summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-18 20:59:46 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-18 20:59:46 (GMT)
commit0e70e81133c25274fe2dd2309556b41357dd759b (patch)
tree9a680b36788ee1ad4e7ecc5ccfeb4494db9fdc72
parentce355c80cf6054bfa5e1dcf81f9e2183ef963ee1 (diff)
parent2ddc75e69db5a3dd379c896d8420c9af20ec1cee (diff)
downloadmonitoring-plugins-0e70e81133c25274fe2dd2309556b41357dd759b.tar.gz
Merge branch 'master' into mysql_detect_mysqldumprefs/pull/1718/head
-rw-r--r--.github/NPTest.cache5
-rw-r--r--.github/dependabot.yml11
-rwxr-xr-x.github/prepare_debian.sh92
-rw-r--r--.github/workflows/codeql-analysis.yml73
-rw-r--r--.github/workflows/test.yml41
-rw-r--r--.gitignore11
-rw-r--r--ACKNOWLEDGEMENTS2
-rw-r--r--AUTHORS2
-rw-r--r--NEWS167
-rw-r--r--NPTest.pm6
-rw-r--r--ROADMAP14
-rw-r--r--THANKS.in25
-rwxr-xr-xbuild-aux/config.rpath22
-rw-r--r--build-aux/ltmain.sh6
-rw-r--r--build-aux/snippet/_Noreturn.h10
-rw-r--r--build-aux/snippet/warn-on-use.h109
-rw-r--r--config_test/child_test.c2
-rw-r--r--configure.ac176
-rw-r--r--doc/RELEASING.md12
-rw-r--r--doc/developer-guidelines.sgml167
-rw-r--r--gl/Makefile.am2392
-rw-r--r--gl/_Noreturn.h50
-rw-r--r--gl/af_alg.c213
-rw-r--r--gl/af_alg.h115
-rw-r--r--gl/alloca.in.h35
-rw-r--r--gl/arg-nonnull.h (renamed from build-aux/snippet/arg-nonnull.h)14
-rw-r--r--gl/arpa_inet.in.h32
-rw-r--r--gl/asnprintf.c18
-rw-r--r--gl/asprintf.c18
-rw-r--r--gl/assert.in.h27
-rw-r--r--gl/attribute.h226
-rw-r--r--gl/base64.c126
-rw-r--r--gl/base64.h41
-rw-r--r--gl/basename-lgpl.c37
-rw-r--r--gl/basename-lgpl.h78
-rw-r--r--gl/basename.c56
-rw-r--r--gl/btowc.c18
-rw-r--r--gl/byteswap.in.h44
-rw-r--r--gl/c++defs.h (renamed from build-aux/snippet/c++defs.h)130
-rw-r--r--gl/calloc.c55
-rw-r--r--gl/cdefs.h707
-rw-r--r--gl/cloexec.c83
-rw-r--r--gl/cloexec.h34
-rw-r--r--gl/close.c75
-rw-r--r--gl/config.charset684
-rw-r--r--gl/dirname-lgpl.c18
-rw-r--r--gl/dirname.c6
-rw-r--r--gl/dirname.h55
-rw-r--r--gl/dosname.h53
-rw-r--r--gl/dup2.c189
-rw-r--r--gl/dynarray.h284
-rw-r--r--gl/errno.in.h22
-rw-r--r--gl/error.c74
-rw-r--r--gl/error.h45
-rw-r--r--gl/exitfail.c18
-rw-r--r--gl/exitfail.h18
-rw-r--r--gl/fcntl.c629
-rw-r--r--gl/fcntl.in.h445
-rw-r--r--gl/fd-hook.c22
-rw-r--r--gl/fd-hook.h22
-rw-r--r--gl/fflush.c233
-rw-r--r--gl/filename.h112
-rw-r--r--gl/float+.h18
-rw-r--r--gl/float.c18
-rw-r--r--gl/float.in.h30
-rw-r--r--gl/floor.c20
-rw-r--r--gl/floorf.c18
-rw-r--r--gl/fopen.c229
-rw-r--r--gl/fpurge.c150
-rw-r--r--gl/freading.c76
-rw-r--r--gl/freading.h54
-rw-r--r--gl/free.c53
-rw-r--r--gl/fseek.c30
-rw-r--r--gl/fseeko.c164
-rw-r--r--gl/fstat.c94
-rw-r--r--gl/fsusage.c123
-rw-r--r--gl/fsusage.h22
-rw-r--r--gl/ftell.c37
-rw-r--r--gl/ftello.c157
-rw-r--r--gl/full-read.c18
-rw-r--r--gl/full-read.h24
-rw-r--r--gl/full-write.c79
-rw-r--r--gl/gai_strerror.c18
-rw-r--r--gl/getaddrinfo.c180
-rw-r--r--gl/getdelim.c147
-rw-r--r--gl/getdtablesize.c124
-rw-r--r--gl/gethostname.c20
-rw-r--r--gl/getline.c27
-rw-r--r--gl/getloadavg.c179
-rw-r--r--gl/getopt-cdefs.in.h66
-rw-r--r--gl/getopt-core.h96
-rw-r--r--gl/getopt-ext.h77
-rw-r--r--gl/getopt-pfx-core.h66
-rw-r--r--gl/getopt-pfx-ext.h70
-rw-r--r--gl/getopt.c1442
-rw-r--r--gl/getopt.in.h242
-rw-r--r--gl/getopt1.c179
-rw-r--r--gl/getopt_int.h91
-rw-r--r--gl/getprogname.c302
-rw-r--r--gl/getprogname.h40
-rw-r--r--gl/gettext.h50
-rw-r--r--gl/gl_openssl.h116
-rw-r--r--gl/glthread/lock.c866
-rw-r--r--gl/glthread/lock.h544
-rw-r--r--gl/glthread/threadlib.c55
-rw-r--r--gl/hard-locale.c35
-rw-r--r--gl/hard-locale.h26
-rw-r--r--gl/ialloc.c21
-rw-r--r--gl/ialloc.h100
-rw-r--r--gl/idpriv-droptemp.c14
-rw-r--r--gl/idpriv.h12
-rw-r--r--gl/idx.h134
-rw-r--r--gl/inet_ntop.c20
-rw-r--r--gl/intprops-internal.h392
-rw-r--r--gl/intprops.h250
-rw-r--r--gl/inttypes.in.h1002
-rw-r--r--gl/itold.c18
-rw-r--r--gl/langinfo.in.h66
-rw-r--r--gl/lc-charset-dispatch.c82
-rw-r--r--gl/lc-charset-dispatch.h40
-rw-r--r--gl/libc-config.h202
-rw-r--r--gl/limits.in.h131
-rw-r--r--gl/localcharset.c1309
-rw-r--r--gl/localcharset.h119
-rw-r--r--gl/locale.in.h121
-rw-r--r--gl/localeconv.c18
-rw-r--r--gl/lseek.c89
-rw-r--r--gl/m4/00gnulib.m491
-rw-r--r--gl/m4/__inline.m422
-rw-r--r--gl/m4/absolute-header.m4100
-rw-r--r--gl/m4/af_alg.m457
-rw-r--r--gl/m4/alloca.m453
-rw-r--r--gl/m4/arpa_inet_h.m435
-rw-r--r--gl/m4/assert_h.m467
-rw-r--r--gl/m4/base64.m42
-rw-r--r--gl/m4/btowc.m433
-rw-r--r--gl/m4/builtin-expect.m449
-rw-r--r--gl/m4/byteswap.m417
-rw-r--r--gl/m4/c-bool.m451
-rw-r--r--gl/m4/calloc.m483
-rw-r--r--gl/m4/close.m435
-rw-r--r--gl/m4/codeset.m43
-rw-r--r--gl/m4/configmake.m450
-rw-r--r--gl/m4/dirname.m419
-rw-r--r--gl/m4/double-slash-root.m42
-rw-r--r--gl/m4/dup2.m4105
-rw-r--r--gl/m4/eealloc.m42
-rw-r--r--gl/m4/environ.m423
-rw-r--r--gl/m4/errno_h.m420
-rw-r--r--gl/m4/error.m48
-rw-r--r--gl/m4/exponentd.m42
-rw-r--r--gl/m4/extensions.m4214
-rw-r--r--gl/m4/extern-inline.m496
-rw-r--r--gl/m4/fcntl-o.m422
-rw-r--r--gl/m4/fcntl.m4151
-rw-r--r--gl/m4/fcntl_h.m470
-rw-r--r--gl/m4/fflush.m4100
-rw-r--r--gl/m4/float_h.m454
-rw-r--r--gl/m4/floorf.m418
-rw-r--r--gl/m4/fopen.m4149
-rw-r--r--gl/m4/fpurge.m473
-rw-r--r--gl/m4/freading.m4 (renamed from gl/m4/sha1.m4)11
-rw-r--r--gl/m4/free.m452
-rw-r--r--gl/m4/fseek.m415
-rw-r--r--gl/m4/fseeko.m477
-rw-r--r--gl/m4/fstat.m440
-rw-r--r--gl/m4/fstypename.m42
-rw-r--r--gl/m4/fsusage.m4363
-rw-r--r--gl/m4/ftell.m415
-rw-r--r--gl/m4/ftello.m4151
-rw-r--r--gl/m4/getaddrinfo.m443
-rw-r--r--gl/m4/getdelim.m4111
-rw-r--r--gl/m4/getdtablesize.m463
-rw-r--r--gl/m4/gethostname.m48
-rw-r--r--gl/m4/getline.m4109
-rw-r--r--gl/m4/getloadavg.m417
-rw-r--r--gl/m4/getopt.m439
-rw-r--r--gl/m4/getprogname.m443
-rw-r--r--gl/m4/gettext.m4401
-rw-r--r--gl/m4/gl-openssl.m476
-rw-r--r--gl/m4/glibc2.m431
-rw-r--r--gl/m4/glibc21.m434
-rw-r--r--gl/m4/gnulib-cache.m444
-rw-r--r--gl/m4/gnulib-common.m41022
-rw-r--r--gl/m4/gnulib-comp.m4885
-rw-r--r--gl/m4/gnulib-tool.m410
-rw-r--r--gl/m4/hostent.m48
-rw-r--r--gl/m4/iconv.m4268
-rw-r--r--gl/m4/idpriv.m42
-rw-r--r--gl/m4/include_next.m490
-rw-r--r--gl/m4/inet_ntop.m416
-rw-r--r--gl/m4/intdiv0.m487
-rw-r--r--gl/m4/intl.m4271
-rw-r--r--gl/m4/intldir.m419
-rw-r--r--gl/m4/intlmacosx.m456
-rw-r--r--gl/m4/intmax.m436
-rw-r--r--gl/m4/intmax_t.m416
-rw-r--r--gl/m4/inttypes-pri.m442
-rw-r--r--gl/m4/inttypes.m4180
-rw-r--r--gl/m4/inttypes_h.m42
-rw-r--r--gl/m4/langinfo_h.m448
-rw-r--r--gl/m4/largefile.m4378
-rw-r--r--gl/m4/lcmessage.m435
-rw-r--r--gl/m4/lib-ld.m4119
-rw-r--r--gl/m4/lib-link.m4777
-rw-r--r--gl/m4/lib-prefix.m4224
-rw-r--r--gl/m4/limits-h.m441
-rw-r--r--gl/m4/localcharset.m410
-rw-r--r--gl/m4/locale-fr.m443
-rw-r--r--gl/m4/locale-ja.m445
-rw-r--r--gl/m4/locale-zh.m445
-rw-r--r--gl/m4/locale_h.m4134
-rw-r--r--gl/m4/localeconv.m42
-rw-r--r--gl/m4/lock.m411
-rw-r--r--gl/m4/longlong.m4113
-rw-r--r--gl/m4/ls-mntd-fs.m4357
-rw-r--r--gl/m4/lseek.m478
-rw-r--r--gl/m4/malloc.m4173
-rw-r--r--gl/m4/malloca.m45
-rw-r--r--gl/m4/math_h.m4560
-rw-r--r--gl/m4/mbrtowc.m4358
-rw-r--r--gl/m4/mbsinit.m415
-rw-r--r--gl/m4/mbstate_t.m413
-rw-r--r--gl/m4/mbtowc.m413
-rw-r--r--gl/m4/memchr.m474
-rw-r--r--gl/m4/minmax.m444
-rw-r--r--gl/m4/mktime.m4142
-rw-r--r--gl/m4/mmap-anon.m48
-rw-r--r--gl/m4/mode_t.m426
-rw-r--r--gl/m4/mountlist.m4331
-rw-r--r--gl/m4/msvc-inval.m42
-rw-r--r--gl/m4/msvc-nothrow.m42
-rw-r--r--gl/m4/multiarch.m469
-rw-r--r--gl/m4/netdb_h.m428
-rw-r--r--gl/m4/netinet_in_h.m410
-rw-r--r--gl/m4/nl_langinfo.m437
-rw-r--r--gl/m4/nls.m432
-rw-r--r--gl/m4/nocrash.m413
-rw-r--r--gl/m4/off_t.m42
-rw-r--r--gl/m4/onceonly.m4104
-rw-r--r--gl/m4/open-cloexec.m421
-rw-r--r--gl/m4/open-slash.m460
-rw-r--r--gl/m4/open.m456
-rw-r--r--gl/m4/pathmax.m442
-rw-r--r--gl/m4/pid_t.m438
-rw-r--r--gl/m4/po.m4453
-rw-r--r--gl/m4/printf-posix.m448
-rw-r--r--gl/m4/printf.m4490
-rw-r--r--gl/m4/progtest.m491
-rw-r--r--gl/m4/pthread_rwlock_rdlock.m4185
-rw-r--r--gl/m4/read.m426
-rw-r--r--gl/m4/realloc.m463
-rw-r--r--gl/m4/reallocarray.m423
-rw-r--r--gl/m4/regex.m4193
-rw-r--r--gl/m4/safe-read.m412
-rw-r--r--gl/m4/servent.m48
-rw-r--r--gl/m4/setenv.m476
-rw-r--r--gl/m4/setlocale_null.m498
-rw-r--r--gl/m4/sha256.m414
-rw-r--r--gl/m4/size_max.m416
-rw-r--r--gl/m4/snprintf.m412
-rw-r--r--gl/m4/socketlib.m438
-rw-r--r--gl/m4/sockets.m42
-rw-r--r--gl/m4/socklen.m417
-rw-r--r--gl/m4/sockpfaf.m423
-rw-r--r--gl/m4/ssize_t.m42
-rw-r--r--gl/m4/stat-time.m483
-rw-r--r--gl/m4/stat.m485
-rw-r--r--gl/m4/std-gnu11.m4829
-rw-r--r--gl/m4/stdalign.m4121
-rw-r--r--gl/m4/stdbool.m4100
-rw-r--r--gl/m4/stddef_h.m481
-rw-r--r--gl/m4/stdint.m4169
-rw-r--r--gl/m4/stdint_h.m42
-rw-r--r--gl/m4/stdio_h.m4229
-rw-r--r--gl/m4/stdlib_h.m4173
-rw-r--r--gl/m4/strcase.m48
-rw-r--r--gl/m4/strcasestr.m461
-rw-r--r--gl/m4/strerror.m430
-rw-r--r--gl/m4/string_h.m4150
-rw-r--r--gl/m4/strings_h.m440
-rw-r--r--gl/m4/strndup.m455
-rw-r--r--gl/m4/strnlen.m430
-rw-r--r--gl/m4/strsep.m46
-rw-r--r--gl/m4/strstr.m467
-rw-r--r--gl/m4/sys_socket_h.m488
-rw-r--r--gl/m4/sys_stat_h.m4129
-rw-r--r--gl/m4/sys_types_h.m450
-rw-r--r--gl/m4/sys_uio_h.m425
-rw-r--r--gl/m4/threadlib.m4667
-rw-r--r--gl/m4/time_h.m4114
-rw-r--r--gl/m4/time_r.m449
-rw-r--r--gl/m4/timegm.m410
-rw-r--r--gl/m4/uintmax_t.m430
-rw-r--r--gl/m4/ungetc.m473
-rw-r--r--gl/m4/unistd_h.m4348
-rw-r--r--gl/m4/unlocked-io.m436
-rw-r--r--gl/m4/vararrays.m472
-rw-r--r--gl/m4/vasnprintf.m417
-rw-r--r--gl/m4/vasprintf.m42
-rw-r--r--gl/m4/visibility.m479
-rw-r--r--gl/m4/vsnprintf.m412
-rw-r--r--gl/m4/warn-on-use.m461
-rw-r--r--gl/m4/wchar_h.m4222
-rw-r--r--gl/m4/wchar_t.m42
-rw-r--r--gl/m4/wcrtomb.m490
-rw-r--r--gl/m4/wctype_h.m499
-rw-r--r--gl/m4/wint_t.m449
-rw-r--r--gl/m4/xalloc.m42
-rw-r--r--gl/m4/xsize.m42
-rw-r--r--gl/m4/xstrndup.m415
-rw-r--r--gl/m4/zzgnulib.m423
-rw-r--r--gl/malloc.c43
-rw-r--r--gl/malloc/dynarray-skeleton.c528
-rw-r--r--gl/malloc/dynarray.h177
-rw-r--r--gl/malloc/dynarray_at_failure.c40
-rw-r--r--gl/malloc/dynarray_emplace_enlarge.c77
-rw-r--r--gl/malloc/dynarray_finalize.c66
-rw-r--r--gl/malloc/dynarray_resize.c68
-rw-r--r--gl/malloc/dynarray_resize_clear.c39
-rw-r--r--gl/malloca.c165
-rw-r--r--gl/malloca.h69
-rw-r--r--gl/malloca.valgrind7
-rw-r--r--gl/math.c19
-rw-r--r--gl/math.in.h722
-rw-r--r--gl/mbrtowc-impl-utf8.h138
-rw-r--r--gl/mbrtowc-impl.h262
-rw-r--r--gl/mbrtowc.c393
-rw-r--r--gl/mbsinit.c52
-rw-r--r--gl/mbtowc-impl.h18
-rw-r--r--gl/mbtowc-lock.c150
-rw-r--r--gl/mbtowc-lock.h125
-rw-r--r--gl/mbtowc.c18
-rw-r--r--gl/memchr.c26
-rw-r--r--gl/memchr.valgrind16
-rw-r--r--gl/minmax.h60
-rw-r--r--gl/mktime-internal.h83
-rw-r--r--gl/mktime.c837
-rw-r--r--gl/mountlist.c486
-rw-r--r--gl/mountlist.h14
-rw-r--r--gl/msvc-inval.c18
-rw-r--r--gl/msvc-inval.h22
-rw-r--r--gl/msvc-nothrow.c22
-rw-r--r--gl/msvc-nothrow.h20
-rw-r--r--gl/netdb.in.h72
-rw-r--r--gl/netinet_in.in.h18
-rw-r--r--gl/nl_langinfo-lock.c150
-rw-r--r--gl/nl_langinfo.c579
-rw-r--r--gl/open.c209
-rw-r--r--gl/pathmax.h83
-rw-r--r--gl/printf-args.c22
-rw-r--r--gl/printf-args.h30
-rw-r--r--gl/printf-parse.c55
-rw-r--r--gl/printf-parse.h18
-rw-r--r--gl/read.c85
-rw-r--r--gl/realloc.c63
-rw-r--r--gl/reallocarray.c38
-rw-r--r--gl/ref-add.sin29
-rw-r--r--gl/ref-del.sin24
-rw-r--r--gl/regcomp.c1364
-rw-r--r--gl/regex.c21
-rw-r--r--gl/regex.h142
-rw-r--r--gl/regex_internal.c394
-rw-r--r--gl/regex_internal.h299
-rw-r--r--gl/regexec.c1169
-rw-r--r--gl/safe-read.c77
-rw-r--r--gl/safe-read.h47
-rw-r--r--gl/setenv.c20
-rw-r--r--gl/setlocale-lock.c150
-rw-r--r--gl/setlocale_null.c411
-rw-r--r--gl/setlocale_null.h82
-rw-r--r--gl/sha1.c426
-rw-r--r--gl/sha1.h91
-rw-r--r--gl/sha256-stream.c145
-rw-r--r--gl/sha256.c432
-rw-r--r--gl/sha256.h121
-rw-r--r--gl/size_max.h18
-rw-r--r--gl/snprintf.c18
-rw-r--r--gl/sockets.c33
-rw-r--r--gl/sockets.h46
-rw-r--r--gl/stat-time.c21
-rw-r--r--gl/stat-time.h251
-rw-r--r--gl/stat-w32.c460
-rw-r--r--gl/stat-w32.h37
-rw-r--r--gl/stat.c438
-rw-r--r--gl/stdalign.in.h78
-rw-r--r--gl/stdbool.in.h132
-rw-r--r--gl/stdckdint.in.h35
-rw-r--r--gl/stddef.in.h111
-rw-r--r--gl/stdint.in.h834
-rw-r--r--gl/stdio-impl.h218
-rw-r--r--gl/stdio-read.c168
-rw-r--r--gl/stdio-write.c206
-rw-r--r--gl/stdio.in.h715
-rw-r--r--gl/stdlib.in.h763
-rw-r--r--gl/str-two-way.h30
-rw-r--r--gl/strcasecmp.c20
-rw-r--r--gl/strcasestr.c19
-rw-r--r--gl/streq.h22
-rw-r--r--gl/strerror-override.c104
-rw-r--r--gl/strerror-override.h21
-rw-r--r--gl/strerror.c24
-rw-r--r--gl/string.in.h467
-rw-r--r--gl/strings.in.h18
-rw-r--r--gl/stripslash.c18
-rw-r--r--gl/strncasecmp.c20
-rw-r--r--gl/strndup.c36
-rw-r--r--gl/strnlen.c30
-rw-r--r--gl/strsep.c18
-rw-r--r--gl/strstr.c24
-rw-r--r--gl/sys-limits.h42
-rw-r--r--gl/sys_socket.c19
-rw-r--r--gl/sys_socket.in.h138
-rw-r--r--gl/sys_stat.in.h954
-rw-r--r--gl/sys_types.in.h77
-rw-r--r--gl/sys_uio.in.h18
-rw-r--r--gl/time.in.h273
-rw-r--r--gl/time_r.c18
-rw-r--r--gl/timegm.c62
-rw-r--r--gl/unistd.c19
-rw-r--r--gl/unistd.in.h997
-rw-r--r--gl/unlocked-io.h136
-rw-r--r--gl/unsetenv.c18
-rw-r--r--gl/vasnprintf.c932
-rw-r--r--gl/vasnprintf.h41
-rw-r--r--gl/vasprintf.c18
-rw-r--r--gl/verify.h191
-rw-r--r--gl/vsnprintf.c18
-rw-r--r--gl/w32sock.h24
-rw-r--r--gl/warn-on-use.h149
-rw-r--r--gl/wchar.in.h571
-rw-r--r--gl/wcrtomb.c49
-rw-r--r--gl/wctype-h.c19
-rw-r--r--gl/wctype.in.h457
-rw-r--r--gl/windows-initguard.h35
-rw-r--r--gl/windows-mutex.c95
-rw-r--r--gl/windows-mutex.h51
-rw-r--r--gl/windows-once.c62
-rw-r--r--gl/windows-once.h47
-rw-r--r--gl/windows-recmutex.c127
-rw-r--r--gl/windows-recmutex.h57
-rw-r--r--gl/windows-rwlock.c377
-rw-r--r--gl/windows-rwlock.h68
-rw-r--r--gl/xalloc-die.c6
-rw-r--r--gl/xalloc-oversized.h79
-rw-r--r--gl/xalloc.h231
-rw-r--r--gl/xmalloc.c306
-rw-r--r--gl/xsize.c18
-rw-r--r--gl/xsize.h44
-rw-r--r--gl/xstrndup.c36
-rw-r--r--gl/xstrndup.h23
-rw-r--r--lib/parse_ini.c4
-rw-r--r--lib/tests/Makefile.am2
-rw-r--r--lib/tests/test_cmd.c14
-rw-r--r--lib/tests/test_disk.c4
-rwxr-xr-xlib/tests/test_ini3.t2
-rwxr-xr-xlib/tests/test_opts3.t2
-rw-r--r--lib/tests/test_utils.c8
-rw-r--r--lib/utils_base.c18
-rw-r--r--lib/utils_base.h3
-rw-r--r--lib/utils_cmd.c2
-rw-r--r--lib/utils_disk.c34
-rw-r--r--lib/utils_disk.h1
-rw-r--r--m4/np_mysqlclient.m42
-rw-r--r--m4/uriparser.m42
-rwxr-xr-xpkg/solaris/solpkg2
-rw-r--r--plugins-root/Makefile.am2
-rw-r--r--plugins-root/check_dhcp.c16
-rw-r--r--plugins-root/check_icmp.c152
-rw-r--r--plugins-root/pst3.c2
-rw-r--r--plugins-root/t/check_icmp.t13
-rw-r--r--plugins-scripts/Makefile.am4
-rwxr-xr-xplugins-scripts/check_breeze.pl3
-rw-r--r--[-rwxr-xr-x]plugins-scripts/check_disk_smb.pl23
-rwxr-xr-xplugins-scripts/check_file_age.pl2
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl8
-rwxr-xr-xplugins-scripts/check_ifstatus.pl2
-rwxr-xr-xplugins-scripts/check_ircd.pl4
-rwxr-xr-xplugins-scripts/check_log.sh168
-rwxr-xr-xplugins-scripts/check_mailq.pl84
-rwxr-xr-xplugins-scripts/check_oracle.sh244
-rwxr-xr-xplugins-scripts/check_rpc.pl2
-rwxr-xr-xplugins-scripts/check_sensors.sh34
-rwxr-xr-xplugins-scripts/check_uptime.pl19
-rwxr-xr-xplugins-scripts/check_wave.pl15
-rw-r--r--plugins-scripts/t/check_log.t82
-rw-r--r--plugins-scripts/t/check_uptime.t22
-rw-r--r--plugins-scripts/utils.pm.in1
-rw-r--r--plugins/Makefile.am6
-rw-r--r--plugins/check_apt.c72
-rw-r--r--plugins/check_by_ssh.c32
-rw-r--r--plugins/check_curl.c591
-rw-r--r--plugins/check_dbi.c14
-rw-r--r--plugins/check_disk.c243
-rw-r--r--plugins/check_dns.c2
-rw-r--r--plugins/check_fping.c40
-rw-r--r--plugins/check_game.c2
-rw-r--r--plugins/check_hpjd.c18
-rw-r--r--plugins/check_http.c374
-rw-r--r--plugins/check_ldap.c7
-rw-r--r--plugins/check_load.c124
-rw-r--r--plugins/check_mysql.c7
-rw-r--r--plugins/check_nt.c2
-rw-r--r--plugins/check_ntp.c18
-rw-r--r--plugins/check_ntp_peer.c12
-rw-r--r--plugins/check_ntp_time.c2
-rw-r--r--plugins/check_nwstat.c2
-rw-r--r--plugins/check_pgsql.c79
-rw-r--r--plugins/check_ping.c69
-rw-r--r--plugins/check_procs.c103
-rw-r--r--plugins/check_radius.c8
-rw-r--r--plugins/check_real.c4
-rw-r--r--plugins/check_smtp.c104
-rw-r--r--plugins/check_snmp.c216
-rw-r--r--plugins/check_swap.c93
-rw-r--r--plugins/check_tcp.c2
-rw-r--r--plugins/check_ups.c21
-rw-r--r--plugins/check_users.c37
-rw-r--r--plugins/picohttpparser/picohttpparser.c34
-rw-r--r--plugins/picohttpparser/picohttpparser.h4
-rw-r--r--plugins/popen.c2
-rw-r--r--plugins/runcmd.c4
-rw-r--r--plugins/sslutils.c34
-rw-r--r--plugins/t/check_by_ssh.t18
-rw-r--r--plugins/t/check_curl.t46
-rw-r--r--plugins/t/check_disk.t39
-rw-r--r--plugins/t/check_http.t16
-rw-r--r--plugins/t/check_load.t15
-rw-r--r--plugins/t/check_mysql.t6
-rw-r--r--plugins/t/check_mysql_query.t2
-rw-r--r--plugins/t/check_nagios.t2
-rw-r--r--plugins/t/check_smtp.t40
-rw-r--r--plugins/t/check_snmp.t68
-rw-r--r--plugins/t/negate.t2
-rw-r--r--plugins/tests/certs/.gitignore2
-rw-r--r--plugins/tests/certs/client-cert.pem22
-rw-r--r--plugins/tests/certs/client-key.pem28
-rw-r--r--plugins/tests/certs/clientca-cert.pem25
-rw-r--r--plugins/tests/certs/clientca-key.pem28
-rw-r--r--plugins/tests/certs/clientchain-cert.pem45
-rw-r--r--plugins/tests/certs/clientchain-key.pem28
-rw-r--r--plugins/tests/certs/clientintermediate-cert.pem23
-rw-r--r--plugins/tests/certs/clientintermediate-key.pem28
-rw-r--r--plugins/tests/certs/expired-cert.pem32
-rw-r--r--plugins/tests/certs/expired-key.pem52
-rw-r--r--plugins/tests/certs/ext.cnf2
-rwxr-xr-xplugins/tests/certs/generate-certs.sh63
-rw-r--r--plugins/tests/certs/server-cert.pem44
-rw-r--r--plugins/tests/certs/server-key.pem52
-rwxr-xr-xplugins/tests/check_curl.t31
-rwxr-xr-xplugins/tests/check_http.t341
-rwxr-xr-xplugins/tests/check_procs.t32
-rwxr-xr-xplugins/tests/check_snmp.t41
-rw-r--r--plugins/tests/check_snmp_agent.pl8
-rw-r--r--plugins/tests/var/ps-axwo.debian219
-rw-r--r--plugins/tests/var/ps_axwo.debian84
-rw-r--r--plugins/utils.c30
-rw-r--r--plugins/utils.h2
-rw-r--r--po/Makevars2
-rw-r--r--po/de.po2211
-rw-r--r--po/fr.po2103
-rw-r--r--po/monitoring-plugins.pot1949
-rw-r--r--tap/tap.34
-rw-r--r--tap/tap.h2
-rwxr-xr-xtools/build_perl_modules6
-rw-r--r--tools/p1.pl2
-rwxr-xr-xtools/tinderbox_build2
567 files changed, 46595 insertions, 25649 deletions
diff --git a/.github/NPTest.cache b/.github/NPTest.cache
index 232305a..d488d1b 100644
--- a/.github/NPTest.cache
+++ b/.github/NPTest.cache
@@ -25,8 +25,9 @@
25 'NP_HOST_TCP_POP' => 'pop.web.de', 25 'NP_HOST_TCP_POP' => 'pop.web.de',
26 'NP_HOST_TCP_PROXY' => 'localhost', 26 'NP_HOST_TCP_PROXY' => 'localhost',
27 'NP_HOST_TCP_SMTP' => 'localhost', 27 'NP_HOST_TCP_SMTP' => 'localhost',
28 'NP_HOST_TCP_SMTP_NOTLS' => '', 28 'NP_HOST_TCP_SMTP_NOSTARTTLS' => '',
29 'NP_HOST_TCP_SMTP_TLS' => '', 29 'NP_HOST_TCP_SMTP_STARTTLS' => 'localhost',
30 'NP_HOST_TCP_SMTP_TLS' => 'localhost',
30 'NP_HOST_TLS_CERT' => 'localhost', 31 'NP_HOST_TLS_CERT' => 'localhost',
31 'NP_HOST_TLS_HTTP' => 'localhost', 32 'NP_HOST_TLS_HTTP' => 'localhost',
32 'NP_HOST_UDP_TIME' => 'none', 33 'NP_HOST_UDP_TIME' => 'none',
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..0707364
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,11 @@
1---
2version: 2
3updates:
4 - package-ecosystem: github-actions
5 directory: "/"
6 schedule:
7 interval: daily
8 time: "04:00"
9 pull-request-branch-name:
10 separator: "-"
11 open-pull-requests-limit: 10
diff --git a/.github/prepare_debian.sh b/.github/prepare_debian.sh
index 4021c10..dcf778b 100755
--- a/.github/prepare_debian.sh
+++ b/.github/prepare_debian.sh
@@ -5,27 +5,63 @@ set -e
5 5
6export DEBIAN_FRONTEND=noninteractive 6export DEBIAN_FRONTEND=noninteractive
7 7
8apt-get update 8source /etc/os-release
9apt-get -y install software-properties-common 9
10if [ $(lsb_release -is) = "Debian" ]; then 10if [ ${ID} = "debian" ]; then
11 apt-add-repository non-free 11 if [ -f /etc/apt/sources.list.d/debian.sources ]; then
12 apt-get update 12 sed "s/main/non-free contrib/g" /etc/apt/sources.list.d/debian.sources > /etc/apt/sources.list.d/debian-nonfree.sources
13 else
14 apt-get update
15 apt-get -y install software-properties-common
16 apt-add-repository non-free
17 fi
13fi 18fi
14apt-get -y install perl autotools-dev libdbi-dev libldap2-dev libpq-dev libradcli-dev libnet-snmp-perl procps 19apt-get update
15apt-get -y install libdbi0-dev libdbd-sqlite3 libssl-dev dnsutils snmp-mibs-downloader libsnmp-perl snmpd 20apt-get -y install perl \
16apt-get -y install fping snmp netcat-openbsd smbclient vsftpd apache2 ssl-cert postfix libhttp-daemon-ssl-perl 21 autotools-dev \
17apt-get -y install libdbd-sybase-perl libnet-dns-perl 22 libdbi-dev \
18apt-get -y install slapd ldap-utils 23 libldap2-dev \
19apt-get -y install gcc make autoconf automake gettext 24 libpq-dev \
20apt-get -y install faketime 25 libradcli-dev \
21apt-get -y install libmonitoring-plugin-perl 26 libnet-snmp-perl \
22apt-get -y install libcurl4-openssl-dev 27 procps \
23apt-get -y install liburiparser-dev 28 libdbi0-dev \
24apt-get -y install squid 29 libdbd-sqlite3 \
25apt-get -y install openssh-server 30 libssl-dev \
26apt-get -y install mariadb-server mariadb-client libmariadb-dev 31 dnsutils \
27apt-get -y install cron iputils-ping 32 snmp-mibs-downloader \
28apt-get -y install iproute2 33 libsnmp-perl \
34 snmpd \
35 fping \
36 snmp \
37 netcat-openbsd \
38 smbclient \
39 vsftpd \
40 apache2 \
41 ssl-cert \
42 postfix \
43 libhttp-daemon-ssl-perl \
44 libdbd-sybase-perl \
45 libnet-dns-perl \
46 slapd \
47 ldap-utils \
48 gcc \
49 make \
50 autoconf \
51 automake \
52 gettext \
53 faketime \
54 libmonitoring-plugin-perl \
55 libcurl4-openssl-dev \
56 liburiparser-dev \
57 squid \
58 openssh-server \
59 mariadb-server \
60 mariadb-client \
61 libmariadb-dev \
62 cron \
63 iputils-ping \
64 iproute2
29 65
30# remove ipv6 interface from hosts 66# remove ipv6 interface from hosts
31if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then 67if [ $(ip addr show | grep "inet6 ::1" | wc -l) -eq "0" ]; then
@@ -37,7 +73,6 @@ ip addr show
37 73
38cat /etc/hosts 74cat /etc/hosts
39 75
40
41# apache 76# apache
42a2enmod ssl 77a2enmod ssl
43a2ensite default-ssl 78a2ensite default-ssl
@@ -53,7 +88,7 @@ cp tools/squid.conf /etc/squid/squid.conf
53service squid start 88service squid start
54 89
55# mariadb 90# mariadb
56service mariadb start 91service mariadb start || service mysql start
57mysql -e "create database IF NOT EXISTS test;" -uroot 92mysql -e "create database IF NOT EXISTS test;" -uroot
58 93
59# ldap 94# ldap
@@ -73,12 +108,7 @@ ssh -tt localhost </dev/null >/dev/null 2>/dev/null &
73disown %1 108disown %1
74 109
75# snmpd 110# snmpd
76for DIR in /usr/share/snmp/mibs /usr/share/mibs; do 111service snmpd stop
77 rm -f $DIR/ietf/SNMPv2-PDU \
78 $DIR/ietf/IPSEC-SPD-MIB \
79 $DIR/ietf/IPATM-IPMC-MIB \
80 $DIR/iana/IANA-IPPM-METRICS-REGISTRY-MIB
81done
82mkdir -p /var/lib/snmp/mib_indexes 112mkdir -p /var/lib/snmp/mib_indexes
83sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf 113sed -e 's/^agentaddress.*/agentaddress 127.0.0.1/' -i /etc/snmp/snmpd.conf
84service snmpd start 114service snmpd start
@@ -86,7 +116,11 @@ service snmpd start
86# start cron, will be used by check_nagios 116# start cron, will be used by check_nagios
87cron 117cron
88 118
89# start postfix 119# postfix
120cat <<EOD >> /etc/postfix/master.cf
121smtps inet n - n - - smtpd
122 -o smtpd_tls_wrappermode=yes
123EOD
90service postfix start 124service postfix start
91 125
92# start ftpd 126# start ftpd
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..0317c8c
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,73 @@
1---
2# For most projects, this workflow file will not need changing; you simply need
3# to commit it to your repository.
4#
5# You may wish to alter this file to override the set of languages analyzed,
6# or to provide custom queries or build logic.
7#
8# ******** NOTE ********
9# We have attempted to detect the languages in your repository. Please check
10# the `language` matrix defined below to confirm you have the correct set of
11# supported CodeQL languages.
12#
13name: "CodeQL"
14
15on:
16 push:
17 branches: [master]
18 pull_request:
19 # The branches below must be a subset of the branches above
20 branches: [master]
21 schedule:
22 - cron: '15 18 * * 0'
23
24jobs:
25 analyze:
26 name: Analyze
27 runs-on: ubuntu-latest
28 permissions:
29 actions: read
30 contents: read
31 security-events: write
32
33 strategy:
34 fail-fast: false
35 matrix:
36 language: ['cpp']
37 # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
38 # Learn more:
39 # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
40
41 steps:
42 - name: Checkout repository
43 uses: actions/checkout@v4
44
45 # Initializes the CodeQL tools for scanning.
46 - name: Initialize CodeQL
47 uses: github/codeql-action/init@v2
48 with:
49 languages: ${{ matrix.language }}
50 # If you wish to specify custom queries, you can do so here or in a config file.
51 # By default, queries listed here will override any specified in a config file.
52 # Prefix the list here with "+" to use these queries and those in the config file.
53 # queries: ./path/to/local/query, your-org/your-repo/queries@main
54
55 - name: Install packages
56 run: |
57 sudo apt update
58 sudo apt-get install -y --no-install-recommends m4 gettext automake autoconf make build-essential
59 sudo apt-get install -y --no-install-recommends perl autotools-dev libdbi-dev libldap2-dev libpq-dev \
60 libmysqlclient-dev libradcli-dev libkrb5-dev libdbi0-dev \
61 libdbd-sqlite3 libssl-dev libcurl4-openssl-dev liburiparser-dev
62
63 - name: Configure build
64 run: |
65 ./tools/setup
66 ./configure --enable-libtap
67
68 - name: Build
69 run: |
70 make
71
72 - name: Perform CodeQL Analysis
73 uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0f93930..77b09f4 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,15 +1,48 @@
1---
1name: Test 2name: Test
2 3
3on: 4on:
4 push: 5 push:
5 branches: 6 branches:
6 - '*' 7 - '*'
8 # Run test for any PRs
7 pull_request: 9 pull_request:
8 10
9jobs: 11jobs:
12 codespell:
13 name: codespell
14 strategy:
15 fail-fast: false
16 runs-on: ubuntu-latest
17 steps:
18 - name: Checkout
19 uses: actions/checkout@v4
20 - name: Codespell
21 uses: codespell-project/actions-codespell@v2
22 with:
23 skip: "./.git,./.gitignore,./ABOUT-NLS,*.po,./gl,./po,./tools/squid.conf,./build-aux/ltmain.sh"
24 ignore_words_list: allright,gord,didi,hda,nd,alis,clen,scrit,ser,fot,te,parm,isnt,consol,oneliners
25 check_filenames: true
26 check_hidden: true
27# super-linter:
28# name: super-linter
29# strategy:
30# fail-fast: false
31# runs-on: ubuntu-latest
32# steps:
33# - name: Checkout
34# uses: actions/checkout@v4
35# - name: Lint Code Base
36# uses: github/super-linter@v5.0.0
37# env:
38# DEFAULT_BRANCH: master
39# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10# macos: 40# macos:
11# ... 41# ...
12 linux: 42 linux:
43 needs:
44 - codespell
45# - super-linter
13 runs-on: ubuntu-latest 46 runs-on: ubuntu-latest
14 name: Running tests on ${{ matrix.distro }} 47 name: Running tests on ${{ matrix.distro }}
15 strategy: 48 strategy:
@@ -24,7 +57,7 @@ jobs:
24 #... 57 #...
25 steps: 58 steps:
26 - name: Git clone repository 59 - name: Git clone repository
27 uses: actions/checkout@v2 60 uses: actions/checkout@v4
28 #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate 61 #- name: Setup tmate session, see https://github.com/marketplace/actions/debugging-with-tmate
29 # uses: mxschmitt/action-tmate@v3 62 # uses: mxschmitt/action-tmate@v3
30 - name: Run the tests on ${{ matrix.distro }} 63 - name: Run the tests on ${{ matrix.distro }}
@@ -40,7 +73,11 @@ jobs:
40 ${{ matrix.distro }} \ 73 ${{ matrix.distro }} \
41 /bin/sh -c '${{ matrix.prepare }} && \ 74 /bin/sh -c '${{ matrix.prepare }} && \
42 tools/setup && \ 75 tools/setup && \
43 ./configure --enable-libtap --with-ipv6=no && \ 76 ./configure --enable-libtap --with-ipv6=no && \
77 set -x && \
78 tmp_dir=$(mktemp -d -t test-XXXX) && cp -a po/ $tmp_dir/ && \
79 cd po && make update-po && cd .. && \
80 diff -Nur $tmp_dir/po/*.po po/*.po | tee -a /tmp/po.diff && diff -Nur $tmp_dir/po/*.pot po/*.pot | tee -a /tmp/po.diff && if [ $(wc -l /tmp/po.diff | cut -f 1 -d" ") -gt 0 ]; then echo "Error: Translations needs to be updated with make update-po!" && exit 1; fi && \
44 make && \ 81 make && \
45 make test' 82 make test'
46 docker container prune -f 83 docker container prune -f
diff --git a/.gitignore b/.gitignore
index c7b668e..02ca61e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,10 +53,8 @@ NP-VERSION-FILE
53# /gl/ 53# /gl/
54/gl/.deps 54/gl/.deps
55/gl/alloca.h 55/gl/alloca.h
56/gl/arg-nonnull.h
57/gl/arpa 56/gl/arpa
58/gl/arpa_inet.h 57/gl/arpa_inet.h
59/gl/c++defs.h
60/gl/charset.alias 58/gl/charset.alias
61/gl/configmake.h 59/gl/configmake.h
62/gl/errno.h 60/gl/errno.h
@@ -70,6 +68,8 @@ NP-VERSION-FILE
70/gl/locale.h 68/gl/locale.h
71/gl/Makefile 69/gl/Makefile
72/gl/Makefile.in 70/gl/Makefile.in
71/gl/malloc/.dirstamp
72/gl/malloc/.deps
73/gl/math.h 73/gl/math.h
74/gl/netdb.h 74/gl/netdb.h
75/gl/netinet_in.h 75/gl/netinet_in.h
@@ -88,9 +88,13 @@ NP-VERSION-FILE
88/gl/sys 88/gl/sys
89/gl/time.h 89/gl/time.h
90/gl/unistd.h 90/gl/unistd.h
91/gl/warn-on-use.h
92/gl/wchar.h 91/gl/wchar.h
93/gl/wctype.h 92/gl/wctype.h
93/gl/inttypes.h
94/gl/limits.h
95/gl/malloc/dynarray-skeleton.gl.h
96/gl/malloc/dynarray.gl.h
97/gl/stdckdint.
94 98
95# /lib/ 99# /lib/
96/lib/.deps 100/lib/.deps
@@ -242,6 +246,7 @@ NP-VERSION-FILE
242/plugins-scripts/check_ircd 246/plugins-scripts/check_ircd
243/plugins-scripts/check_log 247/plugins-scripts/check_log
244/plugins-scripts/check_mailq 248/plugins-scripts/check_mailq
249/plugins-scripts/check_mssql
245/plugins-scripts/check_ntp 250/plugins-scripts/check_ntp
246/plugins-scripts/check_oracle 251/plugins-scripts/check_oracle
247/plugins-scripts/check_rpc 252/plugins-scripts/check_rpc
diff --git a/ACKNOWLEDGEMENTS b/ACKNOWLEDGEMENTS
index d73be54..af29c15 100644
--- a/ACKNOWLEDGEMENTS
+++ b/ACKNOWLEDGEMENTS
@@ -20,7 +20,7 @@ Using the DLPI support on SysV systems to get the host MAC address in check_dhcp
20Stenberg, Daniel 20Stenberg, Daniel
21Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se> 21Copyright (c) 1996 - 2004, Daniel Stenberg, <daniel@haxx.se>
22http://curl.haxx.se/ 22http://curl.haxx.se/
23Use of duplication of macros in m4/np_curl.m4 (slighly adapted for m4/uriparser.m4 too) 23Use of duplication of macros in m4/np_curl.m4 (slightly adapted for m4/uriparser.m4 too)
24 24
25Coreutils team 25Coreutils team
26Copyright (C) 91, 1995-2004 Free Software Foundation, Inc. 26Copyright (C) 91, 1995-2004 Free Software Foundation, Inc.
diff --git a/AUTHORS b/AUTHORS
index 2d455be..1b1a036 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -22,3 +22,5 @@ Jan Wagner
22Holger Weiss 22Holger Weiss
23Michael Wirtgen 23Michael Wirtgen
24Oliver Skibbe 24Oliver Skibbe
25Andreas Baumann
26Lorenz Kästle
diff --git a/NEWS b/NEWS
index 3790e8a..9ec3c5e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,153 @@
1This file documents the major additions and syntax changes between releases. 1This file documents the major additions and syntax changes between releases.
2 2
32.4 [...] 32.3.3 2nd Feb 2023
4 ENHANCEMENTS
5 using PRId64 and PRIu64 instead of %ld directly
6 check_http: Make faster with larger files
7 check_snmp: add 'multiplier' to modify current value
8 check_http: Implement chunked encoding decoding
9 check_http/check_curl: add chunked encoding test
10 check_log: Added --exclude to exclude patterns
11 check_log: Add tests
12 check_disk: Clarify usage possibilities
13
14 FIXES
15 fixed two PRId64 to PRIu64 in perfdata_uint64
16 check_pgsql: Removing is_pg_dbname altogether,using postgres API.
17 check_http: Remove superfluous CRLF in HTTP-Requests
18 check_curl: detect ipv6
19 check_icmp: fix parsing help/version long options
20 check_http: fix test plan
21 check_disk: Find accessible mount path if multiple are available
22 check_apt: Fix unknown escape sequence error output
23 check_curl: fix checking large bodys
24 check_snmp: Improve tests for check_snmp & multiply option
25 check_snmp: always apply format when applying multiplier
26 check_http: Use real booleans instead of ints
27 check_http: Document process_arguments a little bit better
28 check_http: Remove dead code
29 check_http: Fix several bug in the implementation of unchunking
30 check_http: Reformat a part to increase readability
31 check_apt: Put upgrade options in the root sections
32 check_apt: Fix comment
33 check_apt: Use real booleans
34 check_mailq: Fixing nullmailer regex
35 check_snmp: Fix regex matches
36 check_log: Fixed a bug when using --all
37 check_log: Cleaned up duplicated code in the args
38 check_http: Fix memory reallocation error in chunk decoding logic
39 check_http: Add space for ending NULL byte in array for chunked encoding
40
412.3.2 20th Oct 2022
42 GENERAL
43 Use netcat-openbsd for debian explicitly (by @RincewindsHat #1704)
44 Replace egrep with grep -E (by @RincewindsHat #1791)
45 Use silent automake by default (by @RincewindsHat #1747)
46
47 SINGLE PLUGINS
48 check_by_ssh: added option to exit with an warning, if there is output on STDERR (by @nafets #1301)
49 check_by_ssh: Add "-U" flag (#1123). (by @archiecobbs #1774)
50 check_by_ssh: Let ssh decide if a host is valid, enables usage of ssh .config file (by @RincewindsHat #1691)
51 check_curl: Add an option to check_curl to verify the peer certificate & host using the system CA's (by @bazzisoft #1669)
52 check_curl: fixed -ffollow for HTTP/2.0 (Fixes #1685): added major_version parsing to PicoHTTPParser (by @andreasbaumann #1742)
53 check_curl: fixes check_curl: "CRITICAL - Cannot retrieve certificate subject." (by @andreasbaumann #1689)
54 check_curl: fix if http header contains leading spaces (by @sni #1666)
55 check_curl: Update check_curl.c to display a specific human-readable error message where possible (by @bazzisoft #1668)
56 check_curl: verify certificates option should not force SSL to be used (by @bazzisoft #1688)
57 check_disk: Description for -M was the wrong way around (by @RincewindsHat #1746)
58 check_disk: Fixing the stuff that is broken on btrfs (by @waja #1388)
59 check_disk: Fix perfdata for big values for check disk (by @RincewindsHat #1714)
60 check_disk_smb: Add configfile feature (by @Napsty #1402)
61 check_disk_smb: Add timeout (by @cdruee #1770)
62 check_dns: Add --expect-nxdomain (by @Jonny007-MKD #1623)
63 check_dns: split multiple IP addresses passed in one -a argument (by @DerDakon #1649)
64 check_file_age: Make size parameter a little bit more intelligible (by @RincewindsHat #1730)
65 check_fping: Implements 'host-alive' mode (Closes. #1027) (by @waja #1740)
66 check_game: Update Url to qstat (by @RincewindsHat #1725)
67 check_http: changed 'STATE_CRITICAL' to 'STATE_WARNING' for infinite loop (by @xFuture603 #1690)
68 check_http: Increase regexp limit (by @hydrapolic #1566)
69 check_http: Support http redirect (by @waja #1449)
70 check_icmp: buffer offerflow (by @RincewindsHat #1733)
71 check_icmp: delay set_source_ip() until address_family is detected (by @ghciv6 #1735)
72 check_icmp: Fix "Invalid Argument" from sendmsg() under FreeBSD 13.1 and "setsockopt failed" for TTL setting (by @eriksejr #1771)
73 check_icmp: Fix pkt perfdata in check_host mode (by @sjoegren #1721)
74 check_ldap: Allows check_ldap to read password from environment variable (by @mullumaus #1724)
75 check_load: add LOAD prefix to load plugin (by @haraldj #1694)
76 check_load: Display total and scaled load values if check_load scales the values (by number of CPUs by @RincewindsHat #1778)
77 check_log: Missing oldlog now aborts check_log (by @RincewindsHat #1732)
78 check_mailq: Add mailq -C option for config dir or config file (by @leeclemens #1490)
79 check_mailq: Check mailq domain specific warnings (by @RincewindsHat #1731)
80 check_mailq: Fix regexp for nullmailer "mailq" output (by @darksoul42 #1493)
81 check_mysql: fix segfaults with mysql-connector-c #1562 (by @ghciv6 #1644)
82 check_pgsql: add --queryname parameter to check_pgsql (by @datamuc #1741)
83 check_ping: Do not show RTA if no connection was possible (by @RincewindsHat #1697)
84 check_ping: understang ping6 output from iputils package (by @glensc #1412)
85 check_proc: Fix check proc ps detection (by @sni #1712)
86 check_procs: exchange needle and haystack in strstr() for proper st… (by @wolfgangkarall #1654)
87 check_smtp: add -L flag to support LMTP (LHLO instead of HELO/EHLO). (by @ghen2 #1715)
88 check_snmp: Added option for null zero length string exit codes (by @FracKenA #1496)
89 check_snmp: fix performance thresholds when using multiple oids (by @sni #1722)
90 check_snmp fix segfaults (by @adrb #1589)
91 check_snmp: put the "c" (to mark a counter) after the perfdata value (by @lausser #1465)
92 check_swap: fix parsing swap values (by @sni #1780)
93 check_swap: Fix perfdata for check swap (by @RincewindsHat #1707)
94 check_swap: Fix unit for total in perfdata (by @RincewindsHat #1779)
95 check_swap: Handle cached swap (by @mdavranche #1642)
96 check_swap: Small fix to threshold validation and style (indentation) fixes (by @RincewindsHat #1723)
97 check_ups: Fix possible overflow in check_ups (by @phibos #1727)
98 check_uptime: Add option to report uptime in days instead of seconds (by @amotl #1750)
99 check_uptime: Fix/improve output message "Uptime is ..." (by @amotl #1751)
100
101 MULTIPLE PLUGINS
102 check_http, check_curl: added --max-redirs=N option (feature #1684) (by @andreasbaumann #1744)
103 check_http, check_curl: Enhancement --continue-after-certificate (backport from nagios-plugins) (by @andreasbaumann #1762)
104 check_http, check_curl: Remove check_http and check_curl test which are somehow always failing (by @RincewindsHat #1777)
105 check_log, check_oracle, check_sensors: Several fixes shellcheck complaining about (by @waja #1459)
106 sslutils: use chain from client certificates (by @tobiaswiese #1664)
107
108 NON FUNCTIONAL CHANGES
109 Trivial source code whitespace formatting fixes to standard. (by @ziesemer #1424)
110 docs: fix simple typo, conspicuosly -> conspicuously (by @timgates42 #1652)
111 Migrate to GitHub actions (by @jacobbaungard #1686)
112 Point to Icinga Exchange instead of dead Monitoring Exchange (by @RincewindsHat #1737)
113 github actions: fix check_users test case (by @sni #1713)
114 Add CodeQL checks (by @phibos #1682)
115 Fix some QL problems (by @RincewindsHat #1729)
116 Update CodeQL and update runner before installing (by @RincewindsHat #1775)
117 check_disk: Check disk compiler warnings (by @RincewindsHat #1758)
118 check_disk: Trivial printf fix and a little bit of code style (by @RincewindsHat #1695)
119 check_http: Docs: make -C obvious (by @stblassitude #1554)
120 check_ifoperstatus: Re-attach a comment to where it actually belongs (by @peternewman #1699)
121 check_ircd: Restrict the nickname length of the test user for check_ircd (by @RincewindsHat #1710)
122 check_load: Check load compiler warnings (by @RincewindsHat #1759)
123 check_log: Modernize check log (by @RincewindsHat #1692)
124 check_mailq: remove duplicate W=i/C=i args in check_mailq.pl (by @ichdasich #1755)
125 check_ntp: Check ntp remove unused variables (by @RincewindsHat #1781)
126 check_pgsql: Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601) (by @waja #1663)
127 check_procs: Fix double percentage sign in usage (by @RincewindsHat #1743)
128 check_sensors.sh: Make shellcheck happier (by @RincewindsHat #1679)
129 check_snmp: Fixed option description authpassword -> authpasswd + whitespaces (by @RincewindsHat #1676)
130 check_swap: Check swap compiler warnings (by @RincewindsHat #1756)
131
1322.3.1 10 April 2021
4 ENHANCEMENTS 133 ENHANCEMENTS
134 check_curl: Add an option to verify the peer certificate & host using the system CA's
5 135
6 FIXES 136 FIXES
137 check_icmp: fix simple typo, conspicuosly -> conspicuously
138 check_curl: fixed help, usage and errors for TLS 1.3
139 check_curl: fixed a potential buffer overflow in url buffer
140 check_dns: split multiple IP addresses passed in one -a argument
141 check_curl: added string_statuscode function for printing HTTP/1.1 and HTTP/2 correctly
142 check_curl: fix crash if http header contains leading spaces
143 check_curl: display a specific human-readable error message where possible
144 check_pgsql: Using snprintf which honors the buffers size and guarantees null termination.
145 check_snmp: put the "c" (to mark a counter) after the perfdata value
146 check_http: Increase regexp limit
147 check_http: make -C obvious
148 check_curl: Increase regexp limit (to 1024 as in check_http)
149 check_curl: make -C obvious (from check_http)
150 check_curl: backported --show-body/-B to print body (from check_http)
7 151
82.3 10th December 2020 1522.3 10th December 2020
9 ENHANCEMENTS 153 ENHANCEMENTS
@@ -21,7 +165,7 @@ This file documents the major additions and syntax changes between releases.
21 check_apt: adding packages-warning option 165 check_apt: adding packages-warning option
22 check_load: Adding top consuming processes option 166 check_load: Adding top consuming processes option
23 check_http: Adding Proxy-Authorization and extra headers 167 check_http: Adding Proxy-Authorization and extra headers
24 check_snmp: make calcualtion of timeout value in help output more clear 168 check_snmp: make calculation of timeout value in help output more clear
25 check_uptime: new plugin for checking uptime to see how long the system is running 169 check_uptime: new plugin for checking uptime to see how long the system is running
26 check_curl: check_http replacement based on libcurl 170 check_curl: check_http replacement based on libcurl
27 check_http: Allow user to specify HTTP method after proxy CONNECT 171 check_http: Allow user to specify HTTP method after proxy CONNECT
@@ -51,7 +195,7 @@ This file documents the major additions and syntax changes between releases.
51 check_procs: improve command examples for 'at least' processes 195 check_procs: improve command examples for 'at least' processes
52 check_swap: repaired "-n" behaviour 196 check_swap: repaired "-n" behaviour
53 check_disk: include -P switch in help 197 check_disk: include -P switch in help
54 check_mailq: restore accidentially removed options 198 check_mailq: restore accidentally removed options
55 199
562.2 29th November 2016 2002.2 29th November 2016
57 ENHANCEMENTS 201 ENHANCEMENTS
@@ -92,7 +236,7 @@ This file documents the major additions and syntax changes between releases.
92 check_ssh now returns CRITICAL for protocol/version errors 236 check_ssh now returns CRITICAL for protocol/version errors
93 If a plugin is invoked with -h/--help or -V/--version, the exit status 237 If a plugin is invoked with -h/--help or -V/--version, the exit status
94 is now UNKNOWN 238 is now UNKNOWN
95 The superseeded check_ntp.pl was removed, please use check_ntp_peer or 239 The superseded check_ntp.pl was removed, please use check_ntp_peer or
96 check_ntp_time instead 240 check_ntp_time instead
97 241
982.1.2 16th October 2015 2422.1.2 16th October 2015
@@ -119,7 +263,7 @@ This file documents the major additions and syntax changes between releases.
119 New check_mysql -n option to ignore authentication failures 263 New check_mysql -n option to ignore authentication failures
120 Added IP and port or socket name to error messages 264 Added IP and port or socket name to error messages
121 New check_ntp_time -o option to add expected offset 265 New check_ntp_time -o option to add expected offset
122 check_disk shows now troubled partions in verbose mode 266 check_disk shows now troubled partitions in verbose mode
123 check_dig has now support for drill and dig 267 check_dig has now support for drill and dig
124 check_dig has now support for -6 option 268 check_dig has now support for -6 option
125 Add performance data to check_file_age 269 Add performance data to check_file_age
@@ -213,10 +357,10 @@ This file documents the major additions and syntax changes between releases.
213 New check_procs -k option to ignore kernel threads (on Linux) 357 New check_procs -k option to ignore kernel threads (on Linux)
214 Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified 358 Let check_procs use /proc/<PID>/exe (if available) instead of getpid(2), unless -T is specified
215 Let check_mysql support SSL 359 Let check_mysql support SSL
216 Let check_mysql add perfromance metrics for all checks 360 Let check_mysql add performance metrics for all checks
217 New check_mysql -f option to specify a client options file 361 New check_mysql -f option to specify a client options file
218 New check_mysql -g option to specify a client options group 362 New check_mysql -g option to specify a client options group
219 New check_snmp --offset option to allow for adding/substracting an offset value to sensor data 363 New check_snmp --offset option to allow for adding/subtracting an offset value to sensor data
220 Let check_snmp support an arbitrary number of OIDs 364 Let check_snmp support an arbitrary number of OIDs
221 Let check_ide_smart support NetBSD 365 Let check_ide_smart support NetBSD
222 366
@@ -231,7 +375,7 @@ This file documents the major additions and syntax changes between releases.
231 Fix deprecated imports of check_nmap.py 375 Fix deprecated imports of check_nmap.py
232 376
233 WARNINGS 377 WARNINGS
234 check_http behaviour of -k/--header changed since it does not seperate multiple headers by semicolons anymore. Use multiple -k switches instead. 378 check_http behaviour of -k/--header changed since it does not separate multiple headers by semicolons anymore. Use multiple -k switches instead.
235 check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way) 379 check_http's --proxy_authorization option is now called --proxy-authorization (it was always documented this way)
236 The contrib directory has been removed from this distribution 380 The contrib directory has been removed from this distribution
237 381
@@ -382,7 +526,7 @@ This file documents the major additions and syntax changes between releases.
382 check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help 526 check_ntp and check_ntp_peer now show proper jitter/stratum thresholds longopts in --help
383 check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers) 527 check_dns now allow to repeat -a to match multiple possibly returned address (common with load balancers)
384 check_mysql and check_radius now try clearing password in processlist just like check_mysql_query 528 check_mysql and check_radius now try clearing password in processlist just like check_mysql_query
385 check_mysql and check_mysql_query now support sockets explicitely (-s, --socket) 529 check_mysql and check_mysql_query now support sockets explicitly (-s, --socket)
386 negate now has the ability to replace the status text as well (-s, --substitute) 530 negate now has the ability to replace the status text as well (-s, --substitute)
387 Added performance data to check_ping 531 Added performance data to check_ping
388 Added support for --extra-opts in all C plugins (disabled by default, see configure --help) 532 Added support for --extra-opts in all C plugins (disabled by default, see configure --help)
@@ -422,7 +566,7 @@ This file documents the major additions and syntax changes between releases.
422 New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too. 566 New check_disk option -L: Only check local filesystems, but call stat() on remote ones, too.
423 Thus accessibility of remote filesystems can be checked without any threshold comparison. 567 Thus accessibility of remote filesystems can be checked without any threshold comparison.
424 Check_disk's --help now prints some examples for the new features introduced in 1.4.8 568 Check_disk's --help now prints some examples for the new features introduced in 1.4.8
425 New check_disk -i/-I option to ignore pathes/partitions based on regular expressions 569 New check_disk -i/-I option to ignore paths/partitions based on regular expressions
426 New check_disk -A option to select all filesystems explicitly 570 New check_disk -A option to select all filesystems explicitly
427 WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments 571 WARNING: check_disk's -E option must now be passed before -p or -r/-R arguments
428 Passing -E after -p or -r results in UNKNOWN state, now 572 Passing -E after -p or -r results in UNKNOWN state, now
@@ -471,7 +615,7 @@ This file documents the major additions and syntax changes between releases.
471 Fixed MKINSTALLDIRS problem in po/ 615 Fixed MKINSTALLDIRS problem in po/
472 ./configure now detects if possible to compile check_mysql 616 ./configure now detects if possible to compile check_mysql
473 Fixed broken HELO in check_smtp 617 Fixed broken HELO in check_smtp
474 check_icmp now allows to set a minimum number of hosts required for successs (-m) 618 check_icmp now allows to set a minimum number of hosts required for success (-m)
475 check_icmp fix for *BSD when running for long time 619 check_icmp fix for *BSD when running for long time
476 check_ping times out 1 second quicker if host is unreachable 620 check_ping times out 1 second quicker if host is unreachable
477 Root plugins installed with world executable 621 Root plugins installed with world executable
@@ -529,4 +673,3 @@ This file documents the major additions and syntax changes between releases.
529 check_swap % thresholds changed to measure amount free, instead of amount used 673 check_swap % thresholds changed to measure amount free, instead of amount used
530 check_disk syntax changes for -p, -m/-M, defaults to MB instead of kB 674 check_disk syntax changes for -p, -m/-M, defaults to MB instead of kB
531 check_procs -C expects no path for the command name 675 check_procs -C expects no path for the command name
532
diff --git a/NPTest.pm b/NPTest.pm
index 4b2de39..9b25ac3 100644
--- a/NPTest.pm
+++ b/NPTest.pm
@@ -151,14 +151,14 @@ of testing against a set of desired exit status values.
151=item * 151=item *
152 152
153Firstly, if C<$desiredExitStatus> is a reference to an array of exit 153Firstly, if C<$desiredExitStatus> is a reference to an array of exit
154stati, if the actual exit status of the command is present in the 154statuses, if the actual exit status of the command is present in the
155array, it is used in the call to C<Test::ok(...)> when testing the 155array, it is used in the call to C<Test::ok(...)> when testing the
156exit status. 156exit status.
157 157
158=item * 158=item *
159 159
160Alternatively, if C<$desiredExitStatus> is a reference to a hash of 160Alternatively, if C<$desiredExitStatus> is a reference to a hash of
161exit stati (mapped to the strings "continue" or "skip"), similar 161exit statuses(mapped to the strings "continue" or "skip"), similar
162processing to the above occurs with the side affect of determining if 162processing to the above occurs with the side affect of determining if
163any generated output testing should proceed. Note: only the string 163any generated output testing should proceed. Note: only the string
164"skip" will result in generated output testing being skipped. 164"skip" will result in generated output testing being skipped.
@@ -207,7 +207,7 @@ under the same terms as the Monitoring Plugins release.
207 207
208my( %CACHE ) = (); 208my( %CACHE ) = ();
209 209
210# I'm not really sure wether to house a site-specific cache inside 210# I'm not really sure whether to house a site-specific cache inside
211# or outside of the extracted source / build tree - lets default to outside 211# or outside of the extracted source / build tree - lets default to outside
212my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} ) 212my( $CACHEFILENAME ) = ( exists( $ENV{'NPTEST_CACHE'} ) && $ENV{'NPTEST_CACHE'} )
213 ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd"; 213 ? $ENV{'NPTEST_CACHE'} : "/var/tmp/NPTest.cache"; # "../Cache.pdd";
diff --git a/ROADMAP b/ROADMAP
index 28f9b31..6378ec7 100644
--- a/ROADMAP
+++ b/ROADMAP
@@ -7,7 +7,7 @@ With that done, it's time to figure out what we are doing for release
71.3 development. I have a few ideas. Maybe others do as well. 71.3 development. I have a few ideas. Maybe others do as well.
8 8
9DOCUMENTATION: 9DOCUMENTATION:
10 We pretty much have decieded that we will doing something along 10 We pretty much have decided that we will doing something along
11 the lines of a literate programming model. So far, we have site 11 the lines of a literate programming model. So far, we have site
12 documentation in DocBook. I have some ideas here, which I will 12 documentation in DocBook. I have some ideas here, which I will
13 discuss in a separate thread. 13 discuss in a separate thread.
@@ -39,9 +39,9 @@ inconsistent mess and I'd love to ditch it. I only created it to
39satisfy people that wanted reverse compatibility and did not have 39satisfy people that wanted reverse compatibility and did not have
40GNU getopt. 40GNU getopt.
41 41
42Bu I would like to urge that all standard plugins contain 42But I would like to urge that all standard plugins contain
43validate_arguments(). I think this will help convey the idea that 43validate_arguments(). I think this will help convey the idea that
44validations hould be done, even if we don't insist on the specific 44validations should be done, even if we don't insist on the specific
45extent that each plugin must do that validation. 45extent that each plugin must do that validation.
46 46
47This is the set of standard options I envision: 47This is the set of standard options I envision:
@@ -59,7 +59,7 @@ Reserved:
59-F, --file = STRING (usually input) 59-F, --file = STRING (usually input)
60-O, --output = STRING (output file) 60-O, --output = STRING (output file)
61 61
62Recommended, but not reserverd: 62Recommended, but not reserved:
63 63
64-I, --ipaddress = STRING 64-I, --ipaddress = STRING
65-C, --community = STRING 65-C, --community = STRING
@@ -69,7 +69,7 @@ Recommended, but not reserverd:
69-P, --port = INT 69-P, --port = INT
70-u, --url = STRING (also --username if --url is not needed) 70-u, --url = STRING (also --username if --url is not needed)
71 71
72I am suggesting that port alway be '-P' (uppercase) -- we are 72I am suggesting that port always be '-P' (uppercase) -- we are
73currently inconsistent in that regard. 73currently inconsistent in that regard.
74 74
75I am also adding '-q' for silent running. This is totally self 75I am also adding '-q' for silent running. This is totally self
@@ -87,12 +87,12 @@ Programming:
87 length character assignments, at least to the extent possible, 87 length character assignments, at least to the extent possible,
88 from the C-based plugins. To that end, I have made strscpy and 88 from the C-based plugins. To that end, I have made strscpy and
89 friends in utils.c -- I'd like to deploy them. I have comments 89 friends in utils.c -- I'd like to deploy them. I have comments
90 that there is alot of duplicated code, and techniques used that 90 that there is a lot of duplicated code, and techniques used that
91 should be cleaned up. Details in a separate thread. 91 should be cleaned up. Details in a separate thread.
92 92
93Remote checks: 93Remote checks:
94 I have a proposal in hand to incorporate ssh check into spopen() 94 I have a proposal in hand to incorporate ssh check into spopen()
95 so that remote machine checks can be seemless. A nice idea, but 95 so that remote machine checks can be seamless. A nice idea, but
96 complex enough to require discussion. Another thread. 96 complex enough to require discussion. Another thread.
97 97
98I also have a wish list, and I'm sure I've forgot some items. I'll 98I also have a wish list, and I'm sure I've forgot some items. I'll
diff --git a/THANKS.in b/THANKS.in
index 7d1d1ff..b132744 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -381,3 +381,28 @@ Michael Kraus
381Patrick Rauscher 381Patrick Rauscher
382Prathamesh Bhanuse 382Prathamesh Bhanuse
383Valentin Vidic 383Valentin Vidic
384Barak Shohat
385Florian Lohoff
386Stefan Bethke
387Tim Gates
388Tomas Mozes
389Aksel Sjögren
390Andreas Motl
391Claudio Kuenzler
392Daniel Uhlmann
393Eric Wunderlin
394Geert Hendrickx
395Ken D
396Klaus Ethgen
397Lee Clemens
398Linda Guo
399Peter Newman
400Tobias Fiebig
401Tobias Wiese
402Wolfgang Karall-Ahlborn
403Danijel Tasov
404Robert Bohne
405Wolfgang Nieder
406andrew bezella
407Lorenz Gruenwald
408John Morrissey
diff --git a/build-aux/config.rpath b/build-aux/config.rpath
index c38b914..1e2595f 100755
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -2,7 +2,7 @@
2# Output a system dependent set of variables, describing how to set the 2# Output a system dependent set of variables, describing how to set the
3# run time search path of shared libraries in an executable. 3# run time search path of shared libraries in an executable.
4# 4#
5# Copyright 1996-2013 Free Software Foundation, Inc. 5# Copyright 1996-2023 Free Software Foundation, Inc.
6# Taken from GNU libtool, 2001 6# Taken from GNU libtool, 2001
7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8# 8#
@@ -367,15 +367,11 @@ else
367 dgux*) 367 dgux*)
368 hardcode_libdir_flag_spec='-L$libdir' 368 hardcode_libdir_flag_spec='-L$libdir'
369 ;; 369 ;;
370 freebsd2.2*) 370 freebsd2.[01]*)
371 hardcode_libdir_flag_spec='-R$libdir'
372 hardcode_direct=yes
373 ;;
374 freebsd2*)
375 hardcode_direct=yes 371 hardcode_direct=yes
376 hardcode_minus_L=yes 372 hardcode_minus_L=yes
377 ;; 373 ;;
378 freebsd* | dragonfly*) 374 freebsd* | dragonfly* | midnightbsd*)
379 hardcode_libdir_flag_spec='-R$libdir' 375 hardcode_libdir_flag_spec='-R$libdir'
380 hardcode_direct=yes 376 hardcode_direct=yes
381 ;; 377 ;;
@@ -548,13 +544,11 @@ case "$host_os" in
548 dgux*) 544 dgux*)
549 library_names_spec='$libname$shrext' 545 library_names_spec='$libname$shrext'
550 ;; 546 ;;
551 freebsd* | dragonfly*) 547 freebsd[23].*)
552 case "$host_os" in 548 library_names_spec='$libname$shrext$versuffix'
553 freebsd[123]*) 549 ;;
554 library_names_spec='$libname$shrext$versuffix' ;; 550 freebsd* | dragonfly* | midnightbsd*)
555 *) 551 library_names_spec='$libname$shrext'
556 library_names_spec='$libname$shrext' ;;
557 esac
558 ;; 552 ;;
559 gnu*) 553 gnu*)
560 library_names_spec='$libname$shrext' 554 library_names_spec='$libname$shrext'
diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh
index 33f642a..2e8548d 100644
--- a/build-aux/ltmain.sh
+++ b/build-aux/ltmain.sh
@@ -189,7 +189,7 @@ func_basename ()
189# to NONDIR_REPLACEMENT. 189# to NONDIR_REPLACEMENT.
190# value returned in "$func_dirname_result" 190# value returned in "$func_dirname_result"
191# basename: Compute filename of FILE. 191# basename: Compute filename of FILE.
192# value retuned in "$func_basename_result" 192# value returned in "$func_basename_result"
193# Implementation must be kept synchronized with func_dirname 193# Implementation must be kept synchronized with func_dirname
194# and func_basename. For efficiency, we do not delegate to 194# and func_basename. For efficiency, we do not delegate to
195# those functions but instead duplicate the functionality here. 195# those functions but instead duplicate the functionality here.
@@ -522,7 +522,7 @@ func_mkdir_p ()
522 # While some portion of DIR does not yet exist... 522 # While some portion of DIR does not yet exist...
523 while test ! -d "$my_directory_path"; do 523 while test ! -d "$my_directory_path"; do
524 # ...make a list in topmost first order. Use a colon delimited 524 # ...make a list in topmost first order. Use a colon delimited
525 # list incase some portion of path contains whitespace. 525 # list in case some portion of path contains whitespace.
526 my_dir_list="$my_directory_path:$my_dir_list" 526 my_dir_list="$my_directory_path:$my_dir_list"
527 527
528 # If the last portion added has no slash in it, the list is done 528 # If the last portion added has no slash in it, the list is done
@@ -4394,7 +4394,7 @@ EOF
4394 { 4394 {
4395 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4395 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4396 namespace, but it is not one of the ones we know about and 4396 namespace, but it is not one of the ones we know about and
4397 have already dealt with, above (inluding dump-script), then 4397 have already dealt with, above (including dump-script), then
4398 report an error. Otherwise, targets might begin to believe 4398 report an error. Otherwise, targets might begin to believe
4399 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4399 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4400 namespace. The first time any user complains about this, we'll 4400 namespace. The first time any user complains about this, we'll
diff --git a/build-aux/snippet/_Noreturn.h b/build-aux/snippet/_Noreturn.h
deleted file mode 100644
index c44ad89..0000000
--- a/build-aux/snippet/_Noreturn.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#if !defined _Noreturn && __STDC_VERSION__ < 201112
2# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
3 || 0x5110 <= __SUNPRO_C)
4# define _Noreturn __attribute__ ((__noreturn__))
5# elif 1200 <= _MSC_VER
6# define _Noreturn __declspec (noreturn)
7# else
8# define _Noreturn
9# endif
10#endif
diff --git a/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h
deleted file mode 100644
index 1736a1b..0000000
--- a/build-aux/snippet/warn-on-use.h
+++ /dev/null
@@ -1,109 +0,0 @@
1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
18 for FUNCTION which will then trigger a compiler warning containing
19 the text of "literal string" anywhere that function is called, if
20 supported by the compiler. If the compiler does not support this
21 feature, the macro expands to an unused extern declaration.
22
23 This macro is useful for marking a function as a potential
24 portability trap, with the intent that "literal string" include
25 instructions on the replacement function that should be used
26 instead. However, one of the reasons that a function is a
27 portability trap is if it has the wrong signature. Declaring
28 FUNCTION with a different signature in C is a compilation error, so
29 this macro must use the same type as any existing declaration so
30 that programs that avoid the problematic FUNCTION do not fail to
31 compile merely because they included a header that poisoned the
32 function. But this implies that _GL_WARN_ON_USE is only safe to
33 use if FUNCTION is known to already have a declaration. Use of
34 this macro implies that there must not be any other macro hiding
35 the declaration of FUNCTION; but undefining FUNCTION first is part
36 of the poisoning process anyway (although for symbols that are
37 provided only via a macro, the result is a compilation error rather
38 than a warning containing "literal string"). Also note that in
39 C++, it is only safe to use if FUNCTION has no overloads.
40
41 For an example, it is possible to poison 'getline' by:
42 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
43 [getline]) in configure.ac, which potentially defines
44 HAVE_RAW_DECL_GETLINE
45 - adding this code to a header that wraps the system <stdio.h>:
46 #undef getline
47 #if HAVE_RAW_DECL_GETLINE
48 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
49 "not universally present; use the gnulib module getline");
50 #endif
51
52 It is not possible to directly poison global variables. But it is
53 possible to write a wrapper accessor function, and poison that
54 (less common usage, like &environ, will cause a compilation error
55 rather than issue the nice warning, but the end result of informing
56 the developer about their portability problem is still achieved):
57 #if HAVE_RAW_DECL_ENVIRON
58 static char ***rpl_environ (void) { return &environ; }
59 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
60 # undef environ
61 # define environ (*rpl_environ ())
62 #endif
63 */
64#ifndef _GL_WARN_ON_USE
65
66# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
67/* A compiler attribute is available in gcc versions 4.3.0 and later. */
68# define _GL_WARN_ON_USE(function, message) \
69extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
70# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
71/* Verify the existence of the function. */
72# define _GL_WARN_ON_USE(function, message) \
73extern __typeof__ (function) function
74# else /* Unsupported. */
75# define _GL_WARN_ON_USE(function, message) \
76_GL_WARN_EXTERN_C int _gl_warn_on_use
77# endif
78#endif
79
80/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
81 is like _GL_WARN_ON_USE (function, "string"), except that the function is
82 declared with the given prototype, consisting of return type, parameters,
83 and attributes.
84 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
85 not work in this case. */
86#ifndef _GL_WARN_ON_USE_CXX
87# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
88# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
89extern rettype function parameters_and_attributes \
90 __attribute__ ((__warning__ (msg)))
91# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
92/* Verify the existence of the function. */
93# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
94extern rettype function parameters_and_attributes
95# else /* Unsupported. */
96# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
97_GL_WARN_EXTERN_C int _gl_warn_on_use
98# endif
99#endif
100
101/* _GL_WARN_EXTERN_C declaration;
102 performs the declaration with C linkage. */
103#ifndef _GL_WARN_EXTERN_C
104# if defined __cplusplus
105# define _GL_WARN_EXTERN_C extern "C"
106# else
107# define _GL_WARN_EXTERN_C extern
108# endif
109#endif
diff --git a/config_test/child_test.c b/config_test/child_test.c
index 4bf8504..2add3bc 100644
--- a/config_test/child_test.c
+++ b/config_test/child_test.c
@@ -30,7 +30,7 @@ int main(){
30 /* pipefd[1] is for writing to the pipe. We want the output 30 /* pipefd[1] is for writing to the pipe. We want the output
31 * that used to go to the standard output (file descriptor 1) 31 * that used to go to the standard output (file descriptor 1)
32 * to be written to the pipe. The following command does this, 32 * to be written to the pipe. The following command does this,
33 * creating a new file descripter 1 (the lowest available) 33 * creating a new file descriptor 1 (the lowest available)
34 * that writes where pipefd[1] goes. */ 34 * that writes where pipefd[1] goes. */
35 dup (pipefd[1]); /* points pipefd at file descriptor */ 35 dup (pipefd[1]); /* points pipefd at file descriptor */
36 /* the child isn't going to read from the pipe, so 36 /* the child isn't going to read from the pipe, so
diff --git a/configure.ac b/configure.ac
index 7c17dcd..a294b00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,10 +1,11 @@
1dnl Process this file with autoconf to produce a configure script. 1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.59) 2AC_PREREQ(2.64)
3AC_INIT(monitoring-plugins,2.3git) 3AC_INIT(monitoring-plugins,2.3git)
4AC_CONFIG_SRCDIR(NPTest.pm) 4AC_CONFIG_SRCDIR(NPTest.pm)
5AC_CONFIG_FILES([gl/Makefile]) 5AC_CONFIG_FILES([gl/Makefile])
6AC_CONFIG_AUX_DIR(build-aux) 6AC_CONFIG_AUX_DIR(build-aux)
7AM_INIT_AUTOMAKE([1.8.3]) 7AM_INIT_AUTOMAKE([1.8.3])
8AM_SILENT_RULES([yes])
8AM_MAINTAINER_MODE([enable]) 9AM_MAINTAINER_MODE([enable])
9AC_CONFIG_HEADERS([config.h]) 10AC_CONFIG_HEADERS([config.h])
10AC_CANONICAL_HOST 11AC_CANONICAL_HOST
@@ -327,6 +328,25 @@ AS_IF([test "x$with_ldap" != "xno"], [
327 LIBS="$_SAVEDLIBS" 328 LIBS="$_SAVEDLIBS"
328]) 329])
329 330
331
332AC_ARG_WITH([systemd], [AS_HELP_STRING([--without-systemd], [Skips systemd support])])
333
334dnl Check for libsystemd
335AS_IF([test "x$with_systemd" != "xno"], [
336 _SAVEDLIBS="$LIBS"
337 AC_CHECK_LIB(systemd,sd_get_sessions,,,-lsystemd)
338 if test "$ac_cv_lib_systemd_sd_get_sessions" = "yes"; then
339 SYSTEMDLIBS="-lsystemd"
340 SYSTEMDINCLUDE=""
341 AC_SUBST(SYSTEMDLIBS)
342 AC_SUBST(SYSTEMDINCLUDE)
343 else
344 AC_MSG_WARN([Skipping systemd support])
345 fi
346 LIBS="$_SAVEDLIBS"
347])
348
349
330dnl Check for headers used by check_ide_smart 350dnl Check for headers used by check_ide_smart
331case $host in 351case $host in
332 *linux*) 352 *linux*)
@@ -426,7 +446,7 @@ if test "$ac_cv_header_utmpx_h" = "no" -a "$ac_cv_header_wtsapi32_h" = "no"
426then 446then
427 AC_PATH_PROG(PATH_TO_WHO,who) 447 AC_PATH_PROG(PATH_TO_WHO,who)
428 448
429 if [$PATH_TO_WHO -q 2>/dev/null | egrep -i "^# users=[0-9]+$" >/dev/null] 449 if [$PATH_TO_WHO -q 2>/dev/null | grep -E -i "^# users=[0-9]+$" >/dev/null]
430 then 450 then
431 ac_cv_path_to_who="$PATH_TO_WHO -q" 451 ac_cv_path_to_who="$PATH_TO_WHO -q"
432 else 452 else
@@ -775,7 +795,7 @@ dnl Removing this for the moment - Ton
775dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation 795dnl Using /usr/ucb/ps on Solaris systems, to avoid truncation
776dnl Limitation that command name is not available 796dnl Limitation that command name is not available
777dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \ 797dnl elif test "$ac_cv_uname_s" = "SunOS" && /usr/ucb/ps -alxwwn 2>/dev/null | \
778dnl egrep -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null 798dnl grep -E -i ["^ *F +UID +PID +PPID +%C +PRI +NI +SZ +RSS +WCHAN +S +TT +TIME +COMMAND"] > /dev/null
779dnl then 799dnl then
780dnl ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]" 800dnl ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procpcpu,&procvsz,&procrss,procstat,&pos]"
781dnl ac_cv_ps_command="/usr/ucb/ps -alxwwn" 801dnl ac_cv_ps_command="/usr/ucb/ps -alxwwn"
@@ -783,10 +803,20 @@ dnl ac_cv_ps_format=["%*s %d %d %d %d %*d %*d %d %d%*[ 0123456789abcdef]%[OSRZT
783dnl ac_cv_ps_cols=8 803dnl ac_cv_ps_cols=8
784dnl AC_MSG_RESULT([$ac_cv_ps_command]) 804dnl AC_MSG_RESULT([$ac_cv_ps_command])
785 805
806dnl This one is the exact same test as the next one but includes etime
807elif ps axwo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
808 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +ELAPSED +COMMAND"] > /dev/null
809then
810 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
811 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu etime comm args'"
812 ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n"
813 ac_cv_ps_cols=10
814 AC_MSG_RESULT([$ac_cv_ps_command])
815
786dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. 816dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo.
787dnl so test for this first... 817dnl so test for this first...
788elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 818elif ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
789 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 819 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
790then 820then
791 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 821 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
792 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'" 822 ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -798,7 +828,7 @@ dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo
798dnl Should also work for FreeBSD 5.2.1 and 5.3 828dnl Should also work for FreeBSD 5.2.1 and 5.3
799dnl STAT UCOMM VSZ RSS USER PPID COMMAND 829dnl STAT UCOMM VSZ RSS USER PPID COMMAND
800elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 830elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
801 egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null 831 grep -E -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null
802then 832then
803 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 833 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
804 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'" 834 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -810,7 +840,7 @@ dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
810dnl Limitation: Only first 16 chars returned for ucomm field 840dnl Limitation: Only first 16 chars returned for ucomm field
811dnl Must come before ps -weo 841dnl Must come before ps -weo
812elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ 842elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
813 egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null 843 grep -E -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null
814then 844then
815 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 845 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
816 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" 846 ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'"
@@ -820,7 +850,7 @@ then
820 850
821dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND 851dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND
822elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ 852elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \
823 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null 853 grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null
824then 854then
825 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" 855 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]"
826 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'" 856 ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'"
@@ -830,7 +860,7 @@ then
830 860
831dnl FreeBSD 861dnl FreeBSD
832elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \ 862elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \
833 egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null 863 grep -E -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null
834then 864then
835 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 865 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
836 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'" 866 ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'"
@@ -840,7 +870,7 @@ then
840 870
841dnl BSD-like mode in RH 6.1 871dnl BSD-like mode in RH 6.1
842elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ 872elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
843 egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 873 grep -E -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
844then 874then
845 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 875 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
846 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'" 876 ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'"
@@ -852,7 +882,7 @@ dnl SunOS 4.1.3:
852dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND 882dnl F UID PID PPID CP PRI NI SZ RSS WCHAN STAT TT TIME COMMAND
853dnl Need the head -1 otherwise test will work because arguments are found 883dnl Need the head -1 otherwise test will work because arguments are found
854elif ps -laxnwww 2>/dev/null | head -1 | \ 884elif ps -laxnwww 2>/dev/null | head -1 | \
855 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null 885 grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null
856then 886then
857 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" 887 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
858 ac_cv_ps_command="$PATH_TO_PS -laxnwww" 888 ac_cv_ps_command="$PATH_TO_PS -laxnwww"
@@ -865,7 +895,7 @@ dnl FLAGS UID PID PPID PRI NI SIZE RSS WCHAN STA TTY TIME COMMA
865dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2] 895dnl 100 0 1 0 0 0 776 76 c0131c8c S ffff 0:11 init [2]
866dnl 896dnl
867elif ps laxnwww 2>/dev/null | \ 897elif ps laxnwww 2>/dev/null | \
868 egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null 898 grep -E -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null
869then 899then
870 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" 900 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]"
871 ac_cv_ps_command="$PATH_TO_PS laxnwww" 901 ac_cv_ps_command="$PATH_TO_PS laxnwww"
@@ -875,7 +905,7 @@ then
875 905
876dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) 906dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs)
877elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ 907elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \
878 egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null 908 grep -E -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
879then 909then
880 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 910 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
881 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'" 911 ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'"
@@ -888,7 +918,7 @@ dnl Has /usr/bin/ps and /sbin/ps - force sbin version
888dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 918dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
889dnl of 1500). Will need big changes to check_procs to support 919dnl of 1500). Will need big changes to check_procs to support
890elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \ 920elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
891 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null 921 grep -E -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
892then 922then
893 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]" 923 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procpcpu,procetime,procprog,&pos]"
894 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'" 924 ac_cv_ps_command="/sbin/ps -eo 'stat uid pid ppid pcpu etime comm args'"
@@ -897,7 +927,7 @@ then
897 AC_MSG_RESULT([$ac_cv_ps_command]) 927 AC_MSG_RESULT([$ac_cv_ps_command])
898 928
899elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \ 929elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \
900 egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null 930 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null
901then 931then
902 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 932 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
903 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'" 933 ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'"
@@ -907,7 +937,7 @@ then
907 937
908dnl AIX 4.3.3 and 5.1 do not have an rss field 938dnl AIX 4.3.3 and 5.1 do not have an rss field
909elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \ 939elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \
910 egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null 940 grep -E -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
911then 941then
912 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" 942 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
913 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'" 943 ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'"
@@ -917,18 +947,18 @@ then
917 947
918dnl Solaris 2.6 948dnl Solaris 2.6
919elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \ 949elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \
920 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 950 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
921then 951then
922 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 952 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
923 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'" 953 ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'"
924 # There must be no space between the %s and %n due to a wierd problem in sscanf where 954 # There must be no space between the %s and %n due to a weird problem in sscanf where
925 # it will return %n as longer than the line length 955 # it will return %n as longer than the line length
926 ac_cv_ps_format="%s %d %d %d %d %d %f %s%n" 956 ac_cv_ps_format="%s %d %d %d %d %d %f %s%n"
927 ac_cv_ps_cols=9 957 ac_cv_ps_cols=9
928 AC_MSG_RESULT([$ac_cv_ps_command]) 958 AC_MSG_RESULT([$ac_cv_ps_command])
929 959
930elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \ 960elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \
931 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 961 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
932then 962then
933 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 963 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
934 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'" 964 ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'"
@@ -937,7 +967,7 @@ then
937 AC_MSG_RESULT([$ac_cv_ps_command]) 967 AC_MSG_RESULT([$ac_cv_ps_command])
938 968
939elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ 969elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \
940 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 970 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
941then 971then
942 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 972 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
943 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'" 973 ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'"
@@ -947,7 +977,7 @@ then
947 977
948dnl wonder who takes state instead of stat 978dnl wonder who takes state instead of stat
949elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \ 979elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \
950 egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null 980 grep -E -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null
951then 981then
952 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" 982 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]"
953 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'" 983 ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'"
@@ -957,7 +987,7 @@ then
957 987
958dnl IRIX 53 988dnl IRIX 53
959elif ps -el 2>/dev/null | \ 989elif ps -el 2>/dev/null | \
960 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 990 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
961then 991then
962 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]" 992 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&pos,procprog]"
963 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)" 993 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)"
@@ -967,7 +997,7 @@ then
967 997
968dnl IRIX 63 998dnl IRIX 63
969elif ps -el 2>/dev/null | \ 999elif ps -el 2>/dev/null | \
970 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 1000 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
971then 1001then
972 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1002 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
973 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)" 1003 ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)"
@@ -980,7 +1010,7 @@ dnl S UID RUID USER RUSER PID PPID VSZ %CPU COMMAND
980dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X 1010dnl S 0 400 root oracle 2805 1 12904 0.00 ora_dism_SEA1X ora_dism_SEA1X
981dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit 1011dnl S 400 400 oracle oracle 19261 1 126488 0.00 tnslsnr /u01/app/oracle/product/db/11.2.0.3/bin/tnslsnr LISTENER -inherit
982elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \ 1012elif env UNIX95=1 ps -eo 'state uid ruid user ruser pid ppid vsz pcpu comm args' 2>/dev/null | head -n 1 | \
983 egrep -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null 1013 grep -E -i ["^ *S +UID +RUID +USER +RUSER +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null
984then 1014then
985 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]" 1015 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procpcpu,procprog,&pos]"
986 ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'" 1016 ac_cv_ps_command="$PATH_TO_ENV UNIX95=1 $PATH_TO_PS -eo 'state uid pid ppid vsz pcpu comm args'"
@@ -992,7 +1022,7 @@ dnl AIX 4.1:
992dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD 1022dnl F S UID PID PPID C PRI NI ADDR SZ RSS WCHAN TTY TIME CMD
993dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper 1023dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 swapper
994elif ps -el 2>/dev/null | \ 1024elif ps -el 2>/dev/null | \
995 egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null 1025 grep -E -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null
996then 1026then
997 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1027 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
998 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)" 1028 ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)"
@@ -1002,7 +1032,7 @@ then
1002 1032
1003dnl AIX? 1033dnl AIX?
1004elif ps glaxen 2>/dev/null | \ 1034elif ps glaxen 2>/dev/null | \
1005 egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null 1035 grep -E -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null
1006then 1036then
1007 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" 1037 ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]"
1008 ac_cv_ps_command="$PATH_TO_PS glaxen" 1038 ac_cv_ps_command="$PATH_TO_PS glaxen"
@@ -1016,7 +1046,7 @@ dnl Some truncation will happen in UCOMM column
1016dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND 1046dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND
1017dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon 1047dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon
1018elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \ 1048elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \
1019 egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null 1049 grep -E -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null
1020then 1050then
1021 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'" 1051 ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'"
1022 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]" 1052 ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procppid,&procpcpu,procprog,&pos]"
@@ -1026,7 +1056,7 @@ then
1026 1056
1027dnl UnixWare 1057dnl UnixWare
1028elif ps -Al 2>/dev/null | \ 1058elif ps -Al 2>/dev/null | \
1029 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null 1059 grep -E -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
1030then 1060then
1031 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]" 1061 ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&pos,procprog]"
1032 ac_cv_ps_command="$PATH_TO_PS -Al" 1062 ac_cv_ps_command="$PATH_TO_PS -Al"
@@ -1094,14 +1124,14 @@ then
1094 1124
1095elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1125elif [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1096 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \ 1126 $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1097 egrep -i "^round-trip|^rtt" >/dev/null 1127 grep -E -i "^round-trip|^rtt" >/dev/null
1098then 1128then
1099 with_ping_command="$PATH_TO_PING -n -U -c %d %s" 1129 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1100 ac_cv_ping_packets_first=yes 1130 ac_cv_ping_packets_first=yes
1101 AC_MSG_RESULT([$with_ping_command]) 1131 AC_MSG_RESULT([$with_ping_command])
1102 1132
1103elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \ 1133elif $PATH_TO_PING -4 -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1104 egrep -i "^round-trip|^rtt" >/dev/null 1134 grep -E -i "^round-trip|^rtt" >/dev/null
1105then 1135then
1106 # check if -4 is supported - issue #1550 1136 # check if -4 is supported - issue #1550
1107 with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s" 1137 with_ping_command="$PATH_TO_PING -4 -n -U -w %d -c %d %s"
@@ -1109,7 +1139,7 @@ then
1109 ac_cv_ping_has_timeout=yes 1139 ac_cv_ping_has_timeout=yes
1110 AC_MSG_RESULT([$with_ping_command]) 1140 AC_MSG_RESULT([$with_ping_command])
1111elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \ 1141elif $PATH_TO_PING -n -U -w 10 -c 1 127.0.0.1 2>/dev/null | \
1112 egrep -i "^round-trip|^rtt" >/dev/null 1142 grep -E -i "^round-trip|^rtt" >/dev/null
1113then 1143then
1114 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s" 1144 with_ping_command="$PATH_TO_PING -n -U -w %d -c %d %s"
1115 ac_cv_ping_packets_first=yes 1145 ac_cv_ping_packets_first=yes
@@ -1117,52 +1147,52 @@ then
1117 AC_MSG_RESULT([$with_ping_command]) 1147 AC_MSG_RESULT([$with_ping_command])
1118 1148
1119elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \ 1149elif $PATH_TO_PING -n -U -c 1 127.0.0.1 2>/dev/null | \
1120 egrep -i "^round-trip|^rtt" >/dev/null 1150 grep -E -i "^round-trip|^rtt" >/dev/null
1121then 1151then
1122 with_ping_command="$PATH_TO_PING -n -U -c %d %s" 1152 with_ping_command="$PATH_TO_PING -n -U -c %d %s"
1123 ac_cv_ping_packets_first=yes 1153 ac_cv_ping_packets_first=yes
1124 AC_MSG_RESULT([$with_ping_command]) 1154 AC_MSG_RESULT([$with_ping_command])
1125 1155
1126elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \ 1156elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1127 egrep -i "^round-trip|^rtt" >/dev/null 1157 grep -E -i "^round-trip|^rtt" >/dev/null
1128then 1158then
1129 with_ping_command="$PATH_TO_PING -n -c %d %s" 1159 with_ping_command="$PATH_TO_PING -n -c %d %s"
1130 ac_cv_ping_packets_first=yes 1160 ac_cv_ping_packets_first=yes
1131 AC_MSG_RESULT([$with_ping_command]) 1161 AC_MSG_RESULT([$with_ping_command])
1132 1162
1133elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \ 1163elif $PATH_TO_PING -n 127.0.0.1 -c 1 2>/dev/null | \
1134 egrep -i "^round-trip|^rtt" >/dev/null 1164 grep -E -i "^round-trip|^rtt" >/dev/null
1135then 1165then
1136 with_ping_command="$PATH_TO_PING -n %s -c %d" 1166 with_ping_command="$PATH_TO_PING -n %s -c %d"
1137 AC_MSG_RESULT([$with_ping_command]) 1167 AC_MSG_RESULT([$with_ping_command])
1138 1168
1139elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \ 1169elif $PATH_TO_PING 127.0.0.1 -n 1 2>/dev/null | \
1140 egrep -i "^round-trip|^rtt" >/dev/null 1170 grep -E -i "^round-trip|^rtt" >/dev/null
1141then 1171then
1142 with_ping_command="$PATH_TO_PING %s -n %d" 1172 with_ping_command="$PATH_TO_PING %s -n %d"
1143 AC_MSG_RESULT([$with_ping_command]) 1173 AC_MSG_RESULT([$with_ping_command])
1144 1174
1145elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \ 1175elif $PATH_TO_PING -n -s 127.0.0.1 56 1 2>/dev/null | \
1146 egrep -i "^round-trip|^rtt" >/dev/null 1176 grep -E -i "^round-trip|^rtt" >/dev/null
1147then 1177then
1148 with_ping_command="$PATH_TO_PING -n -s %s 56 %d" 1178 with_ping_command="$PATH_TO_PING -n -s %s 56 %d"
1149 AC_MSG_RESULT([$with_ping_command]) 1179 AC_MSG_RESULT([$with_ping_command])
1150 1180
1151elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \ 1181elif $PATH_TO_PING -n -h 127.0.0.1 -s 56 -c 1 2>/dev/null | \
1152 egrep -i "^round-trip|^rtt" >/dev/null 1182 grep -E -i "^round-trip|^rtt" >/dev/null
1153then 1183then
1154 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d" 1184 with_ping_command="$PATH_TO_PING -n -h %s -s 56 -c %d"
1155 AC_MSG_RESULT([$with_ping_command]) 1185 AC_MSG_RESULT([$with_ping_command])
1156 1186
1157elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \ 1187elif $PATH_TO_PING -n -s 56 -c 1 127.0.0.1 2>/dev/null | \
1158 egrep -i "^round-trip|^rtt" >/dev/null 1188 grep -E -i "^round-trip|^rtt" >/dev/null
1159then 1189then
1160 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s" 1190 with_ping_command="$PATH_TO_PING -n -s 56 -c %d %s"
1161 ac_cv_ping_packets_first=yes 1191 ac_cv_ping_packets_first=yes
1162 AC_MSG_RESULT([$with_ping_command]) 1192 AC_MSG_RESULT([$with_ping_command])
1163 1193
1164elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \ 1194elif $PATH_TO_PING -n -c 1 127.0.0.1 2>/dev/null | \
1165 egrep -i "^round-trip|^rtt" >/dev/null 1195 grep -E -i "^round-trip|^rtt" >/dev/null
1166then 1196then
1167 with_ping_command="$PATH_TO_PING -n -c %d %s" 1197 with_ping_command="$PATH_TO_PING -n -c %d %s"
1168 ac_cv_ping_packets_first=yes 1198 ac_cv_ping_packets_first=yes
@@ -1218,14 +1248,14 @@ elif [[ "z$ac_cv_uname_o" = "zCygwin" -a "x$PATH_TO_PING" != "x" ]]; then
1218elif test "x$PATH_TO_PING6" != "x"; then 1248elif test "x$PATH_TO_PING6" != "x"; then
1219 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1249 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1220 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \ 1250 $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1221 egrep -i "^round-trip|^rtt" >/dev/null 1251 grep -E -i "^round-trip|^rtt" >/dev/null
1222 then 1252 then
1223 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s" 1253 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1224 ac_cv_ping6_packets_first=yes 1254 ac_cv_ping6_packets_first=yes
1225 AC_MSG_RESULT([$with_ping6_command]) 1255 AC_MSG_RESULT([$with_ping6_command])
1226 1256
1227 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \ 1257 elif $PATH_TO_PING6 -n -U -w 10 -c 1 ::1 2>/dev/null | \
1228 egrep -i "^round-trip|^rtt" >/dev/null 1258 grep -E -i "^round-trip|^rtt" >/dev/null
1229 then 1259 then
1230 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s" 1260 with_ping6_command="$PATH_TO_PING6 -n -U -w %d -c %d %s"
1231 ac_cv_ping6_packets_first=yes 1261 ac_cv_ping6_packets_first=yes
@@ -1233,52 +1263,52 @@ elif test "x$PATH_TO_PING6" != "x"; then
1233 AC_MSG_RESULT([$with_ping6_command]) 1263 AC_MSG_RESULT([$with_ping6_command])
1234 1264
1235 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \ 1265 elif $PATH_TO_PING6 -n -U -c 1 ::1 2>/dev/null | \
1236 egrep -i "^round-trip|^rtt" >/dev/null 1266 grep -E -i "^round-trip|^rtt" >/dev/null
1237 then 1267 then
1238 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s" 1268 with_ping6_command="$PATH_TO_PING6 -n -U -c %d %s"
1239 ac_cv_ping6_packets_first=yes 1269 ac_cv_ping6_packets_first=yes
1240 AC_MSG_RESULT([$with_ping6_command]) 1270 AC_MSG_RESULT([$with_ping6_command])
1241 1271
1242 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \ 1272 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1243 egrep -i "^round-trip|^rtt" >/dev/null 1273 grep -E -i "^round-trip|^rtt" >/dev/null
1244 then 1274 then
1245 with_ping6_command="$PATH_TO_PING6 -n -c %d %s" 1275 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1246 ac_cv_ping6_packets_first=yes 1276 ac_cv_ping6_packets_first=yes
1247 AC_MSG_RESULT([$with_ping6_command]) 1277 AC_MSG_RESULT([$with_ping6_command])
1248 1278
1249 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \ 1279 elif $PATH_TO_PING6 -n ::1 -c 1 2>/dev/null | \
1250 egrep -i "^round-trip|^rtt" >/dev/null 1280 grep -E -i "^round-trip|^rtt" >/dev/null
1251 then 1281 then
1252 with_ping6_command="$PATH_TO_PING6 -n %s -c %d" 1282 with_ping6_command="$PATH_TO_PING6 -n %s -c %d"
1253 AC_MSG_RESULT([$with_ping6_command]) 1283 AC_MSG_RESULT([$with_ping6_command])
1254 1284
1255 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \ 1285 elif $PATH_TO_PING6 ::1 -n 1 2>/dev/null | \
1256 egrep -i "^round-trip|^rtt" >/dev/null 1286 grep -E -i "^round-trip|^rtt" >/dev/null
1257 then 1287 then
1258 with_ping6_command="$PATH_TO_PING6 %s -n %d" 1288 with_ping6_command="$PATH_TO_PING6 %s -n %d"
1259 AC_MSG_RESULT([$with_ping6_command]) 1289 AC_MSG_RESULT([$with_ping6_command])
1260 1290
1261 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \ 1291 elif $PATH_TO_PING6 -n -s ::1 56 1 2>/dev/null | \
1262 egrep -i "^round-trip|^rtt" >/dev/null 1292 grep -E -i "^round-trip|^rtt" >/dev/null
1263 then 1293 then
1264 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d" 1294 with_ping6_command="$PATH_TO_PING6 -n -s %s 56 %d"
1265 AC_MSG_RESULT([$with_ping6_command]) 1295 AC_MSG_RESULT([$with_ping6_command])
1266 1296
1267 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \ 1297 elif $PATH_TO_PING6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1268 egrep -i "^round-trip|^rtt" >/dev/null 1298 grep -E -i "^round-trip|^rtt" >/dev/null
1269 then 1299 then
1270 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d" 1300 with_ping6_command="$PATH_TO_PING6 -n -h %s -s 56 -c %d"
1271 AC_MSG_RESULT([$with_ping6_command]) 1301 AC_MSG_RESULT([$with_ping6_command])
1272 1302
1273 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \ 1303 elif $PATH_TO_PING6 -n -s 56 -c 1 ::1 2>/dev/null | \
1274 egrep -i "^round-trip|^rtt" >/dev/null 1304 grep -E -i "^round-trip|^rtt" >/dev/null
1275 then 1305 then
1276 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s" 1306 with_ping6_command="$PATH_TO_PING6 -n -s 56 -c %d %s"
1277 ac_cv_ping6_packets_first=yes 1307 ac_cv_ping6_packets_first=yes
1278 AC_MSG_RESULT([$with_ping_command]) 1308 AC_MSG_RESULT([$with_ping_command])
1279 1309
1280 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \ 1310 elif $PATH_TO_PING6 -n -c 1 ::1 2>/dev/null | \
1281 egrep -i "^round-trip|^rtt" >/dev/null 1311 grep -E -i "^round-trip|^rtt" >/dev/null
1282 then 1312 then
1283 with_ping6_command="$PATH_TO_PING6 -n -c %d %s" 1313 with_ping6_command="$PATH_TO_PING6 -n -c %d %s"
1284 ac_cv_ping6_packets_first=yes 1314 ac_cv_ping6_packets_first=yes
@@ -1289,59 +1319,59 @@ elif test "x$PATH_TO_PING6" != "x"; then
1289elif test "x$PATH_TO_PING" != "x"; then 1319elif test "x$PATH_TO_PING" != "x"; then
1290 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \ 1320 if [[ "z$ac_cv_uname_s" = "zUnixWare" ]] && \
1291 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \ 1321 $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1292 egrep -i "^round-trip|^rtt" >/dev/null 1322 grep -E -i "^round-trip|^rtt" >/dev/null
1293 then 1323 then
1294 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s" 1324 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1295 ac_cv_ping6_packets_first=yes 1325 ac_cv_ping6_packets_first=yes
1296 AC_MSG_RESULT([$with_ping6_command]) 1326 AC_MSG_RESULT([$with_ping6_command])
1297 1327
1298 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \ 1328 elif $PATH_TO_PING -A inet6 -n -U -c 1 ::1 2>/dev/null | \
1299 egrep -i "^round-trip|^rtt" >/dev/null 1329 grep -E -i "^round-trip|^rtt" >/dev/null
1300 then 1330 then
1301 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s" 1331 with_ping6_command="$PATH_TO_PING -A inet6 -n -U -c %d %s"
1302 ac_cv_ping6_packets_first=yes 1332 ac_cv_ping6_packets_first=yes
1303 AC_MSG_RESULT([$with_ping6_command]) 1333 AC_MSG_RESULT([$with_ping6_command])
1304 1334
1305 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \ 1335 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1306 egrep -i "^round-trip|^rtt" >/dev/null 1336 grep -E -i "^round-trip|^rtt" >/dev/null
1307 then 1337 then
1308 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s" 1338 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1309 ac_cv_ping6_packets_first=yes 1339 ac_cv_ping6_packets_first=yes
1310 AC_MSG_RESULT([$with_ping6_command]) 1340 AC_MSG_RESULT([$with_ping6_command])
1311 1341
1312 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \ 1342 elif $PATH_TO_PING -A inet6 -n ::1 -c 1 2>/dev/null | \
1313 egrep -i "^round-trip|^rtt" >/dev/null 1343 grep -E -i "^round-trip|^rtt" >/dev/null
1314 then 1344 then
1315 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d" 1345 with_ping6_command="$PATH_TO_PING -A inet6 -n %s -c %d"
1316 AC_MSG_RESULT([$with_ping6_command]) 1346 AC_MSG_RESULT([$with_ping6_command])
1317 1347
1318 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \ 1348 elif $PATH_TO_PING -A inet6 ::1 -n 1 2>/dev/null | \
1319 egrep -i "^round-trip|^rtt" >/dev/null 1349 grep -E -i "^round-trip|^rtt" >/dev/null
1320 then 1350 then
1321 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d" 1351 with_ping6_command="$PATH_TO_PING -A inet6 %s -n %d"
1322 AC_MSG_RESULT([$with_ping6_command]) 1352 AC_MSG_RESULT([$with_ping6_command])
1323 1353
1324 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \ 1354 elif $PATH_TO_PING -A inet6 -n -s ::1 56 1 2>/dev/null | \
1325 egrep -i "^round-trip|^rtt" >/dev/null 1355 grep -E -i "^round-trip|^rtt" >/dev/null
1326 then 1356 then
1327 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d" 1357 with_ping6_command="$PATH_TO_PING -A inet6 -n -s %s 56 %d"
1328 AC_MSG_RESULT([$with_ping6_command]) 1358 AC_MSG_RESULT([$with_ping6_command])
1329 1359
1330 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \ 1360 elif $PATH_TO_PING -A inet6 -n -h ::1 -s 56 -c 1 2>/dev/null | \
1331 egrep -i "^round-trip|^rtt" >/dev/null 1361 grep -E -i "^round-trip|^rtt" >/dev/null
1332 then 1362 then
1333 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d" 1363 with_ping6_command="$PATH_TO_PING -A inet6 -n -h %s -s 56 -c %d"
1334 AC_MSG_RESULT([$with_ping6_command]) 1364 AC_MSG_RESULT([$with_ping6_command])
1335 1365
1336 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \ 1366 elif $PATH_TO_PING -A inet6 -n -s 56 -c 1 ::1 2>/dev/null | \
1337 egrep -i "^round-trip|^rtt" >/dev/null 1367 grep -E -i "^round-trip|^rtt" >/dev/null
1338 then 1368 then
1339 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s" 1369 with_ping6_command="$PATH_TO_PING -A inet6 -n -s 56 -c %d %s"
1340 ac_cv_ping6_packets_first=yes 1370 ac_cv_ping6_packets_first=yes
1341 AC_MSG_RESULT([$with_ping_command]) 1371 AC_MSG_RESULT([$with_ping_command])
1342 1372
1343 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \ 1373 elif $PATH_TO_PING -A inet6 -n -c 1 ::1 2>/dev/null | \
1344 egrep -i "^round-trip|^rtt" >/dev/null 1374 grep -E -i "^round-trip|^rtt" >/dev/null
1345 then 1375 then
1346 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s" 1376 with_ping6_command="$PATH_TO_PING -A inet6 -n -c %d %s"
1347 ac_cv_ping6_packets_first=yes 1377 ac_cv_ping6_packets_first=yes
@@ -1541,7 +1571,7 @@ if test -n "$PATH_TO_SUDO"
1541then 1571then
1542 AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo]) 1572 AC_DEFINE_UNQUOTED(PATH_TO_SUDO,"$PATH_TO_SUDO",[path to sudo])
1543else 1573else
1544 AC_MSG_WARN([Could not find sudo or eqivalent]) 1574 AC_MSG_WARN([Could not find sudo or equivalent])
1545fi 1575fi
1546 1576
1547AC_PATH_PROG(PATH_TO_MAILQ,mailq) 1577AC_PATH_PROG(PATH_TO_MAILQ,mailq)
@@ -1552,7 +1582,7 @@ if test -n "$PATH_TO_MAILQ"
1552then 1582then
1553 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq]) 1583 AC_DEFINE_UNQUOTED(PATH_TO_MAILQ,"$PATH_TO_MAILQ",[path to mailq])
1554else 1584else
1555 AC_MSG_WARN([Could not find mailq or eqivalent]) 1585 AC_MSG_WARN([Could not find mailq or equivalent])
1556fi 1586fi
1557 1587
1558AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat) 1588AC_PATH_PROG(PATH_TO_QMAIL_QSTAT,qmail-qstat)
@@ -1563,7 +1593,7 @@ if test -n "$PATH_TO_QMAIL_QSTAT"
1563then 1593then
1564 AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat]) 1594 AC_DEFINE_UNQUOTED(PATH_TO_QMAIL_QSTAT,"$PATH_TO_QMAIL_QSTAT",[path to qmail-qstat])
1565else 1595else
1566 AC_MSG_WARN([Could not find qmail-qstat or eqivalent]) 1596 AC_MSG_WARN([Could not find qmail-qstat or equivalent])
1567fi 1597fi
1568 1598
1569dnl SWAP info required is amount allocated/available and amount free 1599dnl SWAP info required is amount allocated/available and amount free
@@ -1578,16 +1608,16 @@ then
1578 ac_cv_have_swap=yes 1608 ac_cv_have_swap=yes
1579 ac_cv_swap_command="$PATH_TO_SWAP -l" 1609 ac_cv_swap_command="$PATH_TO_SWAP -l"
1580 if [$PATH_TO_SWAP -l 2>/dev/null | \ 1610 if [$PATH_TO_SWAP -l 2>/dev/null | \
1581 egrep -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \ 1611 grep -E -i "^lswap +path +pri +swaplo +blocks +free +maxswap" \
1582 >/dev/null] 1612 >/dev/null]
1583 then 1613 then
1584 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %f %f"] 1614 ac_cv_swap_format=[" %*d %*s %*d,%*d %*d %*d %lu %lu"]
1585 ac_cv_swap_conv=2048 1615 ac_cv_swap_conv=2048
1586 AC_MSG_RESULT([using IRIX format swap]) 1616 AC_MSG_RESULT([using IRIX format swap])
1587 1617
1588 elif [$PATH_TO_SWAP -l 2>/dev/null | egrep -i "^path +dev +swaplo +blocks +free" >/dev/null] 1618 elif [$PATH_TO_SWAP -l 2>/dev/null | grep -E -i "^path +dev +swaplo +blocks +free" >/dev/null]
1589 then 1619 then
1590 ac_cv_swap_format=["%*s %*[0-9,-] %*d %f %f"] 1620 ac_cv_swap_format=["%*s %*[0-9,-] %*d %lu %lu"]
1591 ac_cv_swap_conv=2048 1621 ac_cv_swap_conv=2048
1592 AC_MSG_RESULT([using Unixware format swap]) 1622 AC_MSG_RESULT([using Unixware format swap])
1593 else 1623 else
@@ -1604,23 +1634,23 @@ AC_PATH_PROG(PATH_TO_SWAPINFO,swapinfo)
1604if (test -n "$PATH_TO_SWAPINFO") 1634if (test -n "$PATH_TO_SWAPINFO")
1605then 1635then
1606AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format]) 1636AC_MSG_CHECKING([for $PATH_TO_SWAPINFO format])
1607if [$PATH_TO_SWAPINFO -k 2>&1 | egrep -i "^Device" >/dev/null] 1637if [$PATH_TO_SWAPINFO -k 2>&1 | grep -E -i "^Device" >/dev/null]
1608then 1638then
1609 ac_cv_have_swap=yes 1639 ac_cv_have_swap=yes
1610 ac_cv_swap_command="$PATH_TO_SWAPINFO -k" 1640 ac_cv_swap_command="$PATH_TO_SWAPINFO -k"
1611 1641
1612 if [$PATH_TO_SWAPINFO -k 2>/dev/null | egrep -i "^Device +1K-blocks +Used +Avail" >/dev/null] 1642 if [$PATH_TO_SWAPINFO -k 2>/dev/null | grep -E -i "^Device +1K-blocks +Used +Avail" >/dev/null]
1613 then 1643 then
1614 ac_cv_swap_format=["%*s %f %*d %f"] 1644 ac_cv_swap_format=["%*s %lu %*d %lu"]
1615 ac_cv_swap_conv=1024 1645 ac_cv_swap_conv=1024
1616 AC_MSG_RESULT([using FreeBSD format swapinfo]) 1646 AC_MSG_RESULT([using FreeBSD format swapinfo])
1617 fi 1647 fi
1618 1648
1619elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | egrep -i "^TYPE +AVAIL +USED +FREE" >/dev/null] 1649elif [$PATH_TO_SWAPINFO -dfM 2>/dev/null | grep -E -i "^TYPE +AVAIL +USED +FREE" >/dev/null]
1620then 1650then
1621 ac_cv_have_swap=yes 1651 ac_cv_have_swap=yes
1622 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM" 1652 ac_cv_swap_command="$PATH_TO_SWAPINFO -dfM"
1623 ac_cv_swap_format=["%*s %f %*d %f"] 1653 ac_cv_swap_format=["%*s %lu %*d %lu"]
1624 ac_cv_swap_conv=1024 1654 ac_cv_swap_conv=1024
1625 AC_MSG_RESULT([using HP-UX format swapinfo]) 1655 AC_MSG_RESULT([using HP-UX format swapinfo])
1626fi 1656fi
@@ -1631,11 +1661,11 @@ AC_PATH_PROG(PATH_TO_LSPS,lsps)
1631if (test -n "$PATH_TO_LSPS") 1661if (test -n "$PATH_TO_LSPS")
1632then 1662then
1633AC_MSG_CHECKING([for $PATH_TO_LSPS format]) 1663AC_MSG_CHECKING([for $PATH_TO_LSPS format])
1634if [$PATH_TO_LSPS -a 2>/dev/null | egrep -i "^Page Space" > /dev/null] 1664if [$PATH_TO_LSPS -a 2>/dev/null | grep -E -i "^Page Space" > /dev/null]
1635then 1665then
1636 ac_cv_have_swap=yes 1666 ac_cv_have_swap=yes
1637 ac_cv_swap_command="$PATH_TO_LSPS -a" 1667 ac_cv_swap_command="$PATH_TO_LSPS -a"
1638 ac_cv_swap_format=["%*s %*s %*s %f%*s %f %*s"] 1668 ac_cv_swap_format=["%*s %*s %*s %lu%*s %lu %*s"]
1639 ac_cv_swap_conv=1 1669 ac_cv_swap_conv=1
1640 AC_MSG_RESULT([using AIX lsps]) 1670 AC_MSG_RESULT([using AIX lsps])
1641fi 1671fi
@@ -1821,7 +1851,7 @@ AM_GNU_GETTEXT([external], [need-ngettext])
1821AM_GNU_GETTEXT_VERSION(0.15) 1851AM_GNU_GETTEXT_VERSION(0.15)
1822 1852
1823dnl Check for Redhat spopen problem 1853dnl Check for Redhat spopen problem
1824dnl Wierd problem where ECHILD is returned from a wait call in error 1854dnl Weird problem where ECHILD is returned from a wait call in error
1825dnl Only appears to affect nslookup and dig calls. Only affects redhat around 1855dnl Only appears to affect nslookup and dig calls. Only affects redhat around
1826dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause 1856dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1827dnl We patch plugins/popen.c 1857dnl We patch plugins/popen.c
@@ -1833,7 +1863,7 @@ AC_ARG_ENABLE(redhat-pthread-workaround,
1833 [ac_cv_enable_redhat_pthread_workaround=$enableval], 1863 [ac_cv_enable_redhat_pthread_workaround=$enableval],
1834 [ac_cv_enable_redhat_pthread_workaround=test]) 1864 [ac_cv_enable_redhat_pthread_workaround=test])
1835if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then 1865if test "$ac_cv_enable_redhat_pthread_workaround" = "test" ; then
1836 if echo $ac_cv_uname_r | egrep "\.EL(smp)?$" >/dev/null 2>&1 ; then 1866 if echo $ac_cv_uname_r | grep -E "\.EL(smp)?$" >/dev/null 2>&1 ; then
1837 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time]) 1867 AC_MSG_NOTICE([See https://www.monitoring-plugins.org/doc/faq/configure-hangs.html if this next part takes a long time])
1838 AC_MSG_CHECKING(for redhat spopen problem) 1868 AC_MSG_CHECKING(for redhat spopen problem)
1839 ( cd config_test && make && make test ) > /dev/null 2>&1 1869 ( cd config_test && make && make test ) > /dev/null 2>&1
diff --git a/doc/RELEASING.md b/doc/RELEASING.md
index bcd2c5a..432b1da 100644
--- a/doc/RELEASING.md
+++ b/doc/RELEASING.md
@@ -2,23 +2,23 @@ Releasing a New Monitoring Plugins Version
2========================================== 2==========================================
3 3
4Throughout this document, it is assumed that the current Monitoring 4Throughout this document, it is assumed that the current Monitoring
5Plugins version is 2.2.1, and that we're about to publish version 2.3. 5Plugins version is 2.3.3, and that we're about to publish version 2.4.
6It is also assumed that the official repository on GitHub is tracked 6It is also assumed that the official repository on GitHub is tracked
7using the remote name `monitoring-plugins` (rather than `origin`). 7using the remote name `monitoring-plugins` (rather than `origin`).
8 8
9Before you start 9Before you start
10---------------- 10----------------
11 11
12- Check Travis CI status. 12- Check Github Actions status.
13- Update local Git repository to the current `master` tip. For a 13- Update local Git repository to the current `master` tip. For a
14 maintenance release (e.g., version 2.3.2), update to the current 14 maintenance release (e.g., version 2.3.4), update to the current
15 `maint-2.3` tip, instead. 15 `maint-2.3` tip, instead.
16 16
17Prepare and commit files 17Prepare and commit files
18------------------------ 18------------------------
19 19
20- Update `configure.ac` and `NP-VERSION-GEN` with new version. 20- Update `configure.ac` and `NP-VERSION-GEN` with new version.
21- Update `NEWS` from `git log --reverse v2.3.1..` output, and specify 21- Update `NEWS` from `git log --reverse v2.3.3..` output, and specify
22 the release version/date. 22 the release version/date.
23- Update `AUTHORS` if there are new team members. 23- Update `AUTHORS` if there are new team members.
24- Update `THANKS.in` using `tools/update-thanks`. 24- Update `THANKS.in` using `tools/update-thanks`.
@@ -55,7 +55,7 @@ Build the tarball
55----------------- 55-----------------
56 56
57 cd /tmp/plugins 57 cd /tmp/plugins
58 tools/setup 58 tools/setup # requires docbook to be installed
59 ./configure 59 ./configure
60 make dist 60 make dist
61 61
@@ -93,6 +93,6 @@ Announce new release
93 93
94If you want to mention the number of contributors in the announcement: 94If you want to mention the number of contributors in the announcement:
95 95
96 git shortlog -s v2.3.1..v2.4 | wc -l 96 git shortlog -s v2.3.3..v2.4 | wc -l
97 97
98<!-- vim:set filetype=markdown textwidth=72: --> 98<!-- vim:set filetype=markdown textwidth=72: -->
diff --git a/doc/developer-guidelines.sgml b/doc/developer-guidelines.sgml
index 6f31f36..37c963e 100644
--- a/doc/developer-guidelines.sgml
+++ b/doc/developer-guidelines.sgml
@@ -13,7 +13,7 @@
13 13
14 <pubdate>2013</pubdate> 14 <pubdate>2013</pubdate>
15 <title>Monitoring Plugins Development Guidelines</title> 15 <title>Monitoring Plugins Development Guidelines</title>
16 16
17 <revhistory> 17 <revhistory>
18 <revision> 18 <revision>
19 <revnumber>1796</revnumber> 19 <revnumber>1796</revnumber>
@@ -31,7 +31,7 @@
31 31
32<preface id="preface"><title>Preface</title> 32<preface id="preface"><title>Preface</title>
33 <para>The purpose of this guidelines is to provide a reference for 33 <para>The purpose of this guidelines is to provide a reference for
34 the plugin developers and encourage the standarization of the 34 the plugin developers and encourage the standardization of the
35 different kind of plugins: C, shell, perl, python, etc.</para> 35 different kind of plugins: C, shell, perl, python, etc.</para>
36 36
37 <para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2013 37 <para>Monitoring Plugins Development Guidelines Copyright (C) 2000-2013
@@ -72,14 +72,14 @@
72</section> 72</section>
73 73
74<section id="PlugOutput"><title>Plugin Output for Nagios</title> 74<section id="PlugOutput"><title>Plugin Output for Nagios</title>
75 75
76 <para>You should always print something to STDOUT that tells if the 76 <para>You should always print something to STDOUT that tells if the
77 service is working or why it is failing. Try to keep the output short - 77 service is working or why it is failing. Try to keep the output short -
78 probably less that 80 characters. Remember that you ideally would like 78 probably less that 80 characters. Remember that you ideally would like
79 the entire output to appear in a pager message, which will get chopped 79 the entire output to appear in a pager message, which will get chopped
80 off after a certain length.</para> 80 off after a certain length.</para>
81 81
82 <para>As Nagios does not capture stderr output, you should only output to 82 <para>As Nagios does not capture stderr output, you should only output to
83 STDOUT and not print to STDERR.</para> 83 STDOUT and not print to STDERR.</para>
84 84
85 <section><title>Print only one line of text</title> 85 <section><title>Print only one line of text</title>
@@ -101,7 +101,7 @@
101 SERVICE STATUS: Information text 101 SERVICE STATUS: Information text
102 </literallayout> 102 </literallayout>
103 <para>However, note that this is not a requirement of the API, so you cannot depend on this 103 <para>However, note that this is not a requirement of the API, so you cannot depend on this
104 being an accurate reflection of the status of the service - the status should always 104 being an accurate reflection of the status of the service - the status should always
105 be determined by the return code.</para> 105 be determined by the return code.</para>
106 </section> 106 </section>
107 107
@@ -148,7 +148,7 @@
148 <para>Code and output should try to respect the 80x25 size of a 148 <para>Code and output should try to respect the 80x25 size of a
149 crt (remember when fixing stuff in the server room!)</para> 149 crt (remember when fixing stuff in the server room!)</para>
150 </section> 150 </section>
151 151
152 <section><title>Plugin Return Codes</title> 152 <section><title>Plugin Return Codes</title>
153 <para>The return codes below are based on the POSIX spec of returning 153 <para>The return codes below are based on the POSIX spec of returning
154 a positive value. Netsaint prior to v0.0.7 supported non-POSIX 154 a positive value. Netsaint prior to v0.0.7 supported non-POSIX
@@ -157,11 +157,11 @@
157 157
158 <para>Note: Some plugins will on occasion print on STDOUT that an error 158 <para>Note: Some plugins will on occasion print on STDOUT that an error
159 occurred and error code is 138 or 255 or some such number. These 159 occurred and error code is 138 or 255 or some such number. These
160 are usually caused by plugins using system commands and having not 160 are usually caused by plugins using system commands and having not
161 enough checks to catch unexpected output. Developers should include a 161 enough checks to catch unexpected output. Developers should include a
162 default catch-all for system command output that returns an UNKNOWN 162 default catch-all for system command output that returns an UNKNOWN
163 return code.</para> 163 return code.</para>
164 164
165 <table id="ReturnCodes"><title>Plugin Return Codes</title> 165 <table id="ReturnCodes"><title>Plugin Return Codes</title>
166 <tgroup cols="3"> 166 <tgroup cols="3">
167 <thead> 167 <thead>
@@ -175,20 +175,20 @@
175 <row> 175 <row>
176 <entry align="center"><para>0</para></entry> 176 <entry align="center"><para>0</para></entry>
177 <entry valign="middle"><para>OK</para></entry> 177 <entry valign="middle"><para>OK</para></entry>
178 <entry><para>The plugin was able to check the service and it 178 <entry><para>The plugin was able to check the service and it
179 appeared to be functioning properly</para></entry> 179 appeared to be functioning properly</para></entry>
180 </row> 180 </row>
181 <row> 181 <row>
182 <entry align="center"><para>1</para></entry> 182 <entry align="center"><para>1</para></entry>
183 <entry valign="middle"><para>Warning</para></entry> 183 <entry valign="middle"><para>Warning</para></entry>
184 <entry><para>The plugin was able to check the service, but it 184 <entry><para>The plugin was able to check the service, but it
185 appeared to be above some "warning" threshold or did not appear 185 appeared to be above some "warning" threshold or did not appear
186 to be working properly</para></entry> 186 to be working properly</para></entry>
187 </row> 187 </row>
188 <row> 188 <row>
189 <entry align="center"><para>2</para></entry> 189 <entry align="center"><para>2</para></entry>
190 <entry valign="middle"><para>Critical</para></entry> 190 <entry valign="middle"><para>Critical</para></entry>
191 <entry><para>The plugin detected that either the service was not 191 <entry><para>The plugin detected that either the service was not
192 running or it was above some "critical" threshold</para></entry> 192 running or it was above some "critical" threshold</para></entry>
193 </row> 193 </row>
194 <row> 194 <row>
@@ -207,7 +207,7 @@
207 </tgroup> 207 </tgroup>
208 </table> 208 </table>
209 209
210 210
211 </section> 211 </section>
212 212
213 <section id="thresholdformat"><title>Threshold and ranges</title> 213 <section id="thresholdformat"><title>Threshold and ranges</title>
@@ -218,7 +218,7 @@
218 set_thresholds(thresholds *, char *, char *) function to set the thresholds. 218 set_thresholds(thresholds *, char *, char *) function to set the thresholds.
219 </para> 219 </para>
220 <para>The theory is that the plugin will do some sort of check which returns 220 <para>The theory is that the plugin will do some sort of check which returns
221 back a numerical value, or metric, which is then compared to the warning and 221 back a numerical value, or metric, which is then compared to the warning and
222 critical thresholds. Use the get_status(double, thresholds *) function to 222 critical thresholds. Use the get_status(double, thresholds *) function to
223 compare the value against the thresholds.</para> 223 compare the value against the thresholds.</para>
224 <para>This is the generalised format for ranges:</para> 224 <para>This is the generalised format for ranges:</para>
@@ -226,14 +226,14 @@
226 <literallayout> 226 <literallayout>
227 [@]start:end 227 [@]start:end
228 </literallayout> 228 </literallayout>
229 229
230 <para>Notes:</para> 230 <para>Notes:</para>
231 <orderedlist> 231 <orderedlist>
232 <listitem><para>start &le; end</para> 232 <listitem><para>start &le; end</para>
233 </listitem> 233 </listitem>
234 <listitem><para>start and ":" is not required if start=0</para> 234 <listitem><para>start and ":" is not required if start=0</para>
235 </listitem> 235 </listitem>
236 <listitem><para>if range is of format "start:" and end is not specified, 236 <listitem><para>if range is of format "start:" and end is not specified,
237 assume end is infinity</para> 237 assume end is infinity</para>
238 </listitem> 238 </listitem>
239 <listitem><para>to specify negative infinity, use "~"</para> 239 <listitem><para>to specify negative infinity, use "~"</para>
@@ -245,7 +245,7 @@
245 (inclusive of endpoints)</para> 245 (inclusive of endpoints)</para>
246 </listitem> 246 </listitem>
247 </orderedlist> 247 </orderedlist>
248 248
249 <para>Note: Not all plugins are coded to expect ranges in this format yet. 249 <para>Note: Not all plugins are coded to expect ranges in this format yet.
250 There will be some work in providing multiple metrics.</para> 250 There will be some work in providing multiple metrics.</para>
251 251
@@ -344,7 +344,7 @@
344 </listitem> 344 </listitem>
345 <listitem><para>label can contain any characters except the equals sign or single quote (')</para> 345 <listitem><para>label can contain any characters except the equals sign or single quote (')</para>
346 </listitem> 346 </listitem>
347 <listitem><para>the single quotes for the label are optional. Required if 347 <listitem><para>the single quotes for the label are optional. Required if
348 spaces are in the label</para> 348 spaces are in the label</para>
349 </listitem> 349 </listitem>
350 <listitem><para>label length is arbitrary, but ideally the first 19 characters 350 <listitem><para>label length is arbitrary, but ideally the first 19 characters
@@ -353,7 +353,7 @@
353 </listitem> 353 </listitem>
354 <listitem><para>to specify a quote character, use two single quotes</para> 354 <listitem><para>to specify a quote character, use two single quotes</para>
355 </listitem> 355 </listitem>
356 <listitem><para>warn, crit, min or max may be null (for example, if the threshold is 356 <listitem><para>warn, crit, min or max may be null (for example, if the threshold is
357 not defined or min and max do not apply). Trailing unfilled semicolons can be 357 not defined or min and max do not apply). Trailing unfilled semicolons can be
358 dropped</para> 358 dropped</para>
359 </listitem> 359 </listitem>
@@ -363,18 +363,18 @@
363 same UOM. value may be a literal "U" instead, this would indicate that the 363 same UOM. value may be a literal "U" instead, this would indicate that the
364 actual value couldn't be determined</para> 364 actual value couldn't be determined</para>
365 </listitem> 365 </listitem>
366 <listitem><para>warn and crit are in the range format (see 366 <listitem><para>warn and crit are in the range format (see
367 <xref linkend="thresholdformat">). Must be the same UOM</para> 367 <xref linkend="thresholdformat">). Must be the same UOM</para>
368 </listitem> 368 </listitem>
369 <listitem><para>UOM (unit of measurement) is one of:</para> 369 <listitem><para>UOM (unit of measurement) is one of:</para>
370 <orderedlist> 370 <orderedlist>
371 <listitem><para>no unit specified - assume a number (int or float) 371 <listitem><para>no unit specified - assume a number (int or float)
372 of things (eg, users, processes, load averages)</para> 372 of things (eg, users, processes, load averages)</para>
373 </listitem> 373 </listitem>
374 <listitem><para>s - seconds (also us, ms)</para></listitem> 374 <listitem><para>s - seconds (also us, ms)</para></listitem>
375 <listitem><para>% - percentage</para></listitem> 375 <listitem><para>% - percentage</para></listitem>
376 <listitem><para>B - bytes (also KB, MB, TB)</para></listitem> 376 <listitem><para>B - bytes (also KB, MB, TB)</para></listitem>
377 <listitem><para>c - a continous counter (such as bytes 377 <listitem><para>c - a continuous counter (such as bytes
378 transmitted on an interface)</para></listitem> 378 transmitted on an interface)</para></listitem>
379 </orderedlist> 379 </orderedlist>
380 </listitem> 380 </listitem>
@@ -385,9 +385,9 @@
385 </section> 385 </section>
386 386
387 <section><title>Translations</title> 387 <section><title>Translations</title>
388 <para>If possible, use translation tools for all output to respect the user's language 388 <para>If possible, use translation tools for all output to respect the user's language
389 settings. See <xref linkend="translationsdevelopers"> for guidelines 389 settings. See <xref linkend="translationsdevelopers"> for guidelines
390 for the core plugins. 390 for the core plugins.
391 </para> 391 </para>
392 </section> 392 </section>
393</section> 393</section>
@@ -397,7 +397,7 @@
397 <section><title>Don't execute system commands without specifying their 397 <section><title>Don't execute system commands without specifying their
398 full path</title> 398 full path</title>
399 <para>Don't use exec(), popen(), etc. to execute external 399 <para>Don't use exec(), popen(), etc. to execute external
400 commands without explicity using the full path of the external 400 commands without explicitly using the full path of the external
401 program.</para> 401 program.</para>
402 402
403 <para>Doing otherwise makes the plugin vulnerable to hijacking 403 <para>Doing otherwise makes the plugin vulnerable to hijacking
@@ -436,7 +436,7 @@
436 </section> 436 </section>
437 437
438</section> 438</section>
439 439
440 440
441 441
442 442
@@ -447,17 +447,17 @@
447 Perl Nagios (ePN) requires stricter use of the some of Perl's features. 447 Perl Nagios (ePN) requires stricter use of the some of Perl's features.
448 This section outlines some of the steps needed to use ePN 448 This section outlines some of the steps needed to use ePN
449 effectively.</para> 449 effectively.</para>
450 450
451 <orderedlist> 451 <orderedlist>
452 452
453 <listitem><para> Do not use BEGIN and END blocks since they will be called 453 <listitem><para> Do not use BEGIN and END blocks since they will be called
454 only once (when Nagios starts and shuts down) with Embedded Perl (ePN). In 454 only once (when Nagios starts and shuts down) with Embedded Perl (ePN). In
455 particular, do not use BEGIN blocks to initialize variables.</para> 455 particular, do not use BEGIN blocks to initialize variables.</para>
456 </listitem> 456 </listitem>
457 457
458 <listitem><para>To use utils.pm, you need to provide a full path to the 458 <listitem><para>To use utils.pm, you need to provide a full path to the
459 module in order for it to work.</para> 459 module in order for it to work.</para>
460 460
461 <literallayout> 461 <literallayout>
462 e.g. 462 e.g.
463 use lib "/usr/local/nagios/libexec"; 463 use lib "/usr/local/nagios/libexec";
@@ -467,24 +467,24 @@
467 467
468 <listitem><para>Perl scripts should be called with "-w"</para> 468 <listitem><para>Perl scripts should be called with "-w"</para>
469 </listitem> 469 </listitem>
470 470
471 <listitem><para>All Perl plugins must compile cleanly under "use strict" - i.e. at 471 <listitem><para>All Perl plugins must compile cleanly under "use strict" - i.e. at
472 least explicitly package names as in "$main::x" or predeclare every 472 least explicitly package names as in "$main::x" or predeclare every
473 variable. </para> 473 variable. </para>
474 474
475 475
476 <para>Explicitly initialize each variable in use. Otherwise with 476 <para>Explicitly initialize each variable in use. Otherwise with
477 caching enabled, the plugin will not be recompiled each time, and 477 caching enabled, the plugin will not be recompiled each time, and
478 therefore Perl will not reinitialize all the variables. All old 478 therefore Perl will not reinitialize all the variables. All old
479 variable values will still be in effect.</para> 479 variable values will still be in effect.</para>
480 </listitem> 480 </listitem>
481 481
482 <listitem><para>Do not use &gt;DATA&lt; handles (these simply do not compile under ePN).</para> 482 <listitem><para>Do not use &gt;DATA&lt; handles (these simply do not compile under ePN).</para>
483 </listitem> 483 </listitem>
484 484
485 <listitem><para>Do not use global variables in named subroutines. This is bad practise anyway, but with ePN the 485 <listitem><para>Do not use global variables in named subroutines. This is bad practise anyway, but with ePN the
486 compiler will report an error "&lt;global_var&gt; will not stay shared ..". Values used by 486 compiler will report an error "&lt;global_var&gt; will not stay shared ..". Values used by
487 subroutines should be passed in the argument list.</para> 487 subroutines should be passed in the argument list.</para>
488 </listitem> 488 </listitem>
489 489
490 <listitem><para>If writing to a file (perhaps recording 490 <listitem><para>If writing to a file (perhaps recording
@@ -492,8 +492,8 @@
492 calls <emphasis role="strong">exit</emphasis>; that is caught by 492 calls <emphasis role="strong">exit</emphasis>; that is caught by
493 p1.pl, so output streams are never closed.</para> 493 p1.pl, so output streams are never closed.</para>
494 </listitem> 494 </listitem>
495 495
496 <listitem><para>As in <xref linkend="runtime"> all plugins need 496 <listitem><para>As in <xref linkend="runtime"> all plugins need
497 to monitor their runtime, specially if they are using network 497 to monitor their runtime, specially if they are using network
498 resources. Use of the <emphasis>alarm</emphasis> is recommended 498 resources. Use of the <emphasis>alarm</emphasis> is recommended
499 noting that some Perl modules (eg LWP) manage timers, so that an alarm 499 noting that some Perl modules (eg LWP) manage timers, so that an alarm
@@ -507,9 +507,9 @@
507 and then "exit $ERRORS{'OK'}" rather than "exit 0" 507 and then "exit $ERRORS{'OK'}" rather than "exit 0"
508 </para> 508 </para>
509 </listitem> 509 </listitem>
510 510
511 </orderedlist> 511 </orderedlist>
512 512
513</section> 513</section>
514 514
515<section id="runtime"><title>Runtime Timeouts</title> 515<section id="runtime"><title>Runtime Timeouts</title>
@@ -524,14 +524,14 @@
524 df could lock up like that. Plus, it should just be more error 524 df could lock up like that. Plus, it should just be more error
525 resistant to be able to time out rather than consume 525 resistant to be able to time out rather than consume
526 resources.</para> 526 resources.</para>
527 527
528 <section><title>Use DEFAULT_SOCKET_TIMEOUT</title> 528 <section><title>Use DEFAULT_SOCKET_TIMEOUT</title>
529 529
530 <para>All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout</para> 530 <para>All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout</para>
531 531
532 </section> 532 </section>
533 533
534 534
535 <section><title>Add alarms to network plugins</title> 535 <section><title>Add alarms to network plugins</title>
536 536
537 <para>If you write a plugin which communicates with another 537 <para>If you write a plugin which communicates with another
@@ -543,16 +543,16 @@
543 543
544 </section> 544 </section>
545 545
546 546
547 547
548</section> 548</section>
549 549
550<section id="PlugOptions"><title>Plugin Options</title> 550<section id="PlugOptions"><title>Plugin Options</title>
551 551
552 <para>A well written plugin should have --help as a way to get 552 <para>A well written plugin should have --help as a way to get
553 verbose help. Code and output should try to respect the 80x25 size of a 553 verbose help. Code and output should try to respect the 80x25 size of a
554 crt (remember when fixing stuff in the server room!)</para> 554 crt (remember when fixing stuff in the server room!)</para>
555 555
556 <section><title>Option Processing</title> 556 <section><title>Option Processing</title>
557 557
558 <para>For plugins written in C, we recommend the C standard 558 <para>For plugins written in C, we recommend the C standard
@@ -585,11 +585,11 @@
585 -p port or password (--port or --passwd/--password)monitors operational 585 -p port or password (--port or --passwd/--password)monitors operational
586 -u url or username (--url or --username) 586 -u url or username (--url or --username)
587 </literallayout> 587 </literallayout>
588 588
589 <para>Look at check_pgsql and check_procs to see how I currently 589 <para>Look at check_pgsql and check_procs to see how I currently
590 think this can work. Standard options are:</para> 590 think this can work. Standard options are:</para>
591 591
592 592
593 <para>The option -V or --version should be present in all 593 <para>The option -V or --version should be present in all
594 plugins. For C plugins it should result in a call to print_revision, a 594 plugins. For C plugins it should result in a call to print_revision, a
595 function in utils.c which takes two character arguments, the 595 function in utils.c which takes two character arguments, the
@@ -603,7 +603,7 @@
603 603
604 <para>The option -h or --help should be present in all plugins. 604 <para>The option -h or --help should be present in all plugins.
605 In C plugins, it should result in a call to print_help (or 605 In C plugins, it should result in a call to print_help (or
606 equivalent). The function print_help should call print_revision, 606 equivalent). The function print_help should call print_revision,
607 then print_usage, then should provide detailed 607 then print_usage, then should provide detailed
608 help. Help text should fit on an 80-character width display, but 608 help. Help text should fit on an 80-character width display, but
609 may run as many lines as needed.</para> 609 may run as many lines as needed.</para>
@@ -655,7 +655,7 @@
655 <para>If possible when writing lists, use tokens to make the 655 <para>If possible when writing lists, use tokens to make the
656 list easy to remember and non-order dependent - so 656 list easy to remember and non-order dependent - so
657 check_disk uses '-c 10000,10%' so that it is clear which is 657 check_disk uses '-c 10000,10%' so that it is clear which is
658 the precentage and which is the KB values (note that due to 658 the percentage and which is the KB values (note that due to
659 my own lack of foresight, that used to be '-c 10000:10%' but 659 my own lack of foresight, that used to be '-c 10000:10%' but
660 such constructs should all be changed for consistency, 660 such constructs should all be changed for consistency,
661 though providing reverse compatibility is fairly 661 though providing reverse compatibility is fairly
@@ -666,7 +666,7 @@
666 666
667 <para>As always, comments are welcome - making this consistent 667 <para>As always, comments are welcome - making this consistent
668 without a host of long options was quite a hassle, and I would 668 without a host of long options was quite a hassle, and I would
669 suspect that there are flaws in this strategy. 669 suspect that there are flaws in this strategy.
670 </para> 670 </para>
671 </section> 671 </section>
672</section> 672</section>
@@ -678,7 +678,7 @@ create and update test cases where possible.
678</para> 678</para>
679 679
680<para> 680<para>
681To run a test, from the top level directory, run "make test". This will run 681To run a test, from the top level directory, run "make test". This will run
682all the current tests and report an overall success rate. 682all the current tests and report an overall success rate.
683</para> 683</para>
684 684
@@ -686,7 +686,7 @@ all the current tests and report an overall success rate.
686<para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t". 686<para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t".
687</para> 687</para>
688 688
689<para>There will somtimes be failures seen in this output which are known failures that 689<para>There will sometimes be failures seen in this output which are known failures that
690need to be fixed. As long as the return code is 0, it will be reported as "test pass". 690need to be fixed. As long as the return code is 0, it will be reported as "test pass".
691(If you have a fix so that the specific test passes, that will be gratefully received!) 691(If you have a fix so that the specific test passes, that will be gratefully received!)
692</para> 692</para>
@@ -697,7 +697,7 @@ This runs the test in a summary format.
697</para> 697</para>
698 698
699<para> 699<para>
700For a good and amusing tutorial on using Test::More, see this 700For a good and amusing tutorial on using Test::More, see this
701<ulink url="http://search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod"> 701<ulink url="http://search.cpan.org/dist/Test-Simple/lib/Test/Tutorial.pod">
702link</ulink> 702link</ulink>
703</para> 703</para>
@@ -706,16 +706,16 @@ link</ulink>
706 706
707<section><title>Testing the C library functions</title> 707<section><title>Testing the C library functions</title>
708<para> 708<para>
709We use <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap">the libtap library</ulink>, which gives 709We use <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap">the libtap library</ulink>, which gives
710perl's TAP 710perl's TAP
711(Test Anything Protocol) output. This is used by the FreeBSD team for their regression testing. 711(Test Anything Protocol) output. This is used by the FreeBSD team for their regression testing.
712</para> 712</para>
713 713
714<para> 714<para>
715To run tests using the libtap library, download the latest tar ball and extract. 715To run tests using the libtap library, download the latest tar ball and extract.
716There is a problem with tap-1.01 where 716There is a problem with tap-1.01 where
717<ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/25">pthread support doesn't appear to work</ulink> 717<ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/25">pthread support doesn't appear to work</ulink>
718properly on non-FreeBSD systems. Install with 'CPPFLAGS="-UHAVE_LIBPTHREAD" ./configure && make && make check && make install'. 718properly on non-FreeBSD systems. Install with 'CPPFLAGS="-UHAVE_LIBPTHREAD" ./configure && make && make check && make install'.
719</para> 719</para>
720 720
721<para> 721<para>
@@ -729,24 +729,21 @@ setup the tests. Run "make test" to run all the tests.
729 <para>See <ulink url="http://www.gnu.org/prep/standards_toc.html">GNU 729 <para>See <ulink url="http://www.gnu.org/prep/standards_toc.html">GNU
730 Coding standards</ulink> for general guidelines.</para> 730 Coding standards</ulink> for general guidelines.</para>
731 <section><title>C coding</title> 731 <section><title>C coding</title>
732
733 <para>Variables should be declared at the beginning of code blocks and
734 not inline because of portability with older compilers.</para>
735 732
736 <para>You should use /* */ for comments and not // as some compilers 733 <para>Variables should be declared at the beginning of code blocks and
737 do not handle the latter form.</para> 734 not inline because of portability with older compilers.</para>
738 735
739 <para>You should also avoid using the type "bool" and its values 736 <para>You should use the type "bool" and its values
740 "true" and "false". Instead use the "int" type and the plugins' own 737 "true" and "false" instead of the "int" type for booleans.
741 "TRUE"/"FALSE" values to keep the code uniformly.</para> 738 </para>
742 </section> 739 </section>
743 740
744 <section><title>Crediting sources</title> 741 <section><title>Crediting sources</title>
745 <para>If you have copied a routine from another source, make sure the licence 742 <para>If you have copied a routine from another source, make sure the licence
746 from your source allows this. Add a comment referencing the ACKNOWLEDGEMENTS 743 from your source allows this. Add a comment referencing the ACKNOWLEDGEMENTS
747 file, where you can put more detail about the source.</para> 744 file, where you can put more detail about the source.</para>
748 <para>For contributed code, do not add any named credits in the source code 745 <para>For contributed code, do not add any named credits in the source code
749 - contributors should be added into the THANKS.in file instead. 746 - contributors should be added into the THANKS.in file instead.
750 </para> 747 </para>
751 </section> 748 </section>
752 749
@@ -809,11 +806,11 @@ setup the tests. Run "make test" to run all the tests.
809 806
810 807
811 <section id="Contributedplugins"><title>Contributed plugins</title> 808 <section id="Contributedplugins"><title>Contributed plugins</title>
812 <para>Plugins that have been contributed to the project and 809 <para>Plugins that have been contributed to the project and
813 distributed with the Monitoring Plugins files are held in the contrib/ directory and are not installed 810 distributed with the Monitoring Plugins files are held in the contrib/ directory and are not installed
814 by default. These plugins are not officially supported by the team. 811 by default. These plugins are not officially supported by the team.
815 The current policy is that these plugins should be owned and maintained by the original 812 The current policy is that these plugins should be owned and maintained by the original
816 contributor, preferably hosted on <ulink url="http://monitoringexchange.org">Monitoring Exchange</ulink>. 813 contributor, preferably hosted on <ulink url="https://exchange.icinga.com/">Icinga Exchange</ulink>.
817 </para> 814 </para>
818 <para>If patches or bugs are raised to an contributed plugin, we will start communications with the 815 <para>If patches or bugs are raised to an contributed plugin, we will start communications with the
819 original contributor, but seek to remove the plugin from our distribution. 816 original contributor, but seek to remove the plugin from our distribution.
@@ -824,11 +821,11 @@ setup the tests. Run "make test" to run all the tests.
824 821
825 <section id="Newplugins"><title>New plugins</title> 822 <section id="Newplugins"><title>New plugins</title>
826 <para>If you would like others to use your plugins, please add it to 823 <para>If you would like others to use your plugins, please add it to
827 the official 3rd party plugin repository, 824 the official 3rd party plugin repository,
828 <ulink url="http://monitoringexchange.org">Monitoring Exchange</ulink>. 825 <ulink url="https://exchange.icinga.com/">Icinga Exchange</ulink>.
829 </para> 826 </para>
830 827
831 <para>We are not accepting requests for inclusion of plugins into 828 <para>We are not accepting requests for inclusion of plugins into
832 our distribution at the moment, but when we do, these are the minimum 829 our distribution at the moment, but when we do, these are the minimum
833 requirements: 830 requirements:
834 </para> 831 </para>
@@ -843,10 +840,10 @@ setup the tests. Run "make test" to run all the tests.
843 --timeout, --warning, --critical)</para> 840 --timeout, --warning, --critical)</para>
844 </listitem> 841 </listitem>
845 <listitem> 842 <listitem>
846 <para>It is determined to be not redundant (for instance, we would not 843 <para>It is determined to be not redundant (for instance, we would not
847 add a new version of check_disk just because someone had provide 844 add a new version of check_disk just because someone had provide
848 a plugin that had perf checking - we would incorporate the features 845 a plugin that had perf checking - we would incorporate the features
849 into an exisiting plugin)</para> 846 into an existing plugin)</para>
850 </listitem> 847 </listitem>
851 <listitem> 848 <listitem>
852 <para>One of the developers has had the time to audit the code and declare 849 <para>One of the developers has had the time to audit the code and declare
@@ -857,7 +854,7 @@ setup the tests. Run "make test" to run all the tests.
857utils (perl or c or sh) rather than using its own</para> 854utils (perl or c or sh) rather than using its own</para>
858 </listitem> 855 </listitem>
859 <listitem> 856 <listitem>
860 <para>Includes patches to configure.in if required (via the EXTRAS list if 857 <para>Includes patches to configure.in if required (via the EXTRAS list if
861 it will only work on some platforms)</para> 858 it will only work on some platforms)</para>
862 </listitem> 859 </listitem>
863 <listitem> 860 <listitem>
@@ -870,5 +867,5 @@ utils (perl or c or sh) rather than using its own</para>
870 867
871</section> 868</section>
872</article> 869</article>
873 870
874</book> 871</book>
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 15135c8..dcebd4a 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1,10 +1,10 @@
1## DO NOT EDIT! GENERATED AUTOMATICALLY! 1## DO NOT EDIT! GENERATED AUTOMATICALLY!
2## Process this file with automake to produce Makefile.in. 2## Process this file with automake to produce Makefile.in.
3# Copyright (C) 2002-2013 Free Software Foundation, Inc. 3# Copyright (C) 2002-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; you can redistribute it and/or modify 5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3 of the License, or 7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version. 8# (at your option) any later version.
9# 9#
10# This file is distributed in the hope that it will be useful, 10# This file is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
13# GNU General Public License for more details. 13# GNU General Public License for more details.
14# 14#
15# You should have received a copy of the GNU General Public License 15# You should have received a copy of the GNU General Public License
16# along with this file. If not, see <http://www.gnu.org/licenses/>. 16# along with this file. If not, see <https://www.gnu.org/licenses/>.
17# 17#
18# As a special exception to the GNU General Public License, 18# As a special exception to the GNU General Public License,
19# this file may be distributed as part of a program that 19# this file may be distributed as part of a program that
@@ -21,9 +21,42 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf 24# Reproduce by:
25 25# gnulib-tool --import \
26AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects 26# --lib=libgnu \
27# --source-base=gl \
28# --m4-base=gl/m4 \
29# --doc-base=doc \
30# --tests-base=tests \
31# --aux-dir=build-aux \
32# --no-conditional-dependencies \
33# --no-libtool \
34# --macro-prefix=gl \
35# --no-vc-files \
36# base64 \
37# crypto/sha256 \
38# dirname \
39# environ \
40# floorf \
41# fsusage \
42# getaddrinfo \
43# gethostname \
44# getloadavg \
45# getopt-gnu \
46# gettext-h \
47# idpriv-droptemp \
48# mountlist \
49# regex \
50# setenv \
51# strcase \
52# strcasestr \
53# strsep \
54# timegm \
55# unsetenv \
56# vasprintf \
57# vsnprintf
58
59AUTOMAKE_OPTIONS = 1.14 gnits subdir-objects
27 60
28SUBDIRS = 61SUBDIRS =
29noinst_HEADERS = 62noinst_HEADERS =
@@ -37,6 +70,7 @@ MOSTLYCLEANDIRS =
37CLEANFILES = 70CLEANFILES =
38DISTCLEANFILES = 71DISTCLEANFILES =
39MAINTAINERCLEANFILES = 72MAINTAINERCLEANFILES =
73# No GNU Make output.
40EXTRA_DIST += m4/gnulib-cache.m4 74EXTRA_DIST += m4/gnulib-cache.m4
41 75
42AM_CPPFLAGS = 76AM_CPPFLAGS =
@@ -45,10 +79,20 @@ AM_CFLAGS =
45noinst_LIBRARIES += libgnu.a 79noinst_LIBRARIES += libgnu.a
46 80
47libgnu_a_SOURCES = 81libgnu_a_SOURCES =
82libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
48libgnu_a_LIBADD = $(gl_LIBOBJS) 83libgnu_a_LIBADD = $(gl_LIBOBJS)
49libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 84libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
50EXTRA_libgnu_a_SOURCES = 85EXTRA_libgnu_a_SOURCES =
51 86
87## begin gnulib module absolute-header
88
89# Use this preprocessor expression to decide whether #include_next works.
90# Do not rely on a 'configure'-time test for this, since the expression
91# might appear in an installed header, which is used by some other compiler.
92HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER)
93
94## end gnulib module absolute-header
95
52## begin gnulib module alloca-opt 96## begin gnulib module alloca-opt
53 97
54BUILT_SOURCES += $(ALLOCA_H) 98BUILT_SOURCES += $(ALLOCA_H)
@@ -57,11 +101,10 @@ BUILT_SOURCES += $(ALLOCA_H)
57# doesn't have one that works with the given compiler. 101# doesn't have one that works with the given compiler.
58if GL_GENERATE_ALLOCA_H 102if GL_GENERATE_ALLOCA_H
59alloca.h: alloca.in.h $(top_builddir)/config.status 103alloca.h: alloca.in.h $(top_builddir)/config.status
60 $(AM_V_GEN)rm -f $@-t $@ && \ 104 $(gl_V_at)$(SED_HEADER_STDOUT) \
61 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 105 -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' \
62 cat $(srcdir)/alloca.in.h; \ 106 $(srcdir)/alloca.in.h > $@-t
63 } > $@-t && \ 107 $(AM_V_at)mv $@-t $@
64 mv -f $@-t $@
65else 108else
66alloca.h: $(top_builddir)/config.status 109alloca.h: $(top_builddir)/config.status
67 rm -f $@ 110 rm -f $@
@@ -79,18 +122,18 @@ BUILT_SOURCES += arpa/inet.h
79# We need the following in order to create <arpa/inet.h> when the system 122# We need the following in order to create <arpa/inet.h> when the system
80# doesn't have one. 123# doesn't have one.
81arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 124arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
82 $(AM_V_at)$(MKDIR_P) arpa 125 $(AM_V_GEN)$(MKDIR_P) '%reldir%/arpa'
83 $(AM_V_GEN)rm -f $@-t $@ && \ 126 $(AM_V_at)$(SED_HEADER_STDOUT) \
84 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 127 -e 's|@''GUARD_PREFIX''@|GL|g' \
85 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
86 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 128 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
87 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 129 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
88 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 130 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
89 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ 131 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
90 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ 132 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
91 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ 133 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
92 -e 's/@''GNULIB_INET_NTOP''@/$(GNULIB_INET_NTOP)/g' \ 134 -e 's/@''GNULIB_INET_NTOP''@/$(GL_GNULIB_INET_NTOP)/g' \
93 -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \ 135 -e 's/@''GNULIB_INET_PTON''@/$(GL_GNULIB_INET_PTON)/g' \
136 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
94 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ 137 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
95 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ 138 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
96 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \ 139 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \
@@ -98,9 +141,8 @@ arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON
98 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 141 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
99 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 142 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
100 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 143 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
101 < $(srcdir)/arpa_inet.in.h; \ 144 $(srcdir)/arpa_inet.in.h > $@-t
102 } > $@-t && \ 145 $(AM_V_at)mv $@-t $@
103 mv $@-t $@
104MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t 146MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
105MOSTLYCLEANDIRS += arpa 147MOSTLYCLEANDIRS += arpa
106 148
@@ -108,72 +150,141 @@ EXTRA_DIST += arpa_inet.in.h
108 150
109## end gnulib module arpa_inet 151## end gnulib module arpa_inet
110 152
153## begin gnulib module assert-h
154
155BUILT_SOURCES += $(ASSERT_H)
156
157# We need the following in order to create <assert.h> when the system
158# doesn't have one that works with the given compiler.
159if GL_GENERATE_ASSERT_H
160assert.h: assert.in.h verify.h $(top_builddir)/config.status
161 $(gl_V_at){ $(SED_HEADER_STDOUT) \
162 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
163 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
164 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
165 -e 's|@''NEXT_ASSERT_H''@|$(NEXT_ASSERT_H)|g' \
166 < $(srcdir)/assert.in.h && \
167 sed -e '/@assert.h omit start@/,/@assert.h omit end@/d' \
168 -e 's|_gl_verify|_gl_static_assert|g' \
169 -e 's|_GL_VERIFY|_GL_STATIC_ASSERT|g' \
170 -e 's|_GL\(_STATIC_ASSERT_H\)|_GL\1|g' \
171 < $(srcdir)/verify.h; \
172 } > $@-t
173 $(AM_V_at)mv $@-t $@
174else
175assert.h: $(top_builddir)/config.status
176 rm -f $@
177endif
178MOSTLYCLEANFILES += assert.h assert.h-t
179
180EXTRA_DIST += assert.in.h verify.h
181
182## end gnulib module assert-h
183
184## begin gnulib module attribute
185
186
187EXTRA_DIST += attribute.h
188
189## end gnulib module attribute
190
111## begin gnulib module base64 191## begin gnulib module base64
112 192
113libgnu_a_SOURCES += base64.h base64.c 193libgnu_a_SOURCES += base64.h base64.c
114 194
115## end gnulib module base64 195## end gnulib module base64
116 196
117## begin gnulib module btowc 197## begin gnulib module basename-lgpl
118 198
199libgnu_a_SOURCES += basename-lgpl.c
119 200
120EXTRA_DIST += btowc.c 201EXTRA_DIST += basename-lgpl.h
121 202
122EXTRA_libgnu_a_SOURCES += btowc.c 203## end gnulib module basename-lgpl
204
205## begin gnulib module btowc
206
207if GL_COND_OBJ_BTOWC
208libgnu_a_SOURCES += btowc.c
209endif
123 210
124## end gnulib module btowc 211## end gnulib module btowc
125 212
126## begin gnulib module configmake 213## begin gnulib module byteswap
127 214
128# Listed in the same order as the GNU makefile conventions, and 215BUILT_SOURCES += $(BYTESWAP_H)
129# provided by autoconf 2.59c+. 216
130# The Automake-defined pkg* macros are appended, in the order 217# We need the following in order to create <byteswap.h> when the system
131# listed in the Automake 1.10a+ documentation. 218# doesn't have one.
132configmake.h: Makefile 219if GL_GENERATE_BYTESWAP_H
133 $(AM_V_GEN)rm -f $@-t && \ 220byteswap.h: byteswap.in.h $(top_builddir)/config.status
134 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 221 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/byteswap.in.h
135 echo '#define PREFIX "$(prefix)"'; \ 222 $(AM_V_at)mv $@-t $@
136 echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ 223else
137 echo '#define BINDIR "$(bindir)"'; \ 224byteswap.h: $(top_builddir)/config.status
138 echo '#define SBINDIR "$(sbindir)"'; \ 225 rm -f $@
139 echo '#define LIBEXECDIR "$(libexecdir)"'; \ 226endif
140 echo '#define DATAROOTDIR "$(datarootdir)"'; \ 227MOSTLYCLEANFILES += byteswap.h byteswap.h-t
141 echo '#define DATADIR "$(datadir)"'; \ 228
142 echo '#define SYSCONFDIR "$(sysconfdir)"'; \ 229EXTRA_DIST += byteswap.in.h
143 echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \ 230
144 echo '#define LOCALSTATEDIR "$(localstatedir)"'; \ 231## end gnulib module byteswap
145 echo '#define INCLUDEDIR "$(includedir)"'; \ 232
146 echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \ 233## begin gnulib module calloc-gnu
147 echo '#define DOCDIR "$(docdir)"'; \ 234
148 echo '#define INFODIR "$(infodir)"'; \ 235
149 echo '#define HTMLDIR "$(htmldir)"'; \ 236EXTRA_DIST += calloc.c
150 echo '#define DVIDIR "$(dvidir)"'; \ 237
151 echo '#define PDFDIR "$(pdfdir)"'; \ 238EXTRA_libgnu_a_SOURCES += calloc.c
152 echo '#define PSDIR "$(psdir)"'; \ 239
153 echo '#define LIBDIR "$(libdir)"'; \ 240## end gnulib module calloc-gnu
154 echo '#define LISPDIR "$(lispdir)"'; \ 241
155 echo '#define LOCALEDIR "$(localedir)"'; \ 242## begin gnulib module calloc-posix
156 echo '#define MANDIR "$(mandir)"'; \ 243
157 echo '#define MANEXT "$(manext)"'; \ 244
158 echo '#define PKGDATADIR "$(pkgdatadir)"'; \ 245EXTRA_DIST += calloc.c
159 echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \ 246
160 echo '#define PKGLIBDIR "$(pkglibdir)"'; \ 247EXTRA_libgnu_a_SOURCES += calloc.c
161 echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ 248
162 } | sed '/""/d' > $@-t && \ 249## end gnulib module calloc-posix
163 mv -f $@-t $@ 250
164 251## begin gnulib module cloexec
165BUILT_SOURCES += configmake.h 252
166CLEANFILES += configmake.h configmake.h-t 253libgnu_a_SOURCES += cloexec.c
167 254
168## end gnulib module configmake 255EXTRA_DIST += cloexec.h
169 256
170## begin gnulib module crypto/sha1 257## end gnulib module cloexec
171 258
172libgnu_a_SOURCES += sha1.c 259## begin gnulib module close
173 260
174EXTRA_DIST += sha1.h 261if GL_COND_OBJ_CLOSE
175 262libgnu_a_SOURCES += close.c
176## end gnulib module crypto/sha1 263endif
264
265## end gnulib module close
266
267## begin gnulib module crypto/af_alg
268
269libgnu_a_SOURCES += af_alg.c
270
271EXTRA_DIST += af_alg.h sys-limits.h
272
273## end gnulib module crypto/af_alg
274
275## begin gnulib module crypto/sha256
276
277libgnu_a_SOURCES += sha256-stream.c
278
279## end gnulib module crypto/sha256
280
281## begin gnulib module crypto/sha256-buffer
282
283libgnu_a_SOURCES += sha256.c
284
285EXTRA_DIST += gl_openssl.h sha256.h
286
287## end gnulib module crypto/sha256-buffer
177 288
178## begin gnulib module dirname 289## begin gnulib module dirname
179 290
@@ -187,18 +298,19 @@ EXTRA_libgnu_a_SOURCES += stripslash.c
187 298
188## begin gnulib module dirname-lgpl 299## begin gnulib module dirname-lgpl
189 300
190libgnu_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c 301libgnu_a_SOURCES += dirname-lgpl.c stripslash.c
191 302
192EXTRA_DIST += dirname.h 303EXTRA_DIST += dirname.h
193 304
194## end gnulib module dirname-lgpl 305## end gnulib module dirname-lgpl
195 306
196## begin gnulib module dosname 307## begin gnulib module dup2
197
198 308
199EXTRA_DIST += dosname.h 309if GL_COND_OBJ_DUP2
310libgnu_a_SOURCES += dup2.c
311endif
200 312
201## end gnulib module dosname 313## end gnulib module dup2
202 314
203## begin gnulib module errno 315## begin gnulib module errno
204 316
@@ -208,9 +320,8 @@ BUILT_SOURCES += $(ERRNO_H)
208# doesn't have one that is POSIX compliant. 320# doesn't have one that is POSIX compliant.
209if GL_GENERATE_ERRNO_H 321if GL_GENERATE_ERRNO_H
210errno.h: errno.in.h $(top_builddir)/config.status 322errno.h: errno.in.h $(top_builddir)/config.status
211 $(AM_V_GEN)rm -f $@-t $@ && \ 323 $(gl_V_at)$(SED_HEADER_STDOUT) \
212 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 324 -e 's|@''GUARD_PREFIX''@|GL|g' \
213 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
214 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 325 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
215 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 326 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
216 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 327 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
@@ -221,9 +332,8 @@ errno.h: errno.in.h $(top_builddir)/config.status
221 -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \ 332 -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
222 -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \ 333 -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
223 -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \ 334 -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
224 < $(srcdir)/errno.in.h; \ 335 $(srcdir)/errno.in.h > $@-t
225 } > $@-t && \ 336 $(AM_V_at)mv $@-t $@
226 mv $@-t $@
227else 337else
228errno.h: $(top_builddir)/config.status 338errno.h: $(top_builddir)/config.status
229 rm -f $@ 339 rm -f $@
@@ -236,10 +346,11 @@ EXTRA_DIST += errno.in.h
236 346
237## begin gnulib module error 347## begin gnulib module error
238 348
349if GL_COND_OBJ_ERROR
350libgnu_a_SOURCES += error.c
351endif
239 352
240EXTRA_DIST += error.c error.h 353EXTRA_DIST += error.h
241
242EXTRA_libgnu_a_SOURCES += error.c
243 354
244## end gnulib module error 355## end gnulib module error
245 356
@@ -251,6 +362,51 @@ EXTRA_DIST += exitfail.h
251 362
252## end gnulib module exitfail 363## end gnulib module exitfail
253 364
365## begin gnulib module fcntl
366
367if GL_COND_OBJ_FCNTL
368libgnu_a_SOURCES += fcntl.c
369endif
370
371## end gnulib module fcntl
372
373## begin gnulib module fcntl-h
374
375BUILT_SOURCES += fcntl.h
376
377# We need the following in order to create <fcntl.h> when the system
378# doesn't have one that works with the given compiler.
379fcntl.h: fcntl.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
380 $(gl_V_at)$(SED_HEADER_STDOUT) \
381 -e 's|@''GUARD_PREFIX''@|GL|g' \
382 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
383 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
384 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
385 -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
386 -e 's/@''GNULIB_CREAT''@/$(GL_GNULIB_CREAT)/g' \
387 -e 's/@''GNULIB_FCNTL''@/$(GL_GNULIB_FCNTL)/g' \
388 -e 's/@''GNULIB_NONBLOCKING''@/$(GL_GNULIB_NONBLOCKING)/g' \
389 -e 's/@''GNULIB_OPEN''@/$(GL_GNULIB_OPEN)/g' \
390 -e 's/@''GNULIB_OPENAT''@/$(GL_GNULIB_OPENAT)/g' \
391 -e 's/@''GNULIB_MDA_CREAT''@/$(GL_GNULIB_MDA_CREAT)/g' \
392 -e 's/@''GNULIB_MDA_OPEN''@/$(GL_GNULIB_MDA_OPEN)/g' \
393 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
394 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
395 -e 's|@''REPLACE_CREAT''@|$(REPLACE_CREAT)|g' \
396 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
397 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
398 -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
399 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
400 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
401 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
402 $(srcdir)/fcntl.in.h > $@-t
403 $(AM_V_at)mv $@-t $@
404MOSTLYCLEANFILES += fcntl.h fcntl.h-t
405
406EXTRA_DIST += fcntl.in.h
407
408## end gnulib module fcntl-h
409
254## begin gnulib module fd-hook 410## begin gnulib module fd-hook
255 411
256libgnu_a_SOURCES += fd-hook.c 412libgnu_a_SOURCES += fd-hook.c
@@ -259,6 +415,23 @@ EXTRA_DIST += fd-hook.h
259 415
260## end gnulib module fd-hook 416## end gnulib module fd-hook
261 417
418## begin gnulib module fflush
419
420if GL_COND_OBJ_FFLUSH
421libgnu_a_SOURCES += fflush.c
422endif
423
424EXTRA_DIST += stdio-impl.h
425
426## end gnulib module fflush
427
428## begin gnulib module filename
429
430
431EXTRA_DIST += filename.h
432
433## end gnulib module filename
434
262## begin gnulib module float 435## begin gnulib module float
263 436
264BUILT_SOURCES += $(FLOAT_H) 437BUILT_SOURCES += $(FLOAT_H)
@@ -267,127 +440,267 @@ BUILT_SOURCES += $(FLOAT_H)
267# doesn't have one that works with the given compiler. 440# doesn't have one that works with the given compiler.
268if GL_GENERATE_FLOAT_H 441if GL_GENERATE_FLOAT_H
269float.h: float.in.h $(top_builddir)/config.status 442float.h: float.in.h $(top_builddir)/config.status
270 $(AM_V_GEN)rm -f $@-t $@ && \ 443 $(gl_V_at)$(SED_HEADER_STDOUT) \
271 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 444 -e 's|@''GUARD_PREFIX''@|GL|g' \
272 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
273 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 445 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
274 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 446 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
275 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 447 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
276 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ 448 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
277 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \ 449 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
278 < $(srcdir)/float.in.h; \ 450 $(srcdir)/float.in.h > $@-t
279 } > $@-t && \ 451 $(AM_V_at)mv $@-t $@
280 mv $@-t $@
281else 452else
282float.h: $(top_builddir)/config.status 453float.h: $(top_builddir)/config.status
283 rm -f $@ 454 rm -f $@
284endif 455endif
285MOSTLYCLEANFILES += float.h float.h-t 456MOSTLYCLEANFILES += float.h float.h-t
286 457
287EXTRA_DIST += float.c float.in.h itold.c 458if GL_COND_OBJ_FLOAT
459libgnu_a_SOURCES += float.c
460endif
461if GL_COND_OBJ_ITOLD
462libgnu_a_SOURCES += itold.c
463endif
288 464
289EXTRA_libgnu_a_SOURCES += float.c itold.c 465EXTRA_DIST += float.in.h
290 466
291## end gnulib module float 467## end gnulib module float
292 468
293## begin gnulib module floorf 469## begin gnulib module floorf
294 470
471if GL_COND_OBJ_FLOORF
472libgnu_a_SOURCES += floorf.c
473endif
295 474
296EXTRA_DIST += floor.c floorf.c 475EXTRA_DIST += floor.c
297 476
298EXTRA_libgnu_a_SOURCES += floor.c floorf.c 477EXTRA_libgnu_a_SOURCES += floor.c
299 478
300## end gnulib module floorf 479## end gnulib module floorf
301 480
302## begin gnulib module fsusage 481## begin gnulib module fopen
482
303 483
484EXTRA_DIST += fopen.c
304 485
305EXTRA_DIST += fsusage.c fsusage.h 486EXTRA_libgnu_a_SOURCES += fopen.c
306 487
307EXTRA_libgnu_a_SOURCES += fsusage.c 488## end gnulib module fopen
489
490## begin gnulib module fopen-gnu
491
492
493EXTRA_DIST += fopen.c
494
495EXTRA_libgnu_a_SOURCES += fopen.c
496
497## end gnulib module fopen-gnu
498
499## begin gnulib module fpurge
500
501if GL_COND_OBJ_FPURGE
502libgnu_a_SOURCES += fpurge.c
503endif
504
505EXTRA_DIST += stdio-impl.h
506
507## end gnulib module fpurge
508
509## begin gnulib module freading
510
511libgnu_a_SOURCES += freading.c
512
513EXTRA_DIST += freading.h stdio-impl.h
514
515## end gnulib module freading
516
517## begin gnulib module free-posix
518
519if GL_COND_OBJ_FREE
520libgnu_a_SOURCES += free.c
521endif
522
523## end gnulib module free-posix
524
525## begin gnulib module fseek
526
527if GL_COND_OBJ_FSEEK
528libgnu_a_SOURCES += fseek.c
529endif
530
531## end gnulib module fseek
532
533## begin gnulib module fseeko
534
535if GL_COND_OBJ_FSEEKO
536libgnu_a_SOURCES += fseeko.c
537endif
538
539EXTRA_DIST += stdio-impl.h
540
541## end gnulib module fseeko
542
543## begin gnulib module fstat
544
545if GL_COND_OBJ_FSTAT
546libgnu_a_SOURCES += fstat.c
547endif
548
549EXTRA_DIST += stat-w32.c stat-w32.h
550
551EXTRA_libgnu_a_SOURCES += stat-w32.c
552
553## end gnulib module fstat
554
555## begin gnulib module fsusage
556
557if GL_COND_OBJ_FSUSAGE
558libgnu_a_SOURCES += fsusage.c
559endif
560
561EXTRA_DIST += fsusage.h
308 562
309## end gnulib module fsusage 563## end gnulib module fsusage
310 564
311## begin gnulib module full-read 565## begin gnulib module ftell
566
567if GL_COND_OBJ_FTELL
568libgnu_a_SOURCES += ftell.c
569endif
570
571## end gnulib module ftell
312 572
313libgnu_a_SOURCES += full-read.h full-read.c 573## begin gnulib module ftello
314 574
315EXTRA_DIST += full-write.c 575if GL_COND_OBJ_FTELLO
576libgnu_a_SOURCES += ftello.c
577endif
316 578
317EXTRA_libgnu_a_SOURCES += full-write.c 579EXTRA_DIST += stdio-impl.h
318 580
319## end gnulib module full-read 581## end gnulib module ftello
320 582
321## begin gnulib module getaddrinfo 583## begin gnulib module gen-header
322 584
585# In 'sed', replace the pattern space with a "DO NOT EDIT" comment.
586SED_HEADER_NOEDIT = s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */,
323 587
324EXTRA_DIST += gai_strerror.c getaddrinfo.c 588# '$(SED_HEADER_STDOUT) -e "..."' runs 'sed' but first outputs "DO NOT EDIT".
589SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G
325 590
326EXTRA_libgnu_a_SOURCES += gai_strerror.c getaddrinfo.c 591# '$(SED_HEADER_TO_AT_t) FILE' copies FILE to $@-t, prepending a leading
592# "DO_NOT_EDIT". Although this could be done more simply via:
593# SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-t
594# the -n and 'w' avoid a fork+exec, at least when GNU Make is used.
595SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t'
596
597# Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that
598gl_V_at = $(AM_V_GEN)
599
600## end gnulib module gen-header
601
602## begin gnulib module getaddrinfo
603
604if GL_COND_OBJ_GETADDRINFO
605libgnu_a_SOURCES += getaddrinfo.c
606endif
607if GL_COND_OBJ_GAI_STRERROR
608libgnu_a_SOURCES += gai_strerror.c
609endif
327 610
328## end gnulib module getaddrinfo 611## end gnulib module getaddrinfo
329 612
330## begin gnulib module gethostname 613## begin gnulib module getdelim
614
615if GL_COND_OBJ_GETDELIM
616libgnu_a_SOURCES += getdelim.c
617endif
618
619## end gnulib module getdelim
620
621## begin gnulib module getdtablesize
331 622
623if GL_COND_OBJ_GETDTABLESIZE
624libgnu_a_SOURCES += getdtablesize.c
625endif
626
627## end gnulib module getdtablesize
628
629## begin gnulib module gethostname
332 630
333EXTRA_DIST += gethostname.c w32sock.h 631if GL_COND_OBJ_GETHOSTNAME
632libgnu_a_SOURCES += gethostname.c
633endif
334 634
335EXTRA_libgnu_a_SOURCES += gethostname.c 635EXTRA_DIST += w32sock.h
336 636
337## end gnulib module gethostname 637## end gnulib module gethostname
338 638
339## begin gnulib module getloadavg 639## begin gnulib module getline
640
641if GL_COND_OBJ_GETLINE
642libgnu_a_SOURCES += getline.c
643endif
340 644
645## end gnulib module getline
341 646
342EXTRA_DIST += getloadavg.c 647## begin gnulib module getloadavg
343 648
344EXTRA_libgnu_a_SOURCES += getloadavg.c 649if GL_COND_OBJ_GETLOADAVG
650libgnu_a_SOURCES += getloadavg.c
651endif
345 652
346## end gnulib module getloadavg 653## end gnulib module getloadavg
347 654
348## begin gnulib module getopt-posix 655## begin gnulib module getopt-posix
349 656
350BUILT_SOURCES += $(GETOPT_H) 657BUILT_SOURCES += $(GETOPT_H) $(GETOPT_CDEFS_H)
351 658
352# We need the following in order to create <getopt.h> when the system 659# We need the following in order to create <getopt.h> when the system
353# doesn't have one that works with the given compiler. 660# doesn't have one that works with the given compiler.
661if GL_GENERATE_GETOPT_H
354getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H) 662getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
355 $(AM_V_GEN)rm -f $@-t $@ && \ 663 $(gl_V_at)$(SED_HEADER_STDOUT) \
356 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 664 -e 's|@''GUARD_PREFIX''@|GL|g' \
357 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
358 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ 665 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
359 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 666 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
360 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 667 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
361 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 668 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
362 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ 669 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
363 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 670 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
364 < $(srcdir)/getopt.in.h; \ 671 $(srcdir)/getopt.in.h > $@-t
365 } > $@-t && \ 672 $(AM_V_at)mv $@-t $@
366 mv -f $@-t $@ 673else
367MOSTLYCLEANFILES += getopt.h getopt.h-t 674getopt.h: $(top_builddir)/config.status
675 rm -f $@
676endif
368 677
369EXTRA_DIST += getopt.c getopt.in.h getopt1.c getopt_int.h 678if GL_GENERATE_GETOPT_CDEFS_H
679getopt-cdefs.h: getopt-cdefs.in.h $(top_builddir)/config.status
680 $(AM_V_GEN)$(SED_HEADER_STDOUT) \
681 -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
682 $(srcdir)/getopt-cdefs.in.h > $@-t
683 $(AM_V_at)mv $@-t $@
684else
685getopt-cdefs.h: $(top_builddir)/config.status
686 rm -f $@
687endif
370 688
371EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c 689MOSTLYCLEANFILES += getopt.h getopt.h-t getopt-cdefs.h getopt-cdefs.h-t
372 690
373## end gnulib module getopt-posix 691if GL_COND_OBJ_GETOPT
692libgnu_a_SOURCES += getopt.c getopt1.c
693endif
694
695EXTRA_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
374 696
375## begin gnulib module gettext 697## end gnulib module getopt-posix
376 698
377# If your project uses "gettextize --intl" to put a source-code 699## begin gnulib module getprogname
378# copy of libintl into the package, every Makefile.am needs
379# -I$(top_builddir)/intl, so that <libintl.h> can be found in this directory.
380# Here's one way to do this:
381#AM_CPPFLAGS += -I$(top_builddir)/intl
382# This option has no effect when the user disables NLS (because then
383# the intl directory contains no libintl.h file). This option is not
384# enabled by default because the intl directory might not exist if
385# your project does not use "gettext --intl", and some compilers
386# complain about -I options applied to nonexistent directories.
387 700
388EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath 701libgnu_a_SOURCES += getprogname.h getprogname.c
389 702
390## end gnulib module gettext 703## end gnulib module getprogname
391 704
392## begin gnulib module gettext-h 705## begin gnulib module gettext-h
393 706
@@ -395,12 +708,54 @@ libgnu_a_SOURCES += gettext.h
395 708
396## end gnulib module gettext-h 709## end gnulib module gettext-h
397 710
398## begin gnulib module havelib 711## begin gnulib module glibc-internal/dynarray
712
713BUILT_SOURCES += malloc/dynarray.gl.h malloc/dynarray-skeleton.gl.h
714
715malloc/dynarray.gl.h: malloc/dynarray.h
716 $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
717 $(AM_V_at)$(SED_HEADER_STDOUT) \
718 -e '/libc_hidden_proto/d' \
719 $(srcdir)/malloc/dynarray.h > $@-t
720 $(AM_V_at)mv $@-t $@
721MOSTLYCLEANFILES += malloc/dynarray.gl.h malloc/dynarray.gl.h-t
722
723malloc/dynarray-skeleton.gl.h: malloc/dynarray-skeleton.c
724 $(AM_V_GEN)$(MKDIR_P) '%reldir%/malloc'
725 $(AM_V_at)$(SED_HEADER_STDOUT) \
726 -e 's|<malloc/dynarray\.h>|<malloc/dynarray.gl.h>|g' \
727 -e 's|__attribute_maybe_unused__|_GL_ATTRIBUTE_MAYBE_UNUSED|g' \
728 -e 's|__attribute_nonnull__|_GL_ATTRIBUTE_NONNULL|g' \
729 -e 's|__attribute_warn_unused_result__|_GL_ATTRIBUTE_NODISCARD|g' \
730 -e 's|__glibc_likely|_GL_LIKELY|g' \
731 -e 's|__glibc_unlikely|_GL_UNLIKELY|g' \
732 $(srcdir)/malloc/dynarray-skeleton.c > $@-t
733 $(AM_V_at)mv $@-t $@
734MOSTLYCLEANFILES += malloc/dynarray-skeleton.gl.h malloc/dynarray-skeleton.gl.h-t
735
736libgnu_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
737
738EXTRA_DIST += dynarray.h malloc/dynarray-skeleton.c malloc/dynarray.h
739
740EXTRA_libgnu_a_SOURCES += malloc/dynarray-skeleton.c
741
742## end gnulib module glibc-internal/dynarray
743
744## begin gnulib module hard-locale
745
746libgnu_a_SOURCES += hard-locale.c
399 747
748EXTRA_DIST += hard-locale.h
400 749
401EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath 750## end gnulib module hard-locale
402 751
403## end gnulib module havelib 752## begin gnulib module ialloc
753
754libgnu_a_SOURCES += ialloc.c
755
756EXTRA_DIST += ialloc.h
757
758## end gnulib module ialloc
404 759
405## begin gnulib module idpriv-droptemp 760## begin gnulib module idpriv-droptemp
406 761
@@ -410,22 +765,68 @@ EXTRA_DIST += idpriv.h
410 765
411## end gnulib module idpriv-droptemp 766## end gnulib module idpriv-droptemp
412 767
413## begin gnulib module inet_ntop 768## begin gnulib module idx
769
770libgnu_a_SOURCES += idx.h
414 771
772## end gnulib module idx
415 773
416EXTRA_DIST += inet_ntop.c 774## begin gnulib module inet_ntop
417 775
418EXTRA_libgnu_a_SOURCES += inet_ntop.c 776if GL_COND_OBJ_INET_NTOP
777libgnu_a_SOURCES += inet_ntop.c
778endif
419 779
420## end gnulib module inet_ntop 780## end gnulib module inet_ntop
421 781
422## begin gnulib module intprops 782## begin gnulib module intprops
423 783
424 784
425EXTRA_DIST += intprops.h 785EXTRA_DIST += intprops-internal.h intprops.h
426 786
427## end gnulib module intprops 787## end gnulib module intprops
428 788
789## begin gnulib module inttypes-incomplete
790
791BUILT_SOURCES += inttypes.h
792
793# We need the following in order to create <inttypes.h> when the system
794# doesn't have one that works with the given compiler.
795inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
796 $(gl_V_at)$(SED_HEADER_STDOUT) \
797 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
798 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
799 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
800 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
801 -e 's|@''NEXT_INTTYPES_H''@|$(NEXT_INTTYPES_H)|g' \
802 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
803 -e 's/@''PRIPTR_PREFIX''@/$(PRIPTR_PREFIX)/g' \
804 -e 's/@''GNULIB_IMAXABS''@/$(GL_GNULIB_IMAXABS)/g' \
805 -e 's/@''GNULIB_IMAXDIV''@/$(GL_GNULIB_IMAXDIV)/g' \
806 -e 's/@''GNULIB_STRTOIMAX''@/$(GL_GNULIB_STRTOIMAX)/g' \
807 -e 's/@''GNULIB_STRTOUMAX''@/$(GL_GNULIB_STRTOUMAX)/g' \
808 -e 's/@''HAVE_DECL_IMAXABS''@/$(HAVE_DECL_IMAXABS)/g' \
809 -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
810 -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
811 -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
812 -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \
813 -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
814 -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
815 -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
816 -e 's/@''INT64_MAX_EQ_LONG_MAX''@/$(INT64_MAX_EQ_LONG_MAX)/g' \
817 -e 's/@''UINT32_MAX_LT_UINTMAX_MAX''@/$(UINT32_MAX_LT_UINTMAX_MAX)/g' \
818 -e 's/@''UINT64_MAX_EQ_ULONG_MAX''@/$(UINT64_MAX_EQ_ULONG_MAX)/g' \
819 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
820 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
821 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
822 $(srcdir)/inttypes.in.h > $@-t
823 $(AM_V_at)mv $@-t $@
824MOSTLYCLEANFILES += inttypes.h inttypes.h-t
825
826EXTRA_DIST += inttypes.in.h
827
828## end gnulib module inttypes-incomplete
829
429## begin gnulib module langinfo 830## begin gnulib module langinfo
430 831
431BUILT_SOURCES += langinfo.h 832BUILT_SOURCES += langinfo.h
@@ -433,103 +834,69 @@ BUILT_SOURCES += langinfo.h
433# We need the following in order to create an empty placeholder for 834# We need the following in order to create an empty placeholder for
434# <langinfo.h> when the system doesn't have one. 835# <langinfo.h> when the system doesn't have one.
435langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) 836langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
436 $(AM_V_GEN)rm -f $@-t $@ && \ 837 $(gl_V_at)$(SED_HEADER_STDOUT) \
437 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 838 -e 's|@''GUARD_PREFIX''@|GL|g' \
438 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
439 -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ 839 -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
440 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 840 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
441 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 841 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
442 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 842 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
443 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ 843 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
444 -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \ 844 -e 's/@''GNULIB_NL_LANGINFO''@/$(GL_GNULIB_NL_LANGINFO)/g' \
445 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ 845 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
446 -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \ 846 -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
847 -e 's|@''HAVE_LANGINFO_ALTMON''@|$(HAVE_LANGINFO_ALTMON)|g' \
447 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ 848 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
448 -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \ 849 -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
449 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ 850 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
450 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ 851 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
451 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 852 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
452 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 853 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
453 < $(srcdir)/langinfo.in.h; \ 854 $(srcdir)/langinfo.in.h > $@-t
454 } > $@-t && \ 855 $(AM_V_at)mv $@-t $@
455 mv $@-t $@
456MOSTLYCLEANFILES += langinfo.h langinfo.h-t 856MOSTLYCLEANFILES += langinfo.h langinfo.h-t
457 857
458EXTRA_DIST += langinfo.in.h 858EXTRA_DIST += langinfo.in.h
459 859
460## end gnulib module langinfo 860## end gnulib module langinfo
461 861
462## begin gnulib module localcharset 862## begin gnulib module libc-config
463 863
464libgnu_a_SOURCES += localcharset.h localcharset.c
465
466# We need the following in order to install a simple file in $(libdir)
467# which is shared with other installed packages. We use a list of referencing
468# packages so that "make uninstall" will remove the file if and only if it
469# is not used by another installed package.
470# On systems with glibc-2.1 or newer, the file is redundant, therefore we
471# avoid installing it.
472
473all-local: charset.alias ref-add.sed ref-del.sed
474
475charset_alias = $(DESTDIR)$(libdir)/charset.alias
476charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
477install-exec-local: install-exec-localcharset
478install-exec-localcharset: all-local
479 if test $(GLIBC21) = no; then \
480 case '$(host_os)' in \
481 darwin[56]*) \
482 need_charset_alias=true ;; \
483 darwin* | cygwin* | mingw* | pw32* | cegcc*) \
484 need_charset_alias=false ;; \
485 *) \
486 need_charset_alias=true ;; \
487 esac ; \
488 else \
489 need_charset_alias=false ; \
490 fi ; \
491 if $$need_charset_alias; then \
492 $(mkinstalldirs) $(DESTDIR)$(libdir) ; \
493 fi ; \
494 if test -f $(charset_alias); then \
495 sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
496 $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
497 rm -f $(charset_tmp) ; \
498 else \
499 if $$need_charset_alias; then \
500 sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
501 $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
502 rm -f $(charset_tmp) ; \
503 fi ; \
504 fi
505
506uninstall-local: uninstall-localcharset
507uninstall-localcharset: all-local
508 if test -f $(charset_alias); then \
509 sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
510 if grep '^# Packages using this file: $$' $(charset_tmp) \
511 > /dev/null; then \
512 rm -f $(charset_alias); \
513 else \
514 $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
515 fi; \
516 rm -f $(charset_tmp); \
517 fi
518 864
519charset.alias: config.charset 865EXTRA_DIST += cdefs.h libc-config.h
520 $(AM_V_GEN)rm -f t-$@ $@ && \
521 $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
522 mv t-$@ $@
523 866
524SUFFIXES += .sed .sin 867## end gnulib module libc-config
525.sin.sed:
526 $(AM_V_GEN)rm -f t-$@ $@ && \
527 sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
528 mv t-$@ $@
529 868
530CLEANFILES += charset.alias ref-add.sed ref-del.sed 869## begin gnulib module limits-h
531 870
532EXTRA_DIST += config.charset ref-add.sin ref-del.sin 871BUILT_SOURCES += $(LIMITS_H)
872
873# We need the following in order to create <limits.h> when the system
874# doesn't have one that is compatible with GNU.
875if GL_GENERATE_LIMITS_H
876limits.h: limits.in.h $(top_builddir)/config.status
877 $(gl_V_at)$(SED_HEADER_STDOUT) \
878 -e 's|@''GUARD_PREFIX''@|GL|g' \
879 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
880 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
881 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
882 -e 's|@''NEXT_LIMITS_H''@|$(NEXT_LIMITS_H)|g' \
883 $(srcdir)/limits.in.h > $@-t
884 $(AM_V_at)mv $@-t $@
885else
886limits.h: $(top_builddir)/config.status
887 rm -f $@
888endif
889MOSTLYCLEANFILES += limits.h limits.h-t
890
891EXTRA_DIST += limits.in.h
892
893## end gnulib module limits-h
894
895## begin gnulib module localcharset
896
897libgnu_a_SOURCES += localcharset.c
898
899EXTRA_DIST += localcharset.h
533 900
534## end gnulib module localcharset 901## end gnulib module localcharset
535 902
@@ -540,28 +907,33 @@ BUILT_SOURCES += locale.h
540# We need the following in order to create <locale.h> when the system 907# We need the following in order to create <locale.h> when the system
541# doesn't have one that provides all definitions. 908# doesn't have one that provides all definitions.
542locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 909locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
543 $(AM_V_GEN)rm -f $@-t $@ && \ 910 $(gl_V_at)$(SED_HEADER_STDOUT) \
544 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 911 -e 's|@''GUARD_PREFIX''@|GL|g' \
545 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
546 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 912 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
547 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 913 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
548 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 914 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
549 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ 915 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
550 -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \ 916 -e 's/@''GNULIB_LOCALECONV''@/$(GL_GNULIB_LOCALECONV)/g' \
551 -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \ 917 -e 's/@''GNULIB_SETLOCALE''@/$(GL_GNULIB_SETLOCALE)/g' \
552 -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \ 918 -e 's/@''GNULIB_SETLOCALE_NULL''@/$(GL_GNULIB_SETLOCALE_NULL)/g' \
919 -e 's/@''GNULIB_DUPLOCALE''@/$(GL_GNULIB_DUPLOCALE)/g' \
920 -e 's/@''GNULIB_LOCALENAME''@/$(GL_GNULIB_LOCALENAME)/g' \
921 -e 's|@''HAVE_NEWLOCALE''@|$(HAVE_NEWLOCALE)|g' \
553 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ 922 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
923 -e 's|@''HAVE_FREELOCALE''@|$(HAVE_FREELOCALE)|g' \
554 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ 924 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
555 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \ 925 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
556 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \ 926 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
927 -e 's|@''REPLACE_NEWLOCALE''@|$(REPLACE_NEWLOCALE)|g' \
557 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ 928 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
929 -e 's|@''REPLACE_FREELOCALE''@|$(REPLACE_FREELOCALE)|g' \
558 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \ 930 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
931 -e 's|@''LOCALENAME_ENHANCE_LOCALE_FUNCS''@|$(LOCALENAME_ENHANCE_LOCALE_FUNCS)|g' \
559 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 932 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
560 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 933 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
561 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 934 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
562 < $(srcdir)/locale.in.h; \ 935 $(srcdir)/locale.in.h > $@-t
563 } > $@-t && \ 936 $(AM_V_at)mv $@-t $@
564 mv $@-t $@
565MOSTLYCLEANFILES += locale.h locale.h-t 937MOSTLYCLEANFILES += locale.h locale.h-t
566 938
567EXTRA_DIST += locale.in.h 939EXTRA_DIST += locale.in.h
@@ -570,10 +942,9 @@ EXTRA_DIST += locale.in.h
570 942
571## begin gnulib module localeconv 943## begin gnulib module localeconv
572 944
573 945if GL_COND_OBJ_LOCALECONV
574EXTRA_DIST += localeconv.c 946libgnu_a_SOURCES += localeconv.c
575 947endif
576EXTRA_libgnu_a_SOURCES += localeconv.c
577 948
578## end gnulib module localeconv 949## end gnulib module localeconv
579 950
@@ -583,6 +954,14 @@ libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
583 954
584## end gnulib module lock 955## end gnulib module lock
585 956
957## begin gnulib module lseek
958
959if GL_COND_OBJ_LSEEK
960libgnu_a_SOURCES += lseek.c
961endif
962
963## end gnulib module lseek
964
586## begin gnulib module malloc-gnu 965## begin gnulib module malloc-gnu
587 966
588 967
@@ -605,7 +984,7 @@ EXTRA_libgnu_a_SOURCES += malloc.c
605 984
606libgnu_a_SOURCES += malloca.c 985libgnu_a_SOURCES += malloca.c
607 986
608EXTRA_DIST += malloca.h malloca.valgrind 987EXTRA_DIST += malloca.h
609 988
610## end gnulib module malloca 989## end gnulib module malloca
611 990
@@ -617,109 +996,114 @@ libgnu_a_SOURCES += math.c
617# We need the following in order to create <math.h> when the system 996# We need the following in order to create <math.h> when the system
618# doesn't have one that works with the given compiler. 997# doesn't have one that works with the given compiler.
619math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 998math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
620 $(AM_V_GEN)rm -f $@-t $@ && \ 999 $(gl_V_at)$(SED_HEADER_STDOUT) \
621 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1000 -e 's|@''GUARD_PREFIX''@|GL|g' \
622 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
623 -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ 1001 -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
624 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1002 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
625 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1003 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
626 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \ 1004 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
627 -e 's/@''GNULIB_ACOSF''@/$(GNULIB_ACOSF)/g' \ 1005 -e 's/@''GNULIB_ACOSF''@/$(GL_GNULIB_ACOSF)/g' \
628 -e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \ 1006 -e 's/@''GNULIB_ACOSL''@/$(GL_GNULIB_ACOSL)/g' \
629 -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \ 1007 -e 's/@''GNULIB_ASINF''@/$(GL_GNULIB_ASINF)/g' \
630 -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \ 1008 -e 's/@''GNULIB_ASINL''@/$(GL_GNULIB_ASINL)/g' \
631 -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \ 1009 -e 's/@''GNULIB_ATANF''@/$(GL_GNULIB_ATANF)/g' \
632 -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \ 1010 -e 's/@''GNULIB_ATANL''@/$(GL_GNULIB_ATANL)/g' \
633 -e 's/@''GNULIB_ATAN2F''@/$(GNULIB_ATAN2F)/g' \ 1011 -e 's/@''GNULIB_ATAN2F''@/$(GL_GNULIB_ATAN2F)/g' \
634 -e 's/@''GNULIB_CBRT''@/$(GNULIB_CBRT)/g' \ 1012 -e 's/@''GNULIB_CBRT''@/$(GL_GNULIB_CBRT)/g' \
635 -e 's/@''GNULIB_CBRTF''@/$(GNULIB_CBRTF)/g' \ 1013 -e 's/@''GNULIB_CBRTF''@/$(GL_GNULIB_CBRTF)/g' \
636 -e 's/@''GNULIB_CBRTL''@/$(GNULIB_CBRTL)/g' \ 1014 -e 's/@''GNULIB_CBRTL''@/$(GL_GNULIB_CBRTL)/g' \
637 -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \ 1015 -e 's/@''GNULIB_CEIL''@/$(GL_GNULIB_CEIL)/g' \
638 -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \ 1016 -e 's/@''GNULIB_CEILF''@/$(GL_GNULIB_CEILF)/g' \
639 -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \ 1017 -e 's/@''GNULIB_CEILL''@/$(GL_GNULIB_CEILL)/g' \
640 -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \ 1018 -e 's/@''GNULIB_COPYSIGN''@/$(GL_GNULIB_COPYSIGN)/g' \
641 -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \ 1019 -e 's/@''GNULIB_COPYSIGNF''@/$(GL_GNULIB_COPYSIGNF)/g' \
642 -e 's/@''GNULIB_COPYSIGNL''@/$(GNULIB_COPYSIGNL)/g' \ 1020 -e 's/@''GNULIB_COPYSIGNL''@/$(GL_GNULIB_COPYSIGNL)/g' \
643 -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \ 1021 -e 's/@''GNULIB_COSF''@/$(GL_GNULIB_COSF)/g' \
644 -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \ 1022 -e 's/@''GNULIB_COSL''@/$(GL_GNULIB_COSL)/g' \
645 -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \ 1023 -e 's/@''GNULIB_COSHF''@/$(GL_GNULIB_COSHF)/g' \
646 -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \ 1024 -e 's/@''GNULIB_EXPF''@/$(GL_GNULIB_EXPF)/g' \
647 -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \ 1025 -e 's/@''GNULIB_EXPL''@/$(GL_GNULIB_EXPL)/g' \
648 -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \ 1026 -e 's/@''GNULIB_EXP2''@/$(GL_GNULIB_EXP2)/g' \
649 -e 's/@''GNULIB_EXP2F''@/$(GNULIB_EXP2F)/g' \ 1027 -e 's/@''GNULIB_EXP2F''@/$(GL_GNULIB_EXP2F)/g' \
650 -e 's/@''GNULIB_EXP2L''@/$(GNULIB_EXP2L)/g' \ 1028 -e 's/@''GNULIB_EXP2L''@/$(GL_GNULIB_EXP2L)/g' \
651 -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \ 1029 -e 's/@''GNULIB_EXPM1''@/$(GL_GNULIB_EXPM1)/g' \
652 -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \ 1030 -e 's/@''GNULIB_EXPM1F''@/$(GL_GNULIB_EXPM1F)/g' \
653 -e 's/@''GNULIB_EXPM1L''@/$(GNULIB_EXPM1L)/g' \ 1031 -e 's/@''GNULIB_EXPM1L''@/$(GL_GNULIB_EXPM1L)/g' \
654 -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \ 1032 -e 's/@''GNULIB_FABSF''@/$(GL_GNULIB_FABSF)/g' \
655 -e 's/@''GNULIB_FABSL''@/$(GNULIB_FABSL)/g' \ 1033 -e 's/@''GNULIB_FABSL''@/$(GL_GNULIB_FABSL)/g' \
656 -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \ 1034 -e 's/@''GNULIB_FLOOR''@/$(GL_GNULIB_FLOOR)/g' \
657 -e 's/@''GNULIB_FLOORF''@/$(GNULIB_FLOORF)/g' \ 1035 -e 's/@''GNULIB_FLOORF''@/$(GL_GNULIB_FLOORF)/g' \
658 -e 's/@''GNULIB_FLOORL''@/$(GNULIB_FLOORL)/g' \ 1036 -e 's/@''GNULIB_FLOORL''@/$(GL_GNULIB_FLOORL)/g' \
659 -e 's/@''GNULIB_FMA''@/$(GNULIB_FMA)/g' \ 1037 -e 's/@''GNULIB_FMA''@/$(GL_GNULIB_FMA)/g' \
660 -e 's/@''GNULIB_FMAF''@/$(GNULIB_FMAF)/g' \ 1038 -e 's/@''GNULIB_FMAF''@/$(GL_GNULIB_FMAF)/g' \
661 -e 's/@''GNULIB_FMAL''@/$(GNULIB_FMAL)/g' \ 1039 -e 's/@''GNULIB_FMAL''@/$(GL_GNULIB_FMAL)/g' \
662 -e 's/@''GNULIB_FMOD''@/$(GNULIB_FMOD)/g' \ 1040 -e 's/@''GNULIB_FMOD''@/$(GL_GNULIB_FMOD)/g' \
663 -e 's/@''GNULIB_FMODF''@/$(GNULIB_FMODF)/g' \ 1041 -e 's/@''GNULIB_FMODF''@/$(GL_GNULIB_FMODF)/g' \
664 -e 's/@''GNULIB_FMODL''@/$(GNULIB_FMODL)/g' \ 1042 -e 's/@''GNULIB_FMODL''@/$(GL_GNULIB_FMODL)/g' \
665 -e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \ 1043 -e 's/@''GNULIB_FREXPF''@/$(GL_GNULIB_FREXPF)/g' \
666 -e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \ 1044 -e 's/@''GNULIB_FREXP''@/$(GL_GNULIB_FREXP)/g' \
667 -e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \ 1045 -e 's/@''GNULIB_FREXPL''@/$(GL_GNULIB_FREXPL)/g' \
668 -e 's/@''GNULIB_HYPOT''@/$(GNULIB_HYPOT)/g' \ 1046 -e 's/@''GNULIB_HYPOT''@/$(GL_GNULIB_HYPOT)/g' \
669 -e 's/@''GNULIB_HYPOTF''@/$(GNULIB_HYPOTF)/g' \ 1047 -e 's/@''GNULIB_HYPOTF''@/$(GL_GNULIB_HYPOTF)/g' \
670 -e 's/@''GNULIB_HYPOTL''@/$(GNULIB_HYPOTL)/g' \ 1048 -e 's/@''GNULIB_HYPOTL''@/$(GL_GNULIB_HYPOTL)/g' \
671 < $(srcdir)/math.in.h | \ 1049 < $(srcdir)/math.in.h | \
672 sed -e 's/@''GNULIB_ILOGB''@/$(GNULIB_ILOGB)/g' \ 1050 sed -e 's/@''GNULIB_ILOGB''@/$(GL_GNULIB_ILOGB)/g' \
673 -e 's/@''GNULIB_ILOGBF''@/$(GNULIB_ILOGBF)/g' \ 1051 -e 's/@''GNULIB_ILOGBF''@/$(GL_GNULIB_ILOGBF)/g' \
674 -e 's/@''GNULIB_ILOGBL''@/$(GNULIB_ILOGBL)/g' \ 1052 -e 's/@''GNULIB_ILOGBL''@/$(GL_GNULIB_ILOGBL)/g' \
675 -e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \ 1053 -e 's/@''GNULIB_ISFINITE''@/$(GL_GNULIB_ISFINITE)/g' \
676 -e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \ 1054 -e 's/@''GNULIB_ISINF''@/$(GL_GNULIB_ISINF)/g' \
677 -e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \ 1055 -e 's/@''GNULIB_ISNAN''@/$(GL_GNULIB_ISNAN)/g' \
678 -e 's/@''GNULIB_ISNANF''@/$(GNULIB_ISNANF)/g' \ 1056 -e 's/@''GNULIB_ISNANF''@/$(GL_GNULIB_ISNANF)/g' \
679 -e 's/@''GNULIB_ISNAND''@/$(GNULIB_ISNAND)/g' \ 1057 -e 's/@''GNULIB_ISNAND''@/$(GL_GNULIB_ISNAND)/g' \
680 -e 's/@''GNULIB_ISNANL''@/$(GNULIB_ISNANL)/g' \ 1058 -e 's/@''GNULIB_ISNANL''@/$(GL_GNULIB_ISNANL)/g' \
681 -e 's/@''GNULIB_LDEXPF''@/$(GNULIB_LDEXPF)/g' \ 1059 -e 's/@''GNULIB_LDEXPF''@/$(GL_GNULIB_LDEXPF)/g' \
682 -e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \ 1060 -e 's/@''GNULIB_LDEXPL''@/$(GL_GNULIB_LDEXPL)/g' \
683 -e 's/@''GNULIB_LOG''@/$(GNULIB_LOG)/g' \ 1061 -e 's/@''GNULIB_LOG''@/$(GL_GNULIB_LOG)/g' \
684 -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \ 1062 -e 's/@''GNULIB_LOGF''@/$(GL_GNULIB_LOGF)/g' \
685 -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \ 1063 -e 's/@''GNULIB_LOGL''@/$(GL_GNULIB_LOGL)/g' \
686 -e 's/@''GNULIB_LOG10''@/$(GNULIB_LOG10)/g' \ 1064 -e 's/@''GNULIB_LOG10''@/$(GL_GNULIB_LOG10)/g' \
687 -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \ 1065 -e 's/@''GNULIB_LOG10F''@/$(GL_GNULIB_LOG10F)/g' \
688 -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \ 1066 -e 's/@''GNULIB_LOG10L''@/$(GL_GNULIB_LOG10L)/g' \
689 -e 's/@''GNULIB_LOG1P''@/$(GNULIB_LOG1P)/g' \ 1067 -e 's/@''GNULIB_LOG1P''@/$(GL_GNULIB_LOG1P)/g' \
690 -e 's/@''GNULIB_LOG1PF''@/$(GNULIB_LOG1PF)/g' \ 1068 -e 's/@''GNULIB_LOG1PF''@/$(GL_GNULIB_LOG1PF)/g' \
691 -e 's/@''GNULIB_LOG1PL''@/$(GNULIB_LOG1PL)/g' \ 1069 -e 's/@''GNULIB_LOG1PL''@/$(GL_GNULIB_LOG1PL)/g' \
692 -e 's/@''GNULIB_LOG2''@/$(GNULIB_LOG2)/g' \ 1070 -e 's/@''GNULIB_LOG2''@/$(GL_GNULIB_LOG2)/g' \
693 -e 's/@''GNULIB_LOG2F''@/$(GNULIB_LOG2F)/g' \ 1071 -e 's/@''GNULIB_LOG2F''@/$(GL_GNULIB_LOG2F)/g' \
694 -e 's/@''GNULIB_LOG2L''@/$(GNULIB_LOG2L)/g' \ 1072 -e 's/@''GNULIB_LOG2L''@/$(GL_GNULIB_LOG2L)/g' \
695 -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \ 1073 -e 's/@''GNULIB_LOGB''@/$(GL_GNULIB_LOGB)/g' \
696 -e 's/@''GNULIB_LOGBF''@/$(GNULIB_LOGBF)/g' \ 1074 -e 's/@''GNULIB_LOGBF''@/$(GL_GNULIB_LOGBF)/g' \
697 -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \ 1075 -e 's/@''GNULIB_LOGBL''@/$(GL_GNULIB_LOGBL)/g' \
698 -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \ 1076 -e 's/@''GNULIB_MODF''@/$(GL_GNULIB_MODF)/g' \
699 -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \ 1077 -e 's/@''GNULIB_MODFF''@/$(GL_GNULIB_MODFF)/g' \
700 -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \ 1078 -e 's/@''GNULIB_MODFL''@/$(GL_GNULIB_MODFL)/g' \
701 -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \ 1079 -e 's/@''GNULIB_POWF''@/$(GL_GNULIB_POWF)/g' \
702 -e 's/@''GNULIB_REMAINDER''@/$(GNULIB_REMAINDER)/g' \ 1080 -e 's/@''GNULIB_REMAINDER''@/$(GL_GNULIB_REMAINDER)/g' \
703 -e 's/@''GNULIB_REMAINDERF''@/$(GNULIB_REMAINDERF)/g' \ 1081 -e 's/@''GNULIB_REMAINDERF''@/$(GL_GNULIB_REMAINDERF)/g' \
704 -e 's/@''GNULIB_REMAINDERL''@/$(GNULIB_REMAINDERL)/g' \ 1082 -e 's/@''GNULIB_REMAINDERL''@/$(GL_GNULIB_REMAINDERL)/g' \
705 -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \ 1083 -e 's/@''GNULIB_RINT''@/$(GL_GNULIB_RINT)/g' \
706 -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \ 1084 -e 's/@''GNULIB_RINTF''@/$(GL_GNULIB_RINTF)/g' \
707 -e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \ 1085 -e 's/@''GNULIB_RINTL''@/$(GL_GNULIB_RINTL)/g' \
708 -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \ 1086 -e 's/@''GNULIB_ROUND''@/$(GL_GNULIB_ROUND)/g' \
709 -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \ 1087 -e 's/@''GNULIB_ROUNDF''@/$(GL_GNULIB_ROUNDF)/g' \
710 -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \ 1088 -e 's/@''GNULIB_ROUNDL''@/$(GL_GNULIB_ROUNDL)/g' \
711 -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ 1089 -e 's/@''GNULIB_SIGNBIT''@/$(GL_GNULIB_SIGNBIT)/g' \
712 -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \ 1090 -e 's/@''GNULIB_SINF''@/$(GL_GNULIB_SINF)/g' \
713 -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ 1091 -e 's/@''GNULIB_SINL''@/$(GL_GNULIB_SINL)/g' \
714 -e 's/@''GNULIB_SINHF''@/$(GNULIB_SINHF)/g' \ 1092 -e 's/@''GNULIB_SINHF''@/$(GL_GNULIB_SINHF)/g' \
715 -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ 1093 -e 's/@''GNULIB_SQRTF''@/$(GL_GNULIB_SQRTF)/g' \
716 -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ 1094 -e 's/@''GNULIB_SQRTL''@/$(GL_GNULIB_SQRTL)/g' \
717 -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \ 1095 -e 's/@''GNULIB_TANF''@/$(GL_GNULIB_TANF)/g' \
718 -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \ 1096 -e 's/@''GNULIB_TANL''@/$(GL_GNULIB_TANL)/g' \
719 -e 's/@''GNULIB_TANHF''@/$(GNULIB_TANHF)/g' \ 1097 -e 's/@''GNULIB_TANHF''@/$(GL_GNULIB_TANHF)/g' \
720 -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \ 1098 -e 's/@''GNULIB_TRUNC''@/$(GL_GNULIB_TRUNC)/g' \
721 -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \ 1099 -e 's/@''GNULIB_TRUNCF''@/$(GL_GNULIB_TRUNCF)/g' \
722 -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \ 1100 -e 's/@''GNULIB_TRUNCL''@/$(GL_GNULIB_TRUNCL)/g' \
1101 -e 's/@''GNULIB_MDA_J0''@/$(GL_GNULIB_MDA_J0)/g' \
1102 -e 's/@''GNULIB_MDA_J1''@/$(GL_GNULIB_MDA_J1)/g' \
1103 -e 's/@''GNULIB_MDA_JN''@/$(GL_GNULIB_MDA_JN)/g' \
1104 -e 's/@''GNULIB_MDA_Y0''@/$(GL_GNULIB_MDA_Y0)/g' \
1105 -e 's/@''GNULIB_MDA_Y1''@/$(GL_GNULIB_MDA_Y1)/g' \
1106 -e 's/@''GNULIB_MDA_YN''@/$(GL_GNULIB_MDA_YN)/g' \
723 | \ 1107 | \
724 sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \ 1108 sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \
725 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ 1109 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
@@ -818,13 +1202,22 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
818 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ 1202 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
819 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ 1203 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
820 | \ 1204 | \
821 sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \ 1205 sed -e 's|@''REPLACE_ACOSF''@|$(REPLACE_ACOSF)|g' \
1206 -e 's|@''REPLACE_ASINF''@|$(REPLACE_ASINF)|g' \
1207 -e 's|@''REPLACE_ATANF''@|$(REPLACE_ATANF)|g' \
1208 -e 's|@''REPLACE_ATAN2F''@|$(REPLACE_ATAN2F)|g' \
1209 -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
822 -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \ 1210 -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \
823 -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \ 1211 -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
824 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ 1212 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
825 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ 1213 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
1214 -e 's|@''REPLACE_COSF''@|$(REPLACE_COSF)|g' \
1215 -e 's|@''REPLACE_COSHF''@|$(REPLACE_COSHF)|g' \
1216 -e 's|@''REPLACE_EXPF''@|$(REPLACE_EXPF)|g' \
1217 -e 's|@''REPLACE_EXPL''@|$(REPLACE_EXPL)|g' \
826 -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \ 1218 -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \
827 -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \ 1219 -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \
1220 -e 's|@''REPLACE_EXPM1L''@|$(REPLACE_EXPM1L)|g' \
828 -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \ 1221 -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \
829 -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \ 1222 -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \
830 -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \ 1223 -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \
@@ -846,6 +1239,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
846 -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \ 1239 -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \
847 -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \ 1240 -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \
848 -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \ 1241 -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \
1242 -e 's|@''REPLACE_ILOGBL''@|$(REPLACE_ILOGBL)|g' \
849 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ 1243 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
850 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ 1244 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
851 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ 1245 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
@@ -873,20 +1267,26 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
873 -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \ 1267 -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \
874 -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \ 1268 -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \
875 -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \ 1269 -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \
1270 -e 's|@''REPLACE_RINTL''@|$(REPLACE_RINTL)|g' \
876 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ 1271 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
877 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ 1272 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
878 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ 1273 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
879 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ 1274 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
880 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ 1275 -e 's|@''REPLACE_SIGNBIT_USING_BUILTINS''@|$(REPLACE_SIGNBIT_USING_BUILTINS)|g' \
1276 -e 's|@''REPLACE_SINF''@|$(REPLACE_SINF)|g' \
1277 -e 's|@''REPLACE_SINHF''@|$(REPLACE_SINHF)|g' \
1278 -e 's|@''REPLACE_SQRTF''@|$(REPLACE_SQRTF)|g' \
881 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \ 1279 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
1280 -e 's|@''REPLACE_TANF''@|$(REPLACE_TANF)|g' \
1281 -e 's|@''REPLACE_TANHF''@|$(REPLACE_TANHF)|g' \
882 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \ 1282 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
883 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \ 1283 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \
884 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ 1284 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
885 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1285 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
886 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1286 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
887 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 1287 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
888 } > $@-t && \ 1288 > $@-t
889 mv $@-t $@ 1289 $(AM_V_at)mv $@-t $@
890MOSTLYCLEANFILES += math.h math.h-t 1290MOSTLYCLEANFILES += math.h math.h-t
891 1291
892EXTRA_DIST += math.in.h 1292EXTRA_DIST += math.in.h
@@ -895,40 +1295,50 @@ EXTRA_DIST += math.in.h
895 1295
896## begin gnulib module mbrtowc 1296## begin gnulib module mbrtowc
897 1297
1298if GL_COND_OBJ_MBRTOWC
1299libgnu_a_SOURCES += mbrtowc.c
1300endif
898 1301
899EXTRA_DIST += mbrtowc.c 1302EXTRA_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
900 1303
901EXTRA_libgnu_a_SOURCES += mbrtowc.c 1304EXTRA_libgnu_a_SOURCES += lc-charset-dispatch.c mbtowc-lock.c
902 1305
903## end gnulib module mbrtowc 1306## end gnulib module mbrtowc
904 1307
905## begin gnulib module mbsinit 1308## begin gnulib module mbsinit
906 1309
907 1310if GL_COND_OBJ_MBSINIT
908EXTRA_DIST += mbsinit.c 1311libgnu_a_SOURCES += mbsinit.c
909 1312endif
910EXTRA_libgnu_a_SOURCES += mbsinit.c
911 1313
912## end gnulib module mbsinit 1314## end gnulib module mbsinit
913 1315
914## begin gnulib module mbtowc 1316## begin gnulib module mbtowc
915 1317
1318if GL_COND_OBJ_MBTOWC
1319libgnu_a_SOURCES += mbtowc.c
1320endif
916 1321
917EXTRA_DIST += mbtowc-impl.h mbtowc.c 1322EXTRA_DIST += mbtowc-impl.h
918
919EXTRA_libgnu_a_SOURCES += mbtowc.c
920 1323
921## end gnulib module mbtowc 1324## end gnulib module mbtowc
922 1325
923## begin gnulib module memchr 1326## begin gnulib module memchr
924 1327
1328if GL_COND_OBJ_MEMCHR
1329libgnu_a_SOURCES += memchr.c
1330endif
925 1331
926EXTRA_DIST += memchr.c memchr.valgrind 1332EXTRA_DIST += memchr.valgrind
927
928EXTRA_libgnu_a_SOURCES += memchr.c
929 1333
930## end gnulib module memchr 1334## end gnulib module memchr
931 1335
1336## begin gnulib module minmax
1337
1338libgnu_a_SOURCES += minmax.h
1339
1340## end gnulib module minmax
1341
932## begin gnulib module mktime 1342## begin gnulib module mktime
933 1343
934 1344
@@ -949,28 +1359,31 @@ EXTRA_libgnu_a_SOURCES += mktime.c
949 1359
950## begin gnulib module mountlist 1360## begin gnulib module mountlist
951 1361
1362if GL_COND_OBJ_MOUNTLIST
1363libgnu_a_SOURCES += mountlist.c
1364endif
952 1365
953EXTRA_DIST += mountlist.c mountlist.h 1366EXTRA_DIST += mountlist.h
954
955EXTRA_libgnu_a_SOURCES += mountlist.c
956 1367
957## end gnulib module mountlist 1368## end gnulib module mountlist
958 1369
959## begin gnulib module msvc-inval 1370## begin gnulib module msvc-inval
960 1371
1372if GL_COND_OBJ_MSVC_INVAL
1373libgnu_a_SOURCES += msvc-inval.c
1374endif
961 1375
962EXTRA_DIST += msvc-inval.c msvc-inval.h 1376EXTRA_DIST += msvc-inval.h
963
964EXTRA_libgnu_a_SOURCES += msvc-inval.c
965 1377
966## end gnulib module msvc-inval 1378## end gnulib module msvc-inval
967 1379
968## begin gnulib module msvc-nothrow 1380## begin gnulib module msvc-nothrow
969 1381
1382if GL_COND_OBJ_MSVC_NOTHROW
1383libgnu_a_SOURCES += msvc-nothrow.c
1384endif
970 1385
971EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h 1386EXTRA_DIST += msvc-nothrow.h
972
973EXTRA_libgnu_a_SOURCES += msvc-nothrow.c
974 1387
975## end gnulib module msvc-nothrow 1388## end gnulib module msvc-nothrow
976 1389
@@ -981,27 +1394,26 @@ BUILT_SOURCES += netdb.h
981# We need the following in order to create <netdb.h> when the system 1394# We need the following in order to create <netdb.h> when the system
982# doesn't have one that works with the given compiler. 1395# doesn't have one that works with the given compiler.
983netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1396netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
984 $(AM_V_GEN)rm -f $@-t $@ && \ 1397 $(gl_V_at)$(SED_HEADER_STDOUT) \
985 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1398 -e 's|@''GUARD_PREFIX''@|GL|g' \
986 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
987 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1399 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
988 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1400 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
989 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1401 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
990 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \ 1402 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \
991 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \ 1403 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
992 -e 's/@''GNULIB_GETADDRINFO''@/$(GNULIB_GETADDRINFO)/g' \ 1404 -e 's/@''GNULIB_GETADDRINFO''@/$(GL_GNULIB_GETADDRINFO)/g' \
993 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \ 1405 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \
994 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \ 1406 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \
995 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \ 1407 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
996 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ 1408 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
997 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ 1409 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
998 -e 's|@''REPLACE_GAI_STRERROR''@|$(REPLACE_GAI_STRERROR)|g' \ 1410 -e 's|@''REPLACE_GAI_STRERROR''@|$(REPLACE_GAI_STRERROR)|g' \
1411 -e 's|@''REPLACE_GETADDRINFO''@|$(REPLACE_GETADDRINFO)|g' \
999 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1412 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1000 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1413 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1001 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 1414 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1002 < $(srcdir)/netdb.in.h; \ 1415 $(srcdir)/netdb.in.h > $@-t
1003 } > $@-t && \ 1416 $(AM_V_at)mv $@-t $@
1004 mv $@-t $@
1005MOSTLYCLEANFILES += netdb.h netdb.h-t 1417MOSTLYCLEANFILES += netdb.h netdb.h-t
1006 1418
1007EXTRA_DIST += netdb.in.h 1419EXTRA_DIST += netdb.in.h
@@ -1016,18 +1428,16 @@ BUILT_SOURCES += $(NETINET_IN_H)
1016# doesn't have one. 1428# doesn't have one.
1017if GL_GENERATE_NETINET_IN_H 1429if GL_GENERATE_NETINET_IN_H
1018netinet/in.h: netinet_in.in.h $(top_builddir)/config.status 1430netinet/in.h: netinet_in.in.h $(top_builddir)/config.status
1019 $(AM_V_at)$(MKDIR_P) netinet 1431 $(AM_V_GEN)$(MKDIR_P) '%reldir%/netinet'
1020 $(AM_V_GEN)rm -f $@-t $@ && \ 1432 $(AM_V_at)$(SED_HEADER_STDOUT) \
1021 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1433 -e 's|@''GUARD_PREFIX''@|GL|g' \
1022 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1023 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1434 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1024 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1435 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1025 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1436 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1026 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ 1437 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
1027 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ 1438 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
1028 < $(srcdir)/netinet_in.in.h; \ 1439 $(srcdir)/netinet_in.in.h > $@-t
1029 } > $@-t && \ 1440 $(AM_V_at)mv $@-t $@
1030 mv $@-t $@
1031else 1441else
1032netinet/in.h: $(top_builddir)/config.status 1442netinet/in.h: $(top_builddir)/config.status
1033 rm -f $@ 1443 rm -f $@
@@ -1041,48 +1451,89 @@ EXTRA_DIST += netinet_in.in.h
1041 1451
1042## begin gnulib module nl_langinfo 1452## begin gnulib module nl_langinfo
1043 1453
1454if GL_COND_OBJ_NL_LANGINFO
1455libgnu_a_SOURCES += nl_langinfo.c
1456endif
1457if GL_COND_OBJ_NL_LANGINFO_LOCK
1458libgnu_a_SOURCES += nl_langinfo-lock.c
1459endif
1044 1460
1045EXTRA_DIST += nl_langinfo.c 1461EXTRA_DIST += windows-initguard.h
1046
1047EXTRA_libgnu_a_SOURCES += nl_langinfo.c
1048 1462
1049## end gnulib module nl_langinfo 1463## end gnulib module nl_langinfo
1050 1464
1051## begin gnulib module read 1465## begin gnulib module open
1052 1466
1467if GL_COND_OBJ_OPEN
1468libgnu_a_SOURCES += open.c
1469endif
1053 1470
1054EXTRA_DIST += read.c 1471## end gnulib module open
1055 1472
1056EXTRA_libgnu_a_SOURCES += read.c 1473## begin gnulib module pathmax
1057 1474
1058## end gnulib module read
1059 1475
1060## begin gnulib module regex 1476EXTRA_DIST += pathmax.h
1061 1477
1478## end gnulib module pathmax
1062 1479
1063EXTRA_DIST += regcomp.c regex.c regex.h regex_internal.c regex_internal.h regexec.c 1480## begin gnulib module realloc-gnu
1064 1481
1065EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
1066 1482
1067## end gnulib module regex 1483EXTRA_DIST += realloc.c
1068 1484
1069## begin gnulib module safe-read 1485EXTRA_libgnu_a_SOURCES += realloc.c
1070 1486
1071libgnu_a_SOURCES += safe-read.c 1487## end gnulib module realloc-gnu
1072 1488
1073EXTRA_DIST += safe-read.h 1489## begin gnulib module realloc-posix
1074 1490
1075## end gnulib module safe-read
1076 1491
1077## begin gnulib module setenv 1492EXTRA_DIST += realloc.c
1493
1494EXTRA_libgnu_a_SOURCES += realloc.c
1495
1496## end gnulib module realloc-posix
1497
1498## begin gnulib module reallocarray
1499
1500if GL_COND_OBJ_REALLOCARRAY
1501libgnu_a_SOURCES += reallocarray.c
1502endif
1078 1503
1504## end gnulib module reallocarray
1079 1505
1080EXTRA_DIST += setenv.c 1506## begin gnulib module regex
1507
1508if GL_COND_OBJ_REGEX
1509libgnu_a_SOURCES += regex.c
1510endif
1511
1512EXTRA_DIST += regcomp.c regex.h regex_internal.c regex_internal.h regexec.c
1513
1514EXTRA_libgnu_a_SOURCES += regcomp.c regex_internal.c regexec.c
1515
1516## end gnulib module regex
1517
1518## begin gnulib module setenv
1081 1519
1082EXTRA_libgnu_a_SOURCES += setenv.c 1520if GL_COND_OBJ_SETENV
1521libgnu_a_SOURCES += setenv.c
1522endif
1083 1523
1084## end gnulib module setenv 1524## end gnulib module setenv
1085 1525
1526## begin gnulib module setlocale-null
1527
1528libgnu_a_SOURCES += setlocale_null.c
1529if GL_COND_OBJ_SETLOCALE_LOCK
1530libgnu_a_SOURCES += setlocale-lock.c
1531endif
1532
1533EXTRA_DIST += setlocale_null.h windows-initguard.h
1534
1535## end gnulib module setlocale-null
1536
1086## begin gnulib module size_max 1537## begin gnulib module size_max
1087 1538
1088libgnu_a_SOURCES += size_max.h 1539libgnu_a_SOURCES += size_max.h
@@ -1092,81 +1543,48 @@ libgnu_a_SOURCES += size_max.h
1092## begin gnulib module snippet/_Noreturn 1543## begin gnulib module snippet/_Noreturn
1093 1544
1094# Because this Makefile snippet defines a variable used by other 1545# Because this Makefile snippet defines a variable used by other
1095# gnulib Makefile snippets, it must be present in all Makefile.am that 1546# gnulib Makefile snippets, it must be present in all makefiles that
1096# need it. This is ensured by the applicability 'all' defined above. 1547# need it. This is ensured by the applicability 'all' defined above.
1097 1548
1098_NORETURN_H=$(top_srcdir)/build-aux/snippet/_Noreturn.h 1549_NORETURN_H=$(srcdir)/_Noreturn.h
1099 1550
1100EXTRA_DIST += $(top_srcdir)/build-aux/snippet/_Noreturn.h 1551EXTRA_DIST += _Noreturn.h
1101 1552
1102## end gnulib module snippet/_Noreturn 1553## end gnulib module snippet/_Noreturn
1103 1554
1104## begin gnulib module snippet/arg-nonnull 1555## begin gnulib module snippet/arg-nonnull
1105 1556
1106# The BUILT_SOURCES created by this Makefile snippet are not used via #include 1557# Because this Makefile snippet defines a variable used by other
1107# statements but through direct file reference. Therefore this snippet must be 1558# gnulib Makefile snippets, it must be present in all makefiles that
1108# present in all Makefile.am that need it. This is ensured by the applicability 1559# need it. This is ensured by the applicability 'all' defined above.
1109# 'all' defined above.
1110
1111BUILT_SOURCES += arg-nonnull.h
1112# The arg-nonnull.h that gets inserted into generated .h files is the same as
1113# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
1114# off.
1115arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
1116 $(AM_V_GEN)rm -f $@-t $@ && \
1117 sed -n -e '/GL_ARG_NONNULL/,$$p' \
1118 < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
1119 > $@-t && \
1120 mv $@-t $@
1121MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
1122 1560
1123ARG_NONNULL_H=arg-nonnull.h 1561ARG_NONNULL_H=$(srcdir)/arg-nonnull.h
1124 1562
1125EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h 1563EXTRA_DIST += arg-nonnull.h
1126 1564
1127## end gnulib module snippet/arg-nonnull 1565## end gnulib module snippet/arg-nonnull
1128 1566
1129## begin gnulib module snippet/c++defs 1567## begin gnulib module snippet/c++defs
1130 1568
1131# The BUILT_SOURCES created by this Makefile snippet are not used via #include 1569# Because this Makefile snippet defines a variable used by other
1132# statements but through direct file reference. Therefore this snippet must be 1570# gnulib Makefile snippets, it must be present in all makefiles that
1133# present in all Makefile.am that need it. This is ensured by the applicability 1571# need it. This is ensured by the applicability 'all' defined above.
1134# 'all' defined above.
1135
1136BUILT_SOURCES += c++defs.h
1137# The c++defs.h that gets inserted into generated .h files is the same as
1138# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
1139c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
1140 $(AM_V_GEN)rm -f $@-t $@ && \
1141 sed -n -e '/_GL_CXXDEFS/,$$p' \
1142 < $(top_srcdir)/build-aux/snippet/c++defs.h \
1143 > $@-t && \
1144 mv $@-t $@
1145MOSTLYCLEANFILES += c++defs.h c++defs.h-t
1146 1572
1147CXXDEFS_H=c++defs.h 1573CXXDEFS_H=$(srcdir)/c++defs.h
1148 1574
1149EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h 1575EXTRA_DIST += c++defs.h
1150 1576
1151## end gnulib module snippet/c++defs 1577## end gnulib module snippet/c++defs
1152 1578
1153## begin gnulib module snippet/warn-on-use 1579## begin gnulib module snippet/warn-on-use
1154 1580
1155BUILT_SOURCES += warn-on-use.h 1581# Because this Makefile snippet defines a variable used by other
1156# The warn-on-use.h that gets inserted into generated .h files is the same as 1582# gnulib Makefile snippets, it must be present in all makefiles that
1157# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut 1583# need it. This is ensured by the applicability 'all' defined above.
1158# off.
1159warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
1160 $(AM_V_GEN)rm -f $@-t $@ && \
1161 sed -n -e '/^.ifndef/,$$p' \
1162 < $(top_srcdir)/build-aux/snippet/warn-on-use.h \
1163 > $@-t && \
1164 mv $@-t $@
1165MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
1166 1584
1167WARN_ON_USE_H=warn-on-use.h 1585WARN_ON_USE_H=$(srcdir)/warn-on-use.h
1168 1586
1169EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h 1587EXTRA_DIST += warn-on-use.h
1170 1588
1171## end gnulib module snippet/warn-on-use 1589## end gnulib module snippet/warn-on-use
1172 1590
@@ -1187,6 +1605,26 @@ EXTRA_DIST += w32sock.h
1187 1605
1188## end gnulib module sockets 1606## end gnulib module sockets
1189 1607
1608## begin gnulib module stat
1609
1610if GL_COND_OBJ_STAT
1611libgnu_a_SOURCES += stat.c
1612endif
1613
1614EXTRA_DIST += stat-w32.c stat-w32.h
1615
1616EXTRA_libgnu_a_SOURCES += stat-w32.c
1617
1618## end gnulib module stat
1619
1620## begin gnulib module stat-time
1621
1622libgnu_a_SOURCES += stat-time.c
1623
1624EXTRA_DIST += stat-time.h
1625
1626## end gnulib module stat-time
1627
1190## begin gnulib module stdalign 1628## begin gnulib module stdalign
1191 1629
1192BUILT_SOURCES += $(STDALIGN_H) 1630BUILT_SOURCES += $(STDALIGN_H)
@@ -1195,11 +1633,8 @@ BUILT_SOURCES += $(STDALIGN_H)
1195# doesn't have one that works. 1633# doesn't have one that works.
1196if GL_GENERATE_STDALIGN_H 1634if GL_GENERATE_STDALIGN_H
1197stdalign.h: stdalign.in.h $(top_builddir)/config.status 1635stdalign.h: stdalign.in.h $(top_builddir)/config.status
1198 $(AM_V_GEN)rm -f $@-t $@ && \ 1636 $(gl_V_at)$(SED_HEADER_TO_AT_t) $(srcdir)/stdalign.in.h
1199 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1637 $(AM_V_at)mv $@-t $@
1200 cat $(srcdir)/stdalign.in.h; \
1201 } > $@-t && \
1202 mv $@-t $@
1203else 1638else
1204stdalign.h: $(top_builddir)/config.status 1639stdalign.h: $(top_builddir)/config.status
1205 rm -f $@ 1640 rm -f $@
@@ -1210,28 +1645,26 @@ EXTRA_DIST += stdalign.in.h
1210 1645
1211## end gnulib module stdalign 1646## end gnulib module stdalign
1212 1647
1213## begin gnulib module stdbool 1648## begin gnulib module stdckdint
1214 1649
1215BUILT_SOURCES += $(STDBOOL_H) 1650BUILT_SOURCES += $(STDCKDINT_H)
1216 1651
1217# We need the following in order to create <stdbool.h> when the system 1652# We need the following in order to create <stdckdint.h> when the system
1218# doesn't have one that works. 1653# doesn't have one that works with the given compiler.
1219if GL_GENERATE_STDBOOL_H 1654if GL_GENERATE_STDCKDINT_H
1220stdbool.h: stdbool.in.h $(top_builddir)/config.status 1655stdckdint.h: stdckdint.in.h $(top_builddir)/config.status
1221 $(AM_V_GEN)rm -f $@-t $@ && \ 1656 $(gl_V_at)$(SED_HEADER_STDOUT) \
1222 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1657 $(srcdir)/stdckdint.in.h > $@-t
1223 sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ 1658 $(AM_V_at)mv $@-t $@
1224 } > $@-t && \
1225 mv $@-t $@
1226else 1659else
1227stdbool.h: $(top_builddir)/config.status 1660stdckdint.h: $(top_builddir)/config.status
1228 rm -f $@ 1661 rm -f $@
1229endif 1662endif
1230MOSTLYCLEANFILES += stdbool.h stdbool.h-t 1663MOSTLYCLEANFILES += stdckdint.h stdckdint.h-t
1231 1664
1232EXTRA_DIST += stdbool.in.h 1665EXTRA_DIST += intprops-internal.h stdckdint.in.h
1233 1666
1234## end gnulib module stdbool 1667## end gnulib module stdckdint
1235 1668
1236## begin gnulib module stddef 1669## begin gnulib module stddef
1237 1670
@@ -1241,18 +1674,17 @@ BUILT_SOURCES += $(STDDEF_H)
1241# doesn't have one that works with the given compiler. 1674# doesn't have one that works with the given compiler.
1242if GL_GENERATE_STDDEF_H 1675if GL_GENERATE_STDDEF_H
1243stddef.h: stddef.in.h $(top_builddir)/config.status 1676stddef.h: stddef.in.h $(top_builddir)/config.status
1244 $(AM_V_GEN)rm -f $@-t $@ && \ 1677 $(gl_V_at)$(SED_HEADER_STDOUT) \
1245 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1678 -e 's|@''GUARD_PREFIX''@|GL|g' \
1246 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1247 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1679 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1248 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1680 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1249 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1681 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1250 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ 1682 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
1683 -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
1251 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ 1684 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
1252 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ 1685 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
1253 < $(srcdir)/stddef.in.h; \ 1686 $(srcdir)/stddef.in.h > $@-t
1254 } > $@-t && \ 1687 $(AM_V_at)mv $@-t $@
1255 mv $@-t $@
1256else 1688else
1257stddef.h: $(top_builddir)/config.status 1689stddef.h: $(top_builddir)/config.status
1258 rm -f $@ 1690 rm -f $@
@@ -1271,21 +1703,19 @@ BUILT_SOURCES += $(STDINT_H)
1271# doesn't have one that works with the given compiler. 1703# doesn't have one that works with the given compiler.
1272if GL_GENERATE_STDINT_H 1704if GL_GENERATE_STDINT_H
1273stdint.h: stdint.in.h $(top_builddir)/config.status 1705stdint.h: stdint.in.h $(top_builddir)/config.status
1274 $(AM_V_GEN)rm -f $@-t $@ && \ 1706 $(gl_V_at)$(SED_HEADER_STDOUT) \
1275 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1707 -e 's|@''GUARD_PREFIX''@|GL|g' \
1276 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1277 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ 1708 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
1278 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1709 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1279 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1710 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1280 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1711 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1281 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ 1712 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
1713 -e 's/@''HAVE_C99_STDINT_H''@/$(HAVE_C99_STDINT_H)/g' \
1282 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ 1714 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
1283 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ 1715 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
1284 -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ 1716 -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
1285 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ 1717 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
1286 -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ 1718 -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
1287 -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
1288 -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
1289 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ 1719 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
1290 -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ 1720 -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
1291 -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ 1721 -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
@@ -1300,9 +1730,9 @@ stdint.h: stdint.in.h $(top_builddir)/config.status
1300 -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \ 1730 -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
1301 -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ 1731 -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
1302 -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ 1732 -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
1303 < $(srcdir)/stdint.in.h; \ 1733 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
1304 } > $@-t && \ 1734 $(srcdir)/stdint.in.h > $@-t
1305 mv $@-t $@ 1735 $(AM_V_at)mv $@-t $@
1306else 1736else
1307stdint.h: $(top_builddir)/config.status 1737stdint.h: $(top_builddir)/config.status
1308 rm -f $@ 1738 rm -f $@
@@ -1320,68 +1750,75 @@ BUILT_SOURCES += stdio.h
1320# We need the following in order to create <stdio.h> when the system 1750# We need the following in order to create <stdio.h> when the system
1321# doesn't have one that works with the given compiler. 1751# doesn't have one that works with the given compiler.
1322stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1752stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1323 $(AM_V_GEN)rm -f $@-t $@ && \ 1753 $(gl_V_at)$(SED_HEADER_STDOUT) \
1324 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1754 -e 's|@''GUARD_PREFIX''@|GL|g' \
1325 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1326 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1755 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1327 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1756 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1328 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1757 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1329 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ 1758 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
1330 -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \ 1759 -e 's/@''GNULIB_DPRINTF''@/$(GL_GNULIB_DPRINTF)/g' \
1331 -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \ 1760 -e 's/@''GNULIB_FCLOSE''@/$(GL_GNULIB_FCLOSE)/g' \
1332 -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \ 1761 -e 's/@''GNULIB_FDOPEN''@/$(GL_GNULIB_FDOPEN)/g' \
1333 -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \ 1762 -e 's/@''GNULIB_FFLUSH''@/$(GL_GNULIB_FFLUSH)/g' \
1334 -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \ 1763 -e 's/@''GNULIB_FGETC''@/$(GL_GNULIB_FGETC)/g' \
1335 -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \ 1764 -e 's/@''GNULIB_FGETS''@/$(GL_GNULIB_FGETS)/g' \
1336 -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \ 1765 -e 's/@''GNULIB_FOPEN''@/$(GL_GNULIB_FOPEN)/g' \
1337 -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \ 1766 -e 's/@''GNULIB_FOPEN_GNU''@/$(GL_GNULIB_FOPEN_GNU)/g' \
1338 -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \ 1767 -e 's/@''GNULIB_FPRINTF''@/$(GL_GNULIB_FPRINTF)/g' \
1339 -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \ 1768 -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GL_GNULIB_FPRINTF_POSIX)/g' \
1340 -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \ 1769 -e 's/@''GNULIB_FPURGE''@/$(GL_GNULIB_FPURGE)/g' \
1341 -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \ 1770 -e 's/@''GNULIB_FPUTC''@/$(GL_GNULIB_FPUTC)/g' \
1342 -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \ 1771 -e 's/@''GNULIB_FPUTS''@/$(GL_GNULIB_FPUTS)/g' \
1343 -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \ 1772 -e 's/@''GNULIB_FREAD''@/$(GL_GNULIB_FREAD)/g' \
1344 -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \ 1773 -e 's/@''GNULIB_FREOPEN''@/$(GL_GNULIB_FREOPEN)/g' \
1345 -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \ 1774 -e 's/@''GNULIB_FSCANF''@/$(GL_GNULIB_FSCANF)/g' \
1346 -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \ 1775 -e 's/@''GNULIB_FSEEK''@/$(GL_GNULIB_FSEEK)/g' \
1347 -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \ 1776 -e 's/@''GNULIB_FSEEKO''@/$(GL_GNULIB_FSEEKO)/g' \
1348 -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \ 1777 -e 's/@''GNULIB_FTELL''@/$(GL_GNULIB_FTELL)/g' \
1349 -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \ 1778 -e 's/@''GNULIB_FTELLO''@/$(GL_GNULIB_FTELLO)/g' \
1350 -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \ 1779 -e 's/@''GNULIB_FWRITE''@/$(GL_GNULIB_FWRITE)/g' \
1351 -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \ 1780 -e 's/@''GNULIB_GETC''@/$(GL_GNULIB_GETC)/g' \
1352 -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \ 1781 -e 's/@''GNULIB_GETCHAR''@/$(GL_GNULIB_GETCHAR)/g' \
1353 -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \ 1782 -e 's/@''GNULIB_GETDELIM''@/$(GL_GNULIB_GETDELIM)/g' \
1354 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \ 1783 -e 's/@''GNULIB_GETLINE''@/$(GL_GNULIB_GETLINE)/g' \
1355 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \ 1784 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GL_GNULIB_OBSTACK_PRINTF)/g' \
1356 -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \ 1785 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GL_GNULIB_OBSTACK_PRINTF_POSIX)/g' \
1357 -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \ 1786 -e 's/@''GNULIB_PCLOSE''@/$(GL_GNULIB_PCLOSE)/g' \
1358 -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \ 1787 -e 's/@''GNULIB_PERROR''@/$(GL_GNULIB_PERROR)/g' \
1359 -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \ 1788 -e 's/@''GNULIB_POPEN''@/$(GL_GNULIB_POPEN)/g' \
1360 -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \ 1789 -e 's/@''GNULIB_PRINTF''@/$(GL_GNULIB_PRINTF)/g' \
1361 -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \ 1790 -e 's/@''GNULIB_PRINTF_POSIX''@/$(GL_GNULIB_PRINTF_POSIX)/g' \
1362 -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \ 1791 -e 's/@''GNULIB_PUTC''@/$(GL_GNULIB_PUTC)/g' \
1363 -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \ 1792 -e 's/@''GNULIB_PUTCHAR''@/$(GL_GNULIB_PUTCHAR)/g' \
1364 -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \ 1793 -e 's/@''GNULIB_PUTS''@/$(GL_GNULIB_PUTS)/g' \
1365 -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \ 1794 -e 's/@''GNULIB_REMOVE''@/$(GL_GNULIB_REMOVE)/g' \
1366 -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \ 1795 -e 's/@''GNULIB_RENAME''@/$(GL_GNULIB_RENAME)/g' \
1367 -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \ 1796 -e 's/@''GNULIB_RENAMEAT''@/$(GL_GNULIB_RENAMEAT)/g' \
1368 -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \ 1797 -e 's/@''GNULIB_SCANF''@/$(GL_GNULIB_SCANF)/g' \
1369 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \ 1798 -e 's/@''GNULIB_SNPRINTF''@/$(GL_GNULIB_SNPRINTF)/g' \
1370 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \ 1799 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GL_GNULIB_SPRINTF_POSIX)/g' \
1371 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \ 1800 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GL_GNULIB_STDIO_H_NONBLOCKING)/g' \
1372 -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \ 1801 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GL_GNULIB_STDIO_H_SIGPIPE)/g' \
1373 -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \ 1802 -e 's/@''GNULIB_TMPFILE''@/$(GL_GNULIB_TMPFILE)/g' \
1374 -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \ 1803 -e 's/@''GNULIB_VASPRINTF''@/$(GL_GNULIB_VASPRINTF)/g' \
1375 -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \ 1804 -e 's/@''GNULIB_VDPRINTF''@/$(GL_GNULIB_VDPRINTF)/g' \
1376 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \ 1805 -e 's/@''GNULIB_VFPRINTF''@/$(GL_GNULIB_VFPRINTF)/g' \
1377 -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \ 1806 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GL_GNULIB_VFPRINTF_POSIX)/g' \
1378 -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \ 1807 -e 's/@''GNULIB_VFSCANF''@/$(GL_GNULIB_VFSCANF)/g' \
1379 -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \ 1808 -e 's/@''GNULIB_VSCANF''@/$(GL_GNULIB_VSCANF)/g' \
1380 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \ 1809 -e 's/@''GNULIB_VPRINTF''@/$(GL_GNULIB_VPRINTF)/g' \
1381 -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \ 1810 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GL_GNULIB_VPRINTF_POSIX)/g' \
1382 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \ 1811 -e 's/@''GNULIB_VSNPRINTF''@/$(GL_GNULIB_VSNPRINTF)/g' \
1812 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GL_GNULIB_VSPRINTF_POSIX)/g' \
1813 -e 's/@''GNULIB_MDA_FCLOSEALL''@/$(GL_GNULIB_MDA_FCLOSEALL)/g' \
1814 -e 's/@''GNULIB_MDA_FDOPEN''@/$(GL_GNULIB_MDA_FDOPEN)/g' \
1815 -e 's/@''GNULIB_MDA_FILENO''@/$(GL_GNULIB_MDA_FILENO)/g' \
1816 -e 's/@''GNULIB_MDA_GETW''@/$(GL_GNULIB_MDA_GETW)/g' \
1817 -e 's/@''GNULIB_MDA_PUTW''@/$(GL_GNULIB_MDA_PUTW)/g' \
1818 -e 's/@''GNULIB_MDA_TEMPNAM''@/$(GL_GNULIB_MDA_TEMPNAM)/g' \
1383 < $(srcdir)/stdio.in.h | \ 1819 < $(srcdir)/stdio.in.h | \
1384 sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ 1820 sed -e 's|@''HAVE_DECL_FCLOSEALL''@|$(HAVE_DECL_FCLOSEALL)|g' \
1821 -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
1385 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ 1822 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
1386 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ 1823 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
1387 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ 1824 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
@@ -1402,6 +1839,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1402 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \ 1839 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
1403 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ 1840 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
1404 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ 1841 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
1842 -e 's|@''REPLACE_FOPEN_FOR_FOPEN_GNU''@|$(REPLACE_FOPEN_FOR_FOPEN_GNU)|g' \
1405 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ 1843 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
1406 -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ 1844 -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
1407 -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ 1845 -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
@@ -1432,11 +1870,18 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
1432 -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \ 1870 -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \
1433 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1871 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1434 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1872 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1435 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 1873 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1436 } > $@-t && \ 1874 > $@-t
1437 mv $@-t $@ 1875 $(AM_V_at)mv $@-t $@
1438MOSTLYCLEANFILES += stdio.h stdio.h-t 1876MOSTLYCLEANFILES += stdio.h stdio.h-t
1439 1877
1878if GL_COND_OBJ_STDIO_READ
1879libgnu_a_SOURCES += stdio-read.c
1880endif
1881if GL_COND_OBJ_STDIO_WRITE
1882libgnu_a_SOURCES += stdio-write.c
1883endif
1884
1440EXTRA_DIST += stdio.in.h 1885EXTRA_DIST += stdio.in.h
1441 1886
1442## end gnulib module stdio 1887## end gnulib module stdio
@@ -1449,95 +1894,141 @@ BUILT_SOURCES += stdlib.h
1449# doesn't have one that works with the given compiler. 1894# doesn't have one that works with the given compiler.
1450stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \ 1895stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1451 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1896 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1452 $(AM_V_GEN)rm -f $@-t $@ && \ 1897 $(gl_V_at)$(SED_HEADER_STDOUT) \
1453 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1898 -e 's|@''GUARD_PREFIX''@|GL|g' \
1454 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1455 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1899 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1456 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1900 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1457 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 1901 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1458 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ 1902 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
1459 -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \ 1903 -e 's/@''GNULIB__EXIT''@/$(GL_GNULIB__EXIT)/g' \
1460 -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \ 1904 -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GL_GNULIB_ALIGNED_ALLOC)/g' \
1461 -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \ 1905 -e 's/@''GNULIB_ATOLL''@/$(GL_GNULIB_ATOLL)/g' \
1462 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \ 1906 -e 's/@''GNULIB_CALLOC_GNU''@/$(GL_GNULIB_CALLOC_GNU)/g' \
1463 -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \ 1907 -e 's/@''GNULIB_CALLOC_POSIX''@/$(GL_GNULIB_CALLOC_POSIX)/g' \
1464 -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \ 1908 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GL_GNULIB_CANONICALIZE_FILE_NAME)/g' \
1465 -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \ 1909 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
1466 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \ 1910 -e 's/@''GNULIB_GETLOADAVG''@/$(GL_GNULIB_GETLOADAVG)/g' \
1467 -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \ 1911 -e 's/@''GNULIB_GETSUBOPT''@/$(GL_GNULIB_GETSUBOPT)/g' \
1468 -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \ 1912 -e 's/@''GNULIB_GRANTPT''@/$(GL_GNULIB_GRANTPT)/g' \
1469 -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \ 1913 -e 's/@''GNULIB_MALLOC_GNU''@/$(GL_GNULIB_MALLOC_GNU)/g' \
1470 -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \ 1914 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GL_GNULIB_MALLOC_POSIX)/g' \
1471 -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \ 1915 -e 's/@''GNULIB_MBTOWC''@/$(GL_GNULIB_MBTOWC)/g' \
1472 -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \ 1916 -e 's/@''GNULIB_MKDTEMP''@/$(GL_GNULIB_MKDTEMP)/g' \
1473 -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \ 1917 -e 's/@''GNULIB_MKOSTEMP''@/$(GL_GNULIB_MKOSTEMP)/g' \
1474 -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \ 1918 -e 's/@''GNULIB_MKOSTEMPS''@/$(GL_GNULIB_MKOSTEMPS)/g' \
1475 -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \ 1919 -e 's/@''GNULIB_MKSTEMP''@/$(GL_GNULIB_MKSTEMP)/g' \
1476 -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \ 1920 -e 's/@''GNULIB_MKSTEMPS''@/$(GL_GNULIB_MKSTEMPS)/g' \
1477 -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \ 1921 -e 's/@''GNULIB_POSIX_MEMALIGN''@/$(GL_GNULIB_POSIX_MEMALIGN)/g' \
1478 -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \ 1922 -e 's/@''GNULIB_POSIX_OPENPT''@/$(GL_GNULIB_POSIX_OPENPT)/g' \
1479 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \ 1923 -e 's/@''GNULIB_PTSNAME''@/$(GL_GNULIB_PTSNAME)/g' \
1480 -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \ 1924 -e 's/@''GNULIB_PTSNAME_R''@/$(GL_GNULIB_PTSNAME_R)/g' \
1481 -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \ 1925 -e 's/@''GNULIB_PUTENV''@/$(GL_GNULIB_PUTENV)/g' \
1482 -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \ 1926 -e 's/@''GNULIB_QSORT_R''@/$(GL_GNULIB_QSORT_R)/g' \
1483 -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \ 1927 -e 's/@''GNULIB_RANDOM''@/$(GL_GNULIB_RANDOM)/g' \
1484 -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \ 1928 -e 's/@''GNULIB_RANDOM_R''@/$(GL_GNULIB_RANDOM_R)/g' \
1485 -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \ 1929 -e 's/@''GNULIB_REALLOC_GNU''@/$(GL_GNULIB_REALLOC_GNU)/g' \
1486 -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \ 1930 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GL_GNULIB_REALLOC_POSIX)/g' \
1487 -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \ 1931 -e 's/@''GNULIB_REALLOCARRAY''@/$(GL_GNULIB_REALLOCARRAY)/g' \
1488 -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \ 1932 -e 's/@''GNULIB_REALPATH''@/$(GL_GNULIB_REALPATH)/g' \
1489 -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \ 1933 -e 's/@''GNULIB_RPMATCH''@/$(GL_GNULIB_RPMATCH)/g' \
1490 -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \ 1934 -e 's/@''GNULIB_SECURE_GETENV''@/$(GL_GNULIB_SECURE_GETENV)/g' \
1935 -e 's/@''GNULIB_SETENV''@/$(GL_GNULIB_SETENV)/g' \
1936 -e 's/@''GNULIB_STRTOD''@/$(GL_GNULIB_STRTOD)/g' \
1937 -e 's/@''GNULIB_STRTOL''@/$(GL_GNULIB_STRTOL)/g' \
1938 -e 's/@''GNULIB_STRTOLD''@/$(GL_GNULIB_STRTOLD)/g' \
1939 -e 's/@''GNULIB_STRTOLL''@/$(GL_GNULIB_STRTOLL)/g' \
1940 -e 's/@''GNULIB_STRTOUL''@/$(GL_GNULIB_STRTOUL)/g' \
1941 -e 's/@''GNULIB_STRTOULL''@/$(GL_GNULIB_STRTOULL)/g' \
1942 -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GL_GNULIB_SYSTEM_POSIX)/g' \
1943 -e 's/@''GNULIB_UNLOCKPT''@/$(GL_GNULIB_UNLOCKPT)/g' \
1944 -e 's/@''GNULIB_UNSETENV''@/$(GL_GNULIB_UNSETENV)/g' \
1945 -e 's/@''GNULIB_WCTOMB''@/$(GL_GNULIB_WCTOMB)/g' \
1946 -e 's/@''GNULIB_MDA_ECVT''@/$(GL_GNULIB_MDA_ECVT)/g' \
1947 -e 's/@''GNULIB_MDA_FCVT''@/$(GL_GNULIB_MDA_FCVT)/g' \
1948 -e 's/@''GNULIB_MDA_GCVT''@/$(GL_GNULIB_MDA_GCVT)/g' \
1949 -e 's/@''GNULIB_MDA_MKTEMP''@/$(GL_GNULIB_MDA_MKTEMP)/g' \
1950 -e 's/@''GNULIB_MDA_PUTENV''@/$(GL_GNULIB_MDA_PUTENV)/g' \
1491 < $(srcdir)/stdlib.in.h | \ 1951 < $(srcdir)/stdlib.in.h | \
1492 sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ 1952 sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
1953 -e 's|@''HAVE_ALIGNED_ALLOC''@|$(HAVE_ALIGNED_ALLOC)|g' \
1493 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ 1954 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
1494 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ 1955 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
1956 -e 's|@''HAVE_DECL_ECVT''@|$(HAVE_DECL_ECVT)|g' \
1957 -e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \
1958 -e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \
1495 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ 1959 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
1496 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ 1960 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
1497 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ 1961 -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
1962 -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \
1963 -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
1964 -e 's|@''HAVE_MBTOWC''@|$(HAVE_MBTOWC)|g' \
1498 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ 1965 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
1499 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ 1966 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
1500 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ 1967 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
1501 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ 1968 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
1502 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ 1969 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
1970 -e 's|@''HAVE_POSIX_MEMALIGN''@|$(HAVE_POSIX_MEMALIGN)|g' \
1503 -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \ 1971 -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
1504 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ 1972 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
1505 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \ 1973 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
1974 -e 's|@''HAVE_QSORT_R''@|$(HAVE_QSORT_R)|g' \
1506 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \ 1975 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
1507 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ 1976 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
1508 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ 1977 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
1978 -e 's|@''HAVE_REALLOCARRAY''@|$(HAVE_REALLOCARRAY)|g' \
1509 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ 1979 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
1510 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ 1980 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
1511 -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \ 1981 -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
1512 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \ 1982 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
1983 -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \
1984 -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
1513 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ 1985 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
1986 -e 's|@''HAVE_STRTOL''@|$(HAVE_STRTOL)|g' \
1987 -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \
1514 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ 1988 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
1989 -e 's|@''HAVE_STRTOUL''@|$(HAVE_STRTOUL)|g' \
1515 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ 1990 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
1516 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ 1991 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
1517 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ 1992 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
1518 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ 1993 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
1519 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \ 1994 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
1520 -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ 1995 -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
1996 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
1997 -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
1521 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ 1998 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
1522 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ 1999 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2000 -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
2001 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
2002 -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
1523 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \ 2003 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
1524 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ 2004 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
2005 -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
1525 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \ 2006 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
1526 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \ 2007 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
1527 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ 2008 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
2009 -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
2010 -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
1528 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \ 2011 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
1529 -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ 2012 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
2013 -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
2014 -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
1530 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ 2015 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
1531 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ 2016 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
2017 -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \
1532 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ 2018 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
2019 -e 's|@''REPLACE_STRTOL''@|$(REPLACE_STRTOL)|g' \
2020 -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \
2021 -e 's|@''REPLACE_STRTOLL''@|$(REPLACE_STRTOLL)|g' \
2022 -e 's|@''REPLACE_STRTOUL''@|$(REPLACE_STRTOUL)|g' \
2023 -e 's|@''REPLACE_STRTOULL''@|$(REPLACE_STRTOULL)|g' \
1533 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ 2024 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
1534 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \ 2025 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
1535 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2026 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1536 -e '/definition of _Noreturn/r $(_NORETURN_H)' \ 2027 -e '/definition of _Noreturn/r $(_NORETURN_H)' \
1537 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2028 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1538 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2029 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1539 } > $@-t && \ 2030 > $@-t
1540 mv $@-t $@ 2031 $(AM_V_at)mv $@-t $@
1541MOSTLYCLEANFILES += stdlib.h stdlib.h-t 2032MOSTLYCLEANFILES += stdlib.h stdlib.h-t
1542 2033
1543EXTRA_DIST += stdlib.in.h 2034EXTRA_DIST += stdlib.in.h
@@ -1546,12 +2037,23 @@ EXTRA_DIST += stdlib.in.h
1546 2037
1547## begin gnulib module strcase 2038## begin gnulib module strcase
1548 2039
2040if GL_COND_OBJ_STRCASECMP
2041libgnu_a_SOURCES += strcasecmp.c
2042endif
2043if GL_COND_OBJ_STRNCASECMP
2044libgnu_a_SOURCES += strncasecmp.c
2045endif
2046
2047## end gnulib module strcase
1549 2048
1550EXTRA_DIST += strcasecmp.c strncasecmp.c 2049## begin gnulib module strcasestr
1551 2050
1552EXTRA_libgnu_a_SOURCES += strcasecmp.c strncasecmp.c
1553 2051
1554## end gnulib module strcase 2052EXTRA_DIST += strcasestr.c
2053
2054EXTRA_libgnu_a_SOURCES += strcasestr.c
2055
2056## end gnulib module strcasestr
1555 2057
1556## begin gnulib module strcasestr-simple 2058## begin gnulib module strcasestr-simple
1557 2059
@@ -1571,19 +2073,19 @@ EXTRA_DIST += streq.h
1571 2073
1572## begin gnulib module strerror 2074## begin gnulib module strerror
1573 2075
1574 2076if GL_COND_OBJ_STRERROR
1575EXTRA_DIST += strerror.c 2077libgnu_a_SOURCES += strerror.c
1576 2078endif
1577EXTRA_libgnu_a_SOURCES += strerror.c
1578 2079
1579## end gnulib module strerror 2080## end gnulib module strerror
1580 2081
1581## begin gnulib module strerror-override 2082## begin gnulib module strerror-override
1582 2083
2084if GL_COND_OBJ_STRERROR_OVERRIDE
2085libgnu_a_SOURCES += strerror-override.c
2086endif
1583 2087
1584EXTRA_DIST += strerror-override.c strerror-override.h 2088EXTRA_DIST += strerror-override.h
1585
1586EXTRA_libgnu_a_SOURCES += strerror-override.c
1587 2089
1588## end gnulib module strerror-override 2090## end gnulib module strerror-override
1589 2091
@@ -1594,58 +2096,66 @@ BUILT_SOURCES += string.h
1594# We need the following in order to create <string.h> when the system 2096# We need the following in order to create <string.h> when the system
1595# doesn't have one that works with the given compiler. 2097# doesn't have one that works with the given compiler.
1596string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2098string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1597 $(AM_V_GEN)rm -f $@-t $@ && \ 2099 $(gl_V_at)$(SED_HEADER_STDOUT) \
1598 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2100 -e 's|@''GUARD_PREFIX''@|GL|g' \
1599 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1600 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2101 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1601 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2102 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1602 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2103 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1603 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ 2104 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
1604 -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ 2105 -e 's/@''GNULIB_EXPLICIT_BZERO''@/$(GL_GNULIB_EXPLICIT_BZERO)/g' \
1605 -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ 2106 -e 's/@''GNULIB_FFSL''@/$(GL_GNULIB_FFSL)/g' \
1606 -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ 2107 -e 's/@''GNULIB_FFSLL''@/$(GL_GNULIB_FFSLL)/g' \
1607 -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \ 2108 -e 's/@''GNULIB_MBSLEN''@/$(GL_GNULIB_MBSLEN)/g' \
1608 -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \ 2109 -e 's/@''GNULIB_MBSNLEN''@/$(GL_GNULIB_MBSNLEN)/g' \
1609 -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \ 2110 -e 's/@''GNULIB_MBSCHR''@/$(GL_GNULIB_MBSCHR)/g' \
1610 -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \ 2111 -e 's/@''GNULIB_MBSRCHR''@/$(GL_GNULIB_MBSRCHR)/g' \
1611 -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \ 2112 -e 's/@''GNULIB_MBSSTR''@/$(GL_GNULIB_MBSSTR)/g' \
1612 -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \ 2113 -e 's/@''GNULIB_MBSCASECMP''@/$(GL_GNULIB_MBSCASECMP)/g' \
1613 -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \ 2114 -e 's/@''GNULIB_MBSNCASECMP''@/$(GL_GNULIB_MBSNCASECMP)/g' \
1614 -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \ 2115 -e 's/@''GNULIB_MBSPCASECMP''@/$(GL_GNULIB_MBSPCASECMP)/g' \
1615 -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \ 2116 -e 's/@''GNULIB_MBSCASESTR''@/$(GL_GNULIB_MBSCASESTR)/g' \
1616 -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \ 2117 -e 's/@''GNULIB_MBSCSPN''@/$(GL_GNULIB_MBSCSPN)/g' \
1617 -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \ 2118 -e 's/@''GNULIB_MBSPBRK''@/$(GL_GNULIB_MBSPBRK)/g' \
1618 -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \ 2119 -e 's/@''GNULIB_MBSSPN''@/$(GL_GNULIB_MBSSPN)/g' \
1619 -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \ 2120 -e 's/@''GNULIB_MBSSEP''@/$(GL_GNULIB_MBSSEP)/g' \
1620 -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \ 2121 -e 's/@''GNULIB_MBSTOK_R''@/$(GL_GNULIB_MBSTOK_R)/g' \
1621 -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \ 2122 -e 's/@''GNULIB_MEMCHR''@/$(GL_GNULIB_MEMCHR)/g' \
1622 -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \ 2123 -e 's/@''GNULIB_MEMMEM''@/$(GL_GNULIB_MEMMEM)/g' \
1623 -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \ 2124 -e 's/@''GNULIB_MEMPCPY''@/$(GL_GNULIB_MEMPCPY)/g' \
1624 -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \ 2125 -e 's/@''GNULIB_MEMRCHR''@/$(GL_GNULIB_MEMRCHR)/g' \
1625 -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \ 2126 -e 's/@''GNULIB_MEMSET_EXPLICIT''@/$(GL_GNULIB_MEMSET_EXPLICIT)/g' \
1626 -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \ 2127 -e 's/@''GNULIB_RAWMEMCHR''@/$(GL_GNULIB_RAWMEMCHR)/g' \
1627 -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \ 2128 -e 's/@''GNULIB_STPCPY''@/$(GL_GNULIB_STPCPY)/g' \
1628 -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \ 2129 -e 's/@''GNULIB_STPNCPY''@/$(GL_GNULIB_STPNCPY)/g' \
1629 -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \ 2130 -e 's/@''GNULIB_STRCHRNUL''@/$(GL_GNULIB_STRCHRNUL)/g' \
1630 -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \ 2131 -e 's/@''GNULIB_STRDUP''@/$(GL_GNULIB_STRDUP)/g' \
1631 -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \ 2132 -e 's/@''GNULIB_STRNCAT''@/$(GL_GNULIB_STRNCAT)/g' \
1632 -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \ 2133 -e 's/@''GNULIB_STRNDUP''@/$(GL_GNULIB_STRNDUP)/g' \
1633 -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \ 2134 -e 's/@''GNULIB_STRNLEN''@/$(GL_GNULIB_STRNLEN)/g' \
1634 -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \ 2135 -e 's/@''GNULIB_STRPBRK''@/$(GL_GNULIB_STRPBRK)/g' \
1635 -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \ 2136 -e 's/@''GNULIB_STRSEP''@/$(GL_GNULIB_STRSEP)/g' \
1636 -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ 2137 -e 's/@''GNULIB_STRSTR''@/$(GL_GNULIB_STRSTR)/g' \
1637 -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ 2138 -e 's/@''GNULIB_STRCASESTR''@/$(GL_GNULIB_STRCASESTR)/g' \
1638 -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ 2139 -e 's/@''GNULIB_STRTOK_R''@/$(GL_GNULIB_STRTOK_R)/g' \
1639 -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ 2140 -e 's/@''GNULIB_STRERROR''@/$(GL_GNULIB_STRERROR)/g' \
1640 -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ 2141 -e 's/@''GNULIB_STRERROR_R''@/$(GL_GNULIB_STRERROR_R)/g' \
2142 -e 's/@''GNULIB_STRERRORNAME_NP''@/$(GL_GNULIB_STRERRORNAME_NP)/g' \
2143 -e 's/@''GNULIB_SIGABBREV_NP''@/$(GL_GNULIB_SIGABBREV_NP)/g' \
2144 -e 's/@''GNULIB_SIGDESCR_NP''@/$(GL_GNULIB_SIGDESCR_NP)/g' \
2145 -e 's/@''GNULIB_STRSIGNAL''@/$(GL_GNULIB_STRSIGNAL)/g' \
2146 -e 's/@''GNULIB_STRVERSCMP''@/$(GL_GNULIB_STRVERSCMP)/g' \
2147 -e 's/@''GNULIB_MDA_MEMCCPY''@/$(GL_GNULIB_MDA_MEMCCPY)/g' \
2148 -e 's/@''GNULIB_MDA_STRDUP''@/$(GL_GNULIB_MDA_STRDUP)/g' \
2149 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
1641 < $(srcdir)/string.in.h | \ 2150 < $(srcdir)/string.in.h | \
1642 sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ 2151 sed -e 's|@''HAVE_EXPLICIT_BZERO''@|$(HAVE_EXPLICIT_BZERO)|g' \
2152 -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
1643 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ 2153 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
1644 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ 2154 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
1645 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
1646 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ 2155 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
1647 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ 2156 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
1648 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ 2157 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
2158 -e 's|@''HAVE_MEMSET_EXPLICIT''@|$(HAVE_MEMSET_EXPLICIT)|g' \
1649 -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ 2159 -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
1650 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ 2160 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
1651 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ 2161 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
@@ -1658,29 +2168,34 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
1658 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ 2168 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
1659 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ 2169 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
1660 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ 2170 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
2171 -e 's|@''HAVE_STRERRORNAME_NP''@|$(HAVE_STRERRORNAME_NP)|g' \
2172 -e 's|@''HAVE_SIGABBREV_NP''@|$(HAVE_SIGABBREV_NP)|g' \
2173 -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \
1661 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ 2174 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
1662 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ 2175 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
1663 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ 2176 -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
1664 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ 2177 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
1665 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ 2178 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
1666 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ 2179 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2180 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
1667 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ 2181 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
1668 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ 2182 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
1669 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
1670 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
1671 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
1672 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ 2183 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
1673 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ 2184 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
1674 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ 2185 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
1675 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ 2186 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
2187 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
1676 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ 2188 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
2189 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
2190 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
2191 -e 's|@''REPLACE_STRERRORNAME_NP''@|$(REPLACE_STRERRORNAME_NP)|g' \
2192 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
1677 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ 2193 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
1678 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2194 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1679 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2195 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1680 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2196 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1681 < $(srcdir)/string.in.h; \ 2197 > $@-t
1682 } > $@-t && \ 2198 $(AM_V_at)mv $@-t $@
1683 mv $@-t $@
1684MOSTLYCLEANFILES += string.h string.h-t 2199MOSTLYCLEANFILES += string.h string.h-t
1685 2200
1686EXTRA_DIST += string.in.h 2201EXTRA_DIST += string.in.h
@@ -1694,54 +2209,33 @@ BUILT_SOURCES += strings.h
1694# We need the following in order to create <strings.h> when the system 2209# We need the following in order to create <strings.h> when the system
1695# doesn't have one that works with the given compiler. 2210# doesn't have one that works with the given compiler.
1696strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 2211strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
1697 $(AM_V_GEN)rm -f $@-t $@ && \ 2212 $(gl_V_at)$(SED_HEADER_STDOUT) \
1698 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2213 -e 's|@''GUARD_PREFIX''@|GL|g' \
1699 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1700 -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \ 2214 -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
1701 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2215 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1702 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2216 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1703 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2217 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1704 -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ 2218 -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
1705 -e 's|@''GNULIB_FFS''@|$(GNULIB_FFS)|g' \ 2219 -e 's/@''GNULIB_FFS''@/$(GL_GNULIB_FFS)/g' \
1706 -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \ 2220 -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
1707 -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ 2221 -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
1708 -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ 2222 -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
1709 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2223 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1710 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2224 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1711 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2225 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1712 < $(srcdir)/strings.in.h; \ 2226 $(srcdir)/strings.in.h > $@-t
1713 } > $@-t && \ 2227 $(AM_V_at)mv $@-t $@
1714 mv $@-t $@
1715MOSTLYCLEANFILES += strings.h strings.h-t 2228MOSTLYCLEANFILES += strings.h strings.h-t
1716 2229
1717EXTRA_DIST += strings.in.h 2230EXTRA_DIST += strings.in.h
1718 2231
1719## end gnulib module strings 2232## end gnulib module strings
1720 2233
1721## begin gnulib module strndup
1722
1723
1724EXTRA_DIST += strndup.c
1725
1726EXTRA_libgnu_a_SOURCES += strndup.c
1727
1728## end gnulib module strndup
1729
1730## begin gnulib module strnlen
1731
1732
1733EXTRA_DIST += strnlen.c
1734
1735EXTRA_libgnu_a_SOURCES += strnlen.c
1736
1737## end gnulib module strnlen
1738
1739## begin gnulib module strsep 2234## begin gnulib module strsep
1740 2235
1741 2236if GL_COND_OBJ_STRSEP
1742EXTRA_DIST += strsep.c 2237libgnu_a_SOURCES += strsep.c
1743 2238endif
1744EXTRA_libgnu_a_SOURCES += strsep.c
1745 2239
1746## end gnulib module strsep 2240## end gnulib module strsep
1747 2241
@@ -1762,31 +2256,30 @@ libgnu_a_SOURCES += sys_socket.c
1762# We need the following in order to create <sys/socket.h> when the system 2256# We need the following in order to create <sys/socket.h> when the system
1763# doesn't have one that works with the given compiler. 2257# doesn't have one that works with the given compiler.
1764sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 2258sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
1765 $(AM_V_at)$(MKDIR_P) sys 2259 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
1766 $(AM_V_GEN)rm -f $@-t $@ && \ 2260 $(AM_V_at)$(SED_HEADER_STDOUT) \
1767 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2261 -e 's|@''GUARD_PREFIX''@|GL|g' \
1768 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1769 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2262 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1770 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2263 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1771 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2264 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1772 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ 2265 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
1773 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ 2266 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
1774 -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ 2267 -e 's/@''GNULIB_CLOSE''@/$(GL_GNULIB_CLOSE)/g' \
1775 -e 's/@''GNULIB_SOCKET''@/$(GNULIB_SOCKET)/g' \ 2268 -e 's/@''GNULIB_SOCKET''@/$(GL_GNULIB_SOCKET)/g' \
1776 -e 's/@''GNULIB_CONNECT''@/$(GNULIB_CONNECT)/g' \ 2269 -e 's/@''GNULIB_CONNECT''@/$(GL_GNULIB_CONNECT)/g' \
1777 -e 's/@''GNULIB_ACCEPT''@/$(GNULIB_ACCEPT)/g' \ 2270 -e 's/@''GNULIB_ACCEPT''@/$(GL_GNULIB_ACCEPT)/g' \
1778 -e 's/@''GNULIB_BIND''@/$(GNULIB_BIND)/g' \ 2271 -e 's/@''GNULIB_BIND''@/$(GL_GNULIB_BIND)/g' \
1779 -e 's/@''GNULIB_GETPEERNAME''@/$(GNULIB_GETPEERNAME)/g' \ 2272 -e 's/@''GNULIB_GETPEERNAME''@/$(GL_GNULIB_GETPEERNAME)/g' \
1780 -e 's/@''GNULIB_GETSOCKNAME''@/$(GNULIB_GETSOCKNAME)/g' \ 2273 -e 's/@''GNULIB_GETSOCKNAME''@/$(GL_GNULIB_GETSOCKNAME)/g' \
1781 -e 's/@''GNULIB_GETSOCKOPT''@/$(GNULIB_GETSOCKOPT)/g' \ 2274 -e 's/@''GNULIB_GETSOCKOPT''@/$(GL_GNULIB_GETSOCKOPT)/g' \
1782 -e 's/@''GNULIB_LISTEN''@/$(GNULIB_LISTEN)/g' \ 2275 -e 's/@''GNULIB_LISTEN''@/$(GL_GNULIB_LISTEN)/g' \
1783 -e 's/@''GNULIB_RECV''@/$(GNULIB_RECV)/g' \ 2276 -e 's/@''GNULIB_RECV''@/$(GL_GNULIB_RECV)/g' \
1784 -e 's/@''GNULIB_SEND''@/$(GNULIB_SEND)/g' \ 2277 -e 's/@''GNULIB_SEND''@/$(GL_GNULIB_SEND)/g' \
1785 -e 's/@''GNULIB_RECVFROM''@/$(GNULIB_RECVFROM)/g' \ 2278 -e 's/@''GNULIB_RECVFROM''@/$(GL_GNULIB_RECVFROM)/g' \
1786 -e 's/@''GNULIB_SENDTO''@/$(GNULIB_SENDTO)/g' \ 2279 -e 's/@''GNULIB_SENDTO''@/$(GL_GNULIB_SENDTO)/g' \
1787 -e 's/@''GNULIB_SETSOCKOPT''@/$(GNULIB_SETSOCKOPT)/g' \ 2280 -e 's/@''GNULIB_SETSOCKOPT''@/$(GL_GNULIB_SETSOCKOPT)/g' \
1788 -e 's/@''GNULIB_SHUTDOWN''@/$(GNULIB_SHUTDOWN)/g' \ 2281 -e 's/@''GNULIB_SHUTDOWN''@/$(GL_GNULIB_SHUTDOWN)/g' \
1789 -e 's/@''GNULIB_ACCEPT4''@/$(GNULIB_ACCEPT4)/g' \ 2282 -e 's/@''GNULIB_ACCEPT4''@/$(GL_GNULIB_ACCEPT4)/g' \
1790 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ 2283 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
1791 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ 2284 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
1792 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ 2285 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
@@ -1796,9 +2289,8 @@ sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_
1796 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2289 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1797 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2290 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1798 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2291 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1799 < $(srcdir)/sys_socket.in.h; \ 2292 $(srcdir)/sys_socket.in.h > $@-t
1800 } > $@-t && \ 2293 $(AM_V_at)mv $@-t $@
1801 mv -f $@-t $@
1802MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t 2294MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
1803MOSTLYCLEANDIRS += sys 2295MOSTLYCLEANDIRS += sys
1804 2296
@@ -1806,6 +2298,79 @@ EXTRA_DIST += sys_socket.in.h
1806 2298
1807## end gnulib module sys_socket 2299## end gnulib module sys_socket
1808 2300
2301## begin gnulib module sys_stat
2302
2303BUILT_SOURCES += sys/stat.h
2304
2305# We need the following in order to create <sys/stat.h> when the system
2306# has one that is incomplete.
2307sys/stat.h: sys_stat.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2308 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
2309 $(AM_V_at)$(SED_HEADER_STDOUT) \
2310 -e 's|@''GUARD_PREFIX''@|GL|g' \
2311 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2312 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2313 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2314 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
2315 -e 's|@''WINDOWS_64_BIT_ST_SIZE''@|$(WINDOWS_64_BIT_ST_SIZE)|g' \
2316 -e 's|@''WINDOWS_STAT_TIMESPEC''@|$(WINDOWS_STAT_TIMESPEC)|g' \
2317 -e 's/@''GNULIB_CHMOD''@/$(GL_GNULIB_CHMOD)/g' \
2318 -e 's/@''GNULIB_FCHMODAT''@/$(GL_GNULIB_FCHMODAT)/g' \
2319 -e 's/@''GNULIB_FSTAT''@/$(GL_GNULIB_FSTAT)/g' \
2320 -e 's/@''GNULIB_FSTATAT''@/$(GL_GNULIB_FSTATAT)/g' \
2321 -e 's/@''GNULIB_FUTIMENS''@/$(GL_GNULIB_FUTIMENS)/g' \
2322 -e 's/@''GNULIB_GETUMASK''@/$(GL_GNULIB_GETUMASK)/g' \
2323 -e 's/@''GNULIB_LCHMOD''@/$(GL_GNULIB_LCHMOD)/g' \
2324 -e 's/@''GNULIB_LSTAT''@/$(GL_GNULIB_LSTAT)/g' \
2325 -e 's/@''GNULIB_MKDIR''@/$(GL_GNULIB_MKDIR)/g' \
2326 -e 's/@''GNULIB_MKDIRAT''@/$(GL_GNULIB_MKDIRAT)/g' \
2327 -e 's/@''GNULIB_MKFIFO''@/$(GL_GNULIB_MKFIFO)/g' \
2328 -e 's/@''GNULIB_MKFIFOAT''@/$(GL_GNULIB_MKFIFOAT)/g' \
2329 -e 's/@''GNULIB_MKNOD''@/$(GL_GNULIB_MKNOD)/g' \
2330 -e 's/@''GNULIB_MKNODAT''@/$(GL_GNULIB_MKNODAT)/g' \
2331 -e 's/@''GNULIB_STAT''@/$(GL_GNULIB_STAT)/g' \
2332 -e 's/@''GNULIB_UTIMENSAT''@/$(GL_GNULIB_UTIMENSAT)/g' \
2333 -e 's/@''GNULIB_OVERRIDES_STRUCT_STAT''@/$(GL_GNULIB_OVERRIDES_STRUCT_STAT)/g' \
2334 -e 's/@''GNULIB_MDA_CHMOD''@/$(GL_GNULIB_MDA_CHMOD)/g' \
2335 -e 's/@''GNULIB_MDA_MKDIR''@/$(GL_GNULIB_MDA_MKDIR)/g' \
2336 -e 's/@''GNULIB_MDA_UMASK''@/$(GL_GNULIB_MDA_UMASK)/g' \
2337 -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
2338 -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
2339 -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
2340 -e 's|@''HAVE_GETUMASK''@|$(HAVE_GETUMASK)|g' \
2341 -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
2342 -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
2343 -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
2344 -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
2345 -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
2346 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
2347 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
2348 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
2349 -e 's|@''REPLACE_CHMOD''@|$(REPLACE_CHMOD)|g' \
2350 -e 's|@''REPLACE_FCHMODAT''@|$(REPLACE_FCHMODAT)|g' \
2351 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
2352 -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
2353 -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
2354 -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
2355 -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
2356 -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
2357 -e 's|@''REPLACE_MKFIFOAT''@|$(REPLACE_MKFIFOAT)|g' \
2358 -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
2359 -e 's|@''REPLACE_MKNODAT''@|$(REPLACE_MKNODAT)|g' \
2360 -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
2361 -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
2362 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2363 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2364 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2365 $(srcdir)/sys_stat.in.h > $@-t
2366 $(AM_V_at)mv $@-t $@
2367MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
2368MOSTLYCLEANDIRS += sys
2369
2370EXTRA_DIST += sys_stat.in.h
2371
2372## end gnulib module sys_stat
2373
1809## begin gnulib module sys_types 2374## begin gnulib module sys_types
1810 2375
1811BUILT_SOURCES += sys/types.h 2376BUILT_SOURCES += sys/types.h
@@ -1813,18 +2378,17 @@ BUILT_SOURCES += sys/types.h
1813# We need the following in order to create <sys/types.h> when the system 2378# We need the following in order to create <sys/types.h> when the system
1814# doesn't have one that works with the given compiler. 2379# doesn't have one that works with the given compiler.
1815sys/types.h: sys_types.in.h $(top_builddir)/config.status 2380sys/types.h: sys_types.in.h $(top_builddir)/config.status
1816 $(AM_V_at)$(MKDIR_P) sys 2381 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
1817 $(AM_V_GEN)rm -f $@-t $@ && \ 2382 $(AM_V_at)$(SED_HEADER_STDOUT) \
1818 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2383 -e 's|@''GUARD_PREFIX''@|GL|g' \
1819 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1820 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2384 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1821 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2385 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1822 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2386 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1823 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \ 2387 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
1824 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ 2388 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
1825 < $(srcdir)/sys_types.in.h; \ 2389 -e 's|@''WINDOWS_STAT_INODES''@|$(WINDOWS_STAT_INODES)|g' \
1826 } > $@-t && \ 2390 $(srcdir)/sys_types.in.h > $@-t
1827 mv $@-t $@ 2391 $(AM_V_at)mv $@-t $@
1828MOSTLYCLEANFILES += sys/types.h sys/types.h-t 2392MOSTLYCLEANFILES += sys/types.h sys/types.h-t
1829 2393
1830EXTRA_DIST += sys_types.in.h 2394EXTRA_DIST += sys_types.in.h
@@ -1838,18 +2402,16 @@ BUILT_SOURCES += sys/uio.h
1838# We need the following in order to create <sys/uio.h> when the system 2402# We need the following in order to create <sys/uio.h> when the system
1839# doesn't have one that works with the given compiler. 2403# doesn't have one that works with the given compiler.
1840sys/uio.h: sys_uio.in.h $(top_builddir)/config.status 2404sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
1841 $(AM_V_at)$(MKDIR_P) sys 2405 $(AM_V_GEN)$(MKDIR_P) '%reldir%/sys'
1842 $(AM_V_GEN)rm -f $@-t $@ && \ 2406 $(AM_V_at)$(SED_HEADER_STDOUT) \
1843 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2407 -e 's|@''GUARD_PREFIX''@|GL|g' \
1844 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1845 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2408 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1846 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2409 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1847 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2410 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1848 -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \ 2411 -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \
1849 -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \ 2412 -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \
1850 < $(srcdir)/sys_uio.in.h; \ 2413 $(srcdir)/sys_uio.in.h > $@-t
1851 } > $@-t && \ 2414 $(AM_V_at)mv $@-t $@
1852 mv -f $@-t $@
1853MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t 2415MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t
1854MOSTLYCLEANDIRS += sys 2416MOSTLYCLEANDIRS += sys
1855 2417
@@ -1861,8 +2423,6 @@ EXTRA_DIST += sys_uio.in.h
1861 2423
1862libgnu_a_SOURCES += glthread/threadlib.c 2424libgnu_a_SOURCES += glthread/threadlib.c
1863 2425
1864EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
1865
1866## end gnulib module threadlib 2426## end gnulib module threadlib
1867 2427
1868## begin gnulib module time 2428## begin gnulib module time
@@ -1872,35 +2432,51 @@ BUILT_SOURCES += time.h
1872# We need the following in order to create <time.h> when the system 2432# We need the following in order to create <time.h> when the system
1873# doesn't have one that works with the given compiler. 2433# doesn't have one that works with the given compiler.
1874time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2434time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1875 $(AM_V_GEN)rm -f $@-t $@ && \ 2435 $(gl_V_at)$(SED_HEADER_STDOUT) \
1876 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 2436 -e 's|@''GUARD_PREFIX''@|GL|g' \
1877 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1878 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2437 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1879 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2438 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1880 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2439 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1881 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ 2440 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
1882 -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \ 2441 -e 's/@''GNULIB_CTIME''@/$(GL_GNULIB_CTIME)/g' \
1883 -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \ 2442 -e 's/@''GNULIB_LOCALTIME''@/$(GL_GNULIB_LOCALTIME)/g' \
1884 -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \ 2443 -e 's/@''GNULIB_MKTIME''@/$(GL_GNULIB_MKTIME)/g' \
1885 -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \ 2444 -e 's/@''GNULIB_NANOSLEEP''@/$(GL_GNULIB_NANOSLEEP)/g' \
1886 -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \ 2445 -e 's/@''GNULIB_STRFTIME''@/$(GL_GNULIB_STRFTIME)/g' \
2446 -e 's/@''GNULIB_STRPTIME''@/$(GL_GNULIB_STRPTIME)/g' \
2447 -e 's/@''GNULIB_TIMEGM''@/$(GL_GNULIB_TIMEGM)/g' \
2448 -e 's/@''GNULIB_TIMESPEC_GET''@/$(GL_GNULIB_TIMESPEC_GET)/g' \
2449 -e 's/@''GNULIB_TIMESPEC_GETRES''@/$(GL_GNULIB_TIMESPEC_GETRES)/g' \
2450 -e 's/@''GNULIB_TIME_R''@/$(GL_GNULIB_TIME_R)/g' \
2451 -e 's/@''GNULIB_TIME_RZ''@/$(GL_GNULIB_TIME_RZ)/g' \
2452 -e 's/@''GNULIB_TZSET''@/$(GL_GNULIB_TZSET)/g' \
2453 -e 's/@''GNULIB_MDA_TZSET''@/$(GL_GNULIB_MDA_TZSET)/g' \
1887 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \ 2454 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
1888 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ 2455 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
1889 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ 2456 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
1890 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ 2457 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
2458 -e 's|@''HAVE_TIMESPEC_GET''@|$(HAVE_TIMESPEC_GET)|g' \
2459 -e 's|@''HAVE_TIMESPEC_GETRES''@|$(HAVE_TIMESPEC_GETRES)|g' \
2460 -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \
2461 -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \
2462 -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \
2463 -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \
1891 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ 2464 -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
1892 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ 2465 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
1893 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ 2466 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
2467 -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
1894 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ 2468 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
2469 -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
1895 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2470 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
1896 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2471 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
1897 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 2472 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
2473 -e 's|@''UNISTD_H_DEFINES_STRUCT_TIMESPEC''@|$(UNISTD_H_DEFINES_STRUCT_TIMESPEC)|g' \
2474 -e 's|@''TIME_H_DEFINES_TIME_UTC''@|$(TIME_H_DEFINES_TIME_UTC)|g' \
1898 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2475 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1899 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2476 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1900 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2477 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1901 < $(srcdir)/time.in.h; \ 2478 $(srcdir)/time.in.h > $@-t
1902 } > $@-t && \ 2479 $(AM_V_at)mv $@-t $@
1903 mv $@-t $@
1904MOSTLYCLEANFILES += time.h time.h-t 2480MOSTLYCLEANFILES += time.h time.h-t
1905 2481
1906EXTRA_DIST += time.in.h 2482EXTRA_DIST += time.in.h
@@ -1909,19 +2485,19 @@ EXTRA_DIST += time.in.h
1909 2485
1910## begin gnulib module time_r 2486## begin gnulib module time_r
1911 2487
1912 2488if GL_COND_OBJ_TIME_R
1913EXTRA_DIST += time_r.c 2489libgnu_a_SOURCES += time_r.c
1914 2490endif
1915EXTRA_libgnu_a_SOURCES += time_r.c
1916 2491
1917## end gnulib module time_r 2492## end gnulib module time_r
1918 2493
1919## begin gnulib module timegm 2494## begin gnulib module timegm
1920 2495
2496if GL_COND_OBJ_TIMEGM
2497libgnu_a_SOURCES += timegm.c
2498endif
1921 2499
1922EXTRA_DIST += mktime-internal.h timegm.c 2500EXTRA_DIST += mktime-internal.h
1923
1924EXTRA_libgnu_a_SOURCES += timegm.c
1925 2501
1926## end gnulib module timegm 2502## end gnulib module timegm
1927 2503
@@ -1933,69 +2509,104 @@ libgnu_a_SOURCES += unistd.c
1933# We need the following in order to create an empty placeholder for 2509# We need the following in order to create an empty placeholder for
1934# <unistd.h> when the system doesn't have one. 2510# <unistd.h> when the system doesn't have one.
1935unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2511unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1936 $(AM_V_GEN)rm -f $@-t $@ && \ 2512 $(gl_V_at)$(SED_HEADER_STDOUT) \
1937 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2513 -e 's|@''GUARD_PREFIX''@|GL|g' \
1938 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1939 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ 2514 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
1940 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2515 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1941 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2516 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1942 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2517 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1943 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ 2518 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
1944 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \ 2519 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
1945 -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \ 2520 -e 's/@''GNULIB_ACCESS''@/$(GL_GNULIB_ACCESS)/g' \
1946 -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \ 2521 -e 's/@''GNULIB_CHDIR''@/$(GL_GNULIB_CHDIR)/g' \
1947 -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \ 2522 -e 's/@''GNULIB_CHOWN''@/$(GL_GNULIB_CHOWN)/g' \
1948 -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \ 2523 -e 's/@''GNULIB_CLOSE''@/$(GL_GNULIB_CLOSE)/g' \
1949 -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \ 2524 -e 's/@''GNULIB_COPY_FILE_RANGE''@/$(GL_GNULIB_COPY_FILE_RANGE)/g' \
1950 -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \ 2525 -e 's/@''GNULIB_DUP''@/$(GL_GNULIB_DUP)/g' \
1951 -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \ 2526 -e 's/@''GNULIB_DUP2''@/$(GL_GNULIB_DUP2)/g' \
1952 -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \ 2527 -e 's/@''GNULIB_DUP3''@/$(GL_GNULIB_DUP3)/g' \
1953 -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \ 2528 -e 's/@''GNULIB_ENVIRON''@/$(GL_GNULIB_ENVIRON)/g' \
1954 -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \ 2529 -e 's/@''GNULIB_EUIDACCESS''@/$(GL_GNULIB_EUIDACCESS)/g' \
1955 -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \ 2530 -e 's/@''GNULIB_EXECL''@/$(GL_GNULIB_EXECL)/g' \
1956 -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \ 2531 -e 's/@''GNULIB_EXECLE''@/$(GL_GNULIB_EXECLE)/g' \
1957 -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \ 2532 -e 's/@''GNULIB_EXECLP''@/$(GL_GNULIB_EXECLP)/g' \
1958 -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \ 2533 -e 's/@''GNULIB_EXECV''@/$(GL_GNULIB_EXECV)/g' \
1959 -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \ 2534 -e 's/@''GNULIB_EXECVE''@/$(GL_GNULIB_EXECVE)/g' \
1960 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \ 2535 -e 's/@''GNULIB_EXECVP''@/$(GL_GNULIB_EXECVP)/g' \
1961 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \ 2536 -e 's/@''GNULIB_EXECVPE''@/$(GL_GNULIB_EXECVPE)/g' \
1962 -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \ 2537 -e 's/@''GNULIB_FACCESSAT''@/$(GL_GNULIB_FACCESSAT)/g' \
1963 -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \ 2538 -e 's/@''GNULIB_FCHDIR''@/$(GL_GNULIB_FCHDIR)/g' \
1964 -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \ 2539 -e 's/@''GNULIB_FCHOWNAT''@/$(GL_GNULIB_FCHOWNAT)/g' \
1965 -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \ 2540 -e 's/@''GNULIB_FDATASYNC''@/$(GL_GNULIB_FDATASYNC)/g' \
1966 -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \ 2541 -e 's/@''GNULIB_FSYNC''@/$(GL_GNULIB_FSYNC)/g' \
1967 -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \ 2542 -e 's/@''GNULIB_FTRUNCATE''@/$(GL_GNULIB_FTRUNCATE)/g' \
1968 -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \ 2543 -e 's/@''GNULIB_GETCWD''@/$(GL_GNULIB_GETCWD)/g' \
1969 -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \ 2544 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GL_GNULIB_GETDOMAINNAME)/g' \
1970 -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \ 2545 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GL_GNULIB_GETDTABLESIZE)/g' \
1971 -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \ 2546 -e 's/@''GNULIB_GETENTROPY''@/$(GL_GNULIB_GETENTROPY)/g' \
1972 -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \ 2547 -e 's/@''GNULIB_GETGROUPS''@/$(GL_GNULIB_GETGROUPS)/g' \
1973 -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \ 2548 -e 's/@''GNULIB_GETHOSTNAME''@/$(GL_GNULIB_GETHOSTNAME)/g' \
1974 -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \ 2549 -e 's/@''GNULIB_GETLOGIN''@/$(GL_GNULIB_GETLOGIN)/g' \
1975 -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \ 2550 -e 's/@''GNULIB_GETLOGIN_R''@/$(GL_GNULIB_GETLOGIN_R)/g' \
1976 -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \ 2551 -e 's/@''GNULIB_GETOPT_POSIX''@/$(GL_GNULIB_GETOPT_POSIX)/g' \
1977 -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \ 2552 -e 's/@''GNULIB_GETPAGESIZE''@/$(GL_GNULIB_GETPAGESIZE)/g' \
1978 -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \ 2553 -e 's/@''GNULIB_GETPASS''@/$(GL_GNULIB_GETPASS)/g' \
1979 -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \ 2554 -e 's/@''GNULIB_GETPASS_GNU''@/$(GL_GNULIB_GETPASS_GNU)/g' \
1980 -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \ 2555 -e 's/@''GNULIB_GETUSERSHELL''@/$(GL_GNULIB_GETUSERSHELL)/g' \
1981 -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \ 2556 -e 's/@''GNULIB_GROUP_MEMBER''@/$(GL_GNULIB_GROUP_MEMBER)/g' \
1982 -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \ 2557 -e 's/@''GNULIB_ISATTY''@/$(GL_GNULIB_ISATTY)/g' \
1983 -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \ 2558 -e 's/@''GNULIB_LCHOWN''@/$(GL_GNULIB_LCHOWN)/g' \
1984 -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \ 2559 -e 's/@''GNULIB_LINK''@/$(GL_GNULIB_LINK)/g' \
1985 -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \ 2560 -e 's/@''GNULIB_LINKAT''@/$(GL_GNULIB_LINKAT)/g' \
1986 -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \ 2561 -e 's/@''GNULIB_LSEEK''@/$(GL_GNULIB_LSEEK)/g' \
1987 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \ 2562 -e 's/@''GNULIB_PIPE''@/$(GL_GNULIB_PIPE)/g' \
1988 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \ 2563 -e 's/@''GNULIB_PIPE2''@/$(GL_GNULIB_PIPE2)/g' \
1989 -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \ 2564 -e 's/@''GNULIB_PREAD''@/$(GL_GNULIB_PREAD)/g' \
1990 -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \ 2565 -e 's/@''GNULIB_PWRITE''@/$(GL_GNULIB_PWRITE)/g' \
1991 -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \ 2566 -e 's/@''GNULIB_READ''@/$(GL_GNULIB_READ)/g' \
1992 -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \ 2567 -e 's/@''GNULIB_READLINK''@/$(GL_GNULIB_READLINK)/g' \
1993 -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \ 2568 -e 's/@''GNULIB_READLINKAT''@/$(GL_GNULIB_READLINKAT)/g' \
2569 -e 's/@''GNULIB_RMDIR''@/$(GL_GNULIB_RMDIR)/g' \
2570 -e 's/@''GNULIB_SETHOSTNAME''@/$(GL_GNULIB_SETHOSTNAME)/g' \
2571 -e 's/@''GNULIB_SLEEP''@/$(GL_GNULIB_SLEEP)/g' \
2572 -e 's/@''GNULIB_SYMLINK''@/$(GL_GNULIB_SYMLINK)/g' \
2573 -e 's/@''GNULIB_SYMLINKAT''@/$(GL_GNULIB_SYMLINKAT)/g' \
2574 -e 's/@''GNULIB_TRUNCATE''@/$(GL_GNULIB_TRUNCATE)/g' \
2575 -e 's/@''GNULIB_TTYNAME_R''@/$(GL_GNULIB_TTYNAME_R)/g' \
2576 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GL_GNULIB_UNISTD_H_GETOPT)/g' \
2577 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GL_GNULIB_UNISTD_H_NONBLOCKING)/g' \
2578 -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GL_GNULIB_UNISTD_H_SIGPIPE)/g' \
2579 -e 's/@''GNULIB_UNLINK''@/$(GL_GNULIB_UNLINK)/g' \
2580 -e 's/@''GNULIB_UNLINKAT''@/$(GL_GNULIB_UNLINKAT)/g' \
2581 -e 's/@''GNULIB_USLEEP''@/$(GL_GNULIB_USLEEP)/g' \
2582 -e 's/@''GNULIB_WRITE''@/$(GL_GNULIB_WRITE)/g' \
2583 -e 's/@''GNULIB_MDA_ACCESS''@/$(GL_GNULIB_MDA_ACCESS)/g' \
2584 -e 's/@''GNULIB_MDA_CHDIR''@/$(GL_GNULIB_MDA_CHDIR)/g' \
2585 -e 's/@''GNULIB_MDA_CLOSE''@/$(GL_GNULIB_MDA_CLOSE)/g' \
2586 -e 's/@''GNULIB_MDA_DUP''@/$(GL_GNULIB_MDA_DUP)/g' \
2587 -e 's/@''GNULIB_MDA_DUP2''@/$(GL_GNULIB_MDA_DUP2)/g' \
2588 -e 's/@''GNULIB_MDA_EXECL''@/$(GL_GNULIB_MDA_EXECL)/g' \
2589 -e 's/@''GNULIB_MDA_EXECLE''@/$(GL_GNULIB_MDA_EXECLE)/g' \
2590 -e 's/@''GNULIB_MDA_EXECLP''@/$(GL_GNULIB_MDA_EXECLP)/g' \
2591 -e 's/@''GNULIB_MDA_EXECV''@/$(GL_GNULIB_MDA_EXECV)/g' \
2592 -e 's/@''GNULIB_MDA_EXECVE''@/$(GL_GNULIB_MDA_EXECVE)/g' \
2593 -e 's/@''GNULIB_MDA_EXECVP''@/$(GL_GNULIB_MDA_EXECVP)/g' \
2594 -e 's/@''GNULIB_MDA_EXECVPE''@/$(GL_GNULIB_MDA_EXECVPE)/g' \
2595 -e 's/@''GNULIB_MDA_GETCWD''@/$(GL_GNULIB_MDA_GETCWD)/g' \
2596 -e 's/@''GNULIB_MDA_GETPID''@/$(GL_GNULIB_MDA_GETPID)/g' \
2597 -e 's/@''GNULIB_MDA_ISATTY''@/$(GL_GNULIB_MDA_ISATTY)/g' \
2598 -e 's/@''GNULIB_MDA_LSEEK''@/$(GL_GNULIB_MDA_LSEEK)/g' \
2599 -e 's/@''GNULIB_MDA_READ''@/$(GL_GNULIB_MDA_READ)/g' \
2600 -e 's/@''GNULIB_MDA_RMDIR''@/$(GL_GNULIB_MDA_RMDIR)/g' \
2601 -e 's/@''GNULIB_MDA_SWAB''@/$(GL_GNULIB_MDA_SWAB)/g' \
2602 -e 's/@''GNULIB_MDA_UNLINK''@/$(GL_GNULIB_MDA_UNLINK)/g' \
2603 -e 's/@''GNULIB_MDA_WRITE''@/$(GL_GNULIB_MDA_WRITE)/g' \
1994 < $(srcdir)/unistd.in.h | \ 2604 < $(srcdir)/unistd.in.h | \
1995 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ 2605 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
1996 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ 2606 -e 's|@''HAVE_COPY_FILE_RANGE''@|$(HAVE_COPY_FILE_RANGE)|g' \
1997 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ 2607 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
1998 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ 2608 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
2609 -e 's|@''HAVE_EXECVPE''@|$(HAVE_EXECVPE)|g' \
1999 -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ 2610 -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
2000 -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ 2611 -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
2001 -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ 2612 -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
@@ -2003,10 +2614,11 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2003 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ 2614 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
2004 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ 2615 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
2005 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ 2616 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
2617 -e 's|@''HAVE_GETENTROPY''@|$(HAVE_GETENTROPY)|g' \
2006 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ 2618 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
2007 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ 2619 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
2008 -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
2009 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ 2620 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
2621 -e 's|@''HAVE_GETPASS''@|$(HAVE_GETPASS)|g' \
2010 -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ 2622 -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
2011 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ 2623 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
2012 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ 2624 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
@@ -2024,28 +2636,44 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2024 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ 2636 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
2025 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ 2637 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
2026 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ 2638 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
2639 -e 's|@''HAVE_DECL_EXECVPE''@|$(HAVE_DECL_EXECVPE)|g' \
2027 -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ 2640 -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
2028 -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ 2641 -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
2029 -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ 2642 -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
2643 -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \
2030 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ 2644 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
2031 -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ 2645 -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
2032 -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ 2646 -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
2033 -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \ 2647 -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
2648 -e 's|@''HAVE_DECL_TRUNCATE''@|$(HAVE_DECL_TRUNCATE)|g' \
2034 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \ 2649 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
2035 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ 2650 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
2036 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ 2651 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
2037 | \ 2652 | \
2038 sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ 2653 sed -e 's|@''REPLACE_ACCESS''@|$(REPLACE_ACCESS)|g' \
2654 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
2039 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ 2655 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
2656 -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
2040 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ 2657 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
2041 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ 2658 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
2659 -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
2660 -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \
2661 -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \
2662 -e 's|@''REPLACE_EXECV''@|$(REPLACE_EXECV)|g' \
2663 -e 's|@''REPLACE_EXECVE''@|$(REPLACE_EXECVE)|g' \
2664 -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \
2665 -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \
2666 -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
2042 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ 2667 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
2043 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \ 2668 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
2044 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 2669 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
2045 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ 2670 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
2671 -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
2046 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ 2672 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
2047 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ 2673 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
2048 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 2674 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
2675 -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
2676 -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
2049 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \ 2677 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
2050 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ 2678 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
2051 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ 2679 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
@@ -2055,33 +2683,43 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
2055 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ 2683 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
2056 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \ 2684 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
2057 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ 2685 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
2686 -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
2058 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ 2687 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
2059 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ 2688 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
2060 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ 2689 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
2690 -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
2691 -e 's|@''REPLACE_TRUNCATE''@|$(REPLACE_TRUNCATE)|g' \
2061 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ 2692 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
2062 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ 2693 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
2063 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ 2694 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
2064 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ 2695 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
2065 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \ 2696 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
2697 -e 's|@''UNISTD_H_HAVE_SYS_RANDOM_H''@|$(UNISTD_H_HAVE_SYS_RANDOM_H)|g' \
2066 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \ 2698 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
2067 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \ 2699 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
2068 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2700 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2069 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2701 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2070 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2702 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2071 } > $@-t && \ 2703 > $@-t
2072 mv $@-t $@ 2704 $(AM_V_at)mv $@-t $@
2073MOSTLYCLEANFILES += unistd.h unistd.h-t 2705MOSTLYCLEANFILES += unistd.h unistd.h-t
2074 2706
2075EXTRA_DIST += unistd.in.h 2707EXTRA_DIST += unistd.in.h
2076 2708
2077## end gnulib module unistd 2709## end gnulib module unistd
2078 2710
2079## begin gnulib module unsetenv 2711## begin gnulib module unlocked-io-internal
2080 2712
2081 2713
2082EXTRA_DIST += unsetenv.c 2714EXTRA_DIST += unlocked-io.h
2715
2716## end gnulib module unlocked-io-internal
2717
2718## begin gnulib module unsetenv
2083 2719
2084EXTRA_libgnu_a_SOURCES += unsetenv.c 2720if GL_COND_OBJ_UNSETENV
2721libgnu_a_SOURCES += unsetenv.c
2722endif
2085 2723
2086## end gnulib module unsetenv 2724## end gnulib module unsetenv
2087 2725
@@ -2126,54 +2764,59 @@ BUILT_SOURCES += wchar.h
2126# We need the following in order to create <wchar.h> when the system 2764# We need the following in order to create <wchar.h> when the system
2127# version does not work standalone. 2765# version does not work standalone.
2128wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2766wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
2129 $(AM_V_GEN)rm -f $@-t $@ && \ 2767 $(gl_V_at)$(SED_HEADER_STDOUT) \
2130 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2768 -e 's|@''GUARD_PREFIX''@|GL|g' \
2131 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2132 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2769 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2133 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2770 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2134 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2771 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2135 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ 2772 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
2136 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ 2773 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
2137 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ 2774 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
2138 -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \ 2775 -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
2139 -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \ 2776 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
2140 -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \ 2777 -e 's/@''GNULIB_BTOWC''@/$(GL_GNULIB_BTOWC)/g' \
2141 -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \ 2778 -e 's/@''GNULIB_WCTOB''@/$(GL_GNULIB_WCTOB)/g' \
2142 -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \ 2779 -e 's/@''GNULIB_MBSINIT''@/$(GL_GNULIB_MBSINIT)/g' \
2143 -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \ 2780 -e 's/@''GNULIB_MBRTOWC''@/$(GL_GNULIB_MBRTOWC)/g' \
2144 -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \ 2781 -e 's/@''GNULIB_MBRLEN''@/$(GL_GNULIB_MBRLEN)/g' \
2145 -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \ 2782 -e 's/@''GNULIB_MBSRTOWCS''@/$(GL_GNULIB_MBSRTOWCS)/g' \
2146 -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \ 2783 -e 's/@''GNULIB_MBSNRTOWCS''@/$(GL_GNULIB_MBSNRTOWCS)/g' \
2147 -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \ 2784 -e 's/@''GNULIB_WCRTOMB''@/$(GL_GNULIB_WCRTOMB)/g' \
2148 -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \ 2785 -e 's/@''GNULIB_WCSRTOMBS''@/$(GL_GNULIB_WCSRTOMBS)/g' \
2149 -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \ 2786 -e 's/@''GNULIB_WCSNRTOMBS''@/$(GL_GNULIB_WCSNRTOMBS)/g' \
2150 -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \ 2787 -e 's/@''GNULIB_WCWIDTH''@/$(GL_GNULIB_WCWIDTH)/g' \
2151 -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \ 2788 -e 's/@''GNULIB_WMEMCHR''@/$(GL_GNULIB_WMEMCHR)/g' \
2152 -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \ 2789 -e 's/@''GNULIB_WMEMCMP''@/$(GL_GNULIB_WMEMCMP)/g' \
2153 -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \ 2790 -e 's/@''GNULIB_WMEMCPY''@/$(GL_GNULIB_WMEMCPY)/g' \
2154 -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \ 2791 -e 's/@''GNULIB_WMEMMOVE''@/$(GL_GNULIB_WMEMMOVE)/g' \
2155 -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \ 2792 -e 's/@''GNULIB_WMEMPCPY''@/$(GL_GNULIB_WMEMPCPY)/g' \
2156 -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \ 2793 -e 's/@''GNULIB_WMEMSET''@/$(GL_GNULIB_WMEMSET)/g' \
2157 -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \ 2794 -e 's/@''GNULIB_WCSLEN''@/$(GL_GNULIB_WCSLEN)/g' \
2158 -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \ 2795 -e 's/@''GNULIB_WCSNLEN''@/$(GL_GNULIB_WCSNLEN)/g' \
2159 -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \ 2796 -e 's/@''GNULIB_WCSCPY''@/$(GL_GNULIB_WCSCPY)/g' \
2160 -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \ 2797 -e 's/@''GNULIB_WCPCPY''@/$(GL_GNULIB_WCPCPY)/g' \
2161 -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \ 2798 -e 's/@''GNULIB_WCSNCPY''@/$(GL_GNULIB_WCSNCPY)/g' \
2162 -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \ 2799 -e 's/@''GNULIB_WCPNCPY''@/$(GL_GNULIB_WCPNCPY)/g' \
2163 -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \ 2800 -e 's/@''GNULIB_WCSCAT''@/$(GL_GNULIB_WCSCAT)/g' \
2164 -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \ 2801 -e 's/@''GNULIB_WCSNCAT''@/$(GL_GNULIB_WCSNCAT)/g' \
2165 -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \ 2802 -e 's/@''GNULIB_WCSCMP''@/$(GL_GNULIB_WCSCMP)/g' \
2166 -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \ 2803 -e 's/@''GNULIB_WCSNCMP''@/$(GL_GNULIB_WCSNCMP)/g' \
2167 -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \ 2804 -e 's/@''GNULIB_WCSCASECMP''@/$(GL_GNULIB_WCSCASECMP)/g' \
2168 -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \ 2805 -e 's/@''GNULIB_WCSNCASECMP''@/$(GL_GNULIB_WCSNCASECMP)/g' \
2169 -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \ 2806 -e 's/@''GNULIB_WCSCOLL''@/$(GL_GNULIB_WCSCOLL)/g' \
2170 -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \ 2807 -e 's/@''GNULIB_WCSXFRM''@/$(GL_GNULIB_WCSXFRM)/g' \
2171 -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \ 2808 -e 's/@''GNULIB_WCSDUP''@/$(GL_GNULIB_WCSDUP)/g' \
2172 -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \ 2809 -e 's/@''GNULIB_WCSCHR''@/$(GL_GNULIB_WCSCHR)/g' \
2173 -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \ 2810 -e 's/@''GNULIB_WCSRCHR''@/$(GL_GNULIB_WCSRCHR)/g' \
2174 -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \ 2811 -e 's/@''GNULIB_WCSCSPN''@/$(GL_GNULIB_WCSCSPN)/g' \
2175 -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \ 2812 -e 's/@''GNULIB_WCSSPN''@/$(GL_GNULIB_WCSSPN)/g' \
2176 -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \ 2813 -e 's/@''GNULIB_WCSPBRK''@/$(GL_GNULIB_WCSPBRK)/g' \
2814 -e 's/@''GNULIB_WCSSTR''@/$(GL_GNULIB_WCSSTR)/g' \
2815 -e 's/@''GNULIB_WCSTOK''@/$(GL_GNULIB_WCSTOK)/g' \
2816 -e 's/@''GNULIB_WCSWIDTH''@/$(GL_GNULIB_WCSWIDTH)/g' \
2817 -e 's/@''GNULIB_WCSFTIME''@/$(GL_GNULIB_WCSFTIME)/g' \
2818 -e 's/@''GNULIB_MDA_WCSDUP''@/$(GL_GNULIB_MDA_WCSDUP)/g' \
2819 -e 's/@''GNULIB_FREE_POSIX''@/$(GL_GNULIB_FREE_POSIX)/g' \
2177 < $(srcdir)/wchar.in.h | \ 2820 < $(srcdir)/wchar.in.h | \
2178 sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ 2821 sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
2179 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ 2822 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
@@ -2189,6 +2832,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2189 -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \ 2832 -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
2190 -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \ 2833 -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
2191 -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \ 2834 -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
2835 -e 's|@''HAVE_WMEMPCPY''@|$(HAVE_WMEMPCPY)|g' \
2192 -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \ 2836 -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
2193 -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \ 2837 -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
2194 -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \ 2838 -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
@@ -2213,12 +2857,15 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2213 -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \ 2857 -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
2214 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \ 2858 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
2215 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \ 2859 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
2860 -e 's|@''HAVE_WCSFTIME''@|$(HAVE_WCSFTIME)|g' \
2216 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ 2861 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
2862 -e 's|@''HAVE_DECL_WCSDUP''@|$(HAVE_DECL_WCSDUP)|g' \
2217 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ 2863 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
2218 | \ 2864 | \
2219 sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ 2865 sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
2220 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ 2866 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
2221 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ 2867 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
2868 -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
2222 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ 2869 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
2223 -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \ 2870 -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
2224 -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \ 2871 -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
@@ -2229,11 +2876,13 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
2229 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ 2876 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
2230 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ 2877 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
2231 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \ 2878 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
2879 -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
2880 -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \
2232 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2881 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2233 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2882 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2234 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 2883 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2235 } > $@-t && \ 2884 > $@-t
2236 mv $@-t $@ 2885 $(AM_V_at)mv $@-t $@
2237MOSTLYCLEANFILES += wchar.h wchar.h-t 2886MOSTLYCLEANFILES += wchar.h wchar.h-t
2238 2887
2239EXTRA_DIST += wchar.in.h 2888EXTRA_DIST += wchar.in.h
@@ -2242,10 +2891,9 @@ EXTRA_DIST += wchar.in.h
2242 2891
2243## begin gnulib module wcrtomb 2892## begin gnulib module wcrtomb
2244 2893
2245 2894if GL_COND_OBJ_WCRTOMB
2246EXTRA_DIST += wcrtomb.c 2895libgnu_a_SOURCES += wcrtomb.c
2247 2896endif
2248EXTRA_libgnu_a_SOURCES += wcrtomb.c
2249 2897
2250## end gnulib module wcrtomb 2898## end gnulib module wcrtomb
2251 2899
@@ -2257,38 +2905,82 @@ libgnu_a_SOURCES += wctype-h.c
2257# We need the following in order to create <wctype.h> when the system 2905# We need the following in order to create <wctype.h> when the system
2258# doesn't have one that works with the given compiler. 2906# doesn't have one that works with the given compiler.
2259wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) 2907wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
2260 $(AM_V_GEN)rm -f $@-t $@ && \ 2908 $(gl_V_at)$(SED_HEADER_STDOUT) \
2261 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2909 -e 's|@''GUARD_PREFIX''@|GL|g' \
2262 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2263 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ 2910 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
2264 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2911 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
2265 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2912 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2266 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ 2913 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2267 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ 2914 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
2268 -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ 2915 -e 's/@''HAVE_CRTDEFS_H''@/$(HAVE_CRTDEFS_H)/g' \
2269 -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ 2916 -e 's/@''GNULIBHEADERS_OVERRIDE_WINT_T''@/$(GNULIBHEADERS_OVERRIDE_WINT_T)/g' \
2270 -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ 2917 -e 's/@''GNULIB_ISWBLANK''@/$(GL_GNULIB_ISWBLANK)/g' \
2271 -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \ 2918 -e 's/@''GNULIB_ISWDIGIT''@/$(GL_GNULIB_ISWDIGIT)/g' \
2272 -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \ 2919 -e 's/@''GNULIB_ISWXDIGIT''@/$(GL_GNULIB_ISWXDIGIT)/g' \
2920 -e 's/@''GNULIB_WCTYPE''@/$(GL_GNULIB_WCTYPE)/g' \
2921 -e 's/@''GNULIB_ISWCTYPE''@/$(GL_GNULIB_ISWCTYPE)/g' \
2922 -e 's/@''GNULIB_WCTRANS''@/$(GL_GNULIB_WCTRANS)/g' \
2923 -e 's/@''GNULIB_TOWCTRANS''@/$(GL_GNULIB_TOWCTRANS)/g' \
2273 -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ 2924 -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
2274 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ 2925 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
2275 -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ 2926 -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
2276 -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \ 2927 -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
2277 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ 2928 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
2278 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \ 2929 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
2930 -e 's/@''REPLACE_ISWDIGIT''@/$(REPLACE_ISWDIGIT)/g' \
2931 -e 's/@''REPLACE_ISWXDIGIT''@/$(REPLACE_ISWXDIGIT)/g' \
2279 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ 2932 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
2280 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \ 2933 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
2281 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2934 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
2282 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2935 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
2283 < $(srcdir)/wctype.in.h; \ 2936 $(srcdir)/wctype.in.h > $@-t
2284 } > $@-t && \ 2937 $(AM_V_at)mv $@-t $@
2285 mv $@-t $@
2286MOSTLYCLEANFILES += wctype.h wctype.h-t 2938MOSTLYCLEANFILES += wctype.h wctype.h-t
2287 2939
2288EXTRA_DIST += wctype.in.h 2940EXTRA_DIST += wctype.in.h
2289 2941
2290## end gnulib module wctype-h 2942## end gnulib module wctype-h
2291 2943
2944## begin gnulib module windows-mutex
2945
2946if GL_COND_OBJ_WINDOWS_MUTEX
2947libgnu_a_SOURCES += windows-mutex.c
2948endif
2949
2950EXTRA_DIST += windows-initguard.h windows-mutex.h
2951
2952## end gnulib module windows-mutex
2953
2954## begin gnulib module windows-once
2955
2956if GL_COND_OBJ_WINDOWS_ONCE
2957libgnu_a_SOURCES += windows-once.c
2958endif
2959
2960EXTRA_DIST += windows-once.h
2961
2962## end gnulib module windows-once
2963
2964## begin gnulib module windows-recmutex
2965
2966if GL_COND_OBJ_WINDOWS_RECMUTEX
2967libgnu_a_SOURCES += windows-recmutex.c
2968endif
2969
2970EXTRA_DIST += windows-initguard.h windows-recmutex.h
2971
2972## end gnulib module windows-recmutex
2973
2974## begin gnulib module windows-rwlock
2975
2976if GL_COND_OBJ_WINDOWS_RWLOCK
2977libgnu_a_SOURCES += windows-rwlock.c
2978endif
2979
2980EXTRA_DIST += windows-initguard.h windows-rwlock.h
2981
2982## end gnulib module windows-rwlock
2983
2292## begin gnulib module xalloc 2984## begin gnulib module xalloc
2293 2985
2294libgnu_a_SOURCES += xmalloc.c 2986libgnu_a_SOURCES += xmalloc.c
@@ -2301,6 +2993,8 @@ EXTRA_DIST += xalloc.h
2301 2993
2302libgnu_a_SOURCES += xalloc-die.c 2994libgnu_a_SOURCES += xalloc-die.c
2303 2995
2996EXTRA_DIST += xalloc.h
2997
2304## end gnulib module xalloc-die 2998## end gnulib module xalloc-die
2305 2999
2306## begin gnulib module xalloc-oversized 3000## begin gnulib module xalloc-oversized
@@ -2316,12 +3010,6 @@ libgnu_a_SOURCES += xsize.h xsize.c
2316 3010
2317## end gnulib module xsize 3011## end gnulib module xsize
2318 3012
2319## begin gnulib module xstrndup
2320
2321libgnu_a_SOURCES += xstrndup.h xstrndup.c
2322
2323## end gnulib module xstrndup
2324
2325 3013
2326mostlyclean-local: mostlyclean-generic 3014mostlyclean-local: mostlyclean-generic
2327 @for dir in '' $(MOSTLYCLEANDIRS); do \ 3015 @for dir in '' $(MOSTLYCLEANDIRS); do \
@@ -2330,3 +3018,7 @@ mostlyclean-local: mostlyclean-generic
2330 fi; \ 3018 fi; \
2331 done; \ 3019 done; \
2332 : 3020 :
3021distclean-local: distclean-gnulib-libobjs
3022distclean-gnulib-libobjs:
3023 -rm -f @gl_LIBOBJDEPS@
3024maintainer-clean-local: distclean-gnulib-libobjs
diff --git a/gl/_Noreturn.h b/gl/_Noreturn.h
new file mode 100644
index 0000000..6ecea98
--- /dev/null
+++ b/gl/_Noreturn.h
@@ -0,0 +1,50 @@
1/* A C macro for declaring that a function does not return.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _Noreturn
18# if (defined __cplusplus \
19 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
20 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
21 && 0)
22 /* [[noreturn]] is not practically usable, because with it the syntax
23 extern _Noreturn void func (...);
24 would not be valid; such a declaration would only be valid with 'extern'
25 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
26 AIX system header files and several gnulib header files use precisely
27 this syntax with 'extern'. */
28# define _Noreturn [[noreturn]]
29# elif (defined __clang__ && __clang_major__ < 16 \
30 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
31 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
32 that rare LLVM bug, though you may get many false-alarm warnings. */
33# define _Noreturn
34# elif ((!defined __cplusplus || defined __clang__) \
35 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
36 || (!defined __STRICT_ANSI__ \
37 && (4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
38 || (defined __apple_build_version__ \
39 ? 6000000 <= __apple_build_version__ \
40 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
41 /* _Noreturn works as-is. */
42# elif (2 < __GNUC__ + (8 <= __GNUC_MINOR__) || defined __clang__ \
43 || 0x5110 <= __SUNPRO_C)
44# define _Noreturn __attribute__ ((__noreturn__))
45# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
46# define _Noreturn __declspec (noreturn)
47# else
48# define _Noreturn
49# endif
50#endif
diff --git a/gl/af_alg.c b/gl/af_alg.c
new file mode 100644
index 0000000..9f022ce
--- /dev/null
+++ b/gl/af_alg.c
@@ -0,0 +1,213 @@
1/* af_alg.c - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Matteo Croce <mcroce@redhat.com>, 2018. */
18
19#include <config.h>
20
21#include "af_alg.h"
22
23#if USE_LINUX_CRYPTO_API
24
25#include <unistd.h>
26#include <string.h>
27#include <stdio.h>
28#include <errno.h>
29#include <linux/if_alg.h>
30#include <sys/stat.h>
31#include <sys/sendfile.h>
32#include <sys/socket.h>
33
34#include "sys-limits.h"
35
36#define BLOCKSIZE 32768
37
38/* Return a newly created socket for ALG.
39 On error, return a negative error number. */
40static int
41alg_socket (char const *alg)
42{
43 struct sockaddr_alg salg = {
44 .salg_family = AF_ALG,
45 .salg_type = "hash",
46 };
47 /* Copy alg into salg.salg_name, without calling strcpy nor strlen. */
48 for (size_t i = 0; (salg.salg_name[i] = alg[i]) != '\0'; i++)
49 if (i == sizeof salg.salg_name - 1)
50 /* alg is too long. */
51 return -EINVAL;
52
53 int cfd = socket (AF_ALG, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
54 if (cfd < 0)
55 return -EAFNOSUPPORT;
56 int ofd = (bind (cfd, (struct sockaddr *) &salg, sizeof salg) == 0
57 ? accept4 (cfd, NULL, 0, SOCK_CLOEXEC)
58 : -1);
59 close (cfd);
60 return ofd < 0 ? -EAFNOSUPPORT : ofd;
61}
62
63int
64afalg_buffer (const char *buffer, size_t len, const char *alg,
65 void *resblock, ssize_t hashlen)
66{
67 /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
68 See <https://patchwork.kernel.org/patch/9308641/>.
69 This was not fixed properly until November 2016,
70 see <https://patchwork.kernel.org/patch/9434741/>. */
71 if (len == 0)
72 return -EAFNOSUPPORT;
73
74 int ofd = alg_socket (alg);
75 if (ofd < 0)
76 return ofd;
77
78 int result;
79
80 for (;;)
81 {
82 ssize_t size = (len > BLOCKSIZE ? BLOCKSIZE : len);
83 if (send (ofd, buffer, size, MSG_MORE) != size)
84 {
85 result = -EAFNOSUPPORT;
86 break;
87 }
88 buffer += size;
89 len -= size;
90 if (len == 0)
91 {
92 result = read (ofd, resblock, hashlen) == hashlen ? 0 : -EAFNOSUPPORT;
93 break;
94 }
95 }
96
97 close (ofd);
98 return result;
99}
100
101int
102afalg_stream (FILE *stream, const char *alg,
103 void *resblock, ssize_t hashlen)
104{
105 int ofd = alg_socket (alg);
106 if (ofd < 0)
107 return ofd;
108
109 /* If STREAM's size is known and nonzero and not too large, attempt
110 sendfile to pipe the data. The nonzero restriction avoids issues
111 with /proc files that pretend to be empty, and lets the classic
112 read-write loop work around an empty-input bug noted below. */
113 int fd = fileno (stream);
114 int result;
115 struct stat st;
116 off_t off = ftello (stream);
117 if (0 <= off && fstat (fd, &st) == 0
118 && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
119 && off < st.st_size && st.st_size - off < SYS_BUFSIZE_MAX)
120 {
121 /* Make sure the offset of fileno (stream) reflects how many bytes
122 have been read from stream before this function got invoked.
123 Note: fflush on an input stream after ungetc does not work as expected
124 on some platforms. Therefore this situation is not supported here. */
125 if (fflush (stream))
126 result = -EIO;
127 else
128 {
129 off_t nbytes = st.st_size - off;
130 if (sendfile (ofd, fd, &off, nbytes) == nbytes)
131 {
132 if (read (ofd, resblock, hashlen) == hashlen)
133 {
134 /* The input buffers of stream are no longer valid. */
135 if (lseek (fd, off, SEEK_SET) != (off_t)-1)
136 result = 0;
137 else
138 /* The file position of fd has not changed. */
139 result = -EAFNOSUPPORT;
140 }
141 else
142 /* The file position of fd has not changed. */
143 result = -EAFNOSUPPORT;
144 }
145 else
146 /* The file position of fd has not changed. */
147 result = -EAFNOSUPPORT;
148 }
149 }
150 else
151 {
152 /* sendfile not possible, do a classic read-write loop. */
153
154 /* Number of bytes to seek (backwards) in case of error. */
155 off_t nseek = 0;
156
157 for (;;)
158 {
159 char buf[BLOCKSIZE];
160 /* When the stream is not seekable, start with a single-byte block,
161 so that we can use ungetc() in the case that send() fails. */
162 size_t blocksize = (nseek == 0 && off < 0 ? 1 : BLOCKSIZE);
163 ssize_t size = fread (buf, 1, blocksize, stream);
164 if (size == 0)
165 {
166 /* On Linux < 4.9, the value for an empty stream is wrong (all 0).
167 See <https://patchwork.kernel.org/patch/9308641/>.
168 This was not fixed properly until November 2016,
169 see <https://patchwork.kernel.org/patch/9434741/>. */
170 result = ferror (stream) ? -EIO : nseek == 0 ? -EAFNOSUPPORT : 0;
171 break;
172 }
173 nseek -= size;
174 if (send (ofd, buf, size, MSG_MORE) != size)
175 {
176 if (nseek == -1)
177 {
178 /* 1 byte of pushback buffer is guaranteed on stream, even
179 if stream is not seekable. */
180 ungetc ((unsigned char) buf[0], stream);
181 result = -EAFNOSUPPORT;
182 }
183 else if (fseeko (stream, nseek, SEEK_CUR) == 0)
184 /* The position of stream has been restored. */
185 result = -EAFNOSUPPORT;
186 else
187 result = -EIO;
188 break;
189 }
190
191 /* Don't assume that EOF is sticky. See:
192 <https://sourceware.org/bugzilla/show_bug.cgi?id=19476>. */
193 if (feof (stream))
194 {
195 result = 0;
196 break;
197 }
198 }
199
200 if (result == 0 && read (ofd, resblock, hashlen) != hashlen)
201 {
202 if (nseek == 0 || fseeko (stream, nseek, SEEK_CUR) == 0)
203 /* The position of stream has been restored. */
204 result = -EAFNOSUPPORT;
205 else
206 result = -EIO;
207 }
208 }
209 close (ofd);
210 return result;
211}
212
213#endif
diff --git a/gl/af_alg.h b/gl/af_alg.h
new file mode 100644
index 0000000..e8ffb3f
--- /dev/null
+++ b/gl/af_alg.h
@@ -0,0 +1,115 @@
1/* af_alg.h - Compute message digests from file streams and buffers.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Matteo Croce <mcroce@redhat.com>, 2018.
18 Documentation by Bruno Haible <bruno@clisp.org>, 2018. */
19
20/* Declare specific functions for computing message digests
21 using the Linux kernel crypto API, if available. This kernel API gives
22 access to specialized crypto instructions (that would also be available
23 in user space) or to crypto devices (not directly available in user space).
24
25 For a more complete set of facilities that use the Linux kernel crypto API,
26 look at libkcapi. */
27
28#ifndef AF_ALG_H
29# define AF_ALG_H 1
30
31# include <stdio.h>
32# include <errno.h>
33
34# ifdef __cplusplus
35extern "C" {
36# endif
37
38# if USE_LINUX_CRYPTO_API
39
40/* Compute a message digest of a memory region.
41
42 The memory region starts at BUFFER and is LEN bytes long.
43
44 ALG is the message digest algorithm; see the file /proc/crypto.
45
46 RESBLOCK points to a block of HASHLEN bytes, for the result.
47 HASHLEN must be the length of the message digest, in bytes, in particular:
48
49 alg | hashlen
50 -------+--------
51 md5 | 16
52 sha1 | 20
53 sha224 | 28
54 sha256 | 32
55 sha384 | 48
56 sha512 | 64
57
58 If successful, fill RESBLOCK and return 0.
59 Upon failure, return a negated error number. */
60int
61afalg_buffer (const char *buffer, size_t len, const char *alg,
62 void *resblock, ssize_t hashlen);
63
64/* Compute a message digest of data read from STREAM.
65
66 STREAM is an open file stream. The last operation on STREAM should
67 not be 'ungetc', and if STREAM is also open for writing it should
68 have been fflushed since its last write. Read from the current
69 position to the end of STREAM. Handle regular files efficiently.
70
71 ALG is the message digest algorithm; see the file /proc/crypto.
72
73 RESBLOCK points to a block of HASHLEN bytes, for the result.
74 HASHLEN must be the length of the message digest, in bytes, in particular:
75
76 alg | hashlen
77 -------+--------
78 md5 | 16
79 sha1 | 20
80 sha224 | 28
81 sha256 | 32
82 sha384 | 48
83 sha512 | 64
84
85 If successful, fill RESBLOCK and return 0.
86 Upon failure, return a negated error number.
87 Unless returning 0 or -EIO, restore STREAM's file position so that
88 the caller can fall back on some other method. */
89int
90afalg_stream (FILE *stream, const char *alg,
91 void *resblock, ssize_t hashlen);
92
93# else
94
95static inline int
96afalg_buffer (const char *buffer, size_t len, const char *alg,
97 void *resblock, ssize_t hashlen)
98{
99 return -EAFNOSUPPORT;
100}
101
102static inline int
103afalg_stream (FILE *stream, const char *alg,
104 void *resblock, ssize_t hashlen)
105{
106 return -EAFNOSUPPORT;
107}
108
109# endif
110
111# ifdef __cplusplus
112}
113# endif
114
115#endif /* AF_ALG_H */
diff --git a/gl/alloca.in.h b/gl/alloca.in.h
index 72d28ee..a1bb3d7 100644
--- a/gl/alloca.in.h
+++ b/gl/alloca.in.h
@@ -1,22 +1,20 @@
1/* Memory allocation on the stack. 1/* Memory allocation on the stack.
2 2
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation, 3 Copyright (C) 1995, 1999, 2001-2004, 2006-2023 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This file is free software: you can redistribute it and/or modify
7 under the terms of the GNU General Public License as published 7 it under the terms of the GNU Lesser General Public License as
8 by the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public License
17 License along with this program; if not, see 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 <http://www.gnu.org/licenses/>.
19 */
20 18
21/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H 19/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
22 means there is a real alloca function. */ 20 means there is a real alloca function. */
@@ -35,7 +33,16 @@
35 */ 33 */
36 34
37#ifndef alloca 35#ifndef alloca
38# ifdef __GNUC__ 36 /* Some version of mingw have an <alloca.h> that causes trouble when
37 included after 'alloca' gets defined as a macro. As a workaround,
38 include this <alloca.h> first and define 'alloca' as a macro afterwards
39 if needed. */
40# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
41# include_next <alloca.h>
42# endif
43#endif
44#ifndef alloca
45# if defined __GNUC__ || (__clang_major__ >= 4)
39# define alloca __builtin_alloca 46# define alloca __builtin_alloca
40# elif defined _AIX 47# elif defined _AIX
41# define alloca __alloca 48# define alloca __alloca
@@ -51,6 +58,8 @@ extern "C"
51void *_alloca (unsigned short); 58void *_alloca (unsigned short);
52# pragma intrinsic (_alloca) 59# pragma intrinsic (_alloca)
53# define alloca _alloca 60# define alloca _alloca
61# elif defined __MVS__
62# include <stdlib.h>
54# else 63# else
55# include <stddef.h> 64# include <stddef.h>
56# ifdef __cplusplus 65# ifdef __cplusplus
diff --git a/build-aux/snippet/arg-nonnull.h b/gl/arg-nonnull.h
index 8ea2a47..9498ae1 100644
--- a/build-aux/snippet/arg-nonnull.h
+++ b/gl/arg-nonnull.h
@@ -1,24 +1,24 @@
1/* A C macro for declaring that specific arguments must not be NULL. 1/* A C macro for declaring that specific arguments must not be NULL.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published 5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or 6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details. 12 Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 17/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
18 that the values passed as arguments n, ..., m must be non-NULL pointers. 18 that the values passed as arguments n, ..., m must be non-NULL pointers.
19 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 19 n = 1 stands for the first argument, n = 2 for the second argument etc. */
20#ifndef _GL_ARG_NONNULL 20#ifndef _GL_ARG_NONNULL
21# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 21# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 22# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
23# else 23# else
24# define _GL_ARG_NONNULL(params) 24# define _GL_ARG_NONNULL(params)
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h
index ba89e97..80e6713 100644
--- a/gl/arpa_inet.in.h
+++ b/gl/arpa_inet.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <arpa/inet.h>. 1/* A GNU-like <arpa/inet.h>.
2 2
3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_ARPA_INET_H 18#ifndef _@GUARD_PREFIX@_ARPA_INET_H
19 19
@@ -49,6 +49,12 @@
49#ifndef _@GUARD_PREFIX@_ARPA_INET_H 49#ifndef _@GUARD_PREFIX@_ARPA_INET_H
50#define _@GUARD_PREFIX@_ARPA_INET_H 50#define _@GUARD_PREFIX@_ARPA_INET_H
51 51
52/* Get all possible declarations of inet_ntop() and inet_pton(). */
53#if (@GNULIB_INET_NTOP@ || @GNULIB_INET_PTON@ || defined GNULIB_POSIXCHECK) \
54 && @HAVE_WS2TCPIP_H@
55# include <ws2tcpip.h>
56#endif
57
52/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 58/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
53 59
54/* The definition of _GL_ARG_NONNULL is copied here. */ 60/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -70,8 +76,8 @@
70 the return value is NULL and errno is set to ENOSPC. A good value 76 the return value is NULL and errno is set to ENOSPC. A good value
71 for CNT is 46. 77 for CNT is 46.
72 78
73 For more details, see the POSIX:2001 specification 79 For more details, see the POSIX:2008 specification
74 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ 80 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html>. */
75# if @REPLACE_INET_NTOP@ 81# if @REPLACE_INET_NTOP@
76# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 82# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
77# undef inet_ntop 83# undef inet_ntop
@@ -97,7 +103,9 @@ _GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
97 (int af, const void *restrict src, 103 (int af, const void *restrict src,
98 char *restrict dst, socklen_t cnt)); 104 char *restrict dst, socklen_t cnt));
99# endif 105# endif
106# if __GLIBC__ >= 2
100_GL_CXXALIASWARN (inet_ntop); 107_GL_CXXALIASWARN (inet_ntop);
108# endif
101#elif defined GNULIB_POSIXCHECK 109#elif defined GNULIB_POSIXCHECK
102# undef inet_ntop 110# undef inet_ntop
103# if HAVE_RAW_DECL_INET_NTOP 111# if HAVE_RAW_DECL_INET_NTOP
@@ -126,7 +134,9 @@ _GL_FUNCDECL_SYS (inet_pton, int,
126_GL_CXXALIAS_SYS (inet_pton, int, 134_GL_CXXALIAS_SYS (inet_pton, int,
127 (int af, const char *restrict src, void *restrict dst)); 135 (int af, const char *restrict src, void *restrict dst));
128# endif 136# endif
137# if __GLIBC__ >= 2
129_GL_CXXALIASWARN (inet_pton); 138_GL_CXXALIASWARN (inet_pton);
139# endif
130#elif defined GNULIB_POSIXCHECK 140#elif defined GNULIB_POSIXCHECK
131# undef inet_pton 141# undef inet_pton
132# if HAVE_RAW_DECL_INET_PTON 142# if HAVE_RAW_DECL_INET_PTON
diff --git a/gl/asnprintf.c b/gl/asnprintf.c
index 76e228d..f4861bf 100644
--- a/gl/asnprintf.c
+++ b/gl/asnprintf.c
@@ -1,18 +1,18 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/asprintf.c b/gl/asprintf.c
index 713dae1..ba58e06 100644
--- a/gl/asprintf.c
+++ b/gl/asprintf.c
@@ -1,19 +1,19 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2007, 2009-2013 Free Software Foundation, 2 Copyright (C) 1999, 2002, 2006-2007, 2009-2023 Free Software Foundation,
3 Inc. 3 Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/assert.in.h b/gl/assert.in.h
new file mode 100644
index 0000000..b0ab99c
--- /dev/null
+++ b/gl/assert.in.h
@@ -0,0 +1,27 @@
1/* Substitute for and wrapper around <assert.h>
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Do not guard the include, since <assert.h> is supposed to define
18 the assert macro each time it is included. */
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25#@INCLUDE_NEXT@ @NEXT_ASSERT_H@
26
27/* The definition of static_assert is copied here. */
diff --git a/gl/attribute.h b/gl/attribute.h
new file mode 100644
index 0000000..130644d
--- /dev/null
+++ b/gl/attribute.h
@@ -0,0 +1,226 @@
1/* ATTRIBUTE_* macros for using attributes in GCC and similar compilers
2
3 Copyright 2020-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20/* Provide public ATTRIBUTE_* names for the private _GL_ATTRIBUTE_*
21 macros used within Gnulib. */
22
23/* These attributes can be placed in two ways:
24 - At the start of a declaration (i.e. even before storage-class
25 specifiers!); then they apply to all entities that are declared
26 by the declaration.
27 - Immediately after the name of an entity being declared by the
28 declaration; then they apply to that entity only. */
29
30#ifndef _GL_ATTRIBUTE_H
31#define _GL_ATTRIBUTE_H
32
33
34/* This file defines two types of attributes:
35 * C23 standard attributes. These have macro names that do not begin with
36 'ATTRIBUTE_'.
37 * Selected GCC attributes; see:
38 https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
39 https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
40 https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html
41 These names begin with 'ATTRIBUTE_' to avoid name clashes. */
42
43
44/* =============== Attributes for specific kinds of functions =============== */
45
46/* Attributes for functions that should not be used. */
47
48/* Warn if the entity is used. */
49/* Applies to:
50 - function, variable,
51 - struct, union, struct/union member,
52 - enumeration, enumeration item,
53 - typedef,
54 in C++ also: namespace, class, template specialization. */
55#define DEPRECATED _GL_ATTRIBUTE_DEPRECATED
56
57/* If a function call is not optimized way, warn with MSG. */
58/* Applies to: functions. */
59#define ATTRIBUTE_WARNING(msg) _GL_ATTRIBUTE_WARNING (msg)
60
61/* If a function call is not optimized way, report an error with MSG. */
62/* Applies to: functions. */
63#define ATTRIBUTE_ERROR(msg) _GL_ATTRIBUTE_ERROR (msg)
64
65
66/* Attributes for memory-allocating functions. */
67
68/* The function returns a pointer to freshly allocated memory. */
69/* Applies to: functions. */
70#define ATTRIBUTE_MALLOC _GL_ATTRIBUTE_MALLOC
71
72/* ATTRIBUTE_ALLOC_SIZE ((N)) - The Nth argument of the function
73 is the size of the returned memory block.
74 ATTRIBUTE_ALLOC_SIZE ((M, N)) - Multiply the Mth and Nth arguments
75 to determine the size of the returned memory block. */
76/* Applies to: function, pointer to function, function types. */
77#define ATTRIBUTE_ALLOC_SIZE(args) _GL_ATTRIBUTE_ALLOC_SIZE (args)
78
79/* ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
80 that can be freed by passing them as the Ith argument to the
81 function F.
82 ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
83 can be freed via 'free'; it can be used only after declaring 'free'. */
84/* Applies to: functions. Cannot be used on inline functions. */
85#define ATTRIBUTE_DEALLOC(f, i) _GL_ATTRIBUTE_DEALLOC(f, i)
86#define ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC_FREE
87
88/* Attributes for variadic functions. */
89
90/* The variadic function expects a trailing NULL argument.
91 ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
92 ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
93/* Applies to: functions. */
94#define ATTRIBUTE_SENTINEL(pos) _GL_ATTRIBUTE_SENTINEL (pos)
95
96
97/* ================== Attributes for compiler diagnostics ================== */
98
99/* Attributes that help the compiler diagnose programmer mistakes.
100 Some of them may also help for some compiler optimizations. */
101
102/* ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) -
103 The STRING-INDEXth function argument is a format string of style
104 ARCHETYPE, which is one of:
105 printf, gnu_printf
106 scanf, gnu_scanf,
107 strftime, gnu_strftime,
108 strfmon,
109 or the same thing prefixed and suffixed with '__'.
110 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
111 are suitable for the format string. */
112/* Applies to: functions. */
113#define ATTRIBUTE_FORMAT(spec) _GL_ATTRIBUTE_FORMAT (spec)
114
115/* ATTRIBUTE_NONNULL ((N1, N2,...)) - Arguments N1, N2,... must not be NULL.
116 ATTRIBUTE_NONNULL () - All pointer arguments must not be null. */
117/* Applies to: functions. */
118#define ATTRIBUTE_NONNULL(args) _GL_ATTRIBUTE_NONNULL (args)
119
120/* The function's return value is a non-NULL pointer. */
121/* Applies to: functions. */
122#define ATTRIBUTE_RETURNS_NONNULL _GL_ATTRIBUTE_RETURNS_NONNULL
123
124/* Warn if the caller does not use the return value,
125 unless the caller uses something like ignore_value. */
126/* Applies to: function, enumeration, class. */
127#define NODISCARD _GL_ATTRIBUTE_NODISCARD
128
129
130/* Attributes that disable false alarms when the compiler diagnoses
131 programmer "mistakes". */
132
133/* Do not warn if the entity is not used. */
134/* Applies to:
135 - function, variable,
136 - struct, union, struct/union member,
137 - enumeration, enumeration item,
138 - typedef,
139 in C++ also: class. */
140#define MAYBE_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
141
142/* The contents of a character array is not meant to be NUL-terminated. */
143/* Applies to: struct/union members and variables that are arrays of element
144 type '[[un]signed] char'. */
145#define ATTRIBUTE_NONSTRING _GL_ATTRIBUTE_NONSTRING
146
147/* Do not warn if control flow falls through to the immediately
148 following 'case' or 'default' label. */
149/* Applies to: Empty statement (;), inside a 'switch' statement. */
150#define FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
151
152
153/* ================== Attributes for debugging information ================== */
154
155/* Attributes regarding debugging information emitted by the compiler. */
156
157/* Omit the function from stack traces when debugging. */
158/* Applies to: function. */
159#define ATTRIBUTE_ARTIFICIAL _GL_ATTRIBUTE_ARTIFICIAL
160
161/* Make the entity visible to debuggers etc., even with '-fwhole-program'. */
162/* Applies to: functions, variables. */
163#define ATTRIBUTE_EXTERNALLY_VISIBLE _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
164
165
166/* ========== Attributes that mainly direct compiler optimizations ========== */
167
168/* The function does not throw exceptions. */
169/* Applies to: functions. */
170#define ATTRIBUTE_NOTHROW _GL_ATTRIBUTE_NOTHROW
171
172/* Do not inline the function. */
173/* Applies to: functions. */
174#define ATTRIBUTE_NOINLINE _GL_ATTRIBUTE_NOINLINE
175
176/* Always inline the function, and report an error if the compiler
177 cannot inline. */
178/* Applies to: function. */
179#define ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_ALWAYS_INLINE
180
181/* It is OK for a compiler to omit duplicate calls with the same arguments.
182 This attribute is safe for a function that neither depends on
183 nor affects observable state, and always returns exactly once -
184 e.g., does not loop forever, and does not call longjmp.
185 (This attribute is stricter than ATTRIBUTE_PURE.) */
186/* Applies to: functions. */
187#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
188
189/* It is OK for a compiler to omit duplicate calls with the same
190 arguments if observable state is not changed between calls.
191 This attribute is safe for a function that does not affect
192 observable state, and always returns exactly once.
193 (This attribute is looser than ATTRIBUTE_CONST.) */
194/* Applies to: functions. */
195#define ATTRIBUTE_PURE _GL_ATTRIBUTE_PURE
196
197/* The function is rarely executed. */
198/* Applies to: functions. */
199#define ATTRIBUTE_COLD _GL_ATTRIBUTE_COLD
200
201/* If called from some other compilation unit, the function executes
202 code from that unit only by return or by exception handling,
203 letting the compiler optimize that unit more aggressively. */
204/* Applies to: functions. */
205#define ATTRIBUTE_LEAF _GL_ATTRIBUTE_LEAF
206
207/* For struct members: The member has the smallest possible alignment.
208 For struct, union, class: All members have the smallest possible alignment,
209 minimizing the memory required. */
210/* Applies to: struct members, struct, union,
211 in C++ also: class. */
212#define ATTRIBUTE_PACKED _GL_ATTRIBUTE_PACKED
213
214
215/* ================ Attributes that make invalid code valid ================ */
216
217/* Attributes that prevent fatal compiler optimizations for code that is not
218 fully ISO C compliant. */
219
220/* Pointers to the type may point to the same storage as pointers to
221 other types, thus disabling strict aliasing optimization. */
222/* Applies to: types. */
223#define ATTRIBUTE_MAY_ALIAS _GL_ATTRIBUTE_MAY_ALIAS
224
225
226#endif /* _GL_ATTRIBUTE_H */
diff --git a/gl/base64.c b/gl/base64.c
index 8da969c..95b669a 100644
--- a/gl/base64.c
+++ b/gl/base64.c
@@ -1,24 +1,24 @@
1/* base64.c -- Encode binary data using printable characters. 1/* base64.c -- Encode binary data using printable characters.
2 Copyright (C) 1999-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999-2001, 2004-2006, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Simon Josefsson. Partially adapted from GNU MailUtils 17/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
18 * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review 18 * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
19 * from Paul Eggert, Bruno Haible, and Stepan Kasal. 19 * from Paul Eggert, Bruno Haible, and Stepan Kasal.
20 * 20 *
21 * See also RFC 4648 <http://www.ietf.org/rfc/rfc4648.txt>. 21 * See also RFC 4648 <https://www.ietf.org/rfc/rfc4648.txt>.
22 * 22 *
23 * Be careful with error checking. Here is how you would typically 23 * Be careful with error checking. Here is how you would typically
24 * use these functions: 24 * use these functions:
@@ -30,7 +30,7 @@
30 * FAIL: memory allocation error 30 * FAIL: memory allocation error
31 * OK: data in OUT/OUTLEN 31 * OK: data in OUT/OUTLEN
32 * 32 *
33 * size_t outlen = base64_encode_alloc (in, inlen, &out); 33 * idx_t outlen = base64_encode_alloc (in, inlen, &out);
34 * if (out == NULL && outlen == 0 && inlen != 0) 34 * if (out == NULL && outlen == 0 && inlen != 0)
35 * FAIL: input too long 35 * FAIL: input too long
36 * if (out == NULL) 36 * if (out == NULL)
@@ -44,51 +44,84 @@
44/* Get prototype. */ 44/* Get prototype. */
45#include "base64.h" 45#include "base64.h"
46 46
47/* Get malloc. */ 47/* Get imalloc. */
48#include <stdlib.h> 48#include <ialloc.h>
49
50#include <intprops.h>
49 51
50/* Get UCHAR_MAX. */ 52/* Get UCHAR_MAX. */
51#include <limits.h> 53#include <limits.h>
52 54
53#include <string.h> 55#include <string.h>
54 56
55/* C89 compliant way to cast 'char' to 'unsigned char'. */ 57/* Convert 'char' to 'unsigned char' without casting. */
56static unsigned char 58static unsigned char
57to_uchar (char ch) 59to_uchar (char ch)
58{ 60{
59 return ch; 61 return ch;
60} 62}
61 63
64static const char b64c[64] =
65 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
66
67/* Base64 encode IN array of size INLEN into OUT array. OUT needs
68 to be of length >= BASE64_LENGTH(INLEN), and INLEN needs to be
69 a multiple of 3. */
70static void
71base64_encode_fast (const char *restrict in, idx_t inlen, char *restrict out)
72{
73 while (inlen)
74 {
75 *out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
76 *out++ = b64c[((to_uchar (in[0]) << 4) + (to_uchar (in[1]) >> 4)) & 0x3f];
77 *out++ = b64c[((to_uchar (in[1]) << 2) + (to_uchar (in[2]) >> 6)) & 0x3f];
78 *out++ = b64c[to_uchar (in[2]) & 0x3f];
79
80 inlen -= 3;
81 in += 3;
82 }
83}
84
62/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN. 85/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
63 If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as 86 If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
64 possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero 87 possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
65 terminate the output buffer. */ 88 terminate the output buffer. */
66void 89void
67base64_encode (const char *restrict in, size_t inlen, 90base64_encode (const char *restrict in, idx_t inlen,
68 char *restrict out, size_t outlen) 91 char *restrict out, idx_t outlen)
69{ 92{
70 static const char b64str[64] = 93 /* Note this outlen constraint can be enforced at compile time.
71 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 94 I.E. that the output buffer is exactly large enough to hold
95 the encoded inlen bytes. The inlen constraints (of corresponding
96 to outlen, and being a multiple of 3) can change at runtime
97 at the end of input. However the common case when reading
98 large inputs is to have both constraints satisfied, so we depend
99 on both in base_encode_fast(). */
100 if (outlen % 4 == 0 && inlen == (outlen >> 2) * 3)
101 {
102 base64_encode_fast (in, inlen, out);
103 return;
104 }
72 105
73 while (inlen && outlen) 106 while (inlen && outlen)
74 { 107 {
75 *out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f]; 108 *out++ = b64c[(to_uchar (in[0]) >> 2) & 0x3f];
76 if (!--outlen) 109 if (!--outlen)
77 break; 110 break;
78 *out++ = b64str[((to_uchar (in[0]) << 4) 111 *out++ = b64c[((to_uchar (in[0]) << 4)
79 + (--inlen ? to_uchar (in[1]) >> 4 : 0)) 112 + (--inlen ? to_uchar (in[1]) >> 4 : 0))
80 & 0x3f]; 113 & 0x3f];
81 if (!--outlen) 114 if (!--outlen)
82 break; 115 break;
83 *out++ = 116 *out++ =
84 (inlen 117 (inlen
85 ? b64str[((to_uchar (in[1]) << 2) 118 ? b64c[((to_uchar (in[1]) << 2)
86 + (--inlen ? to_uchar (in[2]) >> 6 : 0)) 119 + (--inlen ? to_uchar (in[2]) >> 6 : 0))
87 & 0x3f] 120 & 0x3f]
88 : '='); 121 : '=');
89 if (!--outlen) 122 if (!--outlen)
90 break; 123 break;
91 *out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '='; 124 *out++ = inlen ? b64c[to_uchar (in[2]) & 0x3f] : '=';
92 if (!--outlen) 125 if (!--outlen)
93 break; 126 break;
94 if (inlen) 127 if (inlen)
@@ -110,30 +143,21 @@ base64_encode (const char *restrict in, size_t inlen,
110 memory allocation failed, OUT is set to NULL, and the return value 143 memory allocation failed, OUT is set to NULL, and the return value
111 indicates length of the requested memory block, i.e., 144 indicates length of the requested memory block, i.e.,
112 BASE64_LENGTH(inlen) + 1. */ 145 BASE64_LENGTH(inlen) + 1. */
113size_t 146idx_t
114base64_encode_alloc (const char *in, size_t inlen, char **out) 147base64_encode_alloc (const char *in, idx_t inlen, char **out)
115{ 148{
116 size_t outlen = 1 + BASE64_LENGTH (inlen);
117
118 /* Check for overflow in outlen computation. 149 /* Check for overflow in outlen computation.
119 * 150 Treat negative INLEN as overflow, for better compatibility with
120 * If there is no overflow, outlen >= inlen. 151 pre-2021-08-27 API, which used size_t. */
121 * 152 idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
122 * If the operation (inlen + 2) overflows then it yields at most +1, so 153 if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0)
123 * outlen is 0.
124 *
125 * If the multiplication overflows, we lose at least half of the
126 * correct value, so the result is < ((inlen + 2) / 3) * 2, which is
127 * less than (inlen + 2) * 0.66667, which is less than inlen as soon as
128 * (inlen > 4).
129 */
130 if (inlen > outlen)
131 { 154 {
132 *out = NULL; 155 *out = NULL;
133 return 0; 156 return 0;
134 } 157 }
158 outlen++;
135 159
136 *out = malloc (outlen); 160 *out = imalloc (outlen);
137 if (!*out) 161 if (!*out)
138 return outlen; 162 return outlen;
139 163
@@ -317,7 +341,7 @@ base64_decode_ctx_init (struct base64_decode_context *ctx)
317static char * 341static char *
318get_4 (struct base64_decode_context *ctx, 342get_4 (struct base64_decode_context *ctx,
319 char const *restrict *in, char const *restrict in_end, 343 char const *restrict *in, char const *restrict in_end,
320 size_t *n_non_newline) 344 idx_t *n_non_newline)
321{ 345{
322 if (ctx->i == 4) 346 if (ctx->i == 4)
323 ctx->i = 0; 347 ctx->i = 0;
@@ -369,8 +393,8 @@ get_4 (struct base64_decode_context *ctx,
369 *OUT to point to the byte after the last one written, and decrement 393 *OUT to point to the byte after the last one written, and decrement
370 *OUTLEN to reflect the number of bytes remaining in *OUT. */ 394 *OUTLEN to reflect the number of bytes remaining in *OUT. */
371static bool 395static bool
372decode_4 (char const *restrict in, size_t inlen, 396decode_4 (char const *restrict in, idx_t inlen,
373 char *restrict *outp, size_t *outleft) 397 char *restrict *outp, idx_t *outleft)
374{ 398{
375 char *out = *outp; 399 char *out = *outp;
376 if (inlen < 2) 400 if (inlen < 2)
@@ -455,10 +479,10 @@ decode_4 (char const *restrict in, size_t inlen,
455 479
456bool 480bool
457base64_decode_ctx (struct base64_decode_context *ctx, 481base64_decode_ctx (struct base64_decode_context *ctx,
458 const char *restrict in, size_t inlen, 482 const char *restrict in, idx_t inlen,
459 char *restrict out, size_t *outlen) 483 char *restrict out, idx_t *outlen)
460{ 484{
461 size_t outleft = *outlen; 485 idx_t outleft = *outlen;
462 bool ignore_newlines = ctx != NULL; 486 bool ignore_newlines = ctx != NULL;
463 bool flush_ctx = false; 487 bool flush_ctx = false;
464 unsigned int ctx_i = 0; 488 unsigned int ctx_i = 0;
@@ -472,7 +496,7 @@ base64_decode_ctx (struct base64_decode_context *ctx,
472 496
473 while (true) 497 while (true)
474 { 498 {
475 size_t outleft_save = outleft; 499 idx_t outleft_save = outleft;
476 if (ctx_i == 0 && !flush_ctx) 500 if (ctx_i == 0 && !flush_ctx)
477 { 501 {
478 while (true) 502 while (true)
@@ -546,17 +570,17 @@ base64_decode_ctx (struct base64_decode_context *ctx,
546 undefined. */ 570 undefined. */
547bool 571bool
548base64_decode_alloc_ctx (struct base64_decode_context *ctx, 572base64_decode_alloc_ctx (struct base64_decode_context *ctx,
549 const char *in, size_t inlen, char **out, 573 const char *in, idx_t inlen, char **out,
550 size_t *outlen) 574 idx_t *outlen)
551{ 575{
552 /* This may allocate a few bytes too many, depending on input, 576 /* This may allocate a few bytes too many, depending on input,
553 but it's not worth the extra CPU time to compute the exact size. 577 but it's not worth the extra CPU time to compute the exact size.
554 The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the 578 The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
555 input ends with "=" and minus another 1 if the input ends with "==". 579 input ends with "=" and minus another 1 if the input ends with "==".
556 Dividing before multiplying avoids the possibility of overflow. */ 580 Shifting before multiplying avoids the possibility of overflow. */
557 size_t needlen = 3 * (inlen / 4) + 3; 581 idx_t needlen = 3 * ((inlen >> 2) + 1);
558 582
559 *out = malloc (needlen); 583 *out = imalloc (needlen);
560 if (!*out) 584 if (!*out)
561 return true; 585 return true;
562 586
diff --git a/gl/base64.h b/gl/base64.h
index 343150c..9913765 100644
--- a/gl/base64.h
+++ b/gl/base64.h
@@ -1,28 +1,25 @@
1/* base64.h -- Encode binary data using printable characters. 1/* base64.h -- Encode binary data using printable characters.
2 Copyright (C) 2004-2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef BASE64_H 18#ifndef BASE64_H
19# define BASE64_H 19# define BASE64_H
20 20
21/* Get size_t. */ 21/* Get idx_t. */
22# include <stddef.h> 22# include <idx.h>
23
24/* Get bool. */
25# include <stdbool.h>
26 23
27# ifdef __cplusplus 24# ifdef __cplusplus
28extern "C" { 25extern "C" {
@@ -34,26 +31,26 @@ extern "C" {
34 31
35struct base64_decode_context 32struct base64_decode_context
36{ 33{
37 unsigned int i; 34 int i;
38 char buf[4]; 35 char buf[4];
39}; 36};
40 37
41extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST; 38extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
42 39
43extern void base64_encode (const char *restrict in, size_t inlen, 40extern void base64_encode (const char *restrict in, idx_t inlen,
44 char *restrict out, size_t outlen); 41 char *restrict out, idx_t outlen);
45 42
46extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); 43extern idx_t base64_encode_alloc (const char *in, idx_t inlen, char **out);
47 44
48extern void base64_decode_ctx_init (struct base64_decode_context *ctx); 45extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
49 46
50extern bool base64_decode_ctx (struct base64_decode_context *ctx, 47extern bool base64_decode_ctx (struct base64_decode_context *ctx,
51 const char *restrict in, size_t inlen, 48 const char *restrict in, idx_t inlen,
52 char *restrict out, size_t *outlen); 49 char *restrict out, idx_t *outlen);
53 50
54extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx, 51extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
55 const char *in, size_t inlen, 52 const char *in, idx_t inlen,
56 char **out, size_t *outlen); 53 char **out, idx_t *outlen);
57 54
58#define base64_decode(in, inlen, out, outlen) \ 55#define base64_decode(in, inlen, out, outlen) \
59 base64_decode_ctx (NULL, in, inlen, out, outlen) 56 base64_decode_ctx (NULL, in, inlen, out, outlen)
diff --git a/gl/basename-lgpl.c b/gl/basename-lgpl.c
index 9307e83..6de60aa 100644
--- a/gl/basename-lgpl.c
+++ b/gl/basename-lgpl.c
@@ -1,37 +1,36 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
21#include "dirname.h" 21/* Specification. */
22#include "basename-lgpl.h"
22 23
23#include <string.h> 24#include <string.h>
24 25
25/* Return the address of the last file name component of NAME. If 26#include "filename.h"
26 NAME has no relative file name components because it is a file
27 system root, return the empty string. */
28 27
29char * 28char *
30last_component (char const *name) 29last_component (char const *name)
31{ 30{
32 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name); 31 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
33 char const *p; 32 char const *p;
34 bool saw_slash = false; 33 bool last_was_slash = false;
35 34
36 while (ISSLASH (*base)) 35 while (ISSLASH (*base))
37 base++; 36 base++;
@@ -39,21 +38,17 @@ last_component (char const *name)
39 for (p = base; *p; p++) 38 for (p = base; *p; p++)
40 { 39 {
41 if (ISSLASH (*p)) 40 if (ISSLASH (*p))
42 saw_slash = true; 41 last_was_slash = true;
43 else if (saw_slash) 42 else if (last_was_slash)
44 { 43 {
45 base = p; 44 base = p;
46 saw_slash = false; 45 last_was_slash = false;
47 } 46 }
48 } 47 }
49 48
50 return (char *) base; 49 return (char *) base;
51} 50}
52 51
53/* Return the length of the basename NAME. Typically NAME is the
54 value returned by base_name or last_component. Act like strlen
55 (NAME), except omit all trailing slashes. */
56
57size_t 52size_t
58base_len (char const *name) 53base_len (char const *name)
59{ 54{
diff --git a/gl/basename-lgpl.h b/gl/basename-lgpl.h
new file mode 100644
index 0000000..5d996c1
--- /dev/null
+++ b/gl/basename-lgpl.h
@@ -0,0 +1,78 @@
1/* Extract the last component (base name) of a file name.
2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#ifndef _BASENAME_LGPL_H
20#define _BASENAME_LGPL_H
21
22#include <stddef.h>
23
24#ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
25# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
26#endif
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32
33/* Return the address of the last file name component of FILENAME.
34 If FILENAME has some trailing slash(es), they are considered to be
35 part of the last component.
36 If FILENAME has no relative file name components because it is a file
37 system root, return the empty string.
38 Examples:
39 FILENAME RESULT
40 "foo.c" "foo.c"
41 "foo/bar.c" "bar.c"
42 "/foo/bar.c" "bar.c"
43 "foo/bar/" "bar/"
44 "foo/bar//" "bar//"
45 "/" ""
46 "//" ""
47 "" ""
48 The return value is a tail of the given FILENAME; do NOT free() it! */
49
50/* This function was traditionally called 'basename', but we avoid this
51 function name because
52 * Various platforms have different functions in their libc.
53 In particular, the glibc basename(), defined in <string.h>, does
54 not consider trailing slashes to be part of the component:
55 FILENAME RESULT
56 "foo/bar/" ""
57 "foo/bar//" ""
58 * The 'basename' command eliminates trailing slashes and for a root
59 produces a non-empty result:
60 FILENAME RESULT
61 "foo/bar/" "bar"
62 "foo/bar//" "bar"
63 "/" "/"
64 "//" "/"
65 */
66extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE;
67
68/* Return the length of the basename FILENAME.
69 Typically FILENAME is the value returned by base_name or last_component.
70 Act like strlen (FILENAME), except omit all trailing slashes. */
71extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
72
73
74#ifdef __cplusplus
75} /* extern "C" */
76#endif
77
78#endif /* _BASENAME_LGPL_H */
diff --git a/gl/basename.c b/gl/basename.c
index d73fd41..21fab1e 100644
--- a/gl/basename.c
+++ b/gl/basename.c
@@ -1,11 +1,11 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
@@ -22,37 +22,43 @@
22 22
23#include <string.h> 23#include <string.h>
24#include "xalloc.h" 24#include "xalloc.h"
25#include "xstrndup.h"
26 25
27char * 26char *
28base_name (char const *name) 27base_name (char const *name)
29{ 28{
30 char const *base = last_component (name); 29 char const *base = last_component (name);
31 size_t length; 30 idx_t length;
32 31 int dotslash_len;
33 /* If there is no last component, then name is a file system root or the 32 if (*base)
34 empty string. */ 33 {
35 if (! *base) 34 length = base_len (base);
36 return xstrndup (name, base_len (name)); 35
37 36 /* Collapse a sequence of trailing slashes into one. */
38 /* Collapse a sequence of trailing slashes into one. */ 37 length += ISSLASH (base[length]);
39 length = base_len (base); 38
40 if (ISSLASH (base[length])) 39 /* On systems with drive letters, "a/b:c" must return "./b:c" rather
41 length++; 40 than "b:c" to avoid confusion with a drive letter. On systems
42 41 with pure POSIX semantics, this is not an issue. */
43 /* On systems with drive letters, "a/b:c" must return "./b:c" rather 42 dotslash_len = FILE_SYSTEM_PREFIX_LEN (base) != 0 ? 2 : 0;
44 than "b:c" to avoid confusion with a drive letter. On systems 43 }
45 with pure POSIX semantics, this is not an issue. */ 44 else
46 if (FILE_SYSTEM_PREFIX_LEN (base)) 45 {
46 /* There is no last component, so NAME is a file system root or
47 the empty string. */
48 base = name;
49 length = base_len (base);
50 dotslash_len = 0;
51 }
52
53 char *p = ximalloc (dotslash_len + length + 1);
54 if (dotslash_len)
47 { 55 {
48 char *p = xmalloc (length + 3);
49 p[0] = '.'; 56 p[0] = '.';
50 p[1] = '/'; 57 p[1] = '/';
51 memcpy (p + 2, base, length);
52 p[length + 2] = '\0';
53 return p;
54 } 58 }
55 59
56 /* Finally, copy the basename. */ 60 /* Finally, copy the basename. */
57 return xstrndup (base, length); 61 memcpy (p + dotslash_len, base, length);
62 p[dotslash_len + length] = '\0';
63 return p;
58} 64}
diff --git a/gl/btowc.c b/gl/btowc.c
index 6c7cbec..caadbd7 100644
--- a/gl/btowc.c
+++ b/gl/btowc.c
@@ -1,19 +1,19 @@
1/* Convert unibyte character to wide character. 1/* Convert unibyte character to wide character.
2 Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/byteswap.in.h b/gl/byteswap.in.h
new file mode 100644
index 0000000..e61be27
--- /dev/null
+++ b/gl/byteswap.in.h
@@ -0,0 +1,44 @@
1/* byteswap.h - Byte swapping
2 Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Oskar Liljeblad <oskar@osk.mine.nu>, 2005.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_BYTESWAP_H
19#define _GL_BYTESWAP_H
20
21/* Given an unsigned 16-bit argument X, return the value corresponding to
22 X with reversed byte order. */
23#define bswap_16(x) ((((x) & 0x00FF) << 8) | \
24 (((x) & 0xFF00) >> 8))
25
26/* Given an unsigned 32-bit argument X, return the value corresponding to
27 X with reversed byte order. */
28#define bswap_32(x) ((((x) & 0x000000FF) << 24) | \
29 (((x) & 0x0000FF00) << 8) | \
30 (((x) & 0x00FF0000) >> 8) | \
31 (((x) & 0xFF000000) >> 24))
32
33/* Given an unsigned 64-bit argument X, return the value corresponding to
34 X with reversed byte order. */
35#define bswap_64(x) ((((x) & 0x00000000000000FFULL) << 56) | \
36 (((x) & 0x000000000000FF00ULL) << 40) | \
37 (((x) & 0x0000000000FF0000ULL) << 24) | \
38 (((x) & 0x00000000FF000000ULL) << 8) | \
39 (((x) & 0x000000FF00000000ULL) >> 8) | \
40 (((x) & 0x0000FF0000000000ULL) >> 24) | \
41 (((x) & 0x00FF000000000000ULL) >> 40) | \
42 (((x) & 0xFF00000000000000ULL) >> 56))
43
44#endif /* _GL_BYTESWAP_H */
diff --git a/build-aux/snippet/c++defs.h b/gl/c++defs.h
index b35b933..8ad4695 100644
--- a/build-aux/snippet/c++defs.h
+++ b/gl/c++defs.h
@@ -1,22 +1,31 @@
1/* C++ compatible function declaration macros. 1/* C++ compatible function declaration macros.
2 Copyright (C) 2010-2013 Free Software Foundation, Inc. 2 Copyright (C) 2010-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published 5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or 6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details. 12 Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _GL_CXXDEFS_H 17#ifndef _GL_CXXDEFS_H
18#define _GL_CXXDEFS_H 18#define _GL_CXXDEFS_H
19 19
20/* Begin/end the GNULIB_NAMESPACE namespace. */
21#if defined __cplusplus && defined GNULIB_NAMESPACE
22# define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
23# define _GL_END_NAMESPACE }
24#else
25# define _GL_BEGIN_NAMESPACE
26# define _GL_END_NAMESPACE
27#endif
28
20/* The three most frequent use cases of these macros are: 29/* The three most frequent use cases of these macros are:
21 30
22 * For providing a substitute for a function that is missing on some 31 * For providing a substitute for a function that is missing on some
@@ -111,14 +120,25 @@
111 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 120 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
112 Example: 121 Example:
113 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 122 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
114 */ 123
124 Wrapping rpl_func in an object with an inline conversion operator
125 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
126 actually used in the program. */
115#define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 127#define _GL_CXXALIAS_RPL(func,rettype,parameters) \
116 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 128 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
117#if defined __cplusplus && defined GNULIB_NAMESPACE 129#if defined __cplusplus && defined GNULIB_NAMESPACE
118# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 130# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
119 namespace GNULIB_NAMESPACE \ 131 namespace GNULIB_NAMESPACE \
120 { \ 132 { \
121 rettype (*const func) parameters = ::rpl_func; \ 133 static const struct _gl_ ## func ## _wrapper \
134 { \
135 typedef rettype (*type) parameters; \
136 \
137 inline operator type () const \
138 { \
139 return ::rpl_func; \
140 } \
141 } func = {}; \
122 } \ 142 } \
123 _GL_EXTERN_C int _gl_cxxalias_dummy 143 _GL_EXTERN_C int _gl_cxxalias_dummy
124#else 144#else
@@ -126,6 +146,16 @@
126 _GL_EXTERN_C int _gl_cxxalias_dummy 146 _GL_EXTERN_C int _gl_cxxalias_dummy
127#endif 147#endif
128 148
149/* _GL_CXXALIAS_MDA (func, rettype, parameters);
150 is to be used when func is a Microsoft deprecated alias, on native Windows.
151 It declares a C++ alias called GNULIB_NAMESPACE::func
152 that redirects to _func, if GNULIB_NAMESPACE is defined.
153 Example:
154 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
155 */
156#define _GL_CXXALIAS_MDA(func,rettype,parameters) \
157 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
158
129/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 159/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
130 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 160 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
131 except that the C function rpl_func may have a slightly different 161 except that the C function rpl_func may have a slightly different
@@ -135,8 +165,15 @@
135# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 165# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
136 namespace GNULIB_NAMESPACE \ 166 namespace GNULIB_NAMESPACE \
137 { \ 167 { \
138 rettype (*const func) parameters = \ 168 static const struct _gl_ ## func ## _wrapper \
139 reinterpret_cast<rettype(*)parameters>(::rpl_func); \ 169 { \
170 typedef rettype (*type) parameters; \
171 \
172 inline operator type () const \
173 { \
174 return reinterpret_cast<type>(::rpl_func); \
175 } \
176 } func = {}; \
140 } \ 177 } \
141 _GL_EXTERN_C int _gl_cxxalias_dummy 178 _GL_EXTERN_C int _gl_cxxalias_dummy
142#else 179#else
@@ -144,25 +181,38 @@
144 _GL_EXTERN_C int _gl_cxxalias_dummy 181 _GL_EXTERN_C int _gl_cxxalias_dummy
145#endif 182#endif
146 183
184/* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
185 is like _GL_CXXALIAS_MDA (func, rettype, parameters);
186 except that the C function func may have a slightly different declaration.
187 A cast is used to silence the "invalid conversion" error that would
188 otherwise occur. */
189#define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
190 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
191
147/* _GL_CXXALIAS_SYS (func, rettype, parameters); 192/* _GL_CXXALIAS_SYS (func, rettype, parameters);
148 declares a C++ alias called GNULIB_NAMESPACE::func 193 declares a C++ alias called GNULIB_NAMESPACE::func
149 that redirects to the system provided function func, if GNULIB_NAMESPACE 194 that redirects to the system provided function func, if GNULIB_NAMESPACE
150 is defined. 195 is defined.
151 Example: 196 Example:
152 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 197 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
153 */ 198
199 Wrapping func in an object with an inline conversion operator
200 avoids a reference to func unless GNULIB_NAMESPACE::func is
201 actually used in the program. */
154#if defined __cplusplus && defined GNULIB_NAMESPACE 202#if defined __cplusplus && defined GNULIB_NAMESPACE
155 /* If we were to write 203# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
156 rettype (*const func) parameters = ::func; 204 namespace GNULIB_NAMESPACE \
157 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls 205 { \
158 better (remove an indirection through a 'static' pointer variable), 206 static const struct _gl_ ## func ## _wrapper \
159 but then the _GL_CXXALIASWARN macro below would cause a warning not only 207 { \
160 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ 208 typedef rettype (*type) parameters; \
161# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 209 \
162 namespace GNULIB_NAMESPACE \ 210 inline operator type () const \
163 { \ 211 { \
164 static rettype (*func) parameters = ::func; \ 212 return ::func; \
165 } \ 213 } \
214 } func = {}; \
215 } \
166 _GL_EXTERN_C int _gl_cxxalias_dummy 216 _GL_EXTERN_C int _gl_cxxalias_dummy
167#else 217#else
168# define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 218# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
@@ -178,8 +228,15 @@
178# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 228# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
179 namespace GNULIB_NAMESPACE \ 229 namespace GNULIB_NAMESPACE \
180 { \ 230 { \
181 static rettype (*func) parameters = \ 231 static const struct _gl_ ## func ## _wrapper \
182 reinterpret_cast<rettype(*)parameters>(::func); \ 232 { \
233 typedef rettype (*type) parameters; \
234 \
235 inline operator type () const \
236 { \
237 return reinterpret_cast<type>(::func); \
238 } \
239 } func = {}; \
183 } \ 240 } \
184 _GL_EXTERN_C int _gl_cxxalias_dummy 241 _GL_EXTERN_C int _gl_cxxalias_dummy
185#else 242#else
@@ -202,9 +259,15 @@
202# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 259# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
203 namespace GNULIB_NAMESPACE \ 260 namespace GNULIB_NAMESPACE \
204 { \ 261 { \
205 static rettype (*func) parameters = \ 262 static const struct _gl_ ## func ## _wrapper \
206 reinterpret_cast<rettype(*)parameters>( \ 263 { \
207 (rettype2(*)parameters2)(::func)); \ 264 typedef rettype (*type) parameters; \
265 \
266 inline operator type () const \
267 { \
268 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
269 } \
270 } func = {}; \
208 } \ 271 } \
209 _GL_EXTERN_C int _gl_cxxalias_dummy 272 _GL_EXTERN_C int _gl_cxxalias_dummy
210#else 273#else
@@ -221,9 +284,9 @@
221 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 284 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
222# define _GL_CXXALIASWARN_1(func,namespace) \ 285# define _GL_CXXALIASWARN_1(func,namespace) \
223 _GL_CXXALIASWARN_2 (func, namespace) 286 _GL_CXXALIASWARN_2 (func, namespace)
224/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 287/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
225 we enable the warning only when not optimizing. */ 288 we enable the warning only when not optimizing. */
226# if !__OPTIMIZE__ 289# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
227# define _GL_CXXALIASWARN_2(func,namespace) \ 290# define _GL_CXXALIASWARN_2(func,namespace) \
228 _GL_WARN_ON_USE (func, \ 291 _GL_WARN_ON_USE (func, \
229 "The symbol ::" #func " refers to the system function. " \ 292 "The symbol ::" #func " refers to the system function. " \
@@ -249,16 +312,13 @@
249 GNULIB_NAMESPACE) 312 GNULIB_NAMESPACE)
250# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 313# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
251 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 314 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
252/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 315/* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
253 we enable the warning only when not optimizing. */ 316 we enable the warning only when not optimizing. */
254# if !__OPTIMIZE__ 317# if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
255# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 318# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
256 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 319 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
257 "The symbol ::" #func " refers to the system function. " \ 320 "The symbol ::" #func " refers to the system function. " \
258 "Use " #namespace "::" #func " instead.") 321 "Use " #namespace "::" #func " instead.")
259# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
260# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
261 extern __typeof__ (func) func
262# else 322# else
263# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 323# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
264 _GL_EXTERN_C int _gl_cxxalias_dummy 324 _GL_EXTERN_C int _gl_cxxalias_dummy
diff --git a/gl/calloc.c b/gl/calloc.c
new file mode 100644
index 0000000..08843ac
--- /dev/null
+++ b/gl/calloc.c
@@ -0,0 +1,55 @@
1/* calloc() function that is glibc compatible.
2 This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
3 Copyright (C) 2004-2007, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Jim Meyering and Bruno Haible */
19
20#include <config.h>
21
22/* Specification. */
23#include <stdlib.h>
24
25#include <errno.h>
26
27#include "xalloc-oversized.h"
28
29/* Call the system's calloc below. */
30#undef calloc
31
32/* Allocate and zero-fill an NxS-byte block of memory from the heap,
33 even if N or S is zero. */
34
35void *
36rpl_calloc (size_t n, size_t s)
37{
38 if (n == 0 || s == 0)
39 n = s = 1;
40
41 if (xalloc_oversized (n, s))
42 {
43 errno = ENOMEM;
44 return NULL;
45 }
46
47 void *result = calloc (n, s);
48
49#if !HAVE_MALLOC_POSIX
50 if (result == NULL)
51 errno = ENOMEM;
52#endif
53
54 return result;
55}
diff --git a/gl/cdefs.h b/gl/cdefs.h
new file mode 100644
index 0000000..09a3d19
--- /dev/null
+++ b/gl/cdefs.h
@@ -0,0 +1,707 @@
1/* Copyright (C) 1992-2023 Free Software Foundation, Inc.
2 Copyright The GNU Toolchain Authors.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _SYS_CDEFS_H
20#define _SYS_CDEFS_H 1
21
22/* We are almost always included from features.h. */
23#ifndef _FEATURES_H
24# include <features.h>
25#endif
26
27/* The GNU libc does not support any K&R compilers or the traditional mode
28 of ISO C compilers anymore. Check for some of the combinations not
29 supported anymore. */
30#if defined __GNUC__ && !defined __STDC__
31# error "You need a ISO C conforming compiler to use the glibc headers"
32#endif
33
34/* Some user header file might have defined this before. */
35#undef __P
36#undef __PMT
37
38/* Compilers that lack __has_attribute may object to
39 #if defined __has_attribute && __has_attribute (...)
40 even though they do not need to evaluate the right-hand side of the &&.
41 Similarly for __has_builtin, etc. */
42#if (defined __has_attribute \
43 && (!defined __clang_minor__ \
44 || (defined __apple_build_version__ \
45 ? 6000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__))))
47# define __glibc_has_attribute(attr) __has_attribute (attr)
48#else
49# define __glibc_has_attribute(attr) 0
50#endif
51#ifdef __has_builtin
52# define __glibc_has_builtin(name) __has_builtin (name)
53#else
54# define __glibc_has_builtin(name) 0
55#endif
56#ifdef __has_extension
57# define __glibc_has_extension(ext) __has_extension (ext)
58#else
59# define __glibc_has_extension(ext) 0
60#endif
61
62#if defined __GNUC__ || defined __clang__
63
64/* All functions, except those with callbacks or those that
65 synchronize memory, are leaf functions. */
66# if __GNUC_PREREQ (4, 6) && !defined _LIBC
67# define __LEAF , __leaf__
68# define __LEAF_ATTR __attribute__ ((__leaf__))
69# else
70# define __LEAF
71# define __LEAF_ATTR
72# endif
73
74/* GCC can always grok prototypes. For C++ programs we add throw()
75 to help it optimize the function calls. But this only works with
76 gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
77 as non-throwing using a function attribute since programs can use
78 the -fexceptions options for C code as well. */
79# if !defined __cplusplus \
80 && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
81# define __THROW __attribute__ ((__nothrow__ __LEAF))
82# define __THROWNL __attribute__ ((__nothrow__))
83# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
84# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
85# else
86# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
87# if __cplusplus >= 201103L
88# define __THROW noexcept (true)
89# else
90# define __THROW throw ()
91# endif
92# define __THROWNL __THROW
93# define __NTH(fct) __LEAF_ATTR fct __THROW
94# define __NTHNL(fct) fct __THROW
95# else
96# define __THROW
97# define __THROWNL
98# define __NTH(fct) fct
99# define __NTHNL(fct) fct
100# endif
101# endif
102
103#else /* Not GCC or clang. */
104
105# if (defined __cplusplus \
106 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
107# define __inline inline
108# else
109# define __inline /* No inline functions. */
110# endif
111
112# define __THROW
113# define __THROWNL
114# define __NTH(fct) fct
115
116#endif /* GCC || clang. */
117
118/* These two macros are not used in glibc anymore. They are kept here
119 only because some other projects expect the macros to be defined. */
120#define __P(args) args
121#define __PMT(args) args
122
123/* For these things, GCC behaves the ANSI way normally,
124 and the non-ANSI way under -traditional. */
125
126#define __CONCAT(x,y) x ## y
127#define __STRING(x) #x
128
129/* This is not a typedef so `const __ptr_t' does the right thing. */
130#define __ptr_t void *
131
132
133/* C++ needs to know that types and declarations are C, not C++. */
134#ifdef __cplusplus
135# define __BEGIN_DECLS extern "C" {
136# define __END_DECLS }
137#else
138# define __BEGIN_DECLS
139# define __END_DECLS
140#endif
141
142
143/* Fortify support. */
144#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
145#define __bos0(ptr) __builtin_object_size (ptr, 0)
146
147/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
148#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
149 || __GNUC_PREREQ (12, 0))
150# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
151# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
152#else
153# define __glibc_objsize0(__o) __bos0 (__o)
154# define __glibc_objsize(__o) __bos (__o)
155#endif
156
157/* Compile time conditions to choose between the regular, _chk and _chk_warn
158 variants. These conditions should get evaluated to constant and optimized
159 away. */
160
161#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
162#define __glibc_unsigned_or_positive(__l) \
163 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
164 || (__builtin_constant_p (__l) && (__l) > 0))
165
166/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
167 condition can be folded to a constant and if it is true, or unknown (-1) */
168#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
169 ((__osz) == (__SIZE_TYPE__) -1 \
170 || (__glibc_unsigned_or_positive (__l) \
171 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
172 (__s), (__osz))) \
173 && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
174
175/* Conversely, we know at compile time that the length is unsafe if the
176 __L * __S <= __OBJSZ condition can be folded to a constant and if it is
177 false. */
178#define __glibc_unsafe_len(__l, __s, __osz) \
179 (__glibc_unsigned_or_positive (__l) \
180 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
181 __s, __osz)) \
182 && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
183
184/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
185 declared. */
186
187#define __glibc_fortify(f, __l, __s, __osz, ...) \
188 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
189 ? __ ## f ## _alias (__VA_ARGS__) \
190 : (__glibc_unsafe_len (__l, __s, __osz) \
191 ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
192 : __ ## f ## _chk (__VA_ARGS__, __osz))) \
193
194/* Fortify function f, where object size argument passed to f is the number of
195 elements and not total size. */
196
197#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
198 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
199 ? __ ## f ## _alias (__VA_ARGS__) \
200 : (__glibc_unsafe_len (__l, __s, __osz) \
201 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
202 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
203
204#if __GNUC_PREREQ (4,3)
205# define __warnattr(msg) __attribute__((__warning__ (msg)))
206# define __errordecl(name, msg) \
207 extern void name (void) __attribute__((__error__ (msg)))
208#else
209# define __warnattr(msg)
210# define __errordecl(name, msg) extern void name (void)
211#endif
212
213/* Support for flexible arrays.
214 Headers that should use flexible arrays only if they're "real"
215 (e.g. only if they won't affect sizeof()) should test
216 #if __glibc_c99_flexarr_available. */
217#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
218# define __flexarr []
219# define __glibc_c99_flexarr_available 1
220#elif __GNUC_PREREQ (2,97) || defined __clang__
221/* GCC 2.97 and clang support C99 flexible array members as an extension,
222 even when in C89 mode or compiling C++ (any version). */
223# define __flexarr []
224# define __glibc_c99_flexarr_available 1
225#elif defined __GNUC__
226/* Pre-2.97 GCC did not support C99 flexible arrays but did have
227 an equivalent extension with slightly different notation. */
228# define __flexarr [0]
229# define __glibc_c99_flexarr_available 1
230#else
231/* Some other non-C99 compiler. Approximate with [1]. */
232# define __flexarr [1]
233# define __glibc_c99_flexarr_available 0
234#endif
235
236
237/* __asm__ ("xyz") is used throughout the headers to rename functions
238 at the assembly language level. This is wrapped by the __REDIRECT
239 macro, in order to support compilers that can do this some other
240 way. When compilers don't support asm-names at all, we have to do
241 preprocessor tricks instead (which don't have exactly the right
242 semantics, but it's the best we can do).
243
244 Example:
245 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
246
247#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
248
249# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
250# ifdef __cplusplus
251# define __REDIRECT_NTH(name, proto, alias) \
252 name proto __THROW __asm__ (__ASMNAME (#alias))
253# define __REDIRECT_NTHNL(name, proto, alias) \
254 name proto __THROWNL __asm__ (__ASMNAME (#alias))
255# else
256# define __REDIRECT_NTH(name, proto, alias) \
257 name proto __asm__ (__ASMNAME (#alias)) __THROW
258# define __REDIRECT_NTHNL(name, proto, alias) \
259 name proto __asm__ (__ASMNAME (#alias)) __THROWNL
260# endif
261# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
262# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
263
264/*
265#elif __SOME_OTHER_COMPILER__
266
267# define __REDIRECT(name, proto, alias) name proto; \
268 _Pragma("let " #name " = " #alias)
269*/
270#endif
271
272/* GCC and clang have various useful declarations that can be made with
273 the '__attribute__' syntax. All of the ways we use this do fine if
274 they are omitted for compilers that don't understand it. */
275#if !(defined __GNUC__ || defined __clang__)
276# define __attribute__(xyz) /* Ignore */
277#endif
278
279/* At some point during the gcc 2.96 development the `malloc' attribute
280 for functions was introduced. We don't want to use it unconditionally
281 (although this would be possible) since it generates warnings. */
282#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
283# define __attribute_malloc__ __attribute__ ((__malloc__))
284#else
285# define __attribute_malloc__ /* Ignore */
286#endif
287
288/* Tell the compiler which arguments to an allocation function
289 indicate the size of the allocation. */
290#if __GNUC_PREREQ (4, 3)
291# define __attribute_alloc_size__(params) \
292 __attribute__ ((__alloc_size__ params))
293#else
294# define __attribute_alloc_size__(params) /* Ignore. */
295#endif
296
297/* Tell the compiler which argument to an allocation function
298 indicates the alignment of the allocation. */
299#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
300# define __attribute_alloc_align__(param) \
301 __attribute__ ((__alloc_align__ param))
302#else
303# define __attribute_alloc_align__(param) /* Ignore. */
304#endif
305
306/* At some point during the gcc 2.96 development the `pure' attribute
307 for functions was introduced. We don't want to use it unconditionally
308 (although this would be possible) since it generates warnings. */
309#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
310# define __attribute_pure__ __attribute__ ((__pure__))
311#else
312# define __attribute_pure__ /* Ignore */
313#endif
314
315/* This declaration tells the compiler that the value is constant. */
316#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
317# define __attribute_const__ __attribute__ ((__const__))
318#else
319# define __attribute_const__ /* Ignore */
320#endif
321
322#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
323# define __attribute_maybe_unused__ __attribute__ ((__unused__))
324#else
325# define __attribute_maybe_unused__ /* Ignore */
326#endif
327
328/* At some point during the gcc 3.1 development the `used' attribute
329 for functions was introduced. We don't want to use it unconditionally
330 (although this would be possible) since it generates warnings. */
331#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
332# define __attribute_used__ __attribute__ ((__used__))
333# define __attribute_noinline__ __attribute__ ((__noinline__))
334#else
335# define __attribute_used__ __attribute__ ((__unused__))
336# define __attribute_noinline__ /* Ignore */
337#endif
338
339/* Since version 3.2, gcc allows marking deprecated functions. */
340#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
341# define __attribute_deprecated__ __attribute__ ((__deprecated__))
342#else
343# define __attribute_deprecated__ /* Ignore */
344#endif
345
346/* Since version 4.5, gcc also allows one to specify the message printed
347 when a deprecated function is used. clang claims to be gcc 4.2, but
348 may also support this feature. */
349#if __GNUC_PREREQ (4,5) \
350 || __glibc_has_extension (__attribute_deprecated_with_message__)
351# define __attribute_deprecated_msg__(msg) \
352 __attribute__ ((__deprecated__ (msg)))
353#else
354# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
355#endif
356
357/* At some point during the gcc 2.8 development the `format_arg' attribute
358 for functions was introduced. We don't want to use it unconditionally
359 (although this would be possible) since it generates warnings.
360 If several `format_arg' attributes are given for the same function, in
361 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
362 all designated arguments are considered. */
363#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
364# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
365#else
366# define __attribute_format_arg__(x) /* Ignore */
367#endif
368
369/* At some point during the gcc 2.97 development the `strfmon' format
370 attribute for functions was introduced. We don't want to use it
371 unconditionally (although this would be possible) since it
372 generates warnings. */
373#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
374# define __attribute_format_strfmon__(a,b) \
375 __attribute__ ((__format__ (__strfmon__, a, b)))
376#else
377# define __attribute_format_strfmon__(a,b) /* Ignore */
378#endif
379
380/* The nonnull function attribute marks pointer parameters that
381 must not be NULL. This has the name __nonnull in glibc,
382 and __attribute_nonnull__ in files shared with Gnulib to avoid
383 collision with a different __nonnull in DragonFlyBSD 5.9. */
384#ifndef __attribute_nonnull__
385# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
386# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
387# else
388# define __attribute_nonnull__(params)
389# endif
390#endif
391#ifndef __nonnull
392# define __nonnull(params) __attribute_nonnull__ (params)
393#endif
394
395/* The returns_nonnull function attribute marks the return type of the function
396 as always being non-null. */
397#ifndef __returns_nonnull
398# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
399# define __returns_nonnull __attribute__ ((__returns_nonnull__))
400# else
401# define __returns_nonnull
402# endif
403#endif
404
405/* If fortification mode, we warn about unused results of certain
406 function calls which can lead to problems. */
407#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
408# define __attribute_warn_unused_result__ \
409 __attribute__ ((__warn_unused_result__))
410# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
411# define __wur __attribute_warn_unused_result__
412# endif
413#else
414# define __attribute_warn_unused_result__ /* empty */
415#endif
416#ifndef __wur
417# define __wur /* Ignore */
418#endif
419
420/* Forces a function to be always inlined. */
421#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
422/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
423 it conflicts with this definition. Therefore undefine it first to
424 allow either header to be included first. */
425# undef __always_inline
426# define __always_inline __inline __attribute__ ((__always_inline__))
427#else
428# undef __always_inline
429# define __always_inline __inline
430#endif
431
432/* Associate error messages with the source location of the call site rather
433 than with the source location inside the function. */
434#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
435# define __attribute_artificial__ __attribute__ ((__artificial__))
436#else
437# define __attribute_artificial__ /* Ignore */
438#endif
439
440/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
441 inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
442 or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
443 older than 4.3 may define these macros and still not guarantee GNU inlining
444 semantics.
445
446 clang++ identifies itself as gcc-4.2, but has support for GNU inlining
447 semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
448 __GNUC_GNU_INLINE__ macro definitions. */
449#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
450 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
451 || defined __GNUC_GNU_INLINE__)))
452# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
453# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
454# define __extern_always_inline \
455 extern __always_inline __attribute__ ((__gnu_inline__))
456# else
457# define __extern_inline extern __inline
458# define __extern_always_inline extern __always_inline
459# endif
460#endif
461
462#ifdef __extern_always_inline
463# define __fortify_function __extern_always_inline __attribute_artificial__
464#endif
465
466/* GCC 4.3 and above allow passing all anonymous arguments of an
467 __extern_always_inline function to some other vararg function. */
468#if __GNUC_PREREQ (4,3)
469# define __va_arg_pack() __builtin_va_arg_pack ()
470# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
471#endif
472
473/* It is possible to compile containing GCC extensions even if GCC is
474 run in pedantic mode if the uses are carefully marked using the
475 `__extension__' keyword. But this is not generally available before
476 version 2.8. */
477#if !(__GNUC_PREREQ (2,8) || defined __clang__)
478# define __extension__ /* Ignore */
479#endif
480
481/* __restrict is known in EGCS 1.2 and above, and in clang.
482 It works also in C++ mode (outside of arrays), but only when spelled
483 as '__restrict', not 'restrict'. */
484#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
485# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
486# define __restrict restrict
487# else
488# define __restrict /* Ignore */
489# endif
490#endif
491
492/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
493 array_name[restrict]
494 GCC 3.1 and clang support this.
495 This syntax is not usable in C++ mode. */
496#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
497# define __restrict_arr __restrict
498#else
499# ifdef __GNUC__
500# define __restrict_arr /* Not supported in old GCC. */
501# else
502# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
503# define __restrict_arr restrict
504# else
505/* Some other non-C99 compiler. */
506# define __restrict_arr /* Not supported. */
507# endif
508# endif
509#endif
510
511#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
512# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
513# define __glibc_likely(cond) __builtin_expect ((cond), 1)
514#else
515# define __glibc_unlikely(cond) (cond)
516# define __glibc_likely(cond) (cond)
517#endif
518
519#if (!defined _Noreturn \
520 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
521 && !(__GNUC_PREREQ (4,7) \
522 || (3 < __clang_major__ + (5 <= __clang_minor__))))
523# if __GNUC_PREREQ (2,8)
524# define _Noreturn __attribute__ ((__noreturn__))
525# else
526# define _Noreturn
527# endif
528#endif
529
530#if __GNUC_PREREQ (8, 0)
531/* Describes a char array whose address can safely be passed as the first
532 argument to strncpy and strncat, as the char array is not necessarily
533 a NUL-terminated string. */
534# define __attribute_nonstring__ __attribute__ ((__nonstring__))
535#else
536# define __attribute_nonstring__
537#endif
538
539/* Undefine (also defined in libc-symbols.h). */
540#undef __attribute_copy__
541#if __GNUC_PREREQ (9, 0)
542/* Copies attributes from the declaration or type referenced by
543 the argument. */
544# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
545#else
546# define __attribute_copy__(arg)
547#endif
548
549#if (!defined _Static_assert && !defined __cplusplus \
550 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
551 && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
552 || defined __STRICT_ANSI__))
553# define _Static_assert(expr, diagnostic) \
554 extern int (*__Static_assert_function (void)) \
555 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
556#endif
557
558/* Gnulib avoids including these, as they don't work on non-glibc or
559 older glibc platforms. */
560#ifndef __GNULIB_CDEFS
561# include <bits/wordsize.h>
562# include <bits/long-double.h>
563#endif
564
565#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
566# ifdef __REDIRECT
567
568/* Alias name defined automatically. */
569# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
570# define __LDBL_REDIR_DECL(name) \
571 extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
572
573/* Alias name defined automatically, with leading underscores. */
574# define __LDBL_REDIR2_DECL(name) \
575 extern __typeof (__##name) __##name \
576 __asm (__ASMNAME ("__" #name "ieee128"));
577
578/* Alias name defined manually. */
579# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
580# define __LDBL_REDIR1_DECL(name, alias) \
581 extern __typeof (name) name __asm (__ASMNAME (#alias));
582
583# define __LDBL_REDIR1_NTH(name, proto, alias) \
584 __REDIRECT_NTH (name, proto, alias)
585# define __REDIRECT_NTH_LDBL(name, proto, alias) \
586 __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
587
588/* Unused. */
589# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
590# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
591
592# else
593_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
594# endif
595#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
596# define __LDBL_COMPAT 1
597# ifdef __REDIRECT
598# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
599# define __LDBL_REDIR(name, proto) \
600 __LDBL_REDIR1 (name, proto, __nldbl_##name)
601# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
602# define __LDBL_REDIR_NTH(name, proto) \
603 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
604# define __LDBL_REDIR2_DECL(name) \
605 extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
606# define __LDBL_REDIR1_DECL(name, alias) \
607 extern __typeof (name) name __asm (__ASMNAME (#alias));
608# define __LDBL_REDIR_DECL(name) \
609 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
610# define __REDIRECT_LDBL(name, proto, alias) \
611 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
612# define __REDIRECT_NTH_LDBL(name, proto, alias) \
613 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
614# endif
615#endif
616#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
617 || !defined __REDIRECT
618# define __LDBL_REDIR1(name, proto, alias) name proto
619# define __LDBL_REDIR(name, proto) name proto
620# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
621# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
622# define __LDBL_REDIR2_DECL(name)
623# define __LDBL_REDIR_DECL(name)
624# ifdef __REDIRECT
625# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
626# define __REDIRECT_NTH_LDBL(name, proto, alias) \
627 __REDIRECT_NTH (name, proto, alias)
628# endif
629#endif
630
631/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
632 intended for use in preprocessor macros.
633
634 Note: MESSAGE must be a _single_ string; concatenation of string
635 literals is not supported. */
636#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
637# define __glibc_macro_warning1(message) _Pragma (#message)
638# define __glibc_macro_warning(message) \
639 __glibc_macro_warning1 (GCC warning message)
640#else
641# define __glibc_macro_warning(msg)
642#endif
643
644/* Generic selection (ISO C11) is a C-only feature, available in GCC
645 since version 4.9. Previous versions do not provide generic
646 selection, even though they might set __STDC_VERSION__ to 201112L,
647 when in -std=c11 mode. Thus, we must check for !defined __GNUC__
648 when testing __STDC_VERSION__ for generic selection support.
649 On the other hand, Clang also defines __GNUC__, so a clang-specific
650 check is required to enable the use of generic selection. */
651#if !defined __cplusplus \
652 && (__GNUC_PREREQ (4, 9) \
653 || __glibc_has_extension (c_generic_selections) \
654 || (!defined __GNUC__ && defined __STDC_VERSION__ \
655 && __STDC_VERSION__ >= 201112L))
656# define __HAVE_GENERIC_SELECTION 1
657#else
658# define __HAVE_GENERIC_SELECTION 0
659#endif
660
661#if __GNUC_PREREQ (10, 0)
662/* Designates a 1-based positional argument ref-index of pointer type
663 that can be used to access size-index elements of the pointed-to
664 array according to access mode, or at least one element when
665 size-index is not provided:
666 access (access-mode, <ref-index> [, <size-index>]) */
667# define __attr_access(x) __attribute__ ((__access__ x))
668/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
669 use the access attribute to get object sizes from function definition
670 arguments, so we can't use them on functions we fortify. Drop the object
671 size hints for such functions. */
672# if __USE_FORTIFY_LEVEL == 3
673# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
674# else
675# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
676# endif
677# if __GNUC_PREREQ (11, 0)
678# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
679# else
680# define __attr_access_none(argno)
681# endif
682#else
683# define __fortified_attr_access(a, o, s)
684# define __attr_access(x)
685# define __attr_access_none(argno)
686#endif
687
688#if __GNUC_PREREQ (11, 0)
689/* Designates dealloc as a function to call to deallocate objects
690 allocated by the declared function. */
691# define __attr_dealloc(dealloc, argno) \
692 __attribute__ ((__malloc__ (dealloc, argno)))
693# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
694#else
695# define __attr_dealloc(dealloc, argno)
696# define __attr_dealloc_free
697#endif
698
699/* Specify that a function such as setjmp or vfork may return
700 twice. */
701#if __GNUC_PREREQ (4, 1)
702# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
703#else
704# define __attribute_returns_twice__ /* Ignore. */
705#endif
706
707#endif /* sys/cdefs.h */
diff --git a/gl/cloexec.c b/gl/cloexec.c
new file mode 100644
index 0000000..e4cecbd
--- /dev/null
+++ b/gl/cloexec.c
@@ -0,0 +1,83 @@
1/* cloexec.c - set or clear the close-on-exec descriptor flag
2
3 Copyright (C) 1991, 2004-2006, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* The code is taken from glibc/manual/llio.texi */
19
20#include <config.h>
21
22#include "cloexec.h"
23
24#include <errno.h>
25#include <fcntl.h>
26#include <unistd.h>
27
28/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
29 or clear the flag if VALUE is false.
30 Return 0 on success, or -1 on error with 'errno' set.
31
32 Note that on MingW, this function does NOT protect DESC from being
33 inherited into spawned children. Instead, either use dup_cloexec
34 followed by closing the original DESC, or use interfaces such as
35 open or pipe2 that accept flags like O_CLOEXEC to create DESC
36 non-inheritable in the first place. */
37
38int
39set_cloexec_flag (int desc, bool value)
40{
41#ifdef F_SETFD
42
43 int flags = fcntl (desc, F_GETFD, 0);
44
45 if (0 <= flags)
46 {
47 int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
48
49 if (flags == newflags
50 || fcntl (desc, F_SETFD, newflags) != -1)
51 return 0;
52 }
53
54 return -1;
55
56#else /* !F_SETFD */
57
58 /* Use dup2 to reject invalid file descriptors; the cloexec flag
59 will be unaffected. */
60 if (desc < 0)
61 {
62 errno = EBADF;
63 return -1;
64 }
65 if (dup2 (desc, desc) < 0)
66 /* errno is EBADF here. */
67 return -1;
68
69 /* There is nothing we can do on this kind of platform. Punt. */
70 return 0;
71#endif /* !F_SETFD */
72}
73
74
75/* Duplicates a file handle FD, while marking the copy to be closed
76 prior to exec or spawn. Returns -1 and sets errno if FD could not
77 be duplicated. */
78
79int
80dup_cloexec (int fd)
81{
82 return fcntl (fd, F_DUPFD_CLOEXEC, 0);
83}
diff --git a/gl/cloexec.h b/gl/cloexec.h
new file mode 100644
index 0000000..057fd66
--- /dev/null
+++ b/gl/cloexec.h
@@ -0,0 +1,34 @@
1/* cloexec.c - set or clear the close-on-exec descriptor flag
2
3 Copyright (C) 2004, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Set the 'FD_CLOEXEC' flag of DESC if VALUE is true,
19 or clear the flag if VALUE is false.
20 Return 0 on success, or -1 on error with 'errno' set.
21
22 Note that on MingW, this function does NOT protect DESC from being
23 inherited into spawned children. Instead, either use dup_cloexec
24 followed by closing the original DESC, or use interfaces such as
25 open or pipe2 that accept flags like O_CLOEXEC to create DESC
26 non-inheritable in the first place. */
27
28int set_cloexec_flag (int desc, bool value);
29
30/* Duplicates a file handle FD, while marking the copy to be closed
31 prior to exec or spawn. Returns -1 and sets errno if FD could not
32 be duplicated. */
33
34int dup_cloexec (int fd);
diff --git a/gl/close.c b/gl/close.c
new file mode 100644
index 0000000..3c1b09e
--- /dev/null
+++ b/gl/close.c
@@ -0,0 +1,75 @@
1/* close replacement.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#include <errno.h>
23
24#include "fd-hook.h"
25#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
26# include "msvc-inval.h"
27#endif
28
29#undef close
30
31#if defined _WIN32 && !defined __CYGWIN__
32# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
33static int
34close_nothrow (int fd)
35{
36 int result;
37
38 TRY_MSVC_INVAL
39 {
40 result = _close (fd);
41 }
42 CATCH_MSVC_INVAL
43 {
44 result = -1;
45 errno = EBADF;
46 }
47 DONE_MSVC_INVAL;
48
49 return result;
50}
51# else
52# define close_nothrow _close
53# endif
54#else
55# define close_nothrow close
56#endif
57
58/* Override close() to call into other gnulib modules. */
59
60int
61rpl_close (int fd)
62{
63#if WINDOWS_SOCKETS
64 int retval = execute_all_close_hooks (close_nothrow, fd);
65#else
66 int retval = close_nothrow (fd);
67#endif
68
69#if REPLACE_FCHDIR
70 if (retval >= 0)
71 _gl_unregister_fd (fd);
72#endif
73
74 return retval;
75}
diff --git a/gl/config.charset b/gl/config.charset
deleted file mode 100644
index a991419..0000000
--- a/gl/config.charset
+++ /dev/null
@@ -1,684 +0,0 @@
1#! /bin/sh
2# Output a system dependent table of character encoding aliases.
3#
4# Copyright (C) 2000-2004, 2006-2013 Free Software Foundation, Inc.
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3, or (at your option)
9# any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, see <http://www.gnu.org/licenses/>.
18#
19# The table consists of lines of the form
20# ALIAS CANONICAL
21#
22# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
23# ALIAS is compared in a case sensitive way.
24#
25# CANONICAL is the GNU canonical name for this character encoding.
26# It must be an encoding supported by libiconv. Support by GNU libc is
27# also desirable. CANONICAL is case insensitive. Usually an upper case
28# MIME charset name is preferred.
29# The current list of GNU canonical charset names is as follows.
30#
31# name MIME? used by which systems
32# (darwin = Mac OS X, woe32 = native Windows)
33#
34# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
35# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
36# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
37# ISO-8859-3 Y glibc solaris cygwin
38# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
39# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
40# ISO-8859-6 Y glibc aix hpux solaris cygwin
41# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
42# ISO-8859-8 Y glibc aix hpux osf solaris cygwin
43# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin
44# ISO-8859-13 glibc netbsd openbsd darwin cygwin
45# ISO-8859-14 glibc cygwin
46# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
47# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
48# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
49# KOI8-T glibc
50# CP437 dos
51# CP775 dos
52# CP850 aix osf dos
53# CP852 dos
54# CP855 dos
55# CP856 aix
56# CP857 dos
57# CP861 dos
58# CP862 dos
59# CP864 dos
60# CP865 dos
61# CP866 freebsd netbsd openbsd darwin dos
62# CP869 dos
63# CP874 woe32 dos
64# CP922 aix
65# CP932 aix cygwin woe32 dos
66# CP943 aix
67# CP949 osf darwin woe32 dos
68# CP950 woe32 dos
69# CP1046 aix
70# CP1124 aix
71# CP1125 dos
72# CP1129 aix
73# CP1131 darwin
74# CP1250 woe32
75# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32
76# CP1252 aix woe32
77# CP1253 woe32
78# CP1254 woe32
79# CP1255 glibc woe32
80# CP1256 woe32
81# CP1257 woe32
82# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
83# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
84# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
85# EUC-TW glibc aix hpux irix osf solaris netbsd
86# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
87# BIG5-HKSCS glibc solaris darwin
88# GBK glibc aix osf solaris darwin cygwin woe32 dos
89# GB18030 glibc solaris netbsd darwin
90# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
91# JOHAB glibc solaris woe32
92# TIS-620 glibc aix hpux osf solaris cygwin
93# VISCII Y glibc
94# TCVN5712-1 glibc
95# ARMSCII-8 glibc darwin
96# GEORGIAN-PS glibc cygwin
97# PT154 glibc
98# HP-ROMAN8 hpux
99# HP-ARABIC8 hpux
100# HP-GREEK8 hpux
101# HP-HEBREW8 hpux
102# HP-TURKISH8 hpux
103# HP-KANA8 hpux
104# DEC-KANJI osf
105# DEC-HANYU osf
106# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
107#
108# Note: Names which are not marked as being a MIME name should not be used in
109# Internet protocols for information interchange (mail, news, etc.).
110#
111# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
112# must understand both names and treat them as equivalent.
113#
114# The first argument passed to this file is the canonical host specification,
115# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
116# or
117# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
118
119host="$1"
120os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
121echo "# This file contains a table of character encoding aliases,"
122echo "# suitable for operating system '${os}'."
123echo "# It was automatically generated from config.charset."
124# List of references, updated during installation:
125echo "# Packages using this file: "
126case "$os" in
127 linux-gnulibc1*)
128 # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
129 # localcharset.c falls back to using the full locale name
130 # from the environment variables.
131 echo "C ASCII"
132 echo "POSIX ASCII"
133 for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
134 en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
135 en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
136 es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
137 et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
138 fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
139 it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
140 sv_FI sv_SE; do
141 echo "$l ISO-8859-1"
142 echo "$l.iso-8859-1 ISO-8859-1"
143 echo "$l.iso-8859-15 ISO-8859-15"
144 echo "$l.iso-8859-15@euro ISO-8859-15"
145 echo "$l@euro ISO-8859-15"
146 echo "$l.cp-437 CP437"
147 echo "$l.cp-850 CP850"
148 echo "$l.cp-1252 CP1252"
149 echo "$l.cp-1252@euro CP1252"
150 #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
151 echo "$l.utf-8 UTF-8"
152 echo "$l.utf-8@euro UTF-8"
153 done
154 for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
155 sl_SI sr sr_CS sr_YU; do
156 echo "$l ISO-8859-2"
157 echo "$l.iso-8859-2 ISO-8859-2"
158 echo "$l.cp-852 CP852"
159 echo "$l.cp-1250 CP1250"
160 echo "$l.utf-8 UTF-8"
161 done
162 for l in mk mk_MK ru ru_RU; do
163 echo "$l ISO-8859-5"
164 echo "$l.iso-8859-5 ISO-8859-5"
165 echo "$l.koi8-r KOI8-R"
166 echo "$l.cp-866 CP866"
167 echo "$l.cp-1251 CP1251"
168 echo "$l.utf-8 UTF-8"
169 done
170 for l in ar ar_SA; do
171 echo "$l ISO-8859-6"
172 echo "$l.iso-8859-6 ISO-8859-6"
173 echo "$l.cp-864 CP864"
174 #echo "$l.cp-868 CP868" # not a commonly used encoding
175 echo "$l.cp-1256 CP1256"
176 echo "$l.utf-8 UTF-8"
177 done
178 for l in el el_GR gr gr_GR; do
179 echo "$l ISO-8859-7"
180 echo "$l.iso-8859-7 ISO-8859-7"
181 echo "$l.cp-869 CP869"
182 echo "$l.cp-1253 CP1253"
183 echo "$l.cp-1253@euro CP1253"
184 echo "$l.utf-8 UTF-8"
185 echo "$l.utf-8@euro UTF-8"
186 done
187 for l in he he_IL iw iw_IL; do
188 echo "$l ISO-8859-8"
189 echo "$l.iso-8859-8 ISO-8859-8"
190 echo "$l.cp-862 CP862"
191 echo "$l.cp-1255 CP1255"
192 echo "$l.utf-8 UTF-8"
193 done
194 for l in tr tr_TR; do
195 echo "$l ISO-8859-9"
196 echo "$l.iso-8859-9 ISO-8859-9"
197 echo "$l.cp-857 CP857"
198 echo "$l.cp-1254 CP1254"
199 echo "$l.utf-8 UTF-8"
200 done
201 for l in lt lt_LT lv lv_LV; do
202 #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
203 echo "$l ISO-8859-13"
204 done
205 for l in ru_UA uk uk_UA; do
206 echo "$l KOI8-U"
207 done
208 for l in zh zh_CN; do
209 #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
210 echo "$l GB2312"
211 done
212 for l in ja ja_JP ja_JP.EUC; do
213 echo "$l EUC-JP"
214 done
215 for l in ko ko_KR; do
216 echo "$l EUC-KR"
217 done
218 for l in th th_TH; do
219 echo "$l TIS-620"
220 done
221 for l in fa fa_IR; do
222 #echo "$l ISIRI-3342" # a broken encoding
223 echo "$l.utf-8 UTF-8"
224 done
225 ;;
226 linux* | *-gnu*)
227 # With glibc-2.1 or newer, we don't need any canonicalization,
228 # because glibc has iconv and both glibc and libiconv support all
229 # GNU canonical names directly. Therefore, the Makefile does not
230 # need to install the alias file at all.
231 # The following applies only to glibc-2.0.x and older libcs.
232 echo "ISO_646.IRV:1983 ASCII"
233 ;;
234 aix*)
235 echo "ISO8859-1 ISO-8859-1"
236 echo "ISO8859-2 ISO-8859-2"
237 echo "ISO8859-5 ISO-8859-5"
238 echo "ISO8859-6 ISO-8859-6"
239 echo "ISO8859-7 ISO-8859-7"
240 echo "ISO8859-8 ISO-8859-8"
241 echo "ISO8859-9 ISO-8859-9"
242 echo "ISO8859-15 ISO-8859-15"
243 echo "IBM-850 CP850"
244 echo "IBM-856 CP856"
245 echo "IBM-921 ISO-8859-13"
246 echo "IBM-922 CP922"
247 echo "IBM-932 CP932"
248 echo "IBM-943 CP943"
249 echo "IBM-1046 CP1046"
250 echo "IBM-1124 CP1124"
251 echo "IBM-1129 CP1129"
252 echo "IBM-1252 CP1252"
253 echo "IBM-eucCN GB2312"
254 echo "IBM-eucJP EUC-JP"
255 echo "IBM-eucKR EUC-KR"
256 echo "IBM-eucTW EUC-TW"
257 echo "big5 BIG5"
258 echo "GBK GBK"
259 echo "TIS-620 TIS-620"
260 echo "UTF-8 UTF-8"
261 ;;
262 hpux*)
263 echo "iso88591 ISO-8859-1"
264 echo "iso88592 ISO-8859-2"
265 echo "iso88595 ISO-8859-5"
266 echo "iso88596 ISO-8859-6"
267 echo "iso88597 ISO-8859-7"
268 echo "iso88598 ISO-8859-8"
269 echo "iso88599 ISO-8859-9"
270 echo "iso885915 ISO-8859-15"
271 echo "roman8 HP-ROMAN8"
272 echo "arabic8 HP-ARABIC8"
273 echo "greek8 HP-GREEK8"
274 echo "hebrew8 HP-HEBREW8"
275 echo "turkish8 HP-TURKISH8"
276 echo "kana8 HP-KANA8"
277 echo "tis620 TIS-620"
278 echo "big5 BIG5"
279 echo "eucJP EUC-JP"
280 echo "eucKR EUC-KR"
281 echo "eucTW EUC-TW"
282 echo "hp15CN GB2312"
283 #echo "ccdc ?" # what is this?
284 echo "SJIS SHIFT_JIS"
285 echo "utf8 UTF-8"
286 ;;
287 irix*)
288 echo "ISO8859-1 ISO-8859-1"
289 echo "ISO8859-2 ISO-8859-2"
290 echo "ISO8859-5 ISO-8859-5"
291 echo "ISO8859-7 ISO-8859-7"
292 echo "ISO8859-9 ISO-8859-9"
293 echo "eucCN GB2312"
294 echo "eucJP EUC-JP"
295 echo "eucKR EUC-KR"
296 echo "eucTW EUC-TW"
297 ;;
298 osf*)
299 echo "ISO8859-1 ISO-8859-1"
300 echo "ISO8859-2 ISO-8859-2"
301 echo "ISO8859-4 ISO-8859-4"
302 echo "ISO8859-5 ISO-8859-5"
303 echo "ISO8859-7 ISO-8859-7"
304 echo "ISO8859-8 ISO-8859-8"
305 echo "ISO8859-9 ISO-8859-9"
306 echo "ISO8859-15 ISO-8859-15"
307 echo "cp850 CP850"
308 echo "big5 BIG5"
309 echo "dechanyu DEC-HANYU"
310 echo "dechanzi GB2312"
311 echo "deckanji DEC-KANJI"
312 echo "deckorean EUC-KR"
313 echo "eucJP EUC-JP"
314 echo "eucKR EUC-KR"
315 echo "eucTW EUC-TW"
316 echo "GBK GBK"
317 echo "KSC5601 CP949"
318 echo "sdeckanji EUC-JP"
319 echo "SJIS SHIFT_JIS"
320 echo "TACTIS TIS-620"
321 echo "UTF-8 UTF-8"
322 ;;
323 solaris*)
324 echo "646 ASCII"
325 echo "ISO8859-1 ISO-8859-1"
326 echo "ISO8859-2 ISO-8859-2"
327 echo "ISO8859-3 ISO-8859-3"
328 echo "ISO8859-4 ISO-8859-4"
329 echo "ISO8859-5 ISO-8859-5"
330 echo "ISO8859-6 ISO-8859-6"
331 echo "ISO8859-7 ISO-8859-7"
332 echo "ISO8859-8 ISO-8859-8"
333 echo "ISO8859-9 ISO-8859-9"
334 echo "ISO8859-15 ISO-8859-15"
335 echo "koi8-r KOI8-R"
336 echo "ansi-1251 CP1251"
337 echo "BIG5 BIG5"
338 echo "Big5-HKSCS BIG5-HKSCS"
339 echo "gb2312 GB2312"
340 echo "GBK GBK"
341 echo "GB18030 GB18030"
342 echo "cns11643 EUC-TW"
343 echo "5601 EUC-KR"
344 echo "ko_KR.johap92 JOHAB"
345 echo "eucJP EUC-JP"
346 echo "PCK SHIFT_JIS"
347 echo "TIS620.2533 TIS-620"
348 #echo "sun_eu_greek ?" # what is this?
349 echo "UTF-8 UTF-8"
350 ;;
351 freebsd* | os2*)
352 # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
353 # localcharset.c falls back to using the full locale name
354 # from the environment variables.
355 # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
356 # reuse FreeBSD's locale data for OS/2.
357 echo "C ASCII"
358 echo "US-ASCII ASCII"
359 for l in la_LN lt_LN; do
360 echo "$l.ASCII ASCII"
361 done
362 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
363 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
364 lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
365 echo "$l.ISO_8859-1 ISO-8859-1"
366 echo "$l.DIS_8859-15 ISO-8859-15"
367 done
368 for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
369 echo "$l.ISO_8859-2 ISO-8859-2"
370 done
371 for l in la_LN lt_LT; do
372 echo "$l.ISO_8859-4 ISO-8859-4"
373 done
374 for l in ru_RU ru_SU; do
375 echo "$l.KOI8-R KOI8-R"
376 echo "$l.ISO_8859-5 ISO-8859-5"
377 echo "$l.CP866 CP866"
378 done
379 echo "uk_UA.KOI8-U KOI8-U"
380 echo "zh_TW.BIG5 BIG5"
381 echo "zh_TW.Big5 BIG5"
382 echo "zh_CN.EUC GB2312"
383 echo "ja_JP.EUC EUC-JP"
384 echo "ja_JP.SJIS SHIFT_JIS"
385 echo "ja_JP.Shift_JIS SHIFT_JIS"
386 echo "ko_KR.EUC EUC-KR"
387 ;;
388 netbsd*)
389 echo "646 ASCII"
390 echo "ISO8859-1 ISO-8859-1"
391 echo "ISO8859-2 ISO-8859-2"
392 echo "ISO8859-4 ISO-8859-4"
393 echo "ISO8859-5 ISO-8859-5"
394 echo "ISO8859-7 ISO-8859-7"
395 echo "ISO8859-13 ISO-8859-13"
396 echo "ISO8859-15 ISO-8859-15"
397 echo "eucCN GB2312"
398 echo "eucJP EUC-JP"
399 echo "eucKR EUC-KR"
400 echo "eucTW EUC-TW"
401 echo "BIG5 BIG5"
402 echo "SJIS SHIFT_JIS"
403 ;;
404 openbsd*)
405 echo "646 ASCII"
406 echo "ISO8859-1 ISO-8859-1"
407 echo "ISO8859-2 ISO-8859-2"
408 echo "ISO8859-4 ISO-8859-4"
409 echo "ISO8859-5 ISO-8859-5"
410 echo "ISO8859-7 ISO-8859-7"
411 echo "ISO8859-13 ISO-8859-13"
412 echo "ISO8859-15 ISO-8859-15"
413 ;;
414 darwin[56]*)
415 # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
416 # localcharset.c falls back to using the full locale name
417 # from the environment variables.
418 echo "C ASCII"
419 for l in en_AU en_CA en_GB en_US la_LN; do
420 echo "$l.US-ASCII ASCII"
421 done
422 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
423 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
424 nl_NL no_NO pt_PT sv_SE; do
425 echo "$l ISO-8859-1"
426 echo "$l.ISO8859-1 ISO-8859-1"
427 echo "$l.ISO8859-15 ISO-8859-15"
428 done
429 for l in la_LN; do
430 echo "$l.ISO8859-1 ISO-8859-1"
431 echo "$l.ISO8859-15 ISO-8859-15"
432 done
433 for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
434 echo "$l.ISO8859-2 ISO-8859-2"
435 done
436 for l in la_LN lt_LT; do
437 echo "$l.ISO8859-4 ISO-8859-4"
438 done
439 for l in ru_RU; do
440 echo "$l.KOI8-R KOI8-R"
441 echo "$l.ISO8859-5 ISO-8859-5"
442 echo "$l.CP866 CP866"
443 done
444 for l in bg_BG; do
445 echo "$l.CP1251 CP1251"
446 done
447 echo "uk_UA.KOI8-U KOI8-U"
448 echo "zh_TW.BIG5 BIG5"
449 echo "zh_TW.Big5 BIG5"
450 echo "zh_CN.EUC GB2312"
451 echo "ja_JP.EUC EUC-JP"
452 echo "ja_JP.SJIS SHIFT_JIS"
453 echo "ko_KR.EUC EUC-KR"
454 ;;
455 darwin*)
456 # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
457 # useless:
458 # - It returns the empty string when LANG is set to a locale of the
459 # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
460 # LC_CTYPE file.
461 # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
462 # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
463 # - The documentation says:
464 # "... all code that calls BSD system routines should ensure
465 # that the const *char parameters of these routines are in UTF-8
466 # encoding. All BSD system functions expect their string
467 # parameters to be in UTF-8 encoding and nothing else."
468 # It also says
469 # "An additional caveat is that string parameters for files,
470 # paths, and other file-system entities must be in canonical
471 # UTF-8. In a canonical UTF-8 Unicode string, all decomposable
472 # characters are decomposed ..."
473 # but this is not true: You can pass non-decomposed UTF-8 strings
474 # to file system functions, and it is the OS which will convert
475 # them to decomposed UTF-8 before accessing the file system.
476 # - The Apple Terminal application displays UTF-8 by default.
477 # - However, other applications are free to use different encodings:
478 # - xterm uses ISO-8859-1 by default.
479 # - TextEdit uses MacRoman by default.
480 # We prefer UTF-8 over decomposed UTF-8-MAC because one should
481 # minimize the use of decomposed Unicode. Unfortunately, through the
482 # Darwin file system, decomposed UTF-8 strings are leaked into user
483 # space nevertheless.
484 # Then there are also the locales with encodings other than US-ASCII
485 # and UTF-8. These locales can be occasionally useful to users (e.g.
486 # when grepping through ISO-8859-1 encoded text files), when all their
487 # file names are in US-ASCII.
488 echo "ISO8859-1 ISO-8859-1"
489 echo "ISO8859-2 ISO-8859-2"
490 echo "ISO8859-4 ISO-8859-4"
491 echo "ISO8859-5 ISO-8859-5"
492 echo "ISO8859-7 ISO-8859-7"
493 echo "ISO8859-9 ISO-8859-9"
494 echo "ISO8859-13 ISO-8859-13"
495 echo "ISO8859-15 ISO-8859-15"
496 echo "KOI8-R KOI8-R"
497 echo "KOI8-U KOI8-U"
498 echo "CP866 CP866"
499 echo "CP949 CP949"
500 echo "CP1131 CP1131"
501 echo "CP1251 CP1251"
502 echo "eucCN GB2312"
503 echo "GB2312 GB2312"
504 echo "eucJP EUC-JP"
505 echo "eucKR EUC-KR"
506 echo "Big5 BIG5"
507 echo "Big5HKSCS BIG5-HKSCS"
508 echo "GBK GBK"
509 echo "GB18030 GB18030"
510 echo "SJIS SHIFT_JIS"
511 echo "ARMSCII-8 ARMSCII-8"
512 echo "PT154 PT154"
513 #echo "ISCII-DEV ?"
514 echo "* UTF-8"
515 ;;
516 beos* | haiku*)
517 # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
518 echo "* UTF-8"
519 ;;
520 msdosdjgpp*)
521 # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
522 # localcharset.c falls back to using the full locale name
523 # from the environment variables.
524 echo "#"
525 echo "# The encodings given here may not all be correct."
526 echo "# If you find that the encoding given for your language and"
527 echo "# country is not the one your DOS machine actually uses, just"
528 echo "# correct it in this file, and send a mail to"
529 echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
530 echo "# and Bruno Haible <bruno@clisp.org>."
531 echo "#"
532 echo "C ASCII"
533 # ISO-8859-1 languages
534 echo "ca CP850"
535 echo "ca_ES CP850"
536 echo "da CP865" # not CP850 ??
537 echo "da_DK CP865" # not CP850 ??
538 echo "de CP850"
539 echo "de_AT CP850"
540 echo "de_CH CP850"
541 echo "de_DE CP850"
542 echo "en CP850"
543 echo "en_AU CP850" # not CP437 ??
544 echo "en_CA CP850"
545 echo "en_GB CP850"
546 echo "en_NZ CP437"
547 echo "en_US CP437"
548 echo "en_ZA CP850" # not CP437 ??
549 echo "es CP850"
550 echo "es_AR CP850"
551 echo "es_BO CP850"
552 echo "es_CL CP850"
553 echo "es_CO CP850"
554 echo "es_CR CP850"
555 echo "es_CU CP850"
556 echo "es_DO CP850"
557 echo "es_EC CP850"
558 echo "es_ES CP850"
559 echo "es_GT CP850"
560 echo "es_HN CP850"
561 echo "es_MX CP850"
562 echo "es_NI CP850"
563 echo "es_PA CP850"
564 echo "es_PY CP850"
565 echo "es_PE CP850"
566 echo "es_SV CP850"
567 echo "es_UY CP850"
568 echo "es_VE CP850"
569 echo "et CP850"
570 echo "et_EE CP850"
571 echo "eu CP850"
572 echo "eu_ES CP850"
573 echo "fi CP850"
574 echo "fi_FI CP850"
575 echo "fr CP850"
576 echo "fr_BE CP850"
577 echo "fr_CA CP850"
578 echo "fr_CH CP850"
579 echo "fr_FR CP850"
580 echo "ga CP850"
581 echo "ga_IE CP850"
582 echo "gd CP850"
583 echo "gd_GB CP850"
584 echo "gl CP850"
585 echo "gl_ES CP850"
586 echo "id CP850" # not CP437 ??
587 echo "id_ID CP850" # not CP437 ??
588 echo "is CP861" # not CP850 ??
589 echo "is_IS CP861" # not CP850 ??
590 echo "it CP850"
591 echo "it_CH CP850"
592 echo "it_IT CP850"
593 echo "lt CP775"
594 echo "lt_LT CP775"
595 echo "lv CP775"
596 echo "lv_LV CP775"
597 echo "nb CP865" # not CP850 ??
598 echo "nb_NO CP865" # not CP850 ??
599 echo "nl CP850"
600 echo "nl_BE CP850"
601 echo "nl_NL CP850"
602 echo "nn CP865" # not CP850 ??
603 echo "nn_NO CP865" # not CP850 ??
604 echo "no CP865" # not CP850 ??
605 echo "no_NO CP865" # not CP850 ??
606 echo "pt CP850"
607 echo "pt_BR CP850"
608 echo "pt_PT CP850"
609 echo "sv CP850"
610 echo "sv_SE CP850"
611 # ISO-8859-2 languages
612 echo "cs CP852"
613 echo "cs_CZ CP852"
614 echo "hr CP852"
615 echo "hr_HR CP852"
616 echo "hu CP852"
617 echo "hu_HU CP852"
618 echo "pl CP852"
619 echo "pl_PL CP852"
620 echo "ro CP852"
621 echo "ro_RO CP852"
622 echo "sk CP852"
623 echo "sk_SK CP852"
624 echo "sl CP852"
625 echo "sl_SI CP852"
626 echo "sq CP852"
627 echo "sq_AL CP852"
628 echo "sr CP852" # CP852 or CP866 or CP855 ??
629 echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
630 echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
631 # ISO-8859-3 languages
632 echo "mt CP850"
633 echo "mt_MT CP850"
634 # ISO-8859-5 languages
635 echo "be CP866"
636 echo "be_BE CP866"
637 echo "bg CP866" # not CP855 ??
638 echo "bg_BG CP866" # not CP855 ??
639 echo "mk CP866" # not CP855 ??
640 echo "mk_MK CP866" # not CP855 ??
641 echo "ru CP866"
642 echo "ru_RU CP866"
643 echo "uk CP1125"
644 echo "uk_UA CP1125"
645 # ISO-8859-6 languages
646 echo "ar CP864"
647 echo "ar_AE CP864"
648 echo "ar_DZ CP864"
649 echo "ar_EG CP864"
650 echo "ar_IQ CP864"
651 echo "ar_IR CP864"
652 echo "ar_JO CP864"
653 echo "ar_KW CP864"
654 echo "ar_MA CP864"
655 echo "ar_OM CP864"
656 echo "ar_QA CP864"
657 echo "ar_SA CP864"
658 echo "ar_SY CP864"
659 # ISO-8859-7 languages
660 echo "el CP869"
661 echo "el_GR CP869"
662 # ISO-8859-8 languages
663 echo "he CP862"
664 echo "he_IL CP862"
665 # ISO-8859-9 languages
666 echo "tr CP857"
667 echo "tr_TR CP857"
668 # Japanese
669 echo "ja CP932"
670 echo "ja_JP CP932"
671 # Chinese
672 echo "zh_CN GBK"
673 echo "zh_TW CP950" # not CP938 ??
674 # Korean
675 echo "kr CP949" # not CP934 ??
676 echo "kr_KR CP949" # not CP934 ??
677 # Thai
678 echo "th CP874"
679 echo "th_TH CP874"
680 # Other
681 echo "eo CP850"
682 echo "eo_EO CP850"
683 ;;
684esac
diff --git a/gl/dirname-lgpl.c b/gl/dirname-lgpl.c
index 82f6630..e9454af 100644
--- a/gl/dirname-lgpl.c
+++ b/gl/dirname-lgpl.c
@@ -1,20 +1,20 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/dirname.c b/gl/dirname.c
index 1fb6588..e72f713 100644
--- a/gl/dirname.c
+++ b/gl/dirname.c
@@ -1,11 +1,11 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/dirname.h b/gl/dirname.h
index 4ad0312..f98e83b 100644
--- a/gl/dirname.h
+++ b/gl/dirname.h
@@ -1,46 +1,53 @@
1/* Take file names apart into directory and base names. 1/* Take file names apart into directory and base names.
2 2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation, 3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef DIRNAME_H_ 19#ifndef DIRNAME_H_
20# define DIRNAME_H_ 1 20# define DIRNAME_H_ 1
21 21
22# include <stdbool.h> 22# include <stdlib.h>
23# include <stddef.h> 23# include "filename.h"
24# include "dosname.h" 24# include "basename-lgpl.h"
25 25
26# ifndef DIRECTORY_SEPARATOR 26# ifndef DIRECTORY_SEPARATOR
27# define DIRECTORY_SEPARATOR '/' 27# define DIRECTORY_SEPARATOR '/'
28# endif 28# endif
29 29
30# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT 30#ifdef __cplusplus
31# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 31extern "C" {
32# endif 32#endif
33 33
34# if GNULIB_DIRNAME 34# if GNULIB_DIRNAME
35char *base_name (char const *file); 35char *base_name (char const *file)
36char *dir_name (char const *file); 36 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
37 _GL_ATTRIBUTE_RETURNS_NONNULL;
38char *dir_name (char const *file)
39 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
40 _GL_ATTRIBUTE_RETURNS_NONNULL;
37# endif 41# endif
38 42
39char *mdir_name (char const *file); 43char *mdir_name (char const *file)
40size_t base_len (char const *file) _GL_ATTRIBUTE_PURE; 44 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
41size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE; 45size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
42char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
43 46
44bool strip_trailing_slashes (char *file); 47bool strip_trailing_slashes (char *file);
45 48
49#ifdef __cplusplus
50} /* extern "C" */
51#endif
52
46#endif /* not DIRNAME_H_ */ 53#endif /* not DIRNAME_H_ */
diff --git a/gl/dosname.h b/gl/dosname.h
deleted file mode 100644
index ba63ce4..0000000
--- a/gl/dosname.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/* File names on MS-DOS/Windows systems.
2
3 Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 From Paul Eggert and Jim Meyering. */
19
20#ifndef _DOSNAME_H
21#define _DOSNAME_H
22
23#if (defined _WIN32 || defined __WIN32__ || \
24 defined __MSDOS__ || defined __CYGWIN__ || \
25 defined __EMX__ || defined __DJGPP__)
26 /* This internal macro assumes ASCII, but all hosts that support drive
27 letters use ASCII. */
28# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
29 <= 'z' - 'a')
30# define FILE_SYSTEM_PREFIX_LEN(Filename) \
31 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
32# ifndef __CYGWIN__
33# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
34# endif
35# define ISSLASH(C) ((C) == '/' || (C) == '\\')
36#else
37# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
38# define ISSLASH(C) ((C) == '/')
39#endif
40
41#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
42# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
43#endif
44
45#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
46# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
47# else
48# define IS_ABSOLUTE_FILE_NAME(F) \
49 (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
50#endif
51#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
52
53#endif /* DOSNAME_H_ */
diff --git a/gl/dup2.c b/gl/dup2.c
new file mode 100644
index 0000000..7d197ca
--- /dev/null
+++ b/gl/dup2.c
@@ -0,0 +1,189 @@
1/* Duplicate an open file descriptor to a specified file descriptor.
2
3 Copyright (C) 1999, 2004-2007, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#include <config.h>
21
22/* Specification. */
23#include <unistd.h>
24
25#include <errno.h>
26#include <fcntl.h>
27
28#undef dup2
29
30#if defined _WIN32 && ! defined __CYGWIN__
31
32/* Get declarations of the native Windows API functions. */
33# define WIN32_LEAN_AND_MEAN
34# include <windows.h>
35
36# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
37# include "msvc-inval.h"
38# endif
39
40/* Get _get_osfhandle. */
41# if GNULIB_MSVC_NOTHROW
42# include "msvc-nothrow.h"
43# else
44# include <io.h>
45# endif
46
47# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
48static int
49dup2_nothrow (int fd, int desired_fd)
50{
51 int result;
52
53 TRY_MSVC_INVAL
54 {
55 result = _dup2 (fd, desired_fd);
56 }
57 CATCH_MSVC_INVAL
58 {
59 errno = EBADF;
60 result = -1;
61 }
62 DONE_MSVC_INVAL;
63
64 return result;
65}
66# else
67# define dup2_nothrow _dup2
68# endif
69
70static int
71ms_windows_dup2 (int fd, int desired_fd)
72{
73 int result;
74
75 /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
76 dup2 (fd, fd) returns 0, but all further attempts to use fd in
77 future dup2 calls will hang. */
78 if (fd == desired_fd)
79 {
80 if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
81 {
82 errno = EBADF;
83 return -1;
84 }
85 return fd;
86 }
87
88 /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
89 https://bugs.winehq.org/show_bug.cgi?id=21289 */
90 if (desired_fd < 0)
91 {
92 errno = EBADF;
93 return -1;
94 }
95
96 result = dup2_nothrow (fd, desired_fd);
97
98 if (result == 0)
99 result = desired_fd;
100
101 return result;
102}
103
104# define dup2 ms_windows_dup2
105
106#elif defined __KLIBC__
107
108# include <InnoTekLIBC/backend.h>
109
110static int
111klibc_dup2dirfd (int fd, int desired_fd)
112{
113 int tempfd;
114 int dupfd;
115
116 tempfd = open ("NUL", O_RDONLY);
117 if (tempfd == -1)
118 return -1;
119
120 if (tempfd == desired_fd)
121 {
122 close (tempfd);
123
124 char path[_MAX_PATH];
125 if (__libc_Back_ioFHToPath (fd, path, sizeof (path)))
126 return -1;
127
128 return open(path, O_RDONLY);
129 }
130
131 dupfd = klibc_dup2dirfd (fd, desired_fd);
132
133 close (tempfd);
134
135 return dupfd;
136}
137
138static int
139klibc_dup2 (int fd, int desired_fd)
140{
141 int dupfd;
142 struct stat sbuf;
143
144 dupfd = dup2 (fd, desired_fd);
145 if (dupfd == -1 && errno == ENOTSUP \
146 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
147 {
148 close (desired_fd);
149
150 return klibc_dup2dirfd (fd, desired_fd);
151 }
152
153 return dupfd;
154}
155
156# define dup2 klibc_dup2
157#endif
158
159int
160rpl_dup2 (int fd, int desired_fd)
161{
162 int result;
163
164#ifdef F_GETFL
165 /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
166 On Cygwin 1.5.x, dup2 (1, 1) returns 0.
167 On Cygwin 1.7.17, dup2 (1, -1) dumps core.
168 On Cygwin 1.7.25, dup2 (1, 256) can dump core.
169 On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC. */
170# if HAVE_SETDTABLESIZE
171 setdtablesize (desired_fd + 1);
172# endif
173 if (desired_fd < 0)
174 fd = desired_fd;
175 if (fd == desired_fd)
176 return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
177#endif
178
179 result = dup2 (fd, desired_fd);
180
181 /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x. */
182 if (result == -1 && errno == EMFILE)
183 errno = EBADF;
184#if REPLACE_FCHDIR
185 if (fd != desired_fd && result != -1)
186 result = _gl_register_dup (fd, result);
187#endif
188 return result;
189}
diff --git a/gl/dynarray.h b/gl/dynarray.h
new file mode 100644
index 0000000..9155910
--- /dev/null
+++ b/gl/dynarray.h
@@ -0,0 +1,284 @@
1/* Type-safe arrays which grow dynamically.
2 Copyright 2021-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Paul Eggert and Bruno Haible, 2021. */
18
19#ifndef _GL_DYNARRAY_H
20#define _GL_DYNARRAY_H
21
22/* Before including this file, you need to define:
23
24 DYNARRAY_STRUCT
25 The struct tag of dynamic array to be defined.
26
27 DYNARRAY_ELEMENT
28 The type name of the element type. Elements are copied
29 as if by memcpy, and can change address as the dynamic
30 array grows.
31
32 DYNARRAY_PREFIX
33 The prefix of the functions which are defined.
34
35 The following parameters are optional:
36
37 DYNARRAY_ELEMENT_FREE
38 DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
39 contents of elements. E is of type DYNARRAY_ELEMENT *.
40
41 DYNARRAY_ELEMENT_INIT
42 DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
43 element. E is of type DYNARRAY_ELEMENT *.
44 If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
45 defined, new elements are automatically zero-initialized.
46 Otherwise, new elements have undefined contents.
47
48 DYNARRAY_INITIAL_SIZE
49 The size of the statically allocated array (default:
50 at least 2, more elements if they fit into 128 bytes).
51 Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
52 there is no statically allocated array at, and all non-empty
53 arrays are heap-allocated.
54
55 DYNARRAY_FINAL_TYPE
56 The name of the type which holds the final array. If not
57 defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
58 must be a struct type, with members of type DYNARRAY_ELEMENT and
59 size_t at the start (in this order).
60
61 These macros are undefined after this header file has been
62 included.
63
64 The following types are provided (their members are private to the
65 dynarray implementation):
66
67 struct DYNARRAY_STRUCT
68
69 The following functions are provided:
70 */
71
72/* Initialize a dynamic array object. This must be called before any
73 use of the object. */
74#if 0
75static void
76 DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *list);
77#endif
78
79/* Deallocate the dynamic array and its elements. */
80#if 0
81static void
82 DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *list);
83#endif
84
85/* Return true if the dynamic array is in an error state. */
86#if 0
87static bool
88 DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *list);
89#endif
90
91/* Mark the dynamic array as failed. All elements are deallocated as
92 a side effect. */
93#if 0
94static void
95 DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *list);
96#endif
97
98/* Return the number of elements which have been added to the dynamic
99 array. */
100#if 0
101static size_t
102 DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *list);
103#endif
104
105/* Return a pointer to the first array element, if any. For a
106 zero-length array, the pointer can be NULL even though the dynamic
107 array has not entered the failure state. */
108#if 0
109static DYNARRAY_ELEMENT *
110 DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *list);
111#endif
112
113/* Return a pointer one element past the last array element. For a
114 zero-length array, the pointer can be NULL even though the dynamic
115 array has not entered the failure state. */
116#if 0
117static DYNARRAY_ELEMENT *
118 DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *list);
119#endif
120
121/* Return a pointer to the array element at INDEX. Terminate the
122 process if INDEX is out of bounds. */
123#if 0
124static DYNARRAY_ELEMENT *
125 DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *list, size_t index);
126#endif
127
128/* Add ITEM at the end of the array, enlarging it by one element.
129 Mark *LIST as failed if the dynamic array allocation size cannot be
130 increased. */
131#if 0
132static void
133 DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *list,
134 DYNARRAY_ELEMENT item);
135#endif
136
137/* Allocate a place for a new element in *LIST and return a pointer to
138 it. The pointer can be NULL if the dynamic array cannot be
139 enlarged due to a memory allocation failure. */
140#if 0
141static DYNARRAY_ELEMENT *
142 DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *list);
143#endif
144
145/* Change the size of *LIST to SIZE. If SIZE is larger than the
146 existing size, new elements are added (which can be initialized).
147 Otherwise, the list is truncated, and elements are freed. Return
148 false on memory allocation failure (and mark *LIST as failed). */
149#if 0
150static bool
151 DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *list, size_t size);
152#endif
153
154/* Remove the last element of LIST if it is present. */
155#if 0
156static void
157 DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *list);
158#endif
159
160/* Remove all elements from the list. The elements are freed, but the
161 list itself is not. */
162#if 0
163static void
164 DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *list);
165#endif
166
167#if defined DYNARRAY_FINAL_TYPE
168/* Transfer the dynamic array to a permanent location at *RESULT.
169 Returns true on success on false on allocation failure. In either
170 case, *LIST is re-initialized and can be reused. A NULL pointer is
171 stored in *RESULT if LIST refers to an empty list. On success, the
172 pointer in *RESULT is heap-allocated and must be deallocated using
173 free. */
174#if 0
175static bool
176 DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
177 DYNARRAY_FINAL_TYPE *result);
178#endif
179#else /* !defined DYNARRAY_FINAL_TYPE */
180/* Transfer the dynamic array to a heap-allocated array and return a
181 pointer to it. The pointer is NULL if memory allocation fails, or
182 if the array is empty, so this function should be used only for
183 arrays which are known not be empty (usually because they always
184 have a sentinel at the end). If LENGTHP is not NULL, the array
185 length is written to *LENGTHP. *LIST is re-initialized and can be
186 reused. */
187#if 0
188static DYNARRAY_ELEMENT *
189 DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *list,
190 size_t *lengthp);
191#endif
192#endif
193
194/* A minimal example which provides a growing list of integers can be
195 defined like this:
196
197 struct int_array
198 {
199 // Pointer to result array followed by its length,
200 // as required by DYNARRAY_FINAL_TYPE.
201 int *array;
202 size_t length;
203 };
204
205 #define DYNARRAY_STRUCT dynarray_int
206 #define DYNARRAY_ELEMENT int
207 #define DYNARRAY_PREFIX dynarray_int_
208 #define DYNARRAY_FINAL_TYPE struct int_array
209 #include <malloc/dynarray-skeleton.c>
210
211 To create a three-element array with elements 1, 2, 3, use this
212 code:
213
214 struct dynarray_int dyn;
215 dynarray_int_init (&dyn);
216 for (int i = 1; i <= 3; ++i)
217 {
218 int *place = dynarray_int_emplace (&dyn);
219 assert (place != NULL);
220 *place = i;
221 }
222 struct int_array result;
223 bool ok = dynarray_int_finalize (&dyn, &result);
224 assert (ok);
225 assert (result.length == 3);
226 assert (result.array[0] == 1);
227 assert (result.array[1] == 2);
228 assert (result.array[2] == 3);
229 free (result.array);
230
231 If the elements contain resources which must be freed, define
232 DYNARRAY_ELEMENT_FREE appropriately, like this:
233
234 struct str_array
235 {
236 char **array;
237 size_t length;
238 };
239
240 #define DYNARRAY_STRUCT dynarray_str
241 #define DYNARRAY_ELEMENT char *
242 #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
243 #define DYNARRAY_PREFIX dynarray_str_
244 #define DYNARRAY_FINAL_TYPE struct str_array
245 #include <malloc/dynarray-skeleton.c>
246 */
247
248
249/* The implementation is imported from glibc. */
250
251/* Avoid possible conflicts with symbols exported by the GNU libc. */
252#define __libc_dynarray_at_failure gl_dynarray_at_failure
253#define __libc_dynarray_emplace_enlarge gl_dynarray_emplace_enlarge
254#define __libc_dynarray_finalize gl_dynarray_finalize
255#define __libc_dynarray_resize_clear gl_dynarray_resize_clear
256#define __libc_dynarray_resize gl_dynarray_resize
257
258#if defined DYNARRAY_STRUCT || defined DYNARRAY_ELEMENT || defined DYNARRAY_PREFIX
259
260# ifndef _GL_LIKELY
261/* Rely on __builtin_expect, as provided by the module 'builtin-expect'. */
262# define _GL_LIKELY(cond) __builtin_expect ((cond), 1)
263# define _GL_UNLIKELY(cond) __builtin_expect ((cond), 0)
264# endif
265
266/* Define auxiliary structs and declare auxiliary functions, common to all
267 instantiations of dynarray. */
268# include <malloc/dynarray.gl.h>
269
270/* Define the instantiation, specified through
271 DYNARRAY_STRUCT
272 DYNARRAY_ELEMENT
273 DYNARRAY_PREFIX
274 etc. */
275# include <malloc/dynarray-skeleton.gl.h>
276
277#else
278
279/* This file is being included from one of the malloc/dynarray_*.c files. */
280# include <malloc/dynarray.h>
281
282#endif
283
284#endif /* _GL_DYNARRAY_H */
diff --git a/gl/errno.in.h b/gl/errno.in.h
index 49b3546..3dda9c2 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -1,19 +1,19 @@
1/* A POSIX-like <errno.h>. 1/* A POSIX-like <errno.h>.
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_ERRNO_H 18#ifndef _@GUARD_PREFIX@_ERRNO_H
19 19
@@ -30,7 +30,7 @@
30 30
31 31
32/* On native Windows platforms, many macros are not defined. */ 32/* On native Windows platforms, many macros are not defined. */
33# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 33# if defined _WIN32 && ! defined __CYGWIN__
34 34
35/* These are the same values as defined by MSVC 10, for interoperability. */ 35/* These are the same values as defined by MSVC 10, for interoperability. */
36 36
@@ -248,7 +248,7 @@
248 interoperability. */ 248 interoperability. */
249# define EOWNERDEAD 58 249# define EOWNERDEAD 58
250# define ENOTRECOVERABLE 59 250# define ENOTRECOVERABLE 59
251# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 251# elif defined _WIN32 && ! defined __CYGWIN__
252 /* We have a conflict here: pthreads-win32 defines these values 252 /* We have a conflict here: pthreads-win32 defines these values
253 differently than MSVC 10. It's hairy to decide which one to use. */ 253 differently than MSVC 10. It's hairy to decide which one to use. */
254# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS 254# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
diff --git a/gl/error.c b/gl/error.c
index 865b293..6875f13 100644
--- a/gl/error.c
+++ b/gl/error.c
@@ -1,19 +1,19 @@
1/* Error handler for noninteractive utilities 1/* Error handler for noninteractive utilities
2 Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1990-1998, 2000-2007, 2009-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */ 18/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
19 19
@@ -39,6 +39,11 @@
39# include <stdint.h> 39# include <stdint.h>
40# include <wchar.h> 40# include <wchar.h>
41# define mbsrtowcs __mbsrtowcs 41# define mbsrtowcs __mbsrtowcs
42# define USE_UNLOCKED_IO 0
43# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
44# define _GL_ARG_NONNULL(a)
45#else
46# include "getprogname.h"
42#endif 47#endif
43 48
44#if USE_UNLOCKED_IO 49#if USE_UNLOCKED_IO
@@ -72,14 +77,14 @@ extern void __error (int status, int errnum, const char *message, ...)
72extern void __error_at_line (int status, int errnum, const char *file_name, 77extern void __error_at_line (int status, int errnum, const char *file_name,
73 unsigned int line_number, const char *message, 78 unsigned int line_number, const char *message,
74 ...) 79 ...)
75 __attribute__ ((__format__ (__printf__, 5, 6)));; 80 __attribute__ ((__format__ (__printf__, 5, 6)));
76# define error __error 81# define error __error
77# define error_at_line __error_at_line 82# define error_at_line __error_at_line
78 83
79# include <libio/iolibio.h> 84# include <libio/iolibio.h>
80# define fflush(s) INTUSE(_IO_fflush) (s) 85# define fflush(s) _IO_fflush (s)
81# undef putc 86# undef putc
82# define putc(c, fp) INTUSE(_IO_putc) (c, fp) 87# define putc(c, fp) _IO_putc (c, fp)
83 88
84# include <bits/libc-lock.h> 89# include <bits/libc-lock.h>
85 90
@@ -88,35 +93,37 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
88# include <fcntl.h> 93# include <fcntl.h>
89# include <unistd.h> 94# include <unistd.h>
90 95
91# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 96# if defined _WIN32 && ! defined __CYGWIN__
92/* Get declarations of the native Windows API functions. */ 97/* Get declarations of the native Windows API functions. */
93# define WIN32_LEAN_AND_MEAN 98# define WIN32_LEAN_AND_MEAN
94# include <windows.h> 99# include <windows.h>
95/* Get _get_osfhandle. */ 100/* Get _get_osfhandle. */
96# include "msvc-nothrow.h" 101# if GNULIB_MSVC_NOTHROW
102# include "msvc-nothrow.h"
103# else
104# include <io.h>
105# endif
97# endif 106# endif
98 107
99/* The gnulib override of fcntl is not needed in this file. */ 108/* The gnulib override of fcntl is not needed in this file. */
100# undef fcntl 109# undef fcntl
101 110
102# if !HAVE_DECL_STRERROR_R 111# if !(GNULIB_STRERROR_R_POSIX || HAVE_DECL_STRERROR_R)
103# ifndef HAVE_DECL_STRERROR_R 112# ifndef HAVE_DECL_STRERROR_R
104"this configure-time declaration test was not run" 113"this configure-time declaration test was not run"
105# endif 114# endif
106# if STRERROR_R_CHAR_P 115# if STRERROR_R_CHAR_P
107char *strerror_r (); 116char *strerror_r (int errnum, char *buf, size_t buflen);
108# else 117# else
109int strerror_r (); 118int strerror_r (int errnum, char *buf, size_t buflen);
110# endif 119# endif
111# endif 120# endif
112 121
113/* The calling program should define program_name and set it to the 122# define program_name getprogname ()
114 name of the executing program. */
115extern char *program_name;
116 123
117# if HAVE_STRERROR_R || defined strerror_r 124# if GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r
118# define __strerror_r strerror_r 125# define __strerror_r strerror_r
119# endif /* HAVE_STRERROR_R || defined strerror_r */ 126# endif /* GNULIB_STRERROR_R_POSIX || HAVE_STRERROR_R || defined strerror_r */
120#endif /* not _LIBC */ 127#endif /* not _LIBC */
121 128
122#if !_LIBC 129#if !_LIBC
@@ -124,7 +131,7 @@ extern char *program_name;
124static int 131static int
125is_open (int fd) 132is_open (int fd)
126{ 133{
127# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 134# if defined _WIN32 && ! defined __CYGWIN__
128 /* On native Windows: The initial state of unassigned standard file 135 /* On native Windows: The initial state of unassigned standard file
129 descriptors is that they are open but point to an INVALID_HANDLE_VALUE. 136 descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
130 There is no fcntl, and the gnulib replacement fcntl does not support 137 There is no fcntl, and the gnulib replacement fcntl does not support
@@ -169,9 +176,9 @@ print_errno_message (int errnum)
169{ 176{
170 char const *s; 177 char const *s;
171 178
172#if defined HAVE_STRERROR_R || _LIBC 179#if _LIBC || GNULIB_STRERROR_R_POSIX || defined HAVE_STRERROR_R
173 char errbuf[1024]; 180 char errbuf[1024];
174# if STRERROR_R_CHAR_P || _LIBC 181# if _LIBC || (!GNULIB_STRERROR_R_POSIX && STRERROR_R_CHAR_P)
175 s = __strerror_r (errnum, errbuf, sizeof errbuf); 182 s = __strerror_r (errnum, errbuf, sizeof errbuf);
176# else 183# else
177 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) 184 if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
@@ -195,13 +202,12 @@ print_errno_message (int errnum)
195#endif 202#endif
196} 203}
197 204
198static void 205static void _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0) _GL_ARG_NONNULL ((3))
199error_tail (int status, int errnum, const char *message, va_list args) 206error_tail (int status, int errnum, const char *message, va_list args)
200{ 207{
201#if _LIBC 208#if _LIBC
202 if (_IO_fwide (stderr, 0) > 0) 209 if (_IO_fwide (stderr, 0) > 0)
203 { 210 {
204# define ALLOCA_LIMIT 2000
205 size_t len = strlen (message) + 1; 211 size_t len = strlen (message) + 1;
206 wchar_t *wmessage = NULL; 212 wchar_t *wmessage = NULL;
207 mbstate_t st; 213 mbstate_t st;
@@ -237,7 +243,7 @@ error_tail (int status, int errnum, const char *message, va_list args)
237 if (res != len) 243 if (res != len)
238 break; 244 break;
239 245
240 if (__builtin_expect (len >= SIZE_MAX / 2, 0)) 246 if (__builtin_expect (len >= SIZE_MAX / sizeof (wchar_t) / 2, 0))
241 { 247 {
242 /* This really should not happen if everything is fine. */ 248 /* This really should not happen if everything is fine. */
243 res = (size_t) -1; 249 res = (size_t) -1;
@@ -266,7 +272,6 @@ error_tail (int status, int errnum, const char *message, va_list args)
266 else 272 else
267#endif 273#endif
268 vfprintf (stderr, message, args); 274 vfprintf (stderr, message, args);
269 va_end (args);
270 275
271 ++error_message_count; 276 ++error_message_count;
272 if (errnum) 277 if (errnum)
@@ -316,6 +321,7 @@ error (int status, int errnum, const char *message, ...)
316 321
317 va_start (args, message); 322 va_start (args, message);
318 error_tail (status, errnum, message, args); 323 error_tail (status, errnum, message, args);
324 va_end (args);
319 325
320#ifdef _LIBC 326#ifdef _LIBC
321 _IO_funlockfile (stderr); 327 _IO_funlockfile (stderr);
@@ -342,7 +348,10 @@ error_at_line (int status, int errnum, const char *file_name,
342 348
343 if (old_line_number == line_number 349 if (old_line_number == line_number
344 && (file_name == old_file_name 350 && (file_name == old_file_name
345 || strcmp (old_file_name, file_name) == 0)) 351 || (old_file_name != NULL
352 && file_name != NULL
353 && strcmp (old_file_name, file_name) == 0)))
354
346 /* Simply return and print nothing. */ 355 /* Simply return and print nothing. */
347 return; 356 return;
348 357
@@ -374,15 +383,16 @@ error_at_line (int status, int errnum, const char *file_name,
374 } 383 }
375 384
376#if _LIBC 385#if _LIBC
377 __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", 386 __fxprintf (NULL, file_name != NULL ? "%s:%u: " : " ",
378 file_name, line_number); 387 file_name, line_number);
379#else 388#else
380 fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", 389 fprintf (stderr, file_name != NULL ? "%s:%u: " : " ",
381 file_name, line_number); 390 file_name, line_number);
382#endif 391#endif
383 392
384 va_start (args, message); 393 va_start (args, message);
385 error_tail (status, errnum, message, args); 394 error_tail (status, errnum, message, args);
395 va_end (args);
386 396
387#ifdef _LIBC 397#ifdef _LIBC
388 _IO_funlockfile (stderr); 398 _IO_funlockfile (stderr);
diff --git a/gl/error.h b/gl/error.h
index afcb0e1..a240526 100644
--- a/gl/error.h
+++ b/gl/error.h
@@ -1,35 +1,26 @@
1/* Declaration for error-reporting function 1/* Declaration for error-reporting function
2 Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation, 2 Copyright (C) 1995-1997, 2003, 2006, 2008-2023 Free Software Foundation,
3 Inc. 3 Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef _ERROR_H 19#ifndef _ERROR_H
20#define _ERROR_H 1 20#define _ERROR_H 1
21 21
22/* The __attribute__ feature is available in gcc versions 2.5 and later. 22/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM. */
23 The __-protected variants of the attributes 'format' and 'printf' are 23#include <stdio.h>
24 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
25 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
26 gnulib and libintl do '#define printf __printf__' when they override
27 the 'printf' function. */
28#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
29# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
30#else
31# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
32#endif
33 24
34#ifdef __cplusplus 25#ifdef __cplusplus
35extern "C" { 26extern "C" {
@@ -40,11 +31,21 @@ extern "C" {
40 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */ 31 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
41 32
42extern void error (int __status, int __errnum, const char *__format, ...) 33extern void error (int __status, int __errnum, const char *__format, ...)
43 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); 34#if GNULIB_VFPRINTF_POSIX
35 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4))
36#else
37 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 3, 4))
38#endif
39 ;
44 40
45extern void error_at_line (int __status, int __errnum, const char *__fname, 41extern void error_at_line (int __status, int __errnum, const char *__fname,
46 unsigned int __lineno, const char *__format, ...) 42 unsigned int __lineno, const char *__format, ...)
47 _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6)); 43#if GNULIB_VFPRINTF_POSIX
44 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 6))
45#else
46 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, 5, 6))
47#endif
48 ;
48 49
49/* If NULL, error will flush stdout, then print on stderr the program 50/* If NULL, error will flush stdout, then print on stderr the program
50 name, a colon and a space. Otherwise, error will call this 51 name, a colon and a space. Otherwise, error will call this
diff --git a/gl/exitfail.c b/gl/exitfail.c
index b0b4ebe..d67a130 100644
--- a/gl/exitfail.c
+++ b/gl/exitfail.c
@@ -1,19 +1,19 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/exitfail.h b/gl/exitfail.h
index e54333b..85a6af6 100644
--- a/gl/exitfail.h
+++ b/gl/exitfail.h
@@ -1,18 +1,18 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18extern int volatile exit_failure; 18extern int volatile exit_failure;
diff --git a/gl/fcntl.c b/gl/fcntl.c
new file mode 100644
index 0000000..e220800
--- /dev/null
+++ b/gl/fcntl.c
@@ -0,0 +1,629 @@
1/* Provide file descriptor control.
2
3 Copyright (C) 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Eric Blake <ebb9@byu.net>. */
19
20#include <config.h>
21
22/* Specification. */
23#include <fcntl.h>
24
25#include <errno.h>
26#include <limits.h>
27#include <stdarg.h>
28#include <stdlib.h>
29#include <unistd.h>
30
31#ifdef __KLIBC__
32# define INCL_DOS
33# include <os2.h>
34#endif
35
36#if defined _WIN32 && ! defined __CYGWIN__
37/* Get declarations of the native Windows API functions. */
38# define WIN32_LEAN_AND_MEAN
39# include <windows.h>
40
41/* Get _get_osfhandle. */
42# if GNULIB_MSVC_NOTHROW
43# include "msvc-nothrow.h"
44# else
45# include <io.h>
46# endif
47
48/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
49# define OPEN_MAX_MAX 0x10000
50
51/* Duplicate OLDFD into the first available slot of at least NEWFD,
52 which must be positive, with FLAGS determining whether the duplicate
53 will be inheritable. */
54static int
55dupfd (int oldfd, int newfd, int flags)
56{
57 /* Mingw has no way to create an arbitrary fd. Iterate until all
58 file descriptors less than newfd are filled up. */
59 HANDLE curr_process = GetCurrentProcess ();
60 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
61 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
62 unsigned int fds_to_close_bound = 0;
63 int result;
64 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
65 int mode;
66
67 if (newfd < 0 || getdtablesize () <= newfd)
68 {
69 errno = EINVAL;
70 return -1;
71 }
72 if (old_handle == INVALID_HANDLE_VALUE
73 || (mode = _setmode (oldfd, O_BINARY)) == -1)
74 {
75 /* oldfd is not open, or is an unassigned standard file
76 descriptor. */
77 errno = EBADF;
78 return -1;
79 }
80 _setmode (oldfd, mode);
81 flags |= mode;
82
83 for (;;)
84 {
85 HANDLE new_handle;
86 int duplicated_fd;
87 unsigned int index;
88
89 if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
90 old_handle, /* SourceHandle */
91 curr_process, /* TargetProcessHandle */
92 (PHANDLE) &new_handle, /* TargetHandle */
93 (DWORD) 0, /* DesiredAccess */
94 inherit, /* InheritHandle */
95 DUPLICATE_SAME_ACCESS)) /* Options */
96 {
97 switch (GetLastError ())
98 {
99 case ERROR_TOO_MANY_OPEN_FILES:
100 errno = EMFILE;
101 break;
102 case ERROR_INVALID_HANDLE:
103 case ERROR_INVALID_TARGET_HANDLE:
104 case ERROR_DIRECT_ACCESS_HANDLE:
105 errno = EBADF;
106 break;
107 case ERROR_INVALID_PARAMETER:
108 case ERROR_INVALID_FUNCTION:
109 case ERROR_INVALID_ACCESS:
110 errno = EINVAL;
111 break;
112 default:
113 errno = EACCES;
114 break;
115 }
116 result = -1;
117 break;
118 }
119 duplicated_fd = _open_osfhandle ((intptr_t) new_handle, flags);
120 if (duplicated_fd < 0)
121 {
122 CloseHandle (new_handle);
123 result = -1;
124 break;
125 }
126 if (newfd <= duplicated_fd)
127 {
128 result = duplicated_fd;
129 break;
130 }
131
132 /* Set the bit duplicated_fd in fds_to_close[]. */
133 index = (unsigned int) duplicated_fd / CHAR_BIT;
134 if (fds_to_close_bound <= index)
135 {
136 if (sizeof fds_to_close <= index)
137 /* Need to increase OPEN_MAX_MAX. */
138 abort ();
139 memset (fds_to_close + fds_to_close_bound, '\0',
140 index + 1 - fds_to_close_bound);
141 fds_to_close_bound = index + 1;
142 }
143 fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
144 }
145
146 /* Close the previous fds that turned out to be too small. */
147 {
148 int saved_errno = errno;
149 unsigned int duplicated_fd;
150
151 for (duplicated_fd = 0;
152 duplicated_fd < fds_to_close_bound * CHAR_BIT;
153 duplicated_fd++)
154 if ((fds_to_close[duplicated_fd / CHAR_BIT]
155 >> (duplicated_fd % CHAR_BIT))
156 & 1)
157 close (duplicated_fd);
158
159 errno = saved_errno;
160 }
161
162# if REPLACE_FCHDIR
163 if (0 <= result)
164 result = _gl_register_dup (oldfd, result);
165# endif
166 return result;
167}
168#endif /* W32 */
169
170/* Forward declarations, because we '#undef fcntl' in the middle of this
171 compilation unit. */
172/* Our implementation of fcntl (fd, F_DUPFD, target). */
173static int rpl_fcntl_DUPFD (int fd, int target);
174/* Our implementation of fcntl (fd, F_DUPFD_CLOEXEC, target). */
175static int rpl_fcntl_DUPFD_CLOEXEC (int fd, int target);
176#ifdef __KLIBC__
177/* Adds support for fcntl on directories. */
178static int klibc_fcntl (int fd, int action, /* arg */...);
179#endif
180
181
182/* Perform the specified ACTION on the file descriptor FD, possibly
183 using the argument ARG further described below. This replacement
184 handles the following actions, and forwards all others on to the
185 native fcntl. An unrecognized ACTION returns -1 with errno set to
186 EINVAL.
187
188 F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
189 If successful, return the duplicate, which will be inheritable;
190 otherwise return -1 and set errno.
191
192 F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
193 target fd. If successful, return the duplicate, which will not be
194 inheritable; otherwise return -1 and set errno.
195
196 F_GETFD - ARG need not be present. If successful, return a
197 non-negative value containing the descriptor flags of FD (only
198 FD_CLOEXEC is portable, but other flags may be present); otherwise
199 return -1 and set errno. */
200
201int
202fcntl (int fd, int action, /* arg */...)
203#undef fcntl
204#ifdef __KLIBC__
205# define fcntl klibc_fcntl
206#endif
207{
208 va_list arg;
209 int result = -1;
210 va_start (arg, action);
211 switch (action)
212 {
213 case F_DUPFD:
214 {
215 int target = va_arg (arg, int);
216 result = rpl_fcntl_DUPFD (fd, target);
217 break;
218 }
219
220 case F_DUPFD_CLOEXEC:
221 {
222 int target = va_arg (arg, int);
223 result = rpl_fcntl_DUPFD_CLOEXEC (fd, target);
224 break;
225 }
226
227#if !HAVE_FCNTL
228 case F_GETFD:
229 {
230# if defined _WIN32 && ! defined __CYGWIN__
231 HANDLE handle = (HANDLE) _get_osfhandle (fd);
232 DWORD flags;
233 if (handle == INVALID_HANDLE_VALUE
234 || GetHandleInformation (handle, &flags) == 0)
235 errno = EBADF;
236 else
237 result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
238# else /* !W32 */
239 /* Use dup2 to reject invalid file descriptors. No way to
240 access this information, so punt. */
241 if (0 <= dup2 (fd, fd))
242 result = 0;
243# endif /* !W32 */
244 break;
245 } /* F_GETFD */
246#endif /* !HAVE_FCNTL */
247
248 /* Implementing F_SETFD on mingw is not trivial - there is no
249 API for changing the O_NOINHERIT bit on an fd, and merely
250 changing the HANDLE_FLAG_INHERIT bit on the underlying handle
251 can lead to odd state. It may be possible by duplicating the
252 handle, using _open_osfhandle with the right flags, then
253 using dup2 to move the duplicate onto the original, but that
254 is not supported for now. */
255
256 default:
257 {
258#if HAVE_FCNTL
259 switch (action)
260 {
261 #ifdef F_BARRIERFSYNC /* macOS */
262 case F_BARRIERFSYNC:
263 #endif
264 #ifdef F_CHKCLEAN /* macOS */
265 case F_CHKCLEAN:
266 #endif
267 #ifdef F_CLOSEM /* NetBSD, HP-UX */
268 case F_CLOSEM:
269 #endif
270 #ifdef F_FLUSH_DATA /* macOS */
271 case F_FLUSH_DATA:
272 #endif
273 #ifdef F_FREEZE_FS /* macOS */
274 case F_FREEZE_FS:
275 #endif
276 #ifdef F_FULLFSYNC /* macOS */
277 case F_FULLFSYNC:
278 #endif
279 #ifdef F_GETCONFINED /* macOS */
280 case F_GETCONFINED:
281 #endif
282 #ifdef F_GETDEFAULTPROTLEVEL /* macOS */
283 case F_GETDEFAULTPROTLEVEL:
284 #endif
285 #ifdef F_GETFD /* POSIX */
286 case F_GETFD:
287 #endif
288 #ifdef F_GETFL /* POSIX */
289 case F_GETFL:
290 #endif
291 #ifdef F_GETLEASE /* Linux */
292 case F_GETLEASE:
293 #endif
294 #ifdef F_GETNOSIGPIPE /* macOS */
295 case F_GETNOSIGPIPE:
296 #endif
297 #ifdef F_GETOWN /* POSIX */
298 case F_GETOWN:
299 #endif
300 #ifdef F_GETPIPE_SZ /* Linux */
301 case F_GETPIPE_SZ:
302 #endif
303 #ifdef F_GETPROTECTIONCLASS /* macOS */
304 case F_GETPROTECTIONCLASS:
305 #endif
306 #ifdef F_GETPROTECTIONLEVEL /* macOS */
307 case F_GETPROTECTIONLEVEL:
308 #endif
309 #ifdef F_GET_SEALS /* Linux */
310 case F_GET_SEALS:
311 #endif
312 #ifdef F_GETSIG /* Linux */
313 case F_GETSIG:
314 #endif
315 #ifdef F_MAXFD /* NetBSD */
316 case F_MAXFD:
317 #endif
318 #ifdef F_RECYCLE /* macOS */
319 case F_RECYCLE:
320 #endif
321 #ifdef F_SETFIFOENH /* HP-UX */
322 case F_SETFIFOENH:
323 #endif
324 #ifdef F_THAW_FS /* macOS */
325 case F_THAW_FS:
326 #endif
327 /* These actions take no argument. */
328 result = fcntl (fd, action);
329 break;
330
331 #ifdef F_ADD_SEALS /* Linux */
332 case F_ADD_SEALS:
333 #endif
334 #ifdef F_BADFD /* Solaris */
335 case F_BADFD:
336 #endif
337 #ifdef F_CHECK_OPENEVT /* macOS */
338 case F_CHECK_OPENEVT:
339 #endif
340 #ifdef F_DUP2FD /* FreeBSD, AIX, Solaris */
341 case F_DUP2FD:
342 #endif
343 #ifdef F_DUP2FD_CLOEXEC /* FreeBSD, Solaris */
344 case F_DUP2FD_CLOEXEC:
345 #endif
346 #ifdef F_DUP2FD_CLOFORK /* Solaris */
347 case F_DUP2FD_CLOFORK:
348 #endif
349 #ifdef F_DUPFD /* POSIX */
350 case F_DUPFD:
351 #endif
352 #ifdef F_DUPFD_CLOEXEC /* POSIX */
353 case F_DUPFD_CLOEXEC:
354 #endif
355 #ifdef F_DUPFD_CLOFORK /* Solaris */
356 case F_DUPFD_CLOFORK:
357 #endif
358 #ifdef F_GETXFL /* Solaris */
359 case F_GETXFL:
360 #endif
361 #ifdef F_GLOBAL_NOCACHE /* macOS */
362 case F_GLOBAL_NOCACHE:
363 #endif
364 #ifdef F_MAKECOMPRESSED /* macOS */
365 case F_MAKECOMPRESSED:
366 #endif
367 #ifdef F_MOVEDATAEXTENTS /* macOS */
368 case F_MOVEDATAEXTENTS:
369 #endif
370 #ifdef F_NOCACHE /* macOS */
371 case F_NOCACHE:
372 #endif
373 #ifdef F_NODIRECT /* macOS */
374 case F_NODIRECT:
375 #endif
376 #ifdef F_NOTIFY /* Linux */
377 case F_NOTIFY:
378 #endif
379 #ifdef F_OPLKACK /* IRIX */
380 case F_OPLKACK:
381 #endif
382 #ifdef F_OPLKREG /* IRIX */
383 case F_OPLKREG:
384 #endif
385 #ifdef F_RDAHEAD /* macOS */
386 case F_RDAHEAD:
387 #endif
388 #ifdef F_SETBACKINGSTORE /* macOS */
389 case F_SETBACKINGSTORE:
390 #endif
391 #ifdef F_SETCONFINED /* macOS */
392 case F_SETCONFINED:
393 #endif
394 #ifdef F_SETFD /* POSIX */
395 case F_SETFD:
396 #endif
397 #ifdef F_SETFL /* POSIX */
398 case F_SETFL:
399 #endif
400 #ifdef F_SETLEASE /* Linux */
401 case F_SETLEASE:
402 #endif
403 #ifdef F_SETNOSIGPIPE /* macOS */
404 case F_SETNOSIGPIPE:
405 #endif
406 #ifdef F_SETOWN /* POSIX */
407 case F_SETOWN:
408 #endif
409 #ifdef F_SETPIPE_SZ /* Linux */
410 case F_SETPIPE_SZ:
411 #endif
412 #ifdef F_SETPROTECTIONCLASS /* macOS */
413 case F_SETPROTECTIONCLASS:
414 #endif
415 #ifdef F_SETSIG /* Linux */
416 case F_SETSIG:
417 #endif
418 #ifdef F_SINGLE_WRITER /* macOS */
419 case F_SINGLE_WRITER:
420 #endif
421 /* These actions take an 'int' argument. */
422 {
423 int x = va_arg (arg, int);
424 result = fcntl (fd, action, x);
425 }
426 break;
427
428 default:
429 /* Other actions take a pointer argument. */
430 {
431 void *p = va_arg (arg, void *);
432 result = fcntl (fd, action, p);
433 }
434 break;
435 }
436#else
437 errno = EINVAL;
438#endif
439 break;
440 }
441 }
442 va_end (arg);
443 return result;
444}
445
446static int
447rpl_fcntl_DUPFD (int fd, int target)
448{
449 int result;
450#if !HAVE_FCNTL
451 result = dupfd (fd, target, 0);
452#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
453 /* Detect invalid target; needed for cygwin 1.5.x. */
454 if (target < 0 || getdtablesize () <= target)
455 {
456 result = -1;
457 errno = EINVAL;
458 }
459 else
460 {
461 /* Haiku alpha 2 loses fd flags on original. */
462 int flags = fcntl (fd, F_GETFD);
463 if (flags < 0)
464 result = -1;
465 else
466 {
467 result = fcntl (fd, F_DUPFD, target);
468 if (0 <= result && fcntl (fd, F_SETFD, flags) == -1)
469 {
470 int saved_errno = errno;
471 close (result);
472 result = -1;
473 errno = saved_errno;
474 }
475# if REPLACE_FCHDIR
476 if (0 <= result)
477 result = _gl_register_dup (fd, result);
478# endif
479 }
480 }
481#else
482 result = fcntl (fd, F_DUPFD, target);
483#endif
484 return result;
485}
486
487static int
488rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
489{
490 int result;
491#if !HAVE_FCNTL
492 result = dupfd (fd, target, O_CLOEXEC);
493#else /* HAVE_FCNTL */
494# if defined __NetBSD__ || defined __HAIKU__
495 /* On NetBSD 9.0, the system fcntl (fd, F_DUPFD_CLOEXEC, target)
496 has only the same effect as fcntl (fd, F_DUPFD, target). */
497 /* On Haiku, the system fcntl (fd, F_DUPFD_CLOEXEC, target) sets
498 the FD_CLOEXEC flag on fd, not on target. Therefore avoid the
499 system fcntl in this case. */
500# define have_dupfd_cloexec -1
501# else
502 /* Try the system call first, if the headers claim it exists
503 (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
504 may be running with a glibc that has the macro but with an
505 older kernel that does not support it. Cache the
506 information on whether the system call really works, but
507 avoid caching failure if the corresponding F_DUPFD fails
508 for any reason. 0 = unknown, 1 = yes, -1 = no. */
509 static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
510 if (0 <= have_dupfd_cloexec)
511 {
512 result = fcntl (fd, F_DUPFD_CLOEXEC, target);
513 if (0 <= result || errno != EINVAL)
514 {
515 have_dupfd_cloexec = 1;
516# if REPLACE_FCHDIR
517 if (0 <= result)
518 result = _gl_register_dup (fd, result);
519# endif
520 }
521 else
522 {
523 result = rpl_fcntl_DUPFD (fd, target);
524 if (result >= 0)
525 have_dupfd_cloexec = -1;
526 }
527 }
528 else
529# endif
530 result = rpl_fcntl_DUPFD (fd, target);
531 if (0 <= result && have_dupfd_cloexec == -1)
532 {
533 int flags = fcntl (result, F_GETFD);
534 if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
535 {
536 int saved_errno = errno;
537 close (result);
538 errno = saved_errno;
539 result = -1;
540 }
541 }
542#endif /* HAVE_FCNTL */
543 return result;
544}
545
546#undef fcntl
547
548#ifdef __KLIBC__
549
550static int
551klibc_fcntl (int fd, int action, /* arg */...)
552{
553 va_list arg_ptr;
554 int arg;
555 struct stat sbuf;
556 int result;
557
558 va_start (arg_ptr, action);
559 arg = va_arg (arg_ptr, int);
560 result = fcntl (fd, action, arg);
561 /* EPERM for F_DUPFD, ENOTSUP for others */
562 if (result == -1 && (errno == EPERM || errno == ENOTSUP)
563 && !fstat (fd, &sbuf) && S_ISDIR (sbuf.st_mode))
564 {
565 ULONG ulMode;
566
567 switch (action)
568 {
569 case F_DUPFD:
570 /* Find available fd */
571 while (fcntl (arg, F_GETFL) != -1 || errno != EBADF)
572 arg++;
573
574 result = dup2 (fd, arg);
575 break;
576
577 /* Using underlying APIs is right ? */
578 case F_GETFD:
579 if (DosQueryFHState (fd, &ulMode))
580 break;
581
582 result = (ulMode & OPEN_FLAGS_NOINHERIT) ? FD_CLOEXEC : 0;
583 break;
584
585 case F_SETFD:
586 if (arg & ~FD_CLOEXEC)
587 break;
588
589 if (DosQueryFHState (fd, &ulMode))
590 break;
591
592 if (arg & FD_CLOEXEC)
593 ulMode |= OPEN_FLAGS_NOINHERIT;
594 else
595 ulMode &= ~OPEN_FLAGS_NOINHERIT;
596
597 /* Filter supported flags. */
598 ulMode &= (OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR
599 | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT);
600
601 if (DosSetFHState (fd, ulMode))
602 break;
603
604 result = 0;
605 break;
606
607 case F_GETFL:
608 result = 0;
609 break;
610
611 case F_SETFL:
612 if (arg != 0)
613 break;
614
615 result = 0;
616 break;
617
618 default:
619 errno = EINVAL;
620 break;
621 }
622 }
623
624 va_end (arg_ptr);
625
626 return result;
627}
628
629#endif
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
new file mode 100644
index 0000000..e034eaf
--- /dev/null
+++ b/gl/fcntl.in.h
@@ -0,0 +1,445 @@
1/* Like <fcntl.h>, but with non-working flags defined to 0.
2
3 Copyright (C) 2006-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23@PRAGMA_COLUMNS@
24
25#if defined __need_system_fcntl_h
26/* Special invocation convention. */
27
28/* Needed before <sys/stat.h>.
29 May also define off_t to a 64-bit type on native Windows. */
30#include <sys/types.h>
31/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
32 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
33 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
34 extern "C" { ... } block, which leads to errors in C++ mode with the
35 overridden <sys/stat.h> from gnulib. These errors are known to be gone
36 with g++ version >= 4.3. */
37#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
38# include <sys/stat.h>
39#endif
40#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
41
42/* Native Windows platforms declare open(), creat() in <io.h>. */
43#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
44 && (defined _WIN32 && ! defined __CYGWIN__)
45# include <io.h>
46#endif
47
48#else
49/* Normal invocation convention. */
50
51#ifndef _@GUARD_PREFIX@_FCNTL_H
52
53/* Needed before <sys/stat.h>.
54 May also define off_t to a 64-bit type on native Windows. */
55#include <sys/types.h>
56/* On some systems other than glibc, <sys/stat.h> is a prerequisite of
57 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
58 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
59 extern "C" { ... } block, which leads to errors in C++ mode with the
60 overridden <sys/stat.h> from gnulib. These errors are known to be gone
61 with g++ version >= 4.3. */
62#if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))))
63# include <sys/stat.h>
64#endif
65/* The include_next requires a split double-inclusion guard. */
66#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
67
68/* Native Windows platforms declare open(), creat() in <io.h>. */
69#if (@GNULIB_CREAT@ || @GNULIB_OPEN@ || defined GNULIB_POSIXCHECK) \
70 && (defined _WIN32 && ! defined __CYGWIN__)
71# include <io.h>
72#endif
73
74#ifndef _@GUARD_PREFIX@_FCNTL_H
75#define _@GUARD_PREFIX@_FCNTL_H
76
77#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
78# include <unistd.h>
79#endif
80
81
82/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
83
84/* The definition of _GL_ARG_NONNULL is copied here. */
85
86/* The definition of _GL_WARN_ON_USE is copied here. */
87
88
89/* Declare overridden functions. */
90
91#if @GNULIB_CREAT@
92# if @REPLACE_CREAT@
93# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
94# undef creat
95# define creat rpl_creat
96# endif
97_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode)
98 _GL_ARG_NONNULL ((1)));
99_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
100# elif defined _WIN32 && !defined __CYGWIN__
101# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
102# undef creat
103# define creat _creat
104# endif
105_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode));
106# else
107_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
108# endif
109_GL_CXXALIASWARN (creat);
110#elif defined GNULIB_POSIXCHECK
111# undef creat
112/* Assume creat is always declared. */
113_GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - "
114 "use gnulib module creat for portability");
115#elif @GNULIB_MDA_CREAT@
116/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
117 required. In C++ with GNULIB_NAMESPACE, avoid differences between
118 platforms by defining GNULIB_NAMESPACE::creat always. */
119# if defined _WIN32 && !defined __CYGWIN__
120# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
121# undef creat
122# define creat _creat
123# endif
124/* Need to cast, because in mingw the last argument is 'int mode'. */
125_GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode));
126# else
127_GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode));
128# endif
129_GL_CXXALIASWARN (creat);
130#endif
131
132#if @GNULIB_FCNTL@
133# if @REPLACE_FCNTL@
134# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
135# undef fcntl
136# define fcntl rpl_fcntl
137# endif
138_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
139_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
140# if !GNULIB_defined_rpl_fcntl
141# define GNULIB_defined_rpl_fcntl 1
142# endif
143# else
144# if !@HAVE_FCNTL@
145_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
146# if !GNULIB_defined_fcntl
147# define GNULIB_defined_fcntl 1
148# endif
149# endif
150_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
151# endif
152_GL_CXXALIASWARN (fcntl);
153#elif defined GNULIB_POSIXCHECK
154# undef fcntl
155# if HAVE_RAW_DECL_FCNTL
156_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
157 "use gnulib module fcntl for portability");
158# endif
159#endif
160
161#if @GNULIB_OPEN@
162# if @REPLACE_OPEN@
163# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
164# undef open
165# define open rpl_open
166# endif
167_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
168 _GL_ARG_NONNULL ((1)));
169_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
170# elif defined _WIN32 && !defined __CYGWIN__
171# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
172# undef open
173# define open _open
174# endif
175_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
176# else
177_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
178# endif
179/* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
180 default argument. _GL_CXXALIASWARN does not work in this case. */
181# if !defined __hpux
182_GL_CXXALIASWARN (open);
183# endif
184#elif defined GNULIB_POSIXCHECK
185# undef open
186/* Assume open is always declared. */
187_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
188 "use gnulib module open for portability");
189#elif @GNULIB_MDA_OPEN@
190/* On native Windows, map 'open' to '_open', so that -loldnames is not
191 required. In C++ with GNULIB_NAMESPACE, avoid differences between
192 platforms by defining GNULIB_NAMESPACE::open always. */
193# if defined _WIN32 && !defined __CYGWIN__
194# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
195# undef open
196# define open _open
197# endif
198_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
199# else
200_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
201# endif
202# if !defined __hpux
203_GL_CXXALIASWARN (open);
204# endif
205#endif
206
207#if @GNULIB_OPENAT@
208# if @REPLACE_OPENAT@
209# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
210# undef openat
211# define openat rpl_openat
212# endif
213_GL_FUNCDECL_RPL (openat, int,
214 (int fd, char const *file, int flags, /* mode_t mode */ ...)
215 _GL_ARG_NONNULL ((2)));
216_GL_CXXALIAS_RPL (openat, int,
217 (int fd, char const *file, int flags, /* mode_t mode */ ...));
218# else
219# if !@HAVE_OPENAT@
220_GL_FUNCDECL_SYS (openat, int,
221 (int fd, char const *file, int flags, /* mode_t mode */ ...)
222 _GL_ARG_NONNULL ((2)));
223# endif
224_GL_CXXALIAS_SYS (openat, int,
225 (int fd, char const *file, int flags, /* mode_t mode */ ...));
226# endif
227_GL_CXXALIASWARN (openat);
228#elif defined GNULIB_POSIXCHECK
229# undef openat
230# if HAVE_RAW_DECL_OPENAT
231_GL_WARN_ON_USE (openat, "openat is not portable - "
232 "use gnulib module openat for portability");
233# endif
234#endif
235
236
237/* Fix up the FD_* macros, only known to be missing on mingw. */
238
239#ifndef FD_CLOEXEC
240# define FD_CLOEXEC 1
241#endif
242
243/* Fix up the supported F_* macros. Intentionally leave other F_*
244 macros undefined. Only known to be missing on mingw. */
245
246#ifndef F_DUPFD_CLOEXEC
247# define F_DUPFD_CLOEXEC 0x40000000
248/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
249# define GNULIB_defined_F_DUPFD_CLOEXEC 1
250#else
251# define GNULIB_defined_F_DUPFD_CLOEXEC 0
252#endif
253
254#ifndef F_DUPFD
255# define F_DUPFD 1
256#endif
257
258#ifndef F_GETFD
259# define F_GETFD 2
260#endif
261
262/* Fix up the O_* macros. */
263
264/* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT
265 to values outside 'int' range, so omit these misdefinitions.
266 But avoid namespace pollution on non-AIX systems. */
267#ifdef _AIX
268# include <limits.h>
269# if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX)
270# undef O_CLOEXEC
271# endif
272# if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
273# undef O_NOFOLLOW
274# endif
275# if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX)
276# undef O_TTY_INIT
277# endif
278#endif
279
280#if !defined O_DIRECT && defined O_DIRECTIO
281/* Tru64 spells it 'O_DIRECTIO'. */
282# define O_DIRECT O_DIRECTIO
283#endif
284
285#if !defined O_CLOEXEC && defined O_NOINHERIT
286/* Mingw spells it 'O_NOINHERIT'. */
287# define O_CLOEXEC O_NOINHERIT
288#endif
289
290#ifndef O_CLOEXEC
291# define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */
292# define GNULIB_defined_O_CLOEXEC 1
293#else
294# define GNULIB_defined_O_CLOEXEC 0
295#endif
296
297#ifndef O_DIRECT
298# define O_DIRECT 0
299#endif
300
301#ifndef O_DIRECTORY
302# define O_DIRECTORY 0
303#endif
304
305#ifndef O_DSYNC
306# define O_DSYNC 0
307#endif
308
309#ifndef O_EXEC
310# define O_EXEC O_RDONLY /* This is often close enough in older systems. */
311#endif
312
313#ifndef O_IGNORE_CTTY
314# define O_IGNORE_CTTY 0
315#endif
316
317#ifndef O_NDELAY
318# define O_NDELAY 0
319#endif
320
321#ifndef O_NOATIME
322# define O_NOATIME 0
323#endif
324
325#ifndef O_NONBLOCK
326# define O_NONBLOCK O_NDELAY
327#endif
328
329/* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
330 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
331 or to 0 as fallback. */
332#if @GNULIB_NONBLOCKING@
333# if O_NONBLOCK
334# define GNULIB_defined_O_NONBLOCK 0
335# else
336# define GNULIB_defined_O_NONBLOCK 1
337# undef O_NONBLOCK
338# define O_NONBLOCK 0x40000000
339# endif
340#endif
341
342#ifndef O_NOCTTY
343# define O_NOCTTY 0
344#endif
345
346#ifndef O_NOFOLLOW
347# define O_NOFOLLOW 0
348#endif
349
350#ifndef O_NOLINK
351# define O_NOLINK 0
352#endif
353
354#ifndef O_NOLINKS
355# define O_NOLINKS 0
356#endif
357
358#ifndef O_NOTRANS
359# define O_NOTRANS 0
360#endif
361
362#ifndef O_RSYNC
363# define O_RSYNC 0
364#endif
365
366#ifndef O_SEARCH
367# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
368#endif
369
370#ifndef O_SYNC
371# define O_SYNC 0
372#endif
373
374#ifndef O_TTY_INIT
375# define O_TTY_INIT 0
376#endif
377
378#if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
379# undef O_ACCMODE
380# define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
381#endif
382
383/* For systems that distinguish between text and binary I/O.
384 O_BINARY is usually declared in fcntl.h */
385#if !defined O_BINARY && defined _O_BINARY
386 /* For MSC-compatible compilers. */
387# define O_BINARY _O_BINARY
388# define O_TEXT _O_TEXT
389#endif
390
391#if defined __BEOS__ || defined __HAIKU__
392 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
393# undef O_BINARY
394# undef O_TEXT
395#endif
396
397#ifndef O_BINARY
398# define O_BINARY 0
399# define O_TEXT 0
400#endif
401
402/* Fix up the AT_* macros. */
403
404/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
405 value exceeds INT_MAX, so its use as an int doesn't conform to the
406 C standard, and GCC and Sun C complain in some cases. If the bug
407 is present, undef AT_FDCWD here, so it can be redefined below. */
408#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
409# undef AT_FDCWD
410#endif
411
412/* Use the same bit pattern as Solaris 9, but with the proper
413 signedness. The bit pattern is important, in case this actually is
414 Solaris with the above workaround. */
415#ifndef AT_FDCWD
416# define AT_FDCWD (-3041965)
417#endif
418
419/* Use the same values as Solaris 9. This shouldn't matter, but
420 there's no real reason to differ. */
421#ifndef AT_SYMLINK_NOFOLLOW
422# define AT_SYMLINK_NOFOLLOW 4096
423#endif
424
425#ifndef AT_REMOVEDIR
426# define AT_REMOVEDIR 1
427#endif
428
429/* Solaris 9 lacks these two, so just pick unique values. */
430#ifndef AT_SYMLINK_FOLLOW
431# define AT_SYMLINK_FOLLOW 2
432#endif
433
434#ifndef AT_EACCESS
435# define AT_EACCESS 4
436#endif
437
438/* Ignore this flag if not supported. */
439#ifndef AT_NO_AUTOMOUNT
440# define AT_NO_AUTOMOUNT 0
441#endif
442
443#endif /* _@GUARD_PREFIX@_FCNTL_H */
444#endif /* _@GUARD_PREFIX@_FCNTL_H */
445#endif
diff --git a/gl/fd-hook.c b/gl/fd-hook.c
index e158a52..3626115 100644
--- a/gl/fd-hook.c
+++ b/gl/fd-hook.c
@@ -1,19 +1,19 @@
1/* Hook for making making file descriptor functions close(), ioctl() extensible. 1/* Hook for making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009. 3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4 4
5 This program is free software: you can redistribute it and/or modify it 5 This file is free software: you can redistribute it and/or modify
6 under the terms of the GNU General Public License as published 6 it under the terms of the GNU Lesser General Public License as
7 by the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/fd-hook.h b/gl/fd-hook.h
index d15b577..6bf3c24 100644
--- a/gl/fd-hook.h
+++ b/gl/fd-hook.h
@@ -1,18 +1,18 @@
1/* Hook for making making file descriptor functions close(), ioctl() extensible. 1/* Hook for making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This file is free software: you can redistribute it and/or modify
5 under the terms of the GNU General Public License as published 5 it under the terms of the GNU Lesser General Public License as
6 by the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17 17
18#ifndef FD_HOOK_H 18#ifndef FD_HOOK_H
diff --git a/gl/fflush.c b/gl/fflush.c
new file mode 100644
index 0000000..f3689b3
--- /dev/null
+++ b/gl/fflush.c
@@ -0,0 +1,233 @@
1/* fflush.c -- allow flushing input streams
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Eric Blake. */
18
19#include <config.h>
20
21/* Specification. */
22#include <stdio.h>
23
24#include <errno.h>
25#include <unistd.h>
26
27#include "freading.h"
28
29#include "stdio-impl.h"
30
31#undef fflush
32
33
34#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35/* GNU libc, BeOS, Haiku, Linux libc5 */
36
37/* Clear the stream's ungetc buffer, preserving the value of ftello (fp). */
38static void
39clear_ungetc_buffer_preserving_position (FILE *fp)
40{
41 if (fp->_flags & _IO_IN_BACKUP)
42 /* _IO_free_backup_area is a bit complicated. Simply call fseek. */
43 fseeko (fp, 0, SEEK_CUR);
44}
45
46#else
47
48/* Clear the stream's ungetc buffer. May modify the value of ftello (fp). */
49static void
50clear_ungetc_buffer (FILE *fp)
51{
52# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
53 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
54 if (HASUB (fp))
55 {
56 fp_->_p += fp_->_r;
57 fp_->_r = 0;
58 }
59# elif defined __EMX__ /* emx+gcc */
60 if (fp->_ungetc_count > 0)
61 {
62 fp->_ungetc_count = 0;
63 fp->_rcount = - fp->_rcount;
64 }
65# elif defined _IOERR /* Minix, AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
66 /* Nothing to do. */
67# else /* other implementations */
68 fseeko (fp, 0, SEEK_CUR);
69# endif
70}
71
72#endif
73
74#if ! (defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1)
75/* GNU libc, BeOS, Haiku, Linux libc5 */
76
77# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
78/* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
79
80static int
81disable_seek_optimization (FILE *fp)
82{
83 int saved_flags = fp_->_flags & (__SOPT | __SNPT);
84 fp_->_flags = (fp_->_flags & ~__SOPT) | __SNPT;
85 return saved_flags;
86}
87
88static void
89restore_seek_optimization (FILE *fp, int saved_flags)
90{
91 fp_->_flags = (fp_->_flags & ~(__SOPT | __SNPT)) | saved_flags;
92}
93
94# else
95
96static void
97update_fpos_cache (_GL_ATTRIBUTE_MAYBE_UNUSED FILE *fp,
98 _GL_ATTRIBUTE_MAYBE_UNUSED off_t pos)
99{
100# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
101 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
102# if defined __CYGWIN__ || defined __ANDROID__
103 /* fp_->_offset is typed as an integer. */
104 fp_->_offset = pos;
105# else
106 /* fp_->_offset is an fpos_t. */
107 /* Use a union, since on NetBSD, the compilation flags determine
108 whether fpos_t is typedef'd to off_t or a struct containing a
109 single off_t member. */
110 union
111 {
112 fpos_t f;
113 off_t o;
114 } u;
115 u.o = pos;
116 fp_->_offset = u.f;
117# endif
118 fp_->_flags |= __SOFF;
119# endif
120}
121# endif
122#endif
123
124/* Flush all pending data on STREAM according to POSIX rules. Both
125 output and seekable input streams are supported. */
126int
127rpl_fflush (FILE *stream)
128{
129 /* When stream is NULL, POSIX and C99 only require flushing of "output
130 streams and update streams in which the most recent operation was not
131 input", and all implementations do this.
132
133 When stream is "an output stream or an update stream in which the most
134 recent operation was not input", POSIX and C99 requires that fflush
135 writes out any buffered data, and all implementations do this.
136
137 When stream is, however, an input stream or an update stream in
138 which the most recent operation was input, C99 specifies nothing,
139 and POSIX only specifies behavior if the stream is seekable.
140 mingw, in particular, drops the input buffer, leaving the file
141 descriptor positioned at the end of the input buffer. I.e. ftell
142 (stream) is lost. We don't want to call the implementation's
143 fflush in this case.
144
145 We test ! freading (stream) here, rather than fwriting (stream), because
146 what we need to know is whether the stream holds a "read buffer", and on
147 mingw this is indicated by _IOREAD, regardless of _IOWRT. */
148 if (stream == NULL || ! freading (stream))
149 return fflush (stream);
150
151#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
152 /* GNU libc, BeOS, Haiku, Linux libc5 */
153
154 clear_ungetc_buffer_preserving_position (stream);
155
156 return fflush (stream);
157
158#else
159 {
160 /* What POSIX says:
161 1) About the file-position indicator (-> fseeko, ftello):
162 The file position indicator is incremented by fgetc() and decremented
163 by ungetc():
164 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fgetc.html>
165 "... the fgetc() function shall ... advance the associated file
166 position indicator for the stream ..."
167 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ungetc.html>
168 "The file-position indicator is decremented by each successful
169 call to ungetc()..."
170 2) fflush discards bytes pushed back by ungetc:
171 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
172 "...any characters pushed back onto the stream by ungetc()
173 or ungetwc() that have not subsequently been read from the
174 stream shall be discarded..."
175 This implies implicitly: fflush does not change the file position
176 indicator.
177 3) Effects on the file descriptor, if the file descriptor is capable of
178 seeking:
179 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html>
180 "...the file offset of the underlying open file description shall
181 be set to the file position of the stream..." */
182
183 /* POSIX does not specify fflush behavior for non-seekable input
184 streams. Some implementations purge unread data, some return
185 EBADF, some do nothing. */
186 off_t pos = ftello (stream);
187 if (pos == -1)
188 {
189 errno = EBADF;
190 return EOF;
191 }
192
193 /* Clear the ungetc buffer. */
194 clear_ungetc_buffer (stream);
195
196 /* To get here, we must be flushing a seekable input stream, so the
197 semantics of fpurge are now appropriate to clear the buffer. To
198 avoid losing data, the lseek is also necessary. */
199 {
200 int result = fpurge (stream);
201 if (result != 0)
202 return result;
203 }
204
205# if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
206 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
207
208 {
209 /* Disable seek optimization for the next fseeko call. This tells the
210 following fseeko call to seek to the desired position directly, rather
211 than to seek to a block-aligned boundary. */
212 int saved_flags = disable_seek_optimization (stream);
213 int result = fseeko (stream, pos, SEEK_SET);
214
215 restore_seek_optimization (stream, saved_flags);
216 return result;
217 }
218
219# else
220
221 pos = lseek (fileno (stream), pos, SEEK_SET);
222 if (pos == -1)
223 return EOF;
224 /* After a successful lseek, update the file descriptor's position cache
225 in the stream. */
226 update_fpos_cache (stream, pos);
227
228 return 0;
229
230# endif
231 }
232#endif
233}
diff --git a/gl/filename.h b/gl/filename.h
new file mode 100644
index 0000000..a2400a9
--- /dev/null
+++ b/gl/filename.h
@@ -0,0 +1,112 @@
1/* Basic filename support macros.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* From Paul Eggert and Jim Meyering. */
20
21#ifndef _FILENAME_H
22#define _FILENAME_H
23
24#include <string.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31/* Filename support.
32 ISSLASH(C) tests whether C is a directory separator
33 character.
34 HAS_DEVICE(Filename) tests whether Filename contains a device
35 specification.
36 FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification
37 at the beginning of Filename,
38 index of the part consisting of
39 alternating components and slashes.
40 FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
41 1 when a non-empty device specification
42 can be followed by an empty or relative
43 part,
44 0 when a non-empty device specification
45 must be followed by a slash,
46 0 when device specification don't exist.
47 IS_ABSOLUTE_FILE_NAME(Filename)
48 tests whether Filename is independent of
49 any notion of "current directory".
50 IS_RELATIVE_FILE_NAME(Filename)
51 tests whether Filename may be concatenated
52 to a directory filename.
53 Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
54 relative file name!
55 IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device
56 or directory specification.
57 */
58#if defined _WIN32 || defined __CYGWIN__ \
59 || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
60 /* Native Windows, Cygwin, OS/2, DOS */
61# define ISSLASH(C) ((C) == '/' || (C) == '\\')
62 /* Internal macro: Tests whether a character is a drive letter. */
63# define _IS_DRIVE_LETTER(C) \
64 (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
65 /* Help the compiler optimizing it. This assumes ASCII. */
66# undef _IS_DRIVE_LETTER
67# define _IS_DRIVE_LETTER(C) \
68 (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
69# define HAS_DEVICE(Filename) \
70 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
71# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
72# ifdef __CYGWIN__
73# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
74# else
75 /* On native Windows, OS/2, DOS, the system has the notion of a
76 "current directory" on each drive. */
77# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
78# endif
79# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
80# define IS_ABSOLUTE_FILE_NAME(Filename) \
81 ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
82# else
83# define IS_ABSOLUTE_FILE_NAME(Filename) \
84 (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
85# endif
86# define IS_RELATIVE_FILE_NAME(Filename) \
87 (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
88# define IS_FILE_NAME_WITH_DIR(Filename) \
89 (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
90 || HAS_DEVICE (Filename))
91#else
92 /* Unix */
93# define ISSLASH(C) ((C) == '/')
94# define HAS_DEVICE(Filename) ((void) (Filename), 0)
95# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
96# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
97# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
98# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
99# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
100#endif
101
102/* Deprecated macros. For backward compatibility with old users of the
103 'filename' module. */
104#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
105#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
106
107
108#ifdef __cplusplus
109}
110#endif
111
112#endif /* _FILENAME_H */
diff --git a/gl/float+.h b/gl/float+.h
index 32fb790..e7531e4 100644
--- a/gl/float+.h
+++ b/gl/float+.h
@@ -1,19 +1,19 @@
1/* Supplemental information about the floating-point formats. 1/* Supplemental information about the floating-point formats.
2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2007. 3 Written by Bruno Haible <bruno@clisp.org>, 2007.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _FLOATPLUS_H 18#ifndef _FLOATPLUS_H
19#define _FLOATPLUS_H 19#define _FLOATPLUS_H
diff --git a/gl/float.c b/gl/float.c
index 366945f..f81ff33 100644
--- a/gl/float.c
+++ b/gl/float.c
@@ -1,19 +1,19 @@
1/* Auxiliary definitions for <float.h>. 1/* Auxiliary definitions for <float.h>.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/float.in.h b/gl/float.in.h
index 84e1950..bf2c502 100644
--- a/gl/float.in.h
+++ b/gl/float.in.h
@@ -1,19 +1,19 @@
1/* A correct <float.h>. 1/* A correct <float.h>.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_FLOAT_H 18#ifndef _@GUARD_PREFIX@_FLOAT_H
19 19
@@ -62,8 +62,8 @@
62 62
63/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of 63/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
64 precision in the compiler but 64 bits of precision at runtime. See 64 precision in the compiler but 64 bits of precision at runtime. See
65 <http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>. */ 65 <https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>. */
66#if defined __i386__ && defined __FreeBSD__ 66#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
67/* Number of mantissa units, in base FLT_RADIX. */ 67/* Number of mantissa units, in base FLT_RADIX. */
68# undef LDBL_MANT_DIG 68# undef LDBL_MANT_DIG
69# define LDBL_MANT_DIG 64 69# define LDBL_MANT_DIG 64
@@ -81,7 +81,7 @@
81# define LDBL_MAX_EXP 16384 81# define LDBL_MAX_EXP 16384
82/* Minimum positive normalized number. */ 82/* Minimum positive normalized number. */
83# undef LDBL_MIN 83# undef LDBL_MIN
84# define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */ 84# define LDBL_MIN 3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
85/* Maximum representable finite number. */ 85/* Maximum representable finite number. */
86# undef LDBL_MAX 86# undef LDBL_MAX
87/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }. 87/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
@@ -93,11 +93,14 @@
93 extern const long double LDBL_MAX; 93 extern const long double LDBL_MAX;
94 94
95 Unfortunately, this is not a constant expression. */ 95 Unfortunately, this is not a constant expression. */
96# if !GNULIB_defined_long_double_union
96union gl_long_double_union 97union gl_long_double_union
97 { 98 {
98 struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd; 99 struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
99 long double ld; 100 long double ld;
100 }; 101 };
102# define GNULIB_defined_long_double_union 1
103# endif
101extern const union gl_long_double_union gl_LDBL_MAX; 104extern const union gl_long_double_union gl_LDBL_MAX;
102# define LDBL_MAX (gl_LDBL_MAX.ld) 105# define LDBL_MAX (gl_LDBL_MAX.ld)
103/* Minimum e such that 10^e is in the range of normalized numbers. */ 106/* Minimum e such that 10^e is in the range of normalized numbers. */
@@ -146,11 +149,14 @@ extern const union gl_long_double_union gl_LDBL_MAX;
146 149
147 Unfortunately, this is not a constant expression, and the latter expression 150 Unfortunately, this is not a constant expression, and the latter expression
148 does not work well when GCC is optimizing.. */ 151 does not work well when GCC is optimizing.. */
152# if !GNULIB_defined_long_double_union
149union gl_long_double_union 153union gl_long_double_union
150 { 154 {
151 struct { double hi; double lo; } dd; 155 struct { double hi; double lo; } dd;
152 long double ld; 156 long double ld;
153 }; 157 };
158# define GNULIB_defined_long_double_union 1
159# endif
154extern const union gl_long_double_union gl_LDBL_MAX; 160extern const union gl_long_double_union gl_LDBL_MAX;
155# define LDBL_MAX (gl_LDBL_MAX.ld) 161# define LDBL_MAX (gl_LDBL_MAX.ld)
156#endif 162#endif
diff --git a/gl/floor.c b/gl/floor.c
index cf29b19..238f487 100644
--- a/gl/floor.c
+++ b/gl/floor.c
@@ -1,18 +1,18 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2010-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation, either version 3 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18 18
@@ -44,7 +44,7 @@
44 44
45/* MSVC with option -fp:strict refuses to compile constant initializers that 45/* MSVC with option -fp:strict refuses to compile constant initializers that
46 contain floating-point operations. Pacify this compiler. */ 46 contain floating-point operations. Pacify this compiler. */
47#ifdef _MSC_VER 47#if defined _MSC_VER && !defined __clang__
48# pragma fenv_access (off) 48# pragma fenv_access (off)
49#endif 49#endif
50 50
diff --git a/gl/floorf.c b/gl/floorf.c
index bbd3382..e465c18 100644
--- a/gl/floorf.c
+++ b/gl/floorf.c
@@ -1,18 +1,18 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation, either version 3 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18 18
diff --git a/gl/fopen.c b/gl/fopen.c
new file mode 100644
index 0000000..f8469a0
--- /dev/null
+++ b/gl/fopen.c
@@ -0,0 +1,229 @@
1/* Open a stream to a file.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18
19/* If the user's config.h happens to include <stdio.h>, let it include only
20 the system's <stdio.h> here, so that orig_fopen doesn't recurse to
21 rpl_fopen. */
22#define _GL_ALREADY_INCLUDING_STDIO_H
23#include <config.h>
24
25/* Get the original definition of fopen. It might be defined as a macro. */
26#include <stdio.h>
27#undef _GL_ALREADY_INCLUDING_STDIO_H
28
29static FILE *
30orig_fopen (const char *filename, const char *mode)
31{
32 return fopen (filename, mode);
33}
34
35/* Specification. */
36/* Write "stdio.h" here, not <stdio.h>, otherwise OSF/1 5.1 DTK cc eliminates
37 this include because of the preliminary #include <stdio.h> above. */
38#include "stdio.h"
39
40#include <errno.h>
41#include <fcntl.h>
42#include <string.h>
43#include <unistd.h>
44#include <sys/types.h>
45#include <sys/stat.h>
46
47FILE *
48rpl_fopen (const char *filename, const char *mode)
49{
50 int open_direction;
51 int open_flags;
52#if GNULIB_FOPEN_GNU
53 bool open_flags_gnu;
54# define BUF_SIZE 80
55 char fdopen_mode_buf[BUF_SIZE + 1];
56#endif
57
58#if defined _WIN32 && ! defined __CYGWIN__
59 if (strcmp (filename, "/dev/null") == 0)
60 filename = "NUL";
61#endif
62
63 /* Parse the mode. */
64 open_direction = 0;
65 open_flags = 0;
66#if GNULIB_FOPEN_GNU
67 open_flags_gnu = false;
68#endif
69 {
70 const char *p = mode;
71#if GNULIB_FOPEN_GNU
72 char *q = fdopen_mode_buf;
73#endif
74
75 for (; *p != '\0'; p++)
76 {
77 switch (*p)
78 {
79 case 'r':
80 open_direction = O_RDONLY;
81#if GNULIB_FOPEN_GNU
82 if (q < fdopen_mode_buf + BUF_SIZE)
83 *q++ = *p;
84#endif
85 continue;
86 case 'w':
87 open_direction = O_WRONLY;
88 open_flags |= O_CREAT | O_TRUNC;
89#if GNULIB_FOPEN_GNU
90 if (q < fdopen_mode_buf + BUF_SIZE)
91 *q++ = *p;
92#endif
93 continue;
94 case 'a':
95 open_direction = O_WRONLY;
96 open_flags |= O_CREAT | O_APPEND;
97#if GNULIB_FOPEN_GNU
98 if (q < fdopen_mode_buf + BUF_SIZE)
99 *q++ = *p;
100#endif
101 continue;
102 case 'b':
103 /* While it is non-standard, O_BINARY is guaranteed by
104 gnulib <fcntl.h>. We can also assume that orig_fopen
105 supports the 'b' flag. */
106 open_flags |= O_BINARY;
107#if GNULIB_FOPEN_GNU
108 if (q < fdopen_mode_buf + BUF_SIZE)
109 *q++ = *p;
110#endif
111 continue;
112 case '+':
113 open_direction = O_RDWR;
114#if GNULIB_FOPEN_GNU
115 if (q < fdopen_mode_buf + BUF_SIZE)
116 *q++ = *p;
117#endif
118 continue;
119#if GNULIB_FOPEN_GNU
120 case 'x':
121 open_flags |= O_EXCL;
122 open_flags_gnu = true;
123 continue;
124 case 'e':
125 open_flags |= O_CLOEXEC;
126 open_flags_gnu = true;
127 continue;
128#endif
129 default:
130 break;
131 }
132#if GNULIB_FOPEN_GNU
133 /* The rest of the mode string can be a platform-dependent extension.
134 Copy it unmodified. */
135 {
136 size_t len = strlen (p);
137 if (len > fdopen_mode_buf + BUF_SIZE - q)
138 len = fdopen_mode_buf + BUF_SIZE - q;
139 memcpy (q, p, len);
140 q += len;
141 }
142#endif
143 break;
144 }
145#if GNULIB_FOPEN_GNU
146 *q = '\0';
147#endif
148 }
149
150#if FOPEN_TRAILING_SLASH_BUG
151 /* Fail if the mode requires write access and the filename ends in a slash,
152 as POSIX says such a filename must name a directory
153 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
154 "A pathname that contains at least one non-<slash> character and that
155 ends with one or more trailing <slash> characters shall not be resolved
156 successfully unless the last pathname component before the trailing
157 <slash> characters names an existing directory"
158 If the named file already exists as a directory, then if a mode that
159 requires write access is specified, fopen() must fail because POSIX
160 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html>
161 says that it fails with errno = EISDIR in this case.
162 If the named file does not exist or does not name a directory, then
163 fopen() must fail since the file does not contain a '.' directory. */
164 {
165 size_t len = strlen (filename);
166 if (len > 0 && filename[len - 1] == '/')
167 {
168 int fd;
169 struct stat statbuf;
170 FILE *fp;
171
172 if (open_direction != O_RDONLY)
173 {
174 errno = EISDIR;
175 return NULL;
176 }
177
178 fd = open (filename, open_direction | open_flags,
179 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
180 if (fd < 0)
181 return NULL;
182
183 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
184 {
185 close (fd);
186 errno = ENOTDIR;
187 return NULL;
188 }
189
190# if GNULIB_FOPEN_GNU
191 fp = fdopen (fd, fdopen_mode_buf);
192# else
193 fp = fdopen (fd, mode);
194# endif
195 if (fp == NULL)
196 {
197 int saved_errno = errno;
198 close (fd);
199 errno = saved_errno;
200 }
201 return fp;
202 }
203 }
204#endif
205
206#if GNULIB_FOPEN_GNU
207 if (open_flags_gnu)
208 {
209 int fd;
210 FILE *fp;
211
212 fd = open (filename, open_direction | open_flags,
213 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
214 if (fd < 0)
215 return NULL;
216
217 fp = fdopen (fd, fdopen_mode_buf);
218 if (fp == NULL)
219 {
220 int saved_errno = errno;
221 close (fd);
222 errno = saved_errno;
223 }
224 return fp;
225 }
226#endif
227
228 return orig_fopen (filename, mode);
229}
diff --git a/gl/fpurge.c b/gl/fpurge.c
new file mode 100644
index 0000000..0dcb2b7
--- /dev/null
+++ b/gl/fpurge.c
@@ -0,0 +1,150 @@
1/* Flushing buffers of a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
23# if HAVE_STDIO_EXT_H
24# include <stdio_ext.h>
25# endif
26#endif
27#include <stdlib.h>
28
29#include "stdio-impl.h"
30
31int
32fpurge (FILE *fp)
33{
34#if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.10, Android API >= 23, musl libc */
35
36 __fpurge (fp);
37 /* The __fpurge function does not have a return value. */
38 return 0;
39
40#elif HAVE_FPURGE /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin >= 1.7 */
41
42 /* Call the system's fpurge function. */
43# undef fpurge
44# if !HAVE_DECL_FPURGE
45 extern int fpurge (FILE *);
46# endif
47 int result = fpurge (fp);
48# if defined __sferror || defined __DragonFly__ || defined __ANDROID__
49 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
50 if (result == 0)
51 /* Correct the invariants that fpurge broke.
52 <stdio.h> on BSD systems says:
53 "The following always hold: if _flags & __SRD, _w is 0."
54 If this invariant is not fulfilled and the stream is read-write but
55 currently reading, subsequent putc or fputc calls will write directly
56 into the buffer, although they shouldn't be allowed to. */
57 if ((fp_->_flags & __SRD) != 0)
58 fp_->_w = 0;
59# endif
60 return result;
61
62#else
63
64 /* Most systems provide FILE as a struct and the necessary bitmask in
65 <stdio.h>, because they need it for implementing getc() and putc() as
66 fast macros. */
67# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
68 /* GNU libc, BeOS, Haiku, Linux libc5 */
69 fp->_IO_read_end = fp->_IO_read_ptr;
70 fp->_IO_write_ptr = fp->_IO_write_base;
71 /* Avoid memory leak when there is an active ungetc buffer. */
72 if (fp->_IO_save_base != NULL)
73 {
74 free (fp->_IO_save_base);
75 fp->_IO_save_base = NULL;
76 }
77 return 0;
78# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
79 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
80 fp_->_p = fp_->_bf._base;
81 fp_->_r = 0;
82 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
83 ? fp_->_bf._size
84 : 0);
85 /* Avoid memory leak when there is an active ungetc buffer. */
86 if (fp_ub._base != NULL)
87 {
88 if (fp_ub._base != fp_->_ubuf)
89 free (fp_ub._base);
90 fp_ub._base = NULL;
91 }
92 return 0;
93# elif defined __EMX__ /* emx+gcc */
94 fp->_ptr = fp->_buffer;
95 fp->_rcount = 0;
96 fp->_wcount = 0;
97 fp->_ungetc_count = 0;
98 return 0;
99# elif defined __minix /* Minix */
100 fp->_ptr = fp->_buf;
101 if (fp->_ptr != NULL)
102 fp->_count = 0;
103 return 0;
104# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
105 fp_->_ptr = fp_->_base;
106 if (fp_->_ptr != NULL)
107 fp_->_cnt = 0;
108 return 0;
109# elif defined __UCLIBC__ /* uClibc */
110# ifdef __STDIO_BUFFERS
111 if (fp->__modeflags & __FLAG_WRITING)
112 fp->__bufpos = fp->__bufstart;
113 else if (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING))
114 fp->__bufpos = fp->__bufread;
115# endif
116 return 0;
117# elif defined __QNX__ /* QNX */
118 fp->_Rback = fp->_Back + sizeof (fp->_Back);
119 fp->_Rsave = NULL;
120 if (fp->_Mode & 0x2000 /* _MWRITE */)
121 /* fp->_Buf <= fp->_Next <= fp->_Wend */
122 fp->_Next = fp->_Buf;
123 else
124 /* fp->_Buf <= fp->_Next <= fp->_Rend */
125 fp->_Rend = fp->_Next;
126 return 0;
127# elif defined __MINT__ /* Atari FreeMiNT */
128 if (fp->__pushed_back)
129 {
130 fp->__bufp = fp->__pushback_bufp;
131 fp->__pushed_back = 0;
132 }
133 /* Preserve the current file position. */
134 if (fp->__target != -1)
135 fp->__target += fp->__bufp - fp->__buffer;
136 fp->__bufp = fp->__buffer;
137 /* Nothing in the buffer, next getc is nontrivial. */
138 fp->__get_limit = fp->__bufp;
139 /* Nothing in the buffer, next putc is nontrivial. */
140 fp->__put_limit = fp->__buffer;
141 return 0;
142# elif defined EPLAN9 /* Plan9 */
143 fp->rp = fp->wp = fp->lp = fp->buf;
144 return 0;
145# else
146# error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
147# endif
148
149#endif
150}
diff --git a/gl/freading.c b/gl/freading.c
new file mode 100644
index 0000000..b9377cb
--- /dev/null
+++ b/gl/freading.c
@@ -0,0 +1,76 @@
1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include "freading.h"
21
22#include "stdio-impl.h"
23
24/* Don't use glibc's __freading function in glibc < 2.7, see
25 <https://sourceware.org/bugzilla/show_bug.cgi?id=4359> */
26#if !(HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)))
27
28bool
29freading (FILE *fp)
30{
31 /* Most systems provide FILE as a struct and the necessary bitmask in
32 <stdio.h>, because they need it for implementing getc() and putc() as
33 fast macros. */
34# if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
35 /* GNU libc, BeOS, Haiku, Linux libc5 */
36 return ((fp->_flags & _IO_NO_WRITES) != 0
37 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
38 && fp->_IO_read_base != NULL));
39# elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
40 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin < 1.7.34, Minix 3, Android */
41 return (fp_->_flags & __SRD) != 0;
42# elif defined __EMX__ /* emx+gcc */
43 return (fp->_flags & _IOREAD) != 0;
44# elif defined __minix /* Minix */
45 return (fp->_flags & _IOREADING) != 0;
46# elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
47# if defined __sun /* Solaris */
48 return (fp_->_flag & _IOREAD) != 0 && (fp_->_flag & _IOWRT) == 0;
49# else
50 return (fp_->_flag & _IOREAD) != 0;
51# endif
52# elif defined __UCLIBC__ /* uClibc */
53 return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
54# elif defined __QNX__ /* QNX */
55 return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
56 || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
57# elif defined __MINT__ /* Atari FreeMiNT */
58 if (!fp->__mode.__write)
59 return 1;
60 if (!fp->__mode.__read)
61 return 0;
62# ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
63 return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
64# else
65 return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit ??*/);
66# endif
67# elif defined EPLAN9 /* Plan9 */
68 if (fp->state == 0 /* CLOSED */ || fp->state == 4 /* WR */)
69 return 0;
70 return (fp->state == 3 /* RD */ && (fp->bufl == 0 || fp->rp < fp->wp));
71# else
72# error "Please port gnulib freading.c to your platform!"
73# endif
74}
75
76#endif
diff --git a/gl/freading.h b/gl/freading.h
new file mode 100644
index 0000000..27b3abb
--- /dev/null
+++ b/gl/freading.h
@@ -0,0 +1,54 @@
1/* Retrieve information about a FILE stream.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <stdio.h>
18
19/* Return true if the stream STREAM is opened read-only, or if the
20 last operation on the stream was a read operation. Return false if
21 the stream is opened write-only or append-only, or if it supports
22 writing and there is no current read operation (such as fgetc).
23
24 freading and fwriting will never both be true. If STREAM supports
25 both reads and writes, then:
26 - both freading and fwriting might be false when the stream is first
27 opened, after read encounters EOF, or after fflush,
28 - freading might be false or true and fwriting might be false
29 after repositioning (such as fseek, fsetpos, or rewind),
30 depending on the underlying implementation.
31
32 STREAM must not be wide-character oriented. */
33
34#if HAVE___FREADING && (!defined __GLIBC__ || defined __UCLIBC__ || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7))
35/* Solaris >= 7, UnixWare >= 7.1.4.MP4, Cygwin >= 1.7.34, Android API >= 29, not glibc >= 2.2, but glibc >= 2.7, or musl libc */
36
37# if HAVE_STDIO_EXT_H
38# include <stdio_ext.h>
39# endif
40# define freading(stream) (__freading (stream) != 0)
41
42#else
43
44# ifdef __cplusplus
45extern "C" {
46# endif
47
48extern bool freading (FILE *stream) _GL_ATTRIBUTE_PURE;
49
50# ifdef __cplusplus
51}
52# endif
53
54#endif
diff --git a/gl/free.c b/gl/free.c
new file mode 100644
index 0000000..372a6b0
--- /dev/null
+++ b/gl/free.c
@@ -0,0 +1,53 @@
1/* Make free() preserve errno.
2
3 Copyright (C) 2003, 2006, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#include <config.h>
21
22/* Specification. */
23#include <stdlib.h>
24
25/* A function definition is only needed if HAVE_FREE_POSIX is not defined. */
26#if !HAVE_FREE_POSIX
27
28# include <errno.h>
29
30void
31rpl_free (void *p)
32# undef free
33{
34# if defined __GNUC__ && !defined __clang__
35 /* An invalid GCC optimization
36 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396>
37 would optimize away the assignments in the code below, when link-time
38 optimization (LTO) is enabled. Make the code more complicated, so that
39 GCC does not grok how to optimize it. */
40 int err[2];
41 err[0] = errno;
42 err[1] = errno;
43 errno = 0;
44 free (p);
45 errno = err[errno == 0];
46# else
47 int err = errno;
48 free (p);
49 errno = err;
50# endif
51}
52
53#endif
diff --git a/gl/fseek.c b/gl/fseek.c
new file mode 100644
index 0000000..9764375
--- /dev/null
+++ b/gl/fseek.c
@@ -0,0 +1,30 @@
1/* An fseek() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22/* Get off_t. */
23#include <unistd.h>
24
25int
26fseek (FILE *fp, long offset, int whence)
27{
28 /* Use the replacement fseeko function with all its workarounds. */
29 return fseeko (fp, (off_t)offset, whence);
30}
diff --git a/gl/fseeko.c b/gl/fseeko.c
new file mode 100644
index 0000000..89a7087
--- /dev/null
+++ b/gl/fseeko.c
@@ -0,0 +1,164 @@
1/* An fseeko() function that, together with fflush(), is POSIX compliant.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22/* Get off_t, lseek, _POSIX_VERSION. */
23#include <unistd.h>
24
25#include "stdio-impl.h"
26
27int
28fseeko (FILE *fp, off_t offset, int whence)
29#undef fseeko
30#if !HAVE_FSEEKO
31# undef fseek
32# define fseeko fseek
33#endif
34#if _GL_WINDOWS_64_BIT_OFF_T
35# undef fseeko
36# if HAVE__FSEEKI64 && HAVE_DECL__FSEEKI64 /* msvc, mingw since msvcrt8.0, mingw64 */
37# define fseeko _fseeki64
38# else /* mingw before msvcrt8.0 */
39# define fseeko fseeko64
40# endif
41#endif
42{
43#if LSEEK_PIPE_BROKEN
44 /* mingw gives bogus answers rather than failure on non-seekable files. */
45 if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
46 return EOF;
47#endif
48
49 /* These tests are based on fpurge.c. */
50#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
51 /* GNU libc, BeOS, Haiku, Linux libc5 */
52 if (fp->_IO_read_end == fp->_IO_read_ptr
53 && fp->_IO_write_ptr == fp->_IO_write_base
54 && fp->_IO_save_base == NULL)
55#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
56 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
57# if defined __SL64 && defined __SCLE /* Cygwin */
58 if ((fp->_flags & __SL64) == 0)
59 {
60 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
61 mode; but has an fseeko that requires 64-bit mode. */
62 FILE *tmp = fopen ("/dev/null", "r");
63 if (!tmp)
64 return -1;
65 fp->_flags |= __SL64;
66 fp->_seek64 = tmp->_seek64;
67 fclose (tmp);
68 }
69# endif
70 if (fp_->_p == fp_->_bf._base
71 && fp_->_r == 0
72 && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
73 ? fp_->_bf._size
74 : 0)
75 && fp_ub._base == NULL)
76#elif defined __EMX__ /* emx+gcc */
77 if (fp->_ptr == fp->_buffer
78 && fp->_rcount == 0
79 && fp->_wcount == 0
80 && fp->_ungetc_count == 0)
81#elif defined __minix /* Minix */
82 if (fp_->_ptr == fp_->_buf
83 && (fp_->_ptr == NULL || fp_->_count == 0))
84#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
85 if (fp_->_ptr == fp_->_base
86 && (fp_->_ptr == NULL || fp_->_cnt == 0))
87#elif defined __UCLIBC__ /* uClibc */
88 if (((fp->__modeflags & __FLAG_WRITING) == 0
89 || fp->__bufpos == fp->__bufstart)
90 && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
91 || fp->__bufpos == fp->__bufread))
92#elif defined __QNX__ /* QNX */
93 if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
94 && fp->_Rback == fp->_Back + sizeof (fp->_Back)
95 && fp->_Rsave == NULL)
96#elif defined __MINT__ /* Atari FreeMiNT */
97 if (fp->__bufp == fp->__buffer
98 && fp->__get_limit == fp->__bufp
99 && fp->__put_limit == fp->__bufp
100 && !fp->__pushed_back)
101#elif defined EPLAN9 /* Plan9 */
102 if (fp->rp == fp->buf
103 && fp->wp == fp->buf)
104#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
105 /* Cross-compiling to some other system advertising conformance to
106 POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
107 If this assumption is incorrect, please report the bug to
108 bug-gnulib. */
109 if (0)
110#else
111 #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
112#endif
113 {
114 /* We get here when an fflush() call immediately preceded this one (or
115 if ftell() has created buffers but no I/O has occurred on a
116 newly-opened stream). We know there are no buffers. */
117 off_t pos = lseek (fileno (fp), offset, whence);
118 if (pos == -1)
119 {
120#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
121 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
122 fp_->_flags &= ~__SOFF;
123#endif
124 return -1;
125 }
126
127#if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
128 /* GNU libc, BeOS, Haiku, Linux libc5 */
129 fp->_flags &= ~_IO_EOF_SEEN;
130 fp->_offset = pos;
131#elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
132 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
133# if defined __CYGWIN__ || (defined __NetBSD__ && __NetBSD_Version__ >= 600000000) || defined __minix
134 /* fp_->_offset is typed as an integer. */
135 fp_->_offset = pos;
136# else
137 /* fp_->_offset is an fpos_t. */
138 {
139 /* Use a union, since on NetBSD, the compilation flags
140 determine whether fpos_t is typedef'd to off_t or a struct
141 containing a single off_t member. */
142 union
143 {
144 fpos_t f;
145 off_t o;
146 } u;
147 u.o = pos;
148 fp_->_offset = u.f;
149 }
150# endif
151 fp_->_flags |= __SOFF;
152 fp_->_flags &= ~__SEOF;
153#elif defined __EMX__ /* emx+gcc */
154 fp->_flags &= ~_IOEOF;
155#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, UnixWare, mingw, MSVC, NonStop Kernel, OpenVMS */
156 fp_->_flag &= ~_IOEOF;
157#elif defined __MINT__ /* Atari FreeMiNT */
158 fp->__offset = pos;
159 fp->__eof = 0;
160#endif
161 return 0;
162 }
163 return fseeko (fp, offset, whence);
164}
diff --git a/gl/fstat.c b/gl/fstat.c
new file mode 100644
index 0000000..6a23500
--- /dev/null
+++ b/gl/fstat.c
@@ -0,0 +1,94 @@
1/* fstat() replacement.
2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* If the user's config.h happens to include <sys/stat.h>, let it include only
18 the system's <sys/stat.h> here, so that orig_fstat doesn't recurse to
19 rpl_fstat. */
20#define __need_system_sys_stat_h
21#include <config.h>
22
23/* Get the original definition of fstat. It might be defined as a macro. */
24#include <sys/types.h>
25#include <sys/stat.h>
26#undef __need_system_sys_stat_h
27
28#if defined _WIN32 && ! defined __CYGWIN__
29# define WINDOWS_NATIVE
30#endif
31
32#if !defined WINDOWS_NATIVE
33
34static int
35orig_fstat (int fd, struct stat *buf)
36{
37 return fstat (fd, buf);
38}
39
40#endif
41
42/* Specification. */
43#ifdef __osf__
44/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
45 eliminates this include because of the preliminary #include <sys/stat.h>
46 above. */
47# include "sys/stat.h"
48#else
49# include <sys/stat.h>
50#endif
51
52#include "stat-time.h"
53
54#include <errno.h>
55#include <unistd.h>
56#ifdef WINDOWS_NATIVE
57# define WIN32_LEAN_AND_MEAN
58# include <windows.h>
59# if GNULIB_MSVC_NOTHROW
60# include "msvc-nothrow.h"
61# else
62# include <io.h>
63# endif
64# include "stat-w32.h"
65#endif
66
67int
68rpl_fstat (int fd, struct stat *buf)
69{
70#if REPLACE_FCHDIR && REPLACE_OPEN_DIRECTORY
71 /* Handle the case when rpl_open() used a dummy file descriptor to work
72 around an open() that can't normally visit directories. */
73 const char *name = _gl_directory_name (fd);
74 if (name != NULL)
75 return stat (name, buf);
76#endif
77
78#ifdef WINDOWS_NATIVE
79 /* Fill the fields ourselves, because the original fstat function returns
80 values for st_atime, st_mtime, st_ctime that depend on the current time
81 zone. See
82 <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
83 HANDLE h = (HANDLE) _get_osfhandle (fd);
84
85 if (h == INVALID_HANDLE_VALUE)
86 {
87 errno = EBADF;
88 return -1;
89 }
90 return _gl_fstat_by_handle (h, NULL, buf);
91#else
92 return stat_time_normalize (orig_fstat (fd, buf), buf);
93#endif
94}
diff --git a/gl/fsusage.c b/gl/fsusage.c
index 6103ecf..f6f4b1c 100644
--- a/gl/fsusage.c
+++ b/gl/fsusage.c
@@ -1,20 +1,20 @@
1/* fsusage.c -- return space usage of mounted file systems 1/* fsusage.c -- return space usage of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2013 Free Software 3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation, either version 3 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
@@ -43,23 +43,11 @@
43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ 43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
44# include <sys/fs/s5param.h> 44# include <sys/fs/s5param.h>
45# endif 45# endif
46# if defined HAVE_SYS_FILSYS_H && !defined _CRAY
47# include <sys/filsys.h> /* SVR2 */
48# endif
49# if HAVE_SYS_STATFS_H 46# if HAVE_SYS_STATFS_H
50# include <sys/statfs.h> 47# include <sys/statfs.h>
51# endif 48# endif
52# if HAVE_DUSTAT_H /* AIX PS/2 */
53# include <sys/dustat.h>
54# endif
55# include "full-read.h"
56#endif 49#endif
57 50
58/* The results of open() in this file are not used with fchdir,
59 therefore save some unnecessary work in fchdir.c. */
60#undef open
61#undef close
62
63/* Many space usage primitives use all 1 bits to denote a value that is 51/* Many space usage primitives use all 1 bits to denote a value that is
64 not applicable or unknown. Propagate this information by returning 52 not applicable or unknown. Propagate this information by returning
65 a uintmax_t value that is all 1 bits if X is all 1 bits, even if X 53 a uintmax_t value that is all 1 bits if X is all 1 bits, even if X
@@ -143,7 +131,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
143 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (vfsd.f_bavail) != 0; 131 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (vfsd.f_bavail) != 0;
144 fsp->fsu_files = PROPAGATE_ALL_ONES (vfsd.f_files); 132 fsp->fsu_files = PROPAGATE_ALL_ONES (vfsd.f_files);
145 fsp->fsu_ffree = PROPAGATE_ALL_ONES (vfsd.f_ffree); 133 fsp->fsu_ffree = PROPAGATE_ALL_ONES (vfsd.f_ffree);
146 fsp->fsu_favail = PROPAGATE_ALL_ONES (vfsd.f_favail);
147 return 0; 134 return 0;
148 } 135 }
149 136
@@ -161,58 +148,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
161 ? PROPAGATE_ALL_ONES (fsd.f_frsize) 148 ? PROPAGATE_ALL_ONES (fsd.f_frsize)
162 : PROPAGATE_ALL_ONES (fsd.f_bsize)); 149 : PROPAGATE_ALL_ONES (fsd.f_bsize));
163 150
164#elif defined STAT_STATFS2_FS_DATA /* Ultrix */
165
166 struct fs_data fsd;
167
168 if (statfs (file, &fsd) != 1)
169 return -1;
170
171 fsp->fsu_blocksize = 1024;
172 fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.fd_req.btot);
173 fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.fd_req.bfree);
174 fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.fd_req.bfreen);
175 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.fd_req.bfreen) != 0;
176 fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
177 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
178 fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
179
180#elif defined STAT_READ_FILSYS /* SVR2 */
181# ifndef SUPERBOFF
182# define SUPERBOFF (SUPERB * 512)
183# endif
184
185 struct filsys fsd;
186 int fd;
187
188 if (! disk)
189 {
190 errno = 0;
191 return -1;
192 }
193
194 fd = open (disk, O_RDONLY);
195 if (fd < 0)
196 return -1;
197 lseek (fd, (off_t) SUPERBOFF, 0);
198 if (full_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
199 {
200 close (fd);
201 return -1;
202 }
203 close (fd);
204
205 fsp->fsu_blocksize = (fsd.s_type == Fs2b ? 1024 : 512);
206 fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.s_fsize);
207 fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.s_tfree);
208 fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree);
209 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
210 fsp->fsu_files = (fsd.s_isize == -1
211 ? UINTMAX_MAX
212 : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
213 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
214 fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.s_tinode);
215
216#elif defined STAT_STATFS3_OSF1 /* OSF/1 */ 151#elif defined STAT_STATFS3_OSF1 /* OSF/1 */
217 152
218 struct statfs fsd; 153 struct statfs fsd;
@@ -266,12 +201,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
266 201
267 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); 202 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
268 203
269#elif defined STAT_STATFS4 /* SVR3, Dynix, old Irix, old AIX, \ 204#elif defined STAT_STATFS4 /* SVR3, old Irix */
270 Dolphin */
271
272# if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN
273# define f_bavail f_bfree
274# endif
275 205
276 struct statfs fsd; 206 struct statfs fsd;
277 207
@@ -281,11 +211,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
281 /* Empirically, the block counts on most SVR3 and SVR3-derived 211 /* Empirically, the block counts on most SVR3 and SVR3-derived
282 systems seem to always be in terms of 512-byte blocks, 212 systems seem to always be in terms of 512-byte blocks,
283 no matter what value f_bsize has. */ 213 no matter what value f_bsize has. */
284# if _AIX || defined _CRAY
285 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_bsize);
286# else
287 fsp->fsu_blocksize = 512; 214 fsp->fsu_blocksize = 512;
288# endif
289 215
290#endif 216#endif
291 217
@@ -299,38 +225,9 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
299 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0; 225 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.f_bavail) != 0;
300 fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files); 226 fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.f_files);
301 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree); 227 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.f_ffree);
302 fsp->fsu_favail = PROPAGATE_ALL_ONES (fsd.f_ffree);
303 228
304#endif 229#endif
305 230
306 (void) disk; /* avoid argument-unused warning */ 231 (void) disk; /* avoid argument-unused warning */
307 return 0; 232 return 0;
308} 233}
309
310#if defined _AIX && defined _I386
311/* AIX PS/2 does not supply statfs. */
312
313int
314statfs (char *file, struct statfs *fsb)
315{
316 struct stat stats;
317 struct dustat fsd;
318
319 if (stat (file, &stats) != 0)
320 return -1;
321 if (dustat (stats.st_dev, 0, &fsd, sizeof (fsd)))
322 return -1;
323 fsb->f_type = 0;
324 fsb->f_bsize = fsd.du_bsize;
325 fsb->f_blocks = fsd.du_fsize - fsd.du_isize;
326 fsb->f_bfree = fsd.du_tfree;
327 fsb->f_bavail = fsd.du_tfree;
328 fsb->f_files = (fsd.du_isize - 2) * fsd.du_inopb;
329 fsb->f_ffree = fsd.du_tinode;
330 fsb->f_favail = fsd.du_tinode;
331 fsb->f_fsid.val[0] = fsd.du_site;
332 fsb->f_fsid.val[1] = fsd.du_pckno;
333 return 0;
334}
335
336#endif /* _AIX && _I386 */
diff --git a/gl/fsusage.h b/gl/fsusage.h
index e2654fd..9630b04 100644
--- a/gl/fsusage.h
+++ b/gl/fsusage.h
@@ -1,20 +1,20 @@
1/* fsusage.h -- declarations for file system space usage info 1/* fsusage.h -- declarations for file system space usage info
2 2
3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2013 Free Software 3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation, either version 3 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* Space usage statistics for a file system. Blocks are 512-byte. */ 19/* Space usage statistics for a file system. Blocks are 512-byte. */
20 20
@@ -22,7 +22,6 @@
22# define FSUSAGE_H_ 22# define FSUSAGE_H_
23 23
24# include <stdint.h> 24# include <stdint.h>
25# include <stdbool.h>
26 25
27struct fs_usage 26struct fs_usage
28{ 27{
@@ -32,8 +31,7 @@ struct fs_usage
32 uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */ 31 uintmax_t fsu_bavail; /* Free blocks available to non-superuser. */
33 bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */ 32 bool fsu_bavail_top_bit_set; /* 1 if fsu_bavail represents a value < 0. */
34 uintmax_t fsu_files; /* Total file nodes. */ 33 uintmax_t fsu_files; /* Total file nodes. */
35 uintmax_t fsu_ffree; /* Free file nodes to superuser. */ 34 uintmax_t fsu_ffree; /* Free file nodes. */
36 uintmax_t fsu_favail; /* Free file nodes to non-superuser. */
37}; 35};
38 36
39int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp); 37int get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp);
diff --git a/gl/ftell.c b/gl/ftell.c
new file mode 100644
index 0000000..ce2bd54
--- /dev/null
+++ b/gl/ftell.c
@@ -0,0 +1,37 @@
1/* An ftell() function that works around platform bugs.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <errno.h>
23#include <limits.h>
24
25long
26ftell (FILE *fp)
27{
28 /* Use the replacement ftello function with all its workarounds. */
29 off_t offset = ftello (fp);
30 if (LONG_MIN <= offset && offset <= LONG_MAX)
31 return /* (long) */ offset;
32 else
33 {
34 errno = EOVERFLOW;
35 return -1;
36 }
37}
diff --git a/gl/ftello.c b/gl/ftello.c
new file mode 100644
index 0000000..14184e5
--- /dev/null
+++ b/gl/ftello.c
@@ -0,0 +1,157 @@
1/* An ftello() function that works around platform bugs.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <stdio.h>
21
22#include <errno.h>
23#include "intprops.h"
24
25/* Get lseek. */
26#include <unistd.h>
27
28#include "stdio-impl.h"
29
30off_t
31ftello (FILE *fp)
32#undef ftello
33#if !HAVE_FTELLO
34# undef ftell
35# define ftello ftell
36#endif
37#if _GL_WINDOWS_64_BIT_OFF_T
38# undef ftello
39# if HAVE__FTELLI64 /* msvc, mingw64 */
40# define ftello _ftelli64
41# else /* mingw */
42# define ftello ftello64
43# endif
44#endif
45{
46#if FTELLO_BROKEN_AFTER_UNGETC /* macOS >= 10.15 */
47 /* The system's ftello() is completely broken, because it calls __sflush,
48 which makes side effects on the stream. */
49
50 /* Handle non-seekable files first. */
51 if (fp->_file < 0 || fp->_seek == NULL)
52 {
53 errno = ESPIPE;
54 return -1;
55 }
56
57 /* Determine the current offset, ignoring buffered and pushed-back bytes. */
58 off_t pos;
59
60 if (fp->_flags & __SOFF)
61 pos = fp->_offset;
62 else
63 {
64 pos = fp->_seek (fp->_cookie, 0, SEEK_CUR);
65 if (pos < 0)
66 return -1;
67 if (fp->_flags & __SOPT)
68 {
69 fp->_offset = pos;
70 fp->_flags |= __SOFF;
71 }
72 }
73
74 if (fp->_flags & __SRD)
75 {
76 /* Now consider buffered and pushed-back bytes from ungetc. */
77 if (fp->_ub._base != NULL)
78 /* Considering the buffered bytes, we are at position
79 pos - fp->_ur.
80 Considering also the pushed-back bytes, we are at position
81 pos - fp->_ur - fp->_r. */
82 pos = pos - fp->_ur - fp->_r;
83 else
84 /* Considering the buffered bytes, we are at position
85 pos - fp->_r. */
86 pos = pos - fp->_r;
87 if (pos < 0)
88 {
89 errno = EIO;
90 return -1;
91 }
92 }
93 else if ((fp->_flags & __SWR) && fp->_p != NULL)
94 {
95 /* Consider the buffered bytes. */
96 off_t buffered = fp->_p - fp->_bf._base;
97
98 /* Compute pos + buffered, with overflow check. */
99 off_t sum;
100 if (! INT_ADD_OK (pos, buffered, &sum))
101 {
102 errno = EOVERFLOW;
103 return -1;
104 }
105 pos = sum;
106 }
107
108 return pos;
109
110#else
111
112# if LSEEK_PIPE_BROKEN
113 /* mingw gives bogus answers rather than failure on non-seekable files. */
114 if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
115 return -1;
116# endif
117
118# if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */
119 /* The Solaris stdio leaves the _IOREAD flag set after reading from a file
120 reaches EOF and the program then starts writing to the file. ftello
121 gets confused by this. */
122 if (fp_->_flag & _IOWRT)
123 {
124 off_t pos;
125
126 /* Call ftello nevertheless, for the side effects that it does on fp. */
127 ftello (fp);
128
129 /* Compute the file position ourselves. */
130 pos = lseek (fileno (fp), (off_t) 0, SEEK_CUR);
131 if (pos >= 0)
132 {
133 if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
134 pos += fp_->_ptr - fp_->_base;
135 }
136 return pos;
137 }
138# endif
139
140# if defined __SL64 && defined __SCLE /* Cygwin */
141 if ((fp->_flags & __SL64) == 0)
142 {
143 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
144 mode; but has an ftello that requires 64-bit mode. */
145 FILE *tmp = fopen ("/dev/null", "r");
146 if (!tmp)
147 return -1;
148 fp->_flags |= __SL64;
149 fp->_seek64 = tmp->_seek64;
150 fclose (tmp);
151 }
152# endif
153
154 return ftello (fp);
155
156#endif
157}
diff --git a/gl/full-read.c b/gl/full-read.c
deleted file mode 100644
index a0dc82c..0000000
--- a/gl/full-read.c
+++ /dev/null
@@ -1,18 +0,0 @@
1/* An interface to read that retries after partial reads and interrupts.
2 Copyright (C) 2002-2003, 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#define FULL_READ
18#include "full-write.c"
diff --git a/gl/full-read.h b/gl/full-read.h
deleted file mode 100644
index 66c8c5c..0000000
--- a/gl/full-read.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/* An interface to read() that reads all it is asked to read.
2
3 Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, read to the Free Software Foundation,
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include <stddef.h>
20
21/* Read COUNT bytes at BUF to descriptor FD, retrying if interrupted
22 or if partial reads occur. Return the number of bytes successfully
23 read, setting errno if that is less than COUNT. errno = 0 means EOF. */
24extern size_t full_read (int fd, void *buf, size_t count);
diff --git a/gl/full-write.c b/gl/full-write.c
deleted file mode 100644
index beb5bf9..0000000
--- a/gl/full-write.c
+++ /dev/null
@@ -1,79 +0,0 @@
1/* An interface to read and write that retries (if necessary) until complete.
2
3 Copyright (C) 1993-1994, 1997-2006, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#ifdef FULL_READ
22# include "full-read.h"
23#else
24# include "full-write.h"
25#endif
26
27#include <errno.h>
28
29#ifdef FULL_READ
30# include "safe-read.h"
31# define safe_rw safe_read
32# define full_rw full_read
33# undef const
34# define const /* empty */
35#else
36# include "safe-write.h"
37# define safe_rw safe_write
38# define full_rw full_write
39#endif
40
41#ifdef FULL_READ
42/* Set errno to zero upon EOF. */
43# define ZERO_BYTE_TRANSFER_ERRNO 0
44#else
45/* Some buggy drivers return 0 when one tries to write beyond
46 a device's end. (Example: Linux 1.2.13 on /dev/fd0.)
47 Set errno to ENOSPC so they get a sensible diagnostic. */
48# define ZERO_BYTE_TRANSFER_ERRNO ENOSPC
49#endif
50
51/* Write(read) COUNT bytes at BUF to(from) descriptor FD, retrying if
52 interrupted or if a partial write(read) occurs. Return the number
53 of bytes transferred.
54 When writing, set errno if fewer than COUNT bytes are written.
55 When reading, if fewer than COUNT bytes are read, you must examine
56 errno to distinguish failure from EOF (errno == 0). */
57size_t
58full_rw (int fd, const void *buf, size_t count)
59{
60 size_t total = 0;
61 const char *ptr = (const char *) buf;
62
63 while (count > 0)
64 {
65 size_t n_rw = safe_rw (fd, ptr, count);
66 if (n_rw == (size_t) -1)
67 break;
68 if (n_rw == 0)
69 {
70 errno = ZERO_BYTE_TRANSFER_ERRNO;
71 break;
72 }
73 total += n_rw;
74 ptr += n_rw;
75 count -= n_rw;
76 }
77
78 return total;
79}
diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c
index 1e371d2..3436c07 100644
--- a/gl/gai_strerror.c
+++ b/gl/gai_strerror.c
@@ -1,20 +1,20 @@
1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2013 Free Software 1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2023 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. 4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef _LIBC 19#ifndef _LIBC
20# include <config.h> 20# include <config.h>
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 58d2811..6586ee5 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,19 +1,19 @@
1/* Get address information (partial implementation). 1/* Get address information (partial implementation).
2 Copyright (C) 1997, 2001-2002, 2004-2013 Free Software Foundation, Inc. 2 Copyright (C) 1997, 2001-2002, 2004-2023 Free Software Foundation, Inc.
3 Contributed by Simon Josefsson <simon@josefsson.org>. 3 Contributed by Simon Josefsson <simon@josefsson.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
19 optimizes away the sa == NULL test below. */ 19 optimizes away the sa == NULL test below. */
@@ -39,8 +39,6 @@
39/* Get snprintf. */ 39/* Get snprintf. */
40#include <stdio.h> 40#include <stdio.h>
41 41
42#include <stdbool.h>
43
44#include "gettext.h" 42#include "gettext.h"
45#define _(String) gettext (String) 43#define _(String) gettext (String)
46#define N_(String) String 44#define N_(String) String
@@ -54,14 +52,48 @@
54# define PF_UNSPEC 0 52# define PF_UNSPEC 0
55#endif 53#endif
56 54
57#if defined _WIN32 || defined __WIN32__ 55#if HAVE_GETADDRINFO
58# define WINDOWS_NATIVE 56
59#endif 57/* Override with cdecl calling convention. */
58
59int
60getaddrinfo (const char *restrict nodename,
61 const char *restrict servname,
62 const struct addrinfo *restrict hints,
63 struct addrinfo **restrict res)
64# undef getaddrinfo
65{
66 return getaddrinfo (nodename, servname, hints, res);
67}
68
69void
70freeaddrinfo (struct addrinfo *ai)
71# undef freeaddrinfo
72{
73 freeaddrinfo (ai);
74}
75
76#else
77
78# if defined _WIN32 && !defined __CYGWIN__
79# define WINDOWS_NATIVE
80# endif
60 81
61/* gl_sockets_startup */ 82/* gl_sockets_startup */
62#include "sockets.h" 83# include "sockets.h"
84
85# ifdef WINDOWS_NATIVE
86
87/* Don't assume that UNICODE is not defined. */
88# undef GetModuleHandle
89# define GetModuleHandle GetModuleHandleA
90
91# if !(_WIN32_WINNT >= _WIN32_WINNT_WINXP)
92
93/* Avoid warnings from gcc -Wcast-function-type. */
94# define GetProcAddress \
95 (void *) GetProcAddress
63 96
64#ifdef WINDOWS_NATIVE
65typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, 97typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
66 const struct addrinfo*, 98 const struct addrinfo*,
67 struct addrinfo**); 99 struct addrinfo**);
@@ -107,20 +139,43 @@ use_win32_p (void)
107 139
108 return 1; 140 return 1;
109} 141}
110#endif 142
143# else
144
145static int
146use_win32_p (void)
147{
148 static int done = 0;
149
150 if (!done)
151 {
152 done = 1;
153
154 gl_sockets_startup (SOCKETS_1_1);
155 }
156
157 return 1;
158}
159
160# define getaddrinfo_ptr getaddrinfo
161# define freeaddrinfo_ptr freeaddrinfo
162# define getnameinfo_ptr getnameinfo
163
164# endif
165# endif
111 166
112static bool 167static bool
113validate_family (int family) 168validate_family (int family)
114{ 169{
115 /* FIXME: Support more families. */ 170 /* FIXME: Support more families. */
116#if HAVE_IPV4 171# if HAVE_IPV4
117 if (family == PF_INET) 172 if (family == PF_INET)
118 return true; 173 return true;
119#endif 174# endif
120#if HAVE_IPV6 175# if HAVE_IPV6
121 if (family == PF_INET6) 176 if (family == PF_INET6)
122 return true; 177 return true;
123#endif 178# endif
124 if (family == PF_UNSPEC) 179 if (family == PF_UNSPEC)
125 return true; 180 return true;
126 return false; 181 return false;
@@ -133,29 +188,30 @@ getaddrinfo (const char *restrict nodename,
133 const char *restrict servname, 188 const char *restrict servname,
134 const struct addrinfo *restrict hints, 189 const struct addrinfo *restrict hints,
135 struct addrinfo **restrict res) 190 struct addrinfo **restrict res)
191#undef getaddrinfo
136{ 192{
137 struct addrinfo *tmp; 193 struct addrinfo *tmp;
138 int port = 0; 194 int port = 0;
139 struct hostent *he; 195 struct hostent *he;
140 void *storage; 196 void *storage;
141 size_t size; 197 size_t size;
142#if HAVE_IPV6 198# if HAVE_IPV6
143 struct v6_pair { 199 struct v6_pair {
144 struct addrinfo addrinfo; 200 struct addrinfo addrinfo;
145 struct sockaddr_in6 sockaddr_in6; 201 struct sockaddr_in6 sockaddr_in6;
146 }; 202 };
147#endif 203# endif
148#if HAVE_IPV4 204# if HAVE_IPV4
149 struct v4_pair { 205 struct v4_pair {
150 struct addrinfo addrinfo; 206 struct addrinfo addrinfo;
151 struct sockaddr_in sockaddr_in; 207 struct sockaddr_in sockaddr_in;
152 }; 208 };
153#endif 209# endif
154 210
155#ifdef WINDOWS_NATIVE 211# ifdef WINDOWS_NATIVE
156 if (use_win32_p ()) 212 if (use_win32_p ())
157 return getaddrinfo_ptr (nodename, servname, hints, res); 213 return getaddrinfo_ptr (nodename, servname, hints, res);
158#endif 214# endif
159 215
160 if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE))) 216 if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE)))
161 /* FIXME: Support more flags. */ 217 /* FIXME: Support more flags. */
@@ -174,11 +230,11 @@ getaddrinfo (const char *restrict nodename,
174 if (!(hints->ai_flags & AI_PASSIVE)) 230 if (!(hints->ai_flags & AI_PASSIVE))
175 return EAI_NONAME; 231 return EAI_NONAME;
176 232
177#ifdef HAVE_IPV6 233# ifdef HAVE_IPV6
178 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0"; 234 nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
179#else 235# else
180 nodename = "0.0.0.0"; 236 nodename = "0.0.0.0";
181#endif 237# endif
182 } 238 }
183 239
184 if (servname) 240 if (servname)
@@ -212,17 +268,17 @@ getaddrinfo (const char *restrict nodename,
212 268
213 switch (he->h_addrtype) 269 switch (he->h_addrtype)
214 { 270 {
215#if HAVE_IPV6 271# if HAVE_IPV6
216 case PF_INET6: 272 case PF_INET6:
217 size = sizeof (struct v6_pair); 273 size = sizeof (struct v6_pair);
218 break; 274 break;
219#endif 275# endif
220 276
221#if HAVE_IPV4 277# if HAVE_IPV4
222 case PF_INET: 278 case PF_INET:
223 size = sizeof (struct v4_pair); 279 size = sizeof (struct v4_pair);
224 break; 280 break;
225#endif 281# endif
226 282
227 default: 283 default:
228 return EAI_NODATA; 284 return EAI_NODATA;
@@ -234,7 +290,7 @@ getaddrinfo (const char *restrict nodename,
234 290
235 switch (he->h_addrtype) 291 switch (he->h_addrtype)
236 { 292 {
237#if HAVE_IPV6 293# if HAVE_IPV6
238 case PF_INET6: 294 case PF_INET6:
239 { 295 {
240 struct v6_pair *p = storage; 296 struct v6_pair *p = storage;
@@ -256,9 +312,9 @@ getaddrinfo (const char *restrict nodename,
256 tmp->ai_addrlen = sizeof *sinp; 312 tmp->ai_addrlen = sizeof *sinp;
257 } 313 }
258 break; 314 break;
259#endif 315# endif
260 316
261#if HAVE_IPV4 317# if HAVE_IPV4
262 case PF_INET: 318 case PF_INET:
263 { 319 {
264 struct v4_pair *p = storage; 320 struct v4_pair *p = storage;
@@ -280,7 +336,7 @@ getaddrinfo (const char *restrict nodename,
280 tmp->ai_addrlen = sizeof *sinp; 336 tmp->ai_addrlen = sizeof *sinp;
281 } 337 }
282 break; 338 break;
283#endif 339# endif
284 340
285 default: 341 default:
286 free (storage); 342 free (storage);
@@ -308,21 +364,21 @@ getaddrinfo (const char *restrict nodename,
308 tmp->ai_addr->sa_family = he->h_addrtype; 364 tmp->ai_addr->sa_family = he->h_addrtype;
309 tmp->ai_family = he->h_addrtype; 365 tmp->ai_family = he->h_addrtype;
310 366
311#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN 367# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
312 switch (he->h_addrtype) 368 switch (he->h_addrtype)
313 { 369 {
314#if HAVE_IPV4 370# if HAVE_IPV4
315 case AF_INET: 371 case AF_INET:
316 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in); 372 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in);
317 break; 373 break;
318#endif 374# endif
319#if HAVE_IPV6 375# if HAVE_IPV6
320 case AF_INET6: 376 case AF_INET6:
321 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6); 377 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6);
322 break; 378 break;
323#endif 379# endif
324 } 380 }
325#endif 381# endif
326 382
327 /* FIXME: If more than one address, create linked list of addrinfo's. */ 383 /* FIXME: If more than one address, create linked list of addrinfo's. */
328 384
@@ -334,14 +390,15 @@ getaddrinfo (const char *restrict nodename,
334/* Free 'addrinfo' structure AI including associated storage. */ 390/* Free 'addrinfo' structure AI including associated storage. */
335void 391void
336freeaddrinfo (struct addrinfo *ai) 392freeaddrinfo (struct addrinfo *ai)
393#undef freeaddrinfo
337{ 394{
338#ifdef WINDOWS_NATIVE 395# ifdef WINDOWS_NATIVE
339 if (use_win32_p ()) 396 if (use_win32_p ())
340 { 397 {
341 freeaddrinfo_ptr (ai); 398 freeaddrinfo_ptr (ai);
342 return; 399 return;
343 } 400 }
344#endif 401# endif
345 402
346 while (ai) 403 while (ai)
347 { 404 {
@@ -360,12 +417,13 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
360 char *restrict node, socklen_t nodelen, 417 char *restrict node, socklen_t nodelen,
361 char *restrict service, socklen_t servicelen, 418 char *restrict service, socklen_t servicelen,
362 int flags) 419 int flags)
420#undef getnameinfo
363{ 421{
364#ifdef WINDOWS_NATIVE 422# ifdef WINDOWS_NATIVE
365 if (use_win32_p ()) 423 if (use_win32_p ())
366 return getnameinfo_ptr (sa, salen, node, nodelen, 424 return getnameinfo_ptr (sa, salen, node, nodelen,
367 service, servicelen, flags); 425 service, servicelen, flags);
368#endif 426# endif
369 427
370 /* FIXME: Support other flags. */ 428 /* FIXME: Support other flags. */
371 if ((node && nodelen > 0 && !(flags & NI_NUMERICHOST)) || 429 if ((node && nodelen > 0 && !(flags & NI_NUMERICHOST)) ||
@@ -378,18 +436,18 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
378 436
379 switch (sa->sa_family) 437 switch (sa->sa_family)
380 { 438 {
381#if HAVE_IPV4 439# if HAVE_IPV4
382 case AF_INET: 440 case AF_INET:
383 if (salen < sizeof (struct sockaddr_in)) 441 if (salen < sizeof (struct sockaddr_in))
384 return EAI_FAMILY; 442 return EAI_FAMILY;
385 break; 443 break;
386#endif 444# endif
387#if HAVE_IPV6 445# if HAVE_IPV6
388 case AF_INET6: 446 case AF_INET6:
389 if (salen < sizeof (struct sockaddr_in6)) 447 if (salen < sizeof (struct sockaddr_in6))
390 return EAI_FAMILY; 448 return EAI_FAMILY;
391 break; 449 break;
392#endif 450# endif
393 default: 451 default:
394 return EAI_FAMILY; 452 return EAI_FAMILY;
395 } 453 }
@@ -398,23 +456,23 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
398 { 456 {
399 switch (sa->sa_family) 457 switch (sa->sa_family)
400 { 458 {
401#if HAVE_IPV4 459# if HAVE_IPV4
402 case AF_INET: 460 case AF_INET:
403 if (!inet_ntop (AF_INET, 461 if (!inet_ntop (AF_INET,
404 &(((const struct sockaddr_in *) sa)->sin_addr), 462 &(((const struct sockaddr_in *) sa)->sin_addr),
405 node, nodelen)) 463 node, nodelen))
406 return EAI_SYSTEM; 464 return EAI_SYSTEM;
407 break; 465 break;
408#endif 466# endif
409 467
410#if HAVE_IPV6 468# if HAVE_IPV6
411 case AF_INET6: 469 case AF_INET6:
412 if (!inet_ntop (AF_INET6, 470 if (!inet_ntop (AF_INET6,
413 &(((const struct sockaddr_in6 *) sa)->sin6_addr), 471 &(((const struct sockaddr_in6 *) sa)->sin6_addr),
414 node, nodelen)) 472 node, nodelen))
415 return EAI_SYSTEM; 473 return EAI_SYSTEM;
416 break; 474 break;
417#endif 475# endif
418 476
419 default: 477 default:
420 return EAI_FAMILY; 478 return EAI_FAMILY;
@@ -424,12 +482,12 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
424 if (service && servicelen > 0 && flags & NI_NUMERICSERV) 482 if (service && servicelen > 0 && flags & NI_NUMERICSERV)
425 switch (sa->sa_family) 483 switch (sa->sa_family)
426 { 484 {
427#if HAVE_IPV4 485# if HAVE_IPV4
428 case AF_INET: 486 case AF_INET:
429#endif 487# endif
430#if HAVE_IPV6 488# if HAVE_IPV6
431 case AF_INET6: 489 case AF_INET6:
432#endif 490# endif
433 { 491 {
434 unsigned short int port 492 unsigned short int port
435 = ntohs (((const struct sockaddr_in *) sa)->sin_port); 493 = ntohs (((const struct sockaddr_in *) sa)->sin_port);
@@ -441,3 +499,5 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
441 499
442 return 0; 500 return 0;
443} 501}
502
503#endif
diff --git a/gl/getdelim.c b/gl/getdelim.c
new file mode 100644
index 0000000..79ec3dd
--- /dev/null
+++ b/gl/getdelim.c
@@ -0,0 +1,147 @@
1/* getdelim.c --- Implementation of replacement getdelim function.
2 Copyright (C) 1994, 1996-1998, 2001, 2003, 2005-2023 Free Software
3 Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Ported from glibc by Simon Josefsson. */
19
20/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
21 optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
22#define _GL_ARG_NONNULL(params)
23
24#include <config.h>
25
26#include <stdio.h>
27
28#include <limits.h>
29#include <stdint.h>
30#include <stdlib.h>
31#include <errno.h>
32
33#ifndef SSIZE_MAX
34# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
35#endif
36
37#if USE_UNLOCKED_IO
38# include "unlocked-io.h"
39# define getc_maybe_unlocked(fp) getc(fp)
40#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
41# undef flockfile
42# undef funlockfile
43# define flockfile(x) ((void) 0)
44# define funlockfile(x) ((void) 0)
45# define getc_maybe_unlocked(fp) getc(fp)
46#else
47# define getc_maybe_unlocked(fp) getc_unlocked(fp)
48#endif
49
50static void
51alloc_failed (void)
52{
53#if defined _WIN32 && ! defined __CYGWIN__
54 /* Avoid errno problem without using the realloc module; see:
55 https://lists.gnu.org/r/bug-gnulib/2016-08/msg00025.html */
56 errno = ENOMEM;
57#endif
58}
59
60/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
61 NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
62 NULL), pointing to *N characters of space. It is realloc'ed as
63 necessary. Returns the number of characters read (not including
64 the null terminator), or -1 on error or EOF. */
65
66ssize_t
67getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
68{
69 ssize_t result;
70 size_t cur_len = 0;
71
72 if (lineptr == NULL || n == NULL || fp == NULL)
73 {
74 errno = EINVAL;
75 return -1;
76 }
77
78 flockfile (fp);
79
80 if (*lineptr == NULL || *n == 0)
81 {
82 char *new_lineptr;
83 *n = 120;
84 new_lineptr = (char *) realloc (*lineptr, *n);
85 if (new_lineptr == NULL)
86 {
87 alloc_failed ();
88 result = -1;
89 goto unlock_return;
90 }
91 *lineptr = new_lineptr;
92 }
93
94 for (;;)
95 {
96 int i;
97
98 i = getc_maybe_unlocked (fp);
99 if (i == EOF)
100 {
101 result = -1;
102 break;
103 }
104
105 /* Make enough space for len+1 (for final NUL) bytes. */
106 if (cur_len + 1 >= *n)
107 {
108 size_t needed_max =
109 SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
110 size_t needed = 2 * *n + 1; /* Be generous. */
111 char *new_lineptr;
112
113 if (needed_max < needed)
114 needed = needed_max;
115 if (cur_len + 1 >= needed)
116 {
117 result = -1;
118 errno = EOVERFLOW;
119 goto unlock_return;
120 }
121
122 new_lineptr = (char *) realloc (*lineptr, needed);
123 if (new_lineptr == NULL)
124 {
125 alloc_failed ();
126 result = -1;
127 goto unlock_return;
128 }
129
130 *lineptr = new_lineptr;
131 *n = needed;
132 }
133
134 (*lineptr)[cur_len] = i;
135 cur_len++;
136
137 if (i == delimiter)
138 break;
139 }
140 (*lineptr)[cur_len] = '\0';
141 result = cur_len ? cur_len : result;
142
143 unlock_return:
144 funlockfile (fp); /* doesn't set errno */
145
146 return result;
147}
diff --git a/gl/getdtablesize.c b/gl/getdtablesize.c
new file mode 100644
index 0000000..ac2d175
--- /dev/null
+++ b/gl/getdtablesize.c
@@ -0,0 +1,124 @@
1/* getdtablesize() function: Return maximum possible file descriptor value + 1.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23#if defined _WIN32 && ! defined __CYGWIN__
24
25# include <stdio.h>
26
27# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
28# include "msvc-inval.h"
29# endif
30
31# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
32static int
33_setmaxstdio_nothrow (int newmax)
34{
35 int result;
36
37 TRY_MSVC_INVAL
38 {
39 result = _setmaxstdio (newmax);
40 }
41 CATCH_MSVC_INVAL
42 {
43 result = -1;
44 }
45 DONE_MSVC_INVAL;
46
47 return result;
48}
49# else
50# define _setmaxstdio_nothrow _setmaxstdio
51# endif
52
53/* Cache for the previous getdtablesize () result. Safe to cache because
54 Windows also lacks setrlimit. */
55static int dtablesize;
56
57int
58getdtablesize (void)
59{
60 if (dtablesize == 0)
61 {
62 /* We are looking for the number N such that the valid file descriptors
63 are 0..N-1. It can be obtained through a loop as follows:
64 {
65 int fd;
66 for (fd = 3; fd < 65536; fd++)
67 if (dup2 (0, fd) == -1)
68 break;
69 return fd;
70 }
71 On Windows XP, the result is 2048.
72 The drawback of this loop is that it allocates memory for a libc
73 internal array that is never freed.
74
75 The number N can also be obtained as the upper bound for
76 _getmaxstdio (). _getmaxstdio () returns the maximum number of open
77 FILE objects. The sanity check in _setmaxstdio reveals the maximum
78 number of file descriptors. This too allocates memory, but it is
79 freed when we call _setmaxstdio with the original value. */
80 int orig_max_stdio = _getmaxstdio ();
81 unsigned int bound;
82 for (bound = 0x10000; _setmaxstdio_nothrow (bound) < 0; bound = bound / 2)
83 ;
84 _setmaxstdio_nothrow (orig_max_stdio);
85 dtablesize = bound;
86 }
87 return dtablesize;
88}
89
90#else
91
92# include <limits.h>
93# include <sys/resource.h>
94
95# ifndef RLIM_SAVED_CUR
96# define RLIM_SAVED_CUR RLIM_INFINITY
97# endif
98# ifndef RLIM_SAVED_MAX
99# define RLIM_SAVED_MAX RLIM_INFINITY
100# endif
101
102# ifdef __CYGWIN__
103 /* Cygwin 1.7.25 auto-increases the RLIMIT_NOFILE soft limit until it
104 hits the compile-time constant hard limit of 3200. We might as
105 well just report the hard limit. */
106# define rlim_cur rlim_max
107# endif
108
109int
110getdtablesize (void)
111{
112 struct rlimit lim;
113
114 if (getrlimit (RLIMIT_NOFILE, &lim) == 0
115 && 0 <= lim.rlim_cur && lim.rlim_cur <= INT_MAX
116 && lim.rlim_cur != RLIM_INFINITY
117 && lim.rlim_cur != RLIM_SAVED_CUR
118 && lim.rlim_cur != RLIM_SAVED_MAX)
119 return lim.rlim_cur;
120
121 return INT_MAX;
122}
123
124#endif
diff --git a/gl/gethostname.c b/gl/gethostname.c
index 2201573..0c616c3 100644
--- a/gl/gethostname.c
+++ b/gl/gethostname.c
@@ -1,26 +1,26 @@
1/* gethostname emulation for SysV and POSIX.1. 1/* gethostname emulation for SysV and POSIX.1.
2 2
3 Copyright (C) 1992, 2003, 2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 1992, 2003, 2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* David MacKenzie <djm@gnu.ai.mit.edu> 18/* David MacKenzie <djm@gnu.ai.mit.edu>
19 Windows port by Simon Josefsson <simon@josefsson.org> */ 19 Windows port by Simon Josefsson <simon@josefsson.org> */
20 20
21#include <config.h> 21#include <config.h>
22 22
23#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) 23#if !(defined _WIN32 && !defined __CYGWIN__)
24/* Unix API. */ 24/* Unix API. */
25 25
26/* Specification. */ 26/* Specification. */
diff --git a/gl/getline.c b/gl/getline.c
new file mode 100644
index 0000000..85f16ab
--- /dev/null
+++ b/gl/getline.c
@@ -0,0 +1,27 @@
1/* getline.c --- Implementation of replacement getline function.
2 Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Simon Josefsson. */
18
19#include <config.h>
20
21#include <stdio.h>
22
23ssize_t
24getline (char **lineptr, size_t *n, FILE *stream)
25{
26 return getdelim (lineptr, n, '\n', stream);
27}
diff --git a/gl/getloadavg.c b/gl/getloadavg.c
index 6e22819..59b53e7 100644
--- a/gl/getloadavg.c
+++ b/gl/getloadavg.c
@@ -1,6 +1,6 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 2
3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2013 Free Software 3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with gnulib. 6 NOTE: The canonical source of this file is maintained with gnulib.
@@ -8,7 +8,7 @@
8 8
9 This program is free software: you can redistribute it and/or modify 9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or 11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful,
@@ -17,7 +17,7 @@
17 GNU General Public License for more details. 17 GNU General Public License for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 20 along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 21
22/* Compile-time symbols that this file uses: 22/* Compile-time symbols that this file uses:
23 23
@@ -47,29 +47,25 @@
47 N_NAME_POINTER The nlist n_name element is a pointer, 47 N_NAME_POINTER The nlist n_name element is a pointer,
48 not an array. 48 not an array.
49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'. 49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
50 LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing 50 LINUX_LDAV_FILE [__linux__, __ANDROID__, __CYGWIN__]: File
51 load averages. 51 containing load averages.
52 52
53 Specific system predefines this file uses, aside from setting 53 Specific system predefines this file uses, aside from setting
54 default values if not emacs: 54 default values if not emacs:
55 55
56 apollo 56 apollo
57 BSD Real BSD, not just BSD-like. 57 BSD Real BSD, not just BSD-like.
58 convex
59 DGUX 58 DGUX
60 eunice UNIX emulator under VMS. 59 eunice UNIX emulator under VMS.
61 hpux 60 hpux
62 __MSDOS__ No-op for MSDOS. 61 __MSDOS__ No-op for MSDOS.
63 NeXT 62 NeXT
64 sgi 63 sgi
65 sequent Sequent Dynix 3.x.x (BSD)
66 _SEQUENT_ Sequent DYNIX/ptx 1.x.x (SYSV)
67 sony_news NEWS-OS (works at least for 4.1C)
68 UMAX 64 UMAX
69 UMAX4_3 65 UMAX4_3
70 VMS 66 VMS
71 WINDOWS32 No-op for Windows95/NT. 67 _WIN32 Native Windows (possibly also defined on Cygwin)
72 __linux__ Linux: assumes /proc file system mounted. 68 __linux__, __ANDROID__ Linux: assumes /proc file system mounted.
73 Support from Michael K. Johnson. 69 Support from Michael K. Johnson.
74 __CYGWIN__ Cygwin emulates linux /proc/loadavg. 70 __CYGWIN__ Cygwin emulates linux /proc/loadavg.
75 __NetBSD__ NetBSD: assumes /kern file system mounted. 71 __NetBSD__ NetBSD: assumes /kern file system mounted.
@@ -86,7 +82,6 @@
86#include <stdlib.h> 82#include <stdlib.h>
87 83
88#include <errno.h> 84#include <errno.h>
89#include <stdbool.h>
90#include <stdio.h> 85#include <stdio.h>
91 86
92# include <sys/types.h> 87# include <sys/types.h>
@@ -97,9 +92,8 @@
97 92
98# include "intprops.h" 93# include "intprops.h"
99 94
100# if !defined (BSD) && defined (ultrix) 95# if defined _WIN32 && ! defined __CYGWIN__ && ! defined WINDOWS32
101/* Ultrix behaves like BSD on Vaxen. */ 96# define WINDOWS32
102# define BSD
103# endif 97# endif
104 98
105# ifdef NeXT 99# ifdef NeXT
@@ -141,10 +135,6 @@
141# define MORE_BSD 135# define MORE_BSD
142# endif 136# endif
143 137
144# if defined (ultrix) && defined (mips)
145# define decstation
146# endif
147
148# if defined (__SVR4) && !defined (SVR4) 138# if defined (__SVR4) && !defined (SVR4)
149# define SVR4 139# define SVR4
150# endif 140# endif
@@ -168,13 +158,6 @@
168# include <sys/table.h> 158# include <sys/table.h>
169# endif 159# endif
170 160
171/* UTek's /bin/cc on the 4300 has no architecture specific cpp define by
172 default, but _MACH_IND_SYS_TYPES is defined in <sys/types.h>. Combine
173 that with a couple of other things and we'll have a unique match. */
174# if !defined (tek4300) && defined (unix) && defined (m68k) && defined (mc68000) && defined (mc68020) && defined (_MACH_IND_SYS_TYPES)
175# define tek4300 /* Define by emacs, but not by other users. */
176# endif
177
178 161
179/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */ 162/* VAX C can't handle multi-line #ifs, or lines longer than 256 chars. */
180# ifndef LOAD_AVE_TYPE 163# ifndef LOAD_AVE_TYPE
@@ -187,14 +170,6 @@
187# define LOAD_AVE_TYPE long 170# define LOAD_AVE_TYPE long
188# endif 171# endif
189 172
190# ifdef decstation
191# define LOAD_AVE_TYPE long
192# endif
193
194# ifdef _SEQUENT_
195# define LOAD_AVE_TYPE long
196# endif
197
198# ifdef sgi 173# ifdef sgi
199# define LOAD_AVE_TYPE long 174# define LOAD_AVE_TYPE long
200# endif 175# endif
@@ -203,41 +178,14 @@
203# define LOAD_AVE_TYPE long 178# define LOAD_AVE_TYPE long
204# endif 179# endif
205 180
206# ifdef sony_news
207# define LOAD_AVE_TYPE long
208# endif
209
210# ifdef sequent
211# define LOAD_AVE_TYPE long
212# endif
213
214# ifdef OSF_ALPHA 181# ifdef OSF_ALPHA
215# define LOAD_AVE_TYPE long 182# define LOAD_AVE_TYPE long
216# endif 183# endif
217 184
218# if defined (ardent) && defined (titan)
219# define LOAD_AVE_TYPE long
220# endif
221
222# ifdef tek4300
223# define LOAD_AVE_TYPE long
224# endif
225
226# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
227# define LOAD_AVE_TYPE long
228# endif
229
230# if defined _AIX && ! defined HAVE_LIBPERFSTAT 185# if defined _AIX && ! defined HAVE_LIBPERFSTAT
231# define LOAD_AVE_TYPE long 186# define LOAD_AVE_TYPE long
232# endif 187# endif
233 188
234# ifdef convex
235# define LOAD_AVE_TYPE double
236# ifndef LDAV_CVT
237# define LDAV_CVT(n) (n)
238# endif
239# endif
240
241# endif /* No LOAD_AVE_TYPE. */ 189# endif /* No LOAD_AVE_TYPE. */
242 190
243# ifdef OSF_ALPHA 191# ifdef OSF_ALPHA
@@ -247,13 +195,6 @@
247# define FSCALE 1024.0 195# define FSCALE 1024.0
248# endif 196# endif
249 197
250# if defined (alliant) && defined (i860) /* Alliant FX/2800 */
251/* <sys/param.h> defines an incorrect value for FSCALE on an
252 Alliant FX/2800 Concentrix 2.2, according to ghazi@noc.rutgers.edu. */
253# undef FSCALE
254# define FSCALE 100.0
255# endif
256
257 198
258# ifndef FSCALE 199# ifndef FSCALE
259 200
@@ -263,25 +204,17 @@
263# define FSCALE 2048.0 204# define FSCALE 2048.0
264# endif 205# endif
265 206
266# if defined (MIPS) || defined (SVR4) || defined (decstation) 207# if defined (MIPS) || defined (SVR4)
267# define FSCALE 256 208# define FSCALE 256
268# endif 209# endif
269 210
270# if defined (sgi) || defined (sequent) 211# if defined (sgi)
271/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined 212/* Sometimes both MIPS and sgi are defined, so FSCALE was just defined
272 above under #ifdef MIPS. But we want the sgi value. */ 213 above under #ifdef MIPS. But we want the sgi value. */
273# undef FSCALE 214# undef FSCALE
274# define FSCALE 1000.0 215# define FSCALE 1000.0
275# endif 216# endif
276 217
277# if defined (ardent) && defined (titan)
278# define FSCALE 65536.0
279# endif
280
281# ifdef tek4300
282# define FSCALE 100.0
283# endif
284
285# if defined _AIX && !defined HAVE_LIBPERFSTAT 218# if defined _AIX && !defined HAVE_LIBPERFSTAT
286# define FSCALE 65536.0 219# define FSCALE 65536.0
287# endif 220# endif
@@ -303,28 +236,22 @@
303# endif 236# endif
304 237
305 238
306# if !defined (KERNEL_FILE) && defined (sequent)
307# define KERNEL_FILE "/dynix"
308# endif
309
310# if !defined (KERNEL_FILE) && defined (hpux) 239# if !defined (KERNEL_FILE) && defined (hpux)
311# define KERNEL_FILE "/hp-ux" 240# define KERNEL_FILE "/hp-ux"
312# endif 241# endif
313 242
314# if !defined (KERNEL_FILE) && (defined (_SEQUENT_) || defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan))) 243# if !defined (KERNEL_FILE) && (defined (MIPS) || defined (SVR4) || defined (ISC) || defined (sgi))
315# define KERNEL_FILE "/unix" 244# define KERNEL_FILE "/unix"
316# endif 245# endif
317 246
318 247
319# if !defined (LDAV_SYMBOL) && defined (alliant) 248# if !defined (LDAV_SYMBOL) && (defined (hpux) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
320# define LDAV_SYMBOL "_Loadavg"
321# endif
322
323# if !defined (LDAV_SYMBOL) && ((defined (hpux) && !defined (hp9000s300)) || defined (_SEQUENT_) || defined (SVR4) || defined (ISC) || defined (sgi) || (defined (ardent) && defined (titan)) || (defined (_AIX) && !defined(HAVE_LIBPERFSTAT)))
324# define LDAV_SYMBOL "avenrun" 249# define LDAV_SYMBOL "avenrun"
325# endif 250# endif
326 251
327# include <unistd.h> 252# ifdef HAVE_UNISTD_H
253# include <unistd.h>
254# endif
328 255
329/* LOAD_AVE_TYPE should only get defined if we're going to use the 256/* LOAD_AVE_TYPE should only get defined if we're going to use the
330 nlist method. */ 257 nlist method. */
@@ -335,7 +262,7 @@
335# ifdef LOAD_AVE_TYPE 262# ifdef LOAD_AVE_TYPE
336 263
337# ifndef __VMS 264# ifndef __VMS
338# ifndef __linux__ 265# if !(defined __linux__ || defined __ANDROID__)
339# ifndef NLIST_STRUCT 266# ifndef NLIST_STRUCT
340# include <a.out.h> 267# include <a.out.h>
341# else /* NLIST_STRUCT */ 268# else /* NLIST_STRUCT */
@@ -358,7 +285,7 @@
358# ifndef LDAV_SYMBOL 285# ifndef LDAV_SYMBOL
359# define LDAV_SYMBOL "_avenrun" 286# define LDAV_SYMBOL "_avenrun"
360# endif /* LDAV_SYMBOL */ 287# endif /* LDAV_SYMBOL */
361# endif /* __linux__ */ 288# endif /* __linux__ || __ANDROID__ */
362 289
363# else /* __VMS */ 290# else /* __VMS */
364 291
@@ -431,7 +358,8 @@
431# include <sys/dg_sys_info.h> 358# include <sys/dg_sys_info.h>
432# endif 359# endif
433 360
434# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5 \ 361# if (defined __linux__ || defined __ANDROID__ \
362 || defined __CYGWIN__ || defined SUNOS_5 \
435 || (defined LOAD_AVE_TYPE && ! defined __VMS)) 363 || (defined LOAD_AVE_TYPE && ! defined __VMS))
436# include <fcntl.h> 364# include <fcntl.h>
437# endif 365# endif
@@ -460,7 +388,7 @@ static bool getloadavg_initialized;
460/* Offset in kmem to seek to read load average, or 0 means invalid. */ 388/* Offset in kmem to seek to read load average, or 0 means invalid. */
461static long offset; 389static long offset;
462 390
463# if ! defined __VMS && ! defined sgi && ! defined __linux__ 391# if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined __ANDROID__)
464static struct nlist name_list[2]; 392static struct nlist name_list[2];
465# endif 393# endif
466 394
@@ -495,17 +423,17 @@ getloadavg (double loadavg[], int nelem)
495 int saved_errno; 423 int saved_errno;
496 424
497 kc = kstat_open (); 425 kc = kstat_open ();
498 if (kc == 0) 426 if (kc == NULL)
499 return -1; 427 return -1;
500 ksp = kstat_lookup (kc, "unix", 0, "system_misc"); 428 ksp = kstat_lookup (kc, "unix", 0, "system_misc");
501 if (ksp == 0) 429 if (ksp == NULL)
502 return -1; 430 return -1;
503 if (kstat_read (kc, ksp, 0) == -1) 431 if (kstat_read (kc, ksp, 0) == -1)
504 return -1; 432 return -1;
505 433
506 434
507 kn = kstat_data_lookup (ksp, "avenrun_1min"); 435 kn = kstat_data_lookup (ksp, "avenrun_1min");
508 if (kn == 0) 436 if (kn == NULL)
509 { 437 {
510 /* Return -1 if no load average information is available. */ 438 /* Return -1 if no load average information is available. */
511 nelem = 0; 439 nelem = 0;
@@ -518,14 +446,14 @@ getloadavg (double loadavg[], int nelem)
518 if (nelem >= 2) 446 if (nelem >= 2)
519 { 447 {
520 kn = kstat_data_lookup (ksp, "avenrun_5min"); 448 kn = kstat_data_lookup (ksp, "avenrun_5min");
521 if (kn != 0) 449 if (kn != NULL)
522 { 450 {
523 loadavg[elem++] = (double) kn->value.ul / FSCALE; 451 loadavg[elem++] = (double) kn->value.ul / FSCALE;
524 452
525 if (nelem >= 3) 453 if (nelem >= 3)
526 { 454 {
527 kn = kstat_data_lookup (ksp, "avenrun_15min"); 455 kn = kstat_data_lookup (ksp, "avenrun_15min");
528 if (kn != 0) 456 if (kn != NULL)
529 loadavg[elem++] = (double) kn->value.ul / FSCALE; 457 loadavg[elem++] = (double) kn->value.ul / FSCALE;
530 } 458 }
531 } 459 }
@@ -570,8 +498,8 @@ getloadavg (double loadavg[], int nelem)
570 } 498 }
571# endif 499# endif
572 500
573# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__)) 501# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || defined __CYGWIN__)
574 /* Linux without glibc, Cygwin */ 502 /* Linux without glibc, Android, Cygwin */
575# define LDAV_DONE 503# define LDAV_DONE
576# undef LOAD_AVE_TYPE 504# undef LOAD_AVE_TYPE
577 505
@@ -583,7 +511,7 @@ getloadavg (double loadavg[], int nelem)
583 char const *ptr = ldavgbuf; 511 char const *ptr = ldavgbuf;
584 int fd, count, saved_errno; 512 int fd, count, saved_errno;
585 513
586 fd = open (LINUX_LDAV_FILE, O_RDONLY); 514 fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC);
587 if (fd == -1) 515 if (fd == -1)
588 return -1; 516 return -1;
589 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1); 517 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
@@ -621,12 +549,12 @@ getloadavg (double loadavg[], int nelem)
621 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++) 549 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
622 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10; 550 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
623 551
624 loadavg[elem++] = numerator / denominator; 552 loadavg[elem] = numerator / denominator;
625 } 553 }
626 554
627 return elem; 555 return elem;
628 556
629# endif /* __linux__ || __CYGWIN__ */ 557# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */
630 558
631# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */ 559# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */
632# define LDAV_DONE 560# define LDAV_DONE
@@ -638,15 +566,22 @@ getloadavg (double loadavg[], int nelem)
638 566
639 unsigned long int load_ave[3], scale; 567 unsigned long int load_ave[3], scale;
640 int count; 568 int count;
641 FILE *fp; 569 char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
642 570 int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
643 fp = fopen (NETBSD_LDAV_FILE, "r"); 571 if (fd < 0)
644 if (fp == NULL) 572 return fd;
645 return -1; 573 int nread = read (fd, readbuf, sizeof readbuf - 1);
646 count = fscanf (fp, "%lu %lu %lu %lu\n", 574 int err = errno;
575 close (fd);
576 if (nread < 0)
577 {
578 errno = err;
579 return -1;
580 }
581 readbuf[nread] = '\0';
582 count = sscanf (readbuf, "%lu %lu %lu %lu\n",
647 &load_ave[0], &load_ave[1], &load_ave[2], 583 &load_ave[0], &load_ave[1], &load_ave[2],
648 &scale); 584 &scale);
649 (void) fclose (fp);
650 if (count != 4) 585 if (count != 4)
651 { 586 {
652 errno = ENOTSUP; 587 errno = ENOTSUP;
@@ -915,7 +850,7 @@ getloadavg (double loadavg[], int nelem)
915 850
916# ifndef SUNOS_5 851# ifndef SUNOS_5
917 if ( 852 if (
918# if !(defined (_AIX) && !defined (ps2)) 853# if !defined (_AIX)
919 nlist (KERNEL_FILE, name_list) 854 nlist (KERNEL_FILE, name_list)
920# else /* _AIX */ 855# else /* _AIX */
921 knlist (name_list, 1, sizeof (name_list[0])) 856 knlist (name_list, 1, sizeof (name_list[0]))
@@ -940,33 +875,17 @@ getloadavg (double loadavg[], int nelem)
940 if (!getloadavg_initialized) 875 if (!getloadavg_initialized)
941 { 876 {
942# ifndef SUNOS_5 877# ifndef SUNOS_5
943 /* Set the channel to close on exec, so it does not
944 litter any child's descriptor table. */
945# ifndef O_CLOEXEC
946# define O_CLOEXEC 0
947# endif
948 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC); 878 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
949 if (0 <= fd) 879 if (0 <= fd)
950 { 880 {
951# if F_DUPFD_CLOEXEC 881 channel = fd;
952 if (fd <= STDERR_FILENO) 882 getloadavg_initialized = true;
953 {
954 int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
955 close (fd);
956 fd = fd1;
957 }
958# endif
959 if (0 <= fd)
960 {
961 channel = fd;
962 getloadavg_initialized = true;
963 }
964 } 883 }
965# else /* SUNOS_5 */ 884# else /* SUNOS_5 */
966 /* We pass 0 for the kernel, corefile, and swapfile names 885 /* We pass 0 for the kernel, corefile, and swapfile names
967 to use the currently running kernel. */ 886 to use the currently running kernel. */
968 kd = kvm_open (0, 0, 0, O_RDONLY, 0); 887 kd = kvm_open (0, 0, 0, O_RDONLY, 0);
969 if (kd != 0) 888 if (kd != NULL)
970 { 889 {
971 /* nlist the currently running kernel. */ 890 /* nlist the currently running kernel. */
972 kvm_nlist (kd, name_list); 891 kvm_nlist (kd, name_list);
diff --git a/gl/getopt-cdefs.in.h b/gl/getopt-cdefs.in.h
new file mode 100644
index 0000000..e76c78c
--- /dev/null
+++ b/gl/getopt-cdefs.in.h
@@ -0,0 +1,66 @@
1/* getopt-on-non-glibc compatibility macros.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_CDEFS_H
21#define _GETOPT_CDEFS_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. It does not have a protective #error, because
25 the guard macro for getopt.h in gnulib is not fixed. */
26
27/* getopt-core.h and getopt-ext.h are shared with GNU libc, and expect
28 a number of the internal macros supplied to GNU libc's headers by
29 sys/cdefs.h. Provide fallback definitions for all of them. */
30#if @HAVE_SYS_CDEFS_H@
31# include <sys/cdefs.h>
32#endif
33
34#ifndef __BEGIN_DECLS
35# ifdef __cplusplus
36# define __BEGIN_DECLS extern "C" {
37# else
38# define __BEGIN_DECLS /* nothing */
39# endif
40#endif
41#ifndef __END_DECLS
42# ifdef __cplusplus
43# define __END_DECLS }
44# else
45# define __END_DECLS /* nothing */
46# endif
47#endif
48
49#ifndef __GNUC_PREREQ
50# if defined __GNUC__ && defined __GNUC_VERSION__
51# define __GNUC_PREREQ(maj, min) \
52 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
53# else
54# define __GNUC_PREREQ(maj, min) 0
55# endif
56#endif
57
58#ifndef __THROW
59# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4)
60# define __THROW throw ()
61# else
62# define __THROW
63# endif
64#endif
65
66#endif /* _GETOPT_CDEFS_H */
diff --git a/gl/getopt-core.h b/gl/getopt-core.h
new file mode 100644
index 0000000..c5dd493
--- /dev/null
+++ b/gl/getopt-core.h
@@ -0,0 +1,96 @@
1/* Declarations for getopt (basic, portable features only).
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_CORE_H
21#define _GETOPT_CORE_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. Unlike most bits headers, it does not have
25 a protective #error, because the guard macro for getopt.h in
26 gnulib is not fixed. */
27
28__BEGIN_DECLS
29
30/* For communication from 'getopt' to the caller.
31 When 'getopt' finds an option that takes an argument,
32 the argument value is returned here.
33 Also, when 'ordering' is RETURN_IN_ORDER,
34 each non-option ARGV-element is returned here. */
35
36extern char *optarg;
37
38/* Index in ARGV of the next element to be scanned.
39 This is used for communication to and from the caller
40 and for communication between successive calls to 'getopt'.
41
42 On entry to 'getopt', zero means this is the first call; initialize.
43
44 When 'getopt' returns -1, this is the index of the first of the
45 non-option elements that the caller should itself scan.
46
47 Otherwise, 'optind' communicates from one call to the next
48 how much of ARGV has been scanned so far. */
49
50extern int optind;
51
52/* Callers store zero here to inhibit the error message 'getopt' prints
53 for unrecognized options. */
54
55extern int opterr;
56
57/* Set to an option character which was unrecognized. */
58
59extern int optopt;
60
61/* Get definitions and prototypes for functions to process the
62 arguments in ARGV (ARGC of them, minus the program name) for
63 options given in OPTS.
64
65 Return the option character from OPTS just read. Return -1 when
66 there are no more options. For unrecognized options, or options
67 missing arguments, 'optopt' is set to the option letter, and '?' is
68 returned.
69
70 The OPTS string is a list of characters which are recognized option
71 letters, optionally followed by colons, specifying that that letter
72 takes an argument, to be placed in 'optarg'.
73
74 If a letter in OPTS is followed by two colons, its argument is
75 optional. This behavior is specific to the GNU 'getopt'.
76
77 The argument '--' causes premature termination of argument
78 scanning, explicitly telling 'getopt' that there are no more
79 options.
80
81 If OPTS begins with '-', then non-option arguments are treated as
82 arguments to the option '\1'. This behavior is specific to the GNU
83 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
84 the environment, then do not permute arguments.
85
86 For standards compliance, the 'argv' argument has the type
87 char *const *, but this is inaccurate; if argument permutation is
88 enabled, the argv array (not the strings it points to) must be
89 writable. */
90
91extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
92 __THROW _GL_ARG_NONNULL ((2, 3));
93
94__END_DECLS
95
96#endif /* _GETOPT_CORE_H */
diff --git a/gl/getopt-ext.h b/gl/getopt-ext.h
new file mode 100644
index 0000000..d37c293
--- /dev/null
+++ b/gl/getopt-ext.h
@@ -0,0 +1,77 @@
1/* Declarations for getopt (GNU extensions).
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library and is also part of gnulib.
4 Patches to this file should be submitted to both projects.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_EXT_H
21#define _GETOPT_EXT_H 1
22
23/* This header should not be used directly; include getopt.h instead.
24 Unlike most bits headers, it does not have a protective #error,
25 because the guard macro for getopt.h in gnulib is not fixed. */
26
27__BEGIN_DECLS
28
29/* Describe the long-named options requested by the application.
30 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
31 of 'struct option' terminated by an element containing a name which is
32 zero.
33
34 The field 'has_arg' is:
35 no_argument (or 0) if the option does not take an argument,
36 required_argument (or 1) if the option requires an argument,
37 optional_argument (or 2) if the option takes an optional argument.
38
39 If the field 'flag' is not NULL, it points to a variable that is set
40 to the value given in the field 'val' when the option is found, but
41 left unchanged if the option is not found.
42
43 To have a long-named option do something other than set an 'int' to
44 a compiled-in constant, such as set a value from 'optarg', set the
45 option's 'flag' field to zero and its 'val' field to a nonzero
46 value (the equivalent single-letter option character, if there is
47 one). For long options that have a zero 'flag' field, 'getopt'
48 returns the contents of the 'val' field. */
49
50struct option
51{
52 const char *name;
53 /* has_arg can't be an enum because some compilers complain about
54 type mismatches in all the code that assumes it is an int. */
55 int has_arg;
56 int *flag;
57 int val;
58};
59
60/* Names for the values of the 'has_arg' field of 'struct option'. */
61
62#define no_argument 0
63#define required_argument 1
64#define optional_argument 2
65
66extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
67 const char *__shortopts,
68 const struct option *__longopts, int *__longind)
69 __THROW _GL_ARG_NONNULL ((2, 3));
70extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
71 const char *__shortopts,
72 const struct option *__longopts, int *__longind)
73 __THROW _GL_ARG_NONNULL ((2, 3));
74
75__END_DECLS
76
77#endif /* _GETOPT_EXT_H */
diff --git a/gl/getopt-pfx-core.h b/gl/getopt-pfx-core.h
new file mode 100644
index 0000000..3a2fde5
--- /dev/null
+++ b/gl/getopt-pfx-core.h
@@ -0,0 +1,66 @@
1/* getopt (basic, portable features) gnulib wrapper header.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_PFX_CORE_H
21#define _GETOPT_PFX_CORE_H 1
22
23/* This header should not be used directly; include getopt.h or
24 unistd.h instead. It does not have a protective #error, because
25 the guard macro for getopt.h in gnulib is not fixed. */
26
27/* Standalone applications should #define __GETOPT_PREFIX to an
28 identifier that prefixes the external functions and variables
29 defined in getopt-core.h and getopt-ext.h. Systematically
30 rename identifiers so that they do not collide with the system
31 functions and variables. Renaming avoids problems with some
32 compilers and linkers. */
33#ifdef __GETOPT_PREFIX
34# ifndef __GETOPT_ID
35# define __GETOPT_CONCAT(x, y) x ## y
36# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
37# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
38# endif
39# undef getopt
40# undef optarg
41# undef opterr
42# undef optind
43# undef optopt
44# define getopt __GETOPT_ID (getopt)
45# define optarg __GETOPT_ID (optarg)
46# define opterr __GETOPT_ID (opterr)
47# define optind __GETOPT_ID (optind)
48# define optopt __GETOPT_ID (optopt)
49
50/* Work around a a problem on macOS, which declares getopt with a
51 trailing __DARWIN_ALIAS(getopt) that would expand to something like
52 __asm("_" "rpl_getopt" "$UNIX2003") were it not for the following
53 hack to suppress the macOS declaration <https://bugs.gnu.org/40205>. */
54# ifdef __APPLE__
55# define _GETOPT
56# endif
57
58/* The system's getopt.h may have already included getopt-core.h to
59 declare the unprefixed identifiers. Undef _GETOPT_CORE_H so that
60 getopt-core.h declares them with prefixes. */
61# undef _GETOPT_CORE_H
62#endif
63
64#include <getopt-core.h>
65
66#endif /* _GETOPT_PFX_CORE_H */
diff --git a/gl/getopt-pfx-ext.h b/gl/getopt-pfx-ext.h
new file mode 100644
index 0000000..8578d72
--- /dev/null
+++ b/gl/getopt-pfx-ext.h
@@ -0,0 +1,70 @@
1/* getopt (GNU extensions) gnulib wrapper header.
2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 This file is part of gnulib.
4 Unlike most of the getopt implementation, it is NOT shared
5 with the GNU C Library.
6
7 This file is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
11
12 This file is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>. */
19
20#ifndef _GETOPT_PFX_EXT_H
21#define _GETOPT_PFX_EXT_H 1
22
23/* This header should not be used directly; include getopt.h instead.
24 It does not have a protective #error, because the guard macro for
25 getopt.h in gnulib is not fixed. */
26
27/* Standalone applications should #define __GETOPT_PREFIX to an
28 identifier that prefixes the external functions and variables
29 defined in getopt-core.h and getopt-ext.h. Systematically
30 rename identifiers so that they do not collide with the system
31 functions and variables. Renaming avoids problems with some
32 compilers and linkers. */
33#ifdef __GETOPT_PREFIX
34# ifndef __GETOPT_ID
35# define __GETOPT_CONCAT(x, y) x ## y
36# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
37# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
38# endif
39# undef getopt_long
40# undef getopt_long_only
41# undef option
42# undef _getopt_internal
43# define getopt_long __GETOPT_ID (getopt_long)
44# define getopt_long_only __GETOPT_ID (getopt_long_only)
45# define option __GETOPT_ID (option)
46# define _getopt_internal __GETOPT_ID (getopt_internal)
47
48/* The system's getopt.h may have already included getopt-ext.h to
49 declare the unprefixed identifiers. Undef _GETOPT_EXT_H so that
50 getopt-ext.h declares them with prefixes. */
51# undef _GETOPT_EXT_H
52#endif
53
54/* Standalone applications get correct prototypes for getopt_long and
55 getopt_long_only; they declare "char **argv". For backward
56 compatibility with old applications, if __GETOPT_PREFIX is not
57 defined, we supply GNU-libc-compatible, but incorrect, prototypes
58 using "char *const *argv". (GNU libc is stuck with the incorrect
59 prototypes, as they are baked into older versions of LSB.) */
60#ifndef __getopt_argv_const
61# if defined __GETOPT_PREFIX
62# define __getopt_argv_const /* empty */
63# else
64# define __getopt_argv_const const
65# endif
66#endif
67
68#include <getopt-ext.h>
69
70#endif /* _GETOPT_PFX_EXT_H */
diff --git a/gl/getopt.c b/gl/getopt.c
index ef0f4ce..1e2441c 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -1,23 +1,21 @@
1/* Getopt for GNU. 1/* Getopt for GNU.
2 NOTE: getopt is part of the C library, so if you don't know what 2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
3 "Keep this file name-space clean" means, talk to drepper@gnu.org 3 This file is part of the GNU C Library and is also part of gnulib.
4 before changing it! 4 Patches to this file should be submitted to both projects.
5 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software 5
6 Foundation, Inc. 6 The GNU C Library is free software; you can redistribute it and/or
7 This file is part of the GNU C Library. 7 modify it under the terms of the GNU Lesser General Public
8 8 License as published by the Free Software Foundation; either
9 This program is free software: you can redistribute it and/or modify 9 version 2.1 of the License, or (at your option) any later version.
10 it under the terms of the GNU General Public License as published by 10
11 the Free Software Foundation; either version 3 of the License, or 11 The GNU C Library is distributed in the hope that it will be useful,
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 GNU General Public License for more details. 14 Lesser General Public License for more details.
18 15
19 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
21 19
22#ifndef _LIBC 20#ifndef _LIBC
23# include <config.h> 21# include <config.h>
@@ -31,30 +29,54 @@
31#include <unistd.h> 29#include <unistd.h>
32 30
33#ifdef _LIBC 31#ifdef _LIBC
32/* When used as part of glibc, error printing must be done differently
33 for standards compliance. getopt is not a cancellation point, so
34 it must not call functions that are, and it is specified by an
35 older standard than stdio locking, so it must not refer to
36 functions in the "user namespace" related to stdio locking.
37 Finally, it must use glibc's internal message translation so that
38 the messages are looked up in the proper text domain. */
34# include <libintl.h> 39# include <libintl.h>
40# define fprintf __fxprintf_nocancel
41# define flockfile(fp) _IO_flockfile (fp)
42# define funlockfile(fp) _IO_funlockfile (fp)
35#else 43#else
36# include "gettext.h" 44# include "gettext.h"
37# define _(msgid) gettext (msgid) 45# define _(msgid) gettext (msgid)
46/* When used standalone, flockfile and funlockfile might not be
47 available. */
48# if (!defined _POSIX_THREAD_SAFE_FUNCTIONS \
49 || (defined _WIN32 && ! defined __CYGWIN__))
50# define flockfile(fp) /* nop */
51# define funlockfile(fp) /* nop */
52# endif
53/* When used standalone, do not attempt to use alloca. */
54# define __libc_use_alloca(size) 0
55# undef alloca
56# define alloca(size) (abort (), (void *)0)
38#endif 57#endif
39 58
40#if defined _LIBC && defined USE_IN_LIBIO 59/* This implementation of 'getopt' has three modes for handling
41# include <wchar.h> 60 options interspersed with non-option arguments. It can stop
42#endif 61 scanning for options at the first non-option argument encountered,
43 62 as POSIX specifies. It can continue scanning for options after the
44/* This version of 'getopt' appears to the caller like standard Unix 'getopt' 63 first non-option argument, but permute 'argv' as it goes so that,
45 but it behaves differently for the user, since it allows the user 64 after 'getopt' is done, all the options precede all the non-option
46 to intersperse the options with the other arguments. 65 arguments and 'optind' points to the first non-option argument.
47 66 Or, it can report non-option arguments as if they were arguments to
48 As 'getopt_long' works, it permutes the elements of ARGV so that, 67 the option character '\x01'.
49 when it is done, all the options precede everything else. Thus 68
50 all application programs are extended to handle flexible argument order. 69 The default behavior of 'getopt_long' is to permute the argument list.
51 70 When this implementation is used standalone, the default behavior of
52 Using 'getopt' or setting the environment variable POSIXLY_CORRECT 71 'getopt' is to stop at the first non-option argument, but when it is
72 used as part of GNU libc it also permutes the argument list. In both
73 cases, setting the environment variable POSIXLY_CORRECT to any value
53 disables permutation. 74 disables permutation.
54 Then the behavior is completely standard.
55 75
56 GNU application programs can use a third alternative mode in which 76 If the first character of the OPTSTRING argument to 'getopt' or
57 they can distinguish the relative order of options and other arguments. */ 77 'getopt_long' is '+', both functions will stop at the first
78 non-option argument. If it is '-', both functions will report
79 non-option arguments as arguments to the option character '\x01'. */
58 80
59#include "getopt_int.h" 81#include "getopt_int.h"
60 82
@@ -95,42 +117,7 @@ int optopt = '?';
95/* Keep a global copy of all internal members of getopt_data. */ 117/* Keep a global copy of all internal members of getopt_data. */
96 118
97static struct _getopt_data getopt_data; 119static struct _getopt_data getopt_data;
98
99
100#if defined HAVE_DECL_GETENV && !HAVE_DECL_GETENV
101extern char *getenv ();
102#endif
103 120
104#ifdef _LIBC
105/* Stored original parameters.
106 XXX This is no good solution. We should rather copy the args so
107 that we can compare them later. But we must not use malloc(3). */
108extern int __libc_argc;
109extern char **__libc_argv;
110
111/* Bash 2.0 gives us an environment variable containing flags
112 indicating ARGV elements that should not be considered arguments. */
113
114# ifdef USE_NONOPTION_FLAGS
115/* Defined in getopt_init.c */
116extern char *__getopt_nonoption_flags;
117# endif
118
119# ifdef USE_NONOPTION_FLAGS
120# define SWAP_FLAGS(ch1, ch2) \
121 if (d->__nonoption_flags_len > 0) \
122 { \
123 char __tmp = __getopt_nonoption_flags[ch1]; \
124 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
125 __getopt_nonoption_flags[ch2] = __tmp; \
126 }
127# else
128# define SWAP_FLAGS(ch1, ch2)
129# endif
130#else /* !_LIBC */
131# define SWAP_FLAGS(ch1, ch2)
132#endif /* _LIBC */
133
134/* Exchange two adjacent subsequences of ARGV. 121/* Exchange two adjacent subsequences of ARGV.
135 One subsequence is elements [first_nonopt,last_nonopt) 122 One subsequence is elements [first_nonopt,last_nonopt)
136 which contains all the non-options that have been skipped so far. 123 which contains all the non-options that have been skipped so far.
@@ -153,64 +140,40 @@ exchange (char **argv, struct _getopt_data *d)
153 It leaves the longer segment in the right place overall, 140 It leaves the longer segment in the right place overall,
154 but it consists of two parts that need to be swapped next. */ 141 but it consists of two parts that need to be swapped next. */
155 142
156#if defined _LIBC && defined USE_NONOPTION_FLAGS
157 /* First make sure the handling of the '__getopt_nonoption_flags'
158 string can work normally. Our top argument must be in the range
159 of the string. */
160 if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
161 {
162 /* We must extend the array. The user plays games with us and
163 presents new arguments. */
164 char *new_str = malloc (top + 1);
165 if (new_str == NULL)
166 d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
167 else
168 {
169 memset (__mempcpy (new_str, __getopt_nonoption_flags,
170 d->__nonoption_flags_max_len),
171 '\0', top + 1 - d->__nonoption_flags_max_len);
172 d->__nonoption_flags_max_len = top + 1;
173 __getopt_nonoption_flags = new_str;
174 }
175 }
176#endif
177
178 while (top > middle && middle > bottom) 143 while (top > middle && middle > bottom)
179 { 144 {
180 if (top - middle > middle - bottom) 145 if (top - middle > middle - bottom)
181 { 146 {
182 /* Bottom segment is the short one. */ 147 /* Bottom segment is the short one. */
183 int len = middle - bottom; 148 int len = middle - bottom;
184 register int i; 149 int i;
185 150
186 /* Swap it with the top part of the top segment. */ 151 /* Swap it with the top part of the top segment. */
187 for (i = 0; i < len; i++) 152 for (i = 0; i < len; i++)
188 { 153 {
189 tem = argv[bottom + i]; 154 tem = argv[bottom + i];
190 argv[bottom + i] = argv[top - (middle - bottom) + i]; 155 argv[bottom + i] = argv[top - (middle - bottom) + i];
191 argv[top - (middle - bottom) + i] = tem; 156 argv[top - (middle - bottom) + i] = tem;
192 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); 157 }
193 } 158 /* Exclude the moved bottom segment from further swapping. */
194 /* Exclude the moved bottom segment from further swapping. */ 159 top -= len;
195 top -= len; 160 }
196 }
197 else 161 else
198 { 162 {
199 /* Top segment is the short one. */ 163 /* Top segment is the short one. */
200 int len = top - middle; 164 int len = top - middle;
201 register int i; 165 int i;
202 166
203 /* Swap it with the bottom part of the bottom segment. */ 167 /* Swap it with the bottom part of the bottom segment. */
204 for (i = 0; i < len; i++) 168 for (i = 0; i < len; i++)
205 { 169 {
206 tem = argv[bottom + i]; 170 tem = argv[bottom + i];
207 argv[bottom + i] = argv[middle + i]; 171 argv[bottom + i] = argv[middle + i];
208 argv[middle + i] = tem; 172 argv[middle + i] = tem;
209 SWAP_FLAGS (bottom + i, middle + i); 173 }
210 } 174 /* Exclude the moved top segment from further swapping. */
211 /* Exclude the moved top segment from further swapping. */ 175 bottom += len;
212 bottom += len; 176 }
213 }
214 } 177 }
215 178
216 /* Update records for the slots the non-options now occupy. */ 179 /* Update records for the slots the non-options now occupy. */
@@ -219,25 +182,216 @@ exchange (char **argv, struct _getopt_data *d)
219 d->__last_nonopt = d->optind; 182 d->__last_nonopt = d->optind;
220} 183}
221 184
222/* Initialize the internal data when the first call is made. */ 185/* Process the argument starting with d->__nextchar as a long option.
186 d->optind should *not* have been advanced over this argument.
187
188 If the value returned is -1, it was not actually a long option, the
189 state is unchanged, and the argument should be processed as a set
190 of short options (this can only happen when long_only is true).
191 Otherwise, the option (and its argument, if any) have been consumed
192 and the return value is the value to return from _getopt_internal_r. */
193static int
194process_long_option (int argc, char **argv, const char *optstring,
195 const struct option *longopts, int *longind,
196 int long_only, struct _getopt_data *d,
197 int print_errors, const char *prefix)
198{
199 char *nameend;
200 size_t namelen;
201 const struct option *p;
202 const struct option *pfound = NULL;
203 int n_options;
204 int option_index;
205
206 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
207 /* Do nothing. */ ;
208 namelen = nameend - d->__nextchar;
209
210 /* First look for an exact match, counting the options as a side
211 effect. */
212 for (p = longopts, n_options = 0; p->name; p++, n_options++)
213 if (!strncmp (p->name, d->__nextchar, namelen)
214 && namelen == strlen (p->name))
215 {
216 /* Exact match found. */
217 pfound = p;
218 option_index = n_options;
219 break;
220 }
221
222 if (pfound == NULL)
223 {
224 /* Didn't find an exact match, so look for abbreviations. */
225 unsigned char *ambig_set = NULL;
226 int ambig_malloced = 0;
227 int ambig_fallback = 0;
228 int indfound = -1;
229
230 for (p = longopts, option_index = 0; p->name; p++, option_index++)
231 if (!strncmp (p->name, d->__nextchar, namelen))
232 {
233 if (pfound == NULL)
234 {
235 /* First nonexact match found. */
236 pfound = p;
237 indfound = option_index;
238 }
239 else if (long_only
240 || pfound->has_arg != p->has_arg
241 || pfound->flag != p->flag
242 || pfound->val != p->val)
243 {
244 /* Second or later nonexact match found. */
245 if (!ambig_fallback)
246 {
247 if (!print_errors)
248 /* Don't waste effort tracking the ambig set if
249 we're not going to print it anyway. */
250 ambig_fallback = 1;
251 else if (!ambig_set)
252 {
253 if (__libc_use_alloca (n_options))
254 ambig_set = alloca (n_options);
255 else if ((ambig_set = malloc (n_options)) == NULL)
256 /* Fall back to simpler error message. */
257 ambig_fallback = 1;
258 else
259 ambig_malloced = 1;
260
261 if (ambig_set)
262 {
263 memset (ambig_set, 0, n_options);
264 ambig_set[indfound] = 1;
265 }
266 }
267 if (ambig_set)
268 ambig_set[option_index] = 1;
269 }
270 }
271 }
272
273 if (ambig_set || ambig_fallback)
274 {
275 if (print_errors)
276 {
277 if (ambig_fallback)
278 fprintf (stderr, _("%s: option '%s%s' is ambiguous\n"),
279 argv[0], prefix, d->__nextchar);
280 else
281 {
282 flockfile (stderr);
283 fprintf (stderr,
284 _("%s: option '%s%s' is ambiguous; possibilities:"),
285 argv[0], prefix, d->__nextchar);
286
287 for (option_index = 0; option_index < n_options; option_index++)
288 if (ambig_set[option_index])
289 fprintf (stderr, " '%s%s'",
290 prefix, longopts[option_index].name);
291
292 /* This must use 'fprintf' even though it's only
293 printing a single character, so that it goes through
294 __fxprintf_nocancel when compiled as part of glibc. */
295 fprintf (stderr, "\n");
296 funlockfile (stderr);
297 }
298 }
299 if (ambig_malloced)
300 free (ambig_set);
301 d->__nextchar += strlen (d->__nextchar);
302 d->optind++;
303 d->optopt = 0;
304 return '?';
305 }
306
307 option_index = indfound;
308 }
309
310 if (pfound == NULL)
311 {
312 /* Can't find it as a long option. If this is not getopt_long_only,
313 or the option starts with '--' or is not a valid short option,
314 then it's an error. */
315 if (!long_only || argv[d->optind][1] == '-'
316 || strchr (optstring, *d->__nextchar) == NULL)
317 {
318 if (print_errors)
319 fprintf (stderr, _("%s: unrecognized option '%s%s'\n"),
320 argv[0], prefix, d->__nextchar);
321
322 d->__nextchar = NULL;
323 d->optind++;
324 d->optopt = 0;
325 return '?';
326 }
327
328 /* Otherwise interpret it as a short option. */
329 return -1;
330 }
331
332 /* We have found a matching long option. Consume it. */
333 d->optind++;
334 d->__nextchar = NULL;
335 if (*nameend)
336 {
337 /* Don't test has_arg with >, because some C compilers don't
338 allow it to be used on enums. */
339 if (pfound->has_arg)
340 d->optarg = nameend + 1;
341 else
342 {
343 if (print_errors)
344 fprintf (stderr,
345 _("%s: option '%s%s' doesn't allow an argument\n"),
346 argv[0], prefix, pfound->name);
347
348 d->optopt = pfound->val;
349 return '?';
350 }
351 }
352 else if (pfound->has_arg == 1)
353 {
354 if (d->optind < argc)
355 d->optarg = argv[d->optind++];
356 else
357 {
358 if (print_errors)
359 fprintf (stderr,
360 _("%s: option '%s%s' requires an argument\n"),
361 argv[0], prefix, pfound->name);
362
363 d->optopt = pfound->val;
364 return optstring[0] == ':' ? ':' : '?';
365 }
366 }
367
368 if (longind != NULL)
369 *longind = option_index;
370 if (pfound->flag)
371 {
372 *(pfound->flag) = pfound->val;
373 return 0;
374 }
375 return pfound->val;
376}
377
378/* Initialize internal data upon the first call to getopt. */
223 379
224static const char * 380static const char *
225_getopt_initialize (int argc _GL_UNUSED, 381_getopt_initialize (_GL_UNUSED int argc,
226 char **argv _GL_UNUSED, const char *optstring, 382 _GL_UNUSED char **argv, const char *optstring,
227 struct _getopt_data *d, int posixly_correct) 383 struct _getopt_data *d, int posixly_correct)
228{ 384{
229 /* Start processing options with ARGV-element 1 (since ARGV-element 0 385 /* Start processing options with ARGV-element 1 (since ARGV-element 0
230 is the program name); the sequence of previously skipped 386 is the program name); the sequence of previously skipped
231 non-option ARGV-elements is empty. */ 387 non-option ARGV-elements is empty. */
388 if (d->optind == 0)
389 d->optind = 1;
232 390
233 d->__first_nonopt = d->__last_nonopt = d->optind; 391 d->__first_nonopt = d->__last_nonopt = d->optind;
234
235 d->__nextchar = NULL; 392 d->__nextchar = NULL;
236 393
237 d->__posixly_correct = posixly_correct || !!getenv ("POSIXLY_CORRECT");
238
239 /* Determine how to handle the ordering of options and nonoptions. */ 394 /* Determine how to handle the ordering of options and nonoptions. */
240
241 if (optstring[0] == '-') 395 if (optstring[0] == '-')
242 { 396 {
243 d->__ordering = RETURN_IN_ORDER; 397 d->__ordering = RETURN_IN_ORDER;
@@ -248,41 +402,12 @@ _getopt_initialize (int argc _GL_UNUSED,
248 d->__ordering = REQUIRE_ORDER; 402 d->__ordering = REQUIRE_ORDER;
249 ++optstring; 403 ++optstring;
250 } 404 }
251 else if (d->__posixly_correct) 405 else if (posixly_correct || !!getenv ("POSIXLY_CORRECT"))
252 d->__ordering = REQUIRE_ORDER; 406 d->__ordering = REQUIRE_ORDER;
253 else 407 else
254 d->__ordering = PERMUTE; 408 d->__ordering = PERMUTE;
255 409
256#if defined _LIBC && defined USE_NONOPTION_FLAGS 410 d->__initialized = 1;
257 if (!d->__posixly_correct
258 && argc == __libc_argc && argv == __libc_argv)
259 {
260 if (d->__nonoption_flags_max_len == 0)
261 {
262 if (__getopt_nonoption_flags == NULL
263 || __getopt_nonoption_flags[0] == '\0')
264 d->__nonoption_flags_max_len = -1;
265 else
266 {
267 const char *orig_str = __getopt_nonoption_flags;
268 int len = d->__nonoption_flags_max_len = strlen (orig_str);
269 if (d->__nonoption_flags_max_len < argc)
270 d->__nonoption_flags_max_len = argc;
271 __getopt_nonoption_flags =
272 (char *) malloc (d->__nonoption_flags_max_len);
273 if (__getopt_nonoption_flags == NULL)
274 d->__nonoption_flags_max_len = -1;
275 else
276 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
277 '\0', d->__nonoption_flags_max_len - len);
278 }
279 }
280 d->__nonoption_flags_len = d->__nonoption_flags_max_len;
281 }
282 else
283 d->__nonoption_flags_len = 0;
284#endif
285
286 return optstring; 411 return optstring;
287} 412}
288 413
@@ -344,8 +469,8 @@ _getopt_initialize (int argc _GL_UNUSED,
344 469
345int 470int
346_getopt_internal_r (int argc, char **argv, const char *optstring, 471_getopt_internal_r (int argc, char **argv, const char *optstring,
347 const struct option *longopts, int *longind, 472 const struct option *longopts, int *longind,
348 int long_only, struct _getopt_data *d, int posixly_correct) 473 int long_only, struct _getopt_data *d, int posixly_correct)
349{ 474{
350 int print_errors = d->opterr; 475 int print_errors = d->opterr;
351 476
@@ -355,431 +480,129 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
355 d->optarg = NULL; 480 d->optarg = NULL;
356 481
357 if (d->optind == 0 || !d->__initialized) 482 if (d->optind == 0 || !d->__initialized)
358 { 483 optstring = _getopt_initialize (argc, argv, optstring, d, posixly_correct);
359 if (d->optind == 0)
360 d->optind = 1; /* Don't scan ARGV[0], the program name. */
361 optstring = _getopt_initialize (argc, argv, optstring, d,
362 posixly_correct);
363 d->__initialized = 1;
364 }
365 else if (optstring[0] == '-' || optstring[0] == '+') 484 else if (optstring[0] == '-' || optstring[0] == '+')
366 optstring++; 485 optstring++;
486
367 if (optstring[0] == ':') 487 if (optstring[0] == ':')
368 print_errors = 0; 488 print_errors = 0;
369 489
370 /* Test whether ARGV[optind] points to a non-option argument. 490 /* Test whether ARGV[optind] points to a non-option argument. */
371 Either it does not have option syntax, or there is an environment flag 491#define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
372 from the shell indicating it is not an option. The later information
373 is only used when the used in the GNU libc. */
374#if defined _LIBC && defined USE_NONOPTION_FLAGS
375# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
376 || (d->optind < d->__nonoption_flags_len \
377 && __getopt_nonoption_flags[d->optind] == '1'))
378#else
379# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
380#endif
381 492
382 if (d->__nextchar == NULL || *d->__nextchar == '\0') 493 if (d->__nextchar == NULL || *d->__nextchar == '\0')
383 { 494 {
384 /* Advance to the next ARGV-element. */ 495 /* Advance to the next ARGV-element. */
385 496
386 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been 497 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
387 moved back by the user (who may also have changed the arguments). */ 498 moved back by the user (who may also have changed the arguments). */
388 if (d->__last_nonopt > d->optind) 499 if (d->__last_nonopt > d->optind)
389 d->__last_nonopt = d->optind; 500 d->__last_nonopt = d->optind;
390 if (d->__first_nonopt > d->optind) 501 if (d->__first_nonopt > d->optind)
391 d->__first_nonopt = d->optind; 502 d->__first_nonopt = d->optind;
392 503
393 if (d->__ordering == PERMUTE) 504 if (d->__ordering == PERMUTE)
394 { 505 {
395 /* If we have just processed some options following some non-options, 506 /* If we have just processed some options following some non-options,
396 exchange them so that the options come first. */ 507 exchange them so that the options come first. */
397 508
398 if (d->__first_nonopt != d->__last_nonopt 509 if (d->__first_nonopt != d->__last_nonopt
399 && d->__last_nonopt != d->optind) 510 && d->__last_nonopt != d->optind)
400 exchange ((char **) argv, d); 511 exchange (argv, d);
401 else if (d->__last_nonopt != d->optind) 512 else if (d->__last_nonopt != d->optind)
402 d->__first_nonopt = d->optind; 513 d->__first_nonopt = d->optind;
403 514
404 /* Skip any additional non-options 515 /* Skip any additional non-options
405 and extend the range of non-options previously skipped. */ 516 and extend the range of non-options previously skipped. */
406 517
407 while (d->optind < argc && NONOPTION_P) 518 while (d->optind < argc && NONOPTION_P)
408 d->optind++; 519 d->optind++;
409 d->__last_nonopt = d->optind; 520 d->__last_nonopt = d->optind;
410 } 521 }
411 522
412 /* The special ARGV-element '--' means premature end of options. 523 /* The special ARGV-element '--' means premature end of options.
413 Skip it like a null option, 524 Skip it like a null option,
414 then exchange with previous non-options as if it were an option, 525 then exchange with previous non-options as if it were an option,
415 then skip everything else like a non-option. */ 526 then skip everything else like a non-option. */
416 527
417 if (d->optind != argc && !strcmp (argv[d->optind], "--")) 528 if (d->optind != argc && !strcmp (argv[d->optind], "--"))
418 { 529 {
419 d->optind++; 530 d->optind++;
420 531
421 if (d->__first_nonopt != d->__last_nonopt 532 if (d->__first_nonopt != d->__last_nonopt
422 && d->__last_nonopt != d->optind) 533 && d->__last_nonopt != d->optind)
423 exchange ((char **) argv, d); 534 exchange (argv, d);
424 else if (d->__first_nonopt == d->__last_nonopt) 535 else if (d->__first_nonopt == d->__last_nonopt)
425 d->__first_nonopt = d->optind; 536 d->__first_nonopt = d->optind;
426 d->__last_nonopt = argc; 537 d->__last_nonopt = argc;
427 538
428 d->optind = argc; 539 d->optind = argc;
429 } 540 }
430 541
431 /* If we have done all the ARGV-elements, stop the scan 542 /* If we have done all the ARGV-elements, stop the scan
432 and back over any non-options that we skipped and permuted. */ 543 and back over any non-options that we skipped and permuted. */
433 544
434 if (d->optind == argc) 545 if (d->optind == argc)
435 { 546 {
436 /* Set the next-arg-index to point at the non-options 547 /* Set the next-arg-index to point at the non-options
437 that we previously skipped, so the caller will digest them. */ 548 that we previously skipped, so the caller will digest them. */
438 if (d->__first_nonopt != d->__last_nonopt) 549 if (d->__first_nonopt != d->__last_nonopt)
439 d->optind = d->__first_nonopt; 550 d->optind = d->__first_nonopt;
440 return -1; 551 return -1;
441 } 552 }
442 553
443 /* If we have come to a non-option and did not permute it, 554 /* If we have come to a non-option and did not permute it,
444 either stop the scan or describe it to the caller and pass it by. */ 555 either stop the scan or describe it to the caller and pass it by. */
445 556
446 if (NONOPTION_P) 557 if (NONOPTION_P)
447 { 558 {
448 if (d->__ordering == REQUIRE_ORDER) 559 if (d->__ordering == REQUIRE_ORDER)
449 return -1; 560 return -1;
450 d->optarg = argv[d->optind++]; 561 d->optarg = argv[d->optind++];
451 return 1; 562 return 1;
452 } 563 }
453 564
454 /* We have found another option-ARGV-element. 565 /* We have found another option-ARGV-element.
455 Skip the initial punctuation. */ 566 Check whether it might be a long option. */
456 567 if (longopts)
457 d->__nextchar = (argv[d->optind] + 1 568 {
458 + (longopts != NULL && argv[d->optind][1] == '-')); 569 if (argv[d->optind][1] == '-')
459 } 570 {
460 571 /* "--foo" is always a long option. The special option
461 /* Decode the current option-ARGV-element. */ 572 "--" was handled above. */
462 573 d->__nextchar = argv[d->optind] + 2;
463 /* Check whether the ARGV-element is a long option. 574 return process_long_option (argc, argv, optstring, longopts,
464 575 longind, long_only, d,
465 If long_only and the ARGV-element has the form "-f", where f is 576 print_errors, "--");
466 a valid short option, don't consider it an abbreviated form of 577 }
467 a long option that starts with f. Otherwise there would be no 578
468 way to give the -f short option. 579 /* If long_only and the ARGV-element has the form "-f",
469 580 where f is a valid short option, don't consider it an
470 On the other hand, if there's a long option "fubar" and 581 abbreviated form of a long option that starts with f.
471 the ARGV-element is "-fu", do consider that an abbreviation of 582 Otherwise there would be no way to give the -f short
472 the long option, just like "--fu", and not "-f" with arg "u". 583 option.
473 584
474 This distinction seems to be the most useful approach. */ 585 On the other hand, if there's a long option "fubar" and
475 586 the ARGV-element is "-fu", do consider that an
476 if (longopts != NULL 587 abbreviation of the long option, just like "--fu", and
477 && (argv[d->optind][1] == '-' 588 not "-f" with arg "u".
478 || (long_only && (argv[d->optind][2] 589
479 || !strchr (optstring, argv[d->optind][1]))))) 590 This distinction seems to be the most useful approach. */
480 { 591 if (long_only && (argv[d->optind][2]
481 char *nameend; 592 || !strchr (optstring, argv[d->optind][1])))
482 unsigned int namelen; 593 {
483 const struct option *p; 594 int code;
484 const struct option *pfound = NULL; 595 d->__nextchar = argv[d->optind] + 1;
485 struct option_list 596 code = process_long_option (argc, argv, optstring, longopts,
486 { 597 longind, long_only, d,
487 const struct option *p; 598 print_errors, "-");
488 struct option_list *next; 599 if (code != -1)
489 } *ambig_list = NULL; 600 return code;
490 int exact = 0; 601 }
491 int indfound = -1; 602 }
492 int option_index; 603
493 604 /* It is not a long option. Skip the initial punctuation. */
494 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) 605 d->__nextchar = argv[d->optind] + 1;
495 /* Do nothing. */ ;
496 namelen = nameend - d->__nextchar;
497
498 /* Test all long options for either exact match
499 or abbreviated matches. */
500 for (p = longopts, option_index = 0; p->name; p++, option_index++)
501 if (!strncmp (p->name, d->__nextchar, namelen))
502 {
503 if (namelen == (unsigned int) strlen (p->name))
504 {
505 /* Exact match found. */
506 pfound = p;
507 indfound = option_index;
508 exact = 1;
509 break;
510 }
511 else if (pfound == NULL)
512 {
513 /* First nonexact match found. */
514 pfound = p;
515 indfound = option_index;
516 }
517 else if (long_only
518 || pfound->has_arg != p->has_arg
519 || pfound->flag != p->flag
520 || pfound->val != p->val)
521 {
522 /* Second or later nonexact match found. */
523 struct option_list *newp = malloc (sizeof (*newp));
524 newp->p = p;
525 newp->next = ambig_list;
526 ambig_list = newp;
527 }
528 }
529
530 if (ambig_list != NULL && !exact)
531 {
532 if (print_errors)
533 {
534 struct option_list first;
535 first.p = pfound;
536 first.next = ambig_list;
537 ambig_list = &first;
538
539#if defined _LIBC && defined USE_IN_LIBIO
540 char *buf = NULL;
541 size_t buflen = 0;
542
543 FILE *fp = open_memstream (&buf, &buflen);
544 if (fp != NULL)
545 {
546 fprintf (fp,
547 _("%s: option '%s' is ambiguous; possibilities:"),
548 argv[0], argv[d->optind]);
549
550 do
551 {
552 fprintf (fp, " '--%s'", ambig_list->p->name);
553 ambig_list = ambig_list->next;
554 }
555 while (ambig_list != NULL);
556
557 fputc_unlocked ('\n', fp);
558
559 if (__builtin_expect (fclose (fp) != EOF, 1))
560 {
561 _IO_flockfile (stderr);
562
563 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
564 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
565
566 __fxprintf (NULL, "%s", buf);
567
568 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
569 _IO_funlockfile (stderr);
570
571 free (buf);
572 }
573 }
574#else
575 fprintf (stderr,
576 _("%s: option '%s' is ambiguous; possibilities:"),
577 argv[0], argv[d->optind]);
578 do
579 {
580 fprintf (stderr, " '--%s'", ambig_list->p->name);
581 ambig_list = ambig_list->next;
582 }
583 while (ambig_list != NULL);
584
585 fputc ('\n', stderr);
586#endif
587 }
588 d->__nextchar += strlen (d->__nextchar);
589 d->optind++;
590 d->optopt = 0;
591 return '?';
592 }
593
594 while (ambig_list != NULL)
595 {
596 struct option_list *pn = ambig_list->next;
597 free (ambig_list);
598 ambig_list = pn;
599 }
600
601 if (pfound != NULL)
602 {
603 option_index = indfound;
604 d->optind++;
605 if (*nameend)
606 {
607 /* Don't test has_arg with >, because some C compilers don't
608 allow it to be used on enums. */
609 if (pfound->has_arg)
610 d->optarg = nameend + 1;
611 else
612 {
613 if (print_errors)
614 {
615#if defined _LIBC && defined USE_IN_LIBIO
616 char *buf;
617 int n;
618#endif
619
620 if (argv[d->optind - 1][1] == '-')
621 {
622 /* --option */
623#if defined _LIBC && defined USE_IN_LIBIO
624 n = __asprintf (&buf, _("\
625%s: option '--%s' doesn't allow an argument\n"),
626 argv[0], pfound->name);
627#else
628 fprintf (stderr, _("\
629%s: option '--%s' doesn't allow an argument\n"),
630 argv[0], pfound->name);
631#endif
632 }
633 else
634 {
635 /* +option or -option */
636#if defined _LIBC && defined USE_IN_LIBIO
637 n = __asprintf (&buf, _("\
638%s: option '%c%s' doesn't allow an argument\n"),
639 argv[0], argv[d->optind - 1][0],
640 pfound->name);
641#else
642 fprintf (stderr, _("\
643%s: option '%c%s' doesn't allow an argument\n"),
644 argv[0], argv[d->optind - 1][0],
645 pfound->name);
646#endif
647 }
648
649#if defined _LIBC && defined USE_IN_LIBIO
650 if (n >= 0)
651 {
652 _IO_flockfile (stderr);
653
654 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
655 ((_IO_FILE *) stderr)->_flags2
656 |= _IO_FLAGS2_NOTCANCEL;
657
658 __fxprintf (NULL, "%s", buf);
659
660 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
661 _IO_funlockfile (stderr);
662
663 free (buf);
664 }
665#endif
666 }
667
668 d->__nextchar += strlen (d->__nextchar);
669
670 d->optopt = pfound->val;
671 return '?';
672 }
673 }
674 else if (pfound->has_arg == 1)
675 {
676 if (d->optind < argc)
677 d->optarg = argv[d->optind++];
678 else
679 {
680 if (print_errors)
681 {
682#if defined _LIBC && defined USE_IN_LIBIO
683 char *buf;
684
685 if (__asprintf (&buf, _("\
686%s: option '--%s' requires an argument\n"),
687 argv[0], pfound->name) >= 0)
688 {
689 _IO_flockfile (stderr);
690
691 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
692 ((_IO_FILE *) stderr)->_flags2
693 |= _IO_FLAGS2_NOTCANCEL;
694
695 __fxprintf (NULL, "%s", buf);
696
697 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
698 _IO_funlockfile (stderr);
699
700 free (buf);
701 }
702#else
703 fprintf (stderr,
704 _("%s: option '--%s' requires an argument\n"),
705 argv[0], pfound->name);
706#endif
707 }
708 d->__nextchar += strlen (d->__nextchar);
709 d->optopt = pfound->val;
710 return optstring[0] == ':' ? ':' : '?';
711 }
712 }
713 d->__nextchar += strlen (d->__nextchar);
714 if (longind != NULL)
715 *longind = option_index;
716 if (pfound->flag)
717 {
718 *(pfound->flag) = pfound->val;
719 return 0;
720 }
721 return pfound->val;
722 }
723
724 /* Can't find it as a long option. If this is not getopt_long_only,
725 or the option starts with '--' or is not a valid short
726 option, then it's an error.
727 Otherwise interpret it as a short option. */
728 if (!long_only || argv[d->optind][1] == '-'
729 || strchr (optstring, *d->__nextchar) == NULL)
730 {
731 if (print_errors)
732 {
733#if defined _LIBC && defined USE_IN_LIBIO
734 char *buf;
735 int n;
736#endif
737
738 if (argv[d->optind][1] == '-')
739 {
740 /* --option */
741#if defined _LIBC && defined USE_IN_LIBIO
742 n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"),
743 argv[0], d->__nextchar);
744#else
745 fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
746 argv[0], d->__nextchar);
747#endif
748 }
749 else
750 {
751 /* +option or -option */
752#if defined _LIBC && defined USE_IN_LIBIO
753 n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"),
754 argv[0], argv[d->optind][0], d->__nextchar);
755#else
756 fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
757 argv[0], argv[d->optind][0], d->__nextchar);
758#endif
759 }
760
761#if defined _LIBC && defined USE_IN_LIBIO
762 if (n >= 0)
763 {
764 _IO_flockfile (stderr);
765
766 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
767 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
768
769 __fxprintf (NULL, "%s", buf);
770
771 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
772 _IO_funlockfile (stderr);
773
774 free (buf);
775 }
776#endif
777 }
778 d->__nextchar = (char *) "";
779 d->optind++;
780 d->optopt = 0;
781 return '?';
782 }
783 } 606 }
784 607
785 /* Look at and handle the next short option-character. */ 608 /* Look at and handle the next short option-character. */
@@ -794,331 +617,83 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
794 617
795 if (temp == NULL || c == ':' || c == ';') 618 if (temp == NULL || c == ':' || c == ';')
796 { 619 {
797 if (print_errors) 620 if (print_errors)
798 { 621 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
799#if defined _LIBC && defined USE_IN_LIBIO 622 d->optopt = c;
800 char *buf; 623 return '?';
801 int n;
802#endif
803
804#if defined _LIBC && defined USE_IN_LIBIO
805 n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
806 argv[0], c);
807#else
808 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
809#endif
810
811#if defined _LIBC && defined USE_IN_LIBIO
812 if (n >= 0)
813 {
814 _IO_flockfile (stderr);
815
816 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
817 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
818
819 __fxprintf (NULL, "%s", buf);
820
821 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
822 _IO_funlockfile (stderr);
823
824 free (buf);
825 }
826#endif
827 }
828 d->optopt = c;
829 return '?';
830 } 624 }
625
831 /* Convenience. Treat POSIX -W foo same as long option --foo */ 626 /* Convenience. Treat POSIX -W foo same as long option --foo */
832 if (temp[0] == 'W' && temp[1] == ';') 627 if (temp[0] == 'W' && temp[1] == ';' && longopts != NULL)
833 { 628 {
834 char *nameend; 629 /* This is an option that requires an argument. */
835 const struct option *p; 630 if (*d->__nextchar != '\0')
836 const struct option *pfound = NULL; 631 d->optarg = d->__nextchar;
837 int exact = 0; 632 else if (d->optind == argc)
838 int ambig = 0; 633 {
839 int indfound = 0; 634 if (print_errors)
840 int option_index; 635 fprintf (stderr,
841 636 _("%s: option requires an argument -- '%c'\n"),
842 if (longopts == NULL) 637 argv[0], c);
843 goto no_longs; 638
844 639 d->optopt = c;
845 /* This is an option that requires an argument. */ 640 if (optstring[0] == ':')
846 if (*d->__nextchar != '\0') 641 c = ':';
847 { 642 else
848 d->optarg = d->__nextchar; 643 c = '?';
849 /* If we end this ARGV-element by taking the rest as an arg, 644 return c;
850 we must advance to the next element now. */ 645 }
851 d->optind++; 646 else
852 } 647 d->optarg = argv[d->optind];
853 else if (d->optind == argc) 648
854 { 649 d->__nextchar = d->optarg;
855 if (print_errors) 650 d->optarg = NULL;
856 { 651 return process_long_option (argc, argv, optstring, longopts, longind,
857#if defined _LIBC && defined USE_IN_LIBIO 652 0 /* long_only */, d, print_errors, "-W ");
858 char *buf;
859
860 if (__asprintf (&buf,
861 _("%s: option requires an argument -- '%c'\n"),
862 argv[0], c) >= 0)
863 {
864 _IO_flockfile (stderr);
865
866 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
867 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
868
869 __fxprintf (NULL, "%s", buf);
870
871 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
872 _IO_funlockfile (stderr);
873
874 free (buf);
875 }
876#else
877 fprintf (stderr,
878 _("%s: option requires an argument -- '%c'\n"),
879 argv[0], c);
880#endif
881 }
882 d->optopt = c;
883 if (optstring[0] == ':')
884 c = ':';
885 else
886 c = '?';
887 return c;
888 }
889 else
890 /* We already incremented 'd->optind' once;
891 increment it again when taking next ARGV-elt as argument. */
892 d->optarg = argv[d->optind++];
893
894 /* optarg is now the argument, see if it's in the
895 table of longopts. */
896
897 for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
898 nameend++)
899 /* Do nothing. */ ;
900
901 /* Test all long options for either exact match
902 or abbreviated matches. */
903 for (p = longopts, option_index = 0; p->name; p++, option_index++)
904 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
905 {
906 if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
907 {
908 /* Exact match found. */
909 pfound = p;
910 indfound = option_index;
911 exact = 1;
912 break;
913 }
914 else if (pfound == NULL)
915 {
916 /* First nonexact match found. */
917 pfound = p;
918 indfound = option_index;
919 }
920 else if (long_only
921 || pfound->has_arg != p->has_arg
922 || pfound->flag != p->flag
923 || pfound->val != p->val)
924 /* Second or later nonexact match found. */
925 ambig = 1;
926 }
927 if (ambig && !exact)
928 {
929 if (print_errors)
930 {
931#if defined _LIBC && defined USE_IN_LIBIO
932 char *buf;
933
934 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
935 argv[0], d->optarg) >= 0)
936 {
937 _IO_flockfile (stderr);
938
939 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
940 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
941
942 __fxprintf (NULL, "%s", buf);
943
944 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
945 _IO_funlockfile (stderr);
946
947 free (buf);
948 }
949#else
950 fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
951 argv[0], d->optarg);
952#endif
953 }
954 d->__nextchar += strlen (d->__nextchar);
955 d->optind++;
956 return '?';
957 }
958 if (pfound != NULL)
959 {
960 option_index = indfound;
961 if (*nameend)
962 {
963 /* Don't test has_arg with >, because some C compilers don't
964 allow it to be used on enums. */
965 if (pfound->has_arg)
966 d->optarg = nameend + 1;
967 else
968 {
969 if (print_errors)
970 {
971#if defined _LIBC && defined USE_IN_LIBIO
972 char *buf;
973
974 if (__asprintf (&buf, _("\
975%s: option '-W %s' doesn't allow an argument\n"),
976 argv[0], pfound->name) >= 0)
977 {
978 _IO_flockfile (stderr);
979
980 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
981 ((_IO_FILE *) stderr)->_flags2
982 |= _IO_FLAGS2_NOTCANCEL;
983
984 __fxprintf (NULL, "%s", buf);
985
986 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
987 _IO_funlockfile (stderr);
988
989 free (buf);
990 }
991#else
992 fprintf (stderr, _("\
993%s: option '-W %s' doesn't allow an argument\n"),
994 argv[0], pfound->name);
995#endif
996 }
997
998 d->__nextchar += strlen (d->__nextchar);
999 return '?';
1000 }
1001 }
1002 else if (pfound->has_arg == 1)
1003 {
1004 if (d->optind < argc)
1005 d->optarg = argv[d->optind++];
1006 else
1007 {
1008 if (print_errors)
1009 {
1010#if defined _LIBC && defined USE_IN_LIBIO
1011 char *buf;
1012
1013 if (__asprintf (&buf, _("\
1014%s: option '-W %s' requires an argument\n"),
1015 argv[0], pfound->name) >= 0)
1016 {
1017 _IO_flockfile (stderr);
1018
1019 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
1020 ((_IO_FILE *) stderr)->_flags2
1021 |= _IO_FLAGS2_NOTCANCEL;
1022
1023 __fxprintf (NULL, "%s", buf);
1024
1025 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
1026 _IO_funlockfile (stderr);
1027
1028 free (buf);
1029 }
1030#else
1031 fprintf (stderr, _("\
1032%s: option '-W %s' requires an argument\n"),
1033 argv[0], pfound->name);
1034#endif
1035 }
1036 d->__nextchar += strlen (d->__nextchar);
1037 return optstring[0] == ':' ? ':' : '?';
1038 }
1039 }
1040 else
1041 d->optarg = NULL;
1042 d->__nextchar += strlen (d->__nextchar);
1043 if (longind != NULL)
1044 *longind = option_index;
1045 if (pfound->flag)
1046 {
1047 *(pfound->flag) = pfound->val;
1048 return 0;
1049 }
1050 return pfound->val;
1051 }
1052
1053 no_longs:
1054 d->__nextchar = NULL;
1055 return 'W'; /* Let the application handle it. */
1056 } 653 }
1057 if (temp[1] == ':') 654 if (temp[1] == ':')
1058 { 655 {
1059 if (temp[2] == ':') 656 if (temp[2] == ':')
1060 { 657 {
1061 /* This is an option that accepts an argument optionally. */ 658 /* This is an option that accepts an argument optionally. */
1062 if (*d->__nextchar != '\0') 659 if (*d->__nextchar != '\0')
1063 { 660 {
1064 d->optarg = d->__nextchar; 661 d->optarg = d->__nextchar;
1065 d->optind++; 662 d->optind++;
1066 } 663 }
1067 else 664 else
1068 d->optarg = NULL; 665 d->optarg = NULL;
1069 d->__nextchar = NULL; 666 d->__nextchar = NULL;
1070 } 667 }
1071 else 668 else
1072 { 669 {
1073 /* This is an option that requires an argument. */ 670 /* This is an option that requires an argument. */
1074 if (*d->__nextchar != '\0') 671 if (*d->__nextchar != '\0')
1075 { 672 {
1076 d->optarg = d->__nextchar; 673 d->optarg = d->__nextchar;
1077 /* If we end this ARGV-element by taking the rest as an arg, 674 /* If we end this ARGV-element by taking the rest as an arg,
1078 we must advance to the next element now. */ 675 we must advance to the next element now. */
1079 d->optind++; 676 d->optind++;
1080 } 677 }
1081 else if (d->optind == argc) 678 else if (d->optind == argc)
1082 { 679 {
1083 if (print_errors) 680 if (print_errors)
1084 { 681 fprintf (stderr,
1085#if defined _LIBC && defined USE_IN_LIBIO 682 _("%s: option requires an argument -- '%c'\n"),
1086 char *buf; 683 argv[0], c);
1087 684
1088 if (__asprintf (&buf, _("\ 685 d->optopt = c;
1089%s: option requires an argument -- '%c'\n"), 686 if (optstring[0] == ':')
1090 argv[0], c) >= 0) 687 c = ':';
1091 { 688 else
1092 _IO_flockfile (stderr); 689 c = '?';
1093 690 }
1094 int old_flags2 = ((_IO_FILE *) stderr)->_flags2; 691 else
1095 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; 692 /* We already incremented 'optind' once;
1096 693 increment it again when taking next ARGV-elt as argument. */
1097 __fxprintf (NULL, "%s", buf); 694 d->optarg = argv[d->optind++];
1098 695 d->__nextchar = NULL;
1099 ((_IO_FILE *) stderr)->_flags2 = old_flags2; 696 }
1100 _IO_funlockfile (stderr);
1101
1102 free (buf);
1103 }
1104#else
1105 fprintf (stderr,
1106 _("%s: option requires an argument -- '%c'\n"),
1107 argv[0], c);
1108#endif
1109 }
1110 d->optopt = c;
1111 if (optstring[0] == ':')
1112 c = ':';
1113 else
1114 c = '?';
1115 }
1116 else
1117 /* We already incremented 'optind' once;
1118 increment it again when taking next ARGV-elt as argument. */
1119 d->optarg = argv[d->optind++];
1120 d->__nextchar = NULL;
1121 }
1122 } 697 }
1123 return c; 698 return c;
1124 } 699 }
@@ -1126,8 +701,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
1126 701
1127int 702int
1128_getopt_internal (int argc, char **argv, const char *optstring, 703_getopt_internal (int argc, char **argv, const char *optstring,
1129 const struct option *longopts, int *longind, int long_only, 704 const struct option *longopts, int *longind, int long_only,
1130 int posixly_correct) 705 int posixly_correct)
1131{ 706{
1132 int result; 707 int result;
1133 708
@@ -1135,8 +710,8 @@ _getopt_internal (int argc, char **argv, const char *optstring,
1135 getopt_data.opterr = opterr; 710 getopt_data.opterr = opterr;
1136 711
1137 result = _getopt_internal_r (argc, argv, optstring, longopts, 712 result = _getopt_internal_r (argc, argv, optstring, longopts,
1138 longind, long_only, &getopt_data, 713 longind, long_only, &getopt_data,
1139 posixly_correct); 714 posixly_correct);
1140 715
1141 optind = getopt_data.optind; 716 optind = getopt_data.optind;
1142 optarg = getopt_data.optarg; 717 optarg = getopt_data.optarg;
@@ -1145,32 +720,23 @@ _getopt_internal (int argc, char **argv, const char *optstring,
1145 return result; 720 return result;
1146} 721}
1147 722
1148/* glibc gets a LSB-compliant getopt. 723/* glibc gets a LSB-compliant getopt and a POSIX-complaint __posix_getopt.
1149 Standalone applications get a POSIX-compliant getopt. */ 724 Standalone applications just get a POSIX-compliant getopt.
1150#if _LIBC 725 POSIX and LSB both require these functions to take 'char *const *argv'
1151enum { POSIXLY_CORRECT = 0 }; 726 even though this is incorrect (because of the permutation). */
1152#else 727#define GETOPT_ENTRY(NAME, POSIXLY_CORRECT) \
1153enum { POSIXLY_CORRECT = 1 }; 728 int \
1154#endif 729 NAME (int argc, char *const *argv, const char *optstring) \
1155 730 { \
1156int 731 return _getopt_internal (argc, (char **)argv, optstring, \
1157getopt (int argc, char *const *argv, const char *optstring) 732 0, 0, 0, POSIXLY_CORRECT); \
1158{ 733 }
1159 return _getopt_internal (argc, (char **) argv, optstring,
1160 (const struct option *) 0,
1161 (int *) 0,
1162 0, POSIXLY_CORRECT);
1163}
1164 734
1165#ifdef _LIBC 735#ifdef _LIBC
1166int 736GETOPT_ENTRY(getopt, 0)
1167__posix_getopt (int argc, char *const *argv, const char *optstring) 737GETOPT_ENTRY(__posix_getopt, 1)
1168{ 738#else
1169 return _getopt_internal (argc, argv, optstring, 739GETOPT_ENTRY(getopt, 1)
1170 (const struct option *) 0,
1171 (int *) 0,
1172 0, 1);
1173}
1174#endif 740#endif
1175 741
1176 742
@@ -1191,51 +757,51 @@ main (int argc, char **argv)
1191 757
1192 c = getopt (argc, argv, "abc:d:0123456789"); 758 c = getopt (argc, argv, "abc:d:0123456789");
1193 if (c == -1) 759 if (c == -1)
1194 break; 760 break;
1195 761
1196 switch (c) 762 switch (c)
1197 { 763 {
1198 case '0': 764 case '0':
1199 case '1': 765 case '1':
1200 case '2': 766 case '2':
1201 case '3': 767 case '3':
1202 case '4': 768 case '4':
1203 case '5': 769 case '5':
1204 case '6': 770 case '6':
1205 case '7': 771 case '7':
1206 case '8': 772 case '8':
1207 case '9': 773 case '9':
1208 if (digit_optind != 0 && digit_optind != this_option_optind) 774 if (digit_optind != 0 && digit_optind != this_option_optind)
1209 printf ("digits occur in two different argv-elements.\n"); 775 printf ("digits occur in two different argv-elements.\n");
1210 digit_optind = this_option_optind; 776 digit_optind = this_option_optind;
1211 printf ("option %c\n", c); 777 printf ("option %c\n", c);
1212 break; 778 break;
1213 779
1214 case 'a': 780 case 'a':
1215 printf ("option a\n"); 781 printf ("option a\n");
1216 break; 782 break;
1217 783
1218 case 'b': 784 case 'b':
1219 printf ("option b\n"); 785 printf ("option b\n");
1220 break; 786 break;
1221 787
1222 case 'c': 788 case 'c':
1223 printf ("option c with value '%s'\n", optarg); 789 printf ("option c with value '%s'\n", optarg);
1224 break; 790 break;
1225 791
1226 case '?': 792 case '?':
1227 break; 793 break;
1228 794
1229 default: 795 default:
1230 printf ("?? getopt returned character code 0%o ??\n", c); 796 printf ("?? getopt returned character code 0%o ??\n", c);
1231 } 797 }
1232 } 798 }
1233 799
1234 if (optind < argc) 800 if (optind < argc)
1235 { 801 {
1236 printf ("non-option ARGV-elements: "); 802 printf ("non-option ARGV-elements: ");
1237 while (optind < argc) 803 while (optind < argc)
1238 printf ("%s ", argv[optind++]); 804 printf ("%s ", argv[optind++]);
1239 printf ("\n"); 805 printf ("\n");
1240 } 806 }
1241 807
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index d9c7d81..0867d36 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,20 +1,22 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software 2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of gnulib.
4 This file is part of the GNU C Library. 4 Unlike most of the getopt implementation, it is NOT shared
5 5 with the GNU C Library, which supplies a different version of
6 This program is free software: you can redistribute it and/or modify 6 this file.
7 it under the terms of the GNU General Public License as published by 7
8 the Free Software Foundation; either version 3 of the License, or 8 This file is free software: you can redistribute it and/or modify
9 (at your option) any later version. 9 it under the terms of the GNU Lesser General Public License as
10 10 published by the Free Software Foundation; either version 2.1 of the
11 This program is distributed in the hope that it will be useful, 11 License, or (at your option) any later version.
12
13 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 16 GNU Lesser General Public License for more details.
15 17
16 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 20
19#ifndef _@GUARD_PREFIX@_GETOPT_H 21#ifndef _@GUARD_PREFIX@_GETOPT_H
20 22
@@ -32,22 +34,15 @@
32# undef _GL_SYSTEM_GETOPT 34# undef _GL_SYSTEM_GETOPT
33#endif 35#endif
34 36
35#ifndef _@GUARD_PREFIX@_GETOPT_H 37#define _@GUARD_PREFIX@_GETOPT_H 1
36
37#ifndef __need_getopt
38# define _@GUARD_PREFIX@_GETOPT_H 1
39#endif
40 38
41/* Standalone applications should #define __GETOPT_PREFIX to an 39/* Standalone applications should #define __GETOPT_PREFIX to an
42 identifier that prefixes the external functions and variables 40 identifier that prefixes the external functions and variables
43 defined in this header. When this happens, include the 41 defined in getopt-core.h and getopt-ext.h. When this happens,
44 headers that might declare getopt so that they will not cause 42 include the headers that might declare getopt so that they will not
45 confusion if included after this file (if the system had <getopt.h>, 43 cause confusion if included after this file (if the system had
46 we have already included it). Then systematically rename 44 <getopt.h>, we have already included it). */
47 identifiers so that they do not collide with the system functions 45#if defined __GETOPT_PREFIX
48 and variables. Renaming avoids problems with some compilers and
49 linkers. */
50#if defined __GETOPT_PREFIX && !defined __need_getopt
51# if !@HAVE_GETOPT_H@ 46# if !@HAVE_GETOPT_H@
52# define __need_system_stdlib_h 47# define __need_system_stdlib_h
53# include <stdlib.h> 48# include <stdlib.h>
@@ -55,201 +50,12 @@
55# include <stdio.h> 50# include <stdio.h>
56# include <unistd.h> 51# include <unistd.h>
57# endif 52# endif
58# undef __need_getopt
59# undef getopt
60# undef getopt_long
61# undef getopt_long_only
62# undef optarg
63# undef opterr
64# undef optind
65# undef optopt
66# undef option
67# define __GETOPT_CONCAT(x, y) x ## y
68# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
69# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
70# define getopt __GETOPT_ID (getopt)
71# define getopt_long __GETOPT_ID (getopt_long)
72# define getopt_long_only __GETOPT_ID (getopt_long_only)
73# define optarg __GETOPT_ID (optarg)
74# define opterr __GETOPT_ID (opterr)
75# define optind __GETOPT_ID (optind)
76# define optopt __GETOPT_ID (optopt)
77# define option __GETOPT_ID (option)
78# define _getopt_internal __GETOPT_ID (getopt_internal)
79#endif
80
81/* Standalone applications get correct prototypes for getopt_long and
82 getopt_long_only; they declare "char **argv". libc uses prototypes
83 with "char *const *argv" that are incorrect because getopt_long and
84 getopt_long_only can permute argv; this is required for backward
85 compatibility (e.g., for LSB 2.0.1).
86
87 This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
88 but it caused redefinition warnings if both unistd.h and getopt.h were
89 included, since unistd.h includes getopt.h having previously defined
90 __need_getopt.
91
92 The only place where __getopt_argv_const is used is in definitions
93 of getopt_long and getopt_long_only below, but these are visible
94 only if __need_getopt is not defined, so it is quite safe to rewrite
95 the conditional as follows:
96*/
97#if !defined __need_getopt
98# if defined __GETOPT_PREFIX
99# define __getopt_argv_const /* empty */
100# else
101# define __getopt_argv_const const
102# endif
103#endif
104
105/* If __GNU_LIBRARY__ is not already defined, either we are being used
106 standalone, or this is the first header included in the source file.
107 If we are being used with glibc, we need to include <features.h>, but
108 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is
109 not defined, include <ctype.h>, which will pull in <features.h> for us
110 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it
111 doesn't flood the namespace with stuff the way some other headers do.) */
112#if !defined __GNU_LIBRARY__
113# include <ctype.h>
114#endif
115
116#ifndef __THROW
117# ifndef __GNUC_PREREQ
118# define __GNUC_PREREQ(maj, min) (0)
119# endif
120# if defined __cplusplus && __GNUC_PREREQ (2,8)
121# define __THROW throw ()
122# else
123# define __THROW
124# endif
125#endif 53#endif
126 54
127/* The definition of _GL_ARG_NONNULL is copied here. */ 55/* The definition of _GL_ARG_NONNULL is copied here. */
128 56
129#ifdef __cplusplus 57#include <getopt-cdefs.h>
130extern "C" { 58#include <getopt-pfx-core.h>
131#endif 59#include <getopt-pfx-ext.h>
132
133/* For communication from 'getopt' to the caller.
134 When 'getopt' finds an option that takes an argument,
135 the argument value is returned here.
136 Also, when 'ordering' is RETURN_IN_ORDER,
137 each non-option ARGV-element is returned here. */
138
139extern char *optarg;
140
141/* Index in ARGV of the next element to be scanned.
142 This is used for communication to and from the caller
143 and for communication between successive calls to 'getopt'.
144
145 On entry to 'getopt', zero means this is the first call; initialize.
146
147 When 'getopt' returns -1, this is the index of the first of the
148 non-option elements that the caller should itself scan.
149
150 Otherwise, 'optind' communicates from one call to the next
151 how much of ARGV has been scanned so far. */
152
153extern int optind;
154
155/* Callers store zero here to inhibit the error message 'getopt' prints
156 for unrecognized options. */
157
158extern int opterr;
159 60
160/* Set to an option character which was unrecognized. */
161
162extern int optopt;
163
164#ifndef __need_getopt
165/* Describe the long-named options requested by the application.
166 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
167 of 'struct option' terminated by an element containing a name which is
168 zero.
169
170 The field 'has_arg' is:
171 no_argument (or 0) if the option does not take an argument,
172 required_argument (or 1) if the option requires an argument,
173 optional_argument (or 2) if the option takes an optional argument.
174
175 If the field 'flag' is not NULL, it points to a variable that is set
176 to the value given in the field 'val' when the option is found, but
177 left unchanged if the option is not found.
178
179 To have a long-named option do something other than set an 'int' to
180 a compiled-in constant, such as set a value from 'optarg', set the
181 option's 'flag' field to zero and its 'val' field to a nonzero
182 value (the equivalent single-letter option character, if there is
183 one). For long options that have a zero 'flag' field, 'getopt'
184 returns the contents of the 'val' field. */
185
186# if !GNULIB_defined_struct_option
187struct option
188{
189 const char *name;
190 /* has_arg can't be an enum because some compilers complain about
191 type mismatches in all the code that assumes it is an int. */
192 int has_arg;
193 int *flag;
194 int val;
195};
196# define GNULIB_defined_struct_option 1
197# endif
198
199/* Names for the values of the 'has_arg' field of 'struct option'. */
200
201# define no_argument 0
202# define required_argument 1
203# define optional_argument 2
204#endif /* need getopt */
205
206
207/* Get definitions and prototypes for functions to process the
208 arguments in ARGV (ARGC of them, minus the program name) for
209 options given in OPTS.
210
211 Return the option character from OPTS just read. Return -1 when
212 there are no more options. For unrecognized options, or options
213 missing arguments, 'optopt' is set to the option letter, and '?' is
214 returned.
215
216 The OPTS string is a list of characters which are recognized option
217 letters, optionally followed by colons, specifying that that letter
218 takes an argument, to be placed in 'optarg'.
219
220 If a letter in OPTS is followed by two colons, its argument is
221 optional. This behavior is specific to the GNU 'getopt'.
222
223 The argument '--' causes premature termination of argument
224 scanning, explicitly telling 'getopt' that there are no more
225 options.
226
227 If OPTS begins with '-', then non-option arguments are treated as
228 arguments to the option '\1'. This behavior is specific to the GNU
229 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
230 the environment, then do not permute arguments. */
231
232extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
233 __THROW _GL_ARG_NONNULL ((2, 3));
234
235#ifndef __need_getopt
236extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
237 const char *__shortopts,
238 const struct option *__longopts, int *__longind)
239 __THROW _GL_ARG_NONNULL ((2, 3));
240extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
241 const char *__shortopts,
242 const struct option *__longopts, int *__longind)
243 __THROW _GL_ARG_NONNULL ((2, 3));
244
245#endif
246
247#ifdef __cplusplus
248}
249#endif
250
251/* Make sure we later can get all the definitions and declarations. */
252#undef __need_getopt
253
254#endif /* _@GUARD_PREFIX@_GETOPT_H */
255#endif /* _@GUARD_PREFIX@_GETOPT_H */ 61#endif /* _@GUARD_PREFIX@_GETOPT_H */
diff --git a/gl/getopt1.c b/gl/getopt1.c
index 55a6b4e..49323aa 100644
--- a/gl/getopt1.c
+++ b/gl/getopt1.c
@@ -1,56 +1,44 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt. 1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software 2 Copyright (C) 1987-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of the GNU C Library and is also part of gnulib.
4 This file is part of the GNU C Library. 4 Patches to this file should be submitted to both projects.
5 5
6 This program is free software: you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3 of the License, or 8 License as published by the Free Software Foundation; either
9 (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifdef _LIBC 20#ifndef _LIBC
20# include <getopt.h>
21#else
22# include <config.h> 21# include <config.h>
23# include "getopt.h"
24#endif 22#endif
25#include "getopt_int.h"
26
27#include <stdio.h>
28 23
29/* This needs to come after some library #include 24#include "getopt.h"
30 to get __GNU_LIBRARY__ defined. */ 25#include "getopt_int.h"
31#ifdef __GNU_LIBRARY__
32#include <stdlib.h>
33#endif
34
35#ifndef NULL
36#define NULL 0
37#endif
38 26
39int 27int
40getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, 28getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
41 const struct option *long_options, int *opt_index) 29 const struct option *long_options, int *opt_index)
42{ 30{
43 return _getopt_internal (argc, (char **) argv, options, long_options, 31 return _getopt_internal (argc, (char **) argv, options, long_options,
44 opt_index, 0, 0); 32 opt_index, 0, 0);
45} 33}
46 34
47int 35int
48_getopt_long_r (int argc, char **argv, const char *options, 36_getopt_long_r (int argc, char **argv, const char *options,
49 const struct option *long_options, int *opt_index, 37 const struct option *long_options, int *opt_index,
50 struct _getopt_data *d) 38 struct _getopt_data *d)
51{ 39{
52 return _getopt_internal_r (argc, argv, options, long_options, opt_index, 40 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
53 0, d, 0); 41 0, d, 0);
54} 42}
55 43
56/* Like getopt_long, but '-' as well as '--' can indicate a long option. 44/* Like getopt_long, but '-' as well as '--' can indicate a long option.
@@ -60,26 +48,27 @@ _getopt_long_r (int argc, char **argv, const char *options,
60 48
61int 49int
62getopt_long_only (int argc, char *__getopt_argv_const *argv, 50getopt_long_only (int argc, char *__getopt_argv_const *argv,
63 const char *options, 51 const char *options,
64 const struct option *long_options, int *opt_index) 52 const struct option *long_options, int *opt_index)
65{ 53{
66 return _getopt_internal (argc, (char **) argv, options, long_options, 54 return _getopt_internal (argc, (char **) argv, options, long_options,
67 opt_index, 1, 0); 55 opt_index, 1, 0);
68} 56}
69 57
70int 58int
71_getopt_long_only_r (int argc, char **argv, const char *options, 59_getopt_long_only_r (int argc, char **argv, const char *options,
72 const struct option *long_options, int *opt_index, 60 const struct option *long_options, int *opt_index,
73 struct _getopt_data *d) 61 struct _getopt_data *d)
74{ 62{
75 return _getopt_internal_r (argc, argv, options, long_options, opt_index, 63 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
76 1, d, 0); 64 1, d, 0);
77} 65}
78 66
79 67
80#ifdef TEST 68#ifdef TEST
81 69
82#include <stdio.h> 70#include <stdio.h>
71#include <stdlib.h>
83 72
84int 73int
85main (int argc, char **argv) 74main (int argc, char **argv)
@@ -93,74 +82,74 @@ main (int argc, char **argv)
93 int option_index = 0; 82 int option_index = 0;
94 static const struct option long_options[] = 83 static const struct option long_options[] =
95 { 84 {
96 {"add", 1, 0, 0}, 85 {"add", 1, 0, 0},
97 {"append", 0, 0, 0}, 86 {"append", 0, 0, 0},
98 {"delete", 1, 0, 0}, 87 {"delete", 1, 0, 0},
99 {"verbose", 0, 0, 0}, 88 {"verbose", 0, 0, 0},
100 {"create", 0, 0, 0}, 89 {"create", 0, 0, 0},
101 {"file", 1, 0, 0}, 90 {"file", 1, 0, 0},
102 {0, 0, 0, 0} 91 {0, 0, 0, 0}
103 }; 92 };
104 93
105 c = getopt_long (argc, argv, "abc:d:0123456789", 94 c = getopt_long (argc, argv, "abc:d:0123456789",
106 long_options, &option_index); 95 long_options, &option_index);
107 if (c == -1) 96 if (c == -1)
108 break; 97 break;
109 98
110 switch (c) 99 switch (c)
111 { 100 {
112 case 0: 101 case 0:
113 printf ("option %s", long_options[option_index].name); 102 printf ("option %s", long_options[option_index].name);
114 if (optarg) 103 if (optarg)
115 printf (" with arg %s", optarg); 104 printf (" with arg %s", optarg);
116 printf ("\n"); 105 printf ("\n");
117 break; 106 break;
118 107
119 case '0': 108 case '0':
120 case '1': 109 case '1':
121 case '2': 110 case '2':
122 case '3': 111 case '3':
123 case '4': 112 case '4':
124 case '5': 113 case '5':
125 case '6': 114 case '6':
126 case '7': 115 case '7':
127 case '8': 116 case '8':
128 case '9': 117 case '9':
129 if (digit_optind != 0 && digit_optind != this_option_optind) 118 if (digit_optind != 0 && digit_optind != this_option_optind)
130 printf ("digits occur in two different argv-elements.\n"); 119 printf ("digits occur in two different argv-elements.\n");
131 digit_optind = this_option_optind; 120 digit_optind = this_option_optind;
132 printf ("option %c\n", c); 121 printf ("option %c\n", c);
133 break; 122 break;
134 123
135 case 'a': 124 case 'a':
136 printf ("option a\n"); 125 printf ("option a\n");
137 break; 126 break;
138 127
139 case 'b': 128 case 'b':
140 printf ("option b\n"); 129 printf ("option b\n");
141 break; 130 break;
142 131
143 case 'c': 132 case 'c':
144 printf ("option c with value '%s'\n", optarg); 133 printf ("option c with value '%s'\n", optarg);
145 break; 134 break;
146 135
147 case 'd': 136 case 'd':
148 printf ("option d with value '%s'\n", optarg); 137 printf ("option d with value '%s'\n", optarg);
149 break; 138 break;
150 139
151 case '?': 140 case '?':
152 break; 141 break;
153 142
154 default: 143 default:
155 printf ("?? getopt returned character code 0%o ??\n", c); 144 printf ("?? getopt returned character code 0%o ??\n", c);
156 } 145 }
157 } 146 }
158 147
159 if (optind < argc) 148 if (optind < argc)
160 { 149 {
161 printf ("non-option ARGV-elements: "); 150 printf ("non-option ARGV-elements: ");
162 while (optind < argc) 151 while (optind < argc)
163 printf ("%s ", argv[optind++]); 152 printf ("%s ", argv[optind++]);
164 printf ("\n"); 153 printf ("\n");
165 } 154 }
166 155
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index a6e4b9e..4d9e24b 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,30 +1,31 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software 2 Copyright (C) 1989-2023 Free Software Foundation, Inc.
3 Foundation, Inc. 3 This file is part of the GNU C Library and is also part of gnulib.
4 This file is part of the GNU C Library. 4 Patches to this file should be submitted to both projects.
5 5
6 This program is free software: you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3 of the License, or 8 License as published by the Free Software Foundation; either
9 (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifndef _GETOPT_INT_H 20#ifndef _GETOPT_INT_H
20#define _GETOPT_INT_H 1 21#define _GETOPT_INT_H 1
21 22
22#include <getopt.h> 23#include <getopt.h>
23 24
24extern int _getopt_internal (int ___argc, char **___argv, 25extern int _getopt_internal (int ___argc, char **___argv,
25 const char *__shortopts, 26 const char *__shortopts,
26 const struct option *__longopts, int *__longind, 27 const struct option *__longopts, int *__longind,
27 int __long_only, int __posixly_correct); 28 int __long_only, int __posixly_correct);
28 29
29 30
30/* Reentrant versions which can handle parsing multiple argument 31/* Reentrant versions which can handle parsing multiple argument
@@ -32,28 +33,20 @@ extern int _getopt_internal (int ___argc, char **___argv,
32 33
33/* Describe how to deal with options that follow non-option ARGV-elements. 34/* Describe how to deal with options that follow non-option ARGV-elements.
34 35
35 If the caller did not specify anything, 36 REQUIRE_ORDER means don't recognize them as options; stop option
36 the default is REQUIRE_ORDER if the environment variable 37 processing when the first non-option is seen. This is what POSIX
37 POSIXLY_CORRECT is defined, PERMUTE otherwise. 38 specifies should happen.
38 39
39 REQUIRE_ORDER means don't recognize them as options; 40 PERMUTE means permute the contents of ARGV as we scan, so that
40 stop option processing when the first non-option is seen. 41 eventually all the non-options are at the end. This allows options
41 This is what Unix does. 42 to be given in any order, even with programs that were not written
42 This mode of operation is selected by either setting the environment 43 to expect this.
43 variable POSIXLY_CORRECT, or using '+' as the first character
44 of the list of option characters, or by calling getopt.
45
46 PERMUTE is the default. We permute the contents of ARGV as we
47 scan, so that eventually all the non-options are at the end.
48 This allows options to be given in any order, even with programs
49 that were not written to expect this.
50 44
51 RETURN_IN_ORDER is an option available to programs that were 45 RETURN_IN_ORDER is an option available to programs that were
52 written to expect options and other ARGV-elements in any order 46 written to expect options and other ARGV-elements in any order
53 and that care about the ordering of the two. We describe each 47 and that care about the ordering of the two. We describe each
54 non-option ARGV-element as if it were the argument of an option 48 non-option ARGV-element as if it were the argument of an option
55 with character code 1. Using '-' as the first character of the 49 with character code 1.
56 list of option characters selects this mode of operation.
57 50
58 The special argument '--' forces an end of option-scanning regardless 51 The special argument '--' forces an end of option-scanning regardless
59 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only 52 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
@@ -91,11 +84,6 @@ struct _getopt_data
91 /* See __ord above. */ 84 /* See __ord above. */
92 enum __ord __ordering; 85 enum __ord __ordering;
93 86
94 /* If the POSIXLY_CORRECT environment variable is set
95 or getopt was called. */
96 int __posixly_correct;
97
98
99 /* Handle permutation of arguments. */ 87 /* Handle permutation of arguments. */
100 88
101 /* Describe the part of ARGV that contains non-options that have 89 /* Describe the part of ARGV that contains non-options that have
@@ -104,32 +92,27 @@ struct _getopt_data
104 92
105 int __first_nonopt; 93 int __first_nonopt;
106 int __last_nonopt; 94 int __last_nonopt;
107
108#if defined _LIBC && defined USE_NONOPTION_FLAGS
109 int __nonoption_flags_max_len;
110 int __nonoption_flags_len;
111#endif
112}; 95};
113 96
114/* The initializer is necessary to set OPTIND and OPTERR to their 97/* The initializer is necessary to set OPTIND and OPTERR to their
115 default values and to clear the initialization flag. */ 98 default values and to clear the initialization flag. */
116#define _GETOPT_DATA_INITIALIZER { 1, 1 } 99#define _GETOPT_DATA_INITIALIZER { 1, 1 }
117 100
118extern int _getopt_internal_r (int ___argc, char **___argv, 101extern int _getopt_internal_r (int ___argc, char **___argv,
119 const char *__shortopts, 102 const char *__shortopts,
120 const struct option *__longopts, int *__longind, 103 const struct option *__longopts, int *__longind,
121 int __long_only, struct _getopt_data *__data, 104 int __long_only, struct _getopt_data *__data,
122 int __posixly_correct); 105 int __posixly_correct);
123 106
124extern int _getopt_long_r (int ___argc, char **___argv, 107extern int _getopt_long_r (int ___argc, char **___argv,
125 const char *__shortopts, 108 const char *__shortopts,
126 const struct option *__longopts, int *__longind, 109 const struct option *__longopts, int *__longind,
127 struct _getopt_data *__data); 110 struct _getopt_data *__data);
128 111
129extern int _getopt_long_only_r (int ___argc, char **___argv, 112extern int _getopt_long_only_r (int ___argc, char **___argv,
130 const char *__shortopts, 113 const char *__shortopts,
131 const struct option *__longopts, 114 const struct option *__longopts,
132 int *__longind, 115 int *__longind,
133 struct _getopt_data *__data); 116 struct _getopt_data *__data);
134 117
135#endif /* getopt_int.h */ 118#endif /* getopt_int.h */
diff --git a/gl/getprogname.c b/gl/getprogname.c
new file mode 100644
index 0000000..32c9604
--- /dev/null
+++ b/gl/getprogname.c
@@ -0,0 +1,302 @@
1/* Program name management.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include "getprogname.h"
21
22#include <errno.h> /* get program_invocation_name declaration */
23#include <stdlib.h> /* get __argv declaration */
24
25#ifdef _AIX
26# include <unistd.h>
27# include <procinfo.h>
28# include <string.h>
29#endif
30
31#ifdef __MVS__
32# ifndef _OPEN_SYS
33# define _OPEN_SYS
34# endif
35# include <string.h>
36# include <sys/ps.h>
37#endif
38
39#ifdef __hpux
40# include <unistd.h>
41# include <sys/param.h>
42# include <sys/pstat.h>
43# include <string.h>
44#endif
45
46#if defined __sgi || defined __osf__
47# include <string.h>
48# include <unistd.h>
49# include <stdio.h>
50# include <fcntl.h>
51# include <sys/procfs.h>
52#endif
53
54#if defined __SCO_VERSION__ || defined __sysv5__
55# include <fcntl.h>
56# include <stdlib.h>
57# include <string.h>
58#endif
59
60#include "basename-lgpl.h"
61
62#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
63char const *
64getprogname (void)
65{
66# if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME /* glibc, BeOS */
67 /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
68 return program_invocation_short_name;
69# elif HAVE_DECL_PROGRAM_INVOCATION_NAME /* glibc, BeOS */
70 /* https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html */
71 return last_component (program_invocation_name);
72# elif HAVE_GETEXECNAME /* Solaris */
73 /* https://docs.oracle.com/cd/E19253-01/816-5168/6mbb3hrb1/index.html */
74 const char *p = getexecname ();
75 if (!p)
76 p = "?";
77 return last_component (p);
78# elif HAVE_DECL___ARGV /* mingw, MSVC */
79 /* https://docs.microsoft.com/en-us/cpp/c-runtime-library/argc-argv-wargv */
80 const char *p = __argv && __argv[0] ? __argv[0] : "?";
81 return last_component (p);
82# elif HAVE_VAR___PROGNAME /* OpenBSD, Android, QNX */
83 /* https://man.openbsd.org/style.9 */
84 /* http://www.qnx.de/developers/docs/6.5.0/index.jsp?topic=%2Fcom.qnx.doc.neutrino_lib_ref%2Fp%2F__progname.html */
85 /* Be careful to declare this only when we absolutely need it
86 (OpenBSD 5.1), rather than when it's available. Otherwise,
87 its mere declaration makes program_invocation_short_name
88 malfunction (have zero length) with Fedora 25's glibc. */
89 extern char *__progname;
90 const char *p = __progname;
91# if defined __ANDROID__
92 return last_component (p);
93# else
94 return p && p[0] ? p : "?";
95# endif
96# elif _AIX /* AIX */
97 /* Idea by Bastien ROUCARIÈS,
98 https://lists.gnu.org/r/bug-gnulib/2010-12/msg00095.html
99 Reference: https://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.basetrf1/getprocs.htm
100 */
101 static char *p;
102 static int first = 1;
103 if (first)
104 {
105 first = 0;
106 pid_t pid = getpid ();
107 struct procentry64 procs;
108 p = (0 < getprocs64 (&procs, sizeof procs, NULL, 0, &pid, 1)
109 ? strdup (procs.pi_comm)
110 : NULL);
111 if (!p)
112 p = "?";
113 }
114 return p;
115# elif defined __hpux
116 static char *p;
117 static int first = 1;
118 if (first)
119 {
120 first = 0;
121 pid_t pid = getpid ();
122 struct pst_status status;
123 if (pstat_getproc (&status, sizeof status, 0, pid) > 0)
124 {
125 char *ucomm = status.pst_ucomm;
126 char *cmd = status.pst_cmd;
127 if (strlen (ucomm) < PST_UCOMMLEN - 1)
128 p = ucomm;
129 else
130 {
131 /* ucomm is truncated to length PST_UCOMMLEN - 1.
132 Look at cmd instead. */
133 char *space = strchr (cmd, ' ');
134 if (space != NULL)
135 *space = '\0';
136 p = strrchr (cmd, '/');
137 if (p != NULL)
138 p++;
139 else
140 p = cmd;
141 if (strlen (p) > PST_UCOMMLEN - 1
142 && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
143 /* p is less truncated than ucomm. */
144 ;
145 else
146 p = ucomm;
147 }
148 p = strdup (p);
149 }
150 else
151 {
152# if !defined __LP64__
153 /* Support for 32-bit programs running in 64-bit HP-UX.
154 The documented way to do this is to use the same source code
155 as above, but in a compilation unit where '#define _PSTAT64 1'
156 is in effect. I prefer a single compilation unit; the struct
157 size and the offsets are not going to change. */
158 char status64[1216];
159 if (__pstat_getproc64 (status64, sizeof status64, 0, pid) > 0)
160 {
161 char *ucomm = status64 + 288;
162 char *cmd = status64 + 168;
163 if (strlen (ucomm) < PST_UCOMMLEN - 1)
164 p = ucomm;
165 else
166 {
167 /* ucomm is truncated to length PST_UCOMMLEN - 1.
168 Look at cmd instead. */
169 char *space = strchr (cmd, ' ');
170 if (space != NULL)
171 *space = '\0';
172 p = strrchr (cmd, '/');
173 if (p != NULL)
174 p++;
175 else
176 p = cmd;
177 if (strlen (p) > PST_UCOMMLEN - 1
178 && memcmp (p, ucomm, PST_UCOMMLEN - 1) == 0)
179 /* p is less truncated than ucomm. */
180 ;
181 else
182 p = ucomm;
183 }
184 p = strdup (p);
185 }
186 else
187# endif
188 p = NULL;
189 }
190 if (!p)
191 p = "?";
192 }
193 return p;
194# elif __MVS__ /* z/OS */
195 /* https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm */
196 static char *p = "?";
197 static int first = 1;
198 if (first)
199 {
200 pid_t pid = getpid ();
201 int token;
202 W_PSPROC buf;
203 first = 0;
204 memset (&buf, 0, sizeof(buf));
205 buf.ps_cmdptr = (char *) malloc (buf.ps_cmdlen = PS_CMDBLEN_LONG);
206 buf.ps_conttyptr = (char *) malloc (buf.ps_conttylen = PS_CONTTYBLEN);
207 buf.ps_pathptr = (char *) malloc (buf.ps_pathlen = PS_PATHBLEN);
208 if (buf.ps_cmdptr && buf.ps_conttyptr && buf.ps_pathptr)
209 {
210 for (token = 0; token >= 0;
211 token = w_getpsent (token, &buf, sizeof(buf)))
212 {
213 if (token > 0 && buf.ps_pid == pid)
214 {
215 char *s = strdup (last_component (buf.ps_pathptr));
216 if (s)
217 p = s;
218 break;
219 }
220 }
221 }
222 free (buf.ps_cmdptr);
223 free (buf.ps_conttyptr);
224 free (buf.ps_pathptr);
225 }
226 return p;
227# elif defined __sgi || defined __osf__ /* IRIX or Tru64 */
228 char filename[50];
229 int fd;
230
231 # if defined __sgi
232 sprintf (filename, "/proc/pinfo/%d", (int) getpid ());
233 # else
234 sprintf (filename, "/proc/%d", (int) getpid ());
235 # endif
236 fd = open (filename, O_RDONLY | O_CLOEXEC);
237 if (0 <= fd)
238 {
239 prpsinfo_t buf;
240 int ioctl_ok = 0 <= ioctl (fd, PIOCPSINFO, &buf);
241 close (fd);
242 if (ioctl_ok)
243 {
244 char *name = buf.pr_fname;
245 size_t namesize = sizeof buf.pr_fname;
246 /* It may not be NUL-terminated. */
247 char *namenul = memchr (name, '\0', namesize);
248 size_t namelen = namenul ? namenul - name : namesize;
249 char *namecopy = malloc (namelen + 1);
250 if (namecopy)
251 {
252 namecopy[namelen] = '\0';
253 return memcpy (namecopy, name, namelen);
254 }
255 }
256 }
257 return NULL;
258# elif defined __SCO_VERSION__ || defined __sysv5__ /* SCO OpenServer6/UnixWare */
259 char buf[80];
260 int fd;
261 sprintf (buf, "/proc/%d/cmdline", getpid());
262 fd = open (buf, O_RDONLY);
263 if (0 <= fd)
264 {
265 size_t n = read (fd, buf, 79);
266 if (n > 0)
267 {
268 buf[n] = '\0'; /* Guarantee null-termination */
269 char *progname;
270 progname = strrchr (buf, '/');
271 if (progname)
272 {
273 progname = progname + 1; /* Skip the '/' */
274 }
275 else
276 {
277 progname = buf;
278 }
279 char *ret;
280 ret = malloc (strlen (progname) + 1);
281 if (ret)
282 {
283 strcpy (ret, progname);
284 return ret;
285 }
286 }
287 close (fd);
288 }
289 return "?";
290# else
291# error "getprogname module not ported to this OS"
292# endif
293}
294
295#endif
296
297/*
298 * Hey Emacs!
299 * Local Variables:
300 * coding: utf-8
301 * End:
302 */
diff --git a/gl/getprogname.h b/gl/getprogname.h
new file mode 100644
index 0000000..4b9126f
--- /dev/null
+++ b/gl/getprogname.h
@@ -0,0 +1,40 @@
1/* Program name management.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _GL_GETPROGNAME_H
18#define _GL_GETPROGNAME_H
19
20#include <stdlib.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* Return the base name of the executing program.
27 On native Windows this will usually end in ".exe" or ".EXE". */
28#ifndef HAVE_GETPROGNAME
29extern char const *getprogname (void)
30# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
31 _GL_ATTRIBUTE_PURE
32# endif
33 ;
34#endif
35
36#ifdef __cplusplus
37}
38#endif
39
40#endif
diff --git a/gl/gettext.h b/gl/gettext.h
index d021571..d0462c4 100644
--- a/gl/gettext.h
+++ b/gl/gettext.h
@@ -1,25 +1,26 @@
1/* Convenience header for conditional use of GNU <libintl.h>. 1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software 2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _LIBGETTEXT_H 18#ifndef _LIBGETTEXT_H
19#define _LIBGETTEXT_H 1 19#define _LIBGETTEXT_H 1
20 20
21/* NLS can be disabled through the configure --disable-nls option. */ 21/* NLS can be disabled through the configure --disable-nls option
22#if ENABLE_NLS 22 or through "#define ENABLE NLS 0" before including this file. */
23#if defined ENABLE_NLS && ENABLE_NLS
23 24
24/* Get declarations of GNU message catalog functions. */ 25/* Get declarations of GNU message catalog functions. */
25# include <libintl.h> 26# include <libintl.h>
@@ -137,7 +138,7 @@
137#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ 138#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
138 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) 139 npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
139 140
140#ifdef __GNUC__ 141#if defined __GNUC__ || defined __clang__
141__inline 142__inline
142#else 143#else
143#ifdef __cplusplus 144#ifdef __cplusplus
@@ -156,7 +157,7 @@ pgettext_aux (const char *domain,
156 return translation; 157 return translation;
157} 158}
158 159
159#ifdef __GNUC__ 160#if defined __GNUC__ || defined __clang__
160__inline 161__inline
161#else 162#else
162#ifdef __cplusplus 163#ifdef __cplusplus
@@ -183,8 +184,15 @@ npgettext_aux (const char *domain,
183 184
184#include <string.h> 185#include <string.h>
185 186
186#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ 187/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
187 /* || __STDC_VERSION__ >= 199901L */ ) 188 This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
189 the default GCC many warnings set. This allows programs to disable use
190 of VLAs, which may be unintended, or may be awkward to support portably,
191 or may have security implications due to non-deterministic stack usage. */
192
193#if (!defined GNULIB_NO_VLA \
194 && defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
195 && !defined __STDC_NO_VLA__)
188# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 196# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
189#else 197#else
190# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 198# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
@@ -199,7 +207,7 @@ npgettext_aux (const char *domain,
199#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ 207#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
200 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) 208 dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
201 209
202#ifdef __GNUC__ 210#if defined __GNUC__ || defined __clang__
203__inline 211__inline
204#else 212#else
205#ifdef __cplusplus 213#ifdef __cplusplus
@@ -225,15 +233,17 @@ dcpgettext_expr (const char *domain,
225 if (msg_ctxt_id != NULL) 233 if (msg_ctxt_id != NULL)
226#endif 234#endif
227 { 235 {
236 int found_translation;
228 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 237 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
229 msg_ctxt_id[msgctxt_len - 1] = '\004'; 238 msg_ctxt_id[msgctxt_len - 1] = '\004';
230 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 239 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
231 translation = dcgettext (domain, msg_ctxt_id, category); 240 translation = dcgettext (domain, msg_ctxt_id, category);
241 found_translation = (translation != msg_ctxt_id);
232#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 242#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
233 if (msg_ctxt_id != buf) 243 if (msg_ctxt_id != buf)
234 free (msg_ctxt_id); 244 free (msg_ctxt_id);
235#endif 245#endif
236 if (translation != msg_ctxt_id) 246 if (found_translation)
237 return translation; 247 return translation;
238 } 248 }
239 return msgid; 249 return msgid;
@@ -244,7 +254,7 @@ dcpgettext_expr (const char *domain,
244#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ 254#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
245 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) 255 dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
246 256
247#ifdef __GNUC__ 257#if defined __GNUC__ || defined __clang__
248__inline 258__inline
249#else 259#else
250#ifdef __cplusplus 260#ifdef __cplusplus
@@ -271,15 +281,17 @@ dcnpgettext_expr (const char *domain,
271 if (msg_ctxt_id != NULL) 281 if (msg_ctxt_id != NULL)
272#endif 282#endif
273 { 283 {
284 int found_translation;
274 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); 285 memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
275 msg_ctxt_id[msgctxt_len - 1] = '\004'; 286 msg_ctxt_id[msgctxt_len - 1] = '\004';
276 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); 287 memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
277 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); 288 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
289 found_translation = !(translation == msg_ctxt_id || translation == msgid_plural);
278#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 290#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
279 if (msg_ctxt_id != buf) 291 if (msg_ctxt_id != buf)
280 free (msg_ctxt_id); 292 free (msg_ctxt_id);
281#endif 293#endif
282 if (!(translation == msg_ctxt_id || translation == msgid_plural)) 294 if (found_translation)
283 return translation; 295 return translation;
284 } 296 }
285 return (n == 1 ? msgid : msgid_plural); 297 return (n == 1 ? msgid : msgid_plural);
diff --git a/gl/gl_openssl.h b/gl/gl_openssl.h
new file mode 100644
index 0000000..f63c386
--- /dev/null
+++ b/gl/gl_openssl.h
@@ -0,0 +1,116 @@
1/* Wrap openssl crypto hash routines in gnulib interface. -*- coding: utf-8 -*-
2
3 Copyright (C) 2013-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Pádraig Brady */
19
20#ifndef GL_OPENSSL_NAME
21# error "Please define GL_OPENSSL_NAME to 1,5,256 etc."
22#endif
23
24#ifndef _GL_INLINE_HEADER_BEGIN
25# error "Please include config.h first."
26#endif
27_GL_INLINE_HEADER_BEGIN
28#ifndef GL_OPENSSL_INLINE
29# define GL_OPENSSL_INLINE _GL_INLINE
30#endif
31
32/* Concatenate two preprocessor tokens. */
33#define _GLCRYPTO_CONCAT_(prefix, suffix) prefix##suffix
34#define _GLCRYPTO_CONCAT(prefix, suffix) _GLCRYPTO_CONCAT_ (prefix, suffix)
35
36#if GL_OPENSSL_NAME == 5
37# define OPENSSL_ALG md5
38#else
39# define OPENSSL_ALG _GLCRYPTO_CONCAT (sha, GL_OPENSSL_NAME)
40#endif
41
42/* Context type mappings. */
43#if BASE_OPENSSL_TYPE != GL_OPENSSL_NAME
44# undef BASE_OPENSSL_TYPE
45# if GL_OPENSSL_NAME == 224
46# define BASE_OPENSSL_TYPE 256
47# elif GL_OPENSSL_NAME == 384
48# define BASE_OPENSSL_TYPE 512
49# endif
50# define md5_CTX MD5_CTX
51# define sha1_CTX SHA_CTX
52# define sha224_CTX SHA256_CTX
53# define sha224_ctx sha256_ctx
54# define sha256_CTX SHA256_CTX
55# define sha384_CTX SHA512_CTX
56# define sha384_ctx sha512_ctx
57# define sha512_CTX SHA512_CTX
58# undef _gl_CTX
59# undef _gl_ctx
60# define _gl_CTX _GLCRYPTO_CONCAT (OPENSSL_ALG, _CTX) /* openssl type. */
61# define _gl_ctx _GLCRYPTO_CONCAT (OPENSSL_ALG, _ctx) /* gnulib type. */
62
63struct _gl_ctx { _gl_CTX CTX; };
64#endif
65
66/* Function name mappings. */
67#define md5_prefix MD5
68#define sha1_prefix SHA1
69#define sha224_prefix SHA224
70#define sha256_prefix SHA256
71#define sha384_prefix SHA384
72#define sha512_prefix SHA512
73#define _GLCRYPTO_PREFIX _GLCRYPTO_CONCAT (OPENSSL_ALG, _prefix)
74#define OPENSSL_FN(suffix) _GLCRYPTO_CONCAT (_GLCRYPTO_PREFIX, suffix)
75#define GL_CRYPTO_FN(suffix) _GLCRYPTO_CONCAT (OPENSSL_ALG, suffix)
76
77GL_OPENSSL_INLINE void
78GL_CRYPTO_FN (_init_ctx) (struct _gl_ctx *ctx)
79{ (void) OPENSSL_FN (_Init) ((_gl_CTX *) ctx); }
80
81/* These were never exposed by gnulib. */
82#if ! (GL_OPENSSL_NAME == 224 || GL_OPENSSL_NAME == 384)
83GL_OPENSSL_INLINE void
84GL_CRYPTO_FN (_process_bytes) (const void *buf, size_t len, struct _gl_ctx *ctx)
85{ OPENSSL_FN (_Update) ((_gl_CTX *) ctx, buf, len); }
86
87GL_OPENSSL_INLINE void
88GL_CRYPTO_FN (_process_block) (const void *buf, size_t len, struct _gl_ctx *ctx)
89{ GL_CRYPTO_FN (_process_bytes) (buf, len, ctx); }
90#endif
91
92GL_OPENSSL_INLINE void *
93GL_CRYPTO_FN (_finish_ctx) (struct _gl_ctx *ctx, void *restrict res)
94{ OPENSSL_FN (_Final) ((unsigned char *) res, (_gl_CTX *) ctx); return res; }
95
96GL_OPENSSL_INLINE void *
97GL_CRYPTO_FN (_buffer) (const char *buf, size_t len, void *restrict res)
98{ return OPENSSL_FN () ((const unsigned char *) buf, len, (unsigned char *) res); }
99
100GL_OPENSSL_INLINE void *
101GL_CRYPTO_FN (_read_ctx) (const struct _gl_ctx *ctx, void *restrict res)
102{
103 /* Assume any unprocessed bytes in ctx are not to be ignored. */
104 _gl_CTX tmp_ctx = *(_gl_CTX *) ctx;
105 OPENSSL_FN (_Final) ((unsigned char *) res, &tmp_ctx);
106 return res;
107}
108
109/* Undef so we can include multiple times. */
110#undef GL_CRYPTO_FN
111#undef OPENSSL_FN
112#undef _GLCRYPTO_PREFIX
113#undef OPENSSL_ALG
114#undef GL_OPENSSL_NAME
115
116_GL_INLINE_HEADER_END
diff --git a/gl/glthread/lock.c b/gl/glthread/lock.c
index f62aa30..82fb755 100644
--- a/gl/glthread/lock.c
+++ b/gl/glthread/lock.c
@@ -1,22 +1,21 @@
1/* Locking in multithreaded situations. 1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. 17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, 18 Based on GCC's gthr-posix.h, gthr-posix95.h. */
19 gthr-win32.h. */
20 19
21#include <config.h> 20#include <config.h>
22 21
@@ -24,15 +23,267 @@
24 23
25/* ========================================================================= */ 24/* ========================================================================= */
26 25
26#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
27
28/* -------------------------- gl_lock_t datatype -------------------------- */
29
30int
31glthread_lock_init (gl_lock_t *lock)
32{
33 if (mtx_init (&lock->mutex, mtx_plain) != thrd_success)
34 return ENOMEM;
35 lock->init_needed = 0;
36 return 0;
37}
38
39int
40glthread_lock_lock (gl_lock_t *lock)
41{
42 if (lock->init_needed)
43 call_once (&lock->init_once, lock->init_func);
44 if (mtx_lock (&lock->mutex) != thrd_success)
45 return EAGAIN;
46 return 0;
47}
48
49int
50glthread_lock_unlock (gl_lock_t *lock)
51{
52 if (lock->init_needed)
53 call_once (&lock->init_once, lock->init_func);
54 if (mtx_unlock (&lock->mutex) != thrd_success)
55 return EINVAL;
56 return 0;
57}
58
59int
60glthread_lock_destroy (gl_lock_t *lock)
61{
62 if (lock->init_needed)
63 call_once (&lock->init_once, lock->init_func);
64 mtx_destroy (&lock->mutex);
65 return 0;
66}
67
68/* ------------------------- gl_rwlock_t datatype ------------------------- */
69
70int
71glthread_rwlock_init (gl_rwlock_t *lock)
72{
73 if (mtx_init (&lock->lock, mtx_plain) != thrd_success
74 || cnd_init (&lock->waiting_readers) != thrd_success
75 || cnd_init (&lock->waiting_writers) != thrd_success)
76 return ENOMEM;
77 lock->waiting_writers_count = 0;
78 lock->runcount = 0;
79 lock->init_needed = 0;
80 return 0;
81}
82
83int
84glthread_rwlock_rdlock (gl_rwlock_t *lock)
85{
86 if (lock->init_needed)
87 call_once (&lock->init_once, lock->init_func);
88 if (mtx_lock (&lock->lock) != thrd_success)
89 return EAGAIN;
90 /* Test whether only readers are currently running, and whether the runcount
91 field will not overflow, and whether no writer is waiting. The latter
92 condition is because POSIX recommends that "write locks shall take
93 precedence over read locks", to avoid "writer starvation". */
94 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
95 {
96 /* This thread has to wait for a while. Enqueue it among the
97 waiting_readers. */
98 if (cnd_wait (&lock->waiting_readers, &lock->lock) != thrd_success)
99 {
100 mtx_unlock (&lock->lock);
101 return EINVAL;
102 }
103 }
104 lock->runcount++;
105 if (mtx_unlock (&lock->lock) != thrd_success)
106 return EINVAL;
107 return 0;
108}
109
110int
111glthread_rwlock_wrlock (gl_rwlock_t *lock)
112{
113 if (lock->init_needed)
114 call_once (&lock->init_once, lock->init_func);
115 if (mtx_lock (&lock->lock) != thrd_success)
116 return EAGAIN;
117 /* Test whether no readers or writers are currently running. */
118 while (!(lock->runcount == 0))
119 {
120 /* This thread has to wait for a while. Enqueue it among the
121 waiting_writers. */
122 lock->waiting_writers_count++;
123 if (cnd_wait (&lock->waiting_writers, &lock->lock) != thrd_success)
124 {
125 lock->waiting_writers_count--;
126 mtx_unlock (&lock->lock);
127 return EINVAL;
128 }
129 lock->waiting_writers_count--;
130 }
131 lock->runcount--; /* runcount becomes -1 */
132 if (mtx_unlock (&lock->lock) != thrd_success)
133 return EINVAL;
134 return 0;
135}
136
137int
138glthread_rwlock_unlock (gl_rwlock_t *lock)
139{
140 if (lock->init_needed)
141 call_once (&lock->init_once, lock->init_func);
142 if (mtx_lock (&lock->lock) != thrd_success)
143 return EAGAIN;
144 if (lock->runcount < 0)
145 {
146 /* Drop a writer lock. */
147 if (!(lock->runcount == -1))
148 {
149 mtx_unlock (&lock->lock);
150 return EINVAL;
151 }
152 lock->runcount = 0;
153 }
154 else
155 {
156 /* Drop a reader lock. */
157 if (!(lock->runcount > 0))
158 {
159 mtx_unlock (&lock->lock);
160 return EINVAL;
161 }
162 lock->runcount--;
163 }
164 if (lock->runcount == 0)
165 {
166 /* POSIX recommends that "write locks shall take precedence over read
167 locks", to avoid "writer starvation". */
168 if (lock->waiting_writers_count > 0)
169 {
170 /* Wake up one of the waiting writers. */
171 if (cnd_signal (&lock->waiting_writers) != thrd_success)
172 {
173 mtx_unlock (&lock->lock);
174 return EINVAL;
175 }
176 }
177 else
178 {
179 /* Wake up all waiting readers. */
180 if (cnd_broadcast (&lock->waiting_readers) != thrd_success)
181 {
182 mtx_unlock (&lock->lock);
183 return EINVAL;
184 }
185 }
186 }
187 if (mtx_unlock (&lock->lock) != thrd_success)
188 return EINVAL;
189 return 0;
190}
191
192int
193glthread_rwlock_destroy (gl_rwlock_t *lock)
194{
195 if (lock->init_needed)
196 call_once (&lock->init_once, lock->init_func);
197 mtx_destroy (&lock->lock);
198 cnd_destroy (&lock->waiting_readers);
199 cnd_destroy (&lock->waiting_writers);
200 return 0;
201}
202
203/* --------------------- gl_recursive_lock_t datatype --------------------- */
204
205int
206glthread_recursive_lock_init (gl_recursive_lock_t *lock)
207{
208 if (mtx_init (&lock->mutex, mtx_plain | mtx_recursive) != thrd_success)
209 return ENOMEM;
210 lock->init_needed = 0;
211 return 0;
212}
213
214int
215glthread_recursive_lock_lock (gl_recursive_lock_t *lock)
216{
217 if (lock->init_needed)
218 call_once (&lock->init_once, lock->init_func);
219 if (mtx_lock (&lock->mutex) != thrd_success)
220 return EAGAIN;
221 return 0;
222}
223
224int
225glthread_recursive_lock_unlock (gl_recursive_lock_t *lock)
226{
227 if (lock->init_needed)
228 call_once (&lock->init_once, lock->init_func);
229 if (mtx_unlock (&lock->mutex) != thrd_success)
230 return EINVAL;
231 return 0;
232}
233
234int
235glthread_recursive_lock_destroy (gl_recursive_lock_t *lock)
236{
237 if (lock->init_needed)
238 call_once (&lock->init_once, lock->init_func);
239 mtx_destroy (&lock->mutex);
240 return 0;
241}
242
243/* -------------------------- gl_once_t datatype -------------------------- */
244
245#endif
246
247/* ========================================================================= */
248
27#if USE_POSIX_THREADS 249#if USE_POSIX_THREADS
28 250
29/* -------------------------- gl_lock_t datatype -------------------------- */ 251/* -------------------------- gl_lock_t datatype -------------------------- */
30 252
31/* ------------------------- gl_rwlock_t datatype ------------------------- */ 253/* ------------------------- gl_rwlock_t datatype ------------------------- */
32 254
33# if HAVE_PTHREAD_RWLOCK 255# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
256
257# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP
258
259# if !HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
260 /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
261
262int
263glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock)
264{
265 pthread_rwlockattr_t attributes;
266 int err;
34 267
35# if !defined PTHREAD_RWLOCK_INITIALIZER 268 err = pthread_rwlockattr_init (&attributes);
269 if (err != 0)
270 return err;
271 /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that
272 causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not
273 do this; see
274 http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */
275 err = pthread_rwlockattr_setkind_np (&attributes,
276 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP);
277 if (err == 0)
278 err = pthread_rwlock_init(lock, &attributes);
279 /* pthread_rwlockattr_destroy always returns 0. It cannot influence the
280 return value. */
281 pthread_rwlockattr_destroy (&attributes);
282 return err;
283}
284
285# endif
286# else
36 287
37int 288int
38glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) 289glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
@@ -152,11 +403,9 @@ glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
152 if (err != 0) 403 if (err != 0)
153 return err; 404 return err;
154 /* Test whether only readers are currently running, and whether the runcount 405 /* Test whether only readers are currently running, and whether the runcount
155 field will not overflow. */ 406 field will not overflow, and whether no writer is waiting. The latter
156 /* POSIX says: "It is implementation-defined whether the calling thread 407 condition is because POSIX recommends that "write locks shall take
157 acquires the lock when a writer does not hold the lock and there are 408 precedence over read locks", to avoid "writer starvation". */
158 writers blocked on the lock." Let's say, no: give the writers a higher
159 priority. */
160 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) 409 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
161 { 410 {
162 /* This thread has to wait for a while. Enqueue it among the 411 /* This thread has to wait for a while. Enqueue it among the
@@ -469,161 +718,25 @@ glthread_once_singlethreaded (pthread_once_t *once_control)
469 return 0; 718 return 0;
470} 719}
471 720
472#endif 721# if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK)
473
474/* ========================================================================= */
475
476#if USE_PTH_THREADS
477
478/* Use the GNU Pth threads library. */
479
480/* -------------------------- gl_lock_t datatype -------------------------- */
481
482/* ------------------------- gl_rwlock_t datatype ------------------------- */
483
484/* --------------------- gl_recursive_lock_t datatype --------------------- */
485
486/* -------------------------- gl_once_t datatype -------------------------- */
487
488static void
489glthread_once_call (void *arg)
490{
491 void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
492 void (*initfunction) (void) = *gl_once_temp_addr;
493 initfunction ();
494}
495
496int
497glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
498{
499 void (*temp) (void) = initfunction;
500 return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
501}
502
503int
504glthread_once_singlethreaded (pth_once_t *once_control)
505{
506 /* We know that pth_once_t is an integer type. */
507 if (*once_control == PTH_ONCE_INIT)
508 {
509 /* First time use of once_control. Invert the marker. */
510 *once_control = ~ PTH_ONCE_INIT;
511 return 1;
512 }
513 else
514 return 0;
515}
516
517#endif
518
519/* ========================================================================= */
520
521#if USE_SOLARIS_THREADS
522
523/* Use the old Solaris threads library. */
524
525/* -------------------------- gl_lock_t datatype -------------------------- */
526
527/* ------------------------- gl_rwlock_t datatype ------------------------- */
528
529/* --------------------- gl_recursive_lock_t datatype --------------------- */
530 722
531int 723int
532glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock) 724glthread_once_multithreaded (pthread_once_t *once_control,
725 void (*init_function) (void))
533{ 726{
534 int err; 727 int err = pthread_once (once_control, init_function);
535 728 if (err == ENOSYS)
536 err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
537 if (err != 0)
538 return err;
539 lock->owner = (thread_t) 0;
540 lock->depth = 0;
541 return 0;
542}
543
544int
545glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
546{
547 thread_t self = thr_self ();
548 if (lock->owner != self)
549 { 729 {
550 int err; 730 /* This happens on FreeBSD 11: The pthread_once function in libc returns
551 731 ENOSYS. */
552 err = mutex_lock (&lock->mutex); 732 if (glthread_once_singlethreaded (once_control))
553 if (err != 0) 733 init_function ();
554 return err; 734 return 0;
555 lock->owner = self;
556 } 735 }
557 if (++(lock->depth) == 0) /* wraparound? */ 736 return err;
558 {
559 lock->depth--;
560 return EAGAIN;
561 }
562 return 0;
563} 737}
564 738
565int 739# endif
566glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
567{
568 if (lock->owner != thr_self ())
569 return EPERM;
570 if (lock->depth == 0)
571 return EINVAL;
572 if (--(lock->depth) == 0)
573 {
574 lock->owner = (thread_t) 0;
575 return mutex_unlock (&lock->mutex);
576 }
577 else
578 return 0;
579}
580
581int
582glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
583{
584 if (lock->owner != (thread_t) 0)
585 return EBUSY;
586 return mutex_destroy (&lock->mutex);
587}
588
589/* -------------------------- gl_once_t datatype -------------------------- */
590
591int
592glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
593{
594 if (!once_control->inited)
595 {
596 int err;
597
598 /* Use the mutex to guarantee that if another thread is already calling
599 the initfunction, this thread waits until it's finished. */
600 err = mutex_lock (&once_control->mutex);
601 if (err != 0)
602 return err;
603 if (!once_control->inited)
604 {
605 once_control->inited = 1;
606 initfunction ();
607 }
608 return mutex_unlock (&once_control->mutex);
609 }
610 else
611 return 0;
612}
613
614int
615glthread_once_singlethreaded (gl_once_t *once_control)
616{
617 /* We know that gl_once_t contains an integer type. */
618 if (!once_control->inited)
619 {
620 /* First time use of once_control. Invert the marker. */
621 once_control->inited = ~ 0;
622 return 1;
623 }
624 else
625 return 0;
626}
627 740
628#endif 741#endif
629 742
@@ -631,427 +744,6 @@ glthread_once_singlethreaded (gl_once_t *once_control)
631 744
632#if USE_WINDOWS_THREADS 745#if USE_WINDOWS_THREADS
633 746
634/* -------------------------- gl_lock_t datatype -------------------------- */
635
636void
637glthread_lock_init_func (gl_lock_t *lock)
638{
639 InitializeCriticalSection (&lock->lock);
640 lock->guard.done = 1;
641}
642
643int
644glthread_lock_lock_func (gl_lock_t *lock)
645{
646 if (!lock->guard.done)
647 {
648 if (InterlockedIncrement (&lock->guard.started) == 0)
649 /* This thread is the first one to need this lock. Initialize it. */
650 glthread_lock_init (lock);
651 else
652 /* Yield the CPU while waiting for another thread to finish
653 initializing this lock. */
654 while (!lock->guard.done)
655 Sleep (0);
656 }
657 EnterCriticalSection (&lock->lock);
658 return 0;
659}
660
661int
662glthread_lock_unlock_func (gl_lock_t *lock)
663{
664 if (!lock->guard.done)
665 return EINVAL;
666 LeaveCriticalSection (&lock->lock);
667 return 0;
668}
669
670int
671glthread_lock_destroy_func (gl_lock_t *lock)
672{
673 if (!lock->guard.done)
674 return EINVAL;
675 DeleteCriticalSection (&lock->lock);
676 lock->guard.done = 0;
677 return 0;
678}
679
680/* ------------------------- gl_rwlock_t datatype ------------------------- */
681
682/* In this file, the waitqueues are implemented as circular arrays. */
683#define gl_waitqueue_t gl_carray_waitqueue_t
684
685static void
686gl_waitqueue_init (gl_waitqueue_t *wq)
687{
688 wq->array = NULL;
689 wq->count = 0;
690 wq->alloc = 0;
691 wq->offset = 0;
692}
693
694/* Enqueues the current thread, represented by an event, in a wait queue.
695 Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
696static HANDLE
697gl_waitqueue_add (gl_waitqueue_t *wq)
698{
699 HANDLE event;
700 unsigned int index;
701
702 if (wq->count == wq->alloc)
703 {
704 unsigned int new_alloc = 2 * wq->alloc + 1;
705 HANDLE *new_array =
706 (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
707 if (new_array == NULL)
708 /* No more memory. */
709 return INVALID_HANDLE_VALUE;
710 /* Now is a good opportunity to rotate the array so that its contents
711 starts at offset 0. */
712 if (wq->offset > 0)
713 {
714 unsigned int old_count = wq->count;
715 unsigned int old_alloc = wq->alloc;
716 unsigned int old_offset = wq->offset;
717 unsigned int i;
718 if (old_offset + old_count > old_alloc)
719 {
720 unsigned int limit = old_offset + old_count - old_alloc;
721 for (i = 0; i < limit; i++)
722 new_array[old_alloc + i] = new_array[i];
723 }
724 for (i = 0; i < old_count; i++)
725 new_array[i] = new_array[old_offset + i];
726 wq->offset = 0;
727 }
728 wq->array = new_array;
729 wq->alloc = new_alloc;
730 }
731 /* Whether the created event is a manual-reset one or an auto-reset one,
732 does not matter, since we will wait on it only once. */
733 event = CreateEvent (NULL, TRUE, FALSE, NULL);
734 if (event == INVALID_HANDLE_VALUE)
735 /* No way to allocate an event. */
736 return INVALID_HANDLE_VALUE;
737 index = wq->offset + wq->count;
738 if (index >= wq->alloc)
739 index -= wq->alloc;
740 wq->array[index] = event;
741 wq->count++;
742 return event;
743}
744
745/* Notifies the first thread from a wait queue and dequeues it. */
746static void
747gl_waitqueue_notify_first (gl_waitqueue_t *wq)
748{
749 SetEvent (wq->array[wq->offset + 0]);
750 wq->offset++;
751 wq->count--;
752 if (wq->count == 0 || wq->offset == wq->alloc)
753 wq->offset = 0;
754}
755
756/* Notifies all threads from a wait queue and dequeues them all. */
757static void
758gl_waitqueue_notify_all (gl_waitqueue_t *wq)
759{
760 unsigned int i;
761
762 for (i = 0; i < wq->count; i++)
763 {
764 unsigned int index = wq->offset + i;
765 if (index >= wq->alloc)
766 index -= wq->alloc;
767 SetEvent (wq->array[index]);
768 }
769 wq->count = 0;
770 wq->offset = 0;
771}
772
773void
774glthread_rwlock_init_func (gl_rwlock_t *lock)
775{
776 InitializeCriticalSection (&lock->lock);
777 gl_waitqueue_init (&lock->waiting_readers);
778 gl_waitqueue_init (&lock->waiting_writers);
779 lock->runcount = 0;
780 lock->guard.done = 1;
781}
782
783int
784glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
785{
786 if (!lock->guard.done)
787 {
788 if (InterlockedIncrement (&lock->guard.started) == 0)
789 /* This thread is the first one to need this lock. Initialize it. */
790 glthread_rwlock_init (lock);
791 else
792 /* Yield the CPU while waiting for another thread to finish
793 initializing this lock. */
794 while (!lock->guard.done)
795 Sleep (0);
796 }
797 EnterCriticalSection (&lock->lock);
798 /* Test whether only readers are currently running, and whether the runcount
799 field will not overflow. */
800 if (!(lock->runcount + 1 > 0))
801 {
802 /* This thread has to wait for a while. Enqueue it among the
803 waiting_readers. */
804 HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
805 if (event != INVALID_HANDLE_VALUE)
806 {
807 DWORD result;
808 LeaveCriticalSection (&lock->lock);
809 /* Wait until another thread signals this event. */
810 result = WaitForSingleObject (event, INFINITE);
811 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
812 abort ();
813 CloseHandle (event);
814 /* The thread which signalled the event already did the bookkeeping:
815 removed us from the waiting_readers, incremented lock->runcount. */
816 if (!(lock->runcount > 0))
817 abort ();
818 return 0;
819 }
820 else
821 {
822 /* Allocation failure. Weird. */
823 do
824 {
825 LeaveCriticalSection (&lock->lock);
826 Sleep (1);
827 EnterCriticalSection (&lock->lock);
828 }
829 while (!(lock->runcount + 1 > 0));
830 }
831 }
832 lock->runcount++;
833 LeaveCriticalSection (&lock->lock);
834 return 0;
835}
836
837int
838glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
839{
840 if (!lock->guard.done)
841 {
842 if (InterlockedIncrement (&lock->guard.started) == 0)
843 /* This thread is the first one to need this lock. Initialize it. */
844 glthread_rwlock_init (lock);
845 else
846 /* Yield the CPU while waiting for another thread to finish
847 initializing this lock. */
848 while (!lock->guard.done)
849 Sleep (0);
850 }
851 EnterCriticalSection (&lock->lock);
852 /* Test whether no readers or writers are currently running. */
853 if (!(lock->runcount == 0))
854 {
855 /* This thread has to wait for a while. Enqueue it among the
856 waiting_writers. */
857 HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
858 if (event != INVALID_HANDLE_VALUE)
859 {
860 DWORD result;
861 LeaveCriticalSection (&lock->lock);
862 /* Wait until another thread signals this event. */
863 result = WaitForSingleObject (event, INFINITE);
864 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
865 abort ();
866 CloseHandle (event);
867 /* The thread which signalled the event already did the bookkeeping:
868 removed us from the waiting_writers, set lock->runcount = -1. */
869 if (!(lock->runcount == -1))
870 abort ();
871 return 0;
872 }
873 else
874 {
875 /* Allocation failure. Weird. */
876 do
877 {
878 LeaveCriticalSection (&lock->lock);
879 Sleep (1);
880 EnterCriticalSection (&lock->lock);
881 }
882 while (!(lock->runcount == 0));
883 }
884 }
885 lock->runcount--; /* runcount becomes -1 */
886 LeaveCriticalSection (&lock->lock);
887 return 0;
888}
889
890int
891glthread_rwlock_unlock_func (gl_rwlock_t *lock)
892{
893 if (!lock->guard.done)
894 return EINVAL;
895 EnterCriticalSection (&lock->lock);
896 if (lock->runcount < 0)
897 {
898 /* Drop a writer lock. */
899 if (!(lock->runcount == -1))
900 abort ();
901 lock->runcount = 0;
902 }
903 else
904 {
905 /* Drop a reader lock. */
906 if (!(lock->runcount > 0))
907 {
908 LeaveCriticalSection (&lock->lock);
909 return EPERM;
910 }
911 lock->runcount--;
912 }
913 if (lock->runcount == 0)
914 {
915 /* POSIX recommends that "write locks shall take precedence over read
916 locks", to avoid "writer starvation". */
917 if (lock->waiting_writers.count > 0)
918 {
919 /* Wake up one of the waiting writers. */
920 lock->runcount--;
921 gl_waitqueue_notify_first (&lock->waiting_writers);
922 }
923 else
924 {
925 /* Wake up all waiting readers. */
926 lock->runcount += lock->waiting_readers.count;
927 gl_waitqueue_notify_all (&lock->waiting_readers);
928 }
929 }
930 LeaveCriticalSection (&lock->lock);
931 return 0;
932}
933
934int
935glthread_rwlock_destroy_func (gl_rwlock_t *lock)
936{
937 if (!lock->guard.done)
938 return EINVAL;
939 if (lock->runcount != 0)
940 return EBUSY;
941 DeleteCriticalSection (&lock->lock);
942 if (lock->waiting_readers.array != NULL)
943 free (lock->waiting_readers.array);
944 if (lock->waiting_writers.array != NULL)
945 free (lock->waiting_writers.array);
946 lock->guard.done = 0;
947 return 0;
948}
949
950/* --------------------- gl_recursive_lock_t datatype --------------------- */
951
952void
953glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
954{
955 lock->owner = 0;
956 lock->depth = 0;
957 InitializeCriticalSection (&lock->lock);
958 lock->guard.done = 1;
959}
960
961int
962glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
963{
964 if (!lock->guard.done)
965 {
966 if (InterlockedIncrement (&lock->guard.started) == 0)
967 /* This thread is the first one to need this lock. Initialize it. */
968 glthread_recursive_lock_init (lock);
969 else
970 /* Yield the CPU while waiting for another thread to finish
971 initializing this lock. */
972 while (!lock->guard.done)
973 Sleep (0);
974 }
975 {
976 DWORD self = GetCurrentThreadId ();
977 if (lock->owner != self)
978 {
979 EnterCriticalSection (&lock->lock);
980 lock->owner = self;
981 }
982 if (++(lock->depth) == 0) /* wraparound? */
983 {
984 lock->depth--;
985 return EAGAIN;
986 }
987 }
988 return 0;
989}
990
991int
992glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
993{
994 if (lock->owner != GetCurrentThreadId ())
995 return EPERM;
996 if (lock->depth == 0)
997 return EINVAL;
998 if (--(lock->depth) == 0)
999 {
1000 lock->owner = 0;
1001 LeaveCriticalSection (&lock->lock);
1002 }
1003 return 0;
1004}
1005
1006int
1007glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
1008{
1009 if (lock->owner != 0)
1010 return EBUSY;
1011 DeleteCriticalSection (&lock->lock);
1012 lock->guard.done = 0;
1013 return 0;
1014}
1015
1016/* -------------------------- gl_once_t datatype -------------------------- */
1017
1018void
1019glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
1020{
1021 if (once_control->inited <= 0)
1022 {
1023 if (InterlockedIncrement (&once_control->started) == 0)
1024 {
1025 /* This thread is the first one to come to this once_control. */
1026 InitializeCriticalSection (&once_control->lock);
1027 EnterCriticalSection (&once_control->lock);
1028 once_control->inited = 0;
1029 initfunction ();
1030 once_control->inited = 1;
1031 LeaveCriticalSection (&once_control->lock);
1032 }
1033 else
1034 {
1035 /* Undo last operation. */
1036 InterlockedDecrement (&once_control->started);
1037 /* Some other thread has already started the initialization.
1038 Yield the CPU while waiting for the other thread to finish
1039 initializing and taking the lock. */
1040 while (once_control->inited < 0)
1041 Sleep (0);
1042 if (once_control->inited <= 0)
1043 {
1044 /* Take the lock. This blocks until the other thread has
1045 finished calling the initfunction. */
1046 EnterCriticalSection (&once_control->lock);
1047 LeaveCriticalSection (&once_control->lock);
1048 if (!(once_control->inited > 0))
1049 abort ();
1050 }
1051 }
1052 }
1053}
1054
1055#endif 747#endif
1056 748
1057/* ========================================================================= */ 749/* ========================================================================= */
diff --git a/gl/glthread/lock.h b/gl/glthread/lock.h
index d20bbde..ae3ee2d 100644
--- a/gl/glthread/lock.h
+++ b/gl/glthread/lock.h
@@ -1,22 +1,21 @@
1/* Locking in multithreaded situations. 1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. 17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h, 18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */
19 gthr-win32.h. */
20 19
21/* This file contains locking primitives for use with a given thread library. 20/* This file contains locking primitives for use with a given thread library.
22 It does not contain primitives for creating threads or for other 21 It does not contain primitives for creating threads or for other
@@ -81,6 +80,127 @@
81#include <errno.h> 80#include <errno.h>
82#include <stdlib.h> 81#include <stdlib.h>
83 82
83#if !defined c11_threads_in_use
84# if HAVE_THREADS_H && USE_POSIX_THREADS_FROM_LIBC
85# define c11_threads_in_use() 1
86# elif HAVE_THREADS_H && USE_POSIX_THREADS_WEAK
87# include <threads.h>
88# pragma weak thrd_exit
89# define c11_threads_in_use() (thrd_exit != NULL)
90# else
91# define c11_threads_in_use() 0
92# endif
93#endif
94
95/* ========================================================================= */
96
97#if USE_ISOC_THREADS || USE_ISOC_AND_POSIX_THREADS
98
99/* Use the ISO C threads library. */
100
101# include <threads.h>
102
103# ifdef __cplusplus
104extern "C" {
105# endif
106
107/* -------------------------- gl_lock_t datatype -------------------------- */
108
109typedef struct
110 {
111 int volatile init_needed;
112 once_flag init_once;
113 void (*init_func) (void);
114 mtx_t mutex;
115 }
116 gl_lock_t;
117# define gl_lock_define(STORAGECLASS, NAME) \
118 STORAGECLASS gl_lock_t NAME;
119# define gl_lock_define_initialized(STORAGECLASS, NAME) \
120 static void _atomic_init_##NAME (void); \
121 STORAGECLASS gl_lock_t NAME = \
122 { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \
123 static void _atomic_init_##NAME (void) \
124 { \
125 if (glthread_lock_init (&(NAME))) \
126 abort (); \
127 }
128extern int glthread_lock_init (gl_lock_t *lock);
129extern int glthread_lock_lock (gl_lock_t *lock);
130extern int glthread_lock_unlock (gl_lock_t *lock);
131extern int glthread_lock_destroy (gl_lock_t *lock);
132
133/* ------------------------- gl_rwlock_t datatype ------------------------- */
134
135typedef struct
136 {
137 int volatile init_needed;
138 once_flag init_once;
139 void (*init_func) (void);
140 mtx_t lock; /* protects the remaining fields */
141 cnd_t waiting_readers; /* waiting readers */
142 cnd_t waiting_writers; /* waiting writers */
143 unsigned int waiting_writers_count; /* number of waiting writers */
144 int runcount; /* number of readers running, or -1 when a writer runs */
145 }
146 gl_rwlock_t;
147# define gl_rwlock_define(STORAGECLASS, NAME) \
148 STORAGECLASS gl_rwlock_t NAME;
149# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
150 static void _atomic_init_##NAME (void); \
151 STORAGECLASS gl_rwlock_t NAME = \
152 { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \
153 static void _atomic_init_##NAME (void) \
154 { \
155 if (glthread_rwlock_init (&(NAME))) \
156 abort (); \
157 }
158extern int glthread_rwlock_init (gl_rwlock_t *lock);
159extern int glthread_rwlock_rdlock (gl_rwlock_t *lock);
160extern int glthread_rwlock_wrlock (gl_rwlock_t *lock);
161extern int glthread_rwlock_unlock (gl_rwlock_t *lock);
162extern int glthread_rwlock_destroy (gl_rwlock_t *lock);
163
164/* --------------------- gl_recursive_lock_t datatype --------------------- */
165
166typedef struct
167 {
168 int volatile init_needed;
169 once_flag init_once;
170 void (*init_func) (void);
171 mtx_t mutex;
172 }
173 gl_recursive_lock_t;
174# define gl_recursive_lock_define(STORAGECLASS, NAME) \
175 STORAGECLASS gl_recursive_lock_t NAME;
176# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
177 static void _atomic_init_##NAME (void); \
178 STORAGECLASS gl_recursive_lock_t NAME = \
179 { 1, ONCE_FLAG_INIT, _atomic_init_##NAME }; \
180 static void _atomic_init_##NAME (void) \
181 { \
182 if (glthread_recursive_lock_init (&(NAME))) \
183 abort (); \
184 }
185extern int glthread_recursive_lock_init (gl_recursive_lock_t *lock);
186extern int glthread_recursive_lock_lock (gl_recursive_lock_t *lock);
187extern int glthread_recursive_lock_unlock (gl_recursive_lock_t *lock);
188extern int glthread_recursive_lock_destroy (gl_recursive_lock_t *lock);
189
190/* -------------------------- gl_once_t datatype -------------------------- */
191
192typedef once_flag gl_once_t;
193# define gl_once_define(STORAGECLASS, NAME) \
194 STORAGECLASS once_flag NAME = ONCE_FLAG_INIT;
195# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
196 (call_once (ONCE_CONTROL, INITFUNCTION), 0)
197
198# ifdef __cplusplus
199}
200# endif
201
202#endif
203
84/* ========================================================================= */ 204/* ========================================================================= */
85 205
86#if USE_POSIX_THREADS 206#if USE_POSIX_THREADS
@@ -139,13 +259,25 @@ extern int glthread_in_use (void);
139# pragma weak pthread_mutexattr_init 259# pragma weak pthread_mutexattr_init
140# pragma weak pthread_mutexattr_settype 260# pragma weak pthread_mutexattr_settype
141# pragma weak pthread_mutexattr_destroy 261# pragma weak pthread_mutexattr_destroy
262# pragma weak pthread_rwlockattr_init
263# if __GNU_LIBRARY__ > 1
264# pragma weak pthread_rwlockattr_setkind_np
265# endif
266# pragma weak pthread_rwlockattr_destroy
142# ifndef pthread_self 267# ifndef pthread_self
143# pragma weak pthread_self 268# pragma weak pthread_self
144# endif 269# endif
145 270
146# if !PTHREAD_IN_USE_DETECTION_HARD 271# if !PTHREAD_IN_USE_DETECTION_HARD
147# pragma weak pthread_cancel 272 /* Considering all platforms with USE_POSIX_THREADS_WEAK, only few symbols
148# define pthread_in_use() (pthread_cancel != NULL) 273 can be used to determine whether libpthread is in use. These are:
274 pthread_mutexattr_gettype
275 pthread_rwlockattr_destroy
276 pthread_rwlockattr_init
277 */
278# pragma weak pthread_mutexattr_gettype
279# define pthread_in_use() \
280 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
149# endif 281# endif
150 282
151# else 283# else
@@ -176,19 +308,32 @@ typedef pthread_mutex_t gl_lock_t;
176 308
177/* ------------------------- gl_rwlock_t datatype ------------------------- */ 309/* ------------------------- gl_rwlock_t datatype ------------------------- */
178 310
179# if HAVE_PTHREAD_RWLOCK 311# if HAVE_PTHREAD_RWLOCK && (HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER || (defined PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP && (__GNU_LIBRARY__ > 1)))
180 312
181# ifdef PTHREAD_RWLOCK_INITIALIZER 313# if defined PTHREAD_RWLOCK_INITIALIZER || defined PTHREAD_RWLOCK_INITIALIZER_NP
182 314
183typedef pthread_rwlock_t gl_rwlock_t; 315typedef pthread_rwlock_t gl_rwlock_t;
184# define gl_rwlock_define(STORAGECLASS, NAME) \ 316# define gl_rwlock_define(STORAGECLASS, NAME) \
185 STORAGECLASS pthread_rwlock_t NAME; 317 STORAGECLASS pthread_rwlock_t NAME;
186# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ 318# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
187 STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer; 319 STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
188# define gl_rwlock_initializer \ 320# if HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
189 PTHREAD_RWLOCK_INITIALIZER 321# if defined PTHREAD_RWLOCK_INITIALIZER
190# define glthread_rwlock_init(LOCK) \ 322# define gl_rwlock_initializer \
191 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0) 323 PTHREAD_RWLOCK_INITIALIZER
324# else
325# define gl_rwlock_initializer \
326 PTHREAD_RWLOCK_INITIALIZER_NP
327# endif
328# define glthread_rwlock_init(LOCK) \
329 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
330# else /* glibc with bug https://sourceware.org/bugzilla/show_bug.cgi?id=13701 */
331# define gl_rwlock_initializer \
332 PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
333# define glthread_rwlock_init(LOCK) \
334 (pthread_in_use () ? glthread_rwlock_init_for_glibc (LOCK) : 0)
335extern int glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock);
336# endif
192# define glthread_rwlock_rdlock(LOCK) \ 337# define glthread_rwlock_rdlock(LOCK) \
193 (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0) 338 (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
194# define glthread_rwlock_wrlock(LOCK) \ 339# define glthread_rwlock_wrlock(LOCK) \
@@ -362,248 +507,20 @@ extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *l
362typedef pthread_once_t gl_once_t; 507typedef pthread_once_t gl_once_t;
363# define gl_once_define(STORAGECLASS, NAME) \ 508# define gl_once_define(STORAGECLASS, NAME) \
364 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT; 509 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
365# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ 510# if PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK
366 (pthread_in_use () \ 511# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
367 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \ 512 (pthread_in_use () \
368 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) 513 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
369extern int glthread_once_singlethreaded (pthread_once_t *once_control); 514 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
370
371# ifdef __cplusplus
372}
373# endif
374
375#endif
376
377/* ========================================================================= */
378
379#if USE_PTH_THREADS
380
381/* Use the GNU Pth threads library. */
382
383# include <pth.h>
384
385# ifdef __cplusplus
386extern "C" {
387# endif
388
389# if USE_PTH_THREADS_WEAK
390
391/* Use weak references to the GNU Pth threads library. */
392
393# pragma weak pth_mutex_init
394# pragma weak pth_mutex_acquire
395# pragma weak pth_mutex_release
396# pragma weak pth_rwlock_init
397# pragma weak pth_rwlock_acquire
398# pragma weak pth_rwlock_release
399# pragma weak pth_once
400
401# pragma weak pth_cancel
402# define pth_in_use() (pth_cancel != NULL)
403
404# else 515# else
405 516# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
406# define pth_in_use() 1 517 (pthread_in_use () \
407 518 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
519 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
520extern int glthread_once_multithreaded (pthread_once_t *once_control,
521 void (*init_function) (void));
408# endif 522# endif
409 523extern int glthread_once_singlethreaded (pthread_once_t *once_control);
410/* -------------------------- gl_lock_t datatype -------------------------- */
411
412typedef pth_mutex_t gl_lock_t;
413# define gl_lock_define(STORAGECLASS, NAME) \
414 STORAGECLASS pth_mutex_t NAME;
415# define gl_lock_define_initialized(STORAGECLASS, NAME) \
416 STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
417# define gl_lock_initializer \
418 PTH_MUTEX_INIT
419# define glthread_lock_init(LOCK) \
420 (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
421# define glthread_lock_lock(LOCK) \
422 (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
423# define glthread_lock_unlock(LOCK) \
424 (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
425# define glthread_lock_destroy(LOCK) \
426 ((void)(LOCK), 0)
427
428/* ------------------------- gl_rwlock_t datatype ------------------------- */
429
430typedef pth_rwlock_t gl_rwlock_t;
431# define gl_rwlock_define(STORAGECLASS, NAME) \
432 STORAGECLASS pth_rwlock_t NAME;
433# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
434 STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
435# define gl_rwlock_initializer \
436 PTH_RWLOCK_INIT
437# define glthread_rwlock_init(LOCK) \
438 (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
439# define glthread_rwlock_rdlock(LOCK) \
440 (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
441# define glthread_rwlock_wrlock(LOCK) \
442 (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
443# define glthread_rwlock_unlock(LOCK) \
444 (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
445# define glthread_rwlock_destroy(LOCK) \
446 ((void)(LOCK), 0)
447
448/* --------------------- gl_recursive_lock_t datatype --------------------- */
449
450/* In Pth, mutexes are recursive by default. */
451typedef pth_mutex_t gl_recursive_lock_t;
452# define gl_recursive_lock_define(STORAGECLASS, NAME) \
453 STORAGECLASS pth_mutex_t NAME;
454# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
455 STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
456# define gl_recursive_lock_initializer \
457 PTH_MUTEX_INIT
458# define glthread_recursive_lock_init(LOCK) \
459 (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
460# define glthread_recursive_lock_lock(LOCK) \
461 (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
462# define glthread_recursive_lock_unlock(LOCK) \
463 (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
464# define glthread_recursive_lock_destroy(LOCK) \
465 ((void)(LOCK), 0)
466
467/* -------------------------- gl_once_t datatype -------------------------- */
468
469typedef pth_once_t gl_once_t;
470# define gl_once_define(STORAGECLASS, NAME) \
471 STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
472# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
473 (pth_in_use () \
474 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
475 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
476extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
477extern int glthread_once_singlethreaded (pth_once_t *once_control);
478
479# ifdef __cplusplus
480}
481# endif
482
483#endif
484
485/* ========================================================================= */
486
487#if USE_SOLARIS_THREADS
488
489/* Use the old Solaris threads library. */
490
491# include <thread.h>
492# include <synch.h>
493
494# ifdef __cplusplus
495extern "C" {
496# endif
497
498# if USE_SOLARIS_THREADS_WEAK
499
500/* Use weak references to the old Solaris threads library. */
501
502# pragma weak mutex_init
503# pragma weak mutex_lock
504# pragma weak mutex_unlock
505# pragma weak mutex_destroy
506# pragma weak rwlock_init
507# pragma weak rw_rdlock
508# pragma weak rw_wrlock
509# pragma weak rw_unlock
510# pragma weak rwlock_destroy
511# pragma weak thr_self
512
513# pragma weak thr_suspend
514# define thread_in_use() (thr_suspend != NULL)
515
516# else
517
518# define thread_in_use() 1
519
520# endif
521
522/* -------------------------- gl_lock_t datatype -------------------------- */
523
524typedef mutex_t gl_lock_t;
525# define gl_lock_define(STORAGECLASS, NAME) \
526 STORAGECLASS mutex_t NAME;
527# define gl_lock_define_initialized(STORAGECLASS, NAME) \
528 STORAGECLASS mutex_t NAME = gl_lock_initializer;
529# define gl_lock_initializer \
530 DEFAULTMUTEX
531# define glthread_lock_init(LOCK) \
532 (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
533# define glthread_lock_lock(LOCK) \
534 (thread_in_use () ? mutex_lock (LOCK) : 0)
535# define glthread_lock_unlock(LOCK) \
536 (thread_in_use () ? mutex_unlock (LOCK) : 0)
537# define glthread_lock_destroy(LOCK) \
538 (thread_in_use () ? mutex_destroy (LOCK) : 0)
539
540/* ------------------------- gl_rwlock_t datatype ------------------------- */
541
542typedef rwlock_t gl_rwlock_t;
543# define gl_rwlock_define(STORAGECLASS, NAME) \
544 STORAGECLASS rwlock_t NAME;
545# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
546 STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
547# define gl_rwlock_initializer \
548 DEFAULTRWLOCK
549# define glthread_rwlock_init(LOCK) \
550 (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
551# define glthread_rwlock_rdlock(LOCK) \
552 (thread_in_use () ? rw_rdlock (LOCK) : 0)
553# define glthread_rwlock_wrlock(LOCK) \
554 (thread_in_use () ? rw_wrlock (LOCK) : 0)
555# define glthread_rwlock_unlock(LOCK) \
556 (thread_in_use () ? rw_unlock (LOCK) : 0)
557# define glthread_rwlock_destroy(LOCK) \
558 (thread_in_use () ? rwlock_destroy (LOCK) : 0)
559
560/* --------------------- gl_recursive_lock_t datatype --------------------- */
561
562/* Old Solaris threads did not have recursive locks.
563 We have to implement them ourselves. */
564
565typedef struct
566 {
567 mutex_t mutex;
568 thread_t owner;
569 unsigned long depth;
570 }
571 gl_recursive_lock_t;
572# define gl_recursive_lock_define(STORAGECLASS, NAME) \
573 STORAGECLASS gl_recursive_lock_t NAME;
574# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
575 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
576# define gl_recursive_lock_initializer \
577 { DEFAULTMUTEX, (thread_t) 0, 0 }
578# define glthread_recursive_lock_init(LOCK) \
579 (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
580# define glthread_recursive_lock_lock(LOCK) \
581 (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
582# define glthread_recursive_lock_unlock(LOCK) \
583 (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
584# define glthread_recursive_lock_destroy(LOCK) \
585 (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
586extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
587extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
588extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
589extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
590
591/* -------------------------- gl_once_t datatype -------------------------- */
592
593typedef struct
594 {
595 volatile int inited;
596 mutex_t mutex;
597 }
598 gl_once_t;
599# define gl_once_define(STORAGECLASS, NAME) \
600 STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
601# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
602 (thread_in_use () \
603 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
604 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
605extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
606extern int glthread_once_singlethreaded (gl_once_t *once_control);
607 524
608# ifdef __cplusplus 525# ifdef __cplusplus
609} 526}
@@ -618,6 +535,11 @@ extern int glthread_once_singlethreaded (gl_once_t *once_control);
618# define WIN32_LEAN_AND_MEAN /* avoid including junk */ 535# define WIN32_LEAN_AND_MEAN /* avoid including junk */
619# include <windows.h> 536# include <windows.h>
620 537
538# include "windows-mutex.h"
539# include "windows-rwlock.h"
540# include "windows-recmutex.h"
541# include "windows-once.h"
542
621# ifdef __cplusplus 543# ifdef __cplusplus
622extern "C" { 544extern "C" {
623# endif 545# endif
@@ -633,127 +555,69 @@ extern "C" {
633/* There is no way to statically initialize a CRITICAL_SECTION. It needs 555/* There is no way to statically initialize a CRITICAL_SECTION. It needs
634 to be done lazily, once only. For this we need spinlocks. */ 556 to be done lazily, once only. For this we need spinlocks. */
635 557
636typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
637
638/* -------------------------- gl_lock_t datatype -------------------------- */ 558/* -------------------------- gl_lock_t datatype -------------------------- */
639 559
640typedef struct 560typedef glwthread_mutex_t gl_lock_t;
641 {
642 gl_spinlock_t guard; /* protects the initialization */
643 CRITICAL_SECTION lock;
644 }
645 gl_lock_t;
646# define gl_lock_define(STORAGECLASS, NAME) \ 561# define gl_lock_define(STORAGECLASS, NAME) \
647 STORAGECLASS gl_lock_t NAME; 562 STORAGECLASS gl_lock_t NAME;
648# define gl_lock_define_initialized(STORAGECLASS, NAME) \ 563# define gl_lock_define_initialized(STORAGECLASS, NAME) \
649 STORAGECLASS gl_lock_t NAME = gl_lock_initializer; 564 STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
650# define gl_lock_initializer \ 565# define gl_lock_initializer \
651 { { 0, -1 } } 566 GLWTHREAD_MUTEX_INIT
652# define glthread_lock_init(LOCK) \ 567# define glthread_lock_init(LOCK) \
653 (glthread_lock_init_func (LOCK), 0) 568 (glwthread_mutex_init (LOCK), 0)
654# define glthread_lock_lock(LOCK) \ 569# define glthread_lock_lock(LOCK) \
655 glthread_lock_lock_func (LOCK) 570 glwthread_mutex_lock (LOCK)
656# define glthread_lock_unlock(LOCK) \ 571# define glthread_lock_unlock(LOCK) \
657 glthread_lock_unlock_func (LOCK) 572 glwthread_mutex_unlock (LOCK)
658# define glthread_lock_destroy(LOCK) \ 573# define glthread_lock_destroy(LOCK) \
659 glthread_lock_destroy_func (LOCK) 574 glwthread_mutex_destroy (LOCK)
660extern void glthread_lock_init_func (gl_lock_t *lock);
661extern int glthread_lock_lock_func (gl_lock_t *lock);
662extern int glthread_lock_unlock_func (gl_lock_t *lock);
663extern int glthread_lock_destroy_func (gl_lock_t *lock);
664 575
665/* ------------------------- gl_rwlock_t datatype ------------------------- */ 576/* ------------------------- gl_rwlock_t datatype ------------------------- */
666 577
667/* It is impossible to implement read-write locks using plain locks, without 578typedef glwthread_rwlock_t gl_rwlock_t;
668 introducing an extra thread dedicated to managing read-write locks.
669 Therefore here we need to use the low-level Event type. */
670
671typedef struct
672 {
673 HANDLE *array; /* array of waiting threads, each represented by an event */
674 unsigned int count; /* number of waiting threads */
675 unsigned int alloc; /* length of allocated array */
676 unsigned int offset; /* index of first waiting thread in array */
677 }
678 gl_carray_waitqueue_t;
679typedef struct
680 {
681 gl_spinlock_t guard; /* protects the initialization */
682 CRITICAL_SECTION lock; /* protects the remaining fields */
683 gl_carray_waitqueue_t waiting_readers; /* waiting readers */
684 gl_carray_waitqueue_t waiting_writers; /* waiting writers */
685 int runcount; /* number of readers running, or -1 when a writer runs */
686 }
687 gl_rwlock_t;
688# define gl_rwlock_define(STORAGECLASS, NAME) \ 579# define gl_rwlock_define(STORAGECLASS, NAME) \
689 STORAGECLASS gl_rwlock_t NAME; 580 STORAGECLASS gl_rwlock_t NAME;
690# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ 581# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
691 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; 582 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
692# define gl_rwlock_initializer \ 583# define gl_rwlock_initializer \
693 { { 0, -1 } } 584 GLWTHREAD_RWLOCK_INIT
694# define glthread_rwlock_init(LOCK) \ 585# define glthread_rwlock_init(LOCK) \
695 (glthread_rwlock_init_func (LOCK), 0) 586 (glwthread_rwlock_init (LOCK), 0)
696# define glthread_rwlock_rdlock(LOCK) \ 587# define glthread_rwlock_rdlock(LOCK) \
697 glthread_rwlock_rdlock_func (LOCK) 588 glwthread_rwlock_rdlock (LOCK)
698# define glthread_rwlock_wrlock(LOCK) \ 589# define glthread_rwlock_wrlock(LOCK) \
699 glthread_rwlock_wrlock_func (LOCK) 590 glwthread_rwlock_wrlock (LOCK)
700# define glthread_rwlock_unlock(LOCK) \ 591# define glthread_rwlock_unlock(LOCK) \
701 glthread_rwlock_unlock_func (LOCK) 592 glwthread_rwlock_unlock (LOCK)
702# define glthread_rwlock_destroy(LOCK) \ 593# define glthread_rwlock_destroy(LOCK) \
703 glthread_rwlock_destroy_func (LOCK) 594 glwthread_rwlock_destroy (LOCK)
704extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
705extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
706extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
707extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
708extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
709 595
710/* --------------------- gl_recursive_lock_t datatype --------------------- */ 596/* --------------------- gl_recursive_lock_t datatype --------------------- */
711 597
712/* The native Windows documentation says that CRITICAL_SECTION already 598typedef glwthread_recmutex_t gl_recursive_lock_t;
713 implements a recursive lock. But we need not rely on it: It's easy to
714 implement a recursive lock without this assumption. */
715
716typedef struct
717 {
718 gl_spinlock_t guard; /* protects the initialization */
719 DWORD owner;
720 unsigned long depth;
721 CRITICAL_SECTION lock;
722 }
723 gl_recursive_lock_t;
724# define gl_recursive_lock_define(STORAGECLASS, NAME) \ 599# define gl_recursive_lock_define(STORAGECLASS, NAME) \
725 STORAGECLASS gl_recursive_lock_t NAME; 600 STORAGECLASS gl_recursive_lock_t NAME;
726# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ 601# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
727 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer; 602 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
728# define gl_recursive_lock_initializer \ 603# define gl_recursive_lock_initializer \
729 { { 0, -1 }, 0, 0 } 604 GLWTHREAD_RECMUTEX_INIT
730# define glthread_recursive_lock_init(LOCK) \ 605# define glthread_recursive_lock_init(LOCK) \
731 (glthread_recursive_lock_init_func (LOCK), 0) 606 (glwthread_recmutex_init (LOCK), 0)
732# define glthread_recursive_lock_lock(LOCK) \ 607# define glthread_recursive_lock_lock(LOCK) \
733 glthread_recursive_lock_lock_func (LOCK) 608 glwthread_recmutex_lock (LOCK)
734# define glthread_recursive_lock_unlock(LOCK) \ 609# define glthread_recursive_lock_unlock(LOCK) \
735 glthread_recursive_lock_unlock_func (LOCK) 610 glwthread_recmutex_unlock (LOCK)
736# define glthread_recursive_lock_destroy(LOCK) \ 611# define glthread_recursive_lock_destroy(LOCK) \
737 glthread_recursive_lock_destroy_func (LOCK) 612 glwthread_recmutex_destroy (LOCK)
738extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
739extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
740extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
741extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
742 613
743/* -------------------------- gl_once_t datatype -------------------------- */ 614/* -------------------------- gl_once_t datatype -------------------------- */
744 615
745typedef struct 616typedef glwthread_once_t gl_once_t;
746 {
747 volatile int inited;
748 volatile long started;
749 CRITICAL_SECTION lock;
750 }
751 gl_once_t;
752# define gl_once_define(STORAGECLASS, NAME) \ 617# define gl_once_define(STORAGECLASS, NAME) \
753 STORAGECLASS gl_once_t NAME = { -1, -1 }; 618 STORAGECLASS gl_once_t NAME = GLWTHREAD_ONCE_INIT;
754# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ 619# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
755 (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0) 620 (glwthread_once (ONCE_CONTROL, INITFUNCTION), 0)
756extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
757 621
758# ifdef __cplusplus 622# ifdef __cplusplus
759} 623}
@@ -763,7 +627,7 @@ extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (v
763 627
764/* ========================================================================= */ 628/* ========================================================================= */
765 629
766#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS) 630#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS || USE_WINDOWS_THREADS)
767 631
768/* Provide dummy implementation if threads are not supported. */ 632/* Provide dummy implementation if threads are not supported. */
769 633
diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c
index b447657..5ecf827 100644
--- a/gl/glthread/threadlib.c
+++ b/gl/glthread/threadlib.c
@@ -1,18 +1,18 @@
1/* Multithreading primitives. 1/* Multithreading primitives.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
18 18
@@ -20,15 +20,48 @@
20 20
21/* ========================================================================= */ 21/* ========================================================================= */
22 22
23#if USE_POSIX_THREADS 23#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS
24 24
25/* Use the POSIX threads library. */ 25/* Use the POSIX threads library. */
26 26
27# include <errno.h>
27# include <pthread.h> 28# include <pthread.h>
28# include <stdlib.h> 29# include <stdlib.h>
29 30
30# if PTHREAD_IN_USE_DETECTION_HARD 31# if PTHREAD_IN_USE_DETECTION_HARD
31 32
33# if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
34
35/* Test using pthread_key_create. */
36
37int
38glthread_in_use (void)
39{
40 static int tested;
41 static int result; /* 1: linked with -lpthread, 0: only with libc */
42
43 if (!tested)
44 {
45 pthread_key_t key;
46 int err = pthread_key_create (&key, NULL);
47
48 if (err == ENOSYS)
49 result = 0;
50 else
51 {
52 result = 1;
53 if (err == 0)
54 pthread_key_delete (key);
55 }
56 tested = 1;
57 }
58 return result;
59}
60
61# else /* Solaris, HP-UX */
62
63/* Test using pthread_create. */
64
32/* The function to be executed by a dummy thread. */ 65/* The function to be executed by a dummy thread. */
33static void * 66static void *
34dummy_thread_func (void *arg) 67dummy_thread_func (void *arg)
@@ -62,6 +95,8 @@ glthread_in_use (void)
62 return result; 95 return result;
63} 96}
64 97
98# endif
99
65# endif 100# endif
66 101
67#endif 102#endif
diff --git a/gl/hard-locale.c b/gl/hard-locale.c
new file mode 100644
index 0000000..0a28552
--- /dev/null
+++ b/gl/hard-locale.c
@@ -0,0 +1,35 @@
1/* hard-locale.c -- Determine whether a locale is hard.
2
3 Copyright (C) 1997-1999, 2002-2004, 2006-2007, 2009-2023 Free Software
4 Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19#include <config.h>
20
21#include "hard-locale.h"
22
23#include <locale.h>
24#include <string.h>
25
26bool
27hard_locale (int category)
28{
29 char locale[SETLOCALE_NULL_MAX];
30
31 if (setlocale_null_r (category, locale, sizeof (locale)))
32 return false;
33
34 return !(strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0);
35}
diff --git a/gl/hard-locale.h b/gl/hard-locale.h
new file mode 100644
index 0000000..880c9e8
--- /dev/null
+++ b/gl/hard-locale.h
@@ -0,0 +1,26 @@
1/* Determine whether a locale is hard.
2
3 Copyright (C) 1999, 2003-2004, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef HARD_LOCALE_H_
19# define HARD_LOCALE_H_ 1
20
21/* Return true if the specified CATEGORY of the current locale is hard, i.e.
22 different from the C or POSIX locale that has a fixed behavior.
23 CATEGORY must be one of the LC_* values, but not LC_ALL. */
24extern bool hard_locale (int category);
25
26#endif /* HARD_LOCALE_H_ */
diff --git a/gl/ialloc.c b/gl/ialloc.c
new file mode 100644
index 0000000..cd44d8c
--- /dev/null
+++ b/gl/ialloc.c
@@ -0,0 +1,21 @@
1/* malloc with idx_t rather than size_t
2
3 Copyright 2021-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20#define IALLOC_INLINE _GL_EXTERN_INLINE
21#include "ialloc.h"
diff --git a/gl/ialloc.h b/gl/ialloc.h
new file mode 100644
index 0000000..1d43faf
--- /dev/null
+++ b/gl/ialloc.h
@@ -0,0 +1,100 @@
1/* ialloc.h -- malloc with idx_t rather than size_t
2
3 Copyright 2021-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef IALLOC_H_
19#define IALLOC_H_
20
21#include "idx.h"
22
23#include <errno.h>
24#include <stdint.h>
25#include <stdlib.h>
26
27#ifndef _GL_INLINE_HEADER_BEGIN
28 #error "Please include config.h first."
29#endif
30_GL_INLINE_HEADER_BEGIN
31#ifndef IALLOC_INLINE
32# define IALLOC_INLINE _GL_INLINE
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39IALLOC_INLINE void * _GL_ATTRIBUTE_COLD
40_gl_alloc_nomem (void)
41{
42 errno = ENOMEM;
43 return NULL;
44}
45
46IALLOC_INLINE
47_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/
48void *
49imalloc (idx_t s)
50{
51 return s <= SIZE_MAX ? malloc (s) : _gl_alloc_nomem ();
52}
53
54IALLOC_INLINE
55/*_GL_ATTRIBUTE_DEALLOC_FREE*/
56void *
57irealloc (void *p, idx_t s)
58{
59 /* Work around GNU realloc glitch by treating a zero size as if it
60 were 1, so that returning NULL is equivalent to failing. */
61 return s <= SIZE_MAX ? realloc (p, s | !s) : _gl_alloc_nomem ();
62}
63
64IALLOC_INLINE
65_GL_ATTRIBUTE_MALLOC /*_GL_ATTRIBUTE_DEALLOC_FREE*/
66void *
67icalloc (idx_t n, idx_t s)
68{
69 if (SIZE_MAX < n)
70 {
71 if (s != 0)
72 return _gl_alloc_nomem ();
73 n = 0;
74 }
75 if (SIZE_MAX < s)
76 {
77 if (n != 0)
78 return _gl_alloc_nomem ();
79 s = 0;
80 }
81 return calloc (n, s);
82}
83
84IALLOC_INLINE void *
85ireallocarray (void *p, idx_t n, idx_t s)
86{
87 /* Work around GNU reallocarray glitch by treating a zero size as if
88 it were 1, so that returning NULL is equivalent to failing. */
89 if (n == 0 || s == 0)
90 n = s = 1;
91 return (n <= SIZE_MAX && s <= SIZE_MAX
92 ? reallocarray (p, n, s)
93 : _gl_alloc_nomem ());
94}
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif
diff --git a/gl/idpriv-droptemp.c b/gl/idpriv-droptemp.c
index 13d1064..2a85431 100644
--- a/gl/idpriv-droptemp.c
+++ b/gl/idpriv-droptemp.c
@@ -1,9 +1,9 @@
1/* Dropping uid/gid privileges of the current process temporarily. 1/* Dropping uid/gid privileges of the current process temporarily.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
@@ -58,7 +58,9 @@ idpriv_temp_drop (void)
58 58
59 /* This is for executables that have the setuid bit set. */ 59 /* This is for executables that have the setuid bit set. */
60# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */ 60# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
61 /* See <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf> 61 /* See
62 Hao Chen, David Wagner, Drew Dean: Setuid Demystified
63 <https://www.usenix.org/legacy/publications/library/proceedings/sec02/full_papers/chen/chen.pdf>
62 figure 14. */ 64 figure 14. */
63 if (setresuid (-1, uid, saved_uid) < 0) 65 if (setresuid (-1, uid, saved_uid) < 0)
64 return -1; 66 return -1;
@@ -134,7 +136,9 @@ idpriv_temp_restore (void)
134 136
135 /* This is for executables that have the setuid bit set. */ 137 /* This is for executables that have the setuid bit set. */
136# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */ 138# if HAVE_SETRESUID /* glibc, FreeBSD, OpenBSD, HP-UX */
137 /* See <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf> 139 /* See
140 Hao Chen, David Wagner, Drew Dean: Setuid Demystified
141 <https://www.usenix.org/legacy/publications/library/proceedings/sec02/full_papers/chen/chen.pdf>
138 figure 14. */ 142 figure 14. */
139 if (setresuid (-1, saved_uid, -1) < 0) 143 if (setresuid (-1, saved_uid, -1) < 0)
140 return -1; 144 return -1;
diff --git a/gl/idpriv.h b/gl/idpriv.h
index f454a2c..99f87c0 100644
--- a/gl/idpriv.h
+++ b/gl/idpriv.h
@@ -1,9 +1,9 @@
1/* Dropping uid/gid privileges of the current process. 1/* Dropping uid/gid privileges of the current process.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or 6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _IDPRIV_H 17#ifndef _IDPRIV_H
18#define _IDPRIV_H 18#define _IDPRIV_H
@@ -74,11 +74,11 @@ extern "C" {
74 74
75/* For more in-depth discussion of these topics, see the papers/articles 75/* For more in-depth discussion of these topics, see the papers/articles
76 * Hao Chen, David Wagner, Drew Dean: Setuid Demystified 76 * Hao Chen, David Wagner, Drew Dean: Setuid Demystified
77 <http://www.usenix.org/events/sec02/full_papers/chen/chen.pdf> 77 <https://www.usenix.org/legacy/publications/library/proceedings/sec02/full_papers/chen/chen.pdf>
78 * Dan Tsafrir, Dilma da Silva, David Wagner: The Murky Issue of Changing 78 * Dan Tsafrir, Dilma da Silva, David Wagner: The Murky Issue of Changing
79 Process Identity: Revising "Setuid Demystified" 79 Process Identity: Revising "Setuid Demystified"
80 <http://www.eecs.berkeley.edu/~daw/papers/setuid-login08b.pdf> 80 <https://people.eecs.berkeley.edu/~daw/papers/setuid-login08b.pdf>
81 <http://code.google.com/p/change-process-identity/> 81 <https://code.google.com/archive/p/change-process-identity/>
82 * Dhruv Mohindra: Observe correct revocation order while relinquishing 82 * Dhruv Mohindra: Observe correct revocation order while relinquishing
83 privileges 83 privileges
84 <https://www.securecoding.cert.org/confluence/display/seccode/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges> 84 <https://www.securecoding.cert.org/confluence/display/seccode/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges>
diff --git a/gl/idx.h b/gl/idx.h
new file mode 100644
index 0000000..23020b7
--- /dev/null
+++ b/gl/idx.h
@@ -0,0 +1,134 @@
1/* A type for indices and sizes.
2 Copyright (C) 2020-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _IDX_H
20#define _IDX_H
21
22/* Get ptrdiff_t. */
23#include <stddef.h>
24
25/* Get PTRDIFF_MAX. */
26#include <stdint.h>
27
28/* The type 'idx_t' holds an (array) index or an (object) size.
29 Its implementation promotes to a signed integer type,
30 which can hold the values
31 0..2^63-1 (on 64-bit platforms) or
32 0..2^31-1 (on 32-bit platforms).
33
34 Why a signed integer type?
35
36 * Security: Signed types can be checked for overflow via
37 '-fsanitize=undefined', but unsigned types cannot.
38
39 * Comparisons without surprises: ISO C99 § 6.3.1.8 specifies a few
40 surprising results for comparisons, such as
41
42 (int) -3 < (unsigned long) 7 => false
43 (int) -3 < (unsigned int) 7 => false
44 and on 32-bit machines:
45 (long) -3 < (unsigned int) 7 => false
46
47 This is surprising because the natural comparison order is by
48 value in the realm of infinite-precision signed integers (ℤ).
49
50 The best way to get rid of such surprises is to use signed types
51 for numerical integer values, and use unsigned types only for
52 bit masks and enums.
53
54 Why not use 'size_t' directly?
55
56 * Because 'size_t' is an unsigned type, and a signed type is better.
57 See above.
58
59 Why not use 'ssize_t'?
60
61 * 'ptrdiff_t' is more portable; it is standardized by ISO C
62 whereas 'ssize_t' is standardized only by POSIX.
63
64 * 'ssize_t' is not required to be as wide as 'size_t', and some
65 now-obsolete POSIX platforms had 'size_t' wider than 'ssize_t'.
66
67 * Conversely, some now-obsolete platforms had 'ptrdiff_t' wider
68 than 'size_t', which can be a win and conforms to POSIX.
69
70 Won't this cause a problem with objects larger than PTRDIFF_MAX?
71
72 * Typical modern or large platforms do not allocate such objects,
73 so this is not much of a problem in practice; for example, you
74 can safely write 'idx_t len = strlen (s);'. To port to older
75 small platforms where allocations larger than PTRDIFF_MAX could
76 in theory be a problem, you can use Gnulib's ialloc module, or
77 functions like ximalloc in Gnulib's xalloc module.
78
79 Why not use 'ptrdiff_t' directly?
80
81 * Maintainability: When reading and modifying code, it helps to know that
82 a certain variable cannot have negative values. For example, when you
83 have a loop
84
85 int n = ...;
86 for (int i = 0; i < n; i++) ...
87
88 or
89
90 ptrdiff_t n = ...;
91 for (ptrdiff_t i = 0; i < n; i++) ...
92
93 you have to ask yourself "what if n < 0?". Whereas in
94
95 idx_t n = ...;
96 for (idx_t i = 0; i < n; i++) ...
97
98 you know that this case cannot happen.
99
100 Similarly, when a programmer writes
101
102 idx_t = ptr2 - ptr1;
103
104 there is an implied assertion that ptr1 and ptr2 point into the same
105 object and that ptr1 <= ptr2.
106
107 * Being future-proof: In the future, range types (integers which are
108 constrained to a certain range of values) may be added to C compilers
109 or to the C standard. Several programming languages (Ada, Haskell,
110 Common Lisp, Pascal) already have range types. Such range types may
111 help producing good code and good warnings. The type 'idx_t' could
112 then be typedef'ed to a range type that is signed after promotion. */
113
114/* In the future, idx_t could be typedef'ed to a signed range type.
115 The clang "extended integer types", supported in Clang 11 or newer
116 <https://clang.llvm.org/docs/LanguageExtensions.html#extended-integer-types>,
117 are a special case of range types. However, these types don't support binary
118 operators with plain integer types (e.g. expressions such as x > 1).
119 Therefore, they don't behave like signed types (and not like unsigned types
120 either). So, we cannot use them here. */
121
122/* Use the signed type 'ptrdiff_t'. */
123/* Note: ISO C does not mandate that 'size_t' and 'ptrdiff_t' have the same
124 size, but it is so on all platforms we have seen since 1990. */
125typedef ptrdiff_t idx_t;
126
127/* IDX_MAX is the maximum value of an idx_t. */
128#define IDX_MAX PTRDIFF_MAX
129
130/* So far no need has been found for an IDX_WIDTH macro.
131 Perhaps there should be another macro IDX_VALUE_BITS that does not
132 count the sign bit and is therefore one less than PTRDIFF_WIDTH. */
133
134#endif /* _IDX_H */
diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c
index fdfd21d..9e2d412 100644
--- a/gl/inet_ntop.c
+++ b/gl/inet_ntop.c
@@ -1,19 +1,19 @@
1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form 1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
2 2
3 Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* 18/*
19 * Copyright (c) 1996-1999 by Internet Software Consortium. 19 * Copyright (c) 1996-1999 by Internet Software Consortium.
@@ -40,7 +40,7 @@
40/* Use this to suppress gcc's "...may be used before initialized" warnings. 40/* Use this to suppress gcc's "...may be used before initialized" warnings.
41 Beware: The Code argument must not contain commas. */ 41 Beware: The Code argument must not contain commas. */
42#ifndef IF_LINT 42#ifndef IF_LINT
43# ifdef lint 43# if defined GCC_LINT || defined lint
44# define IF_LINT(Code) Code 44# define IF_LINT(Code) Code
45# else 45# else
46# define IF_LINT(Code) /* empty */ 46# define IF_LINT(Code) /* empty */
diff --git a/gl/intprops-internal.h b/gl/intprops-internal.h
new file mode 100644
index 0000000..0467a9c
--- /dev/null
+++ b/gl/intprops-internal.h
@@ -0,0 +1,392 @@
1/* intprops-internal.h -- properties of integer types not visible to users
2
3 Copyright (C) 2001-2023 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_INTPROPS_INTERNAL_H
19#define _GL_INTPROPS_INTERNAL_H
20
21#include <limits.h>
22
23/* Return a value with the common real type of E and V and the value of V.
24 Do not evaluate E. */
25#define _GL_INT_CONVERT(e, v) ((1 ? 0 : (e)) + (v))
26
27/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
28 <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */
29#define _GL_INT_NEGATE_CONVERT(e, v) ((1 ? 0 : (e)) - (v))
30
31/* The extra casts in the following macros work around compiler bugs,
32 e.g., in Cray C 5.0.3.0. */
33
34/* True if the real type T is signed. */
35#define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
36
37/* Return 1 if the real expression E, after promotion, has a
38 signed or floating type. Do not evaluate E. */
39#define _GL_EXPR_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
40
41
42/* Minimum and maximum values for integer types and expressions. */
43
44/* The width in bits of the integer type or expression T.
45 Do not evaluate T. T must not be a bit-field expression.
46 Padding bits are not supported; this is checked at compile-time below. */
47#define _GL_TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
48
49/* The maximum and minimum values for the type of the expression E,
50 after integer promotion. E is not evaluated. */
51#define _GL_INT_MINIMUM(e) \
52 (_GL_EXPR_SIGNED (e) \
53 ? ~ _GL_SIGNED_INT_MAXIMUM (e) \
54 : _GL_INT_CONVERT (e, 0))
55#define _GL_INT_MAXIMUM(e) \
56 (_GL_EXPR_SIGNED (e) \
57 ? _GL_SIGNED_INT_MAXIMUM (e) \
58 : _GL_INT_NEGATE_CONVERT (e, 1))
59#define _GL_SIGNED_INT_MAXIMUM(e) \
60 (((_GL_INT_CONVERT (e, 1) << (_GL_TYPE_WIDTH (+ (e)) - 2)) - 1) * 2 + 1)
61
62/* Work around OpenVMS incompatibility with C99. */
63#if !defined LLONG_MAX && defined __INT64_MAX
64# define LLONG_MAX __INT64_MAX
65# define LLONG_MIN __INT64_MIN
66#endif
67
68/* This include file assumes that signed types are two's complement without
69 padding bits; the above macros have undefined behavior otherwise.
70 If this is a problem for you, please let us know how to fix it for your host.
71 This assumption is tested by the intprops-tests module. */
72
73/* Does the __typeof__ keyword work? This could be done by
74 'configure', but for now it's easier to do it by hand. */
75#if (2 <= __GNUC__ \
76 || (4 <= __clang_major__) \
77 || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
78 || (0x5110 <= __SUNPRO_C && !__STDC__))
79# define _GL_HAVE___TYPEOF__ 1
80#else
81# define _GL_HAVE___TYPEOF__ 0
82#endif
83
84/* Return 1 if the integer type or expression T might be signed. Return 0
85 if it is definitely unsigned. T must not be a bit-field expression.
86 This macro does not evaluate its argument, and expands to an
87 integer constant expression. */
88#if _GL_HAVE___TYPEOF__
89# define _GL_SIGNED_TYPE_OR_EXPR(t) _GL_TYPE_SIGNED (__typeof__ (t))
90#else
91# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
92#endif
93
94/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
95 A should not have side effects, and A's type should be an
96 integer with minimum value MIN and maximum MAX. */
97#define _GL_INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
98 ((min) < 0 ? (a) < - (max) : 0 < (a))
99
100/* True if __builtin_add_overflow (A, B, P) and __builtin_sub_overflow
101 (A, B, P) work when P is non-null. */
102#ifdef __EDG__
103/* EDG-based compilers like nvc 22.1 cannot add 64-bit signed to unsigned
104 <https://bugs.gnu.org/53256>. */
105# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
106#elif defined __has_builtin
107# define _GL_HAS_BUILTIN_ADD_OVERFLOW __has_builtin (__builtin_add_overflow)
108/* __builtin_{add,sub}_overflow exists but is not reliable in GCC 5.x and 6.x,
109 see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98269>. */
110#elif 7 <= __GNUC__
111# define _GL_HAS_BUILTIN_ADD_OVERFLOW 1
112#else
113# define _GL_HAS_BUILTIN_ADD_OVERFLOW 0
114#endif
115
116/* True if __builtin_mul_overflow (A, B, P) works when P is non-null. */
117#if defined __clang_major__ && __clang_major__ < 14
118/* Work around Clang bug <https://bugs.llvm.org/show_bug.cgi?id=16404>. */
119# define _GL_HAS_BUILTIN_MUL_OVERFLOW 0
120#else
121# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
122#endif
123
124/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
125 __builtin_sub_overflow_p and __builtin_mul_overflow_p. */
126#ifdef __EDG__
127/* In EDG-based compilers like ICC 2021.3 and earlier,
128 __builtin_add_overflow_p etc. are not treated as integral constant
129 expressions even when all arguments are. */
130# define _GL_HAS_BUILTIN_OVERFLOW_P 0
131#elif defined __has_builtin
132# define _GL_HAS_BUILTIN_OVERFLOW_P __has_builtin (__builtin_mul_overflow_p)
133#else
134# define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
135#endif
136
137#if (!defined _GL_STDCKDINT_H && 202311 <= __STDC_VERSION__ \
138 && ! (_GL_HAS_BUILTIN_ADD_OVERFLOW && _GL_HAS_BUILTIN_MUL_OVERFLOW))
139# include <stdckdint.h>
140#endif
141
142/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
143 Return 1 if the result overflows. Arguments should not have side
144 effects and A, B and *R can be of any integer type other than char,
145 bool, a bit-precise integer type, or an enumeration type. */
146#if _GL_HAS_BUILTIN_ADD_OVERFLOW
147# define _GL_INT_ADD_WRAPV(a, b, r) __builtin_add_overflow (a, b, r)
148# define _GL_INT_SUBTRACT_WRAPV(a, b, r) __builtin_sub_overflow (a, b, r)
149#elif defined ckd_add && defined ckd_sub && !defined _GL_STDCKDINT_H
150# define _GL_INT_ADD_WRAPV(a, b, r) ckd_add (r, + (a), + (b))
151# define _GL_INT_SUBTRACT_WRAPV(a, b, r) ckd_sub (r, + (a), + (b))
152#else
153# define _GL_INT_ADD_WRAPV(a, b, r) \
154 _GL_INT_OP_WRAPV (a, b, r, +, _GL_INT_ADD_RANGE_OVERFLOW)
155# define _GL_INT_SUBTRACT_WRAPV(a, b, r) \
156 _GL_INT_OP_WRAPV (a, b, r, -, _GL_INT_SUBTRACT_RANGE_OVERFLOW)
157#endif
158#if _GL_HAS_BUILTIN_MUL_OVERFLOW
159# if ((9 < __GNUC__ + (3 <= __GNUC_MINOR__) \
160 || (__GNUC__ == 8 && 4 <= __GNUC_MINOR__)) \
161 && !defined __EDG__)
162# define _GL_INT_MULTIPLY_WRAPV(a, b, r) __builtin_mul_overflow (a, b, r)
163# else
164 /* Work around GCC bug 91450. */
165# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
166 ((!_GL_SIGNED_TYPE_OR_EXPR (*(r)) && _GL_EXPR_SIGNED (a) && _GL_EXPR_SIGNED (b) \
167 && _GL_INT_MULTIPLY_RANGE_OVERFLOW (a, b, 0, (__typeof__ (*(r))) -1)) \
168 ? ((void) __builtin_mul_overflow (a, b, r), 1) \
169 : __builtin_mul_overflow (a, b, r))
170# endif
171#elif defined ckd_mul && !defined _GL_STDCKDINT_H
172# define _GL_INT_MULTIPLY_WRAPV(a, b, r) ckd_mul (r, + (a), + (b))
173#else
174# define _GL_INT_MULTIPLY_WRAPV(a, b, r) \
175 _GL_INT_OP_WRAPV (a, b, r, *, _GL_INT_MULTIPLY_RANGE_OVERFLOW)
176#endif
177
178/* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390. See:
179 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
180 https://llvm.org/bugs/show_bug.cgi?id=25390
181 For now, assume all versions of GCC-like compilers generate bogus
182 warnings for _Generic. This matters only for compilers that
183 lack relevant builtins. */
184#if __GNUC__ || defined __clang__
185# define _GL__GENERIC_BOGUS 1
186#else
187# define _GL__GENERIC_BOGUS 0
188#endif
189
190/* Store the low-order bits of A <op> B into *R, where OP specifies
191 the operation and OVERFLOW the overflow predicate. Return 1 if the
192 result overflows. Arguments should not have side effects,
193 and A, B and *R can be of any integer type other than char, bool, a
194 bit-precise integer type, or an enumeration type. */
195#if 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
196# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
197 (_Generic \
198 (*(r), \
199 signed char: \
200 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
201 signed char, SCHAR_MIN, SCHAR_MAX), \
202 unsigned char: \
203 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
204 unsigned char, 0, UCHAR_MAX), \
205 short int: \
206 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
207 short int, SHRT_MIN, SHRT_MAX), \
208 unsigned short int: \
209 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
210 unsigned short int, 0, USHRT_MAX), \
211 int: \
212 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
213 int, INT_MIN, INT_MAX), \
214 unsigned int: \
215 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
216 unsigned int, 0, UINT_MAX), \
217 long int: \
218 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
219 long int, LONG_MIN, LONG_MAX), \
220 unsigned long int: \
221 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
222 unsigned long int, 0, ULONG_MAX), \
223 long long int: \
224 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
225 long long int, LLONG_MIN, LLONG_MAX), \
226 unsigned long long int: \
227 _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
228 unsigned long long int, 0, ULLONG_MAX)))
229#else
230/* Store the low-order bits of A <op> B into *R, where OP specifies
231 the operation and OVERFLOW the overflow predicate. If *R is
232 signed, its type is ST with bounds SMIN..SMAX; otherwise its type
233 is UT with bounds U..UMAX. ST and UT are narrower than int.
234 Return 1 if the result overflows. Arguments should not have side
235 effects, and A, B and *R can be of any integer type other than
236 char, bool, a bit-precise integer type, or an enumeration type. */
237# if _GL_HAVE___TYPEOF__
238# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
239 (_GL_TYPE_SIGNED (__typeof__ (*(r))) \
240 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, st, smin, smax) \
241 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, ut, 0, umax))
242# else
243# define _GL_INT_OP_WRAPV_SMALLISH(a,b,r,op,overflow,st,smin,smax,ut,umax) \
244 (overflow (a, b, smin, smax) \
245 ? (overflow (a, b, 0, umax) \
246 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 1) \
247 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) < 0) \
248 : (overflow (a, b, 0, umax) \
249 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st)) >= 0 \
250 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a,b,op,unsigned,st), 0)))
251# endif
252
253# define _GL_INT_OP_WRAPV(a, b, r, op, overflow) \
254 (sizeof *(r) == sizeof (signed char) \
255 ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
256 signed char, SCHAR_MIN, SCHAR_MAX, \
257 unsigned char, UCHAR_MAX) \
258 : sizeof *(r) == sizeof (short int) \
259 ? _GL_INT_OP_WRAPV_SMALLISH (a, b, r, op, overflow, \
260 short int, SHRT_MIN, SHRT_MAX, \
261 unsigned short int, USHRT_MAX) \
262 : sizeof *(r) == sizeof (int) \
263 ? (_GL_EXPR_SIGNED (*(r)) \
264 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
265 int, INT_MIN, INT_MAX) \
266 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
267 unsigned int, 0, UINT_MAX)) \
268 : _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow))
269# ifdef LLONG_MAX
270# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
271 (sizeof *(r) == sizeof (long int) \
272 ? (_GL_EXPR_SIGNED (*(r)) \
273 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
274 long int, LONG_MIN, LONG_MAX) \
275 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
276 unsigned long int, 0, ULONG_MAX)) \
277 : (_GL_EXPR_SIGNED (*(r)) \
278 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
279 long long int, LLONG_MIN, LLONG_MAX) \
280 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long long int, \
281 unsigned long long int, 0, ULLONG_MAX)))
282# else
283# define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
284 (_GL_EXPR_SIGNED (*(r)) \
285 ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
286 long int, LONG_MIN, LONG_MAX) \
287 : _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
288 unsigned long int, 0, ULONG_MAX))
289# endif
290#endif
291
292/* Store the low-order bits of A <op> B into *R, where the operation
293 is given by OP. Use the unsigned type UT for calculation to avoid
294 overflow problems. *R's type is T, with extrema TMIN and TMAX.
295 T can be any signed integer type other than char, bool, a
296 bit-precise integer type, or an enumeration type.
297 Return 1 if the result overflows. */
298#define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
299 (overflow (a, b, tmin, tmax) \
300 ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
301 : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
302
303/* Return 1 if the integer expressions A - B and -A would overflow,
304 respectively. Arguments should not have side effects,
305 and can be any signed integer type other than char, bool, a
306 bit-precise integer type, or an enumeration type.
307 These macros are tuned for their last input argument being a constant. */
308
309#if _GL_HAS_BUILTIN_OVERFLOW_P
310# define _GL_INT_NEGATE_OVERFLOW(a) \
311 __builtin_sub_overflow_p (0, a, (__typeof__ (- (a))) 0)
312#else
313# define _GL_INT_NEGATE_OVERFLOW(a) \
314 _GL_INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
315#endif
316
317/* Return the low-order bits of A <op> B, where the operation is given
318 by OP. Use the unsigned type UT for calculation to avoid undefined
319 behavior on signed integer overflow, and convert the result to type T.
320 UT is at least as wide as T and is no narrower than unsigned int,
321 T is two's complement, and there is no padding or trap representations.
322 Assume that converting UT to T yields the low-order bits, as is
323 done in all known two's-complement C compilers. E.g., see:
324 https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
325
326 According to the C standard, converting UT to T yields an
327 implementation-defined result or signal for values outside T's
328 range. However, code that works around this theoretical problem
329 runs afoul of a compiler bug in Oracle Studio 12.3 x86. See:
330 https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
331 As the compiler bug is real, don't try to work around the
332 theoretical problem. */
333
334#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
335 ((t) ((ut) (a) op (ut) (b)))
336
337/* Return true if the numeric values A + B, A - B, A * B fall outside
338 the range TMIN..TMAX. Arguments should not have side effects
339 and can be any integer type other than char, bool,
340 a bit-precise integer type, or an enumeration type.
341 TMIN should be signed and nonpositive.
342 TMAX should be positive, and should be signed unless TMIN is zero. */
343#define _GL_INT_ADD_RANGE_OVERFLOW(a, b, tmin, tmax) \
344 ((b) < 0 \
345 ? (((tmin) \
346 ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, (tmin) - (b))) || (b) < (tmin)) \
347 && (a) < (tmin) - (b)) \
348 : (a) <= -1 - (b)) \
349 || ((_GL_EXPR_SIGNED (a) ? 0 <= (a) : (tmax) < (a)) && (tmax) < (a) + (b))) \
350 : (a) < 0 \
351 ? (((tmin) \
352 ? ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (b, (tmin) - (a))) || (a) < (tmin)) \
353 && (b) < (tmin) - (a)) \
354 : (b) <= -1 - (a)) \
355 || ((_GL_EXPR_SIGNED (_GL_INT_CONVERT (a, b)) || (tmax) < (b)) \
356 && (tmax) < (a) + (b))) \
357 : (tmax) < (b) || (tmax) - (b) < (a))
358#define _GL_INT_SUBTRACT_RANGE_OVERFLOW(a, b, tmin, tmax) \
359 (((a) < 0) == ((b) < 0) \
360 ? ((a) < (b) \
361 ? !(tmin) || -1 - (tmin) < (b) - (a) - 1 \
362 : (tmax) < (a) - (b)) \
363 : (a) < 0 \
364 ? ((!_GL_EXPR_SIGNED (_GL_INT_CONVERT ((a) - (tmin), b)) && (a) - (tmin) < 0) \
365 || (a) - (tmin) < (b)) \
366 : ((! (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
367 && _GL_EXPR_SIGNED (_GL_INT_CONVERT ((tmax) + (b), a))) \
368 && (tmax) <= -1 - (b)) \
369 || (tmax) + (b) < (a)))
370#define _GL_INT_MULTIPLY_RANGE_OVERFLOW(a, b, tmin, tmax) \
371 ((b) < 0 \
372 ? ((a) < 0 \
373 ? (_GL_EXPR_SIGNED (_GL_INT_CONVERT (tmax, b)) \
374 ? (a) < (tmax) / (b) \
375 : ((_GL_INT_NEGATE_OVERFLOW (b) \
376 ? _GL_INT_CONVERT (b, tmax) >> (_GL_TYPE_WIDTH (+ (b)) - 1) \
377 : (tmax) / -(b)) \
378 <= -1 - (a))) \
379 : _GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (b, tmin)) && (b) == -1 \
380 ? (_GL_EXPR_SIGNED (a) \
381 ? 0 < (a) + (tmin) \
382 : 0 < (a) && -1 - (tmin) < (a) - 1) \
383 : (tmin) / (b) < (a)) \
384 : (b) == 0 \
385 ? 0 \
386 : ((a) < 0 \
387 ? (_GL_INT_NEGATE_OVERFLOW (_GL_INT_CONVERT (a, tmin)) && (a) == -1 \
388 ? (_GL_EXPR_SIGNED (b) ? 0 < (b) + (tmin) : -1 - (tmin) < (b) - 1) \
389 : (tmin) / (a) < (b)) \
390 : (tmax) / (b) < (a)))
391
392#endif /* _GL_INTPROPS_INTERNAL_H */
diff --git a/gl/intprops.h b/gl/intprops.h
index f57f9b4..44b5e60 100644
--- a/gl/intprops.h
+++ b/gl/intprops.h
@@ -1,34 +1,24 @@
1/* intprops.h -- properties of integer types 1/* intprops.h -- properties of integer types
2 2
3 Copyright (C) 2001-2005, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2001-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published by 6 under the terms of the GNU Lesser General Public License as published
7 the Free Software Foundation; either version 3 of the License, or 7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19 17
20#ifndef _GL_INTPROPS_H 18#ifndef _GL_INTPROPS_H
21#define _GL_INTPROPS_H 19#define _GL_INTPROPS_H
22 20
23#include <limits.h> 21#include "intprops-internal.h"
24
25/* Return an integer value, converted to the same type as the integer
26 expression E after integer type promotion. V is the unconverted value. */
27#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
28
29/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
30 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
31#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
32 22
33/* The extra casts in the following macros work around compiler bugs, 23/* The extra casts in the following macros work around compiler bugs,
34 e.g., in Cray C 5.0.3.0. */ 24 e.g., in Cray C 5.0.3.0. */
@@ -37,72 +27,27 @@
37 an integer. */ 27 an integer. */
38#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) 28#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
39 29
40/* True if negative values of the signed integer type T use two's 30/* True if the real type T is signed. */
41 complement, ones' complement, or signed magnitude representation, 31#define TYPE_SIGNED(t) _GL_TYPE_SIGNED (t)
42 respectively. Much GNU code assumes two's complement, but some
43 people like to be portable to all possible C hosts. */
44#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
45#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
46#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
47 32
48/* True if the signed integer expression E uses two's complement. */ 33/* Return 1 if the real expression E, after promotion, has a
49#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1) 34 signed or floating type. Do not evaluate E. */
35#define EXPR_SIGNED(e) _GL_EXPR_SIGNED (e)
50 36
51/* True if the arithmetic type T is signed. */
52#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
53 37
54/* Return 1 if the integer expression E, after integer promotion, has 38/* Minimum and maximum values for integer types and expressions. */
55 a signed type. */
56#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
57 39
58 40/* The width in bits of the integer type or expression T.
59/* Minimum and maximum values for integer types and expressions. These 41 Do not evaluate T. T must not be a bit-field expression.
60 macros have undefined behavior if T is signed and has padding bits. 42 Padding bits are not supported; this is checked at compile-time below. */
61 If this is a problem for you, please let us know how to fix it for 43#define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t)
62 your host. */
63 44
64/* The maximum and minimum values for the integer type T. */ 45/* The maximum and minimum values for the integer type T. */
65#define TYPE_MINIMUM(t) \ 46#define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
66 ((t) (! TYPE_SIGNED (t) \
67 ? (t) 0 \
68 : TYPE_SIGNED_MAGNITUDE (t) \
69 ? ~ (t) 0 \
70 : ~ TYPE_MAXIMUM (t)))
71#define TYPE_MAXIMUM(t) \ 47#define TYPE_MAXIMUM(t) \
72 ((t) (! TYPE_SIGNED (t) \ 48 ((t) (! TYPE_SIGNED (t) \
73 ? (t) -1 \ 49 ? (t) -1 \
74 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) 50 : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
75
76/* The maximum and minimum values for the type of the expression E,
77 after integer promotion. E should not have side effects. */
78#define _GL_INT_MINIMUM(e) \
79 (_GL_INT_SIGNED (e) \
80 ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
81 : _GL_INT_CONVERT (e, 0))
82#define _GL_INT_MAXIMUM(e) \
83 (_GL_INT_SIGNED (e) \
84 ? _GL_SIGNED_INT_MAXIMUM (e) \
85 : _GL_INT_NEGATE_CONVERT (e, 1))
86#define _GL_SIGNED_INT_MAXIMUM(e) \
87 (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
88
89
90/* Return 1 if the __typeof__ keyword works. This could be done by
91 'configure', but for now it's easier to do it by hand. */
92#if 2 <= __GNUC__ || defined __IBM__TYPEOF__ || 0x5110 <= __SUNPRO_C
93# define _GL_HAVE___TYPEOF__ 1
94#else
95# define _GL_HAVE___TYPEOF__ 0
96#endif
97
98/* Return 1 if the integer type or expression T might be signed. Return 0
99 if it is definitely unsigned. This macro does not evaluate its argument,
100 and expands to an integer constant expression. */
101#if _GL_HAVE___TYPEOF__
102# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
103#else
104# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
105#endif
106 51
107/* Bound on length of the string representing an unsigned integer 52/* Bound on length of the string representing an unsigned integer
108 value representable in B bits. log10 (2.0) < 146/485. The 53 value representable in B bits. log10 (2.0) < 146/485. The
@@ -110,30 +55,31 @@
110#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) 55#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
111 56
112/* Bound on length of the string representing an integer type or expression T. 57/* Bound on length of the string representing an integer type or expression T.
58 T must not be a bit-field expression.
59
113 Subtract 1 for the sign bit if T is signed, and then add 1 more for 60 Subtract 1 for the sign bit if T is signed, and then add 1 more for
114 a minus sign if needed. 61 a minus sign if needed.
115 62
116 Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is 63 Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 1 when its argument is
117 signed, this macro may overestimate the true bound by one byte when 64 unsigned, this macro may overestimate the true bound by one byte when
118 applied to unsigned types of size 2, 4, 16, ... bytes. */ 65 applied to unsigned types of size 2, 4, 16, ... bytes. */
119#define INT_STRLEN_BOUND(t) \ 66#define INT_STRLEN_BOUND(t) \
120 (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \ 67 (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
121 - _GL_SIGNED_TYPE_OR_EXPR (t)) \
122 + _GL_SIGNED_TYPE_OR_EXPR (t)) 68 + _GL_SIGNED_TYPE_OR_EXPR (t))
123 69
124/* Bound on buffer size needed to represent an integer type or expression T, 70/* Bound on buffer size needed to represent an integer type or expression T,
125 including the terminating null. */ 71 including the terminating null. T must not be a bit-field expression. */
126#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) 72#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
127 73
128 74
129/* Range overflow checks. 75/* Range overflow checks.
130 76
131 The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C 77 The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
132 operators might not yield numerically correct answers due to 78 operators overflow arithmetically when given the same arguments.
133 arithmetic overflow. They do not rely on undefined or 79 These macros do not rely on undefined or implementation-defined behavior.
134 implementation-defined behavior. Their implementations are simple 80 Although their implementations are simple and straightforward,
135 and straightforward, but they are a bit harder to use than the 81 they are harder to use and may be less efficient than the
136 INT_<op>_OVERFLOW macros described below. 82 INT_<op>_WRAPV, INT_<op>_OK, and INT_<op>_OVERFLOW macros described below.
137 83
138 Example usage: 84 Example usage:
139 85
@@ -157,6 +103,9 @@
157 must have minimum value MIN and maximum MAX. Unsigned types should 103 must have minimum value MIN and maximum MAX. Unsigned types should
158 use a zero MIN of the proper type. 104 use a zero MIN of the proper type.
159 105
106 Because all arguments are subject to integer promotions, these
107 macros typically do not work on types narrower than 'int'.
108
160 These macros are tuned for constant MIN and MAX. For commutative 109 These macros are tuned for constant MIN and MAX. For commutative
161 operations such as A + B, they are also tuned for constant B. */ 110 operations such as A + B, they are also tuned for constant B. */
162 111
@@ -177,14 +126,12 @@
177/* Return 1 if - A would overflow in [MIN,MAX] arithmetic. 126/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
178 See above for restrictions. */ 127 See above for restrictions. */
179#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \ 128#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
180 ((min) < 0 \ 129 _GL_INT_NEGATE_RANGE_OVERFLOW (a, min, max)
181 ? (a) < - (max) \
182 : 0 < (a))
183 130
184/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. 131/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
185 See above for restrictions. Avoid && and || as they tickle 132 See above for restrictions. Avoid && and || as they tickle
186 bugs in Sun C 5.11 2010/08/13 and other compilers; see 133 bugs in Sun C 5.11 2010/08/13 and other compilers; see
187 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */ 134 <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */
188#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ 135#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
189 ((b) < 0 \ 136 ((b) < 0 \
190 ? ((a) < 0 \ 137 ? ((a) < 0 \
@@ -223,24 +170,32 @@
223 ? (a) < (min) >> (b) \ 170 ? (a) < (min) >> (b) \
224 : (max) >> (b) < (a)) 171 : (max) >> (b) < (a))
225 172
226
227/* The _GL*_OVERFLOW macros have the same restrictions as the 173/* The _GL*_OVERFLOW macros have the same restrictions as the
228 *_RANGE_OVERFLOW macros, except that they do not assume that operands 174 *_RANGE_OVERFLOW macros, except that they do not assume that operands
229 (e.g., A and B) have the same type as MIN and MAX. Instead, they assume 175 (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
230 that the result (e.g., A + B) has that type. */ 176 that the result (e.g., A + B) has that type. */
231#define _GL_ADD_OVERFLOW(a, b, min, max) \ 177#if _GL_HAS_BUILTIN_OVERFLOW_P
232 ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \ 178# define _GL_ADD_OVERFLOW(a, b, min, max) \
233 : (a) < 0 ? (b) <= (a) + (b) \ 179 __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
234 : (b) < 0 ? (a) <= (a) + (b) \ 180# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
235 : (a) + (b) < (b)) 181 __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
236#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \ 182# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
237 ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \ 183 __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
238 : (a) < 0 ? 1 \ 184#else
239 : (b) < 0 ? (a) - (b) <= (a) \ 185# define _GL_ADD_OVERFLOW(a, b, min, max) \
240 : (a) < (b)) 186 ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
241#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \ 187 : (a) < 0 ? (b) <= (a) + (b) \
242 (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ 188 : (b) < 0 ? (a) <= (a) + (b) \
243 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) 189 : (a) + (b) < (b))
190# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
191 ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
192 : (a) < 0 ? 1 \
193 : (b) < 0 ? (a) - (b) <= (a) \
194 : (a) < (b))
195# define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
196 (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
197 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
198#endif
244#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ 199#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
245 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ 200 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
246 : (a) < 0 ? (b) <= (a) + (b) - 1 \ 201 : (a) < 0 ? (b) <= (a) + (b) - 1 \
@@ -262,22 +217,31 @@
262 : (a) % - (b)) \ 217 : (a) % - (b)) \
263 == 0) 218 == 0)
264 219
265 220/* Check for integer overflow, and report low order bits of answer.
266/* Integer overflow checks.
267 221
268 The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators 222 The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
269 might not yield numerically correct answers due to arithmetic overflow. 223 might not yield numerically correct answers due to arithmetic overflow.
270 They work correctly on all known practical hosts, and do not rely 224 The INT_<op>_WRAPV macros compute the low-order bits of the sum,
225 difference, and product of two C integers, and return 1 if these
226 low-order bits are not numerically correct.
227 These macros work correctly on all known practical hosts, and do not rely
271 on undefined behavior due to signed arithmetic overflow. 228 on undefined behavior due to signed arithmetic overflow.
272 229
273 Example usage: 230 Example usage, assuming A and B are long int:
274 231
275 long int i = ...; 232 if (INT_MULTIPLY_OVERFLOW (a, b))
276 long int j = ...; 233 printf ("result would overflow\n");
277 if (INT_MULTIPLY_OVERFLOW (i, j))
278 printf ("multiply would overflow");
279 else 234 else
280 printf ("product is %ld", i * j); 235 printf ("result is %ld (no overflow)\n", a * b);
236
237 Example usage with WRAPV flavor:
238
239 long int result;
240 bool overflow = INT_MULTIPLY_WRAPV (a, b, &result);
241 printf ("result is %ld (%s)\n", result,
242 overflow ? "after overflow" : "no overflow");
243
244 Restrictions on these macros:
281 245
282 These macros do not check for all possible numerical problems or 246 These macros do not check for all possible numerical problems or
283 undefined or unspecified behavior: they do not check for division 247 undefined or unspecified behavior: they do not check for division
@@ -286,7 +250,23 @@
286 These macros may evaluate their arguments zero or multiple times, so the 250 These macros may evaluate their arguments zero or multiple times, so the
287 arguments should not have side effects. 251 arguments should not have side effects.
288 252
289 These macros are tuned for their last argument being a constant. 253 The WRAPV macros are not constant expressions. They support only
254 +, binary -, and *.
255
256 Because the WRAPV macros convert the result, they report overflow
257 in different circumstances than the OVERFLOW macros do. For
258 example, in the typical case with 16-bit 'short' and 32-bit 'int',
259 if A, B and *R are all of type 'short' then INT_ADD_OVERFLOW (A, B)
260 returns false because the addition cannot overflow after A and B
261 are converted to 'int', whereas INT_ADD_WRAPV (A, B, R) returns
262 true or false depending on whether the sum fits into 'short'.
263
264 These macros are tuned for their last input argument being a constant.
265
266 A, B, and *R should be integers; they need not be the same type,
267 and they need not be all signed or all unsigned.
268 However, none of the integer types should be bit-precise,
269 and *R's type should not be char, bool, or an enumeration type.
290 270
291 Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B, 271 Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
292 A % B, and A << B would overflow, respectively. */ 272 A % B, and A << B would overflow, respectively. */
@@ -295,8 +275,7 @@
295 _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW) 275 _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
296#define INT_SUBTRACT_OVERFLOW(a, b) \ 276#define INT_SUBTRACT_OVERFLOW(a, b) \
297 _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW) 277 _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
298#define INT_NEGATE_OVERFLOW(a) \ 278#define INT_NEGATE_OVERFLOW(a) _GL_INT_NEGATE_OVERFLOW (a)
299 INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
300#define INT_MULTIPLY_OVERFLOW(a, b) \ 279#define INT_MULTIPLY_OVERFLOW(a, b) \
301 _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW) 280 _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
302#define INT_DIVIDE_OVERFLOW(a, b) \ 281#define INT_DIVIDE_OVERFLOW(a, b) \
@@ -313,7 +292,44 @@
313 Arguments should be free of side effects. */ 292 Arguments should be free of side effects. */
314#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ 293#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
315 op_result_overflow (a, b, \ 294 op_result_overflow (a, b, \
316 _GL_INT_MINIMUM (0 * (b) + (a)), \ 295 _GL_INT_MINIMUM (_GL_INT_CONVERT (a, b)), \
317 _GL_INT_MAXIMUM (0 * (b) + (a))) 296 _GL_INT_MAXIMUM (_GL_INT_CONVERT (a, b)))
297
298/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
299 Return 1 if the result overflows. See above for restrictions. */
300#define INT_ADD_WRAPV(a, b, r) _GL_INT_ADD_WRAPV (a, b, r)
301#define INT_SUBTRACT_WRAPV(a, b, r) _GL_INT_SUBTRACT_WRAPV (a, b, r)
302#define INT_MULTIPLY_WRAPV(a, b, r) _GL_INT_MULTIPLY_WRAPV (a, b, r)
303
304/* The following macros compute A + B, A - B, and A * B, respectively.
305 If no overflow occurs, they set *R to the result and return 1;
306 otherwise, they return 0 and may modify *R.
307
308 Example usage:
309
310 long int result;
311 if (INT_ADD_OK (a, b, &result))
312 printf ("result is %ld\n", result);
313 else
314 printf ("overflow\n");
315
316 A, B, and *R should be integers; they need not be the same type,
317 and they need not be all signed or all unsigned.
318 However, none of the integer types should be bit-precise,
319 and *R's type should not be char, bool, or an enumeration type.
320
321 These macros work correctly on all known practical hosts, and do not rely
322 on undefined behavior due to signed arithmetic overflow.
323
324 These macros are not constant expressions.
325
326 These macros may evaluate their arguments zero or multiple times, so the
327 arguments should not have side effects.
328
329 These macros are tuned for B being a constant. */
330
331#define INT_ADD_OK(a, b, r) (! INT_ADD_WRAPV (a, b, r))
332#define INT_SUBTRACT_OK(a, b, r) (! INT_SUBTRACT_WRAPV (a, b, r))
333#define INT_MULTIPLY_OK(a, b, r) (! INT_MULTIPLY_WRAPV (a, b, r))
318 334
319#endif /* _GL_INTPROPS_H */ 335#endif /* _GL_INTPROPS_H */
diff --git a/gl/inttypes.in.h b/gl/inttypes.in.h
new file mode 100644
index 0000000..50a2bbf
--- /dev/null
+++ b/gl/inttypes.in.h
@@ -0,0 +1,1002 @@
1/* Copyright (C) 2006-2023 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Derek Price.
3 This file is part of gnulib.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C 99 <inttypes.h> for platforms that lack it.
20 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html>
21 */
22
23#if __GNUC__ >= 3
24@PRAGMA_SYSTEM_HEADER@
25#endif
26@PRAGMA_COLUMNS@
27
28/* Include the original <inttypes.h> if it exists, and if this file
29 has not been included yet or if this file includes gnulib stdint.h
30 which in turn includes this file.
31 The include_next requires a split double-inclusion guard. */
32#if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
33# if @HAVE_INTTYPES_H@
34
35 /* Some pre-C++11 <stdint.h> implementations need this. */
36# if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
37# define __STDC_FORMAT_MACROS 1
38# endif
39
40# @INCLUDE_NEXT@ @NEXT_INTTYPES_H@
41
42# define _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H
43# endif
44#endif
45
46#if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
47#define INTTYPES_H
48
49/* Include <stdint.h> or the gnulib replacement.
50 But avoid namespace pollution on glibc systems. */
51#ifndef __GLIBC__
52# include <stdint.h>
53#endif
54/* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */
55#include <limits.h>
56/* On mingw, __USE_MINGW_ANSI_STDIO only works if <stdio.h> is also included */
57#if defined _WIN32 && ! defined __CYGWIN__
58# include <stdio.h>
59#endif
60
61#if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1)
62# error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to <bug-gnulib@gnu.org>."
63#endif
64
65/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
66
67/* The definition of _GL_ARG_NONNULL is copied here. */
68
69/* The definition of _GL_WARN_ON_USE is copied here. */
70
71/* 7.8.1 Macros for format specifiers */
72
73#if defined _TNS_R_TARGET
74 /* Tandem NonStop R series and compatible platforms released before
75 July 2005 support %Ld but not %lld. */
76# define _LONG_LONG_FORMAT_PREFIX "L"
77#else
78# define _LONG_LONG_FORMAT_PREFIX "ll"
79#endif
80
81#if !defined PRId8
82# ifdef INT8_MAX
83# define PRId8 "d"
84# endif
85#endif
86#if !defined PRIi8
87# ifdef INT8_MAX
88# define PRIi8 "i"
89# endif
90#endif
91#if !defined PRIo8
92# ifdef UINT8_MAX
93# define PRIo8 "o"
94# endif
95#endif
96#if !defined PRIu8
97# ifdef UINT8_MAX
98# define PRIu8 "u"
99# endif
100#endif
101#if !defined PRIx8
102# ifdef UINT8_MAX
103# define PRIx8 "x"
104# endif
105#endif
106#if !defined PRIX8
107# ifdef UINT8_MAX
108# define PRIX8 "X"
109# endif
110#endif
111#if !defined PRId16
112# ifdef INT16_MAX
113# define PRId16 "d"
114# endif
115#endif
116#if !defined PRIi16
117# ifdef INT16_MAX
118# define PRIi16 "i"
119# endif
120#endif
121#if !defined PRIo16
122# ifdef UINT16_MAX
123# define PRIo16 "o"
124# endif
125#endif
126#if !defined PRIu16
127# ifdef UINT16_MAX
128# define PRIu16 "u"
129# endif
130#endif
131#if !defined PRIx16
132# ifdef UINT16_MAX
133# define PRIx16 "x"
134# endif
135#endif
136#if !defined PRIX16
137# ifdef UINT16_MAX
138# define PRIX16 "X"
139# endif
140#endif
141#if !defined PRId32
142# ifdef INT32_MAX
143# define PRId32 "d"
144# endif
145#endif
146#if !defined PRIi32
147# ifdef INT32_MAX
148# define PRIi32 "i"
149# endif
150#endif
151#if !defined PRIo32
152# ifdef UINT32_MAX
153# define PRIo32 "o"
154# endif
155#endif
156#if !defined PRIu32
157# ifdef UINT32_MAX
158# define PRIu32 "u"
159# endif
160#endif
161#if !defined PRIx32
162# ifdef UINT32_MAX
163# define PRIx32 "x"
164# endif
165#endif
166#if !defined PRIX32
167# ifdef UINT32_MAX
168# define PRIX32 "X"
169# endif
170#endif
171#ifdef INT64_MAX
172# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
173# define _PRI64_PREFIX "l"
174# elif defined _MSC_VER || defined __MINGW32__
175# define _PRI64_PREFIX "I64"
176# elif LONG_MAX >> 30 == 1
177# define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
178# endif
179# if !defined PRId64
180# define PRId64 _PRI64_PREFIX "d"
181# endif
182# if !defined PRIi64
183# define PRIi64 _PRI64_PREFIX "i"
184# endif
185#endif
186#ifdef UINT64_MAX
187# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
188# define _PRIu64_PREFIX "l"
189# elif defined _MSC_VER || defined __MINGW32__
190# define _PRIu64_PREFIX "I64"
191# elif ULONG_MAX >> 31 == 1
192# define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
193# endif
194# if !defined PRIo64
195# define PRIo64 _PRIu64_PREFIX "o"
196# endif
197# if !defined PRIu64
198# define PRIu64 _PRIu64_PREFIX "u"
199# endif
200# if !defined PRIx64
201# define PRIx64 _PRIu64_PREFIX "x"
202# endif
203# if !defined PRIX64
204# define PRIX64 _PRIu64_PREFIX "X"
205# endif
206#endif
207
208#if !defined PRIdLEAST8
209# define PRIdLEAST8 "d"
210#endif
211#if !defined PRIiLEAST8
212# define PRIiLEAST8 "i"
213#endif
214#if !defined PRIoLEAST8
215# define PRIoLEAST8 "o"
216#endif
217#if !defined PRIuLEAST8
218# define PRIuLEAST8 "u"
219#endif
220#if !defined PRIxLEAST8
221# define PRIxLEAST8 "x"
222#endif
223#if !defined PRIXLEAST8
224# define PRIXLEAST8 "X"
225#endif
226#if !defined PRIdLEAST16
227# define PRIdLEAST16 "d"
228#endif
229#if !defined PRIiLEAST16
230# define PRIiLEAST16 "i"
231#endif
232#if !defined PRIoLEAST16
233# define PRIoLEAST16 "o"
234#endif
235#if !defined PRIuLEAST16
236# define PRIuLEAST16 "u"
237#endif
238#if !defined PRIxLEAST16
239# define PRIxLEAST16 "x"
240#endif
241#if !defined PRIXLEAST16
242# define PRIXLEAST16 "X"
243#endif
244#if !defined PRIdLEAST32
245# define PRIdLEAST32 "d"
246#endif
247#if !defined PRIiLEAST32
248# define PRIiLEAST32 "i"
249#endif
250#if !defined PRIoLEAST32
251# define PRIoLEAST32 "o"
252#endif
253#if !defined PRIuLEAST32
254# define PRIuLEAST32 "u"
255#endif
256#if !defined PRIxLEAST32
257# define PRIxLEAST32 "x"
258#endif
259#if !defined PRIXLEAST32
260# define PRIXLEAST32 "X"
261#endif
262#ifdef INT64_MAX
263# if !defined PRIdLEAST64
264# define PRIdLEAST64 PRId64
265# endif
266# if !defined PRIiLEAST64
267# define PRIiLEAST64 PRIi64
268# endif
269#endif
270#ifdef UINT64_MAX
271# if !defined PRIoLEAST64
272# define PRIoLEAST64 PRIo64
273# endif
274# if !defined PRIuLEAST64
275# define PRIuLEAST64 PRIu64
276# endif
277# if !defined PRIxLEAST64
278# define PRIxLEAST64 PRIx64
279# endif
280# if !defined PRIXLEAST64
281# define PRIXLEAST64 PRIX64
282# endif
283#endif
284
285#if !defined PRIdFAST8
286# if INT_FAST8_MAX > INT32_MAX
287# define PRIdFAST8 PRId64
288# else
289# define PRIdFAST8 "d"
290# endif
291#endif
292#if !defined PRIiFAST8
293# if INT_FAST8_MAX > INT32_MAX
294# define PRIiFAST8 PRIi64
295# else
296# define PRIiFAST8 "i"
297# endif
298#endif
299#if !defined PRIoFAST8
300# if UINT_FAST8_MAX > UINT32_MAX
301# define PRIoFAST8 PRIo64
302# else
303# define PRIoFAST8 "o"
304# endif
305#endif
306#if !defined PRIuFAST8
307# if UINT_FAST8_MAX > UINT32_MAX
308# define PRIuFAST8 PRIu64
309# else
310# define PRIuFAST8 "u"
311# endif
312#endif
313#if !defined PRIxFAST8
314# if UINT_FAST8_MAX > UINT32_MAX
315# define PRIxFAST8 PRIx64
316# else
317# define PRIxFAST8 "x"
318# endif
319#endif
320#if !defined PRIXFAST8
321# if UINT_FAST8_MAX > UINT32_MAX
322# define PRIXFAST8 PRIX64
323# else
324# define PRIXFAST8 "X"
325# endif
326#endif
327#if !defined PRIdFAST16
328# if INT_FAST16_MAX > INT32_MAX
329# define PRIdFAST16 PRId64
330# else
331# define PRIdFAST16 "d"
332# endif
333#endif
334#if !defined PRIiFAST16
335# if INT_FAST16_MAX > INT32_MAX
336# define PRIiFAST16 PRIi64
337# else
338# define PRIiFAST16 "i"
339# endif
340#endif
341#if !defined PRIoFAST16
342# if UINT_FAST16_MAX > UINT32_MAX
343# define PRIoFAST16 PRIo64
344# else
345# define PRIoFAST16 "o"
346# endif
347#endif
348#if !defined PRIuFAST16
349# if UINT_FAST16_MAX > UINT32_MAX
350# define PRIuFAST16 PRIu64
351# else
352# define PRIuFAST16 "u"
353# endif
354#endif
355#if !defined PRIxFAST16
356# if UINT_FAST16_MAX > UINT32_MAX
357# define PRIxFAST16 PRIx64
358# else
359# define PRIxFAST16 "x"
360# endif
361#endif
362#if !defined PRIXFAST16
363# if UINT_FAST16_MAX > UINT32_MAX
364# define PRIXFAST16 PRIX64
365# else
366# define PRIXFAST16 "X"
367# endif
368#endif
369#if !defined PRIdFAST32
370# if INT_FAST32_MAX > INT32_MAX
371# define PRIdFAST32 PRId64
372# else
373# define PRIdFAST32 "d"
374# endif
375#endif
376#if !defined PRIiFAST32
377# if INT_FAST32_MAX > INT32_MAX
378# define PRIiFAST32 PRIi64
379# else
380# define PRIiFAST32 "i"
381# endif
382#endif
383#if !defined PRIoFAST32
384# if UINT_FAST32_MAX > UINT32_MAX
385# define PRIoFAST32 PRIo64
386# else
387# define PRIoFAST32 "o"
388# endif
389#endif
390#if !defined PRIuFAST32
391# if UINT_FAST32_MAX > UINT32_MAX
392# define PRIuFAST32 PRIu64
393# else
394# define PRIuFAST32 "u"
395# endif
396#endif
397#if !defined PRIxFAST32
398# if UINT_FAST32_MAX > UINT32_MAX
399# define PRIxFAST32 PRIx64
400# else
401# define PRIxFAST32 "x"
402# endif
403#endif
404#if !defined PRIXFAST32
405# if UINT_FAST32_MAX > UINT32_MAX
406# define PRIXFAST32 PRIX64
407# else
408# define PRIXFAST32 "X"
409# endif
410#endif
411#ifdef INT64_MAX
412# if !defined PRIdFAST64
413# define PRIdFAST64 PRId64
414# endif
415# if !defined PRIiFAST64
416# define PRIiFAST64 PRIi64
417# endif
418#endif
419#ifdef UINT64_MAX
420# if !defined PRIoFAST64
421# define PRIoFAST64 PRIo64
422# endif
423# if !defined PRIuFAST64
424# define PRIuFAST64 PRIu64
425# endif
426# if !defined PRIxFAST64
427# define PRIxFAST64 PRIx64
428# endif
429# if !defined PRIXFAST64
430# define PRIXFAST64 PRIX64
431# endif
432#endif
433
434#if !defined PRIdMAX
435# if @INT32_MAX_LT_INTMAX_MAX@
436# define PRIdMAX PRId64
437# else
438# define PRIdMAX "ld"
439# endif
440#endif
441#if !defined PRIiMAX
442# if @INT32_MAX_LT_INTMAX_MAX@
443# define PRIiMAX PRIi64
444# else
445# define PRIiMAX "li"
446# endif
447#endif
448#if !defined PRIoMAX
449# if @UINT32_MAX_LT_UINTMAX_MAX@
450# define PRIoMAX PRIo64
451# else
452# define PRIoMAX "lo"
453# endif
454#endif
455#if !defined PRIuMAX
456# if @UINT32_MAX_LT_UINTMAX_MAX@
457# define PRIuMAX PRIu64
458# else
459# define PRIuMAX "lu"
460# endif
461#endif
462#if !defined PRIxMAX
463# if @UINT32_MAX_LT_UINTMAX_MAX@
464# define PRIxMAX PRIx64
465# else
466# define PRIxMAX "lx"
467# endif
468#endif
469#if !defined PRIXMAX
470# if @UINT32_MAX_LT_UINTMAX_MAX@
471# define PRIXMAX PRIX64
472# else
473# define PRIXMAX "lX"
474# endif
475#endif
476
477#if !defined PRIdPTR
478# ifdef INTPTR_MAX
479# define PRIdPTR @PRIPTR_PREFIX@ "d"
480# endif
481#endif
482#if !defined PRIiPTR
483# ifdef INTPTR_MAX
484# define PRIiPTR @PRIPTR_PREFIX@ "i"
485# endif
486#endif
487#if !defined PRIoPTR
488# ifdef UINTPTR_MAX
489# define PRIoPTR @PRIPTR_PREFIX@ "o"
490# endif
491#endif
492#if !defined PRIuPTR
493# ifdef UINTPTR_MAX
494# define PRIuPTR @PRIPTR_PREFIX@ "u"
495# endif
496#endif
497#if !defined PRIxPTR
498# ifdef UINTPTR_MAX
499# define PRIxPTR @PRIPTR_PREFIX@ "x"
500# endif
501#endif
502#if !defined PRIXPTR
503# ifdef UINTPTR_MAX
504# define PRIXPTR @PRIPTR_PREFIX@ "X"
505# endif
506#endif
507
508#if !defined SCNd8
509# ifdef INT8_MAX
510# define SCNd8 "hhd"
511# endif
512#endif
513#if !defined SCNi8
514# ifdef INT8_MAX
515# define SCNi8 "hhi"
516# endif
517#endif
518#if !defined SCNo8
519# ifdef UINT8_MAX
520# define SCNo8 "hho"
521# endif
522#endif
523#if !defined SCNu8
524# ifdef UINT8_MAX
525# define SCNu8 "hhu"
526# endif
527#endif
528#if !defined SCNx8
529# ifdef UINT8_MAX
530# define SCNx8 "hhx"
531# endif
532#endif
533#if !defined SCNd16
534# ifdef INT16_MAX
535# define SCNd16 "hd"
536# endif
537#endif
538#if !defined SCNi16
539# ifdef INT16_MAX
540# define SCNi16 "hi"
541# endif
542#endif
543#if !defined SCNo16
544# ifdef UINT16_MAX
545# define SCNo16 "ho"
546# endif
547#endif
548#if !defined SCNu16
549# ifdef UINT16_MAX
550# define SCNu16 "hu"
551# endif
552#endif
553#if !defined SCNx16
554# ifdef UINT16_MAX
555# define SCNx16 "hx"
556# endif
557#endif
558#if !defined SCNd32
559# ifdef INT32_MAX
560# define SCNd32 "d"
561# endif
562#endif
563#if !defined SCNi32
564# ifdef INT32_MAX
565# define SCNi32 "i"
566# endif
567#endif
568#if !defined SCNo32
569# ifdef UINT32_MAX
570# define SCNo32 "o"
571# endif
572#endif
573#if !defined SCNu32
574# ifdef UINT32_MAX
575# define SCNu32 "u"
576# endif
577#endif
578#if !defined SCNx32
579# ifdef UINT32_MAX
580# define SCNx32 "x"
581# endif
582#endif
583#ifdef INT64_MAX
584# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@)
585# define _SCN64_PREFIX "l"
586# elif defined _MSC_VER || defined __MINGW32__
587# define _SCN64_PREFIX "I64"
588# elif LONG_MAX >> 30 == 1
589# define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
590# endif
591# if !defined SCNd64
592# define SCNd64 _SCN64_PREFIX "d"
593# endif
594# if !defined SCNi64
595# define SCNi64 _SCN64_PREFIX "i"
596# endif
597#endif
598#ifdef UINT64_MAX
599# if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@)
600# define _SCNu64_PREFIX "l"
601# elif defined _MSC_VER || defined __MINGW32__
602# define _SCNu64_PREFIX "I64"
603# elif ULONG_MAX >> 31 == 1
604# define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
605# endif
606# if !defined SCNo64
607# define SCNo64 _SCNu64_PREFIX "o"
608# endif
609# if !defined SCNu64
610# define SCNu64 _SCNu64_PREFIX "u"
611# endif
612# if !defined SCNx64
613# define SCNx64 _SCNu64_PREFIX "x"
614# endif
615#endif
616
617#if !defined SCNdLEAST8
618# define SCNdLEAST8 "hhd"
619#endif
620#if !defined SCNiLEAST8
621# define SCNiLEAST8 "hhi"
622#endif
623#if !defined SCNoLEAST8
624# define SCNoLEAST8 "hho"
625#endif
626#if !defined SCNuLEAST8
627# define SCNuLEAST8 "hhu"
628#endif
629#if !defined SCNxLEAST8
630# define SCNxLEAST8 "hhx"
631#endif
632#if !defined SCNdLEAST16
633# define SCNdLEAST16 "hd"
634#endif
635#if !defined SCNiLEAST16
636# define SCNiLEAST16 "hi"
637#endif
638#if !defined SCNoLEAST16
639# define SCNoLEAST16 "ho"
640#endif
641#if !defined SCNuLEAST16
642# define SCNuLEAST16 "hu"
643#endif
644#if !defined SCNxLEAST16
645# define SCNxLEAST16 "hx"
646#endif
647#if !defined SCNdLEAST32
648# define SCNdLEAST32 "d"
649#endif
650#if !defined SCNiLEAST32
651# define SCNiLEAST32 "i"
652#endif
653#if !defined SCNoLEAST32
654# define SCNoLEAST32 "o"
655#endif
656#if !defined SCNuLEAST32
657# define SCNuLEAST32 "u"
658#endif
659#if !defined SCNxLEAST32
660# define SCNxLEAST32 "x"
661#endif
662#ifdef INT64_MAX
663# if !defined SCNdLEAST64
664# define SCNdLEAST64 SCNd64
665# endif
666# if !defined SCNiLEAST64
667# define SCNiLEAST64 SCNi64
668# endif
669#endif
670#ifdef UINT64_MAX
671# if !defined SCNoLEAST64
672# define SCNoLEAST64 SCNo64
673# endif
674# if !defined SCNuLEAST64
675# define SCNuLEAST64 SCNu64
676# endif
677# if !defined SCNxLEAST64
678# define SCNxLEAST64 SCNx64
679# endif
680#endif
681
682#if !defined SCNdFAST8
683# if INT_FAST8_MAX > INT32_MAX
684# define SCNdFAST8 SCNd64
685# elif INT_FAST8_MAX == 0x7fff
686# define SCNdFAST8 "hd"
687# elif INT_FAST8_MAX == 0x7f
688# define SCNdFAST8 "hhd"
689# else
690# define SCNdFAST8 "d"
691# endif
692#endif
693#if !defined SCNiFAST8
694# if INT_FAST8_MAX > INT32_MAX
695# define SCNiFAST8 SCNi64
696# elif INT_FAST8_MAX == 0x7fff
697# define SCNiFAST8 "hi"
698# elif INT_FAST8_MAX == 0x7f
699# define SCNiFAST8 "hhi"
700# else
701# define SCNiFAST8 "i"
702# endif
703#endif
704#if !defined SCNoFAST8
705# if UINT_FAST8_MAX > UINT32_MAX
706# define SCNoFAST8 SCNo64
707# elif UINT_FAST8_MAX == 0xffff
708# define SCNoFAST8 "ho"
709# elif UINT_FAST8_MAX == 0xff
710# define SCNoFAST8 "hho"
711# else
712# define SCNoFAST8 "o"
713# endif
714#endif
715#if !defined SCNuFAST8
716# if UINT_FAST8_MAX > UINT32_MAX
717# define SCNuFAST8 SCNu64
718# elif UINT_FAST8_MAX == 0xffff
719# define SCNuFAST8 "hu"
720# elif UINT_FAST8_MAX == 0xff
721# define SCNuFAST8 "hhu"
722# else
723# define SCNuFAST8 "u"
724# endif
725#endif
726#if !defined SCNxFAST8
727# if UINT_FAST8_MAX > UINT32_MAX
728# define SCNxFAST8 SCNx64
729# elif UINT_FAST8_MAX == 0xffff
730# define SCNxFAST8 "hx"
731# elif UINT_FAST8_MAX == 0xff
732# define SCNxFAST8 "hhx"
733# else
734# define SCNxFAST8 "x"
735# endif
736#endif
737#if !defined SCNdFAST16
738# if INT_FAST16_MAX > INT32_MAX
739# define SCNdFAST16 SCNd64
740# elif INT_FAST16_MAX == 0x7fff
741# define SCNdFAST16 "hd"
742# else
743# define SCNdFAST16 "d"
744# endif
745#endif
746#if !defined SCNiFAST16
747# if INT_FAST16_MAX > INT32_MAX
748# define SCNiFAST16 SCNi64
749# elif INT_FAST16_MAX == 0x7fff
750# define SCNiFAST16 "hi"
751# else
752# define SCNiFAST16 "i"
753# endif
754#endif
755#if !defined SCNoFAST16
756# if UINT_FAST16_MAX > UINT32_MAX
757# define SCNoFAST16 SCNo64
758# elif UINT_FAST16_MAX == 0xffff
759# define SCNoFAST16 "ho"
760# else
761# define SCNoFAST16 "o"
762# endif
763#endif
764#if !defined SCNuFAST16
765# if UINT_FAST16_MAX > UINT32_MAX
766# define SCNuFAST16 SCNu64
767# elif UINT_FAST16_MAX == 0xffff
768# define SCNuFAST16 "hu"
769# else
770# define SCNuFAST16 "u"
771# endif
772#endif
773#if !defined SCNxFAST16
774# if UINT_FAST16_MAX > UINT32_MAX
775# define SCNxFAST16 SCNx64
776# elif UINT_FAST16_MAX == 0xffff
777# define SCNxFAST16 "hx"
778# else
779# define SCNxFAST16 "x"
780# endif
781#endif
782#if !defined SCNdFAST32
783# if INT_FAST32_MAX > INT32_MAX
784# define SCNdFAST32 SCNd64
785# else
786# define SCNdFAST32 "d"
787# endif
788#endif
789#if !defined SCNiFAST32
790# if INT_FAST32_MAX > INT32_MAX
791# define SCNiFAST32 SCNi64
792# else
793# define SCNiFAST32 "i"
794# endif
795#endif
796#if !defined SCNoFAST32
797# if UINT_FAST32_MAX > UINT32_MAX
798# define SCNoFAST32 SCNo64
799# else
800# define SCNoFAST32 "o"
801# endif
802#endif
803#if !defined SCNuFAST32
804# if UINT_FAST32_MAX > UINT32_MAX
805# define SCNuFAST32 SCNu64
806# else
807# define SCNuFAST32 "u"
808# endif
809#endif
810#if !defined SCNxFAST32
811# if UINT_FAST32_MAX > UINT32_MAX
812# define SCNxFAST32 SCNx64
813# else
814# define SCNxFAST32 "x"
815# endif
816#endif
817#ifdef INT64_MAX
818# if !defined SCNdFAST64
819# define SCNdFAST64 SCNd64
820# endif
821# if !defined SCNiFAST64
822# define SCNiFAST64 SCNi64
823# endif
824#endif
825#ifdef UINT64_MAX
826# if !defined SCNoFAST64
827# define SCNoFAST64 SCNo64
828# endif
829# if !defined SCNuFAST64
830# define SCNuFAST64 SCNu64
831# endif
832# if !defined SCNxFAST64
833# define SCNxFAST64 SCNx64
834# endif
835#endif
836
837#if !defined SCNdMAX
838# if @INT32_MAX_LT_INTMAX_MAX@
839# define SCNdMAX SCNd64
840# else
841# define SCNdMAX "ld"
842# endif
843#endif
844#if !defined SCNiMAX
845# if @INT32_MAX_LT_INTMAX_MAX@
846# define SCNiMAX SCNi64
847# else
848# define SCNiMAX "li"
849# endif
850#endif
851#if !defined SCNoMAX
852# if @UINT32_MAX_LT_UINTMAX_MAX@
853# define SCNoMAX SCNo64
854# else
855# define SCNoMAX "lo"
856# endif
857#endif
858#if !defined SCNuMAX
859# if @UINT32_MAX_LT_UINTMAX_MAX@
860# define SCNuMAX SCNu64
861# else
862# define SCNuMAX "lu"
863# endif
864#endif
865#if !defined SCNxMAX
866# if @UINT32_MAX_LT_UINTMAX_MAX@
867# define SCNxMAX SCNx64
868# else
869# define SCNxMAX "lx"
870# endif
871#endif
872
873#if !defined SCNdPTR
874# ifdef INTPTR_MAX
875# define SCNdPTR @PRIPTR_PREFIX@ "d"
876# endif
877#endif
878#if !defined SCNiPTR
879# ifdef INTPTR_MAX
880# define SCNiPTR @PRIPTR_PREFIX@ "i"
881# endif
882#endif
883#if !defined SCNoPTR
884# ifdef UINTPTR_MAX
885# define SCNoPTR @PRIPTR_PREFIX@ "o"
886# endif
887#endif
888#if !defined SCNuPTR
889# ifdef UINTPTR_MAX
890# define SCNuPTR @PRIPTR_PREFIX@ "u"
891# endif
892#endif
893#if !defined SCNxPTR
894# ifdef UINTPTR_MAX
895# define SCNxPTR @PRIPTR_PREFIX@ "x"
896# endif
897#endif
898
899/* 7.8.2 Functions for greatest-width integer types */
900
901#ifdef __cplusplus
902extern "C" {
903#endif
904
905#if @GNULIB_IMAXABS@
906# if !@HAVE_DECL_IMAXABS@
907extern intmax_t imaxabs (intmax_t);
908# endif
909#elif defined GNULIB_POSIXCHECK
910# undef imaxabs
911# if HAVE_RAW_DECL_IMAXABS
912_GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
913 "use gnulib module imaxabs for portability");
914# endif
915#endif
916
917#if @GNULIB_IMAXDIV@
918# if !@HAVE_IMAXDIV_T@
919# if !GNULIB_defined_imaxdiv_t
920typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
921# define GNULIB_defined_imaxdiv_t 1
922# endif
923# endif
924# if !@HAVE_DECL_IMAXDIV@
925extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
926# endif
927#elif defined GNULIB_POSIXCHECK
928# undef imaxdiv
929# if HAVE_RAW_DECL_IMAXDIV
930_GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
931 "use gnulib module imaxdiv for portability");
932# endif
933#endif
934
935#if @GNULIB_STRTOIMAX@
936# if @REPLACE_STRTOIMAX@
937# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
938# undef strtoimax
939# define strtoimax rpl_strtoimax
940# endif
941_GL_FUNCDECL_RPL (strtoimax, intmax_t,
942 (const char *restrict, char **restrict, int)
943 _GL_ARG_NONNULL ((1)));
944_GL_CXXALIAS_RPL (strtoimax, intmax_t,
945 (const char *restrict, char **restrict, int));
946# else
947# if !@HAVE_DECL_STRTOIMAX@
948# undef strtoimax
949_GL_FUNCDECL_SYS (strtoimax, intmax_t,
950 (const char *restrict, char **restrict, int)
951 _GL_ARG_NONNULL ((1)));
952# endif
953_GL_CXXALIAS_SYS (strtoimax, intmax_t,
954 (const char *restrict, char **restrict, int));
955# endif
956_GL_CXXALIASWARN (strtoimax);
957#elif defined GNULIB_POSIXCHECK
958# undef strtoimax
959# if HAVE_RAW_DECL_STRTOIMAX
960_GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
961 "use gnulib module strtoimax for portability");
962# endif
963#endif
964
965#if @GNULIB_STRTOUMAX@
966# if @REPLACE_STRTOUMAX@
967# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968# undef strtoumax
969# define strtoumax rpl_strtoumax
970# endif
971_GL_FUNCDECL_RPL (strtoumax, uintmax_t,
972 (const char *restrict, char **restrict, int)
973 _GL_ARG_NONNULL ((1)));
974_GL_CXXALIAS_RPL (strtoumax, uintmax_t,
975 (const char *restrict, char **restrict, int));
976# else
977# if !@HAVE_DECL_STRTOUMAX@
978# undef strtoumax
979_GL_FUNCDECL_SYS (strtoumax, uintmax_t,
980 (const char *restrict, char **restrict, int)
981 _GL_ARG_NONNULL ((1)));
982# endif
983_GL_CXXALIAS_SYS (strtoumax, uintmax_t,
984 (const char *restrict, char **restrict, int));
985# endif
986_GL_CXXALIASWARN (strtoumax);
987#elif defined GNULIB_POSIXCHECK
988# undef strtoumax
989# if HAVE_RAW_DECL_STRTOUMAX
990_GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
991 "use gnulib module strtoumax for portability");
992# endif
993#endif
994
995/* Don't bother defining or declaring wcstoimax and wcstoumax, since
996 wide-character functions like this are hardly ever useful. */
997
998#ifdef __cplusplus
999}
1000#endif
1001
1002#endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */
diff --git a/gl/itold.c b/gl/itold.c
index 9aabc7e..0ef4464 100644
--- a/gl/itold.c
+++ b/gl/itold.c
@@ -1,19 +1,19 @@
1/* Replacement for 'int' to 'long double' conversion routine. 1/* Replacement for 'int' to 'long double' conversion routine.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/langinfo.in.h b/gl/langinfo.in.h
index 5388ce6..c7555a6 100644
--- a/gl/langinfo.in.h
+++ b/gl/langinfo.in.h
@@ -1,22 +1,22 @@
1/* Substitute for and wrapper around <langinfo.h>. 1/* Substitute for and wrapper around <langinfo.h>.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* 17/*
18 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one. 18 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
19 * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html> 19 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
20 */ 20 */
21 21
22#ifndef _@GUARD_PREFIX@_LANGINFO_H 22#ifndef _@GUARD_PREFIX@_LANGINFO_H
@@ -49,7 +49,10 @@ typedef int nl_item;
49# define CODESET 10000 49# define CODESET 10000
50/* nl_langinfo items of the LC_NUMERIC category */ 50/* nl_langinfo items of the LC_NUMERIC category */
51# define RADIXCHAR 10001 51# define RADIXCHAR 10001
52# define DECIMAL_POINT RADIXCHAR
52# define THOUSEP 10002 53# define THOUSEP 10002
54# define THOUSANDS_SEP THOUSEP
55# define GROUPING 10114
53/* nl_langinfo items of the LC_TIME category */ 56/* nl_langinfo items of the LC_TIME category */
54# define D_T_FMT 10003 57# define D_T_FMT 10003
55# define D_FMT 10004 58# define D_FMT 10004
@@ -83,6 +86,18 @@ typedef int nl_item;
83# define MON_10 (MON_1 + 9) 86# define MON_10 (MON_1 + 9)
84# define MON_11 (MON_1 + 10) 87# define MON_11 (MON_1 + 10)
85# define MON_12 (MON_1 + 11) 88# define MON_12 (MON_1 + 11)
89# define ALTMON_1 10200
90# define ALTMON_2 (ALTMON_1 + 1)
91# define ALTMON_3 (ALTMON_1 + 2)
92# define ALTMON_4 (ALTMON_1 + 3)
93# define ALTMON_5 (ALTMON_1 + 4)
94# define ALTMON_6 (ALTMON_1 + 5)
95# define ALTMON_7 (ALTMON_1 + 6)
96# define ALTMON_8 (ALTMON_1 + 7)
97# define ALTMON_9 (ALTMON_1 + 8)
98# define ALTMON_10 (ALTMON_1 + 9)
99# define ALTMON_11 (ALTMON_1 + 10)
100# define ALTMON_12 (ALTMON_1 + 11)
86# define ABMON_1 10035 101# define ABMON_1 10035
87# define ABMON_2 (ABMON_1 + 1) 102# define ABMON_2 (ABMON_1 + 1)
88# define ABMON_3 (ABMON_1 + 2) 103# define ABMON_3 (ABMON_1 + 2)
@@ -102,6 +117,21 @@ typedef int nl_item;
102# define ALT_DIGITS 10051 117# define ALT_DIGITS 10051
103/* nl_langinfo items of the LC_MONETARY category */ 118/* nl_langinfo items of the LC_MONETARY category */
104# define CRNCYSTR 10052 119# define CRNCYSTR 10052
120# define CURRENCY_SYMBOL CRNCYSTR
121# define INT_CURR_SYMBOL 10100
122# define MON_DECIMAL_POINT 10101
123# define MON_THOUSANDS_SEP 10102
124# define MON_GROUPING 10103
125# define POSITIVE_SIGN 10104
126# define NEGATIVE_SIGN 10105
127# define FRAC_DIGITS 10106
128# define INT_FRAC_DIGITS 10107
129# define P_CS_PRECEDES 10108
130# define N_CS_PRECEDES 10109
131# define P_SEP_BY_SPACE 10110
132# define N_SEP_BY_SPACE 10111
133# define P_SIGN_POSN 10112
134# define N_SIGN_POSN 10113
105/* nl_langinfo items of the LC_MESSAGES category */ 135/* nl_langinfo items of the LC_MESSAGES category */
106# define YESEXPR 10053 136# define YESEXPR 10053
107# define NOEXPR 10054 137# define NOEXPR 10054
@@ -120,6 +150,22 @@ typedef int nl_item;
120# define GNULIB_defined_T_FMT_AMPM 1 150# define GNULIB_defined_T_FMT_AMPM 1
121# endif 151# endif
122 152
153# if !@HAVE_LANGINFO_ALTMON@
154# define ALTMON_1 10200
155# define ALTMON_2 (ALTMON_1 + 1)
156# define ALTMON_3 (ALTMON_1 + 2)
157# define ALTMON_4 (ALTMON_1 + 3)
158# define ALTMON_5 (ALTMON_1 + 4)
159# define ALTMON_6 (ALTMON_1 + 5)
160# define ALTMON_7 (ALTMON_1 + 6)
161# define ALTMON_8 (ALTMON_1 + 7)
162# define ALTMON_9 (ALTMON_1 + 8)
163# define ALTMON_10 (ALTMON_1 + 9)
164# define ALTMON_11 (ALTMON_1 + 10)
165# define ALTMON_12 (ALTMON_1 + 11)
166# define GNULIB_defined_ALTMON 1
167# endif
168
123# if !@HAVE_LANGINFO_ERA@ 169# if !@HAVE_LANGINFO_ERA@
124# define ERA 10047 170# define ERA 10047
125# define ERA_D_FMT 10048 171# define ERA_D_FMT 10048
diff --git a/gl/lc-charset-dispatch.c b/gl/lc-charset-dispatch.c
new file mode 100644
index 0000000..cd74466
--- /dev/null
+++ b/gl/lc-charset-dispatch.c
@@ -0,0 +1,82 @@
1/* Dispatching based on the current locale's character encoding.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2018. */
18
19#include <config.h>
20
21/* Specification. */
22#include "lc-charset-dispatch.h"
23
24#if GNULIB_defined_mbstate_t
25
26# include "localcharset.h"
27# include "streq.h"
28
29# if GNULIB_WCHAR_SINGLE_LOCALE
30/* When we know that the locale does not change, provide a speedup by
31 caching the value of locale_encoding_classification. */
32# define locale_encoding_classification_cached locale_encoding_classification
33# else
34/* By default, don't make assumptions, hence no caching. */
35# define locale_encoding_classification_uncached locale_encoding_classification
36# endif
37
38# if GNULIB_WCHAR_SINGLE_LOCALE
39static inline
40# endif
41enc_t
42locale_encoding_classification_uncached (void)
43{
44 const char *encoding = locale_charset ();
45 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
46 return enc_utf8;
47 if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
48 return enc_eucjp;
49 if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
50 || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
51 || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
52 return enc_94;
53 if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
54 return enc_euctw;
55 if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
56 return enc_gb18030;
57 if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
58 return enc_sjis;
59 return enc_other;
60}
61
62# if GNULIB_WCHAR_SINGLE_LOCALE
63
64static int cached_locale_enc = -1;
65
66enc_t
67locale_encoding_classification_cached (void)
68{
69 if (cached_locale_enc < 0)
70 cached_locale_enc = locale_encoding_classification_uncached ();
71 return cached_locale_enc;
72}
73
74# endif
75
76#else
77
78/* This declaration is solely to ensure that after preprocessing
79 this file is never empty. */
80typedef int dummy;
81
82#endif
diff --git a/gl/lc-charset-dispatch.h b/gl/lc-charset-dispatch.h
new file mode 100644
index 0000000..c82b6a6
--- /dev/null
+++ b/gl/lc-charset-dispatch.h
@@ -0,0 +1,40 @@
1/* Dispatching based on the current locale's character encoding.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2018. */
18
19#include <wchar.h>
20
21#if GNULIB_defined_mbstate_t
22
23/* A classification of special values of the encoding of the current locale. */
24typedef enum
25 {
26 enc_other, /* other */
27 enc_utf8, /* UTF-8 */
28 enc_eucjp, /* EUC-JP */
29 enc_94, /* EUC-KR, GB2312, BIG5 */
30 enc_euctw, /* EUC-TW */
31 enc_gb18030, /* GB18030 */
32 enc_sjis /* SJIS */
33 }
34 enc_t;
35
36/* Returns a classification of special values of the encoding of the current
37 locale. */
38extern enc_t locale_encoding_classification (void);
39
40#endif
diff --git a/gl/libc-config.h b/gl/libc-config.h
new file mode 100644
index 0000000..1d28e58
--- /dev/null
+++ b/gl/libc-config.h
@@ -0,0 +1,202 @@
1/* System definitions for code taken from the GNU C Library
2
3 Copyright 2017-2023 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this program; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* Written by Paul Eggert. */
20
21/* This is intended to be a good-enough substitute for glibc system
22 macros like those defined in <sys/cdefs.h>, so that Gnulib code
23 shared with glibc can do this as the first #include:
24
25 #ifndef _LIBC
26 # include <libc-config.h>
27 #endif
28
29 When compiled as part of glibc this is a no-op; when compiled as
30 part of Gnulib this includes Gnulib's <config.h> and defines macros
31 that glibc library code would normally assume.
32
33 Note: This header file MUST NOT be included by public header files
34 of Gnulib. */
35
36#include <config.h>
37
38/* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
39 _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and
40 DragonFlyBSD 5.9 it includes <sys/cdefs.h> which defines __nonnull.
41 Elsewhere it is harmless. */
42#include <errno.h>
43
44/* From glibc <errno.h>. */
45#ifndef __set_errno
46# define __set_errno(val) (errno = (val))
47#endif
48
49/* From glibc <features.h>. */
50
51#ifndef __GNUC_PREREQ
52# if defined __GNUC__ && defined __GNUC_MINOR__
53# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
54# else
55# define __GNUC_PREREQ(maj, min) 0
56# endif
57#endif
58
59#ifndef __glibc_clang_prereq
60# if defined __clang_major__ && defined __clang_minor__
61# ifdef __apple_build_version__
62/* Apple for some reason renumbers __clang_major__ and __clang_minor__.
63 Gnulib code uses only __glibc_clang_prereq (3, 5); map it to
64 6000000 <= __apple_build_version__. Support for other calls to
65 __glibc_clang_prereq can be added here as needed. */
66# define __glibc_clang_prereq(maj, min) \
67 ((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0)
68# else
69# define __glibc_clang_prereq(maj, min) \
70 ((maj) < __clang_major__ + ((min) <= __clang_minor__))
71# endif
72# else
73# define __glibc_clang_prereq(maj, min) 0
74# endif
75#endif
76
77#ifndef __attribute_nonnull__
78/* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
79 Prepare to include <cdefs.h>, which is Gnulib's version of a
80 more-recent glibc <sys/cdefs.h>. */
81
82/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
83# ifndef _FEATURES_H
84# define _FEATURES_H 1
85# endif
86/* Define __GNULIB_CDEFS so that <cdefs.h> does not attempt to include
87 nonexistent files. */
88# define __GNULIB_CDEFS
89/* Undef the macros unconditionally defined by our copy of glibc
90 <sys/cdefs.h>, so that they do not clash with any system-defined
91 versions. */
92# undef _SYS_CDEFS_H
93# undef __ASMNAME
94# undef __ASMNAME2
95# undef __BEGIN_DECLS
96# undef __CONCAT
97# undef __END_DECLS
98# undef __HAVE_GENERIC_SELECTION
99# undef __LDBL_COMPAT
100# undef __LDBL_REDIR
101# undef __LDBL_REDIR1
102# undef __LDBL_REDIR1_DECL
103# undef __LDBL_REDIR1_NTH
104# undef __LDBL_REDIR2_DECL
105# undef __LDBL_REDIR_DECL
106# undef __LDBL_REDIR_NTH
107# undef __LEAF
108# undef __LEAF_ATTR
109# undef __NTH
110# undef __NTHNL
111# undef __REDIRECT
112# undef __REDIRECT_LDBL
113# undef __REDIRECT_NTH
114# undef __REDIRECT_NTHNL
115# undef __REDIRECT_NTH_LDBL
116# undef __STRING
117# undef __THROW
118# undef __THROWNL
119# undef __attr_access
120# undef __attr_access_none
121# undef __attr_dealloc
122# undef __attr_dealloc_free
123# undef __attribute__
124# undef __attribute_alloc_align__
125# undef __attribute_alloc_size__
126# undef __attribute_artificial__
127# undef __attribute_const__
128# undef __attribute_deprecated__
129# undef __attribute_deprecated_msg__
130# undef __attribute_format_arg__
131# undef __attribute_format_strfmon__
132# undef __attribute_malloc__
133# undef __attribute_maybe_unused__
134# undef __attribute_noinline__
135# undef __attribute_nonstring__
136# undef __attribute_pure__
137# undef __attribute_returns_twice__
138# undef __attribute_used__
139# undef __attribute_warn_unused_result__
140# undef __bos
141# undef __bos0
142# undef __errordecl
143# undef __extension__
144# undef __extern_always_inline
145# undef __extern_inline
146# undef __flexarr
147# undef __fortified_attr_access
148# undef __fortify_function
149# undef __glibc_c99_flexarr_available
150# undef __glibc_fortify
151# undef __glibc_fortify_n
152# undef __glibc_has_attribute
153# undef __glibc_has_builtin
154# undef __glibc_has_extension
155# undef __glibc_likely
156# undef __glibc_macro_warning
157# undef __glibc_macro_warning1
158# undef __glibc_objsize
159# undef __glibc_objsize0
160# undef __glibc_safe_len_cond
161# undef __glibc_safe_or_unknown_len
162# undef __glibc_unlikely
163# undef __glibc_unsafe_len
164# undef __glibc_unsigned_or_positive
165# undef __inline
166# undef __ptr_t
167# undef __restrict
168# undef __restrict_arr
169# undef __va_arg_pack
170# undef __va_arg_pack_len
171# undef __warnattr
172# undef __wur
173
174/* Include our copy of glibc <sys/cdefs.h>. */
175# include <cdefs.h>
176
177/* <cdefs.h> __inline is too pessimistic for non-GCC. */
178# undef __inline
179# ifndef HAVE___INLINE
180# if 199901 <= __STDC_VERSION__ || defined inline
181# define __inline inline
182# else
183# define __inline
184# endif
185# endif
186
187#endif /* defined __glibc_likely */
188
189
190/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
191#define attribute_hidden
192#define libc_hidden_proto(name)
193#define libc_hidden_def(name)
194#define libc_hidden_weak(name)
195#define libc_hidden_ver(local, name)
196#define strong_alias(name, aliasname)
197#define weak_alias(name, aliasname)
198
199/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
200#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
201#define compat_symbol(lib, local, symbol, version) extern int dummy
202#define versioned_symbol(lib, local, symbol, version) extern int dummy
diff --git a/gl/limits.in.h b/gl/limits.in.h
new file mode 100644
index 0000000..eaeac47
--- /dev/null
+++ b/gl/limits.in.h
@@ -0,0 +1,131 @@
1/* A GNU-like <limits.h>.
2
3 Copyright 2016-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@
20#endif
21@PRAGMA_COLUMNS@
22
23#if defined _GL_ALREADY_INCLUDING_LIMITS_H
24/* Special invocation convention:
25 On Haiku/x86_64, we have a sequence of nested includes
26 <limits.h> -> <syslimits.h> -> <limits.h>.
27 In this situation, LONG_MAX and INT_MAX are not yet defined,
28 therefore we should not attempt to define LONG_BIT. */
29
30#@INCLUDE_NEXT@ @NEXT_LIMITS_H@
31
32#else
33/* Normal invocation convention. */
34
35#ifndef _@GUARD_PREFIX@_LIMITS_H
36
37# define _GL_ALREADY_INCLUDING_LIMITS_H
38
39/* The include_next requires a split double-inclusion guard. */
40# @INCLUDE_NEXT@ @NEXT_LIMITS_H@
41
42# undef _GL_ALREADY_INCLUDING_LIMITS_H
43
44#ifndef _@GUARD_PREFIX@_LIMITS_H
45#define _@GUARD_PREFIX@_LIMITS_H
46
47#ifndef LLONG_MIN
48# if defined LONG_LONG_MIN /* HP-UX 11.31 */
49# define LLONG_MIN LONG_LONG_MIN
50# elif defined LONGLONG_MIN /* IRIX 6.5 */
51# define LLONG_MIN LONGLONG_MIN
52# elif defined __GNUC__
53# define LLONG_MIN (- __LONG_LONG_MAX__ - 1LL)
54# endif
55#endif
56#ifndef LLONG_MAX
57# if defined LONG_LONG_MAX /* HP-UX 11.31 */
58# define LLONG_MAX LONG_LONG_MAX
59# elif defined LONGLONG_MAX /* IRIX 6.5 */
60# define LLONG_MAX LONGLONG_MAX
61# elif defined __GNUC__
62# define LLONG_MAX __LONG_LONG_MAX__
63# endif
64#endif
65#ifndef ULLONG_MAX
66# if defined ULONG_LONG_MAX /* HP-UX 11.31 */
67# define ULLONG_MAX ULONG_LONG_MAX
68# elif defined ULONGLONG_MAX /* IRIX 6.5 */
69# define ULLONG_MAX ULONGLONG_MAX
70# elif defined __GNUC__
71# define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1ULL)
72# endif
73#endif
74
75/* The number of usable bits in an unsigned or signed integer type
76 with minimum value MIN and maximum value MAX, as an int expression
77 suitable in #if. Cover all known practical hosts. This
78 implementation exploits the fact that MAX is 1 less than a power of
79 2, and merely counts the number of 1 bits in MAX; "COBn" means
80 "count the number of 1 bits in the low-order n bits"). */
81#define _GL_INTEGER_WIDTH(min, max) (((min) < 0) + _GL_COB128 (max))
82#define _GL_COB128(n) (_GL_COB64 ((n) >> 31 >> 31 >> 2) + _GL_COB64 (n))
83#define _GL_COB64(n) (_GL_COB32 ((n) >> 31 >> 1) + _GL_COB32 (n))
84#define _GL_COB32(n) (_GL_COB16 ((n) >> 16) + _GL_COB16 (n))
85#define _GL_COB16(n) (_GL_COB8 ((n) >> 8) + _GL_COB8 (n))
86#define _GL_COB8(n) (_GL_COB4 ((n) >> 4) + _GL_COB4 (n))
87#define _GL_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + !!((n) & 1))
88
89#ifndef WORD_BIT
90/* Assume 'int' is 32 bits wide. */
91# define WORD_BIT 32
92#endif
93#ifndef LONG_BIT
94/* Assume 'long' is 32 or 64 bits wide. */
95# if LONG_MAX == INT_MAX
96# define LONG_BIT 32
97# else
98# define LONG_BIT 64
99# endif
100#endif
101
102/* Macros specified by C23 and by ISO/IEC TS 18661-1:2014. */
103
104#if (! defined ULLONG_WIDTH \
105 && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \
106 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
107# define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX)
108# define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX)
109# define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX)
110# define SHRT_WIDTH _GL_INTEGER_WIDTH (SHRT_MIN, SHRT_MAX)
111# define USHRT_WIDTH _GL_INTEGER_WIDTH (0, USHRT_MAX)
112# define INT_WIDTH _GL_INTEGER_WIDTH (INT_MIN, INT_MAX)
113# define UINT_WIDTH _GL_INTEGER_WIDTH (0, UINT_MAX)
114# define LONG_WIDTH _GL_INTEGER_WIDTH (LONG_MIN, LONG_MAX)
115# define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX)
116# define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX)
117# define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX)
118#endif
119
120/* Macros specified by C23. */
121
122#if (! defined BOOL_WIDTH \
123 && (defined _GNU_SOURCE \
124 || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__)))
125# define BOOL_MAX 1
126# define BOOL_WIDTH 1
127#endif
128
129#endif /* _@GUARD_PREFIX@_LIMITS_H */
130#endif /* _@GUARD_PREFIX@_LIMITS_H */
131#endif
diff --git a/gl/localcharset.c b/gl/localcharset.c
index a225a2e..7ed9c95 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -1,19 +1,19 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 2
3 Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2000-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Bruno Haible <bruno@clisp.org>. */ 18/* Written by Bruno Haible <bruno@clisp.org>. */
19 19
@@ -22,7 +22,6 @@
22/* Specification. */ 22/* Specification. */
23#include "localcharset.h" 23#include "localcharset.h"
24 24
25#include <fcntl.h>
26#include <stddef.h> 25#include <stddef.h>
27#include <stdio.h> 26#include <stdio.h>
28#include <string.h> 27#include <string.h>
@@ -32,8 +31,9 @@
32# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */ 31# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
33#endif 32#endif
34 33
35#if defined _WIN32 || defined __WIN32__ 34#if defined _WIN32 && !defined __CYGWIN__
36# define WINDOWS_NATIVE 35# define WINDOWS_NATIVE
36# include <locale.h>
37#endif 37#endif
38 38
39#if defined __EMX__ 39#if defined __EMX__
@@ -44,11 +44,10 @@
44#endif 44#endif
45 45
46#if !defined WINDOWS_NATIVE 46#if !defined WINDOWS_NATIVE
47# include <unistd.h>
48# if HAVE_LANGINFO_CODESET 47# if HAVE_LANGINFO_CODESET
49# include <langinfo.h> 48# include <langinfo.h>
50# else 49# else
51# if 0 /* see comment below */ 50# if 0 /* see comment regarding use of setlocale(), below */
52# include <locale.h> 51# include <locale.h>
53# endif 52# endif
54# endif 53# endif
@@ -59,6 +58,9 @@
59#elif defined WINDOWS_NATIVE 58#elif defined WINDOWS_NATIVE
60# define WIN32_LEAN_AND_MEAN 59# define WIN32_LEAN_AND_MEAN
61# include <windows.h> 60# include <windows.h>
61 /* For the use of setlocale() below, the Gnulib override in setlocale.c is
62 not needed; see the platform lists in setlocale_null.m4. */
63# undef setlocale
62#endif 64#endif
63#if defined OS2 65#if defined OS2
64# define INCL_DOS 66# define INCL_DOS
@@ -70,288 +72,755 @@
70# include <xlocale.h> 72# include <xlocale.h>
71#endif 73#endif
72 74
73#if ENABLE_RELOCATABLE
74# include "relocatable.h"
75#else
76# define relocate(pathname) (pathname)
77#endif
78 75
79/* Get LIBDIR. */ 76#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
80#ifndef LIBDIR
81# include "configmake.h"
82#endif
83
84/* Define O_NOFOLLOW to 0 on platforms where it does not exist. */
85#ifndef O_NOFOLLOW
86# define O_NOFOLLOW 0
87#endif
88
89#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
90 /* Native Windows, Cygwin, OS/2, DOS */
91# define ISSLASH(C) ((C) == '/' || (C) == '\\')
92#endif
93
94#ifndef DIRECTORY_SEPARATOR
95# define DIRECTORY_SEPARATOR '/'
96#endif
97 77
98#ifndef ISSLASH 78/* On these platforms, we use a mapping from non-canonical encoding name
99# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR) 79 to GNU canonical encoding name. */
100#endif
101 80
102#if HAVE_DECL_GETC_UNLOCKED 81/* With glibc-2.1 or newer, we don't need any canonicalization,
103# undef getc 82 because glibc has iconv and both glibc and libiconv support all
104# define getc getc_unlocked 83 GNU canonical names directly. */
105#endif 84# if !((defined __GNU_LIBRARY__ && __GLIBC__ >= 2) || defined __UCLIBC__)
106 85
107/* The following static variable is declared 'volatile' to avoid a 86struct table_entry
108 possible multithread problem in the function get_charset_aliases. If we
109 are running in a threaded environment, and if two threads initialize
110 'charset_aliases' simultaneously, both will produce the same value,
111 and everything will be ok if the two assignments to 'charset_aliases'
112 are atomic. But I don't know what will happen if the two assignments mix. */
113#if __STDC__ != 1
114# define volatile /* empty */
115#endif
116/* Pointer to the contents of the charset.alias file, if it has already been
117 read, else NULL. Its format is:
118 ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
119static const char * volatile charset_aliases;
120
121/* Return a pointer to the contents of the charset.alias file. */
122static const char *
123get_charset_aliases (void)
124{ 87{
125 const char *cp; 88 const char alias[11+1];
126 89 const char canonical[11+1];
127 cp = charset_aliases; 90};
128 if (cp == NULL) 91
129 { 92/* Table of platform-dependent mappings, sorted in ascending order. */
130#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__) 93static const struct table_entry alias_table[] =
131 const char *dir; 94 {
132 const char *base = "charset.alias"; 95# if defined __FreeBSD__ /* FreeBSD */
133 char *file_name; 96 /*{ "ARMSCII-8", "ARMSCII-8" },*/
134 97 { "Big5", "BIG5" },
135 /* Make it possible to override the charset.alias location. This is 98 { "C", "ASCII" },
136 necessary for running the testsuite before "make install". */ 99 /*{ "CP1131", "CP1131" },*/
137 dir = getenv ("CHARSETALIASDIR"); 100 /*{ "CP1251", "CP1251" },*/
138 if (dir == NULL || dir[0] == '\0') 101 /*{ "CP866", "CP866" },*/
139 dir = relocate (LIBDIR); 102 /*{ "GB18030", "GB18030" },*/
140 103 /*{ "GB2312", "GB2312" },*/
141 /* Concatenate dir and base into freshly allocated file_name. */ 104 /*{ "GBK", "GBK" },*/
142 { 105 /*{ "ISCII-DEV", "?" },*/
143 size_t dir_len = strlen (dir); 106 { "ISO8859-1", "ISO-8859-1" },
144 size_t base_len = strlen (base); 107 { "ISO8859-13", "ISO-8859-13" },
145 int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1])); 108 { "ISO8859-15", "ISO-8859-15" },
146 file_name = (char *) malloc (dir_len + add_slash + base_len + 1); 109 { "ISO8859-2", "ISO-8859-2" },
147 if (file_name != NULL) 110 { "ISO8859-5", "ISO-8859-5" },
148 { 111 { "ISO8859-7", "ISO-8859-7" },
149 memcpy (file_name, dir, dir_len); 112 { "ISO8859-9", "ISO-8859-9" },
150 if (add_slash) 113 /*{ "KOI8-R", "KOI8-R" },*/
151 file_name[dir_len] = DIRECTORY_SEPARATOR; 114 /*{ "KOI8-U", "KOI8-U" },*/
152 memcpy (file_name + dir_len + add_slash, base, base_len + 1); 115 { "SJIS", "SHIFT_JIS" },
153 } 116 { "US-ASCII", "ASCII" },
154 } 117 { "eucCN", "GB2312" },
155 118 { "eucJP", "EUC-JP" },
156 if (file_name == NULL) 119 { "eucKR", "EUC-KR" }
157 /* Out of memory. Treat the file as empty. */ 120# define alias_table_defined
158 cp = ""; 121# endif
159 else 122# if defined __NetBSD__ /* NetBSD */
160 { 123 { "646", "ASCII" },
161 int fd; 124 /*{ "ARMSCII-8", "ARMSCII-8" },*/
162 125 /*{ "BIG5", "BIG5" },*/
163 /* Open the file. Reject symbolic links on platforms that support 126 { "Big5-HKSCS", "BIG5-HKSCS" },
164 O_NOFOLLOW. This is a security feature. Without it, an attacker 127 /*{ "CP1251", "CP1251" },*/
165 could retrieve parts of the contents (namely, the tail of the 128 /*{ "CP866", "CP866" },*/
166 first line that starts with "* ") of an arbitrary file by placing 129 /*{ "GB18030", "GB18030" },*/
167 a symbolic link to that file under the name "charset.alias" in 130 /*{ "GB2312", "GB2312" },*/
168 some writable directory and defining the environment variable 131 { "ISO8859-1", "ISO-8859-1" },
169 CHARSETALIASDIR to point to that directory. */ 132 { "ISO8859-13", "ISO-8859-13" },
170 fd = open (file_name, 133 { "ISO8859-15", "ISO-8859-15" },
171 O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0)); 134 { "ISO8859-2", "ISO-8859-2" },
172 if (fd < 0) 135 { "ISO8859-4", "ISO-8859-4" },
173 /* File not found. Treat it as empty. */ 136 { "ISO8859-5", "ISO-8859-5" },
174 cp = ""; 137 { "ISO8859-7", "ISO-8859-7" },
175 else 138 /*{ "KOI8-R", "KOI8-R" },*/
176 { 139 /*{ "KOI8-U", "KOI8-U" },*/
177 FILE *fp; 140 /*{ "PT154", "PT154" },*/
178 141 { "SJIS", "SHIFT_JIS" },
179 fp = fdopen (fd, "r"); 142 { "eucCN", "GB2312" },
180 if (fp == NULL) 143 { "eucJP", "EUC-JP" },
181 { 144 { "eucKR", "EUC-KR" },
182 /* Out of memory. Treat the file as empty. */ 145 { "eucTW", "EUC-TW" }
183 close (fd); 146# define alias_table_defined
184 cp = ""; 147# endif
185 } 148# if defined __OpenBSD__ /* OpenBSD */
186 else 149 { "646", "ASCII" },
187 { 150 { "ISO8859-1", "ISO-8859-1" },
188 /* Parse the file's contents. */ 151 { "ISO8859-13", "ISO-8859-13" },
189 char *res_ptr = NULL; 152 { "ISO8859-15", "ISO-8859-15" },
190 size_t res_size = 0; 153 { "ISO8859-2", "ISO-8859-2" },
191 154 { "ISO8859-4", "ISO-8859-4" },
192 for (;;) 155 { "ISO8859-5", "ISO-8859-5" },
193 { 156 { "ISO8859-7", "ISO-8859-7" },
194 int c; 157 { "US-ASCII", "ASCII" }
195 char buf1[50+1]; 158# define alias_table_defined
196 char buf2[50+1]; 159# endif
197 size_t l1, l2; 160# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
198 char *old_res_ptr; 161 /* Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
199 162 useless:
200 c = getc (fp); 163 - It returns the empty string when LANG is set to a locale of the
201 if (c == EOF) 164 form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
202 break; 165 LC_CTYPE file.
203 if (c == '\n' || c == ' ' || c == '\t') 166 - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
204 continue; 167 the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
205 if (c == '#') 168 - The documentation says:
206 { 169 "... all code that calls BSD system routines should ensure
207 /* Skip comment, to end of line. */ 170 that the const *char parameters of these routines are in UTF-8
208 do 171 encoding. All BSD system functions expect their string
209 c = getc (fp); 172 parameters to be in UTF-8 encoding and nothing else."
210 while (!(c == EOF || c == '\n')); 173 It also says
211 if (c == EOF) 174 "An additional caveat is that string parameters for files,
212 break; 175 paths, and other file-system entities must be in canonical
213 continue; 176 UTF-8. In a canonical UTF-8 Unicode string, all decomposable
214 } 177 characters are decomposed ..."
215 ungetc (c, fp); 178 but this is not true: You can pass non-decomposed UTF-8 strings
216 if (fscanf (fp, "%50s %50s", buf1, buf2) < 2) 179 to file system functions, and it is the OS which will convert
217 break; 180 them to decomposed UTF-8 before accessing the file system.
218 l1 = strlen (buf1); 181 - The Apple Terminal application displays UTF-8 by default.
219 l2 = strlen (buf2); 182 - However, other applications are free to use different encodings:
220 old_res_ptr = res_ptr; 183 - xterm uses ISO-8859-1 by default.
221 if (res_size == 0) 184 - TextEdit uses MacRoman by default.
222 { 185 We prefer UTF-8 over decomposed UTF-8-MAC because one should
223 res_size = l1 + 1 + l2 + 1; 186 minimize the use of decomposed Unicode. Unfortunately, through the
224 res_ptr = (char *) malloc (res_size + 1); 187 Darwin file system, decomposed UTF-8 strings are leaked into user
225 } 188 space nevertheless.
226 else 189 Then there are also the locales with encodings other than US-ASCII
227 { 190 and UTF-8. These locales can be occasionally useful to users (e.g.
228 res_size += l1 + 1 + l2 + 1; 191 when grepping through ISO-8859-1 encoded text files), when all their
229 res_ptr = (char *) realloc (res_ptr, res_size + 1); 192 file names are in US-ASCII.
230 } 193 */
231 if (res_ptr == NULL) 194 { "ARMSCII-8", "ARMSCII-8" },
232 { 195 { "Big5", "BIG5" },
233 /* Out of memory. */ 196 { "Big5HKSCS", "BIG5-HKSCS" },
234 res_size = 0; 197 { "CP1131", "CP1131" },
235 free (old_res_ptr); 198 { "CP1251", "CP1251" },
236 break; 199 { "CP866", "CP866" },
237 } 200 { "CP949", "CP949" },
238 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); 201 { "GB18030", "GB18030" },
239 strcpy (res_ptr + res_size - (l2 + 1), buf2); 202 { "GB2312", "GB2312" },
240 } 203 { "GBK", "GBK" },
241 fclose (fp); 204 /*{ "ISCII-DEV", "?" },*/
242 if (res_size == 0) 205 { "ISO8859-1", "ISO-8859-1" },
243 cp = ""; 206 { "ISO8859-13", "ISO-8859-13" },
244 else 207 { "ISO8859-15", "ISO-8859-15" },
245 { 208 { "ISO8859-2", "ISO-8859-2" },
246 *(res_ptr + res_size) = '\0'; 209 { "ISO8859-4", "ISO-8859-4" },
247 cp = res_ptr; 210 { "ISO8859-5", "ISO-8859-5" },
248 } 211 { "ISO8859-7", "ISO-8859-7" },
249 } 212 { "ISO8859-9", "ISO-8859-9" },
250 } 213 { "KOI8-R", "KOI8-R" },
214 { "KOI8-U", "KOI8-U" },
215 { "PT154", "PT154" },
216 { "SJIS", "SHIFT_JIS" },
217 { "eucCN", "GB2312" },
218 { "eucJP", "EUC-JP" },
219 { "eucKR", "EUC-KR" }
220# define alias_table_defined
221# endif
222# if defined _AIX /* AIX */
223 /*{ "GBK", "GBK" },*/
224 { "IBM-1046", "CP1046" },
225 { "IBM-1124", "CP1124" },
226 { "IBM-1129", "CP1129" },
227 { "IBM-1252", "CP1252" },
228 { "IBM-850", "CP850" },
229 { "IBM-856", "CP856" },
230 { "IBM-921", "ISO-8859-13" },
231 { "IBM-922", "CP922" },
232 { "IBM-932", "CP932" },
233 { "IBM-943", "CP943" },
234 { "IBM-eucCN", "GB2312" },
235 { "IBM-eucJP", "EUC-JP" },
236 { "IBM-eucKR", "EUC-KR" },
237 { "IBM-eucTW", "EUC-TW" },
238 { "ISO8859-1", "ISO-8859-1" },
239 { "ISO8859-15", "ISO-8859-15" },
240 { "ISO8859-2", "ISO-8859-2" },
241 { "ISO8859-5", "ISO-8859-5" },
242 { "ISO8859-6", "ISO-8859-6" },
243 { "ISO8859-7", "ISO-8859-7" },
244 { "ISO8859-8", "ISO-8859-8" },
245 { "ISO8859-9", "ISO-8859-9" },
246 { "TIS-620", "TIS-620" },
247 /*{ "UTF-8", "UTF-8" },*/
248 { "big5", "BIG5" }
249# define alias_table_defined
250# endif
251# if defined __hpux /* HP-UX */
252 { "SJIS", "SHIFT_JIS" },
253 { "arabic8", "HP-ARABIC8" },
254 { "big5", "BIG5" },
255 { "cp1251", "CP1251" },
256 { "eucJP", "EUC-JP" },
257 { "eucKR", "EUC-KR" },
258 { "eucTW", "EUC-TW" },
259 { "gb18030", "GB18030" },
260 { "greek8", "HP-GREEK8" },
261 { "hebrew8", "HP-HEBREW8" },
262 { "hkbig5", "BIG5-HKSCS" },
263 { "hp15CN", "GB2312" },
264 { "iso88591", "ISO-8859-1" },
265 { "iso885913", "ISO-8859-13" },
266 { "iso885915", "ISO-8859-15" },
267 { "iso88592", "ISO-8859-2" },
268 { "iso88594", "ISO-8859-4" },
269 { "iso88595", "ISO-8859-5" },
270 { "iso88596", "ISO-8859-6" },
271 { "iso88597", "ISO-8859-7" },
272 { "iso88598", "ISO-8859-8" },
273 { "iso88599", "ISO-8859-9" },
274 { "kana8", "HP-KANA8" },
275 { "koi8r", "KOI8-R" },
276 { "roman8", "HP-ROMAN8" },
277 { "tis620", "TIS-620" },
278 { "turkish8", "HP-TURKISH8" },
279 { "utf8", "UTF-8" }
280# define alias_table_defined
281# endif
282# if defined __sgi /* IRIX */
283 { "ISO8859-1", "ISO-8859-1" },
284 { "ISO8859-15", "ISO-8859-15" },
285 { "ISO8859-2", "ISO-8859-2" },
286 { "ISO8859-5", "ISO-8859-5" },
287 { "ISO8859-7", "ISO-8859-7" },
288 { "ISO8859-9", "ISO-8859-9" },
289 { "eucCN", "GB2312" },
290 { "eucJP", "EUC-JP" },
291 { "eucKR", "EUC-KR" },
292 { "eucTW", "EUC-TW" }
293# define alias_table_defined
294# endif
295# if defined __osf__ /* OSF/1 */
296 /*{ "GBK", "GBK" },*/
297 { "ISO8859-1", "ISO-8859-1" },
298 { "ISO8859-15", "ISO-8859-15" },
299 { "ISO8859-2", "ISO-8859-2" },
300 { "ISO8859-4", "ISO-8859-4" },
301 { "ISO8859-5", "ISO-8859-5" },
302 { "ISO8859-7", "ISO-8859-7" },
303 { "ISO8859-8", "ISO-8859-8" },
304 { "ISO8859-9", "ISO-8859-9" },
305 { "KSC5601", "CP949" },
306 { "SJIS", "SHIFT_JIS" },
307 { "TACTIS", "TIS-620" },
308 /*{ "UTF-8", "UTF-8" },*/
309 { "big5", "BIG5" },
310 { "cp850", "CP850" },
311 { "dechanyu", "DEC-HANYU" },
312 { "dechanzi", "GB2312" },
313 { "deckanji", "DEC-KANJI" },
314 { "deckorean", "EUC-KR" },
315 { "eucJP", "EUC-JP" },
316 { "eucKR", "EUC-KR" },
317 { "eucTW", "EUC-TW" },
318 { "sdeckanji", "EUC-JP" }
319# define alias_table_defined
320# endif
321# if defined __sun /* Solaris */
322 { "5601", "EUC-KR" },
323 { "646", "ASCII" },
324 /*{ "BIG5", "BIG5" },*/
325 { "Big5-HKSCS", "BIG5-HKSCS" },
326 { "GB18030", "GB18030" },
327 /*{ "GBK", "GBK" },*/
328 { "ISO8859-1", "ISO-8859-1" },
329 { "ISO8859-11", "TIS-620" },
330 { "ISO8859-13", "ISO-8859-13" },
331 { "ISO8859-15", "ISO-8859-15" },
332 { "ISO8859-2", "ISO-8859-2" },
333 { "ISO8859-3", "ISO-8859-3" },
334 { "ISO8859-4", "ISO-8859-4" },
335 { "ISO8859-5", "ISO-8859-5" },
336 { "ISO8859-6", "ISO-8859-6" },
337 { "ISO8859-7", "ISO-8859-7" },
338 { "ISO8859-8", "ISO-8859-8" },
339 { "ISO8859-9", "ISO-8859-9" },
340 { "PCK", "SHIFT_JIS" },
341 { "TIS620.2533", "TIS-620" },
342 /*{ "UTF-8", "UTF-8" },*/
343 { "ansi-1251", "CP1251" },
344 { "cns11643", "EUC-TW" },
345 { "eucJP", "EUC-JP" },
346 { "gb2312", "GB2312" },
347 { "koi8-r", "KOI8-R" }
348# define alias_table_defined
349# endif
350# if defined __minix /* Minix */
351 { "646", "ASCII" }
352# define alias_table_defined
353# endif
354# if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Windows */
355 { "CP1361", "JOHAB" },
356 { "CP20127", "ASCII" },
357 { "CP20866", "KOI8-R" },
358 { "CP20936", "GB2312" },
359 { "CP21866", "KOI8-RU" },
360 { "CP28591", "ISO-8859-1" },
361 { "CP28592", "ISO-8859-2" },
362 { "CP28593", "ISO-8859-3" },
363 { "CP28594", "ISO-8859-4" },
364 { "CP28595", "ISO-8859-5" },
365 { "CP28596", "ISO-8859-6" },
366 { "CP28597", "ISO-8859-7" },
367 { "CP28598", "ISO-8859-8" },
368 { "CP28599", "ISO-8859-9" },
369 { "CP28605", "ISO-8859-15" },
370 { "CP38598", "ISO-8859-8" },
371 { "CP51932", "EUC-JP" },
372 { "CP51936", "GB2312" },
373 { "CP51949", "EUC-KR" },
374 { "CP51950", "EUC-TW" },
375 { "CP54936", "GB18030" },
376 { "CP65001", "UTF-8" },
377 { "CP936", "GBK" }
378# define alias_table_defined
379# endif
380# if defined OS2 /* OS/2 */
381 /* The list of encodings is taken from "List of OS/2 Codepages"
382 by Alex Taylor:
383 <http://altsan.org/os2/toolkits/uls/index.html#codepages>.
384 See also "__convcp() of kLIBC":
385 <https://github.com/bitwiseworks/libc/blob/master/src/emx/src/lib/locale/__convcp.c>. */
386 { "CP1004", "CP1252" },
387 /*{ "CP1041", "CP943" },*/
388 /*{ "CP1088", "CP949" },*/
389 { "CP1089", "ISO-8859-6" },
390 /*{ "CP1114", "CP950" },*/
391 /*{ "CP1115", "GB2312" },*/
392 { "CP1208", "UTF-8" },
393 /*{ "CP1380", "GB2312" },*/
394 { "CP1381", "GB2312" },
395 { "CP1383", "GB2312" },
396 { "CP1386", "GBK" },
397 /*{ "CP301", "CP943" },*/
398 { "CP3372", "EUC-JP" },
399 { "CP4946", "CP850" },
400 /*{ "CP5048", "JIS_X0208-1990" },*/
401 /*{ "CP5049", "JIS_X0212-1990" },*/
402 /*{ "CP5067", "KS_C_5601-1987" },*/
403 { "CP813", "ISO-8859-7" },
404 { "CP819", "ISO-8859-1" },
405 { "CP878", "KOI8-R" },
406 /*{ "CP897", "CP943" },*/
407 { "CP912", "ISO-8859-2" },
408 { "CP913", "ISO-8859-3" },
409 { "CP914", "ISO-8859-4" },
410 { "CP915", "ISO-8859-5" },
411 { "CP916", "ISO-8859-8" },
412 { "CP920", "ISO-8859-9" },
413 { "CP921", "ISO-8859-13" },
414 { "CP923", "ISO-8859-15" },
415 /*{ "CP941", "CP943" },*/
416 /*{ "CP947", "CP950" },*/
417 /*{ "CP951", "CP949" },*/
418 /*{ "CP952", "JIS_X0208-1990" },*/
419 /*{ "CP953", "JIS_X0212-1990" },*/
420 { "CP954", "EUC-JP" },
421 { "CP964", "EUC-TW" },
422 { "CP970", "EUC-KR" },
423 /*{ "CP971", "KS_C_5601-1987" },*/
424 { "IBM-1004", "CP1252" },
425 /*{ "IBM-1006", "?" },*/
426 /*{ "IBM-1008", "?" },*/
427 /*{ "IBM-1041", "CP943" },*/
428 /*{ "IBM-1051", "?" },*/
429 /*{ "IBM-1088", "CP949" },*/
430 { "IBM-1089", "ISO-8859-6" },
431 /*{ "IBM-1098", "?" },*/
432 /*{ "IBM-1114", "CP950" },*/
433 /*{ "IBM-1115", "GB2312" },*/
434 /*{ "IBM-1116", "?" },*/
435 /*{ "IBM-1117", "?" },*/
436 /*{ "IBM-1118", "?" },*/
437 /*{ "IBM-1119", "?" },*/
438 { "IBM-1124", "CP1124" },
439 { "IBM-1125", "CP1125" },
440 { "IBM-1131", "CP1131" },
441 { "IBM-1208", "UTF-8" },
442 { "IBM-1250", "CP1250" },
443 { "IBM-1251", "CP1251" },
444 { "IBM-1252", "CP1252" },
445 { "IBM-1253", "CP1253" },
446 { "IBM-1254", "CP1254" },
447 { "IBM-1255", "CP1255" },
448 { "IBM-1256", "CP1256" },
449 { "IBM-1257", "CP1257" },
450 /*{ "IBM-1275", "?" },*/
451 /*{ "IBM-1276", "?" },*/
452 /*{ "IBM-1277", "?" },*/
453 /*{ "IBM-1280", "?" },*/
454 /*{ "IBM-1281", "?" },*/
455 /*{ "IBM-1282", "?" },*/
456 /*{ "IBM-1283", "?" },*/
457 /*{ "IBM-1380", "GB2312" },*/
458 { "IBM-1381", "GB2312" },
459 { "IBM-1383", "GB2312" },
460 { "IBM-1386", "GBK" },
461 /*{ "IBM-301", "CP943" },*/
462 { "IBM-3372", "EUC-JP" },
463 { "IBM-367", "ASCII" },
464 { "IBM-437", "CP437" },
465 { "IBM-4946", "CP850" },
466 /*{ "IBM-5048", "JIS_X0208-1990" },*/
467 /*{ "IBM-5049", "JIS_X0212-1990" },*/
468 /*{ "IBM-5067", "KS_C_5601-1987" },*/
469 { "IBM-813", "ISO-8859-7" },
470 { "IBM-819", "ISO-8859-1" },
471 { "IBM-850", "CP850" },
472 /*{ "IBM-851", "?" },*/
473 { "IBM-852", "CP852" },
474 { "IBM-855", "CP855" },
475 { "IBM-856", "CP856" },
476 { "IBM-857", "CP857" },
477 /*{ "IBM-859", "?" },*/
478 { "IBM-860", "CP860" },
479 { "IBM-861", "CP861" },
480 { "IBM-862", "CP862" },
481 { "IBM-863", "CP863" },
482 { "IBM-864", "CP864" },
483 { "IBM-865", "CP865" },
484 { "IBM-866", "CP866" },
485 /*{ "IBM-868", "?" },*/
486 { "IBM-869", "CP869" },
487 { "IBM-874", "CP874" },
488 { "IBM-878", "KOI8-R" },
489 /*{ "IBM-895", "?" },*/
490 /*{ "IBM-897", "CP943" },*/
491 /*{ "IBM-907", "?" },*/
492 /*{ "IBM-909", "?" },*/
493 { "IBM-912", "ISO-8859-2" },
494 { "IBM-913", "ISO-8859-3" },
495 { "IBM-914", "ISO-8859-4" },
496 { "IBM-915", "ISO-8859-5" },
497 { "IBM-916", "ISO-8859-8" },
498 { "IBM-920", "ISO-8859-9" },
499 { "IBM-921", "ISO-8859-13" },
500 { "IBM-922", "CP922" },
501 { "IBM-923", "ISO-8859-15" },
502 { "IBM-932", "CP932" },
503 /*{ "IBM-941", "CP943" },*/
504 /*{ "IBM-942", "?" },*/
505 { "IBM-943", "CP943" },
506 /*{ "IBM-947", "CP950" },*/
507 { "IBM-949", "CP949" },
508 { "IBM-950", "CP950" },
509 /*{ "IBM-951", "CP949" },*/
510 /*{ "IBM-952", "JIS_X0208-1990" },*/
511 /*{ "IBM-953", "JIS_X0212-1990" },*/
512 { "IBM-954", "EUC-JP" },
513 /*{ "IBM-955", "?" },*/
514 { "IBM-964", "EUC-TW" },
515 { "IBM-970", "EUC-KR" },
516 /*{ "IBM-971", "KS_C_5601-1987" },*/
517 { "IBM-eucCN", "GB2312" },
518 { "IBM-eucJP", "EUC-JP" },
519 { "IBM-eucKR", "EUC-KR" },
520 { "IBM-eucTW", "EUC-TW" },
521 { "IBM33722", "EUC-JP" },
522 { "ISO8859-1", "ISO-8859-1" },
523 { "ISO8859-2", "ISO-8859-2" },
524 { "ISO8859-3", "ISO-8859-3" },
525 { "ISO8859-4", "ISO-8859-4" },
526 { "ISO8859-5", "ISO-8859-5" },
527 { "ISO8859-6", "ISO-8859-6" },
528 { "ISO8859-7", "ISO-8859-7" },
529 { "ISO8859-8", "ISO-8859-8" },
530 { "ISO8859-9", "ISO-8859-9" },
531 /*{ "JISX0201-1976", "JISX0201-1976" },*/
532 /*{ "JISX0208-1978", "?" },*/
533 /*{ "JISX0208-1983", "JIS_X0208-1983" },*/
534 /*{ "JISX0208-1990", "JIS_X0208-1990" },*/
535 /*{ "JISX0212-1990", "JIS_X0212-1990" },*/
536 /*{ "KSC5601-1987", "KS_C_5601-1987" },*/
537 { "SJIS-1", "CP943" },
538 { "SJIS-2", "CP943" },
539 { "eucJP", "EUC-JP" },
540 { "eucKR", "EUC-KR" },
541 { "eucTW-1993", "EUC-TW" }
542# define alias_table_defined
543# endif
544# if defined VMS /* OpenVMS */
545 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
546 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
547 section 10.7 "Handling Different Character Sets". */
548 { "DECHANYU", "DEC-HANYU" },
549 { "DECHANZI", "GB2312" },
550 { "DECKANJI", "DEC-KANJI" },
551 { "DECKOREAN", "EUC-KR" },
552 { "ISO8859-1", "ISO-8859-1" },
553 { "ISO8859-2", "ISO-8859-2" },
554 { "ISO8859-5", "ISO-8859-5" },
555 { "ISO8859-7", "ISO-8859-7" },
556 { "ISO8859-8", "ISO-8859-8" },
557 { "ISO8859-9", "ISO-8859-9" },
558 { "SDECKANJI", "EUC-JP" },
559 { "SJIS", "SHIFT_JIS" },
560 { "eucJP", "EUC-JP" },
561 { "eucTW", "EUC-TW" }
562# define alias_table_defined
563# endif
564# ifndef alias_table_defined
565 /* Just a dummy entry, to avoid a C syntax error. */
566 { "", "" }
567# endif
568 };
251 569
252 free (file_name); 570# endif
253 }
254 571
255#else 572#else
256 573
257# if defined DARWIN7 574/* On these platforms, we use a mapping from locale name to GNU canonical
258 /* To avoid the trouble of installing a file that is shared by many 575 encoding name. */
259 GNU packages -- many packaging systems have problems with this --,
260 simply inline the aliases here. */
261 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
262 "ISO8859-2" "\0" "ISO-8859-2" "\0"
263 "ISO8859-4" "\0" "ISO-8859-4" "\0"
264 "ISO8859-5" "\0" "ISO-8859-5" "\0"
265 "ISO8859-7" "\0" "ISO-8859-7" "\0"
266 "ISO8859-9" "\0" "ISO-8859-9" "\0"
267 "ISO8859-13" "\0" "ISO-8859-13" "\0"
268 "ISO8859-15" "\0" "ISO-8859-15" "\0"
269 "KOI8-R" "\0" "KOI8-R" "\0"
270 "KOI8-U" "\0" "KOI8-U" "\0"
271 "CP866" "\0" "CP866" "\0"
272 "CP949" "\0" "CP949" "\0"
273 "CP1131" "\0" "CP1131" "\0"
274 "CP1251" "\0" "CP1251" "\0"
275 "eucCN" "\0" "GB2312" "\0"
276 "GB2312" "\0" "GB2312" "\0"
277 "eucJP" "\0" "EUC-JP" "\0"
278 "eucKR" "\0" "EUC-KR" "\0"
279 "Big5" "\0" "BIG5" "\0"
280 "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
281 "GBK" "\0" "GBK" "\0"
282 "GB18030" "\0" "GB18030" "\0"
283 "SJIS" "\0" "SHIFT_JIS" "\0"
284 "ARMSCII-8" "\0" "ARMSCII-8" "\0"
285 "PT154" "\0" "PT154" "\0"
286 /*"ISCII-DEV" "\0" "?" "\0"*/
287 "*" "\0" "UTF-8" "\0";
288# endif
289 576
290# if defined VMS 577struct table_entry
291 /* To avoid the troubles of an extra file charset.alias_vms in the 578{
292 sources of many GNU packages, simply inline the aliases here. */ 579 const char locale[17+1];
293 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation 580 const char canonical[11+1];
294 "Compaq C Run-Time Library Reference Manual for OpenVMS systems" 581};
295 section 10.7 "Handling Different Character Sets". */ 582
296 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" 583/* Table of platform-dependent mappings, sorted in ascending order. */
297 "ISO8859-2" "\0" "ISO-8859-2" "\0" 584static const struct table_entry locale_table[] =
298 "ISO8859-5" "\0" "ISO-8859-5" "\0" 585 {
299 "ISO8859-7" "\0" "ISO-8859-7" "\0" 586# if defined __FreeBSD__ /* FreeBSD 4.2 */
300 "ISO8859-8" "\0" "ISO-8859-8" "\0" 587 { "cs_CZ.ISO_8859-2", "ISO-8859-2" },
301 "ISO8859-9" "\0" "ISO-8859-9" "\0" 588 { "da_DK.DIS_8859-15", "ISO-8859-15" },
302 /* Japanese */ 589 { "da_DK.ISO_8859-1", "ISO-8859-1" },
303 "eucJP" "\0" "EUC-JP" "\0" 590 { "de_AT.DIS_8859-15", "ISO-8859-15" },
304 "SJIS" "\0" "SHIFT_JIS" "\0" 591 { "de_AT.ISO_8859-1", "ISO-8859-1" },
305 "DECKANJI" "\0" "DEC-KANJI" "\0" 592 { "de_CH.DIS_8859-15", "ISO-8859-15" },
306 "SDECKANJI" "\0" "EUC-JP" "\0" 593 { "de_CH.ISO_8859-1", "ISO-8859-1" },
307 /* Chinese */ 594 { "de_DE.DIS_8859-15", "ISO-8859-15" },
308 "eucTW" "\0" "EUC-TW" "\0" 595 { "de_DE.ISO_8859-1", "ISO-8859-1" },
309 "DECHANYU" "\0" "DEC-HANYU" "\0" 596 { "en_AU.DIS_8859-15", "ISO-8859-15" },
310 "DECHANZI" "\0" "GB2312" "\0" 597 { "en_AU.ISO_8859-1", "ISO-8859-1" },
311 /* Korean */ 598 { "en_CA.DIS_8859-15", "ISO-8859-15" },
312 "DECKOREAN" "\0" "EUC-KR" "\0"; 599 { "en_CA.ISO_8859-1", "ISO-8859-1" },
600 { "en_GB.DIS_8859-15", "ISO-8859-15" },
601 { "en_GB.ISO_8859-1", "ISO-8859-1" },
602 { "en_US.DIS_8859-15", "ISO-8859-15" },
603 { "en_US.ISO_8859-1", "ISO-8859-1" },
604 { "es_ES.DIS_8859-15", "ISO-8859-15" },
605 { "es_ES.ISO_8859-1", "ISO-8859-1" },
606 { "fi_FI.DIS_8859-15", "ISO-8859-15" },
607 { "fi_FI.ISO_8859-1", "ISO-8859-1" },
608 { "fr_BE.DIS_8859-15", "ISO-8859-15" },
609 { "fr_BE.ISO_8859-1", "ISO-8859-1" },
610 { "fr_CA.DIS_8859-15", "ISO-8859-15" },
611 { "fr_CA.ISO_8859-1", "ISO-8859-1" },
612 { "fr_CH.DIS_8859-15", "ISO-8859-15" },
613 { "fr_CH.ISO_8859-1", "ISO-8859-1" },
614 { "fr_FR.DIS_8859-15", "ISO-8859-15" },
615 { "fr_FR.ISO_8859-1", "ISO-8859-1" },
616 { "hr_HR.ISO_8859-2", "ISO-8859-2" },
617 { "hu_HU.ISO_8859-2", "ISO-8859-2" },
618 { "is_IS.DIS_8859-15", "ISO-8859-15" },
619 { "is_IS.ISO_8859-1", "ISO-8859-1" },
620 { "it_CH.DIS_8859-15", "ISO-8859-15" },
621 { "it_CH.ISO_8859-1", "ISO-8859-1" },
622 { "it_IT.DIS_8859-15", "ISO-8859-15" },
623 { "it_IT.ISO_8859-1", "ISO-8859-1" },
624 { "ja_JP.EUC", "EUC-JP" },
625 { "ja_JP.SJIS", "SHIFT_JIS" },
626 { "ja_JP.Shift_JIS", "SHIFT_JIS" },
627 { "ko_KR.EUC", "EUC-KR" },
628 { "la_LN.ASCII", "ASCII" },
629 { "la_LN.DIS_8859-15", "ISO-8859-15" },
630 { "la_LN.ISO_8859-1", "ISO-8859-1" },
631 { "la_LN.ISO_8859-2", "ISO-8859-2" },
632 { "la_LN.ISO_8859-4", "ISO-8859-4" },
633 { "lt_LN.ASCII", "ASCII" },
634 { "lt_LN.DIS_8859-15", "ISO-8859-15" },
635 { "lt_LN.ISO_8859-1", "ISO-8859-1" },
636 { "lt_LN.ISO_8859-2", "ISO-8859-2" },
637 { "lt_LT.ISO_8859-4", "ISO-8859-4" },
638 { "nl_BE.DIS_8859-15", "ISO-8859-15" },
639 { "nl_BE.ISO_8859-1", "ISO-8859-1" },
640 { "nl_NL.DIS_8859-15", "ISO-8859-15" },
641 { "nl_NL.ISO_8859-1", "ISO-8859-1" },
642 { "no_NO.DIS_8859-15", "ISO-8859-15" },
643 { "no_NO.ISO_8859-1", "ISO-8859-1" },
644 { "pl_PL.ISO_8859-2", "ISO-8859-2" },
645 { "pt_PT.DIS_8859-15", "ISO-8859-15" },
646 { "pt_PT.ISO_8859-1", "ISO-8859-1" },
647 { "ru_RU.CP866", "CP866" },
648 { "ru_RU.ISO_8859-5", "ISO-8859-5" },
649 { "ru_RU.KOI8-R", "KOI8-R" },
650 { "ru_SU.CP866", "CP866" },
651 { "ru_SU.ISO_8859-5", "ISO-8859-5" },
652 { "ru_SU.KOI8-R", "KOI8-R" },
653 { "sl_SI.ISO_8859-2", "ISO-8859-2" },
654 { "sv_SE.DIS_8859-15", "ISO-8859-15" },
655 { "sv_SE.ISO_8859-1", "ISO-8859-1" },
656 { "uk_UA.KOI8-U", "KOI8-U" },
657 { "zh_CN.EUC", "GB2312" },
658 { "zh_TW.BIG5", "BIG5" },
659 { "zh_TW.Big5", "BIG5" }
660# define locale_table_defined
313# endif 661# endif
314 662# if defined __DJGPP__ /* DOS / DJGPP 2.03 */
315# if defined WINDOWS_NATIVE || defined __CYGWIN__ 663 /* The encodings given here may not all be correct.
316 /* To avoid the troubles of installing a separate file in the same 664 If you find that the encoding given for your language and
317 directory as the DLL and of retrieving the DLL's directory at 665 country is not the one your DOS machine actually uses, just
318 runtime, simply inline the aliases here. */ 666 correct it in this file, and send a mail to
319 667 Juan Manuel Guerrero <juan.guerrero@gmx.de>
320 cp = "CP936" "\0" "GBK" "\0" 668 and <bug-gnulib@gnu.org>. */
321 "CP1361" "\0" "JOHAB" "\0" 669 { "C", "ASCII" },
322 "CP20127" "\0" "ASCII" "\0" 670 { "ar", "CP864" },
323 "CP20866" "\0" "KOI8-R" "\0" 671 { "ar_AE", "CP864" },
324 "CP20936" "\0" "GB2312" "\0" 672 { "ar_DZ", "CP864" },
325 "CP21866" "\0" "KOI8-RU" "\0" 673 { "ar_EG", "CP864" },
326 "CP28591" "\0" "ISO-8859-1" "\0" 674 { "ar_IQ", "CP864" },
327 "CP28592" "\0" "ISO-8859-2" "\0" 675 { "ar_IR", "CP864" },
328 "CP28593" "\0" "ISO-8859-3" "\0" 676 { "ar_JO", "CP864" },
329 "CP28594" "\0" "ISO-8859-4" "\0" 677 { "ar_KW", "CP864" },
330 "CP28595" "\0" "ISO-8859-5" "\0" 678 { "ar_MA", "CP864" },
331 "CP28596" "\0" "ISO-8859-6" "\0" 679 { "ar_OM", "CP864" },
332 "CP28597" "\0" "ISO-8859-7" "\0" 680 { "ar_QA", "CP864" },
333 "CP28598" "\0" "ISO-8859-8" "\0" 681 { "ar_SA", "CP864" },
334 "CP28599" "\0" "ISO-8859-9" "\0" 682 { "ar_SY", "CP864" },
335 "CP28605" "\0" "ISO-8859-15" "\0" 683 { "be", "CP866" },
336 "CP38598" "\0" "ISO-8859-8" "\0" 684 { "be_BE", "CP866" },
337 "CP51932" "\0" "EUC-JP" "\0" 685 { "bg", "CP866" }, /* not CP855 ?? */
338 "CP51936" "\0" "GB2312" "\0" 686 { "bg_BG", "CP866" }, /* not CP855 ?? */
339 "CP51949" "\0" "EUC-KR" "\0" 687 { "ca", "CP850" },
340 "CP51950" "\0" "EUC-TW" "\0" 688 { "ca_ES", "CP850" },
341 "CP54936" "\0" "GB18030" "\0" 689 { "cs", "CP852" },
342 "CP65001" "\0" "UTF-8" "\0"; 690 { "cs_CZ", "CP852" },
691 { "da", "CP865" }, /* not CP850 ?? */
692 { "da_DK", "CP865" }, /* not CP850 ?? */
693 { "de", "CP850" },
694 { "de_AT", "CP850" },
695 { "de_CH", "CP850" },
696 { "de_DE", "CP850" },
697 { "el", "CP869" },
698 { "el_GR", "CP869" },
699 { "en", "CP850" },
700 { "en_AU", "CP850" }, /* not CP437 ?? */
701 { "en_CA", "CP850" },
702 { "en_GB", "CP850" },
703 { "en_NZ", "CP437" },
704 { "en_US", "CP437" },
705 { "en_ZA", "CP850" }, /* not CP437 ?? */
706 { "eo", "CP850" },
707 { "eo_EO", "CP850" },
708 { "es", "CP850" },
709 { "es_AR", "CP850" },
710 { "es_BO", "CP850" },
711 { "es_CL", "CP850" },
712 { "es_CO", "CP850" },
713 { "es_CR", "CP850" },
714 { "es_CU", "CP850" },
715 { "es_DO", "CP850" },
716 { "es_EC", "CP850" },
717 { "es_ES", "CP850" },
718 { "es_GT", "CP850" },
719 { "es_HN", "CP850" },
720 { "es_MX", "CP850" },
721 { "es_NI", "CP850" },
722 { "es_PA", "CP850" },
723 { "es_PE", "CP850" },
724 { "es_PY", "CP850" },
725 { "es_SV", "CP850" },
726 { "es_UY", "CP850" },
727 { "es_VE", "CP850" },
728 { "et", "CP850" },
729 { "et_EE", "CP850" },
730 { "eu", "CP850" },
731 { "eu_ES", "CP850" },
732 { "fi", "CP850" },
733 { "fi_FI", "CP850" },
734 { "fr", "CP850" },
735 { "fr_BE", "CP850" },
736 { "fr_CA", "CP850" },
737 { "fr_CH", "CP850" },
738 { "fr_FR", "CP850" },
739 { "ga", "CP850" },
740 { "ga_IE", "CP850" },
741 { "gd", "CP850" },
742 { "gd_GB", "CP850" },
743 { "gl", "CP850" },
744 { "gl_ES", "CP850" },
745 { "he", "CP862" },
746 { "he_IL", "CP862" },
747 { "hr", "CP852" },
748 { "hr_HR", "CP852" },
749 { "hu", "CP852" },
750 { "hu_HU", "CP852" },
751 { "id", "CP850" }, /* not CP437 ?? */
752 { "id_ID", "CP850" }, /* not CP437 ?? */
753 { "is", "CP861" }, /* not CP850 ?? */
754 { "is_IS", "CP861" }, /* not CP850 ?? */
755 { "it", "CP850" },
756 { "it_CH", "CP850" },
757 { "it_IT", "CP850" },
758 { "ja", "CP932" },
759 { "ja_JP", "CP932" },
760 { "kr", "CP949" }, /* not CP934 ?? */
761 { "kr_KR", "CP949" }, /* not CP934 ?? */
762 { "lt", "CP775" },
763 { "lt_LT", "CP775" },
764 { "lv", "CP775" },
765 { "lv_LV", "CP775" },
766 { "mk", "CP866" }, /* not CP855 ?? */
767 { "mk_MK", "CP866" }, /* not CP855 ?? */
768 { "mt", "CP850" },
769 { "mt_MT", "CP850" },
770 { "nb", "CP865" }, /* not CP850 ?? */
771 { "nb_NO", "CP865" }, /* not CP850 ?? */
772 { "nl", "CP850" },
773 { "nl_BE", "CP850" },
774 { "nl_NL", "CP850" },
775 { "nn", "CP865" }, /* not CP850 ?? */
776 { "nn_NO", "CP865" }, /* not CP850 ?? */
777 { "no", "CP865" }, /* not CP850 ?? */
778 { "no_NO", "CP865" }, /* not CP850 ?? */
779 { "pl", "CP852" },
780 { "pl_PL", "CP852" },
781 { "pt", "CP850" },
782 { "pt_BR", "CP850" },
783 { "pt_PT", "CP850" },
784 { "ro", "CP852" },
785 { "ro_RO", "CP852" },
786 { "ru", "CP866" },
787 { "ru_RU", "CP866" },
788 { "sk", "CP852" },
789 { "sk_SK", "CP852" },
790 { "sl", "CP852" },
791 { "sl_SI", "CP852" },
792 { "sq", "CP852" },
793 { "sq_AL", "CP852" },
794 { "sr", "CP852" }, /* CP852 or CP866 or CP855 ?? */
795 { "sr_CS", "CP852" }, /* CP852 or CP866 or CP855 ?? */
796 { "sr_YU", "CP852" }, /* CP852 or CP866 or CP855 ?? */
797 { "sv", "CP850" },
798 { "sv_SE", "CP850" },
799 { "th", "CP874" },
800 { "th_TH", "CP874" },
801 { "tr", "CP857" },
802 { "tr_TR", "CP857" },
803 { "uk", "CP1125" },
804 { "uk_UA", "CP1125" },
805 { "zh_CN", "GBK" },
806 { "zh_TW", "CP950" } /* not CP938 ?? */
807# define locale_table_defined
343# endif 808# endif
344#endif 809# ifndef locale_table_defined
810 /* Just a dummy entry, to avoid a C syntax error. */
811 { "", "" }
812# endif
813 };
345 814
346 charset_aliases = cp; 815#endif
347 }
348 816
349 return cp;
350}
351 817
352/* Determine the current locale's character encoding, and canonicalize it 818/* Determine the current locale's character encoding, and canonicalize it
353 into one of the canonical names listed in config.charset. 819 into one of the canonical names listed below.
354 The result must not be freed; it is statically allocated. 820 The result must not be freed; it is statically allocated. The result
821 becomes invalid when setlocale() is used to change the global locale, or
822 when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
823 is changed; threads in multithreaded programs should not do this.
355 If the canonical name cannot be determined, the result is a non-canonical 824 If the canonical name cannot be determined, the result is a non-canonical
356 name. */ 825 name. */
357 826
@@ -362,9 +831,15 @@ const char *
362locale_charset (void) 831locale_charset (void)
363{ 832{
364 const char *codeset; 833 const char *codeset;
365 const char *aliases;
366 834
367#if !(defined WINDOWS_NATIVE || defined OS2) 835 /* This function must be multithread-safe. To achieve this without using
836 thread-local storage, we use a simple strcpy or memcpy to fill this static
837 buffer. Filling it through, for example, strcpy + strcat would not be
838 guaranteed to leave the buffer's contents intact if another thread is
839 currently accessing it. If necessary, the contents is first assembled in
840 a stack-allocated buffer. */
841
842#if HAVE_LANGINFO_CODESET || defined WINDOWS_NATIVE || defined OS2
368 843
369# if HAVE_LANGINFO_CODESET 844# if HAVE_LANGINFO_CODESET
370 845
@@ -378,7 +853,7 @@ locale_charset (void)
378 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) 853 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
379 { 854 {
380 const char *locale; 855 const char *locale;
381 static char buf[2 + 10 + 1]; 856 static char resultbuf[2 + 10 + 1];
382 857
383 locale = getenv ("LC_ALL"); 858 locale = getenv ("LC_ALL");
384 if (locale == NULL || locale[0] == '\0') 859 if (locale == NULL || locale[0] == '\0')
@@ -402,11 +877,12 @@ locale_charset (void)
402 modifier = strchr (dot, '@'); 877 modifier = strchr (dot, '@');
403 if (modifier == NULL) 878 if (modifier == NULL)
404 return dot; 879 return dot;
405 if (modifier - dot < sizeof (buf)) 880 if (modifier - dot < sizeof (resultbuf))
406 { 881 {
407 memcpy (buf, dot, modifier - dot); 882 /* This way of filling resultbuf is multithread-safe. */
408 buf [modifier - dot] = '\0'; 883 memcpy (resultbuf, dot, modifier - dot);
409 return buf; 884 resultbuf [modifier - dot] = '\0';
885 return resultbuf;
410 } 886 }
411 } 887 }
412 } 888 }
@@ -422,62 +898,65 @@ locale_charset (void)
422 converting to GetConsoleOutputCP(). This leads to correct results, 898 converting to GetConsoleOutputCP(). This leads to correct results,
423 except when SetConsoleOutputCP has been called and a raster font is 899 except when SetConsoleOutputCP has been called and a raster font is
424 in use. */ 900 in use. */
425 sprintf (buf, "CP%u", GetACP ()); 901 {
426 codeset = buf; 902 char buf[2 + 10 + 1];
427 }
428# endif
429
430# else
431
432 /* On old systems which lack it, use setlocale or getenv. */
433 const char *locale = NULL;
434 903
435 /* But most old systems don't have a complete set of locales. Some 904 sprintf (buf, "CP%u", GetACP ());
436 (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't 905 strcpy (resultbuf, buf);
437 use setlocale here; it would return "C" when it doesn't support the 906 codeset = resultbuf;
438 locale name the user has set. */ 907 }
439# if 0
440 locale = setlocale (LC_CTYPE, NULL);
441# endif
442 if (locale == NULL || locale[0] == '\0')
443 {
444 locale = getenv ("LC_ALL");
445 if (locale == NULL || locale[0] == '\0')
446 {
447 locale = getenv ("LC_CTYPE");
448 if (locale == NULL || locale[0] == '\0')
449 locale = getenv ("LANG");
450 }
451 } 908 }
909# endif
452 910
453 /* On some old systems, one used to set locale = "iso8859_1". On others, 911 if (codeset == NULL)
454 you set it to "language_COUNTRY.charset". In any case, we resolve it 912 /* The canonical name cannot be determined. */
455 through the charset.alias file. */ 913 codeset = "";
456 codeset = locale;
457 914
458# endif 915# elif defined WINDOWS_NATIVE
459 916
460#elif defined WINDOWS_NATIVE 917 char buf[2 + 10 + 1];
918 static char resultbuf[2 + 10 + 1];
461 919
462 static char buf[2 + 10 + 1]; 920 /* The Windows API has a function returning the locale's codepage as
921 a number, but the value doesn't change according to what the
922 'setlocale' call specified. So we use it as a last resort, in
923 case the string returned by 'setlocale' doesn't specify the
924 codepage. */
925 char *current_locale = setlocale (LC_CTYPE, NULL);
926 char *pdot = strrchr (current_locale, '.');
463 927
464 /* The Windows API has a function returning the locale's codepage as a 928 if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf))
465 number: GetACP(). 929 sprintf (buf, "CP%s", pdot + 1);
466 When the output goes to a console window, it needs to be provided in 930 else
467 GetOEMCP() encoding if the console is using a raster font, or in 931 {
468 GetConsoleOutputCP() encoding if it is using a TrueType font. 932 /* The Windows API has a function returning the locale's codepage as a
469 But in GUI programs and for output sent to files and pipes, GetACP() 933 number: GetACP().
470 encoding is the best bet. */ 934 When the output goes to a console window, it needs to be provided in
471 sprintf (buf, "CP%u", GetACP ()); 935 GetOEMCP() encoding if the console is using a raster font, or in
472 codeset = buf; 936 GetConsoleOutputCP() encoding if it is using a TrueType font.
937 But in GUI programs and for output sent to files and pipes, GetACP()
938 encoding is the best bet. */
939 sprintf (buf, "CP%u", GetACP ());
940 }
941 /* For a locale name such as "French_France.65001", in Windows 10,
942 setlocale now returns "French_France.utf8" instead. */
943 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
944 codeset = "UTF-8";
945 else
946 {
947 strcpy (resultbuf, buf);
948 codeset = resultbuf;
949 }
473 950
474#elif defined OS2 951# elif defined OS2
475 952
476 const char *locale; 953 const char *locale;
477 static char buf[2 + 10 + 1]; 954 static char resultbuf[2 + 10 + 1];
478 ULONG cp[3]; 955 ULONG cp[3];
479 ULONG cplen; 956 ULONG cplen;
480 957
958 codeset = NULL;
959
481 /* Allow user to override the codeset, as set in the operating system, 960 /* Allow user to override the codeset, as set in the operating system,
482 with standard language environment variables. */ 961 with standard language environment variables. */
483 locale = getenv ("LC_ALL"); 962 locale = getenv ("LC_ALL");
@@ -501,51 +980,173 @@ locale_charset (void)
501 modifier = strchr (dot, '@'); 980 modifier = strchr (dot, '@');
502 if (modifier == NULL) 981 if (modifier == NULL)
503 return dot; 982 return dot;
504 if (modifier - dot < sizeof (buf)) 983 if (modifier - dot < sizeof (resultbuf))
505 { 984 {
506 memcpy (buf, dot, modifier - dot); 985 /* This way of filling resultbuf is multithread-safe. */
507 buf [modifier - dot] = '\0'; 986 memcpy (resultbuf, dot, modifier - dot);
508 return buf; 987 resultbuf [modifier - dot] = '\0';
988 return resultbuf;
509 } 989 }
510 } 990 }
511 991
512 /* Resolve through the charset.alias file. */ 992 /* For the POSIX locale, don't use the system's codepage. */
513 codeset = locale; 993 if (strcmp (locale, "C") == 0 || strcmp (locale, "POSIX") == 0)
994 codeset = "";
514 } 995 }
515 else 996
997 if (codeset == NULL)
516 { 998 {
517 /* OS/2 has a function returning the locale's codepage as a number. */ 999 /* OS/2 has a function returning the locale's codepage as a number. */
518 if (DosQueryCp (sizeof (cp), cp, &cplen)) 1000 if (DosQueryCp (sizeof (cp), cp, &cplen))
519 codeset = ""; 1001 codeset = "";
520 else 1002 else
521 { 1003 {
1004 char buf[2 + 10 + 1];
1005
522 sprintf (buf, "CP%u", cp[0]); 1006 sprintf (buf, "CP%u", cp[0]);
523 codeset = buf; 1007 strcpy (resultbuf, buf);
1008 codeset = resultbuf;
524 } 1009 }
525 } 1010 }
526 1011
527#endif 1012# else
528 1013
529 if (codeset == NULL) 1014# error "Add code for other platforms here."
530 /* The canonical name cannot be determined. */ 1015
531 codeset = ""; 1016# endif
1017
1018 /* Resolve alias. */
1019 {
1020# ifdef alias_table_defined
1021 /* On some platforms, UTF-8 locales are the most frequently used ones.
1022 Speed up the common case and slow down the less common cases by
1023 testing for this case first. */
1024# if defined __OpenBSD__ || (defined __APPLE__ && defined __MACH__) || defined __sun || defined __CYGWIN__
1025 if (strcmp (codeset, "UTF-8") == 0)
1026 goto done_table_lookup;
1027 else
1028# endif
1029 {
1030 const struct table_entry * const table = alias_table;
1031 size_t const table_size =
1032 sizeof (alias_table) / sizeof (struct table_entry);
1033 /* The table is sorted. Perform a binary search. */
1034 size_t hi = table_size;
1035 size_t lo = 0;
1036 while (lo < hi)
1037 {
1038 /* Invariant:
1039 for i < lo, strcmp (table[i].alias, codeset) < 0,
1040 for i >= hi, strcmp (table[i].alias, codeset) > 0. */
1041 size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
1042 int cmp = strcmp (table[mid].alias, codeset);
1043 if (cmp < 0)
1044 lo = mid + 1;
1045 else if (cmp > 0)
1046 hi = mid;
1047 else
1048 {
1049 /* Found an i with
1050 strcmp (table[i].alias, codeset) == 0. */
1051 codeset = table[mid].canonical;
1052 goto done_table_lookup;
1053 }
1054 }
1055 }
1056 if (0)
1057 done_table_lookup: ;
1058 else
1059# endif
1060 {
1061 /* Did not find it in the table. */
1062 /* On Mac OS X, all modern locales use the UTF-8 encoding.
1063 BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
1064# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
1065 codeset = "UTF-8";
1066# else
1067 /* Don't return an empty string. GNU libc and GNU libiconv interpret
1068 the empty string as denoting "the locale's character encoding",
1069 thus GNU libiconv would call this function a second time. */
1070 if (codeset[0] == '\0')
1071 codeset = "ASCII";
1072# endif
1073 }
1074 }
1075
1076#else
532 1077
533 /* Resolve alias. */ 1078 /* On old systems which lack it, use setlocale or getenv. */
534 for (aliases = get_charset_aliases (); 1079 const char *locale = NULL;
535 *aliases != '\0'; 1080
536 aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) 1081 /* But most old systems don't have a complete set of locales. Some
537 if (strcmp (codeset, aliases) == 0 1082 (like DJGPP) have only the C locale. Therefore we don't use setlocale
538 || (aliases[0] == '*' && aliases[1] == '\0')) 1083 here; it would return "C" when it doesn't support the locale name the
1084 user has set. */
1085# if 0
1086 locale = setlocale (LC_CTYPE, NULL);
1087# endif
1088 if (locale == NULL || locale[0] == '\0')
1089 {
1090 locale = getenv ("LC_ALL");
1091 if (locale == NULL || locale[0] == '\0')
1092 {
1093 locale = getenv ("LC_CTYPE");
1094 if (locale == NULL || locale[0] == '\0')
1095 locale = getenv ("LANG");
1096 if (locale == NULL)
1097 locale = "";
1098 }
1099 }
1100
1101 /* Map locale name to canonical encoding name. */
1102 {
1103# ifdef locale_table_defined
1104 const struct table_entry * const table = locale_table;
1105 size_t const table_size =
1106 sizeof (locale_table) / sizeof (struct table_entry);
1107 /* The table is sorted. Perform a binary search. */
1108 size_t hi = table_size;
1109 size_t lo = 0;
1110 while (lo < hi)
539 { 1111 {
540 codeset = aliases + strlen (aliases) + 1; 1112 /* Invariant:
541 break; 1113 for i < lo, strcmp (table[i].locale, locale) < 0,
1114 for i >= hi, strcmp (table[i].locale, locale) > 0. */
1115 size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
1116 int cmp = strcmp (table[mid].locale, locale);
1117 if (cmp < 0)
1118 lo = mid + 1;
1119 else if (cmp > 0)
1120 hi = mid;
1121 else
1122 {
1123 /* Found an i with
1124 strcmp (table[i].locale, locale) == 0. */
1125 codeset = table[mid].canonical;
1126 goto done_table_lookup;
1127 }
1128 }
1129 if (0)
1130 done_table_lookup: ;
1131 else
1132# endif
1133 {
1134 /* Did not find it in the table. */
1135 /* On Mac OS X, all modern locales use the UTF-8 encoding.
1136 BeOS and Haiku have a single locale, and it has UTF-8 encoding. */
1137# if (defined __APPLE__ && defined __MACH__) || defined __BEOS__ || defined __HAIKU__
1138 codeset = "UTF-8";
1139# else
1140 /* The canonical name cannot be determined. */
1141 /* Don't return an empty string. GNU libc and GNU libiconv interpret
1142 the empty string as denoting "the locale's character encoding",
1143 thus GNU libiconv would call this function a second time. */
1144 codeset = "ASCII";
1145# endif
542 } 1146 }
1147 }
543 1148
544 /* Don't return an empty string. GNU libc and GNU libiconv interpret 1149#endif
545 the empty string as denoting "the locale's character encoding",
546 thus GNU libiconv would call this function a second time. */
547 if (codeset[0] == '\0')
548 codeset = "ASCII";
549 1150
550#ifdef DARWIN7 1151#ifdef DARWIN7
551 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8" 1152 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
diff --git a/gl/localcharset.h b/gl/localcharset.h
index c209829..29ee8dc 100644
--- a/gl/localcharset.h
+++ b/gl/localcharset.h
@@ -1,19 +1,19 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2000-2003, 2009-2023 Free Software Foundation, Inc.
3 This file is part of the GNU CHARSET Library. 3 This file is part of the GNU CHARSET Library.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _LOCALCHARSET_H 18#ifndef _LOCALCHARSET_H
19#define _LOCALCHARSET_H 19#define _LOCALCHARSET_H
@@ -25,12 +25,109 @@ extern "C" {
25 25
26 26
27/* Determine the current locale's character encoding, and canonicalize it 27/* Determine the current locale's character encoding, and canonicalize it
28 into one of the canonical names listed in config.charset. 28 into one of the canonical names listed below.
29 The result must not be freed; it is statically allocated. 29 The result must not be freed; it is statically allocated. The result
30 becomes invalid when setlocale() is used to change the global locale, or
31 when the value of one of the environment variables LC_ALL, LC_CTYPE, LANG
32 is changed; threads in multithreaded programs should not do this.
30 If the canonical name cannot be determined, the result is a non-canonical 33 If the canonical name cannot be determined, the result is a non-canonical
31 name. */ 34 name. */
32extern const char * locale_charset (void); 35extern const char * locale_charset (void);
33 36
37/* About GNU canonical names for character encodings:
38
39 Every canonical name must be supported by GNU libiconv. Support by GNU libc
40 is also desirable.
41
42 The name is case insensitive. Usually an upper case MIME charset name is
43 preferred.
44
45 The current list of these GNU canonical names is:
46
47 name MIME? used by which systems
48 (darwin = Mac OS X, windows = native Windows)
49
50 ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin minix cygwin
51 ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
52 ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
53 ISO-8859-3 Y glibc solaris cygwin
54 ISO-8859-4 Y hpux osf solaris freebsd netbsd openbsd darwin
55 ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
56 ISO-8859-6 Y glibc aix hpux solaris cygwin
57 ISO-8859-7 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin zos
58 ISO-8859-8 Y glibc aix hpux osf solaris cygwin zos
59 ISO-8859-9 Y glibc aix hpux irix osf solaris freebsd darwin cygwin zos
60 ISO-8859-13 glibc hpux solaris freebsd netbsd openbsd darwin cygwin
61 ISO-8859-14 glibc cygwin
62 ISO-8859-15 glibc aix irix osf solaris freebsd netbsd openbsd darwin cygwin
63 KOI8-R Y glibc hpux solaris freebsd netbsd openbsd darwin
64 KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
65 KOI8-T glibc
66 CP437 dos
67 CP775 dos
68 CP850 aix osf dos
69 CP852 dos
70 CP855 dos
71 CP856 aix
72 CP857 dos
73 CP861 dos
74 CP862 dos
75 CP864 dos
76 CP865 dos
77 CP866 freebsd netbsd openbsd darwin dos
78 CP869 dos
79 CP874 windows dos
80 CP922 aix
81 CP932 aix cygwin windows dos
82 CP943 aix zos
83 CP949 osf darwin windows dos
84 CP950 windows dos
85 CP1046 aix
86 CP1124 aix
87 CP1125 dos
88 CP1129 aix
89 CP1131 freebsd darwin
90 CP1250 windows
91 CP1251 glibc hpux solaris freebsd netbsd openbsd darwin cygwin windows
92 CP1252 aix windows
93 CP1253 windows
94 CP1254 windows
95 CP1255 glibc windows
96 CP1256 windows
97 CP1257 windows
98 GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin cygwin zos
99 EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
100 EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin zos
101 EUC-TW glibc aix hpux irix osf solaris netbsd
102 BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin zos
103 BIG5-HKSCS glibc hpux solaris netbsd darwin
104 GBK glibc aix osf solaris freebsd darwin cygwin windows dos
105 GB18030 glibc hpux solaris freebsd netbsd darwin
106 SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
107 JOHAB glibc solaris windows
108 TIS-620 glibc aix hpux osf solaris cygwin zos
109 VISCII Y glibc
110 TCVN5712-1 glibc
111 ARMSCII-8 glibc freebsd netbsd darwin
112 GEORGIAN-PS glibc cygwin
113 PT154 glibc netbsd cygwin
114 HP-ROMAN8 hpux
115 HP-ARABIC8 hpux
116 HP-GREEK8 hpux
117 HP-HEBREW8 hpux
118 HP-TURKISH8 hpux
119 HP-KANA8 hpux
120 DEC-KANJI osf
121 DEC-HANYU osf
122 UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin zos
123
124 Note: Names which are not marked as being a MIME name should not be used in
125 Internet protocols for information interchange (mail, news, etc.).
126
127 Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
128 must understand both names and treat them as equivalent.
129 */
130
34 131
35#ifdef __cplusplus 132#ifdef __cplusplus
36} 133}
diff --git a/gl/locale.in.h b/gl/locale.in.h
index 264161a..538b834 100644
--- a/gl/locale.in.h
+++ b/gl/locale.in.h
@@ -1,28 +1,31 @@
1/* A POSIX <locale.h>. 1/* A POSIX <locale.h>.
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#if __GNUC__ >= 3 17#if __GNUC__ >= 3
18@PRAGMA_SYSTEM_HEADER@ 18@PRAGMA_SYSTEM_HEADER@
19#endif 19#endif
20@PRAGMA_COLUMNS@ 20@PRAGMA_COLUMNS@
21 21
22#ifdef _GL_ALREADY_INCLUDING_LOCALE_H 22#if (defined _WIN32 && !defined __CYGWIN__ && defined __need_locale_t) \
23 || defined _GL_ALREADY_INCLUDING_LOCALE_H
23 24
24/* Special invocation conventions to handle Solaris header files 25/* Special invocation convention:
25 (through Solaris 10) when combined with gettext's libintl.h. */ 26 - Inside mingw header files,
27 - To handle Solaris header files (through Solaris 10) when combined
28 with gettext's libintl.h. */
26 29
27#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ 30#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
28 31
@@ -61,6 +64,18 @@
61# define LC_MESSAGES 1729 64# define LC_MESSAGES 1729
62#endif 65#endif
63 66
67/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
68 int_n_*. Instead of overriding 'struct lconv', merely define these member
69 names as macros. This avoids trouble in C++ mode. */
70#if defined _MSC_VER
71# define int_p_cs_precedes p_cs_precedes
72# define int_p_sign_posn p_sign_posn
73# define int_p_sep_by_space p_sep_by_space
74# define int_n_cs_precedes n_cs_precedes
75# define int_n_sign_posn n_sign_posn
76# define int_n_sep_by_space n_sep_by_space
77#endif
78
64/* Bionic libc's 'struct lconv' is just a dummy. */ 79/* Bionic libc's 'struct lconv' is just a dummy. */
65#if @REPLACE_STRUCT_LCONV@ 80#if @REPLACE_STRUCT_LCONV@
66# define lconv rpl_lconv 81# define lconv rpl_lconv
@@ -69,7 +84,7 @@ struct lconv
69 /* All 'char *' are actually 'const char *'. */ 84 /* All 'char *' are actually 'const char *'. */
70 85
71 /* Members that depend on the LC_NUMERIC category of the locale. See 86 /* Members that depend on the LC_NUMERIC category of the locale. See
72 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */ 87 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
73 88
74 /* Symbol used as decimal point. */ 89 /* Symbol used as decimal point. */
75 char *decimal_point; 90 char *decimal_point;
@@ -81,7 +96,7 @@ struct lconv
81 char *grouping; 96 char *grouping;
82 97
83 /* Members that depend on the LC_MONETARY category of the locale. See 98 /* Members that depend on the LC_MONETARY category of the locale. See
84 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */ 99 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
85 100
86 /* Symbol used as decimal point. */ 101 /* Symbol used as decimal point. */
87 char *mon_decimal_point; 102 char *mon_decimal_point;
@@ -153,7 +168,9 @@ _GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
153# else 168# else
154_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void)); 169_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
155# endif 170# endif
171# if __GLIBC__ >= 2
156_GL_CXXALIASWARN (localeconv); 172_GL_CXXALIASWARN (localeconv);
173# endif
157#elif @REPLACE_STRUCT_LCONV@ 174#elif @REPLACE_STRUCT_LCONV@
158# undef localeconv 175# undef localeconv
159# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv 176# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
@@ -178,7 +195,9 @@ _GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
178# else 195# else
179_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale)); 196_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
180# endif 197# endif
198# if __GLIBC__ >= 2
181_GL_CXXALIASWARN (setlocale); 199_GL_CXXALIASWARN (setlocale);
200# endif
182#elif defined GNULIB_POSIXCHECK 201#elif defined GNULIB_POSIXCHECK
183# undef setlocale 202# undef setlocale
184# if HAVE_RAW_DECL_SETLOCALE 203# if HAVE_RAW_DECL_SETLOCALE
@@ -187,11 +206,50 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
187# endif 206# endif
188#endif 207#endif
189 208
190#if @GNULIB_DUPLOCALE@ 209#if @GNULIB_SETLOCALE_NULL@
210/* Included here for convenience. */
211# include "setlocale_null.h"
212#endif
213
214#if /*@GNULIB_NEWLOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_NEWLOCALE@)
215# if @REPLACE_NEWLOCALE@
216# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
217# undef newlocale
218# define newlocale rpl_newlocale
219# define GNULIB_defined_newlocale 1
220# endif
221_GL_FUNCDECL_RPL (newlocale, locale_t,
222 (int category_mask, const char *name, locale_t base)
223 _GL_ARG_NONNULL ((2)));
224_GL_CXXALIAS_RPL (newlocale, locale_t,
225 (int category_mask, const char *name, locale_t base));
226# else
227# if @HAVE_NEWLOCALE@
228_GL_CXXALIAS_SYS (newlocale, locale_t,
229 (int category_mask, const char *name, locale_t base));
230# endif
231# endif
232# if @HAVE_NEWLOCALE@
233_GL_CXXALIASWARN (newlocale);
234# endif
235# if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
236# ifndef HAVE_WORKING_NEWLOCALE
237# define HAVE_WORKING_NEWLOCALE 1
238# endif
239# endif
240#elif defined GNULIB_POSIXCHECK
241# undef newlocale
242# if HAVE_RAW_DECL_NEWLOCALE
243_GL_WARN_ON_USE (newlocale, "newlocale is not portable");
244# endif
245#endif
246
247#if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@)
191# if @REPLACE_DUPLOCALE@ 248# if @REPLACE_DUPLOCALE@
192# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 249# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
193# undef duplocale 250# undef duplocale
194# define duplocale rpl_duplocale 251# define duplocale rpl_duplocale
252# define GNULIB_defined_duplocale 1
195# endif 253# endif
196_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); 254_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1)));
197_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); 255_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
@@ -203,6 +261,11 @@ _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
203# if @HAVE_DUPLOCALE@ 261# if @HAVE_DUPLOCALE@
204_GL_CXXALIASWARN (duplocale); 262_GL_CXXALIASWARN (duplocale);
205# endif 263# endif
264# if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
265# ifndef HAVE_WORKING_DUPLOCALE
266# define HAVE_WORKING_DUPLOCALE 1
267# endif
268# endif
206#elif defined GNULIB_POSIXCHECK 269#elif defined GNULIB_POSIXCHECK
207# undef duplocale 270# undef duplocale
208# if HAVE_RAW_DECL_DUPLOCALE 271# if HAVE_RAW_DECL_DUPLOCALE
@@ -211,6 +274,32 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
211# endif 274# endif
212#endif 275#endif
213 276
277#if /*@GNULIB_FREELOCALE@ ||*/ (@GNULIB_LOCALENAME@ && @LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_FREELOCALE@)
278# if @REPLACE_FREELOCALE@
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# undef freelocale
281# define freelocale rpl_freelocale
282# define GNULIB_defined_freelocale 1
283# endif
284_GL_FUNCDECL_RPL (freelocale, void, (locale_t locale) _GL_ARG_NONNULL ((1)));
285_GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
286# else
287# if @HAVE_FREELOCALE@
288/* Need to cast, because on FreeBSD and Mac OS X 10.13, the return type is
289 int. */
290_GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
291# endif
292# endif
293# if @HAVE_FREELOCALE@
294_GL_CXXALIASWARN (freelocale);
295# endif
296#elif defined GNULIB_POSIXCHECK
297# undef freelocale
298# if HAVE_RAW_DECL_FREELOCALE
299_GL_WARN_ON_USE (freelocale, "freelocale is not portable");
300# endif
301#endif
302
214#endif /* _@GUARD_PREFIX@_LOCALE_H */ 303#endif /* _@GUARD_PREFIX@_LOCALE_H */
215#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
216#endif /* _@GUARD_PREFIX@_LOCALE_H */ 304#endif /* _@GUARD_PREFIX@_LOCALE_H */
305#endif /* !(__need_locale_t || _GL_ALREADY_INCLUDING_LOCALE_H) */
diff --git a/gl/localeconv.c b/gl/localeconv.c
index 7c7c77c..60c050f 100644
--- a/gl/localeconv.c
+++ b/gl/localeconv.c
@@ -1,18 +1,18 @@
1/* Query locale dependent information for formatting numbers. 1/* Query locale dependent information for formatting numbers.
2 Copyright (C) 2012-2013 Free Software Foundation, Inc. 2 Copyright (C) 2012-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/lseek.c b/gl/lseek.c
new file mode 100644
index 0000000..7919b03
--- /dev/null
+++ b/gl/lseek.c
@@ -0,0 +1,89 @@
1/* An lseek() function that detects pipes.
2 Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include <unistd.h>
21
22#if defined _WIN32 && ! defined __CYGWIN__
23/* Windows platforms. */
24/* Get GetFileType. */
25# include <windows.h>
26/* Get _get_osfhandle. */
27# if GNULIB_MSVC_NOTHROW
28# include "msvc-nothrow.h"
29# else
30# include <io.h>
31# endif
32#else
33# include <sys/stat.h>
34#endif
35#include <errno.h>
36
37#undef lseek
38
39off_t
40rpl_lseek (int fd, off_t offset, int whence)
41{
42#if defined _WIN32 && ! defined __CYGWIN__
43 /* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
44 HANDLE h = (HANDLE) _get_osfhandle (fd);
45 if (h == INVALID_HANDLE_VALUE)
46 {
47 errno = EBADF;
48 return -1;
49 }
50 if (GetFileType (h) != FILE_TYPE_DISK)
51 {
52 errno = ESPIPE;
53 return -1;
54 }
55#elif defined __APPLE__ && defined __MACH__ && defined SEEK_DATA
56 if (whence == SEEK_DATA)
57 {
58 /* If OFFSET points to data, macOS lseek+SEEK_DATA returns the
59 start S of the first data region that begins *after* OFFSET,
60 where the region from OFFSET to S consists of possibly-empty
61 data followed by a possibly-empty hole. To work around this
62 portability glitch, check whether OFFSET is within data by
63 using lseek+SEEK_HOLE, and if so return to OFFSET by using
64 lseek+SEEK_SET. Also, contrary to the macOS documentation,
65 lseek+SEEK_HOLE can fail with ENXIO if there are no holes on
66 or after OFFSET. What a mess! */
67 off_t next_hole = lseek (fd, offset, SEEK_HOLE);
68 if (next_hole < 0)
69 return errno == ENXIO ? offset : next_hole;
70 if (next_hole != offset)
71 whence = SEEK_SET;
72 }
73#else
74 /* BeOS lseek mistakenly succeeds on pipes... */
75 struct stat statbuf;
76 if (fstat (fd, &statbuf) < 0)
77 return -1;
78 if (!S_ISREG (statbuf.st_mode))
79 {
80 errno = ESPIPE;
81 return -1;
82 }
83#endif
84#if _GL_WINDOWS_64_BIT_OFF_T || (defined __MINGW32__ && defined _FILE_OFFSET_BITS && (_FILE_OFFSET_BITS == 64))
85 return _lseeki64 (fd, offset, whence);
86#else
87 return lseek (fd, offset, whence);
88#endif
89}
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4
index d4ad759..7fe03e0 100644
--- a/gl/m4/00gnulib.m4
+++ b/gl/m4/00gnulib.m4
@@ -1,27 +1,82 @@
1# 00gnulib.m4 serial 2 1# 00gnulib.m4 serial 8
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl This file must be named something that sorts before all other 7dnl This file must be named something that sorts before all other
8dnl gnulib-provided .m4 files. It is needed until such time as we can 8dnl gnulib-provided .m4 files. It is needed until the clang fix has
9dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. 9dnl been included in Autoconf.
10 10
11# AC_DEFUN_ONCE([NAME], VALUE) 11# The following definitions arrange to use a compiler option
12# ---------------------------- 12# -Werror=implicit-function-declaration in AC_CHECK_DECL, when the
13# Define NAME to expand to VALUE on the first use (whether by direct 13# compiler is clang. Without it, clang implicitly declares "known"
14# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. 14# library functions in C mode, but not in C++ mode, which would cause
15# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This 15# Gnulib to omit a declaration and thus later produce an error in C++
16# definition is slower than the version in Autoconf 2.64, because it 16# mode. As of clang 9.0, these "known" functions are identified through
17# can only use interfaces that existed since 2.59; but it achieves the 17# LIBBUILTIN invocations in the LLVM source file
18# same effect. Quoting is necessary to avoid confusing Automake. 18# llvm/tools/clang/include/clang/Basic/Builtins.def.
19m4_version_prereq([2.63.263], [], 19# It's not possible to AC_REQUIRE the extra tests from AC_CHECK_DECL,
20[m4_define([AC][_DEFUN_ONCE], 20# because AC_CHECK_DECL, like other Autoconf built-ins, is not supposed
21 [AC][_DEFUN([$1], 21# to AC_REQUIRE anything: some configure.ac files have their first
22 [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], 22# AC_CHECK_DECL executed conditionally. Therefore append the extra tests
23 [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl 23# to AC_PROG_CC.
24[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) 24AC_DEFUN([gl_COMPILER_CLANG],
25[
26dnl AC_REQUIRE([AC_PROG_CC])
27 AC_CACHE_CHECK([whether the compiler is clang],
28 [gl_cv_compiler_clang],
29 [dnl Use _AC_COMPILE_IFELSE instead of AC_EGREP_CPP, to avoid error
30 dnl "circular dependency of AC_LANG_COMPILER(C)" if AC_PROG_CC has
31 dnl not yet been invoked.
32 _AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM([[
34 #ifdef __clang__
35 barfbarf
36 #endif
37 ]],[[]])
38 ],
39 [gl_cv_compiler_clang=no],
40 [gl_cv_compiler_clang=yes])
41 ])
42])
43AC_DEFUN([gl_COMPILER_PREPARE_CHECK_DECL],
44[
45dnl AC_REQUIRE([AC_PROG_CC])
46dnl AC_REQUIRE([gl_COMPILER_CLANG])
47 AC_CACHE_CHECK([for compiler option needed when checking for declarations],
48 [gl_cv_compiler_check_decl_option],
49 [if test $gl_cv_compiler_clang = yes; then
50 dnl Test whether the compiler supports the option
51 dnl '-Werror=implicit-function-declaration'.
52 save_ac_compile="$ac_compile"
53 ac_compile="$ac_compile -Werror=implicit-function-declaration"
54 dnl Use _AC_COMPILE_IFELSE instead of AC_COMPILE_IFELSE, to avoid a
55 dnl warning "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
56 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
57 [gl_cv_compiler_check_decl_option='-Werror=implicit-function-declaration'],
58 [gl_cv_compiler_check_decl_option=none])
59 ac_compile="$save_ac_compile"
60 else
61 gl_cv_compiler_check_decl_option=none
62 fi
63 ])
64 if test "x$gl_cv_compiler_check_decl_option" != xnone; then
65 ac_compile_for_check_decl="$ac_compile $gl_cv_compiler_check_decl_option"
66 else
67 ac_compile_for_check_decl="$ac_compile"
68 fi
69])
70dnl Redefine _AC_CHECK_DECL_BODY so that it references ac_compile_for_check_decl
71dnl instead of ac_compile. If, for whatever reason, the override of AC_PROG_CC
72dnl in zzgnulib.m4 is inactive, use the original ac_compile.
73m4_define([_AC_CHECK_DECL_BODY],
74[ ac_save_ac_compile="$ac_compile"
75 if test -n "$ac_compile_for_check_decl"; then
76 ac_compile="$ac_compile_for_check_decl"
77 fi]
78m4_defn([_AC_CHECK_DECL_BODY])[ ac_compile="$ac_save_ac_compile"
79])
25 80
26# gl_00GNULIB 81# gl_00GNULIB
27# ----------- 82# -----------
diff --git a/gl/m4/__inline.m4 b/gl/m4/__inline.m4
new file mode 100644
index 0000000..acf8668
--- /dev/null
+++ b/gl/m4/__inline.m4
@@ -0,0 +1,22 @@
1# Test for __inline keyword
2dnl Copyright 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl___INLINE],
8[
9 AC_CACHE_CHECK([whether the compiler supports the __inline keyword],
10 [gl_cv_c___inline],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_PROGRAM(
13 [[typedef int foo_t;
14 static __inline foo_t foo (void) { return 0; }]],
15 [[return foo ();]])],
16 [gl_cv_c___inline=yes],
17 [gl_cv_c___inline=no])])
18 if test $gl_cv_c___inline = yes; then
19 AC_DEFINE([HAVE___INLINE], [1],
20 [Define to 1 if the compiler supports the keyword '__inline'.])
21 fi
22])
diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4
new file mode 100644
index 0000000..e794764
--- /dev/null
+++ b/gl/m4/absolute-header.m4
@@ -0,0 +1,100 @@
1# absolute-header.m4 serial 17
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price.
8
9# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
10# ---------------------------------------
11# Find the absolute name of a header file, testing first if the header exists.
12# If the header were sys/inttypes.h, this macro would define
13# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h
14# in config.h
15# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
16# The three "///" are to pacify Sun C 5.8, which otherwise would say
17# "warning: #include of /usr/include/... may be non-portable".
18# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
19# Note: This macro assumes that the header file is not empty after
20# preprocessing, i.e. it does not only define preprocessor macros but also
21# provides some type/enum definitions or function/variable declarations.
22AC_DEFUN([gl_ABSOLUTE_HEADER],
23[AC_REQUIRE([AC_CANONICAL_HOST])
24AC_LANG_PREPROC_REQUIRE()dnl
25m4_foreach_w([gl_HEADER_NAME], [$1],
26 [AS_VAR_PUSHDEF([gl_absolute_header],
27 [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
28 AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
29 [gl_absolute_header],
30 [AS_VAR_PUSHDEF([ac_header_exists],
31 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
32 AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
33 if test AS_VAR_GET([ac_header_exists]) = yes; then
34 gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
35 fi
36 AS_VAR_POPDEF([ac_header_exists])dnl
37 ])dnl
38 AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
39 ["AS_VAR_GET([gl_absolute_header])"],
40 [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
41 AS_VAR_POPDEF([gl_absolute_header])dnl
42])dnl
43])# gl_ABSOLUTE_HEADER
44
45# gl_ABSOLUTE_HEADER_ONE(HEADER)
46# ------------------------------
47# Like gl_ABSOLUTE_HEADER, except that:
48# - it assumes that the header exists,
49# - it uses the current CPPFLAGS,
50# - it does not cache the result,
51# - it is silent.
52AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
53[
54 AC_REQUIRE([AC_CANONICAL_HOST])
55 AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
56 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
57 dnl that contain only a #include of other header files and no
58 dnl non-comment tokens of their own. This leads to a failure to
59 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
60 dnl and others. The workaround is to force preservation of comments
61 dnl through option -C. This ensures all necessary #line directives
62 dnl are present. GCC supports option -C as well.
63 case "$host_os" in
64 aix*) gl_absname_cpp="$ac_cpp -C" ;;
65 *) gl_absname_cpp="$ac_cpp" ;;
66 esac
67changequote(,)
68 case "$host_os" in
69 mingw*)
70 dnl For the sake of native Windows compilers (excluding gcc),
71 dnl treat backslash as a directory separator, like /.
72 dnl Actually, these compilers use a double-backslash as
73 dnl directory separator, inside the
74 dnl # line "filename"
75 dnl directives.
76 gl_dirsep_regex='[/\\]'
77 ;;
78 *)
79 gl_dirsep_regex='\/'
80 ;;
81 esac
82 dnl A sed expression that turns a string into a basic regular
83 dnl expression, for use within "/.../".
84 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
85 gl_header_literal_regex=`echo '$1' \
86 | sed -e "$gl_make_literal_regex_sed"`
87 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
88 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
89 s|^/[^/]|//&|
90 p
91 q
92 }'
93changequote([,])
94 dnl eval is necessary to expand gl_absname_cpp.
95 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
96 dnl so use subshell.
97 AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
98[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
99 sed -n "$gl_absolute_header_sed"`])
100])
diff --git a/gl/m4/af_alg.m4 b/gl/m4/af_alg.m4
new file mode 100644
index 0000000..f4c0d62
--- /dev/null
+++ b/gl/m4/af_alg.m4
@@ -0,0 +1,57 @@
1# af_alg.m4 serial 6
2dnl Copyright 2018-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Matteo Croce.
8
9AC_DEFUN_ONCE([gl_AF_ALG],
10[
11 AC_REQUIRE([gl_SYS_SOCKET_H])
12 AC_REQUIRE([AC_C_INLINE])
13
14 dnl Check whether linux/if_alg.h has needed features.
15 AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
16 [gl_cv_header_linux_if_alg_salg],
17 [AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM([[#include <sys/socket.h>
19 #include <linux/if_alg.h>
20 struct sockaddr_alg salg = {
21 .salg_family = AF_ALG,
22 .salg_type = "hash",
23 .salg_name = "sha1",
24 };]])],
25 [gl_cv_header_linux_if_alg_salg=yes],
26 [gl_cv_header_linux_if_alg_salg=no])])
27 if test "$gl_cv_header_linux_if_alg_salg" = yes; then
28 AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
29 [Define to 1 if you have 'struct sockaddr_alg' defined.])
30 fi
31
32 dnl The default is to not use AF_ALG if available,
33 dnl as it's system dependent as to whether the kernel
34 dnl routines are faster than libcrypto for example.
35 use_af_alg=no
36 AC_ARG_WITH([linux-crypto],
37 [AS_HELP_STRING([[--with-linux-crypto]],
38 [use Linux kernel cryptographic API (if available) for the hash functions
39 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])],
40 [use_af_alg=$withval],
41 [use_af_alg=no])
42 dnl We cannot use it if it is not available.
43 if test "$gl_cv_header_linux_if_alg_salg" != yes; then
44 if test "$use_af_alg" != no; then
45 AC_MSG_WARN([Linux kernel cryptographic API not found])
46 fi
47 use_af_alg=no
48 fi
49
50 if test "$use_af_alg" != no; then
51 USE_AF_ALG=1
52 else
53 USE_AF_ALG=0
54 fi
55 AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
56 [Define to 1 if you want to use the Linux kernel cryptographic API.])
57])
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index 270abd0..c685fac 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,5 +1,5 @@
1# alloca.m4 serial 14 1# alloca.m4 serial 21
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -26,30 +26,35 @@ AC_DEFUN([gl_FUNC_ALLOCA],
26 AC_DEFINE([HAVE_ALLOCA], [1], 26 AC_DEFINE([HAVE_ALLOCA], [1],
27 [Define to 1 if you have 'alloca' after including <alloca.h>, 27 [Define to 1 if you have 'alloca' after including <alloca.h>,
28 a header that may be supplied by this distribution.]) 28 a header that may be supplied by this distribution.])
29 ALLOCA_H=alloca.h 29 GL_GENERATE_ALLOCA_H=true
30 else 30 else
31 dnl alloca exists as a library function, i.e. it is slow and probably 31 dnl alloca exists as a library function, i.e. it is slow and probably
32 dnl a memory leak. Don't define HAVE_ALLOCA in this case. 32 dnl a memory leak. Don't define HAVE_ALLOCA in this case.
33 ALLOCA_H= 33 GL_GENERATE_ALLOCA_H=false
34 fi 34 fi
35 else 35 else
36 ALLOCA_H=alloca.h 36 GL_GENERATE_ALLOCA_H=true
37 fi 37 fi
38 AC_SUBST([ALLOCA_H]) 38
39 AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"]) 39 if test $ac_cv_working_alloca_h = yes; then
40 HAVE_ALLOCA_H=1
41 else
42 HAVE_ALLOCA_H=0
43 fi
44 AC_SUBST([HAVE_ALLOCA_H])
40]) 45])
41 46
42# Prerequisites of lib/alloca.c. 47# Prerequisites of lib/alloca.c.
43# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. 48# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
44AC_DEFUN([gl_PREREQ_ALLOCA], [:]) 49AC_DEFUN([gl_PREREQ_ALLOCA], [:])
45 50
46# This works around a bug in autoconf <= 2.68. 51m4_version_prereq([2.70], [], [
47# See <http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
48 52
49m4_version_prereq([2.69], [] ,[ 53# This works around a bug in autoconf <= 2.68 and has simplifications
50 54# from 2.70. See:
51# This is taken from the following Autoconf patch: 55# https://lists.gnu.org/r/bug-gnulib/2011-06/msg00277.html
52# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497 56# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
57# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=15edf7fd8094fd14a89d9891dd72a9624762597a
53 58
54# _AC_LIBOBJ_ALLOCA 59# _AC_LIBOBJ_ALLOCA
55# ----------------- 60# -----------------
@@ -65,26 +70,6 @@ AC_LIBSOURCES(alloca.c)
65AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl 70AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
66AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.]) 71AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
67 72
68AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray,
69[AC_EGREP_CPP(webecray,
70[#if defined CRAY && ! defined CRAY2
71webecray
72#else
73wenotbecray
74#endif
75], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
76if test $ac_cv_os_cray = yes; then
77 for ac_func in _getb67 GETB67 getb67; do
78 AC_CHECK_FUNC($ac_func,
79 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
80 [Define to one of '_getb67', 'GETB67',
81 'getb67' for Cray-2 and Cray-YMP
82 systems. This function is required for
83 'alloca.c' support on those systems.])
84 break])
85 done
86fi
87
88AC_CACHE_CHECK([stack direction for C alloca], 73AC_CACHE_CHECK([stack direction for C alloca],
89 [ac_cv_c_stack_direction], 74 [ac_cv_c_stack_direction],
90[AC_RUN_IFELSE([AC_LANG_SOURCE( 75[AC_RUN_IFELSE([AC_LANG_SOURCE(
@@ -115,7 +100,7 @@ AH_VERBATIM([STACK_DIRECTION],
115 STACK_DIRECTION > 0 => grows toward higher addresses 100 STACK_DIRECTION > 0 => grows toward higher addresses
116 STACK_DIRECTION < 0 => grows toward lower addresses 101 STACK_DIRECTION < 0 => grows toward lower addresses
117 STACK_DIRECTION = 0 => direction of growth unknown */ 102 STACK_DIRECTION = 0 => direction of growth unknown */
118@%:@undef STACK_DIRECTION])dnl 103#undef STACK_DIRECTION])dnl
119AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) 104AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
120])# _AC_LIBOBJ_ALLOCA 105])# _AC_LIBOBJ_ALLOCA
121]) 106])
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index ea69af5..fa5fe83 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,15 +1,15 @@
1# arpa_inet_h.m4 serial 13 1# arpa_inet_h.m4 serial 17
2dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson and Bruno Haible 7dnl Written by Simon Josefsson and Bruno Haible
8 8
9AC_DEFUN([gl_HEADER_ARPA_INET], 9AC_DEFUN_ONCE([gl_ARPA_INET_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) 13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
14 14
15 AC_CHECK_HEADERS_ONCE([arpa/inet.h]) 15 AC_CHECK_HEADERS_ONCE([arpa/inet.h])
@@ -24,6 +24,8 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
24 24
25 AC_REQUIRE([gl_FEATURES_H]) 25 AC_REQUIRE([gl_FEATURES_H])
26 26
27 gl_PREREQ_SYS_H_WS2TCPIP
28
27 dnl Check for declarations of anything we want to poison if the 29 dnl Check for declarations of anything we want to poison if the
28 dnl corresponding gnulib module is not in use. 30 dnl corresponding gnulib module is not in use.
29 gl_WARN_ON_USE_PREPARE([[ 31 gl_WARN_ON_USE_PREPARE([[
@@ -38,17 +40,32 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
38 ]], [inet_ntop inet_pton]) 40 ]], [inet_ntop inet_pton])
39]) 41])
40 42
43# gl_ARPA_INET_MODULE_INDICATOR([modulename])
44# sets the shell variable that indicates the presence of the given module
45# to a C preprocessor expression that will evaluate to 1.
46# This macro invocation must not occur in macros that are AC_REQUIREd.
41AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], 47AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
42[ 48[
43 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 49 dnl Ensure to expand the default settings once only.
44 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) 50 gl_ARPA_INET_H_REQUIRE_DEFAULTS
45 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 51 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
46]) 52])
47 53
54# Initializes the default values for AC_SUBSTed shell variables.
55# This macro must not be AC_REQUIREd. It must only be invoked, and only
56# outside of macros or in macros that are not AC_REQUIREd.
57AC_DEFUN([gl_ARPA_INET_H_REQUIRE_DEFAULTS],
58[
59 m4_defun(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS], [
60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_NTOP])
61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_INET_PTON])
62 ])
63 m4_require(GL_MODULE_INDICATOR_PREFIX[_ARPA_INET_H_MODULE_INDICATOR_DEFAULTS])
64 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
65])
66
48AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], 67AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
49[ 68[
50 GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
51 GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
52 dnl Assume proper GNU behavior unless another module says otherwise. 69 dnl Assume proper GNU behavior unless another module says otherwise.
53 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) 70 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
54 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) 71 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
diff --git a/gl/m4/assert_h.m4 b/gl/m4/assert_h.m4
new file mode 100644
index 0000000..abba4fa
--- /dev/null
+++ b/gl/m4/assert_h.m4
@@ -0,0 +1,67 @@
1# assert-h.m4
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9AC_DEFUN([gl_ASSERT_H],
10[
11 AC_CACHE_CHECK([for static_assert], [gl_cv_static_assert],
12 [gl_save_CFLAGS=$CFLAGS
13 for gl_working in "yes, a keyword" "yes, an <assert.h> macro"; do
14 AS_CASE([$gl_working],
15 [*assert.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_ASSERT_H"])
16
17 AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#if defined __clang__ && __STDC_VERSION__ < 202311
20 #pragma clang diagnostic error "-Wc2x-extensions"
21 #pragma clang diagnostic error "-Wc++17-extensions"
22 #endif
23 #ifdef INCLUDE_ASSERT_H
24 #include <assert.h>
25 #endif
26 static_assert (2 + 2 == 4, "arithmetic does not work");
27 static_assert (2 + 2 == 4);
28 ]],
29 [[
30 static_assert (sizeof (char) == 1, "sizeof does not work");
31 static_assert (sizeof (char) == 1);
32 ]])],
33 [gl_cv_static_assert=$gl_working],
34 [gl_cv_static_assert=no])
35 CFLAGS=$gl_save_CFLAGS
36 test "$gl_cv_static_assert" != no && break
37 done])
38
39 GL_GENERATE_ASSERT_H=false
40 AS_CASE([$gl_cv_static_assert],
41 [yes*keyword*],
42 [AC_DEFINE([HAVE_C_STATIC_ASSERT], [1],
43 [Define to 1 if the static_assert keyword works.])],
44 [no],
45 [GL_GENERATE_ASSERT_H=true
46 gl_NEXT_HEADERS([assert.h])])
47
48 dnl The "zz" puts this toward config.h's end, to avoid potential
49 dnl collisions with other definitions. #undef assert so that
50 dnl programs are not tempted to use it without specifically
51 dnl including assert.h. Break the #undef apart with a comment
52 dnl so that 'configure' does not comment it out.
53 AH_VERBATIM([zzstatic_assert],
54[#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \
55 && (!defined __cplusplus \
56 || (__cpp_static_assert < 201411 \
57 && __GNUG__ < 6 && __clang_major__ < 6)))
58 #include <assert.h>
59 #undef/**/assert
60 /* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
61 We need it also to be invocable with a single argument. */
62 #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
63 #undef/**/static_assert
64 #define static_assert _Static_assert
65 #endif
66#endif])
67])
diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4
index fc19893..987930a 100644
--- a/gl/m4/base64.m4
+++ b/gl/m4/base64.m4
@@ -1,5 +1,5 @@
1# base64.m4 serial 4 1# base64.m4 serial 4
2dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
index 978a06e..77218a7 100644
--- a/gl/m4/btowc.m4
+++ b/gl/m4/btowc.m4
@@ -1,5 +1,5 @@
1# btowc.m4 serial 10 1# btowc.m4 serial 12
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_BTOWC],
10 10
11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test 11 dnl Check whether <wchar.h> is usable at all, first. Otherwise the test
12 dnl program below may lead to an endless loop. See 12 dnl program below may lead to an endless loop. See
13 dnl <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. 13 dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>.
14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
15 15
16 AC_CHECK_FUNCS_ONCE([btowc]) 16 AC_CHECK_FUNCS_ONCE([btowc])
@@ -28,14 +28,6 @@ AC_DEFUN([gl_FUNC_BTOWC],
28 [ 28 [
29 AC_RUN_IFELSE( 29 AC_RUN_IFELSE(
30 [AC_LANG_SOURCE([[ 30 [AC_LANG_SOURCE([[
31#include <string.h>
32/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
33 <wchar.h>.
34 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
35 included before <wchar.h>. */
36#include <stddef.h>
37#include <stdio.h>
38#include <time.h>
39#include <wchar.h> 31#include <wchar.h>
40int main () 32int main ()
41{ 33{
@@ -50,6 +42,8 @@ changequote(,)dnl
50 case "$host_os" in 42 case "$host_os" in
51 # Guess no on Cygwin. 43 # Guess no on Cygwin.
52 cygwin*) gl_cv_func_btowc_nul="guessing no" ;; 44 cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
45 # Guess yes on native Windows.
46 mingw*) gl_cv_func_btowc_nul="guessing yes" ;;
53 # Guess yes otherwise. 47 # Guess yes otherwise.
54 *) gl_cv_func_btowc_nul="guessing yes" ;; 48 *) gl_cv_func_btowc_nul="guessing yes" ;;
55 esac 49 esac
@@ -65,24 +59,19 @@ changequote([,])dnl
65 dnl is present. 59 dnl is present.
66changequote(,)dnl 60changequote(,)dnl
67 case "$host_os" in 61 case "$host_os" in
68 # Guess no on IRIX. 62 # Guess no on IRIX.
69 irix*) gl_cv_func_btowc_eof="guessing no" ;; 63 irix*) gl_cv_func_btowc_eof="guessing no" ;;
70 # Guess yes otherwise. 64 # Guess yes on native Windows.
71 *) gl_cv_func_btowc_eof="guessing yes" ;; 65 mingw*) gl_cv_func_btowc_eof="guessing yes" ;;
66 # Guess yes otherwise.
67 *) gl_cv_func_btowc_eof="guessing yes" ;;
72 esac 68 esac
73changequote([,])dnl 69changequote([,])dnl
74 if test $LOCALE_FR != none; then 70 if test $LOCALE_FR != none; then
75 AC_RUN_IFELSE( 71 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[ 72 [AC_LANG_SOURCE([[
77#include <locale.h> 73#include <locale.h>
78#include <string.h>
79/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
80 <wchar.h>.
81 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
82 included before <wchar.h>. */
83#include <stddef.h>
84#include <stdio.h> 74#include <stdio.h>
85#include <time.h>
86#include <wchar.h> 75#include <wchar.h>
87int main () 76int main ()
88{ 77{
diff --git a/gl/m4/builtin-expect.m4 b/gl/m4/builtin-expect.m4
new file mode 100644
index 0000000..531ed48
--- /dev/null
+++ b/gl/m4/builtin-expect.m4
@@ -0,0 +1,49 @@
1dnl Check for __builtin_expect.
2
3dnl Copyright 2016-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN([gl___BUILTIN_EXPECT],
11[
12 AC_CACHE_CHECK([for __builtin_expect],
13 [gl_cv___builtin_expect],
14 [AC_LINK_IFELSE(
15 [AC_LANG_SOURCE([[
16 int
17 main (int argc, char **argv)
18 {
19 argc = __builtin_expect (argc, 100);
20 return argv[argc != 100][0];
21 }]])],
22 [gl_cv___builtin_expect=yes],
23 [AC_LINK_IFELSE(
24 [AC_LANG_SOURCE([[
25 #include <builtins.h>
26 int
27 main (int argc, char **argv)
28 {
29 argc = __builtin_expect (argc, 100);
30 return argv[argc != 100][0];
31 }]])],
32 [gl_cv___builtin_expect="in <builtins.h>"],
33 [gl_cv___builtin_expect=no])])])
34 if test "$gl_cv___builtin_expect" = yes; then
35 AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
36 elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
37 AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
38 fi
39 AH_VERBATIM([HAVE___BUILTIN_EXPECT],
40 [/* Define to 1 if the compiler supports __builtin_expect,
41 and to 2 if <builtins.h> does. */
42#undef HAVE___BUILTIN_EXPECT
43#ifndef HAVE___BUILTIN_EXPECT
44# define __builtin_expect(e, c) (e)
45#elif HAVE___BUILTIN_EXPECT == 2
46# include <builtins.h>
47#endif
48 ])
49])
diff --git a/gl/m4/byteswap.m4 b/gl/m4/byteswap.m4
new file mode 100644
index 0000000..8058d17
--- /dev/null
+++ b/gl/m4/byteswap.m4
@@ -0,0 +1,17 @@
1# byteswap.m4 serial 5
2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Oskar Liljeblad.
8
9AC_DEFUN([gl_BYTESWAP],
10[
11 dnl Prerequisites of lib/byteswap.in.h.
12 AC_CHECK_HEADERS([byteswap.h], [
13 GL_GENERATE_BYTESWAP_H=false
14 ], [
15 GL_GENERATE_BYTESWAP_H=true
16 ])
17])
diff --git a/gl/m4/c-bool.m4 b/gl/m4/c-bool.m4
new file mode 100644
index 0000000..f614371
--- /dev/null
+++ b/gl/m4/c-bool.m4
@@ -0,0 +1,51 @@
1# Check for bool that conforms to C2023.
2
3dnl Copyright 2022-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_C_BOOL],
9[
10 AC_CACHE_CHECK([for bool, true, false], [gl_cv_c_bool],
11 [AC_COMPILE_IFELSE(
12 [AC_LANG_SOURCE([[
13 #if true == false
14 #error "true == false"
15 #endif
16 extern bool b;
17 bool b = true == false;]])],
18 [gl_cv_c_bool=yes],
19 [gl_cv_c_bool=no])])
20 if test "$gl_cv_c_bool" = yes; then
21 AC_DEFINE([HAVE_C_BOOL], [1],
22 [Define to 1 if bool, true and false work as per C2023.])
23 fi
24
25 AC_CHECK_HEADERS_ONCE([stdbool.h])
26
27 dnl The "zz" puts this toward config.h's end, to avoid potential
28 dnl collisions with other definitions.
29 dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
30 dnl In C, this means including <stdbool.h> if it is not already included.
31 dnl However, if the preprocessor mistakenly treats 'true' as 0,
32 dnl define it to a bool expression equal to 1; this is needed in
33 dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
34 AH_VERBATIM([zzbool],
35[#ifndef HAVE_C_BOOL
36# if !defined __cplusplus && !defined __bool_true_false_are_defined
37# if HAVE_STDBOOL_H
38# include <stdbool.h>
39# else
40# if defined __SUNPRO_C
41# error "<stdbool.h> is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC."
42# else
43# error "<stdbool.h> does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'."
44# endif
45# endif
46# endif
47# if !true
48# define true (!false)
49# endif
50#endif])
51])
diff --git a/gl/m4/calloc.m4 b/gl/m4/calloc.m4
new file mode 100644
index 0000000..23c0dd9
--- /dev/null
+++ b/gl/m4/calloc.m4
@@ -0,0 +1,83 @@
1# calloc.m4 serial 29
2
3# Copyright (C) 2004-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# Written by Jim Meyering.
9
10# Determine whether calloc (N, S) returns non-NULL when N*S is zero,
11# and returns NULL when N*S overflows.
12# If so, define HAVE_CALLOC. Otherwise, define calloc to rpl_calloc
13# and arrange to use a calloc wrapper function that does work in that case.
14
15# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT])
16# -------------------------------------
17# If calloc is compatible with GNU calloc, run IF-WORKS, otherwise, IF-NOT.
18AC_DEFUN([_AC_FUNC_CALLOC_IF],
19[
20 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CACHE_CHECK([whether calloc (0, n) and calloc (n, 0) return nonnull],
22 [ac_cv_func_calloc_0_nonnull],
23 [if test $cross_compiling != yes; then
24 ac_cv_func_calloc_0_nonnull=yes
25 AC_RUN_IFELSE(
26 [AC_LANG_PROGRAM(
27 [AC_INCLUDES_DEFAULT],
28 [[int result = 0;
29 char * volatile p = calloc (0, 0);
30 if (!p)
31 result |= 1;
32 free (p);
33 return result;
34 ]])],
35 [],
36 [ac_cv_func_calloc_0_nonnull=no])
37 else
38 case "$host_os" in
39 # Guess yes on glibc systems.
40 *-gnu* | gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
41 # Guess yes on musl systems.
42 *-musl*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
43 # Guess yes on native Windows.
44 mingw*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
45 # If we don't know, obey --enable-cross-guesses.
46 *) ac_cv_func_calloc_0_nonnull="$gl_cross_guess_normal" ;;
47 esac
48 fi
49 ])
50 AS_CASE([$ac_cv_func_calloc_0_nonnull], [*yes], [$1], [$2])
51])
52
53
54# gl_FUNC_CALLOC_GNU
55# ------------------
56# Replace calloc if it is not compatible with GNU libc.
57AC_DEFUN([gl_FUNC_CALLOC_GNU],
58[
59 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
60 AC_REQUIRE([gl_FUNC_CALLOC_POSIX])
61 REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX"
62 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then
63 _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1])
64 fi
65])# gl_FUNC_CALLOC_GNU
66
67# gl_FUNC_CALLOC_POSIX
68# --------------------
69# Test whether 'calloc' is POSIX compliant (sets errno to ENOMEM when it
70# fails, and doesn't mess up with ptrdiff_t or size_t overflow),
71# and replace calloc if it is not.
72AC_DEFUN([gl_FUNC_CALLOC_POSIX],
73[
74 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
75 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
76 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
77 REPLACE_CALLOC_FOR_CALLOC_POSIX=1
78 fi
79 dnl Although in theory we should also test for size_t overflow,
80 dnl in practice testing for ptrdiff_t overflow suffices
81 dnl since PTRDIFF_MAX <= SIZE_MAX on all known Gnulib porting targets.
82 dnl A separate size_t test would slow down 'configure'.
83])
diff --git a/gl/m4/close.m4 b/gl/m4/close.m4
new file mode 100644
index 0000000..9f95c67
--- /dev/null
+++ b/gl/m4/close.m4
@@ -0,0 +1,35 @@
1# close.m4 serial 9
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_CLOSE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 m4_ifdef([gl_MSVC_INVAL], [
11 AC_REQUIRE([gl_MSVC_INVAL])
12 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
13 REPLACE_CLOSE=1
14 fi
15 ])
16 m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
17 gl_PREREQ_SYS_H_WINSOCK2
18 if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
19 dnl Even if the 'socket' module is not used here, another part of the
20 dnl application may use it and pass file descriptors that refer to
21 dnl sockets to the close() function. So enable the support for sockets.
22 REPLACE_CLOSE=1
23 fi
24 ])
25 dnl Replace close() for supporting the gnulib-defined fchdir() function,
26 dnl to keep fchdir's bookkeeping up-to-date.
27 m4_ifdef([gl_FUNC_FCHDIR], [
28 if test $REPLACE_CLOSE = 0; then
29 gl_TEST_FCHDIR
30 if test $HAVE_FCHDIR = 0; then
31 REPLACE_CLOSE=1
32 fi
33 fi
34 ])
35])
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index c2761be..5804f47 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,5 +1,6 @@
1# codeset.m4 serial 5 (gettext-0.18.2) 1# codeset.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2006, 2008-2014, 2016, 2019-2023 Free Software
3dnl Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/configmake.m4 b/gl/m4/configmake.m4
deleted file mode 100644
index 823ffc0..0000000
--- a/gl/m4/configmake.m4
+++ /dev/null
@@ -1,50 +0,0 @@
1# configmake.m4 serial 1
2dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# gl_CONFIGMAKE_PREP
8# ------------------
9# Guarantee all of the standard directory variables, even when used with
10# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake
11# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.).
12AC_DEFUN([gl_CONFIGMAKE_PREP],
13[
14 dnl Technically, datadir should default to datarootdir. But if
15 dnl autoconf is too old to provide datarootdir, then reversing the
16 dnl definition is a reasonable compromise. Only AC_SUBST a variable
17 dnl if it was not already defined earlier by autoconf.
18 if test "x$datarootdir" = x; then
19 AC_SUBST([datarootdir], ['${datadir}'])
20 fi
21 dnl Copy the approach used in autoconf 2.60.
22 if test "x$docdir" = x; then
23 AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME],
24 ['${datarootdir}/doc/${PACKAGE_TARNAME}'],
25 ['${datarootdir}/doc/${PACKAGE}'])])
26 fi
27 dnl The remaining variables missing from autoconf 2.59 are easier.
28 if test "x$htmldir" = x; then
29 AC_SUBST([htmldir], ['${docdir}'])
30 fi
31 if test "x$dvidir" = x; then
32 AC_SUBST([dvidir], ['${docdir}'])
33 fi
34 if test "x$pdfdir" = x; then
35 AC_SUBST([pdfdir], ['${docdir}'])
36 fi
37 if test "x$psdir" = x; then
38 AC_SUBST([psdir], ['${docdir}'])
39 fi
40 if test "x$lispdir" = x; then
41 AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp'])
42 fi
43 if test "x$localedir" = x; then
44 AC_SUBST([localedir], ['${datarootdir}/locale'])
45 fi
46
47 dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely
48 dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe.
49 AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}'])
50])
diff --git a/gl/m4/dirname.m4 b/gl/m4/dirname.m4
deleted file mode 100644
index 5897a2a..0000000
--- a/gl/m4/dirname.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1#serial 10 -*- autoconf -*-
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_DIRNAME],
8[
9 AC_REQUIRE([gl_DIRNAME_LGPL])
10])
11
12AC_DEFUN([gl_DIRNAME_LGPL],
13[
14 dnl Prerequisites of lib/dirname.h.
15 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
16
17 dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
18 dnl lib/stripslash.c.
19])
diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4
index bd6f867..1776e5e 100644
--- a/gl/m4/double-slash-root.m4
+++ b/gl/m4/double-slash-root.m4
@@ -1,5 +1,5 @@
1# double-slash-root.m4 serial 4 -*- Autoconf -*- 1# double-slash-root.m4 serial 4 -*- Autoconf -*-
2dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
new file mode 100644
index 0000000..e1cc73e
--- /dev/null
+++ b/gl/m4/dup2.m4
@@ -0,0 +1,105 @@
1#serial 27
2dnl Copyright (C) 2002, 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_DUP2],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
12 [AC_RUN_IFELSE([
13 AC_LANG_PROGRAM(
14 [[#include <errno.h>
15 #include <fcntl.h>
16 #include <limits.h>
17 #include <sys/resource.h>
18 #include <unistd.h>
19 ]GL_MDA_DEFINES[
20 #ifndef RLIM_SAVED_CUR
21 # define RLIM_SAVED_CUR RLIM_INFINITY
22 #endif
23 #ifndef RLIM_SAVED_MAX
24 # define RLIM_SAVED_MAX RLIM_INFINITY
25 #endif
26 ]],
27 [[int result = 0;
28 int bad_fd = INT_MAX;
29 struct rlimit rlim;
30 if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
31 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
32 && rlim.rlim_cur != RLIM_INFINITY
33 && rlim.rlim_cur != RLIM_SAVED_MAX
34 && rlim.rlim_cur != RLIM_SAVED_CUR)
35 bad_fd = rlim.rlim_cur;
36 #ifdef FD_CLOEXEC
37 if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
38 result |= 1;
39 #endif
40 if (dup2 (1, 1) != 1)
41 result |= 2;
42 #ifdef FD_CLOEXEC
43 if (fcntl (1, F_GETFD) != FD_CLOEXEC)
44 result |= 4;
45 #endif
46 close (0);
47 if (dup2 (0, 0) != -1)
48 result |= 8;
49 /* Many gnulib modules require POSIX conformance of EBADF. */
50 if (dup2 (2, bad_fd) == -1 && errno != EBADF)
51 result |= 16;
52 /* Flush out some cygwin core dumps. */
53 if (dup2 (2, -1) != -1 || errno != EBADF)
54 result |= 32;
55 dup2 (2, 255);
56 dup2 (2, 256);
57 /* On OS/2 kLIBC, dup2() does not work on a directory fd. */
58 {
59 int fd = open (".", O_RDONLY);
60 if (fd == -1)
61 result |= 64;
62 else if (dup2 (fd, fd + 1) == -1)
63 result |= 128;
64 close (fd);
65 }
66 return result;]])
67 ],
68 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
69 [case "$host_os" in
70 mingw*) # on this platform, dup2 always returns 0 for success
71 gl_cv_func_dup2_works="guessing no" ;;
72 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
73 gl_cv_func_dup2_works="guessing no" ;;
74 aix* | freebsd*)
75 # on AIX 7.1 and FreeBSD 6.1, dup2 (1,toobig) gives EMFILE,
76 # not EBADF.
77 gl_cv_func_dup2_works="guessing no" ;;
78 haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
79 gl_cv_func_dup2_works="guessing no" ;;
80 *-android*) # implemented using dup3(), which fails if oldfd == newfd
81 gl_cv_func_dup2_works="guessing no" ;;
82 os2*) # on OS/2 kLIBC, dup2() does not work on a directory fd.
83 gl_cv_func_dup2_works="guessing no" ;;
84 *) gl_cv_func_dup2_works="guessing yes" ;;
85 esac])
86 ])
87 case "$gl_cv_func_dup2_works" in
88 *yes) ;;
89 *)
90 REPLACE_DUP2=1
91 AC_CHECK_FUNCS([setdtablesize])
92 ;;
93 esac
94 dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
95 dnl to keep fchdir's bookkeeping up-to-date.
96 m4_ifdef([gl_FUNC_FCHDIR], [
97 gl_TEST_FCHDIR
98 if test $HAVE_FCHDIR = 0; then
99 REPLACE_DUP2=1
100 fi
101 ])
102])
103
104# Prerequisites of lib/dup2.c.
105AC_DEFUN([gl_PREREQ_DUP2], [])
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
index c640ec1..cb3e08f 100644
--- a/gl/m4/eealloc.m4
+++ b/gl/m4/eealloc.m4
@@ -1,5 +1,5 @@
1# eealloc.m4 serial 3 1# eealloc.m4 serial 3
2dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 593a33e..741dfc5 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,5 +1,5 @@
1# environ.m4 serial 6 1# environ.m4 serial 8
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -29,16 +29,15 @@ AC_DEFUN_ONCE([gl_ENVIRON],
29AC_DEFUN([gt_CHECK_VAR_DECL], 29AC_DEFUN([gt_CHECK_VAR_DECL],
30[ 30[
31 define([gt_cv_var], [gt_cv_var_]$2[_declaration]) 31 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
32 AC_MSG_CHECKING([if $2 is properly declared]) 32 AC_CACHE_CHECK([if $2 is properly declared], [gt_cv_var],
33 AC_CACHE_VAL([gt_cv_var], [ 33 [AC_COMPILE_IFELSE(
34 AC_COMPILE_IFELSE( 34 [AC_LANG_PROGRAM(
35 [AC_LANG_PROGRAM( 35 [[$1
36 [[$1 36 typedef struct { int foo; } foo_t;
37 extern struct { int foo; } $2;]], 37 extern foo_t $2;]],
38 [[$2.foo = 1;]])], 38 [[$2.foo = 1;]])],
39 [gt_cv_var=no], 39 [gt_cv_var=no],
40 [gt_cv_var=yes])]) 40 [gt_cv_var=yes])])
41 AC_MSG_RESULT([$gt_cv_var])
42 if test $gt_cv_var = yes; then 41 if test $gt_cv_var = yes; then
43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, 42 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
44 [Define if you have the declaration of $2.]) 43 [Define if you have the declaration of $2.])
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index c813ea5..4c70d22 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,9 +1,11 @@
1# errno_h.m4 serial 12 1# errno_h.m4 serial 14
2dnl Copyright (C) 2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_PREREQ([2.61])
8
7AC_DEFUN_ONCE([gl_HEADER_ERRNO_H], 9AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
8[ 10[
9 AC_REQUIRE([AC_PROG_CC]) 11 AC_REQUIRE([AC_PROG_CC])
@@ -66,13 +68,11 @@ booboo
66 [gl_cv_header_errno_h_complete=yes]) 68 [gl_cv_header_errno_h_complete=yes])
67 ]) 69 ])
68 if test $gl_cv_header_errno_h_complete = yes; then 70 if test $gl_cv_header_errno_h_complete = yes; then
69 ERRNO_H='' 71 GL_GENERATE_ERRNO_H=false
70 else 72 else
71 gl_NEXT_HEADERS([errno.h]) 73 gl_NEXT_HEADERS([errno.h])
72 ERRNO_H='errno.h' 74 GL_GENERATE_ERRNO_H=true
73 fi 75 fi
74 AC_SUBST([ERRNO_H])
75 AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"])
76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) 76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
77 gl_REPLACE_ERRNO_VALUE([ENOLINK]) 77 gl_REPLACE_ERRNO_VALUE([ENOLINK])
78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) 78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
@@ -86,7 +86,7 @@ booboo
86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE. 86# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
87AC_DEFUN([gl_REPLACE_ERRNO_VALUE], 87AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
88[ 88[
89 if test -n "$ERRNO_H"; then 89 if $GL_GENERATE_ERRNO_H; then
90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [ 90 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
91 AC_EGREP_CPP([yes],[ 91 AC_EGREP_CPP([yes],[
92#include <errno.h> 92#include <errno.h>
@@ -129,9 +129,3 @@ yes
129 AC_SUBST($1[_VALUE]) 129 AC_SUBST($1[_VALUE])
130 fi 130 fi
131]) 131])
132
133dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
134dnl Remove this when we can assume autoconf >= 2.61.
135m4_ifdef([AC_COMPUTE_INT], [], [
136 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
137])
diff --git a/gl/m4/error.m4 b/gl/m4/error.m4
index 29e6fdc..8cc75df 100644
--- a/gl/m4/error.m4
+++ b/gl/m4/error.m4
@@ -1,6 +1,6 @@
1#serial 14 1#serial 15
2 2
3# Copyright (C) 1996-1998, 2001-2004, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 1996-1998, 2001-2004, 2009-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -22,6 +22,10 @@ AC_DEFUN([gl_ERROR],
22# Prerequisites of lib/error.c. 22# Prerequisites of lib/error.c.
23AC_DEFUN([gl_PREREQ_ERROR], 23AC_DEFUN([gl_PREREQ_ERROR],
24[ 24[
25 dnl Use system extensions on Android, so that AC_FUNC_STRERROR_R
26 dnl discovers the GNU API for strerror_r on Android API level 23 and later.
27 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
28
25 AC_REQUIRE([AC_FUNC_STRERROR_R]) 29 AC_REQUIRE([AC_FUNC_STRERROR_R])
26 : 30 :
27]) 31])
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4
index 09df468..2ef4643 100644
--- a/gl/m4/exponentd.m4
+++ b/gl/m4/exponentd.m4
@@ -1,5 +1,5 @@
1# exponentd.m4 serial 3 1# exponentd.m4 serial 3
2dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index e30f122..5336b8d 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,14 +1,19 @@
1# serial 13 -*- Autoconf -*- 1# serial 23 -*- Autoconf -*-
2# Enable extensions on systems that normally disable them. 2# Enable extensions on systems that normally disable them.
3 3
4# Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. 4# Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
8 8
9dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that
10dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+.
11m4_ifndef([AC_CHECK_INCLUDES_DEFAULT],
12 [AC_DEFUN([AC_CHECK_INCLUDES_DEFAULT], [])])
13
9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git 14# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
10# Autoconf. Perhaps we can remove this once we can assume Autoconf 15# Autoconf. Perhaps we can remove this once we can assume Autoconf
11# 2.70 or later everywhere, but since Autoconf mutates rapidly 16# is recent-enough everywhere, but since Autoconf mutates rapidly
12# enough in this area it's likely we'll need to redefine 17# enough in this area it's likely we'll need to redefine
13# AC_USE_SYSTEM_EXTENSIONS for quite some time. 18# AC_USE_SYSTEM_EXTENSIONS for quite some time.
14 19
@@ -26,67 +31,125 @@
26# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS 31# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
27# invocation occurs in gl_EARLY, not in gl_INIT. 32# invocation occurs in gl_EARLY, not in gl_INIT.
28 33
34m4_version_prereq([2.72], [], [
35
29# AC_USE_SYSTEM_EXTENSIONS 36# AC_USE_SYSTEM_EXTENSIONS
30# ------------------------ 37# ------------------------
31# Enable extensions on systems that normally disable them, 38# Enable extensions on systems that normally disable them,
32# typically due to standards-conformance issues. 39# typically due to standards-conformance issues.
33# 40# We unconditionally define as many of the known feature-enabling
34# Remember that #undef in AH_VERBATIM gets replaced with #define by 41# as possible, reserving conditional behavior for macros that are
35# AC_DEFINE. The goal here is to define all known feature-enabling 42# known to cause problems on some platforms (such as __EXTENSIONS__).
36# macros, then, if reports of conflicts are made, disable macros that
37# cause problems on some platforms (such as __EXTENSIONS__).
38AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], 43AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
39[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl 44[AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl
45AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
46AC_BEFORE([$0], [AC_LINK_IFELSE])dnl
40AC_BEFORE([$0], [AC_RUN_IFELSE])dnl 47AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
41 48AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl
42 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) 49dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE.
43 if test "$MINIX" = yes; then
44 AC_DEFINE([_POSIX_SOURCE], [1],
45 [Define to 1 if you need to in order for 'stat' and other
46 things to work.])
47 AC_DEFINE([_POSIX_1_SOURCE], [2],
48 [Define to 2 if the system does not provide POSIX.1 features
49 except with this defined.])
50 AC_DEFINE([_MINIX], [1],
51 [Define to 1 if on MINIX.])
52 AC_DEFINE([_NETBSD_SOURCE], [1],
53 [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
54 fi
55
56dnl Use a different key than __EXTENSIONS__, as that name broke existing 50dnl Use a different key than __EXTENSIONS__, as that name broke existing
57dnl configure.ac when using autoheader 2.62. 51dnl configure.ac when using autoheader 2.62.
58 AH_VERBATIM([USE_SYSTEM_EXTENSIONS], 52dnl The macros below are in alphabetical order ignoring leading _ or __
53dnl prefixes.
54AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
59[/* Enable extensions on AIX 3, Interix. */ 55[/* Enable extensions on AIX 3, Interix. */
60#ifndef _ALL_SOURCE 56#ifndef _ALL_SOURCE
61# undef _ALL_SOURCE 57# undef _ALL_SOURCE
62#endif 58#endif
63/* Enable general extensions on OS X. */ 59/* Enable general extensions on macOS. */
64#ifndef _DARWIN_C_SOURCE 60#ifndef _DARWIN_C_SOURCE
65# undef _DARWIN_C_SOURCE 61# undef _DARWIN_C_SOURCE
66#endif 62#endif
63/* Enable general extensions on Solaris. */
64#ifndef __EXTENSIONS__
65# undef __EXTENSIONS__
66#endif
67/* Enable GNU extensions on systems that have them. */ 67/* Enable GNU extensions on systems that have them. */
68#ifndef _GNU_SOURCE 68#ifndef _GNU_SOURCE
69# undef _GNU_SOURCE 69# undef _GNU_SOURCE
70#endif 70#endif
71/* Enable threading extensions on Solaris. */ 71/* Enable X/Open compliant socket functions that do not require linking
72 with -lxnet on HP-UX 11.11. */
73#ifndef _HPUX_ALT_XOPEN_SOCKET_API
74# undef _HPUX_ALT_XOPEN_SOCKET_API
75#endif
76/* Identify the host operating system as Minix.
77 This macro does not affect the system headers' behavior.
78 A future release of Autoconf may stop defining this macro. */
79#ifndef _MINIX
80# undef _MINIX
81#endif
82/* Enable general extensions on NetBSD.
83 Enable NetBSD compatibility extensions on Minix. */
84#ifndef _NETBSD_SOURCE
85# undef _NETBSD_SOURCE
86#endif
87/* Enable OpenBSD compatibility extensions on NetBSD.
88 Oddly enough, this does nothing on OpenBSD. */
89#ifndef _OPENBSD_SOURCE
90# undef _OPENBSD_SOURCE
91#endif
92/* Define to 1 if needed for POSIX-compatible behavior. */
93#ifndef _POSIX_SOURCE
94# undef _POSIX_SOURCE
95#endif
96/* Define to 2 if needed for POSIX-compatible behavior. */
97#ifndef _POSIX_1_SOURCE
98# undef _POSIX_1_SOURCE
99#endif
100/* Enable POSIX-compatible threading on Solaris. */
72#ifndef _POSIX_PTHREAD_SEMANTICS 101#ifndef _POSIX_PTHREAD_SEMANTICS
73# undef _POSIX_PTHREAD_SEMANTICS 102# undef _POSIX_PTHREAD_SEMANTICS
74#endif 103#endif
104/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
105#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
106# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
107#endif
108/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
109#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
110# undef __STDC_WANT_IEC_60559_BFP_EXT__
111#endif
112/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
113#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
114# undef __STDC_WANT_IEC_60559_DFP_EXT__
115#endif
116/* Enable extensions specified by C23 Annex F. */
117#ifndef __STDC_WANT_IEC_60559_EXT__
118# undef __STDC_WANT_IEC_60559_EXT__
119#endif
120/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
121#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
122# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
123#endif
124/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */
125#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
126# undef __STDC_WANT_IEC_60559_TYPES_EXT__
127#endif
128/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
129#ifndef __STDC_WANT_LIB_EXT2__
130# undef __STDC_WANT_LIB_EXT2__
131#endif
132/* Enable extensions specified by ISO/IEC 24747:2009. */
133#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
134# undef __STDC_WANT_MATH_SPEC_FUNCS__
135#endif
75/* Enable extensions on HP NonStop. */ 136/* Enable extensions on HP NonStop. */
76#ifndef _TANDEM_SOURCE 137#ifndef _TANDEM_SOURCE
77# undef _TANDEM_SOURCE 138# undef _TANDEM_SOURCE
78#endif 139#endif
79/* Enable X/Open extensions if necessary. HP-UX 11.11 defines 140/* Enable X/Open extensions. Define to 500 only if necessary
80 mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of 141 to make mbstate_t available. */
81 whether compiling with -Ae or -D_HPUX_SOURCE=1. */
82#ifndef _XOPEN_SOURCE 142#ifndef _XOPEN_SOURCE
83# undef _XOPEN_SOURCE 143# undef _XOPEN_SOURCE
84#endif 144#endif
85/* Enable general extensions on Solaris. */ 145])dnl
86#ifndef __EXTENSIONS__ 146
87# undef __EXTENSIONS__ 147 AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl
88#endif 148 _AC_CHECK_HEADER_ONCE([wchar.h])
89]) 149 _AC_CHECK_HEADER_ONCE([minix/config.h])
150
151dnl Defining __EXTENSIONS__ may break the system headers on some systems.
152dnl (FIXME: Which ones?)
90 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], 153 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
91 [ac_cv_safe_to_define___extensions__], 154 [ac_cv_safe_to_define___extensions__],
92 [AC_COMPILE_IFELSE( 155 [AC_COMPILE_IFELSE(
@@ -95,30 +158,57 @@ dnl configure.ac when using autoheader 2.62.
95 ]AC_INCLUDES_DEFAULT])], 158 ]AC_INCLUDES_DEFAULT])],
96 [ac_cv_safe_to_define___extensions__=yes], 159 [ac_cv_safe_to_define___extensions__=yes],
97 [ac_cv_safe_to_define___extensions__=no])]) 160 [ac_cv_safe_to_define___extensions__=no])])
98 test $ac_cv_safe_to_define___extensions__ = yes && 161
99 AC_DEFINE([__EXTENSIONS__]) 162dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to
100 AC_DEFINE([_ALL_SOURCE]) 163dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1.
101 AC_DEFINE([_DARWIN_C_SOURCE]) 164dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms
102 AC_DEFINE([_GNU_SOURCE]) 165dnl not covered by turn-on-extensions macros (notably Dragonfly, Free,
103 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) 166dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so
104 AC_DEFINE([_TANDEM_SOURCE]) 167dnl it should only be defined when necessary.
105 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], 168 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
106 [ac_cv_should_define__xopen_source], 169 [ac_cv_should_define__xopen_source],
107 [ac_cv_should_define__xopen_source=no 170 [ac_cv_should_define__xopen_source=no
108 AC_COMPILE_IFELSE( 171 AS_IF([test $ac_cv_header_wchar_h = yes],
109 [AC_LANG_PROGRAM([[ 172 [AC_COMPILE_IFELSE(
173 [AC_LANG_PROGRAM([[
110 #include <wchar.h> 174 #include <wchar.h>
111 mbstate_t x;]])], 175 mbstate_t x;]])],
112 [], 176 [],
113 [AC_COMPILE_IFELSE( 177 [AC_COMPILE_IFELSE(
114 [AC_LANG_PROGRAM([[ 178 [AC_LANG_PROGRAM([[
115 #define _XOPEN_SOURCE 500 179 #define _XOPEN_SOURCE 500
116 #include <wchar.h> 180 #include <wchar.h>
117 mbstate_t x;]])], 181 mbstate_t x;]])],
118 [ac_cv_should_define__xopen_source=yes])])]) 182 [ac_cv_should_define__xopen_source=yes])])])])
119 test $ac_cv_should_define__xopen_source = yes && 183
120 AC_DEFINE([_XOPEN_SOURCE], [500]) 184 AC_DEFINE([_ALL_SOURCE])
185 AC_DEFINE([_DARWIN_C_SOURCE])
186 AC_DEFINE([_GNU_SOURCE])
187 AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API])
188 AC_DEFINE([_NETBSD_SOURCE])
189 AC_DEFINE([_OPENBSD_SOURCE])
190 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
191 AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
192 AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
193 AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
194 AC_DEFINE([__STDC_WANT_IEC_60559_EXT__])
195 AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
196 AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
197 AC_DEFINE([__STDC_WANT_LIB_EXT2__])
198 AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
199 AC_DEFINE([_TANDEM_SOURCE])
200 AS_IF([test $ac_cv_header_minix_config_h = yes],
201 [MINIX=yes
202 AC_DEFINE([_MINIX])
203 AC_DEFINE([_POSIX_SOURCE])
204 AC_DEFINE([_POSIX_1_SOURCE], [2])],
205 [MINIX=])
206 AS_IF([test $ac_cv_safe_to_define___extensions__ = yes],
207 [AC_DEFINE([__EXTENSIONS__])])
208 AS_IF([test $ac_cv_should_define__xopen_source = yes],
209 [AC_DEFINE([_XOPEN_SOURCE], [500])])
121])# AC_USE_SYSTEM_EXTENSIONS 210])# AC_USE_SYSTEM_EXTENSIONS
211])
122 212
123# gl_USE_SYSTEM_EXTENSIONS 213# gl_USE_SYSTEM_EXTENSIONS
124# ------------------------ 214# ------------------------
@@ -126,13 +216,17 @@ dnl configure.ac when using autoheader 2.62.
126# typically due to standards-conformance issues. 216# typically due to standards-conformance issues.
127AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], 217AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
128[ 218[
129 dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
130 dnl gnulib does not need it. But if it gets required by third-party macros
131 dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
132 dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
133 dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
134 dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
135 AC_REQUIRE([AC_GNU_SOURCE])
136
137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 219 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
220
221 dnl On OpenBSD 6.8 with GCC, the include files contain a couple of
222 dnl definitions that are only activated with an explicit -D_ISOC11_SOURCE.
223 dnl That's because this version of GCC (4.2.1) supports the option
224 dnl '-std=gnu99' but not the option '-std=gnu11'.
225 AC_REQUIRE([AC_CANONICAL_HOST])
226 case "$host_os" in
227 openbsd*)
228 AC_DEFINE([_ISOC11_SOURCE], [1],
229 [Define to enable the declarations of ISO C 11 types and functions.])
230 ;;
231 esac
138]) 232])
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index c4c5e7f..c001b1c 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -1,61 +1,121 @@
1dnl 'extern inline' a la ISO C99. 1dnl 'extern inline' a la ISO C99.
2 2
3dnl Copyright 2012-2013 Free Software Foundation, Inc. 3dnl Copyright 2012-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8AC_DEFUN([gl_EXTERN_INLINE], 8AC_DEFUN([gl_EXTERN_INLINE],
9[ 9[
10 AH_VERBATIM([extern_inline], 10 AC_CACHE_CHECK([whether ctype.h defines __header_inline],
11 [gl_cv_have___header_inline],
12 [AC_PREPROC_IFELSE(
13 [AC_LANG_SOURCE([[#include <ctype.h>
14 #ifndef __header_inline
15 #error "<ctype.h> does not define __header_inline"
16 #endif
17 ]])],
18 [gl_cv_have___header_inline=yes],
19 [gl_cv_have___header_inline=no])])
20 if test "$gl_cv_have___header_inline" = yes; then
21 AC_DEFINE([HAVE___HEADER_INLINE], [1],
22 [Define to 1 if ctype.h defines __header_inline.])
23 fi
24
25 AH_VERBATIM([HAVE___HEADER_INLINE_1],
11[/* Please see the Gnulib manual for how to use these macros. 26[/* Please see the Gnulib manual for how to use these macros.
12 27
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see 28 Suppress extern inline with HP-UX cc, as it appears to be broken; see
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>. 29 <https://lists.gnu.org/r/bug-texinfo/2013-02/msg00030.html>.
15 30
16 Suppress extern inline with Sun C in standards-conformance mode, as it 31 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f 32 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains 33 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'. 34 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. 35 This bug was observed with Oracle Developer Studio 12.6
36 (Sun C 5.15 SunOS_sparc 2017/05/30).
37
38 Suppress extern inline (with or without __attribute__ ((__gnu_inline__)))
39 on configurations that mistakenly use 'static inline' to implement
40 functions or macros in standard C headers like <ctype.h>. For example,
41 if isdigit is mistakenly implemented via a static inline function,
42 a program containing an extern inline function that calls isdigit
43 may not work since the C standard prohibits extern inline functions
44 from calling static functions (ISO C 99 section 6.7.4.(3).
45 This bug is known to occur on:
46
47 OS X 10.8 and earlier; see:
48 https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html
49
50 DragonFly; see
51 http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log
21 52
22 Suppress the use of extern inline on Apple's platforms, as Libc at least 53 FreeBSD; see:
23 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g., 54 https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. 55
25 Perhaps Apple will fix this some day. */ 56 OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
57 for clang but remains for g++; see <https://trac.macports.org/ticket/41033>.
58 Assume DragonFly and FreeBSD will be similar.
59
60 GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
61 inline semantics, unless -fgnu89-inline is used. It defines a macro
62 __GNUC_STDC_INLINE__ to indicate this situation or a macro
63 __GNUC_GNU_INLINE__ to indicate the opposite situation.
64 GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
65 semantics but warns, unless -fgnu89-inline is used:
66 warning: C99 inline functions are not supported; using GNU89
67 warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
68 It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
69 */
70#if (((defined __APPLE__ && defined __MACH__) \
71 || defined __DragonFly__ || defined __FreeBSD__) \
72 && (defined HAVE___HEADER_INLINE \
73 ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \
74 && ! defined __clang__) \
75 : ((! defined _DONT_USE_CTYPE_INLINE_ \
76 && (defined __GNUC__ || defined __cplusplus)) \
77 || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
78 && defined __GNUC__ && ! defined __cplusplus))))
79# define _GL_EXTERN_INLINE_STDHEADER_BUG
80#endif
26#if ((__GNUC__ \ 81#if ((__GNUC__ \
27 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ 82 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
28 : (199901L <= __STDC_VERSION__ \ 83 : (199901L <= __STDC_VERSION__ \
29 && !defined __HP_cc \ 84 && !defined __HP_cc \
85 && !defined __PGI \
30 && !(defined __SUNPRO_C && __STDC__))) \ 86 && !(defined __SUNPRO_C && __STDC__))) \
31 && !defined __APPLE__) 87 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
32# define _GL_INLINE inline 88# define _GL_INLINE inline
33# define _GL_EXTERN_INLINE extern inline 89# define _GL_EXTERN_INLINE extern inline
90# define _GL_EXTERN_INLINE_IN_USE
34#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ 91#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
35 && !defined __APPLE__) 92 && !defined _GL_EXTERN_INLINE_STDHEADER_BUG)
36# if __GNUC_GNU_INLINE__ 93# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__
37 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ 94 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
38# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) 95# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
39# else 96# else
40# define _GL_INLINE extern inline 97# define _GL_INLINE extern inline
41# endif 98# endif
42# define _GL_EXTERN_INLINE extern 99# define _GL_EXTERN_INLINE extern
100# define _GL_EXTERN_INLINE_IN_USE
43#else 101#else
44# define _GL_INLINE static _GL_UNUSED 102# define _GL_INLINE _GL_UNUSED static
45# define _GL_EXTERN_INLINE static _GL_UNUSED 103# define _GL_EXTERN_INLINE _GL_UNUSED static
46#endif 104#endif
47 105
48#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 106/* In GCC 4.6 (inclusive) to 5.1 (exclusive),
107 suppress bogus "no previous prototype for 'FOO'"
108 and "no previous declaration for 'FOO'" diagnostics,
109 when FOO is an inline function in the header; see
110 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113> and
111 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63877>. */
112#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__
49# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ 113# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
50# define _GL_INLINE_HEADER_CONST_PRAGMA 114# define _GL_INLINE_HEADER_CONST_PRAGMA
51# else 115# else
52# define _GL_INLINE_HEADER_CONST_PRAGMA \ 116# define _GL_INLINE_HEADER_CONST_PRAGMA \
53 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") 117 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
54# endif 118# endif
55 /* Suppress GCC's bogus "no previous prototype for 'FOO'"
56 and "no previous declaration for 'FOO'" diagnostics,
57 when FOO is an inline function in the header; see
58 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
59# define _GL_INLINE_HEADER_BEGIN \ 119# define _GL_INLINE_HEADER_BEGIN \
60 _Pragma ("GCC diagnostic push") \ 120 _Pragma ("GCC diagnostic push") \
61 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ 121 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 87cc4bd..59d558b 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,23 +1,22 @@
1# fcntl-o.m4 serial 4 1# fcntl-o.m4 serial 7
2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Paul Eggert. 7dnl Written by Paul Eggert.
8 8
9AC_PREREQ([2.60])
10
9# Test whether the flags O_NOATIME and O_NOFOLLOW actually work. 11# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
10# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise. 12# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
11# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise. 13# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
12AC_DEFUN([gl_FCNTL_O_FLAGS], 14AC_DEFUN([gl_FCNTL_O_FLAGS],
13[ 15[
14 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. 16 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
15 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16 dnl AC_GNU_SOURCE.
17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
19 [AC_REQUIRE([AC_GNU_SOURCE])])
20 18
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21 AC_CHECK_HEADERS_ONCE([unistd.h]) 20 AC_CHECK_HEADERS_ONCE([unistd.h])
22 AC_CHECK_FUNCS_ONCE([symlink]) 21 AC_CHECK_FUNCS_ONCE([symlink])
23 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], 22 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
@@ -33,6 +32,7 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
33 # defined sleep(n) _sleep ((n) * 1000) 32 # defined sleep(n) _sleep ((n) * 1000)
34 #endif 33 #endif
35 #include <fcntl.h> 34 #include <fcntl.h>
35 ]GL_MDA_DEFINES[
36 #ifndef O_NOATIME 36 #ifndef O_NOATIME
37 #define O_NOATIME 0 37 #define O_NOATIME 0
38 #endif 38 #endif
@@ -116,7 +116,13 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
117 *) gl_cv_header_working_fcntl_h='no';; 117 *) gl_cv_header_working_fcntl_h='no';;
118 esac], 118 esac],
119 [gl_cv_header_working_fcntl_h=cross-compiling])]) 119 [case "$host_os" in
120 # Guess 'no' on native Windows.
121 mingw*) gl_cv_header_working_fcntl_h='no' ;;
122 *) gl_cv_header_working_fcntl_h=cross-compiling ;;
123 esac
124 ])
125 ])
120 126
121 case $gl_cv_header_working_fcntl_h in #( 127 case $gl_cv_header_working_fcntl_h in #(
122 *O_NOATIME* | no | cross-compiling) ac_val=0;; #( 128 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4
new file mode 100644
index 0000000..524a99a
--- /dev/null
+++ b/gl/m4/fcntl.m4
@@ -0,0 +1,151 @@
1# fcntl.m4 serial 11
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly
9# - supports or emulates F_DUPFD_CLOEXEC
10# - supports F_GETFD
11# Still to be ported to mingw:
12# - F_SETFD
13# - F_GETFL, F_SETFL
14# - F_GETOWN, F_SETOWN
15# - F_GETLK, F_SETLK, F_SETLKW
16AC_DEFUN([gl_FUNC_FCNTL],
17[
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL
25 else
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
27 dnl haiku alpha 2 F_DUPFD has wrong errno
28 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
29 [gl_cv_func_fcntl_f_dupfd_works],
30 [AC_RUN_IFELSE(
31 [AC_LANG_PROGRAM(
32 [[#include <errno.h>
33 #include <fcntl.h>
34 #include <limits.h>
35 #include <sys/resource.h>
36 #include <unistd.h>
37 ]GL_MDA_DEFINES[
38 #ifndef RLIM_SAVED_CUR
39 # define RLIM_SAVED_CUR RLIM_INFINITY
40 #endif
41 #ifndef RLIM_SAVED_MAX
42 # define RLIM_SAVED_MAX RLIM_INFINITY
43 #endif
44 ]],
45 [[int result = 0;
46 int bad_fd = INT_MAX;
47 struct rlimit rlim;
48 if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
49 && 0 <= rlim.rlim_cur && rlim.rlim_cur <= INT_MAX
50 && rlim.rlim_cur != RLIM_INFINITY
51 && rlim.rlim_cur != RLIM_SAVED_MAX
52 && rlim.rlim_cur != RLIM_SAVED_CUR)
53 bad_fd = rlim.rlim_cur;
54 if (fcntl (0, F_DUPFD, -1) != -1) result |= 1;
55 if (errno != EINVAL) result |= 2;
56 if (fcntl (0, F_DUPFD, bad_fd) != -1) result |= 4;
57 if (errno != EINVAL) result |= 8;
58 /* On OS/2 kLIBC, F_DUPFD does not work on a directory fd */
59 {
60 int fd;
61 fd = open (".", O_RDONLY);
62 if (fd == -1)
63 result |= 16;
64 else if (fcntl (fd, F_DUPFD, STDERR_FILENO + 1) == -1)
65 result |= 32;
66
67 close (fd);
68 }
69 return result;]])],
70 [gl_cv_func_fcntl_f_dupfd_works=yes],
71 [gl_cv_func_fcntl_f_dupfd_works=no],
72 [case $host_os in
73 aix* | cygwin* | haiku*)
74 gl_cv_func_fcntl_f_dupfd_works="guessing no" ;;
75 *) gl_cv_func_fcntl_f_dupfd_works="guessing yes" ;;
76 esac])])
77 case $gl_cv_func_fcntl_f_dupfd_works in
78 *yes) ;;
79 *) gl_REPLACE_FCNTL
80 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
81 behavior does not match POSIX]) ;;
82 esac
83
84 dnl Many systems lack F_DUPFD_CLOEXEC.
85 dnl NetBSD 9.0 declares F_DUPFD_CLOEXEC but it works only like F_DUPFD.
86 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
87 [gl_cv_func_fcntl_f_dupfd_cloexec],
88 [AC_RUN_IFELSE(
89 [AC_LANG_SOURCE(
90 [[#include <fcntl.h>
91 #include <unistd.h>
92 int main (int argc, char *argv[])
93 {
94 if (argc == 1)
95 /* parent process */
96 {
97 if (fcntl (1, F_DUPFD_CLOEXEC, 10) < 0)
98 return 1;
99 return execl ("./conftest", "./conftest", "child", NULL);
100 }
101 else
102 /* child process */
103 return (fcntl (10, F_GETFL) < 0 ? 0 : 42);
104 }
105 ]])
106 ],
107 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
108#ifdef __linux__
109/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
110 it to support the semantics on older kernels that failed with EINVAL. */
111choke me
112#endif
113 ]])],
114 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
115 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])
116 ],
117 [gl_cv_func_fcntl_f_dupfd_cloexec=no],
118 [case "$host_os" in
119 # Guess no on NetBSD.
120 netbsd*) gl_cv_func_fcntl_f_dupfd_cloexec="guessing no" ;;
121 *) gl_cv_func_fcntl_f_dupfd_cloexec="$gl_cross_guess_normal" ;;
122 esac
123 ])
124 ])
125 case "$gl_cv_func_fcntl_f_dupfd_cloexec" in
126 *yes) ;;
127 *) gl_REPLACE_FCNTL
128 dnl No witness macro needed for this bug.
129 ;;
130 esac
131 fi
132 dnl Replace fcntl() for supporting the gnulib-defined fchdir() function,
133 dnl to keep fchdir's bookkeeping up-to-date.
134 m4_ifdef([gl_FUNC_FCHDIR], [
135 gl_TEST_FCHDIR
136 if test $HAVE_FCHDIR = 0; then
137 gl_REPLACE_FCNTL
138 fi
139 ])
140])
141
142AC_DEFUN([gl_REPLACE_FCNTL],
143[
144 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
145 AC_CHECK_FUNCS_ONCE([fcntl])
146 if test $ac_cv_func_fcntl = no; then
147 HAVE_FCNTL=0
148 else
149 REPLACE_FCNTL=1
150 fi
151])
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
new file mode 100644
index 0000000..68f4e64
--- /dev/null
+++ b/gl/m4/fcntl_h.m4
@@ -0,0 +1,70 @@
1# serial 20
2# Configure fcntl.h.
3dnl Copyright (C) 2006-2007, 2009-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN_ONCE([gl_FCNTL_H],
11[
12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13 AC_REQUIRE([gl_FCNTL_O_FLAGS])
14 gl_NEXT_HEADERS([fcntl.h])
15
16 dnl Ensure the type pid_t gets defined.
17 AC_REQUIRE([AC_TYPE_PID_T])
18
19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T])
21
22 dnl Check for declarations of anything we want to poison if the
23 dnl corresponding gnulib module is not in use, if it is not common
24 dnl enough to be declared everywhere.
25 gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
26 ]], [fcntl openat])
27])
28
29# gl_FCNTL_MODULE_INDICATOR([modulename])
30# sets the shell variable that indicates the presence of the given module
31# to a C preprocessor expression that will evaluate to 1.
32# This macro invocation must not occur in macros that are AC_REQUIREd.
33AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
34[
35 dnl Ensure to expand the default settings once only.
36 gl_FCNTL_H_REQUIRE_DEFAULTS
37 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
38 dnl Define it also as a C macro, for the benefit of the unit tests.
39 gl_MODULE_INDICATOR_FOR_TESTS([$1])
40])
41
42# Initializes the default values for AC_SUBSTed shell variables.
43# This macro must not be AC_REQUIREd. It must only be invoked, and only
44# outside of macros or in macros that are not AC_REQUIREd.
45AC_DEFUN([gl_FCNTL_H_REQUIRE_DEFAULTS],
46[
47 m4_defun(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS], [
48 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CREAT])
49 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCNTL])
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NONBLOCKING])
51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPEN])
52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENAT])
53 dnl Support Microsoft deprecated alias function names by default.
54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CREAT], [1])
55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_OPEN], [1])
56 ])
57 m4_require(GL_MODULE_INDICATOR_PREFIX[_FCNTL_H_MODULE_INDICATOR_DEFAULTS])
58 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
59])
60
61AC_DEFUN([gl_FCNTL_H_DEFAULTS],
62[
63 dnl Assume proper GNU behavior unless another module says otherwise.
64 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
65 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
66 REPLACE_CREAT=0; AC_SUBST([REPLACE_CREAT])
67 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
68 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
69 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
70])
diff --git a/gl/m4/fflush.m4 b/gl/m4/fflush.m4
new file mode 100644
index 0000000..3e3c890
--- /dev/null
+++ b/gl/m4/fflush.m4
@@ -0,0 +1,100 @@
1# fflush.m4 serial 18
2
3# Copyright (C) 2007-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8dnl From Eric Blake
9
10dnl Find out how to obey POSIX semantics of fflush(stdin) discarding
11dnl unread input on seekable streams, rather than C99 undefined semantics.
12
13AC_DEFUN([gl_FUNC_FFLUSH],
14[
15 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
16 gl_FUNC_FFLUSH_STDIN
17 case "$gl_cv_func_fflush_stdin" in
18 *yes) ;;
19 *) REPLACE_FFLUSH=1 ;;
20 esac
21])
22
23dnl Determine whether fflush works on input streams.
24dnl Sets gl_cv_func_fflush_stdin.
25
26AC_DEFUN([gl_FUNC_FFLUSH_STDIN],
27[
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
29 AC_CHECK_HEADERS_ONCE([unistd.h])
30 AC_CACHE_CHECK([whether fflush works on input streams],
31 [gl_cv_func_fflush_stdin],
32 [echo hello world > conftest.txt
33 AC_RUN_IFELSE([AC_LANG_PROGRAM(
34 [[
35#include <stdio.h>
36#if HAVE_UNISTD_H
37# include <unistd.h>
38#else /* on Windows with MSVC */
39# include <io.h>
40#endif
41 ]GL_MDA_DEFINES],
42 [[FILE *f = fopen ("conftest.txt", "r");
43 char buffer[10];
44 int fd;
45 int c;
46 if (f == NULL)
47 return 1;
48 fd = fileno (f);
49 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
50 { fclose (f); return 2; }
51 /* For deterministic results, ensure f read a bigger buffer. */
52 if (lseek (fd, 0, SEEK_CUR) == 5)
53 { fclose (f); return 3; }
54 /* POSIX requires fflush-fseek to set file offset of fd. This fails
55 on BSD systems and on mingw. */
56 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
57 { fclose (f); return 4; }
58 if (lseek (fd, 0, SEEK_CUR) != 5)
59 { fclose (f); return 5; }
60 /* Verify behaviour of fflush after ungetc. See
61 <https://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
62 /* Verify behaviour of fflush after a backup ungetc. This fails on
63 mingw. */
64 c = fgetc (f);
65 ungetc (c, f);
66 fflush (f);
67 if (fgetc (f) != c)
68 { fclose (f); return 6; }
69 /* Verify behaviour of fflush after a non-backup ungetc. This fails
70 on glibc 2.8 and on BSD systems. */
71 c = fgetc (f);
72 ungetc ('@', f);
73 fflush (f);
74 if (fgetc (f) != c)
75 { fclose (f); return 7; }
76 fclose (f);
77 return 0;
78 ]])],
79 [gl_cv_func_fflush_stdin=yes],
80 [gl_cv_func_fflush_stdin=no],
81 [case "$host_os" in
82 # Guess no on native Windows.
83 mingw*) gl_cv_func_fflush_stdin="guessing no" ;;
84 *) gl_cv_func_fflush_stdin=cross ;;
85 esac
86 ])
87 rm conftest.txt
88 ])
89 case "$gl_cv_func_fflush_stdin" in
90 *yes) gl_func_fflush_stdin=1 ;;
91 *no) gl_func_fflush_stdin=0 ;;
92 *) gl_func_fflush_stdin='(-1)' ;;
93 esac
94 AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin],
95 [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008,
96 0 if fflush is known to not work, -1 if unknown.])
97])
98
99# Prerequisites of lib/fflush.c.
100AC_DEFUN([gl_PREREQ_FFLUSH], [:])
diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4
index 397f2d1..2f0c9c4 100644
--- a/gl/m4/float_h.m4
+++ b/gl/m4/float_h.m4
@@ -1,5 +1,5 @@
1# float_h.m4 serial 9 1# float_h.m4 serial 13
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,42 +8,46 @@ AC_DEFUN([gl_FLOAT_H],
8[ 8[
9 AC_REQUIRE([AC_PROG_CC]) 9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) 10 AC_REQUIRE([AC_CANONICAL_HOST])
11 FLOAT_H= 11 GL_GENERATE_FLOAT_H=false
12 REPLACE_FLOAT_LDBL=0 12 REPLACE_FLOAT_LDBL=0
13 case "$host_os" in 13 case "$host_os" in
14 aix* | beos* | openbsd* | mirbsd* | irix*) 14 aix* | beos* | openbsd* | mirbsd* | irix*)
15 FLOAT_H=float.h 15 GL_GENERATE_FLOAT_H=true
16 ;; 16 ;;
17 freebsd*) 17 freebsd* | dragonfly*)
18 case "$host_cpu" in 18 case "$host_cpu" in
19changequote(,)dnl 19changequote(,)dnl
20 i[34567]86 ) 20 i[34567]86 )
21changequote([,])dnl 21changequote([,])dnl
22 FLOAT_H=float.h 22 GL_GENERATE_FLOAT_H=true
23 ;; 23 ;;
24 x86_64 ) 24 x86_64 )
25 # On x86_64 systems, the C compiler may still be generating 25 # On x86_64 systems, the C compiler may still be generating
26 # 32-bit code. 26 # 32-bit code.
27 AC_EGREP_CPP([yes], 27 AC_COMPILE_IFELSE(
28 [#if defined __LP64__ || defined __x86_64__ || defined __amd64__ 28 [AC_LANG_SOURCE(
29 yes 29 [[#if defined __LP64__ || defined __x86_64__ || defined __amd64__
30 #endif], 30 int ok;
31 #else
32 error fail
33 #endif
34 ]])],
31 [], 35 [],
32 [FLOAT_H=float.h]) 36 [GL_GENERATE_FLOAT_H=true])
33 ;; 37 ;;
34 esac 38 esac
35 ;; 39 ;;
36 linux*) 40 linux*)
37 case "$host_cpu" in 41 case "$host_cpu" in
38 powerpc*) 42 powerpc*)
39 FLOAT_H=float.h 43 GL_GENERATE_FLOAT_H=true
40 ;; 44 ;;
41 esac 45 esac
42 ;; 46 ;;
43 esac 47 esac
44 case "$host_os" in 48 case "$host_os" in
45 aix* | freebsd* | linux*) 49 aix* | freebsd* | dragonfly* | linux*)
46 if test -n "$FLOAT_H"; then 50 if $GL_GENERATE_FLOAT_H; then
47 REPLACE_FLOAT_LDBL=1 51 REPLACE_FLOAT_LDBL=1
48 fi 52 fi
49 ;; 53 ;;
@@ -69,14 +73,20 @@ int main ()
69 [gl_cv_func_itold_works=no], 73 [gl_cv_func_itold_works=no],
70 [case "$host" in 74 [case "$host" in
71 sparc*-*-linux*) 75 sparc*-*-linux*)
72 AC_EGREP_CPP([yes], 76 AC_COMPILE_IFELSE(
73 [#if defined __LP64__ || defined __arch64__ 77 [AC_LANG_SOURCE(
74 yes 78 [[#if defined __LP64__ || defined __arch64__
75 #endif], 79 int ok;
80 #else
81 error fail
82 #endif
83 ]])],
76 [gl_cv_func_itold_works="guessing no"], 84 [gl_cv_func_itold_works="guessing no"],
77 [gl_cv_func_itold_works="guessing yes"]) 85 [gl_cv_func_itold_works="guessing yes"])
78 ;; 86 ;;
79 *) gl_cv_func_itold_works="guessing yes" ;; 87 # Guess yes on native Windows.
88 mingw*) gl_cv_func_itold_works="guessing yes" ;;
89 *) gl_cv_func_itold_works="guessing yes" ;;
80 esac 90 esac
81 ]) 91 ])
82 ]) 92 ])
@@ -85,14 +95,12 @@ int main ()
85 REPLACE_ITOLD=1 95 REPLACE_ITOLD=1
86 dnl We add the workaround to <float.h> but also to <math.h>, 96 dnl We add the workaround to <float.h> but also to <math.h>,
87 dnl to increase the chances that the fix function gets pulled in. 97 dnl to increase the chances that the fix function gets pulled in.
88 FLOAT_H=float.h 98 GL_GENERATE_FLOAT_H=true
89 ;; 99 ;;
90 esac 100 esac
91 101
92 if test -n "$FLOAT_H"; then 102 if $GL_GENERATE_FLOAT_H; then
93 gl_NEXT_HEADERS([float.h]) 103 gl_NEXT_HEADERS([float.h])
94 fi 104 fi
95 AC_SUBST([FLOAT_H])
96 AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
97 AC_SUBST([REPLACE_ITOLD]) 105 AC_SUBST([REPLACE_ITOLD])
98]) 106])
diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4
index c892ff9..c49ffa6 100644
--- a/gl/m4/floorf.m4
+++ b/gl/m4/floorf.m4
@@ -1,5 +1,5 @@
1# floorf.m4 serial 13 1# floorf.m4 serial 18
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -39,7 +39,7 @@ AC_DEFUN([gl_FUNC_FLOORF],
39static float dummy (float f) { return 0; } 39static float dummy (float f) { return 0; }
40int main (int argc, char *argv[]) 40int main (int argc, char *argv[])
41{ 41{
42 float (*my_floorf) (float) = argc ? floorf : dummy; 42 float (* volatile my_floorf) (float) = argc ? floorf : dummy;
43 /* Test whether floorf (-0.0f) is -0.0f. */ 43 /* Test whether floorf (-0.0f) is -0.0f. */
44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof))) 44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof)))
45 return 1; 45 return 1;
@@ -49,10 +49,14 @@ int main (int argc, char *argv[])
49 [gl_cv_func_floorf_ieee=yes], 49 [gl_cv_func_floorf_ieee=yes],
50 [gl_cv_func_floorf_ieee=no], 50 [gl_cv_func_floorf_ieee=no],
51 [case "$host_os" in 51 [case "$host_os" in
52 # Guess yes on glibc systems. 52 # Guess yes on glibc systems.
53 *-gnu*) gl_cv_func_floorf_ieee="guessing yes" ;; 53 *-gnu* | gnu*) gl_cv_func_floorf_ieee="guessing yes" ;;
54 # If we don't know, assume the worst. 54 # Guess yes on musl systems.
55 *) gl_cv_func_floorf_ieee="guessing no" ;; 55 *-musl*) gl_cv_func_floorf_ieee="guessing yes" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_floorf_ieee="guessing yes" ;;
58 # If we don't know, obey --enable-cross-guesses.
59 *) gl_cv_func_floorf_ieee="$gl_cross_guess_normal" ;;
56 esac 60 esac
57 ]) 61 ])
58 LIBS="$save_LIBS" 62 LIBS="$save_LIBS"
diff --git a/gl/m4/fopen.m4 b/gl/m4/fopen.m4
new file mode 100644
index 0000000..9c39ff7
--- /dev/null
+++ b/gl/m4/fopen.m4
@@ -0,0 +1,149 @@
1# fopen.m4 serial 13
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FOPEN],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 case "$host_os" in
12 mingw* | pw*)
13 dnl Replace fopen, for handling of "/dev/null".
14 REPLACE_FOPEN=1
15 dnl fopen on mingw also has the trailing slash bug.
16 gl_cv_func_fopen_slash="guessing no"
17 ;;
18 *)
19 dnl fopen("foo/", "w") should not create a file when the file name has a
20 dnl trailing slash.
21 AC_CACHE_CHECK([whether fopen recognizes a trailing slash],
22 [gl_cv_func_fopen_slash],
23 [
24 AC_RUN_IFELSE(
25 [AC_LANG_SOURCE([[
26#include <stddef.h>
27#include <stdio.h>
28int main ()
29{
30 FILE *fp = fopen ("conftest.sl/", "w");
31 int result = (fp != NULL);
32 if (fp != NULL)
33 fclose (fp);
34 return result;
35}]])],
36 [gl_cv_func_fopen_slash=yes],
37 [gl_cv_func_fopen_slash=no],
38 [
39changequote(,)dnl
40 case "$host_os" in
41 aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
42 gl_cv_func_fopen_slash="guessing no" ;;
43 *)
44 gl_cv_func_fopen_slash="guessing yes" ;;
45 esac
46changequote([,])dnl
47 ])
48 rm -f conftest.sl
49 ])
50 ;;
51 esac
52 case "$gl_cv_func_fopen_slash" in
53 *no)
54 AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1],
55 [Define to 1 if fopen() fails to recognize a trailing slash.])
56 REPLACE_FOPEN=1
57 ;;
58 esac
59])
60
61AC_DEFUN([gl_FUNC_FOPEN_GNU],
62[
63 AC_REQUIRE([gl_FUNC_FOPEN])
64 AC_CACHE_CHECK([whether fopen supports the mode character 'x'],
65 [gl_cv_func_fopen_mode_x],
66 [rm -f conftest.x
67 AC_RUN_IFELSE(
68 [AC_LANG_SOURCE([[
69#include <stdio.h>
70#include <errno.h>
71int main ()
72{
73 FILE *fp;
74 fp = fopen ("conftest.x", "w");
75 fclose (fp);
76 fp = fopen ("conftest.x", "wx");
77 if (fp != NULL)
78 /* 'x' ignored */
79 return 1;
80 else if (errno == EEXIST)
81 return 0;
82 else
83 /* 'x' rejected */
84 return 2;
85}]])],
86 [gl_cv_func_fopen_mode_x=yes],
87 [gl_cv_func_fopen_mode_x=no],
88 [case "$host_os" in
89 # Guess yes on glibc and musl systems.
90 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*)
91 gl_cv_func_fopen_mode_x="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses.
93 *)
94 gl_cv_func_fopen_mode_x="$gl_cross_guess_normal" ;;
95 esac
96 ])
97 rm -f conftest.x
98 ])
99 AC_CACHE_CHECK([whether fopen supports the mode character 'e'],
100 [gl_cv_func_fopen_mode_e],
101 [echo foo > conftest.x
102 AC_RUN_IFELSE(
103 [AC_LANG_SOURCE([[
104#include <stdio.h>
105#include <errno.h>
106#include <fcntl.h>
107]GL_MDA_DEFINES[
108int main ()
109{
110 FILE *fp = fopen ("conftest.x", "re");
111 if (fp != NULL)
112 {
113 if (fcntl (fileno (fp), F_GETFD) & FD_CLOEXEC)
114 return 0;
115 else
116 /* 'e' ignored */
117 return 1;
118 }
119 else
120 /* 'e' rejected */
121 return 2;
122}]])],
123 [gl_cv_func_fopen_mode_e=yes],
124 [gl_cv_func_fopen_mode_e=no],
125 [case "$host_os" in
126 # Guess yes on glibc and musl systems.
127 linux*-gnu* | gnu* | kfreebsd*-gnu | *-musl*)
128 gl_cv_func_fopen_mode_e="guessing yes" ;;
129 # Guess no on native Windows.
130 mingw*)
131 gl_cv_func_fopen_mode_e="guessing no" ;;
132 # If we don't know, obey --enable-cross-guesses.
133 *)
134 gl_cv_func_fopen_mode_e="$gl_cross_guess_normal" ;;
135 esac
136 ])
137 rm -f conftest.x
138 ])
139 REPLACE_FOPEN_FOR_FOPEN_GNU="$REPLACE_FOPEN"
140 case "$gl_cv_func_fopen_mode_x" in
141 *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
142 esac
143 case "$gl_cv_func_fopen_mode_e" in
144 *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
145 esac
146])
147
148# Prerequisites of lib/fopen.c.
149AC_DEFUN([gl_PREREQ_FOPEN], [:])
diff --git a/gl/m4/fpurge.m4 b/gl/m4/fpurge.m4
new file mode 100644
index 0000000..b365409
--- /dev/null
+++ b/gl/m4/fpurge.m4
@@ -0,0 +1,73 @@
1# fpurge.m4 serial 12
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FPURGE],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
12 AC_CHECK_FUNCS_ONCE([fpurge])
13 AC_CHECK_FUNCS_ONCE([__fpurge])
14 AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
15 if test "x$ac_cv_func_fpurge" = xyes; then
16 HAVE_FPURGE=1
17 # Detect BSD bug. Only cygwin 1.7 and musl are known to be immune.
18 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
19 [AC_RUN_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[#include <stdio.h>
22]],
23 [[FILE *f = fopen ("conftest.txt", "w+");
24 if (!f)
25 return 1;
26 if (fputc ('a', f) != 'a')
27 { fclose (f); return 2; }
28 rewind (f);
29 if (fgetc (f) != 'a')
30 { fclose (f); return 3; }
31 if (fgetc (f) != EOF)
32 { fclose (f); return 4; }
33 if (fpurge (f) != 0)
34 { fclose (f); return 5; }
35 if (putc ('b', f) != 'b')
36 { fclose (f); return 6; }
37 if (fclose (f) != 0)
38 return 7;
39 if ((f = fopen ("conftest.txt", "r")) == NULL)
40 return 8;
41 if (fgetc (f) != 'a')
42 { fclose (f); return 9; }
43 if (fgetc (f) != 'b')
44 { fclose (f); return 10; }
45 if (fgetc (f) != EOF)
46 { fclose (f); return 11; }
47 if (fclose (f) != 0)
48 return 12;
49 if (remove ("conftest.txt") != 0)
50 return 13;
51 return 0;
52 ]])],
53 [gl_cv_func_fpurge_works=yes],
54 [gl_cv_func_fpurge_works=no],
55 [case "$host_os" in
56 # Guess yes on musl systems.
57 *-musl*) gl_cv_func_fpurge_works="guessing yes" ;;
58 # Otherwise obey --enable-cross-guesses.
59 *) gl_cv_func_fpurge_works="$gl_cross_guess_normal" ;;
60 esac
61 ])
62 ])
63 case "$gl_cv_func_fpurge_works" in
64 *yes) ;;
65 *) REPLACE_FPURGE=1 ;;
66 esac
67 else
68 HAVE_FPURGE=0
69 fi
70 if test "x$ac_cv_have_decl_fpurge" = xno; then
71 HAVE_DECL_FPURGE=0
72 fi
73])
diff --git a/gl/m4/sha1.m4 b/gl/m4/freading.m4
index 21c775e..3533336 100644
--- a/gl/m4/sha1.m4
+++ b/gl/m4/freading.m4
@@ -1,12 +1,11 @@
1# sha1.m4 serial 11 1# freading.m4 serial 2
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_SHA1], 7AC_DEFUN([gl_FUNC_FREADING],
8[ 8[
9 dnl Prerequisites of lib/sha1.c. 9 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
10 AC_REQUIRE([gl_BIGENDIAN]) 10 AC_CHECK_FUNCS_ONCE([__freading])
11 :
12]) 11])
diff --git a/gl/m4/free.m4 b/gl/m4/free.m4
new file mode 100644
index 0000000..0389dea
--- /dev/null
+++ b/gl/m4/free.m4
@@ -0,0 +1,52 @@
1# free.m4 serial 6
2# Copyright (C) 2003-2005, 2009-2023 Free Software Foundation, Inc.
3# This file is free software; the Free Software Foundation
4# gives unlimited permission to copy and/or distribute it,
5# with or without modifications, as long as this notice is preserved.
6
7# Written by Paul Eggert and Bruno Haible.
8
9AC_DEFUN([gl_FUNC_FREE],
10[
11 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
12
13 dnl In the next release of POSIX, free must preserve errno.
14 dnl https://www.austingroupbugs.net/view.php?id=385
15 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=17924
16 dnl So far, we know of three platforms that do this:
17 dnl * glibc >= 2.33, thanks to the fix for this bug:
18 dnl <https://sourceware.org/bugzilla/show_bug.cgi?id=17924>
19 dnl * OpenBSD >= 4.5, thanks to this commit:
20 dnl <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/malloc.c.diff?r1=1.100&r2=1.101&f=h>
21 dnl * Solaris, because its malloc() implementation is based on brk(),
22 dnl not mmap(); hence its free() implementation makes no system calls.
23 dnl For other platforms, you can only be sure if they state it in their
24 dnl documentation, or by code inspection of the free() implementation in libc.
25 AC_CACHE_CHECK([whether free is known to preserve errno],
26 [gl_cv_func_free_preserves_errno],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[#include <stdlib.h>
30 ]],
31 [[#if 2 < __GLIBC__ + (33 <= __GLIBC_MINOR__)
32 #elif defined __OpenBSD__
33 #elif defined __sun
34 #else
35 #error "'free' is not known to preserve errno"
36 #endif
37 ]])],
38 [gl_cv_func_free_preserves_errno=yes],
39 [gl_cv_func_free_preserves_errno=no])
40 ])
41
42 case $gl_cv_func_free_preserves_errno in
43 *yes)
44 AC_DEFINE([HAVE_FREE_POSIX], [1],
45 [Define if the 'free' function is guaranteed to preserve errno.])
46 ;;
47 *) REPLACE_FREE=1 ;;
48 esac
49])
50
51# Prerequisites of lib/free.c.
52AC_DEFUN([gl_PREREQ_FREE], [:])
diff --git a/gl/m4/fseek.m4 b/gl/m4/fseek.m4
new file mode 100644
index 0000000..c5fe688
--- /dev/null
+++ b/gl/m4/fseek.m4
@@ -0,0 +1,15 @@
1# fseek.m4 serial 4
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEK],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FSEEKO])
11 dnl When fseeko needs fixes, fseek needs them too.
12 if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then
13 REPLACE_FSEEK=1
14 fi
15])
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
new file mode 100644
index 0000000..05ee06b
--- /dev/null
+++ b/gl/m4/fseeko.m4
@@ -0,0 +1,77 @@
1# fseeko.m4 serial 20
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSEEKO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
11 AC_REQUIRE([gl_SYS_TYPES_H])
12 AC_REQUIRE([AC_PROG_CC])
13
14 dnl Persuade glibc <stdio.h> to declare fseeko().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
18 [
19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
20]], [[fseeko (stdin, 0, 0);]])],
21 [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
22 ])
23
24 AC_CHECK_DECLS_ONCE([fseeko])
25 if test $ac_cv_have_decl_fseeko = no; then
26 HAVE_DECL_FSEEKO=0
27 fi
28
29 if test $gl_cv_func_fseeko = no; then
30 HAVE_FSEEKO=0
31 else
32 if test $WINDOWS_64_BIT_OFF_T = 1; then
33 REPLACE_FSEEKO=1
34 fi
35 if test $gl_cv_var_stdin_large_offset = no; then
36 REPLACE_FSEEKO=1
37 fi
38 m4_ifdef([gl_FUNC_FFLUSH_STDIN], [
39 gl_FUNC_FFLUSH_STDIN
40 case "$gl_cv_func_fflush_stdin" in
41 *yes) ;;
42 *) REPLACE_FSEEKO=1 ;;
43 esac
44 ])
45 fi
46])
47
48dnl Code shared by fseeko and ftello. Determine if large files are supported,
49dnl but stdin does not start as a large file by default.
50AC_DEFUN([gl_STDIN_LARGE_OFFSET],
51 [
52 AC_CACHE_CHECK([whether stdin defaults to large file offsets],
53 [gl_cv_var_stdin_large_offset],
54 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
55[[#if defined __SL64 && defined __SCLE /* cygwin */
56 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
57 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
58 it is easier to do a version check than building a runtime test. */
59# include <cygwin/version.h>
60# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
61 choke me
62# endif
63#endif]])],
64 [gl_cv_var_stdin_large_offset=yes],
65 [gl_cv_var_stdin_large_offset=no])])
66])
67
68# Prerequisites of lib/fseeko.c.
69AC_DEFUN([gl_PREREQ_FSEEKO],
70[
71 dnl Native Windows has the function _fseeki64. mingw hides it in some
72 dnl circumstances, but mingw64 makes it usable again.
73 AC_CHECK_FUNCS([_fseeki64])
74 if test $ac_cv_func__fseeki64 = yes; then
75 AC_CHECK_DECLS([_fseeki64])
76 fi
77])
diff --git a/gl/m4/fstat.m4 b/gl/m4/fstat.m4
new file mode 100644
index 0000000..7cb2edb
--- /dev/null
+++ b/gl/m4/fstat.m4
@@ -0,0 +1,40 @@
1# fstat.m4 serial 8
2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FSTAT],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
11
12 case "$host_os" in
13 mingw* | solaris*)
14 dnl On MinGW, the original stat() returns st_atime, st_mtime,
15 dnl st_ctime values that are affected by the time zone.
16 dnl Solaris stat can return a negative tv_nsec.
17 REPLACE_FSTAT=1
18 ;;
19 esac
20
21 dnl Replace fstat() for supporting the gnulib-defined open() on directories.
22 m4_ifdef([gl_FUNC_FCHDIR], [
23 gl_TEST_FCHDIR
24 if test $HAVE_FCHDIR = 0; then
25 case "$gl_cv_func_open_directory_works" in
26 *yes) ;;
27 *)
28 REPLACE_FSTAT=1
29 ;;
30 esac
31 fi
32 ])
33])
34
35# Prerequisites of lib/fstat.c and lib/stat-w32.c.
36AC_DEFUN([gl_PREREQ_FSTAT], [
37 AC_REQUIRE([gl_SYS_STAT_H])
38 AC_REQUIRE([gl_PREREQ_STAT_W32])
39 :
40])
diff --git a/gl/m4/fstypename.m4 b/gl/m4/fstypename.m4
index c72ecb8..f65c459 100644
--- a/gl/m4/fstypename.m4
+++ b/gl/m4/fstypename.m4
@@ -6,7 +6,7 @@ dnl See if struct statfs has the f_fstypename member.
6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. 6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
7dnl 7dnl
8 8
9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2013 Free Software 9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2023 Free Software
10# Foundation, Inc. 10# Foundation, Inc.
11# This file is free software; the Free Software Foundation 11# This file is free software; the Free Software Foundation
12# gives unlimited permission to copy and/or distribute it, 12# gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4
index 6277bfa..88f3ca8 100644
--- a/gl/m4/fsusage.m4
+++ b/gl/m4/fsusage.m4
@@ -1,7 +1,7 @@
1# serial 30 1# serial 35
2# Obtaining file system usage information. 2# Obtaining file system usage information.
3 3
4# Copyright (C) 1997-1998, 2000-2001, 2003-2013 Free Software Foundation, Inc. 4# Copyright (C) 1997-1998, 2000-2001, 2003-2023 Free Software Foundation, Inc.
5# 5#
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -29,27 +29,29 @@ AC_DEFUN([gl_FSUSAGE],
29 29
30AC_DEFUN([gl_FILE_SYSTEM_USAGE], 30AC_DEFUN([gl_FILE_SYSTEM_USAGE],
31[ 31[
32dnl Enable large-file support. This has the effect of changing the size 32 dnl Enable large-file support. This has the effect of changing the size
33dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on 33 dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on
34dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size 34 dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size
35dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on 35 dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
36dnl Mac OS X >= 10.5 (32-bit mode). 36 dnl Mac OS X >= 10.5 (32-bit mode).
37AC_REQUIRE([AC_SYS_LARGEFILE]) 37 AC_REQUIRE([AC_SYS_LARGEFILE])
38 38
39AC_MSG_NOTICE([checking how to get file system space usage]) 39 ac_fsusage_space=no
40ac_fsusage_space=no
41 40
42# Perform only the link test since it seems there are no variants of the 41 # Perform only the link test since it seems there are no variants of the
43# statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs]) 42 # statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs])
44# because that got a false positive on SCO OSR5. Adding the declaration 43 # because that got a false positive on SCO OSR5. Adding the declaration
45# of a 'struct statvfs' causes this test to fail (as it should) on such 44 # of a 'struct statvfs' causes this test to fail (as it should) on such
46# systems. That system is reported to work fine with STAT_STATFS4 which 45 # systems. That system is reported to work fine with STAT_STATFS4 which
47# is what it gets when this test fails. 46 # is what it gets when this test fails.
48if test $ac_fsusage_space = no; then 47 if test $ac_fsusage_space = no; then
49 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 48 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
50 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. 49 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS.
51 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], 50 AC_CACHE_CHECK([for statvfs function (SVR4)],
52 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 51 [fu_cv_sys_stat_statvfs],
52 [AC_LINK_IFELSE(
53 [AC_LANG_PROGRAM([[
54#include <sys/types.h>
53#ifdef __osf__ 55#ifdef __osf__
54"Do not use Tru64's statvfs implementation" 56"Do not use Tru64's statvfs implementation"
55#endif 57#endif
@@ -68,45 +70,47 @@ struct statvfs fsd;
68int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; 70int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
69#endif 71#endif
70]], 72]],
71 [[statvfs (0, &fsd);]])], 73 [[statvfs (0, &fsd);]])],
72 [fu_cv_sys_stat_statvfs=yes], 74 [fu_cv_sys_stat_statvfs=yes],
73 [fu_cv_sys_stat_statvfs=no])]) 75 [fu_cv_sys_stat_statvfs=no])
74 if test $fu_cv_sys_stat_statvfs = yes; then
75 ac_fsusage_space=yes
76 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
77 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
78 # statvfs with large-file support is already equivalent to statvfs64.
79 AC_CACHE_CHECK([whether to use statvfs64],
80 [fu_cv_sys_stat_statvfs64],
81 [AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[#include <sys/types.h>
84 #include <sys/statvfs.h>
85 struct statvfs64 fsd;
86 int check_f_blocks_larger_in_statvfs64
87 [sizeof (((struct statvfs64 *) 0)->f_blocks)
88 > sizeof (((struct statvfs *) 0)->f_blocks)
89 ? 1 : -1];
90 ]],
91 [[statvfs64 (0, &fsd);]])],
92 [fu_cv_sys_stat_statvfs64=yes],
93 [fu_cv_sys_stat_statvfs64=no])
94 ]) 76 ])
95 if test $fu_cv_sys_stat_statvfs64 = yes; then 77 if test $fu_cv_sys_stat_statvfs = yes; then
96 AC_DEFINE([STAT_STATVFS64], [1], 78 ac_fsusage_space=yes
97 [ Define if statvfs64 should be preferred over statvfs.]) 79 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
98 else 80 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
99 AC_DEFINE([STAT_STATVFS], [1], 81 # statvfs with large-file support is already equivalent to statvfs64.
100 [ Define if there is a function named statvfs. (SVR4)]) 82 AC_CACHE_CHECK([whether to use statvfs64],
83 [fu_cv_sys_stat_statvfs64],
84 [AC_LINK_IFELSE(
85 [AC_LANG_PROGRAM(
86 [[#include <sys/types.h>
87 #include <sys/statvfs.h>
88 struct statvfs64 fsd;
89 int check_f_blocks_larger_in_statvfs64
90 [sizeof (((struct statvfs64 *) 0)->f_blocks)
91 > sizeof (((struct statvfs *) 0)->f_blocks)
92 ? 1 : -1];
93 ]],
94 [[statvfs64 (0, &fsd);]])],
95 [fu_cv_sys_stat_statvfs64=yes],
96 [fu_cv_sys_stat_statvfs64=no])
97 ])
98 if test $fu_cv_sys_stat_statvfs64 = yes; then
99 AC_DEFINE([STAT_STATVFS64], [1],
100 [Define if statvfs64 should be preferred over statvfs.])
101 else
102 AC_DEFINE([STAT_STATVFS], [1],
103 [Define if there is a function named statvfs. (SVR4)])
104 fi
101 fi 105 fi
102 fi 106 fi
103fi
104 107
105# Check for this unconditionally so we have a 108 # Check for this unconditionally so we have a
106# good fallback on glibc/Linux > 2.6 < 2.6.36 109 # good fallback on glibc/Linux > 2.6 < 2.6.36
107AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member]) 110 AC_CACHE_CHECK([for two-argument statfs with statfs.f_frsize member],
108AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize], 111 [fu_cv_sys_stat_statfs2_frsize],
109[AC_RUN_IFELSE([AC_LANG_SOURCE([[ 112 [AC_RUN_IFELSE(
113 [AC_LANG_SOURCE([[
110#ifdef HAVE_SYS_PARAM_H 114#ifdef HAVE_SYS_PARAM_H
111#include <sys/param.h> 115#include <sys/param.h>
112#endif 116#endif
@@ -119,26 +123,26 @@ AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize],
119 int 123 int
120 main () 124 main ()
121 { 125 {
122 struct statfs fsd; 126 struct statfs fsd;
123 fsd.f_frsize = 0; 127 fsd.f_frsize = 0;
124 return statfs (".", &fsd) != 0; 128 return statfs (".", &fsd) != 0;
125 }]])], 129 }]])],
126 [fu_cv_sys_stat_statfs2_frsize=yes], 130 [fu_cv_sys_stat_statfs2_frsize=yes],
127 [fu_cv_sys_stat_statfs2_frsize=no], 131 [fu_cv_sys_stat_statfs2_frsize=no],
128 [fu_cv_sys_stat_statfs2_frsize=no])]) 132 [fu_cv_sys_stat_statfs2_frsize=no])
129AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize]) 133 ])
130if test $fu_cv_sys_stat_statfs2_frsize = yes; then 134 if test $fu_cv_sys_stat_statfs2_frsize = yes; then
131 ac_fsusage_space=yes 135 ac_fsusage_space=yes
132 AC_DEFINE([STAT_STATFS2_FRSIZE], [1], 136 AC_DEFINE([STAT_STATFS2_FRSIZE], [1],
133[ Define if statfs takes 2 args and struct statfs has a field named f_frsize. 137 [Define if statfs takes 2 args and struct statfs has a field named f_frsize.
134 (glibc/Linux > 2.6)]) 138 (glibc/Linux > 2.6)])
135fi 139 fi
136 140
137if test $ac_fsusage_space = no; then 141 if test $ac_fsusage_space = no; then
138 # DEC Alpha running OSF/1 142 # DEC Alpha running OSF/1
139 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) 143 AC_CACHE_CHECK([for 3-argument statfs function (DEC OSF/1)],
140 AC_CACHE_VAL([fu_cv_sys_stat_statfs3_osf1], 144 [fu_cv_sys_stat_statfs3_osf1],
141 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 145 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
142#include <sys/param.h> 146#include <sys/param.h>
143#include <sys/types.h> 147#include <sys/types.h>
144#include <sys/mount.h> 148#include <sys/mount.h>
@@ -149,28 +153,27 @@ if test $ac_fsusage_space = no; then
149 fsd.f_fsize = 0; 153 fsd.f_fsize = 0;
150 return statfs (".", &fsd, sizeof (struct statfs)) != 0; 154 return statfs (".", &fsd, sizeof (struct statfs)) != 0;
151 }]])], 155 }]])],
152 [fu_cv_sys_stat_statfs3_osf1=yes], 156 [fu_cv_sys_stat_statfs3_osf1=yes],
153 [fu_cv_sys_stat_statfs3_osf1=no], 157 [fu_cv_sys_stat_statfs3_osf1=no],
154 [fu_cv_sys_stat_statfs3_osf1=no])]) 158 [fu_cv_sys_stat_statfs3_osf1=no])
155 AC_MSG_RESULT([$fu_cv_sys_stat_statfs3_osf1]) 159 ])
156 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then 160 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
157 ac_fsusage_space=yes 161 ac_fsusage_space=yes
158 AC_DEFINE([STAT_STATFS3_OSF1], [1], 162 AC_DEFINE([STAT_STATFS3_OSF1], [1],
159 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) 163 [Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
164 fi
160 fi 165 fi
161fi
162 166
163if test $ac_fsusage_space = no; then 167 if test $ac_fsusage_space = no; then
164 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. 168 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
165 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0, 169 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
166 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) 170 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
167 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and 171 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
168 # <sys/vfs.h>.) 172 # <sys/vfs.h>.)
169 # (On Solaris, statfs has 4 arguments.) 173 # (On Solaris, statfs has 4 arguments.)
170 AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl 174 AC_CACHE_CHECK([for two-argument statfs with statfs.f_bsize member (AIX, 4.3BSD)],
171member (AIX, 4.3BSD)]) 175 [fu_cv_sys_stat_statfs2_bsize],
172 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize], 176 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
173 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
174#ifdef HAVE_SYS_PARAM_H 177#ifdef HAVE_SYS_PARAM_H
175#include <sys/param.h> 178#include <sys/param.h>
176#endif 179#endif
@@ -183,88 +186,56 @@ member (AIX, 4.3BSD)])
183 int 186 int
184 main () 187 main ()
185 { 188 {
186 struct statfs fsd; 189 struct statfs fsd;
187 fsd.f_bsize = 0; 190 fsd.f_bsize = 0;
188 return statfs (".", &fsd) != 0; 191 return statfs (".", &fsd) != 0;
189 }]])], 192 }]])],
190 [fu_cv_sys_stat_statfs2_bsize=yes], 193 [fu_cv_sys_stat_statfs2_bsize=yes],
191 [fu_cv_sys_stat_statfs2_bsize=no], 194 [fu_cv_sys_stat_statfs2_bsize=no],
192 [fu_cv_sys_stat_statfs2_bsize=no])]) 195 [fu_cv_sys_stat_statfs2_bsize=no])
193 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize]) 196 ])
194 if test $fu_cv_sys_stat_statfs2_bsize = yes; then 197 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
195 ac_fsusage_space=yes 198 ac_fsusage_space=yes
196 AC_DEFINE([STAT_STATFS2_BSIZE], [1], 199 AC_DEFINE([STAT_STATFS2_BSIZE], [1],
197[ Define if statfs takes 2 args and struct statfs has a field named f_bsize. 200 [Define if statfs takes 2 args and struct statfs has a field named f_bsize.
198 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)]) 201 (4.3BSD, SunOS 4, HP-UX)])
202 fi
199 fi 203 fi
200fi
201 204
202if test $ac_fsusage_space = no; then 205 if test $ac_fsusage_space = no; then
203 # SVR3 206 # SVR3
204 # (Solaris already handled above.) 207 # (Solaris already handled above.)
205 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) 208 AC_CACHE_CHECK([for four-argument statfs (SVR3)],
206 AC_CACHE_VAL([fu_cv_sys_stat_statfs4], 209 [fu_cv_sys_stat_statfs4],
207 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 210 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
208#include <sys/types.h> 211#include <sys/types.h>
209#include <sys/statfs.h> 212#include <sys/statfs.h>
210 int 213 int
211 main () 214 main ()
212 { 215 {
213 struct statfs fsd; 216 struct statfs fsd;
214 return statfs (".", &fsd, sizeof fsd, 0) != 0; 217 return statfs (".", &fsd, sizeof fsd, 0) != 0;
215 }]])],
216 [fu_cv_sys_stat_statfs4=yes],
217 [fu_cv_sys_stat_statfs4=no],
218 [fu_cv_sys_stat_statfs4=no])])
219 AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
220 if test $fu_cv_sys_stat_statfs4 = yes; then
221 ac_fsusage_space=yes
222 AC_DEFINE([STAT_STATFS4], [1],
223 [ Define if statfs takes 4 args. (SVR3, Dynix, old Irix, old AIX, Dolphin)])
224 fi
225fi
226
227if test $ac_fsusage_space = no; then
228 # 4.4BSD and older NetBSD
229 # (OSF/1 already handled above.)
230 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
231 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
232 # <sys/mount.h>.)
233 AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl
234member (4.4BSD and NetBSD)])
235 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
236 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
237#include <sys/types.h>
238#ifdef HAVE_SYS_PARAM_H
239#include <sys/param.h>
240#endif
241#ifdef HAVE_SYS_MOUNT_H
242#include <sys/mount.h>
243#endif
244 int
245 main ()
246 {
247 struct statfs fsd;
248 fsd.f_fsize = 0;
249 return statfs (".", &fsd) != 0;
250 }]])], 218 }]])],
251 [fu_cv_sys_stat_statfs2_fsize=yes], 219 [fu_cv_sys_stat_statfs4=yes],
252 [fu_cv_sys_stat_statfs2_fsize=no], 220 [fu_cv_sys_stat_statfs4=no],
253 [fu_cv_sys_stat_statfs2_fsize=no])]) 221 [fu_cv_sys_stat_statfs4=no])
254 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize]) 222 ])
255 if test $fu_cv_sys_stat_statfs2_fsize = yes; then 223 if test $fu_cv_sys_stat_statfs4 = yes; then
256 ac_fsusage_space=yes 224 ac_fsusage_space=yes
257 AC_DEFINE([STAT_STATFS2_FSIZE], [1], 225 AC_DEFINE([STAT_STATFS4], [1],
258[ Define if statfs takes 2 args and struct statfs has a field named f_fsize. 226 [Define if statfs takes 4 args. (SVR3, old Irix)])
259 (4.4BSD, NetBSD)]) 227 fi
260 fi 228 fi
261fi
262 229
263if test $ac_fsusage_space = no; then 230 if test $ac_fsusage_space = no; then
264 # Ultrix 231 # 4.4BSD and older NetBSD
265 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) 232 # (OSF/1 already handled above.)
266 AC_CACHE_VAL([fu_cv_sys_stat_fs_data], 233 # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
267 [AC_RUN_IFELSE([AC_LANG_SOURCE([[ 234 # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
235 # <sys/mount.h>.)
236 AC_CACHE_CHECK([for two-argument statfs with statfs.f_fsize member (4.4BSD and NetBSD)],
237 [fu_cv_sys_stat_statfs2_fsize],
238 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
268#include <sys/types.h> 239#include <sys/types.h>
269#ifdef HAVE_SYS_PARAM_H 240#ifdef HAVE_SYS_PARAM_H
270#include <sys/param.h> 241#include <sys/param.h>
@@ -272,41 +243,26 @@ if test $ac_fsusage_space = no; then
272#ifdef HAVE_SYS_MOUNT_H 243#ifdef HAVE_SYS_MOUNT_H
273#include <sys/mount.h> 244#include <sys/mount.h>
274#endif 245#endif
275#ifdef HAVE_SYS_FS_TYPES_H
276#include <sys/fs_types.h>
277#endif
278 int 246 int
279 main () 247 main ()
280 { 248 {
281 struct fs_data fsd; 249 struct statfs fsd;
282 /* Ultrix's statfs returns 1 for success, 250 fsd.f_fsize = 0;
283 0 for not mounted, -1 for failure. */ 251 return statfs (".", &fsd) != 0;
284 return statfs (".", &fsd) != 1;
285 }]])], 252 }]])],
286 [fu_cv_sys_stat_fs_data=yes], 253 [fu_cv_sys_stat_statfs2_fsize=yes],
287 [fu_cv_sys_stat_fs_data=no], 254 [fu_cv_sys_stat_statfs2_fsize=no],
288 [fu_cv_sys_stat_fs_data=no])]) 255 [fu_cv_sys_stat_statfs2_fsize=no])
289 AC_MSG_RESULT([$fu_cv_sys_stat_fs_data]) 256 ])
290 if test $fu_cv_sys_stat_fs_data = yes; then 257 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
291 ac_fsusage_space=yes 258 ac_fsusage_space=yes
292 AC_DEFINE([STAT_STATFS2_FS_DATA], [1], 259 AC_DEFINE([STAT_STATFS2_FSIZE], [1],
293[ Define if statfs takes 2 args and the second argument has 260 [Define if statfs takes 2 args and struct statfs has a field named f_fsize.
294 type struct fs_data. (Ultrix)]) 261 (4.4BSD, NetBSD)])
262 fi
295 fi 263 fi
296fi
297 264
298if test $ac_fsusage_space = no; then 265 AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
299 # SVR2
300 # (AIX, HP-UX, OSF/1 already handled above.)
301 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h>
302 ]])],
303 [AC_DEFINE([STAT_READ_FILSYS], [1],
304 [Define if there is no specific function for reading file systems usage
305 information and you have the <sys/filsys.h> header file. (SVR2)])
306 ac_fsusage_space=yes])
307fi
308
309AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
310 266
311]) 267])
312 268
@@ -316,18 +272,22 @@ AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
316# enable the work-around code in fsusage.c. 272# enable the work-around code in fsusage.c.
317AC_DEFUN([gl_STATFS_TRUNCATES], 273AC_DEFUN([gl_STATFS_TRUNCATES],
318[ 274[
319 AC_MSG_CHECKING([for statfs that truncates block counts]) 275 AC_CACHE_CHECK([for statfs that truncates block counts],
320 AC_CACHE_VAL([fu_cv_sys_truncating_statfs], 276 [fu_cv_sys_truncating_statfs],
321 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 277 [AC_COMPILE_IFELSE(
278 [AC_LANG_PROGRAM([[
322#if !defined(sun) && !defined(__sun) 279#if !defined(sun) && !defined(__sun)
323choke -- this is a workaround for a Sun-specific problem 280choke -- this is a workaround for a Sun-specific problem
324#endif 281#endif
325#include <sys/types.h> 282#include <sys/types.h>
326#include <sys/vfs.h>]], 283#include <sys/vfs.h>
327 [[struct statfs t; long c = *(t.f_spare); 284 ]],
328 if (c) return 0;]])], 285 [[struct statfs t; long c = *(t.f_spare);
329 [fu_cv_sys_truncating_statfs=yes], 286 if (c) return 0;
330 [fu_cv_sys_truncating_statfs=no])]) 287 ]])],
288 [fu_cv_sys_truncating_statfs=yes],
289 [fu_cv_sys_truncating_statfs=no])
290 ])
331 if test $fu_cv_sys_truncating_statfs = yes; then 291 if test $fu_cv_sys_truncating_statfs = yes; then
332 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1], 292 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1],
333 [Define if the block counts reported by statfs may be truncated to 2GB 293 [Define if the block counts reported by statfs may be truncated to 2GB
@@ -335,13 +295,12 @@ choke -- this is a workaround for a Sun-specific problem
335 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. 295 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
336 SunOS 4.1.1 seems not to be affected.)]) 296 SunOS 4.1.1 seems not to be affected.)])
337 fi 297 fi
338 AC_MSG_RESULT([$fu_cv_sys_truncating_statfs])
339]) 298])
340 299
341 300
342# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE. 301# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
343AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], 302AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
344[ 303[
345 AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h]) 304 AC_CHECK_HEADERS([sys/fs/s5param.h sys/statfs.h])
346 gl_STATFS_TRUNCATES 305 gl_STATFS_TRUNCATES
347]) 306])
diff --git a/gl/m4/ftell.m4 b/gl/m4/ftell.m4
new file mode 100644
index 0000000..79f1aaf
--- /dev/null
+++ b/gl/m4/ftell.m4
@@ -0,0 +1,15 @@
1# ftell.m4 serial 3
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELL],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_FTELLO])
11 dnl When ftello needs fixes, ftell needs them too.
12 if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then
13 REPLACE_FTELL=1
14 fi
15])
diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4
new file mode 100644
index 0000000..4901b16
--- /dev/null
+++ b/gl/m4/ftello.m4
@@ -0,0 +1,151 @@
1# ftello.m4 serial 14
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FTELLO],
8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_PROG_CC])
11 AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
12 AC_REQUIRE([gl_SYS_TYPES_H])
13
14 dnl Persuade glibc <stdio.h> to declare ftello().
15 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
16
17 AC_CHECK_DECLS_ONCE([ftello])
18 if test $ac_cv_have_decl_ftello = no; then
19 HAVE_DECL_FTELLO=0
20 fi
21
22 AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
23 [
24 AC_LINK_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[#include <stdio.h>]],
27 [[ftello (stdin);]])],
28 [gl_cv_func_ftello=yes],
29 [gl_cv_func_ftello=no])
30 ])
31 if test $gl_cv_func_ftello = no; then
32 HAVE_FTELLO=0
33 else
34 if test $WINDOWS_64_BIT_OFF_T = 1; then
35 REPLACE_FTELLO=1
36 fi
37 if test $gl_cv_var_stdin_large_offset = no; then
38 REPLACE_FTELLO=1
39 fi
40 if test $REPLACE_FTELLO = 0; then
41 dnl Detect bug on Solaris.
42 dnl ftell and ftello produce incorrect results after putc that followed a
43 dnl getc call that reached EOF on Solaris. This is because the _IOREAD
44 dnl flag does not get cleared in this case, even though _IOWRT gets set,
45 dnl and ftell and ftello look whether the _IOREAD flag is set.
46 AC_REQUIRE([AC_CANONICAL_HOST])
47 AC_CACHE_CHECK([whether ftello works],
48 [gl_cv_func_ftello_works],
49 [
50 dnl Initial guess, used when cross-compiling or when /dev/tty cannot
51 dnl be opened.
52changequote(,)dnl
53 case "$host_os" in
54 # Guess no on Solaris.
55 solaris*) gl_cv_func_ftello_works="guessing no" ;;
56 # Guess yes on native Windows.
57 mingw*) gl_cv_func_ftello_works="guessing yes" ;;
58 # Guess yes otherwise.
59 *) gl_cv_func_ftello_works="guessing yes" ;;
60 esac
61changequote([,])dnl
62 AC_RUN_IFELSE(
63 [AC_LANG_SOURCE([[
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#define TESTFILE "conftest.tmp"
68int
69main (void)
70{
71 FILE *fp;
72
73 /* Create a file with some contents. */
74 fp = fopen (TESTFILE, "w");
75 if (fp == NULL)
76 return 70;
77 if (fwrite ("foogarsh", 1, 8, fp) < 8)
78 { fclose (fp); return 71; }
79 if (fclose (fp))
80 return 72;
81
82 /* The file's contents is now "foogarsh". */
83
84 /* Try writing after reading to EOF. */
85 fp = fopen (TESTFILE, "r+");
86 if (fp == NULL)
87 return 73;
88 if (fseek (fp, -1, SEEK_END))
89 { fclose (fp); return 74; }
90 if (!(getc (fp) == 'h'))
91 { fclose (fp); return 1; }
92 if (!(getc (fp) == EOF))
93 { fclose (fp); return 2; }
94 if (!(ftell (fp) == 8))
95 { fclose (fp); return 3; }
96 if (!(ftell (fp) == 8))
97 { fclose (fp); return 4; }
98 if (!(putc ('!', fp) == '!'))
99 { fclose (fp); return 5; }
100 if (!(ftell (fp) == 9))
101 { fclose (fp); return 6; }
102 if (!(fclose (fp) == 0))
103 return 7;
104 fp = fopen (TESTFILE, "r");
105 if (fp == NULL)
106 return 75;
107 {
108 char buf[10];
109 if (!(fread (buf, 1, 10, fp) == 9))
110 { fclose (fp); return 10; }
111 if (!(memcmp (buf, "foogarsh!", 9) == 0))
112 { fclose (fp); return 11; }
113 }
114 if (!(fclose (fp) == 0))
115 return 12;
116
117 /* The file's contents is now "foogarsh!". */
118
119 return 0;
120}]])],
121 [gl_cv_func_ftello_works=yes],
122 [gl_cv_func_ftello_works=no], [:])
123 ])
124 case "$gl_cv_func_ftello_works" in
125 *yes) ;;
126 *)
127 REPLACE_FTELLO=1
128 AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1],
129 [Define to 1 if the system's ftello function has the Solaris bug.])
130 ;;
131 esac
132 fi
133 if test $REPLACE_FTELLO = 0; then
134 dnl Detect bug on macOS >= 10.15.
135 gl_FUNC_UNGETC_WORKS
136 if test $gl_ftello_broken_after_ungetc = yes; then
137 REPLACE_FTELLO=1
138 AC_DEFINE([FTELLO_BROKEN_AFTER_UNGETC], [1],
139 [Define to 1 if the system's ftello function has the macOS bug.])
140 fi
141 fi
142 fi
143])
144
145# Prerequisites of lib/ftello.c.
146AC_DEFUN([gl_PREREQ_FTELLO],
147[
148 dnl Native Windows has the function _ftelli64. mingw hides it, but mingw64
149 dnl makes it usable again.
150 AC_CHECK_FUNCS([_ftelli64])
151])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 1d631f8..15f09ff 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,14 +1,13 @@
1# getaddrinfo.m4 serial 30 1# getaddrinfo.m4 serial 34
2dnl Copyright (C) 2004-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_GETADDRINFO], 7AC_DEFUN([gl_GETADDRINFO],
8[ 8[
9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 9 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H 10 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H
11 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
12 GETADDRINFO_LIB= 11 GETADDRINFO_LIB=
13 gai_saved_LIBS="$LIBS" 12 gai_saved_LIBS="$LIBS"
14 13
@@ -55,10 +54,40 @@ AC_DEFUN([gl_GETADDRINFO],
55 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
56 GETADDRINFO_LIB="-lws2_32" 55 GETADDRINFO_LIB="-lws2_32"
57 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB" 56 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
57 dnl Check for correct signature, in particular for a cdecl-compatible
58 dnl calling convention.
59 AC_CACHE_CHECK([for getaddrinfo with POSIX signature],
60 [gl_cv_func_getaddrinfo_posix_signature],
61 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
62#include <sys/types.h>
63#ifdef HAVE_SYS_SOCKET_H
64#include <sys/socket.h>
65#endif
66#ifdef HAVE_NETDB_H
67#include <netdb.h>
68#endif
69#ifdef HAVE_WS2TCPIP_H
70#include <ws2tcpip.h>
71#endif
72#include <stddef.h>
73extern
74#ifdef __cplusplus
75"C"
76#endif
77int getaddrinfo (const char *, const char *, const struct addrinfo *, struct addrinfo **);
78]])],
79 [gl_cv_func_getaddrinfo_posix_signature=yes],
80 [gl_cv_func_getaddrinfo_posix_signature=no])
81 ])
82 if test $gl_cv_func_getaddrinfo_posix_signature = no; then
83 REPLACE_GETADDRINFO=1
84 fi
58 else 85 else
59 HAVE_GETADDRINFO=0 86 HAVE_GETADDRINFO=0
60 fi 87 fi
61 fi 88 fi
89 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
90 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
62 91
63 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an 92 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an
64 # inline function declared in ws2tcpip.h, so we need to get that 93 # inline function declared in ws2tcpip.h, so we need to get that
@@ -127,13 +156,13 @@ const char *gai_strerror(int);]])],
127# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c. 156# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
128AC_DEFUN([gl_PREREQ_GETADDRINFO], [ 157AC_DEFUN([gl_PREREQ_GETADDRINFO], [
129 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 158 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
130 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 159 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
131 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB 160 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
132 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB 161 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
133 AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB 162 AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB
134 AC_REQUIRE([AC_C_RESTRICT]) 163 AC_REQUIRE([AC_C_RESTRICT])
135 AC_REQUIRE([gl_SOCKET_FAMILIES]) 164 AC_REQUIRE([gl_SOCKET_FAMILIES])
136 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 165 AC_REQUIRE([gl_SYS_SOCKET_H])
137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 166 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
138 167
139 dnl Including sys/socket.h is wrong for Windows, but Windows does not 168 dnl Including sys/socket.h is wrong for Windows, but Windows does not
diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4
new file mode 100644
index 0000000..9aaed20
--- /dev/null
+++ b/gl/m4/getdelim.m4
@@ -0,0 +1,111 @@
1# getdelim.m4 serial 16
2
3dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
4dnl
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8
9AC_PREREQ([2.59])
10
11AC_DEFUN([gl_FUNC_GETDELIM],
12[
13 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST])
15
16 dnl Persuade glibc <stdio.h> to declare getdelim().
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
18
19 AC_CHECK_DECLS_ONCE([getdelim])
20
21 AC_CHECK_FUNCS_ONCE([getdelim])
22 if test $ac_cv_func_getdelim = yes; then
23 HAVE_GETDELIM=1
24 dnl Found it in some library. Verify that it works.
25 AC_CACHE_CHECK([for working getdelim function],
26 [gl_cv_func_working_getdelim],
27 [case "$host_os" in
28 darwin*)
29 dnl On macOS 10.13, valgrind detected an out-of-bounds read during
30 dnl the GNU sed test suite:
31 dnl Invalid read of size 16
32 dnl at 0x100EE6A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
33 dnl by 0x100B7B0BD: getdelim (in /usr/lib/system/libsystem_c.dylib)
34 dnl by 0x10000B0BE: ck_getdelim (utils.c:254)
35 gl_cv_func_working_getdelim=no ;;
36 *)
37 echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
38 AC_RUN_IFELSE([AC_LANG_SOURCE([[
39# include <stdio.h>
40# include <stdlib.h>
41# include <string.h>
42 int main ()
43 {
44 FILE *in = fopen ("./conftest.data", "r");
45 if (!in)
46 return 1;
47 {
48 /* Test result for a NULL buffer and a zero size.
49 Based on a test program from Karl Heuer. */
50 char *line = NULL;
51 size_t siz = 0;
52 int len = getdelim (&line, &siz, '\n', in);
53 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
54 { free (line); fclose (in); return 2; }
55 free (line);
56 }
57 {
58 /* Test result for a NULL buffer and a non-zero size.
59 This crashes on FreeBSD 8.0. */
60 char *line = NULL;
61 size_t siz = (size_t)(~0) / 4;
62 if (getdelim (&line, &siz, '\n', in) == -1)
63 { fclose (in); return 3; }
64 free (line);
65 }
66 fclose (in);
67 return 0;
68 }
69 ]])],
70 [gl_cv_func_working_getdelim=yes],
71 [gl_cv_func_working_getdelim=no],
72 [dnl We're cross compiling.
73 dnl Guess it works on glibc2 systems and musl systems.
74 AC_EGREP_CPP([Lucky GNU user],
75 [
76#include <features.h>
77#ifdef __GNU_LIBRARY__
78 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
79 Lucky GNU user
80 #endif
81#endif
82 ],
83 [gl_cv_func_working_getdelim="guessing yes"],
84 [case "$host_os" in
85 *-musl*) gl_cv_func_working_getdelim="guessing yes" ;;
86 *) gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
87 esac
88 ])
89 ])
90 ;;
91 esac
92 ])
93 case "$gl_cv_func_working_getdelim" in
94 *yes) ;;
95 *) REPLACE_GETDELIM=1 ;;
96 esac
97 else
98 HAVE_GETDELIM=0
99 fi
100
101 if test $ac_cv_have_decl_getdelim = no; then
102 HAVE_DECL_GETDELIM=0
103 fi
104])
105
106# Prerequisites of lib/getdelim.c.
107AC_DEFUN([gl_PREREQ_GETDELIM],
108[
109 AC_CHECK_FUNCS([flockfile funlockfile])
110 AC_CHECK_DECLS([getc_unlocked])
111])
diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4
new file mode 100644
index 0000000..8bcda90
--- /dev/null
+++ b/gl/m4/getdtablesize.m4
@@ -0,0 +1,63 @@
1# getdtablesize.m4 serial 8
2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([getdtablesize])
12 AC_CHECK_DECLS_ONCE([getdtablesize])
13 if test $ac_cv_func_getdtablesize = yes &&
14 test $ac_cv_have_decl_getdtablesize = yes; then
15 AC_CACHE_CHECK([whether getdtablesize works],
16 [gl_cv_func_getdtablesize_works],
17 [dnl There are two concepts: the "maximum possible file descriptor value + 1"
18 dnl and the "maximum number of open file descriptors in a process".
19 dnl Per SUSv2 and POSIX, getdtablesize() should return the first one.
20 dnl On most platforms, the first and the second concept are the same.
21 dnl On OpenVMS, however, they are different and getdtablesize() returns
22 dnl the second one; thus the test below fails. But we don't care
23 dnl because there's no good way to write a replacement getdtablesize().
24 case "$host_os" in
25 vms*) gl_cv_func_getdtablesize_works="no (limitation)" ;;
26 *)
27 dnl Cygwin 1.7.25 automatically increases the RLIMIT_NOFILE soft
28 dnl limit up to an unchangeable hard limit; all other platforms
29 dnl correctly require setrlimit before getdtablesize() can report
30 dnl a larger value.
31 AC_RUN_IFELSE([
32 AC_LANG_PROGRAM(
33 [[#include <unistd.h>]
34 GL_MDA_DEFINES
35 ],
36 [[int size = getdtablesize();
37 if (dup2 (0, getdtablesize()) != -1)
38 return 1;
39 if (size != getdtablesize())
40 return 2;
41 ]])],
42 [gl_cv_func_getdtablesize_works=yes],
43 [gl_cv_func_getdtablesize_works=no],
44 [case "$host_os" in
45 cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
46 gl_cv_func_getdtablesize_works="guessing no" ;;
47 *) gl_cv_func_getdtablesize_works="guessing yes" ;;
48 esac
49 ])
50 ;;
51 esac
52 ])
53 case "$gl_cv_func_getdtablesize_works" in
54 *yes | "no (limitation)") ;;
55 *) REPLACE_GETDTABLESIZE=1 ;;
56 esac
57 else
58 HAVE_GETDTABLESIZE=0
59 fi
60])
61
62# Prerequisites of lib/getdtablesize.c.
63AC_DEFUN([gl_PREREQ_GETDTABLESIZE], [:])
diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4
index 7413f9e..63f5f63 100644
--- a/gl/m4/gethostname.m4
+++ b/gl/m4/gethostname.m4
@@ -1,5 +1,5 @@
1# gethostname.m4 serial 13 1# gethostname.m4 serial 15
2dnl Copyright (C) 2002, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -48,7 +48,7 @@ AC_DEFUN([gl_PREREQ_HOST_NAME_MAX], [
48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead. 48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead.
49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead. 49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead.
50 dnl - On mingw, use 256, because 50 dnl - On mingw, use 256, because
51 dnl <http://msdn.microsoft.com/en-us/library/ms738527.aspx> says: 51 dnl <https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-gethostname> says:
52 dnl "if a buffer of 256 bytes is passed in the name parameter and 52 dnl "if a buffer of 256 bytes is passed in the name parameter and
53 dnl the namelen parameter is set to 256, the buffer size will always 53 dnl the namelen parameter is set to 256, the buffer size will always
54 dnl be adequate." 54 dnl be adequate."
@@ -74,7 +74,7 @@ lucky
74 dnl mingw. 74 dnl mingw.
75 gl_cv_decl_HOST_NAME_MAX=256 75 gl_cv_decl_HOST_NAME_MAX=256
76 else 76 else
77 _AC_COMPUTE_INT([MAXHOSTNAMELEN], [gl_cv_decl_HOST_NAME_MAX], [ 77 AC_COMPUTE_INT([gl_cv_decl_HOST_NAME_MAX], [MAXHOSTNAMELEN], [
78#include <sys/types.h> 78#include <sys/types.h>
79#if HAVE_SYS_PARAM_H 79#if HAVE_SYS_PARAM_H
80# include <sys/param.h> 80# include <sys/param.h>
diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4
new file mode 100644
index 0000000..03569f0
--- /dev/null
+++ b/gl/m4/getline.m4
@@ -0,0 +1,109 @@
1# getline.m4 serial 30
2
3dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation,
4dnl Inc.
5dnl
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10AC_PREREQ([2.59])
11
12dnl See if there's a working, system-supplied version of the getline function.
13dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems
14dnl have a function by that name in -linet that doesn't have anything
15dnl to do with the function we need.
16AC_DEFUN([gl_FUNC_GETLINE],
17[
18 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
20
21 dnl Persuade glibc <stdio.h> to declare getline().
22 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
23
24 AC_CHECK_DECLS_ONCE([getline])
25
26 gl_getline_needs_run_time_check=no
27 AC_CHECK_FUNC([getline],
28 [dnl Found it in some library. Verify that it works.
29 gl_getline_needs_run_time_check=yes],
30 [am_cv_func_working_getline=no])
31 if test $gl_getline_needs_run_time_check = yes; then
32 AC_CACHE_CHECK([for working getline function],
33 [am_cv_func_working_getline],
34 [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
35 AC_RUN_IFELSE([AC_LANG_SOURCE([[
36# include <stdio.h>
37# include <stdlib.h>
38# include <string.h>
39 int main ()
40 {
41 FILE *in = fopen ("./conftest.data", "r");
42 if (!in)
43 return 1;
44 {
45 /* Test result for a NULL buffer and a zero size.
46 Based on a test program from Karl Heuer. */
47 char *line = NULL;
48 size_t siz = 0;
49 int len = getline (&line, &siz, in);
50 if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
51 { free (line); fclose (in); return 2; }
52 free (line);
53 }
54 {
55 /* Test result for a NULL buffer and a non-zero size.
56 This crashes on FreeBSD 8.0. */
57 char *line = NULL;
58 size_t siz = (size_t)(~0) / 4;
59 if (getline (&line, &siz, in) == -1)
60 { fclose (in); return 3; }
61 free (line);
62 }
63 fclose (in);
64 return 0;
65 }
66 ]])],
67 [am_cv_func_working_getline=yes],
68 [am_cv_func_working_getline=no],
69 [dnl We're cross compiling.
70 dnl Guess it works on glibc2 systems and musl systems.
71 AC_EGREP_CPP([Lucky GNU user],
72 [
73#include <features.h>
74#ifdef __GNU_LIBRARY__
75 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
76 Lucky GNU user
77 #endif
78#endif
79 ],
80 [am_cv_func_working_getline="guessing yes"],
81 [case "$host_os" in
82 *-musl*) am_cv_func_working_getline="guessing yes" ;;
83 *) am_cv_func_working_getline="$gl_cross_guess_normal" ;;
84 esac
85 ])
86 ])
87 ])
88 fi
89
90 if test $ac_cv_have_decl_getline = no; then
91 HAVE_DECL_GETLINE=0
92 fi
93
94 case "$am_cv_func_working_getline" in
95 *yes) ;;
96 *)
97 dnl Set REPLACE_GETLINE always: Even if we have not found the broken
98 dnl getline function among $LIBS, it may exist in libinet and the
99 dnl executable may be linked with -linet.
100 REPLACE_GETLINE=1
101 ;;
102 esac
103])
104
105# Prerequisites of lib/getline.c.
106AC_DEFUN([gl_PREREQ_GETLINE],
107[
108 :
109])
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index 611372a..79e420b 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,13 +1,13 @@
1# Check for getloadavg. 1# Check for getloadavg.
2 2
3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2013 Free Software 3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2023 Free Software
4# Foundation, Inc. 4# Foundation, Inc.
5 5
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved. 8# with or without modifications, as long as this notice is preserved.
9 9
10#serial 6 10#serial 10
11 11
12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. 12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
13# New applications should use gl_GETLOADAVG instead. 13# New applications should use gl_GETLOADAVG instead.
@@ -22,7 +22,7 @@ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22 22
23gl_save_LIBS=$LIBS 23gl_save_LIBS=$LIBS
24 24
25# getloadvg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0, 25# getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7. 26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
27HAVE_GETLOADAVG=1 27HAVE_GETLOADAVG=1
28AC_CHECK_FUNC([getloadavg], [], 28AC_CHECK_FUNC([getloadavg], [],
@@ -45,7 +45,9 @@ AC_CHECK_FUNC([getloadavg], [],
45 # There is a commonly available library for RS/6000 AIX. 45 # There is a commonly available library for RS/6000 AIX.
46 # Since it is not a standard part of AIX, it might be installed locally. 46 # Since it is not a standard part of AIX, it might be installed locally.
47 gl_getloadavg_LIBS=$LIBS 47 gl_getloadavg_LIBS=$LIBS
48 LIBS="-L/usr/local/lib $LIBS" 48 if test $cross_compiling != yes; then
49 LIBS="-L/usr/local/lib $LIBS"
50 fi
49 AC_CHECK_LIB([getloadavg], [getloadavg], 51 AC_CHECK_LIB([getloadavg], [getloadavg],
50 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes], 52 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes],
51 [LIBS=$gl_getloadavg_LIBS]) 53 [LIBS=$gl_getloadavg_LIBS])
@@ -92,6 +94,9 @@ else
92fi 94fi
93AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0], 95AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
94 [[#if HAVE_SYS_LOADAVG_H 96 [[#if HAVE_SYS_LOADAVG_H
97 /* OpenIndiana has a bug: <sys/time.h> must be included before
98 <sys/loadavg.h>. */
99 # include <sys/time.h>
95 # include <sys/loadavg.h> 100 # include <sys/loadavg.h>
96 #endif 101 #endif
97 #include <stdlib.h>]]) 102 #include <stdlib.h>]])
@@ -105,7 +110,7 @@ AC_DEFUN([gl_PREREQ_GETLOADAVG],
105[ 110[
106# Figure out what our getloadavg.c needs. 111# Figure out what our getloadavg.c needs.
107 112
108AC_CHECK_HEADERS_ONCE([sys/param.h]) 113AC_CHECK_HEADERS_ONCE([sys/param.h unistd.h])
109 114
110# On HPUX9, an unprivileged user can get load averages this way. 115# On HPUX9, an unprivileged user can get load averages this way.
111if test $gl_func_getloadavg_done = no; then 116if test $gl_func_getloadavg_done = no; then
@@ -142,7 +147,7 @@ fi
142AC_CHECK_HEADERS([nlist.h], 147AC_CHECK_HEADERS([nlist.h],
143[AC_CHECK_MEMBERS([struct nlist.n_un.n_name], 148[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
144 [], [], 149 [], [],
145 [@%:@include <nlist.h>]) 150 [#include <nlist.h>])
146 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]], 151 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
147 [[struct nlist x; 152 [[struct nlist x;
148 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME 153 #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 50f4509..7981a09 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
1# getopt.m4 serial 44 1# getopt.m4 serial 48
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -21,6 +21,8 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
21 REPLACE_GETOPT=1 21 REPLACE_GETOPT=1
22 fi 22 fi
23 ]) 23 ])
24 GL_GENERATE_GETOPT_H=false
25 GL_GENERATE_GETOPT_CDEFS_H=false
24 if test $REPLACE_GETOPT = 1; then 26 if test $REPLACE_GETOPT = 1; then
25 dnl Arrange for getopt.h to be created. 27 dnl Arrange for getopt.h to be created.
26 gl_GETOPT_SUBSTITUTE_HEADER 28 gl_GETOPT_SUBSTITUTE_HEADER
@@ -32,9 +34,16 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
32# getopt_long_only. 34# getopt_long_only.
33AC_DEFUN([gl_FUNC_GETOPT_GNU], 35AC_DEFUN([gl_FUNC_GETOPT_GNU],
34[ 36[
37 dnl Set the variable gl_getopt_required, so that all invocations of
38 dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file
39 dnl will check for getopt with GNU extensions.
40 dnl This means that if one gnulib-tool invocation requests getopt-posix
41 dnl and another gnulib-tool invocation requests getopt-gnu, it is as if
42 dnl both had requested getopt-gnu.
35 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) 43 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
36 44
37 AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) 45 dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically
46 dnl done through the module dependency getopt-gnu -> getopt-posix.
38]) 47])
39 48
40# Determine whether to replace the entire getopt facility. 49# Determine whether to replace the entire getopt facility.
@@ -295,8 +304,10 @@ dnl is ambiguous with environment values that contain newlines.
295 ]])], 304 ]])],
296 [gl_cv_func_getopt_gnu=yes], 305 [gl_cv_func_getopt_gnu=yes],
297 [gl_cv_func_getopt_gnu=no], 306 [gl_cv_func_getopt_gnu=no],
298 [dnl Cross compiling. Assume the worst, even on glibc platforms. 307 [dnl Cross compiling.
299 gl_cv_func_getopt_gnu="guessing no" 308 dnl Assume the worst, even on glibc platforms.
309 dnl But obey --enable-cross-guesses.
310 gl_cv_func_getopt_gnu="$gl_cross_guess_normal"
300 ]) 311 ])
301 case $gl_had_POSIXLY_CORRECT in 312 case $gl_had_POSIXLY_CORRECT in
302 exported) ;; 313 exported) ;;
@@ -354,15 +365,17 @@ dnl is ambiguous with environment values that contain newlines.
354 365
355AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], 366AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
356[ 367[
357 GETOPT_H=getopt.h 368 AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
369 if test $ac_cv_header_sys_cdefs_h = yes; then
370 HAVE_SYS_CDEFS_H=1
371 else
372 HAVE_SYS_CDEFS_H=0
373 fi
374 AC_SUBST([HAVE_SYS_CDEFS_H])
375
358 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], 376 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
359 [Define to rpl_ if the getopt replacement functions and variables 377 [Define to rpl_ if the getopt replacement functions and variables
360 should be used.]) 378 should be used.])
361 AC_SUBST([GETOPT_H]) 379 GL_GENERATE_GETOPT_H=true
362]) 380 GL_GENERATE_GETOPT_CDEFS_H=true
363
364# Prerequisites of lib/getopt*.
365AC_DEFUN([gl_PREREQ_GETOPT],
366[
367 AC_CHECK_DECLS_ONCE([getenv])
368]) 381])
diff --git a/gl/m4/getprogname.m4 b/gl/m4/getprogname.m4
new file mode 100644
index 0000000..b67c527
--- /dev/null
+++ b/gl/m4/getprogname.m4
@@ -0,0 +1,43 @@
1# getprogname.m4 - check for getprogname or replacements for it
2
3# Copyright (C) 2016-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# serial 4
9
10AC_DEFUN([gl_FUNC_GETPROGNAME],
11[
12 AC_CHECK_FUNCS_ONCE([getprogname getexecname])
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 ac_found=0
15 AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [],
16 [#include <errno.h>])
17 AC_CHECK_DECLS([program_invocation_short_name], [ac_found=1], [],
18 [#include <errno.h>])
19 AC_CHECK_DECLS([__argv], [ac_found=1], [], [#include <stdlib.h>])
20
21 # Incur the cost of this test only if none of the above worked.
22 if test $ac_found = 0; then
23 # On OpenBSD 5.1, using the global __progname variable appears to be
24 # the only way to implement getprogname.
25 AC_CACHE_CHECK([whether __progname is defined in default libraries],
26 [gl_cv_var___progname],
27 [
28 gl_cv_var___progname=
29 AC_LINK_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[extern char *__progname;]],
32 [[return *__progname;]]
33 )],
34 [gl_cv_var___progname=yes]
35 )
36 ]
37 )
38 if test "$gl_cv_var___progname" = yes; then
39 AC_DEFINE([HAVE_VAR___PROGNAME], 1,
40 [Define if you have a global __progname variable])
41 fi
42 fi
43])
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4
deleted file mode 100644
index 8d1f066..0000000
--- a/gl/m4/gettext.m4
+++ /dev/null
@@ -1,401 +0,0 @@
1# gettext.m4 serial 66 (gettext-0.18.2)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
19
20dnl Macro to add for using GNU gettext.
21
22dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
23dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
24dnl default (if it is not specified or empty) is 'no-libtool'.
25dnl INTLSYMBOL should be 'external' for packages with no intl directory,
26dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
27dnl If INTLSYMBOL is 'use-libtool', then a libtool library
28dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
29dnl depending on --{enable,disable}-{shared,static} and on the presence of
30dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
31dnl $(top_builddir)/intl/libintl.a will be created.
32dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
33dnl implementations (in libc or libintl) without the ngettext() function
34dnl will be ignored. If NEEDSYMBOL is specified and is
35dnl 'need-formatstring-macros', then GNU gettext implementations that don't
36dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
37dnl INTLDIR is used to find the intl libraries. If empty,
38dnl the value '$(top_builddir)/intl/' is used.
39dnl
40dnl The result of the configuration is one of three cases:
41dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
42dnl and used.
43dnl Catalog format: GNU --> install in $(datadir)
44dnl Catalog extension: .mo after installation, .gmo in source tree
45dnl 2) GNU gettext has been found in the system's C library.
46dnl Catalog format: GNU --> install in $(datadir)
47dnl Catalog extension: .mo after installation, .gmo in source tree
48dnl 3) No internationalization, always use English msgid.
49dnl Catalog format: none
50dnl Catalog extension: none
51dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
52dnl The use of .gmo is historical (it was needed to avoid overwriting the
53dnl GNU format catalogs when building on a platform with an X/Open gettext),
54dnl but we keep it in order not to force irrelevant filename changes on the
55dnl maintainers.
56dnl
57AC_DEFUN([AM_GNU_GETTEXT],
58[
59 dnl Argument checking.
60 ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
61 [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
62])])])])])
63 ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
64 [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
65 ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
66 [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
67])])])])
68 define([gt_included_intl],
69 ifelse([$1], [external],
70 ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
71 [yes]))
72 define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
73 gt_NEEDS_INIT
74 AM_GNU_GETTEXT_NEED([$2])
75
76 AC_REQUIRE([AM_PO_SUBDIRS])dnl
77 ifelse(gt_included_intl, yes, [
78 AC_REQUIRE([AM_INTL_SUBDIR])dnl
79 ])
80
81 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
82 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
83 AC_REQUIRE([AC_LIB_RPATH])
84
85 dnl Sometimes libintl requires libiconv, so first search for libiconv.
86 dnl Ideally we would do this search only after the
87 dnl if test "$USE_NLS" = "yes"; then
88 dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
89 dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
90 dnl the configure script would need to contain the same shell code
91 dnl again, outside any 'if'. There are two solutions:
92 dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
93 dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
94 dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
95 dnl documented, we avoid it.
96 ifelse(gt_included_intl, yes, , [
97 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
98 ])
99
100 dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
101 gt_INTL_MACOSX
102
103 dnl Set USE_NLS.
104 AC_REQUIRE([AM_NLS])
105
106 ifelse(gt_included_intl, yes, [
107 BUILD_INCLUDED_LIBINTL=no
108 USE_INCLUDED_LIBINTL=no
109 ])
110 LIBINTL=
111 LTLIBINTL=
112 POSUB=
113
114 dnl Add a version number to the cache macros.
115 case " $gt_needs " in
116 *" need-formatstring-macros "*) gt_api_version=3 ;;
117 *" need-ngettext "*) gt_api_version=2 ;;
118 *) gt_api_version=1 ;;
119 esac
120 gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
121 gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
122
123 dnl If we use NLS figure out what method
124 if test "$USE_NLS" = "yes"; then
125 gt_use_preinstalled_gnugettext=no
126 ifelse(gt_included_intl, yes, [
127 AC_MSG_CHECKING([whether included gettext is requested])
128 AC_ARG_WITH([included-gettext],
129 [ --with-included-gettext use the GNU gettext library included here],
130 nls_cv_force_use_gnu_gettext=$withval,
131 nls_cv_force_use_gnu_gettext=no)
132 AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
133
134 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
135 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
136 ])
137 dnl User does not insist on using GNU NLS library. Figure out what
138 dnl to use. If GNU gettext is available we use this. Else we have
139 dnl to fall back to GNU NLS library.
140
141 if test $gt_api_version -ge 3; then
142 gt_revision_test_code='
143#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
144#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
145#endif
146changequote(,)dnl
147typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
148changequote([,])dnl
149'
150 else
151 gt_revision_test_code=
152 fi
153 if test $gt_api_version -ge 2; then
154 gt_expression_test_code=' + * ngettext ("", "", 0)'
155 else
156 gt_expression_test_code=
157 fi
158
159 AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
160 [AC_LINK_IFELSE(
161 [AC_LANG_PROGRAM(
162 [[
163#include <libintl.h>
164$gt_revision_test_code
165extern int _nl_msg_cat_cntr;
166extern int *_nl_domain_bindings;
167 ]],
168 [[
169bindtextdomain ("", "");
170return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings
171 ]])],
172 [eval "$gt_func_gnugettext_libc=yes"],
173 [eval "$gt_func_gnugettext_libc=no"])])
174
175 if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
176 dnl Sometimes libintl requires libiconv, so first search for libiconv.
177 ifelse(gt_included_intl, yes, , [
178 AM_ICONV_LINK
179 ])
180 dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
181 dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
182 dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
183 dnl even if libiconv doesn't exist.
184 AC_LIB_LINKFLAGS_BODY([intl])
185 AC_CACHE_CHECK([for GNU gettext in libintl],
186 [$gt_func_gnugettext_libintl],
187 [gt_save_CPPFLAGS="$CPPFLAGS"
188 CPPFLAGS="$CPPFLAGS $INCINTL"
189 gt_save_LIBS="$LIBS"
190 LIBS="$LIBS $LIBINTL"
191 dnl Now see whether libintl exists and does not depend on libiconv.
192 AC_LINK_IFELSE(
193 [AC_LANG_PROGRAM(
194 [[
195#include <libintl.h>
196$gt_revision_test_code
197extern int _nl_msg_cat_cntr;
198extern
199#ifdef __cplusplus
200"C"
201#endif
202const char *_nl_expand_alias (const char *);
203 ]],
204 [[
205bindtextdomain ("", "");
206return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
207 ]])],
208 [eval "$gt_func_gnugettext_libintl=yes"],
209 [eval "$gt_func_gnugettext_libintl=no"])
210 dnl Now see whether libintl exists and depends on libiconv.
211 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
212 LIBS="$LIBS $LIBICONV"
213 AC_LINK_IFELSE(
214 [AC_LANG_PROGRAM(
215 [[
216#include <libintl.h>
217$gt_revision_test_code
218extern int _nl_msg_cat_cntr;
219extern
220#ifdef __cplusplus
221"C"
222#endif
223const char *_nl_expand_alias (const char *);
224 ]],
225 [[
226bindtextdomain ("", "");
227return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
228 ]])],
229 [LIBINTL="$LIBINTL $LIBICONV"
230 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
231 eval "$gt_func_gnugettext_libintl=yes"
232 ])
233 fi
234 CPPFLAGS="$gt_save_CPPFLAGS"
235 LIBS="$gt_save_LIBS"])
236 fi
237
238 dnl If an already present or preinstalled GNU gettext() is found,
239 dnl use it. But if this macro is used in GNU gettext, and GNU
240 dnl gettext is already preinstalled in libintl, we update this
241 dnl libintl. (Cf. the install rule in intl/Makefile.in.)
242 if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
243 || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
244 && test "$PACKAGE" != gettext-runtime \
245 && test "$PACKAGE" != gettext-tools; }; then
246 gt_use_preinstalled_gnugettext=yes
247 else
248 dnl Reset the values set by searching for libintl.
249 LIBINTL=
250 LTLIBINTL=
251 INCINTL=
252 fi
253
254 ifelse(gt_included_intl, yes, [
255 if test "$gt_use_preinstalled_gnugettext" != "yes"; then
256 dnl GNU gettext is not found in the C library.
257 dnl Fall back on included GNU gettext library.
258 nls_cv_use_gnu_gettext=yes
259 fi
260 fi
261
262 if test "$nls_cv_use_gnu_gettext" = "yes"; then
263 dnl Mark actions used to generate GNU NLS library.
264 BUILD_INCLUDED_LIBINTL=yes
265 USE_INCLUDED_LIBINTL=yes
266 LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
267 LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
268 LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
269 fi
270
271 CATOBJEXT=
272 if test "$gt_use_preinstalled_gnugettext" = "yes" \
273 || test "$nls_cv_use_gnu_gettext" = "yes"; then
274 dnl Mark actions to use GNU gettext tools.
275 CATOBJEXT=.gmo
276 fi
277 ])
278
279 if test -n "$INTL_MACOSX_LIBS"; then
280 if test "$gt_use_preinstalled_gnugettext" = "yes" \
281 || test "$nls_cv_use_gnu_gettext" = "yes"; then
282 dnl Some extra flags are needed during linking.
283 LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
284 LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
285 fi
286 fi
287
288 if test "$gt_use_preinstalled_gnugettext" = "yes" \
289 || test "$nls_cv_use_gnu_gettext" = "yes"; then
290 AC_DEFINE([ENABLE_NLS], [1],
291 [Define to 1 if translation of program messages to the user's native language
292 is requested.])
293 else
294 USE_NLS=no
295 fi
296 fi
297
298 AC_MSG_CHECKING([whether to use NLS])
299 AC_MSG_RESULT([$USE_NLS])
300 if test "$USE_NLS" = "yes"; then
301 AC_MSG_CHECKING([where the gettext function comes from])
302 if test "$gt_use_preinstalled_gnugettext" = "yes"; then
303 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
304 gt_source="external libintl"
305 else
306 gt_source="libc"
307 fi
308 else
309 gt_source="included intl directory"
310 fi
311 AC_MSG_RESULT([$gt_source])
312 fi
313
314 if test "$USE_NLS" = "yes"; then
315
316 if test "$gt_use_preinstalled_gnugettext" = "yes"; then
317 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
318 AC_MSG_CHECKING([how to link with libintl])
319 AC_MSG_RESULT([$LIBINTL])
320 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
321 fi
322
323 dnl For backward compatibility. Some packages may be using this.
324 AC_DEFINE([HAVE_GETTEXT], [1],
325 [Define if the GNU gettext() function is already present or preinstalled.])
326 AC_DEFINE([HAVE_DCGETTEXT], [1],
327 [Define if the GNU dcgettext() function is already present or preinstalled.])
328 fi
329
330 dnl We need to process the po/ directory.
331 POSUB=po
332 fi
333
334 ifelse(gt_included_intl, yes, [
335 dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
336 dnl to 'yes' because some of the testsuite requires it.
337 if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
338 BUILD_INCLUDED_LIBINTL=yes
339 fi
340
341 dnl Make all variables we use known to autoconf.
342 AC_SUBST([BUILD_INCLUDED_LIBINTL])
343 AC_SUBST([USE_INCLUDED_LIBINTL])
344 AC_SUBST([CATOBJEXT])
345
346 dnl For backward compatibility. Some configure.ins may be using this.
347 nls_cv_header_intl=
348 nls_cv_header_libgt=
349
350 dnl For backward compatibility. Some Makefiles may be using this.
351 DATADIRNAME=share
352 AC_SUBST([DATADIRNAME])
353
354 dnl For backward compatibility. Some Makefiles may be using this.
355 INSTOBJEXT=.mo
356 AC_SUBST([INSTOBJEXT])
357
358 dnl For backward compatibility. Some Makefiles may be using this.
359 GENCAT=gencat
360 AC_SUBST([GENCAT])
361
362 dnl For backward compatibility. Some Makefiles may be using this.
363 INTLOBJS=
364 if test "$USE_INCLUDED_LIBINTL" = yes; then
365 INTLOBJS="\$(GETTOBJS)"
366 fi
367 AC_SUBST([INTLOBJS])
368
369 dnl Enable libtool support if the surrounding package wishes it.
370 INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
371 AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
372 ])
373
374 dnl For backward compatibility. Some Makefiles may be using this.
375 INTLLIBS="$LIBINTL"
376 AC_SUBST([INTLLIBS])
377
378 dnl Make all documented variables known to autoconf.
379 AC_SUBST([LIBINTL])
380 AC_SUBST([LTLIBINTL])
381 AC_SUBST([POSUB])
382])
383
384
385dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
386m4_define([gt_NEEDS_INIT],
387[
388 m4_divert_text([DEFAULTS], [gt_needs=])
389 m4_define([gt_NEEDS_INIT], [])
390])
391
392
393dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
394AC_DEFUN([AM_GNU_GETTEXT_NEED],
395[
396 m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
397])
398
399
400dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
401AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
diff --git a/gl/m4/gl-openssl.m4 b/gl/m4/gl-openssl.m4
new file mode 100644
index 0000000..7eab4e1
--- /dev/null
+++ b/gl/m4/gl-openssl.m4
@@ -0,0 +1,76 @@
1# gl-openssl.m4 serial 6
2dnl Copyright (C) 2013-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SET_CRYPTO_CHECK_DEFAULT],
8[
9 m4_define([gl_CRYPTO_CHECK_DEFAULT], [$1])
10])
11gl_SET_CRYPTO_CHECK_DEFAULT([no])
12
13AC_DEFUN([gl_CRYPTO_CHECK],
14[
15 dnl gnulib users set this before gl_INIT with gl_SET_CRYPTO_CHECK_DEFAULT()
16 m4_divert_once([DEFAULTS], [with_openssl_default='gl_CRYPTO_CHECK_DEFAULT'])
17
18 dnl Only clear once, so crypto routines can be checked for individually
19 m4_divert_once([DEFAULTS], [LIB_CRYPTO=])
20
21 AC_ARG_WITH([openssl],
22 [[ --with-openssl[=ARG] use libcrypto hash routines for the hash functions
23 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512.
24 Valid ARGs are:
25 'yes',
26 'no',
27 'auto' => use if any version available,
28 'auto-gpl-compat' => use if GPL compatible version
29 available,
30 'optional' => use if available
31 and warn if not available;
32 Default is ']gl_CRYPTO_CHECK_DEFAULT['.]m4_ifdef([gl_AF_ALG], [
33 Note also --with-linux-crypto, which will enable the
34 use of Linux kernel crypto routines (if available),
35 which has precedence for files.])],
36 [],
37 [with_openssl=$with_openssl_default])
38
39 AC_SUBST([LIB_CRYPTO])
40 if test "x$with_openssl" != xno; then
41 if test "x$with_openssl" = xauto-gpl-compat; then
42 AC_CACHE_CHECK([whether openssl is GPL compatible],
43 [gl_cv_openssl_gpl_compat],
44 [AC_COMPILE_IFELSE(
45 [AC_LANG_PROGRAM([[
46 #include <openssl/opensslv.h>
47 #if OPENSSL_VERSION_MAJOR < 3
48 #error "openssl >= version 3 not found"
49 #endif
50 ]])],
51 [gl_cv_openssl_gpl_compat=yes],
52 [gl_cv_openssl_gpl_compat=no])])
53 fi
54 if test "x$with_openssl" != xauto-gpl-compat ||
55 test "x$gl_cv_openssl_gpl_compat" = xyes; then
56 AC_CHECK_LIB([crypto], [$1],
57 [AC_CHECK_HEADERS(
58 m4_if([$1], [MD5], [openssl/md5.h], [openssl/sha.h]),
59 [LIB_CRYPTO=-lcrypto
60 AC_DEFINE([HAVE_OPENSSL_$1], [1],
61 [Define to 1 if libcrypto is used for $1.])])])
62 fi
63 if test "x$LIB_CRYPTO" = x; then
64 message='openssl development library not found for $1.
65 If you want to install it, first find the pre-built package name:
66 - On Debian and Debian-based systems: libssl-dev,
67 - On Red Hat distributions: openssl-devel.
68 - Other: https://repology.org/project/openssl/versions'
69 if test "x$with_openssl" = xyes; then
70 AC_MSG_ERROR([$message])
71 elif test "x$with_openssl" = xoptional; then
72 AC_MSG_WARN([$message])
73 fi
74 fi
75 fi
76])
diff --git a/gl/m4/glibc2.m4 b/gl/m4/glibc2.m4
deleted file mode 100644
index 0e50682..0000000
--- a/gl/m4/glibc2.m4
+++ /dev/null
@@ -1,31 +0,0 @@
1# glibc2.m4 serial 3
2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Test for the GNU C Library, version 2.0 or newer.
9# From Bruno Haible.
10
11AC_DEFUN([gt_GLIBC2],
12 [
13 AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer],
14 [ac_cv_gnu_library_2],
15 [AC_EGREP_CPP([Lucky GNU user],
16 [
17#include <features.h>
18#ifdef __GNU_LIBRARY__
19 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
20 Lucky GNU user
21 #endif
22#endif
23 ],
24 [ac_cv_gnu_library_2=yes],
25 [ac_cv_gnu_library_2=no])
26 ]
27 )
28 AC_SUBST([GLIBC2])
29 GLIBC2="$ac_cv_gnu_library_2"
30 ]
31)
diff --git a/gl/m4/glibc21.m4 b/gl/m4/glibc21.m4
deleted file mode 100644
index 613fb2a..0000000
--- a/gl/m4/glibc21.m4
+++ /dev/null
@@ -1,34 +0,0 @@
1# glibc21.m4 serial 5
2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Test for the GNU C Library, version 2.1 or newer, or uClibc.
9# From Bruno Haible.
10
11AC_DEFUN([gl_GLIBC21],
12 [
13 AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
14 [ac_cv_gnu_library_2_1],
15 [AC_EGREP_CPP([Lucky],
16 [
17#include <features.h>
18#ifdef __GNU_LIBRARY__
19 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
20 Lucky GNU user
21 #endif
22#endif
23#ifdef __UCLIBC__
24 Lucky user
25#endif
26 ],
27 [ac_cv_gnu_library_2_1=yes],
28 [ac_cv_gnu_library_2_1=no])
29 ]
30 )
31 AC_SUBST([GLIBC21])
32 GLIBC21="$ac_cv_gnu_library_2_1"
33 ]
34)
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 90ad4aa..267f069 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,8 +1,8 @@
1# Copyright (C) 2002-2013 Free Software Foundation, Inc. 1# Copyright (C) 2002-2023 Free Software Foundation, Inc.
2# 2#
3# This file is free software; you can redistribute it and/or modify 3# This file is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by 4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or 5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version. 6# (at your option) any later version.
7# 7#
8# This file is distributed in the hope that it will be useful, 8# This file is distributed in the hope that it will be useful,
@@ -11,7 +11,7 @@
11# GNU General Public License for more details. 11# GNU General Public License for more details.
12# 12#
13# You should have received a copy of the GNU General Public License 13# You should have received a copy of the GNU General Public License
14# along with this file. If not, see <http://www.gnu.org/licenses/>. 14# along with this file. If not, see <https://www.gnu.org/licenses/>.
15# 15#
16# As a special exception to the GNU General Public License, 16# As a special exception to the GNU General Public License,
17# this file may be distributed as part of a program that 17# this file may be distributed as part of a program that
@@ -27,13 +27,45 @@
27 27
28 28
29# Specification in the form of a command-line invocation: 29# Specification in the form of a command-line invocation:
30# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt-gnu gettext idpriv-droptemp mountlist regex setenv strcase strcasestr strsep timegm unsetenv vasprintf vsnprintf 30# gnulib-tool --import \
31# --lib=libgnu \
32# --source-base=gl \
33# --m4-base=gl/m4 \
34# --doc-base=doc \
35# --tests-base=tests \
36# --aux-dir=build-aux \
37# --no-conditional-dependencies \
38# --no-libtool \
39# --macro-prefix=gl \
40# --no-vc-files \
41# base64 \
42# crypto/sha256 \
43# dirname \
44# environ \
45# floorf \
46# fsusage \
47# getaddrinfo \
48# gethostname \
49# getloadavg \
50# getopt-gnu \
51# gettext-h \
52# idpriv-droptemp \
53# mountlist \
54# regex \
55# setenv \
56# strcase \
57# strcasestr \
58# strsep \
59# timegm \
60# unsetenv \
61# vasprintf \
62# vsnprintf
31 63
32# Specification in the form of a few gnulib-tool.m4 macro invocations: 64# Specification in the form of a few gnulib-tool.m4 macro invocations:
33gl_LOCAL_DIR([]) 65gl_LOCAL_DIR([])
34gl_MODULES([ 66gl_MODULES([
35 base64 67 base64
36 crypto/sha1 68 crypto/sha256
37 dirname 69 dirname
38 environ 70 environ
39 floorf 71 floorf
@@ -42,7 +74,7 @@ gl_MODULES([
42 gethostname 74 gethostname
43 getloadavg 75 getloadavg
44 getopt-gnu 76 getopt-gnu
45 gettext 77 gettext-h
46 idpriv-droptemp 78 idpriv-droptemp
47 mountlist 79 mountlist
48 regex 80 regex
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 0ae5a9e..facc340 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,25 +1,59 @@
1# gnulib-common.m4 serial 33 1# gnulib-common.m4 serial 75a
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_PREREQ([2.62])
8
7# gl_COMMON 9# gl_COMMON
8# is expanded unconditionally through gnulib-tool magic. 10# is expanded unconditionally through gnulib-tool magic.
9AC_DEFUN([gl_COMMON], [ 11AC_DEFUN([gl_COMMON], [
10 dnl Use AC_REQUIRE here, so that the code is expanded once only. 12 dnl Use AC_REQUIRE here, so that the code is expanded once only.
11 AC_REQUIRE([gl_00GNULIB]) 13 AC_REQUIRE([gl_00GNULIB])
12 AC_REQUIRE([gl_COMMON_BODY]) 14 AC_REQUIRE([gl_COMMON_BODY])
15 AC_REQUIRE([gl_ZZGNULIB])
13]) 16])
14AC_DEFUN([gl_COMMON_BODY], [ 17AC_DEFUN([gl_COMMON_BODY], [
18 AH_VERBATIM([_GL_GNUC_PREREQ],
19[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */
20#if defined __GNUC__ && defined __GNUC_MINOR__
21# define _GL_GNUC_PREREQ(major, minor) \
22 ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
23#else
24# define _GL_GNUC_PREREQ(major, minor) 0
25#endif
26])
15 AH_VERBATIM([_Noreturn], 27 AH_VERBATIM([_Noreturn],
16[/* The _Noreturn keyword of C11. */ 28[/* The _Noreturn keyword of C11. */
17#if ! (defined _Noreturn \ 29#ifndef _Noreturn
18 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) 30# if (defined __cplusplus \
19# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ 31 && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
20 || 0x5110 <= __SUNPRO_C) 32 || (defined _MSC_VER && 1900 <= _MSC_VER)) \
33 && 0)
34 /* [[noreturn]] is not practically usable, because with it the syntax
35 extern _Noreturn void func (...);
36 would not be valid; such a declaration would only be valid with 'extern'
37 and '_Noreturn' swapped, or without the 'extern' keyword. However, some
38 AIX system header files and several gnulib header files use precisely
39 this syntax with 'extern'. */
40# define _Noreturn [[noreturn]]
41# elif (defined __clang__ && __clang_major__ < 16 \
42 && defined _GL_WORK_AROUND_LLVM_BUG_59792)
43 /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around
44 that rare LLVM bug, though you may get many false-alarm warnings. */
45# define _Noreturn
46# elif ((!defined __cplusplus || defined __clang__) \
47 && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
48 || (!defined __STRICT_ANSI__ \
49 && (_GL_GNUC_PREREQ (4, 7) \
50 || (defined __apple_build_version__ \
51 ? 6000000 <= __apple_build_version__ \
52 : 3 < __clang_major__ + (5 <= __clang_minor__))))))
53 /* _Noreturn works as-is. */
54# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C
21# define _Noreturn __attribute__ ((__noreturn__)) 55# define _Noreturn __attribute__ ((__noreturn__))
22# elif defined _MSC_VER && 1200 <= _MSC_VER 56# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
23# define _Noreturn __declspec (noreturn) 57# define _Noreturn __declspec (noreturn)
24# else 58# else
25# define _Noreturn 59# define _Noreturn
@@ -36,33 +70,519 @@ AC_DEFUN([gl_COMMON_BODY], [
36#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ 70#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
37# define __GNUC_STDC_INLINE__ 1 71# define __GNUC_STDC_INLINE__ 1
38#endif]) 72#endif])
39 AH_VERBATIM([unused_parameter], 73 AH_VERBATIM([attribute],
40[/* Define as a marker that can be attached to declarations that might not 74[/* Attributes. */
41 be used. This helps to reduce warnings, such as from 75#if (defined __has_attribute \
42 GCC -Wunused-parameter. */ 76 && (!defined __clang_minor__ \
43#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 77 || (defined __apple_build_version__ \
44# define _GL_UNUSED __attribute__ ((__unused__)) 78 ? 6000000 <= __apple_build_version__ \
79 : 3 < __clang_major__ + (5 <= __clang_minor__))))
80# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
45#else 81#else
46# define _GL_UNUSED 82# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr
83# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3)
84# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2)
85# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3)
86# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3)
87# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95)
88# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1)
89# define _GL_ATTR_diagnose_if 0
90# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3)
91# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1)
92# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0)
93# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7)
94# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6)
95# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0)
96# ifdef _ICC
97# define _GL_ATTR_may_alias 0
98# else
99# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3)
100# endif
101# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1)
102# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3)
103# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0)
104# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3)
105# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7)
106# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96)
107# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9)
108# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0)
109# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7)
110# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4)
47#endif 111#endif
48/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
49 is a misnomer outside of parameter lists. */
50#define _UNUSED_PARAMETER_ _GL_UNUSED
51 112
52/* The __pure__ attribute was added in gcc 2.96. */ 113/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */
53#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 114#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \
54# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 115 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710)
55#else 116# pragma GCC diagnostic ignored "-Wpedantic"
56# define _GL_ATTRIBUTE_PURE /* empty */
57#endif 117#endif
58 118
59/* The __const__ attribute was added in gcc 2.95. */ 119]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead.
60#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 120[
61# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) 121/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
62#else 122 is the size of the returned memory block.
63# define _GL_ATTRIBUTE_CONST /* empty */ 123 _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied
124 by the Nth argument of the function is the size of the returned memory block.
125 */
126/* Applies to: function, pointer to function, function types. */
127#ifndef _GL_ATTRIBUTE_ALLOC_SIZE
128# if _GL_HAS_ATTRIBUTE (alloc_size)
129# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
130# else
131# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
132# endif
133#endif
134
135/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the
136 function and report an error if it cannot do so. */
137/* Applies to: function. */
138#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE
139# if _GL_HAS_ATTRIBUTE (always_inline)
140# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__))
141# else
142# define _GL_ATTRIBUTE_ALWAYS_INLINE
143# endif
144#endif
145
146/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show
147 in stack traces when debugging. The compiler should omit the function from
148 stack traces. */
149/* Applies to: function. */
150#ifndef _GL_ATTRIBUTE_ARTIFICIAL
151# if _GL_HAS_ATTRIBUTE (artificial)
152# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__))
153# else
154# define _GL_ATTRIBUTE_ARTIFICIAL
155# endif
156#endif
157
158/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */
159/* Applies to: functions. */
160/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at
161 <https://lists.gnu.org/r/emacs-devel/2019-04/msg01152.html>.
162 Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */
163#ifndef _GL_ATTRIBUTE_COLD
164# if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__
165# ifndef __SUNPRO_C
166# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__))
167# else
168# define _GL_ATTRIBUTE_COLD __attribute__ ((cold))
169# endif
170# else
171# define _GL_ATTRIBUTE_COLD
172# endif
173#endif
174
175/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate
176 calls to the function with the same arguments.
177 This attribute is safe for a function that neither depends on nor affects
178 observable state, and always returns exactly once - e.g., does not loop
179 forever, and does not call longjmp.
180 (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */
181/* Applies to: functions. */
182#ifndef _GL_ATTRIBUTE_CONST
183# if _GL_HAS_ATTRIBUTE (const)
184# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
185# else
186# define _GL_ATTRIBUTE_CONST
187# endif
188#endif
189
190/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
191 that can be freed by passing them as the Ith argument to the
192 function F.
193 _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
194 can be freed via 'free'; it can be used only after declaring 'free'. */
195/* Applies to: functions. Cannot be used on inline functions. */
196#ifndef _GL_ATTRIBUTE_DEALLOC
197# if _GL_GNUC_PREREQ (11, 0)
198# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
199# else
200# define _GL_ATTRIBUTE_DEALLOC(f, i)
201# endif
202#endif
203/* If gnulib's <string.h> or <wchar.h> has already defined this macro, continue
204 to use this earlier definition, since <stdlib.h> may not have been included
205 yet. */
206#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
207# if defined __cplusplus && defined __GNUC__ && !defined __clang__
208/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
209# define _GL_ATTRIBUTE_DEALLOC_FREE \
210 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
211# else
212# define _GL_ATTRIBUTE_DEALLOC_FREE \
213 _GL_ATTRIBUTE_DEALLOC (free, 1)
214# endif
215#endif
216
217/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated.
218 The compiler may warn if the entity is used. */
219/* Applies to:
220 - function, variable,
221 - struct, union, struct/union member,
222 - enumeration, enumeration item,
223 - typedef,
224 in C++ also: namespace, class, template specialization. */
225#ifndef _GL_ATTRIBUTE_DEPRECATED
226# ifdef __has_c_attribute
227# if __has_c_attribute (__deprecated__)
228# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]]
229# endif
230# endif
231# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated)
232# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
233# endif
234# ifndef _GL_ATTRIBUTE_DEPRECATED
235# define _GL_ATTRIBUTE_DEPRECATED
236# endif
237#endif
238
239/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and
240 the function call is not optimized away.
241 _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and
242 the function call is not optimized away. */
243/* Applies to: functions. */
244#if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING)
245# if _GL_HAS_ATTRIBUTE (error)
246# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg)))
247# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg)))
248# elif _GL_HAS_ATTRIBUTE (diagnose_if)
249# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error")))
250# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning")))
251# else
252# define _GL_ATTRIBUTE_ERROR(msg)
253# define _GL_ATTRIBUTE_WARNING(msg)
254# endif
255#endif
256
257/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain
258 visible to debuggers etc., even with '-fwhole-program'. */
259/* Applies to: functions, variables. */
260#ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
261# if _GL_HAS_ATTRIBUTE (externally_visible)
262# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible))
263# else
264# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE
265# endif
266#endif
267
268/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if
269 the control flow falls through to the immediately following 'case' or
270 'default' label. The compiler should not warn in this case. */
271/* Applies to: Empty statement (;), inside a 'switch' statement. */
272/* Always expands to something. */
273#ifndef _GL_ATTRIBUTE_FALLTHROUGH
274# ifdef __has_c_attribute
275# if __has_c_attribute (__fallthrough__)
276# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]]
277# endif
278# endif
279# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough)
280# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
281# endif
282# ifndef _GL_ATTRIBUTE_FALLTHROUGH
283# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0)
284# endif
285#endif
286
287/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK))
288 declares that the STRING-INDEXth function argument is a format string of
289 style ARCHETYPE, which is one of:
290 printf, gnu_printf
291 scanf, gnu_scanf,
292 strftime, gnu_strftime,
293 strfmon,
294 or the same thing prefixed and suffixed with '__'.
295 If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK
296 are suitable for the format string. */
297/* Applies to: functions. */
298#ifndef _GL_ATTRIBUTE_FORMAT
299# if _GL_HAS_ATTRIBUTE (format)
300# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
301# else
302# define _GL_ATTRIBUTE_FORMAT(spec)
303# endif
304#endif
305
306/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other
307 compilation unit, it executes code from that unit only by return or by
308 exception handling. This declaration lets the compiler optimize that unit
309 more aggressively. */
310/* Applies to: functions. */
311#ifndef _GL_ATTRIBUTE_LEAF
312# if _GL_HAS_ATTRIBUTE (leaf)
313# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__))
314# else
315# define _GL_ATTRIBUTE_LEAF
316# endif
317#endif
318
319/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
320 allocated memory. */
321/* Applies to: functions. */
322#ifndef _GL_ATTRIBUTE_MALLOC
323# if _GL_HAS_ATTRIBUTE (malloc)
324# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
325# else
326# define _GL_ATTRIBUTE_MALLOC
327# endif
328#endif
329
330/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the
331 same storage as pointers to other types. Thus this declaration disables
332 strict aliasing optimization. */
333/* Applies to: types. */
334/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */
335#ifndef _GL_ATTRIBUTE_MAY_ALIAS
336# if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C
337# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__))
338# else
339# define _GL_ATTRIBUTE_MAY_ALIAS
340# endif
341#endif
342
343/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if
344 the entity is not used. The compiler should not warn if the entity is not
345 used. */
346/* Applies to:
347 - function, variable,
348 - struct, union, struct/union member,
349 - enumeration, enumeration item,
350 - typedef,
351 in C++ also: class. */
352/* In C++ and C23, this is spelled [[__maybe_unused__]].
353 GCC's syntax is __attribute__ ((__unused__)).
354 clang supports both syntaxes. */
355#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
356# ifdef __has_c_attribute
357# if __has_c_attribute (__maybe_unused__)
358# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]]
359# endif
360# endif
361# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED
362# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED
363# endif
364#endif
365/* Alternative spelling of this macro, for convenience and for
366 compatibility with glibc/include/libc-symbols.h. */
367#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED
368/* Earlier spellings of this macro. */
369#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED
370
371/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not
372 discard the return value. The compiler may warn if the caller does not use
373 the return value, unless the caller uses something like ignore_value. */
374/* Applies to: function, enumeration, class. */
375#ifndef _GL_ATTRIBUTE_NODISCARD
376# ifdef __has_c_attribute
377# if __has_c_attribute (__nodiscard__)
378# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
379# endif
380# endif
381# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result)
382# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
383# endif
384# ifndef _GL_ATTRIBUTE_NODISCARD
385# define _GL_ATTRIBUTE_NODISCARD
386# endif
387#endif
388
389/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the
390 function. */
391/* Applies to: functions. */
392#ifndef _GL_ATTRIBUTE_NOINLINE
393# if _GL_HAS_ATTRIBUTE (noinline)
394# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__))
395# else
396# define _GL_ATTRIBUTE_NOINLINE
397# endif
398#endif
399
400/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,...
401 must not be NULL.
402 _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be
403 null. */
404/* Applies to: functions. */
405#ifndef _GL_ATTRIBUTE_NONNULL
406# if _GL_HAS_ATTRIBUTE (nonnull)
407# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args))
408# else
409# define _GL_ATTRIBUTE_NONNULL(args)
410# endif
411#endif
412
413/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is
414 not meant to be NUL-terminated. */
415/* Applies to: struct/union members and variables that are arrays of element
416 type '[[un]signed] char'. */
417#ifndef _GL_ATTRIBUTE_NONSTRING
418# if _GL_HAS_ATTRIBUTE (nonstring)
419# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__))
420# else
421# define _GL_ATTRIBUTE_NONSTRING
422# endif
423#endif
424
425/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */
426
427/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
428 */
429/* Applies to: functions. */
430#ifndef _GL_ATTRIBUTE_NOTHROW
431# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus
432# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
433# else
434# define _GL_ATTRIBUTE_NOTHROW
435# endif
436#endif
437
438/* _GL_ATTRIBUTE_PACKED declares:
439 For struct members: The member has the smallest possible alignment.
440 For struct, union, class: All members have the smallest possible alignment,
441 minimizing the memory required. */
442/* Applies to: struct members, struct, union,
443 in C++ also: class. */
444#ifndef _GL_ATTRIBUTE_PACKED
445# if _GL_HAS_ATTRIBUTE (packed)
446# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__))
447# else
448# define _GL_ATTRIBUTE_PACKED
449# endif
450#endif
451
452/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate
453 calls to the function with the same arguments if observable state is not
454 changed between calls.
455 This attribute is safe for a function that does not affect
456 observable state, and always returns exactly once.
457 (This attribute is looser than _GL_ATTRIBUTE_CONST.) */
458/* Applies to: functions. */
459#ifndef _GL_ATTRIBUTE_PURE
460# if _GL_HAS_ATTRIBUTE (pure)
461# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
462# else
463# define _GL_ATTRIBUTE_PURE
464# endif
465#endif
466
467/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is
468 a non-NULL pointer. */
469/* Applies to: functions. */
470#ifndef _GL_ATTRIBUTE_RETURNS_NONNULL
471# if _GL_HAS_ATTRIBUTE (returns_nonnull)
472# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
473# else
474# define _GL_ATTRIBUTE_RETURNS_NONNULL
475# endif
476#endif
477
478/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a
479 trailing NULL argument.
480 _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99).
481 _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */
482/* Applies to: functions. */
483#ifndef _GL_ATTRIBUTE_SENTINEL
484# if _GL_HAS_ATTRIBUTE (sentinel)
485# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos))
486# else
487# define _GL_ATTRIBUTE_SENTINEL(pos)
488# endif
489#endif
490
491/* A helper macro. Don't use it directly. */
492#ifndef _GL_ATTRIBUTE_UNUSED
493# if _GL_HAS_ATTRIBUTE (unused)
494# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
495# else
496# define _GL_ATTRIBUTE_UNUSED
497# endif
498#endif
499
500]dnl There is no _GL_ATTRIBUTE_VISIBILITY; see m4/visibility.m4 instead.
501[
502/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the
503 immediately preceding label is not used. The compiler should not warn
504 if the label is not used. */
505/* Applies to: label (both in C and C++). */
506/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;'
507 syntax. But clang does. */
508#ifndef _GL_UNUSED_LABEL
509# if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__
510# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED
511# else
512# define _GL_UNUSED_LABEL
513# endif
64#endif 514#endif
65]) 515])
516 AH_VERBATIM([async_safe],
517[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
518 signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
519 invoked from such signal handlers. Such functions have some restrictions:
520 * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
521 or should be listed as async-signal-safe in POSIX
522 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
523 section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in
524 particular, are NOT async-signal-safe.
525 * All memory locations (variables and struct fields) that these functions
526 access must be marked 'volatile'. This holds for both read and write
527 accesses. Otherwise the compiler might optimize away stores to and
528 reads from such locations that occur in the program, depending on its
529 data flow analysis. For example, when the program contains a loop
530 that is intended to inspect a variable set from within a signal handler
531 while (!signal_occurred)
532 ;
533 the compiler is allowed to transform this into an endless loop if the
534 variable 'signal_occurred' is not declared 'volatile'.
535 Additionally, recall that:
536 * A signal handler should not modify errno (except if it is a handler
537 for a fatal signal and ends by raising the same signal again, thus
538 provoking the termination of the process). If it invokes a function
539 that may clobber errno, it needs to save and restore the value of
540 errno. */
541#define _GL_ASYNC_SAFE
542])
543 AH_VERBATIM([micro_optimizations],
544[/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where
545 n1 and n2 are expressions without side effects, that evaluate to real
546 numbers (excluding NaN).
547 It returns
548 1 if n1 > n2
549 0 if n1 == n2
550 -1 if n1 < n2
551 The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional
552 jump with nearly all GCC versions up to GCC 10.
553 This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many
554 GCC versions up to GCC 9.
555 The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9
556 avoids conditional jumps in all GCC versions >= 3.4. */
557#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2)))
558])
559 dnl Hint which direction to take regarding cross-compilation guesses:
560 dnl When a user installs a program on a platform they are not intimately
561 dnl familiar with, --enable-cross-guesses=conservative is the appropriate
562 dnl choice. It implements the "If we don't know, assume the worst" principle.
563 dnl However, when an operating system developer (on a platform which is not
564 dnl yet known to gnulib) builds packages for their platform, they want to
565 dnl expose, not hide, possible platform bugs; in this case,
566 dnl --enable-cross-guesses=risky is the appropriate choice.
567 dnl Sets the variables
568 dnl gl_cross_guess_normal (to be used when 'yes' is good and 'no' is bad),
569 dnl gl_cross_guess_inverted (to be used when 'no' is good and 'yes' is bad).
570 AC_ARG_ENABLE([cross-guesses],
571 [AS_HELP_STRING([--enable-cross-guesses={conservative|risky}],
572 [specify policy for cross-compilation guesses])],
573 [if test "x$enableval" != xconservative && test "x$enableval" != xrisky; then
574 AC_MSG_WARN([invalid argument supplied to --enable-cross-guesses])
575 enableval=conservative
576 fi
577 gl_cross_guesses="$enableval"],
578 [gl_cross_guesses=conservative])
579 if test $gl_cross_guesses = risky; then
580 gl_cross_guess_normal="guessing yes"
581 gl_cross_guess_inverted="guessing no"
582 else
583 gl_cross_guess_normal="guessing no"
584 gl_cross_guess_inverted="guessing yes"
585 fi
66 dnl Preparation for running test programs: 586 dnl Preparation for running test programs:
67 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not 587 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
68 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics 588 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
@@ -71,6 +591,16 @@ AC_DEFUN([gl_COMMON_BODY], [
71 export LIBC_FATAL_STDERR_ 591 export LIBC_FATAL_STDERR_
72]) 592])
73 593
594# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename])
595# gl_MODULE_INDICATOR_INIT_VARIABLE([variablename], [initialvalue])
596# initializes the shell variable that indicates the presence of the given module
597# as a C preprocessor expression.
598AC_DEFUN([gl_MODULE_INDICATOR_INIT_VARIABLE],
599[
600 GL_MODULE_INDICATOR_PREFIX[]_[$1]=m4_if([$2], , [0], [$2])
601 AC_SUBST(GL_MODULE_INDICATOR_PREFIX[]_[$1])
602])
603
74# gl_MODULE_INDICATOR_CONDITION 604# gl_MODULE_INDICATOR_CONDITION
75# expands to a C preprocessor expression that evaluates to 1 or 0, depending 605# expands to a C preprocessor expression that evaluates to 1 or 0, depending
76# whether a gnulib module that has been requested shall be considered present 606# whether a gnulib module that has been requested shall be considered present
@@ -83,9 +613,9 @@ m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
83AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], 613AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
84[ 614[
85 gl_MODULE_INDICATOR_SET_VARIABLE_AUX( 615 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
86 [GNULIB_[]m4_translit([[$1]], 616 [GL_MODULE_INDICATOR_PREFIX[]_GNULIB_[]m4_translit([[$1]],
87 [abcdefghijklmnopqrstuvwxyz./-], 617 [abcdefghijklmnopqrstuvwxyz./-],
88 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], 618 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
89 [gl_MODULE_INDICATOR_CONDITION]) 619 [gl_MODULE_INDICATOR_CONDITION])
90]) 620])
91 621
@@ -197,42 +727,20 @@ AC_DEFUN([gl_FEATURES_H],
197 AC_SUBST([HAVE_FEATURES_H]) 727 AC_SUBST([HAVE_FEATURES_H])
198]) 728])
199 729
200# m4_foreach_w
201# is a backport of autoconf-2.59c's m4_foreach_w.
202# Remove this macro when we can assume autoconf >= 2.60.
203m4_ifndef([m4_foreach_w],
204 [m4_define([m4_foreach_w],
205 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
206
207# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
208# ----------------------------------------------------
209# Backport of autoconf-2.63b's macro.
210# Remove this macro when we can assume autoconf >= 2.64.
211m4_ifndef([AS_VAR_IF],
212[m4_define([AS_VAR_IF],
213[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
214
215# gl_PROG_CC_C99 730# gl_PROG_CC_C99
216# Modifies the value of the shell variable CC in an attempt to make $CC 731# Modifies the value of the shell variable CC in an attempt to make $CC
217# understand ISO C99 source code. 732# understand ISO C99 source code.
218# This is like AC_PROG_CC_C99, except that
219# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
220# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
221# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
222# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
223# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
224# Remaining problems:
225# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
226# to CC twice
227# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
228# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
229AC_DEFUN([gl_PROG_CC_C99], 733AC_DEFUN([gl_PROG_CC_C99],
230[ 734[
231 dnl Change that version number to the minimum Autoconf version that supports 735 dnl Just use AC_PROG_CC_C99.
232 dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls. 736 dnl When AC_PROG_CC_C99 and AC_PROG_CC_STDC are used together, the substituted
233 m4_version_prereq([9.0], 737 dnl value of CC will contain the C99 enabling options twice. But this is only
234 [AC_REQUIRE([AC_PROG_CC_C99])], 738 dnl a cosmetic problem.
235 [AC_REQUIRE([AC_PROG_CC_STDC])]) 739 dnl With Autoconf >= 2.70, use AC_PROG_CC since it implies AC_PROG_CC_C99;
740 dnl this avoids a "warning: The macro `AC_PROG_CC_C99' is obsolete."
741 m4_version_prereq([2.70],
742 [AC_REQUIRE([AC_PROG_CC])],
743 [AC_REQUIRE([AC_PROG_CC_C99])])
236]) 744])
237 745
238# gl_PROG_AR_RANLIB 746# gl_PROG_AR_RANLIB
@@ -243,9 +751,11 @@ AC_DEFUN([gl_PROG_AR_RANLIB],
243[ 751[
244 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler 752 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
245 dnl as "cc", and GCC as "gcc". They have different object file formats and 753 dnl as "cc", and GCC as "gcc". They have different object file formats and
246 dnl library formats. In particular, the GNU binutils programs ar, ranlib 754 dnl library formats. In particular, the GNU binutils programs ar and ranlib
247 dnl produce libraries that work only with gcc, not with cc. 755 dnl produce libraries that work only with gcc, not with cc.
248 AC_REQUIRE([AC_PROG_CC]) 756 AC_REQUIRE([AC_PROG_CC])
757 dnl The '][' hides this use from 'aclocal'.
758 AC_BEFORE([$0], [A][M_PROG_AR])
249 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler], 759 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
250 [ 760 [
251 AC_EGREP_CPP([Amsterdam], 761 AC_EGREP_CPP([Amsterdam],
@@ -257,25 +767,39 @@ Amsterdam
257 [gl_cv_c_amsterdam_compiler=yes], 767 [gl_cv_c_amsterdam_compiler=yes],
258 [gl_cv_c_amsterdam_compiler=no]) 768 [gl_cv_c_amsterdam_compiler=no])
259 ]) 769 ])
260 if test -z "$AR"; then 770
261 if test $gl_cv_c_amsterdam_compiler = yes; then 771 dnl Don't compete with AM_PROG_AR's decision about AR/ARFLAGS if we are not
772 dnl building with __ACK__.
773 if test $gl_cv_c_amsterdam_compiler = yes; then
774 if test -z "$AR"; then
262 AR='cc -c.a' 775 AR='cc -c.a'
263 if test -z "$ARFLAGS"; then
264 ARFLAGS='-o'
265 fi
266 else
267 dnl Use the Automake-documented default values for AR and ARFLAGS,
268 dnl but prefer ${host}-ar over ar (useful for cross-compiling).
269 AC_CHECK_TOOL([AR], [ar], [ar])
270 if test -z "$ARFLAGS"; then
271 ARFLAGS='cru'
272 fi
273 fi 776 fi
274 else
275 if test -z "$ARFLAGS"; then 777 if test -z "$ARFLAGS"; then
276 ARFLAGS='cru' 778 ARFLAGS='-o'
277 fi 779 fi
780 else
781 dnl AM_PROG_AR was added in automake v1.11.2. AM_PROG_AR does not AC_SUBST
782 dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
783 dnl script on-demand, if not specified by ./configure of course).
784 dnl Don't AC_REQUIRE the AM_PROG_AR otherwise the code for __ACK__ above
785 dnl will be ignored. Also, pay attention to call AM_PROG_AR in else block
786 dnl because AM_PROG_AR is written so it could re-set AR variable even for
787 dnl __ACK__. It may seem like its easier to avoid calling the macro here,
788 dnl but we need to AC_SUBST both AR/ARFLAGS (thus those must have some good
789 dnl default value and automake should usually know them).
790 dnl
791 dnl The '][' hides this use from 'aclocal'.
792 m4_ifdef([A][M_PROG_AR], [A][M_PROG_AR], [:])
278 fi 793 fi
794
795 dnl In case the code above has not helped with setting AR/ARFLAGS, use
796 dnl Automake-documented default values for AR and ARFLAGS, but prefer
797 dnl ${host}-ar over ar (useful for cross-compiling).
798 AC_CHECK_TOOL([AR], [ar], [ar])
799 if test -z "$ARFLAGS"; then
800 ARFLAGS='cr'
801 fi
802
279 AC_SUBST([AR]) 803 AC_SUBST([AR])
280 AC_SUBST([ARFLAGS]) 804 AC_SUBST([ARFLAGS])
281 if test -z "$RANLIB"; then 805 if test -z "$RANLIB"; then
@@ -289,46 +813,29 @@ Amsterdam
289 AC_SUBST([RANLIB]) 813 AC_SUBST([RANLIB])
290]) 814])
291 815
292# AC_PROG_MKDIR_P
293# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
294# for interoperability with automake-1.9.6 from autoconf-2.62.
295# Remove this macro when we can assume autoconf >= 2.62 or
296# autoconf >= 2.60 && automake >= 1.10.
297# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
298m4_ifndef([AC_AUTOCONF_VERSION],[
299m4_ifdef([AC_PROG_MKDIR_P], [
300 dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
301 m4_define([AC_PROG_MKDIR_P],
302 m4_defn([AC_PROG_MKDIR_P])[
303 AC_SUBST([MKDIR_P])])], [
304 dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P.
305 AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
306 [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
307 MKDIR_P='$(mkdir_p)'
308 AC_SUBST([MKDIR_P])])])
309])
310
311# AC_C_RESTRICT 816# AC_C_RESTRICT
312# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, 817# This definition is copied from post-2.70 Autoconf and overrides the
313# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ 818# AC_C_RESTRICT macro from autoconf 2.60..2.70.
314# works. 819m4_version_prereq([2.70.1], [], [
315# This definition can be removed once autoconf >= 2.62 can be assumed.
316# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
317m4_ifndef([AC_AUTOCONF_VERSION],[
318AC_DEFUN([AC_C_RESTRICT], 820AC_DEFUN([AC_C_RESTRICT],
319[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], 821[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
320 [ac_cv_c_restrict=no 822 [ac_cv_c_restrict=no
321 # The order here caters to the fact that C++ does not require restrict. 823 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
322 for ac_kw in __restrict __restrict__ _Restrict restrict; do 824 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
323 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 825 # Put 'restrict' last, because C++ lacks it.
324 [[typedef int * int_ptr; 826 for ac_kw in __restrict__ __restrict _Restrict restrict; do
325 int foo (int_ptr $ac_kw ip) { 827 AC_COMPILE_IFELSE(
326 return ip[0]; 828 [AC_LANG_PROGRAM(
327 }]], 829 [[typedef int *int_ptr;
328 [[int s[1]; 830 int foo (int_ptr $ac_kw ip) { return ip[0]; }
329 int * $ac_kw t = s; 831 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
330 t[0] = 0; 832 int bar (int ip[$ac_kw]) { return ip[0]; }
331 return foo(t)]])], 833 ]],
834 [[int s[1];
835 int *$ac_kw t = s;
836 t[0] = 0;
837 return foo (t) + bar (t);
838 ]])],
332 [ac_cv_c_restrict=$ac_kw]) 839 [ac_cv_c_restrict=$ac_kw])
333 test "$ac_cv_c_restrict" != no && break 840 test "$ac_cv_c_restrict" != no && break
334 done 841 done
@@ -336,22 +843,24 @@ AC_DEFUN([AC_C_RESTRICT],
336 AH_VERBATIM([restrict], 843 AH_VERBATIM([restrict],
337[/* Define to the equivalent of the C99 'restrict' keyword, or to 844[/* Define to the equivalent of the C99 'restrict' keyword, or to
338 nothing if this is not supported. Do not define if restrict is 845 nothing if this is not supported. Do not define if restrict is
339 supported directly. */ 846 supported only directly. */
340#undef restrict 847#undef restrict
341/* Work around a bug in Sun C++: it does not support _Restrict, even 848/* Work around a bug in older versions of Sun C++, which did not
342 though the corresponding Sun C compiler does, which causes 849 #define __restrict__ or support _Restrict or __restrict__
343 "#define restrict _Restrict" in the previous line. Perhaps some future 850 even though the corresponding Sun C compiler ended up with
344 version of Sun C++ will work with _Restrict; if so, it'll probably 851 "#define restrict _Restrict" or "#define restrict __restrict__"
345 define __RESTRICT, just as Sun C does. */ 852 in the previous line. This workaround can be removed once
346#if defined __SUNPRO_CC && !defined __RESTRICT 853 we assume Oracle Developer Studio 12.5 (2016) or later. */
854#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
347# define _Restrict 855# define _Restrict
856# define __restrict__
348#endif]) 857#endif])
349 case $ac_cv_c_restrict in 858 case $ac_cv_c_restrict in
350 restrict) ;; 859 restrict) ;;
351 no) AC_DEFINE([restrict], []) ;; 860 no) AC_DEFINE([restrict], []) ;;
352 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; 861 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
353 esac 862 esac
354]) 863])# AC_C_RESTRICT
355]) 864])
356 865
357# gl_BIGENDIAN 866# gl_BIGENDIAN
@@ -363,6 +872,22 @@ AC_DEFUN([gl_BIGENDIAN],
363 AC_C_BIGENDIAN 872 AC_C_BIGENDIAN
364]) 873])
365 874
875# A temporary file descriptor.
876# Must be less than 10, because dash 0.5.8 does not support redirections
877# with multi-digit file descriptors.
878m4_define([GL_TMP_FD], 9)
879
880# gl_SILENT(command)
881# executes command, but without the normal configure output.
882# This is useful when you want to invoke AC_CACHE_CHECK (or AC_CHECK_FUNC etc.)
883# inside another AC_CACHE_CHECK.
884AC_DEFUN([gl_SILENT],
885[
886 exec GL_TMP_FD>&AS_MESSAGE_FD AS_MESSAGE_FD>/dev/null
887 $1
888 exec AS_MESSAGE_FD>&GL_TMP_FD GL_TMP_FD>&-
889])
890
366# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) 891# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
367# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not 892# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
368# output a spurious "(cached)" mark in the midst of other configure output. 893# output a spurious "(cached)" mark in the midst of other configure output.
@@ -370,8 +895,257 @@ AC_DEFUN([gl_BIGENDIAN],
370# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. 895# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
371AC_DEFUN([gl_CACHE_VAL_SILENT], 896AC_DEFUN([gl_CACHE_VAL_SILENT],
372[ 897[
373 saved_as_echo_n="$as_echo_n" 898 gl_SILENT([
374 as_echo_n=':' 899 AC_CACHE_VAL([$1], [$2])
375 AC_CACHE_VAL([$1], [$2]) 900 ])
376 as_echo_n="$saved_as_echo_n" 901])
902
903# gl_CONDITIONAL(conditional, condition)
904# is like AM_CONDITIONAL(conditional, condition), except that it does not
905# produce an error
906# configure: error: conditional "..." was never defined.
907# Usually this means the macro was only invoked conditionally.
908# when only invoked conditionally. Instead, in that case, both the _TRUE
909# and the _FALSE case are disabled.
910AC_DEFUN([gl_CONDITIONAL],
911[
912 pushdef([AC_CONFIG_COMMANDS_PRE], [:])dnl
913 AM_CONDITIONAL([$1], [$2])
914 popdef([AC_CONFIG_COMMANDS_PRE])dnl
915 if test -z "${[$1]_TRUE}" && test -z "${[$1]_FALSE}"; then
916 [$1]_TRUE='#'
917 [$1]_FALSE='#'
918 fi
919])
920
921# gl_CC_ALLOW_WARNINGS
922# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
923# that reverts a preceding '-Werror' option, if available.
924# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
925# and empty otherwise.
926AC_DEFUN([gl_CC_ALLOW_WARNINGS],
927[
928 AC_REQUIRE([AC_PROG_CC])
929 AC_CACHE_CHECK([for C compiler option to allow warnings],
930 [gl_cv_cc_wallow],
931 [rm -f conftest*
932 echo 'int dummy;' > conftest.c
933 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
934 AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
935 dnl Test the number of error output lines, because AIX xlc accepts the
936 dnl option '-Wno-error', just to produce a warning
937 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
938 dnl afterwards.
939 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
940 gl_cv_cc_wallow='-Wno-error'
941 else
942 gl_cv_cc_wallow=none
943 fi
944 rm -f conftest*
945 ])
946 case "$gl_cv_cc_wallow" in
947 none) GL_CFLAG_ALLOW_WARNINGS='' ;;
948 *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
949 esac
950 AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
951])
952
953# gl_CXX_ALLOW_WARNINGS
954# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
955# that reverts a preceding '-Werror' option, if available.
956AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
957[
958 dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
959 if test -n "$CXX" && test "$CXX" != no; then
960 AC_CACHE_CHECK([for C++ compiler option to allow warnings],
961 [gl_cv_cxx_wallow],
962 [rm -f conftest*
963 echo 'int dummy;' > conftest.cc
964 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
965 AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
966 dnl Test the number of error output lines, because AIX xlC accepts the
967 dnl option '-Wno-error', just to produce a warning
968 dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
969 dnl afterwards.
970 if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
971 gl_cv_cxx_wallow='-Wno-error'
972 else
973 gl_cv_cxx_wallow=none
974 fi
975 rm -f conftest*
976 ])
977 case "$gl_cv_cxx_wallow" in
978 none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
979 *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
980 esac
981 else
982 GL_CXXFLAG_ALLOW_WARNINGS=''
983 fi
984 AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
985])
986
987# gl_CC_GNULIB_WARNINGS
988# sets and substitutes a variable GL_CFLAG_GNULIB_WARNINGS, to a $(CC) option
989# set that enables or disables warnings as suitable for the Gnulib coding style.
990AC_DEFUN([gl_CC_GNULIB_WARNINGS],
991[
992 AC_REQUIRE([gl_CC_ALLOW_WARNINGS])
993 dnl Assume that the compiler supports -Wno-* options only if it also supports
994 dnl -Wno-error.
995 GL_CFLAG_GNULIB_WARNINGS=''
996 if test -n "$GL_CFLAG_ALLOW_WARNINGS"; then
997 dnl Enable these warning options:
998 dnl
999 dnl GCC clang
1000 dnl -Wno-cast-qual >= 3 >= 3.9
1001 dnl -Wno-conversion >= 3 >= 3.9
1002 dnl -Wno-float-conversion >= 4.9 >= 3.9
1003 dnl -Wno-float-equal >= 3 >= 3.9
1004 dnl -Wimplicit-fallthrough >= 7 >= 3.9
1005 dnl -Wno-pedantic >= 4.8 >= 3.9
1006 dnl -Wno-sign-compare >= 3 >= 3.9
1007 dnl -Wno-sign-conversion >= 4.3 >= 3.9
1008 dnl -Wno-type-limits >= 4.3 >= 3.9
1009 dnl -Wno-undef >= 3 >= 3.9
1010 dnl -Wno-unsuffixed-float-constants >= 4.5
1011 dnl -Wno-unused-function >= 3 >= 3.9
1012 dnl -Wno-unused-parameter >= 3 >= 3.9
1013 dnl
1014 cat > conftest.c <<\EOF
1015 #if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1016 -Wno-cast-qual
1017 -Wno-conversion
1018 -Wno-float-equal
1019 -Wno-sign-compare
1020 -Wno-undef
1021 -Wno-unused-function
1022 -Wno-unused-parameter
1023 #endif
1024 #if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1025 -Wno-float-conversion
1026 #endif
1027 #if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1028 -Wimplicit-fallthrough
1029 #endif
1030 #if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1031 -Wno-pedantic
1032 #endif
1033 #if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
1034 -Wno-sign-conversion
1035 -Wno-type-limits
1036 #endif
1037 #if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
1038 -Wno-unsuffixed-float-constants
1039 #endif
1040EOF
1041 gl_command="$CC $CFLAGS $CPPFLAGS -E conftest.c > conftest.out"
1042 if AC_TRY_EVAL([gl_command]); then
1043 gl_options=`grep -v '#' conftest.out`
1044 for word in $gl_options; do
1045 GL_CFLAG_GNULIB_WARNINGS="$GL_CFLAG_GNULIB_WARNINGS $word"
1046 done
1047 fi
1048 rm -f conftest.c conftest.out
1049 fi
1050 AC_SUBST([GL_CFLAG_GNULIB_WARNINGS])
1051])
1052
1053dnl gl_CONDITIONAL_HEADER([foo.h])
1054dnl takes a shell variable GL_GENERATE_FOO_H (with value true or false) as input
1055dnl and produces
1056dnl - an AC_SUBSTed variable FOO_H that is either a file name or empty, based
1057dnl on whether GL_GENERATE_FOO_H is true or false,
1058dnl - an Automake conditional GL_GENERATE_FOO_H that evaluates to the value of
1059dnl the shell variable GL_GENERATE_FOO_H.
1060AC_DEFUN([gl_CONDITIONAL_HEADER],
1061[
1062 m4_pushdef([gl_header_name], AS_TR_SH(m4_toupper($1)))
1063 m4_pushdef([gl_generate_var], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1064 m4_pushdef([gl_generate_cond], [GL_GENERATE_]AS_TR_SH(m4_toupper($1)))
1065 case "$gl_generate_var" in
1066 false) gl_header_name='' ;;
1067 true)
1068 dnl It is OK to use a .h file in lib/ from within tests/, but not vice
1069 dnl versa.
1070 if test -z "$gl_header_name"; then
1071 gl_header_name="${gl_source_base_prefix}$1"
1072 fi
1073 ;;
1074 *) echo "*** gl_generate_var is not set correctly" 1>&2; exit 1 ;;
1075 esac
1076 AC_SUBST(gl_header_name)
1077 gl_CONDITIONAL(gl_generate_cond, [$gl_generate_var])
1078 m4_popdef([gl_generate_cond])
1079 m4_popdef([gl_generate_var])
1080 m4_popdef([gl_header_name])
1081])
1082
1083dnl Expands to some code for use in .c programs that, on native Windows, defines
1084dnl the Microsoft deprecated alias function names to the underscore-prefixed
1085dnl actual function names. With this macro, these function names are available
1086dnl without linking with '-loldnames' and without generating warnings.
1087dnl Usage: Use it after all system header files are included.
1088dnl #include <...>
1089dnl #include <...>
1090dnl ]GL_MDA_DEFINES[
1091dnl ...
1092AC_DEFUN([GL_MDA_DEFINES],[
1093AC_REQUIRE([_GL_MDA_DEFINES])
1094[$gl_mda_defines]
1095])
1096AC_DEFUN([_GL_MDA_DEFINES],
1097[gl_mda_defines='
1098#if defined _WIN32 && !defined __CYGWIN__
1099#define access _access
1100#define chdir _chdir
1101#define chmod _chmod
1102#define close _close
1103#define creat _creat
1104#define dup _dup
1105#define dup2 _dup2
1106#define ecvt _ecvt
1107#define execl _execl
1108#define execle _execle
1109#define execlp _execlp
1110#define execv _execv
1111#define execve _execve
1112#define execvp _execvp
1113#define execvpe _execvpe
1114#define fcloseall _fcloseall
1115#define fcvt _fcvt
1116#define fdopen _fdopen
1117#define fileno _fileno
1118#define gcvt _gcvt
1119#define getcwd _getcwd
1120#define getpid _getpid
1121#define getw _getw
1122#define isatty _isatty
1123#define j0 _j0
1124#define j1 _j1
1125#define jn _jn
1126#define lfind _lfind
1127#define lsearch _lsearch
1128#define lseek _lseek
1129#define memccpy _memccpy
1130#define mkdir _mkdir
1131#define mktemp _mktemp
1132#define open _open
1133#define putenv _putenv
1134#define putw _putw
1135#define read _read
1136#define rmdir _rmdir
1137#define strdup _strdup
1138#define swab _swab
1139#define tempnam _tempnam
1140#define tzset _tzset
1141#define umask _umask
1142#define unlink _unlink
1143#define utime _utime
1144#define wcsdup _wcsdup
1145#define write _write
1146#define y0 _y0
1147#define y1 _y1
1148#define yn _yn
1149#endif
1150'
377]) 1151])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 9a4f502..4764622 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,9 +1,9 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY! 1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2002-2013 Free Software Foundation, Inc. 2# Copyright (C) 2002-2023 Free Software Foundation, Inc.
3# 3#
4# This file is free software; you can redistribute it and/or modify 4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or 6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version. 7# (at your option) any later version.
8# 8#
9# This file is distributed in the hope that it will be useful, 9# This file is distributed in the hope that it will be useful,
@@ -12,7 +12,7 @@
12# GNU General Public License for more details. 12# GNU General Public License for more details.
13# 13#
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with this file. If not, see <http://www.gnu.org/licenses/>. 15# along with this file. If not, see <https://www.gnu.org/licenses/>.
16# 16#
17# As a special exception to the GNU General Public License, 17# As a special exception to the GNU General Public License,
18# this file may be distributed as part of a program that 18# this file may be distributed as part of a program that
@@ -37,50 +37,91 @@ AC_DEFUN([gl_EARLY],
37 m4_pattern_allow([^gl_ES$])dnl a valid locale name 37 m4_pattern_allow([^gl_ES$])dnl a valid locale name
38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
40
41 # Pre-early section.
42 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
40 AC_REQUIRE([gl_PROG_AR_RANLIB]) 43 AC_REQUIRE([gl_PROG_AR_RANLIB])
41 AC_REQUIRE([AM_PROG_CC_C_O]) 44
45 # Code from module absolute-header:
42 # Code from module alloca-opt: 46 # Code from module alloca-opt:
43 # Code from module arpa_inet: 47 # Code from module arpa_inet:
48 # Code from module assert-h:
49 # Code from module attribute:
44 # Code from module base64: 50 # Code from module base64:
51 # Code from module basename-lgpl:
45 # Code from module btowc: 52 # Code from module btowc:
46 # Code from module configmake: 53 # Code from module builtin-expect:
47 # Code from module crypto/sha1: 54 # Code from module byteswap:
55 # Code from module c99:
56 # Code from module calloc-gnu:
57 # Code from module calloc-posix:
58 # Code from module cloexec:
59 # Code from module close:
60 # Code from module crypto/af_alg:
61 # Code from module crypto/sha256:
62 # Code from module crypto/sha256-buffer:
48 # Code from module dirname: 63 # Code from module dirname:
49 # Code from module dirname-lgpl: 64 # Code from module dirname-lgpl:
50 # Code from module dosname:
51 # Code from module double-slash-root: 65 # Code from module double-slash-root:
66 # Code from module dup2:
52 # Code from module environ: 67 # Code from module environ:
53 # Code from module errno: 68 # Code from module errno:
54 # Code from module error: 69 # Code from module error:
55 # Code from module exitfail: 70 # Code from module exitfail:
56 # Code from module extensions: 71 # Code from module extensions:
57 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
58 # Code from module extern-inline: 72 # Code from module extern-inline:
73 # Code from module fcntl:
74 # Code from module fcntl-h:
59 # Code from module fd-hook: 75 # Code from module fd-hook:
76 # Code from module fflush:
77 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
78 # Code from module filename:
60 # Code from module float: 79 # Code from module float:
61 # Code from module floorf: 80 # Code from module floorf:
81 # Code from module fopen:
82 # Code from module fopen-gnu:
83 # Code from module fpurge:
84 # Code from module freading:
85 # Code from module free-posix:
86 # Code from module fseek:
87 # Code from module fseeko:
88 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
89 # Code from module fstat:
62 # Code from module fsusage: 90 # Code from module fsusage:
63 # Code from module full-read: 91 # Code from module ftell:
92 # Code from module ftello:
93 AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
94 # Code from module gen-header:
64 # Code from module getaddrinfo: 95 # Code from module getaddrinfo:
96 # Code from module getdelim:
97 # Code from module getdtablesize:
65 # Code from module gethostname: 98 # Code from module gethostname:
99 # Code from module getline:
66 # Code from module getloadavg: 100 # Code from module getloadavg:
67 # Code from module getopt-gnu: 101 # Code from module getopt-gnu:
68 # Code from module getopt-posix: 102 # Code from module getopt-posix:
69 # Code from module gettext: 103 # Code from module getprogname:
70 # Code from module gettext-h: 104 # Code from module gettext-h:
71 # Code from module havelib: 105 # Code from module glibc-internal/dynarray:
106 # Code from module hard-locale:
72 # Code from module hostent: 107 # Code from module hostent:
108 # Code from module ialloc:
73 # Code from module idpriv-droptemp: 109 # Code from module idpriv-droptemp:
110 # Code from module idx:
74 # Code from module include_next: 111 # Code from module include_next:
75 # Code from module inet_ntop: 112 # Code from module inet_ntop:
76 # Code from module intprops: 113 # Code from module intprops:
114 # Code from module inttypes-incomplete:
77 # Code from module langinfo: 115 # Code from module langinfo:
78 # Code from module largefile: 116 # Code from module largefile:
79 AC_REQUIRE([AC_SYS_LARGEFILE]) 117 AC_REQUIRE([AC_SYS_LARGEFILE])
118 # Code from module libc-config:
119 # Code from module limits-h:
80 # Code from module localcharset: 120 # Code from module localcharset:
81 # Code from module locale: 121 # Code from module locale:
82 # Code from module localeconv: 122 # Code from module localeconv:
83 # Code from module lock: 123 # Code from module lock:
124 # Code from module lseek:
84 # Code from module malloc-gnu: 125 # Code from module malloc-gnu:
85 # Code from module malloc-posix: 126 # Code from module malloc-posix:
86 # Code from module malloca: 127 # Code from module malloca:
@@ -89,6 +130,7 @@ AC_DEFUN([gl_EARLY],
89 # Code from module mbsinit: 130 # Code from module mbsinit:
90 # Code from module mbtowc: 131 # Code from module mbtowc:
91 # Code from module memchr: 132 # Code from module memchr:
133 # Code from module minmax:
92 # Code from module mktime: 134 # Code from module mktime:
93 # Code from module mktime-internal: 135 # Code from module mktime-internal:
94 # Code from module mountlist: 136 # Code from module mountlist:
@@ -99,11 +141,15 @@ AC_DEFUN([gl_EARLY],
99 # Code from module netinet_in: 141 # Code from module netinet_in:
100 # Code from module nl_langinfo: 142 # Code from module nl_langinfo:
101 # Code from module nocrash: 143 # Code from module nocrash:
102 # Code from module read: 144 # Code from module open:
145 # Code from module pathmax:
146 # Code from module realloc-gnu:
147 # Code from module realloc-posix:
148 # Code from module reallocarray:
103 # Code from module regex: 149 # Code from module regex:
104 # Code from module safe-read:
105 # Code from module servent: 150 # Code from module servent:
106 # Code from module setenv: 151 # Code from module setenv:
152 # Code from module setlocale-null:
107 # Code from module size_max: 153 # Code from module size_max:
108 # Code from module snippet/_Noreturn: 154 # Code from module snippet/_Noreturn:
109 # Code from module snippet/arg-nonnull: 155 # Code from module snippet/arg-nonnull:
@@ -114,8 +160,12 @@ AC_DEFUN([gl_EARLY],
114 # Code from module sockets: 160 # Code from module sockets:
115 # Code from module socklen: 161 # Code from module socklen:
116 # Code from module ssize_t: 162 # Code from module ssize_t:
163 # Code from module stat:
164 # Code from module stat-time:
165 # Code from module std-gnu11:
117 # Code from module stdalign: 166 # Code from module stdalign:
118 # Code from module stdbool: 167 # Code from module stdbool:
168 # Code from module stdckdint:
119 # Code from module stddef: 169 # Code from module stddef:
120 # Code from module stdint: 170 # Code from module stdint:
121 # Code from module stdio: 171 # Code from module stdio:
@@ -128,11 +178,10 @@ AC_DEFUN([gl_EARLY],
128 # Code from module strerror-override: 178 # Code from module strerror-override:
129 # Code from module string: 179 # Code from module string:
130 # Code from module strings: 180 # Code from module strings:
131 # Code from module strndup:
132 # Code from module strnlen:
133 # Code from module strsep: 181 # Code from module strsep:
134 # Code from module strstr-simple: 182 # Code from module strstr-simple:
135 # Code from module sys_socket: 183 # Code from module sys_socket:
184 # Code from module sys_stat:
136 # Code from module sys_types: 185 # Code from module sys_types:
137 # Code from module sys_uio: 186 # Code from module sys_uio:
138 # Code from module threadlib: 187 # Code from module threadlib:
@@ -141,7 +190,9 @@ AC_DEFUN([gl_EARLY],
141 # Code from module time_r: 190 # Code from module time_r:
142 # Code from module timegm: 191 # Code from module timegm:
143 # Code from module unistd: 192 # Code from module unistd:
193 # Code from module unlocked-io-internal:
144 # Code from module unsetenv: 194 # Code from module unsetenv:
195 # Code from module vararrays:
145 # Code from module vasnprintf: 196 # Code from module vasnprintf:
146 # Code from module vasprintf: 197 # Code from module vasprintf:
147 # Code from module verify: 198 # Code from module verify:
@@ -149,11 +200,14 @@ AC_DEFUN([gl_EARLY],
149 # Code from module wchar: 200 # Code from module wchar:
150 # Code from module wcrtomb: 201 # Code from module wcrtomb:
151 # Code from module wctype-h: 202 # Code from module wctype-h:
203 # Code from module windows-mutex:
204 # Code from module windows-once:
205 # Code from module windows-recmutex:
206 # Code from module windows-rwlock:
152 # Code from module xalloc: 207 # Code from module xalloc:
153 # Code from module xalloc-die: 208 # Code from module xalloc-die:
154 # Code from module xalloc-oversized: 209 # Code from module xalloc-oversized:
155 # Code from module xsize: 210 # Code from module xsize:
156 # Code from module xstrndup:
157]) 211])
158 212
159# This macro should be invoked from ./configure.ac, in the section 213# This macro should be invoked from ./configure.ac, in the section
@@ -170,154 +224,300 @@ AC_DEFUN([gl_INIT],
170 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) 224 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
171 m4_pushdef([gl_LIBSOURCES_LIST], []) 225 m4_pushdef([gl_LIBSOURCES_LIST], [])
172 m4_pushdef([gl_LIBSOURCES_DIR], []) 226 m4_pushdef([gl_LIBSOURCES_DIR], [])
227 m4_pushdef([GL_MACRO_PREFIX], [gl])
228 m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL])
173 gl_COMMON 229 gl_COMMON
174 gl_source_base='gl' 230 gl_source_base='gl'
231 gl_source_base_prefix=
175 gl_FUNC_ALLOCA 232 gl_FUNC_ALLOCA
176 gl_HEADER_ARPA_INET 233 gl_CONDITIONAL_HEADER([alloca.h])
234 AC_PROG_MKDIR_P
235 gl_ARPA_INET_H
236 gl_ARPA_INET_H_REQUIRE_DEFAULTS
237 AC_PROG_MKDIR_P
238 gl_ASSERT_H
239 gl_CONDITIONAL_HEADER([assert.h])
177 AC_PROG_MKDIR_P 240 AC_PROG_MKDIR_P
178 gl_FUNC_BASE64 241 gl_FUNC_BASE64
179 gl_FUNC_BTOWC 242 gl_FUNC_BTOWC
180 if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then 243 gl_CONDITIONAL([GL_COND_OBJ_BTOWC],
181 AC_LIBOBJ([btowc]) 244 [test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1])
245 AM_COND_IF([GL_COND_OBJ_BTOWC], [
182 gl_PREREQ_BTOWC 246 gl_PREREQ_BTOWC
183 fi 247 ])
184 gl_WCHAR_MODULE_INDICATOR([btowc]) 248 gl_WCHAR_MODULE_INDICATOR([btowc])
185 gl_CONFIGMAKE_PREP 249 gl___BUILTIN_EXPECT
186 gl_SHA1 250 gl_BYTESWAP
187 gl_DIRNAME 251 gl_CONDITIONAL_HEADER([byteswap.h])
252 AC_PROG_MKDIR_P
253 gl_FUNC_CALLOC_GNU
254 if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then
255 AC_LIBOBJ([calloc])
256 fi
257 gl_STDLIB_MODULE_INDICATOR([calloc-gnu])
258 gl_FUNC_CALLOC_POSIX
259 if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then
260 AC_LIBOBJ([calloc])
261 fi
262 gl_STDLIB_MODULE_INDICATOR([calloc-posix])
263 gl_MODULE_INDICATOR_FOR_TESTS([cloexec])
264 gl_FUNC_CLOSE
265 gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
266 gl_UNISTD_MODULE_INDICATOR([close])
267 gl_AF_ALG
268 AC_REQUIRE([AC_C_RESTRICT])
269 gl_SHA256
188 gl_MODULE_INDICATOR([dirname]) 270 gl_MODULE_INDICATOR([dirname])
189 gl_DIRNAME_LGPL
190 gl_DOUBLE_SLASH_ROOT 271 gl_DOUBLE_SLASH_ROOT
272 gl_FUNC_DUP2
273 gl_CONDITIONAL([GL_COND_OBJ_DUP2], [test $REPLACE_DUP2 = 1])
274 AM_COND_IF([GL_COND_OBJ_DUP2], [
275 gl_PREREQ_DUP2
276 ])
277 gl_UNISTD_MODULE_INDICATOR([dup2])
191 gl_ENVIRON 278 gl_ENVIRON
192 gl_UNISTD_MODULE_INDICATOR([environ]) 279 gl_UNISTD_MODULE_INDICATOR([environ])
193 gl_HEADER_ERRNO_H 280 gl_HEADER_ERRNO_H
281 gl_CONDITIONAL_HEADER([errno.h])
282 AC_PROG_MKDIR_P
194 gl_ERROR 283 gl_ERROR
195 if test $ac_cv_lib_error_at_line = no; then 284 gl_CONDITIONAL([GL_COND_OBJ_ERROR], [test "$ac_cv_lib_error_at_line" = no])
196 AC_LIBOBJ([error]) 285 AM_COND_IF([GL_COND_OBJ_ERROR], [
197 gl_PREREQ_ERROR 286 gl_PREREQ_ERROR
198 fi 287 ])
199 m4_ifdef([AM_XGETTEXT_OPTION], 288 m4_ifdef([AM_XGETTEXT_OPTION],
200 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) 289 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
201 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) 290 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
202 AC_REQUIRE([gl_EXTERN_INLINE]) 291 AC_REQUIRE([gl_EXTERN_INLINE])
292 gl_FUNC_FCNTL
293 gl_CONDITIONAL([GL_COND_OBJ_FCNTL],
294 [test $HAVE_FCNTL = 0 || test $REPLACE_FCNTL = 1])
295 gl_FCNTL_MODULE_INDICATOR([fcntl])
296 gl_FCNTL_H
297 gl_FCNTL_H_REQUIRE_DEFAULTS
298 AC_PROG_MKDIR_P
299 gl_FUNC_FFLUSH
300 gl_CONDITIONAL([GL_COND_OBJ_FFLUSH], [test $REPLACE_FFLUSH = 1])
301 AM_COND_IF([GL_COND_OBJ_FFLUSH], [
302 gl_PREREQ_FFLUSH
303 ])
304 gl_MODULE_INDICATOR([fflush])
305 gl_STDIO_MODULE_INDICATOR([fflush])
203 gl_FLOAT_H 306 gl_FLOAT_H
204 if test $REPLACE_FLOAT_LDBL = 1; then 307 gl_CONDITIONAL_HEADER([float.h])
205 AC_LIBOBJ([float]) 308 AC_PROG_MKDIR_P
206 fi 309 gl_CONDITIONAL([GL_COND_OBJ_FLOAT], [test $REPLACE_FLOAT_LDBL = 1])
207 if test $REPLACE_ITOLD = 1; then 310 gl_CONDITIONAL([GL_COND_OBJ_ITOLD], [test $REPLACE_ITOLD = 1])
208 AC_LIBOBJ([itold])
209 fi
210 gl_FUNC_FLOORF 311 gl_FUNC_FLOORF
211 if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then 312 gl_CONDITIONAL([GL_COND_OBJ_FLOORF],
212 AC_LIBOBJ([floorf]) 313 [test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1])
213 fi
214 gl_MATH_MODULE_INDICATOR([floorf]) 314 gl_MATH_MODULE_INDICATOR([floorf])
315 gl_FUNC_FOPEN
316 if test $REPLACE_FOPEN = 1; then
317 AC_LIBOBJ([fopen])
318 gl_PREREQ_FOPEN
319 fi
320 gl_STDIO_MODULE_INDICATOR([fopen])
321 gl_FUNC_FOPEN_GNU
322 if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then
323 AC_LIBOBJ([fopen])
324 gl_PREREQ_FOPEN
325 fi
326 gl_MODULE_INDICATOR([fopen-gnu])
327 gl_STDIO_MODULE_INDICATOR([fopen-gnu])
328 gl_FUNC_FPURGE
329 gl_CONDITIONAL([GL_COND_OBJ_FPURGE],
330 [test $HAVE_FPURGE = 0 || test $REPLACE_FPURGE = 1])
331 gl_STDIO_MODULE_INDICATOR([fpurge])
332 gl_FUNC_FREADING
333 gl_FUNC_FREE
334 gl_CONDITIONAL([GL_COND_OBJ_FREE], [test $REPLACE_FREE = 1])
335 AM_COND_IF([GL_COND_OBJ_FREE], [
336 gl_PREREQ_FREE
337 ])
338 gl_STDLIB_MODULE_INDICATOR([free-posix])
339 gl_FUNC_FSEEK
340 gl_CONDITIONAL([GL_COND_OBJ_FSEEK], [test $REPLACE_FSEEK = 1])
341 gl_STDIO_MODULE_INDICATOR([fseek])
342 gl_FUNC_FSEEKO
343 gl_CONDITIONAL([GL_COND_OBJ_FSEEKO],
344 [test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1])
345 AM_COND_IF([GL_COND_OBJ_FSEEKO], [
346 gl_PREREQ_FSEEKO
347 ])
348 gl_STDIO_MODULE_INDICATOR([fseeko])
349 gl_FUNC_FSTAT
350 gl_CONDITIONAL([GL_COND_OBJ_FSTAT], [test $REPLACE_FSTAT = 1])
351 AM_COND_IF([GL_COND_OBJ_FSTAT], [
352 case "$host_os" in
353 mingw*)
354 AC_LIBOBJ([stat-w32])
355 ;;
356 esac
357 gl_PREREQ_FSTAT
358 ])
359 gl_SYS_STAT_MODULE_INDICATOR([fstat])
215 gl_FSUSAGE 360 gl_FSUSAGE
216 if test $gl_cv_fs_space = yes; then 361 gl_CONDITIONAL([GL_COND_OBJ_FSUSAGE], [test $gl_cv_fs_space = yes])
217 AC_LIBOBJ([fsusage]) 362 AM_COND_IF([GL_COND_OBJ_FSUSAGE], [
218 gl_PREREQ_FSUSAGE_EXTRA 363 gl_PREREQ_FSUSAGE_EXTRA
219 fi 364 ])
365 gl_FUNC_FTELL
366 gl_CONDITIONAL([GL_COND_OBJ_FTELL], [test $REPLACE_FTELL = 1])
367 gl_STDIO_MODULE_INDICATOR([ftell])
368 gl_FUNC_FTELLO
369 gl_CONDITIONAL([GL_COND_OBJ_FTELLO],
370 [test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1])
371 AM_COND_IF([GL_COND_OBJ_FTELLO], [
372 gl_PREREQ_FTELLO
373 ])
374 gl_STDIO_MODULE_INDICATOR([ftello])
220 gl_GETADDRINFO 375 gl_GETADDRINFO
221 if test $HAVE_GETADDRINFO = 0; then 376 gl_CONDITIONAL([GL_COND_OBJ_GETADDRINFO],
222 AC_LIBOBJ([getaddrinfo]) 377 [test $HAVE_GETADDRINFO = 0 || test $REPLACE_GETADDRINFO = 1])
223 fi 378 gl_CONDITIONAL([GL_COND_OBJ_GAI_STRERROR],
224 if test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1; then 379 [test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1])
225 AC_LIBOBJ([gai_strerror])
226 fi
227 gl_NETDB_MODULE_INDICATOR([getaddrinfo]) 380 gl_NETDB_MODULE_INDICATOR([getaddrinfo])
381 gl_FUNC_GETDELIM
382 gl_CONDITIONAL([GL_COND_OBJ_GETDELIM],
383 [test $HAVE_GETDELIM = 0 || test $REPLACE_GETDELIM = 1])
384 AM_COND_IF([GL_COND_OBJ_GETDELIM], [
385 gl_PREREQ_GETDELIM
386 ])
387 gl_STDIO_MODULE_INDICATOR([getdelim])
388 gl_FUNC_GETDTABLESIZE
389 gl_CONDITIONAL([GL_COND_OBJ_GETDTABLESIZE],
390 [test $HAVE_GETDTABLESIZE = 0 || test $REPLACE_GETDTABLESIZE = 1])
391 AM_COND_IF([GL_COND_OBJ_GETDTABLESIZE], [
392 gl_PREREQ_GETDTABLESIZE
393 ])
394 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
228 gl_FUNC_GETHOSTNAME 395 gl_FUNC_GETHOSTNAME
229 if test $HAVE_GETHOSTNAME = 0; then 396 gl_CONDITIONAL([GL_COND_OBJ_GETHOSTNAME], [test $HAVE_GETHOSTNAME = 0])
230 AC_LIBOBJ([gethostname]) 397 AM_COND_IF([GL_COND_OBJ_GETHOSTNAME], [
231 gl_PREREQ_GETHOSTNAME 398 gl_PREREQ_GETHOSTNAME
232 fi 399 ])
233 gl_UNISTD_MODULE_INDICATOR([gethostname]) 400 gl_UNISTD_MODULE_INDICATOR([gethostname])
401 gl_FUNC_GETLINE
402 gl_CONDITIONAL([GL_COND_OBJ_GETLINE], [test $REPLACE_GETLINE = 1])
403 AM_COND_IF([GL_COND_OBJ_GETLINE], [
404 gl_PREREQ_GETLINE
405 ])
406 gl_STDIO_MODULE_INDICATOR([getline])
407 AC_REQUIRE([AC_CANONICAL_HOST])
234 gl_GETLOADAVG 408 gl_GETLOADAVG
235 if test $HAVE_GETLOADAVG = 0; then 409 gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0])
236 AC_LIBOBJ([getloadavg]) 410 AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
237 gl_PREREQ_GETLOADAVG 411 gl_PREREQ_GETLOADAVG
238 fi 412 ])
239 gl_STDLIB_MODULE_INDICATOR([getloadavg]) 413 gl_STDLIB_MODULE_INDICATOR([getloadavg])
240 gl_FUNC_GETOPT_GNU 414 gl_FUNC_GETOPT_GNU
241 if test $REPLACE_GETOPT = 1; then 415 dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the gl_getopt_required
242 AC_LIBOBJ([getopt]) 416 dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they are
243 AC_LIBOBJ([getopt1]) 417 dnl done in the getopt-posix module.
244 gl_PREREQ_GETOPT
245 dnl Arrange for unistd.h to include getopt.h.
246 GNULIB_GL_UNISTD_H_GETOPT=1
247 fi
248 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
249 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
250 gl_FUNC_GETOPT_POSIX 418 gl_FUNC_GETOPT_POSIX
251 if test $REPLACE_GETOPT = 1; then 419 gl_CONDITIONAL_HEADER([getopt.h])
252 AC_LIBOBJ([getopt]) 420 gl_CONDITIONAL_HEADER([getopt-cdefs.h])
253 AC_LIBOBJ([getopt1]) 421 AC_PROG_MKDIR_P
254 gl_PREREQ_GETOPT 422 gl_CONDITIONAL([GL_COND_OBJ_GETOPT], [test $REPLACE_GETOPT = 1])
255 dnl Arrange for unistd.h to include getopt.h. 423 AM_COND_IF([GL_COND_OBJ_GETOPT], [
256 GNULIB_GL_UNISTD_H_GETOPT=1 424 dnl Define the substituted variable GNULIB_UNISTD_H_GETOPT to 1.
257 fi 425 gl_UNISTD_H_REQUIRE_DEFAULTS
258 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT]) 426 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT], [1])
259 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. 427 ])
260 AM_GNU_GETTEXT_VERSION([0.18.1]) 428 gl_UNISTD_MODULE_INDICATOR([getopt-posix])
429 gl_FUNC_GETPROGNAME
261 AC_SUBST([LIBINTL]) 430 AC_SUBST([LIBINTL])
262 AC_SUBST([LTLIBINTL]) 431 AC_SUBST([LTLIBINTL])
432 AC_PROG_MKDIR_P
433 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
434 LIB_HARD_LOCALE="$LIB_SETLOCALE_NULL"
435 AC_SUBST([LIB_HARD_LOCALE])
263 gl_HOSTENT 436 gl_HOSTENT
264 gl_IDPRIV 437 gl_IDPRIV
265 gl_FUNC_INET_NTOP 438 gl_FUNC_INET_NTOP
266 if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then 439 gl_CONDITIONAL([GL_COND_OBJ_INET_NTOP],
267 AC_LIBOBJ([inet_ntop]) 440 [test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1])
441 AM_COND_IF([GL_COND_OBJ_INET_NTOP], [
268 gl_PREREQ_INET_NTOP 442 gl_PREREQ_INET_NTOP
269 fi 443 ])
270 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) 444 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
445 gl_INTTYPES_INCOMPLETE
446 gl_INTTYPES_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P
271 gl_LANGINFO_H 448 gl_LANGINFO_H
449 gl_LANGINFO_H_REQUIRE_DEFAULTS
450 AC_PROG_MKDIR_P
272 AC_REQUIRE([gl_LARGEFILE]) 451 AC_REQUIRE([gl_LARGEFILE])
452 gl___INLINE
453 gl_LIMITS_H
454 gl_CONDITIONAL_HEADER([limits.h])
455 AC_PROG_MKDIR_P
273 gl_LOCALCHARSET 456 gl_LOCALCHARSET
274 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\"" 457 dnl For backward compatibility. Some packages still use this.
458 LOCALCHARSET_TESTS_ENVIRONMENT=
275 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) 459 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
276 gl_LOCALE_H 460 gl_LOCALE_H
461 gl_LOCALE_H_REQUIRE_DEFAULTS
462 AC_PROG_MKDIR_P
277 gl_FUNC_LOCALECONV 463 gl_FUNC_LOCALECONV
278 if test $REPLACE_LOCALECONV = 1; then 464 gl_CONDITIONAL([GL_COND_OBJ_LOCALECONV], [test $REPLACE_LOCALECONV = 1])
279 AC_LIBOBJ([localeconv]) 465 AM_COND_IF([GL_COND_OBJ_LOCALECONV], [
280 gl_PREREQ_LOCALECONV 466 gl_PREREQ_LOCALECONV
281 fi 467 ])
282 gl_LOCALE_MODULE_INDICATOR([localeconv]) 468 gl_LOCALE_MODULE_INDICATOR([localeconv])
283 gl_LOCK 469 gl_LOCK
284 gl_MODULE_INDICATOR([lock]) 470 gl_MODULE_INDICATOR([lock])
471 gl_FUNC_LSEEK
472 gl_CONDITIONAL([GL_COND_OBJ_LSEEK], [test $REPLACE_LSEEK = 1])
473 gl_UNISTD_MODULE_INDICATOR([lseek])
285 gl_FUNC_MALLOC_GNU 474 gl_FUNC_MALLOC_GNU
286 if test $REPLACE_MALLOC = 1; then 475 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
287 AC_LIBOBJ([malloc]) 476 AC_LIBOBJ([malloc])
288 fi 477 fi
289 gl_MODULE_INDICATOR([malloc-gnu]) 478 gl_STDLIB_MODULE_INDICATOR([malloc-gnu])
290 gl_FUNC_MALLOC_POSIX 479 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
291 if test $REPLACE_MALLOC = 1; then 480 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
292 AC_LIBOBJ([malloc]) 481 AC_LIBOBJ([malloc])
293 fi 482 fi
294 gl_STDLIB_MODULE_INDICATOR([malloc-posix]) 483 gl_STDLIB_MODULE_INDICATOR([malloc-posix])
295 gl_MALLOCA 484 gl_MALLOCA
296 gl_MATH_H 485 gl_MATH_H
486 gl_MATH_H_REQUIRE_DEFAULTS
487 AC_PROG_MKDIR_P
297 gl_FUNC_MBRTOWC 488 gl_FUNC_MBRTOWC
298 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then 489 gl_CONDITIONAL([GL_COND_OBJ_MBRTOWC],
299 AC_LIBOBJ([mbrtowc]) 490 [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1])
491 AM_COND_IF([GL_COND_OBJ_MBRTOWC], [
492 if test $REPLACE_MBSTATE_T = 1; then
493 AC_LIBOBJ([lc-charset-dispatch])
494 AC_LIBOBJ([mbtowc-lock])
495 gl_PREREQ_MBTOWC_LOCK
496 fi
300 gl_PREREQ_MBRTOWC 497 gl_PREREQ_MBRTOWC
301 fi 498 ])
302 gl_WCHAR_MODULE_INDICATOR([mbrtowc]) 499 gl_WCHAR_MODULE_INDICATOR([mbrtowc])
303 gl_FUNC_MBSINIT 500 gl_FUNC_MBSINIT
304 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then 501 gl_CONDITIONAL([GL_COND_OBJ_MBSINIT],
305 AC_LIBOBJ([mbsinit]) 502 [test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1])
503 AM_COND_IF([GL_COND_OBJ_MBSINIT], [
306 gl_PREREQ_MBSINIT 504 gl_PREREQ_MBSINIT
307 fi 505 ])
308 gl_WCHAR_MODULE_INDICATOR([mbsinit]) 506 gl_WCHAR_MODULE_INDICATOR([mbsinit])
309 gl_FUNC_MBTOWC 507 gl_FUNC_MBTOWC
310 if test $REPLACE_MBTOWC = 1; then 508 gl_CONDITIONAL([GL_COND_OBJ_MBTOWC],
311 AC_LIBOBJ([mbtowc]) 509 [test $HAVE_MBTOWC = 0 || test $REPLACE_MBTOWC = 1])
510 AM_COND_IF([GL_COND_OBJ_MBTOWC], [
312 gl_PREREQ_MBTOWC 511 gl_PREREQ_MBTOWC
313 fi 512 ])
314 gl_STDLIB_MODULE_INDICATOR([mbtowc]) 513 gl_STDLIB_MODULE_INDICATOR([mbtowc])
315 gl_FUNC_MEMCHR 514 gl_FUNC_MEMCHR
316 if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then 515 gl_CONDITIONAL([GL_COND_OBJ_MEMCHR], [test $REPLACE_MEMCHR = 1])
317 AC_LIBOBJ([memchr]) 516 AM_COND_IF([GL_COND_OBJ_MEMCHR], [
318 gl_PREREQ_MEMCHR 517 gl_PREREQ_MEMCHR
319 fi 518 ])
320 gl_STRING_MODULE_INDICATOR([memchr]) 519 gl_STRING_MODULE_INDICATOR([memchr])
520 gl_MINMAX
321 gl_FUNC_MKTIME 521 gl_FUNC_MKTIME
322 if test $REPLACE_MKTIME = 1; then 522 if test $REPLACE_MKTIME = 1; then
323 AC_LIBOBJ([mktime]) 523 AC_LIBOBJ([mktime])
@@ -325,73 +525,162 @@ AC_DEFUN([gl_INIT],
325 fi 525 fi
326 gl_TIME_MODULE_INDICATOR([mktime]) 526 gl_TIME_MODULE_INDICATOR([mktime])
327 gl_FUNC_MKTIME_INTERNAL 527 gl_FUNC_MKTIME_INTERNAL
328 if test $REPLACE_MKTIME = 1; then 528 if test $WANT_MKTIME_INTERNAL = 1; then
329 AC_LIBOBJ([mktime]) 529 AC_LIBOBJ([mktime])
330 gl_PREREQ_MKTIME 530 gl_PREREQ_MKTIME
331 fi 531 fi
332 gl_MOUNTLIST 532 gl_MOUNTLIST
333 if test $gl_cv_list_mounted_fs = yes; then 533 gl_CONDITIONAL([GL_COND_OBJ_MOUNTLIST], [test $gl_cv_list_mounted_fs = yes])
334 AC_LIBOBJ([mountlist]) 534 AM_COND_IF([GL_COND_OBJ_MOUNTLIST], [
335 gl_PREREQ_MOUNTLIST_EXTRA 535 gl_PREREQ_MOUNTLIST_EXTRA
336 fi 536 ])
337 gl_MSVC_INVAL 537 AC_REQUIRE([gl_MSVC_INVAL])
338 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 538 gl_CONDITIONAL([GL_COND_OBJ_MSVC_INVAL],
339 AC_LIBOBJ([msvc-inval]) 539 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
340 fi 540 AC_REQUIRE([gl_MSVC_NOTHROW])
341 gl_MSVC_NOTHROW 541 gl_CONDITIONAL([GL_COND_OBJ_MSVC_NOTHROW],
342 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 542 [test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1])
343 AC_LIBOBJ([msvc-nothrow]) 543 gl_MODULE_INDICATOR([msvc-nothrow])
344 fi
345 gl_MULTIARCH 544 gl_MULTIARCH
346 gl_HEADER_NETDB 545 gl_NETDB_H
546 gl_NETDB_H_REQUIRE_DEFAULTS
547 AC_PROG_MKDIR_P
347 gl_HEADER_NETINET_IN 548 gl_HEADER_NETINET_IN
549 gl_CONDITIONAL_HEADER([netinet/in.h])
348 AC_PROG_MKDIR_P 550 AC_PROG_MKDIR_P
349 gl_FUNC_NL_LANGINFO 551 gl_FUNC_NL_LANGINFO
350 if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then 552 gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO],
351 AC_LIBOBJ([nl_langinfo]) 553 [test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1])
554 gl_CONDITIONAL([GL_COND_OBJ_NL_LANGINFO_LOCK],
555 [test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0])
556 if test $REPLACE_NL_LANGINFO = 1 && test $NL_LANGINFO_MTSAFE = 0; then
557 gl_PREREQ_NL_LANGINFO_LOCK
352 fi 558 fi
353 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) 559 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
354 gl_FUNC_READ 560 gl_FUNC_OPEN
355 if test $REPLACE_READ = 1; then 561 gl_CONDITIONAL([GL_COND_OBJ_OPEN], [test $REPLACE_OPEN = 1])
356 AC_LIBOBJ([read]) 562 AM_COND_IF([GL_COND_OBJ_OPEN], [
357 gl_PREREQ_READ 563 gl_PREREQ_OPEN
564 ])
565 gl_FCNTL_MODULE_INDICATOR([open])
566 gl_PATHMAX
567 gl_FUNC_REALLOC_GNU
568 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
569 AC_LIBOBJ([realloc])
570 fi
571 gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
572 gl_FUNC_REALLOC_POSIX
573 if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then
574 AC_LIBOBJ([realloc])
358 fi 575 fi
359 gl_UNISTD_MODULE_INDICATOR([read]) 576 gl_STDLIB_MODULE_INDICATOR([realloc-posix])
577 gl_FUNC_REALLOCARRAY
578 gl_CONDITIONAL([GL_COND_OBJ_REALLOCARRAY],
579 [test $HAVE_REALLOCARRAY = 0 || test $REPLACE_REALLOCARRAY = 1])
580 AM_COND_IF([GL_COND_OBJ_REALLOCARRAY], [
581 gl_PREREQ_REALLOCARRAY
582 ])
583 gl_MODULE_INDICATOR([reallocarray])
584 gl_STDLIB_MODULE_INDICATOR([reallocarray])
360 gl_REGEX 585 gl_REGEX
361 if test $ac_use_included_regex = yes; then 586 gl_CONDITIONAL([GL_COND_OBJ_REGEX], [test $ac_use_included_regex = yes])
362 AC_LIBOBJ([regex]) 587 AM_COND_IF([GL_COND_OBJ_REGEX], [
363 gl_PREREQ_REGEX 588 gl_PREREQ_REGEX
364 fi 589 ])
365 gl_PREREQ_SAFE_READ
366 gl_SERVENT 590 gl_SERVENT
367 gl_FUNC_SETENV 591 gl_FUNC_SETENV
368 if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then 592 gl_CONDITIONAL([GL_COND_OBJ_SETENV],
369 AC_LIBOBJ([setenv]) 593 [test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1])
370 fi
371 gl_STDLIB_MODULE_INDICATOR([setenv]) 594 gl_STDLIB_MODULE_INDICATOR([setenv])
595 gl_FUNC_SETLOCALE_NULL
596 gl_CONDITIONAL([GL_COND_OBJ_SETLOCALE_LOCK],
597 [test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0])
598 AM_COND_IF([GL_COND_OBJ_SETLOCALE_LOCK], [
599 gl_PREREQ_SETLOCALE_LOCK
600 ])
601 gl_LOCALE_MODULE_INDICATOR([setlocale_null])
372 gl_SIZE_MAX 602 gl_SIZE_MAX
373 gl_FUNC_SNPRINTF 603 gl_FUNC_SNPRINTF
374 gl_STDIO_MODULE_INDICATOR([snprintf]) 604 gl_STDIO_MODULE_INDICATOR([snprintf])
375 gl_MODULE_INDICATOR([snprintf]) 605 gl_MODULE_INDICATOR([snprintf])
376 gl_SOCKETLIB 606 AC_REQUIRE([gl_SOCKETLIB])
377 gl_SOCKETS 607 AC_REQUIRE([gl_SOCKETS])
378 gl_TYPE_SOCKLEN_T 608 gl_TYPE_SOCKLEN_T
379 gt_TYPE_SSIZE_T 609 gt_TYPE_SSIZE_T
610 gl_FUNC_STAT
611 gl_CONDITIONAL([GL_COND_OBJ_STAT], [test $REPLACE_STAT = 1])
612 AM_COND_IF([GL_COND_OBJ_STAT], [
613 case "$host_os" in
614 mingw*)
615 AC_LIBOBJ([stat-w32])
616 ;;
617 esac
618 gl_PREREQ_STAT
619 ])
620 gl_SYS_STAT_MODULE_INDICATOR([stat])
621 gl_STAT_TIME
622 gl_STAT_BIRTHTIME
380 gl_STDALIGN_H 623 gl_STDALIGN_H
381 AM_STDBOOL_H 624 gl_CONDITIONAL_HEADER([stdalign.h])
625 AC_PROG_MKDIR_P
626 gl_C_BOOL
627 AC_CHECK_HEADERS_ONCE([stdckdint.h])
628 if test $ac_cv_header_stdckdint_h = yes; then
629 GL_GENERATE_STDCKDINT_H=false
630 else
631 GL_GENERATE_STDCKDINT_H=true
632 fi
633 gl_CONDITIONAL_HEADER([stdckdint.h])
634 AC_PROG_MKDIR_P
382 gl_STDDEF_H 635 gl_STDDEF_H
636 gl_STDDEF_H_REQUIRE_DEFAULTS
637 gl_CONDITIONAL_HEADER([stddef.h])
638 AC_PROG_MKDIR_P
383 gl_STDINT_H 639 gl_STDINT_H
640 gl_CONDITIONAL_HEADER([stdint.h])
641 dnl Because of gl_REPLACE_LIMITS_H:
642 gl_CONDITIONAL_HEADER([limits.h])
643 AC_PROG_MKDIR_P
384 gl_STDIO_H 644 gl_STDIO_H
645 gl_STDIO_H_REQUIRE_DEFAULTS
646 AC_PROG_MKDIR_P
647 gl_CONDITIONAL([GL_COND_OBJ_STDIO_READ], [test $REPLACE_STDIO_READ_FUNCS = 1])
648 gl_CONDITIONAL([GL_COND_OBJ_STDIO_WRITE], [test $REPLACE_STDIO_WRITE_FUNCS = 1])
649 dnl No need to create extra modules for these functions. Everyone who uses
650 dnl <stdio.h> likely needs them.
651 gl_STDIO_MODULE_INDICATOR([fscanf])
652 gl_MODULE_INDICATOR([fscanf])
653 gl_STDIO_MODULE_INDICATOR([scanf])
654 gl_MODULE_INDICATOR([scanf])
655 gl_STDIO_MODULE_INDICATOR([fgetc])
656 gl_STDIO_MODULE_INDICATOR([getc])
657 gl_STDIO_MODULE_INDICATOR([getchar])
658 gl_STDIO_MODULE_INDICATOR([fgets])
659 gl_STDIO_MODULE_INDICATOR([fread])
660 dnl No need to create extra modules for these functions. Everyone who uses
661 dnl <stdio.h> likely needs them.
662 gl_STDIO_MODULE_INDICATOR([fprintf])
663 gl_STDIO_MODULE_INDICATOR([printf])
664 gl_STDIO_MODULE_INDICATOR([vfprintf])
665 gl_STDIO_MODULE_INDICATOR([vprintf])
666 gl_STDIO_MODULE_INDICATOR([fputc])
667 gl_STDIO_MODULE_INDICATOR([putc])
668 gl_STDIO_MODULE_INDICATOR([putchar])
669 gl_STDIO_MODULE_INDICATOR([fputs])
670 gl_STDIO_MODULE_INDICATOR([puts])
671 gl_STDIO_MODULE_INDICATOR([fwrite])
385 gl_STDLIB_H 672 gl_STDLIB_H
673 gl_STDLIB_H_REQUIRE_DEFAULTS
674 AC_PROG_MKDIR_P
386 gl_STRCASE 675 gl_STRCASE
387 if test $HAVE_STRCASECMP = 0; then 676 gl_CONDITIONAL([GL_COND_OBJ_STRCASECMP], [test $HAVE_STRCASECMP = 0])
388 AC_LIBOBJ([strcasecmp]) 677 AM_COND_IF([GL_COND_OBJ_STRCASECMP], [
389 gl_PREREQ_STRCASECMP 678 gl_PREREQ_STRCASECMP
390 fi 679 ])
391 if test $HAVE_STRNCASECMP = 0; then 680 gl_CONDITIONAL([GL_COND_OBJ_STRNCASECMP], [test $HAVE_STRNCASECMP = 0])
392 AC_LIBOBJ([strncasecmp]) 681 AM_COND_IF([GL_COND_OBJ_STRNCASECMP], [
393 gl_PREREQ_STRNCASECMP 682 gl_PREREQ_STRNCASECMP
394 fi 683 ])
395 gl_FUNC_STRCASESTR 684 gl_FUNC_STRCASESTR
396 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then 685 if test $HAVE_STRCASESTR = 0 || test $REPLACE_STRCASESTR = 1; then
397 AC_LIBOBJ([strcasestr]) 686 AC_LIBOBJ([strcasestr])
@@ -404,68 +693,76 @@ AC_DEFUN([gl_INIT],
404 fi 693 fi
405 gl_STRING_MODULE_INDICATOR([strcasestr]) 694 gl_STRING_MODULE_INDICATOR([strcasestr])
406 gl_FUNC_STRERROR 695 gl_FUNC_STRERROR
407 if test $REPLACE_STRERROR = 1; then 696 gl_CONDITIONAL([GL_COND_OBJ_STRERROR], [test $REPLACE_STRERROR = 1])
408 AC_LIBOBJ([strerror])
409 fi
410 gl_MODULE_INDICATOR([strerror]) 697 gl_MODULE_INDICATOR([strerror])
411 gl_STRING_MODULE_INDICATOR([strerror]) 698 gl_STRING_MODULE_INDICATOR([strerror])
412 AC_REQUIRE([gl_HEADER_ERRNO_H]) 699 AC_REQUIRE([gl_HEADER_ERRNO_H])
413 AC_REQUIRE([gl_FUNC_STRERROR_0]) 700 AC_REQUIRE([gl_FUNC_STRERROR_0])
414 if test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1; then 701 gl_CONDITIONAL([GL_COND_OBJ_STRERROR_OVERRIDE],
415 AC_LIBOBJ([strerror-override]) 702 [test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1])
703 AM_COND_IF([GL_COND_OBJ_STRERROR_OVERRIDE], [
416 gl_PREREQ_SYS_H_WINSOCK2 704 gl_PREREQ_SYS_H_WINSOCK2
417 fi 705 ])
418 gl_HEADER_STRING_H 706 gl_STRING_H
419 gl_HEADER_STRINGS_H 707 gl_STRING_H_REQUIRE_DEFAULTS
420 gl_FUNC_STRNDUP 708 AC_PROG_MKDIR_P
421 if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then 709 gl_STRINGS_H
422 AC_LIBOBJ([strndup]) 710 gl_STRINGS_H_REQUIRE_DEFAULTS
423 fi 711 AC_PROG_MKDIR_P
424 gl_STRING_MODULE_INDICATOR([strndup])
425 gl_FUNC_STRNLEN
426 if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
427 AC_LIBOBJ([strnlen])
428 gl_PREREQ_STRNLEN
429 fi
430 gl_STRING_MODULE_INDICATOR([strnlen])
431 gl_FUNC_STRSEP 712 gl_FUNC_STRSEP
432 if test $HAVE_STRSEP = 0; then 713 gl_CONDITIONAL([GL_COND_OBJ_STRSEP], [test $HAVE_STRSEP = 0])
433 AC_LIBOBJ([strsep]) 714 AM_COND_IF([GL_COND_OBJ_STRSEP], [
434 gl_PREREQ_STRSEP 715 gl_PREREQ_STRSEP
435 fi 716 ])
436 gl_STRING_MODULE_INDICATOR([strsep]) 717 gl_STRING_MODULE_INDICATOR([strsep])
437 gl_FUNC_STRSTR_SIMPLE 718 gl_FUNC_STRSTR_SIMPLE
438 if test $REPLACE_STRSTR = 1; then 719 if test $REPLACE_STRSTR = 1; then
439 AC_LIBOBJ([strstr]) 720 AC_LIBOBJ([strstr])
440 fi 721 fi
441 gl_STRING_MODULE_INDICATOR([strstr]) 722 gl_STRING_MODULE_INDICATOR([strstr])
442 gl_HEADER_SYS_SOCKET 723 gl_SYS_SOCKET_H
724 gl_SYS_SOCKET_H_REQUIRE_DEFAULTS
725 AC_PROG_MKDIR_P
726 gl_SYS_STAT_H
727 gl_SYS_STAT_H_REQUIRE_DEFAULTS
443 AC_PROG_MKDIR_P 728 AC_PROG_MKDIR_P
444 gl_SYS_TYPES_H 729 gl_SYS_TYPES_H
730 gl_SYS_TYPES_H_REQUIRE_DEFAULTS
731 AC_PROG_MKDIR_P
732 gl_SYS_UIO_H
733 gl_SYS_UIO_H_REQUIRE_DEFAULTS
445 AC_PROG_MKDIR_P 734 AC_PROG_MKDIR_P
446 gl_HEADER_SYS_UIO 735 AC_REQUIRE([gl_THREADLIB])
736 gl_TIME_H
737 gl_TIME_H_REQUIRE_DEFAULTS
447 AC_PROG_MKDIR_P 738 AC_PROG_MKDIR_P
448 gl_THREADLIB
449 gl_HEADER_TIME_H
450 gl_TIME_R 739 gl_TIME_R
451 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then 740 gl_CONDITIONAL([GL_COND_OBJ_TIME_R],
452 AC_LIBOBJ([time_r]) 741 [test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1])
742 AM_COND_IF([GL_COND_OBJ_TIME_R], [
453 gl_PREREQ_TIME_R 743 gl_PREREQ_TIME_R
454 fi 744 ])
455 gl_TIME_MODULE_INDICATOR([time_r]) 745 gl_TIME_MODULE_INDICATOR([time_r])
456 gl_FUNC_TIMEGM 746 gl_FUNC_TIMEGM
457 if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then 747 gl_CONDITIONAL([GL_COND_OBJ_TIMEGM],
458 AC_LIBOBJ([timegm]) 748 [test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1])
749 AM_COND_IF([GL_COND_OBJ_TIMEGM], [
459 gl_PREREQ_TIMEGM 750 gl_PREREQ_TIMEGM
460 fi 751 ])
461 gl_TIME_MODULE_INDICATOR([timegm]) 752 gl_TIME_MODULE_INDICATOR([timegm])
462 gl_UNISTD_H 753 gl_UNISTD_H
754 gl_UNISTD_H_REQUIRE_DEFAULTS
755 AC_PROG_MKDIR_P
756 gl_FUNC_GLIBC_UNLOCKED_IO
463 gl_FUNC_UNSETENV 757 gl_FUNC_UNSETENV
464 if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then 758 gl_CONDITIONAL([GL_COND_OBJ_UNSETENV],
465 AC_LIBOBJ([unsetenv]) 759 [test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1])
760 AM_COND_IF([GL_COND_OBJ_UNSETENV], [
466 gl_PREREQ_UNSETENV 761 gl_PREREQ_UNSETENV
467 fi 762 ])
468 gl_STDLIB_MODULE_INDICATOR([unsetenv]) 763 gl_STDLIB_MODULE_INDICATOR([unsetenv])
764 AC_C_VARARRAYS
765 AC_REQUIRE([AC_C_RESTRICT])
469 gl_FUNC_VASNPRINTF 766 gl_FUNC_VASNPRINTF
470 gl_FUNC_VASPRINTF 767 gl_FUNC_VASPRINTF
471 gl_STDIO_MODULE_INDICATOR([vasprintf]) 768 gl_STDIO_MODULE_INDICATOR([vasprintf])
@@ -475,16 +772,34 @@ AC_DEFUN([gl_INIT],
475 gl_FUNC_VSNPRINTF 772 gl_FUNC_VSNPRINTF
476 gl_STDIO_MODULE_INDICATOR([vsnprintf]) 773 gl_STDIO_MODULE_INDICATOR([vsnprintf])
477 gl_WCHAR_H 774 gl_WCHAR_H
775 gl_WCHAR_H_REQUIRE_DEFAULTS
776 AC_PROG_MKDIR_P
478 gl_FUNC_WCRTOMB 777 gl_FUNC_WCRTOMB
479 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then 778 gl_CONDITIONAL([GL_COND_OBJ_WCRTOMB],
480 AC_LIBOBJ([wcrtomb]) 779 [test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1])
780 AM_COND_IF([GL_COND_OBJ_WCRTOMB], [
481 gl_PREREQ_WCRTOMB 781 gl_PREREQ_WCRTOMB
482 fi 782 ])
483 gl_WCHAR_MODULE_INDICATOR([wcrtomb]) 783 gl_WCHAR_MODULE_INDICATOR([wcrtomb])
484 gl_WCTYPE_H 784 gl_WCTYPE_H
785 gl_WCTYPE_H_REQUIRE_DEFAULTS
786 AC_PROG_MKDIR_P
787 AC_REQUIRE([AC_CANONICAL_HOST])
788 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_MUTEX],
789 [case "$host_os" in mingw*) true;; *) false;; esac])
790 AC_REQUIRE([AC_CANONICAL_HOST])
791 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_ONCE],
792 [case "$host_os" in mingw*) true;; *) false;; esac])
793 AC_REQUIRE([AC_CANONICAL_HOST])
794 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RECMUTEX],
795 [case "$host_os" in mingw*) true;; *) false;; esac])
796 AC_REQUIRE([AC_CANONICAL_HOST])
797 gl_CONDITIONAL([GL_COND_OBJ_WINDOWS_RWLOCK],
798 [case "$host_os" in mingw*) true;; *) false;; esac])
485 gl_XALLOC 799 gl_XALLOC
800 gl_MODULE_INDICATOR([xalloc])
801 gl_MODULE_INDICATOR([xalloc-die])
486 gl_XSIZE 802 gl_XSIZE
487 gl_XSTRNDUP
488 # End of code from modules 803 # End of code from modules
489 m4_ifval(gl_LIBSOURCES_LIST, [ 804 m4_ifval(gl_LIBSOURCES_LIST, [
490 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || 805 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@@ -497,6 +812,8 @@ AC_DEFUN([gl_INIT],
497 m4_if(m4_sysval, [0], [], 812 m4_if(m4_sysval, [0], [],
498 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) 813 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
499 ]) 814 ])
815 m4_popdef([GL_MODULE_INDICATOR_PREFIX])
816 m4_popdef([GL_MACRO_PREFIX])
500 m4_popdef([gl_LIBSOURCES_DIR]) 817 m4_popdef([gl_LIBSOURCES_DIR])
501 m4_popdef([gl_LIBSOURCES_LIST]) 818 m4_popdef([gl_LIBSOURCES_LIST])
502 m4_popdef([AC_LIBSOURCES]) 819 m4_popdef([AC_LIBSOURCES])
@@ -505,16 +822,28 @@ AC_DEFUN([gl_INIT],
505 AC_CONFIG_COMMANDS_PRE([ 822 AC_CONFIG_COMMANDS_PRE([
506 gl_libobjs= 823 gl_libobjs=
507 gl_ltlibobjs= 824 gl_ltlibobjs=
825 gl_libobjdeps=
508 if test -n "$gl_LIBOBJS"; then 826 if test -n "$gl_LIBOBJS"; then
509 # Remove the extension. 827 # Remove the extension.
828changequote(,)dnl
510 sed_drop_objext='s/\.o$//;s/\.obj$//' 829 sed_drop_objext='s/\.o$//;s/\.obj$//'
830 sed_dirname1='s,//*,/,g'
831 sed_dirname2='s,\(.\)/$,\1,'
832 sed_dirname3='s,^[^/]*$,.,'
833 sed_dirname4='s,\(.\)/[^/]*$,\1,'
834 sed_basename1='s,.*/,,'
835changequote([, ])dnl
511 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 836 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
512 gl_libobjs="$gl_libobjs $i.$ac_objext" 837 gl_libobjs="$gl_libobjs $i.$ac_objext"
513 gl_ltlibobjs="$gl_ltlibobjs $i.lo" 838 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
839 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
840 i_base=`echo "$i" | sed -e "$sed_basename1"`
841 gl_libobjdeps="$gl_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
514 done 842 done
515 fi 843 fi
516 AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) 844 AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
517 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) 845 AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
846 AC_SUBST([gl_LIBOBJDEPS], [$gl_libobjdeps])
518 ]) 847 ])
519 gltests_libdeps= 848 gltests_libdeps=
520 gltests_ltlibdeps= 849 gltests_ltlibdeps=
@@ -523,8 +852,11 @@ AC_DEFUN([gl_INIT],
523 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) 852 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
524 m4_pushdef([gltests_LIBSOURCES_LIST], []) 853 m4_pushdef([gltests_LIBSOURCES_LIST], [])
525 m4_pushdef([gltests_LIBSOURCES_DIR], []) 854 m4_pushdef([gltests_LIBSOURCES_DIR], [])
855 m4_pushdef([GL_MACRO_PREFIX], [gltests])
856 m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [GL])
526 gl_COMMON 857 gl_COMMON
527 gl_source_base='tests' 858 gl_source_base='tests'
859 gl_source_base_prefix=
528changequote(,)dnl 860changequote(,)dnl
529 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 861 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
530changequote([, ])dnl 862changequote([, ])dnl
@@ -543,6 +875,8 @@ changequote([, ])dnl
543 m4_if(m4_sysval, [0], [], 875 m4_if(m4_sysval, [0], [],
544 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) 876 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
545 ]) 877 ])
878 m4_popdef([GL_MODULE_INDICATOR_PREFIX])
879 m4_popdef([GL_MACRO_PREFIX])
546 m4_popdef([gltests_LIBSOURCES_DIR]) 880 m4_popdef([gltests_LIBSOURCES_DIR])
547 m4_popdef([gltests_LIBSOURCES_LIST]) 881 m4_popdef([gltests_LIBSOURCES_LIST])
548 m4_popdef([AC_LIBSOURCES]) 882 m4_popdef([AC_LIBSOURCES])
@@ -551,17 +885,30 @@ changequote([, ])dnl
551 AC_CONFIG_COMMANDS_PRE([ 885 AC_CONFIG_COMMANDS_PRE([
552 gltests_libobjs= 886 gltests_libobjs=
553 gltests_ltlibobjs= 887 gltests_ltlibobjs=
888 gltests_libobjdeps=
554 if test -n "$gltests_LIBOBJS"; then 889 if test -n "$gltests_LIBOBJS"; then
555 # Remove the extension. 890 # Remove the extension.
891changequote(,)dnl
556 sed_drop_objext='s/\.o$//;s/\.obj$//' 892 sed_drop_objext='s/\.o$//;s/\.obj$//'
893 sed_dirname1='s,//*,/,g'
894 sed_dirname2='s,\(.\)/$,\1,'
895 sed_dirname3='s,^[^/]*$,.,'
896 sed_dirname4='s,\(.\)/[^/]*$,\1,'
897 sed_basename1='s,.*/,,'
898changequote([, ])dnl
557 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do 899 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
558 gltests_libobjs="$gltests_libobjs $i.$ac_objext" 900 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
559 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" 901 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
902 i_dir=`echo "$i" | sed -e "$sed_dirname1" -e "$sed_dirname2" -e "$sed_dirname3" -e "$sed_dirname4"`
903 i_base=`echo "$i" | sed -e "$sed_basename1"`
904 gltests_libobjdeps="$gltests_libobjdeps $i_dir/\$(DEPDIR)/$i_base.Po"
560 done 905 done
561 fi 906 fi
562 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) 907 AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
563 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) 908 AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
909 AC_SUBST([gltests_LIBOBJDEPS], [$gltests_libobjdeps])
564 ]) 910 ])
911 AC_REQUIRE([gl_CC_GNULIB_WARNINGS])
565 LIBGNU_LIBDEPS="$gl_libdeps" 912 LIBGNU_LIBDEPS="$gl_libdeps"
566 AC_SUBST([LIBGNU_LIBDEPS]) 913 AC_SUBST([LIBGNU_LIBDEPS])
567 LIBGNU_LTLIBDEPS="$gl_ltlibdeps" 914 LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
@@ -625,76 +972,130 @@ AC_DEFUN([gltests_LIBSOURCES], [
625# This macro records the list of files which have been installed by 972# This macro records the list of files which have been installed by
626# gnulib-tool and may be removed by future gnulib-tool invocations. 973# gnulib-tool and may be removed by future gnulib-tool invocations.
627AC_DEFUN([gl_FILE_LIST], [ 974AC_DEFUN([gl_FILE_LIST], [
628 build-aux/config.rpath 975 lib/_Noreturn.h
629 build-aux/snippet/_Noreturn.h 976 lib/af_alg.c
630 build-aux/snippet/arg-nonnull.h 977 lib/af_alg.h
631 build-aux/snippet/c++defs.h
632 build-aux/snippet/warn-on-use.h
633 lib/alloca.in.h 978 lib/alloca.in.h
979 lib/arg-nonnull.h
634 lib/arpa_inet.in.h 980 lib/arpa_inet.in.h
635 lib/asnprintf.c 981 lib/asnprintf.c
636 lib/asprintf.c 982 lib/asprintf.c
983 lib/assert.in.h
984 lib/attribute.h
637 lib/base64.c 985 lib/base64.c
638 lib/base64.h 986 lib/base64.h
639 lib/basename-lgpl.c 987 lib/basename-lgpl.c
988 lib/basename-lgpl.h
640 lib/basename.c 989 lib/basename.c
641 lib/btowc.c 990 lib/btowc.c
642 lib/config.charset 991 lib/byteswap.in.h
992 lib/c++defs.h
993 lib/calloc.c
994 lib/cdefs.h
995 lib/cloexec.c
996 lib/cloexec.h
997 lib/close.c
643 lib/dirname-lgpl.c 998 lib/dirname-lgpl.c
644 lib/dirname.c 999 lib/dirname.c
645 lib/dirname.h 1000 lib/dirname.h
646 lib/dosname.h 1001 lib/dup2.c
1002 lib/dynarray.h
647 lib/errno.in.h 1003 lib/errno.in.h
648 lib/error.c 1004 lib/error.c
649 lib/error.h 1005 lib/error.h
650 lib/exitfail.c 1006 lib/exitfail.c
651 lib/exitfail.h 1007 lib/exitfail.h
1008 lib/fcntl.c
1009 lib/fcntl.in.h
652 lib/fd-hook.c 1010 lib/fd-hook.c
653 lib/fd-hook.h 1011 lib/fd-hook.h
1012 lib/fflush.c
1013 lib/filename.h
654 lib/float+.h 1014 lib/float+.h
655 lib/float.c 1015 lib/float.c
656 lib/float.in.h 1016 lib/float.in.h
657 lib/floor.c 1017 lib/floor.c
658 lib/floorf.c 1018 lib/floorf.c
1019 lib/fopen.c
1020 lib/fpurge.c
1021 lib/freading.c
1022 lib/freading.h
1023 lib/free.c
1024 lib/fseek.c
1025 lib/fseeko.c
1026 lib/fstat.c
659 lib/fsusage.c 1027 lib/fsusage.c
660 lib/fsusage.h 1028 lib/fsusage.h
661 lib/full-read.c 1029 lib/ftell.c
662 lib/full-read.h 1030 lib/ftello.c
663 lib/full-write.c
664 lib/gai_strerror.c 1031 lib/gai_strerror.c
665 lib/getaddrinfo.c 1032 lib/getaddrinfo.c
1033 lib/getdelim.c
1034 lib/getdtablesize.c
666 lib/gethostname.c 1035 lib/gethostname.c
1036 lib/getline.c
667 lib/getloadavg.c 1037 lib/getloadavg.c
1038 lib/getopt-cdefs.in.h
1039 lib/getopt-core.h
1040 lib/getopt-ext.h
1041 lib/getopt-pfx-core.h
1042 lib/getopt-pfx-ext.h
668 lib/getopt.c 1043 lib/getopt.c
669 lib/getopt.in.h 1044 lib/getopt.in.h
670 lib/getopt1.c 1045 lib/getopt1.c
671 lib/getopt_int.h 1046 lib/getopt_int.h
1047 lib/getprogname.c
1048 lib/getprogname.h
672 lib/gettext.h 1049 lib/gettext.h
1050 lib/gl_openssl.h
673 lib/glthread/lock.c 1051 lib/glthread/lock.c
674 lib/glthread/lock.h 1052 lib/glthread/lock.h
675 lib/glthread/threadlib.c 1053 lib/glthread/threadlib.c
1054 lib/hard-locale.c
1055 lib/hard-locale.h
1056 lib/ialloc.c
1057 lib/ialloc.h
676 lib/idpriv-droptemp.c 1058 lib/idpriv-droptemp.c
677 lib/idpriv.h 1059 lib/idpriv.h
1060 lib/idx.h
678 lib/inet_ntop.c 1061 lib/inet_ntop.c
1062 lib/intprops-internal.h
679 lib/intprops.h 1063 lib/intprops.h
1064 lib/inttypes.in.h
680 lib/itold.c 1065 lib/itold.c
681 lib/langinfo.in.h 1066 lib/langinfo.in.h
1067 lib/lc-charset-dispatch.c
1068 lib/lc-charset-dispatch.h
1069 lib/libc-config.h
1070 lib/limits.in.h
682 lib/localcharset.c 1071 lib/localcharset.c
683 lib/localcharset.h 1072 lib/localcharset.h
684 lib/locale.in.h 1073 lib/locale.in.h
685 lib/localeconv.c 1074 lib/localeconv.c
1075 lib/lseek.c
686 lib/malloc.c 1076 lib/malloc.c
1077 lib/malloc/dynarray-skeleton.c
1078 lib/malloc/dynarray.h
1079 lib/malloc/dynarray_at_failure.c
1080 lib/malloc/dynarray_emplace_enlarge.c
1081 lib/malloc/dynarray_finalize.c
1082 lib/malloc/dynarray_resize.c
1083 lib/malloc/dynarray_resize_clear.c
687 lib/malloca.c 1084 lib/malloca.c
688 lib/malloca.h 1085 lib/malloca.h
689 lib/malloca.valgrind
690 lib/math.c 1086 lib/math.c
691 lib/math.in.h 1087 lib/math.in.h
1088 lib/mbrtowc-impl-utf8.h
1089 lib/mbrtowc-impl.h
692 lib/mbrtowc.c 1090 lib/mbrtowc.c
693 lib/mbsinit.c 1091 lib/mbsinit.c
694 lib/mbtowc-impl.h 1092 lib/mbtowc-impl.h
1093 lib/mbtowc-lock.c
1094 lib/mbtowc-lock.h
695 lib/mbtowc.c 1095 lib/mbtowc.c
696 lib/memchr.c 1096 lib/memchr.c
697 lib/memchr.valgrind 1097 lib/memchr.valgrind
1098 lib/minmax.h
698 lib/mktime-internal.h 1099 lib/mktime-internal.h
699 lib/mktime.c 1100 lib/mktime.c
700 lib/mountlist.c 1101 lib/mountlist.c
@@ -705,33 +1106,45 @@ AC_DEFUN([gl_FILE_LIST], [
705 lib/msvc-nothrow.h 1106 lib/msvc-nothrow.h
706 lib/netdb.in.h 1107 lib/netdb.in.h
707 lib/netinet_in.in.h 1108 lib/netinet_in.in.h
1109 lib/nl_langinfo-lock.c
708 lib/nl_langinfo.c 1110 lib/nl_langinfo.c
1111 lib/open.c
1112 lib/pathmax.h
709 lib/printf-args.c 1113 lib/printf-args.c
710 lib/printf-args.h 1114 lib/printf-args.h
711 lib/printf-parse.c 1115 lib/printf-parse.c
712 lib/printf-parse.h 1116 lib/printf-parse.h
713 lib/read.c 1117 lib/realloc.c
714 lib/ref-add.sin 1118 lib/reallocarray.c
715 lib/ref-del.sin
716 lib/regcomp.c 1119 lib/regcomp.c
717 lib/regex.c 1120 lib/regex.c
718 lib/regex.h 1121 lib/regex.h
719 lib/regex_internal.c 1122 lib/regex_internal.c
720 lib/regex_internal.h 1123 lib/regex_internal.h
721 lib/regexec.c 1124 lib/regexec.c
722 lib/safe-read.c
723 lib/safe-read.h
724 lib/setenv.c 1125 lib/setenv.c
725 lib/sha1.c 1126 lib/setlocale-lock.c
726 lib/sha1.h 1127 lib/setlocale_null.c
1128 lib/setlocale_null.h
1129 lib/sha256-stream.c
1130 lib/sha256.c
1131 lib/sha256.h
727 lib/size_max.h 1132 lib/size_max.h
728 lib/snprintf.c 1133 lib/snprintf.c
729 lib/sockets.c 1134 lib/sockets.c
730 lib/sockets.h 1135 lib/sockets.h
1136 lib/stat-time.c
1137 lib/stat-time.h
1138 lib/stat-w32.c
1139 lib/stat-w32.h
1140 lib/stat.c
731 lib/stdalign.in.h 1141 lib/stdalign.in.h
732 lib/stdbool.in.h 1142 lib/stdckdint.in.h
733 lib/stddef.in.h 1143 lib/stddef.in.h
734 lib/stdint.in.h 1144 lib/stdint.in.h
1145 lib/stdio-impl.h
1146 lib/stdio-read.c
1147 lib/stdio-write.c
735 lib/stdio.in.h 1148 lib/stdio.in.h
736 lib/stdlib.in.h 1149 lib/stdlib.in.h
737 lib/str-two-way.h 1150 lib/str-two-way.h
@@ -745,12 +1158,12 @@ AC_DEFUN([gl_FILE_LIST], [
745 lib/strings.in.h 1158 lib/strings.in.h
746 lib/stripslash.c 1159 lib/stripslash.c
747 lib/strncasecmp.c 1160 lib/strncasecmp.c
748 lib/strndup.c
749 lib/strnlen.c
750 lib/strsep.c 1161 lib/strsep.c
751 lib/strstr.c 1162 lib/strstr.c
1163 lib/sys-limits.h
752 lib/sys_socket.c 1164 lib/sys_socket.c
753 lib/sys_socket.in.h 1165 lib/sys_socket.in.h
1166 lib/sys_stat.in.h
754 lib/sys_types.in.h 1167 lib/sys_types.in.h
755 lib/sys_uio.in.h 1168 lib/sys_uio.in.h
756 lib/time.in.h 1169 lib/time.in.h
@@ -758,6 +1171,7 @@ AC_DEFUN([gl_FILE_LIST], [
758 lib/timegm.c 1171 lib/timegm.c
759 lib/unistd.c 1172 lib/unistd.c
760 lib/unistd.in.h 1173 lib/unistd.in.h
1174 lib/unlocked-io.h
761 lib/unsetenv.c 1175 lib/unsetenv.c
762 lib/vasnprintf.c 1176 lib/vasnprintf.c
763 lib/vasnprintf.h 1177 lib/vasnprintf.h
@@ -765,27 +1179,43 @@ AC_DEFUN([gl_FILE_LIST], [
765 lib/verify.h 1179 lib/verify.h
766 lib/vsnprintf.c 1180 lib/vsnprintf.c
767 lib/w32sock.h 1181 lib/w32sock.h
1182 lib/warn-on-use.h
768 lib/wchar.in.h 1183 lib/wchar.in.h
769 lib/wcrtomb.c 1184 lib/wcrtomb.c
770 lib/wctype-h.c 1185 lib/wctype-h.c
771 lib/wctype.in.h 1186 lib/wctype.in.h
1187 lib/windows-initguard.h
1188 lib/windows-mutex.c
1189 lib/windows-mutex.h
1190 lib/windows-once.c
1191 lib/windows-once.h
1192 lib/windows-recmutex.c
1193 lib/windows-recmutex.h
1194 lib/windows-rwlock.c
1195 lib/windows-rwlock.h
772 lib/xalloc-die.c 1196 lib/xalloc-die.c
773 lib/xalloc-oversized.h 1197 lib/xalloc-oversized.h
774 lib/xalloc.h 1198 lib/xalloc.h
775 lib/xmalloc.c 1199 lib/xmalloc.c
776 lib/xsize.c 1200 lib/xsize.c
777 lib/xsize.h 1201 lib/xsize.h
778 lib/xstrndup.c
779 lib/xstrndup.h
780 m4/00gnulib.m4 1202 m4/00gnulib.m4
1203 m4/__inline.m4
1204 m4/absolute-header.m4
1205 m4/af_alg.m4
781 m4/alloca.m4 1206 m4/alloca.m4
782 m4/arpa_inet_h.m4 1207 m4/arpa_inet_h.m4
1208 m4/assert_h.m4
783 m4/base64.m4 1209 m4/base64.m4
784 m4/btowc.m4 1210 m4/btowc.m4
1211 m4/builtin-expect.m4
1212 m4/byteswap.m4
1213 m4/c-bool.m4
1214 m4/calloc.m4
1215 m4/close.m4
785 m4/codeset.m4 1216 m4/codeset.m4
786 m4/configmake.m4
787 m4/dirname.m4
788 m4/double-slash-root.m4 1217 m4/double-slash-root.m4
1218 m4/dup2.m4
789 m4/eealloc.m4 1219 m4/eealloc.m4
790 m4/environ.m4 1220 m4/environ.m4
791 m4/errno_h.m4 1221 m4/errno_h.m4
@@ -794,37 +1224,42 @@ AC_DEFUN([gl_FILE_LIST], [
794 m4/extensions.m4 1224 m4/extensions.m4
795 m4/extern-inline.m4 1225 m4/extern-inline.m4
796 m4/fcntl-o.m4 1226 m4/fcntl-o.m4
1227 m4/fcntl.m4
1228 m4/fcntl_h.m4
1229 m4/fflush.m4
797 m4/float_h.m4 1230 m4/float_h.m4
798 m4/floorf.m4 1231 m4/floorf.m4
1232 m4/fopen.m4
1233 m4/fpurge.m4
1234 m4/freading.m4
1235 m4/free.m4
1236 m4/fseek.m4
1237 m4/fseeko.m4
1238 m4/fstat.m4
799 m4/fstypename.m4 1239 m4/fstypename.m4
800 m4/fsusage.m4 1240 m4/fsusage.m4
1241 m4/ftell.m4
1242 m4/ftello.m4
801 m4/getaddrinfo.m4 1243 m4/getaddrinfo.m4
1244 m4/getdelim.m4
1245 m4/getdtablesize.m4
802 m4/gethostname.m4 1246 m4/gethostname.m4
1247 m4/getline.m4
803 m4/getloadavg.m4 1248 m4/getloadavg.m4
804 m4/getopt.m4 1249 m4/getopt.m4
805 m4/gettext.m4 1250 m4/getprogname.m4
806 m4/glibc2.m4 1251 m4/gl-openssl.m4
807 m4/glibc21.m4
808 m4/gnulib-common.m4 1252 m4/gnulib-common.m4
809 m4/hostent.m4 1253 m4/hostent.m4
810 m4/iconv.m4
811 m4/idpriv.m4 1254 m4/idpriv.m4
812 m4/include_next.m4 1255 m4/include_next.m4
813 m4/inet_ntop.m4 1256 m4/inet_ntop.m4
814 m4/intdiv0.m4
815 m4/intl.m4
816 m4/intldir.m4
817 m4/intlmacosx.m4
818 m4/intmax.m4
819 m4/intmax_t.m4 1257 m4/intmax_t.m4
820 m4/inttypes-pri.m4 1258 m4/inttypes.m4
821 m4/inttypes_h.m4 1259 m4/inttypes_h.m4
822 m4/langinfo_h.m4 1260 m4/langinfo_h.m4
823 m4/largefile.m4 1261 m4/largefile.m4
824 m4/lcmessage.m4 1262 m4/limits-h.m4
825 m4/lib-ld.m4
826 m4/lib-link.m4
827 m4/lib-prefix.m4
828 m4/localcharset.m4 1263 m4/localcharset.m4
829 m4/locale-fr.m4 1264 m4/locale-fr.m4
830 m4/locale-ja.m4 1265 m4/locale-ja.m4
@@ -832,8 +1267,7 @@ AC_DEFUN([gl_FILE_LIST], [
832 m4/locale_h.m4 1267 m4/locale_h.m4
833 m4/localeconv.m4 1268 m4/localeconv.m4
834 m4/lock.m4 1269 m4/lock.m4
835 m4/longlong.m4 1270 m4/lseek.m4
836 m4/ls-mntd-fs.m4
837 m4/malloc.m4 1271 m4/malloc.m4
838 m4/malloca.m4 1272 m4/malloca.m4
839 m4/math_h.m4 1273 m4/math_h.m4
@@ -842,8 +1276,10 @@ AC_DEFUN([gl_FILE_LIST], [
842 m4/mbstate_t.m4 1276 m4/mbstate_t.m4
843 m4/mbtowc.m4 1277 m4/mbtowc.m4
844 m4/memchr.m4 1278 m4/memchr.m4
1279 m4/minmax.m4
845 m4/mktime.m4 1280 m4/mktime.m4
846 m4/mmap-anon.m4 1281 m4/mmap-anon.m4
1282 m4/mode_t.m4
847 m4/mountlist.m4 1283 m4/mountlist.m4
848 m4/msvc-inval.m4 1284 m4/msvc-inval.m4
849 m4/msvc-nothrow.m4 1285 m4/msvc-nothrow.m4
@@ -851,20 +1287,22 @@ AC_DEFUN([gl_FILE_LIST], [
851 m4/netdb_h.m4 1287 m4/netdb_h.m4
852 m4/netinet_in_h.m4 1288 m4/netinet_in_h.m4
853 m4/nl_langinfo.m4 1289 m4/nl_langinfo.m4
854 m4/nls.m4
855 m4/nocrash.m4 1290 m4/nocrash.m4
856 m4/off_t.m4 1291 m4/off_t.m4
857 m4/onceonly.m4 1292 m4/open-cloexec.m4
858 m4/po.m4 1293 m4/open-slash.m4
859 m4/printf-posix.m4 1294 m4/open.m4
1295 m4/pathmax.m4
1296 m4/pid_t.m4
860 m4/printf.m4 1297 m4/printf.m4
861 m4/progtest.m4 1298 m4/pthread_rwlock_rdlock.m4
862 m4/read.m4 1299 m4/realloc.m4
1300 m4/reallocarray.m4
863 m4/regex.m4 1301 m4/regex.m4
864 m4/safe-read.m4
865 m4/servent.m4 1302 m4/servent.m4
866 m4/setenv.m4 1303 m4/setenv.m4
867 m4/sha1.m4 1304 m4/setlocale_null.m4
1305 m4/sha256.m4
868 m4/size_max.m4 1306 m4/size_max.m4
869 m4/snprintf.m4 1307 m4/snprintf.m4
870 m4/socketlib.m4 1308 m4/socketlib.m4
@@ -872,8 +1310,10 @@ AC_DEFUN([gl_FILE_LIST], [
872 m4/socklen.m4 1310 m4/socklen.m4
873 m4/sockpfaf.m4 1311 m4/sockpfaf.m4
874 m4/ssize_t.m4 1312 m4/ssize_t.m4
1313 m4/stat-time.m4
1314 m4/stat.m4
1315 m4/std-gnu11.m4
875 m4/stdalign.m4 1316 m4/stdalign.m4
876 m4/stdbool.m4
877 m4/stddef_h.m4 1317 m4/stddef_h.m4
878 m4/stdint.m4 1318 m4/stdint.m4
879 m4/stdint_h.m4 1319 m4/stdint_h.m4
@@ -884,19 +1324,20 @@ AC_DEFUN([gl_FILE_LIST], [
884 m4/strerror.m4 1324 m4/strerror.m4
885 m4/string_h.m4 1325 m4/string_h.m4
886 m4/strings_h.m4 1326 m4/strings_h.m4
887 m4/strndup.m4
888 m4/strnlen.m4
889 m4/strsep.m4 1327 m4/strsep.m4
890 m4/strstr.m4 1328 m4/strstr.m4
891 m4/sys_socket_h.m4 1329 m4/sys_socket_h.m4
1330 m4/sys_stat_h.m4
892 m4/sys_types_h.m4 1331 m4/sys_types_h.m4
893 m4/sys_uio_h.m4 1332 m4/sys_uio_h.m4
894 m4/threadlib.m4 1333 m4/threadlib.m4
895 m4/time_h.m4 1334 m4/time_h.m4
896 m4/time_r.m4 1335 m4/time_r.m4
897 m4/timegm.m4 1336 m4/timegm.m4
898 m4/uintmax_t.m4 1337 m4/ungetc.m4
899 m4/unistd_h.m4 1338 m4/unistd_h.m4
1339 m4/unlocked-io.m4
1340 m4/vararrays.m4
900 m4/vasnprintf.m4 1341 m4/vasnprintf.m4
901 m4/vasprintf.m4 1342 m4/vasprintf.m4
902 m4/visibility.m4 1343 m4/visibility.m4
@@ -909,5 +1350,5 @@ AC_DEFUN([gl_FILE_LIST], [
909 m4/wint_t.m4 1350 m4/wint_t.m4
910 m4/xalloc.m4 1351 m4/xalloc.m4
911 m4/xsize.m4 1352 m4/xsize.m4
912 m4/xstrndup.m4 1353 m4/zzgnulib.m4
913]) 1354])
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index f3dea1a..a9dd569 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
1# gnulib-tool.m4 serial 2 1# gnulib-tool.m4 serial 4
2dnl Copyright (C) 2004-2005, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -44,6 +44,12 @@ AC_DEFUN([gl_LGPL], [])
44dnl Usage: gl_MAKEFILE_NAME([FILENAME]) 44dnl Usage: gl_MAKEFILE_NAME([FILENAME])
45AC_DEFUN([gl_MAKEFILE_NAME], []) 45AC_DEFUN([gl_MAKEFILE_NAME], [])
46 46
47dnl Usage: gl_TESTS_MAKEFILE_NAME([FILENAME])
48AC_DEFUN([gl_TESTS_MAKEFILE_NAME], [])
49
50dnl Usage: gl_AUTOMAKE_SUBDIR
51AC_DEFUN([gl_AUTOMAKE_SUBDIR], [])
52
47dnl Usage: gl_LIBTOOL 53dnl Usage: gl_LIBTOOL
48AC_DEFUN([gl_LIBTOOL], []) 54AC_DEFUN([gl_LIBTOOL], [])
49 55
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
index 72be876..3b2cc2b 100644
--- a/gl/m4/hostent.m4
+++ b/gl/m4/hostent.m4
@@ -1,5 +1,5 @@
1# hostent.m4 serial 2 1# hostent.m4 serial 4
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,12 +8,12 @@ AC_DEFUN([gl_HOSTENT],
8[ 8[
9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(), 9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
10 dnl gethostbyaddr() defined? 10 dnl gethostbyaddr() defined?
11 dnl - On Solaris, they are in libnsl. Ignore libxnet. 11 dnl - On Solaris < 11.4, they are in libnsl. Ignore libxnet.
12 dnl - On Haiku, they are in libnetwork. 12 dnl - On Haiku, they are in libnetwork.
13 dnl - On BeOS, they are in libnet. 13 dnl - On BeOS, they are in libnet.
14 dnl - On native Windows, they are in ws2_32.dll. 14 dnl - On native Windows, they are in ws2_32.dll.
15 dnl - Otherwise they are in libc. 15 dnl - Otherwise they are in libc.
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 16 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
17 HOSTENT_LIB= 17 HOSTENT_LIB=
18 gl_saved_libs="$LIBS" 18 gl_saved_libs="$LIBS"
19 AC_SEARCH_LIBS([gethostbyname], [nsl network net], 19 AC_SEARCH_LIBS([gethostbyname], [nsl network net],
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
deleted file mode 100644
index a503646..0000000
--- a/gl/m4/iconv.m4
+++ /dev/null
@@ -1,268 +0,0 @@
1# iconv.m4 serial 18 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
10[
11 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
12 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
13 AC_REQUIRE([AC_LIB_RPATH])
14
15 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
16 dnl accordingly.
17 AC_LIB_LINKFLAGS_BODY([iconv])
18])
19
20AC_DEFUN([AM_ICONV_LINK],
21[
22 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
23 dnl those with the standalone portable GNU libiconv installed).
24 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
25
26 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
27 dnl accordingly.
28 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
29
30 dnl Add $INCICONV to CPPFLAGS before performing the following checks,
31 dnl because if the user has installed libiconv and not disabled its use
32 dnl via --without-libiconv-prefix, he wants to use it. The first
33 dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
34 am_save_CPPFLAGS="$CPPFLAGS"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
36
37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
38 am_cv_func_iconv="no, consider installing GNU libiconv"
39 am_cv_lib_iconv=no
40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[
43#include <stdlib.h>
44#include <iconv.h>
45 ]],
46 [[iconv_t cd = iconv_open("","");
47 iconv(cd,NULL,NULL,NULL,NULL);
48 iconv_close(cd);]])],
49 [am_cv_func_iconv=yes])
50 if test "$am_cv_func_iconv" != yes; then
51 am_save_LIBS="$LIBS"
52 LIBS="$LIBS $LIBICONV"
53 AC_LINK_IFELSE(
54 [AC_LANG_PROGRAM(
55 [[
56#include <stdlib.h>
57#include <iconv.h>
58 ]],
59 [[iconv_t cd = iconv_open("","");
60 iconv(cd,NULL,NULL,NULL,NULL);
61 iconv_close(cd);]])],
62 [am_cv_lib_iconv=yes]
63 [am_cv_func_iconv=yes])
64 LIBS="$am_save_LIBS"
65 fi
66 ])
67 if test "$am_cv_func_iconv" = yes; then
68 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
69 dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
70 dnl Solaris 10.
71 am_save_LIBS="$LIBS"
72 if test $am_cv_lib_iconv = yes; then
73 LIBS="$LIBS $LIBICONV"
74 fi
75 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[
77#include <iconv.h>
78#include <string.h>
79int main ()
80{
81 int result = 0;
82 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
83 returns. */
84 {
85 iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
86 if (cd_utf8_to_88591 != (iconv_t)(-1))
87 {
88 static const char input[] = "\342\202\254"; /* EURO SIGN */
89 char buf[10];
90 const char *inptr = input;
91 size_t inbytesleft = strlen (input);
92 char *outptr = buf;
93 size_t outbytesleft = sizeof (buf);
94 size_t res = iconv (cd_utf8_to_88591,
95 (char **) &inptr, &inbytesleft,
96 &outptr, &outbytesleft);
97 if (res == 0)
98 result |= 1;
99 iconv_close (cd_utf8_to_88591);
100 }
101 }
102 /* Test against Solaris 10 bug: Failures are not distinguishable from
103 successful returns. */
104 {
105 iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
106 if (cd_ascii_to_88591 != (iconv_t)(-1))
107 {
108 static const char input[] = "\263";
109 char buf[10];
110 const char *inptr = input;
111 size_t inbytesleft = strlen (input);
112 char *outptr = buf;
113 size_t outbytesleft = sizeof (buf);
114 size_t res = iconv (cd_ascii_to_88591,
115 (char **) &inptr, &inbytesleft,
116 &outptr, &outbytesleft);
117 if (res == 0)
118 result |= 2;
119 iconv_close (cd_ascii_to_88591);
120 }
121 }
122 /* Test against AIX 6.1..7.1 bug: Buffer overrun. */
123 {
124 iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
125 if (cd_88591_to_utf8 != (iconv_t)(-1))
126 {
127 static const char input[] = "\304";
128 static char buf[2] = { (char)0xDE, (char)0xAD };
129 const char *inptr = input;
130 size_t inbytesleft = 1;
131 char *outptr = buf;
132 size_t outbytesleft = 1;
133 size_t res = iconv (cd_88591_to_utf8,
134 (char **) &inptr, &inbytesleft,
135 &outptr, &outbytesleft);
136 if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
137 result |= 4;
138 iconv_close (cd_88591_to_utf8);
139 }
140 }
141#if 0 /* This bug could be worked around by the caller. */
142 /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
143 {
144 iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
145 if (cd_88591_to_utf8 != (iconv_t)(-1))
146 {
147 static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
148 char buf[50];
149 const char *inptr = input;
150 size_t inbytesleft = strlen (input);
151 char *outptr = buf;
152 size_t outbytesleft = sizeof (buf);
153 size_t res = iconv (cd_88591_to_utf8,
154 (char **) &inptr, &inbytesleft,
155 &outptr, &outbytesleft);
156 if ((int)res > 0)
157 result |= 8;
158 iconv_close (cd_88591_to_utf8);
159 }
160 }
161#endif
162 /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
163 provided. */
164 if (/* Try standardized names. */
165 iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
166 /* Try IRIX, OSF/1 names. */
167 && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
168 /* Try AIX names. */
169 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
170 /* Try HP-UX names. */
171 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
172 result |= 16;
173 return result;
174}]])],
175 [am_cv_func_iconv_works=yes],
176 [am_cv_func_iconv_works=no],
177 [
178changequote(,)dnl
179 case "$host_os" in
180 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
181 *) am_cv_func_iconv_works="guessing yes" ;;
182 esac
183changequote([,])dnl
184 ])
185 LIBS="$am_save_LIBS"
186 ])
187 case "$am_cv_func_iconv_works" in
188 *no) am_func_iconv=no am_cv_lib_iconv=no ;;
189 *) am_func_iconv=yes ;;
190 esac
191 else
192 am_func_iconv=no am_cv_lib_iconv=no
193 fi
194 if test "$am_func_iconv" = yes; then
195 AC_DEFINE([HAVE_ICONV], [1],
196 [Define if you have the iconv() function and it works.])
197 fi
198 if test "$am_cv_lib_iconv" = yes; then
199 AC_MSG_CHECKING([how to link with libiconv])
200 AC_MSG_RESULT([$LIBICONV])
201 else
202 dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
203 dnl either.
204 CPPFLAGS="$am_save_CPPFLAGS"
205 LIBICONV=
206 LTLIBICONV=
207 fi
208 AC_SUBST([LIBICONV])
209 AC_SUBST([LTLIBICONV])
210])
211
212dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
213dnl avoid warnings like
214dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
215dnl This is tricky because of the way 'aclocal' is implemented:
216dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
217dnl Otherwise aclocal's initial scan pass would miss the macro definition.
218dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
219dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
220dnl warnings.
221m4_define([gl_iconv_AC_DEFUN],
222 m4_version_prereq([2.64],
223 [[AC_DEFUN_ONCE(
224 [$1], [$2])]],
225 [m4_ifdef([gl_00GNULIB],
226 [[AC_DEFUN_ONCE(
227 [$1], [$2])]],
228 [[AC_DEFUN(
229 [$1], [$2])]])]))
230gl_iconv_AC_DEFUN([AM_ICONV],
231[
232 AM_ICONV_LINK
233 if test "$am_cv_func_iconv" = yes; then
234 AC_MSG_CHECKING([for iconv declaration])
235 AC_CACHE_VAL([am_cv_proto_iconv], [
236 AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM(
238 [[
239#include <stdlib.h>
240#include <iconv.h>
241extern
242#ifdef __cplusplus
243"C"
244#endif
245#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
246size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
247#else
248size_t iconv();
249#endif
250 ]],
251 [[]])],
252 [am_cv_proto_iconv_arg1=""],
253 [am_cv_proto_iconv_arg1="const"])
254 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
255 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
256 AC_MSG_RESULT([
257 $am_cv_proto_iconv])
258 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
259 [Define as const if the declaration of iconv() needs const.])
260 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
261 m4_ifdef([gl_ICONV_H_DEFAULTS],
262 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
263 if test -n "$am_cv_proto_iconv_arg1"; then
264 ICONV_CONST="const"
265 fi
266 ])
267 fi
268])
diff --git a/gl/m4/idpriv.m4 b/gl/m4/idpriv.m4
index 167f523..fc3dd17 100644
--- a/gl/m4/idpriv.m4
+++ b/gl/m4/idpriv.m4
@@ -1,5 +1,5 @@
1# idpriv.m4 serial 1 1# idpriv.m4 serial 1
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index 108d945..9f19215 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,12 +1,13 @@
1# include_next.m4 serial 23 1# include_next.m4 serial 26
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert and Derek Price. 7dnl From Paul Eggert and Derek Price.
8 8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. 9dnl Sets INCLUDE_NEXT, INCLUDE_NEXT_AS_FIRST_DIRECTIVE, PRAGMA_SYSTEM_HEADER,
10dnl and PRAGMA_COLUMNS.
10dnl 11dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to 12dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise. 13dnl 'include' otherwise.
@@ -105,19 +106,21 @@ dnl We intentionally avoid using AC_LANG_SOURCE here.
105 AC_SUBST([INCLUDE_NEXT]) 106 AC_SUBST([INCLUDE_NEXT])
106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) 107 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
107 AC_SUBST([PRAGMA_SYSTEM_HEADER]) 108 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length], 109
109 [gl_cv_pragma_columns], 110 dnl HP NonStop systems, which define __TANDEM, limit the line length
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature. 111 dnl after including some system header files.
111 AC_EGREP_CPP([choke me], 112 AC_CACHE_CHECK([whether source code line length is unlimited],
113 [gl_cv_source_line_length_unlimited],
114 [AC_EGREP_CPP([choke me],
112 [ 115 [
113#ifdef __TANDEM 116#ifdef __TANDEM
114choke me 117choke me
115#endif 118#endif
116 ], 119 ],
117 [gl_cv_pragma_columns=yes], 120 [gl_cv_source_line_length_unlimited=no],
118 [gl_cv_pragma_columns=no]) 121 [gl_cv_source_line_length_unlimited=yes])
119 ]) 122 ])
120 if test $gl_cv_pragma_columns = yes; then 123 if test $gl_cv_source_line_length_unlimited = no; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000" 124 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else 125 else
123 PRAGMA_COLUMNS= 126 PRAGMA_COLUMNS=
@@ -175,89 +178,40 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
175 [AC_CHECK_HEADERS_ONCE([$1]) 178 [AC_CHECK_HEADERS_ONCE([$1])
176 ]) 179 ])
177 180
178dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
179dnl until we can assume autoconf 2.64 or newer.
180 m4_foreach_w([gl_HEADER_NAME], [$1], 181 m4_foreach_w([gl_HEADER_NAME], [$1],
181 [AS_VAR_PUSHDEF([gl_next_header], 182 [AS_VAR_PUSHDEF([gl_next_header],
182 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) 183 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
183 if test $gl_cv_have_include_next = yes; then 184 if test $gl_cv_have_include_next = yes; then
184 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 185 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
185 else 186 else
186 AC_CACHE_CHECK( 187 AC_CACHE_CHECK(
187 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], 188 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
188 m4_defn([gl_next_header]), 189 [gl_next_header],
189 [m4_if([$2], [check], 190 [m4_if([$2], [check],
190 [AS_VAR_PUSHDEF([gl_header_exists], 191 [AS_VAR_PUSHDEF([gl_header_exists],
191 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) 192 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
192 if test AS_VAR_GET(gl_header_exists) = yes; then 193 if test AS_VAR_GET([gl_header_exists]) = yes; then
193 AS_VAR_POPDEF([gl_header_exists]) 194 AS_VAR_POPDEF([gl_header_exists])
194 ]) 195 ])
195 AC_LANG_CONFTEST( 196 gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
196 [AC_LANG_SOURCE( 197 AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
197 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 198 AS_VAR_SET([gl_next_header], ['"'$gl_header'"'])
198 )])
199 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
200 dnl files that contain only a #include of other header files and
201 dnl no non-comment tokens of their own. This leads to a failure
202 dnl to detect the absolute name of <dirent.h>, <signal.h>,
203 dnl <poll.h> and others. The workaround is to force preservation
204 dnl of comments through option -C. This ensures all necessary
205 dnl #line directives are present. GCC supports option -C as well.
206 case "$host_os" in
207 aix*) gl_absname_cpp="$ac_cpp -C" ;;
208 *) gl_absname_cpp="$ac_cpp" ;;
209 esac
210changequote(,)
211 case "$host_os" in
212 mingw*)
213 dnl For the sake of native Windows compilers (excluding gcc),
214 dnl treat backslash as a directory separator, like /.
215 dnl Actually, these compilers use a double-backslash as
216 dnl directory separator, inside the
217 dnl # line "filename"
218 dnl directives.
219 gl_dirsep_regex='[/\\]'
220 ;;
221 *)
222 gl_dirsep_regex='\/'
223 ;;
224 esac
225 dnl A sed expression that turns a string into a basic regular
226 dnl expression, for use within "/.../".
227 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
228changequote([,])
229 gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
230 | sed -e "$gl_make_literal_regex_sed"`
231 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
232 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
233changequote(,)dnl
234 s|^/[^/]|//&|
235changequote([,])dnl
236 p
237 q
238 }'
239 dnl eval is necessary to expand gl_absname_cpp.
240 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
241 dnl so use subshell.
242 AS_VAR_SET(gl_next_header,
243 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
244 sed -n "$gl_absolute_header_sed"`'"'])
245 m4_if([$2], [check], 199 m4_if([$2], [check],
246 [else 200 [else
247 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) 201 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
248 fi 202 fi
249 ]) 203 ])
250 ]) 204 ])
251 fi 205 fi
252 AC_SUBST( 206 AC_SUBST(
253 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), 207 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
254 [AS_VAR_GET(gl_next_header)]) 208 [AS_VAR_GET([gl_next_header])])
255 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then 209 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
256 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' 210 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
257 gl_next_as_first_directive='<'gl_HEADER_NAME'>' 211 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
258 else 212 else
259 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' 213 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
260 gl_next_as_first_directive=AS_VAR_GET(gl_next_header) 214 gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
261 fi 215 fi
262 AC_SUBST( 216 AC_SUBST(
263 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), 217 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index 476f063..48822d6 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,5 +1,5 @@
1# inet_ntop.m4 serial 19 1# inet_ntop.m4 serial 21
2dnl Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,6 +16,7 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
16 dnl Most platforms that provide inet_ntop define it in libc. 16 dnl Most platforms that provide inet_ntop define it in libc.
17 dnl Solaris 8..10 provide inet_ntop in libnsl instead. 17 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. 18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
19 dnl Haiku provides it in -lnetwork.
19 dnl Native Windows provides it in -lws2_32 instead, with a declaration in 20 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
20 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl 21 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
21 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it). 22 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
@@ -23,19 +24,20 @@ AC_DEFUN([gl_FUNC_INET_NTOP],
23 INET_NTOP_LIB= 24 INET_NTOP_LIB=
24 gl_PREREQ_SYS_H_WINSOCK2 25 gl_PREREQ_SYS_H_WINSOCK2
25 if test $HAVE_WINSOCK2_H = 1; then 26 if test $HAVE_WINSOCK2_H = 1; then
27 dnl It needs to be overridden, because the stdcall calling convention
28 dnl is not compliant with POSIX. Set REPLACE_INET_NTOP in order to avoid
29 dnl a name conflict at the linker level, even though the header file
30 dnl <ws2tcpip.h> declares inet_ntop only if _WIN32_WINNT >= 0x0600.
31 REPLACE_INET_NTOP=1
26 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]]) 32 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
27 if test $ac_cv_have_decl_inet_ntop = yes; then 33 if test $ac_cv_have_decl_inet_ntop = yes; then
28 dnl It needs to be overridden, because the stdcall calling convention
29 dnl is not compliant with POSIX.
30 REPLACE_INET_NTOP=1
31 INET_NTOP_LIB="-lws2_32" 34 INET_NTOP_LIB="-lws2_32"
32 else 35 else
33 HAVE_DECL_INET_NTOP=0 36 HAVE_DECL_INET_NTOP=0
34 HAVE_INET_NTOP=0
35 fi 37 fi
36 else 38 else
37 gl_save_LIBS=$LIBS 39 gl_save_LIBS=$LIBS
38 AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [], 40 AC_SEARCH_LIBS([inet_ntop], [nsl resolv network], [],
39 [AC_CHECK_FUNCS([inet_ntop]) 41 [AC_CHECK_FUNCS([inet_ntop])
40 if test $ac_cv_func_inet_ntop = no; then 42 if test $ac_cv_func_inet_ntop = no; then
41 HAVE_INET_NTOP=0 43 HAVE_INET_NTOP=0
diff --git a/gl/m4/intdiv0.m4 b/gl/m4/intdiv0.m4
deleted file mode 100644
index 74d0e80..0000000
--- a/gl/m4/intdiv0.m4
+++ /dev/null
@@ -1,87 +0,0 @@
1# intdiv0.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002, 2007-2008, 2010-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN([gt_INTDIV0],
10[
11 AC_REQUIRE([AC_PROG_CC])dnl
12 AC_REQUIRE([AC_CANONICAL_HOST])dnl
13
14 AC_CACHE_CHECK([whether integer division by zero raises SIGFPE],
15 gt_cv_int_divbyzero_sigfpe,
16 [
17 gt_cv_int_divbyzero_sigfpe=
18changequote(,)dnl
19 case "$host_os" in
20 macos* | darwin[6-9]* | darwin[1-9][0-9]*)
21 # On Mac OS X 10.2 or newer, just assume the same as when cross-
22 # compiling. If we were to perform the real test, 1 Crash Report
23 # dialog window would pop up.
24 case "$host_cpu" in
25 i[34567]86 | x86_64)
26 gt_cv_int_divbyzero_sigfpe="guessing yes" ;;
27 esac
28 ;;
29 esac
30changequote([,])dnl
31 if test -z "$gt_cv_int_divbyzero_sigfpe"; then
32 AC_RUN_IFELSE(
33 [AC_LANG_SOURCE([[
34#include <stdlib.h>
35#include <signal.h>
36
37static void
38sigfpe_handler (int sig)
39{
40 /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */
41 exit (sig != SIGFPE);
42}
43
44int x = 1;
45int y = 0;
46int z;
47int nan;
48
49int main ()
50{
51 signal (SIGFPE, sigfpe_handler);
52/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */
53#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP)
54 signal (SIGTRAP, sigfpe_handler);
55#endif
56/* Linux/SPARC yields signal SIGILL. */
57#if defined (__sparc__) && defined (__linux__)
58 signal (SIGILL, sigfpe_handler);
59#endif
60
61 z = x / y;
62 nan = y / y;
63 exit (2);
64}
65]])],
66 [gt_cv_int_divbyzero_sigfpe=yes],
67 [gt_cv_int_divbyzero_sigfpe=no],
68 [
69 # Guess based on the CPU.
70changequote(,)dnl
71 case "$host_cpu" in
72 alpha* | i[34567]86 | x86_64 | m68k | s390*)
73 gt_cv_int_divbyzero_sigfpe="guessing yes";;
74 *)
75 gt_cv_int_divbyzero_sigfpe="guessing no";;
76 esac
77changequote([,])dnl
78 ])
79 fi
80 ])
81 case "$gt_cv_int_divbyzero_sigfpe" in
82 *yes) value=1;;
83 *) value=0;;
84 esac
85 AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
86 [Define if integer division by zero raises signal SIGFPE.])
87])
diff --git a/gl/m4/intl.m4 b/gl/m4/intl.m4
deleted file mode 100644
index 959bd04..0000000
--- a/gl/m4/intl.m4
+++ /dev/null
@@ -1,271 +0,0 @@
1# intl.m4 serial 23 (gettext-0.18.3)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
19
20AC_PREREQ([2.60])
21
22dnl Checks for all prerequisites of the intl subdirectory,
23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
24dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
25AC_DEFUN([AM_INTL_SUBDIR],
26[
27 AC_REQUIRE([AC_PROG_INSTALL])dnl
28 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
29 AC_REQUIRE([AC_PROG_CC])dnl
30 AC_REQUIRE([AC_CANONICAL_HOST])dnl
31 AC_REQUIRE([gt_GLIBC2])dnl
32 AC_REQUIRE([AC_PROG_RANLIB])dnl
33 AC_REQUIRE([gl_VISIBILITY])dnl
34 AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl
36 AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
37 AC_REQUIRE([gt_TYPE_WINT_T])dnl
38 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
39 AC_REQUIRE([gt_TYPE_INTMAX_T])
40 AC_REQUIRE([gt_PRINTF_POSIX])
41 AC_REQUIRE([gl_GLIBC21])dnl
42 AC_REQUIRE([gl_XSIZE])dnl
43 AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
44 AC_REQUIRE([gt_INTL_MACOSX])dnl
45
46 dnl Support for automake's --enable-silent-rules.
47 case "$enable_silent_rules" in
48 yes) INTL_DEFAULT_VERBOSITY=0;;
49 no) INTL_DEFAULT_VERBOSITY=1;;
50 *) INTL_DEFAULT_VERBOSITY=1;;
51 esac
52 AC_SUBST([INTL_DEFAULT_VERBOSITY])
53
54 AC_CHECK_TYPE([ptrdiff_t], ,
55 [AC_DEFINE([ptrdiff_t], [long],
56 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
57 ])
58 AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h])
59 AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
60 snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
61
62 dnl Use the _snprintf function only if it is declared (because on NetBSD it
63 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
64 AC_CHECK_DECLS([_snprintf _snwprintf], , , [#include <stdio.h>])
65
66 dnl Use the *_unlocked functions only if they are declared.
67 dnl (because some of them were defined without being declared in Solaris
68 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
69 dnl on Solaris 2.5.1 to run on Solaris 2.6).
70 AC_CHECK_DECLS([getc_unlocked], , , [#include <stdio.h>])
71
72 case $gt_cv_func_printf_posix in
73 *yes) HAVE_POSIX_PRINTF=1 ;;
74 *) HAVE_POSIX_PRINTF=0 ;;
75 esac
76 AC_SUBST([HAVE_POSIX_PRINTF])
77 if test "$ac_cv_func_asprintf" = yes; then
78 HAVE_ASPRINTF=1
79 else
80 HAVE_ASPRINTF=0
81 fi
82 AC_SUBST([HAVE_ASPRINTF])
83 if test "$ac_cv_func_snprintf" = yes; then
84 HAVE_SNPRINTF=1
85 else
86 HAVE_SNPRINTF=0
87 fi
88 AC_SUBST([HAVE_SNPRINTF])
89 if test "$ac_cv_func_newlocale" = yes; then
90 HAVE_NEWLOCALE=1
91 else
92 HAVE_NEWLOCALE=0
93 fi
94 AC_SUBST([HAVE_NEWLOCALE])
95 if test "$ac_cv_func_wprintf" = yes; then
96 HAVE_WPRINTF=1
97 else
98 HAVE_WPRINTF=0
99 fi
100 AC_SUBST([HAVE_WPRINTF])
101
102 AM_LANGINFO_CODESET
103 gt_LC_MESSAGES
104
105 dnl Compilation on mingw and Cygwin needs special Makefile rules, because
106 dnl 1. when we install a shared library, we must arrange to export
107 dnl auxiliary pointer variables for every exported variable,
108 dnl 2. when we install a shared library and a static library simultaneously,
109 dnl the include file specifies __declspec(dllimport) and therefore we
110 dnl must arrange to define the auxiliary pointer variables for the
111 dnl exported variables _also_ in the static library.
112 if test "$enable_shared" = yes; then
113 case "$host_os" in
114 mingw* | cygwin*) is_woe32dll=yes ;;
115 *) is_woe32dll=no ;;
116 esac
117 else
118 is_woe32dll=no
119 fi
120 WOE32DLL=$is_woe32dll
121 AC_SUBST([WOE32DLL])
122
123 dnl On mingw and Cygwin, we can activate special Makefile rules which add
124 dnl version information to the shared libraries and executables.
125 case "$host_os" in
126 mingw* | cygwin*) is_woe32=yes ;;
127 *) is_woe32=no ;;
128 esac
129 WOE32=$is_woe32
130 AC_SUBST([WOE32])
131 if test $WOE32 = yes; then
132 dnl Check for a program that compiles Windows resource files.
133 AC_CHECK_TOOL([WINDRES], [windres])
134 fi
135
136 dnl Determine whether when creating a library, "-lc" should be passed to
137 dnl libtool or not. On many platforms, it is required for the libtool option
138 dnl -no-undefined to work. On HP-UX, however, the -lc - stored by libtool
139 dnl in the *.la files - makes it impossible to create multithreaded programs,
140 dnl because libtool also reorders the -lc to come before the -pthread, and
141 dnl this disables pthread_create() <http://docs.hp.com/en/1896/pthreads.html>.
142 case "$host_os" in
143 hpux*) LTLIBC="" ;;
144 *) LTLIBC="-lc" ;;
145 esac
146 AC_SUBST([LTLIBC])
147
148 dnl Rename some macros and functions used for locking.
149 AH_BOTTOM([
150#define __libc_lock_t gl_lock_t
151#define __libc_lock_define gl_lock_define
152#define __libc_lock_define_initialized gl_lock_define_initialized
153#define __libc_lock_init gl_lock_init
154#define __libc_lock_lock gl_lock_lock
155#define __libc_lock_unlock gl_lock_unlock
156#define __libc_lock_recursive_t gl_recursive_lock_t
157#define __libc_lock_define_recursive gl_recursive_lock_define
158#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized
159#define __libc_lock_init_recursive gl_recursive_lock_init
160#define __libc_lock_lock_recursive gl_recursive_lock_lock
161#define __libc_lock_unlock_recursive gl_recursive_lock_unlock
162#define glthread_in_use libintl_thread_in_use
163#define glthread_lock_init_func libintl_lock_init_func
164#define glthread_lock_lock_func libintl_lock_lock_func
165#define glthread_lock_unlock_func libintl_lock_unlock_func
166#define glthread_lock_destroy_func libintl_lock_destroy_func
167#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded
168#define glthread_rwlock_init_func libintl_rwlock_init_func
169#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded
170#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func
171#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded
172#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func
173#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded
174#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func
175#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded
176#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func
177#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded
178#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func
179#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded
180#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func
181#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded
182#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func
183#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded
184#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func
185#define glthread_once_func libintl_once_func
186#define glthread_once_singlethreaded libintl_once_singlethreaded
187#define glthread_once_multithreaded libintl_once_multithreaded
188])
189])
190
191
192dnl Checks for the core files of the intl subdirectory:
193dnl dcigettext.c
194dnl eval-plural.h
195dnl explodename.c
196dnl finddomain.c
197dnl gettextP.h
198dnl gmo.h
199dnl hash-string.h hash-string.c
200dnl l10nflist.c
201dnl libgnuintl.h.in (except the *printf stuff)
202dnl loadinfo.h
203dnl loadmsgcat.c
204dnl localealias.c
205dnl log.c
206dnl plural-exp.h plural-exp.c
207dnl plural.y
208dnl Used by libglocale.
209AC_DEFUN([gt_INTL_SUBDIR_CORE],
210[
211 AC_REQUIRE([AC_C_INLINE])dnl
212 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
213 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
214 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
215 AC_REQUIRE([AC_FUNC_MMAP])dnl
216 AC_REQUIRE([gt_INTDIV0])dnl
217 AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
218 AC_REQUIRE([gt_INTTYPES_PRI])dnl
219 AC_REQUIRE([gl_LOCK])dnl
220
221 AC_LINK_IFELSE(
222 [AC_LANG_PROGRAM(
223 [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]],
224 [[]])],
225 [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
226 [Define to 1 if the compiler understands __builtin_expect.])])
227
228 AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
229 AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
230 stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \
231 argz_stringify argz_next __fsetlocking])
232
233 dnl Use the *_unlocked functions only if they are declared.
234 dnl (because some of them were defined without being declared in Solaris
235 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
236 dnl on Solaris 2.5.1 to run on Solaris 2.6).
237 AC_CHECK_DECLS([feof_unlocked fgets_unlocked], , , [#include <stdio.h>])
238
239 AM_ICONV
240
241 dnl intl/plural.c is generated from intl/plural.y. It requires bison,
242 dnl because plural.y uses bison specific features. It requires at least
243 dnl bison-1.26 because earlier versions generate a plural.c that doesn't
244 dnl compile.
245 dnl bison is only needed for the maintainer (who touches plural.y). But in
246 dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
247 dnl the rule in general Makefile. Now, some people carelessly touch the
248 dnl files or have a broken "make" program, hence the plural.c rule will
249 dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
250 dnl present or too old.
251 AC_CHECK_PROGS([INTLBISON], [bison])
252 if test -z "$INTLBISON"; then
253 ac_verc_fail=yes
254 else
255 dnl Found it, now check the version.
256 AC_MSG_CHECKING([version of bison])
257changequote(<<,>>)dnl
258 ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
259 case $ac_prog_version in
260 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
261 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
262changequote([,])dnl
263 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
264 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
265 esac
266 AC_MSG_RESULT([$ac_prog_version])
267 fi
268 if test $ac_verc_fail = yes; then
269 INTLBISON=:
270 fi
271])
diff --git a/gl/m4/intldir.m4 b/gl/m4/intldir.m4
deleted file mode 100644
index 388ecd6..0000000
--- a/gl/m4/intldir.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1# intldir.m4 serial 2 (gettext-0.18)
2dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16AC_PREREQ([2.52])
17
18dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
19AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
diff --git a/gl/m4/intlmacosx.m4 b/gl/m4/intlmacosx.m4
deleted file mode 100644
index ab97d39..0000000
--- a/gl/m4/intlmacosx.m4
+++ /dev/null
@@ -1,56 +0,0 @@
1# intlmacosx.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2004-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Checks for special options needed on Mac OS X.
17dnl Defines INTL_MACOSX_LIBS.
18AC_DEFUN([gt_INTL_MACOSX],
19[
20 dnl Check for API introduced in Mac OS X 10.2.
21 AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
22 [gt_cv_func_CFPreferencesCopyAppValue],
23 [gt_save_LIBS="$LIBS"
24 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
25 AC_LINK_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <CoreFoundation/CFPreferences.h>]],
28 [[CFPreferencesCopyAppValue(NULL, NULL)]])],
29 [gt_cv_func_CFPreferencesCopyAppValue=yes],
30 [gt_cv_func_CFPreferencesCopyAppValue=no])
31 LIBS="$gt_save_LIBS"])
32 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
33 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
34 [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
35 fi
36 dnl Check for API introduced in Mac OS X 10.3.
37 AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
38 [gt_save_LIBS="$LIBS"
39 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[#include <CoreFoundation/CFLocale.h>]],
43 [[CFLocaleCopyCurrent();]])],
44 [gt_cv_func_CFLocaleCopyCurrent=yes],
45 [gt_cv_func_CFLocaleCopyCurrent=no])
46 LIBS="$gt_save_LIBS"])
47 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
48 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
49 [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
50 fi
51 INTL_MACOSX_LIBS=
52 if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
53 INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
54 fi
55 AC_SUBST([INTL_MACOSX_LIBS])
56])
diff --git a/gl/m4/intmax.m4 b/gl/m4/intmax.m4
deleted file mode 100644
index 18733a5..0000000
--- a/gl/m4/intmax.m4
+++ /dev/null
@@ -1,36 +0,0 @@
1# intmax.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002-2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether the system has the 'intmax_t' type, but don't attempt to
9dnl find a replacement if it is lacking.
10
11AC_DEFUN([gt_TYPE_INTMAX_T],
12[
13 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
15 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
16 [AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[
19#include <stddef.h>
20#include <stdlib.h>
21#if HAVE_STDINT_H_WITH_UINTMAX
22#include <stdint.h>
23#endif
24#if HAVE_INTTYPES_H_WITH_UINTMAX
25#include <inttypes.h>
26#endif
27 ]],
28 [[intmax_t x = -1;
29 return !x;]])],
30 [gt_cv_c_intmax_t=yes],
31 [gt_cv_c_intmax_t=no])])
32 if test $gt_cv_c_intmax_t = yes; then
33 AC_DEFINE([HAVE_INTMAX_T], [1],
34 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
35 fi
36])
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index 6ea7053..ef32e1b 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,5 +1,5 @@
1# intmax_t.m4 serial 8 1# intmax_t.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -19,11 +19,7 @@ AC_DEFUN([gl_AC_TYPE_INTMAX_T],
19 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 19 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
20 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 20 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
21 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then 21 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
22 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 22 AC_DEFINE_UNQUOTED([intmax_t], [long long],
23 test $ac_cv_type_long_long_int = yes \
24 && ac_type='long long' \
25 || ac_type='long'
26 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
27 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.]) 23 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
28 else 24 else
29 AC_DEFINE([HAVE_INTMAX_T], [1], 25 AC_DEFINE([HAVE_INTMAX_T], [1],
@@ -57,11 +53,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
57 AC_DEFINE([HAVE_INTMAX_T], [1], 53 AC_DEFINE([HAVE_INTMAX_T], [1],
58 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 54 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
59 else 55 else
60 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 56 AC_DEFINE_UNQUOTED([intmax_t], [long long],
61 test $ac_cv_type_long_long_int = yes \
62 && ac_type='long long' \
63 || ac_type='long'
64 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
65 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.]) 57 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
66 fi 58 fi
67]) 59])
diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4
deleted file mode 100644
index e5a1e05..0000000
--- a/gl/m4/inttypes-pri.m4
+++ /dev/null
@@ -1,42 +0,0 @@
1# inttypes-pri.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1997-2002, 2006, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ([2.53])
10
11# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
12# macros to non-string values. This is the case on AIX 4.3.3.
13
14AC_DEFUN([gt_INTTYPES_PRI],
15[
16 AC_CHECK_HEADERS([inttypes.h])
17 if test $ac_cv_header_inttypes_h = yes; then
18 AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
19 [gt_cv_inttypes_pri_broken],
20 [
21 AC_COMPILE_IFELSE(
22 [AC_LANG_PROGRAM(
23 [[
24#include <inttypes.h>
25#ifdef PRId32
26char *p = PRId32;
27#endif
28 ]],
29 [[]])],
30 [gt_cv_inttypes_pri_broken=no],
31 [gt_cv_inttypes_pri_broken=yes])
32 ])
33 fi
34 if test "$gt_cv_inttypes_pri_broken" = yes; then
35 AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1],
36 [Define if <inttypes.h> exists and defines unusable PRI* macros.])
37 PRI_MACROS_BROKEN=1
38 else
39 PRI_MACROS_BROKEN=0
40 fi
41 AC_SUBST([PRI_MACROS_BROKEN])
42])
diff --git a/gl/m4/inttypes.m4 b/gl/m4/inttypes.m4
new file mode 100644
index 0000000..bf2eab2
--- /dev/null
+++ b/gl/m4/inttypes.m4
@@ -0,0 +1,180 @@
1# inttypes.m4 serial 36
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price, Bruno Haible.
8dnl Test whether <inttypes.h> is supported or must be substituted.
9
10AC_DEFUN_ONCE([gl_INTTYPES_H],
11[
12 AC_REQUIRE([gl_INTTYPES_INCOMPLETE])
13 gl_INTTYPES_PRI_SCN
14])
15
16AC_DEFUN_ONCE([gl_INTTYPES_INCOMPLETE],
17[
18 AC_REQUIRE([gl_STDINT_H])
19 AC_CHECK_HEADERS_ONCE([inttypes.h])
20
21 dnl Override <inttypes.h> always, so that the portability warnings work.
22 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
23 gl_CHECK_NEXT_HEADERS([inttypes.h])
24
25 AC_REQUIRE([gl_MULTIARCH])
26
27 dnl Check for declarations of anything we want to poison if the
28 dnl corresponding gnulib module is not in use.
29 gl_WARN_ON_USE_PREPARE([[#include <inttypes.h>
30 ]], [imaxabs imaxdiv strtoimax strtoumax])
31
32 AC_REQUIRE([AC_C_RESTRICT])
33])
34
35# Ensure that the PRI* and SCN* macros are defined appropriately.
36AC_DEFUN([gl_INTTYPES_PRI_SCN],
37[
38 PRIPTR_PREFIX=
39 if $GL_GENERATE_STDINT_H; then
40 dnl Using the gnulib <stdint.h>. It defines intptr_t to 'long' or
41 dnl 'long long', depending on _WIN64.
42 AC_COMPILE_IFELSE(
43 [AC_LANG_PROGRAM([[
44 #ifdef _WIN64
45 LLP64
46 #endif
47 ]])
48 ],
49 [PRIPTR_PREFIX='"l"'],
50 [PRIPTR_PREFIX='"ll"'])
51 else
52 dnl Using the system's <stdint.h>.
53 for glpfx in '' l ll I64; do
54 case $glpfx in
55 '') gltype1='int';;
56 l) gltype1='long int';;
57 ll) gltype1='long long int';;
58 I64) gltype1='__int64';;
59 esac
60 AC_COMPILE_IFELSE(
61 [AC_LANG_PROGRAM([[#include <stdint.h>
62 extern intptr_t foo;
63 extern $gltype1 foo;]])],
64 [PRIPTR_PREFIX='"'$glpfx'"'])
65 test -n "$PRIPTR_PREFIX" && break
66 done
67 fi
68 AC_SUBST([PRIPTR_PREFIX])
69
70 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
71 [INT32_MAX_LT_INTMAX_MAX],
72 [defined INT32_MAX && defined INTMAX_MAX],
73 [INT32_MAX < INTMAX_MAX],
74 [sizeof (int) < sizeof (long long int)])
75 if test $APPLE_UNIVERSAL_BUILD = 0; then
76 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
77 [INT64_MAX_EQ_LONG_MAX],
78 [defined INT64_MAX],
79 [INT64_MAX == LONG_MAX],
80 [sizeof (long long int) == sizeof (long int)])
81 else
82 INT64_MAX_EQ_LONG_MAX=-1
83 fi
84 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
85 [UINT32_MAX_LT_UINTMAX_MAX],
86 [defined UINT32_MAX && defined UINTMAX_MAX],
87 [UINT32_MAX < UINTMAX_MAX],
88 [sizeof (unsigned int) < sizeof (unsigned long long int)])
89 if test $APPLE_UNIVERSAL_BUILD = 0; then
90 gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION(
91 [UINT64_MAX_EQ_ULONG_MAX],
92 [defined UINT64_MAX],
93 [UINT64_MAX == ULONG_MAX],
94 [sizeof (unsigned long long int) == sizeof (unsigned long int)])
95 else
96 UINT64_MAX_EQ_ULONG_MAX=-1
97 fi
98])
99
100# Define the symbol $1 to be 1 if the condition is true, 0 otherwise.
101# If $2 is true, the condition is $3; otherwise if long long int is supported
102# approximate the condition with $4; otherwise, assume the condition is false.
103# The condition should work on all C99 platforms; the approximations should be
104# good enough to work on all practical pre-C99 platforms.
105# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants.
106AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION],
107[
108 AC_CACHE_CHECK([whether $3],
109 [gl_cv_test_$1],
110 [AC_COMPILE_IFELSE(
111 [AC_LANG_PROGRAM(
112 [[/* Work also in C++ mode. */
113 #define __STDC_LIMIT_MACROS 1
114
115 /* Work if build is not clean. */
116 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H
117
118 #include <limits.h>
119 #if HAVE_STDINT_H
120 #include <stdint.h>
121 #endif
122
123 #if $2
124 #define CONDITION ($3)
125 #else
126 #define CONDITION ($4)
127 #endif
128 int test[CONDITION ? 1 : -1];]])],
129 [gl_cv_test_$1=yes],
130 [gl_cv_test_$1=no])])
131 if test $gl_cv_test_$1 = yes; then
132 $1=1;
133 else
134 $1=0;
135 fi
136 AC_SUBST([$1])
137])
138
139# gl_INTTYPES_MODULE_INDICATOR([modulename])
140# sets the shell variable that indicates the presence of the given module
141# to a C preprocessor expression that will evaluate to 1.
142# This macro invocation must not occur in macros that are AC_REQUIREd.
143AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR],
144[
145 dnl Ensure to expand the default settings once only.
146 gl_INTTYPES_H_REQUIRE_DEFAULTS
147 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
148])
149
150# Initializes the default values for AC_SUBSTed shell variables.
151# This macro must not be AC_REQUIREd. It must only be invoked, and only
152# outside of macros or in macros that are not AC_REQUIREd.
153AC_DEFUN([gl_INTTYPES_H_REQUIRE_DEFAULTS],
154[
155 m4_defun(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS], [
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXABS])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IMAXDIV])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOIMAX])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUMAX])
160 ])
161 m4_require(GL_MODULE_INDICATOR_PREFIX[_INTTYPES_H_MODULE_INDICATOR_DEFAULTS])
162 AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
163])
164
165AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
166[
167 dnl Assume proper GNU behavior unless another module says otherwise.
168 HAVE_DECL_IMAXABS=1; AC_SUBST([HAVE_DECL_IMAXABS])
169 HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV])
170 HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
171 HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
172 HAVE_IMAXDIV_T=1; AC_SUBST([HAVE_IMAXDIV_T])
173 REPLACE_STRTOIMAX=0; AC_SUBST([REPLACE_STRTOIMAX])
174 REPLACE_STRTOUMAX=0; AC_SUBST([REPLACE_STRTOUMAX])
175 INT32_MAX_LT_INTMAX_MAX=1; AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
176 INT64_MAX_EQ_LONG_MAX='defined _LP64'; AC_SUBST([INT64_MAX_EQ_LONG_MAX])
177 PRIPTR_PREFIX=__PRIPTR_PREFIX; AC_SUBST([PRIPTR_PREFIX])
178 UINT32_MAX_LT_UINTMAX_MAX=1; AC_SUBST([UINT32_MAX_LT_UINTMAX_MAX])
179 UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; AC_SUBST([UINT64_MAX_EQ_ULONG_MAX])
180])
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index 5f05ac5..68c60e9 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
1# inttypes_h.m4 serial 10 1# inttypes_h.m4 serial 10
2dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/langinfo_h.m4 b/gl/m4/langinfo_h.m4
index 73bef8b..b17a526 100644
--- a/gl/m4/langinfo_h.m4
+++ b/gl/m4/langinfo_h.m4
@@ -1,10 +1,10 @@
1# langinfo_h.m4 serial 7 1# langinfo_h.m4 serial 12
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_LANGINFO_H], 7AC_DEFUN_ONCE([gl_LANGINFO_H],
8[ 8[
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 10
@@ -17,13 +17,17 @@ AC_DEFUN([gl_LANGINFO_H],
17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS. 17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
18 HAVE_LANGINFO_CODESET=0 18 HAVE_LANGINFO_CODESET=0
19 HAVE_LANGINFO_T_FMT_AMPM=0 19 HAVE_LANGINFO_T_FMT_AMPM=0
20 HAVE_LANGINFO_ALTMON=0
20 HAVE_LANGINFO_ERA=0 21 HAVE_LANGINFO_ERA=0
21 HAVE_LANGINFO_YESEXPR=0 22 HAVE_LANGINFO_YESEXPR=0
22 AC_CHECK_HEADERS_ONCE([langinfo.h]) 23 AC_CHECK_HEADERS_ONCE([langinfo.h])
23 if test $ac_cv_header_langinfo_h = yes; then 24 if test $ac_cv_header_langinfo_h = yes; then
24 HAVE_LANGINFO_H=1 25 HAVE_LANGINFO_H=1
25 dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing 26 dnl Determine what <langinfo.h> defines.
26 dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3. 27 dnl CODESET is missing on OpenBSD 3.8.
28 dnl ERA etc. are missing on OpenBSD 6.7.
29 dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
30 dnl ALTMON_* are missing on glibc 2.26 and many other systems.
27 AC_CACHE_CHECK([whether langinfo.h defines CODESET], 31 AC_CACHE_CHECK([whether langinfo.h defines CODESET],
28 [gl_cv_header_langinfo_codeset], 32 [gl_cv_header_langinfo_codeset],
29 [AC_COMPILE_IFELSE( 33 [AC_COMPILE_IFELSE(
@@ -48,6 +52,18 @@ int a = T_FMT_AMPM;
48 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then 52 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
49 HAVE_LANGINFO_T_FMT_AMPM=1 53 HAVE_LANGINFO_T_FMT_AMPM=1
50 fi 54 fi
55 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1],
56 [gl_cv_header_langinfo_altmon],
57 [AC_COMPILE_IFELSE(
58 [AC_LANG_PROGRAM([[#include <langinfo.h>
59int a = ALTMON_1;
60]])],
61 [gl_cv_header_langinfo_altmon=yes],
62 [gl_cv_header_langinfo_altmon=no])
63 ])
64 if test $gl_cv_header_langinfo_altmon = yes; then
65 HAVE_LANGINFO_ALTMON=1
66 fi
51 AC_CACHE_CHECK([whether langinfo.h defines ERA], 67 AC_CACHE_CHECK([whether langinfo.h defines ERA],
52 [gl_cv_header_langinfo_era], 68 [gl_cv_header_langinfo_era],
53 [AC_COMPILE_IFELSE( 69 [AC_COMPILE_IFELSE(
@@ -78,6 +94,7 @@ int a = YESEXPR;
78 AC_SUBST([HAVE_LANGINFO_H]) 94 AC_SUBST([HAVE_LANGINFO_H])
79 AC_SUBST([HAVE_LANGINFO_CODESET]) 95 AC_SUBST([HAVE_LANGINFO_CODESET])
80 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM]) 96 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
97 AC_SUBST([HAVE_LANGINFO_ALTMON])
81 AC_SUBST([HAVE_LANGINFO_ERA]) 98 AC_SUBST([HAVE_LANGINFO_ERA])
82 AC_SUBST([HAVE_LANGINFO_YESEXPR]) 99 AC_SUBST([HAVE_LANGINFO_YESEXPR])
83 100
@@ -87,18 +104,33 @@ int a = YESEXPR;
87 ]], [nl_langinfo]) 104 ]], [nl_langinfo])
88]) 105])
89 106
107# gl_LANGINFO_MODULE_INDICATOR([modulename])
108# sets the shell variable that indicates the presence of the given module
109# to a C preprocessor expression that will evaluate to 1.
110# This macro invocation must not occur in macros that are AC_REQUIREd.
90AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR], 111AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
91[ 112[
92 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 113 dnl Ensure to expand the default settings once only.
93 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 114 gl_LANGINFO_H_REQUIRE_DEFAULTS
94 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 115 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
95 dnl Define it also as a C macro, for the benefit of the unit tests. 116 dnl Define it also as a C macro, for the benefit of the unit tests.
96 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 117 gl_MODULE_INDICATOR_FOR_TESTS([$1])
97]) 118])
98 119
120# Initializes the default values for AC_SUBSTed shell variables.
121# This macro must not be AC_REQUIREd. It must only be invoked, and only
122# outside of macros or in macros that are not AC_REQUIREd.
123AC_DEFUN([gl_LANGINFO_H_REQUIRE_DEFAULTS],
124[
125 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS], [
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NL_LANGINFO])
127 ])
128 m4_require(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS])
129 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
130])
131
99AC_DEFUN([gl_LANGINFO_H_DEFAULTS], 132AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
100[ 133[
101 GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO])
102 dnl Assume proper GNU behavior unless another module says otherwise. 134 dnl Assume proper GNU behavior unless another module says otherwise.
103 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO]) 135 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
104 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO]) 136 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
index 1e605e3..7fb81b8 100644
--- a/gl/m4/largefile.m4
+++ b/gl/m4/largefile.m4
@@ -1,104 +1,319 @@
1# Enable large files on systems where this is not the default. 1# Enable large files on systems where this is not the default.
2# Enable support for files on Linux file systems with 64-bit inode numbers.
2 3
3# Copyright 1992-1996, 1998-2013 Free Software Foundation, Inc. 4# Copyright 1992-1996, 1998-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
7 8
8# The following implementation works around a problem in autoconf <= 2.69; 9# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO:
10# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this
11# setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko
12# and ftello in C++ mode as well.
13# Fixed in Autoconf 2.72, which has AC_SYS_YEAR2038.
14AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
15 m4_ifndef([AC_SYS_YEAR2038], [[
16 AC_REQUIRE([AC_CANONICAL_HOST])
17 AC_FUNC_FSEEKO
18 case "$host_os" in
19 hpux*)
20 AC_DEFINE([_LARGEFILE_SOURCE], [1],
21 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
22 ;;
23 esac
24 ]])
25)
26
27# Work around a problem in autoconf <= 2.69:
9# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5, 28# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
10# or configures them incorrectly in some cases. 29# or configures them incorrectly in some cases.
11m4_version_prereq([2.70], [] ,[ 30m4_version_prereq([2.70], [], [
12 31
13# _AC_SYS_LARGEFILE_TEST_INCLUDES 32# _AC_SYS_LARGEFILE_TEST_INCLUDES
14# ------------------------------- 33# -------------------------------
15m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], 34m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
16[@%:@include <sys/types.h> 35[#include <sys/types.h>
17 /* Check that off_t can represent 2**63 - 1 correctly. 36 /* Check that off_t can represent 2**63 - 1 correctly.
18 We can't simply define LARGE_OFF_T to be 9223372036854775807, 37 We can't simply define LARGE_OFF_T to be 9223372036854775807,
19 since some C++ compilers masquerading as C compilers 38 since some C++ compilers masquerading as C compilers
20 incorrectly reject 9223372036854775807. */ 39 incorrectly reject 9223372036854775807. */
21@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) 40#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
22 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 41 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
23 && LARGE_OFF_T % 2147483647 == 1) 42 && LARGE_OFF_T % 2147483647 == 1)
24 ? 1 : -1]];[]dnl 43 ? 1 : -1]];[]dnl
25]) 44])
45])# m4_version_prereq 2.70
46
47# Support AC_SYS_YEAR2038, even if Autoconf 2.71 or earlier.
48# This code is taken from Autoconf master.
49m4_ifndef([AC_SYS_YEAR2038], [
50
51# _AC_SYS_YEAR2038_TEST_CODE
52# --------------------------
53# C code used to probe for time_t that can represent time points more
54# than 2**31 - 1 seconds after the epoch. With the usual Unix epoch,
55# these correspond to dates after 2038-01-18 22:14:07 +0000 (Gregorian),
56# hence the name.
57AC_DEFUN([_AC_SYS_YEAR2038_TEST_CODE],
58[[
59 #include <time.h>
60 /* Check that time_t can represent 2**32 - 1 correctly. */
61 #define LARGE_TIME_T \\
62 ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))
63 int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535
64 && LARGE_TIME_T % 65537 == 0)
65 ? 1 : -1];
66]])
67
68# _AC_SYS_YEAR2038_OPTIONS
69# ------------------------
70# List of known ways to enable support for large time_t. If you change
71# this list you probably also need to change the AS_CASE at the end of
72# _AC_SYS_YEAR2038_PROBE.
73m4_define([_AC_SYS_YEAR2038_OPTIONS], m4_normalize(
74 ["none needed"] dnl 64-bit and newer 32-bit Unix
75 ["-D_TIME_BITS=64"] dnl glibc 2.34 with some 32-bit ABIs
76 ["-D__MINGW_USE_VC2005_COMPAT"] dnl 32-bit MinGW
77 ["-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"]
78 dnl 32-bit MinGW (misconfiguration)
79))
80
81# _AC_SYS_YEAR2038_PROBE([IF-NOT-DETECTED])
82# -----------------------------------------
83# Subroutine of AC_SYS_YEAR2038. Probe for time_t that can represent
84# time points more than 2**31 - 1 seconds after the epoch (dates after
85# 2038-01-18, see above) and set the cache variable ac_cv_sys_year2038_opts
86# to one of the values in the _AC_SYS_YEAR2038_OPTIONS list, or to
87# "support not detected" if none of them worked. Then, set compilation
88# options and #defines as necessary to enable large time_t support.
89#
90# Note that we do not test whether mktime, localtime, etc. handle
91# large values of time_t correctly, as that would require use of
92# AC_TRY_RUN. Note also that some systems only support large time_t
93# together with large off_t.
94#
95# If support is not detected, the behavior depends on which of the
96# top-level AC_SYS_YEAR2038 macros was used (see below).
97#
98# If you change this macro you may also need to change
99# _AC_SYS_YEAR2038_OPTIONS.
100AC_DEFUN([_AC_SYS_YEAR2038_PROBE],
101[AC_CACHE_CHECK([for $CC option to enable timestamps after Jan 2038],
102 [ac_cv_sys_year2038_opts],
103 [ac_save_CPPFLAGS="$CPPFLAGS"
104 ac_opt_found=no
105 for ac_opt in _AC_SYS_YEAR2038_OPTIONS; do
106 AS_IF([test x"$ac_opt" != x"none needed"],
107 [CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"])
108 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_YEAR2038_TEST_CODE])],
109 [ac_cv_sys_year2038_opts="$ac_opt"
110 ac_opt_found=yes])
111 test $ac_opt_found = no || break
112 done
113 CPPFLAGS="$ac_save_CPPFLAGS"
114 test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected"])
115
116ac_have_year2038=yes
117AS_CASE([$ac_cv_sys_year2038_opts],
118 ["none needed"], [],
119 ["support not detected"],
120 [ac_have_year2038=no
121 AS_CASE([$enable_year2038],
122 [yes],
123 [# If we're not cross compiling and 'touch' works with a large
124 # timestamp, then we can presume the system supports wider time_t
125 # *somehow* and we just weren't able to detect it. One common
126 # case that we deliberately *don't* probe for is a system that
127 # supports both 32- and 64-bit ABIs but only the 64-bit ABI offers
128 # wide time_t. (It would be inappropriate for us to override an
129 # intentional use of -m32.) Error out, demanding use of
130 # --disable-year2038 if this is intentional.
131 AS_IF([test $cross_compiling = no],
132 [AS_IF([TZ=UTC0 touch -t 210602070628.15 conftest.time 2>/dev/null],
133 [AS_CASE([`TZ=UTC0 LC_ALL=C ls -l conftest.time 2>/dev/null`],
134 [*'Feb 7 2106'* | *'Feb 7 17:10'*],
135 [AC_MSG_FAILURE(m4_text_wrap(
136 [this system appears to support timestamps after January 2038,
137 but no mechanism for enabling wide 'time_t' was detected.
138 Did you mean to build a 64-bit binary? (e.g. 'CC="${CC} -m64"'.)
139 To proceed with 32-bit time_t, configure with '--disable-year2038'.],
140 [], [], [55]))])])])])],
141
142 ["-D_TIME_BITS=64"],
143 [AC_DEFINE([_TIME_BITS], [64],
144 [Number of bits in time_t, on hosts where this is settable.])],
145
146 ["-D__MINGW_USE_VC2005_COMPAT=1"],
147 [AC_DEFINE([__MINGW_USE_VC2005_COMPAT], [1],
148 [Define to 1 on platforms where this makes time_t a 64-bit type.])],
149
150 ["-U_USE_32_BIT_TIME_T"*],
151 [AC_MSG_FAILURE(m4_text_wrap(
152 [the 'time_t' type is currently forced to be 32-bit.
153 It will stop working after January 2038.
154 Remove _USE_32BIT_TIME_T from the compiler flags.],
155 [], [], [55]))],
156
157 [AC_MSG_ERROR(
158 [internal error: bad value for \$ac_cv_sys_year2038_opts])])
159])
160
161# _AC_SYS_YEAR2038_ENABLE
162# -----------------------
163# Subroutine of AC_SYS_YEAR2038 and _AC_SYS_YEAR2038_OPT_IN.
164# Depending on which of the YEAR2038 macros was used, add either an
165# --enable-year2038, or a --disable-year2038, or no option at all to
166# the configure script. Note that this is expanded very late and
167# therefore there cannot be any code in the AC_ARG_ENABLE. The
168# default value for enable_year2038 is emitted unconditionally
169# because the generated code always looks at this variable.
170m4_define([_AC_SYS_YEAR2038_ENABLE],
171[m4_divert_text([DEFAULTS],
172 m4_provide_if([AC_SYS_YEAR2038],
173 [enable_year2038=yes],
174 [enable_year2038=no]))]dnl
175[AC_ARG_ENABLE([year2038],
176 m4_provide_if([AC_SYS_YEAR2038],
177 [AS_HELP_STRING([--disable-year2038],
178 [do not support timestamps after 2038])],
179 [AS_HELP_STRING([--enable-year2038],
180 [support timestamps after 2038])]))])
181
182# _AC_SYS_YEAR2038_OPT_IN
183# -----------------------
184# If the --enable-year2038 option is given to configure, attempt to
185# detect and activate support for large time_t on 32-bit systems.
186# This macro is automatically invoked by AC_SYS_LARGEFILE when large
187# *file* support is detected. It does not AC_REQUIRE AC_SYS_LARGEFILE
188# to avoid a dependency loop, and is therefore unsafe to expose as a
189# documented macro.
190AC_DEFUN([_AC_SYS_YEAR2038_OPT_IN],
191[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
192 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
193 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
194])])
195
196# AC_SYS_YEAR2038
197# ---------------
198# Attempt to detect and activate support for large time_t.
199# On systems where time_t is not always 64 bits, this probe can be
200# skipped by passing the --disable-year2038 option to configure.
201AC_DEFUN([AC_SYS_YEAR2038],
202[AC_REQUIRE([AC_SYS_LARGEFILE])]dnl
203[m4_provide_if([_AC_SYS_YEAR2038_PROBE], [], [dnl
204 AS_IF([test "$enable_year2038" != no], [_AC_SYS_YEAR2038_PROBE])
205 AC_CONFIG_COMMANDS_PRE([_AC_SYS_YEAR2038_ENABLE])
206])])
207
208# _AC_SYS_LARGEFILE_TEST_CODE
209# ---------------------------
210# C code used to probe for large file support.
211m4_define([_AC_SYS_LARGEFILE_TEST_CODE],
212[@%:@include <sys/types.h>
213 /* Check that off_t can represent 2**63 - 1 correctly.
214 We can't simply define LARGE_OFF_T to be 9223372036854775807,
215 since some C++ compilers masquerading as C compilers
216 incorrectly reject 9223372036854775807. */
217@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31))
218 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
219 && LARGE_OFF_T % 2147483647 == 1)
220 ? 1 : -1]];[]dnl
221])
222
223# _AC_SYS_LARGEFILE_OPTIONS
224# -------------------------
225# List of known ways to enable support for large files. If you change
226# this list you probably also need to change the AS_CASE at the end of
227# _AC_SYS_LARGEFILE_PROBE.
228m4_define([_AC_SYS_LARGEFILE_OPTIONS], m4_normalize(
229 ["none needed"] dnl Most current systems
230 ["-D_FILE_OFFSET_BITS=64"] dnl X/Open LFS spec
231 ["-D_LARGE_FILES=1"] dnl AIX (which versions?)
232 ["-n32"] dnl Irix 6.2 w/ SGI compiler
233))
234
235# _AC_SYS_LARGEFILE_PROBE
236# -----------------------
237# Subroutine of AC_SYS_LARGEFILE. Probe for large file support and set
238# the cache variable ac_cv_sys_largefile_opts to one of the values in
239# the _AC_SYS_LARGEFILE_OPTIONS list, or to "support not detected" if
240# none of the options in that list worked. Then, set compilation
241# options and #defines as necessary to enable large file support.
242#
243# If large file support is not detected, the behavior depends on which of
244# the top-level AC_SYS_LARGEFILE macros was used (see below).
245#
246# If you change this macro you may also need to change
247# _AC_SYS_LARGEFILE_OPTIONS.
248AC_DEFUN([_AC_SYS_LARGEFILE_PROBE],
249[AC_CACHE_CHECK([for $CC option to enable large file support],
250 [ac_cv_sys_largefile_opts],
251 [ac_save_CC="$CC"
252 ac_opt_found=no
253 for ac_opt in _AC_SYS_LARGEFILE_OPTIONS; do
254 AS_IF([test x"$ac_opt" != x"none needed"],
255 [CC="$ac_save_CC $ac_opt"])
256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_CODE])],
257 [ac_cv_sys_largefile_opts="$ac_opt"
258 ac_opt_found=yes])
259 test $ac_opt_found = no || break
260 done
261 CC="$ac_save_CC"
262 test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected"])
263
264ac_have_largefile=yes
265AS_CASE([$ac_cv_sys_largefile_opts],
266 ["none needed"], [],
267 ["support not detected"],
268 [ac_have_largefile=no],
269
270 ["-D_FILE_OFFSET_BITS=64"],
271 [AC_DEFINE([_FILE_OFFSET_BITS], [64],
272 [Number of bits in a file offset, on hosts where this is settable.])],
273
274 ["-D_LARGE_FILES=1"],
275 [AC_DEFINE([_LARGE_FILES], [1],
276 [Define to 1 on platforms where this makes off_t a 64-bit type.])],
26 277
278 ["-n32"],
279 [CC="$CC -n32"],
27 280
28# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, 281 [AC_MSG_ERROR(
29# CACHE-VAR, 282 [internal error: bad value for \$ac_cv_sys_largefile_opts])])
30# DESCRIPTION,
31# PROLOGUE, [FUNCTION-BODY])
32# --------------------------------------------------------
33m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
34[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
35[while :; do
36 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
37 [AC_LANG_PROGRAM([$5], [$6])],
38 [$3=no; break])
39 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
40 [AC_LANG_PROGRAM([@%:@define $1 $2
41$5], [$6])],
42 [$3=$2; break])
43 $3=unknown
44 break
45done])
46case $$3 in #(
47 no | unknown) ;;
48 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
49esac
50rm -rf conftest*[]dnl
51])# _AC_SYS_LARGEFILE_MACRO_VALUE
52 283
284_AC_SYS_YEAR2038_OPT_IN
285])
286
287# _AC_SYS_LARGEFILE_ENABLE
288# ------------------------
289# Subroutine of AC_SYS_LARGEFILE. Note that this
290# is expanded very late and therefore there cannot be any code in the
291# AC_ARG_ENABLE. The default value for enable_largefile is emitted
292# unconditionally because the generated shell code always looks at
293# this variable.
294m4_define([_AC_SYS_LARGEFILE_ENABLE],
295[m4_divert_text([DEFAULTS],
296 enable_largefile=yes)]dnl
297[AC_ARG_ENABLE([largefile],
298 [AS_HELP_STRING([--disable-largefile], [omit support for large files])])])
53 299
54# AC_SYS_LARGEFILE 300# AC_SYS_LARGEFILE
55# ---------------- 301# ----------------
56# By default, many hosts won't let programs access large files; 302# By default, many hosts won't let programs access large files;
57# one must use special compiler options to get large-file access to work. 303# one must use special compiler options to get large-file access to work.
58# For more details about this brain damage please see: 304# For more details about this brain damage please see:
59# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html 305# http://www.unix.org/version2/whatsnew/lfs20mar.html
306# Additionally, on Linux file systems with 64-bit inodes a file that happens
307# to have a 64-bit inode number cannot be accessed by 32-bit applications on
308# Linux x86/x86_64. This can occur with file systems such as XFS and NFS.
309# This macro allows configuration to continue if the system doesn't support
310# large files.
60AC_DEFUN([AC_SYS_LARGEFILE], 311AC_DEFUN([AC_SYS_LARGEFILE],
61[AC_ARG_ENABLE(largefile, 312[m4_provide_if([_AC_SYS_LARGEFILE_PROBE], [], [dnl
62 [ --disable-largefile omit support for large files]) 313 AS_IF([test "$enable_largefile" != no], [_AC_SYS_LARGEFILE_PROBE])
63if test "$enable_largefile" != no; then 314 AC_CONFIG_COMMANDS_PRE([_AC_SYS_LARGEFILE_ENABLE])
64 315])])
65 AC_CACHE_CHECK([for special C compiler options needed for large files], 316])# m4_ifndef AC_SYS_YEAR2038
66 ac_cv_sys_largefile_CC,
67 [ac_cv_sys_largefile_CC=no
68 if test "$GCC" != yes; then
69 ac_save_CC=$CC
70 while :; do
71 # IRIX 6.2 and later do not support large files by default,
72 # so use the C compiler's -n32 option if that helps.
73 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
74 AC_COMPILE_IFELSE([], [break])
75 CC="$CC -n32"
76 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
77 break
78 done
79 CC=$ac_save_CC
80 rm -f conftest.$ac_ext
81 fi])
82 if test "$ac_cv_sys_largefile_CC" != no; then
83 CC=$CC$ac_cv_sys_largefile_CC
84 fi
85
86 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
87 ac_cv_sys_file_offset_bits,
88 [Number of bits in a file offset, on hosts where this is settable.],
89 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
90 if test $ac_cv_sys_file_offset_bits = unknown; then
91 _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
92 ac_cv_sys_large_files,
93 [Define for large files, on AIX-style hosts.],
94 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
95 fi
96
97 AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
98 [Enable large inode numbers on Mac OS X 10.5.])
99fi
100])# AC_SYS_LARGEFILE
101])# m4_version_prereq 2.70
102 317
103# Enable large files on systems where this is implemented by Gnulib, not by the 318# Enable large files on systems where this is implemented by Gnulib, not by the
104# system headers. 319# system headers.
@@ -126,9 +341,24 @@ AC_DEFUN([gl_LARGEFILE],
126 else 341 else
127 WINDOWS_64_BIT_OFF_T=0 342 WINDOWS_64_BIT_OFF_T=0
128 fi 343 fi
129 dnl But all native Windows platforms (including mingw64) have a 32-bit 344 dnl Some mingw versions define, if _FILE_OFFSET_BITS=64, 'struct stat'
130 dnl st_size member in 'struct stat'. 345 dnl to 'struct _stat32i64' or 'struct _stat64' (depending on
131 WINDOWS_64_BIT_ST_SIZE=1 346 dnl _USE_32BIT_TIME_T), which has a 32-bit st_size member.
347 AC_CACHE_CHECK([for 64-bit st_size], [gl_cv_member_st_size_64],
348 [AC_COMPILE_IFELSE(
349 [AC_LANG_PROGRAM(
350 [[#include <sys/types.h>
351 struct stat buf;
352 int verify_st_size_size[sizeof (buf.st_size) >= 8 ? 1 : -1];
353 ]],
354 [[]])],
355 [gl_cv_member_st_size_64=yes], [gl_cv_member_st_size_64=no])
356 ])
357 if test $gl_cv_member_st_size_64 = no; then
358 WINDOWS_64_BIT_ST_SIZE=1
359 else
360 WINDOWS_64_BIT_ST_SIZE=0
361 fi
132 ;; 362 ;;
133 *) 363 *)
134 dnl Nothing to do on gnulib's side. 364 dnl Nothing to do on gnulib's side.
diff --git a/gl/m4/lcmessage.m4 b/gl/m4/lcmessage.m4
deleted file mode 100644
index d62a175..0000000
--- a/gl/m4/lcmessage.m4
+++ /dev/null
@@ -1,35 +0,0 @@
1# lcmessage.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1995-2002, 2004-2005, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl
8dnl This file can can be used in projects which are not available under
9dnl the GNU General Public License or the GNU Library General Public
10dnl License but which still want to provide support for the GNU gettext
11dnl functionality.
12dnl Please note that the actual code of the GNU gettext library is covered
13dnl by the GNU Library General Public License, and the rest of the GNU
14dnl gettext package package is covered by the GNU General Public License.
15dnl They are *not* in the public domain.
16
17dnl Authors:
18dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
19
20# Check whether LC_MESSAGES is available in <locale.h>.
21
22AC_DEFUN([gt_LC_MESSAGES],
23[
24 AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
25 [AC_LINK_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <locale.h>]],
28 [[return LC_MESSAGES]])],
29 [gt_cv_val_LC_MESSAGES=yes],
30 [gt_cv_val_LC_MESSAGES=no])])
31 if test $gt_cv_val_LC_MESSAGES = yes; then
32 AC_DEFINE([HAVE_LC_MESSAGES], [1],
33 [Define if your <locale.h> file defines LC_MESSAGES.])
34 fi
35])
diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4
deleted file mode 100644
index c145e47..0000000
--- a/gl/m4/lib-ld.m4
+++ /dev/null
@@ -1,119 +0,0 @@
1# lib-ld.m4 serial 6
2dnl Copyright (C) 1996-2003, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Subroutines of libtool.m4,
8dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9dnl collision with libtool.m4.
10
11dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
12AC_DEFUN([AC_LIB_PROG_LD_GNU],
13[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
14[# I'd rather use --version here, but apparently some GNU lds only accept -v.
15case `$LD -v 2>&1 </dev/null` in
16*GNU* | *'with BFD'*)
17 acl_cv_prog_gnu_ld=yes
18 ;;
19*)
20 acl_cv_prog_gnu_ld=no
21 ;;
22esac])
23with_gnu_ld=$acl_cv_prog_gnu_ld
24])
25
26dnl From libtool-2.4. Sets the variable LD.
27AC_DEFUN([AC_LIB_PROG_LD],
28[AC_REQUIRE([AC_PROG_CC])dnl
29AC_REQUIRE([AC_CANONICAL_HOST])dnl
30
31AC_ARG_WITH([gnu-ld],
32 [AS_HELP_STRING([--with-gnu-ld],
33 [assume the C compiler uses GNU ld [default=no]])],
34 [test "$withval" = no || with_gnu_ld=yes],
35 [with_gnu_ld=no])dnl
36
37# Prepare PATH_SEPARATOR.
38# The user is always right.
39if test "${PATH_SEPARATOR+set}" != set; then
40 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
41 # contains only /bin. Note that ksh looks also at the FPATH variable,
42 # so we have to set that as well for the test.
43 PATH_SEPARATOR=:
44 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
45 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
46 || PATH_SEPARATOR=';'
47 }
48fi
49
50ac_prog=ld
51if test "$GCC" = yes; then
52 # Check if gcc -print-prog-name=ld gives a path.
53 AC_MSG_CHECKING([for ld used by $CC])
54 case $host in
55 *-*-mingw*)
56 # gcc leaves a trailing carriage return which upsets mingw
57 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
58 *)
59 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
60 esac
61 case $ac_prog in
62 # Accept absolute paths.
63 [[\\/]]* | ?:[[\\/]]*)
64 re_direlt='/[[^/]][[^/]]*/\.\./'
65 # Canonicalize the pathname of ld
66 ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
67 while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
68 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
69 done
70 test -z "$LD" && LD="$ac_prog"
71 ;;
72 "")
73 # If it fails, then pretend we aren't using GCC.
74 ac_prog=ld
75 ;;
76 *)
77 # If it is relative, then search for the first ld in PATH.
78 with_gnu_ld=unknown
79 ;;
80 esac
81elif test "$with_gnu_ld" = yes; then
82 AC_MSG_CHECKING([for GNU ld])
83else
84 AC_MSG_CHECKING([for non-GNU ld])
85fi
86AC_CACHE_VAL([acl_cv_path_LD],
87[if test -z "$LD"; then
88 acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
89 for ac_dir in $PATH; do
90 IFS="$acl_save_ifs"
91 test -z "$ac_dir" && ac_dir=.
92 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
93 acl_cv_path_LD="$ac_dir/$ac_prog"
94 # Check to see if the program is GNU ld. I'd rather use --version,
95 # but apparently some variants of GNU ld only accept -v.
96 # Break only if it was the GNU/non-GNU ld that we prefer.
97 case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
98 *GNU* | *'with BFD'*)
99 test "$with_gnu_ld" != no && break
100 ;;
101 *)
102 test "$with_gnu_ld" != yes && break
103 ;;
104 esac
105 fi
106 done
107 IFS="$acl_save_ifs"
108else
109 acl_cv_path_LD="$LD" # Let the user override the test with a path.
110fi])
111LD="$acl_cv_path_LD"
112if test -n "$LD"; then
113 AC_MSG_RESULT([$LD])
114else
115 AC_MSG_RESULT([no])
116fi
117test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
118AC_LIB_PROG_LD_GNU
119])
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
deleted file mode 100644
index 073f040..0000000
--- a/gl/m4/lib-link.m4
+++ /dev/null
@@ -1,777 +0,0 @@
1# lib-link.m4 serial 26 (gettext-0.18.2)
2dnl Copyright (C) 2001-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_PREREQ([2.54])
10
11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12dnl the libraries corresponding to explicit and implicit dependencies.
13dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14dnl augments the CPPFLAGS variable.
15dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
17AC_DEFUN([AC_LIB_LINKFLAGS],
18[
19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20 AC_REQUIRE([AC_LIB_RPATH])
21 pushdef([Name],[m4_translit([$1],[./+-], [____])])
22 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29 ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
30 ])
31 LIB[]NAME="$ac_cv_lib[]Name[]_libs"
32 LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
33 INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
34 LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
36 AC_SUBST([LIB]NAME)
37 AC_SUBST([LTLIB]NAME)
38 AC_SUBST([LIB]NAME[_PREFIX])
39 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40 dnl results of this search when this library appears as a dependency.
41 HAVE_LIB[]NAME=yes
42 popdef([NAME])
43 popdef([Name])
44])
45
46dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
47dnl searches for libname and the libraries corresponding to explicit and
48dnl implicit dependencies, together with the specified include files and
49dnl the ability to compile and link the specified testcode. The missing-message
50dnl defaults to 'no' and may contain additional hints for the user.
51dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
52dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
53dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
54dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
55dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
56dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
57AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
58[
59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60 AC_REQUIRE([AC_LIB_RPATH])
61 pushdef([Name],[m4_translit([$1],[./+-], [____])])
62 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
64
65 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
66 dnl accordingly.
67 AC_LIB_LINKFLAGS_BODY([$1], [$2])
68
69 dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
70 dnl because if the user has installed lib[]Name and not disabled its use
71 dnl via --without-lib[]Name-prefix, he wants to use it.
72 ac_save_CPPFLAGS="$CPPFLAGS"
73 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
74
75 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
76 ac_save_LIBS="$LIBS"
77 dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
78 dnl because these -l options might require -L options that are present in
79 dnl LIBS. -l options benefit only from the -L options listed before it.
80 dnl Otherwise, add it to the front of LIBS, because it may be a static
81 dnl library that depends on another static library that is present in LIBS.
82 dnl Static libraries benefit only from the static libraries listed after
83 dnl it.
84 case " $LIB[]NAME" in
85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86 *) LIBS="$LIB[]NAME $LIBS" ;;
87 esac
88 AC_LINK_IFELSE(
89 [AC_LANG_PROGRAM([[$3]], [[$4]])],
90 [ac_cv_lib[]Name=yes],
91 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
92 LIBS="$ac_save_LIBS"
93 ])
94 if test "$ac_cv_lib[]Name" = yes; then
95 HAVE_LIB[]NAME=yes
96 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
97 AC_MSG_CHECKING([how to link with lib[]$1])
98 AC_MSG_RESULT([$LIB[]NAME])
99 else
100 HAVE_LIB[]NAME=no
101 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
102 dnl $INC[]NAME either.
103 CPPFLAGS="$ac_save_CPPFLAGS"
104 LIB[]NAME=
105 LTLIB[]NAME=
106 LIB[]NAME[]_PREFIX=
107 fi
108 AC_SUBST([HAVE_LIB]NAME)
109 AC_SUBST([LIB]NAME)
110 AC_SUBST([LTLIB]NAME)
111 AC_SUBST([LIB]NAME[_PREFIX])
112 popdef([NAME])
113 popdef([Name])
114])
115
116dnl Determine the platform dependent parameters needed to use rpath:
117dnl acl_libext,
118dnl acl_shlibext,
119dnl acl_libname_spec,
120dnl acl_library_names_spec,
121dnl acl_hardcode_libdir_flag_spec,
122dnl acl_hardcode_libdir_separator,
123dnl acl_hardcode_direct,
124dnl acl_hardcode_minus_L.
125AC_DEFUN([AC_LIB_RPATH],
126[
127 dnl Tell automake >= 1.10 to complain if config.rpath is missing.
128 m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
129 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
130 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
131 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
132 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
133 AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
134 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
135 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
136 . ./conftest.sh
137 rm -f ./conftest.sh
138 acl_cv_rpath=done
139 ])
140 wl="$acl_cv_wl"
141 acl_libext="$acl_cv_libext"
142 acl_shlibext="$acl_cv_shlibext"
143 acl_libname_spec="$acl_cv_libname_spec"
144 acl_library_names_spec="$acl_cv_library_names_spec"
145 acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
146 acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
147 acl_hardcode_direct="$acl_cv_hardcode_direct"
148 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
149 dnl Determine whether the user wants rpath handling at all.
150 AC_ARG_ENABLE([rpath],
151 [ --disable-rpath do not hardcode runtime library paths],
152 :, enable_rpath=yes)
153])
154
155dnl AC_LIB_FROMPACKAGE(name, package)
156dnl declares that libname comes from the given package. The configure file
157dnl will then not have a --with-libname-prefix option but a
158dnl --with-package-prefix option. Several libraries can come from the same
159dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
160dnl macro call that searches for libname.
161AC_DEFUN([AC_LIB_FROMPACKAGE],
162[
163 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
164 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
165 define([acl_frompackage_]NAME, [$2])
166 popdef([NAME])
167 pushdef([PACK],[$2])
168 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
169 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
170 define([acl_libsinpackage_]PACKUP,
171 m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
172 popdef([PACKUP])
173 popdef([PACK])
174])
175
176dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
177dnl the libraries corresponding to explicit and implicit dependencies.
178dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
179dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
180dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
181AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
182[
183 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
184 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
185 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
186 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
187 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
188 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
189 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
190 dnl Autoconf >= 2.61 supports dots in --with options.
191 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
192 dnl By default, look in $includedir and $libdir.
193 use_additional=yes
194 AC_LIB_WITH_FINAL_PREFIX([
195 eval additional_includedir=\"$includedir\"
196 eval additional_libdir=\"$libdir\"
197 ])
198 AC_ARG_WITH(P_A_C_K[-prefix],
199[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
200 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
201[
202 if test "X$withval" = "Xno"; then
203 use_additional=no
204 else
205 if test "X$withval" = "X"; then
206 AC_LIB_WITH_FINAL_PREFIX([
207 eval additional_includedir=\"$includedir\"
208 eval additional_libdir=\"$libdir\"
209 ])
210 else
211 additional_includedir="$withval/include"
212 additional_libdir="$withval/$acl_libdirstem"
213 if test "$acl_libdirstem2" != "$acl_libdirstem" \
214 && ! test -d "$withval/$acl_libdirstem"; then
215 additional_libdir="$withval/$acl_libdirstem2"
216 fi
217 fi
218 fi
219])
220 dnl Search the library and its dependencies in $additional_libdir and
221 dnl $LDFLAGS. Using breadth-first-seach.
222 LIB[]NAME=
223 LTLIB[]NAME=
224 INC[]NAME=
225 LIB[]NAME[]_PREFIX=
226 dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
227 dnl computed. So it has to be reset here.
228 HAVE_LIB[]NAME=
229 rpathdirs=
230 ltrpathdirs=
231 names_already_handled=
232 names_next_round='$1 $2'
233 while test -n "$names_next_round"; do
234 names_this_round="$names_next_round"
235 names_next_round=
236 for name in $names_this_round; do
237 already_handled=
238 for n in $names_already_handled; do
239 if test "$n" = "$name"; then
240 already_handled=yes
241 break
242 fi
243 done
244 if test -z "$already_handled"; then
245 names_already_handled="$names_already_handled $name"
246 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
247 dnl or AC_LIB_HAVE_LINKFLAGS call.
248 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
249 eval value=\"\$HAVE_LIB$uppername\"
250 if test -n "$value"; then
251 if test "$value" = yes; then
252 eval value=\"\$LIB$uppername\"
253 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
254 eval value=\"\$LTLIB$uppername\"
255 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
256 else
257 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
258 dnl that this library doesn't exist. So just drop it.
259 :
260 fi
261 else
262 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
263 dnl and the already constructed $LIBNAME/$LTLIBNAME.
264 found_dir=
265 found_la=
266 found_so=
267 found_a=
268 eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
269 if test -n "$acl_shlibext"; then
270 shrext=".$acl_shlibext" # typically: shrext=.so
271 else
272 shrext=
273 fi
274 if test $use_additional = yes; then
275 dir="$additional_libdir"
276 dnl The same code as in the loop below:
277 dnl First look for a shared library.
278 if test -n "$acl_shlibext"; then
279 if test -f "$dir/$libname$shrext"; then
280 found_dir="$dir"
281 found_so="$dir/$libname$shrext"
282 else
283 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
284 ver=`(cd "$dir" && \
285 for f in "$libname$shrext".*; do echo "$f"; done \
286 | sed -e "s,^$libname$shrext\\\\.,," \
287 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
288 | sed 1q ) 2>/dev/null`
289 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
290 found_dir="$dir"
291 found_so="$dir/$libname$shrext.$ver"
292 fi
293 else
294 eval library_names=\"$acl_library_names_spec\"
295 for f in $library_names; do
296 if test -f "$dir/$f"; then
297 found_dir="$dir"
298 found_so="$dir/$f"
299 break
300 fi
301 done
302 fi
303 fi
304 fi
305 dnl Then look for a static library.
306 if test "X$found_dir" = "X"; then
307 if test -f "$dir/$libname.$acl_libext"; then
308 found_dir="$dir"
309 found_a="$dir/$libname.$acl_libext"
310 fi
311 fi
312 if test "X$found_dir" != "X"; then
313 if test -f "$dir/$libname.la"; then
314 found_la="$dir/$libname.la"
315 fi
316 fi
317 fi
318 if test "X$found_dir" = "X"; then
319 for x in $LDFLAGS $LTLIB[]NAME; do
320 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
321 case "$x" in
322 -L*)
323 dir=`echo "X$x" | sed -e 's/^X-L//'`
324 dnl First look for a shared library.
325 if test -n "$acl_shlibext"; then
326 if test -f "$dir/$libname$shrext"; then
327 found_dir="$dir"
328 found_so="$dir/$libname$shrext"
329 else
330 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
331 ver=`(cd "$dir" && \
332 for f in "$libname$shrext".*; do echo "$f"; done \
333 | sed -e "s,^$libname$shrext\\\\.,," \
334 | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
335 | sed 1q ) 2>/dev/null`
336 if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
337 found_dir="$dir"
338 found_so="$dir/$libname$shrext.$ver"
339 fi
340 else
341 eval library_names=\"$acl_library_names_spec\"
342 for f in $library_names; do
343 if test -f "$dir/$f"; then
344 found_dir="$dir"
345 found_so="$dir/$f"
346 break
347 fi
348 done
349 fi
350 fi
351 fi
352 dnl Then look for a static library.
353 if test "X$found_dir" = "X"; then
354 if test -f "$dir/$libname.$acl_libext"; then
355 found_dir="$dir"
356 found_a="$dir/$libname.$acl_libext"
357 fi
358 fi
359 if test "X$found_dir" != "X"; then
360 if test -f "$dir/$libname.la"; then
361 found_la="$dir/$libname.la"
362 fi
363 fi
364 ;;
365 esac
366 if test "X$found_dir" != "X"; then
367 break
368 fi
369 done
370 fi
371 if test "X$found_dir" != "X"; then
372 dnl Found the library.
373 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
374 if test "X$found_so" != "X"; then
375 dnl Linking with a shared library. We attempt to hardcode its
376 dnl directory into the executable's runpath, unless it's the
377 dnl standard /usr/lib.
378 if test "$enable_rpath" = no \
379 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
380 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
381 dnl No hardcoding is needed.
382 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
383 else
384 dnl Use an explicit option to hardcode DIR into the resulting
385 dnl binary.
386 dnl Potentially add DIR to ltrpathdirs.
387 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
388 haveit=
389 for x in $ltrpathdirs; do
390 if test "X$x" = "X$found_dir"; then
391 haveit=yes
392 break
393 fi
394 done
395 if test -z "$haveit"; then
396 ltrpathdirs="$ltrpathdirs $found_dir"
397 fi
398 dnl The hardcoding into $LIBNAME is system dependent.
399 if test "$acl_hardcode_direct" = yes; then
400 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
401 dnl resulting binary.
402 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
403 else
404 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
405 dnl Use an explicit option to hardcode DIR into the resulting
406 dnl binary.
407 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
408 dnl Potentially add DIR to rpathdirs.
409 dnl The rpathdirs will be appended to $LIBNAME at the end.
410 haveit=
411 for x in $rpathdirs; do
412 if test "X$x" = "X$found_dir"; then
413 haveit=yes
414 break
415 fi
416 done
417 if test -z "$haveit"; then
418 rpathdirs="$rpathdirs $found_dir"
419 fi
420 else
421 dnl Rely on "-L$found_dir".
422 dnl But don't add it if it's already contained in the LDFLAGS
423 dnl or the already constructed $LIBNAME
424 haveit=
425 for x in $LDFLAGS $LIB[]NAME; do
426 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
427 if test "X$x" = "X-L$found_dir"; then
428 haveit=yes
429 break
430 fi
431 done
432 if test -z "$haveit"; then
433 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
434 fi
435 if test "$acl_hardcode_minus_L" != no; then
436 dnl FIXME: Not sure whether we should use
437 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
438 dnl here.
439 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
440 else
441 dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
442 dnl here, because this doesn't fit in flags passed to the
443 dnl compiler. So give up. No hardcoding. This affects only
444 dnl very old systems.
445 dnl FIXME: Not sure whether we should use
446 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
447 dnl here.
448 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
449 fi
450 fi
451 fi
452 fi
453 else
454 if test "X$found_a" != "X"; then
455 dnl Linking with a static library.
456 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
457 else
458 dnl We shouldn't come here, but anyway it's good to have a
459 dnl fallback.
460 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
461 fi
462 fi
463 dnl Assume the include files are nearby.
464 additional_includedir=
465 case "$found_dir" in
466 */$acl_libdirstem | */$acl_libdirstem/)
467 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
468 if test "$name" = '$1'; then
469 LIB[]NAME[]_PREFIX="$basedir"
470 fi
471 additional_includedir="$basedir/include"
472 ;;
473 */$acl_libdirstem2 | */$acl_libdirstem2/)
474 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
475 if test "$name" = '$1'; then
476 LIB[]NAME[]_PREFIX="$basedir"
477 fi
478 additional_includedir="$basedir/include"
479 ;;
480 esac
481 if test "X$additional_includedir" != "X"; then
482 dnl Potentially add $additional_includedir to $INCNAME.
483 dnl But don't add it
484 dnl 1. if it's the standard /usr/include,
485 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
486 dnl 3. if it's already present in $CPPFLAGS or the already
487 dnl constructed $INCNAME,
488 dnl 4. if it doesn't exist as a directory.
489 if test "X$additional_includedir" != "X/usr/include"; then
490 haveit=
491 if test "X$additional_includedir" = "X/usr/local/include"; then
492 if test -n "$GCC"; then
493 case $host_os in
494 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
495 esac
496 fi
497 fi
498 if test -z "$haveit"; then
499 for x in $CPPFLAGS $INC[]NAME; do
500 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
501 if test "X$x" = "X-I$additional_includedir"; then
502 haveit=yes
503 break
504 fi
505 done
506 if test -z "$haveit"; then
507 if test -d "$additional_includedir"; then
508 dnl Really add $additional_includedir to $INCNAME.
509 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
510 fi
511 fi
512 fi
513 fi
514 fi
515 dnl Look for dependencies.
516 if test -n "$found_la"; then
517 dnl Read the .la file. It defines the variables
518 dnl dlname, library_names, old_library, dependency_libs, current,
519 dnl age, revision, installed, dlopen, dlpreopen, libdir.
520 save_libdir="$libdir"
521 case "$found_la" in
522 */* | *\\*) . "$found_la" ;;
523 *) . "./$found_la" ;;
524 esac
525 libdir="$save_libdir"
526 dnl We use only dependency_libs.
527 for dep in $dependency_libs; do
528 case "$dep" in
529 -L*)
530 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
531 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
532 dnl But don't add it
533 dnl 1. if it's the standard /usr/lib,
534 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
535 dnl 3. if it's already present in $LDFLAGS or the already
536 dnl constructed $LIBNAME,
537 dnl 4. if it doesn't exist as a directory.
538 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
539 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
540 haveit=
541 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
542 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
543 if test -n "$GCC"; then
544 case $host_os in
545 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
546 esac
547 fi
548 fi
549 if test -z "$haveit"; then
550 haveit=
551 for x in $LDFLAGS $LIB[]NAME; do
552 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
553 if test "X$x" = "X-L$additional_libdir"; then
554 haveit=yes
555 break
556 fi
557 done
558 if test -z "$haveit"; then
559 if test -d "$additional_libdir"; then
560 dnl Really add $additional_libdir to $LIBNAME.
561 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
562 fi
563 fi
564 haveit=
565 for x in $LDFLAGS $LTLIB[]NAME; do
566 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
567 if test "X$x" = "X-L$additional_libdir"; then
568 haveit=yes
569 break
570 fi
571 done
572 if test -z "$haveit"; then
573 if test -d "$additional_libdir"; then
574 dnl Really add $additional_libdir to $LTLIBNAME.
575 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
576 fi
577 fi
578 fi
579 fi
580 ;;
581 -R*)
582 dir=`echo "X$dep" | sed -e 's/^X-R//'`
583 if test "$enable_rpath" != no; then
584 dnl Potentially add DIR to rpathdirs.
585 dnl The rpathdirs will be appended to $LIBNAME at the end.
586 haveit=
587 for x in $rpathdirs; do
588 if test "X$x" = "X$dir"; then
589 haveit=yes
590 break
591 fi
592 done
593 if test -z "$haveit"; then
594 rpathdirs="$rpathdirs $dir"
595 fi
596 dnl Potentially add DIR to ltrpathdirs.
597 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
598 haveit=
599 for x in $ltrpathdirs; do
600 if test "X$x" = "X$dir"; then
601 haveit=yes
602 break
603 fi
604 done
605 if test -z "$haveit"; then
606 ltrpathdirs="$ltrpathdirs $dir"
607 fi
608 fi
609 ;;
610 -l*)
611 dnl Handle this in the next round.
612 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
613 ;;
614 *.la)
615 dnl Handle this in the next round. Throw away the .la's
616 dnl directory; it is already contained in a preceding -L
617 dnl option.
618 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
619 ;;
620 *)
621 dnl Most likely an immediate library name.
622 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
623 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
624 ;;
625 esac
626 done
627 fi
628 else
629 dnl Didn't find the library; assume it is in the system directories
630 dnl known to the linker and runtime loader. (All the system
631 dnl directories known to the linker should also be known to the
632 dnl runtime loader, otherwise the system is severely misconfigured.)
633 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
634 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
635 fi
636 fi
637 fi
638 done
639 done
640 if test "X$rpathdirs" != "X"; then
641 if test -n "$acl_hardcode_libdir_separator"; then
642 dnl Weird platform: only the last -rpath option counts, the user must
643 dnl pass all path elements in one option. We can arrange that for a
644 dnl single library, but not when more than one $LIBNAMEs are used.
645 alldirs=
646 for found_dir in $rpathdirs; do
647 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
648 done
649 dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
650 acl_save_libdir="$libdir"
651 libdir="$alldirs"
652 eval flag=\"$acl_hardcode_libdir_flag_spec\"
653 libdir="$acl_save_libdir"
654 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
655 else
656 dnl The -rpath options are cumulative.
657 for found_dir in $rpathdirs; do
658 acl_save_libdir="$libdir"
659 libdir="$found_dir"
660 eval flag=\"$acl_hardcode_libdir_flag_spec\"
661 libdir="$acl_save_libdir"
662 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
663 done
664 fi
665 fi
666 if test "X$ltrpathdirs" != "X"; then
667 dnl When using libtool, the option that works for both libraries and
668 dnl executables is -R. The -R options are cumulative.
669 for found_dir in $ltrpathdirs; do
670 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
671 done
672 fi
673 popdef([P_A_C_K])
674 popdef([PACKLIBS])
675 popdef([PACKUP])
676 popdef([PACK])
677 popdef([NAME])
678])
679
680dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
681dnl unless already present in VAR.
682dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
683dnl contains two or three consecutive elements that belong together.
684AC_DEFUN([AC_LIB_APPENDTOVAR],
685[
686 for element in [$2]; do
687 haveit=
688 for x in $[$1]; do
689 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
690 if test "X$x" = "X$element"; then
691 haveit=yes
692 break
693 fi
694 done
695 if test -z "$haveit"; then
696 [$1]="${[$1]}${[$1]:+ }$element"
697 fi
698 done
699])
700
701dnl For those cases where a variable contains several -L and -l options
702dnl referring to unknown libraries and directories, this macro determines the
703dnl necessary additional linker options for the runtime path.
704dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
705dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
706dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
707dnl otherwise linking without libtool is assumed.
708AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
709[
710 AC_REQUIRE([AC_LIB_RPATH])
711 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
712 $1=
713 if test "$enable_rpath" != no; then
714 if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
715 dnl Use an explicit option to hardcode directories into the resulting
716 dnl binary.
717 rpathdirs=
718 next=
719 for opt in $2; do
720 if test -n "$next"; then
721 dir="$next"
722 dnl No need to hardcode the standard /usr/lib.
723 if test "X$dir" != "X/usr/$acl_libdirstem" \
724 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
725 rpathdirs="$rpathdirs $dir"
726 fi
727 next=
728 else
729 case $opt in
730 -L) next=yes ;;
731 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
732 dnl No need to hardcode the standard /usr/lib.
733 if test "X$dir" != "X/usr/$acl_libdirstem" \
734 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
735 rpathdirs="$rpathdirs $dir"
736 fi
737 next= ;;
738 *) next= ;;
739 esac
740 fi
741 done
742 if test "X$rpathdirs" != "X"; then
743 if test -n ""$3""; then
744 dnl libtool is used for linking. Use -R options.
745 for dir in $rpathdirs; do
746 $1="${$1}${$1:+ }-R$dir"
747 done
748 else
749 dnl The linker is used for linking directly.
750 if test -n "$acl_hardcode_libdir_separator"; then
751 dnl Weird platform: only the last -rpath option counts, the user
752 dnl must pass all path elements in one option.
753 alldirs=
754 for dir in $rpathdirs; do
755 alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
756 done
757 acl_save_libdir="$libdir"
758 libdir="$alldirs"
759 eval flag=\"$acl_hardcode_libdir_flag_spec\"
760 libdir="$acl_save_libdir"
761 $1="$flag"
762 else
763 dnl The -rpath options are cumulative.
764 for dir in $rpathdirs; do
765 acl_save_libdir="$libdir"
766 libdir="$dir"
767 eval flag=\"$acl_hardcode_libdir_flag_spec\"
768 libdir="$acl_save_libdir"
769 $1="${$1}${$1:+ }$flag"
770 done
771 fi
772 fi
773 fi
774 fi
775 fi
776 AC_SUBST([$1])
777])
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4
deleted file mode 100644
index 60908e8..0000000
--- a/gl/m4/lib-prefix.m4
+++ /dev/null
@@ -1,224 +0,0 @@
1# lib-prefix.m4 serial 7 (gettext-0.18)
2dnl Copyright (C) 2001-2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
10dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
11dnl require excessive bracketing.
12ifdef([AC_HELP_STRING],
13[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
14[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
15
16dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
17dnl to access previously installed libraries. The basic assumption is that
18dnl a user will want packages to use other packages he previously installed
19dnl with the same --prefix option.
20dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
21dnl libraries, but is otherwise very convenient.
22AC_DEFUN([AC_LIB_PREFIX],
23[
24 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
25 AC_REQUIRE([AC_PROG_CC])
26 AC_REQUIRE([AC_CANONICAL_HOST])
27 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
28 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
29 dnl By default, look in $includedir and $libdir.
30 use_additional=yes
31 AC_LIB_WITH_FINAL_PREFIX([
32 eval additional_includedir=\"$includedir\"
33 eval additional_libdir=\"$libdir\"
34 ])
35 AC_LIB_ARG_WITH([lib-prefix],
36[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
37 --without-lib-prefix don't search for libraries in includedir and libdir],
38[
39 if test "X$withval" = "Xno"; then
40 use_additional=no
41 else
42 if test "X$withval" = "X"; then
43 AC_LIB_WITH_FINAL_PREFIX([
44 eval additional_includedir=\"$includedir\"
45 eval additional_libdir=\"$libdir\"
46 ])
47 else
48 additional_includedir="$withval/include"
49 additional_libdir="$withval/$acl_libdirstem"
50 fi
51 fi
52])
53 if test $use_additional = yes; then
54 dnl Potentially add $additional_includedir to $CPPFLAGS.
55 dnl But don't add it
56 dnl 1. if it's the standard /usr/include,
57 dnl 2. if it's already present in $CPPFLAGS,
58 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
59 dnl 4. if it doesn't exist as a directory.
60 if test "X$additional_includedir" != "X/usr/include"; then
61 haveit=
62 for x in $CPPFLAGS; do
63 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
64 if test "X$x" = "X-I$additional_includedir"; then
65 haveit=yes
66 break
67 fi
68 done
69 if test -z "$haveit"; then
70 if test "X$additional_includedir" = "X/usr/local/include"; then
71 if test -n "$GCC"; then
72 case $host_os in
73 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
74 esac
75 fi
76 fi
77 if test -z "$haveit"; then
78 if test -d "$additional_includedir"; then
79 dnl Really add $additional_includedir to $CPPFLAGS.
80 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
81 fi
82 fi
83 fi
84 fi
85 dnl Potentially add $additional_libdir to $LDFLAGS.
86 dnl But don't add it
87 dnl 1. if it's the standard /usr/lib,
88 dnl 2. if it's already present in $LDFLAGS,
89 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
90 dnl 4. if it doesn't exist as a directory.
91 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
92 haveit=
93 for x in $LDFLAGS; do
94 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
95 if test "X$x" = "X-L$additional_libdir"; then
96 haveit=yes
97 break
98 fi
99 done
100 if test -z "$haveit"; then
101 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
102 if test -n "$GCC"; then
103 case $host_os in
104 linux*) haveit=yes;;
105 esac
106 fi
107 fi
108 if test -z "$haveit"; then
109 if test -d "$additional_libdir"; then
110 dnl Really add $additional_libdir to $LDFLAGS.
111 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
112 fi
113 fi
114 fi
115 fi
116 fi
117])
118
119dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
120dnl acl_final_exec_prefix, containing the values to which $prefix and
121dnl $exec_prefix will expand at the end of the configure script.
122AC_DEFUN([AC_LIB_PREPARE_PREFIX],
123[
124 dnl Unfortunately, prefix and exec_prefix get only finally determined
125 dnl at the end of configure.
126 if test "X$prefix" = "XNONE"; then
127 acl_final_prefix="$ac_default_prefix"
128 else
129 acl_final_prefix="$prefix"
130 fi
131 if test "X$exec_prefix" = "XNONE"; then
132 acl_final_exec_prefix='${prefix}'
133 else
134 acl_final_exec_prefix="$exec_prefix"
135 fi
136 acl_save_prefix="$prefix"
137 prefix="$acl_final_prefix"
138 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
139 prefix="$acl_save_prefix"
140])
141
142dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
143dnl variables prefix and exec_prefix bound to the values they will have
144dnl at the end of the configure script.
145AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
146[
147 acl_save_prefix="$prefix"
148 prefix="$acl_final_prefix"
149 acl_save_exec_prefix="$exec_prefix"
150 exec_prefix="$acl_final_exec_prefix"
151 $1
152 exec_prefix="$acl_save_exec_prefix"
153 prefix="$acl_save_prefix"
154])
155
156dnl AC_LIB_PREPARE_MULTILIB creates
157dnl - a variable acl_libdirstem, containing the basename of the libdir, either
158dnl "lib" or "lib64" or "lib/64",
159dnl - a variable acl_libdirstem2, as a secondary possible value for
160dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
161dnl "lib/amd64".
162AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
163[
164 dnl There is no formal standard regarding lib and lib64.
165 dnl On glibc systems, the current practice is that on a system supporting
166 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
167 dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
168 dnl the compiler's default mode by looking at the compiler's library search
169 dnl path. If at least one of its elements ends in /lib64 or points to a
170 dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
171 dnl Otherwise we use the default, namely "lib".
172 dnl On Solaris systems, the current practice is that on a system supporting
173 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
174 dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
175 dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
176 AC_REQUIRE([AC_CANONICAL_HOST])
177 acl_libdirstem=lib
178 acl_libdirstem2=
179 case "$host_os" in
180 solaris*)
181 dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
182 dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
185 dnl symlink is missing, so we set acl_libdirstem2 too.
186 AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
187 [AC_EGREP_CPP([sixtyfour bits], [
188#ifdef _LP64
189sixtyfour bits
190#endif
191 ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
192 ])
193 if test $gl_cv_solaris_64bit = yes; then
194 acl_libdirstem=lib/64
195 case "$host_cpu" in
196 sparc*) acl_libdirstem2=lib/sparcv9 ;;
197 i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
198 esac
199 fi
200 ;;
201 *)
202 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
203 if test -n "$searchpath"; then
204 acl_save_IFS="${IFS= }"; IFS=":"
205 for searchdir in $searchpath; do
206 if test -d "$searchdir"; then
207 case "$searchdir" in
208 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
209 */../ | */.. )
210 # Better ignore directories of this form. They are misleading.
211 ;;
212 *) searchdir=`cd "$searchdir" && pwd`
213 case "$searchdir" in
214 */lib64 ) acl_libdirstem=lib64 ;;
215 esac ;;
216 esac
217 fi
218 done
219 IFS="$acl_save_IFS"
220 fi
221 ;;
222 esac
223 test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
224])
diff --git a/gl/m4/limits-h.m4 b/gl/m4/limits-h.m4
new file mode 100644
index 0000000..5088fa1
--- /dev/null
+++ b/gl/m4/limits-h.m4
@@ -0,0 +1,41 @@
1dnl Check whether limits.h has needed features.
2
3dnl Copyright 2016-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl From Paul Eggert.
9
10AC_DEFUN_ONCE([gl_LIMITS_H],
11[
12 gl_CHECK_NEXT_HEADERS([limits.h])
13
14 AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.],
15 [gl_cv_header_limits_width],
16 [AC_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
19 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
20 #endif
21 #include <limits.h>
22 long long llm = LLONG_MAX;
23 int wb = WORD_BIT;
24 int ullw = ULLONG_WIDTH;
25 int bw = BOOL_WIDTH;
26 ]])],
27 [gl_cv_header_limits_width=yes],
28 [gl_cv_header_limits_width=no])])
29 if test "$gl_cv_header_limits_width" = yes; then
30 GL_GENERATE_LIMITS_H=false
31 else
32 GL_GENERATE_LIMITS_H=true
33 fi
34])
35
36dnl Unconditionally enables the replacement of <limits.h>.
37AC_DEFUN([gl_REPLACE_LIMITS_H],
38[
39 AC_REQUIRE([gl_LIMITS_H])
40 GL_GENERATE_LIMITS_H=true
41])
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index 2e93e58..15b6b2a 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,5 +1,5 @@
1# localcharset.m4 serial 7 1# localcharset.m4 serial 8
2dnl Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,10 +8,4 @@ AC_DEFUN([gl_LOCALCHARSET],
8[ 8[
9 dnl Prerequisites of lib/localcharset.c. 9 dnl Prerequisites of lib/localcharset.c.
10 AC_REQUIRE([AM_LANGINFO_CODESET]) 10 AC_REQUIRE([AM_LANGINFO_CODESET])
11 AC_REQUIRE([gl_FCNTL_O_FLAGS])
12 AC_CHECK_DECLS_ONCE([getc_unlocked])
13
14 dnl Prerequisites of the lib/Makefile.am snippet.
15 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_REQUIRE([gl_GLIBC21])
17]) 11])
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
index ef199e3..8c41fad 100644
--- a/gl/m4/locale-fr.m4
+++ b/gl/m4/locale-fr.m4
@@ -1,5 +1,5 @@
1# locale-fr.m4 serial 17 1# locale-fr.m4 serial 20
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_FR],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [ 14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <time.h> 17#include <time.h>
19#if HAVE_LANGINFO_CODESET 18#if HAVE_LANGINFO_CODESET
@@ -24,8 +23,14 @@ changequote(,)dnl
24struct tm t; 23struct tm t;
25char buf[16]; 24char buf[16];
26int main () { 25int main () {
26 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
27 imitates locale dependent behaviour by looking at the environment
28 variables, and all locales use the UTF-8 encoding. */
29#if defined __BEOS__ || defined __HAIKU__
30 return 1;
31#else
27 /* Check whether the given locale name is recognized by the system. */ 32 /* Check whether the given locale name is recognized by the system. */
28#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 33# if defined _WIN32 && !defined __CYGWIN__
29 /* On native Windows, setlocale(category, "") looks at the system settings, 34 /* On native Windows, setlocale(category, "") looks at the system settings,
30 not at the environment variables. Also, when an encoding suffix such 35 not at the environment variables. Also, when an encoding suffix such
31 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 36 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -33,9 +38,9 @@ int main () {
33 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 38 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
34 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 39 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
35 return 1; 40 return 1;
36#else 41# else
37 if (setlocale (LC_ALL, "") == NULL) return 1; 42 if (setlocale (LC_ALL, "") == NULL) return 1;
38#endif 43# endif
39 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 44 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
40 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 45 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
41 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 46 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -44,35 +49,35 @@ int main () {
44 some unit tests fail. 49 some unit tests fail.
45 On MirBSD 10, when an unsupported locale is specified, setlocale() 50 On MirBSD 10, when an unsupported locale is specified, setlocale()
46 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 51 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
47#if HAVE_LANGINFO_CODESET 52# if HAVE_LANGINFO_CODESET
48 { 53 {
49 const char *cs = nl_langinfo (CODESET); 54 const char *cs = nl_langinfo (CODESET);
50 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 55 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
51 || strcmp (cs, "UTF-8") == 0) 56 || strcmp (cs, "UTF-8") == 0)
52 return 1; 57 return 1;
53 } 58 }
54#endif 59# endif
55#ifdef __CYGWIN__ 60# ifdef __CYGWIN__
56 /* On Cygwin, avoid locale names without encoding suffix, because the 61 /* On Cygwin, avoid locale names without encoding suffix, because the
57 locale_charset() function relies on the encoding suffix. Note that 62 locale_charset() function relies on the encoding suffix. Note that
58 LC_ALL is set on the command line. */ 63 LC_ALL is set on the command line. */
59 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 64 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
60#endif 65# endif
61 /* Check whether in the abbreviation of the second month, the second 66 /* Check whether in the abbreviation of the second month, the second
62 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only 67 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
63 one byte long. This excludes the UTF-8 encoding. */ 68 one byte long. This excludes the UTF-8 encoding. */
64 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
65 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; 70 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
66#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */ 71# if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
67 /* Check whether the decimal separator is a comma. 72 /* Check whether the decimal separator is a comma.
68 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 73 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
69 are nl_langinfo(RADIXCHAR) are both ".". */ 74 are nl_langinfo(RADIXCHAR) are both ".". */
70 if (localeconv () ->decimal_point[0] != ',') return 1; 75 if (localeconv () ->decimal_point[0] != ',') return 1;
71#endif 76# endif
72 return 0; 77 return 0;
78#endif
73} 79}
74changequote([,])dnl 80 ]])])
75 ])])
76 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 81 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
77 case "$host_os" in 82 case "$host_os" in
78 # Handle native Windows specially, because there setlocale() interprets 83 # Handle native Windows specially, because there setlocale() interprets
@@ -136,8 +141,7 @@ AC_DEFUN([gt_LOCALE_FR_UTF8],
136[ 141[
137 AC_REQUIRE([AM_LANGINFO_CODESET]) 142 AC_REQUIRE([AM_LANGINFO_CODESET])
138 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [ 143 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
139 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 144 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
140changequote(,)dnl
141#include <locale.h> 145#include <locale.h>
142#include <time.h> 146#include <time.h>
143#if HAVE_LANGINFO_CODESET 147#if HAVE_LANGINFO_CODESET
@@ -153,7 +157,7 @@ int main () {
153 variables, and all locales use the UTF-8 encoding. */ 157 variables, and all locales use the UTF-8 encoding. */
154#if !(defined __BEOS__ || defined __HAIKU__) 158#if !(defined __BEOS__ || defined __HAIKU__)
155 /* Check whether the given locale name is recognized by the system. */ 159 /* Check whether the given locale name is recognized by the system. */
156# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 160# if defined _WIN32 && !defined __CYGWIN__
157 /* On native Windows, setlocale(category, "") looks at the system settings, 161 /* On native Windows, setlocale(category, "") looks at the system settings,
158 not at the environment variables. Also, when an encoding suffix such 162 not at the environment variables. Also, when an encoding suffix such
159 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 163 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -199,8 +203,7 @@ int main () {
199#endif 203#endif
200 return 0; 204 return 0;
201} 205}
202changequote([,])dnl 206 ]])])
203 ])])
204 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 207 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
205 case "$host_os" in 208 case "$host_os" in
206 # Handle native Windows specially, because there setlocale() interprets 209 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
index 132a3e7..2590173 100644
--- a/gl/m4/locale-ja.m4
+++ b/gl/m4/locale-ja.m4
@@ -1,5 +1,5 @@
1# locale-ja.m4 serial 12 1# locale-ja.m4 serial 15
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_JA],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [ 14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <time.h> 17#include <time.h>
19#if HAVE_LANGINFO_CODESET 18#if HAVE_LANGINFO_CODESET
@@ -25,9 +24,14 @@ struct tm t;
25char buf[16]; 24char buf[16];
26int main () 25int main ()
27{ 26{
28 const char *p; 27 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
28 imitates locale dependent behaviour by looking at the environment
29 variables, and all locales use the UTF-8 encoding. */
30#if defined __BEOS__ || defined __HAIKU__
31 return 1;
32#else
29 /* Check whether the given locale name is recognized by the system. */ 33 /* Check whether the given locale name is recognized by the system. */
30#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 34# if defined _WIN32 && !defined __CYGWIN__
31 /* On native Windows, setlocale(category, "") looks at the system settings, 35 /* On native Windows, setlocale(category, "") looks at the system settings,
32 not at the environment variables. Also, when an encoding suffix such 36 not at the environment variables. Also, when an encoding suffix such
33 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 37 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -35,9 +39,9 @@ int main ()
35 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 39 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
36 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 40 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
37 return 1; 41 return 1;
38#else 42# else
39 if (setlocale (LC_ALL, "") == NULL) return 1; 43 if (setlocale (LC_ALL, "") == NULL) return 1;
40#endif 44# endif
41 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 45 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
42 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 46 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
43 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 47 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -46,35 +50,38 @@ int main ()
46 some unit tests fail. 50 some unit tests fail.
47 On MirBSD 10, when an unsupported locale is specified, setlocale() 51 On MirBSD 10, when an unsupported locale is specified, setlocale()
48 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 52 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
49#if HAVE_LANGINFO_CODESET 53# if HAVE_LANGINFO_CODESET
50 { 54 {
51 const char *cs = nl_langinfo (CODESET); 55 const char *cs = nl_langinfo (CODESET);
52 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 56 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
53 || strcmp (cs, "UTF-8") == 0) 57 || strcmp (cs, "UTF-8") == 0)
54 return 1; 58 return 1;
55 } 59 }
56#endif 60# endif
57#ifdef __CYGWIN__ 61# ifdef __CYGWIN__
58 /* On Cygwin, avoid locale names without encoding suffix, because the 62 /* On Cygwin, avoid locale names without encoding suffix, because the
59 locale_charset() function relies on the encoding suffix. Note that 63 locale_charset() function relies on the encoding suffix. Note that
60 LC_ALL is set on the command line. */ 64 LC_ALL is set on the command line. */
61 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 65 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
62#endif 66# endif
63 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales 67 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
64 on Cygwin 1.5.x. */ 68 on Cygwin 1.5.x. */
65 if (MB_CUR_MAX == 1) 69 if (MB_CUR_MAX == 1)
66 return 1; 70 return 1;
67 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 71 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
68 This excludes the UTF-8 encoding (except on MirBSD). */ 72 This excludes the UTF-8 encoding (except on MirBSD). */
69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 73 {
70 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 74 const char *p;
71 for (p = buf; *p != '\0'; p++) 75 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
72 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) 76 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
73 return 1; 77 for (p = buf; *p != '\0'; p++)
78 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
79 return 1;
80 }
74 return 0; 81 return 0;
82#endif
75} 83}
76changequote([,])dnl 84 ]])])
77 ])])
78 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 85 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
79 case "$host_os" in 86 case "$host_os" in
80 # Handle native Windows specially, because there setlocale() interprets 87 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
index 4eed73f..b9f9eef 100644
--- a/gl/m4/locale-zh.m4
+++ b/gl/m4/locale-zh.m4
@@ -1,5 +1,5 @@
1# locale-zh.m4 serial 12 1# locale-zh.m4 serial 15
2dnl Copyright (C) 2003, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,8 +12,7 @@ AC_DEFUN([gt_LOCALE_ZH_CN],
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET]) 13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [ 14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
15 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 15 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
16changequote(,)dnl
17#include <locale.h> 16#include <locale.h>
18#include <stdlib.h> 17#include <stdlib.h>
19#include <time.h> 18#include <time.h>
@@ -26,9 +25,14 @@ struct tm t;
26char buf[16]; 25char buf[16];
27int main () 26int main ()
28{ 27{
29 const char *p; 28 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
29 imitates locale dependent behaviour by looking at the environment
30 variables, and all locales use the UTF-8 encoding. */
31#if defined __BEOS__ || defined __HAIKU__
32 return 1;
33#else
30 /* Check whether the given locale name is recognized by the system. */ 34 /* Check whether the given locale name is recognized by the system. */
31#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 35# if defined _WIN32 && !defined __CYGWIN__
32 /* On native Windows, setlocale(category, "") looks at the system settings, 36 /* On native Windows, setlocale(category, "") looks at the system settings,
33 not at the environment variables. Also, when an encoding suffix such 37 not at the environment variables. Also, when an encoding suffix such
34 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE 38 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
@@ -36,9 +40,9 @@ int main ()
36 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL 40 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
37 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0) 41 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
38 return 1; 42 return 1;
39#else 43# else
40 if (setlocale (LC_ALL, "") == NULL) return 1; 44 if (setlocale (LC_ALL, "") == NULL) return 1;
41#endif 45# endif
42 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 46 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
43 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 47 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
44 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 48 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -47,35 +51,38 @@ int main ()
47 some unit tests fail. 51 some unit tests fail.
48 On MirBSD 10, when an unsupported locale is specified, setlocale() 52 On MirBSD 10, when an unsupported locale is specified, setlocale()
49 succeeds but then nl_langinfo(CODESET) is "UTF-8". */ 53 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
50#if HAVE_LANGINFO_CODESET 54# if HAVE_LANGINFO_CODESET
51 { 55 {
52 const char *cs = nl_langinfo (CODESET); 56 const char *cs = nl_langinfo (CODESET);
53 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0 57 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
54 || strcmp (cs, "UTF-8") == 0) 58 || strcmp (cs, "UTF-8") == 0)
55 return 1; 59 return 1;
56 } 60 }
57#endif 61# endif
58#ifdef __CYGWIN__ 62# ifdef __CYGWIN__
59 /* On Cygwin, avoid locale names without encoding suffix, because the 63 /* On Cygwin, avoid locale names without encoding suffix, because the
60 locale_charset() function relies on the encoding suffix. Note that 64 locale_charset() function relies on the encoding suffix. Note that
61 LC_ALL is set on the command line. */ 65 LC_ALL is set on the command line. */
62 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 66 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
63#endif 67# endif
64 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 68 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
65 This excludes the UTF-8 encoding (except on MirBSD). */ 69 This excludes the UTF-8 encoding (except on MirBSD). */
66 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 70 {
67 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 71 const char *p;
68 for (p = buf; *p != '\0'; p++) 72 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
69 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0) 73 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
70 return 1; 74 for (p = buf; *p != '\0'; p++)
75 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
76 return 1;
77 }
71 /* Check whether a typical GB18030 multibyte sequence is recognized as a 78 /* Check whether a typical GB18030 multibyte sequence is recognized as a
72 single wide character. This excludes the GB2312 and GBK encodings. */ 79 single wide character. This excludes the GB2312 and GBK encodings. */
73 if (mblen ("\203\062\332\066", 5) != 4) 80 if (mblen ("\203\062\332\066", 5) != 4)
74 return 1; 81 return 1;
75 return 0; 82 return 0;
83#endif
76} 84}
77changequote([,])dnl 85 ]])])
78 ])])
79 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 86 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
80 case "$host_os" in 87 case "$host_os" in
81 # Handle native Windows specially, because there setlocale() interprets 88 # Handle native Windows specially, because there setlocale() interprets
diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4
index 8bd12e8..a33a0a4 100644
--- a/gl/m4/locale_h.m4
+++ b/gl/m4/locale_h.m4
@@ -1,13 +1,13 @@
1# locale_h.m4 serial 19 1# locale_h.m4 serial 28
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_LOCALE_H], 7AC_DEFUN_ONCE([gl_LOCALE_H],
8[ 8[
9 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 9 dnl Ensure to expand the default settings once only, before all statements
10 dnl once only, before all statements that occur in other macros. 10 dnl that occur in other macros.
11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
12 12
13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_* 13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
@@ -17,7 +17,9 @@ AC_DEFUN([gl_LOCALE_H],
17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced. 17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
18 AC_REQUIRE([gl_STDDEF_H]) 18 AC_REQUIRE([gl_STDDEF_H])
19 19
20 dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv' 20 AC_REQUIRE([gl_LOCALE_T])
21
22 dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
21 dnl only if _LCONV_C99 is defined. 23 dnl only if _LCONV_C99 is defined.
22 AC_REQUIRE([AC_CANONICAL_HOST]) 24 AC_REQUIRE([AC_CANONICAL_HOST])
23 case "$host_os" in 25 case "$host_os" in
@@ -37,34 +39,6 @@ AC_DEFUN([gl_LOCALE_H],
37 [gl_cv_header_locale_h_posix2001=yes], 39 [gl_cv_header_locale_h_posix2001=yes],
38 [gl_cv_header_locale_h_posix2001=no])]) 40 [gl_cv_header_locale_h_posix2001=no])])
39 41
40 dnl Check for <xlocale.h>.
41 AC_CHECK_HEADERS_ONCE([xlocale.h])
42 if test $ac_cv_header_xlocale_h = yes; then
43 HAVE_XLOCALE_H=1
44 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
45 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
46 dnl itself, we assume that <xlocale.h> will do so.
47 AC_CACHE_CHECK([whether locale.h defines locale_t],
48 [gl_cv_header_locale_has_locale_t],
49 [AC_COMPILE_IFELSE(
50 [AC_LANG_PROGRAM(
51 [[#include <locale.h>
52 locale_t x;]],
53 [[]])],
54 [gl_cv_header_locale_has_locale_t=yes],
55 [gl_cv_header_locale_has_locale_t=no])
56 ])
57 if test $gl_cv_header_locale_has_locale_t = yes; then
58 gl_cv_header_locale_h_needs_xlocale_h=no
59 else
60 gl_cv_header_locale_h_needs_xlocale_h=yes
61 fi
62 else
63 HAVE_XLOCALE_H=0
64 gl_cv_header_locale_h_needs_xlocale_h=no
65 fi
66 AC_SUBST([HAVE_XLOCALE_H])
67
68 dnl Check whether 'struct lconv' is complete. 42 dnl Check whether 'struct lconv' is complete.
69 dnl Bionic libc's 'struct lconv' is just a dummy. 43 dnl Bionic libc's 'struct lconv' is just a dummy.
70 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, 44 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
@@ -82,7 +56,20 @@ AC_DEFUN([gl_LOCALE_H],
82 [gl_cv_sys_struct_lconv_ok=no]) 56 [gl_cv_sys_struct_lconv_ok=no])
83 ]) 57 ])
84 if test $gl_cv_sys_struct_lconv_ok = no; then 58 if test $gl_cv_sys_struct_lconv_ok = no; then
85 REPLACE_STRUCT_LCONV=1 59 dnl On native Windows with MSVC, merely define these member names as macros.
60 dnl This avoids trouble in C++ mode.
61 case "$host_os" in
62 mingw*)
63 AC_EGREP_CPP([Special], [
64#ifdef _MSC_VER
65 Special
66#endif
67 ],
68 [],
69 [REPLACE_STRUCT_LCONV=1])
70 ;;
71 *) REPLACE_STRUCT_LCONV=1 ;;
72 esac
86 fi 73 fi
87 74
88 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK. 75 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
@@ -96,27 +83,92 @@ AC_DEFUN([gl_LOCALE_H],
96# include <xlocale.h> 83# include <xlocale.h>
97#endif 84#endif
98 ]], 85 ]],
99 [setlocale duplocale]) 86 [setlocale newlocale duplocale freelocale])
87])
88
89dnl Checks to determine whether the system has the locale_t type,
90dnl and how to obtain it.
91AC_DEFUN([gl_LOCALE_T],
92[
93 dnl Persuade glibc and Solaris <locale.h> to define locale_t.
94 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
95
96 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
97 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
98 dnl itself, we assume that <xlocale.h> will do so.
99 AC_CACHE_CHECK([whether locale.h defines locale_t],
100 [gl_cv_header_locale_has_locale_t],
101 [AC_COMPILE_IFELSE(
102 [AC_LANG_PROGRAM(
103 [[#include <locale.h>
104 locale_t x;]],
105 [[]])],
106 [gl_cv_header_locale_has_locale_t=yes],
107 [gl_cv_header_locale_has_locale_t=no])
108 ])
109
110 dnl Check for <xlocale.h>.
111 AC_CHECK_HEADERS_ONCE([xlocale.h])
112 if test $ac_cv_header_xlocale_h = yes; then
113 HAVE_XLOCALE_H=1
114 if test $gl_cv_header_locale_has_locale_t = yes; then
115 gl_cv_header_locale_h_needs_xlocale_h=no
116 else
117 gl_cv_header_locale_h_needs_xlocale_h=yes
118 fi
119 HAVE_LOCALE_T=1
120 else
121 HAVE_XLOCALE_H=0
122 gl_cv_header_locale_h_needs_xlocale_h=no
123 if test $gl_cv_header_locale_has_locale_t = yes; then
124 HAVE_LOCALE_T=1
125 else
126 HAVE_LOCALE_T=0
127 fi
128 fi
129 AC_SUBST([HAVE_XLOCALE_H])
100]) 130])
101 131
132# gl_LOCALE_MODULE_INDICATOR([modulename])
133# sets the shell variable that indicates the presence of the given module
134# to a C preprocessor expression that will evaluate to 1.
135# This macro invocation must not occur in macros that are AC_REQUIREd.
102AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], 136AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
103[ 137[
104 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 138 dnl Ensure to expand the default settings once only.
105 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 139 gl_LOCALE_H_REQUIRE_DEFAULTS
106 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 140 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
107 dnl Define it also as a C macro, for the benefit of the unit tests. 141 dnl Define it also as a C macro, for the benefit of the unit tests.
108 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 142 gl_MODULE_INDICATOR_FOR_TESTS([$1])
109]) 143])
110 144
145# Initializes the default values for AC_SUBSTed shell variables.
146# This macro must not be AC_REQUIREd. It must only be invoked, and only
147# outside of macros or in macros that are not AC_REQUIREd.
148AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
149[
150 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME])
156 ])
157 m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
158 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
159])
160
111AC_DEFUN([gl_LOCALE_H_DEFAULTS], 161AC_DEFUN([gl_LOCALE_H_DEFAULTS],
112[ 162[
113 GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
114 GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
115 GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
116 dnl Assume proper GNU behavior unless another module says otherwise. 163 dnl Assume proper GNU behavior unless another module says otherwise.
164 HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
117 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) 165 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
166 HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
118 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV]) 167 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
119 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE]) 168 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
169 REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
120 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) 170 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
171 REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
121 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV]) 172 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
173 LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
122]) 174])
diff --git a/gl/m4/localeconv.m4 b/gl/m4/localeconv.m4
index b8bb596..ae225fe 100644
--- a/gl/m4/localeconv.m4
+++ b/gl/m4/localeconv.m4
@@ -1,5 +1,5 @@
1# localeconv.m4 serial 1 1# localeconv.m4 serial 1
2dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index aae1701..88cf557 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,5 +1,5 @@
1# lock.m4 serial 13 (gettext-0.18.2) 1# lock.m4 serial 14
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,11 +12,16 @@ AC_DEFUN([gl_LOCK],
12 if test "$gl_threads_api" = posix; then 12 if test "$gl_threads_api" = posix; then
13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the 13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
14 # pthread_rwlock_* functions. 14 # pthread_rwlock_* functions.
15 has_rwlock=false
15 AC_CHECK_TYPE([pthread_rwlock_t], 16 AC_CHECK_TYPE([pthread_rwlock_t],
16 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], 17 [has_rwlock=true
18 AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
17 [Define if the POSIX multithreading library has read/write locks.])], 19 [Define if the POSIX multithreading library has read/write locks.])],
18 [], 20 [],
19 [#include <pthread.h>]) 21 [#include <pthread.h>])
22 if $has_rwlock; then
23 gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
24 fi
20 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. 25 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
21 AC_COMPILE_IFELSE([ 26 AC_COMPILE_IFELSE([
22 AC_LANG_PROGRAM( 27 AC_LANG_PROGRAM(
diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4
deleted file mode 100644
index 3af6ab5..0000000
--- a/gl/m4/longlong.m4
+++ /dev/null
@@ -1,113 +0,0 @@
1# longlong.m4 serial 17
2dnl Copyright (C) 1999-2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9# Define HAVE_LONG_LONG_INT if 'long long int' works.
10# This fixes a bug in Autoconf 2.61, and can be faster
11# than what's in Autoconf 2.62 through 2.68.
12
13# Note: If the type 'long long int' exists but is only 32 bits large
14# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
15# defined. In this case you can treat 'long long int' like 'long int'.
16
17AC_DEFUN([AC_TYPE_LONG_LONG_INT],
18[
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
20 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
21 [ac_cv_type_long_long_int=yes
22 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
23 ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
24 if test $ac_cv_type_long_long_int = yes; then
25 dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
26 dnl If cross compiling, assume the bug is not important, since
27 dnl nobody cross compiles for this platform as far as we know.
28 AC_RUN_IFELSE(
29 [AC_LANG_PROGRAM(
30 [[@%:@include <limits.h>
31 @%:@ifndef LLONG_MAX
32 @%:@ define HALF \
33 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
34 @%:@ define LLONG_MAX (HALF - 1 + HALF)
35 @%:@endif]],
36 [[long long int n = 1;
37 int i;
38 for (i = 0; ; i++)
39 {
40 long long int m = n << i;
41 if (m >> i != n)
42 return 1;
43 if (LLONG_MAX / 2 < m)
44 break;
45 }
46 return 0;]])],
47 [],
48 [ac_cv_type_long_long_int=no],
49 [:])
50 fi
51 fi])
52 if test $ac_cv_type_long_long_int = yes; then
53 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
54 [Define to 1 if the system has the type 'long long int'.])
55 fi
56])
57
58# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
59# This fixes a bug in Autoconf 2.61, and can be faster
60# than what's in Autoconf 2.62 through 2.68.
61
62# Note: If the type 'unsigned long long int' exists but is only 32 bits
63# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
64# will not be defined. In this case you can treat 'unsigned long long int'
65# like 'unsigned long int'.
66
67AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
68[
69 AC_CACHE_CHECK([for unsigned long long int],
70 [ac_cv_type_unsigned_long_long_int],
71 [ac_cv_type_unsigned_long_long_int=yes
72 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
73 AC_LINK_IFELSE(
74 [_AC_TYPE_LONG_LONG_SNIPPET],
75 [],
76 [ac_cv_type_unsigned_long_long_int=no])
77 fi])
78 if test $ac_cv_type_unsigned_long_long_int = yes; then
79 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
80 [Define to 1 if the system has the type 'unsigned long long int'.])
81 fi
82])
83
84# Expands to a C program that can be used to test for simultaneous support
85# of 'long long' and 'unsigned long long'. We don't want to say that
86# 'long long' is available if 'unsigned long long' is not, or vice versa,
87# because too many programs rely on the symmetry between signed and unsigned
88# integer types (excluding 'bool').
89AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
90[
91 AC_LANG_PROGRAM(
92 [[/* For now, do not test the preprocessor; as of 2007 there are too many
93 implementations with broken preprocessors. Perhaps this can
94 be revisited in 2012. In the meantime, code should not expect
95 #if to work with literals wider than 32 bits. */
96 /* Test literals. */
97 long long int ll = 9223372036854775807ll;
98 long long int nll = -9223372036854775807LL;
99 unsigned long long int ull = 18446744073709551615ULL;
100 /* Test constant expressions. */
101 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
102 ? 1 : -1)];
103 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
104 ? 1 : -1)];
105 int i = 63;]],
106 [[/* Test availability of runtime routines for shift and division. */
107 long long int llmax = 9223372036854775807ll;
108 unsigned long long int ullmax = 18446744073709551615ull;
109 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
110 | (llmax / ll) | (llmax % ll)
111 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
112 | (ullmax / ull) | (ullmax % ull));]])
113])
diff --git a/gl/m4/ls-mntd-fs.m4 b/gl/m4/ls-mntd-fs.m4
deleted file mode 100644
index fb116c8..0000000
--- a/gl/m4/ls-mntd-fs.m4
+++ /dev/null
@@ -1,357 +0,0 @@
1# serial 30
2# How to list mounted file systems.
3
4# Copyright (C) 1998-2004, 2006, 2009-2013 Free Software Foundation, Inc.
5#
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Jim Meyering.
11dnl
12dnl This is not pretty. I've just taken the autoconf code and wrapped
13dnl it in an AC_DEFUN and made some other fixes.
14dnl
15
16# Replace Autoconf's AC_FUNC_GETMNTENT to work around a bug in Autoconf
17# through Autoconf 2.59. We can remove this once we assume Autoconf 2.60
18# or later.
19AC_DEFUN([AC_FUNC_GETMNTENT],
20[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
21# -lseq on Dynix/PTX, -lgen on Unixware.
22AC_SEARCH_LIBS([getmntent], [sun seq gen])
23AC_CHECK_FUNCS([getmntent])
24])
25
26# gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
27AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
28 [
29AC_CHECK_FUNCS([listmntent getmntinfo])
30AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
31
32# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
33# NGROUPS (as the array dimension for a struct member) without a definition.
34AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
35
36AC_CHECK_HEADERS([sys/mount.h], [], [],
37 [AC_INCLUDES_DEFAULT
38 [#if HAVE_SYS_PARAM_H
39 #include <sys/param.h>
40 #endif]])
41
42AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
43 getfsstat_includes="\
44$ac_includes_default
45#if HAVE_SYS_PARAM_H
46# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
47#endif
48#if HAVE_SYS_UCRED_H
49# include <grp.h> /* needed for definition of NGROUPS */
50# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
51#endif
52#if HAVE_SYS_MOUNT_H
53# include <sys/mount.h>
54#endif
55#if HAVE_SYS_FS_TYPES_H
56# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
57#endif
58"
59AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
60
61# Determine how to get the list of mounted file systems.
62ac_list_mounted_fs=
63
64# If the getmntent function is available but not in the standard library,
65# make sure LIBS contains the appropriate -l option.
66AC_FUNC_GETMNTENT
67
68# This test must precede the ones for getmntent because Unicos-9 is
69# reported to have the getmntent function, but its support is incompatible
70# with other getmntent implementations.
71
72# NOTE: Normally, I wouldn't use a check for system type as I've done for
73# 'CRAY' below since that goes against the whole autoconf philosophy. But
74# I think there is too great a chance that some non-Cray system has a
75# function named listmntent to risk the false positive.
76
77if test -z "$ac_list_mounted_fs"; then
78 # Cray UNICOS 9
79 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
80 AC_CACHE_VAL([fu_cv_sys_mounted_cray_listmntent],
81 [fu_cv_sys_mounted_cray_listmntent=no
82 AC_EGREP_CPP([yes],
83 [#ifdef _CRAY
84yes
85#endif
86 ], [test $ac_cv_func_listmntent = yes \
87 && fu_cv_sys_mounted_cray_listmntent=yes]
88 )
89 ]
90 )
91 AC_MSG_RESULT([$fu_cv_sys_mounted_cray_listmntent])
92 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
93 ac_list_mounted_fs=found
94 AC_DEFINE([MOUNTED_LISTMNTENT], [1],
95 [Define if there is a function named listmntent that can be used to
96 list all mounted file systems. (UNICOS)])
97 fi
98fi
99
100if test -z "$ac_list_mounted_fs"; then
101 # AIX.
102 AC_MSG_CHECKING([for mntctl function and struct vmount])
103 AC_CACHE_VAL([fu_cv_sys_mounted_vmount],
104 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
105 [fu_cv_sys_mounted_vmount=yes],
106 [fu_cv_sys_mounted_vmount=no])])
107 AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
108 if test $fu_cv_sys_mounted_vmount = yes; then
109 ac_list_mounted_fs=found
110 AC_DEFINE([MOUNTED_VMOUNT], [1],
111 [Define if there is a function named mntctl that can be used to read
112 the list of mounted file systems, and there is a system header file
113 that declares 'struct vmount'. (AIX)])
114 fi
115fi
116
117if test $ac_cv_func_getmntent = yes; then
118
119 # This system has the getmntent function.
120 # Determine whether it's the one-argument variant or the two-argument one.
121
122 if test -z "$ac_list_mounted_fs"; then
123 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
124 AC_MSG_CHECKING([for one-argument getmntent function])
125 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent1],
126 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
127/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
128#include <stdio.h>
129
130#include <mntent.h>
131#if !defined MOUNTED
132# if defined _PATH_MOUNTED /* GNU libc */
133# define MOUNTED _PATH_MOUNTED
134# endif
135# if defined MNT_MNTTAB /* HP-UX. */
136# define MOUNTED MNT_MNTTAB
137# endif
138# if defined MNTTABNAME /* Dynix. */
139# define MOUNTED MNTTABNAME
140# endif
141#endif
142]],
143 [[ struct mntent *mnt = 0; char *table = MOUNTED;
144 if (sizeof mnt && sizeof table) return 0;]])],
145 [fu_cv_sys_mounted_getmntent1=yes],
146 [fu_cv_sys_mounted_getmntent1=no])])
147 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
148 if test $fu_cv_sys_mounted_getmntent1 = yes; then
149 ac_list_mounted_fs=found
150 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
151 [Define if there is a function named getmntent for reading the list
152 of mounted file systems, and that function takes a single argument.
153 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
154 fi
155 fi
156
157 if test -z "$ac_list_mounted_fs"; then
158 # SVR4
159 AC_MSG_CHECKING([for two-argument getmntent function])
160 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent2],
161 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
162 fu_cv_sys_mounted_getmntent2=yes,
163 fu_cv_sys_mounted_getmntent2=no)])
164 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
165 if test $fu_cv_sys_mounted_getmntent2 = yes; then
166 ac_list_mounted_fs=found
167 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
168 [Define if there is a function named getmntent for reading the list of
169 mounted file systems, and that function takes two arguments. (SVR4)])
170 AC_CHECK_FUNCS([hasmntopt])
171 fi
172 fi
173
174fi
175
176if test -z "$ac_list_mounted_fs"; then
177 # DEC Alpha running OSF/1, and Apple Darwin 1.3.
178 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
179
180 AC_MSG_CHECKING([for getfsstat function])
181 AC_CACHE_VAL([fu_cv_sys_mounted_getfsstat],
182 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
183#include <sys/types.h>
184#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
185# define FS_TYPE(Ent) ((Ent).f_fstypename)
186#else
187# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
188#endif
189$getfsstat_includes]]
190,
191 [[struct statfs *stats;
192 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
193 char *t = FS_TYPE (*stats); ]])],
194 [fu_cv_sys_mounted_getfsstat=yes],
195 [fu_cv_sys_mounted_getfsstat=no])])
196 AC_MSG_RESULT([$fu_cv_sys_mounted_getfsstat])
197 if test $fu_cv_sys_mounted_getfsstat = yes; then
198 ac_list_mounted_fs=found
199 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
200 [Define if there is a function named getfsstat for reading the
201 list of mounted file systems. (DEC Alpha running OSF/1)])
202 fi
203fi
204
205if test -z "$ac_list_mounted_fs"; then
206 # SVR3
207 AC_MSG_CHECKING([for FIXME existence of three headers])
208 AC_CACHE_VAL([fu_cv_sys_mounted_fread_fstyp],
209 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
210#include <sys/statfs.h>
211#include <sys/fstyp.h>
212#include <mnttab.h>]])],
213 [fu_cv_sys_mounted_fread_fstyp=yes],
214 [fu_cv_sys_mounted_fread_fstyp=no])])
215 AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
216 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
217 ac_list_mounted_fs=found
218 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
219 [Define if (like SVR2) there is no specific function for reading the
220 list of mounted file systems, and your system has these header files:
221 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
222 fi
223fi
224
225if test -z "$ac_list_mounted_fs"; then
226 # 4.4BSD and DEC OSF/1.
227 AC_MSG_CHECKING([for getmntinfo function])
228 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo],
229 [
230 test "$ac_cv_func_getmntinfo" = yes \
231 && fu_cv_sys_mounted_getmntinfo=yes \
232 || fu_cv_sys_mounted_getmntinfo=no
233 ])
234 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
235 if test $fu_cv_sys_mounted_getmntinfo = yes; then
236 AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
237 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo2],
238 [
239 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
240#if HAVE_SYS_PARAM_H
241# include <sys/param.h>
242#endif
243#include <sys/types.h>
244#if HAVE_SYS_MOUNT_H
245# include <sys/mount.h>
246#endif
247#if HAVE_SYS_STATVFS_H
248# include <sys/statvfs.h>
249#endif
250extern
251#ifdef __cplusplus
252"C"
253#endif
254int getmntinfo (struct statfs **, int);
255 ]], [])],
256 [fu_cv_sys_mounted_getmntinfo2=no],
257 [fu_cv_sys_mounted_getmntinfo2=yes])
258 ])
259 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
260 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
261 ac_list_mounted_fs=found
262 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
263 [Define if there is a function named getmntinfo for reading the
264 list of mounted file systems and it returns an array of
265 'struct statfs'. (4.4BSD, Darwin)])
266 else
267 ac_list_mounted_fs=found
268 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
269 [Define if there is a function named getmntinfo for reading the
270 list of mounted file systems and it returns an array of
271 'struct statvfs'. (NetBSD 3.0)])
272 fi
273 fi
274fi
275
276if test -z "$ac_list_mounted_fs"; then
277 # Ultrix
278 AC_MSG_CHECKING([for getmnt function])
279 AC_CACHE_VAL([fu_cv_sys_mounted_getmnt],
280 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
281#include <sys/fs_types.h>
282#include <sys/mount.h>]])],
283 [fu_cv_sys_mounted_getmnt=yes],
284 [fu_cv_sys_mounted_getmnt=no])])
285 AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
286 if test $fu_cv_sys_mounted_getmnt = yes; then
287 ac_list_mounted_fs=found
288 AC_DEFINE([MOUNTED_GETMNT], [1],
289 [Define if there is a function named getmnt for reading the list of
290 mounted file systems. (Ultrix)])
291 fi
292fi
293
294if test -z "$ac_list_mounted_fs"; then
295 # BeOS
296 AC_CHECK_FUNCS([next_dev fs_stat_dev])
297 AC_CHECK_HEADERS([fs_info.h])
298 AC_MSG_CHECKING([for BEOS mounted file system support functions])
299 if test $ac_cv_header_fs_info_h = yes \
300 && test $ac_cv_func_next_dev = yes \
301 && test $ac_cv_func_fs_stat_dev = yes; then
302 fu_result=yes
303 else
304 fu_result=no
305 fi
306 AC_MSG_RESULT([$fu_result])
307 if test $fu_result = yes; then
308 ac_list_mounted_fs=found
309 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
310 [Define if there are functions named next_dev and fs_stat_dev for
311 reading the list of mounted file systems. (BeOS)])
312 fi
313fi
314
315if test -z "$ac_list_mounted_fs"; then
316 # SVR2
317 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
318 AC_CACHE_VAL([fu_cv_sys_mounted_fread],
319 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <mnttab.h>]])],
320 [fu_cv_sys_mounted_fread=yes],
321 [fu_cv_sys_mounted_fread=no])])
322 AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
323 if test $fu_cv_sys_mounted_fread = yes; then
324 ac_list_mounted_fs=found
325 AC_DEFINE([MOUNTED_FREAD], [1],
326 [Define if there is no specific function for reading the list of
327 mounted file systems. fread will be used to read /etc/mnttab.
328 (SVR2) ])
329 fi
330fi
331
332if test -z "$ac_list_mounted_fs"; then
333 # Interix / BSD alike statvfs
334 # the code is really interix specific, so make sure, we're on it.
335 case "$host" in
336 *-interix*)
337 AC_CHECK_FUNCS([statvfs])
338 if test $ac_cv_func_statvfs = yes; then
339 ac_list_mounted_fs=found
340 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
341 [Define if we are on interix, and ought to use statvfs plus
342 some special knowledge on where mounted file systems can be
343 found. (Interix)])
344 fi
345 ;;
346 esac
347fi
348
349if test -z "$ac_list_mounted_fs"; then
350 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
351 # FIXME -- no need to abort building the whole package
352 # Can't build mountlist.c or anything that needs its functions
353fi
354
355AS_IF([test $ac_list_mounted_fs = found], [$1], [$2])
356
357 ])
diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4
new file mode 100644
index 0000000..fd4f1f2
--- /dev/null
+++ b/gl/m4/lseek.m4
@@ -0,0 +1,78 @@
1# lseek.m4 serial 12
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_LSEEK],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([AC_PROG_CC])
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
15 [case "$host_os" in
16 mingw*)
17 dnl Native Windows.
18 dnl The result of lseek (fd, (off_t)0, SEEK_CUR) or
19 dnl SetFilePointer(handle, 0, NULL, FILE_CURRENT)
20 dnl for a pipe depends on the environment: In a Cygwin 1.5
21 dnl environment it succeeds (wrong); in a Cygwin 1.7 environment
22 dnl it fails with a wrong errno value.
23 gl_cv_func_lseek_pipe=no
24 ;;
25 *)
26 if test $cross_compiling = no; then
27 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
28#include <sys/types.h> /* for off_t */
29#include <stdio.h> /* for SEEK_CUR */
30#if HAVE_UNISTD_H
31# include <unistd.h>
32#else /* on Windows with MSVC */
33# include <io.h>
34#endif
35]GL_MDA_DEFINES],
36[[
37 /* Exit with success only if stdin is seekable. */
38 return lseek (0, (off_t)0, SEEK_CUR) < 0;
39]])],
40 [if test -s conftest$ac_exeext \
41 && ./conftest$ac_exeext < conftest.$ac_ext \
42 && test 1 = "`echo hi \
43 | { ./conftest$ac_exeext; echo $?; cat >/dev/null; }`"; then
44 gl_cv_func_lseek_pipe=yes
45 else
46 gl_cv_func_lseek_pipe=no
47 fi
48 ],
49 [gl_cv_func_lseek_pipe=no])
50 else
51 AC_COMPILE_IFELSE(
52 [AC_LANG_SOURCE([[
53#if defined __BEOS__
54/* BeOS mistakenly return 0 when trying to seek on pipes. */
55 Choke me.
56#endif]])],
57 [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
58 fi
59 ;;
60 esac
61 ])
62 if test "$gl_cv_func_lseek_pipe" = no; then
63 REPLACE_LSEEK=1
64 AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
65 [Define to 1 if lseek does not detect pipes.])
66 fi
67
68 AC_REQUIRE([gl_SYS_TYPES_H])
69 if test $WINDOWS_64_BIT_OFF_T = 1; then
70 REPLACE_LSEEK=1
71 fi
72
73 dnl macOS SEEK_DATA is incompatible with other platforms.
74 case $host_os in
75 darwin*)
76 REPLACE_LSEEK=1;;
77 esac
78])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 4b24a0b..5540292 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,98 +1,175 @@
1# malloc.m4 serial 14 1# malloc.m4 serial 28
2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7m4_version_prereq([2.70], [] ,[ 7# This is adapted with modifications from upstream Autoconf here:
8 8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n949
9# This is taken from the following Autoconf patch:
10# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
11AC_DEFUN([_AC_FUNC_MALLOC_IF], 9AC_DEFUN([_AC_FUNC_MALLOC_IF],
12[ 10[
13 AC_REQUIRE([AC_HEADER_STDC])dnl
14 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles 11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
15 AC_CHECK_HEADERS([stdlib.h]) 12 AC_CACHE_CHECK([whether malloc (0) returns nonnull],
16 AC_CACHE_CHECK([for GNU libc compatible malloc],
17 [ac_cv_func_malloc_0_nonnull], 13 [ac_cv_func_malloc_0_nonnull],
18 [AC_RUN_IFELSE( 14 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM( 15 [AC_LANG_PROGRAM(
20 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H 16 [[#include <stdlib.h>
21 # include <stdlib.h>
22 #else
23 char *malloc ();
24 #endif
25 ]], 17 ]],
26 [[return ! malloc (0);]]) 18 [[void *p = malloc (0);
19 int result = !p;
20 free (p);
21 return result;]])
27 ], 22 ],
28 [ac_cv_func_malloc_0_nonnull=yes], 23 [ac_cv_func_malloc_0_nonnull=yes],
29 [ac_cv_func_malloc_0_nonnull=no], 24 [ac_cv_func_malloc_0_nonnull=no],
30 [case "$host_os" in 25 [case "$host_os" in
31 # Guess yes on platforms where we know the result. 26 # Guess yes on platforms where we know the result.
32 *-gnu* | freebsd* | netbsd* | openbsd* \ 27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
33 | hpux* | solaris* | cygwin* | mingw*) 28 | gnu* | *-musl* | midnightbsd* \
34 ac_cv_func_malloc_0_nonnull=yes ;; 29 | hpux* | solaris* | cygwin* | mingw* | msys* )
35 # If we don't know, assume the worst. 30 ac_cv_func_malloc_0_nonnull="guessing yes" ;;
36 *) ac_cv_func_malloc_0_nonnull=no ;; 31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_malloc_0_nonnull="$gl_cross_guess_normal" ;;
37 esac 33 esac
38 ]) 34 ])
39 ]) 35 ])
40 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2]) 36 AS_CASE([$ac_cv_func_malloc_0_nonnull], [*yes], [$1], [$2])
41])# _AC_FUNC_MALLOC_IF 37])# _AC_FUNC_MALLOC_IF
42 38
43])
44
45# gl_FUNC_MALLOC_GNU 39# gl_FUNC_MALLOC_GNU
46# ------------------ 40# ------------------
47# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if 41# Replace malloc if it is not compatible with GNU libc.
48# it is not.
49AC_DEFUN([gl_FUNC_MALLOC_GNU], 42AC_DEFUN([gl_FUNC_MALLOC_GNU],
50[ 43[
51 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
52 dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. 45 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
53 _AC_FUNC_MALLOC_IF( 46 REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX"
54 [AC_DEFINE([HAVE_MALLOC_GNU], [1], 47 if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then
55 [Define to 1 if your system has a GNU libc compatible 'malloc' 48 _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
56 function, and to 0 otherwise.])], 49 fi
57 [AC_DEFINE([HAVE_MALLOC_GNU], [0]) 50])
58 REPLACE_MALLOC=1 51
52# gl_FUNC_MALLOC_PTRDIFF
53# ----------------------
54# Test whether malloc (N) reliably fails when N exceeds PTRDIFF_MAX,
55# and replace malloc otherwise.
56AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
60 test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1
61])
62
63# Test whether malloc, realloc, calloc refuse to create objects
64# larger than what can be expressed in ptrdiff_t.
65# Set gl_cv_func_malloc_gnu to yes or no accordingly.
66AC_DEFUN([gl_CHECK_MALLOC_PTRDIFF],
67[
68 AC_CACHE_CHECK([whether malloc is ptrdiff_t safe],
69 [gl_cv_malloc_ptrdiff],
70 [AC_COMPILE_IFELSE(
71 [AC_LANG_PROGRAM(
72 [[#include <stdint.h>
73 ]],
74 [[/* 64-bit ptrdiff_t is so wide that no practical platform
75 can exceed it. */
76 #define WIDE_PTRDIFF (PTRDIFF_MAX >> 31 >> 31 != 0)
77
78 /* On rare machines where size_t fits in ptrdiff_t there
79 is no problem. */
80 #define NARROW_SIZE (SIZE_MAX <= PTRDIFF_MAX)
81
82 /* glibc 2.30 and later malloc refuses to exceed ptrdiff_t
83 bounds even on 32-bit platforms. We don't know which
84 non-glibc systems are safe. */
85 #define KNOWN_SAFE (2 < __GLIBC__ + (30 <= __GLIBC_MINOR__))
86
87 #if WIDE_PTRDIFF || NARROW_SIZE || KNOWN_SAFE
88 return 0;
89 #else
90 #error "malloc might not be ptrdiff_t safe"
91 syntax error
92 #endif
93 ]])],
94 [gl_cv_malloc_ptrdiff=yes],
95 [gl_cv_malloc_ptrdiff=no])
59 ]) 96 ])
60]) 97])
61 98
62# gl_FUNC_MALLOC_POSIX 99# gl_FUNC_MALLOC_POSIX
63# -------------------- 100# --------------------
64# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it 101# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
65# fails), and replace malloc if it is not. 102# fails, and doesn't mess up with ptrdiff_t overflow), and replace
103# malloc if it is not.
66AC_DEFUN([gl_FUNC_MALLOC_POSIX], 104AC_DEFUN([gl_FUNC_MALLOC_POSIX],
67[ 105[
68 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 106 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
107 AC_REQUIRE([gl_FUNC_MALLOC_PTRDIFF])
69 AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) 108 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
70 if test $gl_cv_func_malloc_posix = yes; then 109 if test "$gl_cv_func_malloc_posix" = yes; then
71 AC_DEFINE([HAVE_MALLOC_POSIX], [1], 110 AC_DEFINE([HAVE_MALLOC_POSIX], [1],
72 [Define if the 'malloc' function is POSIX compliant.]) 111 [Define if malloc, realloc, and calloc set errno on allocation failure.])
73 else 112 else
74 REPLACE_MALLOC=1 113 REPLACE_MALLOC_FOR_MALLOC_POSIX=1
75 fi 114 fi
76]) 115])
77 116
78# Test whether malloc, realloc, calloc are POSIX compliant, 117# Test whether malloc, realloc, calloc set errno to ENOMEM on failure.
79# Set gl_cv_func_malloc_posix to yes or no accordingly. 118# Set gl_cv_func_malloc_posix to yes or no accordingly.
80AC_DEFUN([gl_CHECK_MALLOC_POSIX], 119AC_DEFUN([gl_CHECK_MALLOC_POSIX],
81[ 120[
82 AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant], 121 AC_REQUIRE([AC_CANONICAL_HOST])
122 AC_CACHE_CHECK([whether malloc, realloc, calloc set errno on failure],
83 [gl_cv_func_malloc_posix], 123 [gl_cv_func_malloc_posix],
84 [ 124 [
85 dnl It is too dangerous to try to allocate a large amount of memory: 125 dnl It is too dangerous to try to allocate a large amount of memory:
86 dnl some systems go to their knees when you do that. So assume that 126 dnl some systems go to their knees when you do that. So assume that
87 dnl all Unix implementations of the function are POSIX compliant. 127 dnl all Unix implementations of the function set errno on failure,
88 AC_COMPILE_IFELSE( 128 dnl except on those platforms where we have seen 'test-malloc-gnu',
89 [AC_LANG_PROGRAM( 129 dnl 'test-realloc-gnu', 'test-calloc-gnu' fail.
90 [[]], 130 case "$host_os" in
91 [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 131 mingw*)
92 choke me 132 gl_cv_func_malloc_posix=no ;;
93 #endif 133 irix* | solaris*)
94 ]])], 134 dnl On IRIX 6.5, the three functions return NULL with errno unset
95 [gl_cv_func_malloc_posix=yes], 135 dnl when the argument is larger than PTRDIFF_MAX.
96 [gl_cv_func_malloc_posix=no]) 136 dnl On Solaris 11.3, the three functions return NULL with errno set
137 dnl to EAGAIN, not ENOMEM, when the argument is larger than
138 dnl PTRDIFF_MAX.
139 dnl Here is a test program:
140m4_divert_push([KILL])
141#include <errno.h>
142#include <stdio.h>
143#include <stdlib.h>
144#define ptrdiff_t long
145#ifndef PTRDIFF_MAX
146# define PTRDIFF_MAX ((ptrdiff_t) ((1UL << (8 * sizeof (ptrdiff_t) - 1)) - 1))
147#endif
148
149int main ()
150{
151 void *p;
152
153 fprintf (stderr, "PTRDIFF_MAX = %lu\n", (unsigned long) PTRDIFF_MAX);
154
155 errno = 0;
156 p = malloc ((unsigned long) PTRDIFF_MAX + 1);
157 fprintf (stderr, "p=%p errno=%d\n", p, errno);
158
159 errno = 0;
160 p = calloc (PTRDIFF_MAX / 2 + 1, 2);
161 fprintf (stderr, "p=%p errno=%d\n", p, errno);
162
163 errno = 0;
164 p = realloc (NULL, (unsigned long) PTRDIFF_MAX + 1);
165 fprintf (stderr, "p=%p errno=%d\n", p, errno);
166
167 return 0;
168}
169m4_divert_pop([KILL])
170 gl_cv_func_malloc_posix=no ;;
171 *)
172 gl_cv_func_malloc_posix=yes ;;
173 esac
97 ]) 174 ])
98]) 175])
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
index 791ce10..1d777eb 100644
--- a/gl/m4/malloca.m4
+++ b/gl/m4/malloca.m4
@@ -1,5 +1,5 @@
1# malloca.m4 serial 1 1# malloca.m4 serial 2
2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -11,5 +11,4 @@ AC_DEFUN([gl_MALLOCA],
11 dnl @ALLOCA@ and @LTALLOCA@. 11 dnl @ALLOCA@ and @LTALLOCA@.
12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. 12 dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies.
13 AC_REQUIRE([gl_EEMALLOC]) 13 AC_REQUIRE([gl_EEMALLOC])
14 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
15]) 14])
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
index bf0845f..d2e90ff 100644
--- a/gl/m4/math_h.m4
+++ b/gl/m4/math_h.m4
@@ -1,16 +1,16 @@
1# math_h.m4 serial 114 1# math_h.m4 serial 125
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_MATH_H], 7AC_DEFUN_ONCE([gl_MATH_H],
8[ 8[
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([math.h]) 10 gl_CHECK_NEXT_HEADERS([math.h])
11 11
12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works], 12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
14 [[/* Solaris 10 has a broken definition of NAN. Other platforms 14 [[/* Solaris 10 has a broken definition of NAN. Other platforms
15 fail to provide NAN, or provide it only in C99 mode; this 15 fail to provide NAN, or provide it only in C99 mode; this
16 test only needs to fail when NAN is provided but wrong. */ 16 test only needs to fail when NAN is provided but wrong. */
@@ -25,7 +25,7 @@ AC_DEFUN([gl_MATH_H],
25 REPLACE_NAN=1 25 REPLACE_NAN=1
26 fi 26 fi
27 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works], 27 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
29 [[/* Solaris 10 has a broken definition of HUGE_VAL. */ 29 [[/* Solaris 10 has a broken definition of HUGE_VAL. */
30 double d = HUGE_VAL; 30 double d = HUGE_VAL;
31 return d == 0;]])], 31 return d == 0;]])],
@@ -53,272 +53,310 @@ AC_DEFUN([gl_MATH_H],
53 tanf tanl tanhf trunc truncf truncl]) 53 tanf tanl tanhf trunc truncf truncl])
54]) 54])
55 55
56# gl_MATH_MODULE_INDICATOR([modulename])
57# sets the shell variable that indicates the presence of the given module
58# to a C preprocessor expression that will evaluate to 1.
59# This macro invocation must not occur in macros that are AC_REQUIREd.
56AC_DEFUN([gl_MATH_MODULE_INDICATOR], 60AC_DEFUN([gl_MATH_MODULE_INDICATOR],
57[ 61[
58 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 62 dnl Ensure to expand the default settings once only.
59 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 63 gl_MATH_H_REQUIRE_DEFAULTS
60 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 64 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
61 dnl Define it also as a C macro, for the benefit of the unit tests. 65 dnl Define it also as a C macro, for the benefit of the unit tests.
62 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 66 gl_MODULE_INDICATOR_FOR_TESTS([$1])
63]) 67])
64 68
69# Initializes the default values for AC_SUBSTed shell variables.
70# This macro must not be AC_REQUIREd. It must only be invoked, and only
71# outside of macros or in macros that are not AC_REQUIREd.
72AC_DEFUN([gl_MATH_H_REQUIRE_DEFAULTS],
73[
74 m4_defun(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS], [
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSF])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACOSL])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINF])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ASINL])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANF])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATANL])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATAN2F])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRT])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTF])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CBRTL])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEIL])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILF])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CEILL])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGN])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNF])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPYSIGNL])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSF])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSL])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COSHF])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPF])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPL])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2F])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXP2L])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1F])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPM1L])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSF])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FABSL])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOOR])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORF])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FLOORL])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMA])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAF])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMAL])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMOD])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODF])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FMODL])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPF])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXP])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREXPL])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOT])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTF])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_HYPOTL])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGB])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBF])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ILOGBL])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISFINITE])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISINF])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAN])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANF])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNAND])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISNANL])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPF])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LDEXPL])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGL])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10F])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG10L])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1P])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PF])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG1PL])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2F])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOG2L])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGB])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBF])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOGBL])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFF])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MODFL])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POWF])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDER])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMAINDERL])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINT])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RINTL])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUND])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ROUNDL])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGNBIT])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINF])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINL])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SINHF])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTF])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SQRTL])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANF])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANL])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TANHF])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNC])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCF])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCL])
170 dnl Support Microsoft deprecated alias function names by default.
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J0], [1])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_J1], [1])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_JN], [1])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y0], [1])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_Y1], [1])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_YN], [1])
177 ])
178 m4_require(GL_MODULE_INDICATOR_PREFIX[_MATH_H_MODULE_INDICATOR_DEFAULTS])
179 AC_REQUIRE([gl_MATH_H_DEFAULTS])
180])
181
65AC_DEFUN([gl_MATH_H_DEFAULTS], 182AC_DEFUN([gl_MATH_H_DEFAULTS],
66[ 183[
67 GNULIB_ACOSF=0; AC_SUBST([GNULIB_ACOSF])
68 GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
69 GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF])
70 GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
71 GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF])
72 GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
73 GNULIB_ATAN2F=0; AC_SUBST([GNULIB_ATAN2F])
74 GNULIB_CBRT=0; AC_SUBST([GNULIB_CBRT])
75 GNULIB_CBRTF=0; AC_SUBST([GNULIB_CBRTF])
76 GNULIB_CBRTL=0; AC_SUBST([GNULIB_CBRTL])
77 GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL])
78 GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
79 GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
80 GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN])
81 GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
82 GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
83 GNULIB_COSF=0; AC_SUBST([GNULIB_COSF])
84 GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
85 GNULIB_COSHF=0; AC_SUBST([GNULIB_COSHF])
86 GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF])
87 GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
88 GNULIB_EXP2=0; AC_SUBST([GNULIB_EXP2])
89 GNULIB_EXP2F=0; AC_SUBST([GNULIB_EXP2F])
90 GNULIB_EXP2L=0; AC_SUBST([GNULIB_EXP2L])
91 GNULIB_EXPM1=0; AC_SUBST([GNULIB_EXPM1])
92 GNULIB_EXPM1F=0; AC_SUBST([GNULIB_EXPM1F])
93 GNULIB_EXPM1L=0; AC_SUBST([GNULIB_EXPM1L])
94 GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF])
95 GNULIB_FABSL=0; AC_SUBST([GNULIB_FABSL])
96 GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR])
97 GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
98 GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
99 GNULIB_FMA=0; AC_SUBST([GNULIB_FMA])
100 GNULIB_FMAF=0; AC_SUBST([GNULIB_FMAF])
101 GNULIB_FMAL=0; AC_SUBST([GNULIB_FMAL])
102 GNULIB_FMOD=0; AC_SUBST([GNULIB_FMOD])
103 GNULIB_FMODF=0; AC_SUBST([GNULIB_FMODF])
104 GNULIB_FMODL=0; AC_SUBST([GNULIB_FMODL])
105 GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
106 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
107 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
108 GNULIB_HYPOT=0; AC_SUBST([GNULIB_HYPOT])
109 GNULIB_HYPOTF=0; AC_SUBST([GNULIB_HYPOTF])
110 GNULIB_HYPOTL=0; AC_SUBST([GNULIB_HYPOTL])
111 GNULIB_ILOGB=0; AC_SUBST([GNULIB_ILOGB])
112 GNULIB_ILOGBF=0; AC_SUBST([GNULIB_ILOGBF])
113 GNULIB_ILOGBL=0; AC_SUBST([GNULIB_ILOGBL])
114 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
115 GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
116 GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
117 GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF])
118 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
119 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
120 GNULIB_LDEXPF=0; AC_SUBST([GNULIB_LDEXPF])
121 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
122 GNULIB_LOG=0; AC_SUBST([GNULIB_LOG])
123 GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF])
124 GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
125 GNULIB_LOG10=0; AC_SUBST([GNULIB_LOG10])
126 GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F])
127 GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L])
128 GNULIB_LOG1P=0; AC_SUBST([GNULIB_LOG1P])
129 GNULIB_LOG1PF=0; AC_SUBST([GNULIB_LOG1PF])
130 GNULIB_LOG1PL=0; AC_SUBST([GNULIB_LOG1PL])
131 GNULIB_LOG2=0; AC_SUBST([GNULIB_LOG2])
132 GNULIB_LOG2F=0; AC_SUBST([GNULIB_LOG2F])
133 GNULIB_LOG2L=0; AC_SUBST([GNULIB_LOG2L])
134 GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
135 GNULIB_LOGBF=0; AC_SUBST([GNULIB_LOGBF])
136 GNULIB_LOGBL=0; AC_SUBST([GNULIB_LOGBL])
137 GNULIB_MODF=0; AC_SUBST([GNULIB_MODF])
138 GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
139 GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL])
140 GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
141 GNULIB_REMAINDER=0; AC_SUBST([GNULIB_REMAINDER])
142 GNULIB_REMAINDERF=0; AC_SUBST([GNULIB_REMAINDERF])
143 GNULIB_REMAINDERL=0; AC_SUBST([GNULIB_REMAINDERL])
144 GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
145 GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
146 GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL])
147 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
148 GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
149 GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
150 GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
151 GNULIB_SINF=0; AC_SUBST([GNULIB_SINF])
152 GNULIB_SINL=0; AC_SUBST([GNULIB_SINL])
153 GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF])
154 GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF])
155 GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL])
156 GNULIB_TANF=0; AC_SUBST([GNULIB_TANF])
157 GNULIB_TANL=0; AC_SUBST([GNULIB_TANL])
158 GNULIB_TANHF=0; AC_SUBST([GNULIB_TANHF])
159 GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC])
160 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
161 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
162 dnl Assume proper GNU behavior unless another module says otherwise. 184 dnl Assume proper GNU behavior unless another module says otherwise.
163 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF]) 185 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF])
164 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) 186 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
165 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF]) 187 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF])
166 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) 188 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
167 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF]) 189 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF])
168 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) 190 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
169 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F]) 191 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F])
170 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT]) 192 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT])
171 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF]) 193 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF])
172 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL]) 194 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL])
173 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN]) 195 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN])
174 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL]) 196 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL])
175 HAVE_COSF=1; AC_SUBST([HAVE_COSF]) 197 HAVE_COSF=1; AC_SUBST([HAVE_COSF])
176 HAVE_COSL=1; AC_SUBST([HAVE_COSL]) 198 HAVE_COSL=1; AC_SUBST([HAVE_COSL])
177 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF]) 199 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF])
178 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF]) 200 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
179 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) 201 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
180 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1]) 202 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1])
181 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F]) 203 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F])
182 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF]) 204 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
183 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL]) 205 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL])
184 HAVE_FMA=1; AC_SUBST([HAVE_FMA]) 206 HAVE_FMA=1; AC_SUBST([HAVE_FMA])
185 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF]) 207 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF])
186 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL]) 208 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL])
187 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF]) 209 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
188 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL]) 210 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
189 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF]) 211 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
190 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF]) 212 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF])
191 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL]) 213 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL])
192 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB]) 214 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB])
193 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF]) 215 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF])
194 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL]) 216 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL])
195 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF]) 217 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
196 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND]) 218 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
197 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL]) 219 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
198 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF]) 220 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF])
199 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF]) 221 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF])
200 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) 222 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
201 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) 223 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F])
202 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L]) 224 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L])
203 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P]) 225 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P])
204 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF]) 226 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF])
205 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL]) 227 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL])
206 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF]) 228 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF])
207 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL]) 229 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL])
208 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) 230 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
209 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL]) 231 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL])
210 HAVE_POWF=1; AC_SUBST([HAVE_POWF]) 232 HAVE_POWF=1; AC_SUBST([HAVE_POWF])
211 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER]) 233 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER])
212 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF]) 234 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF])
213 HAVE_RINT=1; AC_SUBST([HAVE_RINT]) 235 HAVE_RINT=1; AC_SUBST([HAVE_RINT])
214 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL]) 236 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
215 HAVE_SINF=1; AC_SUBST([HAVE_SINF]) 237 HAVE_SINF=1; AC_SUBST([HAVE_SINF])
216 HAVE_SINL=1; AC_SUBST([HAVE_SINL]) 238 HAVE_SINL=1; AC_SUBST([HAVE_SINL])
217 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF]) 239 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF])
218 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) 240 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF])
219 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) 241 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
220 HAVE_TANF=1; AC_SUBST([HAVE_TANF]) 242 HAVE_TANF=1; AC_SUBST([HAVE_TANF])
221 HAVE_TANL=1; AC_SUBST([HAVE_TANL]) 243 HAVE_TANL=1; AC_SUBST([HAVE_TANL])
222 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF]) 244 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF])
223 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) 245 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
224 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) 246 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
225 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) 247 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
226 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF]) 248 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF])
227 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL]) 249 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL])
228 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) 250 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF])
229 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) 251 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL])
230 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF]) 252 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF])
231 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) 253 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL])
232 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) 254 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL])
233 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2]) 255 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2])
234 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F]) 256 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F])
235 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L]) 257 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L])
236 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L]) 258 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L])
237 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) 259 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF])
238 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) 260 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
239 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) 261 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL])
240 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) 262 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL])
241 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) 263 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL])
242 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L]) 264 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L])
243 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2]) 265 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2])
244 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F]) 266 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F])
245 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L]) 267 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L])
246 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) 268 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
247 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER]) 269 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER])
248 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL]) 270 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL])
249 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF]) 271 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF])
250 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) 272 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND])
251 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) 273 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF])
252 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) 274 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL])
253 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) 275 HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL])
254 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) 276 HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL])
255 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) 277 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
256 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) 278 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC])
257 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) 279 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
258 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) 280 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
259 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF]) 281 REPLACE_ACOSF=0; AC_SUBST([REPLACE_ACOSF])
260 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL]) 282 REPLACE_ASINF=0; AC_SUBST([REPLACE_ASINF])
261 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL]) 283 REPLACE_ATANF=0; AC_SUBST([REPLACE_ATANF])
262 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) 284 REPLACE_ATAN2F=0; AC_SUBST([REPLACE_ATAN2F])
263 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) 285 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF])
264 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1]) 286 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL])
265 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F]) 287 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL])
266 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2]) 288 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF])
267 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L]) 289 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL])
268 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL]) 290 REPLACE_COSF=0; AC_SUBST([REPLACE_COSF])
269 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR]) 291 REPLACE_COSHF=0; AC_SUBST([REPLACE_COSHF])
270 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) 292 REPLACE_EXPF=0; AC_SUBST([REPLACE_EXPF])
271 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) 293 REPLACE_EXPL=0; AC_SUBST([REPLACE_EXPL])
272 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA]) 294 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1])
273 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF]) 295 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F])
274 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL]) 296 REPLACE_EXPM1L=0; AC_SUBST([REPLACE_EXPM1L])
275 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD]) 297 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2])
276 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF]) 298 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L])
277 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL]) 299 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL])
278 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF]) 300 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR])
279 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) 301 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
280 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) 302 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
281 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) 303 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA])
282 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT]) 304 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF])
283 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF]) 305 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL])
284 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL]) 306 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD])
285 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB]) 307 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF])
286 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF]) 308 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL])
287 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) 309 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
288 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) 310 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
289 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) 311 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
290 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) 312 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
291 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG]) 313 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT])
292 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF]) 314 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF])
293 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL]) 315 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL])
294 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10]) 316 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB])
295 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F]) 317 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF])
296 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L]) 318 REPLACE_ILOGBL=0; AC_SUBST([REPLACE_ILOGBL])
297 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P]) 319 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
298 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF]) 320 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
299 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL]) 321 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
300 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2]) 322 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
301 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F]) 323 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG])
302 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L]) 324 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
303 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB]) 325 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL])
304 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF]) 326 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10])
305 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL]) 327 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F])
306 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF]) 328 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L])
307 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF]) 329 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P])
308 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL]) 330 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF])
309 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) 331 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL])
310 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER]) 332 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2])
311 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF]) 333 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F])
312 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL]) 334 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L])
313 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) 335 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB])
314 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) 336 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF])
315 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) 337 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL])
316 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) 338 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF])
317 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) 339 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
318 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL]) 340 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL])
319 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC]) 341 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
320 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF]) 342 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER])
321 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) 343 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF])
344 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL])
345 REPLACE_RINTL=0; AC_SUBST([REPLACE_RINTL])
346 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
347 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
348 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])
349 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT])
350 REPLACE_SIGNBIT_USING_BUILTINS=0; AC_SUBST([REPLACE_SIGNBIT_USING_BUILTINS])
351 REPLACE_SINF=0; AC_SUBST([REPLACE_SINF])
352 REPLACE_SINHF=0; AC_SUBST([REPLACE_SINHF])
353 REPLACE_SQRTF=0; AC_SUBST([REPLACE_SQRTF])
354 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL])
355 REPLACE_TANF=0; AC_SUBST([REPLACE_TANF])
356 REPLACE_TANHF=0; AC_SUBST([REPLACE_TANHF])
357 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC])
358 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF])
359 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
322]) 360])
323 361
324# gl_LONG_DOUBLE_VS_DOUBLE 362# gl_LONG_DOUBLE_VS_DOUBLE
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index 4c9f388..bb39304 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,5 +1,5 @@
1# mbrtowc.m4 serial 25 1# mbrtowc.m4 serial 38 -*- coding: utf-8 -*-
2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation, 2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,8 @@ dnl with or without modifications, as long as this notice is preserved.
8AC_DEFUN([gl_FUNC_MBRTOWC], 8AC_DEFUN([gl_FUNC_MBRTOWC],
9[ 9[
10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 10 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
11 AC_REQUIRE([gl_PTHREADLIB])
12 AC_CHECK_HEADERS_ONCE([threads.h])
11 13
12 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 14 AC_REQUIRE([AC_TYPE_MBSTATE_T])
13 gl_MBSTATE_T_BROKEN 15 gl_MBSTATE_T_BROKEN
@@ -16,15 +18,8 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
16 if test $ac_cv_func_mbrtowc = no; then 18 if test $ac_cv_func_mbrtowc = no; then
17 HAVE_MBRTOWC=0 19 HAVE_MBRTOWC=0
18 AC_CHECK_DECLS([mbrtowc],,, [[ 20 AC_CHECK_DECLS([mbrtowc],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 21 #include <wchar.h>
20 <wchar.h>. 22 ]])
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbrtowc = yes; then 23 if test $ac_cv_have_decl_mbrtowc = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although 24 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
30 dnl it does not have the function. Avoid a collision with gnulib's 25 dnl it does not have the function. Avoid a collision with gnulib's
@@ -39,6 +34,9 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
39 gl_MBRTOWC_NULL_ARG2 34 gl_MBRTOWC_NULL_ARG2
40 gl_MBRTOWC_RETVAL 35 gl_MBRTOWC_RETVAL
41 gl_MBRTOWC_NUL_RETVAL 36 gl_MBRTOWC_NUL_RETVAL
37 gl_MBRTOWC_STORES_INCOMPLETE
38 gl_MBRTOWC_EMPTY_INPUT
39 gl_MBRTOWC_C_LOCALE
42 case "$gl_cv_func_mbrtowc_null_arg1" in 40 case "$gl_cv_func_mbrtowc_null_arg1" in
43 *yes) ;; 41 *yes) ;;
44 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1], 42 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
@@ -67,8 +65,47 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
67 REPLACE_MBRTOWC=1 65 REPLACE_MBRTOWC=1
68 ;; 66 ;;
69 esac 67 esac
68 case "$gl_cv_func_mbrtowc_stores_incomplete" in
69 *no) ;;
70 *) AC_DEFINE([MBRTOWC_STORES_INCOMPLETE_BUG], [1],
71 [Define if the mbrtowc function stores a wide character when reporting incomplete input.])
72 REPLACE_MBRTOWC=1
73 ;;
74 esac
75 case "$gl_cv_func_mbrtowc_empty_input" in
76 *yes) ;;
77 *) AC_DEFINE([MBRTOWC_EMPTY_INPUT_BUG], [1],
78 [Define if the mbrtowc function does not return (size_t) -2
79 for empty input.])
80 REPLACE_MBRTOWC=1
81 ;;
82 esac
83 case "$gl_cv_func_mbrtowc_C_locale_sans_EILSEQ" in
84 *yes) ;;
85 *) AC_DEFINE([MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ], [1],
86 [Define if the mbrtowc function may signal encoding errors in the C locale.])
87 REPLACE_MBRTOWC=1
88 ;;
89 esac
70 fi 90 fi
71 fi 91 fi
92 if test $REPLACE_MBSTATE_T = 1; then
93 case "$host_os" in
94 mingw*) LIB_MBRTOWC= ;;
95 *)
96 gl_WEAK_SYMBOLS
97 case "$gl_cv_have_weak" in
98 *yes) LIB_MBRTOWC= ;;
99 *) LIB_MBRTOWC="$LIBPTHREAD" ;;
100 esac
101 ;;
102 esac
103 else
104 LIB_MBRTOWC=
105 fi
106 dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX
107 dnl with gcc or xlc, and empty otherwise.
108 AC_SUBST([LIB_MBRTOWC])
72]) 109])
73 110
74dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that 111dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
@@ -80,11 +117,19 @@ dnl avoid inconsistencies.
80AC_DEFUN([gl_MBSTATE_T_BROKEN], 117AC_DEFUN([gl_MBSTATE_T_BROKEN],
81[ 118[
82 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 119 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
120 AC_REQUIRE([AC_CANONICAL_HOST])
83 121
84 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 122 AC_REQUIRE([AC_TYPE_MBSTATE_T])
85 AC_CHECK_FUNCS_ONCE([mbsinit]) 123 AC_CHECK_FUNCS_ONCE([mbsinit])
86 AC_CHECK_FUNCS_ONCE([mbrtowc]) 124 AC_CHECK_FUNCS_ONCE([mbrtowc])
87 if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then 125 dnl On native Windows, we know exactly how mbsinit() behaves and don't need
126 dnl to override it, even if - like on MSVC - mbsinit() is only defined as
127 dnl an inline function, not as a global function.
128 if case "$host_os" in
129 mingw*) true ;;
130 *) test $ac_cv_func_mbsinit = yes ;;
131 esac \
132 && test $ac_cv_func_mbrtowc = yes; then
88 gl_MBRTOWC_INCOMPLETE_STATE 133 gl_MBRTOWC_INCOMPLETE_STATE
89 gl_MBRTOWC_SANITYCHECK 134 gl_MBRTOWC_SANITYCHECK
90 REPLACE_MBSTATE_T=0 135 REPLACE_MBSTATE_T=0
@@ -109,6 +154,7 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
109[ 154[
110 AC_REQUIRE([AC_PROG_CC]) 155 AC_REQUIRE([AC_PROG_CC])
111 AC_REQUIRE([gt_LOCALE_JA]) 156 AC_REQUIRE([gt_LOCALE_JA])
157 AC_REQUIRE([gt_LOCALE_FR_UTF8])
112 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 158 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
113 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters], 159 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
114 [gl_cv_func_mbrtowc_incomplete_state], 160 [gl_cv_func_mbrtowc_incomplete_state],
@@ -128,13 +174,6 @@ changequote([,])dnl
128 [AC_LANG_SOURCE([[ 174 [AC_LANG_SOURCE([[
129#include <locale.h> 175#include <locale.h>
130#include <string.h> 176#include <string.h>
131/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
132 <wchar.h>.
133 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
134 included before <wchar.h>. */
135#include <stddef.h>
136#include <stdio.h>
137#include <time.h>
138#include <wchar.h> 177#include <wchar.h>
139int main () 178int main ()
140{ 179{
@@ -147,13 +186,39 @@ int main ()
147 memset (&state, '\0', sizeof (mbstate_t)); 186 memset (&state, '\0', sizeof (mbstate_t));
148 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2)) 187 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
149 if (mbsinit (&state)) 188 if (mbsinit (&state))
150 return 1; 189 return 2;
190 }
191 return 0;
192}]])],
193 [gl_cv_func_mbrtowc_incomplete_state=yes],
194 [gl_cv_func_mbrtowc_incomplete_state=no],
195 [:])
196 else
197 if test $LOCALE_FR_UTF8 != none; then
198 AC_RUN_IFELSE(
199 [AC_LANG_SOURCE([[
200#include <locale.h>
201#include <string.h>
202#include <wchar.h>
203int main ()
204{
205 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
206 {
207 const char input[] = "B\303\274\303\237er"; /* "Büßer" */
208 mbstate_t state;
209 wchar_t wc;
210
211 memset (&state, '\0', sizeof (mbstate_t));
212 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
213 if (mbsinit (&state))
214 return 2;
151 } 215 }
152 return 0; 216 return 0;
153}]])], 217}]])],
154 [gl_cv_func_mbrtowc_incomplete_state=yes], 218 [gl_cv_func_mbrtowc_incomplete_state=yes],
155 [gl_cv_func_mbrtowc_incomplete_state=no], 219 [gl_cv_func_mbrtowc_incomplete_state=no],
156 [:]) 220 [:])
221 fi
157 fi 222 fi
158 ]) 223 ])
159]) 224])
@@ -185,13 +250,6 @@ changequote([,])dnl
185#include <locale.h> 250#include <locale.h>
186#include <stdlib.h> 251#include <stdlib.h>
187#include <string.h> 252#include <string.h>
188/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
189 <wchar.h>.
190 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
191 included before <wchar.h>. */
192#include <stddef.h>
193#include <stdio.h>
194#include <time.h>
195#include <wchar.h> 253#include <wchar.h>
196int main () 254int main ()
197{ 255{
@@ -207,7 +265,7 @@ int main ()
207 memset (&state, '\0', sizeof (mbstate_t)); 265 memset (&state, '\0', sizeof (mbstate_t));
208 if (mbrtowc (&wc, input + 3, 6, &state) != 4 266 if (mbrtowc (&wc, input + 3, 6, &state) != 4
209 && mbtowc (&wc, input + 3, 6) == 4) 267 && mbtowc (&wc, input + 3, 6) == 4)
210 return 1; 268 return 2;
211 } 269 }
212 return 0; 270 return 0;
213}]])], 271}]])],
@@ -245,13 +303,6 @@ changequote([,])dnl
245#include <locale.h> 303#include <locale.h>
246#include <stdlib.h> 304#include <stdlib.h>
247#include <string.h> 305#include <string.h>
248/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
249 <wchar.h>.
250 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
251 included before <wchar.h>. */
252#include <stddef.h>
253#include <stdio.h>
254#include <time.h>
255#include <wchar.h> 306#include <wchar.h>
256int main () 307int main ()
257{ 308{
@@ -314,13 +365,6 @@ changequote([,])dnl
314 [AC_LANG_SOURCE([[ 365 [AC_LANG_SOURCE([[
315#include <locale.h> 366#include <locale.h>
316#include <string.h> 367#include <string.h>
317/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
318 <wchar.h>.
319 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
320 included before <wchar.h>. */
321#include <stddef.h>
322#include <stdio.h>
323#include <time.h>
324#include <wchar.h> 368#include <wchar.h>
325int main () 369int main ()
326{ 370{
@@ -335,7 +379,7 @@ int main ()
335 mbrtowc (&wc, NULL, 5, &state); 379 mbrtowc (&wc, NULL, 5, &state);
336 /* Check that wc was not modified. */ 380 /* Check that wc was not modified. */
337 if (wc != (wchar_t) 0xBADFACE) 381 if (wc != (wchar_t) 0xBADFACE)
338 return 1; 382 return 2;
339 } 383 }
340 return 0; 384 return 0;
341}]])], 385}]])],
@@ -376,13 +420,6 @@ changequote([,])dnl
376 [AC_LANG_SOURCE([[ 420 [AC_LANG_SOURCE([[
377#include <locale.h> 421#include <locale.h>
378#include <string.h> 422#include <string.h>
379/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
380 <wchar.h>.
381 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
382 included before <wchar.h>. */
383#include <stddef.h>
384#include <stdio.h>
385#include <time.h>
386#include <wchar.h> 423#include <wchar.h>
387int main () 424int main ()
388{ 425{
@@ -504,13 +541,6 @@ changequote([,])dnl
504 [AC_LANG_SOURCE([[ 541 [AC_LANG_SOURCE([[
505#include <locale.h> 542#include <locale.h>
506#include <string.h> 543#include <string.h>
507/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
508 <wchar.h>.
509 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
510 included before <wchar.h>. */
511#include <stddef.h>
512#include <stdio.h>
513#include <time.h>
514#include <wchar.h> 544#include <wchar.h>
515int main () 545int main ()
516{ 546{
@@ -522,7 +552,7 @@ int main ()
522 552
523 memset (&state, '\0', sizeof (mbstate_t)); 553 memset (&state, '\0', sizeof (mbstate_t));
524 if (mbrtowc (&wc, "", 1, &state) != 0) 554 if (mbrtowc (&wc, "", 1, &state) != 0)
525 return 1; 555 return 2;
526 } 556 }
527 return 0; 557 return 0;
528}]])], 558}]])],
@@ -533,11 +563,206 @@ int main ()
533 ]) 563 ])
534]) 564])
535 565
536# Prerequisites of lib/mbrtowc.c. 566dnl Test whether mbrtowc stores a wide character when reporting incomplete
567dnl input.
568
569AC_DEFUN([gl_MBRTOWC_STORES_INCOMPLETE],
570[
571 AC_REQUIRE([AC_PROG_CC])
572 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
573 AC_CACHE_CHECK([whether mbrtowc stores incomplete characters],
574 [gl_cv_func_mbrtowc_stores_incomplete],
575 [
576 dnl Initial guess, used when cross-compiling or when no suitable locale
577 dnl is present.
578changequote(,)dnl
579 case "$host_os" in
580 # Guess yes on native Windows.
581 mingw*) gl_cv_func_mbrtowc_stores_incomplete="guessing yes" ;;
582 *) gl_cv_func_mbrtowc_stores_incomplete="guessing no" ;;
583 esac
584changequote([,])dnl
585 case "$host_os" in
586 mingw*)
587 AC_RUN_IFELSE(
588 [AC_LANG_SOURCE([[
589#include <locale.h>
590#include <string.h>
591#include <wchar.h>
592int main ()
593{
594 int result = 0;
595 if (setlocale (LC_ALL, "French_France.65001") != NULL)
596 {
597 wchar_t wc = (wchar_t) 0xBADFACE;
598 mbstate_t state;
599
600 memset (&state, '\0', sizeof (mbstate_t));
601 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
602 && wc != (wchar_t) 0xBADFACE)
603 result |= 1;
604 }
605 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
606 {
607 wchar_t wc = (wchar_t) 0xBADFACE;
608 mbstate_t state;
609
610 memset (&state, '\0', sizeof (mbstate_t));
611 if (mbrtowc (&wc, "\226", 1, &state) == (size_t)(-2)
612 && wc != (wchar_t) 0xBADFACE)
613 result |= 2;
614 }
615 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
616 {
617 wchar_t wc = (wchar_t) 0xBADFACE;
618 mbstate_t state;
619
620 memset (&state, '\0', sizeof (mbstate_t));
621 if (mbrtowc (&wc, "\245", 1, &state) == (size_t)(-2)
622 && wc != (wchar_t) 0xBADFACE)
623 result |= 4;
624 }
625 if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
626 {
627 wchar_t wc = (wchar_t) 0xBADFACE;
628 mbstate_t state;
629
630 memset (&state, '\0', sizeof (mbstate_t));
631 if (mbrtowc (&wc, "\261", 1, &state) == (size_t)(-2)
632 && wc != (wchar_t) 0xBADFACE)
633 result |= 8;
634 }
635 return result;
636}]])],
637 [gl_cv_func_mbrtowc_stores_incomplete=no],
638 [gl_cv_func_mbrtowc_stores_incomplete=yes],
639 [:])
640 ;;
641 *)
642 AC_REQUIRE([gt_LOCALE_FR_UTF8])
643 if test $LOCALE_FR_UTF8 != none; then
644 AC_RUN_IFELSE(
645 [AC_LANG_SOURCE([[
646#include <locale.h>
647#include <string.h>
648#include <wchar.h>
649int main ()
650{
651 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
652 {
653 wchar_t wc = (wchar_t) 0xBADFACE;
654 mbstate_t state;
655
656 memset (&state, '\0', sizeof (mbstate_t));
657 if (mbrtowc (&wc, "\303", 1, &state) == (size_t)(-2)
658 && wc != (wchar_t) 0xBADFACE)
659 return 1;
660 }
661 return 0;
662}]])],
663 [gl_cv_func_mbrtowc_stores_incomplete=no],
664 [gl_cv_func_mbrtowc_stores_incomplete=yes],
665 [:])
666 fi
667 ;;
668 esac
669 ])
670])
671
672dnl Test whether mbrtowc returns the correct value on empty input.
673
674AC_DEFUN([gl_MBRTOWC_EMPTY_INPUT],
675[
676 AC_REQUIRE([AC_PROG_CC])
677 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
678 AC_CACHE_CHECK([whether mbrtowc works on empty input],
679 [gl_cv_func_mbrtowc_empty_input],
680 [
681 dnl Initial guess, used when cross-compiling or when no suitable locale
682 dnl is present.
683changequote(,)dnl
684 case "$host_os" in
685 # Guess no on AIX and glibc systems.
686 aix* | *-gnu* | gnu*) gl_cv_func_mbrtowc_empty_input="guessing no" ;;
687 # Guess yes on native Windows.
688 mingw*) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
689 *) gl_cv_func_mbrtowc_empty_input="guessing yes" ;;
690 esac
691changequote([,])dnl
692 AC_RUN_IFELSE(
693 [AC_LANG_SOURCE([[
694 #include <wchar.h>
695 static wchar_t wc;
696 static mbstate_t mbs;
697 int
698 main (void)
699 {
700 return mbrtowc (&wc, "", 0, &mbs) != (size_t) -2;
701 }]])],
702 [gl_cv_func_mbrtowc_empty_input=yes],
703 [gl_cv_func_mbrtowc_empty_input=no],
704 [:])
705 ])
706])
707
708dnl Test whether mbrtowc reports encoding errors in the C locale.
709dnl Although POSIX was never intended to allow this, the GNU C Library
710dnl and other implementations do it. See:
711dnl https://sourceware.org/bugzilla/show_bug.cgi?id=19932
712
713AC_DEFUN([gl_MBRTOWC_C_LOCALE],
714[
715 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
716 AC_CACHE_CHECK([whether the C locale is free of encoding errors],
717 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ],
718 [
719 dnl Initial guess, used when cross-compiling or when no suitable locale
720 dnl is present.
721 gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="$gl_cross_guess_normal"
722
723 AC_RUN_IFELSE(
724 [AC_LANG_PROGRAM(
725 [[#include <limits.h>
726 #include <locale.h>
727 #include <wchar.h>
728 ]], [[
729 int i;
730 char *locale = setlocale (LC_ALL, "C");
731 if (! locale)
732 return 2;
733 for (i = CHAR_MIN; i <= CHAR_MAX; i++)
734 {
735 char c = i;
736 wchar_t wc;
737 mbstate_t mbs = { 0, };
738 size_t ss = mbrtowc (&wc, &c, 1, &mbs);
739 if (1 < ss)
740 return 3;
741 }
742 return 0;
743 ]])],
744 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=yes],
745 [gl_cv_func_mbrtowc_C_locale_sans_EILSEQ=no],
746 [case "$host_os" in
747 # Guess yes on native Windows.
748 mingw*) gl_cv_func_mbrtowc_C_locale_sans_EILSEQ="guessing yes" ;;
749 esac
750 ])
751 ])
752])
753
754# Prerequisites of lib/mbrtowc.c and lib/lc-charset-dispatch.c.
537AC_DEFUN([gl_PREREQ_MBRTOWC], [ 755AC_DEFUN([gl_PREREQ_MBRTOWC], [
756 AC_REQUIRE([AC_C_INLINE])
538 : 757 :
539]) 758])
540 759
760# Prerequisites of lib/mbtowc-lock.c.
761AC_DEFUN([gl_PREREQ_MBTOWC_LOCK],
762[
763 gl_VISIBILITY
764])
765
541 766
542dnl From Paul Eggert 767dnl From Paul Eggert
543 768
@@ -547,24 +772,17 @@ AC_DEFUN([AC_FUNC_MBRTOWC],
547[ 772[
548 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. 773 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
549 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared], 774 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
550 gl_cv_func_mbrtowc, 775 [gl_cv_func_mbrtowc],
551 [AC_LINK_IFELSE( 776 [AC_LINK_IFELSE(
552 [AC_LANG_PROGRAM( 777 [AC_LANG_PROGRAM(
553 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 778 [[#include <wchar.h>]],
554 included before <wchar.h>.
555 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
556 must be included before <wchar.h>. */
557 #include <stddef.h>
558 #include <stdio.h>
559 #include <time.h>
560 #include <wchar.h>]],
561 [[wchar_t wc; 779 [[wchar_t wc;
562 char const s[] = ""; 780 char const s[] = "";
563 size_t n = 1; 781 size_t n = 1;
564 mbstate_t state; 782 mbstate_t state;
565 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])], 783 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
566 gl_cv_func_mbrtowc=yes, 784 [gl_cv_func_mbrtowc=yes],
567 gl_cv_func_mbrtowc=no)]) 785 [gl_cv_func_mbrtowc=no])])
568 if test $gl_cv_func_mbrtowc = yes; then 786 if test $gl_cv_func_mbrtowc = yes; then
569 AC_DEFINE([HAVE_MBRTOWC], [1], 787 AC_DEFINE([HAVE_MBRTOWC], [1],
570 [Define to 1 if mbrtowc and mbstate_t are properly declared.]) 788 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
index 2e6d092..c388a8b 100644
--- a/gl/m4/mbsinit.m4
+++ b/gl/m4/mbsinit.m4
@@ -1,5 +1,5 @@
1# mbsinit.m4 serial 8 1# mbsinit.m4 serial 9
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,15 +16,8 @@ AC_DEFUN([gl_FUNC_MBSINIT],
16 if test $ac_cv_func_mbsinit = no; then 16 if test $ac_cv_func_mbsinit = no; then
17 HAVE_MBSINIT=0 17 HAVE_MBSINIT=0
18 AC_CHECK_DECLS([mbsinit],,, [[ 18 AC_CHECK_DECLS([mbsinit],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 19 #include <wchar.h>
20 <wchar.h>. 20 ]])
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbsinit = yes; then 21 if test $ac_cv_have_decl_mbsinit = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although 22 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although
30 dnl it does not have the function. Avoid a collision with gnulib's 23 dnl it does not have the function. Avoid a collision with gnulib's
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index ed00117..dcd66b9 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
1# mbstate_t.m4 serial 13 1# mbstate_t.m4 serial 14
2dnl Copyright (C) 2000-2002, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -20,14 +20,7 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
20 [AC_COMPILE_IFELSE( 20 [AC_COMPILE_IFELSE(
21 [AC_LANG_PROGRAM( 21 [AC_LANG_PROGRAM(
22 [AC_INCLUDES_DEFAULT[ 22 [AC_INCLUDES_DEFAULT[
23/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 23 #include <wchar.h>]],
24 <wchar.h>.
25 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
26 included before <wchar.h>. */
27#include <stddef.h>
28#include <stdio.h>
29#include <time.h>
30#include <wchar.h>]],
31 [[mbstate_t x; return sizeof x;]])], 24 [[mbstate_t x; return sizeof x;]])],
32 [ac_cv_type_mbstate_t=yes], 25 [ac_cv_type_mbstate_t=yes],
33 [ac_cv_type_mbstate_t=no])]) 26 [ac_cv_type_mbstate_t=no])])
diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4
index e479461..7823be0 100644
--- a/gl/m4/mbtowc.m4
+++ b/gl/m4/mbtowc.m4
@@ -1,5 +1,5 @@
1# mbtowc.m4 serial 2 1# mbtowc.m4 serial 3
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,8 +8,13 @@ AC_DEFUN([gl_FUNC_MBTOWC],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 10
11 if false; then 11 AC_CHECK_FUNCS([mbtowc])
12 REPLACE_MBTOWC=1 12 if test $ac_cv_func_mbtowc = no; then
13 HAVE_MBTOWC=0
14 else
15 if false; then
16 REPLACE_MBTOWC=1
17 fi
13 fi 18 fi
14]) 19])
15 20
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index 2d8abe7..4f1aed0 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,35 +1,30 @@
1# memchr.m4 serial 12 1# memchr.m4 serial 18
2dnl Copyright (C) 2002-2004, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN_ONCE([gl_FUNC_MEMCHR], 7AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
8[ 8[
9 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
10
9 dnl Check for prerequisites for memory fence checks. 11 dnl Check for prerequisites for memory fence checks.
10 gl_FUNC_MMAP_ANON 12 gl_FUNC_MMAP_ANON
11 AC_CHECK_HEADERS_ONCE([sys/mman.h]) 13 AC_CHECK_HEADERS_ONCE([sys/mman.h])
12 AC_CHECK_FUNCS_ONCE([mprotect]) 14 AC_CHECK_FUNCS_ONCE([mprotect])
13 15
14 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 16 AC_REQUIRE([gl_STRING_H_DEFAULTS])
15 m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ 17 # Detect platform-specific bugs in some versions of glibc:
16 dnl These days, we assume memchr is present. But if support for old 18 # memchr should not dereference anything with length 0
17 dnl platforms is desired: 19 # https://bugzilla.redhat.com/show_bug.cgi?id=499689
18 AC_CHECK_FUNCS_ONCE([memchr]) 20 # memchr should not dereference overestimated length after a match
19 if test $ac_cv_func_memchr = no; then 21 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
20 HAVE_MEMCHR=0 22 # https://sourceware.org/bugzilla/show_bug.cgi?id=10162
21 fi 23 # memchr should cast the second argument to 'unsigned char'.
22 ]) 24 # This bug exists in Android 4.3.
23 if test $HAVE_MEMCHR = 1; then 25 # Assume that memchr works on platforms that lack mprotect.
24 # Detect platform-specific bugs in some versions of glibc: 26 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
25 # memchr should not dereference anything with length 0 27 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26 # http://bugzilla.redhat.com/499689
27 # memchr should not dereference overestimated length after a match
28 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737
29 # http://sourceware.org/bugzilla/show_bug.cgi?id=10162
30 # Assume that memchr works on platforms that lack mprotect.
31 AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works],
32 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
33#include <string.h> 28#include <string.h>
34#if HAVE_SYS_MMAN_H 29#if HAVE_SYS_MMAN_H
35# include <fcntl.h> 30# include <fcntl.h>
@@ -64,6 +59,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
64#endif 59#endif
65 if (fence) 60 if (fence)
66 { 61 {
62 /* Test against bugs on glibc systems. */
67 if (memchr (fence, 0, 0)) 63 if (memchr (fence, 0, 0))
68 result |= 1; 64 result |= 1;
69 strcpy (fence - 9, "12345678"); 65 strcpy (fence - 9, "12345678");
@@ -71,15 +67,37 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
71 result |= 2; 67 result |= 2;
72 if (memchr (fence - 1, 0, 3) != fence - 1) 68 if (memchr (fence - 1, 0, 3) != fence - 1)
73 result |= 4; 69 result |= 4;
70 /* Test against bug on AIX 7.2. */
71 if (memchr (fence - 4, '6', 16) != fence - 4)
72 result |= 8;
74 } 73 }
74 /* Test against bug on Android 4.3. */
75 {
76 char input[3];
77 input[0] = 'a';
78 input[1] = 'b';
79 input[2] = 'c';
80 if (memchr (input, 0x789abc00 | 'b', 3) != input + 1)
81 result |= 16;
82 }
75 return result; 83 return result;
76]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], 84]])],
77 [dnl Be pessimistic for now. 85 [gl_cv_func_memchr_works=yes],
78 gl_cv_func_memchr_works="guessing no"])]) 86 [gl_cv_func_memchr_works=no],
79 if test "$gl_cv_func_memchr_works" != yes; then 87 [case "$host_os" in
80 REPLACE_MEMCHR=1 88 # Guess no on Android.
81 fi 89 linux*-android*) gl_cv_func_memchr_works="guessing no" ;;
82 fi 90 # Guess yes on native Windows.
91 mingw*) gl_cv_func_memchr_works="guessing yes" ;;
92 # If we don't know, obey --enable-cross-guesses.
93 *) gl_cv_func_memchr_works="$gl_cross_guess_normal" ;;
94 esac
95 ])
96 ])
97 case "$gl_cv_func_memchr_works" in
98 *yes) ;;
99 *) REPLACE_MEMCHR=1 ;;
100 esac
83]) 101])
84 102
85# Prerequisites of lib/memchr.c. 103# Prerequisites of lib/memchr.c.
diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4
new file mode 100644
index 0000000..fd09846
--- /dev/null
+++ b/gl/m4/minmax.m4
@@ -0,0 +1,44 @@
1# minmax.m4 serial 4
2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_PREREQ([2.53])
8
9AC_DEFUN([gl_MINMAX],
10[
11 AC_REQUIRE([gl_PREREQ_MINMAX])
12])
13
14# Prerequisites of lib/minmax.h.
15AC_DEFUN([gl_PREREQ_MINMAX],
16[
17 gl_MINMAX_IN_HEADER([limits.h])
18 gl_MINMAX_IN_HEADER([sys/param.h])
19])
20
21dnl gl_MINMAX_IN_HEADER(HEADER)
22dnl The parameter has to be a literal header name; it cannot be macro,
23dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
24dnl invocations with a literal macro name.)
25AC_DEFUN([gl_MINMAX_IN_HEADER],
26[
27 m4_pushdef([header], AS_TR_SH([$1]))
28 m4_pushdef([HEADER], AS_TR_CPP([$1]))
29 AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
30 [gl_cv_minmax_in_]header,
31 [AC_COMPILE_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <$1>
34 int x = MIN (42, 17);]],
35 [[]])],
36 [gl_cv_minmax_in_]header[=yes],
37 [gl_cv_minmax_in_]header[=no])])
38 if test $gl_cv_minmax_in_[]header = yes; then
39 AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
40 [Define to 1 if <$1> defines the MIN and MAX macros.])
41 fi
42 m4_popdef([HEADER])
43 m4_popdef([header])
44])
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index faefb77..e9d31f3 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,5 +1,5 @@
1# serial 25 1# serial 37
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,24 +7,40 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl From Jim Meyering. 8dnl From Jim Meyering.
9 9
10AC_DEFUN([gl_FUNC_MKTIME], 10AC_DEFUN([gl_TIME_T_IS_SIGNED],
11[
12 AC_CACHE_CHECK([whether time_t is signed],
13 [gl_cv_time_t_is_signed],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM([[#include <time.h>
16 char time_t_signed[(time_t) -1 < 0 ? 1 : -1];]])],
17 [gl_cv_time_t_is_signed=yes],
18 [gl_cv_time_t_is_signed=no])])
19 if test $gl_cv_time_t_is_signed = yes; then
20 AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed.])
21 fi
22])
23
24dnl Test whether mktime works. Set gl_cv_func_working_mktime.
25AC_DEFUN([gl_FUNC_MKTIME_WORKS],
11[ 26[
12 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 27 AC_REQUIRE([gl_TIME_T_IS_SIGNED])
28 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 29
14 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained 30 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained
15 dnl in Autoconf and because it invokes AC_LIBOBJ. 31 dnl in Autoconf and because it invokes AC_LIBOBJ.
16 AC_CHECK_HEADERS_ONCE([unistd.h]) 32 AC_CHECK_HEADERS_ONCE([unistd.h])
17 AC_CHECK_DECLS_ONCE([alarm]) 33 AC_CHECK_DECLS_ONCE([alarm])
18 AC_REQUIRE([gl_MULTIARCH]) 34 AC_REQUIRE([gl_MULTIARCH])
19 if test $APPLE_UNIVERSAL_BUILD = 1; then
20 # A universal build on Apple Mac OS X platforms.
21 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
22 # But we need a configuration result that is valid in both modes.
23 gl_cv_func_working_mktime=no
24 fi
25 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], 35 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
26 [AC_RUN_IFELSE( 36 [if test $APPLE_UNIVERSAL_BUILD = 1; then
27 [AC_LANG_SOURCE( 37 # A universal build on Apple Mac OS X platforms.
38 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
39 # But we need a configuration result that is valid in both modes.
40 gl_cv_func_working_mktime="guessing no"
41 else
42 AC_RUN_IFELSE(
43 [AC_LANG_SOURCE(
28[[/* Test program from Paul Eggert and Tony Leneis. */ 44[[/* Test program from Paul Eggert and Tony Leneis. */
29#include <limits.h> 45#include <limits.h>
30#include <stdlib.h> 46#include <stdlib.h>
@@ -38,8 +54,11 @@ AC_DEFUN([gl_FUNC_MKTIME],
38# include <signal.h> 54# include <signal.h>
39#endif 55#endif
40 56
41/* Work around redefinition to rpl_putenv by other config tests. */ 57]GL_MDA_DEFINES[
42#undef putenv 58
59#ifndef TIME_T_IS_SIGNED
60# define TIME_T_IS_SIGNED 0
61#endif
43 62
44static time_t time_t_max; 63static time_t time_t_max;
45static time_t time_t_min; 64static time_t time_t_min;
@@ -63,7 +82,8 @@ spring_forward_gap ()
63 instead of "TZ=America/Vancouver" in order to detect the bug even 82 instead of "TZ=America/Vancouver" in order to detect the bug even
64 on systems that don't support the Olson extension, or don't have the 83 on systems that don't support the Olson extension, or don't have the
65 full zoneinfo tables installed. */ 84 full zoneinfo tables installed. */
66 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); 85 if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
86 return -1;
67 87
68 tm.tm_year = 98; 88 tm.tm_year = 98;
69 tm.tm_mon = 3; 89 tm.tm_mon = 3;
@@ -151,7 +171,8 @@ year_2050_test ()
151 instead of "TZ=America/Vancouver" in order to detect the bug even 171 instead of "TZ=America/Vancouver" in order to detect the bug even
152 on systems that don't support the Olson extension, or don't have the 172 on systems that don't support the Olson extension, or don't have the
153 full zoneinfo tables installed. */ 173 full zoneinfo tables installed. */
154 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0"); 174 if (putenv ("TZ=PST8PDT,M4.1.0,M10.5.0") != 0)
175 return -1;
155 176
156 t = mktime (&tm); 177 t = mktime (&tm);
157 178
@@ -162,6 +183,25 @@ year_2050_test ()
162 || (0 < t && answer - 120 <= t && t <= answer + 120)); 183 || (0 < t && answer - 120 <= t && t <= answer + 120));
163} 184}
164 185
186static int
187indiana_test ()
188{
189 if (putenv ("TZ=America/Indiana/Indianapolis") != 0)
190 return -1;
191 struct tm tm;
192 tm.tm_year = 1986 - 1900; tm.tm_mon = 4 - 1; tm.tm_mday = 28;
193 tm.tm_hour = 16; tm.tm_min = 24; tm.tm_sec = 50; tm.tm_isdst = 0;
194 time_t std = mktime (&tm);
195 if (! (std == 515107490 || std == 515107503))
196 return 1;
197
198 /* This platform supports TZDB, either without or with leap seconds.
199 Return true if GNU Bug#48085 is absent. */
200 tm.tm_isdst = 1;
201 time_t dst = mktime (&tm);
202 return std - dst == 60 * 60;
203}
204
165int 205int
166main () 206main ()
167{ 207{
@@ -169,7 +209,6 @@ main ()
169 time_t t, delta; 209 time_t t, delta;
170 int i, j; 210 int i, j;
171 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1; 211 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
172 int time_t_signed = ! ((time_t) 0 < (time_t) -1);
173 212
174#if HAVE_DECL_ALARM 213#if HAVE_DECL_ALARM
175 /* This test makes some buggy mktime implementations loop. 214 /* This test makes some buggy mktime implementations loop.
@@ -179,11 +218,11 @@ main ()
179 alarm (60); 218 alarm (60);
180#endif 219#endif
181 220
182 time_t_max = (! time_t_signed 221 time_t_max = (! TIME_T_IS_SIGNED
183 ? (time_t) -1 222 ? (time_t) -1
184 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1) 223 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
185 * 2 + 1)); 224 * 2 + 1));
186 time_t_min = (! time_t_signed 225 time_t_min = (! TIME_T_IS_SIGNED
187 ? (time_t) 0 226 ? (time_t) 0
188 : time_t_signed_magnitude 227 : time_t_signed_magnitude
189 ? ~ (time_t) 0 228 ? ~ (time_t) 0
@@ -218,35 +257,62 @@ main ()
218 result |= 16; 257 result |= 16;
219 if (! spring_forward_gap ()) 258 if (! spring_forward_gap ())
220 result |= 32; 259 result |= 32;
221 if (! year_2050_test ()) 260 if (! year_2050_test () || ! indiana_test ())
222 result |= 64; 261 result |= 64;
223 return result; 262 return result;
224}]])], 263}]])],
225 [gl_cv_func_working_mktime=yes], 264 [gl_cv_func_working_mktime=yes],
226 [gl_cv_func_working_mktime=no], 265 [gl_cv_func_working_mktime=no],
227 [gl_cv_func_working_mktime=no]) 266 [case "$host_os" in
267 # Guess no on native Windows.
268 mingw*) gl_cv_func_working_mktime="guessing no" ;;
269 *) gl_cv_func_working_mktime="$gl_cross_guess_normal" ;;
270 esac
271 ])
272 fi
228 ]) 273 ])
274])
275
276dnl Main macro of module 'mktime'.
277AC_DEFUN([gl_FUNC_MKTIME],
278[
279 AC_REQUIRE([gl_TIME_H_DEFAULTS])
280 AC_REQUIRE([AC_CANONICAL_HOST])
281 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
229 282
230 if test $gl_cv_func_working_mktime = no; then 283 REPLACE_MKTIME=0
284 if test "$gl_cv_func_working_mktime" != yes; then
231 REPLACE_MKTIME=1 285 REPLACE_MKTIME=1
232 else 286 AC_DEFINE([NEED_MKTIME_WORKING], [1],
233 REPLACE_MKTIME=0 287 [Define if the compilation of mktime.c should define 'mktime'
288 with the algorithmic workarounds.])
234 fi 289 fi
290 case "$host_os" in
291 mingw*)
292 REPLACE_MKTIME=1
293 AC_DEFINE([NEED_MKTIME_WINDOWS], [1],
294 [Define if the compilation of mktime.c should define 'mktime'
295 with the native Windows TZ workaround.])
296 ;;
297 esac
235]) 298])
236 299
300dnl Main macro of module 'mktime-internal'.
237AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [ 301AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
238 AC_REQUIRE([gl_FUNC_MKTIME]) 302 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
239 if test $REPLACE_MKTIME = 0; then 303
240 dnl BeOS has __mktime_internal in libc, but other platforms don't. 304 WANT_MKTIME_INTERNAL=0
241 AC_CHECK_FUNC([__mktime_internal], 305 dnl BeOS has __mktime_internal in libc, but other platforms don't.
242 [AC_DEFINE([mktime_internal], [__mktime_internal], 306 AC_CHECK_FUNC([__mktime_internal],
243 [Define to the real name of the mktime_internal function.]) 307 [AC_DEFINE([mktime_internal], [__mktime_internal],
244 ], 308 [Define to the real name of the mktime_internal function.])
245 [dnl mktime works but it doesn't export __mktime_internal, 309 ],
246 dnl so we need to substitute our own mktime implementation. 310 [dnl mktime works but it doesn't export __mktime_internal,
247 REPLACE_MKTIME=1 311 dnl so we need to substitute our own mktime implementation.
248 ]) 312 WANT_MKTIME_INTERNAL=1
249 fi 313 AC_DEFINE([NEED_MKTIME_INTERNAL], [1],
314 [Define if the compilation of mktime.c should define 'mktime_internal'.])
315 ])
250]) 316])
251 317
252# Prerequisites of lib/mktime.c. 318# Prerequisites of lib/mktime.c.
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index 9b60ddf..d07d26e 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -1,5 +1,5 @@
1# mmap-anon.m4 serial 10 1# mmap-anon.m4 serial 12
2dnl Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,11 +9,11 @@ dnl with or without modifications, as long as this notice is preserved.
9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS 9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
10# and MAP_ANON exist and have the same value. 10# and MAP_ANON exist and have the same value.
11# - On HP-UX, only MAP_ANONYMOUS exists. 11# - On HP-UX, only MAP_ANONYMOUS exists.
12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. 12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists.
13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be 13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
14# used. 14# used.
15 15
16AC_DEFUN([gl_FUNC_MMAP_ANON], 16AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
17[ 17[
18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. 18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4
new file mode 100644
index 0000000..82197c0
--- /dev/null
+++ b/gl/m4/mode_t.m4
@@ -0,0 +1,26 @@
1# mode_t.m4 serial 2
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
8# include <sys/types.h>.
9
10# Define PROMOTED_MODE_T to the type that is the result of "default argument
11# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t.
12AC_DEFUN([gl_PROMOTED_TYPE_MODE_T],
13[
14 AC_REQUIRE([AC_TYPE_MODE_T])
15 AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [
16 dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int',
17 dnl and to itself otherwise. This assumption is not guaranteed by the ISO C
18 dnl standard, but we don't know of any real-world counterexamples.
19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
20 [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])],
21 [gl_cv_promoted_mode_t='int'],
22 [gl_cv_promoted_mode_t='mode_t'])
23 ])
24 AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t],
25 [Define to the type that is the result of default argument promotions of type mode_t.])
26])
diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4
index cd137c9..a9b4edb 100644
--- a/gl/m4/mountlist.m4
+++ b/gl/m4/mountlist.m4
@@ -1,19 +1,338 @@
1# serial 11 1# serial 15
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Jim Meyering.
8
9AC_PREREQ([2.60])
10
7AC_DEFUN([gl_MOUNTLIST], 11AC_DEFUN([gl_MOUNTLIST],
8[ 12[
9 gl_LIST_MOUNTED_FILE_SYSTEMS([gl_cv_list_mounted_fs=yes], 13 AC_REQUIRE([AC_CANONICAL_HOST])
10 [gl_cv_list_mounted_fs=no]) 14 AC_CHECK_FUNCS([listmntent])
15 AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
16
17 # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
18 # NGROUPS (as the array dimension for a struct member) without a definition.
19 AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
20
21 AC_CHECK_HEADERS([sys/mount.h], [], [],
22 [AC_INCLUDES_DEFAULT
23 [#if HAVE_SYS_PARAM_H
24 #include <sys/param.h>
25 #endif
26 ]])
27
28 AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
29 getfsstat_includes="\
30$ac_includes_default
31#if HAVE_SYS_PARAM_H
32# include <sys/param.h> /* needed by powerpc-apple-darwin1.3.7 */
33#endif
34#if HAVE_SYS_UCRED_H
35# include <grp.h> /* needed for definition of NGROUPS */
36# include <sys/ucred.h> /* needed by powerpc-apple-darwin1.3.7 */
37#endif
38#if HAVE_SYS_MOUNT_H
39# include <sys/mount.h>
40#endif
41#if HAVE_SYS_FS_TYPES_H
42# include <sys/fs_types.h> /* needed by powerpc-apple-darwin1.3.7 */
43#endif
44"
45 AC_CHECK_MEMBERS([struct fsstat.f_fstypename],,,[$getfsstat_includes])
46
47 # Determine how to get the list of mounted file systems.
48 ac_list_mounted_fs=
49
50 # If the getmntent function is available but not in the standard library,
51 # make sure LIBS contains the appropriate -l option.
52 AC_FUNC_GETMNTENT
53
54 if test -z "$ac_list_mounted_fs"; then
55 # AIX.
56 AC_CACHE_CHECK([for mntctl function and struct vmount],
57 [fu_cv_sys_mounted_vmount],
58 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <fshelp.h>]])],
59 [fu_cv_sys_mounted_vmount=yes],
60 [fu_cv_sys_mounted_vmount=no])])
61 if test $fu_cv_sys_mounted_vmount = yes; then
62 ac_list_mounted_fs=found
63 AC_DEFINE([MOUNTED_VMOUNT], [1],
64 [Define if there is a function named mntctl that can be used to read
65 the list of mounted file systems, and there is a system header file
66 that declares 'struct vmount'. (AIX)])
67 fi
68 fi
69
70 if test $ac_cv_func_getmntent = yes; then
71
72 # This system has the getmntent function.
73 # Determine whether it's the one-argument variant or the two-argument one.
74
75 if test -z "$ac_list_mounted_fs"; then
76 # glibc, HP-UX, IRIX, Cygwin, Android, also (obsolete) 4.3BSD, SunOS.
77 AC_CACHE_CHECK([for one-argument getmntent function],
78 [fu_cv_sys_mounted_getmntent1],
79 [AC_COMPILE_IFELSE(
80 [AC_LANG_PROGRAM([[
81/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
82#include <stdio.h>
83
84#include <mntent.h>
85#if defined __ANDROID__ /* Android */
86# undef MOUNTED
87# define MOUNTED "/proc/mounts"
88#elif !defined MOUNTED
89# if defined _PATH_MOUNTED /* GNU libc */
90# define MOUNTED _PATH_MOUNTED
91# endif
92# if defined MNT_MNTTAB /* HP-UX. */
93# define MOUNTED MNT_MNTTAB
94# endif
95#endif
96]],
97 [[struct mntent *mnt = 0; char *table = MOUNTED;
98 if (sizeof mnt && sizeof table) return 0;
99 ]])],
100 [fu_cv_sys_mounted_getmntent1=yes],
101 [fu_cv_sys_mounted_getmntent1=no])
102 ])
103 if test $fu_cv_sys_mounted_getmntent1 = yes; then
104 ac_list_mounted_fs=found
105 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
106 [Define if there is a function named getmntent for reading the list
107 of mounted file systems, and that function takes a single argument.
108 (4.3BSD, SunOS, HP-UX, Irix)])
109 AC_CHECK_FUNCS([setmntent endmntent hasmntopt])
110 fi
111 fi
112
113 if test -z "$ac_list_mounted_fs"; then
114 # Solaris >= 8.
115 AC_CACHE_CHECK([for getextmntent function],
116 [fu_cv_sys_mounted_getextmntent],
117 [AC_EGREP_HEADER([getextmntent], [sys/mnttab.h],
118 [fu_cv_sys_mounted_getextmntent=yes],
119 [fu_cv_sys_mounted_getextmntent=no])])
120 if test $fu_cv_sys_mounted_getextmntent = yes; then
121 ac_list_mounted_fs=found
122 AC_DEFINE([MOUNTED_GETEXTMNTENT], [1],
123 [Define if there is a function named getextmntent for reading the list
124 of mounted file systems. (Solaris)])
125 fi
126 fi
127
128 if test -z "$ac_list_mounted_fs"; then
129 # Solaris < 8, also (obsolete) SVR4.
130 # Solaris >= 8 has the two-argument getmntent but is already handled above.
131 AC_CACHE_CHECK([for two-argument getmntent function],
132 [fu_cv_sys_mounted_getmntent2],
133 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
134 [fu_cv_sys_mounted_getmntent2=yes],
135 [fu_cv_sys_mounted_getmntent2=no])
136 ])
137 if test $fu_cv_sys_mounted_getmntent2 = yes; then
138 ac_list_mounted_fs=found
139 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
140 [Define if there is a function named getmntent for reading the list of
141 mounted file systems, and that function takes two arguments. (SVR4)])
142 AC_CHECK_FUNCS([hasmntopt])
143 fi
144 fi
145
146 fi
147
148 if test -z "$ac_list_mounted_fs"; then
149 # OSF/1, also (obsolete) Apple Darwin 1.3.
150 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
151
152 AC_CACHE_CHECK([for getfsstat function],
153 [fu_cv_sys_mounted_getfsstat],
154 [AC_LINK_IFELSE(
155 [AC_LANG_PROGRAM([[
156#include <sys/types.h>
157#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
158# define FS_TYPE(Ent) ((Ent).f_fstypename)
159#else
160# define FS_TYPE(Ent) mnt_names[(Ent).f_type]
161#endif
162$getfsstat_includes
163 ]],
164 [[struct statfs *stats;
165 int numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT);
166 char *t = FS_TYPE (*stats);
167 ]])],
168 [fu_cv_sys_mounted_getfsstat=yes],
169 [fu_cv_sys_mounted_getfsstat=no])
170 ])
171 if test $fu_cv_sys_mounted_getfsstat = yes; then
172 ac_list_mounted_fs=found
173 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
174 [Define if there is a function named getfsstat for reading the
175 list of mounted file systems. (DEC Alpha running OSF/1)])
176 fi
177 fi
178
179 if test -z "$ac_list_mounted_fs"; then
180 # (obsolete) SVR3
181 AC_CACHE_CHECK([for FIXME existence of three headers],
182 [fu_cv_sys_mounted_fread_fstyp],
183 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
184#include <sys/statfs.h>
185#include <sys/fstyp.h>
186#include <mnttab.h>
187]])],
188 [fu_cv_sys_mounted_fread_fstyp=yes],
189 [fu_cv_sys_mounted_fread_fstyp=no])
190 ])
191 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
192 ac_list_mounted_fs=found
193 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
194 [Define if (like SVR2) there is no specific function for reading the
195 list of mounted file systems, and your system has these header files:
196 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
197 fi
198 fi
199
200 if test -z "$ac_list_mounted_fs"; then
201 # Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, also (obsolete) 4.4BSD.
202 # OSF/1 also has getmntinfo but is already handled above.
203 # We cannot use AC_CHECK_FUNCS([getmntinfo]) here, because at the linker
204 # level the function is sometimes called getmntinfo64 or getmntinfo$INODE64
205 # on Mac OS X, __getmntinfo13 on NetBSD and Minix, _F64_getmntinfo on OSF/1.
206 AC_CACHE_CHECK([for getmntinfo function],
207 [fu_cv_sys_mounted_getmntinfo],
208 [AC_LINK_IFELSE(
209 [AC_LANG_PROGRAM([[
210#if HAVE_SYS_PARAM_H
211# include <sys/param.h>
212#endif
213#include <sys/types.h>
214#if HAVE_SYS_MOUNT_H
215# include <sys/mount.h>
216#endif
217#if HAVE_SYS_STATVFS_H
218# include <sys/statvfs.h>
219#endif
220#include <stdlib.h>
221 ]],
222 [[int count = getmntinfo (NULL, MNT_WAIT);
223 ]])],
224 [fu_cv_sys_mounted_getmntinfo=yes],
225 [fu_cv_sys_mounted_getmntinfo=no])
226 ])
227 if test $fu_cv_sys_mounted_getmntinfo = yes; then
228 AC_CACHE_CHECK([whether getmntinfo returns statvfs structures],
229 [fu_cv_sys_mounted_getmntinfo2],
230 [AC_COMPILE_IFELSE(
231 [AC_LANG_PROGRAM([[
232#if HAVE_SYS_PARAM_H
233# include <sys/param.h>
234#endif
235#include <sys/types.h>
236#if HAVE_SYS_MOUNT_H
237# include <sys/mount.h>
238#endif
239#if HAVE_SYS_STATVFS_H
240# include <sys/statvfs.h>
241#endif
242extern
243#ifdef __cplusplus
244"C"
245#endif
246int getmntinfo (struct statfs **, int);
247 ]], [[]])],
248 [fu_cv_sys_mounted_getmntinfo2=no],
249 [fu_cv_sys_mounted_getmntinfo2=yes])
250 ])
251 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
252 # Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD.
253 ac_list_mounted_fs=found
254 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
255 [Define if there is a function named getmntinfo for reading the
256 list of mounted file systems and it returns an array of
257 'struct statfs'. (4.4BSD, Darwin)])
258 else
259 # NetBSD, Minix.
260 ac_list_mounted_fs=found
261 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
262 [Define if there is a function named getmntinfo for reading the
263 list of mounted file systems and it returns an array of
264 'struct statvfs'. (NetBSD 3.0)])
265 fi
266 fi
267 fi
268
269 if test -z "$ac_list_mounted_fs"; then
270 # Haiku, also (obsolete) BeOS.
271 AC_CHECK_FUNCS([next_dev fs_stat_dev])
272 AC_CHECK_HEADERS([fs_info.h])
273 AC_CACHE_CHECK([for BEOS mounted file system support functions],
274 [fu_cv_sys_mounted_fs_stat_dev],
275 [if test $ac_cv_header_fs_info_h = yes \
276 && test $ac_cv_func_next_dev = yes \
277 && test $ac_cv_func_fs_stat_dev = yes; then
278 fu_cv_sys_mounted_fs_stat_dev=yes
279 else
280 fu_cv_sys_mounted_fs_stat_dev=no
281 fi
282 ])
283 if test $fu_cv_sys_mounted_fs_stat_dev = yes; then
284 ac_list_mounted_fs=found
285 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
286 [Define if there are functions named next_dev and fs_stat_dev for
287 reading the list of mounted file systems. (BeOS)])
288 fi
289 fi
290
291 if test -z "$ac_list_mounted_fs"; then
292 # Interix / BSD alike statvfs
293 # the code is really interix specific, so make sure, we're on it.
294 case "$host" in
295 *-interix*)
296 AC_CHECK_FUNCS([statvfs])
297 if test $ac_cv_func_statvfs = yes; then
298 ac_list_mounted_fs=found
299 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
300 [Define if we are on interix, and ought to use statvfs plus
301 some special knowledge on where mounted file systems can be
302 found. (Interix)])
303 fi
304 ;;
305 esac
306 fi
307
308 if test -z "$ac_list_mounted_fs"; then
309 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
310 # FIXME -- no need to abort building the whole package
311 # Can't build mountlist.c or anything that needs its functions
312 fi
313
314 if test $ac_list_mounted_fs = found; then
315 gl_cv_list_mounted_fs=yes
316 else
317 gl_cv_list_mounted_fs=no
318 fi
11]) 319])
12 320
13# Prerequisites of lib/mountlist.c not done by gl_LIST_MOUNTED_FILE_SYSTEMS. 321# Prerequisites of lib/mountlist.c not done by gl_MOUNTLIST.
14AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA], 322AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA],
15[ 323[
16 dnl Note gl_LIST_MOUNTED_FILE_SYSTEMS checks for mntent.h, not sys/mntent.h. 324 dnl Note gl_MOUNTLIST checks for mntent.h, not sys/mntent.h.
17 AC_CHECK_HEADERS([sys/mntent.h]) 325 AC_CHECK_HEADERS([sys/mntent.h])
326 AC_HEADER_MAJOR()dnl for use of makedev ()
18 gl_FSTYPENAME 327 gl_FSTYPENAME
19]) 328])
329
330# Replace Autoconf's AC_FUNC_GETMNTENT to omit checks that are unnecessary
331# nowadays.
332AC_DEFUN([AC_FUNC_GETMNTENT],
333[
334 # getmntent is in the standard C library on most systems, but in -lgen on
335 # Unixware.
336 AC_SEARCH_LIBS([getmntent], [gen])
337 AC_CHECK_FUNCS([getmntent])
338])
diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4
index 9a6a47a..8d9d21b 100644
--- a/gl/m4/msvc-inval.m4
+++ b/gl/m4/msvc-inval.m4
@@ -1,5 +1,5 @@
1# msvc-inval.m4 serial 1 1# msvc-inval.m4 serial 1
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/msvc-nothrow.m4 b/gl/m4/msvc-nothrow.m4
index a39618a..0263e49 100644
--- a/gl/m4/msvc-nothrow.m4
+++ b/gl/m4/msvc-nothrow.m4
@@ -1,5 +1,5 @@
1# msvc-nothrow.m4 serial 1 1# msvc-nothrow.m4 serial 1
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
index 552ec7e..3ba5b0f 100644
--- a/gl/m4/multiarch.m4
+++ b/gl/m4/multiarch.m4
@@ -1,5 +1,5 @@
1# multiarch.m4 serial 7 1# multiarch.m4 serial 9
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -21,37 +21,40 @@ dnl with or without modifications, as long as this notice is preserved.
21AC_DEFUN_ONCE([gl_MULTIARCH], 21AC_DEFUN_ONCE([gl_MULTIARCH],
22[ 22[
23 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. 23 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
24 gl_cv_c_multiarch=no 24 AC_CACHE_CHECK([whether the compiler produces multi-arch binaries],
25 AC_COMPILE_IFELSE( 25 [gl_cv_c_multiarch],
26 [AC_LANG_SOURCE( 26 [gl_cv_c_multiarch=no
27 [[#ifndef __APPLE_CC__ 27 AC_COMPILE_IFELSE(
28 not a universal capable compiler 28 [AC_LANG_SOURCE(
29 #endif 29 [[#ifndef __APPLE_CC__
30 typedef int dummy; 30 not a universal capable compiler
31 ]])], 31 #endif
32 [ 32 typedef int dummy;
33 dnl Check for potential -arch flags. It is not universal unless 33 ]])],
34 dnl there are at least two -arch flags with different values. 34 [
35 arch= 35 dnl Check for potential -arch flags. It is not universal unless
36 prev= 36 dnl there are at least two -arch flags with different values.
37 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do 37 arch=
38 if test -n "$prev"; then 38 prev=
39 case $word in 39 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
40 i?86 | x86_64 | ppc | ppc64) 40 if test -n "$prev"; then
41 if test -z "$arch" || test "$arch" = "$word"; then 41 case $word in
42 arch="$word" 42 i?86 | x86_64 | ppc | ppc64 | arm | arm64)
43 else 43 if test -z "$arch" || test "$arch" = "$word"; then
44 gl_cv_c_multiarch=yes 44 arch="$word"
45 fi 45 else
46 ;; 46 gl_cv_c_multiarch=yes
47 esac 47 fi
48 prev= 48 ;;
49 else 49 esac
50 if test "x$word" = "x-arch"; then 50 prev=
51 prev=arch 51 else
52 fi 52 if test "x$word" = "x-arch"; then
53 fi 53 prev=arch
54 done 54 fi
55 fi
56 done
57 ])
55 ]) 58 ])
56 if test $gl_cv_c_multiarch = yes; then 59 if test $gl_cv_c_multiarch = yes; then
57 APPLE_UNIVERSAL_BUILD=1 60 APPLE_UNIVERSAL_BUILD=1
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index 2c69f99..e6aa892 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,10 +1,10 @@
1# netdb_h.m4 serial 11 1# netdb_h.m4 serial 15
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_HEADER_NETDB], 7AC_DEFUN_ONCE([gl_NETDB_H],
8[ 8[
9 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 9 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([netdb.h]) 10 gl_CHECK_NEXT_HEADERS([netdb.h])
@@ -21,18 +21,33 @@ AC_DEFUN([gl_HEADER_NETDB],
21 [getaddrinfo freeaddrinfo gai_strerror getnameinfo]) 21 [getaddrinfo freeaddrinfo gai_strerror getnameinfo])
22]) 22])
23 23
24# gl_NETDB_MODULE_INDICATOR([modulename])
25# sets the shell variable that indicates the presence of the given module
26# to a C preprocessor expression that will evaluate to 1.
27# This macro invocation must not occur in macros that are AC_REQUIREd.
24AC_DEFUN([gl_NETDB_MODULE_INDICATOR], 28AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
25[ 29[
26 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 30 dnl Ensure to expand the default settings once only.
27 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 31 gl_NETDB_H_REQUIRE_DEFAULTS
28 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 32 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
29 dnl Define it also as a C macro, for the benefit of the unit tests. 33 dnl Define it also as a C macro, for the benefit of the unit tests.
30 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 34 gl_MODULE_INDICATOR_FOR_TESTS([$1])
31]) 35])
32 36
37# Initializes the default values for AC_SUBSTed shell variables.
38# This macro must not be AC_REQUIREd. It must only be invoked, and only
39# outside of macros or in macros that are not AC_REQUIREd.
40AC_DEFUN([gl_NETDB_H_REQUIRE_DEFAULTS],
41[
42 m4_defun(GL_MODULE_INDICATOR_PREFIX[_NETDB_H_MODULE_INDICATOR_DEFAULTS], [
43 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETADDRINFO])
44 ])
45 m4_require(GL_MODULE_INDICATOR_PREFIX[_NETDB_H_MODULE_INDICATOR_DEFAULTS])
46 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
47])
48
33AC_DEFUN([gl_NETDB_H_DEFAULTS], 49AC_DEFUN([gl_NETDB_H_DEFAULTS],
34[ 50[
35 GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO])
36 dnl Assume proper GNU behavior unless another module says otherwise. 51 dnl Assume proper GNU behavior unless another module says otherwise.
37 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO]) 52 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO])
38 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO]) 53 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO])
@@ -40,4 +55,5 @@ AC_DEFUN([gl_NETDB_H_DEFAULTS],
40 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO]) 55 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO])
41 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO]) 56 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO])
42 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR]) 57 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR])
58 REPLACE_GETADDRINFO=0; AC_SUBST([REPLACE_GETADDRINFO])
43]) 59])
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index 21971b2..7115419 100644
--- a/gl/m4/netinet_in_h.m4
+++ b/gl/m4/netinet_in_h.m4
@@ -1,5 +1,5 @@
1# netinet_in_h.m4 serial 5 1# netinet_in_h.m4 serial 6
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,9 +14,9 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
14 [gl_cv_header_netinet_in_h_selfcontained=no]) 14 [gl_cv_header_netinet_in_h_selfcontained=no])
15 ]) 15 ])
16 if test $gl_cv_header_netinet_in_h_selfcontained = yes; then 16 if test $gl_cv_header_netinet_in_h_selfcontained = yes; then
17 NETINET_IN_H='' 17 GL_GENERATE_NETINET_IN_H=false
18 else 18 else
19 NETINET_IN_H='netinet/in.h' 19 GL_GENERATE_NETINET_IN_H=true
20 AC_CHECK_HEADERS([netinet/in.h]) 20 AC_CHECK_HEADERS([netinet/in.h])
21 gl_CHECK_NEXT_HEADERS([netinet/in.h]) 21 gl_CHECK_NEXT_HEADERS([netinet/in.h])
22 if test $ac_cv_header_netinet_in_h = yes; then 22 if test $ac_cv_header_netinet_in_h = yes; then
@@ -26,6 +26,4 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
26 fi 26 fi
27 AC_SUBST([HAVE_NETINET_IN_H]) 27 AC_SUBST([HAVE_NETINET_IN_H])
28 fi 28 fi
29 AC_SUBST([NETINET_IN_H])
30 AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"])
31]) 29])
diff --git a/gl/m4/nl_langinfo.m4 b/gl/m4/nl_langinfo.m4
index 25e2101..51e783c 100644
--- a/gl/m4/nl_langinfo.m4
+++ b/gl/m4/nl_langinfo.m4
@@ -1,5 +1,5 @@
1# nl_langinfo.m4 serial 5 1# nl_langinfo.m4 serial 8
2dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,10 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 AC_REQUIRE([gl_LANGINFO_H]) 10 AC_REQUIRE([gl_LANGINFO_H])
11 AC_CHECK_FUNCS_ONCE([nl_langinfo]) 11 AC_CHECK_FUNCS_ONCE([nl_langinfo])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
14 AC_REQUIRE([gl_PTHREADLIB])
15 AC_CHECK_HEADERS_ONCE([threads.h])
13 if test $ac_cv_func_nl_langinfo = yes; then 16 if test $ac_cv_func_nl_langinfo = yes; then
14 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken. 17 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
15 AC_CACHE_CHECK([whether YESEXPR works], 18 AC_CACHE_CHECK([whether YESEXPR works],
@@ -36,8 +39,19 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
36 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS], 39 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
37 [$FUNC_NL_LANGINFO_YESEXPR_WORKS], 40 [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
38 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.]) 41 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
39 if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \ 42 # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe.
40 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then 43 case "$host_os" in
44 solaris*) NL_LANGINFO_MTSAFE=0 ;;
45 *) NL_LANGINFO_MTSAFE=1 ;;
46 esac
47 AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE],
48 [Define to 1 if nl_langinfo is multithread-safe.])
49 if test $HAVE_LANGINFO_CODESET = 1 \
50 && test $HAVE_LANGINFO_T_FMT_AMPM = 1 \
51 && test $HAVE_LANGINFO_ALTMON = 1 \
52 && test $HAVE_LANGINFO_ERA = 1 \
53 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1 \
54 && test $NL_LANGINFO_MTSAFE = 1; then
41 : 55 :
42 else 56 else
43 REPLACE_NL_LANGINFO=1 57 REPLACE_NL_LANGINFO=1
@@ -47,4 +61,17 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
47 else 61 else
48 HAVE_NL_LANGINFO=0 62 HAVE_NL_LANGINFO=0
49 fi 63 fi
64 if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then
65 LIB_NL_LANGINFO="$LIB_SETLOCALE_NULL"
66 else
67 LIB_NL_LANGINFO=
68 fi
69 dnl LIB_NL_LANGINFO is expected to be empty everywhere.
70 AC_SUBST([LIB_NL_LANGINFO])
71])
72
73# Prerequisites of lib/nl_langinfo-lock.c.
74AC_DEFUN([gl_PREREQ_NL_LANGINFO_LOCK],
75[
76 gl_VISIBILITY
50]) 77])
diff --git a/gl/m4/nls.m4 b/gl/m4/nls.m4
deleted file mode 100644
index 8f8a147..0000000
--- a/gl/m4/nls.m4
+++ /dev/null
@@ -1,32 +0,0 @@
1# nls.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 1995-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7dnl
8dnl This file can can be used in projects which are not available under
9dnl the GNU General Public License or the GNU Library General Public
10dnl License but which still want to provide support for the GNU gettext
11dnl functionality.
12dnl Please note that the actual code of the GNU gettext library is covered
13dnl by the GNU Library General Public License, and the rest of the GNU
14dnl gettext package package is covered by the GNU General Public License.
15dnl They are *not* in the public domain.
16
17dnl Authors:
18dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
19dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
20
21AC_PREREQ([2.50])
22
23AC_DEFUN([AM_NLS],
24[
25 AC_MSG_CHECKING([whether NLS is requested])
26 dnl Default is enabled NLS
27 AC_ARG_ENABLE([nls],
28 [ --disable-nls do not use Native Language Support],
29 USE_NLS=$enableval, USE_NLS=yes)
30 AC_MSG_RESULT([$USE_NLS])
31 AC_SUBST([USE_NLS])
32])
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
index 105b884..6a76638 100644
--- a/gl/m4/nocrash.m4
+++ b/gl/m4/nocrash.m4
@@ -1,5 +1,5 @@
1# nocrash.m4 serial 4 1# nocrash.m4 serial 5
2dnl Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -53,7 +53,7 @@ nocrash_init (void)
53 /* Allocate a port on which the thread shall listen for exceptions. */ 53 /* Allocate a port on which the thread shall listen for exceptions. */
54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port) 54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
55 == KERN_SUCCESS) { 55 == KERN_SUCCESS) {
56 /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */ 56 /* See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */
57 if (mach_port_insert_right (self, our_exception_port, our_exception_port, 57 if (mach_port_insert_right (self, our_exception_port, our_exception_port,
58 MACH_MSG_TYPE_MAKE_SEND) 58 MACH_MSG_TYPE_MAKE_SEND)
59 == KERN_SUCCESS) { 59 == KERN_SUCCESS) {
@@ -72,14 +72,14 @@ nocrash_init (void)
72 for a particular thread. This has the effect that when our exception 72 for a particular thread. This has the effect that when our exception
73 port gets the message, the thread specific exception port has already 73 port gets the message, the thread specific exception port has already
74 been asked, and we don't need to bother about it. 74 been asked, and we don't need to bother about it.
75 See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */ 75 See https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */
76 task_set_exception_ports (self, mask, our_exception_port, 76 task_set_exception_ports (self, mask, our_exception_port,
77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE); 77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
78 } 78 }
79 } 79 }
80 } 80 }
81} 81}
82#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 82#elif defined _WIN32 && ! defined __CYGWIN__
83/* Avoid a crash on native Windows. */ 83/* Avoid a crash on native Windows. */
84#define WIN32_LEAN_AND_MEAN 84#define WIN32_LEAN_AND_MEAN
85#include <windows.h> 85#include <windows.h>
@@ -110,11 +110,12 @@ nocrash_init (void)
110#else 110#else
111/* Avoid a crash on POSIX systems. */ 111/* Avoid a crash on POSIX systems. */
112#include <signal.h> 112#include <signal.h>
113#include <unistd.h>
113/* A POSIX signal handler. */ 114/* A POSIX signal handler. */
114static void 115static void
115exception_handler (int sig) 116exception_handler (int sig)
116{ 117{
117 exit (1); 118 _exit (1);
118} 119}
119static void 120static void
120nocrash_init (void) 121nocrash_init (void)
diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4
index d355d01..880f347 100644
--- a/gl/m4/off_t.m4
+++ b/gl/m4/off_t.m4
@@ -1,5 +1,5 @@
1# off_t.m4 serial 1 1# off_t.m4 serial 1
2dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/onceonly.m4 b/gl/m4/onceonly.m4
deleted file mode 100644
index 0a875a3..0000000
--- a/gl/m4/onceonly.m4
+++ /dev/null
@@ -1,104 +0,0 @@
1# onceonly.m4 serial 9
2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc.
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This file is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this file. If not, see <http://www.gnu.org/licenses/>.
17dnl
18dnl As a special exception to the GNU General Public License,
19dnl this file may be distributed as part of a program
20dnl that contains a configuration script generated by Autoconf, under
21dnl the same distribution terms as the rest of that program.
22
23dnl This file defines some "once only" variants of standard autoconf macros.
24dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
25dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
26dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
27dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL
28dnl The advantage is that the check for each of the headers/functions/decls
29dnl will be put only once into the 'configure' file. It keeps the size of
30dnl the 'configure' file down, and avoids redundant output when 'configure'
31dnl is run.
32dnl The drawback is that the checks cannot be conditionalized. If you write
33dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi
34dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
35dnl empty, and the check will be inserted before the body of the AC_DEFUNed
36dnl function.
37
38dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
39dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
40dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
41dnl headers at once, thus reducing the size of 'configure'. It is known to work
42dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
43
44dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
45dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
46dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
47dnl argument!
48AC_PREREQ([2.59])
49
50# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
51# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
52AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
53 :
54 m4_foreach_w([gl_HEADER_NAME], [$1], [
55 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
56 [./-], [___])), [
57 m4_divert_text([INIT_PREPARE],
58 [gl_header_list="$gl_header_list gl_HEADER_NAME"])
59 gl_HEADERS_EXPANSION
60 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
61 [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
62 ])
63 AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
64 [./-], [___])))
65 ])
66])
67m4_define([gl_HEADERS_EXPANSION], [
68 m4_divert_text([DEFAULTS], [gl_header_list=])
69 AC_CHECK_HEADERS([$gl_header_list])
70 m4_define([gl_HEADERS_EXPANSION], [])
71])
72
73# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of
74# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
75AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
76 :
77 m4_foreach_w([gl_FUNC_NAME], [$1], [
78 AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
79 m4_divert_text([INIT_PREPARE],
80 [gl_func_list="$gl_func_list gl_FUNC_NAME"])
81 gl_FUNCS_EXPANSION
82 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
83 [Define to 1 if you have the ']m4_defn([gl_FUNC_NAME])[' function.])
84 ])
85 AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
86 ])
87])
88m4_define([gl_FUNCS_EXPANSION], [
89 m4_divert_text([DEFAULTS], [gl_func_list=])
90 AC_CHECK_FUNCS([$gl_func_list])
91 m4_define([gl_FUNCS_EXPANSION], [])
92])
93
94# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of
95# AC_CHECK_DECLS(DECL1, DECL2, ...).
96AC_DEFUN([AC_CHECK_DECLS_ONCE], [
97 :
98 m4_foreach_w([gl_DECL_NAME], [$1], [
99 AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
100 AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
101 ])
102 AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]))
103 ])
104])
diff --git a/gl/m4/open-cloexec.m4 b/gl/m4/open-cloexec.m4
new file mode 100644
index 0000000..fd572fc
--- /dev/null
+++ b/gl/m4/open-cloexec.m4
@@ -0,0 +1,21 @@
1# Test whether O_CLOEXEC is defined.
2
3dnl Copyright 2017-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_PREPROC_O_CLOEXEC],
9[
10 AC_CACHE_CHECK([for O_CLOEXEC],
11 [gl_cv_macro_O_CLOEXEC],
12 [AC_COMPILE_IFELSE(
13 [AC_LANG_PROGRAM([[#include <fcntl.h>
14 #ifndef O_CLOEXEC
15 choke me;
16 #endif
17 ]],
18 [[return O_CLOEXEC;]])],
19 [gl_cv_macro_O_CLOEXEC=yes],
20 [gl_cv_macro_O_CLOEXEC=no])])
21])
diff --git a/gl/m4/open-slash.m4 b/gl/m4/open-slash.m4
new file mode 100644
index 0000000..1f731f8
--- /dev/null
+++ b/gl/m4/open-slash.m4
@@ -0,0 +1,60 @@
1# open-slash.m4 serial 2
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Tests whether open() and creat() recognize a trailing slash.
8dnl Sets gl_cv_func_open_slash.
9AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 dnl open("foo/") should not create a file when the file name has a
13 dnl trailing slash. FreeBSD only has the problem on symlinks.
14 AC_CHECK_FUNCS_ONCE([lstat])
15 AC_CACHE_CHECK([whether open recognizes a trailing slash],
16 [gl_cv_func_open_slash],
17 [# Assume that if we have lstat, we can also check symlinks.
18 if test $ac_cv_func_lstat = yes; then
19 touch conftest.tmp
20 ln -s conftest.tmp conftest.lnk
21 fi
22 AC_RUN_IFELSE(
23 [AC_LANG_SOURCE([[
24#include <fcntl.h>
25#if HAVE_UNISTD_H
26# include <unistd.h>
27#endif
28]GL_MDA_DEFINES[
29int main ()
30{
31 int result = 0;
32#if HAVE_LSTAT
33 if (open ("conftest.lnk/", O_RDONLY) != -1)
34 result |= 1;
35#endif
36 if (open ("conftest.sl/", O_CREAT, 0600) >= 0)
37 result |= 2;
38 return result;
39}]])],
40 [gl_cv_func_open_slash=yes],
41 [gl_cv_func_open_slash=no],
42 [
43changequote(,)dnl
44 case "$host_os" in
45 freebsd* | aix* | hpux* | solaris2.[0-9] | solaris2.[0-9].*)
46 gl_cv_func_open_slash="guessing no" ;;
47 *)
48 gl_cv_func_open_slash="guessing yes" ;;
49 esac
50changequote([,])dnl
51 ])
52 rm -f conftest.sl conftest.tmp conftest.lnk
53 ])
54 case "$gl_cv_func_open_slash" in
55 *no)
56 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
57 [Define to 1 if open() fails to recognize a trailing slash.])
58 ;;
59 esac
60])
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
new file mode 100644
index 0000000..94fa2bb
--- /dev/null
+++ b/gl/m4/open.m4
@@ -0,0 +1,56 @@
1# open.m4 serial 15
2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_OPEN],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PREPROC_O_CLOEXEC])
11 case "$host_os" in
12 mingw* | pw*)
13 REPLACE_OPEN=1
14 ;;
15 *)
16 dnl open("foo/") should not create a file when the file name has a
17 dnl trailing slash. FreeBSD only has the problem on symlinks.
18 AC_CHECK_FUNCS_ONCE([lstat])
19 if test "$gl_cv_macro_O_CLOEXEC" != yes; then
20 REPLACE_OPEN=1
21 fi
22 gl_OPEN_TRAILING_SLASH_BUG
23 case "$gl_cv_func_open_slash" in
24 *no)
25 REPLACE_OPEN=1
26 ;;
27 esac
28 ;;
29 esac
30 dnl Replace open() for supporting the gnulib-defined fchdir() function,
31 dnl to keep fchdir's bookkeeping up-to-date.
32 m4_ifdef([gl_FUNC_FCHDIR], [
33 if test $REPLACE_OPEN = 0; then
34 gl_TEST_FCHDIR
35 if test $HAVE_FCHDIR = 0; then
36 REPLACE_OPEN=1
37 fi
38 fi
39 ])
40 dnl Replace open() for supporting the gnulib-defined O_NONBLOCK flag.
41 m4_ifdef([gl_NONBLOCKING_IO], [
42 if test $REPLACE_OPEN = 0; then
43 gl_NONBLOCKING_IO
44 if test $gl_cv_have_open_O_NONBLOCK != yes; then
45 REPLACE_OPEN=1
46 fi
47 fi
48 ])
49])
50
51# Prerequisites of lib/open.c.
52AC_DEFUN([gl_PREREQ_OPEN],
53[
54 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
55 :
56])
diff --git a/gl/m4/pathmax.m4 b/gl/m4/pathmax.m4
new file mode 100644
index 0000000..6d47d2c
--- /dev/null
+++ b/gl/m4/pathmax.m4
@@ -0,0 +1,42 @@
1# pathmax.m4 serial 11
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_PATHMAX],
9[
10 dnl Prerequisites of lib/pathmax.h.
11 AC_CHECK_HEADERS_ONCE([sys/param.h])
12])
13
14# Expands to a piece of C program that defines PATH_MAX in the same way as
15# "pathmax.h" will do.
16AC_DEFUN([gl_PATHMAX_SNIPPET], [[
17/* Arrange to define PATH_MAX, like "pathmax.h" does. */
18#if HAVE_UNISTD_H
19# include <unistd.h>
20#endif
21#include <limits.h>
22#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
23# include <sys/param.h>
24#endif
25#if !defined PATH_MAX && defined MAXPATHLEN
26# define PATH_MAX MAXPATHLEN
27#endif
28#ifdef __hpux
29# undef PATH_MAX
30# define PATH_MAX 1024
31#endif
32#if defined _WIN32 && ! defined __CYGWIN__
33# undef PATH_MAX
34# define PATH_MAX 260
35#endif
36]])
37
38# Prerequisites of gl_PATHMAX_SNIPPET.
39AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ],
40[
41 AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h])
42])
diff --git a/gl/m4/pid_t.m4 b/gl/m4/pid_t.m4
new file mode 100644
index 0000000..0fd7d0a
--- /dev/null
+++ b/gl/m4/pid_t.m4
@@ -0,0 +1,38 @@
1# pid_t.m4 serial 4
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# The following implementation works around a problem in autoconf <= 2.69.
8m4_version_prereq([2.70], [], [
9
10dnl Define pid_t if the headers don't define it.
11AC_DEFUN([AC_TYPE_PID_T],
12[
13 AC_CHECK_TYPE([pid_t],
14 [],
15 [dnl On 64-bit native Windows, define it to the equivalent of 'intptr_t'
16 dnl (= 'long long' = '__int64'), because that is the return type
17 dnl of the _spawnv* functions
18 dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvp-wspawnvp>
19 dnl and the argument type of the _cwait function
20 dnl <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/cwait>.
21 dnl Otherwise (on 32-bit Windows and on old Unix platforms), define it
22 dnl to 'int'.
23 AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM([[
25 #if defined _WIN64 && !defined __CYGWIN__
26 LLP64
27 #endif
28 ]])
29 ],
30 [gl_pid_type='int'],
31 [gl_pid_type='__int64'])
32 AC_DEFINE_UNQUOTED([pid_t], [$gl_pid_type],
33 [Define as a signed integer type capable of holding a process identifier.])
34 ],
35 [AC_INCLUDES_DEFAULT])
36])
37
38])# m4_version_prereq 2.70
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4
deleted file mode 100644
index 1c70b6c..0000000
--- a/gl/m4/po.m4
+++ /dev/null
@@ -1,453 +0,0 @@
1# po.m4 serial 21 (gettext-0.18.3)
2dnl Copyright (C) 1995-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19
20AC_PREREQ([2.60])
21
22dnl Checks for all prerequisites of the po subdirectory.
23AC_DEFUN([AM_PO_SUBDIRS],
24[
25 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
26 AC_REQUIRE([AC_PROG_INSTALL])dnl
27 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
28 AC_REQUIRE([AC_PROG_SED])dnl
29 AC_REQUIRE([AM_NLS])dnl
30
31 dnl Release version of the gettext macros. This is used to ensure that
32 dnl the gettext macros and po/Makefile.in.in are in sync.
33 AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
34
35 dnl Perform the following tests also if --disable-nls has been given,
36 dnl because they are needed for "make dist" to work.
37
38 dnl Search for GNU msgfmt in the PATH.
39 dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
40 dnl The second test excludes FreeBSD msgfmt.
41 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
42 [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
43 (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
44 :)
45 AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
46
47 dnl Test whether it is GNU msgfmt >= 0.15.
48changequote(,)dnl
49 case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
50 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;;
51 *) MSGFMT_015=$MSGFMT ;;
52 esac
53changequote([,])dnl
54 AC_SUBST([MSGFMT_015])
55changequote(,)dnl
56 case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
57 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
58 *) GMSGFMT_015=$GMSGFMT ;;
59 esac
60changequote([,])dnl
61 AC_SUBST([GMSGFMT_015])
62
63 dnl Search for GNU xgettext 0.12 or newer in the PATH.
64 dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
65 dnl The second test excludes FreeBSD xgettext.
66 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
67 [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
68 (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
69 :)
70 dnl Remove leftover from FreeBSD xgettext call.
71 rm -f messages.po
72
73 dnl Test whether it is GNU xgettext >= 0.15.
74changequote(,)dnl
75 case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
76 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
77 *) XGETTEXT_015=$XGETTEXT ;;
78 esac
79changequote([,])dnl
80 AC_SUBST([XGETTEXT_015])
81
82 dnl Search for GNU msgmerge 0.11 or newer in the PATH.
83 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
84 [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
85
86 dnl Installation directories.
87 dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we
88 dnl have to define it here, so that it can be used in po/Makefile.
89 test -n "$localedir" || localedir='${datadir}/locale'
90 AC_SUBST([localedir])
91
92 dnl Support for AM_XGETTEXT_OPTION.
93 test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
94 AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
95
96 AC_CONFIG_COMMANDS([po-directories], [[
97 for ac_file in $CONFIG_FILES; do
98 # Support "outfile[:infile[:infile...]]"
99 case "$ac_file" in
100 *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
101 esac
102 # PO directories have a Makefile.in generated from Makefile.in.in.
103 case "$ac_file" in */Makefile.in)
104 # Adjust a relative srcdir.
105 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
106 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
107 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
108 # In autoconf-2.13 it is called $ac_given_srcdir.
109 # In autoconf-2.50 it is called $srcdir.
110 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
111 case "$ac_given_srcdir" in
112 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
113 /*) top_srcdir="$ac_given_srcdir" ;;
114 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
115 esac
116 # Treat a directory as a PO directory if and only if it has a
117 # POTFILES.in file. This allows packages to have multiple PO
118 # directories under different names or in different locations.
119 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
120 rm -f "$ac_dir/POTFILES"
121 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
122 gt_tab=`printf '\t'`
123 cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
124 POMAKEFILEDEPS="POTFILES.in"
125 # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
126 # on $ac_dir but don't depend on user-specified configuration
127 # parameters.
128 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
129 # The LINGUAS file contains the set of available languages.
130 if test -n "$OBSOLETE_ALL_LINGUAS"; then
131 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
132 fi
133 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
134 # Hide the ALL_LINGUAS assignment from automake < 1.5.
135 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
136 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
137 else
138 # The set of available languages was given in configure.in.
139 # Hide the ALL_LINGUAS assignment from automake < 1.5.
140 eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
141 fi
142 # Compute POFILES
143 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
144 # Compute UPDATEPOFILES
145 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
146 # Compute DUMMYPOFILES
147 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
148 # Compute GMOFILES
149 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
150 case "$ac_given_srcdir" in
151 .) srcdirpre= ;;
152 *) srcdirpre='$(srcdir)/' ;;
153 esac
154 POFILES=
155 UPDATEPOFILES=
156 DUMMYPOFILES=
157 GMOFILES=
158 for lang in $ALL_LINGUAS; do
159 POFILES="$POFILES $srcdirpre$lang.po"
160 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
161 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
162 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
163 done
164 # CATALOGS depends on both $ac_dir and the user's LINGUAS
165 # environment variable.
166 INST_LINGUAS=
167 if test -n "$ALL_LINGUAS"; then
168 for presentlang in $ALL_LINGUAS; do
169 useit=no
170 if test "%UNSET%" != "$LINGUAS"; then
171 desiredlanguages="$LINGUAS"
172 else
173 desiredlanguages="$ALL_LINGUAS"
174 fi
175 for desiredlang in $desiredlanguages; do
176 # Use the presentlang catalog if desiredlang is
177 # a. equal to presentlang, or
178 # b. a variant of presentlang (because in this case,
179 # presentlang can be used as a fallback for messages
180 # which are not translated in the desiredlang catalog).
181 case "$desiredlang" in
182 "$presentlang"*) useit=yes;;
183 esac
184 done
185 if test $useit = yes; then
186 INST_LINGUAS="$INST_LINGUAS $presentlang"
187 fi
188 done
189 fi
190 CATALOGS=
191 if test -n "$INST_LINGUAS"; then
192 for lang in $INST_LINGUAS; do
193 CATALOGS="$CATALOGS $lang.gmo"
194 done
195 fi
196 test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
197 sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
198 for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
199 if test -f "$f"; then
200 case "$f" in
201 *.orig | *.bak | *~) ;;
202 *) cat "$f" >> "$ac_dir/Makefile" ;;
203 esac
204 fi
205 done
206 fi
207 ;;
208 esac
209 done]],
210 [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
211 # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it
212 # from automake < 1.5.
213 eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
214 # Capture the value of LINGUAS because we need it to compute CATALOGS.
215 LINGUAS="${LINGUAS-%UNSET%}"
216 ])
217])
218
219dnl Postprocesses a Makefile in a directory containing PO files.
220AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
221[
222 # When this code is run, in config.status, two variables have already been
223 # set:
224 # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
225 # - LINGUAS is the value of the environment variable LINGUAS at configure
226 # time.
227
228changequote(,)dnl
229 # Adjust a relative srcdir.
230 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
231 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
232 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
233 # In autoconf-2.13 it is called $ac_given_srcdir.
234 # In autoconf-2.50 it is called $srcdir.
235 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
236 case "$ac_given_srcdir" in
237 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
238 /*) top_srcdir="$ac_given_srcdir" ;;
239 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
240 esac
241
242 # Find a way to echo strings without interpreting backslash.
243 if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
244 gt_echo='echo'
245 else
246 if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
247 gt_echo='printf %s\n'
248 else
249 echo_func () {
250 cat <<EOT
251$*
252EOT
253 }
254 gt_echo='echo_func'
255 fi
256 fi
257
258 # A sed script that extracts the value of VARIABLE from a Makefile.
259 tab=`printf '\t'`
260 sed_x_variable='
261# Test if the hold space is empty.
262x
263s/P/P/
264x
265ta
266# Yes it was empty. Look if we have the expected variable definition.
267/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
268 # Seen the first line of the variable definition.
269 s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
270 ba
271}
272bd
273:a
274# Here we are processing a line from the variable definition.
275# Remove comment, more precisely replace it with a space.
276s/#.*$/ /
277# See if the line ends in a backslash.
278tb
279:b
280s/\\$//
281# Print the line, without the trailing backslash.
282p
283tc
284# There was no trailing backslash. The end of the variable definition is
285# reached. Clear the hold space.
286s/^.*$//
287x
288bd
289:c
290# A trailing backslash means that the variable definition continues in the
291# next line. Put a nonempty string into the hold space to indicate this.
292s/^.*$/P/
293x
294:d
295'
296changequote([,])dnl
297
298 # Set POTFILES to the value of the Makefile variable POTFILES.
299 sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
300 POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
301 # Compute POTFILES_DEPS as
302 # $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
303 POTFILES_DEPS=
304 for file in $POTFILES; do
305 POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
306 done
307 POMAKEFILEDEPS=""
308
309 if test -n "$OBSOLETE_ALL_LINGUAS"; then
310 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
311 fi
312 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
313 # The LINGUAS file contains the set of available languages.
314 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
315 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
316 else
317 # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
318 sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
319 ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
320 fi
321 # Hide the ALL_LINGUAS assignment from automake < 1.5.
322 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
323 # Compute POFILES
324 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
325 # Compute UPDATEPOFILES
326 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
327 # Compute DUMMYPOFILES
328 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
329 # Compute GMOFILES
330 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
331 # Compute PROPERTIESFILES
332 # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).properties)
333 # Compute CLASSFILES
334 # as $(foreach lang, $(ALL_LINGUAS), $(top_srcdir)/$(DOMAIN)_$(lang).class)
335 # Compute QMFILES
336 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
337 # Compute MSGFILES
338 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
339 # Compute RESOURCESDLLFILES
340 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
341 case "$ac_given_srcdir" in
342 .) srcdirpre= ;;
343 *) srcdirpre='$(srcdir)/' ;;
344 esac
345 POFILES=
346 UPDATEPOFILES=
347 DUMMYPOFILES=
348 GMOFILES=
349 PROPERTIESFILES=
350 CLASSFILES=
351 QMFILES=
352 MSGFILES=
353 RESOURCESDLLFILES=
354 for lang in $ALL_LINGUAS; do
355 POFILES="$POFILES $srcdirpre$lang.po"
356 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
357 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
358 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
359 PROPERTIESFILES="$PROPERTIESFILES \$(top_srcdir)/\$(DOMAIN)_$lang.properties"
360 CLASSFILES="$CLASSFILES \$(top_srcdir)/\$(DOMAIN)_$lang.class"
361 QMFILES="$QMFILES $srcdirpre$lang.qm"
362 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
363 MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
364 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
365 RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
366 done
367 # CATALOGS depends on both $ac_dir and the user's LINGUAS
368 # environment variable.
369 INST_LINGUAS=
370 if test -n "$ALL_LINGUAS"; then
371 for presentlang in $ALL_LINGUAS; do
372 useit=no
373 if test "%UNSET%" != "$LINGUAS"; then
374 desiredlanguages="$LINGUAS"
375 else
376 desiredlanguages="$ALL_LINGUAS"
377 fi
378 for desiredlang in $desiredlanguages; do
379 # Use the presentlang catalog if desiredlang is
380 # a. equal to presentlang, or
381 # b. a variant of presentlang (because in this case,
382 # presentlang can be used as a fallback for messages
383 # which are not translated in the desiredlang catalog).
384 case "$desiredlang" in
385 "$presentlang"*) useit=yes;;
386 esac
387 done
388 if test $useit = yes; then
389 INST_LINGUAS="$INST_LINGUAS $presentlang"
390 fi
391 done
392 fi
393 CATALOGS=
394 JAVACATALOGS=
395 QTCATALOGS=
396 TCLCATALOGS=
397 CSHARPCATALOGS=
398 if test -n "$INST_LINGUAS"; then
399 for lang in $INST_LINGUAS; do
400 CATALOGS="$CATALOGS $lang.gmo"
401 JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
402 QTCATALOGS="$QTCATALOGS $lang.qm"
403 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
404 TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
405 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
406 CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
407 done
408 fi
409
410 sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
411 tab=`printf '\t'`
412 if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
413 # Add dependencies that cannot be formulated as a simple suffix rule.
414 for lang in $ALL_LINGUAS; do
415 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
416 cat >> "$ac_file.tmp" <<EOF
417$frobbedlang.msg: $lang.po
418${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
419${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
420EOF
421 done
422 fi
423 if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
424 # Add dependencies that cannot be formulated as a simple suffix rule.
425 for lang in $ALL_LINGUAS; do
426 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
427 cat >> "$ac_file.tmp" <<EOF
428$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
429${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
430${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
431EOF
432 done
433 fi
434 if test -n "$POMAKEFILEDEPS"; then
435 cat >> "$ac_file.tmp" <<EOF
436Makefile: $POMAKEFILEDEPS
437EOF
438 fi
439 mv "$ac_file.tmp" "$ac_file"
440])
441
442dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
443AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
444[
445 XGETTEXT_EXTRA_OPTIONS=
446])
447
448dnl Registers an option to be passed to xgettext in the po subdirectory.
449AC_DEFUN([AM_XGETTEXT_OPTION],
450[
451 AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
452 XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"
453])
diff --git a/gl/m4/printf-posix.m4 b/gl/m4/printf-posix.m4
deleted file mode 100644
index d7dfb60..0000000
--- a/gl/m4/printf-posix.m4
+++ /dev/null
@@ -1,48 +0,0 @@
1# printf-posix.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Test whether the printf() function supports POSIX/XSI format strings with
9dnl positions.
10
11AC_DEFUN([gt_PRINTF_POSIX],
12[
13 AC_REQUIRE([AC_PROG_CC])
14 AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings],
15 gt_cv_func_printf_posix,
16 [
17 AC_RUN_IFELSE(
18 [AC_LANG_SOURCE([[
19#include <stdio.h>
20#include <string.h>
21/* The string "%2$d %1$d", with dollar characters protected from the shell's
22 dollar expansion (possibly an autoconf bug). */
23static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
24static char buf[100];
25int main ()
26{
27 sprintf (buf, format, 33, 55);
28 return (strcmp (buf, "55 33") != 0);
29}]])],
30 [gt_cv_func_printf_posix=yes],
31 [gt_cv_func_printf_posix=no],
32 [
33 AC_EGREP_CPP([notposix], [
34#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
35 notposix
36#endif
37 ],
38 [gt_cv_func_printf_posix="guessing no"],
39 [gt_cv_func_printf_posix="guessing yes"])
40 ])
41 ])
42 case $gt_cv_func_printf_posix in
43 *yes)
44 AC_DEFINE([HAVE_POSIX_PRINTF], [1],
45 [Define if your printf() function supports format strings with positions.])
46 ;;
47 esac
48])
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index ef44f78..4e65abc 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,5 +1,5 @@
1# printf.m4 serial 50 1# printf.m4 serial 73
2dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -38,6 +38,8 @@ int main ()
38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
39 || strcmp (buf, "12345671 33") != 0) 39 || strcmp (buf, "12345671 33") != 0)
40 result |= 1; 40 result |= 1;
41#else
42 result |= 1;
41#endif 43#endif
42 buf[0] = '\0'; 44 buf[0] = '\0';
43 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 45 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
@@ -56,13 +58,16 @@ int main ()
56 [gl_cv_func_printf_sizes_c99=yes], 58 [gl_cv_func_printf_sizes_c99=yes],
57 [gl_cv_func_printf_sizes_c99=no], 59 [gl_cv_func_printf_sizes_c99=no],
58 [ 60 [
59changequote(,)dnl
60 case "$host_os" in 61 case "$host_os" in
62changequote(,)dnl
61 # Guess yes on glibc systems. 63 # Guess yes on glibc systems.
62 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 64 *-gnu* | gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on musl systems.
66 *-musl*) gl_cv_func_printf_sizes_c99="guessing yes";;
63 # Guess yes on FreeBSD >= 5. 67 # Guess yes on FreeBSD >= 5.
64 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; 68 freebsd[1-4].*) gl_cv_func_printf_sizes_c99="guessing no";;
65 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 69 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
70 midnightbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
66 # Guess yes on Mac OS X >= 10.3. 71 # Guess yes on Mac OS X >= 10.3.
67 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; 72 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
68 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; 73 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
@@ -77,10 +82,21 @@ changequote(,)dnl
77 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 82 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
78 gl_cv_func_printf_sizes_c99="guessing no";; 83 gl_cv_func_printf_sizes_c99="guessing no";;
79 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 84 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
80 # If we don't know, assume the worst. 85 # Guess yes on Android.
81 *) gl_cv_func_printf_sizes_c99="guessing no";; 86 linux*-android*) gl_cv_func_printf_sizes_c99="guessing yes";;
82 esac
83changequote([,])dnl 87changequote([,])dnl
88 # Guess yes on MSVC, no on mingw.
89 mingw*) AC_EGREP_CPP([Known], [
90#ifdef _MSC_VER
91 Known
92#endif
93 ],
94 [gl_cv_func_printf_sizes_c99="guessing yes"],
95 [gl_cv_func_printf_sizes_c99="guessing no"])
96 ;;
97 # If we don't know, obey --enable-cross-guesses.
98 *) gl_cv_func_printf_sizes_c99="$gl_cross_guess_normal";;
99 esac
84 ]) 100 ])
85 ]) 101 ])
86]) 102])
@@ -120,14 +136,22 @@ int main ()
120}]])], 136}]])],
121 [gl_cv_func_printf_long_double=yes], 137 [gl_cv_func_printf_long_double=yes],
122 [gl_cv_func_printf_long_double=no], 138 [gl_cv_func_printf_long_double=no],
123 [ 139 [case "$host_os" in
124changequote(,)dnl 140 # Guess no on BeOS.
125 case "$host_os" in 141 beos*) gl_cv_func_printf_long_double="guessing no";;
126 beos*) gl_cv_func_printf_long_double="guessing no";; 142 # Guess yes on Android.
127 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; 143 linux*-android*) gl_cv_func_printf_long_double="guessing yes";;
128 *) gl_cv_func_printf_long_double="guessing yes";; 144 # Guess yes on MSVC, no on mingw.
145 mingw*) AC_EGREP_CPP([Known], [
146#ifdef _MSC_VER
147 Known
148#endif
149 ],
150 [gl_cv_func_printf_long_double="guessing yes"],
151 [gl_cv_func_printf_long_double="guessing no"])
152 ;;
153 *) gl_cv_func_printf_long_double="guessing yes";;
129 esac 154 esac
130changequote([,])dnl
131 ]) 155 ])
132 ]) 156 ])
133]) 157])
@@ -215,13 +239,16 @@ int main ()
215 [gl_cv_func_printf_infinite=yes], 239 [gl_cv_func_printf_infinite=yes],
216 [gl_cv_func_printf_infinite=no], 240 [gl_cv_func_printf_infinite=no],
217 [ 241 [
218changequote(,)dnl
219 case "$host_os" in 242 case "$host_os" in
243changequote(,)dnl
220 # Guess yes on glibc systems. 244 # Guess yes on glibc systems.
221 *-gnu*) gl_cv_func_printf_infinite="guessing yes";; 245 *-gnu* | gnu*) gl_cv_func_printf_infinite="guessing yes";;
246 # Guess yes on musl systems.
247 *-musl*) gl_cv_func_printf_infinite="guessing yes";;
222 # Guess yes on FreeBSD >= 6. 248 # Guess yes on FreeBSD >= 6.
223 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; 249 freebsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
224 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 250 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
251 midnightbsd*) gl_cv_func_printf_infinite="guessing yes";;
225 # Guess yes on Mac OS X >= 10.3. 252 # Guess yes on Mac OS X >= 10.3.
226 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; 253 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
227 darwin*) gl_cv_func_printf_infinite="guessing yes";; 254 darwin*) gl_cv_func_printf_infinite="guessing yes";;
@@ -232,12 +259,26 @@ changequote(,)dnl
232 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 259 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
233 gl_cv_func_printf_infinite="guessing no";; 260 gl_cv_func_printf_infinite="guessing no";;
234 netbsd*) gl_cv_func_printf_infinite="guessing yes";; 261 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
262 # Guess yes on OpenBSD >= 6.0.
263 openbsd[1-5].*) gl_cv_func_printf_infinite="guessing no";;
264 openbsd*) gl_cv_func_printf_infinite="guessing yes";;
235 # Guess yes on BeOS. 265 # Guess yes on BeOS.
236 beos*) gl_cv_func_printf_infinite="guessing yes";; 266 beos*) gl_cv_func_printf_infinite="guessing yes";;
237 # If we don't know, assume the worst. 267 # Guess no on Android.
238 *) gl_cv_func_printf_infinite="guessing no";; 268 linux*-android*) gl_cv_func_printf_infinite="guessing no";;
239 esac
240changequote([,])dnl 269changequote([,])dnl
270 # Guess yes on MSVC, no on mingw.
271 mingw*) AC_EGREP_CPP([Known], [
272#ifdef _MSC_VER
273 Known
274#endif
275 ],
276 [gl_cv_func_printf_infinite="guessing yes"],
277 [gl_cv_func_printf_infinite="guessing no"])
278 ;;
279 # If we don't know, obey --enable-cross-guesses.
280 *) gl_cv_func_printf_infinite="$gl_cross_guess_normal";;
281 esac
241 ]) 282 ])
242 ]) 283 ])
243]) 284])
@@ -328,7 +369,7 @@ int main ()
328# ifdef WORDS_BIGENDIAN 369# ifdef WORDS_BIGENDIAN
329# define LDBL80_WORDS(exponent,manthi,mantlo) \ 370# define LDBL80_WORDS(exponent,manthi,mantlo) \
330 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \ 371 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
331 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \ 372 ((unsigned int) (manthi) << 16) | ((unsigned int) (mantlo) >> 16), \
332 (unsigned int) (mantlo) << 16 \ 373 (unsigned int) (mantlo) << 16 \
333 } 374 }
334# else 375# else
@@ -365,66 +406,51 @@ int main ()
365 { /* Pseudo-NaN. */ 406 { /* Pseudo-NaN. */
366 static union { unsigned int word[4]; long double value; } x = 407 static union { unsigned int word[4]; long double value; } x =
367 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; 408 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
368 if (sprintf (buf, "%Lf", x.value) < 0 409 if (sprintf (buf, "%Lf", x.value) <= 0)
369 || !strisnan (buf, 0, strlen (buf)))
370 result |= 4; 410 result |= 4;
371 if (sprintf (buf, "%Le", x.value) < 0 411 if (sprintf (buf, "%Le", x.value) <= 0)
372 || !strisnan (buf, 0, strlen (buf)))
373 result |= 4; 412 result |= 4;
374 if (sprintf (buf, "%Lg", x.value) < 0 413 if (sprintf (buf, "%Lg", x.value) <= 0)
375 || !strisnan (buf, 0, strlen (buf)))
376 result |= 4; 414 result |= 4;
377 } 415 }
378 { /* Pseudo-Infinity. */ 416 { /* Pseudo-Infinity. */
379 static union { unsigned int word[4]; long double value; } x = 417 static union { unsigned int word[4]; long double value; } x =
380 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; 418 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
381 if (sprintf (buf, "%Lf", x.value) < 0 419 if (sprintf (buf, "%Lf", x.value) <= 0)
382 || !strisnan (buf, 0, strlen (buf)))
383 result |= 8; 420 result |= 8;
384 if (sprintf (buf, "%Le", x.value) < 0 421 if (sprintf (buf, "%Le", x.value) <= 0)
385 || !strisnan (buf, 0, strlen (buf)))
386 result |= 8; 422 result |= 8;
387 if (sprintf (buf, "%Lg", x.value) < 0 423 if (sprintf (buf, "%Lg", x.value) <= 0)
388 || !strisnan (buf, 0, strlen (buf)))
389 result |= 8; 424 result |= 8;
390 } 425 }
391 { /* Pseudo-Zero. */ 426 { /* Pseudo-Zero. */
392 static union { unsigned int word[4]; long double value; } x = 427 static union { unsigned int word[4]; long double value; } x =
393 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; 428 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
394 if (sprintf (buf, "%Lf", x.value) < 0 429 if (sprintf (buf, "%Lf", x.value) <= 0)
395 || !strisnan (buf, 0, strlen (buf)))
396 result |= 16; 430 result |= 16;
397 if (sprintf (buf, "%Le", x.value) < 0 431 if (sprintf (buf, "%Le", x.value) <= 0)
398 || !strisnan (buf, 0, strlen (buf)))
399 result |= 16; 432 result |= 16;
400 if (sprintf (buf, "%Lg", x.value) < 0 433 if (sprintf (buf, "%Lg", x.value) <= 0)
401 || !strisnan (buf, 0, strlen (buf)))
402 result |= 16; 434 result |= 16;
403 } 435 }
404 { /* Unnormalized number. */ 436 { /* Unnormalized number. */
405 static union { unsigned int word[4]; long double value; } x = 437 static union { unsigned int word[4]; long double value; } x =
406 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; 438 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
407 if (sprintf (buf, "%Lf", x.value) < 0 439 if (sprintf (buf, "%Lf", x.value) <= 0)
408 || !strisnan (buf, 0, strlen (buf)))
409 result |= 32; 440 result |= 32;
410 if (sprintf (buf, "%Le", x.value) < 0 441 if (sprintf (buf, "%Le", x.value) <= 0)
411 || !strisnan (buf, 0, strlen (buf)))
412 result |= 32; 442 result |= 32;
413 if (sprintf (buf, "%Lg", x.value) < 0 443 if (sprintf (buf, "%Lg", x.value) <= 0)
414 || !strisnan (buf, 0, strlen (buf)))
415 result |= 32; 444 result |= 32;
416 } 445 }
417 { /* Pseudo-Denormal. */ 446 { /* Pseudo-Denormal. */
418 static union { unsigned int word[4]; long double value; } x = 447 static union { unsigned int word[4]; long double value; } x =
419 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; 448 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
420 if (sprintf (buf, "%Lf", x.value) < 0 449 if (sprintf (buf, "%Lf", x.value) <= 0)
421 || !strisnan (buf, 0, strlen (buf)))
422 result |= 64; 450 result |= 64;
423 if (sprintf (buf, "%Le", x.value) < 0 451 if (sprintf (buf, "%Le", x.value) <= 0)
424 || !strisnan (buf, 0, strlen (buf)))
425 result |= 64; 452 result |= 64;
426 if (sprintf (buf, "%Lg", x.value) < 0 453 if (sprintf (buf, "%Lg", x.value) <= 0)
427 || !strisnan (buf, 0, strlen (buf)))
428 result |= 64; 454 result |= 64;
429 } 455 }
430#endif 456#endif
@@ -432,27 +458,43 @@ int main ()
432}]])], 458}]])],
433 [gl_cv_func_printf_infinite_long_double=yes], 459 [gl_cv_func_printf_infinite_long_double=yes],
434 [gl_cv_func_printf_infinite_long_double=no], 460 [gl_cv_func_printf_infinite_long_double=no],
435 [ 461 [case "$host_cpu" in
436changequote(,)dnl
437 case "$host_cpu" in
438 # Guess no on ia64, x86_64, i386. 462 # Guess no on ia64, x86_64, i386.
439 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; 463 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
440 *) 464 *)
441 case "$host_os" in 465 case "$host_os" in
466changequote(,)dnl
442 # Guess yes on glibc systems. 467 # Guess yes on glibc systems.
443 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 468 *-gnu* | gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
469 # Guess yes on musl systems.
470 *-musl*) gl_cv_func_printf_infinite_long_double="guessing yes";;
444 # Guess yes on FreeBSD >= 6. 471 # Guess yes on FreeBSD >= 6.
445 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; 472 freebsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
446 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 473 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
474 midnightbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
447 # Guess yes on HP-UX >= 11. 475 # Guess yes on HP-UX >= 11.
448 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; 476 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
449 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; 477 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
450 # If we don't know, assume the worst. 478 # Guess yes on OpenBSD >= 6.0.
451 *) gl_cv_func_printf_infinite_long_double="guessing no";; 479 openbsd[1-5].*) gl_cv_func_printf_infinite_long_double="guessing no";;
480 openbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
481 # Guess no on Android.
482 linux*-android*) gl_cv_func_printf_infinite_long_double="guessing no";;
483changequote([,])dnl
484 # Guess yes on MSVC, no on mingw.
485 mingw*) AC_EGREP_CPP([Known], [
486#ifdef _MSC_VER
487 Known
488#endif
489 ],
490 [gl_cv_func_printf_infinite_long_double="guessing yes"],
491 [gl_cv_func_printf_infinite_long_double="guessing no"])
492 ;;
493 # If we don't know, obey --enable-cross-guesses.
494 *) gl_cv_func_printf_infinite_long_double="$gl_cross_guess_normal";;
452 esac 495 esac
453 ;; 496 ;;
454 esac 497 esac
455changequote([,])dnl
456 ]) 498 ])
457 ]) 499 ])
458 ;; 500 ;;
@@ -495,15 +537,22 @@ int main ()
495 && strcmp (buf, "-0X6.488P-1 33") != 0 537 && strcmp (buf, "-0X6.488P-1 33") != 0
496 && strcmp (buf, "-0XC.91P-2 33") != 0)) 538 && strcmp (buf, "-0XC.91P-2 33") != 0))
497 result |= 2; 539 result |= 2;
498 /* This catches a FreeBSD 6.1 bug: it doesn't round. */ 540 /* This catches a FreeBSD 13.0 bug: it doesn't round. */
499 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 541 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
500 || (strcmp (buf, "0x1.83p+0 33") != 0 542 || (strcmp (buf, "0x1.83p+0 33") != 0
501 && strcmp (buf, "0x3.05p-1 33") != 0 543 && strcmp (buf, "0x3.05p-1 33") != 0
502 && strcmp (buf, "0x6.0ap-2 33") != 0 544 && strcmp (buf, "0x6.0ap-2 33") != 0
503 && strcmp (buf, "0xc.14p-3 33") != 0)) 545 && strcmp (buf, "0xc.14p-3 33") != 0))
504 result |= 4; 546 result |= 4;
547 /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round. */
548 if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
549 || (strcmp (buf, "0x2p+0 33") != 0
550 && strcmp (buf, "0x3p-1 33") != 0
551 && strcmp (buf, "0x6p-2 33") != 0
552 && strcmp (buf, "0xcp-3 33") != 0))
553 result |= 4;
505 /* This catches a FreeBSD 6.1 bug. See 554 /* This catches a FreeBSD 6.1 bug. See
506 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ 555 <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html> */
507 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0 556 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
508 || buf[0] == '0') 557 || buf[0] == '0')
509 result |= 8; 558 result |= 8;
@@ -515,7 +564,7 @@ int main ()
515 && strcmp (buf, "0x8.0p-2") != 0)) 564 && strcmp (buf, "0x8.0p-2") != 0))
516 result |= 16; 565 result |= 16;
517 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a 566 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
518 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 567 glibc 2.4 bug <https://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
519 if (sprintf (buf, "%.1La", 1.999L) < 0 568 if (sprintf (buf, "%.1La", 1.999L) < 0
520 || (strcmp (buf, "0x1.0p+1") != 0 569 || (strcmp (buf, "0x1.0p+1") != 0
521 && strcmp (buf, "0x2.0p+0") != 0 570 && strcmp (buf, "0x2.0p+0") != 0
@@ -529,7 +578,7 @@ int main ()
529 [ 578 [
530 case "$host_os" in 579 case "$host_os" in
531 # Guess yes on glibc >= 2.5 systems. 580 # Guess yes on glibc >= 2.5 systems.
532 *-gnu*) 581 *-gnu* | gnu*)
533 AC_EGREP_CPP([BZ2908], [ 582 AC_EGREP_CPP([BZ2908], [
534 #include <features.h> 583 #include <features.h>
535 #ifdef __GNU_LIBRARY__ 584 #ifdef __GNU_LIBRARY__
@@ -541,8 +590,14 @@ int main ()
541 [gl_cv_func_printf_directive_a="guessing yes"], 590 [gl_cv_func_printf_directive_a="guessing yes"],
542 [gl_cv_func_printf_directive_a="guessing no"]) 591 [gl_cv_func_printf_directive_a="guessing no"])
543 ;; 592 ;;
544 # If we don't know, assume the worst. 593 # Guess yes on musl systems.
545 *) gl_cv_func_printf_directive_a="guessing no";; 594 *-musl*) gl_cv_func_printf_directive_a="guessing yes";;
595 # Guess no on Android.
596 linux*-android*) gl_cv_func_printf_directive_a="guessing no";;
597 # Guess no on native Windows.
598 mingw*) gl_cv_func_printf_directive_a="guessing no";;
599 # If we don't know, obey --enable-cross-guesses.
600 *) gl_cv_func_printf_directive_a="$gl_cross_guess_normal";;
546 esac 601 esac
547 ]) 602 ])
548 ]) 603 ])
@@ -583,23 +638,40 @@ int main ()
583 [gl_cv_func_printf_directive_f=yes], 638 [gl_cv_func_printf_directive_f=yes],
584 [gl_cv_func_printf_directive_f=no], 639 [gl_cv_func_printf_directive_f=no],
585 [ 640 [
586changequote(,)dnl
587 case "$host_os" in 641 case "$host_os" in
642changequote(,)dnl
588 # Guess yes on glibc systems. 643 # Guess yes on glibc systems.
589 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; 644 *-gnu* | gnu*) gl_cv_func_printf_directive_f="guessing yes";;
645 # Guess yes on musl systems.
646 *-musl*) gl_cv_func_printf_directive_f="guessing yes";;
590 # Guess yes on FreeBSD >= 6. 647 # Guess yes on FreeBSD >= 6.
591 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; 648 freebsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
592 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 649 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
650 midnightbsd*) gl_cv_func_printf_directive_f="guessing yes";;
593 # Guess yes on Mac OS X >= 10.3. 651 # Guess yes on Mac OS X >= 10.3.
594 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; 652 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
595 darwin*) gl_cv_func_printf_directive_f="guessing yes";; 653 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
654 # Guess yes on OpenBSD >= 6.0.
655 openbsd[1-5].*) gl_cv_func_printf_directive_f="guessing no";;
656 openbsd*) gl_cv_func_printf_directive_f="guessing yes";;
596 # Guess yes on Solaris >= 2.10. 657 # Guess yes on Solaris >= 2.10.
597 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";; 658 solaris2.[1-9][0-9]*) gl_cv_func_printf_directive_f="guessing yes";;
598 solaris*) gl_cv_func_printf_sizes_c99="guessing no";; 659 solaris*) gl_cv_func_printf_directive_f="guessing no";;
599 # If we don't know, assume the worst. 660 # Guess no on Android.
600 *) gl_cv_func_printf_directive_f="guessing no";; 661 linux*-android*) gl_cv_func_printf_directive_f="guessing no";;
601 esac
602changequote([,])dnl 662changequote([,])dnl
663 # Guess yes on MSVC, no on mingw.
664 mingw*) AC_EGREP_CPP([Known], [
665#ifdef _MSC_VER
666 Known
667#endif
668 ],
669 [gl_cv_func_printf_directive_f="guessing yes"],
670 [gl_cv_func_printf_directive_f="guessing no"])
671 ;;
672 # If we don't know, obey --enable-cross-guesses.
673 *) gl_cv_func_printf_directive_f="$gl_cross_guess_normal";;
674 esac
603 ]) 675 ])
604 ]) 676 ])
605]) 677])
@@ -621,7 +693,10 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
621#include <stdlib.h> 693#include <stdlib.h>
622#include <string.h> 694#include <string.h>
623#ifdef _MSC_VER 695#ifdef _MSC_VER
624/* See page about "Parameter Validation" on msdn.microsoft.com. */ 696#include <inttypes.h>
697/* See page about "Parameter Validation" on msdn.microsoft.com.
698 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation>
699 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-invalid-parameter-handler-set-thread-local-invalid-parameter-handler> */
625static void cdecl 700static void cdecl
626invalid_parameter_handler (const wchar_t *expression, 701invalid_parameter_handler (const wchar_t *expression,
627 const wchar_t *function, 702 const wchar_t *function,
@@ -651,13 +726,23 @@ int main ()
651}]])], 726}]])],
652 [gl_cv_func_printf_directive_n=yes], 727 [gl_cv_func_printf_directive_n=yes],
653 [gl_cv_func_printf_directive_n=no], 728 [gl_cv_func_printf_directive_n=no],
654 [ 729 [case "$host_os" in
655changequote(,)dnl 730 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
656 case "$host_os" in 731 *-gnu* | gnu*) AC_COMPILE_IFELSE(
657 mingw*) gl_cv_func_printf_directive_n="guessing no";; 732 [AC_LANG_SOURCE(
658 *) gl_cv_func_printf_directive_n="guessing yes";; 733 [[#if _FORTIFY_SOURCE >= 2
734 error fail
735 #endif
736 ]])],
737 [gl_cv_func_printf_directive_n="guessing yes"],
738 [gl_cv_func_printf_directive_n="guessing no"])
739 ;;
740 # Guess no on Android.
741 linux*-android*) gl_cv_func_printf_directive_n="guessing no";;
742 # Guess no on native Windows.
743 mingw*) gl_cv_func_printf_directive_n="guessing no";;
744 *) gl_cv_func_printf_directive_n="guessing yes";;
659 esac 745 esac
660changequote([,])dnl
661 ]) 746 ])
662 ]) 747 ])
663]) 748])
@@ -678,13 +763,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
678 [ 763 [
679 AC_RUN_IFELSE( 764 AC_RUN_IFELSE(
680 [AC_LANG_SOURCE([[ 765 [AC_LANG_SOURCE([[
681/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
682 <wchar.h>.
683 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
684 included before <wchar.h>. */
685#include <stddef.h>
686#include <stdio.h> 766#include <stdio.h>
687#include <time.h>
688#include <wchar.h> 767#include <wchar.h>
689#include <string.h> 768#include <string.h>
690int main () 769int main ()
@@ -732,11 +811,17 @@ int main ()
732 [ 811 [
733changequote(,)dnl 812changequote(,)dnl
734 case "$host_os" in 813 case "$host_os" in
735 openbsd*) gl_cv_func_printf_directive_ls="guessing no";; 814 # Guess yes on OpenBSD >= 6.0.
815 openbsd[1-5].*) gl_cv_func_printf_directive_ls="guessing no";;
816 openbsd*) gl_cv_func_printf_directive_ls="guessing yes";;
736 irix*) gl_cv_func_printf_directive_ls="guessing no";; 817 irix*) gl_cv_func_printf_directive_ls="guessing no";;
737 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 818 solaris*) gl_cv_func_printf_directive_ls="guessing no";;
738 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 819 cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
739 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 820 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
821 # Guess no on Android.
822 linux*-android*) gl_cv_func_printf_directive_ls="guessing no";;
823 # Guess yes on native Windows.
824 mingw*) gl_cv_func_printf_directive_ls="guessing yes";;
740 *) gl_cv_func_printf_directive_ls="guessing yes";; 825 *) gl_cv_func_printf_directive_ls="guessing yes";;
741 esac 826 esac
742changequote([,])dnl 827changequote([,])dnl
@@ -774,10 +859,13 @@ int main ()
774changequote(,)dnl 859changequote(,)dnl
775 case "$host_os" in 860 case "$host_os" in
776 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 861 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
777 gl_cv_func_printf_positions="guessing no";; 862 gl_cv_func_printf_positions="guessing no";;
778 beos*) gl_cv_func_printf_positions="guessing no";; 863 beos*) gl_cv_func_printf_positions="guessing no";;
779 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 864 # Guess yes on Android.
780 *) gl_cv_func_printf_positions="guessing yes";; 865 linux*-android*) gl_cv_func_printf_positions="guessing yes";;
866 # Guess no on native Windows.
867 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
868 *) gl_cv_func_printf_positions="guessing yes";;
781 esac 869 esac
782changequote([,])dnl 870changequote([,])dnl
783 ]) 871 ])
@@ -812,10 +900,13 @@ int main ()
812 [ 900 [
813changequote(,)dnl 901changequote(,)dnl
814 case "$host_os" in 902 case "$host_os" in
815 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 903 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
816 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 904 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
817 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 905 # Guess no on Android.
818 *) gl_cv_func_printf_flag_grouping="guessing yes";; 906 linux*-android*) gl_cv_func_printf_flag_grouping="guessing no";;
907 # Guess no on native Windows.
908 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
909 *) gl_cv_func_printf_flag_grouping="guessing yes";;
819 esac 910 esac
820changequote([,])dnl 911changequote([,])dnl
821 ]) 912 ])
@@ -824,7 +915,7 @@ changequote([,])dnl
824 915
825dnl Test whether the *printf family of functions supports the - flag correctly. 916dnl Test whether the *printf family of functions supports the - flag correctly.
826dnl (ISO C99.) See 917dnl (ISO C99.) See
827dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html> 918dnl <https://lists.gnu.org/r/bug-coreutils/2008-02/msg00035.html>
828dnl Result is gl_cv_func_printf_flag_leftadjust. 919dnl Result is gl_cv_func_printf_flag_leftadjust.
829 920
830AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], 921AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
@@ -852,12 +943,16 @@ int main ()
852 [ 943 [
853changequote(,)dnl 944changequote(,)dnl
854 case "$host_os" in 945 case "$host_os" in
855 # Guess yes on HP-UX 11. 946 # Guess yes on HP-UX 11.
856 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";; 947 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
857 # Guess no on HP-UX 10 and older. 948 # Guess no on HP-UX 10 and older.
858 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";; 949 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
859 # Guess yes otherwise. 950 # Guess yes on Android.
860 *) gl_cv_func_printf_flag_leftadjust="guessing yes";; 951 linux*-android*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
952 # Guess yes on native Windows.
953 mingw*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
954 # Guess yes otherwise.
955 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
861 esac 956 esac
862changequote([,])dnl 957changequote([,])dnl
863 ]) 958 ])
@@ -866,7 +961,7 @@ changequote([,])dnl
866 961
867dnl Test whether the *printf family of functions supports padding of non-finite 962dnl Test whether the *printf family of functions supports padding of non-finite
868dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See 963dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
869dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> 964dnl <https://lists.gnu.org/r/bug-gnulib/2007-04/msg00107.html>
870dnl Result is gl_cv_func_printf_flag_zero. 965dnl Result is gl_cv_func_printf_flag_zero.
871 966
872AC_DEFUN([gl_PRINTF_FLAG_ZERO], 967AC_DEFUN([gl_PRINTF_FLAG_ZERO],
@@ -895,12 +990,18 @@ int main ()
895 [ 990 [
896changequote(,)dnl 991changequote(,)dnl
897 case "$host_os" in 992 case "$host_os" in
898 # Guess yes on glibc systems. 993 # Guess yes on glibc systems.
899 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 994 *-gnu* | gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
900 # Guess yes on BeOS. 995 # Guess yes on musl systems.
901 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 996 *-musl*) gl_cv_func_printf_flag_zero="guessing yes";;
902 # If we don't know, assume the worst. 997 # Guess yes on BeOS.
903 *) gl_cv_func_printf_flag_zero="guessing no";; 998 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
999 # Guess no on Android.
1000 linux*-android*) gl_cv_func_printf_flag_zero="guessing no";;
1001 # Guess no on native Windows.
1002 mingw*) gl_cv_func_printf_flag_zero="guessing no";;
1003 # If we don't know, obey --enable-cross-guesses.
1004 *) gl_cv_func_printf_flag_zero="$gl_cross_guess_normal";;
904 esac 1005 esac
905changequote([,])dnl 1006changequote([,])dnl
906 ]) 1007 ])
@@ -953,10 +1054,12 @@ int main ()
953changequote(,)dnl 1054changequote(,)dnl
954 case "$host_os" in 1055 case "$host_os" in
955 # Guess no only on Solaris, native Windows, and BeOS systems. 1056 # Guess no only on Solaris, native Windows, and BeOS systems.
956 solaris*) gl_cv_func_printf_precision="guessing no" ;; 1057 solaris*) gl_cv_func_printf_precision="guessing no" ;;
957 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 1058 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
958 beos*) gl_cv_func_printf_precision="guessing no" ;; 1059 beos*) gl_cv_func_printf_precision="guessing no" ;;
959 *) gl_cv_func_printf_precision="guessing yes" ;; 1060 # Guess yes on Android.
1061 linux*-android*) gl_cv_func_printf_precision="guessing yes" ;;
1062 *) gl_cv_func_printf_precision="guessing yes" ;;
960 esac 1063 esac
961changequote([,])dnl 1064changequote([,])dnl
962 ]) 1065 ])
@@ -978,9 +1081,8 @@ AC_DEFUN([gl_PRINTF_ENOMEM],
978 gl_cv_func_printf_enomem="guessing no" 1081 gl_cv_func_printf_enomem="guessing no"
979 if test "$cross_compiling" = no; then 1082 if test "$cross_compiling" = no; then
980 if test $APPLE_UNIVERSAL_BUILD = 0; then 1083 if test $APPLE_UNIVERSAL_BUILD = 0; then
981 AC_LANG_CONFTEST([AC_LANG_SOURCE([ 1084 AC_LANG_CONFTEST([AC_LANG_SOURCE([[
982]GL_NOCRASH[ 1085]GL_NOCRASH[
983changequote(,)dnl
984#include <stdio.h> 1086#include <stdio.h>
985#include <sys/types.h> 1087#include <sys/types.h>
986#include <sys/time.h> 1088#include <sys/time.h>
@@ -1025,8 +1127,7 @@ int main()
1025 ret = printf ("%.5000000f", 1.0); 1127 ret = printf ("%.5000000f", 1.0);
1026 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM)); 1128 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
1027} 1129}
1028changequote([,])dnl 1130 ]])])
1029 ])])
1030 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 1131 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
1031 (./conftest 2>&AS_MESSAGE_LOG_FD 1132 (./conftest 2>&AS_MESSAGE_LOG_FD
1032 result=$? 1133 result=$?
@@ -1053,28 +1154,30 @@ changequote([,])dnl
1053 if test "$gl_cv_func_printf_enomem" = "guessing no"; then 1154 if test "$gl_cv_func_printf_enomem" = "guessing no"; then
1054changequote(,)dnl 1155changequote(,)dnl
1055 case "$host_os" in 1156 case "$host_os" in
1056 # Guess yes on glibc systems. 1157 # Guess yes on glibc systems.
1057 *-gnu*) gl_cv_func_printf_enomem="guessing yes";; 1158 *-gnu* | gnu*) gl_cv_func_printf_enomem="guessing yes";;
1058 # Guess yes on Solaris. 1159 # Guess yes on Solaris.
1059 solaris*) gl_cv_func_printf_enomem="guessing yes";; 1160 solaris*) gl_cv_func_printf_enomem="guessing yes";;
1060 # Guess yes on AIX. 1161 # Guess yes on AIX.
1061 aix*) gl_cv_func_printf_enomem="guessing yes";; 1162 aix*) gl_cv_func_printf_enomem="guessing yes";;
1062 # Guess yes on HP-UX/hppa. 1163 # Guess yes on HP-UX/hppa.
1063 hpux*) case "$host_cpu" in 1164 hpux*) case "$host_cpu" in
1064 hppa*) gl_cv_func_printf_enomem="guessing yes";; 1165 hppa*) gl_cv_func_printf_enomem="guessing yes";;
1065 *) gl_cv_func_printf_enomem="guessing no";; 1166 *) gl_cv_func_printf_enomem="guessing no";;
1066 esac 1167 esac
1067 ;; 1168 ;;
1068 # Guess yes on IRIX. 1169 # Guess yes on IRIX.
1069 irix*) gl_cv_func_printf_enomem="guessing yes";; 1170 irix*) gl_cv_func_printf_enomem="guessing yes";;
1070 # Guess yes on OSF/1. 1171 # Guess yes on OSF/1.
1071 osf*) gl_cv_func_printf_enomem="guessing yes";; 1172 osf*) gl_cv_func_printf_enomem="guessing yes";;
1072 # Guess yes on BeOS. 1173 # Guess yes on BeOS.
1073 beos*) gl_cv_func_printf_enomem="guessing yes";; 1174 beos*) gl_cv_func_printf_enomem="guessing yes";;
1074 # Guess yes on Haiku. 1175 # Guess yes on Haiku.
1075 haiku*) gl_cv_func_printf_enomem="guessing yes";; 1176 haiku*) gl_cv_func_printf_enomem="guessing yes";;
1076 # If we don't know, assume the worst. 1177 # Guess no on Android.
1077 *) gl_cv_func_printf_enomem="guessing no";; 1178 linux*-android*) gl_cv_func_printf_enomem="guessing no";;
1179 # If we don't know, obey --enable-cross-guesses.
1180 *) gl_cv_func_printf_enomem="$gl_cross_guess_normal";;
1078 esac 1181 esac
1079changequote([,])dnl 1182changequote([,])dnl
1080 fi 1183 fi
@@ -1093,7 +1196,7 @@ dnl Test whether the string produced by the snprintf function is always NUL
1093dnl terminated. (ISO C99, POSIX:2001) 1196dnl terminated. (ISO C99, POSIX:2001)
1094dnl Result is gl_cv_func_snprintf_truncation_c99. 1197dnl Result is gl_cv_func_snprintf_truncation_c99.
1095 1198
1096AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], 1199AC_DEFUN_ONCE([gl_SNPRINTF_TRUNCATION_C99],
1097[ 1200[
1098 AC_REQUIRE([AC_PROG_CC]) 1201 AC_REQUIRE([AC_PROG_CC])
1099 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1202 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
@@ -1134,10 +1237,13 @@ int main ()
1134changequote(,)dnl 1237changequote(,)dnl
1135 case "$host_os" in 1238 case "$host_os" in
1136 # Guess yes on glibc systems. 1239 # Guess yes on glibc systems.
1137 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1240 *-gnu* | gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1241 # Guess yes on musl systems.
1242 *-musl*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1138 # Guess yes on FreeBSD >= 5. 1243 # Guess yes on FreeBSD >= 5.
1139 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1244 freebsd[1-4].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1140 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1245 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1246 midnightbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1141 # Guess yes on Mac OS X >= 10.3. 1247 # Guess yes on Mac OS X >= 10.3.
1142 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1248 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1143 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1249 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
@@ -1166,8 +1272,12 @@ changequote(,)dnl
1166 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1272 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1167 # Guess yes on BeOS. 1273 # Guess yes on BeOS.
1168 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1274 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1169 # If we don't know, assume the worst. 1275 # Guess yes on Android.
1170 *) gl_cv_func_snprintf_truncation_c99="guessing no";; 1276 linux*-android*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1277 # Guess no on native Windows.
1278 mingw*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1279 # If we don't know, obey --enable-cross-guesses.
1280 *) gl_cv_func_snprintf_truncation_c99="$gl_cross_guess_normal";;
1171 esac 1281 esac
1172changequote([,])dnl 1282changequote([,])dnl
1173 ]) 1283 ])
@@ -1229,14 +1339,16 @@ int main ()
1229}]])], 1339}]])],
1230 [gl_cv_func_snprintf_retval_c99=yes], 1340 [gl_cv_func_snprintf_retval_c99=yes],
1231 [gl_cv_func_snprintf_retval_c99=no], 1341 [gl_cv_func_snprintf_retval_c99=no],
1232 [ 1342 [case "$host_os" in
1233changequote(,)dnl 1343changequote(,)dnl
1234 case "$host_os" in
1235 # Guess yes on glibc systems. 1344 # Guess yes on glibc systems.
1236 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1345 *-gnu* | gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1346 # Guess yes on musl systems.
1347 *-musl*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1237 # Guess yes on FreeBSD >= 5. 1348 # Guess yes on FreeBSD >= 5.
1238 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1349 freebsd[1-4].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1239 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1350 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1351 midnightbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1240 # Guess yes on Mac OS X >= 10.3. 1352 # Guess yes on Mac OS X >= 10.3.
1241 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1353 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1242 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1354 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
@@ -1256,10 +1368,21 @@ changequote(,)dnl
1256 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1368 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1257 # Guess yes on BeOS. 1369 # Guess yes on BeOS.
1258 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1370 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1259 # If we don't know, assume the worst. 1371 # Guess yes on Android.
1260 *) gl_cv_func_snprintf_retval_c99="guessing no";; 1372 linux*-android*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1261 esac
1262changequote([,])dnl 1373changequote([,])dnl
1374 # Guess yes on MSVC, no on mingw.
1375 mingw*) AC_EGREP_CPP([Known], [
1376#ifdef _MSC_VER
1377 Known
1378#endif
1379 ],
1380 [gl_cv_func_snprintf_retval_c99="guessing yes"],
1381 [gl_cv_func_snprintf_retval_c99="guessing no"])
1382 ;;
1383 # If we don't know, obey --enable-cross-guesses.
1384 *) gl_cv_func_snprintf_retval_c99="$gl_cross_guess_normal";;
1385 esac
1263 ]) 1386 ])
1264 ]) 1387 ])
1265]) 1388])
@@ -1311,13 +1434,24 @@ int main ()
1311 [gl_cv_func_snprintf_directive_n=yes], 1434 [gl_cv_func_snprintf_directive_n=yes],
1312 [gl_cv_func_snprintf_directive_n=no], 1435 [gl_cv_func_snprintf_directive_n=no],
1313 [ 1436 [
1314changequote(,)dnl
1315 case "$host_os" in 1437 case "$host_os" in
1316 # Guess yes on glibc systems. 1438 # Guess no on glibc when _FORTIFY_SOURCE >= 2.
1317 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; 1439 *-gnu* | gnu*) AC_COMPILE_IFELSE(
1440 [AC_LANG_SOURCE(
1441 [[#if _FORTIFY_SOURCE >= 2
1442 error fail
1443 #endif
1444 ]])],
1445 [gl_cv_func_snprintf_directive_n="guessing yes"],
1446 [gl_cv_func_snprintf_directive_n="guessing no"])
1447 ;;
1448changequote(,)dnl
1449 # Guess yes on musl systems.
1450 *-musl*) gl_cv_func_snprintf_directive_n="guessing yes";;
1318 # Guess yes on FreeBSD >= 5. 1451 # Guess yes on FreeBSD >= 5.
1319 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; 1452 freebsd[1-4].*) gl_cv_func_snprintf_directive_n="guessing no";;
1320 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1453 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1454 midnightbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1321 # Guess yes on Mac OS X >= 10.3. 1455 # Guess yes on Mac OS X >= 10.3.
1322 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; 1456 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
1323 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; 1457 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
@@ -1339,10 +1473,14 @@ changequote(,)dnl
1339 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1473 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1340 # Guess yes on BeOS. 1474 # Guess yes on BeOS.
1341 beos*) gl_cv_func_snprintf_directive_n="guessing yes";; 1475 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
1342 # If we don't know, assume the worst. 1476 # Guess no on Android.
1343 *) gl_cv_func_snprintf_directive_n="guessing no";; 1477 linux*-android*) gl_cv_func_snprintf_directive_n="guessing no";;
1344 esac 1478 # Guess no on native Windows.
1479 mingw*) gl_cv_func_snprintf_directive_n="guessing no";;
1480 # If we don't know, obey --enable-cross-guesses.
1481 *) gl_cv_func_snprintf_directive_n="$gl_cross_guess_normal";;
1345changequote([,])dnl 1482changequote([,])dnl
1483 esac
1346 ]) 1484 ])
1347 ]) 1485 ])
1348]) 1486])
@@ -1355,6 +1493,7 @@ dnl Result is gl_cv_func_snprintf_size1.
1355AC_DEFUN([gl_SNPRINTF_SIZE1], 1493AC_DEFUN([gl_SNPRINTF_SIZE1],
1356[ 1494[
1357 AC_REQUIRE([AC_PROG_CC]) 1495 AC_REQUIRE([AC_PROG_CC])
1496 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1358 AC_REQUIRE([gl_SNPRINTF_PRESENCE]) 1497 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1359 AC_CACHE_CHECK([whether snprintf respects a size of 1], 1498 AC_CACHE_CHECK([whether snprintf respects a size of 1],
1360 [gl_cv_func_snprintf_size1], 1499 [gl_cv_func_snprintf_size1],
@@ -1384,7 +1523,14 @@ int main()
1384}]])], 1523}]])],
1385 [gl_cv_func_snprintf_size1=yes], 1524 [gl_cv_func_snprintf_size1=yes],
1386 [gl_cv_func_snprintf_size1=no], 1525 [gl_cv_func_snprintf_size1=no],
1387 [gl_cv_func_snprintf_size1="guessing yes"]) 1526 [case "$host_os" in
1527 # Guess yes on Android.
1528 linux*-android*) gl_cv_func_snprintf_size1="guessing yes" ;;
1529 # Guess yes on native Windows.
1530 mingw*) gl_cv_func_snprintf_size1="guessing yes" ;;
1531 *) gl_cv_func_snprintf_size1="guessing yes" ;;
1532 esac
1533 ])
1388 ]) 1534 ])
1389]) 1535])
1390 1536
@@ -1456,10 +1602,13 @@ int main()
1456changequote(,)dnl 1602changequote(,)dnl
1457 case "$host_os" in 1603 case "$host_os" in
1458 # Guess yes on glibc systems. 1604 # Guess yes on glibc systems.
1459 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1605 *-gnu* | gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1606 # Guess yes on musl systems.
1607 *-musl*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1460 # Guess yes on FreeBSD >= 5. 1608 # Guess yes on FreeBSD >= 5.
1461 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1609 freebsd[1-4].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1462 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1610 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1611 midnightbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1463 # Guess yes on Mac OS X >= 10.3. 1612 # Guess yes on Mac OS X >= 10.3.
1464 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1613 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1465 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1614 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
@@ -1480,10 +1629,12 @@ changequote(,)dnl
1480 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1629 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1481 # Guess yes on BeOS. 1630 # Guess yes on BeOS.
1482 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1631 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1483 # Guess yes on mingw. 1632 # Guess yes on Android.
1633 linux*-android*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1634 # Guess yes on native Windows.
1484 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1635 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1485 # If we don't know, assume the worst. 1636 # If we don't know, obey --enable-cross-guesses.
1486 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1637 *) gl_cv_func_vsnprintf_zerosize_c99="$gl_cross_guess_normal";;
1487 esac 1638 esac
1488changequote([,])dnl 1639changequote([,])dnl
1489 ]) 1640 ])
@@ -1539,14 +1690,19 @@ dnl
1539dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1690dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1540dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 1691dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . .
1541dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 1692dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . .
1693dnl FreeBSD 13.0 . . . . # . . . . . . . . # . . . . . .
1542dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 1694dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . .
1695dnl Mac OS X 10.13.5 . . . # # . # . . . . . . . . . . # . .
1543dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . . 1696dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . .
1544dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 1697dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . .
1698dnl OpenBSD 6.0, 6.7 . . . . # . . . . . . . . # . . . . . .
1545dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 1699dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
1546dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 1700dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . .
1547dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 1701dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . .
1548dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 1702dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . .
1549dnl Solaris 11 2011-11 . . # # # . . # . . . # . . . . . . . . 1703dnl Solaris 11.4 . . # # # . . # . . . # . . . . . . . .
1704dnl Solaris 11.3 . . . . # . . # . . . . . . . . . . . .
1705dnl Solaris 11.0 . . # # # . . # . . . # . . . . . . . .
1550dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . 1706dnl Solaris 10 . . # # # . . # . . . # # . . . . . . .
1551dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . . 1707dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . .
1552dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 1708dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
@@ -1559,11 +1715,13 @@ dnl HP-UX 10.20 # . # . # # . ? . . # # . . .
1559dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 1715dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . .
1560dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 1716dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . #
1561dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 1717dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # #
1718dnl NetBSD 9.0 . . . . # . . . . . . . . . . . . . . .
1562dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . 1719dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . .
1563dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 1720dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ?
1564dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 1721dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . .
1565dnl Haiku . . . # # # . # . . . . . ? . . ? . . . 1722dnl Haiku . . . # # # . # . . . . . ? . . ? . . .
1566dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . . 1723dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . .
1724dnl Android 4.3 . . # # # # # # . # . # . # . . . # . .
1567dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . . 1725dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . .
1568dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . . 1726dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . .
1569dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . . 1727dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . .
diff --git a/gl/m4/progtest.m4 b/gl/m4/progtest.m4
deleted file mode 100644
index 7b39123..0000000
--- a/gl/m4/progtest.m4
+++ /dev/null
@@ -1,91 +0,0 @@
1# progtest.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1996-2003, 2005, 2008-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6dnl
7dnl This file can can be used in projects which are not available under
8dnl the GNU General Public License or the GNU Library General Public
9dnl License but which still want to provide support for the GNU gettext
10dnl functionality.
11dnl Please note that the actual code of the GNU gettext library is covered
12dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain.
15
16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
18
19AC_PREREQ([2.50])
20
21# Search path for a program which passes the given test.
22
23dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
24dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
25AC_DEFUN([AM_PATH_PROG_WITH_TEST],
26[
27# Prepare PATH_SEPARATOR.
28# The user is always right.
29if test "${PATH_SEPARATOR+set}" != set; then
30 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
31 # contains only /bin. Note that ksh looks also at the FPATH variable,
32 # so we have to set that as well for the test.
33 PATH_SEPARATOR=:
34 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
35 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
36 || PATH_SEPARATOR=';'
37 }
38fi
39
40# Find out how to test for executable files. Don't use a zero-byte file,
41# as systems may use methods other than mode bits to determine executability.
42cat >conf$$.file <<_ASEOF
43#! /bin/sh
44exit 0
45_ASEOF
46chmod +x conf$$.file
47if test -x conf$$.file >/dev/null 2>&1; then
48 ac_executable_p="test -x"
49else
50 ac_executable_p="test -f"
51fi
52rm -f conf$$.file
53
54# Extract the first word of "$2", so it can be a program name with args.
55set dummy $2; ac_word=[$]2
56AC_MSG_CHECKING([for $ac_word])
57AC_CACHE_VAL([ac_cv_path_$1],
58[case "[$]$1" in
59 [[\\/]]* | ?:[[\\/]]*)
60 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
61 ;;
62 *)
63 ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
64 for ac_dir in ifelse([$5], , $PATH, [$5]); do
65 IFS="$ac_save_IFS"
66 test -z "$ac_dir" && ac_dir=.
67 for ac_exec_ext in '' $ac_executable_extensions; do
68 if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
69 echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD
70 if [$3]; then
71 ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
72 break 2
73 fi
74 fi
75 done
76 done
77 IFS="$ac_save_IFS"
78dnl If no 4th arg is given, leave the cache variable unset,
79dnl so AC_PATH_PROGS will keep looking.
80ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
81])dnl
82 ;;
83esac])dnl
84$1="$ac_cv_path_$1"
85if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
86 AC_MSG_RESULT([$][$1])
87else
88 AC_MSG_RESULT([no])
89fi
90AC_SUBST([$1])dnl
91])
diff --git a/gl/m4/pthread_rwlock_rdlock.m4 b/gl/m4/pthread_rwlock_rdlock.m4
new file mode 100644
index 0000000..ae6a885
--- /dev/null
+++ b/gl/m4/pthread_rwlock_rdlock.m4
@@ -0,0 +1,185 @@
1# pthread_rwlock_rdlock.m4 serial 4
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8dnl Inspired by
9dnl https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/2-2.c
10dnl by Intel Corporation.
11
12dnl Test whether in a situation where
13dnl - an rwlock is taken by a reader and has a writer waiting,
14dnl - an additional reader requests the lock,
15dnl - the waiting writer and the requesting reader threads have the same
16dnl priority,
17dnl the requesting reader thread gets blocked, so that at some point the
18dnl waiting writer can acquire the lock.
19dnl Without such a guarantee, when there a N readers and each of the readers
20dnl spends more than 1/Nth of the time with the lock held, there is a high
21dnl probability that the waiting writer will not get the lock in a given finite
22dnl time, a phenomenon called "writer starvation".
23dnl Without such a guarantee, applications have a hard time avoiding writer
24dnl starvation.
25dnl
26dnl POSIX:2017 makes this requirement only for implementations that support TPS
27dnl (Thread Priority Scheduling) and only for the scheduling policies SCHED_FIFO
28dnl and SCHED_RR, see
29dnl https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html
30dnl but this test verifies the guarantee regardless of TPS and regardless of
31dnl scheduling policy.
32dnl Glibc does not provide this guarantee (and never will on Linux), see
33dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701
34dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052
35AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER],
36[
37 AC_REQUIRE([gl_THREADLIB_EARLY])
38 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
39 AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader],
40 [gl_cv_pthread_rwlock_rdlock_prefer_writer],
41 [save_LIBS="$LIBS"
42 LIBS="$LIBS $LIBMULTITHREAD"
43 AC_RUN_IFELSE(
44 [AC_LANG_SOURCE([[
45#include <errno.h>
46#include <pthread.h>
47#include <stdlib.h>
48#include <unistd.h>
49
50#define SUCCEED() exit (0)
51#define FAILURE() exit (1)
52#define UNEXPECTED(n) (exit (10 + (n)))
53
54/* The main thread creates the waiting writer and the requesting reader threads
55 in the default way; this guarantees that they have the same priority.
56 We can reuse the main thread as first reader thread. */
57
58static pthread_rwlock_t lock;
59static pthread_t reader1;
60static pthread_t writer;
61static pthread_t reader2;
62static pthread_t timer;
63/* Used to pass control from writer to reader2 and from reader2 to timer,
64 as in a relay race.
65 Passing control from one running thread to another running thread
66 is most likely faster than to create the second thread. */
67static pthread_mutex_t baton;
68
69static void *
70timer_func (void *ignored)
71{
72 /* Step 13 (can be before or after step 12):
73 The timer thread takes the baton, then waits a moment to make sure
74 it can tell whether the second reader thread is blocked at step 12. */
75 if (pthread_mutex_lock (&baton))
76 UNEXPECTED (13);
77 usleep (100000);
78 /* By the time we get here, it's clear that the second reader thread is
79 blocked at step 12. This is the desired behaviour. */
80 SUCCEED ();
81}
82
83static void *
84reader2_func (void *ignored)
85{
86 int err;
87
88 /* Step 8 (can be before or after step 7):
89 The second reader thread takes the baton, then waits a moment to make sure
90 the writer thread has reached step 7. */
91 if (pthread_mutex_lock (&baton))
92 UNEXPECTED (8);
93 usleep (100000);
94 /* Step 9: The second reader thread requests the lock. */
95 err = pthread_rwlock_tryrdlock (&lock);
96 if (err == 0)
97 FAILURE ();
98 else if (err != EBUSY)
99 UNEXPECTED (9);
100 /* Step 10: Launch a timer, to test whether the next call blocks. */
101 if (pthread_create (&timer, NULL, timer_func, NULL))
102 UNEXPECTED (10);
103 /* Step 11: Release the baton. */
104 if (pthread_mutex_unlock (&baton))
105 UNEXPECTED (11);
106 /* Step 12: The second reader thread requests the lock. */
107 err = pthread_rwlock_rdlock (&lock);
108 if (err == 0)
109 FAILURE ();
110 else
111 UNEXPECTED (12);
112}
113
114static void *
115writer_func (void *ignored)
116{
117 /* Step 4: Take the baton, so that the second reader thread does not go ahead
118 too early. */
119 if (pthread_mutex_lock (&baton))
120 UNEXPECTED (4);
121 /* Step 5: Create the second reader thread. */
122 if (pthread_create (&reader2, NULL, reader2_func, NULL))
123 UNEXPECTED (5);
124 /* Step 6: Release the baton. */
125 if (pthread_mutex_unlock (&baton))
126 UNEXPECTED (6);
127 /* Step 7: The writer thread requests the lock. */
128 if (pthread_rwlock_wrlock (&lock))
129 UNEXPECTED (7);
130 return NULL;
131}
132
133int
134main ()
135{
136 reader1 = pthread_self ();
137
138 /* Step 1: The main thread initializes the lock and the baton. */
139 if (pthread_rwlock_init (&lock, NULL))
140 UNEXPECTED (1);
141 if (pthread_mutex_init (&baton, NULL))
142 UNEXPECTED (1);
143 /* Step 2: The main thread acquires the lock as a reader. */
144 if (pthread_rwlock_rdlock (&lock))
145 UNEXPECTED (2);
146 /* Step 3: Create the writer thread. */
147 if (pthread_create (&writer, NULL, writer_func, NULL))
148 UNEXPECTED (3);
149 /* Job done. Go to sleep. */
150 for (;;)
151 {
152 sleep (1);
153 }
154}
155]])],
156 [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes],
157 [gl_cv_pthread_rwlock_rdlock_prefer_writer=no],
158 [case "$host_os" in
159 # Guess no on glibc systems.
160 *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
161 # Guess no on musl systems.
162 *-musl*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
163 # Guess no on bionic systems.
164 *-android*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
165 # Guess yes on native Windows with the mingw-w64 winpthreads library.
166 # Guess no on native Windows with the gnulib windows-rwlock module.
167 mingw*) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
168 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"
169 else
170 gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no"
171 fi
172 ;;
173 # If we don't know, obey --enable-cross-guesses.
174 *) gl_cv_pthread_rwlock_rdlock_prefer_writer="$gl_cross_guess_normal" ;;
175 esac
176 ])
177 LIBS="$save_LIBS"
178 ])
179 case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in
180 *yes)
181 AC_DEFINE([HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER], [1],
182 [Define if the 'pthread_rwlock_rdlock' function prefers a writer to a reader.])
183 ;;
184 esac
185])
diff --git a/gl/m4/read.m4 b/gl/m4/read.m4
deleted file mode 100644
index 81f0f3a..0000000
--- a/gl/m4/read.m4
+++ /dev/null
@@ -1,26 +0,0 @@
1# read.m4 serial 4
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_READ],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([gl_MSVC_INVAL])
11 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
12 REPLACE_READ=1
13 fi
14 dnl This ifdef is just an optimization, to avoid performing a configure
15 dnl check whose result is not used. It does not make the test of
16 dnl GNULIB_UNISTD_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
17 m4_ifdef([gl_NONBLOCKING_IO], [
18 gl_NONBLOCKING_IO
19 if test $gl_cv_have_nonblocking != yes; then
20 REPLACE_READ=1
21 fi
22 ])
23])
24
25# Prerequisites of lib/read.c.
26AC_DEFUN([gl_PREREQ_READ], [:])
diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4
new file mode 100644
index 0000000..d22138f
--- /dev/null
+++ b/gl/m4/realloc.m4
@@ -0,0 +1,63 @@
1# realloc.m4 serial 26
2dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# This is adapted with modifications from upstream Autoconf here:
8# https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/functions.m4?id=v2.70#n1455
9AC_DEFUN([_AC_FUNC_REALLOC_IF],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
12 AC_CACHE_CHECK([whether realloc (0, 0) returns nonnull],
13 [ac_cv_func_realloc_0_nonnull],
14 [AC_RUN_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stdlib.h>
17 ]],
18 [[void *p = realloc (0, 0);
19 int result = !p;
20 free (p);
21 return result;]])
22 ],
23 [ac_cv_func_realloc_0_nonnull=yes],
24 [ac_cv_func_realloc_0_nonnull=no],
25 [case "$host_os" in
26 # Guess yes on platforms where we know the result.
27 *-gnu* | freebsd* | netbsd* | openbsd* | bitrig* \
28 | gnu* | *-musl* | midnightbsd* \
29 | hpux* | solaris* | cygwin* | mingw* | msys* )
30 ac_cv_func_realloc_0_nonnull="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) ac_cv_func_realloc_0_nonnull="$gl_cross_guess_normal" ;;
33 esac
34 ])
35 ])
36 AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
37])# AC_FUNC_REALLOC
38
39# gl_FUNC_REALLOC_GNU
40# -------------------
41# Replace realloc if it is not compatible with GNU libc.
42AC_DEFUN([gl_FUNC_REALLOC_GNU],
43[
44 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
45 AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
46 if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
47 _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
48 fi
49])# gl_FUNC_REALLOC_GNU
50
51# gl_FUNC_REALLOC_POSIX
52# ---------------------
53# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
54# fails, and doesn't mess up with ptrdiff_t overflow),
55# and replace realloc if it is not.
56AC_DEFUN([gl_FUNC_REALLOC_POSIX],
57[
58 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
59 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
60 if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
61 REPLACE_REALLOC_FOR_REALLOC_POSIX=1
62 fi
63])
diff --git a/gl/m4/reallocarray.m4 b/gl/m4/reallocarray.m4
new file mode 100644
index 0000000..1607b7a
--- /dev/null
+++ b/gl/m4/reallocarray.m4
@@ -0,0 +1,23 @@
1# reallocarray.m4 serial 3
2dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_REALLOCARRAY],
8[
9 dnl Persuade glibc <stdlib.h> to declare reallocarray.
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
13 AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
14 AC_CHECK_FUNCS([reallocarray])
15 if test "$ac_cv_func_reallocarray" = no; then
16 HAVE_REALLOCARRAY=0
17 elif test "$gl_cv_malloc_ptrdiff" = no; then
18 REPLACE_REALLOCARRAY=1
19 fi
20])
21
22# Prerequisites of lib/reallocarray.c.
23AC_DEFUN([gl_PREREQ_REALLOCARRAY], [:])
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4
index 0945c11..c89a143 100644
--- a/gl/m4/regex.m4
+++ b/gl/m4/regex.m4
@@ -1,6 +1,6 @@
1# serial 64 1# serial 73
2 2
3# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc. 3# Copyright (C) 1996-2001, 2003-2023 Free Software Foundation, Inc.
4# 4#
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -13,6 +13,7 @@ AC_PREREQ([2.50])
13 13
14AC_DEFUN([gl_REGEX], 14AC_DEFUN([gl_REGEX],
15[ 15[
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16 AC_ARG_WITH([included-regex], 17 AC_ARG_WITH([included-regex],
17 [AS_HELP_STRING([--without-included-regex], 18 [AS_HELP_STRING([--without-included-regex],
18 [don't compile regex; this is the default on systems 19 [don't compile regex; this is the default on systems
@@ -28,6 +29,7 @@ AC_DEFUN([gl_REGEX],
28 # If cross compiling, assume the test would fail and use the included 29 # If cross compiling, assume the test would fail and use the included
29 # regex.c. 30 # regex.c.
30 AC_CHECK_DECLS_ONCE([alarm]) 31 AC_CHECK_DECLS_ONCE([alarm])
32 AC_CHECK_HEADERS_ONCE([malloc.h])
31 AC_CACHE_CHECK([for working re_compile_pattern], 33 AC_CACHE_CHECK([for working re_compile_pattern],
32 [gl_cv_func_re_compile_pattern_working], 34 [gl_cv_func_re_compile_pattern_working],
33 [AC_RUN_IFELSE( 35 [AC_RUN_IFELSE(
@@ -37,9 +39,19 @@ AC_DEFUN([gl_REGEX],
37 #include <locale.h> 39 #include <locale.h>
38 #include <limits.h> 40 #include <limits.h>
39 #include <string.h> 41 #include <string.h>
40 #if HAVE_DECL_ALARM 42
41 # include <unistd.h> 43 #if defined M_CHECK_ACTION || HAVE_DECL_ALARM
42 # include <signal.h> 44 # include <signal.h>
45 # include <unistd.h>
46 #endif
47
48 #if HAVE_MALLOC_H
49 # include <malloc.h>
50 #endif
51
52 #ifdef M_CHECK_ACTION
53 /* Exit with distinguishable exit code. */
54 static void sigabrt_no_core (int sig) { raise (SIGTERM); }
43 #endif 55 #endif
44 ]], 56 ]],
45 [[int result = 0; 57 [[int result = 0;
@@ -49,15 +61,22 @@ AC_DEFUN([gl_REGEX],
49 const char *s; 61 const char *s;
50 struct re_registers regs; 62 struct re_registers regs;
51 63
64 /* Some builds of glibc go into an infinite loop on this
65 test. Use alarm to force death, and mallopt to avoid
66 malloc recursion in diagnosing the corrupted heap. */
52#if HAVE_DECL_ALARM 67#if HAVE_DECL_ALARM
53 /* Some builds of glibc go into an infinite loop on this test. */
54 signal (SIGALRM, SIG_DFL); 68 signal (SIGALRM, SIG_DFL);
55 alarm (2); 69 alarm (2);
56#endif 70#endif
71#ifdef M_CHECK_ACTION
72 signal (SIGABRT, sigabrt_no_core);
73 mallopt (M_CHECK_ACTION, 2);
74#endif
75
57 if (setlocale (LC_ALL, "en_US.UTF-8")) 76 if (setlocale (LC_ALL, "en_US.UTF-8"))
58 { 77 {
59 { 78 {
60 /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html 79 /* https://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
61 This test needs valgrind to catch the bug on Debian 80 This test needs valgrind to catch the bug on Debian
62 GNU/Linux 3.1 x86, but it might catch the bug better 81 GNU/Linux 3.1 x86, but it might catch the bug better
63 on other platforms and it shouldn't hurt to try the 82 on other platforms and it shouldn't hurt to try the
@@ -71,16 +90,20 @@ AC_DEFUN([gl_REGEX],
71 s = re_compile_pattern (pat, sizeof pat - 1, &regex); 90 s = re_compile_pattern (pat, sizeof pat - 1, &regex);
72 if (s) 91 if (s)
73 result |= 1; 92 result |= 1;
74 else if (re_search (&regex, data, sizeof data - 1, 93 else
75 0, sizeof data - 1, &regs) 94 {
76 != -1) 95 if (re_search (&regex, data, sizeof data - 1,
77 result |= 1; 96 0, sizeof data - 1, &regs)
97 != -1)
98 result |= 1;
99 regfree (&regex);
100 }
78 } 101 }
79 102
80 { 103 {
81 /* This test is from glibc bug 15078. 104 /* This test is from glibc bug 15078.
82 The test case is from Andreas Schwab in 105 The test case is from Andreas Schwab in
83 <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>. 106 <https://sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
84 */ 107 */
85 static char const pat[] = "[^x]x"; 108 static char const pat[] = "[^x]x";
86 static char const data[] = 109 static char const data[] =
@@ -105,6 +128,7 @@ AC_DEFUN([gl_REGEX],
105 0, sizeof data - 1, 0); 128 0, sizeof data - 1, 0);
106 if (i != 0 && i != 21) 129 if (i != 0 && i != 21)
107 result |= 1; 130 result |= 1;
131 regfree (&regex);
108 } 132 }
109 } 133 }
110 134
@@ -118,9 +142,13 @@ AC_DEFUN([gl_REGEX],
118 s = re_compile_pattern ("a[^x]b", 6, &regex); 142 s = re_compile_pattern ("a[^x]b", 6, &regex);
119 if (s) 143 if (s)
120 result |= 2; 144 result |= 2;
121 /* This should fail, but succeeds for glibc-2.5. */ 145 else
122 else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1) 146 {
123 result |= 2; 147 /* This should fail, but succeeds for glibc-2.5. */
148 if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
149 result |= 2;
150 regfree (&regex);
151 }
124 152
125 /* This regular expression is from Spencer ere test number 75 153 /* This regular expression is from Spencer ere test number 75
126 in grep-2.3. */ 154 in grep-2.3. */
@@ -132,7 +160,10 @@ AC_DEFUN([gl_REGEX],
132 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex); 160 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
133 /* This should fail with _Invalid character class name_ error. */ 161 /* This should fail with _Invalid character class name_ error. */
134 if (!s) 162 if (!s)
135 result |= 4; 163 {
164 result |= 4;
165 regfree (&regex);
166 }
136 167
137 /* Ensure that [b-a] is diagnosed as invalid, when 168 /* Ensure that [b-a] is diagnosed as invalid, when
138 using RE_NO_EMPTY_RANGES. */ 169 using RE_NO_EMPTY_RANGES. */
@@ -140,13 +171,18 @@ AC_DEFUN([gl_REGEX],
140 memset (&regex, 0, sizeof regex); 171 memset (&regex, 0, sizeof regex);
141 s = re_compile_pattern ("a[b-a]", 6, &regex); 172 s = re_compile_pattern ("a[b-a]", 6, &regex);
142 if (s == 0) 173 if (s == 0)
143 result |= 8; 174 {
175 result |= 8;
176 regfree (&regex);
177 }
144 178
145 /* This should succeed, but does not for glibc-2.1.3. */ 179 /* This should succeed, but does not for glibc-2.1.3. */
146 memset (&regex, 0, sizeof regex); 180 memset (&regex, 0, sizeof regex);
147 s = re_compile_pattern ("{1", 2, &regex); 181 s = re_compile_pattern ("{1", 2, &regex);
148 if (s) 182 if (s)
149 result |= 8; 183 result |= 8;
184 else
185 regfree (&regex);
150 186
151 /* The following example is derived from a problem report 187 /* The following example is derived from a problem report
152 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ 188 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
@@ -154,17 +190,35 @@ AC_DEFUN([gl_REGEX],
154 s = re_compile_pattern ("[an\371]*n", 7, &regex); 190 s = re_compile_pattern ("[an\371]*n", 7, &regex);
155 if (s) 191 if (s)
156 result |= 8; 192 result |= 8;
157 /* This should match, but does not for glibc-2.2.1. */ 193 else
158 else if (re_match (&regex, "an", 2, 0, &regs) != 2) 194 {
159 result |= 8; 195 /* This should match, but does not for glibc-2.2.1. */
196 if (re_match (&regex, "an", 2, 0, &regs) != 2)
197 result |= 8;
198 else
199 {
200 free (regs.start);
201 free (regs.end);
202 }
203 regfree (&regex);
204 }
160 205
161 memset (&regex, 0, sizeof regex); 206 memset (&regex, 0, sizeof regex);
162 s = re_compile_pattern ("x", 1, &regex); 207 s = re_compile_pattern ("x", 1, &regex);
163 if (s) 208 if (s)
164 result |= 8; 209 result |= 8;
165 /* glibc-2.2.93 does not work with a negative RANGE argument. */ 210 else
166 else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1) 211 {
167 result |= 8; 212 /* glibc-2.2.93 does not work with a negative RANGE argument. */
213 if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
214 result |= 8;
215 else
216 {
217 free (regs.start);
218 free (regs.end);
219 }
220 regfree (&regex);
221 }
168 222
169 /* The version of regex.c in older versions of gnulib 223 /* The version of regex.c in older versions of gnulib
170 ignored RE_ICASE. Detect that problem too. */ 224 ignored RE_ICASE. Detect that problem too. */
@@ -173,25 +227,89 @@ AC_DEFUN([gl_REGEX],
173 s = re_compile_pattern ("x", 1, &regex); 227 s = re_compile_pattern ("x", 1, &regex);
174 if (s) 228 if (s)
175 result |= 16; 229 result |= 16;
176 else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0) 230 else
177 result |= 16; 231 {
232 if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
233 result |= 16;
234 else
235 {
236 free (regs.start);
237 free (regs.end);
238 }
239 regfree (&regex);
240 }
178 241
179 /* Catch a bug reported by Vin Shelton in 242 /* Catch a bug reported by Vin Shelton in
180 http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html 243 https://lists.gnu.org/r/bug-coreutils/2007-06/msg00089.html
181 */ 244 */
182 re_set_syntax (RE_SYNTAX_POSIX_BASIC 245 re_set_syntax (RE_SYNTAX_POSIX_BASIC
183 & ~RE_CONTEXT_INVALID_DUP 246 & ~RE_CONTEXT_INVALID_DUP
184 & ~RE_NO_EMPTY_RANGES); 247 & ~RE_NO_EMPTY_RANGES);
185 memset (&regex, 0, sizeof regex); 248 memset (&regex, 0, sizeof regex);
186 s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex); 249 s = re_compile_pattern ("[[:alnum:]_-]\\\\+\$", 16, &regex);
187 if (s) 250 if (s)
188 result |= 32; 251 result |= 32;
252 else
253 regfree (&regex);
189 254
190 /* REG_STARTEND was added to glibc on 2004-01-15. 255 /* REG_STARTEND was added to glibc on 2004-01-15.
191 Reject older versions. */ 256 Reject older versions. */
192 if (! REG_STARTEND) 257 if (! REG_STARTEND)
193 result |= 64; 258 result |= 64;
194 259
260 /* Matching with the compiled form of this regexp would provoke
261 an assertion failure prior to glibc-2.28:
262 regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed
263 With glibc-2.28, compilation fails and reports the invalid
264 back reference. */
265 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
266 memset (&regex, 0, sizeof regex);
267 s = re_compile_pattern ("0|()0|\\\\1|0", 10, &regex);
268 if (!s)
269 {
270 memset (&regs, 0, sizeof regs);
271 i = re_search (&regex, "x", 1, 0, 1, &regs);
272 if (i != -1)
273 result |= 64;
274 if (0 <= i)
275 {
276 free (regs.start);
277 free (regs.end);
278 }
279 regfree (&regex);
280 }
281 else
282 {
283 if (strcmp (s, "Invalid back reference"))
284 result |= 64;
285 }
286
287 /* glibc bug 11053. */
288 re_set_syntax (RE_SYNTAX_POSIX_BASIC);
289 memset (&regex, 0, sizeof regex);
290 static char const pat_sub2[] = "\\\\(a*\\\\)*a*\\\\1";
291 s = re_compile_pattern (pat_sub2, sizeof pat_sub2 - 1, &regex);
292 if (s)
293 result |= 64;
294 else
295 {
296 memset (&regs, 0, sizeof regs);
297 static char const data[] = "a";
298 int datalen = sizeof data - 1;
299 i = re_search (&regex, data, datalen, 0, datalen, &regs);
300 if (i != 0)
301 result |= 64;
302 else if (regs.num_regs < 2)
303 result |= 64;
304 else if (! (regs.start[0] == 0 && regs.end[0] == 1))
305 result |= 64;
306 else if (! (regs.start[1] == 0 && regs.end[1] == 0))
307 result |= 64;
308 regfree (&regex);
309 free (regs.start);
310 free (regs.end);
311 }
312
195#if 0 313#if 0
196 /* It would be nice to reject hosts whose regoff_t values are too 314 /* It would be nice to reject hosts whose regoff_t values are too
197 narrow (including glibc on hosts with 64-bit ptrdiff_t and 315 narrow (including glibc on hosts with 64-bit ptrdiff_t and
@@ -206,13 +324,19 @@ AC_DEFUN([gl_REGEX],
206 324
207 return result; 325 return result;
208 ]])], 326 ]])],
209 [gl_cv_func_re_compile_pattern_working=yes], 327 [gl_cv_func_re_compile_pattern_working=yes],
210 [gl_cv_func_re_compile_pattern_working=no], 328 [gl_cv_func_re_compile_pattern_working=no],
211 dnl When crosscompiling, assume it is not working. 329 [case "$host_os" in
212 [gl_cv_func_re_compile_pattern_working=no])]) 330 # Guess no on native Windows.
213 case $gl_cv_func_re_compile_pattern_working in #( 331 mingw*) gl_cv_func_re_compile_pattern_working="guessing no" ;;
214 yes) ac_use_included_regex=no;; #( 332 # Otherwise obey --enable-cross-guesses.
215 no) ac_use_included_regex=yes;; 333 *) gl_cv_func_re_compile_pattern_working="$gl_cross_guess_normal" ;;
334 esac
335 ])
336 ])
337 case "$gl_cv_func_re_compile_pattern_working" in #(
338 *yes) ac_use_included_regex=no;; #(
339 *no) ac_use_included_regex=yes;;
216 esac 340 esac
217 ;; 341 ;;
218 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex]) 342 *) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
@@ -266,8 +390,7 @@ AC_DEFUN([gl_PREREQ_REGEX],
266 AC_REQUIRE([AC_C_RESTRICT]) 390 AC_REQUIRE([AC_C_RESTRICT])
267 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 391 AC_REQUIRE([AC_TYPE_MBSTATE_T])
268 AC_REQUIRE([gl_EEMALLOC]) 392 AC_REQUIRE([gl_EEMALLOC])
269 AC_REQUIRE([gl_GLIBC21])
270 AC_CHECK_HEADERS([libintl.h]) 393 AC_CHECK_HEADERS([libintl.h])
271 AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll]) 394 AC_CHECK_FUNCS_ONCE([isblank iswctype])
272 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]]) 395 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
273]) 396])
diff --git a/gl/m4/safe-read.m4 b/gl/m4/safe-read.m4
deleted file mode 100644
index be5207a..0000000
--- a/gl/m4/safe-read.m4
+++ /dev/null
@@ -1,12 +0,0 @@
1# safe-read.m4 serial 6
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Prerequisites of lib/safe-read.c.
9AC_DEFUN([gl_PREREQ_SAFE_READ],
10[
11 AC_REQUIRE([gt_TYPE_SSIZE_T])
12])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
index 01c037a..0f35b8b 100644
--- a/gl/m4/servent.m4
+++ b/gl/m4/servent.m4
@@ -1,5 +1,5 @@
1# servent.m4 serial 2 1# servent.m4 serial 4
2dnl Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,12 +10,12 @@ AC_DEFUN([gl_SERVENT],
10 dnl getservbyport() defined? 10 dnl getservbyport() defined?
11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(), 11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
12 dnl getprotobynumber() defined? 12 dnl getprotobynumber() defined?
13 dnl - On Solaris, they are in libsocket. Ignore libxnet. 13 dnl - On Solaris < 11.4, they are in libsocket. Ignore libxnet.
14 dnl - On Haiku, they are in libnetwork. 14 dnl - On Haiku, they are in libnetwork.
15 dnl - On BeOS, they are in libnet. 15 dnl - On BeOS, they are in libnet.
16 dnl - On native Windows, they are in ws2_32.dll. 16 dnl - On native Windows, they are in ws2_32.dll.
17 dnl - Otherwise they are in libc. 17 dnl - Otherwise they are in libc.
18 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 18 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
19 SERVENT_LIB= 19 SERVENT_LIB=
20 gl_saved_libs="$LIBS" 20 gl_saved_libs="$LIBS"
21 AC_SEARCH_LIBS([getservbyname], [socket network net], 21 AC_SEARCH_LIBS([getservbyname], [socket network net],
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index cb5351a..16f9eb5 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,5 +1,5 @@
1# setenv.m4 serial 26 1# setenv.m4 serial 30
2dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -35,10 +35,12 @@ AC_DEFUN([gl_FUNC_SETENV],
35 ]])], 35 ]])],
36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], 36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
37 [case "$host_os" in 37 [case "$host_os" in
38 # Guess yes on glibc systems. 38 # Guess yes on glibc systems.
39 *-gnu*) gl_cv_func_setenv_works="guessing yes" ;; 39 *-gnu* | gnu*) gl_cv_func_setenv_works="guessing yes" ;;
40 # If we don't know, assume the worst. 40 # Guess yes on musl systems.
41 *) gl_cv_func_setenv_works="guessing no" ;; 41 *-musl*) gl_cv_func_setenv_works="guessing yes" ;;
42 # If we don't know, obey --enable-cross-guesses.
43 *) gl_cv_func_setenv_works="$gl_cross_guess_normal" ;;
42 esac 44 esac
43 ])]) 45 ])])
44 case "$gl_cv_func_setenv_works" in 46 case "$gl_cv_func_setenv_works" in
@@ -104,35 +106,39 @@ int unsetenv (const char *name);
104 dnl OpenBSD 4.7 unsetenv("") does not fail. 106 dnl OpenBSD 4.7 unsetenv("") does not fail.
105 AC_CACHE_CHECK([whether unsetenv obeys POSIX], 107 AC_CACHE_CHECK([whether unsetenv obeys POSIX],
106 [gl_cv_func_unsetenv_works], 108 [gl_cv_func_unsetenv_works],
107 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 109 [AC_RUN_IFELSE(
108 #include <stdlib.h> 110 [AC_LANG_PROGRAM([[
109 #include <errno.h> 111 #include <stdlib.h>
110 extern char **environ; 112 #include <errno.h>
111 ]], [[ 113 extern char **environ;
112 char entry1[] = "a=1"; 114 ]GL_MDA_DEFINES],
113 char entry2[] = "b=2"; 115 [[
114 char *env[] = { entry1, entry2, NULL }; 116 char entry1[] = "a=1";
115 if (putenv ((char *) "a=1")) return 1; 117 char entry2[] = "b=2";
116 if (putenv (entry2)) return 2; 118 char *env[] = { entry1, entry2, NULL };
117 entry2[0] = 'a'; 119 if (putenv ((char *) "a=1")) return 1;
118 unsetenv ("a"); 120 if (putenv (entry2)) return 2;
119 if (getenv ("a")) return 3; 121 entry2[0] = 'a';
120 if (!unsetenv ("") || errno != EINVAL) return 4; 122 unsetenv ("a");
121 entry2[0] = 'b'; 123 if (getenv ("a")) return 3;
122 environ = env; 124 if (!unsetenv ("") || errno != EINVAL) return 4;
123 if (!getenv ("a")) return 5; 125 entry2[0] = 'b';
124 entry2[0] = 'a'; 126 environ = env;
125 unsetenv ("a"); 127 if (!getenv ("a")) return 5;
126 if (getenv ("a")) return 6; 128 entry2[0] = 'a';
127 ]])], 129 unsetenv ("a");
128 [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], 130 if (getenv ("a")) return 6;
129 [case "$host_os" in 131 ]])],
130 # Guess yes on glibc systems. 132 [gl_cv_func_unsetenv_works=yes],
131 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;; 133 [gl_cv_func_unsetenv_works=no],
132 # If we don't know, assume the worst. 134 [case "$host_os" in
133 *) gl_cv_func_unsetenv_works="guessing no" ;; 135 # Guess yes on glibc systems.
134 esac 136 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
135 ])]) 137 # If we don't know, obey --enable-cross-guesses.
138 *) gl_cv_func_unsetenv_works="$gl_cross_guess_normal" ;;
139 esac
140 ])
141 ])
136 case "$gl_cv_func_unsetenv_works" in 142 case "$gl_cv_func_unsetenv_works" in
137 *yes) ;; 143 *yes) ;;
138 *) 144 *)
diff --git a/gl/m4/setlocale_null.m4 b/gl/m4/setlocale_null.m4
new file mode 100644
index 0000000..032119d
--- /dev/null
+++ b/gl/m4/setlocale_null.m4
@@ -0,0 +1,98 @@
1# setlocale_null.m4 serial 5
2dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_REQUIRE([gl_PTHREADLIB])
11 AC_CHECK_HEADERS_ONCE([threads.h])
12
13 AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe],
14 [gl_cv_func_setlocale_null_all_mtsafe],
15 [case "$host_os" in
16 # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
17 *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*)
18 gl_cv_func_setlocale_null_all_mtsafe=no ;;
19 # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows.
20 *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*)
21 gl_cv_func_setlocale_null_all_mtsafe=yes ;;
22 # If we don't know, obey --enable-cross-guesses.
23 *)
24 gl_cv_func_setlocale_null_all_mtsafe="$gl_cross_guess_normal" ;;
25 esac
26 ])
27 dnl On platforms without multithreading, there is no issue.
28 case "$host_os" in
29 mingw*) ;;
30 *)
31 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
32 gl_cv_func_setlocale_null_all_mtsafe="trivially yes"
33 fi
34 ;;
35 esac
36 case "$gl_cv_func_setlocale_null_all_mtsafe" in
37 *yes) SETLOCALE_NULL_ALL_MTSAFE=1 ;;
38 *) SETLOCALE_NULL_ALL_MTSAFE=0 ;;
39 esac
40 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ALL_MTSAFE], [$SETLOCALE_NULL_ALL_MTSAFE],
41 [Define to 1 if setlocale (LC_ALL, NULL) is multithread-safe.])
42
43 dnl This is about a single category (not LC_ALL).
44 AC_CACHE_CHECK([whether setlocale (category, NULL) is multithread-safe],
45 [gl_cv_func_setlocale_null_one_mtsafe],
46 [case "$host_os" in
47 # Guess no on OpenBSD, AIX.
48 openbsd* | aix*)
49 gl_cv_func_setlocale_null_one_mtsafe=no ;;
50 # Guess yes on glibc, musl libc, macOS, FreeBSD, NetBSD, HP-UX, IRIX, Solaris, Haiku, Cygwin, native Windows.
51 *-gnu* | gnu* | *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | hpux* | irix* | solaris* | haiku* | cygwin* | mingw*)
52 gl_cv_func_setlocale_null_one_mtsafe=yes ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *)
55 gl_cv_func_setlocale_null_one_mtsafe="$gl_cross_guess_normal" ;;
56 esac
57 ])
58 dnl On platforms without multithreading, there is no issue.
59 case "$host_os" in
60 mingw*) ;;
61 *)
62 if test $gl_pthread_api = no && test $ac_cv_header_threads_h = no; then
63 gl_cv_func_setlocale_null_one_mtsafe="trivially yes"
64 fi
65 ;;
66 esac
67 case "$gl_cv_func_setlocale_null_one_mtsafe" in
68 *yes) SETLOCALE_NULL_ONE_MTSAFE=1 ;;
69 *) SETLOCALE_NULL_ONE_MTSAFE=0 ;;
70 esac
71 AC_DEFINE_UNQUOTED([SETLOCALE_NULL_ONE_MTSAFE], [$SETLOCALE_NULL_ONE_MTSAFE],
72 [Define to 1 if setlocale (category, NULL) is multithread-safe.])
73
74 dnl Determine link dependencies of lib/setlocale_null.c and lib/setlocale-lock.c.
75 if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0; then
76 case "$host_os" in
77 mingw*) LIB_SETLOCALE_NULL= ;;
78 *)
79 gl_WEAK_SYMBOLS
80 case "$gl_cv_have_weak" in
81 *yes) LIB_SETLOCALE_NULL= ;;
82 *) LIB_SETLOCALE_NULL="$LIBPTHREAD" ;;
83 esac
84 ;;
85 esac
86 else
87 LIB_SETLOCALE_NULL=
88 fi
89 dnl LIB_SETLOCALE_NULL is expected to be '-pthread' or '-lpthread' on AIX
90 dnl with gcc or xlc, and empty otherwise.
91 AC_SUBST([LIB_SETLOCALE_NULL])
92])
93
94# Prerequisites of lib/setlocale-lock.c.
95AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK],
96[
97 gl_VISIBILITY
98])
diff --git a/gl/m4/sha256.m4 b/gl/m4/sha256.m4
new file mode 100644
index 0000000..4d1d1dd
--- /dev/null
+++ b/gl/m4/sha256.m4
@@ -0,0 +1,14 @@
1# sha256.m4 serial 8
2dnl Copyright (C) 2005, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SHA256],
8[
9 dnl Prerequisites of lib/sha256.c.
10 AC_REQUIRE([gl_BIGENDIAN])
11
12 dnl Determine HAVE_OPENSSL_SHA256 and LIB_CRYPTO
13 gl_CRYPTO_CHECK([SHA256])
14])
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index 4b247ab..0763366 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,17 +1,19 @@
1# size_max.m4 serial 10 1# size_max.m4 serial 12
2dnl Copyright (C) 2003, 2005-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.61])
10
9AC_DEFUN([gl_SIZE_MAX], 11AC_DEFUN([gl_SIZE_MAX],
10[ 12[
11 AC_CHECK_HEADERS([stdint.h]) 13 AC_CHECK_HEADERS([stdint.h])
12 dnl First test whether the system already has SIZE_MAX. 14 dnl First test whether the system already has SIZE_MAX.
13 AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [ 15 AC_CACHE_CHECK([for SIZE_MAX], [gl_cv_size_max], [
14 gl_cv_size_max= 16 gl_cv_size_max=no
15 AC_EGREP_CPP([Found it], [ 17 AC_EGREP_CPP([Found it], [
16#include <limits.h> 18#include <limits.h>
17#if HAVE_STDINT_H 19#if HAVE_STDINT_H
@@ -21,7 +23,7 @@ AC_DEFUN([gl_SIZE_MAX],
21Found it 23Found it
22#endif 24#endif
23], [gl_cv_size_max=yes]) 25], [gl_cv_size_max=yes])
24 if test -z "$gl_cv_size_max"; then 26 if test $gl_cv_size_max != yes; then
25 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider 27 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
26 dnl than the type 'unsigned long'. Try hard to find a definition that can 28 dnl than the type 'unsigned long'. Try hard to find a definition that can
27 dnl be used in a preprocessor #if, i.e. doesn't contain a cast. 29 dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
@@ -71,9 +73,3 @@ Found it
71# undef SIZE_MAX 73# undef SIZE_MAX
72#endif]) 74#endif])
73]) 75])
74
75dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
76dnl Remove this when we can assume autoconf >= 2.61.
77m4_ifdef([AC_COMPUTE_INT], [], [
78 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
79])
diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4
index 3698e84..4b5fbdb 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,5 +1,5 @@
1# snprintf.m4 serial 6 1# snprintf.m4 serial 7
2dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,14 @@ AC_DEFUN([gl_REPLACE_SNPRINTF],
46 AC_LIBOBJ([snprintf]) 46 AC_LIBOBJ([snprintf])
47 if test $ac_cv_func_snprintf = yes; then 47 if test $ac_cv_func_snprintf = yes; then
48 REPLACE_SNPRINTF=1 48 REPLACE_SNPRINTF=1
49 else
50 AC_CHECK_DECLS_ONCE([snprintf])
51 if test $ac_cv_have_decl_snprintf = yes; then
52 dnl If the function is declared but does not appear to exist, it may be
53 dnl defined as an inline function. In order to avoid a conflict, we have
54 dnl to define rpl_snprintf, not snprintf.
55 REPLACE_SNPRINTF=1
56 fi
49 fi 57 fi
50 gl_PREREQ_SNPRINTF 58 gl_PREREQ_SNPRINTF
51]) 59])
diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4
index b08a72f..a556af1 100644
--- a/gl/m4/socketlib.m4
+++ b/gl/m4/socketlib.m4
@@ -1,5 +1,5 @@
1# socketlib.m4 serial 1 1# socketlib.m4 serial 3
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,21 +14,27 @@ AC_DEFUN([gl_SOCKETLIB],
14 LIBSOCKET= 14 LIBSOCKET=
15 if test $HAVE_WINSOCK2_H = 1; then 15 if test $HAVE_WINSOCK2_H = 1; then
16 dnl Native Windows API (not Cygwin). 16 dnl Native Windows API (not Cygwin).
17 AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], 17 dnl If the function WSAStartup exists (declared in <winsock2.h> and
18 [gl_cv_func_wsastartup], [ 18 dnl defined through -lws2_32), we need to call it.
19 gl_save_LIBS="$LIBS" 19 AC_CACHE_CHECK([for WSAStartup],
20 LIBS="$LIBS -lws2_32" 20 [gl_cv_func_wsastartup], [
21 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 21 gl_save_LIBS="$LIBS"
22 LIBS="$LIBS -lws2_32"
23 AC_LINK_IFELSE(
24 [AC_LANG_PROGRAM([[
22#ifdef HAVE_WINSOCK2_H 25#ifdef HAVE_WINSOCK2_H
23# include <winsock2.h> 26# include <winsock2.h>
24#endif]], [[ 27#endif]], [[
25 WORD wVersionRequested = MAKEWORD(1, 1); 28 WORD wVersionRequested = MAKEWORD(1, 1);
26 WSADATA wsaData; 29 WSADATA wsaData;
27 int err = WSAStartup(wVersionRequested, &wsaData); 30 int err = WSAStartup(wVersionRequested, &wsaData);
28 WSACleanup ();]])], 31 WSACleanup ();
29 gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) 32 ]])
30 LIBS="$gl_save_LIBS" 33 ],
31 ]) 34 [gl_cv_func_wsastartup=yes],
35 [gl_cv_func_wsastartup=no])
36 LIBS="$gl_save_LIBS"
37 ])
32 if test "$gl_cv_func_wsastartup" = "yes"; then 38 if test "$gl_cv_func_wsastartup" = "yes"; then
33 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) 39 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
34 LIBSOCKET='-lws2_32' 40 LIBSOCKET='-lws2_32'
@@ -38,6 +44,10 @@ AC_DEFUN([gl_SOCKETLIB],
38 dnl Solaris has most socket functions in libsocket. 44 dnl Solaris has most socket functions in libsocket.
39 dnl Haiku has most socket functions in libnetwork. 45 dnl Haiku has most socket functions in libnetwork.
40 dnl BeOS has most socket functions in libnet. 46 dnl BeOS has most socket functions in libnet.
47 dnl On HP-UX, do NOT link with libxnet, because in 64-bit mode this would
48 dnl break code (e.g. in libraries) that invokes accept(), getpeername(),
49 dnl getsockname(), getsockopt(), or recvfrom() with a 32-bit addrlen. See
50 dnl "man xopen_networking" for details.
41 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ 51 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
42 gl_cv_lib_socket= 52 gl_cv_lib_socket=
43 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern 53 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4
index b407391..ed9cb87 100644
--- a/gl/m4/sockets.m4
+++ b/gl/m4/sockets.m4
@@ -1,5 +1,5 @@
1# sockets.m4 serial 7 1# sockets.m4 serial 7
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index e3efd6e..1c63a85 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
1# socklen.m4 serial 10 1# socklen.m4 serial 11
2dnl Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,8 +15,8 @@ dnl So we have to test to find something that will work.
15AC_DEFUN([gl_TYPE_SOCKLEN_T], 15AC_DEFUN([gl_TYPE_SOCKLEN_T],
16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl 16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
17 AC_CHECK_TYPE([socklen_t], , 17 AC_CHECK_TYPE([socklen_t], ,
18 [AC_MSG_CHECKING([for socklen_t equivalent]) 18 [AC_CACHE_CHECK([for socklen_t equivalent],
19 AC_CACHE_VAL([gl_cv_socklen_t_equiv], 19 [gl_cv_socklen_t_equiv],
20 [# Systems have either "struct sockaddr *" or 20 [# Systems have either "struct sockaddr *" or
21 # "void *" as the second argument to getpeername 21 # "void *" as the second argument to getpeername
22 gl_cv_socklen_t_equiv= 22 gl_cv_socklen_t_equiv=
@@ -34,11 +34,10 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
34 done 34 done
35 test "$gl_cv_socklen_t_equiv" != "" && break 35 test "$gl_cv_socklen_t_equiv" != "" && break
36 done 36 done
37 ]) 37 if test "$gl_cv_socklen_t_equiv" = ""; then
38 if test "$gl_cv_socklen_t_equiv" = ""; then 38 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
39 AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) 39 fi
40 fi 40 ])
41 AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
42 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], 41 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
43 [type to use in place of socklen_t if not defined])], 42 [type to use in place of socklen_t if not defined])],
44 [gl_SOCKET_HEADERS])]) 43 [gl_SOCKET_HEADERS])])
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 89557b1..6c6dc2f 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
1# sockpfaf.m4 serial 8 1# sockpfaf.m4 serial 10
2dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,11 +13,11 @@ dnl From Bruno Haible.
13 13
14AC_DEFUN([gl_SOCKET_FAMILIES], 14AC_DEFUN([gl_SOCKET_FAMILIES],
15[ 15[
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 16 AC_REQUIRE([gl_SYS_SOCKET_H])
17 AC_CHECK_HEADERS_ONCE([netinet/in.h]) 17 AC_CHECK_HEADERS_ONCE([netinet/in.h])
18 18
19 AC_MSG_CHECKING([for IPv4 sockets]) 19 AC_CACHE_CHECK([for IPv4 sockets],
20 AC_CACHE_VAL([gl_cv_socket_ipv4], 20 [gl_cv_socket_ipv4],
21 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 21 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
22#ifdef HAVE_SYS_SOCKET_H 22#ifdef HAVE_SYS_SOCKET_H
23#include <sys/socket.h> 23#include <sys/socket.h>
@@ -31,13 +31,12 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
31[[int x = AF_INET; struct in_addr y; struct sockaddr_in z; 31[[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
32 if (&x && &y && &z) return 0;]])], 32 if (&x && &y && &z) return 0;]])],
33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)]) 33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
34 AC_MSG_RESULT([$gl_cv_socket_ipv4])
35 if test $gl_cv_socket_ipv4 = yes; then 34 if test $gl_cv_socket_ipv4 = yes; then
36 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.]) 35 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
37 fi 36 fi
38 37
39 AC_MSG_CHECKING([for IPv6 sockets]) 38 AC_CACHE_CHECK([for IPv6 sockets],
40 AC_CACHE_VAL([gl_cv_socket_ipv6], 39 [gl_cv_socket_ipv6],
41 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 40 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
42#ifdef HAVE_SYS_SOCKET_H 41#ifdef HAVE_SYS_SOCKET_H
43#include <sys/socket.h> 42#include <sys/socket.h>
@@ -54,7 +53,6 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
54[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; 53[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
55 if (&x && &y && &z) return 0;]])], 54 if (&x && &y && &z) return 0;]])],
56 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)]) 55 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
57 AC_MSG_RESULT([$gl_cv_socket_ipv6])
58 if test $gl_cv_socket_ipv6 = yes; then 56 if test $gl_cv_socket_ipv6 = yes; then
59 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.]) 57 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
60 fi 58 fi
@@ -62,11 +60,11 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
62 60
63AC_DEFUN([gl_SOCKET_FAMILY_UNIX], 61AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
64[ 62[
65 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 63 AC_REQUIRE([gl_SYS_SOCKET_H])
66 AC_CHECK_HEADERS_ONCE([sys/un.h]) 64 AC_CHECK_HEADERS_ONCE([sys/un.h])
67 65
68 AC_MSG_CHECKING([for UNIX domain sockets]) 66 AC_CACHE_CHECK([for UNIX domain sockets],
69 AC_CACHE_VAL([gl_cv_socket_unix], 67 [gl_cv_socket_unix],
70 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 68 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
71#ifdef HAVE_SYS_SOCKET_H 69#ifdef HAVE_SYS_SOCKET_H
72#include <sys/socket.h> 70#include <sys/socket.h>
@@ -80,7 +78,6 @@ AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
80[[int x = AF_UNIX; struct sockaddr_un y; 78[[int x = AF_UNIX; struct sockaddr_un y;
81 if (&x && &y) return 0;]])], 79 if (&x && &y) return 0;]])],
82 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)]) 80 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
83 AC_MSG_RESULT([$gl_cv_socket_unix])
84 if test $gl_cv_socket_unix = yes; then 81 if test $gl_cv_socket_unix = yes; then
85 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.]) 82 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
86 fi 83 fi
diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4
index 6338134..1c12c33 100644
--- a/gl/m4/ssize_t.m4
+++ b/gl/m4/ssize_t.m4
@@ -1,5 +1,5 @@
1# ssize_t.m4 serial 5 (gettext-0.18.2) 1# ssize_t.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2001-2003, 2006, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2003, 2006, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/stat-time.m4 b/gl/m4/stat-time.m4
new file mode 100644
index 0000000..40993d5
--- /dev/null
+++ b/gl/m4/stat-time.m4
@@ -0,0 +1,83 @@
1# Checks for stat-related time functions.
2
3# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2023 Free Software
4# Foundation, Inc.
5
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Paul Eggert.
11
12# st_atim.tv_nsec - Linux, Solaris, Cygwin
13# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE
14# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE
15# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1)
16
17# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway)
18# st_birthtim - Cygwin 1.7.0+
19
20AC_DEFUN([gl_STAT_TIME],
21[
22 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
23 AC_CHECK_HEADERS_ONCE([sys/time.h])
24
25 AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec],
26 [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
27 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec],
28 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
29 [[
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #if HAVE_SYS_TIME_H
33 # include <sys/time.h>
34 #endif
35 #include <time.h>
36 struct timespec ts;
37 struct stat st;
38 ]],
39 [[
40 st.st_atim = ts;
41 ]])],
42 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes],
43 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no])])
44 if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
45 AC_DEFINE([TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC], [1],
46 [Define to 1 if the type of the st_atim member of a struct stat is
47 struct timespec.])
48 fi],
49 [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [],
50 [AC_CHECK_MEMBERS([struct stat.st_atimensec], [],
51 [AC_CHECK_MEMBERS([struct stat.st_atim.st__tim.tv_nsec], [], [],
52 [#include <sys/types.h>
53 #include <sys/stat.h>])],
54 [#include <sys/types.h>
55 #include <sys/stat.h>])],
56 [#include <sys/types.h>
57 #include <sys/stat.h>])],
58 [#include <sys/types.h>
59 #include <sys/stat.h>])
60])
61
62# Check for st_birthtime, a feature from UFS2 (FreeBSD, NetBSD, OpenBSD, etc.)
63# and NTFS (Cygwin).
64# There was a time when this field was named st_createtime (21 June
65# 2002 to 16 July 2002) But that window is very small and applied only
66# to development code, so systems still using that configuration are
67# not supported. See revisions 1.10 and 1.11 of FreeBSD's
68# src/sys/ufs/ufs/dinode.h.
69#
70AC_DEFUN([gl_STAT_BIRTHTIME],
71[
72 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
73 AC_CHECK_HEADERS_ONCE([sys/time.h])
74 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [],
75 [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [],
76 [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [],
77 [#include <sys/types.h>
78 #include <sys/stat.h>])],
79 [#include <sys/types.h>
80 #include <sys/stat.h>])],
81 [#include <sys/types.h>
82 #include <sys/stat.h>])
83])
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
new file mode 100644
index 0000000..4d241e2
--- /dev/null
+++ b/gl/m4/stat.m4
@@ -0,0 +1,85 @@
1# serial 18
2
3# Copyright (C) 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9AC_DEFUN([gl_FUNC_STAT],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13 AC_CHECK_FUNCS_ONCE([lstat])
14 case "$host_os" in
15 mingw*)
16 dnl On this platform, the original stat() returns st_atime, st_mtime,
17 dnl st_ctime values that are affected by the time zone.
18 REPLACE_STAT=1
19 ;;
20 *)
21 dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
22 dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
23 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
24 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
25 [gl_cv_func_stat_file_slash],
26 [touch conftest.tmp
27 # Assume that if we have lstat, we can also check symlinks.
28 if test $ac_cv_func_lstat = yes; then
29 ln -s conftest.tmp conftest.lnk
30 fi
31 AC_RUN_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[#include <sys/stat.h>
34]], [[int result = 0;
35 struct stat st;
36 if (!stat ("conftest.tmp/", &st))
37 result |= 1;
38#if HAVE_LSTAT
39 if (!stat ("conftest.lnk/", &st))
40 result |= 2;
41#endif
42 return result;
43 ]])],
44 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
45 [case "$host_os" in
46 # Guess yes on Linux systems.
47 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
48 # Guess yes on glibc systems.
49 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
50 # If we don't know, obey --enable-cross-guesses.
51 *) gl_cv_func_stat_file_slash="$gl_cross_guess_normal" ;;
52 esac
53 ])
54 rm -f conftest.tmp conftest.lnk])
55 case $gl_cv_func_stat_file_slash in
56 *no)
57 REPLACE_STAT=1
58 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
59 help when passed a file name with a trailing slash]);;
60 esac
61 case $host_os in
62 dnl Solaris stat can return a negative tv_nsec.
63 solaris*)
64 REPLACE_FSTAT=1 ;;
65 esac
66 ;;
67 esac
68])
69
70# Prerequisites of lib/stat.c and lib/stat-w32.c.
71AC_DEFUN([gl_PREREQ_STAT], [
72 AC_REQUIRE([gl_SYS_STAT_H])
73 AC_REQUIRE([gl_PREREQ_STAT_W32])
74 :
75])
76
77# Prerequisites of lib/stat-w32.c.
78AC_DEFUN([gl_PREREQ_STAT_W32], [
79 AC_REQUIRE([AC_CANONICAL_HOST])
80 case "$host_os" in
81 mingw*)
82 AC_CHECK_HEADERS([sdkddkver.h])
83 ;;
84 esac
85])
diff --git a/gl/m4/std-gnu11.m4 b/gl/m4/std-gnu11.m4
new file mode 100644
index 0000000..4179470
--- /dev/null
+++ b/gl/m4/std-gnu11.m4
@@ -0,0 +1,829 @@
1# Prefer GNU C11 and C++11 to earlier versions. -*- coding: utf-8 -*-
2
3# This implementation is taken from GNU Autoconf lib/autoconf/c.m4
4# commit 017d5ddd82854911f0119691d91ea8a1438824d6
5# dated Sun Apr 3 13:57:17 2016 -0700
6# This implementation will be obsolete once we can assume Autoconf 2.70
7# or later is installed everywhere a Gnulib program might be developed.
8
9m4_version_prereq([2.70], [], [
10
11
12# Copyright (C) 2001-2023 Free Software Foundation, Inc.
13
14# This program is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, either version 3 of the License, or
17# (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program. If not, see <https://www.gnu.org/licenses/>.
26
27# Written by David MacKenzie, with help from
28# Akim Demaille, Paul Eggert,
29# François Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
30# Roland McGrath, Noah Friedman, david d zuhn, and many others.
31
32
33# AC_PROG_CC([COMPILER ...])
34# --------------------------
35# COMPILER ... is a space separated list of C compilers to search for.
36# This just gives the user an opportunity to specify an alternative
37# search list for the C compiler.
38AC_DEFUN_ONCE([AC_PROG_CC],
39[AC_LANG_PUSH(C)dnl
40AC_ARG_VAR([CC], [C compiler command])dnl
41AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
42_AC_ARG_VAR_LDFLAGS()dnl
43_AC_ARG_VAR_LIBS()dnl
44_AC_ARG_VAR_CPPFLAGS()dnl
45m4_ifval([$1],
46 [AC_CHECK_TOOLS(CC, [$1])],
47[AC_CHECK_TOOL(CC, gcc)
48if test -z "$CC"; then
49 dnl Here we want:
50 dnl AC_CHECK_TOOL(CC, cc)
51 dnl but without the check for a tool without the prefix.
52 dnl Until the check is removed from there, copy the code:
53 if test -n "$ac_tool_prefix"; then
54 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
55 fi
56fi
57if test -z "$CC"; then
58 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
59fi
60if test -z "$CC"; then
61 AC_CHECK_TOOLS(CC, cl.exe)
62fi
63if test -z "$CC"; then
64 AC_CHECK_TOOL(CC, clang)
65fi
66])
67
68test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
69
70# Provide some information about the compiler.
71_AS_ECHO_LOG([checking for _AC_LANG compiler version])
72set X $ac_compile
73ac_compiler=$[2]
74for ac_option in --version -v -V -qversion -version; do
75 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
76done
77
78m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
79m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
80_AC_LANG_COMPILER_GNU
81if test $ac_compiler_gnu = yes; then
82 GCC=yes
83else
84 GCC=
85fi
86_AC_PROG_CC_G
87dnl
88dnl Set ac_prog_cc_stdc to the supported C version.
89dnl Also set the documented variable ac_cv_prog_cc_stdc;
90dnl its name was chosen when it was cached, but it is no longer cached.
91_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
92 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
93 [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
94 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
95 [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
96 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
97 [ac_prog_cc_stdc=no
98 ac_cv_prog_cc_stdc=no])])])
99dnl
100AC_LANG_POP(C)dnl
101])# AC_PROG_CC
102
103
104
105# AC_PROG_CXX([LIST-OF-COMPILERS])
106# --------------------------------
107# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
108# for (if not specified, a default list is used). This just gives the
109# user an opportunity to specify an alternative search list for the C++
110# compiler.
111# aCC HP-UX C++ compiler much better than `CC', so test before.
112# FCC Fujitsu C++ compiler
113# KCC KAI C++ compiler
114# RCC Rational C++
115# xlC_r AIX C Set++ (with support for reentrant code)
116# xlC AIX C Set++
117AC_DEFUN([AC_PROG_CXX],
118[AC_LANG_PUSH(C++)dnl
119AC_ARG_VAR([CXX], [C++ compiler command])dnl
120AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
121_AC_ARG_VAR_LDFLAGS()dnl
122_AC_ARG_VAR_LIBS()dnl
123_AC_ARG_VAR_CPPFLAGS()dnl
124_AC_ARG_VAR_PRECIOUS([CCC])dnl
125if test -z "$CXX"; then
126 if test -n "$CCC"; then
127 CXX=$CCC
128 else
129 AC_CHECK_TOOLS(CXX,
130 [m4_default([$1],
131 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
132 g++)
133 fi
134fi
135# Provide some information about the compiler.
136_AS_ECHO_LOG([checking for _AC_LANG compiler version])
137set X $ac_compile
138ac_compiler=$[2]
139for ac_option in --version -v -V -qversion; do
140 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
141done
142
143m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
144m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
145_AC_LANG_COMPILER_GNU
146if test $ac_compiler_gnu = yes; then
147 GXX=yes
148else
149 GXX=
150fi
151_AC_PROG_CXX_G
152_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
153 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11
154 ac_cv_prog_cxx_cxx98=$ac_cv_prog_cxx_cxx11],
155 [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=cxx98
156 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
157 [ac_prog_cxx_stdcxx=no
158 ac_cv_prog_cxx_stdcxx=no])])
159AC_LANG_POP(C++)dnl
160])# AC_PROG_CXX
161
162
163# _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
164# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
165# --------------------------------------------------------------
166# Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
167# by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
168# try again with each compiler option in the space-separated OPTION-LIST; if one
169# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
170# else ACTION-IF-UNAVAILABLE.
171AC_DEFUN([_AC_C_STD_TRY],
172[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
173AC_CACHE_VAL(ac_cv_prog_cc_$1,
174[ac_cv_prog_cc_$1=no
175ac_save_CC=$CC
176AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
177for ac_arg in '' $4
178do
179 CC="$ac_save_CC $ac_arg"
180 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
181 test "x$ac_cv_prog_cc_$1" != "xno" && break
182done
183rm -f conftest.$ac_ext
184CC=$ac_save_CC
185])# AC_CACHE_VAL
186ac_prog_cc_stdc_options=
187case "x$ac_cv_prog_cc_$1" in
188 x)
189 AC_MSG_RESULT([none needed]) ;;
190 xno)
191 AC_MSG_RESULT([unsupported]) ;;
192 *)
193 ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
194 CC=$CC$ac_prog_cc_stdc_options
195 AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
196esac
197AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
198])# _AC_C_STD_TRY
199
200# _AC_C_C99_TEST_HEADER
201# ---------------------
202# A C header suitable for testing for C99.
203AC_DEFUN([_AC_C_C99_TEST_HEADER],
204[[#include <stdarg.h>
205#include <stdbool.h>
206#include <stddef.h>
207#include <stdlib.h>
208#include <wchar.h>
209#include <stdio.h>
210
211// Check varargs macros. These examples are taken from C99 6.10.3.5.
212#define debug(...) fprintf (stderr, __VA_ARGS__)
213#define showlist(...) puts (#__VA_ARGS__)
214#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
215static void
216test_varargs_macros (void)
217{
218 int x = 1234;
219 int y = 5678;
220 debug ("Flag");
221 debug ("X = %d\n", x);
222 showlist (The first, second, and third items.);
223 report (x>y, "x is %d but y is %d", x, y);
224}
225
226// Check long long types.
227#define BIG64 18446744073709551615ull
228#define BIG32 4294967295ul
229#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
230#if !BIG_OK
231 your preprocessor is broken;
232#endif
233#if BIG_OK
234#else
235 your preprocessor is broken;
236#endif
237static long long int bignum = -9223372036854775807LL;
238static unsigned long long int ubignum = BIG64;
239
240struct incomplete_array
241{
242 int datasize;
243 double data[];
244};
245
246struct named_init {
247 int number;
248 const wchar_t *name;
249 double average;
250};
251
252typedef const char *ccp;
253
254static inline int
255test_restrict (ccp restrict text)
256{
257 // See if C++-style comments work.
258 // Iterate through items via the restricted pointer.
259 // Also check for declarations in for loops.
260 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
261 continue;
262 return 0;
263}
264
265// Check varargs and va_copy.
266static bool
267test_varargs (const char *format, ...)
268{
269 va_list args;
270 va_start (args, format);
271 va_list args_copy;
272 va_copy (args_copy, args);
273
274 const char *str = "";
275 int number = 0;
276 float fnumber = 0;
277
278 while (*format)
279 {
280 switch (*format++)
281 {
282 case 's': // string
283 str = va_arg (args_copy, const char *);
284 break;
285 case 'd': // int
286 number = va_arg (args_copy, int);
287 break;
288 case 'f': // float
289 fnumber = va_arg (args_copy, double);
290 break;
291 default:
292 break;
293 }
294 }
295 va_end (args_copy);
296 va_end (args);
297
298 return *str && number && fnumber;
299}]])# _AC_C_C99_TEST_HEADER
300
301# _AC_C_C99_TEST_BODY
302# -------------------
303# A C body suitable for testing for C99, assuming the corresponding header.
304AC_DEFUN([_AC_C_C99_TEST_BODY],
305[[
306 // Check bool.
307 _Bool success = false;
308
309 // Check restrict.
310 if (test_restrict ("String literal") == 0)
311 success = true;
312 char *restrict newvar = "Another string";
313
314 // Check varargs.
315 success &= test_varargs ("s, d' f .", "string", 65, 34.234);
316 test_varargs_macros ();
317
318 // Check flexible array members.
319 struct incomplete_array *ia =
320 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
321 ia->datasize = 10;
322 for (int i = 0; i < ia->datasize; ++i)
323 ia->data[i] = i * 1.234;
324
325 // Check named initializers.
326 struct named_init ni = {
327 .number = 34,
328 .name = L"Test wide string",
329 .average = 543.34343,
330 };
331
332 ni.number = 58;
333
334 int dynamic_array[ni.number];
335 dynamic_array[ni.number - 1] = 543;
336
337 // work around unused variable warnings
338 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
339 || dynamic_array[ni.number - 1] != 543);
340]])
341
342# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
343# ----------------------------------------------------------------
344# If the C compiler is not in ISO C99 mode by default, try to add an
345# option to output variable CC to make it so. This macro tries
346# various options that select ISO C99 on some system or another. It
347# considers the compiler to be in ISO C99 mode if it handles _Bool,
348# // comments, flexible array members, inline, long long int, mixed
349# code and declarations, named initialization of structs, restrict,
350# va_copy, varargs macros, variable declarations in for loops and
351# variable length arrays.
352AC_DEFUN([_AC_PROG_CC_C99],
353[_AC_C_STD_TRY([c99],
354[_AC_C_C99_TEST_HEADER],
355[_AC_C_C99_TEST_BODY],
356dnl Try
357dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
358dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
359dnl IBM XL C -qlanglvl=extc99
360dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
361dnl HP cc -AC99
362dnl Intel ICC -std=c99, -c99 (deprecated)
363dnl IRIX -c99
364dnl Solaris -D_STDC_C99=
365dnl cc's -xc99 option uses linker magic to define the external
366dnl symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
367dnl behavior for C library functions. This is not wanted here,
368dnl because it means that a single module compiled with -xc99
369dnl alters C runtime behavior for the entire program, not for
370dnl just the module. Instead, define the (private) symbol
371dnl _STDC_C99, which suppresses a bogus failure in <stdbool.h>.
372dnl The resulting compiler passes the test case here, and that's
373dnl good enough. For more, please see the thread starting at:
374dnl https://lists.gnu.org/r/autoconf/2010-12/msg00059.html
375dnl Tru64 -c99
376dnl with extended modes being tried first.
377[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
378])# _AC_PROG_CC_C99
379
380
381# _AC_PROG_CC_C11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
382# ----------------------------------------------------------------
383# If the C compiler is not in ISO C11 mode by default, try to add an
384# option to output variable CC to make it so. This macro tries
385# various options that select ISO C11 on some system or another. It
386# considers the compiler to be in ISO C11 mode if it handles _Alignas,
387# _Alignof, _Noreturn, _Static_assert, UTF-8 string literals,
388# duplicate typedefs, and anonymous structures and unions.
389AC_DEFUN([_AC_PROG_CC_C11],
390[_AC_C_STD_TRY([c11],
391[_AC_C_C99_TEST_HEADER[
392// Check _Alignas.
393char _Alignas (double) aligned_as_double;
394char _Alignas (0) no_special_alignment;
395extern char aligned_as_int;
396char _Alignas (0) _Alignas (int) aligned_as_int;
397
398// Check _Alignof.
399enum
400{
401 int_alignment = _Alignof (int),
402 int_array_alignment = _Alignof (int[100]),
403 char_alignment = _Alignof (char)
404};
405_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
406
407// Check _Noreturn.
408int _Noreturn does_not_return (void) { for (;;) continue; }
409
410// Check _Static_assert.
411struct test_static_assert
412{
413 int x;
414 _Static_assert (sizeof (int) <= sizeof (long int),
415 "_Static_assert does not work in struct");
416 long int y;
417};
418
419// Check UTF-8 literals.
420#define u8 syntax error!
421char const utf8_literal[] = u8"happens to be ASCII" "another string";
422
423// Check duplicate typedefs.
424typedef long *long_ptr;
425typedef long int *long_ptr;
426typedef long_ptr long_ptr;
427
428// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
429struct anonymous
430{
431 union {
432 struct { int i; int j; };
433 struct { int k; long int l; } w;
434 };
435 int m;
436} v1;
437]],
438[_AC_C_C99_TEST_BODY[
439 v1.i = 2;
440 v1.w.k = 5;
441 _Static_assert ((offsetof (struct anonymous, i)
442 == offsetof (struct anonymous, w.k)),
443 "Anonymous union alignment botch");
444]],
445dnl Try
446dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
447dnl with extended modes being tried first.
448dnl
449dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
450dnl of September 2012) does not pass the C11 test. For now, try extc1x when
451dnl compiling the C99 test instead, since it enables _Static_assert and
452dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
453dnl the C11 test in some future version of IBM XL C, we'll add it here,
454dnl preferably extc11.
455[[-std=gnu11]], [$1], [$2])[]dnl
456])# _AC_PROG_CC_C11
457
458
459# AC_PROG_CC_C89
460# --------------
461# Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
462# as that'd be incompatible with how Automake redefines AC_PROG_CC. See
463# <https://lists.gnu.org/r/autoconf/2012-10/msg00048.html>.
464AU_DEFUN([AC_PROG_CC_C89],
465 [AC_REQUIRE([AC_PROG_CC])],
466 [$0 is obsolete; use AC_PROG_CC]
467)
468
469# AC_PROG_CC_C99
470# --------------
471AU_DEFUN([AC_PROG_CC_C99],
472 [AC_REQUIRE([AC_PROG_CC])],
473 [$0 is obsolete; use AC_PROG_CC]
474)
475
476# AC_PROG_CC_STDC
477# ---------------
478AU_DEFUN([AC_PROG_CC_STDC],
479 [AC_REQUIRE([AC_PROG_CC])],
480 [$0 is obsolete; use AC_PROG_CC]
481)
482
483
484# AC_C_PROTOTYPES
485# ---------------
486# Check if the C compiler supports prototypes, included if it needs
487# options.
488AC_DEFUN([AC_C_PROTOTYPES],
489[AC_REQUIRE([AC_PROG_CC])dnl
490if test "$ac_prog_cc_stdc" != no; then
491 AC_DEFINE(PROTOTYPES, 1,
492 [Define to 1 if the C compiler supports function prototypes.])
493 AC_DEFINE(__PROTOTYPES, 1,
494 [Define like PROTOTYPES; this can be used by system headers.])
495fi
496])# AC_C_PROTOTYPES
497
498
499# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
500# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
501# ----------------------------------------------------------------
502# Check whether the C++ compiler accepts features of STANDARD (e.g
503# `cxx98', `cxx11') by trying to compile a program of TEST-PROLOGUE
504# and TEST-BODY. If this fails, try again with each compiler option
505# in the space-separated OPTION-LIST; if one helps, append it to CXX.
506# If eventually successful, run ACTION-IF-AVAILABLE, else
507# ACTION-IF-UNAVAILABLE.
508AC_DEFUN([_AC_CXX_STD_TRY],
509[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
510AC_LANG_PUSH(C++)dnl
511AC_CACHE_VAL(ac_cv_prog_cxx_$1,
512[ac_cv_prog_cxx_$1=no
513ac_save_CXX=$CXX
514AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
515for ac_arg in '' $4
516do
517 CXX="$ac_save_CXX $ac_arg"
518 _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
519 test "x$ac_cv_prog_cxx_$1" != "xno" && break
520done
521rm -f conftest.$ac_ext
522CXX=$ac_save_CXX
523])# AC_CACHE_VAL
524ac_prog_cxx_stdcxx_options=
525case "x$ac_cv_prog_cxx_$1" in
526 x)
527 AC_MSG_RESULT([none needed]) ;;
528 xno)
529 AC_MSG_RESULT([unsupported]) ;;
530 *)
531 ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
532 CXX=$CXX$ac_prog_cxx_stdcxx_options
533 AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
534esac
535AC_LANG_POP(C++)dnl
536AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
537])# _AC_CXX_STD_TRY
538
539# _AC_CXX_CXX98_TEST_HEADER
540# -------------------------
541# A C++ header suitable for testing for CXX98.
542AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
543[[
544#include <algorithm>
545#include <cstdlib>
546#include <fstream>
547#include <iomanip>
548#include <iostream>
549#include <list>
550#include <map>
551#include <set>
552#include <sstream>
553#include <stdexcept>
554#include <string>
555#include <utility>
556#include <vector>
557
558namespace test {
559 typedef std::vector<std::string> string_vec;
560 typedef std::pair<int,bool> map_value;
561 typedef std::map<std::string,map_value> map_type;
562 typedef std::set<int> set_type;
563
564 template<typename T>
565 class printer {
566 public:
567 printer(std::ostringstream& os): os(os) {}
568 void operator() (T elem) { os << elem << std::endl; }
569 private:
570 std::ostringstream& os;
571 };
572}
573]])# _AC_CXX_CXX98_TEST_HEADER
574
575# _AC_CXX_CXX98_TEST_BODY
576# -----------------------
577# A C++ body suitable for testing for CXX98, assuming the corresponding header.
578AC_DEFUN([_AC_CXX_CXX98_TEST_BODY],
579[[
580
581try {
582 // Basic string.
583 std::string teststr("ASCII text");
584 teststr += " string";
585
586 // Simple vector.
587 test::string_vec testvec;
588 testvec.push_back(teststr);
589 testvec.push_back("foo");
590 testvec.push_back("bar");
591 if (testvec.size() != 3) {
592 throw std::runtime_error("vector size is not 1");
593 }
594
595 // Dump vector into stringstream and obtain string.
596 std::ostringstream os;
597 for (test::string_vec::const_iterator i = testvec.begin();
598 i != testvec.end(); ++i) {
599 if (i + 1 != testvec.end()) {
600 os << teststr << '\n';
601 }
602 }
603 // Check algorithms work.
604 std::for_each(testvec.begin(), testvec.end(), test::printer<std::string>(os));
605 std::string os_out = os.str();
606
607 // Test pair and map.
608 test::map_type testmap;
609 testmap.insert(std::make_pair(std::string("key"),
610 std::make_pair(53,false)));
611
612 // Test set.
613 int values[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
614 test::set_type testset(values, values + sizeof(values)/sizeof(values[0]));
615 std::list<int> testlist(testset.begin(), testset.end());
616 std::copy(testset.begin(), testset.end(), std::back_inserter(testlist));
617} catch (const std::exception& e) {
618 std::cerr << "Caught exception: " << e.what() << std::endl;
619
620 // Test fstream
621 std::ofstream of("test.txt");
622 of << "Test ASCII text\n" << std::flush;
623 of << "N= " << std::hex << std::setw(8) << std::left << 534 << std::endl;
624 of.close();
625}
626std::exit(0);
627]])
628
629# _AC_CXX_CXX11_TEST_HEADER
630# -------------------------
631# A C++ header suitable for testing for CXX11.
632AC_DEFUN([_AC_CXX_CXX11_TEST_HEADER],
633[[
634#include <deque>
635#include <functional>
636#include <memory>
637#include <tuple>
638#include <array>
639#include <regex>
640#include <iostream>
641
642namespace cxx11test
643{
644 typedef std::shared_ptr<std::string> sptr;
645 typedef std::weak_ptr<std::string> wptr;
646
647 typedef std::tuple<std::string,int,double> tp;
648 typedef std::array<int, 20> int_array;
649
650 constexpr int get_val() { return 20; }
651
652 struct testinit
653 {
654 int i;
655 double d;
656 };
657
658 class delegate {
659 public:
660 delegate(int n) : n(n) {}
661 delegate(): delegate(2354) {}
662
663 virtual int getval() { return this->n; };
664 protected:
665 int n;
666 };
667
668 class overridden : public delegate {
669 public:
670 overridden(int n): delegate(n) {}
671 virtual int getval() override final { return this->n * 2; }
672 };
673
674 class nocopy {
675 public:
676 nocopy(int i): i(i) {}
677 nocopy() = default;
678 nocopy(const nocopy&) = delete;
679 nocopy & operator=(const nocopy&) = delete;
680 private:
681 int i;
682 };
683}
684]])# _AC_CXX_CXX11_TEST_HEADER
685
686# _AC_CXX_CXX11_TEST_BODY
687# -----------------------
688# A C++ body suitable for testing for CXX11, assuming the corresponding header.
689AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
690[[
691{
692 // Test auto and decltype
693 std::deque<int> d;
694 d.push_front(43);
695 d.push_front(484);
696 d.push_front(3);
697 d.push_front(844);
698 int total = 0;
699 for (auto i = d.begin(); i != d.end(); ++i) { total += *i; }
700
701 auto a1 = 6538;
702 auto a2 = 48573953.4;
703 auto a3 = "String literal";
704
705 decltype(a2) a4 = 34895.034;
706}
707{
708 // Test constexpr
709 short sa[cxx11test::get_val()] = { 0 };
710}
711{
712 // Test initializer lists
713 cxx11test::testinit il = { 4323, 435234.23544 };
714}
715{
716 // Test range-based for and lambda
717 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
718 for (int &x : array) { x += 23; }
719 std::for_each(array.begin(), array.end(), [](int v1){ std::cout << v1; });
720}
721{
722 using cxx11test::sptr;
723 using cxx11test::wptr;
724
725 sptr sp(new std::string("ASCII string"));
726 wptr wp(sp);
727 sptr sp2(wp);
728}
729{
730 cxx11test::tp tuple("test", 54, 45.53434);
731 double d = std::get<2>(tuple);
732 std::string s;
733 int i;
734 std::tie(s,i,d) = tuple;
735}
736{
737 static std::regex filename_regex("^_?([a-z0-9_.]+-)+[a-z0-9]+$");
738 std::string testmatch("Test if this string matches");
739 bool match = std::regex_search(testmatch, filename_regex);
740}
741{
742 cxx11test::int_array array = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
743 cxx11test::int_array::size_type size = array.size();
744}
745{
746 // Test constructor delegation
747 cxx11test::delegate d1;
748 cxx11test::delegate d2();
749 cxx11test::delegate d3(45);
750}
751{
752 // Test override and final
753 cxx11test::overridden o1(55464);
754}
755{
756 // Test nullptr
757 char *c = nullptr;
758}
759{
760 // Test template brackets
761 std::vector<std::pair<int,char*>> v1;
762}
763{
764 // Unicode literals
765 char const *utf8 = u8"UTF-8 string \u2500";
766 char16_t const *utf16 = u"UTF-8 string \u2500";
767 char32_t const *utf32 = U"UTF-32 string \u2500";
768}
769]])
770
771# _AC_PROG_CXX_CXX98 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
772# -------------------------------------------------------------------
773
774# If the C++ compiler is not in ISO C++98 mode by default, try to add
775# an option to output variable CXX to make it so. This macro tries
776# various options that select ISO C++98 on some system or another. It
777# considers the compiler to be in ISO C++98 mode if it handles basic
778# features of the std namespace including: string, containers (list,
779# map, set, vector), streams (fstreams, iostreams, stringstreams,
780# iomanip), pair, exceptions and algorithms.
781
782
783AC_DEFUN([_AC_PROG_CXX_CXX98],
784[_AC_CXX_STD_TRY([cxx98],
785[_AC_CXX_CXX98_TEST_HEADER],
786[_AC_CXX_CXX98_TEST_BODY],
787dnl Try
788dnl GCC -std=gnu++98 (unused restrictive mode: -std=c++98)
789dnl IBM XL C -qlanglvl=extended
790dnl HP aC++ -AA
791dnl Intel ICC -std=gnu++98
792dnl Solaris N/A (default)
793dnl Tru64 N/A (default, but -std gnu could be used)
794dnl with extended modes being tried first.
795[[-std=gnu++98 -std=c++98 -qlanglvl=extended -AA]], [$1], [$2])[]dnl
796])# _AC_PROG_CXX_CXX98
797
798# _AC_PROG_CXX_CXX11 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
799# -------------------------------------------------------------------
800# If the C++ compiler is not in ISO CXX11 mode by default, try to add
801# an option to output variable CXX to make it so. This macro tries
802# various options that select ISO C++11 on some system or another. It
803# considers the compiler to be in ISO C++11 mode if it handles all the
804# tests from the C++98 checks, plus the following: Language features
805# (auto, constexpr, decltype, default/deleted constructors, delegate
806# constructors, final, initializer lists, lambda functions, nullptr,
807# override, range-based for loops, template brackets without spaces,
808# unicode literals) and library features (array, memory (shared_ptr,
809# weak_ptr), regex and tuple types).
810AC_DEFUN([_AC_PROG_CXX_CXX11],
811[_AC_CXX_STD_TRY([cxx11],
812[_AC_CXX_CXX11_TEST_HEADER
813_AC_CXX_CXX98_TEST_HEADER],
814[_AC_CXX_CXX11_TEST_BODY
815_AC_CXX_CXX98_TEST_BODY],
816dnl Try
817dnl GCC -std=gnu++11 (unused restrictive mode: -std=c++11) [and 0x variants]
818dnl IBM XL C -qlanglvl=extended0x
819dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdcxx11)
820dnl HP aC++ -AA
821dnl Intel ICC -std=c++11 -std=c++0x
822dnl Solaris N/A (no support)
823dnl Tru64 N/A (no support)
824dnl with extended modes being tried first.
825[[-std=gnu++11 -std=c++11 -std=gnu++0x -std=c++0x -qlanglvl=extended0x -AA]], [$1], [$2])[]dnl
826])# _AC_PROG_CXX_CXX11
827
828
829])# m4_version_prereq
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
index 20be01a..dc29717 100644
--- a/gl/m4/stdalign.m4
+++ b/gl/m4/stdalign.m4
@@ -1,6 +1,6 @@
1# Check for stdalign.h that conforms to C11. 1# Check for alignas and alignof that conform to C23.
2 2
3dnl Copyright 2011-2013 Free Software Foundation, Inc. 3dnl Copyright 2011-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -9,16 +9,23 @@ dnl with or without modifications, as long as this notice is preserved.
9 9
10AC_DEFUN([gl_STDALIGN_H], 10AC_DEFUN([gl_STDALIGN_H],
11[ 11[
12 AC_CACHE_CHECK([for working stdalign.h], 12 AC_CACHE_CHECK([for alignas and alignof],
13 [gl_cv_header_working_stdalign_h], 13 [gl_cv_header_working_stdalign_h],
14 [AC_COMPILE_IFELSE( 14 [gl_save_CFLAGS=$CFLAGS
15 for gl_working in "yes, keywords" "yes, <stdalign.h> macros"; do
16 AS_CASE([$gl_working],
17 [*stdalign.h*], [CFLAGS="$gl_save_CFLAGS -DINCLUDE_STDALIGN_H"])
18 AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 19 [AC_LANG_PROGRAM(
16 [[#include <stdalign.h> 20 [[#include <stdint.h>
21 #ifdef INCLUDE_STDALIGN_H
22 #include <stdalign.h>
23 #endif
17 #include <stddef.h> 24 #include <stddef.h>
18 25
19 /* Test that alignof yields a result consistent with offsetof. 26 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023 27 This catches GCC bug 52023
21 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */ 28 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
22 #ifdef __cplusplus 29 #ifdef __cplusplus
23 template <class t> struct alignof_helper { char a; t b; }; 30 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b) 31 # define ao(type) offsetof (alignof_helper<type>, b)
@@ -29,25 +36,103 @@ AC_DEFUN([gl_STDALIGN_H],
29 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1]; 36 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
30 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1]; 37 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
31 38
32 /* Test _Alignas only on platforms where gnulib can help. */ 39 /* Test alignas only on platforms where gnulib can help. */
33 #if \ 40 #if \
34 ((defined __cplusplus && 201103 <= __cplusplus) \ 41 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \ 42 || (__TINYC__ && defined __attribute__) \
36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) 43 || (defined __APPLE__ && defined __MACH__ \
44 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
45 : __GNUC__) \
46 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
47 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__ \
48 || 1300 <= _MSC_VER)
37 struct alignas_test { char c; char alignas (8) alignas_8; }; 49 struct alignas_test { char c; char alignas (8) alignas_8; };
38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 50 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
39 ? 1 : -1]; 51 ? 1 : -1];
40 #endif 52 #endif
41 ]])], 53 ]])],
42 [gl_cv_header_working_stdalign_h=yes], 54 [gl_cv_header_working_stdalign_h=$gl_working],
43 [gl_cv_header_working_stdalign_h=no])]) 55 [gl_cv_header_working_stdalign_h=no])
56
57 CFLAGS=$gl_save_CFLAGS
58 test "$gl_cv_header_working_stdalign_h" != no && break
59 done])
60
61 GL_GENERATE_STDALIGN_H=false
62 AS_CASE([$gl_cv_header_working_stdalign_h],
63 [no],
64 [GL_GENERATE_STDALIGN_H=true],
65 [yes*keyword*],
66 [AC_DEFINE([HAVE_C_ALIGNASOF], [1],
67 [Define to 1 if the alignas and alignof keywords work.])])
44 68
45 if test $gl_cv_header_working_stdalign_h = yes; then 69 AC_CHECK_HEADERS_ONCE([stdalign.h])
46 STDALIGN_H=''
47 else
48 STDALIGN_H='stdalign.h'
49 fi
50 70
51 AC_SUBST([STDALIGN_H]) 71 dnl The "zz" puts this toward config.h's end, to avoid potential
52 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"]) 72 dnl collisions with other definitions.
73 AH_VERBATIM([zzalignas],
74[#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof
75# if HAVE_STDALIGN_H
76# include <stdalign.h>
77# else
78 /* Substitute. Keep consistent with gnulib/lib/stdalign.in.h. */
79# ifndef _GL_STDALIGN_H
80# define _GL_STDALIGN_H
81# undef _Alignas
82# undef _Alignof
83# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
84 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
85 && !defined __clang__) \
86 || (defined __clang__ && __clang_major__ < 8))
87# ifdef __cplusplus
88# if (201103 <= __cplusplus || defined _MSC_VER)
89# define _Alignof(type) alignof (type)
90# else
91 template <class __t> struct __alignof_helper { char __a; __t __b; };
92# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
93# define _GL_STDALIGN_NEEDS_STDDEF 1
94# endif
95# else
96# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
97# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
98# else
99# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
100# define _GL_STDALIGN_NEEDS_STDDEF 1
101# endif
102# endif
103# endif
104# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
105# define alignof _Alignof
106# endif
107# define __alignof_is_defined 1
108# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
109# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
110# define _Alignas(a) alignas (a)
111# elif (!defined __attribute__ \
112 && ((defined __APPLE__ && defined __MACH__ \
113 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
114 : __GNUC__ && !defined __ibmxl__) \
115 || (4 <= __clang_major__) \
116 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
117 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
118# define _Alignas(a) __attribute__ ((__aligned__ (a)))
119# elif 1300 <= _MSC_VER
120# define _Alignas(a) __declspec (align (a))
121# endif
122# endif
123# if ((defined _Alignas \
124 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
125 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
126# define alignas _Alignas
127# endif
128# if (defined alignas \
129 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
130# define __alignas_is_defined 1
131# endif
132# if _GL_STDALIGN_NEEDS_STDDEF
133# include <stddef.h>
134# endif
135# endif /* _GL_STDALIGN_H */
136# endif
137#endif])
53]) 138])
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
deleted file mode 100644
index 80d5559..0000000
--- a/gl/m4/stdbool.m4
+++ /dev/null
@@ -1,100 +0,0 @@
1# Check for stdbool.h that conforms to C99.
2
3dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8#serial 5
9
10# Prepare for substituting <stdbool.h> if it is not supported.
11
12AC_DEFUN([AM_STDBOOL_H],
13[
14 AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
15
16 # Define two additional variables used in the Makefile substitution.
17
18 if test "$ac_cv_header_stdbool_h" = yes; then
19 STDBOOL_H=''
20 else
21 STDBOOL_H='stdbool.h'
22 fi
23 AC_SUBST([STDBOOL_H])
24 AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
25
26 if test "$ac_cv_type__Bool" = yes; then
27 HAVE__BOOL=1
28 else
29 HAVE__BOOL=0
30 fi
31 AC_SUBST([HAVE__BOOL])
32])
33
34# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
35AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
36
37# This version of the macro is needed in autoconf <= 2.68.
38
39AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
40 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
41 [ac_cv_header_stdbool_h],
42 [AC_COMPILE_IFELSE(
43 [AC_LANG_PROGRAM(
44 [[
45 #include <stdbool.h>
46 #ifndef bool
47 "error: bool is not defined"
48 #endif
49 #ifndef false
50 "error: false is not defined"
51 #endif
52 #if false
53 "error: false is not 0"
54 #endif
55 #ifndef true
56 "error: true is not defined"
57 #endif
58 #if true != 1
59 "error: true is not 1"
60 #endif
61 #ifndef __bool_true_false_are_defined
62 "error: __bool_true_false_are_defined is not defined"
63 #endif
64
65 struct s { _Bool s: 1; _Bool t; } s;
66
67 char a[true == 1 ? 1 : -1];
68 char b[false == 0 ? 1 : -1];
69 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
70 char d[(bool) 0.5 == true ? 1 : -1];
71 /* See body of main program for 'e'. */
72 char f[(_Bool) 0.0 == false ? 1 : -1];
73 char g[true];
74 char h[sizeof (_Bool)];
75 char i[sizeof s.t];
76 enum { j = false, k = true, l = false * true, m = true * 256 };
77 /* The following fails for
78 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
79 _Bool n[m];
80 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
81 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
82 /* Catch a bug in an HP-UX C compiler. See
83 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
84 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
85 */
86 _Bool q = true;
87 _Bool *pq = &q;
88 ]],
89 [[
90 bool e = &s;
91 *pq |= q;
92 *pq |= ! q;
93 /* Refer to every declared value, to avoid compiler optimizations. */
94 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
95 + !m + !n + !o + !p + !q + !pq);
96 ]])],
97 [ac_cv_header_stdbool_h=yes],
98 [ac_cv_header_stdbool_h=no])])
99 AC_CHECK_TYPES([_Bool])
100])
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index 5da8ab1..a2322eb 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,19 +1,61 @@
1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues. 1# stddef_h.m4 serial 13
2# stddef_h.m4 serial 4 2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
7 6
8AC_DEFUN([gl_STDDEF_H], 7dnl A placeholder for <stddef.h>, for platforms that have issues.
8
9AC_DEFUN_ONCE([gl_STDDEF_H],
9[ 10[
10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 11 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
11 AC_REQUIRE([gt_TYPE_WCHAR_T]) 12 AC_REQUIRE([gt_TYPE_WCHAR_T])
12 STDDEF_H= 13
14 dnl Persuade OpenBSD <stddef.h> to declare max_align_t.
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16
17 GL_GENERATE_STDDEF_H=false
18
19 dnl Test whether the type max_align_t exists and whether its alignment
20 dnl "is as great as is supported by the implementation in all contexts".
21 AC_CACHE_CHECK([for good max_align_t],
22 [gl_cv_type_max_align_t],
23 [AC_COMPILE_IFELSE(
24 [AC_LANG_PROGRAM(
25 [[/* On FreeBSD 12.0/x86, max_align_t defined by <stddef.h> has
26 the correct alignment with the default (wrong) definition of
27 _Alignof, but a wrong alignment as soon as we activate an
28 ISO C compliant _Alignof definition. */
29 #if ((defined __GNUC__ && 4 <= __GNUC__) || defined __clang__) && !defined __cplusplus
30 #define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
31 #endif
32 #include <stddef.h>
33 unsigned int s = sizeof (max_align_t);
34 #if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
35 int check1[2 * (__alignof__ (double) <= __alignof__ (max_align_t)) - 1];
36 int check2[2 * (__alignof__ (long double) <= __alignof__ (max_align_t)) - 1];
37 #endif
38 typedef struct { char a; max_align_t b; } max_helper;
39 typedef struct { char a; long b; } long_helper;
40 typedef struct { char a; double b; } double_helper;
41 typedef struct { char a; long double b; } long_double_helper;
42 int check3[2 * (offsetof (long_helper, b) <= offsetof (max_helper, b)) - 1];
43 int check4[2 * (offsetof (double_helper, b) <= offsetof (max_helper, b)) - 1];
44 int check5[2 * (offsetof (long_double_helper, b) <= offsetof (max_helper, b)) - 1];
45 ]])],
46 [gl_cv_type_max_align_t=yes],
47 [gl_cv_type_max_align_t=no])
48 ])
49 if test $gl_cv_type_max_align_t = no; then
50 HAVE_MAX_ALIGN_T=0
51 GL_GENERATE_STDDEF_H=true
52 fi
53
13 if test $gt_cv_c_wchar_t = no; then 54 if test $gt_cv_c_wchar_t = no; then
14 HAVE_WCHAR_T=0 55 HAVE_WCHAR_T=0
15 STDDEF_H=stddef.h 56 GL_GENERATE_STDDEF_H=true
16 fi 57 fi
58
17 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], 59 AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
18 [gl_cv_decl_null_works], 60 [gl_cv_decl_null_works],
19 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> 61 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
@@ -23,25 +65,40 @@ AC_DEFUN([gl_STDDEF_H],
23 [gl_cv_decl_null_works=no])]) 65 [gl_cv_decl_null_works=no])])
24 if test $gl_cv_decl_null_works = no; then 66 if test $gl_cv_decl_null_works = no; then
25 REPLACE_NULL=1 67 REPLACE_NULL=1
26 STDDEF_H=stddef.h 68 GL_GENERATE_STDDEF_H=true
27 fi 69 fi
28 AC_SUBST([STDDEF_H]) 70
29 AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) 71 if $GL_GENERATE_STDDEF_H; then
30 if test -n "$STDDEF_H"; then
31 gl_NEXT_HEADERS([stddef.h]) 72 gl_NEXT_HEADERS([stddef.h])
32 fi 73 fi
33]) 74])
34 75
76# gl_STDDEF_MODULE_INDICATOR([modulename])
77# sets the shell variable that indicates the presence of the given module
78# to a C preprocessor expression that will evaluate to 1.
79# This macro invocation must not occur in macros that are AC_REQUIREd.
35AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], 80AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
36[ 81[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 82 dnl Ensure to expand the default settings once only.
38 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 83 gl_STDDEF_H_REQUIRE_DEFAULTS
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 84 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40]) 85])
41 86
87# Initializes the default values for AC_SUBSTed shell variables.
88# This macro must not be AC_REQUIREd. It must only be invoked, and only
89# outside of macros or in macros that are not AC_REQUIREd.
90AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS],
91[
92 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS], [
93 ])
94 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDDEF_H_MODULE_INDICATOR_DEFAULTS])
95 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
96])
97
42AC_DEFUN([gl_STDDEF_H_DEFAULTS], 98AC_DEFUN([gl_STDDEF_H_DEFAULTS],
43[ 99[
44 dnl Assume proper GNU behavior unless another module says otherwise. 100 dnl Assume proper GNU behavior unless another module says otherwise.
45 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 101 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
102 HAVE_MAX_ALIGN_T=1; AC_SUBST([HAVE_MAX_ALIGN_T])
46 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) 103 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
47]) 104])
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index 27cdcdb..d6961b0 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
1# stdint.m4 serial 43 1# stdint.m4 serial 61
2dnl Copyright (C) 2001-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,25 +7,22 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl From Paul Eggert and Bruno Haible. 7dnl From Paul Eggert and Bruno Haible.
8dnl Test whether <stdint.h> is supported or must be substituted. 8dnl Test whether <stdint.h> is supported or must be substituted.
9 9
10AC_PREREQ([2.61])
11
10AC_DEFUN_ONCE([gl_STDINT_H], 12AC_DEFUN_ONCE([gl_STDINT_H],
11[ 13[
12 AC_PREREQ([2.59])dnl 14 AC_PREREQ([2.59])dnl
15 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 16
14 dnl Check for long long int and unsigned long long int. 17 AC_REQUIRE([gl_LIMITS_H])
15 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 18 AC_REQUIRE([gt_TYPE_WINT_T])
16 if test $ac_cv_type_long_long_int = yes; then 19
17 HAVE_LONG_LONG_INT=1 20 dnl For backward compatibility. Some packages may still be testing these
18 else 21 dnl macros.
19 HAVE_LONG_LONG_INT=0 22 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
20 fi 23 [Define to 1 if the system has the type 'long long int'.])
21 AC_SUBST([HAVE_LONG_LONG_INT]) 24 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
22 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) 25 [Define to 1 if the system has the type 'unsigned long long int'.])
23 if test $ac_cv_type_unsigned_long_long_int = yes; then
24 HAVE_UNSIGNED_LONG_LONG_INT=1
25 else
26 HAVE_UNSIGNED_LONG_LONG_INT=0
27 fi
28 AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
29 26
30 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does. 27 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
31 AC_CHECK_HEADERS_ONCE([wchar.h]) 28 AC_CHECK_HEADERS_ONCE([wchar.h])
@@ -37,7 +34,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
37 AC_SUBST([HAVE_WCHAR_H]) 34 AC_SUBST([HAVE_WCHAR_H])
38 35
39 dnl Check for <inttypes.h>. 36 dnl Check for <inttypes.h>.
40 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. 37 AC_CHECK_HEADERS_ONCE([inttypes.h])
41 if test $ac_cv_header_inttypes_h = yes; then 38 if test $ac_cv_header_inttypes_h = yes; then
42 HAVE_INTTYPES_H=1 39 HAVE_INTTYPES_H=1
43 else 40 else
@@ -46,7 +43,7 @@ AC_DEFUN_ONCE([gl_STDINT_H],
46 AC_SUBST([HAVE_INTTYPES_H]) 43 AC_SUBST([HAVE_INTTYPES_H])
47 44
48 dnl Check for <sys/types.h>. 45 dnl Check for <sys/types.h>.
49 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h. 46 AC_CHECK_HEADERS_ONCE([sys/types.h])
50 if test $ac_cv_header_sys_types_h = yes; then 47 if test $ac_cv_header_sys_types_h = yes; then
51 HAVE_SYS_TYPES_H=1 48 HAVE_SYS_TYPES_H=1
52 else 49 else
@@ -70,6 +67,8 @@ AC_DEFUN_ONCE([gl_STDINT_H],
70 AC_COMPILE_IFELSE([ 67 AC_COMPILE_IFELSE([
71 AC_LANG_PROGRAM([[ 68 AC_LANG_PROGRAM([[
72#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 69#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
70#define __STDC_CONSTANT_MACROS 1
71#define __STDC_LIMIT_MACROS 1
73#include <stdint.h> 72#include <stdint.h>
74/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */ 73/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
75#if !(defined WCHAR_MIN && defined WCHAR_MAX) 74#if !(defined WCHAR_MIN && defined WCHAR_MAX)
@@ -150,6 +149,15 @@ uintptr_t h = UINTPTR_MAX;
150intmax_t i = INTMAX_MAX; 149intmax_t i = INTMAX_MAX;
151uintmax_t j = UINTMAX_MAX; 150uintmax_t j = UINTMAX_MAX;
152 151
152/* Check that SIZE_MAX has the correct type, if possible. */
153#if 201112 <= __STDC_VERSION__
154int k = _Generic (SIZE_MAX, size_t: 0);
155#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
156 || (0x5110 <= __SUNPRO_C && !__STDC__))
157extern size_t k;
158extern __typeof__ (SIZE_MAX) k;
159#endif
160
153#include <limits.h> /* for CHAR_BIT */ 161#include <limits.h> /* for CHAR_BIT */
154#define TYPE_MINIMUM(t) \ 162#define TYPE_MINIMUM(t) \
155 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) 163 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
@@ -162,7 +170,7 @@ struct s {
162 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) 170 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
163 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) 171 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
164 ? 1 : -1; 172 ? 1 : -1;
165 /* Detect bug in FreeBSD 6.0 / ia64. */ 173 /* Detect bug in FreeBSD 6.0/ia64 and FreeBSD 13.0/arm64. */
166 int check_SIG_ATOMIC: 174 int check_SIG_ATOMIC:
167 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) 175 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
168 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) 176 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
@@ -218,6 +226,8 @@ struct s {
218 AC_RUN_IFELSE([ 226 AC_RUN_IFELSE([
219 AC_LANG_PROGRAM([[ 227 AC_LANG_PROGRAM([[
220#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 228#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
229#define __STDC_CONSTANT_MACROS 1
230#define __STDC_LIMIT_MACROS 1
221#include <stdint.h> 231#include <stdint.h>
222] 232]
223gl_STDINT_INCLUDES 233gl_STDINT_INCLUDES
@@ -272,36 +282,88 @@ static const char *macro_values[] =
272]])], 282]])],
273 [gl_cv_header_working_stdint_h=yes], 283 [gl_cv_header_working_stdint_h=yes],
274 [], 284 [],
275 [dnl When cross-compiling, assume it works. 285 [case "$host_os" in
276 gl_cv_header_working_stdint_h=yes 286 # Guess yes on native Windows.
287 mingw*) gl_cv_header_working_stdint_h="guessing yes" ;;
288 # In general, assume it works.
289 *) gl_cv_header_working_stdint_h="guessing yes" ;;
290 esac
277 ]) 291 ])
278 ]) 292 ])
279 ]) 293 ])
280 fi 294 fi
281 if test "$gl_cv_header_working_stdint_h" = yes; then
282 STDINT_H=
283 else
284 dnl Check for <sys/inttypes.h>, and for
285 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
286 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
287 if test $ac_cv_header_sys_inttypes_h = yes; then
288 HAVE_SYS_INTTYPES_H=1
289 else
290 HAVE_SYS_INTTYPES_H=0
291 fi
292 AC_SUBST([HAVE_SYS_INTTYPES_H])
293 if test $ac_cv_header_sys_bitypes_h = yes; then
294 HAVE_SYS_BITYPES_H=1
295 else
296 HAVE_SYS_BITYPES_H=0
297 fi
298 AC_SUBST([HAVE_SYS_BITYPES_H])
299 295
300 gl_STDINT_TYPE_PROPERTIES 296 HAVE_C99_STDINT_H=0
301 STDINT_H=stdint.h 297 HAVE_SYS_BITYPES_H=0
302 fi 298 HAVE_SYS_INTTYPES_H=0
303 AC_SUBST([STDINT_H]) 299 GL_GENERATE_STDINT_H=true
304 AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) 300 case "$gl_cv_header_working_stdint_h" in
301 *yes)
302 HAVE_C99_STDINT_H=1
303 dnl Now see whether the system <stdint.h> works without
304 dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
305 dnl If not, there would be problems when stdint.h is included from C++.
306 AC_CACHE_CHECK([whether stdint.h works without ISO C predefines],
307 [gl_cv_header_stdint_without_STDC_macros],
308 [gl_cv_header_stdint_without_STDC_macros=no
309 AC_COMPILE_IFELSE([
310 AC_LANG_PROGRAM([[
311#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
312#include <stdint.h>
313]
314gl_STDINT_INCLUDES
315[
316intmax_t im = INTMAX_MAX;
317int32_t i32 = INT32_C (0x7fffffff);
318 ]])],
319 [gl_cv_header_stdint_without_STDC_macros=yes])
320 ])
321
322 if test $gl_cv_header_stdint_without_STDC_macros = no; then
323 AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
324 [Define to 1 if the system <stdint.h> predates C++11.])
325 AC_DEFINE([__STDC_LIMIT_MACROS], [1],
326 [Define to 1 if the system <stdint.h> predates C++11.])
327 fi
328 AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
329 [gl_cv_header_stdint_width],
330 [gl_cv_header_stdint_width=no
331 AC_COMPILE_IFELSE(
332 [AC_LANG_PROGRAM([[
333 /* Work if build is not clean. */
334 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
335 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
336 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
337 #endif
338 #include <stdint.h>
339 ]gl_STDINT_INCLUDES[
340 int iw = UINTMAX_WIDTH;
341 ]])],
342 [gl_cv_header_stdint_width=yes])])
343 if test "$gl_cv_header_stdint_width" = yes; then
344 GL_GENERATE_STDINT_H=false
345 fi
346 ;;
347 *)
348 dnl Check for <sys/inttypes.h>, and for
349 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
350 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
351 if test $ac_cv_header_sys_inttypes_h = yes; then
352 HAVE_SYS_INTTYPES_H=1
353 fi
354 if test $ac_cv_header_sys_bitypes_h = yes; then
355 HAVE_SYS_BITYPES_H=1
356 fi
357 gl_STDINT_TYPE_PROPERTIES
358 ;;
359 esac
360
361 dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
362 gl_REPLACE_LIMITS_H
363
364 AC_SUBST([HAVE_C99_STDINT_H])
365 AC_SUBST([HAVE_SYS_BITYPES_H])
366 AC_SUBST([HAVE_SYS_INTTYPES_H])
305]) 367])
306 368
307dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) 369dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -429,13 +491,9 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
429dnl gl_STDINT_INCLUDES 491dnl gl_STDINT_INCLUDES
430AC_DEFUN([gl_STDINT_INCLUDES], 492AC_DEFUN([gl_STDINT_INCLUDES],
431[[ 493[[
432 /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
433 included before <wchar.h>. */
434 #include <stddef.h> 494 #include <stddef.h>
435 #include <signal.h> 495 #include <signal.h>
436 #if HAVE_WCHAR_H 496 #if HAVE_WCHAR_H
437 # include <stdio.h>
438 # include <time.h>
439 # include <wchar.h> 497 # include <wchar.h>
440 #endif 498 #endif
441]]) 499]])
@@ -467,18 +525,7 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
467 dnl requirement that wint_t is "unchanged by default argument promotions". 525 dnl requirement that wint_t is "unchanged by default argument promotions".
468 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t. 526 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
469 dnl Set the variable BITSIZEOF_WINT_T accordingly. 527 dnl Set the variable BITSIZEOF_WINT_T accordingly.
470 if test $BITSIZEOF_WINT_T -lt 32; then 528 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
471 BITSIZEOF_WINT_T=32 529 BITSIZEOF_WINT_T=32
472 fi 530 fi
473]) 531])
474
475dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
476dnl Remove this when we can assume autoconf >= 2.61.
477m4_ifdef([AC_COMPUTE_INT], [], [
478 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
479])
480
481# Hey Emacs!
482# Local Variables:
483# indent-tabs-mode: nil
484# End:
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index 511ab4e..70349f6 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
1# stdint_h.m4 serial 9 1# stdint_h.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index ebade06..94271e1 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,72 +1,71 @@
1# stdio_h.m4 serial 43 1# stdio_h.m4 serial 59
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_STDIO_H], 7AC_DEFUN_ONCE([gl_STDIO_H],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AH_VERBATIM([MINGW_ANSI_STDIO],
11[/* Use GNU style printf and scanf. */
12#ifndef __USE_MINGW_ANSI_STDIO
13# undef __USE_MINGW_ANSI_STDIO
14#endif
15])
16 AC_DEFINE([__USE_MINGW_ANSI_STDIO])
10 gl_NEXT_HEADERS([stdio.h]) 17 gl_NEXT_HEADERS([stdio.h])
11 18
12 dnl No need to create extra modules for these functions. Everyone who uses 19 dnl Determine whether __USE_MINGW_ANSI_STDIO makes printf and
13 dnl <stdio.h> likely needs them. 20 dnl inttypes.h behave like gnu instead of system; we must give our
14 GNULIB_FSCANF=1 21 dnl printf wrapper the right attribute to match.
15 gl_MODULE_INDICATOR([fscanf]) 22 AC_CACHE_CHECK([which flavor of printf attribute matches inttypes macros],
16 GNULIB_SCANF=1 23 [gl_cv_func_printf_attribute_flavor],
17 gl_MODULE_INDICATOR([scanf]) 24 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
18 GNULIB_FGETC=1 25 #define __STDC_FORMAT_MACROS 1
19 GNULIB_GETC=1 26 #include <stdio.h>
20 GNULIB_GETCHAR=1 27 #include <inttypes.h>
21 GNULIB_FGETS=1 28 /* For non-mingw systems, compilation will trivially succeed.
22 GNULIB_FREAD=1 29 For mingw, compilation will succeed for older mingw (system
23 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c" 30 printf, "I64d") and fail for newer mingw (gnu printf, "lld"). */
24 dnl "expected source file, required through AC_LIBSOURCES, not found". It is 31 #if (defined _WIN32 && ! defined __CYGWIN__) && \
25 dnl also an optimization, to avoid performing a configure check whose result 32 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
26 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING 33 extern char PRIdMAX_probe[sizeof PRIdMAX == sizeof "I64d" ? 1 : -1];
27 dnl or GNULIB_NONBLOCKING redundant. 34 #endif
35 ]])], [gl_cv_func_printf_attribute_flavor=system],
36 [gl_cv_func_printf_attribute_flavor=gnu])])
37 if test "$gl_cv_func_printf_attribute_flavor" = gnu; then
38 AC_DEFINE([GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU], [1],
39 [Define to 1 if printf and friends should be labeled with
40 attribute "__gnu_printf__" instead of "__printf__"])
41 fi
42
43 dnl This ifdef is an optimization, to avoid performing a configure check whose
44 dnl result is not used. But it does not make the test of
45 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
28 m4_ifdef([gl_NONBLOCKING_IO], [ 46 m4_ifdef([gl_NONBLOCKING_IO], [
29 gl_NONBLOCKING_IO 47 gl_NONBLOCKING_IO
30 if test $gl_cv_have_nonblocking != yes; then 48 if test $gl_cv_have_nonblocking != yes; then
31 REPLACE_STDIO_READ_FUNCS=1 49 REPLACE_STDIO_READ_FUNCS=1
32 AC_LIBOBJ([stdio-read])
33 fi 50 fi
34 ]) 51 ])
35 52
36 dnl No need to create extra modules for these functions. Everyone who uses 53 dnl This ifdef is an optimization, to avoid performing a configure check whose
37 dnl <stdio.h> likely needs them. 54 dnl result is not used. But it does not make the test of
38 GNULIB_FPRINTF=1 55 dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
39 GNULIB_PRINTF=1
40 GNULIB_VFPRINTF=1
41 GNULIB_VPRINTF=1
42 GNULIB_FPUTC=1
43 GNULIB_PUTC=1
44 GNULIB_PUTCHAR=1
45 GNULIB_FPUTS=1
46 GNULIB_PUTS=1
47 GNULIB_FWRITE=1
48 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
49 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
50 dnl also an optimization, to avoid performing a configure check whose result
51 dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
52 dnl GNULIB_SIGPIPE redundant.
53 m4_ifdef([gl_SIGNAL_SIGPIPE], [ 56 m4_ifdef([gl_SIGNAL_SIGPIPE], [
54 gl_SIGNAL_SIGPIPE 57 gl_SIGNAL_SIGPIPE
55 if test $gl_cv_header_signal_h_SIGPIPE != yes; then 58 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
56 REPLACE_STDIO_WRITE_FUNCS=1 59 REPLACE_STDIO_WRITE_FUNCS=1
57 AC_LIBOBJ([stdio-write])
58 fi 60 fi
59 ]) 61 ])
60 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c" 62 dnl This ifdef is an optimization, to avoid performing a configure check whose
61 dnl "expected source file, required through AC_LIBSOURCES, not found". It is 63 dnl result is not used. But it does not make the test of
62 dnl also an optimization, to avoid performing a configure check whose result 64 dnl GNULIB_STDIO_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
63 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
64 dnl or GNULIB_NONBLOCKING redundant.
65 m4_ifdef([gl_NONBLOCKING_IO], [ 65 m4_ifdef([gl_NONBLOCKING_IO], [
66 gl_NONBLOCKING_IO 66 gl_NONBLOCKING_IO
67 if test $gl_cv_have_nonblocking != yes; then 67 if test $gl_cv_have_nonblocking != yes; then
68 REPLACE_STDIO_WRITE_FUNCS=1 68 REPLACE_STDIO_WRITE_FUNCS=1
69 AC_LIBOBJ([stdio-write])
70 fi 69 fi
71 ]) 70 ])
72 71
@@ -76,73 +75,104 @@ AC_DEFUN([gl_STDIO_H],
76 gl_WARN_ON_USE_PREPARE([[#include <stdio.h> 75 gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
77 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen 76 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
78 renameat snprintf tmpfile vdprintf vsnprintf]) 77 renameat snprintf tmpfile vdprintf vsnprintf])
78
79 AC_REQUIRE([AC_C_RESTRICT])
80
81 AC_CHECK_DECLS_ONCE([fcloseall])
82 if test $ac_cv_have_decl_fcloseall = no; then
83 HAVE_DECL_FCLOSEALL=0
84 fi
79]) 85])
80 86
87# gl_STDIO_MODULE_INDICATOR([modulename])
88# sets the shell variable that indicates the presence of the given module
89# to a C preprocessor expression that will evaluate to 1.
90# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_STDIO_MODULE_INDICATOR], 91AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
82[ 92[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 93 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 94 gl_STDIO_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 95 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 96 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 97 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 98])
89 99
100# Initializes the default values for AC_SUBSTed shell variables.
101# This macro must not be AC_REQUIREd. It must only be invoked, and only
102# outside of macros or in macros that are not AC_REQUIREd.
103AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
104[
105 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS], [
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DPRINTF])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCLOSE])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPEN])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFLUSH])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTC])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPUTS])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREAD])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREOPEN])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSCANF])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEK])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSEEKO])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELL])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTELLO])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FWRITE])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETC])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCHAR])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDELIM])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLINE])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OBSTACK_PRINTF_POSIX])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PCLOSE])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PERROR])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POPEN])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PRINTF_POSIX])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTC])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTCHAR])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTS])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REMOVE])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAME])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RENAMEAT])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANF])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNPRINTF])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SPRINTF_POSIX])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_NONBLOCKING])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFPRINTF_POSIX])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX])
160 dnl Support Microsoft deprecated alias function names by default.
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FILENO], [1])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETW], [1])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTW], [1])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TEMPNAM], [1])
167 ])
168 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDIO_H_MODULE_INDICATOR_DEFAULTS])
169 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
170])
171
90AC_DEFUN([gl_STDIO_H_DEFAULTS], 172AC_DEFUN([gl_STDIO_H_DEFAULTS],
91[ 173[
92 GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF])
93 GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
94 GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN])
95 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
96 GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC])
97 GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS])
98 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
99 GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
100 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
101 GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE])
102 GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
103 GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
104 GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD])
105 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
106 GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF])
107 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
108 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
109 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
110 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
111 GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
112 GNULIB_GETC=0; AC_SUBST([GNULIB_GETC])
113 GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR])
114 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
115 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
116 GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
117 GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
118 GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE])
119 GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
120 GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN])
121 GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
122 GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX])
123 GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC])
124 GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR])
125 GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS])
126 GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE])
127 GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME])
128 GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT])
129 GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF])
130 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
131 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
132 GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
133 GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
134 GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
135 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
136 GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF])
137 GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF])
138 GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
139 GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
140 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
141 GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF])
142 GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
143 GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
144 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
145 dnl Assume proper GNU behavior unless another module says otherwise. 174 dnl Assume proper GNU behavior unless another module says otherwise.
175 HAVE_DECL_FCLOSEALL=1; AC_SUBST([HAVE_DECL_FCLOSEALL])
146 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) 176 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE])
147 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) 177 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO])
148 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) 178 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
@@ -164,6 +194,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
164 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN]) 194 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN])
165 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) 195 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
166 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) 196 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
197 REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU])
167 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) 198 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
168 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) 199 REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE])
169 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) 200 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index 2027ab3..e96be22 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,10 +1,10 @@
1# stdlib_h.m4 serial 42 1# stdlib_h.m4 serial 66
2dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_STDLIB_H], 7AC_DEFUN_ONCE([gl_STDLIB_H],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 gl_NEXT_HEADERS([stdlib.h]) 10 gl_NEXT_HEADERS([stdlib.h])
@@ -14,104 +14,187 @@ AC_DEFUN([gl_STDLIB_H],
14 dnl guaranteed by C89. 14 dnl guaranteed by C89.
15 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h> 15 gl_WARN_ON_USE_PREPARE([[#include <stdlib.h>
16#if HAVE_SYS_LOADAVG_H 16#if HAVE_SYS_LOADAVG_H
17/* OpenIndiana has a bug: <sys/time.h> must be included before
18 <sys/loadavg.h>. */
19# include <sys/time.h>
17# include <sys/loadavg.h> 20# include <sys/loadavg.h>
18#endif 21#endif
19#if HAVE_RANDOM_H 22#if HAVE_RANDOM_H
20# include <random.h> 23# include <random.h>
21#endif 24#endif
22 ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt 25 ]], [_Exit aligned_alloc atoll canonicalize_file_name free
23 initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps 26 getloadavg getsubopt grantpt
24 posix_openpt ptsname ptsname_r random random_r realpath rpmatch 27 initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
25 secure_getenv setenv setstate setstate_r srandom srandom_r 28 posix_memalign posix_openpt ptsname ptsname_r qsort_r
26 strtod strtoll strtoull unlockpt unsetenv]) 29 random random_r reallocarray realpath rpmatch secure_getenv setenv
30 setstate setstate_r srandom srandom_r
31 strtod strtol strtold strtoll strtoul strtoull unlockpt unsetenv])
32
33 AC_REQUIRE([AC_C_RESTRICT])
34
35 AC_CHECK_DECLS_ONCE([ecvt])
36 if test $ac_cv_have_decl_ecvt = no; then
37 HAVE_DECL_ECVT=0
38 fi
39 AC_CHECK_DECLS_ONCE([fcvt])
40 if test $ac_cv_have_decl_fcvt = no; then
41 HAVE_DECL_FCVT=0
42 fi
43 AC_CHECK_DECLS_ONCE([gcvt])
44 if test $ac_cv_have_decl_gcvt = no; then
45 HAVE_DECL_GCVT=0
46 fi
27]) 47])
28 48
49# gl_STDLIB_MODULE_INDICATOR([modulename])
50# sets the shell variable that indicates the presence of the given module
51# to a C preprocessor expression that will evaluate to 1.
52# This macro invocation must not occur in macros that are AC_REQUIREd.
29AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], 53AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
30[ 54[
31 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 55 dnl Ensure to expand the default settings once only.
32 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 56 gl_STDLIB_H_REQUIRE_DEFAULTS
33 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 57 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
34 dnl Define it also as a C macro, for the benefit of the unit tests. 58 dnl Define it also as a C macro, for the benefit of the unit tests.
35 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 59 gl_MODULE_INDICATOR_FOR_TESTS([$1])
36]) 60])
37 61
62# Initializes the default values for AC_SUBSTed shell variables.
63# This macro must not be AC_REQUIREd. It must only be invoked, and only
64# outside of macros or in macros that are not AC_REQUIREd.
65AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
66[
67 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS], [
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX])
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMP])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKOSTEMPS])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMP])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKSTEMPS])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_MEMALIGN])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_POSIX_OPENPT])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PTSNAME_R])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PUTENV])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_QSORT_R])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SECURE_GETENV])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETENV])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOD])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOL])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLD])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOLL])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOUL])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOULL])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYSTEM_POSIX])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLOCKPT])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNSETENV])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOMB])
111 dnl Support Microsoft deprecated alias function names by default.
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ECVT], [1])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCVT], [1])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GCVT], [1])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKTEMP], [1])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_PUTENV], [1])
117 ])
118 m4_require(GL_MODULE_INDICATOR_PREFIX[_STDLIB_H_MODULE_INDICATOR_DEFAULTS])
119 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
120])
121
38AC_DEFUN([gl_STDLIB_H_DEFAULTS], 122AC_DEFUN([gl_STDLIB_H_DEFAULTS],
39[ 123[
40 GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT])
41 GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
42 GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
43 GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
44 GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
45 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
46 GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
47 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
48 GNULIB_MBTOWC=0; AC_SUBST([GNULIB_MBTOWC])
49 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
50 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
51 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
52 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
53 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
54 GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT])
55 GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME])
56 GNULIB_PTSNAME_R=0; AC_SUBST([GNULIB_PTSNAME_R])
57 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
58 GNULIB_RANDOM=0; AC_SUBST([GNULIB_RANDOM])
59 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
60 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
61 GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
62 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
63 GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV])
64 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
65 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
66 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
67 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
68 GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX])
69 GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
70 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
71 GNULIB_WCTOMB=0; AC_SUBST([GNULIB_WCTOMB])
72 dnl Assume proper GNU behavior unless another module says otherwise. 124 dnl Assume proper GNU behavior unless another module says otherwise.
73 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) 125 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
126 HAVE_ALIGNED_ALLOC=1; AC_SUBST([HAVE_ALIGNED_ALLOC])
74 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) 127 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
75 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) 128 HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
129 HAVE_DECL_ECVT=1; AC_SUBST([HAVE_DECL_ECVT])
130 HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT])
131 HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT])
76 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) 132 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
77 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) 133 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
78 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) 134 HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
135 HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE])
136 HAVE_DECL_INITSTATE=1; AC_SUBST([HAVE_DECL_INITSTATE])
137 HAVE_MBTOWC=1; AC_SUBST([HAVE_MBTOWC])
79 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) 138 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
80 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) 139 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
81 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) 140 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
82 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) 141 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
83 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) 142 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
143 HAVE_POSIX_MEMALIGN=1; AC_SUBST([HAVE_POSIX_MEMALIGN])
84 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT]) 144 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT])
85 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) 145 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
86 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R]) 146 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R])
147 HAVE_QSORT_R=1; AC_SUBST([HAVE_QSORT_R])
87 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM]) 148 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM])
88 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H]) 149 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
89 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) 150 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
151 HAVE_REALLOCARRAY=1; AC_SUBST([HAVE_REALLOCARRAY])
90 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) 152 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
91 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) 153 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
92 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV]) 154 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV])
93 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) 155 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
94 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV]) 156 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
157 HAVE_SETSTATE=1; AC_SUBST([HAVE_SETSTATE])
158 HAVE_DECL_SETSTATE=1; AC_SUBST([HAVE_DECL_SETSTATE])
95 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) 159 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
160 HAVE_STRTOL=1; AC_SUBST([HAVE_STRTOL])
161 HAVE_STRTOLD=1; AC_SUBST([HAVE_STRTOLD])
96 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) 162 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
163 HAVE_STRTOUL=1; AC_SUBST([HAVE_STRTOUL])
97 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) 164 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
98 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) 165 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
99 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) 166 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
100 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) 167 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
101 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV]) 168 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
102 REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) 169 REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC])
170 REPLACE_CALLOC_FOR_CALLOC_GNU=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
171 REPLACE_CALLOC_FOR_CALLOC_POSIX=0; AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
103 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) 172 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
104 REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) 173 REPLACE_FREE=0; AC_SUBST([REPLACE_FREE])
174 REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE])
175 REPLACE_MALLOC_FOR_MALLOC_GNU=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
176 REPLACE_MALLOC_FOR_MALLOC_POSIX=0; AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
105 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC]) 177 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
106 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) 178 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
179 REPLACE_POSIX_MEMALIGN=0; AC_SUBST([REPLACE_POSIX_MEMALIGN])
107 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME]) 180 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
108 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R]) 181 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
109 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) 182 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
183 REPLACE_QSORT_R=0; AC_SUBST([REPLACE_QSORT_R])
184 REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM])
110 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R]) 185 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
111 REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) 186 REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
187 REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
188 REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY])
112 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) 189 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
113 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) 190 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
191 REPLACE_SETSTATE=0; AC_SUBST([REPLACE_SETSTATE])
114 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) 192 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
193 REPLACE_STRTOL=0; AC_SUBST([REPLACE_STRTOL])
194 REPLACE_STRTOLD=0; AC_SUBST([REPLACE_STRTOLD])
195 REPLACE_STRTOLL=0; AC_SUBST([REPLACE_STRTOLL])
196 REPLACE_STRTOUL=0; AC_SUBST([REPLACE_STRTOUL])
197 REPLACE_STRTOULL=0; AC_SUBST([REPLACE_STRTOULL])
115 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) 198 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
116 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB]) 199 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB])
117]) 200])
diff --git a/gl/m4/strcase.m4 b/gl/m4/strcase.m4
index 22bf57c..3cf740d 100644
--- a/gl/m4/strcase.m4
+++ b/gl/m4/strcase.m4
@@ -1,5 +1,5 @@
1# strcase.m4 serial 11 1# strcase.m4 serial 12
2dnl Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_STRCASE],
12 12
13AC_DEFUN([gl_FUNC_STRCASECMP], 13AC_DEFUN([gl_FUNC_STRCASECMP],
14[ 14[
15 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 15 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
16 AC_CHECK_FUNCS([strcasecmp]) 16 AC_CHECK_FUNCS([strcasecmp])
17 if test $ac_cv_func_strcasecmp = no; then 17 if test $ac_cv_func_strcasecmp = no; then
18 HAVE_STRCASECMP=0 18 HAVE_STRCASECMP=0
@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_STRCASECMP],
21 21
22AC_DEFUN([gl_FUNC_STRNCASECMP], 22AC_DEFUN([gl_FUNC_STRNCASECMP],
23[ 23[
24 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 24 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
25 AC_CHECK_FUNCS([strncasecmp]) 25 AC_CHECK_FUNCS([strncasecmp])
26 if test $ac_cv_func_strncasecmp = yes; then 26 if test $ac_cv_func_strncasecmp = yes; then
27 HAVE_STRNCASECMP=1 27 HAVE_STRNCASECMP=1
diff --git a/gl/m4/strcasestr.m4 b/gl/m4/strcasestr.m4
index 8681a6a..971e0b2 100644
--- a/gl/m4/strcasestr.m4
+++ b/gl/m4/strcasestr.m4
@@ -1,5 +1,5 @@
1# strcasestr.m4 serial 21 1# strcasestr.m4 serial 28
2dnl Copyright (C) 2005, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl Check that strcasestr is present and works. 7dnl Check that strcasestr is present and works.
8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE], 8AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 10 AC_REQUIRE([gl_STRING_H_DEFAULTS])
11 11
12 dnl Persuade glibc <string.h> to declare strcasestr(). 12 dnl Persuade glibc <string.h> to declare strcasestr().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -17,28 +17,38 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
17 if test $ac_cv_func_strcasestr = no; then 17 if test $ac_cv_func_strcasestr = no; then
18 HAVE_STRCASESTR=0 18 HAVE_STRCASESTR=0
19 else 19 else
20 if test "$gl_cv_func_memchr_works" != yes; then 20 if test $REPLACE_MEMCHR = 1; then
21 REPLACE_STRCASESTR=1 21 REPLACE_STRCASESTR=1
22 else 22 else
23 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. 23 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
24 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637.
24 AC_CACHE_CHECK([whether strcasestr works], 25 AC_CACHE_CHECK([whether strcasestr works],
25 [gl_cv_func_strcasestr_works_always], 26 [gl_cv_func_strcasestr_works_always],
26 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 27 [AC_RUN_IFELSE(
27#include <string.h> /* for strcasestr */ 28 [AC_LANG_PROGRAM([[
29#include <string.h> /* for __GNU_LIBRARY__, strcasestr */
30#ifdef __GNU_LIBRARY__
31 #include <features.h>
32 #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28
33 Unlucky user
34 #endif
35#endif
28#define P "_EF_BF_BD" 36#define P "_EF_BF_BD"
29#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P 37#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
30#define NEEDLE P P P P P 38#define NEEDLE P P P P P
31]], [[return !!strcasestr (HAYSTACK, NEEDLE); 39]],
32 ]])], 40 [[return !!strcasestr (HAYSTACK, NEEDLE);
33 [gl_cv_func_strcasestr_works_always=yes], 41 ]])],
34 [gl_cv_func_strcasestr_works_always=no], 42 [gl_cv_func_strcasestr_works_always=yes],
35 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not 43 [gl_cv_func_strcasestr_works_always=no],
36 dnl affected, since it uses different source code for strcasestr 44 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
37 dnl than glibc. 45 dnl affected, since it uses different source code for strcasestr
38 dnl Assume that it works on all other platforms, even if it is not 46 dnl than glibc.
39 dnl linear. 47 dnl Assume that it works on all other platforms, even if it is not
40 AC_EGREP_CPP([Lucky user], 48 dnl linear.
41 [ 49 AC_EGREP_CPP([Lucky user],
50 [
51#include <string.h> /* for __GNU_LIBRARY__ */
42#ifdef __GNU_LIBRARY__ 52#ifdef __GNU_LIBRARY__
43 #include <features.h> 53 #include <features.h>
44 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ 54 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
@@ -53,10 +63,10 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
53#else 63#else
54 Lucky user 64 Lucky user
55#endif 65#endif
56 ], 66 ],
57 [gl_cv_func_strcasestr_works_always="guessing yes"], 67 [gl_cv_func_strcasestr_works_always="guessing yes"],
58 [gl_cv_func_strcasestr_works_always="guessing no"]) 68 [gl_cv_func_strcasestr_works_always="$gl_cross_guess_normal"])
59 ]) 69 ])
60 ]) 70 ])
61 case "$gl_cv_func_strcasestr_works_always" in 71 case "$gl_cv_func_strcasestr_works_always" in
62 *yes) ;; 72 *yes) ;;
@@ -80,7 +90,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR],
80#include <string.h> /* for strcasestr */ 90#include <string.h> /* for strcasestr */
81#include <stdlib.h> /* for malloc */ 91#include <stdlib.h> /* for malloc */
82#include <unistd.h> /* for alarm */ 92#include <unistd.h> /* for alarm */
83static void quit (int sig) { exit (sig + 128); } 93static void quit (int sig) { _exit (sig + 128); }
84]], [[ 94]], [[
85 int result = 0; 95 int result = 0;
86 size_t m = 1000000; 96 size_t m = 1000000;
@@ -102,6 +112,9 @@ static void quit (int sig) { exit (sig + 128); }
102 if (!strcasestr (haystack, needle)) 112 if (!strcasestr (haystack, needle))
103 result |= 1; 113 result |= 1;
104 } 114 }
115 /* Free allocated memory, in case some sanitizer is watching. */
116 free (haystack);
117 free (needle);
105 return result; 118 return result;
106 ]])], 119 ]])],
107 [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no], 120 [gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
@@ -124,7 +137,7 @@ static void quit (int sig) { exit (sig + 128); }
124#endif 137#endif
125 ], 138 ],
126 [gl_cv_func_strcasestr_linear="guessing yes"], 139 [gl_cv_func_strcasestr_linear="guessing yes"],
127 [gl_cv_func_strcasestr_linear="guessing no"]) 140 [gl_cv_func_strcasestr_linear="$gl_cross_guess_normal"])
128 ]) 141 ])
129 ]) 142 ])
130 case "$gl_cv_func_strcasestr_linear" in 143 case "$gl_cv_func_strcasestr_linear" in
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index 3989844..8879eb0 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,19 +1,19 @@
1# strerror.m4 serial 17 1# strerror.m4 serial 23
2dnl Copyright (C) 2002, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_STRERROR], 7AC_DEFUN([gl_FUNC_STRERROR],
8[ 8[
9 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 9 AC_REQUIRE([gl_STRING_H_DEFAULTS])
10 AC_REQUIRE([gl_HEADER_ERRNO_H]) 10 AC_REQUIRE([gl_HEADER_ERRNO_H])
11 AC_REQUIRE([gl_FUNC_STRERROR_0]) 11 AC_REQUIRE([gl_FUNC_STRERROR_0])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [ 13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS]) 14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
15 ]) 15 ])
16 if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then 16 if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then
17 AC_CACHE_CHECK([for working strerror function], 17 AC_CACHE_CHECK([for working strerror function],
18 [gl_cv_func_working_strerror], 18 [gl_cv_func_working_strerror],
19 [AC_RUN_IFELSE( 19 [AC_RUN_IFELSE(
@@ -24,10 +24,12 @@ AC_DEFUN([gl_FUNC_STRERROR],
24 [gl_cv_func_working_strerror=yes], 24 [gl_cv_func_working_strerror=yes],
25 [gl_cv_func_working_strerror=no], 25 [gl_cv_func_working_strerror=no],
26 [case "$host_os" in 26 [case "$host_os" in
27 # Guess yes on glibc systems. 27 # Guess yes on glibc systems.
28 *-gnu*) gl_cv_func_working_strerror="guessing yes" ;; 28 *-gnu* | gnu*) gl_cv_func_working_strerror="guessing yes" ;;
29 # If we don't know, assume the worst. 29 # Guess yes on musl systems.
30 *) gl_cv_func_working_strerror="guessing no" ;; 30 *-musl*) gl_cv_func_working_strerror="guessing yes" ;;
31 # If we don't know, obey --enable-cross-guesses.
32 *) gl_cv_func_working_strerror="$gl_cross_guess_normal" ;;
31 esac 33 esac
32 ]) 34 ])
33 ]) 35 ])
@@ -78,10 +80,14 @@ AC_DEFUN([gl_FUNC_STRERROR_0],
78 [gl_cv_func_strerror_0_works=yes], 80 [gl_cv_func_strerror_0_works=yes],
79 [gl_cv_func_strerror_0_works=no], 81 [gl_cv_func_strerror_0_works=no],
80 [case "$host_os" in 82 [case "$host_os" in
81 # Guess yes on glibc systems. 83 # Guess yes on glibc systems.
82 *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;; 84 *-gnu* | gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
83 # If we don't know, assume the worst. 85 # Guess yes on musl systems.
84 *) gl_cv_func_strerror_0_works="guessing no" ;; 86 *-musl*) gl_cv_func_strerror_0_works="guessing yes" ;;
87 # Guess yes on native Windows.
88 mingw*) gl_cv_func_strerror_0_works="guessing yes" ;;
89 # If we don't know, obey --enable-cross-guesses.
90 *) gl_cv_func_strerror_0_works="$gl_cross_guess_normal" ;;
85 esac 91 esac
86 ]) 92 ])
87 ]) 93 ])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index cc5fbbb..5da3cc2 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -1,25 +1,19 @@
1# Configure a GNU-like replacement for <string.h>. 1# Configure a GNU-like replacement for <string.h>.
2 2
3# Copyright (C) 2007-2013 Free Software Foundation, Inc. 3# Copyright (C) 2007-2023 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6# with or without modifications, as long as this notice is preserved.
7 7
8# serial 21 8# serial 35
9 9
10# Written by Paul Eggert. 10# Written by Paul Eggert.
11 11
12AC_DEFUN([gl_HEADER_STRING_H], 12AC_DEFUN_ONCE([gl_STRING_H],
13[ 13[
14 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 14 dnl Ensure to expand the default settings once only, before all statements
15 dnl once only, before all statements that occur in other macros. 15 dnl that occur in other macros.
16 AC_REQUIRE([gl_HEADER_STRING_H_BODY]) 16 AC_REQUIRE([gl_STRING_H_DEFAULTS])
17])
18
19AC_DEFUN([gl_HEADER_STRING_H_BODY],
20[
21 AC_REQUIRE([AC_C_RESTRICT])
22 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
23 gl_NEXT_HEADERS([string.h]) 17 gl_NEXT_HEADERS([string.h])
24 18
25 dnl Check for declarations of anything we want to poison if the 19 dnl Check for declarations of anything we want to poison if the
@@ -27,66 +21,95 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
27 dnl guaranteed by C89. 21 dnl guaranteed by C89.
28 gl_WARN_ON_USE_PREPARE([[#include <string.h> 22 gl_WARN_ON_USE_PREPARE([[#include <string.h>
29 ]], 23 ]],
30 [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul 24 [explicit_bzero ffsl ffsll memmem mempcpy memrchr memset_explicit
25 rawmemchr stpcpy stpncpy strchrnul
31 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r 26 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
32 strerror_r strsignal strverscmp]) 27 strerror_r strerrorname_np sigabbrev_np sigdescr_np strsignal strverscmp])
28
29 AC_REQUIRE([AC_C_RESTRICT])
33]) 30])
34 31
32# gl_STRING_MODULE_INDICATOR([modulename])
33# sets the shell variable that indicates the presence of the given module
34# to a C preprocessor expression that will evaluate to 1.
35# This macro invocation must not occur in macros that are AC_REQUIREd.
35AC_DEFUN([gl_STRING_MODULE_INDICATOR], 36AC_DEFUN([gl_STRING_MODULE_INDICATOR],
36[ 37[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 38 dnl Ensure to expand the default settings once only.
38 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 39 gl_STRING_H_REQUIRE_DEFAULTS
39 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 40 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
40 dnl Define it also as a C macro, for the benefit of the unit tests. 41 dnl Define it also as a C macro, for the benefit of the unit tests.
41 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 42 gl_MODULE_INDICATOR_FOR_TESTS([$1])
42]) 43])
43 44
44AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], 45# Initializes the default values for AC_SUBSTed shell variables.
46# This macro must not be AC_REQUIREd. It must only be invoked, and only
47# outside of macros or in macros that are not AC_REQUIREd.
48AC_DEFUN([gl_STRING_H_REQUIRE_DEFAULTS],
45[ 49[
46 GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL]) 50 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS], [
47 GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL]) 51 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXPLICIT_BZERO])
48 GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) 52 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSL])
49 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) 53 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFSLL])
50 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) 54 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMCHR])
51 GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) 55 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMMEM])
52 GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) 56 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMPCPY])
53 GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) 57 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMRCHR])
54 GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) 58 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MEMSET_EXPLICIT])
55 GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) 59 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RAWMEMCHR])
56 GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) 60 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPCPY])
57 GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) 61 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STPNCPY])
58 GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) 62 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCHRNUL])
59 GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) 63 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRDUP])
60 GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) 64 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNCAT])
61 GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) 65 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNDUP])
62 GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) 66 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRNLEN])
63 GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) 67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPBRK])
64 GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) 68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSEP])
65 GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) 69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSTR])
66 GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) 70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRCASESTR])
67 GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) 71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRTOK_R])
68 GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) 72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSLEN])
69 GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) 73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNLEN])
70 GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) 74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCHR])
71 GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) 75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRCHR])
72 GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) 76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSTR])
73 GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) 77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASECMP])
74 GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) 78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNCASECMP])
75 GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) 79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPCASECMP])
76 GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) 80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCASESTR])
77 GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) 81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSCSPN])
78 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) 82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSPBRK])
79 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) 83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSPN])
80 GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) 84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSSEP])
81 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) 85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSTOK_R])
82 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) 86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR])
83 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) 87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERROR_R])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRERRORNAME_NP])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGABBREV_NP])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SIGDESCR_NP])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRSIGNAL])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRVERSCMP])
93 dnl Support Microsoft deprecated alias function names by default.
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MEMCCPY], [1])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_STRDUP], [1])
96 ])
97 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRING_H_MODULE_INDICATOR_DEFAULTS])
98 dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
99 gl_STDLIB_H_REQUIRE_DEFAULTS
100 AC_REQUIRE([gl_STRING_H_DEFAULTS])
101])
102
103AC_DEFUN([gl_STRING_H_DEFAULTS],
104[
105 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
84 dnl Assume proper GNU behavior unless another module says otherwise. 106 dnl Assume proper GNU behavior unless another module says otherwise.
107 HAVE_EXPLICIT_BZERO=1; AC_SUBST([HAVE_EXPLICIT_BZERO])
85 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL]) 108 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
86 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL]) 109 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
87 HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
88 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) 110 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
89 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) 111 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
112 HAVE_MEMSET_EXPLICIT=1; AC_SUBST([HAVE_MEMSET_EXPLICIT])
90 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) 113 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
91 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) 114 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
92 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) 115 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
@@ -100,21 +123,26 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
100 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) 123 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
101 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) 124 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
102 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) 125 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
126 HAVE_STRERRORNAME_NP=1; AC_SUBST([HAVE_STRERRORNAME_NP])
127 HAVE_SIGABBREV_NP=1; AC_SUBST([HAVE_SIGABBREV_NP])
128 HAVE_SIGDESCR_NP=1; AC_SUBST([HAVE_SIGDESCR_NP])
103 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) 129 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
104 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) 130 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
131 REPLACE_FFSLL=0; AC_SUBST([REPLACE_FFSLL])
105 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) 132 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
106 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) 133 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
107 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) 134 REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
135 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
108 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) 136 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
137 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
138 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
139 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
109 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) 140 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
110 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) 141 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
111 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) 142 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
112 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 143 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
113 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) 144 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
114 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) 145 REPLACE_STRERRORNAME_NP=0; AC_SUBST([REPLACE_STRERRORNAME_NP])
115 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
116 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
117 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) 146 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
118 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
119 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) 147 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
120]) 148])
diff --git a/gl/m4/strings_h.m4 b/gl/m4/strings_h.m4
index 76ef242..4c41221 100644
--- a/gl/m4/strings_h.m4
+++ b/gl/m4/strings_h.m4
@@ -1,21 +1,16 @@
1# Configure a replacement for <strings.h>. 1# Configure a replacement for <strings.h>.
2# serial 6 2# serial 9
3 3
4# Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 4# Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
8 8
9AC_DEFUN([gl_HEADER_STRINGS_H], 9AC_DEFUN_ONCE([gl_STRINGS_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_HEADER_STRINGS_H_BODY]) 13 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
14])
15
16AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
17[
18 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
19 14
20 gl_CHECK_NEXT_HEADERS([strings.h]) 15 gl_CHECK_NEXT_HEADERS([strings.h])
21 if test $ac_cv_header_strings_h = yes; then 16 if test $ac_cv_header_strings_h = yes; then
@@ -35,16 +30,31 @@ AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
35 ]], [ffs strcasecmp strncasecmp]) 30 ]], [ffs strcasecmp strncasecmp])
36]) 31])
37 32
33# gl_STRINGS_MODULE_INDICATOR([modulename])
34# sets the shell variable that indicates the presence of the given module
35# to a C preprocessor expression that will evaluate to 1.
36# This macro invocation must not occur in macros that are AC_REQUIREd.
38AC_DEFUN([gl_STRINGS_MODULE_INDICATOR], 37AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
39[ 38[
40 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 39 dnl Ensure to expand the default settings once only.
41 AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 40 gl_STRINGS_H_REQUIRE_DEFAULTS
42 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 41 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
43]) 42])
44 43
45AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS], 44# Initializes the default values for AC_SUBSTed shell variables.
45# This macro must not be AC_REQUIREd. It must only be invoked, and only
46# outside of macros or in macros that are not AC_REQUIREd.
47AC_DEFUN([gl_STRINGS_H_REQUIRE_DEFAULTS],
48[
49 m4_defun(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS], [
50 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FFS])
51 ])
52 m4_require(GL_MODULE_INDICATOR_PREFIX[_STRINGS_H_MODULE_INDICATOR_DEFAULTS])
53 AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
54])
55
56AC_DEFUN([gl_STRINGS_H_DEFAULTS],
46[ 57[
47 GNULIB_FFS=0; AC_SUBST([GNULIB_FFS])
48 dnl Assume proper GNU behavior unless another module says otherwise. 58 dnl Assume proper GNU behavior unless another module says otherwise.
49 HAVE_FFS=1; AC_SUBST([HAVE_FFS]) 59 HAVE_FFS=1; AC_SUBST([HAVE_FFS])
50 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP]) 60 HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
deleted file mode 100644
index a1f8274..0000000
--- a/gl/m4/strndup.m4
+++ /dev/null
@@ -1,55 +0,0 @@
1# strndup.m4 serial 21
2dnl Copyright (C) 2002-2003, 2005-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_STRNDUP],
8[
9 dnl Persuade glibc <string.h> to declare strndup().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
14 AC_CHECK_DECLS_ONCE([strndup])
15 AC_CHECK_FUNCS_ONCE([strndup])
16 if test $ac_cv_have_decl_strndup = no; then
17 HAVE_DECL_STRNDUP=0
18 fi
19
20 if test $ac_cv_func_strndup = yes; then
21 HAVE_STRNDUP=1
22 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
23 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
24 [AC_RUN_IFELSE([
25 AC_LANG_PROGRAM([[#include <string.h>
26 #include <stdlib.h>]], [[
27#if !HAVE_DECL_STRNDUP
28 extern
29 #ifdef __cplusplus
30 "C"
31 #endif
32 char *strndup (const char *, size_t);
33#endif
34 char *s;
35 s = strndup ("some longer string", 15);
36 free (s);
37 s = strndup ("shorter string", 13);
38 return s[13] != '\0';]])],
39 [gl_cv_func_strndup_works=yes],
40 [gl_cv_func_strndup_works=no],
41 [
42changequote(,)dnl
43 case $host_os in
44 aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
45 *) gl_cv_func_strndup_works="guessing yes";;
46 esac
47changequote([,])dnl
48 ])])
49 case $gl_cv_func_strndup_works in
50 *no) REPLACE_STRNDUP=1 ;;
51 esac
52 else
53 HAVE_STRNDUP=0
54 fi
55])
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4
deleted file mode 100644
index eae82b7..0000000
--- a/gl/m4/strnlen.m4
+++ /dev/null
@@ -1,30 +0,0 @@
1# strnlen.m4 serial 13
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_FUNC_STRNLEN],
9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
11
12 dnl Persuade glibc <string.h> to declare strnlen().
13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
14
15 AC_CHECK_DECLS_ONCE([strnlen])
16 if test $ac_cv_have_decl_strnlen = no; then
17 HAVE_DECL_STRNLEN=0
18 else
19 m4_pushdef([AC_LIBOBJ], [:])
20 dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
21 AC_FUNC_STRNLEN
22 m4_popdef([AC_LIBOBJ])
23 if test $ac_cv_func_strnlen_working = no; then
24 REPLACE_STRNLEN=1
25 fi
26 fi
27])
28
29# Prerequisites of lib/strnlen.c.
30AC_DEFUN([gl_PREREQ_STRNLEN], [:])
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4
index 825fdb8..e0da09a 100644
--- a/gl/m4/strsep.m4
+++ b/gl/m4/strsep.m4
@@ -1,5 +1,5 @@
1# strsep.m4 serial 10 1# strsep.m4 serial 11
2dnl Copyright (C) 2002-2004, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_STRSEP],
12 dnl The strsep() declaration in lib/string.in.h uses 'restrict'. 12 dnl The strsep() declaration in lib/string.in.h uses 'restrict'.
13 AC_REQUIRE([AC_C_RESTRICT]) 13 AC_REQUIRE([AC_C_RESTRICT])
14 14
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 15 AC_REQUIRE([gl_STRING_H_DEFAULTS])
16 AC_CHECK_FUNCS([strsep]) 16 AC_CHECK_FUNCS([strsep])
17 if test $ac_cv_func_strsep = no; then 17 if test $ac_cv_func_strsep = no; then
18 HAVE_STRSEP=0 18 HAVE_STRSEP=0
diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4
index c486bdb..7de203a 100644
--- a/gl/m4/strstr.m4
+++ b/gl/m4/strstr.m4
@@ -1,5 +1,5 @@
1# strstr.m4 serial 16 1# strstr.m4 serial 24
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,30 +7,40 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl Check that strstr works. 7dnl Check that strstr works.
8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE], 8AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 10 AC_REQUIRE([gl_STRING_H_DEFAULTS])
11 AC_REQUIRE([gl_FUNC_MEMCHR]) 11 AC_REQUIRE([gl_FUNC_MEMCHR])
12 if test "$gl_cv_func_memchr_works" != yes; then 12 if test $REPLACE_MEMCHR = 1; then
13 REPLACE_STRSTR=1 13 REPLACE_STRSTR=1
14 else 14 else
15 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. 15 dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092
16 dnl and https://sourceware.org/bugzilla/show_bug.cgi?id=23637.
16 AC_CACHE_CHECK([whether strstr works], 17 AC_CACHE_CHECK([whether strstr works],
17 [gl_cv_func_strstr_works_always], 18 [gl_cv_func_strstr_works_always],
18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 19 [AC_RUN_IFELSE(
19#include <string.h> /* for strstr */ 20 [AC_LANG_PROGRAM([[
21#include <string.h> /* for __GNU_LIBRARY__, strstr */
22#ifdef __GNU_LIBRARY__
23 #include <features.h>
24 #if __GLIBC__ == 2 && __GLIBC_MINOR__ == 28
25 Unlucky user
26 #endif
27#endif
20#define P "_EF_BF_BD" 28#define P "_EF_BF_BD"
21#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P 29#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
22#define NEEDLE P P P P P 30#define NEEDLE P P P P P
23]], [[return !!strstr (HAYSTACK, NEEDLE); 31]],
24 ]])], 32 [[return !!strstr (HAYSTACK, NEEDLE);
25 [gl_cv_func_strstr_works_always=yes], 33 ]])],
26 [gl_cv_func_strstr_works_always=no], 34 [gl_cv_func_strstr_works_always=yes],
27 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not 35 [gl_cv_func_strstr_works_always=no],
28 dnl affected, since it uses different source code for strstr than 36 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
29 dnl glibc. 37 dnl affected, since it uses different source code for strstr than
30 dnl Assume that it works on all other platforms, even if it is not 38 dnl glibc.
31 dnl linear. 39 dnl Assume that it works on all other platforms, even if it is not
32 AC_EGREP_CPP([Lucky user], 40 dnl linear.
33 [ 41 AC_EGREP_CPP([Lucky user],
42 [
43#include <string.h> /* for __GNU_LIBRARY__ */
34#ifdef __GNU_LIBRARY__ 44#ifdef __GNU_LIBRARY__
35 #include <features.h> 45 #include <features.h>
36 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \ 46 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
@@ -45,10 +55,10 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
45#else 55#else
46 Lucky user 56 Lucky user
47#endif 57#endif
48 ], 58 ],
49 [gl_cv_func_strstr_works_always="guessing yes"], 59 [gl_cv_func_strstr_works_always="guessing yes"],
50 [gl_cv_func_strstr_works_always="guessing no"]) 60 [gl_cv_func_strstr_works_always="$gl_cross_guess_normal"])
51 ]) 61 ])
52 ]) 62 ])
53 case "$gl_cv_func_strstr_works_always" in 63 case "$gl_cv_func_strstr_works_always" in
54 *yes) ;; 64 *yes) ;;
@@ -67,11 +77,17 @@ AC_DEFUN([gl_FUNC_STRSTR],
67 AC_CACHE_CHECK([whether strstr works in linear time], 77 AC_CACHE_CHECK([whether strstr works in linear time],
68 [gl_cv_func_strstr_linear], 78 [gl_cv_func_strstr_linear],
69 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 79 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
80#ifdef __MVS__
81/* z/OS does not deliver signals while strstr() is running (thanks to
82 restrictions on its LE runtime), which prevents us from limiting the
83 running time of this test. */
84# error "This test does not work properly on z/OS"
85#endif
70#include <signal.h> /* for signal */ 86#include <signal.h> /* for signal */
71#include <string.h> /* for strstr */ 87#include <string.h> /* for strstr */
72#include <stdlib.h> /* for malloc */ 88#include <stdlib.h> /* for malloc */
73#include <unistd.h> /* for alarm */ 89#include <unistd.h> /* for alarm */
74static void quit (int sig) { exit (sig + 128); } 90static void quit (int sig) { _exit (sig + 128); }
75]], [[ 91]], [[
76 int result = 0; 92 int result = 0;
77 size_t m = 1000000; 93 size_t m = 1000000;
@@ -93,6 +109,9 @@ static void quit (int sig) { exit (sig + 128); }
93 if (!strstr (haystack, needle)) 109 if (!strstr (haystack, needle))
94 result |= 1; 110 result |= 1;
95 } 111 }
112 /* Free allocated memory, in case some sanitizer is watching. */
113 free (haystack);
114 free (needle);
96 return result; 115 return result;
97 ]])], 116 ]])],
98 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no], 117 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
@@ -117,7 +136,7 @@ static void quit (int sig) { exit (sig + 128); }
117#endif 136#endif
118 ], 137 ],
119 [gl_cv_func_strstr_linear="guessing yes"], 138 [gl_cv_func_strstr_linear="guessing yes"],
120 [gl_cv_func_strstr_linear="guessing no"]) 139 [gl_cv_func_strstr_linear="$gl_cross_guess_normal"])
121 ]) 140 ])
122 ]) 141 ])
123 case "$gl_cv_func_strstr_linear" in 142 case "$gl_cv_func_strstr_linear" in
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index 9486377..98a1041 100644
--- a/gl/m4/sys_socket_h.m4
+++ b/gl/m4/sys_socket_h.m4
@@ -1,12 +1,12 @@
1# sys_socket_h.m4 serial 23 1# sys_socket_h.m4 serial 29
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Simon Josefsson. 7dnl From Simon Josefsson.
8 8
9AC_DEFUN([gl_HEADER_SYS_SOCKET], 9AC_DEFUN_ONCE([gl_SYS_SOCKET_H],
10[ 10[
11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
@@ -22,6 +22,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
22 ;; 22 ;;
23 esac 23 esac
24 24
25 GL_GENERATE_SYS_SOCKET_H=false
25 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], 26 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
26 [gl_cv_header_sys_socket_h_selfcontained], 27 [gl_cv_header_sys_socket_h_selfcontained],
27 [ 28 [
@@ -44,7 +45,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
44 [gl_cv_header_sys_socket_h_shut=no]) 45 [gl_cv_header_sys_socket_h_shut=no])
45 ]) 46 ])
46 if test $gl_cv_header_sys_socket_h_shut = no; then 47 if test $gl_cv_header_sys_socket_h_shut = no; then
47 SYS_SOCKET_H='sys/socket.h' 48 GL_GENERATE_SYS_SOCKET_H=true
48 fi 49 fi
49 fi 50 fi
50 fi 51 fi
@@ -83,7 +84,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
83 fi 84 fi
84 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ 85 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \
85 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then 86 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then
86 SYS_SOCKET_H='sys/socket.h' 87 GL_GENERATE_SYS_SOCKET_H=true
87 fi 88 fi
88 gl_PREREQ_SYS_H_WINSOCK2 89 gl_PREREQ_SYS_H_WINSOCK2
89 90
@@ -95,6 +96,8 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
95#include <sys/socket.h> 96#include <sys/socket.h>
96 ]], [socket connect accept bind getpeername getsockname getsockopt 97 ]], [socket connect accept bind getpeername getsockname getsockopt
97 listen recv send recvfrom sendto setsockopt shutdown accept4]) 98 listen recv send recvfrom sendto setsockopt shutdown accept4])
99
100 AC_REQUIRE([AC_C_RESTRICT])
98]) 101])
99 102
100AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], 103AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
@@ -104,17 +107,11 @@ AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
104 gl_CHECK_NEXT_HEADERS([sys/socket.h]) 107 gl_CHECK_NEXT_HEADERS([sys/socket.h])
105 if test $ac_cv_header_sys_socket_h = yes; then 108 if test $ac_cv_header_sys_socket_h = yes; then
106 HAVE_SYS_SOCKET_H=1 109 HAVE_SYS_SOCKET_H=1
107 HAVE_WS2TCPIP_H=0
108 else 110 else
109 HAVE_SYS_SOCKET_H=0 111 HAVE_SYS_SOCKET_H=0
110 if test $ac_cv_header_ws2tcpip_h = yes; then
111 HAVE_WS2TCPIP_H=1
112 else
113 HAVE_WS2TCPIP_H=0
114 fi
115 fi 112 fi
116 AC_SUBST([HAVE_SYS_SOCKET_H]) 113 AC_SUBST([HAVE_SYS_SOCKET_H])
117 AC_SUBST([HAVE_WS2TCPIP_H]) 114 gl_PREREQ_SYS_H_WS2TCPIP
118]) 115])
119 116
120# Common prerequisites of the <sys/socket.h> replacement and of the 117# Common prerequisites of the <sys/socket.h> replacement and of the
@@ -142,32 +139,65 @@ AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
142 AC_SUBST([HAVE_WINSOCK2_H]) 139 AC_SUBST([HAVE_WINSOCK2_H])
143]) 140])
144 141
142# Common prerequisites of the <sys/socket.h> replacement and of the
143# <arpa/inet.h> replacement.
144# Sets and substitutes HAVE_WS2TCPIP_H.
145AC_DEFUN([gl_PREREQ_SYS_H_WS2TCPIP],
146[
147 AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
148 if test $ac_cv_header_sys_socket_h = yes; then
149 HAVE_WS2TCPIP_H=0
150 else
151 if test $ac_cv_header_ws2tcpip_h = yes; then
152 HAVE_WS2TCPIP_H=1
153 else
154 HAVE_WS2TCPIP_H=0
155 fi
156 fi
157 AC_SUBST([HAVE_WS2TCPIP_H])
158])
159
160# gl_SYS_SOCKET_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
145AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], 164AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
146[ 165[
147 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 166 dnl Ensure to expand the default settings once only.
148 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 167 gl_SYS_SOCKET_H_REQUIRE_DEFAULTS
149 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
150 dnl Define it also as a C macro, for the benefit of the unit tests. 169 dnl Define it also as a C macro, for the benefit of the unit tests.
151 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
152]) 171])
153 172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_SYS_SOCKET_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SOCKET])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CONNECT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BIND])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPEERNAME])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKNAME])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSOCKOPT])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LISTEN])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECV])
188 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SEND])
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RECVFROM])
190 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SENDTO])
191 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETSOCKOPT])
192 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SHUTDOWN])
193 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCEPT4])
194 ])
195 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_SOCKET_H_MODULE_INDICATOR_DEFAULTS])
196 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
197])
198
154AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], 199AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
155[ 200[
156 GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET])
157 GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT])
158 GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT])
159 GNULIB_BIND=0; AC_SUBST([GNULIB_BIND])
160 GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME])
161 GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME])
162 GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT])
163 GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN])
164 GNULIB_RECV=0; AC_SUBST([GNULIB_RECV])
165 GNULIB_SEND=0; AC_SUBST([GNULIB_SEND])
166 GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM])
167 GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO])
168 GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT])
169 GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN])
170 GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4])
171 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) 201 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
172 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; 202 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
173 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) 203 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
new file mode 100644
index 0000000..ca57398
--- /dev/null
+++ b/gl/m4/sys_stat_h.m4
@@ -0,0 +1,129 @@
1# sys_stat_h.m4 serial 42 -*- Autoconf -*-
2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Eric Blake.
8dnl Provide a GNU-like <sys/stat.h>.
9
10AC_DEFUN_ONCE([gl_SYS_STAT_H],
11[
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13
14 dnl Check for broken stat macros.
15 AC_REQUIRE([AC_HEADER_STAT])
16
17 gl_CHECK_NEXT_HEADERS([sys/stat.h])
18
19 dnl Ensure the type mode_t gets defined.
20 AC_REQUIRE([AC_TYPE_MODE_T])
21
22 dnl Whether to enable precise timestamps in 'struct stat'.
23 m4_ifdef([gl_WINDOWS_STAT_TIMESPEC], [
24 AC_REQUIRE([gl_WINDOWS_STAT_TIMESPEC])
25 ], [
26 WINDOWS_STAT_TIMESPEC=0
27 ])
28 AC_SUBST([WINDOWS_STAT_TIMESPEC])
29
30 dnl Whether to ensure that struct stat.st_size is 64-bit wide.
31 m4_ifdef([gl_LARGEFILE], [
32 AC_REQUIRE([gl_LARGEFILE])
33 ], [
34 WINDOWS_64_BIT_ST_SIZE=0
35 ])
36 AC_SUBST([WINDOWS_64_BIT_ST_SIZE])
37
38 dnl Define types that are supposed to be defined in <sys/types.h> or
39 dnl <sys/stat.h>.
40 AC_CHECK_TYPE([nlink_t], [],
41 [AC_DEFINE([nlink_t], [int],
42 [Define to the type of st_nlink in struct stat, or a supertype.])],
43 [#include <sys/types.h>
44 #include <sys/stat.h>])
45
46 dnl Check for declarations of anything we want to poison if the
47 dnl corresponding gnulib module is not in use.
48 gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
49 ]], [chmod fchmodat fstat fstatat futimens getumask lchmod lstat
50 mkdirat mkfifo mkfifoat mknod mknodat stat utimensat])
51
52 AC_REQUIRE([AC_C_RESTRICT])
53])
54
55# gl_SYS_STAT_MODULE_INDICATOR([modulename])
56# sets the shell variable that indicates the presence of the given module
57# to a C preprocessor expression that will evaluate to 1.
58# This macro invocation must not occur in macros that are AC_REQUIREd.
59AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
60[
61 dnl Ensure to expand the default settings once only.
62 gl_SYS_STAT_H_REQUIRE_DEFAULTS
63 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
64 dnl Define it also as a C macro, for the benefit of the unit tests.
65 gl_MODULE_INDICATOR_FOR_TESTS([$1])
66])
67
68# Initializes the default values for AC_SUBSTed shell variables.
69# This macro must not be AC_REQUIREd. It must only be invoked, and only
70# outside of macros or in macros that are not AC_REQUIREd.
71AC_DEFUN([gl_SYS_STAT_H_REQUIRE_DEFAULTS],
72[
73 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS], [
74 gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
75 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHMOD])
76 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHMODAT])
77 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTAT])
78 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSTATAT])
79 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FUTIMENS])
80 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUMASK])
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHMOD])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSTAT])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIR])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDIRAT])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFO])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKFIFOAT])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNOD])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKNODAT])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STAT])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UTIMENSAT])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OVERRIDES_STRUCT_STAT])
92 dnl Support Microsoft deprecated alias function names by default.
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHMOD], [1])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_MKDIR], [1])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UMASK], [1])
96 ])
97 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_STAT_H_MODULE_INDICATOR_DEFAULTS])
98 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
99])
100
101AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
102[
103 dnl Assume proper GNU behavior unless another module says otherwise.
104 HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
105 HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
106 HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS])
107 HAVE_GETUMASK=1; AC_SUBST([HAVE_GETUMASK])
108 HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
109 HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
110 HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
111 HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO])
112 HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
113 HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
114 HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
115 HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
116 REPLACE_CHMOD=0; AC_SUBST([REPLACE_CHMOD])
117 REPLACE_FCHMODAT=0; AC_SUBST([REPLACE_FCHMODAT])
118 REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
119 REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
120 REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
121 REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
122 REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
123 REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO])
124 REPLACE_MKFIFOAT=0; AC_SUBST([REPLACE_MKFIFOAT])
125 REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD])
126 REPLACE_MKNODAT=0; AC_SUBST([REPLACE_MKNODAT])
127 REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
128 REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT])
129])
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
index d15c1b3..627671f 100644
--- a/gl/m4/sys_types_h.m4
+++ b/gl/m4/sys_types_h.m4
@@ -1,5 +1,5 @@
1# sys_types_h.m4 serial 5 1# sys_types_h.m4 serial 13
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,6 +7,10 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN_ONCE([gl_SYS_TYPES_H], 7AC_DEFUN_ONCE([gl_SYS_TYPES_H],
8[ 8[
9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) 9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
10
11 dnl Use sane struct stat types in OpenVMS 8.2 and later.
12 AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.])
13
10 gl_NEXT_HEADERS([sys/types.h]) 14 gl_NEXT_HEADERS([sys/types.h])
11 15
12 dnl Ensure the type pid_t gets defined. 16 dnl Ensure the type pid_t gets defined.
@@ -17,8 +21,50 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
17 21
18 dnl Whether to override the 'off_t' type. 22 dnl Whether to override the 'off_t' type.
19 AC_REQUIRE([gl_TYPE_OFF_T]) 23 AC_REQUIRE([gl_TYPE_OFF_T])
24
25 dnl Whether to override the 'dev_t' and 'ino_t' types.
26 m4_ifdef([gl_WINDOWS_STAT_INODES], [
27 AC_REQUIRE([gl_WINDOWS_STAT_INODES])
28 ], [
29 WINDOWS_STAT_INODES=0
30 ])
31 AC_SUBST([WINDOWS_STAT_INODES])
32])
33
34# Initializes the default values for AC_SUBSTed shell variables.
35# This macro must not be AC_REQUIREd. It must only be invoked, and only
36# outside of macros or in macros that are not AC_REQUIREd.
37AC_DEFUN([gl_SYS_TYPES_H_REQUIRE_DEFAULTS],
38[
39 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS], [
40 ])
41 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_TYPE_H_MODULE_INDICATOR_DEFAULTS])
42 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
20]) 43])
21 44
22AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], 45AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
23[ 46[
24]) 47])
48
49# This works around a buggy version in autoconf <= 2.69.
50# See <https://lists.gnu.org/r/autoconf/2016-08/msg00014.html>
51# The 2.70 version isn't quoted properly, so override it too.
52
53m4_version_prereq([2.70.1], [], [
54
55m4_undefine([AC_HEADER_MAJOR])
56AC_DEFUN([AC_HEADER_MAJOR],
57[AC_CHECK_HEADERS_ONCE([sys/types.h])
58AC_CHECK_HEADER([sys/mkdev.h],
59 [AC_DEFINE([MAJOR_IN_MKDEV], [1],
60 [Define to 1 if `major', `minor', and `makedev' are
61 declared in <mkdev.h>.])])
62if test $ac_cv_header_sys_mkdev_h = no; then
63 AC_CHECK_HEADER([sys/sysmacros.h],
64 [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
65 [Define to 1 if `major', `minor', and `makedev'
66 are declared in <sysmacros.h>.])])
67fi
68])# AC_HEADER_MAJOR
69
70])
diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4
index c75cbbd..93a65d2 100644
--- a/gl/m4/sys_uio_h.m4
+++ b/gl/m4/sys_uio_h.m4
@@ -1,10 +1,10 @@
1# sys_uio_h.m4 serial 1 1# sys_uio_h.m4 serial 3
2dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_HEADER_SYS_UIO], 7AC_DEFUN_ONCE([gl_SYS_UIO_H],
8[ 8[
9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK. 10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK.
@@ -17,15 +17,30 @@ AC_DEFUN([gl_HEADER_SYS_UIO],
17 AC_SUBST([HAVE_SYS_UIO_H]) 17 AC_SUBST([HAVE_SYS_UIO_H])
18]) 18])
19 19
20# gl_SYS_UIO_MODULE_INDICATOR([modulename])
21# sets the shell variable that indicates the presence of the given module
22# to a C preprocessor expression that will evaluate to 1.
23# This macro invocation must not occur in macros that are AC_REQUIREd.
20AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR], 24AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR],
21[ 25[
22 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 26 dnl Ensure to expand the default settings once only.
23 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 27 gl_SYS_UIO_H_REQUIRE_DEFAULTS
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 28 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests. 29 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 30 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27]) 31])
28 32
33# Initializes the default values for AC_SUBSTed shell variables.
34# This macro must not be AC_REQUIREd. It must only be invoked, and only
35# outside of macros or in macros that are not AC_REQUIREd.
36AC_DEFUN([gl_SYS_UIO_H_REQUIRE_DEFAULTS],
37[
38 m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS], [
39 ])
40 m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_UIO_H_MODULE_INDICATOR_DEFAULTS])
41 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
42])
43
29AC_DEFUN([gl_SYS_UIO_H_DEFAULTS], 44AC_DEFUN([gl_SYS_UIO_H_DEFAULTS],
30[ 45[
31]) 46])
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 26bdeb5..b536b04 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,11 +1,390 @@
1# threadlib.m4 serial 10 (gettext-0.18.2) 1# threadlib.m4 serial 32a
2dnl Copyright (C) 2005-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ([2.60])
10
11dnl The general structure of the multithreading modules in gnulib is that we
12dnl have three set of modules:
13dnl
14dnl * POSIX API:
15dnl pthread, which combines
16dnl pthread-h
17dnl pthread-thread
18dnl pthread-once
19dnl pthread-mutex
20dnl pthread-rwlock
21dnl pthread-cond
22dnl pthread-tss
23dnl pthread-spin
24dnl sched_yield
25dnl
26dnl * ISO C API:
27dnl threads, which combines
28dnl threads-h
29dnl thrd
30dnl mtx
31dnl cnd
32dnl tss
33dnl
34dnl * Gnulib API, with an implementation that can be chosen at configure
35dnl time through the option --enable-threads=...
36dnl thread
37dnl lock
38dnl cond
39dnl tls
40dnl yield
41dnl
42dnl They are independent, except for the fact that
43dnl - the implementation of the ISO C API may use the POSIX (or some other
44dnl platform dependent) API,
45dnl - the implementation of the Gnulib API may use the POSIX or ISO C or
46dnl some other platform dependent API, depending on the --enable-threads
47dnl option.
48dnl
49dnl This file contains macros for all of these APIs!
50
51dnl ============================================================================
52dnl Macros for all thread APIs
53
54AC_DEFUN([gl_ANYTHREADLIB_EARLY],
55[
56 AC_REQUIRE([AC_CANONICAL_HOST])
57 if test -z "$gl_anythreadlib_early_done"; then
58 case "$host_os" in
59 osf*)
60 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
61 # groks <pthread.h>. cc also understands the flag -pthread, but
62 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
63 # 2. putting a flag into CPPFLAGS that has an effect on the linker
64 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
65 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
66 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
67 ;;
68 esac
69 # Some systems optimize for single-threaded programs by default, and
70 # need special flags to disable these optimizations. For example, the
71 # definition of 'errno' in <errno.h>.
72 case "$host_os" in
73 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
74 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
75 esac
76 gl_anythreadlib_early_done=done
77 fi
78])
79
80dnl Checks whether the compiler and linker support weak declarations of symbols.
81
82AC_DEFUN([gl_WEAK_SYMBOLS],
83[
84 AC_REQUIRE([AC_CANONICAL_HOST])
85 AC_CACHE_CHECK([whether imported symbols can be declared weak],
86 [gl_cv_have_weak],
87 [case "$host_os" in
88 cygwin*)
89 dnl On Cygwin 3.2.0 with gcc 10.2, the test below would succeed, but
90 dnl programs that use pthread_in_use() with weak symbol references
91 dnl crash miserably at runtime.
92 gl_cv_have_weak="guessing no"
93 ;;
94 *)
95 gl_cv_have_weak=no
96 dnl First, test whether the compiler accepts it syntactically.
97 AC_LINK_IFELSE(
98 [AC_LANG_PROGRAM(
99 [[extern void xyzzy ();
100#pragma weak xyzzy]],
101 [[xyzzy();]])],
102 [gl_cv_have_weak=maybe])
103 if test $gl_cv_have_weak = maybe; then
104 dnl Second, test whether it actually works. On Cygwin 1.7.2, with
105 dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
106 AC_RUN_IFELSE(
107 [AC_LANG_SOURCE([[
108#include <stdio.h>
109#pragma weak fputs
110int main ()
111{
112 return (fputs == NULL);
113}]])],
114 [gl_cv_have_weak=yes],
115 [gl_cv_have_weak=no],
116 [dnl When cross-compiling, assume that only ELF platforms support
117 dnl weak symbols.
118 AC_EGREP_CPP([Extensible Linking Format],
119 [#ifdef __ELF__
120 Extensible Linking Format
121 #endif
122 ],
123 [gl_cv_have_weak="guessing yes"],
124 [gl_cv_have_weak="guessing no"])
125 ])
126 fi
127 ;;
128 esac
129 dnl But when linking statically, weak symbols don't work.
130 case " $LDFLAGS " in
131 *" -static "*) gl_cv_have_weak=no ;;
132 esac
133 dnl Test for a bug in FreeBSD 11: A link error occurs when using a weak
134 dnl symbol and linking against a shared library that has a dependency on
135 dnl the shared library that defines the symbol.
136 case "$gl_cv_have_weak" in
137 *yes)
138 case "$host_os" in
139 freebsd* | dragonfly* | midnightbsd*)
140 : > conftest1.c
141 $CC $CPPFLAGS $CFLAGS $LDFLAGS -fPIC -shared -o libempty.so conftest1.c -lpthread >&AS_MESSAGE_LOG_FD 2>&1
142 cat <<EOF > conftest2.c
143#include <pthread.h>
144#pragma weak pthread_mutexattr_gettype
145int main ()
146{
147 return (pthread_mutexattr_gettype != NULL);
148}
149EOF
150 $CC $CPPFLAGS $CFLAGS $LDFLAGS -o conftest conftest2.c libempty.so >&AS_MESSAGE_LOG_FD 2>&1 \
151 || gl_cv_have_weak=no
152 rm -f conftest1.c libempty.so conftest2.c conftest
153 ;;
154 esac
155 ;;
156 esac
157 ])
158 case "$gl_cv_have_weak" in
159 *yes)
160 AC_DEFINE([HAVE_WEAK_SYMBOLS], [1],
161 [Define to 1 if the compiler and linker support weak declarations of symbols.])
162 ;;
163 esac
164])
165
166dnl ============================================================================
167dnl Macros for the POSIX API
168
169dnl gl_PTHREADLIB
170dnl -------------
171dnl Tests for the libraries needs for using the POSIX threads API.
172dnl Sets the variable LIBPTHREAD to the linker options for use in a Makefile.
173dnl Sets the variable LIBPMULTITHREAD, for programs that really need
174dnl multithread functionality. The difference between LIBPTHREAD and
175dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically
176dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not.
177dnl Sets the variable LIB_SCHED_YIELD to the linker options needed to use the
178dnl sched_yield() function.
179dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
180dnl multithread-safe programs.
181dnl Defines the C macro HAVE_PTHREAD_API if (at least parts of) the POSIX
182dnl threads API is available.
183
184dnl The guts of gl_PTHREADLIB. Needs to be expanded only once.
185
186AC_DEFUN([gl_PTHREADLIB_BODY],
187[
188 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
189 if test -z "$gl_pthreadlib_body_done"; then
190 gl_pthread_api=no
191 LIBPTHREAD=
192 LIBPMULTITHREAD=
193 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
194 # it groks <pthread.h>. It's added above, in gl_ANYTHREADLIB_EARLY.
195 AC_CHECK_HEADER([pthread.h],
196 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
197 if test "$gl_have_pthread_h" = yes; then
198 # Other possible tests:
199 # -lpthreads (FSU threads, PCthreads)
200 # -lgthreads
201 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
202 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
203 # the second one only in libpthread, and lock.c needs it.
204 #
205 # If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
206 # needs -pthread for some reason. See:
207 # https://lists.gnu.org/r/bug-gnulib/2014-09/msg00023.html
208 save_LIBS=$LIBS
209 for gl_pthread in '' '-pthread'; do
210 LIBS="$LIBS $gl_pthread"
211 AC_LINK_IFELSE(
212 [AC_LANG_PROGRAM(
213 [[#include <pthread.h>
214 pthread_mutex_t m;
215 pthread_mutexattr_t ma;
216 ]],
217 [[pthread_mutex_lock (&m);
218 pthread_mutexattr_init (&ma);]])],
219 [gl_pthread_api=yes
220 LIBPTHREAD=$gl_pthread
221 LIBPMULTITHREAD=$gl_pthread])
222 LIBS=$save_LIBS
223 test $gl_pthread_api = yes && break
224 done
225 echo "$as_me:__oline__: gl_pthread_api=$gl_pthread_api" >&AS_MESSAGE_LOG_FD
226 echo "$as_me:__oline__: LIBPTHREAD=$LIBPTHREAD" >&AS_MESSAGE_LOG_FD
227
228 gl_pthread_in_glibc=no
229 # On Linux with glibc >= 2.34, libc contains the fully functional
230 # pthread functions.
231 case "$host_os" in
232 linux*)
233 AC_EGREP_CPP([Lucky user],
234 [#include <features.h>
235 #ifdef __GNU_LIBRARY__
236 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) || (__GLIBC__ > 2)
237 Lucky user
238 #endif
239 #endif
240 ],
241 [gl_pthread_in_glibc=yes],
242 [])
243 ;;
244 esac
245 echo "$as_me:__oline__: gl_pthread_in_glibc=$gl_pthread_in_glibc" >&AS_MESSAGE_LOG_FD
246
247 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
248 # since it is defined as a macro on OSF/1.)
249 if test $gl_pthread_api = yes && test -z "$LIBPTHREAD"; then
250 # The program links fine without libpthread. But it may actually
251 # need to link with libpthread in order to create multiple threads.
252 AC_CHECK_LIB([pthread], [pthread_kill],
253 [if test $gl_pthread_in_glibc = yes; then
254 LIBPMULTITHREAD=
255 else
256 LIBPMULTITHREAD=-lpthread
257 # On Solaris and HP-UX, most pthread functions exist also in libc.
258 # Therefore pthread_in_use() needs to actually try to create a
259 # thread: pthread_create from libc will fail, whereas
260 # pthread_create will actually create a thread.
261 # On Solaris 10 or newer, this test is no longer needed, because
262 # libc contains the fully functional pthread functions.
263 case "$host_os" in
264changequote(,)dnl
265 solaris | solaris2.[1-9] | solaris2.[1-9].* | hpux*)
266changequote([,])dnl
267 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
268 [Define if the pthread_in_use() detection is hard.])
269 esac
270 fi
271 ])
272 elif test $gl_pthread_api != yes; then
273 # Some library is needed. Try libpthread and libc_r.
274 AC_CHECK_LIB([pthread], [pthread_kill],
275 [gl_pthread_api=yes
276 LIBPTHREAD=-lpthread
277 LIBPMULTITHREAD=-lpthread])
278 if test $gl_pthread_api != yes; then
279 # For FreeBSD 4.
280 AC_CHECK_LIB([c_r], [pthread_kill],
281 [gl_pthread_api=yes
282 LIBPTHREAD=-lc_r
283 LIBPMULTITHREAD=-lc_r])
284 fi
285 fi
286 echo "$as_me:__oline__: LIBPMULTITHREAD=$LIBPMULTITHREAD" >&AS_MESSAGE_LOG_FD
287 fi
288 AC_MSG_CHECKING([whether POSIX threads API is available])
289 AC_MSG_RESULT([$gl_pthread_api])
290 AC_SUBST([LIBPTHREAD])
291 AC_SUBST([LIBPMULTITHREAD])
292 if test $gl_pthread_api = yes; then
293 AC_DEFINE([HAVE_PTHREAD_API], [1],
294 [Define if you have the <pthread.h> header and the POSIX threads API.])
295 fi
296
297 dnl On some systems, sched_yield is in librt, rather than in libpthread.
298 AC_LINK_IFELSE(
299 [AC_LANG_PROGRAM(
300 [[#include <sched.h>]],
301 [[sched_yield ();]])],
302 [LIB_SCHED_YIELD=
303 ],
304 [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
305 AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt],
306 [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
307 AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])])
308 ])
309 AC_SUBST([LIB_SCHED_YIELD])
310
311 gl_pthreadlib_body_done=done
312 fi
313])
314
315AC_DEFUN([gl_PTHREADLIB],
316[
317 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
318 gl_PTHREADLIB_BODY
319])
320
321dnl ============================================================================
322dnl Macros for the ISO C API
323
324dnl gl_STDTHREADLIB
325dnl ---------------
326dnl Tests for the libraries needs for using the ISO C threads API.
327dnl Sets the variable LIBSTDTHREAD to the linker options for use in a Makefile.
328dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
329dnl multithread-safe programs.
330dnl Defines the C macro HAVE_THREADS_H if (at least parts of) the ISO C threads
331dnl API is available.
332
333dnl The guts of gl_STDTHREADLIB. Needs to be expanded only once.
334
335AC_DEFUN([gl_STDTHREADLIB_BODY],
336[
337 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
338 AC_REQUIRE([AC_CANONICAL_HOST])
339 if test -z "$gl_stdthreadlib_body_done"; then
340 AC_CHECK_HEADERS_ONCE([threads.h])
341
342 case "$host_os" in
343 mingw*)
344 LIBSTDTHREAD=
345 ;;
346 *)
347 gl_PTHREADLIB_BODY
348 if test $ac_cv_header_threads_h = yes; then
349 dnl glibc >= 2.29 has thrd_create in libpthread.
350 dnl FreeBSD >= 10 has thrd_create in libstdthreads; this library depends
351 dnl on libpthread (for the symbol 'pthread_mutexattr_gettype').
352 dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in
353 dnl libc.
354 AC_CHECK_FUNCS([thrd_create])
355 if test $ac_cv_func_thrd_create = yes; then
356 LIBSTDTHREAD=
357 else
358 AC_CHECK_LIB([stdthreads], [thrd_create], [
359 LIBSTDTHREAD='-lstdthreads -lpthread'
360 ], [
361 dnl Guess that thrd_create is in libpthread.
362 LIBSTDTHREAD="$LIBPMULTITHREAD"
363 ])
364 fi
365 else
366 dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c.
367 LIBSTDTHREAD="$LIBPMULTITHREAD $LIB_SCHED_YIELD"
368 fi
369 ;;
370 esac
371 AC_SUBST([LIBSTDTHREAD])
372
373 AC_MSG_CHECKING([whether ISO C threads API is available])
374 AC_MSG_RESULT([$ac_cv_header_threads_h])
375 gl_stdthreadlib_body_done=done
376 fi
377])
378
379AC_DEFUN([gl_STDTHREADLIB],
380[
381 AC_REQUIRE([gl_ANYTHREADLIB_EARLY])
382 gl_STDTHREADLIB_BODY
383])
384
385dnl ============================================================================
386dnl Macros for the Gnulib API
387
9dnl gl_THREADLIB 388dnl gl_THREADLIB
10dnl ------------ 389dnl ------------
11dnl Tests for a multithreading library to be used. 390dnl Tests for a multithreading library to be used.
@@ -14,17 +393,25 @@ dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
14dnl default is 'no', otherwise it is system dependent. In both cases, the user 393dnl default is 'no', otherwise it is system dependent. In both cases, the user
15dnl can change the choice through the options --enable-threads=choice or 394dnl can change the choice through the options --enable-threads=choice or
16dnl --disable-threads. 395dnl --disable-threads.
17dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, 396dnl Defines at most one of the macros USE_ISOC_THREADS, USE_POSIX_THREADS,
18dnl USE_PTH_THREADS, USE_WINDOWS_THREADS 397dnl USE_ISOC_AND_POSIX_THREADS, USE_WINDOWS_THREADS.
398dnl The choice --enable-threads=isoc+posix is available only on platforms that
399dnl have both the ISO C and the POSIX threads APIs. It has the effect of using
400dnl the ISO C API for most things and the POSIX API only for creating and
401dnl controlling threads (because there is no equivalent to pthread_atfork in
402dnl the ISO C API).
19dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use 403dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
20dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with 404dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
21dnl libtool). 405dnl libtool).
22dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for 406dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
23dnl programs that really need multithread functionality. The difference 407dnl programs that really need multithread functionality. The difference
24dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak 408dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
25dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". 409dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not.
26dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for 410dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
27dnl multithread-safe programs. 411dnl multithread-safe programs.
412dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the
413dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the
414dnl same value. Only system libraries are needed.
28 415
29AC_DEFUN([gl_THREADLIB_EARLY], 416AC_DEFUN([gl_THREADLIB_EARLY],
30[ 417[
@@ -43,18 +430,15 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
43 430
44 AC_REQUIRE([AC_CANONICAL_HOST]) 431 AC_REQUIRE([AC_CANONICAL_HOST])
45 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems. 432 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
46 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes 433 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
47 dnl AC_GNU_SOURCE.
48 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
49 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
50 [AC_REQUIRE([AC_GNU_SOURCE])])
51 dnl Check for multithreading. 434 dnl Check for multithreading.
52 m4_ifdef([gl_THREADLIB_DEFAULT_NO], 435 m4_ifdef([gl_THREADLIB_DEFAULT_NO],
53 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], 436 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
54 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) 437 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
438 m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=])
55 AC_ARG_ENABLE([threads], 439 AC_ARG_ENABLE([threads],
56AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ 440AS_HELP_STRING([--enable-threads={isoc|posix|isoc+posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
57AC_HELP_STRING([--disable-threads], [build without multithread safety])]), 441AS_HELP_STRING([--disable-threads], [build without multithread safety])]),
58 [gl_use_threads=$enableval], 442 [gl_use_threads=$enableval],
59 [if test -n "$gl_use_threads_default"; then 443 [if test -n "$gl_use_threads_default"; then
60 gl_use_threads="$gl_use_threads_default" 444 gl_use_threads="$gl_use_threads_default"
@@ -64,41 +448,35 @@ changequote(,)dnl
64 dnl Disable multithreading by default on OSF/1, because it interferes 448 dnl Disable multithreading by default on OSF/1, because it interferes
65 dnl with fork()/exec(): When msgexec is linked with -lpthread, its 449 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
66 dnl child process gets an endless segmentation fault inside execvp(). 450 dnl child process gets an endless segmentation fault inside execvp().
451 osf*) gl_use_threads=no ;;
67 dnl Disable multithreading by default on Cygwin 1.5.x, because it has 452 dnl Disable multithreading by default on Cygwin 1.5.x, because it has
68 dnl bugs that lead to endless loops or crashes. See 453 dnl bugs that lead to endless loops or crashes. See
69 dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>. 454 dnl <https://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
70 osf*) gl_use_threads=no ;;
71 cygwin*) 455 cygwin*)
72 case `uname -r` in 456 case `uname -r` in
73 1.[0-5].*) gl_use_threads=no ;; 457 1.[0-5].*) gl_use_threads=no ;;
74 *) gl_use_threads=yes ;; 458 *) gl_use_threads=yes ;;
75 esac 459 esac
76 ;; 460 ;;
461 dnl Obey gl_AVOID_WINPTHREAD on mingw.
462 mingw*)
463 case "$gl_use_winpthreads_default" in
464 yes) gl_use_threads=posix ;;
465 no) gl_use_threads=windows ;;
466 *) gl_use_threads=yes ;;
467 esac
468 ;;
77 *) gl_use_threads=yes ;; 469 *) gl_use_threads=yes ;;
78 esac 470 esac
79changequote([,])dnl 471changequote([,])dnl
80 fi 472 fi
81 ]) 473 ])
82 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then 474 if test "$gl_use_threads" = yes \
83 # For using <pthread.h>: 475 || test "$gl_use_threads" = isoc \
84 case "$host_os" in 476 || test "$gl_use_threads" = posix \
85 osf*) 477 || test "$gl_use_threads" = isoc+posix; then
86 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it 478 # For using <threads.h> or <pthread.h>:
87 # groks <pthread.h>. cc also understands the flag -pthread, but 479 gl_ANYTHREADLIB_EARLY
88 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
89 # 2. putting a flag into CPPFLAGS that has an effect on the linker
90 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
91 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
92 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
93 ;;
94 esac
95 # Some systems optimize for single-threaded programs by default, and
96 # need special flags to disable these optimizations. For example, the
97 # definition of 'errno' in <errno.h>.
98 case "$host_os" in
99 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
100 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
101 esac
102 fi 480 fi
103]) 481])
104 482
@@ -114,168 +492,69 @@ AC_DEFUN([gl_THREADLIB_BODY],
114 LTLIBMULTITHREAD= 492 LTLIBMULTITHREAD=
115 if test "$gl_use_threads" != no; then 493 if test "$gl_use_threads" != no; then
116 dnl Check whether the compiler and linker support weak declarations. 494 dnl Check whether the compiler and linker support weak declarations.
117 AC_CACHE_CHECK([whether imported symbols can be declared weak], 495 gl_WEAK_SYMBOLS
118 [gl_cv_have_weak], 496 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
119 [gl_cv_have_weak=no 497 dnl If we use weak symbols to implement pthread_in_use / pth_in_use /
120 dnl First, test whether the compiler accepts it syntactically. 498 dnl thread_in_use, we also need to test whether the ISO C 11 thrd_create
121 AC_LINK_IFELSE( 499 dnl facility is in use.
122 [AC_LANG_PROGRAM( 500 AC_CHECK_HEADERS_ONCE([threads.h])
123 [[extern void xyzzy (); 501 :
124#pragma weak xyzzy]], 502 fi
125 [[xyzzy();]])], 503 if test "$gl_use_threads" = isoc || test "$gl_use_threads" = isoc+posix; then
126 [gl_cv_have_weak=maybe]) 504 AC_CHECK_HEADERS_ONCE([threads.h])
127 if test $gl_cv_have_weak = maybe; then 505 gl_have_isoc_threads="$ac_cv_header_threads_h"
128 dnl Second, test whether it actually works. On Cygwin 1.7.2, with 506 fi
129 dnl gcc 4.3, symbols declared weak always evaluate to the address 0. 507 if test "$gl_use_threads" = yes \
130 AC_RUN_IFELSE( 508 || test "$gl_use_threads" = posix \
131 [AC_LANG_SOURCE([[ 509 || test "$gl_use_threads" = isoc+posix; then
132#include <stdio.h> 510 gl_PTHREADLIB_BODY
133#pragma weak fputs 511 LIBTHREAD=$LIBPTHREAD LTLIBTHREAD=$LIBPTHREAD
134int main () 512 LIBMULTITHREAD=$LIBPMULTITHREAD LTLIBMULTITHREAD=$LIBPMULTITHREAD
135{ 513 if test $gl_pthread_api = yes; then
136 return (fputs == NULL); 514 if test "$gl_use_threads" = isoc+posix && test "$gl_have_isoc_threads" = yes; then
137}]])], 515 gl_threads_api='isoc+posix'
138 [gl_cv_have_weak=yes], 516 AC_DEFINE([USE_ISOC_AND_POSIX_THREADS], [1],
139 [gl_cv_have_weak=no], 517 [Define if the combination of the ISO C and POSIX multithreading APIs can be used.])
140 [dnl When cross-compiling, assume that only ELF platforms support 518 LIBTHREAD= LTLIBTHREAD=
141 dnl weak symbols.
142 AC_EGREP_CPP([Extensible Linking Format],
143 [#ifdef __ELF__
144 Extensible Linking Format
145 #endif
146 ],
147 [gl_cv_have_weak="guessing yes"],
148 [gl_cv_have_weak="guessing no"])
149 ])
150 fi
151 ])
152 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
153 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
154 # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
155 AC_CHECK_HEADER([pthread.h],
156 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
157 if test "$gl_have_pthread_h" = yes; then
158 # Other possible tests:
159 # -lpthreads (FSU threads, PCthreads)
160 # -lgthreads
161 gl_have_pthread=
162 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
163 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
164 # the second one only in libpthread, and lock.c needs it.
165 AC_LINK_IFELSE(
166 [AC_LANG_PROGRAM(
167 [[#include <pthread.h>]],
168 [[pthread_mutex_lock((pthread_mutex_t*)0);
169 pthread_mutexattr_init((pthread_mutexattr_t*)0);]])],
170 [gl_have_pthread=yes])
171 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
172 # since it is defined as a macro on OSF/1.)
173 if test -n "$gl_have_pthread"; then
174 # The program links fine without libpthread. But it may actually
175 # need to link with libpthread in order to create multiple threads.
176 AC_CHECK_LIB([pthread], [pthread_kill],
177 [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
178 # On Solaris and HP-UX, most pthread functions exist also in libc.
179 # Therefore pthread_in_use() needs to actually try to create a
180 # thread: pthread_create from libc will fail, whereas
181 # pthread_create will actually create a thread.
182 case "$host_os" in
183 solaris* | hpux*)
184 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
185 [Define if the pthread_in_use() detection is hard.])
186 esac
187 ])
188 else 519 else
189 # Some library is needed. Try libpthread and libc_r.
190 AC_CHECK_LIB([pthread], [pthread_kill],
191 [gl_have_pthread=yes
192 LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
193 LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
194 if test -z "$gl_have_pthread"; then
195 # For FreeBSD 4.
196 AC_CHECK_LIB([c_r], [pthread_kill],
197 [gl_have_pthread=yes
198 LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
199 LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
200 fi
201 fi
202 if test -n "$gl_have_pthread"; then
203 gl_threads_api=posix 520 gl_threads_api=posix
204 AC_DEFINE([USE_POSIX_THREADS], [1], 521 AC_DEFINE([USE_POSIX_THREADS], [1],
205 [Define if the POSIX multithreading library can be used.]) 522 [Define if the POSIX multithreading library can be used.])
206 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then 523 if test -z "$LIBMULTITHREAD" && test -z "$LTLIBMULTITHREAD"; then
524 AC_DEFINE([USE_POSIX_THREADS_FROM_LIBC], [1],
525 [Define if references to the POSIX multithreading library are satisfied by libc.])
526 else
207 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then 527 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
208 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], 528 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
209 [Define if references to the POSIX multithreading library should be made weak.]) 529 [Define if references to the POSIX multithreading library should be made weak.])
210 LIBTHREAD= 530 LIBTHREAD= LTLIBTHREAD=
211 LTLIBTHREAD= 531 else
532 case "$host_os" in
533 freebsd* | dragonfly* | midnightbsd*)
534 if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then
535 dnl If weak symbols can't tell whether pthread_create(), pthread_key_create()
536 dnl etc. will succeed, we need a runtime test.
537 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
538 [Define if the pthread_in_use() detection is hard.])
539 fi
540 ;;
541 esac
212 fi 542 fi
213 fi 543 fi
214 fi 544 fi
215 fi 545 fi
216 fi 546 fi
217 if test -z "$gl_have_pthread"; then 547 if test $gl_threads_api = none; then
218 if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then 548 if test "$gl_use_threads" = isoc && test "$gl_have_isoc_threads" = yes; then
219 gl_have_solaristhread= 549 gl_STDTHREADLIB_BODY
220 gl_save_LIBS="$LIBS" 550 LIBTHREAD=$LIBSTDTHREAD LTLIBTHREAD=$LIBSTDTHREAD
221 LIBS="$LIBS -lthread" 551 LIBMULTITHREAD=$LIBSTDTHREAD LTLIBMULTITHREAD=$LIBSTDTHREAD
222 AC_LINK_IFELSE( 552 gl_threads_api=isoc
223 [AC_LANG_PROGRAM( 553 AC_DEFINE([USE_ISOC_THREADS], [1],
224 [[ 554 [Define if the ISO C multithreading library can be used.])
225#include <thread.h>
226#include <synch.h>
227 ]],
228 [[thr_self();]])],
229 [gl_have_solaristhread=yes])
230 LIBS="$gl_save_LIBS"
231 if test -n "$gl_have_solaristhread"; then
232 gl_threads_api=solaris
233 LIBTHREAD=-lthread
234 LTLIBTHREAD=-lthread
235 LIBMULTITHREAD="$LIBTHREAD"
236 LTLIBMULTITHREAD="$LTLIBTHREAD"
237 AC_DEFINE([USE_SOLARIS_THREADS], [1],
238 [Define if the old Solaris multithreading library can be used.])
239 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
240 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
241 [Define if references to the old Solaris multithreading library should be made weak.])
242 LIBTHREAD=
243 LTLIBTHREAD=
244 fi
245 fi
246 fi 555 fi
247 fi 556 fi
248 if test "$gl_use_threads" = pth; then 557 if test $gl_threads_api = none; then
249 gl_save_CPPFLAGS="$CPPFLAGS"
250 AC_LIB_LINKFLAGS([pth])
251 gl_have_pth=
252 gl_save_LIBS="$LIBS"
253 LIBS="$LIBS $LIBPTH"
254 AC_LINK_IFELSE(
255 [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
256 [gl_have_pth=yes])
257 LIBS="$gl_save_LIBS"
258 if test -n "$gl_have_pth"; then
259 gl_threads_api=pth
260 LIBTHREAD="$LIBPTH"
261 LTLIBTHREAD="$LTLIBPTH"
262 LIBMULTITHREAD="$LIBTHREAD"
263 LTLIBMULTITHREAD="$LTLIBTHREAD"
264 AC_DEFINE([USE_PTH_THREADS], [1],
265 [Define if the GNU Pth multithreading library can be used.])
266 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
267 if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
268 AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
269 [Define if references to the GNU Pth multithreading library should be made weak.])
270 LIBTHREAD=
271 LTLIBTHREAD=
272 fi
273 fi
274 else
275 CPPFLAGS="$gl_save_CPPFLAGS"
276 fi
277 fi
278 if test -z "$gl_have_pthread"; then
279 case "$gl_use_threads" in 558 case "$gl_use_threads" in
280 yes | windows | win32) # The 'win32' is for backward compatibility. 559 yes | windows | win32) # The 'win32' is for backward compatibility.
281 if { case "$host_os" in 560 if { case "$host_os" in
@@ -317,6 +596,21 @@ AC_DEFUN([gl_DISABLE_THREADS], [
317]) 596])
318 597
319 598
599dnl gl_AVOID_WINPTHREAD
600dnl -------------------
601dnl Sets the gl_THREADLIB default so that on mingw, a dependency to the
602dnl libwinpthread DLL (mingw-w64 winpthreads library) is avoided.
603dnl The user can still override it at installation time, by using the
604dnl configure option '--enable-threads'.
605
606AC_DEFUN([gl_AVOID_WINPTHREAD], [
607 m4_divert_text([INIT_PREPARE], [gl_use_winpthreads_default=no])
608])
609
610
611dnl ============================================================================
612
613
320dnl Survey of platforms: 614dnl Survey of platforms:
321dnl 615dnl
322dnl Platform Available Compiler Supports test-lock 616dnl Platform Available Compiler Supports test-lock
@@ -324,7 +618,11 @@ dnl flavours option weak result
324dnl --------------- --------- --------- -------- --------- 618dnl --------------- --------- --------- -------- ---------
325dnl Linux 2.4/glibc posix -lpthread Y OK 619dnl Linux 2.4/glibc posix -lpthread Y OK
326dnl 620dnl
327dnl GNU Hurd/glibc posix 621dnl Linux/glibc 2.34 posix Y OK
622dnl
623dnl GNU Hurd/glibc posix -lpthread Y OK
624dnl
625dnl Ubuntu 14.04 posix -pthread Y OK
328dnl 626dnl
329dnl FreeBSD 5.3 posix -lc_r Y 627dnl FreeBSD 5.3 posix -lc_r Y
330dnl posix -lkse ? Y 628dnl posix -lkse ? Y
@@ -344,7 +642,6 @@ dnl
344dnl Mac OS X 10.[123] posix -lpthread Y OK 642dnl Mac OS X 10.[123] posix -lpthread Y OK
345dnl 643dnl
346dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK 644dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
347dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
348dnl 645dnl
349dnl HP-UX 11 posix -lpthread N (cc) OK 646dnl HP-UX 11 posix -lpthread N (cc) OK
350dnl Y (gcc) 647dnl Y (gcc)
@@ -358,8 +655,6 @@ dnl -lpthread (gcc) Y
358dnl 655dnl
359dnl Cygwin posix -lpthread Y OK 656dnl Cygwin posix -lpthread Y OK
360dnl 657dnl
361dnl Any of the above pth -lpth 0.0
362dnl
363dnl Mingw windows N OK 658dnl Mingw windows N OK
364dnl 659dnl
365dnl BeOS 5 -- 660dnl BeOS 5 --
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index 3b83900..f6bf3a4 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,8 +1,8 @@
1# Configure a more-standard replacement for <time.h>. 1# Configure a more-standard replacement for <time.h>.
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5# serial 7 5# serial 20
6 6
7# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
@@ -10,23 +10,42 @@
10 10
11# Written by Paul Eggert and Jim Meyering. 11# Written by Paul Eggert and Jim Meyering.
12 12
13AC_DEFUN([gl_HEADER_TIME_H], 13AC_DEFUN_ONCE([gl_TIME_H],
14[ 14[
15 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 15 dnl Ensure to expand the default settings once only, before all statements
16 dnl once only, before all statements that occur in other macros. 16 dnl that occur in other macros.
17 AC_REQUIRE([gl_HEADER_TIME_H_BODY]) 17 AC_REQUIRE([gl_TIME_H_DEFAULTS])
18])
19 18
20AC_DEFUN([gl_HEADER_TIME_H_BODY],
21[
22 AC_REQUIRE([AC_C_RESTRICT])
23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
24 gl_NEXT_HEADERS([time.h]) 19 gl_NEXT_HEADERS([time.h])
25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) 20 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
21
22 dnl Check for declarations of anything we want to poison if the
23 dnl corresponding gnulib module is not in use.
24 gl_WARN_ON_USE_PREPARE([[
25#include <time.h>
26 ]], [asctime_r ctime_r])
27
28 AC_REQUIRE([AC_C_RESTRICT])
29
30 AC_CACHE_CHECK([for TIME_UTC in <time.h>],
31 [gl_cv_time_h_has_TIME_UTC],
32 [AC_COMPILE_IFELSE(
33 [AC_LANG_PROGRAM(
34 [[#include <time.h>
35 ]],
36 [[static int x = TIME_UTC; x++;]])],
37 [gl_cv_time_h_has_TIME_UTC=yes],
38 [gl_cv_time_h_has_TIME_UTC=no])])
39 if test $gl_cv_time_h_has_TIME_UTC = yes; then
40 TIME_H_DEFINES_TIME_UTC=1
41 else
42 TIME_H_DEFINES_TIME_UTC=0
43 fi
44 AC_SUBST([TIME_H_DEFINES_TIME_UTC])
26]) 45])
27 46
28dnl Check whether 'struct timespec' is declared 47dnl Check whether 'struct timespec' is declared
29dnl in time.h, sys/time.h, or pthread.h. 48dnl in time.h, sys/time.h, pthread.h, or unistd.h.
30 49
31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 50AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
32[ 51[
@@ -44,6 +63,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
44 TIME_H_DEFINES_STRUCT_TIMESPEC=0 63 TIME_H_DEFINES_STRUCT_TIMESPEC=0
45 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 64 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
46 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 65 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
66 UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
47 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 67 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
48 TIME_H_DEFINES_STRUCT_TIMESPEC=1 68 TIME_H_DEFINES_STRUCT_TIMESPEC=1
49 else 69 else
@@ -70,40 +90,94 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
70 [gl_cv_sys_struct_timespec_in_pthread_h=no])]) 90 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
71 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then 91 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
72 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 92 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
93 else
94 AC_CACHE_CHECK([for struct timespec in <unistd.h>],
95 [gl_cv_sys_struct_timespec_in_unistd_h],
96 [AC_COMPILE_IFELSE(
97 [AC_LANG_PROGRAM(
98 [[#include <unistd.h>
99 ]],
100 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
101 [gl_cv_sys_struct_timespec_in_unistd_h=yes],
102 [gl_cv_sys_struct_timespec_in_unistd_h=no])])
103 if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
104 UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
105 fi
73 fi 106 fi
74 fi 107 fi
75 fi 108 fi
76 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) 109 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
77 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) 110 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
78 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) 111 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
112 AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
79]) 113])
80 114
115# gl_TIME_MODULE_INDICATOR([modulename])
116# sets the shell variable that indicates the presence of the given module
117# to a C preprocessor expression that will evaluate to 1.
118# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_TIME_MODULE_INDICATOR], 119AC_DEFUN([gl_TIME_MODULE_INDICATOR],
82[ 120[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 121 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 122 gl_TIME_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 123 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 124 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 125 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 126])
89 127
90AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], 128# Initializes the default values for AC_SUBSTed shell variables.
129# This macro must not be AC_REQUIREd. It must only be invoked, and only
130# outside of macros or in macros that are not AC_REQUIREd.
131AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS],
132[
133 m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R])
144 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ])
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET])
146 dnl Support Microsoft deprecated alias function names by default.
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1])
148 ])
149 m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS])
150 AC_REQUIRE([gl_TIME_H_DEFAULTS])
151])
152
153AC_DEFUN([gl_TIME_H_DEFAULTS],
91[ 154[
92 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
93 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise. 155 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) 156 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) 157 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 158 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 159 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
160 HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET])
161 HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES])
162 dnl Even GNU libc does not have timezone_t yet.
163 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
102 dnl If another module says to replace or to not replace, do that. 164 dnl If another module says to replace or to not replace, do that.
103 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 165 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
104 dnl this lets maintainers check for portability. 166 dnl this lets maintainers check for portability.
167 REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
105 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) 168 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
106 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) 169 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
107 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) 170 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
171 REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME])
108 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) 172 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
173 REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET])
174
175 dnl Hack so that the time module doesn't depend on the sys_time module.
176 dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
177 : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY])
178 dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
179 dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
180 dnl is no longer a big deal.
181 REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
182 REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
109]) 183])
diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4
index c388a83..adce438 100644
--- a/gl/m4/time_r.m4
+++ b/gl/m4/time_r.m4
@@ -1,6 +1,6 @@
1dnl Reentrant time functions: localtime_r, gmtime_r. 1dnl Reentrant time functions: localtime_r, gmtime_r.
2 2
3dnl Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc. 3dnl Copyright (C) 2003, 2006-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -12,12 +12,20 @@ AC_DEFUN([gl_TIME_R],
12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r. 12 dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14 14
15 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 15 AC_REQUIRE([gl_TIME_H_DEFAULTS])
16 AC_REQUIRE([AC_C_RESTRICT]) 16 AC_REQUIRE([AC_C_RESTRICT])
17 17
18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is 18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
19 dnl not defined. 19 dnl not defined.
20 AC_CHECK_DECLS([localtime_r], [], [], [[#include <time.h>]]) 20 AC_CHECK_DECLS([localtime_r], [], [],
21 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
22 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
23 been included before. */
24 #if defined __MINGW32__
25 # include <unistd.h>
26 #endif
27 #include <time.h>
28 ]])
21 if test $ac_cv_have_decl_localtime_r = no; then 29 if test $ac_cv_have_decl_localtime_r = no; then
22 HAVE_DECL_LOCALTIME_R=0 30 HAVE_DECL_LOCALTIME_R=0
23 fi 31 fi
@@ -29,7 +37,14 @@ AC_DEFUN([gl_TIME_R],
29 [gl_cv_time_r_posix], 37 [gl_cv_time_r_posix],
30 [AC_COMPILE_IFELSE( 38 [AC_COMPILE_IFELSE(
31 [AC_LANG_PROGRAM( 39 [AC_LANG_PROGRAM(
32 [[#include <time.h>]], 40 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
41 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
42 been included before. */
43 #if defined __MINGW32__
44 # include <unistd.h>
45 #endif
46 #include <time.h>
47 ]],
33 [[/* We don't need to append 'restrict's to the argument types, 48 [[/* We don't need to append 'restrict's to the argument types,
34 even though the POSIX signature has the 'restrict's, 49 even though the POSIX signature has the 'restrict's,
35 since C99 says they can't affect type compatibility. */ 50 since C99 says they can't affect type compatibility. */
@@ -49,6 +64,32 @@ AC_DEFUN([gl_TIME_R],
49 fi 64 fi
50 else 65 else
51 HAVE_LOCALTIME_R=0 66 HAVE_LOCALTIME_R=0
67 dnl On mingw, localtime_r() is defined as an inline function; use through a
68 dnl direct function call works but the use as a function pointer leads to a
69 dnl link error.
70 AC_CACHE_CHECK([whether localtime_r exists as an inline function],
71 [gl_cv_func_localtime_r_inline],
72 [AC_LINK_IFELSE(
73 [AC_LANG_PROGRAM(
74 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
75 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
76 been included before. */
77 #if defined __MINGW32__
78 # include <unistd.h>
79 #endif
80 #include <time.h>
81 ]],
82 [[time_t a;
83 struct tm r;
84 localtime_r (&a, &r);
85 ]])
86 ],
87 [gl_cv_func_localtime_r_inline=yes],
88 [gl_cv_func_localtime_r_inline=no])
89 ])
90 if test $gl_cv_func_localtime_r_inline = yes; then
91 REPLACE_LOCALTIME_R=1
92 fi
52 fi 93 fi
53]) 94])
54 95
diff --git a/gl/m4/timegm.m4 b/gl/m4/timegm.m4
index 997953c..6079f1a 100644
--- a/gl/m4/timegm.m4
+++ b/gl/m4/timegm.m4
@@ -1,17 +1,17 @@
1# timegm.m4 serial 11 1# timegm.m4 serial 13
2dnl Copyright (C) 2003, 2007, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_TIMEGM], 7AC_DEFUN([gl_FUNC_TIMEGM],
8[ 8[
9 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 9 AC_REQUIRE([gl_TIME_H_DEFAULTS])
10 AC_REQUIRE([gl_FUNC_MKTIME]) 10 AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
11 REPLACE_TIMEGM=0 11 REPLACE_TIMEGM=0
12 AC_CHECK_FUNCS_ONCE([timegm]) 12 AC_CHECK_FUNCS_ONCE([timegm])
13 if test $ac_cv_func_timegm = yes; then 13 if test $ac_cv_func_timegm = yes; then
14 if test $gl_cv_func_working_mktime = no; then 14 if test "$gl_cv_func_working_mktime" != yes; then
15 # Assume that timegm is buggy if mktime is. 15 # Assume that timegm is buggy if mktime is.
16 REPLACE_TIMEGM=1 16 REPLACE_TIMEGM=1
17 fi 17 fi
diff --git a/gl/m4/uintmax_t.m4 b/gl/m4/uintmax_t.m4
deleted file mode 100644
index c6ff800..0000000
--- a/gl/m4/uintmax_t.m4
+++ /dev/null
@@ -1,30 +0,0 @@
1# uintmax_t.m4 serial 12
2dnl Copyright (C) 1997-2004, 2007-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Paul Eggert.
8
9AC_PREREQ([2.13])
10
11# Define uintmax_t to 'unsigned long' or 'unsigned long long'
12# if it is not already defined in <stdint.h> or <inttypes.h>.
13
14AC_DEFUN([gl_AC_TYPE_UINTMAX_T],
15[
16 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
17 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
18 if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
20 test $ac_cv_type_unsigned_long_long_int = yes \
21 && ac_type='unsigned long long' \
22 || ac_type='unsigned long'
23 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
24 [Define to unsigned long or unsigned long long
25 if <stdint.h> and <inttypes.h> don't define.])
26 else
27 AC_DEFINE([HAVE_UINTMAX_T], [1],
28 [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
29 fi
30])
diff --git a/gl/m4/ungetc.m4 b/gl/m4/ungetc.m4
new file mode 100644
index 0000000..8977a34
--- /dev/null
+++ b/gl/m4/ungetc.m4
@@ -0,0 +1,73 @@
1# ungetc.m4 serial 10
2dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
8[
9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11
12 AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
13 [gl_cv_func_ungetc_works],
14 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
15#include <stdio.h>
16 ]], [[FILE *f;
17 if (!(f = fopen ("conftest.tmp", "w+")))
18 return 1;
19 if (fputs ("abc", f) < 0)
20 { fclose (f); return 2; }
21 rewind (f);
22 if (fgetc (f) != 'a')
23 { fclose (f); return 3; }
24 if (fgetc (f) != 'b')
25 { fclose (f); return 4; }
26 if (ungetc ('d', f) != 'd')
27 { fclose (f); return 5; }
28 if (ftell (f) != 1)
29 { fclose (f); return 6; }
30 if (fgetc (f) != 'd')
31 { fclose (f); return 7; }
32 if (ftell (f) != 2)
33 { fclose (f); return 8; }
34 if (fseek (f, 0, SEEK_CUR) != 0)
35 { fclose (f); return 9; }
36 if (ftell (f) != 2)
37 { fclose (f); return 10; }
38 if (fgetc (f) != 'c')
39 { fclose (f); return 11; }
40 fclose (f);
41 remove ("conftest.tmp");
42 ]])],
43 [gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
44 [case "$host_os" in
45 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_ungetc_works="guessing yes" ;;
47 # Guess yes on musl systems.
48 *-musl*) gl_cv_func_ungetc_works="guessing yes" ;;
49 # Guess yes on bionic systems.
50 *-android*) gl_cv_func_ungetc_works="guessing yes" ;;
51 # Guess yes on native Windows.
52 mingw*) gl_cv_func_ungetc_works="guessing yes" ;;
53 # If we don't know, obey --enable-cross-guesses.
54 *) gl_cv_func_ungetc_works="$gl_cross_guess_normal" ;;
55 esac
56 ])
57 ])
58 gl_ftello_broken_after_ungetc=no
59 case "$gl_cv_func_ungetc_works" in
60 *yes) ;;
61 *)
62 dnl On macOS >= 10.15, where the above program fails with exit code 6,
63 dnl we fix it through an ftello override.
64 case "$host_os" in
65 darwin*) gl_ftello_broken_after_ungetc=yes ;;
66 *)
67 AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
68 [Define to 1 if ungetc is broken when used on arbitrary bytes.])
69 ;;
70 esac
71 ;;
72 esac
73])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 32dcfa5..f438402 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,15 +1,15 @@
1# unistd_h.m4 serial 66 1# unistd_h.m4 serial 90
2dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson, Bruno Haible. 7dnl Written by Simon Josefsson, Bruno Haible.
8 8
9AC_DEFUN([gl_UNISTD_H], 9AC_DEFUN_ONCE([gl_UNISTD_H],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 11 dnl Ensure to expand the default settings once only, before all statements
12 dnl once only, before all statements that occur in other macros. 12 dnl that occur in other macros.
13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14 14
15 gl_CHECK_NEXT_HEADERS([unistd.h]) 15 gl_CHECK_NEXT_HEADERS([unistd.h])
@@ -37,150 +37,234 @@ AC_DEFUN([gl_UNISTD_H],
37# include <fcntl.h> 37# include <fcntl.h>
38# include <stdio.h> 38# include <stdio.h>
39# include <stdlib.h> 39# include <stdlib.h>
40# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 40# if defined _WIN32 && ! defined __CYGWIN__
41# include <io.h> 41# include <io.h>
42# endif 42# endif
43#endif 43#endif
44 ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat 44 ]], [access chdir chown copy_file_range dup dup2 dup3 environ euidaccess
45 fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups 45 execl execle execlp execv execve execvp execvpe
46 gethostname getlogin getlogin_r getpagesize 46 faccessat fchdir
47 fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize
48 getentropy getgroups gethostname getlogin getlogin_r getpagesize getpass
47 getusershell setusershell endusershell 49 getusershell setusershell endusershell
48 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite 50 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
49 readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r 51 readlink readlinkat rmdir sethostname sleep symlink symlinkat
50 unlink unlinkat usleep]) 52 truncate ttyname_r unlink unlinkat usleep])
53
54 AC_REQUIRE([AC_C_RESTRICT])
55
56 AC_CHECK_DECLS_ONCE([execvpe])
57 if test $ac_cv_have_decl_execvpe = no; then
58 HAVE_DECL_EXECVPE=0
59 fi
51]) 60])
52 61
62# gl_UNISTD_MODULE_INDICATOR([modulename])
63# sets the shell variable that indicates the presence of the given module
64# to a C preprocessor expression that will evaluate to 1.
65# This macro invocation must not occur in macros that are AC_REQUIREd.
53AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], 66AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
54[ 67[
55 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 68 dnl Ensure to expand the default settings once only.
56 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 69 gl_UNISTD_H_REQUIRE_DEFAULTS
57 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 70 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
58 dnl Define it also as a C macro, for the benefit of the unit tests. 71 dnl Define it also as a C macro, for the benefit of the unit tests.
59 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 72 gl_MODULE_INDICATOR_FOR_TESTS([$1])
60]) 73])
61 74
75# Initializes the default values for AC_SUBSTed shell variables.
76# This macro must not be AC_REQUIREd. It must only be invoked, and only
77# outside of macros or in macros that are not AC_REQUIREd.
78AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS],
79[
80 m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS], [
81 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCESS])
82 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHDIR])
83 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHOWN])
84 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSE])
85 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPY_FILE_RANGE])
86 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP])
87 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP2])
88 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP3])
89 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ENVIRON])
90 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EUIDACCESS])
91 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECL])
92 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLE])
93 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLP])
94 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECV])
95 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVE])
96 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVP])
97 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVPE])
98 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FACCESSAT])
99 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHDIR])
100 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHOWNAT])
101 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDATASYNC])
102 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSYNC])
103 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTRUNCATE])
104 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCWD])
105 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDOMAINNAME])
106 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDTABLESIZE])
107 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETENTROPY])
108 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETGROUPS])
109 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETHOSTNAME])
110 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN])
111 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN_R])
112 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX])
113 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE])
114 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS])
115 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU])
116 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL])
117 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER])
118 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY])
119 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHOWN])
120 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINK])
121 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINKAT])
122 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSEEK])
123 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE])
124 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE2])
125 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PREAD])
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PWRITE])
127 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READ])
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINK])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINKAT])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RMDIR])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETHOSTNAME])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SLEEP])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINK])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINKAT])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCATE])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TTYNAME_R])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_NONBLOCKING])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_SIGPIPE])
140 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINK])
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINKAT])
142 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_USLEEP])
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WRITE])
144 dnl Support Microsoft deprecated alias function names by default.
145 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ACCESS], [1])
146 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHDIR], [1])
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CLOSE], [1])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP], [1])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP2], [1])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECL], [1])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLE], [1])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLP], [1])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECV], [1])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVE], [1])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVP], [1])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVPE], [1])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETCWD], [1])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETPID], [1])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ISATTY], [1])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEEK], [1])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_READ], [1])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_RMDIR], [1])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_SWAB], [1])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UNLINK], [1])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WRITE], [1])
166 ])
167 m4_require(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS])
168 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
169])
170
62AC_DEFUN([gl_UNISTD_H_DEFAULTS], 171AC_DEFUN([gl_UNISTD_H_DEFAULTS],
63[ 172[
64 GNULIB_CHDIR=0; AC_SUBST([GNULIB_CHDIR])
65 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
66 GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
67 GNULIB_DUP=0; AC_SUBST([GNULIB_DUP])
68 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
69 GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3])
70 GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
71 GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
72 GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
73 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
74 GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
75 GNULIB_FDATASYNC=0; AC_SUBST([GNULIB_FDATASYNC])
76 GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
77 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
78 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
79 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
80 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
81 GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
82 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
83 GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
84 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
85 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
86 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
87 GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER])
88 GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY])
89 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
90 GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
91 GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
92 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
93 GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE])
94 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
95 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
96 GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
97 GNULIB_READ=0; AC_SUBST([GNULIB_READ])
98 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
99 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
100 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
101 GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME])
102 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
103 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
104 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
105 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
106 GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
107 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
108 GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
109 GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
110 GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
111 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
112 dnl Assume proper GNU behavior unless another module says otherwise. 173 dnl Assume proper GNU behavior unless another module says otherwise.
113 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) 174 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
114 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) 175 HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
115 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) 176 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
116 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) 177 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
117 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) 178 HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE])
118 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) 179 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
119 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) 180 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
120 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC]) 181 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
121 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) 182 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC])
122 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) 183 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
123 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) 184 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
124 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) 185 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
125 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) 186 HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY])
126 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) 187 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
127 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) 188 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
128 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER]) 189 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
129 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) 190 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
130 HAVE_LINK=1; AC_SUBST([HAVE_LINK]) 191 HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS])
131 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) 192 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER])
132 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE]) 193 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
133 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) 194 HAVE_LINK=1; AC_SUBST([HAVE_LINK])
134 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) 195 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
135 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) 196 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE])
136 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) 197 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
137 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) 198 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
138 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME]) 199 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
139 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 200 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
140 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) 201 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
141 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) 202 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME])
142 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) 203 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
143 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) 204 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
144 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) 205 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
145 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) 206 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
146 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) 207 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
147 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) 208 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
148 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) 209 HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE])
149 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) 210 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR])
150 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) 211 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC])
151 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME]) 212 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
152 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R]) 213 HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN])
153 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) 214 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
154 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) 215 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
155 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) 216 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
156 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) 217 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
157 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) 218 HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE])
158 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) 219 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R])
159 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) 220 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
160 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE]) 221 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
161 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 222 REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS])
162 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) 223 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
163 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) 224 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
164 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) 225 REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE])
165 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 226 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
166 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY]) 227 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
167 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) 228 REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL])
168 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) 229 REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE])
169 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) 230 REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP])
170 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 231 REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV])
171 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) 232 REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE])
172 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) 233 REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP])
173 REPLACE_READ=0; AC_SUBST([REPLACE_READ]) 234 REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE])
174 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) 235 REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT])
175 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) 236 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
176 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 237 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
177 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) 238 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
178 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) 239 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
179 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) 240 REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
180 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) 241 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
181 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) 242 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
182 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE]) 243 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
183 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H]) 244 REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
245 REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
246 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
247 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
248 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
249 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
250 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
251 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
252 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
253 REPLACE_READ=0; AC_SUBST([REPLACE_READ])
254 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
255 REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT])
256 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
257 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
258 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
259 REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
260 REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE])
261 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
262 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
263 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
264 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
265 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
266 UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
267 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
184 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; 268 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
185 AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) 269 AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
186]) 270])
diff --git a/gl/m4/unlocked-io.m4 b/gl/m4/unlocked-io.m4
new file mode 100644
index 0000000..407c0ba
--- /dev/null
+++ b/gl/m4/unlocked-io.m4
@@ -0,0 +1,36 @@
1# unlocked-io.m4 serial 16
2
3# Copyright (C) 1998-2006, 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9dnl From Jim Meyering.
10dnl
11dnl See if the glibc *_unlocked I/O macros or functions are available.
12dnl Use only those *_unlocked macros or functions that are declared
13dnl (because some of them were declared in Solaris 2.5.1 but were removed
14dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
15dnl on Solaris 2.6).
16
17AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
18[
19 dnl Persuade glibc and Solaris <stdio.h> to declare
20 dnl fgets_unlocked(), fputs_unlocked() etc.
21 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
22
23 AC_CHECK_DECLS_ONCE([clearerr_unlocked])
24 AC_CHECK_DECLS_ONCE([feof_unlocked])
25 AC_CHECK_DECLS_ONCE([ferror_unlocked])
26 AC_CHECK_DECLS_ONCE([fflush_unlocked])
27 AC_CHECK_DECLS_ONCE([fgets_unlocked])
28 AC_CHECK_DECLS_ONCE([fputc_unlocked])
29 AC_CHECK_DECLS_ONCE([fputs_unlocked])
30 AC_CHECK_DECLS_ONCE([fread_unlocked])
31 AC_CHECK_DECLS_ONCE([fwrite_unlocked])
32 AC_CHECK_DECLS_ONCE([getc_unlocked])
33 AC_CHECK_DECLS_ONCE([getchar_unlocked])
34 AC_CHECK_DECLS_ONCE([putc_unlocked])
35 AC_CHECK_DECLS_ONCE([putchar_unlocked])
36])
diff --git a/gl/m4/vararrays.m4 b/gl/m4/vararrays.m4
new file mode 100644
index 0000000..fd6230c
--- /dev/null
+++ b/gl/m4/vararrays.m4
@@ -0,0 +1,72 @@
1# Check for variable-length arrays.
2
3# serial 6
4
5# From Paul Eggert
6
7# Copyright (C) 2001, 2009-2023 Free Software Foundation, Inc.
8# This file is free software; the Free Software Foundation
9# gives unlimited permission to copy and/or distribute it,
10# with or without modifications, as long as this notice is preserved.
11
12m4_version_prereq([2.70], [], [
13
14# AC_C_VARARRAYS
15# --------------
16# Check whether the C compiler supports variable-length arrays.
17AC_DEFUN([AC_C_VARARRAYS],
18[
19 AC_CACHE_CHECK([for variable-length arrays],
20 ac_cv_c_vararrays,
21 [AC_EGREP_CPP([defined],
22 [#ifdef __STDC_NO_VLA__
23 defined
24 #endif
25 ],
26 [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[/* Test for VLA support. This test is partly inspired
30 from examples in the C standard. Use at least two VLA
31 functions to detect the GCC 3.4.3 bug described in:
32 https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
33 */
34 #ifdef __STDC_NO_VLA__
35 syntax error;
36 #else
37 extern int n;
38 int B[100];
39 int fvla (int m, int C[m][m]);
40
41 int
42 simple (int count, int all[static count])
43 {
44 return all[count - 1];
45 }
46
47 int
48 fvla (int m, int C[m][m])
49 {
50 typedef int VLA[m][m];
51 VLA x;
52 int D[m];
53 static int (*q)[m] = &B;
54 int (*s)[n] = q;
55 return C && &x[0][0] == &D[0] && &D[0] == s[0];
56 }
57 #endif
58 ]])],
59 [ac_cv_c_vararrays=yes],
60 [ac_cv_c_vararrays=no])])])
61 if test "$ac_cv_c_vararrays" = yes; then
62 dnl This is for compatibility with Autoconf 2.61-2.69.
63 AC_DEFINE([HAVE_C_VARARRAYS], 1,
64 [Define to 1 if C supports variable-length arrays.])
65 elif test "$ac_cv_c_vararrays" = no; then
66 AC_DEFINE([__STDC_NO_VLA__], 1,
67 [Define to 1 if C does not support variable-length arrays, and
68 if the compiler does not already define this.])
69 fi
70])
71
72])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index d730e43..6361c84 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
1# vasnprintf.m4 serial 36 1# vasnprintf.m4 serial 38
2dnl Copyright (C) 2002-2004, 2006-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -32,7 +32,6 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
32# Prerequisites of lib/printf-args.h, lib/printf-args.c. 32# Prerequisites of lib/printf-args.h, lib/printf-args.c.
33AC_DEFUN([gl_PREREQ_PRINTF_ARGS], 33AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
34[ 34[
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
36 AC_REQUIRE([gt_TYPE_WCHAR_T]) 35 AC_REQUIRE([gt_TYPE_WCHAR_T])
37 AC_REQUIRE([gt_TYPE_WINT_T]) 36 AC_REQUIRE([gt_TYPE_WINT_T])
38]) 37])
@@ -41,7 +40,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
41AC_DEFUN([gl_PREREQ_PRINTF_PARSE], 40AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
42[ 41[
43 AC_REQUIRE([gl_FEATURES_H]) 42 AC_REQUIRE([gl_FEATURES_H])
44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
45 AC_REQUIRE([gt_TYPE_WCHAR_T]) 43 AC_REQUIRE([gt_TYPE_WCHAR_T])
46 AC_REQUIRE([gt_TYPE_WINT_T]) 44 AC_REQUIRE([gt_TYPE_WINT_T])
47 AC_REQUIRE([AC_TYPE_SIZE_T]) 45 AC_REQUIRE([AC_TYPE_SIZE_T])
@@ -56,7 +54,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
56AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 54AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
57[ 55[
58 AC_REQUIRE([AC_FUNC_ALLOCA]) 56 AC_REQUIRE([AC_FUNC_ALLOCA])
59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
60 AC_REQUIRE([gt_TYPE_WCHAR_T]) 57 AC_REQUIRE([gt_TYPE_WCHAR_T])
61 AC_REQUIRE([gt_TYPE_WINT_T]) 58 AC_REQUIRE([gt_TYPE_WINT_T])
62 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 59 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
@@ -77,6 +74,16 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
77 if the buffer had been large enough.]) 74 if the buffer had been large enough.])
78 ;; 75 ;;
79 esac 76 esac
77 dnl Additionally, the use of %n can be eliminated by assuming that snprintf
78 dnl always produces NUL-terminated strings (no truncation).
79 AC_REQUIRE([gl_SNPRINTF_TRUNCATION_C99])
80 case "$gl_cv_func_snprintf_truncation_c99" in
81 *yes)
82 AC_DEFINE([HAVE_SNPRINTF_TRUNCATION_C99], [1],
83 [Define if the string produced by the snprintf function is always NUL
84 terminated.])
85 ;;
86 esac
80]) 87])
81 88
82# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' 89# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4
index c214ff1..6e6156a 100644
--- a/gl/m4/vasprintf.m4
+++ b/gl/m4/vasprintf.m4
@@ -1,5 +1,5 @@
1# vasprintf.m4 serial 6 1# vasprintf.m4 serial 6
2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2013 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2023 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index 6cbd7e5..f0468e8 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,5 +1,5 @@
1# visibility.m4 serial 5 (gettext-0.18.2) 1# visibility.m4 serial 8
2dnl Copyright (C) 2005, 2008, 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008, 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -29,42 +29,47 @@ AC_DEFUN([gl_VISIBILITY],
29 dnl First, check whether -Werror can be added to the command line, or 29 dnl First, check whether -Werror can be added to the command line, or
30 dnl whether it leads to an error because of some other option that the 30 dnl whether it leads to an error because of some other option that the
31 dnl user has put into $CC $CFLAGS $CPPFLAGS. 31 dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 AC_MSG_CHECKING([whether the -Werror option is usable]) 32 AC_CACHE_CHECK([whether the -Werror option is usable],
33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [ 33 [gl_cv_cc_vis_werror],
34 gl_save_CFLAGS="$CFLAGS" 34 [gl_save_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror" 35 CFLAGS="$CFLAGS -Werror"
36 AC_COMPILE_IFELSE( 36 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([[]], [[]])], 37 [AC_LANG_PROGRAM([[]], [[]])],
38 [gl_cv_cc_vis_werror=yes], 38 [gl_cv_cc_vis_werror=yes],
39 [gl_cv_cc_vis_werror=no]) 39 [gl_cv_cc_vis_werror=no])
40 CFLAGS="$gl_save_CFLAGS"]) 40 CFLAGS="$gl_save_CFLAGS"
41 AC_MSG_RESULT([$gl_cv_cc_vis_werror]) 41 ])
42 dnl Now check whether visibility declarations are supported. 42 dnl Now check whether visibility declarations are supported.
43 AC_MSG_CHECKING([for simple visibility declarations]) 43 AC_CACHE_CHECK([for simple visibility declarations],
44 AC_CACHE_VAL([gl_cv_cc_visibility], [ 44 [gl_cv_cc_visibility],
45 gl_save_CFLAGS="$CFLAGS" 45 [gl_save_CFLAGS="$CFLAGS"
46 CFLAGS="$CFLAGS -fvisibility=hidden" 46 CFLAGS="$CFLAGS -fvisibility=hidden"
47 dnl We use the option -Werror and a function dummyfunc, because on some 47 dnl We use the option -Werror and a function dummyfunc, because on some
48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning 48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
49 dnl "visibility attribute not supported in this configuration; ignored" 49 dnl "visibility attribute not supported in this configuration; ignored"
50 dnl at the first function definition in every compilation unit, and we 50 dnl at the first function definition in every compilation unit, and we
51 dnl don't want to use the option in this case. 51 dnl don't want to use the option in this case.
52 if test $gl_cv_cc_vis_werror = yes; then 52 if test $gl_cv_cc_vis_werror = yes; then
53 CFLAGS="$CFLAGS -Werror" 53 CFLAGS="$CFLAGS -Werror"
54 fi 54 fi
55 AC_COMPILE_IFELSE( 55 AC_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM( 56 [AC_LANG_PROGRAM(
57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; 57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
58 extern __attribute__((__visibility__("default"))) int exportedvar; 58 extern __attribute__((__visibility__("default"))) int exportedvar;
59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
60 extern __attribute__((__visibility__("default"))) int exportedfunc (void); 60 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
61 void dummyfunc (void) {} 61 void dummyfunc (void);
62 ]], 62 int hiddenvar;
63 [[]])], 63 int exportedvar;
64 [gl_cv_cc_visibility=yes], 64 int hiddenfunc (void) { return 51; }
65 [gl_cv_cc_visibility=no]) 65 int exportedfunc (void) { return 1225736919; }
66 CFLAGS="$gl_save_CFLAGS"]) 66 void dummyfunc (void) {}
67 AC_MSG_RESULT([$gl_cv_cc_visibility]) 67 ]],
68 [[]])],
69 [gl_cv_cc_visibility=yes],
70 [gl_cv_cc_visibility=no])
71 CFLAGS="$gl_save_CFLAGS"
72 ])
68 if test $gl_cv_cc_visibility = yes; then 73 if test $gl_cv_cc_visibility = yes; then
69 CFLAG_VISIBILITY="-fvisibility=hidden" 74 CFLAG_VISIBILITY="-fvisibility=hidden"
70 HAVE_VISIBILITY=1 75 HAVE_VISIBILITY=1
diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4
index 4900764..7fbb11c 100644
--- a/gl/m4/vsnprintf.m4
+++ b/gl/m4/vsnprintf.m4
@@ -1,5 +1,5 @@
1# vsnprintf.m4 serial 6 1# vsnprintf.m4 serial 7
2dnl Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,6 +46,14 @@ AC_DEFUN([gl_REPLACE_VSNPRINTF],
46 AC_LIBOBJ([vsnprintf]) 46 AC_LIBOBJ([vsnprintf])
47 if test $ac_cv_func_vsnprintf = yes; then 47 if test $ac_cv_func_vsnprintf = yes; then
48 REPLACE_VSNPRINTF=1 48 REPLACE_VSNPRINTF=1
49 else
50 AC_CHECK_DECLS_ONCE([vsnprintf])
51 if test $ac_cv_have_decl_vsnprintf = yes; then
52 dnl If the function is declared but does not appear to exist, it may be
53 dnl defined as an inline function. In order to avoid a conflict, we have
54 dnl to define rpl_vsnprintf, not vsnprintf.
55 REPLACE_VSNPRINTF=1
56 fi
49 fi 57 fi
50 gl_PREREQ_VSNPRINTF 58 gl_PREREQ_VSNPRINTF
51]) 59])
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index e43beeb..10649c5 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,11 +1,13 @@
1# warn-on-use.m4 serial 5 1# warn-on-use.m4 serial 10
2dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) 7# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
8# --------------------------------------- 8# ---------------------------------------
9# If the module 'posixcheck' is in use:
10#
9# For each whitespace-separated element in the list of NAMES, define 11# For each whitespace-separated element in the list of NAMES, define
10# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES 12# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
11# even after being undefined as a macro. 13# even after being undefined as a macro.
@@ -23,25 +25,38 @@ dnl with or without modifications, as long as this notice is preserved.
23# needing gl_WARN_ON_USE_PREPARE. 25# needing gl_WARN_ON_USE_PREPARE.
24AC_DEFUN([gl_WARN_ON_USE_PREPARE], 26AC_DEFUN([gl_WARN_ON_USE_PREPARE],
25[ 27[
26 m4_foreach_w([gl_decl], [$2], 28 m4_ifdef([gl_POSIXCHECK],
27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), 29 [m4_foreach_w([gl_decl], [$2],
28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after 30 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
29 undefining macros.])])dnl 31 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
30dnl FIXME: gl_Symbol must be used unquoted until we can assume 32 undefining macros.])])dnl
31dnl autoconf 2.64 or newer. 33 for gl_func in m4_flatten([$2]); do
32 for gl_func in m4_flatten([$2]); do 34 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
33 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl 35 dnl As a workaround to implicit built-in function declarations in
34 AC_CACHE_CHECK([whether $gl_func is declared without a macro], 36 dnl clang (e.g. strndup), reference ac_compile_for_check_decl instead
35 gl_Symbol, 37 dnl of ac_compile. If, for whatever reason, the override of AC_PROG_CC
36 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], 38 dnl in zzgnulib.m4 is inactive, use the original ac_compile.
37[@%:@undef $gl_func 39 ac_save_ac_compile="$ac_compile"
38 (void) $gl_func;])], 40 if test -n "$ac_compile_for_check_decl"; then
39 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) 41 ac_compile="$ac_compile_for_check_decl"
40 AS_VAR_IF(gl_Symbol, [yes], 42 fi
41 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) 43 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
42 dnl shortcut - if the raw declaration exists, then set a cache 44 [gl_Symbol],
43 dnl variable to allow skipping any later AC_CHECK_DECL efforts 45 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
44 eval ac_cv_have_decl_$gl_func=yes]) 46[[#undef $gl_func
45 AS_VAR_POPDEF([gl_Symbol])dnl 47 (void) $gl_func;]])],
46 done 48 [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
49 ac_compile="$ac_save_ac_compile"
50 AS_VAR_IF([gl_Symbol], [yes],
51 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
52 dnl Shortcut for an AC_CHECK_DECL invocation that may come later:
53 dnl If the raw declaration exists with the given includes, then
54 dnl AC_CHECK_DECL with its many includes would see it as well.
55 dnl So, set a cache variable to allow skipping any later
56 dnl AC_CHECK_DECL invocation for $gl_func.
57 eval "ac_cv_have_decl_$gl_func=yes"
58 ])
59 AS_VAR_POPDEF([gl_Symbol])dnl
60 done
61 ])
47]) 62])
diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4
index bedb15a..8ec6619 100644
--- a/gl/m4/wchar_h.m4
+++ b/gl/m4/wchar_h.m4
@@ -1,15 +1,15 @@
1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. 1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl Written by Eric Blake. 8dnl Written by Eric Blake.
9 9
10# wchar_h.m4 serial 39 10# wchar_h.m4 serial 55
11 11
12AC_DEFUN([gl_WCHAR_H], 12AC_DEFUN_ONCE([gl_WCHAR_H],
13[ 13[
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK]) 15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
@@ -35,76 +35,82 @@ AC_DEFUN([gl_WCHAR_H],
35 fi 35 fi
36 AC_SUBST([HAVE_WINT_T]) 36 AC_SUBST([HAVE_WINT_T])
37 37
38 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
39
38 dnl Check for declarations of anything we want to poison if the 40 dnl Check for declarations of anything we want to poison if the
39 dnl corresponding gnulib module is not in use. 41 dnl corresponding gnulib module is not in use.
40 gl_WARN_ON_USE_PREPARE([[ 42 gl_WARN_ON_USE_PREPARE([[
41/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 43 #include <wchar.h>
42 <wchar.h>.
43 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
44 included before <wchar.h>. */
45#if !(defined __GLIBC__ && !defined __UCLIBC__)
46# include <stddef.h>
47# include <stdio.h>
48# include <time.h>
49#endif
50#include <wchar.h>
51 ]], 44 ]],
52 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb 45 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
53 wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset 46 wcsrtombs wcsnrtombs wcwidth
47 wmemchr wmemcmp wmemcpy wmemmove wmempcpy wmemset
54 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp 48 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
55 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr 49 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
56 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth 50 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth wcsftime
57 ]) 51 ])
52
53 AC_REQUIRE([AC_C_RESTRICT])
54
55 AC_CHECK_DECLS([wcsdup], [], [], [[
56 #include <wchar.h>
57 ]])
58 if test $ac_cv_have_decl_wcsdup = no; then
59 HAVE_DECL_WCSDUP=0
60 fi
58]) 61])
59 62
60dnl Check whether <wchar.h> is usable at all. 63dnl Check whether <wchar.h> is usable at all.
61AC_DEFUN([gl_WCHAR_H_INLINE_OK], 64AC_DEFUN([gl_WCHAR_H_INLINE_OK],
62[ 65[
63 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to 66 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
64 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022> 67 dnl 'gnu_inline'. See <https://sourceware.org/bugzilla/show_bug.cgi?id=4022>
65 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary, 68 dnl and <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
66 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and 69 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
67 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>. 70 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
71 AC_REQUIRE([AC_CANONICAL_HOST])
68 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly], 72 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
69 [gl_cv_header_wchar_h_correct_inline], 73 [gl_cv_header_wchar_h_correct_inline],
70 [gl_cv_header_wchar_h_correct_inline=yes 74 [gl_cv_header_wchar_h_correct_inline=yes
71 AC_LANG_CONFTEST([ 75 case "$host_os" in
72 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 76 *-gnu* | gnu*)
73/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 77 AC_LANG_CONFTEST([
74 <wchar.h>. 78 AC_LANG_SOURCE([[
75 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 79 #define wcstod renamed_wcstod
76 included before <wchar.h>. */ 80 #include <wchar.h>
77#include <stddef.h> 81 extern int zero (void);
78#include <stdio.h> 82 int main () { return zero(); }
79#include <time.h> 83 ]])])
80#include <wchar.h> 84 dnl Do not rename the object file from conftest.$ac_objext to
81extern int zero (void); 85 dnl conftest1.$ac_objext, as this will cause the link to fail on
82int main () { return zero(); } 86 dnl z/OS when using the XPLINK object format (due to duplicate
83]])]) 87 dnl CSECT names). Instead, temporarily redefine $ac_compile so
84 if AC_TRY_EVAL([ac_compile]); then 88 dnl that the object file has the latter name from the start.
85 mv conftest.$ac_objext conftest1.$ac_objext 89 save_ac_compile="$ac_compile"
86 AC_LANG_CONFTEST([ 90 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/`
87 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 91 if echo '#include "conftest.c"' >conftest1.c \
88/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 92 && AC_TRY_EVAL([ac_compile]); then
89 <wchar.h>. 93 AC_LANG_CONFTEST([
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 94 AC_LANG_SOURCE([[
91 included before <wchar.h>. */ 95 #define wcstod renamed_wcstod
92#include <stddef.h> 96 #include <wchar.h>
93#include <stdio.h> 97 int zero (void) { return 0; }
94#include <time.h> 98 ]])])
95#include <wchar.h> 99 dnl See note above about renaming object files.
96int zero (void) { return 0; } 100 ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/`
97]])]) 101 if echo '#include "conftest.c"' >conftest2.c \
98 if AC_TRY_EVAL([ac_compile]); then 102 && AC_TRY_EVAL([ac_compile]); then
99 mv conftest.$ac_objext conftest2.$ac_objext 103 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
100 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then 104 :
101 : 105 else
102 else 106 gl_cv_header_wchar_h_correct_inline=no
103 gl_cv_header_wchar_h_correct_inline=no 107 fi
108 fi
104 fi 109 fi
105 fi 110 ac_compile="$save_ac_compile"
106 fi 111 rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext
107 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext 112 ;;
113 esac
108 ]) 114 ])
109 if test $gl_cv_header_wchar_h_correct_inline = no; then 115 if test $gl_cv_header_wchar_h_correct_inline = no; then
110 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). 116 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
@@ -112,63 +118,84 @@ This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
112C99 mode. You have four options: 118C99 mode. You have four options:
113 - Add the flag -fgnu89-inline to CC and reconfigure, or 119 - Add the flag -fgnu89-inline to CC and reconfigure, or
114 - Fix your include files, using parts of 120 - Fix your include files, using parts of
115 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or 121 <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
116 - Use a gcc version older than 4.3, or 122 - Use a gcc version older than 4.3, or
117 - Don't use the flags -std=c99 or -std=gnu99. 123 - Don't use the flags -std=c99 or -std=gnu99.
118Configuration aborted.]) 124Configuration aborted.])
119 fi 125 fi
120]) 126])
121 127
128# gl_WCHAR_MODULE_INDICATOR([modulename])
129# sets the shell variable that indicates the presence of the given module
130# to a C preprocessor expression that will evaluate to 1.
131# This macro invocation must not occur in macros that are AC_REQUIREd.
122AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], 132AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
123[ 133[
124 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 134 dnl Ensure to expand the default settings once only.
125 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 135 gl_WCHAR_H_REQUIRE_DEFAULTS
126 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 136 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
127 dnl Define it also as a C macro, for the benefit of the unit tests. 137 dnl Define it also as a C macro, for the benefit of the unit tests.
128 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 138 gl_MODULE_INDICATOR_FOR_TESTS([$1])
129]) 139])
130 140
141# Initializes the default values for AC_SUBSTed shell variables.
142# This macro must not be AC_REQUIREd. It must only be invoked, and only
143# outside of macros or in macros that are not AC_REQUIREd.
144AC_DEFUN([gl_WCHAR_H_REQUIRE_DEFAULTS],
145[
146 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS], [
147 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_BTOWC])
148 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTOB])
149 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSINIT])
150 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRTOWC])
151 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBRLEN])
152 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSRTOWCS])
153 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBSNRTOWCS])
154 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCRTOMB])
155 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRTOMBS])
156 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNRTOMBS])
157 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCWIDTH])
158 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCHR])
159 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCMP])
160 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMCPY])
161 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMMOVE])
162 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMPCPY])
163 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WMEMSET])
164 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSLEN])
165 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNLEN])
166 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCPY])
167 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPCPY])
168 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCPY])
169 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCPNCPY])
170 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCAT])
171 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCAT])
172 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCMP])
173 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCMP])
174 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCASECMP])
175 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSNCASECMP])
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCOLL])
177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSXFRM])
178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSDUP])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCHR])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSRCHR])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSCSPN])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSPN])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSPBRK])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSSTR])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSTOK])
186 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSWIDTH])
187 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCSFTIME])
188 dnl Support Microsoft deprecated alias function names by default.
189 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WCSDUP], [1])
190 ])
191 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCHAR_H_MODULE_INDICATOR_DEFAULTS])
192 dnl Make sure the shell variable for GNULIB_FREE_POSIX is initialized.
193 gl_STDLIB_H_REQUIRE_DEFAULTS
194 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
195])
196
131AC_DEFUN([gl_WCHAR_H_DEFAULTS], 197AC_DEFUN([gl_WCHAR_H_DEFAULTS],
132[ 198[
133 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
134 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
135 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
136 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
137 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
138 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
139 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
140 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
141 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
142 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
143 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
144 GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR])
145 GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
146 GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
147 GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
148 GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
149 GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
150 GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
151 GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY])
152 GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY])
153 GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY])
154 GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY])
155 GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT])
156 GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT])
157 GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP])
158 GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP])
159 GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP])
160 GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
161 GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL])
162 GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM])
163 GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP])
164 GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR])
165 GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR])
166 GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN])
167 GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN])
168 GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK])
169 GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR])
170 GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK])
171 GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH])
172 dnl Assume proper GNU behavior unless another module says otherwise. 199 dnl Assume proper GNU behavior unless another module says otherwise.
173 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) 200 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
174 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) 201 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
@@ -183,6 +210,7 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
183 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) 210 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
184 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) 211 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
185 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE]) 212 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
213 HAVE_WMEMPCPY=1; AC_SUBST([HAVE_WMEMPCPY])
186 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET]) 214 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
187 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN]) 215 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
188 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN]) 216 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
@@ -207,7 +235,9 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
207 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR]) 235 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR])
208 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) 236 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
209 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) 237 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
238 HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME])
210 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) 239 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
240 HAVE_DECL_WCSDUP=1; AC_SUBST([HAVE_DECL_WCSDUP])
211 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) 241 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
212 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) 242 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
213 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC]) 243 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
@@ -222,4 +252,6 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
222 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) 252 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
223 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) 253 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
224 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) 254 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
255 REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME])
256 REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK])
225]) 257])
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
index e1e1e69..50bde08 100644
--- a/gl/m4/wchar_t.m4
+++ b/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
1# wchar_t.m4 serial 4 (gettext-0.18.2) 1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index f56b5ba..d51b36e 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,5 +1,5 @@
1# wcrtomb.m4 serial 11 1# wcrtomb.m4 serial 17
2dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,15 +15,8 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
15 if test $ac_cv_func_wcrtomb = no; then 15 if test $ac_cv_func_wcrtomb = no; then
16 HAVE_WCRTOMB=0 16 HAVE_WCRTOMB=0
17 AC_CHECK_DECLS([wcrtomb],,, [[ 17 AC_CHECK_DECLS([wcrtomb],,, [[
18/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 18 #include <wchar.h>
19 <wchar.h>. 19 ]])
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
21 included before <wchar.h>. */
22#include <stddef.h>
23#include <stdio.h>
24#include <time.h>
25#include <wchar.h>
26]])
27 if test $ac_cv_have_decl_wcrtomb = yes; then 20 if test $ac_cv_have_decl_wcrtomb = yes; then
28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although 21 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
29 dnl it does not have the function. Avoid a collision with gnulib's 22 dnl it does not have the function. Avoid a collision with gnulib's
@@ -31,17 +24,56 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
31 REPLACE_WCRTOMB=1 24 REPLACE_WCRTOMB=1
32 fi 25 fi
33 else 26 else
34 if test $REPLACE_MBSTATE_T = 1; then 27 dnl We don't actually need to override wcrtomb when redefining the semantics
35 REPLACE_WCRTOMB=1 28 dnl of the mbstate_t type. Tested on 32-bit AIX.
36 else 29 dnl if test $REPLACE_MBSTATE_T = 1; then
37 dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes 30 dnl REPLACE_WCRTOMB=1
38 dnl returns 0 instead of 1. 31 dnl fi
32 if test $REPLACE_WCRTOMB = 0; then
33 dnl On Android 4.3, wcrtomb produces wrong characters in the C locale.
34 dnl On AIX 4.3, OSF/1 5.1 and Solaris <= 11.3, wcrtomb (NULL, 0, NULL)
35 dnl sometimes returns 0 instead of 1.
39 AC_REQUIRE([AC_PROG_CC]) 36 AC_REQUIRE([AC_PROG_CC])
40 AC_REQUIRE([gt_LOCALE_FR]) 37 AC_REQUIRE([gt_LOCALE_FR])
41 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 38 AC_REQUIRE([gt_LOCALE_FR_UTF8])
42 AC_REQUIRE([gt_LOCALE_JA]) 39 AC_REQUIRE([gt_LOCALE_JA])
43 AC_REQUIRE([gt_LOCALE_ZH_CN]) 40 AC_REQUIRE([gt_LOCALE_ZH_CN])
44 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 41 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
42 AC_CACHE_CHECK([whether wcrtomb works in the C locale],
43 [gl_cv_func_wcrtomb_works],
44 [AC_RUN_IFELSE(
45 [AC_LANG_SOURCE([[
46#include <string.h>
47#include <stdlib.h>
48#include <wchar.h>
49int main ()
50{
51 mbstate_t state;
52 char out[64];
53 int count;
54 memset (&state, 0, sizeof (state));
55 out[0] = 'x';
56 count = wcrtomb (out, L'a', &state);
57 return !(count == 1 && out[0] == 'a');
58}]])],
59 [gl_cv_func_wcrtomb_works=yes],
60 [gl_cv_func_wcrtomb_works=no],
61 [case "$host_os" in
62 # Guess no on Android.
63 linux*-android*) gl_cv_func_wcrtomb_works="guessing no";;
64 # Guess yes otherwise.
65 *) gl_cv_func_wcrtomb_works="guessing yes";;
66 esac
67 ])
68 ])
69 case "$gl_cv_func_wcrtomb_works" in
70 *yes) ;;
71 *) AC_DEFINE([WCRTOMB_C_LOCALE_BUG], [1],
72 [Define if the wcrtomb function does not work in the C locale.])
73 REPLACE_WCRTOMB=1 ;;
74 esac
75 fi
76 if test $REPLACE_WCRTOMB = 0; then
45 AC_CACHE_CHECK([whether wcrtomb return value is correct], 77 AC_CACHE_CHECK([whether wcrtomb return value is correct],
46 [gl_cv_func_wcrtomb_retval], 78 [gl_cv_func_wcrtomb_retval],
47 [ 79 [
@@ -49,10 +81,10 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
49 dnl is present. 81 dnl is present.
50changequote(,)dnl 82changequote(,)dnl
51 case "$host_os" in 83 case "$host_os" in
52 # Guess no on AIX 4, OSF/1 and Solaris. 84 # Guess no on AIX 4, OSF/1, Solaris, native Windows.
53 aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;; 85 aix4* | osf* | solaris* | mingw*) gl_cv_func_wcrtomb_retval="guessing no" ;;
54 # Guess yes otherwise. 86 # Guess yes otherwise.
55 *) gl_cv_func_wcrtomb_retval="guessing yes" ;; 87 *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
56 esac 88 esac
57changequote([,])dnl 89changequote([,])dnl
58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 90 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
@@ -60,14 +92,8 @@ changequote([,])dnl
60 [AC_LANG_SOURCE([[ 92 [AC_LANG_SOURCE([[
61#include <locale.h> 93#include <locale.h>
62#include <string.h> 94#include <string.h>
63/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
64 <wchar.h>.
65 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
66 included before <wchar.h>. */
67#include <stddef.h>
68#include <stdio.h>
69#include <time.h>
70#include <wchar.h> 95#include <wchar.h>
96#include <stdlib.h>
71int main () 97int main ()
72{ 98{
73 int result = 0; 99 int result = 0;
@@ -80,6 +106,12 @@ int main ()
80 { 106 {
81 if (wcrtomb (NULL, 0, NULL) != 1) 107 if (wcrtomb (NULL, 0, NULL) != 1)
82 result |= 2; 108 result |= 2;
109 {
110 wchar_t wc = (wchar_t) 0xBADFACE;
111 if (mbtowc (&wc, "\303\274", 2) == 2)
112 if (wcrtomb (NULL, wc, NULL) != 1)
113 result |= 2;
114 }
83 } 115 }
84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 116 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
85 { 117 {
@@ -100,7 +132,9 @@ int main ()
100 ]) 132 ])
101 case "$gl_cv_func_wcrtomb_retval" in 133 case "$gl_cv_func_wcrtomb_retval" in
102 *yes) ;; 134 *yes) ;;
103 *) REPLACE_WCRTOMB=1 ;; 135 *) AC_DEFINE([WCRTOMB_RETVAL_BUG], [1],
136 [Define if the wcrtomb function has an incorrect return value.])
137 REPLACE_WCRTOMB=1 ;;
104 esac 138 esac
105 fi 139 fi
106 fi 140 fi
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index 82ada0e..6856a73 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,15 +1,15 @@
1# wctype_h.m4 serial 18 1# wctype_h.m4 serial 30
2 2
3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it. 3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
4 4
5dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 5dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
9 9
10dnl Written by Paul Eggert. 10dnl Written by Paul Eggert.
11 11
12AC_DEFUN([gl_WCTYPE_H], 12AC_DEFUN_ONCE([gl_WCTYPE_H],
13[ 13[
14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) 14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
15 AC_REQUIRE([AC_PROG_CC]) 15 AC_REQUIRE([AC_PROG_CC])
@@ -30,6 +30,8 @@ AC_DEFUN([gl_WCTYPE_H],
30 fi 30 fi
31 AC_SUBST([HAVE_WINT_T]) 31 AC_SUBST([HAVE_WINT_T])
32 32
33 AC_REQUIRE([gl_TYPE_WINT_T_PREREQ])
34
33 gl_CHECK_NEXT_HEADERS([wctype.h]) 35 gl_CHECK_NEXT_HEADERS([wctype.h])
34 if test $ac_cv_header_wctype_h = yes; then 36 if test $ac_cv_header_wctype_h = yes; then
35 if test $ac_cv_func_iswcntrl = yes; then 37 if test $ac_cv_func_iswcntrl = yes; then
@@ -39,22 +41,16 @@ AC_DEFUN([gl_WCTYPE_H],
39 [ 41 [
40 AC_RUN_IFELSE( 42 AC_RUN_IFELSE(
41 [AC_LANG_SOURCE([[ 43 [AC_LANG_SOURCE([[
42 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
43 included before <wchar.h>.
44 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
45 must be included before <wchar.h>. */
46 #include <stddef.h>
47 #include <stdio.h>
48 #include <time.h>
49 #include <wchar.h> 44 #include <wchar.h>
50 #include <wctype.h> 45 #include <wctype.h>
51 int main () { return iswprint ('x') == 0; } 46 int main () { return iswprint ('x') == 0; }
52 ]])], 47 ]])],
53 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], 48 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
54 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> 49 [dnl Guess no on Linux libc5, yes otherwise.
50 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
55 #if __GNU_LIBRARY__ == 1 51 #if __GNU_LIBRARY__ == 1
56 Linux libc5 i18n is broken. 52 Linux libc5 i18n is broken.
57 #endif]], [])], 53 #endif]], [[]])],
58 [gl_cv_func_iswcntrl_works="guessing yes"], 54 [gl_cv_func_iswcntrl_works="guessing yes"],
59 [gl_cv_func_iswcntrl_works="guessing no"]) 55 [gl_cv_func_iswcntrl_works="guessing no"])
60 ]) 56 ])
@@ -66,10 +62,14 @@ AC_DEFUN([gl_WCTYPE_H],
66 fi 62 fi
67 AC_SUBST([HAVE_WCTYPE_H]) 63 AC_SUBST([HAVE_WCTYPE_H])
68 64
69 case "$gl_cv_func_iswcntrl_works" in 65 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
70 *yes) REPLACE_ISWCNTRL=0 ;; 66 REPLACE_ISWCNTRL=1
71 *) REPLACE_ISWCNTRL=1 ;; 67 else
72 esac 68 case "$gl_cv_func_iswcntrl_works" in
69 *yes) REPLACE_ISWCNTRL=0 ;;
70 *) REPLACE_ISWCNTRL=1 ;;
71 esac
72 fi
73 AC_SUBST([REPLACE_ISWCNTRL]) 73 AC_SUBST([REPLACE_ISWCNTRL])
74 74
75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then 75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
@@ -85,14 +85,7 @@ AC_DEFUN([gl_WCTYPE_H],
85 REPLACE_TOWLOWER=0 85 REPLACE_TOWLOWER=0
86 else 86 else
87 AC_CHECK_DECLS([towlower],,, 87 AC_CHECK_DECLS([towlower],,,
88 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 88 [[#include <wchar.h>
89 included before <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
91 must be included before <wchar.h>. */
92 #include <stddef.h>
93 #include <stdio.h>
94 #include <time.h>
95 #include <wchar.h>
96 #if HAVE_WCTYPE_H 89 #if HAVE_WCTYPE_H
97 # include <wctype.h> 90 # include <wctype.h>
98 #endif 91 #endif
@@ -121,14 +114,7 @@ AC_DEFUN([gl_WCTYPE_H],
121 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t], 114 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
122 [AC_COMPILE_IFELSE( 115 [AC_COMPILE_IFELSE(
123 [AC_LANG_PROGRAM( 116 [AC_LANG_PROGRAM(
124 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 117 [[#include <wchar.h>
125 included before <wchar.h>.
126 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
127 must be included before <wchar.h>. */
128 #include <stddef.h>
129 #include <stdio.h>
130 #include <time.h>
131 #include <wchar.h>
132 #if HAVE_WCTYPE_H 118 #if HAVE_WCTYPE_H
133 # include <wctype.h> 119 # include <wctype.h>
134 #endif 120 #endif
@@ -147,14 +133,7 @@ AC_DEFUN([gl_WCTYPE_H],
147 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t], 133 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
148 [AC_COMPILE_IFELSE( 134 [AC_COMPILE_IFELSE(
149 [AC_LANG_PROGRAM( 135 [AC_LANG_PROGRAM(
150 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be 136 [[#include <wchar.h>
151 included before <wchar.h>.
152 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
153 must be included before <wchar.h>. */
154 #include <stddef.h>
155 #include <stdio.h>
156 #include <time.h>
157 #include <wchar.h>
158 #include <wctype.h> 137 #include <wctype.h>
159 wctrans_t a; 138 wctrans_t a;
160 ]], 139 ]],
@@ -169,14 +148,7 @@ AC_DEFUN([gl_WCTYPE_H],
169 dnl Check for declarations of anything we want to poison if the 148 dnl Check for declarations of anything we want to poison if the
170 dnl corresponding gnulib module is not in use. 149 dnl corresponding gnulib module is not in use.
171 gl_WARN_ON_USE_PREPARE([[ 150 gl_WARN_ON_USE_PREPARE([[
172/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
173 <wchar.h>.
174 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
175 included before <wchar.h>. */
176#if !(defined __GLIBC__ && !defined __UCLIBC__) 151#if !(defined __GLIBC__ && !defined __UCLIBC__)
177# include <stddef.h>
178# include <stdio.h>
179# include <time.h>
180# include <wchar.h> 152# include <wchar.h>
181#endif 153#endif
182#include <wctype.h> 154#include <wctype.h>
@@ -185,25 +157,44 @@ AC_DEFUN([gl_WCTYPE_H],
185 ]) 157 ])
186]) 158])
187 159
160# gl_WCTYPE_MODULE_INDICATOR([modulename])
161# sets the shell variable that indicates the presence of the given module
162# to a C preprocessor expression that will evaluate to 1.
163# This macro invocation must not occur in macros that are AC_REQUIREd.
188AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], 164AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
189[ 165[
190 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 166 dnl Ensure to expand the default settings once only.
191 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) 167 gl_WCTYPE_H_REQUIRE_DEFAULTS
192 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 168 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
193 dnl Define it also as a C macro, for the benefit of the unit tests. 169 dnl Define it also as a C macro, for the benefit of the unit tests.
194 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 170 gl_MODULE_INDICATOR_FOR_TESTS([$1])
195]) 171])
196 172
173# Initializes the default values for AC_SUBSTed shell variables.
174# This macro must not be AC_REQUIREd. It must only be invoked, and only
175# outside of macros or in macros that are not AC_REQUIREd.
176AC_DEFUN([gl_WCTYPE_H_REQUIRE_DEFAULTS],
177[
178 m4_defun(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS], [
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWBLANK])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWDIGIT])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWXDIGIT])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTYPE])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISWCTYPE])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WCTRANS])
185 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TOWCTRANS])
186 ])
187 m4_require(GL_MODULE_INDICATOR_PREFIX[_WCTYPE_H_MODULE_INDICATOR_DEFAULTS])
188 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
189])
190
197AC_DEFUN([gl_WCTYPE_H_DEFAULTS], 191AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
198[ 192[
199 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
200 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
201 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
202 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
203 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
204 dnl Assume proper GNU behavior unless another module says otherwise. 193 dnl Assume proper GNU behavior unless another module says otherwise.
205 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) 194 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
206 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) 195 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
207 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T]) 196 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
208 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK]) 197 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
198 REPLACE_ISWDIGIT=0; AC_SUBST([REPLACE_ISWDIGIT])
199 REPLACE_ISWXDIGIT=0; AC_SUBST([REPLACE_ISWXDIGIT])
209]) 200])
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index d7cd3db..dfd743b 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,11 +1,12 @@
1# wint_t.m4 serial 5 (gettext-0.18.2) 1# wint_t.m4 serial 11
2dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8dnl Test whether <wchar.h> has the 'wint_t' type. 8dnl Test whether <wchar.h> has the 'wint_t' type and whether gnulib's
9dnl <wchar.h> or <wctype.h> would, if present, override 'wint_t'.
9dnl Prerequisite: AC_PROG_CC 10dnl Prerequisite: AC_PROG_CC
10 11
11AC_DEFUN([gt_TYPE_WINT_T], 12AC_DEFUN([gt_TYPE_WINT_T],
@@ -13,20 +14,44 @@ AC_DEFUN([gt_TYPE_WINT_T],
13 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], 14 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
14 [AC_COMPILE_IFELSE( 15 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM( 16 [AC_LANG_PROGRAM(
16 [[ 17 [[#include <wchar.h>
17/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
18 <wchar.h>.
19 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
20 before <wchar.h>. */
21#include <stddef.h>
22#include <stdio.h>
23#include <time.h>
24#include <wchar.h>
25 wint_t foo = (wchar_t)'\0';]], 18 wint_t foo = (wchar_t)'\0';]],
26 [[]])], 19 [[]])],
27 [gt_cv_c_wint_t=yes], 20 [gt_cv_c_wint_t=yes],
28 [gt_cv_c_wint_t=no])]) 21 [gt_cv_c_wint_t=no])])
29 if test $gt_cv_c_wint_t = yes; then 22 if test $gt_cv_c_wint_t = yes; then
30 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) 23 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
24
25 dnl Determine whether gnulib's <wchar.h> or <wctype.h> would, if present,
26 dnl override 'wint_t'.
27 AC_CACHE_CHECK([whether wint_t is large enough],
28 [gl_cv_type_wint_t_large_enough],
29 [AC_COMPILE_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[#include <wchar.h>
32 int verify[sizeof (wint_t) < sizeof (int) ? -1 : 1];
33 ]])],
34 [gl_cv_type_wint_t_large_enough=yes],
35 [gl_cv_type_wint_t_large_enough=no])])
36 if test $gl_cv_type_wint_t_large_enough = no; then
37 GNULIBHEADERS_OVERRIDE_WINT_T=1
38 else
39 GNULIBHEADERS_OVERRIDE_WINT_T=0
40 fi
41 else
42 GNULIBHEADERS_OVERRIDE_WINT_T=0
43 fi
44 AC_SUBST([GNULIBHEADERS_OVERRIDE_WINT_T])
45])
46
47dnl Prerequisites of the 'wint_t' override.
48AC_DEFUN([gl_TYPE_WINT_T_PREREQ],
49[
50 AC_CHECK_HEADERS_ONCE([crtdefs.h])
51 if test $ac_cv_header_crtdefs_h = yes; then
52 HAVE_CRTDEFS_H=1
53 else
54 HAVE_CRTDEFS_H=0
31 fi 55 fi
56 AC_SUBST([HAVE_CRTDEFS_H])
32]) 57])
diff --git a/gl/m4/xalloc.m4 b/gl/m4/xalloc.m4
index 64ca701..fc56f59 100644
--- a/gl/m4/xalloc.m4
+++ b/gl/m4/xalloc.m4
@@ -1,5 +1,5 @@
1# xalloc.m4 serial 18 1# xalloc.m4 serial 18
2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index 8ea9f2c..649db9c 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
1# xsize.m4 serial 5 1# xsize.m4 serial 5
2dnl Copyright (C) 2003-2004, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2003-2004, 2008-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
diff --git a/gl/m4/xstrndup.m4 b/gl/m4/xstrndup.m4
deleted file mode 100644
index 4a9330b..0000000
--- a/gl/m4/xstrndup.m4
+++ /dev/null
@@ -1,15 +0,0 @@
1# xstrndup.m4 serial 2
2dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_XSTRNDUP],
8[
9 gl_PREREQ_XSTRNDUP
10])
11
12# Prerequisites of lib/xstrndup.c.
13AC_DEFUN([gl_PREREQ_XSTRNDUP], [
14 :
15])
diff --git a/gl/m4/zzgnulib.m4 b/gl/m4/zzgnulib.m4
new file mode 100644
index 0000000..362102b
--- /dev/null
+++ b/gl/m4/zzgnulib.m4
@@ -0,0 +1,23 @@
1# zzgnulib.m4 serial 1
2dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl This file must be named something that sorts after all other
8dnl package- or gnulib-provided .m4 files - at least for those packages
9dnl that redefine AC_PROG_CC.
10
11dnl Redefine AC_PROG_CC so that it ends with invocations of gl_COMPILER_CLANG
12dnl and gl_COMPILER_PREPARE_CHECK_DECL.
13m4_define([AC_PROG_CC],
14 m4_defn([AC_PROG_CC])[
15gl_COMPILER_CLANG
16gl_COMPILER_PREPARE_CHECK_DECL
17])
18
19# gl_ZZGNULIB
20# -----------
21# Witness macro that this file has been included. Needed to force
22# Automake to include this file after all other gnulib .m4 files.
23AC_DEFUN([gl_ZZGNULIB])
diff --git a/gl/malloc.c b/gl/malloc.c
index 908735d..3ade35c 100644
--- a/gl/malloc.c
+++ b/gl/malloc.c
@@ -1,51 +1,46 @@
1/* malloc() function that is glibc compatible. 1/* malloc() function that is glibc compatible.
2 2
3 Copyright (C) 1997-1998, 2006-2007, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 1997-1998, 2006-2007, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* written by Jim Meyering and Bruno Haible */ 18/* written by Jim Meyering and Bruno Haible */
19 19
20#define _GL_USE_STDLIB_ALLOC 1 20#define _GL_USE_STDLIB_ALLOC 1
21#include <config.h> 21#include <config.h>
22/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
23#ifdef malloc
24# define NEED_MALLOC_GNU 1
25# undef malloc
26/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */
27#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU
28# define NEED_MALLOC_GNU 1
29#endif
30 22
31#include <stdlib.h> 23#include <stdlib.h>
32 24
33#include <errno.h> 25#include <errno.h>
34 26
35/* Allocate an N-byte block of memory from the heap. 27#include "xalloc-oversized.h"
36 If N is zero, allocate a 1-byte block. */ 28
29/* Allocate an N-byte block of memory from the heap, even if N is 0. */
37 30
38void * 31void *
39rpl_malloc (size_t n) 32rpl_malloc (size_t n)
40{ 33{
41 void *result;
42
43#if NEED_MALLOC_GNU
44 if (n == 0) 34 if (n == 0)
45 n = 1; 35 n = 1;
46#endif
47 36
48 result = malloc (n); 37 if (xalloc_oversized (n, 1))
38 {
39 errno = ENOMEM;
40 return NULL;
41 }
42
43 void *result = malloc (n);
49 44
50#if !HAVE_MALLOC_POSIX 45#if !HAVE_MALLOC_POSIX
51 if (result == NULL) 46 if (result == NULL)
diff --git a/gl/malloc/dynarray-skeleton.c b/gl/malloc/dynarray-skeleton.c
new file mode 100644
index 0000000..580c278
--- /dev/null
+++ b/gl/malloc/dynarray-skeleton.c
@@ -0,0 +1,528 @@
1/* Type-safe arrays which grow dynamically.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* Pre-processor macros which act as parameters:
20
21 DYNARRAY_STRUCT
22 The struct tag of dynamic array to be defined.
23 DYNARRAY_ELEMENT
24 The type name of the element type. Elements are copied
25 as if by memcpy, and can change address as the dynamic
26 array grows.
27 DYNARRAY_PREFIX
28 The prefix of the functions which are defined.
29
30 The following parameters are optional:
31
32 DYNARRAY_ELEMENT_FREE
33 DYNARRAY_ELEMENT_FREE (E) is evaluated to deallocate the
34 contents of elements. E is of type DYNARRAY_ELEMENT *.
35 DYNARRAY_ELEMENT_INIT
36 DYNARRAY_ELEMENT_INIT (E) is evaluated to initialize a new
37 element. E is of type DYNARRAY_ELEMENT *.
38 If DYNARRAY_ELEMENT_FREE but not DYNARRAY_ELEMENT_INIT is
39 defined, new elements are automatically zero-initialized.
40 Otherwise, new elements have undefined contents.
41 DYNARRAY_INITIAL_SIZE
42 The size of the statically allocated array (default:
43 at least 2, more elements if they fit into 128 bytes).
44 Must be a preprocessor constant. If DYNARRAY_INITIAL_SIZE is 0,
45 there is no statically allocated array at, and all non-empty
46 arrays are heap-allocated.
47 DYNARRAY_FINAL_TYPE
48 The name of the type which holds the final array. If not
49 defined, is PREFIX##finalize not provided. DYNARRAY_FINAL_TYPE
50 must be a struct type, with members of type DYNARRAY_ELEMENT and
51 size_t at the start (in this order).
52
53 These macros are undefined after this header file has been
54 included.
55
56 The following types are provided (their members are private to the
57 dynarray implementation):
58
59 struct DYNARRAY_STRUCT
60
61 The following functions are provided:
62
63 void DYNARRAY_PREFIX##init (struct DYNARRAY_STRUCT *);
64 void DYNARRAY_PREFIX##free (struct DYNARRAY_STRUCT *);
65 bool DYNARRAY_PREFIX##has_failed (const struct DYNARRAY_STRUCT *);
66 void DYNARRAY_PREFIX##mark_failed (struct DYNARRAY_STRUCT *);
67 size_t DYNARRAY_PREFIX##size (const struct DYNARRAY_STRUCT *);
68 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##begin (const struct DYNARRAY_STRUCT *);
69 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##end (const struct DYNARRAY_STRUCT *);
70 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##at (struct DYNARRAY_STRUCT *, size_t);
71 void DYNARRAY_PREFIX##add (struct DYNARRAY_STRUCT *, DYNARRAY_ELEMENT);
72 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##emplace (struct DYNARRAY_STRUCT *);
73 bool DYNARRAY_PREFIX##resize (struct DYNARRAY_STRUCT *, size_t);
74 void DYNARRAY_PREFIX##remove_last (struct DYNARRAY_STRUCT *);
75 void DYNARRAY_PREFIX##clear (struct DYNARRAY_STRUCT *);
76
77 The following functions are provided are provided if the
78 prerequisites are met:
79
80 bool DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
81 DYNARRAY_FINAL_TYPE *);
82 (if DYNARRAY_FINAL_TYPE is defined)
83 DYNARRAY_ELEMENT *DYNARRAY_PREFIX##finalize (struct DYNARRAY_STRUCT *,
84 size_t *);
85 (if DYNARRAY_FINAL_TYPE is not defined)
86*/
87
88#include <malloc/dynarray.h>
89
90#include <errno.h>
91#include <stdlib.h>
92#include <string.h>
93
94#ifndef DYNARRAY_STRUCT
95# error "DYNARRAY_STRUCT must be defined"
96#endif
97
98#ifndef DYNARRAY_ELEMENT
99# error "DYNARRAY_ELEMENT must be defined"
100#endif
101
102#ifndef DYNARRAY_PREFIX
103# error "DYNARRAY_PREFIX must be defined"
104#endif
105
106#ifdef DYNARRAY_INITIAL_SIZE
107# if DYNARRAY_INITIAL_SIZE < 0
108# error "DYNARRAY_INITIAL_SIZE must be non-negative"
109# endif
110# if DYNARRAY_INITIAL_SIZE > 0
111# define DYNARRAY_HAVE_SCRATCH 1
112# else
113# define DYNARRAY_HAVE_SCRATCH 0
114# endif
115#else
116/* Provide a reasonable default which limits the size of
117 DYNARRAY_STRUCT. */
118# define DYNARRAY_INITIAL_SIZE \
119 (sizeof (DYNARRAY_ELEMENT) > 64 ? 2 : 128 / sizeof (DYNARRAY_ELEMENT))
120# define DYNARRAY_HAVE_SCRATCH 1
121#endif
122
123/* Public type definitions. */
124
125/* All fields of this struct are private to the implementation. */
126struct DYNARRAY_STRUCT
127{
128 union
129 {
130 struct dynarray_header dynarray_abstract;
131 struct
132 {
133 /* These fields must match struct dynarray_header. */
134 size_t used;
135 size_t allocated;
136 DYNARRAY_ELEMENT *array;
137 } dynarray_header;
138 } u;
139
140#if DYNARRAY_HAVE_SCRATCH
141 /* Initial inline allocation. */
142 DYNARRAY_ELEMENT scratch[DYNARRAY_INITIAL_SIZE];
143#endif
144};
145
146/* Internal use only: Helper macros. */
147
148/* Ensure macro-expansion of DYNARRAY_PREFIX. */
149#define DYNARRAY_CONCAT0(prefix, name) prefix##name
150#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
151#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
152
153/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
154 so that Gnulib does not change 'free' to 'rpl_free'. */
155#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
156
157/* Address of the scratch buffer if any. */
158#if DYNARRAY_HAVE_SCRATCH
159# define DYNARRAY_SCRATCH(list) (list)->scratch
160#else
161# define DYNARRAY_SCRATCH(list) NULL
162#endif
163
164/* Internal use only: Helper functions. */
165
166/* Internal function. Call DYNARRAY_ELEMENT_FREE with the array
167 elements. Name mangling needed due to the DYNARRAY_ELEMENT_FREE
168 macro expansion. */
169static inline void
170DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
171 size_t __dynarray_used)
172{
173#ifdef DYNARRAY_ELEMENT_FREE
174 for (size_t __dynarray_i = 0; __dynarray_i < __dynarray_used; ++__dynarray_i)
175 DYNARRAY_ELEMENT_FREE (&__dynarray_array[__dynarray_i]);
176#endif /* DYNARRAY_ELEMENT_FREE */
177}
178
179/* Internal function. Free the non-scratch array allocation. */
180static inline void
181DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
182{
183#if DYNARRAY_HAVE_SCRATCH
184 if (list->u.dynarray_header.array != list->scratch)
185 free (list->u.dynarray_header.array);
186#else
187 free (list->u.dynarray_header.array);
188#endif
189}
190
191/* Public functions. */
192
193/* Initialize a dynamic array object. This must be called before any
194 use of the object. */
195__attribute_nonnull__ ((1))
196static void
197DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
198{
199 list->u.dynarray_header.used = 0;
200 list->u.dynarray_header.allocated = DYNARRAY_INITIAL_SIZE;
201 list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
202}
203
204/* Deallocate the dynamic array and its elements. */
205__attribute_maybe_unused__ __attribute_nonnull__ ((1))
206static void
207DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
208{
209 DYNARRAY_NAME (free__elements__)
210 (list->u.dynarray_header.array, list->u.dynarray_header.used);
211 DYNARRAY_NAME (free__array__) (list);
212 DYNARRAY_NAME (init) (list);
213}
214
215/* Return true if the dynamic array is in an error state. */
216__attribute_nonnull__ ((1))
217static inline bool
218DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
219{
220 return list->u.dynarray_header.allocated == __dynarray_error_marker ();
221}
222
223/* Mark the dynamic array as failed. All elements are deallocated as
224 a side effect. */
225__attribute_nonnull__ ((1))
226static void
227DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
228{
229 DYNARRAY_NAME (free__elements__)
230 (list->u.dynarray_header.array, list->u.dynarray_header.used);
231 DYNARRAY_NAME (free__array__) (list);
232 list->u.dynarray_header.array = DYNARRAY_SCRATCH (list);
233 list->u.dynarray_header.used = 0;
234 list->u.dynarray_header.allocated = __dynarray_error_marker ();
235}
236
237/* Return the number of elements which have been added to the dynamic
238 array. */
239__attribute_nonnull__ ((1))
240static inline size_t
241DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
242{
243 return list->u.dynarray_header.used;
244}
245
246/* Return a pointer to the array element at INDEX. Terminate the
247 process if INDEX is out of bounds. */
248__attribute_nonnull__ ((1))
249static inline DYNARRAY_ELEMENT *
250DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
251{
252 if (__glibc_unlikely (index >= DYNARRAY_NAME (size) (list)))
253 __libc_dynarray_at_failure (DYNARRAY_NAME (size) (list), index);
254 return list->u.dynarray_header.array + index;
255}
256
257/* Return a pointer to the first array element, if any. For a
258 zero-length array, the pointer can be NULL even though the dynamic
259 array has not entered the failure state. */
260__attribute_nonnull__ ((1))
261static inline DYNARRAY_ELEMENT *
262DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
263{
264 return list->u.dynarray_header.array;
265}
266
267/* Return a pointer one element past the last array element. For a
268 zero-length array, the pointer can be NULL even though the dynamic
269 array has not entered the failure state. */
270__attribute_nonnull__ ((1))
271static inline DYNARRAY_ELEMENT *
272DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
273{
274 return list->u.dynarray_header.array + list->u.dynarray_header.used;
275}
276
277/* Internal function. Slow path for the add function below. */
278static void
279DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
280{
281 if (__glibc_unlikely
282 (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
283 DYNARRAY_SCRATCH (list),
284 sizeof (DYNARRAY_ELEMENT))))
285 {
286 DYNARRAY_NAME (mark_failed) (list);
287 return;
288 }
289
290 /* Copy the new element and increase the array length. */
291 list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
292}
293
294/* Add ITEM at the end of the array, enlarging it by one element.
295 Mark *LIST as failed if the dynamic array allocation size cannot be
296 increased. */
297__attribute_nonnull__ ((1))
298static inline void
299DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
300{
301 /* Do nothing in case of previous error. */
302 if (DYNARRAY_NAME (has_failed) (list))
303 return;
304
305 /* Enlarge the array if necessary. */
306 if (__glibc_unlikely (list->u.dynarray_header.used
307 == list->u.dynarray_header.allocated))
308 {
309 DYNARRAY_NAME (add__) (list, item);
310 return;
311 }
312
313 /* Copy the new element and increase the array length. */
314 list->u.dynarray_header.array[list->u.dynarray_header.used++] = item;
315}
316
317/* Internal function. Building block for the emplace functions below.
318 Assumes space for one more element in *LIST. */
319static inline DYNARRAY_ELEMENT *
320DYNARRAY_NAME (emplace__tail__) (struct DYNARRAY_STRUCT *list)
321{
322 DYNARRAY_ELEMENT *result
323 = &list->u.dynarray_header.array[list->u.dynarray_header.used];
324 ++list->u.dynarray_header.used;
325#if defined (DYNARRAY_ELEMENT_INIT)
326 DYNARRAY_ELEMENT_INIT (result);
327#elif defined (DYNARRAY_ELEMENT_FREE)
328 memset (result, 0, sizeof (*result));
329#endif
330 return result;
331}
332
333/* Internal function. Slow path for the emplace function below. */
334static DYNARRAY_ELEMENT *
335DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
336{
337 if (__glibc_unlikely
338 (!__libc_dynarray_emplace_enlarge (&list->u.dynarray_abstract,
339 DYNARRAY_SCRATCH (list),
340 sizeof (DYNARRAY_ELEMENT))))
341 {
342 DYNARRAY_NAME (mark_failed) (list);
343 return NULL;
344 }
345 return DYNARRAY_NAME (emplace__tail__) (list);
346}
347
348/* Allocate a place for a new element in *LIST and return a pointer to
349 it. The pointer can be NULL if the dynamic array cannot be
350 enlarged due to a memory allocation failure. */
351__attribute_maybe_unused__ __attribute_warn_unused_result__
352__attribute_nonnull__ ((1))
353static
354/* Avoid inlining with the larger initialization code. */
355#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
356inline
357#endif
358DYNARRAY_ELEMENT *
359DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
360{
361 /* Do nothing in case of previous error. */
362 if (DYNARRAY_NAME (has_failed) (list))
363 return NULL;
364
365 /* Enlarge the array if necessary. */
366 if (__glibc_unlikely (list->u.dynarray_header.used
367 == list->u.dynarray_header.allocated))
368 return (DYNARRAY_NAME (emplace__) (list));
369 return DYNARRAY_NAME (emplace__tail__) (list);
370}
371
372/* Change the size of *LIST to SIZE. If SIZE is larger than the
373 existing size, new elements are added (which can be initialized).
374 Otherwise, the list is truncated, and elements are freed. Return
375 false on memory allocation failure (and mark *LIST as failed). */
376__attribute_maybe_unused__ __attribute_nonnull__ ((1))
377static bool
378DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
379{
380 if (size > list->u.dynarray_header.used)
381 {
382 bool ok;
383#if defined (DYNARRAY_ELEMENT_INIT)
384 /* The new elements have to be initialized. */
385 size_t old_size = list->u.dynarray_header.used;
386 ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
387 size, DYNARRAY_SCRATCH (list),
388 sizeof (DYNARRAY_ELEMENT));
389 if (ok)
390 for (size_t i = old_size; i < size; ++i)
391 {
392 DYNARRAY_ELEMENT_INIT (&list->u.dynarray_header.array[i]);
393 }
394#elif defined (DYNARRAY_ELEMENT_FREE)
395 /* Zero initialization is needed so that the elements can be
396 safely freed. */
397 ok = __libc_dynarray_resize_clear
398 (&list->u.dynarray_abstract, size,
399 DYNARRAY_SCRATCH (list), sizeof (DYNARRAY_ELEMENT));
400#else
401 ok = __libc_dynarray_resize (&list->u.dynarray_abstract,
402 size, DYNARRAY_SCRATCH (list),
403 sizeof (DYNARRAY_ELEMENT));
404#endif
405 if (__glibc_unlikely (!ok))
406 DYNARRAY_NAME (mark_failed) (list);
407 return ok;
408 }
409 else
410 {
411 /* The list has shrunk in size. Free the removed elements. */
412 DYNARRAY_NAME (free__elements__)
413 (list->u.dynarray_header.array + size,
414 list->u.dynarray_header.used - size);
415 list->u.dynarray_header.used = size;
416 return true;
417 }
418}
419
420/* Remove the last element of LIST if it is present. */
421__attribute_maybe_unused__ __attribute_nonnull__ ((1))
422static void
423DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
424{
425 /* used > 0 implies that the array is the non-failed state. */
426 if (list->u.dynarray_header.used > 0)
427 {
428 size_t new_length = list->u.dynarray_header.used - 1;
429#ifdef DYNARRAY_ELEMENT_FREE
430 DYNARRAY_ELEMENT_FREE (&list->u.dynarray_header.array[new_length]);
431#endif
432 list->u.dynarray_header.used = new_length;
433 }
434}
435
436/* Remove all elements from the list. The elements are freed, but the
437 list itself is not. */
438__attribute_maybe_unused__ __attribute_nonnull__ ((1))
439static void
440DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
441{
442 /* free__elements__ does nothing if the list is in the failed
443 state. */
444 DYNARRAY_NAME (free__elements__)
445 (list->u.dynarray_header.array, list->u.dynarray_header.used);
446 list->u.dynarray_header.used = 0;
447}
448
449#ifdef DYNARRAY_FINAL_TYPE
450/* Transfer the dynamic array to a permanent location at *RESULT.
451 Returns true on success on false on allocation failure. In either
452 case, *LIST is re-initialized and can be reused. A NULL pointer is
453 stored in *RESULT if LIST refers to an empty list. On success, the
454 pointer in *RESULT is heap-allocated and must be deallocated using
455 free. */
456__attribute_maybe_unused__ __attribute_warn_unused_result__
457__attribute_nonnull__ ((1, 2))
458static bool
459DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
460 DYNARRAY_FINAL_TYPE *result)
461{
462 struct dynarray_finalize_result res;
463 if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
464 DYNARRAY_SCRATCH (list),
465 sizeof (DYNARRAY_ELEMENT), &res))
466 {
467 /* On success, the result owns all the data. */
468 DYNARRAY_NAME (init) (list);
469 *result = (DYNARRAY_FINAL_TYPE) { res.array, res.length };
470 return true;
471 }
472 else
473 {
474 /* On error, we need to free all data. */
475 DYNARRAY_FREE (list);
476 errno = ENOMEM;
477 return false;
478 }
479}
480#else /* !DYNARRAY_FINAL_TYPE */
481/* Transfer the dynamic array to a heap-allocated array and return a
482 pointer to it. The pointer is NULL if memory allocation fails, or
483 if the array is empty, so this function should be used only for
484 arrays which are known not be empty (usually because they always
485 have a sentinel at the end). If LENGTHP is not NULL, the array
486 length is written to *LENGTHP. *LIST is re-initialized and can be
487 reused. */
488__attribute_maybe_unused__ __attribute_warn_unused_result__
489__attribute_nonnull__ ((1))
490static DYNARRAY_ELEMENT *
491DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
492{
493 struct dynarray_finalize_result res;
494 if (__libc_dynarray_finalize (&list->u.dynarray_abstract,
495 DYNARRAY_SCRATCH (list),
496 sizeof (DYNARRAY_ELEMENT), &res))
497 {
498 /* On success, the result owns all the data. */
499 DYNARRAY_NAME (init) (list);
500 if (lengthp != NULL)
501 *lengthp = res.length;
502 return res.array;
503 }
504 else
505 {
506 /* On error, we need to free all data. */
507 DYNARRAY_FREE (list);
508 errno = ENOMEM;
509 return NULL;
510 }
511}
512#endif /* !DYNARRAY_FINAL_TYPE */
513
514/* Undo macro definitions. */
515
516#undef DYNARRAY_CONCAT0
517#undef DYNARRAY_CONCAT1
518#undef DYNARRAY_NAME
519#undef DYNARRAY_SCRATCH
520#undef DYNARRAY_HAVE_SCRATCH
521
522#undef DYNARRAY_STRUCT
523#undef DYNARRAY_ELEMENT
524#undef DYNARRAY_PREFIX
525#undef DYNARRAY_ELEMENT_FREE
526#undef DYNARRAY_ELEMENT_INIT
527#undef DYNARRAY_INITIAL_SIZE
528#undef DYNARRAY_FINAL_TYPE
diff --git a/gl/malloc/dynarray.h b/gl/malloc/dynarray.h
new file mode 100644
index 0000000..a9a3b08
--- /dev/null
+++ b/gl/malloc/dynarray.h
@@ -0,0 +1,177 @@
1/* Type-safe arrays which grow dynamically. Shared definitions.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* To use the dynarray facility, you need to include
20 <malloc/dynarray-skeleton.c> and define the parameter macros
21 documented in that file.
22
23 A minimal example which provides a growing list of integers can be
24 defined like this:
25
26 struct int_array
27 {
28 // Pointer to result array followed by its length,
29 // as required by DYNARRAY_FINAL_TYPE.
30 int *array;
31 size_t length;
32 };
33
34 #define DYNARRAY_STRUCT dynarray_int
35 #define DYNARRAY_ELEMENT int
36 #define DYNARRAY_PREFIX dynarray_int_
37 #define DYNARRAY_FINAL_TYPE struct int_array
38 #include <malloc/dynarray-skeleton.c>
39
40 To create a three-element array with elements 1, 2, 3, use this
41 code:
42
43 struct dynarray_int dyn;
44 dynarray_int_init (&dyn);
45 for (int i = 1; i <= 3; ++i)
46 {
47 int *place = dynarray_int_emplace (&dyn);
48 assert (place != NULL);
49 *place = i;
50 }
51 struct int_array result;
52 bool ok = dynarray_int_finalize (&dyn, &result);
53 assert (ok);
54 assert (result.length == 3);
55 assert (result.array[0] == 1);
56 assert (result.array[1] == 2);
57 assert (result.array[2] == 3);
58 free (result.array);
59
60 If the elements contain resources which must be freed, define
61 DYNARRAY_ELEMENT_FREE appropriately, like this:
62
63 struct str_array
64 {
65 char **array;
66 size_t length;
67 };
68
69 #define DYNARRAY_STRUCT dynarray_str
70 #define DYNARRAY_ELEMENT char *
71 #define DYNARRAY_ELEMENT_FREE(ptr) free (*ptr)
72 #define DYNARRAY_PREFIX dynarray_str_
73 #define DYNARRAY_FINAL_TYPE struct str_array
74 #include <malloc/dynarray-skeleton.c>
75
76 Compared to scratch buffers, dynamic arrays have the following
77 features:
78
79 - They have an element type, and are not just an untyped buffer of
80 bytes.
81
82 - When growing, previously stored elements are preserved. (It is
83 expected that scratch_buffer_grow_preserve and
84 scratch_buffer_set_array_size eventually go away because all
85 current users are moved to dynamic arrays.)
86
87 - Scratch buffers have a more aggressive growth policy because
88 growing them typically means a retry of an operation (across an
89 NSS service module boundary), which is expensive.
90
91 - For the same reason, scratch buffers have a much larger initial
92 stack allocation. */
93
94#ifndef _DYNARRAY_H
95#define _DYNARRAY_H
96
97#include <stddef.h>
98#include <string.h>
99
100struct dynarray_header
101{
102 size_t used;
103 size_t allocated;
104 void *array;
105};
106
107/* Marker used in the allocated member to indicate that an error was
108 encountered. */
109static inline size_t
110__dynarray_error_marker (void)
111{
112 return -1;
113}
114
115/* Internal function. See the has_failed function in
116 dynarray-skeleton.c. */
117static inline bool
118__dynarray_error (struct dynarray_header *list)
119{
120 return list->allocated == __dynarray_error_marker ();
121}
122
123/* Internal function. Enlarge the dynamically allocated area of the
124 array to make room for one more element. SCRATCH is a pointer to
125 the scratch area (which is not heap-allocated and must not be
126 freed). ELEMENT_SIZE is the size, in bytes, of one element.
127 Return false on failure, true on success. */
128bool __libc_dynarray_emplace_enlarge (struct dynarray_header *,
129 void *scratch, size_t element_size);
130
131/* Internal function. Enlarge the dynamically allocated area of the
132 array to make room for at least SIZE elements (which must be larger
133 than the existing used part of the dynamic array). SCRATCH is a
134 pointer to the scratch area (which is not heap-allocated and must
135 not be freed). ELEMENT_SIZE is the size, in bytes, of one element.
136 Return false on failure, true on success. */
137bool __libc_dynarray_resize (struct dynarray_header *, size_t size,
138 void *scratch, size_t element_size);
139
140/* Internal function. Like __libc_dynarray_resize, but clear the new
141 part of the dynamic array. */
142bool __libc_dynarray_resize_clear (struct dynarray_header *, size_t size,
143 void *scratch, size_t element_size);
144
145/* Internal type. */
146struct dynarray_finalize_result
147{
148 void *array;
149 size_t length;
150};
151
152/* Internal function. Copy the dynamically-allocated area to an
153 explicitly-sized heap allocation. SCRATCH is a pointer to the
154 embedded scratch space. ELEMENT_SIZE is the size, in bytes, of the
155 element type. On success, true is returned, and pointer and length
156 are written to *RESULT. On failure, false is returned. The caller
157 has to take care of some of the memory management; this function is
158 expected to be called from dynarray-skeleton.c. */
159bool __libc_dynarray_finalize (struct dynarray_header *list, void *scratch,
160 size_t element_size,
161 struct dynarray_finalize_result *result);
162
163
164/* Internal function. Terminate the process after an index error.
165 SIZE is the number of elements of the dynamic array. INDEX is the
166 lookup index which triggered the failure. */
167_Noreturn void __libc_dynarray_at_failure (size_t size, size_t index);
168
169#ifndef _ISOMAC
170libc_hidden_proto (__libc_dynarray_emplace_enlarge)
171libc_hidden_proto (__libc_dynarray_resize)
172libc_hidden_proto (__libc_dynarray_resize_clear)
173libc_hidden_proto (__libc_dynarray_finalize)
174libc_hidden_proto (__libc_dynarray_at_failure)
175#endif
176
177#endif /* _DYNARRAY_H */
diff --git a/gl/malloc/dynarray_at_failure.c b/gl/malloc/dynarray_at_failure.c
new file mode 100644
index 0000000..ebc9310
--- /dev/null
+++ b/gl/malloc/dynarray_at_failure.c
@@ -0,0 +1,40 @@
1/* Report an dynamic array index out of bounds condition.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21# include <stdlib.h>
22#endif
23
24#include <dynarray.h>
25#include <stdio.h>
26
27void
28__libc_dynarray_at_failure (size_t size, size_t index)
29{
30#ifdef _LIBC
31 char buf[200];
32 __snprintf (buf, sizeof (buf), "Fatal glibc error: "
33 "array index %zu not less than array length %zu\n",
34 index, size);
35 __libc_fatal (buf);
36#else
37 abort ();
38#endif
39}
40libc_hidden_def (__libc_dynarray_at_failure)
diff --git a/gl/malloc/dynarray_emplace_enlarge.c b/gl/malloc/dynarray_emplace_enlarge.c
new file mode 100644
index 0000000..7da5393
--- /dev/null
+++ b/gl/malloc/dynarray_emplace_enlarge.c
@@ -0,0 +1,77 @@
1/* Increase the size of a dynamic array in preparation of an emplace operation.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <errno.h>
25#include <intprops.h>
26#include <stdlib.h>
27#include <string.h>
28
29bool
30__libc_dynarray_emplace_enlarge (struct dynarray_header *list,
31 void *scratch, size_t element_size)
32{
33 size_t new_allocated;
34 if (list->allocated == 0)
35 {
36 /* No scratch buffer provided. Choose a reasonable default
37 size. */
38 if (element_size < 4)
39 new_allocated = 16;
40 else if (element_size < 8)
41 new_allocated = 8;
42 else
43 new_allocated = 4;
44 }
45 else
46 /* Increase the allocated size, using an exponential growth
47 policy. */
48 {
49 new_allocated = list->allocated + list->allocated / 2 + 1;
50 if (new_allocated <= list->allocated)
51 {
52 /* Overflow. */
53 __set_errno (ENOMEM);
54 return false;
55 }
56 }
57
58 size_t new_size;
59 if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size))
60 return false;
61 void *new_array;
62 if (list->array == scratch)
63 {
64 /* The previous array was not heap-allocated. */
65 new_array = malloc (new_size);
66 if (new_array != NULL && list->array != NULL)
67 memcpy (new_array, list->array, list->used * element_size);
68 }
69 else
70 new_array = realloc (list->array, new_size);
71 if (new_array == NULL)
72 return false;
73 list->array = new_array;
74 list->allocated = new_allocated;
75 return true;
76}
77libc_hidden_def (__libc_dynarray_emplace_enlarge)
diff --git a/gl/malloc/dynarray_finalize.c b/gl/malloc/dynarray_finalize.c
new file mode 100644
index 0000000..673595a
--- /dev/null
+++ b/gl/malloc/dynarray_finalize.c
@@ -0,0 +1,66 @@
1/* Copy the dynamically-allocated area to an explicitly-sized heap allocation.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <stdlib.h>
25#include <string.h>
26
27bool
28__libc_dynarray_finalize (struct dynarray_header *list,
29 void *scratch, size_t element_size,
30 struct dynarray_finalize_result *result)
31{
32 if (__dynarray_error (list))
33 /* The caller will reported the deferred error. */
34 return false;
35
36 size_t used = list->used;
37
38 /* Empty list. */
39 if (used == 0)
40 {
41 /* An empty list could still be backed by a heap-allocated
42 array. Free it if necessary. */
43 if (list->array != scratch)
44 free (list->array);
45 *result = (struct dynarray_finalize_result) { NULL, 0 };
46 return true;
47 }
48
49 size_t allocation_size = used * element_size;
50 void *heap_array = malloc (allocation_size);
51 if (heap_array != NULL)
52 {
53 /* The new array takes ownership of the strings. */
54 if (list->array != NULL)
55 memcpy (heap_array, list->array, allocation_size);
56 if (list->array != scratch)
57 free (list->array);
58 *result = (struct dynarray_finalize_result)
59 { .array = heap_array, .length = used };
60 return true;
61 }
62 else
63 /* The caller will perform the freeing operation. */
64 return false;
65}
66libc_hidden_def (__libc_dynarray_finalize)
diff --git a/gl/malloc/dynarray_resize.c b/gl/malloc/dynarray_resize.c
new file mode 100644
index 0000000..7ecd4de
--- /dev/null
+++ b/gl/malloc/dynarray_resize.c
@@ -0,0 +1,68 @@
1/* Increase the size of a dynamic array.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <errno.h>
25#include <intprops.h>
26#include <stdlib.h>
27#include <string.h>
28
29bool
30__libc_dynarray_resize (struct dynarray_header *list, size_t size,
31 void *scratch, size_t element_size)
32{
33 /* The existing allocation provides sufficient room. */
34 if (size <= list->allocated)
35 {
36 list->used = size;
37 return true;
38 }
39
40 /* Otherwise, use size as the new allocation size. The caller is
41 expected to provide the final size of the array, so there is no
42 over-allocation here. */
43
44 size_t new_size_bytes;
45 if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes))
46 {
47 /* Overflow. */
48 __set_errno (ENOMEM);
49 return false;
50 }
51 void *new_array;
52 if (list->array == scratch)
53 {
54 /* The previous array was not heap-allocated. */
55 new_array = malloc (new_size_bytes);
56 if (new_array != NULL && list->array != NULL)
57 memcpy (new_array, list->array, list->used * element_size);
58 }
59 else
60 new_array = realloc (list->array, new_size_bytes);
61 if (new_array == NULL)
62 return false;
63 list->array = new_array;
64 list->allocated = size;
65 list->used = size;
66 return true;
67}
68libc_hidden_def (__libc_dynarray_resize)
diff --git a/gl/malloc/dynarray_resize_clear.c b/gl/malloc/dynarray_resize_clear.c
new file mode 100644
index 0000000..bb23c52
--- /dev/null
+++ b/gl/malloc/dynarray_resize_clear.c
@@ -0,0 +1,39 @@
1/* Increase the size of a dynamic array and clear the new part.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _LIBC
20# include <libc-config.h>
21#endif
22
23#include <dynarray.h>
24#include <string.h>
25
26bool
27__libc_dynarray_resize_clear (struct dynarray_header *list, size_t size,
28 void *scratch, size_t element_size)
29{
30 size_t old_size = list->used;
31 if (!__libc_dynarray_resize (list, size, scratch, element_size))
32 return false;
33 /* __libc_dynarray_resize already checked for overflow. */
34 char *array = list->array;
35 memset (array + (old_size * element_size), 0,
36 (size - old_size) * element_size);
37 return true;
38}
39libc_hidden_def (__libc_dynarray_resize_clear)
diff --git a/gl/malloca.c b/gl/malloca.c
index 311be56..f055b1e 100644
--- a/gl/malloca.c
+++ b/gl/malloca.c
@@ -1,19 +1,19 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003, 2006-2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003, 2018.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#define _GL_USE_STDLIB_ALLOC 1 18#define _GL_USE_STDLIB_ALLOC 1
19#include <config.h> 19#include <config.h>
@@ -21,82 +21,56 @@
21/* Specification. */ 21/* Specification. */
22#include "malloca.h" 22#include "malloca.h"
23 23
24#include <stdint.h> 24#include <stdckdint.h>
25 25
26#include "verify.h" 26#include "idx.h"
27 27
28/* The speed critical point in this file is freea() applied to an alloca() 28/* The speed critical point in this file is freea() applied to an alloca()
29 result: it must be fast, to match the speed of alloca(). The speed of 29 result: it must be fast, to match the speed of alloca(). The speed of
30 mmalloca() and freea() in the other case are not critical, because they 30 mmalloca() and freea() in the other case are not critical, because they
31 are only invoked for big memory sizes. */ 31 are only invoked for big memory sizes.
32 32 Here we use a bit in the address as an indicator, an idea by Ondřej Bílka.
33#if HAVE_ALLOCA 33 malloca() can return three types of pointers:
34 34 - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation.
35/* Store the mmalloca() results in a hash table. This is needed to reliably 35 - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap
36 distinguish a mmalloca() result and an alloca() result. 36 allocation.
37 37 - NULL comes from a failed heap allocation. */
38 Although it is possible that the same pointer is returned by alloca() and 38
39 by mmalloca() at different times in the same application, it does not lead 39/* Type for holding very small pointer differences. */
40 to a bug in freea(), because: 40typedef unsigned char small_t;
41 - Before a pointer returned by alloca() can point into malloc()ed memory, 41/* Verify that it is wide enough. */
42 the function must return, and once this has happened the programmer must 42static_assert (2 * sa_alignment_max - 1 <= (small_t) -1);
43 not call freea() on it anyway.
44 - Before a pointer returned by mmalloca() can point into the stack, it
45 must be freed. The only function that can free it is freea(), and
46 when freea() frees it, it also removes it from the hash table. */
47
48#define MAGIC_NUMBER 0x1415fb4a
49#define MAGIC_SIZE sizeof (int)
50/* This is how the header info would look like without any alignment
51 considerations. */
52struct preliminary_header { void *next; int magic; };
53/* But the header's size must be a multiple of sa_alignment_max. */
54#define HEADER_SIZE \
55 (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max)
56union header {
57 void *next;
58 struct {
59 char room[HEADER_SIZE - MAGIC_SIZE];
60 int word;
61 } magic;
62};
63verify (HEADER_SIZE == sizeof (union header));
64/* We make the hash table quite big, so that during lookups the probability
65 of empty hash buckets is quite high. There is no need to make the hash
66 table resizable, because when the hash table gets filled so much that the
67 lookup becomes slow, it means that the application has memory leaks. */
68#define HASH_TABLE_SIZE 257
69static void * mmalloca_results[HASH_TABLE_SIZE];
70
71#endif
72 43
73void * 44void *
74mmalloca (size_t n) 45mmalloca (size_t n)
75{ 46{
76#if HAVE_ALLOCA 47#if HAVE_ALLOCA
77 /* Allocate one more word, that serves as an indicator for malloc()ed 48 /* Allocate one more word, used to determine the address to pass to freea(),
78 memory, so that freea() of an alloca() result is fast. */ 49 and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */
79 size_t nplus = n + HEADER_SIZE; 50 uintptr_t alignment2_mask = 2 * sa_alignment_max - 1;
80 51 int plus = sizeof (small_t) + alignment2_mask;
81 if (nplus >= n) 52 idx_t nplus;
53 if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))
82 { 54 {
83 void *p = malloc (nplus); 55 char *mem = (char *) malloc (nplus);
84 56
85 if (p != NULL) 57 if (mem != NULL)
86 { 58 {
87 size_t slot; 59 uintptr_t umem = (uintptr_t)mem, umemplus;
88 union header *h = p; 60 /* The ckd_add avoids signed integer overflow on
89 61 theoretical platforms where UINTPTR_MAX <= INT_MAX. */
90 p = h + 1; 62 ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
91 63 idx_t offset = ((umemplus & ~alignment2_mask)
92 /* Put a magic number into the indicator word. */ 64 + sa_alignment_max - umem);
93 h->magic.word = MAGIC_NUMBER; 65 void *vp = mem + offset;
94 66 small_t *p = vp;
95 /* Enter p into the hash table. */ 67 /* Here p >= mem + sizeof (small_t),
96 slot = (uintptr_t) p % HASH_TABLE_SIZE; 68 and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1
97 h->next = mmalloca_results[slot]; 69 hence p + n <= mem + nplus.
98 mmalloca_results[slot] = p; 70 So, the memory range [p, p+n) lies in the allocated memory range
99 71 [mem, mem + nplus). */
72 p[-1] = offset;
73 /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */
100 return p; 74 return p;
101 } 75 }
102 } 76 }
@@ -115,35 +89,24 @@ mmalloca (size_t n)
115void 89void
116freea (void *p) 90freea (void *p)
117{ 91{
118 /* mmalloca() may have returned NULL. */ 92 /* Check argument. */
119 if (p != NULL) 93 if ((uintptr_t) p & (sa_alignment_max - 1))
120 { 94 {
121 /* Attempt to quickly distinguish the mmalloca() result - which has 95 /* p was not the result of a malloca() call. Invalid argument. */
122 a magic indicator word - and the alloca() result - which has an 96 abort ();
123 uninitialized indicator word. It is for this test that sa_increment 97 }
124 additional bytes are allocated in the alloca() case. */ 98 /* Determine whether p was a non-NULL pointer returned by mmalloca(). */
125 if (((int *) p)[-1] == MAGIC_NUMBER) 99 if ((uintptr_t) p & sa_alignment_max)
126 { 100 {
127 /* Looks like a mmalloca() result. To see whether it really is one, 101 void *mem = (char *) p - ((small_t *) p)[-1];
128 perform a lookup in the hash table. */ 102 free (mem);
129 size_t slot = (uintptr_t) p % HASH_TABLE_SIZE;
130 void **chain = &mmalloca_results[slot];
131 for (; *chain != NULL;)
132 {
133 union header *h = p;
134 if (*chain == p)
135 {
136 /* Found it. Remove it from the hash table and free it. */
137 union header *p_begin = h - 1;
138 *chain = p_begin->next;
139 free (p_begin);
140 return;
141 }
142 h = *chain;
143 chain = &h[-1].next;
144 }
145 }
146 /* At this point, we know it was not a mmalloca() result. */
147 } 103 }
148} 104}
149#endif 105#endif
106
107/*
108 * Hey Emacs!
109 * Local Variables:
110 * coding: utf-8
111 * End:
112 */
diff --git a/gl/malloca.h b/gl/malloca.h
index 6fbe45e..325c727 100644
--- a/gl/malloca.h
+++ b/gl/malloca.h
@@ -1,19 +1,19 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _MALLOCA_H 18#ifndef _MALLOCA_H
19#define _MALLOCA_H 19#define _MALLOCA_H
@@ -21,6 +21,9 @@
21#include <alloca.h> 21#include <alloca.h>
22#include <stddef.h> 22#include <stddef.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <stdint.h>
25
26#include "xalloc-oversized.h"
24 27
25 28
26#ifdef __cplusplus 29#ifdef __cplusplus
@@ -48,40 +51,37 @@ extern "C" {
48# define safe_alloca(N) ((void) (N), NULL) 51# define safe_alloca(N) ((void) (N), NULL)
49#endif 52#endif
50 53
54/* Free a block of memory allocated through malloca(). */
55#if HAVE_ALLOCA
56extern void freea (void *p);
57#else
58# define freea free
59#endif
60
51/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of 61/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
52 memory allocated on the stack, that must be freed using freea() before 62 memory allocated on the stack, that must be freed using freea() before
53 the function returns. Upon failure, it returns NULL. */ 63 the function returns. Upon failure, it returns NULL. */
54#if HAVE_ALLOCA 64#if HAVE_ALLOCA
55# define malloca(N) \ 65# define malloca(N) \
56 ((N) < 4032 - sa_increment \ 66 ((N) < 4032 - (2 * sa_alignment_max - 1) \
57 ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \ 67 ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \
68 + (2 * sa_alignment_max - 1)) \
69 & ~(uintptr_t)(2 * sa_alignment_max - 1)) \
58 : mmalloca (N)) 70 : mmalloca (N))
59#else 71#else
60# define malloca(N) \ 72# define malloca(N) \
61 mmalloca (N) 73 mmalloca (N)
62#endif 74#endif
63extern void * mmalloca (size_t n); 75extern void *mmalloca (size_t n)
64 76 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (freea, 1)
65/* Free a block of memory allocated through malloca(). */ 77 _GL_ATTRIBUTE_ALLOC_SIZE ((1));
66#if HAVE_ALLOCA
67extern void freea (void *p);
68#else
69# define freea free
70#endif
71 78
72/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). 79/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
73 It allocates an array of N objects, each with S bytes of memory, 80 It allocates an array of N objects, each with S bytes of memory,
74 on the stack. S must be positive and N must be nonnegative. 81 on the stack. N and S should be nonnegative and free of side effects.
75 The array must be freed using freea() before the function returns. */ 82 The array must be freed using freea() before the function returns. */
76#if 1 83#define nmalloca(n, s) \
77/* Cf. the definition of xalloc_oversized. */ 84 (xalloc_oversized (n, s) ? NULL : malloca ((n) * (size_t) (s)))
78# define nmalloca(n, s) \
79 ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
80 ? NULL \
81 : malloca ((n) * (s)))
82#else
83extern void * nmalloca (size_t n, size_t s);
84#endif
85 85
86 86
87#ifdef __cplusplus 87#ifdef __cplusplus
@@ -92,7 +92,7 @@ extern void * nmalloca (size_t n, size_t s);
92/* ------------------- Auxiliary, non-public definitions ------------------- */ 92/* ------------------- Auxiliary, non-public definitions ------------------- */
93 93
94/* Determine the alignment of a type at compile time. */ 94/* Determine the alignment of a type at compile time. */
95#if defined __GNUC__ || defined __IBM__ALIGNOF__ 95#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__
96# define sa_alignof __alignof__ 96# define sa_alignof __alignof__
97#elif defined __cplusplus 97#elif defined __cplusplus
98 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; 98 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
@@ -115,19 +115,12 @@ enum
115 among all elementary types. */ 115 among all elementary types. */
116 sa_alignment_long = sa_alignof (long), 116 sa_alignment_long = sa_alignof (long),
117 sa_alignment_double = sa_alignof (double), 117 sa_alignment_double = sa_alignof (double),
118#if HAVE_LONG_LONG_INT
119 sa_alignment_longlong = sa_alignof (long long), 118 sa_alignment_longlong = sa_alignof (long long),
120#endif
121 sa_alignment_longdouble = sa_alignof (long double), 119 sa_alignment_longdouble = sa_alignof (long double),
122 sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) 120 sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
123#if HAVE_LONG_LONG_INT
124 | (sa_alignment_longlong - 1) 121 | (sa_alignment_longlong - 1)
125#endif
126 | (sa_alignment_longdouble - 1) 122 | (sa_alignment_longdouble - 1)
127 ) + 1, 123 ) + 1
128/* The increment that guarantees room for a magic word must be >= sizeof (int)
129 and a multiple of sa_alignment_max. */
130 sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max
131}; 124};
132 125
133#endif /* _MALLOCA_H */ 126#endif /* _MALLOCA_H */
diff --git a/gl/malloca.valgrind b/gl/malloca.valgrind
deleted file mode 100644
index 52f0a50..0000000
--- a/gl/malloca.valgrind
+++ /dev/null
@@ -1,7 +0,0 @@
1# Suppress a valgrind message about use of uninitialized memory in freea().
2# This use is OK because it provides only a speedup.
3{
4 freea
5 Memcheck:Cond
6 fun:freea
7}
diff --git a/gl/math.c b/gl/math.c
index ddb2ded..67cabbc 100644
--- a/gl/math.c
+++ b/gl/math.c
@@ -1,3 +1,22 @@
1/* Inline functions for <math.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define _GL_MATH_INLINE _GL_EXTERN_INLINE 20#define _GL_MATH_INLINE _GL_EXTERN_INLINE
3#include "math.h" 21#include "math.h"
22typedef int dummy;
diff --git a/gl/math.in.h b/gl/math.in.h
index 7189819..f3d58af 100644
--- a/gl/math.in.h
+++ b/gl/math.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <math.h>. 1/* A GNU-like <math.h>.
2 2
3 Copyright (C) 2002-2003, 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_MATH_H 18#ifndef _@GUARD_PREFIX@_MATH_H
19 19
@@ -22,17 +22,50 @@
22#endif 22#endif
23@PRAGMA_COLUMNS@ 23@PRAGMA_COLUMNS@
24 24
25#if defined _GL_INCLUDING_MATH_H
26/* Special invocation convention:
27 - On FreeBSD 12.2 we have a sequence of nested includes
28 <math.h> -> <stdlib.h> -> <sys/wait.h> -> <sys/types.h> -> <sys/select.h>
29 -> <signal.h> -> <pthread.h> -> <stdlib.h> -> <math.h>
30 In this situation, the functions are not yet declared, therefore we cannot
31 provide the C++ aliases. */
32
33#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
34
35#else
36/* Normal invocation convention. */
37
25/* The include_next requires a split double-inclusion guard. */ 38/* The include_next requires a split double-inclusion guard. */
39#define _GL_INCLUDING_MATH_H
26#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ 40#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
41#undef _GL_INCLUDING_MATH_H
27 42
28#ifndef _@GUARD_PREFIX@_MATH_H 43#ifndef _@GUARD_PREFIX@_MATH_H
29#define _@GUARD_PREFIX@_MATH_H 44#define _@GUARD_PREFIX@_MATH_H
30 45
46/* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in <fp.h>. */
47#if defined __VMS && ! defined NAN
48# include <fp.h>
49#endif
50
51#ifndef _GL_INLINE_HEADER_BEGIN
52 #error "Please include config.h first."
53#endif
31_GL_INLINE_HEADER_BEGIN 54_GL_INLINE_HEADER_BEGIN
32#ifndef _GL_MATH_INLINE 55#ifndef _GL_MATH_INLINE
33# define _GL_MATH_INLINE _GL_INLINE 56# define _GL_MATH_INLINE _GL_INLINE
34#endif 57#endif
35 58
59/* The __attribute__ feature is available in gcc versions 2.5 and later.
60 The attribute __const__ was added in gcc 2.95. */
61#ifndef _GL_ATTRIBUTE_CONST
62# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__
63# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
64# else
65# define _GL_ATTRIBUTE_CONST /* empty */
66# endif
67#endif
68
36/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 69/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
37 70
38/* The definition of _GL_ARG_NONNULL is copied here. */ 71/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -59,22 +92,24 @@ _gl_cxx_ ## func ## l (long double l) \
59{ \ 92{ \
60 return func (l); \ 93 return func (l); \
61} 94}
62# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \ 95# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func,rpl_func,rettype) \
63inline int \ 96_GL_BEGIN_NAMESPACE \
64func (float f) \ 97inline rettype \
98rpl_func (float f) \
65{ \ 99{ \
66 return _gl_cxx_ ## func ## f (f); \ 100 return _gl_cxx_ ## func ## f (f); \
67} \ 101} \
68inline int \ 102inline rettype \
69func (double d) \ 103rpl_func (double d) \
70{ \ 104{ \
71 return _gl_cxx_ ## func ## d (d); \ 105 return _gl_cxx_ ## func ## d (d); \
72} \ 106} \
73inline int \ 107inline rettype \
74func (long double l) \ 108rpl_func (long double l) \
75{ \ 109{ \
76 return _gl_cxx_ ## func ## l (l); \ 110 return _gl_cxx_ ## func ## l (l); \
77} 111} \
112_GL_END_NAMESPACE
78#endif 113#endif
79 114
80/* Helper macros to define a portability warning for the 115/* Helper macros to define a portability warning for the
@@ -82,27 +117,27 @@ func (long double l) \
82 classification macros with an argument of real-floating (that is, 117 classification macros with an argument of real-floating (that is,
83 one of float, double, or long double). */ 118 one of float, double, or long double). */
84#define _GL_WARN_REAL_FLOATING_DECL(func) \ 119#define _GL_WARN_REAL_FLOATING_DECL(func) \
85_GL_MATH_INLINE int \ 120_GL_MATH_INLINE int \
86rpl_ ## func ## f (float f) \ 121_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \
87{ \ 122 "use gnulib module " #func " for portability") \
88 return func (f); \ 123rpl_ ## func ## f (float f) \
89} \ 124{ \
90_GL_MATH_INLINE int \ 125 return func (f); \
91rpl_ ## func ## d (double d) \ 126} \
92{ \ 127_GL_MATH_INLINE int \
93 return func (d); \ 128_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \
94} \ 129 "use gnulib module " #func " for portability") \
95_GL_MATH_INLINE int \ 130rpl_ ## func ## d (double d) \
96rpl_ ## func ## l (long double l) \ 131{ \
97{ \ 132 return func (d); \
98 return func (l); \ 133} \
99} \ 134_GL_MATH_INLINE int \
100_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \ 135_GL_WARN_ON_USE_ATTRIBUTE (#func " is unportable - " \
101 "use gnulib module " #func " for portability"); \ 136 "use gnulib module " #func " for portability") \
102_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \ 137rpl_ ## func ## l (long double l) \
103 "use gnulib module " #func " for portability"); \ 138{ \
104_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \ 139 return func (l); \
105 "use gnulib module " #func " for portability") 140}
106#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \ 141#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
107 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \ 142 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \
108 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \ 143 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \
@@ -184,8 +219,17 @@ _NaN ()
184#endif 219#endif
185 220
186 221
187/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */ 222#if defined FP_ILOGB0 && defined FP_ILOGBNAN
188#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN) 223 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are correct. */
224# if defined __HAIKU__
225 /* Haiku: match what ilogb() does */
226# undef FP_ILOGB0
227# undef FP_ILOGBNAN
228# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
229# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
230# endif
231#else
232 /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
189# if defined __NetBSD__ || defined __sgi 233# if defined __NetBSD__ || defined __sgi
190 /* NetBSD, IRIX 6.5: match what ilogb() does */ 234 /* NetBSD, IRIX 6.5: match what ilogb() does */
191# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */ 235# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
@@ -207,11 +251,20 @@ _NaN ()
207 251
208 252
209#if @GNULIB_ACOSF@ 253#if @GNULIB_ACOSF@
210# if !@HAVE_ACOSF@ 254# if @REPLACE_ACOSF@
211# undef acosf 255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
256# undef acosf
257# define acosf rpl_acosf
258# endif
259_GL_FUNCDECL_RPL (acosf, float, (float x));
260_GL_CXXALIAS_RPL (acosf, float, (float x));
261# else
262# if !@HAVE_ACOSF@
263# undef acosf
212_GL_FUNCDECL_SYS (acosf, float, (float x)); 264_GL_FUNCDECL_SYS (acosf, float, (float x));
213# endif 265# endif
214_GL_CXXALIAS_SYS (acosf, float, (float x)); 266_GL_CXXALIAS_SYS (acosf, float, (float x));
267# endif
215_GL_CXXALIASWARN (acosf); 268_GL_CXXALIASWARN (acosf);
216#elif defined GNULIB_POSIXCHECK 269#elif defined GNULIB_POSIXCHECK
217# undef acosf 270# undef acosf
@@ -227,7 +280,9 @@ _GL_WARN_ON_USE (acosf, "acosf is unportable - "
227_GL_FUNCDECL_SYS (acosl, long double, (long double x)); 280_GL_FUNCDECL_SYS (acosl, long double, (long double x));
228# endif 281# endif
229_GL_CXXALIAS_SYS (acosl, long double, (long double x)); 282_GL_CXXALIAS_SYS (acosl, long double, (long double x));
283# if __GLIBC__ >= 2
230_GL_CXXALIASWARN (acosl); 284_GL_CXXALIASWARN (acosl);
285# endif
231#elif defined GNULIB_POSIXCHECK 286#elif defined GNULIB_POSIXCHECK
232# undef acosl 287# undef acosl
233# if HAVE_RAW_DECL_ACOSL 288# if HAVE_RAW_DECL_ACOSL
@@ -238,11 +293,20 @@ _GL_WARN_ON_USE (acosl, "acosl is unportable - "
238 293
239 294
240#if @GNULIB_ASINF@ 295#if @GNULIB_ASINF@
241# if !@HAVE_ASINF@ 296# if @REPLACE_ASINF@
242# undef asinf 297# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
298# undef asinf
299# define asinf rpl_asinf
300# endif
301_GL_FUNCDECL_RPL (asinf, float, (float x));
302_GL_CXXALIAS_RPL (asinf, float, (float x));
303# else
304# if !@HAVE_ASINF@
305# undef asinf
243_GL_FUNCDECL_SYS (asinf, float, (float x)); 306_GL_FUNCDECL_SYS (asinf, float, (float x));
244# endif 307# endif
245_GL_CXXALIAS_SYS (asinf, float, (float x)); 308_GL_CXXALIAS_SYS (asinf, float, (float x));
309# endif
246_GL_CXXALIASWARN (asinf); 310_GL_CXXALIASWARN (asinf);
247#elif defined GNULIB_POSIXCHECK 311#elif defined GNULIB_POSIXCHECK
248# undef asinf 312# undef asinf
@@ -258,7 +322,9 @@ _GL_WARN_ON_USE (asinf, "asinf is unportable - "
258_GL_FUNCDECL_SYS (asinl, long double, (long double x)); 322_GL_FUNCDECL_SYS (asinl, long double, (long double x));
259# endif 323# endif
260_GL_CXXALIAS_SYS (asinl, long double, (long double x)); 324_GL_CXXALIAS_SYS (asinl, long double, (long double x));
325# if __GLIBC__ >= 2
261_GL_CXXALIASWARN (asinl); 326_GL_CXXALIASWARN (asinl);
327# endif
262#elif defined GNULIB_POSIXCHECK 328#elif defined GNULIB_POSIXCHECK
263# undef asinl 329# undef asinl
264# if HAVE_RAW_DECL_ASINL 330# if HAVE_RAW_DECL_ASINL
@@ -269,11 +335,20 @@ _GL_WARN_ON_USE (asinl, "asinl is unportable - "
269 335
270 336
271#if @GNULIB_ATANF@ 337#if @GNULIB_ATANF@
272# if !@HAVE_ATANF@ 338# if @REPLACE_ATANF@
273# undef atanf 339# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340# undef atanf
341# define atanf rpl_atanf
342# endif
343_GL_FUNCDECL_RPL (atanf, float, (float x));
344_GL_CXXALIAS_RPL (atanf, float, (float x));
345# else
346# if !@HAVE_ATANF@
347# undef atanf
274_GL_FUNCDECL_SYS (atanf, float, (float x)); 348_GL_FUNCDECL_SYS (atanf, float, (float x));
275# endif 349# endif
276_GL_CXXALIAS_SYS (atanf, float, (float x)); 350_GL_CXXALIAS_SYS (atanf, float, (float x));
351# endif
277_GL_CXXALIASWARN (atanf); 352_GL_CXXALIASWARN (atanf);
278#elif defined GNULIB_POSIXCHECK 353#elif defined GNULIB_POSIXCHECK
279# undef atanf 354# undef atanf
@@ -289,7 +364,9 @@ _GL_WARN_ON_USE (atanf, "atanf is unportable - "
289_GL_FUNCDECL_SYS (atanl, long double, (long double x)); 364_GL_FUNCDECL_SYS (atanl, long double, (long double x));
290# endif 365# endif
291_GL_CXXALIAS_SYS (atanl, long double, (long double x)); 366_GL_CXXALIAS_SYS (atanl, long double, (long double x));
367# if __GLIBC__ >= 2
292_GL_CXXALIASWARN (atanl); 368_GL_CXXALIASWARN (atanl);
369# endif
293#elif defined GNULIB_POSIXCHECK 370#elif defined GNULIB_POSIXCHECK
294# undef atanl 371# undef atanl
295# if HAVE_RAW_DECL_ATANL 372# if HAVE_RAW_DECL_ATANL
@@ -300,11 +377,20 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
300 377
301 378
302#if @GNULIB_ATAN2F@ 379#if @GNULIB_ATAN2F@
303# if !@HAVE_ATAN2F@ 380# if @REPLACE_ATAN2F@
304# undef atan2f 381# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
382# undef atan2f
383# define atan2f rpl_atan2f
384# endif
385_GL_FUNCDECL_RPL (atan2f, float, (float y, float x));
386_GL_CXXALIAS_RPL (atan2f, float, (float y, float x));
387# else
388# if !@HAVE_ATAN2F@
389# undef atan2f
305_GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); 390_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
306# endif 391# endif
307_GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); 392_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
393# endif
308_GL_CXXALIASWARN (atan2f); 394_GL_CXXALIASWARN (atan2f);
309#elif defined GNULIB_POSIXCHECK 395#elif defined GNULIB_POSIXCHECK
310# undef atan2f 396# undef atan2f
@@ -343,7 +429,9 @@ _GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - "
343_GL_FUNCDECL_SYS (cbrt, double, (double x)); 429_GL_FUNCDECL_SYS (cbrt, double, (double x));
344# endif 430# endif
345_GL_CXXALIAS_SYS (cbrt, double, (double x)); 431_GL_CXXALIAS_SYS (cbrt, double, (double x));
346_GL_CXXALIASWARN (cbrt); 432# if __GLIBC__ >= 2
433_GL_CXXALIASWARN1 (cbrt, double, (double x));
434# endif
347#elif defined GNULIB_POSIXCHECK 435#elif defined GNULIB_POSIXCHECK
348# undef cbrt 436# undef cbrt
349# if HAVE_RAW_DECL_CBRT 437# if HAVE_RAW_DECL_CBRT
@@ -366,7 +454,9 @@ _GL_FUNCDECL_SYS (cbrtl, long double, (long double x));
366# endif 454# endif
367_GL_CXXALIAS_SYS (cbrtl, long double, (long double x)); 455_GL_CXXALIAS_SYS (cbrtl, long double, (long double x));
368# endif 456# endif
457# if __GLIBC__ >= 2
369_GL_CXXALIASWARN (cbrtl); 458_GL_CXXALIASWARN (cbrtl);
459# endif
370#elif defined GNULIB_POSIXCHECK 460#elif defined GNULIB_POSIXCHECK
371# undef cbrtl 461# undef cbrtl
372# if HAVE_RAW_DECL_CBRTL 462# if HAVE_RAW_DECL_CBRTL
@@ -403,6 +493,7 @@ _GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
403#if @GNULIB_CEIL@ 493#if @GNULIB_CEIL@
404# if @REPLACE_CEIL@ 494# if @REPLACE_CEIL@
405# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 495# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
496# undef ceil
406# define ceil rpl_ceil 497# define ceil rpl_ceil
407# endif 498# endif
408_GL_FUNCDECL_RPL (ceil, double, (double x)); 499_GL_FUNCDECL_RPL (ceil, double, (double x));
@@ -410,7 +501,9 @@ _GL_CXXALIAS_RPL (ceil, double, (double x));
410# else 501# else
411_GL_CXXALIAS_SYS (ceil, double, (double x)); 502_GL_CXXALIAS_SYS (ceil, double, (double x));
412# endif 503# endif
413_GL_CXXALIASWARN (ceil); 504# if __GLIBC__ >= 2
505_GL_CXXALIASWARN1 (ceil, double, (double x));
506# endif
414#endif 507#endif
415 508
416#if @GNULIB_CEILL@ 509#if @GNULIB_CEILL@
@@ -428,7 +521,9 @@ _GL_FUNCDECL_SYS (ceill, long double, (long double x));
428# endif 521# endif
429_GL_CXXALIAS_SYS (ceill, long double, (long double x)); 522_GL_CXXALIAS_SYS (ceill, long double, (long double x));
430# endif 523# endif
524# if __GLIBC__ >= 2
431_GL_CXXALIASWARN (ceill); 525_GL_CXXALIASWARN (ceill);
526# endif
432#elif defined GNULIB_POSIXCHECK 527#elif defined GNULIB_POSIXCHECK
433# undef ceill 528# undef ceill
434# if HAVE_RAW_DECL_CEILL 529# if HAVE_RAW_DECL_CEILL
@@ -440,6 +535,7 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - "
440 535
441#if @GNULIB_COPYSIGNF@ 536#if @GNULIB_COPYSIGNF@
442# if !@HAVE_DECL_COPYSIGNF@ 537# if !@HAVE_DECL_COPYSIGNF@
538# undef copysignf
443_GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); 539_GL_FUNCDECL_SYS (copysignf, float, (float x, float y));
444# endif 540# endif
445_GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); 541_GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
@@ -457,7 +553,9 @@ _GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
457_GL_FUNCDECL_SYS (copysign, double, (double x, double y)); 553_GL_FUNCDECL_SYS (copysign, double, (double x, double y));
458# endif 554# endif
459_GL_CXXALIAS_SYS (copysign, double, (double x, double y)); 555_GL_CXXALIAS_SYS (copysign, double, (double x, double y));
460_GL_CXXALIASWARN (copysign); 556# if __GLIBC__ >= 2
557_GL_CXXALIASWARN1 (copysign, double, (double x, double y));
558# endif
461#elif defined GNULIB_POSIXCHECK 559#elif defined GNULIB_POSIXCHECK
462# undef copysign 560# undef copysign
463# if HAVE_RAW_DECL_COPYSIGN 561# if HAVE_RAW_DECL_COPYSIGN
@@ -471,7 +569,9 @@ _GL_WARN_ON_USE (copysign, "copysign is unportable - "
471_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); 569_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y));
472# endif 570# endif
473_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); 571_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
572# if __GLIBC__ >= 2
474_GL_CXXALIASWARN (copysignl); 573_GL_CXXALIASWARN (copysignl);
574# endif
475#elif defined GNULIB_POSIXCHECK 575#elif defined GNULIB_POSIXCHECK
476# undef copysignl 576# undef copysignl
477# if HAVE_RAW_DECL_COPYSIGNL 577# if HAVE_RAW_DECL_COPYSIGNL
@@ -482,11 +582,20 @@ _GL_WARN_ON_USE (copysign, "copysignl is unportable - "
482 582
483 583
484#if @GNULIB_COSF@ 584#if @GNULIB_COSF@
485# if !@HAVE_COSF@ 585# if @REPLACE_COSF@
486# undef cosf 586# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
587# undef cosf
588# define cosf rpl_cosf
589# endif
590_GL_FUNCDECL_RPL (cosf, float, (float x));
591_GL_CXXALIAS_RPL (cosf, float, (float x));
592# else
593# if !@HAVE_COSF@
594# undef cosf
487_GL_FUNCDECL_SYS (cosf, float, (float x)); 595_GL_FUNCDECL_SYS (cosf, float, (float x));
488# endif 596# endif
489_GL_CXXALIAS_SYS (cosf, float, (float x)); 597_GL_CXXALIAS_SYS (cosf, float, (float x));
598# endif
490_GL_CXXALIASWARN (cosf); 599_GL_CXXALIASWARN (cosf);
491#elif defined GNULIB_POSIXCHECK 600#elif defined GNULIB_POSIXCHECK
492# undef cosf 601# undef cosf
@@ -502,7 +611,9 @@ _GL_WARN_ON_USE (cosf, "cosf is unportable - "
502_GL_FUNCDECL_SYS (cosl, long double, (long double x)); 611_GL_FUNCDECL_SYS (cosl, long double, (long double x));
503# endif 612# endif
504_GL_CXXALIAS_SYS (cosl, long double, (long double x)); 613_GL_CXXALIAS_SYS (cosl, long double, (long double x));
614# if __GLIBC__ >= 2
505_GL_CXXALIASWARN (cosl); 615_GL_CXXALIASWARN (cosl);
616# endif
506#elif defined GNULIB_POSIXCHECK 617#elif defined GNULIB_POSIXCHECK
507# undef cosl 618# undef cosl
508# if HAVE_RAW_DECL_COSL 619# if HAVE_RAW_DECL_COSL
@@ -513,11 +624,20 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - "
513 624
514 625
515#if @GNULIB_COSHF@ 626#if @GNULIB_COSHF@
516# if !@HAVE_COSHF@ 627# if @REPLACE_COSHF@
517# undef coshf 628# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
629# undef coshf
630# define coshf rpl_coshf
631# endif
632_GL_FUNCDECL_RPL (coshf, float, (float x));
633_GL_CXXALIAS_RPL (coshf, float, (float x));
634# else
635# if !@HAVE_COSHF@
636# undef coshf
518_GL_FUNCDECL_SYS (coshf, float, (float x)); 637_GL_FUNCDECL_SYS (coshf, float, (float x));
519# endif 638# endif
520_GL_CXXALIAS_SYS (coshf, float, (float x)); 639_GL_CXXALIAS_SYS (coshf, float, (float x));
640# endif
521_GL_CXXALIASWARN (coshf); 641_GL_CXXALIASWARN (coshf);
522#elif defined GNULIB_POSIXCHECK 642#elif defined GNULIB_POSIXCHECK
523# undef coshf 643# undef coshf
@@ -529,11 +649,20 @@ _GL_WARN_ON_USE (coshf, "coshf is unportable - "
529 649
530 650
531#if @GNULIB_EXPF@ 651#if @GNULIB_EXPF@
532# if !@HAVE_EXPF@ 652# if @REPLACE_EXPF@
533# undef expf 653# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
654# undef expf
655# define expf rpl_expf
656# endif
657_GL_FUNCDECL_RPL (expf, float, (float x));
658_GL_CXXALIAS_RPL (expf, float, (float x));
659# else
660# if !@HAVE_EXPF@
661# undef expf
534_GL_FUNCDECL_SYS (expf, float, (float x)); 662_GL_FUNCDECL_SYS (expf, float, (float x));
535# endif 663# endif
536_GL_CXXALIAS_SYS (expf, float, (float x)); 664_GL_CXXALIAS_SYS (expf, float, (float x));
665# endif
537_GL_CXXALIASWARN (expf); 666_GL_CXXALIASWARN (expf);
538#elif defined GNULIB_POSIXCHECK 667#elif defined GNULIB_POSIXCHECK
539# undef expf 668# undef expf
@@ -544,12 +673,23 @@ _GL_WARN_ON_USE (expf, "expf is unportable - "
544#endif 673#endif
545 674
546#if @GNULIB_EXPL@ 675#if @GNULIB_EXPL@
547# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@ 676# if @REPLACE_EXPL@
548# undef expl 677# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
678# undef expl
679# define expl rpl_expl
680# endif
681_GL_FUNCDECL_RPL (expl, long double, (long double x));
682_GL_CXXALIAS_RPL (expl, long double, (long double x));
683# else
684# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
685# undef expl
549_GL_FUNCDECL_SYS (expl, long double, (long double x)); 686_GL_FUNCDECL_SYS (expl, long double, (long double x));
550# endif 687# endif
551_GL_CXXALIAS_SYS (expl, long double, (long double x)); 688_GL_CXXALIAS_SYS (expl, long double, (long double x));
689# endif
690# if __GLIBC__ >= 2
552_GL_CXXALIASWARN (expl); 691_GL_CXXALIASWARN (expl);
692# endif
553#elif defined GNULIB_POSIXCHECK 693#elif defined GNULIB_POSIXCHECK
554# undef expl 694# undef expl
555# if HAVE_RAW_DECL_EXPL 695# if HAVE_RAW_DECL_EXPL
@@ -587,7 +727,9 @@ _GL_FUNCDECL_SYS (exp2, double, (double x));
587# endif 727# endif
588_GL_CXXALIAS_SYS (exp2, double, (double x)); 728_GL_CXXALIAS_SYS (exp2, double, (double x));
589# endif 729# endif
590_GL_CXXALIASWARN (exp2); 730# if __GLIBC__ >= 2
731_GL_CXXALIASWARN1 (exp2, double, (double x));
732# endif
591#elif defined GNULIB_POSIXCHECK 733#elif defined GNULIB_POSIXCHECK
592# undef exp2 734# undef exp2
593# if HAVE_RAW_DECL_EXP2 735# if HAVE_RAW_DECL_EXP2
@@ -611,7 +753,9 @@ _GL_FUNCDECL_SYS (exp2l, long double, (long double x));
611# endif 753# endif
612_GL_CXXALIAS_SYS (exp2l, long double, (long double x)); 754_GL_CXXALIAS_SYS (exp2l, long double, (long double x));
613# endif 755# endif
756# if __GLIBC__ >= 2
614_GL_CXXALIASWARN (exp2l); 757_GL_CXXALIASWARN (exp2l);
758# endif
615#elif defined GNULIB_POSIXCHECK 759#elif defined GNULIB_POSIXCHECK
616# undef exp2l 760# undef exp2l
617# if HAVE_RAW_DECL_EXP2L 761# if HAVE_RAW_DECL_EXP2L
@@ -658,7 +802,9 @@ _GL_FUNCDECL_SYS (expm1, double, (double x));
658# endif 802# endif
659_GL_CXXALIAS_SYS (expm1, double, (double x)); 803_GL_CXXALIAS_SYS (expm1, double, (double x));
660# endif 804# endif
661_GL_CXXALIASWARN (expm1); 805# if __GLIBC__ >= 2
806_GL_CXXALIASWARN1 (expm1, double, (double x));
807# endif
662#elif defined GNULIB_POSIXCHECK 808#elif defined GNULIB_POSIXCHECK
663# undef expm1 809# undef expm1
664# if HAVE_RAW_DECL_EXPM1 810# if HAVE_RAW_DECL_EXPM1
@@ -668,12 +814,25 @@ _GL_WARN_ON_USE (expm1, "expm1 is unportable - "
668#endif 814#endif
669 815
670#if @GNULIB_EXPM1L@ 816#if @GNULIB_EXPM1L@
671# if !@HAVE_DECL_EXPM1L@ 817# if @REPLACE_EXPM1L@
672# undef expm1l 818# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
819# undef expm1l
820# define expm1l rpl_expm1l
821# endif
822_GL_FUNCDECL_RPL (expm1l, long double, (long double x));
823_GL_CXXALIAS_RPL (expm1l, long double, (long double x));
824# else
825# if !@HAVE_DECL_EXPM1L@
826# undef expm1l
827# if !(defined __cplusplus && defined _AIX)
673_GL_FUNCDECL_SYS (expm1l, long double, (long double x)); 828_GL_FUNCDECL_SYS (expm1l, long double, (long double x));
674# endif 829# endif
830# endif
675_GL_CXXALIAS_SYS (expm1l, long double, (long double x)); 831_GL_CXXALIAS_SYS (expm1l, long double, (long double x));
832# endif
833# if __GLIBC__ >= 2
676_GL_CXXALIASWARN (expm1l); 834_GL_CXXALIASWARN (expm1l);
835# endif
677#elif defined GNULIB_POSIXCHECK 836#elif defined GNULIB_POSIXCHECK
678# undef expm1l 837# undef expm1l
679# if HAVE_RAW_DECL_EXPM1L 838# if HAVE_RAW_DECL_EXPM1L
@@ -689,7 +848,9 @@ _GL_WARN_ON_USE (expm1l, "expm1l is unportable - "
689_GL_FUNCDECL_SYS (fabsf, float, (float x)); 848_GL_FUNCDECL_SYS (fabsf, float, (float x));
690# endif 849# endif
691_GL_CXXALIAS_SYS (fabsf, float, (float x)); 850_GL_CXXALIAS_SYS (fabsf, float, (float x));
851# if __GLIBC__ >= 2
692_GL_CXXALIASWARN (fabsf); 852_GL_CXXALIASWARN (fabsf);
853# endif
693#elif defined GNULIB_POSIXCHECK 854#elif defined GNULIB_POSIXCHECK
694# undef fabsf 855# undef fabsf
695# if HAVE_RAW_DECL_FABSF 856# if HAVE_RAW_DECL_FABSF
@@ -713,7 +874,9 @@ _GL_FUNCDECL_SYS (fabsl, long double, (long double x));
713# endif 874# endif
714_GL_CXXALIAS_SYS (fabsl, long double, (long double x)); 875_GL_CXXALIAS_SYS (fabsl, long double, (long double x));
715# endif 876# endif
877# if __GLIBC__ >= 2
716_GL_CXXALIASWARN (fabsl); 878_GL_CXXALIASWARN (fabsl);
879# endif
717#elif defined GNULIB_POSIXCHECK 880#elif defined GNULIB_POSIXCHECK
718# undef fabsl 881# undef fabsl
719# if HAVE_RAW_DECL_FABSL 882# if HAVE_RAW_DECL_FABSL
@@ -750,6 +913,7 @@ _GL_WARN_ON_USE (floorf, "floorf is unportable - "
750#if @GNULIB_FLOOR@ 913#if @GNULIB_FLOOR@
751# if @REPLACE_FLOOR@ 914# if @REPLACE_FLOOR@
752# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 915# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
916# undef floor
753# define floor rpl_floor 917# define floor rpl_floor
754# endif 918# endif
755_GL_FUNCDECL_RPL (floor, double, (double x)); 919_GL_FUNCDECL_RPL (floor, double, (double x));
@@ -757,7 +921,9 @@ _GL_CXXALIAS_RPL (floor, double, (double x));
757# else 921# else
758_GL_CXXALIAS_SYS (floor, double, (double x)); 922_GL_CXXALIAS_SYS (floor, double, (double x));
759# endif 923# endif
760_GL_CXXALIASWARN (floor); 924# if __GLIBC__ >= 2
925_GL_CXXALIASWARN1 (floor, double, (double x));
926# endif
761#endif 927#endif
762 928
763#if @GNULIB_FLOORL@ 929#if @GNULIB_FLOORL@
@@ -775,7 +941,9 @@ _GL_FUNCDECL_SYS (floorl, long double, (long double x));
775# endif 941# endif
776_GL_CXXALIAS_SYS (floorl, long double, (long double x)); 942_GL_CXXALIAS_SYS (floorl, long double, (long double x));
777# endif 943# endif
944# if __GLIBC__ >= 2
778_GL_CXXALIASWARN (floorl); 945_GL_CXXALIASWARN (floorl);
946# endif
779#elif defined GNULIB_POSIXCHECK 947#elif defined GNULIB_POSIXCHECK
780# undef floorl 948# undef floorl
781# if HAVE_RAW_DECL_FLOORL 949# if HAVE_RAW_DECL_FLOORL
@@ -795,6 +963,7 @@ _GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z));
795_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); 963_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z));
796# else 964# else
797# if !@HAVE_FMAF@ 965# if !@HAVE_FMAF@
966# undef fmaf
798_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); 967_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z));
799# endif 968# endif
800_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); 969_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z));
@@ -818,11 +987,14 @@ _GL_FUNCDECL_RPL (fma, double, (double x, double y, double z));
818_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); 987_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z));
819# else 988# else
820# if !@HAVE_FMA@ 989# if !@HAVE_FMA@
990# undef fma
821_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); 991_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z));
822# endif 992# endif
823_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); 993_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z));
824# endif 994# endif
825_GL_CXXALIASWARN (fma); 995# if __GLIBC__ >= 2
996_GL_CXXALIASWARN1 (fma, double, (double x, double y, double z));
997# endif
826#elif defined GNULIB_POSIXCHECK 998#elif defined GNULIB_POSIXCHECK
827# undef fma 999# undef fma
828# if HAVE_RAW_DECL_FMA 1000# if HAVE_RAW_DECL_FMA
@@ -844,13 +1016,17 @@ _GL_CXXALIAS_RPL (fmal, long double,
844# else 1016# else
845# if !@HAVE_FMAL@ 1017# if !@HAVE_FMAL@
846# undef fmal 1018# undef fmal
1019# if !(defined __cplusplus && defined _AIX)
847_GL_FUNCDECL_SYS (fmal, long double, 1020_GL_FUNCDECL_SYS (fmal, long double,
848 (long double x, long double y, long double z)); 1021 (long double x, long double y, long double z));
1022# endif
849# endif 1023# endif
850_GL_CXXALIAS_SYS (fmal, long double, 1024_GL_CXXALIAS_SYS (fmal, long double,
851 (long double x, long double y, long double z)); 1025 (long double x, long double y, long double z));
852# endif 1026# endif
1027# if __GLIBC__ >= 2
853_GL_CXXALIASWARN (fmal); 1028_GL_CXXALIASWARN (fmal);
1029# endif
854#elif defined GNULIB_POSIXCHECK 1030#elif defined GNULIB_POSIXCHECK
855# undef fmal 1031# undef fmal
856# if HAVE_RAW_DECL_FMAL 1032# if HAVE_RAW_DECL_FMAL
@@ -895,7 +1071,9 @@ _GL_CXXALIAS_RPL (fmod, double, (double x, double y));
895# else 1071# else
896_GL_CXXALIAS_SYS (fmod, double, (double x, double y)); 1072_GL_CXXALIAS_SYS (fmod, double, (double x, double y));
897# endif 1073# endif
898_GL_CXXALIASWARN (fmod); 1074# if __GLIBC__ >= 2
1075_GL_CXXALIASWARN1 (fmod, double, (double x, double y));
1076# endif
899#elif defined GNULIB_POSIXCHECK 1077#elif defined GNULIB_POSIXCHECK
900# undef fmod 1078# undef fmod
901# if HAVE_RAW_DECL_FMOD 1079# if HAVE_RAW_DECL_FMOD
@@ -919,7 +1097,9 @@ _GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y));
919# endif 1097# endif
920_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y)); 1098_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y));
921# endif 1099# endif
1100# if __GLIBC__ >= 2
922_GL_CXXALIASWARN (fmodl); 1101_GL_CXXALIASWARN (fmodl);
1102# endif
923#elif defined GNULIB_POSIXCHECK 1103#elif defined GNULIB_POSIXCHECK
924# undef fmodl 1104# undef fmodl
925# if HAVE_RAW_DECL_FMODL 1105# if HAVE_RAW_DECL_FMODL
@@ -951,7 +1131,9 @@ _GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
951# endif 1131# endif
952_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr)); 1132_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
953# endif 1133# endif
1134# if __GLIBC__ >= 2
954_GL_CXXALIASWARN (frexpf); 1135_GL_CXXALIASWARN (frexpf);
1136# endif
955#elif defined GNULIB_POSIXCHECK 1137#elif defined GNULIB_POSIXCHECK
956# undef frexpf 1138# undef frexpf
957# if HAVE_RAW_DECL_FREXPF 1139# if HAVE_RAW_DECL_FREXPF
@@ -970,6 +1152,7 @@ _GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
970#if @GNULIB_FREXP@ 1152#if @GNULIB_FREXP@
971# if @REPLACE_FREXP@ 1153# if @REPLACE_FREXP@
972# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1154# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1155# undef frexp
973# define frexp rpl_frexp 1156# define frexp rpl_frexp
974# endif 1157# endif
975_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2))); 1158_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
@@ -977,7 +1160,9 @@ _GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
977# else 1160# else
978_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); 1161_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
979# endif 1162# endif
980_GL_CXXALIASWARN (frexp); 1163# if __GLIBC__ >= 2
1164_GL_CXXALIASWARN1 (frexp, double, (double x, int *expptr));
1165# endif
981#elif defined GNULIB_POSIXCHECK 1166#elif defined GNULIB_POSIXCHECK
982# undef frexp 1167# undef frexp
983/* Assume frexp is always declared. */ 1168/* Assume frexp is always declared. */
@@ -1010,7 +1195,9 @@ _GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr));
1010# endif 1195# endif
1011#endif 1196#endif
1012#if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@) 1197#if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@)
1198# if __GLIBC__ >= 2
1013_GL_CXXALIASWARN (frexpl); 1199_GL_CXXALIASWARN (frexpl);
1200# endif
1014#endif 1201#endif
1015#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK 1202#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
1016# undef frexpl 1203# undef frexpl
@@ -1036,7 +1223,9 @@ _GL_FUNCDECL_SYS (hypotf, float, (float x, float y));
1036# endif 1223# endif
1037_GL_CXXALIAS_SYS (hypotf, float, (float x, float y)); 1224_GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
1038# endif 1225# endif
1226# if __GLIBC__ >= 2
1039_GL_CXXALIASWARN (hypotf); 1227_GL_CXXALIASWARN (hypotf);
1228# endif
1040#elif defined GNULIB_POSIXCHECK 1229#elif defined GNULIB_POSIXCHECK
1041# undef hypotf 1230# undef hypotf
1042# if HAVE_RAW_DECL_HYPOTF 1231# if HAVE_RAW_DECL_HYPOTF
@@ -1057,7 +1246,9 @@ _GL_CXXALIAS_RPL (hypot, double, (double x, double y));
1057# else 1246# else
1058_GL_CXXALIAS_SYS (hypot, double, (double x, double y)); 1247_GL_CXXALIAS_SYS (hypot, double, (double x, double y));
1059# endif 1248# endif
1060_GL_CXXALIASWARN (hypot); 1249# if __GLIBC__ >= 2
1250_GL_CXXALIASWARN1 (hypot, double, (double x, double y));
1251# endif
1061#elif defined GNULIB_POSIXCHECK 1252#elif defined GNULIB_POSIXCHECK
1062# undef hypot 1253# undef hypot
1063# if HAVE_RAW_DECL_HYPOT 1254# if HAVE_RAW_DECL_HYPOT
@@ -1081,7 +1272,9 @@ _GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y));
1081# endif 1272# endif
1082_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y)); 1273_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y));
1083# endif 1274# endif
1275# if __GLIBC__ >= 2
1084_GL_CXXALIASWARN (hypotl); 1276_GL_CXXALIASWARN (hypotl);
1277# endif
1085#elif defined GNULIB_POSIXCHECK 1278#elif defined GNULIB_POSIXCHECK
1086# undef hypotl 1279# undef hypotl
1087# if HAVE_RAW_DECL_HYPOTL 1280# if HAVE_RAW_DECL_HYPOTL
@@ -1128,7 +1321,9 @@ _GL_FUNCDECL_SYS (ilogb, int, (double x));
1128# endif 1321# endif
1129_GL_CXXALIAS_SYS (ilogb, int, (double x)); 1322_GL_CXXALIAS_SYS (ilogb, int, (double x));
1130# endif 1323# endif
1131_GL_CXXALIASWARN (ilogb); 1324# if __GLIBC__ >= 2
1325_GL_CXXALIASWARN1 (ilogb, int, (double x));
1326# endif
1132#elif defined GNULIB_POSIXCHECK 1327#elif defined GNULIB_POSIXCHECK
1133# undef ilogb 1328# undef ilogb
1134# if HAVE_RAW_DECL_ILOGB 1329# if HAVE_RAW_DECL_ILOGB
@@ -1138,11 +1333,23 @@ _GL_WARN_ON_USE (ilogb, "ilogb is unportable - "
1138#endif 1333#endif
1139 1334
1140#if @GNULIB_ILOGBL@ 1335#if @GNULIB_ILOGBL@
1141# if !@HAVE_ILOGBL@ 1336# if @REPLACE_ILOGBL@
1337# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1338# undef ilogbl
1339# define ilogbl rpl_ilogbl
1340# endif
1341_GL_FUNCDECL_RPL (ilogbl, int, (long double x));
1342_GL_CXXALIAS_RPL (ilogbl, int, (long double x));
1343# else
1344# if !@HAVE_ILOGBL@
1345# undef ilogbl
1142_GL_FUNCDECL_SYS (ilogbl, int, (long double x)); 1346_GL_FUNCDECL_SYS (ilogbl, int, (long double x));
1143# endif 1347# endif
1144_GL_CXXALIAS_SYS (ilogbl, int, (long double x)); 1348_GL_CXXALIAS_SYS (ilogbl, int, (long double x));
1349# endif
1350# if __GLIBC__ >= 2
1145_GL_CXXALIASWARN (ilogbl); 1351_GL_CXXALIASWARN (ilogbl);
1352# endif
1146#elif defined GNULIB_POSIXCHECK 1353#elif defined GNULIB_POSIXCHECK
1147# undef ilogbl 1354# undef ilogbl
1148# if HAVE_RAW_DECL_ILOGBL 1355# if HAVE_RAW_DECL_ILOGBL
@@ -1152,6 +1359,55 @@ _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
1152#endif 1359#endif
1153 1360
1154 1361
1362#if @GNULIB_MDA_J0@
1363/* On native Windows, map 'j0' to '_j0', so that -loldnames is not
1364 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1365 platforms by defining GNULIB_NAMESPACE::j0 always. */
1366# if defined _WIN32 && !defined __CYGWIN__
1367# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1368# undef j0
1369# define j0 _j0
1370# endif
1371_GL_CXXALIAS_MDA (j0, double, (double x));
1372# else
1373_GL_CXXALIAS_SYS (j0, double, (double x));
1374# endif
1375_GL_CXXALIASWARN (j0);
1376#endif
1377
1378#if @GNULIB_MDA_J1@
1379/* On native Windows, map 'j1' to '_j1', so that -loldnames is not
1380 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1381 platforms by defining GNULIB_NAMESPACE::j1 always. */
1382# if defined _WIN32 && !defined __CYGWIN__
1383# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1384# undef j1
1385# define j1 _j1
1386# endif
1387_GL_CXXALIAS_MDA (j1, double, (double x));
1388# else
1389_GL_CXXALIAS_SYS (j1, double, (double x));
1390# endif
1391_GL_CXXALIASWARN (j1);
1392#endif
1393
1394#if @GNULIB_MDA_JN@
1395/* On native Windows, map 'jn' to '_jn', so that -loldnames is not
1396 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1397 platforms by defining GNULIB_NAMESPACE::jn always. */
1398# if defined _WIN32 && !defined __CYGWIN__
1399# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1400# undef jn
1401# define jn _jn
1402# endif
1403_GL_CXXALIAS_MDA (jn, double, (int n, double x));
1404# else
1405_GL_CXXALIAS_SYS (jn, double, (int n, double x));
1406# endif
1407_GL_CXXALIASWARN (jn);
1408#endif
1409
1410
1155/* Return x * 2^exp. */ 1411/* Return x * 2^exp. */
1156#if @GNULIB_LDEXPF@ 1412#if @GNULIB_LDEXPF@
1157# if !@HAVE_LDEXPF@ 1413# if !@HAVE_LDEXPF@
@@ -1159,7 +1415,9 @@ _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
1159_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp)); 1415_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp));
1160# endif 1416# endif
1161_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp)); 1417_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp));
1418# if __GLIBC__ >= 2
1162_GL_CXXALIASWARN (ldexpf); 1419_GL_CXXALIASWARN (ldexpf);
1420# endif
1163#elif defined GNULIB_POSIXCHECK 1421#elif defined GNULIB_POSIXCHECK
1164# undef ldexpf 1422# undef ldexpf
1165# if HAVE_RAW_DECL_LDEXPF 1423# if HAVE_RAW_DECL_LDEXPF
@@ -1185,7 +1443,9 @@ _GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp));
1185# endif 1443# endif
1186#endif 1444#endif
1187#if @GNULIB_LDEXPL@ 1445#if @GNULIB_LDEXPL@
1446# if __GLIBC__ >= 2
1188_GL_CXXALIASWARN (ldexpl); 1447_GL_CXXALIASWARN (ldexpl);
1448# endif
1189#endif 1449#endif
1190#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK 1450#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
1191# undef ldexpl 1451# undef ldexpl
@@ -1231,7 +1491,9 @@ _GL_CXXALIAS_RPL (log, double, (double x));
1231# else 1491# else
1232_GL_CXXALIAS_SYS (log, double, (double x)); 1492_GL_CXXALIAS_SYS (log, double, (double x));
1233# endif 1493# endif
1234_GL_CXXALIASWARN (log); 1494# if __GLIBC__ >= 2
1495_GL_CXXALIASWARN1 (log, double, (double x));
1496# endif
1235#elif defined GNULIB_POSIXCHECK 1497#elif defined GNULIB_POSIXCHECK
1236# undef log 1498# undef log
1237# if HAVE_RAW_DECL_LOG 1499# if HAVE_RAW_DECL_LOG
@@ -1255,7 +1517,9 @@ _GL_FUNCDECL_SYS (logl, long double, (long double x));
1255# endif 1517# endif
1256_GL_CXXALIAS_SYS (logl, long double, (long double x)); 1518_GL_CXXALIAS_SYS (logl, long double, (long double x));
1257# endif 1519# endif
1520# if __GLIBC__ >= 2
1258_GL_CXXALIASWARN (logl); 1521_GL_CXXALIASWARN (logl);
1522# endif
1259#elif defined GNULIB_POSIXCHECK 1523#elif defined GNULIB_POSIXCHECK
1260# undef logl 1524# undef logl
1261# if HAVE_RAW_DECL_LOGL 1525# if HAVE_RAW_DECL_LOGL
@@ -1300,7 +1564,9 @@ _GL_CXXALIAS_RPL (log10, double, (double x));
1300# else 1564# else
1301_GL_CXXALIAS_SYS (log10, double, (double x)); 1565_GL_CXXALIAS_SYS (log10, double, (double x));
1302# endif 1566# endif
1303_GL_CXXALIASWARN (log10); 1567# if __GLIBC__ >= 2
1568_GL_CXXALIASWARN1 (log10, double, (double x));
1569# endif
1304#elif defined GNULIB_POSIXCHECK 1570#elif defined GNULIB_POSIXCHECK
1305# undef log10 1571# undef log10
1306# if HAVE_RAW_DECL_LOG10 1572# if HAVE_RAW_DECL_LOG10
@@ -1324,7 +1590,9 @@ _GL_FUNCDECL_SYS (log10l, long double, (long double x));
1324# endif 1590# endif
1325_GL_CXXALIAS_SYS (log10l, long double, (long double x)); 1591_GL_CXXALIAS_SYS (log10l, long double, (long double x));
1326# endif 1592# endif
1593# if __GLIBC__ >= 2
1327_GL_CXXALIASWARN (log10l); 1594_GL_CXXALIASWARN (log10l);
1595# endif
1328#elif defined GNULIB_POSIXCHECK 1596#elif defined GNULIB_POSIXCHECK
1329# undef log10l 1597# undef log10l
1330# if HAVE_RAW_DECL_LOG10L 1598# if HAVE_RAW_DECL_LOG10L
@@ -1371,7 +1639,9 @@ _GL_FUNCDECL_SYS (log1p, double, (double x));
1371# endif 1639# endif
1372_GL_CXXALIAS_SYS (log1p, double, (double x)); 1640_GL_CXXALIAS_SYS (log1p, double, (double x));
1373# endif 1641# endif
1374_GL_CXXALIASWARN (log1p); 1642# if __GLIBC__ >= 2
1643_GL_CXXALIASWARN1 (log1p, double, (double x));
1644# endif
1375#elif defined GNULIB_POSIXCHECK 1645#elif defined GNULIB_POSIXCHECK
1376# undef log1p 1646# undef log1p
1377# if HAVE_RAW_DECL_LOG1P 1647# if HAVE_RAW_DECL_LOG1P
@@ -1394,7 +1664,9 @@ _GL_FUNCDECL_SYS (log1pl, long double, (long double x));
1394# endif 1664# endif
1395_GL_CXXALIAS_SYS (log1pl, long double, (long double x)); 1665_GL_CXXALIAS_SYS (log1pl, long double, (long double x));
1396# endif 1666# endif
1667# if __GLIBC__ >= 2
1397_GL_CXXALIASWARN (log1pl); 1668_GL_CXXALIASWARN (log1pl);
1669# endif
1398#elif defined GNULIB_POSIXCHECK 1670#elif defined GNULIB_POSIXCHECK
1399# undef log1pl 1671# undef log1pl
1400# if HAVE_RAW_DECL_LOG1PL 1672# if HAVE_RAW_DECL_LOG1PL
@@ -1443,7 +1715,9 @@ _GL_FUNCDECL_SYS (log2, double, (double x));
1443# endif 1715# endif
1444_GL_CXXALIAS_SYS (log2, double, (double x)); 1716_GL_CXXALIAS_SYS (log2, double, (double x));
1445# endif 1717# endif
1446_GL_CXXALIASWARN (log2); 1718# if __GLIBC__ >= 2
1719_GL_CXXALIASWARN1 (log2, double, (double x));
1720# endif
1447#elif defined GNULIB_POSIXCHECK 1721#elif defined GNULIB_POSIXCHECK
1448# undef log2 1722# undef log2
1449# if HAVE_RAW_DECL_LOG2 1723# if HAVE_RAW_DECL_LOG2
@@ -1466,7 +1740,9 @@ _GL_FUNCDECL_SYS (log2l, long double, (long double x));
1466# endif 1740# endif
1467_GL_CXXALIAS_SYS (log2l, long double, (long double x)); 1741_GL_CXXALIAS_SYS (log2l, long double, (long double x));
1468# endif 1742# endif
1743# if __GLIBC__ >= 2
1469_GL_CXXALIASWARN (log2l); 1744_GL_CXXALIASWARN (log2l);
1745# endif
1470#elif defined GNULIB_POSIXCHECK 1746#elif defined GNULIB_POSIXCHECK
1471# undef log2l 1747# undef log2l
1472# if HAVE_RAW_DECL_LOG2L 1748# if HAVE_RAW_DECL_LOG2L
@@ -1513,7 +1789,9 @@ _GL_FUNCDECL_SYS (logb, double, (double x));
1513# endif 1789# endif
1514_GL_CXXALIAS_SYS (logb, double, (double x)); 1790_GL_CXXALIAS_SYS (logb, double, (double x));
1515# endif 1791# endif
1516_GL_CXXALIASWARN (logb); 1792# if __GLIBC__ >= 2
1793_GL_CXXALIASWARN1 (logb, double, (double x));
1794# endif
1517#elif defined GNULIB_POSIXCHECK 1795#elif defined GNULIB_POSIXCHECK
1518# undef logb 1796# undef logb
1519# if HAVE_RAW_DECL_LOGB 1797# if HAVE_RAW_DECL_LOGB
@@ -1536,7 +1814,9 @@ _GL_FUNCDECL_SYS (logbl, long double, (long double x));
1536# endif 1814# endif
1537_GL_CXXALIAS_SYS (logbl, long double, (long double x)); 1815_GL_CXXALIAS_SYS (logbl, long double, (long double x));
1538# endif 1816# endif
1817# if __GLIBC__ >= 2
1539_GL_CXXALIASWARN (logbl); 1818_GL_CXXALIASWARN (logbl);
1819# endif
1540#elif defined GNULIB_POSIXCHECK 1820#elif defined GNULIB_POSIXCHECK
1541# undef logbl 1821# undef logbl
1542# if HAVE_RAW_DECL_LOGBL 1822# if HAVE_RAW_DECL_LOGBL
@@ -1581,7 +1861,9 @@ _GL_CXXALIAS_RPL (modf, double, (double x, double *iptr));
1581# else 1861# else
1582_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr)); 1862_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr));
1583# endif 1863# endif
1584_GL_CXXALIASWARN (modf); 1864# if __GLIBC__ >= 2
1865_GL_CXXALIASWARN1 (modf, double, (double x, double *iptr));
1866# endif
1585#elif defined GNULIB_POSIXCHECK 1867#elif defined GNULIB_POSIXCHECK
1586# undef modf 1868# undef modf
1587# if HAVE_RAW_DECL_MODF 1869# if HAVE_RAW_DECL_MODF
@@ -1607,7 +1889,9 @@ _GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr)
1607# endif 1889# endif
1608_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr)); 1890_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
1609# endif 1891# endif
1892# if __GLIBC__ >= 2
1610_GL_CXXALIASWARN (modfl); 1893_GL_CXXALIASWARN (modfl);
1894# endif
1611#elif defined GNULIB_POSIXCHECK 1895#elif defined GNULIB_POSIXCHECK
1612# undef modfl 1896# undef modfl
1613# if HAVE_RAW_DECL_MODFL 1897# if HAVE_RAW_DECL_MODFL
@@ -1670,7 +1954,9 @@ _GL_FUNCDECL_SYS (remainder, double, (double x, double y));
1670# endif 1954# endif
1671_GL_CXXALIAS_SYS (remainder, double, (double x, double y)); 1955_GL_CXXALIAS_SYS (remainder, double, (double x, double y));
1672# endif 1956# endif
1673_GL_CXXALIASWARN (remainder); 1957# if __GLIBC__ >= 2
1958_GL_CXXALIASWARN1 (remainder, double, (double x, double y));
1959# endif
1674#elif defined GNULIB_POSIXCHECK 1960#elif defined GNULIB_POSIXCHECK
1675# undef remainder 1961# undef remainder
1676# if HAVE_RAW_DECL_REMAINDER 1962# if HAVE_RAW_DECL_REMAINDER
@@ -1690,11 +1976,15 @@ _GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y));
1690# else 1976# else
1691# if !@HAVE_DECL_REMAINDERL@ 1977# if !@HAVE_DECL_REMAINDERL@
1692# undef remainderl 1978# undef remainderl
1979# if !(defined __cplusplus && defined _AIX)
1693_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y)); 1980_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y));
1981# endif
1694# endif 1982# endif
1695_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y)); 1983_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
1696# endif 1984# endif
1985# if __GLIBC__ >= 2
1697_GL_CXXALIASWARN (remainderl); 1986_GL_CXXALIASWARN (remainderl);
1987# endif
1698#elif defined GNULIB_POSIXCHECK 1988#elif defined GNULIB_POSIXCHECK
1699# undef remainderl 1989# undef remainderl
1700# if HAVE_RAW_DECL_REMAINDERL 1990# if HAVE_RAW_DECL_REMAINDERL
@@ -1723,7 +2013,9 @@ _GL_WARN_ON_USE (rintf, "rintf is unportable - "
1723_GL_FUNCDECL_SYS (rint, double, (double x)); 2013_GL_FUNCDECL_SYS (rint, double, (double x));
1724# endif 2014# endif
1725_GL_CXXALIAS_SYS (rint, double, (double x)); 2015_GL_CXXALIAS_SYS (rint, double, (double x));
1726_GL_CXXALIASWARN (rint); 2016# if __GLIBC__ >= 2
2017_GL_CXXALIASWARN1 (rint, double, (double x));
2018# endif
1727#elif defined GNULIB_POSIXCHECK 2019#elif defined GNULIB_POSIXCHECK
1728# undef rint 2020# undef rint
1729# if HAVE_RAW_DECL_RINT 2021# if HAVE_RAW_DECL_RINT
@@ -1733,11 +2025,22 @@ _GL_WARN_ON_USE (rint, "rint is unportable - "
1733#endif 2025#endif
1734 2026
1735#if @GNULIB_RINTL@ 2027#if @GNULIB_RINTL@
1736# if !@HAVE_RINTL@ 2028# if @REPLACE_RINTL@
2029# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2030# undef rintl
2031# define rintl rpl_rintl
2032# endif
2033_GL_FUNCDECL_RPL (rintl, long double, (long double x));
2034_GL_CXXALIAS_RPL (rintl, long double, (long double x));
2035# else
2036# if !@HAVE_RINTL@
1737_GL_FUNCDECL_SYS (rintl, long double, (long double x)); 2037_GL_FUNCDECL_SYS (rintl, long double, (long double x));
1738# endif 2038# endif
1739_GL_CXXALIAS_SYS (rintl, long double, (long double x)); 2039_GL_CXXALIAS_SYS (rintl, long double, (long double x));
2040# endif
2041# if __GLIBC__ >= 2
1740_GL_CXXALIASWARN (rintl); 2042_GL_CXXALIASWARN (rintl);
2043# endif
1741#elif defined GNULIB_POSIXCHECK 2044#elif defined GNULIB_POSIXCHECK
1742# undef rintl 2045# undef rintl
1743# if HAVE_RAW_DECL_RINTL 2046# if HAVE_RAW_DECL_RINTL
@@ -1784,7 +2087,9 @@ _GL_FUNCDECL_SYS (round, double, (double x));
1784# endif 2087# endif
1785_GL_CXXALIAS_SYS (round, double, (double x)); 2088_GL_CXXALIAS_SYS (round, double, (double x));
1786# endif 2089# endif
1787_GL_CXXALIASWARN (round); 2090# if __GLIBC__ >= 2
2091_GL_CXXALIASWARN1 (round, double, (double x));
2092# endif
1788#elif defined GNULIB_POSIXCHECK 2093#elif defined GNULIB_POSIXCHECK
1789# undef round 2094# undef round
1790# if HAVE_RAW_DECL_ROUND 2095# if HAVE_RAW_DECL_ROUND
@@ -1804,11 +2109,15 @@ _GL_CXXALIAS_RPL (roundl, long double, (long double x));
1804# else 2109# else
1805# if !@HAVE_DECL_ROUNDL@ 2110# if !@HAVE_DECL_ROUNDL@
1806# undef roundl 2111# undef roundl
2112# if !(defined __cplusplus && defined _AIX)
1807_GL_FUNCDECL_SYS (roundl, long double, (long double x)); 2113_GL_FUNCDECL_SYS (roundl, long double, (long double x));
2114# endif
1808# endif 2115# endif
1809_GL_CXXALIAS_SYS (roundl, long double, (long double x)); 2116_GL_CXXALIAS_SYS (roundl, long double, (long double x));
1810# endif 2117# endif
2118# if __GLIBC__ >= 2
1811_GL_CXXALIASWARN (roundl); 2119_GL_CXXALIASWARN (roundl);
2120# endif
1812#elif defined GNULIB_POSIXCHECK 2121#elif defined GNULIB_POSIXCHECK
1813# undef roundl 2122# undef roundl
1814# if HAVE_RAW_DECL_ROUNDL 2123# if HAVE_RAW_DECL_ROUNDL
@@ -1819,11 +2128,20 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - "
1819 2128
1820 2129
1821#if @GNULIB_SINF@ 2130#if @GNULIB_SINF@
1822# if !@HAVE_SINF@ 2131# if @REPLACE_SINF@
1823# undef sinf 2132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2133# undef sinf
2134# define sinf rpl_sinf
2135# endif
2136_GL_FUNCDECL_RPL (sinf, float, (float x));
2137_GL_CXXALIAS_RPL (sinf, float, (float x));
2138# else
2139# if !@HAVE_SINF@
2140# undef sinf
1824_GL_FUNCDECL_SYS (sinf, float, (float x)); 2141_GL_FUNCDECL_SYS (sinf, float, (float x));
1825# endif 2142# endif
1826_GL_CXXALIAS_SYS (sinf, float, (float x)); 2143_GL_CXXALIAS_SYS (sinf, float, (float x));
2144# endif
1827_GL_CXXALIASWARN (sinf); 2145_GL_CXXALIASWARN (sinf);
1828#elif defined GNULIB_POSIXCHECK 2146#elif defined GNULIB_POSIXCHECK
1829# undef sinf 2147# undef sinf
@@ -1839,7 +2157,9 @@ _GL_WARN_ON_USE (sinf, "sinf is unportable - "
1839_GL_FUNCDECL_SYS (sinl, long double, (long double x)); 2157_GL_FUNCDECL_SYS (sinl, long double, (long double x));
1840# endif 2158# endif
1841_GL_CXXALIAS_SYS (sinl, long double, (long double x)); 2159_GL_CXXALIAS_SYS (sinl, long double, (long double x));
2160# if __GLIBC__ >= 2
1842_GL_CXXALIASWARN (sinl); 2161_GL_CXXALIASWARN (sinl);
2162# endif
1843#elif defined GNULIB_POSIXCHECK 2163#elif defined GNULIB_POSIXCHECK
1844# undef sinl 2164# undef sinl
1845# if HAVE_RAW_DECL_SINL 2165# if HAVE_RAW_DECL_SINL
@@ -1850,11 +2170,20 @@ _GL_WARN_ON_USE (sinl, "sinl is unportable - "
1850 2170
1851 2171
1852#if @GNULIB_SINHF@ 2172#if @GNULIB_SINHF@
1853# if !@HAVE_SINHF@ 2173# if @REPLACE_SINHF@
1854# undef sinhf 2174# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2175# undef sinhf
2176# define sinhf rpl_sinhf
2177# endif
2178_GL_FUNCDECL_RPL (sinhf, float, (float x));
2179_GL_CXXALIAS_RPL (sinhf, float, (float x));
2180# else
2181# if !@HAVE_SINHF@
2182# undef sinhf
1855_GL_FUNCDECL_SYS (sinhf, float, (float x)); 2183_GL_FUNCDECL_SYS (sinhf, float, (float x));
1856# endif 2184# endif
1857_GL_CXXALIAS_SYS (sinhf, float, (float x)); 2185_GL_CXXALIAS_SYS (sinhf, float, (float x));
2186# endif
1858_GL_CXXALIASWARN (sinhf); 2187_GL_CXXALIASWARN (sinhf);
1859#elif defined GNULIB_POSIXCHECK 2188#elif defined GNULIB_POSIXCHECK
1860# undef sinhf 2189# undef sinhf
@@ -1866,11 +2195,20 @@ _GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
1866 2195
1867 2196
1868#if @GNULIB_SQRTF@ 2197#if @GNULIB_SQRTF@
1869# if !@HAVE_SQRTF@ 2198# if @REPLACE_SQRTF@
1870# undef sqrtf 2199# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2200# undef sqrtf
2201# define sqrtf rpl_sqrtf
2202# endif
2203_GL_FUNCDECL_RPL (sqrtf, float, (float x));
2204_GL_CXXALIAS_RPL (sqrtf, float, (float x));
2205# else
2206# if !@HAVE_SQRTF@
2207# undef sqrtf
1871_GL_FUNCDECL_SYS (sqrtf, float, (float x)); 2208_GL_FUNCDECL_SYS (sqrtf, float, (float x));
1872# endif 2209# endif
1873_GL_CXXALIAS_SYS (sqrtf, float, (float x)); 2210_GL_CXXALIAS_SYS (sqrtf, float, (float x));
2211# endif
1874_GL_CXXALIASWARN (sqrtf); 2212_GL_CXXALIASWARN (sqrtf);
1875#elif defined GNULIB_POSIXCHECK 2213#elif defined GNULIB_POSIXCHECK
1876# undef sqrtf 2214# undef sqrtf
@@ -1895,7 +2233,9 @@ _GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
1895# endif 2233# endif
1896_GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); 2234_GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
1897# endif 2235# endif
2236# if __GLIBC__ >= 2
1898_GL_CXXALIASWARN (sqrtl); 2237_GL_CXXALIASWARN (sqrtl);
2238# endif
1899#elif defined GNULIB_POSIXCHECK 2239#elif defined GNULIB_POSIXCHECK
1900# undef sqrtl 2240# undef sqrtl
1901# if HAVE_RAW_DECL_SQRTL 2241# if HAVE_RAW_DECL_SQRTL
@@ -1906,11 +2246,20 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
1906 2246
1907 2247
1908#if @GNULIB_TANF@ 2248#if @GNULIB_TANF@
1909# if !@HAVE_TANF@ 2249# if @REPLACE_TANF@
1910# undef tanf 2250# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2251# undef tanf
2252# define tanf rpl_tanf
2253# endif
2254_GL_FUNCDECL_RPL (tanf, float, (float x));
2255_GL_CXXALIAS_RPL (tanf, float, (float x));
2256# else
2257# if !@HAVE_TANF@
2258# undef tanf
1911_GL_FUNCDECL_SYS (tanf, float, (float x)); 2259_GL_FUNCDECL_SYS (tanf, float, (float x));
1912# endif 2260# endif
1913_GL_CXXALIAS_SYS (tanf, float, (float x)); 2261_GL_CXXALIAS_SYS (tanf, float, (float x));
2262# endif
1914_GL_CXXALIASWARN (tanf); 2263_GL_CXXALIASWARN (tanf);
1915#elif defined GNULIB_POSIXCHECK 2264#elif defined GNULIB_POSIXCHECK
1916# undef tanf 2265# undef tanf
@@ -1926,7 +2275,9 @@ _GL_WARN_ON_USE (tanf, "tanf is unportable - "
1926_GL_FUNCDECL_SYS (tanl, long double, (long double x)); 2275_GL_FUNCDECL_SYS (tanl, long double, (long double x));
1927# endif 2276# endif
1928_GL_CXXALIAS_SYS (tanl, long double, (long double x)); 2277_GL_CXXALIAS_SYS (tanl, long double, (long double x));
2278# if __GLIBC__ >= 2
1929_GL_CXXALIASWARN (tanl); 2279_GL_CXXALIASWARN (tanl);
2280# endif
1930#elif defined GNULIB_POSIXCHECK 2281#elif defined GNULIB_POSIXCHECK
1931# undef tanl 2282# undef tanl
1932# if HAVE_RAW_DECL_TANL 2283# if HAVE_RAW_DECL_TANL
@@ -1937,11 +2288,20 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - "
1937 2288
1938 2289
1939#if @GNULIB_TANHF@ 2290#if @GNULIB_TANHF@
1940# if !@HAVE_TANHF@ 2291# if @REPLACE_TANHF@
1941# undef tanhf 2292# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2293# undef tanhf
2294# define tanhf rpl_tanhf
2295# endif
2296_GL_FUNCDECL_RPL (tanhf, float, (float x));
2297_GL_CXXALIAS_RPL (tanhf, float, (float x));
2298# else
2299# if !@HAVE_TANHF@
2300# undef tanhf
1942_GL_FUNCDECL_SYS (tanhf, float, (float x)); 2301_GL_FUNCDECL_SYS (tanhf, float, (float x));
1943# endif 2302# endif
1944_GL_CXXALIAS_SYS (tanhf, float, (float x)); 2303_GL_CXXALIAS_SYS (tanhf, float, (float x));
2304# endif
1945_GL_CXXALIASWARN (tanhf); 2305_GL_CXXALIASWARN (tanhf);
1946#elif defined GNULIB_POSIXCHECK 2306#elif defined GNULIB_POSIXCHECK
1947# undef tanhf 2307# undef tanhf
@@ -1955,6 +2315,7 @@ _GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
1955#if @GNULIB_TRUNCF@ 2315#if @GNULIB_TRUNCF@
1956# if @REPLACE_TRUNCF@ 2316# if @REPLACE_TRUNCF@
1957# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2317# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2318# undef truncf
1958# define truncf rpl_truncf 2319# define truncf rpl_truncf
1959# endif 2320# endif
1960_GL_FUNCDECL_RPL (truncf, float, (float x)); 2321_GL_FUNCDECL_RPL (truncf, float, (float x));
@@ -1977,6 +2338,7 @@ _GL_WARN_ON_USE (truncf, "truncf is unportable - "
1977#if @GNULIB_TRUNC@ 2338#if @GNULIB_TRUNC@
1978# if @REPLACE_TRUNC@ 2339# if @REPLACE_TRUNC@
1979# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2340# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2341# undef trunc
1980# define trunc rpl_trunc 2342# define trunc rpl_trunc
1981# endif 2343# endif
1982_GL_FUNCDECL_RPL (trunc, double, (double x)); 2344_GL_FUNCDECL_RPL (trunc, double, (double x));
@@ -1987,7 +2349,9 @@ _GL_FUNCDECL_SYS (trunc, double, (double x));
1987# endif 2349# endif
1988_GL_CXXALIAS_SYS (trunc, double, (double x)); 2350_GL_CXXALIAS_SYS (trunc, double, (double x));
1989# endif 2351# endif
1990_GL_CXXALIASWARN (trunc); 2352# if __GLIBC__ >= 2
2353_GL_CXXALIASWARN1 (trunc, double, (double x));
2354# endif
1991#elif defined GNULIB_POSIXCHECK 2355#elif defined GNULIB_POSIXCHECK
1992# undef trunc 2356# undef trunc
1993# if HAVE_RAW_DECL_TRUNC 2357# if HAVE_RAW_DECL_TRUNC
@@ -2010,7 +2374,9 @@ _GL_FUNCDECL_SYS (truncl, long double, (long double x));
2010# endif 2374# endif
2011_GL_CXXALIAS_SYS (truncl, long double, (long double x)); 2375_GL_CXXALIAS_SYS (truncl, long double, (long double x));
2012# endif 2376# endif
2377# if __GLIBC__ >= 2
2013_GL_CXXALIASWARN (truncl); 2378_GL_CXXALIASWARN (truncl);
2379# endif
2014#elif defined GNULIB_POSIXCHECK 2380#elif defined GNULIB_POSIXCHECK
2015# undef truncl 2381# undef truncl
2016# if HAVE_RAW_DECL_TRUNCL 2382# if HAVE_RAW_DECL_TRUNCL
@@ -2020,6 +2386,55 @@ _GL_WARN_ON_USE (truncl, "truncl is unportable - "
2020#endif 2386#endif
2021 2387
2022 2388
2389#if @GNULIB_MDA_Y0@
2390/* On native Windows, map 'y0' to '_y0', so that -loldnames is not
2391 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2392 platforms by defining GNULIB_NAMESPACE::y0 always. */
2393# if defined _WIN32 && !defined __CYGWIN__
2394# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2395# undef y0
2396# define y0 _y0
2397# endif
2398_GL_CXXALIAS_MDA (y0, double, (double x));
2399# else
2400_GL_CXXALIAS_SYS (y0, double, (double x));
2401# endif
2402_GL_CXXALIASWARN (y0);
2403#endif
2404
2405#if @GNULIB_MDA_Y1@
2406/* On native Windows, map 'y1' to '_y1', so that -loldnames is not
2407 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2408 platforms by defining GNULIB_NAMESPACE::y1 always. */
2409# if defined _WIN32 && !defined __CYGWIN__
2410# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2411# undef y1
2412# define y1 _y1
2413# endif
2414_GL_CXXALIAS_MDA (y1, double, (double x));
2415# else
2416_GL_CXXALIAS_SYS (y1, double, (double x));
2417# endif
2418_GL_CXXALIASWARN (y1);
2419#endif
2420
2421#if @GNULIB_MDA_YN@
2422/* On native Windows, map 'yn' to '_yn', so that -loldnames is not
2423 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2424 platforms by defining GNULIB_NAMESPACE::yn always. */
2425# if defined _WIN32 && !defined __CYGWIN__
2426# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2427# undef yn
2428# define yn _yn
2429# endif
2430_GL_CXXALIAS_MDA (yn, double, (int n, double x));
2431# else
2432_GL_CXXALIAS_SYS (yn, double, (int n, double x));
2433# endif
2434_GL_CXXALIASWARN (yn);
2435#endif
2436
2437
2023/* Definitions of function-like macros come here, after the function 2438/* Definitions of function-like macros come here, after the function
2024 declarations. */ 2439 declarations. */
2025 2440
@@ -2036,10 +2451,18 @@ _GL_EXTERN_C int gl_isfinitel (long double x);
2036 gl_isfinitef (x)) 2451 gl_isfinitef (x))
2037# endif 2452# endif
2038# ifdef __cplusplus 2453# ifdef __cplusplus
2039# ifdef isfinite 2454# if defined isfinite || defined GNULIB_NAMESPACE
2040_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) 2455_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
2041# undef isfinite 2456# undef isfinite
2042_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite) 2457# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__)))
2458 /* This platform's <cmath> possibly defines isfinite through a set of inline
2459 functions. */
2460_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, rpl_isfinite, bool)
2461# define isfinite rpl_isfinite
2462# define GNULIB_NAMESPACE_LACKS_ISFINITE 1
2463# else
2464_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite, isfinite, bool)
2465# endif
2043# endif 2466# endif
2044# endif 2467# endif
2045#elif defined GNULIB_POSIXCHECK 2468#elif defined GNULIB_POSIXCHECK
@@ -2063,10 +2486,18 @@ _GL_EXTERN_C int gl_isinfl (long double x);
2063 gl_isinff (x)) 2486 gl_isinff (x))
2064# endif 2487# endif
2065# ifdef __cplusplus 2488# ifdef __cplusplus
2066# ifdef isinf 2489# if defined isinf || defined GNULIB_NAMESPACE
2067_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) 2490_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
2068# undef isinf 2491# undef isinf
2069_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf) 2492# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || (defined _WIN32 && !defined __CYGWIN__)))
2493 /* This platform's <cmath> possibly defines isinf through a set of inline
2494 functions. */
2495_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, rpl_isinf, bool)
2496# define isinf rpl_isinf
2497# define GNULIB_NAMESPACE_LACKS_ISINF 1
2498# else
2499_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf, isinf, bool)
2500# endif
2070# endif 2501# endif
2071# endif 2502# endif
2072#elif defined GNULIB_POSIXCHECK 2503#elif defined GNULIB_POSIXCHECK
@@ -2083,10 +2514,11 @@ _GL_WARN_REAL_FLOATING_DECL (isinf);
2083# if @HAVE_ISNANF@ 2514# if @HAVE_ISNANF@
2084/* The original <math.h> included above provides a declaration of isnan macro 2515/* The original <math.h> included above provides a declaration of isnan macro
2085 or (older) isnanf function. */ 2516 or (older) isnanf function. */
2086# if __GNUC__ >= 4 2517# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2087 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2518 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
2519 GCC >= 4.0 also provides __builtin_isnanf, but clang doesn't. */
2088# undef isnanf 2520# undef isnanf
2089# define isnanf(x) __builtin_isnanf ((float)(x)) 2521# define isnanf(x) __builtin_isnan ((float)(x))
2090# elif defined isnan 2522# elif defined isnan
2091# undef isnanf 2523# undef isnanf
2092# define isnanf(x) isnan ((float)(x)) 2524# define isnanf(x) isnan ((float)(x))
@@ -2106,8 +2538,8 @@ _GL_EXTERN_C int isnanf (float x);
2106# if @HAVE_ISNAND@ 2538# if @HAVE_ISNAND@
2107/* The original <math.h> included above provides a declaration of isnan 2539/* The original <math.h> included above provides a declaration of isnan
2108 macro. */ 2540 macro. */
2109# if __GNUC__ >= 4 2541# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2110 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2542 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan. */
2111# undef isnand 2543# undef isnand
2112# define isnand(x) __builtin_isnan ((double)(x)) 2544# define isnand(x) __builtin_isnan ((double)(x))
2113# else 2545# else
@@ -2127,10 +2559,11 @@ _GL_EXTERN_C int isnand (double x);
2127# if @HAVE_ISNANL@ 2559# if @HAVE_ISNANL@
2128/* The original <math.h> included above provides a declaration of isnan 2560/* The original <math.h> included above provides a declaration of isnan
2129 macro or (older) isnanl function. */ 2561 macro or (older) isnanl function. */
2130# if __GNUC__ >= 4 2562# if (__GNUC__ >= 4) || (__clang_major__ >= 4)
2131 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2563 /* GCC >= 4.0 and clang provide a type-generic built-in for isnan.
2564 GCC >= 4.0 also provides __builtin_isnanl, but clang doesn't. */
2132# undef isnanl 2565# undef isnanl
2133# define isnanl(x) __builtin_isnanl ((long double)(x)) 2566# define isnanl(x) __builtin_isnan ((long double)(x))
2134# elif defined isnan 2567# elif defined isnan
2135# undef isnanl 2568# undef isnanl
2136# define isnanl(x) isnan ((long double)(x)) 2569# define isnanl(x) isnan ((long double)(x))
@@ -2150,20 +2583,20 @@ _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
2150 isnanf.h (e.g.) here, because those may end up being macros 2583 isnanf.h (e.g.) here, because those may end up being macros
2151 that recursively expand back to isnan. So use the gnulib 2584 that recursively expand back to isnan. So use the gnulib
2152 replacements for them directly. */ 2585 replacements for them directly. */
2153# if @HAVE_ISNANF@ && __GNUC__ >= 4 2586# if @HAVE_ISNANF@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
2154# define gl_isnan_f(x) __builtin_isnanf ((float)(x)) 2587# define gl_isnan_f(x) __builtin_isnan ((float)(x))
2155# else 2588# else
2156_GL_EXTERN_C int rpl_isnanf (float x); 2589_GL_EXTERN_C int rpl_isnanf (float x);
2157# define gl_isnan_f(x) rpl_isnanf (x) 2590# define gl_isnan_f(x) rpl_isnanf (x)
2158# endif 2591# endif
2159# if @HAVE_ISNAND@ && __GNUC__ >= 4 2592# if @HAVE_ISNAND@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
2160# define gl_isnan_d(x) __builtin_isnan ((double)(x)) 2593# define gl_isnan_d(x) __builtin_isnan ((double)(x))
2161# else 2594# else
2162_GL_EXTERN_C int rpl_isnand (double x); 2595_GL_EXTERN_C int rpl_isnand (double x);
2163# define gl_isnan_d(x) rpl_isnand (x) 2596# define gl_isnan_d(x) rpl_isnand (x)
2164# endif 2597# endif
2165# if @HAVE_ISNANL@ && __GNUC__ >= 4 2598# if @HAVE_ISNANL@ && (__GNUC__ >= 4) || (__clang_major__ >= 4)
2166# define gl_isnan_l(x) __builtin_isnanl ((long double)(x)) 2599# define gl_isnan_l(x) __builtin_isnan ((long double)(x))
2167# else 2600# else
2168_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; 2601_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
2169# define gl_isnan_l(x) rpl_isnanl (x) 2602# define gl_isnan_l(x) rpl_isnanl (x)
@@ -2173,18 +2606,26 @@ _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
2173 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ 2606 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
2174 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ 2607 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
2175 gl_isnan_f (x)) 2608 gl_isnan_f (x))
2176# elif __GNUC__ >= 4 2609# elif (__GNUC__ >= 4) || (__clang_major__ >= 4)
2177# undef isnan 2610# undef isnan
2178# define isnan(x) \ 2611# define isnan(x) \
2179 (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \ 2612 (sizeof (x) == sizeof (long double) ? __builtin_isnan ((long double)(x)) : \
2180 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ 2613 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
2181 __builtin_isnanf ((float)(x))) 2614 __builtin_isnan ((float)(x)))
2182# endif 2615# endif
2183# ifdef __cplusplus 2616# ifdef __cplusplus
2184# ifdef isnan 2617# if defined isnan || defined GNULIB_NAMESPACE
2185_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) 2618_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
2186# undef isnan 2619# undef isnan
2187_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan) 2620# 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__)))
2621 /* This platform's <cmath> possibly defines isnan through a set of inline
2622 functions. */
2623_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, rpl_isnan, bool)
2624# define isnan rpl_isnan
2625# define GNULIB_NAMESPACE_LACKS_ISNAN 1
2626# else
2627_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan, isnan, bool)
2628# endif
2188# endif 2629# endif
2189# else 2630# else
2190/* Ensure isnan is a macro. */ 2631/* Ensure isnan is a macro. */
@@ -2202,20 +2643,21 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
2202 2643
2203 2644
2204#if @GNULIB_SIGNBIT@ 2645#if @GNULIB_SIGNBIT@
2205# if @REPLACE_SIGNBIT_USING_GCC@ 2646# if (@REPLACE_SIGNBIT_USING_BUILTINS@ \
2647 && (!defined __cplusplus || __cplusplus < 201103))
2206# undef signbit 2648# undef signbit
2207 /* GCC 4.0 and newer provides three built-ins for signbit. */ 2649 /* GCC >= 4.0 and clang provide three built-ins for signbit. */
2208# define signbit(x) \ 2650# define signbit(x) \
2209 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \ 2651 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
2210 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \ 2652 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
2211 __builtin_signbitf (x)) 2653 __builtin_signbitf (x))
2212# endif 2654# endif
2213# if @REPLACE_SIGNBIT@ 2655# if @REPLACE_SIGNBIT@ && !GNULIB_defined_signbit
2214# undef signbit 2656# undef signbit
2215_GL_EXTERN_C int gl_signbitf (float arg); 2657_GL_EXTERN_C int gl_signbitf (float arg);
2216_GL_EXTERN_C int gl_signbitd (double arg); 2658_GL_EXTERN_C int gl_signbitd (double arg);
2217_GL_EXTERN_C int gl_signbitl (long double arg); 2659_GL_EXTERN_C int gl_signbitl (long double arg);
2218# if __GNUC__ >= 2 && !defined __STRICT_ANSI__ 2660# if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
2219# define _GL_NUM_UINT_WORDS(type) \ 2661# define _GL_NUM_UINT_WORDS(type) \
2220 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) 2662 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
2221# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf 2663# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
@@ -2253,12 +2695,21 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
2253 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \ 2695 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
2254 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ 2696 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
2255 gl_signbitf (x)) 2697 gl_signbitf (x))
2698# define GNULIB_defined_signbit 1
2256# endif 2699# endif
2257# ifdef __cplusplus 2700# ifdef __cplusplus
2258# ifdef signbit 2701# if defined signbit || defined GNULIB_NAMESPACE
2259_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) 2702_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
2260# undef signbit 2703# undef signbit
2261_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit) 2704# if __GNUC__ >= 6 || (defined __clang__ && !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined _AIX || (defined _WIN32 && !defined __CYGWIN__)))
2705 /* This platform's <cmath> possibly defines signbit through a set of inline
2706 functions. */
2707_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, rpl_signbit, bool)
2708# define signbit rpl_signbit
2709# define GNULIB_NAMESPACE_LACKS_SIGNBIT 1
2710# else
2711_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit, signbit, bool)
2712# endif
2262# endif 2713# endif
2263# endif 2714# endif
2264#elif defined GNULIB_POSIXCHECK 2715#elif defined GNULIB_POSIXCHECK
@@ -2272,4 +2723,5 @@ _GL_WARN_REAL_FLOATING_DECL (signbit);
2272_GL_INLINE_HEADER_END 2723_GL_INLINE_HEADER_END
2273 2724
2274#endif /* _@GUARD_PREFIX@_MATH_H */ 2725#endif /* _@GUARD_PREFIX@_MATH_H */
2726#endif /* _GL_INCLUDING_MATH_H */
2275#endif /* _@GUARD_PREFIX@_MATH_H */ 2727#endif /* _@GUARD_PREFIX@_MATH_H */
diff --git a/gl/mbrtowc-impl-utf8.h b/gl/mbrtowc-impl-utf8.h
new file mode 100644
index 0000000..4fdd65d
--- /dev/null
+++ b/gl/mbrtowc-impl-utf8.h
@@ -0,0 +1,138 @@
1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
18
19/* This file contains the part of the body of the mbrtowc and mbrtoc32 functions
20 that handles the special case of the UTF-8 encoding. */
21
22 /* Cf. unistr/u8-mbtouc.c. */
23 unsigned char c = (unsigned char) p[0];
24
25 if (c < 0x80)
26 {
27 if (pwc != NULL)
28 *pwc = c;
29 res = (c == 0 ? 0 : 1);
30 goto success;
31 }
32 if (c >= 0xc2)
33 {
34 if (c < 0xe0)
35 {
36 if (m == 1)
37 goto incomplete;
38 else /* m >= 2 */
39 {
40 unsigned char c2 = (unsigned char) p[1];
41
42 if ((c2 ^ 0x80) < 0x40)
43 {
44 if (pwc != NULL)
45 *pwc = ((unsigned int) (c & 0x1f) << 6)
46 | (unsigned int) (c2 ^ 0x80);
47 res = 2;
48 goto success;
49 }
50 }
51 }
52 else if (c < 0xf0)
53 {
54 if (m == 1)
55 goto incomplete;
56 else
57 {
58 unsigned char c2 = (unsigned char) p[1];
59
60 if ((c2 ^ 0x80) < 0x40
61 && (c >= 0xe1 || c2 >= 0xa0)
62 && (c != 0xed || c2 < 0xa0))
63 {
64 if (m == 2)
65 goto incomplete;
66 else /* m >= 3 */
67 {
68 unsigned char c3 = (unsigned char) p[2];
69
70 if ((c3 ^ 0x80) < 0x40)
71 {
72 unsigned int wc =
73 (((unsigned int) (c & 0x0f) << 12)
74 | ((unsigned int) (c2 ^ 0x80) << 6)
75 | (unsigned int) (c3 ^ 0x80));
76
77 if (FITS_IN_CHAR_TYPE (wc))
78 {
79 if (pwc != NULL)
80 *pwc = wc;
81 res = 3;
82 goto success;
83 }
84 }
85 }
86 }
87 }
88 }
89 else if (c <= 0xf4)
90 {
91 if (m == 1)
92 goto incomplete;
93 else
94 {
95 unsigned char c2 = (unsigned char) p[1];
96
97 if ((c2 ^ 0x80) < 0x40
98 && (c >= 0xf1 || c2 >= 0x90)
99 && (c < 0xf4 || (/* c == 0xf4 && */ c2 < 0x90)))
100 {
101 if (m == 2)
102 goto incomplete;
103 else
104 {
105 unsigned char c3 = (unsigned char) p[2];
106
107 if ((c3 ^ 0x80) < 0x40)
108 {
109 if (m == 3)
110 goto incomplete;
111 else /* m >= 4 */
112 {
113 unsigned char c4 = (unsigned char) p[3];
114
115 if ((c4 ^ 0x80) < 0x40)
116 {
117 unsigned int wc =
118 (((unsigned int) (c & 0x07) << 18)
119 | ((unsigned int) (c2 ^ 0x80) << 12)
120 | ((unsigned int) (c3 ^ 0x80) << 6)
121 | (unsigned int) (c4 ^ 0x80));
122
123 if (FITS_IN_CHAR_TYPE (wc))
124 {
125 if (pwc != NULL)
126 *pwc = wc;
127 res = 4;
128 goto success;
129 }
130 }
131 }
132 }
133 }
134 }
135 }
136 }
137 }
138 goto invalid;
diff --git a/gl/mbrtowc-impl.h b/gl/mbrtowc-impl.h
new file mode 100644
index 0000000..e9c04ed
--- /dev/null
+++ b/gl/mbrtowc-impl.h
@@ -0,0 +1,262 @@
1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2008. */
18
19/* This file contains the body of the mbrtowc and mbrtoc32 functions,
20 when GNULIB_defined_mbstate_t is defined. */
21
22 char *pstate = (char *)ps;
23
24 if (s == NULL)
25 {
26 pwc = NULL;
27 s = "";
28 n = 1;
29 }
30
31 if (n == 0)
32 return (size_t)(-2);
33
34 /* Here n > 0. */
35
36 if (pstate == NULL)
37 pstate = internal_state;
38
39 {
40 size_t nstate = pstate[0];
41 char buf[4];
42 const char *p;
43 size_t m;
44 enc_t enc;
45 int res;
46
47 switch (nstate)
48 {
49 case 0:
50 p = s;
51 m = n;
52 break;
53 case 3:
54 buf[2] = pstate[3];
55 FALLTHROUGH;
56 case 2:
57 buf[1] = pstate[2];
58 FALLTHROUGH;
59 case 1:
60 buf[0] = pstate[1];
61 p = buf;
62 m = nstate;
63 buf[m++] = s[0];
64 if (n >= 2 && m < 4)
65 {
66 buf[m++] = s[1];
67 if (n >= 3 && m < 4)
68 buf[m++] = s[2];
69 }
70 break;
71 default:
72 errno = EINVAL;
73 return (size_t)(-1);
74 }
75
76 /* Here m > 0. */
77
78 enc = locale_encoding_classification ();
79
80 if (enc == enc_utf8) /* UTF-8 */
81 {
82 /* Achieve
83 - multi-thread safety and
84 - the ability to produce wide character values > WCHAR_MAX
85 by not calling mbtowc() at all. */
86#include "mbrtowc-impl-utf8.h"
87 }
88 else
89 {
90 /* The hidden internal state of mbtowc would make this function not
91 multi-thread safe. Achieve multi-thread safety through a lock. */
92 wchar_t wc;
93 res = mbtowc_with_lock (&wc, p, m);
94
95 if (res >= 0)
96 {
97 if ((wc == 0) != (res == 0))
98 abort ();
99 if (pwc != NULL)
100 *pwc = wc;
101 goto success;
102 }
103
104 /* mbtowc does not distinguish between invalid and incomplete multibyte
105 sequences. But mbrtowc needs to make this distinction.
106 There are two possible approaches:
107 - Use iconv() and its return value.
108 - Use built-in knowledge about the possible encodings.
109 Given the low quality of implementation of iconv() on the systems
110 that lack mbrtowc(), we use the second approach.
111 The possible encodings are:
112 - 8-bit encodings,
113 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
114 - UTF-8 (already handled above).
115 Use specialized code for each. */
116 if (m >= 4 || m >= MB_CUR_MAX)
117 goto invalid;
118 /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
119 switch (enc)
120 {
121 /* As a reference for this code, you can use the GNU libiconv
122 implementation. Look for uses of the RET_TOOFEW macro. */
123
124 case enc_eucjp: /* EUC-JP */
125 {
126 if (m == 1)
127 {
128 unsigned char c = (unsigned char) p[0];
129
130 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
131 goto incomplete;
132 }
133 if (m == 2)
134 {
135 unsigned char c = (unsigned char) p[0];
136
137 if (c == 0x8f)
138 {
139 unsigned char c2 = (unsigned char) p[1];
140
141 if (c2 >= 0xa1 && c2 < 0xff)
142 goto incomplete;
143 }
144 }
145 goto invalid;
146 }
147
148 case enc_94: /* EUC-KR, GB2312, BIG5 */
149 {
150 if (m == 1)
151 {
152 unsigned char c = (unsigned char) p[0];
153
154 if (c >= 0xa1 && c < 0xff)
155 goto incomplete;
156 }
157 goto invalid;
158 }
159
160 case enc_euctw: /* EUC-TW */
161 {
162 if (m == 1)
163 {
164 unsigned char c = (unsigned char) p[0];
165
166 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
167 goto incomplete;
168 }
169 else /* m == 2 || m == 3 */
170 {
171 unsigned char c = (unsigned char) p[0];
172
173 if (c == 0x8e)
174 goto incomplete;
175 }
176 goto invalid;
177 }
178
179 case enc_gb18030: /* GB18030 */
180 {
181 if (m == 1)
182 {
183 unsigned char c = (unsigned char) p[0];
184
185 if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
186 goto incomplete;
187 }
188 else /* m == 2 || m == 3 */
189 {
190 unsigned char c = (unsigned char) p[0];
191
192 if (c >= 0x90 && c <= 0xe3)
193 {
194 unsigned char c2 = (unsigned char) p[1];
195
196 if (c2 >= 0x30 && c2 <= 0x39)
197 {
198 if (m == 2)
199 goto incomplete;
200 else /* m == 3 */
201 {
202 unsigned char c3 = (unsigned char) p[2];
203
204 if (c3 >= 0x81 && c3 <= 0xfe)
205 goto incomplete;
206 }
207 }
208 }
209 }
210 goto invalid;
211 }
212
213 case enc_sjis: /* SJIS */
214 {
215 if (m == 1)
216 {
217 unsigned char c = (unsigned char) p[0];
218
219 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
220 || (c >= 0xf0 && c <= 0xf9))
221 goto incomplete;
222 }
223 goto invalid;
224 }
225
226 default:
227 /* An unknown multibyte encoding. */
228 goto incomplete;
229 }
230 }
231
232 success:
233 /* res >= 0 is the corrected return value of
234 mbtowc_with_lock (&wc, p, m). */
235 if (nstate >= (res > 0 ? res : 1))
236 abort ();
237 res -= nstate;
238 pstate[0] = 0;
239 return res;
240
241 incomplete:
242 {
243 size_t k = nstate;
244 /* Here 0 <= k < m < 4. */
245 pstate[++k] = s[0];
246 if (k < m)
247 {
248 pstate[++k] = s[1];
249 if (k < m)
250 pstate[++k] = s[2];
251 }
252 if (k != m)
253 abort ();
254 }
255 pstate[0] = m;
256 return (size_t)(-2);
257
258 invalid:
259 errno = EILSEQ;
260 /* The conversion state is undefined, says POSIX. */
261 return (size_t)(-1);
262 }
diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c
index 5ee44ae..c1a689a 100644
--- a/gl/mbrtowc.c
+++ b/gl/mbrtowc.c
@@ -1,19 +1,19 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999-2002, 2005-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -21,314 +21,66 @@
21#include <wchar.h> 21#include <wchar.h>
22 22
23#if GNULIB_defined_mbstate_t 23#if GNULIB_defined_mbstate_t
24/* Implement mbrtowc() on top of mbtowc(). */ 24/* Implement mbrtowc() on top of mbtowc() for the non-UTF-8 locales
25 and directly for the UTF-8 locales. */
25 26
26# include <errno.h> 27# include <errno.h>
28# include <stdint.h>
27# include <stdlib.h> 29# include <stdlib.h>
28 30
29# include "localcharset.h" 31# if defined _WIN32 && !defined __CYGWIN__
30# include "streq.h"
31# include "verify.h"
32 32
33# define WIN32_LEAN_AND_MEAN /* avoid including junk */
34# include <windows.h>
33 35
34verify (sizeof (mbstate_t) >= 4); 36# elif HAVE_PTHREAD_API
35 37
36static char internal_state[4]; 38# include <pthread.h>
39# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
40# include <threads.h>
41# pragma weak thrd_exit
42# define c11_threads_in_use() (thrd_exit != NULL)
43# else
44# define c11_threads_in_use() 0
45# endif
37 46
38size_t 47# elif HAVE_THREADS_H
39mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
40{
41 char *pstate = (char *)ps;
42
43 if (s == NULL)
44 {
45 pwc = NULL;
46 s = "";
47 n = 1;
48 }
49
50 if (n == 0)
51 return (size_t)(-2);
52 48
53 /* Here n > 0. */ 49# include <threads.h>
54 50
55 if (pstate == NULL)
56 pstate = internal_state;
57
58 {
59 size_t nstate = pstate[0];
60 char buf[4];
61 const char *p;
62 size_t m;
63
64 switch (nstate)
65 {
66 case 0:
67 p = s;
68 m = n;
69 break;
70 case 3:
71 buf[2] = pstate[3];
72 /*FALLTHROUGH*/
73 case 2:
74 buf[1] = pstate[2];
75 /*FALLTHROUGH*/
76 case 1:
77 buf[0] = pstate[1];
78 p = buf;
79 m = nstate;
80 buf[m++] = s[0];
81 if (n >= 2 && m < 4)
82 {
83 buf[m++] = s[1];
84 if (n >= 3 && m < 4)
85 buf[m++] = s[2];
86 }
87 break;
88 default:
89 errno = EINVAL;
90 return (size_t)(-1);
91 }
92
93 /* Here m > 0. */
94
95# if __GLIBC__ || defined __UCLIBC__
96 /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
97 mbtowc (NULL, NULL, 0);
98# endif 51# endif
99 {
100 int res = mbtowc (pwc, p, m);
101
102 if (res >= 0)
103 {
104 if (pwc != NULL && ((*pwc == 0) != (res == 0)))
105 abort ();
106 if (nstate >= (res > 0 ? res : 1))
107 abort ();
108 res -= nstate;
109 pstate[0] = 0;
110 return res;
111 }
112
113 /* mbtowc does not distinguish between invalid and incomplete multibyte
114 sequences. But mbrtowc needs to make this distinction.
115 There are two possible approaches:
116 - Use iconv() and its return value.
117 - Use built-in knowledge about the possible encodings.
118 Given the low quality of implementation of iconv() on the systems that
119 lack mbrtowc(), we use the second approach.
120 The possible encodings are:
121 - 8-bit encodings,
122 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
123 - UTF-8.
124 Use specialized code for each. */
125 if (m >= 4 || m >= MB_CUR_MAX)
126 goto invalid;
127 /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
128 {
129 const char *encoding = locale_charset ();
130
131 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
132 {
133 /* Cf. unistr/u8-mblen.c. */
134 unsigned char c = (unsigned char) p[0];
135
136 if (c >= 0xc2)
137 {
138 if (c < 0xe0)
139 {
140 if (m == 1)
141 goto incomplete;
142 }
143 else if (c < 0xf0)
144 {
145 if (m == 1)
146 goto incomplete;
147 if (m == 2)
148 {
149 unsigned char c2 = (unsigned char) p[1];
150
151 if ((c2 ^ 0x80) < 0x40
152 && (c >= 0xe1 || c2 >= 0xa0)
153 && (c != 0xed || c2 < 0xa0))
154 goto incomplete;
155 }
156 }
157 else if (c <= 0xf4)
158 {
159 if (m == 1)
160 goto incomplete;
161 else /* m == 2 || m == 3 */
162 {
163 unsigned char c2 = (unsigned char) p[1];
164
165 if ((c2 ^ 0x80) < 0x40
166 && (c >= 0xf1 || c2 >= 0x90)
167 && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
168 {
169 if (m == 2)
170 goto incomplete;
171 else /* m == 3 */
172 {
173 unsigned char c3 = (unsigned char) p[2];
174
175 if ((c3 ^ 0x80) < 0x40)
176 goto incomplete;
177 }
178 }
179 }
180 }
181 }
182 goto invalid;
183 }
184
185 /* As a reference for this code, you can use the GNU libiconv
186 implementation. Look for uses of the RET_TOOFEW macro. */
187
188 if (STREQ_OPT (encoding,
189 "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
190 {
191 if (m == 1)
192 {
193 unsigned char c = (unsigned char) p[0];
194
195 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
196 goto incomplete;
197 }
198 if (m == 2)
199 {
200 unsigned char c = (unsigned char) p[0];
201
202 if (c == 0x8f)
203 {
204 unsigned char c2 = (unsigned char) p[1];
205
206 if (c2 >= 0xa1 && c2 < 0xff)
207 goto incomplete;
208 }
209 }
210 goto invalid;
211 }
212 if (STREQ_OPT (encoding,
213 "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
214 || STREQ_OPT (encoding,
215 "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
216 || STREQ_OPT (encoding,
217 "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
218 {
219 if (m == 1)
220 {
221 unsigned char c = (unsigned char) p[0];
222
223 if (c >= 0xa1 && c < 0xff)
224 goto incomplete;
225 }
226 goto invalid;
227 }
228 if (STREQ_OPT (encoding,
229 "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
230 {
231 if (m == 1)
232 {
233 unsigned char c = (unsigned char) p[0];
234
235 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
236 goto incomplete;
237 }
238 else /* m == 2 || m == 3 */
239 {
240 unsigned char c = (unsigned char) p[0];
241
242 if (c == 0x8e)
243 goto incomplete;
244 }
245 goto invalid;
246 }
247 if (STREQ_OPT (encoding,
248 "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
249 {
250 if (m == 1)
251 {
252 unsigned char c = (unsigned char) p[0];
253 52
254 if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe)) 53# include "attribute.h"
255 goto incomplete; 54# include "lc-charset-dispatch.h"
256 } 55# include "mbtowc-lock.h"
257 else /* m == 2 || m == 3 */
258 {
259 unsigned char c = (unsigned char) p[0];
260
261 if (c >= 0x90 && c <= 0xe3)
262 {
263 unsigned char c2 = (unsigned char) p[1];
264
265 if (c2 >= 0x30 && c2 <= 0x39)
266 {
267 if (m == 2)
268 goto incomplete;
269 else /* m == 3 */
270 {
271 unsigned char c3 = (unsigned char) p[2];
272
273 if (c3 >= 0x81 && c3 <= 0xfe)
274 goto incomplete;
275 }
276 }
277 }
278 }
279 goto invalid;
280 }
281 if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
282 {
283 if (m == 1)
284 {
285 unsigned char c = (unsigned char) p[0];
286 56
287 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea) 57static_assert (sizeof (mbstate_t) >= 4);
288 || (c >= 0xf0 && c <= 0xf9)) 58static char internal_state[4];
289 goto incomplete;
290 }
291 goto invalid;
292 }
293
294 /* An unknown multibyte encoding. */
295 goto incomplete;
296 }
297
298 incomplete:
299 {
300 size_t k = nstate;
301 /* Here 0 <= k < m < 4. */
302 pstate[++k] = s[0];
303 if (k < m)
304 {
305 pstate[++k] = s[1];
306 if (k < m)
307 pstate[++k] = s[2];
308 }
309 if (k != m)
310 abort ();
311 }
312 pstate[0] = m;
313 return (size_t)(-2);
314 59
315 invalid: 60size_t
316 errno = EILSEQ; 61mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
317 /* The conversion state is undefined, says POSIX. */ 62{
318 return (size_t)(-1); 63# define FITS_IN_CHAR_TYPE(wc) ((wc) <= WCHAR_MAX)
319 } 64# include "mbrtowc-impl.h"
320 }
321} 65}
322 66
323#else 67#else
324/* Override the system's mbrtowc() function. */ 68/* Override the system's mbrtowc() function. */
325 69
70# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
71# include "hard-locale.h"
72# include <locale.h>
73# endif
74
326# undef mbrtowc 75# undef mbrtowc
327 76
328size_t 77size_t
329rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) 78rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
330{ 79{
331# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG 80 size_t ret;
81 wchar_t wc;
82
83# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG || MBRTOWC_EMPTY_INPUT_BUG
332 if (s == NULL) 84 if (s == NULL)
333 { 85 {
334 pwc = NULL; 86 pwc = NULL;
@@ -337,6 +89,14 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
337 } 89 }
338# endif 90# endif
339 91
92# if MBRTOWC_EMPTY_INPUT_BUG
93 if (n == 0)
94 return (size_t) -2;
95# endif
96
97 if (! pwc)
98 pwc = &wc;
99
340# if MBRTOWC_RETVAL_BUG 100# if MBRTOWC_RETVAL_BUG
341 { 101 {
342 static mbstate_t internal_state; 102 static mbstate_t internal_state;
@@ -352,8 +112,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
352 size_t count = 0; 112 size_t count = 0;
353 for (; n > 0; s++, n--) 113 for (; n > 0; s++, n--)
354 { 114 {
355 wchar_t wc; 115 ret = mbrtowc (&wc, s, 1, ps);
356 size_t ret = mbrtowc (&wc, s, 1, ps);
357 116
358 if (ret == (size_t)(-1)) 117 if (ret == (size_t)(-1))
359 return (size_t)(-1); 118 return (size_t)(-1);
@@ -361,8 +120,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
361 if (ret != (size_t)(-2)) 120 if (ret != (size_t)(-2))
362 { 121 {
363 /* The multibyte character has been completed. */ 122 /* The multibyte character has been completed. */
364 if (pwc != NULL) 123 *pwc = wc;
365 *pwc = wc;
366 return (wc == 0 ? 0 : count); 124 return (wc == 0 ? 0 : count);
367 } 125 }
368 } 126 }
@@ -371,32 +129,29 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
371 } 129 }
372# endif 130# endif
373 131
374# if MBRTOWC_NUL_RETVAL_BUG 132# if MBRTOWC_STORES_INCOMPLETE_BUG
375 { 133 ret = mbrtowc (&wc, s, n, ps);
376 wchar_t wc; 134 if (ret < (size_t) -2 && pwc != NULL)
377 size_t ret = mbrtowc (&wc, s, n, ps); 135 *pwc = wc;
378
379 if (ret != (size_t)(-1) && ret != (size_t)(-2))
380 {
381 if (pwc != NULL)
382 *pwc = wc;
383 if (wc == 0)
384 ret = 0;
385 }
386 return ret;
387 }
388# else 136# else
389 { 137 ret = mbrtowc (pwc, s, n, ps);
390# if MBRTOWC_NULL_ARG1_BUG 138# endif
391 wchar_t dummy;
392 139
393 if (pwc == NULL) 140# if MBRTOWC_NUL_RETVAL_BUG
394 pwc = &dummy; 141 if (ret < (size_t) -2 && !*pwc)
395# endif 142 return 0;
143# endif
396 144
397 return mbrtowc (pwc, s, n, ps); 145# if MBRTOWC_IN_C_LOCALE_MAYBE_EILSEQ
398 } 146 if ((size_t) -2 <= ret && n != 0 && ! hard_locale (LC_CTYPE))
147 {
148 unsigned char uc = *s;
149 *pwc = uc;
150 return 1;
151 }
399# endif 152# endif
153
154 return ret;
400} 155}
401 156
402#endif 157#endif
diff --git a/gl/mbsinit.c b/gl/mbsinit.c
index 26fbb7f..6e60079 100644
--- a/gl/mbsinit.c
+++ b/gl/mbsinit.c
@@ -1,38 +1,27 @@
1/* Test for initial conversion state. 1/* Test for initial conversion state.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
20/* Specification. */ 20/* Specification. */
21#include <wchar.h> 21#include <wchar.h>
22 22
23#include "verify.h"
24 23
25#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ 24#if GNULIB_defined_mbstate_t
26
27/* On native Windows, 'mbstate_t' is defined as 'int'. */
28
29int
30mbsinit (const mbstate_t *ps)
31{
32 return ps == NULL || *ps == 0;
33}
34
35#else
36 25
37/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() 26/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
38 and wcrtomb(), wcsrtombs(). 27 and wcrtomb(), wcsrtombs().
@@ -45,10 +34,11 @@ mbsinit (const mbstate_t *ps)
45 We define the meaning of mbstate_t as follows: 34 We define the meaning of mbstate_t as follows:
46 - In mb -> wc direction, mbstate_t's first byte contains the number of 35 - In mb -> wc direction, mbstate_t's first byte contains the number of
47 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes. 36 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
37 See mbrtowc.c.
48 - In wc -> mb direction, mbstate_t contains no information. In other 38 - In wc -> mb direction, mbstate_t contains no information. In other
49 words, it is always in the initial state. */ 39 words, it is always in the initial state. */
50 40
51verify (sizeof (mbstate_t) >= 4); 41static_assert (sizeof (mbstate_t) >= 4);
52 42
53int 43int
54mbsinit (const mbstate_t *ps) 44mbsinit (const mbstate_t *ps)
@@ -58,4 +48,22 @@ mbsinit (const mbstate_t *ps)
58 return pstate == NULL || pstate[0] == 0; 48 return pstate == NULL || pstate[0] == 0;
59} 49}
60 50
51#else
52
53int
54mbsinit (const mbstate_t *ps)
55{
56# if defined _WIN32 && !defined __CYGWIN__
57 /* Native Windows. */
58 /* MSVC defines 'mbstate_t' as an 8-byte struct; the first 4 bytes matter.
59 On mingw, 'mbstate_t' is sometimes defined as 'int', sometimes defined as
60 an 8-byte struct, of which the first 4 bytes matter. */
61 return ps == NULL || *(const unsigned int *)ps == 0;
62# else
63 /* Minix, HP-UX 11.00, Solaris 2.6, Interix, ... */
64 /* Maybe this definition works, maybe not... */
65 return ps == NULL || *(const char *)ps == 0;
66# endif
67}
68
61#endif 69#endif
diff --git a/gl/mbtowc-impl.h b/gl/mbtowc-impl.h
index 767ab39..39b977b 100644
--- a/gl/mbtowc-impl.h
+++ b/gl/mbtowc-impl.h
@@ -1,19 +1,19 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* We don't need a static internal state, because the encoding is not state 18/* We don't need a static internal state, because the encoding is not state
19 dependent, and when mbrtowc returns (size_t)(-2). we throw the result 19 dependent, and when mbrtowc returns (size_t)(-2). we throw the result
diff --git a/gl/mbtowc-lock.c b/gl/mbtowc-lock.c
new file mode 100644
index 0000000..6ca6e10
--- /dev/null
+++ b/gl/mbtowc-lock.c
@@ -0,0 +1,150 @@
1/* Return the internal lock used by mbrtowc and mbrtoc32.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
18
19#include <config.h>
20
21/* When it is known that the gl_get_mbtowc_lock function is defined
22 by a dependency library, it should not be defined here. */
23#if OMIT_MBTOWC_LOCK
24
25/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */
27typedef int dummy;
28
29#else
30
31/* This file defines the internal lock used by mbrtowc and mbrtoc32.
32 It is a separate compilation unit, so that only one copy of it is
33 present when linking statically. */
34
35/* Prohibit renaming this symbol. */
36# undef gl_get_mbtowc_lock
37
38/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */
40# ifndef DLL_EXPORTED
41# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport)
46# else
47# define DLL_EXPORTED
48# endif
49# endif
50
51# if defined _WIN32 && !defined __CYGWIN__
52
53# define WIN32_LEAN_AND_MEAN /* avoid including junk */
54# include <windows.h>
55
56# include "windows-initguard.h"
57
58/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
59 because the latter is not guaranteed to be a stable ABI in the future. */
60
61/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
63
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock;
66
67/* Returns the internal lock used by mbrtowc and mbrtoc32. */
68CRITICAL_SECTION *
69gl_get_mbtowc_lock (void)
70{
71 if (!guard.done)
72 {
73 if (InterlockedIncrement (&guard.started) == 0)
74 {
75 /* This thread is the first one to need the lock. Initialize it. */
76 InitializeCriticalSection (&lock);
77 guard.done = 1;
78 }
79 else
80 {
81 /* Don't let guard.started grow and wrap around. */
82 InterlockedDecrement (&guard.started);
83 /* Yield the CPU while waiting for another thread to finish
84 initializing this mutex. */
85 while (!guard.done)
86 Sleep (0);
87 }
88 }
89 return &lock;
90}
91
92# elif HAVE_PTHREAD_API
93
94# include <pthread.h>
95
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97
98/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
100
101/* Returns the internal lock used by mbrtowc and mbrtoc32. */
102pthread_mutex_t *
103gl_get_mbtowc_lock (void)
104{
105 return &mutex;
106}
107
108# elif HAVE_THREADS_H
109
110# include <threads.h>
111# include <stdlib.h>
112
113static int volatile init_needed = 1;
114static once_flag init_once = ONCE_FLAG_INIT;
115static mtx_t mutex;
116
117static void
118atomic_init (void)
119{
120 if (mtx_init (&mutex, mtx_plain) != thrd_success)
121 abort ();
122 init_needed = 0;
123}
124
125/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
127
128/* Returns the internal lock used by mbrtowc and mbrtoc32. */
129mtx_t *
130gl_get_mbtowc_lock (void)
131{
132 if (init_needed)
133 call_once (&init_once, atomic_init);
134 return &mutex;
135}
136
137# endif
138
139# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
140/* Make sure the '__declspec(dllimport)' in mbrtowc.c and mbrtoc32.c does not
141 cause a link failure when no DLLs are involved. */
142# if defined _WIN64 || defined _LP64
143# define IMP(x) __imp_##x
144# else
145# define IMP(x) _imp__##x
146# endif
147void * IMP(gl_get_mbtowc_lock) = &gl_get_mbtowc_lock;
148# endif
149
150#endif
diff --git a/gl/mbtowc-lock.h b/gl/mbtowc-lock.h
new file mode 100644
index 0000000..2dc22ac
--- /dev/null
+++ b/gl/mbtowc-lock.h
@@ -0,0 +1,125 @@
1/* Use the internal lock used by mbrtowc and mbrtoc32.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
18
19/* Use a lock, so that no two threads can invoke mbtowc at the same time. */
20
21static inline int
22mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
23{
24 /* Put the hidden internal state of mbtowc into its initial state.
25 This is needed at least with glibc, uClibc, and MSVC CRT.
26 See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>. */
27 mbtowc (NULL, NULL, 0);
28
29 return mbtowc (pwc, p, m);
30}
31
32/* Prohibit renaming this symbol. */
33#undef gl_get_mbtowc_lock
34
35#if GNULIB_MBRTOWC_SINGLE_THREAD
36
37/* All uses of this function are in a single thread. No locking needed. */
38
39static int
40mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
41{
42 return mbtowc_unlocked (pwc, p, m);
43}
44
45#elif defined _WIN32 && !defined __CYGWIN__
46
47extern __declspec(dllimport) CRITICAL_SECTION *gl_get_mbtowc_lock (void);
48
49static int
50mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
51{
52 CRITICAL_SECTION *lock = gl_get_mbtowc_lock ();
53 int ret;
54
55 EnterCriticalSection (lock);
56 ret = mbtowc_unlocked (pwc, p, m);
57 LeaveCriticalSection (lock);
58
59 return ret;
60}
61
62#elif HAVE_PTHREAD_API /* AIX, IRIX, Cygwin */
63
64extern
65# if defined _WIN32 || defined __CYGWIN__
66 __declspec(dllimport)
67# endif
68 pthread_mutex_t *gl_get_mbtowc_lock (void);
69
70# if HAVE_WEAK_SYMBOLS /* IRIX */
71
72 /* Avoid the need to link with '-lpthread'. */
73# pragma weak pthread_mutex_lock
74# pragma weak pthread_mutex_unlock
75
76 /* Determine whether libpthread is in use. */
77# pragma weak pthread_mutexattr_gettype
78 /* See the comments in lock.h. */
79# define pthread_in_use() \
80 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
81
82# else
83# define pthread_in_use() 1
84# endif
85
86static int
87mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
88{
89 if (pthread_in_use())
90 {
91 pthread_mutex_t *lock = gl_get_mbtowc_lock ();
92 int ret;
93
94 if (pthread_mutex_lock (lock))
95 abort ();
96 ret = mbtowc_unlocked (pwc, p, m);
97 if (pthread_mutex_unlock (lock))
98 abort ();
99
100 return ret;
101 }
102 else
103 return mbtowc_unlocked (pwc, p, m);
104}
105
106#elif HAVE_THREADS_H
107
108extern mtx_t *gl_get_mbtowc_lock (void);
109
110static int
111mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
112{
113 mtx_t *lock = gl_get_mbtowc_lock ();
114 int ret;
115
116 if (mtx_lock (lock) != thrd_success)
117 abort ();
118 ret = mbtowc_unlocked (pwc, p, m);
119 if (mtx_unlock (lock) != thrd_success)
120 abort ();
121
122 return ret;
123}
124
125#endif
diff --git a/gl/mbtowc.c b/gl/mbtowc.c
index 632f2e1..8d9b06d 100644
--- a/gl/mbtowc.c
+++ b/gl/mbtowc.c
@@ -1,19 +1,19 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/memchr.c b/gl/memchr.c
index 3db38a9..8e95579 100644
--- a/gl/memchr.c
+++ b/gl/memchr.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2013 1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2023
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 3
4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se), 4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
@@ -7,21 +7,21 @@
7 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), 7 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
8 and implemented by Roland McGrath (roland@ai.mit.edu). 8 and implemented by Roland McGrath (roland@ai.mit.edu).
9 9
10NOTE: The canonical source of this file is maintained with the GNU C Library. 10 NOTE: The canonical source of this file is maintained with the GNU C Library.
11Bugs can be reported to bug-glibc@prep.ai.mit.edu. 11 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
12 12
13This program is free software: you can redistribute it and/or modify it 13 This file is free software: you can redistribute it and/or modify
14under the terms of the GNU General Public License as published by the 14 it under the terms of the GNU Lesser General Public License as
15Free Software Foundation; either version 3 of the License, or any 15 published by the Free Software Foundation; either version 2.1 of the
16later version. 16 License, or (at your option) any later version.
17 17
18This program is distributed in the hope that it will be useful, 18 This file is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of 19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details. 21 GNU Lesser General Public License for more details.
22 22
23You should have received a copy of the GNU General Public License 23 You should have received a copy of the GNU Lesser General Public License
24along with this program. If not, see <http://www.gnu.org/licenses/>. */ 24 along with this program. If not, see <https://www.gnu.org/licenses/>. */
25 25
26#ifndef _LIBC 26#ifndef _LIBC
27# include <config.h> 27# include <config.h>
diff --git a/gl/memchr.valgrind b/gl/memchr.valgrind
index 60f247e..97690f2 100644
--- a/gl/memchr.valgrind
+++ b/gl/memchr.valgrind
@@ -1,4 +1,20 @@
1# Suppress a valgrind message about use of uninitialized memory in memchr(). 1# Suppress a valgrind message about use of uninitialized memory in memchr().
2
3# Copyright (C) 2009-2023 Free Software Foundation, Inc.
4#
5# This file is free software: you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as
7# published by the Free Software Foundation; either version 2.1 of the
8# License, or (at your option) any later version.
9#
10# This file is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this program. If not, see <https://www.gnu.org/licenses/>.
17
2# POSIX states that when the character is found, memchr must not read extra 18# POSIX states that when the character is found, memchr must not read extra
3# bytes in an overestimated length (for example, where memchr is used to 19# bytes in an overestimated length (for example, where memchr is used to
4# implement strnlen). However, we use a safe word read to provide a speedup. 20# implement strnlen). However, we use a safe word read to provide a speedup.
diff --git a/gl/minmax.h b/gl/minmax.h
new file mode 100644
index 0000000..1fbfc66
--- /dev/null
+++ b/gl/minmax.h
@@ -0,0 +1,60 @@
1/* MIN, MAX macros.
2 Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2023 Free Software
3 Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _MINMAX_H
19#define _MINMAX_H
20
21/* Note: MIN, MAX are also defined in <sys/param.h> on some systems
22 (glibc, IRIX, HP-UX, OSF/1). Therefore you might get warnings about
23 MIN, MAX macro redefinitions on some systems; the workaround is to
24 #include this file as the last one among the #include list. */
25
26/* Before we define the following symbols we get the <limits.h> file
27 since otherwise we get redefinitions on some systems if <limits.h> is
28 included after this file. Likewise for <sys/param.h>.
29 If more than one of these system headers define MIN and MAX, pick just
30 one of the headers (because the definitions most likely are the same). */
31#if HAVE_MINMAX_IN_LIMITS_H
32# include <limits.h>
33#elif HAVE_MINMAX_IN_SYS_PARAM_H
34# include <sys/param.h>
35#endif
36
37/* Note: MIN and MAX should be used with two arguments of the
38 same type. They might not return the minimum and maximum of their two
39 arguments, if the arguments have different types or have unusual
40 floating-point values. For example, on a typical host with 32-bit 'int',
41 64-bit 'long long', and 64-bit IEEE 754 'double' types:
42
43 MAX (-1, 2147483648) returns 4294967295.
44 MAX (9007199254740992.0, 9007199254740993) returns 9007199254740992.0.
45 MAX (NaN, 0.0) returns 0.0.
46 MAX (+0.0, -0.0) returns -0.0.
47
48 and in each case the answer is in some sense bogus. */
49
50/* MAX(a,b) returns the maximum of A and B. */
51#ifndef MAX
52# define MAX(a,b) ((a) > (b) ? (a) : (b))
53#endif
54
55/* MIN(a,b) returns the minimum of A and B. */
56#ifndef MIN
57# define MIN(a,b) ((a) < (b) ? (a) : (b))
58#endif
59
60#endif /* _MINMAX_H */
diff --git a/gl/mktime-internal.h b/gl/mktime-internal.h
index 4287acf..709c36b 100644
--- a/gl/mktime-internal.h
+++ b/gl/mktime-internal.h
@@ -1,4 +1,79 @@
1#include <time.h> 1/* Internals of mktime and related functions
2time_t mktime_internal (struct tm *, 2 Copyright 2016-2023 Free Software Foundation, Inc.
3 struct tm * (*) (time_t const *, struct tm *), 3 This file is part of the GNU C Library.
4 time_t *); 4 Contributed by Paul Eggert <eggert@cs.ucla.edu>.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
19
20#ifndef _LIBC
21# include <time.h>
22#endif
23
24/* mktime_offset_t is a signed type wide enough to hold a UTC offset
25 in seconds, and used as part of the type of the offset-guess
26 argument to mktime_internal. In Glibc, it is always long int.
27 When in Gnulib, use time_t on platforms where time_t
28 is signed, to be compatible with platforms like BeOS that export
29 this implementation detail of mktime. On platforms where time_t is
30 unsigned, GNU and POSIX code can assume 'int' is at least 32 bits
31 which is wide enough for a UTC offset. */
32#ifdef _LIBC
33typedef long int mktime_offset_t;
34#elif defined TIME_T_IS_SIGNED
35typedef time_t mktime_offset_t;
36#else
37typedef int mktime_offset_t;
38#endif
39
40/* The source code uses identifiers like __time64_t for glibc
41 timestamps that can contain 64-bit values even when time_t is only
42 32 bits. These are just macros for the ordinary identifiers unless
43 compiling within glibc when time_t is 32 bits. */
44#if ! (defined _LIBC && __TIMESIZE != 64)
45# undef __time64_t
46# define __time64_t time_t
47# define __gmtime64_r __gmtime_r
48# define __localtime64_r __localtime_r
49# define __mktime64 mktime
50# define __timegm64 timegm
51#endif
52
53#ifndef _LIBC
54
55/* Although glibc source code uses leading underscores, Gnulib wants
56 ordinary names.
57
58 Portable standalone applications should supply a <time.h> that
59 declares a POSIX-compliant localtime_r, for the benefit of older
60 implementations that lack localtime_r or have a nonstandard one.
61 Similarly for gmtime_r. See the gnulib time_r module for one way
62 to implement this. */
63
64# undef __gmtime_r
65# undef __localtime_r
66# define __gmtime_r gmtime_r
67# define __localtime_r localtime_r
68
69# define __mktime_internal mktime_internal
70
71#endif
72
73/* Subroutine of mktime. Return the time_t representation of TP and
74 normalize TP, given that a struct tm * maps to a time_t as performed
75 by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */
76extern __time64_t __mktime_internal (struct tm *tp,
77 struct tm *(*func) (__time64_t const *,
78 struct tm *),
79 mktime_offset_t *offset) attribute_hidden;
diff --git a/gl/mktime.c b/gl/mktime.c
index e660a23..94a4320 100644
--- a/gl/mktime.c
+++ b/gl/mktime.c
@@ -1,28 +1,37 @@
1/* Convert a 'struct tm' to a time_t value. 1/* Convert a 'struct tm' to a time_t value.
2 Copyright (C) 1993-2013 Free Software Foundation, Inc. 2 Copyright (C) 1993-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@twinsun.com>. 4 Contributed by Paul Eggert <eggert@twinsun.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20/* Define this to have a standalone program to test this implementation of 20/* The following macros influence what gets defined when this file is compiled:
21 mktime. */ 21
22/* #define DEBUG 1 */ 22 Macro/expression Which gnulib module This compilation unit
23 should define
24
25 _LIBC (glibc proper) mktime
26
27 NEED_MKTIME_WORKING mktime rpl_mktime
28 || NEED_MKTIME_WINDOWS
29
30 NEED_MKTIME_INTERNAL mktime-internal mktime_internal
31 */
23 32
24#ifndef _LIBC 33#ifndef _LIBC
25# include <config.h> 34# include <libc-config.h>
26#endif 35#endif
27 36
28/* Assume that leap seconds are possible, unless told otherwise. 37/* Assume that leap seconds are possible, unless told otherwise.
@@ -34,115 +43,123 @@
34 43
35#include <time.h> 44#include <time.h>
36 45
46#include <errno.h>
37#include <limits.h> 47#include <limits.h>
48#include <stdbool.h>
49#include <stdlib.h>
50#include <string.h>
51
52#include <intprops.h>
53#include <verify.h>
54
55#ifndef NEED_MKTIME_INTERNAL
56# define NEED_MKTIME_INTERNAL 0
57#endif
58#ifndef NEED_MKTIME_WINDOWS
59# define NEED_MKTIME_WINDOWS 0
60#endif
61#ifndef NEED_MKTIME_WORKING
62# define NEED_MKTIME_WORKING 0
63#endif
64
65#include "mktime-internal.h"
38 66
39#include <string.h> /* For the real memcpy prototype. */ 67#if !defined _LIBC && (NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS)
40 68static void
41#if DEBUG 69my_tzset (void)
42# include <stdio.h> 70{
43# include <stdlib.h> 71# if NEED_MKTIME_WINDOWS
44/* Make it work even if the system's libc has its own mktime routine. */ 72 /* Rectify the value of the environment variable TZ.
45# undef mktime 73 There are four possible kinds of such values:
46# define mktime my_mktime 74 - Traditional US time zone names, e.g. "PST8PDT". Syntax: see
47#endif /* DEBUG */ 75 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset>
48 76 - Time zone names based on geography, that contain one or more
49/* Some of the code in this file assumes that signed integer overflow 77 slashes, e.g. "Europe/Moscow".
50 silently wraps around. This assumption can't easily be programmed 78 - Time zone names based on geography, without slashes, e.g.
51 around, nor can it be checked for portably at compile-time or 79 "Singapore".
52 easily eliminated at run-time. 80 - Time zone names that contain explicit DST rules. Syntax: see
53 81 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03>
54 Define WRAPV to 1 if the assumption is valid and if 82 The Microsoft CRT understands only the first kind. It produces incorrect
55 #pragma GCC optimize ("wrapv") 83 results if the value of TZ is of the other kinds.
56 does not trigger GCC bug 51793 84 But in a Cygwin environment, /etc/profile.d/tzset.sh sets TZ to a value
57 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>. 85 of the second kind for most geographies, or of the first kind in a few
58 Otherwise, define it to 0; this forces the use of slower code that, 86 other geographies. If it is of the second kind, neutralize it. For the
59 while not guaranteed by the C Standard, works on all production 87 Microsoft CRT, an absent or empty TZ means the time zone that the user
60 platforms that we know about. */ 88 has set in the Windows Control Panel.
61#ifndef WRAPV 89 If the value of TZ is of the third or fourth kind -- Cygwin programs
62# if (((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) \ 90 understand these syntaxes as well --, it does not matter whether we
63 && defined __GLIBC__) 91 neutralize it or not, since these values occur only when a Cygwin user
64# pragma GCC optimize ("wrapv") 92 has set TZ explicitly; this case is 1. rare and 2. under the user's
65# define WRAPV 1 93 responsibility. */
94 const char *tz = getenv ("TZ");
95 if (tz != NULL && strchr (tz, '/') != NULL)
96 _putenv ("TZ=");
66# else 97# else
67# define WRAPV 0 98 tzset ();
68# endif 99# endif
100}
101# undef __tzset
102# define __tzset() my_tzset ()
69#endif 103#endif
70 104
71/* Verify a requirement at compile-time (unlike assert, which is runtime). */ 105#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL
72#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; } 106
107/* A signed type that can represent an integer number of years
108 multiplied by four times the number of seconds in a year. It is
109 needed when converting a tm_year value times the number of seconds
110 in a year. The factor of four comes because these products need
111 to be subtracted from each other, and sometimes with an offset
112 added to them, and then with another timestamp added, without
113 worrying about overflow.
73 114
74/* A signed type that is at least one bit wider than int. */ 115 Much of the code uses long_int to represent __time64_t values, to
75#if INT_MAX <= LONG_MAX / 2 116 lessen the hassle of dealing with platforms where __time64_t is
117 unsigned, and because long_int should suffice to represent all
118 __time64_t values that mktime can generate even on platforms where
119 __time64_t is wider than the int components of struct tm. */
120
121#if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60
76typedef long int long_int; 122typedef long int long_int;
77#else 123#else
78typedef long long int long_int; 124typedef long long int long_int;
79#endif 125#endif
80verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2); 126verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60);
81 127
82/* Shift A right by B bits portably, by dividing A by 2**B and 128/* Shift A right by B bits portably, by dividing A by 2**B and
83 truncating towards minus infinity. A and B should be free of side 129 truncating towards minus infinity. B should be in the range 0 <= B
84 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where 130 <= LONG_INT_BITS - 2, where LONG_INT_BITS is the number of useful
85 INT_BITS is the number of useful bits in an int. GNU code can 131 bits in a long_int. LONG_INT_BITS is at least 32.
86 assume that INT_BITS is at least 32.
87 132
88 ISO C99 says that A >> B is implementation-defined if A < 0. Some 133 ISO C99 says that A >> B is implementation-defined if A < 0. Some
89 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift 134 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
90 right in the usual way when A < 0, so SHR falls back on division if 135 right in the usual way when A < 0, so SHR falls back on division if
91 ordinary A >> B doesn't seem to be the usual signed shift. */ 136 ordinary A >> B doesn't seem to be the usual signed shift. */
92#define SHR(a, b) \
93 ((-1 >> 1 == -1 \
94 && (long_int) -1 >> 1 == -1 \
95 && ((time_t) -1 >> 1 == -1 || ! TYPE_SIGNED (time_t))) \
96 ? (a) >> (b) \
97 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
98
99/* The extra casts in the following macros work around compiler bugs,
100 e.g., in Cray C 5.0.3.0. */
101
102/* True if the arithmetic type T is an integer type. bool counts as
103 an integer. */
104#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
105
106/* True if negative values of the signed integer type T use two's
107 complement, or if T is an unsigned integer type. */
108#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
109
110/* True if the arithmetic type T is signed. */
111#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
112
113/* The maximum and minimum values for the integer type T. These
114 macros have undefined behavior if T is signed and has padding bits.
115 If this is a problem for you, please let us know how to fix it for
116 your host. */
117#define TYPE_MINIMUM(t) \
118 ((t) (! TYPE_SIGNED (t) \
119 ? (t) 0 \
120 : ~ TYPE_MAXIMUM (t)))
121#define TYPE_MAXIMUM(t) \
122 ((t) (! TYPE_SIGNED (t) \
123 ? (t) -1 \
124 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
125
126#ifndef TIME_T_MIN
127# define TIME_T_MIN TYPE_MINIMUM (time_t)
128#endif
129#ifndef TIME_T_MAX
130# define TIME_T_MAX TYPE_MAXIMUM (time_t)
131#endif
132#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
133 137
134verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); 138static long_int
135verify (twos_complement_arithmetic, 139shr (long_int a, int b)
136 (TYPE_TWOS_COMPLEMENT (int) 140{
137 && TYPE_TWOS_COMPLEMENT (long_int) 141 long_int one = 1;
138 && TYPE_TWOS_COMPLEMENT (time_t))); 142 return (-one >> 1 == -1
143 ? a >> b
144 : (a + (a < 0)) / (one << b) - (a < 0));
145}
146
147/* Bounds for the intersection of __time64_t and long_int. */
148
149static long_int const mktime_min
150 = ((TYPE_SIGNED (__time64_t)
151 && TYPE_MINIMUM (__time64_t) < TYPE_MINIMUM (long_int))
152 ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (__time64_t));
153static long_int const mktime_max
154 = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t)
155 ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t));
139 156
140#define EPOCH_YEAR 1970 157#define EPOCH_YEAR 1970
141#define TM_YEAR_BASE 1900 158#define TM_YEAR_BASE 1900
142verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0); 159verify (TM_YEAR_BASE % 100 == 0);
143 160
144/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */ 161/* Is YEAR + TM_YEAR_BASE a leap year? */
145static int 162static bool
146leapyear (long_int year) 163leapyear (long_int year)
147{ 164{
148 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow. 165 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
@@ -166,20 +183,9 @@ const unsigned short int __mon_yday[2][13] =
166 }; 183 };
167 184
168 185
169#ifndef _LIBC 186/* Do the values A and B differ according to the rules for tm_isdst?
170/* Portable standalone applications should supply a <time.h> that 187 A and B differ if one is zero and the other positive. */
171 declares a POSIX-compliant localtime_r, for the benefit of older 188static bool
172 implementations that lack localtime_r or have a nonstandard one.
173 See the gnulib time_r module for one way to implement this. */
174# undef __localtime_r
175# define __localtime_r localtime_r
176# define __mktime_internal mktime_internal
177# include "mktime-internal.h"
178#endif
179
180/* Return 1 if the values A and B differ according to the rules for
181 tm_isdst: A and B differ if one is zero and the other positive. */
182static int
183isdst_differ (int a, int b) 189isdst_differ (int a, int b)
184{ 190{
185 return (!a != !b) && (0 <= a) && (0 <= b); 191 return (!a != !b) && (0 <= a) && (0 <= b);
@@ -187,171 +193,135 @@ isdst_differ (int a, int b)
187 193
188/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - 194/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
189 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks 195 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
190 were not adjusted between the time stamps. 196 were not adjusted between the timestamps.
191 197
192 The YEAR values uses the same numbering as TP->tm_year. Values 198 The YEAR values uses the same numbering as TP->tm_year. Values
193 need not be in the usual range. However, YEAR1 must not be less 199 need not be in the usual range. However, YEAR1 - YEAR0 must not
194 than 2 * INT_MIN or greater than 2 * INT_MAX. 200 overflow even when multiplied by three times the number of seconds
201 in a year, and likewise for YDAY1 - YDAY0 and three times the
202 number of seconds in a day. */
195 203
196 The result may overflow. It is the caller's responsibility to 204static long_int
197 detect overflow. */
198
199static time_t
200ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1, 205ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
201 int year0, int yday0, int hour0, int min0, int sec0) 206 int year0, int yday0, int hour0, int min0, int sec0)
202{ 207{
203 verify (C99_integer_division, -1 / 2 == 0); 208 verify (-1 / 2 == 0);
204 209
205 /* Compute intervening leap days correctly even if year is negative. 210 /* Compute intervening leap days correctly even if year is negative.
206 Take care to avoid integer overflow here. */ 211 Take care to avoid integer overflow here. */
207 int a4 = SHR (year1, 2) + SHR (TM_YEAR_BASE, 2) - ! (year1 & 3); 212 int a4 = shr (year1, 2) + shr (TM_YEAR_BASE, 2) - ! (year1 & 3);
208 int b4 = SHR (year0, 2) + SHR (TM_YEAR_BASE, 2) - ! (year0 & 3); 213 int b4 = shr (year0, 2) + shr (TM_YEAR_BASE, 2) - ! (year0 & 3);
209 int a100 = a4 / 25 - (a4 % 25 < 0); 214 int a100 = (a4 + (a4 < 0)) / 25 - (a4 < 0);
210 int b100 = b4 / 25 - (b4 % 25 < 0); 215 int b100 = (b4 + (b4 < 0)) / 25 - (b4 < 0);
211 int a400 = SHR (a100, 2); 216 int a400 = shr (a100, 2);
212 int b400 = SHR (b100, 2); 217 int b400 = shr (b100, 2);
213 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); 218 int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400);
214 219
215 /* Compute the desired time in time_t precision. Overflow might 220 /* Compute the desired time without overflowing. */
216 occur here. */ 221 long_int years = year1 - year0;
217 time_t tyear1 = year1; 222 long_int days = 365 * years + yday1 - yday0 + intervening_leap_days;
218 time_t years = tyear1 - year0; 223 long_int hours = 24 * days + hour1 - hour0;
219 time_t days = 365 * years + yday1 - yday0 + intervening_leap_days; 224 long_int minutes = 60 * hours + min1 - min0;
220 time_t hours = 24 * days + hour1 - hour0; 225 long_int seconds = 60 * minutes + sec1 - sec0;
221 time_t minutes = 60 * hours + min1 - min0;
222 time_t seconds = 60 * minutes + sec1 - sec0;
223 return seconds; 226 return seconds;
224} 227}
225 228
226/* Return the average of A and B, even if A + B would overflow. */ 229/* Return the average of A and B, even if A + B would overflow.
227static time_t 230 Round toward positive infinity. */
228time_t_avg (time_t a, time_t b) 231static long_int
232long_int_avg (long_int a, long_int b)
229{ 233{
230 return SHR (a, 1) + SHR (b, 1) + (a & b & 1); 234 return shr (a, 1) + shr (b, 1) + ((a | b) & 1);
231} 235}
232 236
233/* Return 1 if A + B does not overflow. If time_t is unsigned and if 237/* Return a long_int value corresponding to (YEAR-YDAY HOUR:MIN:SEC)
234 B's top bit is set, assume that the sum represents A - -B, and 238 minus *TP seconds, assuming no clock adjustments occurred between
235 return 1 if the subtraction does not wrap around. */ 239 the two timestamps.
236static int
237time_t_add_ok (time_t a, time_t b)
238{
239 if (! TYPE_SIGNED (time_t))
240 {
241 time_t sum = a + b;
242 return (sum < a) == (TIME_T_MIDPOINT <= b);
243 }
244 else if (WRAPV)
245 {
246 time_t sum = a + b;
247 return (sum < a) == (b < 0);
248 }
249 else
250 {
251 time_t avg = time_t_avg (a, b);
252 return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2;
253 }
254}
255 240
256/* Return 1 if A + B does not overflow. */ 241 YEAR and YDAY must not be so large that multiplying them by three times the
257static int 242 number of seconds in a year (or day, respectively) would overflow long_int.
258time_t_int_add_ok (time_t a, int b) 243 *TP should be in the usual range. */
244static long_int
245tm_diff (long_int year, long_int yday, int hour, int min, int sec,
246 struct tm const *tp)
259{ 247{
260 verify (int_no_wider_than_time_t, INT_MAX <= TIME_T_MAX); 248 return ydhms_diff (year, yday, hour, min, sec,
261 if (WRAPV) 249 tp->tm_year, tp->tm_yday,
262 { 250 tp->tm_hour, tp->tm_min, tp->tm_sec);
263 time_t sum = a + b;
264 return (sum < a) == (b < 0);
265 }
266 else
267 {
268 int a_odd = a & 1;
269 time_t avg = SHR (a, 1) + (SHR (b, 1) + (a_odd & b));
270 return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2;
271 }
272} 251}
273 252
274/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC), 253/* Use CONVERT to convert T to a struct tm value in *TM. T must be in
275 assuming that *T corresponds to *TP and that no clock adjustments 254 range for __time64_t. Return TM if successful, NULL (setting errno) on
276 occurred between *TP and the desired time. 255 failure. */
277 If TP is null, return a value not equal to *T; this avoids false matches. 256static struct tm *
278 If overflow occurs, yield the minimal or maximal value, except do not 257convert_time (struct tm *(*convert) (const __time64_t *, struct tm *),
279 yield a value equal to *T. */ 258 long_int t, struct tm *tm)
280static time_t
281guess_time_tm (long_int year, long_int yday, int hour, int min, int sec,
282 const time_t *t, const struct tm *tp)
283{ 259{
284 if (tp) 260 __time64_t x = t;
285 { 261 return convert (&x, tm);
286 time_t d = ydhms_diff (year, yday, hour, min, sec,
287 tp->tm_year, tp->tm_yday,
288 tp->tm_hour, tp->tm_min, tp->tm_sec);
289 if (time_t_add_ok (*t, d))
290 return *t + d;
291 }
292
293 /* Overflow occurred one way or another. Return the nearest result
294 that is actually in range, except don't report a zero difference
295 if the actual difference is nonzero, as that would cause a false
296 match; and don't oscillate between two values, as that would
297 confuse the spring-forward gap detector. */
298 return (*t < TIME_T_MIDPOINT
299 ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN)
300 : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX));
301} 262}
302 263
303/* Use CONVERT to convert *T to a broken down time in *TP. 264/* Use CONVERT to convert *T to a broken down time in *TP.
304 If *T is out of range for conversion, adjust it so that 265 If *T is out of range for conversion, adjust it so that
305 it is the nearest in-range value and then convert that. */ 266 it is the nearest in-range value and then convert that.
267 A value is in range if it fits in both __time64_t and long_int.
268 Return TP on success, NULL (setting errno) on failure. */
306static struct tm * 269static struct tm *
307ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), 270ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
308 time_t *t, struct tm *tp) 271 long_int *t, struct tm *tp)
309{ 272{
310 struct tm *r = convert (t, tp); 273 long_int t1 = (*t < mktime_min ? mktime_min
311 274 : *t <= mktime_max ? *t : mktime_max);
312 if (!r && *t) 275 struct tm *r = convert_time (convert, t1, tp);
276 if (r)
313 { 277 {
314 time_t bad = *t; 278 *t = t1;
315 time_t ok = 0; 279 return r;
280 }
281 if (errno != EOVERFLOW)
282 return NULL;
316 283
317 /* BAD is a known unconvertible time_t, and OK is a known good one. 284 long_int bad = t1;
318 Use binary search to narrow the range between BAD and OK until 285 long_int ok = 0;
319 they differ by 1. */ 286 struct tm oktm; oktm.tm_sec = -1;
320 while (bad != ok + (bad < 0 ? -1 : 1))
321 {
322 time_t mid = *t = time_t_avg (ok, bad);
323 r = convert (t, tp);
324 if (r)
325 ok = mid;
326 else
327 bad = mid;
328 }
329 287
330 if (!r && ok) 288 /* BAD is a known out-of-range value, and OK is a known in-range one.
331 { 289 Use binary search to narrow the range between BAD and OK until
332 /* The last conversion attempt failed; 290 they differ by 1. */
333 revert to the most recent successful attempt. */ 291 while (true)
334 *t = ok; 292 {
335 r = convert (t, tp); 293 long_int mid = long_int_avg (ok, bad);
336 } 294 if (mid == ok || mid == bad)
295 break;
296 if (convert_time (convert, mid, tp))
297 ok = mid, oktm = *tp;
298 else if (errno != EOVERFLOW)
299 return NULL;
300 else
301 bad = mid;
337 } 302 }
338 303
339 return r; 304 if (oktm.tm_sec < 0)
305 return NULL;
306 *t = ok;
307 *tp = oktm;
308 return tp;
340} 309}
341 310
342 311
343/* Convert *TP to a time_t value, inverting 312/* Convert *TP to a __time64_t value, inverting
344 the monotonic and mostly-unit-linear conversion function CONVERT. 313 the monotonic and mostly-unit-linear conversion function CONVERT.
345 Use *OFFSET to keep track of a guess at the offset of the result, 314 Use *OFFSET to keep track of a guess at the offset of the result,
346 compared to what the result would be for UTC without leap seconds. 315 compared to what the result would be for UTC without leap seconds.
347 If *OFFSET's guess is correct, only one CONVERT call is needed. 316 If *OFFSET's guess is correct, only one CONVERT call is needed.
317 If successful, set *TP to the canonicalized struct tm;
318 otherwise leave *TP alone, return ((time_t) -1) and set errno.
348 This function is external because it is used also by timegm.c. */ 319 This function is external because it is used also by timegm.c. */
349time_t 320__time64_t
350__mktime_internal (struct tm *tp, 321__mktime_internal (struct tm *tp,
351 struct tm *(*convert) (const time_t *, struct tm *), 322 struct tm *(*convert) (const __time64_t *, struct tm *),
352 time_t *offset) 323 mktime_offset_t *offset)
353{ 324{
354 time_t t, gt, t0, t1, t2;
355 struct tm tm; 325 struct tm tm;
356 326
357 /* The maximum number of probes (calls to CONVERT) should be enough 327 /* The maximum number of probes (calls to CONVERT) should be enough
@@ -371,7 +341,7 @@ __mktime_internal (struct tm *tp,
371 int isdst = tp->tm_isdst; 341 int isdst = tp->tm_isdst;
372 342
373 /* 1 if the previous probe was DST. */ 343 /* 1 if the previous probe was DST. */
374 int dst2; 344 int dst2 = 0;
375 345
376 /* Ensure that mon is in range, and set year accordingly. */ 346 /* Ensure that mon is in range, and set year accordingly. */
377 int mon_remainder = mon % 12; 347 int mon_remainder = mon % 12;
@@ -381,9 +351,7 @@ __mktime_internal (struct tm *tp,
381 long_int year = lyear_requested + mon_years; 351 long_int year = lyear_requested + mon_years;
382 352
383 /* The other values need not be in range: 353 /* The other values need not be in range:
384 the remaining code handles minor overflows correctly, 354 the remaining code handles overflows correctly. */
385 assuming int and time_t arithmetic wraps around.
386 Major overflows are caught at the end. */
387 355
388 /* Calculate day of year from year, month, and day of month. 356 /* Calculate day of year from year, month, and day of month.
389 The result need not be in range. */ 357 The result need not be in range. */
@@ -393,14 +361,15 @@ __mktime_internal (struct tm *tp,
393 long_int lmday = mday; 361 long_int lmday = mday;
394 long_int yday = mon_yday + lmday; 362 long_int yday = mon_yday + lmday;
395 363
396 time_t guessed_offset = *offset; 364 mktime_offset_t off = *offset;
365 int negative_offset_guess;
397 366
398 int sec_requested = sec; 367 int sec_requested = sec;
399 368
400 if (LEAP_SECONDS_POSSIBLE) 369 if (LEAP_SECONDS_POSSIBLE)
401 { 370 {
402 /* Handle out-of-range seconds specially, 371 /* Handle out-of-range seconds specially,
403 since ydhms_tm_diff assumes every minute has 60 seconds. */ 372 since ydhms_diff assumes every minute has 60 seconds. */
404 if (sec < 0) 373 if (sec < 0)
405 sec = 0; 374 sec = 0;
406 if (59 < sec) 375 if (59 < sec)
@@ -410,91 +379,47 @@ __mktime_internal (struct tm *tp,
410 /* Invert CONVERT by probing. First assume the same offset as last 379 /* Invert CONVERT by probing. First assume the same offset as last
411 time. */ 380 time. */
412 381
413 t0 = ydhms_diff (year, yday, hour, min, sec, 382 INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess);
414 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset); 383 long_int t0 = ydhms_diff (year, yday, hour, min, sec,
384 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0,
385 negative_offset_guess);
386 long_int t = t0, t1 = t0, t2 = t0;
387
388 /* Repeatedly use the error to improve the guess. */
415 389
416 if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) 390 while (true)
417 { 391 {
418 /* time_t isn't large enough to rule out overflows, so check 392 if (! ranged_convert (convert, &t, &tm))
419 for major overflows. A gross check suffices, since if t0 393 return -1;
420 has overflowed, it is off by a multiple of TIME_T_MAX - 394 long_int dt = tm_diff (year, yday, hour, min, sec, &tm);
421 TIME_T_MIN + 1. So ignore any component of the difference 395 if (dt == 0)
422 that is bounded by a small value. */ 396 break;
423 397
424 /* Approximate log base 2 of the number of time units per 398 if (t == t1 && t != t2
425 biennium. A biennium is 2 years; use this unit instead of 399 && (tm.tm_isdst < 0
426 years to avoid integer overflow. For example, 2 average 400 || (isdst < 0
427 Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds, 401 ? dst2 <= (tm.tm_isdst != 0)
428 which is 63113904 seconds, and rint (log2 (63113904)) is 402 : (isdst != 0) != (tm.tm_isdst != 0))))
429 26. */ 403 /* We can't possibly find a match, as we are oscillating
430 int ALOG2_SECONDS_PER_BIENNIUM = 26; 404 between two values. The requested time probably falls
431 int ALOG2_MINUTES_PER_BIENNIUM = 20; 405 within a spring-forward gap of size DT. Follow the common
432 int ALOG2_HOURS_PER_BIENNIUM = 14; 406 practice in this case, which is to return a time that is DT
433 int ALOG2_DAYS_PER_BIENNIUM = 10; 407 away from the requested time, preferring a time whose
434 int LOG2_YEARS_PER_BIENNIUM = 1; 408 tm_isdst differs from the requested value. (If no tm_isdst
435 409 was requested and only one of the two values has a nonzero
436 int approx_requested_biennia = 410 tm_isdst, prefer that value.) In practice, this is more
437 (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM) 411 useful than returning -1. */
438 - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM) 412 goto offset_found;
439 + SHR (mday, ALOG2_DAYS_PER_BIENNIUM) 413
440 + SHR (hour, ALOG2_HOURS_PER_BIENNIUM) 414 remaining_probes--;
441 + SHR (min, ALOG2_MINUTES_PER_BIENNIUM) 415 if (remaining_probes == 0)
442 + (LEAP_SECONDS_POSSIBLE
443 ? 0
444 : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
445
446 int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM);
447 int diff = approx_biennia - approx_requested_biennia;
448 int approx_abs_diff = diff < 0 ? -1 - diff : diff;
449
450 /* IRIX 4.0.5 cc miscalculates TIME_T_MIN / 3: it erroneously
451 gives a positive value of 715827882. Setting a variable
452 first then doing math on it seems to work.
453 (ghazi@caip.rutgers.edu) */
454 time_t time_t_max = TIME_T_MAX;
455 time_t time_t_min = TIME_T_MIN;
456 time_t overflow_threshold =
457 (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM;
458
459 if (overflow_threshold < approx_abs_diff)
460 { 416 {
461 /* Overflow occurred. Try repairing it; this might work if 417 __set_errno (EOVERFLOW);
462 the time zone offset is enough to undo the overflow. */ 418 return -1;
463 time_t repaired_t0 = -1 - t0;
464 approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
465 diff = approx_biennia - approx_requested_biennia;
466 approx_abs_diff = diff < 0 ? -1 - diff : diff;
467 if (overflow_threshold < approx_abs_diff)
468 return -1;
469 guessed_offset += repaired_t0 - t0;
470 t0 = repaired_t0;
471 } 419 }
472 }
473
474 /* Repeatedly use the error to improve the guess. */
475 420
476 for (t = t1 = t2 = t0, dst2 = 0; 421 t1 = t2, t2 = t, t += dt, dst2 = tm.tm_isdst != 0;
477 (gt = guess_time_tm (year, yday, hour, min, sec, &t, 422 }
478 ranged_convert (convert, &t, &tm)),
479 t != gt);
480 t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
481 if (t == t1 && t != t2
482 && (tm.tm_isdst < 0
483 || (isdst < 0
484 ? dst2 <= (tm.tm_isdst != 0)
485 : (isdst != 0) != (tm.tm_isdst != 0))))
486 /* We can't possibly find a match, as we are oscillating
487 between two values. The requested time probably falls
488 within a spring-forward gap of size GT - T. Follow the common
489 practice in this case, which is to return a time that is GT - T
490 away from the requested time, preferring a time whose
491 tm_isdst differs from the requested value. (If no tm_isdst
492 was requested and only one of the two values has a nonzero
493 tm_isdst, prefer that value.) In practice, this is more
494 useful than returning -1. */
495 goto offset_found;
496 else if (--remaining_probes == 0)
497 return -1;
498 423
499 /* We have a match. Check whether tm.tm_isdst has the requested 424 /* We have a match. Check whether tm.tm_isdst has the requested
500 value, if any. */ 425 value, if any. */
@@ -504,8 +429,13 @@ __mktime_internal (struct tm *tp,
504 time with the right value, and use its UTC offset. 429 time with the right value, and use its UTC offset.
505 430
506 Heuristic: probe the adjacent timestamps in both directions, 431 Heuristic: probe the adjacent timestamps in both directions,
507 looking for the desired isdst. This should work for all real 432 looking for the desired isdst. If none is found within a
508 time zone histories in the tz database. */ 433 reasonable duration bound, assume a one-hour DST difference.
434 This should work for all real time zone histories in the tz
435 database. */
436
437 /* +1 if we wanted standard time but got DST, -1 if the reverse. */
438 int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
509 439
510 /* Distance between probes when looking for a DST boundary. In 440 /* Distance between probes when looking for a DST boundary. In
511 tzdata2003a, the shortest period of DST is 601200 seconds 441 tzdata2003a, the shortest period of DST is 601200 seconds
@@ -516,12 +446,14 @@ __mktime_internal (struct tm *tp,
516 periods when probing. */ 446 periods when probing. */
517 int stride = 601200; 447 int stride = 601200;
518 448
519 /* The longest period of DST in tzdata2003a is 536454000 seconds 449 /* In TZDB 2021e, the longest period of DST (or of non-DST), in
520 (e.g., America/Jujuy starting 1946-10-01 01:00). The longest 450 which the DST (or adjacent DST) difference is not one hour,
521 period of non-DST is much longer, but it makes no real sense 451 is 457243209 seconds: e.g., America/Cambridge_Bay with leap
522 to search for more than a year of non-DST, so use the DST 452 seconds, starting 1965-10-31 00:00 in a switch from
523 max. */ 453 double-daylight time (-05) to standard time (-07), and
524 int duration_max = 536454000; 454 continuing to 1980-04-27 02:00 in a switch from standard time
455 (-07) to daylight time (-06). */
456 int duration_max = 457243209;
525 457
526 /* Search in both directions, so the maximum distance is half 458 /* Search in both directions, so the maximum distance is half
527 the duration; add the stride to avoid off-by-1 problems. */ 459 the duration; add the stride to avoid off-by-1 problems. */
@@ -531,211 +463,116 @@ __mktime_internal (struct tm *tp,
531 463
532 for (delta = stride; delta < delta_bound; delta += stride) 464 for (delta = stride; delta < delta_bound; delta += stride)
533 for (direction = -1; direction <= 1; direction += 2) 465 for (direction = -1; direction <= 1; direction += 2)
534 if (time_t_int_add_ok (t, delta * direction)) 466 {
535 { 467 long_int ot;
536 time_t ot = t + delta * direction; 468 if (! INT_ADD_WRAPV (t, delta * direction, &ot))
537 struct tm otm; 469 {
538 ranged_convert (convert, &ot, &otm); 470 struct tm otm;
539 if (! isdst_differ (isdst, otm.tm_isdst)) 471 if (! ranged_convert (convert, &ot, &otm))
540 { 472 return -1;
541 /* We found the desired tm_isdst. 473 if (! isdst_differ (isdst, otm.tm_isdst))
542 Extrapolate back to the desired time. */ 474 {
543 t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); 475 /* We found the desired tm_isdst.
544 ranged_convert (convert, &t, &tm); 476 Extrapolate back to the desired time. */
545 goto offset_found; 477 long_int gt = ot + tm_diff (year, yday, hour, min, sec,
546 } 478 &otm);
547 } 479 if (mktime_min <= gt && gt <= mktime_max)
480 {
481 if (convert_time (convert, gt, &tm))
482 {
483 t = gt;
484 goto offset_found;
485 }
486 if (errno != EOVERFLOW)
487 return -1;
488 }
489 }
490 }
491 }
492
493 /* No unusual DST offset was found nearby. Assume one-hour DST. */
494 t += 60 * 60 * dst_difference;
495 if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
496 goto offset_found;
497
498 __set_errno (EOVERFLOW);
499 return -1;
548 } 500 }
549 501
550 offset_found: 502 offset_found:
551 *offset = guessed_offset + t - t0; 503 /* Set *OFFSET to the low-order bits of T - T0 - NEGATIVE_OFFSET_GUESS.
504 This is just a heuristic to speed up the next mktime call, and
505 correctness is unaffected if integer overflow occurs here. */
506 INT_SUBTRACT_WRAPV (t, t0, offset);
507 INT_SUBTRACT_WRAPV (*offset, negative_offset_guess, offset);
552 508
553 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) 509 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
554 { 510 {
555 /* Adjust time to reflect the tm_sec requested, not the normalized value. 511 /* Adjust time to reflect the tm_sec requested, not the normalized value.
556 Also, repair any damage from a false match due to a leap second. */ 512 Also, repair any damage from a false match due to a leap second. */
557 int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec; 513 long_int sec_adjustment = sec == 0 && tm.tm_sec == 60;
558 if (! time_t_int_add_ok (t, sec_requested)) 514 sec_adjustment -= sec;
559 return -1; 515 sec_adjustment += sec_requested;
560 t1 = t + sec_requested; 516 if (INT_ADD_WRAPV (t, sec_adjustment, &t)
561 if (! time_t_int_add_ok (t1, sec_adjustment)) 517 || ! (mktime_min <= t && t <= mktime_max))
562 return -1; 518 {
563 t2 = t1 + sec_adjustment; 519 __set_errno (EOVERFLOW);
564 if (! convert (&t2, &tm)) 520 return -1;
521 }
522 if (! convert_time (convert, t, &tm))
565 return -1; 523 return -1;
566 t = t2;
567 } 524 }
568 525
569 *tp = tm; 526 *tp = tm;
570 return t; 527 return t;
571} 528}
572 529
530#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_INTERNAL */
573 531
574/* FIXME: This should use a signed type wide enough to hold any UTC 532#if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS
575 offset in seconds. 'int' should be good enough for GNU code. We
576 can't fix this unilaterally though, as other modules invoke
577 __mktime_internal. */
578static time_t localtime_offset;
579 533
580/* Convert *TP to a time_t value. */ 534/* Convert *TP to a __time64_t value. */
581time_t 535__time64_t
582mktime (struct tm *tp) 536__mktime64 (struct tm *tp)
583{ 537{
584#ifdef _LIBC
585 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the 538 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the
586 time zone names contained in the external variable 'tzname' shall 539 time zone names contained in the external variable 'tzname' shall
587 be set as if the tzset() function had been called. */ 540 be set as if the tzset() function had been called. */
588 __tzset (); 541 __tzset ();
589#endif
590 542
591 return __mktime_internal (tp, __localtime_r, &localtime_offset); 543# if defined _LIBC || NEED_MKTIME_WORKING
544 static mktime_offset_t localtime_offset;
545 return __mktime_internal (tp, __localtime64_r, &localtime_offset);
546# else
547# undef mktime
548 return mktime (tp);
549# endif
592} 550}
551#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */
593 552
594#ifdef weak_alias 553#if defined _LIBC && __TIMESIZE != 64
595weak_alias (mktime, timelocal)
596#endif
597
598#ifdef _LIBC
599libc_hidden_def (mktime)
600libc_hidden_weak (timelocal)
601#endif
602
603#if DEBUG
604 554
605static int 555libc_hidden_def (__mktime64)
606not_equal_tm (const struct tm *a, const struct tm *b)
607{
608 return ((a->tm_sec ^ b->tm_sec)
609 | (a->tm_min ^ b->tm_min)
610 | (a->tm_hour ^ b->tm_hour)
611 | (a->tm_mday ^ b->tm_mday)
612 | (a->tm_mon ^ b->tm_mon)
613 | (a->tm_year ^ b->tm_year)
614 | (a->tm_yday ^ b->tm_yday)
615 | isdst_differ (a->tm_isdst, b->tm_isdst));
616}
617 556
618static void 557time_t
619print_tm (const struct tm *tp) 558mktime (struct tm *tp)
620{
621 if (tp)
622 printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
623 tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
624 tp->tm_hour, tp->tm_min, tp->tm_sec,
625 tp->tm_yday, tp->tm_wday, tp->tm_isdst);
626 else
627 printf ("0");
628}
629
630static int
631check_result (time_t tk, struct tm tmk, time_t tl, const struct tm *lt)
632{
633 if (tk != tl || !lt || not_equal_tm (&tmk, lt))
634 {
635 printf ("mktime (");
636 print_tm (lt);
637 printf (")\nyields (");
638 print_tm (&tmk);
639 printf (") == %ld, should be %ld\n", (long int) tk, (long int) tl);
640 return 1;
641 }
642
643 return 0;
644}
645
646int
647main (int argc, char **argv)
648{ 559{
649 int status = 0; 560 struct tm tm = *tp;
650 struct tm tm, tmk, tml; 561 __time64_t t = __mktime64 (&tm);
651 struct tm *lt; 562 if (in_time_t_range (t))
652 time_t tk, tl, tl1;
653 char trailer;
654
655 if ((argc == 3 || argc == 4)
656 && (sscanf (argv[1], "%d-%d-%d%c",
657 &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
658 == 3)
659 && (sscanf (argv[2], "%d:%d:%d%c",
660 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
661 == 3))
662 { 563 {
663 tm.tm_year -= TM_YEAR_BASE; 564 *tp = tm;
664 tm.tm_mon--; 565 return t;
665 tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]);
666 tmk = tm;
667 tl = mktime (&tmk);
668 lt = localtime (&tl);
669 if (lt)
670 {
671 tml = *lt;
672 lt = &tml;
673 }
674 printf ("mktime returns %ld == ", (long int) tl);
675 print_tm (&tmk);
676 printf ("\n");
677 status = check_result (tl, tmk, tl, lt);
678 } 566 }
679 else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0)) 567 else
680 { 568 {
681 time_t from = atol (argv[1]); 569 __set_errno (EOVERFLOW);
682 time_t by = atol (argv[2]); 570 return -1;
683 time_t to = atol (argv[3]);
684
685 if (argc == 4)
686 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
687 {
688 lt = localtime (&tl);
689 if (lt)
690 {
691 tmk = tml = *lt;
692 tk = mktime (&tmk);
693 status |= check_result (tk, tmk, tl, &tml);
694 }
695 else
696 {
697 printf ("localtime (%ld) yields 0\n", (long int) tl);
698 status = 1;
699 }
700 tl1 = tl + by;
701 if ((tl1 < tl) != (by < 0))
702 break;
703 }
704 else
705 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
706 {
707 /* Null benchmark. */
708 lt = localtime (&tl);
709 if (lt)
710 {
711 tmk = tml = *lt;
712 tk = tl;
713 status |= check_result (tk, tmk, tl, &tml);
714 }
715 else
716 {
717 printf ("localtime (%ld) yields 0\n", (long int) tl);
718 status = 1;
719 }
720 tl1 = tl + by;
721 if ((tl1 < tl) != (by < 0))
722 break;
723 }
724 } 571 }
725 else
726 printf ("Usage:\
727\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
728\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
729\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
730 argv[0], argv[0], argv[0]);
731
732 return status;
733} 572}
734 573
735#endif /* DEBUG */ 574#endif
736 575
737/* 576weak_alias (mktime, timelocal)
738Local Variables: 577libc_hidden_def (mktime)
739compile-command: "gcc -DDEBUG -I. -Wall -W -O2 -g mktime.c -o mktime" 578libc_hidden_weak (timelocal)
740End:
741*/
diff --git a/gl/mountlist.c b/gl/mountlist.c
index 30f4286..6d38481 100644
--- a/gl/mountlist.c
+++ b/gl/mountlist.c
@@ -1,10 +1,10 @@
1/* mountlist.c -- return a list of mounted file systems 1/* mountlist.c -- return a list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1997-2013 Free Software Foundation, Inc. 3 Copyright (C) 1991-1992, 1997-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -37,7 +37,13 @@
37# include <sys/param.h> 37# include <sys/param.h>
38#endif 38#endif
39 39
40#if defined MOUNTED_GETFSSTAT /* OSF_1 and Darwin1.3.x */ 40#if MAJOR_IN_MKDEV
41# include <sys/mkdev.h>
42#elif MAJOR_IN_SYSMACROS
43# include <sys/sysmacros.h>
44#endif
45
46#if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */
41# if HAVE_SYS_UCRED_H 47# if HAVE_SYS_UCRED_H
42# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS, 48# include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS,
43 NGROUPS is used as an array dimension in ucred.h */ 49 NGROUPS is used as an array dimension in ucred.h */
@@ -56,102 +62,104 @@
56# endif 62# endif
57#endif /* MOUNTED_GETFSSTAT */ 63#endif /* MOUNTED_GETFSSTAT */
58 64
59#ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ 65#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android,
66 also (obsolete) 4.3BSD, SunOS */
60# include <mntent.h> 67# include <mntent.h>
61# if !defined MOUNTED 68# include <sys/types.h>
69# if defined __ANDROID__ /* Android */
70 /* Bionic versions from between 2014-01-09 and 2015-01-08 define MOUNTED to
71 an incorrect value; older Bionic versions don't define it at all. */
72# undef MOUNTED
73# define MOUNTED "/proc/mounts"
74# elif !defined MOUNTED
62# if defined _PATH_MOUNTED /* GNU libc */ 75# if defined _PATH_MOUNTED /* GNU libc */
63# define MOUNTED _PATH_MOUNTED 76# define MOUNTED _PATH_MOUNTED
64# endif 77# endif
65# if defined MNT_MNTTAB /* HP-UX. */ 78# if defined MNT_MNTTAB /* HP-UX. */
66# define MOUNTED MNT_MNTTAB 79# define MOUNTED MNT_MNTTAB
67# endif 80# endif
68# if defined MNTTABNAME /* Dynix. */
69# define MOUNTED MNTTABNAME
70# endif
71# endif 81# endif
72#endif 82#endif
73 83
74#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ 84#ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
75# include <sys/mount.h> 85# include <sys/mount.h>
76#endif 86#endif
77 87
78#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ 88#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */
79# include <sys/statvfs.h> 89# include <sys/statvfs.h>
80#endif 90#endif
81 91
82#ifdef MOUNTED_GETMNT /* Ultrix. */ 92#ifdef MOUNTED_FS_STAT_DEV /* Haiku, also (obsolete) BeOS */
83# include <sys/mount.h>
84# include <sys/fs_types.h>
85#endif
86
87#ifdef MOUNTED_FS_STAT_DEV /* BeOS. */
88# include <fs_info.h> 93# include <fs_info.h>
89# include <dirent.h> 94# include <dirent.h>
90#endif 95#endif
91 96
92#ifdef MOUNTED_FREAD /* SVR2. */ 97#ifdef MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */
93# include <mnttab.h>
94#endif
95
96#ifdef MOUNTED_FREAD_FSTYP /* SVR3. */
97# include <mnttab.h> 98# include <mnttab.h>
98# include <sys/fstyp.h> 99# include <sys/fstyp.h>
99# include <sys/statfs.h> 100# include <sys/statfs.h>
100#endif 101#endif
101 102
102#ifdef MOUNTED_LISTMNTENT 103#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
103# include <mntent.h> 104# include <sys/mnttab.h>
104#endif 105#endif
105 106
106#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ 107#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
107# include <sys/mnttab.h> 108# include <sys/mnttab.h>
108#endif 109#endif
109 110
110#ifdef MOUNTED_VMOUNT /* AIX. */ 111#ifdef MOUNTED_VMOUNT /* AIX */
111# include <fshelp.h> 112# include <fshelp.h>
112# include <sys/vfs.h> 113# include <sys/vfs.h>
113#endif 114#endif
114 115
115#ifdef MOUNTED_INTERIX_STATVFS /* Interix. */ 116#ifdef MOUNTED_INTERIX_STATVFS /* Interix */
116# include <sys/statvfs.h> 117# include <sys/statvfs.h>
117# include <dirent.h> 118# include <dirent.h>
118#endif 119#endif
119 120
120#ifdef DOLPHIN
121/* So special that it's not worth putting this in autoconf. */
122# undef MOUNTED_FREAD_FSTYP
123# define MOUNTED_GETMNTTBL
124#endif
125
126#if HAVE_SYS_MNTENT_H 121#if HAVE_SYS_MNTENT_H
127/* This is to get MNTOPT_IGNORE on e.g. SVR4. */ 122/* This is to get MNTOPT_IGNORE on e.g. SVR4. */
128# include <sys/mntent.h> 123# include <sys/mntent.h>
129#endif 124#endif
130 125
126#ifdef MOUNTED_GETMNTENT1
127# if !HAVE_SETMNTENT /* Android <= 4.4 */
128# define setmntent(fp,mode) fopen (fp, mode "e")
129# endif
130# if !HAVE_ENDMNTENT /* Android <= 4.4 */
131# define endmntent(fp) fclose (fp)
132# endif
133#endif
134
131#ifndef HAVE_HASMNTOPT 135#ifndef HAVE_HASMNTOPT
132# define hasmntopt(mnt, opt) ((char *) 0) 136# define hasmntopt(mnt, opt) ((char *) 0)
133#endif 137#endif
134 138
135#undef MNT_IGNORE 139#undef MNT_IGNORE
136#ifdef MNTOPT_IGNORE 140#ifdef MNTOPT_IGNORE
137# define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE) 141# if defined __sun && defined __SVR4
142/* Solaris defines hasmntopt(struct mnttab *, char *)
143 while it is otherwise hasmntopt(struct mnttab *, const char *). */
144# define MNT_IGNORE(M) hasmntopt (M, (char *) MNTOPT_IGNORE)
145# else
146# define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE)
147# endif
138#else 148#else
139# define MNT_IGNORE(M) 0 149# define MNT_IGNORE(M) 0
140#endif 150#endif
141 151
142#if USE_UNLOCKED_IO 152/* Each of the FILE streams in this file is only used in a single thread. */
143# include "unlocked-io.h" 153#include "unlocked-io.h"
144#endif
145
146/* The results of open() in this file are not used with fchdir,
147 therefore save some unnecessary work in fchdir.c. */
148#undef open
149#undef close
150 154
151/* The results of opendir() in this file are not used with dirfd and fchdir, 155/* The results of opendir() in this file are not used with dirfd and fchdir,
152 therefore save some unnecessary work in fchdir.c. */ 156 therefore save some unnecessary work in fchdir.c. */
153#undef opendir 157#ifdef GNULIB_defined_opendir
154#undef closedir 158# undef opendir
159#endif
160#ifdef GNULIB_defined_closedir
161# undef closedir
162#endif
155 163
156#define ME_DUMMY_0(Fs_name, Fs_type) \ 164#define ME_DUMMY_0(Fs_name, Fs_type) \
157 (strcmp (Fs_type, "autofs") == 0 \ 165 (strcmp (Fs_type, "autofs") == 0 \
@@ -161,6 +169,7 @@
161 || strcmp (Fs_type, "debugfs") == 0 \ 169 || strcmp (Fs_type, "debugfs") == 0 \
162 || strcmp (Fs_type, "devpts") == 0 \ 170 || strcmp (Fs_type, "devpts") == 0 \
163 || strcmp (Fs_type, "fusectl") == 0 \ 171 || strcmp (Fs_type, "fusectl") == 0 \
172 || strcmp (Fs_type, "fuse.portal") == 0 \
164 || strcmp (Fs_type, "mqueue") == 0 \ 173 || strcmp (Fs_type, "mqueue") == 0 \
165 || strcmp (Fs_type, "rpc_pipefs") == 0 \ 174 || strcmp (Fs_type, "rpc_pipefs") == 0 \
166 || strcmp (Fs_type, "sysfs") == 0 \ 175 || strcmp (Fs_type, "sysfs") == 0 \
@@ -176,10 +185,9 @@
176 we grant an exception to any with "bind" in its list of mount options. 185 we grant an exception to any with "bind" in its list of mount options.
177 I.e., those are *not* dummy entries. */ 186 I.e., those are *not* dummy entries. */
178#ifdef MOUNTED_GETMNTENT1 187#ifdef MOUNTED_GETMNTENT1
179# define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \ 188# define ME_DUMMY(Fs_name, Fs_type, Bind) \
180 (ME_DUMMY_0 (Fs_name, Fs_type) \ 189 (ME_DUMMY_0 (Fs_name, Fs_type) \
181 || (strcmp (Fs_type, "none") == 0 \ 190 || (strcmp (Fs_type, "none") == 0 && !Bind))
182 && !hasmntopt (Fs_ent, "bind")))
183#else 191#else
184# define ME_DUMMY(Fs_name, Fs_type) \ 192# define ME_DUMMY(Fs_name, Fs_type) \
185 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0) 193 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
@@ -187,11 +195,14 @@
187 195
188#ifdef __CYGWIN__ 196#ifdef __CYGWIN__
189# include <windows.h> 197# include <windows.h>
198/* Don't assume that UNICODE is not defined. */
199# undef GetDriveType
200# define GetDriveType GetDriveTypeA
190# define ME_REMOTE me_remote 201# define ME_REMOTE me_remote
191/* All cygwin mount points include ':' or start with '//'; so it 202/* All cygwin mount points include ':' or start with '//'; so it
192 requires a native Windows call to determine remote disks. */ 203 requires a native Windows call to determine remote disks. */
193static bool 204static bool
194me_remote (char const *fs_name, char const *fs_type _GL_UNUSED) 205me_remote (char const *fs_name, _GL_UNUSED char const *fs_type)
195{ 206{
196 if (fs_name[0] && fs_name[1] == ':') 207 if (fs_name[0] && fs_name[1] == ':')
197 { 208 {
@@ -212,16 +223,30 @@ me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
212 223
213#ifndef ME_REMOTE 224#ifndef ME_REMOTE
214/* A file system is "remote" if its Fs_name contains a ':' 225/* A file system is "remote" if its Fs_name contains a ':'
215 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//'). */ 226 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//')
227 or if it is of any other of the listed types
228 or Fs_name is equal to "-hosts" (used by autofs to mount remote fs).
229 "VM" file systems like prl_fs or vboxsf are not considered remote here. */
216# define ME_REMOTE(Fs_name, Fs_type) \ 230# define ME_REMOTE(Fs_name, Fs_type) \
217 (strchr (Fs_name, ':') != NULL \ 231 (strchr (Fs_name, ':') != NULL \
218 || ((Fs_name)[0] == '/' \ 232 || ((Fs_name)[0] == '/' \
219 && (Fs_name)[1] == '/' \ 233 && (Fs_name)[1] == '/' \
220 && (strcmp (Fs_type, "smbfs") == 0 \ 234 && (strcmp (Fs_type, "smbfs") == 0 \
221 || strcmp (Fs_type, "cifs") == 0))) 235 || strcmp (Fs_type, "smb3") == 0 \
236 || strcmp (Fs_type, "cifs") == 0)) \
237 || strcmp (Fs_type, "acfs") == 0 \
238 || strcmp (Fs_type, "afs") == 0 \
239 || strcmp (Fs_type, "coda") == 0 \
240 || strcmp (Fs_type, "auristorfs") == 0 \
241 || strcmp (Fs_type, "fhgfs") == 0 \
242 || strcmp (Fs_type, "gpfs") == 0 \
243 || strcmp (Fs_type, "ibrix") == 0 \
244 || strcmp (Fs_type, "ocfs2") == 0 \
245 || strcmp (Fs_type, "vxfs") == 0 \
246 || strcmp ("-hosts", Fs_name) == 0)
222#endif 247#endif
223 248
224#if MOUNTED_GETMNTINFO 249#if MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
225 250
226# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME 251# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME
227static char * 252static char *
@@ -331,7 +356,7 @@ fsp_to_string (const struct statfs *fsp)
331 356
332#endif /* MOUNTED_GETMNTINFO */ 357#endif /* MOUNTED_GETMNTINFO */
333 358
334#ifdef MOUNTED_VMOUNT /* AIX. */ 359#ifdef MOUNTED_VMOUNT /* AIX */
335static char * 360static char *
336fstype_to_string (int t) 361fstype_to_string (int t)
337{ 362{
@@ -382,6 +407,46 @@ dev_from_mount_options (char const *mount_options)
382 407
383#endif 408#endif
384 409
410#if defined MOUNTED_GETMNTENT1 && (defined __linux__ || defined __ANDROID__) /* GNU/Linux, Android */
411
412/* Unescape the paths in mount tables.
413 STR is updated in place. */
414
415static void
416unescape_tab (char *str)
417{
418 size_t i, j = 0;
419 size_t len = strlen (str) + 1;
420 for (i = 0; i < len; i++)
421 {
422 if (str[i] == '\\' && (i + 4 < len)
423 && str[i + 1] >= '0' && str[i + 1] <= '3'
424 && str[i + 2] >= '0' && str[i + 2] <= '7'
425 && str[i + 3] >= '0' && str[i + 3] <= '7')
426 {
427 str[j++] = (str[i + 1] - '0') * 64 +
428 (str[i + 2] - '0') * 8 +
429 (str[i + 3] - '0');
430 i += 3;
431 }
432 else
433 str[j++] = str[i];
434 }
435}
436
437/* Find the next space in STR, terminate the string there in place,
438 and return that position. Otherwise return NULL. */
439
440static char *
441terminate_at_blank (char *str)
442{
443 char *s = strchr (str, ' ');
444 if (s)
445 *s = '\0';
446 return s;
447}
448#endif
449
385/* Return a list of the currently mounted file systems, or NULL on error. 450/* Return a list of the currently mounted file systems, or NULL on error.
386 Add each entry to the tail of the list so that they stay in order. 451 Add each entry to the tail of the list so that they stay in order.
387 If NEED_FS_TYPE is true, ensure that the file system type fields in 452 If NEED_FS_TYPE is true, ensure that the file system type fields in
@@ -395,69 +460,141 @@ read_file_system_list (bool need_fs_type)
395 struct mount_entry **mtail = &mount_list; 460 struct mount_entry **mtail = &mount_list;
396 (void) need_fs_type; 461 (void) need_fs_type;
397 462
398#ifdef MOUNTED_LISTMNTENT 463#ifdef MOUNTED_GETMNTENT1 /* glibc, HP-UX, IRIX, Cygwin, Android,
464 also (obsolete) 4.3BSD, SunOS */
399 { 465 {
400 struct tabmntent *mntlist, *p; 466 FILE *fp;
401 struct mntent *mnt;
402 struct mount_entry *me;
403
404 /* the third and fourth arguments could be used to filter mounts,
405 but Crays doesn't seem to have any mounts that we want to
406 remove. Specifically, automount create normal NFS mounts.
407 */
408 467
409 if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0) 468# if defined __linux__ || defined __ANDROID__
410 return NULL; 469 /* Try parsing mountinfo first, as that make device IDs available.
411 for (p = mntlist; p; p = p->next) 470 Note we could use libmount routines to simplify this parsing a little
471 (and that code is in previous versions of this function), however
472 libmount depends on libselinux which pulls in many dependencies. */
473 char const *mountinfo = "/proc/self/mountinfo";
474 fp = fopen (mountinfo, "re");
475 if (fp != NULL)
412 { 476 {
413 mnt = p->ment; 477 char *line = NULL;
414 me = xmalloc (sizeof *me); 478 size_t buf_size = 0;
415 me->me_devname = xstrdup (mnt->mnt_fsname);
416 me->me_mountdir = xstrdup (mnt->mnt_dir);
417 me->me_type = xstrdup (mnt->mnt_type);
418 me->me_type_malloced = 1;
419 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
420 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
421 me->me_dev = -1;
422 *mtail = me;
423 mtail = &me->me_next;
424 }
425 freemntlist (mntlist);
426 }
427#endif
428 479
429#ifdef MOUNTED_GETMNTENT1 /* GNU/Linux, 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ 480 while (getline (&line, &buf_size, fp) != -1)
430 { 481 {
431 struct mntent *mnt; 482 unsigned int devmaj, devmin;
432 char const *table = MOUNTED; 483 int rc, mntroot_s;
433 FILE *fp;
434 484
435 fp = setmntent (table, "r"); 485 rc = sscanf(line, "%*u " /* id - discarded */
436 if (fp == NULL) 486 "%*u " /* parent - discarded */
437 return NULL; 487 "%u:%u " /* dev major:minor */
488 "%n", /* mountroot (start) */
489 &devmaj, &devmin,
490 &mntroot_s);
438 491
439 while ((mnt = getmntent (fp))) 492 if (rc != 2 && rc != 3) /* 3 if %n included in count. */
440 { 493 continue;
441 me = xmalloc (sizeof *me);
442 me->me_devname = xstrdup (mnt->mnt_fsname);
443 me->me_mountdir = xstrdup (mnt->mnt_dir);
444 me->me_type = xstrdup (mnt->mnt_type);
445 me->me_type_malloced = 1;
446 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, mnt);
447 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
448 me->me_dev = dev_from_mount_options (mnt->mnt_opts);
449 494
450 /* Add to the linked list. */ 495 /* find end of MNTROOT. */
451 *mtail = me; 496 char *mntroot = line + mntroot_s;
452 mtail = &me->me_next; 497 char *blank = terminate_at_blank (mntroot);
498 if (! blank)
499 continue;
500
501 /* find end of TARGET. */
502 char *target = blank + 1;
503 blank = terminate_at_blank (target);
504 if (! blank)
505 continue;
506
507 /* skip optional fields, terminated by " - " */
508 char *dash = strstr (blank + 1, " - ");
509 if (! dash)
510 continue;
511
512 /* advance past the " - " separator. */
513 char *fstype = dash + 3;
514 blank = terminate_at_blank (fstype);
515 if (! blank)
516 continue;
517
518 /* find end of SOURCE. */
519 char *source = blank + 1;
520 if (! terminate_at_blank (source))
521 continue;
522
523 /* manipulate the sub-strings in place. */
524 unescape_tab (source);
525 unescape_tab (target);
526 unescape_tab (mntroot);
527 unescape_tab (fstype);
528
529 me = xmalloc (sizeof *me);
530
531 me->me_devname = xstrdup (source);
532 me->me_mountdir = xstrdup (target);
533 me->me_mntroot = xstrdup (mntroot);
534 me->me_type = xstrdup (fstype);
535 me->me_type_malloced = 1;
536 me->me_dev = makedev (devmaj, devmin);
537 /* we pass "false" for the "Bind" option as that's only
538 significant when the Fs_type is "none" which will not be
539 the case when parsing "/proc/self/mountinfo", and only
540 applies for static /etc/mtab files. */
541 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, false);
542 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
543
544 /* Add to the linked list. */
545 *mtail = me;
546 mtail = &me->me_next;
547 }
548
549 free (line);
550
551 if (ferror (fp))
552 {
553 int saved_errno = errno;
554 fclose (fp);
555 errno = saved_errno;
556 goto free_then_fail;
557 }
558
559 if (fclose (fp) == EOF)
560 goto free_then_fail;
453 } 561 }
562 else /* fallback to /proc/self/mounts (/etc/mtab). */
563# endif /* __linux __ || __ANDROID__ */
564 {
565 struct mntent *mnt;
566 char const *table = MOUNTED;
454 567
455 if (endmntent (fp) == 0) 568 fp = setmntent (table, "r");
456 goto free_then_fail; 569 if (fp == NULL)
570 return NULL;
571
572 while ((mnt = getmntent (fp)))
573 {
574 bool bind = hasmntopt (mnt, "bind");
575
576 me = xmalloc (sizeof *me);
577 me->me_devname = xstrdup (mnt->mnt_fsname);
578 me->me_mountdir = xstrdup (mnt->mnt_dir);
579 me->me_mntroot = NULL;
580 me->me_type = xstrdup (mnt->mnt_type);
581 me->me_type_malloced = 1;
582 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, bind);
583 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
584 me->me_dev = dev_from_mount_options (mnt->mnt_opts);
585
586 /* Add to the linked list. */
587 *mtail = me;
588 mtail = &me->me_next;
589 }
590
591 if (endmntent (fp) == 0)
592 goto free_then_fail;
593 }
457 } 594 }
458#endif /* MOUNTED_GETMNTENT1. */ 595#endif /* MOUNTED_GETMNTENT1. */
459 596
460#ifdef MOUNTED_GETMNTINFO /* 4.4BSD. */ 597#ifdef MOUNTED_GETMNTINFO /* Mac OS X, FreeBSD, OpenBSD, also (obsolete) 4.4BSD */
461 { 598 {
462 struct statfs *fsp; 599 struct statfs *fsp;
463 int entries; 600 int entries;
@@ -472,6 +609,7 @@ read_file_system_list (bool need_fs_type)
472 me = xmalloc (sizeof *me); 609 me = xmalloc (sizeof *me);
473 me->me_devname = xstrdup (fsp->f_mntfromname); 610 me->me_devname = xstrdup (fsp->f_mntfromname);
474 me->me_mountdir = xstrdup (fsp->f_mntonname); 611 me->me_mountdir = xstrdup (fsp->f_mntonname);
612 me->me_mntroot = NULL;
475 me->me_type = fs_type; 613 me->me_type = fs_type;
476 me->me_type_malloced = 0; 614 me->me_type_malloced = 0;
477 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 615 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -485,7 +623,7 @@ read_file_system_list (bool need_fs_type)
485 } 623 }
486#endif /* MOUNTED_GETMNTINFO */ 624#endif /* MOUNTED_GETMNTINFO */
487 625
488#ifdef MOUNTED_GETMNTINFO2 /* NetBSD 3.0. */ 626#ifdef MOUNTED_GETMNTINFO2 /* NetBSD, Minix */
489 { 627 {
490 struct statvfs *fsp; 628 struct statvfs *fsp;
491 int entries; 629 int entries;
@@ -498,6 +636,7 @@ read_file_system_list (bool need_fs_type)
498 me = xmalloc (sizeof *me); 636 me = xmalloc (sizeof *me);
499 me->me_devname = xstrdup (fsp->f_mntfromname); 637 me->me_devname = xstrdup (fsp->f_mntfromname);
500 me->me_mountdir = xstrdup (fsp->f_mntonname); 638 me->me_mountdir = xstrdup (fsp->f_mntonname);
639 me->me_mntroot = NULL;
501 me->me_type = xstrdup (fsp->f_fstypename); 640 me->me_type = xstrdup (fsp->f_fstypename);
502 me->me_type_malloced = 1; 641 me->me_type_malloced = 1;
503 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 642 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -511,35 +650,7 @@ read_file_system_list (bool need_fs_type)
511 } 650 }
512#endif /* MOUNTED_GETMNTINFO2 */ 651#endif /* MOUNTED_GETMNTINFO2 */
513 652
514#ifdef MOUNTED_GETMNT /* Ultrix. */ 653#if defined MOUNTED_FS_STAT_DEV /* Haiku, also (obsolete) BeOS */
515 {
516 int offset = 0;
517 int val;
518 struct fs_data fsd;
519
520 while (errno = 0,
521 0 < (val = getmnt (&offset, &fsd, sizeof (fsd), NOSTAT_MANY,
522 (char *) 0)))
523 {
524 me = xmalloc (sizeof *me);
525 me->me_devname = xstrdup (fsd.fd_req.devname);
526 me->me_mountdir = xstrdup (fsd.fd_req.path);
527 me->me_type = gt_names[fsd.fd_req.fstype];
528 me->me_type_malloced = 0;
529 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
530 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
531 me->me_dev = fsd.fd_req.dev;
532
533 /* Add to the linked list. */
534 *mtail = me;
535 mtail = &me->me_next;
536 }
537 if (val < 0)
538 goto free_then_fail;
539 }
540#endif /* MOUNTED_GETMNT. */
541
542#if defined MOUNTED_FS_STAT_DEV /* BeOS */
543 { 654 {
544 /* The next_dev() and fs_stat_dev() system calls give the list of 655 /* The next_dev() and fs_stat_dev() system calls give the list of
545 all file systems, including the information returned by statvfs() 656 all file systems, including the information returned by statvfs()
@@ -622,6 +733,7 @@ read_file_system_list (bool need_fs_type)
622 me->me_devname = xstrdup (fi.device_name[0] != '\0' 733 me->me_devname = xstrdup (fi.device_name[0] != '\0'
623 ? fi.device_name : fi.fsh_name); 734 ? fi.device_name : fi.fsh_name);
624 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); 735 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
736 me->me_mntroot = NULL;
625 me->me_type = xstrdup (fi.fsh_name); 737 me->me_type = xstrdup (fi.fsh_name);
626 me->me_type_malloced = 1; 738 me->me_type_malloced = 1;
627 me->me_dev = fi.dev; 739 me->me_dev = fi.dev;
@@ -644,7 +756,7 @@ read_file_system_list (bool need_fs_type)
644 } 756 }
645#endif /* MOUNTED_FS_STAT_DEV */ 757#endif /* MOUNTED_FS_STAT_DEV */
646 758
647#if defined MOUNTED_GETFSSTAT /* __alpha running OSF_1 */ 759#if defined MOUNTED_GETFSSTAT /* OSF/1, also (obsolete) Apple Darwin 1.3 */
648 { 760 {
649 int numsys, counter; 761 int numsys, counter;
650 size_t bufsize; 762 size_t bufsize;
@@ -671,6 +783,7 @@ read_file_system_list (bool need_fs_type)
671 me = xmalloc (sizeof *me); 783 me = xmalloc (sizeof *me);
672 me->me_devname = xstrdup (stats[counter].f_mntfromname); 784 me->me_devname = xstrdup (stats[counter].f_mntfromname);
673 me->me_mountdir = xstrdup (stats[counter].f_mntonname); 785 me->me_mountdir = xstrdup (stats[counter].f_mntonname);
786 me->me_mntroot = NULL;
674 me->me_type = xstrdup (FS_TYPE (stats[counter])); 787 me->me_type = xstrdup (FS_TYPE (stats[counter]));
675 me->me_type_malloced = 1; 788 me->me_type_malloced = 1;
676 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 789 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -686,31 +799,25 @@ read_file_system_list (bool need_fs_type)
686 } 799 }
687#endif /* MOUNTED_GETFSSTAT */ 800#endif /* MOUNTED_GETFSSTAT */
688 801
689#if defined MOUNTED_FREAD || defined MOUNTED_FREAD_FSTYP /* SVR[23]. */ 802#if defined MOUNTED_FREAD_FSTYP /* (obsolete) SVR3 */
690 { 803 {
691 struct mnttab mnt; 804 struct mnttab mnt;
692 char *table = "/etc/mnttab"; 805 char *table = "/etc/mnttab";
693 FILE *fp; 806 FILE *fp;
694 807
695 fp = fopen (table, "r"); 808 fp = fopen (table, "re");
696 if (fp == NULL) 809 if (fp == NULL)
697 return NULL; 810 return NULL;
698 811
699 while (fread (&mnt, sizeof mnt, 1, fp) > 0) 812 while (fread (&mnt, sizeof mnt, 1, fp) > 0)
700 { 813 {
701 me = xmalloc (sizeof *me); 814 me = xmalloc (sizeof *me);
702# ifdef GETFSTYP /* SVR3. */
703 me->me_devname = xstrdup (mnt.mt_dev); 815 me->me_devname = xstrdup (mnt.mt_dev);
704# else
705 me->me_devname = xmalloc (strlen (mnt.mt_dev) + 6);
706 strcpy (me->me_devname, "/dev/");
707 strcpy (me->me_devname + 5, mnt.mt_dev);
708# endif
709 me->me_mountdir = xstrdup (mnt.mt_filsys); 816 me->me_mountdir = xstrdup (mnt.mt_filsys);
817 me->me_mntroot = NULL;
710 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 818 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
711 me->me_type = ""; 819 me->me_type = "";
712 me->me_type_malloced = 0; 820 me->me_type_malloced = 0;
713# ifdef GETFSTYP /* SVR3. */
714 if (need_fs_type) 821 if (need_fs_type)
715 { 822 {
716 struct statfs fsd; 823 struct statfs fsd;
@@ -723,7 +830,6 @@ read_file_system_list (bool need_fs_type)
723 me->me_type_malloced = 1; 830 me->me_type_malloced = 1;
724 } 831 }
725 } 832 }
726# endif
727 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 833 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
728 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 834 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
729 835
@@ -744,34 +850,57 @@ read_file_system_list (bool need_fs_type)
744 if (fclose (fp) == EOF) 850 if (fclose (fp) == EOF)
745 goto free_then_fail; 851 goto free_then_fail;
746 } 852 }
747#endif /* MOUNTED_FREAD || MOUNTED_FREAD_FSTYP. */ 853#endif /* MOUNTED_FREAD_FSTYP. */
748 854
749#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ 855#ifdef MOUNTED_GETEXTMNTENT /* Solaris >= 8 */
750 { 856 {
751 struct mntent **mnttbl = getmnttbl (), **ent; 857 struct extmnttab mnt;
752 for (ent = mnttbl; *ent; ent++) 858 const char *table = MNTTAB;
859 FILE *fp;
860 int ret;
861
862 /* No locking is needed, because the contents of /etc/mnttab is generated
863 by the kernel. */
864
865 errno = 0;
866 fp = fopen (table, "re");
867 if (fp == NULL)
868 ret = errno;
869 else
753 { 870 {
754 me = xmalloc (sizeof *me); 871 while ((ret = getextmntent (fp, &mnt, 1)) == 0)
755 me->me_devname = xstrdup ((*ent)->mt_resource); 872 {
756 me->me_mountdir = xstrdup ((*ent)->mt_directory); 873 me = xmalloc (sizeof *me);
757 me->me_type = xstrdup ((*ent)->mt_fstype); 874 me->me_devname = xstrdup (mnt.mnt_special);
758 me->me_type_malloced = 1; 875 me->me_mountdir = xstrdup (mnt.mnt_mountp);
759 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 876 me->me_mntroot = NULL;
760 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 877 me->me_type = xstrdup (mnt.mnt_fstype);
761 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ 878 me->me_type_malloced = 1;
879 me->me_dummy = MNT_IGNORE (&mnt) != 0;
880 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
881 me->me_dev = makedev (mnt.mnt_major, mnt.mnt_minor);
762 882
763 /* Add to the linked list. */ 883 /* Add to the linked list. */
764 *mtail = me; 884 *mtail = me;
765 mtail = &me->me_next; 885 mtail = &me->me_next;
886 }
887
888 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
889 /* Here ret = -1 means success, ret >= 0 means failure. */
890 }
891
892 if (0 <= ret)
893 {
894 errno = ret;
895 goto free_then_fail;
766 } 896 }
767 endmnttbl ();
768 } 897 }
769#endif 898#endif /* MOUNTED_GETEXTMNTENT */
770 899
771#ifdef MOUNTED_GETMNTENT2 /* SVR4. */ 900#ifdef MOUNTED_GETMNTENT2 /* Solaris < 8, also (obsolete) SVR4 */
772 { 901 {
773 struct mnttab mnt; 902 struct mnttab mnt;
774 char *table = MNTTAB; 903 const char *table = MNTTAB;
775 FILE *fp; 904 FILE *fp;
776 int ret; 905 int ret;
777 int lockfd = -1; 906 int lockfd = -1;
@@ -784,7 +913,7 @@ read_file_system_list (bool need_fs_type)
784# ifndef MNTTAB_LOCK 913# ifndef MNTTAB_LOCK
785# define MNTTAB_LOCK "/etc/.mnttab.lock" 914# define MNTTAB_LOCK "/etc/.mnttab.lock"
786# endif 915# endif
787 lockfd = open (MNTTAB_LOCK, O_RDONLY); 916 lockfd = open (MNTTAB_LOCK, O_RDONLY | O_CLOEXEC);
788 if (0 <= lockfd) 917 if (0 <= lockfd)
789 { 918 {
790 struct flock flock; 919 struct flock flock;
@@ -806,7 +935,7 @@ read_file_system_list (bool need_fs_type)
806# endif 935# endif
807 936
808 errno = 0; 937 errno = 0;
809 fp = fopen (table, "r"); 938 fp = fopen (table, "re");
810 if (fp == NULL) 939 if (fp == NULL)
811 ret = errno; 940 ret = errno;
812 else 941 else
@@ -816,6 +945,7 @@ read_file_system_list (bool need_fs_type)
816 me = xmalloc (sizeof *me); 945 me = xmalloc (sizeof *me);
817 me->me_devname = xstrdup (mnt.mnt_special); 946 me->me_devname = xstrdup (mnt.mnt_special);
818 me->me_mountdir = xstrdup (mnt.mnt_mountp); 947 me->me_mountdir = xstrdup (mnt.mnt_mountp);
948 me->me_mntroot = NULL;
819 me->me_type = xstrdup (mnt.mnt_fstype); 949 me->me_type = xstrdup (mnt.mnt_fstype);
820 me->me_type_malloced = 1; 950 me->me_type_malloced = 1;
821 me->me_dummy = MNT_IGNORE (&mnt) != 0; 951 me->me_dummy = MNT_IGNORE (&mnt) != 0;
@@ -828,6 +958,7 @@ read_file_system_list (bool need_fs_type)
828 } 958 }
829 959
830 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1; 960 ret = fclose (fp) == EOF ? errno : 0 < ret ? 0 : -1;
961 /* Here ret = -1 means success, ret >= 0 means failure. */
831 } 962 }
832 963
833 if (0 <= lockfd && close (lockfd) != 0) 964 if (0 <= lockfd && close (lockfd) != 0)
@@ -841,26 +972,26 @@ read_file_system_list (bool need_fs_type)
841 } 972 }
842#endif /* MOUNTED_GETMNTENT2. */ 973#endif /* MOUNTED_GETMNTENT2. */
843 974
844#ifdef MOUNTED_VMOUNT /* AIX. */ 975#ifdef MOUNTED_VMOUNT /* AIX */
845 { 976 {
846 int bufsize; 977 int bufsize;
847 char *entries, *thisent; 978 void *entries;
979 char *thisent;
848 struct vmount *vmp; 980 struct vmount *vmp;
849 int n_entries; 981 int n_entries;
850 int i; 982 int i;
851 983
852 /* Ask how many bytes to allocate for the mounted file system info. */ 984 /* Ask how many bytes to allocate for the mounted file system info. */
853 if (mntctl (MCTL_QUERY, sizeof bufsize, (struct vmount *) &bufsize) != 0) 985 entries = &bufsize;
986 if (mntctl (MCTL_QUERY, sizeof bufsize, entries) != 0)
854 return NULL; 987 return NULL;
855 entries = xmalloc (bufsize); 988 entries = xmalloc (bufsize);
856 989
857 /* Get the list of mounted file systems. */ 990 /* Get the list of mounted file systems. */
858 n_entries = mntctl (MCTL_QUERY, bufsize, (struct vmount *) entries); 991 n_entries = mntctl (MCTL_QUERY, bufsize, entries);
859 if (n_entries < 0) 992 if (n_entries < 0)
860 { 993 {
861 int saved_errno = errno;
862 free (entries); 994 free (entries);
863 errno = saved_errno;
864 return NULL; 995 return NULL;
865 } 996 }
866 997
@@ -892,6 +1023,7 @@ read_file_system_list (bool need_fs_type)
892 vmp->vmt_data[VMT_OBJECT].vmt_off); 1023 vmp->vmt_data[VMT_OBJECT].vmt_off);
893 } 1024 }
894 me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off); 1025 me->me_mountdir = xstrdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
1026 me->me_mntroot = NULL;
895 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype)); 1027 me->me_type = xstrdup (fstype_to_string (vmp->vmt_gfstype));
896 me->me_type_malloced = 1; 1028 me->me_type_malloced = 1;
897 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off; 1029 options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
@@ -910,7 +1042,7 @@ read_file_system_list (bool need_fs_type)
910 } 1042 }
911#endif /* MOUNTED_VMOUNT. */ 1043#endif /* MOUNTED_VMOUNT. */
912 1044
913#ifdef MOUNTED_INTERIX_STATVFS 1045#ifdef MOUNTED_INTERIX_STATVFS /* Interix */
914 { 1046 {
915 DIR *dirp = opendir ("/dev/fs"); 1047 DIR *dirp = opendir ("/dev/fs");
916 char node[9 + NAME_MAX]; 1048 char node[9 + NAME_MAX];
@@ -924,6 +1056,8 @@ read_file_system_list (bool need_fs_type)
924 struct dirent entry; 1056 struct dirent entry;
925 struct dirent *result; 1057 struct dirent *result;
926 1058
1059 /* FIXME: readdir_r is planned to be withdrawn from POSIX and
1060 marked obsolescent in glibc. Use readdir instead. */
927 if (readdir_r (dirp, &entry, &result) || result == NULL) 1061 if (readdir_r (dirp, &entry, &result) || result == NULL)
928 break; 1062 break;
929 1063
@@ -935,6 +1069,7 @@ read_file_system_list (bool need_fs_type)
935 me = xmalloc (sizeof *me); 1069 me = xmalloc (sizeof *me);
936 me->me_devname = xstrdup (dev.f_mntfromname); 1070 me->me_devname = xstrdup (dev.f_mntfromname);
937 me->me_mountdir = xstrdup (dev.f_mntonname); 1071 me->me_mountdir = xstrdup (dev.f_mntonname);
1072 me->me_mntroot = NULL;
938 me->me_type = xstrdup (dev.f_fstypename); 1073 me->me_type = xstrdup (dev.f_fstypename);
939 me->me_type_malloced = 1; 1074 me->me_type_malloced = 1;
940 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 1075 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -946,6 +1081,7 @@ read_file_system_list (bool need_fs_type)
946 mtail = &me->me_next; 1081 mtail = &me->me_next;
947 } 1082 }
948 } 1083 }
1084 closedir (dirp);
949 } 1085 }
950#endif /* MOUNTED_INTERIX_STATVFS */ 1086#endif /* MOUNTED_INTERIX_STATVFS */
951 1087
@@ -953,7 +1089,7 @@ read_file_system_list (bool need_fs_type)
953 return mount_list; 1089 return mount_list;
954 1090
955 1091
956 free_then_fail: 1092 free_then_fail: _GL_UNUSED_LABEL;
957 { 1093 {
958 int saved_errno = errno; 1094 int saved_errno = errno;
959 *mtail = NULL; 1095 *mtail = NULL;
@@ -972,10 +1108,12 @@ read_file_system_list (bool need_fs_type)
972 1108
973/* Free a mount entry as returned from read_file_system_list (). */ 1109/* Free a mount entry as returned from read_file_system_list (). */
974 1110
975void free_mount_entry (struct mount_entry *me) 1111void
1112free_mount_entry (struct mount_entry *me)
976{ 1113{
977 free (me->me_devname); 1114 free (me->me_devname);
978 free (me->me_mountdir); 1115 free (me->me_mountdir);
1116 free (me->me_mntroot);
979 if (me->me_type_malloced) 1117 if (me->me_type_malloced)
980 free (me->me_type); 1118 free (me->me_type);
981 free (me); 1119 free (me);
diff --git a/gl/mountlist.h b/gl/mountlist.h
index 55877e2..aed7f88 100644
--- a/gl/mountlist.h
+++ b/gl/mountlist.h
@@ -1,11 +1,11 @@
1/* mountlist.h -- declarations for list of mounted file systems 1/* mountlist.h -- declarations for list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2013 Free Software 3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,12 +14,11 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#ifndef MOUNTLIST_H_ 19#ifndef MOUNTLIST_H_
20# define MOUNTLIST_H_ 20# define MOUNTLIST_H_
21 21
22# include <stdbool.h>
23# include <sys/types.h> 22# include <sys/types.h>
24 23
25/* A mount table entry. */ 24/* A mount table entry. */
@@ -27,15 +26,18 @@ struct mount_entry
27{ 26{
28 char *me_devname; /* Device node name, including "/dev/". */ 27 char *me_devname; /* Device node name, including "/dev/". */
29 char *me_mountdir; /* Mount point directory name. */ 28 char *me_mountdir; /* Mount point directory name. */
29 char *me_mntroot; /* Directory on filesystem of device used */
30 /* as root for the (bind) mount. */
30 char *me_type; /* "nfs", "4.2", etc. */ 31 char *me_type; /* "nfs", "4.2", etc. */
31 dev_t me_dev; /* Device number of me_mountdir. */ 32 dev_t me_dev; /* Device number of me_mountdir. */
32 unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */ 33 unsigned int me_dummy : 1; /* Nonzero for dummy file systems. */
33 unsigned int me_remote : 1; /* Nonzero for remote fileystems. */ 34 unsigned int me_remote : 1; /* Nonzero for remote file systems. */
34 unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */ 35 unsigned int me_type_malloced : 1; /* Nonzero if me_type was malloced. */
35 struct mount_entry *me_next; 36 struct mount_entry *me_next;
36}; 37};
37 38
38struct mount_entry *read_file_system_list (bool need_fs_type); 39struct mount_entry *read_file_system_list (bool need_fs_type)
40 _GL_ATTRIBUTE_MALLOC;
39void free_mount_entry (struct mount_entry *entry); 41void free_mount_entry (struct mount_entry *entry);
40 42
41#endif 43#endif
diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c
index 396031e..c5149a8 100644
--- a/gl/msvc-inval.c
+++ b/gl/msvc-inval.c
@@ -1,18 +1,18 @@
1/* Invalid parameter handler for MSVC runtime libraries. 1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h
index dcb0353..ed00461 100644
--- a/gl/msvc-inval.h
+++ b/gl/msvc-inval.h
@@ -1,18 +1,18 @@
1/* Invalid parameter handler for MSVC runtime libraries. 1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _MSVC_INVAL_H 17#ifndef _MSVC_INVAL_H
18#define _MSVC_INVAL_H 18#define _MSVC_INVAL_H
@@ -95,7 +95,7 @@ extern void gl_msvc_inval_ensure_handler (void);
95 95
96/* Gnulib can define its own status codes, as described in the page 96/* Gnulib can define its own status codes, as described in the page
97 "Raising Software Exceptions" on microsoft.com 97 "Raising Software Exceptions" on microsoft.com
98 <http://msdn.microsoft.com/en-us/library/het71c37.aspx>. 98 <https://docs.microsoft.com/en-us/cpp/cpp/raising-software-exceptions>.
99 Our status codes are composed of 99 Our status codes are composed of
100 - 0xE0000000, mandatory for all user-defined status codes, 100 - 0xE0000000, mandatory for all user-defined status codes,
101 - 0x474E550, a API identifier ("GNU"), 101 - 0x474E550, a API identifier ("GNU"),
@@ -106,7 +106,7 @@ extern void gl_msvc_inval_ensure_handler (void);
106# if defined _MSC_VER 106# if defined _MSC_VER
107/* A compiler that supports __try/__except, as described in the page 107/* A compiler that supports __try/__except, as described in the page
108 "try-except statement" on microsoft.com 108 "try-except statement" on microsoft.com
109 <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>. 109 <https://docs.microsoft.com/en-us/cpp/cpp/try-except-statement>.
110 With __try/__except, we can use the multithread-safe exception handling. */ 110 With __try/__except, we can use the multithread-safe exception handling. */
111 111
112# ifdef __cplusplus 112# ifdef __cplusplus
diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c
index 8d65472..f729fe6 100644
--- a/gl/msvc-nothrow.c
+++ b/gl/msvc-nothrow.c
@@ -1,19 +1,19 @@
1/* Wrappers that don't throw invalid parameter notifications 1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries. 2 with MSVC runtime libraries.
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -24,7 +24,9 @@
24#define WIN32_LEAN_AND_MEAN 24#define WIN32_LEAN_AND_MEAN
25#include <windows.h> 25#include <windows.h>
26 26
27#include "msvc-inval.h" 27#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
28# include "msvc-inval.h"
29#endif
28 30
29#undef _get_osfhandle 31#undef _get_osfhandle
30 32
diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h
index 5f52181..82d3f6a 100644
--- a/gl/msvc-nothrow.h
+++ b/gl/msvc-nothrow.h
@@ -1,19 +1,19 @@
1/* Wrappers that don't throw invalid parameter notifications 1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries. 2 with MSVC runtime libraries.
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _MSVC_NOTHROW_H 18#ifndef _MSVC_NOTHROW_H
19#define _MSVC_NOTHROW_H 19#define _MSVC_NOTHROW_H
@@ -25,7 +25,7 @@
25 This file defines wrappers that turn such an invalid parameter notification 25 This file defines wrappers that turn such an invalid parameter notification
26 into an error code. */ 26 into an error code. */
27 27
28#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 28#if defined _WIN32 && ! defined __CYGWIN__
29 29
30/* Get original declaration of _get_osfhandle. */ 30/* Get original declaration of _get_osfhandle. */
31# include <io.h> 31# include <io.h>
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
index 0da1800..9549cd7 100644
--- a/gl/netdb.in.h
+++ b/gl/netdb.in.h
@@ -1,19 +1,19 @@
1/* Provide a netdb.h header file for systems lacking it (read: MinGW). 1/* Provide a netdb.h header file for systems lacking it (read: MinGW).
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* This file is supposed to be used on platforms that lack <netdb.h>. 18/* This file is supposed to be used on platforms that lack <netdb.h>.
19 It is intended to provide definitions and prototypes needed by an 19 It is intended to provide definitions and prototypes needed by an
@@ -158,33 +158,61 @@ struct addrinfo
158# endif 158# endif
159# endif 159# endif
160 160
161# if !@HAVE_DECL_GETADDRINFO@
162/* Translate name of a service location and/or a service name to set of 161/* Translate name of a service location and/or a service name to set of
163 socket addresses. 162 socket addresses.
164 For more details, see the POSIX:2001 specification 163 For more details, see the POSIX:2008 specification
165 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ 164 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>. */
165# if @REPLACE_GETADDRINFO@
166# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167# undef getaddrinfo
168# define getaddrinfo rpl_getaddrinfo
169# endif
170_GL_FUNCDECL_RPL (getaddrinfo, int,
171 (const char *restrict nodename,
172 const char *restrict servname,
173 const struct addrinfo *restrict hints,
174 struct addrinfo **restrict res)
175 _GL_ARG_NONNULL ((4)));
176_GL_CXXALIAS_RPL (getaddrinfo, int,
177 (const char *restrict nodename,
178 const char *restrict servname,
179 const struct addrinfo *restrict hints,
180 struct addrinfo **restrict res));
181# else
182# if !@HAVE_DECL_GETADDRINFO@
166_GL_FUNCDECL_SYS (getaddrinfo, int, 183_GL_FUNCDECL_SYS (getaddrinfo, int,
167 (const char *restrict nodename, 184 (const char *restrict nodename,
168 const char *restrict servname, 185 const char *restrict servname,
169 const struct addrinfo *restrict hints, 186 const struct addrinfo *restrict hints,
170 struct addrinfo **restrict res) 187 struct addrinfo **restrict res)
171 _GL_ARG_NONNULL ((4))); 188 _GL_ARG_NONNULL ((4)));
172# endif 189# endif
173_GL_CXXALIAS_SYS (getaddrinfo, int, 190_GL_CXXALIAS_SYS (getaddrinfo, int,
174 (const char *restrict nodename, 191 (const char *restrict nodename,
175 const char *restrict servname, 192 const char *restrict servname,
176 const struct addrinfo *restrict hints, 193 const struct addrinfo *restrict hints,
177 struct addrinfo **restrict res)); 194 struct addrinfo **restrict res));
195# endif
178_GL_CXXALIASWARN (getaddrinfo); 196_GL_CXXALIASWARN (getaddrinfo);
179 197
180# if !@HAVE_DECL_FREEADDRINFO@
181/* Free 'addrinfo' structure AI including associated storage. 198/* Free 'addrinfo' structure AI including associated storage.
182 For more details, see the POSIX:2001 specification 199 For more details, see the POSIX:2008 specification
183 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ 200 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>. */
201# if @REPLACE_GETADDRINFO@
202# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
203# undef freeaddrinfo
204# define freeaddrinfo rpl_freeaddrinfo
205# endif
206_GL_FUNCDECL_RPL (freeaddrinfo, void, (struct addrinfo *ai)
207 _GL_ARG_NONNULL ((1)));
208_GL_CXXALIAS_RPL (freeaddrinfo, void, (struct addrinfo *ai));
209# else
210# if !@HAVE_DECL_FREEADDRINFO@
184_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai) 211_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai)
185 _GL_ARG_NONNULL ((1))); 212 _GL_ARG_NONNULL ((1)));
186# endif 213# endif
187_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai)); 214_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai));
215# endif
188_GL_CXXALIASWARN (freeaddrinfo); 216_GL_CXXALIASWARN (freeaddrinfo);
189 217
190# if @REPLACE_GAI_STRERROR@ 218# if @REPLACE_GAI_STRERROR@
@@ -197,18 +225,20 @@ _GL_CXXALIAS_RPL (gai_strerror, const char *, (int ecode));
197# else 225# else
198# if !@HAVE_DECL_GAI_STRERROR@ 226# if !@HAVE_DECL_GAI_STRERROR@
199/* Convert error return from getaddrinfo() to a string. 227/* Convert error return from getaddrinfo() to a string.
200 For more details, see the POSIX:2001 specification 228 For more details, see the POSIX:2008 specification
201 <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */ 229 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html>. */
202_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode)); 230_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode));
203# endif 231# endif
204_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode)); 232_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode));
205# endif 233# endif
234# if __GLIBC__ >= 2
206_GL_CXXALIASWARN (gai_strerror); 235_GL_CXXALIASWARN (gai_strerror);
236# endif
207 237
208# if !@HAVE_DECL_GETNAMEINFO@ 238# if !@HAVE_DECL_GETNAMEINFO@
209/* Convert socket address to printable node and service names. 239/* Convert socket address to printable node and service names.
210 For more details, see the POSIX:2001 specification 240 For more details, see the POSIX:2008 specification
211 <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */ 241 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html>. */
212_GL_FUNCDECL_SYS (getnameinfo, int, 242_GL_FUNCDECL_SYS (getnameinfo, int,
213 (const struct sockaddr *restrict sa, socklen_t salen, 243 (const struct sockaddr *restrict sa, socklen_t salen,
214 char *restrict node, socklen_t nodelen, 244 char *restrict node, socklen_t nodelen,
diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h
index b456c4f..f88923a 100644
--- a/gl/netinet_in.in.h
+++ b/gl/netinet_in.in.h
@@ -1,18 +1,18 @@
1/* Substitute for <netinet/in.h>. 1/* Substitute for <netinet/in.h>.
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. 2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _@GUARD_PREFIX@_NETINET_IN_H 17#ifndef _@GUARD_PREFIX@_NETINET_IN_H
18 18
diff --git a/gl/nl_langinfo-lock.c b/gl/nl_langinfo-lock.c
new file mode 100644
index 0000000..e5cdcd3
--- /dev/null
+++ b/gl/nl_langinfo-lock.c
@@ -0,0 +1,150 @@
1/* Return the internal lock used by nl_langinfo.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019-2020. */
18
19#include <config.h>
20
21/* When it is known that the gl_get_nl_langinfo_lock function is defined
22 by a dependency library, it should not be defined here. */
23#if OMIT_NL_LANGINFO_LOCK
24
25/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */
27typedef int dummy;
28
29#else
30
31/* This file defines the internal lock used by nl_langinfo.
32 It is a separate compilation unit, so that only one copy of it is
33 present when linking statically. */
34
35/* Prohibit renaming this symbol. */
36# undef gl_get_nl_langinfo_lock
37
38/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */
40# ifndef DLL_EXPORTED
41# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport)
46# else
47# define DLL_EXPORTED
48# endif
49# endif
50
51# if defined _WIN32 && !defined __CYGWIN__
52
53# define WIN32_LEAN_AND_MEAN /* avoid including junk */
54# include <windows.h>
55
56# include "windows-initguard.h"
57
58/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
59 because the latter is not guaranteed to be a stable ABI in the future. */
60
61/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
63
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock;
66
67/* Returns the internal lock used by nl_langinfo. */
68CRITICAL_SECTION *
69gl_get_nl_langinfo_lock (void)
70{
71 if (!guard.done)
72 {
73 if (InterlockedIncrement (&guard.started) == 0)
74 {
75 /* This thread is the first one to need the lock. Initialize it. */
76 InitializeCriticalSection (&lock);
77 guard.done = 1;
78 }
79 else
80 {
81 /* Don't let guard.started grow and wrap around. */
82 InterlockedDecrement (&guard.started);
83 /* Yield the CPU while waiting for another thread to finish
84 initializing this mutex. */
85 while (!guard.done)
86 Sleep (0);
87 }
88 }
89 return &lock;
90}
91
92# elif HAVE_PTHREAD_API
93
94# include <pthread.h>
95
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97
98/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_nl_langinfo_lock (void);
100
101/* Returns the internal lock used by nl_langinfo. */
102pthread_mutex_t *
103gl_get_nl_langinfo_lock (void)
104{
105 return &mutex;
106}
107
108# elif HAVE_THREADS_H
109
110# include <threads.h>
111# include <stdlib.h>
112
113static int volatile init_needed = 1;
114static once_flag init_once = ONCE_FLAG_INIT;
115static mtx_t mutex;
116
117static void
118atomic_init (void)
119{
120 if (mtx_init (&mutex, mtx_plain) != thrd_success)
121 abort ();
122 init_needed = 0;
123}
124
125/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_nl_langinfo_lock (void);
127
128/* Returns the internal lock used by nl_langinfo. */
129mtx_t *
130gl_get_nl_langinfo_lock (void)
131{
132 if (init_needed)
133 call_once (&init_once, atomic_init);
134 return &mutex;
135}
136
137# endif
138
139# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
140/* Make sure the '__declspec(dllimport)' in nl_langinfo.c does not cause
141 a link failure when no DLLs are involved. */
142# if defined _WIN64 || defined _LP64
143# define IMP(x) __imp_##x
144# else
145# define IMP(x) _imp__##x
146# endif
147void * IMP(gl_get_nl_langinfo_lock) = &gl_get_nl_langinfo_lock;
148# endif
149
150#endif
diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c
index 771c953..131166f 100644
--- a/gl/nl_langinfo.c
+++ b/gl/nl_langinfo.c
@@ -1,34 +1,278 @@
1/* nl_langinfo() replacement: query locale dependent information. 1/* nl_langinfo() replacement: query locale dependent information.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
20/* Specification. */ 20/* Specification. */
21#include <langinfo.h> 21#include <langinfo.h>
22 22
23#include <locale.h>
24#include <stdlib.h>
25#include <string.h>
26#if defined _WIN32 && ! defined __CYGWIN__
27# define WIN32_LEAN_AND_MEAN /* avoid including junk */
28# include <windows.h>
29# include <stdio.h>
30#endif
31
32#if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE
33# if defined _WIN32 && !defined __CYGWIN__
34
35# define WIN32_LEAN_AND_MEAN /* avoid including junk */
36# include <windows.h>
37
38# elif HAVE_PTHREAD_API
39
40# include <pthread.h>
41# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
42# include <threads.h>
43# pragma weak thrd_exit
44# define c11_threads_in_use() (thrd_exit != NULL)
45# else
46# define c11_threads_in_use() 0
47# endif
48
49# elif HAVE_THREADS_H
50
51# include <threads.h>
52
53# endif
54#endif
55
56/* nl_langinfo() must be multithread-safe. To achieve this without using
57 thread-local storage:
58 1. We use a specific static buffer for each possible argument.
59 So that different threads can call nl_langinfo with different arguments,
60 without interfering.
61 2. We use a simple strcpy or memcpy to fill this static buffer. Filling it
62 through, for example, strcpy + strcat would not be guaranteed to leave
63 the buffer's contents intact if another thread is currently accessing
64 it. If necessary, the contents is first assembled in a stack-allocated
65 buffer. */
66
67#if !REPLACE_NL_LANGINFO || GNULIB_defined_CODESET
68/* Return the codeset of the current locale, if this is easily deducible.
69 Otherwise, return "". */
70static char *
71ctype_codeset (void)
72{
73 static char result[2 + 10 + 1];
74 char buf[2 + 10 + 1];
75 char locale[SETLOCALE_NULL_MAX];
76 char *codeset;
77 size_t codesetlen;
78
79 if (setlocale_null_r (LC_CTYPE, locale, sizeof (locale)))
80 locale[0] = '\0';
81
82 codeset = buf;
83 codeset[0] = '\0';
84
85 if (locale[0])
86 {
87 /* If the locale name contains an encoding after the dot, return it. */
88 char *dot = strchr (locale, '.');
89
90 if (dot)
91 {
92 /* Look for the possible @... trailer and remove it, if any. */
93 char *codeset_start = dot + 1;
94 char const *modifier = strchr (codeset_start, '@');
95
96 if (! modifier)
97 codeset = codeset_start;
98 else
99 {
100 codesetlen = modifier - codeset_start;
101 if (codesetlen < sizeof buf)
102 {
103 codeset = memcpy (buf, codeset_start, codesetlen);
104 codeset[codesetlen] = '\0';
105 }
106 }
107 }
108 }
109
110# if defined _WIN32 && ! defined __CYGWIN__
111 /* If setlocale is successful, it returns the number of the
112 codepage, as a string. Otherwise, fall back on Windows API
113 GetACP, which returns the locale's codepage as a number (although
114 this doesn't change according to what the 'setlocale' call specified).
115 Either way, prepend "CP" to make it a valid codeset name. */
116 codesetlen = strlen (codeset);
117 if (0 < codesetlen && codesetlen < sizeof buf - 2)
118 memmove (buf + 2, codeset, codesetlen + 1);
119 else
120 sprintf (buf + 2, "%u", GetACP ());
121 /* For a locale name such as "French_France.65001", in Windows 10,
122 setlocale now returns "French_France.utf8" instead. */
123 if (strcmp (buf + 2, "65001") == 0 || strcmp (buf + 2, "utf8") == 0)
124 return (char *) "UTF-8";
125 else
126 {
127 memcpy (buf, "CP", 2);
128 strcpy (result, buf);
129 return result;
130 }
131# else
132 strcpy (result, codeset);
133 return result;
134#endif
135}
136#endif
137
138
23#if REPLACE_NL_LANGINFO 139#if REPLACE_NL_LANGINFO
24 140
25/* Override nl_langinfo with support for added nl_item values. */ 141/* Override nl_langinfo with support for added nl_item values. */
26 142
27# include <locale.h>
28# include <string.h>
29
30# undef nl_langinfo 143# undef nl_langinfo
31 144
145/* Without locking, on Solaris 11.3, test-nl_langinfo-mt fails, with message
146 "thread5 disturbed by threadN!", even when threadN invokes only
147 nl_langinfo (CODESET);
148 nl_langinfo (CRNCYSTR);
149 Similarly on Solaris 10. */
150
151# if !NL_LANGINFO_MTSAFE /* Solaris */
152
153# define ITEMS (MAXSTRMSG + 1)
154# define MAX_RESULT_LEN 80
155
156static char *
157nl_langinfo_unlocked (nl_item item)
158{
159 static char result[ITEMS][MAX_RESULT_LEN];
160
161 /* The result of nl_langinfo is in storage that can be overwritten by
162 other calls to nl_langinfo. */
163 char *tmp = nl_langinfo (item);
164 if (item >= 0 && item < ITEMS && tmp != NULL)
165 {
166 size_t tmp_len = strlen (tmp);
167 if (tmp_len < MAX_RESULT_LEN)
168 strcpy (result[item], tmp);
169 else
170 {
171 /* Produce a truncated result. Oh well... */
172 result[item][MAX_RESULT_LEN - 1] = '\0';
173 memcpy (result[item], tmp, MAX_RESULT_LEN - 1);
174 }
175 return result[item];
176 }
177 else
178 return tmp;
179}
180
181/* Use a lock, so that no two threads can invoke nl_langinfo_unlocked
182 at the same time. */
183
184/* Prohibit renaming this symbol. */
185# undef gl_get_nl_langinfo_lock
186
187# if defined _WIN32 && !defined __CYGWIN__
188
189extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
190
191static char *
192nl_langinfo_with_lock (nl_item item)
193{
194 CRITICAL_SECTION *lock = gl_get_nl_langinfo_lock ();
195 char *ret;
196
197 EnterCriticalSection (lock);
198 ret = nl_langinfo_unlocked (item);
199 LeaveCriticalSection (lock);
200
201 return ret;
202}
203
204# elif HAVE_PTHREAD_API
205
206extern
207# if defined _WIN32 || defined __CYGWIN__
208 __declspec(dllimport)
209# endif
210 pthread_mutex_t *gl_get_nl_langinfo_lock (void);
211
212# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */
213
214 /* Avoid the need to link with '-lpthread'. */
215# pragma weak pthread_mutex_lock
216# pragma weak pthread_mutex_unlock
217
218 /* Determine whether libpthread is in use. */
219# pragma weak pthread_mutexattr_gettype
220 /* See the comments in lock.h. */
221# define pthread_in_use() \
222 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
223
224# else
225# define pthread_in_use() 1
226# endif
227
228static char *
229nl_langinfo_with_lock (nl_item item)
230{
231 if (pthread_in_use())
232 {
233 pthread_mutex_t *lock = gl_get_nl_langinfo_lock ();
234 char *ret;
235
236 if (pthread_mutex_lock (lock))
237 abort ();
238 ret = nl_langinfo_unlocked (item);
239 if (pthread_mutex_unlock (lock))
240 abort ();
241
242 return ret;
243 }
244 else
245 return nl_langinfo_unlocked (item);
246}
247
248# elif HAVE_THREADS_H
249
250extern mtx_t *gl_get_nl_langinfo_lock (void);
251
252static char *
253nl_langinfo_with_lock (nl_item item)
254{
255 mtx_t *lock = gl_get_nl_langinfo_lock ();
256 char *ret;
257
258 if (mtx_lock (lock) != thrd_success)
259 abort ();
260 ret = nl_langinfo_unlocked (item);
261 if (mtx_unlock (lock) != thrd_success)
262 abort ();
263
264 return ret;
265}
266
267# endif
268
269# else
270
271/* On other platforms, no lock is needed. */
272# define nl_langinfo_with_lock nl_langinfo
273
274# endif
275
32char * 276char *
33rpl_nl_langinfo (nl_item item) 277rpl_nl_langinfo (nl_item item)
34{ 278{
@@ -36,47 +280,36 @@ rpl_nl_langinfo (nl_item item)
36 { 280 {
37# if GNULIB_defined_CODESET 281# if GNULIB_defined_CODESET
38 case CODESET: 282 case CODESET:
39 { 283 return ctype_codeset ();
40 const char *locale;
41 static char buf[2 + 10 + 1];
42
43 locale = setlocale (LC_CTYPE, NULL);
44 if (locale != NULL && locale[0] != '\0')
45 {
46 /* If the locale name contains an encoding after the dot, return
47 it. */
48 const char *dot = strchr (locale, '.');
49
50 if (dot != NULL)
51 {
52 const char *modifier;
53
54 dot++;
55 /* Look for the possible @... trailer and remove it, if any. */
56 modifier = strchr (dot, '@');
57 if (modifier == NULL)
58 return dot;
59 if (modifier - dot < sizeof (buf))
60 {
61 memcpy (buf, dot, modifier - dot);
62 buf [modifier - dot] = '\0';
63 return buf;
64 }
65 }
66 }
67 return "";
68 }
69# endif 284# endif
70# if GNULIB_defined_T_FMT_AMPM 285# if GNULIB_defined_T_FMT_AMPM
71 case T_FMT_AMPM: 286 case T_FMT_AMPM:
72 return "%I:%M:%S %p"; 287 return (char *) "%I:%M:%S %p";
288# endif
289# if GNULIB_defined_ALTMON
290 case ALTMON_1:
291 case ALTMON_2:
292 case ALTMON_3:
293 case ALTMON_4:
294 case ALTMON_5:
295 case ALTMON_6:
296 case ALTMON_7:
297 case ALTMON_8:
298 case ALTMON_9:
299 case ALTMON_10:
300 case ALTMON_11:
301 case ALTMON_12:
302 /* We don't ship the appropriate localizations with gnulib. Therefore,
303 treat ALTMON_i like MON_i. */
304 item = item - ALTMON_1 + MON_1;
305 break;
73# endif 306# endif
74# if GNULIB_defined_ERA 307# if GNULIB_defined_ERA
75 case ERA: 308 case ERA:
76 /* The format is not standardized. In glibc it is a sequence of strings 309 /* The format is not standardized. In glibc it is a sequence of strings
77 of the form "direction:offset:start_date:end_date:era_name:era_format" 310 of the form "direction:offset:start_date:end_date:era_name:era_format"
78 with an empty string at the end. */ 311 with an empty string at the end. */
79 return ""; 312 return (char *) "";
80 case ERA_D_FMT: 313 case ERA_D_FMT:
81 /* The %Ex conversion in strftime behaves like %x if the locale does not 314 /* The %Ex conversion in strftime behaves like %x if the locale does not
82 have an alternative time format. */ 315 have an alternative time format. */
@@ -95,176 +328,244 @@ rpl_nl_langinfo (nl_item item)
95 case ALT_DIGITS: 328 case ALT_DIGITS:
96 /* The format is not standardized. In glibc it is a sequence of 10 329 /* The format is not standardized. In glibc it is a sequence of 10
97 strings, appended in memory. */ 330 strings, appended in memory. */
98 return "\0\0\0\0\0\0\0\0\0\0"; 331 return (char *) "\0\0\0\0\0\0\0\0\0\0";
99# endif 332# endif
100# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS 333# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
101 case YESEXPR: 334 case YESEXPR:
102 return "^[yY]"; 335 return (char *) "^[yY]";
103 case NOEXPR: 336 case NOEXPR:
104 return "^[nN]"; 337 return (char *) "^[nN]";
105# endif 338# endif
106 default: 339 default:
107 break; 340 break;
108 } 341 }
109 return nl_langinfo (item); 342 return nl_langinfo_with_lock (item);
110} 343}
111 344
112#else 345#else
113 346
114/* Provide nl_langinfo from scratch. */ 347/* Provide nl_langinfo from scratch, either for native MS-Windows, or
115 348 for old Unix platforms without locales, such as Linux libc5 or
116# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 349 BeOS. */
117 350
118/* Native Windows platforms. */ 351# include <time.h>
119
120# define WIN32_LEAN_AND_MEAN /* avoid including junk */
121# include <windows.h>
122
123# include <stdio.h>
124
125# else
126
127/* An old Unix platform without locales, such as Linux libc5 or BeOS. */
128
129# endif
130
131# include <locale.h>
132 352
133char * 353char *
134nl_langinfo (nl_item item) 354nl_langinfo (nl_item item)
135{ 355{
356 char buf[100];
357 struct tm tmm = { 0 };
358
136 switch (item) 359 switch (item)
137 { 360 {
138 /* nl_langinfo items of the LC_CTYPE category */ 361 /* nl_langinfo items of the LC_CTYPE category */
139 case CODESET: 362 case CODESET:
140# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
141 { 363 {
142 static char buf[2 + 10 + 1]; 364 char *codeset = ctype_codeset ();
143 365 if (*codeset)
144 /* The Windows API has a function returning the locale's codepage as 366 return codeset;
145 a number. */
146 sprintf (buf, "CP%u", GetACP ());
147 return buf;
148 } 367 }
149# elif defined __BEOS__ 368# ifdef __BEOS__
150 return "UTF-8"; 369 return (char *) "UTF-8";
151# else 370# else
152 return "ISO-8859-1"; 371 return (char *) "ISO-8859-1";
153# endif 372# endif
154 /* nl_langinfo items of the LC_NUMERIC category */ 373 /* nl_langinfo items of the LC_NUMERIC category */
155 case RADIXCHAR: 374 case RADIXCHAR:
156 return localeconv () ->decimal_point; 375 return localeconv () ->decimal_point;
157 case THOUSEP: 376 case THOUSEP:
158 return localeconv () ->thousands_sep; 377 return localeconv () ->thousands_sep;
378# ifdef GROUPING
379 case GROUPING:
380 return localeconv () ->grouping;
381# endif
159 /* nl_langinfo items of the LC_TIME category. 382 /* nl_langinfo items of the LC_TIME category.
160 TODO: Really use the locale. */ 383 TODO: Really use the locale. */
161 case D_T_FMT: 384 case D_T_FMT:
162 case ERA_D_T_FMT: 385 case ERA_D_T_FMT:
163 return "%a %b %e %H:%M:%S %Y"; 386 return (char *) "%a %b %e %H:%M:%S %Y";
164 case D_FMT: 387 case D_FMT:
165 case ERA_D_FMT: 388 case ERA_D_FMT:
166 return "%m/%d/%y"; 389 return (char *) "%m/%d/%y";
167 case T_FMT: 390 case T_FMT:
168 case ERA_T_FMT: 391 case ERA_T_FMT:
169 return "%H:%M:%S"; 392 return (char *) "%H:%M:%S";
170 case T_FMT_AMPM: 393 case T_FMT_AMPM:
171 return "%I:%M:%S %p"; 394 return (char *) "%I:%M:%S %p";
172 case AM_STR: 395 case AM_STR:
173 return "AM"; 396 {
397 static char result[80];
398 if (!strftime (buf, sizeof result, "%p", &tmm))
399 return (char *) "AM";
400 strcpy (result, buf);
401 return result;
402 }
174 case PM_STR: 403 case PM_STR:
175 return "PM"; 404 {
405 static char result[80];
406 tmm.tm_hour = 12;
407 if (!strftime (buf, sizeof result, "%p", &tmm))
408 return (char *) "PM";
409 strcpy (result, buf);
410 return result;
411 }
176 case DAY_1: 412 case DAY_1:
177 return "Sunday";
178 case DAY_2: 413 case DAY_2:
179 return "Monday";
180 case DAY_3: 414 case DAY_3:
181 return "Tuesday";
182 case DAY_4: 415 case DAY_4:
183 return "Wednesday";
184 case DAY_5: 416 case DAY_5:
185 return "Thursday";
186 case DAY_6: 417 case DAY_6:
187 return "Friday";
188 case DAY_7: 418 case DAY_7:
189 return "Saturday"; 419 {
420 static char result[7][50];
421 static char const days[][sizeof "Wednesday"] = {
422 "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
423 "Friday", "Saturday"
424 };
425 tmm.tm_wday = item - DAY_1;
426 if (!strftime (buf, sizeof result[0], "%A", &tmm))
427 return (char *) days[item - DAY_1];
428 strcpy (result[item - DAY_1], buf);
429 return result[item - DAY_1];
430 }
190 case ABDAY_1: 431 case ABDAY_1:
191 return "Sun";
192 case ABDAY_2: 432 case ABDAY_2:
193 return "Mon";
194 case ABDAY_3: 433 case ABDAY_3:
195 return "Tue";
196 case ABDAY_4: 434 case ABDAY_4:
197 return "Wed";
198 case ABDAY_5: 435 case ABDAY_5:
199 return "Thu";
200 case ABDAY_6: 436 case ABDAY_6:
201 return "Fri";
202 case ABDAY_7: 437 case ABDAY_7:
203 return "Sat"; 438 {
204 case MON_1: 439 static char result[7][30];
205 return "January"; 440 static char const abdays[][sizeof "Sun"] = {
206 case MON_2: 441 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
207 return "February"; 442 };
208 case MON_3: 443 tmm.tm_wday = item - ABDAY_1;
209 return "March"; 444 if (!strftime (buf, sizeof result[0], "%a", &tmm))
210 case MON_4: 445 return (char *) abdays[item - ABDAY_1];
211 return "April"; 446 strcpy (result[item - ABDAY_1], buf);
212 case MON_5: 447 return result[item - ABDAY_1];
213 return "May"; 448 }
214 case MON_6: 449 {
215 return "June"; 450 static char const months[][sizeof "September"] = {
216 case MON_7: 451 "January", "February", "March", "April", "May", "June", "July",
217 return "July"; 452 "September", "October", "November", "December"
218 case MON_8: 453 };
219 return "August"; 454 case MON_1:
220 case MON_9: 455 case MON_2:
221 return "September"; 456 case MON_3:
222 case MON_10: 457 case MON_4:
223 return "October"; 458 case MON_5:
224 case MON_11: 459 case MON_6:
225 return "November"; 460 case MON_7:
226 case MON_12: 461 case MON_8:
227 return "December"; 462 case MON_9:
463 case MON_10:
464 case MON_11:
465 case MON_12:
466 {
467 static char result[12][50];
468 tmm.tm_mon = item - MON_1;
469 if (!strftime (buf, sizeof result[0], "%B", &tmm))
470 return (char *) months[item - MON_1];
471 strcpy (result[item - MON_1], buf);
472 return result[item - MON_1];
473 }
474 case ALTMON_1:
475 case ALTMON_2:
476 case ALTMON_3:
477 case ALTMON_4:
478 case ALTMON_5:
479 case ALTMON_6:
480 case ALTMON_7:
481 case ALTMON_8:
482 case ALTMON_9:
483 case ALTMON_10:
484 case ALTMON_11:
485 case ALTMON_12:
486 {
487 static char result[12][50];
488 tmm.tm_mon = item - ALTMON_1;
489 /* The platforms without nl_langinfo() don't support strftime with
490 %OB. We don't even need to try. */
491 #if 0
492 if (!strftime (buf, sizeof result[0], "%OB", &tmm))
493 #endif
494 if (!strftime (buf, sizeof result[0], "%B", &tmm))
495 return (char *) months[item - ALTMON_1];
496 strcpy (result[item - ALTMON_1], buf);
497 return result[item - ALTMON_1];
498 }
499 }
228 case ABMON_1: 500 case ABMON_1:
229 return "Jan";
230 case ABMON_2: 501 case ABMON_2:
231 return "Feb";
232 case ABMON_3: 502 case ABMON_3:
233 return "Mar";
234 case ABMON_4: 503 case ABMON_4:
235 return "Apr";
236 case ABMON_5: 504 case ABMON_5:
237 return "May";
238 case ABMON_6: 505 case ABMON_6:
239 return "Jun";
240 case ABMON_7: 506 case ABMON_7:
241 return "Jul";
242 case ABMON_8: 507 case ABMON_8:
243 return "Aug";
244 case ABMON_9: 508 case ABMON_9:
245 return "Sep";
246 case ABMON_10: 509 case ABMON_10:
247 return "Oct";
248 case ABMON_11: 510 case ABMON_11:
249 return "Nov";
250 case ABMON_12: 511 case ABMON_12:
251 return "Dec"; 512 {
513 static char result[12][30];
514 static char const abmonths[][sizeof "Jan"] = {
515 "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
516 "Sep", "Oct", "Nov", "Dec"
517 };
518 tmm.tm_mon = item - ABMON_1;
519 if (!strftime (buf, sizeof result[0], "%b", &tmm))
520 return (char *) abmonths[item - ABMON_1];
521 strcpy (result[item - ABMON_1], buf);
522 return result[item - ABMON_1];
523 }
252 case ERA: 524 case ERA:
253 return ""; 525 return (char *) "";
254 case ALT_DIGITS: 526 case ALT_DIGITS:
255 return "\0\0\0\0\0\0\0\0\0\0"; 527 return (char *) "\0\0\0\0\0\0\0\0\0\0";
256 /* nl_langinfo items of the LC_MONETARY category 528 /* nl_langinfo items of the LC_MONETARY category. */
257 TODO: Really use the locale. */
258 case CRNCYSTR: 529 case CRNCYSTR:
259 return "-"; 530 return localeconv () ->currency_symbol;
531# ifdef INT_CURR_SYMBOL
532 case INT_CURR_SYMBOL:
533 return localeconv () ->int_curr_symbol;
534 case MON_DECIMAL_POINT:
535 return localeconv () ->mon_decimal_point;
536 case MON_THOUSANDS_SEP:
537 return localeconv () ->mon_thousands_sep;
538 case MON_GROUPING:
539 return localeconv () ->mon_grouping;
540 case POSITIVE_SIGN:
541 return localeconv () ->positive_sign;
542 case NEGATIVE_SIGN:
543 return localeconv () ->negative_sign;
544 case FRAC_DIGITS:
545 return & localeconv () ->frac_digits;
546 case INT_FRAC_DIGITS:
547 return & localeconv () ->int_frac_digits;
548 case P_CS_PRECEDES:
549 return & localeconv () ->p_cs_precedes;
550 case N_CS_PRECEDES:
551 return & localeconv () ->n_cs_precedes;
552 case P_SEP_BY_SPACE:
553 return & localeconv () ->p_sep_by_space;
554 case N_SEP_BY_SPACE:
555 return & localeconv () ->n_sep_by_space;
556 case P_SIGN_POSN:
557 return & localeconv () ->p_sign_posn;
558 case N_SIGN_POSN:
559 return & localeconv () ->n_sign_posn;
560# endif
260 /* nl_langinfo items of the LC_MESSAGES category 561 /* nl_langinfo items of the LC_MESSAGES category
261 TODO: Really use the locale. */ 562 TODO: Really use the locale. */
262 case YESEXPR: 563 case YESEXPR:
263 return "^[yY]"; 564 return (char *) "^[yY]";
264 case NOEXPR: 565 case NOEXPR:
265 return "^[nN]"; 566 return (char *) "^[nN]";
266 default: 567 default:
267 return ""; 568 return (char *) "";
268 } 569 }
269} 570}
270 571
diff --git a/gl/open.c b/gl/open.c
new file mode 100644
index 0000000..7ec8fdc
--- /dev/null
+++ b/gl/open.c
@@ -0,0 +1,209 @@
1/* Open a descriptor to a file.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18
19/* If the user's config.h happens to include <fcntl.h>, let it include only
20 the system's <fcntl.h> here, so that orig_open doesn't recurse to
21 rpl_open. */
22#define __need_system_fcntl_h
23#include <config.h>
24
25/* Get the original definition of open. It might be defined as a macro. */
26#include <fcntl.h>
27#include <sys/types.h>
28#undef __need_system_fcntl_h
29
30static int
31orig_open (const char *filename, int flags, mode_t mode)
32{
33#if defined _WIN32 && !defined __CYGWIN__
34 return _open (filename, flags, mode);
35#else
36 return open (filename, flags, mode);
37#endif
38}
39
40/* Specification. */
41/* Write "fcntl.h" here, not <fcntl.h>, otherwise OSF/1 5.1 DTK cc eliminates
42 this include because of the preliminary #include <fcntl.h> above. */
43#include "fcntl.h"
44
45#include "cloexec.h"
46
47#include <errno.h>
48#include <stdarg.h>
49#include <string.h>
50#include <sys/types.h>
51#include <sys/stat.h>
52#include <unistd.h>
53
54#ifndef REPLACE_OPEN_DIRECTORY
55# define REPLACE_OPEN_DIRECTORY 0
56#endif
57
58int
59open (const char *filename, int flags, ...)
60{
61 /* 0 = unknown, 1 = yes, -1 = no. */
62#if GNULIB_defined_O_CLOEXEC
63 int have_cloexec = -1;
64#else
65 static int have_cloexec;
66#endif
67
68 mode_t mode;
69 int fd;
70
71 mode = 0;
72 if (flags & O_CREAT)
73 {
74 va_list arg;
75 va_start (arg, flags);
76
77 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
78 creates crashing code when 'mode_t' is smaller than 'int'. */
79 mode = va_arg (arg, PROMOTED_MODE_T);
80
81 va_end (arg);
82 }
83
84#if GNULIB_defined_O_NONBLOCK
85 /* The only known platform that lacks O_NONBLOCK is mingw, but it
86 also lacks named pipes and Unix sockets, which are the only two
87 file types that require non-blocking handling in open().
88 Therefore, it is safe to ignore O_NONBLOCK here. It is handy
89 that mingw also lacks openat(), so that is also covered here. */
90 flags &= ~O_NONBLOCK;
91#endif
92
93#if defined _WIN32 && ! defined __CYGWIN__
94 if (strcmp (filename, "/dev/null") == 0)
95 filename = "NUL";
96#endif
97
98#if OPEN_TRAILING_SLASH_BUG
99 /* Fail if one of O_CREAT, O_WRONLY, O_RDWR is specified and the filename
100 ends in a slash, as POSIX says such a filename must name a directory
101 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
102 "A pathname that contains at least one non-<slash> character and that
103 ends with one or more trailing <slash> characters shall not be resolved
104 successfully unless the last pathname component before the trailing
105 <slash> characters names an existing directory"
106 If the named file already exists as a directory, then
107 - if O_CREAT is specified, open() must fail because of the semantics
108 of O_CREAT,
109 - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
110 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html>
111 says that it fails with errno = EISDIR in this case.
112 If the named file does not exist or does not name a directory, then
113 - if O_CREAT is specified, open() must fail since open() cannot create
114 directories,
115 - if O_WRONLY or O_RDWR is specified, open() must fail because the
116 file does not contain a '.' directory. */
117 if ((flags & O_CREAT)
118 || (flags & O_ACCMODE) == O_RDWR
119 || (flags & O_ACCMODE) == O_WRONLY)
120 {
121 size_t len = strlen (filename);
122 if (len > 0 && filename[len - 1] == '/')
123 {
124 errno = EISDIR;
125 return -1;
126 }
127 }
128#endif
129
130 fd = orig_open (filename,
131 flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode);
132
133 if (flags & O_CLOEXEC)
134 {
135 if (! have_cloexec)
136 {
137 if (0 <= fd)
138 have_cloexec = 1;
139 else if (errno == EINVAL)
140 {
141 fd = orig_open (filename, flags & ~O_CLOEXEC, mode);
142 have_cloexec = -1;
143 }
144 }
145 if (have_cloexec < 0 && 0 <= fd)
146 set_cloexec_flag (fd, true);
147 }
148
149
150#if REPLACE_FCHDIR
151 /* Implementing fchdir and fdopendir requires the ability to open a
152 directory file descriptor. If open doesn't support that (as on
153 mingw), we use a dummy file that behaves the same as directories
154 on Linux (ie. always reports EOF on attempts to read()), and
155 override fstat() in fchdir.c to hide the fact that we have a
156 dummy. */
157 if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
158 && ((flags & O_ACCMODE) == O_RDONLY
159 || (O_SEARCH != O_RDONLY && (flags & O_ACCMODE) == O_SEARCH)))
160 {
161 struct stat statbuf;
162 if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
163 {
164 /* Maximum recursion depth of 1. */
165 fd = open ("/dev/null", flags, mode);
166 if (0 <= fd)
167 fd = _gl_register_fd (fd, filename);
168 }
169 else
170 errno = EACCES;
171 }
172#endif
173
174#if OPEN_TRAILING_SLASH_BUG
175 /* If the filename ends in a slash and fd does not refer to a directory,
176 then fail.
177 Rationale: POSIX says such a filename must name a directory
178 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>:
179 "A pathname that contains at least one non-<slash> character and that
180 ends with one or more trailing <slash> characters shall not be resolved
181 successfully unless the last pathname component before the trailing
182 <slash> characters names an existing directory"
183 If the named file without the slash is not a directory, open() must fail
184 with ENOTDIR. */
185 if (fd >= 0)
186 {
187 /* We know len is positive, since open did not fail with ENOENT. */
188 size_t len = strlen (filename);
189 if (filename[len - 1] == '/')
190 {
191 struct stat statbuf;
192
193 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
194 {
195 close (fd);
196 errno = ENOTDIR;
197 return -1;
198 }
199 }
200 }
201#endif
202
203#if REPLACE_FCHDIR
204 if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
205 fd = _gl_register_fd (fd, filename);
206#endif
207
208 return fd;
209}
diff --git a/gl/pathmax.h b/gl/pathmax.h
new file mode 100644
index 0000000..0dd8f3b
--- /dev/null
+++ b/gl/pathmax.h
@@ -0,0 +1,83 @@
1/* Define PATH_MAX somehow. Requires sys/types.h.
2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2023 Free Software
3 Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _PATHMAX_H
19# define _PATHMAX_H
20
21/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
22 including the terminating NUL byte.
23 <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
24 PATH_MAX is not defined on systems which have no limit on filename length,
25 such as GNU/Hurd.
26
27 This file does *not* define PATH_MAX always. Programs that use this file
28 can handle the GNU/Hurd case in several ways:
29 - Either with a package-wide handling, or with a per-file handling,
30 - Either through a
31 #ifdef PATH_MAX
32 or through a fallback like
33 #ifndef PATH_MAX
34 # define PATH_MAX 8192
35 #endif
36 or through a fallback like
37 #ifndef PATH_MAX
38 # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
39 #endif
40 */
41
42# include <unistd.h>
43
44# include <limits.h>
45
46# ifndef _POSIX_PATH_MAX
47# define _POSIX_PATH_MAX 256
48# endif
49
50/* Don't include sys/param.h if it already has been. */
51# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
52# include <sys/param.h>
53# endif
54
55# if !defined PATH_MAX && defined MAXPATHLEN
56# define PATH_MAX MAXPATHLEN
57# endif
58
59# ifdef __hpux
60/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
61 *not* including the terminating NUL byte, and is set to 1023.
62 Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
63 not defined at all any more. */
64# undef PATH_MAX
65# define PATH_MAX 1024
66# endif
67
68# if defined _WIN32 && ! defined __CYGWIN__
69/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
70 section "Maximum Path Length Limitation",
71 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation>
72 explains that the maximum size of a filename, including the terminating
73 NUL byte, is 260 = 3 + 256 + 1.
74 This is the same value as
75 - FILENAME_MAX in <stdio.h>,
76 - _MAX_PATH in <stdlib.h>,
77 - MAX_PATH in <windef.h>.
78 Undefine the original value, because mingw's <limits.h> gets it wrong. */
79# undef PATH_MAX
80# define PATH_MAX 260
81# endif
82
83#endif /* _PATHMAX_H */
diff --git a/gl/printf-args.c b/gl/printf-args.c
index c27e6bc..5e14f65 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,19 +1,19 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2013 Free Software 2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* This file can be parametrized with the following macros: 18/* This file can be parametrized with the following macros:
19 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. 19 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
@@ -65,14 +65,12 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
65 case TYPE_ULONGINT: 65 case TYPE_ULONGINT:
66 ap->a.a_ulongint = va_arg (args, unsigned long int); 66 ap->a.a_ulongint = va_arg (args, unsigned long int);
67 break; 67 break;
68#if HAVE_LONG_LONG_INT
69 case TYPE_LONGLONGINT: 68 case TYPE_LONGLONGINT:
70 ap->a.a_longlongint = va_arg (args, long long int); 69 ap->a.a_longlongint = va_arg (args, long long int);
71 break; 70 break;
72 case TYPE_ULONGLONGINT: 71 case TYPE_ULONGLONGINT:
73 ap->a.a_ulonglongint = va_arg (args, unsigned long long int); 72 ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
74 break; 73 break;
75#endif
76 case TYPE_DOUBLE: 74 case TYPE_DOUBLE:
77 ap->a.a_double = va_arg (args, double); 75 ap->a.a_double = va_arg (args, double);
78 break; 76 break;
@@ -135,11 +133,9 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
135 case TYPE_COUNT_LONGINT_POINTER: 133 case TYPE_COUNT_LONGINT_POINTER:
136 ap->a.a_count_longint_pointer = va_arg (args, long int *); 134 ap->a.a_count_longint_pointer = va_arg (args, long int *);
137 break; 135 break;
138#if HAVE_LONG_LONG_INT
139 case TYPE_COUNT_LONGLONGINT_POINTER: 136 case TYPE_COUNT_LONGLONGINT_POINTER:
140 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *); 137 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
141 break; 138 break;
142#endif
143#if ENABLE_UNISTDIO 139#if ENABLE_UNISTDIO
144 /* The unistdio extensions. */ 140 /* The unistdio extensions. */
145 case TYPE_U8_STRING: 141 case TYPE_U8_STRING:
diff --git a/gl/printf-args.h b/gl/printf-args.h
index 2a9c2a3..f303cb1 100644
--- a/gl/printf-args.h
+++ b/gl/printf-args.h
@@ -1,19 +1,19 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2013 Free Software 2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _PRINTF_ARGS_H 18#ifndef _PRINTF_ARGS_H
19#define _PRINTF_ARGS_H 19#define _PRINTF_ARGS_H
@@ -57,10 +57,8 @@ typedef enum
57 TYPE_UINT, 57 TYPE_UINT,
58 TYPE_LONGINT, 58 TYPE_LONGINT,
59 TYPE_ULONGINT, 59 TYPE_ULONGINT,
60#if HAVE_LONG_LONG_INT
61 TYPE_LONGLONGINT, 60 TYPE_LONGLONGINT,
62 TYPE_ULONGLONGINT, 61 TYPE_ULONGLONGINT,
63#endif
64 TYPE_DOUBLE, 62 TYPE_DOUBLE,
65 TYPE_LONGDOUBLE, 63 TYPE_LONGDOUBLE,
66 TYPE_CHAR, 64 TYPE_CHAR,
@@ -75,10 +73,8 @@ typedef enum
75 TYPE_COUNT_SCHAR_POINTER, 73 TYPE_COUNT_SCHAR_POINTER,
76 TYPE_COUNT_SHORT_POINTER, 74 TYPE_COUNT_SHORT_POINTER,
77 TYPE_COUNT_INT_POINTER, 75 TYPE_COUNT_INT_POINTER,
78 TYPE_COUNT_LONGINT_POINTER 76 TYPE_COUNT_LONGINT_POINTER,
79#if HAVE_LONG_LONG_INT 77 TYPE_COUNT_LONGLONGINT_POINTER
80, TYPE_COUNT_LONGLONGINT_POINTER
81#endif
82#if ENABLE_UNISTDIO 78#if ENABLE_UNISTDIO
83 /* The unistdio extensions. */ 79 /* The unistdio extensions. */
84, TYPE_U8_STRING 80, TYPE_U8_STRING
@@ -101,10 +97,8 @@ typedef struct
101 unsigned int a_uint; 97 unsigned int a_uint;
102 long int a_longint; 98 long int a_longint;
103 unsigned long int a_ulongint; 99 unsigned long int a_ulongint;
104#if HAVE_LONG_LONG_INT
105 long long int a_longlongint; 100 long long int a_longlongint;
106 unsigned long long int a_ulonglongint; 101 unsigned long long int a_ulonglongint;
107#endif
108 float a_float; 102 float a_float;
109 double a_double; 103 double a_double;
110 long double a_longdouble; 104 long double a_longdouble;
@@ -121,9 +115,7 @@ typedef struct
121 short * a_count_short_pointer; 115 short * a_count_short_pointer;
122 int * a_count_int_pointer; 116 int * a_count_int_pointer;
123 long int * a_count_longint_pointer; 117 long int * a_count_longint_pointer;
124#if HAVE_LONG_LONG_INT
125 long long int * a_count_longlongint_pointer; 118 long long int * a_count_longlongint_pointer;
126#endif
127#if ENABLE_UNISTDIO 119#if ENABLE_UNISTDIO
128 /* The unistdio extensions. */ 120 /* The unistdio extensions. */
129 const uint8_t * a_u8_string; 121 const uint8_t * a_u8_string;
diff --git a/gl/printf-parse.c b/gl/printf-parse.c
index 23cacc1..3040749 100644
--- a/gl/printf-parse.c
+++ b/gl/printf-parse.c
@@ -1,18 +1,18 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999-2000, 2002-2003, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999-2000, 2002-2003, 2006-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* This file can be parametrized with the following macros: 17/* This file can be parametrized with the following macros:
18 CHAR_T The element type of the format string. 18 CHAR_T The element type of the format string.
@@ -48,16 +48,7 @@
48#include <stddef.h> 48#include <stddef.h>
49 49
50/* Get intmax_t. */ 50/* Get intmax_t. */
51#if defined IN_LIBINTL || defined IN_LIBASPRINTF 51#include <stdint.h>
52# if HAVE_STDINT_H_WITH_UINTMAX
53# include <stdint.h>
54# endif
55# if HAVE_INTTYPES_H_WITH_UINTMAX
56# include <inttypes.h>
57# endif
58#else
59# include <stdint.h>
60#endif
61 52
62/* malloc(), realloc(), free(). */ 53/* malloc(), realloc(), free(). */
63#include <stdlib.h> 54#include <stdlib.h>
@@ -419,7 +410,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
419 cp++; 410 cp++;
420 } 411 }
421#endif 412#endif
422#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 413#if defined _WIN32 && ! defined __CYGWIN__
423 /* On native Windows, PRIdMAX is defined as "I64d". 414 /* On native Windows, PRIdMAX is defined as "I64d".
424 We cannot change it to "lld" because PRIdMAX must also 415 We cannot change it to "lld" because PRIdMAX must also
425 be understood by the system's printf routines. */ 416 be understood by the system's printf routines. */
@@ -447,14 +438,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
447 switch (c) 438 switch (c)
448 { 439 {
449 case 'd': case 'i': 440 case 'd': case 'i':
450#if HAVE_LONG_LONG_INT 441 /* If 'long long' is larger than 'long': */
451 /* If 'long long' exists and is larger than 'long': */
452 if (flags >= 16 || (flags & 4)) 442 if (flags >= 16 || (flags & 4))
453 type = TYPE_LONGLONGINT; 443 type = TYPE_LONGLONGINT;
454 else 444 else
455#endif 445 /* If 'long long' is the same as 'long', we parse "lld" into
456 /* If 'long long' exists and is the same as 'long', we parse 446 TYPE_LONGINT. */
457 "lld" into TYPE_LONGINT. */
458 if (flags >= 8) 447 if (flags >= 8)
459 type = TYPE_LONGINT; 448 type = TYPE_LONGINT;
460 else if (flags & 2) 449 else if (flags & 2)
@@ -465,14 +454,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
465 type = TYPE_INT; 454 type = TYPE_INT;
466 break; 455 break;
467 case 'o': case 'u': case 'x': case 'X': 456 case 'o': case 'u': case 'x': case 'X':
468#if HAVE_LONG_LONG_INT 457 /* If 'unsigned long long' is larger than 'unsigned long': */
469 /* If 'long long' exists and is larger than 'long': */
470 if (flags >= 16 || (flags & 4)) 458 if (flags >= 16 || (flags & 4))
471 type = TYPE_ULONGLONGINT; 459 type = TYPE_ULONGLONGINT;
472 else 460 else
473#endif 461 /* If 'unsigned long long' is the same as 'unsigned long', we
474 /* If 'unsigned long long' exists and is the same as 462 parse "llu" into TYPE_ULONGINT. */
475 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
476 if (flags >= 8) 463 if (flags >= 8)
477 type = TYPE_ULONGINT; 464 type = TYPE_ULONGINT;
478 else if (flags & 2) 465 else if (flags & 2)
@@ -525,14 +512,12 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
525 type = TYPE_POINTER; 512 type = TYPE_POINTER;
526 break; 513 break;
527 case 'n': 514 case 'n':
528#if HAVE_LONG_LONG_INT 515 /* If 'long long' is larger than 'long': */
529 /* If 'long long' exists and is larger than 'long': */
530 if (flags >= 16 || (flags & 4)) 516 if (flags >= 16 || (flags & 4))
531 type = TYPE_COUNT_LONGLONGINT_POINTER; 517 type = TYPE_COUNT_LONGLONGINT_POINTER;
532 else 518 else
533#endif 519 /* If 'long long' is the same as 'long', we parse "lln" into
534 /* If 'long long' exists and is the same as 'long', we parse 520 TYPE_COUNT_LONGINT_POINTER. */
535 "lln" into TYPE_COUNT_LONGINT_POINTER. */
536 if (flags >= 8) 521 if (flags >= 8)
537 type = TYPE_COUNT_LONGINT_POINTER; 522 type = TYPE_COUNT_LONGINT_POINTER;
538 else if (flags & 2) 523 else if (flags & 2)
diff --git a/gl/printf-parse.h b/gl/printf-parse.h
index d8474be..1f86e32 100644
--- a/gl/printf-parse.h
+++ b/gl/printf-parse.h
@@ -1,19 +1,19 @@
1/* Parse printf format string. 1/* Parse printf format string.
2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2013 Free Software 2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2023 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _PRINTF_PARSE_H 18#ifndef _PRINTF_PARSE_H
19#define _PRINTF_PARSE_H 19#define _PRINTF_PARSE_H
diff --git a/gl/read.c b/gl/read.c
deleted file mode 100644
index 0fe0306..0000000
--- a/gl/read.c
+++ /dev/null
@@ -1,85 +0,0 @@
1/* POSIX compatible read() function.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24
25# include <errno.h>
26# include <io.h>
27
28# define WIN32_LEAN_AND_MEAN /* avoid including junk */
29# include <windows.h>
30
31# include "msvc-inval.h"
32# include "msvc-nothrow.h"
33
34# undef read
35
36# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
37static ssize_t
38read_nothrow (int fd, void *buf, size_t count)
39{
40 ssize_t result;
41
42 TRY_MSVC_INVAL
43 {
44 result = read (fd, buf, count);
45 }
46 CATCH_MSVC_INVAL
47 {
48 result = -1;
49 errno = EBADF;
50 }
51 DONE_MSVC_INVAL;
52
53 return result;
54}
55# else
56# define read_nothrow read
57# endif
58
59ssize_t
60rpl_read (int fd, void *buf, size_t count)
61{
62 ssize_t ret = read_nothrow (fd, buf, count);
63
64# if GNULIB_NONBLOCKING
65 if (ret < 0
66 && GetLastError () == ERROR_NO_DATA)
67 {
68 HANDLE h = (HANDLE) _get_osfhandle (fd);
69 if (GetFileType (h) == FILE_TYPE_PIPE)
70 {
71 /* h is a pipe or socket. */
72 DWORD state;
73 if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0)
74 && (state & PIPE_NOWAIT) != 0)
75 /* h is a pipe in non-blocking mode.
76 Change errno from EINVAL to EAGAIN. */
77 errno = EAGAIN;
78 }
79 }
80# endif
81
82 return ret;
83}
84
85#endif
diff --git a/gl/realloc.c b/gl/realloc.c
new file mode 100644
index 0000000..1063eb0
--- /dev/null
+++ b/gl/realloc.c
@@ -0,0 +1,63 @@
1/* realloc() function that is glibc compatible.
2
3 Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2023 Free Software
4 Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* written by Jim Meyering and Bruno Haible */
20
21#include <config.h>
22
23#include <stdlib.h>
24
25#include <errno.h>
26
27#include "xalloc-oversized.h"
28
29/* Call the system's realloc below. This file does not define
30 _GL_USE_STDLIB_ALLOC because it needs Gnulib's malloc if present. */
31#undef realloc
32
33/* Change the size of an allocated block of memory P to N bytes,
34 with error checking. If P is NULL, use malloc. Otherwise if N is zero,
35 free P and return NULL. */
36
37void *
38rpl_realloc (void *p, size_t n)
39{
40 if (p == NULL)
41 return malloc (n);
42
43 if (n == 0)
44 {
45 free (p);
46 return NULL;
47 }
48
49 if (xalloc_oversized (n, 1))
50 {
51 errno = ENOMEM;
52 return NULL;
53 }
54
55 void *result = realloc (p, n);
56
57#if !HAVE_MALLOC_POSIX
58 if (result == NULL)
59 errno = ENOMEM;
60#endif
61
62 return result;
63}
diff --git a/gl/reallocarray.c b/gl/reallocarray.c
new file mode 100644
index 0000000..8c99250
--- /dev/null
+++ b/gl/reallocarray.c
@@ -0,0 +1,38 @@
1/* reallocarray function that is glibc compatible.
2
3 Copyright (C) 2017-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* written by Darshit Shah */
19
20#include <config.h>
21
22#include <stdckdint.h>
23#include <stdlib.h>
24#include <errno.h>
25
26void *
27reallocarray (void *ptr, size_t nmemb, size_t size)
28{
29 size_t nbytes;
30 if (ckd_mul (&nbytes, nmemb, size))
31 {
32 errno = ENOMEM;
33 return NULL;
34 }
35
36 /* Rely on the semantics of GNU realloc. */
37 return realloc (ptr, nbytes);
38}
diff --git a/gl/ref-add.sin b/gl/ref-add.sin
deleted file mode 100644
index 112bcdc64..0000000
--- a/gl/ref-add.sin
+++ /dev/null
@@ -1,29 +0,0 @@
1# Add this package to a list of references stored in a text file.
2#
3# Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, see <http://www.gnu.org/licenses/>.
17#
18# Written by Bruno Haible <haible@clisp.cons.org>.
19#
20/^# Packages using this file: / {
21 s/# Packages using this file://
22 ta
23 :a
24 s/ @PACKAGE@ / @PACKAGE@ /
25 tb
26 s/ $/ @PACKAGE@ /
27 :b
28 s/^/# Packages using this file:/
29}
diff --git a/gl/ref-del.sin b/gl/ref-del.sin
deleted file mode 100644
index 6f73868..0000000
--- a/gl/ref-del.sin
+++ /dev/null
@@ -1,24 +0,0 @@
1# Remove this package from a list of references stored in a text file.
2#
3# Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 3, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along
16# with this program; if not, see <http://www.gnu.org/licenses/>.
17#
18# Written by Bruno Haible <haible@clisp.cons.org>.
19#
20/^# Packages using this file: / {
21 s/# Packages using this file://
22 s/ @PACKAGE@ / /
23 s/^/# Packages using this file:/
24}
diff --git a/gl/regcomp.c b/gl/regcomp.c
index f0b2e52..8947839 100644
--- a/gl/regcomp.c
+++ b/gl/regcomp.c
@@ -1,21 +1,25 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19
20#ifdef _LIBC
21# include <locale/weight.h>
22#endif
19 23
20static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, 24static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
21 size_t length, reg_syntax_t syntax); 25 size_t length, reg_syntax_t syntax);
@@ -23,14 +27,10 @@ static void re_compile_fastmap_iter (regex_t *bufp,
23 const re_dfastate_t *init_state, 27 const re_dfastate_t *init_state,
24 char *fastmap); 28 char *fastmap);
25static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); 29static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len);
26#ifdef RE_ENABLE_I18N
27static void free_charset (re_charset_t *cset); 30static void free_charset (re_charset_t *cset);
28#endif /* RE_ENABLE_I18N */
29static void free_workarea_compile (regex_t *preg); 31static void free_workarea_compile (regex_t *preg);
30static reg_errcode_t create_initial_state (re_dfa_t *dfa); 32static reg_errcode_t create_initial_state (re_dfa_t *dfa);
31#ifdef RE_ENABLE_I18N
32static void optimize_utf8 (re_dfa_t *dfa); 33static void optimize_utf8 (re_dfa_t *dfa);
33#endif
34static reg_errcode_t analyze (regex_t *preg); 34static reg_errcode_t analyze (regex_t *preg);
35static reg_errcode_t preorder (bin_tree_t *root, 35static reg_errcode_t preorder (bin_tree_t *root,
36 reg_errcode_t (fn (void *, bin_tree_t *)), 36 reg_errcode_t (fn (void *, bin_tree_t *)),
@@ -55,7 +55,7 @@ static reg_errcode_t calc_inveclosure (re_dfa_t *dfa);
55static Idx fetch_number (re_string_t *input, re_token_t *token, 55static Idx fetch_number (re_string_t *input, re_token_t *token,
56 reg_syntax_t syntax); 56 reg_syntax_t syntax);
57static int peek_token (re_token_t *token, re_string_t *input, 57static int peek_token (re_token_t *token, re_string_t *input,
58 reg_syntax_t syntax) internal_function; 58 reg_syntax_t syntax);
59static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, 59static bin_tree_t *parse (re_string_t *regexp, regex_t *preg,
60 reg_syntax_t syntax, reg_errcode_t *err); 60 reg_syntax_t syntax, reg_errcode_t *err);
61static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, 61static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg,
@@ -85,7 +85,6 @@ static reg_errcode_t parse_bracket_element (bracket_elem_t *elem,
85static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, 85static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem,
86 re_string_t *regexp, 86 re_string_t *regexp,
87 re_token_t *token); 87 re_token_t *token);
88#ifdef RE_ENABLE_I18N
89static reg_errcode_t build_equiv_class (bitset_t sbcset, 88static reg_errcode_t build_equiv_class (bitset_t sbcset,
90 re_charset_t *mbcset, 89 re_charset_t *mbcset,
91 Idx *equiv_class_alloc, 90 Idx *equiv_class_alloc,
@@ -96,14 +95,6 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
96 Idx *char_class_alloc, 95 Idx *char_class_alloc,
97 const char *class_name, 96 const char *class_name,
98 reg_syntax_t syntax); 97 reg_syntax_t syntax);
99#else /* not RE_ENABLE_I18N */
100static reg_errcode_t build_equiv_class (bitset_t sbcset,
101 const unsigned char *name);
102static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
103 bitset_t sbcset,
104 const char *class_name,
105 reg_syntax_t syntax);
106#endif /* not RE_ENABLE_I18N */
107static bin_tree_t *build_charclass_op (re_dfa_t *dfa, 98static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
108 RE_TRANSLATE_TYPE trans, 99 RE_TRANSLATE_TYPE trans,
109 const char *class_name, 100 const char *class_name,
@@ -149,9 +140,9 @@ static const char __re_error_msgid[] =
149 gettext_noop ("Invalid back reference") /* REG_ESUBREG */ 140 gettext_noop ("Invalid back reference") /* REG_ESUBREG */
150 "\0" 141 "\0"
151#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") 142#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
152 gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ 143 gettext_noop ("Unmatched [, [^, [:, [., or [=") /* REG_EBRACK */
153 "\0" 144 "\0"
154#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") 145#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [, [^, [:, [., or [=")
155 gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ 146 gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
156 "\0" 147 "\0"
157#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") 148#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
@@ -209,17 +200,9 @@ static const size_t __re_error_msgid_idx[] =
209 Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields 200 Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields
210 are set in BUFP on entry. */ 201 are set in BUFP on entry. */
211 202
212#ifdef _LIBC
213const char *
214re_compile_pattern (pattern, length, bufp)
215 const char *pattern;
216 size_t length;
217 struct re_pattern_buffer *bufp;
218#else /* size_t might promote */
219const char * 203const char *
220re_compile_pattern (const char *pattern, size_t length, 204re_compile_pattern (const char *pattern, size_t length,
221 struct re_pattern_buffer *bufp) 205 struct re_pattern_buffer *bufp)
222#endif
223{ 206{
224 reg_errcode_t ret; 207 reg_errcode_t ret;
225 208
@@ -237,9 +220,7 @@ re_compile_pattern (const char *pattern, size_t length,
237 return NULL; 220 return NULL;
238 return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); 221 return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
239} 222}
240#ifdef _LIBC
241weak_alias (__re_compile_pattern, re_compile_pattern) 223weak_alias (__re_compile_pattern, re_compile_pattern)
242#endif
243 224
244/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can 225/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
245 also be assigned to arbitrarily: each pattern buffer stores its own 226 also be assigned to arbitrarily: each pattern buffer stores its own
@@ -257,21 +238,17 @@ reg_syntax_t re_syntax_options;
257 defined in regex.h. We return the old syntax. */ 238 defined in regex.h. We return the old syntax. */
258 239
259reg_syntax_t 240reg_syntax_t
260re_set_syntax (syntax) 241re_set_syntax (reg_syntax_t syntax)
261 reg_syntax_t syntax;
262{ 242{
263 reg_syntax_t ret = re_syntax_options; 243 reg_syntax_t ret = re_syntax_options;
264 244
265 re_syntax_options = syntax; 245 re_syntax_options = syntax;
266 return ret; 246 return ret;
267} 247}
268#ifdef _LIBC
269weak_alias (__re_set_syntax, re_set_syntax) 248weak_alias (__re_set_syntax, re_set_syntax)
270#endif
271 249
272int 250int
273re_compile_fastmap (bufp) 251re_compile_fastmap (struct re_pattern_buffer *bufp)
274 struct re_pattern_buffer *bufp;
275{ 252{
276 re_dfa_t *dfa = bufp->buffer; 253 re_dfa_t *dfa = bufp->buffer;
277 char *fastmap = bufp->fastmap; 254 char *fastmap = bufp->fastmap;
@@ -287,12 +264,9 @@ re_compile_fastmap (bufp)
287 bufp->fastmap_accurate = 1; 264 bufp->fastmap_accurate = 1;
288 return 0; 265 return 0;
289} 266}
290#ifdef _LIBC
291weak_alias (__re_compile_fastmap, re_compile_fastmap) 267weak_alias (__re_compile_fastmap, re_compile_fastmap)
292#endif
293 268
294static inline void 269static __always_inline void
295__attribute__ ((always_inline))
296re_set_fastmap (char *fastmap, bool icase, int ch) 270re_set_fastmap (char *fastmap, bool icase, int ch)
297{ 271{
298 fastmap[ch] = 1; 272 fastmap[ch] = 1;
@@ -318,7 +292,6 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
318 if (type == CHARACTER) 292 if (type == CHARACTER)
319 { 293 {
320 re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); 294 re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c);
321#ifdef RE_ENABLE_I18N
322 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) 295 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
323 { 296 {
324 unsigned char buf[MB_LEN_MAX]; 297 unsigned char buf[MB_LEN_MAX];
@@ -335,11 +308,10 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
335 memset (&state, '\0', sizeof (state)); 308 memset (&state, '\0', sizeof (state));
336 if (__mbrtowc (&wc, (const char *) buf, p - buf, 309 if (__mbrtowc (&wc, (const char *) buf, p - buf,
337 &state) == p - buf 310 &state) == p - buf
338 && (__wcrtomb ((char *) buf, towlower (wc), &state) 311 && (__wcrtomb ((char *) buf, __towlower (wc), &state)
339 != (size_t) -1)) 312 != (size_t) -1))
340 re_set_fastmap (fastmap, false, buf[0]); 313 re_set_fastmap (fastmap, false, buf[0]);
341 } 314 }
342#endif
343 } 315 }
344 else if (type == SIMPLE_BRACKET) 316 else if (type == SIMPLE_BRACKET)
345 { 317 {
@@ -353,13 +325,12 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
353 re_set_fastmap (fastmap, icase, ch); 325 re_set_fastmap (fastmap, icase, ch);
354 } 326 }
355 } 327 }
356#ifdef RE_ENABLE_I18N
357 else if (type == COMPLEX_BRACKET) 328 else if (type == COMPLEX_BRACKET)
358 { 329 {
359 re_charset_t *cset = dfa->nodes[node].opr.mbcset; 330 re_charset_t *cset = dfa->nodes[node].opr.mbcset;
360 Idx i; 331 Idx i;
361 332
362# ifdef _LIBC 333#ifdef _LIBC
363 /* See if we have to try all bytes which start multiple collation 334 /* See if we have to try all bytes which start multiple collation
364 elements. 335 elements.
365 e.g. In da_DK, we want to catch 'a' since "aa" is a valid 336 e.g. In da_DK, we want to catch 'a' since "aa" is a valid
@@ -375,7 +346,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
375 if (table[i] < 0) 346 if (table[i] < 0)
376 re_set_fastmap (fastmap, icase, i); 347 re_set_fastmap (fastmap, icase, i);
377 } 348 }
378# endif /* _LIBC */ 349#endif /* _LIBC */
379 350
380 /* See if we have to start the match at all multibyte characters, 351 /* See if we have to start the match at all multibyte characters,
381 i.e. where we would not find an invalid sequence. This only 352 i.e. where we would not find an invalid sequence. This only
@@ -383,9 +354,9 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
383 sets, the SIMPLE_BRACKET again suffices. */ 354 sets, the SIMPLE_BRACKET again suffices. */
384 if (dfa->mb_cur_max > 1 355 if (dfa->mb_cur_max > 1
385 && (cset->nchar_classes || cset->non_match || cset->nranges 356 && (cset->nchar_classes || cset->non_match || cset->nranges
386# ifdef _LIBC 357#ifdef _LIBC
387 || cset->nequiv_classes 358 || cset->nequiv_classes
388# endif /* _LIBC */ 359#endif /* _LIBC */
389 )) 360 ))
390 { 361 {
391 unsigned char c = 0; 362 unsigned char c = 0;
@@ -411,19 +382,14 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
411 re_set_fastmap (fastmap, icase, *(unsigned char *) buf); 382 re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
412 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) 383 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
413 { 384 {
414 if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) 385 if (__wcrtomb (buf, __towlower (cset->mbchars[i]), &state)
415 != (size_t) -1) 386 != (size_t) -1)
416 re_set_fastmap (fastmap, false, *(unsigned char *) buf); 387 re_set_fastmap (fastmap, false, *(unsigned char *) buf);
417 } 388 }
418 } 389 }
419 } 390 }
420 } 391 }
421#endif /* RE_ENABLE_I18N */ 392 else if (type == OP_PERIOD || type == OP_UTF8_PERIOD || type == END_OF_RE)
422 else if (type == OP_PERIOD
423#ifdef RE_ENABLE_I18N
424 || type == OP_UTF8_PERIOD
425#endif /* RE_ENABLE_I18N */
426 || type == END_OF_RE)
427 { 393 {
428 memset (fastmap, '\1', sizeof (char) * SBC_MAX); 394 memset (fastmap, '\1', sizeof (char) * SBC_MAX);
429 if (type == END_OF_RE) 395 if (type == END_OF_RE)
@@ -470,10 +436,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
470 the return codes and their meanings.) */ 436 the return codes and their meanings.) */
471 437
472int 438int
473regcomp (preg, pattern, cflags) 439regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
474 regex_t *_Restrict_ preg;
475 const char *_Restrict_ pattern;
476 int cflags;
477{ 440{
478 reg_errcode_t ret; 441 reg_errcode_t ret;
479 reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED 442 reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
@@ -485,7 +448,7 @@ regcomp (preg, pattern, cflags)
485 448
486 /* Try to allocate space for the fastmap. */ 449 /* Try to allocate space for the fastmap. */
487 preg->fastmap = re_malloc (char, SBC_MAX); 450 preg->fastmap = re_malloc (char, SBC_MAX);
488 if (BE (preg->fastmap == NULL, 0)) 451 if (__glibc_unlikely (preg->fastmap == NULL))
489 return REG_ESPACE; 452 return REG_ESPACE;
490 453
491 syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; 454 syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0;
@@ -511,7 +474,7 @@ regcomp (preg, pattern, cflags)
511 ret = REG_EPAREN; 474 ret = REG_EPAREN;
512 475
513 /* We have already checked preg->fastmap != NULL. */ 476 /* We have already checked preg->fastmap != NULL. */
514 if (BE (ret == REG_NOERROR, 1)) 477 if (__glibc_likely (ret == REG_NOERROR))
515 /* Compute the fastmap now, since regexec cannot modify the pattern 478 /* Compute the fastmap now, since regexec cannot modify the pattern
516 buffer. This function never fails in this implementation. */ 479 buffer. This function never fails in this implementation. */
517 (void) re_compile_fastmap (preg); 480 (void) re_compile_fastmap (preg);
@@ -524,32 +487,21 @@ regcomp (preg, pattern, cflags)
524 487
525 return (int) ret; 488 return (int) ret;
526} 489}
527#ifdef _LIBC 490libc_hidden_def (__regcomp)
528weak_alias (__regcomp, regcomp) 491weak_alias (__regcomp, regcomp)
529#endif
530 492
531/* Returns a message corresponding to an error code, ERRCODE, returned 493/* Returns a message corresponding to an error code, ERRCODE, returned
532 from either regcomp or regexec. We don't use PREG here. */ 494 from either regcomp or regexec. We don't use PREG here. */
533 495
534#ifdef _LIBC
535size_t
536regerror (errcode, preg, errbuf, errbuf_size)
537 int errcode;
538 const regex_t *_Restrict_ preg;
539 char *_Restrict_ errbuf;
540 size_t errbuf_size;
541#else /* size_t might promote */
542size_t 496size_t
543regerror (int errcode, const regex_t *_Restrict_ preg, 497regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
544 char *_Restrict_ errbuf, size_t errbuf_size) 498 size_t errbuf_size)
545#endif
546{ 499{
547 const char *msg; 500 const char *msg;
548 size_t msg_size; 501 size_t msg_size;
502 int nerrcodes = sizeof __re_error_msgid_idx / sizeof __re_error_msgid_idx[0];
549 503
550 if (BE (errcode < 0 504 if (__glibc_unlikely (errcode < 0 || errcode >= nerrcodes))
551 || errcode >= (int) (sizeof (__re_error_msgid_idx)
552 / sizeof (__re_error_msgid_idx[0])), 0))
553 /* Only error codes returned by the rest of the code should be passed 505 /* Only error codes returned by the rest of the code should be passed
554 to this routine. If we are given anything else, or if other regex 506 to this routine. If we are given anything else, or if other regex
555 code generates an invalid error code, then the program has a bug. 507 code generates an invalid error code, then the program has a bug.
@@ -560,10 +512,10 @@ regerror (int errcode, const regex_t *_Restrict_ preg,
560 512
561 msg_size = strlen (msg) + 1; /* Includes the null. */ 513 msg_size = strlen (msg) + 1; /* Includes the null. */
562 514
563 if (BE (errbuf_size != 0, 1)) 515 if (__glibc_likely (errbuf_size != 0))
564 { 516 {
565 size_t cpy_size = msg_size; 517 size_t cpy_size = msg_size;
566 if (BE (msg_size > errbuf_size, 0)) 518 if (__glibc_unlikely (msg_size > errbuf_size))
567 { 519 {
568 cpy_size = errbuf_size - 1; 520 cpy_size = errbuf_size - 1;
569 errbuf[cpy_size] = '\0'; 521 errbuf[cpy_size] = '\0';
@@ -573,12 +525,9 @@ regerror (int errcode, const regex_t *_Restrict_ preg,
573 525
574 return msg_size; 526 return msg_size;
575} 527}
576#ifdef _LIBC
577weak_alias (__regerror, regerror) 528weak_alias (__regerror, regerror)
578#endif
579 529
580 530
581#ifdef RE_ENABLE_I18N
582/* This static array is used for the map to single-byte characters when 531/* This static array is used for the map to single-byte characters when
583 UTF-8 is used. Otherwise we would allocate memory just to initialize 532 UTF-8 is used. Otherwise we would allocate memory just to initialize
584 it the same all the time. UTF-8 is the preferred encoding so this is 533 it the same all the time. UTF-8 is the preferred encoding so this is
@@ -586,25 +535,24 @@ weak_alias (__regerror, regerror)
586static const bitset_t utf8_sb_map = 535static const bitset_t utf8_sb_map =
587{ 536{
588 /* Set the first 128 bits. */ 537 /* Set the first 128 bits. */
589# if defined __GNUC__ && !defined __STRICT_ANSI__ 538#if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__
590 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX 539 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
591# else 540#else
592# if 4 * BITSET_WORD_BITS < ASCII_CHARS 541# if 4 * BITSET_WORD_BITS < ASCII_CHARS
593# error "bitset_word_t is narrower than 32 bits" 542# error "bitset_word_t is narrower than 32 bits"
594# elif 3 * BITSET_WORD_BITS < ASCII_CHARS 543# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
595 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, 544 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
596# elif 2 * BITSET_WORD_BITS < ASCII_CHARS 545# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
597 BITSET_WORD_MAX, BITSET_WORD_MAX, 546 BITSET_WORD_MAX, BITSET_WORD_MAX,
598# elif 1 * BITSET_WORD_BITS < ASCII_CHARS 547# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
599 BITSET_WORD_MAX, 548 BITSET_WORD_MAX,
600# endif 549# endif
601 (BITSET_WORD_MAX 550 (BITSET_WORD_MAX
602 >> (SBC_MAX % BITSET_WORD_BITS == 0 551 >> (SBC_MAX % BITSET_WORD_BITS == 0
603 ? 0 552 ? 0
604 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) 553 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
605# endif
606};
607#endif 554#endif
555};
608 556
609 557
610static void 558static void
@@ -642,10 +590,8 @@ free_dfa_content (re_dfa_t *dfa)
642 re_free (entry->array); 590 re_free (entry->array);
643 } 591 }
644 re_free (dfa->state_table); 592 re_free (dfa->state_table);
645#ifdef RE_ENABLE_I18N
646 if (dfa->sb_char != utf8_sb_map) 593 if (dfa->sb_char != utf8_sb_map)
647 re_free (dfa->sb_char); 594 re_free (dfa->sb_char);
648#endif
649 re_free (dfa->subexp_map); 595 re_free (dfa->subexp_map);
650#ifdef DEBUG 596#ifdef DEBUG
651 re_free (dfa->re_str); 597 re_free (dfa->re_str);
@@ -658,11 +604,10 @@ free_dfa_content (re_dfa_t *dfa)
658/* Free dynamically allocated space used by PREG. */ 604/* Free dynamically allocated space used by PREG. */
659 605
660void 606void
661regfree (preg) 607regfree (regex_t *preg)
662 regex_t *preg;
663{ 608{
664 re_dfa_t *dfa = preg->buffer; 609 re_dfa_t *dfa = preg->buffer;
665 if (BE (dfa != NULL, 1)) 610 if (__glibc_likely (dfa != NULL))
666 { 611 {
667 lock_fini (dfa->lock); 612 lock_fini (dfa->lock);
668 free_dfa_content (dfa); 613 free_dfa_content (dfa);
@@ -676,9 +621,8 @@ regfree (preg)
676 re_free (preg->translate); 621 re_free (preg->translate);
677 preg->translate = NULL; 622 preg->translate = NULL;
678} 623}
679#ifdef _LIBC 624libc_hidden_def (__regfree)
680weak_alias (__regfree, regfree) 625weak_alias (__regfree, regfree)
681#endif
682 626
683/* Entry points compatible with 4.2 BSD regex library. We don't define 627/* Entry points compatible with 4.2 BSD regex library. We don't define
684 them unless specifically requested. */ 628 them unless specifically requested. */
@@ -695,8 +639,7 @@ char *
695 regcomp/regexec above without link errors. */ 639 regcomp/regexec above without link errors. */
696weak_function 640weak_function
697# endif 641# endif
698re_comp (s) 642re_comp (const char *s)
699 const char *s;
700{ 643{
701 reg_errcode_t ret; 644 reg_errcode_t ret;
702 char *fastmap; 645 char *fastmap;
@@ -719,7 +662,7 @@ re_comp (s)
719 662
720 if (re_comp_buf.fastmap == NULL) 663 if (re_comp_buf.fastmap == NULL)
721 { 664 {
722 re_comp_buf.fastmap = (char *) malloc (SBC_MAX); 665 re_comp_buf.fastmap = re_malloc (char, SBC_MAX);
723 if (re_comp_buf.fastmap == NULL) 666 if (re_comp_buf.fastmap == NULL)
724 return (char *) gettext (__re_error_msgid 667 return (char *) gettext (__re_error_msgid
725 + __re_error_msgid_idx[(int) REG_ESPACE]); 668 + __re_error_msgid_idx[(int) REG_ESPACE]);
@@ -772,7 +715,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
772 715
773 /* Initialize the dfa. */ 716 /* Initialize the dfa. */
774 dfa = preg->buffer; 717 dfa = preg->buffer;
775 if (BE (preg->allocated < sizeof (re_dfa_t), 0)) 718 if (__glibc_unlikely (preg->allocated < sizeof (re_dfa_t)))
776 { 719 {
777 /* If zero allocated, but buffer is non-null, try to realloc 720 /* If zero allocated, but buffer is non-null, try to realloc
778 enough space. This loses if buffer's address is bogus, but 721 enough space. This loses if buffer's address is bogus, but
@@ -787,9 +730,9 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
787 preg->used = sizeof (re_dfa_t); 730 preg->used = sizeof (re_dfa_t);
788 731
789 err = init_dfa (dfa, length); 732 err = init_dfa (dfa, length);
790 if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0)) 733 if (__glibc_unlikely (err == REG_NOERROR && lock_init (dfa->lock) != 0))
791 err = REG_ESPACE; 734 err = REG_ESPACE;
792 if (BE (err != REG_NOERROR, 0)) 735 if (__glibc_unlikely (err != REG_NOERROR))
793 { 736 {
794 free_dfa_content (dfa); 737 free_dfa_content (dfa);
795 preg->buffer = NULL; 738 preg->buffer = NULL;
@@ -804,7 +747,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
804 747
805 err = re_string_construct (&regexp, pattern, length, preg->translate, 748 err = re_string_construct (&regexp, pattern, length, preg->translate,
806 (syntax & RE_ICASE) != 0, dfa); 749 (syntax & RE_ICASE) != 0, dfa);
807 if (BE (err != REG_NOERROR, 0)) 750 if (__glibc_unlikely (err != REG_NOERROR))
808 { 751 {
809 re_compile_internal_free_return: 752 re_compile_internal_free_return:
810 free_workarea_compile (preg); 753 free_workarea_compile (preg);
@@ -819,19 +762,17 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
819 /* Parse the regular expression, and build a structure tree. */ 762 /* Parse the regular expression, and build a structure tree. */
820 preg->re_nsub = 0; 763 preg->re_nsub = 0;
821 dfa->str_tree = parse (&regexp, preg, syntax, &err); 764 dfa->str_tree = parse (&regexp, preg, syntax, &err);
822 if (BE (dfa->str_tree == NULL, 0)) 765 if (__glibc_unlikely (dfa->str_tree == NULL))
823 goto re_compile_internal_free_return; 766 goto re_compile_internal_free_return;
824 767
825 /* Analyze the tree and create the nfa. */ 768 /* Analyze the tree and create the nfa. */
826 err = analyze (preg); 769 err = analyze (preg);
827 if (BE (err != REG_NOERROR, 0)) 770 if (__glibc_unlikely (err != REG_NOERROR))
828 goto re_compile_internal_free_return; 771 goto re_compile_internal_free_return;
829 772
830#ifdef RE_ENABLE_I18N
831 /* If possible, do searching in single byte encoding to speed things up. */ 773 /* If possible, do searching in single byte encoding to speed things up. */
832 if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) 774 if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL)
833 optimize_utf8 (dfa); 775 optimize_utf8 (dfa);
834#endif
835 776
836 /* Then create the initial state of the dfa. */ 777 /* Then create the initial state of the dfa. */
837 err = create_initial_state (dfa); 778 err = create_initial_state (dfa);
@@ -840,7 +781,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
840 free_workarea_compile (preg); 781 free_workarea_compile (preg);
841 re_string_destruct (&regexp); 782 re_string_destruct (&regexp);
842 783
843 if (BE (err != REG_NOERROR, 0)) 784 if (__glibc_unlikely (err != REG_NOERROR))
844 { 785 {
845 lock_fini (dfa->lock); 786 lock_fini (dfa->lock);
846 free_dfa_content (dfa); 787 free_dfa_content (dfa);
@@ -861,11 +802,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
861#ifndef _LIBC 802#ifndef _LIBC
862 const char *codeset_name; 803 const char *codeset_name;
863#endif 804#endif
864#ifdef RE_ENABLE_I18N
865 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); 805 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
866#else
867 size_t max_i18n_object_size = 0;
868#endif
869 size_t max_object_size = 806 size_t max_object_size =
870 MAX (sizeof (struct re_state_table_entry), 807 MAX (sizeof (struct re_state_table_entry),
871 MAX (sizeof (re_token_t), 808 MAX (sizeof (re_token_t),
@@ -882,7 +819,8 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
882 calculation below, and for similar doubling calculations 819 calculation below, and for similar doubling calculations
883 elsewhere. And it's <= rather than <, because some of the 820 elsewhere. And it's <= rather than <, because some of the
884 doubling calculations add 1 afterwards. */ 821 doubling calculations add 1 afterwards. */
885 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0)) 822 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2
823 <= pat_len))
886 return REG_ESPACE; 824 return REG_ESPACE;
887 825
888 dfa->nodes_alloc = pat_len + 1; 826 dfa->nodes_alloc = pat_len + 1;
@@ -916,7 +854,6 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
916 dfa->map_notascii = 0; 854 dfa->map_notascii = 0;
917#endif 855#endif
918 856
919#ifdef RE_ENABLE_I18N
920 if (dfa->mb_cur_max > 1) 857 if (dfa->mb_cur_max > 1)
921 { 858 {
922 if (dfa->is_utf8) 859 if (dfa->is_utf8)
@@ -926,7 +863,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
926 int i, j, ch; 863 int i, j, ch;
927 864
928 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 865 dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
929 if (BE (dfa->sb_char == NULL, 0)) 866 if (__glibc_unlikely (dfa->sb_char == NULL))
930 return REG_ESPACE; 867 return REG_ESPACE;
931 868
932 /* Set the bits corresponding to single byte chars. */ 869 /* Set the bits corresponding to single byte chars. */
@@ -936,16 +873,15 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
936 wint_t wch = __btowc (ch); 873 wint_t wch = __btowc (ch);
937 if (wch != WEOF) 874 if (wch != WEOF)
938 dfa->sb_char[i] |= (bitset_word_t) 1 << j; 875 dfa->sb_char[i] |= (bitset_word_t) 1 << j;
939# ifndef _LIBC 876#ifndef _LIBC
940 if (isascii (ch) && wch != ch) 877 if (isascii (ch) && wch != ch)
941 dfa->map_notascii = 1; 878 dfa->map_notascii = 1;
942# endif 879#endif
943 } 880 }
944 } 881 }
945 } 882 }
946#endif
947 883
948 if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) 884 if (__glibc_unlikely (dfa->nodes == NULL || dfa->state_table == NULL))
949 return REG_ESPACE; 885 return REG_ESPACE;
950 return REG_NOERROR; 886 return REG_NOERROR;
951} 887}
@@ -955,14 +891,13 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
955 character used by some operators like "\<", "\>", etc. */ 891 character used by some operators like "\<", "\>", etc. */
956 892
957static void 893static void
958internal_function
959init_word_char (re_dfa_t *dfa) 894init_word_char (re_dfa_t *dfa)
960{ 895{
961 int i = 0; 896 int i = 0;
962 int j; 897 int j;
963 int ch = 0; 898 int ch = 0;
964 dfa->word_ops_used = 1; 899 dfa->word_ops_used = 1;
965 if (BE (dfa->map_notascii == 0, 1)) 900 if (__glibc_likely (dfa->map_notascii == 0))
966 { 901 {
967 bitset_word_t bits0 = 0x00000000; 902 bitset_word_t bits0 = 0x00000000;
968 bitset_word_t bits1 = 0x03ff0000; 903 bitset_word_t bits1 = 0x03ff0000;
@@ -970,6 +905,7 @@ init_word_char (re_dfa_t *dfa)
970 bitset_word_t bits3 = 0x07fffffe; 905 bitset_word_t bits3 = 0x07fffffe;
971 if (BITSET_WORD_BITS == 64) 906 if (BITSET_WORD_BITS == 64)
972 { 907 {
908 /* Pacify gcc -Woverflow on 32-bit platformns. */
973 dfa->word_char[0] = bits1 << 31 << 1 | bits0; 909 dfa->word_char[0] = bits1 << 31 << 1 | bits0;
974 dfa->word_char[1] = bits3 << 31 << 1 | bits2; 910 dfa->word_char[1] = bits3 << 31 << 1 | bits2;
975 i = 2; 911 i = 2;
@@ -986,7 +922,7 @@ init_word_char (re_dfa_t *dfa)
986 goto general_case; 922 goto general_case;
987 ch = 128; 923 ch = 128;
988 924
989 if (BE (dfa->is_utf8, 1)) 925 if (__glibc_likely (dfa->is_utf8))
990 { 926 {
991 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); 927 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
992 return; 928 return;
@@ -1033,7 +969,7 @@ create_initial_state (re_dfa_t *dfa)
1033 first = dfa->str_tree->first->node_idx; 969 first = dfa->str_tree->first->node_idx;
1034 dfa->init_node = first; 970 dfa->init_node = first;
1035 err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); 971 err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first);
1036 if (BE (err != REG_NOERROR, 0)) 972 if (__glibc_unlikely (err != REG_NOERROR))
1037 return err; 973 return err;
1038 974
1039 /* The back-references which are in initial states can epsilon transit, 975 /* The back-references which are in initial states can epsilon transit,
@@ -1077,7 +1013,7 @@ create_initial_state (re_dfa_t *dfa)
1077 /* It must be the first time to invoke acquire_state. */ 1013 /* It must be the first time to invoke acquire_state. */
1078 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); 1014 dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0);
1079 /* We don't check ERR here, since the initial state must not be NULL. */ 1015 /* We don't check ERR here, since the initial state must not be NULL. */
1080 if (BE (dfa->init_state == NULL, 0)) 1016 if (__glibc_unlikely (dfa->init_state == NULL))
1081 return err; 1017 return err;
1082 if (dfa->init_state->has_constraint) 1018 if (dfa->init_state->has_constraint)
1083 { 1019 {
@@ -1089,8 +1025,9 @@ create_initial_state (re_dfa_t *dfa)
1089 &init_nodes, 1025 &init_nodes,
1090 CONTEXT_NEWLINE 1026 CONTEXT_NEWLINE
1091 | CONTEXT_BEGBUF); 1027 | CONTEXT_BEGBUF);
1092 if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL 1028 if (__glibc_unlikely (dfa->init_state_word == NULL
1093 || dfa->init_state_begbuf == NULL, 0)) 1029 || dfa->init_state_nl == NULL
1030 || dfa->init_state_begbuf == NULL))
1094 return err; 1031 return err;
1095 } 1032 }
1096 else 1033 else
@@ -1101,7 +1038,6 @@ create_initial_state (re_dfa_t *dfa)
1101 return REG_NOERROR; 1038 return REG_NOERROR;
1102} 1039}
1103 1040
1104#ifdef RE_ENABLE_I18N
1105/* If it is possible to do searching in single byte encoding instead of UTF-8 1041/* If it is possible to do searching in single byte encoding instead of UTF-8
1106 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change 1042 to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change
1107 DFA nodes where needed. */ 1043 DFA nodes where needed. */
@@ -1181,7 +1117,6 @@ optimize_utf8 (re_dfa_t *dfa)
1181 dfa->is_utf8 = 0; 1117 dfa->is_utf8 = 0;
1182 dfa->has_mb_node = dfa->nbackref > 0 || has_period; 1118 dfa->has_mb_node = dfa->nbackref > 0 || has_period;
1183} 1119}
1184#endif
1185 1120
1186/* Analyze the structure tree, and calculate "first", "next", "edest", 1121/* Analyze the structure tree, and calculate "first", "next", "edest",
1187 "eclosure", and "inveclosure". */ 1122 "eclosure", and "inveclosure". */
@@ -1197,8 +1132,8 @@ analyze (regex_t *preg)
1197 dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc); 1132 dfa->org_indices = re_malloc (Idx, dfa->nodes_alloc);
1198 dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); 1133 dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc);
1199 dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); 1134 dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc);
1200 if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL 1135 if (__glibc_unlikely (dfa->nexts == NULL || dfa->org_indices == NULL
1201 || dfa->eclosures == NULL, 0)) 1136 || dfa->edests == NULL || dfa->eclosures == NULL))
1202 return REG_ESPACE; 1137 return REG_ESPACE;
1203 1138
1204 dfa->subexp_map = re_malloc (Idx, preg->re_nsub); 1139 dfa->subexp_map = re_malloc (Idx, preg->re_nsub);
@@ -1213,23 +1148,23 @@ analyze (regex_t *preg)
1213 break; 1148 break;
1214 if (i == preg->re_nsub) 1149 if (i == preg->re_nsub)
1215 { 1150 {
1216 free (dfa->subexp_map); 1151 re_free (dfa->subexp_map);
1217 dfa->subexp_map = NULL; 1152 dfa->subexp_map = NULL;
1218 } 1153 }
1219 } 1154 }
1220 1155
1221 ret = postorder (dfa->str_tree, lower_subexps, preg); 1156 ret = postorder (dfa->str_tree, lower_subexps, preg);
1222 if (BE (ret != REG_NOERROR, 0)) 1157 if (__glibc_unlikely (ret != REG_NOERROR))
1223 return ret; 1158 return ret;
1224 ret = postorder (dfa->str_tree, calc_first, dfa); 1159 ret = postorder (dfa->str_tree, calc_first, dfa);
1225 if (BE (ret != REG_NOERROR, 0)) 1160 if (__glibc_unlikely (ret != REG_NOERROR))
1226 return ret; 1161 return ret;
1227 preorder (dfa->str_tree, calc_next, dfa); 1162 preorder (dfa->str_tree, calc_next, dfa);
1228 ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); 1163 ret = preorder (dfa->str_tree, link_nfa_nodes, dfa);
1229 if (BE (ret != REG_NOERROR, 0)) 1164 if (__glibc_unlikely (ret != REG_NOERROR))
1230 return ret; 1165 return ret;
1231 ret = calc_eclosure (dfa); 1166 ret = calc_eclosure (dfa);
1232 if (BE (ret != REG_NOERROR, 0)) 1167 if (__glibc_unlikely (ret != REG_NOERROR))
1233 return ret; 1168 return ret;
1234 1169
1235 /* We only need this during the prune_impossible_nodes pass in regexec.c; 1170 /* We only need this during the prune_impossible_nodes pass in regexec.c;
@@ -1238,7 +1173,7 @@ analyze (regex_t *preg)
1238 || dfa->nbackref) 1173 || dfa->nbackref)
1239 { 1174 {
1240 dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); 1175 dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len);
1241 if (BE (dfa->inveclosures == NULL, 0)) 1176 if (__glibc_unlikely (dfa->inveclosures == NULL))
1242 return REG_ESPACE; 1177 return REG_ESPACE;
1243 ret = calc_inveclosure (dfa); 1178 ret = calc_inveclosure (dfa);
1244 } 1179 }
@@ -1268,7 +1203,7 @@ postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1268 do 1203 do
1269 { 1204 {
1270 reg_errcode_t err = fn (extra, node); 1205 reg_errcode_t err = fn (extra, node);
1271 if (BE (err != REG_NOERROR, 0)) 1206 if (__glibc_unlikely (err != REG_NOERROR))
1272 return err; 1207 return err;
1273 if (node->parent == NULL) 1208 if (node->parent == NULL)
1274 return REG_NOERROR; 1209 return REG_NOERROR;
@@ -1290,7 +1225,7 @@ preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)),
1290 for (node = root; ; ) 1225 for (node = root; ; )
1291 { 1226 {
1292 reg_errcode_t err = fn (extra, node); 1227 reg_errcode_t err = fn (extra, node);
1293 if (BE (err != REG_NOERROR, 0)) 1228 if (__glibc_unlikely (err != REG_NOERROR))
1294 return err; 1229 return err;
1295 1230
1296 /* Go to the left node, or up and to the right. */ 1231 /* Go to the left node, or up and to the right. */
@@ -1391,7 +1326,8 @@ lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
1391 cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); 1326 cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP);
1392 tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; 1327 tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls;
1393 tree = create_tree (dfa, op, tree1, CONCAT); 1328 tree = create_tree (dfa, op, tree1, CONCAT);
1394 if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) 1329 if (__glibc_unlikely (tree == NULL || tree1 == NULL
1330 || op == NULL || cls == NULL))
1395 { 1331 {
1396 *err = REG_ESPACE; 1332 *err = REG_ESPACE;
1397 return NULL; 1333 return NULL;
@@ -1417,7 +1353,7 @@ calc_first (void *extra, bin_tree_t *node)
1417 { 1353 {
1418 node->first = node; 1354 node->first = node;
1419 node->node_idx = re_dfa_add_node (dfa, node->token); 1355 node->node_idx = re_dfa_add_node (dfa, node->token);
1420 if (BE (node->node_idx == REG_MISSING, 0)) 1356 if (__glibc_unlikely (node->node_idx == -1))
1421 return REG_ESPACE; 1357 return REG_ESPACE;
1422 if (node->token.type == ANCHOR) 1358 if (node->token.type == ANCHOR)
1423 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; 1359 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
@@ -1462,7 +1398,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1462 break; 1398 break;
1463 1399
1464 case END_OF_RE: 1400 case END_OF_RE:
1465 assert (node->next == NULL); 1401 DEBUG_ASSERT (node->next == NULL);
1466 break; 1402 break;
1467 1403
1468 case OP_DUP_ASTERISK: 1404 case OP_DUP_ASTERISK:
@@ -1478,8 +1414,8 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1478 right = node->right->first->node_idx; 1414 right = node->right->first->node_idx;
1479 else 1415 else
1480 right = node->next->node_idx; 1416 right = node->next->node_idx;
1481 assert (REG_VALID_INDEX (left)); 1417 DEBUG_ASSERT (left > -1);
1482 assert (REG_VALID_INDEX (right)); 1418 DEBUG_ASSERT (right > -1);
1483 err = re_node_set_init_2 (dfa->edests + idx, left, right); 1419 err = re_node_set_init_2 (dfa->edests + idx, left, right);
1484 } 1420 }
1485 break; 1421 break;
@@ -1497,7 +1433,7 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1497 break; 1433 break;
1498 1434
1499 default: 1435 default:
1500 assert (!IS_EPSILON_NODE (node->token.type)); 1436 DEBUG_ASSERT (!IS_EPSILON_NODE (node->token.type));
1501 dfa->nexts[idx] = node->next->node_idx; 1437 dfa->nexts[idx] = node->next->node_idx;
1502 break; 1438 break;
1503 } 1439 }
@@ -1510,7 +1446,6 @@ link_nfa_nodes (void *extra, bin_tree_t *node)
1510 to their own constraint. */ 1446 to their own constraint. */
1511 1447
1512static reg_errcode_t 1448static reg_errcode_t
1513internal_function
1514duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node, 1449duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1515 Idx root_node, unsigned int init_constraint) 1450 Idx root_node, unsigned int init_constraint)
1516{ 1451{
@@ -1529,11 +1464,11 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1529 org_dest = dfa->nexts[org_node]; 1464 org_dest = dfa->nexts[org_node];
1530 re_node_set_empty (dfa->edests + clone_node); 1465 re_node_set_empty (dfa->edests + clone_node);
1531 clone_dest = duplicate_node (dfa, org_dest, constraint); 1466 clone_dest = duplicate_node (dfa, org_dest, constraint);
1532 if (BE (clone_dest == REG_MISSING, 0)) 1467 if (__glibc_unlikely (clone_dest == -1))
1533 return REG_ESPACE; 1468 return REG_ESPACE;
1534 dfa->nexts[clone_node] = dfa->nexts[org_node]; 1469 dfa->nexts[clone_node] = dfa->nexts[org_node];
1535 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1470 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1536 if (BE (! ok, 0)) 1471 if (__glibc_unlikely (! ok))
1537 return REG_ESPACE; 1472 return REG_ESPACE;
1538 } 1473 }
1539 else if (dfa->edests[org_node].nelem == 0) 1474 else if (dfa->edests[org_node].nelem == 0)
@@ -1555,17 +1490,17 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1555 if (org_node == root_node && clone_node != org_node) 1490 if (org_node == root_node && clone_node != org_node)
1556 { 1491 {
1557 ok = re_node_set_insert (dfa->edests + clone_node, org_dest); 1492 ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
1558 if (BE (! ok, 0)) 1493 if (__glibc_unlikely (! ok))
1559 return REG_ESPACE; 1494 return REG_ESPACE;
1560 break; 1495 break;
1561 } 1496 }
1562 /* In case the node has another constraint, append it. */ 1497 /* In case the node has another constraint, append it. */
1563 constraint |= dfa->nodes[org_node].constraint; 1498 constraint |= dfa->nodes[org_node].constraint;
1564 clone_dest = duplicate_node (dfa, org_dest, constraint); 1499 clone_dest = duplicate_node (dfa, org_dest, constraint);
1565 if (BE (clone_dest == REG_MISSING, 0)) 1500 if (__glibc_unlikely (clone_dest == -1))
1566 return REG_ESPACE; 1501 return REG_ESPACE;
1567 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1502 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1568 if (BE (! ok, 0)) 1503 if (__glibc_unlikely (! ok))
1569 return REG_ESPACE; 1504 return REG_ESPACE;
1570 } 1505 }
1571 else /* dfa->edests[org_node].nelem == 2 */ 1506 else /* dfa->edests[org_node].nelem == 2 */
@@ -1576,19 +1511,19 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1576 re_node_set_empty (dfa->edests + clone_node); 1511 re_node_set_empty (dfa->edests + clone_node);
1577 /* Search for a duplicated node which satisfies the constraint. */ 1512 /* Search for a duplicated node which satisfies the constraint. */
1578 clone_dest = search_duplicated_node (dfa, org_dest, constraint); 1513 clone_dest = search_duplicated_node (dfa, org_dest, constraint);
1579 if (clone_dest == REG_MISSING) 1514 if (clone_dest == -1)
1580 { 1515 {
1581 /* There is no such duplicated node, create a new one. */ 1516 /* There is no such duplicated node, create a new one. */
1582 reg_errcode_t err; 1517 reg_errcode_t err;
1583 clone_dest = duplicate_node (dfa, org_dest, constraint); 1518 clone_dest = duplicate_node (dfa, org_dest, constraint);
1584 if (BE (clone_dest == REG_MISSING, 0)) 1519 if (__glibc_unlikely (clone_dest == -1))
1585 return REG_ESPACE; 1520 return REG_ESPACE;
1586 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1521 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1587 if (BE (! ok, 0)) 1522 if (__glibc_unlikely (! ok))
1588 return REG_ESPACE; 1523 return REG_ESPACE;
1589 err = duplicate_node_closure (dfa, org_dest, clone_dest, 1524 err = duplicate_node_closure (dfa, org_dest, clone_dest,
1590 root_node, constraint); 1525 root_node, constraint);
1591 if (BE (err != REG_NOERROR, 0)) 1526 if (__glibc_unlikely (err != REG_NOERROR))
1592 return err; 1527 return err;
1593 } 1528 }
1594 else 1529 else
@@ -1596,16 +1531,16 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1596 /* There is a duplicated node which satisfies the constraint, 1531 /* There is a duplicated node which satisfies the constraint,
1597 use it to avoid infinite loop. */ 1532 use it to avoid infinite loop. */
1598 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1533 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1599 if (BE (! ok, 0)) 1534 if (__glibc_unlikely (! ok))
1600 return REG_ESPACE; 1535 return REG_ESPACE;
1601 } 1536 }
1602 1537
1603 org_dest = dfa->edests[org_node].elems[1]; 1538 org_dest = dfa->edests[org_node].elems[1];
1604 clone_dest = duplicate_node (dfa, org_dest, constraint); 1539 clone_dest = duplicate_node (dfa, org_dest, constraint);
1605 if (BE (clone_dest == REG_MISSING, 0)) 1540 if (__glibc_unlikely (clone_dest == -1))
1606 return REG_ESPACE; 1541 return REG_ESPACE;
1607 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1542 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1608 if (BE (! ok, 0)) 1543 if (__glibc_unlikely (! ok))
1609 return REG_ESPACE; 1544 return REG_ESPACE;
1610 } 1545 }
1611 org_node = org_dest; 1546 org_node = org_dest;
@@ -1628,18 +1563,18 @@ search_duplicated_node (const re_dfa_t *dfa, Idx org_node,
1628 && constraint == dfa->nodes[idx].constraint) 1563 && constraint == dfa->nodes[idx].constraint)
1629 return idx; /* Found. */ 1564 return idx; /* Found. */
1630 } 1565 }
1631 return REG_MISSING; /* Not found. */ 1566 return -1; /* Not found. */
1632} 1567}
1633 1568
1634/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. 1569/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT.
1635 Return the index of the new node, or REG_MISSING if insufficient storage is 1570 Return the index of the new node, or -1 if insufficient storage is
1636 available. */ 1571 available. */
1637 1572
1638static Idx 1573static Idx
1639duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint) 1574duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
1640{ 1575{
1641 Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); 1576 Idx dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]);
1642 if (BE (dup_idx != REG_MISSING, 1)) 1577 if (__glibc_likely (dup_idx != -1))
1643 { 1578 {
1644 dfa->nodes[dup_idx].constraint = constraint; 1579 dfa->nodes[dup_idx].constraint = constraint;
1645 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; 1580 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
@@ -1665,7 +1600,7 @@ calc_inveclosure (re_dfa_t *dfa)
1665 for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) 1600 for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx)
1666 { 1601 {
1667 ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); 1602 ok = re_node_set_insert_last (dfa->inveclosures + elems[idx], src);
1668 if (BE (! ok, 0)) 1603 if (__glibc_unlikely (! ok))
1669 return REG_ESPACE; 1604 return REG_ESPACE;
1670 } 1605 }
1671 } 1606 }
@@ -1680,9 +1615,7 @@ calc_eclosure (re_dfa_t *dfa)
1680{ 1615{
1681 Idx node_idx; 1616 Idx node_idx;
1682 bool incomplete; 1617 bool incomplete;
1683#ifdef DEBUG 1618 DEBUG_ASSERT (dfa->nodes_len > 0);
1684 assert (dfa->nodes_len > 0);
1685#endif
1686 incomplete = false; 1619 incomplete = false;
1687 /* For each nodes, calculate epsilon closure. */ 1620 /* For each nodes, calculate epsilon closure. */
1688 for (node_idx = 0; ; ++node_idx) 1621 for (node_idx = 0; ; ++node_idx)
@@ -1697,16 +1630,14 @@ calc_eclosure (re_dfa_t *dfa)
1697 node_idx = 0; 1630 node_idx = 0;
1698 } 1631 }
1699 1632
1700#ifdef DEBUG 1633 DEBUG_ASSERT (dfa->eclosures[node_idx].nelem != -1);
1701 assert (dfa->eclosures[node_idx].nelem != REG_MISSING);
1702#endif
1703 1634
1704 /* If we have already calculated, skip it. */ 1635 /* If we have already calculated, skip it. */
1705 if (dfa->eclosures[node_idx].nelem != 0) 1636 if (dfa->eclosures[node_idx].nelem != 0)
1706 continue; 1637 continue;
1707 /* Calculate epsilon closure of 'node_idx'. */ 1638 /* Calculate epsilon closure of 'node_idx'. */
1708 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); 1639 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
1709 if (BE (err != REG_NOERROR, 0)) 1640 if (__glibc_unlikely (err != REG_NOERROR))
1710 return err; 1641 return err;
1711 1642
1712 if (dfa->eclosures[node_idx].nelem == 0) 1643 if (dfa->eclosures[node_idx].nelem == 0)
@@ -1726,15 +1657,17 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1726 reg_errcode_t err; 1657 reg_errcode_t err;
1727 Idx i; 1658 Idx i;
1728 re_node_set eclosure; 1659 re_node_set eclosure;
1729 bool ok;
1730 bool incomplete = false; 1660 bool incomplete = false;
1731 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); 1661 err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1);
1732 if (BE (err != REG_NOERROR, 0)) 1662 if (__glibc_unlikely (err != REG_NOERROR))
1733 return err; 1663 return err;
1734 1664
1665 /* An epsilon closure includes itself. */
1666 eclosure.elems[eclosure.nelem++] = node;
1667
1735 /* This indicates that we are calculating this node now. 1668 /* This indicates that we are calculating this node now.
1736 We reference this value to avoid infinite loop. */ 1669 We reference this value to avoid infinite loop. */
1737 dfa->eclosures[node].nelem = REG_MISSING; 1670 dfa->eclosures[node].nelem = -1;
1738 1671
1739 /* If the current node has constraints, duplicate all nodes 1672 /* If the current node has constraints, duplicate all nodes
1740 since they must inherit the constraints. */ 1673 since they must inherit the constraints. */
@@ -1744,7 +1677,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1744 { 1677 {
1745 err = duplicate_node_closure (dfa, node, node, node, 1678 err = duplicate_node_closure (dfa, node, node, node,
1746 dfa->nodes[node].constraint); 1679 dfa->nodes[node].constraint);
1747 if (BE (err != REG_NOERROR, 0)) 1680 if (__glibc_unlikely (err != REG_NOERROR))
1748 return err; 1681 return err;
1749 } 1682 }
1750 1683
@@ -1756,7 +1689,7 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1756 Idx edest = dfa->edests[node].elems[i]; 1689 Idx edest = dfa->edests[node].elems[i];
1757 /* If calculating the epsilon closure of 'edest' is in progress, 1690 /* If calculating the epsilon closure of 'edest' is in progress,
1758 return intermediate result. */ 1691 return intermediate result. */
1759 if (dfa->eclosures[edest].nelem == REG_MISSING) 1692 if (dfa->eclosures[edest].nelem == -1)
1760 { 1693 {
1761 incomplete = true; 1694 incomplete = true;
1762 continue; 1695 continue;
@@ -1766,14 +1699,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1766 if (dfa->eclosures[edest].nelem == 0) 1699 if (dfa->eclosures[edest].nelem == 0)
1767 { 1700 {
1768 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false); 1701 err = calc_eclosure_iter (&eclosure_elem, dfa, edest, false);
1769 if (BE (err != REG_NOERROR, 0)) 1702 if (__glibc_unlikely (err != REG_NOERROR))
1770 return err; 1703 return err;
1771 } 1704 }
1772 else 1705 else
1773 eclosure_elem = dfa->eclosures[edest]; 1706 eclosure_elem = dfa->eclosures[edest];
1774 /* Merge the epsilon closure of 'edest'. */ 1707 /* Merge the epsilon closure of 'edest'. */
1775 err = re_node_set_merge (&eclosure, &eclosure_elem); 1708 err = re_node_set_merge (&eclosure, &eclosure_elem);
1776 if (BE (err != REG_NOERROR, 0)) 1709 if (__glibc_unlikely (err != REG_NOERROR))
1777 return err; 1710 return err;
1778 /* If the epsilon closure of 'edest' is incomplete, 1711 /* If the epsilon closure of 'edest' is incomplete,
1779 the epsilon closure of this node is also incomplete. */ 1712 the epsilon closure of this node is also incomplete. */
@@ -1784,10 +1717,6 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1784 } 1717 }
1785 } 1718 }
1786 1719
1787 /* An epsilon closure includes itself. */
1788 ok = re_node_set_insert (&eclosure, node);
1789 if (BE (! ok, 0))
1790 return REG_ESPACE;
1791 if (incomplete && !root) 1720 if (incomplete && !root)
1792 dfa->eclosures[node].nelem = 0; 1721 dfa->eclosures[node].nelem = 0;
1793 else 1722 else
@@ -1802,7 +1731,6 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1802 We must not use this function inside bracket expressions. */ 1731 We must not use this function inside bracket expressions. */
1803 1732
1804static void 1733static void
1805internal_function
1806fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) 1734fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
1807{ 1735{
1808 re_string_skip_bytes (input, peek_token (result, input, syntax)); 1736 re_string_skip_bytes (input, peek_token (result, input, syntax));
@@ -1812,7 +1740,6 @@ fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax)
1812 We must not use this function inside bracket expressions. */ 1740 We must not use this function inside bracket expressions. */
1813 1741
1814static int 1742static int
1815internal_function
1816peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) 1743peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1817{ 1744{
1818 unsigned char c; 1745 unsigned char c;
@@ -1827,16 +1754,14 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1827 token->opr.c = c; 1754 token->opr.c = c;
1828 1755
1829 token->word_char = 0; 1756 token->word_char = 0;
1830#ifdef RE_ENABLE_I18N
1831 token->mb_partial = 0; 1757 token->mb_partial = 0;
1832 if (input->mb_cur_max > 1 && 1758 if (input->mb_cur_max > 1
1833 !re_string_first_byte (input, re_string_cur_idx (input))) 1759 && !re_string_first_byte (input, re_string_cur_idx (input)))
1834 { 1760 {
1835 token->type = CHARACTER; 1761 token->type = CHARACTER;
1836 token->mb_partial = 1; 1762 token->mb_partial = 1;
1837 return 1; 1763 return 1;
1838 } 1764 }
1839#endif
1840 if (c == '\\') 1765 if (c == '\\')
1841 { 1766 {
1842 unsigned char c2; 1767 unsigned char c2;
@@ -1849,7 +1774,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1849 c2 = re_string_peek_byte_case (input, 1); 1774 c2 = re_string_peek_byte_case (input, 1);
1850 token->opr.c = c2; 1775 token->opr.c = c2;
1851 token->type = CHARACTER; 1776 token->type = CHARACTER;
1852#ifdef RE_ENABLE_I18N
1853 if (input->mb_cur_max > 1) 1777 if (input->mb_cur_max > 1)
1854 { 1778 {
1855 wint_t wc = re_string_wchar_at (input, 1779 wint_t wc = re_string_wchar_at (input,
@@ -1857,7 +1781,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1857 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; 1781 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
1858 } 1782 }
1859 else 1783 else
1860#endif
1861 token->word_char = IS_WORD_CHAR (c2) != 0; 1784 token->word_char = IS_WORD_CHAR (c2) != 0;
1862 1785
1863 switch (c2) 1786 switch (c2)
@@ -1963,14 +1886,12 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
1963 } 1886 }
1964 1887
1965 token->type = CHARACTER; 1888 token->type = CHARACTER;
1966#ifdef RE_ENABLE_I18N
1967 if (input->mb_cur_max > 1) 1889 if (input->mb_cur_max > 1)
1968 { 1890 {
1969 wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); 1891 wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input));
1970 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; 1892 token->word_char = IS_WIDE_WORD_CHAR (wc) != 0;
1971 } 1893 }
1972 else 1894 else
1973#endif
1974 token->word_char = IS_WORD_CHAR (token->opr.c); 1895 token->word_char = IS_WORD_CHAR (token->opr.c);
1975 1896
1976 switch (c) 1897 switch (c)
@@ -2017,8 +1938,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2017 token->type = OP_PERIOD; 1938 token->type = OP_PERIOD;
2018 break; 1939 break;
2019 case '^': 1940 case '^':
2020 if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && 1941 if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE))
2021 re_string_cur_idx (input) != 0) 1942 && re_string_cur_idx (input) != 0)
2022 { 1943 {
2023 char prev = re_string_peek_byte (input, -1); 1944 char prev = re_string_peek_byte (input, -1);
2024 if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') 1945 if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
@@ -2028,8 +1949,8 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2028 token->opr.ctx_type = LINE_FIRST; 1949 token->opr.ctx_type = LINE_FIRST;
2029 break; 1950 break;
2030 case '$': 1951 case '$':
2031 if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && 1952 if (!(syntax & RE_CONTEXT_INDEP_ANCHORS)
2032 re_string_cur_idx (input) + 1 != re_string_length (input)) 1953 && re_string_cur_idx (input) + 1 != re_string_length (input))
2033 { 1954 {
2034 re_token_t next; 1955 re_token_t next;
2035 re_string_skip_bytes (input, 1); 1956 re_string_skip_bytes (input, 1);
@@ -2051,7 +1972,6 @@ peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2051 We must not use this function out of bracket expressions. */ 1972 We must not use this function out of bracket expressions. */
2052 1973
2053static int 1974static int
2054internal_function
2055peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) 1975peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2056{ 1976{
2057 unsigned char c; 1977 unsigned char c;
@@ -2063,14 +1983,12 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2063 c = re_string_peek_byte (input, 0); 1983 c = re_string_peek_byte (input, 0);
2064 token->opr.c = c; 1984 token->opr.c = c;
2065 1985
2066#ifdef RE_ENABLE_I18N 1986 if (input->mb_cur_max > 1
2067 if (input->mb_cur_max > 1 && 1987 && !re_string_first_byte (input, re_string_cur_idx (input)))
2068 !re_string_first_byte (input, re_string_cur_idx (input)))
2069 { 1988 {
2070 token->type = CHARACTER; 1989 token->type = CHARACTER;
2071 return 1; 1990 return 1;
2072 } 1991 }
2073#endif /* RE_ENABLE_I18N */
2074 1992
2075 if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) 1993 if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
2076 && re_string_cur_idx (input) + 1 < re_string_length (input)) 1994 && re_string_cur_idx (input) + 1 < re_string_length (input))
@@ -2098,16 +2016,18 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2098 case '.': 2016 case '.':
2099 token->type = OP_OPEN_COLL_ELEM; 2017 token->type = OP_OPEN_COLL_ELEM;
2100 break; 2018 break;
2019
2101 case '=': 2020 case '=':
2102 token->type = OP_OPEN_EQUIV_CLASS; 2021 token->type = OP_OPEN_EQUIV_CLASS;
2103 break; 2022 break;
2023
2104 case ':': 2024 case ':':
2105 if (syntax & RE_CHAR_CLASSES) 2025 if (syntax & RE_CHAR_CLASSES)
2106 { 2026 {
2107 token->type = OP_OPEN_CHAR_CLASS; 2027 token->type = OP_OPEN_CHAR_CLASS;
2108 break; 2028 break;
2109 } 2029 }
2110 /* else fall through. */ 2030 FALLTHROUGH;
2111 default: 2031 default:
2112 token->type = CHARACTER; 2032 token->type = CHARACTER;
2113 token->opr.c = c; 2033 token->opr.c = c;
@@ -2118,15 +2038,25 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2118 } 2038 }
2119 switch (c) 2039 switch (c)
2120 { 2040 {
2121 case '-':
2122 token->type = OP_CHARSET_RANGE;
2123 break;
2124 case ']': 2041 case ']':
2125 token->type = OP_CLOSE_BRACKET; 2042 token->type = OP_CLOSE_BRACKET;
2126 break; 2043 break;
2127 case '^': 2044 case '^':
2128 token->type = OP_NON_MATCH_LIST; 2045 token->type = OP_NON_MATCH_LIST;
2129 break; 2046 break;
2047 case '-':
2048 /* In V7 Unix grep and Unix awk and mawk, [...---...]
2049 (3 adjacent minus signs) stands for a single minus sign.
2050 Support that without breaking anything else. */
2051 if (! (re_string_cur_idx (input) + 2 < re_string_length (input)
2052 && re_string_peek_byte (input, 1) == '-'
2053 && re_string_peek_byte (input, 2) == '-'))
2054 {
2055 token->type = OP_CHARSET_RANGE;
2056 break;
2057 }
2058 re_string_skip_bytes (input, 2);
2059 FALLTHROUGH;
2130 default: 2060 default:
2131 token->type = CHARACTER; 2061 token->type = CHARACTER;
2132 } 2062 }
@@ -2157,14 +2087,14 @@ parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
2157 dfa->syntax = syntax; 2087 dfa->syntax = syntax;
2158 fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE); 2088 fetch_token (&current_token, regexp, syntax | RE_CARET_ANCHORS_HERE);
2159 tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err); 2089 tree = parse_reg_exp (regexp, preg, &current_token, syntax, 0, err);
2160 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2090 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2161 return NULL; 2091 return NULL;
2162 eor = create_tree (dfa, NULL, NULL, END_OF_RE); 2092 eor = create_tree (dfa, NULL, NULL, END_OF_RE);
2163 if (tree != NULL) 2093 if (tree != NULL)
2164 root = create_tree (dfa, tree, eor, CONCAT); 2094 root = create_tree (dfa, tree, eor, CONCAT);
2165 else 2095 else
2166 root = eor; 2096 root = eor;
2167 if (BE (eor == NULL || root == NULL, 0)) 2097 if (__glibc_unlikely (eor == NULL || root == NULL))
2168 { 2098 {
2169 *err = REG_ESPACE; 2099 *err = REG_ESPACE;
2170 return NULL; 2100 return NULL;
@@ -2187,8 +2117,9 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2187{ 2117{
2188 re_dfa_t *dfa = preg->buffer; 2118 re_dfa_t *dfa = preg->buffer;
2189 bin_tree_t *tree, *branch = NULL; 2119 bin_tree_t *tree, *branch = NULL;
2120 bitset_word_t initial_bkref_map = dfa->completed_bkref_map;
2190 tree = parse_branch (regexp, preg, token, syntax, nest, err); 2121 tree = parse_branch (regexp, preg, token, syntax, nest, err);
2191 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2122 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2192 return NULL; 2123 return NULL;
2193 2124
2194 while (token->type == OP_ALT) 2125 while (token->type == OP_ALT)
@@ -2197,14 +2128,21 @@ parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2197 if (token->type != OP_ALT && token->type != END_OF_RE 2128 if (token->type != OP_ALT && token->type != END_OF_RE
2198 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) 2129 && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
2199 { 2130 {
2131 bitset_word_t accumulated_bkref_map = dfa->completed_bkref_map;
2132 dfa->completed_bkref_map = initial_bkref_map;
2200 branch = parse_branch (regexp, preg, token, syntax, nest, err); 2133 branch = parse_branch (regexp, preg, token, syntax, nest, err);
2201 if (BE (*err != REG_NOERROR && branch == NULL, 0)) 2134 if (__glibc_unlikely (*err != REG_NOERROR && branch == NULL))
2202 return NULL; 2135 {
2136 if (tree != NULL)
2137 postorder (tree, free_tree, NULL);
2138 return NULL;
2139 }
2140 dfa->completed_bkref_map |= accumulated_bkref_map;
2203 } 2141 }
2204 else 2142 else
2205 branch = NULL; 2143 branch = NULL;
2206 tree = create_tree (dfa, tree, branch, OP_ALT); 2144 tree = create_tree (dfa, tree, branch, OP_ALT);
2207 if (BE (tree == NULL, 0)) 2145 if (__glibc_unlikely (tree == NULL))
2208 { 2146 {
2209 *err = REG_ESPACE; 2147 *err = REG_ESPACE;
2210 return NULL; 2148 return NULL;
@@ -2229,14 +2167,14 @@ parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
2229 bin_tree_t *tree, *expr; 2167 bin_tree_t *tree, *expr;
2230 re_dfa_t *dfa = preg->buffer; 2168 re_dfa_t *dfa = preg->buffer;
2231 tree = parse_expression (regexp, preg, token, syntax, nest, err); 2169 tree = parse_expression (regexp, preg, token, syntax, nest, err);
2232 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2170 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2233 return NULL; 2171 return NULL;
2234 2172
2235 while (token->type != OP_ALT && token->type != END_OF_RE 2173 while (token->type != OP_ALT && token->type != END_OF_RE
2236 && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) 2174 && (nest == 0 || token->type != OP_CLOSE_SUBEXP))
2237 { 2175 {
2238 expr = parse_expression (regexp, preg, token, syntax, nest, err); 2176 expr = parse_expression (regexp, preg, token, syntax, nest, err);
2239 if (BE (*err != REG_NOERROR && expr == NULL, 0)) 2177 if (__glibc_unlikely (*err != REG_NOERROR && expr == NULL))
2240 { 2178 {
2241 if (tree != NULL) 2179 if (tree != NULL)
2242 postorder (tree, free_tree, NULL); 2180 postorder (tree, free_tree, NULL);
@@ -2277,12 +2215,11 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2277 { 2215 {
2278 case CHARACTER: 2216 case CHARACTER:
2279 tree = create_token_tree (dfa, NULL, NULL, token); 2217 tree = create_token_tree (dfa, NULL, NULL, token);
2280 if (BE (tree == NULL, 0)) 2218 if (__glibc_unlikely (tree == NULL))
2281 { 2219 {
2282 *err = REG_ESPACE; 2220 *err = REG_ESPACE;
2283 return NULL; 2221 return NULL;
2284 } 2222 }
2285#ifdef RE_ENABLE_I18N
2286 if (dfa->mb_cur_max > 1) 2223 if (dfa->mb_cur_max > 1)
2287 { 2224 {
2288 while (!re_string_eoi (regexp) 2225 while (!re_string_eoi (regexp)
@@ -2292,34 +2229,36 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2292 fetch_token (token, regexp, syntax); 2229 fetch_token (token, regexp, syntax);
2293 mbc_remain = create_token_tree (dfa, NULL, NULL, token); 2230 mbc_remain = create_token_tree (dfa, NULL, NULL, token);
2294 tree = create_tree (dfa, tree, mbc_remain, CONCAT); 2231 tree = create_tree (dfa, tree, mbc_remain, CONCAT);
2295 if (BE (mbc_remain == NULL || tree == NULL, 0)) 2232 if (__glibc_unlikely (mbc_remain == NULL || tree == NULL))
2296 { 2233 {
2297 *err = REG_ESPACE; 2234 *err = REG_ESPACE;
2298 return NULL; 2235 return NULL;
2299 } 2236 }
2300 } 2237 }
2301 } 2238 }
2302#endif
2303 break; 2239 break;
2240
2304 case OP_OPEN_SUBEXP: 2241 case OP_OPEN_SUBEXP:
2305 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); 2242 tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err);
2306 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2243 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2307 return NULL; 2244 return NULL;
2308 break; 2245 break;
2246
2309 case OP_OPEN_BRACKET: 2247 case OP_OPEN_BRACKET:
2310 tree = parse_bracket_exp (regexp, dfa, token, syntax, err); 2248 tree = parse_bracket_exp (regexp, dfa, token, syntax, err);
2311 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2249 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2312 return NULL; 2250 return NULL;
2313 break; 2251 break;
2252
2314 case OP_BACK_REF: 2253 case OP_BACK_REF:
2315 if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) 2254 if (!__glibc_likely (dfa->completed_bkref_map & (1 << token->opr.idx)))
2316 { 2255 {
2317 *err = REG_ESUBREG; 2256 *err = REG_ESUBREG;
2318 return NULL; 2257 return NULL;
2319 } 2258 }
2320 dfa->used_bkref_map |= 1 << token->opr.idx; 2259 dfa->used_bkref_map |= 1 << token->opr.idx;
2321 tree = create_token_tree (dfa, NULL, NULL, token); 2260 tree = create_token_tree (dfa, NULL, NULL, token);
2322 if (BE (tree == NULL, 0)) 2261 if (__glibc_unlikely (tree == NULL))
2323 { 2262 {
2324 *err = REG_ESPACE; 2263 *err = REG_ESPACE;
2325 return NULL; 2264 return NULL;
@@ -2327,13 +2266,14 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2327 ++dfa->nbackref; 2266 ++dfa->nbackref;
2328 dfa->has_mb_node = 1; 2267 dfa->has_mb_node = 1;
2329 break; 2268 break;
2269
2330 case OP_OPEN_DUP_NUM: 2270 case OP_OPEN_DUP_NUM:
2331 if (syntax & RE_CONTEXT_INVALID_DUP) 2271 if (syntax & RE_CONTEXT_INVALID_DUP)
2332 { 2272 {
2333 *err = REG_BADRPT; 2273 *err = REG_BADRPT;
2334 return NULL; 2274 return NULL;
2335 } 2275 }
2336 /* FALLTHROUGH */ 2276 FALLTHROUGH;
2337 case OP_DUP_ASTERISK: 2277 case OP_DUP_ASTERISK:
2338 case OP_DUP_PLUS: 2278 case OP_DUP_PLUS:
2339 case OP_DUP_QUESTION: 2279 case OP_DUP_QUESTION:
@@ -2347,15 +2287,15 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2347 fetch_token (token, regexp, syntax); 2287 fetch_token (token, regexp, syntax);
2348 return parse_expression (regexp, preg, token, syntax, nest, err); 2288 return parse_expression (regexp, preg, token, syntax, nest, err);
2349 } 2289 }
2350 /* else fall through */ 2290 FALLTHROUGH;
2351 case OP_CLOSE_SUBEXP: 2291 case OP_CLOSE_SUBEXP:
2352 if ((token->type == OP_CLOSE_SUBEXP) && 2292 if ((token->type == OP_CLOSE_SUBEXP)
2353 !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) 2293 && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
2354 { 2294 {
2355 *err = REG_ERPAREN; 2295 *err = REG_ERPAREN;
2356 return NULL; 2296 return NULL;
2357 } 2297 }
2358 /* else fall through */ 2298 FALLTHROUGH;
2359 case OP_CLOSE_DUP_NUM: 2299 case OP_CLOSE_DUP_NUM:
2360 /* We treat it as a normal character. */ 2300 /* We treat it as a normal character. */
2361 2301
@@ -2364,12 +2304,13 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2364 /* mb_partial and word_char bits should be initialized already 2304 /* mb_partial and word_char bits should be initialized already
2365 by peek_token. */ 2305 by peek_token. */
2366 tree = create_token_tree (dfa, NULL, NULL, token); 2306 tree = create_token_tree (dfa, NULL, NULL, token);
2367 if (BE (tree == NULL, 0)) 2307 if (__glibc_unlikely (tree == NULL))
2368 { 2308 {
2369 *err = REG_ESPACE; 2309 *err = REG_ESPACE;
2370 return NULL; 2310 return NULL;
2371 } 2311 }
2372 break; 2312 break;
2313
2373 case ANCHOR: 2314 case ANCHOR:
2374 if ((token->opr.ctx_type 2315 if ((token->opr.ctx_type
2375 & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) 2316 & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST))
@@ -2393,7 +2334,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2393 } 2334 }
2394 tree_last = create_token_tree (dfa, NULL, NULL, token); 2335 tree_last = create_token_tree (dfa, NULL, NULL, token);
2395 tree = create_tree (dfa, tree_first, tree_last, OP_ALT); 2336 tree = create_tree (dfa, tree_first, tree_last, OP_ALT);
2396 if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) 2337 if (__glibc_unlikely (tree_first == NULL || tree_last == NULL
2338 || tree == NULL))
2397 { 2339 {
2398 *err = REG_ESPACE; 2340 *err = REG_ESPACE;
2399 return NULL; 2341 return NULL;
@@ -2402,7 +2344,7 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2402 else 2344 else
2403 { 2345 {
2404 tree = create_token_tree (dfa, NULL, NULL, token); 2346 tree = create_token_tree (dfa, NULL, NULL, token);
2405 if (BE (tree == NULL, 0)) 2347 if (__glibc_unlikely (tree == NULL))
2406 { 2348 {
2407 *err = REG_ESPACE; 2349 *err = REG_ESPACE;
2408 return NULL; 2350 return NULL;
@@ -2414,9 +2356,10 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2414 it must not be "<ANCHOR(^)><REPEAT(*)>". */ 2356 it must not be "<ANCHOR(^)><REPEAT(*)>". */
2415 fetch_token (token, regexp, syntax); 2357 fetch_token (token, regexp, syntax);
2416 return tree; 2358 return tree;
2359
2417 case OP_PERIOD: 2360 case OP_PERIOD:
2418 tree = create_token_tree (dfa, NULL, NULL, token); 2361 tree = create_token_tree (dfa, NULL, NULL, token);
2419 if (BE (tree == NULL, 0)) 2362 if (__glibc_unlikely (tree == NULL))
2420 { 2363 {
2421 *err = REG_ESPACE; 2364 *err = REG_ESPACE;
2422 return NULL; 2365 return NULL;
@@ -2424,35 +2367,38 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2424 if (dfa->mb_cur_max > 1) 2367 if (dfa->mb_cur_max > 1)
2425 dfa->has_mb_node = 1; 2368 dfa->has_mb_node = 1;
2426 break; 2369 break;
2370
2427 case OP_WORD: 2371 case OP_WORD:
2428 case OP_NOTWORD: 2372 case OP_NOTWORD:
2429 tree = build_charclass_op (dfa, regexp->trans, 2373 tree = build_charclass_op (dfa, regexp->trans,
2430 "alnum", 2374 "alnum",
2431 "_", 2375 "_",
2432 token->type == OP_NOTWORD, err); 2376 token->type == OP_NOTWORD, err);
2433 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2377 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2434 return NULL; 2378 return NULL;
2435 break; 2379 break;
2380
2436 case OP_SPACE: 2381 case OP_SPACE:
2437 case OP_NOTSPACE: 2382 case OP_NOTSPACE:
2438 tree = build_charclass_op (dfa, regexp->trans, 2383 tree = build_charclass_op (dfa, regexp->trans,
2439 "space", 2384 "space",
2440 "", 2385 "",
2441 token->type == OP_NOTSPACE, err); 2386 token->type == OP_NOTSPACE, err);
2442 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2387 if (__glibc_unlikely (*err != REG_NOERROR && tree == NULL))
2443 return NULL; 2388 return NULL;
2444 break; 2389 break;
2390
2445 case OP_ALT: 2391 case OP_ALT:
2446 case END_OF_RE: 2392 case END_OF_RE:
2447 return NULL; 2393 return NULL;
2394
2448 case BACK_SLASH: 2395 case BACK_SLASH:
2449 *err = REG_EESCAPE; 2396 *err = REG_EESCAPE;
2450 return NULL; 2397 return NULL;
2398
2451 default: 2399 default:
2452 /* Must not happen? */ 2400 /* Must not happen? */
2453#ifdef DEBUG 2401 DEBUG_ASSERT (false);
2454 assert (0);
2455#endif
2456 return NULL; 2402 return NULL;
2457 } 2403 }
2458 fetch_token (token, regexp, syntax); 2404 fetch_token (token, regexp, syntax);
@@ -2460,14 +2406,22 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2460 while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS 2406 while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS
2461 || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) 2407 || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM)
2462 { 2408 {
2463 tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); 2409 bin_tree_t *dup_tree = parse_dup_op (tree, regexp, dfa, token,
2464 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2410 syntax, err);
2465 return NULL; 2411 if (__glibc_unlikely (*err != REG_NOERROR && dup_tree == NULL))
2412 {
2413 if (tree != NULL)
2414 postorder (tree, free_tree, NULL);
2415 return NULL;
2416 }
2417 tree = dup_tree;
2466 /* In BRE consecutive duplications are not allowed. */ 2418 /* In BRE consecutive duplications are not allowed. */
2467 if ((syntax & RE_CONTEXT_INVALID_DUP) 2419 if ((syntax & RE_CONTEXT_INVALID_DUP)
2468 && (token->type == OP_DUP_ASTERISK 2420 && (token->type == OP_DUP_ASTERISK
2469 || token->type == OP_OPEN_DUP_NUM)) 2421 || token->type == OP_OPEN_DUP_NUM))
2470 { 2422 {
2423 if (tree != NULL)
2424 postorder (tree, free_tree, NULL);
2471 *err = REG_BADRPT; 2425 *err = REG_BADRPT;
2472 return NULL; 2426 return NULL;
2473 } 2427 }
@@ -2500,13 +2454,14 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2500 else 2454 else
2501 { 2455 {
2502 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); 2456 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
2503 if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) 2457 if (__glibc_unlikely (*err == REG_NOERROR
2458 && token->type != OP_CLOSE_SUBEXP))
2504 { 2459 {
2505 if (tree != NULL) 2460 if (tree != NULL)
2506 postorder (tree, free_tree, NULL); 2461 postorder (tree, free_tree, NULL);
2507 *err = REG_EPAREN; 2462 *err = REG_EPAREN;
2508 } 2463 }
2509 if (BE (*err != REG_NOERROR, 0)) 2464 if (__glibc_unlikely (*err != REG_NOERROR))
2510 return NULL; 2465 return NULL;
2511 } 2466 }
2512 2467
@@ -2514,7 +2469,7 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2514 dfa->completed_bkref_map |= 1 << cur_nsub; 2469 dfa->completed_bkref_map |= 1 << cur_nsub;
2515 2470
2516 tree = create_tree (dfa, tree, NULL, SUBEXP); 2471 tree = create_tree (dfa, tree, NULL, SUBEXP);
2517 if (BE (tree == NULL, 0)) 2472 if (__glibc_unlikely (tree == NULL))
2518 { 2473 {
2519 *err = REG_ESPACE; 2474 *err = REG_ESPACE;
2520 return NULL; 2475 return NULL;
@@ -2537,7 +2492,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2537 { 2492 {
2538 end = 0; 2493 end = 0;
2539 start = fetch_number (regexp, token, syntax); 2494 start = fetch_number (regexp, token, syntax);
2540 if (start == REG_MISSING) 2495 if (start == -1)
2541 { 2496 {
2542 if (token->type == CHARACTER && token->opr.c == ',') 2497 if (token->type == CHARACTER && token->opr.c == ',')
2543 start = 0; /* We treat "{,m}" as "{0,m}". */ 2498 start = 0; /* We treat "{,m}" as "{0,m}". */
@@ -2547,17 +2502,17 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2547 return NULL; 2502 return NULL;
2548 } 2503 }
2549 } 2504 }
2550 if (BE (start != REG_ERROR, 1)) 2505 if (__glibc_likely (start != -2))
2551 { 2506 {
2552 /* We treat "{n}" as "{n,n}". */ 2507 /* We treat "{n}" as "{n,n}". */
2553 end = ((token->type == OP_CLOSE_DUP_NUM) ? start 2508 end = ((token->type == OP_CLOSE_DUP_NUM) ? start
2554 : ((token->type == CHARACTER && token->opr.c == ',') 2509 : ((token->type == CHARACTER && token->opr.c == ',')
2555 ? fetch_number (regexp, token, syntax) : REG_ERROR)); 2510 ? fetch_number (regexp, token, syntax) : -2));
2556 } 2511 }
2557 if (BE (start == REG_ERROR || end == REG_ERROR, 0)) 2512 if (__glibc_unlikely (start == -2 || end == -2))
2558 { 2513 {
2559 /* Invalid sequence. */ 2514 /* Invalid sequence. */
2560 if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) 2515 if (__glibc_unlikely (!(syntax & RE_INVALID_INTERVAL_ORD)))
2561 { 2516 {
2562 if (token->type == END_OF_RE) 2517 if (token->type == END_OF_RE)
2563 *err = REG_EBRACE; 2518 *err = REG_EBRACE;
@@ -2576,15 +2531,15 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2576 return elem; 2531 return elem;
2577 } 2532 }
2578 2533
2579 if (BE ((end != REG_MISSING && start > end) 2534 if (__glibc_unlikely ((end != -1 && start > end)
2580 || token->type != OP_CLOSE_DUP_NUM, 0)) 2535 || token->type != OP_CLOSE_DUP_NUM))
2581 { 2536 {
2582 /* First number greater than second. */ 2537 /* First number greater than second. */
2583 *err = REG_BADBR; 2538 *err = REG_BADBR;
2584 return NULL; 2539 return NULL;
2585 } 2540 }
2586 2541
2587 if (BE (RE_DUP_MAX < (end == REG_MISSING ? start : end), 0)) 2542 if (__glibc_unlikely (RE_DUP_MAX < (end == -1 ? start : end)))
2588 { 2543 {
2589 *err = REG_ESIZE; 2544 *err = REG_ESIZE;
2590 return NULL; 2545 return NULL;
@@ -2593,28 +2548,28 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2593 else 2548 else
2594 { 2549 {
2595 start = (token->type == OP_DUP_PLUS) ? 1 : 0; 2550 start = (token->type == OP_DUP_PLUS) ? 1 : 0;
2596 end = (token->type == OP_DUP_QUESTION) ? 1 : REG_MISSING; 2551 end = (token->type == OP_DUP_QUESTION) ? 1 : -1;
2597 } 2552 }
2598 2553
2599 fetch_token (token, regexp, syntax); 2554 fetch_token (token, regexp, syntax);
2600 2555
2601 if (BE (elem == NULL, 0)) 2556 if (__glibc_unlikely (elem == NULL))
2602 return NULL; 2557 return NULL;
2603 if (BE (start == 0 && end == 0, 0)) 2558 if (__glibc_unlikely (start == 0 && end == 0))
2604 { 2559 {
2605 postorder (elem, free_tree, NULL); 2560 postorder (elem, free_tree, NULL);
2606 return NULL; 2561 return NULL;
2607 } 2562 }
2608 2563
2609 /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */ 2564 /* Extract "<re>{n,m}" to "<re><re>...<re><re>{0,<m-n>}". */
2610 if (BE (start > 0, 0)) 2565 if (__glibc_unlikely (start > 0))
2611 { 2566 {
2612 tree = elem; 2567 tree = elem;
2613 for (i = 2; i <= start; ++i) 2568 for (i = 2; i <= start; ++i)
2614 { 2569 {
2615 elem = duplicate_tree (elem, dfa); 2570 elem = duplicate_tree (elem, dfa);
2616 tree = create_tree (dfa, tree, elem, CONCAT); 2571 tree = create_tree (dfa, tree, elem, CONCAT);
2617 if (BE (elem == NULL || tree == NULL, 0)) 2572 if (__glibc_unlikely (elem == NULL || tree == NULL))
2618 goto parse_dup_op_espace; 2573 goto parse_dup_op_espace;
2619 } 2574 }
2620 2575
@@ -2623,6 +2578,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2623 2578
2624 /* Duplicate ELEM before it is marked optional. */ 2579 /* Duplicate ELEM before it is marked optional. */
2625 elem = duplicate_tree (elem, dfa); 2580 elem = duplicate_tree (elem, dfa);
2581 if (__glibc_unlikely (elem == NULL))
2582 goto parse_dup_op_espace;
2626 old_tree = tree; 2583 old_tree = tree;
2627 } 2584 }
2628 else 2585 else
@@ -2635,27 +2592,23 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2635 } 2592 }
2636 2593
2637 tree = create_tree (dfa, elem, NULL, 2594 tree = create_tree (dfa, elem, NULL,
2638 (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT)); 2595 (end == -1 ? OP_DUP_ASTERISK : OP_ALT));
2639 if (BE (tree == NULL, 0)) 2596 if (__glibc_unlikely (tree == NULL))
2640 goto parse_dup_op_espace; 2597 goto parse_dup_op_espace;
2641 2598
2642/* From gnulib's "intprops.h": 2599 /* This loop is actually executed only when end != -1,
2643 True if the arithmetic type T is signed. */
2644#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
2645
2646 /* This loop is actually executed only when end != REG_MISSING,
2647 to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have 2600 to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
2648 already created the start+1-th copy. */ 2601 already created the start+1-th copy. */
2649 if (TYPE_SIGNED (Idx) || end != REG_MISSING) 2602 if (TYPE_SIGNED (Idx) || end != -1)
2650 for (i = start + 2; i <= end; ++i) 2603 for (i = start + 2; i <= end; ++i)
2651 { 2604 {
2652 elem = duplicate_tree (elem, dfa); 2605 elem = duplicate_tree (elem, dfa);
2653 tree = create_tree (dfa, tree, elem, CONCAT); 2606 tree = create_tree (dfa, tree, elem, CONCAT);
2654 if (BE (elem == NULL || tree == NULL, 0)) 2607 if (__glibc_unlikely (elem == NULL || tree == NULL))
2655 goto parse_dup_op_espace; 2608 goto parse_dup_op_espace;
2656 2609
2657 tree = create_tree (dfa, tree, NULL, OP_ALT); 2610 tree = create_tree (dfa, tree, NULL, OP_ALT);
2658 if (BE (tree == NULL, 0)) 2611 if (__glibc_unlikely (tree == NULL))
2659 goto parse_dup_op_espace; 2612 goto parse_dup_op_espace;
2660 } 2613 }
2661 2614
@@ -2674,146 +2627,131 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2674#define BRACKET_NAME_BUF_SIZE 32 2627#define BRACKET_NAME_BUF_SIZE 32
2675 2628
2676#ifndef _LIBC 2629#ifndef _LIBC
2677 /* Local function for parse_bracket_exp only used in case of NOT _LIBC. 2630
2678 Build the range expression which starts from START_ELEM, and ends 2631/* Convert the byte B to the corresponding wide character. In a
2679 at END_ELEM. The result are written to MBCSET and SBCSET. 2632 unibyte locale, treat B as itself. In a multibyte locale, return
2680 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2633 WEOF if B is an encoding error. */
2681 mbcset->range_ends, is a pointer argument since we may 2634static wint_t
2682 update it. */ 2635parse_byte (unsigned char b, re_dfa_t const *dfa)
2636{
2637 return dfa->mb_cur_max > 1 ? __btowc (b) : b;
2638}
2639
2640/* Local function for parse_bracket_exp used in _LIBC environment.
2641 Build the range expression which starts from START_ELEM, and ends
2642 at END_ELEM. The result are written to MBCSET and SBCSET.
2643 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2644 mbcset->range_ends, is a pointer argument since we may
2645 update it. */
2683 2646
2684static reg_errcode_t 2647static reg_errcode_t
2685internal_function 2648build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
2686# ifdef RE_ENABLE_I18N 2649 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
2687build_range_exp (const reg_syntax_t syntax, 2650 re_dfa_t *dfa, reg_syntax_t syntax, uint_fast32_t nrules,
2688 bitset_t sbcset, 2651 const unsigned char *collseqmb, const char *collseqwc,
2689 re_charset_t *mbcset, 2652 int_fast32_t table_size, const void *symb_table,
2690 Idx *range_alloc, 2653 const unsigned char *extra)
2691 const bracket_elem_t *start_elem,
2692 const bracket_elem_t *end_elem)
2693# else /* not RE_ENABLE_I18N */
2694build_range_exp (const reg_syntax_t syntax,
2695 bitset_t sbcset,
2696 const bracket_elem_t *start_elem,
2697 const bracket_elem_t *end_elem)
2698# endif /* not RE_ENABLE_I18N */
2699{ 2654{
2700 unsigned int start_ch, end_ch;
2701 /* Equivalence Classes and Character Classes can't be a range start/end. */ 2655 /* Equivalence Classes and Character Classes can't be a range start/end. */
2702 if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS 2656 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2703 || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 2657 || start_elem->type == CHAR_CLASS
2704 0)) 2658 || end_elem->type == EQUIV_CLASS
2659 || end_elem->type == CHAR_CLASS))
2705 return REG_ERANGE; 2660 return REG_ERANGE;
2706 2661
2707 /* We can handle no multi character collating elements without libc 2662 /* We can handle no multi character collating elements without libc
2708 support. */ 2663 support. */
2709 if (BE ((start_elem->type == COLL_SYM 2664 if (__glibc_unlikely ((start_elem->type == COLL_SYM
2710 && strlen ((char *) start_elem->opr.name) > 1) 2665 && strlen ((char *) start_elem->opr.name) > 1)
2711 || (end_elem->type == COLL_SYM 2666 || (end_elem->type == COLL_SYM
2712 && strlen ((char *) end_elem->opr.name) > 1), 0)) 2667 && strlen ((char *) end_elem->opr.name) > 1)))
2713 return REG_ECOLLATE; 2668 return REG_ECOLLATE;
2714 2669
2715# ifdef RE_ENABLE_I18N 2670 unsigned int
2716 {
2717 wchar_t wc;
2718 wint_t start_wc;
2719 wint_t end_wc;
2720
2721 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch 2671 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
2722 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] 2672 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
2723 : 0)); 2673 : 0)),
2724 end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch 2674 end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch
2725 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] 2675 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
2726 : 0)); 2676 : 0));
2677 wint_t
2727 start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) 2678 start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM)
2728 ? __btowc (start_ch) : start_elem->opr.wch); 2679 ? parse_byte (start_ch, dfa) : start_elem->opr.wch),
2729 end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) 2680 end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM)
2730 ? __btowc (end_ch) : end_elem->opr.wch); 2681 ? parse_byte (end_ch, dfa) : end_elem->opr.wch);
2731 if (start_wc == WEOF || end_wc == WEOF)
2732 return REG_ECOLLATE;
2733 else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
2734 return REG_ERANGE;
2735
2736 /* Got valid collation sequence values, add them as a new entry.
2737 However, for !_LIBC we have no collation elements: if the
2738 character set is single byte, the single byte character set
2739 that we build below suffices. parse_bracket_exp passes
2740 no MBCSET if dfa->mb_cur_max == 1. */
2741 if (mbcset)
2742 {
2743 /* Check the space of the arrays. */
2744 if (BE (*range_alloc == mbcset->nranges, 0))
2745 {
2746 /* There is not enough space, need realloc. */
2747 wchar_t *new_array_start, *new_array_end;
2748 Idx new_nranges;
2749
2750 /* +1 in case of mbcset->nranges is 0. */
2751 new_nranges = 2 * mbcset->nranges + 1;
2752 /* Use realloc since mbcset->range_starts and mbcset->range_ends
2753 are NULL if *range_alloc == 0. */
2754 new_array_start = re_realloc (mbcset->range_starts, wchar_t,
2755 new_nranges);
2756 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2757 new_nranges);
2758 2682
2759 if (BE (new_array_start == NULL || new_array_end == NULL, 0)) 2683 if (start_wc == WEOF || end_wc == WEOF)
2760 return REG_ESPACE; 2684 return REG_ECOLLATE;
2685 else if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2686 && start_wc > end_wc))
2687 return REG_ERANGE;
2761 2688
2762 mbcset->range_starts = new_array_start; 2689 /* Got valid collation sequence values, add them as a new entry.
2763 mbcset->range_ends = new_array_end; 2690 However, for !_LIBC we have no collation elements: if the
2764 *range_alloc = new_nranges; 2691 character set is single byte, the single byte character set
2765 } 2692 that we build below suffices. parse_bracket_exp passes
2693 no MBCSET if dfa->mb_cur_max == 1. */
2694 if (dfa->mb_cur_max > 1)
2695 {
2696 /* Check the space of the arrays. */
2697 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2698 {
2699 /* There is not enough space, need realloc. */
2700 wchar_t *new_array_start, *new_array_end;
2701 Idx new_nranges;
2766 2702
2767 mbcset->range_starts[mbcset->nranges] = start_wc; 2703 /* +1 in case of mbcset->nranges is 0. */
2768 mbcset->range_ends[mbcset->nranges++] = end_wc; 2704 new_nranges = 2 * mbcset->nranges + 1;
2769 } 2705 /* Use realloc since mbcset->range_starts and mbcset->range_ends
2706 are NULL if *range_alloc == 0. */
2707 new_array_start = re_realloc (mbcset->range_starts, wchar_t,
2708 new_nranges);
2709 new_array_end = re_realloc (mbcset->range_ends, wchar_t,
2710 new_nranges);
2711
2712 if (__glibc_unlikely (new_array_start == NULL
2713 || new_array_end == NULL))
2714 {
2715 re_free (new_array_start);
2716 re_free (new_array_end);
2717 return REG_ESPACE;
2718 }
2719
2720 mbcset->range_starts = new_array_start;
2721 mbcset->range_ends = new_array_end;
2722 *range_alloc = new_nranges;
2723 }
2724
2725 mbcset->range_starts[mbcset->nranges] = start_wc;
2726 mbcset->range_ends[mbcset->nranges++] = end_wc;
2727 }
2728
2729 /* Build the table for single byte characters. */
2730 for (wchar_t wc = 0; wc < SBC_MAX; ++wc)
2731 {
2732 if (start_wc <= wc && wc <= end_wc)
2733 bitset_set (sbcset, wc);
2734 }
2770 2735
2771 /* Build the table for single byte characters. */
2772 for (wc = 0; wc < SBC_MAX; ++wc)
2773 {
2774 if (start_wc <= wc && wc <= end_wc)
2775 bitset_set (sbcset, wc);
2776 }
2777 }
2778# else /* not RE_ENABLE_I18N */
2779 {
2780 unsigned int ch;
2781 start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch
2782 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
2783 : 0));
2784 end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch
2785 : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0]
2786 : 0));
2787 if (start_ch > end_ch)
2788 return REG_ERANGE;
2789 /* Build the table for single byte characters. */
2790 for (ch = 0; ch < SBC_MAX; ++ch)
2791 if (start_ch <= ch && ch <= end_ch)
2792 bitset_set (sbcset, ch);
2793 }
2794# endif /* not RE_ENABLE_I18N */
2795 return REG_NOERROR; 2736 return REG_NOERROR;
2796} 2737}
2797#endif /* not _LIBC */ 2738#endif /* not _LIBC */
2798 2739
2799#ifndef _LIBC 2740#ifndef _LIBC
2800/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. 2741/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.
2801 Build the collating element which is represented by NAME. 2742 Build the collating element which is represented by NAME.
2802 The result are written to MBCSET and SBCSET. 2743 The result are written to MBCSET and SBCSET.
2803 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 2744 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2804 pointer argument since we may update it. */ 2745 pointer argument since we may update it. */
2805 2746
2806static reg_errcode_t 2747static reg_errcode_t
2807internal_function
2808# ifdef RE_ENABLE_I18N
2809build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, 2748build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2810 Idx *coll_sym_alloc, const unsigned char *name) 2749 Idx *coll_sym_alloc, const unsigned char *name,
2811# else /* not RE_ENABLE_I18N */ 2750 uint_fast32_t nrules, int_fast32_t table_size,
2812build_collating_symbol (bitset_t sbcset, const unsigned char *name) 2751 const void *symb_table, const unsigned char *extra)
2813# endif /* not RE_ENABLE_I18N */
2814{ 2752{
2815 size_t name_len = strlen ((const char *) name); 2753 size_t name_len = strlen ((const char *) name);
2816 if (BE (name_len != 1, 0)) 2754 if (__glibc_unlikely (name_len != 1))
2817 return REG_ECOLLATE; 2755 return REG_ECOLLATE;
2818 else 2756 else
2819 { 2757 {
@@ -2823,267 +2761,280 @@ build_collating_symbol (bitset_t sbcset, const unsigned char *name)
2823} 2761}
2824#endif /* not _LIBC */ 2762#endif /* not _LIBC */
2825 2763
2826/* This function parse bracket expression like "[abc]", "[a-c]",
2827 "[[.a-a.]]" etc. */
2828
2829static bin_tree_t *
2830parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2831 reg_syntax_t syntax, reg_errcode_t *err)
2832{
2833#ifdef _LIBC 2764#ifdef _LIBC
2834 const unsigned char *collseqmb; 2765/* Local function for parse_bracket_exp used in _LIBC environment.
2835 const char *collseqwc; 2766 Seek the collating symbol entry corresponding to NAME.
2836 uint32_t nrules; 2767 Return the index of the symbol in the SYMB_TABLE,
2837 int32_t table_size; 2768 or -1 if not found. */
2838 const int32_t *symb_table; 2769
2839 const unsigned char *extra; 2770static __always_inline int32_t
2840 2771seek_collating_symbol_entry (const unsigned char *name, size_t name_len,
2841 /* Local function for parse_bracket_exp used in _LIBC environment. 2772 const int32_t *symb_table,
2842 Seek the collating symbol entry corresponding to NAME. 2773 int_fast32_t table_size,
2843 Return the index of the symbol in the SYMB_TABLE, 2774 const unsigned char *extra)
2844 or -1 if not found. */ 2775{
2845 2776 int_fast32_t elem;
2846 auto inline int32_t
2847 __attribute__ ((always_inline))
2848 seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
2849 {
2850 int32_t elem;
2851
2852 for (elem = 0; elem < table_size; elem++)
2853 if (symb_table[2 * elem] != 0)
2854 {
2855 int32_t idx = symb_table[2 * elem + 1];
2856 /* Skip the name of collating element name. */
2857 idx += 1 + extra[idx];
2858 if (/* Compare the length of the name. */
2859 name_len == extra[idx]
2860 /* Compare the name. */
2861 && memcmp (name, &extra[idx + 1], name_len) == 0)
2862 /* Yep, this is the entry. */
2863 return elem;
2864 }
2865 return -1;
2866 }
2867 2777
2868 /* Local function for parse_bracket_exp used in _LIBC environment. 2778 for (elem = 0; elem < table_size; elem++)
2869 Look up the collation sequence value of BR_ELEM. 2779 if (symb_table[2 * elem] != 0)
2870 Return the value if succeeded, UINT_MAX otherwise. */ 2780 {
2781 int32_t idx = symb_table[2 * elem + 1];
2782 /* Skip the name of collating element name. */
2783 idx += 1 + extra[idx];
2784 if (/* Compare the length of the name. */
2785 name_len == extra[idx]
2786 /* Compare the name. */
2787 && memcmp (name, &extra[idx + 1], name_len) == 0)
2788 /* Yep, this is the entry. */
2789 return elem;
2790 }
2791 return -1;
2792}
2871 2793
2872 auto inline unsigned int 2794/* Local function for parse_bracket_exp used in _LIBC environment.
2873 __attribute__ ((always_inline)) 2795 Look up the collation sequence value of BR_ELEM.
2874 lookup_collation_sequence_value (bracket_elem_t *br_elem) 2796 Return the value if succeeded, UINT_MAX otherwise. */
2797
2798static __always_inline unsigned int
2799lookup_collation_sequence_value (bracket_elem_t *br_elem, uint32_t nrules,
2800 const unsigned char *collseqmb,
2801 const char *collseqwc,
2802 int_fast32_t table_size,
2803 const int32_t *symb_table,
2804 const unsigned char *extra)
2805{
2806 if (br_elem->type == SB_CHAR)
2875 { 2807 {
2876 if (br_elem->type == SB_CHAR) 2808 /* if (MB_CUR_MAX == 1) */
2877 { 2809 if (nrules == 0)
2878 /* 2810 return collseqmb[br_elem->opr.ch];
2879 if (MB_CUR_MAX == 1) 2811 else
2880 */
2881 if (nrules == 0)
2882 return collseqmb[br_elem->opr.ch];
2883 else
2884 {
2885 wint_t wc = __btowc (br_elem->opr.ch);
2886 return __collseq_table_lookup (collseqwc, wc);
2887 }
2888 }
2889 else if (br_elem->type == MB_CHAR)
2890 { 2812 {
2891 if (nrules != 0) 2813 wint_t wc = __btowc (br_elem->opr.ch);
2892 return __collseq_table_lookup (collseqwc, br_elem->opr.wch); 2814 return __collseq_table_lookup (collseqwc, wc);
2893 } 2815 }
2894 else if (br_elem->type == COLL_SYM) 2816 }
2817 else if (br_elem->type == MB_CHAR)
2818 {
2819 if (nrules != 0)
2820 return __collseq_table_lookup (collseqwc, br_elem->opr.wch);
2821 }
2822 else if (br_elem->type == COLL_SYM)
2823 {
2824 size_t sym_name_len = strlen ((char *) br_elem->opr.name);
2825 if (nrules != 0)
2895 { 2826 {
2896 size_t sym_name_len = strlen ((char *) br_elem->opr.name); 2827 int32_t elem, idx;
2897 if (nrules != 0) 2828 elem = seek_collating_symbol_entry (br_elem->opr.name,
2829 sym_name_len,
2830 symb_table, table_size,
2831 extra);
2832 if (elem != -1)
2898 { 2833 {
2899 int32_t elem, idx; 2834 /* We found the entry. */
2900 elem = seek_collating_symbol_entry (br_elem->opr.name, 2835 idx = symb_table[2 * elem + 1];
2901 sym_name_len); 2836 /* Skip the name of collating element name. */
2902 if (elem != -1) 2837 idx += 1 + extra[idx];
2903 { 2838 /* Skip the byte sequence of the collating element. */
2904 /* We found the entry. */ 2839 idx += 1 + extra[idx];
2905 idx = symb_table[2 * elem + 1]; 2840 /* Adjust for the alignment. */
2906 /* Skip the name of collating element name. */ 2841 idx = (idx + 3) & ~3;
2907 idx += 1 + extra[idx]; 2842 /* Skip the multibyte collation sequence value. */
2908 /* Skip the byte sequence of the collating element. */ 2843 idx += sizeof (unsigned int);
2909 idx += 1 + extra[idx]; 2844 /* Skip the wide char sequence of the collating element. */
2910 /* Adjust for the alignment. */ 2845 idx += sizeof (unsigned int) *
2911 idx = (idx + 3) & ~3; 2846 (1 + *(unsigned int *) (extra + idx));
2912 /* Skip the multibyte collation sequence value. */ 2847 /* Return the collation sequence value. */
2913 idx += sizeof (unsigned int); 2848 return *(unsigned int *) (extra + idx);
2914 /* Skip the wide char sequence of the collating element. */
2915 idx += sizeof (unsigned int) *
2916 (1 + *(unsigned int *) (extra + idx));
2917 /* Return the collation sequence value. */
2918 return *(unsigned int *) (extra + idx);
2919 }
2920 else if (sym_name_len == 1)
2921 {
2922 /* No valid character. Match it as a single byte
2923 character. */
2924 return collseqmb[br_elem->opr.name[0]];
2925 }
2926 } 2849 }
2927 else if (sym_name_len == 1) 2850 else if (sym_name_len == 1)
2928 return collseqmb[br_elem->opr.name[0]]; 2851 {
2852 /* No valid character. Match it as a single byte
2853 character. */
2854 return collseqmb[br_elem->opr.name[0]];
2855 }
2929 } 2856 }
2930 return UINT_MAX; 2857 else if (sym_name_len == 1)
2858 return collseqmb[br_elem->opr.name[0]];
2931 } 2859 }
2860 return UINT_MAX;
2861}
2932 2862
2933 /* Local function for parse_bracket_exp used in _LIBC environment. 2863/* Local function for parse_bracket_exp used in _LIBC environment.
2934 Build the range expression which starts from START_ELEM, and ends 2864 Build the range expression which starts from START_ELEM, and ends
2935 at END_ELEM. The result are written to MBCSET and SBCSET. 2865 at END_ELEM. The result are written to MBCSET and SBCSET.
2936 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2866 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2937 mbcset->range_ends, is a pointer argument since we may 2867 mbcset->range_ends, is a pointer argument since we may
2938 update it. */ 2868 update it. */
2939 2869
2940 auto inline reg_errcode_t 2870static __always_inline reg_errcode_t
2941 __attribute__ ((always_inline)) 2871build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
2942 build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, 2872 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
2943 bracket_elem_t *start_elem, bracket_elem_t *end_elem) 2873 re_dfa_t *dfa, reg_syntax_t syntax, uint32_t nrules,
2944 { 2874 const unsigned char *collseqmb, const char *collseqwc,
2945 unsigned int ch; 2875 int_fast32_t table_size, const int32_t *symb_table,
2946 uint32_t start_collseq; 2876 const unsigned char *extra)
2947 uint32_t end_collseq; 2877{
2948 2878 unsigned int ch;
2949 /* Equivalence Classes and Character Classes can't be a range 2879 uint32_t start_collseq;
2950 start/end. */ 2880 uint32_t end_collseq;
2951 if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS 2881
2952 || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, 2882 /* Equivalence Classes and Character Classes can't be a range
2953 0)) 2883 start/end. */
2954 return REG_ERANGE; 2884 if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
2885 || start_elem->type == CHAR_CLASS
2886 || end_elem->type == EQUIV_CLASS
2887 || end_elem->type == CHAR_CLASS))
2888 return REG_ERANGE;
2955 2889
2956 /* FIXME: Implement rational ranges here, too. */ 2890 /* FIXME: Implement rational ranges here, too. */
2957 start_collseq = lookup_collation_sequence_value (start_elem); 2891 start_collseq = lookup_collation_sequence_value (start_elem, nrules, collseqmb, collseqwc,
2958 end_collseq = lookup_collation_sequence_value (end_elem); 2892 table_size, symb_table, extra);
2959 /* Check start/end collation sequence values. */ 2893 end_collseq = lookup_collation_sequence_value (end_elem, nrules, collseqmb, collseqwc,
2960 if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) 2894 table_size, symb_table, extra);
2961 return REG_ECOLLATE; 2895 /* Check start/end collation sequence values. */
2962 if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) 2896 if (__glibc_unlikely (start_collseq == UINT_MAX
2963 return REG_ERANGE; 2897 || end_collseq == UINT_MAX))
2898 return REG_ECOLLATE;
2899 if (__glibc_unlikely ((syntax & RE_NO_EMPTY_RANGES)
2900 && start_collseq > end_collseq))
2901 return REG_ERANGE;
2964 2902
2965 /* Got valid collation sequence values, add them as a new entry. 2903 /* Got valid collation sequence values, add them as a new entry.
2966 However, if we have no collation elements, and the character set 2904 However, if we have no collation elements, and the character set
2967 is single byte, the single byte character set that we 2905 is single byte, the single byte character set that we
2968 build below suffices. */ 2906 build below suffices. */
2969 if (nrules > 0 || dfa->mb_cur_max > 1) 2907 if (nrules > 0 || dfa->mb_cur_max > 1)
2908 {
2909 /* Check the space of the arrays. */
2910 if (__glibc_unlikely (*range_alloc == mbcset->nranges))
2970 { 2911 {
2971 /* Check the space of the arrays. */ 2912 /* There is not enough space, need realloc. */
2972 if (BE (*range_alloc == mbcset->nranges, 0)) 2913 uint32_t *new_array_start;
2973 { 2914 uint32_t *new_array_end;
2974 /* There is not enough space, need realloc. */ 2915 int new_nranges;
2975 uint32_t *new_array_start;
2976 uint32_t *new_array_end;
2977 Idx new_nranges;
2978
2979 /* +1 in case of mbcset->nranges is 0. */
2980 new_nranges = 2 * mbcset->nranges + 1;
2981 new_array_start = re_realloc (mbcset->range_starts, uint32_t,
2982 new_nranges);
2983 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
2984 new_nranges);
2985
2986 if (BE (new_array_start == NULL || new_array_end == NULL, 0))
2987 return REG_ESPACE;
2988 2916
2989 mbcset->range_starts = new_array_start; 2917 /* +1 in case of mbcset->nranges is 0. */
2990 mbcset->range_ends = new_array_end; 2918 new_nranges = 2 * mbcset->nranges + 1;
2991 *range_alloc = new_nranges; 2919 new_array_start = re_realloc (mbcset->range_starts, uint32_t,
2992 } 2920 new_nranges);
2921 new_array_end = re_realloc (mbcset->range_ends, uint32_t,
2922 new_nranges);
2993 2923
2994 mbcset->range_starts[mbcset->nranges] = start_collseq; 2924 if (__glibc_unlikely (new_array_start == NULL
2995 mbcset->range_ends[mbcset->nranges++] = end_collseq; 2925 || new_array_end == NULL))
2996 } 2926 return REG_ESPACE;
2997 2927
2998 /* Build the table for single byte characters. */ 2928 mbcset->range_starts = new_array_start;
2999 for (ch = 0; ch < SBC_MAX; ch++) 2929 mbcset->range_ends = new_array_end;
3000 { 2930 *range_alloc = new_nranges;
3001 uint32_t ch_collseq;
3002 /*
3003 if (MB_CUR_MAX == 1)
3004 */
3005 if (nrules == 0)
3006 ch_collseq = collseqmb[ch];
3007 else
3008 ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
3009 if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
3010 bitset_set (sbcset, ch);
3011 } 2931 }
3012 return REG_NOERROR; 2932
2933 mbcset->range_starts[mbcset->nranges] = start_collseq;
2934 mbcset->range_ends[mbcset->nranges++] = end_collseq;
3013 } 2935 }
3014 2936
3015 /* Local function for parse_bracket_exp used in _LIBC environment. 2937 /* Build the table for single byte characters. */
3016 Build the collating element which is represented by NAME. 2938 for (ch = 0; ch < SBC_MAX; ch++)
3017 The result are written to MBCSET and SBCSET. 2939 {
3018 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 2940 uint32_t ch_collseq;
3019 pointer argument since we may update it. */ 2941 /* if (MB_CUR_MAX == 1) */
2942 if (nrules == 0)
2943 ch_collseq = collseqmb[ch];
2944 else
2945 ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch));
2946 if (start_collseq <= ch_collseq && ch_collseq <= end_collseq)
2947 bitset_set (sbcset, ch);
2948 }
2949 return REG_NOERROR;
2950}
3020 2951
3021 auto inline reg_errcode_t 2952/* Local function for parse_bracket_exp used in _LIBC environment.
3022 __attribute__ ((always_inline)) 2953 Build the collating element which is represented by NAME.
3023 build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, 2954 The result are written to MBCSET and SBCSET.
3024 Idx *coll_sym_alloc, const unsigned char *name) 2955 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2956 pointer argument since we may update it. */
2957
2958static __always_inline reg_errcode_t
2959build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2960 Idx *coll_sym_alloc, const unsigned char *name,
2961 uint_fast32_t nrules, int_fast32_t table_size,
2962 const int32_t *symb_table, const unsigned char *extra)
2963{
2964 int32_t elem, idx;
2965 size_t name_len = strlen ((const char *) name);
2966 if (nrules != 0)
3025 { 2967 {
3026 int32_t elem, idx; 2968 elem = seek_collating_symbol_entry (name, name_len, symb_table,
3027 size_t name_len = strlen ((const char *) name); 2969 table_size, extra);
3028 if (nrules != 0) 2970 if (elem != -1)
3029 { 2971 {
3030 elem = seek_collating_symbol_entry (name, name_len); 2972 /* We found the entry. */
3031 if (elem != -1) 2973 idx = symb_table[2 * elem + 1];
3032 { 2974 /* Skip the name of collating element name. */
3033 /* We found the entry. */ 2975 idx += 1 + extra[idx];
3034 idx = symb_table[2 * elem + 1]; 2976 }
3035 /* Skip the name of collating element name. */ 2977 else if (name_len == 1)
3036 idx += 1 + extra[idx]; 2978 {
3037 } 2979 /* No valid character, treat it as a normal
3038 else if (name_len == 1) 2980 character. */
3039 { 2981 bitset_set (sbcset, name[0]);
3040 /* No valid character, treat it as a normal
3041 character. */
3042 bitset_set (sbcset, name[0]);
3043 return REG_NOERROR;
3044 }
3045 else
3046 return REG_ECOLLATE;
3047
3048 /* Got valid collation sequence, add it as a new entry. */
3049 /* Check the space of the arrays. */
3050 if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0))
3051 {
3052 /* Not enough, realloc it. */
3053 /* +1 in case of mbcset->ncoll_syms is 0. */
3054 Idx new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3055 /* Use realloc since mbcset->coll_syms is NULL
3056 if *alloc == 0. */
3057 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3058 new_coll_sym_alloc);
3059 if (BE (new_coll_syms == NULL, 0))
3060 return REG_ESPACE;
3061 mbcset->coll_syms = new_coll_syms;
3062 *coll_sym_alloc = new_coll_sym_alloc;
3063 }
3064 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
3065 return REG_NOERROR; 2982 return REG_NOERROR;
3066 } 2983 }
3067 else 2984 else
2985 return REG_ECOLLATE;
2986
2987 /* Got valid collation sequence, add it as a new entry. */
2988 /* Check the space of the arrays. */
2989 if (__glibc_unlikely (*coll_sym_alloc == mbcset->ncoll_syms))
3068 { 2990 {
3069 if (BE (name_len != 1, 0)) 2991 /* Not enough, realloc it. */
3070 return REG_ECOLLATE; 2992 /* +1 in case of mbcset->ncoll_syms is 0. */
3071 else 2993 int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1;
3072 { 2994 /* Use realloc since mbcset->coll_syms is NULL
3073 bitset_set (sbcset, name[0]); 2995 if *alloc == 0. */
3074 return REG_NOERROR; 2996 int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t,
3075 } 2997 new_coll_sym_alloc);
2998 if (__glibc_unlikely (new_coll_syms == NULL))
2999 return REG_ESPACE;
3000 mbcset->coll_syms = new_coll_syms;
3001 *coll_sym_alloc = new_coll_sym_alloc;
3076 } 3002 }
3003 mbcset->coll_syms[mbcset->ncoll_syms++] = idx;
3004 return REG_NOERROR;
3077 } 3005 }
3078#endif 3006 else
3007 {
3008 if (__glibc_unlikely (name_len != 1))
3009 return REG_ECOLLATE;
3010 else
3011 {
3012 bitset_set (sbcset, name[0]);
3013 return REG_NOERROR;
3014 }
3015 }
3016}
3017#endif /* _LIBC */
3018
3019/* This function parse bracket expression like "[abc]", "[a-c]",
3020 "[[.a-a.]]" etc. */
3021
3022static bin_tree_t *
3023parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3024 reg_syntax_t syntax, reg_errcode_t *err)
3025{
3026 const unsigned char *collseqmb = NULL;
3027 const char *collseqwc = NULL;
3028 uint_fast32_t nrules = 0;
3029 int_fast32_t table_size = 0;
3030 const void *symb_table = NULL;
3031 const unsigned char *extra = NULL;
3079 3032
3080 re_token_t br_token; 3033 re_token_t br_token;
3081 re_bitset_ptr_t sbcset; 3034 re_bitset_ptr_t sbcset;
3082#ifdef RE_ENABLE_I18N
3083 re_charset_t *mbcset; 3035 re_charset_t *mbcset;
3084 Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; 3036 Idx coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0;
3085 Idx equiv_class_alloc = 0, char_class_alloc = 0; 3037 Idx equiv_class_alloc = 0, char_class_alloc = 0;
3086#endif /* not RE_ENABLE_I18N */
3087 bool non_match = false; 3038 bool non_match = false;
3088 bin_tree_t *work_tree; 3039 bin_tree_t *work_tree;
3089 int token_len; 3040 int token_len;
@@ -3099,47 +3050,36 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3099 */ 3050 */
3100 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); 3051 collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC);
3101 table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); 3052 table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB);
3102 symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3053 symb_table = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_TABLEMB);
3103 _NL_COLLATE_SYMB_TABLEMB);
3104 extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, 3054 extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
3105 _NL_COLLATE_SYMB_EXTRAMB); 3055 _NL_COLLATE_SYMB_EXTRAMB);
3106 } 3056 }
3107#endif 3057#endif
3108 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3058 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
3109#ifdef RE_ENABLE_I18N
3110 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); 3059 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3111#endif /* RE_ENABLE_I18N */ 3060 if (__glibc_unlikely (sbcset == NULL || mbcset == NULL))
3112#ifdef RE_ENABLE_I18N
3113 if (BE (sbcset == NULL || mbcset == NULL, 0))
3114#else
3115 if (BE (sbcset == NULL, 0))
3116#endif /* RE_ENABLE_I18N */
3117 { 3061 {
3118 re_free (sbcset); 3062 re_free (sbcset);
3119#ifdef RE_ENABLE_I18N
3120 re_free (mbcset); 3063 re_free (mbcset);
3121#endif
3122 *err = REG_ESPACE; 3064 *err = REG_ESPACE;
3123 return NULL; 3065 return NULL;
3124 } 3066 }
3125 3067
3126 token_len = peek_token_bracket (token, regexp, syntax); 3068 token_len = peek_token_bracket (token, regexp, syntax);
3127 if (BE (token->type == END_OF_RE, 0)) 3069 if (__glibc_unlikely (token->type == END_OF_RE))
3128 { 3070 {
3129 *err = REG_BADPAT; 3071 *err = REG_BADPAT;
3130 goto parse_bracket_exp_free_return; 3072 goto parse_bracket_exp_free_return;
3131 } 3073 }
3132 if (token->type == OP_NON_MATCH_LIST) 3074 if (token->type == OP_NON_MATCH_LIST)
3133 { 3075 {
3134#ifdef RE_ENABLE_I18N
3135 mbcset->non_match = 1; 3076 mbcset->non_match = 1;
3136#endif /* not RE_ENABLE_I18N */
3137 non_match = true; 3077 non_match = true;
3138 if (syntax & RE_HAT_LISTS_NOT_NEWLINE) 3078 if (syntax & RE_HAT_LISTS_NOT_NEWLINE)
3139 bitset_set (sbcset, '\n'); 3079 bitset_set (sbcset, '\n');
3140 re_string_skip_bytes (regexp, token_len); /* Skip a token. */ 3080 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3141 token_len = peek_token_bracket (token, regexp, syntax); 3081 token_len = peek_token_bracket (token, regexp, syntax);
3142 if (BE (token->type == END_OF_RE, 0)) 3082 if (__glibc_unlikely (token->type == END_OF_RE))
3143 { 3083 {
3144 *err = REG_BADPAT; 3084 *err = REG_BADPAT;
3145 goto parse_bracket_exp_free_return; 3085 goto parse_bracket_exp_free_return;
@@ -3161,9 +3101,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3161 re_token_t token2; 3101 re_token_t token2;
3162 3102
3163 start_elem.opr.name = start_name_buf; 3103 start_elem.opr.name = start_name_buf;
3104 start_elem.type = COLL_SYM;
3164 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, 3105 ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa,
3165 syntax, first_round); 3106 syntax, first_round);
3166 if (BE (ret != REG_NOERROR, 0)) 3107 if (__glibc_unlikely (ret != REG_NOERROR))
3167 { 3108 {
3168 *err = ret; 3109 *err = ret;
3169 goto parse_bracket_exp_free_return; 3110 goto parse_bracket_exp_free_return;
@@ -3176,7 +3117,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3176 /* Do not check for ranges if we know they are not allowed. */ 3117 /* Do not check for ranges if we know they are not allowed. */
3177 if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) 3118 if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS)
3178 { 3119 {
3179 if (BE (token->type == END_OF_RE, 0)) 3120 if (__glibc_unlikely (token->type == END_OF_RE))
3180 { 3121 {
3181 *err = REG_EBRACK; 3122 *err = REG_EBRACK;
3182 goto parse_bracket_exp_free_return; 3123 goto parse_bracket_exp_free_return;
@@ -3185,7 +3126,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3185 { 3126 {
3186 re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ 3127 re_string_skip_bytes (regexp, token_len); /* Skip '-'. */
3187 token_len2 = peek_token_bracket (&token2, regexp, syntax); 3128 token_len2 = peek_token_bracket (&token2, regexp, syntax);
3188 if (BE (token2.type == END_OF_RE, 0)) 3129 if (__glibc_unlikely (token2.type == END_OF_RE))
3189 { 3130 {
3190 *err = REG_EBRACK; 3131 *err = REG_EBRACK;
3191 goto parse_bracket_exp_free_return; 3132 goto parse_bracket_exp_free_return;
@@ -3204,9 +3145,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3204 if (is_range_exp == true) 3145 if (is_range_exp == true)
3205 { 3146 {
3206 end_elem.opr.name = end_name_buf; 3147 end_elem.opr.name = end_name_buf;
3148 end_elem.type = COLL_SYM;
3207 ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, 3149 ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2,
3208 dfa, syntax, true); 3150 dfa, syntax, true);
3209 if (BE (ret != REG_NOERROR, 0)) 3151 if (__glibc_unlikely (ret != REG_NOERROR))
3210 { 3152 {
3211 *err = ret; 3153 *err = ret;
3212 goto parse_bracket_exp_free_return; 3154 goto parse_bracket_exp_free_return;
@@ -3214,19 +3156,11 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3214 3156
3215 token_len = peek_token_bracket (token, regexp, syntax); 3157 token_len = peek_token_bracket (token, regexp, syntax);
3216 3158
3217#ifdef _LIBC
3218 *err = build_range_exp (sbcset, mbcset, &range_alloc, 3159 *err = build_range_exp (sbcset, mbcset, &range_alloc,
3219 &start_elem, &end_elem); 3160 &start_elem, &end_elem,
3220#else 3161 dfa, syntax, nrules, collseqmb, collseqwc,
3221# ifdef RE_ENABLE_I18N 3162 table_size, symb_table, extra);
3222 *err = build_range_exp (syntax, sbcset, 3163 if (__glibc_unlikely (*err != REG_NOERROR))
3223 dfa->mb_cur_max > 1 ? mbcset : NULL,
3224 &range_alloc, &start_elem, &end_elem);
3225# else
3226 *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem);
3227# endif
3228#endif /* RE_ENABLE_I18N */
3229 if (BE (*err != REG_NOERROR, 0))
3230 goto parse_bracket_exp_free_return; 3164 goto parse_bracket_exp_free_return;
3231 } 3165 }
3232 else 3166 else
@@ -3236,10 +3170,9 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3236 case SB_CHAR: 3170 case SB_CHAR:
3237 bitset_set (sbcset, start_elem.opr.ch); 3171 bitset_set (sbcset, start_elem.opr.ch);
3238 break; 3172 break;
3239#ifdef RE_ENABLE_I18N
3240 case MB_CHAR: 3173 case MB_CHAR:
3241 /* Check whether the array has enough space. */ 3174 /* Check whether the array has enough space. */
3242 if (BE (mbchar_alloc == mbcset->nmbchars, 0)) 3175 if (__glibc_unlikely (mbchar_alloc == mbcset->nmbchars))
3243 { 3176 {
3244 wchar_t *new_mbchars; 3177 wchar_t *new_mbchars;
3245 /* Not enough, realloc it. */ 3178 /* Not enough, realloc it. */
@@ -3248,47 +3181,41 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3248 /* Use realloc since array is NULL if *alloc == 0. */ 3181 /* Use realloc since array is NULL if *alloc == 0. */
3249 new_mbchars = re_realloc (mbcset->mbchars, wchar_t, 3182 new_mbchars = re_realloc (mbcset->mbchars, wchar_t,
3250 mbchar_alloc); 3183 mbchar_alloc);
3251 if (BE (new_mbchars == NULL, 0)) 3184 if (__glibc_unlikely (new_mbchars == NULL))
3252 goto parse_bracket_exp_espace; 3185 goto parse_bracket_exp_espace;
3253 mbcset->mbchars = new_mbchars; 3186 mbcset->mbchars = new_mbchars;
3254 } 3187 }
3255 mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; 3188 mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch;
3256 break; 3189 break;
3257#endif /* RE_ENABLE_I18N */
3258 case EQUIV_CLASS: 3190 case EQUIV_CLASS:
3259 *err = build_equiv_class (sbcset, 3191 *err = build_equiv_class (sbcset,
3260#ifdef RE_ENABLE_I18N
3261 mbcset, &equiv_class_alloc, 3192 mbcset, &equiv_class_alloc,
3262#endif /* RE_ENABLE_I18N */
3263 start_elem.opr.name); 3193 start_elem.opr.name);
3264 if (BE (*err != REG_NOERROR, 0)) 3194 if (__glibc_unlikely (*err != REG_NOERROR))
3265 goto parse_bracket_exp_free_return; 3195 goto parse_bracket_exp_free_return;
3266 break; 3196 break;
3267 case COLL_SYM: 3197 case COLL_SYM:
3268 *err = build_collating_symbol (sbcset, 3198 *err = build_collating_symbol (sbcset,
3269#ifdef RE_ENABLE_I18N
3270 mbcset, &coll_sym_alloc, 3199 mbcset, &coll_sym_alloc,
3271#endif /* RE_ENABLE_I18N */ 3200 start_elem.opr.name,
3272 start_elem.opr.name); 3201 nrules, table_size, symb_table, extra);
3273 if (BE (*err != REG_NOERROR, 0)) 3202 if (__glibc_unlikely (*err != REG_NOERROR))
3274 goto parse_bracket_exp_free_return; 3203 goto parse_bracket_exp_free_return;
3275 break; 3204 break;
3276 case CHAR_CLASS: 3205 case CHAR_CLASS:
3277 *err = build_charclass (regexp->trans, sbcset, 3206 *err = build_charclass (regexp->trans, sbcset,
3278#ifdef RE_ENABLE_I18N
3279 mbcset, &char_class_alloc, 3207 mbcset, &char_class_alloc,
3280#endif /* RE_ENABLE_I18N */
3281 (const char *) start_elem.opr.name, 3208 (const char *) start_elem.opr.name,
3282 syntax); 3209 syntax);
3283 if (BE (*err != REG_NOERROR, 0)) 3210 if (__glibc_unlikely (*err != REG_NOERROR))
3284 goto parse_bracket_exp_free_return; 3211 goto parse_bracket_exp_free_return;
3285 break; 3212 break;
3286 default: 3213 default:
3287 assert (0); 3214 DEBUG_ASSERT (false);
3288 break; 3215 break;
3289 } 3216 }
3290 } 3217 }
3291 if (BE (token->type == END_OF_RE, 0)) 3218 if (__glibc_unlikely (token->type == END_OF_RE))
3292 { 3219 {
3293 *err = REG_EBRACK; 3220 *err = REG_EBRACK;
3294 goto parse_bracket_exp_free_return; 3221 goto parse_bracket_exp_free_return;
@@ -3303,7 +3230,6 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3303 if (non_match) 3230 if (non_match)
3304 bitset_not (sbcset); 3231 bitset_not (sbcset);
3305 3232
3306#ifdef RE_ENABLE_I18N
3307 /* Ensure only single byte characters are set. */ 3233 /* Ensure only single byte characters are set. */
3308 if (dfa->mb_cur_max > 1) 3234 if (dfa->mb_cur_max > 1)
3309 bitset_mask (sbcset, dfa->sb_char); 3235 bitset_mask (sbcset, dfa->sb_char);
@@ -3319,7 +3245,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3319 br_token.type = COMPLEX_BRACKET; 3245 br_token.type = COMPLEX_BRACKET;
3320 br_token.opr.mbcset = mbcset; 3246 br_token.opr.mbcset = mbcset;
3321 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3247 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3322 if (BE (mbc_tree == NULL, 0)) 3248 if (__glibc_unlikely (mbc_tree == NULL))
3323 goto parse_bracket_exp_espace; 3249 goto parse_bracket_exp_espace;
3324 for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) 3250 for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx)
3325 if (sbcset[sbc_idx]) 3251 if (sbcset[sbc_idx])
@@ -3332,12 +3258,12 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3332 br_token.type = SIMPLE_BRACKET; 3258 br_token.type = SIMPLE_BRACKET;
3333 br_token.opr.sbcset = sbcset; 3259 br_token.opr.sbcset = sbcset;
3334 work_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3260 work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3335 if (BE (work_tree == NULL, 0)) 3261 if (__glibc_unlikely (work_tree == NULL))
3336 goto parse_bracket_exp_espace; 3262 goto parse_bracket_exp_espace;
3337 3263
3338 /* Then join them by ALT node. */ 3264 /* Then join them by ALT node. */
3339 work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); 3265 work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT);
3340 if (BE (work_tree == NULL, 0)) 3266 if (__glibc_unlikely (work_tree == NULL))
3341 goto parse_bracket_exp_espace; 3267 goto parse_bracket_exp_espace;
3342 } 3268 }
3343 else 3269 else
@@ -3347,16 +3273,13 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3347 } 3273 }
3348 } 3274 }
3349 else 3275 else
3350#endif /* not RE_ENABLE_I18N */
3351 { 3276 {
3352#ifdef RE_ENABLE_I18N
3353 free_charset (mbcset); 3277 free_charset (mbcset);
3354#endif
3355 /* Build a tree for simple bracket. */ 3278 /* Build a tree for simple bracket. */
3356 br_token.type = SIMPLE_BRACKET; 3279 br_token.type = SIMPLE_BRACKET;
3357 br_token.opr.sbcset = sbcset; 3280 br_token.opr.sbcset = sbcset;
3358 work_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3281 work_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3359 if (BE (work_tree == NULL, 0)) 3282 if (__glibc_unlikely (work_tree == NULL))
3360 goto parse_bracket_exp_espace; 3283 goto parse_bracket_exp_espace;
3361 } 3284 }
3362 return work_tree; 3285 return work_tree;
@@ -3365,9 +3288,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3365 *err = REG_ESPACE; 3288 *err = REG_ESPACE;
3366 parse_bracket_exp_free_return: 3289 parse_bracket_exp_free_return:
3367 re_free (sbcset); 3290 re_free (sbcset);
3368#ifdef RE_ENABLE_I18N
3369 free_charset (mbcset); 3291 free_charset (mbcset);
3370#endif /* RE_ENABLE_I18N */
3371 return NULL; 3292 return NULL;
3372} 3293}
3373 3294
@@ -3378,7 +3299,6 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3378 re_token_t *token, int token_len, re_dfa_t *dfa, 3299 re_token_t *token, int token_len, re_dfa_t *dfa,
3379 reg_syntax_t syntax, bool accept_hyphen) 3300 reg_syntax_t syntax, bool accept_hyphen)
3380{ 3301{
3381#ifdef RE_ENABLE_I18N
3382 int cur_char_size; 3302 int cur_char_size;
3383 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); 3303 cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp));
3384 if (cur_char_size > 1) 3304 if (cur_char_size > 1)
@@ -3388,12 +3308,11 @@ parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
3388 re_string_skip_bytes (regexp, cur_char_size); 3308 re_string_skip_bytes (regexp, cur_char_size);
3389 return REG_NOERROR; 3309 return REG_NOERROR;
3390 } 3310 }
3391#endif /* RE_ENABLE_I18N */
3392 re_string_skip_bytes (regexp, token_len); /* Skip a token. */ 3311 re_string_skip_bytes (regexp, token_len); /* Skip a token. */
3393 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS 3312 if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS
3394 || token->type == OP_OPEN_EQUIV_CLASS) 3313 || token->type == OP_OPEN_EQUIV_CLASS)
3395 return parse_bracket_symbol (elem, regexp, token); 3314 return parse_bracket_symbol (elem, regexp, token);
3396 if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) 3315 if (__glibc_unlikely (token->type == OP_CHARSET_RANGE) && !accept_hyphen)
3397 { 3316 {
3398 /* A '-' must only appear as anything but a range indicator before 3317 /* A '-' must only appear as anything but a range indicator before
3399 the closing bracket. Everything else is an error. */ 3318 the closing bracket. Everything else is an error. */
@@ -3461,12 +3380,8 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
3461 is a pointer argument since we may update it. */ 3380 is a pointer argument since we may update it. */
3462 3381
3463static reg_errcode_t 3382static reg_errcode_t
3464#ifdef RE_ENABLE_I18N
3465build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, 3383build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
3466 Idx *equiv_class_alloc, const unsigned char *name) 3384 Idx *equiv_class_alloc, const unsigned char *name)
3467#else /* not RE_ENABLE_I18N */
3468build_equiv_class (bitset_t sbcset, const unsigned char *name)
3469#endif /* not RE_ENABLE_I18N */
3470{ 3385{
3471#ifdef _LIBC 3386#ifdef _LIBC
3472 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3387 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3478,8 +3393,6 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3478 int32_t idx1, idx2; 3393 int32_t idx1, idx2;
3479 unsigned int ch; 3394 unsigned int ch;
3480 size_t len; 3395 size_t len;
3481 /* This #include defines a local function! */
3482# include <locale/weight.h>
3483 /* Calculate the index for equivalence class. */ 3396 /* Calculate the index for equivalence class. */
3484 cp = name; 3397 cp = name;
3485 table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); 3398 table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
@@ -3489,8 +3402,8 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3489 _NL_COLLATE_EXTRAMB); 3402 _NL_COLLATE_EXTRAMB);
3490 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3403 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
3491 _NL_COLLATE_INDIRECTMB); 3404 _NL_COLLATE_INDIRECTMB);
3492 idx1 = findidx (&cp, -1); 3405 idx1 = findidx (table, indirect, extra, &cp, -1);
3493 if (BE (idx1 == 0 || *cp != '\0', 0)) 3406 if (__glibc_unlikely (idx1 == 0 || *cp != '\0'))
3494 /* This isn't a valid character. */ 3407 /* This isn't a valid character. */
3495 return REG_ECOLLATE; 3408 return REG_ECOLLATE;
3496 3409
@@ -3500,7 +3413,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3500 { 3413 {
3501 char_buf[0] = ch; 3414 char_buf[0] = ch;
3502 cp = char_buf; 3415 cp = char_buf;
3503 idx2 = findidx (&cp, 1); 3416 idx2 = findidx (table, indirect, extra, &cp, 1);
3504/* 3417/*
3505 idx2 = table[ch]; 3418 idx2 = table[ch];
3506*/ 3419*/
@@ -3509,21 +3422,13 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3509 continue; 3422 continue;
3510 /* Compare only if the length matches and the collation rule 3423 /* Compare only if the length matches and the collation rule
3511 index is the same. */ 3424 index is the same. */
3512 if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)) 3425 if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)
3513 { 3426 && memcmp (weights + (idx1 & 0xffffff) + 1,
3514 int cnt = 0; 3427 weights + (idx2 & 0xffffff) + 1, len) == 0)
3515 3428 bitset_set (sbcset, ch);
3516 while (cnt <= len &&
3517 weights[(idx1 & 0xffffff) + 1 + cnt]
3518 == weights[(idx2 & 0xffffff) + 1 + cnt])
3519 ++cnt;
3520
3521 if (cnt > len)
3522 bitset_set (sbcset, ch);
3523 }
3524 } 3429 }
3525 /* Check whether the array has enough space. */ 3430 /* Check whether the array has enough space. */
3526 if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) 3431 if (__glibc_unlikely (*equiv_class_alloc == mbcset->nequiv_classes))
3527 { 3432 {
3528 /* Not enough, realloc it. */ 3433 /* Not enough, realloc it. */
3529 /* +1 in case of mbcset->nequiv_classes is 0. */ 3434 /* +1 in case of mbcset->nequiv_classes is 0. */
@@ -3532,7 +3437,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3532 int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, 3437 int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes,
3533 int32_t, 3438 int32_t,
3534 new_equiv_class_alloc); 3439 new_equiv_class_alloc);
3535 if (BE (new_equiv_classes == NULL, 0)) 3440 if (__glibc_unlikely (new_equiv_classes == NULL))
3536 return REG_ESPACE; 3441 return REG_ESPACE;
3537 mbcset->equiv_classes = new_equiv_classes; 3442 mbcset->equiv_classes = new_equiv_classes;
3538 *equiv_class_alloc = new_equiv_class_alloc; 3443 *equiv_class_alloc = new_equiv_class_alloc;
@@ -3542,7 +3447,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3542 else 3447 else
3543#endif /* _LIBC */ 3448#endif /* _LIBC */
3544 { 3449 {
3545 if (BE (strlen ((const char *) name) != 1, 0)) 3450 if (__glibc_unlikely (strlen ((const char *) name) != 1))
3546 return REG_ECOLLATE; 3451 return REG_ECOLLATE;
3547 bitset_set (sbcset, *name); 3452 bitset_set (sbcset, *name);
3548 } 3453 }
@@ -3556,14 +3461,9 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3556 is a pointer argument since we may update it. */ 3461 is a pointer argument since we may update it. */
3557 3462
3558static reg_errcode_t 3463static reg_errcode_t
3559#ifdef RE_ENABLE_I18N
3560build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3464build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3561 re_charset_t *mbcset, Idx *char_class_alloc, 3465 re_charset_t *mbcset, Idx *char_class_alloc,
3562 const char *class_name, reg_syntax_t syntax) 3466 const char *class_name, reg_syntax_t syntax)
3563#else /* not RE_ENABLE_I18N */
3564build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3565 const char *class_name, reg_syntax_t syntax)
3566#endif /* not RE_ENABLE_I18N */
3567{ 3467{
3568 int i; 3468 int i;
3569 const char *name = class_name; 3469 const char *name = class_name;
@@ -3574,9 +3474,8 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3574 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) 3474 && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0))
3575 name = "alpha"; 3475 name = "alpha";
3576 3476
3577#ifdef RE_ENABLE_I18N
3578 /* Check the space of the arrays. */ 3477 /* Check the space of the arrays. */
3579 if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) 3478 if (__glibc_unlikely (*char_class_alloc == mbcset->nchar_classes))
3580 { 3479 {
3581 /* Not enough, realloc it. */ 3480 /* Not enough, realloc it. */
3582 /* +1 in case of mbcset->nchar_classes is 0. */ 3481 /* +1 in case of mbcset->nchar_classes is 0. */
@@ -3584,17 +3483,16 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3584 /* Use realloc since array is NULL if *alloc == 0. */ 3483 /* Use realloc since array is NULL if *alloc == 0. */
3585 wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, 3484 wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t,
3586 new_char_class_alloc); 3485 new_char_class_alloc);
3587 if (BE (new_char_classes == NULL, 0)) 3486 if (__glibc_unlikely (new_char_classes == NULL))
3588 return REG_ESPACE; 3487 return REG_ESPACE;
3589 mbcset->char_classes = new_char_classes; 3488 mbcset->char_classes = new_char_classes;
3590 *char_class_alloc = new_char_class_alloc; 3489 *char_class_alloc = new_char_class_alloc;
3591 } 3490 }
3592 mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); 3491 mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name);
3593#endif /* RE_ENABLE_I18N */
3594 3492
3595#define BUILD_CHARCLASS_LOOP(ctype_func) \ 3493#define BUILD_CHARCLASS_LOOP(ctype_func) \
3596 do { \ 3494 do { \
3597 if (BE (trans != NULL, 0)) \ 3495 if (__glibc_unlikely (trans != NULL)) \
3598 { \ 3496 { \
3599 for (i = 0; i < SBC_MAX; ++i) \ 3497 for (i = 0; i < SBC_MAX; ++i) \
3600 if (ctype_func (i)) \ 3498 if (ctype_func (i)) \
@@ -3645,49 +3543,33 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3645 reg_errcode_t *err) 3543 reg_errcode_t *err)
3646{ 3544{
3647 re_bitset_ptr_t sbcset; 3545 re_bitset_ptr_t sbcset;
3648#ifdef RE_ENABLE_I18N
3649 re_charset_t *mbcset; 3546 re_charset_t *mbcset;
3650 Idx alloc = 0; 3547 Idx alloc = 0;
3651#endif /* not RE_ENABLE_I18N */
3652 reg_errcode_t ret; 3548 reg_errcode_t ret;
3653 re_token_t br_token;
3654 bin_tree_t *tree; 3549 bin_tree_t *tree;
3655 3550
3656 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); 3551 sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
3657#ifdef RE_ENABLE_I18N 3552 if (__glibc_unlikely (sbcset == NULL))
3658 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3659#endif /* RE_ENABLE_I18N */
3660
3661#ifdef RE_ENABLE_I18N
3662 if (BE (sbcset == NULL || mbcset == NULL, 0))
3663#else /* not RE_ENABLE_I18N */
3664 if (BE (sbcset == NULL, 0))
3665#endif /* not RE_ENABLE_I18N */
3666 { 3553 {
3667 *err = REG_ESPACE; 3554 *err = REG_ESPACE;
3668 return NULL; 3555 return NULL;
3669 } 3556 }
3670 3557 mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
3671 if (non_match) 3558 if (__glibc_unlikely (mbcset == NULL))
3672 { 3559 {
3673#ifdef RE_ENABLE_I18N 3560 re_free (sbcset);
3674 mbcset->non_match = 1; 3561 *err = REG_ESPACE;
3675#endif /* not RE_ENABLE_I18N */ 3562 return NULL;
3676 } 3563 }
3564 mbcset->non_match = non_match;
3677 3565
3678 /* We don't care the syntax in this case. */ 3566 /* We don't care the syntax in this case. */
3679 ret = build_charclass (trans, sbcset, 3567 ret = build_charclass (trans, sbcset, mbcset, &alloc, class_name, 0);
3680#ifdef RE_ENABLE_I18N
3681 mbcset, &alloc,
3682#endif /* RE_ENABLE_I18N */
3683 class_name, 0);
3684 3568
3685 if (BE (ret != REG_NOERROR, 0)) 3569 if (__glibc_unlikely (ret != REG_NOERROR))
3686 { 3570 {
3687 re_free (sbcset); 3571 re_free (sbcset);
3688#ifdef RE_ENABLE_I18N
3689 free_charset (mbcset); 3572 free_charset (mbcset);
3690#endif /* RE_ENABLE_I18N */
3691 *err = ret; 3573 *err = ret;
3692 return NULL; 3574 return NULL;
3693 } 3575 }
@@ -3699,20 +3581,16 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3699 if (non_match) 3581 if (non_match)
3700 bitset_not (sbcset); 3582 bitset_not (sbcset);
3701 3583
3702#ifdef RE_ENABLE_I18N
3703 /* Ensure only single byte characters are set. */ 3584 /* Ensure only single byte characters are set. */
3704 if (dfa->mb_cur_max > 1) 3585 if (dfa->mb_cur_max > 1)
3705 bitset_mask (sbcset, dfa->sb_char); 3586 bitset_mask (sbcset, dfa->sb_char);
3706#endif
3707 3587
3708 /* Build a tree for simple bracket. */ 3588 /* Build a tree for simple bracket. */
3709 br_token.type = SIMPLE_BRACKET; 3589 re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
3710 br_token.opr.sbcset = sbcset;
3711 tree = create_token_tree (dfa, NULL, NULL, &br_token); 3590 tree = create_token_tree (dfa, NULL, NULL, &br_token);
3712 if (BE (tree == NULL, 0)) 3591 if (__glibc_unlikely (tree == NULL))
3713 goto build_word_op_espace; 3592 goto build_word_op_espace;
3714 3593
3715#ifdef RE_ENABLE_I18N
3716 if (dfa->mb_cur_max > 1) 3594 if (dfa->mb_cur_max > 1)
3717 { 3595 {
3718 bin_tree_t *mbc_tree; 3596 bin_tree_t *mbc_tree;
@@ -3721,11 +3599,11 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3721 br_token.opr.mbcset = mbcset; 3599 br_token.opr.mbcset = mbcset;
3722 dfa->has_mb_node = 1; 3600 dfa->has_mb_node = 1;
3723 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); 3601 mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token);
3724 if (BE (mbc_tree == NULL, 0)) 3602 if (__glibc_unlikely (mbc_tree == NULL))
3725 goto build_word_op_espace; 3603 goto build_word_op_espace;
3726 /* Then join them by ALT node. */ 3604 /* Then join them by ALT node. */
3727 tree = create_tree (dfa, tree, mbc_tree, OP_ALT); 3605 tree = create_tree (dfa, tree, mbc_tree, OP_ALT);
3728 if (BE (mbc_tree != NULL, 1)) 3606 if (__glibc_likely (mbc_tree != NULL))
3729 return tree; 3607 return tree;
3730 } 3608 }
3731 else 3609 else
@@ -3733,63 +3611,55 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3733 free_charset (mbcset); 3611 free_charset (mbcset);
3734 return tree; 3612 return tree;
3735 } 3613 }
3736#else /* not RE_ENABLE_I18N */
3737 return tree;
3738#endif /* not RE_ENABLE_I18N */
3739 3614
3740 build_word_op_espace: 3615 build_word_op_espace:
3741 re_free (sbcset); 3616 re_free (sbcset);
3742#ifdef RE_ENABLE_I18N
3743 free_charset (mbcset); 3617 free_charset (mbcset);
3744#endif /* RE_ENABLE_I18N */
3745 *err = REG_ESPACE; 3618 *err = REG_ESPACE;
3746 return NULL; 3619 return NULL;
3747} 3620}
3748 3621
3749/* This is intended for the expressions like "a{1,3}". 3622/* This is intended for the expressions like "a{1,3}".
3750 Fetch a number from 'input', and return the number. 3623 Fetch a number from 'input', and return the number.
3751 Return REG_MISSING if the number field is empty like "{,1}". 3624 Return -1 if the number field is empty like "{,1}".
3752 Return RE_DUP_MAX + 1 if the number field is too large. 3625 Return RE_DUP_MAX + 1 if the number field is too large.
3753 Return REG_ERROR if an error occurred. */ 3626 Return -2 if an error occurred. */
3754 3627
3755static Idx 3628static Idx
3756fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) 3629fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
3757{ 3630{
3758 Idx num = REG_MISSING; 3631 Idx num = -1;
3759 unsigned char c; 3632 unsigned char c;
3760 while (1) 3633 while (1)
3761 { 3634 {
3762 fetch_token (token, input, syntax); 3635 fetch_token (token, input, syntax);
3763 c = token->opr.c; 3636 c = token->opr.c;
3764 if (BE (token->type == END_OF_RE, 0)) 3637 if (__glibc_unlikely (token->type == END_OF_RE))
3765 return REG_ERROR; 3638 return -2;
3766 if (token->type == OP_CLOSE_DUP_NUM || c == ',') 3639 if (token->type == OP_CLOSE_DUP_NUM || c == ',')
3767 break; 3640 break;
3768 num = ((token->type != CHARACTER || c < '0' || '9' < c 3641 num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2)
3769 || num == REG_ERROR) 3642 ? -2
3770 ? REG_ERROR 3643 : num == -1
3771 : num == REG_MISSING
3772 ? c - '0' 3644 ? c - '0'
3773 : MIN (RE_DUP_MAX + 1, num * 10 + c - '0')); 3645 : MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
3774 } 3646 }
3775 return num; 3647 return num;
3776} 3648}
3777 3649
3778#ifdef RE_ENABLE_I18N
3779static void 3650static void
3780free_charset (re_charset_t *cset) 3651free_charset (re_charset_t *cset)
3781{ 3652{
3782 re_free (cset->mbchars); 3653 re_free (cset->mbchars);
3783# ifdef _LIBC 3654#ifdef _LIBC
3784 re_free (cset->coll_syms); 3655 re_free (cset->coll_syms);
3785 re_free (cset->equiv_classes); 3656 re_free (cset->equiv_classes);
3657#endif
3786 re_free (cset->range_starts); 3658 re_free (cset->range_starts);
3787 re_free (cset->range_ends); 3659 re_free (cset->range_ends);
3788# endif
3789 re_free (cset->char_classes); 3660 re_free (cset->char_classes);
3790 re_free (cset); 3661 re_free (cset);
3791} 3662}
3792#endif /* RE_ENABLE_I18N */
3793 3663
3794/* Functions for binary tree operation. */ 3664/* Functions for binary tree operation. */
3795 3665
@@ -3799,8 +3669,7 @@ static bin_tree_t *
3799create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, 3669create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3800 re_token_type_t type) 3670 re_token_type_t type)
3801{ 3671{
3802 re_token_t t; 3672 re_token_t t = { .type = type };
3803 t.type = type;
3804 return create_token_tree (dfa, left, right, &t); 3673 return create_token_tree (dfa, left, right, &t);
3805} 3674}
3806 3675
@@ -3809,7 +3678,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3809 const re_token_t *token) 3678 const re_token_t *token)
3810{ 3679{
3811 bin_tree_t *tree; 3680 bin_tree_t *tree;
3812 if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) 3681 if (__glibc_unlikely (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE))
3813 { 3682 {
3814 bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); 3683 bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1);
3815 3684
@@ -3829,7 +3698,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3829 tree->token.opt_subexp = 0; 3698 tree->token.opt_subexp = 0;
3830 tree->first = NULL; 3699 tree->first = NULL;
3831 tree->next = NULL; 3700 tree->next = NULL;
3832 tree->node_idx = REG_MISSING; 3701 tree->node_idx = -1;
3833 3702
3834 if (left != NULL) 3703 if (left != NULL)
3835 left->parent = tree; 3704 left->parent = tree;
@@ -3856,13 +3725,10 @@ mark_opt_subexp (void *extra, bin_tree_t *node)
3856static void 3725static void
3857free_token (re_token_t *node) 3726free_token (re_token_t *node)
3858{ 3727{
3859#ifdef RE_ENABLE_I18N
3860 if (node->type == COMPLEX_BRACKET && node->duplicated == 0) 3728 if (node->type == COMPLEX_BRACKET && node->duplicated == 0)
3861 free_charset (node->opr.mbcset); 3729 free_charset (node->opr.mbcset);
3862 else 3730 else if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
3863#endif /* RE_ENABLE_I18N */ 3731 re_free (node->opr.sbcset);
3864 if (node->type == SIMPLE_BRACKET && node->duplicated == 0)
3865 re_free (node->opr.sbcset);
3866} 3732}
3867 3733
3868/* Worker function for tree walking. Free the allocated memory inside NODE 3734/* Worker function for tree walking. Free the allocated memory inside NODE
diff --git a/gl/regex.c b/gl/regex.c
index 5a0332e..3beb0de 100644
--- a/gl/regex.c
+++ b/gl/regex.c
@@ -1,29 +1,32 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19
20#define __STDC_WANT_IEC_60559_BFP_EXT__
19 21
20#ifndef _LIBC 22#ifndef _LIBC
21# include <config.h> 23# include <libc-config.h>
22 24
23# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ 25# if __GNUC_PREREQ (4, 6)
24# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure" 26# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
27# pragma GCC diagnostic ignored "-Wvla"
25# endif 28# endif
26# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ 29# if __GNUC_PREREQ (4, 3)
27# pragma GCC diagnostic ignored "-Wold-style-definition" 30# pragma GCC diagnostic ignored "-Wold-style-definition"
28# pragma GCC diagnostic ignored "-Wtype-limits" 31# pragma GCC diagnostic ignored "-Wtype-limits"
29# endif 32# endif
diff --git a/gl/regex.h b/gl/regex.h
index 854c6ed..9ef0252 100644
--- a/gl/regex.h
+++ b/gl/regex.h
@@ -1,22 +1,21 @@
1/* Definitions for data structures and routines for the regular 1/* Definitions for data structures and routines for the regular
2 expression library. 2 expression library.
3 Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software 3 Copyright (C) 1985, 1989-2023 Free Software Foundation, Inc.
4 Foundation, Inc.
5 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
6 5
7 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
10 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
11 10
12 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 14 Lesser General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
20 19
21#ifndef _REGEX_H 20#ifndef _REGEX_H
22#define _REGEX_H 1 21#define _REGEX_H 1
@@ -42,11 +41,6 @@ extern "C" {
42 supported within glibc itself, and glibc users should not define 41 supported within glibc itself, and glibc users should not define
43 _REGEX_LARGE_OFFSETS. */ 42 _REGEX_LARGE_OFFSETS. */
44 43
45/* The type of nonnegative object indexes. Traditionally, GNU regex
46 uses 'int' for these. Code that uses __re_idx_t should work
47 regardless of whether the type is signed. */
48typedef size_t __re_idx_t;
49
50/* The type of object sizes. */ 44/* The type of object sizes. */
51typedef size_t __re_size_t; 45typedef size_t __re_size_t;
52 46
@@ -58,7 +52,6 @@ typedef size_t __re_long_size_t;
58 52
59/* The traditional GNU regex implementation mishandles strings longer 53/* The traditional GNU regex implementation mishandles strings longer
60 than INT_MAX. */ 54 than INT_MAX. */
61typedef int __re_idx_t;
62typedef unsigned int __re_size_t; 55typedef unsigned int __re_size_t;
63typedef unsigned long int __re_long_size_t; 56typedef unsigned long int __re_long_size_t;
64 57
@@ -244,19 +237,16 @@ extern reg_syntax_t re_syntax_options;
244 | RE_INVALID_INTERVAL_ORD) 237 | RE_INVALID_INTERVAL_ORD)
245 238
246# define RE_SYNTAX_GREP \ 239# define RE_SYNTAX_GREP \
247 (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ 240 ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \
248 | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ 241 & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL))
249 | RE_NEWLINE_ALT)
250 242
251# define RE_SYNTAX_EGREP \ 243# define RE_SYNTAX_EGREP \
252 (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ 244 ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \
253 | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ 245 & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL))
254 | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
255 | RE_NO_BK_VBAR)
256 246
247/* POSIX grep -E behavior is no longer incompatible with GNU. */
257# define RE_SYNTAX_POSIX_EGREP \ 248# define RE_SYNTAX_POSIX_EGREP \
258 (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ 249 RE_SYNTAX_EGREP
259 | RE_INVALID_INTERVAL_ORD)
260 250
261/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ 251/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
262# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC 252# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
@@ -491,7 +481,8 @@ typedef struct re_pattern_buffer regex_t;
491#ifdef _REGEX_LARGE_OFFSETS 481#ifdef _REGEX_LARGE_OFFSETS
492/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as 482/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
493 ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t 483 ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
494 is wider than ssize_t, so ssize_t is safe. */ 484 is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not
485 visible here, so use ssize_t. */
495typedef ssize_t regoff_t; 486typedef ssize_t regoff_t;
496#else 487#else
497/* The traditional GNU regex implementation mishandles strings longer 488/* The traditional GNU regex implementation mishandles strings longer
@@ -531,6 +522,30 @@ typedef struct
531 522
532/* Declarations for routines. */ 523/* Declarations for routines. */
533 524
525#ifndef _REGEX_NELTS
526# if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \
527 && !defined __STDC_NO_VLA__)
528# define _REGEX_NELTS(n) n
529# else
530# define _REGEX_NELTS(n)
531# endif
532#endif
533
534#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
535# pragma GCC diagnostic push
536# pragma GCC diagnostic ignored "-Wvla"
537#endif
538
539#ifndef _Attr_access_
540# ifdef __attr_access
541# define _Attr_access_(arg) __attr_access (arg)
542# elif defined __GNUC__ && 10 <= __GNUC__
543# define _Attr_access_(x) __attribute__ ((__access__ x))
544# else
545# define _Attr_access_(x)
546# endif
547#endif
548
534#ifdef __USE_GNU 549#ifdef __USE_GNU
535/* Sets the current default syntax to SYNTAX, and return the old syntax. 550/* Sets the current default syntax to SYNTAX, and return the old syntax.
536 You can also simply assign to the 're_syntax_options' variable. */ 551 You can also simply assign to the 're_syntax_options' variable. */
@@ -541,11 +556,12 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
541 BUFFER. Return NULL if successful, and an error string if not. 556 BUFFER. Return NULL if successful, and an error string if not.
542 557
543 To free the allocated storage, you must call 'regfree' on BUFFER. 558 To free the allocated storage, you must call 'regfree' on BUFFER.
544 Note that the translate table must either have been initialised by 559 Note that the translate table must either have been initialized by
545 'regcomp', with a malloc'ed value, or set to NULL before calling 560 'regcomp', with a malloc'ed value, or set to NULL before calling
546 'regfree'. */ 561 'regfree'. */
547extern const char *re_compile_pattern (const char *__pattern, size_t __length, 562extern const char *re_compile_pattern (const char *__pattern, size_t __length,
548 struct re_pattern_buffer *__buffer); 563 struct re_pattern_buffer *__buffer)
564 _Attr_access_ ((__read_only__, 1, 2));
549 565
550 566
551/* Compile a fastmap for the compiled pattern in BUFFER; used to 567/* Compile a fastmap for the compiled pattern in BUFFER; used to
@@ -560,34 +576,40 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer);
560 match, or -2 for an internal error. Also return register 576 match, or -2 for an internal error. Also return register
561 information in REGS (if REGS and BUFFER->no_sub are nonzero). */ 577 information in REGS (if REGS and BUFFER->no_sub are nonzero). */
562extern regoff_t re_search (struct re_pattern_buffer *__buffer, 578extern regoff_t re_search (struct re_pattern_buffer *__buffer,
563 const char *__string, __re_idx_t __length, 579 const char *__String, regoff_t __length,
564 __re_idx_t __start, regoff_t __range, 580 regoff_t __start, regoff_t __range,
565 struct re_registers *__regs); 581 struct re_registers *__regs)
582 _Attr_access_ ((__read_only__, 2, 3));
566 583
567 584
568/* Like 're_search', but search in the concatenation of STRING1 and 585/* Like 're_search', but search in the concatenation of STRING1 and
569 STRING2. Also, stop searching at index START + STOP. */ 586 STRING2. Also, stop searching at index START + STOP. */
570extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, 587extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
571 const char *__string1, __re_idx_t __length1, 588 const char *__string1, regoff_t __length1,
572 const char *__string2, __re_idx_t __length2, 589 const char *__string2, regoff_t __length2,
573 __re_idx_t __start, regoff_t __range, 590 regoff_t __start, regoff_t __range,
574 struct re_registers *__regs, 591 struct re_registers *__regs,
575 __re_idx_t __stop); 592 regoff_t __stop)
593 _Attr_access_ ((__read_only__, 2, 3))
594 _Attr_access_ ((__read_only__, 4, 5));
576 595
577 596
578/* Like 're_search', but return how many characters in STRING the regexp 597/* Like 're_search', but return how many characters in STRING the regexp
579 in BUFFER matched, starting at position START. */ 598 in BUFFER matched, starting at position START. */
580extern regoff_t re_match (struct re_pattern_buffer *__buffer, 599extern regoff_t re_match (struct re_pattern_buffer *__buffer,
581 const char *__string, __re_idx_t __length, 600 const char *__String, regoff_t __length,
582 __re_idx_t __start, struct re_registers *__regs); 601 regoff_t __start, struct re_registers *__regs)
602 _Attr_access_ ((__read_only__, 2, 3));
583 603
584 604
585/* Relates to 're_match' as 're_search_2' relates to 're_search'. */ 605/* Relates to 're_match' as 're_search_2' relates to 're_search'. */
586extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, 606extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
587 const char *__string1, __re_idx_t __length1, 607 const char *__string1, regoff_t __length1,
588 const char *__string2, __re_idx_t __length2, 608 const char *__string2, regoff_t __length2,
589 __re_idx_t __start, struct re_registers *__regs, 609 regoff_t __start, struct re_registers *__regs,
590 __re_idx_t __stop); 610 regoff_t __stop)
611 _Attr_access_ ((__read_only__, 2, 3))
612 _Attr_access_ ((__read_only__, 4, 5));
591 613
592 614
593/* Set REGS to hold NUM_REGS registers, storing them in STARTS and 615/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
@@ -608,36 +630,41 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer,
608 regoff_t *__starts, regoff_t *__ends); 630 regoff_t *__starts, regoff_t *__ends);
609#endif /* Use GNU */ 631#endif /* Use GNU */
610 632
611#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD) 633#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC)
612# ifndef _CRAY
613/* 4.2 bsd compatibility. */ 634/* 4.2 bsd compatibility. */
614extern char *re_comp (const char *); 635extern char *re_comp (const char *);
615extern int re_exec (const char *); 636extern int re_exec (const char *);
616# endif
617#endif 637#endif
618 638
619/* GCC 2.95 and later have "__restrict"; C99 compilers have 639/* For plain 'restrict', use glibc's __restrict if defined.
640 Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have
620 "restrict", and "configure" may have defined "restrict". 641 "restrict", and "configure" may have defined "restrict".
621 Other compilers use __restrict, __restrict__, and _Restrict, and 642 Other compilers use __restrict, __restrict__, and _Restrict, and
622 'configure' might #define 'restrict' to those words, so pick a 643 'configure' might #define 'restrict' to those words, so pick a
623 different name. */ 644 different name. */
624#ifndef _Restrict_ 645#ifndef _Restrict_
625# if 199901L <= __STDC_VERSION__ 646# if defined __restrict \
626# define _Restrict_ restrict 647 || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \
627# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) 648 || __clang_major__ >= 3
628# define _Restrict_ __restrict 649# define _Restrict_ __restrict
650# elif 199901L <= __STDC_VERSION__ || defined restrict
651# define _Restrict_ restrict
629# else 652# else
630# define _Restrict_ 653# define _Restrict_
631# endif 654# endif
632#endif 655#endif
633/* gcc 3.1 and up support the [restrict] syntax. Don't trust 656/* For the ISO C99 syntax
634 sys/cdefs.h's definition of __restrict_arr, though, as it 657 array_name[restrict]
635 mishandles gcc -ansi -pedantic. */ 658 use glibc's __restrict_arr if available.
659 Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode).
660 Other ISO C99 compilers support it as well. */
636#ifndef _Restrict_arr_ 661#ifndef _Restrict_arr_
637# if ((199901L <= __STDC_VERSION__ \ 662# ifdef __restrict_arr
638 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ 663# define _Restrict_arr_ __restrict_arr
639 && !defined __STRICT_ANSI__)) \ 664# elif ((199901L <= __STDC_VERSION__ \
640 && !defined __GNUG__) 665 || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \
666 || __clang_major__ >= 3) \
667 && !defined __cplusplus)
641# define _Restrict_arr_ _Restrict_ 668# define _Restrict_arr_ _Restrict_
642# else 669# else
643# define _Restrict_arr_ 670# define _Restrict_arr_
@@ -650,15 +677,20 @@ extern int regcomp (regex_t *_Restrict_ __preg,
650 int __cflags); 677 int __cflags);
651 678
652extern int regexec (const regex_t *_Restrict_ __preg, 679extern int regexec (const regex_t *_Restrict_ __preg,
653 const char *_Restrict_ __string, size_t __nmatch, 680 const char *_Restrict_ __String, size_t __nmatch,
654 regmatch_t __pmatch[_Restrict_arr_], 681 regmatch_t __pmatch[_Restrict_arr_
682 _REGEX_NELTS (__nmatch)],
655 int __eflags); 683 int __eflags);
656 684
657extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, 685extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
658 char *_Restrict_ __errbuf, size_t __errbuf_size); 686 char *_Restrict_ __errbuf, size_t __errbuf_size)
687 _Attr_access_ ((__write_only__, 3, 4));
659 688
660extern void regfree (regex_t *__preg); 689extern void regfree (regex_t *__preg);
661 690
691#if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
692# pragma GCC diagnostic pop
693#endif
662 694
663#ifdef __cplusplus 695#ifdef __cplusplus
664} 696}
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index 899b0ae..998a19b 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -1,33 +1,41 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20static void re_string_construct_common (const char *str, Idx len, 20static void re_string_construct_common (const char *str, Idx len,
21 re_string_t *pstr, 21 re_string_t *pstr,
22 RE_TRANSLATE_TYPE trans, bool icase, 22 RE_TRANSLATE_TYPE trans, bool icase,
23 const re_dfa_t *dfa) internal_function; 23 const re_dfa_t *dfa);
24static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, 24static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa,
25 const re_node_set *nodes, 25 const re_node_set *nodes,
26 re_hashval_t hash) internal_function; 26 re_hashval_t hash);
27static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, 27static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
28 const re_node_set *nodes, 28 const re_node_set *nodes,
29 unsigned int context, 29 unsigned int context,
30 re_hashval_t hash) internal_function; 30 re_hashval_t hash);
31static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
32 Idx new_buf_len);
33static void build_wcs_buffer (re_string_t *pstr);
34static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr);
35static void build_upper_buffer (re_string_t *pstr);
36static void re_string_translate_buffer (re_string_t *pstr);
37static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
38 int eflags) __attribute__ ((pure));
31 39
32/* Functions for string operation. */ 40/* Functions for string operation. */
33 41
@@ -35,7 +43,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
35 re_string_reconstruct before using the object. */ 43 re_string_reconstruct before using the object. */
36 44
37static reg_errcode_t 45static reg_errcode_t
38internal_function __attribute_warn_unused_result__ 46__attribute_warn_unused_result__
39re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len, 47re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
40 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) 48 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
41{ 49{
@@ -49,7 +57,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
49 re_string_construct_common (str, len, pstr, trans, icase, dfa); 57 re_string_construct_common (str, len, pstr, trans, icase, dfa);
50 58
51 ret = re_string_realloc_buffers (pstr, init_buf_len); 59 ret = re_string_realloc_buffers (pstr, init_buf_len);
52 if (BE (ret != REG_NOERROR, 0)) 60 if (__glibc_unlikely (ret != REG_NOERROR))
53 return ret; 61 return ret;
54 62
55 pstr->word_char = dfa->word_char; 63 pstr->word_char = dfa->word_char;
@@ -63,7 +71,7 @@ re_string_allocate (re_string_t *pstr, const char *str, Idx len, Idx init_len,
63/* This function allocate the buffers, and initialize them. */ 71/* This function allocate the buffers, and initialize them. */
64 72
65static reg_errcode_t 73static reg_errcode_t
66internal_function __attribute_warn_unused_result__ 74__attribute_warn_unused_result__
67re_string_construct (re_string_t *pstr, const char *str, Idx len, 75re_string_construct (re_string_t *pstr, const char *str, Idx len,
68 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa) 76 RE_TRANSLATE_TYPE trans, bool icase, const re_dfa_t *dfa)
69{ 77{
@@ -74,41 +82,37 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
74 if (len > 0) 82 if (len > 0)
75 { 83 {
76 ret = re_string_realloc_buffers (pstr, len + 1); 84 ret = re_string_realloc_buffers (pstr, len + 1);
77 if (BE (ret != REG_NOERROR, 0)) 85 if (__glibc_unlikely (ret != REG_NOERROR))
78 return ret; 86 return ret;
79 } 87 }
80 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; 88 pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str;
81 89
82 if (icase) 90 if (icase)
83 { 91 {
84#ifdef RE_ENABLE_I18N
85 if (dfa->mb_cur_max > 1) 92 if (dfa->mb_cur_max > 1)
86 { 93 {
87 while (1) 94 while (1)
88 { 95 {
89 ret = build_wcs_upper_buffer (pstr); 96 ret = build_wcs_upper_buffer (pstr);
90 if (BE (ret != REG_NOERROR, 0)) 97 if (__glibc_unlikely (ret != REG_NOERROR))
91 return ret; 98 return ret;
92 if (pstr->valid_raw_len >= len) 99 if (pstr->valid_raw_len >= len)
93 break; 100 break;
94 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) 101 if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max)
95 break; 102 break;
96 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); 103 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
97 if (BE (ret != REG_NOERROR, 0)) 104 if (__glibc_unlikely (ret != REG_NOERROR))
98 return ret; 105 return ret;
99 } 106 }
100 } 107 }
101 else 108 else
102#endif /* RE_ENABLE_I18N */
103 build_upper_buffer (pstr); 109 build_upper_buffer (pstr);
104 } 110 }
105 else 111 else
106 { 112 {
107#ifdef RE_ENABLE_I18N
108 if (dfa->mb_cur_max > 1) 113 if (dfa->mb_cur_max > 1)
109 build_wcs_buffer (pstr); 114 build_wcs_buffer (pstr);
110 else 115 else
111#endif /* RE_ENABLE_I18N */
112 { 116 {
113 if (trans != NULL) 117 if (trans != NULL)
114 re_string_translate_buffer (pstr); 118 re_string_translate_buffer (pstr);
@@ -126,37 +130,36 @@ re_string_construct (re_string_t *pstr, const char *str, Idx len,
126/* Helper functions for re_string_allocate, and re_string_construct. */ 130/* Helper functions for re_string_allocate, and re_string_construct. */
127 131
128static reg_errcode_t 132static reg_errcode_t
129internal_function __attribute_warn_unused_result__ 133__attribute_warn_unused_result__
130re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len) 134re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
131{ 135{
132#ifdef RE_ENABLE_I18N
133 if (pstr->mb_cur_max > 1) 136 if (pstr->mb_cur_max > 1)
134 { 137 {
135 wint_t *new_wcs; 138 wint_t *new_wcs;
136 139
137 /* Avoid overflow in realloc. */ 140 /* Avoid overflow in realloc. */
138 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); 141 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
139 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0)) 142 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
143 < new_buf_len))
140 return REG_ESPACE; 144 return REG_ESPACE;
141 145
142 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); 146 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
143 if (BE (new_wcs == NULL, 0)) 147 if (__glibc_unlikely (new_wcs == NULL))
144 return REG_ESPACE; 148 return REG_ESPACE;
145 pstr->wcs = new_wcs; 149 pstr->wcs = new_wcs;
146 if (pstr->offsets != NULL) 150 if (pstr->offsets != NULL)
147 { 151 {
148 Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len); 152 Idx *new_offsets = re_realloc (pstr->offsets, Idx, new_buf_len);
149 if (BE (new_offsets == NULL, 0)) 153 if (__glibc_unlikely (new_offsets == NULL))
150 return REG_ESPACE; 154 return REG_ESPACE;
151 pstr->offsets = new_offsets; 155 pstr->offsets = new_offsets;
152 } 156 }
153 } 157 }
154#endif /* RE_ENABLE_I18N */
155 if (pstr->mbs_allocated) 158 if (pstr->mbs_allocated)
156 { 159 {
157 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, 160 unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char,
158 new_buf_len); 161 new_buf_len);
159 if (BE (new_mbs == NULL, 0)) 162 if (__glibc_unlikely (new_mbs == NULL))
160 return REG_ESPACE; 163 return REG_ESPACE;
161 pstr->mbs = new_mbs; 164 pstr->mbs = new_mbs;
162 } 165 }
@@ -166,7 +169,6 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
166 169
167 170
168static void 171static void
169internal_function
170re_string_construct_common (const char *str, Idx len, re_string_t *pstr, 172re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
171 RE_TRANSLATE_TYPE trans, bool icase, 173 RE_TRANSLATE_TYPE trans, bool icase,
172 const re_dfa_t *dfa) 174 const re_dfa_t *dfa)
@@ -184,7 +186,6 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
184 pstr->raw_stop = pstr->stop; 186 pstr->raw_stop = pstr->stop;
185} 187}
186 188
187#ifdef RE_ENABLE_I18N
188 189
189/* Build wide character buffer PSTR->WCS. 190/* Build wide character buffer PSTR->WCS.
190 If the byte sequence of the string are: 191 If the byte sequence of the string are:
@@ -198,12 +199,11 @@ re_string_construct_common (const char *str, Idx len, re_string_t *pstr,
198 built and starts from PSTR->VALID_LEN. */ 199 built and starts from PSTR->VALID_LEN. */
199 200
200static void 201static void
201internal_function
202build_wcs_buffer (re_string_t *pstr) 202build_wcs_buffer (re_string_t *pstr)
203{ 203{
204#ifdef _LIBC 204#ifdef _LIBC
205 unsigned char buf[MB_LEN_MAX]; 205 unsigned char buf[MB_LEN_MAX];
206 assert (MB_LEN_MAX >= pstr->mb_cur_max); 206 DEBUG_ASSERT (MB_LEN_MAX >= pstr->mb_cur_max);
207#else 207#else
208 unsigned char buf[64]; 208 unsigned char buf[64];
209#endif 209#endif
@@ -222,7 +222,7 @@ build_wcs_buffer (re_string_t *pstr)
222 remain_len = end_idx - byte_idx; 222 remain_len = end_idx - byte_idx;
223 prev_st = pstr->cur_state; 223 prev_st = pstr->cur_state;
224 /* Apply the translation if we need. */ 224 /* Apply the translation if we need. */
225 if (BE (pstr->trans != NULL, 0)) 225 if (__glibc_unlikely (pstr->trans != NULL))
226 { 226 {
227 int i, ch; 227 int i, ch;
228 228
@@ -236,17 +236,18 @@ build_wcs_buffer (re_string_t *pstr)
236 else 236 else
237 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; 237 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
238 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 238 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
239 if (BE (mbclen == (size_t) -1 || mbclen == 0 239 if (__glibc_unlikely (mbclen == (size_t) -1 || mbclen == 0
240 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0)) 240 || (mbclen == (size_t) -2
241 && pstr->bufs_len >= pstr->len)))
241 { 242 {
242 /* We treat these cases as a singlebyte character. */ 243 /* We treat these cases as a singlebyte character. */
243 mbclen = 1; 244 mbclen = 1;
244 wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; 245 wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
245 if (BE (pstr->trans != NULL, 0)) 246 if (__glibc_unlikely (pstr->trans != NULL))
246 wc = pstr->trans[wc]; 247 wc = pstr->trans[wc];
247 pstr->cur_state = prev_st; 248 pstr->cur_state = prev_st;
248 } 249 }
249 else if (BE (mbclen == (size_t) -2, 0)) 250 else if (__glibc_unlikely (mbclen == (size_t) -2))
250 { 251 {
251 /* The buffer doesn't have enough space, finish to build. */ 252 /* The buffer doesn't have enough space, finish to build. */
252 pstr->cur_state = prev_st; 253 pstr->cur_state = prev_st;
@@ -267,7 +268,7 @@ build_wcs_buffer (re_string_t *pstr)
267 but for REG_ICASE. */ 268 but for REG_ICASE. */
268 269
269static reg_errcode_t 270static reg_errcode_t
270internal_function __attribute_warn_unused_result__ 271__attribute_warn_unused_result__
271build_wcs_upper_buffer (re_string_t *pstr) 272build_wcs_upper_buffer (re_string_t *pstr)
272{ 273{
273 mbstate_t prev_st; 274 mbstate_t prev_st;
@@ -275,7 +276,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
275 size_t mbclen; 276 size_t mbclen;
276#ifdef _LIBC 277#ifdef _LIBC
277 char buf[MB_LEN_MAX]; 278 char buf[MB_LEN_MAX];
278 assert (MB_LEN_MAX >= pstr->mb_cur_max); 279 DEBUG_ASSERT (pstr->mb_cur_max <= MB_LEN_MAX);
279#else 280#else
280 char buf[64]; 281 char buf[64];
281#endif 282#endif
@@ -290,18 +291,20 @@ build_wcs_upper_buffer (re_string_t *pstr)
290 while (byte_idx < end_idx) 291 while (byte_idx < end_idx)
291 { 292 {
292 wchar_t wc; 293 wchar_t wc;
294 unsigned char ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
293 295
294 if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) 296 if (isascii (ch) && mbsinit (&pstr->cur_state))
295 && mbsinit (&pstr->cur_state))
296 { 297 {
297 /* In case of a singlebyte character. */
298 pstr->mbs[byte_idx]
299 = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]);
300 /* The next step uses the assumption that wchar_t is encoded 298 /* The next step uses the assumption that wchar_t is encoded
301 ASCII-safe: all ASCII values can be converted like this. */ 299 ASCII-safe: all ASCII values can be converted like this. */
302 pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; 300 wchar_t wcu = __towupper (ch);
303 ++byte_idx; 301 if (isascii (wcu))
304 continue; 302 {
303 pstr->mbs[byte_idx] = wcu;
304 pstr->wcs[byte_idx] = wcu;
305 byte_idx++;
306 continue;
307 }
305 } 308 }
306 309
307 remain_len = end_idx - byte_idx; 310 remain_len = end_idx - byte_idx;
@@ -309,16 +312,15 @@ build_wcs_upper_buffer (re_string_t *pstr)
309 mbclen = __mbrtowc (&wc, 312 mbclen = __mbrtowc (&wc,
310 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx 313 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
311 + byte_idx), remain_len, &pstr->cur_state); 314 + byte_idx), remain_len, &pstr->cur_state);
312 if (BE (mbclen < (size_t) -2, 1)) 315 if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
313 { 316 {
314 wchar_t wcu = wc; 317 wchar_t wcu = __towupper (wc);
315 if (iswlower (wc)) 318 if (wcu != wc)
316 { 319 {
317 size_t mbcdlen; 320 size_t mbcdlen;
318 321
319 wcu = towupper (wc); 322 mbcdlen = __wcrtomb (buf, wcu, &prev_st);
320 mbcdlen = wcrtomb (buf, wcu, &prev_st); 323 if (__glibc_likely (mbclen == mbcdlen))
321 if (BE (mbclen == mbcdlen, 1))
322 memcpy (pstr->mbs + byte_idx, buf, mbclen); 324 memcpy (pstr->mbs + byte_idx, buf, mbclen);
323 else 325 else
324 { 326 {
@@ -339,11 +341,10 @@ build_wcs_upper_buffer (re_string_t *pstr)
339 { 341 {
340 /* It is an invalid character, an incomplete character 342 /* It is an invalid character, an incomplete character
341 at the end of the string, or '\0'. Just use the byte. */ 343 at the end of the string, or '\0'. Just use the byte. */
342 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
343 pstr->mbs[byte_idx] = ch; 344 pstr->mbs[byte_idx] = ch;
344 /* And also cast it to wide char. */ 345 /* And also cast it to wide char. */
345 pstr->wcs[byte_idx++] = (wchar_t) ch; 346 pstr->wcs[byte_idx++] = (wchar_t) ch;
346 if (BE (mbclen == (size_t) -1, 0)) 347 if (__glibc_unlikely (mbclen == (size_t) -1))
347 pstr->cur_state = prev_st; 348 pstr->cur_state = prev_st;
348 } 349 }
349 else 350 else
@@ -365,7 +366,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
365 offsets_needed: 366 offsets_needed:
366 remain_len = end_idx - byte_idx; 367 remain_len = end_idx - byte_idx;
367 prev_st = pstr->cur_state; 368 prev_st = pstr->cur_state;
368 if (BE (pstr->trans != NULL, 0)) 369 if (__glibc_unlikely (pstr->trans != NULL))
369 { 370 {
370 int i, ch; 371 int i, ch;
371 372
@@ -379,16 +380,15 @@ build_wcs_upper_buffer (re_string_t *pstr)
379 else 380 else
380 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; 381 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
381 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 382 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
382 if (BE (mbclen < (size_t) -2, 1)) 383 if (__glibc_likely (0 < mbclen && mbclen < (size_t) -2))
383 { 384 {
384 wchar_t wcu = wc; 385 wchar_t wcu = __towupper (wc);
385 if (iswlower (wc)) 386 if (wcu != wc)
386 { 387 {
387 size_t mbcdlen; 388 size_t mbcdlen;
388 389
389 wcu = towupper (wc); 390 mbcdlen = __wcrtomb ((char *) buf, wcu, &prev_st);
390 mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st); 391 if (__glibc_likely (mbclen == mbcdlen))
391 if (BE (mbclen == mbcdlen, 1))
392 memcpy (pstr->mbs + byte_idx, buf, mbclen); 392 memcpy (pstr->mbs + byte_idx, buf, mbclen);
393 else if (mbcdlen != (size_t) -1) 393 else if (mbcdlen != (size_t) -1)
394 { 394 {
@@ -438,7 +438,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
438 else 438 else
439 memcpy (pstr->mbs + byte_idx, p, mbclen); 439 memcpy (pstr->mbs + byte_idx, p, mbclen);
440 440
441 if (BE (pstr->offsets_needed != 0, 0)) 441 if (__glibc_unlikely (pstr->offsets_needed != 0))
442 { 442 {
443 size_t i; 443 size_t i;
444 for (i = 0; i < mbclen; ++i) 444 for (i = 0; i < mbclen; ++i)
@@ -457,17 +457,17 @@ build_wcs_upper_buffer (re_string_t *pstr)
457 /* It is an invalid character or '\0'. Just use the byte. */ 457 /* It is an invalid character or '\0'. Just use the byte. */
458 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; 458 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
459 459
460 if (BE (pstr->trans != NULL, 0)) 460 if (__glibc_unlikely (pstr->trans != NULL))
461 ch = pstr->trans [ch]; 461 ch = pstr->trans [ch];
462 pstr->mbs[byte_idx] = ch; 462 pstr->mbs[byte_idx] = ch;
463 463
464 if (BE (pstr->offsets_needed != 0, 0)) 464 if (__glibc_unlikely (pstr->offsets_needed != 0))
465 pstr->offsets[byte_idx] = src_idx; 465 pstr->offsets[byte_idx] = src_idx;
466 ++src_idx; 466 ++src_idx;
467 467
468 /* And also cast it to wide char. */ 468 /* And also cast it to wide char. */
469 pstr->wcs[byte_idx++] = (wchar_t) ch; 469 pstr->wcs[byte_idx++] = (wchar_t) ch;
470 if (BE (mbclen == (size_t) -1, 0)) 470 if (__glibc_unlikely (mbclen == (size_t) -1))
471 pstr->cur_state = prev_st; 471 pstr->cur_state = prev_st;
472 } 472 }
473 else 473 else
@@ -486,7 +486,6 @@ build_wcs_upper_buffer (re_string_t *pstr)
486 Return the index. */ 486 Return the index. */
487 487
488static Idx 488static Idx
489internal_function
490re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc) 489re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
491{ 490{
492 mbstate_t prev_st; 491 mbstate_t prev_st;
@@ -503,7 +502,8 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
503 prev_st = pstr->cur_state; 502 prev_st = pstr->cur_state;
504 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, 503 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
505 remain_len, &pstr->cur_state); 504 remain_len, &pstr->cur_state);
506 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) 505 if (__glibc_unlikely (mbclen == (size_t) -2 || mbclen == (size_t) -1
506 || mbclen == 0))
507 { 507 {
508 /* We treat these cases as a single byte character. */ 508 /* We treat these cases as a single byte character. */
509 if (mbclen == 0 || remain_len == 0) 509 if (mbclen == 0 || remain_len == 0)
@@ -521,13 +521,11 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
521 *last_wc = wc; 521 *last_wc = wc;
522 return rawbuf_idx; 522 return rawbuf_idx;
523} 523}
524#endif /* RE_ENABLE_I18N */
525 524
526/* Build the buffer PSTR->MBS, and apply the translation if we need. 525/* Build the buffer PSTR->MBS, and apply the translation if we need.
527 This function is used in case of REG_ICASE. */ 526 This function is used in case of REG_ICASE. */
528 527
529static void 528static void
530internal_function
531build_upper_buffer (re_string_t *pstr) 529build_upper_buffer (re_string_t *pstr)
532{ 530{
533 Idx char_idx, end_idx; 531 Idx char_idx, end_idx;
@@ -536,12 +534,9 @@ build_upper_buffer (re_string_t *pstr)
536 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) 534 for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx)
537 { 535 {
538 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; 536 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx];
539 if (BE (pstr->trans != NULL, 0)) 537 if (__glibc_unlikely (pstr->trans != NULL))
540 ch = pstr->trans[ch]; 538 ch = pstr->trans[ch];
541 if (islower (ch)) 539 pstr->mbs[char_idx] = toupper (ch);
542 pstr->mbs[char_idx] = toupper (ch);
543 else
544 pstr->mbs[char_idx] = ch;
545 } 540 }
546 pstr->valid_len = char_idx; 541 pstr->valid_len = char_idx;
547 pstr->valid_raw_len = char_idx; 542 pstr->valid_raw_len = char_idx;
@@ -550,7 +545,6 @@ build_upper_buffer (re_string_t *pstr)
550/* Apply TRANS to the buffer in PSTR. */ 545/* Apply TRANS to the buffer in PSTR. */
551 546
552static void 547static void
553internal_function
554re_string_translate_buffer (re_string_t *pstr) 548re_string_translate_buffer (re_string_t *pstr)
555{ 549{
556 Idx buf_idx, end_idx; 550 Idx buf_idx, end_idx;
@@ -571,20 +565,18 @@ re_string_translate_buffer (re_string_t *pstr)
571 convert to upper case in case of REG_ICASE, apply translation. */ 565 convert to upper case in case of REG_ICASE, apply translation. */
572 566
573static reg_errcode_t 567static reg_errcode_t
574internal_function __attribute_warn_unused_result__ 568__attribute_warn_unused_result__
575re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags) 569re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
576{ 570{
577 Idx offset; 571 Idx offset;
578 572
579 if (BE (pstr->raw_mbs_idx <= idx, 0)) 573 if (__glibc_unlikely (pstr->raw_mbs_idx <= idx))
580 offset = idx - pstr->raw_mbs_idx; 574 offset = idx - pstr->raw_mbs_idx;
581 else 575 else
582 { 576 {
583 /* Reset buffer. */ 577 /* Reset buffer. */
584#ifdef RE_ENABLE_I18N
585 if (pstr->mb_cur_max > 1) 578 if (pstr->mb_cur_max > 1)
586 memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); 579 memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
587#endif /* RE_ENABLE_I18N */
588 pstr->len = pstr->raw_len; 580 pstr->len = pstr->raw_len;
589 pstr->stop = pstr->raw_stop; 581 pstr->stop = pstr->raw_stop;
590 pstr->valid_len = 0; 582 pstr->valid_len = 0;
@@ -598,14 +590,13 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
598 offset = idx; 590 offset = idx;
599 } 591 }
600 592
601 if (BE (offset != 0, 1)) 593 if (__glibc_likely (offset != 0))
602 { 594 {
603 /* Should the already checked characters be kept? */ 595 /* Should the already checked characters be kept? */
604 if (BE (offset < pstr->valid_raw_len, 1)) 596 if (__glibc_likely (offset < pstr->valid_raw_len))
605 { 597 {
606 /* Yes, move them to the front of the buffer. */ 598 /* Yes, move them to the front of the buffer. */
607#ifdef RE_ENABLE_I18N 599 if (__glibc_unlikely (pstr->offsets_needed))
608 if (BE (pstr->offsets_needed, 0))
609 { 600 {
610 Idx low = 0, high = pstr->valid_len, mid; 601 Idx low = 0, high = pstr->valid_len, mid;
611 do 602 do
@@ -668,40 +659,32 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
668 } 659 }
669 } 660 }
670 else 661 else
671#endif
672 { 662 {
673 pstr->tip_context = re_string_context_at (pstr, offset - 1, 663 pstr->tip_context = re_string_context_at (pstr, offset - 1,
674 eflags); 664 eflags);
675#ifdef RE_ENABLE_I18N
676 if (pstr->mb_cur_max > 1) 665 if (pstr->mb_cur_max > 1)
677 memmove (pstr->wcs, pstr->wcs + offset, 666 memmove (pstr->wcs, pstr->wcs + offset,
678 (pstr->valid_len - offset) * sizeof (wint_t)); 667 (pstr->valid_len - offset) * sizeof (wint_t));
679#endif /* RE_ENABLE_I18N */ 668 if (__glibc_unlikely (pstr->mbs_allocated))
680 if (BE (pstr->mbs_allocated, 0))
681 memmove (pstr->mbs, pstr->mbs + offset, 669 memmove (pstr->mbs, pstr->mbs + offset,
682 pstr->valid_len - offset); 670 pstr->valid_len - offset);
683 pstr->valid_len -= offset; 671 pstr->valid_len -= offset;
684 pstr->valid_raw_len -= offset; 672 pstr->valid_raw_len -= offset;
685#if DEBUG 673 DEBUG_ASSERT (pstr->valid_len > 0);
686 assert (pstr->valid_len > 0);
687#endif
688 } 674 }
689 } 675 }
690 else 676 else
691 { 677 {
692#ifdef RE_ENABLE_I18N
693 /* No, skip all characters until IDX. */ 678 /* No, skip all characters until IDX. */
694 Idx prev_valid_len = pstr->valid_len; 679 Idx prev_valid_len = pstr->valid_len;
695 680
696 if (BE (pstr->offsets_needed, 0)) 681 if (__glibc_unlikely (pstr->offsets_needed))
697 { 682 {
698 pstr->len = pstr->raw_len - idx + offset; 683 pstr->len = pstr->raw_len - idx + offset;
699 pstr->stop = pstr->raw_stop - idx + offset; 684 pstr->stop = pstr->raw_stop - idx + offset;
700 pstr->offsets_needed = 0; 685 pstr->offsets_needed = 0;
701 } 686 }
702#endif
703 pstr->valid_len = 0; 687 pstr->valid_len = 0;
704#ifdef RE_ENABLE_I18N
705 if (pstr->mb_cur_max > 1) 688 if (pstr->mb_cur_max > 1)
706 { 689 {
707 Idx wcs_idx; 690 Idx wcs_idx;
@@ -721,7 +704,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
721#ifdef _LIBC 704#ifdef _LIBC
722 /* We know the wchar_t encoding is UCS4, so for the simple 705 /* We know the wchar_t encoding is UCS4, so for the simple
723 case, ASCII characters, skip the conversion step. */ 706 case, ASCII characters, skip the conversion step. */
724 if (isascii (*p) && BE (pstr->trans == NULL, 1)) 707 if (isascii (*p) && __glibc_likely (pstr->trans == NULL))
725 { 708 {
726 memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); 709 memset (&pstr->cur_state, '\0', sizeof (mbstate_t));
727 /* pstr->valid_len = 0; */ 710 /* pstr->valid_len = 0; */
@@ -739,7 +722,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
739 size_t mbclen; 722 size_t mbclen;
740 723
741 const unsigned char *pp = p; 724 const unsigned char *pp = p;
742 if (BE (pstr->trans != NULL, 0)) 725 if (__glibc_unlikely (pstr->trans != NULL))
743 { 726 {
744 int i = mlen < 6 ? mlen : 6; 727 int i = mlen < 6 ? mlen : 6;
745 while (--i >= 0) 728 while (--i >= 0)
@@ -769,13 +752,13 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
769 pstr->tip_context 752 pstr->tip_context
770 = re_string_context_at (pstr, prev_valid_len - 1, eflags); 753 = re_string_context_at (pstr, prev_valid_len - 1, eflags);
771 else 754 else
772 pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) 755 pstr->tip_context = ((__glibc_unlikely (pstr->word_ops_used != 0)
773 && IS_WIDE_WORD_CHAR (wc)) 756 && IS_WIDE_WORD_CHAR (wc))
774 ? CONTEXT_WORD 757 ? CONTEXT_WORD
775 : ((IS_WIDE_NEWLINE (wc) 758 : ((IS_WIDE_NEWLINE (wc)
776 && pstr->newline_anchor) 759 && pstr->newline_anchor)
777 ? CONTEXT_NEWLINE : 0)); 760 ? CONTEXT_NEWLINE : 0));
778 if (BE (pstr->valid_len, 0)) 761 if (__glibc_unlikely (pstr->valid_len))
779 { 762 {
780 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) 763 for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx)
781 pstr->wcs[wcs_idx] = WEOF; 764 pstr->wcs[wcs_idx] = WEOF;
@@ -785,7 +768,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
785 pstr->valid_raw_len = pstr->valid_len; 768 pstr->valid_raw_len = pstr->valid_len;
786 } 769 }
787 else 770 else
788#endif /* RE_ENABLE_I18N */
789 { 771 {
790 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; 772 int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1];
791 pstr->valid_raw_len = 0; 773 pstr->valid_raw_len = 0;
@@ -797,7 +779,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
797 ? CONTEXT_NEWLINE : 0)); 779 ? CONTEXT_NEWLINE : 0));
798 } 780 }
799 } 781 }
800 if (!BE (pstr->mbs_allocated, 0)) 782 if (!__glibc_unlikely (pstr->mbs_allocated))
801 pstr->mbs += offset; 783 pstr->mbs += offset;
802 } 784 }
803 pstr->raw_mbs_idx = idx; 785 pstr->raw_mbs_idx = idx;
@@ -805,21 +787,19 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
805 pstr->stop -= offset; 787 pstr->stop -= offset;
806 788
807 /* Then build the buffers. */ 789 /* Then build the buffers. */
808#ifdef RE_ENABLE_I18N
809 if (pstr->mb_cur_max > 1) 790 if (pstr->mb_cur_max > 1)
810 { 791 {
811 if (pstr->icase) 792 if (pstr->icase)
812 { 793 {
813 reg_errcode_t ret = build_wcs_upper_buffer (pstr); 794 reg_errcode_t ret = build_wcs_upper_buffer (pstr);
814 if (BE (ret != REG_NOERROR, 0)) 795 if (__glibc_unlikely (ret != REG_NOERROR))
815 return ret; 796 return ret;
816 } 797 }
817 else 798 else
818 build_wcs_buffer (pstr); 799 build_wcs_buffer (pstr);
819 } 800 }
820 else 801 else
821#endif /* RE_ENABLE_I18N */ 802 if (__glibc_unlikely (pstr->mbs_allocated))
822 if (BE (pstr->mbs_allocated, 0))
823 { 803 {
824 if (pstr->icase) 804 if (pstr->icase)
825 build_upper_buffer (pstr); 805 build_upper_buffer (pstr);
@@ -834,50 +814,42 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
834} 814}
835 815
836static unsigned char 816static unsigned char
837internal_function __attribute__ ((pure)) 817__attribute__ ((pure))
838re_string_peek_byte_case (const re_string_t *pstr, Idx idx) 818re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
839{ 819{
840 int ch; 820 int ch;
841 Idx off; 821 Idx off;
842 822
843 /* Handle the common (easiest) cases first. */ 823 /* Handle the common (easiest) cases first. */
844 if (BE (!pstr->mbs_allocated, 1)) 824 if (__glibc_likely (!pstr->mbs_allocated))
845 return re_string_peek_byte (pstr, idx); 825 return re_string_peek_byte (pstr, idx);
846 826
847#ifdef RE_ENABLE_I18N
848 if (pstr->mb_cur_max > 1 827 if (pstr->mb_cur_max > 1
849 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) 828 && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx))
850 return re_string_peek_byte (pstr, idx); 829 return re_string_peek_byte (pstr, idx);
851#endif
852 830
853 off = pstr->cur_idx + idx; 831 off = pstr->cur_idx + idx;
854#ifdef RE_ENABLE_I18N
855 if (pstr->offsets_needed) 832 if (pstr->offsets_needed)
856 off = pstr->offsets[off]; 833 off = pstr->offsets[off];
857#endif
858 834
859 ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; 835 ch = pstr->raw_mbs[pstr->raw_mbs_idx + off];
860 836
861#ifdef RE_ENABLE_I18N
862 /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I 837 /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I
863 this function returns CAPITAL LETTER I instead of first byte of 838 this function returns CAPITAL LETTER I instead of first byte of
864 DOTLESS SMALL LETTER I. The latter would confuse the parser, 839 DOTLESS SMALL LETTER I. The latter would confuse the parser,
865 since peek_byte_case doesn't advance cur_idx in any way. */ 840 since peek_byte_case doesn't advance cur_idx in any way. */
866 if (pstr->offsets_needed && !isascii (ch)) 841 if (pstr->offsets_needed && !isascii (ch))
867 return re_string_peek_byte (pstr, idx); 842 return re_string_peek_byte (pstr, idx);
868#endif
869 843
870 return ch; 844 return ch;
871} 845}
872 846
873static unsigned char 847static unsigned char
874internal_function
875re_string_fetch_byte_case (re_string_t *pstr) 848re_string_fetch_byte_case (re_string_t *pstr)
876{ 849{
877 if (BE (!pstr->mbs_allocated, 1)) 850 if (__glibc_likely (!pstr->mbs_allocated))
878 return re_string_fetch_byte (pstr); 851 return re_string_fetch_byte (pstr);
879 852
880#ifdef RE_ENABLE_I18N
881 if (pstr->offsets_needed) 853 if (pstr->offsets_needed)
882 { 854 {
883 Idx off; 855 Idx off;
@@ -903,19 +875,15 @@ re_string_fetch_byte_case (re_string_t *pstr)
903 re_string_char_size_at (pstr, pstr->cur_idx)); 875 re_string_char_size_at (pstr, pstr->cur_idx));
904 return ch; 876 return ch;
905 } 877 }
906#endif
907 878
908 return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; 879 return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++];
909} 880}
910 881
911static void 882static void
912internal_function
913re_string_destruct (re_string_t *pstr) 883re_string_destruct (re_string_t *pstr)
914{ 884{
915#ifdef RE_ENABLE_I18N
916 re_free (pstr->wcs); 885 re_free (pstr->wcs);
917 re_free (pstr->offsets); 886 re_free (pstr->offsets);
918#endif /* RE_ENABLE_I18N */
919 if (pstr->mbs_allocated) 887 if (pstr->mbs_allocated)
920 re_free (pstr->mbs); 888 re_free (pstr->mbs);
921} 889}
@@ -923,40 +891,35 @@ re_string_destruct (re_string_t *pstr)
923/* Return the context at IDX in INPUT. */ 891/* Return the context at IDX in INPUT. */
924 892
925static unsigned int 893static unsigned int
926internal_function
927re_string_context_at (const re_string_t *input, Idx idx, int eflags) 894re_string_context_at (const re_string_t *input, Idx idx, int eflags)
928{ 895{
929 int c; 896 int c;
930 if (BE (! REG_VALID_INDEX (idx), 0)) 897 if (__glibc_unlikely (idx < 0))
931 /* In this case, we use the value stored in input->tip_context, 898 /* In this case, we use the value stored in input->tip_context,
932 since we can't know the character in input->mbs[-1] here. */ 899 since we can't know the character in input->mbs[-1] here. */
933 return input->tip_context; 900 return input->tip_context;
934 if (BE (idx == input->len, 0)) 901 if (__glibc_unlikely (idx == input->len))
935 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF 902 return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF
936 : CONTEXT_NEWLINE | CONTEXT_ENDBUF); 903 : CONTEXT_NEWLINE | CONTEXT_ENDBUF);
937#ifdef RE_ENABLE_I18N
938 if (input->mb_cur_max > 1) 904 if (input->mb_cur_max > 1)
939 { 905 {
940 wint_t wc; 906 wint_t wc;
941 Idx wc_idx = idx; 907 Idx wc_idx = idx;
942 while(input->wcs[wc_idx] == WEOF) 908 while(input->wcs[wc_idx] == WEOF)
943 { 909 {
944#ifdef DEBUG 910 DEBUG_ASSERT (wc_idx >= 0);
945 /* It must not happen. */
946 assert (REG_VALID_INDEX (wc_idx));
947#endif
948 --wc_idx; 911 --wc_idx;
949 if (! REG_VALID_INDEX (wc_idx)) 912 if (wc_idx < 0)
950 return input->tip_context; 913 return input->tip_context;
951 } 914 }
952 wc = input->wcs[wc_idx]; 915 wc = input->wcs[wc_idx];
953 if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) 916 if (__glibc_unlikely (input->word_ops_used != 0)
917 && IS_WIDE_WORD_CHAR (wc))
954 return CONTEXT_WORD; 918 return CONTEXT_WORD;
955 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor 919 return (IS_WIDE_NEWLINE (wc) && input->newline_anchor
956 ? CONTEXT_NEWLINE : 0); 920 ? CONTEXT_NEWLINE : 0);
957 } 921 }
958 else 922 else
959#endif
960 { 923 {
961 c = re_string_byte_at (input, idx); 924 c = re_string_byte_at (input, idx);
962 if (bitset_contain (input->word_char, c)) 925 if (bitset_contain (input->word_char, c))
@@ -968,25 +931,26 @@ re_string_context_at (const re_string_t *input, Idx idx, int eflags)
968/* Functions for set operation. */ 931/* Functions for set operation. */
969 932
970static reg_errcode_t 933static reg_errcode_t
971internal_function __attribute_warn_unused_result__ 934__attribute_warn_unused_result__
972re_node_set_alloc (re_node_set *set, Idx size) 935re_node_set_alloc (re_node_set *set, Idx size)
973{ 936{
974 set->alloc = size; 937 set->alloc = size;
975 set->nelem = 0; 938 set->nelem = 0;
976 set->elems = re_malloc (Idx, size); 939 set->elems = re_malloc (Idx, size);
977 if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0)) 940 if (__glibc_unlikely (set->elems == NULL)
941 && (MALLOC_0_IS_NONNULL || size != 0))
978 return REG_ESPACE; 942 return REG_ESPACE;
979 return REG_NOERROR; 943 return REG_NOERROR;
980} 944}
981 945
982static reg_errcode_t 946static reg_errcode_t
983internal_function __attribute_warn_unused_result__ 947__attribute_warn_unused_result__
984re_node_set_init_1 (re_node_set *set, Idx elem) 948re_node_set_init_1 (re_node_set *set, Idx elem)
985{ 949{
986 set->alloc = 1; 950 set->alloc = 1;
987 set->nelem = 1; 951 set->nelem = 1;
988 set->elems = re_malloc (Idx, 1); 952 set->elems = re_malloc (Idx, 1);
989 if (BE (set->elems == NULL, 0)) 953 if (__glibc_unlikely (set->elems == NULL))
990 { 954 {
991 set->alloc = set->nelem = 0; 955 set->alloc = set->nelem = 0;
992 return REG_ESPACE; 956 return REG_ESPACE;
@@ -996,12 +960,12 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
996} 960}
997 961
998static reg_errcode_t 962static reg_errcode_t
999internal_function __attribute_warn_unused_result__ 963__attribute_warn_unused_result__
1000re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2) 964re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
1001{ 965{
1002 set->alloc = 2; 966 set->alloc = 2;
1003 set->elems = re_malloc (Idx, 2); 967 set->elems = re_malloc (Idx, 2);
1004 if (BE (set->elems == NULL, 0)) 968 if (__glibc_unlikely (set->elems == NULL))
1005 return REG_ESPACE; 969 return REG_ESPACE;
1006 if (elem1 == elem2) 970 if (elem1 == elem2)
1007 { 971 {
@@ -1026,7 +990,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
1026} 990}
1027 991
1028static reg_errcode_t 992static reg_errcode_t
1029internal_function __attribute_warn_unused_result__ 993__attribute_warn_unused_result__
1030re_node_set_init_copy (re_node_set *dest, const re_node_set *src) 994re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1031{ 995{
1032 dest->nelem = src->nelem; 996 dest->nelem = src->nelem;
@@ -1034,7 +998,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1034 { 998 {
1035 dest->alloc = dest->nelem; 999 dest->alloc = dest->nelem;
1036 dest->elems = re_malloc (Idx, dest->alloc); 1000 dest->elems = re_malloc (Idx, dest->alloc);
1037 if (BE (dest->elems == NULL, 0)) 1001 if (__glibc_unlikely (dest->elems == NULL))
1038 { 1002 {
1039 dest->alloc = dest->nelem = 0; 1003 dest->alloc = dest->nelem = 0;
1040 return REG_ESPACE; 1004 return REG_ESPACE;
@@ -1051,7 +1015,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
1051 Note: We assume dest->elems is NULL, when dest->alloc is 0. */ 1015 Note: We assume dest->elems is NULL, when dest->alloc is 0. */
1052 1016
1053static reg_errcode_t 1017static reg_errcode_t
1054internal_function __attribute_warn_unused_result__ 1018__attribute_warn_unused_result__
1055re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, 1019re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1056 const re_node_set *src2) 1020 const re_node_set *src2)
1057{ 1021{
@@ -1065,7 +1029,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1065 { 1029 {
1066 Idx new_alloc = src1->nelem + src2->nelem + dest->alloc; 1030 Idx new_alloc = src1->nelem + src2->nelem + dest->alloc;
1067 Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc); 1031 Idx *new_elems = re_realloc (dest->elems, Idx, new_alloc);
1068 if (BE (new_elems == NULL, 0)) 1032 if (__glibc_unlikely (new_elems == NULL))
1069 return REG_ESPACE; 1033 return REG_ESPACE;
1070 dest->elems = new_elems; 1034 dest->elems = new_elems;
1071 dest->alloc = new_alloc; 1035 dest->alloc = new_alloc;
@@ -1082,25 +1046,25 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1082 if (src1->elems[i1] == src2->elems[i2]) 1046 if (src1->elems[i1] == src2->elems[i2])
1083 { 1047 {
1084 /* Try to find the item in DEST. Maybe we could binary search? */ 1048 /* Try to find the item in DEST. Maybe we could binary search? */
1085 while (REG_VALID_INDEX (id) && dest->elems[id] > src1->elems[i1]) 1049 while (id >= 0 && dest->elems[id] > src1->elems[i1])
1086 --id; 1050 --id;
1087 1051
1088 if (! REG_VALID_INDEX (id) || dest->elems[id] != src1->elems[i1]) 1052 if (id < 0 || dest->elems[id] != src1->elems[i1])
1089 dest->elems[--sbase] = src1->elems[i1]; 1053 dest->elems[--sbase] = src1->elems[i1];
1090 1054
1091 if (! REG_VALID_INDEX (--i1) || ! REG_VALID_INDEX (--i2)) 1055 if (--i1 < 0 || --i2 < 0)
1092 break; 1056 break;
1093 } 1057 }
1094 1058
1095 /* Lower the highest of the two items. */ 1059 /* Lower the highest of the two items. */
1096 else if (src1->elems[i1] < src2->elems[i2]) 1060 else if (src1->elems[i1] < src2->elems[i2])
1097 { 1061 {
1098 if (! REG_VALID_INDEX (--i2)) 1062 if (--i2 < 0)
1099 break; 1063 break;
1100 } 1064 }
1101 else 1065 else
1102 { 1066 {
1103 if (! REG_VALID_INDEX (--i1)) 1067 if (--i1 < 0)
1104 break; 1068 break;
1105 } 1069 }
1106 } 1070 }
@@ -1113,7 +1077,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1113 DEST elements are already in place; this is more or 1077 DEST elements are already in place; this is more or
1114 less the same loop that is in re_node_set_merge. */ 1078 less the same loop that is in re_node_set_merge. */
1115 dest->nelem += delta; 1079 dest->nelem += delta;
1116 if (delta > 0 && REG_VALID_INDEX (id)) 1080 if (delta > 0 && id >= 0)
1117 for (;;) 1081 for (;;)
1118 { 1082 {
1119 if (dest->elems[is] > dest->elems[id]) 1083 if (dest->elems[is] > dest->elems[id])
@@ -1127,7 +1091,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1127 { 1091 {
1128 /* Slide from the bottom. */ 1092 /* Slide from the bottom. */
1129 dest->elems[id + delta] = dest->elems[id]; 1093 dest->elems[id + delta] = dest->elems[id];
1130 if (! REG_VALID_INDEX (--id)) 1094 if (--id < 0)
1131 break; 1095 break;
1132 } 1096 }
1133 } 1097 }
@@ -1142,7 +1106,7 @@ re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1,
1142 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ 1106 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
1143 1107
1144static reg_errcode_t 1108static reg_errcode_t
1145internal_function __attribute_warn_unused_result__ 1109__attribute_warn_unused_result__
1146re_node_set_init_union (re_node_set *dest, const re_node_set *src1, 1110re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1147 const re_node_set *src2) 1111 const re_node_set *src2)
1148{ 1112{
@@ -1151,7 +1115,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1151 { 1115 {
1152 dest->alloc = src1->nelem + src2->nelem; 1116 dest->alloc = src1->nelem + src2->nelem;
1153 dest->elems = re_malloc (Idx, dest->alloc); 1117 dest->elems = re_malloc (Idx, dest->alloc);
1154 if (BE (dest->elems == NULL, 0)) 1118 if (__glibc_unlikely (dest->elems == NULL))
1155 return REG_ESPACE; 1119 return REG_ESPACE;
1156 } 1120 }
1157 else 1121 else
@@ -1195,7 +1159,7 @@ re_node_set_init_union (re_node_set *dest, const re_node_set *src1,
1195 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ 1159 DEST. Return value indicate the error code or REG_NOERROR if succeeded. */
1196 1160
1197static reg_errcode_t 1161static reg_errcode_t
1198internal_function __attribute_warn_unused_result__ 1162__attribute_warn_unused_result__
1199re_node_set_merge (re_node_set *dest, const re_node_set *src) 1163re_node_set_merge (re_node_set *dest, const re_node_set *src)
1200{ 1164{
1201 Idx is, id, sbase, delta; 1165 Idx is, id, sbase, delta;
@@ -1205,14 +1169,18 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1205 { 1169 {
1206 Idx new_alloc = 2 * (src->nelem + dest->alloc); 1170 Idx new_alloc = 2 * (src->nelem + dest->alloc);
1207 Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc); 1171 Idx *new_buffer = re_realloc (dest->elems, Idx, new_alloc);
1208 if (BE (new_buffer == NULL, 0)) 1172 if (__glibc_unlikely (new_buffer == NULL))
1209 return REG_ESPACE; 1173 return REG_ESPACE;
1210 dest->elems = new_buffer; 1174 dest->elems = new_buffer;
1211 dest->alloc = new_alloc; 1175 dest->alloc = new_alloc;
1212 } 1176 }
1213 1177
1214 if (BE (dest->nelem == 0, 0)) 1178 if (__glibc_unlikely (dest->nelem == 0))
1215 { 1179 {
1180 /* Although we already guaranteed above that dest->alloc != 0 and
1181 therefore dest->elems != NULL, add a debug assertion to pacify
1182 GCC 11.2.1's -fanalyzer. */
1183 DEBUG_ASSERT (dest->elems);
1216 dest->nelem = src->nelem; 1184 dest->nelem = src->nelem;
1217 memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx)); 1185 memcpy (dest->elems, src->elems, src->nelem * sizeof (Idx));
1218 return REG_NOERROR; 1186 return REG_NOERROR;
@@ -1221,8 +1189,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1221 /* Copy into the top of DEST the items of SRC that are not 1189 /* Copy into the top of DEST the items of SRC that are not
1222 found in DEST. Maybe we could binary search in DEST? */ 1190 found in DEST. Maybe we could binary search in DEST? */
1223 for (sbase = dest->nelem + 2 * src->nelem, 1191 for (sbase = dest->nelem + 2 * src->nelem,
1224 is = src->nelem - 1, id = dest->nelem - 1; 1192 is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; )
1225 REG_VALID_INDEX (is) && REG_VALID_INDEX (id); )
1226 { 1193 {
1227 if (dest->elems[id] == src->elems[is]) 1194 if (dest->elems[id] == src->elems[is])
1228 is--, id--; 1195 is--, id--;
@@ -1232,7 +1199,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1232 --id; 1199 --id;
1233 } 1200 }
1234 1201
1235 if (REG_VALID_INDEX (is)) 1202 if (is >= 0)
1236 { 1203 {
1237 /* If DEST is exhausted, the remaining items of SRC must be unique. */ 1204 /* If DEST is exhausted, the remaining items of SRC must be unique. */
1238 sbase -= is + 1; 1205 sbase -= is + 1;
@@ -1261,7 +1228,7 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1261 { 1228 {
1262 /* Slide from the bottom. */ 1229 /* Slide from the bottom. */
1263 dest->elems[id + delta] = dest->elems[id]; 1230 dest->elems[id + delta] = dest->elems[id];
1264 if (! REG_VALID_INDEX (--id)) 1231 if (--id < 0)
1265 { 1232 {
1266 /* Copy remaining SRC elements. */ 1233 /* Copy remaining SRC elements. */
1267 memcpy (dest->elems, dest->elems + sbase, 1234 memcpy (dest->elems, dest->elems + sbase,
@@ -1279,17 +1246,20 @@ re_node_set_merge (re_node_set *dest, const re_node_set *src)
1279 Return true if successful. */ 1246 Return true if successful. */
1280 1247
1281static bool 1248static bool
1282internal_function __attribute_warn_unused_result__ 1249__attribute_warn_unused_result__
1283re_node_set_insert (re_node_set *set, Idx elem) 1250re_node_set_insert (re_node_set *set, Idx elem)
1284{ 1251{
1285 Idx idx; 1252 Idx idx;
1286 /* In case the set is empty. */ 1253 /* In case the set is empty. */
1287 if (set->alloc == 0) 1254 if (set->alloc == 0)
1288 return BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1); 1255 return __glibc_likely (re_node_set_init_1 (set, elem) == REG_NOERROR);
1289 1256
1290 if (BE (set->nelem, 0) == 0) 1257 if (__glibc_unlikely (set->nelem) == 0)
1291 { 1258 {
1292 /* We already guaranteed above that set->alloc != 0. */ 1259 /* Although we already guaranteed above that set->alloc != 0 and
1260 therefore set->elems != NULL, add a debug assertion to pacify
1261 GCC 11.2 -fanalyzer. */
1262 DEBUG_ASSERT (set->elems);
1293 set->elems[0] = elem; 1263 set->elems[0] = elem;
1294 ++set->nelem; 1264 ++set->nelem;
1295 return true; 1265 return true;
@@ -1301,7 +1271,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1301 Idx *new_elems; 1271 Idx *new_elems;
1302 set->alloc = set->alloc * 2; 1272 set->alloc = set->alloc * 2;
1303 new_elems = re_realloc (set->elems, Idx, set->alloc); 1273 new_elems = re_realloc (set->elems, Idx, set->alloc);
1304 if (BE (new_elems == NULL, 0)) 1274 if (__glibc_unlikely (new_elems == NULL))
1305 return false; 1275 return false;
1306 set->elems = new_elems; 1276 set->elems = new_elems;
1307 } 1277 }
@@ -1310,7 +1280,6 @@ re_node_set_insert (re_node_set *set, Idx elem)
1310 first element separately to skip a check in the inner loop. */ 1280 first element separately to skip a check in the inner loop. */
1311 if (elem < set->elems[0]) 1281 if (elem < set->elems[0])
1312 { 1282 {
1313 idx = 0;
1314 for (idx = set->nelem; idx > 0; idx--) 1283 for (idx = set->nelem; idx > 0; idx--)
1315 set->elems[idx] = set->elems[idx - 1]; 1284 set->elems[idx] = set->elems[idx - 1];
1316 } 1285 }
@@ -1318,6 +1287,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1318 { 1287 {
1319 for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) 1288 for (idx = set->nelem; set->elems[idx - 1] > elem; idx--)
1320 set->elems[idx] = set->elems[idx - 1]; 1289 set->elems[idx] = set->elems[idx - 1];
1290 DEBUG_ASSERT (set->elems[idx - 1] < elem);
1321 } 1291 }
1322 1292
1323 /* Insert the new element. */ 1293 /* Insert the new element. */
@@ -1331,7 +1301,7 @@ re_node_set_insert (re_node_set *set, Idx elem)
1331 Return true if successful. */ 1301 Return true if successful. */
1332 1302
1333static bool 1303static bool
1334internal_function __attribute_warn_unused_result__ 1304__attribute_warn_unused_result__
1335re_node_set_insert_last (re_node_set *set, Idx elem) 1305re_node_set_insert_last (re_node_set *set, Idx elem)
1336{ 1306{
1337 /* Realloc if we need. */ 1307 /* Realloc if we need. */
@@ -1340,7 +1310,7 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
1340 Idx *new_elems; 1310 Idx *new_elems;
1341 set->alloc = (set->alloc + 1) * 2; 1311 set->alloc = (set->alloc + 1) * 2;
1342 new_elems = re_realloc (set->elems, Idx, set->alloc); 1312 new_elems = re_realloc (set->elems, Idx, set->alloc);
1343 if (BE (new_elems == NULL, 0)) 1313 if (__glibc_unlikely (new_elems == NULL))
1344 return false; 1314 return false;
1345 set->elems = new_elems; 1315 set->elems = new_elems;
1346 } 1316 }
@@ -1354,13 +1324,13 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
1354 Return true if SET1 and SET2 are equivalent. */ 1324 Return true if SET1 and SET2 are equivalent. */
1355 1325
1356static bool 1326static bool
1357internal_function __attribute__ ((pure)) 1327__attribute__ ((pure))
1358re_node_set_compare (const re_node_set *set1, const re_node_set *set2) 1328re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
1359{ 1329{
1360 Idx i; 1330 Idx i;
1361 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) 1331 if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem)
1362 return false; 1332 return false;
1363 for (i = set1->nelem ; REG_VALID_INDEX (--i) ; ) 1333 for (i = set1->nelem ; --i >= 0 ; )
1364 if (set1->elems[i] != set2->elems[i]) 1334 if (set1->elems[i] != set2->elems[i])
1365 return false; 1335 return false;
1366 return true; 1336 return true;
@@ -1369,11 +1339,11 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
1369/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ 1339/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
1370 1340
1371static Idx 1341static Idx
1372internal_function __attribute__ ((pure)) 1342__attribute__ ((pure))
1373re_node_set_contains (const re_node_set *set, Idx elem) 1343re_node_set_contains (const re_node_set *set, Idx elem)
1374{ 1344{
1375 __re_size_t idx, right, mid; 1345 __re_size_t idx, right, mid;
1376 if (! REG_VALID_NONZERO_INDEX (set->nelem)) 1346 if (set->nelem <= 0)
1377 return 0; 1347 return 0;
1378 1348
1379 /* Binary search the element. */ 1349 /* Binary search the element. */
@@ -1391,7 +1361,6 @@ re_node_set_contains (const re_node_set *set, Idx elem)
1391} 1361}
1392 1362
1393static void 1363static void
1394internal_function
1395re_node_set_remove_at (re_node_set *set, Idx idx) 1364re_node_set_remove_at (re_node_set *set, Idx idx)
1396{ 1365{
1397 if (idx < 0 || idx >= set->nelem) 1366 if (idx < 0 || idx >= set->nelem)
@@ -1403,13 +1372,12 @@ re_node_set_remove_at (re_node_set *set, Idx idx)
1403 1372
1404 1373
1405/* Add the token TOKEN to dfa->nodes, and return the index of the token. 1374/* Add the token TOKEN to dfa->nodes, and return the index of the token.
1406 Or return REG_MISSING if an error occurred. */ 1375 Or return -1 if an error occurred. */
1407 1376
1408static Idx 1377static Idx
1409internal_function
1410re_dfa_add_node (re_dfa_t *dfa, re_token_t token) 1378re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1411{ 1379{
1412 if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) 1380 if (__glibc_unlikely (dfa->nodes_len >= dfa->nodes_alloc))
1413 { 1381 {
1414 size_t new_nodes_alloc = dfa->nodes_alloc * 2; 1382 size_t new_nodes_alloc = dfa->nodes_alloc * 2;
1415 Idx *new_nexts, *new_indices; 1383 Idx *new_nexts, *new_indices;
@@ -1420,41 +1388,43 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1420 const size_t max_object_size = MAX (sizeof (re_token_t), 1388 const size_t max_object_size = MAX (sizeof (re_token_t),
1421 MAX (sizeof (re_node_set), 1389 MAX (sizeof (re_node_set),
1422 sizeof (Idx))); 1390 sizeof (Idx)));
1423 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0)) 1391 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size)
1424 return REG_MISSING; 1392 < new_nodes_alloc))
1393 return -1;
1425 1394
1426 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); 1395 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
1427 if (BE (new_nodes == NULL, 0)) 1396 if (__glibc_unlikely (new_nodes == NULL))
1428 return REG_MISSING; 1397 return -1;
1429 dfa->nodes = new_nodes; 1398 dfa->nodes = new_nodes;
1399 dfa->nodes_alloc = new_nodes_alloc;
1430 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc); 1400 new_nexts = re_realloc (dfa->nexts, Idx, new_nodes_alloc);
1401 if (new_nexts != NULL)
1402 dfa->nexts = new_nexts;
1431 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc); 1403 new_indices = re_realloc (dfa->org_indices, Idx, new_nodes_alloc);
1404 if (new_indices != NULL)
1405 dfa->org_indices = new_indices;
1432 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); 1406 new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc);
1407 if (new_edests != NULL)
1408 dfa->edests = new_edests;
1433 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); 1409 new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc);
1434 if (BE (new_nexts == NULL || new_indices == NULL 1410 if (new_eclosures != NULL)
1435 || new_edests == NULL || new_eclosures == NULL, 0)) 1411 dfa->eclosures = new_eclosures;
1436 return REG_MISSING; 1412 if (__glibc_unlikely (new_nexts == NULL || new_indices == NULL
1437 dfa->nexts = new_nexts; 1413 || new_edests == NULL || new_eclosures == NULL))
1438 dfa->org_indices = new_indices; 1414 return -1;
1439 dfa->edests = new_edests;
1440 dfa->eclosures = new_eclosures;
1441 dfa->nodes_alloc = new_nodes_alloc;
1442 } 1415 }
1443 dfa->nodes[dfa->nodes_len] = token; 1416 dfa->nodes[dfa->nodes_len] = token;
1444 dfa->nodes[dfa->nodes_len].constraint = 0; 1417 dfa->nodes[dfa->nodes_len].constraint = 0;
1445#ifdef RE_ENABLE_I18N
1446 dfa->nodes[dfa->nodes_len].accept_mb = 1418 dfa->nodes[dfa->nodes_len].accept_mb =
1447 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1) 1419 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
1448 || token.type == COMPLEX_BRACKET); 1420 || token.type == COMPLEX_BRACKET);
1449#endif 1421 dfa->nexts[dfa->nodes_len] = -1;
1450 dfa->nexts[dfa->nodes_len] = REG_MISSING;
1451 re_node_set_init_empty (dfa->edests + dfa->nodes_len); 1422 re_node_set_init_empty (dfa->edests + dfa->nodes_len);
1452 re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); 1423 re_node_set_init_empty (dfa->eclosures + dfa->nodes_len);
1453 return dfa->nodes_len++; 1424 return dfa->nodes_len++;
1454} 1425}
1455 1426
1456static re_hashval_t 1427static re_hashval_t
1457internal_function
1458calc_state_hash (const re_node_set *nodes, unsigned int context) 1428calc_state_hash (const re_node_set *nodes, unsigned int context)
1459{ 1429{
1460 re_hashval_t hash = nodes->nelem + context; 1430 re_hashval_t hash = nodes->nelem + context;
@@ -1474,7 +1444,7 @@ calc_state_hash (const re_node_set *nodes, unsigned int context)
1474 optimization. */ 1444 optimization. */
1475 1445
1476static re_dfastate_t * 1446static re_dfastate_t *
1477internal_function __attribute_warn_unused_result__ 1447__attribute_warn_unused_result__
1478re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, 1448re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1479 const re_node_set *nodes) 1449 const re_node_set *nodes)
1480{ 1450{
@@ -1482,11 +1452,11 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1482 re_dfastate_t *new_state; 1452 re_dfastate_t *new_state;
1483 struct re_state_table_entry *spot; 1453 struct re_state_table_entry *spot;
1484 Idx i; 1454 Idx i;
1485#ifdef lint 1455#if defined GCC_LINT || defined lint
1486 /* Suppress bogus uninitialized-variable warnings. */ 1456 /* Suppress bogus uninitialized-variable warnings. */
1487 *err = REG_NOERROR; 1457 *err = REG_NOERROR;
1488#endif 1458#endif
1489 if (BE (nodes->nelem == 0, 0)) 1459 if (__glibc_unlikely (nodes->nelem == 0))
1490 { 1460 {
1491 *err = REG_NOERROR; 1461 *err = REG_NOERROR;
1492 return NULL; 1462 return NULL;
@@ -1505,7 +1475,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1505 1475
1506 /* There are no appropriate state in the dfa, create the new one. */ 1476 /* There are no appropriate state in the dfa, create the new one. */
1507 new_state = create_ci_newstate (dfa, nodes, hash); 1477 new_state = create_ci_newstate (dfa, nodes, hash);
1508 if (BE (new_state == NULL, 0)) 1478 if (__glibc_unlikely (new_state == NULL))
1509 *err = REG_ESPACE; 1479 *err = REG_ESPACE;
1510 1480
1511 return new_state; 1481 return new_state;
@@ -1522,7 +1492,7 @@ re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa,
1522 optimization. */ 1492 optimization. */
1523 1493
1524static re_dfastate_t * 1494static re_dfastate_t *
1525internal_function __attribute_warn_unused_result__ 1495__attribute_warn_unused_result__
1526re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, 1496re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1527 const re_node_set *nodes, unsigned int context) 1497 const re_node_set *nodes, unsigned int context)
1528{ 1498{
@@ -1530,7 +1500,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1530 re_dfastate_t *new_state; 1500 re_dfastate_t *new_state;
1531 struct re_state_table_entry *spot; 1501 struct re_state_table_entry *spot;
1532 Idx i; 1502 Idx i;
1533#ifdef lint 1503#if defined GCC_LINT || defined lint
1534 /* Suppress bogus uninitialized-variable warnings. */ 1504 /* Suppress bogus uninitialized-variable warnings. */
1535 *err = REG_NOERROR; 1505 *err = REG_NOERROR;
1536#endif 1506#endif
@@ -1552,7 +1522,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1552 } 1522 }
1553 /* There are no appropriate state in 'dfa', create the new one. */ 1523 /* There are no appropriate state in 'dfa', create the new one. */
1554 new_state = create_cd_newstate (dfa, nodes, context, hash); 1524 new_state = create_cd_newstate (dfa, nodes, context, hash);
1555 if (BE (new_state == NULL, 0)) 1525 if (__glibc_unlikely (new_state == NULL))
1556 *err = REG_ESPACE; 1526 *err = REG_ESPACE;
1557 1527
1558 return new_state; 1528 return new_state;
@@ -1573,7 +1543,7 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1573 1543
1574 newstate->hash = hash; 1544 newstate->hash = hash;
1575 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); 1545 err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem);
1576 if (BE (err != REG_NOERROR, 0)) 1546 if (__glibc_unlikely (err != REG_NOERROR))
1577 return REG_ESPACE; 1547 return REG_ESPACE;
1578 for (i = 0; i < newstate->nodes.nelem; i++) 1548 for (i = 0; i < newstate->nodes.nelem; i++)
1579 { 1549 {
@@ -1584,12 +1554,12 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1584 } 1554 }
1585 1555
1586 spot = dfa->state_table + (hash & dfa->state_hash_mask); 1556 spot = dfa->state_table + (hash & dfa->state_hash_mask);
1587 if (BE (spot->alloc <= spot->num, 0)) 1557 if (__glibc_unlikely (spot->alloc <= spot->num))
1588 { 1558 {
1589 Idx new_alloc = 2 * spot->num + 2; 1559 Idx new_alloc = 2 * spot->num + 2;
1590 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, 1560 re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *,
1591 new_alloc); 1561 new_alloc);
1592 if (BE (new_array == NULL, 0)) 1562 if (__glibc_unlikely (new_array == NULL))
1593 return REG_ESPACE; 1563 return REG_ESPACE;
1594 spot->array = new_array; 1564 spot->array = new_array;
1595 spot->alloc = new_alloc; 1565 spot->alloc = new_alloc;
@@ -1618,7 +1588,7 @@ free_state (re_dfastate_t *state)
1618 Return the new state if succeeded, otherwise return NULL. */ 1588 Return the new state if succeeded, otherwise return NULL. */
1619 1589
1620static re_dfastate_t * 1590static re_dfastate_t *
1621internal_function __attribute_warn_unused_result__ 1591__attribute_warn_unused_result__
1622create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, 1592create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1623 re_hashval_t hash) 1593 re_hashval_t hash)
1624{ 1594{
@@ -1627,10 +1597,10 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1627 re_dfastate_t *newstate; 1597 re_dfastate_t *newstate;
1628 1598
1629 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1599 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
1630 if (BE (newstate == NULL, 0)) 1600 if (__glibc_unlikely (newstate == NULL))
1631 return NULL; 1601 return NULL;
1632 err = re_node_set_init_copy (&newstate->nodes, nodes); 1602 err = re_node_set_init_copy (&newstate->nodes, nodes);
1633 if (BE (err != REG_NOERROR, 0)) 1603 if (__glibc_unlikely (err != REG_NOERROR))
1634 { 1604 {
1635 re_free (newstate); 1605 re_free (newstate);
1636 return NULL; 1606 return NULL;
@@ -1643,9 +1613,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1643 re_token_type_t type = node->type; 1613 re_token_type_t type = node->type;
1644 if (type == CHARACTER && !node->constraint) 1614 if (type == CHARACTER && !node->constraint)
1645 continue; 1615 continue;
1646#ifdef RE_ENABLE_I18N
1647 newstate->accept_mb |= node->accept_mb; 1616 newstate->accept_mb |= node->accept_mb;
1648#endif /* RE_ENABLE_I18N */
1649 1617
1650 /* If the state has the halt node, the state is a halt state. */ 1618 /* If the state has the halt node, the state is a halt state. */
1651 if (type == END_OF_RE) 1619 if (type == END_OF_RE)
@@ -1656,7 +1624,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1656 newstate->has_constraint = 1; 1624 newstate->has_constraint = 1;
1657 } 1625 }
1658 err = register_state (dfa, newstate, hash); 1626 err = register_state (dfa, newstate, hash);
1659 if (BE (err != REG_NOERROR, 0)) 1627 if (__glibc_unlikely (err != REG_NOERROR))
1660 { 1628 {
1661 free_state (newstate); 1629 free_state (newstate);
1662 newstate = NULL; 1630 newstate = NULL;
@@ -1668,7 +1636,7 @@ create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1668 Return the new state if succeeded, otherwise return NULL. */ 1636 Return the new state if succeeded, otherwise return NULL. */
1669 1637
1670static re_dfastate_t * 1638static re_dfastate_t *
1671internal_function __attribute_warn_unused_result__ 1639__attribute_warn_unused_result__
1672create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, 1640create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1673 unsigned int context, re_hashval_t hash) 1641 unsigned int context, re_hashval_t hash)
1674{ 1642{
@@ -1677,10 +1645,10 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1677 re_dfastate_t *newstate; 1645 re_dfastate_t *newstate;
1678 1646
1679 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); 1647 newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1);
1680 if (BE (newstate == NULL, 0)) 1648 if (__glibc_unlikely (newstate == NULL))
1681 return NULL; 1649 return NULL;
1682 err = re_node_set_init_copy (&newstate->nodes, nodes); 1650 err = re_node_set_init_copy (&newstate->nodes, nodes);
1683 if (BE (err != REG_NOERROR, 0)) 1651 if (__glibc_unlikely (err != REG_NOERROR))
1684 { 1652 {
1685 re_free (newstate); 1653 re_free (newstate);
1686 return NULL; 1654 return NULL;
@@ -1697,9 +1665,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1697 1665
1698 if (type == CHARACTER && !constraint) 1666 if (type == CHARACTER && !constraint)
1699 continue; 1667 continue;
1700#ifdef RE_ENABLE_I18N
1701 newstate->accept_mb |= node->accept_mb; 1668 newstate->accept_mb |= node->accept_mb;
1702#endif /* RE_ENABLE_I18N */
1703 1669
1704 /* If the state has the halt node, the state is a halt state. */ 1670 /* If the state has the halt node, the state is a halt state. */
1705 if (type == END_OF_RE) 1671 if (type == END_OF_RE)
@@ -1711,15 +1677,19 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1711 { 1677 {
1712 if (newstate->entrance_nodes == &newstate->nodes) 1678 if (newstate->entrance_nodes == &newstate->nodes)
1713 { 1679 {
1714 newstate->entrance_nodes = re_malloc (re_node_set, 1); 1680 re_node_set *entrance_nodes = re_malloc (re_node_set, 1);
1715 if (BE (newstate->entrance_nodes == NULL, 0)) 1681 if (__glibc_unlikely (entrance_nodes == NULL))
1716 { 1682 {
1717 free_state (newstate); 1683 free_state (newstate);
1718 return NULL; 1684 return NULL;
1719 } 1685 }
1686 newstate->entrance_nodes = entrance_nodes;
1720 if (re_node_set_init_copy (newstate->entrance_nodes, nodes) 1687 if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
1721 != REG_NOERROR) 1688 != REG_NOERROR)
1722 return NULL; 1689 {
1690 free_state (newstate);
1691 return NULL;
1692 }
1723 nctx_nodes = 0; 1693 nctx_nodes = 0;
1724 newstate->has_constraint = 1; 1694 newstate->has_constraint = 1;
1725 } 1695 }
@@ -1732,7 +1702,7 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1732 } 1702 }
1733 } 1703 }
1734 err = register_state (dfa, newstate, hash); 1704 err = register_state (dfa, newstate, hash);
1735 if (BE (err != REG_NOERROR, 0)) 1705 if (__glibc_unlikely (err != REG_NOERROR))
1736 { 1706 {
1737 free_state (newstate); 1707 free_state (newstate);
1738 newstate = NULL; 1708 newstate = NULL;
diff --git a/gl/regex_internal.h b/gl/regex_internal.h
index a2b8f16..149ec2e 100644
--- a/gl/regex_internal.h
+++ b/gl/regex_internal.h
@@ -1,26 +1,25 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20#ifndef _REGEX_INTERNAL_H 20#ifndef _REGEX_INTERNAL_H
21#define _REGEX_INTERNAL_H 1 21#define _REGEX_INTERNAL_H 1
22 22
23#include <assert.h>
24#include <ctype.h> 23#include <ctype.h>
25#include <stdio.h> 24#include <stdio.h>
26#include <stdlib.h> 25#include <stdlib.h>
@@ -30,39 +29,37 @@
30#include <locale.h> 29#include <locale.h>
31#include <wchar.h> 30#include <wchar.h>
32#include <wctype.h> 31#include <wctype.h>
33#include <stdbool.h>
34#include <stdint.h> 32#include <stdint.h>
35 33
34#ifndef _LIBC
35# include <dynarray.h>
36#endif
37
38#include <intprops.h>
39#include <verify.h>
40
41#if defined DEBUG && DEBUG != 0
42# include <assert.h>
43# define DEBUG_ASSERT(x) assert (x)
44#else
45# define DEBUG_ASSERT(x) assume (x)
46#endif
47
36#ifdef _LIBC 48#ifdef _LIBC
37# include <bits/libc-lock.h> 49# include <libc-lock.h>
38# define lock_define(name) __libc_lock_define (, name) 50# define lock_define(name) __libc_lock_define (, name)
39# define lock_init(lock) (__libc_lock_init (lock), 0) 51# define lock_init(lock) (__libc_lock_init (lock), 0)
40# define lock_fini(lock) 0 52# define lock_fini(lock) ((void) 0)
41# define lock_lock(lock) __libc_lock_lock (lock) 53# define lock_lock(lock) __libc_lock_lock (lock)
42# define lock_unlock(lock) __libc_lock_unlock (lock) 54# define lock_unlock(lock) __libc_lock_unlock (lock)
43#elif defined GNULIB_LOCK 55#elif defined GNULIB_LOCK && !defined GNULIB_REGEX_SINGLE_THREAD
44# include "glthread/lock.h" 56# include "glthread/lock.h"
45 /* Use gl_lock_define if empty macro arguments are known to work. 57# define lock_define(name) gl_lock_define (, name)
46 Otherwise, fall back on less-portable substitutes. */
47# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
48 || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
49# define lock_define(name) gl_lock_define (, name)
50# elif USE_POSIX_THREADS
51# define lock_define(name) pthread_mutex_t name;
52# elif USE_PTH_THREADS
53# define lock_define(name) pth_mutex_t name;
54# elif USE_SOLARIS_THREADS
55# define lock_define(name) mutex_t name;
56# elif USE_WINDOWS_THREADS
57# define lock_define(name) gl_lock_t name;
58# else
59# define lock_define(name)
60# endif
61# define lock_init(lock) glthread_lock_init (&(lock)) 58# define lock_init(lock) glthread_lock_init (&(lock))
62# define lock_fini(lock) glthread_lock_destroy (&(lock)) 59# define lock_fini(lock) glthread_lock_destroy (&(lock))
63# define lock_lock(lock) glthread_lock_lock (&(lock)) 60# define lock_lock(lock) glthread_lock_lock (&(lock))
64# define lock_unlock(lock) glthread_lock_unlock (&(lock)) 61# define lock_unlock(lock) glthread_lock_unlock (&(lock))
65#elif defined GNULIB_PTHREAD 62#elif defined GNULIB_PTHREAD && !defined GNULIB_REGEX_SINGLE_THREAD
66# include <pthread.h> 63# include <pthread.h>
67# define lock_define(name) pthread_mutex_t name; 64# define lock_define(name) pthread_mutex_t name;
68# define lock_init(lock) pthread_mutex_init (&(lock), 0) 65# define lock_init(lock) pthread_mutex_init (&(lock), 0)
@@ -83,11 +80,18 @@
83# define isblank(ch) ((ch) == ' ' || (ch) == '\t') 80# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
84#endif 81#endif
85 82
83/* regex code assumes isascii has its usual numeric meaning,
84 even if the portable character set uses EBCDIC encoding,
85 and even if wint_t is wider than int. */
86#ifndef _LIBC
87# undef isascii
88# define isascii(c) (((c) & ~0x7f) == 0)
89#endif
90
86#ifdef _LIBC 91#ifdef _LIBC
87# ifndef _RE_DEFINE_LOCALE_FUNCTIONS 92# ifndef _RE_DEFINE_LOCALE_FUNCTIONS
88# define _RE_DEFINE_LOCALE_FUNCTIONS 1 93# define _RE_DEFINE_LOCALE_FUNCTIONS 1
89# include <locale/localeinfo.h> 94# include <locale/localeinfo.h>
90# include <locale/elem-hash.h>
91# include <locale/coll-lookup.h> 95# include <locale/coll-lookup.h>
92# endif 96# endif
93#endif 97#endif
@@ -101,6 +105,7 @@
101 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES) 105 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
102# endif 106# endif
103#else 107#else
108# undef gettext
104# define gettext(msgid) (msgid) 109# define gettext(msgid) (msgid)
105#endif 110#endif
106 111
@@ -110,16 +115,6 @@
110# define gettext_noop(String) String 115# define gettext_noop(String) String
111#endif 116#endif
112 117
113#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
114# define RE_ENABLE_I18N
115#endif
116
117#if __GNUC__ >= 3
118# define BE(expr, val) __builtin_expect (expr, val)
119#else
120# define BE(expr, val) (expr)
121#endif
122
123/* Number of ASCII characters. */ 118/* Number of ASCII characters. */
124#define ASCII_CHARS 0x80 119#define ASCII_CHARS 0x80
125 120
@@ -135,45 +130,60 @@
135/* Rename to standard API for using out of glibc. */ 130/* Rename to standard API for using out of glibc. */
136#ifndef _LIBC 131#ifndef _LIBC
137# undef __wctype 132# undef __wctype
133# undef __iswalnum
138# undef __iswctype 134# undef __iswctype
135# undef __towlower
136# undef __towupper
139# define __wctype wctype 137# define __wctype wctype
138# define __iswalnum iswalnum
140# define __iswctype iswctype 139# define __iswctype iswctype
140# define __towlower towlower
141# define __towupper towupper
141# define __btowc btowc 142# define __btowc btowc
142# define __mbrtowc mbrtowc 143# define __mbrtowc mbrtowc
143# define __wcrtomb wcrtomb 144# define __wcrtomb wcrtomb
144# define __regfree regfree 145# define __regfree regfree
145# define attribute_hidden
146#endif /* not _LIBC */ 146#endif /* not _LIBC */
147 147
148#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1) 148/* Types related to integers. Unless protected by #ifdef _LIBC, the
149# define __attribute__(arg) 149 regex code should avoid exact-width types like int32_t and uint64_t
150#endif 150 as some non-GCC platforms lack them, an issue when this code is
151 used in Gnulib. */
151 152
152typedef __re_idx_t Idx; 153#ifndef SSIZE_MAX
153#ifdef _REGEX_LARGE_OFFSETS 154# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
154# define IDX_MAX (SIZE_MAX - 2)
155#else
156# define IDX_MAX INT_MAX
157#endif 155#endif
158 156#ifndef ULONG_WIDTH
159/* Special return value for failure to match. */ 157# define ULONG_WIDTH REGEX_UINTEGER_WIDTH (ULONG_MAX)
160#define REG_MISSING ((Idx) -1) 158/* The number of usable bits in an unsigned integer type with maximum
161 159 value MAX, as an int expression suitable in #if. Cover all known
162/* Special return value for internal error. */ 160 practical hosts. This implementation exploits the fact that MAX is
163#define REG_ERROR ((Idx) -2) 161 1 less than a power of 2, and merely counts the number of 1 bits in
164 162 MAX; "COBn" means "count the number of 1 bits in the low-order n bits". */
165/* Test whether N is a valid index, and is not one of the above. */ 163# define REGEX_UINTEGER_WIDTH(max) REGEX_COB128 (max)
166#ifdef _REGEX_LARGE_OFFSETS 164# define REGEX_COB128(n) (REGEX_COB64 ((n) >> 31 >> 31 >> 2) + REGEX_COB64 (n))
167# define REG_VALID_INDEX(n) ((Idx) (n) < REG_ERROR) 165# define REGEX_COB64(n) (REGEX_COB32 ((n) >> 31 >> 1) + REGEX_COB32 (n))
168#else 166# define REGEX_COB32(n) (REGEX_COB16 ((n) >> 16) + REGEX_COB16 (n))
169# define REG_VALID_INDEX(n) (0 <= (n)) 167# define REGEX_COB16(n) (REGEX_COB8 ((n) >> 8) + REGEX_COB8 (n))
168# define REGEX_COB8(n) (REGEX_COB4 ((n) >> 4) + REGEX_COB4 (n))
169# define REGEX_COB4(n) (!!((n) & 8) + !!((n) & 4) + !!((n) & 2) + ((n) & 1))
170# if ULONG_MAX / 2 + 1 != 1ul << (ULONG_WIDTH - 1)
171# error "ULONG_MAX out of range"
172# endif
170#endif 173#endif
171 174
172/* Test whether N is a valid nonzero index. */ 175/* The type of indexes into strings. This is signed, not size_t,
176 since the API requires indexes to fit in regoff_t anyway, and using
177 signed integers makes the code a bit smaller and presumably faster.
178 The traditional GNU regex implementation uses int for indexes.
179 The POSIX-compatible implementation uses a possibly-wider type.
180 The name 'Idx' is three letters to minimize the hassle of
181 reindenting a lot of regex code that formerly used 'int'. */
182typedef regoff_t Idx;
173#ifdef _REGEX_LARGE_OFFSETS 183#ifdef _REGEX_LARGE_OFFSETS
174# define REG_VALID_NONZERO_INDEX(n) ((Idx) ((n) - 1) < (Idx) (REG_ERROR - 1)) 184# define IDX_MAX SSIZE_MAX
175#else 185#else
176# define REG_VALID_NONZERO_INDEX(n) (0 < (n)) 186# define IDX_MAX INT_MAX
177#endif 187#endif
178 188
179/* A hash value, suitable for computing hash tables. */ 189/* A hash value, suitable for computing hash tables. */
@@ -184,36 +194,8 @@ typedef __re_size_t re_hashval_t;
184typedef unsigned long int bitset_word_t; 194typedef unsigned long int bitset_word_t;
185/* All bits set in a bitset_word_t. */ 195/* All bits set in a bitset_word_t. */
186#define BITSET_WORD_MAX ULONG_MAX 196#define BITSET_WORD_MAX ULONG_MAX
187 197/* Number of bits in a bitset_word_t. */
188/* Number of bits in a bitset_word_t. For portability to hosts with 198#define BITSET_WORD_BITS ULONG_WIDTH
189 padding bits, do not use '(sizeof (bitset_word_t) * CHAR_BIT)';
190 instead, deduce it directly from BITSET_WORD_MAX. Avoid
191 greater-than-32-bit integers and unconditional shifts by more than
192 31 bits, as they're not portable. */
193#if BITSET_WORD_MAX == 0xffffffffUL
194# define BITSET_WORD_BITS 32
195#elif BITSET_WORD_MAX >> 31 >> 4 == 1
196# define BITSET_WORD_BITS 36
197#elif BITSET_WORD_MAX >> 31 >> 16 == 1
198# define BITSET_WORD_BITS 48
199#elif BITSET_WORD_MAX >> 31 >> 28 == 1
200# define BITSET_WORD_BITS 60
201#elif BITSET_WORD_MAX >> 31 >> 31 >> 1 == 1
202# define BITSET_WORD_BITS 64
203#elif BITSET_WORD_MAX >> 31 >> 31 >> 9 == 1
204# define BITSET_WORD_BITS 72
205#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 3 == 1
206# define BITSET_WORD_BITS 128
207#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 == 1
208# define BITSET_WORD_BITS 256
209#elif BITSET_WORD_MAX >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 31 >> 7 > 1
210# define BITSET_WORD_BITS 257 /* any value > SBC_MAX will do here */
211# if BITSET_WORD_BITS <= SBC_MAX
212# error "Invalid SBC_MAX"
213# endif
214#else
215# error "Add case for new bitset_word_t size"
216#endif
217 199
218/* Number of bitset_word_t values in a bitset_t. */ 200/* Number of bitset_word_t values in a bitset_t. */
219#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS) 201#define BITSET_WORDS ((SBC_MAX + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
@@ -264,10 +246,8 @@ typedef enum
264 SIMPLE_BRACKET = 3, 246 SIMPLE_BRACKET = 3,
265 OP_BACK_REF = 4, 247 OP_BACK_REF = 4,
266 OP_PERIOD = 5, 248 OP_PERIOD = 5,
267#ifdef RE_ENABLE_I18N
268 COMPLEX_BRACKET = 6, 249 COMPLEX_BRACKET = 6,
269 OP_UTF8_PERIOD = 7, 250 OP_UTF8_PERIOD = 7,
270#endif /* RE_ENABLE_I18N */
271 251
272 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used 252 /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used
273 when the debugger shows values of this enum type. */ 253 when the debugger shows values of this enum type. */
@@ -305,30 +285,29 @@ typedef enum
305 285
306} re_token_type_t; 286} re_token_type_t;
307 287
308#ifdef RE_ENABLE_I18N
309typedef struct 288typedef struct
310{ 289{
311 /* Multibyte characters. */ 290 /* Multibyte characters. */
312 wchar_t *mbchars; 291 wchar_t *mbchars;
313 292
293#ifdef _LIBC
314 /* Collating symbols. */ 294 /* Collating symbols. */
315# ifdef _LIBC
316 int32_t *coll_syms; 295 int32_t *coll_syms;
317# endif 296#endif
318 297
298#ifdef _LIBC
319 /* Equivalence classes. */ 299 /* Equivalence classes. */
320# ifdef _LIBC
321 int32_t *equiv_classes; 300 int32_t *equiv_classes;
322# endif 301#endif
323 302
324 /* Range expressions. */ 303 /* Range expressions. */
325# ifdef _LIBC 304#ifdef _LIBC
326 uint32_t *range_starts; 305 uint32_t *range_starts;
327 uint32_t *range_ends; 306 uint32_t *range_ends;
328# else /* not _LIBC */ 307#else
329 wchar_t *range_starts; 308 wchar_t *range_starts;
330 wchar_t *range_ends; 309 wchar_t *range_ends;
331# endif /* not _LIBC */ 310#endif
332 311
333 /* Character classes. */ 312 /* Character classes. */
334 wctype_t *char_classes; 313 wctype_t *char_classes;
@@ -351,7 +330,6 @@ typedef struct
351 /* # of character classes. */ 330 /* # of character classes. */
352 Idx nchar_classes; 331 Idx nchar_classes;
353} re_charset_t; 332} re_charset_t;
354#endif /* RE_ENABLE_I18N */
355 333
356typedef struct 334typedef struct
357{ 335{
@@ -359,13 +337,11 @@ typedef struct
359 { 337 {
360 unsigned char c; /* for CHARACTER */ 338 unsigned char c; /* for CHARACTER */
361 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ 339 re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */
362#ifdef RE_ENABLE_I18N
363 re_charset_t *mbcset; /* for COMPLEX_BRACKET */ 340 re_charset_t *mbcset; /* for COMPLEX_BRACKET */
364#endif /* RE_ENABLE_I18N */
365 Idx idx; /* for BACK_REF */ 341 Idx idx; /* for BACK_REF */
366 re_context_type ctx_type; /* for ANCHOR */ 342 re_context_type ctx_type; /* for ANCHOR */
367 } opr; 343 } opr;
368#if __GNUC__ >= 2 && !defined __STRICT_ANSI__ 344#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__
369 re_token_type_t type : 8; 345 re_token_type_t type : 8;
370#else 346#else
371 re_token_type_t type; 347 re_token_type_t type;
@@ -373,12 +349,10 @@ typedef struct
373 unsigned int constraint : 10; /* context constraint */ 349 unsigned int constraint : 10; /* context constraint */
374 unsigned int duplicated : 1; 350 unsigned int duplicated : 1;
375 unsigned int opt_subexp : 1; 351 unsigned int opt_subexp : 1;
376#ifdef RE_ENABLE_I18N
377 unsigned int accept_mb : 1; 352 unsigned int accept_mb : 1;
378 /* These 2 bits can be moved into the union if needed (e.g. if running out 353 /* These 2 bits can be moved into the union if needed (e.g. if running out
379 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ 354 of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */
380 unsigned int mb_partial : 1; 355 unsigned int mb_partial : 1;
381#endif
382 unsigned int word_char : 1; 356 unsigned int word_char : 1;
383} re_token_t; 357} re_token_t;
384 358
@@ -393,12 +367,10 @@ struct re_string_t
393 REG_ICASE, upper cases of the string are stored, otherwise MBS points 367 REG_ICASE, upper cases of the string are stored, otherwise MBS points
394 the same address that RAW_MBS points. */ 368 the same address that RAW_MBS points. */
395 unsigned char *mbs; 369 unsigned char *mbs;
396#ifdef RE_ENABLE_I18N
397 /* Store the wide character string which is corresponding to MBS. */ 370 /* Store the wide character string which is corresponding to MBS. */
398 wint_t *wcs; 371 wint_t *wcs;
399 Idx *offsets; 372 Idx *offsets;
400 mbstate_t cur_state; 373 mbstate_t cur_state;
401#endif
402 /* Index in RAW_MBS. Each character mbs[i] corresponds to 374 /* Index in RAW_MBS. Each character mbs[i] corresponds to
403 raw_mbs[raw_mbs_idx + i]. */ 375 raw_mbs[raw_mbs_idx + i]. */
404 Idx raw_mbs_idx; 376 Idx raw_mbs_idx;
@@ -446,24 +418,9 @@ struct re_dfa_t;
446typedef struct re_dfa_t re_dfa_t; 418typedef struct re_dfa_t re_dfa_t;
447 419
448#ifndef _LIBC 420#ifndef _LIBC
449# define internal_function 421# define IS_IN(libc) false
450#endif 422#endif
451 423
452#ifndef NOT_IN_libc
453static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
454 Idx new_buf_len)
455 internal_function;
456# ifdef RE_ENABLE_I18N
457static void build_wcs_buffer (re_string_t *pstr) internal_function;
458static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
459 internal_function;
460# endif /* RE_ENABLE_I18N */
461static void build_upper_buffer (re_string_t *pstr) internal_function;
462static void re_string_translate_buffer (re_string_t *pstr) internal_function;
463static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
464 int eflags)
465 internal_function __attribute__ ((pure));
466#endif
467#define re_string_peek_byte(pstr, offset) \ 424#define re_string_peek_byte(pstr, offset) \
468 ((pstr)->mbs[(pstr)->cur_idx + offset]) 425 ((pstr)->mbs[(pstr)->cur_idx + offset])
469#define re_string_fetch_byte(pstr) \ 426#define re_string_fetch_byte(pstr) \
@@ -481,25 +438,6 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
481#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) 438#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
482#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) 439#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
483 440
484#if defined _LIBC || HAVE_ALLOCA
485# include <alloca.h>
486#endif
487
488#ifndef _LIBC
489# if HAVE_ALLOCA
490/* The OS usually guarantees only one guard page at the bottom of the stack,
491 and a page size can be as small as 4096 bytes. So we cannot safely
492 allocate anything larger than 4096 bytes. Also care for the possibility
493 of a few compiler-allocated temporary stack slots. */
494# define __libc_use_alloca(n) ((n) < 4032)
495# else
496/* alloca is implemented with malloc, so just use malloc. */
497# define __libc_use_alloca(n) 0
498# undef alloca
499# define alloca(n) malloc (n)
500# endif
501#endif
502
503#ifdef _LIBC 441#ifdef _LIBC
504# define MALLOC_0_IS_NONNULL 1 442# define MALLOC_0_IS_NONNULL 1
505#elif !defined MALLOC_0_IS_NONNULL 443#elif !defined MALLOC_0_IS_NONNULL
@@ -556,7 +494,7 @@ typedef struct bin_tree_storage_t bin_tree_storage_t;
556 494
557#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') 495#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_')
558#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) 496#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR)
559#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') 497#define IS_WIDE_WORD_CHAR(ch) (__iswalnum (ch) || (ch) == L'_')
560#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) 498#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR)
561 499
562#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ 500#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \
@@ -636,20 +574,15 @@ struct re_backref_cache_entry
636 Idx str_idx; 574 Idx str_idx;
637 Idx subexp_from; 575 Idx subexp_from;
638 Idx subexp_to; 576 Idx subexp_to;
577 bitset_word_t eps_reachable_subexps_map;
639 char more; 578 char more;
640 char unused;
641 unsigned short int eps_reachable_subexps_map;
642}; 579};
643 580
644typedef struct 581typedef struct
645{ 582{
646 /* The string object corresponding to the input string. */ 583 /* The string object corresponding to the input string. */
647 re_string_t input; 584 re_string_t input;
648#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
649 const re_dfa_t *const dfa; 585 const re_dfa_t *const dfa;
650#else
651 const re_dfa_t *dfa;
652#endif
653 /* EFLAGS of the argument of regexec. */ 586 /* EFLAGS of the argument of regexec. */
654 int eflags; 587 int eflags;
655 /* Where the matching ends. */ 588 /* Where the matching ends. */
@@ -769,31 +702,31 @@ typedef struct
769 702
770/* Functions for bitset_t operation. */ 703/* Functions for bitset_t operation. */
771 704
772static void 705static inline void
773bitset_set (bitset_t set, Idx i) 706bitset_set (bitset_t set, Idx i)
774{ 707{
775 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; 708 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
776} 709}
777 710
778static void 711static inline void
779bitset_clear (bitset_t set, Idx i) 712bitset_clear (bitset_t set, Idx i)
780{ 713{
781 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); 714 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
782} 715}
783 716
784static bool 717static inline bool
785bitset_contain (const bitset_t set, Idx i) 718bitset_contain (const bitset_t set, Idx i)
786{ 719{
787 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; 720 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
788} 721}
789 722
790static void 723static inline void
791bitset_empty (bitset_t set) 724bitset_empty (bitset_t set)
792{ 725{
793 memset (set, '\0', sizeof (bitset_t)); 726 memset (set, '\0', sizeof (bitset_t));
794} 727}
795 728
796static void 729static inline void
797bitset_set_all (bitset_t set) 730bitset_set_all (bitset_t set)
798{ 731{
799 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); 732 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
@@ -802,13 +735,13 @@ bitset_set_all (bitset_t set)
802 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; 735 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
803} 736}
804 737
805static void 738static inline void
806bitset_copy (bitset_t dest, const bitset_t src) 739bitset_copy (bitset_t dest, const bitset_t src)
807{ 740{
808 memcpy (dest, src, sizeof (bitset_t)); 741 memcpy (dest, src, sizeof (bitset_t));
809} 742}
810 743
811static void __attribute__ ((unused)) 744static inline void
812bitset_not (bitset_t set) 745bitset_not (bitset_t set)
813{ 746{
814 int bitset_i; 747 int bitset_i;
@@ -820,7 +753,7 @@ bitset_not (bitset_t set)
820 & ~set[BITSET_WORDS - 1]); 753 & ~set[BITSET_WORDS - 1]);
821} 754}
822 755
823static void __attribute__ ((unused)) 756static inline void
824bitset_merge (bitset_t dest, const bitset_t src) 757bitset_merge (bitset_t dest, const bitset_t src)
825{ 758{
826 int bitset_i; 759 int bitset_i;
@@ -828,7 +761,7 @@ bitset_merge (bitset_t dest, const bitset_t src)
828 dest[bitset_i] |= src[bitset_i]; 761 dest[bitset_i] |= src[bitset_i];
829} 762}
830 763
831static void __attribute__ ((unused)) 764static inline void
832bitset_mask (bitset_t dest, const bitset_t src) 765bitset_mask (bitset_t dest, const bitset_t src)
833{ 766{
834 int bitset_i; 767 int bitset_i;
@@ -836,10 +769,9 @@ bitset_mask (bitset_t dest, const bitset_t src)
836 dest[bitset_i] &= src[bitset_i]; 769 dest[bitset_i] &= src[bitset_i];
837} 770}
838 771
839#ifdef RE_ENABLE_I18N
840/* Functions for re_string. */ 772/* Functions for re_string. */
841static int 773static int
842internal_function __attribute__ ((pure, unused)) 774__attribute__ ((pure, unused))
843re_string_char_size_at (const re_string_t *pstr, Idx idx) 775re_string_char_size_at (const re_string_t *pstr, Idx idx)
844{ 776{
845 int byte_idx; 777 int byte_idx;
@@ -852,7 +784,7 @@ re_string_char_size_at (const re_string_t *pstr, Idx idx)
852} 784}
853 785
854static wint_t 786static wint_t
855internal_function __attribute__ ((pure, unused)) 787__attribute__ ((pure, unused))
856re_string_wchar_at (const re_string_t *pstr, Idx idx) 788re_string_wchar_at (const re_string_t *pstr, Idx idx)
857{ 789{
858 if (pstr->mb_cur_max == 1) 790 if (pstr->mb_cur_max == 1)
@@ -860,15 +792,17 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
860 return (wint_t) pstr->wcs[idx]; 792 return (wint_t) pstr->wcs[idx];
861} 793}
862 794
863# ifndef NOT_IN_libc 795#ifdef _LIBC
796# include <locale/weight.h>
797#endif
798
864static int 799static int
865internal_function __attribute__ ((pure, unused)) 800__attribute__ ((pure, unused))
866re_string_elem_size_at (const re_string_t *pstr, Idx idx) 801re_string_elem_size_at (const re_string_t *pstr, Idx idx)
867{ 802{
868# ifdef _LIBC 803#ifdef _LIBC
869 const unsigned char *p, *extra; 804 const unsigned char *p, *extra;
870 const int32_t *table, *indirect; 805 const int32_t *table, *indirect;
871# include <locale/weight.h>
872 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 806 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
873 807
874 if (nrules != 0) 808 if (nrules != 0)
@@ -879,31 +813,22 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
879 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 813 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
880 _NL_COLLATE_INDIRECTMB); 814 _NL_COLLATE_INDIRECTMB);
881 p = pstr->mbs + idx; 815 p = pstr->mbs + idx;
882 findidx (&p, pstr->len - idx); 816 findidx (table, indirect, extra, &p, pstr->len - idx);
883 return p - pstr->mbs - idx; 817 return p - pstr->mbs - idx;
884 } 818 }
885 else 819#endif /* _LIBC */
886# endif /* _LIBC */ 820
887 return 1; 821 return 1;
888} 822}
889# endif
890#endif /* RE_ENABLE_I18N */
891 823
892#ifndef __GNUC_PREREQ 824#ifdef _LIBC
893# if defined __GNUC__ && defined __GNUC_MINOR__ 825# if __GNUC__ >= 7
894# define __GNUC_PREREQ(maj, min) \ 826# define FALLTHROUGH __attribute__ ((__fallthrough__))
895 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
896# else 827# else
897# define __GNUC_PREREQ(maj, min) 0 828# define FALLTHROUGH ((void) 0)
898# endif 829# endif
899#endif
900
901#if __GNUC_PREREQ (3,4)
902# undef __attribute_warn_unused_result__
903# define __attribute_warn_unused_result__ \
904 __attribute__ ((__warn_unused_result__))
905#else 830#else
906# define __attribute_warn_unused_result__ /* empty */ 831# include "attribute.h"
907#endif 832#endif
908 833
909#endif /* _REGEX_INTERNAL_H */ 834#endif /* _REGEX_INTERNAL_H */
diff --git a/gl/regexec.c b/gl/regexec.c
index d29d442..13e0349 100644
--- a/gl/regexec.c
+++ b/gl/regexec.c
@@ -1,206 +1,170 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 5
6 The GNU C Library is free software; you can redistribute it and/or 6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public 7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 3 of the License, or (at your option) any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 The GNU C Library is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see 17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */ 18 <https://www.gnu.org/licenses/>. */
19 19
20static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, 20static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
21 Idx n) internal_function; 21 Idx n);
22static void match_ctx_clean (re_match_context_t *mctx) internal_function; 22static void match_ctx_clean (re_match_context_t *mctx);
23static void match_ctx_free (re_match_context_t *cache) internal_function; 23static void match_ctx_free (re_match_context_t *cache);
24static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node, 24static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, Idx node,
25 Idx str_idx, Idx from, Idx to) 25 Idx str_idx, Idx from, Idx to);
26 internal_function; 26static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx);
27static Idx search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
28 internal_function;
29static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node, 27static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, Idx node,
30 Idx str_idx) internal_function; 28 Idx str_idx);
31static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, 29static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop,
32 Idx node, Idx str_idx) 30 Idx node, Idx str_idx);
33 internal_function;
34static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, 31static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
35 re_dfastate_t **limited_sts, Idx last_node, 32 re_dfastate_t **limited_sts, Idx last_node,
36 Idx last_str_idx) 33 Idx last_str_idx);
37 internal_function;
38static reg_errcode_t re_search_internal (const regex_t *preg, 34static reg_errcode_t re_search_internal (const regex_t *preg,
39 const char *string, Idx length, 35 const char *string, Idx length,
40 Idx start, Idx last_start, Idx stop, 36 Idx start, Idx last_start, Idx stop,
41 size_t nmatch, regmatch_t pmatch[], 37 size_t nmatch, regmatch_t pmatch[],
42 int eflags) internal_function; 38 int eflags);
43static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp, 39static regoff_t re_search_2_stub (struct re_pattern_buffer *bufp,
44 const char *string1, Idx length1, 40 const char *string1, Idx length1,
45 const char *string2, Idx length2, 41 const char *string2, Idx length2,
46 Idx start, regoff_t range, 42 Idx start, regoff_t range,
47 struct re_registers *regs, 43 struct re_registers *regs,
48 Idx stop, bool ret_len) internal_function; 44 Idx stop, bool ret_len);
49static regoff_t re_search_stub (struct re_pattern_buffer *bufp, 45static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
50 const char *string, Idx length, Idx start, 46 const char *string, Idx length, Idx start,
51 regoff_t range, Idx stop, 47 regoff_t range, Idx stop,
52 struct re_registers *regs, 48 struct re_registers *regs,
53 bool ret_len) internal_function; 49 bool ret_len);
54static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, 50static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
55 Idx nregs, int regs_allocated) internal_function; 51 Idx nregs, int regs_allocated);
56static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) 52static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx);
57 internal_function;
58static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match, 53static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
59 Idx *p_match_first) internal_function; 54 Idx *p_match_first);
60static Idx check_halt_state_context (const re_match_context_t *mctx, 55static Idx check_halt_state_context (const re_match_context_t *mctx,
61 const re_dfastate_t *state, Idx idx) 56 const re_dfastate_t *state, Idx idx);
62 internal_function;
63static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, 57static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
64 regmatch_t *prev_idx_match, Idx cur_node, 58 regmatch_t *prev_idx_match, Idx cur_node,
65 Idx cur_idx, Idx nmatch) internal_function; 59 Idx cur_idx, Idx nmatch);
66static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, 60static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs,
67 Idx str_idx, Idx dest_node, Idx nregs, 61 Idx str_idx, Idx dest_node, Idx nregs,
68 regmatch_t *regs, 62 regmatch_t *regs, regmatch_t *prevregs,
69 re_node_set *eps_via_nodes) 63 re_node_set *eps_via_nodes);
70 internal_function;
71static reg_errcode_t set_regs (const regex_t *preg, 64static reg_errcode_t set_regs (const regex_t *preg,
72 const re_match_context_t *mctx, 65 const re_match_context_t *mctx,
73 size_t nmatch, regmatch_t *pmatch, 66 size_t nmatch, regmatch_t *pmatch,
74 bool fl_backtrack) internal_function; 67 bool fl_backtrack);
75static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) 68static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs);
76 internal_function;
77 69
78#ifdef RE_ENABLE_I18N
79static int sift_states_iter_mb (const re_match_context_t *mctx, 70static int sift_states_iter_mb (const re_match_context_t *mctx,
80 re_sift_context_t *sctx, 71 re_sift_context_t *sctx,
81 Idx node_idx, Idx str_idx, Idx max_str_idx) 72 Idx node_idx, Idx str_idx, Idx max_str_idx);
82 internal_function;
83#endif /* RE_ENABLE_I18N */
84static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, 73static reg_errcode_t sift_states_backward (const re_match_context_t *mctx,
85 re_sift_context_t *sctx) 74 re_sift_context_t *sctx);
86 internal_function;
87static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, 75static reg_errcode_t build_sifted_states (const re_match_context_t *mctx,
88 re_sift_context_t *sctx, Idx str_idx, 76 re_sift_context_t *sctx, Idx str_idx,
89 re_node_set *cur_dest) 77 re_node_set *cur_dest);
90 internal_function;
91static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, 78static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx,
92 re_sift_context_t *sctx, 79 re_sift_context_t *sctx,
93 Idx str_idx, 80 Idx str_idx,
94 re_node_set *dest_nodes) 81 re_node_set *dest_nodes);
95 internal_function;
96static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, 82static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa,
97 re_node_set *dest_nodes, 83 re_node_set *dest_nodes,
98 const re_node_set *candidates) 84 const re_node_set *candidates);
99 internal_function;
100static bool check_dst_limits (const re_match_context_t *mctx, 85static bool check_dst_limits (const re_match_context_t *mctx,
101 const re_node_set *limits, 86 const re_node_set *limits,
102 Idx dst_node, Idx dst_idx, Idx src_node, 87 Idx dst_node, Idx dst_idx, Idx src_node,
103 Idx src_idx) internal_function; 88 Idx src_idx);
104static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, 89static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx,
105 int boundaries, Idx subexp_idx, 90 int boundaries, Idx subexp_idx,
106 Idx from_node, Idx bkref_idx) 91 Idx from_node, Idx bkref_idx);
107 internal_function;
108static int check_dst_limits_calc_pos (const re_match_context_t *mctx, 92static int check_dst_limits_calc_pos (const re_match_context_t *mctx,
109 Idx limit, Idx subexp_idx, 93 Idx limit, Idx subexp_idx,
110 Idx node, Idx str_idx, 94 Idx node, Idx str_idx,
111 Idx bkref_idx) internal_function; 95 Idx bkref_idx);
112static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, 96static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa,
113 re_node_set *dest_nodes, 97 re_node_set *dest_nodes,
114 const re_node_set *candidates, 98 const re_node_set *candidates,
115 re_node_set *limits, 99 re_node_set *limits,
116 struct re_backref_cache_entry *bkref_ents, 100 struct re_backref_cache_entry *bkref_ents,
117 Idx str_idx) internal_function; 101 Idx str_idx);
118static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, 102static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx,
119 re_sift_context_t *sctx, 103 re_sift_context_t *sctx,
120 Idx str_idx, const re_node_set *candidates) 104 Idx str_idx, const re_node_set *candidates);
121 internal_function;
122static reg_errcode_t merge_state_array (const re_dfa_t *dfa, 105static reg_errcode_t merge_state_array (const re_dfa_t *dfa,
123 re_dfastate_t **dst, 106 re_dfastate_t **dst,
124 re_dfastate_t **src, Idx num) 107 re_dfastate_t **src, Idx num);
125 internal_function;
126static re_dfastate_t *find_recover_state (reg_errcode_t *err, 108static re_dfastate_t *find_recover_state (reg_errcode_t *err,
127 re_match_context_t *mctx) internal_function; 109 re_match_context_t *mctx);
128static re_dfastate_t *transit_state (reg_errcode_t *err, 110static re_dfastate_t *transit_state (reg_errcode_t *err,
129 re_match_context_t *mctx, 111 re_match_context_t *mctx,
130 re_dfastate_t *state) internal_function; 112 re_dfastate_t *state);
131static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, 113static re_dfastate_t *merge_state_with_log (reg_errcode_t *err,
132 re_match_context_t *mctx, 114 re_match_context_t *mctx,
133 re_dfastate_t *next_state) 115 re_dfastate_t *next_state);
134 internal_function;
135static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, 116static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx,
136 re_node_set *cur_nodes, 117 re_node_set *cur_nodes,
137 Idx str_idx) internal_function; 118 Idx str_idx);
138#if 0 119#if 0
139static re_dfastate_t *transit_state_sb (reg_errcode_t *err, 120static re_dfastate_t *transit_state_sb (reg_errcode_t *err,
140 re_match_context_t *mctx, 121 re_match_context_t *mctx,
141 re_dfastate_t *pstate) 122 re_dfastate_t *pstate);
142 internal_function;
143#endif 123#endif
144#ifdef RE_ENABLE_I18N
145static reg_errcode_t transit_state_mb (re_match_context_t *mctx, 124static reg_errcode_t transit_state_mb (re_match_context_t *mctx,
146 re_dfastate_t *pstate) 125 re_dfastate_t *pstate);
147 internal_function;
148#endif /* RE_ENABLE_I18N */
149static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, 126static reg_errcode_t transit_state_bkref (re_match_context_t *mctx,
150 const re_node_set *nodes) 127 const re_node_set *nodes);
151 internal_function;
152static reg_errcode_t get_subexp (re_match_context_t *mctx, 128static reg_errcode_t get_subexp (re_match_context_t *mctx,
153 Idx bkref_node, Idx bkref_str_idx) 129 Idx bkref_node, Idx bkref_str_idx);
154 internal_function;
155static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, 130static reg_errcode_t get_subexp_sub (re_match_context_t *mctx,
156 const re_sub_match_top_t *sub_top, 131 const re_sub_match_top_t *sub_top,
157 re_sub_match_last_t *sub_last, 132 re_sub_match_last_t *sub_last,
158 Idx bkref_node, Idx bkref_str) 133 Idx bkref_node, Idx bkref_str);
159 internal_function;
160static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, 134static Idx find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
161 Idx subexp_idx, int type) internal_function; 135 Idx subexp_idx, int type);
162static reg_errcode_t check_arrival (re_match_context_t *mctx, 136static reg_errcode_t check_arrival (re_match_context_t *mctx,
163 state_array_t *path, Idx top_node, 137 state_array_t *path, Idx top_node,
164 Idx top_str, Idx last_node, Idx last_str, 138 Idx top_str, Idx last_node, Idx last_str,
165 int type) internal_function; 139 int type);
166static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, 140static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx,
167 Idx str_idx, 141 Idx str_idx,
168 re_node_set *cur_nodes, 142 re_node_set *cur_nodes,
169 re_node_set *next_nodes) 143 re_node_set *next_nodes);
170 internal_function;
171static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, 144static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa,
172 re_node_set *cur_nodes, 145 re_node_set *cur_nodes,
173 Idx ex_subexp, int type) 146 Idx ex_subexp, int type);
174 internal_function;
175static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, 147static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa,
176 re_node_set *dst_nodes, 148 re_node_set *dst_nodes,
177 Idx target, Idx ex_subexp, 149 Idx target, Idx ex_subexp,
178 int type) internal_function; 150 int type);
179static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, 151static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx,
180 re_node_set *cur_nodes, Idx cur_str, 152 re_node_set *cur_nodes, Idx cur_str,
181 Idx subexp_num, int type) 153 Idx subexp_num, int type);
182 internal_function; 154static bool build_trtable (const re_dfa_t *dfa, re_dfastate_t *state);
183static bool build_trtable (const re_dfa_t *dfa,
184 re_dfastate_t *state) internal_function;
185#ifdef RE_ENABLE_I18N
186static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, 155static int check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
187 const re_string_t *input, Idx idx) 156 const re_string_t *input, Idx idx);
188 internal_function; 157#ifdef _LIBC
189# ifdef _LIBC
190static unsigned int find_collation_sequence_value (const unsigned char *mbs, 158static unsigned int find_collation_sequence_value (const unsigned char *mbs,
191 size_t name_len) 159 size_t name_len);
192 internal_function; 160#endif
193# endif /* _LIBC */
194#endif /* RE_ENABLE_I18N */
195static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa, 161static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
196 const re_dfastate_t *state, 162 const re_dfastate_t *state,
197 re_node_set *states_node, 163 re_node_set *states_node,
198 bitset_t *states_ch) internal_function; 164 bitset_t *states_ch);
199static bool check_node_accept (const re_match_context_t *mctx, 165static bool check_node_accept (const re_match_context_t *mctx,
200 const re_token_t *node, Idx idx) 166 const re_token_t *node, Idx idx);
201 internal_function; 167static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len);
202static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
203 internal_function;
204 168
205/* Entry point for POSIX code. */ 169/* Entry point for POSIX code. */
206 170
@@ -216,15 +180,12 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
216 REG_NOTBOL is set, then ^ does not match at the beginning of the 180 REG_NOTBOL is set, then ^ does not match at the beginning of the
217 string; if REG_NOTEOL is set, then $ does not match at the end. 181 string; if REG_NOTEOL is set, then $ does not match at the end.
218 182
219 We return 0 if we find a match and REG_NOMATCH if not. */ 183 Return 0 if a match is found, REG_NOMATCH if not, REG_BADPAT if
184 EFLAGS is invalid. */
220 185
221int 186int
222regexec (preg, string, nmatch, pmatch, eflags) 187regexec (const regex_t *__restrict preg, const char *__restrict string,
223 const regex_t *_Restrict_ preg; 188 size_t nmatch, regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
224 const char *_Restrict_ string;
225 size_t nmatch;
226 regmatch_t pmatch[_Restrict_arr_];
227 int eflags;
228{ 189{
229 reg_errcode_t err; 190 reg_errcode_t err;
230 Idx start, length; 191 Idx start, length;
@@ -256,6 +217,8 @@ regexec (preg, string, nmatch, pmatch, eflags)
256} 217}
257 218
258#ifdef _LIBC 219#ifdef _LIBC
220libc_hidden_def (__regexec)
221
259# include <shlib-compat.h> 222# include <shlib-compat.h>
260versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); 223versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4);
261 224
@@ -264,9 +227,9 @@ __typeof__ (__regexec) __compat_regexec;
264 227
265int 228int
266attribute_compat_text_section 229attribute_compat_text_section
267__compat_regexec (const regex_t *_Restrict_ preg, 230__compat_regexec (const regex_t *__restrict preg,
268 const char *_Restrict_ string, size_t nmatch, 231 const char *__restrict string, size_t nmatch,
269 regmatch_t pmatch[], int eflags) 232 regmatch_t pmatch[_REGEX_NELTS (nmatch)], int eflags)
270{ 233{
271 return regexec (preg, string, nmatch, pmatch, 234 return regexec (preg, string, nmatch, pmatch,
272 eflags & (REG_NOTBOL | REG_NOTEOL)); 235 eflags & (REG_NOTBOL | REG_NOTEOL));
@@ -301,15 +264,12 @@ compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
301 strings.) 264 strings.)
302 265
303 On success, re_match* functions return the length of the match, re_search* 266 On success, re_match* functions return the length of the match, re_search*
304 return the position of the start of the match. Return value -1 means no 267 return the position of the start of the match. They return -1 on
305 match was found and -2 indicates an internal error. */ 268 match failure, -2 on error. */
306 269
307regoff_t 270regoff_t
308re_match (bufp, string, length, start, regs) 271re_match (struct re_pattern_buffer *bufp, const char *string, Idx length,
309 struct re_pattern_buffer *bufp; 272 Idx start, struct re_registers *regs)
310 const char *string;
311 Idx length, start;
312 struct re_registers *regs;
313{ 273{
314 return re_search_stub (bufp, string, length, start, 0, length, regs, true); 274 return re_search_stub (bufp, string, length, start, 0, length, regs, true);
315} 275}
@@ -318,12 +278,8 @@ weak_alias (__re_match, re_match)
318#endif 278#endif
319 279
320regoff_t 280regoff_t
321re_search (bufp, string, length, start, range, regs) 281re_search (struct re_pattern_buffer *bufp, const char *string, Idx length,
322 struct re_pattern_buffer *bufp; 282 Idx start, regoff_t range, struct re_registers *regs)
323 const char *string;
324 Idx length, start;
325 regoff_t range;
326 struct re_registers *regs;
327{ 283{
328 return re_search_stub (bufp, string, length, start, range, length, regs, 284 return re_search_stub (bufp, string, length, start, range, length, regs,
329 false); 285 false);
@@ -333,11 +289,9 @@ weak_alias (__re_search, re_search)
333#endif 289#endif
334 290
335regoff_t 291regoff_t
336re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop) 292re_match_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
337 struct re_pattern_buffer *bufp; 293 const char *string2, Idx length2, Idx start,
338 const char *string1, *string2; 294 struct re_registers *regs, Idx stop)
339 Idx length1, length2, start, stop;
340 struct re_registers *regs;
341{ 295{
342 return re_search_2_stub (bufp, string1, length1, string2, length2, 296 return re_search_2_stub (bufp, string1, length1, string2, length2,
343 start, 0, regs, stop, true); 297 start, 0, regs, stop, true);
@@ -347,12 +301,9 @@ weak_alias (__re_match_2, re_match_2)
347#endif 301#endif
348 302
349regoff_t 303regoff_t
350re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop) 304re_search_2 (struct re_pattern_buffer *bufp, const char *string1, Idx length1,
351 struct re_pattern_buffer *bufp; 305 const char *string2, Idx length2, Idx start, regoff_t range,
352 const char *string1, *string2; 306 struct re_registers *regs, Idx stop)
353 Idx length1, length2, start, stop;
354 regoff_t range;
355 struct re_registers *regs;
356{ 307{
357 return re_search_2_stub (bufp, string1, length1, string2, length2, 308 return re_search_2_stub (bufp, string1, length1, string2, length2,
358 start, range, regs, stop, false); 309 start, range, regs, stop, false);
@@ -362,18 +313,18 @@ weak_alias (__re_search_2, re_search_2)
362#endif 313#endif
363 314
364static regoff_t 315static regoff_t
365re_search_2_stub (struct re_pattern_buffer *bufp, 316re_search_2_stub (struct re_pattern_buffer *bufp, const char *string1,
366 const char *string1, Idx length1, 317 Idx length1, const char *string2, Idx length2, Idx start,
367 const char *string2, Idx length2, 318 regoff_t range, struct re_registers *regs,
368 Idx start, regoff_t range, struct re_registers *regs,
369 Idx stop, bool ret_len) 319 Idx stop, bool ret_len)
370{ 320{
371 const char *str; 321 const char *str;
372 regoff_t rval; 322 regoff_t rval;
373 Idx len = length1 + length2; 323 Idx len;
374 char *s = NULL; 324 char *s = NULL;
375 325
376 if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) 326 if (__glibc_unlikely ((length1 < 0 || length2 < 0 || stop < 0
327 || INT_ADD_WRAPV (length1, length2, &len))))
377 return -2; 328 return -2;
378 329
379 /* Concatenate the strings. */ 330 /* Concatenate the strings. */
@@ -382,7 +333,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
382 { 333 {
383 s = re_malloc (char, len); 334 s = re_malloc (char, len);
384 335
385 if (BE (s == NULL, 0)) 336 if (__glibc_unlikely (s == NULL))
386 return -2; 337 return -2;
387#ifdef _LIBC 338#ifdef _LIBC
388 memcpy (__mempcpy (s, string1, length1), string2, length2); 339 memcpy (__mempcpy (s, string1, length1), string2, length2);
@@ -409,8 +360,7 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
409 otherwise the position of the match is returned. */ 360 otherwise the position of the match is returned. */
410 361
411static regoff_t 362static regoff_t
412re_search_stub (struct re_pattern_buffer *bufp, 363re_search_stub (struct re_pattern_buffer *bufp, const char *string, Idx length,
413 const char *string, Idx length,
414 Idx start, regoff_t range, Idx stop, struct re_registers *regs, 364 Idx start, regoff_t range, Idx stop, struct re_registers *regs,
415 bool ret_len) 365 bool ret_len)
416{ 366{
@@ -423,11 +373,13 @@ re_search_stub (struct re_pattern_buffer *bufp,
423 Idx last_start = start + range; 373 Idx last_start = start + range;
424 374
425 /* Check for out-of-range. */ 375 /* Check for out-of-range. */
426 if (BE (start < 0 || start > length, 0)) 376 if (__glibc_unlikely (start < 0 || start > length))
427 return -1; 377 return -1;
428 if (BE (length < last_start || (0 <= range && last_start < start), 0)) 378 if (__glibc_unlikely (length < last_start
379 || (0 <= range && last_start < start)))
429 last_start = length; 380 last_start = length;
430 else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) 381 else if (__glibc_unlikely (last_start < 0
382 || (range < 0 && start <= last_start)))
431 last_start = 0; 383 last_start = 0;
432 384
433 lock_lock (dfa->lock); 385 lock_lock (dfa->lock);
@@ -439,17 +391,17 @@ re_search_stub (struct re_pattern_buffer *bufp,
439 if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate) 391 if (start < last_start && bufp->fastmap != NULL && !bufp->fastmap_accurate)
440 re_compile_fastmap (bufp); 392 re_compile_fastmap (bufp);
441 393
442 if (BE (bufp->no_sub, 0)) 394 if (__glibc_unlikely (bufp->no_sub))
443 regs = NULL; 395 regs = NULL;
444 396
445 /* We need at least 1 register. */ 397 /* We need at least 1 register. */
446 if (regs == NULL) 398 if (regs == NULL)
447 nregs = 1; 399 nregs = 1;
448 else if (BE (bufp->regs_allocated == REGS_FIXED 400 else if (__glibc_unlikely (bufp->regs_allocated == REGS_FIXED
449 && regs->num_regs <= bufp->re_nsub, 0)) 401 && regs->num_regs <= bufp->re_nsub))
450 { 402 {
451 nregs = regs->num_regs; 403 nregs = regs->num_regs;
452 if (BE (nregs < 1, 0)) 404 if (__glibc_unlikely (nregs < 1))
453 { 405 {
454 /* Nothing can be copied to regs. */ 406 /* Nothing can be copied to regs. */
455 regs = NULL; 407 regs = NULL;
@@ -459,7 +411,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
459 else 411 else
460 nregs = bufp->re_nsub + 1; 412 nregs = bufp->re_nsub + 1;
461 pmatch = re_malloc (regmatch_t, nregs); 413 pmatch = re_malloc (regmatch_t, nregs);
462 if (BE (pmatch == NULL, 0)) 414 if (__glibc_unlikely (pmatch == NULL))
463 { 415 {
464 rval = -2; 416 rval = -2;
465 goto out; 417 goto out;
@@ -478,15 +430,15 @@ re_search_stub (struct re_pattern_buffer *bufp,
478 /* If caller wants register contents data back, copy them. */ 430 /* If caller wants register contents data back, copy them. */
479 bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, 431 bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs,
480 bufp->regs_allocated); 432 bufp->regs_allocated);
481 if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) 433 if (__glibc_unlikely (bufp->regs_allocated == REGS_UNALLOCATED))
482 rval = -2; 434 rval = -2;
483 } 435 }
484 436
485 if (BE (rval == 0, 1)) 437 if (__glibc_likely (rval == 0))
486 { 438 {
487 if (ret_len) 439 if (ret_len)
488 { 440 {
489 assert (pmatch[0].rm_so == start); 441 DEBUG_ASSERT (pmatch[0].rm_so == start);
490 rval = pmatch[0].rm_eo - start; 442 rval = pmatch[0].rm_eo - start;
491 } 443 }
492 else 444 else
@@ -512,10 +464,10 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
512 if (regs_allocated == REGS_UNALLOCATED) 464 if (regs_allocated == REGS_UNALLOCATED)
513 { /* No. So allocate them with malloc. */ 465 { /* No. So allocate them with malloc. */
514 regs->start = re_malloc (regoff_t, need_regs); 466 regs->start = re_malloc (regoff_t, need_regs);
515 if (BE (regs->start == NULL, 0)) 467 if (__glibc_unlikely (regs->start == NULL))
516 return REGS_UNALLOCATED; 468 return REGS_UNALLOCATED;
517 regs->end = re_malloc (regoff_t, need_regs); 469 regs->end = re_malloc (regoff_t, need_regs);
518 if (BE (regs->end == NULL, 0)) 470 if (__glibc_unlikely (regs->end == NULL))
519 { 471 {
520 re_free (regs->start); 472 re_free (regs->start);
521 return REGS_UNALLOCATED; 473 return REGS_UNALLOCATED;
@@ -526,14 +478,14 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
526 { /* Yes. If we need more elements than were already 478 { /* Yes. If we need more elements than were already
527 allocated, reallocate them. If we need fewer, just 479 allocated, reallocate them. If we need fewer, just
528 leave it alone. */ 480 leave it alone. */
529 if (BE (need_regs > regs->num_regs, 0)) 481 if (__glibc_unlikely (need_regs > regs->num_regs))
530 { 482 {
531 regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); 483 regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs);
532 regoff_t *new_end; 484 regoff_t *new_end;
533 if (BE (new_start == NULL, 0)) 485 if (__glibc_unlikely (new_start == NULL))
534 return REGS_UNALLOCATED; 486 return REGS_UNALLOCATED;
535 new_end = re_realloc (regs->end, regoff_t, need_regs); 487 new_end = re_realloc (regs->end, regoff_t, need_regs);
536 if (BE (new_end == NULL, 0)) 488 if (__glibc_unlikely (new_end == NULL))
537 { 489 {
538 re_free (new_start); 490 re_free (new_start);
539 return REGS_UNALLOCATED; 491 return REGS_UNALLOCATED;
@@ -545,9 +497,9 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
545 } 497 }
546 else 498 else
547 { 499 {
548 assert (regs_allocated == REGS_FIXED); 500 DEBUG_ASSERT (regs_allocated == REGS_FIXED);
549 /* This function may not be called with REGS_FIXED and nregs too big. */ 501 /* This function may not be called with REGS_FIXED and nregs too big. */
550 assert (regs->num_regs >= nregs); 502 DEBUG_ASSERT (nregs <= regs->num_regs);
551 rval = REGS_FIXED; 503 rval = REGS_FIXED;
552 } 504 }
553 505
@@ -577,11 +529,8 @@ re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
577 freeing the old data. */ 529 freeing the old data. */
578 530
579void 531void
580re_set_registers (bufp, regs, num_regs, starts, ends) 532re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
581 struct re_pattern_buffer *bufp; 533 __re_size_t num_regs, regoff_t *starts, regoff_t *ends)
582 struct re_registers *regs;
583 __re_size_t num_regs;
584 regoff_t *starts, *ends;
585{ 534{
586 if (num_regs) 535 if (num_regs)
587 { 536 {
@@ -609,8 +558,7 @@ int
609# ifdef _LIBC 558# ifdef _LIBC
610weak_function 559weak_function
611# endif 560# endif
612re_exec (s) 561re_exec (const char *s)
613 const char *s;
614{ 562{
615 return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); 563 return 0 == regexec (&re_comp_buf, s, 0, NULL, 0);
616} 564}
@@ -629,11 +577,9 @@ re_exec (s)
629 577
630static reg_errcode_t 578static reg_errcode_t
631__attribute_warn_unused_result__ 579__attribute_warn_unused_result__
632re_search_internal (const regex_t *preg, 580re_search_internal (const regex_t *preg, const char *string, Idx length,
633 const char *string, Idx length, 581 Idx start, Idx last_start, Idx stop, size_t nmatch,
634 Idx start, Idx last_start, Idx stop, 582 regmatch_t pmatch[], int eflags)
635 size_t nmatch, regmatch_t pmatch[],
636 int eflags)
637{ 583{
638 reg_errcode_t err; 584 reg_errcode_t err;
639 const re_dfa_t *dfa = preg->buffer; 585 const re_dfa_t *dfa = preg->buffer;
@@ -642,38 +588,28 @@ re_search_internal (const regex_t *preg,
642 bool fl_longest_match; 588 bool fl_longest_match;
643 int match_kind; 589 int match_kind;
644 Idx match_first; 590 Idx match_first;
645 Idx match_last = REG_MISSING; 591 Idx match_last = -1;
646 Idx extra_nmatch; 592 Idx extra_nmatch;
647 bool sb; 593 bool sb;
648 int ch; 594 int ch;
649#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
650 re_match_context_t mctx = { .dfa = dfa }; 595 re_match_context_t mctx = { .dfa = dfa };
651#else
652 re_match_context_t mctx;
653#endif
654 char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate 596 char *fastmap = ((preg->fastmap != NULL && preg->fastmap_accurate
655 && start != last_start && !preg->can_be_null) 597 && start != last_start && !preg->can_be_null)
656 ? preg->fastmap : NULL); 598 ? preg->fastmap : NULL);
657 RE_TRANSLATE_TYPE t = preg->translate; 599 RE_TRANSLATE_TYPE t = preg->translate;
658 600
659#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
660 memset (&mctx, '\0', sizeof (re_match_context_t));
661 mctx.dfa = dfa;
662#endif
663
664 extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; 601 extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0;
665 nmatch -= extra_nmatch; 602 nmatch -= extra_nmatch;
666 603
667 /* Check if the DFA haven't been compiled. */ 604 /* Check if the DFA haven't been compiled. */
668 if (BE (preg->used == 0 || dfa->init_state == NULL 605 if (__glibc_unlikely (preg->used == 0 || dfa->init_state == NULL
669 || dfa->init_state_word == NULL || dfa->init_state_nl == NULL 606 || dfa->init_state_word == NULL
670 || dfa->init_state_begbuf == NULL, 0)) 607 || dfa->init_state_nl == NULL
608 || dfa->init_state_begbuf == NULL))
671 return REG_NOMATCH; 609 return REG_NOMATCH;
672 610
673#ifdef DEBUG
674 /* We assume front-end functions already check them. */ 611 /* We assume front-end functions already check them. */
675 assert (0 <= last_start && last_start <= length); 612 DEBUG_ASSERT (0 <= last_start && last_start <= length);
676#endif
677 613
678 /* If initial states with non-begbuf contexts have no elements, 614 /* If initial states with non-begbuf contexts have no elements,
679 the regex must be anchored. If preg->newline_anchor is set, 615 the regex must be anchored. If preg->newline_anchor is set,
@@ -694,14 +630,14 @@ re_search_internal (const regex_t *preg,
694 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, 630 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
695 preg->translate, (preg->syntax & RE_ICASE) != 0, 631 preg->translate, (preg->syntax & RE_ICASE) != 0,
696 dfa); 632 dfa);
697 if (BE (err != REG_NOERROR, 0)) 633 if (__glibc_unlikely (err != REG_NOERROR))
698 goto free_return; 634 goto free_return;
699 mctx.input.stop = stop; 635 mctx.input.stop = stop;
700 mctx.input.raw_stop = stop; 636 mctx.input.raw_stop = stop;
701 mctx.input.newline_anchor = preg->newline_anchor; 637 mctx.input.newline_anchor = preg->newline_anchor;
702 638
703 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); 639 err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2);
704 if (BE (err != REG_NOERROR, 0)) 640 if (__glibc_unlikely (err != REG_NOERROR))
705 goto free_return; 641 goto free_return;
706 642
707 /* We will log all the DFA states through which the dfa pass, 643 /* We will log all the DFA states through which the dfa pass,
@@ -711,22 +647,20 @@ re_search_internal (const regex_t *preg,
711 if (nmatch > 1 || dfa->has_mb_node) 647 if (nmatch > 1 || dfa->has_mb_node)
712 { 648 {
713 /* Avoid overflow. */ 649 /* Avoid overflow. */
714 if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) 650 if (__glibc_unlikely ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
715 <= mctx.input.bufs_len), 0)) 651 <= mctx.input.bufs_len)))
716 { 652 {
717 err = REG_ESPACE; 653 err = REG_ESPACE;
718 goto free_return; 654 goto free_return;
719 } 655 }
720 656
721 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); 657 mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1);
722 if (BE (mctx.state_log == NULL, 0)) 658 if (__glibc_unlikely (mctx.state_log == NULL))
723 { 659 {
724 err = REG_ESPACE; 660 err = REG_ESPACE;
725 goto free_return; 661 goto free_return;
726 } 662 }
727 } 663 }
728 else
729 mctx.state_log = NULL;
730 664
731 match_first = start; 665 match_first = start;
732 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF 666 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
@@ -763,19 +697,19 @@ re_search_internal (const regex_t *preg,
763 697
764 case 7: 698 case 7:
765 /* Fastmap with single-byte translation, match forward. */ 699 /* Fastmap with single-byte translation, match forward. */
766 while (BE (match_first < right_lim, 1) 700 while (__glibc_likely (match_first < right_lim)
767 && !fastmap[t[(unsigned char) string[match_first]]]) 701 && !fastmap[t[(unsigned char) string[match_first]]])
768 ++match_first; 702 ++match_first;
769 goto forward_match_found_start_or_reached_end; 703 goto forward_match_found_start_or_reached_end;
770 704
771 case 6: 705 case 6:
772 /* Fastmap without translation, match forward. */ 706 /* Fastmap without translation, match forward. */
773 while (BE (match_first < right_lim, 1) 707 while (__glibc_likely (match_first < right_lim)
774 && !fastmap[(unsigned char) string[match_first]]) 708 && !fastmap[(unsigned char) string[match_first]])
775 ++match_first; 709 ++match_first;
776 710
777 forward_match_found_start_or_reached_end: 711 forward_match_found_start_or_reached_end:
778 if (BE (match_first == right_lim, 0)) 712 if (__glibc_unlikely (match_first == right_lim))
779 { 713 {
780 ch = match_first >= length 714 ch = match_first >= length
781 ? 0 : (unsigned char) string[match_first]; 715 ? 0 : (unsigned char) string[match_first];
@@ -808,19 +742,19 @@ re_search_internal (const regex_t *preg,
808 /* If MATCH_FIRST is out of the valid range, reconstruct the 742 /* If MATCH_FIRST is out of the valid range, reconstruct the
809 buffers. */ 743 buffers. */
810 __re_size_t offset = match_first - mctx.input.raw_mbs_idx; 744 __re_size_t offset = match_first - mctx.input.raw_mbs_idx;
811 if (BE (offset >= (__re_size_t) mctx.input.valid_raw_len, 0)) 745 if (__glibc_unlikely (offset
746 >= (__re_size_t) mctx.input.valid_raw_len))
812 { 747 {
813 err = re_string_reconstruct (&mctx.input, match_first, 748 err = re_string_reconstruct (&mctx.input, match_first,
814 eflags); 749 eflags);
815 if (BE (err != REG_NOERROR, 0)) 750 if (__glibc_unlikely (err != REG_NOERROR))
816 goto free_return; 751 goto free_return;
817 752
818 offset = match_first - mctx.input.raw_mbs_idx; 753 offset = match_first - mctx.input.raw_mbs_idx;
819 } 754 }
820 /* If MATCH_FIRST is out of the buffer, leave it as '\0'. 755 /* Use buffer byte if OFFSET is in buffer, otherwise '\0'. */
821 Note that MATCH_FIRST must not be smaller than 0. */ 756 ch = (offset < mctx.input.valid_len
822 ch = (match_first >= length 757 ? re_string_byte_at (&mctx.input, offset) : 0);
823 ? 0 : re_string_byte_at (&mctx.input, offset));
824 if (fastmap[ch]) 758 if (fastmap[ch])
825 break; 759 break;
826 match_first += incr; 760 match_first += incr;
@@ -836,24 +770,22 @@ re_search_internal (const regex_t *preg,
836 /* Reconstruct the buffers so that the matcher can assume that 770 /* Reconstruct the buffers so that the matcher can assume that
837 the matching starts from the beginning of the buffer. */ 771 the matching starts from the beginning of the buffer. */
838 err = re_string_reconstruct (&mctx.input, match_first, eflags); 772 err = re_string_reconstruct (&mctx.input, match_first, eflags);
839 if (BE (err != REG_NOERROR, 0)) 773 if (__glibc_unlikely (err != REG_NOERROR))
840 goto free_return; 774 goto free_return;
841 775
842#ifdef RE_ENABLE_I18N 776 /* Don't consider this char as a possible match start if it part,
843 /* Don't consider this char as a possible match start if it part, 777 yet isn't the head, of a multibyte character. */
844 yet isn't the head, of a multibyte character. */
845 if (!sb && !re_string_first_byte (&mctx.input, 0)) 778 if (!sb && !re_string_first_byte (&mctx.input, 0))
846 continue; 779 continue;
847#endif
848 780
849 /* It seems to be appropriate one, then use the matcher. */ 781 /* It seems to be appropriate one, then use the matcher. */
850 /* We assume that the matching starts from 0. */ 782 /* We assume that the matching starts from 0. */
851 mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; 783 mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0;
852 match_last = check_matching (&mctx, fl_longest_match, 784 match_last = check_matching (&mctx, fl_longest_match,
853 start <= last_start ? &match_first : NULL); 785 start <= last_start ? &match_first : NULL);
854 if (match_last != REG_MISSING) 786 if (match_last != -1)
855 { 787 {
856 if (BE (match_last == REG_ERROR, 0)) 788 if (__glibc_unlikely (match_last == -2))
857 { 789 {
858 err = REG_ESPACE; 790 err = REG_ESPACE;
859 goto free_return; 791 goto free_return;
@@ -873,9 +805,9 @@ re_search_internal (const regex_t *preg,
873 err = prune_impossible_nodes (&mctx); 805 err = prune_impossible_nodes (&mctx);
874 if (err == REG_NOERROR) 806 if (err == REG_NOERROR)
875 break; 807 break;
876 if (BE (err != REG_NOMATCH, 0)) 808 if (__glibc_unlikely (err != REG_NOMATCH))
877 goto free_return; 809 goto free_return;
878 match_last = REG_MISSING; 810 match_last = -1;
879 } 811 }
880 else 812 else
881 break; /* We found a match. */ 813 break; /* We found a match. */
@@ -885,10 +817,8 @@ re_search_internal (const regex_t *preg,
885 match_ctx_clean (&mctx); 817 match_ctx_clean (&mctx);
886 } 818 }
887 819
888#ifdef DEBUG 820 DEBUG_ASSERT (match_last != -1);
889 assert (match_last != REG_MISSING); 821 DEBUG_ASSERT (err == REG_NOERROR);
890 assert (err == REG_NOERROR);
891#endif
892 822
893 /* Set pmatch[] if we need. */ 823 /* Set pmatch[] if we need. */
894 if (nmatch > 0) 824 if (nmatch > 0)
@@ -910,7 +840,7 @@ re_search_internal (const regex_t *preg,
910 { 840 {
911 err = set_regs (preg, &mctx, nmatch, pmatch, 841 err = set_regs (preg, &mctx, nmatch, pmatch,
912 dfa->has_plural_match && dfa->nbackref > 0); 842 dfa->has_plural_match && dfa->nbackref > 0);
913 if (BE (err != REG_NOERROR, 0)) 843 if (__glibc_unlikely (err != REG_NOERROR))
914 goto free_return; 844 goto free_return;
915 } 845 }
916 846
@@ -920,8 +850,7 @@ re_search_internal (const regex_t *preg,
920 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) 850 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
921 if (pmatch[reg_idx].rm_so != -1) 851 if (pmatch[reg_idx].rm_so != -1)
922 { 852 {
923#ifdef RE_ENABLE_I18N 853 if (__glibc_unlikely (mctx.input.offsets_needed != 0))
924 if (BE (mctx.input.offsets_needed != 0, 0))
925 { 854 {
926 pmatch[reg_idx].rm_so = 855 pmatch[reg_idx].rm_so =
927 (pmatch[reg_idx].rm_so == mctx.input.valid_len 856 (pmatch[reg_idx].rm_so == mctx.input.valid_len
@@ -932,9 +861,6 @@ re_search_internal (const regex_t *preg,
932 ? mctx.input.valid_raw_len 861 ? mctx.input.valid_raw_len
933 : mctx.input.offsets[pmatch[reg_idx].rm_eo]); 862 : mctx.input.offsets[pmatch[reg_idx].rm_eo]);
934 } 863 }
935#else
936 assert (mctx.input.offsets_needed == 0);
937#endif
938 pmatch[reg_idx].rm_so += match_first; 864 pmatch[reg_idx].rm_so += match_first;
939 pmatch[reg_idx].rm_eo += match_first; 865 pmatch[reg_idx].rm_eo += match_first;
940 } 866 }
@@ -973,18 +899,17 @@ prune_impossible_nodes (re_match_context_t *mctx)
973 re_dfastate_t **sifted_states; 899 re_dfastate_t **sifted_states;
974 re_dfastate_t **lim_states = NULL; 900 re_dfastate_t **lim_states = NULL;
975 re_sift_context_t sctx; 901 re_sift_context_t sctx;
976#ifdef DEBUG 902 DEBUG_ASSERT (mctx->state_log != NULL);
977 assert (mctx->state_log != NULL);
978#endif
979 match_last = mctx->match_last; 903 match_last = mctx->match_last;
980 halt_node = mctx->last_node; 904 halt_node = mctx->last_node;
981 905
982 /* Avoid overflow. */ 906 /* Avoid overflow. */
983 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0)) 907 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
908 <= match_last))
984 return REG_ESPACE; 909 return REG_ESPACE;
985 910
986 sifted_states = re_malloc (re_dfastate_t *, match_last + 1); 911 sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
987 if (BE (sifted_states == NULL, 0)) 912 if (__glibc_unlikely (sifted_states == NULL))
988 { 913 {
989 ret = REG_ESPACE; 914 ret = REG_ESPACE;
990 goto free_return; 915 goto free_return;
@@ -992,7 +917,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
992 if (dfa->nbackref) 917 if (dfa->nbackref)
993 { 918 {
994 lim_states = re_malloc (re_dfastate_t *, match_last + 1); 919 lim_states = re_malloc (re_dfastate_t *, match_last + 1);
995 if (BE (lim_states == NULL, 0)) 920 if (__glibc_unlikely (lim_states == NULL))
996 { 921 {
997 ret = REG_ESPACE; 922 ret = REG_ESPACE;
998 goto free_return; 923 goto free_return;
@@ -1005,14 +930,14 @@ prune_impossible_nodes (re_match_context_t *mctx)
1005 match_last); 930 match_last);
1006 ret = sift_states_backward (mctx, &sctx); 931 ret = sift_states_backward (mctx, &sctx);
1007 re_node_set_free (&sctx.limits); 932 re_node_set_free (&sctx.limits);
1008 if (BE (ret != REG_NOERROR, 0)) 933 if (__glibc_unlikely (ret != REG_NOERROR))
1009 goto free_return; 934 goto free_return;
1010 if (sifted_states[0] != NULL || lim_states[0] != NULL) 935 if (sifted_states[0] != NULL || lim_states[0] != NULL)
1011 break; 936 break;
1012 do 937 do
1013 { 938 {
1014 --match_last; 939 --match_last;
1015 if (! REG_VALID_INDEX (match_last)) 940 if (match_last < 0)
1016 { 941 {
1017 ret = REG_NOMATCH; 942 ret = REG_NOMATCH;
1018 goto free_return; 943 goto free_return;
@@ -1027,7 +952,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1027 match_last + 1); 952 match_last + 1);
1028 re_free (lim_states); 953 re_free (lim_states);
1029 lim_states = NULL; 954 lim_states = NULL;
1030 if (BE (ret != REG_NOERROR, 0)) 955 if (__glibc_unlikely (ret != REG_NOERROR))
1031 goto free_return; 956 goto free_return;
1032 } 957 }
1033 else 958 else
@@ -1035,7 +960,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1035 sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); 960 sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last);
1036 ret = sift_states_backward (mctx, &sctx); 961 ret = sift_states_backward (mctx, &sctx);
1037 re_node_set_free (&sctx.limits); 962 re_node_set_free (&sctx.limits);
1038 if (BE (ret != REG_NOERROR, 0)) 963 if (__glibc_unlikely (ret != REG_NOERROR))
1039 goto free_return; 964 goto free_return;
1040 if (sifted_states[0] == NULL) 965 if (sifted_states[0] == NULL)
1041 { 966 {
@@ -1059,8 +984,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1059 We must select appropriate initial state depending on the context, 984 We must select appropriate initial state depending on the context,
1060 since initial states may have constraints like "\<", "^", etc.. */ 985 since initial states may have constraints like "\<", "^", etc.. */
1061 986
1062static inline re_dfastate_t * 987static __always_inline re_dfastate_t *
1063__attribute__ ((always_inline)) internal_function
1064acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, 988acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1065 Idx idx) 989 Idx idx)
1066{ 990{
@@ -1093,8 +1017,8 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1093} 1017}
1094 1018
1095/* Check whether the regular expression match input string INPUT or not, 1019/* Check whether the regular expression match input string INPUT or not,
1096 and return the index where the matching end. Return REG_MISSING if 1020 and return the index where the matching end. Return -1 if
1097 there is no match, and return REG_ERROR in case of an error. 1021 there is no match, and return -2 in case of an error.
1098 FL_LONGEST_MATCH means we want the POSIX longest matching. 1022 FL_LONGEST_MATCH means we want the POSIX longest matching.
1099 If P_MATCH_FIRST is not NULL, and the match fails, it is set to the 1023 If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
1100 next place where we may want to try matching. 1024 next place where we may want to try matching.
@@ -1102,14 +1026,14 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1102 index of the buffer. */ 1026 index of the buffer. */
1103 1027
1104static Idx 1028static Idx
1105internal_function __attribute_warn_unused_result__ 1029__attribute_warn_unused_result__
1106check_matching (re_match_context_t *mctx, bool fl_longest_match, 1030check_matching (re_match_context_t *mctx, bool fl_longest_match,
1107 Idx *p_match_first) 1031 Idx *p_match_first)
1108{ 1032{
1109 const re_dfa_t *const dfa = mctx->dfa; 1033 const re_dfa_t *const dfa = mctx->dfa;
1110 reg_errcode_t err; 1034 reg_errcode_t err;
1111 Idx match = 0; 1035 Idx match = 0;
1112 Idx match_last = REG_MISSING; 1036 Idx match_last = -1;
1113 Idx cur_str_idx = re_string_cur_idx (&mctx->input); 1037 Idx cur_str_idx = re_string_cur_idx (&mctx->input);
1114 re_dfastate_t *cur_state; 1038 re_dfastate_t *cur_state;
1115 bool at_init_state = p_match_first != NULL; 1039 bool at_init_state = p_match_first != NULL;
@@ -1118,10 +1042,10 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1118 err = REG_NOERROR; 1042 err = REG_NOERROR;
1119 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); 1043 cur_state = acquire_init_state_context (&err, mctx, cur_str_idx);
1120 /* An initial state must not be NULL (invalid). */ 1044 /* An initial state must not be NULL (invalid). */
1121 if (BE (cur_state == NULL, 0)) 1045 if (__glibc_unlikely (cur_state == NULL))
1122 { 1046 {
1123 assert (err == REG_ESPACE); 1047 DEBUG_ASSERT (err == REG_ESPACE);
1124 return REG_ERROR; 1048 return -2;
1125 } 1049 }
1126 1050
1127 if (mctx->state_log != NULL) 1051 if (mctx->state_log != NULL)
@@ -1130,24 +1054,24 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1130 1054
1131 /* Check OP_OPEN_SUBEXP in the initial state in case that we use them 1055 /* Check OP_OPEN_SUBEXP in the initial state in case that we use them
1132 later. E.g. Processing back references. */ 1056 later. E.g. Processing back references. */
1133 if (BE (dfa->nbackref, 0)) 1057 if (__glibc_unlikely (dfa->nbackref))
1134 { 1058 {
1135 at_init_state = false; 1059 at_init_state = false;
1136 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); 1060 err = check_subexp_matching_top (mctx, &cur_state->nodes, 0);
1137 if (BE (err != REG_NOERROR, 0)) 1061 if (__glibc_unlikely (err != REG_NOERROR))
1138 return err; 1062 return err;
1139 1063
1140 if (cur_state->has_backref) 1064 if (cur_state->has_backref)
1141 { 1065 {
1142 err = transit_state_bkref (mctx, &cur_state->nodes); 1066 err = transit_state_bkref (mctx, &cur_state->nodes);
1143 if (BE (err != REG_NOERROR, 0)) 1067 if (__glibc_unlikely (err != REG_NOERROR))
1144 return err; 1068 return err;
1145 } 1069 }
1146 } 1070 }
1147 } 1071 }
1148 1072
1149 /* If the RE accepts NULL string. */ 1073 /* If the RE accepts NULL string. */
1150 if (BE (cur_state->halt, 0)) 1074 if (__glibc_unlikely (cur_state->halt))
1151 { 1075 {
1152 if (!cur_state->has_constraint 1076 if (!cur_state->has_constraint
1153 || check_halt_state_context (mctx, cur_state, cur_str_idx)) 1077 || check_halt_state_context (mctx, cur_state, cur_str_idx))
@@ -1167,16 +1091,16 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1167 re_dfastate_t *old_state = cur_state; 1091 re_dfastate_t *old_state = cur_state;
1168 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; 1092 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
1169 1093
1170 if ((BE (next_char_idx >= mctx->input.bufs_len, 0) 1094 if ((__glibc_unlikely (next_char_idx >= mctx->input.bufs_len)
1171 && mctx->input.bufs_len < mctx->input.len) 1095 && mctx->input.bufs_len < mctx->input.len)
1172 || (BE (next_char_idx >= mctx->input.valid_len, 0) 1096 || (__glibc_unlikely (next_char_idx >= mctx->input.valid_len)
1173 && mctx->input.valid_len < mctx->input.len)) 1097 && mctx->input.valid_len < mctx->input.len))
1174 { 1098 {
1175 err = extend_buffers (mctx, next_char_idx + 1); 1099 err = extend_buffers (mctx, next_char_idx + 1);
1176 if (BE (err != REG_NOERROR, 0)) 1100 if (__glibc_unlikely (err != REG_NOERROR))
1177 { 1101 {
1178 assert (err == REG_ESPACE); 1102 DEBUG_ASSERT (err == REG_ESPACE);
1179 return REG_ERROR; 1103 return -2;
1180 } 1104 }
1181 } 1105 }
1182 1106
@@ -1189,8 +1113,8 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1189 /* Reached the invalid state or an error. Try to recover a valid 1113 /* Reached the invalid state or an error. Try to recover a valid
1190 state using the state log, if available and if we have not 1114 state using the state log, if available and if we have not
1191 already found a valid (even if not the longest) match. */ 1115 already found a valid (even if not the longest) match. */
1192 if (BE (err != REG_NOERROR, 0)) 1116 if (__glibc_unlikely (err != REG_NOERROR))
1193 return REG_ERROR; 1117 return -2;
1194 1118
1195 if (mctx->state_log == NULL 1119 if (mctx->state_log == NULL
1196 || (match && !fl_longest_match) 1120 || (match && !fl_longest_match)
@@ -1198,7 +1122,7 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1198 break; 1122 break;
1199 } 1123 }
1200 1124
1201 if (BE (at_init_state, 0)) 1125 if (__glibc_unlikely (at_init_state))
1202 { 1126 {
1203 if (old_state == cur_state) 1127 if (old_state == cur_state)
1204 next_start_idx = next_char_idx; 1128 next_start_idx = next_char_idx;
@@ -1235,7 +1159,6 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1235/* Check NODE match the current context. */ 1159/* Check NODE match the current context. */
1236 1160
1237static bool 1161static bool
1238internal_function
1239check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context) 1162check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
1240{ 1163{
1241 re_token_type_t type = dfa->nodes[node].type; 1164 re_token_type_t type = dfa->nodes[node].type;
@@ -1254,15 +1177,12 @@ check_halt_node_context (const re_dfa_t *dfa, Idx node, unsigned int context)
1254 match the context, return the node. */ 1177 match the context, return the node. */
1255 1178
1256static Idx 1179static Idx
1257internal_function
1258check_halt_state_context (const re_match_context_t *mctx, 1180check_halt_state_context (const re_match_context_t *mctx,
1259 const re_dfastate_t *state, Idx idx) 1181 const re_dfastate_t *state, Idx idx)
1260{ 1182{
1261 Idx i; 1183 Idx i;
1262 unsigned int context; 1184 unsigned int context;
1263#ifdef DEBUG 1185 DEBUG_ASSERT (state->halt);
1264 assert (state->halt);
1265#endif
1266 context = re_string_context_at (&mctx->input, idx, mctx->eflags); 1186 context = re_string_context_at (&mctx->input, idx, mctx->eflags);
1267 for (i = 0; i < state->nodes.nelem; ++i) 1187 for (i = 0; i < state->nodes.nelem; ++i)
1268 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) 1188 if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context))
@@ -1273,33 +1193,35 @@ check_halt_state_context (const re_match_context_t *mctx,
1273/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA 1193/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA
1274 corresponding to the DFA). 1194 corresponding to the DFA).
1275 Return the destination node, and update EPS_VIA_NODES; 1195 Return the destination node, and update EPS_VIA_NODES;
1276 return REG_MISSING in case of errors. */ 1196 return -1 on match failure, -2 on error. */
1277 1197
1278static Idx 1198static Idx
1279internal_function
1280proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs, 1199proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1200 regmatch_t *prevregs,
1281 Idx *pidx, Idx node, re_node_set *eps_via_nodes, 1201 Idx *pidx, Idx node, re_node_set *eps_via_nodes,
1282 struct re_fail_stack_t *fs) 1202 struct re_fail_stack_t *fs)
1283{ 1203{
1284 const re_dfa_t *const dfa = mctx->dfa; 1204 const re_dfa_t *const dfa = mctx->dfa;
1285 Idx i;
1286 bool ok;
1287 if (IS_EPSILON_NODE (dfa->nodes[node].type)) 1205 if (IS_EPSILON_NODE (dfa->nodes[node].type))
1288 { 1206 {
1289 re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; 1207 re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes;
1290 re_node_set *edests = &dfa->edests[node]; 1208 re_node_set *edests = &dfa->edests[node];
1291 Idx dest_node; 1209
1292 ok = re_node_set_insert (eps_via_nodes, node); 1210 if (! re_node_set_contains (eps_via_nodes, node))
1293 if (BE (! ok, 0)) 1211 {
1294 return REG_ERROR; 1212 bool ok = re_node_set_insert (eps_via_nodes, node);
1295 /* Pick up a valid destination, or return REG_MISSING if none 1213 if (__glibc_unlikely (! ok))
1296 is found. */ 1214 return -2;
1297 for (dest_node = REG_MISSING, i = 0; i < edests->nelem; ++i) 1215 }
1216
1217 /* Pick a valid destination, or return -1 if none is found. */
1218 Idx dest_node = -1;
1219 for (Idx i = 0; i < edests->nelem; i++)
1298 { 1220 {
1299 Idx candidate = edests->elems[i]; 1221 Idx candidate = edests->elems[i];
1300 if (!re_node_set_contains (cur_nodes, candidate)) 1222 if (!re_node_set_contains (cur_nodes, candidate))
1301 continue; 1223 continue;
1302 if (dest_node == REG_MISSING) 1224 if (dest_node == -1)
1303 dest_node = candidate; 1225 dest_node = candidate;
1304 1226
1305 else 1227 else
@@ -1312,8 +1234,8 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1312 /* Otherwise, push the second epsilon-transition on the fail stack. */ 1234 /* Otherwise, push the second epsilon-transition on the fail stack. */
1313 else if (fs != NULL 1235 else if (fs != NULL
1314 && push_fail_stack (fs, *pidx, candidate, nregs, regs, 1236 && push_fail_stack (fs, *pidx, candidate, nregs, regs,
1315 eps_via_nodes)) 1237 prevregs, eps_via_nodes))
1316 return REG_ERROR; 1238 return -2;
1317 1239
1318 /* We know we are going to exit. */ 1240 /* We know we are going to exit. */
1319 break; 1241 break;
@@ -1326,34 +1248,36 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1326 Idx naccepted = 0; 1248 Idx naccepted = 0;
1327 re_token_type_t type = dfa->nodes[node].type; 1249 re_token_type_t type = dfa->nodes[node].type;
1328 1250
1329#ifdef RE_ENABLE_I18N
1330 if (dfa->nodes[node].accept_mb) 1251 if (dfa->nodes[node].accept_mb)
1331 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); 1252 naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx);
1332 else 1253 else if (type == OP_BACK_REF)
1333#endif /* RE_ENABLE_I18N */
1334 if (type == OP_BACK_REF)
1335 { 1254 {
1336 Idx subexp_idx = dfa->nodes[node].opr.idx + 1; 1255 Idx subexp_idx = dfa->nodes[node].opr.idx + 1;
1337 naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; 1256 if (subexp_idx < nregs)
1257 naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so;
1338 if (fs != NULL) 1258 if (fs != NULL)
1339 { 1259 {
1340 if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) 1260 if (subexp_idx >= nregs
1341 return REG_MISSING; 1261 || regs[subexp_idx].rm_so == -1
1262 || regs[subexp_idx].rm_eo == -1)
1263 return -1;
1342 else if (naccepted) 1264 else if (naccepted)
1343 { 1265 {
1344 char *buf = (char *) re_string_get_buffer (&mctx->input); 1266 char *buf = (char *) re_string_get_buffer (&mctx->input);
1345 if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, 1267 if (mctx->input.valid_len - *pidx < naccepted
1346 naccepted) != 0) 1268 || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
1347 return REG_MISSING; 1269 naccepted)
1270 != 0))
1271 return -1;
1348 } 1272 }
1349 } 1273 }
1350 1274
1351 if (naccepted == 0) 1275 if (naccepted == 0)
1352 { 1276 {
1353 Idx dest_node; 1277 Idx dest_node;
1354 ok = re_node_set_insert (eps_via_nodes, node); 1278 bool ok = re_node_set_insert (eps_via_nodes, node);
1355 if (BE (! ok, 0)) 1279 if (__glibc_unlikely (! ok))
1356 return REG_ERROR; 1280 return -2;
1357 dest_node = dfa->edests[node].elems[0]; 1281 dest_node = dfa->edests[node].elems[0];
1358 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, 1282 if (re_node_set_contains (&mctx->state_log[*pidx]->nodes,
1359 dest_node)) 1283 dest_node))
@@ -1369,26 +1293,27 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
1369 if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL 1293 if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL
1370 || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, 1294 || !re_node_set_contains (&mctx->state_log[*pidx]->nodes,
1371 dest_node))) 1295 dest_node)))
1372 return REG_MISSING; 1296 return -1;
1373 re_node_set_empty (eps_via_nodes); 1297 re_node_set_empty (eps_via_nodes);
1374 return dest_node; 1298 return dest_node;
1375 } 1299 }
1376 } 1300 }
1377 return REG_MISSING; 1301 return -1;
1378} 1302}
1379 1303
1380static reg_errcode_t 1304static reg_errcode_t
1381internal_function __attribute_warn_unused_result__ 1305__attribute_warn_unused_result__
1382push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node, 1306push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
1383 Idx nregs, regmatch_t *regs, re_node_set *eps_via_nodes) 1307 Idx nregs, regmatch_t *regs, regmatch_t *prevregs,
1308 re_node_set *eps_via_nodes)
1384{ 1309{
1385 reg_errcode_t err; 1310 reg_errcode_t err;
1386 Idx num = fs->num++; 1311 Idx num = fs->num;
1387 if (fs->num == fs->alloc) 1312 if (num == fs->alloc)
1388 { 1313 {
1389 struct re_fail_stack_ent_t *new_array; 1314 struct re_fail_stack_ent_t *new_array;
1390 new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) 1315 new_array = re_realloc (fs->stack, struct re_fail_stack_ent_t,
1391 * fs->alloc * 2)); 1316 fs->alloc * 2);
1392 if (new_array == NULL) 1317 if (new_array == NULL)
1393 return REG_ESPACE; 1318 return REG_ESPACE;
1394 fs->alloc *= 2; 1319 fs->alloc *= 2;
@@ -1396,36 +1321,47 @@ push_fail_stack (struct re_fail_stack_t *fs, Idx str_idx, Idx dest_node,
1396 } 1321 }
1397 fs->stack[num].idx = str_idx; 1322 fs->stack[num].idx = str_idx;
1398 fs->stack[num].node = dest_node; 1323 fs->stack[num].node = dest_node;
1399 fs->stack[num].regs = re_malloc (regmatch_t, nregs); 1324 fs->stack[num].regs = re_malloc (regmatch_t, 2 * nregs);
1400 if (fs->stack[num].regs == NULL) 1325 if (fs->stack[num].regs == NULL)
1401 return REG_ESPACE; 1326 return REG_ESPACE;
1327 fs->num = num + 1;
1402 memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); 1328 memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs);
1329 memcpy (fs->stack[num].regs + nregs, prevregs, sizeof (regmatch_t) * nregs);
1403 err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); 1330 err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes);
1404 return err; 1331 return err;
1405} 1332}
1406 1333
1407static Idx 1334static Idx
1408internal_function
1409pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs, 1335pop_fail_stack (struct re_fail_stack_t *fs, Idx *pidx, Idx nregs,
1410 regmatch_t *regs, re_node_set *eps_via_nodes) 1336 regmatch_t *regs, regmatch_t *prevregs,
1337 re_node_set *eps_via_nodes)
1411{ 1338{
1339 if (fs == NULL || fs->num == 0)
1340 return -1;
1412 Idx num = --fs->num; 1341 Idx num = --fs->num;
1413 assert (REG_VALID_INDEX (num));
1414 *pidx = fs->stack[num].idx; 1342 *pidx = fs->stack[num].idx;
1415 memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); 1343 memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs);
1344 memcpy (prevregs, fs->stack[num].regs + nregs, sizeof (regmatch_t) * nregs);
1416 re_node_set_free (eps_via_nodes); 1345 re_node_set_free (eps_via_nodes);
1417 re_free (fs->stack[num].regs); 1346 re_free (fs->stack[num].regs);
1418 *eps_via_nodes = fs->stack[num].eps_via_nodes; 1347 *eps_via_nodes = fs->stack[num].eps_via_nodes;
1348 DEBUG_ASSERT (0 <= fs->stack[num].node);
1419 return fs->stack[num].node; 1349 return fs->stack[num].node;
1420} 1350}
1421 1351
1352
1353#define DYNARRAY_STRUCT regmatch_list
1354#define DYNARRAY_ELEMENT regmatch_t
1355#define DYNARRAY_PREFIX regmatch_list_
1356#include <malloc/dynarray-skeleton.c>
1357
1422/* Set the positions where the subexpressions are starts/ends to registers 1358/* Set the positions where the subexpressions are starts/ends to registers
1423 PMATCH. 1359 PMATCH.
1424 Note: We assume that pmatch[0] is already set, and 1360 Note: We assume that pmatch[0] is already set, and
1425 pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ 1361 pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */
1426 1362
1427static reg_errcode_t 1363static reg_errcode_t
1428internal_function __attribute_warn_unused_result__ 1364__attribute_warn_unused_result__
1429set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, 1365set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1430 regmatch_t *pmatch, bool fl_backtrack) 1366 regmatch_t *pmatch, bool fl_backtrack)
1431{ 1367{
@@ -1434,13 +1370,11 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1434 re_node_set eps_via_nodes; 1370 re_node_set eps_via_nodes;
1435 struct re_fail_stack_t *fs; 1371 struct re_fail_stack_t *fs;
1436 struct re_fail_stack_t fs_body = { 0, 2, NULL }; 1372 struct re_fail_stack_t fs_body = { 0, 2, NULL };
1437 regmatch_t *prev_idx_match; 1373 struct regmatch_list prev_match;
1438 bool prev_idx_match_malloced = false; 1374 regmatch_list_init (&prev_match);
1439 1375
1440#ifdef DEBUG 1376 DEBUG_ASSERT (nmatch > 1);
1441 assert (nmatch > 1); 1377 DEBUG_ASSERT (mctx->state_log != NULL);
1442 assert (mctx->state_log != NULL);
1443#endif
1444 if (fl_backtrack) 1378 if (fl_backtrack)
1445 { 1379 {
1446 fs = &fs_body; 1380 fs = &fs_body;
@@ -1454,85 +1388,73 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1454 cur_node = dfa->init_node; 1388 cur_node = dfa->init_node;
1455 re_node_set_init_empty (&eps_via_nodes); 1389 re_node_set_init_empty (&eps_via_nodes);
1456 1390
1457 if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) 1391 if (!regmatch_list_resize (&prev_match, nmatch))
1458 prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t));
1459 else
1460 { 1392 {
1461 prev_idx_match = re_malloc (regmatch_t, nmatch); 1393 regmatch_list_free (&prev_match);
1462 if (prev_idx_match == NULL) 1394 free_fail_stack_return (fs);
1463 { 1395 return REG_ESPACE;
1464 free_fail_stack_return (fs);
1465 return REG_ESPACE;
1466 }
1467 prev_idx_match_malloced = true;
1468 } 1396 }
1397 regmatch_t *prev_idx_match = regmatch_list_begin (&prev_match);
1469 memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); 1398 memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
1470 1399
1471 for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) 1400 for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;)
1472 { 1401 {
1473 update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); 1402 update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch);
1474 1403
1475 if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) 1404 if ((idx == pmatch[0].rm_eo && cur_node == mctx->last_node)
1405 || (fs && re_node_set_contains (&eps_via_nodes, cur_node)))
1476 { 1406 {
1477 Idx reg_idx; 1407 Idx reg_idx;
1408 cur_node = -1;
1478 if (fs) 1409 if (fs)
1479 { 1410 {
1480 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) 1411 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
1481 if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) 1412 if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1)
1482 break; 1413 {
1483 if (reg_idx == nmatch) 1414 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
1484 { 1415 prev_idx_match, &eps_via_nodes);
1485 re_node_set_free (&eps_via_nodes); 1416 break;
1486 if (prev_idx_match_malloced) 1417 }
1487 re_free (prev_idx_match);
1488 return free_fail_stack_return (fs);
1489 }
1490 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
1491 &eps_via_nodes);
1492 } 1418 }
1493 else 1419 if (cur_node < 0)
1494 { 1420 {
1495 re_node_set_free (&eps_via_nodes); 1421 re_node_set_free (&eps_via_nodes);
1496 if (prev_idx_match_malloced) 1422 regmatch_list_free (&prev_match);
1497 re_free (prev_idx_match); 1423 return free_fail_stack_return (fs);
1498 return REG_NOERROR;
1499 } 1424 }
1500 } 1425 }
1501 1426
1502 /* Proceed to next node. */ 1427 /* Proceed to next node. */
1503 cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, 1428 cur_node = proceed_next_node (mctx, nmatch, pmatch, prev_idx_match,
1429 &idx, cur_node,
1504 &eps_via_nodes, fs); 1430 &eps_via_nodes, fs);
1505 1431
1506 if (BE (! REG_VALID_INDEX (cur_node), 0)) 1432 if (__glibc_unlikely (cur_node < 0))
1507 { 1433 {
1508 if (BE (cur_node == REG_ERROR, 0)) 1434 if (__glibc_unlikely (cur_node == -2))
1509 { 1435 {
1510 re_node_set_free (&eps_via_nodes); 1436 re_node_set_free (&eps_via_nodes);
1511 if (prev_idx_match_malloced) 1437 regmatch_list_free (&prev_match);
1512 re_free (prev_idx_match);
1513 free_fail_stack_return (fs); 1438 free_fail_stack_return (fs);
1514 return REG_ESPACE; 1439 return REG_ESPACE;
1515 } 1440 }
1516 if (fs) 1441 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch,
1517 cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, 1442 prev_idx_match, &eps_via_nodes);
1518 &eps_via_nodes); 1443 if (cur_node < 0)
1519 else
1520 { 1444 {
1521 re_node_set_free (&eps_via_nodes); 1445 re_node_set_free (&eps_via_nodes);
1522 if (prev_idx_match_malloced) 1446 regmatch_list_free (&prev_match);
1523 re_free (prev_idx_match); 1447 free_fail_stack_return (fs);
1524 return REG_NOMATCH; 1448 return REG_NOMATCH;
1525 } 1449 }
1526 } 1450 }
1527 } 1451 }
1528 re_node_set_free (&eps_via_nodes); 1452 re_node_set_free (&eps_via_nodes);
1529 if (prev_idx_match_malloced) 1453 regmatch_list_free (&prev_match);
1530 re_free (prev_idx_match);
1531 return free_fail_stack_return (fs); 1454 return free_fail_stack_return (fs);
1532} 1455}
1533 1456
1534static reg_errcode_t 1457static reg_errcode_t
1535internal_function
1536free_fail_stack_return (struct re_fail_stack_t *fs) 1458free_fail_stack_return (struct re_fail_stack_t *fs)
1537{ 1459{
1538 if (fs) 1460 if (fs)
@@ -1549,7 +1471,6 @@ free_fail_stack_return (struct re_fail_stack_t *fs)
1549} 1471}
1550 1472
1551static void 1473static void
1552internal_function
1553update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, 1474update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1554 regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch) 1475 regmatch_t *prev_idx_match, Idx cur_node, Idx cur_idx, Idx nmatch)
1555{ 1476{
@@ -1567,10 +1488,10 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1567 } 1488 }
1568 else if (type == OP_CLOSE_SUBEXP) 1489 else if (type == OP_CLOSE_SUBEXP)
1569 { 1490 {
1491 /* We are at the last node of this sub expression. */
1570 Idx reg_num = dfa->nodes[cur_node].opr.idx + 1; 1492 Idx reg_num = dfa->nodes[cur_node].opr.idx + 1;
1571 if (reg_num < nmatch) 1493 if (reg_num < nmatch)
1572 { 1494 {
1573 /* We are at the last node of this sub expression. */
1574 if (pmatch[reg_num].rm_so < cur_idx) 1495 if (pmatch[reg_num].rm_so < cur_idx)
1575 { 1496 {
1576 pmatch[reg_num].rm_eo = cur_idx; 1497 pmatch[reg_num].rm_eo = cur_idx;
@@ -1621,7 +1542,6 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1621 ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) 1542 ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
1622 1543
1623static reg_errcode_t 1544static reg_errcode_t
1624internal_function
1625sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) 1545sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1626{ 1546{
1627 reg_errcode_t err; 1547 reg_errcode_t err;
@@ -1629,17 +1549,15 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1629 Idx str_idx = sctx->last_str_idx; 1549 Idx str_idx = sctx->last_str_idx;
1630 re_node_set cur_dest; 1550 re_node_set cur_dest;
1631 1551
1632#ifdef DEBUG 1552 DEBUG_ASSERT (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1633 assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL);
1634#endif
1635 1553
1636 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon 1554 /* Build sifted state_log[str_idx]. It has the nodes which can epsilon
1637 transit to the last_node and the last_node itself. */ 1555 transit to the last_node and the last_node itself. */
1638 err = re_node_set_init_1 (&cur_dest, sctx->last_node); 1556 err = re_node_set_init_1 (&cur_dest, sctx->last_node);
1639 if (BE (err != REG_NOERROR, 0)) 1557 if (__glibc_unlikely (err != REG_NOERROR))
1640 return err; 1558 return err;
1641 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); 1559 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1642 if (BE (err != REG_NOERROR, 0)) 1560 if (__glibc_unlikely (err != REG_NOERROR))
1643 goto free_return; 1561 goto free_return;
1644 1562
1645 /* Then check each states in the state_log. */ 1563 /* Then check each states in the state_log. */
@@ -1660,7 +1578,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1660 if (mctx->state_log[str_idx]) 1578 if (mctx->state_log[str_idx])
1661 { 1579 {
1662 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); 1580 err = build_sifted_states (mctx, sctx, str_idx, &cur_dest);
1663 if (BE (err != REG_NOERROR, 0)) 1581 if (__glibc_unlikely (err != REG_NOERROR))
1664 goto free_return; 1582 goto free_return;
1665 } 1583 }
1666 1584
@@ -1669,7 +1587,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1669 - It is in CUR_SRC. 1587 - It is in CUR_SRC.
1670 And update state_log. */ 1588 And update state_log. */
1671 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); 1589 err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest);
1672 if (BE (err != REG_NOERROR, 0)) 1590 if (__glibc_unlikely (err != REG_NOERROR))
1673 goto free_return; 1591 goto free_return;
1674 } 1592 }
1675 err = REG_NOERROR; 1593 err = REG_NOERROR;
@@ -1679,7 +1597,7 @@ sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx)
1679} 1597}
1680 1598
1681static reg_errcode_t 1599static reg_errcode_t
1682internal_function __attribute_warn_unused_result__ 1600__attribute_warn_unused_result__
1683build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, 1601build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1684 Idx str_idx, re_node_set *cur_dest) 1602 Idx str_idx, re_node_set *cur_dest)
1685{ 1603{
@@ -1699,17 +1617,12 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1699 Idx prev_node = cur_src->elems[i]; 1617 Idx prev_node = cur_src->elems[i];
1700 int naccepted = 0; 1618 int naccepted = 0;
1701 bool ok; 1619 bool ok;
1620 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[prev_node].type));
1702 1621
1703#ifdef DEBUG
1704 re_token_type_t type = dfa->nodes[prev_node].type;
1705 assert (!IS_EPSILON_NODE (type));
1706#endif
1707#ifdef RE_ENABLE_I18N
1708 /* If the node may accept "multi byte". */ 1622 /* If the node may accept "multi byte". */
1709 if (dfa->nodes[prev_node].accept_mb) 1623 if (dfa->nodes[prev_node].accept_mb)
1710 naccepted = sift_states_iter_mb (mctx, sctx, prev_node, 1624 naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
1711 str_idx, sctx->last_str_idx); 1625 str_idx, sctx->last_str_idx);
1712#endif /* RE_ENABLE_I18N */
1713 1626
1714 /* We don't check backreferences here. 1627 /* We don't check backreferences here.
1715 See update_cur_sifted_state(). */ 1628 See update_cur_sifted_state(). */
@@ -1731,7 +1644,7 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1731 continue; 1644 continue;
1732 } 1645 }
1733 ok = re_node_set_insert (cur_dest, prev_node); 1646 ok = re_node_set_insert (cur_dest, prev_node);
1734 if (BE (! ok, 0)) 1647 if (__glibc_unlikely (! ok))
1735 return REG_ESPACE; 1648 return REG_ESPACE;
1736 } 1649 }
1737 1650
@@ -1741,7 +1654,6 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1741/* Helper functions. */ 1654/* Helper functions. */
1742 1655
1743static reg_errcode_t 1656static reg_errcode_t
1744internal_function
1745clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx) 1657clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1746{ 1658{
1747 Idx top = mctx->state_log_top; 1659 Idx top = mctx->state_log_top;
@@ -1753,12 +1665,13 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1753 { 1665 {
1754 reg_errcode_t err; 1666 reg_errcode_t err;
1755 err = extend_buffers (mctx, next_state_log_idx + 1); 1667 err = extend_buffers (mctx, next_state_log_idx + 1);
1756 if (BE (err != REG_NOERROR, 0)) 1668 if (__glibc_unlikely (err != REG_NOERROR))
1757 return err; 1669 return err;
1758 } 1670 }
1759 1671
1760 if (top < next_state_log_idx) 1672 if (top < next_state_log_idx)
1761 { 1673 {
1674 DEBUG_ASSERT (mctx->state_log != NULL);
1762 memset (mctx->state_log + top + 1, '\0', 1675 memset (mctx->state_log + top + 1, '\0',
1763 sizeof (re_dfastate_t *) * (next_state_log_idx - top)); 1676 sizeof (re_dfastate_t *) * (next_state_log_idx - top));
1764 mctx->state_log_top = next_state_log_idx; 1677 mctx->state_log_top = next_state_log_idx;
@@ -1767,7 +1680,6 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1767} 1680}
1768 1681
1769static reg_errcode_t 1682static reg_errcode_t
1770internal_function
1771merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, 1683merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1772 re_dfastate_t **src, Idx num) 1684 re_dfastate_t **src, Idx num)
1773{ 1685{
@@ -1782,11 +1694,11 @@ merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1782 re_node_set merged_set; 1694 re_node_set merged_set;
1783 err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, 1695 err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes,
1784 &src[st_idx]->nodes); 1696 &src[st_idx]->nodes);
1785 if (BE (err != REG_NOERROR, 0)) 1697 if (__glibc_unlikely (err != REG_NOERROR))
1786 return err; 1698 return err;
1787 dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); 1699 dst[st_idx] = re_acquire_state (&err, dfa, &merged_set);
1788 re_node_set_free (&merged_set); 1700 re_node_set_free (&merged_set);
1789 if (BE (err != REG_NOERROR, 0)) 1701 if (__glibc_unlikely (err != REG_NOERROR))
1790 return err; 1702 return err;
1791 } 1703 }
1792 } 1704 }
@@ -1794,7 +1706,6 @@ merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst,
1794} 1706}
1795 1707
1796static reg_errcode_t 1708static reg_errcode_t
1797internal_function
1798update_cur_sifted_state (const re_match_context_t *mctx, 1709update_cur_sifted_state (const re_match_context_t *mctx,
1799 re_sift_context_t *sctx, Idx str_idx, 1710 re_sift_context_t *sctx, Idx str_idx,
1800 re_node_set *dest_nodes) 1711 re_node_set *dest_nodes)
@@ -1814,7 +1725,7 @@ update_cur_sifted_state (const re_match_context_t *mctx,
1814 /* At first, add the nodes which can epsilon transit to a node in 1725 /* At first, add the nodes which can epsilon transit to a node in
1815 DEST_NODE. */ 1726 DEST_NODE. */
1816 err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); 1727 err = add_epsilon_src_nodes (dfa, dest_nodes, candidates);
1817 if (BE (err != REG_NOERROR, 0)) 1728 if (__glibc_unlikely (err != REG_NOERROR))
1818 return err; 1729 return err;
1819 1730
1820 /* Then, check the limitations in the current sift_context. */ 1731 /* Then, check the limitations in the current sift_context. */
@@ -1822,27 +1733,27 @@ update_cur_sifted_state (const re_match_context_t *mctx,
1822 { 1733 {
1823 err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, 1734 err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits,
1824 mctx->bkref_ents, str_idx); 1735 mctx->bkref_ents, str_idx);
1825 if (BE (err != REG_NOERROR, 0)) 1736 if (__glibc_unlikely (err != REG_NOERROR))
1826 return err; 1737 return err;
1827 } 1738 }
1828 } 1739 }
1829 1740
1830 sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); 1741 sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes);
1831 if (BE (err != REG_NOERROR, 0)) 1742 if (__glibc_unlikely (err != REG_NOERROR))
1832 return err; 1743 return err;
1833 } 1744 }
1834 1745
1835 if (candidates && mctx->state_log[str_idx]->has_backref) 1746 if (candidates && mctx->state_log[str_idx]->has_backref)
1836 { 1747 {
1837 err = sift_states_bkref (mctx, sctx, str_idx, candidates); 1748 err = sift_states_bkref (mctx, sctx, str_idx, candidates);
1838 if (BE (err != REG_NOERROR, 0)) 1749 if (__glibc_unlikely (err != REG_NOERROR))
1839 return err; 1750 return err;
1840 } 1751 }
1841 return REG_NOERROR; 1752 return REG_NOERROR;
1842} 1753}
1843 1754
1844static reg_errcode_t 1755static reg_errcode_t
1845internal_function __attribute_warn_unused_result__ 1756__attribute_warn_unused_result__
1846add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, 1757add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1847 const re_node_set *candidates) 1758 const re_node_set *candidates)
1848{ 1759{
@@ -1850,19 +1761,19 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1850 Idx i; 1761 Idx i;
1851 1762
1852 re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); 1763 re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes);
1853 if (BE (err != REG_NOERROR, 0)) 1764 if (__glibc_unlikely (err != REG_NOERROR))
1854 return err; 1765 return err;
1855 1766
1856 if (!state->inveclosure.alloc) 1767 if (!state->inveclosure.alloc)
1857 { 1768 {
1858 err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); 1769 err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem);
1859 if (BE (err != REG_NOERROR, 0)) 1770 if (__glibc_unlikely (err != REG_NOERROR))
1860 return REG_ESPACE; 1771 return REG_ESPACE;
1861 for (i = 0; i < dest_nodes->nelem; i++) 1772 for (i = 0; i < dest_nodes->nelem; i++)
1862 { 1773 {
1863 err = re_node_set_merge (&state->inveclosure, 1774 err = re_node_set_merge (&state->inveclosure,
1864 dfa->inveclosures + dest_nodes->elems[i]); 1775 dfa->inveclosures + dest_nodes->elems[i]);
1865 if (BE (err != REG_NOERROR, 0)) 1776 if (__glibc_unlikely (err != REG_NOERROR))
1866 return REG_ESPACE; 1777 return REG_ESPACE;
1867 } 1778 }
1868 } 1779 }
@@ -1871,7 +1782,6 @@ add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes,
1871} 1782}
1872 1783
1873static reg_errcode_t 1784static reg_errcode_t
1874internal_function
1875sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes, 1785sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1876 const re_node_set *candidates) 1786 const re_node_set *candidates)
1877{ 1787{
@@ -1889,16 +1799,16 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1889 { 1799 {
1890 Idx edst1 = dfa->edests[cur_node].elems[0]; 1800 Idx edst1 = dfa->edests[cur_node].elems[0];
1891 Idx edst2 = ((dfa->edests[cur_node].nelem > 1) 1801 Idx edst2 = ((dfa->edests[cur_node].nelem > 1)
1892 ? dfa->edests[cur_node].elems[1] : REG_MISSING); 1802 ? dfa->edests[cur_node].elems[1] : -1);
1893 if ((!re_node_set_contains (inv_eclosure, edst1) 1803 if ((!re_node_set_contains (inv_eclosure, edst1)
1894 && re_node_set_contains (dest_nodes, edst1)) 1804 && re_node_set_contains (dest_nodes, edst1))
1895 || (REG_VALID_NONZERO_INDEX (edst2) 1805 || (edst2 > 0
1896 && !re_node_set_contains (inv_eclosure, edst2) 1806 && !re_node_set_contains (inv_eclosure, edst2)
1897 && re_node_set_contains (dest_nodes, edst2))) 1807 && re_node_set_contains (dest_nodes, edst2)))
1898 { 1808 {
1899 err = re_node_set_add_intersect (&except_nodes, candidates, 1809 err = re_node_set_add_intersect (&except_nodes, candidates,
1900 dfa->inveclosures + cur_node); 1810 dfa->inveclosures + cur_node);
1901 if (BE (err != REG_NOERROR, 0)) 1811 if (__glibc_unlikely (err != REG_NOERROR))
1902 { 1812 {
1903 re_node_set_free (&except_nodes); 1813 re_node_set_free (&except_nodes);
1904 return err; 1814 return err;
@@ -1920,7 +1830,6 @@ sub_epsilon_src_nodes (const re_dfa_t *dfa, Idx node, re_node_set *dest_nodes,
1920} 1830}
1921 1831
1922static bool 1832static bool
1923internal_function
1924check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits, 1833check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
1925 Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx) 1834 Idx dst_node, Idx dst_idx, Idx src_node, Idx src_idx)
1926{ 1835{
@@ -1956,7 +1865,6 @@ check_dst_limits (const re_match_context_t *mctx, const re_node_set *limits,
1956} 1865}
1957 1866
1958static int 1867static int
1959internal_function
1960check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, 1868check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
1961 Idx subexp_idx, Idx from_node, Idx bkref_idx) 1869 Idx subexp_idx, Idx from_node, Idx bkref_idx)
1962{ 1870{
@@ -1972,7 +1880,7 @@ check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
1972 switch (dfa->nodes[node].type) 1880 switch (dfa->nodes[node].type)
1973 { 1881 {
1974 case OP_BACK_REF: 1882 case OP_BACK_REF:
1975 if (bkref_idx != REG_MISSING) 1883 if (bkref_idx != -1)
1976 { 1884 {
1977 struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; 1885 struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx;
1978 do 1886 do
@@ -2038,7 +1946,6 @@ check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries,
2038} 1946}
2039 1947
2040static int 1948static int
2041internal_function
2042check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit, 1949check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
2043 Idx subexp_idx, Idx from_node, Idx str_idx, 1950 Idx subexp_idx, Idx from_node, Idx str_idx,
2044 Idx bkref_idx) 1951 Idx bkref_idx)
@@ -2068,7 +1975,6 @@ check_dst_limits_calc_pos (const re_match_context_t *mctx, Idx limit,
2068 which are against limitations from DEST_NODES. */ 1975 which are against limitations from DEST_NODES. */
2069 1976
2070static reg_errcode_t 1977static reg_errcode_t
2071internal_function
2072check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, 1978check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2073 const re_node_set *candidates, re_node_set *limits, 1979 const re_node_set *candidates, re_node_set *limits,
2074 struct re_backref_cache_entry *bkref_ents, Idx str_idx) 1980 struct re_backref_cache_entry *bkref_ents, Idx str_idx)
@@ -2088,8 +1994,8 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2088 subexp_idx = dfa->nodes[ent->node].opr.idx; 1994 subexp_idx = dfa->nodes[ent->node].opr.idx;
2089 if (ent->subexp_to == str_idx) 1995 if (ent->subexp_to == str_idx)
2090 { 1996 {
2091 Idx ops_node = REG_MISSING; 1997 Idx ops_node = -1;
2092 Idx cls_node = REG_MISSING; 1998 Idx cls_node = -1;
2093 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) 1999 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
2094 { 2000 {
2095 Idx node = dest_nodes->elems[node_idx]; 2001 Idx node = dest_nodes->elems[node_idx];
@@ -2104,16 +2010,16 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2104 2010
2105 /* Check the limitation of the open subexpression. */ 2011 /* Check the limitation of the open subexpression. */
2106 /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ 2012 /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */
2107 if (REG_VALID_INDEX (ops_node)) 2013 if (ops_node >= 0)
2108 { 2014 {
2109 err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, 2015 err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes,
2110 candidates); 2016 candidates);
2111 if (BE (err != REG_NOERROR, 0)) 2017 if (__glibc_unlikely (err != REG_NOERROR))
2112 return err; 2018 return err;
2113 } 2019 }
2114 2020
2115 /* Check the limitation of the close subexpression. */ 2021 /* Check the limitation of the close subexpression. */
2116 if (REG_VALID_INDEX (cls_node)) 2022 if (cls_node >= 0)
2117 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) 2023 for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx)
2118 { 2024 {
2119 Idx node = dest_nodes->elems[node_idx]; 2025 Idx node = dest_nodes->elems[node_idx];
@@ -2126,7 +2032,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2126 Remove it form the current sifted state. */ 2032 Remove it form the current sifted state. */
2127 err = sub_epsilon_src_nodes (dfa, node, dest_nodes, 2033 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
2128 candidates); 2034 candidates);
2129 if (BE (err != REG_NOERROR, 0)) 2035 if (__glibc_unlikely (err != REG_NOERROR))
2130 return err; 2036 return err;
2131 --node_idx; 2037 --node_idx;
2132 } 2038 }
@@ -2146,7 +2052,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2146 Remove it form the current sifted state. */ 2052 Remove it form the current sifted state. */
2147 err = sub_epsilon_src_nodes (dfa, node, dest_nodes, 2053 err = sub_epsilon_src_nodes (dfa, node, dest_nodes,
2148 candidates); 2054 candidates);
2149 if (BE (err != REG_NOERROR, 0)) 2055 if (__glibc_unlikely (err != REG_NOERROR))
2150 return err; 2056 return err;
2151 } 2057 }
2152 } 2058 }
@@ -2156,7 +2062,7 @@ check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes,
2156} 2062}
2157 2063
2158static reg_errcode_t 2064static reg_errcode_t
2159internal_function __attribute_warn_unused_result__ 2065__attribute_warn_unused_result__
2160sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, 2066sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2161 Idx str_idx, const re_node_set *candidates) 2067 Idx str_idx, const re_node_set *candidates)
2162{ 2068{
@@ -2166,7 +2072,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2166 re_sift_context_t local_sctx; 2072 re_sift_context_t local_sctx;
2167 Idx first_idx = search_cur_bkref_entry (mctx, str_idx); 2073 Idx first_idx = search_cur_bkref_entry (mctx, str_idx);
2168 2074
2169 if (first_idx == REG_MISSING) 2075 if (first_idx == -1)
2170 return REG_NOERROR; 2076 return REG_NOERROR;
2171 2077
2172 local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ 2078 local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */
@@ -2212,27 +2118,27 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2212 { 2118 {
2213 local_sctx = *sctx; 2119 local_sctx = *sctx;
2214 err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); 2120 err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits);
2215 if (BE (err != REG_NOERROR, 0)) 2121 if (__glibc_unlikely (err != REG_NOERROR))
2216 goto free_return; 2122 goto free_return;
2217 } 2123 }
2218 local_sctx.last_node = node; 2124 local_sctx.last_node = node;
2219 local_sctx.last_str_idx = str_idx; 2125 local_sctx.last_str_idx = str_idx;
2220 ok = re_node_set_insert (&local_sctx.limits, enabled_idx); 2126 ok = re_node_set_insert (&local_sctx.limits, enabled_idx);
2221 if (BE (! ok, 0)) 2127 if (__glibc_unlikely (! ok))
2222 { 2128 {
2223 err = REG_ESPACE; 2129 err = REG_ESPACE;
2224 goto free_return; 2130 goto free_return;
2225 } 2131 }
2226 cur_state = local_sctx.sifted_states[str_idx]; 2132 cur_state = local_sctx.sifted_states[str_idx];
2227 err = sift_states_backward (mctx, &local_sctx); 2133 err = sift_states_backward (mctx, &local_sctx);
2228 if (BE (err != REG_NOERROR, 0)) 2134 if (__glibc_unlikely (err != REG_NOERROR))
2229 goto free_return; 2135 goto free_return;
2230 if (sctx->limited_states != NULL) 2136 if (sctx->limited_states != NULL)
2231 { 2137 {
2232 err = merge_state_array (dfa, sctx->limited_states, 2138 err = merge_state_array (dfa, sctx->limited_states,
2233 local_sctx.sifted_states, 2139 local_sctx.sifted_states,
2234 str_idx + 1); 2140 str_idx + 1);
2235 if (BE (err != REG_NOERROR, 0)) 2141 if (__glibc_unlikely (err != REG_NOERROR))
2236 goto free_return; 2142 goto free_return;
2237 } 2143 }
2238 local_sctx.sifted_states[str_idx] = cur_state; 2144 local_sctx.sifted_states[str_idx] = cur_state;
@@ -2254,9 +2160,7 @@ sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx,
2254} 2160}
2255 2161
2256 2162
2257#ifdef RE_ENABLE_I18N
2258static int 2163static int
2259internal_function
2260sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, 2164sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2261 Idx node_idx, Idx str_idx, Idx max_str_idx) 2165 Idx node_idx, Idx str_idx, Idx max_str_idx)
2262{ 2166{
@@ -2264,44 +2168,41 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2264 int naccepted; 2168 int naccepted;
2265 /* Check the node can accept "multi byte". */ 2169 /* Check the node can accept "multi byte". */
2266 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); 2170 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
2267 if (naccepted > 0 && str_idx + naccepted <= max_str_idx && 2171 if (naccepted > 0 && str_idx + naccepted <= max_str_idx
2268 !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], 2172 && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
2269 dfa->nexts[node_idx])) 2173 dfa->nexts[node_idx]))
2270 /* The node can't accept the "multi byte", or the 2174 /* The node can't accept the "multi byte", or the
2271 destination was already thrown away, then the node 2175 destination was already thrown away, then the node
2272 could't accept the current input "multi byte". */ 2176 couldn't accept the current input "multi byte". */
2273 naccepted = 0; 2177 naccepted = 0;
2274 /* Otherwise, it is sure that the node could accept 2178 /* Otherwise, it is sure that the node could accept
2275 'naccepted' bytes input. */ 2179 'naccepted' bytes input. */
2276 return naccepted; 2180 return naccepted;
2277} 2181}
2278#endif /* RE_ENABLE_I18N */
2279
2280 2182
2281/* Functions for state transition. */ 2183/* Functions for state transition. */
2282 2184
2283/* Return the next state to which the current state STATE will transit by 2185/* Return the next state to which the current state STATE will transit by
2284 accepting the current input byte, and update STATE_LOG if necessary. 2186 accepting the current input byte, and update STATE_LOG if necessary.
2187 Return NULL on failure.
2285 If STATE can accept a multibyte char/collating element/back reference 2188 If STATE can accept a multibyte char/collating element/back reference
2286 update the destination of STATE_LOG. */ 2189 update the destination of STATE_LOG. */
2287 2190
2288static re_dfastate_t * 2191static re_dfastate_t *
2289internal_function __attribute_warn_unused_result__ 2192__attribute_warn_unused_result__
2290transit_state (reg_errcode_t *err, re_match_context_t *mctx, 2193transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2291 re_dfastate_t *state) 2194 re_dfastate_t *state)
2292{ 2195{
2293 re_dfastate_t **trtable; 2196 re_dfastate_t **trtable;
2294 unsigned char ch; 2197 unsigned char ch;
2295 2198
2296#ifdef RE_ENABLE_I18N
2297 /* If the current state can accept multibyte. */ 2199 /* If the current state can accept multibyte. */
2298 if (BE (state->accept_mb, 0)) 2200 if (__glibc_unlikely (state->accept_mb))
2299 { 2201 {
2300 *err = transit_state_mb (mctx, state); 2202 *err = transit_state_mb (mctx, state);
2301 if (BE (*err != REG_NOERROR, 0)) 2203 if (__glibc_unlikely (*err != REG_NOERROR))
2302 return NULL; 2204 return NULL;
2303 } 2205 }
2304#endif /* RE_ENABLE_I18N */
2305 2206
2306 /* Then decide the next state with the single byte. */ 2207 /* Then decide the next state with the single byte. */
2307#if 0 2208#if 0
@@ -2315,11 +2216,11 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2315 for (;;) 2216 for (;;)
2316 { 2217 {
2317 trtable = state->trtable; 2218 trtable = state->trtable;
2318 if (BE (trtable != NULL, 1)) 2219 if (__glibc_likely (trtable != NULL))
2319 return trtable[ch]; 2220 return trtable[ch];
2320 2221
2321 trtable = state->word_trtable; 2222 trtable = state->word_trtable;
2322 if (BE (trtable != NULL, 1)) 2223 if (__glibc_likely (trtable != NULL))
2323 { 2224 {
2324 unsigned int context; 2225 unsigned int context;
2325 context 2226 context
@@ -2344,7 +2245,6 @@ transit_state (reg_errcode_t *err, re_match_context_t *mctx,
2344 2245
2345/* Update the state_log if we need */ 2246/* Update the state_log if we need */
2346static re_dfastate_t * 2247static re_dfastate_t *
2347internal_function
2348merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, 2248merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2349 re_dfastate_t *next_state) 2249 re_dfastate_t *next_state)
2350{ 2250{
@@ -2376,7 +2276,7 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2376 table_nodes = next_state->entrance_nodes; 2276 table_nodes = next_state->entrance_nodes;
2377 *err = re_node_set_init_union (&next_nodes, table_nodes, 2277 *err = re_node_set_init_union (&next_nodes, table_nodes,
2378 log_nodes); 2278 log_nodes);
2379 if (BE (*err != REG_NOERROR, 0)) 2279 if (__glibc_unlikely (*err != REG_NOERROR))
2380 return NULL; 2280 return NULL;
2381 } 2281 }
2382 else 2282 else
@@ -2396,21 +2296,21 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2396 re_node_set_free (&next_nodes); 2296 re_node_set_free (&next_nodes);
2397 } 2297 }
2398 2298
2399 if (BE (dfa->nbackref, 0) && next_state != NULL) 2299 if (__glibc_unlikely (dfa->nbackref) && next_state != NULL)
2400 { 2300 {
2401 /* Check OP_OPEN_SUBEXP in the current state in case that we use them 2301 /* Check OP_OPEN_SUBEXP in the current state in case that we use them
2402 later. We must check them here, since the back references in the 2302 later. We must check them here, since the back references in the
2403 next state might use them. */ 2303 next state might use them. */
2404 *err = check_subexp_matching_top (mctx, &next_state->nodes, 2304 *err = check_subexp_matching_top (mctx, &next_state->nodes,
2405 cur_idx); 2305 cur_idx);
2406 if (BE (*err != REG_NOERROR, 0)) 2306 if (__glibc_unlikely (*err != REG_NOERROR))
2407 return NULL; 2307 return NULL;
2408 2308
2409 /* If the next state has back references. */ 2309 /* If the next state has back references. */
2410 if (next_state->has_backref) 2310 if (next_state->has_backref)
2411 { 2311 {
2412 *err = transit_state_bkref (mctx, &next_state->nodes); 2312 *err = transit_state_bkref (mctx, &next_state->nodes);
2413 if (BE (*err != REG_NOERROR, 0)) 2313 if (__glibc_unlikely (*err != REG_NOERROR))
2414 return NULL; 2314 return NULL;
2415 next_state = mctx->state_log[cur_idx]; 2315 next_state = mctx->state_log[cur_idx];
2416 } 2316 }
@@ -2423,7 +2323,6 @@ merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
2423 multi-byte match, then look in the log for a state 2323 multi-byte match, then look in the log for a state
2424 from which to restart matching. */ 2324 from which to restart matching. */
2425static re_dfastate_t * 2325static re_dfastate_t *
2426internal_function
2427find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) 2326find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
2428{ 2327{
2429 re_dfastate_t *cur_state; 2328 re_dfastate_t *cur_state;
@@ -2454,7 +2353,6 @@ find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
2454 corresponding back references. */ 2353 corresponding back references. */
2455 2354
2456static reg_errcode_t 2355static reg_errcode_t
2457internal_function
2458check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, 2356check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2459 Idx str_idx) 2357 Idx str_idx)
2460{ 2358{
@@ -2476,7 +2374,7 @@ check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2476 & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) 2374 & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx)))
2477 { 2375 {
2478 err = match_ctx_add_subtop (mctx, node, str_idx); 2376 err = match_ctx_add_subtop (mctx, node, str_idx);
2479 if (BE (err != REG_NOERROR, 0)) 2377 if (__glibc_unlikely (err != REG_NOERROR))
2480 return err; 2378 return err;
2481 } 2379 }
2482 } 2380 }
@@ -2485,7 +2383,7 @@ check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes,
2485 2383
2486#if 0 2384#if 0
2487/* Return the next state to which the current state STATE will transit by 2385/* Return the next state to which the current state STATE will transit by
2488 accepting the current input byte. */ 2386 accepting the current input byte. Return NULL on failure. */
2489 2387
2490static re_dfastate_t * 2388static re_dfastate_t *
2491transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, 2389transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
@@ -2498,7 +2396,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2498 unsigned int context; 2396 unsigned int context;
2499 2397
2500 *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); 2398 *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1);
2501 if (BE (*err != REG_NOERROR, 0)) 2399 if (__glibc_unlikely (*err != REG_NOERROR))
2502 return NULL; 2400 return NULL;
2503 for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) 2401 for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt)
2504 { 2402 {
@@ -2507,7 +2405,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2507 { 2405 {
2508 *err = re_node_set_merge (&next_nodes, 2406 *err = re_node_set_merge (&next_nodes,
2509 dfa->eclosures + dfa->nexts[cur_node]); 2407 dfa->eclosures + dfa->nexts[cur_node]);
2510 if (BE (*err != REG_NOERROR, 0)) 2408 if (__glibc_unlikely (*err != REG_NOERROR))
2511 { 2409 {
2512 re_node_set_free (&next_nodes); 2410 re_node_set_free (&next_nodes);
2513 return NULL; 2411 return NULL;
@@ -2525,9 +2423,7 @@ transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx,
2525} 2423}
2526#endif 2424#endif
2527 2425
2528#ifdef RE_ENABLE_I18N
2529static reg_errcode_t 2426static reg_errcode_t
2530internal_function
2531transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) 2427transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2532{ 2428{
2533 const re_dfa_t *const dfa = mctx->dfa; 2429 const re_dfa_t *const dfa = mctx->dfa;
@@ -2567,11 +2463,9 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2567 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted 2463 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
2568 : mctx->max_mb_elem_len); 2464 : mctx->max_mb_elem_len);
2569 err = clean_state_log_if_needed (mctx, dest_idx); 2465 err = clean_state_log_if_needed (mctx, dest_idx);
2570 if (BE (err != REG_NOERROR, 0)) 2466 if (__glibc_unlikely (err != REG_NOERROR))
2571 return err; 2467 return err;
2572#ifdef DEBUG 2468 DEBUG_ASSERT (dfa->nexts[cur_node_idx] != -1);
2573 assert (dfa->nexts[cur_node_idx] != REG_MISSING);
2574#endif
2575 new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; 2469 new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx];
2576 2470
2577 dest_state = mctx->state_log[dest_idx]; 2471 dest_state = mctx->state_log[dest_idx];
@@ -2581,7 +2475,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2581 { 2475 {
2582 err = re_node_set_init_union (&dest_nodes, 2476 err = re_node_set_init_union (&dest_nodes,
2583 dest_state->entrance_nodes, new_nodes); 2477 dest_state->entrance_nodes, new_nodes);
2584 if (BE (err != REG_NOERROR, 0)) 2478 if (__glibc_unlikely (err != REG_NOERROR))
2585 return err; 2479 return err;
2586 } 2480 }
2587 context = re_string_context_at (&mctx->input, dest_idx - 1, 2481 context = re_string_context_at (&mctx->input, dest_idx - 1,
@@ -2590,15 +2484,14 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2590 = re_acquire_state_context (&err, dfa, &dest_nodes, context); 2484 = re_acquire_state_context (&err, dfa, &dest_nodes, context);
2591 if (dest_state != NULL) 2485 if (dest_state != NULL)
2592 re_node_set_free (&dest_nodes); 2486 re_node_set_free (&dest_nodes);
2593 if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) 2487 if (__glibc_unlikely (mctx->state_log[dest_idx] == NULL
2488 && err != REG_NOERROR))
2594 return err; 2489 return err;
2595 } 2490 }
2596 return REG_NOERROR; 2491 return REG_NOERROR;
2597} 2492}
2598#endif /* RE_ENABLE_I18N */
2599 2493
2600static reg_errcode_t 2494static reg_errcode_t
2601internal_function
2602transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) 2495transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2603{ 2496{
2604 const re_dfa_t *const dfa = mctx->dfa; 2497 const re_dfa_t *const dfa = mctx->dfa;
@@ -2630,14 +2523,12 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2630 Check the substring which the substring matched. */ 2523 Check the substring which the substring matched. */
2631 bkc_idx = mctx->nbkref_ents; 2524 bkc_idx = mctx->nbkref_ents;
2632 err = get_subexp (mctx, node_idx, cur_str_idx); 2525 err = get_subexp (mctx, node_idx, cur_str_idx);
2633 if (BE (err != REG_NOERROR, 0)) 2526 if (__glibc_unlikely (err != REG_NOERROR))
2634 goto free_return; 2527 goto free_return;
2635 2528
2636 /* And add the epsilon closures (which is 'new_dest_nodes') of 2529 /* And add the epsilon closures (which is 'new_dest_nodes') of
2637 the backreference to appropriate state_log. */ 2530 the backreference to appropriate state_log. */
2638#ifdef DEBUG 2531 DEBUG_ASSERT (dfa->nexts[node_idx] != -1);
2639 assert (dfa->nexts[node_idx] != REG_MISSING);
2640#endif
2641 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) 2532 for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx)
2642 { 2533 {
2643 Idx subexp_len; 2534 Idx subexp_len;
@@ -2663,8 +2554,8 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2663 mctx->state_log[dest_str_idx] 2554 mctx->state_log[dest_str_idx]
2664 = re_acquire_state_context (&err, dfa, new_dest_nodes, 2555 = re_acquire_state_context (&err, dfa, new_dest_nodes,
2665 context); 2556 context);
2666 if (BE (mctx->state_log[dest_str_idx] == NULL 2557 if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
2667 && err != REG_NOERROR, 0)) 2558 && err != REG_NOERROR))
2668 goto free_return; 2559 goto free_return;
2669 } 2560 }
2670 else 2561 else
@@ -2673,7 +2564,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2673 err = re_node_set_init_union (&dest_nodes, 2564 err = re_node_set_init_union (&dest_nodes,
2674 dest_state->entrance_nodes, 2565 dest_state->entrance_nodes,
2675 new_dest_nodes); 2566 new_dest_nodes);
2676 if (BE (err != REG_NOERROR, 0)) 2567 if (__glibc_unlikely (err != REG_NOERROR))
2677 { 2568 {
2678 re_node_set_free (&dest_nodes); 2569 re_node_set_free (&dest_nodes);
2679 goto free_return; 2570 goto free_return;
@@ -2681,8 +2572,8 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2681 mctx->state_log[dest_str_idx] 2572 mctx->state_log[dest_str_idx]
2682 = re_acquire_state_context (&err, dfa, &dest_nodes, context); 2573 = re_acquire_state_context (&err, dfa, &dest_nodes, context);
2683 re_node_set_free (&dest_nodes); 2574 re_node_set_free (&dest_nodes);
2684 if (BE (mctx->state_log[dest_str_idx] == NULL 2575 if (__glibc_unlikely (mctx->state_log[dest_str_idx] == NULL
2685 && err != REG_NOERROR, 0)) 2576 && err != REG_NOERROR))
2686 goto free_return; 2577 goto free_return;
2687 } 2578 }
2688 /* We need to check recursively if the backreference can epsilon 2579 /* We need to check recursively if the backreference can epsilon
@@ -2692,10 +2583,10 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2692 { 2583 {
2693 err = check_subexp_matching_top (mctx, new_dest_nodes, 2584 err = check_subexp_matching_top (mctx, new_dest_nodes,
2694 cur_str_idx); 2585 cur_str_idx);
2695 if (BE (err != REG_NOERROR, 0)) 2586 if (__glibc_unlikely (err != REG_NOERROR))
2696 goto free_return; 2587 goto free_return;
2697 err = transit_state_bkref (mctx, new_dest_nodes); 2588 err = transit_state_bkref (mctx, new_dest_nodes);
2698 if (BE (err != REG_NOERROR, 0)) 2589 if (__glibc_unlikely (err != REG_NOERROR))
2699 goto free_return; 2590 goto free_return;
2700 } 2591 }
2701 } 2592 }
@@ -2712,7 +2603,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2712 delay these checking for prune_impossible_nodes(). */ 2603 delay these checking for prune_impossible_nodes(). */
2713 2604
2714static reg_errcode_t 2605static reg_errcode_t
2715internal_function __attribute_warn_unused_result__ 2606__attribute_warn_unused_result__
2716get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx) 2607get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2717{ 2608{
2718 const re_dfa_t *const dfa = mctx->dfa; 2609 const re_dfa_t *const dfa = mctx->dfa;
@@ -2720,7 +2611,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2720 const char *buf = (const char *) re_string_get_buffer (&mctx->input); 2611 const char *buf = (const char *) re_string_get_buffer (&mctx->input);
2721 /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ 2612 /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */
2722 Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); 2613 Idx cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx);
2723 if (cache_idx != REG_MISSING) 2614 if (cache_idx != -1)
2724 { 2615 {
2725 const struct re_backref_cache_entry *entry 2616 const struct re_backref_cache_entry *entry
2726 = mctx->bkref_ents + cache_idx; 2617 = mctx->bkref_ents + cache_idx;
@@ -2756,7 +2647,8 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2756 at the back reference? */ 2647 at the back reference? */
2757 if (sl_str_diff > 0) 2648 if (sl_str_diff > 0)
2758 { 2649 {
2759 if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) 2650 if (__glibc_unlikely (bkref_str_off + sl_str_diff
2651 > mctx->input.valid_len))
2760 { 2652 {
2761 /* Not enough chars for a successful match. */ 2653 /* Not enough chars for a successful match. */
2762 if (bkref_str_off + sl_str_diff > mctx->input.len) 2654 if (bkref_str_off + sl_str_diff > mctx->input.len)
@@ -2765,7 +2657,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2765 err = clean_state_log_if_needed (mctx, 2657 err = clean_state_log_if_needed (mctx,
2766 bkref_str_off 2658 bkref_str_off
2767 + sl_str_diff); 2659 + sl_str_diff);
2768 if (BE (err != REG_NOERROR, 0)) 2660 if (__glibc_unlikely (err != REG_NOERROR))
2769 return err; 2661 return err;
2770 buf = (const char *) re_string_get_buffer (&mctx->input); 2662 buf = (const char *) re_string_get_buffer (&mctx->input);
2771 } 2663 }
@@ -2784,7 +2676,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2784 2676
2785 if (err == REG_NOMATCH) 2677 if (err == REG_NOMATCH)
2786 continue; 2678 continue;
2787 if (BE (err != REG_NOERROR, 0)) 2679 if (__glibc_unlikely (err != REG_NOERROR))
2788 return err; 2680 return err;
2789 } 2681 }
2790 2682
@@ -2803,14 +2695,14 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2803 at the back reference? */ 2695 at the back reference? */
2804 if (sl_str_off > 0) 2696 if (sl_str_off > 0)
2805 { 2697 {
2806 if (BE (bkref_str_off >= mctx->input.valid_len, 0)) 2698 if (__glibc_unlikely (bkref_str_off >= mctx->input.valid_len))
2807 { 2699 {
2808 /* If we are at the end of the input, we cannot match. */ 2700 /* If we are at the end of the input, we cannot match. */
2809 if (bkref_str_off >= mctx->input.len) 2701 if (bkref_str_off >= mctx->input.len)
2810 break; 2702 break;
2811 2703
2812 err = extend_buffers (mctx, bkref_str_off + 1); 2704 err = extend_buffers (mctx, bkref_str_off + 1);
2813 if (BE (err != REG_NOERROR, 0)) 2705 if (__glibc_unlikely (err != REG_NOERROR))
2814 return err; 2706 return err;
2815 2707
2816 buf = (const char *) re_string_get_buffer (&mctx->input); 2708 buf = (const char *) re_string_get_buffer (&mctx->input);
@@ -2825,7 +2717,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2825 nodes = &mctx->state_log[sl_str]->nodes; 2717 nodes = &mctx->state_log[sl_str]->nodes;
2826 cls_node = find_subexp_node (dfa, nodes, subexp_num, 2718 cls_node = find_subexp_node (dfa, nodes, subexp_num,
2827 OP_CLOSE_SUBEXP); 2719 OP_CLOSE_SUBEXP);
2828 if (cls_node == REG_MISSING) 2720 if (cls_node == -1)
2829 continue; /* No. */ 2721 continue; /* No. */
2830 if (sub_top->path == NULL) 2722 if (sub_top->path == NULL)
2831 { 2723 {
@@ -2841,15 +2733,18 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2841 OP_CLOSE_SUBEXP); 2733 OP_CLOSE_SUBEXP);
2842 if (err == REG_NOMATCH) 2734 if (err == REG_NOMATCH)
2843 continue; 2735 continue;
2844 if (BE (err != REG_NOERROR, 0)) 2736 if (__glibc_unlikely (err != REG_NOERROR))
2845 return err; 2737 return err;
2846 sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); 2738 sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str);
2847 if (BE (sub_last == NULL, 0)) 2739 if (__glibc_unlikely (sub_last == NULL))
2848 return REG_ESPACE; 2740 return REG_ESPACE;
2849 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, 2741 err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
2850 bkref_str_idx); 2742 bkref_str_idx);
2743 buf = (const char *) re_string_get_buffer (&mctx->input);
2851 if (err == REG_NOMATCH) 2744 if (err == REG_NOMATCH)
2852 continue; 2745 continue;
2746 if (__glibc_unlikely (err != REG_NOERROR))
2747 return err;
2853 } 2748 }
2854 } 2749 }
2855 return REG_NOERROR; 2750 return REG_NOERROR;
@@ -2862,7 +2757,6 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2862 and SUB_LAST. */ 2757 and SUB_LAST. */
2863 2758
2864static reg_errcode_t 2759static reg_errcode_t
2865internal_function
2866get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, 2760get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2867 re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str) 2761 re_sub_match_last_t *sub_last, Idx bkref_node, Idx bkref_str)
2868{ 2762{
@@ -2876,7 +2770,7 @@ get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2876 return err; 2770 return err;
2877 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, 2771 err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx,
2878 sub_last->str_idx); 2772 sub_last->str_idx);
2879 if (BE (err != REG_NOERROR, 0)) 2773 if (__glibc_unlikely (err != REG_NOERROR))
2880 return err; 2774 return err;
2881 to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; 2775 to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx;
2882 return clean_state_log_if_needed (mctx, to_idx); 2776 return clean_state_log_if_needed (mctx, to_idx);
@@ -2891,7 +2785,6 @@ get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top,
2891 E.g. RE: (a){2} */ 2785 E.g. RE: (a){2} */
2892 2786
2893static Idx 2787static Idx
2894internal_function
2895find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, 2788find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
2896 Idx subexp_idx, int type) 2789 Idx subexp_idx, int type)
2897{ 2790{
@@ -2904,16 +2797,17 @@ find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes,
2904 && node->opr.idx == subexp_idx) 2797 && node->opr.idx == subexp_idx)
2905 return cls_node; 2798 return cls_node;
2906 } 2799 }
2907 return REG_MISSING; 2800 return -1;
2908} 2801}
2909 2802
2910/* Check whether the node TOP_NODE at TOP_STR can arrive to the node 2803/* Check whether the node TOP_NODE at TOP_STR can arrive to the node
2911 LAST_NODE at LAST_STR. We record the path onto PATH since it will be 2804 LAST_NODE at LAST_STR. We record the path onto PATH since it will be
2912 heavily reused. 2805 heavily reused.
2913 Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ 2806 Return REG_NOERROR if it can arrive, REG_NOMATCH if it cannot,
2807 REG_ESPACE if memory is exhausted. */
2914 2808
2915static reg_errcode_t 2809static reg_errcode_t
2916internal_function __attribute_warn_unused_result__ 2810__attribute_warn_unused_result__
2917check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node, 2811check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2918 Idx top_str, Idx last_node, Idx last_str, int type) 2812 Idx top_str, Idx last_node, Idx last_str, int type)
2919{ 2813{
@@ -2927,19 +2821,19 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2927 2821
2928 subexp_num = dfa->nodes[top_node].opr.idx; 2822 subexp_num = dfa->nodes[top_node].opr.idx;
2929 /* Extend the buffer if we need. */ 2823 /* Extend the buffer if we need. */
2930 if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) 2824 if (__glibc_unlikely (path->alloc < last_str + mctx->max_mb_elem_len + 1))
2931 { 2825 {
2932 re_dfastate_t **new_array; 2826 re_dfastate_t **new_array;
2933 Idx old_alloc = path->alloc; 2827 Idx old_alloc = path->alloc;
2934 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1; 2828 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
2935 Idx new_alloc; 2829 Idx new_alloc;
2936 if (BE (IDX_MAX - old_alloc < incr_alloc, 0)) 2830 if (__glibc_unlikely (IDX_MAX - old_alloc < incr_alloc))
2937 return REG_ESPACE; 2831 return REG_ESPACE;
2938 new_alloc = old_alloc + incr_alloc; 2832 new_alloc = old_alloc + incr_alloc;
2939 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0)) 2833 if (__glibc_unlikely (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc))
2940 return REG_ESPACE; 2834 return REG_ESPACE;
2941 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); 2835 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
2942 if (BE (new_array == NULL, 0)) 2836 if (__glibc_unlikely (new_array == NULL))
2943 return REG_ESPACE; 2837 return REG_ESPACE;
2944 path->array = new_array; 2838 path->array = new_array;
2945 path->alloc = new_alloc; 2839 path->alloc = new_alloc;
@@ -2960,10 +2854,10 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2960 if (str_idx == top_str) 2854 if (str_idx == top_str)
2961 { 2855 {
2962 err = re_node_set_init_1 (&next_nodes, top_node); 2856 err = re_node_set_init_1 (&next_nodes, top_node);
2963 if (BE (err != REG_NOERROR, 0)) 2857 if (__glibc_unlikely (err != REG_NOERROR))
2964 return err; 2858 return err;
2965 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); 2859 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
2966 if (BE (err != REG_NOERROR, 0)) 2860 if (__glibc_unlikely (err != REG_NOERROR))
2967 { 2861 {
2968 re_node_set_free (&next_nodes); 2862 re_node_set_free (&next_nodes);
2969 return err; 2863 return err;
@@ -2975,7 +2869,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2975 if (cur_state && cur_state->has_backref) 2869 if (cur_state && cur_state->has_backref)
2976 { 2870 {
2977 err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); 2871 err = re_node_set_init_copy (&next_nodes, &cur_state->nodes);
2978 if (BE (err != REG_NOERROR, 0)) 2872 if (__glibc_unlikely (err != REG_NOERROR))
2979 return err; 2873 return err;
2980 } 2874 }
2981 else 2875 else
@@ -2987,14 +2881,14 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2987 { 2881 {
2988 err = expand_bkref_cache (mctx, &next_nodes, str_idx, 2882 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
2989 subexp_num, type); 2883 subexp_num, type);
2990 if (BE (err != REG_NOERROR, 0)) 2884 if (__glibc_unlikely (err != REG_NOERROR))
2991 { 2885 {
2992 re_node_set_free (&next_nodes); 2886 re_node_set_free (&next_nodes);
2993 return err; 2887 return err;
2994 } 2888 }
2995 } 2889 }
2996 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); 2890 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
2997 if (BE (cur_state == NULL && err != REG_NOERROR, 0)) 2891 if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
2998 { 2892 {
2999 re_node_set_free (&next_nodes); 2893 re_node_set_free (&next_nodes);
3000 return err; 2894 return err;
@@ -3009,7 +2903,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3009 { 2903 {
3010 err = re_node_set_merge (&next_nodes, 2904 err = re_node_set_merge (&next_nodes,
3011 &mctx->state_log[str_idx + 1]->nodes); 2905 &mctx->state_log[str_idx + 1]->nodes);
3012 if (BE (err != REG_NOERROR, 0)) 2906 if (__glibc_unlikely (err != REG_NOERROR))
3013 { 2907 {
3014 re_node_set_free (&next_nodes); 2908 re_node_set_free (&next_nodes);
3015 return err; 2909 return err;
@@ -3020,7 +2914,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3020 err = check_arrival_add_next_nodes (mctx, str_idx, 2914 err = check_arrival_add_next_nodes (mctx, str_idx,
3021 &cur_state->non_eps_nodes, 2915 &cur_state->non_eps_nodes,
3022 &next_nodes); 2916 &next_nodes);
3023 if (BE (err != REG_NOERROR, 0)) 2917 if (__glibc_unlikely (err != REG_NOERROR))
3024 { 2918 {
3025 re_node_set_free (&next_nodes); 2919 re_node_set_free (&next_nodes);
3026 return err; 2920 return err;
@@ -3030,14 +2924,14 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3030 if (next_nodes.nelem) 2924 if (next_nodes.nelem)
3031 { 2925 {
3032 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); 2926 err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type);
3033 if (BE (err != REG_NOERROR, 0)) 2927 if (__glibc_unlikely (err != REG_NOERROR))
3034 { 2928 {
3035 re_node_set_free (&next_nodes); 2929 re_node_set_free (&next_nodes);
3036 return err; 2930 return err;
3037 } 2931 }
3038 err = expand_bkref_cache (mctx, &next_nodes, str_idx, 2932 err = expand_bkref_cache (mctx, &next_nodes, str_idx,
3039 subexp_num, type); 2933 subexp_num, type);
3040 if (BE (err != REG_NOERROR, 0)) 2934 if (__glibc_unlikely (err != REG_NOERROR))
3041 { 2935 {
3042 re_node_set_free (&next_nodes); 2936 re_node_set_free (&next_nodes);
3043 return err; 2937 return err;
@@ -3045,7 +2939,7 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3045 } 2939 }
3046 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); 2940 context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags);
3047 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); 2941 cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context);
3048 if (BE (cur_state == NULL && err != REG_NOERROR, 0)) 2942 if (__glibc_unlikely (cur_state == NULL && err != REG_NOERROR))
3049 { 2943 {
3050 re_node_set_free (&next_nodes); 2944 re_node_set_free (&next_nodes);
3051 return err; 2945 return err;
@@ -3078,27 +2972,22 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
3078 Can't we unify them? */ 2972 Can't we unify them? */
3079 2973
3080static reg_errcode_t 2974static reg_errcode_t
3081internal_function __attribute_warn_unused_result__ 2975__attribute_warn_unused_result__
3082check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx, 2976check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3083 re_node_set *cur_nodes, re_node_set *next_nodes) 2977 re_node_set *cur_nodes, re_node_set *next_nodes)
3084{ 2978{
3085 const re_dfa_t *const dfa = mctx->dfa; 2979 const re_dfa_t *const dfa = mctx->dfa;
3086 bool ok; 2980 bool ok;
3087 Idx cur_idx; 2981 Idx cur_idx;
3088#ifdef RE_ENABLE_I18N
3089 reg_errcode_t err = REG_NOERROR; 2982 reg_errcode_t err = REG_NOERROR;
3090#endif
3091 re_node_set union_set; 2983 re_node_set union_set;
3092 re_node_set_init_empty (&union_set); 2984 re_node_set_init_empty (&union_set);
3093 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) 2985 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
3094 { 2986 {
3095 int naccepted = 0; 2987 int naccepted = 0;
3096 Idx cur_node = cur_nodes->elems[cur_idx]; 2988 Idx cur_node = cur_nodes->elems[cur_idx];
3097#ifdef DEBUG 2989 DEBUG_ASSERT (!IS_EPSILON_NODE (dfa->nodes[cur_node].type));
3098 re_token_type_t type = dfa->nodes[cur_node].type; 2990
3099 assert (!IS_EPSILON_NODE (type));
3100#endif
3101#ifdef RE_ENABLE_I18N
3102 /* If the node may accept "multi byte". */ 2991 /* If the node may accept "multi byte". */
3103 if (dfa->nodes[cur_node].accept_mb) 2992 if (dfa->nodes[cur_node].accept_mb)
3104 { 2993 {
@@ -3114,34 +3003,34 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3114 if (dest_state) 3003 if (dest_state)
3115 { 3004 {
3116 err = re_node_set_merge (&union_set, &dest_state->nodes); 3005 err = re_node_set_merge (&union_set, &dest_state->nodes);
3117 if (BE (err != REG_NOERROR, 0)) 3006 if (__glibc_unlikely (err != REG_NOERROR))
3118 { 3007 {
3119 re_node_set_free (&union_set); 3008 re_node_set_free (&union_set);
3120 return err; 3009 return err;
3121 } 3010 }
3122 } 3011 }
3123 ok = re_node_set_insert (&union_set, next_node); 3012 ok = re_node_set_insert (&union_set, next_node);
3124 if (BE (! ok, 0)) 3013 if (__glibc_unlikely (! ok))
3125 { 3014 {
3126 re_node_set_free (&union_set); 3015 re_node_set_free (&union_set);
3127 return REG_ESPACE; 3016 return REG_ESPACE;
3128 } 3017 }
3129 mctx->state_log[next_idx] = re_acquire_state (&err, dfa, 3018 mctx->state_log[next_idx] = re_acquire_state (&err, dfa,
3130 &union_set); 3019 &union_set);
3131 if (BE (mctx->state_log[next_idx] == NULL 3020 if (__glibc_unlikely (mctx->state_log[next_idx] == NULL
3132 && err != REG_NOERROR, 0)) 3021 && err != REG_NOERROR))
3133 { 3022 {
3134 re_node_set_free (&union_set); 3023 re_node_set_free (&union_set);
3135 return err; 3024 return err;
3136 } 3025 }
3137 } 3026 }
3138 } 3027 }
3139#endif /* RE_ENABLE_I18N */ 3028
3140 if (naccepted 3029 if (naccepted
3141 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) 3030 || check_node_accept (mctx, dfa->nodes + cur_node, str_idx))
3142 { 3031 {
3143 ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); 3032 ok = re_node_set_insert (next_nodes, dfa->nexts[cur_node]);
3144 if (BE (! ok, 0)) 3033 if (__glibc_unlikely (! ok))
3145 { 3034 {
3146 re_node_set_free (&union_set); 3035 re_node_set_free (&union_set);
3147 return REG_ESPACE; 3036 return REG_ESPACE;
@@ -3159,18 +3048,15 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3159*/ 3048*/
3160 3049
3161static reg_errcode_t 3050static reg_errcode_t
3162internal_function
3163check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, 3051check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3164 Idx ex_subexp, int type) 3052 Idx ex_subexp, int type)
3165{ 3053{
3166 reg_errcode_t err; 3054 reg_errcode_t err;
3167 Idx idx, outside_node; 3055 Idx idx, outside_node;
3168 re_node_set new_nodes; 3056 re_node_set new_nodes;
3169#ifdef DEBUG 3057 DEBUG_ASSERT (cur_nodes->nelem);
3170 assert (cur_nodes->nelem);
3171#endif
3172 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); 3058 err = re_node_set_alloc (&new_nodes, cur_nodes->nelem);
3173 if (BE (err != REG_NOERROR, 0)) 3059 if (__glibc_unlikely (err != REG_NOERROR))
3174 return err; 3060 return err;
3175 /* Create a new node set NEW_NODES with the nodes which are epsilon 3061 /* Create a new node set NEW_NODES with the nodes which are epsilon
3176 closures of the node in CUR_NODES. */ 3062 closures of the node in CUR_NODES. */
@@ -3180,11 +3066,11 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3180 Idx cur_node = cur_nodes->elems[idx]; 3066 Idx cur_node = cur_nodes->elems[idx];
3181 const re_node_set *eclosure = dfa->eclosures + cur_node; 3067 const re_node_set *eclosure = dfa->eclosures + cur_node;
3182 outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); 3068 outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type);
3183 if (outside_node == REG_MISSING) 3069 if (outside_node == -1)
3184 { 3070 {
3185 /* There are no problematic nodes, just merge them. */ 3071 /* There are no problematic nodes, just merge them. */
3186 err = re_node_set_merge (&new_nodes, eclosure); 3072 err = re_node_set_merge (&new_nodes, eclosure);
3187 if (BE (err != REG_NOERROR, 0)) 3073 if (__glibc_unlikely (err != REG_NOERROR))
3188 { 3074 {
3189 re_node_set_free (&new_nodes); 3075 re_node_set_free (&new_nodes);
3190 return err; 3076 return err;
@@ -3195,7 +3081,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3195 /* There are problematic nodes, re-calculate incrementally. */ 3081 /* There are problematic nodes, re-calculate incrementally. */
3196 err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, 3082 err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node,
3197 ex_subexp, type); 3083 ex_subexp, type);
3198 if (BE (err != REG_NOERROR, 0)) 3084 if (__glibc_unlikely (err != REG_NOERROR))
3199 { 3085 {
3200 re_node_set_free (&new_nodes); 3086 re_node_set_free (&new_nodes);
3201 return err; 3087 return err;
@@ -3212,7 +3098,7 @@ check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes,
3212 problematic append it to DST_NODES. */ 3098 problematic append it to DST_NODES. */
3213 3099
3214static reg_errcode_t 3100static reg_errcode_t
3215internal_function __attribute_warn_unused_result__ 3101__attribute_warn_unused_result__
3216check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, 3102check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3217 Idx target, Idx ex_subexp, int type) 3103 Idx target, Idx ex_subexp, int type)
3218{ 3104{
@@ -3227,13 +3113,13 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3227 if (type == OP_CLOSE_SUBEXP) 3113 if (type == OP_CLOSE_SUBEXP)
3228 { 3114 {
3229 ok = re_node_set_insert (dst_nodes, cur_node); 3115 ok = re_node_set_insert (dst_nodes, cur_node);
3230 if (BE (! ok, 0)) 3116 if (__glibc_unlikely (! ok))
3231 return REG_ESPACE; 3117 return REG_ESPACE;
3232 } 3118 }
3233 break; 3119 break;
3234 } 3120 }
3235 ok = re_node_set_insert (dst_nodes, cur_node); 3121 ok = re_node_set_insert (dst_nodes, cur_node);
3236 if (BE (! ok, 0)) 3122 if (__glibc_unlikely (! ok))
3237 return REG_ESPACE; 3123 return REG_ESPACE;
3238 if (dfa->edests[cur_node].nelem == 0) 3124 if (dfa->edests[cur_node].nelem == 0)
3239 break; 3125 break;
@@ -3243,7 +3129,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3243 err = check_arrival_expand_ecl_sub (dfa, dst_nodes, 3129 err = check_arrival_expand_ecl_sub (dfa, dst_nodes,
3244 dfa->edests[cur_node].elems[1], 3130 dfa->edests[cur_node].elems[1],
3245 ex_subexp, type); 3131 ex_subexp, type);
3246 if (BE (err != REG_NOERROR, 0)) 3132 if (__glibc_unlikely (err != REG_NOERROR))
3247 return err; 3133 return err;
3248 } 3134 }
3249 cur_node = dfa->edests[cur_node].elems[0]; 3135 cur_node = dfa->edests[cur_node].elems[0];
@@ -3257,7 +3143,7 @@ check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes,
3257 in MCTX->BKREF_ENTS. */ 3143 in MCTX->BKREF_ENTS. */
3258 3144
3259static reg_errcode_t 3145static reg_errcode_t
3260internal_function __attribute_warn_unused_result__ 3146__attribute_warn_unused_result__
3261expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, 3147expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3262 Idx cur_str, Idx subexp_num, int type) 3148 Idx cur_str, Idx subexp_num, int type)
3263{ 3149{
@@ -3266,7 +3152,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3266 Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str); 3152 Idx cache_idx_start = search_cur_bkref_entry (mctx, cur_str);
3267 struct re_backref_cache_entry *ent; 3153 struct re_backref_cache_entry *ent;
3268 3154
3269 if (cache_idx_start == REG_MISSING) 3155 if (cache_idx_start == -1)
3270 return REG_NOERROR; 3156 return REG_NOERROR;
3271 3157
3272 restart: 3158 restart:
@@ -3295,8 +3181,8 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3295 err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); 3181 err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type);
3296 err3 = re_node_set_merge (cur_nodes, &new_dests); 3182 err3 = re_node_set_merge (cur_nodes, &new_dests);
3297 re_node_set_free (&new_dests); 3183 re_node_set_free (&new_dests);
3298 if (BE (err != REG_NOERROR || err2 != REG_NOERROR 3184 if (__glibc_unlikely (err != REG_NOERROR || err2 != REG_NOERROR
3299 || err3 != REG_NOERROR, 0)) 3185 || err3 != REG_NOERROR))
3300 { 3186 {
3301 err = (err != REG_NOERROR ? err 3187 err = (err != REG_NOERROR ? err
3302 : (err2 != REG_NOERROR ? err2 : err3)); 3188 : (err2 != REG_NOERROR ? err2 : err3));
@@ -3318,7 +3204,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3318 err = re_node_set_init_copy (&union_set, 3204 err = re_node_set_init_copy (&union_set,
3319 &mctx->state_log[to_idx]->nodes); 3205 &mctx->state_log[to_idx]->nodes);
3320 ok = re_node_set_insert (&union_set, next_node); 3206 ok = re_node_set_insert (&union_set, next_node);
3321 if (BE (err != REG_NOERROR || ! ok, 0)) 3207 if (__glibc_unlikely (err != REG_NOERROR || ! ok))
3322 { 3208 {
3323 re_node_set_free (&union_set); 3209 re_node_set_free (&union_set);
3324 err = err != REG_NOERROR ? err : REG_ESPACE; 3210 err = err != REG_NOERROR ? err : REG_ESPACE;
@@ -3328,13 +3214,13 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3328 else 3214 else
3329 { 3215 {
3330 err = re_node_set_init_1 (&union_set, next_node); 3216 err = re_node_set_init_1 (&union_set, next_node);
3331 if (BE (err != REG_NOERROR, 0)) 3217 if (__glibc_unlikely (err != REG_NOERROR))
3332 return err; 3218 return err;
3333 } 3219 }
3334 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); 3220 mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set);
3335 re_node_set_free (&union_set); 3221 re_node_set_free (&union_set);
3336 if (BE (mctx->state_log[to_idx] == NULL 3222 if (__glibc_unlikely (mctx->state_log[to_idx] == NULL
3337 && err != REG_NOERROR, 0)) 3223 && err != REG_NOERROR))
3338 return err; 3224 return err;
3339 } 3225 }
3340 } 3226 }
@@ -3345,8 +3231,7 @@ expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes,
3345/* Build transition table for the state. 3231/* Build transition table for the state.
3346 Return true if successful. */ 3232 Return true if successful. */
3347 3233
3348static bool 3234static bool __attribute_noinline__
3349internal_function
3350build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) 3235build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3351{ 3236{
3352 reg_errcode_t err; 3237 reg_errcode_t err;
@@ -3354,36 +3239,20 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3354 int ch; 3239 int ch;
3355 bool need_word_trtable = false; 3240 bool need_word_trtable = false;
3356 bitset_word_t elem, mask; 3241 bitset_word_t elem, mask;
3357 bool dests_node_malloced = false;
3358 bool dest_states_malloced = false;
3359 Idx ndests; /* Number of the destination states from 'state'. */ 3242 Idx ndests; /* Number of the destination states from 'state'. */
3360 re_dfastate_t **trtable; 3243 re_dfastate_t **trtable;
3361 re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; 3244 re_dfastate_t *dest_states[SBC_MAX];
3362 re_node_set follows, *dests_node; 3245 re_dfastate_t *dest_states_word[SBC_MAX];
3363 bitset_t *dests_ch; 3246 re_dfastate_t *dest_states_nl[SBC_MAX];
3247 re_node_set follows;
3364 bitset_t acceptable; 3248 bitset_t acceptable;
3365 3249
3366 struct dests_alloc
3367 {
3368 re_node_set dests_node[SBC_MAX];
3369 bitset_t dests_ch[SBC_MAX];
3370 } *dests_alloc;
3371
3372 /* We build DFA states which corresponds to the destination nodes 3250 /* We build DFA states which corresponds to the destination nodes
3373 from 'state'. 'dests_node[i]' represents the nodes which i-th 3251 from 'state'. 'dests_node[i]' represents the nodes which i-th
3374 destination state contains, and 'dests_ch[i]' represents the 3252 destination state contains, and 'dests_ch[i]' represents the
3375 characters which i-th destination state accepts. */ 3253 characters which i-th destination state accepts. */
3376 if (__libc_use_alloca (sizeof (struct dests_alloc))) 3254 re_node_set dests_node[SBC_MAX];
3377 dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); 3255 bitset_t dests_ch[SBC_MAX];
3378 else
3379 {
3380 dests_alloc = re_malloc (struct dests_alloc, 1);
3381 if (BE (dests_alloc == NULL, 0))
3382 return false;
3383 dests_node_malloced = true;
3384 }
3385 dests_node = dests_alloc->dests_node;
3386 dests_ch = dests_alloc->dests_ch;
3387 3256
3388 /* Initialize transition table. */ 3257 /* Initialize transition table. */
3389 state->word_trtable = state->trtable = NULL; 3258 state->word_trtable = state->trtable = NULL;
@@ -3391,16 +3260,14 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3391 /* At first, group all nodes belonging to 'state' into several 3260 /* At first, group all nodes belonging to 'state' into several
3392 destinations. */ 3261 destinations. */
3393 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); 3262 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
3394 if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0)) 3263 if (__glibc_unlikely (ndests <= 0))
3395 { 3264 {
3396 if (dests_node_malloced)
3397 free (dests_alloc);
3398 /* Return false in case of an error, true otherwise. */ 3265 /* Return false in case of an error, true otherwise. */
3399 if (ndests == 0) 3266 if (ndests == 0)
3400 { 3267 {
3401 state->trtable = (re_dfastate_t **) 3268 state->trtable = (re_dfastate_t **)
3402 calloc (sizeof (re_dfastate_t *), SBC_MAX); 3269 calloc (sizeof (re_dfastate_t *), SBC_MAX);
3403 if (BE (state->trtable == NULL, 0)) 3270 if (__glibc_unlikely (state->trtable == NULL))
3404 return false; 3271 return false;
3405 return true; 3272 return true;
3406 } 3273 }
@@ -3408,40 +3275,15 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3408 } 3275 }
3409 3276
3410 err = re_node_set_alloc (&follows, ndests + 1); 3277 err = re_node_set_alloc (&follows, ndests + 1);
3411 if (BE (err != REG_NOERROR, 0)) 3278 if (__glibc_unlikely (err != REG_NOERROR))
3412 goto out_free;
3413
3414 /* Avoid arithmetic overflow in size calculation. */
3415 if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX)
3416 / (3 * sizeof (re_dfastate_t *)))
3417 < ndests),
3418 0))
3419 goto out_free;
3420
3421 if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX
3422 + ndests * 3 * sizeof (re_dfastate_t *)))
3423 dest_states = (re_dfastate_t **)
3424 alloca (ndests * 3 * sizeof (re_dfastate_t *));
3425 else
3426 { 3279 {
3427 dest_states = (re_dfastate_t **) 3280 out_free:
3428 malloc (ndests * 3 * sizeof (re_dfastate_t *)); 3281 re_node_set_free (&follows);
3429 if (BE (dest_states == NULL, 0)) 3282 for (i = 0; i < ndests; ++i)
3430 { 3283 re_node_set_free (dests_node + i);
3431out_free: 3284 return false;
3432 if (dest_states_malloced)
3433 free (dest_states);
3434 re_node_set_free (&follows);
3435 for (i = 0; i < ndests; ++i)
3436 re_node_set_free (dests_node + i);
3437 if (dests_node_malloced)
3438 free (dests_alloc);
3439 return false;
3440 }
3441 dest_states_malloced = true;
3442 } 3285 }
3443 dest_states_word = dest_states + ndests; 3286
3444 dest_states_nl = dest_states_word + ndests;
3445 bitset_empty (acceptable); 3287 bitset_empty (acceptable);
3446 3288
3447 /* Then build the states for all destinations. */ 3289 /* Then build the states for all destinations. */
@@ -3453,15 +3295,15 @@ out_free:
3453 for (j = 0; j < dests_node[i].nelem; ++j) 3295 for (j = 0; j < dests_node[i].nelem; ++j)
3454 { 3296 {
3455 next_node = dfa->nexts[dests_node[i].elems[j]]; 3297 next_node = dfa->nexts[dests_node[i].elems[j]];
3456 if (next_node != REG_MISSING) 3298 if (next_node != -1)
3457 { 3299 {
3458 err = re_node_set_merge (&follows, dfa->eclosures + next_node); 3300 err = re_node_set_merge (&follows, dfa->eclosures + next_node);
3459 if (BE (err != REG_NOERROR, 0)) 3301 if (__glibc_unlikely (err != REG_NOERROR))
3460 goto out_free; 3302 goto out_free;
3461 } 3303 }
3462 } 3304 }
3463 dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); 3305 dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0);
3464 if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) 3306 if (__glibc_unlikely (dest_states[i] == NULL && err != REG_NOERROR))
3465 goto out_free; 3307 goto out_free;
3466 /* If the new state has context constraint, 3308 /* If the new state has context constraint,
3467 build appropriate states for these contexts. */ 3309 build appropriate states for these contexts. */
@@ -3469,7 +3311,8 @@ out_free:
3469 { 3311 {
3470 dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, 3312 dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows,
3471 CONTEXT_WORD); 3313 CONTEXT_WORD);
3472 if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) 3314 if (__glibc_unlikely (dest_states_word[i] == NULL
3315 && err != REG_NOERROR))
3473 goto out_free; 3316 goto out_free;
3474 3317
3475 if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) 3318 if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1)
@@ -3477,7 +3320,7 @@ out_free:
3477 3320
3478 dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, 3321 dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows,
3479 CONTEXT_NEWLINE); 3322 CONTEXT_NEWLINE);
3480 if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) 3323 if (__glibc_unlikely (dest_states_nl[i] == NULL && err != REG_NOERROR))
3481 goto out_free; 3324 goto out_free;
3482 } 3325 }
3483 else 3326 else
@@ -3488,7 +3331,7 @@ out_free:
3488 bitset_merge (acceptable, dests_ch[i]); 3331 bitset_merge (acceptable, dests_ch[i]);
3489 } 3332 }
3490 3333
3491 if (!BE (need_word_trtable, 0)) 3334 if (!__glibc_unlikely (need_word_trtable))
3492 { 3335 {
3493 /* We don't care about whether the following character is a word 3336 /* We don't care about whether the following character is a word
3494 character, or we are in a single-byte character set so we can 3337 character, or we are in a single-byte character set so we can
@@ -3496,7 +3339,7 @@ out_free:
3496 256-entry transition table. */ 3339 256-entry transition table. */
3497 trtable = state->trtable = 3340 trtable = state->trtable =
3498 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); 3341 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX);
3499 if (BE (trtable == NULL, 0)) 3342 if (__glibc_unlikely (trtable == NULL))
3500 goto out_free; 3343 goto out_free;
3501 3344
3502 /* For all characters ch...: */ 3345 /* For all characters ch...: */
@@ -3504,7 +3347,7 @@ out_free:
3504 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; 3347 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
3505 elem; 3348 elem;
3506 mask <<= 1, elem >>= 1, ++ch) 3349 mask <<= 1, elem >>= 1, ++ch)
3507 if (BE (elem & 1, 0)) 3350 if (__glibc_unlikely (elem & 1))
3508 { 3351 {
3509 /* There must be exactly one destination which accepts 3352 /* There must be exactly one destination which accepts
3510 character ch. See group_nodes_into_DFAstates. */ 3353 character ch. See group_nodes_into_DFAstates. */
@@ -3527,7 +3370,7 @@ out_free:
3527 starting at trtable[SBC_MAX]. */ 3370 starting at trtable[SBC_MAX]. */
3528 trtable = state->word_trtable = 3371 trtable = state->word_trtable =
3529 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); 3372 (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX);
3530 if (BE (trtable == NULL, 0)) 3373 if (__glibc_unlikely (trtable == NULL))
3531 goto out_free; 3374 goto out_free;
3532 3375
3533 /* For all characters ch...: */ 3376 /* For all characters ch...: */
@@ -3535,7 +3378,7 @@ out_free:
3535 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; 3378 for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1;
3536 elem; 3379 elem;
3537 mask <<= 1, elem >>= 1, ++ch) 3380 mask <<= 1, elem >>= 1, ++ch)
3538 if (BE (elem & 1, 0)) 3381 if (__glibc_unlikely (elem & 1))
3539 { 3382 {
3540 /* There must be exactly one destination which accepts 3383 /* There must be exactly one destination which accepts
3541 character ch. See group_nodes_into_DFAstates. */ 3384 character ch. See group_nodes_into_DFAstates. */
@@ -3565,26 +3408,19 @@ out_free:
3565 } 3408 }
3566 } 3409 }
3567 3410
3568 if (dest_states_malloced)
3569 free (dest_states);
3570
3571 re_node_set_free (&follows); 3411 re_node_set_free (&follows);
3572 for (i = 0; i < ndests; ++i) 3412 for (i = 0; i < ndests; ++i)
3573 re_node_set_free (dests_node + i); 3413 re_node_set_free (dests_node + i);
3574
3575 if (dests_node_malloced)
3576 free (dests_alloc);
3577
3578 return true; 3414 return true;
3579} 3415}
3580 3416
3581/* Group all nodes belonging to STATE into several destinations. 3417/* Group all nodes belonging to STATE into several destinations.
3582 Then for all destinations, set the nodes belonging to the destination 3418 Then for all destinations, set the nodes belonging to the destination
3583 to DESTS_NODE[i] and set the characters accepted by the destination 3419 to DESTS_NODE[i] and set the characters accepted by the destination
3584 to DEST_CH[i]. This function return the number of destinations. */ 3420 to DEST_CH[i]. Return the number of destinations if successful,
3421 -1 on internal error. */
3585 3422
3586static Idx 3423static Idx
3587internal_function
3588group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, 3424group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3589 re_node_set *dests_node, bitset_t *dests_ch) 3425 re_node_set *dests_node, bitset_t *dests_ch)
3590{ 3426{
@@ -3613,18 +3449,15 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3613 } 3449 }
3614 else if (type == OP_PERIOD) 3450 else if (type == OP_PERIOD)
3615 { 3451 {
3616#ifdef RE_ENABLE_I18N
3617 if (dfa->mb_cur_max > 1) 3452 if (dfa->mb_cur_max > 1)
3618 bitset_merge (accepts, dfa->sb_char); 3453 bitset_merge (accepts, dfa->sb_char);
3619 else 3454 else
3620#endif
3621 bitset_set_all (accepts); 3455 bitset_set_all (accepts);
3622 if (!(dfa->syntax & RE_DOT_NEWLINE)) 3456 if (!(dfa->syntax & RE_DOT_NEWLINE))
3623 bitset_clear (accepts, '\n'); 3457 bitset_clear (accepts, '\n');
3624 if (dfa->syntax & RE_DOT_NOT_NULL) 3458 if (dfa->syntax & RE_DOT_NOT_NULL)
3625 bitset_clear (accepts, '\0'); 3459 bitset_clear (accepts, '\0');
3626 } 3460 }
3627#ifdef RE_ENABLE_I18N
3628 else if (type == OP_UTF8_PERIOD) 3461 else if (type == OP_UTF8_PERIOD)
3629 { 3462 {
3630 if (ASCII_CHARS % BITSET_WORD_BITS == 0) 3463 if (ASCII_CHARS % BITSET_WORD_BITS == 0)
@@ -3636,7 +3469,6 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3636 if (dfa->syntax & RE_DOT_NOT_NULL) 3469 if (dfa->syntax & RE_DOT_NOT_NULL)
3637 bitset_clear (accepts, '\0'); 3470 bitset_clear (accepts, '\0');
3638 } 3471 }
3639#endif
3640 else 3472 else
3641 continue; 3473 continue;
3642 3474
@@ -3667,12 +3499,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3667 bitset_empty (accepts); 3499 bitset_empty (accepts);
3668 continue; 3500 continue;
3669 } 3501 }
3670#ifdef RE_ENABLE_I18N
3671 if (dfa->mb_cur_max > 1) 3502 if (dfa->mb_cur_max > 1)
3672 for (j = 0; j < BITSET_WORDS; ++j) 3503 for (j = 0; j < BITSET_WORDS; ++j)
3673 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); 3504 any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j]));
3674 else 3505 else
3675#endif
3676 for (j = 0; j < BITSET_WORDS; ++j) 3506 for (j = 0; j < BITSET_WORDS; ++j)
3677 any_set |= (accepts[j] &= dfa->word_char[j]); 3507 any_set |= (accepts[j] &= dfa->word_char[j]);
3678 if (!any_set) 3508 if (!any_set)
@@ -3686,12 +3516,10 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3686 bitset_empty (accepts); 3516 bitset_empty (accepts);
3687 continue; 3517 continue;
3688 } 3518 }
3689#ifdef RE_ENABLE_I18N
3690 if (dfa->mb_cur_max > 1) 3519 if (dfa->mb_cur_max > 1)
3691 for (j = 0; j < BITSET_WORDS; ++j) 3520 for (j = 0; j < BITSET_WORDS; ++j)
3692 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); 3521 any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j]));
3693 else 3522 else
3694#endif
3695 for (j = 0; j < BITSET_WORDS; ++j) 3523 for (j = 0; j < BITSET_WORDS; ++j)
3696 any_set |= (accepts[j] &= ~dfa->word_char[j]); 3524 any_set |= (accepts[j] &= ~dfa->word_char[j]);
3697 if (!any_set) 3525 if (!any_set)
@@ -3735,14 +3563,14 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3735 bitset_copy (dests_ch[ndests], remains); 3563 bitset_copy (dests_ch[ndests], remains);
3736 bitset_copy (dests_ch[j], intersec); 3564 bitset_copy (dests_ch[j], intersec);
3737 err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); 3565 err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]);
3738 if (BE (err != REG_NOERROR, 0)) 3566 if (__glibc_unlikely (err != REG_NOERROR))
3739 goto error_return; 3567 goto error_return;
3740 ++ndests; 3568 ++ndests;
3741 } 3569 }
3742 3570
3743 /* Put the position in the current group. */ 3571 /* Put the position in the current group. */
3744 ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); 3572 ok = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]);
3745 if (BE (! ok, 0)) 3573 if (__glibc_unlikely (! ok))
3746 goto error_return; 3574 goto error_return;
3747 3575
3748 /* If all characters are consumed, go to next node. */ 3576 /* If all characters are consumed, go to next node. */
@@ -3754,20 +3582,20 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3754 { 3582 {
3755 bitset_copy (dests_ch[ndests], accepts); 3583 bitset_copy (dests_ch[ndests], accepts);
3756 err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); 3584 err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]);
3757 if (BE (err != REG_NOERROR, 0)) 3585 if (__glibc_unlikely (err != REG_NOERROR))
3758 goto error_return; 3586 goto error_return;
3759 ++ndests; 3587 ++ndests;
3760 bitset_empty (accepts); 3588 bitset_empty (accepts);
3761 } 3589 }
3762 } 3590 }
3591 assume (ndests <= SBC_MAX);
3763 return ndests; 3592 return ndests;
3764 error_return: 3593 error_return:
3765 for (j = 0; j < ndests; ++j) 3594 for (j = 0; j < ndests; ++j)
3766 re_node_set_free (dests_node + j); 3595 re_node_set_free (dests_node + j);
3767 return REG_MISSING; 3596 return -1;
3768} 3597}
3769 3598
3770#ifdef RE_ENABLE_I18N
3771/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts. 3599/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
3772 Return the number of the bytes the node accepts. 3600 Return the number of the bytes the node accepts.
3773 STR_IDX is the current index of the input string. 3601 STR_IDX is the current index of the input string.
@@ -3776,8 +3604,11 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3776 one collating element like '.', '[a-z]', opposite to the other nodes 3604 one collating element like '.', '[a-z]', opposite to the other nodes
3777 can only accept one byte. */ 3605 can only accept one byte. */
3778 3606
3607#ifdef _LIBC
3608# include <locale/weight.h>
3609#endif
3610
3779static int 3611static int
3780internal_function
3781check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx, 3612check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3782 const re_string_t *input, Idx str_idx) 3613 const re_string_t *input, Idx str_idx)
3783{ 3614{
@@ -3785,10 +3616,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3785 int char_len, elem_len; 3616 int char_len, elem_len;
3786 Idx i; 3617 Idx i;
3787 3618
3788 if (BE (node->type == OP_UTF8_PERIOD, 0)) 3619 if (__glibc_unlikely (node->type == OP_UTF8_PERIOD))
3789 { 3620 {
3790 unsigned char c = re_string_byte_at (input, str_idx), d; 3621 unsigned char c = re_string_byte_at (input, str_idx), d;
3791 if (BE (c < 0xc2, 1)) 3622 if (__glibc_likely (c < 0xc2))
3792 return 0; 3623 return 0;
3793 3624
3794 if (str_idx + 2 > input->len) 3625 if (str_idx + 2 > input->len)
@@ -3844,10 +3675,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3844 /* FIXME: I don't think this if is needed, as both '\n' 3675 /* FIXME: I don't think this if is needed, as both '\n'
3845 and '\0' are char_len == 1. */ 3676 and '\0' are char_len == 1. */
3846 /* '.' accepts any one character except the following two cases. */ 3677 /* '.' accepts any one character except the following two cases. */
3847 if ((!(dfa->syntax & RE_DOT_NEWLINE) && 3678 if ((!(dfa->syntax & RE_DOT_NEWLINE)
3848 re_string_byte_at (input, str_idx) == '\n') || 3679 && re_string_byte_at (input, str_idx) == '\n')
3849 ((dfa->syntax & RE_DOT_NOT_NULL) && 3680 || ((dfa->syntax & RE_DOT_NOT_NULL)
3850 re_string_byte_at (input, str_idx) == '\0')) 3681 && re_string_byte_at (input, str_idx) == '\0'))
3851 return 0; 3682 return 0;
3852 return char_len; 3683 return char_len;
3853 } 3684 }
@@ -3859,12 +3690,12 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3859 if (node->type == COMPLEX_BRACKET) 3690 if (node->type == COMPLEX_BRACKET)
3860 { 3691 {
3861 const re_charset_t *cset = node->opr.mbcset; 3692 const re_charset_t *cset = node->opr.mbcset;
3862# ifdef _LIBC 3693#ifdef _LIBC
3863 const unsigned char *pin 3694 const unsigned char *pin
3864 = ((const unsigned char *) re_string_get_buffer (input) + str_idx); 3695 = ((const unsigned char *) re_string_get_buffer (input) + str_idx);
3865 Idx j; 3696 Idx j;
3866 uint32_t nrules; 3697 uint32_t nrules;
3867# endif /* _LIBC */ 3698#endif
3868 int match_len = 0; 3699 int match_len = 0;
3869 wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) 3700 wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars)
3870 ? re_string_wchar_at (input, str_idx) : 0); 3701 ? re_string_wchar_at (input, str_idx) : 0);
@@ -3887,7 +3718,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3887 } 3718 }
3888 } 3719 }
3889 3720
3890# ifdef _LIBC 3721#ifdef _LIBC
3891 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3722 nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
3892 if (nrules != 0) 3723 if (nrules != 0)
3893 { 3724 {
@@ -3895,8 +3726,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3895 const int32_t *table, *indirect; 3726 const int32_t *table, *indirect;
3896 const unsigned char *weights, *extra; 3727 const unsigned char *weights, *extra;
3897 const char *collseqwc; 3728 const char *collseqwc;
3898 /* This #include defines a local function! */
3899# include <locale/weight.h>
3900 3729
3901 /* match with collating_symbol? */ 3730 /* match with collating_symbol? */
3902 if (cset->ncoll_syms) 3731 if (cset->ncoll_syms)
@@ -3953,35 +3782,32 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3953 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); 3782 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
3954 indirect = (const int32_t *) 3783 indirect = (const int32_t *)
3955 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); 3784 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
3956 int32_t idx = findidx (&cp, elem_len); 3785 int32_t idx = findidx (table, indirect, extra, &cp, elem_len);
3786 int32_t rule = idx >> 24;
3787 idx &= 0xffffff;
3957 if (idx > 0) 3788 if (idx > 0)
3958 for (i = 0; i < cset->nequiv_classes; ++i) 3789 {
3959 { 3790 size_t weight_len = weights[idx];
3960 int32_t equiv_class_idx = cset->equiv_classes[i]; 3791 for (i = 0; i < cset->nequiv_classes; ++i)
3961 size_t weight_len = weights[idx & 0xffffff]; 3792 {
3962 if (weight_len == weights[equiv_class_idx & 0xffffff] 3793 int32_t equiv_class_idx = cset->equiv_classes[i];
3963 && (idx >> 24) == (equiv_class_idx >> 24)) 3794 int32_t equiv_class_rule = equiv_class_idx >> 24;
3964 { 3795 equiv_class_idx &= 0xffffff;
3965 Idx cnt = 0; 3796 if (weights[equiv_class_idx] == weight_len
3966 3797 && equiv_class_rule == rule
3967 idx &= 0xffffff; 3798 && memcmp (weights + idx + 1,
3968 equiv_class_idx &= 0xffffff; 3799 weights + equiv_class_idx + 1,
3969 3800 weight_len) == 0)
3970 while (cnt <= weight_len 3801 {
3971 && (weights[equiv_class_idx + 1 + cnt] 3802 match_len = elem_len;
3972 == weights[idx + 1 + cnt])) 3803 goto check_node_accept_bytes_match;
3973 ++cnt; 3804 }
3974 if (cnt > weight_len) 3805 }
3975 { 3806 }
3976 match_len = elem_len;
3977 goto check_node_accept_bytes_match;
3978 }
3979 }
3980 }
3981 } 3807 }
3982 } 3808 }
3983 else 3809 else
3984# endif /* _LIBC */ 3810#endif /* _LIBC */
3985 { 3811 {
3986 /* match with range expression? */ 3812 /* match with range expression? */
3987 for (i = 0; i < cset->nranges; ++i) 3813 for (i = 0; i < cset->nranges; ++i)
@@ -4007,9 +3833,8 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
4007 return 0; 3833 return 0;
4008} 3834}
4009 3835
4010# ifdef _LIBC 3836#ifdef _LIBC
4011static unsigned int 3837static unsigned int
4012internal_function
4013find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) 3838find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
4014{ 3839{
4015 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 3840 uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -4066,14 +3891,12 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
4066 return UINT_MAX; 3891 return UINT_MAX;
4067 } 3892 }
4068} 3893}
4069# endif /* _LIBC */ 3894#endif /* _LIBC */
4070#endif /* RE_ENABLE_I18N */
4071 3895
4072/* Check whether the node accepts the byte which is IDX-th 3896/* Check whether the node accepts the byte which is IDX-th
4073 byte of the INPUT. */ 3897 byte of the INPUT. */
4074 3898
4075static bool 3899static bool
4076internal_function
4077check_node_accept (const re_match_context_t *mctx, const re_token_t *node, 3900check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4078 Idx idx) 3901 Idx idx)
4079{ 3902{
@@ -4091,12 +3914,10 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4091 return false; 3914 return false;
4092 break; 3915 break;
4093 3916
4094#ifdef RE_ENABLE_I18N
4095 case OP_UTF8_PERIOD: 3917 case OP_UTF8_PERIOD:
4096 if (ch >= ASCII_CHARS) 3918 if (ch >= ASCII_CHARS)
4097 return false; 3919 return false;
4098 /* FALLTHROUGH */ 3920 FALLTHROUGH;
4099#endif
4100 case OP_PERIOD: 3921 case OP_PERIOD:
4101 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) 3922 if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE))
4102 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) 3923 || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL)))
@@ -4123,22 +3944,22 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4123/* Extend the buffers, if the buffers have run out. */ 3944/* Extend the buffers, if the buffers have run out. */
4124 3945
4125static reg_errcode_t 3946static reg_errcode_t
4126internal_function __attribute_warn_unused_result__ 3947__attribute_warn_unused_result__
4127extend_buffers (re_match_context_t *mctx, int min_len) 3948extend_buffers (re_match_context_t *mctx, int min_len)
4128{ 3949{
4129 reg_errcode_t ret; 3950 reg_errcode_t ret;
4130 re_string_t *pstr = &mctx->input; 3951 re_string_t *pstr = &mctx->input;
4131 3952
4132 /* Avoid overflow. */ 3953 /* Avoid overflow. */
4133 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2 3954 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
4134 <= pstr->bufs_len, 0)) 3955 <= pstr->bufs_len))
4135 return REG_ESPACE; 3956 return REG_ESPACE;
4136 3957
4137 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */ 3958 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
4138 ret = re_string_realloc_buffers (pstr, 3959 ret = re_string_realloc_buffers (pstr,
4139 MAX (min_len, 3960 MAX (min_len,
4140 MIN (pstr->len, pstr->bufs_len * 2))); 3961 MIN (pstr->len, pstr->bufs_len * 2)));
4141 if (BE (ret != REG_NOERROR, 0)) 3962 if (__glibc_unlikely (ret != REG_NOERROR))
4142 return ret; 3963 return ret;
4143 3964
4144 if (mctx->state_log != NULL) 3965 if (mctx->state_log != NULL)
@@ -4149,7 +3970,7 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4149 does not have the right size. */ 3970 does not have the right size. */
4150 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, 3971 re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *,
4151 pstr->bufs_len + 1); 3972 pstr->bufs_len + 1);
4152 if (BE (new_array == NULL, 0)) 3973 if (__glibc_unlikely (new_array == NULL))
4153 return REG_ESPACE; 3974 return REG_ESPACE;
4154 mctx->state_log = new_array; 3975 mctx->state_log = new_array;
4155 } 3976 }
@@ -4157,24 +3978,20 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4157 /* Then reconstruct the buffers. */ 3978 /* Then reconstruct the buffers. */
4158 if (pstr->icase) 3979 if (pstr->icase)
4159 { 3980 {
4160#ifdef RE_ENABLE_I18N
4161 if (pstr->mb_cur_max > 1) 3981 if (pstr->mb_cur_max > 1)
4162 { 3982 {
4163 ret = build_wcs_upper_buffer (pstr); 3983 ret = build_wcs_upper_buffer (pstr);
4164 if (BE (ret != REG_NOERROR, 0)) 3984 if (__glibc_unlikely (ret != REG_NOERROR))
4165 return ret; 3985 return ret;
4166 } 3986 }
4167 else 3987 else
4168#endif /* RE_ENABLE_I18N */
4169 build_upper_buffer (pstr); 3988 build_upper_buffer (pstr);
4170 } 3989 }
4171 else 3990 else
4172 { 3991 {
4173#ifdef RE_ENABLE_I18N
4174 if (pstr->mb_cur_max > 1) 3992 if (pstr->mb_cur_max > 1)
4175 build_wcs_buffer (pstr); 3993 build_wcs_buffer (pstr);
4176 else 3994 else
4177#endif /* RE_ENABLE_I18N */
4178 { 3995 {
4179 if (pstr->trans != NULL) 3996 if (pstr->trans != NULL)
4180 re_string_translate_buffer (pstr); 3997 re_string_translate_buffer (pstr);
@@ -4189,23 +4006,23 @@ extend_buffers (re_match_context_t *mctx, int min_len)
4189/* Initialize MCTX. */ 4006/* Initialize MCTX. */
4190 4007
4191static reg_errcode_t 4008static reg_errcode_t
4192internal_function __attribute_warn_unused_result__ 4009__attribute_warn_unused_result__
4193match_ctx_init (re_match_context_t *mctx, int eflags, Idx n) 4010match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4194{ 4011{
4195 mctx->eflags = eflags; 4012 mctx->eflags = eflags;
4196 mctx->match_last = REG_MISSING; 4013 mctx->match_last = -1;
4197 if (n > 0) 4014 if (n > 0)
4198 { 4015 {
4199 /* Avoid overflow. */ 4016 /* Avoid overflow. */
4200 size_t max_object_size = 4017 size_t max_object_size =
4201 MAX (sizeof (struct re_backref_cache_entry), 4018 MAX (sizeof (struct re_backref_cache_entry),
4202 sizeof (re_sub_match_top_t *)); 4019 sizeof (re_sub_match_top_t *));
4203 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0)) 4020 if (__glibc_unlikely (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n))
4204 return REG_ESPACE; 4021 return REG_ESPACE;
4205 4022
4206 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); 4023 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
4207 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); 4024 mctx->sub_tops = re_malloc (re_sub_match_top_t *, n);
4208 if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) 4025 if (__glibc_unlikely (mctx->bkref_ents == NULL || mctx->sub_tops == NULL))
4209 return REG_ESPACE; 4026 return REG_ESPACE;
4210 } 4027 }
4211 /* Already zero-ed by the caller. 4028 /* Already zero-ed by the caller.
@@ -4224,7 +4041,6 @@ match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4224 of the input, or changes the input string. */ 4041 of the input, or changes the input string. */
4225 4042
4226static void 4043static void
4227internal_function
4228match_ctx_clean (re_match_context_t *mctx) 4044match_ctx_clean (re_match_context_t *mctx)
4229{ 4045{
4230 Idx st_idx; 4046 Idx st_idx;
@@ -4244,7 +4060,7 @@ match_ctx_clean (re_match_context_t *mctx)
4244 re_free (top->path->array); 4060 re_free (top->path->array);
4245 re_free (top->path); 4061 re_free (top->path);
4246 } 4062 }
4247 free (top); 4063 re_free (top);
4248 } 4064 }
4249 4065
4250 mctx->nsub_tops = 0; 4066 mctx->nsub_tops = 0;
@@ -4254,7 +4070,6 @@ match_ctx_clean (re_match_context_t *mctx)
4254/* Free all the memory associated with MCTX. */ 4070/* Free all the memory associated with MCTX. */
4255 4071
4256static void 4072static void
4257internal_function
4258match_ctx_free (re_match_context_t *mctx) 4073match_ctx_free (re_match_context_t *mctx)
4259{ 4074{
4260 /* First, free all the memory associated with MCTX->SUB_TOPS. */ 4075 /* First, free all the memory associated with MCTX->SUB_TOPS. */
@@ -4269,7 +4084,7 @@ match_ctx_free (re_match_context_t *mctx)
4269*/ 4084*/
4270 4085
4271static reg_errcode_t 4086static reg_errcode_t
4272internal_function __attribute_warn_unused_result__ 4087__attribute_warn_unused_result__
4273match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from, 4088match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4274 Idx to) 4089 Idx to)
4275{ 4090{
@@ -4278,7 +4093,7 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4278 struct re_backref_cache_entry* new_entry; 4093 struct re_backref_cache_entry* new_entry;
4279 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, 4094 new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry,
4280 mctx->abkref_ents * 2); 4095 mctx->abkref_ents * 2);
4281 if (BE (new_entry == NULL, 0)) 4096 if (__glibc_unlikely (new_entry == NULL))
4282 { 4097 {
4283 re_free (mctx->bkref_ents); 4098 re_free (mctx->bkref_ents);
4284 return REG_ESPACE; 4099 return REG_ESPACE;
@@ -4314,11 +4129,10 @@ match_ctx_add_entry (re_match_context_t *mctx, Idx node, Idx str_idx, Idx from,
4314 return REG_NOERROR; 4129 return REG_NOERROR;
4315} 4130}
4316 4131
4317/* Return the first entry with the same str_idx, or REG_MISSING if none is 4132/* Return the first entry with the same str_idx, or -1 if none is
4318 found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ 4133 found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */
4319 4134
4320static Idx 4135static Idx
4321internal_function
4322search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx) 4136search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
4323{ 4137{
4324 Idx left, right, mid, last; 4138 Idx left, right, mid, last;
@@ -4334,33 +4148,31 @@ search_cur_bkref_entry (const re_match_context_t *mctx, Idx str_idx)
4334 if (left < last && mctx->bkref_ents[left].str_idx == str_idx) 4148 if (left < last && mctx->bkref_ents[left].str_idx == str_idx)
4335 return left; 4149 return left;
4336 else 4150 else
4337 return REG_MISSING; 4151 return -1;
4338} 4152}
4339 4153
4340/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches 4154/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches
4341 at STR_IDX. */ 4155 at STR_IDX. */
4342 4156
4343static reg_errcode_t 4157static reg_errcode_t
4344internal_function __attribute_warn_unused_result__ 4158__attribute_warn_unused_result__
4345match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx) 4159match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4346{ 4160{
4347#ifdef DEBUG 4161 DEBUG_ASSERT (mctx->sub_tops != NULL);
4348 assert (mctx->sub_tops != NULL); 4162 DEBUG_ASSERT (mctx->asub_tops > 0);
4349 assert (mctx->asub_tops > 0); 4163 if (__glibc_unlikely (mctx->nsub_tops == mctx->asub_tops))
4350#endif
4351 if (BE (mctx->nsub_tops == mctx->asub_tops, 0))
4352 { 4164 {
4353 Idx new_asub_tops = mctx->asub_tops * 2; 4165 Idx new_asub_tops = mctx->asub_tops * 2;
4354 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, 4166 re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops,
4355 re_sub_match_top_t *, 4167 re_sub_match_top_t *,
4356 new_asub_tops); 4168 new_asub_tops);
4357 if (BE (new_array == NULL, 0)) 4169 if (__glibc_unlikely (new_array == NULL))
4358 return REG_ESPACE; 4170 return REG_ESPACE;
4359 mctx->sub_tops = new_array; 4171 mctx->sub_tops = new_array;
4360 mctx->asub_tops = new_asub_tops; 4172 mctx->asub_tops = new_asub_tops;
4361 } 4173 }
4362 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); 4174 mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t));
4363 if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) 4175 if (__glibc_unlikely (mctx->sub_tops[mctx->nsub_tops] == NULL))
4364 return REG_ESPACE; 4176 return REG_ESPACE;
4365 mctx->sub_tops[mctx->nsub_tops]->node = node; 4177 mctx->sub_tops[mctx->nsub_tops]->node = node;
4366 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; 4178 mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx;
@@ -4368,26 +4180,26 @@ match_ctx_add_subtop (re_match_context_t *mctx, Idx node, Idx str_idx)
4368} 4180}
4369 4181
4370/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches 4182/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches
4371 at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */ 4183 at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP.
4184 Return the new entry if successful, NULL if memory is exhausted. */
4372 4185
4373static re_sub_match_last_t * 4186static re_sub_match_last_t *
4374internal_function
4375match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx) 4187match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
4376{ 4188{
4377 re_sub_match_last_t *new_entry; 4189 re_sub_match_last_t *new_entry;
4378 if (BE (subtop->nlasts == subtop->alasts, 0)) 4190 if (__glibc_unlikely (subtop->nlasts == subtop->alasts))
4379 { 4191 {
4380 Idx new_alasts = 2 * subtop->alasts + 1; 4192 Idx new_alasts = 2 * subtop->alasts + 1;
4381 re_sub_match_last_t **new_array = re_realloc (subtop->lasts, 4193 re_sub_match_last_t **new_array = re_realloc (subtop->lasts,
4382 re_sub_match_last_t *, 4194 re_sub_match_last_t *,
4383 new_alasts); 4195 new_alasts);
4384 if (BE (new_array == NULL, 0)) 4196 if (__glibc_unlikely (new_array == NULL))
4385 return NULL; 4197 return NULL;
4386 subtop->lasts = new_array; 4198 subtop->lasts = new_array;
4387 subtop->alasts = new_alasts; 4199 subtop->alasts = new_alasts;
4388 } 4200 }
4389 new_entry = calloc (1, sizeof (re_sub_match_last_t)); 4201 new_entry = calloc (1, sizeof (re_sub_match_last_t));
4390 if (BE (new_entry != NULL, 1)) 4202 if (__glibc_likely (new_entry != NULL))
4391 { 4203 {
4392 subtop->lasts[subtop->nlasts] = new_entry; 4204 subtop->lasts[subtop->nlasts] = new_entry;
4393 new_entry->node = node; 4205 new_entry->node = node;
@@ -4398,7 +4210,6 @@ match_ctx_add_sublast (re_sub_match_top_t *subtop, Idx node, Idx str_idx)
4398} 4210}
4399 4211
4400static void 4212static void
4401internal_function
4402sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, 4213sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts,
4403 re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx) 4214 re_dfastate_t **limited_sts, Idx last_node, Idx last_str_idx)
4404{ 4215{
diff --git a/gl/safe-read.c b/gl/safe-read.c
deleted file mode 100644
index 6a48c0c..0000000
--- a/gl/safe-read.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/* An interface to read and write that retries after interrupts.
2
3 Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2013 Free Software
4 Foundation, Inc.
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include <config.h>
20
21/* Specification. */
22#ifdef SAFE_WRITE
23# include "safe-write.h"
24#else
25# include "safe-read.h"
26#endif
27
28/* Get ssize_t. */
29#include <sys/types.h>
30#include <unistd.h>
31
32#include <errno.h>
33
34#ifdef EINTR
35# define IS_EINTR(x) ((x) == EINTR)
36#else
37# define IS_EINTR(x) 0
38#endif
39
40#include <limits.h>
41
42#ifdef SAFE_WRITE
43# define safe_rw safe_write
44# define rw write
45#else
46# define safe_rw safe_read
47# define rw read
48# undef const
49# define const /* empty */
50#endif
51
52/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if
53 interrupted. Return the actual number of bytes read(written), zero for EOF,
54 or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */
55size_t
56safe_rw (int fd, void const *buf, size_t count)
57{
58 /* Work around a bug in Tru64 5.1. Attempting to read more than
59 INT_MAX bytes fails with errno == EINVAL. See
60 <http://lists.gnu.org/archive/html/bug-gnu-utils/2002-04/msg00010.html>.
61 When decreasing COUNT, keep it block-aligned. */
62 enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
63
64 for (;;)
65 {
66 ssize_t result = rw (fd, buf, count);
67
68 if (0 <= result)
69 return result;
70 else if (IS_EINTR (errno))
71 continue;
72 else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count)
73 count = BUGGY_READ_MAXIMUM;
74 else
75 return result;
76 }
77}
diff --git a/gl/safe-read.h b/gl/safe-read.h
deleted file mode 100644
index 992b7a6..0000000
--- a/gl/safe-read.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/* An interface to read() that retries after interrupts.
2 Copyright (C) 2002, 2006, 2009-2013 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Some system calls may be interrupted and fail with errno = EINTR in the
18 following situations:
19 - The process is stopped and restarted (signal SIGSTOP and SIGCONT, user
20 types Ctrl-Z) on some platforms: Mac OS X.
21 - The process receives a signal for which a signal handler was installed
22 with sigaction() with an sa_flags field that does not contain
23 SA_RESTART.
24 - The process receives a signal for which a signal handler was installed
25 with signal() and for which no call to siginterrupt(sig,0) was done,
26 on some platforms: AIX, HP-UX, IRIX, OSF/1, Solaris.
27
28 This module provides a wrapper around read() that handles EINTR. */
29
30#include <stddef.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36
37#define SAFE_READ_ERROR ((size_t) -1)
38
39/* Read up to COUNT bytes at BUF from descriptor FD, retrying if interrupted.
40 Return the actual number of bytes read, zero for EOF, or SAFE_READ_ERROR
41 upon error. */
42extern size_t safe_read (int fd, void *buf, size_t count);
43
44
45#ifdef __cplusplus
46}
47#endif
diff --git a/gl/setenv.c b/gl/setenv.c
index 995a0f2..f0b8899 100644
--- a/gl/setenv.c
+++ b/gl/setenv.c
@@ -1,18 +1,18 @@
1/* Copyright (C) 1992, 1995-2003, 2005-2013 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2003, 2005-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#if !_LIBC 17#if !_LIBC
18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
@@ -72,7 +72,7 @@ __libc_lock_define_initialized (static, envlock)
72 values are from a small set. Outside glibc this will eat up all 72 values are from a small set. Outside glibc this will eat up all
73 memory after a while. */ 73 memory after a while. */
74#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \ 74#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \
75 && defined __GNUC__) 75 && (defined __GNUC__ || defined __clang__))
76# define USE_TSEARCH 1 76# define USE_TSEARCH 1
77# include <search.h> 77# include <search.h>
78typedef int (*compar_fn_t) (const void *, const void *); 78typedef int (*compar_fn_t) (const void *, const void *);
diff --git a/gl/setlocale-lock.c b/gl/setlocale-lock.c
new file mode 100644
index 0000000..b70ba09
--- /dev/null
+++ b/gl/setlocale-lock.c
@@ -0,0 +1,150 @@
1/* Return the internal lock used by setlocale_null_r.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#include <config.h>
20
21/* When it is known that the gl_get_setlocale_null_lock function is defined
22 by a dependency library, it should not be defined here. */
23#if OMIT_SETLOCALE_LOCK
24
25/* This declaration is solely to ensure that after preprocessing
26 this file is never empty. */
27typedef int dummy;
28
29#else
30
31/* This file defines the internal lock used by setlocale_null_r.
32 It is a separate compilation unit, so that only one copy of it is
33 present when linking statically. */
34
35/* Prohibit renaming this symbol. */
36# undef gl_get_setlocale_null_lock
37
38/* Macro for exporting a symbol (function, not variable) defined in this file,
39 when compiled into a shared library. */
40# ifndef DLL_EXPORTED
41# if HAVE_VISIBILITY
42 /* Override the effect of the compiler option '-fvisibility=hidden'. */
43# define DLL_EXPORTED __attribute__((__visibility__("default")))
44# elif defined _WIN32 || defined __CYGWIN__
45# define DLL_EXPORTED __declspec(dllexport)
46# else
47# define DLL_EXPORTED
48# endif
49# endif
50
51# if defined _WIN32 && !defined __CYGWIN__
52
53# define WIN32_LEAN_AND_MEAN /* avoid including junk */
54# include <windows.h>
55
56# include "windows-initguard.h"
57
58/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
59 because the latter is not guaranteed to be a stable ABI in the future. */
60
61/* Make sure the function gets exported from DLLs. */
62DLL_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
63
64static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
65static CRITICAL_SECTION lock;
66
67/* Returns the internal lock used by setlocale_null_r. */
68CRITICAL_SECTION *
69gl_get_setlocale_null_lock (void)
70{
71 if (!guard.done)
72 {
73 if (InterlockedIncrement (&guard.started) == 0)
74 {
75 /* This thread is the first one to need the lock. Initialize it. */
76 InitializeCriticalSection (&lock);
77 guard.done = 1;
78 }
79 else
80 {
81 /* Don't let guard.started grow and wrap around. */
82 InterlockedDecrement (&guard.started);
83 /* Yield the CPU while waiting for another thread to finish
84 initializing this mutex. */
85 while (!guard.done)
86 Sleep (0);
87 }
88 }
89 return &lock;
90}
91
92# elif HAVE_PTHREAD_API
93
94# include <pthread.h>
95
96static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
97
98/* Make sure the function gets exported from shared libraries. */
99DLL_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
100
101/* Returns the internal lock used by setlocale_null_r. */
102pthread_mutex_t *
103gl_get_setlocale_null_lock (void)
104{
105 return &mutex;
106}
107
108# elif HAVE_THREADS_H
109
110# include <threads.h>
111# include <stdlib.h>
112
113static int volatile init_needed = 1;
114static once_flag init_once = ONCE_FLAG_INIT;
115static mtx_t mutex;
116
117static void
118atomic_init (void)
119{
120 if (mtx_init (&mutex, mtx_plain) != thrd_success)
121 abort ();
122 init_needed = 0;
123}
124
125/* Make sure the function gets exported from shared libraries. */
126DLL_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
127
128/* Returns the internal lock used by setlocale_null_r. */
129mtx_t *
130gl_get_setlocale_null_lock (void)
131{
132 if (init_needed)
133 call_once (&init_once, atomic_init);
134 return &mutex;
135}
136
137# endif
138
139# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
140/* Make sure the '__declspec(dllimport)' in setlocale_null.c does not cause
141 a link failure when no DLLs are involved. */
142# if defined _WIN64 || defined _LP64
143# define IMP(x) __imp_##x
144# else
145# define IMP(x) _imp__##x
146# endif
147void * IMP(gl_get_setlocale_null_lock) = &gl_get_setlocale_null_lock;
148# endif
149
150#endif
diff --git a/gl/setlocale_null.c b/gl/setlocale_null.c
new file mode 100644
index 0000000..6ac563d
--- /dev/null
+++ b/gl/setlocale_null.c
@@ -0,0 +1,411 @@
1/* Query the name of the current global locale.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#include <config.h>
20
21/* Specification. */
22#include "setlocale_null.h"
23
24#include <errno.h>
25#include <locale.h>
26#include <stdlib.h>
27#include <string.h>
28#if defined _WIN32 && !defined __CYGWIN__
29# include <wchar.h>
30#endif
31
32#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE)
33# if defined _WIN32 && !defined __CYGWIN__
34
35# define WIN32_LEAN_AND_MEAN /* avoid including junk */
36# include <windows.h>
37
38# elif HAVE_PTHREAD_API
39
40# include <pthread.h>
41# if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
42# include <threads.h>
43# pragma weak thrd_exit
44# define c11_threads_in_use() (thrd_exit != NULL)
45# else
46# define c11_threads_in_use() 0
47# endif
48
49# elif HAVE_THREADS_H
50
51# include <threads.h>
52
53# endif
54#endif
55
56/* Use the system's setlocale() function, not the gnulib override, here. */
57#undef setlocale
58
59static const char *
60setlocale_null_androidfix (int category)
61{
62 const char *result = setlocale (category, NULL);
63
64#ifdef __ANDROID__
65 if (result == NULL)
66 switch (category)
67 {
68 case LC_CTYPE:
69 case LC_NUMERIC:
70 case LC_TIME:
71 case LC_COLLATE:
72 case LC_MONETARY:
73 case LC_MESSAGES:
74 case LC_ALL:
75 case LC_PAPER:
76 case LC_NAME:
77 case LC_ADDRESS:
78 case LC_TELEPHONE:
79 case LC_MEASUREMENT:
80 result = "C";
81 break;
82 default:
83 break;
84 }
85#endif
86
87 return result;
88}
89
90static int
91setlocale_null_unlocked (int category, char *buf, size_t bufsize)
92{
93#if defined _WIN32 && !defined __CYGWIN__ && defined _MSC_VER
94 /* On native Windows, nowadays, the setlocale() implementation is based
95 on _wsetlocale() and uses malloc() for the result. We are better off
96 using _wsetlocale() directly. */
97 const wchar_t *result = _wsetlocale (category, NULL);
98
99 if (result == NULL)
100 {
101 /* CATEGORY is invalid. */
102 if (bufsize > 0)
103 /* Return an empty string in BUF.
104 This is a convenience for callers that don't want to write explicit
105 code for handling EINVAL. */
106 buf[0] = '\0';
107 return EINVAL;
108 }
109 else
110 {
111 size_t length = wcslen (result);
112 if (length < bufsize)
113 {
114 size_t i;
115
116 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
117 for (i = 0; i <= length; i++)
118 buf[i] = result[i];
119
120 return 0;
121 }
122 else
123 {
124 if (bufsize > 0)
125 {
126 /* Return a truncated result in BUF.
127 This is a convenience for callers that don't want to write
128 explicit code for handling ERANGE. */
129 size_t i;
130
131 /* Convert wchar_t[] -> char[], assuming plain ASCII. */
132 for (i = 0; i < bufsize; i++)
133 buf[i] = result[i];
134 buf[bufsize - 1] = '\0';
135 }
136 return ERANGE;
137 }
138 }
139#else
140 const char *result = setlocale_null_androidfix (category);
141
142 if (result == NULL)
143 {
144 /* CATEGORY is invalid. */
145 if (bufsize > 0)
146 /* Return an empty string in BUF.
147 This is a convenience for callers that don't want to write explicit
148 code for handling EINVAL. */
149 buf[0] = '\0';
150 return EINVAL;
151 }
152 else
153 {
154 size_t length = strlen (result);
155 if (length < bufsize)
156 {
157 memcpy (buf, result, length + 1);
158 return 0;
159 }
160 else
161 {
162 if (bufsize > 0)
163 {
164 /* Return a truncated result in BUF.
165 This is a convenience for callers that don't want to write
166 explicit code for handling ERANGE. */
167 memcpy (buf, result, bufsize - 1);
168 buf[bufsize - 1] = '\0';
169 }
170 return ERANGE;
171 }
172 }
173#endif
174}
175
176#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */
177
178/* Use a lock, so that no two threads can invoke setlocale_null_unlocked
179 at the same time. */
180
181/* Prohibit renaming this symbol. */
182# undef gl_get_setlocale_null_lock
183
184# if defined _WIN32 && !defined __CYGWIN__
185
186extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
187
188static int
189setlocale_null_with_lock (int category, char *buf, size_t bufsize)
190{
191 CRITICAL_SECTION *lock = gl_get_setlocale_null_lock ();
192 int ret;
193
194 EnterCriticalSection (lock);
195 ret = setlocale_null_unlocked (category, buf, bufsize);
196 LeaveCriticalSection (lock);
197
198 return ret;
199}
200
201# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */
202
203extern
204# if defined _WIN32 || defined __CYGWIN__
205 __declspec(dllimport)
206# endif
207 pthread_mutex_t *gl_get_setlocale_null_lock (void);
208
209# if HAVE_WEAK_SYMBOLS /* musl libc, FreeBSD, NetBSD, OpenBSD, Haiku */
210
211 /* Avoid the need to link with '-lpthread'. */
212# pragma weak pthread_mutex_lock
213# pragma weak pthread_mutex_unlock
214
215 /* Determine whether libpthread is in use. */
216# pragma weak pthread_mutexattr_gettype
217 /* See the comments in lock.h. */
218# define pthread_in_use() \
219 (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
220
221# else
222# define pthread_in_use() 1
223# endif
224
225static int
226setlocale_null_with_lock (int category, char *buf, size_t bufsize)
227{
228 if (pthread_in_use())
229 {
230 pthread_mutex_t *lock = gl_get_setlocale_null_lock ();
231 int ret;
232
233 if (pthread_mutex_lock (lock))
234 abort ();
235 ret = setlocale_null_unlocked (category, buf, bufsize);
236 if (pthread_mutex_unlock (lock))
237 abort ();
238
239 return ret;
240 }
241 else
242 return setlocale_null_unlocked (category, buf, bufsize);
243}
244
245# elif HAVE_THREADS_H
246
247extern mtx_t *gl_get_setlocale_null_lock (void);
248
249static int
250setlocale_null_with_lock (int category, char *buf, size_t bufsize)
251{
252 mtx_t *lock = gl_get_setlocale_null_lock ();
253 int ret;
254
255 if (mtx_lock (lock) != thrd_success)
256 abort ();
257 ret = setlocale_null_unlocked (category, buf, bufsize);
258 if (mtx_unlock (lock) != thrd_success)
259 abort ();
260
261 return ret;
262}
263
264# endif
265
266#endif
267
268int
269setlocale_null_r (int category, char *buf, size_t bufsize)
270{
271#if SETLOCALE_NULL_ALL_MTSAFE
272# if SETLOCALE_NULL_ONE_MTSAFE
273
274 return setlocale_null_unlocked (category, buf, bufsize);
275
276# else
277
278 if (category == LC_ALL)
279 return setlocale_null_unlocked (category, buf, bufsize);
280 else
281 return setlocale_null_with_lock (category, buf, bufsize);
282
283# endif
284#else
285# if SETLOCALE_NULL_ONE_MTSAFE
286
287 if (category == LC_ALL)
288 return setlocale_null_with_lock (category, buf, bufsize);
289 else
290 return setlocale_null_unlocked (category, buf, bufsize);
291
292# else
293
294 return setlocale_null_with_lock (category, buf, bufsize);
295
296# endif
297#endif
298}
299
300const char *
301setlocale_null (int category)
302{
303#if SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE
304 return setlocale_null_androidfix (category);
305#else
306
307 /* This call must be multithread-safe. To achieve this without using
308 thread-local storage:
309 1. We use a specific static buffer for each possible CATEGORY
310 argument. So that different threads can call setlocale_mtsafe
311 with different CATEGORY arguments, without interfering.
312 2. We use a simple strcpy or memcpy to fill this static buffer.
313 Filling it through, for example, strcpy + strcat would not be
314 guaranteed to leave the buffer's contents intact if another thread
315 is currently accessing it. If necessary, the contents is first
316 assembled in a stack-allocated buffer. */
317 if (category == LC_ALL)
318 {
319# if SETLOCALE_NULL_ALL_MTSAFE
320 return setlocale_null_androidfix (LC_ALL);
321# else
322 char buf[SETLOCALE_NULL_ALL_MAX];
323 static char resultbuf[SETLOCALE_NULL_ALL_MAX];
324
325 if (setlocale_null_r (LC_ALL, buf, sizeof (buf)))
326 return "C";
327 strcpy (resultbuf, buf);
328 return resultbuf;
329# endif
330 }
331 else
332 {
333# if SETLOCALE_NULL_ONE_MTSAFE
334 return setlocale_null_androidfix (category);
335# else
336 enum
337 {
338 LC_CTYPE_INDEX,
339 LC_NUMERIC_INDEX,
340 LC_TIME_INDEX,
341 LC_COLLATE_INDEX,
342 LC_MONETARY_INDEX,
343 LC_MESSAGES_INDEX,
344# ifdef LC_PAPER
345 LC_PAPER_INDEX,
346# endif
347# ifdef LC_NAME
348 LC_NAME_INDEX,
349# endif
350# ifdef LC_ADDRESS
351 LC_ADDRESS_INDEX,
352# endif
353# ifdef LC_TELEPHONE
354 LC_TELEPHONE_INDEX,
355# endif
356# ifdef LC_MEASUREMENT
357 LC_MEASUREMENT_INDEX,
358# endif
359# ifdef LC_IDENTIFICATION
360 LC_IDENTIFICATION_INDEX,
361# endif
362 LC_INDICES_COUNT
363 }
364 i;
365 char buf[SETLOCALE_NULL_MAX];
366 static char resultbuf[LC_INDICES_COUNT][SETLOCALE_NULL_MAX];
367 int err;
368
369 err = setlocale_null_r (category, buf, sizeof (buf));
370 if (err == EINVAL)
371 return NULL;
372 if (err)
373 return "C";
374
375 switch (category)
376 {
377 case LC_CTYPE: i = LC_CTYPE_INDEX; break;
378 case LC_NUMERIC: i = LC_NUMERIC_INDEX; break;
379 case LC_TIME: i = LC_TIME_INDEX; break;
380 case LC_COLLATE: i = LC_COLLATE_INDEX; break;
381 case LC_MONETARY: i = LC_MONETARY_INDEX; break;
382 case LC_MESSAGES: i = LC_MESSAGES_INDEX; break;
383# ifdef LC_PAPER
384 case LC_PAPER: i = LC_PAPER_INDEX; break;
385# endif
386# ifdef LC_NAME
387 case LC_NAME: i = LC_NAME_INDEX; break;
388# endif
389# ifdef LC_ADDRESS
390 case LC_ADDRESS: i = LC_ADDRESS_INDEX; break;
391# endif
392# ifdef LC_TELEPHONE
393 case LC_TELEPHONE: i = LC_TELEPHONE_INDEX; break;
394# endif
395# ifdef LC_MEASUREMENT
396 case LC_MEASUREMENT: i = LC_MEASUREMENT_INDEX; break;
397# endif
398# ifdef LC_IDENTIFICATION
399 case LC_IDENTIFICATION: i = LC_IDENTIFICATION_INDEX; break;
400# endif
401 default:
402 /* If you get here, a #ifdef LC_xxx is missing. */
403 abort ();
404 }
405
406 strcpy (resultbuf[i], buf);
407 return resultbuf[i];
408# endif
409 }
410#endif
411}
diff --git a/gl/setlocale_null.h b/gl/setlocale_null.h
new file mode 100644
index 0000000..c740fa0
--- /dev/null
+++ b/gl/setlocale_null.h
@@ -0,0 +1,82 @@
1/* Query the name of the current global locale.
2 Copyright (C) 2019-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2019. */
18
19#ifndef _SETLOCALE_NULL_H
20#define _SETLOCALE_NULL_H
21
22#include <stddef.h>
23
24#include "arg-nonnull.h"
25
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31
32/* Recommended size of a buffer for a locale name for a single category.
33 On glibc systems, you can have locale names that are relative file names;
34 assume a maximum length 256.
35 In native Windows, in 2018 the longest locale name was of length 58
36 ("FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251"). */
37#define SETLOCALE_NULL_MAX (256+1)
38
39/* Recommended size of a buffer for a locale name with all categories.
40 On glibc systems, you can have locale names that are relative file names;
41 assume maximum length 256 for each. There are 12 categories; so, the
42 maximum total length is 148+12*256.
43 In native Windows, there are 5 categories, and the maximum total length is
44 55+5*58. */
45#define SETLOCALE_NULL_ALL_MAX (148+12*256+1)
46
47/* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
48 except that
49 - it is guaranteed to be multithread-safe,
50 - it returns the resulting locale category name or locale name in the
51 user-supplied buffer BUF, which must be BUFSIZE bytes long.
52 The recommended minimum buffer size is
53 - SETLOCALE_NULL_MAX for CATEGORY != LC_ALL, and
54 - SETLOCALE_NULL_ALL_MAX for CATEGORY == LC_ALL.
55 The return value is an error code: 0 if the call is successful, EINVAL if
56 CATEGORY is invalid, or ERANGE if BUFSIZE is smaller than the length needed
57 size (including the trailing NUL byte). In the latter case, a truncated
58 result is returned in BUF, but still NUL-terminated if BUFSIZE > 0.
59 For this call to be multithread-safe, *all* calls to
60 setlocale (CATEGORY, NULL) in all other threads must have been converted
61 to use setlocale_null_r or setlocale_null as well, and the other threads
62 must not make other setlocale invocations (since changing the global locale
63 has side effects on all threads). */
64extern int setlocale_null_r (int category, char *buf, size_t bufsize)
65 _GL_ARG_NONNULL ((2));
66
67/* setlocale_null (CATEGORY) is like setlocale (CATEGORY, NULL), except that
68 it is guaranteed to be multithread-safe.
69 The return value is NULL if CATEGORY is invalid.
70 For this call to be multithread-safe, *all* calls to
71 setlocale (CATEGORY, NULL) in all other threads must have been converted
72 to use setlocale_null_r or setlocale_null as well, and the other threads
73 must not make other setlocale invocations (since changing the global locale
74 has side effects on all threads). */
75extern const char *setlocale_null (int category);
76
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif /* _SETLOCALE_NULL_H */
diff --git a/gl/sha1.c b/gl/sha1.c
deleted file mode 100644
index 778389a..0000000
--- a/gl/sha1.c
+++ /dev/null
@@ -1,426 +0,0 @@
1/* sha1.c - Functions to compute SHA1 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-1.
3
4 Copyright (C) 2000-2001, 2003-2006, 2008-2013 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19/* Written by Scott G. Miller
20 Credits:
21 Robert Klep <robert@ilse.nl> -- Expansion function fix
22*/
23
24#include <config.h>
25
26#include "sha1.h"
27
28#include <stdalign.h>
29#include <stdint.h>
30#include <stdlib.h>
31#include <string.h>
32
33#if USE_UNLOCKED_IO
34# include "unlocked-io.h"
35#endif
36
37#ifdef WORDS_BIGENDIAN
38# define SWAP(n) (n)
39#else
40# define SWAP(n) \
41 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
42#endif
43
44#define BLOCKSIZE 32768
45#if BLOCKSIZE % 64 != 0
46# error "invalid BLOCKSIZE"
47#endif
48
49/* This array contains the bytes used to pad the buffer to the next
50 64-byte boundary. (RFC 1321, 3.1: Step 1) */
51static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
52
53
54/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
55 initialize it to the start constants of the SHA1 algorithm. This
56 must be called before using hash in the call to sha1_hash. */
57void
58sha1_init_ctx (struct sha1_ctx *ctx)
59{
60 ctx->A = 0x67452301;
61 ctx->B = 0xefcdab89;
62 ctx->C = 0x98badcfe;
63 ctx->D = 0x10325476;
64 ctx->E = 0xc3d2e1f0;
65
66 ctx->total[0] = ctx->total[1] = 0;
67 ctx->buflen = 0;
68}
69
70/* Copy the 4 byte value from v into the memory location pointed to by *cp,
71 If your architecture allows unaligned access this is equivalent to
72 * (uint32_t *) cp = v */
73static void
74set_uint32 (char *cp, uint32_t v)
75{
76 memcpy (cp, &v, sizeof v);
77}
78
79/* Put result from CTX in first 20 bytes following RESBUF. The result
80 must be in little endian byte order. */
81void *
82sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
83{
84 char *r = resbuf;
85 set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
86 set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
87 set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
88 set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
89 set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E));
90
91 return resbuf;
92}
93
94/* Process the remaining bytes in the internal buffer and the usual
95 prolog according to the standard and write the result to RESBUF. */
96void *
97sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
98{
99 /* Take yet unprocessed bytes into account. */
100 uint32_t bytes = ctx->buflen;
101 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
102
103 /* Now count remaining bytes. */
104 ctx->total[0] += bytes;
105 if (ctx->total[0] < bytes)
106 ++ctx->total[1];
107
108 /* Put the 64-bit file length in *bits* at the end of the buffer. */
109 ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
110 ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
111
112 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
113
114 /* Process last bytes. */
115 sha1_process_block (ctx->buffer, size * 4, ctx);
116
117 return sha1_read_ctx (ctx, resbuf);
118}
119
120/* Compute SHA1 message digest for bytes read from STREAM. The
121 resulting message digest number will be written into the 16 bytes
122 beginning at RESBLOCK. */
123int
124sha1_stream (FILE *stream, void *resblock)
125{
126 struct sha1_ctx ctx;
127 size_t sum;
128
129 char *buffer = malloc (BLOCKSIZE + 72);
130 if (!buffer)
131 return 1;
132
133 /* Initialize the computation context. */
134 sha1_init_ctx (&ctx);
135
136 /* Iterate over full file contents. */
137 while (1)
138 {
139 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
140 computation function processes the whole buffer so that with the
141 next round of the loop another block can be read. */
142 size_t n;
143 sum = 0;
144
145 /* Read block. Take care for partial reads. */
146 while (1)
147 {
148 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
149
150 sum += n;
151
152 if (sum == BLOCKSIZE)
153 break;
154
155 if (n == 0)
156 {
157 /* Check for the error flag IFF N == 0, so that we don't
158 exit the loop after a partial read due to e.g., EAGAIN
159 or EWOULDBLOCK. */
160 if (ferror (stream))
161 {
162 free (buffer);
163 return 1;
164 }
165 goto process_partial_block;
166 }
167
168 /* We've read at least one byte, so ignore errors. But always
169 check for EOF, since feof may be true even though N > 0.
170 Otherwise, we could end up calling fread after EOF. */
171 if (feof (stream))
172 goto process_partial_block;
173 }
174
175 /* Process buffer with BLOCKSIZE bytes. Note that
176 BLOCKSIZE % 64 == 0
177 */
178 sha1_process_block (buffer, BLOCKSIZE, &ctx);
179 }
180
181 process_partial_block:;
182
183 /* Process any remaining bytes. */
184 if (sum > 0)
185 sha1_process_bytes (buffer, sum, &ctx);
186
187 /* Construct result in desired memory. */
188 sha1_finish_ctx (&ctx, resblock);
189 free (buffer);
190 return 0;
191}
192
193/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
194 result is always in little endian byte order, so that a byte-wise
195 output yields to the wanted ASCII representation of the message
196 digest. */
197void *
198sha1_buffer (const char *buffer, size_t len, void *resblock)
199{
200 struct sha1_ctx ctx;
201
202 /* Initialize the computation context. */
203 sha1_init_ctx (&ctx);
204
205 /* Process whole buffer but last len % 64 bytes. */
206 sha1_process_bytes (buffer, len, &ctx);
207
208 /* Put result in desired memory area. */
209 return sha1_finish_ctx (&ctx, resblock);
210}
211
212void
213sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
214{
215 /* When we already have some bits in our internal buffer concatenate
216 both inputs first. */
217 if (ctx->buflen != 0)
218 {
219 size_t left_over = ctx->buflen;
220 size_t add = 128 - left_over > len ? len : 128 - left_over;
221
222 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
223 ctx->buflen += add;
224
225 if (ctx->buflen > 64)
226 {
227 sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
228
229 ctx->buflen &= 63;
230 /* The regions in the following copy operation cannot overlap. */
231 memcpy (ctx->buffer,
232 &((char *) ctx->buffer)[(left_over + add) & ~63],
233 ctx->buflen);
234 }
235
236 buffer = (const char *) buffer + add;
237 len -= add;
238 }
239
240 /* Process available complete blocks. */
241 if (len >= 64)
242 {
243#if !_STRING_ARCH_unaligned
244# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
245 if (UNALIGNED_P (buffer))
246 while (len > 64)
247 {
248 sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
249 buffer = (const char *) buffer + 64;
250 len -= 64;
251 }
252 else
253#endif
254 {
255 sha1_process_block (buffer, len & ~63, ctx);
256 buffer = (const char *) buffer + (len & ~63);
257 len &= 63;
258 }
259 }
260
261 /* Move remaining bytes in internal buffer. */
262 if (len > 0)
263 {
264 size_t left_over = ctx->buflen;
265
266 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
267 left_over += len;
268 if (left_over >= 64)
269 {
270 sha1_process_block (ctx->buffer, 64, ctx);
271 left_over -= 64;
272 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
273 }
274 ctx->buflen = left_over;
275 }
276}
277
278/* --- Code below is the primary difference between md5.c and sha1.c --- */
279
280/* SHA1 round constants */
281#define K1 0x5a827999
282#define K2 0x6ed9eba1
283#define K3 0x8f1bbcdc
284#define K4 0xca62c1d6
285
286/* Round functions. Note that F2 is the same as F4. */
287#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
288#define F2(B,C,D) (B ^ C ^ D)
289#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
290#define F4(B,C,D) (B ^ C ^ D)
291
292/* Process LEN bytes of BUFFER, accumulating context into CTX.
293 It is assumed that LEN % 64 == 0.
294 Most of this code comes from GnuPG's cipher/sha1.c. */
295
296void
297sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
298{
299 const uint32_t *words = buffer;
300 size_t nwords = len / sizeof (uint32_t);
301 const uint32_t *endp = words + nwords;
302 uint32_t x[16];
303 uint32_t a = ctx->A;
304 uint32_t b = ctx->B;
305 uint32_t c = ctx->C;
306 uint32_t d = ctx->D;
307 uint32_t e = ctx->E;
308 uint32_t lolen = len;
309
310 /* First increment the byte count. RFC 1321 specifies the possible
311 length of the file up to 2^64 bits. Here we only compute the
312 number of bytes. Do a double word increment. */
313 ctx->total[0] += lolen;
314 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
315
316#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
317
318#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
319 ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
320 , (x[I&0x0f] = rol(tm, 1)) )
321
322#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
323 + F( B, C, D ) \
324 + K \
325 + M; \
326 B = rol( B, 30 ); \
327 } while(0)
328
329 while (words < endp)
330 {
331 uint32_t tm;
332 int t;
333 for (t = 0; t < 16; t++)
334 {
335 x[t] = SWAP (*words);
336 words++;
337 }
338
339 R( a, b, c, d, e, F1, K1, x[ 0] );
340 R( e, a, b, c, d, F1, K1, x[ 1] );
341 R( d, e, a, b, c, F1, K1, x[ 2] );
342 R( c, d, e, a, b, F1, K1, x[ 3] );
343 R( b, c, d, e, a, F1, K1, x[ 4] );
344 R( a, b, c, d, e, F1, K1, x[ 5] );
345 R( e, a, b, c, d, F1, K1, x[ 6] );
346 R( d, e, a, b, c, F1, K1, x[ 7] );
347 R( c, d, e, a, b, F1, K1, x[ 8] );
348 R( b, c, d, e, a, F1, K1, x[ 9] );
349 R( a, b, c, d, e, F1, K1, x[10] );
350 R( e, a, b, c, d, F1, K1, x[11] );
351 R( d, e, a, b, c, F1, K1, x[12] );
352 R( c, d, e, a, b, F1, K1, x[13] );
353 R( b, c, d, e, a, F1, K1, x[14] );
354 R( a, b, c, d, e, F1, K1, x[15] );
355 R( e, a, b, c, d, F1, K1, M(16) );
356 R( d, e, a, b, c, F1, K1, M(17) );
357 R( c, d, e, a, b, F1, K1, M(18) );
358 R( b, c, d, e, a, F1, K1, M(19) );
359 R( a, b, c, d, e, F2, K2, M(20) );
360 R( e, a, b, c, d, F2, K2, M(21) );
361 R( d, e, a, b, c, F2, K2, M(22) );
362 R( c, d, e, a, b, F2, K2, M(23) );
363 R( b, c, d, e, a, F2, K2, M(24) );
364 R( a, b, c, d, e, F2, K2, M(25) );
365 R( e, a, b, c, d, F2, K2, M(26) );
366 R( d, e, a, b, c, F2, K2, M(27) );
367 R( c, d, e, a, b, F2, K2, M(28) );
368 R( b, c, d, e, a, F2, K2, M(29) );
369 R( a, b, c, d, e, F2, K2, M(30) );
370 R( e, a, b, c, d, F2, K2, M(31) );
371 R( d, e, a, b, c, F2, K2, M(32) );
372 R( c, d, e, a, b, F2, K2, M(33) );
373 R( b, c, d, e, a, F2, K2, M(34) );
374 R( a, b, c, d, e, F2, K2, M(35) );
375 R( e, a, b, c, d, F2, K2, M(36) );
376 R( d, e, a, b, c, F2, K2, M(37) );
377 R( c, d, e, a, b, F2, K2, M(38) );
378 R( b, c, d, e, a, F2, K2, M(39) );
379 R( a, b, c, d, e, F3, K3, M(40) );
380 R( e, a, b, c, d, F3, K3, M(41) );
381 R( d, e, a, b, c, F3, K3, M(42) );
382 R( c, d, e, a, b, F3, K3, M(43) );
383 R( b, c, d, e, a, F3, K3, M(44) );
384 R( a, b, c, d, e, F3, K3, M(45) );
385 R( e, a, b, c, d, F3, K3, M(46) );
386 R( d, e, a, b, c, F3, K3, M(47) );
387 R( c, d, e, a, b, F3, K3, M(48) );
388 R( b, c, d, e, a, F3, K3, M(49) );
389 R( a, b, c, d, e, F3, K3, M(50) );
390 R( e, a, b, c, d, F3, K3, M(51) );
391 R( d, e, a, b, c, F3, K3, M(52) );
392 R( c, d, e, a, b, F3, K3, M(53) );
393 R( b, c, d, e, a, F3, K3, M(54) );
394 R( a, b, c, d, e, F3, K3, M(55) );
395 R( e, a, b, c, d, F3, K3, M(56) );
396 R( d, e, a, b, c, F3, K3, M(57) );
397 R( c, d, e, a, b, F3, K3, M(58) );
398 R( b, c, d, e, a, F3, K3, M(59) );
399 R( a, b, c, d, e, F4, K4, M(60) );
400 R( e, a, b, c, d, F4, K4, M(61) );
401 R( d, e, a, b, c, F4, K4, M(62) );
402 R( c, d, e, a, b, F4, K4, M(63) );
403 R( b, c, d, e, a, F4, K4, M(64) );
404 R( a, b, c, d, e, F4, K4, M(65) );
405 R( e, a, b, c, d, F4, K4, M(66) );
406 R( d, e, a, b, c, F4, K4, M(67) );
407 R( c, d, e, a, b, F4, K4, M(68) );
408 R( b, c, d, e, a, F4, K4, M(69) );
409 R( a, b, c, d, e, F4, K4, M(70) );
410 R( e, a, b, c, d, F4, K4, M(71) );
411 R( d, e, a, b, c, F4, K4, M(72) );
412 R( c, d, e, a, b, F4, K4, M(73) );
413 R( b, c, d, e, a, F4, K4, M(74) );
414 R( a, b, c, d, e, F4, K4, M(75) );
415 R( e, a, b, c, d, F4, K4, M(76) );
416 R( d, e, a, b, c, F4, K4, M(77) );
417 R( c, d, e, a, b, F4, K4, M(78) );
418 R( b, c, d, e, a, F4, K4, M(79) );
419
420 a = ctx->A += a;
421 b = ctx->B += b;
422 c = ctx->C += c;
423 d = ctx->D += d;
424 e = ctx->E += e;
425 }
426}
diff --git a/gl/sha1.h b/gl/sha1.h
deleted file mode 100644
index ddd386f..0000000
--- a/gl/sha1.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/* Declarations of functions and data types used for SHA1 sum
2 library functions.
3 Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2013 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef SHA1_H
20# define SHA1_H 1
21
22# include <stdio.h>
23# include <stdint.h>
24
25# ifdef __cplusplus
26extern "C" {
27# endif
28
29#define SHA1_DIGEST_SIZE 20
30
31/* Structure to save state of computation between the single steps. */
32struct sha1_ctx
33{
34 uint32_t A;
35 uint32_t B;
36 uint32_t C;
37 uint32_t D;
38 uint32_t E;
39
40 uint32_t total[2];
41 uint32_t buflen;
42 uint32_t buffer[32];
43};
44
45
46/* Initialize structure containing state of computation. */
47extern void sha1_init_ctx (struct sha1_ctx *ctx);
48
49/* Starting with the result of former calls of this function (or the
50 initialization function update the context for the next LEN bytes
51 starting at BUFFER.
52 It is necessary that LEN is a multiple of 64!!! */
53extern void sha1_process_block (const void *buffer, size_t len,
54 struct sha1_ctx *ctx);
55
56/* Starting with the result of former calls of this function (or the
57 initialization function update the context for the next LEN bytes
58 starting at BUFFER.
59 It is NOT required that LEN is a multiple of 64. */
60extern void sha1_process_bytes (const void *buffer, size_t len,
61 struct sha1_ctx *ctx);
62
63/* Process the remaining bytes in the buffer and put result from CTX
64 in first 20 bytes following RESBUF. The result is always in little
65 endian byte order, so that a byte-wise output yields to the wanted
66 ASCII representation of the message digest. */
67extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
68
69
70/* Put result from CTX in first 20 bytes following RESBUF. The result is
71 always in little endian byte order, so that a byte-wise output yields
72 to the wanted ASCII representation of the message digest. */
73extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
74
75
76/* Compute SHA1 message digest for bytes read from STREAM. The
77 resulting message digest number will be written into the 20 bytes
78 beginning at RESBLOCK. */
79extern int sha1_stream (FILE *stream, void *resblock);
80
81/* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
82 result is always in little endian byte order, so that a byte-wise
83 output yields to the wanted ASCII representation of the message
84 digest. */
85extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
86
87# ifdef __cplusplus
88}
89# endif
90
91#endif
diff --git a/gl/sha256-stream.c b/gl/sha256-stream.c
new file mode 100644
index 0000000..0e83380
--- /dev/null
+++ b/gl/sha256-stream.c
@@ -0,0 +1,145 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2.
3
4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* Written by David Madore, considerably copypasting from
20 Scott G. Miller's sha1.c
21*/
22
23#include <config.h>
24
25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h"
30
31#include <stdlib.h>
32
33#if USE_UNLOCKED_IO
34# include "unlocked-io.h"
35#endif
36
37#include "af_alg.h"
38
39#define BLOCKSIZE 32768
40#if BLOCKSIZE % 64 != 0
41# error "invalid BLOCKSIZE"
42#endif
43
44/* Compute message digest for bytes read from STREAM using algorithm ALG.
45 Write the message digest into RESBLOCK, which contains HASHLEN bytes.
46 The initial and finishing operations are INIT_CTX and FINISH_CTX.
47 Return zero if and only if successful. */
48static int
49shaxxx_stream (FILE *stream, char const *alg, void *resblock,
50 ssize_t hashlen, void (*init_ctx) (struct sha256_ctx *),
51 void *(*finish_ctx) (struct sha256_ctx *, void *))
52{
53 switch (afalg_stream (stream, alg, resblock, hashlen))
54 {
55 case 0: return 0;
56 case -EIO: return 1;
57 }
58
59 char *buffer = malloc (BLOCKSIZE + 72);
60 if (!buffer)
61 return 1;
62
63 struct sha256_ctx ctx;
64 init_ctx (&ctx);
65 size_t sum;
66
67 /* Iterate over full file contents. */
68 while (1)
69 {
70 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
71 computation function processes the whole buffer so that with the
72 next round of the loop another block can be read. */
73 size_t n;
74 sum = 0;
75
76 /* Read block. Take care for partial reads. */
77 while (1)
78 {
79 /* Either process a partial fread() from this loop,
80 or the fread() in afalg_stream may have gotten EOF.
81 We need to avoid a subsequent fread() as EOF may
82 not be sticky. For details of such systems, see:
83 https://sourceware.org/bugzilla/show_bug.cgi?id=1190 */
84 if (feof (stream))
85 goto process_partial_block;
86
87 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
88
89 sum += n;
90
91 if (sum == BLOCKSIZE)
92 break;
93
94 if (n == 0)
95 {
96 /* Check for the error flag IFF N == 0, so that we don't
97 exit the loop after a partial read due to e.g., EAGAIN
98 or EWOULDBLOCK. */
99 if (ferror (stream))
100 {
101 free (buffer);
102 return 1;
103 }
104 goto process_partial_block;
105 }
106 }
107
108 /* Process buffer with BLOCKSIZE bytes. Note that
109 BLOCKSIZE % 64 == 0
110 */
111 sha256_process_block (buffer, BLOCKSIZE, &ctx);
112 }
113
114 process_partial_block:;
115
116 /* Process any remaining bytes. */
117 if (sum > 0)
118 sha256_process_bytes (buffer, sum, &ctx);
119
120 /* Construct result in desired memory. */
121 finish_ctx (&ctx, resblock);
122 free (buffer);
123 return 0;
124}
125
126int
127sha256_stream (FILE *stream, void *resblock)
128{
129 return shaxxx_stream (stream, "sha256", resblock, SHA256_DIGEST_SIZE,
130 sha256_init_ctx, sha256_finish_ctx);
131}
132
133int
134sha224_stream (FILE *stream, void *resblock)
135{
136 return shaxxx_stream (stream, "sha224", resblock, SHA224_DIGEST_SIZE,
137 sha224_init_ctx, sha224_finish_ctx);
138}
139
140/*
141 * Hey Emacs!
142 * Local Variables:
143 * coding: utf-8
144 * End:
145 */
diff --git a/gl/sha256.c b/gl/sha256.c
new file mode 100644
index 0000000..e5fea02
--- /dev/null
+++ b/gl/sha256.c
@@ -0,0 +1,432 @@
1/* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-2.
3
4 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19/* Written by David Madore, considerably copypasting from
20 Scott G. Miller's sha1.c
21*/
22
23#include <config.h>
24
25/* Specification. */
26#if HAVE_OPENSSL_SHA256
27# define GL_OPENSSL_INLINE _GL_EXTERN_INLINE
28#endif
29#include "sha256.h"
30
31#include <stdint.h>
32#include <string.h>
33
34#include <byteswap.h>
35#ifdef WORDS_BIGENDIAN
36# define SWAP(n) (n)
37#else
38# define SWAP(n) bswap_32 (n)
39#endif
40
41#if ! HAVE_OPENSSL_SHA256
42
43/* This array contains the bytes used to pad the buffer to the next
44 64-byte boundary. */
45static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
46
47
48/*
49 Takes a pointer to a 256 bit block of data (eight 32 bit ints) and
50 initializes it to the start constants of the SHA256 algorithm. This
51 must be called before using hash in the call to sha256_hash
52*/
53void
54sha256_init_ctx (struct sha256_ctx *ctx)
55{
56 ctx->state[0] = 0x6a09e667UL;
57 ctx->state[1] = 0xbb67ae85UL;
58 ctx->state[2] = 0x3c6ef372UL;
59 ctx->state[3] = 0xa54ff53aUL;
60 ctx->state[4] = 0x510e527fUL;
61 ctx->state[5] = 0x9b05688cUL;
62 ctx->state[6] = 0x1f83d9abUL;
63 ctx->state[7] = 0x5be0cd19UL;
64
65 ctx->total[0] = ctx->total[1] = 0;
66 ctx->buflen = 0;
67}
68
69void
70sha224_init_ctx (struct sha256_ctx *ctx)
71{
72 ctx->state[0] = 0xc1059ed8UL;
73 ctx->state[1] = 0x367cd507UL;
74 ctx->state[2] = 0x3070dd17UL;
75 ctx->state[3] = 0xf70e5939UL;
76 ctx->state[4] = 0xffc00b31UL;
77 ctx->state[5] = 0x68581511UL;
78 ctx->state[6] = 0x64f98fa7UL;
79 ctx->state[7] = 0xbefa4fa4UL;
80
81 ctx->total[0] = ctx->total[1] = 0;
82 ctx->buflen = 0;
83}
84
85/* Copy the value from v into the memory location pointed to by *CP,
86 If your architecture allows unaligned access, this is equivalent to
87 * (__typeof__ (v) *) cp = v */
88static void
89set_uint32 (char *cp, uint32_t v)
90{
91 memcpy (cp, &v, sizeof v);
92}
93
94/* Put result from CTX in first 32 bytes following RESBUF.
95 The result must be in little endian byte order. */
96void *
97sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
98{
99 int i;
100 char *r = resbuf;
101
102 for (i = 0; i < 8; i++)
103 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
104
105 return resbuf;
106}
107
108void *
109sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf)
110{
111 int i;
112 char *r = resbuf;
113
114 for (i = 0; i < 7; i++)
115 set_uint32 (r + i * sizeof ctx->state[0], SWAP (ctx->state[i]));
116
117 return resbuf;
118}
119
120/* Process the remaining bytes in the internal buffer and the usual
121 prolog according to the standard and write the result to RESBUF. */
122static void
123sha256_conclude_ctx (struct sha256_ctx *ctx)
124{
125 /* Take yet unprocessed bytes into account. */
126 size_t bytes = ctx->buflen;
127 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
128
129 /* Now count remaining bytes. */
130 ctx->total[0] += bytes;
131 if (ctx->total[0] < bytes)
132 ++ctx->total[1];
133
134 /* Put the 64-bit file length in *bits* at the end of the buffer.
135 Use set_uint32 rather than a simple assignment, to avoid risk of
136 unaligned access. */
137 set_uint32 ((char *) &ctx->buffer[size - 2],
138 SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)));
139 set_uint32 ((char *) &ctx->buffer[size - 1],
140 SWAP (ctx->total[0] << 3));
141
142 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
143
144 /* Process last bytes. */
145 sha256_process_block (ctx->buffer, size * 4, ctx);
146}
147
148void *
149sha256_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
150{
151 sha256_conclude_ctx (ctx);
152 return sha256_read_ctx (ctx, resbuf);
153}
154
155void *
156sha224_finish_ctx (struct sha256_ctx *ctx, void *resbuf)
157{
158 sha256_conclude_ctx (ctx);
159 return sha224_read_ctx (ctx, resbuf);
160}
161
162/* Compute SHA256 message digest for LEN bytes beginning at BUFFER. The
163 result is always in little endian byte order, so that a byte-wise
164 output yields to the wanted ASCII representation of the message
165 digest. */
166void *
167sha256_buffer (const char *buffer, size_t len, void *resblock)
168{
169 struct sha256_ctx ctx;
170
171 /* Initialize the computation context. */
172 sha256_init_ctx (&ctx);
173
174 /* Process whole buffer but last len % 64 bytes. */
175 sha256_process_bytes (buffer, len, &ctx);
176
177 /* Put result in desired memory area. */
178 return sha256_finish_ctx (&ctx, resblock);
179}
180
181void *
182sha224_buffer (const char *buffer, size_t len, void *resblock)
183{
184 struct sha256_ctx ctx;
185
186 /* Initialize the computation context. */
187 sha224_init_ctx (&ctx);
188
189 /* Process whole buffer but last len % 64 bytes. */
190 sha256_process_bytes (buffer, len, &ctx);
191
192 /* Put result in desired memory area. */
193 return sha224_finish_ctx (&ctx, resblock);
194}
195
196void
197sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx)
198{
199 /* When we already have some bits in our internal buffer concatenate
200 both inputs first. */
201 if (ctx->buflen != 0)
202 {
203 size_t left_over = ctx->buflen;
204 size_t add = 128 - left_over > len ? len : 128 - left_over;
205
206 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
207 ctx->buflen += add;
208
209 if (ctx->buflen > 64)
210 {
211 sha256_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
212
213 ctx->buflen &= 63;
214 /* The regions in the following copy operation cannot overlap,
215 because ctx->buflen < 64 ≤ (left_over + add) & ~63. */
216 memcpy (ctx->buffer,
217 &((char *) ctx->buffer)[(left_over + add) & ~63],
218 ctx->buflen);
219 }
220
221 buffer = (const char *) buffer + add;
222 len -= add;
223 }
224
225 /* Process available complete blocks. */
226 if (len >= 64)
227 {
228#if !(_STRING_ARCH_unaligned || _STRING_INLINE_unaligned)
229# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
230 if (UNALIGNED_P (buffer))
231 while (len > 64)
232 {
233 sha256_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
234 buffer = (const char *) buffer + 64;
235 len -= 64;
236 }
237 else
238#endif
239 {
240 sha256_process_block (buffer, len & ~63, ctx);
241 buffer = (const char *) buffer + (len & ~63);
242 len &= 63;
243 }
244 }
245
246 /* Move remaining bytes in internal buffer. */
247 if (len > 0)
248 {
249 size_t left_over = ctx->buflen;
250
251 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
252 left_over += len;
253 if (left_over >= 64)
254 {
255 sha256_process_block (ctx->buffer, 64, ctx);
256 left_over -= 64;
257 /* The regions in the following copy operation cannot overlap,
258 because left_over ≤ 64. */
259 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
260 }
261 ctx->buflen = left_over;
262 }
263}
264
265/* --- Code below is the primary difference between sha1.c and sha256.c --- */
266
267/* SHA256 round constants */
268#define K(I) sha256_round_constants[I]
269static const uint32_t sha256_round_constants[64] = {
270 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
271 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
272 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
273 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
274 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
275 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
276 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
277 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
278 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
279 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
280 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
281 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
282 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
283 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
284 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
285 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL,
286};
287
288/* Round functions. */
289#define F2(A,B,C) ( ( A & B ) | ( C & ( A | B ) ) )
290#define F1(E,F,G) ( G ^ ( E & ( F ^ G ) ) )
291
292/* Process LEN bytes of BUFFER, accumulating context into CTX.
293 It is assumed that LEN % 64 == 0.
294 Most of this code comes from GnuPG's cipher/sha1.c. */
295
296void
297sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx)
298{
299 const uint32_t *words = buffer;
300 size_t nwords = len / sizeof (uint32_t);
301 const uint32_t *endp = words + nwords;
302 uint32_t x[16];
303 uint32_t a = ctx->state[0];
304 uint32_t b = ctx->state[1];
305 uint32_t c = ctx->state[2];
306 uint32_t d = ctx->state[3];
307 uint32_t e = ctx->state[4];
308 uint32_t f = ctx->state[5];
309 uint32_t g = ctx->state[6];
310 uint32_t h = ctx->state[7];
311 uint32_t lolen = len;
312
313 /* First increment the byte count. FIPS PUB 180-2 specifies the possible
314 length of the file up to 2^64 bits. Here we only compute the
315 number of bytes. Do a double word increment. */
316 ctx->total[0] += lolen;
317 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
318
319#define rol(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
320#define S0(x) (rol(x,25)^rol(x,14)^(x>>3))
321#define S1(x) (rol(x,15)^rol(x,13)^(x>>10))
322#define SS0(x) (rol(x,30)^rol(x,19)^rol(x,10))
323#define SS1(x) (rol(x,26)^rol(x,21)^rol(x,7))
324
325#define M(I) ( tm = S1(x[(I-2)&0x0f]) + x[(I-7)&0x0f] \
326 + S0(x[(I-15)&0x0f]) + x[I&0x0f] \
327 , x[I&0x0f] = tm )
328
329#define R(A,B,C,D,E,F,G,H,K,M) do { t0 = SS0(A) + F2(A,B,C); \
330 t1 = H + SS1(E) \
331 + F1(E,F,G) \
332 + K \
333 + M; \
334 D += t1; H = t0 + t1; \
335 } while(0)
336
337 while (words < endp)
338 {
339 uint32_t tm;
340 uint32_t t0, t1;
341 int t;
342 /* FIXME: see sha1.c for a better implementation. */
343 for (t = 0; t < 16; t++)
344 {
345 x[t] = SWAP (*words);
346 words++;
347 }
348
349 R( a, b, c, d, e, f, g, h, K( 0), x[ 0] );
350 R( h, a, b, c, d, e, f, g, K( 1), x[ 1] );
351 R( g, h, a, b, c, d, e, f, K( 2), x[ 2] );
352 R( f, g, h, a, b, c, d, e, K( 3), x[ 3] );
353 R( e, f, g, h, a, b, c, d, K( 4), x[ 4] );
354 R( d, e, f, g, h, a, b, c, K( 5), x[ 5] );
355 R( c, d, e, f, g, h, a, b, K( 6), x[ 6] );
356 R( b, c, d, e, f, g, h, a, K( 7), x[ 7] );
357 R( a, b, c, d, e, f, g, h, K( 8), x[ 8] );
358 R( h, a, b, c, d, e, f, g, K( 9), x[ 9] );
359 R( g, h, a, b, c, d, e, f, K(10), x[10] );
360 R( f, g, h, a, b, c, d, e, K(11), x[11] );
361 R( e, f, g, h, a, b, c, d, K(12), x[12] );
362 R( d, e, f, g, h, a, b, c, K(13), x[13] );
363 R( c, d, e, f, g, h, a, b, K(14), x[14] );
364 R( b, c, d, e, f, g, h, a, K(15), x[15] );
365 R( a, b, c, d, e, f, g, h, K(16), M(16) );
366 R( h, a, b, c, d, e, f, g, K(17), M(17) );
367 R( g, h, a, b, c, d, e, f, K(18), M(18) );
368 R( f, g, h, a, b, c, d, e, K(19), M(19) );
369 R( e, f, g, h, a, b, c, d, K(20), M(20) );
370 R( d, e, f, g, h, a, b, c, K(21), M(21) );
371 R( c, d, e, f, g, h, a, b, K(22), M(22) );
372 R( b, c, d, e, f, g, h, a, K(23), M(23) );
373 R( a, b, c, d, e, f, g, h, K(24), M(24) );
374 R( h, a, b, c, d, e, f, g, K(25), M(25) );
375 R( g, h, a, b, c, d, e, f, K(26), M(26) );
376 R( f, g, h, a, b, c, d, e, K(27), M(27) );
377 R( e, f, g, h, a, b, c, d, K(28), M(28) );
378 R( d, e, f, g, h, a, b, c, K(29), M(29) );
379 R( c, d, e, f, g, h, a, b, K(30), M(30) );
380 R( b, c, d, e, f, g, h, a, K(31), M(31) );
381 R( a, b, c, d, e, f, g, h, K(32), M(32) );
382 R( h, a, b, c, d, e, f, g, K(33), M(33) );
383 R( g, h, a, b, c, d, e, f, K(34), M(34) );
384 R( f, g, h, a, b, c, d, e, K(35), M(35) );
385 R( e, f, g, h, a, b, c, d, K(36), M(36) );
386 R( d, e, f, g, h, a, b, c, K(37), M(37) );
387 R( c, d, e, f, g, h, a, b, K(38), M(38) );
388 R( b, c, d, e, f, g, h, a, K(39), M(39) );
389 R( a, b, c, d, e, f, g, h, K(40), M(40) );
390 R( h, a, b, c, d, e, f, g, K(41), M(41) );
391 R( g, h, a, b, c, d, e, f, K(42), M(42) );
392 R( f, g, h, a, b, c, d, e, K(43), M(43) );
393 R( e, f, g, h, a, b, c, d, K(44), M(44) );
394 R( d, e, f, g, h, a, b, c, K(45), M(45) );
395 R( c, d, e, f, g, h, a, b, K(46), M(46) );
396 R( b, c, d, e, f, g, h, a, K(47), M(47) );
397 R( a, b, c, d, e, f, g, h, K(48), M(48) );
398 R( h, a, b, c, d, e, f, g, K(49), M(49) );
399 R( g, h, a, b, c, d, e, f, K(50), M(50) );
400 R( f, g, h, a, b, c, d, e, K(51), M(51) );
401 R( e, f, g, h, a, b, c, d, K(52), M(52) );
402 R( d, e, f, g, h, a, b, c, K(53), M(53) );
403 R( c, d, e, f, g, h, a, b, K(54), M(54) );
404 R( b, c, d, e, f, g, h, a, K(55), M(55) );
405 R( a, b, c, d, e, f, g, h, K(56), M(56) );
406 R( h, a, b, c, d, e, f, g, K(57), M(57) );
407 R( g, h, a, b, c, d, e, f, K(58), M(58) );
408 R( f, g, h, a, b, c, d, e, K(59), M(59) );
409 R( e, f, g, h, a, b, c, d, K(60), M(60) );
410 R( d, e, f, g, h, a, b, c, K(61), M(61) );
411 R( c, d, e, f, g, h, a, b, K(62), M(62) );
412 R( b, c, d, e, f, g, h, a, K(63), M(63) );
413
414 a = ctx->state[0] += a;
415 b = ctx->state[1] += b;
416 c = ctx->state[2] += c;
417 d = ctx->state[3] += d;
418 e = ctx->state[4] += e;
419 f = ctx->state[5] += f;
420 g = ctx->state[6] += g;
421 h = ctx->state[7] += h;
422 }
423}
424
425#endif
426
427/*
428 * Hey Emacs!
429 * Local Variables:
430 * coding: utf-8
431 * End:
432 */
diff --git a/gl/sha256.h b/gl/sha256.h
new file mode 100644
index 0000000..2879477
--- /dev/null
+++ b/gl/sha256.h
@@ -0,0 +1,121 @@
1/* Declarations of functions and data types used for SHA256 and SHA224 sum
2 library functions.
3 Copyright (C) 2005-2006, 2008-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef SHA256_H
19# define SHA256_H 1
20
21# include <stdio.h>
22# include <stdint.h>
23
24# if HAVE_OPENSSL_SHA256
25# ifndef OPENSSL_API_COMPAT
26# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
27# endif
28# include <openssl/sha.h>
29# endif
30
31# ifdef __cplusplus
32extern "C" {
33# endif
34
35enum { SHA224_DIGEST_SIZE = 224 / 8 };
36enum { SHA256_DIGEST_SIZE = 256 / 8 };
37
38# if HAVE_OPENSSL_SHA256
39# define GL_OPENSSL_NAME 224
40# include "gl_openssl.h"
41# define GL_OPENSSL_NAME 256
42# include "gl_openssl.h"
43# else
44/* Structure to save state of computation between the single steps. */
45struct sha256_ctx
46{
47 uint32_t state[8];
48
49 uint32_t total[2];
50 size_t buflen; /* ≥ 0, ≤ 128 */
51 uint32_t buffer[32]; /* 128 bytes; the first buflen bytes are in use */
52};
53
54/* Initialize structure containing state of computation. */
55extern void sha256_init_ctx (struct sha256_ctx *ctx);
56extern void sha224_init_ctx (struct sha256_ctx *ctx);
57
58/* Starting with the result of former calls of this function (or the
59 initialization function update the context for the next LEN bytes
60 starting at BUFFER.
61 It is necessary that LEN is a multiple of 64!!! */
62extern void sha256_process_block (const void *buffer, size_t len,
63 struct sha256_ctx *ctx);
64
65/* Starting with the result of former calls of this function (or the
66 initialization function update the context for the next LEN bytes
67 starting at BUFFER.
68 It is NOT required that LEN is a multiple of 64. */
69extern void sha256_process_bytes (const void *buffer, size_t len,
70 struct sha256_ctx *ctx);
71
72/* Process the remaining bytes in the buffer and put result from CTX
73 in first 32 (28) bytes following RESBUF. The result is always in little
74 endian byte order, so that a byte-wise output yields to the wanted
75 ASCII representation of the message digest. */
76extern void *sha256_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
77extern void *sha224_finish_ctx (struct sha256_ctx *ctx, void *restrict resbuf);
78
79
80/* Put result from CTX in first 32 (28) bytes following RESBUF. The result is
81 always in little endian byte order, so that a byte-wise output yields
82 to the wanted ASCII representation of the message digest. */
83extern void *sha256_read_ctx (const struct sha256_ctx *ctx,
84 void *restrict resbuf);
85extern void *sha224_read_ctx (const struct sha256_ctx *ctx,
86 void *restrict resbuf);
87
88
89/* Compute SHA256 (SHA224) message digest for LEN bytes beginning at BUFFER.
90 The result is always in little endian byte order, so that a byte-wise
91 output yields to the wanted ASCII representation of the message
92 digest. */
93extern void *sha256_buffer (const char *buffer, size_t len,
94 void *restrict resblock);
95extern void *sha224_buffer (const char *buffer, size_t len,
96 void *restrict resblock);
97
98# endif
99
100/* Compute SHA256 (SHA224) message digest for bytes read from STREAM.
101 STREAM is an open file stream. Regular files are handled more efficiently.
102 The contents of STREAM from its current position to its end will be read.
103 The case that the last operation on STREAM was an 'ungetc' is not supported.
104 The resulting message digest number will be written into the 32 (28) bytes
105 beginning at RESBLOCK. */
106extern int sha256_stream (FILE *stream, void *resblock);
107extern int sha224_stream (FILE *stream, void *resblock);
108
109
110# ifdef __cplusplus
111}
112# endif
113
114#endif
115
116/*
117 * Hey Emacs!
118 * Local Variables:
119 * coding: utf-8
120 * End:
121 */
diff --git a/gl/size_max.h b/gl/size_max.h
index 5f33124..48af025 100644
--- a/gl/size_max.h
+++ b/gl/size_max.h
@@ -1,19 +1,19 @@
1/* size_max.h -- declare SIZE_MAX through system headers 1/* size_max.h -- declare SIZE_MAX through system headers
2 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef GNULIB_SIZE_MAX_H 18#ifndef GNULIB_SIZE_MAX_H
19#define GNULIB_SIZE_MAX_H 19#define GNULIB_SIZE_MAX_H
diff --git a/gl/snprintf.c b/gl/snprintf.c
index 9c4ab3f..cdff314 100644
--- a/gl/snprintf.c
+++ b/gl/snprintf.c
@@ -1,19 +1,19 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Paul Eggert. 3 Written by Simon Josefsson and Paul Eggert.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
diff --git a/gl/sockets.c b/gl/sockets.c
index ae96148..ca99db8 100644
--- a/gl/sockets.c
+++ b/gl/sockets.c
@@ -1,19 +1,19 @@
1/* sockets.c --- wrappers for Windows socket functions 1/* sockets.c --- wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Simon Josefsson */ 18/* Written by Simon Josefsson */
19 19
@@ -28,7 +28,11 @@
28# include <sys/socket.h> 28# include <sys/socket.h>
29 29
30# include "fd-hook.h" 30# include "fd-hook.h"
31# include "msvc-nothrow.h" 31# if GNULIB_MSVC_NOTHROW
32# include "msvc-nothrow.h"
33# else
34# include <io.h>
35# endif
32 36
33/* Get set_winsock_errno, FD_TO_SOCKET etc. */ 37/* Get set_winsock_errno, FD_TO_SOCKET etc. */
34# include "w32sock.h" 38# include "w32sock.h"
@@ -109,7 +113,7 @@ static int initialized_sockets_version /* = 0 */;
109#endif /* WINDOWS_SOCKETS */ 113#endif /* WINDOWS_SOCKETS */
110 114
111int 115int
112gl_sockets_startup (int version _GL_UNUSED) 116gl_sockets_startup (_GL_UNUSED int version)
113{ 117{
114#if WINDOWS_SOCKETS 118#if WINDOWS_SOCKETS
115 if (version > initialized_sockets_version) 119 if (version > initialized_sockets_version)
@@ -121,8 +125,11 @@ gl_sockets_startup (int version _GL_UNUSED)
121 if (err != 0) 125 if (err != 0)
122 return 1; 126 return 1;
123 127
124 if (data.wVersion < version) 128 if (data.wVersion != version)
125 return 2; 129 {
130 WSACleanup ();
131 return 2;
132 }
126 133
127 if (initialized_sockets_version == 0) 134 if (initialized_sockets_version == 0)
128 register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket, 135 register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket,
diff --git a/gl/sockets.h b/gl/sockets.h
index 1570ad8..a0b1601 100644
--- a/gl/sockets.h
+++ b/gl/sockets.h
@@ -1,39 +1,39 @@
1/* sockets.h - wrappers for Windows socket functions 1/* sockets.h - wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Simon Josefsson */ 18/* Written by Simon Josefsson */
19 19
20#ifndef SOCKETS_H 20#ifndef SOCKETS_H
21# define SOCKETS_H 1 21#define SOCKETS_H 1
22 22
23#define SOCKETS_1_0 0x100 /* don't use - does not work on Windows XP */ 23#define SOCKETS_1_0 0x0001
24#define SOCKETS_1_1 0x101 24#define SOCKETS_1_1 0x0101
25#define SOCKETS_2_0 0x200 /* don't use - does not work on Windows XP */ 25#define SOCKETS_2_0 0x0002
26#define SOCKETS_2_1 0x201 26#define SOCKETS_2_1 0x0102
27#define SOCKETS_2_2 0x202 27#define SOCKETS_2_2 0x0202
28 28
29int gl_sockets_startup (int version) 29int gl_sockets_startup (int version)
30#if !WINDOWS_SOCKETS 30#ifndef WINDOWS_SOCKETS
31 _GL_ATTRIBUTE_CONST 31 _GL_ATTRIBUTE_CONST
32#endif 32#endif
33 ; 33 ;
34 34
35int gl_sockets_cleanup (void) 35int gl_sockets_cleanup (void)
36#if !WINDOWS_SOCKETS 36#ifndef WINDOWS_SOCKETS
37 _GL_ATTRIBUTE_CONST 37 _GL_ATTRIBUTE_CONST
38#endif 38#endif
39 ; 39 ;
@@ -41,11 +41,15 @@ int gl_sockets_cleanup (void)
41/* This function is useful it you create a socket using gnulib's 41/* This function is useful it you create a socket using gnulib's
42 Winsock wrappers but needs to pass on the socket handle to some 42 Winsock wrappers but needs to pass on the socket handle to some
43 other library that only accepts sockets. */ 43 other library that only accepts sockets. */
44#if WINDOWS_SOCKETS 44#ifdef WINDOWS_SOCKETS
45 45
46#include <sys/socket.h> 46# include <sys/socket.h>
47 47
48#include "msvc-nothrow.h" 48# if GNULIB_MSVC_NOTHROW
49# include "msvc-nothrow.h"
50# else
51# include <io.h>
52# endif
49 53
50static inline SOCKET 54static inline SOCKET
51gl_fd_to_handle (int fd) 55gl_fd_to_handle (int fd)
@@ -55,7 +59,7 @@ gl_fd_to_handle (int fd)
55 59
56#else 60#else
57 61
58#define gl_fd_to_handle(x) (x) 62# define gl_fd_to_handle(x) (x)
59 63
60#endif /* WINDOWS_SOCKETS */ 64#endif /* WINDOWS_SOCKETS */
61 65
diff --git a/gl/stat-time.c b/gl/stat-time.c
new file mode 100644
index 0000000..bc28223
--- /dev/null
+++ b/gl/stat-time.c
@@ -0,0 +1,21 @@
1/* stat-related time functions.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20#define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE
21#include "stat-time.h"
diff --git a/gl/stat-time.h b/gl/stat-time.h
new file mode 100644
index 0000000..92aa1e6
--- /dev/null
+++ b/gl/stat-time.h
@@ -0,0 +1,251 @@
1/* stat-related time functions.
2
3 Copyright (C) 2005, 2007, 2009-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#ifndef STAT_TIME_H
21#define STAT_TIME_H 1
22
23#include <errno.h>
24#include <stdckdint.h>
25#include <stddef.h>
26#include <sys/stat.h>
27#include <time.h>
28
29#ifndef _GL_INLINE_HEADER_BEGIN
30 #error "Please include config.h first."
31#endif
32_GL_INLINE_HEADER_BEGIN
33#ifndef _GL_STAT_TIME_INLINE
34# define _GL_STAT_TIME_INLINE _GL_INLINE
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
42 struct timespec, if available. If not, then STAT_TIMESPEC_NS (ST,
43 ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
44 if available. ST_XTIM can be st_atim, st_ctim, st_mtim, or st_birthtim
45 for access, status change, data modification, or birth (creation)
46 time respectively.
47
48 These macros are private to stat-time.h. */
49#if _GL_WINDOWS_STAT_TIMESPEC || defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
50# if _GL_WINDOWS_STAT_TIMESPEC || defined TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC
51# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim)
52# else
53# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.tv_nsec)
54# endif
55#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
56# define STAT_TIMESPEC(st, st_xtim) ((st)->st_xtim##espec)
57#elif defined HAVE_STRUCT_STAT_ST_ATIMENSEC
58# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim##ensec)
59#elif defined HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
60# define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec)
61#endif
62
63/* Return the nanosecond component of *ST's access time. */
64_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
65get_stat_atime_ns (struct stat const *st)
66{
67# if defined STAT_TIMESPEC
68 return STAT_TIMESPEC (st, st_atim).tv_nsec;
69# elif defined STAT_TIMESPEC_NS
70 return STAT_TIMESPEC_NS (st, st_atim);
71# else
72 return 0;
73# endif
74}
75
76/* Return the nanosecond component of *ST's status change time. */
77_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
78get_stat_ctime_ns (struct stat const *st)
79{
80# if defined STAT_TIMESPEC
81 return STAT_TIMESPEC (st, st_ctim).tv_nsec;
82# elif defined STAT_TIMESPEC_NS
83 return STAT_TIMESPEC_NS (st, st_ctim);
84# else
85 return 0;
86# endif
87}
88
89/* Return the nanosecond component of *ST's data modification time. */
90_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
91get_stat_mtime_ns (struct stat const *st)
92{
93# if defined STAT_TIMESPEC
94 return STAT_TIMESPEC (st, st_mtim).tv_nsec;
95# elif defined STAT_TIMESPEC_NS
96 return STAT_TIMESPEC_NS (st, st_mtim);
97# else
98 return 0;
99# endif
100}
101
102/* Return the nanosecond component of *ST's birth time. */
103_GL_STAT_TIME_INLINE long int _GL_ATTRIBUTE_PURE
104get_stat_birthtime_ns (_GL_UNUSED struct stat const *st)
105{
106# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
107 return STAT_TIMESPEC (st, st_birthtim).tv_nsec;
108# elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
109 return STAT_TIMESPEC_NS (st, st_birthtim);
110# else
111 return 0;
112# endif
113}
114
115/* Return *ST's access time. */
116_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
117get_stat_atime (struct stat const *st)
118{
119#ifdef STAT_TIMESPEC
120 return STAT_TIMESPEC (st, st_atim);
121#else
122 struct timespec t;
123 t.tv_sec = st->st_atime;
124 t.tv_nsec = get_stat_atime_ns (st);
125 return t;
126#endif
127}
128
129/* Return *ST's status change time. */
130_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
131get_stat_ctime (struct stat const *st)
132{
133#ifdef STAT_TIMESPEC
134 return STAT_TIMESPEC (st, st_ctim);
135#else
136 struct timespec t;
137 t.tv_sec = st->st_ctime;
138 t.tv_nsec = get_stat_ctime_ns (st);
139 return t;
140#endif
141}
142
143/* Return *ST's data modification time. */
144_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
145get_stat_mtime (struct stat const *st)
146{
147#ifdef STAT_TIMESPEC
148 return STAT_TIMESPEC (st, st_mtim);
149#else
150 struct timespec t;
151 t.tv_sec = st->st_mtime;
152 t.tv_nsec = get_stat_mtime_ns (st);
153 return t;
154#endif
155}
156
157/* Return *ST's birth time, if available; otherwise return a value
158 with tv_sec and tv_nsec both equal to -1. */
159_GL_STAT_TIME_INLINE struct timespec _GL_ATTRIBUTE_PURE
160get_stat_birthtime (_GL_UNUSED struct stat const *st)
161{
162 struct timespec t;
163
164#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
165 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
166 t = STAT_TIMESPEC (st, st_birthtim);
167#elif defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC
168 t.tv_sec = st->st_birthtime;
169 t.tv_nsec = st->st_birthtimensec;
170#elif defined _WIN32 && ! defined __CYGWIN__
171 /* Native Windows platforms (but not Cygwin) put the "file creation
172 time" in st_ctime (!). See
173 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions>. */
174# if _GL_WINDOWS_STAT_TIMESPEC
175 t = st->st_ctim;
176# else
177 t.tv_sec = st->st_ctime;
178 t.tv_nsec = 0;
179# endif
180#else
181 /* Birth time is not supported. */
182 t.tv_sec = -1;
183 t.tv_nsec = -1;
184#endif
185
186#if (defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC \
187 || defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC \
188 || defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
189 /* FreeBSD and NetBSD sometimes signal the absence of knowledge by
190 using zero. Attempt to work around this problem. Alas, this can
191 report failure even for valid timestamps. Also, NetBSD
192 sometimes returns junk in the birth time fields; work around this
193 bug if it is detected. */
194 if (! (t.tv_sec && 0 <= t.tv_nsec && t.tv_nsec < 1000000000))
195 {
196 t.tv_sec = -1;
197 t.tv_nsec = -1;
198 }
199#endif
200
201 return t;
202}
203
204/* If a stat-like function returned RESULT, normalize the timestamps
205 in *ST, in case this platform suffers from the Solaris 11 bug where
206 tv_nsec might be negative. Return the adjusted RESULT, setting
207 errno to EOVERFLOW if normalization overflowed. This function
208 is intended to be private to this .h file. */
209_GL_STAT_TIME_INLINE int
210stat_time_normalize (int result, _GL_UNUSED struct stat *st)
211{
212#if defined __sun && defined STAT_TIMESPEC
213 if (result == 0)
214 {
215 long int timespec_hz = 1000000000;
216 short int const ts_off[] = { offsetof (struct stat, st_atim),
217 offsetof (struct stat, st_mtim),
218 offsetof (struct stat, st_ctim) };
219 int i;
220 for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++)
221 {
222 struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]);
223 long int q = ts->tv_nsec / timespec_hz;
224 long int r = ts->tv_nsec % timespec_hz;
225 if (r < 0)
226 {
227 r += timespec_hz;
228 q--;
229 }
230 ts->tv_nsec = r;
231 /* Overflow is possible, as Solaris 11 stat can yield
232 tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000.
233 INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */
234 if (ckd_add (&ts->tv_sec, q, ts->tv_sec))
235 {
236 errno = EOVERFLOW;
237 return -1;
238 }
239 }
240 }
241#endif
242 return result;
243}
244
245#ifdef __cplusplus
246}
247#endif
248
249_GL_INLINE_HEADER_END
250
251#endif
diff --git a/gl/stat-w32.c b/gl/stat-w32.c
new file mode 100644
index 0000000..2f01197
--- /dev/null
+++ b/gl/stat-w32.c
@@ -0,0 +1,460 @@
1/* Core of implementation of fstat and stat for native Windows.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible. */
18
19#include <config.h>
20
21#if defined _WIN32 && ! defined __CYGWIN__
22
23/* Attempt to make <windows.h> define FILE_ID_INFO.
24 But ensure that the redefinition of _WIN32_WINNT does not make us assume
25 Windows Vista or newer when building for an older version of Windows. */
26#if HAVE_SDKDDKVER_H
27# include <sdkddkver.h>
28# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
29# define WIN32_ASSUME_VISTA 1
30# else
31# define WIN32_ASSUME_VISTA 0
32# endif
33# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
34# undef _WIN32_WINNT
35# define _WIN32_WINNT _WIN32_WINNT_WIN8
36# endif
37#else
38# define WIN32_ASSUME_VISTA (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
39#endif
40
41#include <sys/types.h>
42#include <sys/stat.h>
43#include <errno.h>
44#include <limits.h>
45#include <string.h>
46#include <unistd.h>
47#include <windows.h>
48
49/* Specification. */
50#include "stat-w32.h"
51
52#include "pathmax.h"
53
54/* Don't assume that UNICODE is not defined. */
55#undef LoadLibrary
56#define LoadLibrary LoadLibraryA
57#undef GetFinalPathNameByHandle
58#define GetFinalPathNameByHandle GetFinalPathNameByHandleA
59
60/* Older mingw headers do not define VOLUME_NAME_NONE. */
61#ifndef VOLUME_NAME_NONE
62# define VOLUME_NAME_NONE 4
63#endif
64
65#if !WIN32_ASSUME_VISTA
66
67/* Avoid warnings from gcc -Wcast-function-type. */
68# define GetProcAddress \
69 (void *) GetProcAddress
70
71# if _GL_WINDOWS_STAT_INODES == 2
72/* GetFileInformationByHandleEx was introduced only in Windows Vista. */
73typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,
74 FILE_INFO_BY_HANDLE_CLASS fiClass,
75 LPVOID lpBuffer,
76 DWORD dwBufferSize);
77static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL;
78# endif
79/* GetFinalPathNameByHandle was introduced only in Windows Vista. */
80typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile,
81 LPSTR lpFilePath,
82 DWORD lenFilePath,
83 DWORD dwFlags);
84static GetFinalPathNameByHandleFuncType GetFinalPathNameByHandleFunc = NULL;
85static BOOL initialized = FALSE;
86
87static void
88initialize (void)
89{
90 HMODULE kernel32 = LoadLibrary ("kernel32.dll");
91 if (kernel32 != NULL)
92 {
93# if _GL_WINDOWS_STAT_INODES == 2
94 GetFileInformationByHandleExFunc =
95 (GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx");
96# endif
97 GetFinalPathNameByHandleFunc =
98 (GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA");
99 }
100 initialized = TRUE;
101}
102
103#else
104
105# define GetFileInformationByHandleExFunc GetFileInformationByHandleEx
106# define GetFinalPathNameByHandleFunc GetFinalPathNameByHandle
107
108#endif
109
110/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
111#if _GL_WINDOWS_STAT_TIMESPEC
112struct timespec
113_gl_convert_FILETIME_to_timespec (const FILETIME *ft)
114{
115 struct timespec result;
116 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */
117 unsigned long long since_1601 =
118 ((unsigned long long) ft->dwHighDateTime << 32)
119 | (unsigned long long) ft->dwLowDateTime;
120 if (since_1601 == 0)
121 {
122 result.tv_sec = 0;
123 result.tv_nsec = 0;
124 }
125 else
126 {
127 /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
128 leap years, in total 134774 days. */
129 unsigned long long since_1970 =
130 since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
131 result.tv_sec = since_1970 / (unsigned long long) 10000000;
132 result.tv_nsec = (unsigned long) (since_1970 % (unsigned long long) 10000000) * 100;
133 }
134 return result;
135}
136#else
137time_t
138_gl_convert_FILETIME_to_POSIX (const FILETIME *ft)
139{
140 /* FILETIME: <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime> */
141 unsigned long long since_1601 =
142 ((unsigned long long) ft->dwHighDateTime << 32)
143 | (unsigned long long) ft->dwLowDateTime;
144 if (since_1601 == 0)
145 return 0;
146 else
147 {
148 /* Between 1601-01-01 and 1970-01-01 there were 280 normal years and 89
149 leap years, in total 134774 days. */
150 unsigned long long since_1970 =
151 since_1601 - (unsigned long long) 134774 * (unsigned long long) 86400 * (unsigned long long) 10000000;
152 return since_1970 / (unsigned long long) 10000000;
153 }
154}
155#endif
156
157/* Fill *BUF with information about the file designated by H.
158 PATH is the file name, if known, otherwise NULL.
159 Return 0 if successful, or -1 with errno set upon failure. */
160int
161_gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
162{
163 /* GetFileType
164 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletype> */
165 DWORD type = GetFileType (h);
166 if (type == FILE_TYPE_DISK)
167 {
168#if !WIN32_ASSUME_VISTA
169 if (!initialized)
170 initialize ();
171#endif
172
173 /* st_mode can be determined through
174 GetFileAttributesEx
175 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileattributesexa>
176 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_win32_file_attribute_data>
177 or through
178 GetFileInformationByHandle
179 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
180 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
181 or through
182 GetFileInformationByHandleEx with argument FileBasicInfo
183 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
184 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_basic_info>
185 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
186 BY_HANDLE_FILE_INFORMATION info;
187 if (! GetFileInformationByHandle (h, &info))
188 goto failed;
189
190 /* Test for error conditions before starting to fill *buf. */
191 if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
192 {
193 errno = EOVERFLOW;
194 return -1;
195 }
196
197#if _GL_WINDOWS_STAT_INODES
198 /* st_ino can be determined through
199 GetFileInformationByHandle
200 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
201 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
202 as 64 bits, or through
203 GetFileInformationByHandleEx with argument FileIdInfo
204 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
205 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_id_info>
206 as 128 bits.
207 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */
208 /* Experiments show that GetFileInformationByHandleEx does not provide
209 much more information than GetFileInformationByHandle:
210 * The dwVolumeSerialNumber from GetFileInformationByHandle is equal
211 to the low 32 bits of the 64-bit VolumeSerialNumber from
212 GetFileInformationByHandleEx, and is apparently sufficient for
213 identifying the device.
214 * The nFileIndex from GetFileInformationByHandle is equal to the low
215 64 bits of the 128-bit FileId from GetFileInformationByHandleEx,
216 and the high 64 bits of this 128-bit FileId are zero.
217 * On a FAT file system, GetFileInformationByHandleEx fails with error
218 ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle
219 succeeds.
220 * On a CIFS/SMB file system, GetFileInformationByHandleEx fails with
221 error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle
222 succeeds. */
223# if _GL_WINDOWS_STAT_INODES == 2
224 if (GetFileInformationByHandleExFunc != NULL)
225 {
226 FILE_ID_INFO id;
227 if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id)))
228 {
229 buf->st_dev = id.VolumeSerialNumber;
230 static_assert (sizeof (ino_t) == sizeof (id.FileId));
231 memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t));
232 goto ino_done;
233 }
234 else
235 {
236 switch (GetLastError ())
237 {
238 case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */
239 case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */
240 goto fallback;
241 default:
242 goto failed;
243 }
244 }
245 }
246 fallback: ;
247 /* Fallback for older Windows versions. */
248 buf->st_dev = info.dwVolumeSerialNumber;
249 buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
250 buf->st_ino._gl_ino[1] = 0;
251 ino_done: ;
252# else /* _GL_WINDOWS_STAT_INODES == 1 */
253 buf->st_dev = info.dwVolumeSerialNumber;
254 buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow;
255# endif
256#else
257 /* st_ino is not wide enough for identifying a file on a device.
258 Without st_ino, st_dev is pointless. */
259 buf->st_dev = 0;
260 buf->st_ino = 0;
261#endif
262
263 /* st_mode. */
264 unsigned int mode =
265 /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
266 ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
267 | S_IREAD_UGO
268 | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
269 if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
270 {
271 /* Determine whether the file is executable by looking at the file
272 name suffix.
273 If the file name is already known, use it. Otherwise, for
274 non-empty files, it can be determined through
275 GetFinalPathNameByHandle
276 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea>
277 or through
278 GetFileInformationByHandleEx with argument FileNameInfo
279 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
280 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_name_info>
281 Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
282 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
283 {
284 char fpath[PATH_MAX];
285 if (path != NULL
286 || (GetFinalPathNameByHandleFunc != NULL
287 && GetFinalPathNameByHandleFunc (h, fpath, sizeof (fpath), VOLUME_NAME_NONE)
288 < sizeof (fpath)
289 && (path = fpath, 1)))
290 {
291 const char *last_dot = NULL;
292 const char *p;
293 for (p = path; *p != '\0'; p++)
294 if (*p == '.')
295 last_dot = p;
296 if (last_dot != NULL)
297 {
298 const char *suffix = last_dot + 1;
299 if (_stricmp (suffix, "exe") == 0
300 || _stricmp (suffix, "bat") == 0
301 || _stricmp (suffix, "cmd") == 0
302 || _stricmp (suffix, "com") == 0)
303 mode |= S_IEXEC_UGO;
304 }
305 }
306 else
307 /* Cannot determine file name. Pretend that it is executable. */
308 mode |= S_IEXEC_UGO;
309 }
310 }
311 buf->st_mode = mode;
312
313 /* st_nlink can be determined through
314 GetFileInformationByHandle
315 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
316 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
317 or through
318 GetFileInformationByHandleEx with argument FileStandardInfo
319 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
320 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_standard_info>
321 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
322 buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks);
323
324 /* There's no easy way to map the Windows SID concept to an integer. */
325 buf->st_uid = 0;
326 buf->st_gid = 0;
327
328 /* st_rdev is irrelevant for normal files and directories. */
329 buf->st_rdev = 0;
330
331 /* st_size can be determined through
332 GetFileSizeEx
333 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfilesizeex>
334 or through
335 GetFileAttributesEx
336 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileattributesexa>
337 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_win32_file_attribute_data>
338 or through
339 GetFileInformationByHandle
340 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
341 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
342 or through
343 GetFileInformationByHandleEx with argument FileStandardInfo
344 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
345 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_standard_info>
346 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
347 if (sizeof (buf->st_size) <= 4)
348 /* Range check already done above. */
349 buf->st_size = info.nFileSizeLow;
350 else
351 buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
352
353 /* st_atime, st_mtime, st_ctime can be determined through
354 GetFileTime
355 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfiletime>
356 or through
357 GetFileAttributesEx
358 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileattributesexa>
359 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_win32_file_attribute_data>
360 or through
361 GetFileInformationByHandle
362 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle>
363 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>
364 or through
365 GetFileInformationByHandleEx with argument FileBasicInfo
366 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex>
367 <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_basic_info>
368 The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */
369#if _GL_WINDOWS_STAT_TIMESPEC
370 buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
371 buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
372 buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
373#else
374 buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
375 buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
376 buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
377#endif
378
379 return 0;
380 }
381 else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE)
382 {
383 buf->st_dev = 0;
384#if _GL_WINDOWS_STAT_INODES == 2
385 buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
386#else
387 buf->st_ino = 0;
388#endif
389 buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR);
390 buf->st_nlink = 1;
391 buf->st_uid = 0;
392 buf->st_gid = 0;
393 buf->st_rdev = 0;
394 if (type == FILE_TYPE_PIPE)
395 {
396 /* PeekNamedPipe
397 <https://msdn.microsoft.com/en-us/library/aa365779.aspx> */
398 DWORD bytes_available;
399 if (PeekNamedPipe (h, NULL, 0, NULL, &bytes_available, NULL))
400 buf->st_size = bytes_available;
401 else
402 buf->st_size = 0;
403 }
404 else
405 buf->st_size = 0;
406#if _GL_WINDOWS_STAT_TIMESPEC
407 buf->st_atim.tv_sec = 0; buf->st_atim.tv_nsec = 0;
408 buf->st_mtim.tv_sec = 0; buf->st_mtim.tv_nsec = 0;
409 buf->st_ctim.tv_sec = 0; buf->st_ctim.tv_nsec = 0;
410#else
411 buf->st_atime = 0;
412 buf->st_mtime = 0;
413 buf->st_ctime = 0;
414#endif
415 return 0;
416 }
417 else
418 {
419 errno = ENOENT;
420 return -1;
421 }
422
423 failed:
424 {
425 DWORD error = GetLastError ();
426 #if 0
427 fprintf (stderr, "_gl_fstat_by_handle error 0x%x\n", (unsigned int) error);
428 #endif
429 switch (error)
430 {
431 case ERROR_ACCESS_DENIED:
432 case ERROR_SHARING_VIOLATION:
433 errno = EACCES;
434 break;
435
436 case ERROR_OUTOFMEMORY:
437 errno = ENOMEM;
438 break;
439
440 case ERROR_WRITE_FAULT:
441 case ERROR_READ_FAULT:
442 case ERROR_GEN_FAILURE:
443 errno = EIO;
444 break;
445
446 default:
447 errno = EINVAL;
448 break;
449 }
450 return -1;
451 }
452}
453
454#else
455
456/* This declaration is solely to ensure that after preprocessing
457 this file is never empty. */
458typedef int dummy;
459
460#endif
diff --git a/gl/stat-w32.h b/gl/stat-w32.h
new file mode 100644
index 0000000..c673874
--- /dev/null
+++ b/gl/stat-w32.h
@@ -0,0 +1,37 @@
1/* Core of implementation of fstat and stat for native Windows.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _STAT_W32_H
18#define _STAT_W32_H 1
19
20/* Converts a FILETIME to GMT time since 1970-01-01 00:00:00. */
21#if _GL_WINDOWS_STAT_TIMESPEC
22extern struct timespec _gl_convert_FILETIME_to_timespec (const FILETIME *ft);
23#else
24extern time_t _gl_convert_FILETIME_to_POSIX (const FILETIME *ft);
25#endif
26
27/* Fill *BUF with information about the file designated by H.
28 PATH is the file name, if known, otherwise NULL.
29 Return 0 if successful, or -1 with errno set upon failure. */
30extern int _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf);
31
32/* Bitmasks for st_mode. */
33#define S_IREAD_UGO (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
34#define S_IWRITE_UGO (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
35#define S_IEXEC_UGO (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
36
37#endif /* _STAT_W32_H */
diff --git a/gl/stat.c b/gl/stat.c
new file mode 100644
index 0000000..7987e26
--- /dev/null
+++ b/gl/stat.c
@@ -0,0 +1,438 @@
1/* Work around platform bugs in stat.
2 Copyright (C) 2009-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Eric Blake and Bruno Haible. */
18
19/* If the user's config.h happens to include <sys/stat.h>, let it include only
20 the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
21 rpl_stat. */
22#define __need_system_sys_stat_h
23#include <config.h>
24
25/* Get the original definition of stat. It might be defined as a macro. */
26#include <sys/types.h>
27#include <sys/stat.h>
28#undef __need_system_sys_stat_h
29
30#if defined _WIN32 && ! defined __CYGWIN__
31# define WINDOWS_NATIVE
32#endif
33
34#if !defined WINDOWS_NATIVE
35
36static int
37orig_stat (const char *filename, struct stat *buf)
38{
39 return stat (filename, buf);
40}
41
42#endif
43
44/* Specification. */
45#ifdef __osf__
46/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
47 eliminates this include because of the preliminary #include <sys/stat.h>
48 above. */
49# include "sys/stat.h"
50#else
51# include <sys/stat.h>
52#endif
53
54#include "stat-time.h"
55
56#include <errno.h>
57#include <limits.h>
58#include <string.h>
59#include "filename.h"
60#include "malloca.h"
61
62#ifdef WINDOWS_NATIVE
63# define WIN32_LEAN_AND_MEAN
64# include <windows.h>
65# include "stat-w32.h"
66/* Don't assume that UNICODE is not defined. */
67# undef WIN32_FIND_DATA
68# define WIN32_FIND_DATA WIN32_FIND_DATAA
69# undef CreateFile
70# define CreateFile CreateFileA
71# undef FindFirstFile
72# define FindFirstFile FindFirstFileA
73#endif
74
75#ifdef WINDOWS_NATIVE
76/* Return TRUE if the given file name denotes an UNC root. */
77static BOOL
78is_unc_root (const char *rname)
79{
80 /* Test whether it has the syntax '\\server\share'. */
81 if (ISSLASH (rname[0]) && ISSLASH (rname[1]))
82 {
83 /* It starts with two slashes. Find the next slash. */
84 const char *p = rname + 2;
85 const char *q = p;
86 while (*q != '\0' && !ISSLASH (*q))
87 q++;
88 if (q > p && *q != '\0')
89 {
90 /* Found the next slash at q. */
91 q++;
92 const char *r = q;
93 while (*r != '\0' && !ISSLASH (*r))
94 r++;
95 if (r > q && *r == '\0')
96 return TRUE;
97 }
98 }
99 return FALSE;
100}
101#endif
102
103/* Store information about NAME into ST. Work around bugs with
104 trailing slashes. Mingw has other bugs (such as st_ino always
105 being 0 on success) which this wrapper does not work around. But
106 at least this implementation provides the ability to emulate fchdir
107 correctly. */
108
109int
110rpl_stat (char const *name, struct stat *buf)
111{
112#ifdef WINDOWS_NATIVE
113 /* Fill the fields ourselves, because the original stat function returns
114 values for st_atime, st_mtime, st_ctime that depend on the current time
115 zone. See
116 <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */
117 /* XXX Should we convert to wchar_t* and prepend '\\?\', in order to work
118 around length limitations
119 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file> ? */
120
121 /* POSIX <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>
122 specifies: "More than two leading <slash> characters shall be treated as
123 a single <slash> character." */
124 if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2]))
125 {
126 name += 2;
127 while (ISSLASH (name[1]))
128 name++;
129 }
130
131 size_t len = strlen (name);
132 size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0);
133
134 /* Remove trailing slashes (except the very first one, at position
135 drive_prefix_len), but remember their presence. */
136 size_t rlen;
137 bool check_dir = false;
138
139 rlen = len;
140 while (rlen > drive_prefix_len && ISSLASH (name[rlen-1]))
141 {
142 check_dir = true;
143 if (rlen == drive_prefix_len + 1)
144 break;
145 rlen--;
146 }
147
148 /* Handle '' and 'C:'. */
149 if (!check_dir && rlen == drive_prefix_len)
150 {
151 errno = ENOENT;
152 return -1;
153 }
154
155 /* Handle '\\'. */
156 if (rlen == 1 && ISSLASH (name[0]) && len >= 2)
157 {
158 errno = ENOENT;
159 return -1;
160 }
161
162 const char *rname;
163 char *malloca_rname;
164 if (rlen == len)
165 {
166 rname = name;
167 malloca_rname = NULL;
168 }
169 else
170 {
171 malloca_rname = malloca (rlen + 1);
172 if (malloca_rname == NULL)
173 {
174 errno = ENOMEM;
175 return -1;
176 }
177 memcpy (malloca_rname, name, rlen);
178 malloca_rname[rlen] = '\0';
179 rname = malloca_rname;
180 }
181
182 /* There are two ways to get at the requested information:
183 - by scanning the parent directory and examining the relevant
184 directory entry,
185 - by opening the file directly.
186 The first approach fails for root directories (e.g. 'C:\') and
187 UNC root directories (e.g. '\\server\share').
188 The second approach fails for some system files (e.g. 'C:\pagefile.sys'
189 and 'C:\hiberfil.sys'): ERROR_SHARING_VIOLATION.
190 The second approach gives more information (in particular, correct
191 st_dev, st_ino, st_nlink fields).
192 So we use the second approach and, as a fallback except for root and
193 UNC root directories, also the first approach. */
194 {
195 int ret;
196
197 {
198 /* Approach based on the file. */
199
200 /* Open a handle to the file.
201 CreateFile
202 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea>
203 <https://docs.microsoft.com/en-us/windows/desktop/FileIO/creating-and-opening-files> */
204 HANDLE h =
205 CreateFile (rname,
206 FILE_READ_ATTRIBUTES,
207 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
208 NULL,
209 OPEN_EXISTING,
210 /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only
211 in case as different) makes sense only when applied to *all*
212 filesystem operations. */
213 FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */,
214 NULL);
215 if (h != INVALID_HANDLE_VALUE)
216 {
217 ret = _gl_fstat_by_handle (h, rname, buf);
218 CloseHandle (h);
219 goto done;
220 }
221 }
222
223 /* Test for root and UNC root directories. */
224 if ((rlen == drive_prefix_len + 1 && ISSLASH (rname[drive_prefix_len]))
225 || is_unc_root (rname))
226 goto failed;
227
228 /* Fallback. */
229 {
230 /* Approach based on the directory entry. */
231
232 if (strchr (rname, '?') != NULL || strchr (rname, '*') != NULL)
233 {
234 /* Other Windows API functions would fail with error
235 ERROR_INVALID_NAME. */
236 if (malloca_rname != NULL)
237 freea (malloca_rname);
238 errno = ENOENT;
239 return -1;
240 }
241
242 /* Get the details about the directory entry. This can be done through
243 FindFirstFile
244 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfilea>
245 <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-_win32_find_dataa>
246 or through
247 FindFirstFileEx with argument FindExInfoBasic
248 <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-findfirstfileexa>
249 <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ne-minwinbase-findex_info_levels>
250 <https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-_win32_find_dataa> */
251 WIN32_FIND_DATA info;
252 HANDLE h = FindFirstFile (rname, &info);
253 if (h == INVALID_HANDLE_VALUE)
254 goto failed;
255
256 /* Test for error conditions before starting to fill *buf. */
257 if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0)
258 {
259 FindClose (h);
260 if (malloca_rname != NULL)
261 freea (malloca_rname);
262 errno = EOVERFLOW;
263 return -1;
264 }
265
266# if _GL_WINDOWS_STAT_INODES
267 buf->st_dev = 0;
268# if _GL_WINDOWS_STAT_INODES == 2
269 buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0;
270# else /* _GL_WINDOWS_STAT_INODES == 1 */
271 buf->st_ino = 0;
272# endif
273# else
274 /* st_ino is not wide enough for identifying a file on a device.
275 Without st_ino, st_dev is pointless. */
276 buf->st_dev = 0;
277 buf->st_ino = 0;
278# endif
279
280 /* st_mode. */
281 unsigned int mode =
282 /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */
283 ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG)
284 | S_IREAD_UGO
285 | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO);
286 if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
287 {
288 /* Determine whether the file is executable by looking at the file
289 name suffix. */
290 if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0)
291 {
292 const char *last_dot = NULL;
293 const char *p;
294 for (p = info.cFileName; *p != '\0'; p++)
295 if (*p == '.')
296 last_dot = p;
297 if (last_dot != NULL)
298 {
299 const char *suffix = last_dot + 1;
300 if (_stricmp (suffix, "exe") == 0
301 || _stricmp (suffix, "bat") == 0
302 || _stricmp (suffix, "cmd") == 0
303 || _stricmp (suffix, "com") == 0)
304 mode |= S_IEXEC_UGO;
305 }
306 }
307 }
308 buf->st_mode = mode;
309
310 /* st_nlink. Ignore hard links here. */
311 buf->st_nlink = 1;
312
313 /* There's no easy way to map the Windows SID concept to an integer. */
314 buf->st_uid = 0;
315 buf->st_gid = 0;
316
317 /* st_rdev is irrelevant for normal files and directories. */
318 buf->st_rdev = 0;
319
320 /* st_size. */
321 if (sizeof (buf->st_size) <= 4)
322 /* Range check already done above. */
323 buf->st_size = info.nFileSizeLow;
324 else
325 buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow;
326
327 /* st_atime, st_mtime, st_ctime. */
328# if _GL_WINDOWS_STAT_TIMESPEC
329 buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime);
330 buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime);
331 buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime);
332# else
333 buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime);
334 buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime);
335 buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime);
336# endif
337
338 FindClose (h);
339
340 ret = 0;
341 }
342
343 done:
344 if (ret >= 0 && check_dir && !S_ISDIR (buf->st_mode))
345 {
346 errno = ENOTDIR;
347 ret = -1;
348 }
349 if (malloca_rname != NULL)
350 {
351 int saved_errno = errno;
352 freea (malloca_rname);
353 errno = saved_errno;
354 }
355 return ret;
356 }
357
358 failed:
359 {
360 DWORD error = GetLastError ();
361 #if 0
362 fprintf (stderr, "rpl_stat error 0x%x\n", (unsigned int) error);
363 #endif
364
365 if (malloca_rname != NULL)
366 freea (malloca_rname);
367
368 switch (error)
369 {
370 /* Some of these errors probably cannot happen with the specific flags
371 that we pass to CreateFile. But who knows... */
372 case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */
373 case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */
374 case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */
375 case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */
376 case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */
377 case ERROR_DIRECTORY:
378 errno = ENOENT;
379 break;
380
381 case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */
382 case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys' (second approach only). */
383 /* XXX map to EACCES or EPERM? */
384 errno = EACCES;
385 break;
386
387 case ERROR_OUTOFMEMORY:
388 errno = ENOMEM;
389 break;
390
391 case ERROR_WRITE_PROTECT:
392 errno = EROFS;
393 break;
394
395 case ERROR_WRITE_FAULT:
396 case ERROR_READ_FAULT:
397 case ERROR_GEN_FAILURE:
398 errno = EIO;
399 break;
400
401 case ERROR_BUFFER_OVERFLOW:
402 case ERROR_FILENAME_EXCED_RANGE:
403 errno = ENAMETOOLONG;
404 break;
405
406 case ERROR_DELETE_PENDING: /* XXX map to EACCES or EPERM? */
407 errno = EPERM;
408 break;
409
410 default:
411 errno = EINVAL;
412 break;
413 }
414
415 return -1;
416 }
417#else
418 int result = orig_stat (name, buf);
419 if (result == 0)
420 {
421# if REPLACE_FUNC_STAT_FILE
422 /* Solaris 9 mistakenly succeeds when given a non-directory with a
423 trailing slash. */
424 if (!S_ISDIR (buf->st_mode))
425 {
426 size_t len = strlen (name);
427 if (ISSLASH (name[len - 1]))
428 {
429 errno = ENOTDIR;
430 return -1;
431 }
432 }
433# endif /* REPLACE_FUNC_STAT_FILE */
434 result = stat_time_normalize (result, buf);
435 }
436 return result;
437#endif
438}
diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h
index 7254a3d..7f9dbb4 100644
--- a/gl/stdalign.in.h
+++ b/gl/stdalign.in.h
@@ -1,19 +1,19 @@
1/* A substitute for ISO C11 <stdalign.h>. 1/* A substitute for ISO C11 <stdalign.h>.
2 2
3 Copyright 2011-2013 Free Software Foundation, Inc. 3 Copyright 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paul Eggert and Bruno Haible. */ 18/* Written by Paul Eggert and Bruno Haible. */
19 19
@@ -34,17 +34,15 @@
34 requirement of a structure member (i.e., slot or field) that is of 34 requirement of a structure member (i.e., slot or field) that is of
35 type TYPE, as an integer constant expression. 35 type TYPE, as an integer constant expression.
36 36
37 This differs from GCC's __alignof__ operator, which can yield a 37 This differs from GCC's and clang's __alignof__ operator, which can
38 better-performing alignment for an object of that type. For 38 yield a better-performing alignment for an object of that type. For
39 example, on x86 with GCC, __alignof__ (double) and __alignof__ 39 example, on x86 with GCC and on Linux/x86 with clang,
40 (long long) are 8, whereas alignof (double) and alignof (long long) 40 __alignof__ (double) and __alignof__ (long long) are 8, whereas
41 are 4 unless the option '-malign-double' is used. 41 alignof (double) and alignof (long long) are 4 unless the option
42 '-malign-double' is used.
42 43
43 The result cannot be used as a value for an 'enum' constant, if you 44 The result cannot be used as a value for an 'enum' constant, if you
44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. 45 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
45
46 Include <stddef.h> for offsetof. */
47#include <stddef.h>
48 46
49/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other 47/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
50 standard headers, defines conflicting implementations of _Alignas 48 standard headers, defines conflicting implementations of _Alignas
@@ -52,19 +50,33 @@
52#undef _Alignas 50#undef _Alignas
53#undef _Alignof 51#undef _Alignof
54 52
55#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 53/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
54 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
55 clang versions < 8.0.0 have the same bug. */
56#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \
57 || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
58 && !defined __clang__) \
59 || (defined __clang__ && __clang_major__ < 8))
56# ifdef __cplusplus 60# ifdef __cplusplus
57# if 201103 <= __cplusplus 61# if (201103 <= __cplusplus || defined _MSC_VER)
58# define _Alignof(type) alignof (type) 62# define _Alignof(type) alignof (type)
59# else 63# else
60 template <class __t> struct __alignof_helper { char __a; __t __b; }; 64 template <class __t> struct __alignof_helper { char __a; __t __b; };
61# define _Alignof(type) offsetof (__alignof_helper<type>, __b) 65# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
66# define _GL_STDALIGN_NEEDS_STDDEF 1
62# endif 67# endif
63# else 68# else
64# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) 69# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__
70# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b)
71# else
72# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
73# define _GL_STDALIGN_NEEDS_STDDEF 1
74# endif
65# endif 75# endif
66#endif 76#endif
67#define alignof _Alignof 77#if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))
78# define alignof _Alignof
79#endif
68#define __alignof_is_defined 1 80#define __alignof_is_defined 1
69 81
70/* alignas (A), also known as _Alignas (A), aligns a variable or type 82/* alignas (A), also known as _Alignas (A), aligns a variable or type
@@ -93,17 +105,33 @@
93 */ 105 */
94 106
95#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 107#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
96# if defined __cplusplus && 201103 <= __cplusplus 108# if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)
97# define _Alignas(a) alignas (a) 109# define _Alignas(a) alignas (a)
98# elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C 110# elif (!defined __attribute__ \
111 && ((defined __APPLE__ && defined __MACH__ \
112 ? 4 < __GNUC__ + (1 <= __GNUC_MINOR__) \
113 : __GNUC__ && !defined __ibmxl__) \
114 || (4 <= __clang_major__) \
115 || (__ia64 && (61200 <= __HP_cc || 61200 <= __HP_aCC)) \
116 || __ICC || 0x590 <= __SUNPRO_C || 0x0600 <= __xlC__))
99# define _Alignas(a) __attribute__ ((__aligned__ (a))) 117# define _Alignas(a) __attribute__ ((__aligned__ (a)))
100# elif 1300 <= _MSC_VER 118# elif 1300 <= _MSC_VER
101# define _Alignas(a) __declspec (align (a)) 119# define _Alignas(a) __declspec (align (a))
102# endif 120# endif
103#endif 121#endif
104#if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__) 122#if ((defined _Alignas \
123 && !(defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER))) \
124 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
105# define alignas _Alignas 125# define alignas _Alignas
126#endif
127#if (defined alignas \
128 || (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)))
106# define __alignas_is_defined 1 129# define __alignas_is_defined 1
107#endif 130#endif
108 131
132/* Include <stddef.h> if needed for offsetof. */
133#if _GL_STDALIGN_NEEDS_STDDEF
134# include <stddef.h>
135#endif
136
109#endif /* _GL_STDALIGN_H */ 137#endif /* _GL_STDALIGN_H */
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
deleted file mode 100644
index 7c15772..0000000
--- a/gl/stdbool.in.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _GL_STDBOOL_H
18#define _GL_STDBOOL_H
19
20/* ISO C 99 <stdbool.h> for platforms that lack it. */
21
22/* Usage suggestions:
23
24 Programs that use <stdbool.h> should be aware of some limitations
25 and standards compliance issues.
26
27 Standards compliance:
28
29 - <stdbool.h> must be #included before 'bool', 'false', 'true'
30 can be used.
31
32 - You cannot assume that sizeof (bool) == 1.
33
34 - Programs should not undefine the macros bool, true, and false,
35 as C99 lists that as an "obsolescent feature".
36
37 Limitations of this substitute, when used in a C89 environment:
38
39 - <stdbool.h> must be #included before the '_Bool' type can be used.
40
41 - You cannot assume that _Bool is a typedef; it might be a macro.
42
43 - Bit-fields of type 'bool' are not supported. Portable code
44 should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'.
45
46 - In C99, casts and automatic conversions to '_Bool' or 'bool' are
47 performed in such a way that every nonzero value gets converted
48 to 'true', and zero gets converted to 'false'. This doesn't work
49 with this substitute. With this substitute, only the values 0 and 1
50 give the expected result when converted to _Bool' or 'bool'.
51
52 - C99 allows the use of (_Bool)0.0 in constant expressions, but
53 this substitute cannot always provide this property.
54
55 Also, it is suggested that programs use 'bool' rather than '_Bool';
56 this isn't required, but 'bool' is more common. */
57
58
59/* 7.16. Boolean type and values */
60
61/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
62 definitions below, but temporarily we have to #undef them. */
63#if defined __BEOS__ && !defined __HAIKU__
64# include <OS.h> /* defines bool but not _Bool */
65# undef false
66# undef true
67#endif
68
69#ifdef __cplusplus
70# define _Bool bool
71# define bool bool
72#else
73# if defined __BEOS__ && !defined __HAIKU__
74 /* A compiler known to have 'bool'. */
75 /* If the compiler already has both 'bool' and '_Bool', we can assume they
76 are the same types. */
77# if !@HAVE__BOOL@
78typedef bool _Bool;
79# endif
80# else
81# if !defined __GNUC__
82 /* If @HAVE__BOOL@:
83 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
84 the built-in _Bool type is used. See
85 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
86 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
87 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
88 Similar bugs are likely with other compilers as well; this file
89 wouldn't be used if <stdbool.h> was working.
90 So we override the _Bool type.
91 If !@HAVE__BOOL@:
92 Need to define _Bool ourselves. As 'signed char' or as an enum type?
93 Use of a typedef, with SunPRO C, leads to a stupid
94 "warning: _Bool is a keyword in ISO C99".
95 Use of an enum type, with IRIX cc, leads to a stupid
96 "warning(1185): enumerated type mixed with another type".
97 Even the existence of an enum type, without a typedef,
98 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
99 The only benefit of the enum, debuggability, is not important
100 with these compilers. So use 'signed char' and no enum. */
101# define _Bool signed char
102# else
103 /* With this compiler, trust the _Bool type if the compiler has it. */
104# if !@HAVE__BOOL@
105 /* For the sake of symbolic names in gdb, define true and false as
106 enum constants, not only as macros.
107 It is tempting to write
108 typedef enum { false = 0, true = 1 } _Bool;
109 so that gdb prints values of type 'bool' symbolically. But then
110 values of type '_Bool' might promote to 'int' or 'unsigned int'
111 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
112 (see ISO C 99 6.3.1.1.(2)). So add a negative value to the
113 enum; this ensures that '_Bool' promotes to 'int'. */
114typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
115# endif
116# endif
117# endif
118# define bool _Bool
119#endif
120
121/* The other macros must be usable in preprocessor directives. */
122#ifdef __cplusplus
123# define false false
124# define true true
125#else
126# define false 0
127# define true 1
128#endif
129
130#define __bool_true_false_are_defined 1
131
132#endif /* _GL_STDBOOL_H */
diff --git a/gl/stdckdint.in.h b/gl/stdckdint.in.h
new file mode 100644
index 0000000..71bab5f
--- /dev/null
+++ b/gl/stdckdint.in.h
@@ -0,0 +1,35 @@
1/* stdckdint.h -- checked integer arithmetic
2
3 Copyright 2022-2023 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_STDCKDINT_H
19#define _GL_STDCKDINT_H
20
21#include "intprops-internal.h"
22
23/* Store into *R the low-order bits of A + B, A - B, A * B, respectively.
24 Return 1 if the result overflows, 0 otherwise.
25 A, B, and *R can have any integer type other than char, bool, a
26 bit-precise integer type, or an enumeration type.
27
28 These are like the standard macros introduced in C23, except that
29 arguments should not have side effects. */
30
31#define ckd_add(r, a, b) ((bool) _GL_INT_ADD_WRAPV (a, b, r))
32#define ckd_sub(r, a, b) ((bool) _GL_INT_SUBTRACT_WRAPV (a, b, r))
33#define ckd_mul(r, a, b) ((bool) _GL_INT_MULTIPLY_WRAPV (a, b, r))
34
35#endif /* _GL_STDCKDINT_H */
diff --git a/gl/stddef.in.h b/gl/stddef.in.h
index 40f0536..6eadcc3 100644
--- a/gl/stddef.in.h
+++ b/gl/stddef.in.h
@@ -1,25 +1,25 @@
1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. 1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
2 2
3 Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * POSIX 2008 <stddef.h> for platforms that have issues. 21 * POSIX 2008 <stddef.h> for platforms that have issues.
22 * <http://www.opengroup.org/susv3xbd/stddef.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html>
23 */ 23 */
24 24
25#if __GNUC__ >= 3 25#if __GNUC__ >= 3
@@ -39,10 +39,16 @@
39 39
40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) 40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
41# ifdef __need_wint_t 41# ifdef __need_wint_t
42# undef _@GUARD_PREFIX@_STDDEF_H
43# define _GL_STDDEF_WINT_T 42# define _GL_STDDEF_WINT_T
44# endif 43# endif
45# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 44# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
45 /* On TinyCC, make sure that the macros that indicate the special invocation
46 convention get undefined. */
47# undef __need_wchar_t
48# undef __need_size_t
49# undef __need_ptrdiff_t
50# undef __need_NULL
51# undef __need_wint_t
46# endif 52# endif
47 53
48#else 54#else
@@ -50,37 +56,92 @@
50 56
51# ifndef _@GUARD_PREFIX@_STDDEF_H 57# ifndef _@GUARD_PREFIX@_STDDEF_H
52 58
59/* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
60 type with alignment 4, but 'long' has alignment 8. */
61# if defined _AIX && defined __LP64__
62# if !GNULIB_defined_max_align_t
63# ifdef _MAX_ALIGN_T
64/* /usr/include/stddef.h has already defined max_align_t. Override it. */
65typedef long rpl_max_align_t;
66# define max_align_t rpl_max_align_t
67# else
68/* Prevent /usr/include/stddef.h from defining max_align_t. */
69typedef long max_align_t;
70# define _MAX_ALIGN_T
71# endif
72# define GNULIB_defined_max_align_t 1
73# endif
74# endif
75
53/* The include_next requires a split double-inclusion guard. */ 76/* The include_next requires a split double-inclusion guard. */
54 77
55# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 78# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
56 79
57# ifndef _@GUARD_PREFIX@_STDDEF_H
58# define _@GUARD_PREFIX@_STDDEF_H
59
60/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 80/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
61#if @REPLACE_NULL@ 81# if (@REPLACE_NULL@ \
62# undef NULL 82 && (!defined _@GUARD_PREFIX@_STDDEF_H || defined _GL_STDDEF_WINT_T))
63# ifdef __cplusplus 83# undef NULL
84# ifdef __cplusplus
64 /* ISO C++ says that the macro NULL must expand to an integer constant 85 /* ISO C++ says that the macro NULL must expand to an integer constant
65 expression, hence '((void *) 0)' is not allowed in C++. */ 86 expression, hence '((void *) 0)' is not allowed in C++. */
66# if __GNUG__ >= 3 87# if __GNUG__ >= 3
67 /* GNU C++ has a __null macro that behaves like an integer ('int' or 88 /* GNU C++ has a __null macro that behaves like an integer ('int' or
68 'long') but has the same size as a pointer. Use that, to avoid 89 'long') but has the same size as a pointer. Use that, to avoid
69 warnings. */ 90 warnings. */
70# define NULL __null 91# define NULL __null
71# else 92# else
72# define NULL 0L 93# define NULL 0L
94# endif
95# else
96# define NULL ((void *) 0)
97# endif
73# endif 98# endif
74# else 99
75# define NULL ((void *) 0) 100# ifndef _@GUARD_PREFIX@_STDDEF_H
76# endif 101# define _@GUARD_PREFIX@_STDDEF_H
77#endif
78 102
79/* Some platforms lack wchar_t. */ 103/* Some platforms lack wchar_t. */
80#if !@HAVE_WCHAR_T@ 104#if !@HAVE_WCHAR_T@
81# define wchar_t int 105# define wchar_t int
82#endif 106#endif
83 107
108/* Some platforms lack max_align_t. The check for _GCC_MAX_ALIGN_T is
109 a hack in case the configure-time test was done with g++ even though
110 we are currently compiling with gcc.
111 On MSVC, max_align_t is defined only in C++ mode, after <cstddef> was
112 included. Its definition is good since it has an alignment of 8 (on x86
113 and x86_64).
114 Similarly on OS/2 kLIBC. */
115#if (defined _MSC_VER || (defined __KLIBC__ && !defined __LIBCN__)) \
116 && defined __cplusplus
117# include <cstddef>
118#else
119# if ! (@HAVE_MAX_ALIGN_T@ || (defined _GCC_MAX_ALIGN_T && !defined __clang__))
120# if !GNULIB_defined_max_align_t
121/* On the x86, the maximum storage alignment of double, long, etc. is 4,
122 but GCC's C11 ABI for x86 says that max_align_t has an alignment of 8,
123 and the C11 standard allows this. Work around this problem by
124 using __alignof__ (which returns 8 for double) rather than _Alignof
125 (which returns 4), and align each union member accordingly. */
126# if defined __GNUC__ || (__clang_major__ >= 4)
127# define _GL_STDDEF_ALIGNAS(type) \
128 __attribute__ ((__aligned__ (__alignof__ (type))))
129# else
130# define _GL_STDDEF_ALIGNAS(type) /* */
131# endif
132typedef union
133{
134 char *__p _GL_STDDEF_ALIGNAS (char *);
135 double __d _GL_STDDEF_ALIGNAS (double);
136 long double __ld _GL_STDDEF_ALIGNAS (long double);
137 long int __i _GL_STDDEF_ALIGNAS (long int);
138} rpl_max_align_t;
139# define max_align_t rpl_max_align_t
140# define GNULIB_defined_max_align_t 1
141# endif
142# endif
143#endif
144
84# endif /* _@GUARD_PREFIX@_STDDEF_H */ 145# endif /* _@GUARD_PREFIX@_STDDEF_H */
85# endif /* _@GUARD_PREFIX@_STDDEF_H */ 146# endif /* _@GUARD_PREFIX@_STDDEF_H */
86#endif /* __need_XXX */ 147#endif /* __need_XXX */
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 2db8b2e..5ddc644 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -1,23 +1,23 @@
1/* Copyright (C) 2001-2002, 2004-2013 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2002, 2004-2023 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. 2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* 18/*
19 * ISO C 99 <stdint.h> for platforms that lack it. 19 * ISO C 99 <stdint.h> for platforms that lack it.
20 * <http://www.opengroup.org/susv3xbd/stdint.h.html> 20 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html>
21 */ 21 */
22 22
23#ifndef _@GUARD_PREFIX@_STDINT_H 23#ifndef _@GUARD_PREFIX@_STDINT_H
@@ -38,8 +38,7 @@
38 other system header files; just include the system's <stdint.h>. 38 other system header files; just include the system's <stdint.h>.
39 Ideally we should test __BIONIC__ here, but it is only defined after 39 Ideally we should test __BIONIC__ here, but it is only defined after
40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */ 40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
41#if defined __ANDROID__ \ 41#if defined __ANDROID__ && defined _GL_INCLUDING_SYS_TYPES_H
42 && defined _SYS_TYPES_H_ && !defined __need_size_t
43# @INCLUDE_NEXT@ @NEXT_STDINT_H@ 42# @INCLUDE_NEXT@ @NEXT_STDINT_H@
44#else 43#else
45 44
@@ -80,54 +79,65 @@
80#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H 79#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
81#define _@GUARD_PREFIX@_STDINT_H 80#define _@GUARD_PREFIX@_STDINT_H
82 81
82/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
83 LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH. */
84#include <limits.h>
85
86/* Override WINT_MIN and WINT_MAX if gnulib's <wchar.h> or <wctype.h> overrides
87 wint_t. */
88#if @GNULIBHEADERS_OVERRIDE_WINT_T@
89# undef WINT_MIN
90# undef WINT_MAX
91# define WINT_MIN 0x0U
92# define WINT_MAX 0xffffffffU
93#endif
94
95#if ! @HAVE_C99_STDINT_H@
96
83/* <sys/types.h> defines some of the stdint.h types as well, on glibc, 97/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
84 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). 98 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
85 AIX 5.2 <sys/types.h> isn't needed and causes troubles. 99 AIX 5.2 <sys/types.h> isn't needed and causes troubles.
86 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but 100 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
87 relies on the system <stdint.h> definitions, so include 101 relies on the system <stdint.h> definitions, so include
88 <sys/types.h> after @NEXT_STDINT_H@. */ 102 <sys/types.h> after @NEXT_STDINT_H@. */
89#if @HAVE_SYS_TYPES_H@ && ! defined _AIX 103# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
90# include <sys/types.h> 104# include <sys/types.h>
91#endif 105# endif
92
93/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
94 LONG_MIN, LONG_MAX, ULONG_MAX. */
95#include <limits.h>
96 106
97#if @HAVE_INTTYPES_H@ 107# if @HAVE_INTTYPES_H@
98 /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines 108 /* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
99 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. 109 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
100 <inttypes.h> also defines intptr_t and uintptr_t. */ 110 <inttypes.h> also defines intptr_t and uintptr_t. */
101# include <inttypes.h> 111# include <inttypes.h>
102#elif @HAVE_SYS_INTTYPES_H@ 112# elif @HAVE_SYS_INTTYPES_H@
103 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and 113 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
104 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ 114 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
105# include <sys/inttypes.h> 115# include <sys/inttypes.h>
106#endif 116# endif
107 117
108#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ 118# if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__
109 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines 119 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
110 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is 120 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is
111 included by <sys/types.h>. */ 121 included by <sys/types.h>. */
112# include <sys/bitypes.h> 122# include <sys/bitypes.h>
113#endif 123# endif
114 124
115#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 125# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
116 126
117/* Minimum and maximum values for an integer type under the usual assumption. 127/* Minimum and maximum values for an integer type under the usual assumption.
118 Return an unspecified value if BITS == 0, adding a check to pacify 128 Return an unspecified value if BITS == 0, adding a check to pacify
119 picky compilers. */ 129 picky compilers. */
120 130
121#define _STDINT_MIN(signed, bits, zero) \ 131/* These are separate macros, because if you try to merge these macros into
122 ((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) 132 a single one, HP-UX cc rejects the resulting expression in constant
133 expressions. */
134# define _STDINT_UNSIGNED_MIN(bits, zero) \
135 (zero)
136# define _STDINT_SIGNED_MIN(bits, zero) \
137 (~ _STDINT_MAX (1, bits, zero))
123 138
124#define _STDINT_MAX(signed, bits, zero) \ 139# define _STDINT_MAX(signed, bits, zero) \
125 ((signed) \ 140 (((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
126 ? ~ _STDINT_MIN (signed, bits, zero) \
127 : /* The expression for the unsigned case. The subtraction of (signed) \
128 is a nop in the unsigned case and avoids "signed integer overflow" \
129 warnings in the signed case. */ \
130 ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
131 141
132#if !GNULIB_defined_stdint_types 142#if !GNULIB_defined_stdint_types
133 143
@@ -136,26 +146,26 @@
136/* Here we assume a standard architecture where the hardware integer 146/* Here we assume a standard architecture where the hardware integer
137 types have 8, 16, 32, optionally 64 bits. */ 147 types have 8, 16, 32, optionally 64 bits. */
138 148
139#undef int8_t 149# undef int8_t
140#undef uint8_t 150# undef uint8_t
141typedef signed char gl_int8_t; 151typedef signed char gl_int8_t;
142typedef unsigned char gl_uint8_t; 152typedef unsigned char gl_uint8_t;
143#define int8_t gl_int8_t 153# define int8_t gl_int8_t
144#define uint8_t gl_uint8_t 154# define uint8_t gl_uint8_t
145 155
146#undef int16_t 156# undef int16_t
147#undef uint16_t 157# undef uint16_t
148typedef short int gl_int16_t; 158typedef short int gl_int16_t;
149typedef unsigned short int gl_uint16_t; 159typedef unsigned short int gl_uint16_t;
150#define int16_t gl_int16_t 160# define int16_t gl_int16_t
151#define uint16_t gl_uint16_t 161# define uint16_t gl_uint16_t
152 162
153#undef int32_t 163# undef int32_t
154#undef uint32_t 164# undef uint32_t
155typedef int gl_int32_t; 165typedef int gl_int32_t;
156typedef unsigned int gl_uint32_t; 166typedef unsigned int gl_uint32_t;
157#define int32_t gl_int32_t 167# define int32_t gl_int32_t
158#define uint32_t gl_uint32_t 168# define uint32_t gl_uint32_t
159 169
160/* If the system defines INT64_MAX, assume int64_t works. That way, 170/* If the system defines INT64_MAX, assume int64_t works. That way,
161 if the underlying platform defines int64_t to be a 64-bit long long 171 if the underlying platform defines int64_t to be a 64-bit long long
@@ -163,54 +173,54 @@ typedef unsigned int gl_uint32_t;
163 int, which would mess up C++ name mangling. We must use #ifdef 173 int, which would mess up C++ name mangling. We must use #ifdef
164 rather than #if, to avoid an error with HP-UX 10.20 cc. */ 174 rather than #if, to avoid an error with HP-UX 10.20 cc. */
165 175
166#ifdef INT64_MAX 176# ifdef INT64_MAX
167# define GL_INT64_T 177# define GL_INT64_T
168#else 178# else
169/* Do not undefine int64_t if gnulib is not being used with 64-bit 179/* Do not undefine int64_t if gnulib is not being used with 64-bit
170 types, since otherwise it breaks platforms like Tandem/NSK. */ 180 types, since otherwise it breaks platforms like Tandem/NSK. */
171# if LONG_MAX >> 31 >> 31 == 1 181# if LONG_MAX >> 31 >> 31 == 1
172# undef int64_t 182# undef int64_t
173typedef long int gl_int64_t; 183typedef long int gl_int64_t;
174# define int64_t gl_int64_t 184# define int64_t gl_int64_t
175# define GL_INT64_T 185# define GL_INT64_T
176# elif defined _MSC_VER 186# elif defined _MSC_VER
177# undef int64_t 187# undef int64_t
178typedef __int64 gl_int64_t; 188typedef __int64 gl_int64_t;
179# define int64_t gl_int64_t 189# define int64_t gl_int64_t
180# define GL_INT64_T 190# define GL_INT64_T
181# elif @HAVE_LONG_LONG_INT@ 191# else
182# undef int64_t 192# undef int64_t
183typedef long long int gl_int64_t; 193typedef long long int gl_int64_t;
184# define int64_t gl_int64_t 194# define int64_t gl_int64_t
185# define GL_INT64_T 195# define GL_INT64_T
196# endif
186# endif 197# endif
187#endif
188 198
189#ifdef UINT64_MAX 199# ifdef UINT64_MAX
190# define GL_UINT64_T
191#else
192# if ULONG_MAX >> 31 >> 31 >> 1 == 1
193# undef uint64_t
194typedef unsigned long int gl_uint64_t;
195# define uint64_t gl_uint64_t
196# define GL_UINT64_T 200# define GL_UINT64_T
197# elif defined _MSC_VER 201# else
198# undef uint64_t 202# if ULONG_MAX >> 31 >> 31 >> 1 == 1
203# undef uint64_t
204typedef unsigned long int gl_uint64_t;
205# define uint64_t gl_uint64_t
206# define GL_UINT64_T
207# elif defined _MSC_VER
208# undef uint64_t
199typedef unsigned __int64 gl_uint64_t; 209typedef unsigned __int64 gl_uint64_t;
200# define uint64_t gl_uint64_t 210# define uint64_t gl_uint64_t
201# define GL_UINT64_T 211# define GL_UINT64_T
202# elif @HAVE_UNSIGNED_LONG_LONG_INT@ 212# else
203# undef uint64_t 213# undef uint64_t
204typedef unsigned long long int gl_uint64_t; 214typedef unsigned long long int gl_uint64_t;
205# define uint64_t gl_uint64_t 215# define uint64_t gl_uint64_t
206# define GL_UINT64_T 216# define GL_UINT64_T
217# endif
207# endif 218# endif
208#endif
209 219
210/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ 220/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
211#define _UINT8_T 221# define _UINT8_T
212#define _UINT32_T 222# define _UINT32_T
213#define _UINT64_T 223# define _UINT64_T
214 224
215 225
216/* 7.18.1.2. Minimum-width integer types */ 226/* 7.18.1.2. Minimum-width integer types */
@@ -219,26 +229,26 @@ typedef unsigned long long int gl_uint64_t;
219 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 229 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
220 are the same as the corresponding N_t types. */ 230 are the same as the corresponding N_t types. */
221 231
222#undef int_least8_t 232# undef int_least8_t
223#undef uint_least8_t 233# undef uint_least8_t
224#undef int_least16_t 234# undef int_least16_t
225#undef uint_least16_t 235# undef uint_least16_t
226#undef int_least32_t 236# undef int_least32_t
227#undef uint_least32_t 237# undef uint_least32_t
228#undef int_least64_t 238# undef int_least64_t
229#undef uint_least64_t 239# undef uint_least64_t
230#define int_least8_t int8_t 240# define int_least8_t int8_t
231#define uint_least8_t uint8_t 241# define uint_least8_t uint8_t
232#define int_least16_t int16_t 242# define int_least16_t int16_t
233#define uint_least16_t uint16_t 243# define uint_least16_t uint16_t
234#define int_least32_t int32_t 244# define int_least32_t int32_t
235#define uint_least32_t uint32_t 245# define uint_least32_t uint32_t
236#ifdef GL_INT64_T 246# ifdef GL_INT64_T
237# define int_least64_t int64_t 247# define int_least64_t int64_t
238#endif 248# endif
239#ifdef GL_UINT64_T 249# ifdef GL_UINT64_T
240# define uint_least64_t uint64_t 250# define uint_least64_t uint64_t
241#endif 251# endif
242 252
243/* 7.18.1.3. Fastest minimum-width integer types */ 253/* 7.18.1.3. Fastest minimum-width integer types */
244 254
@@ -251,50 +261,64 @@ typedef unsigned long long int gl_uint64_t;
251 uses types consistent with glibc, as that lessens the chance of 261 uses types consistent with glibc, as that lessens the chance of
252 incompatibility with older GNU hosts. */ 262 incompatibility with older GNU hosts. */
253 263
254#undef int_fast8_t 264# undef int_fast8_t
255#undef uint_fast8_t 265# undef uint_fast8_t
256#undef int_fast16_t 266# undef int_fast16_t
257#undef uint_fast16_t 267# undef uint_fast16_t
258#undef int_fast32_t 268# undef int_fast32_t
259#undef uint_fast32_t 269# undef uint_fast32_t
260#undef int_fast64_t 270# undef int_fast64_t
261#undef uint_fast64_t 271# undef uint_fast64_t
262typedef signed char gl_int_fast8_t; 272typedef signed char gl_int_fast8_t;
263typedef unsigned char gl_uint_fast8_t; 273typedef unsigned char gl_uint_fast8_t;
264 274
265#ifdef __sun 275# ifdef __sun
266/* Define types compatible with SunOS 5.10, so that code compiled under 276/* Define types compatible with SunOS 5.10, so that code compiled under
267 earlier SunOS versions works with code compiled under SunOS 5.10. */ 277 earlier SunOS versions works with code compiled under SunOS 5.10. */
268typedef int gl_int_fast32_t; 278typedef int gl_int_fast32_t;
269typedef unsigned int gl_uint_fast32_t; 279typedef unsigned int gl_uint_fast32_t;
270#else 280# else
271typedef long int gl_int_fast32_t; 281typedef long int gl_int_fast32_t;
272typedef unsigned long int gl_uint_fast32_t; 282typedef unsigned long int gl_uint_fast32_t;
273#endif 283# endif
274typedef gl_int_fast32_t gl_int_fast16_t; 284typedef gl_int_fast32_t gl_int_fast16_t;
275typedef gl_uint_fast32_t gl_uint_fast16_t; 285typedef gl_uint_fast32_t gl_uint_fast16_t;
276 286
277#define int_fast8_t gl_int_fast8_t 287# define int_fast8_t gl_int_fast8_t
278#define uint_fast8_t gl_uint_fast8_t 288# define uint_fast8_t gl_uint_fast8_t
279#define int_fast16_t gl_int_fast16_t 289# define int_fast16_t gl_int_fast16_t
280#define uint_fast16_t gl_uint_fast16_t 290# define uint_fast16_t gl_uint_fast16_t
281#define int_fast32_t gl_int_fast32_t 291# define int_fast32_t gl_int_fast32_t
282#define uint_fast32_t gl_uint_fast32_t 292# define uint_fast32_t gl_uint_fast32_t
283#ifdef GL_INT64_T 293# ifdef GL_INT64_T
284# define int_fast64_t int64_t 294# define int_fast64_t int64_t
285#endif 295# endif
286#ifdef GL_UINT64_T 296# ifdef GL_UINT64_T
287# define uint_fast64_t uint64_t 297# define uint_fast64_t uint64_t
288#endif 298# endif
289 299
290/* 7.18.1.4. Integer types capable of holding object pointers */ 300/* 7.18.1.4. Integer types capable of holding object pointers */
291 301
292#undef intptr_t 302/* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own
293#undef uintptr_t 303 definitions of intptr_t and uintptr_t (which use int and unsigned)
304 to avoid clashes with declarations of system functions like sbrk.
305 Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and
306 uintptr_t to avoid conflicting declarations of system functions like
307 _findclose in <io.h>. */
308# if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
309 || defined __MINGW32__)
310# undef intptr_t
311# undef uintptr_t
312# ifdef _WIN64
313typedef long long int gl_intptr_t;
314typedef unsigned long long int gl_uintptr_t;
315# else
294typedef long int gl_intptr_t; 316typedef long int gl_intptr_t;
295typedef unsigned long int gl_uintptr_t; 317typedef unsigned long int gl_uintptr_t;
296#define intptr_t gl_intptr_t 318# endif
297#define uintptr_t gl_uintptr_t 319# define intptr_t gl_intptr_t
320# define uintptr_t gl_uintptr_t
321# endif
298 322
299/* 7.18.1.5. Greatest-width integer types */ 323/* 7.18.1.5. Greatest-width integer types */
300 324
@@ -305,33 +329,33 @@ typedef unsigned long int gl_uintptr_t;
305 similarly for UINTMAX_MAX and uintmax_t. This avoids problems with 329 similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
306 assuming one type where another is used by the system. */ 330 assuming one type where another is used by the system. */
307 331
308#ifndef INTMAX_MAX 332# ifndef INTMAX_MAX
309# undef INTMAX_C 333# undef INTMAX_C
310# undef intmax_t 334# undef intmax_t
311# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 335# if LONG_MAX >> 30 == 1
312typedef long long int gl_intmax_t; 336typedef long long int gl_intmax_t;
313# define intmax_t gl_intmax_t 337# define intmax_t gl_intmax_t
314# elif defined GL_INT64_T 338# elif defined GL_INT64_T
315# define intmax_t int64_t 339# define intmax_t int64_t
316# else 340# else
317typedef long int gl_intmax_t; 341typedef long int gl_intmax_t;
318# define intmax_t gl_intmax_t 342# define intmax_t gl_intmax_t
343# endif
319# endif 344# endif
320#endif
321 345
322#ifndef UINTMAX_MAX 346# ifndef UINTMAX_MAX
323# undef UINTMAX_C 347# undef UINTMAX_C
324# undef uintmax_t 348# undef uintmax_t
325# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 349# if ULONG_MAX >> 31 == 1
326typedef unsigned long long int gl_uintmax_t; 350typedef unsigned long long int gl_uintmax_t;
327# define uintmax_t gl_uintmax_t 351# define uintmax_t gl_uintmax_t
328# elif defined GL_UINT64_T 352# elif defined GL_UINT64_T
329# define uintmax_t uint64_t 353# define uintmax_t uint64_t
330# else 354# else
331typedef unsigned long int gl_uintmax_t; 355typedef unsigned long int gl_uintmax_t;
332# define uintmax_t gl_uintmax_t 356# define uintmax_t gl_uintmax_t
357# endif
333# endif 358# endif
334#endif
335 359
336/* Verify that intmax_t and uintmax_t have the same size. Too much code 360/* Verify that intmax_t and uintmax_t have the same size. Too much code
337 breaks if this is not the case. If this check fails, the reason is likely 361 breaks if this is not the case. If this check fails, the reason is likely
@@ -339,8 +363,8 @@ typedef unsigned long int gl_uintmax_t;
339typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) 363typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
340 ? 1 : -1]; 364 ? 1 : -1];
341 365
342#define GNULIB_defined_stdint_types 1 366# define GNULIB_defined_stdint_types 1
343#endif /* !GNULIB_defined_stdint_types */ 367# endif /* !GNULIB_defined_stdint_types */
344 368
345/* 7.18.2. Limits of specified-width integer types */ 369/* 7.18.2. Limits of specified-width integer types */
346 370
@@ -349,37 +373,37 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
349/* Here we assume a standard architecture where the hardware integer 373/* Here we assume a standard architecture where the hardware integer
350 types have 8, 16, 32, optionally 64 bits. */ 374 types have 8, 16, 32, optionally 64 bits. */
351 375
352#undef INT8_MIN 376# undef INT8_MIN
353#undef INT8_MAX 377# undef INT8_MAX
354#undef UINT8_MAX 378# undef UINT8_MAX
355#define INT8_MIN (~ INT8_MAX) 379# define INT8_MIN (~ INT8_MAX)
356#define INT8_MAX 127 380# define INT8_MAX 127
357#define UINT8_MAX 255 381# define UINT8_MAX 255
358 382
359#undef INT16_MIN 383# undef INT16_MIN
360#undef INT16_MAX 384# undef INT16_MAX
361#undef UINT16_MAX 385# undef UINT16_MAX
362#define INT16_MIN (~ INT16_MAX) 386# define INT16_MIN (~ INT16_MAX)
363#define INT16_MAX 32767 387# define INT16_MAX 32767
364#define UINT16_MAX 65535 388# define UINT16_MAX 65535
365 389
366#undef INT32_MIN 390# undef INT32_MIN
367#undef INT32_MAX 391# undef INT32_MAX
368#undef UINT32_MAX 392# undef UINT32_MAX
369#define INT32_MIN (~ INT32_MAX) 393# define INT32_MIN (~ INT32_MAX)
370#define INT32_MAX 2147483647 394# define INT32_MAX 2147483647
371#define UINT32_MAX 4294967295U 395# define UINT32_MAX 4294967295U
372 396
373#if defined GL_INT64_T && ! defined INT64_MAX 397# if defined GL_INT64_T && ! defined INT64_MAX
374/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 398/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
375 evaluates the latter incorrectly in preprocessor expressions. */ 399 evaluates the latter incorrectly in preprocessor expressions. */
376# define INT64_MIN (- INTMAX_C (1) << 63) 400# define INT64_MIN (- INTMAX_C (1) << 63)
377# define INT64_MAX INTMAX_C (9223372036854775807) 401# define INT64_MAX INTMAX_C (9223372036854775807)
378#endif 402# endif
379 403
380#if defined GL_UINT64_T && ! defined UINT64_MAX 404# if defined GL_UINT64_T && ! defined UINT64_MAX
381# define UINT64_MAX UINTMAX_C (18446744073709551615) 405# define UINT64_MAX UINTMAX_C (18446744073709551615)
382#endif 406# endif
383 407
384/* 7.18.2.2. Limits of minimum-width integer types */ 408/* 7.18.2.2. Limits of minimum-width integer types */
385 409
@@ -387,38 +411,38 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
387 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 411 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
388 are the same as the corresponding N_t types. */ 412 are the same as the corresponding N_t types. */
389 413
390#undef INT_LEAST8_MIN 414# undef INT_LEAST8_MIN
391#undef INT_LEAST8_MAX 415# undef INT_LEAST8_MAX
392#undef UINT_LEAST8_MAX 416# undef UINT_LEAST8_MAX
393#define INT_LEAST8_MIN INT8_MIN 417# define INT_LEAST8_MIN INT8_MIN
394#define INT_LEAST8_MAX INT8_MAX 418# define INT_LEAST8_MAX INT8_MAX
395#define UINT_LEAST8_MAX UINT8_MAX 419# define UINT_LEAST8_MAX UINT8_MAX
396 420
397#undef INT_LEAST16_MIN 421# undef INT_LEAST16_MIN
398#undef INT_LEAST16_MAX 422# undef INT_LEAST16_MAX
399#undef UINT_LEAST16_MAX 423# undef UINT_LEAST16_MAX
400#define INT_LEAST16_MIN INT16_MIN 424# define INT_LEAST16_MIN INT16_MIN
401#define INT_LEAST16_MAX INT16_MAX 425# define INT_LEAST16_MAX INT16_MAX
402#define UINT_LEAST16_MAX UINT16_MAX 426# define UINT_LEAST16_MAX UINT16_MAX
403 427
404#undef INT_LEAST32_MIN 428# undef INT_LEAST32_MIN
405#undef INT_LEAST32_MAX 429# undef INT_LEAST32_MAX
406#undef UINT_LEAST32_MAX 430# undef UINT_LEAST32_MAX
407#define INT_LEAST32_MIN INT32_MIN 431# define INT_LEAST32_MIN INT32_MIN
408#define INT_LEAST32_MAX INT32_MAX 432# define INT_LEAST32_MAX INT32_MAX
409#define UINT_LEAST32_MAX UINT32_MAX 433# define UINT_LEAST32_MAX UINT32_MAX
410 434
411#undef INT_LEAST64_MIN 435# undef INT_LEAST64_MIN
412#undef INT_LEAST64_MAX 436# undef INT_LEAST64_MAX
413#ifdef GL_INT64_T 437# ifdef GL_INT64_T
414# define INT_LEAST64_MIN INT64_MIN 438# define INT_LEAST64_MIN INT64_MIN
415# define INT_LEAST64_MAX INT64_MAX 439# define INT_LEAST64_MAX INT64_MAX
416#endif 440# endif
417 441
418#undef UINT_LEAST64_MAX 442# undef UINT_LEAST64_MAX
419#ifdef GL_UINT64_T 443# ifdef GL_UINT64_T
420# define UINT_LEAST64_MAX UINT64_MAX 444# define UINT_LEAST64_MAX UINT64_MAX
421#endif 445# endif
422 446
423/* 7.18.2.3. Limits of fastest minimum-width integer types */ 447/* 7.18.2.3. Limits of fastest minimum-width integer types */
424 448
@@ -426,117 +450,127 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
426 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 450 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
427 are taken from the same list of types. */ 451 are taken from the same list of types. */
428 452
429#undef INT_FAST8_MIN 453# undef INT_FAST8_MIN
430#undef INT_FAST8_MAX 454# undef INT_FAST8_MAX
431#undef UINT_FAST8_MAX 455# undef UINT_FAST8_MAX
432#define INT_FAST8_MIN SCHAR_MIN 456# define INT_FAST8_MIN SCHAR_MIN
433#define INT_FAST8_MAX SCHAR_MAX 457# define INT_FAST8_MAX SCHAR_MAX
434#define UINT_FAST8_MAX UCHAR_MAX 458# define UINT_FAST8_MAX UCHAR_MAX
435 459
436#undef INT_FAST16_MIN 460# undef INT_FAST16_MIN
437#undef INT_FAST16_MAX 461# undef INT_FAST16_MAX
438#undef UINT_FAST16_MAX 462# undef UINT_FAST16_MAX
439#define INT_FAST16_MIN INT_FAST32_MIN 463# define INT_FAST16_MIN INT_FAST32_MIN
440#define INT_FAST16_MAX INT_FAST32_MAX 464# define INT_FAST16_MAX INT_FAST32_MAX
441#define UINT_FAST16_MAX UINT_FAST32_MAX 465# define UINT_FAST16_MAX UINT_FAST32_MAX
442 466
443#undef INT_FAST32_MIN 467# undef INT_FAST32_MIN
444#undef INT_FAST32_MAX 468# undef INT_FAST32_MAX
445#undef UINT_FAST32_MAX 469# undef UINT_FAST32_MAX
446#ifdef __sun 470# ifdef __sun
447# define INT_FAST32_MIN INT_MIN 471# define INT_FAST32_MIN INT_MIN
448# define INT_FAST32_MAX INT_MAX 472# define INT_FAST32_MAX INT_MAX
449# define UINT_FAST32_MAX UINT_MAX 473# define UINT_FAST32_MAX UINT_MAX
450#else 474# else
451# define INT_FAST32_MIN LONG_MIN 475# define INT_FAST32_MIN LONG_MIN
452# define INT_FAST32_MAX LONG_MAX 476# define INT_FAST32_MAX LONG_MAX
453# define UINT_FAST32_MAX ULONG_MAX 477# define UINT_FAST32_MAX ULONG_MAX
454#endif 478# endif
455 479
456#undef INT_FAST64_MIN 480# undef INT_FAST64_MIN
457#undef INT_FAST64_MAX 481# undef INT_FAST64_MAX
458#ifdef GL_INT64_T 482# ifdef GL_INT64_T
459# define INT_FAST64_MIN INT64_MIN 483# define INT_FAST64_MIN INT64_MIN
460# define INT_FAST64_MAX INT64_MAX 484# define INT_FAST64_MAX INT64_MAX
461#endif 485# endif
462 486
463#undef UINT_FAST64_MAX 487# undef UINT_FAST64_MAX
464#ifdef GL_UINT64_T 488# ifdef GL_UINT64_T
465# define UINT_FAST64_MAX UINT64_MAX 489# define UINT_FAST64_MAX UINT64_MAX
466#endif 490# endif
467 491
468/* 7.18.2.4. Limits of integer types capable of holding object pointers */ 492/* 7.18.2.4. Limits of integer types capable of holding object pointers */
469 493
470#undef INTPTR_MIN 494# undef INTPTR_MIN
471#undef INTPTR_MAX 495# undef INTPTR_MAX
472#undef UINTPTR_MAX 496# undef UINTPTR_MAX
473#define INTPTR_MIN LONG_MIN 497# ifdef _WIN64
474#define INTPTR_MAX LONG_MAX 498# define INTPTR_MIN LLONG_MIN
475#define UINTPTR_MAX ULONG_MAX 499# define INTPTR_MAX LLONG_MAX
500# define UINTPTR_MAX ULLONG_MAX
501# else
502# define INTPTR_MIN LONG_MIN
503# define INTPTR_MAX LONG_MAX
504# define UINTPTR_MAX ULONG_MAX
505# endif
476 506
477/* 7.18.2.5. Limits of greatest-width integer types */ 507/* 7.18.2.5. Limits of greatest-width integer types */
478 508
479#ifndef INTMAX_MAX 509# ifndef INTMAX_MAX
480# undef INTMAX_MIN 510# undef INTMAX_MIN
481# ifdef INT64_MAX 511# ifdef INT64_MAX
482# define INTMAX_MIN INT64_MIN 512# define INTMAX_MIN INT64_MIN
483# define INTMAX_MAX INT64_MAX 513# define INTMAX_MAX INT64_MAX
484# else 514# else
485# define INTMAX_MIN INT32_MIN 515# define INTMAX_MIN INT32_MIN
486# define INTMAX_MAX INT32_MAX 516# define INTMAX_MAX INT32_MAX
517# endif
487# endif 518# endif
488#endif
489 519
490#ifndef UINTMAX_MAX 520# ifndef UINTMAX_MAX
491# ifdef UINT64_MAX 521# ifdef UINT64_MAX
492# define UINTMAX_MAX UINT64_MAX 522# define UINTMAX_MAX UINT64_MAX
493# else 523# else
494# define UINTMAX_MAX UINT32_MAX 524# define UINTMAX_MAX UINT32_MAX
525# endif
495# endif 526# endif
496#endif
497 527
498/* 7.18.3. Limits of other integer types */ 528/* 7.18.3. Limits of other integer types */
499 529
500/* ptrdiff_t limits */ 530/* ptrdiff_t limits */
501#undef PTRDIFF_MIN 531# undef PTRDIFF_MIN
502#undef PTRDIFF_MAX 532# undef PTRDIFF_MAX
503#if @APPLE_UNIVERSAL_BUILD@ 533# if @APPLE_UNIVERSAL_BUILD@
504# ifdef _LP64 534# ifdef _LP64
505# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) 535# define PTRDIFF_MIN _STDINT_SIGNED_MIN (64, 0l)
506# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) 536# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
537# else
538# define PTRDIFF_MIN _STDINT_SIGNED_MIN (32, 0)
539# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
540# endif
507# else 541# else
508# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) 542# define PTRDIFF_MIN \
509# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) 543 _STDINT_SIGNED_MIN (@BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
510# endif 544# define PTRDIFF_MAX \
511#else
512# define PTRDIFF_MIN \
513 _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
514# define PTRDIFF_MAX \
515 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) 545 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
516#endif 546# endif
517 547
518/* sig_atomic_t limits */ 548/* sig_atomic_t limits */
519#undef SIG_ATOMIC_MIN 549# undef SIG_ATOMIC_MIN
520#undef SIG_ATOMIC_MAX 550# undef SIG_ATOMIC_MAX
521#define SIG_ATOMIC_MIN \ 551# if @HAVE_SIGNED_SIG_ATOMIC_T@
522 _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 552# define SIG_ATOMIC_MIN \
523 0@SIG_ATOMIC_T_SUFFIX@) 553 _STDINT_SIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
524#define SIG_ATOMIC_MAX \ 554# else
555# define SIG_ATOMIC_MIN \
556 _STDINT_UNSIGNED_MIN (@BITSIZEOF_SIG_ATOMIC_T@, 0@SIG_ATOMIC_T_SUFFIX@)
557# endif
558# define SIG_ATOMIC_MAX \
525 _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ 559 _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
526 0@SIG_ATOMIC_T_SUFFIX@) 560 0@SIG_ATOMIC_T_SUFFIX@)
527 561
528 562
529/* size_t limit */ 563/* size_t limit */
530#undef SIZE_MAX 564# undef SIZE_MAX
531#if @APPLE_UNIVERSAL_BUILD@ 565# if @APPLE_UNIVERSAL_BUILD@
532# ifdef _LP64 566# ifdef _LP64
533# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) 567# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
568# else
569# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
570# endif
534# else 571# else
535# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) 572# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
536# endif 573# endif
537#else
538# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
539#endif
540 574
541/* wchar_t limits */ 575/* wchar_t limits */
542/* Get WCHAR_MIN, WCHAR_MAX. 576/* Get WCHAR_MIN, WCHAR_MAX.
@@ -544,30 +578,39 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
544 sequence of nested includes 578 sequence of nested includes
545 <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes 579 <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
546 <stdint.h> and assumes its types are already defined. */ 580 <stdint.h> and assumes its types are already defined. */
547#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) 581# if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
548 /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 582# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
549 included before <wchar.h>. */ 583# include <wchar.h>
550# include <stddef.h> 584# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
551# include <stdio.h> 585# endif
552# include <time.h> 586# undef WCHAR_MIN
553# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 587# undef WCHAR_MAX
554# include <wchar.h> 588# if @HAVE_SIGNED_WCHAR_T@
555# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 589# define WCHAR_MIN \
556#endif 590 _STDINT_SIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
557#undef WCHAR_MIN 591# else
558#undef WCHAR_MAX 592# define WCHAR_MIN \
559#define WCHAR_MIN \ 593 _STDINT_UNSIGNED_MIN (@BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
560 _STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 594# endif
561#define WCHAR_MAX \ 595# define WCHAR_MAX \
562 _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) 596 _STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@)
563 597
564/* wint_t limits */ 598/* wint_t limits */
565#undef WINT_MIN 599/* If gnulib's <wchar.h> or <wctype.h> overrides wint_t, @WINT_T_SUFFIX@ is not
566#undef WINT_MAX 600 accurate, therefore use the definitions from above. */
567#define WINT_MIN \ 601# if !@GNULIBHEADERS_OVERRIDE_WINT_T@
568 _STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 602# undef WINT_MIN
569#define WINT_MAX \ 603# undef WINT_MAX
570 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 604# if @HAVE_SIGNED_WINT_T@
605# define WINT_MIN \
606 _STDINT_SIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
607# else
608# define WINT_MIN \
609 _STDINT_UNSIGNED_MIN (@BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
610# endif
611# define WINT_MAX \
612 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
613# endif
571 614
572/* 7.18.4. Macros for integer constants */ 615/* 7.18.4. Macros for integer constants */
573 616
@@ -577,59 +620,120 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
577/* Here we assume a standard architecture where the hardware integer 620/* Here we assume a standard architecture where the hardware integer
578 types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ 621 types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */
579 622
580#undef INT8_C 623# undef INT8_C
581#undef UINT8_C 624# undef UINT8_C
582#define INT8_C(x) x 625# define INT8_C(x) x
583#define UINT8_C(x) x 626# define UINT8_C(x) x
584
585#undef INT16_C
586#undef UINT16_C
587#define INT16_C(x) x
588#define UINT16_C(x) x
589
590#undef INT32_C
591#undef UINT32_C
592#define INT32_C(x) x
593#define UINT32_C(x) x ## U
594
595#undef INT64_C
596#undef UINT64_C
597#if LONG_MAX >> 31 >> 31 == 1
598# define INT64_C(x) x##L
599#elif defined _MSC_VER
600# define INT64_C(x) x##i64
601#elif @HAVE_LONG_LONG_INT@
602# define INT64_C(x) x##LL
603#endif
604#if ULONG_MAX >> 31 >> 31 >> 1 == 1
605# define UINT64_C(x) x##UL
606#elif defined _MSC_VER
607# define UINT64_C(x) x##ui64
608#elif @HAVE_UNSIGNED_LONG_LONG_INT@
609# define UINT64_C(x) x##ULL
610#endif
611 627
612/* 7.18.4.2. Macros for greatest-width integer constants */ 628# undef INT16_C
629# undef UINT16_C
630# define INT16_C(x) x
631# define UINT16_C(x) x
632
633# undef INT32_C
634# undef UINT32_C
635# define INT32_C(x) x
636# define UINT32_C(x) x ## U
613 637
614#ifndef INTMAX_C 638# undef INT64_C
615# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 639# undef UINT64_C
616# define INTMAX_C(x) x##LL 640# if LONG_MAX >> 31 >> 31 == 1
617# elif defined GL_INT64_T 641# define INT64_C(x) x##L
618# define INTMAX_C(x) INT64_C(x) 642# elif defined _MSC_VER
643# define INT64_C(x) x##i64
619# else 644# else
620# define INTMAX_C(x) x##L 645# define INT64_C(x) x##LL
621# endif 646# endif
622#endif 647# if ULONG_MAX >> 31 >> 31 >> 1 == 1
623 648# define UINT64_C(x) x##UL
624#ifndef UINTMAX_C 649# elif defined _MSC_VER
625# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 650# define UINT64_C(x) x##ui64
626# define UINTMAX_C(x) x##ULL
627# elif defined GL_UINT64_T
628# define UINTMAX_C(x) UINT64_C(x)
629# else 651# else
630# define UINTMAX_C(x) x##UL 652# define UINT64_C(x) x##ULL
631# endif 653# endif
632#endif 654
655/* 7.18.4.2. Macros for greatest-width integer constants */
656
657# ifndef INTMAX_C
658# if LONG_MAX >> 30 == 1
659# define INTMAX_C(x) x##LL
660# elif defined GL_INT64_T
661# define INTMAX_C(x) INT64_C(x)
662# else
663# define INTMAX_C(x) x##L
664# endif
665# endif
666
667# ifndef UINTMAX_C
668# if ULONG_MAX >> 31 == 1
669# define UINTMAX_C(x) x##ULL
670# elif defined GL_UINT64_T
671# define UINTMAX_C(x) UINT64_C(x)
672# else
673# define UINTMAX_C(x) x##UL
674# endif
675# endif
676
677#endif /* !@HAVE_C99_STDINT_H@ */
678
679/* Macros specified by ISO/IEC TS 18661-1:2014. */
680
681#if (!defined UINTMAX_WIDTH \
682 && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__))
683# ifdef INT8_MAX
684# define INT8_WIDTH _GL_INTEGER_WIDTH (INT8_MIN, INT8_MAX)
685# endif
686# ifdef UINT8_MAX
687# define UINT8_WIDTH _GL_INTEGER_WIDTH (0, UINT8_MAX)
688# endif
689# ifdef INT16_MAX
690# define INT16_WIDTH _GL_INTEGER_WIDTH (INT16_MIN, INT16_MAX)
691# endif
692# ifdef UINT16_MAX
693# define UINT16_WIDTH _GL_INTEGER_WIDTH (0, UINT16_MAX)
694# endif
695# ifdef INT32_MAX
696# define INT32_WIDTH _GL_INTEGER_WIDTH (INT32_MIN, INT32_MAX)
697# endif
698# ifdef UINT32_MAX
699# define UINT32_WIDTH _GL_INTEGER_WIDTH (0, UINT32_MAX)
700# endif
701# ifdef INT64_MAX
702# define INT64_WIDTH _GL_INTEGER_WIDTH (INT64_MIN, INT64_MAX)
703# endif
704# ifdef UINT64_MAX
705# define UINT64_WIDTH _GL_INTEGER_WIDTH (0, UINT64_MAX)
706# endif
707# define INT_LEAST8_WIDTH _GL_INTEGER_WIDTH (INT_LEAST8_MIN, INT_LEAST8_MAX)
708# define UINT_LEAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST8_MAX)
709# define INT_LEAST16_WIDTH _GL_INTEGER_WIDTH (INT_LEAST16_MIN, INT_LEAST16_MAX)
710# define UINT_LEAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST16_MAX)
711# define INT_LEAST32_WIDTH _GL_INTEGER_WIDTH (INT_LEAST32_MIN, INT_LEAST32_MAX)
712# define UINT_LEAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST32_MAX)
713# define INT_LEAST64_WIDTH _GL_INTEGER_WIDTH (INT_LEAST64_MIN, INT_LEAST64_MAX)
714# define UINT_LEAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_LEAST64_MAX)
715# define INT_FAST8_WIDTH _GL_INTEGER_WIDTH (INT_FAST8_MIN, INT_FAST8_MAX)
716# define UINT_FAST8_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST8_MAX)
717# define INT_FAST16_WIDTH _GL_INTEGER_WIDTH (INT_FAST16_MIN, INT_FAST16_MAX)
718# define UINT_FAST16_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST16_MAX)
719# define INT_FAST32_WIDTH _GL_INTEGER_WIDTH (INT_FAST32_MIN, INT_FAST32_MAX)
720# define UINT_FAST32_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST32_MAX)
721# define INT_FAST64_WIDTH _GL_INTEGER_WIDTH (INT_FAST64_MIN, INT_FAST64_MAX)
722# define UINT_FAST64_WIDTH _GL_INTEGER_WIDTH (0, UINT_FAST64_MAX)
723# define INTPTR_WIDTH _GL_INTEGER_WIDTH (INTPTR_MIN, INTPTR_MAX)
724# define UINTPTR_WIDTH _GL_INTEGER_WIDTH (0, UINTPTR_MAX)
725# define INTMAX_WIDTH _GL_INTEGER_WIDTH (INTMAX_MIN, INTMAX_MAX)
726# define UINTMAX_WIDTH _GL_INTEGER_WIDTH (0, UINTMAX_MAX)
727# define PTRDIFF_WIDTH _GL_INTEGER_WIDTH (PTRDIFF_MIN, PTRDIFF_MAX)
728# define SIZE_WIDTH _GL_INTEGER_WIDTH (0, SIZE_MAX)
729# define WCHAR_WIDTH _GL_INTEGER_WIDTH (WCHAR_MIN, WCHAR_MAX)
730# ifdef WINT_MAX
731# define WINT_WIDTH _GL_INTEGER_WIDTH (WINT_MIN, WINT_MAX)
732# endif
733# ifdef SIG_ATOMIC_MAX
734# define SIG_ATOMIC_WIDTH _GL_INTEGER_WIDTH (SIG_ATOMIC_MIN, SIG_ATOMIC_MAX)
735# endif
736#endif /* !WINT_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */
633 737
634#endif /* _@GUARD_PREFIX@_STDINT_H */ 738#endif /* _@GUARD_PREFIX@_STDINT_H */
635#endif /* !(defined __ANDROID__ && ...) */ 739#endif /* !(defined __ANDROID__ && ...) */
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
new file mode 100644
index 0000000..46608be
--- /dev/null
+++ b/gl/stdio-impl.h
@@ -0,0 +1,218 @@
1/* Implementation details of FILE streams.
2 Copyright (C) 2007-2008, 2010-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Many stdio implementations have the same logic and therefore can share
18 the same implementation of stdio extension API, except that some fields
19 have different naming conventions, or their access requires some casts. */
20
21/* Glibc 2.28 made _IO_UNBUFFERED and _IO_IN_BACKUP private. For now, work
22 around this problem by defining them ourselves. FIXME: Do not rely on glibc
23 internals. */
24#if defined _IO_EOF_SEEN
25# if !defined _IO_UNBUFFERED
26# define _IO_UNBUFFERED 0x2
27# endif
28# if !defined _IO_IN_BACKUP
29# define _IO_IN_BACKUP 0x100
30# endif
31#endif
32
33/* BSD stdio derived implementations. */
34
35#if defined __NetBSD__ /* NetBSD */
36/* Get __NetBSD_Version__. */
37# include <sys/param.h>
38#endif
39
40#include <errno.h> /* For detecting Plan9. */
41
42#if defined __sferror || defined __DragonFly__ || defined __ANDROID__
43 /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
44
45# if defined __DragonFly__ /* DragonFly */
46 /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/lib/libc/stdio/priv_stdio.h>. */
47# define fp_ ((struct { struct __FILE_public pub; \
48 struct { unsigned char *_base; int _size; } _bf; \
49 void *cookie; \
50 void *_close; \
51 void *_read; \
52 void *_seek; \
53 void *_write; \
54 struct { unsigned char *_base; int _size; } _ub; \
55 int _ur; \
56 unsigned char _ubuf[3]; \
57 unsigned char _nbuf[1]; \
58 struct { unsigned char *_base; int _size; } _lb; \
59 int _blksize; \
60 fpos_t _offset; \
61 /* More fields, not relevant here. */ \
62 } *) fp)
63 /* See <https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/include/stdio.h>. */
64# define _p pub._p
65# define _flags pub._flags
66# define _r pub._r
67# define _w pub._w
68# elif defined __ANDROID__ /* Android */
69# ifdef __LP64__
70# define _gl_flags_file_t int
71# else
72# define _gl_flags_file_t short
73# endif
74# ifdef __LP64__
75# define _gl_file_offset_t int64_t
76# else
77 /* see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md */
78# define _gl_file_offset_t __kernel_off_t
79# endif
80 /* Up to this commit from 2015-10-12
81 <https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
82 the innards of FILE were public, and fp_ub could be defined like for OpenBSD,
83 see <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/fileext.h>
84 and <https://android.googlesource.com/platform/bionic.git/+/e78392637d5086384a5631ddfdfa8d7ec8326ee3/libc/stdio/local.h>.
85 After this commit, the innards of FILE are hidden. */
86# define fp_ ((struct { unsigned char *_p; \
87 int _r; \
88 int _w; \
89 _gl_flags_file_t _flags; \
90 _gl_flags_file_t _file; \
91 struct { unsigned char *_base; size_t _size; } _bf; \
92 int _lbfsize; \
93 void *_cookie; \
94 void *_close; \
95 void *_read; \
96 void *_seek; \
97 void *_write; \
98 struct { unsigned char *_base; size_t _size; } _ext; \
99 unsigned char *_up; \
100 int _ur; \
101 unsigned char _ubuf[3]; \
102 unsigned char _nbuf[1]; \
103 struct { unsigned char *_base; size_t _size; } _lb; \
104 int _blksize; \
105 _gl_file_offset_t _offset; \
106 /* More fields, not relevant here. */ \
107 } *) fp)
108# else
109# define fp_ fp
110# endif
111
112# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ || defined __minix /* NetBSD >= 1.5ZA, OpenBSD, Minix 3 */
113 /* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
114 and <https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
115 and <https://github.com/Stichting-MINIX-Research-Foundation/minix/blob/master/lib/libc/stdio/fileext.h> */
116 struct __sfileext
117 {
118 struct __sbuf _ub; /* ungetc buffer */
119 /* More fields, not relevant here. */
120 };
121# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
122# elif defined __ANDROID__ /* Android */
123 struct __sfileext
124 {
125 struct { unsigned char *_base; size_t _size; } _ub; /* ungetc buffer */
126 /* More fields, not relevant here. */
127 };
128# define fp_ub ((struct __sfileext *) fp_->_ext._base)->_ub
129# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, Mac OS X, Cygwin */
130# define fp_ub fp_->_ub
131# endif
132
133# define HASUB(fp) (fp_ub._base != NULL)
134
135# if defined __ANDROID__ /* Android */
136 /* Needed after this commit from 2016-01-25
137 <https://android.googlesource.com/platform/bionic.git/+/e70e0e9267d069bf56a5078c99307e08a7280de7> */
138# ifndef __SEOF
139# define __SLBF 1
140# define __SNBF 2
141# define __SRD 4
142# define __SWR 8
143# define __SRW 0x10
144# define __SEOF 0x20
145# define __SERR 0x40
146# endif
147# ifndef __SOFF
148# define __SOFF 0x1000
149# endif
150# endif
151
152#endif
153
154
155/* SystemV derived implementations. */
156
157#ifdef __TANDEM /* NonStop Kernel */
158# ifndef _IOERR
159/* These values were determined by the program 'stdioext-flags' at
160 <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
161# define _IOERR 0x40
162# define _IOREAD 0x80
163# define _IOWRT 0x4
164# define _IORW 0x100
165# endif
166#endif
167
168#if defined _IOERR
169
170# if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
171# define fp_ ((struct { unsigned char *_ptr; \
172 unsigned char *_base; \
173 unsigned char *_end; \
174 long _cnt; \
175 int _file; \
176 unsigned int _flag; \
177 } *) fp)
178# elif defined __VMS /* OpenVMS */
179# define fp_ ((struct _iobuf *) fp)
180# else
181# define fp_ fp
182# endif
183
184# if defined _SCO_DS || (defined __SCO_VERSION__ || defined __sysv5__) /* OpenServer 5, OpenServer 6, UnixWare 7 */
185# define _cnt __cnt
186# define _ptr __ptr
187# define _base __base
188# define _flag __flag
189# endif
190
191#elif defined _WIN32 && ! defined __CYGWIN__ /* newer Windows with MSVC */
192
193/* <stdio.h> does not define the innards of FILE any more. */
194# define WINDOWS_OPAQUE_FILE
195
196struct _gl_real_FILE
197{
198 /* Note: Compared to older Windows and to mingw, it has the fields
199 _base and _cnt swapped. */
200 unsigned char *_ptr;
201 unsigned char *_base;
202 int _cnt;
203 int _flag;
204 int _file;
205 int _charbuf;
206 int _bufsiz;
207};
208# define fp_ ((struct _gl_real_FILE *) fp)
209
210/* These values were determined by a program similar to the one at
211 <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */
212# define _IOREAD 0x1
213# define _IOWRT 0x2
214# define _IORW 0x4
215# define _IOEOF 0x8
216# define _IOERR 0x10
217
218#endif
diff --git a/gl/stdio-read.c b/gl/stdio-read.c
new file mode 100644
index 0000000..6e2984c
--- /dev/null
+++ b/gl/stdio-read.c
@@ -0,0 +1,168 @@
1/* POSIX compatible FILE stream read function.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <stdio.h>
22
23/* Replace these functions only if module 'nonblocking' is requested. */
24#if GNULIB_NONBLOCKING
25
26/* On native Windows platforms, when read() is called on a non-blocking pipe
27 with an empty buffer, ReadFile() fails with error GetLastError() =
28 ERROR_NO_DATA, and read() in consequence fails with error EINVAL. This
29 read() function is at the basis of the function which fills the buffer of
30 a FILE stream. */
31
32# if defined _WIN32 && ! defined __CYGWIN__
33
34# include <errno.h>
35# include <io.h>
36
37# define WIN32_LEAN_AND_MEAN /* avoid including junk */
38# include <windows.h>
39
40# if GNULIB_MSVC_NOTHROW
41# include "msvc-nothrow.h"
42# else
43# include <io.h>
44# endif
45
46/* Don't assume that UNICODE is not defined. */
47# undef GetNamedPipeHandleState
48# define GetNamedPipeHandleState GetNamedPipeHandleStateA
49
50# define CALL_WITH_ERRNO_FIX(RETTYPE, EXPRESSION, FAILED) \
51 if (ferror (stream)) \
52 return (EXPRESSION); \
53 else \
54 { \
55 RETTYPE ret; \
56 SetLastError (0); \
57 ret = (EXPRESSION); \
58 if (FAILED) \
59 { \
60 if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
61 { \
62 int fd = fileno (stream); \
63 if (fd >= 0) \
64 { \
65 HANDLE h = (HANDLE) _get_osfhandle (fd); \
66 if (GetFileType (h) == FILE_TYPE_PIPE) \
67 { \
68 /* h is a pipe or socket. */ \
69 DWORD state; \
70 if (GetNamedPipeHandleState (h, &state, NULL, NULL, \
71 NULL, NULL, 0) \
72 && (state & PIPE_NOWAIT) != 0) \
73 /* h is a pipe in non-blocking mode. \
74 Change errno from EINVAL to EAGAIN. */ \
75 errno = EAGAIN; \
76 } \
77 } \
78 } \
79 } \
80 return ret; \
81 }
82
83/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
84 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
85# if GNULIB_SCANF
86int
87scanf (const char *format, ...)
88{
89 int retval;
90 va_list args;
91
92 va_start (args, format);
93 retval = vfscanf (stdin, format, args);
94 va_end (args);
95
96 return retval;
97}
98# endif
99
100/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
101 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
102# if GNULIB_FSCANF
103int
104fscanf (FILE *stream, const char *format, ...)
105{
106 int retval;
107 va_list args;
108
109 va_start (args, format);
110 retval = vfscanf (stream, format, args);
111 va_end (args);
112
113 return retval;
114}
115# endif
116
117/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
118 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
119# if GNULIB_VSCANF
120int
121vscanf (const char *format, va_list args)
122{
123 return vfscanf (stdin, format, args);
124}
125# endif
126
127/* Enable this function definition only if gnulib's <stdio.h> has prepared it.
128 Otherwise we get a function definition conflict with mingw64's <stdio.h>. */
129# if GNULIB_VFSCANF
130int
131vfscanf (FILE *stream, const char *format, va_list args)
132#undef vfscanf
133{
134 CALL_WITH_ERRNO_FIX (int, vfscanf (stream, format, args), ret == EOF)
135}
136# endif
137
138int
139getchar (void)
140{
141 return fgetc (stdin);
142}
143
144int
145fgetc (FILE *stream)
146#undef fgetc
147{
148 CALL_WITH_ERRNO_FIX (int, fgetc (stream), ret == EOF)
149}
150
151char *
152fgets (char *s, int n, FILE *stream)
153#undef fgets
154{
155 CALL_WITH_ERRNO_FIX (char *, fgets (s, n, stream), ret == NULL)
156}
157
158/* We intentionally don't bother to fix gets. */
159
160size_t
161fread (void *ptr, size_t s, size_t n, FILE *stream)
162#undef fread
163{
164 CALL_WITH_ERRNO_FIX (size_t, fread (ptr, s, n, stream), ret < n)
165}
166
167# endif
168#endif
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
new file mode 100644
index 0000000..9cf36cc
--- /dev/null
+++ b/gl/stdio-write.c
@@ -0,0 +1,206 @@
1/* POSIX compatible FILE stream write function.
2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <stdio.h>
22
23/* Replace these functions only if module 'nonblocking' or module 'sigpipe' is
24 requested. */
25#if GNULIB_NONBLOCKING || GNULIB_SIGPIPE
26
27/* On native Windows platforms, SIGPIPE does not exist. When write() is
28 called on a pipe with no readers, WriteFile() fails with error
29 GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
30 error EINVAL. This write() function is at the basis of the function
31 which flushes the buffer of a FILE stream. */
32
33# if defined _WIN32 && ! defined __CYGWIN__
34
35# include <errno.h>
36# include <signal.h>
37# include <io.h>
38
39# define WIN32_LEAN_AND_MEAN /* avoid including junk */
40# include <windows.h>
41
42# if GNULIB_MSVC_NOTHROW
43# include "msvc-nothrow.h"
44# else
45# include <io.h>
46# endif
47
48/* Don't assume that UNICODE is not defined. */
49# undef GetNamedPipeHandleState
50# define GetNamedPipeHandleState GetNamedPipeHandleStateA
51
52# if GNULIB_NONBLOCKING
53# define CLEAR_ERRNO \
54 errno = 0;
55# define HANDLE_ENOSPC \
56 if (errno == ENOSPC && ferror (stream)) \
57 { \
58 int fd = fileno (stream); \
59 if (fd >= 0) \
60 { \
61 HANDLE h = (HANDLE) _get_osfhandle (fd); \
62 if (GetFileType (h) == FILE_TYPE_PIPE) \
63 { \
64 /* h is a pipe or socket. */ \
65 DWORD state; \
66 if (GetNamedPipeHandleState (h, &state, NULL, NULL, \
67 NULL, NULL, 0) \
68 && (state & PIPE_NOWAIT) != 0) \
69 /* h is a pipe in non-blocking mode. \
70 Change errno from ENOSPC to EAGAIN. */ \
71 errno = EAGAIN; \
72 } \
73 } \
74 } \
75 else
76# else
77# define CLEAR_ERRNO
78# define HANDLE_ENOSPC
79# endif
80
81# if GNULIB_SIGPIPE
82# define CLEAR_LastError \
83 SetLastError (0);
84# define HANDLE_ERROR_NO_DATA \
85 if (GetLastError () == ERROR_NO_DATA && ferror (stream)) \
86 { \
87 int fd = fileno (stream); \
88 if (fd >= 0 \
89 && GetFileType ((HANDLE) _get_osfhandle (fd)) \
90 == FILE_TYPE_PIPE) \
91 { \
92 /* Try to raise signal SIGPIPE. */ \
93 raise (SIGPIPE); \
94 /* If it is currently blocked or ignored, change errno from \
95 EINVAL to EPIPE. */ \
96 errno = EPIPE; \
97 } \
98 } \
99 else
100# else
101# define CLEAR_LastError
102# define HANDLE_ERROR_NO_DATA
103# endif
104
105# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
106 if (ferror (stream)) \
107 return (EXPRESSION); \
108 else \
109 { \
110 RETTYPE ret; \
111 CLEAR_ERRNO \
112 CLEAR_LastError \
113 ret = (EXPRESSION); \
114 if (FAILED) \
115 { \
116 HANDLE_ENOSPC \
117 HANDLE_ERROR_NO_DATA \
118 ; \
119 } \
120 return ret; \
121 }
122
123# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
124int
125printf (const char *format, ...)
126{
127 int retval;
128 va_list args;
129
130 va_start (args, format);
131 retval = vfprintf (stdout, format, args);
132 va_end (args);
133
134 return retval;
135}
136# endif
137
138# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
139int
140fprintf (FILE *stream, const char *format, ...)
141{
142 int retval;
143 va_list args;
144
145 va_start (args, format);
146 retval = vfprintf (stream, format, args);
147 va_end (args);
148
149 return retval;
150}
151# endif
152
153# if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */
154int
155vprintf (const char *format, va_list args)
156{
157 return vfprintf (stdout, format, args);
158}
159# endif
160
161# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */
162int
163vfprintf (FILE *stream, const char *format, va_list args)
164#undef vfprintf
165{
166 CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF)
167}
168# endif
169
170int
171putchar (int c)
172{
173 return fputc (c, stdout);
174}
175
176int
177fputc (int c, FILE *stream)
178#undef fputc
179{
180 CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF)
181}
182
183int
184fputs (const char *string, FILE *stream)
185#undef fputs
186{
187 CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF)
188}
189
190int
191puts (const char *string)
192#undef puts
193{
194 FILE *stream = stdout;
195 CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF)
196}
197
198size_t
199fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
200#undef fwrite
201{
202 CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n)
203}
204
205# endif
206#endif
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 06cbad0..59cbea3 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <stdio.h>. 1/* A GNU-like <stdio.h>.
2 2
3 Copyright (C) 2004, 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
@@ -56,36 +56,103 @@
56 May also define off_t to a 64-bit type on native Windows. */ 56 May also define off_t to a 64-bit type on native Windows. */
57#include <sys/types.h> 57#include <sys/types.h>
58 58
59/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */
60/* But in any case avoid namespace pollution on glibc systems. */
61#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
62 && ! defined __GLIBC__
63# include <unistd.h>
64#endif
65
66/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */
67/* But in any case avoid namespace pollution on glibc systems. */
68#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
69 && ! defined __GLIBC__
70# include <sys/stat.h>
71#endif
72
73/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include
74 it before we #define perror rpl_perror. */
75/* But in any case avoid namespace pollution on glibc systems. */
76#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
77 && (defined _WIN32 && ! defined __CYGWIN__) \
78 && ! defined __GLIBC__
79# include <stdlib.h>
80#endif
81
82/* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include
83 it before we #define remove rpl_remove. */
84/* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include
85 it before we #define rename rpl_rename. */
86/* But in any case avoid namespace pollution on glibc systems. */
87#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
88 && (defined _WIN32 && ! defined __CYGWIN__) \
89 && ! defined __GLIBC__
90# include <io.h>
91#endif
92
93
94/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
95 that can be freed by passing them as the Ith argument to the
96 function F. */
97#ifndef _GL_ATTRIBUTE_DEALLOC
98# if __GNUC__ >= 11
99# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
100# else
101# define _GL_ATTRIBUTE_DEALLOC(f, i)
102# endif
103#endif
104
59/* The __attribute__ feature is available in gcc versions 2.5 and later. 105/* The __attribute__ feature is available in gcc versions 2.5 and later.
60 The __-protected variants of the attributes 'format' and 'printf' are 106 The __-protected variants of the attributes 'format' and 'printf' are
61 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 107 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
62 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because 108 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
63 gnulib and libintl do '#define printf __printf__' when they override 109 gnulib and libintl do '#define printf __printf__' when they override
64 the 'printf' function. */ 110 the 'printf' function. */
65#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 111#ifndef _GL_ATTRIBUTE_FORMAT
66# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) 112# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
113# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
114# else
115# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
116# endif
117#endif
118
119/* An __attribute__ __format__ specifier for a function that takes a format
120 string and arguments, where the format string directives are the ones
121 standardized by ISO C99 and POSIX.
122 _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */
123/* __gnu_printf__ is supported in GCC >= 4.4. */
124#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
125# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
67#else 126#else
68# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ 127# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
69#endif 128#endif
70 129
71/* _GL_ATTRIBUTE_FORMAT_PRINTF 130/* An __attribute__ __format__ specifier for a function that takes a format
131 string and arguments, where the format string directives are the ones of the
132 system printf(), rather than the ones standardized by ISO C99 and POSIX.
133 _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM */
134/* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
135 the standards. The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
136 whether this change is effective. On older mingw, it is not. */
137#if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
138# define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
139#else
140# define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
141#endif
142
143/* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
72 indicates to GCC that the function takes a format string and arguments, 144 indicates to GCC that the function takes a format string and arguments,
73 where the format string directives are the ones standardized by ISO C99 145 where the format string directives are the ones standardized by ISO C99
74 and POSIX. */ 146 and POSIX. */
75#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 147#define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
76# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 148 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
77 _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
78#else
79# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
80 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
81#endif
82 149
83/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF, 150/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
84 except that it indicates to GCC that the supported format string directives 151 except that it indicates to GCC that the supported format string directives
85 are the ones of the system printf(), rather than the ones standardized by 152 are the ones of the system printf(), rather than the ones standardized by
86 ISO C99 and POSIX. */ 153 ISO C99 and POSIX. */
87#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ 154#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
88 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) 155 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
89 156
90/* _GL_ATTRIBUTE_FORMAT_SCANF 157/* _GL_ATTRIBUTE_FORMAT_SCANF
91 indicates to GCC that the function takes a format string and arguments, 158 indicates to GCC that the function takes a format string and arguments,
@@ -106,14 +173,6 @@
106#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ 173#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
107 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) 174 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
108 175
109/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
110/* But in any case avoid namespace pollution on glibc systems. */
111#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
112 && ! defined __GLIBC__
113# include <unistd.h>
114#endif
115
116
117/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 176/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
118 177
119/* The definition of _GL_ARG_NONNULL is copied here. */ 178/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -124,23 +183,32 @@
124#define _GL_STDIO_STRINGIZE(token) #token 183#define _GL_STDIO_STRINGIZE(token) #token
125#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) 184#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
126 185
186/* When also using extern inline, suppress the use of static inline in
187 standard headers of problematic Apple configurations, as Libc at
188 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
189 <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
190 Perhaps Apple will fix this some day. */
191#if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
192 && defined __GNUC__ && defined __STDC__)
193# undef putc_unlocked
194#endif
127 195
128#if @GNULIB_DPRINTF@ 196#if @GNULIB_DPRINTF@
129# if @REPLACE_DPRINTF@ 197# if @REPLACE_DPRINTF@
130# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 198# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
131# define dprintf rpl_dprintf 199# define dprintf rpl_dprintf
132# endif 200# endif
133_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) 201_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
134 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 202 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
135 _GL_ARG_NONNULL ((2))); 203 _GL_ARG_NONNULL ((2)));
136_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); 204_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
137# else 205# else
138# if !@HAVE_DPRINTF@ 206# if !@HAVE_DPRINTF@
139_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) 207_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
140 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 208 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
141 _GL_ARG_NONNULL ((2))); 209 _GL_ARG_NONNULL ((2)));
142# endif 210# endif
143_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); 211_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
144# endif 212# endif
145_GL_CXXALIASWARN (dprintf); 213_GL_CXXALIASWARN (dprintf);
146#elif defined GNULIB_POSIXCHECK 214#elif defined GNULIB_POSIXCHECK
@@ -162,7 +230,9 @@ _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
162# else 230# else
163_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); 231_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
164# endif 232# endif
233# if __GLIBC__ >= 2
165_GL_CXXALIASWARN (fclose); 234_GL_CXXALIASWARN (fclose);
235# endif
166#elif defined GNULIB_POSIXCHECK 236#elif defined GNULIB_POSIXCHECK
167# undef fclose 237# undef fclose
168/* Assume fclose is always declared. */ 238/* Assume fclose is always declared. */
@@ -170,24 +240,84 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
170 "use gnulib module fclose for portable POSIX compliance"); 240 "use gnulib module fclose for portable POSIX compliance");
171#endif 241#endif
172 242
243#if @GNULIB_MDA_FCLOSEALL@
244/* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
245 not required. In C++ with GNULIB_NAMESPACE, avoid differences between
246 platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
247 it. */
248# if defined _WIN32 && !defined __CYGWIN__
249# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
250# undef fcloseall
251# define fcloseall _fcloseall
252# endif
253_GL_CXXALIAS_MDA (fcloseall, int, (void));
254# else
255# if @HAVE_DECL_FCLOSEALL@
256# if defined __FreeBSD__ || defined __DragonFly__
257_GL_CXXALIAS_SYS (fcloseall, void, (void));
258# else
259_GL_CXXALIAS_SYS (fcloseall, int, (void));
260# endif
261# endif
262# endif
263# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@
264_GL_CXXALIASWARN (fcloseall);
265# endif
266#endif
267
173#if @GNULIB_FDOPEN@ 268#if @GNULIB_FDOPEN@
174# if @REPLACE_FDOPEN@ 269# if @REPLACE_FDOPEN@
175# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 270# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176# undef fdopen 271# undef fdopen
177# define fdopen rpl_fdopen 272# define fdopen rpl_fdopen
178# endif 273# endif
179_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) 274_GL_FUNCDECL_RPL (fdopen, FILE *,
180 _GL_ARG_NONNULL ((2))); 275 (int fd, const char *mode)
276 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
181_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 277_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
278# elif defined _WIN32 && !defined __CYGWIN__
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# undef fdopen
281# define fdopen _fdopen
282# endif
283_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
182# else 284# else
285# if __GNUC__ >= 11
286/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
287_GL_FUNCDECL_SYS (fdopen, FILE *,
288 (int fd, const char *mode)
289 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
290# endif
183_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 291_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
184# endif 292# endif
185_GL_CXXALIASWARN (fdopen); 293_GL_CXXALIASWARN (fdopen);
186#elif defined GNULIB_POSIXCHECK 294#else
187# undef fdopen 295# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
296/* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose. */
297_GL_FUNCDECL_SYS (fdopen, FILE *,
298 (int fd, const char *mode)
299 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
300# endif
301# if defined GNULIB_POSIXCHECK
302# undef fdopen
188/* Assume fdopen is always declared. */ 303/* Assume fdopen is always declared. */
189_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " 304_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
190 "use gnulib module fdopen for portability"); 305 "use gnulib module fdopen for portability");
306# elif @GNULIB_MDA_FDOPEN@
307/* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
308 required. In C++ with GNULIB_NAMESPACE, avoid differences between
309 platforms by defining GNULIB_NAMESPACE::fdopen always. */
310# if defined _WIN32 && !defined __CYGWIN__
311# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312# undef fdopen
313# define fdopen _fdopen
314# endif
315_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
316# else
317_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
318# endif
319_GL_CXXALIASWARN (fdopen);
320# endif
191#endif 321#endif
192 322
193#if @GNULIB_FFLUSH@ 323#if @GNULIB_FFLUSH@
@@ -206,7 +336,9 @@ _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
206# else 336# else
207_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); 337_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
208# endif 338# endif
339# if __GLIBC__ >= 2
209_GL_CXXALIASWARN (fflush); 340_GL_CXXALIASWARN (fflush);
341# endif
210#elif defined GNULIB_POSIXCHECK 342#elif defined GNULIB_POSIXCHECK
211# undef fflush 343# undef fflush
212/* Assume fflush is always declared. */ 344/* Assume fflush is always declared. */
@@ -225,7 +357,9 @@ _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
225# else 357# else
226_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); 358_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
227# endif 359# endif
360# if __GLIBC__ >= 2
228_GL_CXXALIASWARN (fgetc); 361_GL_CXXALIASWARN (fgetc);
362# endif
229#endif 363#endif
230 364
231#if @GNULIB_FGETS@ 365#if @GNULIB_FGETS@
@@ -234,33 +368,74 @@ _GL_CXXALIASWARN (fgetc);
234# undef fgets 368# undef fgets
235# define fgets rpl_fgets 369# define fgets rpl_fgets
236# endif 370# endif
237_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream) 371_GL_FUNCDECL_RPL (fgets, char *,
238 _GL_ARG_NONNULL ((1, 3))); 372 (char *restrict s, int n, FILE *restrict stream)
239_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream)); 373 _GL_ARG_NONNULL ((1, 3)));
374_GL_CXXALIAS_RPL (fgets, char *,
375 (char *restrict s, int n, FILE *restrict stream));
240# else 376# else
241_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream)); 377_GL_CXXALIAS_SYS (fgets, char *,
378 (char *restrict s, int n, FILE *restrict stream));
242# endif 379# endif
380# if __GLIBC__ >= 2
243_GL_CXXALIASWARN (fgets); 381_GL_CXXALIASWARN (fgets);
382# endif
383#endif
384
385#if @GNULIB_MDA_FILENO@
386/* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
387 required. In C++ with GNULIB_NAMESPACE, avoid differences between
388 platforms by defining GNULIB_NAMESPACE::fileno always. */
389# if defined _WIN32 && !defined __CYGWIN__
390# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
391# undef fileno
392# define fileno _fileno
393# endif
394_GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream));
395# else
396_GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream));
397# endif
398_GL_CXXALIASWARN (fileno);
244#endif 399#endif
245 400
246#if @GNULIB_FOPEN@ 401#if @GNULIB_FOPEN@
247# if @REPLACE_FOPEN@ 402# if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
403 || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
248# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 404# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
249# undef fopen 405# undef fopen
250# define fopen rpl_fopen 406# define fopen rpl_fopen
251# endif 407# endif
252_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) 408_GL_FUNCDECL_RPL (fopen, FILE *,
253 _GL_ARG_NONNULL ((1, 2))); 409 (const char *restrict filename, const char *restrict mode)
254_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); 410 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
411_GL_CXXALIAS_RPL (fopen, FILE *,
412 (const char *restrict filename, const char *restrict mode));
255# else 413# else
256_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); 414# if __GNUC__ >= 11
415/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
416_GL_FUNCDECL_SYS (fopen, FILE *,
417 (const char *restrict filename, const char *restrict mode)
418 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
419# endif
420_GL_CXXALIAS_SYS (fopen, FILE *,
421 (const char *restrict filename, const char *restrict mode));
257# endif 422# endif
423# if __GLIBC__ >= 2
258_GL_CXXALIASWARN (fopen); 424_GL_CXXALIASWARN (fopen);
259#elif defined GNULIB_POSIXCHECK 425# endif
260# undef fopen 426#else
427# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
428/* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose. */
429_GL_FUNCDECL_SYS (fopen, FILE *,
430 (const char *restrict filename, const char *restrict mode)
431 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
432# endif
433# if defined GNULIB_POSIXCHECK
434# undef fopen
261/* Assume fopen is always declared. */ 435/* Assume fopen is always declared. */
262_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " 436_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
263 "use gnulib module fopen for portability"); 437 "use gnulib module fopen for portability");
438# endif
264#endif 439#endif
265 440
266#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ 441#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
@@ -271,19 +446,25 @@ _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX complian
271# endif 446# endif
272# define GNULIB_overrides_fprintf 1 447# define GNULIB_overrides_fprintf 1
273# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 448# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
274_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 449_GL_FUNCDECL_RPL (fprintf, int,
275 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 450 (FILE *restrict fp, const char *restrict format, ...)
276 _GL_ARG_NONNULL ((1, 2))); 451 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
452 _GL_ARG_NONNULL ((1, 2)));
277# else 453# else
278_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 454_GL_FUNCDECL_RPL (fprintf, int,
279 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) 455 (FILE *restrict fp, const char *restrict format, ...)
280 _GL_ARG_NONNULL ((1, 2))); 456 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
457 _GL_ARG_NONNULL ((1, 2)));
281# endif 458# endif
282_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); 459_GL_CXXALIAS_RPL (fprintf, int,
460 (FILE *restrict fp, const char *restrict format, ...));
283# else 461# else
284_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); 462_GL_CXXALIAS_SYS (fprintf, int,
463 (FILE *restrict fp, const char *restrict format, ...));
285# endif 464# endif
465# if __GLIBC__ >= 2
286_GL_CXXALIASWARN (fprintf); 466_GL_CXXALIASWARN (fprintf);
467# endif
287#endif 468#endif
288#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 469#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
289# if !GNULIB_overrides_fprintf 470# if !GNULIB_overrides_fprintf
@@ -334,7 +515,9 @@ _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
334# else 515# else
335_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); 516_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
336# endif 517# endif
518# if __GLIBC__ >= 2
337_GL_CXXALIASWARN (fputc); 519_GL_CXXALIASWARN (fputc);
520# endif
338#endif 521#endif
339 522
340#if @GNULIB_FPUTS@ 523#if @GNULIB_FPUTS@
@@ -343,13 +526,18 @@ _GL_CXXALIASWARN (fputc);
343# undef fputs 526# undef fputs
344# define fputs rpl_fputs 527# define fputs rpl_fputs
345# endif 528# endif
346_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) 529_GL_FUNCDECL_RPL (fputs, int,
347 _GL_ARG_NONNULL ((1, 2))); 530 (const char *restrict string, FILE *restrict stream)
348_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); 531 _GL_ARG_NONNULL ((1, 2)));
532_GL_CXXALIAS_RPL (fputs, int,
533 (const char *restrict string, FILE *restrict stream));
349# else 534# else
350_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); 535_GL_CXXALIAS_SYS (fputs, int,
536 (const char *restrict string, FILE *restrict stream));
351# endif 537# endif
538# if __GLIBC__ >= 2
352_GL_CXXALIASWARN (fputs); 539_GL_CXXALIASWARN (fputs);
540# endif
353#endif 541#endif
354 542
355#if @GNULIB_FREAD@ 543#if @GNULIB_FREAD@
@@ -358,13 +546,21 @@ _GL_CXXALIASWARN (fputs);
358# undef fread 546# undef fread
359# define fread rpl_fread 547# define fread rpl_fread
360# endif 548# endif
361_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream) 549_GL_FUNCDECL_RPL (fread, size_t,
362 _GL_ARG_NONNULL ((4))); 550 (void *restrict ptr, size_t s, size_t n,
363_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); 551 FILE *restrict stream)
552 _GL_ARG_NONNULL ((4)));
553_GL_CXXALIAS_RPL (fread, size_t,
554 (void *restrict ptr, size_t s, size_t n,
555 FILE *restrict stream));
364# else 556# else
365_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); 557_GL_CXXALIAS_SYS (fread, size_t,
558 (void *restrict ptr, size_t s, size_t n,
559 FILE *restrict stream));
366# endif 560# endif
561# if __GLIBC__ >= 2
367_GL_CXXALIASWARN (fread); 562_GL_CXXALIASWARN (fread);
563# endif
368#endif 564#endif
369 565
370#if @GNULIB_FREOPEN@ 566#if @GNULIB_FREOPEN@
@@ -374,15 +570,20 @@ _GL_CXXALIASWARN (fread);
374# define freopen rpl_freopen 570# define freopen rpl_freopen
375# endif 571# endif
376_GL_FUNCDECL_RPL (freopen, FILE *, 572_GL_FUNCDECL_RPL (freopen, FILE *,
377 (const char *filename, const char *mode, FILE *stream) 573 (const char *restrict filename, const char *restrict mode,
574 FILE *restrict stream)
378 _GL_ARG_NONNULL ((2, 3))); 575 _GL_ARG_NONNULL ((2, 3)));
379_GL_CXXALIAS_RPL (freopen, FILE *, 576_GL_CXXALIAS_RPL (freopen, FILE *,
380 (const char *filename, const char *mode, FILE *stream)); 577 (const char *restrict filename, const char *restrict mode,
578 FILE *restrict stream));
381# else 579# else
382_GL_CXXALIAS_SYS (freopen, FILE *, 580_GL_CXXALIAS_SYS (freopen, FILE *,
383 (const char *filename, const char *mode, FILE *stream)); 581 (const char *restrict filename, const char *restrict mode,
582 FILE *restrict stream));
384# endif 583# endif
584# if __GLIBC__ >= 2
385_GL_CXXALIASWARN (freopen); 585_GL_CXXALIASWARN (freopen);
586# endif
386#elif defined GNULIB_POSIXCHECK 587#elif defined GNULIB_POSIXCHECK
387# undef freopen 588# undef freopen
388/* Assume freopen is always declared. */ 589/* Assume freopen is always declared. */
@@ -397,14 +598,19 @@ _GL_WARN_ON_USE (freopen,
397# undef fscanf 598# undef fscanf
398# define fscanf rpl_fscanf 599# define fscanf rpl_fscanf
399# endif 600# endif
400_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...) 601_GL_FUNCDECL_RPL (fscanf, int,
401 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) 602 (FILE *restrict stream, const char *restrict format, ...)
402 _GL_ARG_NONNULL ((1, 2))); 603 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
403_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...)); 604 _GL_ARG_NONNULL ((1, 2)));
605_GL_CXXALIAS_RPL (fscanf, int,
606 (FILE *restrict stream, const char *restrict format, ...));
404# else 607# else
405_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...)); 608_GL_CXXALIAS_SYS (fscanf, int,
609 (FILE *restrict stream, const char *restrict format, ...));
406# endif 610# endif
611# if __GLIBC__ >= 2
407_GL_CXXALIASWARN (fscanf); 612_GL_CXXALIASWARN (fscanf);
613# endif
408#endif 614#endif
409 615
410 616
@@ -455,7 +661,9 @@ _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
455# else 661# else
456_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); 662_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
457# endif 663# endif
664# if __GLIBC__ >= 2
458_GL_CXXALIASWARN (fseek); 665_GL_CXXALIASWARN (fseek);
666# endif
459#endif 667#endif
460 668
461#if @GNULIB_FSEEKO@ 669#if @GNULIB_FSEEKO@
@@ -518,7 +726,9 @@ _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
518# else 726# else
519_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); 727_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
520# endif 728# endif
729# if __GLIBC__ >= 2
521_GL_CXXALIASWARN (ftell); 730_GL_CXXALIASWARN (ftell);
731# endif
522#endif 732#endif
523 733
524#if @GNULIB_FTELLO@ 734#if @GNULIB_FTELLO@
@@ -567,16 +777,19 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
567# define fwrite rpl_fwrite 777# define fwrite rpl_fwrite
568# endif 778# endif
569_GL_FUNCDECL_RPL (fwrite, size_t, 779_GL_FUNCDECL_RPL (fwrite, size_t,
570 (const void *ptr, size_t s, size_t n, FILE *stream) 780 (const void *restrict ptr, size_t s, size_t n,
781 FILE *restrict stream)
571 _GL_ARG_NONNULL ((1, 4))); 782 _GL_ARG_NONNULL ((1, 4)));
572_GL_CXXALIAS_RPL (fwrite, size_t, 783_GL_CXXALIAS_RPL (fwrite, size_t,
573 (const void *ptr, size_t s, size_t n, FILE *stream)); 784 (const void *restrict ptr, size_t s, size_t n,
785 FILE *restrict stream));
574# else 786# else
575_GL_CXXALIAS_SYS (fwrite, size_t, 787_GL_CXXALIAS_SYS (fwrite, size_t,
576 (const void *ptr, size_t s, size_t n, FILE *stream)); 788 (const void *restrict ptr, size_t s, size_t n,
789 FILE *restrict stream));
577 790
578/* Work around bug 11959 when fortifying glibc 2.4 through 2.15 791/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
579 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>, 792 <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
580 which sometimes causes an unwanted diagnostic for fwrite calls. 793 which sometimes causes an unwanted diagnostic for fwrite calls.
581 This affects only function declaration attributes under certain 794 This affects only function declaration attributes under certain
582 versions of gcc and clang, and is not needed for C++. */ 795 versions of gcc and clang, and is not needed for C++. */
@@ -598,7 +811,9 @@ extern size_t __REDIRECT (rpl_fwrite_unlocked,
598# define fwrite_unlocked rpl_fwrite_unlocked 811# define fwrite_unlocked rpl_fwrite_unlocked
599# endif 812# endif
600# endif 813# endif
814# if __GLIBC__ >= 2
601_GL_CXXALIASWARN (fwrite); 815_GL_CXXALIASWARN (fwrite);
816# endif
602#endif 817#endif
603 818
604#if @GNULIB_GETC@ 819#if @GNULIB_GETC@
@@ -612,7 +827,9 @@ _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
612# else 827# else
613_GL_CXXALIAS_SYS (getc, int, (FILE *stream)); 828_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
614# endif 829# endif
830# if __GLIBC__ >= 2
615_GL_CXXALIASWARN (getc); 831_GL_CXXALIASWARN (getc);
832# endif
616#endif 833#endif
617 834
618#if @GNULIB_GETCHAR@ 835#if @GNULIB_GETCHAR@
@@ -626,7 +843,9 @@ _GL_CXXALIAS_RPL (getchar, int, (void));
626# else 843# else
627_GL_CXXALIAS_SYS (getchar, int, (void)); 844_GL_CXXALIAS_SYS (getchar, int, (void));
628# endif 845# endif
846# if __GLIBC__ >= 2
629_GL_CXXALIASWARN (getchar); 847_GL_CXXALIASWARN (getchar);
848# endif
630#endif 849#endif
631 850
632#if @GNULIB_GETDELIM@ 851#if @GNULIB_GETDELIM@
@@ -642,22 +861,26 @@ _GL_CXXALIASWARN (getchar);
642# define getdelim rpl_getdelim 861# define getdelim rpl_getdelim
643# endif 862# endif
644_GL_FUNCDECL_RPL (getdelim, ssize_t, 863_GL_FUNCDECL_RPL (getdelim, ssize_t,
645 (char **lineptr, size_t *linesize, int delimiter, 864 (char **restrict lineptr, size_t *restrict linesize,
646 FILE *stream) 865 int delimiter,
866 FILE *restrict stream)
647 _GL_ARG_NONNULL ((1, 2, 4))); 867 _GL_ARG_NONNULL ((1, 2, 4)));
648_GL_CXXALIAS_RPL (getdelim, ssize_t, 868_GL_CXXALIAS_RPL (getdelim, ssize_t,
649 (char **lineptr, size_t *linesize, int delimiter, 869 (char **restrict lineptr, size_t *restrict linesize,
650 FILE *stream)); 870 int delimiter,
871 FILE *restrict stream));
651# else 872# else
652# if !@HAVE_DECL_GETDELIM@ 873# if !@HAVE_DECL_GETDELIM@
653_GL_FUNCDECL_SYS (getdelim, ssize_t, 874_GL_FUNCDECL_SYS (getdelim, ssize_t,
654 (char **lineptr, size_t *linesize, int delimiter, 875 (char **restrict lineptr, size_t *restrict linesize,
655 FILE *stream) 876 int delimiter,
877 FILE *restrict stream)
656 _GL_ARG_NONNULL ((1, 2, 4))); 878 _GL_ARG_NONNULL ((1, 2, 4)));
657# endif 879# endif
658_GL_CXXALIAS_SYS (getdelim, ssize_t, 880_GL_CXXALIAS_SYS (getdelim, ssize_t,
659 (char **lineptr, size_t *linesize, int delimiter, 881 (char **restrict lineptr, size_t *restrict linesize,
660 FILE *stream)); 882 int delimiter,
883 FILE *restrict stream));
661# endif 884# endif
662_GL_CXXALIASWARN (getdelim); 885_GL_CXXALIASWARN (getdelim);
663#elif defined GNULIB_POSIXCHECK 886#elif defined GNULIB_POSIXCHECK
@@ -681,18 +904,22 @@ _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
681# define getline rpl_getline 904# define getline rpl_getline
682# endif 905# endif
683_GL_FUNCDECL_RPL (getline, ssize_t, 906_GL_FUNCDECL_RPL (getline, ssize_t,
684 (char **lineptr, size_t *linesize, FILE *stream) 907 (char **restrict lineptr, size_t *restrict linesize,
908 FILE *restrict stream)
685 _GL_ARG_NONNULL ((1, 2, 3))); 909 _GL_ARG_NONNULL ((1, 2, 3)));
686_GL_CXXALIAS_RPL (getline, ssize_t, 910_GL_CXXALIAS_RPL (getline, ssize_t,
687 (char **lineptr, size_t *linesize, FILE *stream)); 911 (char **restrict lineptr, size_t *restrict linesize,
912 FILE *restrict stream));
688# else 913# else
689# if !@HAVE_DECL_GETLINE@ 914# if !@HAVE_DECL_GETLINE@
690_GL_FUNCDECL_SYS (getline, ssize_t, 915_GL_FUNCDECL_SYS (getline, ssize_t,
691 (char **lineptr, size_t *linesize, FILE *stream) 916 (char **restrict lineptr, size_t *restrict linesize,
917 FILE *restrict stream)
692 _GL_ARG_NONNULL ((1, 2, 3))); 918 _GL_ARG_NONNULL ((1, 2, 3)));
693# endif 919# endif
694_GL_CXXALIAS_SYS (getline, ssize_t, 920_GL_CXXALIAS_SYS (getline, ssize_t,
695 (char **lineptr, size_t *linesize, FILE *stream)); 921 (char **restrict lineptr, size_t *restrict linesize,
922 FILE *restrict stream));
696# endif 923# endif
697# if @HAVE_DECL_GETLINE@ 924# if @HAVE_DECL_GETLINE@
698_GL_CXXALIASWARN (getline); 925_GL_CXXALIASWARN (getline);
@@ -709,10 +936,25 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
709 so any use of gets warrants an unconditional warning; besides, C11 936 so any use of gets warrants an unconditional warning; besides, C11
710 removed it. */ 937 removed it. */
711#undef gets 938#undef gets
712#if HAVE_RAW_DECL_GETS 939#if HAVE_RAW_DECL_GETS && !defined __cplusplus
713_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 940_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
714#endif 941#endif
715 942
943#if @GNULIB_MDA_GETW@
944/* On native Windows, map 'getw' to '_getw', so that -loldnames is not
945 required. In C++ with GNULIB_NAMESPACE, avoid differences between
946 platforms by defining GNULIB_NAMESPACE::getw always. */
947# if defined _WIN32 && !defined __CYGWIN__
948# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949# undef getw
950# define getw _getw
951# endif
952_GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
953# else
954_GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
955# endif
956_GL_CXXALIASWARN (getw);
957#endif
716 958
717#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 959#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
718struct obstack; 960struct obstack;
@@ -727,7 +969,7 @@ struct obstack;
727# endif 969# endif
728_GL_FUNCDECL_RPL (obstack_printf, int, 970_GL_FUNCDECL_RPL (obstack_printf, int,
729 (struct obstack *obs, const char *format, ...) 971 (struct obstack *obs, const char *format, ...)
730 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 972 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
731 _GL_ARG_NONNULL ((1, 2))); 973 _GL_ARG_NONNULL ((1, 2)));
732_GL_CXXALIAS_RPL (obstack_printf, int, 974_GL_CXXALIAS_RPL (obstack_printf, int,
733 (struct obstack *obs, const char *format, ...)); 975 (struct obstack *obs, const char *format, ...));
@@ -735,7 +977,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
735# if !@HAVE_DECL_OBSTACK_PRINTF@ 977# if !@HAVE_DECL_OBSTACK_PRINTF@
736_GL_FUNCDECL_SYS (obstack_printf, int, 978_GL_FUNCDECL_SYS (obstack_printf, int,
737 (struct obstack *obs, const char *format, ...) 979 (struct obstack *obs, const char *format, ...)
738 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 980 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
739 _GL_ARG_NONNULL ((1, 2))); 981 _GL_ARG_NONNULL ((1, 2)));
740# endif 982# endif
741_GL_CXXALIAS_SYS (obstack_printf, int, 983_GL_CXXALIAS_SYS (obstack_printf, int,
@@ -748,7 +990,7 @@ _GL_CXXALIASWARN (obstack_printf);
748# endif 990# endif
749_GL_FUNCDECL_RPL (obstack_vprintf, int, 991_GL_FUNCDECL_RPL (obstack_vprintf, int,
750 (struct obstack *obs, const char *format, va_list args) 992 (struct obstack *obs, const char *format, va_list args)
751 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 993 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
752 _GL_ARG_NONNULL ((1, 2))); 994 _GL_ARG_NONNULL ((1, 2)));
753_GL_CXXALIAS_RPL (obstack_vprintf, int, 995_GL_CXXALIAS_RPL (obstack_vprintf, int,
754 (struct obstack *obs, const char *format, va_list args)); 996 (struct obstack *obs, const char *format, va_list args));
@@ -756,7 +998,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
756# if !@HAVE_DECL_OBSTACK_PRINTF@ 998# if !@HAVE_DECL_OBSTACK_PRINTF@
757_GL_FUNCDECL_SYS (obstack_vprintf, int, 999_GL_FUNCDECL_SYS (obstack_vprintf, int,
758 (struct obstack *obs, const char *format, va_list args) 1000 (struct obstack *obs, const char *format, va_list args)
759 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1001 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
760 _GL_ARG_NONNULL ((1, 2))); 1002 _GL_ARG_NONNULL ((1, 2)));
761# endif 1003# endif
762_GL_CXXALIAS_SYS (obstack_vprintf, int, 1004_GL_CXXALIAS_SYS (obstack_vprintf, int,
@@ -792,7 +1034,9 @@ _GL_CXXALIAS_RPL (perror, void, (const char *string));
792# else 1034# else
793_GL_CXXALIAS_SYS (perror, void, (const char *string)); 1035_GL_CXXALIAS_SYS (perror, void, (const char *string));
794# endif 1036# endif
1037# if __GLIBC__ >= 2
795_GL_CXXALIASWARN (perror); 1038_GL_CXXALIASWARN (perror);
1039# endif
796#elif defined GNULIB_POSIXCHECK 1040#elif defined GNULIB_POSIXCHECK
797# undef perror 1041# undef perror
798/* Assume perror is always declared. */ 1042/* Assume perror is always declared. */
@@ -806,43 +1050,53 @@ _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
806# undef popen 1050# undef popen
807# define popen rpl_popen 1051# define popen rpl_popen
808# endif 1052# endif
809_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) 1053_GL_FUNCDECL_RPL (popen, FILE *,
810 _GL_ARG_NONNULL ((1, 2))); 1054 (const char *cmd, const char *mode)
1055 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
811_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 1056_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
812# else 1057# else
813# if !@HAVE_POPEN@ 1058# if !@HAVE_POPEN@ || __GNUC__ >= 11
814_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) 1059_GL_FUNCDECL_SYS (popen, FILE *,
815 _GL_ARG_NONNULL ((1, 2))); 1060 (const char *cmd, const char *mode)
1061 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
816# endif 1062# endif
817_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 1063_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
818# endif 1064# endif
819_GL_CXXALIASWARN (popen); 1065_GL_CXXALIASWARN (popen);
820#elif defined GNULIB_POSIXCHECK 1066#else
821# undef popen 1067# if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
822# if HAVE_RAW_DECL_POPEN 1068/* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose. */
1069_GL_FUNCDECL_SYS (popen, FILE *,
1070 (const char *cmd, const char *mode)
1071 _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1));
1072# endif
1073# if defined GNULIB_POSIXCHECK
1074# undef popen
1075# if HAVE_RAW_DECL_POPEN
823_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " 1076_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
824 "use gnulib module popen or pipe for more portability"); 1077 "use gnulib module popen or pipe for more portability");
1078# endif
825# endif 1079# endif
826#endif 1080#endif
827 1081
828#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 1082#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
829# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 1083# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
830 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) 1084 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
831# if defined __GNUC__ 1085# if defined __GNUC__ || defined __clang__
832# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1086# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
833/* Don't break __attribute__((format(printf,M,N))). */ 1087/* Don't break __attribute__((format(printf,M,N))). */
834# define printf __printf__ 1088# define printf __printf__
835# endif 1089# endif
836# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 1090# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
837_GL_FUNCDECL_RPL_1 (__printf__, int, 1091_GL_FUNCDECL_RPL_1 (__printf__, int,
838 (const char *format, ...) 1092 (const char *restrict format, ...)
839 __asm__ (@ASM_SYMBOL_PREFIX@ 1093 __asm__ (@ASM_SYMBOL_PREFIX@
840 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1094 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
841 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) 1095 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
842 _GL_ARG_NONNULL ((1))); 1096 _GL_ARG_NONNULL ((1)));
843# else 1097# else
844_GL_FUNCDECL_RPL_1 (__printf__, int, 1098_GL_FUNCDECL_RPL_1 (__printf__, int,
845 (const char *format, ...) 1099 (const char *restrict format, ...)
846 __asm__ (@ASM_SYMBOL_PREFIX@ 1100 __asm__ (@ASM_SYMBOL_PREFIX@
847 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 1101 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
848 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) 1102 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
@@ -854,16 +1108,18 @@ _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
854# define printf rpl_printf 1108# define printf rpl_printf
855# endif 1109# endif
856_GL_FUNCDECL_RPL (printf, int, 1110_GL_FUNCDECL_RPL (printf, int,
857 (const char *format, ...) 1111 (const char *restrict format, ...)
858 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) 1112 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
859 _GL_ARG_NONNULL ((1))); 1113 _GL_ARG_NONNULL ((1)));
860_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); 1114_GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
861# endif 1115# endif
862# define GNULIB_overrides_printf 1 1116# define GNULIB_overrides_printf 1
863# else 1117# else
864_GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); 1118_GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
865# endif 1119# endif
1120# if __GLIBC__ >= 2
866_GL_CXXALIASWARN (printf); 1121_GL_CXXALIASWARN (printf);
1122# endif
867#endif 1123#endif
868#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1124#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
869# if !GNULIB_overrides_printf 1125# if !GNULIB_overrides_printf
@@ -886,7 +1142,9 @@ _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
886# else 1142# else
887_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); 1143_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
888# endif 1144# endif
1145# if __GLIBC__ >= 2
889_GL_CXXALIASWARN (putc); 1146_GL_CXXALIASWARN (putc);
1147# endif
890#endif 1148#endif
891 1149
892#if @GNULIB_PUTCHAR@ 1150#if @GNULIB_PUTCHAR@
@@ -900,7 +1158,9 @@ _GL_CXXALIAS_RPL (putchar, int, (int c));
900# else 1158# else
901_GL_CXXALIAS_SYS (putchar, int, (int c)); 1159_GL_CXXALIAS_SYS (putchar, int, (int c));
902# endif 1160# endif
1161# if __GLIBC__ >= 2
903_GL_CXXALIASWARN (putchar); 1162_GL_CXXALIASWARN (putchar);
1163# endif
904#endif 1164#endif
905 1165
906#if @GNULIB_PUTS@ 1166#if @GNULIB_PUTS@
@@ -914,7 +1174,25 @@ _GL_CXXALIAS_RPL (puts, int, (const char *string));
914# else 1174# else
915_GL_CXXALIAS_SYS (puts, int, (const char *string)); 1175_GL_CXXALIAS_SYS (puts, int, (const char *string));
916# endif 1176# endif
1177# if __GLIBC__ >= 2
917_GL_CXXALIASWARN (puts); 1178_GL_CXXALIASWARN (puts);
1179# endif
1180#endif
1181
1182#if @GNULIB_MDA_PUTW@
1183/* On native Windows, map 'putw' to '_putw', so that -loldnames is not
1184 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1185 platforms by defining GNULIB_NAMESPACE::putw always. */
1186# if defined _WIN32 && !defined __CYGWIN__
1187# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1188# undef putw
1189# define putw _putw
1190# endif
1191_GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
1192# else
1193_GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
1194# endif
1195_GL_CXXALIASWARN (putw);
918#endif 1196#endif
919 1197
920#if @GNULIB_REMOVE@ 1198#if @GNULIB_REMOVE@
@@ -928,7 +1206,9 @@ _GL_CXXALIAS_RPL (remove, int, (const char *name));
928# else 1206# else
929_GL_CXXALIAS_SYS (remove, int, (const char *name)); 1207_GL_CXXALIAS_SYS (remove, int, (const char *name));
930# endif 1208# endif
1209# if __GLIBC__ >= 2
931_GL_CXXALIASWARN (remove); 1210_GL_CXXALIASWARN (remove);
1211# endif
932#elif defined GNULIB_POSIXCHECK 1212#elif defined GNULIB_POSIXCHECK
933# undef remove 1213# undef remove
934/* Assume remove is always declared. */ 1214/* Assume remove is always declared. */
@@ -951,7 +1231,9 @@ _GL_CXXALIAS_RPL (rename, int,
951_GL_CXXALIAS_SYS (rename, int, 1231_GL_CXXALIAS_SYS (rename, int,
952 (const char *old_filename, const char *new_filename)); 1232 (const char *old_filename, const char *new_filename));
953# endif 1233# endif
1234# if __GLIBC__ >= 2
954_GL_CXXALIASWARN (rename); 1235_GL_CXXALIASWARN (rename);
1236# endif
955#elif defined GNULIB_POSIXCHECK 1237#elif defined GNULIB_POSIXCHECK
956# undef rename 1238# undef rename
957/* Assume rename is always declared. */ 1239/* Assume rename is always declared. */
@@ -990,33 +1272,35 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
990 1272
991#if @GNULIB_SCANF@ 1273#if @GNULIB_SCANF@
992# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ 1274# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
993# if defined __GNUC__ 1275# if defined __GNUC__ || defined __clang__
994# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1276# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
995# undef scanf 1277# undef scanf
996/* Don't break __attribute__((format(scanf,M,N))). */ 1278/* Don't break __attribute__((format(scanf,M,N))). */
997# define scanf __scanf__ 1279# define scanf __scanf__
998# endif 1280# endif
999_GL_FUNCDECL_RPL_1 (__scanf__, int, 1281_GL_FUNCDECL_RPL_1 (__scanf__, int,
1000 (const char *format, ...) 1282 (const char *restrict format, ...)
1001 __asm__ (@ASM_SYMBOL_PREFIX@ 1283 __asm__ (@ASM_SYMBOL_PREFIX@
1002 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) 1284 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
1003 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1285 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1004 _GL_ARG_NONNULL ((1))); 1286 _GL_ARG_NONNULL ((1)));
1005_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...)); 1287_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
1006# else 1288# else
1007# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1289# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1008# undef scanf 1290# undef scanf
1009# define scanf rpl_scanf 1291# define scanf rpl_scanf
1010# endif 1292# endif
1011_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...) 1293_GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
1012 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 1294 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1013 _GL_ARG_NONNULL ((1))); 1295 _GL_ARG_NONNULL ((1)));
1014_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...)); 1296_GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
1015# endif 1297# endif
1016# else 1298# else
1017_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...)); 1299_GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
1018# endif 1300# endif
1301# if __GLIBC__ >= 2
1019_GL_CXXALIASWARN (scanf); 1302_GL_CXXALIASWARN (scanf);
1303# endif
1020#endif 1304#endif
1021 1305
1022#if @GNULIB_SNPRINTF@ 1306#if @GNULIB_SNPRINTF@
@@ -1024,23 +1308,30 @@ _GL_CXXALIASWARN (scanf);
1024# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1308# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1025# define snprintf rpl_snprintf 1309# define snprintf rpl_snprintf
1026# endif 1310# endif
1311# define GNULIB_overrides_snprintf 1
1027_GL_FUNCDECL_RPL (snprintf, int, 1312_GL_FUNCDECL_RPL (snprintf, int,
1028 (char *str, size_t size, const char *format, ...) 1313 (char *restrict str, size_t size,
1029 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) 1314 const char *restrict format, ...)
1315 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1030 _GL_ARG_NONNULL ((3))); 1316 _GL_ARG_NONNULL ((3)));
1031_GL_CXXALIAS_RPL (snprintf, int, 1317_GL_CXXALIAS_RPL (snprintf, int,
1032 (char *str, size_t size, const char *format, ...)); 1318 (char *restrict str, size_t size,
1319 const char *restrict format, ...));
1033# else 1320# else
1034# if !@HAVE_DECL_SNPRINTF@ 1321# if !@HAVE_DECL_SNPRINTF@
1035_GL_FUNCDECL_SYS (snprintf, int, 1322_GL_FUNCDECL_SYS (snprintf, int,
1036 (char *str, size_t size, const char *format, ...) 1323 (char *restrict str, size_t size,
1037 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) 1324 const char *restrict format, ...)
1325 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
1038 _GL_ARG_NONNULL ((3))); 1326 _GL_ARG_NONNULL ((3)));
1039# endif 1327# endif
1040_GL_CXXALIAS_SYS (snprintf, int, 1328_GL_CXXALIAS_SYS (snprintf, int,
1041 (char *str, size_t size, const char *format, ...)); 1329 (char *restrict str, size_t size,
1330 const char *restrict format, ...));
1042# endif 1331# endif
1332# if __GLIBC__ >= 2
1043_GL_CXXALIASWARN (snprintf); 1333_GL_CXXALIASWARN (snprintf);
1334# endif
1044#elif defined GNULIB_POSIXCHECK 1335#elif defined GNULIB_POSIXCHECK
1045# undef snprintf 1336# undef snprintf
1046# if HAVE_RAW_DECL_SNPRINTF 1337# if HAVE_RAW_DECL_SNPRINTF
@@ -1063,14 +1354,20 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
1063# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1354# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1064# define sprintf rpl_sprintf 1355# define sprintf rpl_sprintf
1065# endif 1356# endif
1066_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) 1357# define GNULIB_overrides_sprintf 1
1067 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 1358_GL_FUNCDECL_RPL (sprintf, int,
1068 _GL_ARG_NONNULL ((1, 2))); 1359 (char *restrict str, const char *restrict format, ...)
1069_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); 1360 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1361 _GL_ARG_NONNULL ((1, 2)));
1362_GL_CXXALIAS_RPL (sprintf, int,
1363 (char *restrict str, const char *restrict format, ...));
1070# else 1364# else
1071_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); 1365_GL_CXXALIAS_SYS (sprintf, int,
1366 (char *restrict str, const char *restrict format, ...));
1072# endif 1367# endif
1368# if __GLIBC__ >= 2
1073_GL_CXXALIASWARN (sprintf); 1369_GL_CXXALIASWARN (sprintf);
1370# endif
1074#elif defined GNULIB_POSIXCHECK 1371#elif defined GNULIB_POSIXCHECK
1075# undef sprintf 1372# undef sprintf
1076/* Assume sprintf is always declared. */ 1373/* Assume sprintf is always declared. */
@@ -1079,22 +1376,53 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
1079 "POSIX compliance"); 1376 "POSIX compliance");
1080#endif 1377#endif
1081 1378
1379#if @GNULIB_MDA_TEMPNAM@
1380/* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
1381 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1382 platforms by defining GNULIB_NAMESPACE::tempnam always. */
1383# if defined _WIN32 && !defined __CYGWIN__
1384# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1385# undef tempnam
1386# define tempnam _tempnam
1387# endif
1388_GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix));
1389# else
1390_GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix));
1391# endif
1392_GL_CXXALIASWARN (tempnam);
1393#endif
1394
1082#if @GNULIB_TMPFILE@ 1395#if @GNULIB_TMPFILE@
1083# if @REPLACE_TMPFILE@ 1396# if @REPLACE_TMPFILE@
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1397# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085# define tmpfile rpl_tmpfile 1398# define tmpfile rpl_tmpfile
1086# endif 1399# endif
1087_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); 1400_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
1401 _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1088_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); 1402_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
1089# else 1403# else
1404# if __GNUC__ >= 11
1405/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1406_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1407 _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1408# endif
1090_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); 1409_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
1091# endif 1410# endif
1411# if __GLIBC__ >= 2
1092_GL_CXXALIASWARN (tmpfile); 1412_GL_CXXALIASWARN (tmpfile);
1093#elif defined GNULIB_POSIXCHECK 1413# endif
1094# undef tmpfile 1414#else
1095# if HAVE_RAW_DECL_TMPFILE 1415# if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
1416/* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose. */
1417_GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
1418 _GL_ATTRIBUTE_DEALLOC (fclose, 1));
1419# endif
1420# if defined GNULIB_POSIXCHECK
1421# undef tmpfile
1422# if HAVE_RAW_DECL_TMPFILE
1096_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " 1423_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1097 "use gnulib module tmpfile for portability"); 1424 "use gnulib module tmpfile for portability");
1425# endif
1098# endif 1426# endif
1099#endif 1427#endif
1100 1428
@@ -1107,9 +1435,10 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
1107# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1435# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1108# define asprintf rpl_asprintf 1436# define asprintf rpl_asprintf
1109# endif 1437# endif
1438# define GNULIB_overrides_asprintf
1110_GL_FUNCDECL_RPL (asprintf, int, 1439_GL_FUNCDECL_RPL (asprintf, int,
1111 (char **result, const char *format, ...) 1440 (char **result, const char *format, ...)
1112 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 1441 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1113 _GL_ARG_NONNULL ((1, 2))); 1442 _GL_ARG_NONNULL ((1, 2)));
1114_GL_CXXALIAS_RPL (asprintf, int, 1443_GL_CXXALIAS_RPL (asprintf, int,
1115 (char **result, const char *format, ...)); 1444 (char **result, const char *format, ...));
@@ -1117,7 +1446,7 @@ _GL_CXXALIAS_RPL (asprintf, int,
1117# if !@HAVE_VASPRINTF@ 1446# if !@HAVE_VASPRINTF@
1118_GL_FUNCDECL_SYS (asprintf, int, 1447_GL_FUNCDECL_SYS (asprintf, int,
1119 (char **result, const char *format, ...) 1448 (char **result, const char *format, ...)
1120 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 1449 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
1121 _GL_ARG_NONNULL ((1, 2))); 1450 _GL_ARG_NONNULL ((1, 2)));
1122# endif 1451# endif
1123_GL_CXXALIAS_SYS (asprintf, int, 1452_GL_CXXALIAS_SYS (asprintf, int,
@@ -1128,9 +1457,10 @@ _GL_CXXALIASWARN (asprintf);
1128# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1457# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1129# define vasprintf rpl_vasprintf 1458# define vasprintf rpl_vasprintf
1130# endif 1459# endif
1460# define GNULIB_overrides_vasprintf 1
1131_GL_FUNCDECL_RPL (vasprintf, int, 1461_GL_FUNCDECL_RPL (vasprintf, int,
1132 (char **result, const char *format, va_list args) 1462 (char **result, const char *format, va_list args)
1133 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1463 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1134 _GL_ARG_NONNULL ((1, 2))); 1464 _GL_ARG_NONNULL ((1, 2)));
1135_GL_CXXALIAS_RPL (vasprintf, int, 1465_GL_CXXALIAS_RPL (vasprintf, int,
1136 (char **result, const char *format, va_list args)); 1466 (char **result, const char *format, va_list args));
@@ -1138,7 +1468,7 @@ _GL_CXXALIAS_RPL (vasprintf, int,
1138# if !@HAVE_VASPRINTF@ 1468# if !@HAVE_VASPRINTF@
1139_GL_FUNCDECL_SYS (vasprintf, int, 1469_GL_FUNCDECL_SYS (vasprintf, int,
1140 (char **result, const char *format, va_list args) 1470 (char **result, const char *format, va_list args)
1141 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1471 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1142 _GL_ARG_NONNULL ((1, 2))); 1472 _GL_ARG_NONNULL ((1, 2)));
1143# endif 1473# endif
1144_GL_CXXALIAS_SYS (vasprintf, int, 1474_GL_CXXALIAS_SYS (vasprintf, int,
@@ -1152,22 +1482,27 @@ _GL_CXXALIASWARN (vasprintf);
1152# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1482# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1153# define vdprintf rpl_vdprintf 1483# define vdprintf rpl_vdprintf
1154# endif 1484# endif
1155_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) 1485_GL_FUNCDECL_RPL (vdprintf, int,
1156 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1486 (int fd, const char *restrict format, va_list args)
1157 _GL_ARG_NONNULL ((2))); 1487 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1158_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); 1488 _GL_ARG_NONNULL ((2)));
1489_GL_CXXALIAS_RPL (vdprintf, int,
1490 (int fd, const char *restrict format, va_list args));
1159# else 1491# else
1160# if !@HAVE_VDPRINTF@ 1492# if !@HAVE_VDPRINTF@
1161_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) 1493_GL_FUNCDECL_SYS (vdprintf, int,
1162 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1494 (int fd, const char *restrict format, va_list args)
1163 _GL_ARG_NONNULL ((2))); 1495 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1496 _GL_ARG_NONNULL ((2)));
1164# endif 1497# endif
1165/* Need to cast, because on Solaris, the third parameter will likely be 1498/* Need to cast, because on Solaris, the third parameter will likely be
1166 __va_list args. */ 1499 __va_list args. */
1167_GL_CXXALIAS_SYS_CAST (vdprintf, int, 1500_GL_CXXALIAS_SYS_CAST (vdprintf, int,
1168 (int fd, const char *format, va_list args)); 1501 (int fd, const char *restrict format, va_list args));
1169# endif 1502# endif
1503# if __GLIBC__ >= 2
1170_GL_CXXALIASWARN (vdprintf); 1504_GL_CXXALIASWARN (vdprintf);
1505# endif
1171#elif defined GNULIB_POSIXCHECK 1506#elif defined GNULIB_POSIXCHECK
1172# undef vdprintf 1507# undef vdprintf
1173# if HAVE_RAW_DECL_VDPRINTF 1508# if HAVE_RAW_DECL_VDPRINTF
@@ -1184,23 +1519,32 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1184# endif 1519# endif
1185# define GNULIB_overrides_vfprintf 1 1520# define GNULIB_overrides_vfprintf 1
1186# if @GNULIB_VFPRINTF_POSIX@ 1521# if @GNULIB_VFPRINTF_POSIX@
1187_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 1522_GL_FUNCDECL_RPL (vfprintf, int,
1188 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1523 (FILE *restrict fp,
1189 _GL_ARG_NONNULL ((1, 2))); 1524 const char *restrict format, va_list args)
1525 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1526 _GL_ARG_NONNULL ((1, 2)));
1190# else 1527# else
1191_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 1528_GL_FUNCDECL_RPL (vfprintf, int,
1192 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) 1529 (FILE *restrict fp,
1193 _GL_ARG_NONNULL ((1, 2))); 1530 const char *restrict format, va_list args)
1531 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1532 _GL_ARG_NONNULL ((1, 2)));
1194# endif 1533# endif
1195_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); 1534_GL_CXXALIAS_RPL (vfprintf, int,
1535 (FILE *restrict fp,
1536 const char *restrict format, va_list args));
1196# else 1537# else
1197/* Need to cast, because on Solaris, the third parameter is 1538/* Need to cast, because on Solaris, the third parameter is
1198 __va_list args 1539 __va_list args
1199 and GCC's fixincludes did not change this to __gnuc_va_list. */ 1540 and GCC's fixincludes did not change this to __gnuc_va_list. */
1200_GL_CXXALIAS_SYS_CAST (vfprintf, int, 1541_GL_CXXALIAS_SYS_CAST (vfprintf, int,
1201 (FILE *fp, const char *format, va_list args)); 1542 (FILE *restrict fp,
1543 const char *restrict format, va_list args));
1202# endif 1544# endif
1545# if __GLIBC__ >= 2
1203_GL_CXXALIASWARN (vfprintf); 1546_GL_CXXALIASWARN (vfprintf);
1547# endif
1204#endif 1548#endif
1205#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1549#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1206# if !GNULIB_overrides_vfprintf 1550# if !GNULIB_overrides_vfprintf
@@ -1219,16 +1563,21 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1219# define vfscanf rpl_vfscanf 1563# define vfscanf rpl_vfscanf
1220# endif 1564# endif
1221_GL_FUNCDECL_RPL (vfscanf, int, 1565_GL_FUNCDECL_RPL (vfscanf, int,
1222 (FILE *stream, const char *format, va_list args) 1566 (FILE *restrict stream,
1567 const char *restrict format, va_list args)
1223 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) 1568 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1224 _GL_ARG_NONNULL ((1, 2))); 1569 _GL_ARG_NONNULL ((1, 2)));
1225_GL_CXXALIAS_RPL (vfscanf, int, 1570_GL_CXXALIAS_RPL (vfscanf, int,
1226 (FILE *stream, const char *format, va_list args)); 1571 (FILE *restrict stream,
1572 const char *restrict format, va_list args));
1227# else 1573# else
1228_GL_CXXALIAS_SYS (vfscanf, int, 1574_GL_CXXALIAS_SYS (vfscanf, int,
1229 (FILE *stream, const char *format, va_list args)); 1575 (FILE *restrict stream,
1576 const char *restrict format, va_list args));
1230# endif 1577# endif
1578# if __GLIBC__ >= 2
1231_GL_CXXALIASWARN (vfscanf); 1579_GL_CXXALIASWARN (vfscanf);
1580# endif
1232#endif 1581#endif
1233 1582
1234#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1583#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
@@ -1239,22 +1588,25 @@ _GL_CXXALIASWARN (vfscanf);
1239# endif 1588# endif
1240# define GNULIB_overrides_vprintf 1 1589# define GNULIB_overrides_vprintf 1
1241# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@ 1590# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1242_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 1591_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1243 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0) 1592 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
1244 _GL_ARG_NONNULL ((1))); 1593 _GL_ARG_NONNULL ((1)));
1245# else 1594# else
1246_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 1595_GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
1247 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) 1596 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1248 _GL_ARG_NONNULL ((1))); 1597 _GL_ARG_NONNULL ((1)));
1249# endif 1598# endif
1250_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); 1599_GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
1251# else 1600# else
1252/* Need to cast, because on Solaris, the second parameter is 1601/* Need to cast, because on Solaris, the second parameter is
1253 __va_list args 1602 __va_list args
1254 and GCC's fixincludes did not change this to __gnuc_va_list. */ 1603 and GCC's fixincludes did not change this to __gnuc_va_list. */
1255_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); 1604_GL_CXXALIAS_SYS_CAST (vprintf, int,
1605 (const char *restrict format, va_list args));
1256# endif 1606# endif
1607# if __GLIBC__ >= 2
1257_GL_CXXALIASWARN (vprintf); 1608_GL_CXXALIASWARN (vprintf);
1609# endif
1258#endif 1610#endif
1259#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK 1611#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1260# if !GNULIB_overrides_vprintf 1612# if !GNULIB_overrides_vprintf
@@ -1272,14 +1624,16 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1272# undef vscanf 1624# undef vscanf
1273# define vscanf rpl_vscanf 1625# define vscanf rpl_vscanf
1274# endif 1626# endif
1275_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args) 1627_GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
1276 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) 1628 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1277 _GL_ARG_NONNULL ((1))); 1629 _GL_ARG_NONNULL ((1)));
1278_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args)); 1630_GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
1279# else 1631# else
1280_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args)); 1632_GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
1281# endif 1633# endif
1634# if __GLIBC__ >= 2
1282_GL_CXXALIASWARN (vscanf); 1635_GL_CXXALIASWARN (vscanf);
1636# endif
1283#endif 1637#endif
1284 1638
1285#if @GNULIB_VSNPRINTF@ 1639#if @GNULIB_VSNPRINTF@
@@ -1287,23 +1641,30 @@ _GL_CXXALIASWARN (vscanf);
1287# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1641# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1288# define vsnprintf rpl_vsnprintf 1642# define vsnprintf rpl_vsnprintf
1289# endif 1643# endif
1644# define GNULIB_overrides_vsnprintf 1
1290_GL_FUNCDECL_RPL (vsnprintf, int, 1645_GL_FUNCDECL_RPL (vsnprintf, int,
1291 (char *str, size_t size, const char *format, va_list args) 1646 (char *restrict str, size_t size,
1292 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) 1647 const char *restrict format, va_list args)
1648 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1293 _GL_ARG_NONNULL ((3))); 1649 _GL_ARG_NONNULL ((3)));
1294_GL_CXXALIAS_RPL (vsnprintf, int, 1650_GL_CXXALIAS_RPL (vsnprintf, int,
1295 (char *str, size_t size, const char *format, va_list args)); 1651 (char *restrict str, size_t size,
1652 const char *restrict format, va_list args));
1296# else 1653# else
1297# if !@HAVE_DECL_VSNPRINTF@ 1654# if !@HAVE_DECL_VSNPRINTF@
1298_GL_FUNCDECL_SYS (vsnprintf, int, 1655_GL_FUNCDECL_SYS (vsnprintf, int,
1299 (char *str, size_t size, const char *format, va_list args) 1656 (char *restrict str, size_t size,
1300 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) 1657 const char *restrict format, va_list args)
1658 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
1301 _GL_ARG_NONNULL ((3))); 1659 _GL_ARG_NONNULL ((3)));
1302# endif 1660# endif
1303_GL_CXXALIAS_SYS (vsnprintf, int, 1661_GL_CXXALIAS_SYS (vsnprintf, int,
1304 (char *str, size_t size, const char *format, va_list args)); 1662 (char *restrict str, size_t size,
1663 const char *restrict format, va_list args));
1305# endif 1664# endif
1665# if __GLIBC__ >= 2
1306_GL_CXXALIASWARN (vsnprintf); 1666_GL_CXXALIASWARN (vsnprintf);
1667# endif
1307#elif defined GNULIB_POSIXCHECK 1668#elif defined GNULIB_POSIXCHECK
1308# undef vsnprintf 1669# undef vsnprintf
1309# if HAVE_RAW_DECL_VSNPRINTF 1670# if HAVE_RAW_DECL_VSNPRINTF
@@ -1317,20 +1678,26 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1317# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1678# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1318# define vsprintf rpl_vsprintf 1679# define vsprintf rpl_vsprintf
1319# endif 1680# endif
1681# define GNULIB_overrides_vsprintf 1
1320_GL_FUNCDECL_RPL (vsprintf, int, 1682_GL_FUNCDECL_RPL (vsprintf, int,
1321 (char *str, const char *format, va_list args) 1683 (char *restrict str,
1322 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 1684 const char *restrict format, va_list args)
1685 _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
1323 _GL_ARG_NONNULL ((1, 2))); 1686 _GL_ARG_NONNULL ((1, 2)));
1324_GL_CXXALIAS_RPL (vsprintf, int, 1687_GL_CXXALIAS_RPL (vsprintf, int,
1325 (char *str, const char *format, va_list args)); 1688 (char *restrict str,
1689 const char *restrict format, va_list args));
1326# else 1690# else
1327/* Need to cast, because on Solaris, the third parameter is 1691/* Need to cast, because on Solaris, the third parameter is
1328 __va_list args 1692 __va_list args
1329 and GCC's fixincludes did not change this to __gnuc_va_list. */ 1693 and GCC's fixincludes did not change this to __gnuc_va_list. */
1330_GL_CXXALIAS_SYS_CAST (vsprintf, int, 1694_GL_CXXALIAS_SYS_CAST (vsprintf, int,
1331 (char *str, const char *format, va_list args)); 1695 (char *restrict str,
1696 const char *restrict format, va_list args));
1332# endif 1697# endif
1698# if __GLIBC__ >= 2
1333_GL_CXXALIASWARN (vsprintf); 1699_GL_CXXALIASWARN (vsprintf);
1700# endif
1334#elif defined GNULIB_POSIXCHECK 1701#elif defined GNULIB_POSIXCHECK
1335# undef vsprintf 1702# undef vsprintf
1336/* Assume vsprintf is always declared. */ 1703/* Assume vsprintf is always declared. */
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index c955248..b79e5f7 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,19 +1,19 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
@@ -47,11 +47,14 @@
47 47
48/* Solaris declares getloadavg() in <sys/loadavg.h>. */ 48/* Solaris declares getloadavg() in <sys/loadavg.h>. */
49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ 49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
50/* OpenIndiana has a bug: <sys/time.h> must be included before
51 <sys/loadavg.h>. */
52# include <sys/time.h>
50# include <sys/loadavg.h> 53# include <sys/loadavg.h>
51#endif 54#endif
52 55
53/* Native Windows platforms declare mktemp() in <io.h>. */ 56/* Native Windows platforms declare _mktemp() in <io.h>. */
54#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 57#if defined _WIN32 && !defined __CYGWIN__
55# include <io.h> 58# include <io.h>
56#endif 59#endif
57 60
@@ -87,20 +90,52 @@ struct random_data
87# endif 90# endif
88#endif 91#endif
89 92
90#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 93#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
91/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */ 94/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
92/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */ 95/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
96/* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
93/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ 97/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
94/* But avoid namespace pollution on glibc systems and native Windows. */ 98/* But avoid namespace pollution on glibc systems and native Windows. */
95# include <unistd.h> 99# include <unistd.h>
96#endif 100#endif
97 101
102/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
103 that can be freed by passing them as the Ith argument to the
104 function F. */
105#ifndef _GL_ATTRIBUTE_DEALLOC
106# if __GNUC__ >= 11
107# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
108# else
109# define _GL_ATTRIBUTE_DEALLOC(f, i)
110# endif
111#endif
112
113/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
114 can be freed via 'free'; it can be used only after declaring 'free'. */
115/* Applies to: functions. Cannot be used on inline functions. */
116#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
117# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1)
118#endif
119
120/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
121 allocated memory. */
122/* Applies to: functions. */
123#ifndef _GL_ATTRIBUTE_MALLOC
124# if __GNUC__ >= 3 || defined __clang__
125# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
126# else
127# define _GL_ATTRIBUTE_MALLOC
128# endif
129#endif
130
98/* The __attribute__ feature is available in gcc versions 2.5 and later. 131/* The __attribute__ feature is available in gcc versions 2.5 and later.
99 The attribute __pure__ was added in gcc 2.96. */ 132 The attribute __pure__ was added in gcc 2.96. */
100#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 133#ifndef _GL_ATTRIBUTE_PURE
101# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 134# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
102#else 135# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
103# define _GL_ATTRIBUTE_PURE /* empty */ 136# else
137# define _GL_ATTRIBUTE_PURE /* empty */
138# endif
104#endif 139#endif
105 140
106/* The definition of _Noreturn is copied here. */ 141/* The definition of _Noreturn is copied here. */
@@ -143,6 +178,73 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
143#endif 178#endif
144 179
145 180
181#if @GNULIB_FREE_POSIX@
182# if @REPLACE_FREE@
183# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184# undef free
185# define free rpl_free
186# endif
187# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
188_GL_FUNCDECL_RPL (free, void, (void *ptr) throw ());
189# else
190_GL_FUNCDECL_RPL (free, void, (void *ptr));
191# endif
192_GL_CXXALIAS_RPL (free, void, (void *ptr));
193# else
194_GL_CXXALIAS_SYS (free, void, (void *ptr));
195# endif
196# if __GLIBC__ >= 2
197_GL_CXXALIASWARN (free);
198# endif
199#elif defined GNULIB_POSIXCHECK
200# undef free
201/* Assume free is always declared. */
202_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
203 "use gnulib module free for portability");
204#endif
205
206
207/* Allocate memory with indefinite extent and specified alignment. */
208#if @GNULIB_ALIGNED_ALLOC@
209# if @REPLACE_ALIGNED_ALLOC@
210# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
211# undef aligned_alloc
212# define aligned_alloc rpl_aligned_alloc
213# endif
214_GL_FUNCDECL_RPL (aligned_alloc, void *,
215 (size_t alignment, size_t size)
216 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
217_GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
218# else
219# if @HAVE_ALIGNED_ALLOC@
220# if __GNUC__ >= 11
221/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
222_GL_FUNCDECL_SYS (aligned_alloc, void *,
223 (size_t alignment, size_t size)
224 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
225# endif
226_GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
227# endif
228# endif
229# if (__GLIBC__ >= 2) && @HAVE_ALIGNED_ALLOC@
230_GL_CXXALIASWARN (aligned_alloc);
231# endif
232#else
233# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined aligned_alloc
234/* For -Wmismatched-dealloc: Associate aligned_alloc with free or rpl_free. */
235_GL_FUNCDECL_SYS (aligned_alloc, void *,
236 (size_t alignment, size_t size)
237 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
238# endif
239# if defined GNULIB_POSIXCHECK
240# undef aligned_alloc
241# if HAVE_RAW_DECL_ALIGNED_ALLOC
242_GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
243 "use gnulib module aligned_alloc for portability");
244# endif
245# endif
246#endif
247
146#if @GNULIB_ATOLL@ 248#if @GNULIB_ATOLL@
147/* Parse a signed decimal integer. 249/* Parse a signed decimal integer.
148 Returns the value of the integer. Errors are not detected. */ 250 Returns the value of the integer. Errors are not detected. */
@@ -162,22 +264,41 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
162#endif 264#endif
163 265
164#if @GNULIB_CALLOC_POSIX@ 266#if @GNULIB_CALLOC_POSIX@
165# if @REPLACE_CALLOC@ 267# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \
268 || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
166# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 269# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167# undef calloc 270# undef calloc
168# define calloc rpl_calloc 271# define calloc rpl_calloc
169# endif 272# endif
170_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); 273_GL_FUNCDECL_RPL (calloc, void *,
274 (size_t nmemb, size_t size)
275 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
171_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); 276_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
172# else 277# else
278# if __GNUC__ >= 11
279/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
280_GL_FUNCDECL_SYS (calloc, void *,
281 (size_t nmemb, size_t size)
282 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
283# endif
173_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); 284_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
174# endif 285# endif
286# if __GLIBC__ >= 2
175_GL_CXXALIASWARN (calloc); 287_GL_CXXALIASWARN (calloc);
176#elif defined GNULIB_POSIXCHECK 288# endif
177# undef calloc 289#else
290# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined calloc
291/* For -Wmismatched-dealloc: Associate calloc with free or rpl_free. */
292_GL_FUNCDECL_SYS (calloc, void *,
293 (size_t nmemb, size_t size)
294 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
295# endif
296# if defined GNULIB_POSIXCHECK
297# undef calloc
178/* Assume calloc is always declared. */ 298/* Assume calloc is always declared. */
179_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " 299_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
180 "use gnulib module calloc-posix for portability"); 300 "use gnulib module calloc-posix for portability");
301# endif
181#endif 302#endif
182 303
183#if @GNULIB_CANONICALIZE_FILE_NAME@ 304#if @GNULIB_CANONICALIZE_FILE_NAME@
@@ -185,23 +306,108 @@ _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
185# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 306# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
186# define canonicalize_file_name rpl_canonicalize_file_name 307# define canonicalize_file_name rpl_canonicalize_file_name
187# endif 308# endif
188_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) 309_GL_FUNCDECL_RPL (canonicalize_file_name, char *,
189 _GL_ARG_NONNULL ((1))); 310 (const char *name)
311 _GL_ARG_NONNULL ((1))
312 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
190_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); 313_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
191# else 314# else
192# if !@HAVE_CANONICALIZE_FILE_NAME@ 315# if !@HAVE_CANONICALIZE_FILE_NAME@ || __GNUC__ >= 11
193_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) 316_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
194 _GL_ARG_NONNULL ((1))); 317 (const char *name)
318 _GL_ARG_NONNULL ((1))
319 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
195# endif 320# endif
196_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); 321_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
197# endif 322# endif
323# ifndef GNULIB_defined_canonicalize_file_name
324# define GNULIB_defined_canonicalize_file_name \
325 (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
326# endif
198_GL_CXXALIASWARN (canonicalize_file_name); 327_GL_CXXALIASWARN (canonicalize_file_name);
199#elif defined GNULIB_POSIXCHECK 328#else
200# undef canonicalize_file_name 329# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined canonicalize_file_name
201# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME 330/* For -Wmismatched-dealloc: Associate canonicalize_file_name with free or
331 rpl_free. */
332_GL_FUNCDECL_SYS (canonicalize_file_name, char *,
333 (const char *name)
334 _GL_ARG_NONNULL ((1))
335 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
336# endif
337# if defined GNULIB_POSIXCHECK
338# undef canonicalize_file_name
339# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
202_GL_WARN_ON_USE (canonicalize_file_name, 340_GL_WARN_ON_USE (canonicalize_file_name,
203 "canonicalize_file_name is unportable - " 341 "canonicalize_file_name is unportable - "
204 "use gnulib module canonicalize-lgpl for portability"); 342 "use gnulib module canonicalize-lgpl for portability");
343# endif
344# endif
345#endif
346
347#if @GNULIB_MDA_ECVT@
348/* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not
349 required. In C++ with GNULIB_NAMESPACE, avoid differences between
350 platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have
351 it. */
352# if defined _WIN32 && !defined __CYGWIN__
353# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
354# undef ecvt
355# define ecvt _ecvt
356# endif
357_GL_CXXALIAS_MDA (ecvt, char *,
358 (double number, int ndigits, int *decptp, int *signp));
359# else
360# if @HAVE_DECL_ECVT@
361_GL_CXXALIAS_SYS (ecvt, char *,
362 (double number, int ndigits, int *decptp, int *signp));
363# endif
364# endif
365# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@
366_GL_CXXALIASWARN (ecvt);
367# endif
368#endif
369
370#if @GNULIB_MDA_FCVT@
371/* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not
372 required. In C++ with GNULIB_NAMESPACE, avoid differences between
373 platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have
374 it. */
375# if defined _WIN32 && !defined __CYGWIN__
376# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377# undef fcvt
378# define fcvt _fcvt
379# endif
380_GL_CXXALIAS_MDA (fcvt, char *,
381 (double number, int ndigits, int *decptp, int *signp));
382# else
383# if @HAVE_DECL_FCVT@
384_GL_CXXALIAS_SYS (fcvt, char *,
385 (double number, int ndigits, int *decptp, int *signp));
386# endif
387# endif
388# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@
389_GL_CXXALIASWARN (fcvt);
390# endif
391#endif
392
393#if @GNULIB_MDA_GCVT@
394/* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
395 required. In C++ with GNULIB_NAMESPACE, avoid differences between
396 platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
397 it. */
398# if defined _WIN32 && !defined __CYGWIN__
399# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
400# undef gcvt
401# define gcvt _gcvt
402# endif
403_GL_CXXALIAS_MDA (gcvt, char *, (double number, int ndigits, char *buf));
404# else
405# if @HAVE_DECL_GCVT@
406_GL_CXXALIAS_SYS (gcvt, char *, (double number, int ndigits, char *buf));
407# endif
408# endif
409# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@
410_GL_CXXALIASWARN (gcvt);
205# endif 411# endif
206#endif 412#endif
207 413
@@ -234,8 +440,8 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
234 element (or NULL if it doesn't contain an "=" sign), 440 element (or NULL if it doesn't contain an "=" sign),
235 - It returns the index of the "token" in the given array of tokens. 441 - It returns the index of the "token" in the given array of tokens.
236 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. 442 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
237 For more details see the POSIX:2001 specification. 443 For more details see the POSIX specification.
238 http://www.opengroup.org/susv3xsh/getsubopt.html */ 444 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
239# if !@HAVE_GETSUBOPT@ 445# if !@HAVE_GETSUBOPT@
240_GL_FUNCDECL_SYS (getsubopt, int, 446_GL_FUNCDECL_SYS (getsubopt, int,
241 (char **optionp, char *const *tokens, char **valuep) 447 (char **optionp, char *const *tokens, char **valuep)
@@ -273,23 +479,42 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
273 by never specifying a zero size), so it does not need malloc or 479 by never specifying a zero size), so it does not need malloc or
274 realloc to be redefined. */ 480 realloc to be redefined. */
275#if @GNULIB_MALLOC_POSIX@ 481#if @GNULIB_MALLOC_POSIX@
276# if @REPLACE_MALLOC@ 482# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \
483 || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
277# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 484# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
278 || _GL_USE_STDLIB_ALLOC) 485 || _GL_USE_STDLIB_ALLOC)
279# undef malloc 486# undef malloc
280# define malloc rpl_malloc 487# define malloc rpl_malloc
281# endif 488# endif
282_GL_FUNCDECL_RPL (malloc, void *, (size_t size)); 489_GL_FUNCDECL_RPL (malloc, void *,
490 (size_t size)
491 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
283_GL_CXXALIAS_RPL (malloc, void *, (size_t size)); 492_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
284# else 493# else
494# if __GNUC__ >= 11
495/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
496_GL_FUNCDECL_SYS (malloc, void *,
497 (size_t size)
498 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
499# endif
285_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 500_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
286# endif 501# endif
502# if __GLIBC__ >= 2
287_GL_CXXALIASWARN (malloc); 503_GL_CXXALIASWARN (malloc);
288#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 504# endif
289# undef malloc 505#else
506# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined malloc
507/* For -Wmismatched-dealloc: Associate malloc with free or rpl_free. */
508_GL_FUNCDECL_SYS (malloc, void *,
509 (size_t size)
510 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
511# endif
512# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
513# undef malloc
290/* Assume malloc is always declared. */ 514/* Assume malloc is always declared. */
291_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " 515_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
292 "use gnulib module malloc-posix for portability"); 516 "use gnulib module malloc-posix for portability");
517# endif
293#endif 518#endif
294 519
295/* Convert a multibyte character to a wide character. */ 520/* Convert a multibyte character to a wide character. */
@@ -299,12 +524,27 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
299# undef mbtowc 524# undef mbtowc
300# define mbtowc rpl_mbtowc 525# define mbtowc rpl_mbtowc
301# endif 526# endif
302_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); 527_GL_FUNCDECL_RPL (mbtowc, int,
303_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); 528 (wchar_t *restrict pwc, const char *restrict s, size_t n));
529_GL_CXXALIAS_RPL (mbtowc, int,
530 (wchar_t *restrict pwc, const char *restrict s, size_t n));
304# else 531# else
305_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); 532# if !@HAVE_MBTOWC@
533_GL_FUNCDECL_SYS (mbtowc, int,
534 (wchar_t *restrict pwc, const char *restrict s, size_t n));
535# endif
536_GL_CXXALIAS_SYS (mbtowc, int,
537 (wchar_t *restrict pwc, const char *restrict s, size_t n));
306# endif 538# endif
539# if __GLIBC__ >= 2
307_GL_CXXALIASWARN (mbtowc); 540_GL_CXXALIASWARN (mbtowc);
541# endif
542#elif defined GNULIB_POSIXCHECK
543# undef mbtowc
544# if HAVE_RAW_DECL_MBTOWC
545_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
546 "use gnulib module mbtowc for portability");
547# endif
308#endif 548#endif
309 549
310#if @GNULIB_MKDTEMP@ 550#if @GNULIB_MKDTEMP@
@@ -439,6 +679,51 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
439# endif 679# endif
440#endif 680#endif
441 681
682#if @GNULIB_MDA_MKTEMP@
683/* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not
684 required. In C++ with GNULIB_NAMESPACE, avoid differences between
685 platforms by defining GNULIB_NAMESPACE::mktemp always. */
686# if defined _WIN32 && !defined __CYGWIN__
687# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
688# undef mktemp
689# define mktemp _mktemp
690# endif
691_GL_CXXALIAS_MDA (mktemp, char *, (char * /*template*/));
692# else
693_GL_CXXALIAS_SYS (mktemp, char *, (char * /*template*/));
694# endif
695_GL_CXXALIASWARN (mktemp);
696#endif
697
698/* Allocate memory with indefinite extent and specified alignment. */
699#if @GNULIB_POSIX_MEMALIGN@
700# if @REPLACE_POSIX_MEMALIGN@
701# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
702# undef posix_memalign
703# define posix_memalign rpl_posix_memalign
704# endif
705_GL_FUNCDECL_RPL (posix_memalign, int,
706 (void **memptr, size_t alignment, size_t size)
707 _GL_ARG_NONNULL ((1)));
708_GL_CXXALIAS_RPL (posix_memalign, int,
709 (void **memptr, size_t alignment, size_t size));
710# else
711# if @HAVE_POSIX_MEMALIGN@
712_GL_CXXALIAS_SYS (posix_memalign, int,
713 (void **memptr, size_t alignment, size_t size));
714# endif
715# endif
716# if @HAVE_POSIX_MEMALIGN@
717_GL_CXXALIASWARN (posix_memalign);
718# endif
719#elif defined GNULIB_POSIXCHECK
720# undef posix_memalign
721# if HAVE_RAW_DECL_POSIX_MEMALIGN
722_GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
723 "use gnulib module posix_memalign for portability");
724# endif
725#endif
726
442#if @GNULIB_POSIX_OPENPT@ 727#if @GNULIB_POSIX_OPENPT@
443/* Return an FD open to the master side of a pseudo-terminal. Flags should 728/* Return an FD open to the master side of a pseudo-terminal. Flags should
444 include O_RDWR, and may also include O_NOCTTY. */ 729 include O_RDWR, and may also include O_NOCTTY. */
@@ -497,6 +782,9 @@ _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
497# endif 782# endif
498_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len)); 783_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
499# endif 784# endif
785# ifndef GNULIB_defined_ptsname_r
786# define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
787# endif
500_GL_CXXALIASWARN (ptsname_r); 788_GL_CXXALIASWARN (ptsname_r);
501#elif defined GNULIB_POSIXCHECK 789#elif defined GNULIB_POSIXCHECK
502# undef ptsname_r 790# undef ptsname_r
@@ -514,12 +802,78 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
514# endif 802# endif
515_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); 803_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
516_GL_CXXALIAS_RPL (putenv, int, (char *string)); 804_GL_CXXALIAS_RPL (putenv, int, (char *string));
805# elif defined _WIN32 && !defined __CYGWIN__
806# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
807# undef putenv
808# define putenv _putenv
809# endif
810_GL_CXXALIAS_MDA (putenv, int, (char *string));
811# else
812_GL_CXXALIAS_SYS (putenv, int, (char *string));
813# endif
814_GL_CXXALIASWARN (putenv);
815#elif @GNULIB_MDA_PUTENV@
816/* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not
817 required. In C++ with GNULIB_NAMESPACE, avoid differences between
818 platforms by defining GNULIB_NAMESPACE::putenv always. */
819# if defined _WIN32 && !defined __CYGWIN__
820# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
821# undef putenv
822# define putenv _putenv
823# endif
824/* Need to cast, because on mingw, the parameter is either
825 'const char *string' or 'char *string'. */
826_GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
517# else 827# else
518_GL_CXXALIAS_SYS (putenv, int, (char *string)); 828_GL_CXXALIAS_SYS (putenv, int, (char *string));
519# endif 829# endif
520_GL_CXXALIASWARN (putenv); 830_GL_CXXALIASWARN (putenv);
521#endif 831#endif
522 832
833#if @GNULIB_QSORT_R@
834/* Sort an array of NMEMB elements, starting at address BASE, each element
835 occupying SIZE bytes, in ascending order according to the comparison
836 function COMPARE. */
837# ifdef __cplusplus
838extern "C" {
839# endif
840# if !GNULIB_defined_qsort_r_fn_types
841typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
842# define GNULIB_defined_qsort_r_fn_types 1
843# endif
844# ifdef __cplusplus
845}
846# endif
847# if @REPLACE_QSORT_R@
848# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
849# undef qsort_r
850# define qsort_r rpl_qsort_r
851# endif
852_GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
853 _gl_qsort_r_compar_fn compare,
854 void *arg) _GL_ARG_NONNULL ((1, 4)));
855_GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
856 _gl_qsort_r_compar_fn compare,
857 void *arg));
858# else
859# if !@HAVE_QSORT_R@
860_GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
861 _gl_qsort_r_compar_fn compare,
862 void *arg) _GL_ARG_NONNULL ((1, 4)));
863# endif
864_GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
865 _gl_qsort_r_compar_fn compare,
866 void *arg));
867# endif
868_GL_CXXALIASWARN (qsort_r);
869#elif defined GNULIB_POSIXCHECK
870# undef qsort_r
871# if HAVE_RAW_DECL_QSORT_R
872_GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
873 "use gnulib module qsort_r for portability");
874# endif
875#endif
876
523 877
524#if @GNULIB_RANDOM_R@ 878#if @GNULIB_RANDOM_R@
525# if !@HAVE_RANDOM_R@ 879# if !@HAVE_RANDOM_R@
@@ -531,10 +885,21 @@ _GL_CXXALIASWARN (putenv);
531 885
532 886
533#if @GNULIB_RANDOM@ 887#if @GNULIB_RANDOM@
534# if !@HAVE_RANDOM@ 888# if @REPLACE_RANDOM@
889# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
890# undef random
891# define random rpl_random
892# endif
893_GL_FUNCDECL_RPL (random, long, (void));
894_GL_CXXALIAS_RPL (random, long, (void));
895# else
896# if !@HAVE_RANDOM@
535_GL_FUNCDECL_SYS (random, long, (void)); 897_GL_FUNCDECL_SYS (random, long, (void));
898# endif
899/* Need to cast, because on Haiku, the return type is
900 int. */
901_GL_CXXALIAS_SYS_CAST (random, long, (void));
536# endif 902# endif
537_GL_CXXALIAS_SYS (random, long, (void));
538_GL_CXXALIASWARN (random); 903_GL_CXXALIASWARN (random);
539#elif defined GNULIB_POSIXCHECK 904#elif defined GNULIB_POSIXCHECK
540# undef random 905# undef random
@@ -545,10 +910,21 @@ _GL_WARN_ON_USE (random, "random is unportable - "
545#endif 910#endif
546 911
547#if @GNULIB_RANDOM@ 912#if @GNULIB_RANDOM@
548# if !@HAVE_RANDOM@ 913# if @REPLACE_RANDOM@
914# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
915# undef srandom
916# define srandom rpl_srandom
917# endif
918_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed));
919_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
920# else
921# if !@HAVE_RANDOM@
549_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed)); 922_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
923# endif
924/* Need to cast, because on FreeBSD, the first parameter is
925 unsigned long seed. */
926_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
550# endif 927# endif
551_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
552_GL_CXXALIASWARN (srandom); 928_GL_CXXALIASWARN (srandom);
553#elif defined GNULIB_POSIXCHECK 929#elif defined GNULIB_POSIXCHECK
554# undef srandom 930# undef srandom
@@ -559,31 +935,56 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
559#endif 935#endif
560 936
561#if @GNULIB_RANDOM@ 937#if @GNULIB_RANDOM@
562# if !@HAVE_RANDOM@ 938# if @REPLACE_INITSTATE@
939# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# undef initstate
941# define initstate rpl_initstate
942# endif
943_GL_FUNCDECL_RPL (initstate, char *,
944 (unsigned int seed, char *buf, size_t buf_size)
945 _GL_ARG_NONNULL ((2)));
946_GL_CXXALIAS_RPL (initstate, char *,
947 (unsigned int seed, char *buf, size_t buf_size));
948# else
949# if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
563_GL_FUNCDECL_SYS (initstate, char *, 950_GL_FUNCDECL_SYS (initstate, char *,
564 (unsigned int seed, char *buf, size_t buf_size) 951 (unsigned int seed, char *buf, size_t buf_size)
565 _GL_ARG_NONNULL ((2))); 952 _GL_ARG_NONNULL ((2)));
953# endif
954/* Need to cast, because on FreeBSD, the first parameter is
955 unsigned long seed. */
956_GL_CXXALIAS_SYS_CAST (initstate, char *,
957 (unsigned int seed, char *buf, size_t buf_size));
566# endif 958# endif
567_GL_CXXALIAS_SYS (initstate, char *,
568 (unsigned int seed, char *buf, size_t buf_size));
569_GL_CXXALIASWARN (initstate); 959_GL_CXXALIASWARN (initstate);
570#elif defined GNULIB_POSIXCHECK 960#elif defined GNULIB_POSIXCHECK
571# undef initstate 961# undef initstate
572# if HAVE_RAW_DECL_INITSTATE_R 962# if HAVE_RAW_DECL_INITSTATE
573_GL_WARN_ON_USE (initstate, "initstate is unportable - " 963_GL_WARN_ON_USE (initstate, "initstate is unportable - "
574 "use gnulib module random for portability"); 964 "use gnulib module random for portability");
575# endif 965# endif
576#endif 966#endif
577 967
578#if @GNULIB_RANDOM@ 968#if @GNULIB_RANDOM@
579# if !@HAVE_RANDOM@ 969# if @REPLACE_SETSTATE@
970# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
971# undef setstate
972# define setstate rpl_setstate
973# endif
974_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
975_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
976# else
977# if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
580_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); 978_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
979# endif
980/* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
981 is const char *arg_state. */
982_GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
581# endif 983# endif
582_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
583_GL_CXXALIASWARN (setstate); 984_GL_CXXALIASWARN (setstate);
584#elif defined GNULIB_POSIXCHECK 985#elif defined GNULIB_POSIXCHECK
585# undef setstate 986# undef setstate
586# if HAVE_RAW_DECL_SETSTATE_R 987# if HAVE_RAW_DECL_SETSTATE
587_GL_WARN_ON_USE (setstate, "setstate is unportable - " 988_GL_WARN_ON_USE (setstate, "setstate is unportable - "
588 "use gnulib module random for portability"); 989 "use gnulib module random for portability");
589# endif 990# endif
@@ -664,9 +1065,11 @@ _GL_FUNCDECL_SYS (initstate_r, int,
664 struct random_data *rand_state) 1065 struct random_data *rand_state)
665 _GL_ARG_NONNULL ((2, 4))); 1066 _GL_ARG_NONNULL ((2, 4)));
666# endif 1067# endif
667_GL_CXXALIAS_SYS (initstate_r, int, 1068/* Need to cast, because on Haiku, the third parameter is
668 (unsigned int seed, char *buf, size_t buf_size, 1069 unsigned long buf_size. */
669 struct random_data *rand_state)); 1070_GL_CXXALIAS_SYS_CAST (initstate_r, int,
1071 (unsigned int seed, char *buf, size_t buf_size,
1072 struct random_data *rand_state));
670# endif 1073# endif
671_GL_CXXALIASWARN (initstate_r); 1074_GL_CXXALIASWARN (initstate_r);
672#elif defined GNULIB_POSIXCHECK 1075#elif defined GNULIB_POSIXCHECK
@@ -694,8 +1097,10 @@ _GL_FUNCDECL_SYS (setstate_r, int,
694 (char *arg_state, struct random_data *rand_state) 1097 (char *arg_state, struct random_data *rand_state)
695 _GL_ARG_NONNULL ((1, 2))); 1098 _GL_ARG_NONNULL ((1, 2)));
696# endif 1099# endif
697_GL_CXXALIAS_SYS (setstate_r, int, 1100/* Need to cast, because on Haiku, the first parameter is
698 (char *arg_state, struct random_data *rand_state)); 1101 void *arg_state. */
1102_GL_CXXALIAS_SYS_CAST (setstate_r, int,
1103 (char *arg_state, struct random_data *rand_state));
699# endif 1104# endif
700_GL_CXXALIASWARN (setstate_r); 1105_GL_CXXALIASWARN (setstate_r);
701#elif defined GNULIB_POSIXCHECK 1106#elif defined GNULIB_POSIXCHECK
@@ -708,23 +1113,67 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
708 1113
709 1114
710#if @GNULIB_REALLOC_POSIX@ 1115#if @GNULIB_REALLOC_POSIX@
711# if @REPLACE_REALLOC@ 1116# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
1117 || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
712# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ 1118# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
713 || _GL_USE_STDLIB_ALLOC) 1119 || _GL_USE_STDLIB_ALLOC)
714# undef realloc 1120# undef realloc
715# define realloc rpl_realloc 1121# define realloc rpl_realloc
716# endif 1122# endif
717_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); 1123_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)
1124 _GL_ATTRIBUTE_DEALLOC_FREE);
718_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); 1125_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
719# else 1126# else
1127# if __GNUC__ >= 11
1128/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1129_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
1130 _GL_ATTRIBUTE_DEALLOC_FREE);
1131# endif
720_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 1132_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
721# endif 1133# endif
1134# if __GLIBC__ >= 2
722_GL_CXXALIASWARN (realloc); 1135_GL_CXXALIASWARN (realloc);
723#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC 1136# endif
724# undef realloc 1137#else
1138# if @GNULIB_FREE_POSIX@ && __GNUC__ >= 11 && !defined realloc
1139/* For -Wmismatched-dealloc: Associate realloc with free or rpl_free. */
1140_GL_FUNCDECL_SYS (realloc, void *, (void *ptr, size_t size)
1141 _GL_ATTRIBUTE_DEALLOC_FREE);
1142# endif
1143# if defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
1144# undef realloc
725/* Assume realloc is always declared. */ 1145/* Assume realloc is always declared. */
726_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " 1146_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
727 "use gnulib module realloc-posix for portability"); 1147 "use gnulib module realloc-posix for portability");
1148# endif
1149#endif
1150
1151
1152#if @GNULIB_REALLOCARRAY@
1153# if @REPLACE_REALLOCARRAY@
1154# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1155# undef reallocarray
1156# define reallocarray rpl_reallocarray
1157# endif
1158_GL_FUNCDECL_RPL (reallocarray, void *,
1159 (void *ptr, size_t nmemb, size_t size));
1160_GL_CXXALIAS_RPL (reallocarray, void *,
1161 (void *ptr, size_t nmemb, size_t size));
1162# else
1163# if ! @HAVE_REALLOCARRAY@
1164_GL_FUNCDECL_SYS (reallocarray, void *,
1165 (void *ptr, size_t nmemb, size_t size));
1166# endif
1167_GL_CXXALIAS_SYS (reallocarray, void *,
1168 (void *ptr, size_t nmemb, size_t size));
1169# endif
1170_GL_CXXALIASWARN (reallocarray);
1171#elif defined GNULIB_POSIXCHECK
1172# undef reallocarray
1173# if HAVE_RAW_DECL_REALLOCARRAY
1174_GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
1175 "use gnulib module reallocarray for portability");
1176# endif
728#endif 1177#endif
729 1178
730#if @GNULIB_REALPATH@ 1179#if @GNULIB_REALPATH@
@@ -732,15 +1181,19 @@ _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
732# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1181# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733# define realpath rpl_realpath 1182# define realpath rpl_realpath
734# endif 1183# endif
735_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) 1184_GL_FUNCDECL_RPL (realpath, char *,
736 _GL_ARG_NONNULL ((1))); 1185 (const char *restrict name, char *restrict resolved)
737_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); 1186 _GL_ARG_NONNULL ((1)));
1187_GL_CXXALIAS_RPL (realpath, char *,
1188 (const char *restrict name, char *restrict resolved));
738# else 1189# else
739# if !@HAVE_REALPATH@ 1190# if !@HAVE_REALPATH@
740_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) 1191_GL_FUNCDECL_SYS (realpath, char *,
741 _GL_ARG_NONNULL ((1))); 1192 (const char *restrict name, char *restrict resolved)
1193 _GL_ARG_NONNULL ((1)));
742# endif 1194# endif
743_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); 1195_GL_CXXALIAS_SYS (realpath, char *,
1196 (const char *restrict name, char *restrict resolved));
744# endif 1197# endif
745_GL_CXXALIASWARN (realpath); 1198_GL_CXXALIASWARN (realpath);
746#elif defined GNULIB_POSIXCHECK 1199#elif defined GNULIB_POSIXCHECK
@@ -822,17 +1275,24 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
822# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1275# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
823# define strtod rpl_strtod 1276# define strtod rpl_strtod
824# endif 1277# endif
825_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) 1278# define GNULIB_defined_strtod_function 1
826 _GL_ARG_NONNULL ((1))); 1279_GL_FUNCDECL_RPL (strtod, double,
827_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); 1280 (const char *restrict str, char **restrict endp)
1281 _GL_ARG_NONNULL ((1)));
1282_GL_CXXALIAS_RPL (strtod, double,
1283 (const char *restrict str, char **restrict endp));
828# else 1284# else
829# if !@HAVE_STRTOD@ 1285# if !@HAVE_STRTOD@
830_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) 1286_GL_FUNCDECL_SYS (strtod, double,
831 _GL_ARG_NONNULL ((1))); 1287 (const char *restrict str, char **restrict endp)
1288 _GL_ARG_NONNULL ((1)));
832# endif 1289# endif
833_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); 1290_GL_CXXALIAS_SYS (strtod, double,
1291 (const char *restrict str, char **restrict endp));
834# endif 1292# endif
1293# if __GLIBC__ >= 2
835_GL_CXXALIASWARN (strtod); 1294_GL_CXXALIASWARN (strtod);
1295# endif
836#elif defined GNULIB_POSIXCHECK 1296#elif defined GNULIB_POSIXCHECK
837# undef strtod 1297# undef strtod
838# if HAVE_RAW_DECL_STRTOD 1298# if HAVE_RAW_DECL_STRTOD
@@ -841,6 +1301,79 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
841# endif 1301# endif
842#endif 1302#endif
843 1303
1304#if @GNULIB_STRTOLD@
1305 /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
1306# if @REPLACE_STRTOLD@
1307# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1308# define strtold rpl_strtold
1309# endif
1310# define GNULIB_defined_strtold_function 1
1311_GL_FUNCDECL_RPL (strtold, long double,
1312 (const char *restrict str, char **restrict endp)
1313 _GL_ARG_NONNULL ((1)));
1314_GL_CXXALIAS_RPL (strtold, long double,
1315 (const char *restrict str, char **restrict endp));
1316# else
1317# if !@HAVE_STRTOLD@
1318_GL_FUNCDECL_SYS (strtold, long double,
1319 (const char *restrict str, char **restrict endp)
1320 _GL_ARG_NONNULL ((1)));
1321# endif
1322_GL_CXXALIAS_SYS (strtold, long double,
1323 (const char *restrict str, char **restrict endp));
1324# endif
1325_GL_CXXALIASWARN (strtold);
1326#elif defined GNULIB_POSIXCHECK
1327# undef strtold
1328# if HAVE_RAW_DECL_STRTOLD
1329_GL_WARN_ON_USE (strtold, "strtold is unportable - "
1330 "use gnulib module strtold for portability");
1331# endif
1332#endif
1333
1334#if @GNULIB_STRTOL@
1335/* Parse a signed integer whose textual representation starts at STRING.
1336 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1337 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1338 "0x").
1339 If ENDPTR is not NULL, the address of the first byte after the integer is
1340 stored in *ENDPTR.
1341 Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set
1342 to ERANGE. */
1343# if @REPLACE_STRTOL@
1344# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1345# define strtol rpl_strtol
1346# endif
1347# define GNULIB_defined_strtol_function 1
1348_GL_FUNCDECL_RPL (strtol, long,
1349 (const char *restrict string, char **restrict endptr,
1350 int base)
1351 _GL_ARG_NONNULL ((1)));
1352_GL_CXXALIAS_RPL (strtol, long,
1353 (const char *restrict string, char **restrict endptr,
1354 int base));
1355# else
1356# if !@HAVE_STRTOL@
1357_GL_FUNCDECL_SYS (strtol, long,
1358 (const char *restrict string, char **restrict endptr,
1359 int base)
1360 _GL_ARG_NONNULL ((1)));
1361# endif
1362_GL_CXXALIAS_SYS (strtol, long,
1363 (const char *restrict string, char **restrict endptr,
1364 int base));
1365# endif
1366# if __GLIBC__ >= 2
1367_GL_CXXALIASWARN (strtol);
1368# endif
1369#elif defined GNULIB_POSIXCHECK
1370# undef strtol
1371# if HAVE_RAW_DECL_STRTOL
1372_GL_WARN_ON_USE (strtol, "strtol is unportable - "
1373 "use gnulib module strtol for portability");
1374# endif
1375#endif
1376
844#if @GNULIB_STRTOLL@ 1377#if @GNULIB_STRTOLL@
845/* Parse a signed integer whose textual representation starts at STRING. 1378/* Parse a signed integer whose textual representation starts at STRING.
846 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, 1379 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
@@ -850,13 +1383,29 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
850 stored in *ENDPTR. 1383 stored in *ENDPTR.
851 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set 1384 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
852 to ERANGE. */ 1385 to ERANGE. */
853# if !@HAVE_STRTOLL@ 1386# if @REPLACE_STRTOLL@
1387# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1388# define strtoll rpl_strtoll
1389# endif
1390# define GNULIB_defined_strtoll_function 1
1391_GL_FUNCDECL_RPL (strtoll, long long,
1392 (const char *restrict string, char **restrict endptr,
1393 int base)
1394 _GL_ARG_NONNULL ((1)));
1395_GL_CXXALIAS_RPL (strtoll, long long,
1396 (const char *restrict string, char **restrict endptr,
1397 int base));
1398# else
1399# if !@HAVE_STRTOLL@
854_GL_FUNCDECL_SYS (strtoll, long long, 1400_GL_FUNCDECL_SYS (strtoll, long long,
855 (const char *string, char **endptr, int base) 1401 (const char *restrict string, char **restrict endptr,
1402 int base)
856 _GL_ARG_NONNULL ((1))); 1403 _GL_ARG_NONNULL ((1)));
857# endif 1404# endif
858_GL_CXXALIAS_SYS (strtoll, long long, 1405_GL_CXXALIAS_SYS (strtoll, long long,
859 (const char *string, char **endptr, int base)); 1406 (const char *restrict string, char **restrict endptr,
1407 int base));
1408# endif
860_GL_CXXALIASWARN (strtoll); 1409_GL_CXXALIASWARN (strtoll);
861#elif defined GNULIB_POSIXCHECK 1410#elif defined GNULIB_POSIXCHECK
862# undef strtoll 1411# undef strtoll
@@ -866,6 +1415,48 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
866# endif 1415# endif
867#endif 1416#endif
868 1417
1418#if @GNULIB_STRTOUL@
1419/* Parse an unsigned integer whose textual representation starts at STRING.
1420 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
1421 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
1422 "0x").
1423 If ENDPTR is not NULL, the address of the first byte after the integer is
1424 stored in *ENDPTR.
1425 Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */
1426# if @REPLACE_STRTOUL@
1427# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1428# define strtoul rpl_strtoul
1429# endif
1430# define GNULIB_defined_strtoul_function 1
1431_GL_FUNCDECL_RPL (strtoul, unsigned long,
1432 (const char *restrict string, char **restrict endptr,
1433 int base)
1434 _GL_ARG_NONNULL ((1)));
1435_GL_CXXALIAS_RPL (strtoul, unsigned long,
1436 (const char *restrict string, char **restrict endptr,
1437 int base));
1438# else
1439# if !@HAVE_STRTOUL@
1440_GL_FUNCDECL_SYS (strtoul, unsigned long,
1441 (const char *restrict string, char **restrict endptr,
1442 int base)
1443 _GL_ARG_NONNULL ((1)));
1444# endif
1445_GL_CXXALIAS_SYS (strtoul, unsigned long,
1446 (const char *restrict string, char **restrict endptr,
1447 int base));
1448# endif
1449# if __GLIBC__ >= 2
1450_GL_CXXALIASWARN (strtoul);
1451# endif
1452#elif defined GNULIB_POSIXCHECK
1453# undef strtoul
1454# if HAVE_RAW_DECL_STRTOUL
1455_GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
1456 "use gnulib module strtoul for portability");
1457# endif
1458#endif
1459
869#if @GNULIB_STRTOULL@ 1460#if @GNULIB_STRTOULL@
870/* Parse an unsigned integer whose textual representation starts at STRING. 1461/* Parse an unsigned integer whose textual representation starts at STRING.
871 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, 1462 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
@@ -875,13 +1466,29 @@ _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
875 stored in *ENDPTR. 1466 stored in *ENDPTR.
876 Upon overflow, the return value is ULLONG_MAX, and errno is set to 1467 Upon overflow, the return value is ULLONG_MAX, and errno is set to
877 ERANGE. */ 1468 ERANGE. */
878# if !@HAVE_STRTOULL@ 1469# if @REPLACE_STRTOULL@
1470# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1471# define strtoull rpl_strtoull
1472# endif
1473# define GNULIB_defined_strtoull_function 1
1474_GL_FUNCDECL_RPL (strtoull, unsigned long long,
1475 (const char *restrict string, char **restrict endptr,
1476 int base)
1477 _GL_ARG_NONNULL ((1)));
1478_GL_CXXALIAS_RPL (strtoull, unsigned long long,
1479 (const char *restrict string, char **restrict endptr,
1480 int base));
1481# else
1482# if !@HAVE_STRTOULL@
879_GL_FUNCDECL_SYS (strtoull, unsigned long long, 1483_GL_FUNCDECL_SYS (strtoull, unsigned long long,
880 (const char *string, char **endptr, int base) 1484 (const char *restrict string, char **restrict endptr,
1485 int base)
881 _GL_ARG_NONNULL ((1))); 1486 _GL_ARG_NONNULL ((1)));
882# endif 1487# endif
883_GL_CXXALIAS_SYS (strtoull, unsigned long long, 1488_GL_CXXALIAS_SYS (strtoull, unsigned long long,
884 (const char *string, char **endptr, int base)); 1489 (const char *restrict string, char **restrict endptr,
1490 int base));
1491# endif
885_GL_CXXALIASWARN (strtoull); 1492_GL_CXXALIASWARN (strtoull);
886#elif defined GNULIB_POSIXCHECK 1493#elif defined GNULIB_POSIXCHECK
887# undef strtoull 1494# undef strtoull
@@ -945,7 +1552,9 @@ _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
945# else 1552# else
946_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); 1553_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
947# endif 1554# endif
1555# if __GLIBC__ >= 2
948_GL_CXXALIASWARN (wctomb); 1556_GL_CXXALIASWARN (wctomb);
1557# endif
949#endif 1558#endif
950 1559
951 1560
diff --git a/gl/str-two-way.h b/gl/str-two-way.h
index 707145d..dfe7022 100644
--- a/gl/str-two-way.h
+++ b/gl/str-two-way.h
@@ -1,24 +1,24 @@
1/* Byte-wise substring search, using the Two-Way algorithm. 1/* Byte-wise substring search, using the Two-Way algorithm.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Written by Eric Blake <ebb9@byu.net>, 2008. 4 Written by Eric Blake <ebb9@byu.net>, 2008.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU Lesser General Public License
17 with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* Before including this file, you need to include <config.h> and 19/* Before including this file, you need to include <config.h> and
20 <string.h>, and define: 20 <string.h>, and define:
21 RESULT_TYPE A macro that expands to the return type. 21 RETURN_TYPE A macro that expands to the return type.
22 AVAILABLE(h, h_l, j, n_l) 22 AVAILABLE(h, h_l, j, n_l)
23 A macro that returns nonzero if there are 23 A macro that returns nonzero if there are
24 at least N_L bytes left starting at H[J]. 24 at least N_L bytes left starting at H[J].
@@ -49,9 +49,9 @@
49 character shift table similar to the Boyer-Moore algorithm to 49 character shift table similar to the Boyer-Moore algorithm to
50 achieve improved (potentially sub-linear) performance. 50 achieve improved (potentially sub-linear) performance.
51 51
52 See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260, 52 See https://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260,
53 http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm, 53 https://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm,
54 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf 54 https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf
55*/ 55*/
56 56
57/* Point at which computing a bad-byte shift table is likely to be 57/* Point at which computing a bad-byte shift table is likely to be
@@ -231,7 +231,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
231 most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. 231 most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
232 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 232 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
233 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ 233 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */
234static RETURN_TYPE 234static RETURN_TYPE _GL_ATTRIBUTE_PURE
235two_way_short_needle (const unsigned char *haystack, size_t haystack_len, 235two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
236 const unsigned char *needle, size_t needle_len) 236 const unsigned char *needle, size_t needle_len)
237{ 237{
@@ -325,7 +325,7 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
325 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * 325 If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
326 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and 326 HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
327 sublinear performance is not possible. */ 327 sublinear performance is not possible. */
328static RETURN_TYPE 328static RETURN_TYPE _GL_ATTRIBUTE_PURE
329two_way_long_needle (const unsigned char *haystack, size_t haystack_len, 329two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
330 const unsigned char *needle, size_t needle_len) 330 const unsigned char *needle, size_t needle_len)
331{ 331{
diff --git a/gl/strcasecmp.c b/gl/strcasecmp.c
index 0f0a742..3a5ce3e 100644
--- a/gl/strcasecmp.c
+++ b/gl/strcasecmp.c
@@ -1,18 +1,18 @@
1/* Case-insensitive string comparison function. 1/* Case-insensitive string comparison function.
2 Copyright (C) 1998-1999, 2005-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
@@ -58,5 +58,5 @@ strcasecmp (const char *s1, const char *s2)
58 /* On machines where 'char' and 'int' are types of the same size, the 58 /* On machines where 'char' and 'int' are types of the same size, the
59 difference of two 'unsigned char' values - including the sign bit - 59 difference of two 'unsigned char' values - including the sign bit -
60 doesn't fit in an 'int'. */ 60 doesn't fit in an 'int'. */
61 return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); 61 return _GL_CMP (c1, c2);
62} 62}
diff --git a/gl/strcasestr.c b/gl/strcasestr.c
index 53474a4..8eea435 100644
--- a/gl/strcasestr.c
+++ b/gl/strcasestr.c
@@ -1,19 +1,19 @@
1/* Case-insensitive searching in a string. 1/* Case-insensitive searching in a string.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2005. 3 Written by Bruno Haible <bruno@clisp.org>, 2005.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -21,7 +21,6 @@
21#include <string.h> 21#include <string.h>
22 22
23#include <ctype.h> 23#include <ctype.h>
24#include <stdbool.h>
25#include <strings.h> 24#include <strings.h>
26 25
27#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) 26#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
diff --git a/gl/streq.h b/gl/streq.h
index 12c1867..712948e 100644
--- a/gl/streq.h
+++ b/gl/streq.h
@@ -1,18 +1,18 @@
1/* Optimized string comparison. 1/* Optimized string comparison.
2 Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 2001-2002, 2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This file is free software: you can redistribute it and/or modify
5 under the terms of the GNU General Public License as published 5 it under the terms of the GNU Lesser General Public License as
6 by the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>. */ 17/* Written by Bruno Haible <bruno@clisp.org>. */
18 18
@@ -29,7 +29,7 @@
29 29
30/* Help GCC to generate good code for string comparisons with 30/* Help GCC to generate good code for string comparisons with
31 immediate strings. */ 31 immediate strings. */
32#if defined (__GNUC__) && defined (__OPTIMIZE__) 32#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__
33 33
34static inline int 34static inline int
35streq9 (const char *s1, const char *s2) 35streq9 (const char *s1, const char *s2)
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
index d0ed2fb..cddaa4a 100644
--- a/gl/strerror-override.c
+++ b/gl/strerror-override.c
@@ -1,19 +1,19 @@
1/* strerror-override.c --- POSIX compatible system error routine 1/* strerror-override.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2010-2013 Free Software Foundation, Inc. 3 Copyright (C) 2010-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Bruno Haible <bruno@clisp.org>, 2010. */ 18/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
19 19
@@ -29,6 +29,8 @@
29# endif 29# endif
30#endif 30#endif
31 31
32#if !GNULIB_defined_strerror_override_macro
33
32/* If ERRNUM maps to an errno value defined by gnulib, return a string 34/* If ERRNUM maps to an errno value defined by gnulib, return a string
33 describing the error. Otherwise return NULL. */ 35 describing the error. Otherwise return NULL. */
34const char * 36const char *
@@ -37,12 +39,12 @@ strerror_override (int errnum)
37 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ 39 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
38 switch (errnum) 40 switch (errnum)
39 { 41 {
40#if REPLACE_STRERROR_0 42# if REPLACE_STRERROR_0
41 case 0: 43 case 0:
42 return "Success"; 44 return "Success";
43#endif 45# endif
44 46
45#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */ 47# if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
46 case EINPROGRESS: 48 case EINPROGRESS:
47 return "Operation now in progress"; 49 return "Operation now in progress";
48 case EALREADY: 50 case EALREADY:
@@ -89,8 +91,8 @@ strerror_override (int errnum)
89 return "No route to host"; 91 return "No route to host";
90 case EWOULDBLOCK: 92 case EWOULDBLOCK:
91 return "Operation would block"; 93 return "Operation would block";
92#endif 94# endif
93#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */ 95# if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
94 case ETXTBSY: 96 case ETXTBSY:
95 return "Text file busy"; 97 return "Text file busy";
96 case ENODATA: 98 case ENODATA:
@@ -103,8 +105,8 @@ strerror_override (int errnum)
103 return "Timer expired"; 105 return "Timer expired";
104 case EOTHER: 106 case EOTHER:
105 return "Other error"; 107 return "Other error";
106#endif 108# endif
107#if GNULIB_defined_EWINSOCK /* native Windows platforms */ 109# if GNULIB_defined_EWINSOCK /* native Windows platforms */
108 case ESOCKTNOSUPPORT: 110 case ESOCKTNOSUPPORT:
109 return "Socket type not supported"; 111 return "Socket type not supported";
110 case EPFNOSUPPORT: 112 case EPFNOSUPPORT:
@@ -125,7 +127,7 @@ strerror_override (int errnum)
125 return "Stale NFS file handle"; 127 return "Stale NFS file handle";
126 case EREMOTE: 128 case EREMOTE:
127 return "Object is remote"; 129 return "Object is remote";
128# if HAVE_WINSOCK2_H 130# if HAVE_WINSOCK2_H
129 /* WSA_INVALID_HANDLE maps to EBADF */ 131 /* WSA_INVALID_HANDLE maps to EBADF */
130 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */ 132 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
131 /* WSA_INVALID_PARAMETER maps to EINVAL */ 133 /* WSA_INVALID_PARAMETER maps to EINVAL */
@@ -213,90 +215,92 @@ strerror_override (int errnum)
213 case WSANO_DATA: 215 case WSANO_DATA:
214 return "Valid name, no data record of requested type"; 216 return "Valid name, no data record of requested type";
215 /* WSA_QOS_* omitted */ 217 /* WSA_QOS_* omitted */
218# endif
216# endif 219# endif
217#endif
218 220
219#if GNULIB_defined_ENOMSG 221# if GNULIB_defined_ENOMSG
220 case ENOMSG: 222 case ENOMSG:
221 return "No message of desired type"; 223 return "No message of desired type";
222#endif 224# endif
223 225
224#if GNULIB_defined_EIDRM 226# if GNULIB_defined_EIDRM
225 case EIDRM: 227 case EIDRM:
226 return "Identifier removed"; 228 return "Identifier removed";
227#endif 229# endif
228 230
229#if GNULIB_defined_ENOLINK 231# if GNULIB_defined_ENOLINK
230 case ENOLINK: 232 case ENOLINK:
231 return "Link has been severed"; 233 return "Link has been severed";
232#endif 234# endif
233 235
234#if GNULIB_defined_EPROTO 236# if GNULIB_defined_EPROTO
235 case EPROTO: 237 case EPROTO:
236 return "Protocol error"; 238 return "Protocol error";
237#endif 239# endif
238 240
239#if GNULIB_defined_EMULTIHOP 241# if GNULIB_defined_EMULTIHOP
240 case EMULTIHOP: 242 case EMULTIHOP:
241 return "Multihop attempted"; 243 return "Multihop attempted";
242#endif 244# endif
243 245
244#if GNULIB_defined_EBADMSG 246# if GNULIB_defined_EBADMSG
245 case EBADMSG: 247 case EBADMSG:
246 return "Bad message"; 248 return "Bad message";
247#endif 249# endif
248 250
249#if GNULIB_defined_EOVERFLOW 251# if GNULIB_defined_EOVERFLOW
250 case EOVERFLOW: 252 case EOVERFLOW:
251 return "Value too large for defined data type"; 253 return "Value too large for defined data type";
252#endif 254# endif
253 255
254#if GNULIB_defined_ENOTSUP 256# if GNULIB_defined_ENOTSUP
255 case ENOTSUP: 257 case ENOTSUP:
256 return "Not supported"; 258 return "Not supported";
257#endif 259# endif
258 260
259#if GNULIB_defined_ENETRESET 261# if GNULIB_defined_ENETRESET
260 case ENETRESET: 262 case ENETRESET:
261 return "Network dropped connection on reset"; 263 return "Network dropped connection on reset";
262#endif 264# endif
263 265
264#if GNULIB_defined_ECONNABORTED 266# if GNULIB_defined_ECONNABORTED
265 case ECONNABORTED: 267 case ECONNABORTED:
266 return "Software caused connection abort"; 268 return "Software caused connection abort";
267#endif 269# endif
268 270
269#if GNULIB_defined_ESTALE 271# if GNULIB_defined_ESTALE
270 case ESTALE: 272 case ESTALE:
271 return "Stale NFS file handle"; 273 return "Stale NFS file handle";
272#endif 274# endif
273 275
274#if GNULIB_defined_EDQUOT 276# if GNULIB_defined_EDQUOT
275 case EDQUOT: 277 case EDQUOT:
276 return "Disk quota exceeded"; 278 return "Disk quota exceeded";
277#endif 279# endif
278 280
279#if GNULIB_defined_ECANCELED 281# if GNULIB_defined_ECANCELED
280 case ECANCELED: 282 case ECANCELED:
281 return "Operation canceled"; 283 return "Operation canceled";
282#endif 284# endif
283 285
284#if GNULIB_defined_EOWNERDEAD 286# if GNULIB_defined_EOWNERDEAD
285 case EOWNERDEAD: 287 case EOWNERDEAD:
286 return "Owner died"; 288 return "Owner died";
287#endif 289# endif
288 290
289#if GNULIB_defined_ENOTRECOVERABLE 291# if GNULIB_defined_ENOTRECOVERABLE
290 case ENOTRECOVERABLE: 292 case ENOTRECOVERABLE:
291 return "State not recoverable"; 293 return "State not recoverable";
292#endif 294# endif
293 295
294#if GNULIB_defined_EILSEQ 296# if GNULIB_defined_EILSEQ
295 case EILSEQ: 297 case EILSEQ:
296 return "Invalid or incomplete multibyte or wide character"; 298 return "Invalid or incomplete multibyte or wide character";
297#endif 299# endif
298 300
299 default: 301 default:
300 return NULL; 302 return NULL;
301 } 303 }
302} 304}
305
306#endif
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
index 3b8f24b..388cc28 100644
--- a/gl/strerror-override.h
+++ b/gl/strerror-override.h
@@ -1,19 +1,19 @@
1/* strerror-override.h --- POSIX compatible system error routine 1/* strerror-override.h --- POSIX compatible system error routine
2 2
3 Copyright (C) 2010-2013 Free Software Foundation, Inc. 3 Copyright (C) 2010-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _GL_STRERROR_OVERRIDE_H 18#ifndef _GL_STRERROR_OVERRIDE_H
19# define _GL_STRERROR_OVERRIDE_H 19# define _GL_STRERROR_OVERRIDE_H
@@ -48,9 +48,10 @@
48 || GNULIB_defined_EOWNERDEAD \ 48 || GNULIB_defined_EOWNERDEAD \
49 || GNULIB_defined_ENOTRECOVERABLE \ 49 || GNULIB_defined_ENOTRECOVERABLE \
50 || GNULIB_defined_EILSEQ 50 || GNULIB_defined_EILSEQ
51extern const char *strerror_override (int errnum); 51extern const char *strerror_override (int errnum) _GL_ATTRIBUTE_CONST;
52# else 52# else
53# define strerror_override(ignored) NULL 53# define strerror_override(ignored) NULL
54# define GNULIB_defined_strerror_override_macro 1
54# endif 55# endif
55 56
56#endif /* _GL_STRERROR_OVERRIDE_H */ 57#endif /* _GL_STRERROR_OVERRIDE_H */
diff --git a/gl/strerror.c b/gl/strerror.c
index 80a2f2e..d754f60 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -1,19 +1,19 @@
1/* strerror.c --- POSIX compatible system error routine 1/* strerror.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -27,7 +27,6 @@
27 27
28#include "intprops.h" 28#include "intprops.h"
29#include "strerror-override.h" 29#include "strerror-override.h"
30#include "verify.h"
31 30
32/* Use the system functions, not the gnulib overrides in this file. */ 31/* Use the system functions, not the gnulib overrides in this file. */
33#undef sprintf 32#undef sprintf
@@ -55,7 +54,7 @@ strerror (int n)
55 if (!msg || !*msg) 54 if (!msg || !*msg)
56 { 55 {
57 static char const fmt[] = "Unknown error %d"; 56 static char const fmt[] = "Unknown error %d";
58 verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); 57 static_assert (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n));
59 sprintf (buf, fmt, n); 58 sprintf (buf, fmt, n);
60 errno = EINVAL; 59 errno = EINVAL;
61 return buf; 60 return buf;
@@ -66,5 +65,6 @@ strerror (int n)
66 if (sizeof buf <= len) 65 if (sizeof buf <= len)
67 abort (); 66 abort ();
68 67
69 return memcpy (buf, msg, len + 1); 68 memcpy (buf, msg, len + 1);
69 return buf;
70} 70}
diff --git a/gl/string.in.h b/gl/string.in.h
index d7a6c9c..e993b2f 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,30 +1,46 @@
1/* A GNU-like <string.h>. 1/* A GNU-like <string.h>.
2 2
3 Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _@GUARD_PREFIX@_STRING_H
19 17
20#if __GNUC__ >= 3 18#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
22#endif 20#endif
23@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
24 22
23#if defined _GL_ALREADY_INCLUDING_STRING_H
24/* Special invocation convention:
25 - On OS X/NetBSD we have a sequence of nested includes
26 <string.h> -> <strings.h> -> "string.h"
27 In this situation system _chk variants due to -D_FORTIFY_SOURCE
28 might be used after any replacements defined here. */
29
30#@INCLUDE_NEXT@ @NEXT_STRING_H@
31
32#else
33/* Normal invocation convention. */
34
35#ifndef _@GUARD_PREFIX@_STRING_H
36
37#define _GL_ALREADY_INCLUDING_STRING_H
38
25/* The include_next requires a split double-inclusion guard. */ 39/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_STRING_H@ 40#@INCLUDE_NEXT@ @NEXT_STRING_H@
27 41
42#undef _GL_ALREADY_INCLUDING_STRING_H
43
28#ifndef _@GUARD_PREFIX@_STRING_H 44#ifndef _@GUARD_PREFIX@_STRING_H
29#define _@GUARD_PREFIX@_STRING_H 45#define _@GUARD_PREFIX@_STRING_H
30 46
@@ -36,14 +52,6 @@
36# include <wchar.h> 52# include <wchar.h>
37#endif 53#endif
38 54
39/* The __attribute__ feature is available in gcc versions 2.5 and later.
40 The attribute __pure__ was added in gcc 2.96. */
41#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
42# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
43#else
44# define _GL_ATTRIBUTE_PURE /* empty */
45#endif
46
47/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ 55/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
48/* But in any case avoid namespace pollution on glibc systems. */ 56/* But in any case avoid namespace pollution on glibc systems. */
49#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ 57#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
@@ -51,12 +59,122 @@
51# include <unistd.h> 59# include <unistd.h>
52#endif 60#endif
53 61
62/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */
63/* But in any case avoid namespace pollution on glibc systems. */
64#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
65 && defined _AIX) \
66 && ! defined __GLIBC__
67# include <strings.h>
68#endif
69
70/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
71 that can be freed by passing them as the Ith argument to the
72 function F. */
73#ifndef _GL_ATTRIBUTE_DEALLOC
74# if __GNUC__ >= 11
75# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
76# else
77# define _GL_ATTRIBUTE_DEALLOC(f, i)
78# endif
79#endif
80
81/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
82 can be freed via 'free'; it can be used only after declaring 'free'. */
83/* Applies to: functions. Cannot be used on inline functions. */
84#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
85# if defined __cplusplus && defined __GNUC__ && !defined __clang__
86/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
87# define _GL_ATTRIBUTE_DEALLOC_FREE \
88 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
89# else
90# define _GL_ATTRIBUTE_DEALLOC_FREE \
91 _GL_ATTRIBUTE_DEALLOC (free, 1)
92# endif
93#endif
94
95/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
96 allocated memory. */
97/* Applies to: functions. */
98#ifndef _GL_ATTRIBUTE_MALLOC
99# if __GNUC__ >= 3 || defined __clang__
100# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
101# else
102# define _GL_ATTRIBUTE_MALLOC
103# endif
104#endif
105
106/* The __attribute__ feature is available in gcc versions 2.5 and later.
107 The attribute __pure__ was added in gcc 2.96. */
108#ifndef _GL_ATTRIBUTE_PURE
109# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
110# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
111# else
112# define _GL_ATTRIBUTE_PURE /* empty */
113# endif
114#endif
115
54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 116/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 117
56/* The definition of _GL_ARG_NONNULL is copied here. */ 118/* The definition of _GL_ARG_NONNULL is copied here. */
57 119
58/* The definition of _GL_WARN_ON_USE is copied here. */ 120/* The definition of _GL_WARN_ON_USE is copied here. */
59 121
122/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
123 been included yet. */
124#if @GNULIB_FREE_POSIX@
125# if (@REPLACE_FREE@ && !defined free \
126 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
127/* We can't do '#define free rpl_free' here. */
128_GL_EXTERN_C void rpl_free (void *);
129# undef _GL_ATTRIBUTE_DEALLOC_FREE
130# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
131# else
132# if defined _MSC_VER && !defined free
133_GL_EXTERN_C
134# if defined _DLL
135 __declspec (dllimport)
136# endif
137 void __cdecl free (void *);
138# else
139# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
140_GL_EXTERN_C void free (void *) throw ();
141# else
142_GL_EXTERN_C void free (void *);
143# endif
144# endif
145# endif
146#else
147# if defined _MSC_VER && !defined free
148_GL_EXTERN_C
149# if defined _DLL
150 __declspec (dllimport)
151# endif
152 void __cdecl free (void *);
153# else
154# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
155_GL_EXTERN_C void free (void *) throw ();
156# else
157_GL_EXTERN_C void free (void *);
158# endif
159# endif
160#endif
161
162/* Clear a block of memory. The compiler will not delete a call to
163 this function, even if the block is dead after the call. */
164#if @GNULIB_EXPLICIT_BZERO@
165# if ! @HAVE_EXPLICIT_BZERO@
166_GL_FUNCDECL_SYS (explicit_bzero, void,
167 (void *__dest, size_t __n) _GL_ARG_NONNULL ((1)));
168# endif
169_GL_CXXALIAS_SYS (explicit_bzero, void, (void *__dest, size_t __n));
170_GL_CXXALIASWARN (explicit_bzero);
171#elif defined GNULIB_POSIXCHECK
172# undef explicit_bzero
173# if HAVE_RAW_DECL_EXPLICIT_BZERO
174_GL_WARN_ON_USE (explicit_bzero, "explicit_bzero is unportable - "
175 "use gnulib module explicit_bzero for portability");
176# endif
177#endif
60 178
61/* Find the index of the least-significant set bit. */ 179/* Find the index of the least-significant set bit. */
62#if @GNULIB_FFSL@ 180#if @GNULIB_FFSL@
@@ -75,10 +193,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
75 193
76/* Find the index of the least-significant set bit. */ 194/* Find the index of the least-significant set bit. */
77#if @GNULIB_FFSLL@ 195#if @GNULIB_FFSLL@
78# if !@HAVE_FFSLL@ 196# if @REPLACE_FFSLL@
197# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
198# define ffsll rpl_ffsll
199# endif
200_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
201_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
202# else
203# if !@HAVE_FFSLL@
79_GL_FUNCDECL_SYS (ffsll, int, (long long int i)); 204_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
80# endif 205# endif
81_GL_CXXALIAS_SYS (ffsll, int, (long long int i)); 206_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
207# endif
82_GL_CXXALIASWARN (ffsll); 208_GL_CXXALIASWARN (ffsll);
83#elif defined GNULIB_POSIXCHECK 209#elif defined GNULIB_POSIXCHECK
84# undef ffsll 210# undef ffsll
@@ -88,10 +214,30 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
88#endif 214#endif
89 215
90 216
217#if @GNULIB_MDA_MEMCCPY@
218/* On native Windows, map 'memccpy' to '_memccpy', so that -loldnames is not
219 required. In C++ with GNULIB_NAMESPACE, avoid differences between
220 platforms by defining GNULIB_NAMESPACE::memccpy always. */
221# if defined _WIN32 && !defined __CYGWIN__
222# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
223# undef memccpy
224# define memccpy _memccpy
225# endif
226_GL_CXXALIAS_MDA (memccpy, void *,
227 (void *dest, const void *src, int c, size_t n));
228# else
229_GL_CXXALIAS_SYS (memccpy, void *,
230 (void *dest, const void *src, int c, size_t n));
231# endif
232_GL_CXXALIASWARN (memccpy);
233#endif
234
235
91/* Return the first instance of C within N bytes of S, or NULL. */ 236/* Return the first instance of C within N bytes of S, or NULL. */
92#if @GNULIB_MEMCHR@ 237#if @GNULIB_MEMCHR@
93# if @REPLACE_MEMCHR@ 238# if @REPLACE_MEMCHR@
94# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 239# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
240# undef memchr
95# define memchr rpl_memchr 241# define memchr rpl_memchr
96# endif 242# endif
97_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) 243_GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
@@ -99,11 +245,6 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
99 _GL_ARG_NONNULL ((1))); 245 _GL_ARG_NONNULL ((1)));
100_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); 246_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
101# else 247# else
102# if ! @HAVE_MEMCHR@
103_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
104 _GL_ATTRIBUTE_PURE
105 _GL_ARG_NONNULL ((1)));
106# endif
107 /* On some systems, this function is defined as an overloaded function: 248 /* On some systems, this function is defined as an overloaded function:
108 extern "C" { const void * std::memchr (const void *, int, size_t); } 249 extern "C" { const void * std::memchr (const void *, int, size_t); }
109 extern "C++" { void * std::memchr (void *, int, size_t); } */ 250 extern "C++" { void * std::memchr (void *, int, size_t); } */
@@ -112,11 +253,12 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
112 void const *, (void const *__s, int __c, size_t __n)); 253 void const *, (void const *__s, int __c, size_t __n));
113# endif 254# endif
114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 255# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 256 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
116_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 257 || defined __clang__)
258_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n) throw ());
117_GL_CXXALIASWARN1 (memchr, void const *, 259_GL_CXXALIASWARN1 (memchr, void const *,
118 (void const *__s, int __c, size_t __n)); 260 (void const *__s, int __c, size_t __n) throw ());
119# else 261# elif __GLIBC__ >= 2
120_GL_CXXALIASWARN (memchr); 262_GL_CXXALIASWARN (memchr);
121# endif 263# endif
122#elif defined GNULIB_POSIXCHECK 264#elif defined GNULIB_POSIXCHECK
@@ -197,9 +339,10 @@ _GL_CXXALIAS_SYS_CAST2 (memrchr,
197 void *, (void const *, int, size_t), 339 void *, (void const *, int, size_t),
198 void const *, (void const *, int, size_t)); 340 void const *, (void const *, int, size_t));
199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 341# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 342 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 343 || defined __clang__)
202_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 344_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t) throw ());
345_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t) throw ());
203# else 346# else
204_GL_CXXALIASWARN (memrchr); 347_GL_CXXALIASWARN (memrchr);
205# endif 348# endif
@@ -211,6 +354,23 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
211# endif 354# endif
212#endif 355#endif
213 356
357/* Overwrite a block of memory. The compiler will not optimize
358 effects away, even if the block is dead after the call. */
359#if @GNULIB_MEMSET_EXPLICIT@
360# if ! @HAVE_MEMSET_EXPLICIT@
361_GL_FUNCDECL_SYS (memset_explicit, void *,
362 (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1)));
363# endif
364_GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
365_GL_CXXALIASWARN (memset_explicit);
366#elif defined GNULIB_POSIXCHECK
367# undef memset_explicit
368# if HAVE_RAW_DECL_MEMSET_EXPLICIT
369_GL_WARN_ON_USE (memset_explicit, "memset_explicit is unportable - "
370 "use gnulib module memset_explicit for portability");
371# endif
372#endif
373
214/* Find the first occurrence of C in S. More efficient than 374/* Find the first occurrence of C in S. More efficient than
215 memchr(S,C,N), at the expense of undefined behavior if C does not 375 memchr(S,C,N), at the expense of undefined behavior if C does not
216 occur within N bytes. */ 376 occur within N bytes. */
@@ -227,9 +387,11 @@ _GL_CXXALIAS_SYS_CAST2 (rawmemchr,
227 void *, (void const *__s, int __c_in), 387 void *, (void const *__s, int __c_in),
228 void const *, (void const *__s, int __c_in)); 388 void const *, (void const *__s, int __c_in));
229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 389# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 390 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 391 || defined __clang__)
232_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 392_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in) throw ());
393_GL_CXXALIASWARN1 (rawmemchr, void const *,
394 (void const *__s, int __c_in) throw ());
233# else 395# else
234_GL_CXXALIASWARN (rawmemchr); 396_GL_CXXALIASWARN (rawmemchr);
235# endif 397# endif
@@ -299,9 +461,11 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
299 GB18030 and the character to be searched is a digit. */ 461 GB18030 and the character to be searched is a digit. */
300# undef strchr 462# undef strchr
301/* Assume strchr is always declared. */ 463/* Assume strchr is always declared. */
302_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " 464_GL_WARN_ON_USE_CXX (strchr,
303 "in some multibyte locales - " 465 const char *, char *, (const char *, int),
304 "use mbschr if you care about internationalization"); 466 "strchr cannot work correctly on character strings "
467 "in some multibyte locales - "
468 "use mbschr if you care about internationalization");
305#endif 469#endif
306 470
307/* Find the first occurrence of C in S or the final NUL byte. */ 471/* Find the first occurrence of C in S or the final NUL byte. */
@@ -329,9 +493,11 @@ _GL_CXXALIAS_SYS_CAST2 (strchrnul,
329 char const *, (char const *__s, int __c_in)); 493 char const *, (char const *__s, int __c_in));
330# endif 494# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 495# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 496 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 497 || defined __clang__)
334_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 498_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in) throw ());
499_GL_CXXALIASWARN1 (strchrnul, char const *,
500 (char const *__s, int __c_in) throw ());
335# else 501# else
336_GL_CXXALIASWARN (strchrnul); 502_GL_CXXALIASWARN (strchrnul);
337# endif 503# endif
@@ -350,24 +516,62 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
350# undef strdup 516# undef strdup
351# define strdup rpl_strdup 517# define strdup rpl_strdup
352# endif 518# endif
353_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 519_GL_FUNCDECL_RPL (strdup, char *,
520 (char const *__s)
521 _GL_ARG_NONNULL ((1))
522 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 523_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
524# elif defined _WIN32 && !defined __CYGWIN__
525# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
526# undef strdup
527# define strdup _strdup
528# endif
529_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
355# else 530# else
356# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup 531# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
357 /* strdup exists as a function and as a macro. Get rid of the macro. */ 532 /* strdup exists as a function and as a macro. Get rid of the macro. */
358# undef strdup 533# undef strdup
359# endif 534# endif
360# if !(@HAVE_DECL_STRDUP@ || defined strdup) 535# if (!@HAVE_DECL_STRDUP@ || __GNUC__ >= 11) && !defined strdup
361_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 536_GL_FUNCDECL_SYS (strdup, char *,
537 (char const *__s)
538 _GL_ARG_NONNULL ((1))
539 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
362# endif 540# endif
363_GL_CXXALIAS_SYS (strdup, char *, (char const *__s)); 541_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
364# endif 542# endif
365_GL_CXXALIASWARN (strdup); 543_GL_CXXALIASWARN (strdup);
366#elif defined GNULIB_POSIXCHECK 544#else
367# undef strdup 545# if __GNUC__ >= 11 && !defined strdup
368# if HAVE_RAW_DECL_STRDUP 546/* For -Wmismatched-dealloc: Associate strdup with free or rpl_free. */
547_GL_FUNCDECL_SYS (strdup, char *,
548 (char const *__s)
549 _GL_ARG_NONNULL ((1))
550 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
551# endif
552# if defined GNULIB_POSIXCHECK
553# undef strdup
554# if HAVE_RAW_DECL_STRDUP
369_GL_WARN_ON_USE (strdup, "strdup is unportable - " 555_GL_WARN_ON_USE (strdup, "strdup is unportable - "
370 "use gnulib module strdup for portability"); 556 "use gnulib module strdup for portability");
557# endif
558# elif @GNULIB_MDA_STRDUP@
559/* On native Windows, map 'creat' to '_creat', so that -loldnames is not
560 required. In C++ with GNULIB_NAMESPACE, avoid differences between
561 platforms by defining GNULIB_NAMESPACE::strdup always. */
562# if defined _WIN32 && !defined __CYGWIN__
563# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
564# undef strdup
565# define strdup _strdup
566# endif
567_GL_CXXALIAS_MDA (strdup, char *, (char const *__s));
568# else
569# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
570# undef strdup
571# endif
572_GL_CXXALIAS_SYS (strdup, char *, (char const *__s));
573# endif
574_GL_CXXALIASWARN (strdup);
371# endif 575# endif
372#endif 576#endif
373 577
@@ -378,13 +582,18 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
378# undef strncat 582# undef strncat
379# define strncat rpl_strncat 583# define strncat rpl_strncat
380# endif 584# endif
381_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) 585_GL_FUNCDECL_RPL (strncat, char *,
382 _GL_ARG_NONNULL ((1, 2))); 586 (char *restrict dest, const char *restrict src, size_t n)
383_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); 587 _GL_ARG_NONNULL ((1, 2)));
588_GL_CXXALIAS_RPL (strncat, char *,
589 (char *restrict dest, const char *restrict src, size_t n));
384# else 590# else
385_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); 591_GL_CXXALIAS_SYS (strncat, char *,
592 (char *restrict dest, const char *restrict src, size_t n));
386# endif 593# endif
594# if __GLIBC__ >= 2
387_GL_CXXALIASWARN (strncat); 595_GL_CXXALIASWARN (strncat);
596# endif
388#elif defined GNULIB_POSIXCHECK 597#elif defined GNULIB_POSIXCHECK
389# undef strncat 598# undef strncat
390# if HAVE_RAW_DECL_STRNCAT 599# if HAVE_RAW_DECL_STRNCAT
@@ -400,22 +609,35 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
400# undef strndup 609# undef strndup
401# define strndup rpl_strndup 610# define strndup rpl_strndup
402# endif 611# endif
403_GL_FUNCDECL_RPL (strndup, char *, (char const *__string, size_t __n) 612_GL_FUNCDECL_RPL (strndup, char *,
404 _GL_ARG_NONNULL ((1))); 613 (char const *__s, size_t __n)
405_GL_CXXALIAS_RPL (strndup, char *, (char const *__string, size_t __n)); 614 _GL_ARG_NONNULL ((1))
615 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
616_GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
406# else 617# else
407# if ! @HAVE_DECL_STRNDUP@ 618# if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
408_GL_FUNCDECL_SYS (strndup, char *, (char const *__string, size_t __n) 619_GL_FUNCDECL_SYS (strndup, char *,
409 _GL_ARG_NONNULL ((1))); 620 (char const *__s, size_t __n)
621 _GL_ARG_NONNULL ((1))
622 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
410# endif 623# endif
411_GL_CXXALIAS_SYS (strndup, char *, (char const *__string, size_t __n)); 624_GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
412# endif 625# endif
413_GL_CXXALIASWARN (strndup); 626_GL_CXXALIASWARN (strndup);
414#elif defined GNULIB_POSIXCHECK 627#else
415# undef strndup 628# if __GNUC__ >= 11 && !defined strndup
416# if HAVE_RAW_DECL_STRNDUP 629/* For -Wmismatched-dealloc: Associate strndup with free or rpl_free. */
630_GL_FUNCDECL_SYS (strndup, char *,
631 (char const *__s, size_t __n)
632 _GL_ARG_NONNULL ((1))
633 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
634# endif
635# if defined GNULIB_POSIXCHECK
636# undef strndup
637# if HAVE_RAW_DECL_STRNDUP
417_GL_WARN_ON_USE (strndup, "strndup is unportable - " 638_GL_WARN_ON_USE (strndup, "strndup is unportable - "
418 "use gnulib module strndup for portability"); 639 "use gnulib module strndup for portability");
640# endif
419# endif 641# endif
420#endif 642#endif
421 643
@@ -428,17 +650,17 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
428# undef strnlen 650# undef strnlen
429# define strnlen rpl_strnlen 651# define strnlen rpl_strnlen
430# endif 652# endif
431_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) 653_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)
432 _GL_ATTRIBUTE_PURE 654 _GL_ATTRIBUTE_PURE
433 _GL_ARG_NONNULL ((1))); 655 _GL_ARG_NONNULL ((1)));
434_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); 656_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen));
435# else 657# else
436# if ! @HAVE_DECL_STRNLEN@ 658# if ! @HAVE_DECL_STRNLEN@
437_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) 659_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)
438 _GL_ATTRIBUTE_PURE 660 _GL_ATTRIBUTE_PURE
439 _GL_ARG_NONNULL ((1))); 661 _GL_ARG_NONNULL ((1)));
440# endif 662# endif
441_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); 663_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen));
442# endif 664# endif
443_GL_CXXALIASWARN (strnlen); 665_GL_CXXALIASWARN (strnlen);
444#elif defined GNULIB_POSIXCHECK 666#elif defined GNULIB_POSIXCHECK
@@ -475,11 +697,12 @@ _GL_CXXALIAS_SYS_CAST2 (strpbrk,
475 char *, (char const *__s, char const *__accept), 697 char *, (char const *__s, char const *__accept),
476 const char *, (char const *__s, char const *__accept)); 698 const char *, (char const *__s, char const *__accept));
477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 699# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 700 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 701 || defined __clang__)
702_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept) throw ());
480_GL_CXXALIASWARN1 (strpbrk, char const *, 703_GL_CXXALIASWARN1 (strpbrk, char const *,
481 (char const *__s, char const *__accept)); 704 (char const *__s, char const *__accept) throw ());
482# else 705# elif __GLIBC__ >= 2
483_GL_CXXALIASWARN (strpbrk); 706_GL_CXXALIASWARN (strpbrk);
484# endif 707# endif
485# if defined GNULIB_POSIXCHECK 708# if defined GNULIB_POSIXCHECK
@@ -488,15 +711,19 @@ _GL_CXXALIASWARN (strpbrk);
488 locale encoding is GB18030 and one of the characters to be searched is a 711 locale encoding is GB18030 and one of the characters to be searched is a
489 digit. */ 712 digit. */
490# undef strpbrk 713# undef strpbrk
491_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings " 714_GL_WARN_ON_USE_CXX (strpbrk,
492 "in multibyte locales - " 715 const char *, char *, (const char *, const char *),
493 "use mbspbrk if you care about internationalization"); 716 "strpbrk cannot work correctly on character strings "
717 "in multibyte locales - "
718 "use mbspbrk if you care about internationalization");
494# endif 719# endif
495#elif defined GNULIB_POSIXCHECK 720#elif defined GNULIB_POSIXCHECK
496# undef strpbrk 721# undef strpbrk
497# if HAVE_RAW_DECL_STRPBRK 722# if HAVE_RAW_DECL_STRPBRK
498_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - " 723_GL_WARN_ON_USE_CXX (strpbrk,
499 "use gnulib module strpbrk for portability"); 724 const char *, char *, (const char *, const char *),
725 "strpbrk is unportable - "
726 "use gnulib module strpbrk for portability");
500# endif 727# endif
501#endif 728#endif
502 729
@@ -515,9 +742,11 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
515 GB18030 and the character to be searched is a digit. */ 742 GB18030 and the character to be searched is a digit. */
516# undef strrchr 743# undef strrchr
517/* Assume strrchr is always declared. */ 744/* Assume strrchr is always declared. */
518_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings " 745_GL_WARN_ON_USE_CXX (strrchr,
519 "in some multibyte locales - " 746 const char *, char *, (const char *, int),
520 "use mbsrchr if you care about internationalization"); 747 "strrchr cannot work correctly on character strings "
748 "in some multibyte locales - "
749 "use mbsrchr if you care about internationalization");
521#endif 750#endif
522 751
523/* Search the next delimiter (char listed in DELIM) starting at *STRINGP. 752/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
@@ -577,11 +806,13 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
577 const char *, (const char *haystack, const char *needle)); 806 const char *, (const char *haystack, const char *needle));
578# endif 807# endif
579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 808# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 809 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 810 || defined __clang__)
811_GL_CXXALIASWARN1 (strstr, char *,
812 (char *haystack, const char *needle) throw ());
582_GL_CXXALIASWARN1 (strstr, const char *, 813_GL_CXXALIASWARN1 (strstr, const char *,
583 (const char *haystack, const char *needle)); 814 (const char *haystack, const char *needle) throw ());
584# else 815# elif __GLIBC__ >= 2
585_GL_CXXALIASWARN (strstr); 816_GL_CXXALIASWARN (strstr);
586# endif 817# endif
587#elif defined GNULIB_POSIXCHECK 818#elif defined GNULIB_POSIXCHECK
@@ -626,10 +857,12 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
626 const char *, (const char *haystack, const char *needle)); 857 const char *, (const char *haystack, const char *needle));
627# endif 858# endif
628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 859# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 860 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) \
630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 861 || defined __clang__)
862_GL_CXXALIASWARN1 (strcasestr, char *,
863 (char *haystack, const char *needle) throw ());
631_GL_CXXALIASWARN1 (strcasestr, const char *, 864_GL_CXXALIASWARN1 (strcasestr, const char *,
632 (const char *haystack, const char *needle)); 865 (const char *haystack, const char *needle) throw ());
633# else 866# else
634_GL_CXXALIASWARN (strcasestr); 867_GL_CXXALIASWARN (strcasestr);
635# endif 868# endif
@@ -660,7 +893,7 @@ _GL_WARN_ON_USE (strcasestr, "strcasestr does work correctly on character "
660 This is a variant of strtok() that is multithread-safe. 893 This is a variant of strtok() that is multithread-safe.
661 894
662 For the POSIX documentation for this function, see: 895 For the POSIX documentation for this function, see:
663 http://www.opengroup.org/susv3xsh/strtok.html 896 https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtok.html
664 897
665 Caveat: It modifies the original string. 898 Caveat: It modifies the original string.
666 Caveat: These functions cannot be used on constant strings. 899 Caveat: These functions cannot be used on constant strings.
@@ -734,7 +967,9 @@ _GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
734 _GL_ARG_NONNULL ((1))); 967 _GL_ARG_NONNULL ((1)));
735_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 968_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
736# endif 969# endif
970# if __GLIBC__ >= 2
737_GL_CXXALIASWARN (mbslen); 971_GL_CXXALIASWARN (mbslen);
972# endif
738#endif 973#endif
739 974
740#if @GNULIB_MBSNLEN@ 975#if @GNULIB_MBSNLEN@
@@ -931,7 +1166,8 @@ _GL_EXTERN_C char * mbssep (char **stringp, const char *delim)
931 Caveat: The identity of the delimiting character is lost. 1166 Caveat: The identity of the delimiting character is lost.
932 1167
933 See also mbssep(). */ 1168 See also mbssep(). */
934_GL_EXTERN_C char * mbstok_r (char *string, const char *delim, char **save_ptr) 1169_GL_EXTERN_C char * mbstok_r (char *restrict string, const char *delim,
1170 char **save_ptr)
935 _GL_ARG_NONNULL ((2, 3)); 1171 _GL_ARG_NONNULL ((2, 3));
936#endif 1172#endif
937 1173
@@ -947,7 +1183,9 @@ _GL_CXXALIAS_RPL (strerror, char *, (int));
947# else 1183# else
948_GL_CXXALIAS_SYS (strerror, char *, (int)); 1184_GL_CXXALIAS_SYS (strerror, char *, (int));
949# endif 1185# endif
1186# if __GLIBC__ >= 2
950_GL_CXXALIASWARN (strerror); 1187_GL_CXXALIASWARN (strerror);
1188# endif
951#elif defined GNULIB_POSIXCHECK 1189#elif defined GNULIB_POSIXCHECK
952# undef strerror 1190# undef strerror
953/* Assume strerror is always declared. */ 1191/* Assume strerror is always declared. */
@@ -984,6 +1222,60 @@ _GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
984# endif 1222# endif
985#endif 1223#endif
986 1224
1225/* Return the name of the system error code ERRNUM. */
1226#if @GNULIB_STRERRORNAME_NP@
1227# if @REPLACE_STRERRORNAME_NP@
1228# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1229# undef strerrorname_np
1230# define strerrorname_np rpl_strerrorname_np
1231# endif
1232_GL_FUNCDECL_RPL (strerrorname_np, const char *, (int errnum));
1233_GL_CXXALIAS_RPL (strerrorname_np, const char *, (int errnum));
1234# else
1235# if !@HAVE_STRERRORNAME_NP@
1236_GL_FUNCDECL_SYS (strerrorname_np, const char *, (int errnum));
1237# endif
1238_GL_CXXALIAS_SYS (strerrorname_np, const char *, (int errnum));
1239# endif
1240_GL_CXXALIASWARN (strerrorname_np);
1241#elif defined GNULIB_POSIXCHECK
1242# undef strerrorname_np
1243# if HAVE_RAW_DECL_STRERRORNAME_NP
1244_GL_WARN_ON_USE (strerrorname_np, "strerrorname_np is unportable - "
1245 "use gnulib module strerrorname_np for portability");
1246# endif
1247#endif
1248
1249/* Return an abbreviation string for the signal number SIG. */
1250#if @GNULIB_SIGABBREV_NP@
1251# if ! @HAVE_SIGABBREV_NP@
1252_GL_FUNCDECL_SYS (sigabbrev_np, const char *, (int sig));
1253# endif
1254_GL_CXXALIAS_SYS (sigabbrev_np, const char *, (int sig));
1255_GL_CXXALIASWARN (sigabbrev_np);
1256#elif defined GNULIB_POSIXCHECK
1257# undef sigabbrev_np
1258# if HAVE_RAW_DECL_SIGABBREV_NP
1259_GL_WARN_ON_USE (sigabbrev_np, "sigabbrev_np is unportable - "
1260 "use gnulib module sigabbrev_np for portability");
1261# endif
1262#endif
1263
1264/* Return an English description string for the signal number SIG. */
1265#if @GNULIB_SIGDESCR_NP@
1266# if ! @HAVE_SIGDESCR_NP@
1267_GL_FUNCDECL_SYS (sigdescr_np, const char *, (int sig));
1268# endif
1269_GL_CXXALIAS_SYS (sigdescr_np, const char *, (int sig));
1270_GL_CXXALIASWARN (sigdescr_np);
1271#elif defined GNULIB_POSIXCHECK
1272# undef sigdescr_np
1273# if HAVE_RAW_DECL_SIGDESCR_NP
1274_GL_WARN_ON_USE (sigdescr_np, "sigdescr_np is unportable - "
1275 "use gnulib module sigdescr_np for portability");
1276# endif
1277#endif
1278
987#if @GNULIB_STRSIGNAL@ 1279#if @GNULIB_STRSIGNAL@
988# if @REPLACE_STRSIGNAL@ 1280# if @REPLACE_STRSIGNAL@
989# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1281# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1027,3 +1319,4 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
1027 1319
1028#endif /* _@GUARD_PREFIX@_STRING_H */ 1320#endif /* _@GUARD_PREFIX@_STRING_H */
1029#endif /* _@GUARD_PREFIX@_STRING_H */ 1321#endif /* _@GUARD_PREFIX@_STRING_H */
1322#endif
diff --git a/gl/strings.in.h b/gl/strings.in.h
index 4469f86..2cfe8b1 100644
--- a/gl/strings.in.h
+++ b/gl/strings.in.h
@@ -1,19 +1,19 @@
1/* A substitute <strings.h>. 1/* A substitute <strings.h>.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _@GUARD_PREFIX@_STRINGS_H 18#ifndef _@GUARD_PREFIX@_STRINGS_H
19 19
diff --git a/gl/stripslash.c b/gl/stripslash.c
index 0e452a9..fe46a9c 100644
--- a/gl/stripslash.c
+++ b/gl/stripslash.c
@@ -1,20 +1,20 @@
1/* stripslash.c -- remove redundant trailing slashes from a file name 1/* stripslash.c -- remove redundant trailing slashes from a file name
2 2
3 Copyright (C) 1990, 2001, 2003-2006, 2009-2013 Free Software Foundation, 3 Copyright (C) 1990, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc. 4 Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3 of the License, or 8 published by the Free Software Foundation; either version 2.1 of the
9 (at your option) any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/strncasecmp.c b/gl/strncasecmp.c
index 35840bc..c5c2cd3 100644
--- a/gl/strncasecmp.c
+++ b/gl/strncasecmp.c
@@ -1,18 +1,18 @@
1/* strncasecmp.c -- case insensitive string comparator 1/* strncasecmp.c -- case insensitive string comparator
2 Copyright (C) 1998-1999, 2005-2007, 2009-2013 Free Software Foundation, Inc. 2 Copyright (C) 1998-1999, 2005-2007, 2009-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
@@ -58,5 +58,5 @@ strncasecmp (const char *s1, const char *s2, size_t n)
58 /* On machines where 'char' and 'int' are types of the same size, the 58 /* On machines where 'char' and 'int' are types of the same size, the
59 difference of two 'unsigned char' values - including the sign bit - 59 difference of two 'unsigned char' values - including the sign bit -
60 doesn't fit in an 'int'. */ 60 doesn't fit in an 'int'. */
61 return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); 61 return _GL_CMP (c1, c2);
62} 62}
diff --git a/gl/strndup.c b/gl/strndup.c
deleted file mode 100644
index e60268b..0000000
--- a/gl/strndup.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* A replacement function, for systems that lack strndup.
2
3 Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2013 Free Software
4 Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18
19#include <config.h>
20
21#include <string.h>
22
23#include <stdlib.h>
24
25char *
26strndup (char const *s, size_t n)
27{
28 size_t len = strnlen (s, n);
29 char *new = malloc (len + 1);
30
31 if (new == NULL)
32 return NULL;
33
34 new[len] = '\0';
35 return memcpy (new, s, len);
36}
diff --git a/gl/strnlen.c b/gl/strnlen.c
deleted file mode 100644
index 57fdfe7..0000000
--- a/gl/strnlen.c
+++ /dev/null
@@ -1,30 +0,0 @@
1/* Find the length of STRING, but scan at most MAXLEN characters.
2 Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc.
3 Written by Simon Josefsson.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20#include <string.h>
21
22/* Find the length of STRING, but scan at most MAXLEN characters.
23 If no '\0' terminator is found in that many characters, return MAXLEN. */
24
25size_t
26strnlen (const char *string, size_t maxlen)
27{
28 const char *end = memchr (string, '\0', maxlen);
29 return end ? (size_t) (end - string) : maxlen;
30}
diff --git a/gl/strsep.c b/gl/strsep.c
index c51ac0d..8e9708a 100644
--- a/gl/strsep.c
+++ b/gl/strsep.c
@@ -1,19 +1,19 @@
1/* Copyright (C) 2004, 2007, 2009-2013 Free Software Foundation, Inc. 1/* Copyright (C) 2004, 2007, 2009-2023 Free Software Foundation, Inc.
2 2
3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
19# include <config.h> 19# include <config.h>
diff --git a/gl/strstr.c b/gl/strstr.c
index b91acec..574f4d5 100644
--- a/gl/strstr.c
+++ b/gl/strstr.c
@@ -1,19 +1,19 @@
1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2013 Free Software 1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2023 Free Software
2 Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* This particular implementation was written by Eric Blake, 2008. */ 18/* This particular implementation was written by Eric Blake, 2008. */
19 19
@@ -24,12 +24,6 @@
24/* Specification of strstr. */ 24/* Specification of strstr. */
25#include <string.h> 25#include <string.h>
26 26
27#include <stdbool.h>
28
29#ifndef _LIBC
30# define __builtin_expect(expr, val) (expr)
31#endif
32
33#define RETURN_TYPE char * 27#define RETURN_TYPE char *
34#define AVAILABLE(h, h_l, j, n_l) \ 28#define AVAILABLE(h, h_l, j, n_l) \
35 (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \ 29 (!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \
diff --git a/gl/sys-limits.h b/gl/sys-limits.h
new file mode 100644
index 0000000..0e9556d
--- /dev/null
+++ b/gl/sys-limits.h
@@ -0,0 +1,42 @@
1/* System call limits
2
3 Copyright 2018-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18#ifndef _GL_SYS_LIMITS_H
19#define _GL_SYS_LIMITS_H
20
21#include <limits.h>
22
23/* Maximum number of bytes to read or write in a single system call.
24 This can be useful for system calls like sendfile on GNU/Linux,
25 which do not handle more than MAX_RW_COUNT bytes correctly.
26 The Linux kernel MAX_RW_COUNT is at least INT_MAX >> 20 << 20,
27 where the 20 comes from the Hexagon port with 1 MiB pages; use that
28 as an approximation, as the exact value may not be available to us.
29
30 Using this also works around a serious Linux bug before 2.6.16; see
31 <https://bugzilla.redhat.com/show_bug.cgi?id=612839>.
32
33 Using this also works around a Tru64 5.1 bug, where attempting
34 to read INT_MAX bytes fails with errno == EINVAL. See
35 <https://lists.gnu.org/r/bug-gnu-utils/2002-04/msg00010.html>.
36
37 Using this is likely to work around similar bugs in other operating
38 systems. */
39
40enum { SYS_BUFSIZE_MAX = INT_MAX >> 20 << 20 };
41
42#endif
diff --git a/gl/sys_socket.c b/gl/sys_socket.c
index 3f017f8..b7388ce 100644
--- a/gl/sys_socket.c
+++ b/gl/sys_socket.c
@@ -1,3 +1,22 @@
1/* Inline functions for <sys/socket.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE 20#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE
3#include "sys/socket.h" 21#include "sys/socket.h"
22typedef int dummy;
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index b4cf0c3..6705593 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,20 +1,20 @@
1/* Provide a sys/socket header file for systems lacking it (read: MinGW) 1/* Provide a sys/socket header file for systems lacking it (read: MinGW)
2 and for systems where it is incomplete. 2 and for systems where it is incomplete.
3 Copyright (C) 2005-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2023 Free Software Foundation, Inc.
4 Written by Simon Josefsson. 4 Written by Simon Josefsson.
5 5
6 This program is free software; you can redistribute it and/or modify 6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU Lesser General Public License as
8 the Free Software Foundation; either version 3, or (at your option) 8 published by the Free Software Foundation; either version 2.1 of the
9 any later version. 9 License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19/* This file is supposed to be used on platforms that lack <sys/socket.h>, 19/* This file is supposed to be used on platforms that lack <sys/socket.h>,
20 on platforms where <sys/socket.h> cannot be included standalone, and on 20 on platforms where <sys/socket.h> cannot be included standalone, and on
@@ -63,6 +63,9 @@
63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H 63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
64#define _@GUARD_PREFIX@_SYS_SOCKET_H 64#define _@GUARD_PREFIX@_SYS_SOCKET_H
65 65
66#ifndef _GL_INLINE_HEADER_BEGIN
67 #error "Please include config.h first."
68#endif
66_GL_INLINE_HEADER_BEGIN 69_GL_INLINE_HEADER_BEGIN
67#ifndef _GL_SYS_SOCKET_INLINE 70#ifndef _GL_SYS_SOCKET_INLINE
68# define _GL_SYS_SOCKET_INLINE _GL_INLINE 71# define _GL_SYS_SOCKET_INLINE _GL_INLINE
@@ -76,7 +79,12 @@ _GL_INLINE_HEADER_BEGIN
76 79
77#if !@HAVE_SA_FAMILY_T@ 80#if !@HAVE_SA_FAMILY_T@
78# if !GNULIB_defined_sa_family_t 81# if !GNULIB_defined_sa_family_t
82/* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
83# if !defined __KLIBC__ || defined TCPV40HDRS
79typedef unsigned short sa_family_t; 84typedef unsigned short sa_family_t;
85# else
86typedef unsigned char sa_family_t;
87# endif
80# define GNULIB_defined_sa_family_t 1 88# define GNULIB_defined_sa_family_t 1
81# endif 89# endif
82#endif 90#endif
@@ -89,7 +97,6 @@ typedef unsigned short sa_family_t;
89# endif 97# endif
90# endif 98# endif
91#else 99#else
92# include <stdalign.h>
93/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on 100/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
94 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ 101 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
95# define __ss_aligntype unsigned long int 102# define __ss_aligntype unsigned long int
@@ -133,6 +140,15 @@ struct sockaddr_storage
133# define SHUT_RDWR 2 140# define SHUT_RDWR 2
134# endif 141# endif
135 142
143# ifdef __VMS /* OpenVMS */
144# ifndef CMSG_SPACE
145# define CMSG_SPACE(length) _CMSG_SPACE(length)
146# endif
147# ifndef CMSG_LEN
148# define CMSG_LEN(length) _CMSG_LEN(length)
149# endif
150# endif
151
136#else 152#else
137 153
138# ifdef __CYGWIN__ 154# ifdef __CYGWIN__
@@ -152,7 +168,7 @@ struct sockaddr_storage
152 code may not run on older Windows releases then. My Windows 2000 168 code may not run on older Windows releases then. My Windows 2000
153 box was not able to run the code, for example. The situation is 169 box was not able to run the code, for example. The situation is
154 slightly confusing because 170 slightly confusing because
155 <http://msdn.microsoft.com/en-us/library/ms738520> 171 <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
156 suggests that getaddrinfo should be available on all Windows 172 suggests that getaddrinfo should be available on all Windows
157 releases. */ 173 releases. */
158 174
@@ -178,12 +194,7 @@ struct sockaddr_storage
178/* Include headers needed by the emulation code. */ 194/* Include headers needed by the emulation code. */
179# include <sys/types.h> 195# include <sys/types.h>
180# include <io.h> 196# include <io.h>
181 197/* If these headers don't define socklen_t, <config.h> does. */
182# if !GNULIB_defined_socklen_t
183typedef int socklen_t;
184# define GNULIB_defined_socklen_t 1
185# endif
186
187# endif 198# endif
188 199
189/* Rudimentary 'struct msghdr'; this works as long as you don't try to 200/* Rudimentary 'struct msghdr'; this works as long as you don't try to
@@ -198,6 +209,15 @@ struct msghdr {
198 209
199#endif 210#endif
200 211
212/* Ensure SO_REUSEPORT is defined. */
213/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
214 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
215 and https://lwn.net/Articles/542629/
216 */
217#ifndef SO_REUSEPORT
218# define SO_REUSEPORT SO_REUSEADDR
219#endif
220
201/* Fix some definitions from <winsock2.h>. */ 221/* Fix some definitions from <winsock2.h>. */
202 222
203#if @HAVE_WINSOCK2_H@ 223#if @HAVE_WINSOCK2_H@
@@ -235,7 +255,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
235# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 255# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
236# undef close 256# undef close
237# define close close_used_without_including_unistd_h 257# define close close_used_without_including_unistd_h
238# else 258# elif !defined __clang__
239 _GL_WARN_ON_USE (close, 259 _GL_WARN_ON_USE (close,
240 "close() used without including <unistd.h>"); 260 "close() used without including <unistd.h>");
241# endif 261# endif
@@ -320,14 +340,20 @@ _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
320# define accept rpl_accept 340# define accept rpl_accept
321# endif 341# endif
322_GL_FUNCDECL_RPL (accept, int, 342_GL_FUNCDECL_RPL (accept, int,
323 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 343 (int fd,
344 struct sockaddr *restrict addr,
345 socklen_t *restrict addrlen));
324_GL_CXXALIAS_RPL (accept, int, 346_GL_CXXALIAS_RPL (accept, int,
325 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 347 (int fd,
348 struct sockaddr *restrict addr,
349 socklen_t *restrict addrlen));
326# else 350# else
327/* Need to cast, because on Solaris 10 systems, the third parameter is 351/* Need to cast, because on Solaris 10 systems, the third parameter is
328 void *addrlen. */ 352 void *addrlen. */
329_GL_CXXALIAS_SYS_CAST (accept, int, 353_GL_CXXALIAS_SYS_CAST (accept, int,
330 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 354 (int fd,
355 struct sockaddr *restrict addr,
356 socklen_t *restrict addrlen));
331# endif 357# endif
332_GL_CXXALIASWARN (accept); 358_GL_CXXALIASWARN (accept);
333#elif @HAVE_WINSOCK2_H@ 359#elif @HAVE_WINSOCK2_H@
@@ -378,15 +404,18 @@ _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
378# define getpeername rpl_getpeername 404# define getpeername rpl_getpeername
379# endif 405# endif
380_GL_FUNCDECL_RPL (getpeername, int, 406_GL_FUNCDECL_RPL (getpeername, int,
381 (int fd, struct sockaddr *addr, socklen_t *addrlen) 407 (int fd, struct sockaddr *restrict addr,
408 socklen_t *restrict addrlen)
382 _GL_ARG_NONNULL ((2, 3))); 409 _GL_ARG_NONNULL ((2, 3)));
383_GL_CXXALIAS_RPL (getpeername, int, 410_GL_CXXALIAS_RPL (getpeername, int,
384 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 411 (int fd, struct sockaddr *restrict addr,
412 socklen_t *restrict addrlen));
385# else 413# else
386/* Need to cast, because on Solaris 10 systems, the third parameter is 414/* Need to cast, because on Solaris 10 systems, the third parameter is
387 void *addrlen. */ 415 void *addrlen. */
388_GL_CXXALIAS_SYS_CAST (getpeername, int, 416_GL_CXXALIAS_SYS_CAST (getpeername, int,
389 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 417 (int fd, struct sockaddr *restrict addr,
418 socklen_t *restrict addrlen));
390# endif 419# endif
391_GL_CXXALIASWARN (getpeername); 420_GL_CXXALIASWARN (getpeername);
392#elif @HAVE_WINSOCK2_H@ 421#elif @HAVE_WINSOCK2_H@
@@ -407,15 +436,18 @@ _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
407# define getsockname rpl_getsockname 436# define getsockname rpl_getsockname
408# endif 437# endif
409_GL_FUNCDECL_RPL (getsockname, int, 438_GL_FUNCDECL_RPL (getsockname, int,
410 (int fd, struct sockaddr *addr, socklen_t *addrlen) 439 (int fd, struct sockaddr *restrict addr,
440 socklen_t *restrict addrlen)
411 _GL_ARG_NONNULL ((2, 3))); 441 _GL_ARG_NONNULL ((2, 3)));
412_GL_CXXALIAS_RPL (getsockname, int, 442_GL_CXXALIAS_RPL (getsockname, int,
413 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 443 (int fd, struct sockaddr *restrict addr,
444 socklen_t *restrict addrlen));
414# else 445# else
415/* Need to cast, because on Solaris 10 systems, the third parameter is 446/* Need to cast, because on Solaris 10 systems, the third parameter is
416 void *addrlen. */ 447 void *addrlen. */
417_GL_CXXALIAS_SYS_CAST (getsockname, int, 448_GL_CXXALIAS_SYS_CAST (getsockname, int,
418 (int fd, struct sockaddr *addr, socklen_t *addrlen)); 449 (int fd, struct sockaddr *restrict addr,
450 socklen_t *restrict addrlen));
419# endif 451# endif
420_GL_CXXALIASWARN (getsockname); 452_GL_CXXALIASWARN (getsockname);
421#elif @HAVE_WINSOCK2_H@ 453#elif @HAVE_WINSOCK2_H@
@@ -435,16 +467,19 @@ _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
435# undef getsockopt 467# undef getsockopt
436# define getsockopt rpl_getsockopt 468# define getsockopt rpl_getsockopt
437# endif 469# endif
438_GL_FUNCDECL_RPL (getsockopt, int, (int fd, int level, int optname, 470_GL_FUNCDECL_RPL (getsockopt, int,
439 void *optval, socklen_t *optlen) 471 (int fd, int level, int optname,
440 _GL_ARG_NONNULL ((4, 5))); 472 void *restrict optval, socklen_t *restrict optlen)
441_GL_CXXALIAS_RPL (getsockopt, int, (int fd, int level, int optname, 473 _GL_ARG_NONNULL ((4, 5)));
442 void *optval, socklen_t *optlen)); 474_GL_CXXALIAS_RPL (getsockopt, int,
475 (int fd, int level, int optname,
476 void *restrict optval, socklen_t *restrict optlen));
443# else 477# else
444/* Need to cast, because on Solaris 10 systems, the fifth parameter is 478/* Need to cast, because on Solaris 10 systems, the fifth parameter is
445 void *optlen. */ 479 void *optlen. */
446_GL_CXXALIAS_SYS_CAST (getsockopt, int, (int fd, int level, int optname, 480_GL_CXXALIAS_SYS_CAST (getsockopt, int,
447 void *optval, socklen_t *optlen)); 481 (int fd, int level, int optname,
482 void *restrict optval, socklen_t *restrict optlen));
448# endif 483# endif
449_GL_CXXALIASWARN (getsockopt); 484_GL_CXXALIASWARN (getsockopt);
450#elif @HAVE_WINSOCK2_H@ 485#elif @HAVE_WINSOCK2_H@
@@ -491,7 +526,10 @@ _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
491 _GL_ARG_NONNULL ((2))); 526 _GL_ARG_NONNULL ((2)));
492_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 527_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
493# else 528# else
494_GL_CXXALIAS_SYS (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); 529/* Need to cast, because on HP-UX 11.31 the return type may be
530 int,
531 depending on compiler options. */
532_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
495# endif 533# endif
496_GL_CXXALIASWARN (recv); 534_GL_CXXALIASWARN (recv);
497#elif @HAVE_WINSOCK2_H@ 535#elif @HAVE_WINSOCK2_H@
@@ -517,8 +555,11 @@ _GL_FUNCDECL_RPL (send, ssize_t,
517_GL_CXXALIAS_RPL (send, ssize_t, 555_GL_CXXALIAS_RPL (send, ssize_t,
518 (int fd, const void *buf, size_t len, int flags)); 556 (int fd, const void *buf, size_t len, int flags));
519# else 557# else
520_GL_CXXALIAS_SYS (send, ssize_t, 558/* Need to cast, because on HP-UX 11.31 the return type may be
521 (int fd, const void *buf, size_t len, int flags)); 559 int,
560 depending on compiler options. */
561_GL_CXXALIAS_SYS_CAST (send, ssize_t,
562 (int fd, const void *buf, size_t len, int flags));
522# endif 563# endif
523_GL_CXXALIASWARN (send); 564_GL_CXXALIASWARN (send);
524#elif @HAVE_WINSOCK2_H@ 565#elif @HAVE_WINSOCK2_H@
@@ -539,18 +580,21 @@ _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
539# define recvfrom rpl_recvfrom 580# define recvfrom rpl_recvfrom
540# endif 581# endif
541_GL_FUNCDECL_RPL (recvfrom, ssize_t, 582_GL_FUNCDECL_RPL (recvfrom, ssize_t,
542 (int fd, void *buf, size_t len, int flags, 583 (int fd, void *restrict buf, size_t len, int flags,
543 struct sockaddr *from, socklen_t *fromlen) 584 struct sockaddr *restrict from,
585 socklen_t *restrict fromlen)
544 _GL_ARG_NONNULL ((2))); 586 _GL_ARG_NONNULL ((2)));
545_GL_CXXALIAS_RPL (recvfrom, ssize_t, 587_GL_CXXALIAS_RPL (recvfrom, ssize_t,
546 (int fd, void *buf, size_t len, int flags, 588 (int fd, void *restrict buf, size_t len, int flags,
547 struct sockaddr *from, socklen_t *fromlen)); 589 struct sockaddr *restrict from,
590 socklen_t *restrict fromlen));
548# else 591# else
549/* Need to cast, because on Solaris 10 systems, the sixth parameter is 592/* Need to cast, because on Solaris 10 systems, the sixth parameter is
550 void *fromlen. */ 593 void *fromlen. */
551_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, 594_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
552 (int fd, void *buf, size_t len, int flags, 595 (int fd, void *restrict buf, size_t len, int flags,
553 struct sockaddr *from, socklen_t *fromlen)); 596 struct sockaddr *restrict from,
597 socklen_t *restrict fromlen));
554# endif 598# endif
555_GL_CXXALIASWARN (recvfrom); 599_GL_CXXALIASWARN (recvfrom);
556#elif @HAVE_WINSOCK2_H@ 600#elif @HAVE_WINSOCK2_H@
@@ -654,7 +698,7 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
654 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) 698 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
655 and O_TEXT, O_BINARY (defined in "binary-io.h"). 699 and O_TEXT, O_BINARY (defined in "binary-io.h").
656 See also the Linux man page at 700 See also the Linux man page at
657 <http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */ 701 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
658# if @HAVE_ACCEPT4@ 702# if @HAVE_ACCEPT4@
659# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 703# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
660# define accept4 rpl_accept4 704# define accept4 rpl_accept4
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
new file mode 100644
index 0000000..096887c
--- /dev/null
+++ b/gl/sys_stat.in.h
@@ -0,0 +1,954 @@
1/* Provide a more complete sys/stat.h header file.
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
18
19/* This file is supposed to be used on platforms where <sys/stat.h> is
20 incomplete. It is intended to provide definitions and prototypes
21 needed by an application. Start with what the system provides. */
22
23#if __GNUC__ >= 3
24@PRAGMA_SYSTEM_HEADER@
25#endif
26@PRAGMA_COLUMNS@
27
28#if defined __need_system_sys_stat_h
29/* Special invocation convention. */
30
31#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
32
33#else
34/* Normal invocation convention. */
35
36#ifndef _@GUARD_PREFIX@_SYS_STAT_H
37
38/* Get nlink_t.
39 May also define off_t to a 64-bit type on native Windows. */
40#include <sys/types.h>
41
42/* Get struct timespec. */
43#include <time.h>
44
45/* The include_next requires a split double-inclusion guard. */
46#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
47
48#ifndef _@GUARD_PREFIX@_SYS_STAT_H
49#define _@GUARD_PREFIX@_SYS_STAT_H
50
51/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
52
53/* The definition of _GL_ARG_NONNULL is copied here. */
54
55/* The definition of _GL_WARN_ON_USE is copied here. */
56
57/* Before doing "#define mknod rpl_mknod" below, we need to include all
58 headers that may declare mknod(). OS/2 kLIBC declares mknod() in
59 <unistd.h>, not in <sys/stat.h>. */
60#ifdef __KLIBC__
61# include <unistd.h>
62#endif
63
64/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
65 headers that may declare mkdir(). Native Windows platforms declare mkdir
66 in <io.h> and/or <direct.h>, not in <sys/stat.h>. */
67#if defined _WIN32 && ! defined __CYGWIN__
68# include <io.h> /* mingw32, mingw64 */
69# include <direct.h> /* mingw64, MSVC 9 */
70#endif
71
72/* Native Windows platforms declare umask() in <io.h>. */
73#if 0 && (defined _WIN32 && ! defined __CYGWIN__)
74# include <io.h>
75#endif
76
77/* Large File Support on native Windows. */
78#if @WINDOWS_64_BIT_ST_SIZE@
79# define stat _stati64
80#endif
81
82/* Optionally, override 'struct stat' on native Windows. */
83#if @GNULIB_OVERRIDES_STRUCT_STAT@
84
85# undef stat
86# if @GNULIB_STAT@
87# define stat rpl_stat
88# else
89 /* Provoke a clear link error if stat() is used as a function and
90 module 'stat' is not in use. */
91# define stat stat_used_without_requesting_gnulib_module_stat
92# endif
93
94# if !GNULIB_defined_struct_stat
95struct stat
96{
97 dev_t st_dev;
98 ino_t st_ino;
99 mode_t st_mode;
100 nlink_t st_nlink;
101# if 0
102 uid_t st_uid;
103# else /* uid_t is not defined by default on native Windows. */
104 short st_uid;
105# endif
106# if 0
107 gid_t st_gid;
108# else /* gid_t is not defined by default on native Windows. */
109 short st_gid;
110# endif
111 dev_t st_rdev;
112 off_t st_size;
113# if 0
114 blksize_t st_blksize;
115 blkcnt_t st_blocks;
116# endif
117
118# if @WINDOWS_STAT_TIMESPEC@
119 struct timespec st_atim;
120 struct timespec st_mtim;
121 struct timespec st_ctim;
122# else
123 time_t st_atime;
124 time_t st_mtime;
125 time_t st_ctime;
126# endif
127};
128# if @WINDOWS_STAT_TIMESPEC@
129# define st_atime st_atim.tv_sec
130# define st_mtime st_mtim.tv_sec
131# define st_ctime st_ctim.tv_sec
132 /* Indicator, for gnulib internal purposes. */
133# define _GL_WINDOWS_STAT_TIMESPEC 1
134# endif
135# define GNULIB_defined_struct_stat 1
136# endif
137
138/* Other possible values of st_mode. */
139# if 0
140# define _S_IFBLK 0x6000
141# endif
142# if 0
143# define _S_IFLNK 0xA000
144# endif
145# if 0
146# define _S_IFSOCK 0xC000
147# endif
148
149#endif
150
151#ifndef S_IFIFO
152# ifdef _S_IFIFO
153# define S_IFIFO _S_IFIFO
154# endif
155#endif
156
157#ifndef S_IFMT
158# define S_IFMT 0170000
159#endif
160
161#if STAT_MACROS_BROKEN
162# undef S_ISBLK
163# undef S_ISCHR
164# undef S_ISDIR
165# undef S_ISFIFO
166# undef S_ISLNK
167# undef S_ISNAM
168# undef S_ISMPB
169# undef S_ISMPC
170# undef S_ISNWK
171# undef S_ISREG
172# undef S_ISSOCK
173#endif
174
175#ifndef S_ISBLK
176# ifdef S_IFBLK
177# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
178# else
179# define S_ISBLK(m) 0
180# endif
181#endif
182
183#ifndef S_ISCHR
184# ifdef S_IFCHR
185# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
186# else
187# define S_ISCHR(m) 0
188# endif
189#endif
190
191#ifndef S_ISDIR
192# ifdef S_IFDIR
193# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
194# else
195# define S_ISDIR(m) 0
196# endif
197#endif
198
199#ifndef S_ISDOOR /* Solaris 2.5 and up */
200# define S_ISDOOR(m) 0
201#endif
202
203#ifndef S_ISFIFO
204# ifdef S_IFIFO
205# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
206# else
207# define S_ISFIFO(m) 0
208# endif
209#endif
210
211#ifndef S_ISLNK
212# ifdef S_IFLNK
213# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
214# else
215# define S_ISLNK(m) 0
216# endif
217#endif
218
219#ifndef S_ISMPB /* V7 */
220# ifdef S_IFMPB
221# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
222# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
223# else
224# define S_ISMPB(m) 0
225# define S_ISMPC(m) 0
226# endif
227#endif
228
229#ifndef S_ISMPX /* AIX */
230# define S_ISMPX(m) 0
231#endif
232
233#ifndef S_ISNAM /* Xenix */
234# ifdef S_IFNAM
235# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
236# else
237# define S_ISNAM(m) 0
238# endif
239#endif
240
241#ifndef S_ISNWK /* HP/UX */
242# ifdef S_IFNWK
243# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
244# else
245# define S_ISNWK(m) 0
246# endif
247#endif
248
249#ifndef S_ISPORT /* Solaris 10 and up */
250# define S_ISPORT(m) 0
251#endif
252
253#ifndef S_ISREG
254# ifdef S_IFREG
255# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
256# else
257# define S_ISREG(m) 0
258# endif
259#endif
260
261#ifndef S_ISSOCK
262# ifdef S_IFSOCK
263# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
264# else
265# define S_ISSOCK(m) 0
266# endif
267#endif
268
269
270#ifndef S_TYPEISMQ
271# define S_TYPEISMQ(p) 0
272#endif
273
274#ifndef S_TYPEISTMO
275# define S_TYPEISTMO(p) 0
276#endif
277
278
279#ifndef S_TYPEISSEM
280# ifdef S_INSEM
281# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
282# else
283# define S_TYPEISSEM(p) 0
284# endif
285#endif
286
287#ifndef S_TYPEISSHM
288# ifdef S_INSHD
289# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
290# else
291# define S_TYPEISSHM(p) 0
292# endif
293#endif
294
295/* high performance ("contiguous data") */
296#ifndef S_ISCTG
297# define S_ISCTG(p) 0
298#endif
299
300/* Cray DMF (data migration facility): off line, with data */
301#ifndef S_ISOFD
302# define S_ISOFD(p) 0
303#endif
304
305/* Cray DMF (data migration facility): off line, with no data */
306#ifndef S_ISOFL
307# define S_ISOFL(p) 0
308#endif
309
310/* 4.4BSD whiteout */
311#ifndef S_ISWHT
312# define S_ISWHT(m) 0
313#endif
314
315/* If any of the following are undefined,
316 define them to their de facto standard values. */
317#if !S_ISUID
318# define S_ISUID 04000
319#endif
320#if !S_ISGID
321# define S_ISGID 02000
322#endif
323
324/* S_ISVTX is a common extension to POSIX. */
325#ifndef S_ISVTX
326# define S_ISVTX 01000
327#endif
328
329#if !S_IRUSR && S_IREAD
330# define S_IRUSR S_IREAD
331#endif
332#if !S_IRUSR
333# define S_IRUSR 00400
334#endif
335#if !S_IRGRP
336# define S_IRGRP (S_IRUSR >> 3)
337#endif
338#if !S_IROTH
339# define S_IROTH (S_IRUSR >> 6)
340#endif
341
342#if !S_IWUSR && S_IWRITE
343# define S_IWUSR S_IWRITE
344#endif
345#if !S_IWUSR
346# define S_IWUSR 00200
347#endif
348#if !S_IWGRP
349# define S_IWGRP (S_IWUSR >> 3)
350#endif
351#if !S_IWOTH
352# define S_IWOTH (S_IWUSR >> 6)
353#endif
354
355#if !S_IXUSR && S_IEXEC
356# define S_IXUSR S_IEXEC
357#endif
358#if !S_IXUSR
359# define S_IXUSR 00100
360#endif
361#if !S_IXGRP
362# define S_IXGRP (S_IXUSR >> 3)
363#endif
364#if !S_IXOTH
365# define S_IXOTH (S_IXUSR >> 6)
366#endif
367
368#if !S_IRWXU
369# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
370#endif
371#if !S_IRWXG
372# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
373#endif
374#if !S_IRWXO
375# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
376#endif
377
378/* Although S_IXUGO and S_IRWXUGO are not specified by POSIX and are
379 not implemented in GNU/Linux, some Gnulib-using apps use the macros. */
380#if !S_IXUGO
381# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
382#endif
383#ifndef S_IRWXUGO
384# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
385#endif
386
387/* Macros for futimens and utimensat. */
388#ifndef UTIME_NOW
389# define UTIME_NOW (-1)
390# define UTIME_OMIT (-2)
391#endif
392
393
394#if @GNULIB_CHMOD@
395# if @REPLACE_CHMOD@
396# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397# undef chmod
398# define chmod rpl_chmod
399# endif
400_GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
401 _GL_ARG_NONNULL ((1)));
402_GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
403# elif defined _WIN32 && !defined __CYGWIN__
404# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
405# undef chmod
406# define chmod _chmod
407# endif
408/* Need to cast, because in mingw the last argument is 'int mode'. */
409_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
410# else
411_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
412# endif
413_GL_CXXALIASWARN (chmod);
414#elif defined GNULIB_POSIXCHECK
415# undef chmod
416# if HAVE_RAW_DECL_CHMOD
417_GL_WARN_ON_USE (chmod, "chmod has portability problems - "
418 "use gnulib module chmod for portability");
419# endif
420#elif @GNULIB_MDA_CHMOD@
421/* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
422 required. In C++ with GNULIB_NAMESPACE, avoid differences between
423 platforms by defining GNULIB_NAMESPACE::chmod always. */
424# if defined _WIN32 && !defined __CYGWIN__
425# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
426# undef chmod
427# define chmod _chmod
428# endif
429/* Need to cast, because in mingw the last argument is 'int mode'. */
430_GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
431# else
432_GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
433# endif
434_GL_CXXALIASWARN (chmod);
435#endif
436
437
438#if @GNULIB_FCHMODAT@
439# if @REPLACE_FCHMODAT@
440# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
441# undef fchmodat
442# define fchmodat rpl_fchmodat
443# endif
444_GL_FUNCDECL_RPL (fchmodat, int,
445 (int fd, char const *file, mode_t mode, int flag)
446 _GL_ARG_NONNULL ((2)));
447_GL_CXXALIAS_RPL (fchmodat, int,
448 (int fd, char const *file, mode_t mode, int flag));
449# else
450# if !@HAVE_FCHMODAT@
451_GL_FUNCDECL_SYS (fchmodat, int,
452 (int fd, char const *file, mode_t mode, int flag)
453 _GL_ARG_NONNULL ((2)));
454# endif
455_GL_CXXALIAS_SYS (fchmodat, int,
456 (int fd, char const *file, mode_t mode, int flag));
457# endif
458_GL_CXXALIASWARN (fchmodat);
459#elif defined GNULIB_POSIXCHECK
460# undef fchmodat
461# if HAVE_RAW_DECL_FCHMODAT
462_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
463 "use gnulib module openat for portability");
464# endif
465#endif
466
467
468#if @GNULIB_FSTAT@
469# if @REPLACE_FSTAT@
470# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
471# undef fstat
472# define fstat rpl_fstat
473# endif
474_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
475_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
476# else
477_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
478# endif
479# if __GLIBC__ >= 2
480_GL_CXXALIASWARN (fstat);
481# endif
482#elif @GNULIB_OVERRIDES_STRUCT_STAT@
483# undef fstat
484# define fstat fstat_used_without_requesting_gnulib_module_fstat
485#elif @WINDOWS_64_BIT_ST_SIZE@
486/* Above, we define stat to _stati64. */
487# define fstat _fstati64
488#elif defined GNULIB_POSIXCHECK
489# undef fstat
490# if HAVE_RAW_DECL_FSTAT
491_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
492 "use gnulib module fstat for portability");
493# endif
494#endif
495
496
497#if @GNULIB_FSTATAT@
498# if @REPLACE_FSTATAT@
499# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500# undef fstatat
501# define fstatat rpl_fstatat
502# endif
503_GL_FUNCDECL_RPL (fstatat, int,
504 (int fd, char const *restrict name, struct stat *restrict st,
505 int flags)
506 _GL_ARG_NONNULL ((2, 3)));
507_GL_CXXALIAS_RPL (fstatat, int,
508 (int fd, char const *restrict name, struct stat *restrict st,
509 int flags));
510# else
511# if !@HAVE_FSTATAT@
512_GL_FUNCDECL_SYS (fstatat, int,
513 (int fd, char const *restrict name, struct stat *restrict st,
514 int flags)
515 _GL_ARG_NONNULL ((2, 3)));
516# endif
517_GL_CXXALIAS_SYS (fstatat, int,
518 (int fd, char const *restrict name, struct stat *restrict st,
519 int flags));
520# endif
521_GL_CXXALIASWARN (fstatat);
522#elif @GNULIB_OVERRIDES_STRUCT_STAT@
523# undef fstatat
524# define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
525#elif defined GNULIB_POSIXCHECK
526# undef fstatat
527# if HAVE_RAW_DECL_FSTATAT
528_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
529 "use gnulib module openat for portability");
530# endif
531#endif
532
533
534#if @GNULIB_FUTIMENS@
535/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
536 implementation relies on futimesat, which on Solaris 10 makes an invocation
537 to futimens that is meant to invoke the libc's futimens(), not gnulib's
538 futimens(). */
539# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
540# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
541# undef futimens
542# define futimens rpl_futimens
543# endif
544_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
545_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
546# else
547# if !@HAVE_FUTIMENS@
548_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
549# endif
550_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
551# endif
552# if @HAVE_FUTIMENS@
553_GL_CXXALIASWARN (futimens);
554# endif
555#elif defined GNULIB_POSIXCHECK
556# undef futimens
557# if HAVE_RAW_DECL_FUTIMENS
558_GL_WARN_ON_USE (futimens, "futimens is not portable - "
559 "use gnulib module futimens for portability");
560# endif
561#endif
562
563
564#if @GNULIB_GETUMASK@
565# if !@HAVE_GETUMASK@
566_GL_FUNCDECL_SYS (getumask, mode_t, (void));
567# endif
568_GL_CXXALIAS_SYS (getumask, mode_t, (void));
569# if @HAVE_GETUMASK@
570_GL_CXXALIASWARN (getumask);
571# endif
572#elif defined GNULIB_POSIXCHECK
573# undef getumask
574# if HAVE_RAW_DECL_GETUMASK
575_GL_WARN_ON_USE (getumask, "getumask is not portable - "
576 "use gnulib module getumask for portability");
577# endif
578#endif
579
580
581#if @GNULIB_LCHMOD@
582/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
583 denotes a symbolic link. */
584# if !@HAVE_LCHMOD@ || defined __hpux
585_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
586 _GL_ARG_NONNULL ((1)));
587# endif
588_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
589_GL_CXXALIASWARN (lchmod);
590#elif defined GNULIB_POSIXCHECK
591# undef lchmod
592# if HAVE_RAW_DECL_LCHMOD
593_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
594 "use gnulib module lchmod for portability");
595# endif
596#endif
597
598
599#if @GNULIB_MKDIR@
600# if @REPLACE_MKDIR@
601# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602# undef mkdir
603# define mkdir rpl_mkdir
604# endif
605_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
606 _GL_ARG_NONNULL ((1)));
607_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
608# elif defined _WIN32 && !defined __CYGWIN__
609/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
610 Additionally, it declares _mkdir (and depending on compile flags, an
611 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
612 which are included above. */
613# if !GNULIB_defined_rpl_mkdir
614static int
615rpl_mkdir (char const *name, mode_t mode)
616{
617 return _mkdir (name);
618}
619# define GNULIB_defined_rpl_mkdir 1
620# endif
621# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
622# undef mkdir
623# define mkdir rpl_mkdir
624# endif
625_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
626# else
627_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
628# endif
629_GL_CXXALIASWARN (mkdir);
630#elif defined GNULIB_POSIXCHECK
631# undef mkdir
632# if HAVE_RAW_DECL_MKDIR
633_GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
634 "use gnulib module mkdir for portability");
635# endif
636#elif @GNULIB_MDA_MKDIR@
637/* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
638 required. In C++ with GNULIB_NAMESPACE, avoid differences between
639 platforms by defining GNULIB_NAMESPACE::mkdir always. */
640# if defined _WIN32 && !defined __CYGWIN__
641# if !GNULIB_defined_rpl_mkdir
642static int
643rpl_mkdir (char const *name, mode_t mode)
644{
645 return _mkdir (name);
646}
647# define GNULIB_defined_rpl_mkdir 1
648# endif
649# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650# undef mkdir
651# define mkdir rpl_mkdir
652# endif
653_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
654# else
655_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
656# endif
657_GL_CXXALIASWARN (mkdir);
658#endif
659
660
661#if @GNULIB_MKDIRAT@
662# if !@HAVE_MKDIRAT@
663_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
664 _GL_ARG_NONNULL ((2)));
665# endif
666_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
667_GL_CXXALIASWARN (mkdirat);
668#elif defined GNULIB_POSIXCHECK
669# undef mkdirat
670# if HAVE_RAW_DECL_MKDIRAT
671_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
672 "use gnulib module openat for portability");
673# endif
674#endif
675
676
677#if @GNULIB_MKFIFO@
678# if @REPLACE_MKFIFO@
679# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
680# undef mkfifo
681# define mkfifo rpl_mkfifo
682# endif
683_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
684 _GL_ARG_NONNULL ((1)));
685_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
686# else
687# if !@HAVE_MKFIFO@
688_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
689 _GL_ARG_NONNULL ((1)));
690# endif
691_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
692# endif
693_GL_CXXALIASWARN (mkfifo);
694#elif defined GNULIB_POSIXCHECK
695# undef mkfifo
696# if HAVE_RAW_DECL_MKFIFO
697_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
698 "use gnulib module mkfifo for portability");
699# endif
700#endif
701
702
703#if @GNULIB_MKFIFOAT@
704# if @REPLACE_MKFIFOAT@
705# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706# undef mkfifoat
707# define mkfifoat rpl_mkfifoat
708# endif
709_GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)
710 _GL_ARG_NONNULL ((2)));
711_GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
712# else
713# if !@HAVE_MKFIFOAT@
714_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
715 _GL_ARG_NONNULL ((2)));
716# endif
717_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
718# endif
719_GL_CXXALIASWARN (mkfifoat);
720#elif defined GNULIB_POSIXCHECK
721# undef mkfifoat
722# if HAVE_RAW_DECL_MKFIFOAT
723_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
724 "use gnulib module mkfifoat for portability");
725# endif
726#endif
727
728
729#if @GNULIB_MKNOD@
730# if @REPLACE_MKNOD@
731# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
732# undef mknod
733# define mknod rpl_mknod
734# endif
735_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
736 _GL_ARG_NONNULL ((1)));
737_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
738# else
739# if !@HAVE_MKNOD@
740_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
741 _GL_ARG_NONNULL ((1)));
742# endif
743/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
744_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
745# endif
746_GL_CXXALIASWARN (mknod);
747#elif defined GNULIB_POSIXCHECK
748# undef mknod
749# if HAVE_RAW_DECL_MKNOD
750_GL_WARN_ON_USE (mknod, "mknod is not portable - "
751 "use gnulib module mknod for portability");
752# endif
753#endif
754
755
756#if @GNULIB_MKNODAT@
757# if @REPLACE_MKNODAT@
758# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
759# undef mknodat
760# define mknodat rpl_mknodat
761# endif
762_GL_FUNCDECL_RPL (mknodat, int,
763 (int fd, char const *file, mode_t mode, dev_t dev)
764 _GL_ARG_NONNULL ((2)));
765_GL_CXXALIAS_RPL (mknodat, int,
766 (int fd, char const *file, mode_t mode, dev_t dev));
767# else
768# if !@HAVE_MKNODAT@
769_GL_FUNCDECL_SYS (mknodat, int,
770 (int fd, char const *file, mode_t mode, dev_t dev)
771 _GL_ARG_NONNULL ((2)));
772# endif
773_GL_CXXALIAS_SYS (mknodat, int,
774 (int fd, char const *file, mode_t mode, dev_t dev));
775# endif
776_GL_CXXALIASWARN (mknodat);
777#elif defined GNULIB_POSIXCHECK
778# undef mknodat
779# if HAVE_RAW_DECL_MKNODAT
780_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
781 "use gnulib module mkfifoat for portability");
782# endif
783#endif
784
785
786#if @GNULIB_STAT@
787# if @REPLACE_STAT@
788# if !@GNULIB_OVERRIDES_STRUCT_STAT@
789 /* We can't use the object-like #define stat rpl_stat, because of
790 struct stat. This means that rpl_stat will not be used if the user
791 does (stat)(a,b). Oh well. */
792# if defined _AIX && defined stat && defined _LARGE_FILES
793 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
794 so we have to replace stat64() instead of stat(). */
795# undef stat64
796# define stat64(name, st) rpl_stat (name, st)
797# elif @WINDOWS_64_BIT_ST_SIZE@
798 /* Above, we define stat to _stati64. */
799# if defined __MINGW32__ && defined _stati64
800# ifndef _USE_32BIT_TIME_T
801 /* The system headers define _stati64 to _stat64. */
802# undef _stat64
803# define _stat64(name, st) rpl_stat (name, st)
804# endif
805# elif defined _MSC_VER && defined _stati64
806# ifdef _USE_32BIT_TIME_T
807 /* The system headers define _stati64 to _stat32i64. */
808# undef _stat32i64
809# define _stat32i64(name, st) rpl_stat (name, st)
810# else
811 /* The system headers define _stati64 to _stat64. */
812# undef _stat64
813# define _stat64(name, st) rpl_stat (name, st)
814# endif
815# else
816# undef _stati64
817# define _stati64(name, st) rpl_stat (name, st)
818# endif
819# elif defined __MINGW32__ && defined stat
820# ifdef _USE_32BIT_TIME_T
821 /* The system headers define stat to _stat32i64. */
822# undef _stat32i64
823# define _stat32i64(name, st) rpl_stat (name, st)
824# else
825 /* The system headers define stat to _stat64. */
826# undef _stat64
827# define _stat64(name, st) rpl_stat (name, st)
828# endif
829# elif defined _MSC_VER && defined stat
830# ifdef _USE_32BIT_TIME_T
831 /* The system headers define stat to _stat32. */
832# undef _stat32
833# define _stat32(name, st) rpl_stat (name, st)
834# else
835 /* The system headers define stat to _stat64i32. */
836# undef _stat64i32
837# define _stat64i32(name, st) rpl_stat (name, st)
838# endif
839# else /* !(_AIX || __MINGW32__ || _MSC_VER) */
840# undef stat
841# define stat(name, st) rpl_stat (name, st)
842# endif /* !_LARGE_FILES */
843# endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
844_GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
845 _GL_ARG_NONNULL ((1, 2));
846# endif
847#elif @GNULIB_OVERRIDES_STRUCT_STAT@
848/* see above:
849 #define stat stat_used_without_requesting_gnulib_module_stat
850 */
851#elif defined GNULIB_POSIXCHECK
852# undef stat
853# if HAVE_RAW_DECL_STAT
854_GL_WARN_ON_USE (stat, "stat is unportable - "
855 "use gnulib module stat for portability");
856# endif
857#endif
858
859
860#if @GNULIB_LSTAT@
861# if ! @HAVE_LSTAT@
862/* mingw does not support symlinks, therefore it does not have lstat. But
863 without links, stat does just fine. */
864# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
865# define lstat stat
866# endif
867_GL_CXXALIAS_RPL_1 (lstat, stat, int,
868 (const char *restrict name, struct stat *restrict buf));
869# elif @REPLACE_LSTAT@
870# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
871# undef lstat
872# define lstat rpl_lstat
873# endif
874_GL_FUNCDECL_RPL (lstat, int,
875 (const char *restrict name, struct stat *restrict buf)
876 _GL_ARG_NONNULL ((1, 2)));
877_GL_CXXALIAS_RPL (lstat, int,
878 (const char *restrict name, struct stat *restrict buf));
879# else
880_GL_CXXALIAS_SYS (lstat, int,
881 (const char *restrict name, struct stat *restrict buf));
882# endif
883# if @HAVE_LSTAT@
884_GL_CXXALIASWARN (lstat);
885# endif
886#elif @GNULIB_OVERRIDES_STRUCT_STAT@
887# undef lstat
888# define lstat lstat_used_without_requesting_gnulib_module_lstat
889#elif defined GNULIB_POSIXCHECK
890# undef lstat
891# if HAVE_RAW_DECL_LSTAT
892_GL_WARN_ON_USE (lstat, "lstat is unportable - "
893 "use gnulib module lstat for portability");
894# endif
895#endif
896
897
898#if @GNULIB_MDA_UMASK@
899/* On native Windows, map 'umask' to '_umask', so that -loldnames is not
900 required. In C++ with GNULIB_NAMESPACE, avoid differences between
901 platforms by defining GNULIB_NAMESPACE::umask always. */
902# if defined _WIN32 && !defined __CYGWIN__
903# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
904# undef umask
905# define umask _umask
906# endif
907/* Need to cast, because in mingw the last argument is 'int mode'. */
908_GL_CXXALIAS_MDA_CAST (umask, mode_t, (mode_t mask));
909# else
910_GL_CXXALIAS_SYS (umask, mode_t, (mode_t mask));
911# endif
912_GL_CXXALIASWARN (umask);
913#endif
914
915
916#if @GNULIB_UTIMENSAT@
917/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
918 implementation relies on futimesat, which on Solaris 10 makes an invocation
919 to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
920 utimensat(). */
921# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
922# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
923# undef utimensat
924# define utimensat rpl_utimensat
925# endif
926_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
927 struct timespec const times[2], int flag)
928 _GL_ARG_NONNULL ((2)));
929_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
930 struct timespec const times[2], int flag));
931# else
932# if !@HAVE_UTIMENSAT@
933_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
934 struct timespec const times[2], int flag)
935 _GL_ARG_NONNULL ((2)));
936# endif
937_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
938 struct timespec const times[2], int flag));
939# endif
940# if @HAVE_UTIMENSAT@
941_GL_CXXALIASWARN (utimensat);
942# endif
943#elif defined GNULIB_POSIXCHECK
944# undef utimensat
945# if HAVE_RAW_DECL_UTIMENSAT
946_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
947 "use gnulib module utimensat for portability");
948# endif
949#endif
950
951
952#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
953#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
954#endif
diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h
index d7da356..082a6c6 100644
--- a/gl/sys_types.in.h
+++ b/gl/sys_types.in.h
@@ -1,29 +1,42 @@
1/* Provide a more complete sys/types.h. 1/* Provide a more complete sys/types.h.
2 2
3 Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 Copyright (C) 2011-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
20#endif 20#endif
21@PRAGMA_COLUMNS@ 21@PRAGMA_COLUMNS@
22 22
23#if defined _WIN32 && !defined __CYGWIN__ \
24 && (defined __need_off_t || defined __need___off64_t \
25 || defined __need_ssize_t || defined __need_time_t)
26
27/* Special invocation convention inside mingw header files. */
28
29#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
30
31#else
32/* Normal invocation convention. */
33
23#ifndef _@GUARD_PREFIX@_SYS_TYPES_H 34#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
24 35
25/* The include_next requires a split double-inclusion guard. */ 36/* The include_next requires a split double-inclusion guard. */
37# define _GL_INCLUDING_SYS_TYPES_H
26#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@ 38#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
39# undef _GL_INCLUDING_SYS_TYPES_H
27 40
28#ifndef _@GUARD_PREFIX@_SYS_TYPES_H 41#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
29#define _@GUARD_PREFIX@_SYS_TYPES_H 42#define _@GUARD_PREFIX@_SYS_TYPES_H
@@ -40,12 +53,54 @@
40# define _GL_WINDOWS_64_BIT_OFF_T 1 53# define _GL_WINDOWS_64_BIT_OFF_T 1
41#endif 54#endif
42 55
56/* Override dev_t and ino_t if distinguishable inodes support is requested
57 on native Windows. */
58#if @WINDOWS_STAT_INODES@
59
60# if @WINDOWS_STAT_INODES@ == 2
61/* Experimental, not useful in Windows 10. */
62
63/* Define dev_t to a 64-bit type. */
64# if !defined GNULIB_defined_dev_t
65typedef unsigned long long int rpl_dev_t;
66# undef dev_t
67# define dev_t rpl_dev_t
68# define GNULIB_defined_dev_t 1
69# endif
70
71/* Define ino_t to a 128-bit type. */
72# if !defined GNULIB_defined_ino_t
73/* MSVC does not have a 128-bit integer type.
74 GCC has a 128-bit integer type __int128, but only on 64-bit targets. */
75typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t;
76# undef ino_t
77# define ino_t rpl_ino_t
78# define GNULIB_defined_ino_t 1
79# endif
80
81# else /* @WINDOWS_STAT_INODES@ == 1 */
82
83/* Define ino_t to a 64-bit type. */
84# if !defined GNULIB_defined_ino_t
85typedef unsigned long long int rpl_ino_t;
86# undef ino_t
87# define ino_t rpl_ino_t
88# define GNULIB_defined_ino_t 1
89# endif
90
91# endif
92
93/* Indicator, for gnulib internal purposes. */
94# define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@
95
96#endif
97
43/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */ 98/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
44/* But avoid namespace pollution on glibc systems. */ 99/* But avoid namespace pollution on glibc systems. */
45#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \ 100#if (defined _WIN32 && ! defined __CYGWIN__) && ! defined __GLIBC__
46 && ! defined __GLIBC__
47# include <stddef.h> 101# include <stddef.h>
48#endif 102#endif
49 103
50#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ 104#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
51#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */ 105#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
106#endif /* __need_XXX */
diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h
index fef19dc..64c4fb6 100644
--- a/gl/sys_uio.in.h
+++ b/gl/sys_uio.in.h
@@ -1,18 +1,18 @@
1/* Substitute for <sys/uio.h>. 1/* Substitute for <sys/uio.h>.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc. 2 Copyright (C) 2011-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17# if __GNUC__ >= 3 17# if __GNUC__ >= 3
18@PRAGMA_SYSTEM_HEADER@ 18@PRAGMA_SYSTEM_HEADER@
diff --git a/gl/time.in.h b/gl/time.in.h
index 8ced794..50c9b30 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -1,19 +1,19 @@
1/* A more-standard <time.h>. 1/* A more-standard <time.h>.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
@@ -22,11 +22,13 @@
22 22
23/* Don't get in the way of glibc when it includes time.h merely to 23/* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the 24 declare a few standard symbols, rather than to declare all the
25 symbols. Also, Solaris 8 <time.h> eventually includes itself 25 symbols. (However, skip this for MinGW as it treats __need_time_t
26 incompatibly.) Also, Solaris 8 <time.h> eventually includes itself
26 recursively; if that is happening, just include the system <time.h> 27 recursively; if that is happening, just include the system <time.h>
27 without adding our own declarations. */ 28 without adding our own declarations. */
28#if (defined __need_time_t || defined __need_clock_t \ 29#if (((defined __need_time_t || defined __need_clock_t \
29 || defined __need_timespec \ 30 || defined __need_timespec) \
31 && !defined __MINGW32__) \
30 || defined _@GUARD_PREFIX@_TIME_H) 32 || defined _@GUARD_PREFIX@_TIME_H)
31 33
32# @INCLUDE_NEXT@ @NEXT_TIME_H@ 34# @INCLUDE_NEXT@ @NEXT_TIME_H@
@@ -35,6 +37,12 @@
35 37
36# define _@GUARD_PREFIX@_TIME_H 38# define _@GUARD_PREFIX@_TIME_H
37 39
40/* mingw's <time.h> provides the functions asctime_r, ctime_r, gmtime_r,
41 localtime_r only if <unistd.h> or <pthread.h> has been included before. */
42# if defined __MINGW32__
43# include <unistd.h>
44# endif
45
38# @INCLUDE_NEXT@ @NEXT_TIME_H@ 46# @INCLUDE_NEXT@ @NEXT_TIME_H@
39 47
40/* NetBSD 5.0 mis-defines NULL. */ 48/* NetBSD 5.0 mis-defines NULL. */
@@ -46,22 +54,17 @@
46 54
47/* The definition of _GL_WARN_ON_USE is copied here. */ 55/* The definition of _GL_WARN_ON_USE is copied here. */
48 56
49/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). 57/* Some systems don't define struct timespec (e.g., AIX 4.1).
50 Or they define it with the wrong member names or define it in <sys/time.h> 58 Or they define it with the wrong member names or define it in <sys/time.h>
51 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the 59 (e.g., FreeBSD circa 1997). Stock Mingw prior to 3.0 does not define it,
52 pthreads-win32 library defines it in <pthread.h>. */ 60 but the pthreads-win32 library defines it in <pthread.h>. */
53# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ 61# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
54# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ 62# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
55# include <sys/time.h> 63# include <sys/time.h>
56# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ 64# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
57# include <pthread.h> 65# include <pthread.h>
58/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */ 66# elif @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
59# undef asctime_r 67# include <unistd.h>
60# undef ctime_r
61# undef gmtime_r
62# undef localtime_r
63# undef rand_r
64# undef strtok_r
65# else 68# else
66 69
67# ifdef __cplusplus 70# ifdef __cplusplus
@@ -87,8 +90,8 @@ struct timespec
87# endif 90# endif
88 91
89# if !GNULIB_defined_struct_time_t_must_be_integral 92# if !GNULIB_defined_struct_time_t_must_be_integral
90/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires 93/* https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
91 time_t to be an integer type, even though C99 permits floating 94 requires time_t to be an integer type, even though C99 permits floating
92 point. We don't know of any implementation that uses floating 95 point. We don't know of any implementation that uses floating
93 point, and it is much easier to write code that doesn't have to 96 point, and it is much easier to write code that doesn't have to
94 worry about that corner case, so we force the issue. */ 97 worry about that corner case, so we force the issue. */
@@ -98,9 +101,39 @@ struct __time_t_must_be_integral {
98# define GNULIB_defined_struct_time_t_must_be_integral 1 101# define GNULIB_defined_struct_time_t_must_be_integral 1
99# endif 102# endif
100 103
104/* Define TIME_UTC, a positive integer constant used for timespec_get(). */
105# if ! @TIME_H_DEFINES_TIME_UTC@
106# if !GNULIB_defined_TIME_UTC
107# define TIME_UTC 1
108# define GNULIB_defined_TIME_UTC 1
109# endif
110# endif
111
112/* Set *TS to the current time, and return BASE.
113 Upon failure, return 0. */
114# if @GNULIB_TIMESPEC_GET@
115# if ! @HAVE_TIMESPEC_GET@
116_GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
117 _GL_ARG_NONNULL ((1)));
118# endif
119_GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
120_GL_CXXALIASWARN (timespec_get);
121# endif
122
123/* Set *TS to the current time resolution, and return BASE.
124 Upon failure, return 0. */
125# if @GNULIB_TIMESPEC_GETRES@
126# if ! @HAVE_TIMESPEC_GETRES@
127_GL_FUNCDECL_SYS (timespec_getres, int, (struct timespec *ts, int base)
128 _GL_ARG_NONNULL ((1)));
129# endif
130_GL_CXXALIAS_SYS (timespec_getres, int, (struct timespec *ts, int base));
131_GL_CXXALIASWARN (timespec_getres);
132# endif
133
101/* Sleep for at least RQTP seconds unless interrupted, If interrupted, 134/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
102 return -1 and store the remaining time into RMTP. See 135 return -1 and store the remaining time into RMTP. See
103 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */ 136 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html>. */
104# if @GNULIB_NANOSLEEP@ 137# if @GNULIB_NANOSLEEP@
105# if @REPLACE_NANOSLEEP@ 138# if @REPLACE_NANOSLEEP@
106# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 139# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -123,6 +156,41 @@ _GL_CXXALIAS_SYS (nanosleep, int,
123_GL_CXXALIASWARN (nanosleep); 156_GL_CXXALIASWARN (nanosleep);
124# endif 157# endif
125 158
159/* Initialize time conversion information. */
160# if @GNULIB_TZSET@
161# if @REPLACE_TZSET@
162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163# undef tzset
164# define tzset rpl_tzset
165# endif
166_GL_FUNCDECL_RPL (tzset, void, (void));
167_GL_CXXALIAS_RPL (tzset, void, (void));
168# elif defined _WIN32 && !defined __CYGWIN__
169# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170# undef tzset
171# define tzset _tzset
172# endif
173_GL_CXXALIAS_MDA (tzset, void, (void));
174# else
175_GL_CXXALIAS_SYS (tzset, void, (void));
176# endif
177_GL_CXXALIASWARN (tzset);
178# elif @GNULIB_MDA_TZSET@
179/* On native Windows, map 'tzset' to '_tzset', so that -loldnames is not
180 required. In C++ with GNULIB_NAMESPACE, avoid differences between
181 platforms by defining GNULIB_NAMESPACE::tzset always. */
182# if defined _WIN32 && !defined __CYGWIN__
183# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
184# undef tzset
185# define tzset _tzset
186# endif
187_GL_CXXALIAS_MDA (tzset, void, (void));
188# else
189_GL_CXXALIAS_SYS (tzset, void, (void));
190# endif
191_GL_CXXALIASWARN (tzset);
192# endif
193
126/* Return the 'time_t' representation of TP and normalize TP. */ 194/* Return the 'time_t' representation of TP and normalize TP. */
127# if @GNULIB_MKTIME@ 195# if @GNULIB_MKTIME@
128# if @REPLACE_MKTIME@ 196# if @REPLACE_MKTIME@
@@ -134,12 +202,14 @@ _GL_CXXALIAS_RPL (mktime, time_t, (struct tm *__tp));
134# else 202# else
135_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp)); 203_GL_CXXALIAS_SYS (mktime, time_t, (struct tm *__tp));
136# endif 204# endif
205# if __GLIBC__ >= 2
137_GL_CXXALIASWARN (mktime); 206_GL_CXXALIASWARN (mktime);
207# endif
138# endif 208# endif
139 209
140/* Convert TIMER to RESULT, assuming local time and UTC respectively. See 210/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
141 <http://www.opengroup.org/susv3xsh/localtime_r.html> and 211 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html> and
142 <http://www.opengroup.org/susv3xsh/gmtime_r.html>. */ 212 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html>. */
143# if @GNULIB_TIME_R@ 213# if @GNULIB_TIME_R@
144# if @REPLACE_LOCALTIME_R@ 214# if @REPLACE_LOCALTIME_R@
145# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -187,9 +257,44 @@ _GL_CXXALIASWARN (gmtime_r);
187# endif 257# endif
188# endif 258# endif
189 259
190/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store 260/* Convert TIMER to RESULT, assuming local time and UTC respectively. See
261 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime.html> and
262 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html>. */
263# if @GNULIB_LOCALTIME@ || @REPLACE_LOCALTIME@
264# if @REPLACE_LOCALTIME@
265# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
266# undef localtime
267# define localtime rpl_localtime
268# endif
269_GL_FUNCDECL_RPL (localtime, struct tm *, (time_t const *__timer)
270 _GL_ARG_NONNULL ((1)));
271_GL_CXXALIAS_RPL (localtime, struct tm *, (time_t const *__timer));
272# else
273_GL_CXXALIAS_SYS (localtime, struct tm *, (time_t const *__timer));
274# endif
275# if __GLIBC__ >= 2
276_GL_CXXALIASWARN (localtime);
277# endif
278# endif
279
280# if 0 || @REPLACE_GMTIME@
281# if @REPLACE_GMTIME@
282# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
283# undef gmtime
284# define gmtime rpl_gmtime
285# endif
286_GL_FUNCDECL_RPL (gmtime, struct tm *, (time_t const *__timer)
287 _GL_ARG_NONNULL ((1)));
288_GL_CXXALIAS_RPL (gmtime, struct tm *, (time_t const *__timer));
289# else
290_GL_CXXALIAS_SYS (gmtime, struct tm *, (time_t const *__timer));
291# endif
292_GL_CXXALIASWARN (gmtime);
293# endif
294
295/* Parse BUF as a timestamp, assuming FORMAT specifies its layout, and store
191 the resulting broken-down time into TM. See 296 the resulting broken-down time into TM. See
192 <http://www.opengroup.org/susv3xsh/strptime.html>. */ 297 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html>. */
193# if @GNULIB_STRPTIME@ 298# if @GNULIB_STRPTIME@
194# if ! @HAVE_STRPTIME@ 299# if ! @HAVE_STRPTIME@
195_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, 300_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
@@ -203,6 +308,106 @@ _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
203_GL_CXXALIASWARN (strptime); 308_GL_CXXALIASWARN (strptime);
204# endif 309# endif
205 310
311/* Convert *TP to a date and time string. See
312 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime.html>. */
313# if @GNULIB_CTIME@
314# if @REPLACE_CTIME@
315# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316# define ctime rpl_ctime
317# endif
318_GL_ATTRIBUTE_DEPRECATED
319_GL_FUNCDECL_RPL (ctime, char *, (time_t const *__tp)
320 _GL_ARG_NONNULL ((1)));
321_GL_CXXALIAS_RPL (ctime, char *, (time_t const *__tp));
322# else
323_GL_CXXALIAS_SYS (ctime, char *, (time_t const *__tp));
324# endif
325# if __GLIBC__ >= 2
326_GL_CXXALIASWARN (ctime);
327# endif
328# endif
329
330/* Convert *TP to a date and time string. See
331 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html>. */
332# if @GNULIB_STRFTIME@
333# if @REPLACE_STRFTIME@
334# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
335# define strftime rpl_strftime
336# endif
337_GL_FUNCDECL_RPL (strftime, size_t,
338 (char *restrict __buf, size_t __bufsize,
339 const char *restrict __fmt, const struct tm *restrict __tp)
340 _GL_ARG_NONNULL ((1, 3, 4)));
341_GL_CXXALIAS_RPL (strftime, size_t,
342 (char *restrict __buf, size_t __bufsize,
343 const char *restrict __fmt, const struct tm *restrict __tp));
344# else
345_GL_CXXALIAS_SYS (strftime, size_t,
346 (char *restrict __buf, size_t __bufsize,
347 const char *restrict __fmt, const struct tm *restrict __tp));
348# endif
349# if __GLIBC__ >= 2
350_GL_CXXALIASWARN (strftime);
351# endif
352# endif
353
354# if defined _GNU_SOURCE && @GNULIB_TIME_RZ@ && ! @HAVE_TIMEZONE_T@
355/* Functions that use a first-class time zone data type, instead of
356 relying on an implicit global time zone.
357 Inspired by NetBSD. */
358
359/* Represents a time zone.
360 (timezone_t) NULL stands for UTC. */
361typedef struct tm_zone *timezone_t;
362
363/* tzalloc (name)
364 Returns a time zone object for the given time zone NAME. This object
365 represents the time zone that other functions would use it the TZ
366 environment variable was set to NAME.
367 If NAME is NULL, the result represents the time zone that other functions
368 would use it the TZ environment variable was unset.
369 May return NULL if NAME is invalid (this is platform dependent) or
370 upon memory allocation failure. */
371_GL_FUNCDECL_SYS (tzalloc, timezone_t, (char const *__name));
372_GL_CXXALIAS_SYS (tzalloc, timezone_t, (char const *__name));
373
374/* tzfree (tz)
375 Frees a time zone object.
376 The argument must have been returned by tzalloc(). */
377_GL_FUNCDECL_SYS (tzfree, void, (timezone_t __tz));
378_GL_CXXALIAS_SYS (tzfree, void, (timezone_t __tz));
379
380/* localtime_rz (tz, &t, &result)
381 Converts an absolute time T to a broken-down time RESULT, assuming the
382 time zone TZ.
383 This function is like 'localtime_r', but relies on the argument TZ instead
384 of an implicit global time zone. */
385_GL_FUNCDECL_SYS (localtime_rz, struct tm *,
386 (timezone_t __tz, time_t const *restrict __timer,
387 struct tm *restrict __result) _GL_ARG_NONNULL ((2, 3)));
388_GL_CXXALIAS_SYS (localtime_rz, struct tm *,
389 (timezone_t __tz, time_t const *restrict __timer,
390 struct tm *restrict __result));
391
392/* mktime_z (tz, &tm)
393 Normalizes the broken-down time TM and converts it to an absolute time,
394 assuming the time zone TZ. Returns the absolute time.
395 This function is like 'mktime', but relies on the argument TZ instead
396 of an implicit global time zone. */
397_GL_FUNCDECL_SYS (mktime_z, time_t,
398 (timezone_t __tz, struct tm *restrict __tm)
399 _GL_ARG_NONNULL ((2)));
400_GL_CXXALIAS_SYS (mktime_z, time_t,
401 (timezone_t __tz, struct tm *restrict __tm));
402
403/* Time zone abbreviation strings (returned by 'localtime_rz' or 'mktime_z'
404 in the 'tm_zone' member of 'struct tm') are valid as long as
405 - the 'struct tm' argument is not destroyed or overwritten,
406 and
407 - the 'timezone_t' argument is not freed through tzfree(). */
408
409# endif
410
206/* Convert TM to a time_t value, assuming UTC. */ 411/* Convert TM to a time_t value, assuming UTC. */
207# if @GNULIB_TIMEGM@ 412# if @GNULIB_TIMEGM@
208# if @REPLACE_TIMEGM@ 413# if @REPLACE_TIMEGM@
@@ -231,18 +436,22 @@ _GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - "
231# endif 436# endif
232# if defined GNULIB_POSIXCHECK 437# if defined GNULIB_POSIXCHECK
233# undef asctime_r 438# undef asctime_r
234_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " 439# if HAVE_RAW_DECL_ASCTIME_R
440_GL_WARN_ON_USE (asctime_r, "asctime_r can overrun buffers in some cases - "
235 "better use strftime (or even sprintf) instead"); 441 "better use strftime (or even sprintf) instead");
442# endif
236# endif 443# endif
237# if defined GNULIB_POSIXCHECK 444# if defined GNULIB_POSIXCHECK
238# undef ctime 445# undef ctime
239_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " 446_GL_WARN_ON_USE (ctime, "ctime can overrun buffers in some cases - "
240 "better use strftime (or even sprintf) instead"); 447 "better use strftime (or even sprintf) instead");
241# endif 448# endif
242# if defined GNULIB_POSIXCHECK 449# if defined GNULIB_POSIXCHECK
243# undef ctime_r 450# undef ctime_r
244_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " 451# if HAVE_RAW_DECL_CTIME_R
452_GL_WARN_ON_USE (ctime_r, "ctime_r can overrun buffers in some cases - "
245 "better use strftime (or even sprintf) instead"); 453 "better use strftime (or even sprintf) instead");
454# endif
246# endif 455# endif
247 456
248#endif 457#endif
diff --git a/gl/time_r.c b/gl/time_r.c
index 9866299..97be4fd 100644
--- a/gl/time_r.c
+++ b/gl/time_r.c
@@ -1,19 +1,19 @@
1/* Reentrant time functions like localtime_r. 1/* Reentrant time functions like localtime_r.
2 2
3 Copyright (C) 2003, 2006-2007, 2010-2013 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006-2007, 2010-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
19 19
diff --git a/gl/timegm.c b/gl/timegm.c
index 6338baa..b47025a 100644
--- a/gl/timegm.c
+++ b/gl/timegm.c
@@ -1,38 +1,58 @@
1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. 1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
2 2
3 Copyright (C) 1994, 1997, 2003-2004, 2006-2007, 2009-2013 Free Software 3 Copyright (C) 1994-2023 Free Software Foundation, Inc.
4 Foundation, Inc. This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
6 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU Lesser General Public
8 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
9 any later version. 9 version 2.1 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 Lesser General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU Lesser General Public
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
18 19
19#ifndef _LIBC 20#ifndef _LIBC
20# include <config.h> 21# include <libc-config.h>
21#endif 22#endif
22 23
23#include <time.h> 24#include <time.h>
25#include <errno.h>
24 26
25#ifndef _LIBC 27#include "mktime-internal.h"
26# undef __gmtime_r 28
27# define __gmtime_r gmtime_r 29__time64_t
28# define __mktime_internal mktime_internal 30__timegm64 (struct tm *tmp)
29# include "mktime-internal.h" 31{
30#endif 32 static mktime_offset_t gmtime_offset;
33 tmp->tm_isdst = 0;
34 return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset);
35}
36
37#if defined _LIBC && __TIMESIZE != 64
38
39libc_hidden_def (__timegm64)
31 40
32time_t 41time_t
33timegm (struct tm *tmp) 42timegm (struct tm *tmp)
34{ 43{
35 static time_t gmtime_offset; 44 struct tm tm = *tmp;
36 tmp->tm_isdst = 0; 45 __time64_t t = __timegm64 (&tm);
37 return __mktime_internal (tmp, __gmtime_r, &gmtime_offset); 46 if (in_time_t_range (t))
47 {
48 *tmp = tm;
49 return t;
50 }
51 else
52 {
53 __set_errno (EOVERFLOW);
54 return -1;
55 }
38} 56}
57
58#endif
diff --git a/gl/unistd.c b/gl/unistd.c
index 6c6a8e2..be7a825 100644
--- a/gl/unistd.c
+++ b/gl/unistd.c
@@ -1,3 +1,22 @@
1/* Inline functions for <unistd.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE 20#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
3#include "unistd.h" 21#include "unistd.h"
22typedef int dummy;
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 2ea9af4..4812fdb 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,18 +1,18 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2013 Free Software Foundation, Inc. 2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _@GUARD_PREFIX@_UNISTD_H 17#ifndef _@GUARD_PREFIX@_UNISTD_H
18 18
@@ -21,9 +21,23 @@
21#endif 21#endif
22@PRAGMA_COLUMNS@ 22@PRAGMA_COLUMNS@
23 23
24#if @HAVE_UNISTD_H@ && defined _GL_INCLUDING_UNISTD_H
25/* Special invocation convention:
26 - On Mac OS X 10.3.9 we have a sequence of nested includes
27 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
28 In this situation, the functions are not yet declared, therefore we cannot
29 provide the C++ aliases. */
30
31#@INCLUDE_NEXT@ @NEXT_UNISTD_H@
32
33#else
34/* Normal invocation convention. */
35
24/* The include_next requires a split double-inclusion guard. */ 36/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_UNISTD_H@ 37#if @HAVE_UNISTD_H@
38# define _GL_INCLUDING_UNISTD_H
26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ 39# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
40# undef _GL_INCLUDING_UNISTD_H
27#endif 41#endif
28 42
29/* Get all possible declarations of gethostname(). */ 43/* Get all possible declarations of gethostname(). */
@@ -38,21 +52,30 @@
38#define _@GUARD_PREFIX@_UNISTD_H 52#define _@GUARD_PREFIX@_UNISTD_H
39 53
40/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ 54/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
41#include <stddef.h> 55/* But avoid namespace pollution on glibc systems. */
56#ifndef __GLIBC__
57# include <stddef.h>
58#endif
42 59
43/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ 60/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
61/* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
62 it before we #define unlink rpl_unlink. */
44/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ 63/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
45/* But avoid namespace pollution on glibc systems. */ 64/* But avoid namespace pollution on glibc systems. */
46#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ 65#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
66 || ((@GNULIB_UNLINK@ || defined GNULIB_POSIXCHECK) \
67 && (defined _WIN32 && ! defined __CYGWIN__)) \
47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ 68 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \ 69 && defined __CYGWIN__)) \
49 && ! defined __GLIBC__ 70 && ! defined __GLIBC__
50# include <stdio.h> 71# include <stdio.h>
51#endif 72#endif
52 73
53/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ 74/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
75 <unistd.h>. */
54/* But avoid namespace pollution on glibc systems. */ 76/* But avoid namespace pollution on glibc systems. */
55#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ 77#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
78 && (defined __CYGWIN__ || defined __ANDROID__) \
56 && ! defined __GLIBC__ 79 && ! defined __GLIBC__
57# include <fcntl.h> 80# include <fcntl.h>
58#endif 81#endif
@@ -70,20 +93,18 @@
70# undef __need_system_stdlib_h 93# undef __need_system_stdlib_h
71#endif 94#endif
72 95
73/* Native Windows platforms declare chdir, getcwd, rmdir in 96/* Native Windows platforms declare _chdir, _getcwd, _rmdir in
74 <io.h> and/or <direct.h>, not in <unistd.h>. 97 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(), 98 They also declare _access(), _chmod(), _close(), _dup(), _dup2(), _isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */ 99 _lseek(), _read(), _unlink(), _write() in <io.h>. */
77#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \ 100#if defined _WIN32 && !defined __CYGWIN__
78 || defined GNULIB_POSIXCHECK) \
79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80# include <io.h> /* mingw32, mingw64 */
81# include <direct.h> /* mingw64, MSVC 9 */
82#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
86# include <io.h> 101# include <io.h>
102# include <direct.h>
103#endif
104
105/* Native Windows platforms declare _execl*, _execv* in <process.h>. */
106#if defined _WIN32 && !defined __CYGWIN__
107# include <process.h>
87#endif 108#endif
88 109
89/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. 110/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
@@ -95,31 +116,28 @@
95# include <netdb.h> 116# include <netdb.h>
96#endif 117#endif
97 118
98/* MSVC defines off_t in <sys/types.h>. 119/* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
99 May also define off_t to a 64-bit type on native Windows. */ 120 <sys/random.h>, not in <unistd.h>. */
100#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@ 121/* But avoid namespace pollution on glibc systems. */
101/* Get off_t. */ 122#if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
102# include <sys/types.h> 123 && ((defined __APPLE__ && defined __MACH__) || defined __sun \
103#endif 124 || defined __ANDROID__) \
104 125 && @UNISTD_H_HAVE_SYS_RANDOM_H@ \
105#if (@GNULIB_READ@ || @GNULIB_WRITE@ \ 126 && !defined __GLIBC__
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ 127# include <sys/random.h>
107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
108/* Get ssize_t. */
109# include <sys/types.h>
110#endif 128#endif
111 129
112/* Get getopt(), optarg, optind, opterr, optopt. 130/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
113 But avoid namespace pollution on glibc systems. */ 131/* But avoid namespace pollution on glibc systems. */
114#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT 132#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
115# define __need_getopt 133 && !defined __GLIBC__
116# include <getopt.h> 134# include <sys/stat.h>
117#endif 135#endif
118 136
119_GL_INLINE_HEADER_BEGIN 137/* MSVC defines off_t in <sys/types.h>.
120#ifndef _GL_UNISTD_INLINE 138 May also define off_t to a 64-bit type on native Windows. */
121# define _GL_UNISTD_INLINE _GL_INLINE 139/* Get off_t, ssize_t, mode_t. */
122#endif 140#include <sys/types.h>
123 141
124/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 142/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
125 143
@@ -128,6 +146,20 @@ _GL_INLINE_HEADER_BEGIN
128/* The definition of _GL_WARN_ON_USE is copied here. */ 146/* The definition of _GL_WARN_ON_USE is copied here. */
129 147
130 148
149/* Get getopt(), optarg, optind, opterr, optopt. */
150#if @GNULIB_GETOPT_POSIX@ && @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
151# include <getopt-cdefs.h>
152# include <getopt-pfx-core.h>
153#endif
154
155#ifndef _GL_INLINE_HEADER_BEGIN
156 #error "Please include config.h first."
157#endif
158_GL_INLINE_HEADER_BEGIN
159#ifndef _GL_UNISTD_INLINE
160# define _GL_UNISTD_INLINE _GL_INLINE
161#endif
162
131/* Hide some function declarations from <winsock2.h>. */ 163/* Hide some function declarations from <winsock2.h>. */
132 164
133#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ 165#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
@@ -227,15 +259,61 @@ _GL_INLINE_HEADER_BEGIN
227/* Declare overridden functions. */ 259/* Declare overridden functions. */
228 260
229 261
230#if defined GNULIB_POSIXCHECK 262#if @GNULIB_ACCESS@
263# if @REPLACE_ACCESS@
264# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
265# undef access
266# define access rpl_access
267# endif
268_GL_FUNCDECL_RPL (access, int, (const char *file, int mode)
269 _GL_ARG_NONNULL ((1)));
270_GL_CXXALIAS_RPL (access, int, (const char *file, int mode));
271# elif defined _WIN32 && !defined __CYGWIN__
272# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273# undef access
274# define access _access
275# endif
276_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
277# else
278_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
279# endif
280_GL_CXXALIASWARN (access);
281#elif defined GNULIB_POSIXCHECK
282# undef access
283# if HAVE_RAW_DECL_ACCESS
231/* The access() function is a security risk. */ 284/* The access() function is a security risk. */
232_GL_WARN_ON_USE (access, "the access function is a security risk - " 285_GL_WARN_ON_USE (access, "access does not always support X_OK - "
286 "use gnulib module access for portability; "
287 "also, this function is a security risk - "
233 "use the gnulib module faccessat instead"); 288 "use the gnulib module faccessat instead");
289# endif
290#elif @GNULIB_MDA_ACCESS@
291/* On native Windows, map 'access' to '_access', so that -loldnames is not
292 required. In C++ with GNULIB_NAMESPACE, avoid differences between
293 platforms by defining GNULIB_NAMESPACE::access always. */
294# if defined _WIN32 && !defined __CYGWIN__
295# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296# undef access
297# define access _access
298# endif
299_GL_CXXALIAS_MDA (access, int, (const char *file, int mode));
300# else
301_GL_CXXALIAS_SYS (access, int, (const char *file, int mode));
302# endif
303_GL_CXXALIASWARN (access);
234#endif 304#endif
235 305
236 306
237#if @GNULIB_CHDIR@ 307#if @GNULIB_CHDIR@
308# if defined _WIN32 && !defined __CYGWIN__
309# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310# undef chdir
311# define chdir _chdir
312# endif
313_GL_CXXALIAS_MDA (chdir, int, (const char *file));
314# else
238_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); 315_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
316# endif
239_GL_CXXALIASWARN (chdir); 317_GL_CXXALIASWARN (chdir);
240#elif defined GNULIB_POSIXCHECK 318#elif defined GNULIB_POSIXCHECK
241# undef chdir 319# undef chdir
@@ -243,6 +321,20 @@ _GL_CXXALIASWARN (chdir);
243_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - " 321_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
244 "use gnulib module chdir for portability"); 322 "use gnulib module chdir for portability");
245# endif 323# endif
324#elif @GNULIB_MDA_CHDIR@
325/* On native Windows, map 'chdir' to '_chdir', so that -loldnames is not
326 required. In C++ with GNULIB_NAMESPACE, avoid differences between
327 platforms by defining GNULIB_NAMESPACE::chdir always. */
328# if defined _WIN32 && !defined __CYGWIN__
329# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
330# undef chdir
331# define chdir _chdir
332# endif
333_GL_CXXALIAS_MDA (chdir, int, (const char *file));
334# else
335_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
336# endif
337_GL_CXXALIASWARN (chdir);
246#endif 338#endif
247 339
248 340
@@ -251,7 +343,7 @@ _GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
251 to GID (if GID is not -1). Follow symbolic links. 343 to GID (if GID is not -1). Follow symbolic links.
252 Return 0 if successful, otherwise -1 and errno set. 344 Return 0 if successful, otherwise -1 and errno set.
253 See the POSIX:2008 specification 345 See the POSIX:2008 specification
254 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */ 346 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
255# if @REPLACE_CHOWN@ 347# if @REPLACE_CHOWN@
256# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 348# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257# undef chown 349# undef chown
@@ -287,6 +379,12 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
287# endif 379# endif
288_GL_FUNCDECL_RPL (close, int, (int fd)); 380_GL_FUNCDECL_RPL (close, int, (int fd));
289_GL_CXXALIAS_RPL (close, int, (int fd)); 381_GL_CXXALIAS_RPL (close, int, (int fd));
382# elif defined _WIN32 && !defined __CYGWIN__
383# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
384# undef close
385# define close _close
386# endif
387_GL_CXXALIAS_MDA (close, int, (int fd));
290# else 388# else
291_GL_CXXALIAS_SYS (close, int, (int fd)); 389_GL_CXXALIAS_SYS (close, int, (int fd));
292# endif 390# endif
@@ -299,6 +397,53 @@ _GL_CXXALIASWARN (close);
299/* Assume close is always declared. */ 397/* Assume close is always declared. */
300_GL_WARN_ON_USE (close, "close does not portably work on sockets - " 398_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
301 "use gnulib module close for portability"); 399 "use gnulib module close for portability");
400#elif @GNULIB_MDA_CLOSE@
401/* On native Windows, map 'close' to '_close', so that -loldnames is not
402 required. In C++ with GNULIB_NAMESPACE, avoid differences between
403 platforms by defining GNULIB_NAMESPACE::close always. */
404# if defined _WIN32 && !defined __CYGWIN__
405# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
406# undef close
407# define close _close
408# endif
409_GL_CXXALIAS_MDA (close, int, (int fd));
410# else
411_GL_CXXALIAS_SYS (close, int, (int fd));
412# endif
413_GL_CXXALIASWARN (close);
414#endif
415
416
417#if @GNULIB_COPY_FILE_RANGE@
418# if @REPLACE_COPY_FILE_RANGE@
419# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
420# undef copy_file_range
421# define copy_file_range rpl_copy_file_range
422# endif
423_GL_FUNCDECL_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
424 int ofd, off_t *opos,
425 size_t len, unsigned flags));
426_GL_CXXALIAS_RPL (copy_file_range, ssize_t, (int ifd, off_t *ipos,
427 int ofd, off_t *opos,
428 size_t len, unsigned flags));
429# else
430# if !@HAVE_COPY_FILE_RANGE@
431_GL_FUNCDECL_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
432 int ofd, off_t *opos,
433 size_t len, unsigned flags));
434# endif
435_GL_CXXALIAS_SYS (copy_file_range, ssize_t, (int ifd, off_t *ipos,
436 int ofd, off_t *opos,
437 size_t len, unsigned flags));
438# endif
439_GL_CXXALIASWARN (copy_file_range);
440#elif defined GNULIB_POSIXCHECK
441# undef copy_file_range
442# if HAVE_RAW_DECL_COPY_FILE_RANGE
443_GL_WARN_ON_USE (copy_file_range,
444 "copy_file_range is unportable - "
445 "use gnulib module copy_file_range for portability");
446# endif
302#endif 447#endif
303 448
304 449
@@ -309,6 +454,12 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
309# endif 454# endif
310_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 455_GL_FUNCDECL_RPL (dup, int, (int oldfd));
311_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 456_GL_CXXALIAS_RPL (dup, int, (int oldfd));
457# elif defined _WIN32 && !defined __CYGWIN__
458# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
459# undef dup
460# define dup _dup
461# endif
462_GL_CXXALIAS_MDA (dup, int, (int oldfd));
312# else 463# else
313_GL_CXXALIAS_SYS (dup, int, (int oldfd)); 464_GL_CXXALIAS_SYS (dup, int, (int oldfd));
314# endif 465# endif
@@ -319,6 +470,20 @@ _GL_CXXALIASWARN (dup);
319_GL_WARN_ON_USE (dup, "dup is unportable - " 470_GL_WARN_ON_USE (dup, "dup is unportable - "
320 "use gnulib module dup for portability"); 471 "use gnulib module dup for portability");
321# endif 472# endif
473#elif @GNULIB_MDA_DUP@
474/* On native Windows, map 'dup' to '_dup', so that -loldnames is not
475 required. In C++ with GNULIB_NAMESPACE, avoid differences between
476 platforms by defining GNULIB_NAMESPACE::dup always. */
477# if defined _WIN32 && !defined __CYGWIN__
478# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
479# undef dup
480# define dup _dup
481# endif
482_GL_CXXALIAS_MDA (dup, int, (int oldfd));
483# else
484_GL_CXXALIAS_SYS (dup, int, (int oldfd));
485# endif
486_GL_CXXALIASWARN (dup);
322#endif 487#endif
323 488
324 489
@@ -327,17 +492,20 @@ _GL_WARN_ON_USE (dup, "dup is unportable - "
327 NEWFD = OLDFD, otherwise close NEWFD first if it is open. 492 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
328 Return newfd if successful, otherwise -1 and errno set. 493 Return newfd if successful, otherwise -1 and errno set.
329 See the POSIX:2008 specification 494 See the POSIX:2008 specification
330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */ 495 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
331# if @REPLACE_DUP2@ 496# if @REPLACE_DUP2@
332# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 497# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333# define dup2 rpl_dup2 498# define dup2 rpl_dup2
334# endif 499# endif
335_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); 500_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
336_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); 501_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
337# else 502# elif defined _WIN32 && !defined __CYGWIN__
338# if !@HAVE_DUP2@ 503# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); 504# undef dup2
505# define dup2 _dup2
340# endif 506# endif
507_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
508# else
341_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); 509_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
342# endif 510# endif
343_GL_CXXALIASWARN (dup2); 511_GL_CXXALIASWARN (dup2);
@@ -347,6 +515,20 @@ _GL_CXXALIASWARN (dup2);
347_GL_WARN_ON_USE (dup2, "dup2 is unportable - " 515_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
348 "use gnulib module dup2 for portability"); 516 "use gnulib module dup2 for portability");
349# endif 517# endif
518#elif @GNULIB_MDA_DUP2@
519/* On native Windows, map 'dup2' to '_dup2', so that -loldnames is not
520 required. In C++ with GNULIB_NAMESPACE, avoid differences between
521 platforms by defining GNULIB_NAMESPACE::dup2 always. */
522# if defined _WIN32 && !defined __CYGWIN__
523# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
524# undef dup2
525# define dup2 _dup2
526# endif
527_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd));
528# else
529_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
530# endif
531_GL_CXXALIASWARN (dup2);
350#endif 532#endif
351 533
352 534
@@ -358,7 +540,7 @@ _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
358 Close NEWFD first if it is open. 540 Close NEWFD first if it is open.
359 Return newfd if successful, otherwise -1 and errno set. 541 Return newfd if successful, otherwise -1 and errno set.
360 See the Linux man page at 542 See the Linux man page at
361 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ 543 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
362# if @HAVE_DUP3@ 544# if @HAVE_DUP3@
363# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 545# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
364# define dup3 rpl_dup3 546# define dup3 rpl_dup3
@@ -380,10 +562,23 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
380 562
381 563
382#if @GNULIB_ENVIRON@ 564#if @GNULIB_ENVIRON@
565# if defined __CYGWIN__ && !defined __i386__
566/* The 'environ' variable is defined in a DLL. Therefore its declaration needs
567 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
568 This leads to a link error on 64-bit Cygwin when the option
569 -Wl,--disable-auto-import is in use. */
570_GL_EXTERN_C __declspec(dllimport) char **environ;
571# endif
383# if !@HAVE_DECL_ENVIRON@ 572# if !@HAVE_DECL_ENVIRON@
384/* Set of environment variables and values. An array of strings of the form 573/* Set of environment variables and values. An array of strings of the form
385 "VARIABLE=VALUE", terminated with a NULL. */ 574 "VARIABLE=VALUE", terminated with a NULL. */
386# if defined __APPLE__ && defined __MACH__ 575# if defined __APPLE__ && defined __MACH__
576# include <TargetConditionals.h>
577# if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
578# define _GL_USE_CRT_EXTERNS
579# endif
580# endif
581# ifdef _GL_USE_CRT_EXTERNS
387# include <crt_externs.h> 582# include <crt_externs.h>
388# define environ (*_NSGetEnviron ()) 583# define environ (*_NSGetEnviron ())
389# else 584# else
@@ -399,12 +594,12 @@ extern char **environ;
399#elif defined GNULIB_POSIXCHECK 594#elif defined GNULIB_POSIXCHECK
400# if HAVE_RAW_DECL_ENVIRON 595# if HAVE_RAW_DECL_ENVIRON
401_GL_UNISTD_INLINE char *** 596_GL_UNISTD_INLINE char ***
597_GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
598 "use gnulib module environ for portability")
402rpl_environ (void) 599rpl_environ (void)
403{ 600{
404 return &environ; 601 return &environ;
405} 602}
406_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
407 "use gnulib module environ for portability");
408# undef environ 603# undef environ
409# define environ (*rpl_environ ()) 604# define environ (*rpl_environ ())
410# endif 605# endif
@@ -434,14 +629,302 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
434#endif 629#endif
435 630
436 631
632#if @GNULIB_EXECL@
633# if @REPLACE_EXECL@
634# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
635# undef execl
636# define execl rpl_execl
637# endif
638_GL_FUNCDECL_RPL (execl, int, (const char *program, const char *arg, ...)
639 _GL_ARG_NONNULL ((1)));
640_GL_CXXALIAS_RPL (execl, int, (const char *program, const char *arg, ...));
641# else
642_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
643# endif
644_GL_CXXALIASWARN (execl);
645#elif defined GNULIB_POSIXCHECK
646# undef execl
647# if HAVE_RAW_DECL_EXECL
648_GL_WARN_ON_USE (execl, "execl behaves very differently on mingw - "
649 "use gnulib module execl for portability");
650# endif
651#elif @GNULIB_MDA_EXECL@
652/* On native Windows, map 'execl' to '_execl', so that -loldnames is not
653 required. In C++ with GNULIB_NAMESPACE, avoid differences between
654 platforms by defining GNULIB_NAMESPACE::execl always. */
655# if defined _WIN32 && !defined __CYGWIN__
656# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
657# undef execl
658# define execl _execl
659# endif
660_GL_CXXALIAS_MDA (execl, intptr_t, (const char *program, const char *arg, ...));
661# else
662_GL_CXXALIAS_SYS (execl, int, (const char *program, const char *arg, ...));
663# endif
664_GL_CXXALIASWARN (execl);
665#endif
666
667#if @GNULIB_EXECLE@
668# if @REPLACE_EXECLE@
669# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
670# undef execle
671# define execle rpl_execle
672# endif
673_GL_FUNCDECL_RPL (execle, int, (const char *program, const char *arg, ...)
674 _GL_ARG_NONNULL ((1)));
675_GL_CXXALIAS_RPL (execle, int, (const char *program, const char *arg, ...));
676# else
677_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
678# endif
679_GL_CXXALIASWARN (execle);
680#elif defined GNULIB_POSIXCHECK
681# undef execle
682# if HAVE_RAW_DECL_EXECLE
683_GL_WARN_ON_USE (execle, "execle behaves very differently on mingw - "
684 "use gnulib module execle for portability");
685# endif
686#elif @GNULIB_MDA_EXECLE@
687/* On native Windows, map 'execle' to '_execle', so that -loldnames is not
688 required. In C++ with GNULIB_NAMESPACE, avoid differences between
689 platforms by defining GNULIB_NAMESPACE::execle always. */
690# if defined _WIN32 && !defined __CYGWIN__
691# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692# undef execle
693# define execle _execle
694# endif
695_GL_CXXALIAS_MDA (execle, intptr_t,
696 (const char *program, const char *arg, ...));
697# else
698_GL_CXXALIAS_SYS (execle, int, (const char *program, const char *arg, ...));
699# endif
700_GL_CXXALIASWARN (execle);
701#endif
702
703#if @GNULIB_EXECLP@
704# if @REPLACE_EXECLP@
705# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706# undef execlp
707# define execlp rpl_execlp
708# endif
709_GL_FUNCDECL_RPL (execlp, int, (const char *program, const char *arg, ...)
710 _GL_ARG_NONNULL ((1)));
711_GL_CXXALIAS_RPL (execlp, int, (const char *program, const char *arg, ...));
712# else
713_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
714# endif
715_GL_CXXALIASWARN (execlp);
716#elif defined GNULIB_POSIXCHECK
717# undef execlp
718# if HAVE_RAW_DECL_EXECLP
719_GL_WARN_ON_USE (execlp, "execlp behaves very differently on mingw - "
720 "use gnulib module execlp for portability");
721# endif
722#elif @GNULIB_MDA_EXECLP@
723/* On native Windows, map 'execlp' to '_execlp', so that -loldnames is not
724 required. In C++ with GNULIB_NAMESPACE, avoid differences between
725 platforms by defining GNULIB_NAMESPACE::execlp always. */
726# if defined _WIN32 && !defined __CYGWIN__
727# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
728# undef execlp
729# define execlp _execlp
730# endif
731_GL_CXXALIAS_MDA (execlp, intptr_t,
732 (const char *program, const char *arg, ...));
733# else
734_GL_CXXALIAS_SYS (execlp, int, (const char *program, const char *arg, ...));
735# endif
736_GL_CXXALIASWARN (execlp);
737#endif
738
739
740#if @GNULIB_EXECV@
741# if @REPLACE_EXECV@
742# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
743# undef execv
744# define execv rpl_execv
745# endif
746_GL_FUNCDECL_RPL (execv, int, (const char *program, char * const *argv)
747 _GL_ARG_NONNULL ((1, 2)));
748_GL_CXXALIAS_RPL (execv, int, (const char *program, char * const *argv));
749# else
750_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
751# endif
752_GL_CXXALIASWARN (execv);
753#elif defined GNULIB_POSIXCHECK
754# undef execv
755# if HAVE_RAW_DECL_EXECV
756_GL_WARN_ON_USE (execv, "execv behaves very differently on mingw - "
757 "use gnulib module execv for portability");
758# endif
759#elif @GNULIB_MDA_EXECV@
760/* On native Windows, map 'execv' to '_execv', so that -loldnames is not
761 required. In C++ with GNULIB_NAMESPACE, avoid differences between
762 platforms by defining GNULIB_NAMESPACE::execv always. */
763# if defined _WIN32 && !defined __CYGWIN__
764# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765# undef execv
766# define execv _execv
767# endif
768_GL_CXXALIAS_MDA_CAST (execv, intptr_t,
769 (const char *program, char * const *argv));
770# else
771_GL_CXXALIAS_SYS (execv, int, (const char *program, char * const *argv));
772# endif
773_GL_CXXALIASWARN (execv);
774#endif
775
776#if @GNULIB_EXECVE@
777# if @REPLACE_EXECVE@
778# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
779# undef execve
780# define execve rpl_execve
781# endif
782_GL_FUNCDECL_RPL (execve, int,
783 (const char *program, char * const *argv, char * const *env)
784 _GL_ARG_NONNULL ((1, 2)));
785_GL_CXXALIAS_RPL (execve, int,
786 (const char *program, char * const *argv, char * const *env));
787# else
788_GL_CXXALIAS_SYS (execve, int,
789 (const char *program, char * const *argv, char * const *env));
790# endif
791_GL_CXXALIASWARN (execve);
792#elif defined GNULIB_POSIXCHECK
793# undef execve
794# if HAVE_RAW_DECL_EXECVE
795_GL_WARN_ON_USE (execve, "execve behaves very differently on mingw - "
796 "use gnulib module execve for portability");
797# endif
798#elif @GNULIB_MDA_EXECVE@
799/* On native Windows, map 'execve' to '_execve', so that -loldnames is not
800 required. In C++ with GNULIB_NAMESPACE, avoid differences between
801 platforms by defining GNULIB_NAMESPACE::execve always. */
802# if defined _WIN32 && !defined __CYGWIN__
803# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804# undef execve
805# define execve _execve
806# endif
807_GL_CXXALIAS_MDA_CAST (execve, intptr_t,
808 (const char *program, char * const *argv,
809 char * const *env));
810# else
811_GL_CXXALIAS_SYS (execve, int,
812 (const char *program, char * const *argv, char * const *env));
813# endif
814_GL_CXXALIASWARN (execve);
815#endif
816
817#if @GNULIB_EXECVP@
818# if @REPLACE_EXECVP@
819# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
820# undef execvp
821# define execvp rpl_execvp
822# endif
823_GL_FUNCDECL_RPL (execvp, int, (const char *program, char * const *argv)
824 _GL_ARG_NONNULL ((1, 2)));
825_GL_CXXALIAS_RPL (execvp, int, (const char *program, char * const *argv));
826# else
827_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
828# endif
829_GL_CXXALIASWARN (execvp);
830#elif defined GNULIB_POSIXCHECK
831# undef execvp
832# if HAVE_RAW_DECL_EXECVP
833_GL_WARN_ON_USE (execvp, "execvp behaves very differently on mingw - "
834 "use gnulib module execvp for portability");
835# endif
836#elif @GNULIB_MDA_EXECVP@
837/* On native Windows, map 'execvp' to '_execvp', so that -loldnames is not
838 required. In C++ with GNULIB_NAMESPACE, avoid differences between
839 platforms by defining GNULIB_NAMESPACE::execvp always. */
840# if defined _WIN32 && !defined __CYGWIN__
841# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
842# undef execvp
843# define execvp _execvp
844# endif
845_GL_CXXALIAS_MDA_CAST (execvp, intptr_t,
846 (const char *program, char * const *argv));
847# else
848_GL_CXXALIAS_SYS (execvp, int, (const char *program, char * const *argv));
849# endif
850_GL_CXXALIASWARN (execvp);
851#endif
852
853#if @GNULIB_EXECVPE@
854# if @REPLACE_EXECVPE@
855# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
856# undef execvpe
857# define execvpe rpl_execvpe
858# endif
859_GL_FUNCDECL_RPL (execvpe, int,
860 (const char *program, char * const *argv, char * const *env)
861 _GL_ARG_NONNULL ((1, 2)));
862_GL_CXXALIAS_RPL (execvpe, int,
863 (const char *program, char * const *argv, char * const *env));
864# else
865# if !@HAVE_DECL_EXECVPE@
866_GL_FUNCDECL_SYS (execvpe, int,
867 (const char *program, char * const *argv, char * const *env)
868 _GL_ARG_NONNULL ((1, 2)));
869# endif
870_GL_CXXALIAS_SYS (execvpe, int,
871 (const char *program, char * const *argv, char * const *env));
872# endif
873_GL_CXXALIASWARN (execvpe);
874#elif defined GNULIB_POSIXCHECK
875# undef execvpe
876# if HAVE_RAW_DECL_EXECVPE
877_GL_WARN_ON_USE (execvpe, "execvpe behaves very differently on mingw - "
878 "use gnulib module execvpe for portability");
879# endif
880#elif @GNULIB_MDA_EXECVPE@
881/* On native Windows, map 'execvpe' to '_execvpe', so that -loldnames is not
882 required. In C++ with GNULIB_NAMESPACE, avoid differences between
883 platforms by defining GNULIB_NAMESPACE::execvpe on all platforms that have
884 it. */
885# if defined _WIN32 && !defined __CYGWIN__
886# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
887# undef execvpe
888# define execvpe _execvpe
889# endif
890_GL_CXXALIAS_MDA_CAST (execvpe, intptr_t,
891 (const char *program, char * const *argv,
892 char * const *env));
893# elif @HAVE_EXECVPE@
894# if !@HAVE_DECL_EXECVPE@
895_GL_FUNCDECL_SYS (execvpe, int,
896 (const char *program, char * const *argv, char * const *env)
897 _GL_ARG_NONNULL ((1, 2)));
898# endif
899_GL_CXXALIAS_SYS (execvpe, int,
900 (const char *program, char * const *argv, char * const *env));
901# endif
902# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_EXECVPE@
903_GL_CXXALIASWARN (execvpe);
904# endif
905#endif
906
907
437#if @GNULIB_FACCESSAT@ 908#if @GNULIB_FACCESSAT@
438# if !@HAVE_FACCESSAT@ 909# if @REPLACE_FACCESSAT@
910# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
911# undef faccessat
912# define faccessat rpl_faccessat
913# endif
914_GL_FUNCDECL_RPL (faccessat, int,
915 (int fd, char const *name, int mode, int flag)
916 _GL_ARG_NONNULL ((2)));
917_GL_CXXALIAS_RPL (faccessat, int,
918 (int fd, char const *name, int mode, int flag));
919# else
920# if !@HAVE_FACCESSAT@
439_GL_FUNCDECL_SYS (faccessat, int, 921_GL_FUNCDECL_SYS (faccessat, int,
440 (int fd, char const *file, int mode, int flag) 922 (int fd, char const *file, int mode, int flag)
441 _GL_ARG_NONNULL ((2))); 923 _GL_ARG_NONNULL ((2)));
442# endif 924# endif
443_GL_CXXALIAS_SYS (faccessat, int, 925_GL_CXXALIAS_SYS (faccessat, int,
444 (int fd, char const *file, int mode, int flag)); 926 (int fd, char const *file, int mode, int flag));
927# endif
445_GL_CXXALIASWARN (faccessat); 928_GL_CXXALIASWARN (faccessat);
446#elif defined GNULIB_POSIXCHECK 929#elif defined GNULIB_POSIXCHECK
447# undef faccessat 930# undef faccessat
@@ -457,7 +940,7 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
457 the given file descriptor is open. 940 the given file descriptor is open.
458 Return 0 if successful, otherwise -1 and errno set. 941 Return 0 if successful, otherwise -1 and errno set.
459 See the POSIX:2008 specification 942 See the POSIX:2008 specification
460 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */ 943 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
461# if ! @HAVE_FCHDIR@ 944# if ! @HAVE_FCHDIR@
462_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); 945_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
463 946
@@ -509,7 +992,7 @@ _GL_CXXALIASWARN (fchownat);
509# undef fchownat 992# undef fchownat
510# if HAVE_RAW_DECL_FCHOWNAT 993# if HAVE_RAW_DECL_FCHOWNAT
511_GL_WARN_ON_USE (fchownat, "fchownat is not portable - " 994_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
512 "use gnulib module openat for portability"); 995 "use gnulib module fchownat for portability");
513# endif 996# endif
514#endif 997#endif
515 998
@@ -518,7 +1001,7 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
518/* Synchronize changes to a file. 1001/* Synchronize changes to a file.
519 Return 0 if successful, otherwise -1 and errno set. 1002 Return 0 if successful, otherwise -1 and errno set.
520 See POSIX:2008 specification 1003 See POSIX:2008 specification
521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */ 1004 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
522# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ 1005# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
523_GL_FUNCDECL_SYS (fdatasync, int, (int fd)); 1006_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
524# endif 1007# endif
@@ -537,7 +1020,7 @@ _GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
537/* Synchronize changes, including metadata, to a file. 1020/* Synchronize changes, including metadata, to a file.
538 Return 0 if successful, otherwise -1 and errno set. 1021 Return 0 if successful, otherwise -1 and errno set.
539 See POSIX:2008 specification 1022 See POSIX:2008 specification
540 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */ 1023 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
541# if !@HAVE_FSYNC@ 1024# if !@HAVE_FSYNC@
542_GL_FUNCDECL_SYS (fsync, int, (int fd)); 1025_GL_FUNCDECL_SYS (fsync, int, (int fd));
543# endif 1026# endif
@@ -556,7 +1039,7 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
556/* Change the size of the file to which FD is opened to become equal to LENGTH. 1039/* Change the size of the file to which FD is opened to become equal to LENGTH.
557 Return 0 if successful, otherwise -1 and errno set. 1040 Return 0 if successful, otherwise -1 and errno set.
558 See the POSIX:2008 specification 1041 See the POSIX:2008 specification
559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */ 1042 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
560# if @REPLACE_FTRUNCATE@ 1043# if @REPLACE_FTRUNCATE@
561# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1044# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
562# undef ftruncate 1045# undef ftruncate
@@ -586,7 +1069,7 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
586 Return BUF if successful, or NULL if the directory couldn't be determined 1069 Return BUF if successful, or NULL if the directory couldn't be determined
587 or SIZE was too small. 1070 or SIZE was too small.
588 See the POSIX:2008 specification 1071 See the POSIX:2008 specification
589 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>. 1072 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
590 Additionally, the gnulib module 'getcwd' guarantees the following GNU 1073 Additionally, the gnulib module 'getcwd' guarantees the following GNU
591 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 1074 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
592 is SIZE bytes long, unless SIZE == 0, in which case it is as big as 1075 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
@@ -597,6 +1080,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
597# endif 1080# endif
598_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); 1081_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
599_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); 1082_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
1083# elif defined _WIN32 && !defined __CYGWIN__
1084# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1085# undef getcwd
1086# define getcwd _getcwd
1087# endif
1088_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size));
600# else 1089# else
601/* Need to cast, because on mingw, the second parameter is 1090/* Need to cast, because on mingw, the second parameter is
602 int size. */ 1091 int size. */
@@ -609,6 +1098,22 @@ _GL_CXXALIASWARN (getcwd);
609_GL_WARN_ON_USE (getcwd, "getcwd is unportable - " 1098_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
610 "use gnulib module getcwd for portability"); 1099 "use gnulib module getcwd for portability");
611# endif 1100# endif
1101#elif @GNULIB_MDA_GETCWD@
1102/* On native Windows, map 'getcwd' to '_getcwd', so that -loldnames is not
1103 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1104 platforms by defining GNULIB_NAMESPACE::getcwd always. */
1105# if defined _WIN32 && !defined __CYGWIN__
1106# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1107# undef getcwd
1108# define getcwd _getcwd
1109# endif
1110/* Need to cast, because on mingw, the second parameter is either
1111 'int size' or 'size_t size'. */
1112_GL_CXXALIAS_MDA_CAST (getcwd, char *, (char *buf, size_t size));
1113# else
1114_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
1115# endif
1116_GL_CXXALIASWARN (getcwd);
612#endif 1117#endif
613 1118
614 1119
@@ -638,7 +1143,9 @@ _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
638# endif 1143# endif
639_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); 1144_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
640# endif 1145# endif
1146# if __GLIBC__ >= 2
641_GL_CXXALIASWARN (getdomainname); 1147_GL_CXXALIASWARN (getdomainname);
1148# endif
642#elif defined GNULIB_POSIXCHECK 1149#elif defined GNULIB_POSIXCHECK
643# undef getdomainname 1150# undef getdomainname
644# if HAVE_RAW_DECL_GETDOMAINNAME 1151# if HAVE_RAW_DECL_GETDOMAINNAME
@@ -651,10 +1158,21 @@ _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
651#if @GNULIB_GETDTABLESIZE@ 1158#if @GNULIB_GETDTABLESIZE@
652/* Return the maximum number of file descriptors in the current process. 1159/* Return the maximum number of file descriptors in the current process.
653 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ 1160 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
654# if !@HAVE_GETDTABLESIZE@ 1161# if @REPLACE_GETDTABLESIZE@
1162# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1163# undef getdtablesize
1164# define getdtablesize rpl_getdtablesize
1165# endif
1166_GL_FUNCDECL_RPL (getdtablesize, int, (void));
1167_GL_CXXALIAS_RPL (getdtablesize, int, (void));
1168# else
1169# if !@HAVE_GETDTABLESIZE@
655_GL_FUNCDECL_SYS (getdtablesize, int, (void)); 1170_GL_FUNCDECL_SYS (getdtablesize, int, (void));
1171# endif
1172/* Need to cast, because on AIX, the parameter list is
1173 (...). */
1174_GL_CXXALIAS_SYS_CAST (getdtablesize, int, (void));
656# endif 1175# endif
657_GL_CXXALIAS_SYS (getdtablesize, int, (void));
658_GL_CXXALIASWARN (getdtablesize); 1176_GL_CXXALIASWARN (getdtablesize);
659#elif defined GNULIB_POSIXCHECK 1177#elif defined GNULIB_POSIXCHECK
660# undef getdtablesize 1178# undef getdtablesize
@@ -665,6 +1183,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
665#endif 1183#endif
666 1184
667 1185
1186#if @GNULIB_GETENTROPY@
1187/* Fill a buffer with random bytes. */
1188# if !@HAVE_GETENTROPY@
1189_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
1190# endif
1191_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
1192_GL_CXXALIASWARN (getentropy);
1193#elif defined GNULIB_POSIXCHECK
1194# undef getentropy
1195# if HAVE_RAW_DECL_GETENTROPY
1196_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
1197 "use gnulib module getentropy for portability");
1198# endif
1199#endif
1200
1201
668#if @GNULIB_GETGROUPS@ 1202#if @GNULIB_GETGROUPS@
669/* Return the supplemental groups that the current process belongs to. 1203/* Return the supplemental groups that the current process belongs to.
670 It is unspecified whether the effective group id is in the list. 1204 It is unspecified whether the effective group id is in the list.
@@ -737,14 +1271,14 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
737/* Returns the user's login name, or NULL if it cannot be found. Upon error, 1271/* Returns the user's login name, or NULL if it cannot be found. Upon error,
738 returns NULL with errno set. 1272 returns NULL with errno set.
739 1273
740 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1274 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
741 1275
742 Most programs don't need to use this function, because the information is 1276 Most programs don't need to use this function, because the information is
743 available through environment variables: 1277 available through environment variables:
744 ${LOGNAME-$USER} on Unix platforms, 1278 ${LOGNAME-$USER} on Unix platforms,
745 $USERNAME on native Windows platforms. 1279 $USERNAME on native Windows platforms.
746 */ 1280 */
747# if !@HAVE_GETLOGIN@ 1281# if !@HAVE_DECL_GETLOGIN@
748_GL_FUNCDECL_SYS (getlogin, char *, (void)); 1282_GL_FUNCDECL_SYS (getlogin, char *, (void));
749# endif 1283# endif
750_GL_CXXALIAS_SYS (getlogin, char *, (void)); 1284_GL_CXXALIAS_SYS (getlogin, char *, (void));
@@ -766,7 +1300,7 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
766 the case that the login name cannot be found but no specific error is 1300 the case that the login name cannot be found but no specific error is
767 provided (this case is hopefully rare but is left open by the POSIX spec). 1301 provided (this case is hopefully rare but is left open by the POSIX spec).
768 1302
769 See <http://www.opengroup.org/susv3xsh/getlogin.html>. 1303 See <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html>.
770 1304
771 Most programs don't need to use this function, because the information is 1305 Most programs don't need to use this function, because the information is
772 available through environment variables: 1306 available through environment variables:
@@ -807,6 +1341,11 @@ _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
807_GL_FUNCDECL_RPL (getpagesize, int, (void)); 1341_GL_FUNCDECL_RPL (getpagesize, int, (void));
808_GL_CXXALIAS_RPL (getpagesize, int, (void)); 1342_GL_CXXALIAS_RPL (getpagesize, int, (void));
809# else 1343# else
1344/* On HP-UX, getpagesize exists, but it is not declared in <unistd.h> even if
1345 the compiler options -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 are used. */
1346# if defined __hpux
1347_GL_FUNCDECL_SYS (getpagesize, int, (void));
1348# endif
810# if !@HAVE_GETPAGESIZE@ 1349# if !@HAVE_GETPAGESIZE@
811# if !defined getpagesize 1350# if !defined getpagesize
812/* This is for POSIX systems. */ 1351/* This is for POSIX systems. */
@@ -881,6 +1420,54 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
881#endif 1420#endif
882 1421
883 1422
1423#if @GNULIB_GETPASS@
1424/* Function getpass() from module 'getpass':
1425 Read a password from /dev/tty or stdin.
1426 Function getpass() from module 'getpass-gnu':
1427 Read a password of arbitrary length from /dev/tty or stdin. */
1428# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
1429 || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
1430# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1431# undef getpass
1432# define getpass rpl_getpass
1433# endif
1434_GL_FUNCDECL_RPL (getpass, char *, (const char *prompt)
1435 _GL_ARG_NONNULL ((1)));
1436_GL_CXXALIAS_RPL (getpass, char *, (const char *prompt));
1437# else
1438# if !@HAVE_GETPASS@
1439_GL_FUNCDECL_SYS (getpass, char *, (const char *prompt)
1440 _GL_ARG_NONNULL ((1)));
1441# endif
1442_GL_CXXALIAS_SYS (getpass, char *, (const char *prompt));
1443# endif
1444_GL_CXXALIASWARN (getpass);
1445#elif defined GNULIB_POSIXCHECK
1446# undef getpass
1447# if HAVE_RAW_DECL_GETPASS
1448_GL_WARN_ON_USE (getpass, "getpass is unportable - "
1449 "use gnulib module getpass or getpass-gnu for portability");
1450# endif
1451#endif
1452
1453
1454#if @GNULIB_MDA_GETPID@
1455/* On native Windows, map 'getpid' to '_getpid', so that -loldnames is not
1456 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1457 platforms by defining GNULIB_NAMESPACE::getpid always. */
1458# if defined _WIN32 && !defined __CYGWIN__
1459# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1460# undef getpid
1461# define getpid _getpid
1462# endif
1463_GL_CXXALIAS_MDA (getpid, int, (void));
1464# else
1465_GL_CXXALIAS_SYS (getpid, pid_t, (void));
1466# endif
1467_GL_CXXALIASWARN (getpid);
1468#endif
1469
1470
884#if @GNULIB_GETUSERSHELL@ 1471#if @GNULIB_GETUSERSHELL@
885/* Return the next valid login shell on the system, or NULL when the end of 1472/* Return the next valid login shell on the system, or NULL when the end of
886 the list has been reached. */ 1473 the list has been reached. */
@@ -951,8 +1538,15 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - "
951# undef isatty 1538# undef isatty
952# define isatty rpl_isatty 1539# define isatty rpl_isatty
953# endif 1540# endif
1541# define GNULIB_defined_isatty 1
954_GL_FUNCDECL_RPL (isatty, int, (int fd)); 1542_GL_FUNCDECL_RPL (isatty, int, (int fd));
955_GL_CXXALIAS_RPL (isatty, int, (int fd)); 1543_GL_CXXALIAS_RPL (isatty, int, (int fd));
1544# elif defined _WIN32 && !defined __CYGWIN__
1545# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1546# undef isatty
1547# define isatty _isatty
1548# endif
1549_GL_CXXALIAS_MDA (isatty, int, (int fd));
956# else 1550# else
957_GL_CXXALIAS_SYS (isatty, int, (int fd)); 1551_GL_CXXALIAS_SYS (isatty, int, (int fd));
958# endif 1552# endif
@@ -963,6 +1557,20 @@ _GL_CXXALIASWARN (isatty);
963_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " 1557_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability"); 1558 "use gnulib module isatty for portability");
965# endif 1559# endif
1560#elif @GNULIB_MDA_ISATTY@
1561/* On native Windows, map 'isatty' to '_isatty', so that -loldnames is not
1562 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1563 platforms by defining GNULIB_NAMESPACE::isatty always. */
1564# if defined _WIN32 && !defined __CYGWIN__
1565# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1566# undef isatty
1567# define isatty _isatty
1568# endif
1569_GL_CXXALIAS_MDA (isatty, int, (int fd));
1570# else
1571_GL_CXXALIAS_SYS (isatty, int, (int fd));
1572# endif
1573_GL_CXXALIASWARN (isatty);
966#endif 1574#endif
967 1575
968 1576
@@ -971,7 +1579,7 @@ _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
971 to GID (if GID is not -1). Do not follow symbolic links. 1579 to GID (if GID is not -1). Do not follow symbolic links.
972 Return 0 if successful, otherwise -1 and errno set. 1580 Return 0 if successful, otherwise -1 and errno set.
973 See the POSIX:2008 specification 1581 See the POSIX:2008 specification
974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */ 1582 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
975# if @REPLACE_LCHOWN@ 1583# if @REPLACE_LCHOWN@
976# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1584# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977# undef lchown 1585# undef lchown
@@ -1001,7 +1609,7 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1001/* Create a new hard link for an existing file. 1609/* Create a new hard link for an existing file.
1002 Return 0 if successful, otherwise -1 and errno set. 1610 Return 0 if successful, otherwise -1 and errno set.
1003 See POSIX:2008 specification 1611 See POSIX:2008 specification
1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */ 1612 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1005# if @REPLACE_LINK@ 1613# if @REPLACE_LINK@
1006# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1614# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1007# define link rpl_link 1615# define link rpl_link
@@ -1067,13 +1675,19 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
1067/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 1675/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1068 Return the new offset if successful, otherwise -1 and errno set. 1676 Return the new offset if successful, otherwise -1 and errno set.
1069 See the POSIX:2008 specification 1677 See the POSIX:2008 specification
1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */ 1678 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1071# if @REPLACE_LSEEK@ 1679# if @REPLACE_LSEEK@
1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1680# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073# define lseek rpl_lseek 1681# define lseek rpl_lseek
1074# endif 1682# endif
1075_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1683_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1076_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); 1684_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1685# elif defined _WIN32 && !defined __CYGWIN__
1686# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1687# undef lseek
1688# define lseek _lseek
1689# endif
1690_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence));
1077# else 1691# else
1078_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); 1692_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1079# endif 1693# endif
@@ -1084,6 +1698,20 @@ _GL_CXXALIASWARN (lseek);
1084_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " 1698_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1085 "systems - use gnulib module lseek for portability"); 1699 "systems - use gnulib module lseek for portability");
1086# endif 1700# endif
1701#elif @GNULIB_MDA_LSEEK@
1702/* On native Windows, map 'lseek' to '_lseek', so that -loldnames is not
1703 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1704 platforms by defining GNULIB_NAMESPACE::lseek always. */
1705# if defined _WIN32 && !defined __CYGWIN__
1706# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1707# undef lseek
1708# define lseek _lseek
1709# endif
1710_GL_CXXALIAS_MDA (lseek, long, (int fd, long offset, int whence));
1711# else
1712_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1713# endif
1714_GL_CXXALIASWARN (lseek);
1087#endif 1715#endif
1088 1716
1089 1717
@@ -1113,7 +1741,7 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
1113 Store the read-end as fd[0] and the write-end as fd[1]. 1741 Store the read-end as fd[0] and the write-end as fd[1].
1114 Return 0 upon success, or -1 with errno set upon failure. 1742 Return 0 upon success, or -1 with errno set upon failure.
1115 See also the Linux man page at 1743 See also the Linux man page at
1116 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ 1744 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1117# if @HAVE_PIPE2@ 1745# if @HAVE_PIPE2@
1118# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1746# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1119# define pipe2 rpl_pipe2 1747# define pipe2 rpl_pipe2
@@ -1139,7 +1767,7 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1139 Return the number of bytes placed into BUF if successful, otherwise 1767 Return the number of bytes placed into BUF if successful, otherwise
1140 set errno and return -1. 0 indicates EOF. 1768 set errno and return -1. 0 indicates EOF.
1141 See the POSIX:2008 specification 1769 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */ 1770 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1143# if @REPLACE_PREAD@ 1771# if @REPLACE_PREAD@
1144# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1772# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145# undef pread 1773# undef pread
@@ -1174,7 +1802,7 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1174 Return the number of bytes written if successful, otherwise 1802 Return the number of bytes written if successful, otherwise
1175 set errno and return -1. 0 indicates nothing written. See the 1803 set errno and return -1. 0 indicates nothing written. See the
1176 POSIX:2008 specification 1804 POSIX:2008 specification
1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */ 1805 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1178# if @REPLACE_PWRITE@ 1806# if @REPLACE_PWRITE@
1179# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1807# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1180# undef pwrite 1808# undef pwrite
@@ -1207,7 +1835,7 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1207#if @GNULIB_READ@ 1835#if @GNULIB_READ@
1208/* Read up to COUNT bytes from file descriptor FD into the buffer starting 1836/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification 1837 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */ 1838 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1211# if @REPLACE_READ@ 1839# if @REPLACE_READ@
1212# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1840# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213# undef read 1841# undef read
@@ -1216,11 +1844,32 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1216_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) 1844_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1217 _GL_ARG_NONNULL ((2))); 1845 _GL_ARG_NONNULL ((2)));
1218_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); 1846_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1847# elif defined _WIN32 && !defined __CYGWIN__
1848# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1849# undef read
1850# define read _read
1851# endif
1852_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count));
1853# else
1854_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1855# endif
1856_GL_CXXALIASWARN (read);
1857#elif @GNULIB_MDA_READ@
1858/* On native Windows, map 'read' to '_read', so that -loldnames is not
1859 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1860 platforms by defining GNULIB_NAMESPACE::read always. */
1861# if defined _WIN32 && !defined __CYGWIN__
1862# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1863# undef read
1864# define read _read
1865# endif
1866# ifdef __MINGW32__
1867_GL_CXXALIAS_MDA (read, int, (int fd, void *buf, unsigned int count));
1868# else
1869_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, unsigned int count));
1870# endif
1219# else 1871# else
1220/* Need to cast, because on mingw, the third parameter is 1872_GL_CXXALIAS_SYS (read, ssize_t, (int fd, void *buf, size_t count));
1221 unsigned int count
1222 and the return type is 'int'. */
1223_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1224# endif 1873# endif
1225_GL_CXXALIASWARN (read); 1874_GL_CXXALIASWARN (read);
1226#endif 1875#endif
@@ -1231,24 +1880,28 @@ _GL_CXXALIASWARN (read);
1231 bytes of it into BUF. Return the number of bytes placed into BUF if 1880 bytes of it into BUF. Return the number of bytes placed into BUF if
1232 successful, otherwise -1 and errno set. 1881 successful, otherwise -1 and errno set.
1233 See the POSIX:2008 specification 1882 See the POSIX:2008 specification
1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */ 1883 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1235# if @REPLACE_READLINK@ 1884# if @REPLACE_READLINK@
1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1885# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1237# define readlink rpl_readlink 1886# define readlink rpl_readlink
1238# endif 1887# endif
1239_GL_FUNCDECL_RPL (readlink, ssize_t, 1888_GL_FUNCDECL_RPL (readlink, ssize_t,
1240 (const char *file, char *buf, size_t bufsize) 1889 (const char *restrict file,
1890 char *restrict buf, size_t bufsize)
1241 _GL_ARG_NONNULL ((1, 2))); 1891 _GL_ARG_NONNULL ((1, 2)));
1242_GL_CXXALIAS_RPL (readlink, ssize_t, 1892_GL_CXXALIAS_RPL (readlink, ssize_t,
1243 (const char *file, char *buf, size_t bufsize)); 1893 (const char *restrict file,
1894 char *restrict buf, size_t bufsize));
1244# else 1895# else
1245# if !@HAVE_READLINK@ 1896# if !@HAVE_READLINK@
1246_GL_FUNCDECL_SYS (readlink, ssize_t, 1897_GL_FUNCDECL_SYS (readlink, ssize_t,
1247 (const char *file, char *buf, size_t bufsize) 1898 (const char *restrict file,
1899 char *restrict buf, size_t bufsize)
1248 _GL_ARG_NONNULL ((1, 2))); 1900 _GL_ARG_NONNULL ((1, 2)));
1249# endif 1901# endif
1250_GL_CXXALIAS_SYS (readlink, ssize_t, 1902_GL_CXXALIAS_SYS (readlink, ssize_t,
1251 (const char *file, char *buf, size_t bufsize)); 1903 (const char *restrict file,
1904 char *restrict buf, size_t bufsize));
1252# endif 1905# endif
1253_GL_CXXALIASWARN (readlink); 1906_GL_CXXALIASWARN (readlink);
1254#elif defined GNULIB_POSIXCHECK 1907#elif defined GNULIB_POSIXCHECK
@@ -1261,13 +1914,28 @@ _GL_WARN_ON_USE (readlink, "readlink is unportable - "
1261 1914
1262 1915
1263#if @GNULIB_READLINKAT@ 1916#if @GNULIB_READLINKAT@
1264# if !@HAVE_READLINKAT@ 1917# if @REPLACE_READLINKAT@
1918# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1919# define readlinkat rpl_readlinkat
1920# endif
1921_GL_FUNCDECL_RPL (readlinkat, ssize_t,
1922 (int fd, char const *restrict file,
1923 char *restrict buf, size_t len)
1924 _GL_ARG_NONNULL ((2, 3)));
1925_GL_CXXALIAS_RPL (readlinkat, ssize_t,
1926 (int fd, char const *restrict file,
1927 char *restrict buf, size_t len));
1928# else
1929# if !@HAVE_READLINKAT@
1265_GL_FUNCDECL_SYS (readlinkat, ssize_t, 1930_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1266 (int fd, char const *file, char *buf, size_t len) 1931 (int fd, char const *restrict file,
1932 char *restrict buf, size_t len)
1267 _GL_ARG_NONNULL ((2, 3))); 1933 _GL_ARG_NONNULL ((2, 3)));
1268# endif 1934# endif
1269_GL_CXXALIAS_SYS (readlinkat, ssize_t, 1935_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1270 (int fd, char const *file, char *buf, size_t len)); 1936 (int fd, char const *restrict file,
1937 char *restrict buf, size_t len));
1938# endif
1271_GL_CXXALIASWARN (readlinkat); 1939_GL_CXXALIASWARN (readlinkat);
1272#elif defined GNULIB_POSIXCHECK 1940#elif defined GNULIB_POSIXCHECK
1273# undef readlinkat 1941# undef readlinkat
@@ -1286,6 +1954,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1286# endif 1954# endif
1287_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); 1955_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1288_GL_CXXALIAS_RPL (rmdir, int, (char const *name)); 1956_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1957# elif defined _WIN32 && !defined __CYGWIN__
1958# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1959# undef rmdir
1960# define rmdir _rmdir
1961# endif
1962_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1289# else 1963# else
1290_GL_CXXALIAS_SYS (rmdir, int, (char const *name)); 1964_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1291# endif 1965# endif
@@ -1296,6 +1970,20 @@ _GL_CXXALIASWARN (rmdir);
1296_GL_WARN_ON_USE (rmdir, "rmdir is unportable - " 1970_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1297 "use gnulib module rmdir for portability"); 1971 "use gnulib module rmdir for portability");
1298# endif 1972# endif
1973#elif @GNULIB_MDA_RMDIR@
1974/* On native Windows, map 'rmdir' to '_rmdir', so that -loldnames is not
1975 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1976 platforms by defining GNULIB_NAMESPACE::rmdir always. */
1977# if defined _WIN32 && !defined __CYGWIN__
1978# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1979# undef rmdir
1980# define rmdir _rmdir
1981# endif
1982_GL_CXXALIAS_MDA (rmdir, int, (char const *name));
1983# else
1984_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1985# endif
1986_GL_CXXALIASWARN (rmdir);
1299#endif 1987#endif
1300 1988
1301 1989
@@ -1330,7 +2018,7 @@ _GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1330/* Pause the execution of the current thread for N seconds. 2018/* Pause the execution of the current thread for N seconds.
1331 Returns the number of seconds left to sleep. 2019 Returns the number of seconds left to sleep.
1332 See the POSIX:2008 specification 2020 See the POSIX:2008 specification
1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */ 2021 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1334# if @REPLACE_SLEEP@ 2022# if @REPLACE_SLEEP@
1335# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2023# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1336# undef sleep 2024# undef sleep
@@ -1354,6 +2042,31 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - "
1354#endif 2042#endif
1355 2043
1356 2044
2045#if @GNULIB_MDA_SWAB@
2046/* On native Windows, map 'swab' to '_swab', so that -loldnames is not
2047 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2048 platforms by defining GNULIB_NAMESPACE::swab always. */
2049# if defined _WIN32 && !defined __CYGWIN__
2050# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2051# undef swab
2052# define swab _swab
2053# endif
2054/* Need to cast, because in old mingw the arguments are
2055 (const char *from, char *to, size_t n). */
2056_GL_CXXALIAS_MDA_CAST (swab, void, (char *from, char *to, int n));
2057# else
2058# if defined __hpux /* HP-UX */
2059_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, int n));
2060# elif defined __sun && (defined __SunOS_5_10 || defined __XOPEN_OR_POSIX) && !defined _XPG4 /* Solaris */
2061_GL_CXXALIAS_SYS (swab, void, (const char *from, char *to, ssize_t n));
2062# else
2063_GL_CXXALIAS_SYS (swab, void, (const void *from, void *to, ssize_t n));
2064# endif
2065# endif
2066_GL_CXXALIASWARN (swab);
2067#endif
2068
2069
1357#if @GNULIB_SYMLINK@ 2070#if @GNULIB_SYMLINK@
1358# if @REPLACE_SYMLINK@ 2071# if @REPLACE_SYMLINK@
1359# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2072# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1381,13 +2094,25 @@ _GL_WARN_ON_USE (symlink, "symlink is not portable - "
1381 2094
1382 2095
1383#if @GNULIB_SYMLINKAT@ 2096#if @GNULIB_SYMLINKAT@
1384# if !@HAVE_SYMLINKAT@ 2097# if @REPLACE_SYMLINKAT@
2098# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2099# undef symlinkat
2100# define symlinkat rpl_symlinkat
2101# endif
2102_GL_FUNCDECL_RPL (symlinkat, int,
2103 (char const *contents, int fd, char const *file)
2104 _GL_ARG_NONNULL ((1, 3)));
2105_GL_CXXALIAS_RPL (symlinkat, int,
2106 (char const *contents, int fd, char const *file));
2107# else
2108# if !@HAVE_SYMLINKAT@
1385_GL_FUNCDECL_SYS (symlinkat, int, 2109_GL_FUNCDECL_SYS (symlinkat, int,
1386 (char const *contents, int fd, char const *file) 2110 (char const *contents, int fd, char const *file)
1387 _GL_ARG_NONNULL ((1, 3))); 2111 _GL_ARG_NONNULL ((1, 3)));
1388# endif 2112# endif
1389_GL_CXXALIAS_SYS (symlinkat, int, 2113_GL_CXXALIAS_SYS (symlinkat, int,
1390 (char const *contents, int fd, char const *file)); 2114 (char const *contents, int fd, char const *file));
2115# endif
1391_GL_CXXALIASWARN (symlinkat); 2116_GL_CXXALIASWARN (symlinkat);
1392#elif defined GNULIB_POSIXCHECK 2117#elif defined GNULIB_POSIXCHECK
1393# undef symlinkat 2118# undef symlinkat
@@ -1398,6 +2123,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1398#endif 2123#endif
1399 2124
1400 2125
2126#if @GNULIB_TRUNCATE@
2127/* Change the size of the file designated by FILENAME to become equal to LENGTH.
2128 Return 0 if successful, otherwise -1 and errno set.
2129 See the POSIX:2008 specification
2130 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
2131# if @REPLACE_TRUNCATE@
2132# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2133# undef truncate
2134# define truncate rpl_truncate
2135# endif
2136_GL_FUNCDECL_RPL (truncate, int, (const char *filename, off_t length)
2137 _GL_ARG_NONNULL ((1)));
2138_GL_CXXALIAS_RPL (truncate, int, (const char *filename, off_t length));
2139# else
2140# if !@HAVE_DECL_TRUNCATE@
2141_GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
2142 _GL_ARG_NONNULL ((1)));
2143# endif
2144_GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
2145# endif
2146_GL_CXXALIASWARN (truncate);
2147#elif defined GNULIB_POSIXCHECK
2148# undef truncate
2149# if HAVE_RAW_DECL_TRUNCATE
2150_GL_WARN_ON_USE (truncate, "truncate is unportable - "
2151 "use gnulib module truncate for portability");
2152# endif
2153#endif
2154
2155
1401#if @GNULIB_TTYNAME_R@ 2156#if @GNULIB_TTYNAME_R@
1402/* Store at most BUFLEN characters of the pathname of the terminal FD is 2157/* Store at most BUFLEN characters of the pathname of the terminal FD is
1403 open on in BUF. Return 0 on success, otherwise an error number. */ 2158 open on in BUF. Return 0 on success, otherwise an error number. */
@@ -1436,6 +2191,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1436# endif 2191# endif
1437_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); 2192_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1438_GL_CXXALIAS_RPL (unlink, int, (char const *file)); 2193_GL_CXXALIAS_RPL (unlink, int, (char const *file));
2194# elif defined _WIN32 && !defined __CYGWIN__
2195# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2196# undef unlink
2197# define unlink _unlink
2198# endif
2199_GL_CXXALIAS_MDA (unlink, int, (char const *file));
1439# else 2200# else
1440_GL_CXXALIAS_SYS (unlink, int, (char const *file)); 2201_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1441# endif 2202# endif
@@ -1446,6 +2207,20 @@ _GL_CXXALIASWARN (unlink);
1446_GL_WARN_ON_USE (unlink, "unlink is not portable - " 2207_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1447 "use gnulib module unlink for portability"); 2208 "use gnulib module unlink for portability");
1448# endif 2209# endif
2210#elif @GNULIB_MDA_UNLINK@
2211/* On native Windows, map 'unlink' to '_unlink', so that -loldnames is not
2212 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2213 platforms by defining GNULIB_NAMESPACE::unlink always. */
2214# if defined _WIN32 && !defined __CYGWIN__
2215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2216# undef unlink
2217# define unlink _unlink
2218# endif
2219_GL_CXXALIAS_MDA (unlink, int, (char const *file));
2220# else
2221_GL_CXXALIAS_SYS (unlink, int, (char const *file));
2222# endif
2223_GL_CXXALIASWARN (unlink);
1449#endif 2224#endif
1450 2225
1451 2226
@@ -1470,7 +2245,7 @@ _GL_CXXALIASWARN (unlinkat);
1470# undef unlinkat 2245# undef unlinkat
1471# if HAVE_RAW_DECL_UNLINKAT 2246# if HAVE_RAW_DECL_UNLINKAT
1472_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " 2247_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1473 "use gnulib module openat for portability"); 2248 "use gnulib module unlinkat for portability");
1474# endif 2249# endif
1475#endif 2250#endif
1476 2251
@@ -1479,7 +2254,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1479/* Pause the execution of the current thread for N microseconds. 2254/* Pause the execution of the current thread for N microseconds.
1480 Returns 0 on completion, or -1 on range error. 2255 Returns 0 on completion, or -1 on range error.
1481 See the POSIX:2001 specification 2256 See the POSIX:2001 specification
1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */ 2257 <https://pubs.opengroup.org/onlinepubs/009695399/functions/usleep.html>. */
1483# if @REPLACE_USLEEP@ 2258# if @REPLACE_USLEEP@
1484# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2259# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1485# undef usleep 2260# undef usleep
@@ -1491,7 +2266,9 @@ _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1491# if !@HAVE_USLEEP@ 2266# if !@HAVE_USLEEP@
1492_GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); 2267_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1493# endif 2268# endif
1494_GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); 2269/* Need to cast, because on Haiku, the first parameter is
2270 unsigned int n. */
2271_GL_CXXALIAS_SYS_CAST (usleep, int, (useconds_t n));
1495# endif 2272# endif
1496_GL_CXXALIASWARN (usleep); 2273_GL_CXXALIASWARN (usleep);
1497#elif defined GNULIB_POSIXCHECK 2274#elif defined GNULIB_POSIXCHECK
@@ -1506,7 +2283,7 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1506#if @GNULIB_WRITE@ 2283#if @GNULIB_WRITE@
1507/* Write up to COUNT bytes starting at BUF to file descriptor FD. 2284/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1508 See the POSIX:2008 specification 2285 See the POSIX:2008 specification
1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */ 2286 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1510# if @REPLACE_WRITE@ 2287# if @REPLACE_WRITE@
1511# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 2288# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1512# undef write 2289# undef write
@@ -1515,11 +2292,32 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1515_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) 2292_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1516 _GL_ARG_NONNULL ((2))); 2293 _GL_ARG_NONNULL ((2)));
1517_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 2294_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
2295# elif defined _WIN32 && !defined __CYGWIN__
2296# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2297# undef write
2298# define write _write
2299# endif
2300_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count));
2301# else
2302_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
2303# endif
2304_GL_CXXALIASWARN (write);
2305#elif @GNULIB_MDA_WRITE@
2306/* On native Windows, map 'write' to '_write', so that -loldnames is not
2307 required. In C++ with GNULIB_NAMESPACE, avoid differences between
2308 platforms by defining GNULIB_NAMESPACE::write always. */
2309# if defined _WIN32 && !defined __CYGWIN__
2310# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2311# undef write
2312# define write _write
2313# endif
2314# ifdef __MINGW32__
2315_GL_CXXALIAS_MDA (write, int, (int fd, const void *buf, unsigned int count));
2316# else
2317_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, unsigned int count));
2318# endif
1518# else 2319# else
1519/* Need to cast, because on mingw, the third parameter is 2320_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
1520 unsigned int count
1521 and the return type is 'int'. */
1522_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1523# endif 2321# endif
1524_GL_CXXALIASWARN (write); 2322_GL_CXXALIASWARN (write);
1525#endif 2323#endif
@@ -1527,4 +2325,5 @@ _GL_CXXALIASWARN (write);
1527_GL_INLINE_HEADER_END 2325_GL_INLINE_HEADER_END
1528 2326
1529#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2327#endif /* _@GUARD_PREFIX@_UNISTD_H */
2328#endif /* _GL_INCLUDING_UNISTD_H */
1530#endif /* _@GUARD_PREFIX@_UNISTD_H */ 2329#endif /* _@GUARD_PREFIX@_UNISTD_H */
diff --git a/gl/unlocked-io.h b/gl/unlocked-io.h
new file mode 100644
index 0000000..fdef624
--- /dev/null
+++ b/gl/unlocked-io.h
@@ -0,0 +1,136 @@
1/* Prefer faster, non-thread-safe stdio functions if available.
2
3 Copyright (C) 2001-2004, 2009-2023 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Jim Meyering. */
19
20#ifndef UNLOCKED_IO_H
21# define UNLOCKED_IO_H 1
22
23/* These are wrappers for functions/macros from the GNU C library, and
24 from other C libraries supporting POSIX's optional thread-safe functions.
25
26 The standard I/O functions are thread-safe. These *_unlocked ones are
27 more efficient but not thread-safe. That they're not thread-safe is
28 fine since all of the applications in this package are single threaded.
29
30 Also, some code that is shared with the GNU C library may invoke
31 the *_unlocked functions directly. On hosts that lack those
32 functions, invoke the non-thread-safe versions instead. */
33
34# include <stdio.h>
35
36# if HAVE_DECL_CLEARERR_UNLOCKED || defined clearerr_unlocked
37# undef clearerr
38# define clearerr(x) clearerr_unlocked (x)
39# else
40# define clearerr_unlocked(x) clearerr (x)
41# endif
42
43# if HAVE_DECL_FEOF_UNLOCKED || defined feof_unlocked
44# undef feof
45# define feof(x) feof_unlocked (x)
46# else
47# define feof_unlocked(x) feof (x)
48# endif
49
50# if HAVE_DECL_FERROR_UNLOCKED || defined ferror_unlocked
51# undef ferror
52# define ferror(x) ferror_unlocked (x)
53# else
54# define ferror_unlocked(x) ferror (x)
55# endif
56
57# if HAVE_DECL_FFLUSH_UNLOCKED || defined fflush_unlocked
58# undef fflush
59# define fflush(x) fflush_unlocked (x)
60# else
61# define fflush_unlocked(x) fflush (x)
62# endif
63
64# if HAVE_DECL_FGETS_UNLOCKED || defined fgets_unlocked
65# undef fgets
66# define fgets(x,y,z) fgets_unlocked (x,y,z)
67# else
68# define fgets_unlocked(x,y,z) fgets (x,y,z)
69# endif
70
71# if HAVE_DECL_FPUTC_UNLOCKED || defined fputc_unlocked
72# undef fputc
73# define fputc(x,y) fputc_unlocked (x,y)
74# else
75# define fputc_unlocked(x,y) fputc (x,y)
76# endif
77
78# if HAVE_DECL_FPUTS_UNLOCKED || defined fputs_unlocked
79# undef fputs
80# define fputs(x,y) fputs_unlocked (x,y)
81# else
82# define fputs_unlocked(x,y) fputs (x,y)
83# endif
84
85# if HAVE_DECL_FREAD_UNLOCKED || defined fread_unlocked
86# undef fread
87# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
88# else
89# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
90# endif
91
92# if HAVE_DECL_FWRITE_UNLOCKED || defined fwrite_unlocked
93# undef fwrite
94# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
95# else
96# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
97# endif
98
99# if HAVE_DECL_GETC_UNLOCKED || defined get_unlocked
100# undef getc
101# define getc(x) getc_unlocked (x)
102# else
103# define getc_unlocked(x) getc (x)
104# endif
105
106# if HAVE_DECL_GETCHAR_UNLOCKED || defined getchar_unlocked
107# undef getchar
108# define getchar() getchar_unlocked ()
109# else
110# define getchar_unlocked() getchar ()
111# endif
112
113# if HAVE_DECL_PUTC_UNLOCKED || defined putc_unlocked
114# undef putc
115# define putc(x,y) putc_unlocked (x,y)
116# else
117# define putc_unlocked(x,y) putc (x,y)
118# endif
119
120# if HAVE_DECL_PUTCHAR_UNLOCKED || defined putchar_unlocked
121# undef putchar
122# define putchar(x) putchar_unlocked (x)
123# else
124# define putchar_unlocked(x) putchar (x)
125# endif
126
127# undef flockfile
128# define flockfile(x) ((void) 0)
129
130# undef ftrylockfile
131# define ftrylockfile(x) 0
132
133# undef funlockfile
134# define funlockfile(x) ((void) 0)
135
136#endif /* UNLOCKED_IO_H */
diff --git a/gl/unsetenv.c b/gl/unsetenv.c
index c58c82f..e548949 100644
--- a/gl/unsetenv.c
+++ b/gl/unsetenv.c
@@ -1,18 +1,18 @@
1/* Copyright (C) 1992, 1995-2002, 2005-2013 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2002, 2005-2023 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 3
4 This program is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3 of the License, or 6 published by the Free Software Foundation; either version 2.1 of the
7 (at your option) any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 17/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
18 optimizes away the name == NULL test below. */ 18 optimizes away the name == NULL test below. */
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 5267b1b..277c39e 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -1,18 +1,18 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 1999, 2002-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* This file can be parametrized with the following macros: 17/* This file can be parametrized with the following macros:
18 VASNPRINTF The name of the function being defined. 18 VASNPRINTF The name of the function being defined.
@@ -41,7 +41,14 @@
41 DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[]. 41 DCHAR_CONV_FROM_ENCODING A function to convert from char[] to DCHAR[].
42 DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t. 42 DCHAR_IS_UINT8_T Set to 1 if DCHAR_T is uint8_t.
43 DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t. 43 DCHAR_IS_UINT16_T Set to 1 if DCHAR_T is uint16_t.
44 DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t. */ 44 DCHAR_IS_UINT32_T Set to 1 if DCHAR_T is uint32_t.
45 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
46 ENABLE_WCHAR_FALLBACK Set to 1 to avoid EILSEQ during conversion of wide
47 characters (wchar_t) and wide character strings
48 (wchar_t[]) to multibyte sequences. The fallback is the
49 hexadecimal escape syntax (\unnnn or \Unnnnnnnn) or,
50 if wchar_t is not Unicode encoded, \wnnnn or \Wnnnnnnnn.
51 */
45 52
46/* Tell glibc's <stdio.h> to provide a prototype for snprintf(). 53/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
47 This must come before <config.h> because <config.h> may include 54 This must come before <config.h> because <config.h> may include
@@ -53,10 +60,16 @@
53#ifndef VASNPRINTF 60#ifndef VASNPRINTF
54# include <config.h> 61# include <config.h>
55#endif 62#endif
56#ifndef IN_LIBINTL 63
57# include <alloca.h> 64/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that main's
65 use of CHECK macros expands to code that is too complicated for gcc
66 -fanalyzer. Suppress the resulting bogus warnings. */
67#if 10 <= __GNUC__
68# pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
58#endif 69#endif
59 70
71#include <alloca.h>
72
60/* Specification. */ 73/* Specification. */
61#ifndef VASNPRINTF 74#ifndef VASNPRINTF
62# if WIDE_CHAR_VERSION 75# if WIDE_CHAR_VERSION
@@ -70,6 +83,7 @@
70#include <stdio.h> /* snprintf(), sprintf() */ 83#include <stdio.h> /* snprintf(), sprintf() */
71#include <stdlib.h> /* abort(), malloc(), realloc(), free() */ 84#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
72#include <string.h> /* memcpy(), strlen() */ 85#include <string.h> /* memcpy(), strlen() */
86#include <wchar.h> /* mbstate_t, mbrtowc(), mbrlen(), wcrtomb() */
73#include <errno.h> /* errno */ 87#include <errno.h> /* errno */
74#include <limits.h> /* CHAR_BIT */ 88#include <limits.h> /* CHAR_BIT */
75#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ 89#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
@@ -87,7 +101,7 @@
87/* Checked size_t computations. */ 101/* Checked size_t computations. */
88#include "xsize.h" 102#include "xsize.h"
89 103
90#include "verify.h" 104#include "attribute.h"
91 105
92#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 106#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
93# include <math.h> 107# include <math.h>
@@ -156,6 +170,7 @@
156# define SNPRINTF snwprintf 170# define SNPRINTF snwprintf
157# else 171# else
158# define SNPRINTF _snwprintf 172# define SNPRINTF _snwprintf
173# define USE_MSVC__SNPRINTF 1
159# endif 174# endif
160# else 175# else
161 /* Unix. */ 176 /* Unix. */
@@ -181,7 +196,9 @@
181 /* Here we need to call the native snprintf, not rpl_snprintf. */ 196 /* Here we need to call the native snprintf, not rpl_snprintf. */
182# undef snprintf 197# undef snprintf
183# else 198# else
199 /* MSVC versions < 14 did not have snprintf, only _snprintf. */
184# define SNPRINTF _snprintf 200# define SNPRINTF _snprintf
201# define USE_MSVC__SNPRINTF 1
185# endif 202# endif
186# else 203# else
187 /* Unix. */ 204 /* Unix. */
@@ -195,7 +212,7 @@
195 212
196/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized" 213/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
197 warnings in this file. Use -Dlint to suppress them. */ 214 warnings in this file. Use -Dlint to suppress them. */
198#ifdef lint 215#if defined GCC_LINT || defined lint
199# define IF_LINT(Code) Code 216# define IF_LINT(Code) Code
200#else 217#else
201# define IF_LINT(Code) /* empty */ 218# define IF_LINT(Code) /* empty */
@@ -208,7 +225,7 @@
208#undef remainder 225#undef remainder
209#define remainder rem 226#define remainder rem
210 227
211#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION 228#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && !WIDE_CHAR_VERSION
212# if (HAVE_STRNLEN && !defined _AIX) 229# if (HAVE_STRNLEN && !defined _AIX)
213# define local_strnlen strnlen 230# define local_strnlen strnlen
214# else 231# else
@@ -224,7 +241,7 @@ local_strnlen (const char *string, size_t maxlen)
224# endif 241# endif
225#endif 242#endif
226 243
227#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T 244#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
228# if HAVE_WCSLEN 245# if HAVE_WCSLEN
229# define local_wcslen wcslen 246# define local_wcslen wcslen
230# else 247# else
@@ -247,7 +264,7 @@ local_wcslen (const wchar_t *s)
247# endif 264# endif
248#endif 265#endif
249 266
250#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION 267#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
251# if HAVE_WCSNLEN 268# if HAVE_WCSNLEN
252# define local_wcsnlen wcsnlen 269# define local_wcsnlen wcsnlen
253# else 270# else
@@ -266,6 +283,74 @@ local_wcsnlen (const wchar_t *s, size_t maxlen)
266# endif 283# endif
267#endif 284#endif
268 285
286#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T) || (ENABLE_WCHAR_FALLBACK && HAVE_WINT_T)) && !WIDE_CHAR_VERSION
287# if ENABLE_WCHAR_FALLBACK
288static size_t
289wctomb_fallback (char *s, wchar_t wc)
290{
291 static char hex[16] = "0123456789ABCDEF";
292
293 s[0] = '\\';
294 if (sizeof (wchar_t) > 2 && wc > 0xffff)
295 {
296# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__)
297 s[1] = 'U';
298# else
299 s[1] = 'W';
300# endif
301 s[2] = hex[(wc & 0xf0000000U) >> 28];
302 s[3] = hex[(wc & 0xf000000U) >> 24];
303 s[4] = hex[(wc & 0xf00000U) >> 20];
304 s[5] = hex[(wc & 0xf0000U) >> 16];
305 s[6] = hex[(wc & 0xf000U) >> 12];
306 s[7] = hex[(wc & 0xf00U) >> 8];
307 s[8] = hex[(wc & 0xf0U) >> 4];
308 s[9] = hex[wc & 0xfU];
309 return 10;
310 }
311 else
312 {
313# if __STDC_ISO_10646__ || (__GLIBC__ >= 2) || (defined _WIN32 || defined __CYGWIN__)
314 s[1] = 'u';
315# else
316 s[1] = 'w';
317# endif
318 s[2] = hex[(wc & 0xf000U) >> 12];
319 s[3] = hex[(wc & 0xf00U) >> 8];
320 s[4] = hex[(wc & 0xf0U) >> 4];
321 s[5] = hex[wc & 0xfU];
322 return 6;
323 }
324}
325# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
326static size_t
327local_wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
328{
329 size_t count = wcrtomb (s, wc, ps);
330 if (count == (size_t)(-1))
331 count = wctomb_fallback (s, wc);
332 return count;
333}
334# else
335static int
336local_wctomb (char *s, wchar_t wc)
337{
338 int count = wctomb (s, wc);
339 if (count < 0)
340 count = wctomb_fallback (s, wc);
341 return count;
342}
343# define local_wcrtomb(S, WC, PS) local_wctomb ((S), (WC))
344# endif
345# else
346# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
347# define local_wcrtomb(S, WC, PS) wcrtomb ((S), (WC), (PS))
348# else
349# define local_wcrtomb(S, WC, PS) wctomb ((S), (WC))
350# endif
351# endif
352#endif
353
269#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL 354#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
270/* Determine the decimal-point character according to the current locale. */ 355/* Determine the decimal-point character according to the current locale. */
271# ifndef decimal_point_char_defined 356# ifndef decimal_point_char_defined
@@ -323,11 +408,11 @@ is_infinite_or_zerol (long double x)
323 408
324typedef unsigned int mp_limb_t; 409typedef unsigned int mp_limb_t;
325# define GMP_LIMB_BITS 32 410# define GMP_LIMB_BITS 32
326verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS); 411static_assert (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
327 412
328typedef unsigned long long mp_twolimb_t; 413typedef unsigned long long mp_twolimb_t;
329# define GMP_TWOLIMB_BITS 64 414# define GMP_TWOLIMB_BITS 64
330verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS); 415static_assert (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
331 416
332/* Representation of a bignum >= 0. */ 417/* Representation of a bignum >= 0. */
333typedef struct 418typedef struct
@@ -554,7 +639,8 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
554 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ 639 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
555 /* Determine s = GMP_LIMB_BITS - integer_length (msd). 640 /* Determine s = GMP_LIMB_BITS - integer_length (msd).
556 Code copied from gnulib's integer_length.c. */ 641 Code copied from gnulib's integer_length.c. */
557# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 642# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) \
643 || (__clang_major__ >= 4)
558 s = __builtin_clz (msd); 644 s = __builtin_clz (msd);
559# else 645# else
560# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT 646# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
@@ -829,8 +915,7 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
829 q_ptr[q_len++] = 1; 915 q_ptr[q_len++] = 1;
830 } 916 }
831 keep_q: 917 keep_q:
832 if (tmp_roomptr != NULL) 918 free (tmp_roomptr);
833 free (tmp_roomptr);
834 q->limbs = q_ptr; 919 q->limbs = q_ptr;
835 q->nlimbs = q_len; 920 q->nlimbs = q_len;
836 return roomptr; 921 return roomptr;
@@ -849,7 +934,9 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
849 size_t a_len = a.nlimbs; 934 size_t a_len = a.nlimbs;
850 /* 0.03345 is slightly larger than log(2)/(9*log(10)). */ 935 /* 0.03345 is slightly larger than log(2)/(9*log(10)). */
851 size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1); 936 size_t c_len = 9 * ((size_t)(a_len * (GMP_LIMB_BITS * 0.03345f)) + 1);
852 char *c_ptr = (char *) malloc (xsum (c_len, extra_zeroes)); 937 /* We need extra_zeroes bytes for zeroes, followed by c_len bytes for the
938 digits of a, followed by 1 byte for the terminating NUL. */
939 char *c_ptr = (char *) malloc (xsum (xsum (extra_zeroes, c_len), 1));
853 if (c_ptr != NULL) 940 if (c_ptr != NULL)
854 { 941 {
855 char *d_ptr = c_ptr; 942 char *d_ptr = c_ptr;
@@ -1517,7 +1604,7 @@ is_borderline (const char *digits, size_t precision)
1517 1604
1518#endif 1605#endif
1519 1606
1520#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 1607#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
1521 1608
1522/* Use a different function name, to make it possible that the 'wchar_t' 1609/* Use a different function name, to make it possible that the 'wchar_t'
1523 parametrization and the 'char' parametrization get compiled in the same 1610 parametrization and the 'char' parametrization get compiled in the same
@@ -1540,16 +1627,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1540 switch (conversion) 1627 switch (conversion)
1541 { 1628 {
1542 case 'd': case 'i': case 'u': 1629 case 'd': case 'i': case 'u':
1543# if HAVE_LONG_LONG_INT
1544 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1630 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1545 tmp_length = 1631 tmp_length =
1546 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1632 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1547 * 0.30103 /* binary -> decimal */ 1633 * 0.30103 /* binary -> decimal */
1548 ) 1634 )
1549 + 1; /* turn floor into ceil */ 1635 + 1; /* turn floor into ceil */
1550 else 1636 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1551# endif
1552 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1553 tmp_length = 1637 tmp_length =
1554 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1638 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1555 * 0.30103 /* binary -> decimal */ 1639 * 0.30103 /* binary -> decimal */
@@ -1570,16 +1654,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1570 break; 1654 break;
1571 1655
1572 case 'o': 1656 case 'o':
1573# if HAVE_LONG_LONG_INT
1574 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1657 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1575 tmp_length = 1658 tmp_length =
1576 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1659 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1577 * 0.333334 /* binary -> octal */ 1660 * 0.333334 /* binary -> octal */
1578 ) 1661 )
1579 + 1; /* turn floor into ceil */ 1662 + 1; /* turn floor into ceil */
1580 else 1663 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1581# endif
1582 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1583 tmp_length = 1664 tmp_length =
1584 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1665 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1585 * 0.333334 /* binary -> octal */ 1666 * 0.333334 /* binary -> octal */
@@ -1598,16 +1679,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1598 break; 1679 break;
1599 1680
1600 case 'x': case 'X': 1681 case 'x': case 'X':
1601# if HAVE_LONG_LONG_INT
1602 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) 1682 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1603 tmp_length = 1683 tmp_length =
1604 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT 1684 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1605 * 0.25 /* binary -> hexadecimal */ 1685 * 0.25 /* binary -> hexadecimal */
1606 ) 1686 )
1607 + 1; /* turn floor into ceil */ 1687 + 1; /* turn floor into ceil */
1608 else 1688 else if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1609# endif
1610 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1611 tmp_length = 1689 tmp_length =
1612 (unsigned int) (sizeof (unsigned long) * CHAR_BIT 1690 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1613 * 0.25 /* binary -> hexadecimal */ 1691 * 0.25 /* binary -> hexadecimal */
@@ -1673,7 +1751,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1673 case 'c': 1751 case 'c':
1674# if HAVE_WINT_T && !WIDE_CHAR_VERSION 1752# if HAVE_WINT_T && !WIDE_CHAR_VERSION
1675 if (type == TYPE_WIDE_CHAR) 1753 if (type == TYPE_WIDE_CHAR)
1676 tmp_length = MB_CUR_MAX; 1754 {
1755 tmp_length = MB_CUR_MAX;
1756# if ENABLE_WCHAR_FALLBACK
1757 if (tmp_length < (sizeof (wchar_t) > 2 ? 10 : 6))
1758 tmp_length = (sizeof (wchar_t) > 2 ? 10 : 6);
1759# endif
1760 }
1677 else 1761 else
1678# endif 1762# endif
1679 tmp_length = 1; 1763 tmp_length = 1;
@@ -1780,6 +1864,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1780 /* errno is already set. */ 1864 /* errno is already set. */
1781 return NULL; 1865 return NULL;
1782 1866
1867 /* Frees the memory allocated by this function. Preserves errno. */
1783#define CLEANUP() \ 1868#define CLEANUP() \
1784 if (d.dir != d.direct_alloc_dir) \ 1869 if (d.dir != d.direct_alloc_dir) \
1785 free (d.dir); \ 1870 free (d.dir); \
@@ -1787,11 +1872,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1787 free (a.arg); 1872 free (a.arg);
1788 1873
1789 if (PRINTF_FETCHARGS (args, &a) < 0) 1874 if (PRINTF_FETCHARGS (args, &a) < 0)
1790 { 1875 goto fail_1_with_EINVAL;
1791 CLEANUP ();
1792 errno = EINVAL;
1793 return NULL;
1794 }
1795 1876
1796 { 1877 {
1797 size_t buf_neededlength; 1878 size_t buf_neededlength;
@@ -1827,24 +1908,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1827 buf_malloced = buf; 1908 buf_malloced = buf;
1828 } 1909 }
1829 1910
1830 if (resultbuf != NULL) 1911 result = resultbuf;
1831 { 1912 allocated = (resultbuf != NULL ? *lengthp : 0);
1832 result = resultbuf;
1833 allocated = *lengthp;
1834 }
1835 else
1836 {
1837 result = NULL;
1838 allocated = 0;
1839 }
1840 length = 0; 1913 length = 0;
1841 /* Invariants: 1914 /* Invariants:
1842 result is either == resultbuf or == NULL or malloc-allocated. 1915 result is either == resultbuf or malloc-allocated.
1916 If result == NULL, resultbuf is == NULL as well.
1843 If length > 0, then result != NULL. */ 1917 If length > 0, then result != NULL. */
1844 1918
1845 /* Ensures that allocated >= needed. Aborts through a jump to 1919 /* Ensures that allocated >= needed. Aborts through a jump to
1846 out_of_memory if needed is SIZE_MAX or otherwise too big. */ 1920 out_of_memory if needed is SIZE_MAX or otherwise too big. */
1847#define ENSURE_ALLOCATION(needed) \ 1921#define ENSURE_ALLOCATION_ELSE(needed, oom_statement) \
1848 if ((needed) > allocated) \ 1922 if ((needed) > allocated) \
1849 { \ 1923 { \
1850 size_t memory_size; \ 1924 size_t memory_size; \
@@ -1855,17 +1929,19 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1855 allocated = (needed); \ 1929 allocated = (needed); \
1856 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \ 1930 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
1857 if (size_overflow_p (memory_size)) \ 1931 if (size_overflow_p (memory_size)) \
1858 goto out_of_memory; \ 1932 oom_statement \
1859 if (result == resultbuf || result == NULL) \ 1933 if (result == resultbuf) \
1860 memory = (DCHAR_T *) malloc (memory_size); \ 1934 memory = (DCHAR_T *) malloc (memory_size); \
1861 else \ 1935 else \
1862 memory = (DCHAR_T *) realloc (result, memory_size); \ 1936 memory = (DCHAR_T *) realloc (result, memory_size); \
1863 if (memory == NULL) \ 1937 if (memory == NULL) \
1864 goto out_of_memory; \ 1938 oom_statement \
1865 if (result == resultbuf && length > 0) \ 1939 if (result == resultbuf && length > 0) \
1866 DCHAR_CPY (memory, result, length); \ 1940 DCHAR_CPY (memory, result, length); \
1867 result = memory; \ 1941 result = memory; \
1868 } 1942 }
1943#define ENSURE_ALLOCATION(needed) \
1944 ENSURE_ALLOCATION_ELSE((needed), goto out_of_memory; )
1869 1945
1870 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++) 1946 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
1871 { 1947 {
@@ -1886,7 +1962,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1886 else 1962 else
1887 { 1963 {
1888 do 1964 do
1889 result[length++] = (unsigned char) *cp++; 1965 result[length++] = *cp++;
1890 while (--n > 0); 1966 while (--n > 0);
1891 } 1967 }
1892 } 1968 }
@@ -1926,11 +2002,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1926 case TYPE_COUNT_LONGINT_POINTER: 2002 case TYPE_COUNT_LONGINT_POINTER:
1927 *a.arg[dp->arg_index].a.a_count_longint_pointer = length; 2003 *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
1928 break; 2004 break;
1929#if HAVE_LONG_LONG_INT
1930 case TYPE_COUNT_LONGLONGINT_POINTER: 2005 case TYPE_COUNT_LONGLONGINT_POINTER:
1931 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; 2006 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
1932 break; 2007 break;
1933#endif
1934 default: 2008 default:
1935 abort (); 2009 abort ();
1936 } 2010 }
@@ -1957,15 +2031,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1957 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 2031 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
1958 abort (); 2032 abort ();
1959 arg = a.arg[dp->width_arg_index].a.a_int; 2033 arg = a.arg[dp->width_arg_index].a.a_int;
2034 width = arg;
1960 if (arg < 0) 2035 if (arg < 0)
1961 { 2036 {
1962 /* "A negative field width is taken as a '-' flag 2037 /* "A negative field width is taken as a '-' flag
1963 followed by a positive field width." */ 2038 followed by a positive field width." */
1964 flags |= FLAG_LEFT; 2039 flags |= FLAG_LEFT;
1965 width = (unsigned int) (-arg); 2040 width = -width;
1966 } 2041 }
1967 else
1968 width = arg;
1969 } 2042 }
1970 else 2043 else
1971 { 2044 {
@@ -2027,15 +2100,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2027 if (count == 0) 2100 if (count == 0)
2028 break; 2101 break;
2029 if (count < 0) 2102 if (count < 0)
2030 { 2103 goto fail_with_EILSEQ;
2031 if (!(result == resultbuf || result == NULL))
2032 free (result);
2033 if (buf_malloced != NULL)
2034 free (buf_malloced);
2035 CLEANUP ();
2036 errno = EILSEQ;
2037 return NULL;
2038 }
2039 arg_end += count; 2104 arg_end += count;
2040 characters++; 2105 characters++;
2041 } 2106 }
@@ -2052,15 +2117,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2052 if (count == 0) 2117 if (count == 0)
2053 break; 2118 break;
2054 if (count < 0) 2119 if (count < 0)
2055 { 2120 goto fail_with_EILSEQ;
2056 if (!(result == resultbuf || result == NULL))
2057 free (result);
2058 if (buf_malloced != NULL)
2059 free (buf_malloced);
2060 CLEANUP ();
2061 errno = EILSEQ;
2062 return NULL;
2063 }
2064 arg_end += count; 2121 arg_end += count;
2065 characters++; 2122 characters++;
2066 } 2123 }
@@ -2073,8 +2130,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2073 characters = 0; 2130 characters = 0;
2074 } 2131 }
2075 2132
2076 if (has_width && width > characters 2133 if (characters < width && !(dp->flags & FLAG_LEFT))
2077 && !(dp->flags & FLAG_LEFT))
2078 { 2134 {
2079 size_t n = width - characters; 2135 size_t n = width - characters;
2080 ENSURE_ALLOCATION (xsum (length, n)); 2136 ENSURE_ALLOCATION (xsum (length, n));
@@ -2107,19 +2163,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2107 converted, &converted_len); 2163 converted, &converted_len);
2108# endif 2164# endif
2109 if (converted == NULL) 2165 if (converted == NULL)
2110 { 2166 goto fail_with_errno;
2111 int saved_errno = errno;
2112 if (!(result == resultbuf || result == NULL))
2113 free (result);
2114 if (buf_malloced != NULL)
2115 free (buf_malloced);
2116 CLEANUP ();
2117 errno = saved_errno;
2118 return NULL;
2119 }
2120 if (converted != result + length) 2167 if (converted != result + length)
2121 { 2168 {
2122 ENSURE_ALLOCATION (xsum (length, converted_len)); 2169 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2170 { free (converted); goto out_of_memory; });
2123 DCHAR_CPY (result + length, converted, converted_len); 2171 DCHAR_CPY (result + length, converted, converted_len);
2124 free (converted); 2172 free (converted);
2125 } 2173 }
@@ -2127,8 +2175,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2127 } 2175 }
2128# endif 2176# endif
2129 2177
2130 if (has_width && width > characters 2178 if (characters < width && (dp->flags & FLAG_LEFT))
2131 && (dp->flags & FLAG_LEFT))
2132 { 2179 {
2133 size_t n = width - characters; 2180 size_t n = width - characters;
2134 ENSURE_ALLOCATION (xsum (length, n)); 2181 ENSURE_ALLOCATION (xsum (length, n));
@@ -2155,15 +2202,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2155 if (count == 0) 2202 if (count == 0)
2156 break; 2203 break;
2157 if (count < 0) 2204 if (count < 0)
2158 { 2205 goto fail_with_EILSEQ;
2159 if (!(result == resultbuf || result == NULL))
2160 free (result);
2161 if (buf_malloced != NULL)
2162 free (buf_malloced);
2163 CLEANUP ();
2164 errno = EILSEQ;
2165 return NULL;
2166 }
2167 arg_end += count; 2206 arg_end += count;
2168 characters++; 2207 characters++;
2169 } 2208 }
@@ -2180,15 +2219,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2180 if (count == 0) 2219 if (count == 0)
2181 break; 2220 break;
2182 if (count < 0) 2221 if (count < 0)
2183 { 2222 goto fail_with_EILSEQ;
2184 if (!(result == resultbuf || result == NULL))
2185 free (result);
2186 if (buf_malloced != NULL)
2187 free (buf_malloced);
2188 CLEANUP ();
2189 errno = EILSEQ;
2190 return NULL;
2191 }
2192 arg_end += count; 2223 arg_end += count;
2193 characters++; 2224 characters++;
2194 } 2225 }
@@ -2201,8 +2232,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2201 characters = 0; 2232 characters = 0;
2202 } 2233 }
2203 2234
2204 if (has_width && width > characters 2235 if (characters < width && !(dp->flags & FLAG_LEFT))
2205 && !(dp->flags & FLAG_LEFT))
2206 { 2236 {
2207 size_t n = width - characters; 2237 size_t n = width - characters;
2208 ENSURE_ALLOCATION (xsum (length, n)); 2238 ENSURE_ALLOCATION (xsum (length, n));
@@ -2235,19 +2265,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2235 converted, &converted_len); 2265 converted, &converted_len);
2236# endif 2266# endif
2237 if (converted == NULL) 2267 if (converted == NULL)
2238 { 2268 goto fail_with_errno;
2239 int saved_errno = errno;
2240 if (!(result == resultbuf || result == NULL))
2241 free (result);
2242 if (buf_malloced != NULL)
2243 free (buf_malloced);
2244 CLEANUP ();
2245 errno = saved_errno;
2246 return NULL;
2247 }
2248 if (converted != result + length) 2269 if (converted != result + length)
2249 { 2270 {
2250 ENSURE_ALLOCATION (xsum (length, converted_len)); 2271 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2272 { free (converted); goto out_of_memory; });
2251 DCHAR_CPY (result + length, converted, converted_len); 2273 DCHAR_CPY (result + length, converted, converted_len);
2252 free (converted); 2274 free (converted);
2253 } 2275 }
@@ -2255,8 +2277,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2255 } 2277 }
2256# endif 2278# endif
2257 2279
2258 if (has_width && width > characters 2280 if (characters < width && (dp->flags & FLAG_LEFT))
2259 && (dp->flags & FLAG_LEFT))
2260 { 2281 {
2261 size_t n = width - characters; 2282 size_t n = width - characters;
2262 ENSURE_ALLOCATION (xsum (length, n)); 2283 ENSURE_ALLOCATION (xsum (length, n));
@@ -2283,15 +2304,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2283 if (count == 0) 2304 if (count == 0)
2284 break; 2305 break;
2285 if (count < 0) 2306 if (count < 0)
2286 { 2307 goto fail_with_EILSEQ;
2287 if (!(result == resultbuf || result == NULL))
2288 free (result);
2289 if (buf_malloced != NULL)
2290 free (buf_malloced);
2291 CLEANUP ();
2292 errno = EILSEQ;
2293 return NULL;
2294 }
2295 arg_end += count; 2308 arg_end += count;
2296 characters++; 2309 characters++;
2297 } 2310 }
@@ -2308,15 +2321,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2308 if (count == 0) 2321 if (count == 0)
2309 break; 2322 break;
2310 if (count < 0) 2323 if (count < 0)
2311 { 2324 goto fail_with_EILSEQ;
2312 if (!(result == resultbuf || result == NULL))
2313 free (result);
2314 if (buf_malloced != NULL)
2315 free (buf_malloced);
2316 CLEANUP ();
2317 errno = EILSEQ;
2318 return NULL;
2319 }
2320 arg_end += count; 2325 arg_end += count;
2321 characters++; 2326 characters++;
2322 } 2327 }
@@ -2329,8 +2334,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2329 characters = 0; 2334 characters = 0;
2330 } 2335 }
2331 2336
2332 if (has_width && width > characters 2337 if (characters < width && !(dp->flags & FLAG_LEFT))
2333 && !(dp->flags & FLAG_LEFT))
2334 { 2338 {
2335 size_t n = width - characters; 2339 size_t n = width - characters;
2336 ENSURE_ALLOCATION (xsum (length, n)); 2340 ENSURE_ALLOCATION (xsum (length, n));
@@ -2363,19 +2367,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2363 converted, &converted_len); 2367 converted, &converted_len);
2364# endif 2368# endif
2365 if (converted == NULL) 2369 if (converted == NULL)
2366 { 2370 goto fail_with_errno;
2367 int saved_errno = errno;
2368 if (!(result == resultbuf || result == NULL))
2369 free (result);
2370 if (buf_malloced != NULL)
2371 free (buf_malloced);
2372 CLEANUP ();
2373 errno = saved_errno;
2374 return NULL;
2375 }
2376 if (converted != result + length) 2371 if (converted != result + length)
2377 { 2372 {
2378 ENSURE_ALLOCATION (xsum (length, converted_len)); 2373 ENSURE_ALLOCATION_ELSE (xsum (length, converted_len),
2374 { free (converted); goto out_of_memory; });
2379 DCHAR_CPY (result + length, converted, converted_len); 2375 DCHAR_CPY (result + length, converted, converted_len);
2380 free (converted); 2376 free (converted);
2381 } 2377 }
@@ -2383,8 +2379,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2383 } 2379 }
2384# endif 2380# endif
2385 2381
2386 if (has_width && width > characters 2382 if (characters < width && (dp->flags & FLAG_LEFT))
2387 && (dp->flags & FLAG_LEFT))
2388 { 2383 {
2389 size_t n = width - characters; 2384 size_t n = width - characters;
2390 ENSURE_ALLOCATION (xsum (length, n)); 2385 ENSURE_ALLOCATION (xsum (length, n));
@@ -2399,7 +2394,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2399 } 2394 }
2400 } 2395 }
2401#endif 2396#endif
2402#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T 2397#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T
2403 else if (dp->conversion == 's' 2398 else if (dp->conversion == 's'
2404# if WIDE_CHAR_VERSION 2399# if WIDE_CHAR_VERSION
2405 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING 2400 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -2435,15 +2430,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2435 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 2430 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2436 abort (); 2431 abort ();
2437 arg = a.arg[dp->width_arg_index].a.a_int; 2432 arg = a.arg[dp->width_arg_index].a.a_int;
2433 width = arg;
2438 if (arg < 0) 2434 if (arg < 0)
2439 { 2435 {
2440 /* "A negative field width is taken as a '-' flag 2436 /* "A negative field width is taken as a '-' flag
2441 followed by a positive field width." */ 2437 followed by a positive field width." */
2442 flags |= FLAG_LEFT; 2438 flags |= FLAG_LEFT;
2443 width = (unsigned int) (-arg); 2439 width = -width;
2444 } 2440 }
2445 else
2446 width = arg;
2447 } 2441 }
2448 else 2442 else
2449 { 2443 {
@@ -2515,16 +2509,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2515 /* Found the terminating NUL. */ 2509 /* Found the terminating NUL. */
2516 break; 2510 break;
2517 if (count < 0) 2511 if (count < 0)
2518 { 2512 /* Invalid or incomplete multibyte character. */
2519 /* Invalid or incomplete multibyte character. */ 2513 goto fail_with_EILSEQ;
2520 if (!(result == resultbuf || result == NULL))
2521 free (result);
2522 if (buf_malloced != NULL)
2523 free (buf_malloced);
2524 CLEANUP ();
2525 errno = EILSEQ;
2526 return NULL;
2527 }
2528 arg_end += count; 2514 arg_end += count;
2529 characters++; 2515 characters++;
2530 } 2516 }
@@ -2551,16 +2537,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2551 /* Found the terminating NUL. */ 2537 /* Found the terminating NUL. */
2552 break; 2538 break;
2553 if (count < 0) 2539 if (count < 0)
2554 { 2540 /* Invalid or incomplete multibyte character. */
2555 /* Invalid or incomplete multibyte character. */ 2541 goto fail_with_EILSEQ;
2556 if (!(result == resultbuf || result == NULL))
2557 free (result);
2558 if (buf_malloced != NULL)
2559 free (buf_malloced);
2560 CLEANUP ();
2561 errno = EILSEQ;
2562 return NULL;
2563 }
2564 arg_end += count; 2542 arg_end += count;
2565 characters++; 2543 characters++;
2566 } 2544 }
@@ -2573,8 +2551,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2573 characters = 0; 2551 characters = 0;
2574 } 2552 }
2575 2553
2576 if (has_width && width > characters 2554 if (characters < width && !(dp->flags & FLAG_LEFT))
2577 && !(dp->flags & FLAG_LEFT))
2578 { 2555 {
2579 size_t n = width - characters; 2556 size_t n = width - characters;
2580 ENSURE_ALLOCATION (xsum (length, n)); 2557 ENSURE_ALLOCATION (xsum (length, n));
@@ -2635,8 +2612,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2635 } 2612 }
2636 } 2613 }
2637 2614
2638 if (has_width && width > characters 2615 if (characters < width && (dp->flags & FLAG_LEFT))
2639 && (dp->flags & FLAG_LEFT))
2640 { 2616 {
2641 size_t n = width - characters; 2617 size_t n = width - characters;
2642 ENSURE_ALLOCATION (xsum (length, n)); 2618 ENSURE_ALLOCATION (xsum (length, n));
@@ -2652,7 +2628,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2652 size_t characters; 2628 size_t characters;
2653# if !DCHAR_IS_TCHAR 2629# if !DCHAR_IS_TCHAR
2654 /* This code assumes that TCHAR_T is 'char'. */ 2630 /* This code assumes that TCHAR_T is 'char'. */
2655 verify (sizeof (TCHAR_T) == 1); 2631 static_assert (sizeof (TCHAR_T) == 1);
2656 TCHAR_T *tmpsrc; 2632 TCHAR_T *tmpsrc;
2657 DCHAR_T *tmpdst; 2633 DCHAR_T *tmpdst;
2658 size_t tmpdst_len; 2634 size_t tmpdst_len;
@@ -2677,23 +2653,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2677 if (*arg_end == 0) 2653 if (*arg_end == 0)
2678 /* Found the terminating null wide character. */ 2654 /* Found the terminating null wide character. */
2679 break; 2655 break;
2680# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2656 count = local_wcrtomb (cbuf, *arg_end, &state);
2681 count = wcrtomb (cbuf, *arg_end, &state);
2682# else
2683 count = wctomb (cbuf, *arg_end);
2684# endif
2685 if (count < 0) 2657 if (count < 0)
2686 { 2658 /* Cannot convert. */
2687 /* Cannot convert. */ 2659 goto fail_with_EILSEQ;
2688 if (!(result == resultbuf || result == NULL)) 2660 if (precision < (unsigned int) count)
2689 free (result);
2690 if (buf_malloced != NULL)
2691 free (buf_malloced);
2692 CLEANUP ();
2693 errno = EILSEQ;
2694 return NULL;
2695 }
2696 if (precision < count)
2697 break; 2661 break;
2698 arg_end++; 2662 arg_end++;
2699 characters += count; 2663 characters += count;
@@ -2722,22 +2686,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2722 if (*arg_end == 0) 2686 if (*arg_end == 0)
2723 /* Found the terminating null wide character. */ 2687 /* Found the terminating null wide character. */
2724 break; 2688 break;
2725# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2689 count = local_wcrtomb (cbuf, *arg_end, &state);
2726 count = wcrtomb (cbuf, *arg_end, &state);
2727# else
2728 count = wctomb (cbuf, *arg_end);
2729# endif
2730 if (count < 0) 2690 if (count < 0)
2731 { 2691 /* Cannot convert. */
2732 /* Cannot convert. */ 2692 goto fail_with_EILSEQ;
2733 if (!(result == resultbuf || result == NULL))
2734 free (result);
2735 if (buf_malloced != NULL)
2736 free (buf_malloced);
2737 CLEANUP ();
2738 errno = EILSEQ;
2739 return NULL;
2740 }
2741 arg_end++; 2693 arg_end++;
2742 characters += count; 2694 characters += count;
2743 } 2695 }
@@ -2771,11 +2723,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2771 2723
2772 if (*arg == 0) 2724 if (*arg == 0)
2773 abort (); 2725 abort ();
2774# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2726 count = local_wcrtomb (cbuf, *arg, &state);
2775 count = wcrtomb (cbuf, *arg, &state);
2776# else
2777 count = wctomb (cbuf, *arg);
2778# endif
2779 if (count <= 0) 2727 if (count <= 0)
2780 /* Inconsistency. */ 2728 /* Inconsistency. */
2781 abort (); 2729 abort ();
@@ -2797,15 +2745,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2797 NULL, &tmpdst_len); 2745 NULL, &tmpdst_len);
2798 if (tmpdst == NULL) 2746 if (tmpdst == NULL)
2799 { 2747 {
2800 int saved_errno = errno;
2801 free (tmpsrc); 2748 free (tmpsrc);
2802 if (!(result == resultbuf || result == NULL)) 2749 goto fail_with_errno;
2803 free (result);
2804 if (buf_malloced != NULL)
2805 free (buf_malloced);
2806 CLEANUP ();
2807 errno = saved_errno;
2808 return NULL;
2809 } 2750 }
2810 free (tmpsrc); 2751 free (tmpsrc);
2811# endif 2752# endif
@@ -2827,8 +2768,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2827 /* w doesn't matter. */ 2768 /* w doesn't matter. */
2828 w = 0; 2769 w = 0;
2829 2770
2830 if (has_width && width > w 2771 if (w < width && !(dp->flags & FLAG_LEFT))
2831 && !(dp->flags & FLAG_LEFT))
2832 { 2772 {
2833 size_t n = width - w; 2773 size_t n = width - w;
2834 ENSURE_ALLOCATION (xsum (length, n)); 2774 ENSURE_ALLOCATION (xsum (length, n));
@@ -2853,11 +2793,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2853 2793
2854 if (*arg == 0) 2794 if (*arg == 0)
2855 abort (); 2795 abort ();
2856# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2796 count = local_wcrtomb (cbuf, *arg, &state);
2857 count = wcrtomb (cbuf, *arg, &state);
2858# else
2859 count = wctomb (cbuf, *arg);
2860# endif
2861 if (count <= 0) 2797 if (count <= 0)
2862 /* Inconsistency. */ 2798 /* Inconsistency. */
2863 abort (); 2799 abort ();
@@ -2882,22 +2818,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2882 2818
2883 if (*arg == 0) 2819 if (*arg == 0)
2884 abort (); 2820 abort ();
2885# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t 2821 count = local_wcrtomb (cbuf, *arg, &state);
2886 count = wcrtomb (cbuf, *arg, &state);
2887# else
2888 count = wctomb (cbuf, *arg);
2889# endif
2890 if (count <= 0) 2822 if (count <= 0)
2891 { 2823 /* Cannot convert. */
2892 /* Cannot convert. */ 2824 goto fail_with_EILSEQ;
2893 if (!(result == resultbuf || result == NULL))
2894 free (result);
2895 if (buf_malloced != NULL)
2896 free (buf_malloced);
2897 CLEANUP ();
2898 errno = EILSEQ;
2899 return NULL;
2900 }
2901 ENSURE_ALLOCATION (xsum (length, count)); 2825 ENSURE_ALLOCATION (xsum (length, count));
2902 memcpy (result + length, cbuf, count); 2826 memcpy (result + length, cbuf, count);
2903 length += count; 2827 length += count;
@@ -2905,14 +2829,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2905 } 2829 }
2906 } 2830 }
2907# else 2831# else
2908 ENSURE_ALLOCATION (xsum (length, tmpdst_len)); 2832 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
2833 { free (tmpdst); goto out_of_memory; });
2909 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 2834 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
2910 free (tmpdst); 2835 free (tmpdst);
2911 length += tmpdst_len; 2836 length += tmpdst_len;
2912# endif 2837# endif
2913 2838
2914 if (has_width && width > w 2839 if (w < width && (dp->flags & FLAG_LEFT))
2915 && (dp->flags & FLAG_LEFT))
2916 { 2840 {
2917 size_t n = width - w; 2841 size_t n = width - w;
2918 ENSURE_ALLOCATION (xsum (length, n)); 2842 ENSURE_ALLOCATION (xsum (length, n));
@@ -2923,6 +2847,202 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2923# endif 2847# endif
2924 } 2848 }
2925#endif 2849#endif
2850#if ENABLE_WCHAR_FALLBACK && HAVE_WINT_T && !WIDE_CHAR_VERSION
2851 else if (dp->conversion == 'c'
2852 && a.arg[dp->arg_index].type == TYPE_WIDE_CHAR)
2853 {
2854 /* Implement the 'lc' directive ourselves, in order to provide
2855 the fallback that avoids EILSEQ. */
2856 int flags = dp->flags;
2857 int has_width;
2858 size_t width;
2859
2860 has_width = 0;
2861 width = 0;
2862 if (dp->width_start != dp->width_end)
2863 {
2864 if (dp->width_arg_index != ARG_NONE)
2865 {
2866 int arg;
2867
2868 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2869 abort ();
2870 arg = a.arg[dp->width_arg_index].a.a_int;
2871 width = arg;
2872 if (arg < 0)
2873 {
2874 /* "A negative field width is taken as a '-' flag
2875 followed by a positive field width." */
2876 flags |= FLAG_LEFT;
2877 width = -width;
2878 }
2879 }
2880 else
2881 {
2882 const FCHAR_T *digitp = dp->width_start;
2883
2884 do
2885 width = xsum (xtimes (width, 10), *digitp++ - '0');
2886 while (digitp != dp->width_end);
2887 }
2888 has_width = 1;
2889 }
2890
2891 /* %lc in vasnprintf. See the specification of fprintf. */
2892 {
2893 wchar_t arg = (wchar_t) a.arg[dp->arg_index].a.a_wide_char;
2894 size_t characters;
2895# if !DCHAR_IS_TCHAR
2896 /* This code assumes that TCHAR_T is 'char'. */
2897 static_assert (sizeof (TCHAR_T) == 1);
2898 TCHAR_T tmpsrc[64]; /* Assume MB_CUR_MAX <= 64. */
2899 DCHAR_T *tmpdst;
2900 size_t tmpdst_len;
2901# endif
2902 size_t w;
2903
2904# if DCHAR_IS_TCHAR
2905 if (has_width)
2906# endif
2907 {
2908 /* Count the number of bytes. */
2909 characters = 0;
2910 if (arg != 0)
2911 {
2912 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2913 int count;
2914# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2915 mbstate_t state;
2916 memset (&state, '\0', sizeof (mbstate_t));
2917# endif
2918
2919 count = local_wcrtomb (cbuf, arg, &state);
2920 if (count < 0)
2921 /* Inconsistency. */
2922 abort ();
2923 characters = count;
2924 }
2925 }
2926# if DCHAR_IS_TCHAR
2927 else
2928 {
2929 /* The number of bytes doesn't matter. */
2930 characters = 0;
2931 }
2932# endif
2933
2934# if !DCHAR_IS_TCHAR
2935 /* Convert the string into a piece of temporary memory. */
2936 if (characters > 0) /* implies arg != 0 */
2937 {
2938 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2939 int count;
2940# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2941 mbstate_t state;
2942 memset (&state, '\0', sizeof (mbstate_t));
2943# endif
2944
2945 count = local_wcrtomb (cbuf, arg, &state);
2946 if (count <= 0)
2947 /* Inconsistency. */
2948 abort ();
2949 memcpy (tmpsrc, cbuf, count);
2950 }
2951
2952 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2953 tmpdst =
2954 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2955 iconveh_question_mark,
2956 tmpsrc, characters,
2957 NULL,
2958 NULL, &tmpdst_len);
2959 if (tmpdst == NULL)
2960 goto fail_with_errno;
2961# endif
2962
2963 if (has_width)
2964 {
2965# if ENABLE_UNISTDIO
2966 /* Outside POSIX, it's preferable to compare the width
2967 against the number of _characters_ of the converted
2968 value. */
2969 w = DCHAR_MBSNLEN (result + length, characters);
2970# else
2971 /* The width is compared against the number of _bytes_
2972 of the converted value, says POSIX. */
2973 w = characters;
2974# endif
2975 }
2976 else
2977 /* w doesn't matter. */
2978 w = 0;
2979
2980 if (w < width && !(dp->flags & FLAG_LEFT))
2981 {
2982 size_t n = width - w;
2983 ENSURE_ALLOCATION (xsum (length, n));
2984 DCHAR_SET (result + length, ' ', n);
2985 length += n;
2986 }
2987
2988# if DCHAR_IS_TCHAR
2989 if (has_width)
2990 {
2991 /* We know the number of bytes in advance. */
2992 ENSURE_ALLOCATION (xsum (length, characters));
2993 if (characters > 0) /* implies arg != 0 */
2994 {
2995 int count;
2996# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2997 mbstate_t state;
2998 memset (&state, '\0', sizeof (mbstate_t));
2999# endif
3000
3001 count = local_wcrtomb (result + length, arg, &state);
3002 if (count <= 0)
3003 /* Inconsistency. */
3004 abort ();
3005 length += count;
3006 }
3007 }
3008 else
3009 {
3010 if (arg != 0)
3011 {
3012 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
3013 int count;
3014# if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
3015 mbstate_t state;
3016 memset (&state, '\0', sizeof (mbstate_t));
3017# endif
3018
3019 count = local_wcrtomb (cbuf, arg, &state);
3020 if (count <= 0)
3021 /* Inconsistency. */
3022 abort ();
3023 ENSURE_ALLOCATION (xsum (length, count));
3024 memcpy (result + length, cbuf, count);
3025 length += count;
3026 }
3027 }
3028# else
3029 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
3030 { free (tmpdst); goto out_of_memory; });
3031 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
3032 free (tmpdst);
3033 length += tmpdst_len;
3034# endif
3035
3036 if (w < width && (dp->flags & FLAG_LEFT))
3037 {
3038 size_t n = width - w;
3039 ENSURE_ALLOCATION (xsum (length, n));
3040 DCHAR_SET (result + length, ' ', n);
3041 length += n;
3042 }
3043 }
3044 }
3045#endif
2926#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 3046#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
2927 else if ((dp->conversion == 'a' || dp->conversion == 'A') 3047 else if ((dp->conversion == 'a' || dp->conversion == 'A')
2928# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE)) 3048# if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
@@ -2939,17 +3059,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2939 { 3059 {
2940 arg_type type = a.arg[dp->arg_index].type; 3060 arg_type type = a.arg[dp->arg_index].type;
2941 int flags = dp->flags; 3061 int flags = dp->flags;
2942 int has_width;
2943 size_t width; 3062 size_t width;
2944 int has_precision; 3063 int has_precision;
2945 size_t precision; 3064 size_t precision;
2946 size_t tmp_length; 3065 size_t tmp_length;
3066 size_t count;
2947 DCHAR_T tmpbuf[700]; 3067 DCHAR_T tmpbuf[700];
2948 DCHAR_T *tmp; 3068 DCHAR_T *tmp;
2949 DCHAR_T *pad_ptr; 3069 DCHAR_T *pad_ptr;
2950 DCHAR_T *p; 3070 DCHAR_T *p;
2951 3071
2952 has_width = 0;
2953 width = 0; 3072 width = 0;
2954 if (dp->width_start != dp->width_end) 3073 if (dp->width_start != dp->width_end)
2955 { 3074 {
@@ -2960,15 +3079,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2960 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 3079 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2961 abort (); 3080 abort ();
2962 arg = a.arg[dp->width_arg_index].a.a_int; 3081 arg = a.arg[dp->width_arg_index].a.a_int;
3082 width = arg;
2963 if (arg < 0) 3083 if (arg < 0)
2964 { 3084 {
2965 /* "A negative field width is taken as a '-' flag 3085 /* "A negative field width is taken as a '-' flag
2966 followed by a positive field width." */ 3086 followed by a positive field width." */
2967 flags |= FLAG_LEFT; 3087 flags |= FLAG_LEFT;
2968 width = (unsigned int) (-arg); 3088 width = -width;
2969 } 3089 }
2970 else
2971 width = arg;
2972 } 3090 }
2973 else 3091 else
2974 { 3092 {
@@ -2978,7 +3096,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2978 width = xsum (xtimes (width, 10), *digitp++ - '0'); 3096 width = xsum (xtimes (width, 10), *digitp++ - '0');
2979 while (digitp != dp->width_end); 3097 while (digitp != dp->width_end);
2980 } 3098 }
2981 has_width = 1;
2982 } 3099 }
2983 3100
2984 has_precision = 0; 3101 has_precision = 0;
@@ -3354,11 +3471,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3354 abort (); 3471 abort ();
3355# endif 3472# endif
3356 } 3473 }
3474
3357 /* The generated string now extends from tmp to p, with the 3475 /* The generated string now extends from tmp to p, with the
3358 zero padding insertion point being at pad_ptr. */ 3476 zero padding insertion point being at pad_ptr. */
3359 if (has_width && p - tmp < width) 3477 count = p - tmp;
3478
3479 if (count < width)
3360 { 3480 {
3361 size_t pad = width - (p - tmp); 3481 size_t pad = width - count;
3362 DCHAR_T *end = p + pad; 3482 DCHAR_T *end = p + pad;
3363 3483
3364 if (flags & FLAG_LEFT) 3484 if (flags & FLAG_LEFT)
@@ -3391,28 +3511,26 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3391 p = end; 3511 p = end;
3392 } 3512 }
3393 3513
3394 { 3514 count = p - tmp;
3395 size_t count = p - tmp;
3396 3515
3397 if (count >= tmp_length) 3516 if (count >= tmp_length)
3398 /* tmp_length was incorrectly calculated - fix the 3517 /* tmp_length was incorrectly calculated - fix the
3399 code above! */ 3518 code above! */
3400 abort (); 3519 abort ();
3401 3520
3402 /* Make room for the result. */ 3521 /* Make room for the result. */
3403 if (count >= allocated - length) 3522 if (count >= allocated - length)
3404 { 3523 {
3405 size_t n = xsum (length, count); 3524 size_t n = xsum (length, count);
3406 3525
3407 ENSURE_ALLOCATION (n); 3526 ENSURE_ALLOCATION (n);
3408 } 3527 }
3409 3528
3410 /* Append the result. */ 3529 /* Append the result. */
3411 memcpy (result + length, tmp, count * sizeof (DCHAR_T)); 3530 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
3412 if (tmp != tmpbuf) 3531 if (tmp != tmpbuf)
3413 free (tmp); 3532 free (tmp);
3414 length += count; 3533 length += count;
3415 }
3416 } 3534 }
3417#endif 3535#endif
3418#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 3536#if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
@@ -3446,8 +3564,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3446 arg_type type = a.arg[dp->arg_index].type; 3564 arg_type type = a.arg[dp->arg_index].type;
3447# endif 3565# endif
3448 int flags = dp->flags; 3566 int flags = dp->flags;
3449 int has_width;
3450 size_t width; 3567 size_t width;
3568 size_t count;
3451 int has_precision; 3569 int has_precision;
3452 size_t precision; 3570 size_t precision;
3453 size_t tmp_length; 3571 size_t tmp_length;
@@ -3456,7 +3574,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3456 DCHAR_T *pad_ptr; 3574 DCHAR_T *pad_ptr;
3457 DCHAR_T *p; 3575 DCHAR_T *p;
3458 3576
3459 has_width = 0;
3460 width = 0; 3577 width = 0;
3461 if (dp->width_start != dp->width_end) 3578 if (dp->width_start != dp->width_end)
3462 { 3579 {
@@ -3467,15 +3584,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3467 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 3584 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3468 abort (); 3585 abort ();
3469 arg = a.arg[dp->width_arg_index].a.a_int; 3586 arg = a.arg[dp->width_arg_index].a.a_int;
3587 width = arg;
3470 if (arg < 0) 3588 if (arg < 0)
3471 { 3589 {
3472 /* "A negative field width is taken as a '-' flag 3590 /* "A negative field width is taken as a '-' flag
3473 followed by a positive field width." */ 3591 followed by a positive field width." */
3474 flags |= FLAG_LEFT; 3592 flags |= FLAG_LEFT;
3475 width = (unsigned int) (-arg); 3593 width = -width;
3476 } 3594 }
3477 else
3478 width = arg;
3479 } 3595 }
3480 else 3596 else
3481 { 3597 {
@@ -3485,7 +3601,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3485 width = xsum (xtimes (width, 10), *digitp++ - '0'); 3601 width = xsum (xtimes (width, 10), *digitp++ - '0');
3486 while (digitp != dp->width_end); 3602 while (digitp != dp->width_end);
3487 } 3603 }
3488 has_width = 1;
3489 } 3604 }
3490 3605
3491 has_precision = 0; 3606 has_precision = 0;
@@ -3925,9 +4040,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3925 digits without trailing zeroes. */ 4040 digits without trailing zeroes. */
3926 if (exponent >= 0) 4041 if (exponent >= 0)
3927 { 4042 {
3928 size_t count = exponent + 1; 4043 size_t ecount = exponent + 1;
3929 /* Note: count <= precision = ndigits. */ 4044 /* Note: count <= precision = ndigits. */
3930 for (; count > 0; count--) 4045 for (; ecount > 0; ecount--)
3931 *p++ = digits[--ndigits]; 4046 *p++ = digits[--ndigits];
3932 if ((flags & FLAG_ALT) || ndigits > nzeroes) 4047 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3933 { 4048 {
@@ -3941,10 +4056,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3941 } 4056 }
3942 else 4057 else
3943 { 4058 {
3944 size_t count = -exponent - 1; 4059 size_t ecount = -exponent - 1;
3945 *p++ = '0'; 4060 *p++ = '0';
3946 *p++ = decimal_point_char (); 4061 *p++ = decimal_point_char ();
3947 for (; count > 0; count--) 4062 for (; ecount > 0; ecount--)
3948 *p++ = '0'; 4063 *p++ = '0';
3949 while (ndigits > nzeroes) 4064 while (ndigits > nzeroes)
3950 { 4065 {
@@ -4249,7 +4364,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4249 static const wchar_t decimal_format[] = 4364 static const wchar_t decimal_format[] =
4250 /* Produce the same number of exponent digits 4365 /* Produce the same number of exponent digits
4251 as the native printf implementation. */ 4366 as the native printf implementation. */
4252# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4367# if defined _WIN32 && ! defined __CYGWIN__
4253 { '%', '+', '.', '3', 'd', '\0' }; 4368 { '%', '+', '.', '3', 'd', '\0' };
4254# else 4369# else
4255 { '%', '+', '.', '2', 'd', '\0' }; 4370 { '%', '+', '.', '2', 'd', '\0' };
@@ -4263,7 +4378,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4263 static const char decimal_format[] = 4378 static const char decimal_format[] =
4264 /* Produce the same number of exponent digits 4379 /* Produce the same number of exponent digits
4265 as the native printf implementation. */ 4380 as the native printf implementation. */
4266# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4381# if defined _WIN32 && ! defined __CYGWIN__
4267 "%+.3d"; 4382 "%+.3d";
4268# else 4383# else
4269 "%+.2d"; 4384 "%+.2d";
@@ -4395,9 +4510,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4395 digits without trailing zeroes. */ 4510 digits without trailing zeroes. */
4396 if (exponent >= 0) 4511 if (exponent >= 0)
4397 { 4512 {
4398 size_t count = exponent + 1; 4513 size_t ecount = exponent + 1;
4399 /* Note: count <= precision = ndigits. */ 4514 /* Note: ecount <= precision = ndigits. */
4400 for (; count > 0; count--) 4515 for (; ecount > 0; ecount--)
4401 *p++ = digits[--ndigits]; 4516 *p++ = digits[--ndigits];
4402 if ((flags & FLAG_ALT) || ndigits > nzeroes) 4517 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4403 { 4518 {
@@ -4411,10 +4526,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4411 } 4526 }
4412 else 4527 else
4413 { 4528 {
4414 size_t count = -exponent - 1; 4529 size_t ecount = -exponent - 1;
4415 *p++ = '0'; 4530 *p++ = '0';
4416 *p++ = decimal_point_char (); 4531 *p++ = decimal_point_char ();
4417 for (; count > 0; count--) 4532 for (; ecount > 0; ecount--)
4418 *p++ = '0'; 4533 *p++ = '0';
4419 while (ndigits > nzeroes) 4534 while (ndigits > nzeroes)
4420 { 4535 {
@@ -4442,7 +4557,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4442 static const wchar_t decimal_format[] = 4557 static const wchar_t decimal_format[] =
4443 /* Produce the same number of exponent digits 4558 /* Produce the same number of exponent digits
4444 as the native printf implementation. */ 4559 as the native printf implementation. */
4445# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4560# if defined _WIN32 && ! defined __CYGWIN__
4446 { '%', '+', '.', '3', 'd', '\0' }; 4561 { '%', '+', '.', '3', 'd', '\0' };
4447# else 4562# else
4448 { '%', '+', '.', '2', 'd', '\0' }; 4563 { '%', '+', '.', '2', 'd', '\0' };
@@ -4456,7 +4571,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4456 static const char decimal_format[] = 4571 static const char decimal_format[] =
4457 /* Produce the same number of exponent digits 4572 /* Produce the same number of exponent digits
4458 as the native printf implementation. */ 4573 as the native printf implementation. */
4459# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4574# if defined _WIN32 && ! defined __CYGWIN__
4460 "%+.3d"; 4575 "%+.3d";
4461# else 4576# else
4462 "%+.2d"; 4577 "%+.2d";
@@ -4514,7 +4629,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4514 *p++ = '+'; 4629 *p++ = '+';
4515 /* Produce the same number of exponent digits as 4630 /* Produce the same number of exponent digits as
4516 the native printf implementation. */ 4631 the native printf implementation. */
4517# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4632# if defined _WIN32 && ! defined __CYGWIN__
4518 *p++ = '0'; 4633 *p++ = '0';
4519# endif 4634# endif
4520 *p++ = '0'; 4635 *p++ = '0';
@@ -4542,9 +4657,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4542 4657
4543 /* The generated string now extends from tmp to p, with the 4658 /* The generated string now extends from tmp to p, with the
4544 zero padding insertion point being at pad_ptr. */ 4659 zero padding insertion point being at pad_ptr. */
4545 if (has_width && p - tmp < width) 4660 count = p - tmp;
4661
4662 if (count < width)
4546 { 4663 {
4547 size_t pad = width - (p - tmp); 4664 size_t pad = width - count;
4548 DCHAR_T *end = p + pad; 4665 DCHAR_T *end = p + pad;
4549 4666
4550 if (flags & FLAG_LEFT) 4667 if (flags & FLAG_LEFT)
@@ -4577,39 +4694,39 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4577 p = end; 4694 p = end;
4578 } 4695 }
4579 4696
4580 { 4697 count = p - tmp;
4581 size_t count = p - tmp;
4582 4698
4583 if (count >= tmp_length) 4699 if (count >= tmp_length)
4584 /* tmp_length was incorrectly calculated - fix the 4700 /* tmp_length was incorrectly calculated - fix the
4585 code above! */ 4701 code above! */
4586 abort (); 4702 abort ();
4587 4703
4588 /* Make room for the result. */ 4704 /* Make room for the result. */
4589 if (count >= allocated - length) 4705 if (count >= allocated - length)
4590 { 4706 {
4591 size_t n = xsum (length, count); 4707 size_t n = xsum (length, count);
4592 4708
4593 ENSURE_ALLOCATION (n); 4709 ENSURE_ALLOCATION (n);
4594 } 4710 }
4595 4711
4596 /* Append the result. */ 4712 /* Append the result. */
4597 memcpy (result + length, tmp, count * sizeof (DCHAR_T)); 4713 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
4598 if (tmp != tmpbuf) 4714 if (tmp != tmpbuf)
4599 free (tmp); 4715 free (tmp);
4600 length += count; 4716 length += count;
4601 }
4602 } 4717 }
4603#endif 4718#endif
4604 else 4719 else
4605 { 4720 {
4606 arg_type type = a.arg[dp->arg_index].type; 4721 arg_type type = a.arg[dp->arg_index].type;
4607 int flags = dp->flags; 4722 int flags = dp->flags;
4608#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 4723#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4609 int has_width; 4724 int has_width;
4725#endif
4726#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4610 size_t width; 4727 size_t width;
4611#endif 4728#endif
4612#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION 4729#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4613 int has_precision; 4730 int has_precision;
4614 size_t precision; 4731 size_t precision;
4615#endif 4732#endif
@@ -4635,8 +4752,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4635 TCHAR_T *tmp; 4752 TCHAR_T *tmp;
4636#endif 4753#endif
4637 4754
4638#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 4755#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4639 has_width = 0; 4756 has_width = 0;
4757#endif
4758#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4640 width = 0; 4759 width = 0;
4641 if (dp->width_start != dp->width_end) 4760 if (dp->width_start != dp->width_end)
4642 { 4761 {
@@ -4647,15 +4766,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4647 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 4766 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4648 abort (); 4767 abort ();
4649 arg = a.arg[dp->width_arg_index].a.a_int; 4768 arg = a.arg[dp->width_arg_index].a.a_int;
4769 width = arg;
4650 if (arg < 0) 4770 if (arg < 0)
4651 { 4771 {
4652 /* "A negative field width is taken as a '-' flag 4772 /* "A negative field width is taken as a '-' flag
4653 followed by a positive field width." */ 4773 followed by a positive field width." */
4654 flags |= FLAG_LEFT; 4774 flags |= FLAG_LEFT;
4655 width = (unsigned int) (-arg); 4775 width = -width;
4656 } 4776 }
4657 else
4658 width = arg;
4659 } 4777 }
4660 else 4778 else
4661 { 4779 {
@@ -4665,11 +4783,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4665 width = xsum (xtimes (width, 10), *digitp++ - '0'); 4783 width = xsum (xtimes (width, 10), *digitp++ - '0');
4666 while (digitp != dp->width_end); 4784 while (digitp != dp->width_end);
4667 } 4785 }
4786#if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4668 has_width = 1; 4787 has_width = 1;
4788#endif
4669 } 4789 }
4670#endif 4790#endif
4671 4791
4672#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION 4792#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4673 has_precision = 0; 4793 has_precision = 0;
4674 precision = 6; 4794 precision = 6;
4675 if (dp->precision_start != dp->precision_end) 4795 if (dp->precision_start != dp->precision_end)
@@ -4805,7 +4925,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4805 { 4925 {
4806 const FCHAR_T *mp = dp->width_start; 4926 const FCHAR_T *mp = dp->width_start;
4807 do 4927 do
4808 *fbp++ = (unsigned char) *mp++; 4928 *fbp++ = *mp++;
4809 while (--n > 0); 4929 while (--n > 0);
4810 } 4930 }
4811 } 4931 }
@@ -4826,7 +4946,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4826 { 4946 {
4827 const FCHAR_T *mp = dp->precision_start; 4947 const FCHAR_T *mp = dp->precision_start;
4828 do 4948 do
4829 *fbp++ = (unsigned char) *mp++; 4949 *fbp++ = *mp++;
4830 while (--n > 0); 4950 while (--n > 0);
4831 } 4951 }
4832 } 4952 }
@@ -4834,19 +4954,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4834 4954
4835 switch (type) 4955 switch (type)
4836 { 4956 {
4837#if HAVE_LONG_LONG_INT
4838 case TYPE_LONGLONGINT: 4957 case TYPE_LONGLONGINT:
4839 case TYPE_ULONGLONGINT: 4958 case TYPE_ULONGLONGINT:
4840# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 4959#if defined _WIN32 && ! defined __CYGWIN__
4841 *fbp++ = 'I'; 4960 *fbp++ = 'I';
4842 *fbp++ = '6'; 4961 *fbp++ = '6';
4843 *fbp++ = '4'; 4962 *fbp++ = '4';
4844 break; 4963 break;
4845# else 4964#else
4846 *fbp++ = 'l'; 4965 *fbp++ = 'l';
4847 /*FALLTHROUGH*/
4848# endif
4849#endif 4966#endif
4967 FALLTHROUGH;
4850 case TYPE_LONGINT: 4968 case TYPE_LONGINT:
4851 case TYPE_ULONGINT: 4969 case TYPE_ULONGINT:
4852#if HAVE_WINT_T 4970#if HAVE_WINT_T
@@ -4870,20 +4988,32 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4870#endif 4988#endif
4871 *fbp = dp->conversion; 4989 *fbp = dp->conversion;
4872#if USE_SNPRINTF 4990#if USE_SNPRINTF
4873# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) 4991# if ((HAVE_SNPRINTF_RETVAL_C99 && HAVE_SNPRINTF_TRUNCATION_C99) \
4874 fbp[1] = '%'; 4992 || ((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) \
4875 fbp[2] = 'n'; 4993 && !defined __UCLIBC__) \
4876 fbp[3] = '\0'; 4994 || (defined __APPLE__ && defined __MACH__) \
4877# else 4995 || defined __ANDROID__ \
4878 /* On glibc2 systems from glibc >= 2.3 - probably also older 4996 || (defined _WIN32 && ! defined __CYGWIN__))
4879 ones - we know that snprintf's return value conforms to 4997 /* On systems where we know that snprintf's return value
4880 ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and 4998 conforms to ISO C 99 (HAVE_SNPRINTF_RETVAL_C99) and that
4881 gl_SNPRINTF_TRUNCATION_C99 pass. 4999 snprintf always produces NUL-terminated strings
4882 Therefore we can avoid using %n in this situation. 5000 (HAVE_SNPRINTF_TRUNCATION_C99), it is possible to avoid
4883 On glibc2 systems from 2004-10-18 or newer, the use of %n 5001 using %n. And it is desirable to do so, because more and
4884 in format strings in writable memory may crash the program 5002 more platforms no longer support %n, for "security reasons".
4885 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it 5003 In particular, the following platforms:
4886 in this situation. */ 5004 - On glibc2 systems from 2004-10-18 or newer, the use of
5005 %n in format strings in writable memory may crash the
5006 program (if compiled with _FORTIFY_SOURCE=2).
5007 - On Mac OS X 10.13 or newer, the use of %n in format
5008 strings in writable memory by default crashes the
5009 program.
5010 - On Android, starting on 2018-03-07, the use of %n in
5011 format strings produces a fatal error (see
5012 <https://android.googlesource.com/platform/bionic/+/41398d03b7e8e0dfb951660ae713e682e9fc0336>).
5013 On these platforms, HAVE_SNPRINTF_RETVAL_C99 and
5014 HAVE_SNPRINTF_TRUNCATION_C99 are 1. We have listed them
5015 explicitly in the condition above, in case of cross-
5016 compilation (just to be sure). */
4887 /* On native Windows systems (such as mingw), we can avoid using 5017 /* On native Windows systems (such as mingw), we can avoid using
4888 %n because: 5018 %n because:
4889 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, 5019 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
@@ -4896,10 +5026,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4896 On native Windows systems (such as mingw) where the OS is 5026 On native Windows systems (such as mingw) where the OS is
4897 Windows Vista, the use of %n in format strings by default 5027 Windows Vista, the use of %n in format strings by default
4898 crashes the program. See 5028 crashes the program. See
4899 <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and 5029 <https://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
4900 <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx> 5030 <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-printf-count-output>
4901 So we should avoid %n in this situation. */ 5031 So we should avoid %n in this situation. */
4902 fbp[1] = '\0'; 5032 fbp[1] = '\0';
5033# else /* AIX <= 5.1, HP-UX, IRIX, OSF/1, Solaris <= 9, BeOS */
5034 fbp[1] = '%';
5035 fbp[2] = 'n';
5036 fbp[3] = '\0';
4903# endif 5037# endif
4904#else 5038#else
4905 fbp[1] = '\0'; 5039 fbp[1] = '\0';
@@ -5043,7 +5177,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5043 SNPRINTF_BUF (arg); 5177 SNPRINTF_BUF (arg);
5044 } 5178 }
5045 break; 5179 break;
5046#if HAVE_LONG_LONG_INT
5047 case TYPE_LONGLONGINT: 5180 case TYPE_LONGLONGINT:
5048 { 5181 {
5049 long long int arg = a.arg[dp->arg_index].a.a_longlongint; 5182 long long int arg = a.arg[dp->arg_index].a.a_longlongint;
@@ -5056,7 +5189,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5056 SNPRINTF_BUF (arg); 5189 SNPRINTF_BUF (arg);
5057 } 5190 }
5058 break; 5191 break;
5059#endif
5060 case TYPE_DOUBLE: 5192 case TYPE_DOUBLE:
5061 { 5193 {
5062 double arg = a.arg[dp->arg_index].a.a_double; 5194 double arg = a.arg[dp->arg_index].a.a_double;
@@ -5116,7 +5248,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5116 { 5248 {
5117 /* Verify that snprintf() has NUL-terminated its 5249 /* Verify that snprintf() has NUL-terminated its
5118 result. */ 5250 result. */
5119 if (count < maxlen 5251 if ((unsigned int) count < maxlen
5120 && ((TCHAR_T *) (result + length)) [count] != '\0') 5252 && ((TCHAR_T *) (result + length)) [count] != '\0')
5121 abort (); 5253 abort ();
5122 /* Portability hack. */ 5254 /* Portability hack. */
@@ -5139,7 +5271,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5139 /* Look at the snprintf() return value. */ 5271 /* Look at the snprintf() return value. */
5140 if (retcount < 0) 5272 if (retcount < 0)
5141 { 5273 {
5142# if !HAVE_SNPRINTF_RETVAL_C99 5274# if !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF
5143 /* HP-UX 10.20 snprintf() is doubly deficient: 5275 /* HP-UX 10.20 snprintf() is doubly deficient:
5144 It doesn't understand the '%n' directive, 5276 It doesn't understand the '%n' directive,
5145 *and* it returns -1 (rather than the length 5277 *and* it returns -1 (rather than the length
@@ -5153,7 +5285,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5153 size_t tmp_length = 5285 size_t tmp_length =
5154 MAX_ROOM_NEEDED (&a, dp->arg_index, 5286 MAX_ROOM_NEEDED (&a, dp->arg_index,
5155 dp->conversion, type, flags, 5287 dp->conversion, type, flags,
5156 has_width ? width : 0, 5288 width,
5157 has_precision, 5289 has_precision,
5158 precision, pad_ourselves); 5290 precision, pad_ourselves);
5159 5291
@@ -5188,22 +5320,17 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5188 /* Attempt to handle failure. */ 5320 /* Attempt to handle failure. */
5189 if (count < 0) 5321 if (count < 0)
5190 { 5322 {
5191 /* SNPRINTF or sprintf failed. Save and use the errno 5323 /* SNPRINTF or sprintf failed. Use the errno that it
5192 that it has set, if any. */ 5324 has set, if any. */
5193 int saved_errno = errno; 5325 if (errno == 0)
5194 5326 {
5195 if (!(result == resultbuf || result == NULL)) 5327 if (dp->conversion == 'c' || dp->conversion == 's')
5196 free (result); 5328 errno = EILSEQ;
5197 if (buf_malloced != NULL) 5329 else
5198 free (buf_malloced); 5330 errno = EINVAL;
5199 CLEANUP (); 5331 }
5200 errno = 5332
5201 (saved_errno != 0 5333 goto fail_with_errno;
5202 ? saved_errno
5203 : (dp->conversion == 'c' || dp->conversion == 's'
5204 ? EILSEQ
5205 : EINVAL));
5206 return NULL;
5207 } 5334 }
5208 5335
5209#if USE_SNPRINTF 5336#if USE_SNPRINTF
@@ -5324,7 +5451,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5324 DCHAR_T *tmpdst; 5451 DCHAR_T *tmpdst;
5325 size_t tmpdst_len; 5452 size_t tmpdst_len;
5326 /* This code assumes that TCHAR_T is 'char'. */ 5453 /* This code assumes that TCHAR_T is 'char'. */
5327 verify (sizeof (TCHAR_T) == 1); 5454 static_assert (sizeof (TCHAR_T) == 1);
5328# if USE_SNPRINTF 5455# if USE_SNPRINTF
5329 tmpsrc = (TCHAR_T *) (result + length); 5456 tmpsrc = (TCHAR_T *) (result + length);
5330# else 5457# else
@@ -5337,17 +5464,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5337 NULL, 5464 NULL,
5338 NULL, &tmpdst_len); 5465 NULL, &tmpdst_len);
5339 if (tmpdst == NULL) 5466 if (tmpdst == NULL)
5340 { 5467 goto fail_with_errno;
5341 int saved_errno = errno; 5468 ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
5342 if (!(result == resultbuf || result == NULL)) 5469 { free (tmpdst); goto out_of_memory; });
5343 free (result);
5344 if (buf_malloced != NULL)
5345 free (buf_malloced);
5346 CLEANUP ();
5347 errno = saved_errno;
5348 return NULL;
5349 }
5350 ENSURE_ALLOCATION (xsum (length, tmpdst_len));
5351 DCHAR_CPY (result + length, tmpdst, tmpdst_len); 5470 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
5352 free (tmpdst); 5471 free (tmpdst);
5353 count = tmpdst_len; 5472 count = tmpdst_len;
@@ -5391,7 +5510,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5391 tmpsrc += count; 5510 tmpsrc += count;
5392 tmpdst += count; 5511 tmpdst += count;
5393 for (n = count; n > 0; n--) 5512 for (n = count; n > 0; n--)
5394 *--tmpdst = (unsigned char) *--tmpsrc; 5513 *--tmpdst = *--tmpsrc;
5395 } 5514 }
5396 } 5515 }
5397#endif 5516#endif
@@ -5570,25 +5689,40 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5570 5689
5571#if USE_SNPRINTF 5690#if USE_SNPRINTF
5572 overflow: 5691 overflow:
5573 if (!(result == resultbuf || result == NULL))
5574 free (result);
5575 if (buf_malloced != NULL)
5576 free (buf_malloced);
5577 CLEANUP ();
5578 errno = EOVERFLOW; 5692 errno = EOVERFLOW;
5579 return NULL; 5693 goto fail_with_errno;
5580#endif 5694#endif
5581 5695
5582 out_of_memory: 5696 out_of_memory:
5583 if (!(result == resultbuf || result == NULL)) 5697 errno = ENOMEM;
5698 goto fail_with_errno;
5699
5700#if ENABLE_UNISTDIO || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL) || ENABLE_WCHAR_FALLBACK) && HAVE_WCHAR_T)
5701 fail_with_EILSEQ:
5702 errno = EILSEQ;
5703 goto fail_with_errno;
5704#endif
5705
5706 fail_with_errno:
5707 if (result != resultbuf)
5584 free (result); 5708 free (result);
5585 if (buf_malloced != NULL) 5709 if (buf_malloced != NULL)
5586 free (buf_malloced); 5710 free (buf_malloced);
5587 out_of_memory_1:
5588 CLEANUP (); 5711 CLEANUP ();
5589 errno = ENOMEM;
5590 return NULL; 5712 return NULL;
5591 } 5713 }
5714
5715 out_of_memory_1:
5716 errno = ENOMEM;
5717 goto fail_1_with_errno;
5718
5719 fail_1_with_EINVAL:
5720 errno = EINVAL;
5721 goto fail_1_with_errno;
5722
5723 fail_1_with_errno:
5724 CLEANUP ();
5725 return NULL;
5592} 5726}
5593 5727
5594#undef MAX_ROOM_NEEDED 5728#undef MAX_ROOM_NEEDED
diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h
index 7658f50..f69649f 100644
--- a/gl/vasnprintf.h
+++ b/gl/vasnprintf.h
@@ -1,18 +1,18 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc. 2 Copyright (C) 2002-2004, 2007-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#ifndef _VASNPRINTF_H 17#ifndef _VASNPRINTF_H
18#define _VASNPRINTF_H 18#define _VASNPRINTF_H
@@ -23,17 +23,8 @@
23/* Get size_t. */ 23/* Get size_t. */
24#include <stddef.h> 24#include <stddef.h>
25 25
26/* The __attribute__ feature is available in gcc versions 2.5 and later. 26/* Get _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD. */
27 The __-protected variants of the attributes 'format' and 'printf' are 27#include <stdio.h>
28 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
29 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
30 gnulib and libintl do '#define printf __printf__' when they override
31 the 'printf' function. */
32#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
33# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
34#else
35# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
36#endif
37 28
38#ifdef __cplusplus 29#ifdef __cplusplus
39extern "C" { 30extern "C" {
@@ -67,10 +58,12 @@ extern "C" {
67# define asnprintf rpl_asnprintf 58# define asnprintf rpl_asnprintf
68# define vasnprintf rpl_vasnprintf 59# define vasnprintf rpl_vasnprintf
69#endif 60#endif
70extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 61extern char * asnprintf (char *restrict resultbuf, size_t *lengthp,
71 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); 62 const char *format, ...)
72extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) 63 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4));
73 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0)); 64extern char * vasnprintf (char *restrict resultbuf, size_t *lengthp,
65 const char *format, va_list args)
66 _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
74 67
75#ifdef __cplusplus 68#ifdef __cplusplus
76} 69}
diff --git a/gl/vasprintf.c b/gl/vasprintf.c
index d0d4a11..d2878cd 100644
--- a/gl/vasprintf.c
+++ b/gl/vasprintf.c
@@ -1,18 +1,18 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU Lesser General Public License
15 with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17#include <config.h> 17#include <config.h>
18 18
diff --git a/gl/verify.h b/gl/verify.h
index d42d075..b63cb26 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -1,19 +1,19 @@
1/* Compile-time assert-like macros. 1/* Compile-time assert-like macros.
2 2
3 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2009-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ 18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
19 19
@@ -21,31 +21,32 @@
21#define _GL_VERIFY_H 21#define _GL_VERIFY_H
22 22
23 23
24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. 24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)
25 This is supported by GCC 4.6.0 and later, in C mode, and its use 25 works as per C11. This is supported by GCC 4.6.0+ and by clang 4+.
26 here generates easier-to-read diagnostics when verify (R) fails.
27 26
28 Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11. 27 Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as
29 This will likely be supported by future GCC versions, in C++ mode. 28 per C23. This is supported by GCC 9.1+.
30 29
31 Use this only with GCC. If we were willing to slow 'configure' 30 Support compilers claiming conformance to the relevant standard,
32 down we could also use it with other compilers, but since this 31 and also support GCC when not pedantic. If we were willing to slow
33 affects only the quality of diagnostics, why bother? */ 32 'configure' down we could also use it with other compilers, but
34#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ 33 since this affects only the quality of diagnostics, why bother? */
35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ 34#ifndef __cplusplus
36 && !defined __cplusplus) 35# if (201112 <= __STDC_VERSION__ \
37# define _GL_HAVE__STATIC_ASSERT 1 36 || (!defined __STRICT_ANSI__ \
38#endif 37 && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 5 <= __clang_major__)))
39/* The condition (99 < __GNUC__) is temporary, until we know about the 38# define _GL_HAVE__STATIC_ASSERT 1
40 first G++ release that supports static_assert. */ 39# endif
41#if (99 < __GNUC__) && defined __cplusplus 40# if (202311 <= __STDC_VERSION__ \
42# define _GL_HAVE_STATIC_ASSERT 1 41 || (!defined __STRICT_ANSI__ && 9 <= __GNUC__))
42# define _GL_HAVE__STATIC_ASSERT1 1
43# endif
43#endif 44#endif
44 45
45/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other 46/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
46 system headers, defines a conflicting _Static_assert that is no 47 system headers, defines a conflicting _Static_assert that is no
47 better than ours; override it. */ 48 better than ours; override it. */
48#ifndef _GL_HAVE_STATIC_ASSERT 49#ifndef _GL_HAVE__STATIC_ASSERT
49# include <stddef.h> 50# include <stddef.h>
50# undef _Static_assert 51# undef _Static_assert
51#endif 52#endif
@@ -143,9 +144,9 @@
143 which do not support _Static_assert, also do not warn about the 144 which do not support _Static_assert, also do not warn about the
144 last declaration mentioned above. 145 last declaration mentioned above.
145 146
146 * GCC warns if -Wnested-externs is enabled and verify() is used 147 * GCC warns if -Wnested-externs is enabled and 'verify' is used
147 within a function body; but inside a function, you can always 148 within a function body; but inside a function, you can always
148 arrange to use verify_expr() instead. 149 arrange to use verify_expr instead.
149 150
150 * In C++, any struct definition inside sizeof is invalid. 151 * In C++, any struct definition inside sizeof is invalid.
151 Use a template type to work around the problem. */ 152 Use a template type to work around the problem. */
@@ -197,48 +198,95 @@ template <int w>
197#endif 198#endif
198 199
199/* Verify requirement R at compile-time, as a declaration without a 200/* Verify requirement R at compile-time, as a declaration without a
200 trailing ';'. If R is false, fail at compile-time, preferably 201 trailing ';'. If R is false, fail at compile-time.
201 with a diagnostic that includes the string-literal DIAGNOSTIC. 202
203 This macro requires three or more arguments but uses at most the first
204 two, so that the _Static_assert macro optionally defined below supports
205 both the C11 two-argument syntax and the C23 one-argument syntax.
202 206
203 Unfortunately, unlike C11, this implementation must appear as an 207 Unfortunately, unlike C11, this implementation must appear as an
204 ordinary declaration, and cannot appear inside struct { ... }. */ 208 ordinary declaration, and cannot appear inside struct { ... }. */
205 209
206#ifdef _GL_HAVE__STATIC_ASSERT 210#if 202311 <= __STDC_VERSION__ || 200410 <= __cpp_static_assert
207# define _GL_VERIFY _Static_assert 211# define _GL_VERIFY(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC)
212#elif defined _GL_HAVE__STATIC_ASSERT
213# define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC)
208#else 214#else
209# define _GL_VERIFY(R, DIAGNOSTIC) \ 215# define _GL_VERIFY(R, DIAGNOSTIC, ...) \
210 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ 216 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
211 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] 217 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
218# if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
219# pragma GCC diagnostic ignored "-Wnested-externs"
220# endif
212#endif 221#endif
213 222
214/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ 223/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
215#ifdef _GL_STATIC_ASSERT_H 224#ifdef _GL_STATIC_ASSERT_H
216# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert 225# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert
217# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) 226# if !defined _MSC_VER || defined __clang__
227# define _Static_assert(...) \
228 _GL_VERIFY (__VA_ARGS__, "static assertion failed", -)
229# else
230 /* Work around MSVC preprocessor incompatibility with ISO C; see
231 <https://stackoverflow.com/questions/5134523/>. */
232# define _Static_assert(R, ...) \
233 _GL_VERIFY ((R), "static assertion failed", -)
234# endif
218# endif 235# endif
219# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert 236# if (!defined static_assert \
220# define static_assert _Static_assert /* C11 requires this #define. */ 237 && __STDC_VERSION__ < 202311 \
238 && (!defined __cplusplus \
239 || (__cpp_static_assert < 201411 \
240 && __GNUG__ < 6 && __clang_major__ < 6)))
241# if defined __cplusplus && _MSC_VER >= 1900 && !defined __clang__
242/* MSVC 14 in C++ mode supports the two-arguments static_assert but not
243 the one-argument static_assert, and it does not support _Static_assert.
244 We have to play preprocessor tricks to distinguish the two cases.
245 Since the MSVC preprocessor is not ISO C compliant (see above),.
246 the solution is specific to MSVC. */
247# define _GL_EXPAND(x) x
248# define _GL_SA1(a1) static_assert ((a1), "static assertion failed")
249# define _GL_SA2 static_assert
250# define _GL_SA3 static_assert
251# define _GL_SA_PICK(x1,x2,x3,x4,...) x4
252# define static_assert(...) _GL_EXPAND(_GL_SA_PICK(__VA_ARGS__,_GL_SA3,_GL_SA2,_GL_SA1)) (__VA_ARGS__)
253# else
254# define static_assert _Static_assert /* C11 requires this #define. */
255# endif
221# endif 256# endif
222#endif 257#endif
223 258
224/* @assert.h omit start@ */ 259/* @assert.h omit start@ */
225 260
261#if defined __clang_major__ && __clang_major__ < 5
262# define _GL_HAS_BUILTIN_TRAP 0
263#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
264# define _GL_HAS_BUILTIN_TRAP 1
265#elif defined __has_builtin
266# define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap)
267#else
268# define _GL_HAS_BUILTIN_TRAP 0
269#endif
270
271#if defined __clang_major__ && __clang_major__ < 5
272# define _GL_HAS_BUILTIN_UNREACHABLE 0
273#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
274# define _GL_HAS_BUILTIN_UNREACHABLE 1
275#elif defined __has_builtin
276# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)
277#else
278# define _GL_HAS_BUILTIN_UNREACHABLE 0
279#endif
280
226/* Each of these macros verifies that its argument R is nonzero. To 281/* Each of these macros verifies that its argument R is nonzero. To
227 be portable, R should be an integer constant expression. Unlike 282 be portable, R should be an integer constant expression. Unlike
228 assert (R), there is no run-time overhead. 283 assert (R), there is no run-time overhead.
229 284
230 There are two macros, since no single macro can be used in all 285 There are two macros, since no single macro can be used in all
231 contexts in C. verify_true (R) is for scalar contexts, including 286 contexts in C. verify_expr (R, E) is for scalar contexts, including
232 integer constant expression contexts. verify (R) is for declaration 287 integer constant expression contexts. verify (R) is for declaration
233 contexts, e.g., the top level. */ 288 contexts, e.g., the top level. */
234 289
235/* Verify requirement R at compile-time, as an integer constant expression.
236 Return 1. This is equivalent to verify_expr (R, 1).
237
238 verify_true is obsolescent; please use verify_expr instead. */
239
240#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
241
242/* Verify requirement R at compile-time. Return the value of the 290/* Verify requirement R at compile-time. Return the value of the
243 expression E. */ 291 expression E. */
244 292
@@ -246,9 +294,56 @@ template <int w>
246 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) 294 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
247 295
248/* Verify requirement R at compile-time, as a declaration without a 296/* Verify requirement R at compile-time, as a declaration without a
249 trailing ';'. */ 297 trailing ';'. verify (R) acts like static_assert (R) except that
298 it is portable to C11/C++14 and earlier, it can issue better
299 diagnostics, and its name is shorter and may be more convenient. */
300
301#ifdef __PGI
302/* PGI barfs if R is long. */
303# define verify(R) _GL_VERIFY (R, "verify (...)", -)
304#else
305# define verify(R) _GL_VERIFY (R, "verify (" #R ")", -)
306#endif
250 307
251#define verify(R) _GL_VERIFY (R, "verify (" #R ")") 308/* Assume that R always holds. Behavior is undefined if R is false,
309 fails to evaluate, or has side effects.
310
311 'assume (R)' is a directive from the programmer telling the
312 compiler that R is true so the compiler needn't generate code to
313 test R. This is why 'assume' is in verify.h: it's related to
314 static checking (in this case, static checking done by the
315 programmer), not dynamic checking.
316
317 'assume (R)' can affect compilation of all the code, not just code
318 that happens to be executed after the assume (R) is "executed".
319 For example, if the code mistakenly does 'assert (R); assume (R);'
320 the compiler is entitled to optimize away the 'assert (R)'.
321
322 Although assuming R can help a compiler generate better code or
323 diagnostics, performance can suffer if R uses hard-to-optimize
324 features such as function calls not inlined by the compiler.
325
326 Avoid Clang's __builtin_assume, as it breaks GNU Emacs master
327 as of 2020-08-23T21:09:49Z!eggert@cs.ucla.edu; see
328 <https://bugs.gnu.org/43152#71>. It's not known whether this breakage
329 is a Clang bug or an Emacs bug; play it safe for now. */
330
331#if _GL_HAS_BUILTIN_UNREACHABLE
332# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
333#elif 1200 <= _MSC_VER
334# define assume(R) __assume (R)
335#elif 202311 <= __STDC_VERSION__
336# include <stddef.h>
337# define assume(R) ((R) ? (void) 0 : unreachable ())
338#elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP
339 /* Doing it this way helps various packages when configured with
340 --enable-gcc-warnings, which compiles with -Dlint. It's nicer
341 if 'assume' silences warnings with GCC 3.4 through GCC 4.4.7 (2012). */
342# define assume(R) ((R) ? (void) 0 : __builtin_trap ())
343#else
344 /* Some older tools grok NOTREACHED, e.g., Oracle Studio 12.6 (2017). */
345# define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
346#endif
252 347
253/* @assert.h omit end@ */ 348/* @assert.h omit end@ */
254 349
diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c
index 7d4dfbe..acd4e2d 100644
--- a/gl/vsnprintf.c
+++ b/gl/vsnprintf.c
@@ -1,19 +1,19 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2023 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU Lesser General Public License
16 with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
19# include <config.h> 19# include <config.h>
diff --git a/gl/w32sock.h b/gl/w32sock.h
index 44f3a1a..84e46e3 100644
--- a/gl/w32sock.h
+++ b/gl/w32sock.h
@@ -1,19 +1,19 @@
1/* w32sock.h --- internal auxiliary functions for Windows socket functions 1/* w32sock.h --- internal auxiliary functions for Windows socket functions
2 2
3 Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Paolo Bonzini */ 18/* Written by Paolo Bonzini */
19 19
@@ -26,7 +26,11 @@
26#include <io.h> 26#include <io.h>
27 27
28/* Get _get_osfhandle(). */ 28/* Get _get_osfhandle(). */
29#include "msvc-nothrow.h" 29#if GNULIB_MSVC_NOTHROW
30# include "msvc-nothrow.h"
31#else
32# include <io.h>
33#endif
30 34
31#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) 35#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
32#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY)) 36#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))
diff --git a/gl/warn-on-use.h b/gl/warn-on-use.h
new file mode 100644
index 0000000..3075603
--- /dev/null
+++ b/gl/warn-on-use.h
@@ -0,0 +1,149 @@
1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2023 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
18 for FUNCTION which will then trigger a compiler warning containing
19 the text of "literal string" anywhere that function is called, if
20 supported by the compiler. If the compiler does not support this
21 feature, the macro expands to an unused extern declaration.
22
23 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
24 attribute used in _GL_WARN_ON_USE. If the compiler does not support
25 this feature, it expands to empty.
26
27 These macros are useful for marking a function as a potential
28 portability trap, with the intent that "literal string" include
29 instructions on the replacement function that should be used
30 instead.
31 _GL_WARN_ON_USE is for functions with 'extern' linkage.
32 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
33 linkage.
34
35 However, one of the reasons that a function is a portability trap is
36 if it has the wrong signature. Declaring FUNCTION with a different
37 signature in C is a compilation error, so this macro must use the
38 same type as any existing declaration so that programs that avoid
39 the problematic FUNCTION do not fail to compile merely because they
40 included a header that poisoned the function. But this implies that
41 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
42 have a declaration. Use of this macro implies that there must not
43 be any other macro hiding the declaration of FUNCTION; but
44 undefining FUNCTION first is part of the poisoning process anyway
45 (although for symbols that are provided only via a macro, the result
46 is a compilation error rather than a warning containing
47 "literal string"). Also note that in C++, it is only safe to use if
48 FUNCTION has no overloads.
49
50 For an example, it is possible to poison 'getline' by:
51 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
52 [getline]) in configure.ac, which potentially defines
53 HAVE_RAW_DECL_GETLINE
54 - adding this code to a header that wraps the system <stdio.h>:
55 #undef getline
56 #if HAVE_RAW_DECL_GETLINE
57 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
58 "not universally present; use the gnulib module getline");
59 #endif
60
61 It is not possible to directly poison global variables. But it is
62 possible to write a wrapper accessor function, and poison that
63 (less common usage, like &environ, will cause a compilation error
64 rather than issue the nice warning, but the end result of informing
65 the developer about their portability problem is still achieved):
66 #if HAVE_RAW_DECL_ENVIRON
67 static char ***
68 rpl_environ (void) { return &environ; }
69 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
70 # undef environ
71 # define environ (*rpl_environ ())
72 #endif
73 or better (avoiding contradictory use of 'static' and 'extern'):
74 #if HAVE_RAW_DECL_ENVIRON
75 static char ***
76 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
77 rpl_environ (void) { return &environ; }
78 # undef environ
79 # define environ (*rpl_environ ())
80 #endif
81 */
82#ifndef _GL_WARN_ON_USE
83
84# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
85/* A compiler attribute is available in gcc versions 4.3.0 and later. */
86# define _GL_WARN_ON_USE(function, message) \
87_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
88# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
89 __attribute__ ((__warning__ (message)))
90# elif __clang_major__ >= 4
91/* Another compiler attribute is available in clang. */
92# define _GL_WARN_ON_USE(function, message) \
93_GL_WARN_EXTERN_C __typeof__ (function) function \
94 __attribute__ ((__diagnose_if__ (1, message, "warning")))
95# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
96 __attribute__ ((__diagnose_if__ (1, message, "warning")))
97# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
98/* Verify the existence of the function. */
99# define _GL_WARN_ON_USE(function, message) \
100_GL_WARN_EXTERN_C __typeof__ (function) function
101# define _GL_WARN_ON_USE_ATTRIBUTE(message)
102# else /* Unsupported. */
103# define _GL_WARN_ON_USE(function, message) \
104_GL_WARN_EXTERN_C int _gl_warn_on_use
105# define _GL_WARN_ON_USE_ATTRIBUTE(message)
106# endif
107#endif
108
109/* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
110 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
111 function is declared with the given prototype, consisting of return type,
112 parameters, and attributes.
113 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
114 not work in this case. */
115#ifndef _GL_WARN_ON_USE_CXX
116# if !defined __cplusplus
117# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
118 _GL_WARN_ON_USE (function, msg)
119# else
120# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
121/* A compiler attribute is available in gcc versions 4.3.0 and later. */
122# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
123extern rettype_gcc function parameters_and_attributes \
124 __attribute__ ((__warning__ (msg)))
125# elif __clang_major__ >= 4
126/* Another compiler attribute is available in clang. */
127# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
128extern rettype_clang function parameters_and_attributes \
129 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
130# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
131/* Verify the existence of the function. */
132# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
133extern rettype_gcc function parameters_and_attributes
134# else /* Unsupported. */
135# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
136_GL_WARN_EXTERN_C int _gl_warn_on_use
137# endif
138# endif
139#endif
140
141/* _GL_WARN_EXTERN_C declaration;
142 performs the declaration with C linkage. */
143#ifndef _GL_WARN_EXTERN_C
144# if defined __cplusplus
145# define _GL_WARN_EXTERN_C extern "C"
146# else
147# define _GL_WARN_EXTERN_C extern
148# endif
149#endif
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index b6e4362..09c9185 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,25 +1,25 @@
1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. 1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3 Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 Copyright (C) 2007-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
19 19
20/* 20/*
21 * ISO C 99 <wchar.h> for platforms that have issues. 21 * ISO C 99 <wchar.h> for platforms that have issues.
22 * <http://www.opengroup.org/susv3xbd/wchar.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wchar.h.html>
23 * 23 *
24 * For now, this just ensures proper prerequisite inclusion order and 24 * For now, this just ensures proper prerequisite inclusion order and
25 * the declaration of wcwidth(). 25 * the declaration of wcwidth().
@@ -30,15 +30,24 @@
30#endif 30#endif
31@PRAGMA_COLUMNS@ 31@PRAGMA_COLUMNS@
32 32
33#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H 33#if (((defined __need_mbstate_t || defined __need_wint_t) \
34 && !defined __MINGW32__) \
35 || (defined __hpux \
36 && ((defined _INTTYPES_INCLUDED \
37 && !defined _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H) \
38 || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) \
39 || (defined __MINGW32__ && defined __STRING_H_SOURCED__) \
40 || defined _GL_ALREADY_INCLUDING_WCHAR_H)
34/* Special invocation convention: 41/* Special invocation convention:
35 - Inside glibc and uClibc header files. 42 - Inside glibc and uClibc header files, but not MinGW.
36 - On HP-UX 11.00 we have a sequence of nested includes 43 - On HP-UX 11.00 we have a sequence of nested includes
37 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>, 44 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
38 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h> 45 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
39 and once directly. In both situations 'wint_t' is not yet defined, 46 and once directly. In both situations 'wint_t' is not yet defined,
40 therefore we cannot provide the function overrides; instead include only 47 therefore we cannot provide the function overrides; instead include only
41 the system's <wchar.h>. 48 the system's <wchar.h>.
49 - With MinGW 3.22, when <string.h> includes <wchar.h>, only some part of
50 <wchar.h> is actually processed, and that doesn't include 'mbstate_t'.
42 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and 51 - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
43 the latter includes <wchar.h>. But here, we have no way to detect whether 52 the latter includes <wchar.h>. But here, we have no way to detect whether
44 <wctype.h> is completely included or is still being included. */ 53 <wctype.h> is completely included or is still being included. */
@@ -56,20 +65,12 @@
56# include <features.h> /* for __GLIBC__ */ 65# include <features.h> /* for __GLIBC__ */
57#endif 66#endif
58 67
59/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 68/* In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
60 <wchar.h>.
61 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
62 included before <wchar.h>.
63 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
64 by <stddef.h>. 69 by <stddef.h>.
65 But avoid namespace pollution on glibc systems. */ 70 But avoid namespace pollution on glibc systems. */
66#if !(defined __GLIBC__ && !defined __UCLIBC__) 71#if !(defined __GLIBC__ && !defined __UCLIBC__)
67# include <stddef.h> 72# include <stddef.h>
68#endif 73#endif
69#ifndef __GLIBC__
70# include <stdio.h>
71# include <time.h>
72#endif
73 74
74/* Include the original <wchar.h> if it exists. 75/* Include the original <wchar.h> if it exists.
75 Some builds of uClibc lack it. */ 76 Some builds of uClibc lack it. */
@@ -83,12 +84,50 @@
83#ifndef _@GUARD_PREFIX@_WCHAR_H 84#ifndef _@GUARD_PREFIX@_WCHAR_H
84#define _@GUARD_PREFIX@_WCHAR_H 85#define _@GUARD_PREFIX@_WCHAR_H
85 86
87/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
88 that can be freed by passing them as the Ith argument to the
89 function F. */
90#ifndef _GL_ATTRIBUTE_DEALLOC
91# if __GNUC__ >= 11
92# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
93# else
94# define _GL_ATTRIBUTE_DEALLOC(f, i)
95# endif
96#endif
97
98/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that
99 can be freed via 'free'; it can be used only after declaring 'free'. */
100/* Applies to: functions. Cannot be used on inline functions. */
101#ifndef _GL_ATTRIBUTE_DEALLOC_FREE
102# if defined __cplusplus && defined __GNUC__ && !defined __clang__
103/* Work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108231> */
104# define _GL_ATTRIBUTE_DEALLOC_FREE \
105 _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1)
106# else
107# define _GL_ATTRIBUTE_DEALLOC_FREE \
108 _GL_ATTRIBUTE_DEALLOC (free, 1)
109# endif
110#endif
111
112/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
113 allocated memory. */
114/* Applies to: functions. */
115#ifndef _GL_ATTRIBUTE_MALLOC
116# if __GNUC__ >= 3 || defined __clang__
117# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
118# else
119# define _GL_ATTRIBUTE_MALLOC
120# endif
121#endif
122
86/* The __attribute__ feature is available in gcc versions 2.5 and later. 123/* The __attribute__ feature is available in gcc versions 2.5 and later.
87 The attribute __pure__ was added in gcc 2.96. */ 124 The attribute __pure__ was added in gcc 2.96. */
88#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 125#ifndef _GL_ATTRIBUTE_PURE
89# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 126# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
90#else 127# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
91# define _GL_ATTRIBUTE_PURE /* empty */ 128# else
129# define _GL_ATTRIBUTE_PURE /* empty */
130# endif
92#endif 131#endif
93 132
94/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 133/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -105,12 +144,16 @@
105# define WEOF -1 144# define WEOF -1
106# endif 145# endif
107#else 146#else
108/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>. 147/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
109 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be 148 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
110 "unchanged by default argument promotions". Override it. */ 149 wint_t must be "unchanged by default argument promotions". Override it. */
111# if defined _MSC_VER 150# if @GNULIBHEADERS_OVERRIDE_WINT_T@
112# if !GNULIB_defined_wint_t 151# if !GNULIB_defined_wint_t
113# include <crtdefs.h> 152# if @HAVE_CRTDEFS_H@
153# include <crtdefs.h>
154# else
155# include <stddef.h>
156# endif
114typedef unsigned int rpl_wint_t; 157typedef unsigned int rpl_wint_t;
115# undef wint_t 158# undef wint_t
116# define wint_t rpl_wint_t 159# define wint_t rpl_wint_t
@@ -125,16 +168,59 @@ typedef unsigned int rpl_wint_t;
125 168
126/* Override mbstate_t if it is too small. 169/* Override mbstate_t if it is too small.
127 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for 170 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
128 implementing mbrtowc for encodings like UTF-8. */ 171 implementing mbrtowc for encodings like UTF-8.
129#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ 172 On AIX and MSVC, mbrtowc needs to be overridden, but mbstate_t exists and is
173 large enough and overriding it would cause problems in C++ mode. */
174#if !(((defined _WIN32 && !defined __CYGWIN__) || @HAVE_MBSINIT@) && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
130# if !GNULIB_defined_mbstate_t 175# if !GNULIB_defined_mbstate_t
176# if !(defined _AIX || defined _MSC_VER)
131typedef int rpl_mbstate_t; 177typedef int rpl_mbstate_t;
132# undef mbstate_t 178# undef mbstate_t
133# define mbstate_t rpl_mbstate_t 179# define mbstate_t rpl_mbstate_t
180# endif
134# define GNULIB_defined_mbstate_t 1 181# define GNULIB_defined_mbstate_t 1
135# endif 182# endif
136#endif 183#endif
137 184
185/* Make _GL_ATTRIBUTE_DEALLOC_FREE work, even though <stdlib.h> may not have
186 been included yet. */
187#if @GNULIB_FREE_POSIX@
188# if (@REPLACE_FREE@ && !defined free \
189 && !(defined __cplusplus && defined GNULIB_NAMESPACE))
190/* We can't do '#define free rpl_free' here. */
191_GL_EXTERN_C void rpl_free (void *);
192# undef _GL_ATTRIBUTE_DEALLOC_FREE
193# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (rpl_free, 1)
194# else
195# if defined _MSC_VER && !defined free
196_GL_EXTERN_C
197# if defined _DLL
198 __declspec (dllimport)
199# endif
200 void __cdecl free (void *);
201# else
202# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
203_GL_EXTERN_C void free (void *) throw ();
204# else
205_GL_EXTERN_C void free (void *);
206# endif
207# endif
208# endif
209#else
210# if defined _MSC_VER && !defined free
211_GL_EXTERN_C
212# if defined _DLL
213 __declspec (dllimport)
214# endif
215 void __cdecl free (void *);
216# else
217# if defined __cplusplus && (__GLIBC__ + (__GLIBC_MINOR__ >= 14) > 2)
218_GL_EXTERN_C void free (void *) throw ();
219# else
220_GL_EXTERN_C void free (void *);
221# endif
222# endif
223#endif
138 224
139/* Convert a single-byte character to a wide character. */ 225/* Convert a single-byte character to a wide character. */
140#if @GNULIB_BTOWC@ 226#if @GNULIB_BTOWC@
@@ -149,9 +235,12 @@ _GL_CXXALIAS_RPL (btowc, wint_t, (int c));
149# if !@HAVE_BTOWC@ 235# if !@HAVE_BTOWC@
150_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE); 236_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
151# endif 237# endif
152_GL_CXXALIAS_SYS (btowc, wint_t, (int c)); 238/* Need to cast, because on mingw, the return type is 'unsigned short'. */
239_GL_CXXALIAS_SYS_CAST (btowc, wint_t, (int c));
153# endif 240# endif
241# if __GLIBC__ >= 2
154_GL_CXXALIASWARN (btowc); 242_GL_CXXALIASWARN (btowc);
243# endif
155#elif defined GNULIB_POSIXCHECK 244#elif defined GNULIB_POSIXCHECK
156# undef btowc 245# undef btowc
157# if HAVE_RAW_DECL_BTOWC 246# if HAVE_RAW_DECL_BTOWC
@@ -177,7 +266,9 @@ _GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
177# endif 266# endif
178_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); 267_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
179# endif 268# endif
269# if __GLIBC__ >= 2
180_GL_CXXALIASWARN (wctob); 270_GL_CXXALIASWARN (wctob);
271# endif
181#elif defined GNULIB_POSIXCHECK 272#elif defined GNULIB_POSIXCHECK
182# undef wctob 273# undef wctob
183# if HAVE_RAW_DECL_WCTOB 274# if HAVE_RAW_DECL_WCTOB
@@ -202,7 +293,9 @@ _GL_FUNCDECL_SYS (mbsinit, int, (const mbstate_t *ps));
202# endif 293# endif
203_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps)); 294_GL_CXXALIAS_SYS (mbsinit, int, (const mbstate_t *ps));
204# endif 295# endif
296# if __GLIBC__ >= 2
205_GL_CXXALIASWARN (mbsinit); 297_GL_CXXALIASWARN (mbsinit);
298# endif
206#elif defined GNULIB_POSIXCHECK 299#elif defined GNULIB_POSIXCHECK
207# undef mbsinit 300# undef mbsinit
208# if HAVE_RAW_DECL_MBSINIT 301# if HAVE_RAW_DECL_MBSINIT
@@ -220,18 +313,24 @@ _GL_WARN_ON_USE (mbsinit, "mbsinit is unportable - "
220# define mbrtowc rpl_mbrtowc 313# define mbrtowc rpl_mbrtowc
221# endif 314# endif
222_GL_FUNCDECL_RPL (mbrtowc, size_t, 315_GL_FUNCDECL_RPL (mbrtowc, size_t,
223 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 316 (wchar_t *restrict pwc, const char *restrict s, size_t n,
317 mbstate_t *restrict ps));
224_GL_CXXALIAS_RPL (mbrtowc, size_t, 318_GL_CXXALIAS_RPL (mbrtowc, size_t,
225 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 319 (wchar_t *restrict pwc, const char *restrict s, size_t n,
320 mbstate_t *restrict ps));
226# else 321# else
227# if !@HAVE_MBRTOWC@ 322# if !@HAVE_MBRTOWC@
228_GL_FUNCDECL_SYS (mbrtowc, size_t, 323_GL_FUNCDECL_SYS (mbrtowc, size_t,
229 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 324 (wchar_t *restrict pwc, const char *restrict s, size_t n,
325 mbstate_t *restrict ps));
230# endif 326# endif
231_GL_CXXALIAS_SYS (mbrtowc, size_t, 327_GL_CXXALIAS_SYS (mbrtowc, size_t,
232 (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)); 328 (wchar_t *restrict pwc, const char *restrict s, size_t n,
329 mbstate_t *restrict ps));
233# endif 330# endif
331# if __GLIBC__ >= 2
234_GL_CXXALIASWARN (mbrtowc); 332_GL_CXXALIASWARN (mbrtowc);
333# endif
235#elif defined GNULIB_POSIXCHECK 334#elif defined GNULIB_POSIXCHECK
236# undef mbrtowc 335# undef mbrtowc
237# if HAVE_RAW_DECL_MBRTOWC 336# if HAVE_RAW_DECL_MBRTOWC
@@ -248,15 +347,21 @@ _GL_WARN_ON_USE (mbrtowc, "mbrtowc is unportable - "
248# undef mbrlen 347# undef mbrlen
249# define mbrlen rpl_mbrlen 348# define mbrlen rpl_mbrlen
250# endif 349# endif
251_GL_FUNCDECL_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 350_GL_FUNCDECL_RPL (mbrlen, size_t,
252_GL_CXXALIAS_RPL (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 351 (const char *restrict s, size_t n, mbstate_t *restrict ps));
352_GL_CXXALIAS_RPL (mbrlen, size_t,
353 (const char *restrict s, size_t n, mbstate_t *restrict ps));
253# else 354# else
254# if !@HAVE_MBRLEN@ 355# if !@HAVE_MBRLEN@
255_GL_FUNCDECL_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 356_GL_FUNCDECL_SYS (mbrlen, size_t,
357 (const char *restrict s, size_t n, mbstate_t *restrict ps));
256# endif 358# endif
257_GL_CXXALIAS_SYS (mbrlen, size_t, (const char *s, size_t n, mbstate_t *ps)); 359_GL_CXXALIAS_SYS (mbrlen, size_t,
360 (const char *restrict s, size_t n, mbstate_t *restrict ps));
258# endif 361# endif
362# if __GLIBC__ >= 2
259_GL_CXXALIASWARN (mbrlen); 363_GL_CXXALIASWARN (mbrlen);
364# endif
260#elif defined GNULIB_POSIXCHECK 365#elif defined GNULIB_POSIXCHECK
261# undef mbrlen 366# undef mbrlen
262# if HAVE_RAW_DECL_MBRLEN 367# if HAVE_RAW_DECL_MBRLEN
@@ -274,22 +379,30 @@ _GL_WARN_ON_USE (mbrlen, "mbrlen is unportable - "
274# define mbsrtowcs rpl_mbsrtowcs 379# define mbsrtowcs rpl_mbsrtowcs
275# endif 380# endif
276_GL_FUNCDECL_RPL (mbsrtowcs, size_t, 381_GL_FUNCDECL_RPL (mbsrtowcs, size_t,
277 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) 382 (wchar_t *restrict dest,
383 const char **restrict srcp, size_t len,
384 mbstate_t *restrict ps)
278 _GL_ARG_NONNULL ((2))); 385 _GL_ARG_NONNULL ((2)));
279_GL_CXXALIAS_RPL (mbsrtowcs, size_t, 386_GL_CXXALIAS_RPL (mbsrtowcs, size_t,
280 (wchar_t *dest, const char **srcp, size_t len, 387 (wchar_t *restrict dest,
281 mbstate_t *ps)); 388 const char **restrict srcp, size_t len,
389 mbstate_t *restrict ps));
282# else 390# else
283# if !@HAVE_MBSRTOWCS@ 391# if !@HAVE_MBSRTOWCS@
284_GL_FUNCDECL_SYS (mbsrtowcs, size_t, 392_GL_FUNCDECL_SYS (mbsrtowcs, size_t,
285 (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps) 393 (wchar_t *restrict dest,
394 const char **restrict srcp, size_t len,
395 mbstate_t *restrict ps)
286 _GL_ARG_NONNULL ((2))); 396 _GL_ARG_NONNULL ((2)));
287# endif 397# endif
288_GL_CXXALIAS_SYS (mbsrtowcs, size_t, 398_GL_CXXALIAS_SYS (mbsrtowcs, size_t,
289 (wchar_t *dest, const char **srcp, size_t len, 399 (wchar_t *restrict dest,
290 mbstate_t *ps)); 400 const char **restrict srcp, size_t len,
401 mbstate_t *restrict ps));
291# endif 402# endif
403# if __GLIBC__ >= 2
292_GL_CXXALIASWARN (mbsrtowcs); 404_GL_CXXALIASWARN (mbsrtowcs);
405# endif
293#elif defined GNULIB_POSIXCHECK 406#elif defined GNULIB_POSIXCHECK
294# undef mbsrtowcs 407# undef mbsrtowcs
295# if HAVE_RAW_DECL_MBSRTOWCS 408# if HAVE_RAW_DECL_MBSRTOWCS
@@ -307,22 +420,26 @@ _GL_WARN_ON_USE (mbsrtowcs, "mbsrtowcs is unportable - "
307# define mbsnrtowcs rpl_mbsnrtowcs 420# define mbsnrtowcs rpl_mbsnrtowcs
308# endif 421# endif
309_GL_FUNCDECL_RPL (mbsnrtowcs, size_t, 422_GL_FUNCDECL_RPL (mbsnrtowcs, size_t,
310 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 423 (wchar_t *restrict dest,
311 mbstate_t *ps) 424 const char **restrict srcp, size_t srclen, size_t len,
425 mbstate_t *restrict ps)
312 _GL_ARG_NONNULL ((2))); 426 _GL_ARG_NONNULL ((2)));
313_GL_CXXALIAS_RPL (mbsnrtowcs, size_t, 427_GL_CXXALIAS_RPL (mbsnrtowcs, size_t,
314 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 428 (wchar_t *restrict dest,
315 mbstate_t *ps)); 429 const char **restrict srcp, size_t srclen, size_t len,
430 mbstate_t *restrict ps));
316# else 431# else
317# if !@HAVE_MBSNRTOWCS@ 432# if !@HAVE_MBSNRTOWCS@
318_GL_FUNCDECL_SYS (mbsnrtowcs, size_t, 433_GL_FUNCDECL_SYS (mbsnrtowcs, size_t,
319 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 434 (wchar_t *restrict dest,
320 mbstate_t *ps) 435 const char **restrict srcp, size_t srclen, size_t len,
436 mbstate_t *restrict ps)
321 _GL_ARG_NONNULL ((2))); 437 _GL_ARG_NONNULL ((2)));
322# endif 438# endif
323_GL_CXXALIAS_SYS (mbsnrtowcs, size_t, 439_GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
324 (wchar_t *dest, const char **srcp, size_t srclen, size_t len, 440 (wchar_t *restrict dest,
325 mbstate_t *ps)); 441 const char **restrict srcp, size_t srclen, size_t len,
442 mbstate_t *restrict ps));
326# endif 443# endif
327_GL_CXXALIASWARN (mbsnrtowcs); 444_GL_CXXALIASWARN (mbsnrtowcs);
328#elif defined GNULIB_POSIXCHECK 445#elif defined GNULIB_POSIXCHECK
@@ -341,15 +458,21 @@ _GL_WARN_ON_USE (mbsnrtowcs, "mbsnrtowcs is unportable - "
341# undef wcrtomb 458# undef wcrtomb
342# define wcrtomb rpl_wcrtomb 459# define wcrtomb rpl_wcrtomb
343# endif 460# endif
344_GL_FUNCDECL_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 461_GL_FUNCDECL_RPL (wcrtomb, size_t,
345_GL_CXXALIAS_RPL (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 462 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
463_GL_CXXALIAS_RPL (wcrtomb, size_t,
464 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
346# else 465# else
347# if !@HAVE_WCRTOMB@ 466# if !@HAVE_WCRTOMB@
348_GL_FUNCDECL_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 467_GL_FUNCDECL_SYS (wcrtomb, size_t,
468 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
349# endif 469# endif
350_GL_CXXALIAS_SYS (wcrtomb, size_t, (char *s, wchar_t wc, mbstate_t *ps)); 470_GL_CXXALIAS_SYS (wcrtomb, size_t,
471 (char *restrict s, wchar_t wc, mbstate_t *restrict ps));
351# endif 472# endif
473# if __GLIBC__ >= 2
352_GL_CXXALIASWARN (wcrtomb); 474_GL_CXXALIASWARN (wcrtomb);
475# endif
353#elif defined GNULIB_POSIXCHECK 476#elif defined GNULIB_POSIXCHECK
354# undef wcrtomb 477# undef wcrtomb
355# if HAVE_RAW_DECL_WCRTOMB 478# if HAVE_RAW_DECL_WCRTOMB
@@ -367,22 +490,30 @@ _GL_WARN_ON_USE (wcrtomb, "wcrtomb is unportable - "
367# define wcsrtombs rpl_wcsrtombs 490# define wcsrtombs rpl_wcsrtombs
368# endif 491# endif
369_GL_FUNCDECL_RPL (wcsrtombs, size_t, 492_GL_FUNCDECL_RPL (wcsrtombs, size_t,
370 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) 493 (char *restrict dest, const wchar_t **restrict srcp,
494 size_t len,
495 mbstate_t *restrict ps)
371 _GL_ARG_NONNULL ((2))); 496 _GL_ARG_NONNULL ((2)));
372_GL_CXXALIAS_RPL (wcsrtombs, size_t, 497_GL_CXXALIAS_RPL (wcsrtombs, size_t,
373 (char *dest, const wchar_t **srcp, size_t len, 498 (char *restrict dest, const wchar_t **restrict srcp,
374 mbstate_t *ps)); 499 size_t len,
500 mbstate_t *restrict ps));
375# else 501# else
376# if !@HAVE_WCSRTOMBS@ 502# if !@HAVE_WCSRTOMBS@
377_GL_FUNCDECL_SYS (wcsrtombs, size_t, 503_GL_FUNCDECL_SYS (wcsrtombs, size_t,
378 (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps) 504 (char *restrict dest, const wchar_t **restrict srcp,
505 size_t len,
506 mbstate_t *restrict ps)
379 _GL_ARG_NONNULL ((2))); 507 _GL_ARG_NONNULL ((2)));
380# endif 508# endif
381_GL_CXXALIAS_SYS (wcsrtombs, size_t, 509_GL_CXXALIAS_SYS (wcsrtombs, size_t,
382 (char *dest, const wchar_t **srcp, size_t len, 510 (char *restrict dest, const wchar_t **restrict srcp,
383 mbstate_t *ps)); 511 size_t len,
512 mbstate_t *restrict ps));
384# endif 513# endif
514# if __GLIBC__ >= 2
385_GL_CXXALIASWARN (wcsrtombs); 515_GL_CXXALIASWARN (wcsrtombs);
516# endif
386#elif defined GNULIB_POSIXCHECK 517#elif defined GNULIB_POSIXCHECK
387# undef wcsrtombs 518# undef wcsrtombs
388# if HAVE_RAW_DECL_WCSRTOMBS 519# if HAVE_RAW_DECL_WCSRTOMBS
@@ -400,24 +531,34 @@ _GL_WARN_ON_USE (wcsrtombs, "wcsrtombs is unportable - "
400# define wcsnrtombs rpl_wcsnrtombs 531# define wcsnrtombs rpl_wcsnrtombs
401# endif 532# endif
402_GL_FUNCDECL_RPL (wcsnrtombs, size_t, 533_GL_FUNCDECL_RPL (wcsnrtombs, size_t,
403 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 534 (char *restrict dest,
404 mbstate_t *ps) 535 const wchar_t **restrict srcp, size_t srclen,
536 size_t len,
537 mbstate_t *restrict ps)
405 _GL_ARG_NONNULL ((2))); 538 _GL_ARG_NONNULL ((2)));
406_GL_CXXALIAS_RPL (wcsnrtombs, size_t, 539_GL_CXXALIAS_RPL (wcsnrtombs, size_t,
407 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 540 (char *restrict dest,
408 mbstate_t *ps)); 541 const wchar_t **restrict srcp, size_t srclen,
542 size_t len,
543 mbstate_t *restrict ps));
409# else 544# else
410# if !@HAVE_WCSNRTOMBS@ 545# if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
411_GL_FUNCDECL_SYS (wcsnrtombs, size_t, 546_GL_FUNCDECL_SYS (wcsnrtombs, size_t,
412 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 547 (char *restrict dest,
413 mbstate_t *ps) 548 const wchar_t **restrict srcp, size_t srclen,
549 size_t len,
550 mbstate_t *restrict ps)
414 _GL_ARG_NONNULL ((2))); 551 _GL_ARG_NONNULL ((2)));
415# endif 552# endif
416_GL_CXXALIAS_SYS (wcsnrtombs, size_t, 553_GL_CXXALIAS_SYS (wcsnrtombs, size_t,
417 (char *dest, const wchar_t **srcp, size_t srclen, size_t len, 554 (char *restrict dest,
418 mbstate_t *ps)); 555 const wchar_t **restrict srcp, size_t srclen,
556 size_t len,
557 mbstate_t *restrict ps));
419# endif 558# endif
559# if __GLIBC__ >= 2
420_GL_CXXALIASWARN (wcsnrtombs); 560_GL_CXXALIASWARN (wcsnrtombs);
561# endif
421#elif defined GNULIB_POSIXCHECK 562#elif defined GNULIB_POSIXCHECK
422# undef wcsnrtombs 563# undef wcsnrtombs
423# if HAVE_RAW_DECL_WCSNRTOMBS 564# if HAVE_RAW_DECL_WCSNRTOMBS
@@ -443,7 +584,9 @@ _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
443# endif 584# endif
444_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); 585_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
445# endif 586# endif
587# if __GLIBC__ >= 2
446_GL_CXXALIASWARN (wcwidth); 588_GL_CXXALIASWARN (wcwidth);
589# endif
447#elif defined GNULIB_POSIXCHECK 590#elif defined GNULIB_POSIXCHECK
448# undef wcwidth 591# undef wcwidth
449# if HAVE_RAW_DECL_WCWIDTH 592# if HAVE_RAW_DECL_WCWIDTH
@@ -472,7 +615,7 @@ _GL_CXXALIAS_SYS_CAST2 (wmemchr,
472_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 615_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
473_GL_CXXALIASWARN1 (wmemchr, const wchar_t *, 616_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
474 (const wchar_t *s, wchar_t c, size_t n)); 617 (const wchar_t *s, wchar_t c, size_t n));
475# else 618# elif __GLIBC__ >= 2
476_GL_CXXALIASWARN (wmemchr); 619_GL_CXXALIASWARN (wmemchr);
477# endif 620# endif
478#elif defined GNULIB_POSIXCHECK 621#elif defined GNULIB_POSIXCHECK
@@ -493,7 +636,9 @@ _GL_FUNCDECL_SYS (wmemcmp, int,
493# endif 636# endif
494_GL_CXXALIAS_SYS (wmemcmp, int, 637_GL_CXXALIAS_SYS (wmemcmp, int,
495 (const wchar_t *s1, const wchar_t *s2, size_t n)); 638 (const wchar_t *s1, const wchar_t *s2, size_t n));
639# if __GLIBC__ >= 2
496_GL_CXXALIASWARN (wmemcmp); 640_GL_CXXALIASWARN (wmemcmp);
641# endif
497#elif defined GNULIB_POSIXCHECK 642#elif defined GNULIB_POSIXCHECK
498# undef wmemcmp 643# undef wmemcmp
499# if HAVE_RAW_DECL_WMEMCMP 644# if HAVE_RAW_DECL_WMEMCMP
@@ -507,11 +652,15 @@ _GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
507#if @GNULIB_WMEMCPY@ 652#if @GNULIB_WMEMCPY@
508# if !@HAVE_WMEMCPY@ 653# if !@HAVE_WMEMCPY@
509_GL_FUNCDECL_SYS (wmemcpy, wchar_t *, 654_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
510 (wchar_t *dest, const wchar_t *src, size_t n)); 655 (wchar_t *restrict dest,
656 const wchar_t *restrict src, size_t n));
511# endif 657# endif
512_GL_CXXALIAS_SYS (wmemcpy, wchar_t *, 658_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
513 (wchar_t *dest, const wchar_t *src, size_t n)); 659 (wchar_t *restrict dest,
660 const wchar_t *restrict src, size_t n));
661# if __GLIBC__ >= 2
514_GL_CXXALIASWARN (wmemcpy); 662_GL_CXXALIASWARN (wmemcpy);
663# endif
515#elif defined GNULIB_POSIXCHECK 664#elif defined GNULIB_POSIXCHECK
516# undef wmemcpy 665# undef wmemcpy
517# if HAVE_RAW_DECL_WMEMCPY 666# if HAVE_RAW_DECL_WMEMCPY
@@ -530,7 +679,9 @@ _GL_FUNCDECL_SYS (wmemmove, wchar_t *,
530# endif 679# endif
531_GL_CXXALIAS_SYS (wmemmove, wchar_t *, 680_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
532 (wchar_t *dest, const wchar_t *src, size_t n)); 681 (wchar_t *dest, const wchar_t *src, size_t n));
682# if __GLIBC__ >= 2
533_GL_CXXALIASWARN (wmemmove); 683_GL_CXXALIASWARN (wmemmove);
684# endif
534#elif defined GNULIB_POSIXCHECK 685#elif defined GNULIB_POSIXCHECK
535# undef wmemmove 686# undef wmemmove
536# if HAVE_RAW_DECL_WMEMMOVE 687# if HAVE_RAW_DECL_WMEMMOVE
@@ -540,13 +691,38 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
540#endif 691#endif
541 692
542 693
694/* Copy N wide characters of SRC to DEST.
695 Return pointer to wide characters after the last written wide character. */
696#if @GNULIB_WMEMPCPY@
697# if !@HAVE_WMEMPCPY@
698_GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
699 (wchar_t *restrict dest,
700 const wchar_t *restrict src, size_t n));
701# endif
702_GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
703 (wchar_t *restrict dest,
704 const wchar_t *restrict src, size_t n));
705# if __GLIBC__ >= 2
706_GL_CXXALIASWARN (wmempcpy);
707# endif
708#elif defined GNULIB_POSIXCHECK
709# undef wmempcpy
710# if HAVE_RAW_DECL_WMEMPCPY
711_GL_WARN_ON_USE (wmempcpy, "wmempcpy is unportable - "
712 "use gnulib module wmempcpy for portability");
713# endif
714#endif
715
716
543/* Set N wide characters of S to C. */ 717/* Set N wide characters of S to C. */
544#if @GNULIB_WMEMSET@ 718#if @GNULIB_WMEMSET@
545# if !@HAVE_WMEMSET@ 719# if !@HAVE_WMEMSET@
546_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 720_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
547# endif 721# endif
548_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n)); 722_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
723# if __GLIBC__ >= 2
549_GL_CXXALIASWARN (wmemset); 724_GL_CXXALIASWARN (wmemset);
725# endif
550#elif defined GNULIB_POSIXCHECK 726#elif defined GNULIB_POSIXCHECK
551# undef wmemset 727# undef wmemset
552# if HAVE_RAW_DECL_WMEMSET 728# if HAVE_RAW_DECL_WMEMSET
@@ -562,7 +738,9 @@ _GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
562_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE); 738_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
563# endif 739# endif
564_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s)); 740_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
741# if __GLIBC__ >= 2
565_GL_CXXALIASWARN (wcslen); 742_GL_CXXALIASWARN (wcslen);
743# endif
566#elif defined GNULIB_POSIXCHECK 744#elif defined GNULIB_POSIXCHECK
567# undef wcslen 745# undef wcslen
568# if HAVE_RAW_DECL_WCSLEN 746# if HAVE_RAW_DECL_WCSLEN
@@ -574,7 +752,10 @@ _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
574 752
575/* Return the number of wide characters in S, but at most MAXLEN. */ 753/* Return the number of wide characters in S, but at most MAXLEN. */
576#if @GNULIB_WCSNLEN@ 754#if @GNULIB_WCSNLEN@
577# if !@HAVE_WCSNLEN@ 755/* On Solaris 11.3, the header files declare the function in the std::
756 namespace, not in the global namespace. So, force a declaration in
757 the global namespace. */
758# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
578_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen) 759_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
579 _GL_ATTRIBUTE_PURE); 760 _GL_ATTRIBUTE_PURE);
580# endif 761# endif
@@ -592,10 +773,14 @@ _GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
592/* Copy SRC to DEST. */ 773/* Copy SRC to DEST. */
593#if @GNULIB_WCSCPY@ 774#if @GNULIB_WCSCPY@
594# if !@HAVE_WCSCPY@ 775# if !@HAVE_WCSCPY@
595_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 776_GL_FUNCDECL_SYS (wcscpy, wchar_t *,
777 (wchar_t *restrict dest, const wchar_t *restrict src));
596# endif 778# endif
597_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 779_GL_CXXALIAS_SYS (wcscpy, wchar_t *,
780 (wchar_t *restrict dest, const wchar_t *restrict src));
781# if __GLIBC__ >= 2
598_GL_CXXALIASWARN (wcscpy); 782_GL_CXXALIASWARN (wcscpy);
783# endif
599#elif defined GNULIB_POSIXCHECK 784#elif defined GNULIB_POSIXCHECK
600# undef wcscpy 785# undef wcscpy
601# if HAVE_RAW_DECL_WCSCPY 786# if HAVE_RAW_DECL_WCSCPY
@@ -607,10 +792,15 @@ _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
607 792
608/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */ 793/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
609#if @GNULIB_WCPCPY@ 794#if @GNULIB_WCPCPY@
610# if !@HAVE_WCPCPY@ 795/* On Solaris 11.3, the header files declare the function in the std::
611_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 796 namespace, not in the global namespace. So, force a declaration in
612# endif 797 the global namespace. */
613_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src)); 798# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
799_GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
800 (wchar_t *restrict dest, const wchar_t *restrict src));
801# endif
802_GL_CXXALIAS_SYS (wcpcpy, wchar_t *,
803 (wchar_t *restrict dest, const wchar_t *restrict src));
614_GL_CXXALIASWARN (wcpcpy); 804_GL_CXXALIASWARN (wcpcpy);
615#elif defined GNULIB_POSIXCHECK 805#elif defined GNULIB_POSIXCHECK
616# undef wcpcpy 806# undef wcpcpy
@@ -625,11 +815,15 @@ _GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
625#if @GNULIB_WCSNCPY@ 815#if @GNULIB_WCSNCPY@
626# if !@HAVE_WCSNCPY@ 816# if !@HAVE_WCSNCPY@
627_GL_FUNCDECL_SYS (wcsncpy, wchar_t *, 817_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
628 (wchar_t *dest, const wchar_t *src, size_t n)); 818 (wchar_t *restrict dest,
819 const wchar_t *restrict src, size_t n));
629# endif 820# endif
630_GL_CXXALIAS_SYS (wcsncpy, wchar_t *, 821_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
631 (wchar_t *dest, const wchar_t *src, size_t n)); 822 (wchar_t *restrict dest,
823 const wchar_t *restrict src, size_t n));
824# if __GLIBC__ >= 2
632_GL_CXXALIASWARN (wcsncpy); 825_GL_CXXALIASWARN (wcsncpy);
826# endif
633#elif defined GNULIB_POSIXCHECK 827#elif defined GNULIB_POSIXCHECK
634# undef wcsncpy 828# undef wcsncpy
635# if HAVE_RAW_DECL_WCSNCPY 829# if HAVE_RAW_DECL_WCSNCPY
@@ -642,12 +836,17 @@ _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
642/* Copy no more than N characters of SRC to DEST, returning the address of 836/* Copy no more than N characters of SRC to DEST, returning the address of
643 the last character written into DEST. */ 837 the last character written into DEST. */
644#if @GNULIB_WCPNCPY@ 838#if @GNULIB_WCPNCPY@
645# if !@HAVE_WCPNCPY@ 839/* On Solaris 11.3, the header files declare the function in the std::
840 namespace, not in the global namespace. So, force a declaration in
841 the global namespace. */
842# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
646_GL_FUNCDECL_SYS (wcpncpy, wchar_t *, 843_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
647 (wchar_t *dest, const wchar_t *src, size_t n)); 844 (wchar_t *restrict dest,
845 const wchar_t *restrict src, size_t n));
648# endif 846# endif
649_GL_CXXALIAS_SYS (wcpncpy, wchar_t *, 847_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
650 (wchar_t *dest, const wchar_t *src, size_t n)); 848 (wchar_t *restrict dest,
849 const wchar_t *restrict src, size_t n));
651_GL_CXXALIASWARN (wcpncpy); 850_GL_CXXALIASWARN (wcpncpy);
652#elif defined GNULIB_POSIXCHECK 851#elif defined GNULIB_POSIXCHECK
653# undef wcpncpy 852# undef wcpncpy
@@ -661,10 +860,14 @@ _GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
661/* Append SRC onto DEST. */ 860/* Append SRC onto DEST. */
662#if @GNULIB_WCSCAT@ 861#if @GNULIB_WCSCAT@
663# if !@HAVE_WCSCAT@ 862# if !@HAVE_WCSCAT@
664_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); 863_GL_FUNCDECL_SYS (wcscat, wchar_t *,
864 (wchar_t *restrict dest, const wchar_t *restrict src));
665# endif 865# endif
666_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src)); 866_GL_CXXALIAS_SYS (wcscat, wchar_t *,
867 (wchar_t *restrict dest, const wchar_t *restrict src));
868# if __GLIBC__ >= 2
667_GL_CXXALIASWARN (wcscat); 869_GL_CXXALIASWARN (wcscat);
870# endif
668#elif defined GNULIB_POSIXCHECK 871#elif defined GNULIB_POSIXCHECK
669# undef wcscat 872# undef wcscat
670# if HAVE_RAW_DECL_WCSCAT 873# if HAVE_RAW_DECL_WCSCAT
@@ -678,11 +881,15 @@ _GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
678#if @GNULIB_WCSNCAT@ 881#if @GNULIB_WCSNCAT@
679# if !@HAVE_WCSNCAT@ 882# if !@HAVE_WCSNCAT@
680_GL_FUNCDECL_SYS (wcsncat, wchar_t *, 883_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
681 (wchar_t *dest, const wchar_t *src, size_t n)); 884 (wchar_t *restrict dest, const wchar_t *restrict src,
885 size_t n));
682# endif 886# endif
683_GL_CXXALIAS_SYS (wcsncat, wchar_t *, 887_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
684 (wchar_t *dest, const wchar_t *src, size_t n)); 888 (wchar_t *restrict dest, const wchar_t *restrict src,
889 size_t n));
890# if __GLIBC__ >= 2
685_GL_CXXALIASWARN (wcsncat); 891_GL_CXXALIASWARN (wcsncat);
892# endif
686#elif defined GNULIB_POSIXCHECK 893#elif defined GNULIB_POSIXCHECK
687# undef wcsncat 894# undef wcsncat
688# if HAVE_RAW_DECL_WCSNCAT 895# if HAVE_RAW_DECL_WCSNCAT
@@ -699,7 +906,9 @@ _GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
699 _GL_ATTRIBUTE_PURE); 906 _GL_ATTRIBUTE_PURE);
700# endif 907# endif
701_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)); 908_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
909# if __GLIBC__ >= 2
702_GL_CXXALIASWARN (wcscmp); 910_GL_CXXALIASWARN (wcscmp);
911# endif
703#elif defined GNULIB_POSIXCHECK 912#elif defined GNULIB_POSIXCHECK
704# undef wcscmp 913# undef wcscmp
705# if HAVE_RAW_DECL_WCSCMP 914# if HAVE_RAW_DECL_WCSCMP
@@ -718,7 +927,9 @@ _GL_FUNCDECL_SYS (wcsncmp, int,
718# endif 927# endif
719_GL_CXXALIAS_SYS (wcsncmp, int, 928_GL_CXXALIAS_SYS (wcsncmp, int,
720 (const wchar_t *s1, const wchar_t *s2, size_t n)); 929 (const wchar_t *s1, const wchar_t *s2, size_t n));
930# if __GLIBC__ >= 2
721_GL_CXXALIASWARN (wcsncmp); 931_GL_CXXALIASWARN (wcsncmp);
932# endif
722#elif defined GNULIB_POSIXCHECK 933#elif defined GNULIB_POSIXCHECK
723# undef wcsncmp 934# undef wcsncmp
724# if HAVE_RAW_DECL_WCSNCMP 935# if HAVE_RAW_DECL_WCSNCMP
@@ -730,7 +941,10 @@ _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
730 941
731/* Compare S1 and S2, ignoring case. */ 942/* Compare S1 and S2, ignoring case. */
732#if @GNULIB_WCSCASECMP@ 943#if @GNULIB_WCSCASECMP@
733# if !@HAVE_WCSCASECMP@ 944/* On Solaris 11.3, the header files declare the function in the std::
945 namespace, not in the global namespace. So, force a declaration in
946 the global namespace. */
947# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
734_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2) 948_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
735 _GL_ATTRIBUTE_PURE); 949 _GL_ATTRIBUTE_PURE);
736# endif 950# endif
@@ -747,7 +961,10 @@ _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
747 961
748/* Compare no more than N chars of S1 and S2, ignoring case. */ 962/* Compare no more than N chars of S1 and S2, ignoring case. */
749#if @GNULIB_WCSNCASECMP@ 963#if @GNULIB_WCSNCASECMP@
750# if !@HAVE_WCSNCASECMP@ 964/* On Solaris 11.3, the header files declare the function in the std::
965 namespace, not in the global namespace. So, force a declaration in
966 the global namespace. */
967# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
751_GL_FUNCDECL_SYS (wcsncasecmp, int, 968_GL_FUNCDECL_SYS (wcsncasecmp, int,
752 (const wchar_t *s1, const wchar_t *s2, size_t n) 969 (const wchar_t *s1, const wchar_t *s2, size_t n)
753 _GL_ATTRIBUTE_PURE); 970 _GL_ATTRIBUTE_PURE);
@@ -771,7 +988,9 @@ _GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
771_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 988_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
772# endif 989# endif
773_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2)); 990_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
991# if __GLIBC__ >= 2
774_GL_CXXALIASWARN (wcscoll); 992_GL_CXXALIASWARN (wcscoll);
993# endif
775#elif defined GNULIB_POSIXCHECK 994#elif defined GNULIB_POSIXCHECK
776# undef wcscoll 995# undef wcscoll
777# if HAVE_RAW_DECL_WCSCOLL 996# if HAVE_RAW_DECL_WCSCOLL
@@ -786,10 +1005,14 @@ _GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
786 original strings. */ 1005 original strings. */
787#if @GNULIB_WCSXFRM@ 1006#if @GNULIB_WCSXFRM@
788# if !@HAVE_WCSXFRM@ 1007# if !@HAVE_WCSXFRM@
789_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); 1008_GL_FUNCDECL_SYS (wcsxfrm, size_t,
1009 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
790# endif 1010# endif
791_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n)); 1011_GL_CXXALIAS_SYS (wcsxfrm, size_t,
1012 (wchar_t *restrict s1, const wchar_t *restrict s2, size_t n));
1013# if __GLIBC__ >= 2
792_GL_CXXALIASWARN (wcsxfrm); 1014_GL_CXXALIASWARN (wcsxfrm);
1015# endif
793#elif defined GNULIB_POSIXCHECK 1016#elif defined GNULIB_POSIXCHECK
794# undef wcsxfrm 1017# undef wcsxfrm
795# if HAVE_RAW_DECL_WCSXFRM 1018# if HAVE_RAW_DECL_WCSXFRM
@@ -801,16 +1024,58 @@ _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
801 1024
802/* Duplicate S, returning an identical malloc'd string. */ 1025/* Duplicate S, returning an identical malloc'd string. */
803#if @GNULIB_WCSDUP@ 1026#if @GNULIB_WCSDUP@
804# if !@HAVE_WCSDUP@ 1027# if defined _WIN32 && !defined __CYGWIN__
805_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1028# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
806# endif 1029# undef wcsdup
1030# define wcsdup _wcsdup
1031# endif
1032_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1033# else
1034/* On Solaris 11.3, the header files declare the function in the std::
1035 namespace, not in the global namespace. So, force a declaration in
1036 the global namespace. */
1037# if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11
1038_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1039 (const wchar_t *s)
1040 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1041# endif
807_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s)); 1042_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1043# endif
808_GL_CXXALIASWARN (wcsdup); 1044_GL_CXXALIASWARN (wcsdup);
809#elif defined GNULIB_POSIXCHECK 1045#else
810# undef wcsdup 1046# if __GNUC__ >= 11 && !defined wcsdup
811# if HAVE_RAW_DECL_WCSDUP 1047/* For -Wmismatched-dealloc: Associate wcsdup with free or rpl_free. */
1048_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1049 (const wchar_t *s)
1050 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1051# endif
1052# if defined GNULIB_POSIXCHECK
1053# undef wcsdup
1054# if HAVE_RAW_DECL_WCSDUP
812_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - " 1055_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
813 "use gnulib module wcsdup for portability"); 1056 "use gnulib module wcsdup for portability");
1057# endif
1058# elif @GNULIB_MDA_WCSDUP@
1059/* On native Windows, map 'wcsdup' to '_wcsdup', so that -loldnames is not
1060 required. In C++ with GNULIB_NAMESPACE, avoid differences between
1061 platforms by defining GNULIB_NAMESPACE::wcsdup always. */
1062# if defined _WIN32 && !defined __CYGWIN__
1063# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1064# undef wcsdup
1065# define wcsdup _wcsdup
1066# endif
1067_GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
1068# else
1069_GL_FUNCDECL_SYS (wcsdup, wchar_t *,
1070 (const wchar_t *s)
1071 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
1072# if @HAVE_DECL_WCSDUP@
1073_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
1074# endif
1075# endif
1076# if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_WCSDUP@
1077_GL_CXXALIASWARN (wcsdup);
1078# endif
814# endif 1079# endif
815#endif 1080#endif
816 1081
@@ -833,7 +1098,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcschr,
833 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1098 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
834_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1099_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
835_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1100_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
836# else 1101# elif __GLIBC__ >= 2
837_GL_CXXALIASWARN (wcschr); 1102_GL_CXXALIASWARN (wcschr);
838# endif 1103# endif
839#elif defined GNULIB_POSIXCHECK 1104#elif defined GNULIB_POSIXCHECK
@@ -863,7 +1128,7 @@ _GL_CXXALIAS_SYS_CAST2 (wcsrchr,
863 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1128 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
864_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc)); 1129_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
865_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc)); 1130_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
866# else 1131# elif __GLIBC__ >= 2
867_GL_CXXALIASWARN (wcsrchr); 1132_GL_CXXALIASWARN (wcsrchr);
868# endif 1133# endif
869#elif defined GNULIB_POSIXCHECK 1134#elif defined GNULIB_POSIXCHECK
@@ -883,7 +1148,9 @@ _GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
883 _GL_ATTRIBUTE_PURE); 1148 _GL_ATTRIBUTE_PURE);
884# endif 1149# endif
885_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)); 1150_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
1151# if __GLIBC__ >= 2
886_GL_CXXALIASWARN (wcscspn); 1152_GL_CXXALIASWARN (wcscspn);
1153# endif
887#elif defined GNULIB_POSIXCHECK 1154#elif defined GNULIB_POSIXCHECK
888# undef wcscspn 1155# undef wcscspn
889# if HAVE_RAW_DECL_WCSCSPN 1156# if HAVE_RAW_DECL_WCSCSPN
@@ -901,7 +1168,9 @@ _GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
901 _GL_ATTRIBUTE_PURE); 1168 _GL_ATTRIBUTE_PURE);
902# endif 1169# endif
903_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)); 1170_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
1171# if __GLIBC__ >= 2
904_GL_CXXALIASWARN (wcsspn); 1172_GL_CXXALIASWARN (wcsspn);
1173# endif
905#elif defined GNULIB_POSIXCHECK 1174#elif defined GNULIB_POSIXCHECK
906# undef wcsspn 1175# undef wcsspn
907# if HAVE_RAW_DECL_WCSSPN 1176# if HAVE_RAW_DECL_WCSSPN
@@ -932,7 +1201,7 @@ _GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
932 (wchar_t *wcs, const wchar_t *accept)); 1201 (wchar_t *wcs, const wchar_t *accept));
933_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *, 1202_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
934 (const wchar_t *wcs, const wchar_t *accept)); 1203 (const wchar_t *wcs, const wchar_t *accept));
935# else 1204# elif __GLIBC__ >= 2
936_GL_CXXALIASWARN (wcspbrk); 1205_GL_CXXALIASWARN (wcspbrk);
937# endif 1206# endif
938#elif defined GNULIB_POSIXCHECK 1207#elif defined GNULIB_POSIXCHECK
@@ -948,7 +1217,8 @@ _GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
948#if @GNULIB_WCSSTR@ 1217#if @GNULIB_WCSSTR@
949# if !@HAVE_WCSSTR@ 1218# if !@HAVE_WCSSTR@
950_GL_FUNCDECL_SYS (wcsstr, wchar_t *, 1219_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
951 (const wchar_t *haystack, const wchar_t *needle) 1220 (const wchar_t *restrict haystack,
1221 const wchar_t *restrict needle)
952 _GL_ATTRIBUTE_PURE); 1222 _GL_ATTRIBUTE_PURE);
953# endif 1223# endif
954 /* On some systems, this function is defined as an overloaded function: 1224 /* On some systems, this function is defined as an overloaded function:
@@ -957,15 +1227,19 @@ _GL_FUNCDECL_SYS (wcsstr, wchar_t *,
957 wchar_t * std::wcsstr (wchar_t *, const wchar_t *); 1227 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
958 } */ 1228 } */
959_GL_CXXALIAS_SYS_CAST2 (wcsstr, 1229_GL_CXXALIAS_SYS_CAST2 (wcsstr,
960 wchar_t *, (const wchar_t *, const wchar_t *), 1230 wchar_t *,
961 const wchar_t *, (const wchar_t *, const wchar_t *)); 1231 (const wchar_t *restrict, const wchar_t *restrict),
1232 const wchar_t *,
1233 (const wchar_t *restrict, const wchar_t *restrict));
962# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ 1234# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
963 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 1235 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
964_GL_CXXALIASWARN1 (wcsstr, wchar_t *, 1236_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
965 (wchar_t *haystack, const wchar_t *needle)); 1237 (wchar_t *restrict haystack,
1238 const wchar_t *restrict needle));
966_GL_CXXALIASWARN1 (wcsstr, const wchar_t *, 1239_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
967 (const wchar_t *haystack, const wchar_t *needle)); 1240 (const wchar_t *restrict haystack,
968# else 1241 const wchar_t *restrict needle));
1242# elif __GLIBC__ >= 2
969_GL_CXXALIASWARN (wcsstr); 1243_GL_CXXALIASWARN (wcsstr);
970# endif 1244# endif
971#elif defined GNULIB_POSIXCHECK 1245#elif defined GNULIB_POSIXCHECK
@@ -979,13 +1253,30 @@ _GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
979 1253
980/* Divide WCS into tokens separated by characters in DELIM. */ 1254/* Divide WCS into tokens separated by characters in DELIM. */
981#if @GNULIB_WCSTOK@ 1255#if @GNULIB_WCSTOK@
982# if !@HAVE_WCSTOK@ 1256# if @REPLACE_WCSTOK@
1257# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1258# undef wcstok
1259# define wcstok rpl_wcstok
1260# endif
1261_GL_FUNCDECL_RPL (wcstok, wchar_t *,
1262 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1263 wchar_t **restrict ptr));
1264_GL_CXXALIAS_RPL (wcstok, wchar_t *,
1265 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1266 wchar_t **restrict ptr));
1267# else
1268# if !@HAVE_WCSTOK@
983_GL_FUNCDECL_SYS (wcstok, wchar_t *, 1269_GL_FUNCDECL_SYS (wcstok, wchar_t *,
984 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); 1270 (wchar_t *restrict wcs, const wchar_t *restrict delim,
985# endif 1271 wchar_t **restrict ptr));
1272# endif
986_GL_CXXALIAS_SYS (wcstok, wchar_t *, 1273_GL_CXXALIAS_SYS (wcstok, wchar_t *,
987 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)); 1274 (wchar_t *restrict wcs, const wchar_t *restrict delim,
1275 wchar_t **restrict ptr));
1276# endif
1277# if __GLIBC__ >= 2
988_GL_CXXALIASWARN (wcstok); 1278_GL_CXXALIASWARN (wcstok);
1279# endif
989#elif defined GNULIB_POSIXCHECK 1280#elif defined GNULIB_POSIXCHECK
990# undef wcstok 1281# undef wcstok
991# if HAVE_RAW_DECL_WCSTOK 1282# if HAVE_RAW_DECL_WCSTOK
@@ -1013,7 +1304,9 @@ _GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1013# endif 1304# endif
1014_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n)); 1305_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1015# endif 1306# endif
1307# if __GLIBC__ >= 2
1016_GL_CXXALIASWARN (wcswidth); 1308_GL_CXXALIASWARN (wcswidth);
1309# endif
1017#elif defined GNULIB_POSIXCHECK 1310#elif defined GNULIB_POSIXCHECK
1018# undef wcswidth 1311# undef wcswidth
1019# if HAVE_RAW_DECL_WCSWIDTH 1312# if HAVE_RAW_DECL_WCSWIDTH
@@ -1023,6 +1316,48 @@ _GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1023#endif 1316#endif
1024 1317
1025 1318
1319/* Convert *TP to a date and time wide string. See
1320 <https://pubs.opengroup.org/onlinepubs/9699919799/functions/wcsftime.html>. */
1321#if @GNULIB_WCSFTIME@
1322# if @REPLACE_WCSFTIME@
1323# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1324# undef wcsftime
1325# define wcsftime rpl_wcsftime
1326# endif
1327_GL_FUNCDECL_RPL (wcsftime, size_t,
1328 (wchar_t *restrict __buf, size_t __bufsize,
1329 const wchar_t *restrict __fmt,
1330 const struct tm *restrict __tp)
1331 _GL_ARG_NONNULL ((1, 3, 4)));
1332_GL_CXXALIAS_RPL (wcsftime, size_t,
1333 (wchar_t *restrict __buf, size_t __bufsize,
1334 const wchar_t *restrict __fmt,
1335 const struct tm *restrict __tp));
1336# else
1337# if !@HAVE_WCSFTIME@
1338_GL_FUNCDECL_SYS (wcsftime, size_t,
1339 (wchar_t *restrict __buf, size_t __bufsize,
1340 const wchar_t *restrict __fmt,
1341 const struct tm *restrict __tp)
1342 _GL_ARG_NONNULL ((1, 3, 4)));
1343# endif
1344_GL_CXXALIAS_SYS (wcsftime, size_t,
1345 (wchar_t *restrict __buf, size_t __bufsize,
1346 const wchar_t *restrict __fmt,
1347 const struct tm *restrict __tp));
1348# endif
1349# if __GLIBC__ >= 2
1350_GL_CXXALIASWARN (wcsftime);
1351# endif
1352#elif defined GNULIB_POSIXCHECK
1353# undef wcsftime
1354# if HAVE_RAW_DECL_WCSFTIME
1355_GL_WARN_ON_USE (wcsftime, "wcsftime is unportable - "
1356 "use gnulib module wcsftime for portability");
1357# endif
1358#endif
1359
1360
1026#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1361#endif /* _@GUARD_PREFIX@_WCHAR_H */
1027#endif /* _@GUARD_PREFIX@_WCHAR_H */ 1362#endif /* _@GUARD_PREFIX@_WCHAR_H */
1028#endif 1363#endif
diff --git a/gl/wcrtomb.c b/gl/wcrtomb.c
index da42809..48a6c8e 100644
--- a/gl/wcrtomb.c
+++ b/gl/wcrtomb.c
@@ -1,19 +1,19 @@
1/* Convert wide character to multibyte character. 1/* Convert wide character to multibyte character.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc. 2 Copyright (C) 2008-2023 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -26,20 +26,46 @@
26 26
27size_t 27size_t
28wcrtomb (char *s, wchar_t wc, mbstate_t *ps) 28wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
29#undef wcrtomb
29{ 30{
30 /* This implementation of wcrtomb on top of wctomb() supports only 31 /* This implementation of wcrtomb supports only stateless encodings.
31 stateless encodings. ps must be in the initial state. */ 32 ps must be in the initial state. */
32 if (ps != NULL && !mbsinit (ps)) 33 if (ps != NULL && !mbsinit (ps))
33 { 34 {
34 errno = EINVAL; 35 errno = EINVAL;
35 return (size_t)(-1); 36 return (size_t)(-1);
36 } 37 }
37 38
39#if !HAVE_WCRTOMB /* IRIX 6.5 */ \
40 || WCRTOMB_RETVAL_BUG /* Solaris 11.3, MSVC */ \
41 || WCRTOMB_C_LOCALE_BUG /* Android */
38 if (s == NULL) 42 if (s == NULL)
39 /* We know the NUL wide character corresponds to the NUL character. */ 43 /* We know the NUL wide character corresponds to the NUL character. */
40 return 1; 44 return 1;
41 else 45 else
46#endif
42 { 47 {
48#if HAVE_WCRTOMB
49# if WCRTOMB_C_LOCALE_BUG /* Android */
50 /* Implement consistently with mbrtowc(): through a 1:1 correspondence,
51 as in ISO-8859-1. */
52 if (wc >= 0 && wc <= 0xff)
53 {
54 *s = (unsigned char) wc;
55 return 1;
56 }
57 else
58 {
59 errno = EILSEQ;
60 return (size_t)(-1);
61 }
62# else
63 return wcrtomb (s, wc, ps);
64# endif
65#else /* IRIX 6.5 */
66 /* Fallback for platforms that don't have wcrtomb().
67 Implement on top of wctomb().
68 This code is not multithread-safe. */
43 int ret = wctomb (s, wc); 69 int ret = wctomb (s, wc);
44 70
45 if (ret >= 0) 71 if (ret >= 0)
@@ -49,5 +75,6 @@ wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
49 errno = EILSEQ; 75 errno = EILSEQ;
50 return (size_t)(-1); 76 return (size_t)(-1);
51 } 77 }
78#endif
52 } 79 }
53} 80}
diff --git a/gl/wctype-h.c b/gl/wctype-h.c
index bb5f847..7d3e14a 100644
--- a/gl/wctype-h.c
+++ b/gl/wctype-h.c
@@ -1,4 +1,23 @@
1/* Inline functions for <wctype.h>.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1/* Normally this would be wctype.c, but that name's already taken. */ 18/* Normally this would be wctype.c, but that name's already taken. */
19
2#include <config.h> 20#include <config.h>
21
3#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE 22#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE
4#include "wctype.h" 23#include "wctype.h"
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index a7c07d1..f6e474d 100644
--- a/gl/wctype.in.h
+++ b/gl/wctype.in.h
@@ -1,54 +1,61 @@
1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it. 1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
2 2
3 Copyright (C) 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18/* Written by Bruno Haible and Paul Eggert. */ 18/* Written by Bruno Haible and Paul Eggert. */
19 19
20/* 20/*
21 * ISO C 99 <wctype.h> for platforms that lack it. 21 * ISO C 99 <wctype.h> for platforms that lack it.
22 * <http://www.opengroup.org/susv3xbd/wctype.h.html> 22 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html>
23 * 23 *
24 * iswctype, towctrans, towlower, towupper, wctrans, wctype, 24 * iswctype, towctrans, towlower, towupper, wctrans, wctype,
25 * wctrans_t, and wctype_t are not yet implemented. 25 * wctrans_t, and wctype_t are not yet implemented.
26 */ 26 */
27 27
28#ifndef _@GUARD_PREFIX@_WCTYPE_H
29
30#if __GNUC__ >= 3 28#if __GNUC__ >= 3
31@PRAGMA_SYSTEM_HEADER@ 29@PRAGMA_SYSTEM_HEADER@
32#endif 30#endif
33@PRAGMA_COLUMNS@ 31@PRAGMA_COLUMNS@
34 32
33#if (defined __MINGW32__ && defined __CTYPE_H_SOURCED__)
34
35/* Special invocation convention:
36 - With MinGW 3.22, when <ctype.h> includes <wctype.h>, only some part of
37 <wctype.h> is being processed, which doesn't include the idempotency
38 guard. */
39
40#@INCLUDE_NEXT@ @NEXT_WCTYPE_H@
41
42#else
43/* Normal invocation convention. */
44
45#ifndef _@GUARD_PREFIX@_WCTYPE_H
46
35#if @HAVE_WINT_T@ 47#if @HAVE_WINT_T@
36/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. 48/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
37 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
38 <wchar.h>.
39 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
40 included before <wchar.h>. */
41# include <stddef.h>
42# include <stdio.h>
43# include <time.h>
44# include <wchar.h> 49# include <wchar.h>
45#endif 50#endif
46 51
47/* mingw has declarations of towupper and towlower in <ctype.h> as 52/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
48 well <wctype.h>. Include <ctype.h> in advance to avoid rpl_ prefix 53 isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>. Include
49 being added to the declarations. */ 54 <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
50#ifdef __MINGW32__ 55 declarations. */
56#if defined _WIN32 && ! defined __CYGWIN__
51# include <ctype.h> 57# include <ctype.h>
58# include <wchar.h>
52#endif 59#endif
53 60
54/* Include the original <wctype.h> if it exists. 61/* Include the original <wctype.h> if it exists.
@@ -61,6 +68,9 @@
61#ifndef _@GUARD_PREFIX@_WCTYPE_H 68#ifndef _@GUARD_PREFIX@_WCTYPE_H
62#define _@GUARD_PREFIX@_WCTYPE_H 69#define _@GUARD_PREFIX@_WCTYPE_H
63 70
71#ifndef _GL_INLINE_HEADER_BEGIN
72 #error "Please include config.h first."
73#endif
64_GL_INLINE_HEADER_BEGIN 74_GL_INLINE_HEADER_BEGIN
65#ifndef _GL_WCTYPE_INLINE 75#ifndef _GL_WCTYPE_INLINE
66# define _GL_WCTYPE_INLINE _GL_INLINE 76# define _GL_WCTYPE_INLINE _GL_INLINE
@@ -90,12 +100,16 @@ _GL_INLINE_HEADER_BEGIN
90# define WEOF -1 100# define WEOF -1
91# endif 101# endif
92#else 102#else
93/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>. 103/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h> or
94 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be 104 <stddef.h>. This is too small: ISO C 99 section 7.24.1.(2) says that
95 "unchanged by default argument promotions". Override it. */ 105 wint_t must be "unchanged by default argument promotions". Override it. */
96# if defined _MSC_VER 106# if @GNULIBHEADERS_OVERRIDE_WINT_T@
97# if !GNULIB_defined_wint_t 107# if !GNULIB_defined_wint_t
98# include <crtdefs.h> 108# if @HAVE_CRTDEFS_H@
109# include <crtdefs.h>
110# else
111# include <stddef.h>
112# endif
99typedef unsigned int rpl_wint_t; 113typedef unsigned int rpl_wint_t;
100# undef wint_t 114# undef wint_t
101# define wint_t rpl_wint_t 115# define wint_t rpl_wint_t
@@ -112,33 +126,116 @@ typedef unsigned int rpl_wint_t;
112 126
113/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. 127/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
114 Linux libc5 has <wctype.h> and the functions but they are broken. 128 Linux libc5 has <wctype.h> and the functions but they are broken.
129 mingw and MSVC have <wctype.h> and the functions but they take a wchar_t
130 as argument, not an rpl_wint_t.
115 Assume all 11 functions (all isw* except iswblank) are implemented the 131 Assume all 11 functions (all isw* except iswblank) are implemented the
116 same way, or not at all. */ 132 same way, or not at all. */
117# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ 133# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
118 134
119/* IRIX 5.3 has macros but no functions, its isw* macros refer to an 135# if @GNULIBHEADERS_OVERRIDE_WINT_T@ /* implies @REPLACE_ISWCNTRL@ */
120 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they 136
121 refer to system functions like _iswctype that are not in the 137_GL_WCTYPE_INLINE int
122 standard C library. Rather than try to get ancient buggy 138rpl_iswalnum (wint_t wc)
123 implementations like this to work, just disable them. */ 139{
124# undef iswalnum 140 return ((wchar_t) wc == wc ? iswalnum ((wchar_t) wc) : 0);
125# undef iswalpha 141}
126# undef iswblank 142
127# undef iswcntrl 143_GL_WCTYPE_INLINE int
128# undef iswdigit 144rpl_iswalpha (wint_t wc)
129# undef iswgraph 145{
130# undef iswlower 146 return ((wchar_t) wc == wc ? iswalpha ((wchar_t) wc) : 0);
131# undef iswprint 147}
132# undef iswpunct 148
133# undef iswspace 149_GL_WCTYPE_INLINE int
134# undef iswupper 150rpl_iswblank (wint_t wc)
135# undef iswxdigit 151{
136# undef towlower 152 return ((wchar_t) wc == wc ? iswblank ((wchar_t) wc) : 0);
137# undef towupper 153}
154
155_GL_WCTYPE_INLINE int
156rpl_iswcntrl (wint_t wc)
157{
158 return ((wchar_t) wc == wc ? iswcntrl ((wchar_t) wc) : 0);
159}
160
161_GL_WCTYPE_INLINE int
162rpl_iswdigit (wint_t wc)
163{
164 return ((wchar_t) wc == wc ? wc >= '0' && wc <= '9' : 0);
165}
166
167_GL_WCTYPE_INLINE int
168rpl_iswgraph (wint_t wc)
169{
170 return ((wchar_t) wc == wc ? iswgraph ((wchar_t) wc) : 0);
171}
172
173_GL_WCTYPE_INLINE int
174rpl_iswlower (wint_t wc)
175{
176 return ((wchar_t) wc == wc ? iswlower ((wchar_t) wc) : 0);
177}
178
179_GL_WCTYPE_INLINE int
180rpl_iswprint (wint_t wc)
181{
182 return ((wchar_t) wc == wc ? iswprint ((wchar_t) wc) : 0);
183}
184
185_GL_WCTYPE_INLINE int
186rpl_iswpunct (wint_t wc)
187{
188 return ((wchar_t) wc == wc ? iswpunct ((wchar_t) wc) : 0);
189}
190
191_GL_WCTYPE_INLINE int
192rpl_iswspace (wint_t wc)
193{
194 return ((wchar_t) wc == wc ? iswspace ((wchar_t) wc) : 0);
195}
196
197_GL_WCTYPE_INLINE int
198rpl_iswupper (wint_t wc)
199{
200 return ((wchar_t) wc == wc ? iswupper ((wchar_t) wc) : 0);
201}
202
203_GL_WCTYPE_INLINE int
204rpl_iswxdigit (wint_t wc)
205{
206 return ((wchar_t) wc == wc
207 ? (wc >= '0' && wc <= '9')
208 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')
209 : 0);
210}
211
212_GL_WCTYPE_INLINE wint_t
213rpl_towlower (wint_t wc)
214{
215 return ((wchar_t) wc == wc ? (wchar_t) towlower ((wchar_t) wc) : wc);
216}
217
218_GL_WCTYPE_INLINE wint_t
219rpl_towupper (wint_t wc)
220{
221 return ((wchar_t) wc == wc ? (wchar_t) towupper ((wchar_t) wc) : wc);
222}
138 223
139/* Linux libc5 has <wctype.h> and the functions but they are broken. */
140# if @REPLACE_ISWCNTRL@
141# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 224# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
225# undef iswalnum
226# undef iswalpha
227# undef iswblank
228# undef iswcntrl
229# undef iswdigit
230# undef iswgraph
231# undef iswlower
232# undef iswprint
233# undef iswpunct
234# undef iswspace
235# undef iswupper
236# undef iswxdigit
237# undef towlower
238# undef towupper
142# define iswalnum rpl_iswalnum 239# define iswalnum rpl_iswalnum
143# define iswalpha rpl_iswalpha 240# define iswalpha rpl_iswalpha
144# define iswblank rpl_iswblank 241# define iswblank rpl_iswblank
@@ -151,21 +248,62 @@ typedef unsigned int rpl_wint_t;
151# define iswspace rpl_iswspace 248# define iswspace rpl_iswspace
152# define iswupper rpl_iswupper 249# define iswupper rpl_iswupper
153# define iswxdigit rpl_iswxdigit 250# define iswxdigit rpl_iswxdigit
154# endif
155# endif
156# if @REPLACE_TOWLOWER@
157# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158# define towlower rpl_towlower 251# define towlower rpl_towlower
159# define towupper rpl_towupper 252# define towupper rpl_towupper
160# endif 253# endif
161# endif 254
255# else
256
257/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
258 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
259 refer to system functions like _iswctype that are not in the
260 standard C library. Rather than try to get ancient buggy
261 implementations like this to work, just disable them. */
262# undef iswalnum
263# undef iswalpha
264# undef iswblank
265# undef iswcntrl
266# undef iswdigit
267# undef iswgraph
268# undef iswlower
269# undef iswprint
270# undef iswpunct
271# undef iswspace
272# undef iswupper
273# undef iswxdigit
274# undef towlower
275# undef towupper
276
277/* Linux libc5 has <wctype.h> and the functions but they are broken. */
278# if @REPLACE_ISWCNTRL@
279# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
280# define iswalnum rpl_iswalnum
281# define iswalpha rpl_iswalpha
282# define iswblank rpl_iswblank
283# define iswcntrl rpl_iswcntrl
284# define iswdigit rpl_iswdigit
285# define iswgraph rpl_iswgraph
286# define iswlower rpl_iswlower
287# define iswprint rpl_iswprint
288# define iswpunct rpl_iswpunct
289# define iswspace rpl_iswspace
290# define iswupper rpl_iswupper
291# define iswxdigit rpl_iswxdigit
292# endif
293# endif
294# if @REPLACE_TOWLOWER@
295# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296# define towlower rpl_towlower
297# define towupper rpl_towupper
298# endif
299# endif
162 300
163_GL_WCTYPE_INLINE int 301_GL_WCTYPE_INLINE int
164# if @REPLACE_ISWCNTRL@ 302# if @REPLACE_ISWCNTRL@
165rpl_iswalnum 303rpl_iswalnum
166# else 304# else
167iswalnum 305iswalnum
168# endif 306# endif
169 (wint_t wc) 307 (wint_t wc)
170{ 308{
171 return ((wc >= '0' && wc <= '9') 309 return ((wc >= '0' && wc <= '9')
@@ -173,88 +311,88 @@ iswalnum
173} 311}
174 312
175_GL_WCTYPE_INLINE int 313_GL_WCTYPE_INLINE int
176# if @REPLACE_ISWCNTRL@ 314# if @REPLACE_ISWCNTRL@
177rpl_iswalpha 315rpl_iswalpha
178# else 316# else
179iswalpha 317iswalpha
180# endif 318# endif
181 (wint_t wc) 319 (wint_t wc)
182{ 320{
183 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; 321 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
184} 322}
185 323
186_GL_WCTYPE_INLINE int 324_GL_WCTYPE_INLINE int
187# if @REPLACE_ISWCNTRL@ 325# if @REPLACE_ISWCNTRL@
188rpl_iswblank 326rpl_iswblank
189# else 327# else
190iswblank 328iswblank
191# endif 329# endif
192 (wint_t wc) 330 (wint_t wc)
193{ 331{
194 return wc == ' ' || wc == '\t'; 332 return wc == ' ' || wc == '\t';
195} 333}
196 334
197_GL_WCTYPE_INLINE int 335_GL_WCTYPE_INLINE int
198# if @REPLACE_ISWCNTRL@ 336# if @REPLACE_ISWCNTRL@
199rpl_iswcntrl 337rpl_iswcntrl
200# else 338# else
201iswcntrl 339iswcntrl
202# endif 340# endif
203 (wint_t wc) 341 (wint_t wc)
204{ 342{
205 return (wc & ~0x1f) == 0 || wc == 0x7f; 343 return (wc & ~0x1f) == 0 || wc == 0x7f;
206} 344}
207 345
208_GL_WCTYPE_INLINE int 346_GL_WCTYPE_INLINE int
209# if @REPLACE_ISWCNTRL@ 347# if @REPLACE_ISWDIGIT@
210rpl_iswdigit 348rpl_iswdigit
211# else 349# else
212iswdigit 350iswdigit
213# endif 351# endif
214 (wint_t wc) 352 (wint_t wc)
215{ 353{
216 return wc >= '0' && wc <= '9'; 354 return wc >= '0' && wc <= '9';
217} 355}
218 356
219_GL_WCTYPE_INLINE int 357_GL_WCTYPE_INLINE int
220# if @REPLACE_ISWCNTRL@ 358# if @REPLACE_ISWCNTRL@
221rpl_iswgraph 359rpl_iswgraph
222# else 360# else
223iswgraph 361iswgraph
224# endif 362# endif
225 (wint_t wc) 363 (wint_t wc)
226{ 364{
227 return wc >= '!' && wc <= '~'; 365 return wc >= '!' && wc <= '~';
228} 366}
229 367
230_GL_WCTYPE_INLINE int 368_GL_WCTYPE_INLINE int
231# if @REPLACE_ISWCNTRL@ 369# if @REPLACE_ISWCNTRL@
232rpl_iswlower 370rpl_iswlower
233# else 371# else
234iswlower 372iswlower
235# endif 373# endif
236 (wint_t wc) 374 (wint_t wc)
237{ 375{
238 return wc >= 'a' && wc <= 'z'; 376 return wc >= 'a' && wc <= 'z';
239} 377}
240 378
241_GL_WCTYPE_INLINE int 379_GL_WCTYPE_INLINE int
242# if @REPLACE_ISWCNTRL@ 380# if @REPLACE_ISWCNTRL@
243rpl_iswprint 381rpl_iswprint
244# else 382# else
245iswprint 383iswprint
246# endif 384# endif
247 (wint_t wc) 385 (wint_t wc)
248{ 386{
249 return wc >= ' ' && wc <= '~'; 387 return wc >= ' ' && wc <= '~';
250} 388}
251 389
252_GL_WCTYPE_INLINE int 390_GL_WCTYPE_INLINE int
253# if @REPLACE_ISWCNTRL@ 391# if @REPLACE_ISWCNTRL@
254rpl_iswpunct 392rpl_iswpunct
255# else 393# else
256iswpunct 394iswpunct
257# endif 395# endif
258 (wint_t wc) 396 (wint_t wc)
259{ 397{
260 return (wc >= '!' && wc <= '~' 398 return (wc >= '!' && wc <= '~'
@@ -263,11 +401,11 @@ iswpunct
263} 401}
264 402
265_GL_WCTYPE_INLINE int 403_GL_WCTYPE_INLINE int
266# if @REPLACE_ISWCNTRL@ 404# if @REPLACE_ISWCNTRL@
267rpl_iswspace 405rpl_iswspace
268# else 406# else
269iswspace 407iswspace
270# endif 408# endif
271 (wint_t wc) 409 (wint_t wc)
272{ 410{
273 return (wc == ' ' || wc == '\t' 411 return (wc == ' ' || wc == '\t'
@@ -275,22 +413,22 @@ iswspace
275} 413}
276 414
277_GL_WCTYPE_INLINE int 415_GL_WCTYPE_INLINE int
278# if @REPLACE_ISWCNTRL@ 416# if @REPLACE_ISWCNTRL@
279rpl_iswupper 417rpl_iswupper
280# else 418# else
281iswupper 419iswupper
282# endif 420# endif
283 (wint_t wc) 421 (wint_t wc)
284{ 422{
285 return wc >= 'A' && wc <= 'Z'; 423 return wc >= 'A' && wc <= 'Z';
286} 424}
287 425
288_GL_WCTYPE_INLINE int 426_GL_WCTYPE_INLINE int
289# if @REPLACE_ISWCNTRL@ 427# if @REPLACE_ISWXDIGIT@
290rpl_iswxdigit 428rpl_iswxdigit
291# else 429# else
292iswxdigit 430iswxdigit
293# endif 431# endif
294 (wint_t wc) 432 (wint_t wc)
295{ 433{
296 return ((wc >= '0' && wc <= '9') 434 return ((wc >= '0' && wc <= '9')
@@ -298,42 +436,67 @@ iswxdigit
298} 436}
299 437
300_GL_WCTYPE_INLINE wint_t 438_GL_WCTYPE_INLINE wint_t
301# if @REPLACE_TOWLOWER@ 439# if @REPLACE_TOWLOWER@
302rpl_towlower 440rpl_towlower
303# else 441# else
304towlower 442towlower
305# endif 443# endif
306 (wint_t wc) 444 (wint_t wc)
307{ 445{
308 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); 446 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
309} 447}
310 448
311_GL_WCTYPE_INLINE wint_t 449_GL_WCTYPE_INLINE wint_t
312# if @REPLACE_TOWLOWER@ 450# if @REPLACE_TOWLOWER@
313rpl_towupper 451rpl_towupper
314# else 452# else
315towupper 453towupper
316# endif 454# endif
317 (wint_t wc) 455 (wint_t wc)
318{ 456{
319 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); 457 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
320} 458}
321 459
322# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@) 460# endif
323/* Only the iswblank function is missing. */
324 461
325# if @REPLACE_ISWBLANK@ 462# else
326# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 463/* Only some of the functions are missing or broken. */
327# define iswblank rpl_iswblank 464
328# endif 465# if @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
466/* Only the iswblank function is missing. */
467# if @REPLACE_ISWBLANK@
468# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
469# define iswblank rpl_iswblank
470# endif
329_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc)); 471_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
330# else 472# else
331_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc)); 473_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
474# endif
475# endif
476
477# if @GNULIB_ISWDIGIT@
478# if @REPLACE_ISWDIGIT@
479# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
480# undef iswdigit
481# define iswdigit rpl_iswdigit
482# endif
483_GL_FUNCDECL_RPL (iswdigit, int, (wint_t wc));
484# endif
485# endif
486
487# if @GNULIB_ISWXDIGIT@
488# if @REPLACE_ISWXDIGIT@
489# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
490# undef iswxdigit
491# define iswxdigit rpl_iswxdigit
492# endif
493_GL_FUNCDECL_RPL (iswxdigit, int, (wint_t wc));
494# endif
332# endif 495# endif
333 496
334# endif 497# endif
335 498
336# if defined __MINGW32__ 499# if defined __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@
337 500
338/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. 501/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
339 The functions towlower and towupper are implemented in the MSVCRT library 502 The functions towlower and towupper are implemented in the MSVCRT library
@@ -366,36 +529,71 @@ rpl_towupper (wint_t wc)
366# define towupper rpl_towupper 529# define towupper rpl_towupper
367# endif 530# endif
368 531
369# endif /* __MINGW32__ */ 532# endif /* __MINGW32__ && !@GNULIBHEADERS_OVERRIDE_WINT_T@ */
370 533
371# define GNULIB_defined_wctype_functions 1 534# define GNULIB_defined_wctype_functions 1
372#endif 535#endif
373 536
374#if @REPLACE_ISWCNTRL@ 537#if @REPLACE_ISWCNTRL@
375_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); 538_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
376_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
377_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
378_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
379_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
380_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
381_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
382_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
383_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
384_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
385_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
386#else 539#else
387_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); 540_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
541#endif
542#if @REPLACE_ISWCNTRL@
543_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
544#else
388_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); 545_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
546#endif
547#if @REPLACE_ISWCNTRL@
548_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
549#else
389_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); 550_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
551#endif
552#if @GNULIB_ISWDIGIT@
553# if @REPLACE_ISWDIGIT@
554_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
555# else
390_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); 556_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
557# endif
558#endif
559#if @REPLACE_ISWCNTRL@
560_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
561#else
391_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); 562_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
563#endif
564#if @REPLACE_ISWCNTRL@
565_GL_CXXALIAS_RPL (iswlower, int, (wint_t wc));
566#else
392_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc)); 567_GL_CXXALIAS_SYS (iswlower, int, (wint_t wc));
568#endif
569#if @REPLACE_ISWCNTRL@
570_GL_CXXALIAS_RPL (iswprint, int, (wint_t wc));
571#else
393_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc)); 572_GL_CXXALIAS_SYS (iswprint, int, (wint_t wc));
573#endif
574#if @REPLACE_ISWCNTRL@
575_GL_CXXALIAS_RPL (iswpunct, int, (wint_t wc));
576#else
394_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc)); 577_GL_CXXALIAS_SYS (iswpunct, int, (wint_t wc));
578#endif
579#if @REPLACE_ISWCNTRL@
580_GL_CXXALIAS_RPL (iswspace, int, (wint_t wc));
581#else
395_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc)); 582_GL_CXXALIAS_SYS (iswspace, int, (wint_t wc));
583#endif
584#if @REPLACE_ISWCNTRL@
585_GL_CXXALIAS_RPL (iswupper, int, (wint_t wc));
586#else
396_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc)); 587_GL_CXXALIAS_SYS (iswupper, int, (wint_t wc));
588#endif
589#if @GNULIB_ISWXDIGIT@
590# if @REPLACE_ISWXDIGIT@
591_GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
592# else
397_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc)); 593_GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
594# endif
398#endif 595#endif
596#if __GLIBC__ >= 2
399_GL_CXXALIASWARN (iswalnum); 597_GL_CXXALIASWARN (iswalnum);
400_GL_CXXALIASWARN (iswalpha); 598_GL_CXXALIASWARN (iswalpha);
401_GL_CXXALIASWARN (iswcntrl); 599_GL_CXXALIASWARN (iswcntrl);
@@ -407,6 +605,7 @@ _GL_CXXALIASWARN (iswpunct);
407_GL_CXXALIASWARN (iswspace); 605_GL_CXXALIASWARN (iswspace);
408_GL_CXXALIASWARN (iswupper); 606_GL_CXXALIASWARN (iswupper);
409_GL_CXXALIASWARN (iswxdigit); 607_GL_CXXALIASWARN (iswxdigit);
608#endif
410 609
411#if @GNULIB_ISWBLANK@ 610#if @GNULIB_ISWBLANK@
412# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@ 611# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
@@ -414,7 +613,9 @@ _GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
414# else 613# else
415_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc)); 614_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
416# endif 615# endif
616# if __GLIBC__ >= 2
417_GL_CXXALIASWARN (iswblank); 617_GL_CXXALIASWARN (iswblank);
618# endif
418#endif 619#endif
419 620
420#if !@HAVE_WCTYPE_T@ 621#if !@HAVE_WCTYPE_T@
@@ -430,7 +631,9 @@ typedef void * wctype_t;
430_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); 631_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
431# endif 632# endif
432_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); 633_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
634# if __GLIBC__ >= 2
433_GL_CXXALIASWARN (wctype); 635_GL_CXXALIASWARN (wctype);
636# endif
434#elif defined GNULIB_POSIXCHECK 637#elif defined GNULIB_POSIXCHECK
435# undef wctype 638# undef wctype
436# if HAVE_RAW_DECL_WCTYPE 639# if HAVE_RAW_DECL_WCTYPE
@@ -443,11 +646,22 @@ _GL_WARN_ON_USE (wctype, "wctype is unportable - "
443 The argument WC must be either a wchar_t value or WEOF. 646 The argument WC must be either a wchar_t value or WEOF.
444 The argument DESC must have been returned by the wctype() function. */ 647 The argument DESC must have been returned by the wctype() function. */
445#if @GNULIB_ISWCTYPE@ 648#if @GNULIB_ISWCTYPE@
446# if !@HAVE_WCTYPE_T@ 649# if @GNULIBHEADERS_OVERRIDE_WINT_T@
650# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
651# undef iswctype
652# define iswctype rpl_iswctype
653# endif
654_GL_FUNCDECL_RPL (iswctype, int, (wint_t wc, wctype_t desc));
655_GL_CXXALIAS_RPL (iswctype, int, (wint_t wc, wctype_t desc));
656# else
657# if !@HAVE_WCTYPE_T@
447_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); 658_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
448# endif 659# endif
449_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); 660_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
661# endif
662# if __GLIBC__ >= 2
450_GL_CXXALIASWARN (iswctype); 663_GL_CXXALIASWARN (iswctype);
664# endif
451#elif defined GNULIB_POSIXCHECK 665#elif defined GNULIB_POSIXCHECK
452# undef iswctype 666# undef iswctype
453# if HAVE_RAW_DECL_ISWCTYPE 667# if HAVE_RAW_DECL_ISWCTYPE
@@ -463,8 +677,10 @@ _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
463_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc)); 677_GL_CXXALIAS_SYS (towlower, wint_t, (wint_t wc));
464_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc)); 678_GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
465#endif 679#endif
680#if __GLIBC__ >= 2
466_GL_CXXALIASWARN (towlower); 681_GL_CXXALIASWARN (towlower);
467_GL_CXXALIASWARN (towupper); 682_GL_CXXALIASWARN (towupper);
683#endif
468 684
469#if !@HAVE_WCTRANS_T@ 685#if !@HAVE_WCTRANS_T@
470# if !GNULIB_defined_wctrans_t 686# if !GNULIB_defined_wctrans_t
@@ -479,7 +695,9 @@ typedef void * wctrans_t;
479_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name)); 695_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
480# endif 696# endif
481_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name)); 697_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
698# if __GLIBC__ >= 2
482_GL_CXXALIASWARN (wctrans); 699_GL_CXXALIASWARN (wctrans);
700# endif
483#elif defined GNULIB_POSIXCHECK 701#elif defined GNULIB_POSIXCHECK
484# undef wctrans 702# undef wctrans
485# if HAVE_RAW_DECL_WCTRANS 703# if HAVE_RAW_DECL_WCTRANS
@@ -496,7 +714,9 @@ _GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
496_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); 714_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
497# endif 715# endif
498_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); 716_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
717# if __GLIBC__ >= 2
499_GL_CXXALIASWARN (towctrans); 718_GL_CXXALIASWARN (towctrans);
719# endif
500#elif defined GNULIB_POSIXCHECK 720#elif defined GNULIB_POSIXCHECK
501# undef towctrans 721# undef towctrans
502# if HAVE_RAW_DECL_TOWCTRANS 722# if HAVE_RAW_DECL_TOWCTRANS
@@ -509,3 +729,4 @@ _GL_INLINE_HEADER_END
509 729
510#endif /* _@GUARD_PREFIX@_WCTYPE_H */ 730#endif /* _@GUARD_PREFIX@_WCTYPE_H */
511#endif /* _@GUARD_PREFIX@_WCTYPE_H */ 731#endif /* _@GUARD_PREFIX@_WCTYPE_H */
732#endif
diff --git a/gl/windows-initguard.h b/gl/windows-initguard.h
new file mode 100644
index 0000000..9d36f53
--- /dev/null
+++ b/gl/windows-initguard.h
@@ -0,0 +1,35 @@
1/* Init guards, somewhat like spinlocks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_INITGUARD_H
21#define _WINDOWS_INITGUARD_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26typedef struct
27 {
28 volatile int done;
29 volatile LONG started;
30 }
31 glwthread_initguard_t;
32
33#define GLWTHREAD_INITGUARD_INIT { 0, -1 }
34
35#endif /* _WINDOWS_INITGUARD_H */
diff --git a/gl/windows-mutex.c b/gl/windows-mutex.c
new file mode 100644
index 0000000..ab7258c
--- /dev/null
+++ b/gl/windows-mutex.c
@@ -0,0 +1,95 @@
1/* Plain mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-mutex.h"
24
25#include <errno.h>
26
27void
28glwthread_mutex_init (glwthread_mutex_t *mutex)
29{
30 InitializeCriticalSection (&mutex->lock);
31 mutex->guard.done = 1;
32}
33
34int
35glwthread_mutex_lock (glwthread_mutex_t *mutex)
36{
37 if (!mutex->guard.done)
38 {
39 if (InterlockedIncrement (&mutex->guard.started) == 0)
40 /* This thread is the first one to need this mutex. Initialize it. */
41 glwthread_mutex_init (mutex);
42 else
43 {
44 /* Don't let mutex->guard.started grow and wrap around. */
45 InterlockedDecrement (&mutex->guard.started);
46 /* Yield the CPU while waiting for another thread to finish
47 initializing this mutex. */
48 while (!mutex->guard.done)
49 Sleep (0);
50 }
51 }
52 EnterCriticalSection (&mutex->lock);
53 return 0;
54}
55
56int
57glwthread_mutex_trylock (glwthread_mutex_t *mutex)
58{
59 if (!mutex->guard.done)
60 {
61 if (InterlockedIncrement (&mutex->guard.started) == 0)
62 /* This thread is the first one to need this mutex. Initialize it. */
63 glwthread_mutex_init (mutex);
64 else
65 {
66 /* Don't let mutex->guard.started grow and wrap around. */
67 InterlockedDecrement (&mutex->guard.started);
68 /* Let another thread finish initializing this mutex, and let it also
69 lock this mutex. */
70 return EBUSY;
71 }
72 }
73 if (!TryEnterCriticalSection (&mutex->lock))
74 return EBUSY;
75 return 0;
76}
77
78int
79glwthread_mutex_unlock (glwthread_mutex_t *mutex)
80{
81 if (!mutex->guard.done)
82 return EINVAL;
83 LeaveCriticalSection (&mutex->lock);
84 return 0;
85}
86
87int
88glwthread_mutex_destroy (glwthread_mutex_t *mutex)
89{
90 if (!mutex->guard.done)
91 return EINVAL;
92 DeleteCriticalSection (&mutex->lock);
93 mutex->guard.done = 0;
94 return 0;
95}
diff --git a/gl/windows-mutex.h b/gl/windows-mutex.h
new file mode 100644
index 0000000..039eb70
--- /dev/null
+++ b/gl/windows-mutex.h
@@ -0,0 +1,51 @@
1/* Plain mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_MUTEX_H
21#define _WINDOWS_MUTEX_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26#include "windows-initguard.h"
27
28typedef struct
29 {
30 glwthread_initguard_t guard; /* protects the initialization */
31 CRITICAL_SECTION lock;
32 }
33 glwthread_mutex_t;
34
35#define GLWTHREAD_MUTEX_INIT { GLWTHREAD_INITGUARD_INIT }
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41extern void glwthread_mutex_init (glwthread_mutex_t *mutex);
42extern int glwthread_mutex_lock (glwthread_mutex_t *mutex);
43extern int glwthread_mutex_trylock (glwthread_mutex_t *mutex);
44extern int glwthread_mutex_unlock (glwthread_mutex_t *mutex);
45extern int glwthread_mutex_destroy (glwthread_mutex_t *mutex);
46
47#ifdef __cplusplus
48}
49#endif
50
51#endif /* _WINDOWS_MUTEX_H */
diff --git a/gl/windows-once.c b/gl/windows-once.c
new file mode 100644
index 0000000..0d28281
--- /dev/null
+++ b/gl/windows-once.c
@@ -0,0 +1,62 @@
1/* Once-only control (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-once.h"
24
25#include <stdlib.h>
26
27void
28glwthread_once (glwthread_once_t *once_control, void (*initfunction) (void))
29{
30 if (once_control->inited <= 0)
31 {
32 if (InterlockedIncrement (&once_control->started) == 0)
33 {
34 /* This thread is the first one to come to this once_control. */
35 InitializeCriticalSection (&once_control->lock);
36 EnterCriticalSection (&once_control->lock);
37 once_control->inited = 0;
38 initfunction ();
39 once_control->inited = 1;
40 LeaveCriticalSection (&once_control->lock);
41 }
42 else
43 {
44 /* Don't let once_control->started grow and wrap around. */
45 InterlockedDecrement (&once_control->started);
46 /* Some other thread has already started the initialization.
47 Yield the CPU while waiting for the other thread to finish
48 initializing and taking the lock. */
49 while (once_control->inited < 0)
50 Sleep (0);
51 if (once_control->inited <= 0)
52 {
53 /* Take the lock. This blocks until the other thread has
54 finished calling the initfunction. */
55 EnterCriticalSection (&once_control->lock);
56 LeaveCriticalSection (&once_control->lock);
57 if (!(once_control->inited > 0))
58 abort ();
59 }
60 }
61 }
62}
diff --git a/gl/windows-once.h b/gl/windows-once.h
new file mode 100644
index 0000000..5488568
--- /dev/null
+++ b/gl/windows-once.h
@@ -0,0 +1,47 @@
1/* Once-only control (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_ONCE_H
21#define _WINDOWS_ONCE_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26typedef struct
27 {
28 volatile int inited;
29 volatile LONG started;
30 CRITICAL_SECTION lock;
31 }
32 glwthread_once_t;
33
34#define GLWTHREAD_ONCE_INIT { -1, -1 }
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40extern void glwthread_once (glwthread_once_t *once_control,
41 void (*initfunction) (void));
42
43#ifdef __cplusplus
44}
45#endif
46
47#endif /* _WINDOWS_ONCE_H */
diff --git a/gl/windows-recmutex.c b/gl/windows-recmutex.c
new file mode 100644
index 0000000..a8ce9a0
--- /dev/null
+++ b/gl/windows-recmutex.c
@@ -0,0 +1,127 @@
1/* Plain recursive mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-recmutex.h"
24
25#include <errno.h>
26
27void
28glwthread_recmutex_init (glwthread_recmutex_t *mutex)
29{
30 mutex->owner = 0;
31 mutex->depth = 0;
32 InitializeCriticalSection (&mutex->lock);
33 mutex->guard.done = 1;
34}
35
36int
37glwthread_recmutex_lock (glwthread_recmutex_t *mutex)
38{
39 if (!mutex->guard.done)
40 {
41 if (InterlockedIncrement (&mutex->guard.started) == 0)
42 /* This thread is the first one to need this mutex. Initialize it. */
43 glwthread_recmutex_init (mutex);
44 else
45 {
46 /* Don't let mutex->guard.started grow and wrap around. */
47 InterlockedDecrement (&mutex->guard.started);
48 /* Yield the CPU while waiting for another thread to finish
49 initializing this mutex. */
50 while (!mutex->guard.done)
51 Sleep (0);
52 }
53 }
54 {
55 DWORD self = GetCurrentThreadId ();
56 if (mutex->owner != self)
57 {
58 EnterCriticalSection (&mutex->lock);
59 mutex->owner = self;
60 }
61 if (++(mutex->depth) == 0) /* wraparound? */
62 {
63 mutex->depth--;
64 return EAGAIN;
65 }
66 }
67 return 0;
68}
69
70int
71glwthread_recmutex_trylock (glwthread_recmutex_t *mutex)
72{
73 if (!mutex->guard.done)
74 {
75 if (InterlockedIncrement (&mutex->guard.started) == 0)
76 /* This thread is the first one to need this mutex. Initialize it. */
77 glwthread_recmutex_init (mutex);
78 else
79 {
80 /* Don't let mutex->guard.started grow and wrap around. */
81 InterlockedDecrement (&mutex->guard.started);
82 /* Let another thread finish initializing this mutex, and let it also
83 lock this mutex. */
84 return EBUSY;
85 }
86 }
87 {
88 DWORD self = GetCurrentThreadId ();
89 if (mutex->owner != self)
90 {
91 if (!TryEnterCriticalSection (&mutex->lock))
92 return EBUSY;
93 mutex->owner = self;
94 }
95 if (++(mutex->depth) == 0) /* wraparound? */
96 {
97 mutex->depth--;
98 return EAGAIN;
99 }
100 }
101 return 0;
102}
103
104int
105glwthread_recmutex_unlock (glwthread_recmutex_t *mutex)
106{
107 if (mutex->owner != GetCurrentThreadId ())
108 return EPERM;
109 if (mutex->depth == 0)
110 return EINVAL;
111 if (--(mutex->depth) == 0)
112 {
113 mutex->owner = 0;
114 LeaveCriticalSection (&mutex->lock);
115 }
116 return 0;
117}
118
119int
120glwthread_recmutex_destroy (glwthread_recmutex_t *mutex)
121{
122 if (mutex->owner != 0)
123 return EBUSY;
124 DeleteCriticalSection (&mutex->lock);
125 mutex->guard.done = 0;
126 return 0;
127}
diff --git a/gl/windows-recmutex.h b/gl/windows-recmutex.h
new file mode 100644
index 0000000..08ff459
--- /dev/null
+++ b/gl/windows-recmutex.h
@@ -0,0 +1,57 @@
1/* Plain recursive mutexes (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_RECMUTEX_H
21#define _WINDOWS_RECMUTEX_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26#include "windows-initguard.h"
27
28/* The native Windows documentation says that CRITICAL_SECTION already
29 implements a recursive lock. But we need not rely on it: It's easy to
30 implement a recursive lock without this assumption. */
31
32typedef struct
33 {
34 glwthread_initguard_t guard; /* protects the initialization */
35 DWORD owner;
36 unsigned long depth;
37 CRITICAL_SECTION lock;
38 }
39 glwthread_recmutex_t;
40
41#define GLWTHREAD_RECMUTEX_INIT { GLWTHREAD_INITGUARD_INIT, 0, 0 }
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47extern void glwthread_recmutex_init (glwthread_recmutex_t *mutex);
48extern int glwthread_recmutex_lock (glwthread_recmutex_t *mutex);
49extern int glwthread_recmutex_trylock (glwthread_recmutex_t *mutex);
50extern int glwthread_recmutex_unlock (glwthread_recmutex_t *mutex);
51extern int glwthread_recmutex_destroy (glwthread_recmutex_t *mutex);
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif /* _WINDOWS_RECMUTEX_H */
diff --git a/gl/windows-rwlock.c b/gl/windows-rwlock.c
new file mode 100644
index 0000000..7cbd7bb
--- /dev/null
+++ b/gl/windows-rwlock.c
@@ -0,0 +1,377 @@
1/* Read-write locks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#include <config.h>
21
22/* Specification. */
23#include "windows-rwlock.h"
24
25#include <errno.h>
26#include <stdlib.h>
27
28/* Don't assume that UNICODE is not defined. */
29#undef CreateEvent
30#define CreateEvent CreateEventA
31
32/* In this file, the waitqueues are implemented as circular arrays. */
33#define glwthread_waitqueue_t glwthread_carray_waitqueue_t
34
35static void
36glwthread_waitqueue_init (glwthread_waitqueue_t *wq)
37{
38 wq->array = NULL;
39 wq->count = 0;
40 wq->alloc = 0;
41 wq->offset = 0;
42}
43
44/* Enqueues the current thread, represented by an event, in a wait queue.
45 Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
46static HANDLE
47glwthread_waitqueue_add (glwthread_waitqueue_t *wq)
48{
49 HANDLE event;
50 unsigned int index;
51
52 if (wq->count == wq->alloc)
53 {
54 unsigned int new_alloc = 2 * wq->alloc + 1;
55 HANDLE *new_array =
56 (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
57 if (new_array == NULL)
58 /* No more memory. */
59 return INVALID_HANDLE_VALUE;
60 /* Now is a good opportunity to rotate the array so that its contents
61 starts at offset 0. */
62 if (wq->offset > 0)
63 {
64 unsigned int old_count = wq->count;
65 unsigned int old_alloc = wq->alloc;
66 unsigned int old_offset = wq->offset;
67 unsigned int i;
68 if (old_offset + old_count > old_alloc)
69 {
70 unsigned int limit = old_offset + old_count - old_alloc;
71 for (i = 0; i < limit; i++)
72 new_array[old_alloc + i] = new_array[i];
73 }
74 for (i = 0; i < old_count; i++)
75 new_array[i] = new_array[old_offset + i];
76 wq->offset = 0;
77 }
78 wq->array = new_array;
79 wq->alloc = new_alloc;
80 }
81 /* Whether the created event is a manual-reset one or an auto-reset one,
82 does not matter, since we will wait on it only once. */
83 event = CreateEvent (NULL, TRUE, FALSE, NULL);
84 if (event == INVALID_HANDLE_VALUE)
85 /* No way to allocate an event. */
86 return INVALID_HANDLE_VALUE;
87 index = wq->offset + wq->count;
88 if (index >= wq->alloc)
89 index -= wq->alloc;
90 wq->array[index] = event;
91 wq->count++;
92 return event;
93}
94
95/* Notifies the first thread from a wait queue and dequeues it. */
96static void
97glwthread_waitqueue_notify_first (glwthread_waitqueue_t *wq)
98{
99 SetEvent (wq->array[wq->offset + 0]);
100 wq->offset++;
101 wq->count--;
102 if (wq->count == 0 || wq->offset == wq->alloc)
103 wq->offset = 0;
104}
105
106/* Notifies all threads from a wait queue and dequeues them all. */
107static void
108glwthread_waitqueue_notify_all (glwthread_waitqueue_t *wq)
109{
110 unsigned int i;
111
112 for (i = 0; i < wq->count; i++)
113 {
114 unsigned int index = wq->offset + i;
115 if (index >= wq->alloc)
116 index -= wq->alloc;
117 SetEvent (wq->array[index]);
118 }
119 wq->count = 0;
120 wq->offset = 0;
121}
122
123void
124glwthread_rwlock_init (glwthread_rwlock_t *lock)
125{
126 InitializeCriticalSection (&lock->lock);
127 glwthread_waitqueue_init (&lock->waiting_readers);
128 glwthread_waitqueue_init (&lock->waiting_writers);
129 lock->runcount = 0;
130 lock->guard.done = 1;
131}
132
133int
134glwthread_rwlock_rdlock (glwthread_rwlock_t *lock)
135{
136 if (!lock->guard.done)
137 {
138 if (InterlockedIncrement (&lock->guard.started) == 0)
139 /* This thread is the first one to need this lock. Initialize it. */
140 glwthread_rwlock_init (lock);
141 else
142 {
143 /* Don't let lock->guard.started grow and wrap around. */
144 InterlockedDecrement (&lock->guard.started);
145 /* Yield the CPU while waiting for another thread to finish
146 initializing this lock. */
147 while (!lock->guard.done)
148 Sleep (0);
149 }
150 }
151 EnterCriticalSection (&lock->lock);
152 /* Test whether only readers are currently running, and whether the runcount
153 field will not overflow, and whether no writer is waiting. The latter
154 condition is because POSIX recommends that "write locks shall take
155 precedence over read locks", to avoid "writer starvation". */
156 if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0))
157 {
158 /* This thread has to wait for a while. Enqueue it among the
159 waiting_readers. */
160 HANDLE event = glwthread_waitqueue_add (&lock->waiting_readers);
161 if (event != INVALID_HANDLE_VALUE)
162 {
163 DWORD result;
164 LeaveCriticalSection (&lock->lock);
165 /* Wait until another thread signals this event. */
166 result = WaitForSingleObject (event, INFINITE);
167 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
168 abort ();
169 CloseHandle (event);
170 /* The thread which signalled the event already did the bookkeeping:
171 removed us from the waiting_readers, incremented lock->runcount. */
172 if (!(lock->runcount > 0))
173 abort ();
174 return 0;
175 }
176 else
177 {
178 /* Allocation failure. Weird. */
179 do
180 {
181 LeaveCriticalSection (&lock->lock);
182 Sleep (1);
183 EnterCriticalSection (&lock->lock);
184 }
185 while (!(lock->runcount + 1 > 0));
186 }
187 }
188 lock->runcount++;
189 LeaveCriticalSection (&lock->lock);
190 return 0;
191}
192
193int
194glwthread_rwlock_wrlock (glwthread_rwlock_t *lock)
195{
196 if (!lock->guard.done)
197 {
198 if (InterlockedIncrement (&lock->guard.started) == 0)
199 /* This thread is the first one to need this lock. Initialize it. */
200 glwthread_rwlock_init (lock);
201 else
202 {
203 /* Don't let lock->guard.started grow and wrap around. */
204 InterlockedDecrement (&lock->guard.started);
205 /* Yield the CPU while waiting for another thread to finish
206 initializing this lock. */
207 while (!lock->guard.done)
208 Sleep (0);
209 }
210 }
211 EnterCriticalSection (&lock->lock);
212 /* Test whether no readers or writers are currently running. */
213 if (!(lock->runcount == 0))
214 {
215 /* This thread has to wait for a while. Enqueue it among the
216 waiting_writers. */
217 HANDLE event = glwthread_waitqueue_add (&lock->waiting_writers);
218 if (event != INVALID_HANDLE_VALUE)
219 {
220 DWORD result;
221 LeaveCriticalSection (&lock->lock);
222 /* Wait until another thread signals this event. */
223 result = WaitForSingleObject (event, INFINITE);
224 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
225 abort ();
226 CloseHandle (event);
227 /* The thread which signalled the event already did the bookkeeping:
228 removed us from the waiting_writers, set lock->runcount = -1. */
229 if (!(lock->runcount == -1))
230 abort ();
231 return 0;
232 }
233 else
234 {
235 /* Allocation failure. Weird. */
236 do
237 {
238 LeaveCriticalSection (&lock->lock);
239 Sleep (1);
240 EnterCriticalSection (&lock->lock);
241 }
242 while (!(lock->runcount == 0));
243 }
244 }
245 lock->runcount--; /* runcount becomes -1 */
246 LeaveCriticalSection (&lock->lock);
247 return 0;
248}
249
250int
251glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock)
252{
253 if (!lock->guard.done)
254 {
255 if (InterlockedIncrement (&lock->guard.started) == 0)
256 /* This thread is the first one to need this lock. Initialize it. */
257 glwthread_rwlock_init (lock);
258 else
259 {
260 /* Don't let lock->guard.started grow and wrap around. */
261 InterlockedDecrement (&lock->guard.started);
262 /* Yield the CPU while waiting for another thread to finish
263 initializing this lock. */
264 while (!lock->guard.done)
265 Sleep (0);
266 }
267 }
268 /* It's OK to wait for this critical section, because it is never taken for a
269 long time. */
270 EnterCriticalSection (&lock->lock);
271 /* Test whether only readers are currently running, and whether the runcount
272 field will not overflow, and whether no writer is waiting. The latter
273 condition is because POSIX recommends that "write locks shall take
274 precedence over read locks", to avoid "writer starvation". */
275 if (!(lock->runcount + 1 > 0 && lock->waiting_writers.count == 0))
276 {
277 /* This thread would have to wait for a while. Return instead. */
278 LeaveCriticalSection (&lock->lock);
279 return EBUSY;
280 }
281 lock->runcount++;
282 LeaveCriticalSection (&lock->lock);
283 return 0;
284}
285
286int
287glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock)
288{
289 if (!lock->guard.done)
290 {
291 if (InterlockedIncrement (&lock->guard.started) == 0)
292 /* This thread is the first one to need this lock. Initialize it. */
293 glwthread_rwlock_init (lock);
294 else
295 {
296 /* Don't let lock->guard.started grow and wrap around. */
297 InterlockedDecrement (&lock->guard.started);
298 /* Yield the CPU while waiting for another thread to finish
299 initializing this lock. */
300 while (!lock->guard.done)
301 Sleep (0);
302 }
303 }
304 /* It's OK to wait for this critical section, because it is never taken for a
305 long time. */
306 EnterCriticalSection (&lock->lock);
307 /* Test whether no readers or writers are currently running. */
308 if (!(lock->runcount == 0))
309 {
310 /* This thread would have to wait for a while. Return instead. */
311 LeaveCriticalSection (&lock->lock);
312 return EBUSY;
313 }
314 lock->runcount--; /* runcount becomes -1 */
315 LeaveCriticalSection (&lock->lock);
316 return 0;
317}
318
319int
320glwthread_rwlock_unlock (glwthread_rwlock_t *lock)
321{
322 if (!lock->guard.done)
323 return EINVAL;
324 EnterCriticalSection (&lock->lock);
325 if (lock->runcount < 0)
326 {
327 /* Drop a writer lock. */
328 if (!(lock->runcount == -1))
329 abort ();
330 lock->runcount = 0;
331 }
332 else
333 {
334 /* Drop a reader lock. */
335 if (!(lock->runcount > 0))
336 {
337 LeaveCriticalSection (&lock->lock);
338 return EPERM;
339 }
340 lock->runcount--;
341 }
342 if (lock->runcount == 0)
343 {
344 /* POSIX recommends that "write locks shall take precedence over read
345 locks", to avoid "writer starvation". */
346 if (lock->waiting_writers.count > 0)
347 {
348 /* Wake up one of the waiting writers. */
349 lock->runcount--;
350 glwthread_waitqueue_notify_first (&lock->waiting_writers);
351 }
352 else
353 {
354 /* Wake up all waiting readers. */
355 lock->runcount += lock->waiting_readers.count;
356 glwthread_waitqueue_notify_all (&lock->waiting_readers);
357 }
358 }
359 LeaveCriticalSection (&lock->lock);
360 return 0;
361}
362
363int
364glwthread_rwlock_destroy (glwthread_rwlock_t *lock)
365{
366 if (!lock->guard.done)
367 return EINVAL;
368 if (lock->runcount != 0)
369 return EBUSY;
370 DeleteCriticalSection (&lock->lock);
371 if (lock->waiting_readers.array != NULL)
372 free (lock->waiting_readers.array);
373 if (lock->waiting_writers.array != NULL)
374 free (lock->waiting_writers.array);
375 lock->guard.done = 0;
376 return 0;
377}
diff --git a/gl/windows-rwlock.h b/gl/windows-rwlock.h
new file mode 100644
index 0000000..fe8381e
--- /dev/null
+++ b/gl/windows-rwlock.h
@@ -0,0 +1,68 @@
1/* Read-write locks (native Windows implementation).
2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005.
18 Based on GCC's gthr-win32.h. */
19
20#ifndef _WINDOWS_RWLOCK_H
21#define _WINDOWS_RWLOCK_H
22
23#define WIN32_LEAN_AND_MEAN /* avoid including junk */
24#include <windows.h>
25
26#include "windows-initguard.h"
27
28/* It is impossible to implement read-write locks using plain locks, without
29 introducing an extra thread dedicated to managing read-write locks.
30 Therefore here we need to use the low-level Event type. */
31
32typedef struct
33 {
34 HANDLE *array; /* array of waiting threads, each represented by an event */
35 unsigned int count; /* number of waiting threads */
36 unsigned int alloc; /* length of allocated array */
37 unsigned int offset; /* index of first waiting thread in array */
38 }
39 glwthread_carray_waitqueue_t;
40typedef struct
41 {
42 glwthread_initguard_t guard; /* protects the initialization */
43 CRITICAL_SECTION lock; /* protects the remaining fields */
44 glwthread_carray_waitqueue_t waiting_readers; /* waiting readers */
45 glwthread_carray_waitqueue_t waiting_writers; /* waiting writers */
46 int runcount; /* number of readers running, or -1 when a writer runs */
47 }
48 glwthread_rwlock_t;
49
50#define GLWTHREAD_RWLOCK_INIT { GLWTHREAD_INITGUARD_INIT }
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56extern void glwthread_rwlock_init (glwthread_rwlock_t *lock);
57extern int glwthread_rwlock_rdlock (glwthread_rwlock_t *lock);
58extern int glwthread_rwlock_wrlock (glwthread_rwlock_t *lock);
59extern int glwthread_rwlock_tryrdlock (glwthread_rwlock_t *lock);
60extern int glwthread_rwlock_trywrlock (glwthread_rwlock_t *lock);
61extern int glwthread_rwlock_unlock (glwthread_rwlock_t *lock);
62extern int glwthread_rwlock_destroy (glwthread_rwlock_t *lock);
63
64#ifdef __cplusplus
65}
66#endif
67
68#endif /* _WINDOWS_RWLOCK_H */
diff --git a/gl/xalloc-die.c b/gl/xalloc-die.c
index daa403b..7605eee 100644
--- a/gl/xalloc-die.c
+++ b/gl/xalloc-die.c
@@ -1,11 +1,11 @@
1/* Report a memory allocation failure and exit. 1/* Report a memory allocation failure and exit.
2 2
3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2013 Free Software 3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2023 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or 8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
diff --git a/gl/xalloc-oversized.h b/gl/xalloc-oversized.h
index a971c78..5dbdfb5 100644
--- a/gl/xalloc-oversized.h
+++ b/gl/xalloc-oversized.h
@@ -1,38 +1,65 @@
1/* xalloc-oversized.h -- memory allocation size checking 1/* xalloc-oversized.h -- memory allocation size checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3 of the License, or 7 published by the Free Software Foundation; either version 2.1 of the
8 (at your option) any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef XALLOC_OVERSIZED_H_ 18#ifndef XALLOC_OVERSIZED_H_
19# define XALLOC_OVERSIZED_H_ 19#define XALLOC_OVERSIZED_H_
20 20
21# include <stddef.h> 21#include <stddef.h>
22 22#include <stdint.h>
23/* Return 1 if an array of N objects, each of size S, cannot exist due 23
24 to size arithmetic overflow. S must be positive and N must be 24/* True if N * S does not fit into both ptrdiff_t and size_t.
25 nonnegative. This is a macro, not a function, so that it 25 N and S should be nonnegative and free of side effects.
26 works correctly even when SIZE_MAX < N. 26 This expands to a constant expression if N and S are both constants.
27 27 By gnulib convention, SIZE_MAX represents overflow in size_t
28 By gnulib convention, SIZE_MAX represents overflow in size 28 calculations, so the conservative size_t-based dividend to use here
29 calculations, so the conservative dividend to use here is 29 is SIZE_MAX - 1. */
30 SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. 30#define __xalloc_oversized(n, s) \
31 However, malloc (SIZE_MAX) fails on all known hosts where 31 ((s) != 0 \
32 sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for 32 && ((size_t) (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : SIZE_MAX - 1) / (s) \
33 exactly-SIZE_MAX allocations on such hosts; this avoids a test and 33 < (n)))
34 branch when S is known to be 1. */ 34
35/* Return 1 if and only if an array of N objects, each of size S,
36 cannot exist reliably because its total size in bytes would exceed
37 MIN (PTRDIFF_MAX, SIZE_MAX - 1).
38
39 N and S should be nonnegative and free of side effects.
40
41 Warning: (xalloc_oversized (N, S) ? NULL : malloc (N * S)) can
42 misbehave if N and S are both narrower than ptrdiff_t and size_t,
43 and can be rewritten as (xalloc_oversized (N, S) ? NULL
44 : malloc (N * (size_t) S)).
45
46 This is a macro, not a function, so that it works even if an
47 argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX). */
48#if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX
35# define xalloc_oversized(n, s) \ 49# define xalloc_oversized(n, s) \
36 ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) 50 __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1)
51#elif (5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__ \
52 && PTRDIFF_MAX < SIZE_MAX)
53# define xalloc_oversized(n, s) \
54 (__builtin_constant_p (n) && __builtin_constant_p (s) \
55 ? __xalloc_oversized (n, s) \
56 : ({ ptrdiff_t __xalloc_count; \
57 __builtin_mul_overflow (n, s, &__xalloc_count); }))
58
59/* Other compilers use integer division; this may be slower but is
60 more portable. */
61#else
62# define xalloc_oversized(n, s) __xalloc_oversized (n, s)
63#endif
37 64
38#endif /* !XALLOC_OVERSIZED_H_ */ 65#endif /* !XALLOC_OVERSIZED_H_ */
diff --git a/gl/xalloc.h b/gl/xalloc.h
index da7c4b6..f373c2f 100644
--- a/gl/xalloc.h
+++ b/gl/xalloc.h
@@ -1,10 +1,10 @@
1/* xalloc.h -- malloc with out-of-memory checking 1/* xalloc.h -- malloc with out-of-memory checking
2 2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2003-2004, 2006-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -13,57 +13,92 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef XALLOC_H_ 18#ifndef XALLOC_H_
19#define XALLOC_H_ 19#define XALLOC_H_
20 20
21#include <stddef.h> 21#include <stddef.h>
22#include <stdlib.h>
22 23
23#include "xalloc-oversized.h" 24#if GNULIB_XALLOC
25# include "idx.h"
26#endif
24 27
28#ifndef _GL_INLINE_HEADER_BEGIN
29 #error "Please include config.h first."
30#endif
25_GL_INLINE_HEADER_BEGIN 31_GL_INLINE_HEADER_BEGIN
26#ifndef XALLOC_INLINE 32#ifndef XALLOC_INLINE
27# define XALLOC_INLINE _GL_INLINE 33# define XALLOC_INLINE _GL_INLINE
28#endif 34#endif
29 35
36
30#ifdef __cplusplus 37#ifdef __cplusplus
31extern "C" { 38extern "C" {
32#endif 39#endif
33 40
34 41
35#if __GNUC__ >= 3 42#if GNULIB_XALLOC_DIE
36# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
37#else
38# define _GL_ATTRIBUTE_MALLOC
39#endif
40
41#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
42# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
43#else
44# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
45#endif
46 43
47/* This function is always triggered when memory is exhausted. 44/* This function is always triggered when memory is exhausted.
48 It must be defined by the application, either explicitly 45 It must be defined by the application, either explicitly
49 or by using gnulib's xalloc-die module. This is the 46 or by using gnulib's xalloc-die module. This is the
50 function to call when one wants the program to die because of a 47 function to call when one wants the program to die because of a
51 memory allocation failure. */ 48 memory allocation failure. */
52extern _Noreturn void xalloc_die (void); 49/*extern*/ _Noreturn void xalloc_die (void);
50
51#endif /* GNULIB_XALLOC_DIE */
52
53#if GNULIB_XALLOC
53 54
54void *xmalloc (size_t s) 55void *xmalloc (size_t s)
55 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); 56 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
57 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
58void *ximalloc (idx_t s)
59 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
60 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
61void *xinmalloc (idx_t n, idx_t s)
62 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
63 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
56void *xzalloc (size_t s) 64void *xzalloc (size_t s)
57 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); 65 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
66 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
67void *xizalloc (idx_t s)
68 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
69 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
58void *xcalloc (size_t n, size_t s) 70void *xcalloc (size_t n, size_t s)
59 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); 71 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
72 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
73void *xicalloc (idx_t n, idx_t s)
74 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
75 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
60void *xrealloc (void *p, size_t s) 76void *xrealloc (void *p, size_t s)
61 _GL_ATTRIBUTE_ALLOC_SIZE ((2)); 77 _GL_ATTRIBUTE_ALLOC_SIZE ((2));
62void *x2realloc (void *p, size_t *pn); 78void *xirealloc (void *p, idx_t s)
79 _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
80void *xreallocarray (void *p, size_t n, size_t s)
81 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
82void *xireallocarray (void *p, idx_t n, idx_t s)
83 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)) _GL_ATTRIBUTE_RETURNS_NONNULL;
84void *x2realloc (void *p, size_t *ps) /* superseded by xpalloc */
85 _GL_ATTRIBUTE_RETURNS_NONNULL;
86void *x2nrealloc (void *p, size_t *pn, size_t s) /* superseded by xpalloc */
87 _GL_ATTRIBUTE_RETURNS_NONNULL;
88void *xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
89 _GL_ATTRIBUTE_RETURNS_NONNULL;
63void *xmemdup (void const *p, size_t s) 90void *xmemdup (void const *p, size_t s)
64 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2)); 91 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
92 _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
93void *ximemdup (void const *p, idx_t s)
94 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
95 _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
96char *ximemdup0 (void const *p, idx_t s)
97 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
98 _GL_ATTRIBUTE_RETURNS_NONNULL;
65char *xstrdup (char const *str) 99char *xstrdup (char const *str)
66 _GL_ATTRIBUTE_MALLOC; 100 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
101 _GL_ATTRIBUTE_RETURNS_NONNULL;
67 102
68/* In the following macros, T must be an elementary or structure/union or 103/* In the following macros, T must be an elementary or structure/union or
69 typedef'ed type, or a pointer to such a type. To apply one of the 104 typedef'ed type, or a pointer to such a type. To apply one of the
@@ -72,153 +107,60 @@ char *xstrdup (char const *str)
72 107
73/* Allocate an object of type T dynamically, with error checking. */ 108/* Allocate an object of type T dynamically, with error checking. */
74/* extern t *XMALLOC (typename t); */ 109/* extern t *XMALLOC (typename t); */
75#define XMALLOC(t) ((t *) xmalloc (sizeof (t))) 110# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
76 111
77/* Allocate memory for N elements of type T, with error checking. */ 112/* Allocate memory for N elements of type T, with error checking. */
78/* extern t *XNMALLOC (size_t n, typename t); */ 113/* extern t *XNMALLOC (size_t n, typename t); */
79#define XNMALLOC(n, t) \ 114# define XNMALLOC(n, t) \
80 ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t)))) 115 ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
81 116
82/* Allocate an object of type T dynamically, with error checking, 117/* Allocate an object of type T dynamically, with error checking,
83 and zero it. */ 118 and zero it. */
84/* extern t *XZALLOC (typename t); */ 119/* extern t *XZALLOC (typename t); */
85#define XZALLOC(t) ((t *) xzalloc (sizeof (t))) 120# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
86 121
87/* Allocate memory for N elements of type T, with error checking, 122/* Allocate memory for N elements of type T, with error checking,
88 and zero it. */ 123 and zero it. */
89/* extern t *XCALLOC (size_t n, typename t); */ 124/* extern t *XCALLOC (size_t n, typename t); */
90#define XCALLOC(n, t) \ 125# define XCALLOC(n, t) \
91 ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) 126 ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
92 127
93 128
94/* Allocate an array of N objects, each with S bytes of memory, 129/* Allocate an array of N objects, each with S bytes of memory,
95 dynamically, with error checking. S must be nonzero. */ 130 dynamically, with error checking. S must be nonzero. */
96 131
97XALLOC_INLINE void *xnmalloc (size_t n, size_t s) 132void *xnmalloc (size_t n, size_t s)
98 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); 133 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
99XALLOC_INLINE void * 134 _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
100xnmalloc (size_t n, size_t s)
101{
102 if (xalloc_oversized (n, s))
103 xalloc_die ();
104 return xmalloc (n * s);
105}
106 135
136/* FIXME: Deprecate this in favor of xreallocarray? */
107/* Change the size of an allocated block of memory P to an array of N 137/* Change the size of an allocated block of memory P to an array of N
108 objects each of S bytes, with error checking. S must be nonzero. */ 138 objects each of S bytes, with error checking. S must be nonzero. */
109 139
110XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s) 140XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s)
111 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); 141 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
112XALLOC_INLINE void * 142XALLOC_INLINE void *
113xnrealloc (void *p, size_t n, size_t s) 143xnrealloc (void *p, size_t n, size_t s)
114{ 144{
115 if (xalloc_oversized (n, s)) 145 return xreallocarray (p, n, s);
116 xalloc_die ();
117 return xrealloc (p, n * s);
118}
119
120/* If P is null, allocate a block of at least *PN such objects;
121 otherwise, reallocate P so that it contains more than *PN objects
122 each of S bytes. *PN must be nonzero unless P is null, and S must
123 be nonzero. Set *PN to the new number of objects, and return the
124 pointer to the new block. *PN is never set to zero, and the
125 returned pointer is never null.
126
127 Repeated reallocations are guaranteed to make progress, either by
128 allocating an initial block with a nonzero size, or by allocating a
129 larger block.
130
131 In the following implementation, nonzero sizes are increased by a
132 factor of approximately 1.5 so that repeated reallocations have
133 O(N) overall cost rather than O(N**2) cost, but the
134 specification for this function does not guarantee that rate.
135
136 Here is an example of use:
137
138 int *p = NULL;
139 size_t used = 0;
140 size_t allocated = 0;
141
142 void
143 append_int (int value)
144 {
145 if (used == allocated)
146 p = x2nrealloc (p, &allocated, sizeof *p);
147 p[used++] = value;
148 }
149
150 This causes x2nrealloc to allocate a block of some nonzero size the
151 first time it is called.
152
153 To have finer-grained control over the initial size, set *PN to a
154 nonzero value before calling this function with P == NULL. For
155 example:
156
157 int *p = NULL;
158 size_t used = 0;
159 size_t allocated = 0;
160 size_t allocated1 = 1000;
161
162 void
163 append_int (int value)
164 {
165 if (used == allocated)
166 {
167 p = x2nrealloc (p, &allocated1, sizeof *p);
168 allocated = allocated1;
169 }
170 p[used++] = value;
171 }
172
173 */
174
175XALLOC_INLINE void *
176x2nrealloc (void *p, size_t *pn, size_t s)
177{
178 size_t n = *pn;
179
180 if (! p)
181 {
182 if (! n)
183 {
184 /* The approximate size to use for initial small allocation
185 requests, when the invoking code specifies an old size of
186 zero. This is the largest "small" request for the GNU C
187 library malloc. */
188 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
189
190 n = DEFAULT_MXFAST / s;
191 n += !n;
192 }
193 }
194 else
195 {
196 /* Set N = ceil (1.5 * N) so that progress is made if N == 1.
197 Check for overflow, so that N * S stays in size_t range.
198 The check is slightly conservative, but an exact check isn't
199 worth the trouble. */
200 if ((size_t) -1 / 3 * 2 / s <= n)
201 xalloc_die ();
202 n += (n + 1) / 2;
203 }
204
205 *pn = n;
206 return xrealloc (p, n * s);
207} 146}
208 147
209/* Return a pointer to a new buffer of N bytes. This is like xmalloc, 148/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
210 except it returns char *. */ 149 except it returns char *. */
211 150
212XALLOC_INLINE char *xcharalloc (size_t n) 151char *xcharalloc (size_t n)
213 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); 152 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
214XALLOC_INLINE char * 153 _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
215xcharalloc (size_t n) 154
216{ 155#endif /* GNULIB_XALLOC */
217 return XNMALLOC (n, char); 156
218}
219 157
220#ifdef __cplusplus 158#ifdef __cplusplus
221} 159}
160#endif
161
162
163#if GNULIB_XALLOC && defined __cplusplus
222 164
223/* C++ does not allow conversions from void * to other pointer types 165/* C++ does not allow conversions from void * to other pointer types
224 without a cast. Use templates to work around the problem when 166 without a cast. Use templates to work around the problem when
@@ -231,9 +173,16 @@ xrealloc (T *p, size_t s)
231} 173}
232 174
233template <typename T> inline T * 175template <typename T> inline T *
176xreallocarray (T *p, size_t n, size_t s)
177{
178 return (T *) xreallocarray ((void *) p, n, s);
179}
180
181/* FIXME: Deprecate this in favor of xreallocarray? */
182template <typename T> inline T *
234xnrealloc (T *p, size_t n, size_t s) 183xnrealloc (T *p, size_t n, size_t s)
235{ 184{
236 return (T *) xnrealloc ((void *) p, n, s); 185 return xreallocarray (p, n, s);
237} 186}
238 187
239template <typename T> inline T * 188template <typename T> inline T *
@@ -254,7 +203,9 @@ xmemdup (T const *p, size_t s)
254 return (T *) xmemdup ((void const *) p, s); 203 return (T *) xmemdup ((void const *) p, s);
255} 204}
256 205
257#endif 206#endif /* GNULIB_XALLOC && C++ */
207
258 208
209_GL_INLINE_HEADER_END
259 210
260#endif /* !XALLOC_H_ */ 211#endif /* !XALLOC_H_ */
diff --git a/gl/xmalloc.c b/gl/xmalloc.c
index 57e34b7..289cbd0 100644
--- a/gl/xmalloc.c
+++ b/gl/xmalloc.c
@@ -1,10 +1,10 @@
1/* xmalloc.c -- malloc with out of memory checking 1/* xmalloc.c -- malloc with out of memory checking
2 2
3 Copyright (C) 1990-2000, 2002-2006, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 1990-2000, 2002-2006, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or 7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#include <config.h> 18#include <config.h>
19 19
@@ -21,59 +21,256 @@
21 21
22#include "xalloc.h" 22#include "xalloc.h"
23 23
24#include "ialloc.h"
25#include "minmax.h"
26
27#include <stdckdint.h>
24#include <stdlib.h> 28#include <stdlib.h>
29#include <stdint.h>
25#include <string.h> 30#include <string.h>
26 31
27/* 1 if calloc is known to be compatible with GNU calloc. This 32static void * _GL_ATTRIBUTE_PURE
28 matters if we are not also using the calloc module, which defines 33nonnull (void *p)
29 HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */ 34{
30#if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__) 35 if (!p)
31enum { HAVE_GNU_CALLOC = 1 }; 36 xalloc_die ();
32#else 37 return p;
33enum { HAVE_GNU_CALLOC = 0 }; 38}
34#endif
35 39
36/* Allocate N bytes of memory dynamically, with error checking. */ 40/* Allocate S bytes of memory dynamically, with error checking. */
37 41
38void * 42void *
39xmalloc (size_t n) 43xmalloc (size_t s)
40{ 44{
41 void *p = malloc (n); 45 return nonnull (malloc (s));
42 if (!p && n != 0) 46}
43 xalloc_die (); 47
44 return p; 48void *
49ximalloc (idx_t s)
50{
51 return nonnull (imalloc (s));
45} 52}
46 53
47/* Change the size of an allocated block of memory P to N bytes, 54char *
55xcharalloc (size_t n)
56{
57 return XNMALLOC (n, char);
58}
59
60/* Change the size of an allocated block of memory P to S bytes,
48 with error checking. */ 61 with error checking. */
49 62
50void * 63void *
51xrealloc (void *p, size_t n) 64xrealloc (void *p, size_t s)
65{
66 void *r = realloc (p, s);
67 if (!r && (!p || s))
68 xalloc_die ();
69 return r;
70}
71
72void *
73xirealloc (void *p, idx_t s)
74{
75 return nonnull (irealloc (p, s));
76}
77
78/* Change the size of an allocated block of memory P to an array of N
79 objects each of S bytes, with error checking. */
80
81void *
82xreallocarray (void *p, size_t n, size_t s)
83{
84 void *r = reallocarray (p, n, s);
85 if (!r && (!p || (n && s)))
86 xalloc_die ();
87 return r;
88}
89
90void *
91xireallocarray (void *p, idx_t n, idx_t s)
92{
93 return nonnull (ireallocarray (p, n, s));
94}
95
96/* Allocate an array of N objects, each with S bytes of memory,
97 dynamically, with error checking. S must be nonzero. */
98
99void *
100xnmalloc (size_t n, size_t s)
101{
102 return xreallocarray (NULL, n, s);
103}
104
105void *
106xinmalloc (idx_t n, idx_t s)
107{
108 return xireallocarray (NULL, n, s);
109}
110
111/* If P is null, allocate a block of at least *PS bytes; otherwise,
112 reallocate P so that it contains more than *PS bytes. *PS must be
113 nonzero unless P is null. Set *PS to the new block's size, and
114 return the pointer to the new block. *PS is never set to zero, and
115 the returned pointer is never null. */
116
117void *
118x2realloc (void *p, size_t *ps)
119{
120 return x2nrealloc (p, ps, 1);
121}
122
123/* If P is null, allocate a block of at least *PN such objects;
124 otherwise, reallocate P so that it contains more than *PN objects
125 each of S bytes. S must be nonzero. Set *PN to the new number of
126 objects, and return the pointer to the new block. *PN is never set
127 to zero, and the returned pointer is never null.
128
129 Repeated reallocations are guaranteed to make progress, either by
130 allocating an initial block with a nonzero size, or by allocating a
131 larger block.
132
133 In the following implementation, nonzero sizes are increased by a
134 factor of approximately 1.5 so that repeated reallocations have
135 O(N) overall cost rather than O(N**2) cost, but the
136 specification for this function does not guarantee that rate.
137
138 Here is an example of use:
139
140 int *p = NULL;
141 size_t used = 0;
142 size_t allocated = 0;
143
144 void
145 append_int (int value)
146 {
147 if (used == allocated)
148 p = x2nrealloc (p, &allocated, sizeof *p);
149 p[used++] = value;
150 }
151
152 This causes x2nrealloc to allocate a block of some nonzero size the
153 first time it is called.
154
155 To have finer-grained control over the initial size, set *PN to a
156 nonzero value before calling this function with P == NULL. For
157 example:
158
159 int *p = NULL;
160 size_t used = 0;
161 size_t allocated = 0;
162 size_t allocated1 = 1000;
163
164 void
165 append_int (int value)
166 {
167 if (used == allocated)
168 {
169 p = x2nrealloc (p, &allocated1, sizeof *p);
170 allocated = allocated1;
171 }
172 p[used++] = value;
173 }
174
175 */
176
177void *
178x2nrealloc (void *p, size_t *pn, size_t s)
52{ 179{
53 if (!n && p) 180 size_t n = *pn;
181
182 if (! p)
54 { 183 {
55 /* The GNU and C99 realloc behaviors disagree here. Act like 184 if (! n)
56 GNU, even if the underlying realloc is C99. */ 185 {
57 free (p); 186 /* The approximate size to use for initial small allocation
58 return NULL; 187 requests, when the invoking code specifies an old size of
188 zero. This is the largest "small" request for the GNU C
189 library malloc. */
190 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
191
192 n = DEFAULT_MXFAST / s;
193 n += !n;
194 }
195 }
196 else
197 {
198 /* Set N = floor (1.5 * N) + 1 to make progress even if N == 0. */
199 if (ckd_add (&n, n, (n >> 1) + 1))
200 xalloc_die ();
59 } 201 }
60 202
61 p = realloc (p, n); 203 p = xreallocarray (p, n, s);
62 if (!p && n) 204 *pn = n;
63 xalloc_die ();
64 return p; 205 return p;
65} 206}
66 207
67/* If P is null, allocate a block of at least *PN bytes; otherwise, 208/* Grow PA, which points to an array of *PN items, and return the
68 reallocate P so that it contains more than *PN bytes. *PN must be 209 location of the reallocated array, updating *PN to reflect its
69 nonzero unless P is null. Set *PN to the new block's size, and 210 new size. The new array will contain at least N_INCR_MIN more
70 return the pointer to the new block. *PN is never set to zero, and 211 items, but will not contain more than N_MAX items total.
71 the returned pointer is never null. */ 212 S is the size of each item, in bytes.
213
214 S and N_INCR_MIN must be positive. *PN must be
215 nonnegative. If N_MAX is -1, it is treated as if it were
216 infinity.
217
218 If PA is null, then allocate a new array instead of reallocating
219 the old one.
220
221 Thus, to grow an array A without saving its old contents, do
222 { free (A); A = xpalloc (NULL, &AITEMS, ...); }. */
72 223
73void * 224void *
74x2realloc (void *p, size_t *pn) 225xpalloc (void *pa, idx_t *pn, idx_t n_incr_min, ptrdiff_t n_max, idx_t s)
75{ 226{
76 return x2nrealloc (p, pn, 1); 227 idx_t n0 = *pn;
228
229 /* The approximate size to use for initial small allocation
230 requests. This is the largest "small" request for the GNU C
231 library malloc. */
232 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
233
234 /* If the array is tiny, grow it to about (but no greater than)
235 DEFAULT_MXFAST bytes. Otherwise, grow it by about 50%.
236 Adjust the growth according to three constraints: N_INCR_MIN,
237 N_MAX, and what the C language can represent safely. */
238
239 idx_t n;
240 if (ckd_add (&n, n0, n0 >> 1))
241 n = IDX_MAX;
242 if (0 <= n_max && n_max < n)
243 n = n_max;
244
245 /* NBYTES is of a type suitable for holding the count of bytes in an object.
246 This is typically idx_t, but it should be size_t on (theoretical?)
247 platforms where SIZE_MAX < IDX_MAX so xpalloc does not pass
248 values greater than SIZE_MAX to xrealloc. */
249#if IDX_MAX <= SIZE_MAX
250 idx_t nbytes;
251#else
252 size_t nbytes;
253#endif
254 idx_t adjusted_nbytes
255 = (ckd_mul (&nbytes, n, s)
256 ? MIN (IDX_MAX, SIZE_MAX)
257 : nbytes < DEFAULT_MXFAST ? DEFAULT_MXFAST : 0);
258 if (adjusted_nbytes)
259 {
260 n = adjusted_nbytes / s;
261 nbytes = adjusted_nbytes - adjusted_nbytes % s;
262 }
263
264 if (! pa)
265 *pn = 0;
266 if (n - n0 < n_incr_min
267 && (ckd_add (&n, n0, n_incr_min)
268 || (0 <= n_max && n_max < n)
269 || ckd_mul (&nbytes, n, s)))
270 xalloc_die ();
271 pa = xrealloc (pa, nbytes);
272 *pn = n;
273 return pa;
77} 274}
78 275
79/* Allocate S bytes of zeroed memory dynamically, with error checking. 276/* Allocate S bytes of zeroed memory dynamically, with error checking.
@@ -83,7 +280,13 @@ x2realloc (void *p, size_t *pn)
83void * 280void *
84xzalloc (size_t s) 281xzalloc (size_t s)
85{ 282{
86 return memset (xmalloc (s), 0, s); 283 return xcalloc (s, 1);
284}
285
286void *
287xizalloc (idx_t s)
288{
289 return xicalloc (s, 1);
87} 290}
88 291
89/* Allocate zeroed memory for N elements of S bytes, with error 292/* Allocate zeroed memory for N elements of S bytes, with error
@@ -92,15 +295,13 @@ xzalloc (size_t s)
92void * 295void *
93xcalloc (size_t n, size_t s) 296xcalloc (size_t n, size_t s)
94{ 297{
95 void *p; 298 return nonnull (calloc (n, s));
96 /* Test for overflow, since some calloc implementations don't have 299}
97 proper overflow checks. But omit overflow and size-zero tests if 300
98 HAVE_GNU_CALLOC, since GNU calloc catches overflow and never 301void *
99 returns NULL if successful. */ 302xicalloc (idx_t n, idx_t s)
100 if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s)) 303{
101 || (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0))) 304 return nonnull (icalloc (n, s));
102 xalloc_die ();
103 return p;
104} 305}
105 306
106/* Clone an object P of size S, with error checking. There's no need 307/* Clone an object P of size S, with error checking. There's no need
@@ -113,6 +314,23 @@ xmemdup (void const *p, size_t s)
113 return memcpy (xmalloc (s), p, s); 314 return memcpy (xmalloc (s), p, s);
114} 315}
115 316
317void *
318ximemdup (void const *p, idx_t s)
319{
320 return memcpy (ximalloc (s), p, s);
321}
322
323/* Clone an object P of size S, with error checking. Append
324 a terminating NUL byte. */
325
326char *
327ximemdup0 (void const *p, idx_t s)
328{
329 char *result = ximalloc (s + 1);
330 result[s] = 0;
331 return memcpy (result, p, s);
332}
333
116/* Clone STRING. */ 334/* Clone STRING. */
117 335
118char * 336char *
diff --git a/gl/xsize.c b/gl/xsize.c
index 4b4914c..279ae82 100644
--- a/gl/xsize.c
+++ b/gl/xsize.c
@@ -1,3 +1,21 @@
1/* Checked size_t computations.
2
3 Copyright (C) 2012-2023 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
1#include <config.h> 18#include <config.h>
19
2#define XSIZE_INLINE _GL_EXTERN_INLINE 20#define XSIZE_INLINE _GL_EXTERN_INLINE
3#include "xsize.h" 21#include "xsize.h"
diff --git a/gl/xsize.h b/gl/xsize.h
index 2922f35..1ec78e7 100644
--- a/gl/xsize.h
+++ b/gl/xsize.h
@@ -1,19 +1,19 @@
1/* xsize.h -- Checked size_t computations. 1/* xsize.h -- Checked size_t computations.
2 2
3 Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2008-2023 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU Lesser General Public License as
7 the Free Software Foundation; either version 3, or (at your option) 7 published by the Free Software Foundation; either version 2.1 of the
8 any later version. 8 License, or (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18#ifndef _XSIZE_H 18#ifndef _XSIZE_H
19#define _XSIZE_H 19#define _XSIZE_H
@@ -27,6 +27,12 @@
27# include <stdint.h> 27# include <stdint.h>
28#endif 28#endif
29 29
30/* Get ATTRIBUTE_PURE. */
31#include "attribute.h"
32
33#ifndef _GL_INLINE_HEADER_BEGIN
34 #error "Please include config.h first."
35#endif
30_GL_INLINE_HEADER_BEGIN 36_GL_INLINE_HEADER_BEGIN
31#ifndef XSIZE_INLINE 37#ifndef XSIZE_INLINE
32# define XSIZE_INLINE _GL_INLINE 38# define XSIZE_INLINE _GL_INLINE
@@ -53,10 +59,7 @@ _GL_INLINE_HEADER_BEGIN
53 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) 59 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
54 60
55/* Sum of two sizes, with overflow check. */ 61/* Sum of two sizes, with overflow check. */
56XSIZE_INLINE size_t 62XSIZE_INLINE size_t ATTRIBUTE_PURE
57#if __GNUC__ >= 3
58__attribute__ ((__pure__))
59#endif
60xsum (size_t size1, size_t size2) 63xsum (size_t size1, size_t size2)
61{ 64{
62 size_t sum = size1 + size2; 65 size_t sum = size1 + size2;
@@ -64,30 +67,21 @@ xsum (size_t size1, size_t size2)
64} 67}
65 68
66/* Sum of three sizes, with overflow check. */ 69/* Sum of three sizes, with overflow check. */
67XSIZE_INLINE size_t 70XSIZE_INLINE size_t ATTRIBUTE_PURE
68#if __GNUC__ >= 3
69__attribute__ ((__pure__))
70#endif
71xsum3 (size_t size1, size_t size2, size_t size3) 71xsum3 (size_t size1, size_t size2, size_t size3)
72{ 72{
73 return xsum (xsum (size1, size2), size3); 73 return xsum (xsum (size1, size2), size3);
74} 74}
75 75
76/* Sum of four sizes, with overflow check. */ 76/* Sum of four sizes, with overflow check. */
77XSIZE_INLINE size_t 77XSIZE_INLINE size_t ATTRIBUTE_PURE
78#if __GNUC__ >= 3
79__attribute__ ((__pure__))
80#endif
81xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) 78xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
82{ 79{
83 return xsum (xsum (xsum (size1, size2), size3), size4); 80 return xsum (xsum (xsum (size1, size2), size3), size4);
84} 81}
85 82
86/* Maximum of two sizes, with overflow check. */ 83/* Maximum of two sizes, with overflow check. */
87XSIZE_INLINE size_t 84XSIZE_INLINE size_t ATTRIBUTE_PURE
88#if __GNUC__ >= 3
89__attribute__ ((__pure__))
90#endif
91xmax (size_t size1, size_t size2) 85xmax (size_t size1, size_t size2)
92{ 86{
93 /* No explicit check is needed here, because for any n: 87 /* No explicit check is needed here, because for any n:
diff --git a/gl/xstrndup.c b/gl/xstrndup.c
deleted file mode 100644
index eae92d0..0000000
--- a/gl/xstrndup.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* Duplicate a bounded initial segment of a string, with out-of-memory
2 checking.
3 Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "xstrndup.h"
22
23#include <string.h>
24#include "xalloc.h"
25
26/* Return a newly allocated copy of at most N bytes of STRING.
27 In other words, return a copy of the initial segment of length N of
28 STRING. */
29char *
30xstrndup (const char *string, size_t n)
31{
32 char *s = strndup (string, n);
33 if (! s)
34 xalloc_die ();
35 return s;
36}
diff --git a/gl/xstrndup.h b/gl/xstrndup.h
deleted file mode 100644
index 59673b0..0000000
--- a/gl/xstrndup.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/* Duplicate a bounded initial segment of a string, with out-of-memory
2 checking.
3 Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <stddef.h>
19
20/* Return a newly allocated copy of at most N bytes of STRING.
21 In other words, return a copy of the initial segment of length N of
22 STRING. */
23extern char *xstrndup (const char *string, size_t n);
diff --git a/lib/parse_ini.c b/lib/parse_ini.c
index 25abc89..547af43 100644
--- a/lib/parse_ini.c
+++ b/lib/parse_ini.c
@@ -78,7 +78,7 @@ static char *default_file_in_path(void);
78/* 78/*
79 * Parse_locator decomposes a string of the form 79 * Parse_locator decomposes a string of the form
80 * [stanza][@filename] 80 * [stanza][@filename]
81 * into its seperate parts. 81 * into its separate parts.
82 */ 82 */
83static void 83static void
84parse_locator(const char *locator, const char *def_stanza, np_ini_info *i) 84parse_locator(const char *locator, const char *def_stanza, np_ini_info *i)
@@ -169,7 +169,7 @@ read_defaults(FILE *f, const char *stanza, np_arg_list **opts)
169 if (isspace(c)) 169 if (isspace(c))
170 continue; 170 continue;
171 switch (c) { 171 switch (c) {
172 /* globble up coment lines */ 172 /* globble up comment lines */
173 case ';': 173 case ';':
174 case '#': 174 case '#':
175 GOBBLE_TO(f, c, '\n'); 175 GOBBLE_TO(f, c, '\n');
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index a8d7ade..31d79df 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -27,7 +27,7 @@ endif
27 27
28AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags) 28AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags)
29AM_LDFLAGS = $(tap_ldflags) -ltap 29AM_LDFLAGS = $(tap_ldflags) -ltap
30LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a 30LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a $(LIB_CRYPTO)
31 31
32SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c 32SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c
33 33
diff --git a/lib/tests/test_cmd.c b/lib/tests/test_cmd.c
index 29ca42a..4bb60aa 100644
--- a/lib/tests/test_cmd.c
+++ b/lib/tests/test_cmd.c
@@ -176,14 +176,14 @@ main (int argc, char **argv)
176 ok (result == UNSET, "(initialised) Checking exit code is reset"); 176 ok (result == UNSET, "(initialised) Checking exit code is reset");
177 177
178 command = (char *)malloc(COMMAND_LINE); 178 command = (char *)malloc(COMMAND_LINE);
179 strcpy(command, "/bin/echo3456 non-existant command"); 179 strcpy(command, "/bin/echo3456 non-existent command");
180 result = cmd_run (command, &chld_out, &chld_err, 0); 180 result = cmd_run (command, &chld_out, &chld_err, 0);
181 181
182 ok (chld_out.lines == 0, 182 ok (chld_out.lines == 0,
183 "Non existant command, so no output"); 183 "Non existent command, so no output");
184 ok (chld_err.lines == 0, 184 ok (chld_err.lines == 0,
185 "No stderr either"); 185 "No stderr either");
186 ok (result == 3, "Get return code 3 (?) for non-existant command"); 186 ok (result == 3, "Get return code 3 (?) for non-existent command");
187 187
188 188
189 /* ensure everything is empty again */ 189 /* ensure everything is empty again */
@@ -192,14 +192,14 @@ main (int argc, char **argv)
192 result = UNSET; 192 result = UNSET;
193 193
194 command = (char *)malloc(COMMAND_LINE); 194 command = (char *)malloc(COMMAND_LINE);
195 strcpy(command, "/bin/sh non-existant-file"); 195 strcpy(command, "/bin/sh non-existent-file");
196 result = cmd_run (command, &chld_out, &chld_err, 0); 196 result = cmd_run (command, &chld_out, &chld_err, 0);
197 197
198 ok (chld_out.lines == 0, 198 ok (chld_out.lines == 0,
199 "/bin/sh returns no stdout when file is missing..."); 199 "/bin/sh returns no stdout when file is missing...");
200 ok (chld_err.lines == 1, 200 ok (chld_err.lines == 1,
201 "...but does give an error line"); 201 "...but does give an error line");
202 ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message"); 202 ok (strstr(chld_err.line[0],"non-existent-file") != NULL, "And missing filename is in error message");
203 ok (result != 0, "Get non-zero return code from /bin/sh"); 203 ok (result != 0, "Get non-zero return code from /bin/sh");
204 204
205 205
@@ -219,11 +219,11 @@ main (int argc, char **argv)
219 result = UNSET; 219 result = UNSET;
220 220
221 command = (char *)malloc(COMMAND_LINE); 221 command = (char *)malloc(COMMAND_LINE);
222 strcpy(command, "/bin/non-existant-command"); 222 strcpy(command, "/bin/non-existent-command");
223 result = cmd_run (command, &chld_out, &chld_err, 0); 223 result = cmd_run (command, &chld_out, &chld_err, 0);
224 224
225 ok (chld_out.lines == 0, 225 ok (chld_out.lines == 0,
226 "/bin/non-existant-command returns no stdout..."); 226 "/bin/non-existent-command returns no stdout...");
227 ok (chld_err.lines == 0, 227 ok (chld_err.lines == 0,
228 "...and no stderr output either"); 228 "...and no stderr output either");
229 ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist"); 229 ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist");
diff --git a/lib/tests/test_disk.c b/lib/tests/test_disk.c
index f6477ac..9bd68c7 100644
--- a/lib/tests/test_disk.c
+++ b/lib/tests/test_disk.c
@@ -88,10 +88,10 @@ main (int argc, char **argv)
88 cflags, 3,strdup("regex on dev names:")); 88 cflags, 3,strdup("regex on dev names:"));
89 np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"), 89 np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"),
90 cflags, 0, 90 cflags, 0,
91 strdup("regex on non existant dev/path:")); 91 strdup("regex on non existent dev/path:"));
92 np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"), 92 np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"),
93 cflags | REG_ICASE,0, 93 cflags | REG_ICASE,0,
94 strdup("regi on non existant dev/path:")); 94 strdup("regi on non existent dev/path:"));
95 np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"), 95 np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"),
96 cflags, 3, 96 cflags, 3,
97 strdup("partial devname regex match:")); 97 strdup("partial devname regex match:"));
diff --git a/lib/tests/test_ini3.t b/lib/tests/test_ini3.t
index a2ca94a..41169db 100755
--- a/lib/tests/test_ini3.t
+++ b/lib/tests/test_ini3.t
@@ -10,7 +10,7 @@ if (! -e "./test_ini3") {
10# array of argument arrays 10# array of argument arrays
11# - First value is the expected return code 11# - First value is the expected return code
12# - 2nd value is the NAGIOS_CONFIG_PATH 12# - 2nd value is the NAGIOS_CONFIG_PATH
13# TODO: looks like we look in default path after looking trough this variable - shall we? 13# TODO: looks like we look in default path after looking through this variable - shall we?
14# - 3rd value is the plugin name 14# - 3rd value is the plugin name
15# - 4th is the ini locator 15# - 4th is the ini locator
16my @TESTS = ( 16my @TESTS = (
diff --git a/lib/tests/test_opts3.t b/lib/tests/test_opts3.t
index 8d974ca..d77a35c 100755
--- a/lib/tests/test_opts3.t
+++ b/lib/tests/test_opts3.t
@@ -10,7 +10,7 @@ if (! -e "./test_opts3") {
10# array of argument arrays 10# array of argument arrays
11# - First value is the expected return code 11# - First value is the expected return code
12# - 2nd value is the NAGIOS_CONFIG_PATH 12# - 2nd value is the NAGIOS_CONFIG_PATH
13# TODO: looks like we look in default path after looking trough this variable - shall we? 13# TODO: looks like we look in default path after looking through this variable - shall we?
14# - 3rd value is the plugin name 14# - 3rd value is the plugin name
15# - 4th and up are arguments 15# - 4th and up are arguments
16my @TESTS = ( 16my @TESTS = (
diff --git a/lib/tests/test_utils.c b/lib/tests/test_utils.c
index f35b7e2..7b10494 100644
--- a/lib/tests/test_utils.c
+++ b/lib/tests/test_utils.c
@@ -309,7 +309,7 @@ main (int argc, char **argv)
309 309
310 /* This is the result of running ./test_utils */ 310 /* This is the result of running ./test_utils */
311 temp_string = (char *) _np_state_generate_key(); 311 temp_string = (char *) _np_state_generate_key();
312 ok(!strcmp(temp_string, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got hash with exe and no parameters" ) || 312 ok(!strcmp(temp_string, "e2d17f995fd4c020411b85e3e3d0ff7306d4147e"), "Got hash with exe and no parameters" ) ||
313 diag( "You are probably running in wrong directory. Must run as ./test_utils" ); 313 diag( "You are probably running in wrong directory. Must run as ./test_utils" );
314 314
315 315
@@ -319,7 +319,7 @@ main (int argc, char **argv)
319 this_monitoring_plugin->argv[2] = "--and"; 319 this_monitoring_plugin->argv[2] = "--and";
320 this_monitoring_plugin->argv[3] = "now"; 320 this_monitoring_plugin->argv[3] = "now";
321 temp_string = (char *) _np_state_generate_key(); 321 temp_string = (char *) _np_state_generate_key();
322 ok(!strcmp(temp_string, "94b5e17bf5abf51cb15aff5f69b96f2f8dac5ecd"), "Got based on expected argv" ); 322 ok(!strcmp(temp_string, "bd72da9f78ff1419fad921ea5e43ce56508aef6c"), "Got based on expected argv" );
323 323
324 unsetenv("MP_STATE_PATH"); 324 unsetenv("MP_STATE_PATH");
325 temp_string = (char *) _np_state_calculate_location_prefix(); 325 temp_string = (char *) _np_state_calculate_location_prefix();
@@ -342,7 +342,7 @@ main (int argc, char **argv)
342 np_enable_state(NULL, 51); 342 np_enable_state(NULL, 51);
343 temp_state_key = this_monitoring_plugin->state; 343 temp_state_key = this_monitoring_plugin->state;
344 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" ); 344 ok( !strcmp(temp_state_key->plugin_name, "check_test"), "Got plugin name" );
345 ok( !strcmp(temp_state_key->name, "83d877b6cdfefb5d6f06101fd6fe76762f21792c"), "Got generated filename" ); 345 ok( !strcmp(temp_state_key->name, "e2d17f995fd4c020411b85e3e3d0ff7306d4147e"), "Got generated filename" );
346 346
347 347
348 np_enable_state("allowedchars_in_keyname", 77); 348 np_enable_state("allowedchars_in_keyname", 77);
@@ -395,7 +395,7 @@ main (int argc, char **argv)
395 ok( temp_state_data==NULL, "Older data version gives NULL" ); 395 ok( temp_state_data==NULL, "Older data version gives NULL" );
396 temp_state_key->data_version=54; 396 temp_state_key->data_version=54;
397 397
398 temp_state_key->_filename="var/nonexistant"; 398 temp_state_key->_filename="var/nonexistent";
399 temp_state_data = np_state_read(); 399 temp_state_data = np_state_read();
400 ok( temp_state_data==NULL, "Missing file gives NULL" ); 400 ok( temp_state_data==NULL, "Missing file gives NULL" );
401 ok( this_monitoring_plugin->state->state_data==NULL, "No state information" ); 401 ok( this_monitoring_plugin->state->state_data==NULL, "No state information" );
diff --git a/lib/utils_base.c b/lib/utils_base.c
index fd7058d..c458cf6 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -24,7 +24,7 @@
24* 24*
25*****************************************************************************/ 25*****************************************************************************/
26 26
27#include "common.h" 27#include "../plugins/common.h"
28#include <stdarg.h> 28#include <stdarg.h>
29#include "utils_base.h" 29#include "utils_base.h"
30#include <ctype.h> 30#include <ctype.h>
@@ -128,6 +128,7 @@ range
128 temp_range->end = 0; 128 temp_range->end = 0;
129 temp_range->end_infinity = TRUE; 129 temp_range->end_infinity = TRUE;
130 temp_range->alert_on = OUTSIDE; 130 temp_range->alert_on = OUTSIDE;
131 temp_range->text = strdup(str);
131 132
132 if (str[0] == '@') { 133 if (str[0] == '@') {
133 temp_range->alert_on = INSIDE; 134 temp_range->alert_on = INSIDE;
@@ -318,18 +319,18 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
318 319
319 while (1) { 320 while (1) {
320 /* Strip any leading space */ 321 /* Strip any leading space */
321 for (varlist; isspace(varlist[0]); varlist++); 322 for (; isspace(varlist[0]); varlist++);
322 323
323 if (strncmp(name, varlist, strlen(name)) == 0) { 324 if (strncmp(name, varlist, strlen(name)) == 0) {
324 varlist += strlen(name); 325 varlist += strlen(name);
325 /* strip trailing spaces */ 326 /* strip trailing spaces */
326 for (varlist; isspace(varlist[0]); varlist++); 327 for (; isspace(varlist[0]); varlist++);
327 328
328 if (varlist[0] == '=') { 329 if (varlist[0] == '=') {
329 /* We matched the key, go past the = sign */ 330 /* We matched the key, go past the = sign */
330 varlist++; 331 varlist++;
331 /* strip leading spaces */ 332 /* strip leading spaces */
332 for (varlist; isspace(varlist[0]); varlist++); 333 for (; isspace(varlist[0]); varlist++);
333 334
334 if (tmp = index(varlist, sep)) { 335 if (tmp = index(varlist, sep)) {
335 /* Value is delimited by a comma */ 336 /* Value is delimited by a comma */
@@ -401,20 +402,20 @@ int mp_translate_state (char *state_text) {
401 * parse of argv, so that uniqueness in parameters are reflected there. 402 * parse of argv, so that uniqueness in parameters are reflected there.
402 */ 403 */
403char *_np_state_generate_key() { 404char *_np_state_generate_key() {
404 struct sha1_ctx ctx; 405 struct sha256_ctx ctx;
405 int i; 406 int i;
406 char **argv = this_monitoring_plugin->argv; 407 char **argv = this_monitoring_plugin->argv;
407 unsigned char result[20]; 408 unsigned char result[20];
408 char keyname[41]; 409 char keyname[41];
409 char *p=NULL; 410 char *p=NULL;
410 411
411 sha1_init_ctx(&ctx); 412 sha256_init_ctx(&ctx);
412 413
413 for(i=0; i<this_monitoring_plugin->argc; i++) { 414 for(i=0; i<this_monitoring_plugin->argc; i++) {
414 sha1_process_bytes(argv[i], strlen(argv[i]), &ctx); 415 sha256_process_bytes(argv[i], strlen(argv[i]), &ctx);
415 } 416 }
416 417
417 sha1_finish_ctx(&ctx, &result); 418 sha256_finish_ctx(&ctx, &result);
418 419
419 for (i=0; i<20; ++i) { 420 for (i=0; i<20; ++i) {
420 sprintf(&keyname[2*i], "%02x", result[i]); 421 sprintf(&keyname[2*i], "%02x", result[i]);
@@ -706,4 +707,3 @@ void np_state_write_string(time_t data_time, char *data_string) {
706 707
707 np_free(temp_file); 708 np_free(temp_file);
708} 709}
709
diff --git a/lib/utils_base.h b/lib/utils_base.h
index d7e7dff..5906550 100644
--- a/lib/utils_base.h
+++ b/lib/utils_base.h
@@ -2,7 +2,7 @@
2#define _UTILS_BASE_ 2#define _UTILS_BASE_
3/* Header file for Monitoring Plugins utils_base.c */ 3/* Header file for Monitoring Plugins utils_base.c */
4 4
5#include "sha1.h" 5#include "sha256.h"
6 6
7/* This file holds header information for thresholds - use this in preference to 7/* This file holds header information for thresholds - use this in preference to
8 individual plugin logic */ 8 individual plugin logic */
@@ -23,6 +23,7 @@ typedef struct range_struct {
23 double end; 23 double end;
24 int end_infinity; 24 int end_infinity;
25 int alert_on; /* OUTSIDE (default) or INSIDE */ 25 int alert_on; /* OUTSIDE (default) or INSIDE */
26 char* text; /* original unparsed text input */
26 } range; 27 } range;
27 28
28typedef struct thresholds_struct { 29typedef struct thresholds_struct {
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 795840d..8b8e570 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -161,7 +161,7 @@ _cmd_open (char *const *argv, int *pfd, int *pfderr)
161 } 161 }
162 162
163 /* parent picks up execution here */ 163 /* parent picks up execution here */
164 /* close childs descriptors in our address space */ 164 /* close children descriptors in our address space */
165 close (pfd[1]); 165 close (pfd[1]);
166 close (pfderr[1]); 166 close (pfderr[1]);
167 167
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index c7c9126..582d3ea 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -28,6 +28,7 @@
28 28
29#include "common.h" 29#include "common.h"
30#include "utils_disk.h" 30#include "utils_disk.h"
31#include "gl/fsusage.h"
31 32
32void 33void
33np_add_name (struct name_list **list, const char *name) 34np_add_name (struct name_list **list, const char *name)
@@ -46,9 +47,10 @@ np_add_parameter(struct parameter_list **list, const char *name)
46 struct parameter_list *current = *list; 47 struct parameter_list *current = *list;
47 struct parameter_list *new_path; 48 struct parameter_list *new_path;
48 new_path = (struct parameter_list *) malloc (sizeof *new_path); 49 new_path = (struct parameter_list *) malloc (sizeof *new_path);
49 new_path->name = (char *) name; 50 new_path->name = (char *) malloc(strlen(name) + 1);
50 new_path->best_match = NULL; 51 new_path->best_match = NULL;
51 new_path->name_next = NULL; 52 new_path->name_next = NULL;
53 new_path->name_prev = NULL;
52 new_path->freespace_bytes = NULL; 54 new_path->freespace_bytes = NULL;
53 new_path->freespace_units = NULL; 55 new_path->freespace_units = NULL;
54 new_path->freespace_percent = NULL; 56 new_path->freespace_percent = NULL;
@@ -74,13 +76,17 @@ np_add_parameter(struct parameter_list **list, const char *name)
74 new_path->dused_inodes_percent = 0; 76 new_path->dused_inodes_percent = 0;
75 new_path->dfree_inodes_percent = 0; 77 new_path->dfree_inodes_percent = 0;
76 78
79 strcpy(new_path->name, name);
80
77 if (current == NULL) { 81 if (current == NULL) {
78 *list = new_path; 82 *list = new_path;
83 new_path->name_prev = NULL;
79 } else { 84 } else {
80 while (current->name_next) { 85 while (current->name_next) {
81 current = current->name_next; 86 current = current->name_next;
82 } 87 }
83 current->name_next = new_path; 88 current->name_next = new_path;
89 new_path->name_prev = current;
84 } 90 }
85 return new_path; 91 return new_path;
86} 92}
@@ -89,6 +95,9 @@ np_add_parameter(struct parameter_list **list, const char *name)
89struct parameter_list * 95struct parameter_list *
90np_del_parameter(struct parameter_list *item, struct parameter_list *prev) 96np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
91{ 97{
98 if (item == NULL) {
99 return NULL;
100 }
92 struct parameter_list *next; 101 struct parameter_list *next;
93 102
94 if (item->name_next) 103 if (item->name_next)
@@ -96,10 +105,17 @@ np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
96 else 105 else
97 next = NULL; 106 next = NULL;
98 107
99 free(item); 108 if (next)
109 next->name_prev = prev;
110
100 if (prev) 111 if (prev)
101 prev->name_next = next; 112 prev->name_next = next;
102 113
114 if (item->name) {
115 free(item->name);
116 }
117 free(item);
118
103 return next; 119 return next;
104} 120}
105 121
@@ -127,11 +143,15 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
127 size_t name_len = strlen(d->name); 143 size_t name_len = strlen(d->name);
128 size_t best_match_len = 0; 144 size_t best_match_len = 0;
129 struct mount_entry *best_match = NULL; 145 struct mount_entry *best_match = NULL;
146 struct fs_usage fsp;
130 147
131 /* set best match if path name exactly matches a mounted device name */ 148 /* set best match if path name exactly matches a mounted device name */
132 for (me = mount_list; me; me = me->me_next) { 149 for (me = mount_list; me; me = me->me_next) {
133 if (strcmp(me->me_devname, d->name)==0) 150 if (strcmp(me->me_devname, d->name)==0) {
134 best_match = me; 151 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
152 best_match = me;
153 }
154 }
135 } 155 }
136 156
137 /* set best match by directory name if no match was found by devname */ 157 /* set best match by directory name if no match was found by devname */
@@ -142,8 +162,10 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
142 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) 162 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
143 || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) 163 || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
144 { 164 {
145 best_match = me; 165 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
146 best_match_len = len; 166 best_match = me;
167 best_match_len = len;
168 }
147 } 169 }
148 } 170 }
149 } 171 }
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index bf52e4c..3b5a45f 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -24,6 +24,7 @@ struct parameter_list
24 char *group; 24 char *group;
25 struct mount_entry *best_match; 25 struct mount_entry *best_match;
26 struct parameter_list *name_next; 26 struct parameter_list *name_next;
27 struct parameter_list *name_prev;
27 uintmax_t total, available, available_to_root, used, 28 uintmax_t total, available, available_to_root, used,
28 inodes_free, inodes_free_to_root, inodes_used, inodes_total; 29 inodes_free, inodes_free_to_root, inodes_used, inodes_total;
29 double dfree_pct, dused_pct; 30 double dfree_pct, dused_pct;
diff --git a/m4/np_mysqlclient.m4 b/m4/np_mysqlclient.m4
index 5099a02..9f533ea 100644
--- a/m4/np_mysqlclient.m4
+++ b/m4/np_mysqlclient.m4
@@ -81,7 +81,7 @@ AC_DEFUN([np_check_lib_mariadbclient],
81 ], [with_mysql=no], [$np_mysql_libs]) 81 ], [with_mysql=no], [$np_mysql_libs])
82]) 82])
83 83
84dnl Will take $1, find last occurrance of -LDIR and add DIR to LD_RUN_PATH 84dnl Will take $1, find last occurrence of -LDIR and add DIR to LD_RUN_PATH
85AC_DEFUN([np_add_to_runpath], 85AC_DEFUN([np_add_to_runpath],
86[ 86[
87 dnl Need [[ ]] so autoconf gives us just one set 87 dnl Need [[ ]] so autoconf gives us just one set
diff --git a/m4/uriparser.m4 b/m4/uriparser.m4
index dbb8a55..5113638 100644
--- a/m4/uriparser.m4
+++ b/m4/uriparser.m4
@@ -1,4 +1,4 @@
1# (this check is rougly based on and inspired libcurl.m4) 1# (this check is roughly based on and inspired libcurl.m4)
2# URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION], 2# URIPARSER_CHECK ([DEFAULT-ACTION], [MINIMUM-VERSION],
3# [ACTION-IF-YES], [ACTION-IF-NO]) 3# [ACTION-IF-YES], [ACTION-IF-NO])
4# Checks for uriparser library. DEFAULT-ACTION is the string yes or no to 4# Checks for uriparser library. DEFAULT-ACTION is the string yes or no to
diff --git a/pkg/solaris/solpkg b/pkg/solaris/solpkg
index a21176e..73b3c64 100755
--- a/pkg/solaris/solpkg
+++ b/pkg/solaris/solpkg
@@ -9,7 +9,7 @@ $pkgtrans = "/usr/bin/pkgtrans";
9$prototype = "prototype"; 9$prototype = "prototype";
10$pkginfo = "pkginfo"; 10$pkginfo = "pkginfo";
11$preinstall = "preinstall"; 11$preinstall = "preinstall";
12$egrep = "/usr/bin/egrep"; 12$egrep = "/usr/bin/grep -E";
13 13
14# Sanity check 14# Sanity check
15 15
diff --git a/plugins-root/Makefile.am b/plugins-root/Makefile.am
index 7cd2675..40aa020 100644
--- a/plugins-root/Makefile.am
+++ b/plugins-root/Makefile.am
@@ -26,7 +26,7 @@ EXTRA_PROGRAMS = pst3
26 26
27EXTRA_DIST = t pst3.c 27EXTRA_DIST = t pst3.c
28 28
29BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a 29BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
30NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS) 30NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS)
31NETLIBS = $(NETOBJS) $(SOCKETLIBS) 31NETLIBS = $(NETOBJS) $(SOCKETLIBS)
32 32
diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index ad67323..2d22619 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -229,7 +229,7 @@ struct in_addr requested_address;
229 229
230int process_arguments(int, char **); 230int process_arguments(int, char **);
231int call_getopt(int, char **); 231int call_getopt(int, char **);
232int validate_arguments(int, int); 232int validate_arguments(int);
233void print_usage(void); 233void print_usage(void);
234void print_help(void); 234void print_help(void);
235 235
@@ -470,10 +470,6 @@ int send_dhcp_discover(int sock){
470 packet_xid=random(); 470 packet_xid=random();
471 discover_packet.xid=htonl(packet_xid); 471 discover_packet.xid=htonl(packet_xid);
472 472
473 /**** WHAT THE HECK IS UP WITH THIS?!? IF I DON'T MAKE THIS CALL, ONLY ONE SERVER RESPONSE IS PROCESSED!!!! ****/
474 /* downright bizzarre... */
475 ntohl(discover_packet.xid);
476
477 /*discover_packet.secs=htons(65535);*/ 473 /*discover_packet.secs=htons(65535);*/
478 discover_packet.secs=0xFF; 474 discover_packet.secs=0xFF;
479 475
@@ -1059,8 +1055,8 @@ int process_arguments(int argc, char **argv){
1059 return ERROR; 1055 return ERROR;
1060 1056
1061 arg_index = call_getopt(argc,argv); 1057 arg_index = call_getopt(argc,argv);
1062 return validate_arguments(argc,arg_index); 1058 return validate_arguments(argc);
1063 } 1059}
1064 1060
1065 1061
1066 1062
@@ -1158,13 +1154,13 @@ int call_getopt(int argc, char **argv){
1158 } 1154 }
1159 1155
1160 1156
1161int validate_arguments(int argc, int arg_index){ 1157int validate_arguments(int argc){
1162 1158
1163 if(argc-optind > 0) 1159 if(argc - optind > 0)
1164 usage(_("Got unexpected non-option argument")); 1160 usage(_("Got unexpected non-option argument"));
1165 1161
1166 return OK; 1162 return OK;
1167 } 1163}
1168 1164
1169 1165
1170#if defined(__sun__) || defined(__solaris__) || defined(__hpux__) 1166#if defined(__sun__) || defined(__solaris__) || defined(__hpux__)
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 31eb4c6..1d47e9f 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1,39 +1,39 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_icmp plugin 3* Monitoring check_icmp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2005-2008 Monitoring Plugins Development Team 6* Copyright (c) 2005-2008 Monitoring Plugins Development Team
7* Original Author : Andreas Ericsson <ae@op5.se> 7* Original Author : Andreas Ericsson <ae@op5.se>
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_icmp plugin 11* This file contains the check_icmp plugin
12* 12*
13* Relevant RFC's: 792 (ICMP), 791 (IP) 13* Relevant RFC's: 792 (ICMP), 791 (IP)
14* 14*
15* This program was modeled somewhat after the check_icmp program, 15* This program was modeled somewhat after the check_icmp program,
16* which was in turn a hack of fping (www.fping.org) but has been 16* which was in turn a hack of fping (www.fping.org) but has been
17* completely rewritten since to generate higher precision rta values, 17* completely rewritten since to generate higher precision rta values,
18* and support several different modes as well as setting ttl to control. 18* and support several different modes as well as setting ttl to control.
19* redundant routes. The only remainders of fping is currently a few 19* redundant routes. The only remainders of fping is currently a few
20* function names. 20* function names.
21* 21*
22* 22*
23* This program is free software: you can redistribute it and/or modify 23* This program is free software: you can redistribute it and/or modify
24* it under the terms of the GNU General Public License as published by 24* it under the terms of the GNU General Public License as published by
25* the Free Software Foundation, either version 3 of the License, or 25* the Free Software Foundation, either version 3 of the License, or
26* (at your option) any later version. 26* (at your option) any later version.
27* 27*
28* This program is distributed in the hope that it will be useful, 28* This program is distributed in the hope that it will be useful,
29* but WITHOUT ANY WARRANTY; without even the implied warranty of 29* but WITHOUT ANY WARRANTY; without even the implied warranty of
30* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 30* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31* GNU General Public License for more details. 31* GNU General Public License for more details.
32* 32*
33* You should have received a copy of the GNU General Public License 33* You should have received a copy of the GNU General Public License
34* along with this program. If not, see <http://www.gnu.org/licenses/>. 34* along with this program. If not, see <http://www.gnu.org/licenses/>.
35* 35*
36* 36*
37*****************************************************************************/ 37*****************************************************************************/
38 38
39/* progname may change */ 39/* progname may change */
@@ -50,19 +50,12 @@ const char *email = "devel@monitoring-plugins.org";
50#if HAVE_SYS_SOCKIO_H 50#if HAVE_SYS_SOCKIO_H
51#include <sys/sockio.h> 51#include <sys/sockio.h>
52#endif 52#endif
53#include <sys/ioctl.h> 53
54#include <sys/time.h> 54#include <sys/time.h>
55#include <sys/types.h>
56#include <stdio.h>
57#include <stdlib.h>
58#include <stdarg.h>
59#include <unistd.h>
60#include <stddef.h>
61#include <errno.h> 55#include <errno.h>
62#include <string.h> 56#include <signal.h>
63#include <ctype.h> 57#include <ctype.h>
64#include <netdb.h> 58#include <float.h>
65#include <sys/socket.h>
66#include <net/if.h> 59#include <net/if.h>
67#include <netinet/in_systm.h> 60#include <netinet/in_systm.h>
68#include <netinet/in.h> 61#include <netinet/in.h>
@@ -71,8 +64,6 @@ const char *email = "devel@monitoring-plugins.org";
71#include <netinet/ip_icmp.h> 64#include <netinet/ip_icmp.h>
72#include <netinet/icmp6.h> 65#include <netinet/icmp6.h>
73#include <arpa/inet.h> 66#include <arpa/inet.h>
74#include <signal.h>
75#include <float.h>
76 67
77 68
78/** sometimes undefined system macros (quite a few, actually) **/ 69/** sometimes undefined system macros (quite a few, actually) **/
@@ -105,10 +96,6 @@ const char *email = "devel@monitoring-plugins.org";
105# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 96# define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
106#endif 97#endif
107 98
108#ifndef DBL_MAX
109# define DBL_MAX 9.9999999999e999
110#endif
111
112typedef unsigned short range_t; /* type for get_range() -- unimplemented */ 99typedef unsigned short range_t; /* type for get_range() -- unimplemented */
113 100
114typedef struct rta_host { 101typedef struct rta_host {
@@ -207,7 +194,7 @@ static int add_target(char *);
207static int add_target_ip(char *, struct sockaddr_storage *); 194static int add_target_ip(char *, struct sockaddr_storage *);
208static int handle_random_icmp(unsigned char *, struct sockaddr_storage *); 195static int handle_random_icmp(unsigned char *, struct sockaddr_storage *);
209static void parse_address(struct sockaddr_storage *, char *, int); 196static void parse_address(struct sockaddr_storage *, char *, int);
210static unsigned short icmp_checksum(unsigned short *, int); 197static unsigned short icmp_checksum(uint16_t *, size_t);
211static void finish(int); 198static void finish(int);
212static void crash(const char *, ...); 199static void crash(const char *, ...);
213 200
@@ -223,7 +210,7 @@ static int mode, protocols, sockets, debug = 0, timeout = 10;
223static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE; 210static unsigned short icmp_data_size = DEFAULT_PING_DATA_SIZE;
224static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN; 211static unsigned short icmp_pkt_size = DEFAULT_PING_DATA_SIZE + ICMP_MINLEN;
225 212
226static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0; 213static unsigned int icmp_sent = 0, icmp_recv = 0, icmp_lost = 0, ttl = 0;
227#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost)) 214#define icmp_pkts_en_route (icmp_sent - (icmp_recv + icmp_lost))
228static unsigned short targets_down = 0, targets = 0, packets = 0; 215static unsigned short targets_down = 0, targets = 0, packets = 0;
229#define targets_alive (targets - targets_down) 216#define targets_alive (targets - targets_down)
@@ -233,7 +220,6 @@ static pid_t pid;
233static struct timezone tz; 220static struct timezone tz;
234static struct timeval prog_start; 221static struct timeval prog_start;
235static unsigned long long max_completion_time = 0; 222static unsigned long long max_completion_time = 0;
236static unsigned char ttl = 0; /* outgoing ttl */
237static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */ 223static unsigned int warn_down = 1, crit_down = 1; /* host down threshold values */
238static int min_hosts_alive = -1; 224static int min_hosts_alive = -1;
239float pkt_backoff_factor = 1.5; 225float pkt_backoff_factor = 1.5;
@@ -288,7 +274,7 @@ get_icmp_error_msg(unsigned char icmp_type, unsigned char icmp_code)
288 break; 274 break;
289 275
290 case ICMP_TIMXCEED: 276 case ICMP_TIMXCEED:
291 /* really 'out of reach', or non-existant host behind a router serving 277 /* really 'out of reach', or non-existent host behind a router serving
292 * two different subnets */ 278 * two different subnets */
293 switch(icmp_code) { 279 switch(icmp_code) {
294 case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break; 280 case ICMP_TIMXCEED_INTRANS: msg = "Time to live exceeded in transit"; break;
@@ -410,6 +396,7 @@ main(int argc, char **argv)
410#ifdef SO_TIMESTAMP 396#ifdef SO_TIMESTAMP
411 int on = 1; 397 int on = 1;
412#endif 398#endif
399 char *source_ip = NULL;
413 char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64"; 400 char * opts_str = "vhVw:c:n:p:t:H:s:i:b:I:l:m:64";
414 401
415 setlocale (LC_ALL, ""); 402 setlocale (LC_ALL, "");
@@ -461,10 +448,17 @@ main(int argc, char **argv)
461 packets = 5; 448 packets = 5;
462 } 449 }
463 450
451 /* support "--help" and "--version" */
452 if(argc == 2) {
453 if(!strcmp(argv[1], "--help"))
454 strcpy(argv[1], "-h");
455 if(!strcmp(argv[1], "--version"))
456 strcpy(argv[1], "-V");
457 }
458
464 /* Parse protocol arguments first */ 459 /* Parse protocol arguments first */
465 for(i = 1; i < argc; i++) { 460 for(i = 1; i < argc; i++) {
466 while((arg = getopt(argc, argv, opts_str)) != EOF) { 461 while((arg = getopt(argc, argv, opts_str)) != EOF) {
467 unsigned short size;
468 switch(arg) { 462 switch(arg) {
469 case '4': 463 case '4':
470 if (address_family != -1) 464 if (address_family != -1)
@@ -487,10 +481,10 @@ main(int argc, char **argv)
487 /* Reset argument scanning */ 481 /* Reset argument scanning */
488 optind = 1; 482 optind = 1;
489 483
484 unsigned short size;
490 /* parse the arguments */ 485 /* parse the arguments */
491 for(i = 1; i < argc; i++) { 486 for(i = 1; i < argc; i++) {
492 while((arg = getopt(argc, argv, opts_str)) != EOF) { 487 while((arg = getopt(argc, argv, opts_str)) != EOF) {
493 unsigned short size;
494 switch(arg) { 488 switch(arg) {
495 case 'v': 489 case 'v':
496 debug++; 490 debug++;
@@ -502,7 +496,7 @@ main(int argc, char **argv)
502 icmp_data_size = size; 496 icmp_data_size = size;
503 icmp_pkt_size = size + ICMP_MINLEN; 497 icmp_pkt_size = size + ICMP_MINLEN;
504 } else 498 } else
505 usage_va("ICMP data length must be between: %d and %d", 499 usage_va("ICMP data length must be between: %lu and %lu",
506 sizeof(struct icmp) + sizeof(struct icmp_ping_data), 500 sizeof(struct icmp) + sizeof(struct icmp_ping_data),
507 MAX_PING_DATA - 1); 501 MAX_PING_DATA - 1);
508 break; 502 break;
@@ -530,7 +524,7 @@ main(int argc, char **argv)
530 add_target(optarg); 524 add_target(optarg);
531 break; 525 break;
532 case 'l': 526 case 'l':
533 ttl = (unsigned char)strtoul(optarg, NULL, 0); 527 ttl = (int)strtoul(optarg, NULL, 0);
534 break; 528 break;
535 case 'm': 529 case 'm':
536 min_hosts_alive = (int)strtoul(optarg, NULL, 0); 530 min_hosts_alive = (int)strtoul(optarg, NULL, 0);
@@ -542,7 +536,7 @@ main(int argc, char **argv)
542 } 536 }
543 break; 537 break;
544 case 's': /* specify source IP address */ 538 case 's': /* specify source IP address */
545 set_source_ip(optarg); 539 source_ip = optarg;
546 break; 540 break;
547 case 'V': /* version */ 541 case 'V': /* version */
548 print_revision (progname, NP_VERSION); 542 print_revision (progname, NP_VERSION);
@@ -566,14 +560,6 @@ main(int argc, char **argv)
566 /* Parse extra opts if any */ 560 /* Parse extra opts if any */
567 argv=np_extra_opts(&argc, argv, progname); 561 argv=np_extra_opts(&argc, argv, progname);
568 562
569 /* support "--help" and "--version" */
570 if(argc == 2) {
571 if(!strcmp(argv[1], "--help"))
572 strcpy(argv[1], "-h");
573 if(!strcmp(argv[1], "--version"))
574 strcpy(argv[1], "-V");
575 }
576
577 argv = &argv[optind]; 563 argv = &argv[optind];
578 while(*argv) { 564 while(*argv) {
579 add_target(*argv); 565 add_target(*argv);
@@ -597,6 +583,8 @@ main(int argc, char **argv)
597 sockets |= HAVE_ICMP; 583 sockets |= HAVE_ICMP;
598 else icmp_sockerrno = errno; 584 else icmp_sockerrno = errno;
599 585
586 if( source_ip )
587 set_source_ip(source_ip);
600 588
601#ifdef SO_TIMESTAMP 589#ifdef SO_TIMESTAMP
602 if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) 590 if(setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on)))
@@ -717,7 +705,7 @@ main(int argc, char **argv)
717static void 705static void
718run_checks() 706run_checks()
719{ 707{
720 u_int i, t, result; 708 u_int i, t;
721 u_int final_wait, time_passed; 709 u_int final_wait, time_passed;
722 710
723 /* this loop might actually violate the pkt_interval or target_interval 711 /* this loop might actually violate the pkt_interval or target_interval
@@ -735,9 +723,9 @@ run_checks()
735 723
736 /* we're still in the game, so send next packet */ 724 /* we're still in the game, so send next packet */
737 (void)send_icmp_ping(icmp_sock, table[t]); 725 (void)send_icmp_ping(icmp_sock, table[t]);
738 result = wait_for_reply(icmp_sock, target_interval); 726 wait_for_reply(icmp_sock, target_interval);
739 } 727 }
740 result = wait_for_reply(icmp_sock, pkt_interval * targets); 728 wait_for_reply(icmp_sock, pkt_interval * targets);
741 } 729 }
742 730
743 if(icmp_pkts_en_route && targets_alive) { 731 if(icmp_pkts_en_route && targets_alive) {
@@ -757,7 +745,7 @@ run_checks()
757 * haven't yet */ 745 * haven't yet */
758 if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n", 746 if(debug) printf("Waiting for %u micro-seconds (%0.3f msecs)\n",
759 final_wait, (float)final_wait / 1000); 747 final_wait, (float)final_wait / 1000);
760 result = wait_for_reply(icmp_sock, final_wait); 748 wait_for_reply(icmp_sock, final_wait);
761 } 749 }
762} 750}
763 751
@@ -776,7 +764,7 @@ static int
776wait_for_reply(int sock, u_int t) 764wait_for_reply(int sock, u_int t)
777{ 765{
778 int n, hlen; 766 int n, hlen;
779 static unsigned char buf[4096]; 767 static unsigned char buf[65536];
780 struct sockaddr_storage resp_addr; 768 struct sockaddr_storage resp_addr;
781 union ip_hdr *ip; 769 union ip_hdr *ip;
782 union icmp_packet packet; 770 union icmp_packet packet;
@@ -913,15 +901,33 @@ wait_for_reply(int sock, u_int t)
913 if(debug) { 901 if(debug) {
914 char address[INET6_ADDRSTRLEN]; 902 char address[INET6_ADDRSTRLEN];
915 parse_address(&resp_addr, address, sizeof(address)); 903 parse_address(&resp_addr, address, sizeof(address));
916 printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n", 904
917 (float)tdiff / 1000, address, 905 switch(address_family) {
918 ttl, ip->ip.ip_ttl, (float)host->rtmax / 1000, (float)host->rtmin / 1000); 906 case AF_INET: {
907 printf("%0.3f ms rtt from %s, outgoing ttl: %u, incoming ttl: %u, max: %0.3f, min: %0.3f\n",
908 (float)tdiff / 1000,
909 address,
910 ttl,
911 ip->ip.ip_ttl,
912 (float)host->rtmax / 1000,
913 (float)host->rtmin / 1000);
914 break;
915 };
916 case AF_INET6: {
917 printf("%0.3f ms rtt from %s, outgoing ttl: %u, max: %0.3f, min: %0.3f\n",
918 (float)tdiff / 1000,
919 address,
920 ttl,
921 (float)host->rtmax / 1000,
922 (float)host->rtmin / 1000);
923 };
924 }
919 } 925 }
920 926
921 /* if we're in hostcheck mode, exit with limited printouts */ 927 /* if we're in hostcheck mode, exit with limited printouts */
922 if(mode == MODE_HOSTCHECK) { 928 if(mode == MODE_HOSTCHECK) {
923 printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|" 929 printf("OK - %s responds to ICMP. Packet %u, rta %0.3fms|"
924 "pkt=%u;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n", 930 "pkt=%u;;;0;%u rta=%0.3f;%0.3f;%0.3f;;\n",
925 host->name, icmp_recv, (float)tdiff / 1000, 931 host->name, icmp_recv, (float)tdiff / 1000,
926 icmp_recv, packets, (float)tdiff / 1000, 932 icmp_recv, packets, (float)tdiff / 1000,
927 (float)warn.rta / 1000, (float)crit.rta / 1000); 933 (float)warn.rta / 1000, (float)crit.rta / 1000);
@@ -938,6 +944,7 @@ static int
938send_icmp_ping(int sock, struct rta_host *host) 944send_icmp_ping(int sock, struct rta_host *host)
939{ 945{
940 long int len; 946 long int len;
947 size_t addrlen;
941 struct icmp_ping_data data; 948 struct icmp_ping_data data;
942 struct msghdr hdr; 949 struct msghdr hdr;
943 struct iovec iov; 950 struct iovec iov;
@@ -969,6 +976,7 @@ send_icmp_ping(int sock, struct rta_host *host)
969 976
970 if (address_family == AF_INET) { 977 if (address_family == AF_INET) {
971 struct icmp *icp = (struct icmp*)buf; 978 struct icmp *icp = (struct icmp*)buf;
979 addrlen = sizeof(struct sockaddr_in);
972 980
973 memcpy(&icp->icmp_data, &data, sizeof(data)); 981 memcpy(&icp->icmp_data, &data, sizeof(data));
974 982
@@ -977,7 +985,7 @@ send_icmp_ping(int sock, struct rta_host *host)
977 icp->icmp_cksum = 0; 985 icp->icmp_cksum = 0;
978 icp->icmp_id = htons(pid); 986 icp->icmp_id = htons(pid);
979 icp->icmp_seq = htons(host->id++); 987 icp->icmp_seq = htons(host->id++);
980 icp->icmp_cksum = icmp_checksum((unsigned short*)buf, icmp_pkt_size); 988 icp->icmp_cksum = icmp_checksum((uint16_t*)buf, (size_t)icmp_pkt_size);
981 989
982 if (debug > 2) 990 if (debug > 2)
983 printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n", 991 printf("Sending ICMP echo-request of len %lu, id %u, seq %u, cksum 0x%X to host %s\n",
@@ -985,7 +993,10 @@ send_icmp_ping(int sock, struct rta_host *host)
985 } 993 }
986 else { 994 else {
987 struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf; 995 struct icmp6_hdr *icp6 = (struct icmp6_hdr*)buf;
996 addrlen = sizeof(struct sockaddr_in6);
997
988 memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data)); 998 memcpy(&icp6->icmp6_dataun.icmp6_un_data8[4], &data, sizeof(data));
999
989 icp6->icmp6_type = ICMP6_ECHO_REQUEST; 1000 icp6->icmp6_type = ICMP6_ECHO_REQUEST;
990 icp6->icmp6_code = 0; 1001 icp6->icmp6_code = 0;
991 icp6->icmp6_cksum = 0; 1002 icp6->icmp6_cksum = 0;
@@ -1006,7 +1017,7 @@ send_icmp_ping(int sock, struct rta_host *host)
1006 1017
1007 memset(&hdr, 0, sizeof(hdr)); 1018 memset(&hdr, 0, sizeof(hdr));
1008 hdr.msg_name = (struct sockaddr *)&host->saddr_in; 1019 hdr.msg_name = (struct sockaddr *)&host->saddr_in;
1009 hdr.msg_namelen = sizeof(struct sockaddr_storage); 1020 hdr.msg_namelen = addrlen;
1010 hdr.msg_iov = &iov; 1021 hdr.msg_iov = &iov;
1011 hdr.msg_iovlen = 1; 1022 hdr.msg_iovlen = 1;
1012 1023
@@ -1210,7 +1221,7 @@ finish(int sig)
1210 host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, 1221 host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000,
1211 (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl, 1222 (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl,
1212 (targets > 1) ? host->name : "", (float)host->rtmax / 1000, 1223 (targets > 1) ? host->name : "", (float)host->rtmax / 1000,
1213 (targets > 1) ? host->name : "", (host->rtmin < DBL_MAX) ? (float)host->rtmin / 1000 : (float)0); 1224 (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0);
1214 1225
1215 host = host->next; 1226 host = host->next;
1216 } 1227 }
@@ -1293,7 +1304,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in)
1293 if(!host) { 1304 if(!host) {
1294 char straddr[INET6_ADDRSTRLEN]; 1305 char straddr[INET6_ADDRSTRLEN];
1295 parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr)); 1306 parse_address((struct sockaddr_storage*)&in, straddr, sizeof(straddr));
1296 crash("add_target_ip(%s, %s): malloc(%d) failed", 1307 crash("add_target_ip(%s, %s): malloc(%lu) failed",
1297 arg, straddr, sizeof(struct rta_host)); 1308 arg, straddr, sizeof(struct rta_host));
1298 } 1309 }
1299 memset(host, 0, sizeof(struct rta_host)); 1310 memset(host, 0, sizeof(struct rta_host));
@@ -1313,7 +1324,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in)
1313 memcpy(host_sin6->sin6_addr.s6_addr, sin6->sin6_addr.s6_addr, sizeof host_sin6->sin6_addr.s6_addr); 1324 memcpy(host_sin6->sin6_addr.s6_addr, sin6->sin6_addr.s6_addr, sizeof host_sin6->sin6_addr.s6_addr);
1314 } 1325 }
1315 1326
1316 host->rtmin = DBL_MAX; 1327 host->rtmin = INFINITY;
1317 1328
1318 if(!list) list = cursor = host; 1329 if(!list) list = cursor = host;
1319 else cursor->next = host; 1330 else cursor->next = host;
@@ -1328,7 +1339,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in)
1328static int 1339static int
1329add_target(char *arg) 1340add_target(char *arg)
1330{ 1341{
1331 int error, result; 1342 int error, result = -1;
1332 struct sockaddr_storage ip; 1343 struct sockaddr_storage ip;
1333 struct addrinfo hints, *res, *p; 1344 struct addrinfo hints, *res, *p;
1334 struct sockaddr_in *sin; 1345 struct sockaddr_in *sin;
@@ -1419,20 +1430,26 @@ set_source_ip(char *arg)
1419static in_addr_t 1430static in_addr_t
1420get_ip_address(const char *ifname) 1431get_ip_address(const char *ifname)
1421{ 1432{
1433 // TODO: Rewrite this so the function return an error and we exit somewhere else
1434 struct sockaddr_in ip;
1435 ip.sin_addr.s_addr = 0; // Fake initialization to make compiler happy
1422#if defined(SIOCGIFADDR) 1436#if defined(SIOCGIFADDR)
1423 struct ifreq ifr; 1437 struct ifreq ifr;
1424 struct sockaddr_in ip;
1425 1438
1426 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); 1439 strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
1440
1427 ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; 1441 ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
1442
1428 if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) 1443 if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1)
1429 crash("Cannot determine IP address of interface %s", ifname); 1444 crash("Cannot determine IP address of interface %s", ifname);
1445
1430 memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); 1446 memcpy(&ip, &ifr.ifr_addr, sizeof(ip));
1431 return ip.sin_addr.s_addr;
1432#else 1447#else
1448 (void) ifname;
1433 errno = 0; 1449 errno = 0;
1434 crash("Cannot get interface IP address on this platform."); 1450 crash("Cannot get interface IP address on this platform.");
1435#endif 1451#endif
1452 return ip.sin_addr.s_addr;
1436} 1453}
1437 1454
1438/* 1455/*
@@ -1514,18 +1531,19 @@ get_threshold(char *str, threshold *th)
1514} 1531}
1515 1532
1516unsigned short 1533unsigned short
1517icmp_checksum(unsigned short *p, int n) 1534icmp_checksum(uint16_t *p, size_t n)
1518{ 1535{
1519 unsigned short cksum; 1536 unsigned short cksum;
1520 long sum = 0; 1537 long sum = 0;
1521 1538
1522 while(n > 2) { 1539 /* sizeof(uint16_t) == 2 */
1523 sum += *p++; 1540 while(n >= 2) {
1524 n -= sizeof(unsigned short); 1541 sum += *(p++);
1542 n -= 2;
1525 } 1543 }
1526 1544
1527 /* mop up the occasional odd byte */ 1545 /* mop up the occasional odd byte */
1528 if(n == 1) sum += (unsigned char)*p; 1546 if(n == 1) sum += *((uint8_t *)p -1);
1529 1547
1530 sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */ 1548 sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
1531 sum += (sum >> 16); /* add carry */ 1549 sum += (sum >> 16); /* add carry */
diff --git a/plugins-root/pst3.c b/plugins-root/pst3.c
index c3589f0..1f69f3a 100644
--- a/plugins-root/pst3.c
+++ b/plugins-root/pst3.c
@@ -257,6 +257,6 @@ void usage() {
257 printf("\tRSS - Real memory usage (kilobytes)\n"); 257 printf("\tRSS - Real memory usage (kilobytes)\n");
258 printf("\t%%CPU - CPU usage\n"); 258 printf("\t%%CPU - CPU usage\n");
259 printf("\tCOMMAND - Command being run\n"); 259 printf("\tCOMMAND - Command being run\n");
260 printf("\tARGS - Full command line with arguements\n"); 260 printf("\tARGS - Full command line with arguments\n");
261 return; 261 return;
262} 262}
diff --git a/plugins-root/t/check_icmp.t b/plugins-root/t/check_icmp.t
index e043d4e..96addd3 100644
--- a/plugins-root/t/check_icmp.t
+++ b/plugins-root/t/check_icmp.t
@@ -12,7 +12,7 @@ my $allow_sudo = getTestParameter( "NP_ALLOW_SUDO",
12 "no" ); 12 "no" );
13 13
14if ($allow_sudo eq "yes" or $> == 0) { 14if ($allow_sudo eq "yes" or $> == 0) {
15 plan tests => 16; 15 plan tests => 20;
16} else { 16} else {
17 plan skip_all => "Need sudo to test check_icmp"; 17 plan skip_all => "Need sudo to test check_icmp";
18} 18}
@@ -83,3 +83,14 @@ $res = NPTest->testCmd(
83is( $res->return_code, 2, "One of two host nonresponsive - two required" ); 83is( $res->return_code, 2, "One of two host nonresponsive - two required" );
84like( $res->output, $failureOutput, "Output OK" ); 84like( $res->output, $failureOutput, "Output OK" );
85 85
86$res = NPTest->testCmd(
87 "$sudo ./check_icmp -H $host_responsive -s 127.0.15.15 -w 10000ms,100% -c 10000ms,100% -n 1 -m 2"
88 );
89is( $res->return_code, 0, "IPv4 source_ip accepted" );
90like( $res->output, $successOutput, "Output OK" );
91
92$res = NPTest->testCmd(
93 "$sudo ./check_icmp -H $host_responsive -b 65507"
94 );
95is( $res->return_code, 0, "Try max packet size" );
96like( $res->output, $successOutput, "Output OK - Didn't overflow" );
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am
index 088a445..7879791 100644
--- a/plugins-scripts/Makefile.am
+++ b/plugins-scripts/Makefile.am
@@ -16,13 +16,13 @@ VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/
16libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ 16libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
17 check_log check_oracle check_rpc check_sensors check_wave \ 17 check_log check_oracle check_rpc check_sensors check_wave \
18 check_ifstatus check_ifoperstatus check_mailq check_file_age \ 18 check_ifstatus check_ifoperstatus check_mailq check_file_age \
19 check_uptime \ 19 check_uptime check_mssql \
20 utils.sh utils.pm 20 utils.sh utils.pm
21 21
22EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ 22EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
23 check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \ 23 check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
24 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \ 24 check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
25 check_uptime.pl \ 25 check_uptime.pl check_mssql.pl \
26 utils.sh.in utils.pm.in t 26 utils.sh.in utils.pm.in t
27 27
28EDIT = sed \ 28EDIT = sed \
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl
index 05b9920..531625c 100755
--- a/plugins-scripts/check_breeze.pl
+++ b/plugins-scripts/check_breeze.pl
@@ -14,8 +14,9 @@ sub print_help ();
14sub print_usage (); 14sub print_usage ();
15 15
16$ENV{'PATH'}='@TRUSTED_PATH@'; 16$ENV{'PATH'}='@TRUSTED_PATH@';
17$ENV{'BASH_ENV'}=''; 17$ENV{'BASH_ENV'}='';
18$ENV{'ENV'}=''; 18$ENV{'ENV'}='';
19$ENV{'CDPATH'}='';
19 20
20Getopt::Long::Configure('bundling'); 21Getopt::Long::Configure('bundling');
21GetOptions 22GetOptions
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 28c49e8..f4d33a7 100755..100644
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -22,13 +22,13 @@ require 5.004;
22use POSIX qw(setsid); 22use POSIX qw(setsid);
23use strict; 23use strict;
24use Getopt::Long; 24use Getopt::Long;
25use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose); 25use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $opt_t $verbose);
26use vars qw($PROGNAME); 26use vars qw($PROGNAME);
27use FindBin; 27use FindBin;
28use lib "$FindBin::Bin"; 28use lib "$FindBin::Bin";
29use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); 29use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
30 30
31# make us session leader which makes all childs exit if we do 31# make us session leader which makes all children exit if we do
32setsid; 32setsid;
33 33
34sub print_help (); 34sub print_help ();
@@ -43,6 +43,7 @@ $ENV{'ENV'}='';
43Getopt::Long::Configure('bundling'); 43Getopt::Long::Configure('bundling');
44GetOptions 44GetOptions
45 ("v" => \$verbose, "verbose" => \$verbose, 45 ("v" => \$verbose, "verbose" => \$verbose,
46 "t=i" => \$opt_t, "timeout=i" => \$opt_t,
46 "P=s" => \$opt_P, "port=s" => \$opt_P, 47 "P=s" => \$opt_P, "port=s" => \$opt_P,
47 "V" => \$opt_V, "version" => \$opt_V, 48 "V" => \$opt_V, "version" => \$opt_V,
48 "h" => \$opt_h, "help" => \$opt_h, 49 "h" => \$opt_h, "help" => \$opt_h,
@@ -53,7 +54,8 @@ GetOptions
53 "s=s" => \$opt_s, "share=s" => \$opt_s, 54 "s=s" => \$opt_s, "share=s" => \$opt_s,
54 "W=s" => \$opt_W, "workgroup=s" => \$opt_W, 55 "W=s" => \$opt_W, "workgroup=s" => \$opt_W,
55 "H=s" => \$opt_H, "hostname=s" => \$opt_H, 56 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
56 "a=s" => \$opt_a, "address=s" => \$opt_a); 57 "a=s" => \$opt_a, "address=s" => \$opt_a,
58 "C=s" => \$opt_C, "configfile=s" => \$opt_C);
57 59
58if ($opt_V) { 60if ($opt_V) {
59 print_revision($PROGNAME,'@NP_VERSION@'); #' 61 print_revision($PROGNAME,'@NP_VERSION@'); #'
@@ -91,6 +93,12 @@ my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
91my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); 93my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
92($crit) || usage("Invalid critical threshold: $opt_c\n"); 94($crit) || usage("Invalid critical threshold: $opt_c\n");
93 95
96($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = "");
97my $configfile = $opt_C if ($opt_C);
98usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile);
99
100if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; }
101
94# Execute the given command line and return anything it writes to STDOUT and/or 102# Execute the given command line and return anything it writes to STDOUT and/or
95# STDERR. (This might be useful for other plugins, too, so it should possibly 103# STDERR. (This might be useful for other plugins, too, so it should possibly
96# be moved to utils.pm.) 104# be moved to utils.pm.)
@@ -193,6 +201,7 @@ my @cmd = (
193 defined($workgroup) ? ("-W", $workgroup) : (), 201 defined($workgroup) ? ("-W", $workgroup) : (),
194 defined($address) ? ("-I", $address) : (), 202 defined($address) ? ("-I", $address) : (),
195 defined($opt_P) ? ("-p", $opt_P) : (), 203 defined($opt_P) ? ("-p", $opt_P) : (),
204 defined($configfile) ? ("-s", $configfile) : (),
196 "-c", "du" 205 "-c", "du"
197); 206);
198 207
@@ -292,7 +301,8 @@ exit $ERRORS{$state};
292 301
293sub print_usage () { 302sub print_usage () {
294 print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> 303 print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
295 -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n"; 304 -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>] [-t timeout]
305 [-C <configfile>]\n";
296} 306}
297 307
298sub print_help () { 308sub print_help () {
@@ -318,11 +328,14 @@ Perl Check SMB Disk plugin for monitoring
318 Password to log in to server. (Defaults to an empty password) 328 Password to log in to server. (Defaults to an empty password)
319-w, --warning=INTEGER or INTEGER[kMG] 329-w, --warning=INTEGER or INTEGER[kMG]
320 Percent of used space at which a warning will be generated (Default: 85%) 330 Percent of used space at which a warning will be generated (Default: 85%)
321
322-c, --critical=INTEGER or INTEGER[kMG] 331-c, --critical=INTEGER or INTEGER[kMG]
323 Percent of used space at which a critical will be generated (Defaults: 95%) 332 Percent of used space at which a critical will be generated (Defaults: 95%)
333-t, --timeout=INTEGER
334 Seconds before connection times out (Default: 15)
324-P, --port=INTEGER 335-P, --port=INTEGER
325 Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) 336 Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
337-C, --configfile=STRING
338 Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation)
326 339
327 If thresholds are followed by either a k, M, or G then check to see if that 340 If thresholds are followed by either a k, M, or G then check to see if that
328 much disk space is available (kilobytes, Megabytes, Gigabytes) 341 much disk space is available (kilobytes, Megabytes, Gigabytes)
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl
index 01b854a..26281dd 100755
--- a/plugins-scripts/check_file_age.pl
+++ b/plugins-scripts/check_file_age.pl
@@ -147,7 +147,7 @@ sub print_help () {
147 print "\n"; 147 print "\n";
148 print " -i | --ignore-missing : return OK if the file does not exist\n"; 148 print " -i | --ignore-missing : return OK if the file does not exist\n";
149 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; 149 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
150 print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n\n"; 150 print " <size> File must be at least this many bytes long (default: file size is ignored (0 bytes))\n\n";
151 print " Both <secs> and <size> can specify a range using the standard plugin syntax\n"; 151 print " Both <secs> and <size> can specify a range using the standard plugin syntax\n";
152 print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n"; 152 print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n";
153 print " then all warning and critical arguments will be interpreted as ranges.\n"; 153 print " then all warning and critical arguments will be interpreted as ranges.\n";
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index c190ce9..e335cda 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -134,7 +134,7 @@ if (defined $ifdescr || defined $iftype) {
134 } 134 }
135 if ($status==0) { 135 if ($status==0) {
136 $state = "UNKNOWN"; 136 $state = "UNKNOWN";
137 printf "$state: could not retrive ifdescr/iftype snmpkey - $status-$snmpkey\n"; 137 printf "$state: could not retrieve ifdescr/iftype snmpkey - $status-$snmpkey\n";
138 $session->close; 138 $session->close;
139 exit $ERRORS{$state}; 139 exit $ERRORS{$state};
140 } 140 }
@@ -187,7 +187,7 @@ if (defined $ifXTable) {
187 $name = $response->{$snmpIfDescr} ; 187 $name = $response->{$snmpIfDescr} ;
188} 188}
189 189
190## if AdminStatus is down - some one made a consious effort to change config 190## if AdminStatus is down - some one made a conscious effort to change config
191## 191##
192if ( not ($response->{$snmpIfAdminStatus} == 1) ) { 192if ( not ($response->{$snmpIfAdminStatus} == 1) ) {
193 $answer = "Interface $name (index $snmpkey) is administratively down."; 193 $answer = "Interface $name (index $snmpkey) is administratively down.";
@@ -286,7 +286,7 @@ sub print_usage() {
286 printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n"; 286 printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n";
287 printf "Copyright (C) 2000 Christoph Kron\n"; 287 printf "Copyright (C) 2000 Christoph Kron\n";
288 printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n"; 288 printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n";
289 printf "This programm is licensed under the terms of the "; 289 printf "This program is licensed under the terms of the ";
290 printf "GNU General Public License\n(check source code for details)\n"; 290 printf "GNU General Public License\n(check source code for details)\n";
291 printf "\n\n"; 291 printf "\n\n";
292} 292}
@@ -424,7 +424,7 @@ sub process_arguments() {
424 if (defined $seclevel && defined $secname) { 424 if (defined $seclevel && defined $secname) {
425 $session_opts{'-username'} = $secname; 425 $session_opts{'-username'} = $secname;
426 426
427 # Must define a security level even though defualt is noAuthNoPriv 427 # Must define a security level even though default is noAuthNoPriv
428 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { 428 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) {
429 usage("Must define a valid security level even though default is noAuthNoPriv"); 429 usage("Must define a valid security level even though default is noAuthNoPriv");
430 } 430 }
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 32984e5..38b87fc 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -354,7 +354,7 @@ sub process_arguments() {
354 if (defined $seclevel && defined $secname) { 354 if (defined $seclevel && defined $secname) {
355 $session_opts{'-username'} = $secname; 355 $session_opts{'-username'} = $secname;
356 356
357 # Must define a security level even though defualt is noAuthNoPriv 357 # Must define a security level even though default is noAuthNoPriv
358 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { 358 unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) {
359 usage("Must define a valid security level even though default is noAuthNoPriv"); 359 usage("Must define a valid security level even though default is noAuthNoPriv");
360 } 360 }
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index d869ae7..84f2022 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/check_ircd.pl
@@ -60,7 +60,7 @@ sub print_usage ();
60sub connection ($$$$); 60sub connection ($$$$);
61sub bindRemote ($$); 61sub bindRemote ($$);
62 62
63# -------------------------------------------------------------[ Enviroment ]-- 63# -------------------------------------------------------------[ Environment ]--
64 64
65$ENV{'PATH'}='@TRUSTED_PATH@'; 65$ENV{'PATH'}='@TRUSTED_PATH@';
66$ENV{'BASH_ENV'}=''; 66$ENV{'BASH_ENV'}='';
@@ -208,7 +208,7 @@ MAIN:
208 208
209 # Just in case of problems, let's not hang the monitoring system 209 # Just in case of problems, let's not hang the monitoring system
210 $SIG{'ALRM'} = sub { 210 $SIG{'ALRM'} = sub {
211 print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; 211 print "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
212 exit $ERRORS{"UNKNOWN"}; 212 exit $ERRORS{"UNKNOWN"};
213 }; 213 };
214 214
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index d28c8d0..8ecdd31 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -1,8 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# Log file pattern detector plugin for monitoring 3# Log file pattern detector plugin for monitoring
4# Written by Ethan Galstad (nagios@nagios.org) 4# Written originally by Ethan Galstad (nagios@nagios.org)
5# Last Modified: 07-31-1999
6# 5#
7# Usage: ./check_log <log_file> <old_log_file> <pattern> 6# Usage: ./check_log <log_file> <old_log_file> <pattern>
8# 7#
@@ -19,7 +18,7 @@
19# On the first run of the plugin, it will return an OK state with a message 18# On the first run of the plugin, it will return an OK state with a message
20# of "Log check data initialized". On successive runs, it will return an OK 19# of "Log check data initialized". On successive runs, it will return an OK
21# state if *no* pattern matches have been found in the *difference* between the 20# state if *no* pattern matches have been found in the *difference* between the
22# log file and the older copy of the log file. If the plugin detects any 21# log file and the older copy of the log file. If the plugin detects any
23# pattern matches in the log diff, it will return a CRITICAL state and print 22# pattern matches in the log diff, it will return a CRITICAL state and print
24# out a message is the following format: "(x) last_match", where "x" is the 23# out a message is the following format: "(x) last_match", where "x" is the
25# total number of pattern matches found in the file and "last_match" is the 24# total number of pattern matches found in the file and "last_match" is the
@@ -44,6 +43,10 @@
44# check the same <log_file> for pattern matches. This is necessary 43# check the same <log_file> for pattern matches. This is necessary
45# because of the way the script operates. 44# because of the way the script operates.
46# 45#
46# 4. This plugin does NOT have an understanding of logrotation or similar
47# mechanisms. Therefore bad timing could lead to missing events
48#
49#
47# Examples: 50# Examples:
48# 51#
49# Check for login failures in the syslog... 52# Check for login failures in the syslog...
@@ -60,20 +63,26 @@
60 63
61PATH="@TRUSTED_PATH@" 64PATH="@TRUSTED_PATH@"
62export PATH 65export PATH
63PROGNAME=`basename $0` 66PROGNAME=$(basename "$0")
64PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 67PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
65REVISION="@NP_VERSION@" 68REVISION="@NP_VERSION@"
66 69
67. $PROGPATH/utils.sh 70. "$PROGPATH"/utils.sh
68 71
69print_usage() { 72print_usage() {
70 echo "Usage: $PROGNAME -F logfile -O oldlog -q query" 73 echo "Usage: $PROGNAME -F logfile -O oldlog -q query"
71 echo "Usage: $PROGNAME --help" 74 echo "Usage: $PROGNAME --help"
72 echo "Usage: $PROGNAME --version" 75 echo "Usage: $PROGNAME --version"
76 echo ""
77 echo "Other parameters:"
78 echo " -a|--all : Print all matching lines"
79 echo " --exclude: Exclude a pattern (-p or -e also applies here when used)"
80 echo " -p|--perl-regex : Use perl style regular expressions in the query"
81 echo " -e|--extended-regex : Use extended style regular expressions in the query (not necessary for GNU grep)"
73} 82}
74 83
75print_help() { 84print_help() {
76 print_revision $PROGNAME $REVISION 85 print_revision "$PROGNAME" "$REVISION"
77 echo "" 86 echo ""
78 print_usage 87 print_usage
79 echo "" 88 echo ""
@@ -87,81 +96,89 @@ print_help() {
87 96
88if [ $# -lt 1 ]; then 97if [ $# -lt 1 ]; then
89 print_usage 98 print_usage
90 exit $STATE_UNKNOWN 99 exit "$STATE_UNKNOWN"
91fi 100fi
92 101
93# Grab the command line arguments 102# Grab the command line arguments
94
95#logfile=$1
96#oldlog=$2
97#query=$3
98exitstatus=$STATE_WARNING #default 103exitstatus=$STATE_WARNING #default
99while test -n "$1"; do 104while test -n "$1"; do
100 case "$1" in 105 case "$1" in
101 --help) 106 -h | --help)
102 print_help 107 print_help
103 exit $STATE_OK 108 exit "$STATE_UNKNOWN"
104 ;; 109 ;;
105 -h) 110 -V | --version)
106 print_help 111 print_revision "$PROGNAME" "$REVISION"
107 exit $STATE_OK 112 exit "$STATE_UNKNOWN"
108 ;;
109 --version)
110 print_revision $PROGNAME $REVISION
111 exit $STATE_OK
112 ;;
113 -V)
114 print_revision $PROGNAME $REVISION
115 exit $STATE_OK
116 ;;
117 --filename)
118 logfile=$2
119 shift
120 ;; 113 ;;
121 -F) 114 -F | --filename)
122 logfile=$2 115 logfile=$2
123 shift 116 shift 2
124 ;; 117 ;;
125 --oldlog) 118 -O | --oldlog)
126 oldlog=$2 119 oldlog=$2
127 shift 120 shift 2
128 ;; 121 ;;
129 -O) 122 -q | --query)
130 oldlog=$2
131 shift
132 ;;
133 --query)
134 query=$2 123 query=$2
135 shift 124 shift 2
136 ;; 125 ;;
137 -q) 126 --exclude)
138 query=$2 127 exclude=$2
139 shift 128 shift 2
140 ;; 129 ;;
141 -x) 130 -x | --exitstatus)
142 exitstatus=$2 131 exitstatus=$2
132 shift 2
133 ;;
134 -e | --extended-regex)
135 ERE=1
143 shift 136 shift
144 ;; 137 ;;
145 --exitstatus) 138 -p | --perl-regex)
146 exitstatus=$2 139 PRE=1
140 shift
141 ;;
142 -a | --all)
143 ALL=1
147 shift 144 shift
148 ;; 145 ;;
149 *) 146 *)
150 echo "Unknown argument: $1" 147 echo "Unknown argument: $1"
151 print_usage 148 print_usage
152 exit $STATE_UNKNOWN 149 exit "$STATE_UNKNOWN"
153 ;; 150 ;;
154 esac 151 esac
155 shift
156done 152done
157 153
154# Parameter sanity check
155if [ $ERE ] && [ $PRE ] ; then
156 echo "Can not use extended and perl regex at the same time"
157 exit "$STATE_UNKNOWN"
158fi
159
160GREP="grep"
161
162if [ $ERE ]; then
163 GREP="grep -E"
164fi
165
166if [ $PRE ]; then
167 GREP="grep -P"
168fi
169
158# If the source log file doesn't exist, exit 170# If the source log file doesn't exist, exit
159 171
160if [ ! -e $logfile ]; then 172if [ ! -e "$logfile" ]; then
161 echo "Log check error: Log file $logfile does not exist!" 173 echo "Log check error: Log file $logfile does not exist!"
162 exit $STATE_UNKNOWN 174 exit "$STATE_UNKNOWN"
163elif [ ! -r $logfile ] ; then 175elif [ ! -r "$logfile" ] ; then
164 echo "Log check error: Log file $logfile is not readable!" 176 echo "Log check error: Log file $logfile is not readable!"
177 exit "$STATE_UNKNOWN"
178fi
179# If no oldlog was given this can not work properly, abort then
180if [ -z "$oldlog" ]; then
181 echo "Oldlog parameter is needed"
165 exit $STATE_UNKNOWN 182 exit $STATE_UNKNOWN
166fi 183fi
167 184
@@ -169,10 +186,10 @@ fi
169# we're running this test, so copy the original log file over to 186# we're running this test, so copy the original log file over to
170# the old diff file and exit 187# the old diff file and exit
171 188
172if [ ! -e $oldlog ]; then 189if [ ! -e "$oldlog" ]; then
173 cat $logfile > $oldlog 190 cat "$logfile" > "$oldlog"
174 echo "Log check data initialized..." 191 echo "Log check data initialized..."
175 exit $STATE_OK 192 exit "$STATE_OK"
176fi 193fi
177 194
178# The old log file exists, so compare it to the original log now 195# The old log file exists, so compare it to the original log now
@@ -180,31 +197,48 @@ fi
180# The temporary file that the script should use while 197# The temporary file that the script should use while
181# processing the log file. 198# processing the log file.
182if [ -x /bin/mktemp ]; then 199if [ -x /bin/mktemp ]; then
183 tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX` 200
201 tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX)
184else 202else
185 tempdiff=`/bin/date '+%H%M%S'` 203 tempdiff=$(/bin/date '+%H%M%S')
186 tempdiff="/tmp/check_log.${tempdiff}" 204 tempdiff="/tmp/check_log.${tempdiff}"
187 touch $tempdiff 205 touch "$tempdiff"
188 chmod 600 $tempdiff 206 chmod 600 "$tempdiff"
189fi 207fi
190 208
191diff $logfile $oldlog | grep -v "^>" > $tempdiff 209diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff"
210
192 211
193# Count the number of matching log entries we have 212if [ $ALL ]; then
194count=`grep -c "$query" $tempdiff` 213 # Get all matching entries in the diff file
214 if [ -n "$exclude" ]; then
215 entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude")
216 count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
217 else
218 entry=$($GREP "$query" "$tempdiff")
219 count=$($GREP -c "$query" "$tempdiff")
220 fi
195 221
196# Get the last matching entry in the diff file 222else
197lastentry=`grep "$query" $tempdiff | tail -1` 223 # Get the last matching entry in the diff file
224 if [ -n "$exclude" ]; then
225 entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude" | tail -1)
226 count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude")
227 else
228 entry=$($GREP "$query" "$tempdiff" | tail -1)
229 count=$($GREP -c "$query" "$tempdiff")
230 fi
231fi
198 232
199rm -f $tempdiff 233rm -f "$tempdiff"
200cat $logfile > $oldlog 234cat "$logfile" > "$oldlog"
201 235
202if [ "$count" = "0" ]; then # no matches, exit with no error 236if [ "$count" = "0" ]; then # no matches, exit with no error
203 echo "Log check ok - 0 pattern matches found" 237 echo "Log check ok - 0 pattern matches found"
204 exitstatus=$STATE_OK 238 exitstatus=$STATE_OK
205else # Print total matche count and the last entry we found 239else # Print total match count and the last entry we found
206 echo "($count) $lastentry" 240 echo "($count) $entry"
207 exitstatus=$STATE_CRITICAL 241 exitstatus=$STATE_CRITICAL
208fi 242fi
209 243
210exit $exitstatus 244exit "$exitstatus"
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index aac1310..49156af 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -4,7 +4,7 @@
4# transmittal. 4# transmittal.
5# 5#
6# Initial version support sendmail's mailq command 6# Initial version support sendmail's mailq command
7# Support for mutiple sendmail queues (Carlos Canau) 7# Support for multiple sendmail queues (Carlos Canau)
8# Support for qmail (Benjamin Schmid) 8# Support for qmail (Benjamin Schmid)
9 9
10# License Information: 10# License Information:
@@ -28,9 +28,9 @@
28use POSIX; 28use POSIX;
29use strict; 29use strict;
30use Getopt::Long; 30use Getopt::Long;
31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s 31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s $opt_d
32 $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines 32 $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq $mailq_args
33 %srcdomains %dstdomains); 33 @lines %srcdomains %dstdomains);
34use FindBin; 34use FindBin;
35use lib "$FindBin::Bin"; 35use lib "$FindBin::Bin";
36use utils qw(%ERRORS &print_revision &support &usage ); 36use utils qw(%ERRORS &print_revision &support &usage );
@@ -48,6 +48,8 @@ $PROGNAME = "check_mailq";
48$mailq = 'sendmail'; # default 48$mailq = 'sendmail'; # default
49$msg_q = 0 ; 49$msg_q = 0 ;
50$msg_p = 0 ; 50$msg_p = 0 ;
51# If appended, must start with a space
52$mailq_args = '' ;
51$state = $ERRORS{'UNKNOWN'}; 53$state = $ERRORS{'UNKNOWN'};
52 54
53Getopt::Long::Configure('bundling'); 55Getopt::Long::Configure('bundling');
@@ -68,6 +70,10 @@ if ($opt_s) {
68 $sudo = ""; 70 $sudo = "";
69} 71}
70 72
73if ($opt_d) {
74 $mailq_args = $mailq_args . ' -C ' . $opt_d;
75}
76
71$SIG{'ALRM'} = sub { 77$SIG{'ALRM'} = sub {
72 print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); 78 print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n");
73 exit $ERRORS{"WARNING"}; 79 exit $ERRORS{"WARNING"};
@@ -143,7 +149,26 @@ if ($mailq eq "sendmail") {
143##/var/spool/mqueue/qF/df is empty 149##/var/spool/mqueue/qF/df is empty
144## Total Requests: 1 150## Total Requests: 1
145 151
146 152# separate submission/transport queues, empty
153## MSP Queue status...
154## /var/spool/mqueue-client is empty
155## Total requests: 0
156## MTA Queue status...
157## /var/spool/mqueue is empty
158## Total requests: 0
159# separate submission/transport queues: 1
160## MSP Queue status...
161## /var/spool/mqueue-client (1 request)
162## -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
163## oAJEfhdW014123 5 Fri Nov 19 14:41 jwm
164## (Deferred: Connection refused by [127.0.0.1])
165## root
166## Total requests: 1
167## MTA Queue status...
168## /var/spool/mqueue is empty
169## Total requests: 0
170
171 my $this_msg_q = 0;
147 while (<MAILQ>) { 172 while (<MAILQ>) {
148 173
149 # match email addr on queue listing 174 # match email addr on queue listing
@@ -183,13 +208,18 @@ if ($mailq eq "sendmail") {
183 # 208 #
184 # single queue: first line 209 # single queue: first line
185 # multi queue: one for each queue. overwrite on multi queue below 210 # multi queue: one for each queue. overwrite on multi queue below
186 $msg_q = $1 ; 211 $this_msg_q = $1 ;
212 $msg_q += $1 ;
187 } 213 }
188 } elsif (/^\s+Total\sRequests:\s(\d+)$/i) { 214 } elsif (/^\s+Total\sRequests:\s(\d+)$/i) {
189 print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ; 215 if ($this_msg_q) {
190 # 216 $this_msg_q = 0 ;
191 # multi queue: last line 217 } else {
192 $msg_q = $1 ; 218 print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ;
219 #
220 # multi queue: last line
221 $msg_q += $1 ;
222 }
193 } 223 }
194 224
195 } 225 }
@@ -309,8 +339,8 @@ elsif ( $mailq eq "postfix" ) {
309 339
310 ## open mailq 340 ## open mailq
311 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { 341 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
312 if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { 342 if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) {
313 print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; 343 print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n";
314 exit $ERRORS{'UNKNOWN'}; 344 exit $ERRORS{'UNKNOWN'};
315 } 345 }
316 }elsif( defined $utils::PATH_TO_MAILQ){ 346 }elsif( defined $utils::PATH_TO_MAILQ){
@@ -330,7 +360,7 @@ elsif ( $mailq eq "postfix" ) {
330 close MAILQ; 360 close MAILQ;
331 361
332 if ( $? ) { 362 if ( $? ) {
333 print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/; 363 print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/;
334 exit $ERRORS{CRITICAL}; 364 exit $ERRORS{CRITICAL};
335 } 365 }
336 366
@@ -343,7 +373,7 @@ elsif ( $mailq eq "postfix" ) {
343 }elsif ($lines[0]=~/Mail queue is empty/) { 373 }elsif ($lines[0]=~/Mail queue is empty/) {
344 $msg_q = 0; 374 $msg_q = 0;
345 }else{ 375 }else{
346 print "Couldn't match $utils::PATH_TO_MAILQ output\n"; 376 print "Couldn't match $utils::PATH_TO_MAILQ$mailq_args output\n";
347 exit $ERRORS{'UNKNOWN'}; 377 exit $ERRORS{'UNKNOWN'};
348 } 378 }
349 379
@@ -531,9 +561,9 @@ elsif ( $mailq eq "nullmailer" ) {
531 } 561 }
532 562
533 while (<MAILQ>) { 563 while (<MAILQ>) {
534 #2006-06-22 16:00:00 282 bytes 564 #2022-08-25 01:30:40 502 bytes from <user@example.com>
535 565
536 if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) { 566 if (/^\d{4}-\d{2}-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d+\sbytes/) {
537 $msg_q++ ; 567 $msg_q++ ;
538 } 568 }
539 } 569 }
@@ -561,16 +591,17 @@ exit $state;
561 591
562sub process_arguments(){ 592sub process_arguments(){
563 GetOptions 593 GetOptions
564 ("V" => \$opt_V, "version" => \$opt_V, 594 ("V" => \$opt_V, "version" => \$opt_V,
565 "v" => \$opt_v, "verbose" => \$opt_v, 595 "v" => \$opt_v, "verbose" => \$opt_v,
566 "h" => \$opt_h, "help" => \$opt_h, 596 "h" => \$opt_h, "help" => \$opt_h,
567 "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) 597 "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail)
568 "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number 598 "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number
569 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number 599 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
600 "W=i" => \$opt_W, "warning-domain=i" => \$opt_W, # Warning if above this number
601 "C=i" => \$opt_C, "critical-domain=i" => \$opt_C, # Critical if above this number
570 "t=i" => \$opt_t, "timeout=i" => \$opt_t, 602 "t=i" => \$opt_t, "timeout=i" => \$opt_t,
571 "s" => \$opt_s, "sudo" => \$opt_s, 603 "s" => \$opt_s, "sudo" => \$opt_s,
572 "W=i" => \$opt_W, # warning if above this number 604 "d:s" => \$opt_d, "configdir:s" => \$opt_d,
573 "C=i" => \$opt_C, # critical if above this number
574 ); 605 );
575 606
576 if ($opt_V) { 607 if ($opt_V) {
@@ -651,7 +682,7 @@ sub process_arguments(){
651} 682}
652 683
653sub print_usage () { 684sub print_usage () {
654 print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n"; 685 print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-d <CONFIGDIR>] [-v]\n";
655} 686}
656 687
657sub print_help () { 688sub print_help () {
@@ -664,14 +695,15 @@ sub print_help () {
664 print " Feedback/patches to support non-sendmail mailqueue welcome\n\n"; 695 print " Feedback/patches to support non-sendmail mailqueue welcome\n\n";
665 print "-w (--warning) = Min. number of messages in queue to generate warning\n"; 696 print "-w (--warning) = Min. number of messages in queue to generate warning\n";
666 print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n"; 697 print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n";
667 print "-W = Min. number of messages for same domain in queue to generate warning\n"; 698 print "-W (--warning-domain) = Min. number of messages for same domain in queue to generate warning\n";
668 print "-C = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; 699 print "-C (--critical-domain) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
669 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; 700 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
670 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; 701 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
671 print "-s (--sudo) = Use sudo to call the mailq command\n"; 702 print "-s (--sudo) = Use sudo to call the mailq command\n";
703 print "-d (--configdir) = Config file or directory\n";
672 print "-h (--help)\n"; 704 print "-h (--help)\n";
673 print "-V (--version)\n"; 705 print "-V (--version)\n";
674 print "-v (--verbose) = debugging output\n"; 706 print "-v (--verbose) = debugging output\n";
675 print "\n\n"; 707 print "\n\n";
676 print "Note: -w and -c are required arguments. -W and -C are optional.\n"; 708 print "Note: -w and -c are required arguments. -W and -C are optional.\n";
677 print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; 709 print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n";
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index 96078ac..5998138 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -8,11 +8,11 @@
8 8
9PATH="@TRUSTED_PATH@" 9PATH="@TRUSTED_PATH@"
10export PATH 10export PATH
11PROGNAME=`basename $0` 11PROGNAME=$(basename "$0")
12PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 12PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
13REVISION="@NP_VERSION@" 13REVISION="@NP_VERSION@"
14 14
15. $PROGPATH/utils.sh 15. "$PROGPATH"/utils.sh
16 16
17 17
18print_usage() { 18print_usage() {
@@ -29,7 +29,7 @@ print_usage() {
29} 29}
30 30
31print_help() { 31print_help() {
32 print_revision $PROGNAME $REVISION 32 print_revision "$PROGNAME" "$REVISION"
33 echo "" 33 echo ""
34 print_usage 34 print_usage
35 echo "" 35 echo ""
@@ -86,48 +86,48 @@ esac
86# Information options 86# Information options
87case "$cmd" in 87case "$cmd" in
88--help) 88--help)
89 print_help 89 print_help
90 exit $STATE_OK 90 exit "$STATE_UNKNOWN"
91 ;; 91 ;;
92-h) 92-h)
93 print_help 93 print_help
94 exit $STATE_OK 94 exit "$STATE_UNKNOWN"
95 ;; 95 ;;
96--version) 96--version)
97 print_revision $PROGNAME $REVISION 97 print_revision "$PROGNAME" "$REVISION"
98 exit $STATE_OK 98 exit "$STATE_UNKNOWN"
99 ;; 99 ;;
100-V) 100-V)
101 print_revision $PROGNAME $REVISION 101 print_revision "$PROGNAME" "$REVISION"
102 exit $STATE_OK 102 exit "$STATE_UNKNOWN"
103 ;; 103 ;;
104esac 104esac
105 105
106# Hunt down a reasonable ORACLE_HOME 106# Hunt down a reasonable ORACLE_HOME
107if [ -z "$ORACLE_HOME" ] ; then 107if [ -z "$ORACLE_HOME" ] ; then
108 # Adjust to taste 108 # Adjust to taste
109 for oratab in /var/opt/oracle/oratab /etc/oratab 109 for oratab in /var/opt/oracle/oratab /etc/oratab
110 do 110 do
111 [ ! -f $oratab ] && continue 111 [ ! -f $oratab ] && continue
112 ORACLE_HOME=`IFS=: 112 ORACLE_HOME=`IFS=:
113 while read SID ORACLE_HOME junk; 113 while read -r SID ORACLE_HOME junk;
114 do 114 do
115 if [ "$SID" = "$2" -o "$SID" = "*" ] ; then 115 if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then
116 echo $ORACLE_HOME; 116 echo "$ORACLE_HOME";
117 exit; 117 exit;
118 fi; 118 fi;
119 done < $oratab` 119 done < $oratab`
120 [ -n "$ORACLE_HOME" ] && break 120 [ -n "$ORACLE_HOME" ] && break
121 done 121 done
122fi 122fi
123# Last resort 123# Last resort
124[ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle 124[ -z "$ORACLE_HOME" ] && [ -d "$PROGPATH"/oracle ] && ORACLE_HOME=$PROGPATH/oracle
125 125
126if [ "$cmd" != "--db" ]; then 126if [ "$cmd" != "--db" ]; then
127 if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then 127 if [ -z "$ORACLE_HOME" ] || [ ! -d "$ORACLE_HOME" ] ; then
128 echo "Cannot determine ORACLE_HOME for sid $2" 128 echo "Cannot determine ORACLE_HOME for sid $2"
129 exit $STATE_UNKNOWN 129 exit "$STATE_UNKNOWN"
130 fi 130 fi
131fi 131fi
132PATH=$PATH:$ORACLE_HOME/bin 132PATH=$PATH:$ORACLE_HOME/bin
133LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib 133LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
@@ -135,81 +135,81 @@ export ORACLE_HOME PATH LD_LIBRARY_PATH
135 135
136case "$cmd" in 136case "$cmd" in
137--tns) 137--tns)
138 tnschk=` tnsping $2` 138 tnschk=$(tnsping "$2")
139 tnschk2=` echo $tnschk | grep -c OK` 139 tnschk2=$(echo "$tnschk" | grep -c OK)
140 if [ ${tnschk2} -eq 1 ] ; then 140 if [ "${tnschk2}" -eq 1 ] ; then
141 tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} 141 tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*}
142 echo "OK - reply time ${tnschk3} from $2" 142 echo "OK - reply time ${tnschk3} from $2"
143 exit $STATE_OK 143 exit "$STATE_OK"
144 else 144 else
145 echo "No TNS Listener on $2" 145 echo "No TNS Listener on $2"
146 exit $STATE_CRITICAL 146 exit "$STATE_CRITICAL"
147 fi 147 fi
148 ;; 148 ;;
149--oranames) 149--oranames)
150 namesctl status $2 | awk ' 150 namesctl status "$2" | awk '
151 /Server has been running for:/ { 151 /Server has been running for:/ {
152 msg = "OK: Up" 152 msg = "OK: Up"
153 for (i = 6; i <= NF; i++) { 153 for (i = 6; i <= NF; i++) {
154 msg = msg " " $i 154 msg = msg " " $i
155 } 155 }
156 status = '$STATE_OK' 156 status = '"$STATE_OK"'
157 } 157 }
158 /error/ { 158 /error/ {
159 msg = "CRITICAL: " $0 159 msg = "CRITICAL: " $0
160 status = '$STATE_CRITICAL' 160 status = '"$STATE_CRITICAL"'
161 } 161 }
162 END { 162 END {
163 print msg 163 print msg
164 exit status 164 exit status
165 }' 165 }'
166 ;; 166 ;;
167--db) 167--db)
168 pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"` 168 pmonchk=$(pgrep -f "(asm|ora)_pmon_${2}$")
169 if [ ${pmonchk} -ge 1 ] ; then 169 if [ "${pmonchk}" -ge 1 ] ; then
170 echo "${2} OK - ${pmonchk} PMON process(es) running" 170 echo "${2} OK - ${pmonchk} PMON process(es) running"
171 exit $STATE_OK 171 exit "$STATE_OK"
172 #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then 172 #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then
173 #if [ ${pmonchk} -eq 1 ] ; then 173 #if [ ${pmonchk} -eq 1 ] ; then
174 #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` 174 #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55`
175 #echo "${2} OK - running since ${utime}" 175 #echo "${2} OK - running since ${utime}"
176 #exit $STATE_OK 176 #exit $STATE_OK
177 #fi 177 #fi
178 else 178 else
179 echo "${2} Database is DOWN" 179 echo "${2} Database is DOWN"
180 exit $STATE_CRITICAL 180 exit "$STATE_CRITICAL"
181 fi 181 fi
182 ;; 182 ;;
183--login) 183--login)
184 loginchk=`sqlplus dummy/user@$2 < /dev/null` 184 loginchk=$(sqlplus dummy/user@"$2" < /dev/null)
185 loginchk2=` echo $loginchk | grep -c ORA-01017` 185 loginchk2=$(echo "$loginchk" | grep -c ORA-01017)
186 if [ ${loginchk2} -eq 1 ] ; then 186 if [ "${loginchk2}" -eq 1 ] ; then
187 echo "OK - dummy login connected" 187 echo "OK - dummy login connected"
188 exit $STATE_OK 188 exit "$STATE_OK"
189 else 189 else
190 loginchk3=` echo "$loginchk" | grep "ORA-" | head -1` 190 loginchk3=$(echo "$loginchk" | grep "ORA-" | head -1)
191 echo "CRITICAL - $loginchk3" 191 echo "CRITICAL - $loginchk3"
192 exit $STATE_CRITICAL 192 exit "$STATE_CRITICAL"
193 fi 193 fi
194 ;; 194 ;;
195--connect) 195--connect)
196 connectchk=`sqlplus $2 < /dev/null` 196 connectchk=$(sqlplus "$2" < /dev/null)
197 connectchk2=` echo $connectchk | grep -c ORA-` 197 connectchk2=$(echo "$connectchk" | grep -c ORA-)
198 if [ ${connectchk2} -eq 0 ] ; then 198 if [ "${connectchk2}" -eq 0 ] ; then
199 echo "OK - login successful" 199 echo "OK - login successful"
200 exit $STATE_OK 200 exit "$STATE_OK"
201 else 201 else
202 connectchk3=` echo "$connectchk" | grep "ORA-" | head -1` 202 connectchk3=$(echo "$connectchk" | grep "ORA-" | head -1)
203 echo "CRITICAL - $connectchk3" 203 echo "CRITICAL - $connectchk3"
204 exit $STATE_CRITICAL 204 exit "$STATE_CRITICAL"
205 fi 205 fi
206 ;; 206 ;;
207--cache) 207--cache)
208 if [ ${5} -gt ${6} ] ; then 208 if [ "${5}" -gt "${6}" ] ; then
209 echo "UNKNOWN - Warning level is less then Crit" 209 echo "UNKNOWN - Warning level is less then Crit"
210 exit $STATE_UNKNOWN 210 exit "$STATE_UNKNOWN"
211 fi 211 fi
212 result=`sqlplus -s ${3}/${4}@${2} << EOF 212 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
213set pagesize 0 213set pagesize 0
214set numf '9999999.99' 214set numf '9999999.99'
215select (1-(pr.value/(dbg.value+cg.value)))*100 215select (1-(pr.value/(dbg.value+cg.value)))*100
@@ -219,48 +219,48 @@ and dbg.name='db block gets'
219and cg.name='consistent gets'; 219and cg.name='consistent gets';
220EOF` 220EOF`
221 221
222 if [ -n "`echo $result | grep ORA-`" ] ; then 222 if echo "$result" | grep -q 'ORA-' ; then
223 error=` echo "$result" | grep "ORA-" | head -1` 223 error=$(echo "$result" | grep "ORA-" | head -1)
224 echo "CRITICAL - $error" 224 echo "CRITICAL - $error"
225 exit $STATE_CRITICAL 225 exit "$STATE_CRITICAL"
226 fi 226 fi
227 227
228 buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 228 buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
229 buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 229 buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
230 result=`sqlplus -s ${3}/${4}@${2} << EOF 230 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
231set pagesize 0 231set pagesize 0
232set numf '9999999.99' 232set numf '9999999.99'
233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 233select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100
234from v\\$librarycache lc; 234from v\\$librarycache lc;
235EOF` 235EOF`
236 236
237 if [ -n "`echo $result | grep ORA-`" ] ; then 237 if echo "$result" | grep -q 'ORA-' ; then
238 error=` echo "$result" | grep "ORA-" | head -1` 238 error=$(echo "$result" | grep "ORA-" | head -1)
239 echo "CRITICAL - $error" 239 echo "CRITICAL - $error"
240 exit $STATE_CRITICAL 240 exit "$STATE_CRITICAL"
241 fi 241 fi
242 242
243 lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` 243 lib_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}')
244 lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` 244 lib_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}')
245 245
246 if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then 246 if [ "$buf_hr" -le "${5}" ] || [ "$lib_hr" -le "${5}" ] ; then
247 echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 247 echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
248 exit $STATE_CRITICAL 248 exit "$STATE_CRITICAL"
249 fi 249 fi
250 if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then 250 if [ "$buf_hr" -le "${6}" ] || [ "$lib_hr" -le "${6}" ] ; then
251 echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 251 echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
252 exit $STATE_WARNING 252 exit "$STATE_WARNING"
253 fi 253 fi
254 echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" 254 echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100"
255 255
256 exit $STATE_OK 256 exit "$STATE_OK"
257 ;; 257 ;;
258--tablespace) 258--tablespace)
259 if [ ${6} -lt ${7} ] ; then 259 if [ "${6}" -lt "${7}" ] ; then
260 echo "UNKNOWN - Warning level is more then Crit" 260 echo "UNKNOWN - Warning level is more then Crit"
261 exit $STATE_UNKNOWN 261 exit "$STATE_UNKNOWN"
262 fi 262 fi
263 result=`sqlplus -s ${3}/${4}@${2} << EOF 263 result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF
264set pagesize 0 264set pagesize 0
265set numf '9999999.99' 265set numf '9999999.99'
266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc 266select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc
@@ -273,32 +273,32 @@ from dba_free_space group by tablespace_name) B
273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; 273ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}';
274EOF` 274EOF`
275 275
276 if [ -n "`echo $result | grep ORA-`" ] ; then 276 if echo "$result" | grep -q 'ORA-' ; then
277 error=` echo "$result" | grep "ORA-" | head -1` 277 error=$(echo "$result" | grep "ORA-" | head -1)
278 echo "CRITICAL - $error" 278 echo "CRITICAL - $error"
279 exit $STATE_CRITICAL 279 exit "$STATE_CRITICAL"
280 fi 280 fi
281 281
282 ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` 282 ts_free=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}')
283 ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` 283 ts_total=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}')
284 ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` 284 ts_pct=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}')
285 ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` 285 ts_pctx=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}')
286 if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then 286 if [ "$ts_free" -eq 0 ] && [ "$ts_total" -eq 0 ] && [ "$ts_pct" -eq 0 ] ; then
287 echo "No data returned by Oracle - tablespace $5 not found?" 287 echo "No data returned by Oracle - tablespace $5 not found?"
288 exit $STATE_UNKNOWN 288 exit "$STATE_UNKNOWN"
289 fi 289 fi
290 if [ "$ts_pct" -ge ${6} ] ; then 290 if [ "$ts_pct" -ge "${6}" ] ; then
291 echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 291 echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
292 exit $STATE_CRITICAL 292 exit "$STATE_CRITICAL"
293 fi 293 fi
294 if [ "$ts_pct" -ge ${7} ] ; then 294 if [ "$ts_pct" -ge "${7}" ] ; then
295 echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 295 echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
296 exit $STATE_WARNING 296 exit "$STATE_WARNING"
297 fi 297 fi
298 echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" 298 echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100"
299 exit $STATE_OK 299 exit "$STATE_OK"
300 ;; 300 ;;
301*) 301*)
302 print_usage 302 print_usage
303 exit $STATE_UNKNOWN 303 exit "$STATE_UNKNOWN"
304esac 304esac
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl
index 47d6e49..8a56b9f 100755
--- a/plugins-scripts/check_rpc.pl
+++ b/plugins-scripts/check_rpc.pl
@@ -5,7 +5,7 @@
5# usage: 5# usage:
6# check_rpc host service 6# check_rpc host service
7# 7#
8# Check if an rpc serice is registered and running 8# Check if an rpc service is registered and running
9# using rpcinfo - $proto $host $prognum 2>&1 |"; 9# using rpcinfo - $proto $host $prognum 2>&1 |";
10# 10#
11# Use these hosts.cfg entries as examples 11# Use these hosts.cfg entries as examples
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh
index f742830..866e0e0 100755
--- a/plugins-scripts/check_sensors.sh
+++ b/plugins-scripts/check_sensors.sh
@@ -2,57 +2,57 @@
2 2
3PATH="@TRUSTED_PATH@" 3PATH="@TRUSTED_PATH@"
4export PATH 4export PATH
5PROGNAME=`basename $0` 5PROGNAME=$(basename "$0")
6PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 6PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,')
7REVISION="@NP_VERSION@" 7REVISION="@NP_VERSION@"
8 8
9. $PROGPATH/utils.sh 9. "$PROGPATH"/utils.sh
10 10
11print_usage() { 11print_usage() {
12 echo "Usage: $PROGNAME" [--ignore-fault] 12 echo "Usage: $PROGNAME" [--ignore-fault]
13} 13}
14 14
15print_help() { 15print_help() {
16 print_revision $PROGNAME $REVISION 16 print_revision "$PROGNAME" "$REVISION"
17 echo "" 17 echo ""
18 print_usage 18 print_usage
19 echo "" 19 echo ""
20 echo "This plugin checks hardware status using the lm_sensors package." 20 echo "This plugin checks hardware status using the lm_sensors package."
21 echo "" 21 echo ""
22 support 22 support
23 exit $STATE_OK 23 exit "$STATE_OK"
24} 24}
25 25
26case "$1" in 26case "$1" in
27 --help) 27 --help)
28 print_help 28 print_help
29 exit $STATE_OK 29 exit "$STATE_UNKNOWN"
30 ;; 30 ;;
31 -h) 31 -h)
32 print_help 32 print_help
33 exit $STATE_OK 33 exit "$STATE_UNKNOWN"
34 ;; 34 ;;
35 --version) 35 --version)
36 print_revision $PROGNAME $REVISION 36 print_revision "$PROGNAME" "$REVISION"
37 exit $STATE_OK 37 exit "$STATE_UNKNOWN"
38 ;; 38 ;;
39 -V) 39 -V)
40 print_revision $PROGNAME $REVISION 40 print_revision "$PROGNAME" "$REVISION"
41 exit $STATE_OK 41 exit "$STATE_UNKNOWN"
42 ;; 42 ;;
43 *) 43 *)
44 sensordata=`sensors 2>&1` 44 sensordata=$(sensors 2>&1)
45 status=$? 45 status=$?
46 if test ${status} -eq 127; then 46 if test ${status} -eq 127; then
47 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" 47 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
48 exit=$STATE_UNKNOWN 48 exit=$STATE_UNKNOWN
49 elif test ${status} -ne 0; then 49 elif test "${status}" -ne 0; then
50 text="WARNING - sensors returned state $status" 50 text="WARNING - sensors returned state $status"
51 exit=$STATE_WARNING 51 exit=$STATE_WARNING
52 elif echo ${sensordata} | egrep ALARM > /dev/null; then 52 elif echo "${sensordata}" | grep -E ALARM > /dev/null; then
53 text="SENSOR CRITICAL - Sensor alarm detected!" 53 text="SENSOR CRITICAL - Sensor alarm detected!"
54 exit=$STATE_CRITICAL 54 exit=$STATE_CRITICAL
55 elif echo ${sensordata} | egrep FAULT > /dev/null \ 55 elif echo "${sensordata}" | grep -E FAULT > /dev/null \
56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then 56 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then
57 text="SENSOR UNKNOWN - Sensor reported fault" 57 text="SENSOR UNKNOWN - Sensor reported fault"
58 exit=$STATE_UNKNOWN 58 exit=$STATE_UNKNOWN
@@ -63,8 +63,8 @@ case "$1" in
63 63
64 echo "$text" 64 echo "$text"
65 if test "$1" = "-v" -o "$1" = "--verbose"; then 65 if test "$1" = "-v" -o "$1" = "--verbose"; then
66 echo ${sensordata} 66 echo "${sensordata}"
67 fi 67 fi
68 exit $exit 68 exit "$exit"
69 ;; 69 ;;
70esac 70esac
diff --git a/plugins-scripts/check_uptime.pl b/plugins-scripts/check_uptime.pl
index 4c9f22d..d73e40e 100755
--- a/plugins-scripts/check_uptime.pl
+++ b/plugins-scripts/check_uptime.pl
@@ -25,7 +25,7 @@ use POSIX;
25use strict; 25use strict;
26use Getopt::Long; 26use Getopt::Long;
27use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c 27use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c
28 $opt_f $opt_s 28 $opt_f $opt_s $opt_d
29 $lower_warn_threshold $upper_warn_threshold 29 $lower_warn_threshold $upper_warn_threshold
30 $lower_crit_threshold $upper_crit_threshold 30 $lower_crit_threshold $upper_crit_threshold
31 $status $state $msg); 31 $status $state $msg);
@@ -110,7 +110,7 @@ $pretty_uptime .= sprintf( "%d week%s, ", $weeks, $weeks == 1 ? "" : "s" ) if
110$pretty_uptime .= sprintf( "%d day%s, ", $days, $days == 1 ? "" : "s" ) if $days; 110$pretty_uptime .= sprintf( "%d day%s, ", $days, $days == 1 ? "" : "s" ) if $days;
111$pretty_uptime .= sprintf( "%d hour%s, ", $hours, $hours == 1 ? "" : "s" ) if $hours; 111$pretty_uptime .= sprintf( "%d hour%s, ", $hours, $hours == 1 ? "" : "s" ) if $hours;
112$pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" ) if $mins; 112$pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" ) if $mins;
113# Replace last occurence of comma with "and" 113# Replace last occurrence of comma with "and"
114$pretty_uptime =~ s/, $/ and /; 114$pretty_uptime =~ s/, $/ and /;
115# Always print the seconds (though it may be 0 seconds) 115# Always print the seconds (though it may be 0 seconds)
116$pretty_uptime .= sprintf( "%d second%s", $secs, $secs == 1 ? "" : "s" ); 116$pretty_uptime .= sprintf( "%d second%s", $secs, $secs == 1 ? "" : "s" );
@@ -137,9 +137,20 @@ if ( $uptime_seconds > $upper_crit_threshold ) {
137 $state_str = "OK"; 137 $state_str = "OK";
138} 138}
139 139
140# Prepare uptime value (seconds or days)
141my $uptime_text = "";
142my $uptime_unit = "";
143if ( $opt_d ) {
144 $uptime_text = floor($uptime_seconds / 60 / 60 / 24);
145 $uptime_unit = "days";
146} else {
147 $uptime_text = $uptime_seconds;
148 $uptime_unit = "seconds";
149}
150
140$msg = "$state_str: "; 151$msg = "$state_str: ";
141 152
142$msg .= "uptime is $uptime_seconds seconds. "; 153$msg .= "Uptime is $uptime_text $uptime_unit. ";
143$msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text; 154$msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text;
144$msg .= "Running for $pretty_uptime. " if $opt_f; 155$msg .= "Running for $pretty_uptime. " if $opt_f;
145if ( $opt_s ) { 156if ( $opt_s ) {
@@ -167,6 +178,7 @@ sub process_arguments(){
167 "c=s" => \$opt_c, "critical=s" => \$opt_c, # critical if above this number 178 "c=s" => \$opt_c, "critical=s" => \$opt_c, # critical if above this number
168 "f" => \$opt_f, "for" => \$opt_f, # show "running for ..." 179 "f" => \$opt_f, "for" => \$opt_f, # show "running for ..."
169 "s" => \$opt_s, "since" => \$opt_s, # show "running since ..." 180 "s" => \$opt_s, "since" => \$opt_s, # show "running since ..."
181 "d" => \$opt_d, "days" => \$opt_d, # report uptime in days
170 ); 182 );
171 183
172 if ($opt_V) { 184 if ($opt_V) {
@@ -262,6 +274,7 @@ sub print_help () {
262 print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n"; 274 print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n";
263 print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n"; 275 print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n";
264 print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n"; 276 print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n";
277 print "-d (--days) = Show uptime in days\n";
265 print "-h (--help)\n"; 278 print "-h (--help)\n";
266 print "-V (--version)\n"; 279 print "-V (--version)\n";
267 print "-v (--verbose) = debugging output\n"; 280 print "-v (--verbose) = debugging output\n";
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl
index 41e15f5..c24015c 100755
--- a/plugins-scripts/check_wave.pl
+++ b/plugins-scripts/check_wave.pl
@@ -19,6 +19,7 @@ sub print_usage ();
19$ENV{'PATH'}='@TRUSTED_PATH@'; 19$ENV{'PATH'}='@TRUSTED_PATH@';
20$ENV{'BASH_ENV'}=''; 20$ENV{'BASH_ENV'}='';
21$ENV{'ENV'}=''; 21$ENV{'ENV'}='';
22$ENV{'CDPATH'}='';
22 23
23Getopt::Long::Configure('bundling'); 24Getopt::Long::Configure('bundling');
24GetOptions 25GetOptions
@@ -50,34 +51,34 @@ my $critical = $1 if ($opt_c =~ /([0-9]+)/);
50($opt_w) || ($opt_w = shift) || ($opt_w = 60); 51($opt_w) || ($opt_w = shift) || ($opt_w = 60);
51my $warning = $1 if ($opt_w =~ /([0-9]+)/); 52my $warning = $1 if ($opt_w =~ /([0-9]+)/);
52 53
53$low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; 54$low1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
54@test = split(/ /,$low1); 55@test = split(/ /,$low1);
55$low1 = $test[2]; 56$low1 = $test[2];
56 57
57$med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; 58$med1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
58@test = split(/ /,$med1); 59@test = split(/ /,$med1);
59$med1 = $test[2]; 60$med1 = $test[2];
60 61
61$high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; 62$high1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
62@test = split(/ /,$high1); 63@test = split(/ /,$high1);
63$high1 = $test[2]; 64$high1 = $test[2];
64 65
65sleep(2); 66sleep(2);
66 67
67$snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`; 68$snr = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
68@test = split(/ /,$snr); 69@test = split(/ /,$snr);
69$snr = $test[2]; 70$snr = $test[2];
70$snr = int($snr*25); 71$snr = int($snr*25);
71 72
72$low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; 73$low2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
73@test = split(/ /,$low2); 74@test = split(/ /,$low2);
74$low2 = $test[2]; 75$low2 = $test[2];
75 76
76$med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; 77$med2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
77@test = split(/ /,$med2); 78@test = split(/ /,$med2);
78$med2 = $test[2]; 79$med2 = $test[2];
79 80
80$high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; 81$high2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
81@test = split(/ /,$high2); 82@test = split(/ /,$high2);
82$high2 = $test[2]; 83$high2 = $test[2];
83 84
diff --git a/plugins-scripts/t/check_log.t b/plugins-scripts/t/check_log.t
new file mode 100644
index 0000000..b66e0fd
--- /dev/null
+++ b/plugins-scripts/t/check_log.t
@@ -0,0 +1,82 @@
1#!/usr/bin/perl -w -I ..
2#
3# check_log tests
4#
5#
6
7use strict;
8use Test::More;
9use NPTest;
10
11my $tests = 18;
12plan tests => $tests;
13
14my $firstTimeOutput ='/^Log check data initialized/';
15my $okOutput = '/^Log check ok - 0 pattern matches found/';
16my $criticalOutput = '/^\(\d+\) < /';
17my $multilineOutput = '/\(3\) <.*\n.*\n.*$/';
18my $unknownOutput = '/^Usage: /';
19my $unknownArgOutput = '/^Unknown argument: /';
20my $bothRegexOutput = '/^Can not use extended and perl regex/';
21
22my $result;
23my $temp_file = "/tmp/check_log.tmp";
24my $oldlog = "/tmp/oldlog.tmp";
25
26open(FH, '>', $temp_file) or die $!;
27close(FH);
28
29$result = NPTest->testCmd("./check_log");
30cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
31like ( $result->output, $unknownOutput, "Output for unknown correct" );
32
33$result = NPTest->testCmd("./check_log -f");
34cmp_ok( $result->return_code, '==', 3, "Wrong parameters" );
35like ( $result->output, $unknownArgOutput, "Output for unknown correct" );
36
37$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match' -e -p");
38cmp_ok( $result->return_code, '==', 3, "Both regex parameters" );
39like ( $result->output, $bothRegexOutput, "Output for unknown correct" );
40
41$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match'");
42cmp_ok( $result->return_code, '==', 0, "First time executing" );
43like ( $result->output, $firstTimeOutput, "Output for first time executing correct" );
44
45open(FH, '>>', $temp_file) or die $!;
46print FH "This is some text, that should not match\n";
47close(FH);
48
49$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'No match'");
50cmp_ok( $result->return_code, '==', 0, "No match" );
51like ( $result->output, $okOutput, "Output for no match correct" );
52
53open(FH, '>>', $temp_file) or die $!;
54print FH "This text should match\n";
55close(FH);
56
57$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'should match'");
58cmp_ok( $result->return_code, '==', 2, "Pattern match" );
59like ( $result->output, $criticalOutput, "Output for match correct" );
60
61open(FH, '>>', $temp_file) or die $!;
62print FH "This text should not match, because it is excluded\n";
63close(FH);
64
65$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' --exclude 'because'");
66cmp_ok( $result->return_code, '==', 0, "Exclude a pattern" );
67like ( $result->output, $okOutput, "Output for no match correct" );
68
69open(FH, '>>', $temp_file) or die $!;
70print FH "Trying\nwith\nmultiline\nignore me\n";
71close(FH);
72
73$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Trying\\|with\\|multiline\\|ignore' --exclude 'me' --all");
74cmp_ok( $result->return_code, '==', 2, "Multiline pattern match with --all" );
75like ( $result->output, $multilineOutput, "Output for multiline match correct" );
76
77$result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' -a");
78cmp_ok( $result->return_code, '==', 0, "Non matching --all" );
79like ( $result->output, $okOutput, "Output for no match correct" );
80
81unlink($oldlog);
82unlink($temp_file);
diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t
index c395307..6e81db3 100644
--- a/plugins-scripts/t/check_uptime.t
+++ b/plugins-scripts/t/check_uptime.t
@@ -5,7 +5,7 @@
5# 5#
6 6
7use strict; 7use strict;
8use Test::More tests => 40; 8use Test::More tests => 42;
9use NPTest; 9use NPTest;
10 10
11my $result; 11my $result;
@@ -46,29 +46,35 @@ cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
46like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" ); 46like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" );
47 47
48$result = NPTest->testCmd( 48$result = NPTest->testCmd(
49 "./check_uptime -d -w 1 -c 2"
50 );
51cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
52like ( $result->output, '/CRITICAL: Uptime is \d+ days/', "Output for the d parameter correct" );
53
54$result = NPTest->testCmd(
49 "./check_uptime -w 1 -c 2" 55 "./check_uptime -w 1 -c 2"
50 ); 56 );
51cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); 57cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" );
52like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" ); 58like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" );
53 59
54$result = NPTest->testCmd( 60$result = NPTest->testCmd(
55 "./check_uptime -w 1 -c 9999w" 61 "./check_uptime -w 1 -c 9999w"
56 ); 62 );
57cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" ); 63cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" );
58like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" ); 64like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" );
59 65
60$result = NPTest->testCmd( 66$result = NPTest->testCmd(
61 "./check_uptime -w 9998w -c 9999w" 67 "./check_uptime -w 9998w -c 9999w"
62 ); 68 );
63cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" ); 69cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" );
64like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" ); 70like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" );
65like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" ); 71like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" );
66 72
67$result = NPTest->testCmd( 73$result = NPTest->testCmd(
68 "./check_uptime -w 111222d -c 222333d" 74 "./check_uptime -w 111222d -c 222333d"
69 ); 75 );
70cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" ); 76cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" );
71like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); 77like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" );
72like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); 78like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
73 79
74# Same as before, hopefully uptime is higher than 2 seconds so no warning 80# Same as before, hopefully uptime is higher than 2 seconds so no warning
@@ -76,7 +82,7 @@ $result = NPTest->testCmd(
76 "./check_uptime -w 2:111222d -c 1:222333d" 82 "./check_uptime -w 2:111222d -c 1:222333d"
77 ); 83 );
78cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" ); 84cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" );
79like ( $result->output, '/^OK: uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" ); 85like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" );
80like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); 86like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
81 87
82# Same as before, now the low warning should trigger 88# Same as before, now the low warning should trigger
@@ -84,7 +90,7 @@ $result = NPTest->testCmd(
84 "./check_uptime -w 111221d:111222d -c 1:222333d" 90 "./check_uptime -w 111221d:111222d -c 1:222333d"
85 ); 91 );
86cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" ); 92cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" );
87like ( $result->output, '/^WARNING: uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" ); 93like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" );
88like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" ); 94like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" );
89like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); 95like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
90 96
@@ -93,7 +99,7 @@ $result = NPTest->testCmd(
93 "./check_uptime -w 111221d:111222d -c 111220d:222333d" 99 "./check_uptime -w 111221d:111222d -c 111220d:222333d"
94 ); 100 );
95cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" ); 101cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" );
96like ( $result->output, '/^CRITICAL: uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" ); 102like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" );
97like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" ); 103like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" );
98like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); 104like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" );
99 105
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in
index 386831e..c84769f 100644
--- a/plugins-scripts/utils.pm.in
+++ b/plugins-scripts/utils.pm.in
@@ -23,6 +23,7 @@ $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ;
23$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; 23$PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ;
24$PATH_TO_MAILQ = "@PATH_TO_MAILQ@"; 24$PATH_TO_MAILQ = "@PATH_TO_MAILQ@";
25$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@"; 25$PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@";
26$PATH_TO_SNMPGET = "@PATH_TO_SNMPGET@";
26 27
27## common variables 28## common variables
28$TIMEOUT = 15; 29$TIMEOUT = 15;
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 3fde54d..49086b7 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -51,10 +51,10 @@ noinst_LIBRARIES = libnpcommon.a
51libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \ 51libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \
52 popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h 52 popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h
53 53
54BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a 54BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
55NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS) 55NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS)
56NETLIBS = $(NETOBJS) $(SOCKETLIBS) 56NETLIBS = $(NETOBJS) $(SOCKETLIBS)
57SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) 57SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) $(LIB_CRYPTO)
58 58
59TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) 59TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir)
60 60
@@ -112,7 +112,7 @@ check_tcp_LDADD = $(SSLOBJS)
112check_time_LDADD = $(NETLIBS) 112check_time_LDADD = $(NETLIBS)
113check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS) 113check_ntp_time_LDADD = $(NETLIBS) $(MATHLIBS)
114check_ups_LDADD = $(NETLIBS) 114check_ups_LDADD = $(NETLIBS)
115check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) 115check_users_LDADD = $(BASEOBJS) $(WTSAPI32LIBS) $(SYSTEMDLIBS)
116check_by_ssh_LDADD = $(NETLIBS) 116check_by_ssh_LDADD = $(NETLIBS)
117check_ide_smart_LDADD = $(BASEOBJS) 117check_ide_smart_LDADD = $(BASEOBJS)
118negate_LDADD = $(BASEOBJS) 118negate_LDADD = $(BASEOBJS)
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index d7be575..fa982ae 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -1,32 +1,32 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_apt plugin 3* Monitoring check_apt plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2006-2008 Monitoring Plugins Development Team 6* Copyright (c) 2006-2008 Monitoring Plugins Development Team
7* 7*
8* Original author: Sean Finney 8* Original author: Sean Finney
9* 9*
10* Description: 10* Description:
11* 11*
12* This file contains the check_apt plugin 12* This file contains the check_apt plugin
13* 13*
14* Check for available updates in apt package management systems 14* Check for available updates in apt package management systems
15* 15*
16* 16*
17* This program is free software: you can redistribute it and/or modify 17* This program is free software: you can redistribute it and/or modify
18* it under the terms of the GNU General Public License as published by 18* it under the terms of the GNU General Public License as published by
19* the Free Software Foundation, either version 3 of the License, or 19* the Free Software Foundation, either version 3 of the License, or
20* (at your option) any later version. 20* (at your option) any later version.
21* 21*
22* This program is distributed in the hope that it will be useful, 22* This program is distributed in the hope that it will be useful,
23* but WITHOUT ANY WARRANTY; without even the implied warranty of 23* but WITHOUT ANY WARRANTY; without even the implied warranty of
24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25* GNU General Public License for more details. 25* GNU General Public License for more details.
26* 26*
27* You should have received a copy of the GNU General Public License 27* You should have received a copy of the GNU General Public License
28* along with this program. If not, see <http://www.gnu.org/licenses/>. 28* along with this program. If not, see <http://www.gnu.org/licenses/>.
29* 29*
30*****************************************************************************/ 30*****************************************************************************/
31 31
32const char *progname = "check_apt"; 32const char *progname = "check_apt";
@@ -76,9 +76,9 @@ int cmpstringp(const void *p1, const void *p2);
76 76
77/* configuration variables */ 77/* configuration variables */
78static int verbose = 0; /* -v */ 78static int verbose = 0; /* -v */
79static int list = 0; /* list packages available for upgrade */ 79static bool list = false; /* list packages available for upgrade */
80static int do_update = 0; /* whether to call apt-get update */ 80static bool do_update = false; /* whether to call apt-get update */
81static int only_critical = 0; /* whether to warn about non-critical updates */ 81static bool only_critical = false; /* whether to warn about non-critical updates */
82static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */ 82static upgrade_type upgrade = UPGRADE; /* which type of upgrade to do */
83static char *upgrade_opts = NULL; /* options to override defaults for upgrade */ 83static char *upgrade_opts = NULL; /* options to override defaults for upgrade */
84static char *update_opts = NULL; /* options to override defaults for update */ 84static char *update_opts = NULL; /* options to override defaults for update */
@@ -119,7 +119,7 @@ int main (int argc, char **argv) {
119 119
120 if(sec_count > 0){ 120 if(sec_count > 0){
121 result = max_state(result, STATE_CRITICAL); 121 result = max_state(result, STATE_CRITICAL);
122 } else if(packages_available >= packages_warning && only_critical == 0){ 122 } else if(packages_available >= packages_warning && only_critical == false){
123 result = max_state(result, STATE_WARNING); 123 result = max_state(result, STATE_WARNING);
124 } else if(result > STATE_UNKNOWN){ 124 } else if(result > STATE_UNKNOWN){
125 result = STATE_UNKNOWN; 125 result = STATE_UNKNOWN;
@@ -144,7 +144,7 @@ int main (int argc, char **argv) {
144 144
145 for(i = 0; i < sec_count; i++) 145 for(i = 0; i < sec_count; i++)
146 printf("%s (security)\n", secpackages_list[i]); 146 printf("%s (security)\n", secpackages_list[i]);
147 if (only_critical == 0) { 147 if (only_critical == false) {
148 for(i = 0; i < packages_available - sec_count; i++) 148 for(i = 0; i < packages_available - sec_count; i++)
149 printf("%s\n", packages_list[i]); 149 printf("%s\n", packages_list[i]);
150 } 150 }
@@ -166,7 +166,7 @@ int process_arguments (int argc, char **argv) {
166 {"upgrade", optional_argument, 0, 'U'}, 166 {"upgrade", optional_argument, 0, 'U'},
167 {"no-upgrade", no_argument, 0, 'n'}, 167 {"no-upgrade", no_argument, 0, 'n'},
168 {"dist-upgrade", optional_argument, 0, 'd'}, 168 {"dist-upgrade", optional_argument, 0, 'd'},
169 {"list", no_argument, 0, 'l'}, 169 {"list", no_argument, false, 'l'},
170 {"include", required_argument, 0, 'i'}, 170 {"include", required_argument, 0, 'i'},
171 {"exclude", required_argument, 0, 'e'}, 171 {"exclude", required_argument, 0, 'e'},
172 {"critical", required_argument, 0, 'c'}, 172 {"critical", required_argument, 0, 'c'},
@@ -212,14 +212,14 @@ int process_arguments (int argc, char **argv) {
212 upgrade=NO_UPGRADE; 212 upgrade=NO_UPGRADE;
213 break; 213 break;
214 case 'u': 214 case 'u':
215 do_update=1; 215 do_update=true;
216 if(optarg!=NULL){ 216 if(optarg!=NULL){
217 update_opts=strdup(optarg); 217 update_opts=strdup(optarg);
218 if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed"); 218 if(update_opts==NULL) die(STATE_UNKNOWN, "strdup failed");
219 } 219 }
220 break; 220 break;
221 case 'l': 221 case 'l':
222 list=1; 222 list=true;
223 break; 223 break;
224 case 'i': 224 case 'i':
225 do_include=add_to_regexp(do_include, optarg); 225 do_include=add_to_regexp(do_include, optarg);
@@ -231,7 +231,7 @@ int process_arguments (int argc, char **argv) {
231 do_critical=add_to_regexp(do_critical, optarg); 231 do_critical=add_to_regexp(do_critical, optarg);
232 break; 232 break;
233 case 'o': 233 case 'o':
234 only_critical=1; 234 only_critical=true;
235 break; 235 break;
236 case INPUT_FILE_OPT: 236 case INPUT_FILE_OPT:
237 input_filename = optarg; 237 input_filename = optarg;
@@ -269,7 +269,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
269 die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf); 269 die(STATE_UNKNOWN, _("%s: Error compiling regexp: %s"), progname, rerrbuf);
270 } 270 }
271 } 271 }
272 272
273 if(do_exclude!=NULL){ 273 if(do_exclude!=NULL){
274 regres=regcomp(&ereg, do_exclude, REG_EXTENDED); 274 regres=regcomp(&ereg, do_exclude, REG_EXTENDED);
275 if(regres!=0) { 275 if(regres!=0) {
@@ -278,7 +278,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
278 progname, rerrbuf); 278 progname, rerrbuf);
279 } 279 }
280 } 280 }
281 281
282 const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE; 282 const char *crit_ptr = (do_critical != NULL) ? do_critical : SECURITY_RE;
283 regres=regcomp(&sreg, crit_ptr, REG_EXTENDED); 283 regres=regcomp(&sreg, crit_ptr, REG_EXTENDED);
284 if(regres!=0) { 284 if(regres!=0) {
@@ -295,7 +295,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
295 /* run the upgrade */ 295 /* run the upgrade */
296 result = np_runcmd(cmdline, &chld_out, &chld_err, 0); 296 result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
297 } 297 }
298 298
299 /* apt-get upgrade only changes exit status if there is an 299 /* apt-get upgrade only changes exit status if there is an
300 * internal error when run in dry-run mode. therefore we will 300 * internal error when run in dry-run mode. therefore we will
301 * treat such an error as UNKNOWN */ 301 * treat such an error as UNKNOWN */
@@ -371,7 +371,7 @@ int run_update(void){
371 struct output chld_out, chld_err; 371 struct output chld_out, chld_err;
372 char *cmdline; 372 char *cmdline;
373 373
374 /* run the upgrade */ 374 /* run the update */
375 cmdline = construct_cmdline(NO_UPGRADE, update_opts); 375 cmdline = construct_cmdline(NO_UPGRADE, update_opts);
376 result = np_runcmd(cmdline, &chld_out, &chld_err, 0); 376 result = np_runcmd(cmdline, &chld_out, &chld_err, 0);
377 /* apt-get update changes exit status if it can't fetch packages. 377 /* apt-get update changes exit status if it can't fetch packages.
@@ -501,16 +501,6 @@ print_help (void)
501 501
502 printf(UT_PLUG_TIMEOUT, timeout_interval); 502 printf(UT_PLUG_TIMEOUT, timeout_interval);
503 503
504 printf (" %s\n", "-U, --upgrade=OPTS");
505 printf (" %s\n", _("[Default] Perform an upgrade. If an optional OPTS argument is provided,"));
506 printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
507 printf (" %s", _("default "));
508 printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
509 printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
510 printf (" %s\n", _("the default options."));
511 printf (" %s\n", "-d, --dist-upgrade=OPTS");
512 printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
513 printf (" %s\n", _("can be provided to override the default options."));
514 printf (" %s\n", "-n, --no-upgrade"); 504 printf (" %s\n", "-n, --no-upgrade");
515 printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least).")); 505 printf (" %s\n", _("Do not run the upgrade. Probably not useful (without -u at least)."));
516 printf (" %s\n", "-l, --list"); 506 printf (" %s\n", "-l, --list");
@@ -530,7 +520,7 @@ print_help (void)
530 printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified")); 520 printf (" %s\n", _("this REGEXP, the plugin will return CRITICAL status. Can be specified"));
531 printf (" %s\n", _("multiple times like above. Default is a regexp matching security")); 521 printf (" %s\n", _("multiple times like above. Default is a regexp matching security"));
532 printf (" %s\n", _("upgrades for Debian and Ubuntu:")); 522 printf (" %s\n", _("upgrades for Debian and Ubuntu:"));
533 printf (" \t\%s\n", SECURITY_RE); 523 printf (" \t%s\n", SECURITY_RE);
534 printf (" %s\n", _("Note that the package must first match the include list before its")); 524 printf (" %s\n", _("Note that the package must first match the include list before its"));
535 printf (" %s\n", _("information is compared against the critical list.")); 525 printf (" %s\n", _("information is compared against the critical list."));
536 printf (" %s\n", "-o, --only-critical"); 526 printf (" %s\n", "-o, --only-critical");
@@ -538,7 +528,7 @@ print_help (void)
538 printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause")); 528 printf (" %s\n", _("of upgrades will be printed, but any non-critical upgrades will not cause"));
539 printf (" %s\n", _("the plugin to return WARNING status.")); 529 printf (" %s\n", _("the plugin to return WARNING status."));
540 printf (" %s\n", "-w, --packages-warning"); 530 printf (" %s\n", "-w, --packages-warning");
541 printf (" %s\n", _("Minumum number of packages available for upgrade to return WARNING status.")); 531 printf (" %s\n", _("Minimum number of packages available for upgrade to return WARNING status."));
542 printf (" %s\n\n", _("Default is 1 package.")); 532 printf (" %s\n\n", _("Default is 1 package."));
543 533
544 printf ("%s\n\n", _("The following options require root privileges and should be used with care:")); 534 printf ("%s\n\n", _("The following options require root privileges and should be used with care:"));
@@ -547,6 +537,16 @@ print_help (void)
547 printf (" %s\n", _("the default options. Note: you may also need to adjust the global")); 537 printf (" %s\n", _("the default options. Note: you may also need to adjust the global"));
548 printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get")); 538 printf (" %s\n", _("timeout (with -t) to prevent the plugin from timing out if apt-get"));
549 printf (" %s\n", _("upgrade is expected to take longer than the default timeout.")); 539 printf (" %s\n", _("upgrade is expected to take longer than the default timeout."));
540 printf (" %s\n", "-U, --upgrade=OPTS");
541 printf (" %s\n", _("Perform an upgrade. If an optional OPTS argument is provided,"));
542 printf (" %s\n", _("apt-get will be run with these command line options instead of the"));
543 printf (" %s", _("default "));
544 printf ("(%s).\n", UPGRADE_DEFAULT_OPTS);
545 printf (" %s\n", _("Note that you may be required to have root privileges if you do not use"));
546 printf (" %s\n", _("the default options, which will only run a simulation and NOT perform the upgrade"));
547 printf (" %s\n", "-d, --dist-upgrade=OPTS");
548 printf (" %s\n", _("Perform a dist-upgrade instead of normal upgrade. Like with -U OPTS"));
549 printf (" %s\n", _("can be provided to override the default options."));
550 550
551 printf(UT_SUPPORT); 551 printf(UT_SUPPORT);
552} 552}
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 485bf3b..1ad547e 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -49,6 +49,8 @@ unsigned int commands = 0;
49unsigned int services = 0; 49unsigned int services = 0;
50int skip_stdout = 0; 50int skip_stdout = 0;
51int skip_stderr = 0; 51int skip_stderr = 0;
52int warn_on_stderr = 0;
53bool unknown_timeout = FALSE;
52char *remotecmd = NULL; 54char *remotecmd = NULL;
53char **commargv = NULL; 55char **commargv = NULL;
54int commargc = 0; 56int commargc = 0;
@@ -100,6 +102,13 @@ main (int argc, char **argv)
100 102
101 result = cmd_run_array (commargv, &chld_out, &chld_err, 0); 103 result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
102 104
105 /* SSH returns 255 if connection attempt fails; include the first line of error output */
106 if (result == 255 && unknown_timeout) {
107 printf (_("SSH connection failed: %s\n"),
108 chld_err.lines > 0 ? chld_err.line[0] : "(no error output)");
109 return STATE_UNKNOWN;
110 }
111
103 if (verbose) { 112 if (verbose) {
104 for(i = 0; i < chld_out.lines; i++) 113 for(i = 0; i < chld_out.lines; i++)
105 printf("stdout: %s\n", chld_out.line[i]); 114 printf("stdout: %s\n", chld_out.line[i]);
@@ -116,7 +125,10 @@ main (int argc, char **argv)
116 if(chld_err.lines > skip_stderr) { 125 if(chld_err.lines > skip_stderr) {
117 printf (_("Remote command execution failed: %s\n"), 126 printf (_("Remote command execution failed: %s\n"),
118 chld_err.line[skip_stderr]); 127 chld_err.line[skip_stderr]);
119 return max_state_alt(result, STATE_UNKNOWN); 128 if ( warn_on_stderr )
129 return max_state_alt(result, STATE_WARNING);
130 else
131 return max_state_alt(result, STATE_UNKNOWN);
120 } 132 }
121 133
122 /* this is simple if we're not supposed to be passive. 134 /* this is simple if we're not supposed to be passive.
@@ -176,6 +188,7 @@ process_arguments (int argc, char **argv)
176 {"verbose", no_argument, 0, 'v'}, 188 {"verbose", no_argument, 0, 'v'},
177 {"fork", no_argument, 0, 'f'}, 189 {"fork", no_argument, 0, 'f'},
178 {"timeout", required_argument, 0, 't'}, 190 {"timeout", required_argument, 0, 't'},
191 {"unknown-timeout", no_argument, 0, 'U'},
179 {"host", required_argument, 0, 'H'}, /* backward compatibility */ 192 {"host", required_argument, 0, 'H'}, /* backward compatibility */
180 {"hostname", required_argument, 0, 'H'}, 193 {"hostname", required_argument, 0, 'H'},
181 {"port", required_argument,0,'p'}, 194 {"port", required_argument,0,'p'},
@@ -189,6 +202,7 @@ process_arguments (int argc, char **argv)
189 {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */ 202 {"skip", optional_argument, 0, 'S'}, /* backwards compatibility */
190 {"skip-stdout", optional_argument, 0, 'S'}, 203 {"skip-stdout", optional_argument, 0, 'S'},
191 {"skip-stderr", optional_argument, 0, 'E'}, 204 {"skip-stderr", optional_argument, 0, 'E'},
205 {"warn-on-stderr", no_argument, 0, 'W'},
192 {"proto1", no_argument, 0, '1'}, 206 {"proto1", no_argument, 0, '1'},
193 {"proto2", no_argument, 0, '2'}, 207 {"proto2", no_argument, 0, '2'},
194 {"use-ipv4", no_argument, 0, '4'}, 208 {"use-ipv4", no_argument, 0, '4'},
@@ -207,7 +221,7 @@ process_arguments (int argc, char **argv)
207 strcpy (argv[c], "-t"); 221 strcpy (argv[c], "-t");
208 222
209 while (1) { 223 while (1) {
210 c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, 224 c = getopt_long (argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
211 &option); 225 &option);
212 226
213 if (c == -1 || c == EOF) 227 if (c == -1 || c == EOF)
@@ -229,6 +243,9 @@ process_arguments (int argc, char **argv)
229 else 243 else
230 timeout_interval = atoi (optarg); 244 timeout_interval = atoi (optarg);
231 break; 245 break;
246 case 'U':
247 unknown_timeout = TRUE;
248 break;
232 case 'H': /* host */ 249 case 'H': /* host */
233 hostname = optarg; 250 hostname = optarg;
234 break; 251 break;
@@ -307,6 +324,9 @@ process_arguments (int argc, char **argv)
307 else 324 else
308 skip_stderr = atoi (optarg); 325 skip_stderr = atoi (optarg);
309 break; 326 break;
327 case 'W': /* exit with warning if there is an output on stderr */
328 warn_on_stderr = 1;
329 break;
310 case 'o': /* Extra options for the ssh command */ 330 case 'o': /* Extra options for the ssh command */
311 comm_append("-o"); 331 comm_append("-o");
312 comm_append(optarg); 332 comm_append(optarg);
@@ -413,6 +433,8 @@ print_help (void)
413 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]")); 433 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDOUT [optional]"));
414 printf (" %s\n", "-E, --skip-stderr[=n]"); 434 printf (" %s\n", "-E, --skip-stderr[=n]");
415 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]")); 435 printf (" %s\n", _("Ignore all or (if specified) first n lines on STDERR [optional]"));
436 printf (" %s\n", "-W, --warn-on-stderr]");
437 printf (" %s\n", _("Exit with an warning, if there is an output on STDERR"));
416 printf (" %s\n", "-f"); 438 printf (" %s\n", "-f");
417 printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed")); 439 printf (" %s\n", _("tells ssh to fork rather than create a tty [optional]. This will always return OK if ssh is executed"));
418 printf (" %s\n","-C, --command='COMMAND STRING'"); 440 printf (" %s\n","-C, --command='COMMAND STRING'");
@@ -435,6 +457,8 @@ print_help (void)
435 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); 457 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
436 printf (UT_WARN_CRIT); 458 printf (UT_WARN_CRIT);
437 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 459 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
460 printf (" %s\n","-U, --unknown-timeout");
461 printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
438 printf (UT_VERBOSE); 462 printf (UT_VERBOSE);
439 printf("\n"); 463 printf("\n");
440 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); 464 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with"));
@@ -464,8 +488,8 @@ void
464print_usage (void) 488print_usage (void)
465{ 489{
466 printf ("%s\n", _("Usage:")); 490 printf ("%s\n", _("Usage:"));
467 printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" 491 printf (" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n"
468 " [-S [lines]] [-E [lines]] [-t timeout] [-i identity]\n" 492 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n"
469 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" 493 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
470 " [-p port] [-o ssh-option] [-F configfile]\n", 494 " [-p port] [-o ssh-option] [-F configfile]\n",
471 progname); 495 progname);
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 5990b95..d0871c4 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -37,6 +37,7 @@ const char *progname = "check_curl";
37const char *copyright = "2006-2019"; 37const char *copyright = "2006-2019";
38const char *email = "devel@monitoring-plugins.org"; 38const char *email = "devel@monitoring-plugins.org";
39 39
40#include <stdbool.h>
40#include <ctype.h> 41#include <ctype.h>
41 42
42#include "common.h" 43#include "common.h"
@@ -54,6 +55,7 @@ const char *email = "devel@monitoring-plugins.org";
54#include "uriparser/Uri.h" 55#include "uriparser/Uri.h"
55 56
56#include <arpa/inet.h> 57#include <arpa/inet.h>
58#include <netinet/in.h>
57 59
58#if defined(HAVE_SSL) && defined(USE_OPENSSL) 60#if defined(HAVE_SSL) && defined(USE_OPENSSL)
59#include <openssl/opensslv.h> 61#include <openssl/opensslv.h>
@@ -66,13 +68,13 @@ const char *email = "devel@monitoring-plugins.org";
66#define DEFAULT_BUFFER_SIZE 2048 68#define DEFAULT_BUFFER_SIZE 2048
67#define DEFAULT_SERVER_URL "/" 69#define DEFAULT_SERVER_URL "/"
68#define HTTP_EXPECT "HTTP/" 70#define HTTP_EXPECT "HTTP/"
69#define DEFAULT_MAX_REDIRS 15
70#define INET_ADDR_MAX_SIZE INET6_ADDRSTRLEN 71#define INET_ADDR_MAX_SIZE INET6_ADDRSTRLEN
71enum { 72enum {
72 MAX_IPV4_HOSTLENGTH = 255, 73 MAX_IPV4_HOSTLENGTH = 255,
73 HTTP_PORT = 80, 74 HTTP_PORT = 80,
74 HTTPS_PORT = 443, 75 HTTPS_PORT = 443,
75 MAX_PORT = 65535 76 MAX_PORT = 65535,
77 DEFAULT_MAX_REDIRS = 15
76}; 78};
77 79
78enum { 80enum {
@@ -131,14 +133,14 @@ regmatch_t pmatch[REGS];
131char regexp[MAX_RE_SIZE]; 133char regexp[MAX_RE_SIZE];
132int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; 134int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE;
133int errcode; 135int errcode;
134int invert_regex = 0; 136bool invert_regex = false;
135 137
136char *server_address = NULL; 138char *server_address = NULL;
137char *host_name = NULL; 139char *host_name = NULL;
138char *server_url = 0; 140char *server_url = 0;
139char server_ip[DEFAULT_BUFFER_SIZE]; 141char server_ip[DEFAULT_BUFFER_SIZE];
140struct curl_slist *server_ips = NULL; 142struct curl_slist *server_ips = NULL;
141int specify_port = FALSE; 143bool specify_port = false;
142unsigned short server_port = HTTP_PORT; 144unsigned short server_port = HTTP_PORT;
143unsigned short virtual_port = 0; 145unsigned short virtual_port = 0;
144int host_name_length; 146int host_name_length;
@@ -150,8 +152,8 @@ int days_till_exp_warn, days_till_exp_crit;
150thresholds *thlds; 152thresholds *thlds;
151char user_agent[DEFAULT_BUFFER_SIZE]; 153char user_agent[DEFAULT_BUFFER_SIZE];
152int verbose = 0; 154int verbose = 0;
153int show_extended_perfdata = FALSE; 155bool show_extended_perfdata = false;
154int show_body = FALSE; 156bool show_body = false;
155int min_page_len = 0; 157int min_page_len = 0;
156int max_page_len = 0; 158int max_page_len = 0;
157int redir_depth = 0; 159int redir_depth = 0;
@@ -160,10 +162,16 @@ char *http_method = NULL;
160char *http_post_data = NULL; 162char *http_post_data = NULL;
161char *http_content_type = NULL; 163char *http_content_type = NULL;
162CURL *curl; 164CURL *curl;
165bool curl_global_initialized = false;
166bool curl_easy_initialized = false;
163struct curl_slist *header_list = NULL; 167struct curl_slist *header_list = NULL;
168bool body_buf_initialized = false;
164curlhelp_write_curlbuf body_buf; 169curlhelp_write_curlbuf body_buf;
170bool header_buf_initialized = false;
165curlhelp_write_curlbuf header_buf; 171curlhelp_write_curlbuf header_buf;
172bool status_line_initialized = false;
166curlhelp_statusline status_line; 173curlhelp_statusline status_line;
174bool put_buf_initialized = false;
167curlhelp_read_curlbuf put_buf; 175curlhelp_read_curlbuf put_buf;
168char http_header[DEFAULT_BUFFER_SIZE]; 176char http_header[DEFAULT_BUFFER_SIZE];
169long code; 177long code;
@@ -173,7 +181,7 @@ double time_connect;
173double time_appconnect; 181double time_appconnect;
174double time_headers; 182double time_headers;
175double time_firstbyte; 183double time_firstbyte;
176char errbuf[CURL_ERROR_SIZE+1]; 184char errbuf[MAX_INPUT_BUFFER];
177CURLcode res; 185CURLcode res;
178char url[DEFAULT_BUFFER_SIZE]; 186char url[DEFAULT_BUFFER_SIZE];
179char msg[DEFAULT_BUFFER_SIZE]; 187char msg[DEFAULT_BUFFER_SIZE];
@@ -186,13 +194,14 @@ char user_auth[MAX_INPUT_BUFFER] = "";
186char proxy_auth[MAX_INPUT_BUFFER] = ""; 194char proxy_auth[MAX_INPUT_BUFFER] = "";
187char **http_opt_headers; 195char **http_opt_headers;
188int http_opt_headers_count = 0; 196int http_opt_headers_count = 0;
189int display_html = FALSE; 197bool display_html = false;
190int onredirect = STATE_OK; 198int onredirect = STATE_OK;
191int followmethod = FOLLOW_HTTP_CURL; 199int followmethod = FOLLOW_HTTP_CURL;
192int followsticky = STICKY_NONE; 200int followsticky = STICKY_NONE;
193int use_ssl = FALSE; 201bool use_ssl = false;
194int use_sni = TRUE; 202bool use_sni = true;
195int check_cert = FALSE; 203bool check_cert = false;
204bool continue_after_check_cert = false;
196typedef union { 205typedef union {
197 struct curl_slist* to_info; 206 struct curl_slist* to_info;
198 struct curl_certinfo* to_certinfo; 207 struct curl_certinfo* to_certinfo;
@@ -202,19 +211,20 @@ int ssl_version = CURL_SSLVERSION_DEFAULT;
202char *client_cert = NULL; 211char *client_cert = NULL;
203char *client_privkey = NULL; 212char *client_privkey = NULL;
204char *ca_cert = NULL; 213char *ca_cert = NULL;
205int verify_peer_and_host = FALSE; 214bool verify_peer_and_host = false;
206int is_openssl_callback = FALSE; 215bool is_openssl_callback = false;
207#if defined(HAVE_SSL) && defined(USE_OPENSSL) 216#if defined(HAVE_SSL) && defined(USE_OPENSSL)
208X509 *cert = NULL; 217X509 *cert = NULL;
209#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */ 218#endif /* defined(HAVE_SSL) && defined(USE_OPENSSL) */
210int no_body = FALSE; 219bool no_body = false;
211int maximum_age = -1; 220int maximum_age = -1;
212int address_family = AF_UNSPEC; 221int address_family = AF_UNSPEC;
213curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN; 222curlhelp_ssl_library ssl_library = CURLHELP_SSL_LIBRARY_UNKNOWN;
214int curl_http_version = CURL_HTTP_VERSION_NONE; 223int curl_http_version = CURL_HTTP_VERSION_NONE;
215int automatic_decompression = FALSE; 224bool automatic_decompression = false;
225char *cookie_jar_file = NULL;
216 226
217int process_arguments (int, char**); 227bool process_arguments (int, char**);
218void handle_curl_option_return_code (CURLcode res, const char* option); 228void handle_curl_option_return_code (CURLcode res, const char* option);
219int check_http (void); 229int check_http (void);
220void redir (curlhelp_write_curlbuf*); 230void redir (curlhelp_write_curlbuf*);
@@ -234,7 +244,7 @@ void curlhelp_freewritebuffer (curlhelp_write_curlbuf*);
234int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t); 244int curlhelp_initreadbuffer (curlhelp_read_curlbuf *, const char *, size_t);
235int curlhelp_buffer_read_callback (void *, size_t , size_t , void *); 245int curlhelp_buffer_read_callback (void *, size_t , size_t , void *);
236void curlhelp_freereadbuffer (curlhelp_read_curlbuf *); 246void curlhelp_freereadbuffer (curlhelp_read_curlbuf *);
237curlhelp_ssl_library curlhelp_get_ssl_library (CURL*); 247curlhelp_ssl_library curlhelp_get_ssl_library ();
238const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library); 248const char* curlhelp_get_ssl_library_string (curlhelp_ssl_library);
239int net_noopenssl_check_certificate (cert_ptr_union*, int, int); 249int net_noopenssl_check_certificate (cert_ptr_union*, int, int);
240 250
@@ -268,10 +278,10 @@ main (int argc, char **argv)
268 progname, NP_VERSION, VERSION, curl_version()); 278 progname, NP_VERSION, VERSION, curl_version());
269 279
270 /* parse arguments */ 280 /* parse arguments */
271 if (process_arguments (argc, argv) == ERROR) 281 if (process_arguments (argc, argv) == false)
272 usage4 (_("Could not parse arguments")); 282 usage4 (_("Could not parse arguments"));
273 283
274 if (display_html == TRUE) 284 if (display_html)
275 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", 285 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
276 use_ssl ? "https" : "http", 286 use_ssl ? "https" : "http",
277 host_name ? host_name : server_address, 287 host_name ? host_name : server_address,
@@ -287,6 +297,7 @@ main (int argc, char **argv)
287 297
288int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx) 298int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
289{ 299{
300 (void) preverify_ok;
290 /* TODO: we get all certificates of the chain, so which ones 301 /* TODO: we get all certificates of the chain, so which ones
291 * should we test? 302 * should we test?
292 * TODO: is the last certificate always the server certificate? 303 * TODO: is the last certificate always the server certificate?
@@ -311,6 +322,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
311 322
312CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm) 323CURLcode sslctxfun(CURL *curl, SSL_CTX *sslctx, void *parm)
313{ 324{
325 (void) curl; // ignore unused parameter
326 (void) parm; // ignore unused parameter
314 SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback); 327 SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, verify_callback);
315 328
316 return CURLE_OK; 329 return CURLE_OK;
@@ -365,8 +378,12 @@ void
365handle_curl_option_return_code (CURLcode res, const char* option) 378handle_curl_option_return_code (CURLcode res, const char* option)
366{ 379{
367 if (res != CURLE_OK) { 380 if (res != CURLE_OK) {
368 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Error while setting cURL option '%s': cURL returned %d - %s"), 381 snprintf (msg,
369 option, res, curl_easy_strerror(res)); 382 DEFAULT_BUFFER_SIZE,
383 _("Error while setting cURL option '%s': cURL returned %d - %s"),
384 option,
385 res,
386 curl_easy_strerror(res));
370 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 387 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
371 } 388 }
372} 389}
@@ -375,8 +392,11 @@ int
375lookup_host (const char *host, char *buf, size_t buflen) 392lookup_host (const char *host, char *buf, size_t buflen)
376{ 393{
377 struct addrinfo hints, *res, *result; 394 struct addrinfo hints, *res, *result;
395 char addrstr[100];
396 size_t addrstr_len;
378 int errcode; 397 int errcode;
379 void *ptr; 398 void *ptr;
399 size_t buflen_remaining = buflen - 1;
380 400
381 memset (&hints, 0, sizeof (hints)); 401 memset (&hints, 0, sizeof (hints));
382 hints.ai_family = address_family; 402 hints.ai_family = address_family;
@@ -386,31 +406,62 @@ lookup_host (const char *host, char *buf, size_t buflen)
386 errcode = getaddrinfo (host, NULL, &hints, &result); 406 errcode = getaddrinfo (host, NULL, &hints, &result);
387 if (errcode != 0) 407 if (errcode != 0)
388 return errcode; 408 return errcode;
389 409
410 strcpy(buf, "");
390 res = result; 411 res = result;
391 412
392 while (res) { 413 while (res) {
393 inet_ntop (res->ai_family, res->ai_addr->sa_data, buf, buflen); 414 switch (res->ai_family) {
394 switch (res->ai_family) { 415 case AF_INET:
395 case AF_INET: 416 ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
396 ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr; 417 break;
397 break; 418 case AF_INET6:
398 case AF_INET6: 419 ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
399 ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr; 420 break;
400 break;
401 } 421 }
402 inet_ntop (res->ai_family, ptr, buf, buflen); 422
403 if (verbose >= 1) 423 inet_ntop (res->ai_family, ptr, addrstr, 100);
424 if (verbose >= 1) {
404 printf ("* getaddrinfo IPv%d address: %s\n", 425 printf ("* getaddrinfo IPv%d address: %s\n",
405 res->ai_family == PF_INET6 ? 6 : 4, buf); 426 res->ai_family == PF_INET6 ? 6 : 4, addrstr);
427 }
428
429 // Append all IPs to buf as a comma-separated string
430 addrstr_len = strlen(addrstr);
431 if (buflen_remaining > addrstr_len + 1) {
432 if (buf[0] != '\0') {
433 strncat(buf, ",", buflen_remaining);
434 buflen_remaining -= 1;
435 }
436 strncat(buf, addrstr, buflen_remaining);
437 buflen_remaining -= addrstr_len;
438 }
439
406 res = res->ai_next; 440 res = res->ai_next;
407 } 441 }
408 442
409 freeaddrinfo(result); 443 freeaddrinfo(result);
410 444
411 return 0; 445 return 0;
412} 446}
413 447
448static void
449cleanup (void)
450{
451 if (status_line_initialized) curlhelp_free_statusline(&status_line);
452 status_line_initialized = false;
453 if (curl_easy_initialized) curl_easy_cleanup (curl);
454 curl_easy_initialized = false;
455 if (curl_global_initialized) curl_global_cleanup ();
456 curl_global_initialized = false;
457 if (body_buf_initialized) curlhelp_freewritebuffer (&body_buf);
458 body_buf_initialized = false;
459 if (header_buf_initialized) curlhelp_freewritebuffer (&header_buf);
460 header_buf_initialized = false;
461 if (put_buf_initialized) curlhelp_freereadbuffer (&put_buf);
462 put_buf_initialized = false;
463}
464
414int 465int
415check_http (void) 466check_http (void)
416{ 467{
@@ -419,18 +470,24 @@ check_http (void)
419 int i; 470 int i;
420 char *force_host_header = NULL; 471 char *force_host_header = NULL;
421 struct curl_slist *host = NULL; 472 struct curl_slist *host = NULL;
422 char addrstr[100]; 473 char addrstr[DEFAULT_BUFFER_SIZE/2];
423 char dnscache[DEFAULT_BUFFER_SIZE]; 474 char dnscache[DEFAULT_BUFFER_SIZE];
424 475
425 /* initialize curl */ 476 /* initialize curl */
426 if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK) 477 if (curl_global_init (CURL_GLOBAL_DEFAULT) != CURLE_OK)
427 die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_global_init failed\n"); 478 die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_global_init failed\n");
479 curl_global_initialized = true;
428 480
429 if ((curl = curl_easy_init()) == NULL) 481 if ((curl = curl_easy_init()) == NULL) {
430 die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_easy_init failed\n"); 482 die (STATE_UNKNOWN, "HTTP UNKNOWN - curl_easy_init failed\n");
483 }
484 curl_easy_initialized = true;
431 485
486 /* register cleanup function to shut down libcurl properly */
487 atexit (cleanup);
488
432 if (verbose >= 1) 489 if (verbose >= 1)
433 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, TRUE), "CURLOPT_VERBOSE"); 490 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_VERBOSE, 1), "CURLOPT_VERBOSE");
434 491
435 /* print everything on stdout like check_http would do */ 492 /* print everything on stdout like check_http would do */
436 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR"); 493 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_STDERR, stdout), "CURLOPT_STDERR");
@@ -445,12 +502,14 @@ check_http (void)
445 /* initialize buffer for body of the answer */ 502 /* initialize buffer for body of the answer */
446 if (curlhelp_initwritebuffer(&body_buf) < 0) 503 if (curlhelp_initwritebuffer(&body_buf) < 0)
447 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n"); 504 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for body\n");
505 body_buf_initialized = true;
448 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_WRITEFUNCTION"); 506 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_WRITEFUNCTION");
449 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void *)&body_buf), "CURLOPT_WRITEDATA"); 507 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void *)&body_buf), "CURLOPT_WRITEDATA");
450 508
451 /* initialize buffer for header of the answer */ 509 /* initialize buffer for header of the answer */
452 if (curlhelp_initwritebuffer( &header_buf ) < 0) 510 if (curlhelp_initwritebuffer( &header_buf ) < 0)
453 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for header\n" ); 511 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating buffer for header\n" );
512 header_buf_initialized = true;
454 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_HEADERFUNCTION"); 513 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_HEADERFUNCTION, (curl_write_callback)curlhelp_buffer_write_callback), "CURLOPT_HEADERFUNCTION");
455 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEHEADER, (void *)&header_buf), "CURLOPT_WRITEHEADER"); 514 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_WRITEHEADER, (void *)&header_buf), "CURLOPT_WRITEHEADER");
456 515
@@ -463,10 +522,14 @@ check_http (void)
463 522
464 // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy 523 // fill dns resolve cache to make curl connect to the given server_address instead of the host_name, only required for ssl, because we use the host_name later on to make SNI happy
465 if(use_ssl && host_name != NULL) { 524 if(use_ssl && host_name != NULL) {
466 if ( (res=lookup_host (server_address, addrstr, 100)) != 0) { 525 if ( (res=lookup_host (server_address, addrstr, DEFAULT_BUFFER_SIZE/2)) != 0) {
467 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"), 526 snprintf (msg,
468 server_address, res, gai_strerror (res)); 527 DEFAULT_BUFFER_SIZE,
469 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 528 _("Unable to lookup IP address for '%s': getaddrinfo returned %d - %s"),
529 server_address,
530 res,
531 gai_strerror (res));
532 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
470 } 533 }
471 snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, addrstr); 534 snprintf (dnscache, DEFAULT_BUFFER_SIZE, "%s:%d:%s", host_name, server_port, addrstr);
472 host = curl_slist_append(NULL, dnscache); 535 host = curl_slist_append(NULL, dnscache);
@@ -475,10 +538,22 @@ check_http (void)
475 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache); 538 printf ("* curl CURLOPT_RESOLVE: %s\n", dnscache);
476 } 539 }
477 540
541 // If server_address is an IPv6 address it must be surround by square brackets
542 struct in6_addr tmp_in_addr;
543 if (inet_pton(AF_INET6, server_address, &tmp_in_addr) == 1) {
544 char *new_server_address = malloc(strlen(server_address) + 3);
545 if (new_server_address == NULL) {
546 die(STATE_UNKNOWN, "HTTP UNKNOWN - Unable to allocate memory\n");
547 }
548 snprintf(new_server_address, strlen(server_address)+3, "[%s]", server_address);
549 free(server_address);
550 server_address = new_server_address;
551 }
552
478 /* compose URL: use the address we want to connect to, set Host: header later */ 553 /* compose URL: use the address we want to connect to, set Host: header later */
479 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s", 554 snprintf (url, DEFAULT_BUFFER_SIZE, "%s://%s:%d%s",
480 use_ssl ? "https" : "http", 555 use_ssl ? "https" : "http",
481 use_ssl & host_name != NULL ? host_name : server_address, 556 ( use_ssl & ( host_name != NULL ) ) ? host_name : server_address,
482 server_port, 557 server_port,
483 server_url 558 server_url
484 ); 559 );
@@ -499,7 +574,7 @@ check_http (void)
499 574
500 /* disable body for HEAD request */ 575 /* disable body for HEAD request */
501 if (http_method && !strcmp (http_method, "HEAD" )) { 576 if (http_method && !strcmp (http_method, "HEAD" )) {
502 no_body = TRUE; 577 no_body = true;
503 } 578 }
504 579
505 /* set HTTP protocol version */ 580 /* set HTTP protocol version */
@@ -554,7 +629,7 @@ check_http (void)
554 629
555#ifdef LIBCURL_FEATURE_SSL 630#ifdef LIBCURL_FEATURE_SSL
556 631
557 /* set SSL version, warn about unsecure or unsupported versions */ 632 /* set SSL version, warn about insecure or unsupported versions */
558 if (use_ssl) { 633 if (use_ssl) {
559 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSLVERSION, ssl_version), "CURLOPT_SSLVERSION"); 634 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_SSLVERSION, ssl_version), "CURLOPT_SSLVERSION");
560 } 635 }
@@ -582,7 +657,7 @@ check_http (void)
582 } 657 }
583 658
584 /* detect SSL library used by libcurl */ 659 /* detect SSL library used by libcurl */
585 ssl_library = curlhelp_get_ssl_library (curl); 660 ssl_library = curlhelp_get_ssl_library ();
586 661
587 /* try hard to get a stack of certificates to verify against */ 662 /* try hard to get a stack of certificates to verify against */
588 if (check_cert) { 663 if (check_cert) {
@@ -596,7 +671,7 @@ check_http (void)
596#ifdef USE_OPENSSL 671#ifdef USE_OPENSSL
597 /* libcurl and monitoring plugins built with OpenSSL, good */ 672 /* libcurl and monitoring plugins built with OpenSSL, good */
598 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION"); 673 handle_curl_option_return_code (curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION, sslctxfun), "CURLOPT_SSL_CTX_FUNCTION");
599 is_openssl_callback = TRUE; 674 is_openssl_callback = true;
600#else /* USE_OPENSSL */ 675#else /* USE_OPENSSL */
601#endif /* USE_OPENSSL */ 676#endif /* USE_OPENSSL */
602 /* libcurl is built with OpenSSL, monitoring plugins, so falling 677 /* libcurl is built with OpenSSL, monitoring plugins, so falling
@@ -675,9 +750,11 @@ check_http (void)
675 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_MAXREDIRS, max_depth+1), "CURLOPT_MAXREDIRS"); 750 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_MAXREDIRS, max_depth+1), "CURLOPT_MAXREDIRS");
676 751
677 /* for now allow only http and https (we are a http(s) check plugin in the end) */ 752 /* for now allow only http and https (we are a http(s) check plugin in the end) */
678#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 4) 753#if LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 85, 0)
754 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_REDIR_PROTOCOLS_STR, "http,https"), "CURLOPT_REDIR_PROTOCOLS_STR");
755#elif LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 4)
679 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS), "CURLOPT_REDIRECT_PROTOCOLS"); 756 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS), "CURLOPT_REDIRECT_PROTOCOLS");
680#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 19, 4) */ 757#endif
681 758
682 /* TODO: handle the following aspects of redirection, make them 759 /* TODO: handle the following aspects of redirection, make them
683 * command line options too later: 760 * command line options too later:
@@ -721,11 +798,19 @@ check_http (void)
721 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_POSTFIELDS, http_post_data), "CURLOPT_POSTFIELDS"); 798 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_POSTFIELDS, http_post_data), "CURLOPT_POSTFIELDS");
722 } else if (!strcmp(http_method, "PUT")) { 799 } else if (!strcmp(http_method, "PUT")) {
723 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READFUNCTION, (curl_read_callback)curlhelp_buffer_read_callback), "CURLOPT_READFUNCTION"); 800 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READFUNCTION, (curl_read_callback)curlhelp_buffer_read_callback), "CURLOPT_READFUNCTION");
724 curlhelp_initreadbuffer (&put_buf, http_post_data, strlen (http_post_data)); 801 if (curlhelp_initreadbuffer (&put_buf, http_post_data, strlen (http_post_data)) < 0)
802 die (STATE_UNKNOWN, "HTTP CRITICAL - out of memory allocating read buffer for PUT\n");
803 put_buf_initialized = true;
725 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READDATA, (void *)&put_buf), "CURLOPT_READDATA"); 804 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_READDATA, (void *)&put_buf), "CURLOPT_READDATA");
726 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE"); 805 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_INFILESIZE, (curl_off_t)strlen (http_post_data)), "CURLOPT_INFILESIZE");
727 } 806 }
728 } 807 }
808
809 /* cookie handling */
810 if (cookie_jar_file != NULL) {
811 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEJAR, cookie_jar_file), "CURLOPT_COOKIEJAR");
812 handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_COOKIEFILE, cookie_jar_file), "CURLOPT_COOKIEFILE");
813 }
729 814
730 /* do the request */ 815 /* do the request */
731 res = curl_easy_perform(curl); 816 res = curl_easy_perform(curl);
@@ -736,25 +821,34 @@ check_http (void)
736 /* free header and server IP resolve lists, we don't need it anymore */ 821 /* free header and server IP resolve lists, we don't need it anymore */
737 curl_slist_free_all (header_list); header_list = NULL; 822 curl_slist_free_all (header_list); header_list = NULL;
738 curl_slist_free_all (server_ips); server_ips = NULL; 823 curl_slist_free_all (server_ips); server_ips = NULL;
824 if (host) {
825 curl_slist_free_all (host); host = NULL;
826 }
739 827
740 /* Curl errors, result in critical Nagios state */ 828 /* Curl errors, result in critical Nagios state */
741 if (res != CURLE_OK) { 829 if (res != CURLE_OK) {
742 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"), 830 snprintf (msg,
743 server_port, res, errbuf[0] ? errbuf : curl_easy_strerror(res)); 831 DEFAULT_BUFFER_SIZE,
744 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 832 _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
833 server_port,
834 res,
835 errbuf[0] ? errbuf : curl_easy_strerror(res));
836 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
745 } 837 }
746 838
747 /* certificate checks */ 839 /* certificate checks */
748#ifdef LIBCURL_FEATURE_SSL 840#ifdef LIBCURL_FEATURE_SSL
749 if (use_ssl == TRUE) { 841 if (use_ssl) {
750 if (check_cert == TRUE) { 842 if (check_cert) {
751 if (is_openssl_callback) { 843 if (is_openssl_callback) {
752#ifdef USE_OPENSSL 844#ifdef USE_OPENSSL
753 /* check certificate with OpenSSL functions, curl has been built against OpenSSL 845 /* check certificate with OpenSSL functions, curl has been built against OpenSSL
754 * and we actually have OpenSSL in the monitoring tools 846 * and we actually have OpenSSL in the monitoring tools
755 */ 847 */
756 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); 848 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
757 return result; 849 if (!continue_after_check_cert) {
850 return result;
851 }
758#else /* USE_OPENSSL */ 852#else /* USE_OPENSSL */
759 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n"); 853 die (STATE_CRITICAL, "HTTP CRITICAL - Cannot retrieve certificates - OpenSSL callback used and not linked against OpenSSL\n");
760#endif /* USE_OPENSSL */ 854#endif /* USE_OPENSSL */
@@ -782,30 +876,41 @@ check_http (void)
782 } 876 }
783GOT_FIRST_CERT: 877GOT_FIRST_CERT:
784 if (!raw_cert) { 878 if (!raw_cert) {
785 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot retrieve certificates from CERTINFO information - certificate data was empty")); 879 snprintf (msg,
786 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 880 DEFAULT_BUFFER_SIZE,
881 _("Cannot retrieve certificates from CERTINFO information - certificate data was empty"));
882 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
787 } 883 }
788 BIO* cert_BIO = BIO_new (BIO_s_mem()); 884 BIO* cert_BIO = BIO_new (BIO_s_mem());
789 BIO_write (cert_BIO, raw_cert, strlen(raw_cert)); 885 BIO_write (cert_BIO, raw_cert, strlen(raw_cert));
790 cert = PEM_read_bio_X509 (cert_BIO, NULL, NULL, NULL); 886 cert = PEM_read_bio_X509 (cert_BIO, NULL, NULL, NULL);
791 if (!cert) { 887 if (!cert) {
792 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot read certificate from CERTINFO information - BIO error")); 888 snprintf (msg,
793 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 889 DEFAULT_BUFFER_SIZE,
890 _("Cannot read certificate from CERTINFO information - BIO error"));
891 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
794 } 892 }
795 BIO_free (cert_BIO); 893 BIO_free (cert_BIO);
796 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit); 894 result = np_net_ssl_check_certificate(cert, days_till_exp_warn, days_till_exp_crit);
797 return result; 895 if (!continue_after_check_cert) {
896 return result;
897 }
798#else /* USE_OPENSSL */ 898#else /* USE_OPENSSL */
799 /* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal, 899 /* We assume we don't have OpenSSL and np_net_ssl_check_certificate at our disposal,
800 * so we use the libcurl CURLINFO data 900 * so we use the libcurl CURLINFO data
801 */ 901 */
802 result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit); 902 result = net_noopenssl_check_certificate(&cert_ptr, days_till_exp_warn, days_till_exp_crit);
803 return result; 903 if (!continue_after_check_cert) {
904 return result;
905 }
804#endif /* USE_OPENSSL */ 906#endif /* USE_OPENSSL */
805 } else { 907 } else {
806 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Cannot retrieve certificates - cURL returned %d - %s"), 908 snprintf (msg,
807 res, curl_easy_strerror(res)); 909 DEFAULT_BUFFER_SIZE,
808 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 910 _("Cannot retrieve certificates - cURL returned %d - %s"),
911 res,
912 curl_easy_strerror(res));
913 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
809 } 914 }
810 } 915 }
811 } 916 }
@@ -826,7 +931,7 @@ GOT_FIRST_CERT:
826 perfd_time(total_time), 931 perfd_time(total_time),
827 perfd_size(page_len), 932 perfd_size(page_len),
828 perfd_time_connect(time_connect), 933 perfd_time_connect(time_connect),
829 use_ssl == TRUE ? perfd_time_ssl (time_appconnect-time_connect) : "", 934 use_ssl ? perfd_time_ssl (time_appconnect-time_connect) : "",
830 perfd_time_headers(time_headers - time_appconnect), 935 perfd_time_headers(time_headers - time_appconnect),
831 perfd_time_firstbyte(time_firstbyte - time_headers), 936 perfd_time_firstbyte(time_firstbyte - time_headers),
832 perfd_time_transfer(total_time-time_firstbyte) 937 perfd_time_transfer(total_time-time_firstbyte)
@@ -844,11 +949,15 @@ GOT_FIRST_CERT:
844 949
845 /* get status line of answer, check sanity of HTTP code */ 950 /* get status line of answer, check sanity of HTTP code */
846 if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) { 951 if (curlhelp_parse_statusline (header_buf.buf, &status_line) < 0) {
847 snprintf (msg, DEFAULT_BUFFER_SIZE, "Unparsable status line in %.3g seconds response time|%s\n", 952 snprintf (msg,
848 total_time, perfstring); 953 DEFAULT_BUFFER_SIZE,
954 "Unparsable status line in %.3g seconds response time|%s\n",
955 total_time,
956 perfstring);
849 /* we cannot know the major/minor version here for sure as we cannot parse the first line */ 957 /* we cannot know the major/minor version here for sure as we cannot parse the first line */
850 die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg); 958 die (STATE_CRITICAL, "HTTP CRITICAL HTTP/x.x %ld unknown - %s", code, msg);
851 } 959 }
960 status_line_initialized = true;
852 961
853 /* get result code from cURL */ 962 /* get result code from cURL */
854 handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE"); 963 handle_curl_option_return_code (curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &code), "CURLINFO_RESPONSE_CODE");
@@ -864,9 +973,16 @@ GOT_FIRST_CERT:
864 /* make sure the status line matches the response we are looking for */ 973 /* make sure the status line matches the response we are looking for */
865 if (!expected_statuscode(status_line.first_line, server_expect)) { 974 if (!expected_statuscode(status_line.first_line, server_expect)) {
866 if (server_port == HTTP_PORT) 975 if (server_port == HTTP_PORT)
867 snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host: %s\n"), status_line.first_line); 976 snprintf(msg,
977 DEFAULT_BUFFER_SIZE,
978 _("Invalid HTTP response received from host: %s\n"),
979 status_line.first_line);
868 else 980 else
869 snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: %s\n"), server_port, status_line.first_line); 981 snprintf(msg,
982 DEFAULT_BUFFER_SIZE,
983 _("Invalid HTTP response received from host on port %d: %s\n"),
984 server_port,
985 status_line.first_line);
870 die (STATE_CRITICAL, "HTTP CRITICAL - %s%s%s", msg, 986 die (STATE_CRITICAL, "HTTP CRITICAL - %s%s%s", msg,
871 show_body ? "\n" : "", 987 show_body ? "\n" : "",
872 show_body ? body_buf.buf : ""); 988 show_body ? body_buf.buf : "");
@@ -902,7 +1018,7 @@ GOT_FIRST_CERT:
902 } 1018 }
903 } else { 1019 } else {
904 /* this is a specific code in the command line to 1020 /* this is a specific code in the command line to
905 * be returned when a redirection is encoutered 1021 * be returned when a redirection is encountered
906 */ 1022 */
907 } 1023 }
908 result = max_state_alt (onredirect, result); 1024 result = max_state_alt (onredirect, result);
@@ -939,64 +1055,119 @@ GOT_FIRST_CERT:
939 1055
940 if (strlen (header_expect)) { 1056 if (strlen (header_expect)) {
941 if (!strstr (header_buf.buf, header_expect)) { 1057 if (!strstr (header_buf.buf, header_expect)) {
1058
942 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search)); 1059 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
1060
943 if(output_header_search[sizeof(output_header_search)-1]!='\0') { 1061 if(output_header_search[sizeof(output_header_search)-1]!='\0') {
944 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4); 1062 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
945 } 1063 }
946 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1064
947 result = STATE_CRITICAL; 1065 char tmp[DEFAULT_BUFFER_SIZE];
1066
1067 snprintf (tmp,
1068 DEFAULT_BUFFER_SIZE,
1069 _("%sheader '%s' not found on '%s://%s:%d%s', "),
1070 msg,
1071 output_header_search,
1072 use_ssl ? "https" : "http",
1073 host_name ? host_name : server_address,
1074 server_port,
1075 server_url);
1076
1077 strcpy(msg, tmp);
1078
1079 result = STATE_CRITICAL;
948 } 1080 }
949 } 1081 }
950 1082
951 if (strlen (string_expect)) { 1083 if (strlen (string_expect)) {
952 if (!strstr (body_buf.buf, string_expect)) { 1084 if (!strstr (body_buf.buf, string_expect)) {
1085
953 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search)); 1086 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
1087
954 if(output_string_search[sizeof(output_string_search)-1]!='\0') { 1088 if(output_string_search[sizeof(output_string_search)-1]!='\0') {
955 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); 1089 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4);
956 } 1090 }
957 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1091
958 result = STATE_CRITICAL; 1092 char tmp[DEFAULT_BUFFER_SIZE];
1093
1094 snprintf (tmp,
1095 DEFAULT_BUFFER_SIZE,
1096 _("%sstring '%s' not found on '%s://%s:%d%s', "),
1097 msg,
1098 output_string_search,
1099 use_ssl ? "https" : "http",
1100 host_name ? host_name : server_address,
1101 server_port,
1102 server_url);
1103
1104 strcpy(msg, tmp);
1105
1106 result = STATE_CRITICAL;
959 } 1107 }
960 } 1108 }
961 1109
962 if (strlen (regexp)) { 1110 if (strlen (regexp)) {
963 errcode = regexec (&preg, body_buf.buf, REGS, pmatch, 0); 1111 errcode = regexec (&preg, body_buf.buf, REGS, pmatch, 0);
964 if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) { 1112 if ((errcode == 0 && !invert_regex) || (errcode == REG_NOMATCH && invert_regex)) {
965 /* OK - No-op to avoid changing the logic around it */ 1113 /* OK - No-op to avoid changing the logic around it */
966 result = max_state_alt(STATE_OK, result); 1114 result = max_state_alt(STATE_OK, result);
967 } 1115 }
968 else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) { 1116 else if ((errcode == REG_NOMATCH && !invert_regex) || (errcode == 0 && invert_regex)) {
969 if (invert_regex == 0) 1117 if (!invert_regex) {
970 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg); 1118 char tmp[DEFAULT_BUFFER_SIZE];
971 else 1119
972 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg); 1120 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern not found, "), msg);
973 result = STATE_CRITICAL; 1121 strcpy(msg, tmp);
974 } 1122
975 else { 1123 } else {
976 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 1124 char tmp[DEFAULT_BUFFER_SIZE];
977 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf); 1125
978 result = STATE_UNKNOWN; 1126 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spattern found, "), msg);
979 } 1127 strcpy(msg, tmp);
1128
1129 }
1130 result = STATE_CRITICAL;
1131 } else {
1132 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
1133
1134 char tmp[DEFAULT_BUFFER_SIZE];
1135
1136 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sExecute Error: %s, "), msg, errbuf);
1137 strcpy(msg, tmp);
1138 result = STATE_UNKNOWN;
1139 }
980 } 1140 }
981 1141
982 /* make sure the page is of an appropriate size */ 1142 /* make sure the page is of an appropriate size */
983 if ((max_page_len > 0) && (page_len > max_page_len)) { 1143 if ((max_page_len > 0) && (page_len > max_page_len)) {
984 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len); 1144 char tmp[DEFAULT_BUFFER_SIZE];
985 result = max_state_alt(STATE_WARNING, result); 1145
986 } else if ((min_page_len > 0) && (page_len < min_page_len)) { 1146 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too large, "), msg, page_len);
987 snprintf (msg, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len); 1147
988 result = max_state_alt(STATE_WARNING, result); 1148 strcpy(msg, tmp);
989 } 1149
1150 result = max_state_alt(STATE_WARNING, result);
1151
1152 } else if ((min_page_len > 0) && (page_len < min_page_len)) {
1153 char tmp[DEFAULT_BUFFER_SIZE];
1154
1155 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%spage size %d too small, "), msg, page_len);
1156 strcpy(msg, tmp);
1157 result = max_state_alt(STATE_WARNING, result);
1158 }
990 1159
991 /* -w, -c: check warning and critical level */ 1160 /* -w, -c: check warning and critical level */
992 result = max_state_alt(get_status(total_time, thlds), result); 1161 result = max_state_alt(get_status(total_time, thlds), result);
993 1162
994 /* Cut-off trailing characters */ 1163 /* Cut-off trailing characters */
995 if(msg[strlen(msg)-2] == ',') 1164 if (strlen(msg) >= 2) {
996 msg[strlen(msg)-2] = '\0'; 1165 if(msg[strlen(msg)-2] == ',')
997 else 1166 msg[strlen(msg)-2] = '\0';
998 msg[strlen(msg)-3] = '\0'; 1167 else
999 1168 msg[strlen(msg)-3] = '\0';
1169 }
1170
1000 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ 1171 /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */
1001 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", 1172 die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s",
1002 state_text(result), string_statuscode (status_line.http_major, status_line.http_minor), 1173 state_text(result), string_statuscode (status_line.http_major, status_line.http_minor),
@@ -1008,16 +1179,6 @@ GOT_FIRST_CERT:
1008 (show_body ? body_buf.buf : ""), 1179 (show_body ? body_buf.buf : ""),
1009 (show_body ? "\n" : "") ); 1180 (show_body ? "\n" : "") );
1010 1181
1011 /* proper cleanup after die? */
1012 curlhelp_free_statusline(&status_line);
1013 curl_easy_cleanup (curl);
1014 curl_global_cleanup ();
1015 curlhelp_freewritebuffer (&body_buf);
1016 curlhelp_freewritebuffer (&header_buf);
1017 if (!strcmp (http_method, "PUT")) {
1018 curlhelp_freereadbuffer (&put_buf);
1019 }
1020
1021 return result; 1182 return result;
1022} 1183}
1023 1184
@@ -1054,7 +1215,7 @@ redir (curlhelp_write_curlbuf* header_buf)
1054 char *new_url; 1215 char *new_url;
1055 1216
1056 int res = phr_parse_response (header_buf->buf, header_buf->buflen, 1217 int res = phr_parse_response (header_buf->buf, header_buf->buflen,
1057 &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen, 1218 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
1058 headers, &nof_headers, 0); 1219 headers, &nof_headers, 0);
1059 1220
1060 location = get_header_value (headers, nof_headers, "location"); 1221 location = get_header_value (headers, nof_headers, "location");
@@ -1113,7 +1274,10 @@ redir (curlhelp_write_curlbuf* header_buf)
1113 } 1274 }
1114 } 1275 }
1115 1276
1116 use_ssl = !uri_strcmp (uri.scheme, "https"); 1277 if (!uri_strcmp (uri.scheme, "https"))
1278 use_ssl = true;
1279 else
1280 use_ssl = false;
1117 1281
1118 /* we do a sloppy test here only, because uriparser would have failed 1282 /* we do a sloppy test here only, because uriparser would have failed
1119 * above, if the port would be invalid, we just check for MAX_PORT 1283 * above, if the port would be invalid, we just check for MAX_PORT
@@ -1188,6 +1352,7 @@ redir (curlhelp_write_curlbuf* header_buf)
1188 * attached to the URL in Location 1352 * attached to the URL in Location
1189 */ 1353 */
1190 1354
1355 cleanup ();
1191 check_http (); 1356 check_http ();
1192} 1357}
1193 1358
@@ -1200,7 +1365,7 @@ test_file (char *path)
1200 usage2 (_("file does not exist or is not readable"), path); 1365 usage2 (_("file does not exist or is not readable"), path);
1201} 1366}
1202 1367
1203int 1368bool
1204process_arguments (int argc, char **argv) 1369process_arguments (int argc, char **argv)
1205{ 1370{
1206 char *p; 1371 char *p;
@@ -1210,9 +1375,12 @@ process_arguments (int argc, char **argv)
1210 enum { 1375 enum {
1211 INVERT_REGEX = CHAR_MAX + 1, 1376 INVERT_REGEX = CHAR_MAX + 1,
1212 SNI_OPTION, 1377 SNI_OPTION,
1378 MAX_REDIRS_OPTION,
1379 CONTINUE_AFTER_CHECK_CERT,
1213 CA_CERT_OPTION, 1380 CA_CERT_OPTION,
1214 HTTP_VERSION_OPTION, 1381 HTTP_VERSION_OPTION,
1215 AUTOMATIC_DECOMPRESSION 1382 AUTOMATIC_DECOMPRESSION,
1383 COOKIE_JAR
1216 }; 1384 };
1217 1385
1218 int option = 0; 1386 int option = 0;
@@ -1243,6 +1411,7 @@ process_arguments (int argc, char **argv)
1243 {"private-key", required_argument, 0, 'K'}, 1411 {"private-key", required_argument, 0, 'K'},
1244 {"ca-cert", required_argument, 0, CA_CERT_OPTION}, 1412 {"ca-cert", required_argument, 0, CA_CERT_OPTION},
1245 {"verify-cert", no_argument, 0, 'D'}, 1413 {"verify-cert", no_argument, 0, 'D'},
1414 {"continue-after-certificate", no_argument, 0, CONTINUE_AFTER_CHECK_CERT},
1246 {"useragent", required_argument, 0, 'A'}, 1415 {"useragent", required_argument, 0, 'A'},
1247 {"header", required_argument, 0, 'k'}, 1416 {"header", required_argument, 0, 'k'},
1248 {"no-body", no_argument, 0, 'N'}, 1417 {"no-body", no_argument, 0, 'N'},
@@ -1254,13 +1423,15 @@ process_arguments (int argc, char **argv)
1254 {"use-ipv6", no_argument, 0, '6'}, 1423 {"use-ipv6", no_argument, 0, '6'},
1255 {"extended-perfdata", no_argument, 0, 'E'}, 1424 {"extended-perfdata", no_argument, 0, 'E'},
1256 {"show-body", no_argument, 0, 'B'}, 1425 {"show-body", no_argument, 0, 'B'},
1426 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION},
1257 {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, 1427 {"http-version", required_argument, 0, HTTP_VERSION_OPTION},
1258 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION}, 1428 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION},
1429 {"cookie-jar", required_argument, 0, COOKIE_JAR},
1259 {0, 0, 0, 0} 1430 {0, 0, 0, 0}
1260 }; 1431 };
1261 1432
1262 if (argc < 2) 1433 if (argc < 2)
1263 return ERROR; 1434 return false;
1264 1435
1265 /* support check_http compatible arguments */ 1436 /* support check_http compatible arguments */
1266 for (c = 1; c < argc; c++) { 1437 for (c = 1; c < argc; c++) {
@@ -1340,7 +1511,7 @@ process_arguments (int argc, char **argv)
1340 if( strtol(optarg, NULL, 10) > MAX_PORT) 1511 if( strtol(optarg, NULL, 10) > MAX_PORT)
1341 usage2 (_("Invalid port number, supplied port number is too big"), optarg); 1512 usage2 (_("Invalid port number, supplied port number is too big"), optarg);
1342 server_port = (unsigned short)strtol(optarg, NULL, 10); 1513 server_port = (unsigned short)strtol(optarg, NULL, 10);
1343 specify_port = TRUE; 1514 specify_port = true;
1344 } 1515 }
1345 break; 1516 break;
1346 case 'a': /* authorization info */ 1517 case 'a': /* authorization info */
@@ -1374,10 +1545,10 @@ process_arguments (int argc, char **argv)
1374 http_opt_headers[http_opt_headers_count - 1] = optarg; 1545 http_opt_headers[http_opt_headers_count - 1] = optarg;
1375 break; 1546 break;
1376 case 'L': /* show html link */ 1547 case 'L': /* show html link */
1377 display_html = TRUE; 1548 display_html = true;
1378 break; 1549 break;
1379 case 'n': /* do not show html link */ 1550 case 'n': /* do not show html link */
1380 display_html = FALSE; 1551 display_html = false;
1381 break; 1552 break;
1382 case 'C': /* Check SSL cert validity */ 1553 case 'C': /* Check SSL cert validity */
1383#ifdef LIBCURL_FEATURE_SSL 1554#ifdef LIBCURL_FEATURE_SSL
@@ -1398,9 +1569,14 @@ process_arguments (int argc, char **argv)
1398 usage2 (_("Invalid certificate expiration period"), optarg); 1569 usage2 (_("Invalid certificate expiration period"), optarg);
1399 days_till_exp_warn = atoi (optarg); 1570 days_till_exp_warn = atoi (optarg);
1400 } 1571 }
1401 check_cert = TRUE; 1572 check_cert = true;
1402 goto enable_ssl; 1573 goto enable_ssl;
1403#endif 1574#endif
1575 case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */
1576#ifdef HAVE_SSL
1577 continue_after_check_cert = true;
1578 break;
1579#endif
1404 case 'J': /* use client certificate */ 1580 case 'J': /* use client certificate */
1405#ifdef LIBCURL_FEATURE_SSL 1581#ifdef LIBCURL_FEATURE_SSL
1406 test_file(optarg); 1582 test_file(optarg);
@@ -1421,13 +1597,13 @@ process_arguments (int argc, char **argv)
1421#endif 1597#endif
1422#ifdef LIBCURL_FEATURE_SSL 1598#ifdef LIBCURL_FEATURE_SSL
1423 case 'D': /* verify peer certificate & host */ 1599 case 'D': /* verify peer certificate & host */
1424 verify_peer_and_host = TRUE; 1600 verify_peer_and_host = true;
1425 goto enable_ssl; 1601 break;
1426#endif 1602#endif
1427 case 'S': /* use SSL */ 1603 case 'S': /* use SSL */
1428#ifdef LIBCURL_FEATURE_SSL 1604#ifdef LIBCURL_FEATURE_SSL
1429 enable_ssl: 1605 enable_ssl:
1430 use_ssl = TRUE; 1606 use_ssl = true;
1431 /* ssl_version initialized to CURL_SSLVERSION_DEFAULT as a default. 1607 /* ssl_version initialized to CURL_SSLVERSION_DEFAULT as a default.
1432 * Only set if it's non-zero. This helps when we include multiple 1608 * Only set if it's non-zero. This helps when we include multiple
1433 * parameters, like -S and -C combinations */ 1609 * parameters, like -S and -C combinations */
@@ -1501,17 +1677,24 @@ process_arguments (int argc, char **argv)
1501#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */ 1677#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 54, 0) */
1502 if (verbose >= 2) 1678 if (verbose >= 2)
1503 printf(_("* Set SSL/TLS version to %d\n"), ssl_version); 1679 printf(_("* Set SSL/TLS version to %d\n"), ssl_version);
1504 if (specify_port == FALSE) 1680 if (!specify_port)
1505 server_port = HTTPS_PORT; 1681 server_port = HTTPS_PORT;
1506 break; 1682 break;
1507#else /* LIBCURL_FEATURE_SSL */ 1683#else /* LIBCURL_FEATURE_SSL */
1508 /* -C -J and -K fall through to here without SSL */ 1684 /* -C -J and -K fall through to here without SSL */
1509 usage4 (_("Invalid option - SSL is not available")); 1685 usage4 (_("Invalid option - SSL is not available"));
1510 break; 1686 break;
1511 case SNI_OPTION: /* --sni is parsed, but ignored, the default is TRUE with libcurl */ 1687 case SNI_OPTION: /* --sni is parsed, but ignored, the default is true with libcurl */
1512 use_sni = TRUE; 1688 use_sni = true;
1513 break; 1689 break;
1514#endif /* LIBCURL_FEATURE_SSL */ 1690#endif /* LIBCURL_FEATURE_SSL */
1691 case MAX_REDIRS_OPTION:
1692 if (!is_intnonneg (optarg))
1693 usage2 (_("Invalid max_redirs count"), optarg);
1694 else {
1695 max_depth = atoi (optarg);
1696 }
1697 break;
1515 case 'f': /* onredirect */ 1698 case 'f': /* onredirect */
1516 if (!strcmp (optarg, "ok")) 1699 if (!strcmp (optarg, "ok"))
1517 onredirect = STATE_OK; 1700 onredirect = STATE_OK;
@@ -1556,6 +1739,7 @@ process_arguments (int argc, char **argv)
1556 break; 1739 break;
1557 case 'R': /* regex */ 1740 case 'R': /* regex */
1558 cflags |= REG_ICASE; 1741 cflags |= REG_ICASE;
1742 // fall through
1559 case 'r': /* regex */ 1743 case 'r': /* regex */
1560 strncpy (regexp, optarg, MAX_RE_SIZE - 1); 1744 strncpy (regexp, optarg, MAX_RE_SIZE - 1);
1561 regexp[MAX_RE_SIZE - 1] = 0; 1745 regexp[MAX_RE_SIZE - 1] = 0;
@@ -1563,11 +1747,11 @@ process_arguments (int argc, char **argv)
1563 if (errcode != 0) { 1747 if (errcode != 0) {
1564 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 1748 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
1565 printf (_("Could Not Compile Regular Expression: %s"), errbuf); 1749 printf (_("Could Not Compile Regular Expression: %s"), errbuf);
1566 return ERROR; 1750 return false;
1567 } 1751 }
1568 break; 1752 break;
1569 case INVERT_REGEX: 1753 case INVERT_REGEX:
1570 invert_regex = 1; 1754 invert_regex = true;
1571 break; 1755 break;
1572 case '4': 1756 case '4':
1573 address_family = AF_INET; 1757 address_family = AF_INET;
@@ -1602,7 +1786,7 @@ process_arguments (int argc, char **argv)
1602 break; 1786 break;
1603 } 1787 }
1604 case 'N': /* no-body */ 1788 case 'N': /* no-body */
1605 no_body = TRUE; 1789 no_body = true;
1606 break; 1790 break;
1607 case 'M': /* max-age */ 1791 case 'M': /* max-age */
1608 { 1792 {
@@ -1625,10 +1809,10 @@ process_arguments (int argc, char **argv)
1625 } 1809 }
1626 break; 1810 break;
1627 case 'E': /* show extended perfdata */ 1811 case 'E': /* show extended perfdata */
1628 show_extended_perfdata = TRUE; 1812 show_extended_perfdata = true;
1629 break; 1813 break;
1630 case 'B': /* print body content after status line */ 1814 case 'B': /* print body content after status line */
1631 show_body = TRUE; 1815 show_body = true;
1632 break; 1816 break;
1633 case HTTP_VERSION_OPTION: 1817 case HTTP_VERSION_OPTION:
1634 curl_http_version = CURL_HTTP_VERSION_NONE; 1818 curl_http_version = CURL_HTTP_VERSION_NONE;
@@ -1643,12 +1827,15 @@ process_arguments (int argc, char **argv)
1643 curl_http_version = CURL_HTTP_VERSION_NONE; 1827 curl_http_version = CURL_HTTP_VERSION_NONE;
1644#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */ 1828#endif /* LIBCURL_VERSION_NUM >= MAKE_LIBCURL_VERSION(7, 33, 0) */
1645 } else { 1829 } else {
1646 fprintf (stderr, "unkown http-version parameter: %s\n", optarg); 1830 fprintf (stderr, "unknown http-version parameter: %s\n", optarg);
1647 exit (STATE_WARNING); 1831 exit (STATE_WARNING);
1648 } 1832 }
1649 break; 1833 break;
1650 case AUTOMATIC_DECOMPRESSION: 1834 case AUTOMATIC_DECOMPRESSION:
1651 automatic_decompression = TRUE; 1835 automatic_decompression = true;
1836 break;
1837 case COOKIE_JAR:
1838 cookie_jar_file = optarg;
1652 break; 1839 break;
1653 case '?': 1840 case '?':
1654 /* print short usage statement if args not parsable */ 1841 /* print short usage statement if args not parsable */
@@ -1689,52 +1876,52 @@ process_arguments (int argc, char **argv)
1689 virtual_port = server_port; 1876 virtual_port = server_port;
1690 else { 1877 else {
1691 if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT)) 1878 if ((use_ssl && server_port == HTTPS_PORT) || (!use_ssl && server_port == HTTP_PORT))
1692 if(specify_port == FALSE) 1879 if(!specify_port)
1693 server_port = virtual_port; 1880 server_port = virtual_port;
1694 } 1881 }
1695 1882
1696 return TRUE; 1883 return true;
1697} 1884}
1698 1885
1699char *perfd_time (double elapsed_time) 1886char *perfd_time (double elapsed_time)
1700{ 1887{
1701 return fperfdata ("time", elapsed_time, "s", 1888 return fperfdata ("time", elapsed_time, "s",
1702 thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0, 1889 thlds->warning?true:false, thlds->warning?thlds->warning->end:0,
1703 thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0, 1890 thlds->critical?true:false, thlds->critical?thlds->critical->end:0,
1704 TRUE, 0, TRUE, socket_timeout); 1891 true, 0, true, socket_timeout);
1705} 1892}
1706 1893
1707char *perfd_time_connect (double elapsed_time_connect) 1894char *perfd_time_connect (double elapsed_time_connect)
1708{ 1895{
1709 return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1896 return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1710} 1897}
1711 1898
1712char *perfd_time_ssl (double elapsed_time_ssl) 1899char *perfd_time_ssl (double elapsed_time_ssl)
1713{ 1900{
1714 return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1901 return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1715} 1902}
1716 1903
1717char *perfd_time_headers (double elapsed_time_headers) 1904char *perfd_time_headers (double elapsed_time_headers)
1718{ 1905{
1719 return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1906 return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1720} 1907}
1721 1908
1722char *perfd_time_firstbyte (double elapsed_time_firstbyte) 1909char *perfd_time_firstbyte (double elapsed_time_firstbyte)
1723{ 1910{
1724 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1911 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1725} 1912}
1726 1913
1727char *perfd_time_transfer (double elapsed_time_transfer) 1914char *perfd_time_transfer (double elapsed_time_transfer)
1728{ 1915{
1729 return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1916 return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1730} 1917}
1731 1918
1732char *perfd_size (int page_len) 1919char *perfd_size (int page_len)
1733{ 1920{
1734 return perfdata ("size", page_len, "B", 1921 return perfdata ("size", page_len, "B",
1735 (min_page_len>0?TRUE:FALSE), min_page_len, 1922 (min_page_len>0?true:false), min_page_len,
1736 (min_page_len>0?TRUE:FALSE), 0, 1923 (min_page_len>0?true:false), 0,
1737 TRUE, 0, FALSE, 0); 1924 true, 0, false, 0);
1738} 1925}
1739 1926
1740void 1927void
@@ -1791,7 +1978,11 @@ print_help (void)
1791#endif 1978#endif
1792 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); 1979 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
1793 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443")); 1980 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
1794 printf (" %s\n", _("(when this option is used the URL is not checked.)")); 1981 printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use"));
1982 printf (" %s\n", _(" --continue-after-certificate to override this behavior)"));
1983 printf (" %s\n", "--continue-after-certificate");
1984 printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check."));
1985 printf (" %s\n", _("Does nothing unless -C is used."));
1795 printf (" %s\n", "-J, --client-cert=FILE"); 1986 printf (" %s\n", "-J, --client-cert=FILE");
1796 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)")); 1987 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)"));
1797 printf (" %s\n", _("to be used in establishing the SSL session")); 1988 printf (" %s\n", _("to be used in establishing the SSL session"));
@@ -1854,6 +2045,9 @@ print_help (void)
1854 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same.")); 2045 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same."));
1855 printf (" %s\n", _("follow uses the old redirection algorithm of check_http.")); 2046 printf (" %s\n", _("follow uses the old redirection algorithm of check_http."));
1856 printf (" %s\n", _("curl uses CURL_FOLLOWLOCATION built into libcurl.")); 2047 printf (" %s\n", _("curl uses CURL_FOLLOWLOCATION built into libcurl."));
2048 printf (" %s\n", "--max-redirs=INTEGER");
2049 printf (" %s", _("Maximal number of redirects (default: "));
2050 printf ("%d)\n", DEFAULT_MAX_REDIRS);
1857 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); 2051 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
1858 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); 2052 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));
1859 printf ("\n"); 2053 printf ("\n");
@@ -1862,6 +2056,8 @@ print_help (void)
1862 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)")); 2056 printf (" %s\n", _("1.0 = HTTP/1.0, 1.1 = HTTP/1.1, 2.0 = HTTP/2 (HTTP/2 will fail without -S)"));
1863 printf (" %s\n", "--enable-automatic-decompression"); 2057 printf (" %s\n", "--enable-automatic-decompression");
1864 printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING).")); 2058 printf (" %s\n", _("Enable automatic decompression of body (CURLOPT_ACCEPT_ENCODING)."));
2059 printf (" %s\n", "---cookie-jar=FILE");
2060 printf (" %s\n", _("Store cookies in the cookie jar and send them out when requested."));
1865 printf ("\n"); 2061 printf ("\n");
1866 2062
1867 printf (UT_WARN_CRIT); 2063 printf (UT_WARN_CRIT);
@@ -1941,12 +2137,13 @@ print_usage (void)
1941 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); 2137 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
1942 printf (" [-J <client certificate file>] [-K <private key>] [--ca-cert <CA certificate file>] [-D]\n"); 2138 printf (" [-J <client certificate file>] [-K <private key>] [--ca-cert <CA certificate file>] [-D]\n");
1943 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n"); 2139 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n");
1944 printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport|curl>]\n"); 2140 printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport|curl>]\n");
1945 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); 2141 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
1946 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); 2142 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
1947 printf (" [-A string] [-k string] [-S <version>] [--sni]\n"); 2143 printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
1948 printf (" [-T <content-type>] [-j method]\n"); 2144 printf (" [-T <content-type>] [-j method]\n");
1949 printf (" [--http-version=<version>]\n"); 2145 printf (" [--http-version=<version>] [--enable-automatic-decompression]\n");
2146 printf (" [--cookie-jar=<cookie jar file>\n");
1950 printf (" %s -H <vhost> | -I <IP-address> -C <warn_age>[,<crit_age>]\n",progname); 2147 printf (" %s -H <vhost> | -I <IP-address> -C <warn_age>[,<crit_age>]\n",progname);
1951 printf (" [-p <port>] [-t <timeout>] [-4|-6] [--sni]\n"); 2148 printf (" [-p <port>] [-t <timeout>] [-4|-6] [--sni]\n");
1952 printf ("\n"); 2149 printf ("\n");
@@ -1980,9 +2177,12 @@ curlhelp_buffer_write_callback (void *buffer, size_t size, size_t nmemb, void *s
1980 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream; 2177 curlhelp_write_curlbuf *buf = (curlhelp_write_curlbuf *)stream;
1981 2178
1982 while (buf->bufsize < buf->buflen + size * nmemb + 1) { 2179 while (buf->bufsize < buf->buflen + size * nmemb + 1) {
1983 buf->bufsize *= buf->bufsize * 2; 2180 buf->bufsize = buf->bufsize * 2;
1984 buf->buf = (char *)realloc (buf->buf, buf->bufsize); 2181 buf->buf = (char *)realloc (buf->buf, buf->bufsize);
1985 if (buf->buf == NULL) return -1; 2182 if (buf->buf == NULL) {
2183 fprintf(stderr, "malloc failed (%d) %s\n", errno, strerror(errno));
2184 return -1;
2185 }
1986 } 2186 }
1987 2187
1988 memcpy (buf->buf + buf->buflen, buffer, size * nmemb); 2188 memcpy (buf->buf + buf->buflen, buffer, size * nmemb);
@@ -2103,11 +2303,10 @@ curlhelp_parse_statusline (const char *buf, curlhelp_statusline *status_line)
2103 if( strchr( p, '.' ) != NULL ) { 2303 if( strchr( p, '.' ) != NULL ) {
2104 2304
2105 /* HTTP 1.x case */ 2305 /* HTTP 1.x case */
2106 char *ppp; 2306 strtok( p, "." );
2107 ppp = strtok( p, "." );
2108 status_line->http_major = (int)strtol( p, &pp, 10 ); 2307 status_line->http_major = (int)strtol( p, &pp, 10 );
2109 if( *pp != '\0' ) { free( first_line_buf ); return -1; } 2308 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2110 ppp = strtok( NULL, " " ); 2309 strtok( NULL, " " );
2111 status_line->http_minor = (int)strtol( p, &pp, 10 ); 2310 status_line->http_minor = (int)strtol( p, &pp, 10 );
2112 if( *pp != '\0' ) { free( first_line_buf ); return -1; } 2311 if( *pp != '\0' ) { free( first_line_buf ); return -1; }
2113 p += 4; /* 1.x SP */ 2312 p += 4; /* 1.x SP */
@@ -2188,43 +2387,73 @@ check_document_dates (const curlhelp_write_curlbuf *header_buf, char (*msg)[DEFA
2188 size_t msglen; 2387 size_t msglen;
2189 2388
2190 int res = phr_parse_response (header_buf->buf, header_buf->buflen, 2389 int res = phr_parse_response (header_buf->buf, header_buf->buflen,
2191 &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen, 2390 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
2192 headers, &nof_headers, 0); 2391 headers, &nof_headers, 0);
2193 2392
2194 server_date = get_header_value (headers, nof_headers, "date"); 2393 server_date = get_header_value (headers, nof_headers, "date");
2195 document_date = get_header_value (headers, nof_headers, "last-modified"); 2394 document_date = get_header_value (headers, nof_headers, "last-modified");
2196 2395
2197 if (!server_date || !*server_date) { 2396 if (!server_date || !*server_date) {
2198 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg); 2397 char tmp[DEFAULT_BUFFER_SIZE];
2199 date_result = max_state_alt(STATE_UNKNOWN, date_result); 2398
2200 } else if (!document_date || !*document_date) { 2399 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date unknown, "), *msg);
2201 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg); 2400 strcpy(*msg, tmp);
2202 date_result = max_state_alt(STATE_CRITICAL, date_result); 2401
2402 date_result = max_state_alt(STATE_UNKNOWN, date_result);
2403
2404 } else if (!document_date || !*document_date) {
2405 char tmp[DEFAULT_BUFFER_SIZE];
2406
2407 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument modification date unknown, "), *msg);
2408 strcpy(*msg, tmp);
2409
2410 date_result = max_state_alt(STATE_CRITICAL, date_result);
2411
2203 } else { 2412 } else {
2204 time_t srv_data = curl_getdate (server_date, NULL); 2413 time_t srv_data = curl_getdate (server_date, NULL);
2205 time_t doc_data = curl_getdate (document_date, NULL); 2414 time_t doc_data = curl_getdate (document_date, NULL);
2206 if (verbose >= 2) 2415 if (verbose >= 2)
2207 printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data); 2416 printf ("* server date: '%s' (%d), doc_date: '%s' (%d)\n", server_date, (int)srv_data, document_date, (int)doc_data);
2208 if (srv_data <= 0) { 2417 if (srv_data <= 0) {
2209 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); 2418 char tmp[DEFAULT_BUFFER_SIZE];
2210 date_result = max_state_alt(STATE_CRITICAL, date_result); 2419
2211 } else if (doc_data <= 0) { 2420 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sServer date \"%100s\" unparsable, "), *msg, server_date);
2212 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date); 2421 strcpy(*msg, tmp);
2213 date_result = max_state_alt(STATE_CRITICAL, date_result); 2422
2214 } else if (doc_data > srv_data + 30) { 2423 date_result = max_state_alt(STATE_CRITICAL, date_result);
2215 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data); 2424 } else if (doc_data <= 0) {
2216 date_result = max_state_alt(STATE_CRITICAL, date_result); 2425 char tmp[DEFAULT_BUFFER_SIZE];
2217 } else if (doc_data < srv_data - maximum_age) { 2426
2218 int n = (srv_data - doc_data); 2427 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date);
2219 if (n > (60 * 60 * 24 * 2)) { 2428 strcpy(*msg, tmp);
2220 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24)); 2429
2221 date_result = max_state_alt(STATE_CRITICAL, date_result); 2430 date_result = max_state_alt(STATE_CRITICAL, date_result);
2222 } else { 2431 } else if (doc_data > srv_data + 30) {
2223 snprintf (*msg, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60); 2432 char tmp[DEFAULT_BUFFER_SIZE];
2224 date_result = max_state_alt(STATE_CRITICAL, date_result); 2433
2225 } 2434 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data);
2226 } 2435 strcpy(*msg, tmp);
2227 } 2436
2437 date_result = max_state_alt(STATE_CRITICAL, date_result);
2438 } else if (doc_data < srv_data - maximum_age) {
2439 int n = (srv_data - doc_data);
2440 if (n > (60 * 60 * 24 * 2)) {
2441 char tmp[DEFAULT_BUFFER_SIZE];
2442
2443 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24));
2444 strcpy(*msg, tmp);
2445
2446 date_result = max_state_alt(STATE_CRITICAL, date_result);
2447 } else {
2448 char tmp[DEFAULT_BUFFER_SIZE];
2449
2450 snprintf (tmp, DEFAULT_BUFFER_SIZE, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60);
2451 strcpy(*msg, tmp);
2452
2453 date_result = max_state_alt(STATE_CRITICAL, date_result);
2454 }
2455 }
2456 }
2228 2457
2229 if (server_date) free (server_date); 2458 if (server_date) free (server_date);
2230 if (document_date) free (document_date); 2459 if (document_date) free (document_date);
@@ -2246,7 +2475,7 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
2246 curlhelp_statusline status_line; 2475 curlhelp_statusline status_line;
2247 2476
2248 int res = phr_parse_response (header_buf->buf, header_buf->buflen, 2477 int res = phr_parse_response (header_buf->buf, header_buf->buflen,
2249 &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen, 2478 &status_line.http_major, &status_line.http_minor, &status_line.http_code, &status_line.msg, &msglen,
2250 headers, &nof_headers, 0); 2479 headers, &nof_headers, 0);
2251 2480
2252 content_length_s = get_header_value (headers, nof_headers, "content-length"); 2481 content_length_s = get_header_value (headers, nof_headers, "content-length");
@@ -2266,7 +2495,7 @@ get_content_length (const curlhelp_write_curlbuf* header_buf, const curlhelp_wri
2266 2495
2267/* TODO: is there a better way in libcurl to check for the SSL library? */ 2496/* TODO: is there a better way in libcurl to check for the SSL library? */
2268curlhelp_ssl_library 2497curlhelp_ssl_library
2269curlhelp_get_ssl_library (CURL* curl) 2498curlhelp_get_ssl_library ()
2270{ 2499{
2271 curl_version_info_data* version_data; 2500 curl_version_info_data* version_data;
2272 char *ssl_version; 2501 char *ssl_version;
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index ced13d0..c24ca24 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -141,21 +141,28 @@ main (int argc, char **argv)
141 if (verbose > 2) 141 if (verbose > 2)
142 printf ("Initializing DBI\n"); 142 printf ("Initializing DBI\n");
143 143
144 if (dbi_initialize (NULL) < 0) { 144 dbi_inst *instance_p;
145
146 if (dbi_initialize_r(NULL, instance_p) < 0) {
145 printf ("UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n"); 147 printf ("UNKNOWN - failed to initialize DBI; possibly you don't have any drivers installed.\n");
146 return STATE_UNKNOWN; 148 return STATE_UNKNOWN;
147 } 149 }
148 150
151 if (instance_p == NULL) {
152 printf ("UNKNOWN - failed to initialize DBI.\n");
153 return STATE_UNKNOWN;
154 }
155
149 if (verbose) 156 if (verbose)
150 printf ("Opening DBI driver '%s'\n", np_dbi_driver); 157 printf ("Opening DBI driver '%s'\n", np_dbi_driver);
151 158
152 driver = dbi_driver_open (np_dbi_driver); 159 driver = dbi_driver_open_r(np_dbi_driver, instance_p);
153 if (! driver) { 160 if (! driver) {
154 printf ("UNKNOWN - failed to open DBI driver '%s'; possibly it's not installed.\n", 161 printf ("UNKNOWN - failed to open DBI driver '%s'; possibly it's not installed.\n",
155 np_dbi_driver); 162 np_dbi_driver);
156 163
157 printf ("Known drivers:\n"); 164 printf ("Known drivers:\n");
158 for (driver = dbi_driver_list (NULL); driver; driver = dbi_driver_list (driver)) { 165 for (driver = dbi_driver_list_r(NULL, instance_p); driver; driver = dbi_driver_list_r(driver, instance_p)) {
159 printf (" - %s\n", dbi_driver_get_name (driver)); 166 printf (" - %s\n", dbi_driver_get_name (driver));
160 } 167 }
161 return STATE_UNKNOWN; 168 return STATE_UNKNOWN;
@@ -426,6 +433,7 @@ process_arguments (int argc, char **argv)
426 else 433 else
427 timeout_interval = atoi (optarg); 434 timeout_interval = atoi (optarg);
428 435
436 break;
429 case 'H': /* host */ 437 case 'H': /* host */
430 if (!is_host (optarg)) 438 if (!is_host (optarg))
431 usage2 (_("Invalid hostname/address"), optarg); 439 usage2 (_("Invalid hostname/address"), optarg);
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index c526d05..05e5502 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -112,11 +112,12 @@ enum
112{ 112{
113 SYNC_OPTION = CHAR_MAX + 1, 113 SYNC_OPTION = CHAR_MAX + 1,
114 NO_SYNC_OPTION, 114 NO_SYNC_OPTION,
115 BLOCK_SIZE_OPTION 115 BLOCK_SIZE_OPTION,
116 IGNORE_MISSING
116}; 117};
117 118
118#ifdef _AIX 119#ifdef _AIX
119 #pragma alloca 120#pragma alloca
120#endif 121#endif
121 122
122int process_arguments (int, char **); 123int process_arguments (int, char **);
@@ -126,13 +127,10 @@ int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, ch
126void print_help (void); 127void print_help (void);
127void print_usage (void); 128void print_usage (void);
128double calculate_percent(uintmax_t, uintmax_t); 129double calculate_percent(uintmax_t, uintmax_t);
129void stat_path (struct parameter_list *p); 130bool stat_path (struct parameter_list *p);
130void get_stats (struct parameter_list *p, struct fs_usage *fsp); 131void get_stats (struct parameter_list *p, struct fs_usage *fsp);
131void get_path_stats (struct parameter_list *p, struct fs_usage *fsp); 132void get_path_stats (struct parameter_list *p, struct fs_usage *fsp);
132 133
133double w_dfp = -1.0;
134double c_dfp = -1.0;
135char *path;
136char *exclude_device; 134char *exclude_device;
137char *units; 135char *units;
138uintmax_t mult = 1024 * 1024; 136uintmax_t mult = 1024 * 1024;
@@ -140,6 +138,7 @@ int verbose = 0;
140int erronly = FALSE; 138int erronly = FALSE;
141int display_mntp = FALSE; 139int display_mntp = FALSE;
142int exact_match = FALSE; 140int exact_match = FALSE;
141bool ignore_missing = false;
143int freespace_ignore_reserved = FALSE; 142int freespace_ignore_reserved = FALSE;
144int display_inodes_perfdata = FALSE; 143int display_inodes_perfdata = FALSE;
145char *warn_freespace_units = NULL; 144char *warn_freespace_units = NULL;
@@ -155,6 +154,7 @@ char *crit_usedinodes_percent = NULL;
155char *warn_freeinodes_percent = NULL; 154char *warn_freeinodes_percent = NULL;
156char *crit_freeinodes_percent = NULL; 155char *crit_freeinodes_percent = NULL;
157int path_selected = FALSE; 156int path_selected = FALSE;
157bool path_ignored = false;
158char *group = NULL; 158char *group = NULL;
159struct stat *stat_buf; 159struct stat *stat_buf;
160struct name_list *seen = NULL; 160struct name_list *seen = NULL;
@@ -166,12 +166,13 @@ main (int argc, char **argv)
166 int result = STATE_UNKNOWN; 166 int result = STATE_UNKNOWN;
167 int disk_result = STATE_UNKNOWN; 167 int disk_result = STATE_UNKNOWN;
168 char *output; 168 char *output;
169 char *ignored;
169 char *details; 170 char *details;
170 char *perf; 171 char *perf;
171 char *perf_ilabel; 172 char *perf_ilabel;
172 char *preamble; 173 char *preamble = " - free space:";
174 char *ignored_preamble = " - ignored paths:";
173 char *flag_header; 175 char *flag_header;
174 double inode_space_pct;
175 int temp_result; 176 int temp_result;
176 177
177 struct mount_entry *me; 178 struct mount_entry *me;
@@ -182,8 +183,8 @@ main (int argc, char **argv)
182 char mountdir[32]; 183 char mountdir[32];
183#endif 184#endif
184 185
185 preamble = strdup (" - free space:");
186 output = strdup (""); 186 output = strdup ("");
187 ignored = strdup ("");
187 details = strdup (""); 188 details = strdup ("");
188 perf = strdup (""); 189 perf = strdup ("");
189 perf_ilabel = strdup (""); 190 perf_ilabel = strdup ("");
@@ -204,7 +205,7 @@ main (int argc, char **argv)
204 /* If a list of paths has not been selected, find entire 205 /* If a list of paths has not been selected, find entire
205 mount list and create list of paths 206 mount list and create list of paths
206 */ 207 */
207 if (path_selected == FALSE) { 208 if (path_selected == FALSE && path_ignored == false) {
208 for (me = mount_list; me; me = me->me_next) { 209 for (me = mount_list; me; me = me->me_next) {
209 if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) { 210 if (! (path = np_find_parameter(path_select_list, me->me_mountdir))) {
210 path = np_add_parameter(&path_select_list, me->me_mountdir); 211 path = np_add_parameter(&path_select_list, me->me_mountdir);
@@ -214,24 +215,49 @@ main (int argc, char **argv)
214 set_all_thresholds(path); 215 set_all_thresholds(path);
215 } 216 }
216 } 217 }
217 np_set_best_match(path_select_list, mount_list, exact_match); 218
219 if (path_ignored == false) {
220 np_set_best_match(path_select_list, mount_list, exact_match);
221 }
218 222
219 /* Error if no match found for specified paths */ 223 /* Error if no match found for specified paths */
220 temp_list = path_select_list; 224 temp_list = path_select_list;
221 225
222 while (temp_list) { 226 while (path_select_list) {
223 if (! temp_list->best_match) { 227 if (! path_select_list->best_match && ignore_missing == true) {
224 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), temp_list->name); 228 /* If the first element will be deleted, the temp_list must be updated with the new start address as well */
229 if (path_select_list == temp_list) {
230 temp_list = path_select_list->name_next;
231 }
232 /* Add path argument to list of ignored paths to inform about missing paths being ignored and not alerted */
233 xasprintf (&ignored, "%s %s;", ignored, path_select_list->name);
234 /* Delete the path from the list so that it is not stat-checked later in the code. */
235 path_select_list = np_del_parameter(path_select_list, path_select_list->name_prev);
236 } else if (! path_select_list->best_match) {
237 /* Without --ignore-missing option, exit with Critical state. */
238 die (STATE_CRITICAL, _("DISK %s: %s not found\n"), _("CRITICAL"), path_select_list->name);
239 } else {
240 /* Continue jumping through the list */
241 path_select_list = path_select_list->name_next;
225 } 242 }
243 }
226 244
227 temp_list = temp_list->name_next; 245 path_select_list = temp_list;
246
247 if (! path_select_list && ignore_missing == true) {
248 result = STATE_OK;
249 if (verbose >= 2) {
250 printf ("None of the provided paths were found\n");
251 }
228 } 252 }
229 253
230 /* Process for every path in list */ 254 /* Process for every path in list */
231 for (path = path_select_list; path; path=path->name_next) { 255 for (path = path_select_list; path; path=path->name_next) {
232 if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL) 256 if (verbose >= 3 && path->freespace_percent->warning != NULL && path->freespace_percent->critical != NULL)
233 printf("Thresholds(pct) for %s warn: %f crit %f\n",path->name, path->freespace_percent->warning->end, 257 printf("Thresholds(pct) for %s warn: %f crit %f\n",
234 path->freespace_percent->critical->end); 258 path->name,
259 path->freespace_percent->warning->end,
260 path->freespace_percent->critical->end);
235 261
236 if (verbose >= 3 && path->group != NULL) 262 if (verbose >= 3 && path->group != NULL)
237 printf("Group of %s: %s\n",path->name,path->group); 263 printf("Group of %s: %s\n",path->name,path->group);
@@ -241,6 +267,10 @@ main (int argc, char **argv)
241 267
242 me = path->best_match; 268 me = path->best_match;
243 269
270 if (!me) {
271 continue;
272 }
273
244#ifdef __CYGWIN__ 274#ifdef __CYGWIN__
245 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11) 275 if (strncmp(path->name, "/cygdrive/", 10) != 0 || strlen(path->name) > 11)
246 continue; 276 continue;
@@ -259,8 +289,12 @@ main (int argc, char **argv)
259 if (path->group == NULL) { 289 if (path->group == NULL) {
260 /* Skip remote filesystems if we're not interested in them */ 290 /* Skip remote filesystems if we're not interested in them */
261 if (me->me_remote && show_local_fs) { 291 if (me->me_remote && show_local_fs) {
262 if (stat_remote_fs) 292 if (stat_remote_fs) {
263 stat_path(path); 293 if (!stat_path(path) && ignore_missing == true) {
294 result = STATE_OK;
295 xasprintf (&ignored, "%s %s;", ignored, path->name);
296 }
297 }
264 continue; 298 continue;
265 /* Skip pseudo fs's if we haven't asked for all fs's */ 299 /* Skip pseudo fs's if we haven't asked for all fs's */
266 } else if (me->me_dummy && !show_all_fs) { 300 } else if (me->me_dummy && !show_all_fs) {
@@ -279,14 +313,20 @@ main (int argc, char **argv)
279 } 313 }
280 } 314 }
281 315
282 stat_path(path); 316 if (!stat_path(path)) {
317 if (ignore_missing == true) {
318 result = STATE_OK;
319 xasprintf (&ignored, "%s %s;", ignored, path->name);
320 }
321 continue;
322 }
283 get_fs_usage (me->me_mountdir, me->me_devname, &fsp); 323 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
284 324
285 if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) { 325 if (fsp.fsu_blocks && strcmp ("none", me->me_mountdir)) {
286 get_stats (path, &fsp); 326 get_stats (path, &fsp);
287 327
288 if (verbose >= 3) { 328 if (verbose >= 3) {
289 printf ("For %s, used_pct=%g free_pct=%g used_units=%llu free_units=%llu total_units=%llu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%llu mult=%llu\n", 329 printf ("For %s, used_pct=%g free_pct=%g used_units=%lu free_units=%lu total_units=%lu used_inodes_pct=%g free_inodes_pct=%g fsp.fsu_blocksize=%lu mult=%lu\n",
290 me->me_mountdir, 330 me->me_mountdir,
291 path->dused_pct, 331 path->dused_pct,
292 path->dfree_pct, 332 path->dfree_pct,
@@ -367,10 +407,10 @@ main (int argc, char **argv)
367 critical_high_tide = UINT64_MAX; 407 critical_high_tide = UINT64_MAX;
368 408
369 if (path->freeinodes_percent->warning != NULL) { 409 if (path->freeinodes_percent->warning != NULL) {
370 warning_high_tide = llabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total )); 410 warning_high_tide = (uint64_t) fabs( min( (double) warning_high_tide, (double) (1.0 - path->freeinodes_percent->warning->end/100)*path->inodes_total ));
371 } 411 }
372 if (path->freeinodes_percent->critical != NULL) { 412 if (path->freeinodes_percent->critical != NULL) {
373 critical_high_tide = llabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total )); 413 critical_high_tide = (uint64_t) fabs( min( (double) critical_high_tide, (double) (1.0 - path->freeinodes_percent->critical->end/100)*path->inodes_total ));
374 } 414 }
375 415
376 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir); 416 xasprintf (&perf_ilabel, "%s (inodes)", (!strcmp(me->me_mountdir, "none") || display_mntp) ? me->me_devname : me->me_mountdir);
@@ -404,22 +444,18 @@ main (int argc, char **argv)
404 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : "")); 444 xasprintf(&output, "%s inode=%.0f%%)%s;", output, path->dfree_inodes_percent, ((disk_result && verbose >= 1) ? "]" : ""));
405 } 445 }
406 free(flag_header); 446 free(flag_header);
407 /* TODO: Need to do a similar debug line
408 xasprintf (&details, _("%s\n\%.0f of %.0f %s (%.0f%% inode=%.0f%%) free on %s (type %s mounted on %s) warn:%lu crit:%lu warn%%:%.0f%% crit%%:%.0f%%"),
409 details, dfree_units, dtotal_units, units, dfree_pct, inode_space_pct,
410 me->me_devname, me->me_type, me->me_mountdir,
411 (unsigned long)w_df, (unsigned long)c_df, w_dfp, c_dfp);
412 */
413
414 } 447 }
415
416 } 448 }
417 449
418 if (verbose >= 2) 450 if (verbose >= 2)
419 xasprintf (&output, "%s%s", output, details); 451 xasprintf (&output, "%s%s", output, details);
420 452
453 if (strcmp(output, "") == 0 && ! erronly) {
454 preamble = "";
455 xasprintf (&output, " - No disks were found for provided parameters;");
456 }
421 457
422 printf ("DISK %s%s%s|%s\n", state_text (result), (erronly && result==STATE_OK) ? "" : preamble, output, perf); 458 printf ("DISK %s%s%s%s%s|%s\n", state_text (result), ((erronly && result==STATE_OK)) ? "" : preamble, output, (strcmp(ignored, "") == 0) ? "" : ignored_preamble, ignored, perf);
423 return result; 459 return result;
424} 460}
425 461
@@ -488,6 +524,7 @@ process_arguments (int argc, char **argv)
488 {"ignore-ereg-partition", required_argument, 0, 'i'}, 524 {"ignore-ereg-partition", required_argument, 0, 'i'},
489 {"ignore-eregi-path", required_argument, 0, 'I'}, 525 {"ignore-eregi-path", required_argument, 0, 'I'},
490 {"ignore-eregi-partition", required_argument, 0, 'I'}, 526 {"ignore-eregi-partition", required_argument, 0, 'I'},
527 {"ignore-missing", no_argument, 0, IGNORE_MISSING},
491 {"local", no_argument, 0, 'l'}, 528 {"local", no_argument, 0, 'l'},
492 {"stat-remote-fs", no_argument, 0, 'L'}, 529 {"stat-remote-fs", no_argument, 0, 'L'},
493 {"iperfdata", no_argument, 0, 'P'}, 530 {"iperfdata", no_argument, 0, 'P'},
@@ -547,7 +584,7 @@ process_arguments (int argc, char **argv)
547 584
548 /* Awful mistake where the range values do not make sense. Normally, 585 /* Awful mistake where the range values do not make sense. Normally,
549 you alert if the value is within the range, but since we are using 586 you alert if the value is within the range, but since we are using
550 freespace, we have to alert if outside the range. Thus we artifically 587 freespace, we have to alert if outside the range. Thus we artificially
551 force @ at the beginning of the range, so that it is backwards compatible 588 force @ at the beginning of the range, so that it is backwards compatible
552 */ 589 */
553 case 'c': /* critical threshold */ 590 case 'c': /* critical threshold */
@@ -586,21 +623,36 @@ process_arguments (int argc, char **argv)
586 if (! strcasecmp (optarg, "bytes")) { 623 if (! strcasecmp (optarg, "bytes")) {
587 mult = (uintmax_t)1; 624 mult = (uintmax_t)1;
588 units = strdup ("B"); 625 units = strdup ("B");
589 } else if ( (! strcmp (optarg, "kB")) || (!strcmp(optarg, "KiB")) ) { 626 } else if (!strcmp(optarg, "KiB")) {
590 mult = (uintmax_t)1024; 627 mult = (uintmax_t)1024;
591 units = strdup ("kiB"); 628 units = strdup ("KiB");
592 } else if ( (! strcmp (optarg, "MB")) || (!strcmp(optarg, "MiB")) ) { 629 } else if (! strcmp (optarg, "kB")) {
630 mult = (uintmax_t)1000;
631 units = strdup ("kB");
632 } else if (!strcmp(optarg, "MiB")) {
593 mult = (uintmax_t)1024 * 1024; 633 mult = (uintmax_t)1024 * 1024;
594 units = strdup ("MiB"); 634 units = strdup ("MiB");
595 } else if ( (! strcmp (optarg, "GB")) || (!strcmp(optarg, "GiB")) ) { 635 } else if (! strcmp (optarg, "MB")) {
636 mult = (uintmax_t)1000 * 1000;
637 units = strdup ("MB");
638 } else if (!strcmp(optarg, "GiB")) {
596 mult = (uintmax_t)1024 * 1024 * 1024; 639 mult = (uintmax_t)1024 * 1024 * 1024;
597 units = strdup ("GiB"); 640 units = strdup ("GiB");
598 } else if ( (! strcmp (optarg, "TB")) || (!strcmp(optarg, "TiB")) ) { 641 } else if (! strcmp (optarg, "GB")){
642 mult = (uintmax_t)1000 * 1000 * 1000;
643 units = strdup ("GB");
644 } else if (!strcmp(optarg, "TiB")) {
599 mult = (uintmax_t)1024 * 1024 * 1024 * 1024; 645 mult = (uintmax_t)1024 * 1024 * 1024 * 1024;
600 units = strdup ("TiB"); 646 units = strdup ("TiB");
601 } else if ( (! strcmp (optarg, "PB")) || (!strcmp(optarg, "PiB")) ) { 647 } else if (! strcmp (optarg, "TB")) {
648 mult = (uintmax_t)1000 * 1000 * 1000 * 1000;
649 units = strdup ("TB");
650 } else if (!strcmp(optarg, "PiB")) {
602 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024; 651 mult = (uintmax_t)1024 * 1024 * 1024 * 1024 * 1024;
603 units = strdup ("PiB"); 652 units = strdup ("PiB");
653 } else if (! strcmp (optarg, "PB")){
654 mult = (uintmax_t)1000 * 1000 * 1000 * 1000 * 1000;
655 units = strdup ("PB");
604 } else { 656 } else {
605 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg); 657 die (STATE_UNKNOWN, _("unit type %s not known\n"), optarg);
606 } 658 }
@@ -639,12 +691,19 @@ process_arguments (int argc, char **argv)
639 /* add parameter if not found. overwrite thresholds if path has already been added */ 691 /* add parameter if not found. overwrite thresholds if path has already been added */
640 if (! (se = np_find_parameter(path_select_list, optarg))) { 692 if (! (se = np_find_parameter(path_select_list, optarg))) {
641 se = np_add_parameter(&path_select_list, optarg); 693 se = np_add_parameter(&path_select_list, optarg);
694
695 if (stat(optarg, &stat_buf[0]) && ignore_missing == true) {
696 path_ignored = true;
697 break;
698 }
642 } 699 }
643 se->group = group; 700 se->group = group;
644 set_all_thresholds(se); 701 set_all_thresholds(se);
645 702
646 /* With autofs, it is required to stat() the path before re-populating the mount_list */ 703 /* With autofs, it is required to stat() the path before re-populating the mount_list */
647 stat_path(se); 704 if (!stat_path(se)) {
705 break;
706 }
648 /* NB: We can't free the old mount_list "just like that": both list pointers and struct 707 /* NB: We can't free the old mount_list "just like that": both list pointers and struct
649 * pointers are copied around. One of the reason it wasn't done yet is that other parts 708 * pointers are copied around. One of the reason it wasn't done yet is that other parts
650 * of check_disk need the same kind of cleanup so it'd better be done as a whole */ 709 * of check_disk need the same kind of cleanup so it'd better be done as a whole */
@@ -687,6 +746,7 @@ process_arguments (int argc, char **argv)
687 break; 746 break;
688 case 'I': 747 case 'I':
689 cflags |= REG_ICASE; 748 cflags |= REG_ICASE;
749 // Intentional fallthrough
690 case 'i': 750 case 'i':
691 if (!path_selected) 751 if (!path_selected)
692 die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly")); 752 die (STATE_UNKNOWN, "DISK %s: %s\n", _("UNKNOWN"), _("Paths need to be selected before using -i/-I. Use -A to select all paths explicitly"));
@@ -724,10 +784,15 @@ process_arguments (int argc, char **argv)
724 cflags = default_cflags; 784 cflags = default_cflags;
725 break; 785 break;
726 786
787 case IGNORE_MISSING:
788 ignore_missing = true;
789 break;
727 case 'A': 790 case 'A':
728 optarg = strdup(".*"); 791 optarg = strdup(".*");
792 // Intentional fallthrough
729 case 'R': 793 case 'R':
730 cflags |= REG_ICASE; 794 cflags |= REG_ICASE;
795 // Intentional fallthrough
731 case 'r': 796 case 'r':
732 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent || 797 if (! (warn_freespace_units || crit_freespace_units || warn_freespace_percent ||
733 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units || 798 crit_freespace_percent || warn_usedspace_units || crit_usedspace_units ||
@@ -757,7 +822,11 @@ process_arguments (int argc, char **argv)
757 } 822 }
758 } 823 }
759 824
760 if (!fnd) 825 if (!fnd && ignore_missing == true) {
826 path_ignored = true;
827 /* path_selected = TRUE;*/
828 break;
829 } else if (!fnd)
761 die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"), 830 die (STATE_UNKNOWN, "DISK %s: %s - %s\n",_("UNKNOWN"),
762 _("Regular expression did not match any path or disk"), optarg); 831 _("Regular expression did not match any path or disk"), optarg);
763 832
@@ -817,7 +886,7 @@ process_arguments (int argc, char **argv)
817 if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c])) 886 if (crit_usedspace_percent == NULL && argc > c && is_intnonneg (argv[c]))
818 crit_usedspace_percent = argv[c++]; 887 crit_usedspace_percent = argv[c++];
819 888
820 if (argc > c && path == NULL) { 889 if (argc > c) {
821 se = np_add_parameter(&path_select_list, strdup(argv[c++])); 890 se = np_add_parameter(&path_select_list, strdup(argv[c++]));
822 path_selected = TRUE; 891 path_selected = TRUE;
823 set_all_thresholds(se); 892 set_all_thresholds(se);
@@ -860,51 +929,6 @@ set_all_thresholds (struct parameter_list *path)
860 set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent); 929 set_thresholds(&path->freeinodes_percent, warn_freeinodes_percent, crit_freeinodes_percent);
861} 930}
862 931
863/* TODO: Remove?
864
865int
866validate_arguments (uintmax_t w, uintmax_t c, double wp, double cp, double iwp, double icp, char *mypath)
867{
868 if (w < 0 && c < 0 && wp < 0.0 && cp < 0.0) {
869 printf (_("INPUT ERROR: No thresholds specified"));
870 print_path (mypath);
871 return ERROR;
872 }
873 else if ((wp >= 0.0 || cp >= 0.0) &&
874 (wp < 0.0 || cp < 0.0 || wp > 100.0 || cp > 100.0 || cp > wp)) {
875 printf (_("\
876INPUT ERROR: C_DFP (%f) should be less than W_DFP (%.1f) and both should be between zero and 100 percent, inclusive"),
877 cp, wp);
878 print_path (mypath);
879 return ERROR;
880 }
881 else if ((iwp >= 0.0 || icp >= 0.0) &&
882 (iwp < 0.0 || icp < 0.0 || iwp > 100.0 || icp > 100.0 || icp > iwp)) {
883 printf (_("\
884INPUT ERROR: C_IDFP (%f) should be less than W_IDFP (%.1f) and both should be between zero and 100 percent, inclusive"),
885 icp, iwp);
886 print_path (mypath);
887 return ERROR;
888 }
889 else if ((w > 0 || c > 0) && (w == 0 || c == 0 || c > w)) {
890 printf (_("\
891INPUT ERROR: C_DF (%lu) should be less than W_DF (%lu) and both should be greater than zero"),
892 (unsigned long)c, (unsigned long)w);
893 print_path (mypath);
894 return ERROR;
895 }
896
897 return OK;
898}
899
900*/
901
902
903
904
905
906
907
908void 932void
909print_help (void) 933print_help (void)
910{ 934{
@@ -959,7 +983,7 @@ print_help (void)
959 printf (" %s\n", _("Only check local filesystems against thresholds. Yet call stat on remote filesystems")); 983 printf (" %s\n", _("Only check local filesystems against thresholds. Yet call stat on remote filesystems"));
960 printf (" %s\n", _("to test if they are accessible (e.g. to detect Stale NFS Handles)")); 984 printf (" %s\n", _("to test if they are accessible (e.g. to detect Stale NFS Handles)"));
961 printf (" %s\n", "-M, --mountpoint"); 985 printf (" %s\n", "-M, --mountpoint");
962 printf (" %s\n", _("Display the mountpoint instead of the partition")); 986 printf (" %s\n", _("Display the (block) device instead of the mount point"));
963 printf (" %s\n", "-m, --megabytes"); 987 printf (" %s\n", "-m, --megabytes");
964 printf (" %s\n", _("Same as '--units MB'")); 988 printf (" %s\n", _("Same as '--units MB'"));
965 printf (" %s\n", "-A, --all"); 989 printf (" %s\n", "-A, --all");
@@ -972,6 +996,9 @@ print_help (void)
972 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)")); 996 printf (" %s\n", _("Regular expression to ignore selected path/partition (case insensitive) (may be repeated)"));
973 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION"); 997 printf (" %s\n", "-i, --ignore-ereg-path=PATH, --ignore-ereg-partition=PARTITION");
974 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)")); 998 printf (" %s\n", _("Regular expression to ignore selected path or partition (may be repeated)"));
999 printf (" %s\n", "--ignore-missing");
1000 printf (" %s\n", _("Return OK if no filesystem matches, filesystem does not exist or is inaccessible."));
1001 printf (" %s\n", _("(Provide this option before -p / -r / --ereg-path if used)"));
975 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1002 printf (UT_PLUG_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
976 printf (" %s\n", "-u, --units=STRING"); 1003 printf (" %s\n", "-u, --units=STRING");
977 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)")); 1004 printf (" %s\n", _("Choose bytes, kB, MB, GB, TB (default: MB)"));
@@ -1000,12 +1027,12 @@ void
1000print_usage (void) 1027print_usage (void)
1001{ 1028{
1002 printf ("%s\n", _("Usage:")); 1029 printf ("%s\n", _("Usage:"));
1003 printf (" %s -w limit -c limit [-W limit] [-K limit] {-p path | -x device}\n", progname); 1030 printf (" %s {-w absolute_limit |-w percentage_limit% | -W inode_percentage_limit } {-c absolute_limit|-c percentage_limit% | -K inode_percentage_limit } {-p path | -x device}\n", progname);
1004 printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n"); 1031 printf ("[-C] [-E] [-e] [-f] [-g group ] [-k] [-l] [-M] [-m] [-R path ] [-r path ]\n");
1005 printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n"); 1032 printf ("[-t timeout] [-u unit] [-v] [-X type] [-N type]\n");
1006} 1033}
1007 1034
1008void 1035bool
1009stat_path (struct parameter_list *p) 1036stat_path (struct parameter_list *p)
1010{ 1037{
1011 /* Stat entry to check that dir exists and is accessible */ 1038 /* Stat entry to check that dir exists and is accessible */
@@ -1014,9 +1041,14 @@ stat_path (struct parameter_list *p)
1014 if (stat (p->name, &stat_buf[0])) { 1041 if (stat (p->name, &stat_buf[0])) {
1015 if (verbose >= 3) 1042 if (verbose >= 3)
1016 printf("stat failed on %s\n", p->name); 1043 printf("stat failed on %s\n", p->name);
1017 printf("DISK %s - ", _("CRITICAL")); 1044 if (ignore_missing == true) {
1018 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno)); 1045 return false;
1046 } else {
1047 printf("DISK %s - ", _("CRITICAL"));
1048 die (STATE_CRITICAL, _("%s %s: %s\n"), p->name, _("is not accessible"), strerror(errno));
1049 }
1019 } 1050 }
1051 return true;
1020} 1052}
1021 1053
1022 1054
@@ -1036,13 +1068,20 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1036 continue; 1068 continue;
1037#endif 1069#endif
1038 if (p_list->group && ! (strcmp(p_list->group, p->group))) { 1070 if (p_list->group && ! (strcmp(p_list->group, p->group))) {
1039 stat_path(p_list); 1071 if (! stat_path(p_list))
1072 continue;
1040 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp); 1073 get_fs_usage (p_list->best_match->me_mountdir, p_list->best_match->me_devname, &tmpfsp);
1041 get_path_stats(p_list, &tmpfsp); 1074 get_path_stats(p_list, &tmpfsp);
1042 if (verbose >= 3) 1075 if (verbose >= 3)
1043 printf("Group %s: adding %llu blocks sized %llu, (%s) used_units=%g free_units=%g total_units=%g fsu_blocksize=%llu mult=%llu\n", 1076 printf("Group %s: adding %lu blocks sized %lu, (%s) used_units=%lu free_units=%lu total_units=%lu mult=%lu\n",
1044 p_list->group, tmpfsp.fsu_bavail, tmpfsp.fsu_blocksize, p_list->best_match->me_mountdir, p_list->dused_units, p_list->dfree_units, 1077 p_list->group,
1045 p_list->dtotal_units, mult); 1078 tmpfsp.fsu_blocks,
1079 tmpfsp.fsu_blocksize,
1080 p_list->best_match->me_mountdir,
1081 p_list->dused_units,
1082 p_list->dfree_units,
1083 p_list->dtotal_units,
1084 mult);
1046 1085
1047 /* prevent counting the first FS of a group twice since its parameter_list entry 1086 /* prevent counting the first FS of a group twice since its parameter_list entry
1048 * is used to carry the information of all file systems of the entire group */ 1087 * is used to carry the information of all file systems of the entire group */
@@ -1063,14 +1102,12 @@ get_stats (struct parameter_list *p, struct fs_usage *fsp) {
1063 first = 0; 1102 first = 0;
1064 } 1103 }
1065 if (verbose >= 3) 1104 if (verbose >= 3)
1066 printf("Group %s now has: used_units=%g free_units=%g total_units=%g fsu_blocksize=%llu mult=%llu\n", 1105 printf("Group %s now has: used_units=%lu free_units=%lu total_units=%lu fsu_blocksize=%lu mult=%lu\n",
1067 p->group, 1106 p->group,
1068 tmpfsp.fsu_bavail,
1069 tmpfsp.fsu_blocksize,
1070 p->best_match->me_mountdir,
1071 p->dused_units, 1107 p->dused_units,
1072 p->dfree_units, 1108 p->dfree_units,
1073 p->dtotal_units, 1109 p->dtotal_units,
1110 tmpfsp.fsu_blocksize,
1074 mult); 1111 mult);
1075 } 1112 }
1076 /* modify devname and mountdir for output */ 1113 /* modify devname and mountdir for output */
@@ -1090,7 +1127,7 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
1090 p->available_to_root = fsp->fsu_bfree; 1127 p->available_to_root = fsp->fsu_bfree;
1091 p->used = fsp->fsu_blocks - fsp->fsu_bfree; 1128 p->used = fsp->fsu_blocks - fsp->fsu_bfree;
1092 if (freespace_ignore_reserved) { 1129 if (freespace_ignore_reserved) {
1093 /* option activated : we substract the root-reserved space from the total */ 1130 /* option activated : we subtract the root-reserved space from the total */
1094 p->total = fsp->fsu_blocks - p->available_to_root + p->available; 1131 p->total = fsp->fsu_blocks - p->available_to_root + p->available;
1095 } else { 1132 } else {
1096 /* default behaviour : take all the blocks into account */ 1133 /* default behaviour : take all the blocks into account */
@@ -1101,11 +1138,11 @@ get_path_stats (struct parameter_list *p, struct fs_usage *fsp) {
1101 p->dfree_units = p->available*fsp->fsu_blocksize/mult; 1138 p->dfree_units = p->available*fsp->fsu_blocksize/mult;
1102 p->dtotal_units = p->total*fsp->fsu_blocksize/mult; 1139 p->dtotal_units = p->total*fsp->fsu_blocksize/mult;
1103 /* Free file nodes. Not sure the workaround is required, but in case...*/ 1140 /* Free file nodes. Not sure the workaround is required, but in case...*/
1104 p->inodes_free = fsp->fsu_favail > fsp->fsu_ffree ? 0 : fsp->fsu_favail; 1141 p->inodes_free = fsp->fsu_ffree;
1105 p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */ 1142 p->inodes_free_to_root = fsp->fsu_ffree; /* Free file nodes for root. */
1106 p->inodes_used = fsp->fsu_files - fsp->fsu_ffree; 1143 p->inodes_used = fsp->fsu_files - fsp->fsu_ffree;
1107 if (freespace_ignore_reserved) { 1144 if (freespace_ignore_reserved) {
1108 /* option activated : we substract the root-reserved inodes from the total */ 1145 /* option activated : we subtract the root-reserved inodes from the total */
1109 /* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */ 1146 /* not all OS report fsp->fsu_favail, only the ones with statvfs syscall */
1110 /* for others, fsp->fsu_ffree == fsp->fsu_favail */ 1147 /* for others, fsp->fsu_ffree == fsp->fsu_favail */
1111 p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free; 1148 p->inodes_total = fsp->fsu_files - p->inodes_free_to_root + p->inodes_free;
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 9de6caf..7ffce98 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -75,7 +75,7 @@ main (int argc, char **argv)
75{ 75{
76 char *command_line = NULL; 76 char *command_line = NULL;
77 char input_buffer[MAX_INPUT_BUFFER]; 77 char input_buffer[MAX_INPUT_BUFFER];
78 char *address = NULL; /* comma seperated str with addrs/ptrs (sorted) */ 78 char *address = NULL; /* comma separated str with addrs/ptrs (sorted) */
79 char **addresses = NULL; 79 char **addresses = NULL;
80 int n_addresses = 0; 80 int n_addresses = 0;
81 char *msg = NULL; 81 char *msg = NULL;
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index 521d0fe..23a9e99 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -37,6 +37,7 @@ const char *email = "devel@monitoring-plugins.org";
37#include "popen.h" 37#include "popen.h"
38#include "netutils.h" 38#include "netutils.h"
39#include "utils.h" 39#include "utils.h"
40#include <stdbool.h>
40 41
41enum { 42enum {
42 PACKET_COUNT = 1, 43 PACKET_COUNT = 1,
@@ -65,13 +66,14 @@ double crta;
65double wrta; 66double wrta;
66int cpl_p = FALSE; 67int cpl_p = FALSE;
67int wpl_p = FALSE; 68int wpl_p = FALSE;
69bool alive_p = FALSE;
68int crta_p = FALSE; 70int crta_p = FALSE;
69int wrta_p = FALSE; 71int wrta_p = FALSE;
70 72
71int 73int
72main (int argc, char **argv) 74main (int argc, char **argv)
73{ 75{
74/* normaly should be int result = STATE_UNKNOWN; */ 76/* normally should be int result = STATE_UNKNOWN; */
75 77
76 int status = STATE_UNKNOWN; 78 int status = STATE_UNKNOWN;
77 int result = 0; 79 int result = 0;
@@ -147,9 +149,11 @@ main (int argc, char **argv)
147 (void) fclose (child_stderr); 149 (void) fclose (child_stderr);
148 150
149 /* close the pipe */ 151 /* close the pipe */
150 if (result = spclose (child_process)) 152 result = spclose (child_process);
153 if (result) {
151 /* need to use max_state not max */ 154 /* need to use max_state not max */
152 status = max_state (status, STATE_WARNING); 155 status = max_state (status, STATE_WARNING);
156 }
153 157
154 if (result > 1 ) { 158 if (result > 1 ) {
155 status = max_state (status, STATE_UNKNOWN); 159 status = max_state (status, STATE_UNKNOWN);
@@ -171,10 +175,7 @@ main (int argc, char **argv)
171} 175}
172 176
173 177
174 178int textscan (char *buf) {
175int
176textscan (char *buf)
177{
178 char *rtastr = NULL; 179 char *rtastr = NULL;
179 char *losstr = NULL; 180 char *losstr = NULL;
180 char *xmtstr = NULL; 181 char *xmtstr = NULL;
@@ -183,6 +184,20 @@ textscan (char *buf)
183 double xmt; 184 double xmt;
184 int status = STATE_UNKNOWN; 185 int status = STATE_UNKNOWN;
185 186
187 /* stops testing after the first successful reply. */
188 if (alive_p && strstr(buf, "avg, 0% loss)")) {
189 rtastr = strstr (buf, "ms (");
190 rtastr = 1 + index(rtastr, '(');
191 rta = strtod(rtastr, NULL);
192 loss=strtod("0",NULL);
193 die (STATE_OK,
194 _("FPING %s - %s (rta=%f ms)|%s\n"),
195 state_text (STATE_OK), server_name,rta,
196 /* No loss since we only waited for the first reply
197 perfdata ("loss", (long int)loss, "%", wpl_p, wpl, cpl_p, cpl, TRUE, 0, TRUE, 100), */
198 fperfdata ("rta", rta/1.0e3, "s", wrta_p, wrta/1.0e3, crta_p, crta/1.0e3, TRUE, 0, FALSE, 0));
199 }
200
186 if (strstr (buf, "not found")) { 201 if (strstr (buf, "not found")) {
187 die (STATE_CRITICAL, _("FPING UNKNOWN - %s not found\n"), server_name); 202 die (STATE_CRITICAL, _("FPING UNKNOWN - %s not found\n"), server_name);
188 203
@@ -278,6 +293,7 @@ process_arguments (int argc, char **argv)
278 {"sourceif", required_argument, 0, 'I'}, 293 {"sourceif", required_argument, 0, 'I'},
279 {"critical", required_argument, 0, 'c'}, 294 {"critical", required_argument, 0, 'c'},
280 {"warning", required_argument, 0, 'w'}, 295 {"warning", required_argument, 0, 'w'},
296 {"alive", no_argument, 0, 'a'},
281 {"bytes", required_argument, 0, 'b'}, 297 {"bytes", required_argument, 0, 'b'},
282 {"number", required_argument, 0, 'n'}, 298 {"number", required_argument, 0, 'n'},
283 {"target-timeout", required_argument, 0, 'T'}, 299 {"target-timeout", required_argument, 0, 'T'},
@@ -304,7 +320,7 @@ process_arguments (int argc, char **argv)
304 } 320 }
305 321
306 while (1) { 322 while (1) {
307 c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:46", longopts, &option); 323 c = getopt_long (argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option);
308 324
309 if (c == -1 || c == EOF || c == 1) 325 if (c == -1 || c == EOF || c == 1)
310 break; 326 break;
@@ -312,6 +328,9 @@ process_arguments (int argc, char **argv)
312 switch (c) { 328 switch (c) {
313 case '?': /* print short usage statement if args not parsable */ 329 case '?': /* print short usage statement if args not parsable */
314 usage5 (); 330 usage5 ();
331 case 'a': /* host alive mode */
332 alive_p = TRUE;
333 break;
315 case 'h': /* help */ 334 case 'h': /* help */
316 print_help (); 335 print_help ();
317 exit (STATE_UNKNOWN); 336 exit (STATE_UNKNOWN);
@@ -335,6 +354,7 @@ process_arguments (int argc, char **argv)
335 break; 354 break;
336 case 'I': /* sourceip */ 355 case 'I': /* sourceip */
337 sourceif = strscpy (sourceif, optarg); 356 sourceif = strscpy (sourceif, optarg);
357 break;
338 case '4': /* IPv4 only */ 358 case '4': /* IPv4 only */
339 address_family = AF_INET; 359 address_family = AF_INET;
340 break; 360 break;
@@ -446,9 +466,7 @@ get_threshold (char *arg, char *rv[2])
446} 466}
447 467
448 468
449void 469void print_help (void) {
450print_help (void)
451{
452 470
453 print_revision (progname, NP_VERSION); 471 print_revision (progname, NP_VERSION);
454 472
@@ -474,6 +492,8 @@ print_help (void)
474 printf (" %s\n", _("warning threshold pair")); 492 printf (" %s\n", _("warning threshold pair"));
475 printf (" %s\n", "-c, --critical=THRESHOLD"); 493 printf (" %s\n", "-c, --critical=THRESHOLD");
476 printf (" %s\n", _("critical threshold pair")); 494 printf (" %s\n", _("critical threshold pair"));
495 printf (" %s\n", "-a, --alive");
496 printf (" %s\n", _("Return OK after first successful reply"));
477 printf (" %s\n", "-b, --bytes=INTEGER"); 497 printf (" %s\n", "-b, --bytes=INTEGER");
478 printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE); 498 printf (" %s (default: %d)\n", _("size of ICMP packet"),PACKET_SIZE);
479 printf (" %s\n", "-n, --number=INTEGER"); 499 printf (" %s\n", "-n, --number=INTEGER");
diff --git a/plugins/check_game.c b/plugins/check_game.c
index 709dae1..a534b69 100644
--- a/plugins/check_game.c
+++ b/plugins/check_game.c
@@ -318,7 +318,7 @@ print_help (void)
318 printf ("%s\n", _("Notes:")); 318 printf ("%s\n", _("Notes:"));
319 printf (" %s\n", _("This plugin uses the 'qstat' command, the popular game server status query tool.")); 319 printf (" %s\n", _("This plugin uses the 'qstat' command, the popular game server status query tool."));
320 printf (" %s\n", _("If you don't have the package installed, you will need to download it from")); 320 printf (" %s\n", _("If you don't have the package installed, you will need to download it from"));
321 printf (" %s\n", _("http://www.activesw.com/people/steve/qstat.html before you can use this plugin.")); 321 printf (" %s\n", _("https://github.com/multiplay/qstat before you can use this plugin."));
322 322
323 printf (UT_SUPPORT); 323 printf (UT_SUPPORT);
324} 324}
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 6546556..c34bb08 100644
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
@@ -66,7 +66,7 @@ void print_usage (void);
66 66
67char *community = NULL; 67char *community = NULL;
68char *address = NULL; 68char *address = NULL;
69char *port = NULL; 69unsigned int port = 0;
70int check_paper_out = 1; 70int check_paper_out = 1;
71 71
72int 72int
@@ -121,8 +121,12 @@ main (int argc, char **argv)
121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY); 121 HPJD_GD_DOOR_OPEN, HPJD_GD_PAPER_OUTPUT, HPJD_GD_STATUS_DISPLAY);
122 122
123 /* get the command to run */ 123 /* get the command to run */
124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%hd %s", PATH_TO_SNMPGET, community, 124 sprintf (command_line, "%s -OQa -m : -v 1 -c %s %s:%u %s",
125 address, port, query_string); 125 PATH_TO_SNMPGET,
126 community,
127 address,
128 port,
129 query_string);
126 130
127 /* run the command */ 131 /* run the command */
128 child_process = spopen (command_line); 132 child_process = spopen (command_line);
@@ -349,6 +353,7 @@ process_arguments (int argc, char **argv)
349 usage2 (_("Port must be a positive short integer"), optarg); 353 usage2 (_("Port must be a positive short integer"), optarg);
350 else 354 else
351 port = atoi(optarg); 355 port = atoi(optarg);
356 break;
352 case 'D': /* disable paper out check*/ 357 case 'D': /* disable paper out check*/
353 check_paper_out = 0; 358 check_paper_out = 0;
354 break; 359 break;
@@ -380,11 +385,8 @@ process_arguments (int argc, char **argv)
380 community = strdup (DEFAULT_COMMUNITY); 385 community = strdup (DEFAULT_COMMUNITY);
381 } 386 }
382 387
383 if (port == NULL) { 388 if (port == 0) {
384 if (argv[c] != NULL ) 389 port = atoi(DEFAULT_PORT);
385 port = argv[c];
386 else
387 port = atoi (DEFAULT_PORT);
388 } 390 }
389 391
390 return validate_arguments (); 392 return validate_arguments ();
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 34fb4f0..718c8ee 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -31,13 +31,14 @@
31* 31*
32*****************************************************************************/ 32*****************************************************************************/
33 33
34/* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
35
36const char *progname = "check_http"; 34const char *progname = "check_http";
37const char *copyright = "1999-2013"; 35const char *copyright = "1999-2022";
38const char *email = "devel@monitoring-plugins.org"; 36const char *email = "devel@monitoring-plugins.org";
39 37
38// Do NOT sort those headers, it will break the build
39// TODO: Fix this
40#include "common.h" 40#include "common.h"
41#include "base64.h"
41#include "netutils.h" 42#include "netutils.h"
42#include "utils.h" 43#include "utils.h"
43#include "base64.h" 44#include "base64.h"
@@ -52,11 +53,13 @@ enum {
52 MAX_IPV4_HOSTLENGTH = 255, 53 MAX_IPV4_HOSTLENGTH = 255,
53 HTTP_PORT = 80, 54 HTTP_PORT = 80,
54 HTTPS_PORT = 443, 55 HTTPS_PORT = 443,
55 MAX_PORT = 65535 56 MAX_PORT = 65535,
57 DEFAULT_MAX_REDIRS = 15
56}; 58};
57 59
58#ifdef HAVE_SSL 60#ifdef HAVE_SSL
59int check_cert = FALSE; 61bool check_cert = false;
62bool continue_after_check_cert = false;
60int ssl_version = 0; 63int ssl_version = 0;
61int days_till_exp_warn, days_till_exp_crit; 64int days_till_exp_warn, days_till_exp_crit;
62char *randbuff; 65char *randbuff;
@@ -67,7 +70,7 @@ X509 *server_cert;
67# define my_recv(buf, len) read(sd, buf, len) 70# define my_recv(buf, len) read(sd, buf, len)
68# define my_send(buf, len) send(sd, buf, len, 0) 71# define my_send(buf, len) send(sd, buf, len, 0)
69#endif /* HAVE_SSL */ 72#endif /* HAVE_SSL */
70int no_body = FALSE; 73bool no_body = false;
71int maximum_age = -1; 74int maximum_age = -1;
72 75
73enum { 76enum {
@@ -89,7 +92,7 @@ struct timeval tv_temp;
89#define HTTP_URL "/" 92#define HTTP_URL "/"
90#define CRLF "\r\n" 93#define CRLF "\r\n"
91 94
92int specify_port = FALSE; 95bool specify_port = false;
93int server_port = HTTP_PORT; 96int server_port = HTTP_PORT;
94int virtual_port = 0; 97int virtual_port = 0;
95char server_port_text[6] = ""; 98char server_port_text[6] = "";
@@ -104,28 +107,26 @@ int server_expect_yn = 0;
104char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; 107char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
105char header_expect[MAX_INPUT_BUFFER] = ""; 108char header_expect[MAX_INPUT_BUFFER] = "";
106char string_expect[MAX_INPUT_BUFFER] = ""; 109char string_expect[MAX_INPUT_BUFFER] = "";
107char output_header_search[30] = "";
108char output_string_search[30] = "";
109char *warning_thresholds = NULL; 110char *warning_thresholds = NULL;
110char *critical_thresholds = NULL; 111char *critical_thresholds = NULL;
111thresholds *thlds; 112thresholds *thlds;
112char user_auth[MAX_INPUT_BUFFER] = ""; 113char user_auth[MAX_INPUT_BUFFER] = "";
113char proxy_auth[MAX_INPUT_BUFFER] = ""; 114char proxy_auth[MAX_INPUT_BUFFER] = "";
114int display_html = FALSE; 115bool display_html = false;
115char **http_opt_headers; 116char **http_opt_headers;
116int http_opt_headers_count = 0; 117int http_opt_headers_count = 0;
117int onredirect = STATE_OK; 118int onredirect = STATE_OK;
118int followsticky = STICKY_NONE; 119int followsticky = STICKY_NONE;
119int use_ssl = FALSE; 120bool use_ssl = false;
120int use_sni = FALSE; 121bool use_sni = false;
121int verbose = FALSE; 122bool verbose = false;
122int show_extended_perfdata = FALSE; 123bool show_extended_perfdata = false;
123int show_body = FALSE; 124bool show_body = false;
124int sd; 125int sd;
125int min_page_len = 0; 126int min_page_len = 0;
126int max_page_len = 0; 127int max_page_len = 0;
127int redir_depth = 0; 128int redir_depth = 0;
128int max_depth = 15; 129int max_depth = DEFAULT_MAX_REDIRS;
129char *http_method; 130char *http_method;
130char *http_method_proxy; 131char *http_method_proxy;
131char *http_post_data; 132char *http_post_data;
@@ -134,10 +135,11 @@ char buffer[MAX_INPUT_BUFFER];
134char *client_cert = NULL; 135char *client_cert = NULL;
135char *client_privkey = NULL; 136char *client_privkey = NULL;
136 137
137int process_arguments (int, char **); 138// Forward function declarations
139bool process_arguments (int, char **);
138int check_http (void); 140int check_http (void);
139void redir (char *pos, char *status_line); 141void redir (char *pos, char *status_line);
140int server_type_check(const char *type); 142bool server_type_check(const char *type);
141int server_port_check(int ssl_flag); 143int server_port_check(int ssl_flag);
142char *perfd_time (double microsec); 144char *perfd_time (double microsec);
143char *perfd_time_connect (double microsec); 145char *perfd_time_connect (double microsec);
@@ -148,6 +150,7 @@ char *perfd_time_transfer (double microsec);
148char *perfd_size (int page_len); 150char *perfd_size (int page_len);
149void print_help (void); 151void print_help (void);
150void print_usage (void); 152void print_usage (void);
153char *unchunk_content(const char *content);
151 154
152int 155int
153main (int argc, char **argv) 156main (int argc, char **argv)
@@ -167,10 +170,10 @@ main (int argc, char **argv)
167 /* Parse extra opts if any */ 170 /* Parse extra opts if any */
168 argv=np_extra_opts (&argc, argv, progname); 171 argv=np_extra_opts (&argc, argv, progname);
169 172
170 if (process_arguments (argc, argv) == ERROR) 173 if (process_arguments (argc, argv) == false)
171 usage4 (_("Could not parse arguments")); 174 usage4 (_("Could not parse arguments"));
172 175
173 if (display_html == TRUE) 176 if (display_html == true)
174 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">", 177 printf ("<A HREF=\"%s://%s:%d%s\" target=\"_blank\">",
175 use_ssl ? "https" : "http", host_name ? host_name : server_address, 178 use_ssl ? "https" : "http", host_name ? host_name : server_address,
176 server_port, server_url); 179 server_port, server_url);
@@ -193,9 +196,11 @@ test_file (char *path)
193 usage2 (_("file does not exist or is not readable"), path); 196 usage2 (_("file does not exist or is not readable"), path);
194} 197}
195 198
196/* process command-line arguments */ 199/*
197int 200 * process command-line arguments
198process_arguments (int argc, char **argv) 201 * returns true on success, false otherwise
202 */
203bool process_arguments (int argc, char **argv)
199{ 204{
200 int c = 1; 205 int c = 1;
201 char *p; 206 char *p;
@@ -203,7 +208,9 @@ process_arguments (int argc, char **argv)
203 208
204 enum { 209 enum {
205 INVERT_REGEX = CHAR_MAX + 1, 210 INVERT_REGEX = CHAR_MAX + 1,
206 SNI_OPTION 211 SNI_OPTION,
212 MAX_REDIRS_OPTION,
213 CONTINUE_AFTER_CHECK_CERT
207 }; 214 };
208 215
209 int option = 0; 216 int option = 0;
@@ -231,6 +238,7 @@ process_arguments (int argc, char **argv)
231 {"certificate", required_argument, 0, 'C'}, 238 {"certificate", required_argument, 0, 'C'},
232 {"client-cert", required_argument, 0, 'J'}, 239 {"client-cert", required_argument, 0, 'J'},
233 {"private-key", required_argument, 0, 'K'}, 240 {"private-key", required_argument, 0, 'K'},
241 {"continue-after-certificate", no_argument, 0, CONTINUE_AFTER_CHECK_CERT},
234 {"useragent", required_argument, 0, 'A'}, 242 {"useragent", required_argument, 0, 'A'},
235 {"header", required_argument, 0, 'k'}, 243 {"header", required_argument, 0, 'k'},
236 {"no-body", no_argument, 0, 'N'}, 244 {"no-body", no_argument, 0, 'N'},
@@ -242,11 +250,12 @@ process_arguments (int argc, char **argv)
242 {"use-ipv6", no_argument, 0, '6'}, 250 {"use-ipv6", no_argument, 0, '6'},
243 {"extended-perfdata", no_argument, 0, 'E'}, 251 {"extended-perfdata", no_argument, 0, 'E'},
244 {"show-body", no_argument, 0, 'B'}, 252 {"show-body", no_argument, 0, 'B'},
253 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION},
245 {0, 0, 0, 0} 254 {0, 0, 0, 0}
246 }; 255 };
247 256
248 if (argc < 2) 257 if (argc < 2)
249 return ERROR; 258 return false;
250 259
251 for (c = 1; c < argc; c++) { 260 for (c = 1; c < argc; c++) {
252 if (strcmp ("-to", argv[c]) == 0) 261 if (strcmp ("-to", argv[c]) == 0)
@@ -302,10 +311,10 @@ process_arguments (int argc, char **argv)
302 /* xasprintf (&http_opt_headers, "%s", optarg); */ 311 /* xasprintf (&http_opt_headers, "%s", optarg); */
303 break; 312 break;
304 case 'L': /* show html link */ 313 case 'L': /* show html link */
305 display_html = TRUE; 314 display_html = true;
306 break; 315 break;
307 case 'n': /* do not show html link */ 316 case 'n': /* do not show html link */
308 display_html = FALSE; 317 display_html = false;
309 break; 318 break;
310 case 'C': /* Check SSL cert validity */ 319 case 'C': /* Check SSL cert validity */
311#ifdef HAVE_SSL 320#ifdef HAVE_SSL
@@ -326,9 +335,14 @@ process_arguments (int argc, char **argv)
326 usage2 (_("Invalid certificate expiration period"), optarg); 335 usage2 (_("Invalid certificate expiration period"), optarg);
327 days_till_exp_warn = atoi (optarg); 336 days_till_exp_warn = atoi (optarg);
328 } 337 }
329 check_cert = TRUE; 338 check_cert = true;
330 goto enable_ssl; 339 goto enable_ssl;
331#endif 340#endif
341 case CONTINUE_AFTER_CHECK_CERT: /* don't stop after the certificate is checked */
342#ifdef HAVE_SSL
343 continue_after_check_cert = true;
344 break;
345#endif
332 case 'J': /* use client certificate */ 346 case 'J': /* use client certificate */
333#ifdef HAVE_SSL 347#ifdef HAVE_SSL
334 test_file(optarg); 348 test_file(optarg);
@@ -346,7 +360,7 @@ process_arguments (int argc, char **argv)
346 enable_ssl: 360 enable_ssl:
347 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple 361 /* ssl_version initialized to 0 as a default. Only set if it's non-zero. This helps when we include multiple
348 parameters, like -S and -C combinations */ 362 parameters, like -S and -C combinations */
349 use_ssl = TRUE; 363 use_ssl = true;
350 if (c=='S' && optarg != NULL) { 364 if (c=='S' && optarg != NULL) {
351 int got_plus = strchr(optarg, '+') != NULL; 365 int got_plus = strchr(optarg, '+') != NULL;
352 366
@@ -363,7 +377,7 @@ process_arguments (int argc, char **argv)
363 else 377 else
364 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)")); 378 usage4 (_("Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional '+' suffix)"));
365 } 379 }
366 if (specify_port == FALSE) 380 if (specify_port == false)
367 server_port = HTTPS_PORT; 381 server_port = HTTPS_PORT;
368#else 382#else
369 /* -C -J and -K fall through to here without SSL */ 383 /* -C -J and -K fall through to here without SSL */
@@ -371,8 +385,15 @@ process_arguments (int argc, char **argv)
371#endif 385#endif
372 break; 386 break;
373 case SNI_OPTION: 387 case SNI_OPTION:
374 use_sni = TRUE; 388 use_sni = true;
375 break; 389 break;
390 case MAX_REDIRS_OPTION:
391 if (!is_intnonneg (optarg))
392 usage2 (_("Invalid max_redirs count"), optarg);
393 else {
394 max_depth = atoi (optarg);
395 }
396 break;
376 case 'f': /* onredirect */ 397 case 'f': /* onredirect */
377 if (!strcmp (optarg, "stickyport")) 398 if (!strcmp (optarg, "stickyport"))
378 onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT; 399 onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT;
@@ -402,7 +423,7 @@ process_arguments (int argc, char **argv)
402 host_name_length = strlen (host_name) - strlen (p) - 1; 423 host_name_length = strlen (host_name) - strlen (p) - 1;
403 free (host_name); 424 free (host_name);
404 host_name = strndup (optarg, host_name_length); 425 host_name = strndup (optarg, host_name_length);
405 if (specify_port == FALSE) 426 if (specify_port == false)
406 server_port = virtual_port; 427 server_port = virtual_port;
407 } 428 }
408 } else if ((p = strchr (host_name, ':')) != NULL 429 } else if ((p = strchr (host_name, ':')) != NULL
@@ -412,7 +433,7 @@ process_arguments (int argc, char **argv)
412 host_name_length = strlen (host_name) - strlen (p) - 1; 433 host_name_length = strlen (host_name) - strlen (p) - 1;
413 free (host_name); 434 free (host_name);
414 host_name = strndup (optarg, host_name_length); 435 host_name = strndup (optarg, host_name_length);
415 if (specify_port == FALSE) 436 if (specify_port == false)
416 server_port = virtual_port; 437 server_port = virtual_port;
417 } 438 }
418 break; 439 break;
@@ -428,7 +449,7 @@ process_arguments (int argc, char **argv)
428 usage2 (_("Invalid port number"), optarg); 449 usage2 (_("Invalid port number"), optarg);
429 else { 450 else {
430 server_port = atoi (optarg); 451 server_port = atoi (optarg);
431 specify_port = TRUE; 452 specify_port = true;
432 } 453 }
433 break; 454 break;
434 case 'a': /* authorization info */ 455 case 'a': /* authorization info */
@@ -477,6 +498,7 @@ process_arguments (int argc, char **argv)
477 break; 498 break;
478 case 'R': /* regex */ 499 case 'R': /* regex */
479 cflags |= REG_ICASE; 500 cflags |= REG_ICASE;
501 // fall through
480 case 'r': /* regex */ 502 case 'r': /* regex */
481 strncpy (regexp, optarg, MAX_RE_SIZE - 1); 503 strncpy (regexp, optarg, MAX_RE_SIZE - 1);
482 regexp[MAX_RE_SIZE - 1] = 0; 504 regexp[MAX_RE_SIZE - 1] = 0;
@@ -484,7 +506,7 @@ process_arguments (int argc, char **argv)
484 if (errcode != 0) { 506 if (errcode != 0) {
485 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); 507 (void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
486 printf (_("Could Not Compile Regular Expression: %s"), errbuf); 508 printf (_("Could Not Compile Regular Expression: %s"), errbuf);
487 return ERROR; 509 return false;
488 } 510 }
489 break; 511 break;
490 case INVERT_REGEX: 512 case INVERT_REGEX:
@@ -501,7 +523,7 @@ process_arguments (int argc, char **argv)
501#endif 523#endif
502 break; 524 break;
503 case 'v': /* verbose */ 525 case 'v': /* verbose */
504 verbose = TRUE; 526 verbose = true;
505 break; 527 break;
506 case 'm': /* min_page_length */ 528 case 'm': /* min_page_length */
507 { 529 {
@@ -526,7 +548,7 @@ process_arguments (int argc, char **argv)
526 break; 548 break;
527 } 549 }
528 case 'N': /* no-body */ 550 case 'N': /* no-body */
529 no_body = TRUE; 551 no_body = true;
530 break; 552 break;
531 case 'M': /* max-age */ 553 case 'M': /* max-age */
532 { 554 {
@@ -547,10 +569,10 @@ process_arguments (int argc, char **argv)
547 } 569 }
548 break; 570 break;
549 case 'E': /* show extended perfdata */ 571 case 'E': /* show extended perfdata */
550 show_extended_perfdata = TRUE; 572 show_extended_perfdata = true;
551 break; 573 break;
552 case 'B': /* print body content after status line */ 574 case 'B': /* print body content after status line */
553 show_body = TRUE; 575 show_body = true;
554 break; 576 break;
555 } 577 }
556 } 578 }
@@ -587,7 +609,7 @@ process_arguments (int argc, char **argv)
587 if (virtual_port == 0) 609 if (virtual_port == 0)
588 virtual_port = server_port; 610 virtual_port = server_port;
589 611
590 return TRUE; 612 return true;
591} 613}
592 614
593 615
@@ -927,7 +949,7 @@ check_http (void)
927 /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */ 949 /* @20100414, public[at]frank4dd.com, http://www.frank4dd.com/howto */
928 950
929 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 951 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
930 && host_name != NULL && use_ssl == TRUE) { 952 && host_name != NULL && use_ssl == true) {
931 953
932 if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT); 954 if (verbose) printf ("Entering CONNECT tunnel mode with proxy %s:%d to dst %s:%d\n", server_address, server_port, host_name, HTTPS_PORT);
933 asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent); 955 asprintf (&buf, "%s %s:%d HTTP/1.1\r\n%s\r\n", http_method, host_name, HTTPS_PORT, user_agent);
@@ -961,7 +983,7 @@ check_http (void)
961 } 983 }
962#ifdef HAVE_SSL 984#ifdef HAVE_SSL
963 elapsed_time_connect = (double)microsec_connect / 1.0e6; 985 elapsed_time_connect = (double)microsec_connect / 1.0e6;
964 if (use_ssl == TRUE) { 986 if (use_ssl == true) {
965 gettimeofday (&tv_temp, NULL); 987 gettimeofday (&tv_temp, NULL);
966 result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey); 988 result = np_net_ssl_init_with_hostname_version_and_cert(sd, (use_sni ? host_name : NULL), ssl_version, client_cert, client_privkey);
967 if (verbose) printf ("SSL initialized\n"); 989 if (verbose) printf ("SSL initialized\n");
@@ -969,17 +991,19 @@ check_http (void)
969 die (STATE_CRITICAL, NULL); 991 die (STATE_CRITICAL, NULL);
970 microsec_ssl = deltime (tv_temp); 992 microsec_ssl = deltime (tv_temp);
971 elapsed_time_ssl = (double)microsec_ssl / 1.0e6; 993 elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
972 if (check_cert == TRUE) { 994 if (check_cert == true) {
973 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); 995 result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit);
974 if (sd) close(sd); 996 if (continue_after_check_cert == false) {
975 np_net_ssl_cleanup(); 997 if (sd) close(sd);
976 return result; 998 np_net_ssl_cleanup();
999 return result;
1000 }
977 } 1001 }
978 } 1002 }
979#endif /* HAVE_SSL */ 1003#endif /* HAVE_SSL */
980 1004
981 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 1005 if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0
982 && host_name != NULL && use_ssl == TRUE) 1006 && host_name != NULL && use_ssl == true)
983 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 1007 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
984 else 1008 else
985 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); 1009 asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
@@ -1007,10 +1031,10 @@ check_http (void)
1007 * 14.23). Some server applications/configurations cause trouble if the 1031 * 14.23). Some server applications/configurations cause trouble if the
1008 * (default) port is explicitly specified in the "Host:" header line. 1032 * (default) port is explicitly specified in the "Host:" header line.
1009 */ 1033 */
1010 if ((use_ssl == FALSE && virtual_port == HTTP_PORT) || 1034 if ((use_ssl == false && virtual_port == HTTP_PORT) ||
1011 (use_ssl == TRUE && virtual_port == HTTPS_PORT) || 1035 (use_ssl == true && virtual_port == HTTPS_PORT) ||
1012 (server_address != NULL && strcmp(http_method, "CONNECT") == 0 1036 (server_address != NULL && strcmp(http_method, "CONNECT") == 0
1013 && host_name != NULL && use_ssl == TRUE)) 1037 && host_name != NULL && use_ssl == true))
1014 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); 1038 xasprintf (&buf, "%sHost: %s\r\n", buf, host_name);
1015 else 1039 else
1016 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port); 1040 xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, virtual_port);
@@ -1050,9 +1074,8 @@ check_http (void)
1050 } 1074 }
1051 1075
1052 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); 1076 xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data));
1053 xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); 1077 xasprintf (&buf, "%s%s", buf, http_post_data);
1054 } 1078 } else {
1055 else {
1056 /* or just a newline so the server knows we're done with the request */ 1079 /* or just a newline so the server knows we're done with the request */
1057 xasprintf (&buf, "%s%s", buf, CRLF); 1080 xasprintf (&buf, "%s%s", buf, CRLF);
1058 } 1081 }
@@ -1076,9 +1099,14 @@ check_http (void)
1076 *pos = ' '; 1099 *pos = ' ';
1077 } 1100 }
1078 buffer[i] = '\0'; 1101 buffer[i] = '\0';
1079 xasprintf (&full_page_new, "%s%s", full_page, buffer); 1102
1080 free (full_page); 1103 if ((full_page_new = realloc(full_page, pagesize + i + 1)) == NULL)
1104 die (STATE_UNKNOWN, _("HTTP UNKNOWN - Could not allocate memory for full_page\n"));
1105
1106 memmove(&full_page_new[pagesize], buffer, i + 1);
1107
1081 full_page = full_page_new; 1108 full_page = full_page_new;
1109
1082 pagesize += i; 1110 pagesize += i;
1083 1111
1084 if (no_body && document_headers_done (full_page)) { 1112 if (no_body && document_headers_done (full_page)) {
@@ -1090,25 +1118,7 @@ check_http (void)
1090 elapsed_time_transfer = (double)microsec_transfer / 1.0e6; 1118 elapsed_time_transfer = (double)microsec_transfer / 1.0e6;
1091 1119
1092 if (i < 0 && errno != ECONNRESET) { 1120 if (i < 0 && errno != ECONNRESET) {
1093#ifdef HAVE_SSL 1121 die(STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1094 /*
1095 if (use_ssl) {
1096 sslerr=SSL_get_error(ssl, i);
1097 if ( sslerr == SSL_ERROR_SSL ) {
1098 die (STATE_WARNING, _("HTTP WARNING - Client Certificate Required\n"));
1099 } else {
1100 die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1101 }
1102 }
1103 else {
1104 */
1105#endif
1106 die (STATE_CRITICAL, _("HTTP CRITICAL - Error on receive\n"));
1107#ifdef HAVE_SSL
1108 /* XXX
1109 }
1110 */
1111#endif
1112 } 1122 }
1113 1123
1114 /* return a CRITICAL status if we couldn't read any data */ 1124 /* return a CRITICAL status if we couldn't read any data */
@@ -1233,32 +1243,73 @@ check_http (void)
1233 } 1243 }
1234 1244
1235 /* Page and Header content checks go here */ 1245 /* Page and Header content checks go here */
1236 if (strlen (header_expect)) { 1246 if (strlen(header_expect) > 0) {
1237 if (!strstr (header, header_expect)) { 1247 if (strstr(header, header_expect) == NULL) {
1238 strncpy(&output_header_search[0],header_expect,sizeof(output_header_search)); 1248 // We did not find the header, the rest is for building the output and setting the state
1239 if(output_header_search[sizeof(output_header_search)-1]!='\0') { 1249 char output_header_search[30] = "";
1240 bcopy("...",&output_header_search[sizeof(output_header_search)-4],4); 1250
1251 strncpy(&output_header_search[0], header_expect,
1252 sizeof(output_header_search));
1253
1254 if (output_header_search[sizeof(output_header_search) - 1] != '\0') {
1255 bcopy("...",
1256 &output_header_search[sizeof(output_header_search) - 4],
1257 4);
1241 } 1258 }
1242 xasprintf (&msg, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1259
1260 xasprintf (&msg,
1261 _("%sheader '%s' not found on '%s://%s:%d%s', "),
1262 msg,
1263 output_header_search, use_ssl ? "https" : "http",
1264 host_name ? host_name : server_address, server_port,
1265 server_url);
1266
1243 result = STATE_CRITICAL; 1267 result = STATE_CRITICAL;
1244 } 1268 }
1245 } 1269 }
1246 1270
1271 // At this point we should test if the content is chunked and unchunk it, so
1272 // it can be searched (and possibly printed)
1273 const char *chunked_header_regex_string = "Transfer-Encoding: *chunked *";
1274 regex_t chunked_header_regex;
1247 1275
1248 if (strlen (string_expect)) { 1276 if (regcomp(&chunked_header_regex, chunked_header_regex_string, REG_ICASE)) {
1249 if (!strstr (page, string_expect)) { 1277 die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to compile chunked_header_regex regex");
1250 strncpy(&output_string_search[0],string_expect,sizeof(output_string_search)); 1278 }
1251 if(output_string_search[sizeof(output_string_search)-1]!='\0') { 1279
1252 bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); 1280 regmatch_t chre_pmatch[1]; // We actually do not care about this, since we only want to know IF it was found
1281
1282 if (!no_body && regexec(&chunked_header_regex, header, 1, chre_pmatch, 0) == 0) {
1283 if (verbose) {
1284 printf("Found chunked content\n");
1285 }
1286 // We actually found the chunked header
1287 char *tmp = unchunk_content(page);
1288 if (tmp == NULL) {
1289 die(STATE_UNKNOWN, "HTTP %s: %s\n", state_text(STATE_UNKNOWN), "Failed to unchunk message body");
1290 }
1291 page = tmp;
1292 }
1293
1294 if (strlen(string_expect) > 0) {
1295 if (!strstr(page, string_expect)) {
1296 // We found the string the body, the rest is for building the output
1297 char output_string_search[30] = "";
1298 strncpy(&output_string_search[0], string_expect,
1299 sizeof(output_string_search));
1300 if (output_string_search[sizeof(output_string_search) - 1] != '\0') {
1301 bcopy("...", &output_string_search[sizeof(output_string_search) - 4],
1302 4);
1253 } 1303 }
1254 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); 1304 xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
1255 result = STATE_CRITICAL; 1305 result = STATE_CRITICAL;
1256 } 1306 }
1257 } 1307 }
1258 1308
1259 if (strlen (regexp)) { 1309 if (strlen(regexp) > 0) {
1260 errcode = regexec (&preg, page, REGS, pmatch, 0); 1310 errcode = regexec(&preg, page, REGS, pmatch, 0);
1261 if ((errcode == 0 && invert_regex == 0) || (errcode == REG_NOMATCH && invert_regex == 1)) { 1311 if ((errcode == 0 && invert_regex == 0) ||
1312 (errcode == REG_NOMATCH && invert_regex == 1)) {
1262 /* OK - No-op to avoid changing the logic around it */ 1313 /* OK - No-op to avoid changing the logic around it */
1263 result = max_state_alt(STATE_OK, result); 1314 result = max_state_alt(STATE_OK, result);
1264 } 1315 }
@@ -1310,7 +1361,7 @@ check_http (void)
1310 perfd_time (elapsed_time), 1361 perfd_time (elapsed_time),
1311 perfd_size (page_len), 1362 perfd_size (page_len),
1312 perfd_time_connect (elapsed_time_connect), 1363 perfd_time_connect (elapsed_time_connect),
1313 use_ssl == TRUE ? perfd_time_ssl (elapsed_time_ssl) : "", 1364 use_ssl == true ? perfd_time_ssl (elapsed_time_ssl) : "",
1314 perfd_time_headers (elapsed_time_headers), 1365 perfd_time_headers (elapsed_time_headers),
1315 perfd_time_firstbyte (elapsed_time_firstbyte), 1366 perfd_time_firstbyte (elapsed_time_firstbyte),
1316 perfd_time_transfer (elapsed_time_transfer)); 1367 perfd_time_transfer (elapsed_time_transfer));
@@ -1332,7 +1383,94 @@ check_http (void)
1332 return STATE_UNKNOWN; 1383 return STATE_UNKNOWN;
1333} 1384}
1334 1385
1386/* Receivces a pointer to the beginning of the body of a HTTP message
1387 * which is chunked and returns a pointer to a freshly allocated memory
1388 * region containing the unchunked body or NULL if something failed.
1389 * The result must be freed by the caller.
1390 */
1391char *unchunk_content(const char *content) {
1392 // https://en.wikipedia.org/wiki/Chunked_transfer_encoding
1393 // https://www.rfc-editor.org/rfc/rfc7230#section-4.1
1394 char *result = NULL;
1395 char *start_of_chunk;
1396 char* end_of_chunk;
1397 long size_of_chunk;
1398 const char *pointer = content;
1399 char *endptr;
1400 long length_of_chunk = 0;
1401 size_t overall_size = 0;
1402
1403 while (true) {
1404 size_of_chunk = strtol(pointer, &endptr, 16);
1405 if (size_of_chunk == LONG_MIN || size_of_chunk == LONG_MAX) {
1406 // Apparently underflow or overflow, should not happen
1407 if (verbose) {
1408 printf("Got an underflow or overflow from strtol at: %u\n", __LINE__);
1409 }
1410 return NULL;
1411 }
1412 if (endptr == pointer) {
1413 // Apparently this was not a number
1414 if (verbose) {
1415 printf("Chunked content did not start with a number at all (Line: %u)\n", __LINE__);
1416 }
1417 return NULL;
1418 }
1419
1420 // So, we got the length of the chunk
1421 if (*endptr == ';') {
1422 // Chunk extension starts here
1423 while (*endptr != '\r') {
1424 endptr++;
1425 }
1426 }
1427
1428 start_of_chunk = endptr + 2;
1429 end_of_chunk = start_of_chunk + size_of_chunk;
1430 length_of_chunk = (long)(end_of_chunk - start_of_chunk);
1431 pointer = end_of_chunk + 2; //Next number should be here
1432
1433 if (length_of_chunk == 0) {
1434 // Chunk length is 0, so this is the last one
1435 break;
1436 }
1437
1438 overall_size += length_of_chunk;
1439
1440 if (result == NULL) {
1441 // Size of the chunk plus the ending NULL byte
1442 result = (char *)malloc(length_of_chunk +1);
1443 if (result == NULL) {
1444 if (verbose) {
1445 printf("Failed to allocate memory for unchunked body\n");
1446 }
1447 return NULL;
1448 }
1449 } else {
1450 // Enlarge memory to the new size plus the ending NULL byte
1451 void *tmp = realloc(result, overall_size +1);
1452 if (tmp == NULL) {
1453 if (verbose) {
1454 printf("Failed to allocate memory for unchunked body\n");
1455 }
1456 return NULL;
1457 } else {
1458 result = tmp;
1459 }
1460 }
1461
1462 memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
1463 }
1335 1464
1465 if (overall_size == 0 && result == NULL) {
1466 // We might just have received the end chunk without previous content, so result is never allocated
1467 result = calloc(1, sizeof(char));
1468 // No error handling here, we can only return NULL anyway
1469 } else {
1470 result[overall_size] = '\0';
1471 }
1472 return result;
1473}
1336 1474
1337/* per RFC 2396 */ 1475/* per RFC 2396 */
1338#define URI_HTTP "%5[HTPShtps]" 1476#define URI_HTTP "%5[HTPShtps]"
@@ -1343,7 +1481,9 @@ check_http (void)
1343#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH 1481#define HD2 URI_HTTP "://" URI_HOST "/" URI_PATH
1344#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT 1482#define HD3 URI_HTTP "://" URI_HOST ":" URI_PORT
1345#define HD4 URI_HTTP "://" URI_HOST 1483#define HD4 URI_HTTP "://" URI_HOST
1346#define HD5 URI_PATH 1484/* relative reference redirect like //www.site.org/test https://tools.ietf.org/html/rfc3986 */
1485#define HD5 "//" URI_HOST "/" URI_PATH
1486#define HD6 URI_PATH
1347 1487
1348void 1488void
1349redir (char *pos, char *status_line) 1489redir (char *pos, char *status_line)
@@ -1420,9 +1560,21 @@ redir (char *pos, char *status_line)
1420 use_ssl = server_type_check (type); 1560 use_ssl = server_type_check (type);
1421 i = server_port_check (use_ssl); 1561 i = server_port_check (use_ssl);
1422 } 1562 }
1563 /* URI_HTTP, URI_HOST, URI_PATH */
1564 else if (sscanf (pos, HD5, addr, url) == 2) {
1565 if(use_ssl){
1566 strcpy (type,"https");
1567 }
1568 else{
1569 strcpy (type, server_type);
1570 }
1571 xasprintf (&url, "/%s", url);
1572 use_ssl = server_type_check (type);
1573 i = server_port_check (use_ssl);
1574 }
1423 1575
1424 /* URI_PATH */ 1576 /* URI_PATH */
1425 else if (sscanf (pos, HD5, url) == 1) { 1577 else if (sscanf (pos, HD6, url) == 1) {
1426 /* relative url */ 1578 /* relative url */
1427 if ((url[0] != '/')) { 1579 if ((url[0] != '/')) {
1428 if ((x = strrchr(server_url, '/'))) 1580 if ((x = strrchr(server_url, '/')))
@@ -1491,13 +1643,13 @@ redir (char *pos, char *status_line)
1491} 1643}
1492 1644
1493 1645
1494int 1646bool
1495server_type_check (const char *type) 1647server_type_check (const char *type)
1496{ 1648{
1497 if (strcmp (type, "https")) 1649 if (strcmp (type, "https"))
1498 return FALSE; 1650 return false;
1499 else 1651 else
1500 return TRUE; 1652 return true;
1501} 1653}
1502 1654
1503int 1655int
@@ -1512,42 +1664,42 @@ server_port_check (int ssl_flag)
1512char *perfd_time (double elapsed_time) 1664char *perfd_time (double elapsed_time)
1513{ 1665{
1514 return fperfdata ("time", elapsed_time, "s", 1666 return fperfdata ("time", elapsed_time, "s",
1515 thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0, 1667 thlds->warning?true:false, thlds->warning?thlds->warning->end:0,
1516 thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0, 1668 thlds->critical?true:false, thlds->critical?thlds->critical->end:0,
1517 TRUE, 0, TRUE, socket_timeout); 1669 true, 0, true, socket_timeout);
1518} 1670}
1519 1671
1520char *perfd_time_connect (double elapsed_time_connect) 1672char *perfd_time_connect (double elapsed_time_connect)
1521{ 1673{
1522 return fperfdata ("time_connect", elapsed_time_connect, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1674 return fperfdata ("time_connect", elapsed_time_connect, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1523} 1675}
1524 1676
1525char *perfd_time_ssl (double elapsed_time_ssl) 1677char *perfd_time_ssl (double elapsed_time_ssl)
1526{ 1678{
1527 return fperfdata ("time_ssl", elapsed_time_ssl, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1679 return fperfdata ("time_ssl", elapsed_time_ssl, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1528} 1680}
1529 1681
1530char *perfd_time_headers (double elapsed_time_headers) 1682char *perfd_time_headers (double elapsed_time_headers)
1531{ 1683{
1532 return fperfdata ("time_headers", elapsed_time_headers, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1684 return fperfdata ("time_headers", elapsed_time_headers, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1533} 1685}
1534 1686
1535char *perfd_time_firstbyte (double elapsed_time_firstbyte) 1687char *perfd_time_firstbyte (double elapsed_time_firstbyte)
1536{ 1688{
1537 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1689 return fperfdata ("time_firstbyte", elapsed_time_firstbyte, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1538} 1690}
1539 1691
1540char *perfd_time_transfer (double elapsed_time_transfer) 1692char *perfd_time_transfer (double elapsed_time_transfer)
1541{ 1693{
1542 return fperfdata ("time_transfer", elapsed_time_transfer, "s", FALSE, 0, FALSE, 0, FALSE, 0, TRUE, socket_timeout); 1694 return fperfdata ("time_transfer", elapsed_time_transfer, "s", false, 0, false, 0, false, 0, true, socket_timeout);
1543} 1695}
1544 1696
1545char *perfd_size (int page_len) 1697char *perfd_size (int page_len)
1546{ 1698{
1547 return perfdata ("size", page_len, "B", 1699 return perfdata ("size", page_len, "B",
1548 (min_page_len>0?TRUE:FALSE), min_page_len, 1700 (min_page_len>0?true:false), min_page_len,
1549 (min_page_len>0?TRUE:FALSE), 0, 1701 (min_page_len>0?true:false), 0,
1550 TRUE, 0, FALSE, 0); 1702 true, 0, false, 0);
1551} 1703}
1552 1704
1553void 1705void
@@ -1598,7 +1750,11 @@ print_help (void)
1598 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); 1750 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
1599 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]"); 1751 printf (" %s\n", "-C, --certificate=INTEGER[,INTEGER]");
1600 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443")); 1752 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
1601 printf (" %s\n", _("(when this option is used the URL is not checked.)")); 1753 printf (" %s\n", _("(when this option is used the URL is not checked by default. You can use"));
1754 printf (" %s\n", _(" --continue-after-certificate to override this behavior)"));
1755 printf (" %s\n", "--continue-after-certificate");
1756 printf (" %s\n", _("Allows the HTTP check to continue after performing the certificate check."));
1757 printf (" %s\n", _("Does nothing unless -C is used."));
1602 printf (" %s\n", "-J, --client-cert=FILE"); 1758 printf (" %s\n", "-J, --client-cert=FILE");
1603 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)")); 1759 printf (" %s\n", _("Name of file that contains the client certificate (PEM format)"));
1604 printf (" %s\n", _("to be used in establishing the SSL session")); 1760 printf (" %s\n", _("to be used in establishing the SSL session"));
@@ -1657,9 +1813,11 @@ print_help (void)
1657 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); 1813 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>");
1658 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the")); 1814 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the"));
1659 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same.")); 1815 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same."));
1816 printf (" %s\n", "--max-redirs=INTEGER");
1817 printf (" %s", _("Maximal number of redirects (default: "));
1818 printf ("%d)\n", DEFAULT_MAX_REDIRS);
1660 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); 1819 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
1661 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); 1820 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));
1662
1663 printf (UT_WARN_CRIT); 1821 printf (UT_WARN_CRIT);
1664 1822
1665 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1823 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
@@ -1727,7 +1885,7 @@ print_usage (void)
1727 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); 1885 printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
1728 printf (" [-J <client certificate file>] [-K <private key>]\n"); 1886 printf (" [-J <client certificate file>] [-K <private key>]\n");
1729 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n"); 1887 printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]\n");
1730 printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); 1888 printf (" [-b proxy_auth] [-f <ok|warning|critical|follow|sticky|stickyport>]\n");
1731 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); 1889 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
1732 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); 1890 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
1733 printf (" [-A string] [-k string] [-S <version>] [--sni]\n"); 1891 printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index bc7bd44..a1bfe1b 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -222,7 +222,7 @@ main (int argc, char *argv[])
222 /* reset the alarm handler */ 222 /* reset the alarm handler */
223 alarm (0); 223 alarm (0);
224 224
225 /* calcutate the elapsed time and compare to thresholds */ 225 /* calculate the elapsed time and compare to thresholds */
226 226
227 microsec = deltime (tv); 227 microsec = deltime (tv);
228 elapsed_time = (double)microsec / 1.0e6; 228 elapsed_time = (double)microsec / 1.0e6;
@@ -432,6 +432,9 @@ validate_arguments ()
432 set_thresholds(&entries_thresholds, 432 set_thresholds(&entries_thresholds,
433 warn_entries, crit_entries); 433 warn_entries, crit_entries);
434 } 434 }
435 if (ld_passwd==NULL)
436 ld_passwd = getenv("LDAP_PASSWORD");
437
435 return OK; 438 return OK;
436} 439}
437 440
@@ -465,7 +468,7 @@ print_help (void)
465 printf (" %s\n", "-D [--bind]"); 468 printf (" %s\n", "-D [--bind]");
466 printf (" %s\n", _("ldap bind DN (if required)")); 469 printf (" %s\n", _("ldap bind DN (if required)"));
467 printf (" %s\n", "-P [--pass]"); 470 printf (" %s\n", "-P [--pass]");
468 printf (" %s\n", _("ldap password (if required)")); 471 printf (" %s\n", _("ldap password (if required, or set the password through environment variable 'LDAP_PASSWORD')"));
469 printf (" %s\n", "-T [--starttls]"); 472 printf (" %s\n", "-T [--starttls]");
470 printf (" %s\n", _("use starttls mechanism introduced in protocol version 3")); 473 printf (" %s\n", _("use starttls mechanism introduced in protocol version 3"));
471 printf (" %s\n", "-S [--ssl]"); 474 printf (" %s\n", "-S [--ssl]");
diff --git a/plugins/check_load.c b/plugins/check_load.c
index 0e4de54..313df8a 100644
--- a/plugins/check_load.c
+++ b/plugins/check_load.c
@@ -1,41 +1,43 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_load plugin 3* Monitoring check_load plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_load plugin 10* This file contains the check_load plugin
11* 11*
12* This plugin tests the current system load average. 12* This plugin tests the current system load average.
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_load"; 31const char *progname = "check_load";
32const char *copyright = "1999-2007"; 32const char *copyright = "1999-2022";
33const char *email = "devel@monitoring-plugins.org"; 33const char *email = "devel@monitoring-plugins.org";
34 34
35#include "common.h" 35#include "./common.h"
36#include "runcmd.h" 36#include "./runcmd.h"
37#include "utils.h" 37#include "./utils.h"
38#include "popen.h" 38#include "./popen.h"
39
40#include <string.h>
39 41
40#ifdef HAVE_SYS_LOADAVG_H 42#ifdef HAVE_SYS_LOADAVG_H
41#include <sys/loadavg.h> 43#include <sys/loadavg.h>
@@ -68,7 +70,7 @@ double cload[3] = { 0.0, 0.0, 0.0 };
68#define la15 la[2] 70#define la15 la[2]
69 71
70char *status_line; 72char *status_line;
71int take_into_account_cpus = 0; 73bool take_into_account_cpus = false;
72 74
73static void 75static void
74get_threshold(char *arg, double *th) 76get_threshold(char *arg, double *th)
@@ -101,11 +103,11 @@ get_threshold(char *arg, double *th)
101int 103int
102main (int argc, char **argv) 104main (int argc, char **argv)
103{ 105{
104 int result; 106 int result = -1;
105 int i; 107 int i;
106 long numcpus; 108 long numcpus;
107 109
108 double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about unitialized arrays */ 110 double la[3] = { 0.0, 0.0, 0.0 }; /* NetBSD complains about uninitialized arrays */
109#ifndef HAVE_GETLOADAVG 111#ifndef HAVE_GETLOADAVG
110 char input_buffer[MAX_INPUT_BUFFER]; 112 char input_buffer[MAX_INPUT_BUFFER];
111# ifdef HAVE_PROC_LOADAVG 113# ifdef HAVE_PROC_LOADAVG
@@ -164,7 +166,7 @@ main (int argc, char **argv)
164 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15); 166 sscanf (input_buffer, "%*[^l]load averages: %lf, %lf, %lf", &la1, &la5, &la15);
165 } 167 }
166 else { 168 else {
167 printf (_("could not parse load from uptime %s: %s\n"), PATH_TO_UPTIME, result); 169 printf (_("could not parse load from uptime %s: %d\n"), PATH_TO_UPTIME, result);
168 return STATE_UNKNOWN; 170 return STATE_UNKNOWN;
169 } 171 }
170 172
@@ -176,13 +178,6 @@ main (int argc, char **argv)
176# endif 178# endif
177#endif 179#endif
178 180
179 if (take_into_account_cpus == 1) {
180 if ((numcpus = GET_NUMBER_OF_CPUS()) > 0) {
181 la[0] = la[0] / numcpus;
182 la[1] = la[1] / numcpus;
183 la[2] = la[2] / numcpus;
184 }
185 }
186 if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) { 181 if ((la[0] < 0.0) || (la[1] < 0.0) || (la[2] < 0.0)) {
187#ifdef HAVE_GETLOADAVG 182#ifdef HAVE_GETLOADAVG
188 printf (_("Error in getloadavg()\n")); 183 printf (_("Error in getloadavg()\n"));
@@ -200,18 +195,49 @@ main (int argc, char **argv)
200 result = STATE_OK; 195 result = STATE_OK;
201 196
202 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15); 197 xasprintf(&status_line, _("load average: %.2f, %.2f, %.2f"), la1, la5, la15);
198 xasprintf(&status_line, ("total %s"), status_line);
199
200
201 double scaled_la[3] = { 0.0, 0.0, 0.0 };
202 bool is_using_scaled_load_values = false;
203
204 if (take_into_account_cpus == true && (numcpus = GET_NUMBER_OF_CPUS()) > 0) {
205 is_using_scaled_load_values = true;
206
207 scaled_la[0] = la[0] / numcpus;
208 scaled_la[1] = la[1] / numcpus;
209 scaled_la[2] = la[2] / numcpus;
210
211 char *tmp = NULL;
212 xasprintf(&tmp, _("load average: %.2f, %.2f, %.2f"), scaled_la[0], scaled_la[1], scaled_la[2]);
213 xasprintf(&status_line, "scaled %s - %s", tmp, status_line);
214 }
203 215
204 for(i = 0; i < 3; i++) { 216 for(i = 0; i < 3; i++) {
205 if(la[i] > cload[i]) { 217 if (is_using_scaled_load_values) {
206 result = STATE_CRITICAL; 218 if(scaled_la[i] > cload[i]) {
207 break; 219 result = STATE_CRITICAL;
220 break;
221 }
222 else if(scaled_la[i] > wload[i]) result = STATE_WARNING;
223 } else {
224 if(la[i] > cload[i]) {
225 result = STATE_CRITICAL;
226 break;
227 }
228 else if(la[i] > wload[i]) result = STATE_WARNING;
208 } 229 }
209 else if(la[i] > wload[i]) result = STATE_WARNING;
210 } 230 }
211 231
212 printf("LOAD %s - %s|", state_text(result), status_line); 232 printf("LOAD %s - %s|", state_text(result), status_line);
213 for(i = 0; i < 3; i++) 233 for(i = 0; i < 3; i++) {
214 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]); 234 if (is_using_scaled_load_values) {
235 printf("load%d=%.3f;;;0; ", nums[i], la[i]);
236 printf("scaled_load%d=%.3f;%.3f;%.3f;0; ", nums[i], scaled_la[i], wload[i], cload[i]);
237 } else {
238 printf("load%d=%.3f;%.3f;%.3f;0; ", nums[i], la[i], wload[i], cload[i]);
239 }
240 }
215 241
216 putchar('\n'); 242 putchar('\n');
217 if (n_procs_to_show > 0) { 243 if (n_procs_to_show > 0) {
@@ -255,7 +281,7 @@ process_arguments (int argc, char **argv)
255 get_threshold(optarg, cload); 281 get_threshold(optarg, cload);
256 break; 282 break;
257 case 'r': /* Divide load average by number of CPUs */ 283 case 'r': /* Divide load average by number of CPUs */
258 take_into_account_cpus = 1; 284 take_into_account_cpus = true;
259 break; 285 break;
260 case 'V': /* version */ 286 case 'V': /* version */
261 print_revision (progname, NP_VERSION); 287 print_revision (progname, NP_VERSION);
@@ -289,7 +315,6 @@ process_arguments (int argc, char **argv)
289} 315}
290 316
291 317
292
293static int 318static int
294validate_arguments (void) 319validate_arguments (void)
295{ 320{
@@ -310,7 +335,6 @@ validate_arguments (void)
310} 335}
311 336
312 337
313
314void 338void
315print_help (void) 339print_help (void)
316{ 340{
@@ -321,7 +345,7 @@ print_help (void)
321 345
322 printf (_("This plugin tests the current system load average.")); 346 printf (_("This plugin tests the current system load average."));
323 347
324 printf ("\n\n"); 348 printf ("\n\n");
325 349
326 print_usage (); 350 print_usage ();
327 351
@@ -329,15 +353,15 @@ print_help (void)
329 printf (UT_EXTRA_OPTS); 353 printf (UT_EXTRA_OPTS);
330 354
331 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15"); 355 printf (" %s\n", "-w, --warning=WLOAD1,WLOAD5,WLOAD15");
332 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn")); 356 printf (" %s\n", _("Exit with WARNING status if load average exceeds WLOADn"));
333 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15"); 357 printf (" %s\n", "-c, --critical=CLOAD1,CLOAD5,CLOAD15");
334 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn")); 358 printf (" %s\n", _("Exit with CRITICAL status if load average exceed CLOADn"));
335 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\"")); 359 printf (" %s\n", _("the load average format is the same used by \"uptime\" and \"w\""));
336 printf (" %s\n", "-r, --percpu"); 360 printf (" %s\n", "-r, --percpu");
337 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)")); 361 printf (" %s\n", _("Divide the load averages by the number of CPUs (when possible)"));
338 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS"); 362 printf (" %s\n", "-n, --procs-to-show=NUMBER_OF_PROCS");
339 printf (" %s\n", _("Number of processes to show when printing the top consuming processes.")); 363 printf (" %s\n", _("Number of processes to show when printing the top consuming processes."));
340 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0")); 364 printf (" %s\n", _("NUMBER_OF_PROCS=0 disables this feature. Default value is 0"));
341 365
342 printf (UT_SUPPORT); 366 printf (UT_SUPPORT);
343} 367}
@@ -345,8 +369,8 @@ print_help (void)
345void 369void
346print_usage (void) 370print_usage (void)
347{ 371{
348 printf ("%s\n", _("Usage:")); 372 printf ("%s\n", _("Usage:"));
349 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname); 373 printf ("%s [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 [-n NUMBER_OF_PROCS]\n", progname);
350} 374}
351 375
352#ifdef PS_USES_PROCPCPU 376#ifdef PS_USES_PROCPCPU
@@ -384,8 +408,8 @@ static int print_top_consuming_processes() {
384#ifdef PS_USES_PROCPCPU 408#ifdef PS_USES_PROCPCPU
385 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp); 409 qsort(chld_out.line + 1, chld_out.lines - 1, sizeof(char*), cmpstringp);
386#endif /* PS_USES_PROCPCPU */ 410#endif /* PS_USES_PROCPCPU */
387 int lines_to_show = chld_out.lines < (n_procs_to_show + 1) 411 int lines_to_show = chld_out.lines < (size_t)(n_procs_to_show + 1)
388 ? chld_out.lines : n_procs_to_show + 1; 412 ? (int)chld_out.lines : n_procs_to_show + 1;
389 for (i = 0; i < lines_to_show; i += 1) { 413 for (i = 0; i < lines_to_show; i += 1) {
390 printf("%s\n", chld_out.line[i]); 414 printf("%s\n", chld_out.line[i]);
391 } 415 }
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 9b7d13f..7d85554 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -140,7 +140,10 @@ main (int argc, char **argv)
140 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers); 140 mysql_ssl_set(&mysql,key,cert,ca_cert,ca_dir,ciphers);
141 /* establish a connection to the server and error checking */ 141 /* establish a connection to the server and error checking */
142 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) { 142 if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
143 if (ignore_auth && mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR) 143 /* Depending on internally-selected auth plugin MySQL might return */
144 /* ER_ACCESS_DENIED_NO_PASSWORD_ERROR or ER_ACCESS_DENIED_ERROR. */
145 /* Semantically these errors are the same. */
146 if (ignore_auth && (mysql_errno (&mysql) == ER_ACCESS_DENIED_ERROR || mysql_errno (&mysql) == ER_ACCESS_DENIED_NO_PASSWORD_ERROR))
144 { 147 {
145 printf("MySQL OK - Version: %s (protocol %d)\n", 148 printf("MySQL OK - Version: %s (protocol %d)\n",
146 mysql_get_server_info(&mysql), 149 mysql_get_server_info(&mysql),
@@ -572,7 +575,7 @@ print_help (void)
572 printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds")); 575 printf (" %s\n", _("Exit with CRITICAL status if slave server is more then INTEGER seconds"));
573 printf (" %s\n", _("behind master")); 576 printf (" %s\n", _("behind master"));
574 printf (" %s\n", "-l, --ssl"); 577 printf (" %s\n", "-l, --ssl");
575 printf (" %s\n", _("Use ssl encryptation")); 578 printf (" %s\n", _("Use ssl encryption"));
576 printf (" %s\n", "-C, --ca-cert=STRING"); 579 printf (" %s\n", "-C, --ca-cert=STRING");
577 printf (" %s\n", _("Path to CA signing the cert")); 580 printf (" %s\n", _("Path to CA signing the cert"));
578 printf (" %s\n", "-a, --cert=STRING"); 581 printf (" %s\n", "-a, --cert=STRING");
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 59c135d..d73d83c 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -341,7 +341,7 @@ int main(int argc, char **argv){
341 341
342 2) If the counter you're going to measure is percent-based, the code will detect 342 2) If the counter you're going to measure is percent-based, the code will detect
343 the percent sign in its name and will attribute minimum (0%) and maximum (100%) 343 the percent sign in its name and will attribute minimum (0%) and maximum (100%)
344 values automagically, as well the ¨%" sign to graph units. 344 values automagically, as well the "%" sign to graph units.
345 345
346 3) OTOH, if the counter is "absolute", you'll have to provide the following 346 3) OTOH, if the counter is "absolute", you'll have to provide the following
347 the counter unit - that is, the dimensions of the counter you're getting. Examples: 347 the counter unit - that is, the dimensions of the counter you're getting. Examples:
diff --git a/plugins/check_ntp.c b/plugins/check_ntp.c
index 914b40c..3614650 100644
--- a/plugins/check_ntp.c
+++ b/plugins/check_ntp.c
@@ -10,7 +10,7 @@
10* 10*
11* This file contains the check_ntp plugin 11* This file contains the check_ntp plugin
12* 12*
13* This plugin to check ntp servers independant of any commandline 13* This plugin to check ntp servers independent of any commandline
14* programs or external libraries. 14* programs or external libraries.
15* 15*
16* 16*
@@ -79,7 +79,7 @@ typedef struct {
79/* this structure holds data about results from querying offset from a peer */ 79/* this structure holds data about results from querying offset from a peer */
80typedef struct { 80typedef struct {
81 time_t waiting; /* ts set when we started waiting for a response */ 81 time_t waiting; /* ts set when we started waiting for a response */
82 int num_responses; /* number of successfully recieved responses */ 82 int num_responses; /* number of successfully received responses */
83 uint8_t stratum; /* copied verbatim from the ntp_message */ 83 uint8_t stratum; /* copied verbatim from the ntp_message */
84 double rtdelay; /* converted from the ntp_message */ 84 double rtdelay; /* converted from the ntp_message */
85 double rtdisp; /* converted from the ntp_message */ 85 double rtdisp; /* converted from the ntp_message */
@@ -100,7 +100,7 @@ typedef struct {
100 /* NB: not necessarily NULL terminated! */ 100 /* NB: not necessarily NULL terminated! */
101} ntp_control_message; 101} ntp_control_message;
102 102
103/* this is an association/status-word pair found in control packet reponses */ 103/* this is an association/status-word pair found in control packet responses */
104typedef struct { 104typedef struct {
105 uint16_t assoc; 105 uint16_t assoc;
106 uint16_t status; 106 uint16_t status;
@@ -355,7 +355,7 @@ int best_offset_server(const ntp_server_results *slist, int nservers){
355 * - we also "manually" handle resolving host names and connecting, because 355 * - we also "manually" handle resolving host names and connecting, because
356 * we have to do it in a way that our lazy macros don't handle currently :( */ 356 * we have to do it in a way that our lazy macros don't handle currently :( */
357double offset_request(const char *host, int *status){ 357double offset_request(const char *host, int *status){
358 int i=0, j=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0; 358 int i=0, ga_result=0, num_hosts=0, *socklist=NULL, respnum=0;
359 int servers_completed=0, one_read=0, servers_readable=0, best_index=-1; 359 int servers_completed=0, one_read=0, servers_readable=0, best_index=-1;
360 time_t now_time=0, start_ts=0; 360 time_t now_time=0, start_ts=0;
361 ntp_message *req=NULL; 361 ntp_message *req=NULL;
@@ -488,7 +488,7 @@ double offset_request(const char *host, int *status){
488 /* cleanup */ 488 /* cleanup */
489 /* FIXME: Not closing the socket to avoid re-use of the local port 489 /* FIXME: Not closing the socket to avoid re-use of the local port
490 * which can cause old NTP packets to be read instead of NTP control 490 * which can cause old NTP packets to be read instead of NTP control
491 * pactets in jitter_request(). THERE MUST BE ANOTHER WAY... 491 * packets in jitter_request(). THERE MUST BE ANOTHER WAY...
492 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */ 492 * for(j=0; j<num_hosts; j++){ close(socklist[j]); } */
493 free(socklist); 493 free(socklist);
494 free(ufds); 494 free(ufds);
@@ -512,7 +512,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
512} 512}
513 513
514/* XXX handle responses with the error bit set */ 514/* XXX handle responses with the error bit set */
515double jitter_request(const char *host, int *status){ 515double jitter_request(int *status){
516 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0; 516 int conn=-1, i, npeers=0, num_candidates=0, syncsource_found=0;
517 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0; 517 int run=0, min_peer_sel=PEER_INCLUDED, num_selected=0, num_valid=0;
518 int peers_size=0, peer_offset=0; 518 int peers_size=0, peer_offset=0;
@@ -575,7 +575,7 @@ double jitter_request(const char *host, int *status){
575 } 575 }
576 } 576 }
577 } 577 }
578 if(verbose) printf("%d candiate peers available\n", num_candidates); 578 if(verbose) printf("%d candidate peers available\n", num_candidates);
579 if(verbose && syncsource_found) printf("synchronization source found\n"); 579 if(verbose && syncsource_found) printf("synchronization source found\n");
580 if(! syncsource_found){ 580 if(! syncsource_found){
581 *status = STATE_UNKNOWN; 581 *status = STATE_UNKNOWN;
@@ -597,7 +597,7 @@ double jitter_request(const char *host, int *status){
597 /* By spec, putting the variable name "jitter" in the request 597 /* By spec, putting the variable name "jitter" in the request
598 * should cause the server to provide _only_ the jitter value. 598 * should cause the server to provide _only_ the jitter value.
599 * thus reducing net traffic, guaranteeing us only a single 599 * thus reducing net traffic, guaranteeing us only a single
600 * datagram in reply, and making intepretation much simpler 600 * datagram in reply, and making interpretation much simpler
601 */ 601 */
602 /* Older servers doesn't know what jitter is, so if we get an 602 /* Older servers doesn't know what jitter is, so if we get an
603 * error on the first pass we redo it with "dispersion" */ 603 * error on the first pass we redo it with "dispersion" */
@@ -803,7 +803,7 @@ int main(int argc, char *argv[]){
803 * (for example) will result in an error 803 * (for example) will result in an error
804 */ 804 */
805 if(do_jitter){ 805 if(do_jitter){
806 jitter=jitter_request(server_address, &jitter_result); 806 jitter=jitter_request(&jitter_result);
807 result = max_state_alt(result, get_status(jitter, jitter_thresholds)); 807 result = max_state_alt(result, get_status(jitter, jitter_thresholds));
808 /* -1 indicates that we couldn't calculate the jitter 808 /* -1 indicates that we couldn't calculate the jitter
809 * Only overrides STATE_OK from the offset */ 809 * Only overrides STATE_OK from the offset */
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index 6842842..49cb100 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -86,7 +86,7 @@ typedef struct {
86 /* NB: not necessarily NULL terminated! */ 86 /* NB: not necessarily NULL terminated! */
87} ntp_control_message; 87} ntp_control_message;
88 88
89/* this is an association/status-word pair found in control packet reponses */ 89/* this is an association/status-word pair found in control packet responses */
90typedef struct { 90typedef struct {
91 uint16_t assoc; 91 uint16_t assoc;
92 uint16_t status; 92 uint16_t status;
@@ -189,7 +189,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
189} 189}
190 190
191/* This function does all the actual work; roughly here's what it does 191/* This function does all the actual work; roughly here's what it does
192 * beside setting the offest, jitter and stratum passed as argument: 192 * beside setting the offset, jitter and stratum passed as argument:
193 * - offset can be negative, so if it cannot get the offset, offset_result 193 * - offset can be negative, so if it cannot get the offset, offset_result
194 * is set to UNKNOWN, otherwise OK. 194 * is set to UNKNOWN, otherwise OK.
195 * - jitter and stratum are set to -1 if they cannot be retrieved so any 195 * - jitter and stratum are set to -1 if they cannot be retrieved so any
@@ -199,7 +199,7 @@ setup_control_request(ntp_control_message *p, uint8_t opcode, uint16_t seq){
199 * status is pretty much useless as syncsource_found is a global variable 199 * status is pretty much useless as syncsource_found is a global variable
200 * used later in main to check is the server was synchronized. It works 200 * used later in main to check is the server was synchronized. It works
201 * so I left it alone */ 201 * so I left it alone */
202int ntp_request(const char *host, double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){ 202int ntp_request(double *offset, int *offset_result, double *jitter, int *stratum, int *num_truechimers){
203 int conn=-1, i, npeers=0, num_candidates=0; 203 int conn=-1, i, npeers=0, num_candidates=0;
204 double tmp_offset = 0; 204 double tmp_offset = 0;
205 int min_peer_sel=PEER_INCLUDED; 205 int min_peer_sel=PEER_INCLUDED;
@@ -306,7 +306,7 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
306 /* Putting the wanted variable names in the request 306 /* Putting the wanted variable names in the request
307 * cause the server to provide _only_ the requested values. 307 * cause the server to provide _only_ the requested values.
308 * thus reducing net traffic, guaranteeing us only a single 308 * thus reducing net traffic, guaranteeing us only a single
309 * datagram in reply, and making intepretation much simpler 309 * datagram in reply, and making interpretation much simpler
310 */ 310 */
311 /* Older servers doesn't know what jitter is, so if we get an 311 /* Older servers doesn't know what jitter is, so if we get an
312 * error on the first pass we redo it with "dispersion" */ 312 * error on the first pass we redo it with "dispersion" */
@@ -585,8 +585,8 @@ int main(int argc, char *argv[]){
585 /* set socket timeout */ 585 /* set socket timeout */
586 alarm (socket_timeout); 586 alarm (socket_timeout);
587 587
588 /* This returns either OK or WARNING (See comment preceeding ntp_request) */ 588 /* This returns either OK or WARNING (See comment preceding ntp_request) */
589 result = ntp_request(server_address, &offset, &offset_result, &jitter, &stratum, &num_truechimers); 589 result = ntp_request(&offset, &offset_result, &jitter, &stratum, &num_truechimers);
590 590
591 if(offset_result == STATE_UNKNOWN) { 591 if(offset_result == STATE_UNKNOWN) {
592 /* if there's no sync peer (this overrides ntp_request output): */ 592 /* if there's no sync peer (this overrides ntp_request output): */
diff --git a/plugins/check_ntp_time.c b/plugins/check_ntp_time.c
index 391b2df..46cc604 100644
--- a/plugins/check_ntp_time.c
+++ b/plugins/check_ntp_time.c
@@ -81,7 +81,7 @@ typedef struct {
81/* this structure holds data about results from querying offset from a peer */ 81/* this structure holds data about results from querying offset from a peer */
82typedef struct { 82typedef struct {
83 time_t waiting; /* ts set when we started waiting for a response */ 83 time_t waiting; /* ts set when we started waiting for a response */
84 int num_responses; /* number of successfully recieved responses */ 84 int num_responses; /* number of successfully received responses */
85 uint8_t stratum; /* copied verbatim from the ntp_message */ 85 uint8_t stratum; /* copied verbatim from the ntp_message */
86 double rtdelay; /* converted from the ntp_message */ 86 double rtdelay; /* converted from the ntp_message */
87 double rtdisp; /* converted from the ntp_message */ 87 double rtdisp; /* converted from the ntp_message */
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index e7e8de0..3c9d23e 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -1668,7 +1668,7 @@ void print_help(void)
1668 1668
1669 printf ("\n"); 1669 printf ("\n");
1670 printf ("%s\n", _("Notes:")); 1670 printf ("%s\n", _("Notes:"));
1671 printf (" %s\n", _("- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG")); 1671 printf (" %s\n", _("- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"));
1672 printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check.")); 1672 printf (" %s\n", _(" extension for NetWare be loaded on the Novell servers you wish to check."));
1673 printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)")); 1673 printf (" %s\n", _(" (available from http://www.engr.wisc.edu/~drews/mrtg/)"));
1674 printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds")); 1674 printf (" %s\n", _("- Values for critical thresholds should be lower than warning thresholds"));
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c
index b8fc5f1..6199033 100644
--- a/plugins/check_pgsql.c
+++ b/plugins/check_pgsql.c
@@ -69,7 +69,6 @@ int process_arguments (int, char **);
69int validate_arguments (void); 69int validate_arguments (void);
70void print_usage (void); 70void print_usage (void);
71void print_help (void); 71void print_help (void);
72int is_pg_dbname (char *);
73int is_pg_logname (char *); 72int is_pg_logname (char *);
74int do_query (PGconn *, char *); 73int do_query (PGconn *, char *);
75 74
@@ -85,6 +84,8 @@ char *pgparams = NULL;
85double twarn = (double)DEFAULT_WARN; 84double twarn = (double)DEFAULT_WARN;
86double tcrit = (double)DEFAULT_CRIT; 85double tcrit = (double)DEFAULT_CRIT;
87char *pgquery = NULL; 86char *pgquery = NULL;
87#define OPTID_QUERYNAME -1000
88char *pgqueryname = NULL;
88char *query_warning = NULL; 89char *query_warning = NULL;
89char *query_critical = NULL; 90char *query_critical = NULL;
90thresholds *qthresholds = NULL; 91thresholds *qthresholds = NULL;
@@ -92,7 +93,7 @@ int verbose = 0;
92 93
93/****************************************************************************** 94/******************************************************************************
94 95
95The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@ 96The (pseudo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
96tags in the comments. With in the tags, the XML is assembled sequentially. 97tags in the comments. With in the tags, the XML is assembled sequentially.
97You can define entities in tags. You also have all the #defines available as 98You can define entities in tags. You also have all the #defines available as
98entities. 99entities.
@@ -285,6 +286,7 @@ process_arguments (int argc, char **argv)
285 {"database", required_argument, 0, 'd'}, 286 {"database", required_argument, 0, 'd'},
286 {"option", required_argument, 0, 'o'}, 287 {"option", required_argument, 0, 'o'},
287 {"query", required_argument, 0, 'q'}, 288 {"query", required_argument, 0, 'q'},
289 {"queryname", required_argument, 0, OPTID_QUERYNAME},
288 {"query_critical", required_argument, 0, 'C'}, 290 {"query_critical", required_argument, 0, 'C'},
289 {"query_warning", required_argument, 0, 'W'}, 291 {"query_warning", required_argument, 0, 'W'},
290 {"verbose", no_argument, 0, 'v'}, 292 {"verbose", no_argument, 0, 'v'},
@@ -344,10 +346,10 @@ process_arguments (int argc, char **argv)
344 pgport = optarg; 346 pgport = optarg;
345 break; 347 break;
346 case 'd': /* database name */ 348 case 'd': /* database name */
347 if (!is_pg_dbname (optarg)) /* checks length and valid chars */ 349 if (strlen(optarg) >= NAMEDATALEN) {
348 usage2 (_("Database name is not valid"), optarg); 350 usage2 (_("Database name exceeds the maximum length"), optarg);
349 else /* we know length, and know optarg is terminated, so us strcpy */ 351 }
350 snprintf(dbName, NAMEDATALEN, "%s", optarg); 352 snprintf(dbName, NAMEDATALEN, "%s", optarg);
351 break; 353 break;
352 case 'l': /* login name */ 354 case 'l': /* login name */
353 if (!is_pg_logname (optarg)) 355 if (!is_pg_logname (optarg))
@@ -368,6 +370,9 @@ process_arguments (int argc, char **argv)
368 case 'q': 370 case 'q':
369 pgquery = optarg; 371 pgquery = optarg;
370 break; 372 break;
373 case OPTID_QUERYNAME:
374 pgqueryname = optarg;
375 break;
371 case 'v': 376 case 'v':
372 verbose++; 377 verbose++;
373 break; 378 break;
@@ -408,45 +413,6 @@ validate_arguments ()
408 return OK; 413 return OK;
409} 414}
410 415
411
412/******************************************************************************
413
414@@-
415<sect3>
416<title>is_pg_dbname</title>
417
418<para>&PROTO_is_pg_dbname;</para>
419
420<para>Given a database name, this function returns TRUE if the string
421is a valid PostgreSQL database name, and returns false if it is
422not.</para>
423
424<para>Valid PostgreSQL database names are less than &NAMEDATALEN;
425characters long and consist of letters, numbers, and underscores. The
426first character cannot be a number, however.</para>
427
428</sect3>
429-@@
430******************************************************************************/
431
432
433
434int
435is_pg_dbname (char *dbname)
436{
437 char txt[NAMEDATALEN];
438 char tmp[NAMEDATALEN];
439 if (strlen (dbname) > NAMEDATALEN - 1)
440 return (FALSE);
441 strncpy (txt, dbname, NAMEDATALEN - 1);
442 txt[NAMEDATALEN - 1] = 0;
443 if (sscanf (txt, "%[_a-zA-Z]%[^_a-zA-Z0-9-]", tmp, tmp) == 1)
444 return (TRUE);
445 if (sscanf (txt, "%[_a-zA-Z]%[_a-zA-Z0-9-]%[^_a-zA-Z0-9-]", tmp, tmp, tmp) ==
446 2) return (TRUE);
447 return (FALSE);
448}
449
450/** 416/**
451 417
452the tango program should eventually create an entity here based on the 418the tango program should eventually create an entity here based on the
@@ -529,6 +495,9 @@ print_help (void)
529 495
530 printf (" %s\n", "-q, --query=STRING"); 496 printf (" %s\n", "-q, --query=STRING");
531 printf (" %s\n", _("SQL query to run. Only first column in first row will be read")); 497 printf (" %s\n", _("SQL query to run. Only first column in first row will be read"));
498 printf (" %s\n", "--queryname=STRING");
499 printf (" %s\n", _("A name for the query, this string is used instead of the query"));
500 printf (" %s\n", _("in the long output of the plugin"));
532 printf (" %s\n", "-W, --query-warning=RANGE"); 501 printf (" %s\n", "-W, --query-warning=RANGE");
533 printf (" %s\n", _("SQL query value to result in warning status (double)")); 502 printf (" %s\n", _("SQL query value to result in warning status (double)"));
534 printf (" %s\n", "-C, --query-critical=RANGE"); 503 printf (" %s\n", "-C, --query-critical=RANGE");
@@ -548,7 +517,10 @@ print_help (void)
548 printf (" %s\n", _("connecting to the server. The result from the query has to be numeric.")); 517 printf (" %s\n", _("connecting to the server. The result from the query has to be numeric."));
549 printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result ")); 518 printf (" %s\n", _("Multiple SQL commands, separated by semicolon, are allowed but the result "));
550 printf (" %s\n", _("of the last command is taken into account only. The value of the first")); 519 printf (" %s\n", _("of the last command is taken into account only. The value of the first"));
551 printf (" %s\n\n", _("column in the first row is used as the check result.")); 520 printf (" %s\n", _("column in the first row is used as the check result. If a second column is"));
521 printf (" %s\n", _("present in the result set, this is added to the plugin output with a"));
522 printf (" %s\n", _("prefix of \"Extra Info:\". This information can be displayed in the system"));
523 printf (" %s\n\n", _("executing the plugin."));
552 524
553 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual")); 525 printf (" %s\n", _("See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"));
554 printf (" %s\n\n", _("for details about how to access internal statistics of the database server.")); 526 printf (" %s\n\n", _("for details about how to access internal statistics of the database server."));
@@ -588,6 +560,7 @@ do_query (PGconn *conn, char *query)
588 PGresult *res; 560 PGresult *res;
589 561
590 char *val_str; 562 char *val_str;
563 char *extra_info;
591 double value; 564 double value;
592 565
593 char *endptr = NULL; 566 char *endptr = NULL;
@@ -642,10 +615,22 @@ do_query (PGconn *conn, char *query)
642 : (my_status == STATE_CRITICAL) 615 : (my_status == STATE_CRITICAL)
643 ? _("CRITICAL") 616 ? _("CRITICAL")
644 : _("UNKNOWN")); 617 : _("UNKNOWN"));
645 printf (_("'%s' returned %f"), query, value); 618 if(pgqueryname) {
619 printf (_("%s returned %f"), pgqueryname, value);
620 }
621 else {
622 printf (_("'%s' returned %f"), query, value);
623 }
624
646 printf ("|query=%f;%s;%s;;\n", value, 625 printf ("|query=%f;%s;%s;;\n", value,
647 query_warning ? query_warning : "", 626 query_warning ? query_warning : "",
648 query_critical ? query_critical : ""); 627 query_critical ? query_critical : "");
628 if (PQnfields (res) > 1) {
629 extra_info = PQgetvalue (res, 0, 1);
630 if (extra_info != NULL) {
631 printf ("Extra Info: %s\n", extra_info);
632 }
633 }
649 return my_status; 634 return my_status;
650} 635}
651 636
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 423ecbe..741f732 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -37,6 +37,8 @@ const char *email = "devel@monitoring-plugins.org";
37#include "popen.h" 37#include "popen.h"
38#include "utils.h" 38#include "utils.h"
39 39
40#include <signal.h>
41
40#define WARN_DUPLICATES "DUPLICATES FOUND! " 42#define WARN_DUPLICATES "DUPLICATES FOUND! "
41#define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */ 43#define UNKNOWN_TRIP_TIME -1.0 /* -1 seconds */
42 44
@@ -138,7 +140,7 @@ main (int argc, char **argv)
138 if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) { 140 if (pl == UNKNOWN_PACKET_LOSS || rta < 0.0) {
139 printf ("%s\n", cmd); 141 printf ("%s\n", cmd);
140 die (STATE_UNKNOWN, 142 die (STATE_UNKNOWN,
141 _("CRITICAL - Could not interpret output from ping command\n")); 143 _("CRITICAL - Could not interpret output from ping command\n"));
142 } 144 }
143 145
144 if (pl >= cpl || rta >= crta || rta < 0) 146 if (pl >= cpl || rta >= crta || rta < 0)
@@ -163,10 +165,14 @@ main (int argc, char **argv)
163 printf ("</A>"); 165 printf ("</A>");
164 166
165 /* Print performance data */ 167 /* Print performance data */
166 printf("|%s", fperfdata ("rta", (double) rta, "ms", 168 if (pl != 100) {
167 wrta>0?TRUE:FALSE, wrta, 169 printf("|%s", fperfdata ("rta", (double) rta, "ms",
168 crta>0?TRUE:FALSE, crta, 170 wrta>0?TRUE:FALSE, wrta,
169 TRUE, 0, FALSE, 0)); 171 crta>0?TRUE:FALSE, crta,
172 TRUE, 0, FALSE, 0));
173 } else {
174 printf("| rta=U;%f;%f;;", wrta, crta);
175 }
170 printf(" %s\n", perfdata ("pl", (long) pl, "%", 176 printf(" %s\n", perfdata ("pl", (long) pl, "%",
171 wpl>0?TRUE:FALSE, wpl, 177 wpl>0?TRUE:FALSE, wpl,
172 cpl>0?TRUE:FALSE, cpl, 178 cpl>0?TRUE:FALSE, cpl,
@@ -521,12 +527,13 @@ int
521error_scan (char buf[MAX_INPUT_BUFFER], const char *addr) 527error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
522{ 528{
523 if (strstr (buf, "Network is unreachable") || 529 if (strstr (buf, "Network is unreachable") ||
524 strstr (buf, "Destination Net Unreachable") 530 strstr (buf, "Destination Net Unreachable") ||
531 strstr (buf, "No route")
525 ) 532 )
526 die (STATE_CRITICAL, _("CRITICAL - Network Unreachable (%s)\n"), addr); 533 die (STATE_CRITICAL, _("CRITICAL - Network Unreachable (%s)\n"), addr);
527 else if (strstr (buf, "Destination Host Unreachable")) 534 else if (strstr (buf, "Destination Host Unreachable") || strstr(buf, "Address unreachable"))
528 die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)\n"), addr); 535 die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)\n"), addr);
529 else if (strstr (buf, "Destination Port Unreachable")) 536 else if (strstr (buf, "Destination Port Unreachable") || strstr(buf, "Port unreachable"))
530 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"), addr); 537 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"), addr);
531 else if (strstr (buf, "Destination Protocol Unreachable")) 538 else if (strstr (buf, "Destination Protocol Unreachable"))
532 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"), addr); 539 die (STATE_CRITICAL, _("CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"), addr);
@@ -534,11 +541,11 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
534 die (STATE_CRITICAL, _("CRITICAL - Network Prohibited (%s)\n"), addr); 541 die (STATE_CRITICAL, _("CRITICAL - Network Prohibited (%s)\n"), addr);
535 else if (strstr (buf, "Destination Host Prohibited")) 542 else if (strstr (buf, "Destination Host Prohibited"))
536 die (STATE_CRITICAL, _("CRITICAL - Host Prohibited (%s)\n"), addr); 543 die (STATE_CRITICAL, _("CRITICAL - Host Prohibited (%s)\n"), addr);
537 else if (strstr (buf, "Packet filtered")) 544 else if (strstr (buf, "Packet filtered") || strstr(buf, "Administratively prohibited"))
538 die (STATE_CRITICAL, _("CRITICAL - Packet Filtered (%s)\n"), addr); 545 die (STATE_CRITICAL, _("CRITICAL - Packet Filtered (%s)\n"), addr);
539 else if (strstr (buf, "unknown host" )) 546 else if (strstr (buf, "unknown host" ))
540 die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)\n"), addr); 547 die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)\n"), addr);
541 else if (strstr (buf, "Time to live exceeded")) 548 else if (strstr (buf, "Time to live exceeded") || strstr(buf, "Time exceeded"))
542 die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)\n"), addr); 549 die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)\n"), addr);
543 else if (strstr (buf, "Destination unreachable: ")) 550 else if (strstr (buf, "Destination unreachable: "))
544 die (STATE_CRITICAL, _("CRITICAL - Destination Unreachable (%s)\n"), addr); 551 die (STATE_CRITICAL, _("CRITICAL - Destination Unreachable (%s)\n"), addr);
@@ -547,7 +554,7 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
547 if (warn_text == NULL) 554 if (warn_text == NULL)
548 warn_text = strdup (_(WARN_DUPLICATES)); 555 warn_text = strdup (_(WARN_DUPLICATES));
549 else if (! strstr (warn_text, _(WARN_DUPLICATES)) && 556 else if (! strstr (warn_text, _(WARN_DUPLICATES)) &&
550 xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1) 557 xasprintf (&warn_text, "%s %s", warn_text, _(WARN_DUPLICATES)) == -1)
551 die (STATE_UNKNOWN, _("Unable to realloc warn_text\n")); 558 die (STATE_UNKNOWN, _("Unable to realloc warn_text\n"));
552 return (STATE_WARNING); 559 return (STATE_WARNING);
553 } 560 }
@@ -567,7 +574,7 @@ print_help (void)
567 574
568 printf (_("Use ping to check connection statistics for a remote host.")); 575 printf (_("Use ping to check connection statistics for a remote host."));
569 576
570 printf ("\n\n"); 577 printf ("\n\n");
571 578
572 print_usage (); 579 print_usage ();
573 580
@@ -577,29 +584,29 @@ print_help (void)
577 printf (UT_IPv46); 584 printf (UT_IPv46);
578 585
579 printf (" %s\n", "-H, --hostname=HOST"); 586 printf (" %s\n", "-H, --hostname=HOST");
580 printf (" %s\n", _("host to ping")); 587 printf (" %s\n", _("host to ping"));
581 printf (" %s\n", "-w, --warning=THRESHOLD"); 588 printf (" %s\n", "-w, --warning=THRESHOLD");
582 printf (" %s\n", _("warning threshold pair")); 589 printf (" %s\n", _("warning threshold pair"));
583 printf (" %s\n", "-c, --critical=THRESHOLD"); 590 printf (" %s\n", "-c, --critical=THRESHOLD");
584 printf (" %s\n", _("critical threshold pair")); 591 printf (" %s\n", _("critical threshold pair"));
585 printf (" %s\n", "-p, --packets=INTEGER"); 592 printf (" %s\n", "-p, --packets=INTEGER");
586 printf (" %s ", _("number of ICMP ECHO packets to send")); 593 printf (" %s ", _("number of ICMP ECHO packets to send"));
587 printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS); 594 printf (_("(Default: %d)\n"), DEFAULT_MAX_PACKETS);
588 printf (" %s\n", "-L, --link"); 595 printf (" %s\n", "-L, --link");
589 printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)")); 596 printf (" %s\n", _("show HTML in the plugin output (obsoleted by urlize)"));
590 597
591 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 598 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
592 599
593 printf ("\n"); 600 printf ("\n");
594 printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel")); 601 printf ("%s\n", _("THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"));
595 printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the")); 602 printf ("%s\n", _("time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"));
596 printf ("%s\n", _("percentage of packet loss to trigger an alarm state.")); 603 printf ("%s\n", _("percentage of packet loss to trigger an alarm state."));
597 604
598 printf ("\n"); 605 printf ("\n");
599 printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss")); 606 printf ("%s\n", _("This plugin uses the ping command to probe the specified host for packet loss"));
600 printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output")); 607 printf ("%s\n", _("(percentage) and round trip average (milliseconds). It can produce HTML output"));
601 printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in")); 608 printf ("%s\n", _("linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"));
602 printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/")); 609 printf ("%s\n", _("the contrib area of the downloads section at http://www.nagios.org/"));
603 610
604 printf (UT_SUPPORT); 611 printf (UT_SUPPORT);
605} 612}
@@ -607,7 +614,7 @@ print_help (void)
607void 614void
608print_usage (void) 615print_usage (void)
609{ 616{
610 printf ("%s\n", _("Usage:")); 617 printf ("%s\n", _("Usage:"));
611 printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname); 618 printf ("%s -H <host_address> -w <wrta>,<wpl>%% -c <crta>,<cpl>%%\n", progname);
612 printf (" [-p packets] [-t timeout] [-4|-6]\n"); 619 printf (" [-p packets] [-t timeout] [-4|-6]\n");
613} 620}
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index f7917c3..c17c699 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -1,34 +1,34 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_procs plugin 3* Monitoring check_procs plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2008 Monitoring Plugins Development Team 6* Copyright (c) 2000-2008 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_procs plugin 10* This file contains the check_procs plugin
11* 11*
12* Checks all processes and generates WARNING or CRITICAL states if the 12* Checks all processes and generates WARNING or CRITICAL states if the
13* specified metric is outside the required threshold ranges. The metric 13* specified metric is outside the required threshold ranges. The metric
14* defaults to number of processes. Search filters can be applied to limit 14* defaults to number of processes. Search filters can be applied to limit
15* the processes to check. 15* the processes to check.
16* 16*
17* 17*
18* This program is free software: you can redistribute it and/or modify 18* This program is free software: you can redistribute it and/or modify
19* it under the terms of the GNU General Public License as published by 19* it under the terms of the GNU General Public License as published by
20* the Free Software Foundation, either version 3 of the License, or 20* the Free Software Foundation, either version 3 of the License, or
21* (at your option) any later version. 21* (at your option) any later version.
22* 22*
23* This program is distributed in the hope that it will be useful, 23* This program is distributed in the hope that it will be useful,
24* but WITHOUT ANY WARRANTY; without even the implied warranty of 24* but WITHOUT ANY WARRANTY; without even the implied warranty of
25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26* GNU General Public License for more details. 26* GNU General Public License for more details.
27* 27*
28* You should have received a copy of the GNU General Public License 28* You should have received a copy of the GNU General Public License
29* along with this program. If not, see <http://www.gnu.org/licenses/>. 29* along with this program. If not, see <http://www.gnu.org/licenses/>.
30* 30*
31* 31*
32*****************************************************************************/ 32*****************************************************************************/
33 33
34const char *progname = "check_procs"; 34const char *progname = "check_procs";
@@ -50,7 +50,7 @@ const char *email = "devel@monitoring-plugins.org";
50 50
51int process_arguments (int, char **); 51int process_arguments (int, char **);
52int validate_arguments (void); 52int validate_arguments (void);
53int convert_to_seconds (char *); 53int convert_to_seconds (char *);
54void print_help (void); 54void print_help (void);
55void print_usage (void); 55void print_usage (void);
56 56
@@ -70,6 +70,7 @@ int options = 0; /* bitmask of filter criteria to test against */
70#define PCPU 256 70#define PCPU 256
71#define ELAPSED 512 71#define ELAPSED 512
72#define EREG_ARGS 1024 72#define EREG_ARGS 1024
73#define EXCLUDE_PROGS 2048
73 74
74#define KTHREAD_PARENT "kthreadd" /* the parent process of kernel threads: 75#define KTHREAD_PARENT "kthreadd" /* the parent process of kernel threads:
75 ppid of procs are compared to pid of this proc*/ 76 ppid of procs are compared to pid of this proc*/
@@ -93,6 +94,9 @@ int rss;
93float pcpu; 94float pcpu;
94char *statopts; 95char *statopts;
95char *prog; 96char *prog;
97char *exclude_progs;
98char **exclude_progs_arr = NULL;
99char exclude_progs_counter = 0;
96char *args; 100char *args;
97char *input_filename = NULL; 101char *input_filename = NULL;
98regex_t re_args; 102regex_t re_args;
@@ -230,9 +234,9 @@ main (int argc, char **argv)
230 procseconds = convert_to_seconds(procetime); 234 procseconds = convert_to_seconds(procetime);
231 235
232 if (verbose >= 3) 236 if (verbose >= 3)
233 printf ("proc#=%d uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n", 237 printf ("proc#=%d uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n",
234 procs, procuid, procvsz, procrss, 238 procs, procuid, procvsz, procrss,
235 procpid, procppid, procpcpu, procstat, 239 procpid, procppid, procpcpu, procstat,
236 procetime, procprog, procargs); 240 procetime, procprog, procargs);
237 241
238 /* Ignore self */ 242 /* Ignore self */
@@ -250,7 +254,26 @@ main (int argc, char **argv)
250 continue; 254 continue;
251 } 255 }
252 256
253 /* filter kernel threads (childs of KTHREAD_PARENT)*/ 257 /* Ignore excluded processes by name */
258 if(options & EXCLUDE_PROGS) {
259 int found = 0;
260 int i = 0;
261
262 for(i=0; i < (exclude_progs_counter); i++) {
263 if(!strcmp(procprog, exclude_progs_arr[i])) {
264 found = 1;
265 }
266 }
267 if(found == 0) {
268 resultsum |= EXCLUDE_PROGS;
269 } else
270 {
271 if(verbose >= 3)
272 printf("excluding - by ignorelist\n");
273 }
274 }
275
276 /* filter kernel threads (children of KTHREAD_PARENT)*/
254 /* TODO adapt for other OSes than GNU/Linux 277 /* TODO adapt for other OSes than GNU/Linux
255 sorry for not doing that, but I've no other OSes to test :-( */ 278 sorry for not doing that, but I've no other OSes to test :-( */
256 if (kthread_filter == 1) { 279 if (kthread_filter == 1) {
@@ -265,7 +288,7 @@ main (int argc, char **argv)
265 } 288 }
266 } 289 }
267 290
268 if ((options & STAT) && (strstr (statopts, procstat))) 291 if ((options & STAT) && (strstr (procstat, statopts)))
269 resultsum |= STAT; 292 resultsum |= STAT;
270 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) 293 if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL))
271 resultsum |= ARGS; 294 resultsum |= ARGS;
@@ -292,9 +315,9 @@ main (int argc, char **argv)
292 315
293 procs++; 316 procs++;
294 if (verbose >= 2) { 317 if (verbose >= 2) {
295 printf ("Matched: uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n", 318 printf ("Matched: uid=%d vsz=%d rss=%d pid=%d ppid=%d pcpu=%.2f stat=%s etime=%s prog=%s args=%s\n",
296 procuid, procvsz, procrss, 319 procuid, procvsz, procrss,
297 procpid, procppid, procpcpu, procstat, 320 procpid, procppid, procpcpu, procstat,
298 procetime, procprog, procargs); 321 procetime, procprog, procargs);
299 } 322 }
300 323
@@ -320,7 +343,7 @@ main (int argc, char **argv)
320 result = max_state (result, i); 343 result = max_state (result, i);
321 } 344 }
322 } 345 }
323 } 346 }
324 /* This should not happen */ 347 /* This should not happen */
325 else if (verbose) { 348 else if (verbose) {
326 printf(_("Not parseable: %s"), input_buffer); 349 printf(_("Not parseable: %s"), input_buffer);
@@ -332,7 +355,7 @@ main (int argc, char **argv)
332 return STATE_UNKNOWN; 355 return STATE_UNKNOWN;
333 } 356 }
334 357
335 if ( result == STATE_UNKNOWN ) 358 if ( result == STATE_UNKNOWN )
336 result = STATE_OK; 359 result = STATE_OK;
337 360
338 /* Needed if procs found, but none match filter */ 361 /* Needed if procs found, but none match filter */
@@ -352,9 +375,9 @@ main (int argc, char **argv)
352 if (metric != METRIC_PROCS) { 375 if (metric != METRIC_PROCS) {
353 printf (_("%d crit, %d warn out of "), crit, warn); 376 printf (_("%d crit, %d warn out of "), crit, warn);
354 } 377 }
355 } 378 }
356 printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs); 379 printf (ngettext ("%d process", "%d processes", (unsigned long) procs), procs);
357 380
358 if (strcmp(fmt,"") != 0) { 381 if (strcmp(fmt,"") != 0) {
359 printf (_(" with %s"), fmt); 382 printf (_(" with %s"), fmt);
360 } 383 }
@@ -409,6 +432,7 @@ process_arguments (int argc, char **argv)
409 {"input-file", required_argument, 0, CHAR_MAX+2}, 432 {"input-file", required_argument, 0, CHAR_MAX+2},
410 {"no-kthreads", required_argument, 0, 'k'}, 433 {"no-kthreads", required_argument, 0, 'k'},
411 {"traditional-filter", no_argument, 0, 'T'}, 434 {"traditional-filter", no_argument, 0, 'T'},
435 {"exclude-process", required_argument, 0, 'X'},
412 {0, 0, 0, 0} 436 {0, 0, 0, 0}
413 }; 437 };
414 438
@@ -417,7 +441,7 @@ process_arguments (int argc, char **argv)
417 strcpy (argv[c], "-t"); 441 strcpy (argv[c], "-t");
418 442
419 while (1) { 443 while (1) {
420 c = getopt_long (argc, argv, "Vvhkt:c:w:p:s:u:C:a:z:r:m:P:T", 444 c = getopt_long (argc, argv, "Vvhkt:c:w:p:s:u:C:a:z:r:m:P:T:X:",
421 longopts, &option); 445 longopts, &option);
422 446
423 if (c == -1 || c == EOF) 447 if (c == -1 || c == EOF)
@@ -440,7 +464,7 @@ process_arguments (int argc, char **argv)
440 break; 464 break;
441 case 'c': /* critical threshold */ 465 case 'c': /* critical threshold */
442 critical_range = optarg; 466 critical_range = optarg;
443 break; 467 break;
444 case 'w': /* warning threshold */ 468 case 'w': /* warning threshold */
445 warning_range = optarg; 469 warning_range = optarg;
446 break; 470 break;
@@ -490,6 +514,23 @@ process_arguments (int argc, char **argv)
490 prog); 514 prog);
491 options |= PROG; 515 options |= PROG;
492 break; 516 break;
517 case 'X':
518 if(exclude_progs)
519 break;
520 else
521 exclude_progs = optarg;
522 xasprintf (&fmt, _("%s%sexclude progs '%s'"), (fmt ? fmt : ""), (options ? ", " : ""),
523 exclude_progs);
524 char *p = strtok(exclude_progs, ",");
525
526 while(p){
527 exclude_progs_arr = realloc(exclude_progs_arr, sizeof(char*) * ++exclude_progs_counter);
528 exclude_progs_arr[exclude_progs_counter-1] = p;
529 p = strtok(NULL, ",");
530 }
531
532 options |= EXCLUDE_PROGS;
533 break;
493 case 'a': /* args (full path name with args) */ 534 case 'a': /* args (full path name with args) */
494 /* TODO: allow this to be passed in with --metric */ 535 /* TODO: allow this to be passed in with --metric */
495 if (args) 536 if (args)
@@ -542,11 +583,11 @@ process_arguments (int argc, char **argv)
542 if ( strcmp(optarg, "PROCS") == 0) { 583 if ( strcmp(optarg, "PROCS") == 0) {
543 metric = METRIC_PROCS; 584 metric = METRIC_PROCS;
544 break; 585 break;
545 } 586 }
546 else if ( strcmp(optarg, "VSZ") == 0) { 587 else if ( strcmp(optarg, "VSZ") == 0) {
547 metric = METRIC_VSZ; 588 metric = METRIC_VSZ;
548 break; 589 break;
549 } 590 }
550 else if ( strcmp(optarg, "RSS") == 0 ) { 591 else if ( strcmp(optarg, "RSS") == 0 ) {
551 metric = METRIC_RSS; 592 metric = METRIC_RSS;
552 break; 593 break;
@@ -559,7 +600,7 @@ process_arguments (int argc, char **argv)
559 metric = METRIC_ELAPSED; 600 metric = METRIC_ELAPSED;
560 break; 601 break;
561 } 602 }
562 603
563 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!")); 604 usage4 (_("Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"));
564 case 'k': /* linux kernel thread filter */ 605 case 'k': /* linux kernel thread filter */
565 kthread_filter = 1; 606 kthread_filter = 1;
@@ -642,7 +683,7 @@ convert_to_seconds(char *etime) {
642 seconds = 0; 683 seconds = 0;
643 684
644 for (ptr = etime; *ptr != '\0'; ptr++) { 685 for (ptr = etime; *ptr != '\0'; ptr++) {
645 686
646 if (*ptr == '-') { 687 if (*ptr == '-') {
647 hyphcnt++; 688 hyphcnt++;
648 continue; 689 continue;
@@ -745,6 +786,8 @@ print_help (void)
745 printf (" %s\n", _("Only scan for processes with args that contain the regex STRING.")); 786 printf (" %s\n", _("Only scan for processes with args that contain the regex STRING."));
746 printf (" %s\n", "-C, --command=COMMAND"); 787 printf (" %s\n", "-C, --command=COMMAND");
747 printf (" %s\n", _("Only scan for exact matches of COMMAND (without path).")); 788 printf (" %s\n", _("Only scan for exact matches of COMMAND (without path)."));
789 printf (" %s\n", "-X, --exclude-process");
790 printf (" %s\n", _("Exclude processes which match this comma separated list"));
748 printf (" %s\n", "-k, --no-kthreads"); 791 printf (" %s\n", "-k, --no-kthreads");
749 printf (" %s\n", _("Only scan for non kernel threads (works on Linux only).")); 792 printf (" %s\n", _("Only scan for non kernel threads (works on Linux only)."));
750 793
@@ -775,7 +818,7 @@ be the total number of running processes\n\n"));
775 printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ"); 818 printf (" %s\n", "check_procs -w 50000 -c 100000 --metric=VSZ");
776 printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K")); 819 printf (" %s\n\n", _("Alert if VSZ of any processes over 50K or 100K"));
777 printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU"); 820 printf (" %s\n", "check_procs -w 10 -c 20 --metric=CPU");
778 printf (" %s\n", _("Alert if CPU of any processes over 10%% or 20%%")); 821 printf (" %s\n", _("Alert if CPU of any processes over 10\% or 20\%"));
779 822
780 printf (UT_SUPPORT); 823 printf (UT_SUPPORT);
781} 824}
@@ -786,5 +829,5 @@ print_usage (void)
786 printf ("%s\n", _("Usage:")); 829 printf ("%s\n", _("Usage:"));
787 printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname); 830 printf ("%s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n", progname);
788 printf (" [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n"); 831 printf (" [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n");
789 printf (" [-C command] [-k] [-t timeout] [-v]\n"); 832 printf (" [-C command] [-X process_to_exclude] [-k] [-t timeout] [-v]\n");
790} 833}
diff --git a/plugins/check_radius.c b/plugins/check_radius.c
index be1001b..b1b4938 100644
--- a/plugins/check_radius.c
+++ b/plugins/check_radius.c
@@ -97,7 +97,7 @@ int verbose = FALSE;
97 97
98/****************************************************************************** 98/******************************************************************************
99 99
100The (psuedo?)literate programming XML is contained within \@\@\- <XML> \-\@\@ 100The (pseudo?)literate programming XML is contained within \@\@\- <XML> \-\@\@
101tags in the comments. With in the tags, the XML is assembled sequentially. 101tags in the comments. With in the tags, the XML is assembled sequentially.
102You can define entities in tags. You also have all the #defines available as 102You can define entities in tags. You also have all the #defines available as
103entities. 103entities.
@@ -155,7 +155,11 @@ main (int argc, char **argv)
155{ 155{
156 struct sockaddr_storage ss; 156 struct sockaddr_storage ss;
157 char name[HOST_NAME_MAX]; 157 char name[HOST_NAME_MAX];
158#ifdef RC_BUFFER_LEN
159 char msg[RC_BUFFER_LEN];
160#else
158 char msg[BUFFER_LEN]; 161 char msg[BUFFER_LEN];
162#endif
159 SEND_DATA data; 163 SEND_DATA data;
160 int result = STATE_UNKNOWN; 164 int result = STATE_UNKNOWN;
161 uint32_t client_id, service; 165 uint32_t client_id, service;
@@ -377,7 +381,7 @@ print_help (void)
377 printf ("\n"); 381 printf ("\n");
378 printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections.")); 382 printf ("%s\n", _("This plugin tests a RADIUS server to see if it is accepting connections."));
379 printf ("%s\n", _("The server to test must be specified in the invocation, as well as a user")); 383 printf ("%s\n", _("The server to test must be specified in the invocation, as well as a user"));
380 printf ("%s\n", _("name and password. A configuration file may also be present. The format of")); 384 printf ("%s\n", _("name and password. A configuration file must be present. The format of"));
381 printf ("%s\n", _("the configuration file is described in the radiusclient library sources.")); 385 printf ("%s\n", _("the configuration file is described in the radiusclient library sources."));
382 printf ("%s\n", _("The password option presents a substantial security issue because the")); 386 printf ("%s\n", _("The password option presents a substantial security issue because the"));
383 printf ("%s\n", _("password can possibly be determined by careful watching of the command line")); 387 printf ("%s\n", _("password can possibly be determined by careful watching of the command line"));
diff --git a/plugins/check_real.c b/plugins/check_real.c
index 0f1a1ba..fbdb70f 100644
--- a/plugins/check_real.c
+++ b/plugins/check_real.c
@@ -178,7 +178,7 @@ main (int argc, char **argv)
178 178
179 /* watch for the REAL connection string */ 179 /* watch for the REAL connection string */
180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0); 180 result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
181 buffer[result] = '\0'; /* null terminate recieved buffer */ 181 buffer[result] = '\0'; /* null terminate received buffer */
182 182
183 /* return a CRITICAL status if we couldn't read any data */ 183 /* return a CRITICAL status if we couldn't read any data */
184 if (result == -1) { 184 if (result == -1) {
@@ -436,7 +436,7 @@ print_help (void)
436 436
437 printf ("\n"); 437 printf ("\n");
438 printf ("%s\n", _("This plugin will attempt to open an RTSP connection with the host.")); 438 printf ("%s\n", _("This plugin will attempt to open an RTSP connection with the host."));
439 printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return")); 439 printf ("%s\n", _("Successful connects return STATE_OK, refusals and timeouts return"));
440 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,")); 440 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"));
441 printf ("%s\n", _("but incorrect response messages from the host result in STATE_WARNING return")); 441 printf ("%s\n", _("but incorrect response messages from the host result in STATE_WARNING return"));
442 printf ("%s\n", _("values.")); 442 printf ("%s\n", _("values."));
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index d37c57c..fc0ae2c 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -3,7 +3,7 @@
3* Monitoring check_smtp plugin 3* Monitoring check_smtp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2007 Monitoring Plugins Development Team 6* Copyright (c) 2000-2023 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
@@ -42,19 +42,22 @@ const char *email = "devel@monitoring-plugins.org";
42#ifdef HAVE_SSL 42#ifdef HAVE_SSL
43int check_cert = FALSE; 43int check_cert = FALSE;
44int days_till_exp_warn, days_till_exp_crit; 44int days_till_exp_warn, days_till_exp_crit;
45# define my_recv(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) 45# define my_recv(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_read(buf, len) : read(sd, buf, len))
46# define my_send(buf, len) ((use_ssl && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0)) 46# define my_send(buf, len) (((use_starttls || use_ssl) && ssl_established) ? np_net_ssl_write(buf, len) : send(sd, buf, len, 0))
47#else /* ifndef HAVE_SSL */ 47#else /* ifndef HAVE_SSL */
48# define my_recv(buf, len) read(sd, buf, len) 48# define my_recv(buf, len) read(sd, buf, len)
49# define my_send(buf, len) send(sd, buf, len, 0) 49# define my_send(buf, len) send(sd, buf, len, 0)
50#endif 50#endif
51 51
52enum { 52enum {
53 SMTP_PORT = 25 53 SMTP_PORT = 25,
54 SMTPS_PORT = 465
54}; 55};
56#define PROXY_PREFIX "PROXY TCP4 0.0.0.0 0.0.0.0 25 25\r\n"
55#define SMTP_EXPECT "220" 57#define SMTP_EXPECT "220"
56#define SMTP_HELO "HELO " 58#define SMTP_HELO "HELO "
57#define SMTP_EHLO "EHLO " 59#define SMTP_EHLO "EHLO "
60#define SMTP_LHLO "LHLO "
58#define SMTP_QUIT "QUIT\r\n" 61#define SMTP_QUIT "QUIT\r\n"
59#define SMTP_STARTTLS "STARTTLS\r\n" 62#define SMTP_STARTTLS "STARTTLS\r\n"
60#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n" 63#define SMTP_AUTH_LOGIN "AUTH LOGIN\r\n"
@@ -81,6 +84,7 @@ int eflags = 0;
81int errcode, excode; 84int errcode, excode;
82 85
83int server_port = SMTP_PORT; 86int server_port = SMTP_PORT;
87int server_port_option = 0;
84char *server_address = NULL; 88char *server_address = NULL;
85char *server_expect = NULL; 89char *server_expect = NULL;
86char *mail_command = NULL; 90char *mail_command = NULL;
@@ -101,7 +105,11 @@ double critical_time = 0;
101int check_critical_time = FALSE; 105int check_critical_time = FALSE;
102int verbose = 0; 106int verbose = 0;
103int use_ssl = FALSE; 107int use_ssl = FALSE;
108int use_starttls = FALSE;
109int use_sni = FALSE;
110short use_proxy_prefix = FALSE;
104short use_ehlo = FALSE; 111short use_ehlo = FALSE;
112short use_lhlo = FALSE;
105short ssl_established = 0; 113short ssl_established = 0;
106char *localhostname = NULL; 114char *localhostname = NULL;
107int sd; 115int sd;
@@ -152,7 +160,9 @@ main (int argc, char **argv)
152 return STATE_CRITICAL; 160 return STATE_CRITICAL;
153 } 161 }
154 } 162 }
155 if(use_ehlo) 163 if(use_lhlo)
164 xasprintf (&helocmd, "%s%s%s", SMTP_LHLO, localhostname, "\r\n");
165 else if(use_ehlo)
156 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n"); 166 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
157 else 167 else
158 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n"); 168 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
@@ -179,6 +189,26 @@ main (int argc, char **argv)
179 result = my_tcp_connect (server_address, server_port, &sd); 189 result = my_tcp_connect (server_address, server_port, &sd);
180 190
181 if (result == STATE_OK) { /* we connected */ 191 if (result == STATE_OK) { /* we connected */
192 /* If requested, send PROXY header */
193 if (use_proxy_prefix) {
194 if (verbose)
195 printf ("Sending header %s\n", PROXY_PREFIX);
196 my_send(PROXY_PREFIX, strlen(PROXY_PREFIX));
197 }
198
199#ifdef HAVE_SSL
200 if (use_ssl) {
201 result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
202 if (result != STATE_OK) {
203 printf (_("CRITICAL - Cannot create SSL context.\n"));
204 close(sd);
205 np_net_ssl_cleanup();
206 return STATE_CRITICAL;
207 } else {
208 ssl_established = 1;
209 }
210 }
211#endif
182 212
183 /* watch for the SMTP connection string and */ 213 /* watch for the SMTP connection string and */
184 /* return a WARNING status if we couldn't read any data */ 214 /* return a WARNING status if we couldn't read any data */
@@ -191,27 +221,27 @@ main (int argc, char **argv)
191 xasprintf(&server_response, "%s", buffer); 221 xasprintf(&server_response, "%s", buffer);
192 222
193 /* send the HELO/EHLO command */ 223 /* send the HELO/EHLO command */
194 send(sd, helocmd, strlen(helocmd), 0); 224 my_send(helocmd, strlen(helocmd));
195 225
196 /* allow for response to helo command to reach us */ 226 /* allow for response to helo command to reach us */
197 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) { 227 if (recvlines(buffer, MAX_INPUT_BUFFER) <= 0) {
198 printf (_("recv() failed\n")); 228 printf (_("recv() failed\n"));
199 return STATE_WARNING; 229 return STATE_WARNING;
200 } else if(use_ehlo){ 230 } else if(use_ehlo || use_lhlo){
201 if(strstr(buffer, "250 STARTTLS") != NULL || 231 if(strstr(buffer, "250 STARTTLS") != NULL ||
202 strstr(buffer, "250-STARTTLS") != NULL){ 232 strstr(buffer, "250-STARTTLS") != NULL){
203 supports_tls=TRUE; 233 supports_tls=TRUE;
204 } 234 }
205 } 235 }
206 236
207 if(use_ssl && ! supports_tls){ 237 if(use_starttls && ! supports_tls){
208 printf(_("WARNING - TLS not supported by server\n")); 238 printf(_("WARNING - TLS not supported by server\n"));
209 smtp_quit(); 239 smtp_quit();
210 return STATE_WARNING; 240 return STATE_WARNING;
211 } 241 }
212 242
213#ifdef HAVE_SSL 243#ifdef HAVE_SSL
214 if(use_ssl) { 244 if(use_starttls) {
215 /* send the STARTTLS command */ 245 /* send the STARTTLS command */
216 send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0); 246 send(sd, SMTP_STARTTLS, strlen(SMTP_STARTTLS), 0);
217 247
@@ -221,7 +251,7 @@ main (int argc, char **argv)
221 smtp_quit(); 251 smtp_quit();
222 return STATE_UNKNOWN; 252 return STATE_UNKNOWN;
223 } 253 }
224 result = np_net_ssl_init(sd); 254 result = np_net_ssl_init_with_hostname(sd, (use_sni ? server_address : NULL));
225 if(result != STATE_OK) { 255 if(result != STATE_OK) {
226 printf (_("CRITICAL - Cannot create SSL context.\n")); 256 printf (_("CRITICAL - Cannot create SSL context.\n"));
227 close(sd); 257 close(sd);
@@ -450,6 +480,10 @@ process_arguments (int argc, char **argv)
450 int c; 480 int c;
451 char* temp; 481 char* temp;
452 482
483 enum {
484 SNI_OPTION
485 };
486
453 int option = 0; 487 int option = 0;
454 static struct option longopts[] = { 488 static struct option longopts[] = {
455 {"hostname", required_argument, 0, 'H'}, 489 {"hostname", required_argument, 0, 'H'},
@@ -470,9 +504,14 @@ process_arguments (int argc, char **argv)
470 {"use-ipv4", no_argument, 0, '4'}, 504 {"use-ipv4", no_argument, 0, '4'},
471 {"use-ipv6", no_argument, 0, '6'}, 505 {"use-ipv6", no_argument, 0, '6'},
472 {"help", no_argument, 0, 'h'}, 506 {"help", no_argument, 0, 'h'},
507 {"lmtp", no_argument, 0, 'L'},
508 {"ssl", no_argument, 0, 's'},
509 {"tls", no_argument, 0, 's'},
473 {"starttls",no_argument,0,'S'}, 510 {"starttls",no_argument,0,'S'},
511 {"sni", no_argument, 0, SNI_OPTION},
474 {"certificate",required_argument,0,'D'}, 512 {"certificate",required_argument,0,'D'},
475 {"ignore-quit-failure",no_argument,0,'q'}, 513 {"ignore-quit-failure",no_argument,0,'q'},
514 {"proxy",no_argument,0,'r'},
476 {0, 0, 0, 0} 515 {0, 0, 0, 0}
477 }; 516 };
478 517
@@ -489,7 +528,7 @@ process_arguments (int argc, char **argv)
489 } 528 }
490 529
491 while (1) { 530 while (1) {
492 c = getopt_long (argc, argv, "+hVv46t:p:f:e:c:w:H:C:R:SD:F:A:U:P:q", 531 c = getopt_long (argc, argv, "+hVv46Lrt:p:f:e:c:w:H:C:R:sSD:F:A:U:P:q",
493 longopts, &option); 532 longopts, &option);
494 533
495 if (c == -1 || c == EOF) 534 if (c == -1 || c == EOF)
@@ -506,7 +545,7 @@ process_arguments (int argc, char **argv)
506 break; 545 break;
507 case 'p': /* port */ 546 case 'p': /* port */
508 if (is_intpos (optarg)) 547 if (is_intpos (optarg))
509 server_port = atoi (optarg); 548 server_port_option = atoi (optarg);
510 else 549 else
511 usage4 (_("Port must be a positive integer")); 550 usage4 (_("Port must be a positive integer"));
512 break; 551 break;
@@ -611,11 +650,29 @@ process_arguments (int argc, char **argv)
611#else 650#else
612 usage (_("SSL support not available - install OpenSSL and recompile")); 651 usage (_("SSL support not available - install OpenSSL and recompile"));
613#endif 652#endif
653 case 's':
654 /* ssl */
655 use_ssl = TRUE;
656 server_port = SMTPS_PORT;
657 break;
614 case 'S': 658 case 'S':
615 /* starttls */ 659 /* starttls */
616 use_ssl = TRUE; 660 use_starttls = TRUE;
617 use_ehlo = TRUE; 661 use_ehlo = TRUE;
618 break; 662 break;
663 case SNI_OPTION:
664#ifdef HAVE_SSL
665 use_sni = TRUE;
666#else
667 usage (_("SSL support not available - install OpenSSL and recompile"));
668#endif
669 break;
670 case 'r':
671 use_proxy_prefix = TRUE;
672 break;
673 case 'L':
674 use_lhlo = TRUE;
675 break;
619 case '4': 676 case '4':
620 address_family = AF_INET; 677 address_family = AF_INET;
621 break; 678 break;
@@ -659,6 +716,14 @@ process_arguments (int argc, char **argv)
659 if (from_arg==NULL) 716 if (from_arg==NULL)
660 from_arg = strdup(" "); 717 from_arg = strdup(" ");
661 718
719 if (use_starttls && use_ssl) {
720 usage4 (_("Set either -s/--ssl/--tls or -S/--starttls"));
721 }
722
723 if (server_port_option != 0) {
724 server_port = server_port_option;
725 }
726
662 return validate_arguments (); 727 return validate_arguments ();
663} 728}
664 729
@@ -811,11 +876,18 @@ print_help (void)
811 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")), 876 printf (" %s\n", _("FROM-address to include in MAIL command, required by Exchange 2000")),
812 printf (" %s\n", "-F, --fqdn=STRING"); 877 printf (" %s\n", "-F, --fqdn=STRING");
813 printf (" %s\n", _("FQDN used for HELO")); 878 printf (" %s\n", _("FQDN used for HELO"));
879 printf (" %s\n", "-r, --proxy");
880 printf (" %s\n", _("Use PROXY protocol prefix for the connection."));
814#ifdef HAVE_SSL 881#ifdef HAVE_SSL
815 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]"); 882 printf (" %s\n", "-D, --certificate=INTEGER[,INTEGER]");
816 printf (" %s\n", _("Minimum number of days a certificate has to be valid.")); 883 printf (" %s\n", _("Minimum number of days a certificate has to be valid."));
884 printf (" %s\n", "-s, --ssl, --tls");
885 printf (" %s\n", _("Use SSL/TLS for the connection."));
886 printf (_(" Sets default port to %d.\n"), SMTPS_PORT);
817 printf (" %s\n", "-S, --starttls"); 887 printf (" %s\n", "-S, --starttls");
818 printf (" %s\n", _("Use STARTTLS for the connection.")); 888 printf (" %s\n", _("Use STARTTLS for the connection."));
889 printf (" %s\n", "--sni");
890 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
819#endif 891#endif
820 892
821 printf (" %s\n", "-A, --authtype=STRING"); 893 printf (" %s\n", "-A, --authtype=STRING");
@@ -824,6 +896,8 @@ print_help (void)
824 printf (" %s\n", _("SMTP AUTH username")); 896 printf (" %s\n", _("SMTP AUTH username"));
825 printf (" %s\n", "-P, --authpass=STRING"); 897 printf (" %s\n", "-P, --authpass=STRING");
826 printf (" %s\n", _("SMTP AUTH password")); 898 printf (" %s\n", _("SMTP AUTH password"));
899 printf (" %s\n", "-L, --lmtp");
900 printf (" %s\n", _("Send LHLO instead of HELO/EHLO"));
827 printf (" %s\n", "-q, --ignore-quit-failure"); 901 printf (" %s\n", "-q, --ignore-quit-failure");
828 printf (" %s\n", _("Ignore failure when sending QUIT command to server")); 902 printf (" %s\n", _("Ignore failure when sending QUIT command to server"));
829 903
@@ -834,7 +908,7 @@ print_help (void)
834 printf (UT_VERBOSE); 908 printf (UT_VERBOSE);
835 909
836 printf("\n"); 910 printf("\n");
837 printf ("%s\n", _("Successul connects return STATE_OK, refusals and timeouts return")); 911 printf ("%s\n", _("Successful connects return STATE_OK, refusals and timeouts return"));
838 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful")); 912 printf ("%s\n", _("STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"));
839 printf ("%s\n", _("connects, but incorrect response messages from the host result in")); 913 printf ("%s\n", _("connects, but incorrect response messages from the host result in"));
840 printf ("%s\n", _("STATE_WARNING return values.")); 914 printf ("%s\n", _("STATE_WARNING return values."));
@@ -850,6 +924,6 @@ print_usage (void)
850 printf ("%s\n", _("Usage:")); 924 printf ("%s\n", _("Usage:"));
851 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname); 925 printf ("%s -H host [-p port] [-4|-6] [-e expect] [-C command] [-R response] [-f from addr]\n", progname);
852 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n"); 926 printf ("[-A authtype -U authuser -P authpass] [-w warn] [-c crit] [-t timeout] [-q]\n");
853 printf ("[-F fqdn] [-S] [-D warn days cert expire[,crit days cert expire]] [-v] \n"); 927 printf ("[-F fqdn] [-S] [-L] [-D warn days cert expire[,crit days cert expire]] [-r] [--sni] [-v] \n");
854} 928}
855 929
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index afc568b..2acada2 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -1,31 +1,31 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_snmp plugin 3* Monitoring check_snmp plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 1999-2007 Monitoring Plugins Development Team 6* Copyright (c) 1999-2007 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_snmp plugin 10* This file contains the check_snmp plugin
11* 11*
12* Check status of remote machines and obtain system information via SNMP 12* Check status of remote machines and obtain system information via SNMP
13* 13*
14* 14*
15* This program is free software: you can redistribute it and/or modify 15* This program is free software: you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by 16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation, either version 3 of the License, or 17* the Free Software Foundation, either version 3 of the License, or
18* (at your option) any later version. 18* (at your option) any later version.
19* 19*
20* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details. 23* GNU General Public License for more details.
24* 24*
25* You should have received a copy of the GNU General Public License 25* You should have received a copy of the GNU General Public License
26* along with this program. If not, see <http://www.gnu.org/licenses/>. 26* along with this program. If not, see <http://www.gnu.org/licenses/>.
27* 27*
28* 28*
29*****************************************************************************/ 29*****************************************************************************/
30 30
31const char *progname = "check_snmp"; 31const char *progname = "check_snmp";
@@ -46,6 +46,7 @@ const char *email = "devel@monitoring-plugins.org";
46#define DEFAULT_PRIV_PROTOCOL "DES" 46#define DEFAULT_PRIV_PROTOCOL "DES"
47#define DEFAULT_DELIMITER "=" 47#define DEFAULT_DELIMITER "="
48#define DEFAULT_OUTPUT_DELIMITER " " 48#define DEFAULT_OUTPUT_DELIMITER " "
49#define DEFAULT_BUFFER_SIZE 100
49 50
50#define mark(a) ((a)!=0?"*":"") 51#define mark(a) ((a)!=0?"*":"")
51 52
@@ -64,6 +65,7 @@ const char *email = "devel@monitoring-plugins.org";
64#define L_RATE_MULTIPLIER CHAR_MAX+2 65#define L_RATE_MULTIPLIER CHAR_MAX+2
65#define L_INVERT_SEARCH CHAR_MAX+3 66#define L_INVERT_SEARCH CHAR_MAX+3
66#define L_OFFSET CHAR_MAX+4 67#define L_OFFSET CHAR_MAX+4
68#define L_IGNORE_MIB_PARSING_ERRORS CHAR_MAX+5
67 69
68/* Gobble to string - stop incrementing c when c[0] match one of the 70/* Gobble to string - stop incrementing c when c[0] match one of the
69 * characters in s */ 71 * characters in s */
@@ -90,6 +92,7 @@ char *thisarg (char *str);
90char *nextarg (char *str); 92char *nextarg (char *str);
91void print_usage (void); 93void print_usage (void);
92void print_help (void); 94void print_help (void);
95char *multiply (char *str);
93 96
94#include "regex.h" 97#include "regex.h"
95char regex_expect[MAX_INPUT_BUFFER] = ""; 98char regex_expect[MAX_INPUT_BUFFER] = "";
@@ -113,6 +116,7 @@ char *authproto = NULL;
113char *privproto = NULL; 116char *privproto = NULL;
114char *authpasswd = NULL; 117char *authpasswd = NULL;
115char *privpasswd = NULL; 118char *privpasswd = NULL;
119int nulloid = STATE_UNKNOWN;
116char **oids = NULL; 120char **oids = NULL;
117size_t oids_size = 0; 121size_t oids_size = 0;
118char *label; 122char *label;
@@ -153,6 +157,10 @@ double *previous_value;
153size_t previous_size = OID_COUNT_STEP; 157size_t previous_size = OID_COUNT_STEP;
154int perf_labels = 1; 158int perf_labels = 1;
155char* ip_version = ""; 159char* ip_version = "";
160double multiplier = 1.0;
161char *fmtstr = "";
162char buffer[DEFAULT_BUFFER_SIZE];
163bool ignore_mib_parsing_errors = false;
156 164
157static char *fix_snmp_range(char *th) 165static char *fix_snmp_range(char *th)
158{ 166{
@@ -300,42 +308,55 @@ main (int argc, char **argv)
300 } 308 }
301 309
302 /* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */ 310 /* 10 arguments to pass before context and authpriv options + 1 for host and numoids. Add one for terminating NULL */
303 command_line = calloc (10 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *)); 311
304 command_line[0] = snmpcmd; 312 unsigned index = 0;
305 command_line[1] = strdup ("-Le"); 313 command_line = calloc (11 + numcontext + numauthpriv + 1 + numoids + 1, sizeof (char *));
306 command_line[2] = strdup ("-t"); 314
307 xasprintf (&command_line[3], "%d", timeout_interval); 315 command_line[index++] = snmpcmd;
308 command_line[4] = strdup ("-r"); 316 command_line[index++] = strdup ("-Le");
309 xasprintf (&command_line[5], "%d", retries); 317 command_line[index++] = strdup ("-t");
310 command_line[6] = strdup ("-m"); 318 xasprintf (&command_line[index++], "%d", timeout_interval);
311 command_line[7] = strdup (miblist); 319 command_line[index++] = strdup ("-r");
312 command_line[8] = "-v"; 320 xasprintf (&command_line[index++], "%d", retries);
313 command_line[9] = strdup (proto); 321 command_line[index++] = strdup ("-m");
322 command_line[index++] = strdup (miblist);
323 command_line[index++] = "-v";
324 command_line[index++] = strdup (proto);
325
326 xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s",
327 snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto);
328
329 if (ignore_mib_parsing_errors) {
330 command_line[index++] = "-Pe";
331 xasprintf(&cl_hidden_auth, "%s -Pe", cl_hidden_auth);
332 }
333
314 334
315 for (i = 0; i < numcontext; i++) { 335 for (i = 0; i < numcontext; i++) {
316 command_line[10 + i] = contextargs[i]; 336 command_line[index++] = contextargs[i];
317 } 337 }
318 338
319 for (i = 0; i < numauthpriv; i++) { 339 for (i = 0; i < numauthpriv; i++) {
320 command_line[10 + numcontext + i] = authpriv[i]; 340 command_line[index++] = authpriv[i];
321 } 341 }
322 342
323 xasprintf (&command_line[10 + numcontext + numauthpriv], "%s:%s", server_address, port); 343 xasprintf (&command_line[index++], "%s:%s", server_address, port);
324 344
325 /* This is just for display purposes, so it can remain a string */ 345 xasprintf(&cl_hidden_auth, "%s [context] [authpriv] %s:%s",
326 xasprintf(&cl_hidden_auth, "%s -Le -t %d -r %d -m %s -v %s %s %s %s:%s", 346 cl_hidden_auth,
327 snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[context]", "[authpriv]", 347 server_address,
328 server_address, port); 348 port);
329 349
330 for (i = 0; i < numoids; i++) { 350 for (i = 0; i < numoids; i++) {
331 command_line[10 + numcontext + numauthpriv + 1 + i] = oids[i]; 351 command_line[index++] = oids[i];
332 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]); 352 xasprintf(&cl_hidden_auth, "%s %s", cl_hidden_auth, oids[i]);
333 } 353 }
334 354
335 command_line[10 + numcontext + numauthpriv + 1 + numoids] = NULL; 355 command_line[index++] = NULL;
336 356
337 if (verbose) 357 if (verbose) {
338 printf ("%s\n", cl_hidden_auth); 358 printf ("%s\n", cl_hidden_auth);
359 }
339 360
340 /* Set signal handling and alarm */ 361 /* Set signal handling and alarm */
341 if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) { 362 if (signal (SIGALRM, runcmd_timeout_alarm_handler) == SIG_ERR) {
@@ -375,7 +396,7 @@ main (int argc, char **argv)
375 } 396 }
376 } 397 }
377 398
378 for (line=0, i=0; line < chld_out.lines; line++, i++) { 399 for (line=0, i=0; line < chld_out.lines && i < numoids ; line++, i++) {
379 if(calculate_rate) 400 if(calculate_rate)
380 conv = "%.10g"; 401 conv = "%.10g";
381 else 402 else
@@ -397,15 +418,15 @@ main (int argc, char **argv)
397 is_counter=0; 418 is_counter=0;
398 /* We strip out the datatype indicator for PHBs */ 419 /* We strip out the datatype indicator for PHBs */
399 if (strstr (response, "Gauge: ")) { 420 if (strstr (response, "Gauge: ")) {
400 show = strstr (response, "Gauge: ") + 7; 421 show = multiply (strstr (response, "Gauge: ") + 7);
401 } 422 }
402 else if (strstr (response, "Gauge32: ")) { 423 else if (strstr (response, "Gauge32: ")) {
403 show = strstr (response, "Gauge32: ") + 9; 424 show = multiply (strstr (response, "Gauge32: ") + 9);
404 } 425 }
405 else if (strstr (response, "Counter32: ")) { 426 else if (strstr (response, "Counter32: ")) {
406 show = strstr (response, "Counter32: ") + 11; 427 show = strstr (response, "Counter32: ") + 11;
407 is_counter=1; 428 is_counter=1;
408 if(!calculate_rate) 429 if(!calculate_rate)
409 strcpy(type, "c"); 430 strcpy(type, "c");
410 } 431 }
411 else if (strstr (response, "Counter64: ")) { 432 else if (strstr (response, "Counter64: ")) {
@@ -415,7 +436,10 @@ main (int argc, char **argv)
415 strcpy(type, "c"); 436 strcpy(type, "c");
416 } 437 }
417 else if (strstr (response, "INTEGER: ")) { 438 else if (strstr (response, "INTEGER: ")) {
418 show = strstr (response, "INTEGER: ") + 9; 439 show = multiply (strstr (response, "INTEGER: ") + 9);
440 if (fmtstr != "") {
441 conv = fmtstr;
442 }
419 } 443 }
420 else if (strstr (response, "OID: ")) { 444 else if (strstr (response, "OID: ")) {
421 show = strstr (response, "OID: ") + 5; 445 show = strstr (response, "OID: ") + 5;
@@ -468,9 +492,20 @@ main (int argc, char **argv)
468 /* Process this block for numeric comparisons */ 492 /* Process this block for numeric comparisons */
469 /* Make some special values,like Timeticks numeric only if a threshold is defined */ 493 /* Make some special values,like Timeticks numeric only if a threshold is defined */
470 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) { 494 if (thlds[i]->warning || thlds[i]->critical || calculate_rate) {
495 if (verbose > 2) {
496 print_thresholds(" thresholds", thlds[i]);
497 }
471 ptr = strpbrk (show, "-0123456789"); 498 ptr = strpbrk (show, "-0123456789");
472 if (ptr == NULL) 499 if (ptr == NULL){
473 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show); 500 if (nulloid == 3)
501 die (STATE_UNKNOWN,_("No valid data returned (%s)\n"), show);
502 else if (nulloid == 0)
503 die (STATE_OK,_("No valid data returned (%s)\n"), show);
504 else if (nulloid == 1)
505 die (STATE_WARNING,_("No valid data returned (%s)\n"), show);
506 else if (nulloid == 2)
507 die (STATE_CRITICAL,_("No valid data returned (%s)\n"), show);
508 }
474 while (i >= response_size) { 509 while (i >= response_size) {
475 response_size += OID_COUNT_STEP; 510 response_size += OID_COUNT_STEP;
476 response_value = realloc(response_value, response_size * sizeof(*response_value)); 511 response_value = realloc(response_value, response_size * sizeof(*response_value));
@@ -581,14 +616,16 @@ main (int argc, char **argv)
581 616
582 if (warning_thresholds) { 617 if (warning_thresholds) {
583 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 618 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
584 strncat(perfstr, warning_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 619 if(thlds[i]->warning && thlds[i]->warning->text)
620 strncat(perfstr, thlds[i]->warning->text, sizeof(perfstr)-strlen(perfstr)-1);
585 } 621 }
586 622
587 if (critical_thresholds) { 623 if (critical_thresholds) {
588 if (!warning_thresholds) 624 if (!warning_thresholds)
589 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 625 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
590 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1); 626 strncat(perfstr, ";", sizeof(perfstr)-strlen(perfstr)-1);
591 strncat(perfstr, critical_thresholds, sizeof(perfstr)-strlen(perfstr)-1); 627 if(thlds[i]->critical && thlds[i]->critical->text)
628 strncat(perfstr, thlds[i]->critical->text, sizeof(perfstr)-strlen(perfstr)-1);
592 } 629 }
593 630
594 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1); 631 strncat(perfstr, " ", sizeof(perfstr)-strlen(perfstr)-1);
@@ -602,7 +639,7 @@ main (int argc, char **argv)
602 state_string=malloc(string_length); 639 state_string=malloc(string_length);
603 if(state_string==NULL) 640 if(state_string==NULL)
604 die(STATE_UNKNOWN, _("Cannot malloc")); 641 die(STATE_UNKNOWN, _("Cannot malloc"));
605 642
606 current_length=0; 643 current_length=0;
607 for(i=0; i<total_oids; i++) { 644 for(i=0; i<total_oids; i++) {
608 xasprintf(&temp_string,"%.0f",response_value[i]); 645 xasprintf(&temp_string,"%.0f",response_value[i]);
@@ -624,7 +661,7 @@ main (int argc, char **argv)
624 state_string[--current_length]='\0'; 661 state_string[--current_length]='\0';
625 if (verbose > 2) 662 if (verbose > 2)
626 printf("State string=%s\n",state_string); 663 printf("State string=%s\n",state_string);
627 664
628 /* This is not strictly the same as time now, but any subtle variations will cancel out */ 665 /* This is not strictly the same as time now, but any subtle variations will cancel out */
629 np_state_write_string(current_time, state_string ); 666 np_state_write_string(current_time, state_string );
630 if(previous_state==NULL) { 667 if(previous_state==NULL) {
@@ -656,6 +693,7 @@ process_arguments (int argc, char **argv)
656 {"oid", required_argument, 0, 'o'}, 693 {"oid", required_argument, 0, 'o'},
657 {"object", required_argument, 0, 'o'}, 694 {"object", required_argument, 0, 'o'},
658 {"delimiter", required_argument, 0, 'd'}, 695 {"delimiter", required_argument, 0, 'd'},
696 {"nulloid", required_argument, 0, 'z'},
659 {"output-delimiter", required_argument, 0, 'D'}, 697 {"output-delimiter", required_argument, 0, 'D'},
660 {"string", required_argument, 0, 's'}, 698 {"string", required_argument, 0, 's'},
661 {"timeout", required_argument, 0, 't'}, 699 {"timeout", required_argument, 0, 't'},
@@ -683,6 +721,9 @@ process_arguments (int argc, char **argv)
683 {"perf-oids", no_argument, 0, 'O'}, 721 {"perf-oids", no_argument, 0, 'O'},
684 {"ipv4", no_argument, 0, '4'}, 722 {"ipv4", no_argument, 0, '4'},
685 {"ipv6", no_argument, 0, '6'}, 723 {"ipv6", no_argument, 0, '6'},
724 {"multiplier", required_argument, 0, 'M'},
725 {"fmtstr", required_argument, 0, 'f'},
726 {"ignore-mib-parsing-errors", no_argument, false, L_IGNORE_MIB_PARSING_ERRORS},
686 {0, 0, 0, 0} 727 {0, 0, 0, 0}
687 }; 728 };
688 729
@@ -700,7 +741,7 @@ process_arguments (int argc, char **argv)
700 } 741 }
701 742
702 while (1) { 743 while (1) {
703 c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:", 744 c = getopt_long (argc, argv, "nhvVO46t:c:w:H:C:o:e:E:d:D:s:t:R:r:l:u:p:m:P:N:L:U:a:x:A:X:M:f:z:",
704 longopts, &option); 745 longopts, &option);
705 746
706 if (c == -1 || c == EOF) 747 if (c == -1 || c == EOF)
@@ -811,6 +852,12 @@ process_arguments (int argc, char **argv)
811 eval_method[j+1] |= CRIT_PRESENT; 852 eval_method[j+1] |= CRIT_PRESENT;
812 } 853 }
813 break; 854 break;
855 case 'z': /* Null OID Return Check */
856 if (!is_integer (optarg))
857 usage2 (_("Exit status must be a positive integer"), optarg);
858 else
859 nulloid = atoi(optarg);
860 break;
814 case 's': /* string or substring */ 861 case 's': /* string or substring */
815 strncpy (string_value, optarg, sizeof (string_value) - 1); 862 strncpy (string_value, optarg, sizeof (string_value) - 1);
816 string_value[sizeof (string_value) - 1] = 0; 863 string_value[sizeof (string_value) - 1] = 0;
@@ -824,6 +871,7 @@ process_arguments (int argc, char **argv)
824 break; 871 break;
825 case 'R': /* regex */ 872 case 'R': /* regex */
826 cflags = REG_ICASE; 873 cflags = REG_ICASE;
874 // fall through
827 case 'r': /* regex */ 875 case 'r': /* regex */
828 cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; 876 cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
829 strncpy (regex_expect, optarg, sizeof (regex_expect) - 1); 877 strncpy (regex_expect, optarg, sizeof (regex_expect) - 1);
@@ -932,6 +980,18 @@ process_arguments (int argc, char **argv)
932 if(verbose>2) 980 if(verbose>2)
933 printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n"); 981 printf("IPv6 detected! Will pass \"udp6:\" to snmpget.\n");
934 break; 982 break;
983 case 'M':
984 if ( strspn( optarg, "0123456789.," ) == strlen( optarg ) ) {
985 multiplier=strtod(optarg,NULL);
986 }
987 break;
988 case 'f':
989 if (multiplier != 1.0) {
990 fmtstr=optarg;
991 }
992 break;
993 case L_IGNORE_MIB_PARSING_ERRORS:
994 ignore_mib_parsing_errors = true;
935 } 995 }
936 } 996 }
937 997
@@ -1001,7 +1061,7 @@ validate_arguments ()
1001 contextargs[0] = strdup ("-n"); 1061 contextargs[0] = strdup ("-n");
1002 contextargs[1] = strdup (context); 1062 contextargs[1] = strdup (context);
1003 } 1063 }
1004 1064
1005 if (seclevel == NULL) 1065 if (seclevel == NULL)
1006 xasprintf(&seclevel, "noAuthNoPriv"); 1066 xasprintf(&seclevel, "noAuthNoPriv");
1007 1067
@@ -1122,6 +1182,44 @@ nextarg (char *str)
1122 1182
1123 1183
1124 1184
1185/* multiply result (values 0 < n < 1 work as divider) */
1186char *
1187multiply (char *str)
1188{
1189 char *endptr;
1190 double val;
1191 char *conv = "%f";
1192
1193 if(multiplier == 1)
1194 return(str);
1195
1196 if(verbose>2)
1197 printf(" multiply input: %s\n", str);
1198
1199 val = strtod (str, &endptr);
1200 if ((val == 0.0) && (endptr == str)) {
1201 die(STATE_UNKNOWN, _("multiplier set (%.1f), but input is not a number: %s"), multiplier, str);
1202 }
1203
1204 if(verbose>2)
1205 printf(" multiply extracted double: %f\n", val);
1206 val *= multiplier;
1207 if (fmtstr != "") {
1208 conv = fmtstr;
1209 }
1210 if (val == (int)val) {
1211 snprintf(buffer, DEFAULT_BUFFER_SIZE, "%.0f", val);
1212 } else {
1213 if(verbose>2)
1214 printf(" multiply using format: %s\n", conv);
1215 snprintf(buffer, DEFAULT_BUFFER_SIZE, conv, val);
1216 }
1217 if(verbose>2)
1218 printf(" multiply result: %s\n", buffer);
1219 return buffer;
1220}
1221
1222
1125void 1223void
1126print_help (void) 1224print_help (void)
1127{ 1225{
@@ -1161,7 +1259,7 @@ print_help (void)
1161 printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY); 1259 printf ("(%s \"%s\")\n", _("default is") ,DEFAULT_COMMUNITY);
1162 printf (" %s\n", "-U, --secname=USERNAME"); 1260 printf (" %s\n", "-U, --secname=USERNAME");
1163 printf (" %s\n", _("SNMPv3 username")); 1261 printf (" %s\n", _("SNMPv3 username"));
1164 printf (" %s\n", "-A, --authpassword=PASSWORD"); 1262 printf (" %s\n", "-A, --authpasswd=PASSWORD");
1165 printf (" %s\n", _("SNMPv3 authentication password")); 1263 printf (" %s\n", _("SNMPv3 authentication password"));
1166 printf (" %s\n", "-X, --privpasswd=PASSWORD"); 1264 printf (" %s\n", "-X, --privpasswd=PASSWORD");
1167 printf (" %s\n", _("SNMPv3 privacy password")); 1265 printf (" %s\n", _("SNMPv3 privacy password"));
@@ -1176,6 +1274,14 @@ print_help (void)
1176 printf (" %s \"%s\"\n", _("Delimiter to use when parsing returned data. Default is"), DEFAULT_DELIMITER); 1274 printf (" %s \"%s\"\n", _("Delimiter to use when parsing returned data. Default is"), DEFAULT_DELIMITER);
1177 printf (" %s\n", _("Any data on the right hand side of the delimiter is considered")); 1275 printf (" %s\n", _("Any data on the right hand side of the delimiter is considered"));
1178 printf (" %s\n", _("to be the data that should be used in the evaluation.")); 1276 printf (" %s\n", _("to be the data that should be used in the evaluation."));
1277 printf (" %s\n", "-z, --nulloid=#");
1278 printf (" %s\n", _("If the check returns a 0 length string or NULL value"));
1279 printf (" %s\n", _("This option allows you to choose what status you want it to exit"));
1280 printf (" %s\n", _("Excluding this option renders the default exit of 3(STATE_UNKNOWN)"));
1281 printf (" %s\n", _("0 = OK"));
1282 printf (" %s\n", _("1 = WARNING"));
1283 printf (" %s\n", _("2 = CRITICAL"));
1284 printf (" %s\n", _("3 = UNKNOWN"));
1179 1285
1180 /* Tests Against Integers */ 1286 /* Tests Against Integers */
1181 printf (" %s\n", "-w, --warning=THRESHOLD(s)"); 1287 printf (" %s\n", "-w, --warning=THRESHOLD(s)");
@@ -1187,7 +1293,7 @@ print_help (void)
1187 printf (" %s\n", "--rate-multiplier"); 1293 printf (" %s\n", "--rate-multiplier");
1188 printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute")); 1294 printf (" %s\n", _("Converts rate per second. For example, set to 60 to convert to per minute"));
1189 printf (" %s\n", "--offset=OFFSET"); 1295 printf (" %s\n", "--offset=OFFSET");
1190 printf (" %s\n", _("Add/substract the specified OFFSET to numeric sensor data")); 1296 printf (" %s\n", _("Add/subtract the specified OFFSET to numeric sensor data"));
1191 1297
1192 /* Tests Against Strings */ 1298 /* Tests Against Strings */
1193 printf (" %s\n", "-s, --string=STRING"); 1299 printf (" %s\n", "-s, --string=STRING");
@@ -1206,6 +1312,10 @@ print_help (void)
1206 printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.').")); 1312 printf (" %s\n", _("Units label(s) for output data (e.g., 'sec.')."));
1207 printf (" %s\n", "-D, --output-delimiter=STRING"); 1313 printf (" %s\n", "-D, --output-delimiter=STRING");
1208 printf (" %s\n", _("Separates output on multiple OID requests")); 1314 printf (" %s\n", _("Separates output on multiple OID requests"));
1315 printf (" %s\n", "-M, --multiplier=FLOAT");
1316 printf (" %s\n", _("Multiplies current value, 0 < n < 1 works as divider, defaults to 1"));
1317 printf (" %s\n", "-f, --fmtstr=STRING");
1318 printf (" %s\n", _("C-style format string for float values (see option -M)"));
1209 1319
1210 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1320 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1211 printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5")); 1321 printf (" %s\n", _("NOTE the final timeout value is calculated using this formula: timeout_interval * retries + 5"));
@@ -1215,6 +1325,9 @@ print_help (void)
1215 printf (" %s\n", "-O, --perf-oids"); 1325 printf (" %s\n", "-O, --perf-oids");
1216 printf (" %s\n", _("Label performance data with OIDs instead of --label's")); 1326 printf (" %s\n", _("Label performance data with OIDs instead of --label's"));
1217 1327
1328 printf (" %s\n", "--ignore-mib-parsing-errors");
1329 printf (" %s\n", _("Tell snmpget to not print errors encountered when parsing MIB files"));
1330
1218 printf (UT_VERBOSE); 1331 printf (UT_VERBOSE);
1219 1332
1220 printf ("\n"); 1333 printf ("\n");
@@ -1258,4 +1371,5 @@ print_usage (void)
1258 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n"); 1371 printf ("[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]\n");
1259 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n"); 1372 printf ("[-m miblist] [-P snmp version] [-N context] [-L seclevel] [-U secname]\n");
1260 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n"); 1373 printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-4|6]\n");
1374 printf ("[-M multiplier [-f format]]\n");
1261} 1375}
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 685c2cc..cd965e3 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -1,30 +1,30 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_swap plugin 3* Monitoring check_swap plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
7* Copyright (c) 2000-2007 Monitoring Plugins Development Team 7* Copyright (c) 2000-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_swap plugin 11* This file contains the check_swap plugin
12* 12*
13* 13*
14* This program is free software: you can redistribute it and/or modify 14* This program is free software: you can redistribute it and/or modify
15* it under the terms of the GNU General Public License as published by 15* it under the terms of the GNU General Public License as published by
16* the Free Software Foundation, either version 3 of the License, or 16* the Free Software Foundation, either version 3 of the License, or
17* (at your option) any later version. 17* (at your option) any later version.
18* 18*
19* This program is distributed in the hope that it will be useful, 19* This program is distributed in the hope that it will be useful,
20* but WITHOUT ANY WARRANTY; without even the implied warranty of 20* but WITHOUT ANY WARRANTY; without even the implied warranty of
21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22* GNU General Public License for more details. 22* GNU General Public License for more details.
23* 23*
24* You should have received a copy of the GNU General Public License 24* You should have received a copy of the GNU General Public License
25* along with this program. If not, see <http://www.gnu.org/licenses/>. 25* along with this program. If not, see <http://www.gnu.org/licenses/>.
26* 26*
27* 27*
28*****************************************************************************/ 28*****************************************************************************/
29 29
30const char *progname = "check_swap"; 30const char *progname = "check_swap";
@@ -34,9 +34,6 @@ const char *email = "devel@monitoring-plugins.org";
34#include "common.h" 34#include "common.h"
35#include "popen.h" 35#include "popen.h"
36#include "utils.h" 36#include "utils.h"
37#include <string.h>
38#include <math.h>
39#include <libintl.h>
40 37
41#ifdef HAVE_DECL_SWAPCTL 38#ifdef HAVE_DECL_SWAPCTL
42# ifdef HAVE_SYS_PARAM_H 39# ifdef HAVE_SYS_PARAM_H
@@ -142,14 +139,15 @@ main (int argc, char **argv)
142 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb)); 139 percent = 100 * (((double) dskused_mb) / ((double) dsktotal_mb));
143 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb)); 140 result = max_state (result, check_swap (dskfree_mb, dsktotal_mb));
144 if (verbose) 141 if (verbose)
145 xasprintf (&status, "%s [%.0f (%d%%)]", status, dskfree_mb, 100 - percent); 142 xasprintf (&status, "%s [%lu (%d%%)]", status, dskfree_mb, 100 - percent);
146 } 143 }
147 } 144 }
145
148 /* 146 /*
149 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" 147 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123"
150 * This format exists at least on Debian Linux with a 5.* kernel 148 * This format exists at least on Debian Linux with a 5.* kernel
151 */ 149 */
152 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFre]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) { 150 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) {
153 if (verbose >= 3) { 151 if (verbose >= 3) {
154 printf("Got %s with %lu\n", str, tmp_KB); 152 printf("Got %s with %lu\n", str, tmp_KB);
155 } 153 }
@@ -158,7 +156,10 @@ main (int argc, char **argv)
158 dsktotal_mb = tmp_KB / 1024; 156 dsktotal_mb = tmp_KB / 1024;
159 } 157 }
160 else if (strcmp ("Free", str) == 0) { 158 else if (strcmp ("Free", str) == 0) {
161 dskfree_mb = tmp_KB / 1024; 159 dskfree_mb = dskfree_mb + tmp_KB / 1024;
160 }
161 else if (strcmp ("Cached", str) == 0) {
162 dskfree_mb = dskfree_mb + tmp_KB / 1024;
162 } 163 }
163 } 164 }
164 } 165 }
@@ -177,7 +178,7 @@ main (int argc, char **argv)
177# ifdef _AIX 178# ifdef _AIX
178 if (!allswaps) { 179 if (!allswaps) {
179 xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s"); 180 xasprintf(&swap_command, "%s", "/usr/sbin/lsps -s");
180 xasprintf(&swap_format, "%s", "%f%*s %f"); 181 xasprintf(&swap_format, "%s", "%lu%*s %lu");
181 conv_factor = 1; 182 conv_factor = 1;
182 } 183 }
183# endif 184# endif
@@ -204,9 +205,9 @@ main (int argc, char **argv)
204 temp_buffer = strtok (input_buffer, " \n"); 205 temp_buffer = strtok (input_buffer, " \n");
205 while (temp_buffer) { 206 while (temp_buffer) {
206 if (strstr (temp_buffer, "blocks")) 207 if (strstr (temp_buffer, "blocks"))
207 sprintf (str, "%s %s", str, "%f"); 208 sprintf (str, "%s %s", str, "%lu");
208 else if (strstr (temp_buffer, "dskfree")) 209 else if (strstr (temp_buffer, "dskfree"))
209 sprintf (str, "%s %s", str, "%f"); 210 sprintf (str, "%s %s", str, "%lu");
210 else 211 else
211 sprintf (str, "%s %s", str, "%*s"); 212 sprintf (str, "%s %s", str, "%*s");
212 temp_buffer = strtok (NULL, " \n"); 213 temp_buffer = strtok (NULL, " \n");
@@ -385,7 +386,7 @@ main (int argc, char **argv)
385 TRUE, warn_print, 386 TRUE, warn_print,
386 TRUE, crit_print, 387 TRUE, crit_print,
387 TRUE, 0, 388 TRUE, 0,
388 TRUE, (long) total_swap_mb)); 389 TRUE, (long) total_swap_mb * 1024 * 1024));
389 390
390 return result; 391 return result;
391} 392}
@@ -406,7 +407,6 @@ check_swap(float free_swap_mb, float total_swap_mb)
406 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100; 407 uint64_t usage_percentage = ((total_swap_mb - free_swap_mb) / total_swap_mb) * 100;
407 408
408 if (crit.is_percentage && 409 if (crit.is_percentage &&
409 usage_percentage >= 0 &&
410 crit.value != 0 && 410 crit.value != 0 &&
411 usage_percentage >= (100 - crit.value)) 411 usage_percentage >= (100 - crit.value))
412 { 412 {
@@ -414,7 +414,6 @@ check_swap(float free_swap_mb, float total_swap_mb)
414 } 414 }
415 415
416 if (warn.is_percentage && 416 if (warn.is_percentage &&
417 usage_percentage >= 0 &&
418 warn.value != 0 && 417 warn.value != 0 &&
419 usage_percentage >= (100 - warn.value)) 418 usage_percentage >= (100 - warn.value))
420 { 419 {
@@ -471,10 +470,9 @@ process_arguments (int argc, char **argv)
471 if (is_uint64(optarg, &warn.value)) { 470 if (is_uint64(optarg, &warn.value)) {
472 if (warn.value > 100) { 471 if (warn.value > 100) {
473 usage4 (_("Warning threshold percentage must be <= 100!")); 472 usage4 (_("Warning threshold percentage must be <= 100!"));
474 } else {
475 break;
476 } 473 }
477 } 474 }
475 break;
478 } else { 476 } else {
479 /* It's Bytes */ 477 /* It's Bytes */
480 warn.is_percentage = 0; 478 warn.is_percentage = 0;
@@ -502,10 +500,9 @@ process_arguments (int argc, char **argv)
502 if (is_uint64(optarg, &crit.value)) { 500 if (is_uint64(optarg, &crit.value)) {
503 if (crit.value> 100) { 501 if (crit.value> 100) {
504 usage4 (_("Critical threshold percentage must be <= 100!")); 502 usage4 (_("Critical threshold percentage must be <= 100!"));
505 } else {
506 break;
507 } 503 }
508 } 504 }
505 break;
509 } else { 506 } else {
510 /* It's Bytes */ 507 /* It's Bytes */
511 crit.is_percentage = 0; 508 crit.is_percentage = 0;
@@ -523,6 +520,7 @@ process_arguments (int argc, char **argv)
523 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) { 520 if ((no_swap_state = mp_translate_state(optarg)) == ERROR) {
524 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3).")); 521 usage4 (_("no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-3)."));
525 } 522 }
523 break;
526 case 'v': /* verbose */ 524 case 'v': /* verbose */
527 verbose++; 525 verbose++;
528 break; 526 break;
@@ -552,9 +550,12 @@ validate_arguments (void)
552 if (warn.value == 0 && crit.value == 0) { 550 if (warn.value == 0 && crit.value == 0) {
553 return ERROR; 551 return ERROR;
554 } 552 }
555 else if (warn.value < crit.value) { 553 else if ((warn.is_percentage == crit.is_percentage) && (warn.value < crit.value)) {
556 usage4 554 /* This is NOT triggered if warn and crit are different units, e.g warn is percentage
557 (_("Warning should be more than critical")); 555 * and crit is absolute. We cannot determine the condition at this point since we
556 * dont know the value of total swap yet
557 */
558 usage4(_("Warning should be more than critical"));
558 } 559 }
559 return OK; 560 return OK;
560} 561}
@@ -570,7 +571,7 @@ print_help (void)
570 571
571 printf ("%s\n", _("Check swap space on local machine.")); 572 printf ("%s\n", _("Check swap space on local machine."));
572 573
573 printf ("\n\n"); 574 printf ("\n\n");
574 575
575 print_usage (); 576 print_usage ();
576 577
@@ -578,23 +579,23 @@ print_help (void)
578 printf (UT_EXTRA_OPTS); 579 printf (UT_EXTRA_OPTS);
579 580
580 printf (" %s\n", "-w, --warning=INTEGER"); 581 printf (" %s\n", "-w, --warning=INTEGER");
581 printf (" %s\n", _("Exit with WARNING status if less than INTEGER bytes of swap space are free")); 582 printf (" %s\n", _("Exit with WARNING status if less than INTEGER bytes of swap space are free"));
582 printf (" %s\n", "-w, --warning=PERCENT%%"); 583 printf (" %s\n", "-w, --warning=PERCENT%");
583 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of swap space is free")); 584 printf (" %s\n", _("Exit with WARNING status if less than PERCENT of swap space is free"));
584 printf (" %s\n", "-c, --critical=INTEGER"); 585 printf (" %s\n", "-c, --critical=INTEGER");
585 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free")); 586 printf (" %s\n", _("Exit with CRITICAL status if less than INTEGER bytes of swap space are free"));
586 printf (" %s\n", "-c, --critical=PERCENT%%"); 587 printf (" %s\n", "-c, --critical=PERCENT%");
587 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free")); 588 printf (" %s\n", _("Exit with CRITICAL status if less than PERCENT of swap space is free"));
588 printf (" %s\n", "-a, --allswaps"); 589 printf (" %s\n", "-a, --allswaps");
589 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one")); 590 printf (" %s\n", _("Conduct comparisons for all swap partitions, one by one"));
590 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>"); 591 printf (" %s\n", "-n, --no-swap=<ok|warning|critical|unknown>");
591 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state)); 592 printf (" %s %s\n", _("Resulting state when there is no swap regardless of thresholds. Default:"), state_text(no_swap_state));
592 printf (UT_VERBOSE); 593 printf (UT_VERBOSE);
593 594
594 printf ("\n"); 595 printf ("\n");
595 printf ("%s\n", _("Notes:")); 596 printf ("%s\n", _("Notes:"));
596 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked.")); 597 printf (" %s\n", _("Both INTEGER and PERCENT thresholds can be specified, they are all checked."));
597 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s.")); 598 printf (" %s\n", _("On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."));
598 599
599 printf (UT_SUPPORT); 600 printf (UT_SUPPORT);
600} 601}
@@ -604,6 +605,6 @@ void
604print_usage (void) 605print_usage (void)
605{ 606{
606 printf ("%s\n", _("Usage:")); 607 printf ("%s\n", _("Usage:"));
607 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname); 608 printf (" %s [-av] -w <percent_free>%% -c <percent_free>%%\n",progname);
608 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n"); 609 printf (" -w <bytes_free> -c <bytes_free> [-n <state>]\n");
609} 610}
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index 1365b9c..1d307cf 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -128,7 +128,7 @@ main (int argc, char **argv)
128 SERVICE[i] = toupper(SERVICE[i]); 128 SERVICE[i] = toupper(SERVICE[i]);
129 } 129 }
130 130
131 /* set up a resonable buffer at first (will be realloc()'ed if 131 /* set up a reasonable buffer at first (will be realloc()'ed if
132 * user specifies other options) */ 132 * user specifies other options) */
133 server_expect = calloc(sizeof(char *), 2); 133 server_expect = calloc(sizeof(char *), 2);
134 134
diff --git a/plugins/check_ups.c b/plugins/check_ups.c
index e9e56a5..68737c4 100644
--- a/plugins/check_ups.c
+++ b/plugins/check_ups.c
@@ -89,7 +89,7 @@ char *ups_status;
89int temp_output_c = 0; 89int temp_output_c = 0;
90 90
91int determine_status (void); 91int determine_status (void);
92int get_ups_variable (const char *, char *, size_t); 92int get_ups_variable (const char *, char *);
93 93
94int process_arguments (int, char **); 94int process_arguments (int, char **);
95int validate_arguments (void); 95int validate_arguments (void);
@@ -189,7 +189,7 @@ main (int argc, char **argv)
189 } 189 }
190 190
191 /* get the ups utility voltage if possible */ 191 /* get the ups utility voltage if possible */
192 res=get_ups_variable ("input.voltage", temp_buffer, sizeof (temp_buffer)); 192 res=get_ups_variable ("input.voltage", temp_buffer);
193 if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY; 193 if (res == NOSUCHVAR) supported_options &= ~UPS_UTILITY;
194 else if (res != OK) 194 else if (res != OK)
195 return STATE_CRITICAL; 195 return STATE_CRITICAL;
@@ -224,7 +224,7 @@ main (int argc, char **argv)
224 } 224 }
225 225
226 /* get the ups battery percent if possible */ 226 /* get the ups battery percent if possible */
227 res=get_ups_variable ("battery.charge", temp_buffer, sizeof (temp_buffer)); 227 res=get_ups_variable ("battery.charge", temp_buffer);
228 if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT; 228 if (res == NOSUCHVAR) supported_options &= ~UPS_BATTPCT;
229 else if ( res != OK) 229 else if ( res != OK)
230 return STATE_CRITICAL; 230 return STATE_CRITICAL;
@@ -253,7 +253,7 @@ main (int argc, char **argv)
253 } 253 }
254 254
255 /* get the ups load percent if possible */ 255 /* get the ups load percent if possible */
256 res=get_ups_variable ("ups.load", temp_buffer, sizeof (temp_buffer)); 256 res=get_ups_variable ("ups.load", temp_buffer);
257 if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT; 257 if ( res == NOSUCHVAR ) supported_options &= ~UPS_LOADPCT;
258 else if ( res != OK) 258 else if ( res != OK)
259 return STATE_CRITICAL; 259 return STATE_CRITICAL;
@@ -282,7 +282,7 @@ main (int argc, char **argv)
282 } 282 }
283 283
284 /* get the ups temperature if possible */ 284 /* get the ups temperature if possible */
285 res=get_ups_variable ("ups.temperature", temp_buffer, sizeof (temp_buffer)); 285 res=get_ups_variable ("ups.temperature", temp_buffer);
286 if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP; 286 if ( res == NOSUCHVAR ) supported_options &= ~UPS_TEMP;
287 else if ( res != OK) 287 else if ( res != OK)
288 return STATE_CRITICAL; 288 return STATE_CRITICAL;
@@ -342,7 +342,7 @@ determine_status (void)
342 char *ptr; 342 char *ptr;
343 int res; 343 int res;
344 344
345 res=get_ups_variable ("ups.status", recv_buffer, sizeof (recv_buffer)); 345 res=get_ups_variable ("ups.status", recv_buffer);
346 if (res == NOSUCHVAR) return OK; 346 if (res == NOSUCHVAR) return OK;
347 if (res != STATE_OK) { 347 if (res != STATE_OK) {
348 printf ("%s\n", _("Invalid response received from host")); 348 printf ("%s\n", _("Invalid response received from host"));
@@ -388,7 +388,7 @@ determine_status (void)
388 388
389/* gets a variable value for a specific UPS */ 389/* gets a variable value for a specific UPS */
390int 390int
391get_ups_variable (const char *varname, char *buf, size_t buflen) 391get_ups_variable (const char *varname, char *buf)
392{ 392{
393 /* char command[MAX_INPUT_BUFFER]; */ 393 /* char command[MAX_INPUT_BUFFER]; */
394 char temp_buffer[MAX_INPUT_BUFFER]; 394 char temp_buffer[MAX_INPUT_BUFFER];
@@ -402,7 +402,10 @@ get_ups_variable (const char *varname, char *buf, size_t buflen)
402 402
403 /* create the command string to send to the UPS daemon */ 403 /* create the command string to send to the UPS daemon */
404 /* Add LOGOUT to avoid read failure logs */ 404 /* Add LOGOUT to avoid read failure logs */
405 sprintf (send_buffer, "GET VAR %s %s\nLOGOUT\n", ups_name, varname); 405 if (snprintf (send_buffer, sizeof(send_buffer), "GET VAR %s %s\nLOGOUT\n", ups_name, varname) >= sizeof(send_buffer)) {
406 printf("%s\n", _("UPS name to long for buffer"));
407 return ERROR;
408 }
406 409
407 /* send the command to the daemon and get a response back */ 410 /* send the command to the daemon and get a response back */
408 if (process_tcp_request 411 if (process_tcp_request
@@ -504,7 +507,7 @@ process_arguments (int argc, char **argv)
504 usage2 (_("Invalid hostname/address"), optarg); 507 usage2 (_("Invalid hostname/address"), optarg);
505 } 508 }
506 break; 509 break;
507 case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Farenheit) */ 510 case 'T': /* FIXME: to be improved (ie "-T C" for Celsius or "-T F" for Fahrenheit) */
508 temp_output_c = 1; 511 temp_output_c = 1;
509 break; 512 break;
510 case 'u': /* ups name */ 513 case 'u': /* ups name */
diff --git a/plugins/check_users.c b/plugins/check_users.c
index f6f4b36..2a9ee98 100644
--- a/plugins/check_users.c
+++ b/plugins/check_users.c
@@ -1,33 +1,33 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_users plugin 3* Monitoring check_users plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000-2012 Monitoring Plugins Development Team 6* Copyright (c) 2000-2012 Monitoring Plugins Development Team
7* 7*
8* Description: 8* Description:
9* 9*
10* This file contains the check_users plugin 10* This file contains the check_users plugin
11* 11*
12* This plugin checks the number of users currently logged in on the local 12* This plugin checks the number of users currently logged in on the local
13* system and generates an error if the number exceeds the thresholds 13* system and generates an error if the number exceeds the thresholds
14* specified. 14* specified.
15* 15*
16* 16*
17* This program is free software: you can redistribute it and/or modify 17* This program is free software: you can redistribute it and/or modify
18* it under the terms of the GNU General Public License as published by 18* it under the terms of the GNU General Public License as published by
19* the Free Software Foundation, either version 3 of the License, or 19* the Free Software Foundation, either version 3 of the License, or
20* (at your option) any later version. 20* (at your option) any later version.
21* 21*
22* This program is distributed in the hope that it will be useful, 22* This program is distributed in the hope that it will be useful,
23* but WITHOUT ANY WARRANTY; without even the implied warranty of 23* but WITHOUT ANY WARRANTY; without even the implied warranty of
24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25* GNU General Public License for more details. 25* GNU General Public License for more details.
26* 26*
27* You should have received a copy of the GNU General Public License 27* You should have received a copy of the GNU General Public License
28* along with this program. If not, see <http://www.gnu.org/licenses/>. 28* along with this program. If not, see <http://www.gnu.org/licenses/>.
29* 29*
30* 30*
31*****************************************************************************/ 31*****************************************************************************/
32 32
33const char *progname = "check_users"; 33const char *progname = "check_users";
@@ -48,6 +48,11 @@ const char *email = "devel@monitoring-plugins.org";
48# include "popen.h" 48# include "popen.h"
49#endif 49#endif
50 50
51#ifdef HAVE_LIBSYSTEMD
52#include <systemd/sd-daemon.h>
53#include <systemd/sd-login.h>
54#endif
55
51#define possibly_set(a,b) ((a) == 0 ? (b) : 0) 56#define possibly_set(a,b) ((a) == 0 ? (b) : 0)
52 57
53int process_arguments (int, char **); 58int process_arguments (int, char **);
@@ -85,6 +90,11 @@ main (int argc, char **argv)
85 90
86 users = 0; 91 users = 0;
87 92
93#ifdef HAVE_LIBSYSTEMD
94 if (sd_booted () > 0)
95 users = sd_get_sessions (NULL);
96 else {
97#endif
88#if HAVE_WTSAPI32_H 98#if HAVE_WTSAPI32_H
89 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 99 if (!WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
90 0, 1, &wtsinfo, &wtscount)) { 100 0, 1, &wtsinfo, &wtscount)) {
@@ -156,6 +166,9 @@ main (int argc, char **argv)
156 if (spclose (child_process)) 166 if (spclose (child_process))
157 result = possibly_set (result, STATE_UNKNOWN); 167 result = possibly_set (result, STATE_UNKNOWN);
158#endif 168#endif
169#ifdef HAVE_LIBSYSTEMD
170 }
171#endif
159 172
160 /* check the user count against warning and critical thresholds */ 173 /* check the user count against warning and critical thresholds */
161 result = get_status((double)users, thlds); 174 result = get_status((double)users, thlds);
@@ -163,7 +176,7 @@ main (int argc, char **argv)
163 if (result == STATE_UNKNOWN) 176 if (result == STATE_UNKNOWN)
164 printf ("%s\n", _("Unable to read output")); 177 printf ("%s\n", _("Unable to read output"));
165 else { 178 else {
166 printf (_("USERS %s - %d users currently logged in |%s\n"), 179 printf (_("USERS %s - %d users currently logged in |%s\n"),
167 state_text(result), users, 180 state_text(result), users,
168 sperfdata_int("users", users, "", warning_range, 181 sperfdata_int("users", users, "", warning_range,
169 critical_range, TRUE, 0, FALSE, 0)); 182 critical_range, TRUE, 0, FALSE, 0));
diff --git a/plugins/picohttpparser/picohttpparser.c b/plugins/picohttpparser/picohttpparser.c
index 74ccc3e..d0bfac6 100644
--- a/plugins/picohttpparser/picohttpparser.c
+++ b/plugins/picohttpparser/picohttpparser.c
@@ -242,7 +242,7 @@ static const char *is_complete(const char *buf, const char *buf_end, size_t last
242 } while (0) 242 } while (0)
243 243
244/* returned pointer is always within [buf, buf_end), or null */ 244/* returned pointer is always within [buf, buf_end), or null */
245static const char *parse_http_version(const char *buf, const char *buf_end, int *minor_version, int *ret) 245static const char *parse_http_version(const char *buf, const char *buf_end, int *major_version, int *minor_version, int *ret)
246{ 246{
247 /* we want at least [HTTP/1.<two chars>] to try to parse */ 247 /* we want at least [HTTP/1.<two chars>] to try to parse */
248 if (buf_end - buf < 9) { 248 if (buf_end - buf < 9) {
@@ -254,9 +254,13 @@ static const char *parse_http_version(const char *buf, const char *buf_end, int
254 EXPECT_CHAR_NO_CHECK('T'); 254 EXPECT_CHAR_NO_CHECK('T');
255 EXPECT_CHAR_NO_CHECK('P'); 255 EXPECT_CHAR_NO_CHECK('P');
256 EXPECT_CHAR_NO_CHECK('/'); 256 EXPECT_CHAR_NO_CHECK('/');
257 EXPECT_CHAR_NO_CHECK('1'); 257 PARSE_INT(major_version, 1);
258 EXPECT_CHAR_NO_CHECK('.'); 258 if (*major_version == 1) {
259 PARSE_INT(minor_version, 1); 259 EXPECT_CHAR_NO_CHECK('.');
260 PARSE_INT(minor_version, 1);
261 } else {
262 *minor_version = 0;
263 }
260 return buf; 264 return buf;
261} 265}
262 266
@@ -339,7 +343,7 @@ static const char *parse_headers(const char *buf, const char *buf_end, struct ph
339} 343}
340 344
341static const char *parse_request(const char *buf, const char *buf_end, const char **method, size_t *method_len, const char **path, 345static const char *parse_request(const char *buf, const char *buf_end, const char **method, size_t *method_len, const char **path,
342 size_t *path_len, int *minor_version, struct phr_header *headers, size_t *num_headers, 346 size_t *path_len, int *major_version, int *minor_version, struct phr_header *headers, size_t *num_headers,
343 size_t max_headers, int *ret) 347 size_t max_headers, int *ret)
344{ 348{
345 /* skip first empty line (some clients add CRLF after POST content) */ 349 /* skip first empty line (some clients add CRLF after POST content) */
@@ -364,7 +368,7 @@ static const char *parse_request(const char *buf, const char *buf_end, const cha
364 *ret = -1; 368 *ret = -1;
365 return NULL; 369 return NULL;
366 } 370 }
367 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) { 371 if ((buf = parse_http_version(buf, buf_end, major_version, minor_version, ret)) == NULL) {
368 return NULL; 372 return NULL;
369 } 373 }
370 if (*buf == '\015') { 374 if (*buf == '\015') {
@@ -381,7 +385,7 @@ static const char *parse_request(const char *buf, const char *buf_end, const cha
381} 385}
382 386
383int phr_parse_request(const char *buf_start, size_t len, const char **method, size_t *method_len, const char **path, 387int phr_parse_request(const char *buf_start, size_t len, const char **method, size_t *method_len, const char **path,
384 size_t *path_len, int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len) 388 size_t *path_len, int *major_version, int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len)
385{ 389{
386 const char *buf = buf_start, *buf_end = buf_start + len; 390 const char *buf = buf_start, *buf_end = buf_start + len;
387 size_t max_headers = *num_headers; 391 size_t max_headers = *num_headers;
@@ -391,16 +395,17 @@ int phr_parse_request(const char *buf_start, size_t len, const char **method, si
391 *method_len = 0; 395 *method_len = 0;
392 *path = NULL; 396 *path = NULL;
393 *path_len = 0; 397 *path_len = 0;
398 *major_version = -1;
394 *minor_version = -1; 399 *minor_version = -1;
395 *num_headers = 0; 400 *num_headers = 0;
396 401
397 /* if last_len != 0, check if the request is complete (a fast countermeasure 402 /* if last_len != 0, check if the request is complete (a fast countermeasure
398 againt slowloris */ 403 against slowloris */
399 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) { 404 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
400 return r; 405 return r;
401 } 406 }
402 407
403 if ((buf = parse_request(buf, buf_end, method, method_len, path, path_len, minor_version, headers, num_headers, max_headers, 408 if ((buf = parse_request(buf, buf_end, method, method_len, path, path_len, major_version, minor_version, headers, num_headers, max_headers,
404 &r)) == NULL) { 409 &r)) == NULL) {
405 return r; 410 return r;
406 } 411 }
@@ -408,11 +413,11 @@ int phr_parse_request(const char *buf_start, size_t len, const char **method, si
408 return (int)(buf - buf_start); 413 return (int)(buf - buf_start);
409} 414}
410 415
411static const char *parse_response(const char *buf, const char *buf_end, int *minor_version, int *status, const char **msg, 416static const char *parse_response(const char *buf, const char *buf_end, int *major_version, int *minor_version, int *status, const char **msg,
412 size_t *msg_len, struct phr_header *headers, size_t *num_headers, size_t max_headers, int *ret) 417 size_t *msg_len, struct phr_header *headers, size_t *num_headers, size_t max_headers, int *ret)
413{ 418{
414 /* parse "HTTP/1.x" */ 419 /* parse "HTTP/1.x" */
415 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) { 420 if ((buf = parse_http_version(buf, buf_end, major_version, minor_version, ret)) == NULL) {
416 return NULL; 421 return NULL;
417 } 422 }
418 /* skip space */ 423 /* skip space */
@@ -430,7 +435,7 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min
430 } 435 }
431 PARSE_INT_3(status); 436 PARSE_INT_3(status);
432 437
433 /* get message includig preceding space */ 438 /* get message including preceding space */
434 if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) { 439 if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) {
435 return NULL; 440 return NULL;
436 } 441 }
@@ -451,13 +456,14 @@ static const char *parse_response(const char *buf, const char *buf_end, int *min
451 return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret); 456 return parse_headers(buf, buf_end, headers, num_headers, max_headers, ret);
452} 457}
453 458
454int phr_parse_response(const char *buf_start, size_t len, int *minor_version, int *status, const char **msg, size_t *msg_len, 459int phr_parse_response(const char *buf_start, size_t len, int *major_version, int *minor_version, int *status, const char **msg, size_t *msg_len,
455 struct phr_header *headers, size_t *num_headers, size_t last_len) 460 struct phr_header *headers, size_t *num_headers, size_t last_len)
456{ 461{
457 const char *buf = buf_start, *buf_end = buf + len; 462 const char *buf = buf_start, *buf_end = buf + len;
458 size_t max_headers = *num_headers; 463 size_t max_headers = *num_headers;
459 int r; 464 int r;
460 465
466 *major_version = -1;
461 *minor_version = -1; 467 *minor_version = -1;
462 *status = 0; 468 *status = 0;
463 *msg = NULL; 469 *msg = NULL;
@@ -470,7 +476,7 @@ int phr_parse_response(const char *buf_start, size_t len, int *minor_version, in
470 return r; 476 return r;
471 } 477 }
472 478
473 if ((buf = parse_response(buf, buf_end, minor_version, status, msg, msg_len, headers, num_headers, max_headers, &r)) == NULL) { 479 if ((buf = parse_response(buf, buf_end, major_version, minor_version, status, msg, msg_len, headers, num_headers, max_headers, &r)) == NULL) {
474 return r; 480 return r;
475 } 481 }
476 482
diff --git a/plugins/picohttpparser/picohttpparser.h b/plugins/picohttpparser/picohttpparser.h
index 0849f84..8f13b36 100644
--- a/plugins/picohttpparser/picohttpparser.h
+++ b/plugins/picohttpparser/picohttpparser.h
@@ -49,10 +49,10 @@ struct phr_header {
49/* returns number of bytes consumed if successful, -2 if request is partial, 49/* returns number of bytes consumed if successful, -2 if request is partial,
50 * -1 if failed */ 50 * -1 if failed */
51int phr_parse_request(const char *buf, size_t len, const char **method, size_t *method_len, const char **path, size_t *path_len, 51int phr_parse_request(const char *buf, size_t len, const char **method, size_t *method_len, const char **path, size_t *path_len,
52 int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len); 52 int *major_version, int *minor_version, struct phr_header *headers, size_t *num_headers, size_t last_len);
53 53
54/* ditto */ 54/* ditto */
55int phr_parse_response(const char *_buf, size_t len, int *minor_version, int *status, const char **msg, size_t *msg_len, 55int phr_parse_response(const char *_buf, size_t len, int *major_version, int *minor_version, int *status, const char **msg, size_t *msg_len,
56 struct phr_header *headers, size_t *num_headers, size_t last_len); 56 struct phr_header *headers, size_t *num_headers, size_t last_len);
57 57
58/* ditto */ 58/* ditto */
diff --git a/plugins/popen.c b/plugins/popen.c
index 9eb49b6..723817d 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -14,7 +14,7 @@
14* FILE * spopen(const char *); 14* FILE * spopen(const char *);
15* int spclose(FILE *); 15* int spclose(FILE *);
16* 16*
17* Code taken with liitle modification from "Advanced Programming for the Unix 17* Code taken with little modification from "Advanced Programming for the Unix
18* Environment" by W. Richard Stevens 18* Environment" by W. Richard Stevens
19* 19*
20* This is considered safe in that no shell is spawned, and the environment 20* This is considered safe in that no shell is spawned, and the environment
diff --git a/plugins/runcmd.c b/plugins/runcmd.c
index a7155d2..c1d675d 100644
--- a/plugins/runcmd.c
+++ b/plugins/runcmd.c
@@ -44,6 +44,8 @@
44# include <sys/wait.h> 44# include <sys/wait.h>
45#endif 45#endif
46 46
47#include "./utils.h"
48
47/** macros **/ 49/** macros **/
48#ifndef WEXITSTATUS 50#ifndef WEXITSTATUS
49# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) 51# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
@@ -203,7 +205,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
203 } 205 }
204 206
205 /* parent picks up execution here */ 207 /* parent picks up execution here */
206 /* close childs descriptors in our address space */ 208 /* close children descriptors in our address space */
207 close(pfd[1]); 209 close(pfd[1]);
208 close(pfderr[1]); 210 close(pfderr[1]);
209 211
diff --git a/plugins/sslutils.c b/plugins/sslutils.c
index 14f6579..666a012 100644
--- a/plugins/sslutils.c
+++ b/plugins/sslutils.c
@@ -134,7 +134,16 @@ int np_net_ssl_init_with_hostname_version_and_cert(int sd, char *host_name, int
134 return STATE_CRITICAL; 134 return STATE_CRITICAL;
135 } 135 }
136 if (cert && privkey) { 136 if (cert && privkey) {
137 SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM); 137#ifdef USE_OPENSSL
138 if (!SSL_CTX_use_certificate_chain_file(c, cert)) {
139#elif USE_GNUTLS
140 if (!SSL_CTX_use_certificate_file(c, cert, SSL_FILETYPE_PEM)) {
141#else
142#error Unported for unknown SSL library
143#endif
144 printf ("%s\n", _("CRITICAL - Unable to open certificate chain file!\n"));
145 return STATE_CRITICAL;
146 }
138 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM); 147 SSL_CTX_use_PrivateKey_file(c, privkey, SSL_FILETYPE_PEM);
139#ifdef USE_OPENSSL 148#ifdef USE_OPENSSL
140 if (!SSL_CTX_check_private_key(c)) { 149 if (!SSL_CTX_check_private_key(c)) {
@@ -191,17 +200,6 @@ int np_net_ssl_read(void *buf, int num) {
191 return SSL_read(s, buf, num); 200 return SSL_read(s, buf, num);
192} 201}
193 202
194int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
195# ifdef USE_OPENSSL
196 X509 *certificate = NULL;
197 certificate=SSL_get_peer_certificate(s);
198 return(np_net_ssl_check_certificate(certificate, days_till_exp_warn, days_till_exp_crit));
199# else /* ifndef USE_OPENSSL */
200 printf("%s\n", _("WARNING - Plugin does not support checking certificates."));
201 return STATE_WARNING;
202# endif /* USE_OPENSSL */
203}
204
205int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit){ 203int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int days_till_exp_crit){
206# ifdef USE_OPENSSL 204# ifdef USE_OPENSSL
207 X509_NAME *subj=NULL; 205 X509_NAME *subj=NULL;
@@ -328,4 +326,16 @@ int np_net_ssl_check_certificate(X509 *certificate, int days_till_exp_warn, int
328# endif /* USE_OPENSSL */ 326# endif /* USE_OPENSSL */
329} 327}
330 328
329int np_net_ssl_check_cert(int days_till_exp_warn, int days_till_exp_crit){
330# ifdef USE_OPENSSL
331 X509 *certificate = NULL;
332 certificate=SSL_get_peer_certificate(s);
333 return(np_net_ssl_check_certificate(certificate, days_till_exp_warn, days_till_exp_crit));
334# else /* ifndef USE_OPENSSL */
335 printf("%s\n", _("WARNING - Plugin does not support checking certificates."));
336 return STATE_WARNING;
337# endif /* USE_OPENSSL */
338}
339
340
331#endif /* HAVE_SSL */ 341#endif /* HAVE_SSL */
diff --git a/plugins/t/check_by_ssh.t b/plugins/t/check_by_ssh.t
index 1d2939e..b6479f1 100644
--- a/plugins/t/check_by_ssh.t
+++ b/plugins/t/check_by_ssh.t
@@ -19,19 +19,19 @@ plan skip_all => "SSH_HOST and SSH_IDENTITY must be defined" unless ($ssh_servic
19plan tests => 42; 19plan tests => 42;
20 20
21# Some random check strings/response 21# Some random check strings/response
22my @responce = ('OK: Everything is fine', 22my @response = ('OK: Everything is fine',
23 'WARNING: Hey, pick me, pick me', 23 'WARNING: Hey, pick me, pick me',
24 'CRITICAL: Shit happens', 24 'CRITICAL: Shit happens',
25 'UNKNOWN: What can I do for ya', 25 'UNKNOWN: What can I do for ya',
26 'WOOPS: What did I smoke', 26 'WOOPS: What did I smoke',
27); 27);
28my @responce_re; 28my @response_re;
29my @check; 29my @check;
30for (@responce) { 30for (@response) {
31 push(@check, "echo $_"); 31 push(@check, "echo $_");
32 my $re_str = $_; 32 my $re_str = $_;
33 $re_str =~ s{(.)} { "\Q$1" }ge; 33 $re_str =~ s{(.)} { "\Q$1" }ge;
34 push(@responce_re, $re_str); 34 push(@response_re, $re_str);
35} 35}
36 36
37my $result; 37my $result;
@@ -47,7 +47,7 @@ for (my $i=0; $i<4; $i++) {
47 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'" 47 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[$i]; exit $i'"
48 ); 48 );
49 cmp_ok($result->return_code, '==', $i, "Exit with return code $i"); 49 cmp_ok($result->return_code, '==', $i, "Exit with return code $i");
50 is($result->output, $responce[$i], "Status text is correct for check $i"); 50 is($result->output, $response[$i], "Status text is correct for check $i");
51} 51}
52 52
53$result = NPTest->testCmd( 53$result = NPTest->testCmd(
@@ -84,7 +84,7 @@ $result = NPTest->testCmd(
84 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'" 84 "./check_by_ssh -i $ssh_key -H $ssh_service -C '$check[4]; exit 8'"
85 ); 85 );
86cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)"); 86cmp_ok($result->return_code, '==', 8, "Exit with return code 8 (out of bounds)");
87is($result->output, $responce[4], "Return proper status text even with unknown status codes"); 87is($result->output, $response[4], "Return proper status text even with unknown status codes");
88 88
89$result = NPTest->testCmd( 89$result = NPTest->testCmd(
90 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'" 90 "./check_by_ssh -i $ssh_key -H $ssh_service -F $ssh_conf -C 'exit 0'"
@@ -108,7 +108,7 @@ my %linemap = (
108foreach my $line (0, 2, 4, 6) { 108foreach my $line (0, 2, 4, 6) {
109 my $code = $linemap{$line}; 109 my $code = $linemap{$line};
110 my $statline = $line+1; 110 my $statline = $line+1;
111 is($lines[$line], "$responce[$code]", "multiple checks status text is correct for line $line"); 111 is($lines[$line], "$response[$code]", "multiple checks status text is correct for line $line");
112 is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line"); 112 is($lines[$statline], "STATUS CODE: $code", "multiple check status code is correct for line $line");
113} 113}
114 114
@@ -124,7 +124,7 @@ close(PASV) or die("Unable to close '/tmp/check_by_ssh.$$': $!");
124cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed'); 124cmp_ok(scalar(@pasv), '==', 1, 'One passive result for one check performed');
125for (0) { 125for (0) {
126 if ($pasv[$_]) { 126 if ($pasv[$_]) {
127 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $responce_re[2] . '$/', 'proper result for passive check'); 127 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;serv;2;' . $response_re[2] . '$/', 'proper result for passive check');
128 } else { 128 } else {
129 fail('proper result for passive check'); 129 fail('proper result for passive check');
130 } 130 }
@@ -144,7 +144,7 @@ for (0, 1, 2, 3, 4) {
144 if ($pasv[$_]) { 144 if ($pasv[$_]) {
145 my $ret = $_; 145 my $ret = $_;
146 $ret = 9 if ($_ == 4); 146 $ret = 9 if ($_ == 4);
147 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $responce_re[$_] . '$/', "proper result for passive check $_"); 147 like($pasv[$_], '/^\[\d+\] PROCESS_SERVICE_CHECK_RESULT;flint;c' . $_ . ';' . $ret . ';' . $response_re[$_] . '$/', "proper result for passive check $_");
148 } else { 148 } else {
149 fail("proper result for passive check $_"); 149 fail("proper result for passive check $_");
150 } 150 }
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
index 45ee533..eae98cc 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -1,15 +1,22 @@
1#! /usr/bin/perl -w -I .. 1#! /usr/bin/perl -w -I ..
2# 2#
3# HyperText Transfer Protocol (HTTP) Test via check_http 3# HyperText Transfer Protocol (HTTP) Test via check_curl
4# 4#
5# 5#
6 6
7use strict; 7use strict;
8use Test::More; 8use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest;
11 10
12plan tests => 58; 11use vars qw($tests $has_ipv6);
12
13BEGIN {
14 use NPTest;
15 $has_ipv6 = NPTest::has_ipv6();
16 $tests = $has_ipv6 ? 59 : 57;
17 plan tests => $tests;
18}
19
13 20
14my $successOutput = '/OK.*HTTP.*second/'; 21my $successOutput = '/OK.*HTTP.*second/';
15 22
@@ -18,6 +25,7 @@ my $plugin = 'check_http';
18$plugin = 'check_curl' if $0 =~ m/check_curl/mx; 25$plugin = 'check_curl' if $0 =~ m/check_curl/mx;
19 26
20my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost"); 27my $host_tcp_http = getTestParameter("NP_HOST_TCP_HTTP", "A host providing the HTTP Service (a web server)", "localhost");
28my $host_tcp_http_ipv6 = getTestParameter("NP_HOST_TCP_HTTP_IPV6", "An IPv6 address providing a HTTP Service (a web server)", "::1");
21my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost"); 29my $host_tls_http = getTestParameter("NP_HOST_TLS_HTTP", "A host providing the HTTPS Service (a tls web server)", "localhost");
22my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost"); 30my $host_tls_cert = getTestParameter("NP_HOST_TLS_CERT", "the common name of the certificate.", "localhost");
23my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1"); 31my $host_nonresponsive = getTestParameter("NP_HOST_NONRESPONSIVE", "The hostname of system not responsive to network requests", "10.0.0.1");
@@ -31,26 +39,35 @@ my $faketime = -x '/usr/bin/faketime' ? 1 : 0;
31 39
32 40
33$res = NPTest->testCmd( 41$res = NPTest->testCmd(
34 "./$plugin $host_tcp_http -wt 300 -ct 600" 42 "./$plugin $host_tcp_http -wt 300 -ct 600"
35 ); 43 );
36cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" ); 44cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
37like( $res->output, $successOutput, "Output OK" ); 45like( $res->output, $successOutput, "Output OK" );
38 46
47if ($has_ipv6) {
48 # Test for IPv6 formatting
49 $res = NPTest->testCmd(
50 "./$plugin -I $host_tcp_http_ipv6 -wt 300 -ct 600"
51 );
52 cmp_ok( $res->return_code, '==', 0, "IPv6 URL formatting is working" );
53 like( $res->output, $successOutput, "Output OK" );
54}
55
39$res = NPTest->testCmd( 56$res = NPTest->testCmd(
40 "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'" 57 "./$plugin $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
41 ); 58 );
42like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" ); 59like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
43 60
44$res = NPTest->testCmd( 61$res = NPTest->testCmd(
45 "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3" 62 "./$plugin $host_nonresponsive -wt 1 -ct 2 -t 3"
46 ); 63 );
47cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); 64cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
48# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) 65# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
49like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK"); 66like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
50 67
51$res = NPTest->testCmd( 68$res = NPTest->testCmd(
52 "./$plugin $hostname_invalid -wt 1 -ct 2" 69 "./$plugin $hostname_invalid -wt 1 -ct 2"
53 ); 70 );
54cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); 71cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
55# The first part of the message comes from the OS catalogue, so cannot check this. 72# The first part of the message comes from the OS catalogue, so cannot check this.
56# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename 73# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
@@ -95,7 +112,7 @@ SKIP: {
95 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); 112 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443");
96 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); 113 like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" );
97 114
98 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -p 443"); 115 $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -S -p 443");
99 like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" ); 116 like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" );
100}; 117};
101 118
@@ -188,11 +205,6 @@ SKIP: {
188 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 205 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
189 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 206 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
190 207
191 $res = NPTest->testCmd(
192 "./$plugin --ssl -H www.e-paycobalt.com"
193 );
194 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
195
196 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); 208 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
197 is( $res->return_code, 0, "Redirection based on location is okay"); 209 is( $res->return_code, 0, "Redirection based on location is okay");
198 210
diff --git a/plugins/t/check_disk.t b/plugins/t/check_disk.t
index ec527e7..ca035ce 100644
--- a/plugins/t/check_disk.t
+++ b/plugins/t/check_disk.t
@@ -23,7 +23,7 @@ my $mountpoint2_valid = getTestParameter( "NP_MOUNTPOINT2_VALID", "Path to anoth
23if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") { 23if ($mountpoint_valid eq "" or $mountpoint2_valid eq "") {
24 plan skip_all => "Need 2 mountpoints to test"; 24 plan skip_all => "Need 2 mountpoints to test";
25} else { 25} else {
26 plan tests => 78; 26 plan tests => 88;
27} 27}
28 28
29$result = NPTest->testCmd( 29$result = NPTest->testCmd(
@@ -326,19 +326,19 @@ cmp_ok( $result->return_code, '==', 0, "grouping: exit ok if the sum of free meg
326$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" ); 326$result = NPTest->testCmd( "./check_disk -w ". ($free_mb_on_all - 1) ." -c ". ($free_mb_on_all - 1) ." -p $mountpoint_valid -g group -p $mountpoint2_valid" );
327cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname"); 327cmp_ok( $result->return_code, '==', 3, "Invalid options: -p must come after groupname");
328 328
329# regex: exit unknown if given regex is not compileable 329# regex: exit unknown if given regex is not compilable
330$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" ); 330$result = NPTest->testCmd( "./check_disk -w 1 -c 1 -r '('" );
331cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compileable"); 331cmp_ok( $result->return_code, '==', 3, "Exit UNKNOWN if regex is not compilable");
332 332
333# ignore: exit unknown, if all pathes are deselected using -i 333# ignore: exit unknown, if all paths are deselected using -i
334$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" ); 334$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '$mountpoint_valid' -i '$mountpoint2_valid'" );
335cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)"); 335cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case sensitive)");
336 336
337# ignore: exit unknown, if all pathes are deselected using -I 337# ignore: exit unknown, if all paths are deselected using -I
338$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" ); 338$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -I '".uc($mountpoint_valid)."' -I '".uc($mountpoint2_valid)."'" );
339cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)"); 339cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored (case insensitive)");
340 340
341# ignore: exit unknown, if all pathes are deselected using -i 341# ignore: exit unknown, if all paths are deselected using -i
342$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" ); 342$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '.*'" );
343cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'"); 343cmp_ok( $result->return_code, '==', 3, "ignore-ereg: Unknown if all fs are ignored using -i '.*'");
344 344
@@ -347,7 +347,32 @@ $result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mo
347like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it"); 347like( $result->output, qr/$mountpoint_valid/, "output data does have $mountpoint_valid in it");
348unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it"); 348unlike( $result->output, qr/$mountpoint2_valid/, "output data does not have $mountpoint2_valid in it");
349 349
350# ignore: test if all pathes are listed when ignore regex doesn't match 350# ignore: test if all paths are listed when ignore regex doesn't match
351$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'"); 351$result = NPTest->testCmd( "./check_disk -w 0% -c 0% -p $mountpoint_valid -p $mountpoint2_valid -i '^barbazJodsf\$'");
352like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match"); 352like( $result->output, qr/$mountpoint_valid/, "ignore: output data does have $mountpoint_valid when regex doesn't match");
353like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match"); 353like( $result->output, qr/$mountpoint2_valid/,"ignore: output data does have $mountpoint2_valid when regex doesn't match");
354
355# ignore-missing: exit okay, when fs is not accessible
356$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p /bob");
357cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for not existing filesystem /bob");
358like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /bob;.*$/', 'Output OK');
359
360# ignore-missing: exit okay, when regex does not match
361$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r /bob");
362cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
363like( $result->output, '/^DISK OK - No disks were found for provided parameters;.*$/', 'Output OK');
364
365# ignore-missing: exit okay, when fs with exact match (-E) is not found
366$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -E -p /etc");
367cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay when exact match does not find fs");
368like( $result->output, '/^DISK OK - No disks were found for provided parameters; - ignored paths: /etc;.*$/', 'Output OK');
369
370# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (regex)
371$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -r '/bob' -r '^/\$'");
372cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
373like( $result->output, '/^DISK OK - free space: \/ .*$/', 'Output OK');
374
375# ignore-missing: exit okay, when checking one existing fs and one non-existing fs (path)
376$result = NPTest->testCmd( "./check_disk --ignore-missing -w 0% -c 0% -p '/bob' -p '/'");
377cmp_ok( $result->return_code, '==', 0, "ignore-missing: return okay for regular expression not matching");
378like( $result->output, '/^DISK OK - free space: / .*; - ignored paths: /bob;.*$/', 'Output OK'); \ No newline at end of file
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index c137f7b..1f2fbdf 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 50; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $successOutput = '/OK.*HTTP.*second/';
15 15
@@ -103,7 +103,7 @@ SKIP: {
103 cmp_ok( $res->return_code, "==", 0, "And also when not found"); 103 cmp_ok( $res->return_code, "==", 0, "And also when not found");
104} 104}
105SKIP: { 105SKIP: {
106 skip "No internet access", 23 if $internet_access eq "no"; 106 skip "No internet access", 22 if $internet_access eq "no";
107 107
108 $res = NPTest->testCmd( 108 $res = NPTest->testCmd(
109 "./$plugin --ssl $host_tls_http" 109 "./$plugin --ssl $host_tls_http"
@@ -166,12 +166,6 @@ SKIP: {
166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
168 168
169 $res = NPTest->testCmd(
170 "./$plugin --ssl -H www.e-paycobalt.com"
171 );
172 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
173
174
175 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); 169 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
176 is( $res->return_code, 0, "Redirection based on location is okay"); 170 is( $res->return_code, 0, "Redirection based on location is okay");
177 171
@@ -184,13 +178,13 @@ SKIP: {
184 178
185 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302"); 179 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302");
186 is( $res->return_code, 0, "Proxy HTTP works"); 180 is( $res->return_code, 0, "Proxy HTTP works");
187 like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent"); 181 like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficient");
188 182
189 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT"); 183 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT");
190 is( $res->return_code, 0, "Proxy HTTP CONNECT works"); 184 is( $res->return_code, 0, "Proxy HTTP CONNECT works");
191 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); 185 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
192 186
193 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD"); 187 $res = NPTest->testCmd( "./$plugin -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD");
194 is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method"); 188 is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method");
195 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); 189 like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficient");
196} 190}
diff --git a/plugins/t/check_load.t b/plugins/t/check_load.t
index 60837ef..bba8947 100644
--- a/plugins/t/check_load.t
+++ b/plugins/t/check_load.t
@@ -11,10 +11,12 @@ use NPTest;
11my $res; 11my $res;
12 12
13my $loadValue = "[0-9]+\.?[0-9]+"; 13my $loadValue = "[0-9]+\.?[0-9]+";
14my $successOutput = "/^LOAD OK - load average: $loadValue, $loadValue, $loadValue/"; 14my $successOutput = "/^LOAD OK - total load average: $loadValue, $loadValue, $loadValue/";
15my $failureOutput = "/^LOAD CRITICAL - load average: $loadValue, $loadValue, $loadValue/"; 15my $successScaledOutput = "/^LOAD OK - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16my $failureOutput = "/^LOAD CRITICAL - total load average: $loadValue, $loadValue, $loadValue/";
17my $failurScaledOutput = "/^LOAD CRITICAL - scaled load average: $loadValue, $loadValue, $loadValue - total load average: $loadValue, $loadValue, $loadValue/";
16 18
17plan tests => 11; 19plan tests => 13;
18 20
19$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" ); 21$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100" );
20cmp_ok( $res->return_code, 'eq', 0, "load not over 100"); 22cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
@@ -26,7 +28,7 @@ like( $res->output, $failureOutput, "Output OK");
26 28
27$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" ); 29$res = NPTest->testCmd( "./check_load -r -w 0,0,0 -c 0,0,0" );
28cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division"); 30cmp_ok( $res->return_code, 'eq', 2, "Load over 0 with per cpu division");
29like( $res->output, $failureOutput, "Output OK"); 31like( $res->output, $failurScaledOutput, "Output OK");
30 32
31$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" ); 33$res = NPTest->testCmd( "./check_load -w 100 -c 100,110" );
32cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments"); 34cmp_ok( $res->return_code, 'eq', 0, "Plugin can handle non-triplet-arguments");
@@ -34,3 +36,8 @@ like( $res->output, $successOutput, "Output OK");
34like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)"); 36like( $res->perf_output, "/load1=$loadValue;100.000;100.000/", "Test handling of non triplet thresholds (load1)");
35like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)"); 37like( $res->perf_output, "/load5=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load5)");
36like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)"); 38like( $res->perf_output, "/load15=$loadValue;100.000;110.000/", "Test handling of non triplet thresholds (load15)");
39
40
41$res = NPTest->testCmd( "./check_load -w 100,100,100 -c 100,100,100 -r" );
42cmp_ok( $res->return_code, 'eq', 0, "load not over 100");
43like( $res->output, $successScaledOutput, "Output OK");
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t
index e426bf5..baf3acc 100644
--- a/plugins/t/check_mysql.t
+++ b/plugins/t/check_mysql.t
@@ -5,7 +5,7 @@
5# 5#
6# 6#
7# These are the database permissions required for this test: 7# These are the database permissions required for this test:
8# GRANT SELECT ON $db.* TO $user@$host INDENTIFIED BY '$password'; 8# GRANT SELECT ON $db.* TO $user@$host IDENTIFIED BY '$password';
9# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host; 9# GRANT SUPER, REPLICATION CLIENT ON *.* TO $user@$host;
10# Check with: 10# Check with:
11# mysql -u$user -p$password -h$host $db 11# mysql -u$user -p$password -h$host $db
@@ -23,9 +23,9 @@ plan tests => 15;
23my $bad_login_output = '/Access denied for user /'; 23my $bad_login_output = '/Access denied for user /';
24my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup"); 24my $mysqlserver = getTestParameter("NP_MYSQL_SERVER", "A MySQL Server hostname or IP with no slaves setup");
25my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup"); 25my $mysqlsocket = getTestParameter("NP_MYSQL_SOCKET", "Full path to a MySQL Server socket with no slaves setup");
26my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privleges)", "-u test -ptest"); 26my $mysql_login_details = getTestParameter("NP_MYSQL_LOGIN_DETAILS", "Command line parameters to specify login access (requires REPLICATION CLIENT privileges)", "-u test -ptest");
27my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup"); 27my $with_slave = getTestParameter("NP_MYSQL_WITH_SLAVE", "MySQL server with slaves setup");
28my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privleges)", $mysql_login_details || "-u test -ptest"); 28my $with_slave_login = getTestParameter("NP_MYSQL_WITH_SLAVE_LOGIN", "Login details for server with slave (requires REPLICATION CLIENT privileges)", $mysql_login_details || "-u test -ptest");
29 29
30my $result; 30my $result;
31 31
diff --git a/plugins/t/check_mysql_query.t b/plugins/t/check_mysql_query.t
index 96899ac..c30245b 100644
--- a/plugins/t/check_mysql_query.t
+++ b/plugins/t/check_mysql_query.t
@@ -31,7 +31,7 @@ $result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver $
31cmp_ok( $result->return_code, '==', 0, "Can run query"); 31cmp_ok( $result->return_code, '==', 0, "Can run query");
32 32
33$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details"); 33$result = NPTest->testCmd("./check_mysql_query -H $mysqlserver $mysql_login_details");
34cmp_ok( $result->return_code, '==', 3, "Missing query parmeter"); 34cmp_ok( $result->return_code, '==', 3, "Missing query parameter");
35like( $result->output, "/Must specify a SQL query to run/", "Missing query error message"); 35like( $result->output, "/Must specify a SQL query to run/", "Missing query error message");
36 36
37$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql"); 37$result = NPTest->testCmd("./check_mysql_query -q 'SELECT 1+1' -H $mysqlserver -u dummy -d mysql");
diff --git a/plugins/t/check_nagios.t b/plugins/t/check_nagios.t
index 81fc24d..f38f5e9 100644
--- a/plugins/t/check_nagios.t
+++ b/plugins/t/check_nagios.t
@@ -36,7 +36,7 @@ cmp_ok( $result->return_code, '==', 1, "Log over 5 minutes old" );
36like ( $result->output, $warningOutput, "Output for warning correct" ); 36like ( $result->output, $warningOutput, "Output for warning correct" );
37 37
38my $now = time; 38my $now = time;
39# This substitution is dependant on the testcase 39# This substitution is dependent on the testcase
40system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1"; 40system( "perl -pe 's/1133537544/$now/' $nagios1 > $nagios1.tmp" ) == 0 or die "Problem with munging $nagios1";
41 41
42$result = NPTest->testCmd( 42$result = NPTest->testCmd(
diff --git a/plugins/t/check_smtp.t b/plugins/t/check_smtp.t
index aa6dae4..1a1ebe3 100644
--- a/plugins/t/check_smtp.t
+++ b/plugins/t/check_smtp.t
@@ -8,12 +8,14 @@ use strict;
8use Test::More; 8use Test::More;
9use NPTest; 9use NPTest;
10 10
11my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP", 11my $host_tcp_smtp = getTestParameter( "NP_HOST_TCP_SMTP",
12 "A host providing an SMTP Service (a mail server)", "mailhost"); 12 "A host providing an SMTP Service (a mail server)", "mailhost");
13my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS", 13my $host_tcp_smtp_starttls = getTestParameter( "NP_HOST_TCP_SMTP_STARTTLS",
14 "A host providing SMTP with STARTTLS", $host_tcp_smtp);
15my $host_tcp_smtp_nostarttls = getTestParameter( "NP_HOST_TCP_SMTP_NOSTARTTLS",
16 "A host providing SMTP without STARTTLS", "");
17my $host_tcp_smtp_tls = getTestParameter( "NP_HOST_TCP_SMTP_TLS",
14 "A host providing SMTP with TLS", $host_tcp_smtp); 18 "A host providing SMTP with TLS", $host_tcp_smtp);
15my $host_tcp_smtp_notls = getTestParameter( "NP_HOST_TCP_SMTP_NOTLS",
16 "A host providing SMTP without TLS", "");
17 19
18my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE", 20my $host_nonresponsive = getTestParameter( "NP_HOST_NONRESPONSIVE",
19 "The hostname of system not responsive to network requests", "10.0.0.1" ); 21 "The hostname of system not responsive to network requests", "10.0.0.1" );
@@ -22,7 +24,7 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
22 "An invalid (not known to DNS) hostname", "nosuchhost" ); 24 "An invalid (not known to DNS) hostname", "nosuchhost" );
23my $res; 25my $res;
24 26
25plan tests => 10; 27plan tests => 16;
26 28
27SKIP: { 29SKIP: {
28 skip "No SMTP server defined", 4 unless $host_tcp_smtp; 30 skip "No SMTP server defined", 4 unless $host_tcp_smtp;
@@ -42,22 +44,38 @@ SKIP: {
42 local $TODO = "Output is over two lines"; 44 local $TODO = "Output is over two lines";
43 like ( $res->output, qr/^SMTP WARNING/, "Correct error message" ); 45 like ( $res->output, qr/^SMTP WARNING/, "Correct error message" );
44 } 46 }
47
48 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp --ssl -p 25" );
49 is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp with TLS on standard SMTP port" );
50 like ($res->output, qr/^CRITICAL - Cannot make SSL connection\./, "Check output of connecting to $host_tcp_smtp with TLS on standard SMTP port");
45} 51}
46 52
47SKIP: { 53SKIP: {
48 skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls; 54 skip "No SMTP server with STARTTLS defined", 1 unless $host_tcp_smtp_starttls;
49 # SSL connection for TLS 55 # SSL connection for STARTTLS
50 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p 25 -S" ); 56 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_starttls -p 25 -S" );
51 is ($res->return_code, 0, "OK, with STARTTLS" ); 57 is ($res->return_code, 0, "OK, with STARTTLS" );
52} 58}
53 59
54SKIP: { 60SKIP: {
55 skip "No SMTP server without TLS defined", 2 unless $host_tcp_smtp_notls; 61 skip "No SMTP server without STARTTLS defined", 2 unless $host_tcp_smtp_nostarttls;
56 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_notls -p 25 -S" ); 62 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_nostarttls -p 25 -S" );
57 is ($res->return_code, 1, "OK, got warning from server without TLS"); 63 is ($res->return_code, 1, "OK, got warning from server without STARTTLS");
58 is ($res->output, "WARNING - TLS not supported by server", "Right error message" ); 64 is ($res->output, "WARNING - TLS not supported by server", "Right error message" );
59} 65}
60 66
67SKIP: {
68 skip "No SMTP server with TLS defined", 1 unless $host_tcp_smtp_tls;
69 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls --ssl" );
70 is ($res->return_code, 0, "Check rc of connecting to $host_tcp_smtp_tls with TLS" );
71 like ($res->output, qr/^SMTP OK - /, "Check output of connecting to $host_tcp_smtp_tls with TLS" );
72
73 my $unused_port = 4465;
74 $res = NPTest->testCmd( "./check_smtp -H $host_tcp_smtp_tls -p $unused_port --ssl" );
75 is ($res->return_code, 2, "Check rc of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port" );
76 like ($res->output, qr/^connect to address $host_tcp_smtp_tls and port $unused_port: Connection refused/, "Check output of connecting to $host_tcp_smtp_tls with TLS on unused port $unused_port");
77}
78
61$res = NPTest->testCmd( "./check_smtp $host_nonresponsive" ); 79$res = NPTest->testCmd( "./check_smtp $host_nonresponsive" );
62is ($res->return_code, 2, "CRITICAL - host non responding" ); 80is ($res->return_code, 2, "CRITICAL - host non responding" );
63 81
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index f2f218f..576cc50 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -26,22 +26,22 @@ $res = NPTest->testCmd( "./check_snmp -t 1" );
26is( $res->return_code, 3, "No host name" ); 26is( $res->return_code, 3, "No host name" );
27is( $res->output, "No host specified" ); 27is( $res->output, "No host specified" );
28 28
29$res = NPTest->testCmd( "./check_snmp -H fakehostname" ); 29$res = NPTest->testCmd( "./check_snmp -H fakehostname --ignore-mib-parsing-errors" );
30is( $res->return_code, 3, "No OIDs specified" ); 30is( $res->return_code, 3, "No OIDs specified" );
31is( $res->output, "No OIDs specified" ); 31is( $res->output, "No OIDs specified" );
32 32
33$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3 -U not_a_user --seclevel=rubbish" ); 33$res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3 -U not_a_user --seclevel=rubbish" );
34is( $res->return_code, 3, "Invalid seclevel" ); 34is( $res->return_code, 3, "Invalid seclevel" );
35like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" ); 35like( $res->output, "/check_snmp: Invalid seclevel - rubbish/" );
36 36
37$res = NPTest->testCmd( "./check_snmp -H fakehost -o oids -P 3c" ); 37$res = NPTest->testCmd( "./check_snmp -H fakehost --ignore-mib-parsing-errors -o oids -P 3c" );
38is( $res->return_code, 3, "Invalid protocol" ); 38is( $res->return_code, 3, "Invalid protocol" );
39like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" ); 39like( $res->output, "/check_snmp: Invalid SNMP version - 3c/" );
40 40
41SKIP: { 41SKIP: {
42 skip "no snmp host defined", 50 if ( ! $host_snmp ); 42 skip "no snmp host defined", 50 if ( ! $host_snmp );
43 43
44 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:"); 44 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:");
45 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" ); 45 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying uptime" );
46 like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK"); 46 like($res->output, '/^SNMP OK - (\d+)/', "String contains SNMP OK");
47 $res->output =~ /^SNMP OK - (\d+)/; 47 $res->output =~ /^SNMP OK - (\d+)/;
@@ -51,111 +51,111 @@ SKIP: {
51 51
52 52
53 # some more threshold tests 53 # some more threshold tests
54 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1"); 54 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1");
55 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" ); 55 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1" );
56 56
57 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:"); 57 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:");
58 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" ); 58 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 1:" );
59 59
60 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c ~:1"); 60 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c ~:1");
61 cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" ); 61 cmp_ok( $res->return_code, '==', 2, "Threshold test -c ~:1" );
62 62
63 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1:10"); 63 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1:10");
64 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" ); 64 cmp_ok( $res->return_code, '==', 2, "Threshold test -c 1:10" );
65 65
66 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c \@1:10"); 66 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c \@1:10");
67 cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" ); 67 cmp_ok( $res->return_code, '==', 0, "Threshold test -c \@1:10" );
68 68
69 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 10:1"); 69 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 10:1");
70 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" ); 70 cmp_ok( $res->return_code, '==', 0, "Threshold test -c 10:1" );
71 71
72 72
73 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:"); 73 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o .1.3.6.1.2.1.1.3.0 -w 1: -c 1:");
74 cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" ); 74 cmp_ok( $res->return_code, '==', 0, "Test with numeric OID (no mibs loaded)" );
75 like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK"); 75 like($res->output, '/^SNMP OK - \d+/', "String contains SNMP OK");
76 76
77 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0"); 77 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0");
78 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" ); 78 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying sysDescr" );
79 unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values"); 79 unlike($res->perf_output, '/sysDescr/', "Perfdata doesn't contain string values");
80 80
81 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0,system.sysDescr.0"); 81 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0,system.sysDescr.0");
82 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" ); 82 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, comma-separated" );
83 like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 83 like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
84 84
85 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0"); 85 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysDescr.0 -o system.sysDescr.0");
86 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" ); 86 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying two string OIDs, repeated option" );
87 like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 87 like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
88 88
89 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"); 89 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1");
90 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" ); 90 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrSWRunIndex.1" );
91 like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format"); 91 like($res->output, '/^SNMP OK - 1\s.*$/', "String fits SNMP OK and output format");
92 92
93 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"); 93 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:");
94 cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " ); 94 cmp_ok( $res->return_code, '==', 1, "Exit WARNING when querying hrSWRunIndex.1 and warn-th doesn't apply " );
95 like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format"); 95 like($res->output, '/^SNMP WARNING - \*1\*\s.*$/', "String matches SNMP WARNING and output format");
96 96
97 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"); 97 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0");
98 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" ); 98 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL when querying hrSWRunIndex.1 and crit-th doesn't apply" );
99 like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format"); 99 like($res->output, '/^SNMP CRITICAL - \*1\*\s.*$/', "String matches SNMP CRITICAL and output format");
100 100
101 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2"); 101 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2 -c 1:2");
102 cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" ); 102 cmp_ok( $res->return_code, '==', 0, "Checking two OIDs at once" );
103 like($res->output, "/^SNMP OK - 2 1/", "Got two values back" ); 103 like($res->output, "/^SNMP OK - 2 1/", "Got two values back" );
104 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); 104 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" );
105 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); 105 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" );
106 106
107 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2"); 107 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o ifIndex.2,ifIndex.1 -w 1:2,1:2 -c 2:2,2:2");
108 cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" ); 108 cmp_ok( $res->return_code, '==', 2, "Checking critical threshold is passed if any one value crosses" );
109 like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" ); 109 like($res->output, "/^SNMP CRITICAL - 2 *1*/", "Got two values back" );
110 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" ); 110 like( $res->perf_output, "/ifIndex.2=2/", "Got 1st perf data" );
111 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" ); 111 like( $res->perf_output, "/ifIndex.1=1/", "Got 2nd perf data" );
112 112
113 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:"); 113 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w 1:,1: -c 1:,1:");
114 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses"); 114 cmp_ok( $res->return_code, '==', 0, "Exit OK when querying hrMemorySize and hrSystemProcesses");
115 like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses"); 115 like($res->output, '/^SNMP OK - \d+ \d+/', "String contains hrMemorySize and hrSystemProcesses");
116 116
117 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0"); 117 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w \@:0 -c \@0");
118 cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds"); 118 cmp_ok( $res->return_code, '==', 0, "Exit OK with inside-range thresholds");
119 like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format"); 119 like($res->output, '/^SNMP OK - 1\s.*$/', "String matches SNMP OK and output format");
120 120
121 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3"); 121 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3");
122 $res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/; 122 $res->output =~ m/^SNMP OK - (\d+\.\d{2})\s.*$/;
123 my $lower = $1 - 0.05; 123 my $lower = $1 - 0.05;
124 my $higher = $1 + 0.05; 124 my $higher = $1 + 0.05;
125 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher"); 125 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o enterprises.ucdavis.laTable.laEntry.laLoad.3 -w $lower -c $higher");
126 cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments"); 126 cmp_ok( $res->return_code, '==', 1, "Exit WARNING with fractionnal arguments");
127 127
128 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2"); 128 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0,host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w ,:0 -c ,:2");
129 cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold"); 129 cmp_ok( $res->return_code, '==', 1, "Exit WARNING on 2nd threshold");
130 like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds"); 130 like($res->output, '/^SNMP WARNING - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s+\*1\*\s.*$/', "First OID returned as string, 2nd checked for thresholds");
131 131
132 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''"); 132 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w '' -c ''");
133 cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash"); 133 cmp_ok( $res->return_code, '==', 0, "Empty thresholds doesn't crash");
134 134
135 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2"); 135 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,,1 -c ,,2");
136 cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check"); 136 cmp_ok( $res->return_code, '==', 0, "Skipping first two thresholds on 2 OID check");
137 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed"); 137 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping first two thresholds, result printed rather than parsed");
138 138
139 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,"); 139 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o host.hrStorage.hrMemorySize.0,host.hrSystem.hrSystemProcesses.0 -w ,, -c ,,");
140 cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds"); 140 cmp_ok( $res->return_code, '==', 0, "Skipping all thresholds");
141 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed"); 141 like($res->output, '/^SNMP OK - \d+ \w+ \d+\s.*$/', "Skipping all thresholds, result printed rather than parsed");
142 142
143 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'"); 143 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0 -c 1000000000000: -u '1/100 sec'");
144 cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold"); 144 cmp_ok( $res->return_code, '==', 2, "Timetick used as a threshold");
145 like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric"); 145 like($res->output, '/^SNMP CRITICAL - \*\d+\* 1\/100 sec.*$/', "Timetick used as a threshold, parsed as numeric");
146 146
147 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0"); 147 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o system.sysUpTime.0");
148 cmp_ok( $res->return_code, '==', 0, "Timetick used as a string"); 148 cmp_ok( $res->return_code, '==', 0, "Timetick used as a string");
149 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed"); 149 like($res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "Timetick used as a string, result printed rather than parsed");
150 150
151 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1"); 151 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -C $snmp_community -o HOST-RESOURCES-MIB::hrSWRunName.1");
152 cmp_ok( $res->return_code, '==', 0, "snmp response without datatype"); 152 cmp_ok( $res->return_code, '==', 0, "snmp response without datatype");
153 like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" ); 153 like( $res->output, '/^SNMP OK - "(systemd|init)" \| $/', "snmp response without datatype" );
154} 154}
155 155
156SKIP: { 156SKIP: {
157 skip "no SNMP user defined", 1 if ( ! $user_snmp ); 157 skip "no SNMP user defined", 1 if ( ! $user_snmp );
158 $res = NPTest->testCmd( "./check_snmp -H $host_snmp -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv"); 158 $res = NPTest->testCmd( "./check_snmp -H $host_snmp --ignore-mib-parsing-errors -o HOST-RESOURCES-MIB::hrSystemUptime.0 -P 3 -U $user_snmp -L noAuthNoPriv");
159 like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" ); 159 like( $res->output, '/^SNMP OK - Timeticks:\s\(\d+\)\s+(?:\d+ days?,\s+)?\d+:\d+:\d+\.\d+\s.*$/', "noAuthNoPriv security level works properly" );
160} 160}
161 161
@@ -163,14 +163,14 @@ SKIP: {
163# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway 163# the tests can run on hosts w/o snmp host/community in NPTest.cache. Execution will fail anyway
164SKIP: { 164SKIP: {
165 skip "no non responsive host defined", 2 if ( ! $host_nonresponsive ); 165 skip "no non responsive host defined", 2 if ( ! $host_nonresponsive );
166 $res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); 166 $res = NPTest->testCmd( "./check_snmp -H $host_nonresponsive --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
167 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" ); 167 cmp_ok( $res->return_code, '==', 2, "Exit CRITICAL with non responsive host" );
168 like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem"); 168 like($res->output, '/Plugin timed out while executing system call/', "String matches timeout problem");
169} 169}
170 170
171SKIP: { 171SKIP: {
172 skip "no non invalid host defined", 2 if ( ! $hostname_invalid ); 172 skip "no non invalid host defined", 2 if ( ! $hostname_invalid );
173 $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:"); 173 $res = NPTest->testCmd( "./check_snmp -H $hostname_invalid --ignore-mib-parsing-errors -C np_foobar -o system.sysUpTime.0 -w 1: -c 1:");
174 cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); 174 cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" );
175 like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host)/', "String matches invalid host"); 175 like($res->output, '/External command error: .*(nosuchhost|Name or service not known|Unknown host).*/s', "String matches invalid host");
176} 176}
diff --git a/plugins/t/negate.t b/plugins/t/negate.t
index d96a109..5ec1c84 100644
--- a/plugins/t/negate.t
+++ b/plugins/t/negate.t
@@ -84,7 +84,7 @@ foreach my $current_state (keys(%state)) {
84 foreach my $new_state (keys(%state)) { 84 foreach my $new_state (keys(%state)) {
85 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" ); 85 $res = NPTest->testCmd( "./negate -s --$current_state=$new_state ./check_dummy ".$state{$current_state}." 'Fake $new_state'" );
86 is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" ); 86 is( $res->return_code, $state{$new_state}, "Got fake $new_state (with substitute)" );
87 is( $res->output, uc($new_state).": Fake $new_state", "Substitued fake $new_state output"); 87 is( $res->output, uc($new_state).": Fake $new_state", "Substituted fake $new_state output");
88 } 88 }
89} 89}
90 90
diff --git a/plugins/tests/certs/.gitignore b/plugins/tests/certs/.gitignore
new file mode 100644
index 0000000..79acaaa
--- /dev/null
+++ b/plugins/tests/certs/.gitignore
@@ -0,0 +1,2 @@
1/*.csr
2/*.srl
diff --git a/plugins/tests/certs/client-cert.pem b/plugins/tests/certs/client-cert.pem
new file mode 100644
index 0000000..5709750
--- /dev/null
+++ b/plugins/tests/certs/client-cert.pem
@@ -0,0 +1,22 @@
1-----BEGIN CERTIFICATE-----
2MIIDtDCCApwCAQIwDQYJKoZIhvcNAQELBQAwgaAxCzAJBgNVBAYTAkRFMRAwDgYD
3VQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0b3Jp
4bmcgUGx1Z2luczEkMCIGA1UEAwwbTW9uaXRvcmluZyBQbHVnaW5zIENsaWVudENB
5MSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdpbnMub3JnMB4X
6DTIxMDIyODIxMDIxMloXDTMwMTEyODIxMDIxMlowgZ4xCzAJBgNVBAYTAkRFMRAw
7DgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0
8b3JpbmcgUGx1Z2luczEiMCAGA1UEAwwZTW9uaXRvcmluZyBQbHVnaW5zIENsaWVu
9dDErMCkGCSqGSIb3DQEJARYcZGV2ZWxAbW9uaXRvcmluZy1wbHVnaW5zLm9yZzCC
10ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM3EiqfFPomm5dZQPGYG5SrF
11rPvyqseXTzCkwUIUzGf+Sfm3s13zx7e3ije/04yKhTXgK59EQ793q7E2aWhSOz3s
12hwKKdylFkOIyc5jgbAfF1/pLZMK209rLt/mMRksXCRXYrHdTjRMx1ev4C2407+8Y
138qkf77DuYQmUqCQe7DPOvqLeagdw9JcLGmQNTKHg3fl6wyRl5K1Bsy+qXu2XvEjZ
140Ng7n8LHjOUkTqUEJndOxci9gL5cHU5ttul/GW34dKOtTuMU/pQX6/ywYusOGVOx
15RYI76OolRqj5BqbNctDIB/obe2RLo+UVx74/0jAxtH4XS23pYjO7NUpJcytsVG8C
16AwEAATANBgkqhkiG9w0BAQsFAAOCAQEAYfaY5n4pCq0NWPCdeVVRr4nr+GAfv1TC
17/PKcGuEoJZKt7TQT+OOA5yeZMZb53OvtA49D1r9aoJzWe946KElWOEBqxDRi5Cdr
18wkqpwGcPT2RfAqA3/cvQZ1XsquboXrCf7ajdl5OC64bs2jkqCFh9gnxuI140g8Ar
19Njol8BFxRPaYWOnwuQwmh/2t0FJqr3WSD85HrNqtxUSNGbTdSsvCfgF0v7QVkvLG
203/cbx6z5hxzj2JUjhMnCvn+EbasoJt4xyBFvg67Q2229SMwu9YNqS63GVoKUqhCB
214Gl5v31qx8dAFKuRvnez3ze/6oohwmakZkst4hcQdgZocHhzesvKlg==
22-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/client-key.pem b/plugins/tests/certs/client-key.pem
new file mode 100644
index 0000000..09b6761
--- /dev/null
+++ b/plugins/tests/certs/client-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDNxIqnxT6JpuXW
3UDxmBuUqxaz78qrHl08wpMFCFMxn/kn5t7Nd88e3t4o3v9OMioU14CufREO/d6ux
4NmloUjs97IcCincpRZDiMnOY4GwHxdf6S2TCttPay7f5jEZLFwkV2Kx3U40TMdXr
5+AtuNO/vGPKpH++w7mEJlKgkHuwzzr6i3moHcPSXCxpkDUyh4N35esMkZeStQbMv
6ql7tl7xI2dDYO5/Cx4zlJE6lBCZ3TsXIvYC+XB1Obbbpfxlt+HSjrU7jFP6UF+v8
7sGLrDhlTsUWCO+jqJUao+QamzXLQyAf6G3tkS6PlFce+P9IwMbR+F0tt6WIzuzVK
8SXMrbFRvAgMBAAECggEBALtc2pB3p0E6KpAiEU0pvCRdSO1FgsIpAd+eNadRPur2
9fi+XWQkUwGeGBaJL1npja3aqP65PP40pj7nWfNaUAgOZyznCEU0QXiPJor6yo0vU
10l5v+aKpwRao107i0RRF80TYGTMx+1LeEqnCqNOZN56gERHlBbkTiWpOZvBzf1143
11oegTcyM6+Ee6+FYNhHaDyIYD0md1S2wGR+IBPet6HwWiakLNKahFPa7lOLIKfmmD
12iTtifcbf4724wSe44a0uTeP4JrquZSeIKakm8MEmffmYqpycnaakYefd0Xc5UEsH
13+VbhKpOWGY3d8FKHqUsTa+6QyXb2uFPo6A+yWm0pdJECgYEA7Prd5sbWACvXOcHT
14ONDBAgyfAVDQwOXi3D4dk6D5mg+/jxl5ZQY5slszJrwsLFtoEzXtYpNfTy3cpNOp
15JLbBDZYnqty+5tD8t3/Zv2IBXCAgvuk5CgfJWP5FNAfiyUEE6Vbp6J/5/vAnODsa
16fxZryN5UsH0X8ew7AlbfcVNyj4kCgYEA3khetIgn+GR6sv9jFRdCT6aJbp0xMsms
176F4v3L5FG4Kp+SwDHL1bVOhieJ5g8odYp9hDbgTEEqbJfNmyCOu9+OQmZ/mztku7
186reU8HhYBIvi+hFeJmvqKpdIgU0Zveg4Bst5QordmhPk8AHjBC4xvQ++uh7rwYKd
19WVsS08bGDjcCgYEAlAuNARUKsASzakOqHv5a9VrJIttH7povBYRQmd+gzxwzgcRa
20UEB5XvEWnYZE2lkoRYgVCtYiXqa6BsasDmGVbVV25okNQckhd8mJUMR7MQBpNJsi
21pR+EK/J9bSnYBf52gQdpDYiTdy60ca6KuQZaw5wRsEgV426+1pFK+dM16HECgYBY
22cTsdYb9lmbUoW201CxgbUQwFsw3MQ2pE2pT4o8wjcg3nUpe6a61XT08+5uV0Gl4w
23CmBp+gN52Fr7DjNEUWg5C64sWLIkqmWOspTUSU3cITyiex6W8wEtCRyUNfU0Fp2U
24Nol87HvXvmqtBFMraqXnr8gXjg4H5MxurUoEcWaEaQKBgCT4iIGZwW0Qf2rkFC7B
25xObzVGefivVVbaf8/c/LRO8TMLdnExkShMOmCzHeHV4mMEZDLbMOusHCI7xm10EX
26l3L1I1Kyqnhm1RH3e7TVWgkTmIDW3V5Fgrhm1jx5Iz6et4sb4Uh+bZq9tTLyqfZY
278s0yJUrfpjRggfk7eUs5s7aY
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/clientca-cert.pem b/plugins/tests/certs/clientca-cert.pem
new file mode 100644
index 0000000..9ce7cd7
--- /dev/null
+++ b/plugins/tests/certs/clientca-cert.pem
@@ -0,0 +1,25 @@
1-----BEGIN CERTIFICATE-----
2MIIEIzCCAwugAwIBAgIUL9Jfp5zv5B29NgDsNEFU2OM/UHswDQYJKoZIhvcNAQEL
3BQAwgaAxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN
4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEkMCIGA1UEAwwbTW9u
5aXRvcmluZyBQbHVnaW5zIENsaWVudENBMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBt
6b25pdG9yaW5nLXBsdWdpbnMub3JnMB4XDTIxMDIyODIxMDIxMVoXDTMwMTEyODIx
7MDIxMVowgaAxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQH
8DAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEkMCIGA1UEAwwb
9TW9uaXRvcmluZyBQbHVnaW5zIENsaWVudENBMSswKQYJKoZIhvcNAQkBFhxkZXZl
10bEBtb25pdG9yaW5nLXBsdWdpbnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
11MIIBCgKCAQEAyxiWsGrsJFHw3VR0pqHviXUfbfKMw8LaCxI5EQZfInsMVkBIGWEW
12tFW6qDuAOsMdzsrKOnQRNNt852ts/0Uz++z8zysoauAGpc4JnCZuM5A1DU5CFXBx
13w6Ax+1ft3UsTt8C6kfLfs8mPCbtNVqAHrMrIqDxsNSRRxQSqkzp1vD8rwSKcbB1h
14u2+lut1bEqMe7dp89jKOtc6G/1tHUFQuLAGFoX/qk9yPscmQNzL6YbLP4m9r/416
15PsxWsAfyY97hmoYo6mSCue5LmeanOsjf4Kzq90hIJRwrpiUGmxGjW+tPLEhQBZw6
16C2wHyN74YIJYX2xREz2ijT0mgsqdhO5ZxwIDAQABo1MwUTAdBgNVHQ4EFgQUtsP9
17Z3fKkhmFp97Kh/cW/UqHMIMwHwYDVR0jBBgwFoAUtsP9Z3fKkhmFp97Kh/cW/UqH
18MIMwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEApO5o+YECwTEv
19s+elDJZQ20UYwDSiU9Lpf4EcdnRv6FAb5UlhfRTH3ZdKCc/HX7kcKuy3PsF+b8Pw
20EusoKito9OlNEOF5HYAI9/J54/qceqn+SC0INsISeE19PvT0dma7lBSj4OvBv0IS
21GYbdztVaKLWqYgYs0mcEzteUc4MZcy1/C+Ru1i1Kp2s9/vIeAw2PV2+kpWtw88Pb
22FRJomGngP/hQdwniayCltG/Q1smS4iFEHNI5ayLZj1qJGMHwzqGiRr4KknJKfHzv
23fl4NQaFyMY31s1FRIS6QVIRFHVzUAlKZTdzwqEJygg3fUS9n9uDBnyDI/sW7DQuj
24yjSmYRS1hw==
25-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/clientca-key.pem b/plugins/tests/certs/clientca-key.pem
new file mode 100644
index 0000000..a939f03
--- /dev/null
+++ b/plugins/tests/certs/clientca-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDLGJawauwkUfDd
3VHSmoe+JdR9t8ozDwtoLEjkRBl8iewxWQEgZYRa0VbqoO4A6wx3Oyso6dBE023zn
4a2z/RTP77PzPKyhq4AalzgmcJm4zkDUNTkIVcHHDoDH7V+3dSxO3wLqR8t+zyY8J
5u01WoAesysioPGw1JFHFBKqTOnW8PyvBIpxsHWG7b6W63VsSox7t2nz2Mo61zob/
6W0dQVC4sAYWhf+qT3I+xyZA3Mvphss/ib2v/jXo+zFawB/Jj3uGahijqZIK57kuZ
75qc6yN/grOr3SEglHCumJQabEaNb608sSFAFnDoLbAfI3vhgglhfbFETPaKNPSaC
8yp2E7lnHAgMBAAECggEAJqAWiJbNMlsjI/Tb+pTxqYLM52wpuVFlhpWApOxBS517
9SywOikUcvE9RoI0wZfyVvq5yp4tLenID3z9fC21t5Yu8yOm8VhclLINy8G+epc/X
10RyCLEOjBuiLNXq/qXRvaNChDU16NjPPYcFFe9AqbaxFl+BkFu1Wc94tbpYSIv7Qt
11L6iBxUTXdgvLM5doa9AazIQzJx+jUsVCgRVQQf3zsLqtp9hH0Pfq+KWFIy5TA+bG
120NFmYyQndRjtT0ihWGuNU7D8AXa+z7abzk+HydIlx4D//vGgdNq92QYPdnu2BBya
135Fs6LkmkUonX/I8FbkLbRKkQWNPMt+Ks21t3xcVBgQKBgQDn4HuHVCPwxgU6Mv+5
140sHJXYBq1fDzrUt0+iTtYkRqViX+9Mp4sUpYgXext/wXFLcKzQQp5B0g1dLYLSRS
15KwhsdiN0J7ZcoP1GMStw8zsayRTf8C3WRU6aACqyFiylYbyh56XomfYgwhja/7l9
16pzpVJD9ecG+mLVAyAkJtK2JolQKBgQDgOZfvrQj0L4QG+9E5VmFc3PE+6k3g+zDO
17MWqTSh0fOHqdTEyet4bMC4DogXGVsvw0/UKwbrGHOk0+ltA5VyKUtK/whSutr/+S
18nhCHljhV0XUN/I3OFcvezFjM3g0oC4uy1cL30hoM4IfeHM1d3EYse9N1Y/Op+mR6
19Sx+fEku16wKBgQC0KQ7RjuZ95N2a4pUe5En9EtD8MU4Nhs/iC5k1d+yAUn8jIT9P
20lzCUo8NEKheMN2Qg2Dor8jlPkdNIc4qM7TKWUxQo49IlFlCzgPCnydRac3HsrMhw
21e1ke/pIt3FzEArR1d27I0xcRTL3TKm4M2ynPjWJPFj0peHue33KNL/A+IQKBgEpL
22awd0Sxo1wEZcG9gmwf32C01wbzuTn3lCsHB7Ryj4GtCR3nVclCJ50U24zjzu4Fhi
23bj1tgA8xhzSs3fOR5phlQkKsrWtQfJtFGm8CnEn7LBDlVMsrN7Dr/qRrEuro4HHy
24GDbq+8y2fO5glr955BqLMOadprf0imRnDeQ0OLffAoGBAJio+X+xpglgMOC4BeH9
259LcYi9nUEw8MDJNGo9/3e0XKA7spd3HShLDvt8YZhFJ2m168qBpGfezuw0+jpWxy
26PV9q0dokAgDx4pvCzIKaptZ1D30CWXJZHq25VK1tA41PCUIOh8JD5+R0MpxA5rn2
27DbqL4Vq7K7K0imGENYhHdyM+
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/clientchain-cert.pem b/plugins/tests/certs/clientchain-cert.pem
new file mode 100644
index 0000000..acd1e3e
--- /dev/null
+++ b/plugins/tests/certs/clientchain-cert.pem
@@ -0,0 +1,45 @@
1-----BEGIN CERTIFICATE-----
2MIIDuTCCAqECAQQwDQYJKoZIhvcNAQELBQAwgaAxCzAJBgNVBAYTAkRFMRAwDgYD
3VQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0b3Jp
4bmcgUGx1Z2luczEkMCIGA1UEAwwbTW9uaXRvcmluZyBQbHVnaW5zIENsaWVudENB
5MSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdpbnMub3JnMB4X
6DTIxMDIyODIxMDIxMloXDTMwMTEyODIxMDIxMlowgaMxCzAJBgNVBAYTAkRFMRAw
7DgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gxGzAZBgNVBAoMEk1vbml0
8b3JpbmcgUGx1Z2luczEnMCUGA1UEAwweTW9uaXRvcmluZyBQbHVnaW5zIENsaWVu
9dENoYWluMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdpbnMu
10b3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAphvoJBbi/rDvm3+X
118xok0sLCJvCRuUpSbU5wEmREQlkoOGmWK4l6r1JyOphKRBo8+n2MxPiCMvAmTrqx
12VlBmkcmyrwWj392Nga+2SLWTziASk5nFrrhV6U79PkgXnETV2Wk1/FNVIFkB8N+B
13undsTce8LLiCs7hfA5CK7ctJg8fqsAsmgKBNGzBRWwkbvxZPd6xlY6foIJeD7PQ2
14elvTmrD6WXSZq7GshFpDEkL3AifqrPMdsTnbBpyGgJ/fBM1b2dx9k53e25mgEQmn
15iSuYQxn08BsUT0FOvav8ksZLBQz859fuqCtwhikpODO635fD9zK5YkBPlVl+/5xo
16SvKOywIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBh4zeSKjENfY+VDLtPssaNQz2a
17R1ioY40lZ0WoihDSrfG32dqTK/R2YsLKBABjJ7uRYS1NIBMrtS2OktK8BWD5IUTF
18FuGuWilu6IWiTKZrLiZh1rsilNDVqwhorRPxDnbF+qVt9EMIvzKnKdJLGF+CWHN9
19yYJDeTD8MK5uR7zUJR3PsgW4ve5pFTi7z2UJ/xRvgOds6bmeeQnvaWDEL7k2+hrr
200G899A086NL3htzaOnIllg0xo2D1o4ToncAJn+cUQVJmHZSg9HYiD4Lg3z8uXPAl
21rt/MX7dBm4dnImLXbSg7N3e8FdUtz+kZT9z+beKAeIe9JTbpxtsVUTzUZBBA
22-----END CERTIFICATE-----
23-----BEGIN CERTIFICATE-----
24MIID2jCCAsKgAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBoDELMAkGA1UEBhMCREUx
25EDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwSTW9u
26aXRvcmluZyBQbHVnaW5zMSQwIgYDVQQDDBtNb25pdG9yaW5nIFBsdWdpbnMgQ2xp
27ZW50Q0ExKzApBgkqhkiG9w0BCQEWHGRldmVsQG1vbml0b3JpbmctcGx1Z2lucy5v
28cmcwHhcNMjEwMjI4MjEwMjEyWhcNMzAxMTI4MjEwMjEyWjCBqjELMAkGA1UEBhMC
29REUxEDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwS
30TW9uaXRvcmluZyBQbHVnaW5zMS4wLAYDVQQDDCVNb25pdG9yaW5nIFBsdWdpbnMg
31Q2xpZW50SW50ZXJtZWRpYXRlMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9y
32aW5nLXBsdWdpbnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
336rUgOZ9pAOxrcgeeOT3Vmu1YmY2O/C9tXhpKzDzjTaWUzcdDg00KdsjXfgbDzSiV
34uvMzjX63aKpmqeFG+05D2VzQGit3knqerUgl10FnTotiJGF5CU5/gY1aPxTJ7rj2
35tD6LINBkJcPTyQ4MoJT19pssvCax9erY1RxoXxLblJ+31C+VvrftdmBP4nVKXK26
364anb1oUQhkgpXpJimJBmF+v7NbDs1Wh21Be80KXUh9SKgePhSQblr2QlRcA7jLgJ
374PMjZ+KYF+da+4RB7s+DvTXVDMn9AL84E1w5Ut1E8XZV+u4RjWPvNdhK/7GnuxOR
38C9SdxonqkPQ8hiI7thP9bQIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MA0GCSqG
39SIb3DQEBCwUAA4IBAQDKQeiDbyr0/7sEhX33MmTDv84GeWgKl9qqHecx+d/0vImb
40c8XHK0PDa4lVqo/BW4P1hjKzpt2DW35kbOhuqGqM0lasIczef43aCDDEBLwstAe6
41qMoyWGVGoAQbpwT3li2pMrsIYoPwMvoSGNUphjrkdpviff2POkLly7a5RrR1X3qt
42Dai6eYbeMCr9NdgW7AZ5++/sKlFoe+zVk/Ed31s4D2lh3awrApZhVgcoquPmEwpt
43gm+OgRmHw50U4SF3ZaJPwDyLMbx+clH/bgUg0+Za9e53Br1NtGKmw7hh/7CG/hy0
44yxeLd930pH4vZu7s0XM56N/ckkfUzRkAH8dSmhH4
45-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/clientchain-key.pem b/plugins/tests/certs/clientchain-key.pem
new file mode 100644
index 0000000..0263604
--- /dev/null
+++ b/plugins/tests/certs/clientchain-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCmG+gkFuL+sO+b
3f5fzGiTSwsIm8JG5SlJtTnASZERCWSg4aZYriXqvUnI6mEpEGjz6fYzE+IIy8CZO
4urFWUGaRybKvBaPf3Y2Br7ZItZPOIBKTmcWuuFXpTv0+SBecRNXZaTX8U1UgWQHw
534G6d2xNx7wsuIKzuF8DkIrty0mDx+qwCyaAoE0bMFFbCRu/Fk93rGVjp+ggl4Ps
69DZ6W9OasPpZdJmrsayEWkMSQvcCJ+qs8x2xOdsGnIaAn98EzVvZ3H2Tnd7bmaAR
7CaeJK5hDGfTwGxRPQU69q/ySxksFDPzn1+6oK3CGKSk4M7rfl8P3MrliQE+VWX7/
8nGhK8o7LAgMBAAECggEAAfTqMyKh4eYrrGVAYPi53lG0/8htrwUVG3yFDXJo628p
9biCwSCsCavZJqi8JEOxOM5UvB1L2FauGh/7i/+VKkAUUOcOTPpvZguGTACBDcXYn
10Qd3Z2kkJmgn4Kbenr4uQCVOX8zT4F710rGW1nYCyoefsa4pw37UYSW52dH6kiwzW
119k4X251nDMl/twBdOcjZbL768IEa5l4nySLpUNwfrVbSb1NzBoH0dVioh3DTLjt6
12gaShW4eIpaKczht1U97n6/7WNLl6vHX/mR99k/py8OhzhR1ccYpd2IfSHAWyQT0M
13K8BoNnkjICrr9oc0FCr2BVJa3IzKHlhukF4GTZiGYQKBgQDWCHTwAmwL4FFEBVhj
14pZne/sjaZc8TzPPxA8SkmxwDIZrM7tSu7qUuYgWTM432jZbLILWTyGfXf2PpqyF6
15wOpoBJj1ETkre8ZfRmYvsSvS5vtjF3Drszol+XvZnOclfB5VG3m5P2vYkQ8wI9OE
16Y5jUBgDj0RsCNd8QnrC1u54U/wKBgQDGrd5y8S9kUT0P0lkZit7bYjSPJExtClXt
17V7YNTjELrVCdc0jranxBWaub8NP3e6TGTi9HiQWvk2eOAS2qyccqlK4+YAK5XO3D
18EpFUNNcClq8CErw2POuCAKajrPuSp6vd6q8h4lTzDExVctQS4R9fRKKFBKkPUV5G
19UiKFllnKNQKBgQDBGIQXfLfpxwjKK2BhFihKDOc8UhmOrZtvV4zzTJTrJkg4l0f+
20QoN34ytQcHSleXwP6oSmvWkh/GYxjBj6XE2eZndwsYc4ecSwdB0A7gCxl345Gg7g
21NqRBWmGoJGxNXzsmYVFiFZvAmK5xKgFMMWbR8lCfOCn7xopmviSC8K9gFQKBgFRb
22KmH/SbH8VELNews/TVQ0pEBKlzCM/OLjJOcNVgGxOtM/Say677sHibeST0168AFK
233QQwh3t+yK8gjPVA6xGHQ1w0g7OUY1c6IP5x2QC+XdwxfDxDLXNrN1WzcrVX/78f
24j/CBGrR/ekGlmanSb/GRQLfdvLJGSBLveLzjk4gpAoGBANN9RUm/aRz3dDBWex46
25kJ15xKJfLZiUeyDvY5+5d7YF4/tw5LU4XmKQNhiojHecykrTzPUMaGyMrbMPNn32
26WFW9CKMjuBEwWpMDJJb1/5NLEvpwu++sr7bUPZkQl76ot6OqgNHodbP8ATqrNr80
275b8FrEN1LyfkTbabxNyAWcA0
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/clientintermediate-cert.pem b/plugins/tests/certs/clientintermediate-cert.pem
new file mode 100644
index 0000000..608a8fa
--- /dev/null
+++ b/plugins/tests/certs/clientintermediate-cert.pem
@@ -0,0 +1,23 @@
1-----BEGIN CERTIFICATE-----
2MIID2jCCAsKgAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBoDELMAkGA1UEBhMCREUx
3EDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwSTW9u
4aXRvcmluZyBQbHVnaW5zMSQwIgYDVQQDDBtNb25pdG9yaW5nIFBsdWdpbnMgQ2xp
5ZW50Q0ExKzApBgkqhkiG9w0BCQEWHGRldmVsQG1vbml0b3JpbmctcGx1Z2lucy5v
6cmcwHhcNMjEwMjI4MjEwMjEyWhcNMzAxMTI4MjEwMjEyWjCBqjELMAkGA1UEBhMC
7REUxEDAOBgNVBAgMB0JhdmFyaWExDzANBgNVBAcMBk11bmljaDEbMBkGA1UECgwS
8TW9uaXRvcmluZyBQbHVnaW5zMS4wLAYDVQQDDCVNb25pdG9yaW5nIFBsdWdpbnMg
9Q2xpZW50SW50ZXJtZWRpYXRlMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9y
10aW5nLXBsdWdpbnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
116rUgOZ9pAOxrcgeeOT3Vmu1YmY2O/C9tXhpKzDzjTaWUzcdDg00KdsjXfgbDzSiV
12uvMzjX63aKpmqeFG+05D2VzQGit3knqerUgl10FnTotiJGF5CU5/gY1aPxTJ7rj2
13tD6LINBkJcPTyQ4MoJT19pssvCax9erY1RxoXxLblJ+31C+VvrftdmBP4nVKXK26
144anb1oUQhkgpXpJimJBmF+v7NbDs1Wh21Be80KXUh9SKgePhSQblr2QlRcA7jLgJ
154PMjZ+KYF+da+4RB7s+DvTXVDMn9AL84E1w5Ut1E8XZV+u4RjWPvNdhK/7GnuxOR
16C9SdxonqkPQ8hiI7thP9bQIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MA0GCSqG
17SIb3DQEBCwUAA4IBAQDKQeiDbyr0/7sEhX33MmTDv84GeWgKl9qqHecx+d/0vImb
18c8XHK0PDa4lVqo/BW4P1hjKzpt2DW35kbOhuqGqM0lasIczef43aCDDEBLwstAe6
19qMoyWGVGoAQbpwT3li2pMrsIYoPwMvoSGNUphjrkdpviff2POkLly7a5RrR1X3qt
20Dai6eYbeMCr9NdgW7AZ5++/sKlFoe+zVk/Ed31s4D2lh3awrApZhVgcoquPmEwpt
21gm+OgRmHw50U4SF3ZaJPwDyLMbx+clH/bgUg0+Za9e53Br1NtGKmw7hh/7CG/hy0
22yxeLd930pH4vZu7s0XM56N/ckkfUzRkAH8dSmhH4
23-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/clientintermediate-key.pem b/plugins/tests/certs/clientintermediate-key.pem
new file mode 100644
index 0000000..13f6887
--- /dev/null
+++ b/plugins/tests/certs/clientintermediate-key.pem
@@ -0,0 +1,28 @@
1-----BEGIN PRIVATE KEY-----
2MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDqtSA5n2kA7Gty
3B545PdWa7ViZjY78L21eGkrMPONNpZTNx0ODTQp2yNd+BsPNKJW68zONfrdoqmap
44Ub7TkPZXNAaK3eSep6tSCXXQWdOi2IkYXkJTn+BjVo/FMnuuPa0Posg0GQlw9PJ
5DgyglPX2myy8JrH16tjVHGhfEtuUn7fUL5W+t+12YE/idUpcrbrhqdvWhRCGSCle
6kmKYkGYX6/s1sOzVaHbUF7zQpdSH1IqB4+FJBuWvZCVFwDuMuAng8yNn4pgX51r7
7hEHuz4O9NdUMyf0AvzgTXDlS3UTxdlX67hGNY+812Er/sae7E5EL1J3GieqQ9DyG
8Iju2E/1tAgMBAAECggEACyYJXtNUoIeaXvM/r8ZhJBfMEpcnyJDUKBklnmfyABky
9ZUfmzBDXw2as3b6ihFc+LYAp3bm8KouVjtI1lfBUxrli5StVZa7PZLm9mmjv6Eo0
10ojfDEQ8afWPieoaZRO6iQVOLNkbPyv9vSuiQ7vvEZy9dw54u69h47j6IMqPprDiG
11ropUNeGAvTnh1Vf9/8aCHEvHUNHcc4zjzGiQ+E60JgnbpGVeJKoeiMgrQE0yjweo
12KyKA47Y6vqP6+AxAaPplXtmrx2UCbMjktHNvLvg42+2UlLS5roiwmJYEN9c6iT6t
13y82MJrjEFGZyLG2u6ZQANSJiIWaCnOyT1o2deJ8NoQKBgQD7UxivDTuljQD0so+E
14JX9UaFZ9PgS+8LC9v56PciL4XQ7bcCVP5vVgZZPABiQ9i989Wq7qI042Jrfu5qtE
15SthlOAu80GvAQV+Oujwo7ZzM6ciQtjMsj63r2uayWXnmQ07QcIg7x7y161Pt9Bqr
16LIDrqHziIj/lzT7+6QKZaQwFaQKBgQDvEuSC14CBlMhy2jji71kB/3Ya3c+8dP+A
17kQZL9wEWK4a4dm8IaTS8jl1/luhQUzFRMyh2rWaTqqigSe3dvs5DRblhE5NPwTSI
189TO7t1EnzjW3R8LxZZsySyiSFnZ/8mR0empxq0Mov37OdXBj0tXuuzREf/hwijWh
19WuLxJUSjZQKBgAIDZ2Y3l+u6lnBfYdDwL/XwJAk6zvTsnq3WdCG4C1mr/St62YGr
20WvnbtnRKWE356d7m9BHCGKVMaBrM1EBmzRb6fPWVQde3blmJWmQFi0UE9mtaWkyY
21Fg+WoFR7bQOQNHhs/lpkPjnC2dhFJVWLtLiuj9mL5rEjlMab/T5XXhZJAoGBAMEP
22FZ8fXbPGrTQqSwPfWpZFcF9zvbynEmkFM/uGRMddcNZnNXSqWJ7nrFNLTuEGvW2g
23DU4A6zPV/YQrDz4hRjmHBZOCFlSyZbUvpY4yFAQ7/p66AY+kiHZNwT5vi1P5Luvs
24qyaNsZcnRMR+i7rg2EeHv0aNvNdMlNBvL5KikNINAoGAU2P/phdwJOUcqgHavQcQ
25ureTEyZ5i5AeNomNeHSj0slG24V9nxOqEL7D00JKln7oAPovYBUWocEnF39uBJe0
26p0Hy7fCCK6EI8/0QyiQuuZmJfDEEvjQqE6irONNH63r2UwDEpDNGFvGsZNuWHLZc
27SXADu5oSNu6o6IydiyOx528=
28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/expired-cert.pem b/plugins/tests/certs/expired-cert.pem
index 77a9166..87fc8e4 100644
--- a/plugins/tests/certs/expired-cert.pem
+++ b/plugins/tests/certs/expired-cert.pem
@@ -1,24 +1,24 @@
1-----BEGIN CERTIFICATE----- 1-----BEGIN CERTIFICATE-----
2MIIEETCCAvmgAwIBAgIUFDsP6WnV/uqeQMpD/DYSqouE13kwDQYJKoZIhvcNAQEL 2MIIEETCCAvmgAwIBAgIUVDKkhcUoYFnjYCw12tScPIqQzqIwDQYJKoZIhvcNAQEL
3BQAwgZcxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN 3BQAwgZcxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN
4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9u 4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9u
5aXRvcmluZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5n 5aXRvcmluZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5n
6LXBsdWdpbnMub3JnMB4XDTA4MDEwMTExMDAyNloXDTA4MDEwMjExMDAyNlowgZcx 6LXBsdWdpbnMub3JnMB4XDTA4MDEwMTEyMDAwMFoXDTA4MDEwMjEyMDAwMFowgZcx
7CzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gx 7CzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gx
8GzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9uaXRvcmlu 8GzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9uaXRvcmlu
9ZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdp 9ZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdp
10bnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyeHKwKFjJWUX 10bnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwg1dmGT3rVqM
11YHKsisypUf9dHlIPQAISyGP1BX6UL26ZLvE6kKbx3LFQ9W2POGoQWlzFiB1soGeV 11beVWWLy8EAiq9re07AF8sTERy9oIYF5EUq9f0xO53mwwqIWV77O9mF99/kDFGQuQ
12WDd0U0JtWdCKmOXWdcXpupQlTSUtRCMDQkfqLN8GR5TBTd73rezp5mz08nMfLwu0 12NOnICMSHXNtMXEXzfBaMighw0uyCh1o/VCejNQ5x/HU8aLh930g5DIcOJQ3fZ4v9
13p5VQ191Ui8JHFgrAOalAn8Uw5De8vj4VmTXmU5NJ2UFoC0ddU/Th/lwRCayHc1cn 138kBaie7+aPgRMVDM1vIrILfedq9Kt56zvPizkXhDeqxjKyIZdrdoBlX5zAfftWtY
14MVq2F7c/uhMUUQYNBmJy0pxoHawp+j9NKl/xIYsjgQNgahQyNuswuGHjaEwhPu+7 14HpQ+lkThSSXqQnchN6S2JFejmRtsNnceDVOBBdvlzmH0NlfwjynLK3/EJooTsINy
15G03XsW4ehu+H1898M/MkSln6LQAU1syoJ8ypPM8tV+zgx4uwj7udnZ2hceN95uW7 15i9dXD8/Oe8r+UA+nokWvnWC2IAUJjpxW+XAyTG/NofGwX+PwquT0YD5cSlODIwZA
160PWg5DQyUwIDAQABo1MwUTAdBgNVHQ4EFgQUt9ps3KJ1XiMuy/ijFBjMzf6jgwkw 16WAimygWLqQIDAQABo1MwUTAdBgNVHQ4EFgQUsKyJAwR9OXWEcSZMQz73GfpxCJIw
17HwYDVR0jBBgwFoAUt9ps3KJ1XiMuy/ijFBjMzf6jgwkwDwYDVR0TAQH/BAUwAwEB 17HwYDVR0jBBgwFoAUsKyJAwR9OXWEcSZMQz73GfpxCJIwDwYDVR0TAQH/BAUwAwEB
18/zANBgkqhkiG9w0BAQsFAAOCAQEAVPBZwMHbrnHFbmhbcPuvYd5cxk0uSVNAUzsl 18/zANBgkqhkiG9w0BAQsFAAOCAQEAYKFGX7J3Fc/T9s278w61E2dSsY4DS/mjSDik
192biCq5P+ZHo10VHGygXtdV4utqk/IrAt2u5qSxycWPStCtAgTd3Q8ncfjOkaHM4z 19fMWvod6eKw0fE3wJOnkWxjEH3VywTY6CmHd/oiJOaD8lr/Vk+BJfYNVBaVNmguyg
202bxTkhLyQeU8NWPuDBqDszo2GOaFTv+lm36LEKiAfqB1tjQVePSkycdrWIhkamBV 204LXoWz9Benx0bAIeuDbNAhOvA4H4aIz8UrD9lKFvKdRp42gPMLtMEbzbLcBdT95D
21EgMe6uHLdU7QQk1ajQfrBdakN1beqki/dKieA6gm+XF/QS4SSYINmsHB/2X5cT9U 216BX7EhYm7vTnpitLPgFxVCsJ1JFqv2AQfUm+IkqQkezPs5x0tWLyrvCDNRGJ0kfv
22b/KMB8xurCnuJQuk1P4VsSkJCOSeHjWZgK9pKNdsIJZr4wDVfhjQgU0XT6xakSf7 22UuowpUZXDOh3k1vB+xaSOFviieLaCW8TSdd5FZgI2HQj4e6vCKsMGuKKZXrMUTI/
23eCaHtO0VKsbLZoiTmpxidjsdYiXyeKYIQNtUpTjyJ5V/cZsq9w== 23qtrFlUfsOuwourfC5LMHtCyYo5B3uvAWT1eTXxhrGqyleSlxJQ==
24-----END CERTIFICATE----- 24-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/expired-key.pem b/plugins/tests/certs/expired-key.pem
index c1510b2..c5bba56 100644
--- a/plugins/tests/certs/expired-key.pem
+++ b/plugins/tests/certs/expired-key.pem
@@ -1,28 +1,28 @@
1-----BEGIN PRIVATE KEY----- 1-----BEGIN PRIVATE KEY-----
2MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDJ4crAoWMlZRdg 2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCDV2YZPetWoxt
3cqyKzKlR/10eUg9AAhLIY/UFfpQvbpku8TqQpvHcsVD1bY84ahBaXMWIHWygZ5VY 35VZYvLwQCKr2t7TsAXyxMRHL2ghgXkRSr1/TE7nebDCohZXvs72YX33+QMUZC5A0
4N3RTQm1Z0IqY5dZ1xem6lCVNJS1EIwNCR+os3wZHlMFN3vet7OnmbPTycx8vC7Sn 46cgIxIdc20xcRfN8FoyKCHDS7IKHWj9UJ6M1DnH8dTxouH3fSDkMhw4lDd9ni/3y
5lVDX3VSLwkcWCsA5qUCfxTDkN7y+PhWZNeZTk0nZQWgLR11T9OH+XBEJrIdzVycx 5QFqJ7v5o+BExUMzW8isgt952r0q3nrO8+LOReEN6rGMrIhl2t2gGVfnMB9+1a1ge
6WrYXtz+6ExRRBg0GYnLSnGgdrCn6P00qX/EhiyOBA2BqFDI26zC4YeNoTCE+77sb 6lD6WROFJJepCdyE3pLYkV6OZG2w2dx4NU4EF2+XOYfQ2V/CPKcsrf8QmihOwg3KL
7Tdexbh6G74fXz3wz8yRKWfotABTWzKgnzKk8zy1X7ODHi7CPu52dnaFx433m5bvQ 711cPz857yv5QD6eiRa+dYLYgBQmOnFb5cDJMb82h8bBf4/Cq5PRgPlxKU4MjBkBY
89aDkNDJTAgMBAAECggEACrLFfNnQmD24NGs/S4e2/VpsA9xTZI/3kNkDNgxULANP 8CKbKBYupAgMBAAECggEBAJ2mdCKJ7LoWdT4W8pZ3BqZUFGkKCF8wOhhOUDH3+ZQp
9aNZtxRajwI9A/BCXQ2UTgsZhzWnJxOJYXrlpl7PweY78mUesysb3MOUC6QisUm0M 9IYK3XbdDMF7mMIXIuW4a7W4sLlTwU/Ar98U1JMESwRIMS7YvUke+ngDKKLcDVGwY
10kimfdktHWOnAKLFFLNleN9DUVjjVkTeslijqhNX80f80py1grG2UuCLKCX4OqYIm 10Qpjg9vP0v2Al8qT1NbW/nDF0S2aJJbWfAvnblHK5ClFHL9iL107NQYJ8PqzXbnFL
11qACE8TMmSZLz42AO96TndNtKplQ8LuGLEmByW95wEfhx3Gm4ckkL7qII/U3DnQXr 11gCQRiZxVHlrbn/73ZUMHPGEoU0711U9hSjrsqrRuSAMC+V38s4HxOomZWutlVAHF
120T+3xLaj+eNJzYDpIFZiw4sNzOuAyCz+4Cc4sPDuMnzquXF+enpkemoycC1RmEpG 12HwClNZBqRO+a2njPyUuV9DM/rl5Tm9IQ89iFo3/QEORICK77HjJYhi+UzdfI5F35
13KIDTwmFsc8TrbGV0qifC6fsCrDivdYLqL7R/q3IBQQKBgQDmfvO3VYTEKY8NA+AT 13UntRJt+WLaiAP+K6Vt6oxHSm58qXnOkeLzaAunTTie0CgYEA6OLYfme8xe5zYXWX
145s6+7NTxRsXxJUCEhCNBWimSH3EzmBAvrodLY6A0oYg8i81bgNX1I9GPVXJZ/QA7 14rqmKNYdcVfMkvL+vUfVT475o/piRtE54JC1LYWEFAN8paxEWHD5HZMy0+ONNXfGm
15ukd84HUIQoGS5Usmo4rp+kz4P6KkLXDemZtWPU5GXxicfajHRQlkbW6St6SpV7IS 15zyNNTN/Lagz4WcpdFzKQmhfdro7DzRiDfdvwSLmaZDyE41PPPVVvfrI9IeDiUNY4
16ibJcDADeoiaPL1xvue1ToP/LoQKBgQDgOFHjYpep00gabvjXfYW7vhrg1vVwaKUM 16nWLSb3sWo96Iuns+RoMqeA9wkqsCgYEA1U/UqeVQVTPlrWyiB2VXoI1xvFCCJTf8
17rf0+UW8Exk4nbBw0eEC2YjxIwzdktlkdbzGaXYULnhg8GnfxYesMOpCLPw1JdB8o 174NC0gcisxLRrtINk0BwrUJrRy0x1OLpJWiKwUl/W1GgvPPfhbYcUOb669JNtTIjY
18ixETAFpW5bKrUsjEFRUGhzWnsCSFIQ4smpmtGLTxOQ8AkoDdORY5Z+Wv7JtFF6Do 18FeIZblCTjz9GzKKmXeDciXvccyEdCJVUlPO3/e2JiJ4mCDjULprifq0a2gcQevFS
19PSoblckZcwKBgB3TD3YJesRnHDty5OuuUdIikuslXTd2uoJrFqS+JeLibqNeabnB 19PfqVULhBOvsCgYB5KfS7J1vGmv36ucSWAe0/VlKLATqe3RfpCzt/JQTZWSWNaroF
20u3/lxDULMbWj4U6VvRmbKOKDC+jY887Gq7lc0cff0yROxwqY3sCnwo3crg7QUmp7 20EG/ElUaWIoUZCEW5oglg/0Q0rYYGF4DTCingkhrx7ReVF70BIbSsBzi15d8nKNbY
21Nb5S8G3qoCSfndcq96wm/Me/O28uCbycVJfUdchY8uRUHIHYbP0FOBQBAoGBAMgh 21t4I3RCF4fyggYe1TmsysXS2DH85/gkToVY7oo2CvF0uJwi8vXnTNDDNkiwKBgHKs
22fPX4imaKr1DovDObVkK87EDDnU84GBm5MtDs3qrkVd3aIVK0Aw7HoAdSN58tI12i 22mAc94BHt9GtnGzQepx0I7TvvjAe2MZwqlt+uojKdS8mfWXMHscGDeYVxdRMqEoUC
23YiPmVVqJQhhjh6tsOuAvZdTj8ngdrbICbrsHFZt6an+A5LIgHyQ0iy+hiPdLCdvG 23YQfnvfYyjDKaj/XxyE3C237gQsICTyh0hHdpmepIeidIyWdumyDOFZVPF+ylWvM4
24ImTeKKMmyr04Bs1upueWVO0xw2VoMbcY4Py+NUEBAoGASQqedfCSKGLT+5lLZrhP 24kpFQQb/QRWHmKyti2KCBLw5G/fUaBryLGfprE6ZBAoGBANy5rr41A679UQZ0abev
25CbFVMmswEPjBcRb1trcuA09vfExn9FfUNFnnw3i9miprED5kufvAjb+6nduXizKg 25bOZb7YWOHYp/wReJaQbvLAyR30os3aEY/0ht9S+OWdrgGMezPKvsx2Sqr/CwoFXI
267HQYHCwVvakgtXgbiDMaNgYZcjWm+MdnfiwLJjJTO3DfI1JF2PJ8y9R95DPlAkDm 26esiklpknr11maEPxnQJYi4FYiXS1a3NCg7yBvKzFEgx2XnMAC3s6zhuZXaFq4zNu
27xH3OV8KV4UiTEVxS7ksmGzY= 27pm5Btrq/NZqtVXovS+UhGLvJ
28-----END PRIVATE KEY----- 28-----END PRIVATE KEY-----
diff --git a/plugins/tests/certs/ext.cnf b/plugins/tests/certs/ext.cnf
new file mode 100644
index 0000000..d09cee1
--- /dev/null
+++ b/plugins/tests/certs/ext.cnf
@@ -0,0 +1,2 @@
1[ client_ca ]
2basicConstraints = critical, CA:true
diff --git a/plugins/tests/certs/generate-certs.sh b/plugins/tests/certs/generate-certs.sh
new file mode 100755
index 0000000..78660a2
--- /dev/null
+++ b/plugins/tests/certs/generate-certs.sh
@@ -0,0 +1,63 @@
1#!/bin/sh -e
2#
3# Recreates the https server certificates
4#
5# Set the GEN_EXPIRED environment variable to also regenerate
6# the expired certificate.
7
8cd "$(dirname "$0")"
9trap 'rm -f *.csr; rm -f clientca-cert.srl' EXIT
10
11subj() {
12 c="DE"
13 st="Bavaria"
14 l="Munich"
15 o="Monitoring Plugins"
16 cn="Monitoring Plugins"
17 emailAddress="devel@monitoring-plugins.org"
18
19 if [ -n "$1" ]; then
20 # Add to CN
21 cn="$cn $1"
22 fi
23
24 printf "/C=%s/ST=%s/L=%s/O=%s/CN=%s/emailAddress=%s" \
25 "$c" "$st" "$l" "$o" "$cn" "$emailAddress"
26}
27
28# server
29openssl req -new -x509 -days 3560 -nodes \
30 -keyout server-key.pem -out server-cert.pem \
31 -subj "$(subj)"
32# server, expired
33# there is generally no need to regenerate this, as it will stay epxired
34[ -n "$GEN_EXPIRED" ] && TZ=UTC faketime -f '2008-01-01 12:00:00' \
35 openssl req -new -x509 -days 1 -nodes \
36 -keyout expired-key.pem -out expired-cert.pem \
37 -subj "$(subj)"
38
39# client, ca
40openssl req -new -x509 -days 3560 -nodes \
41 -keyout clientca-key.pem -out clientca-cert.pem \
42 -subj "$(subj ClientCA)"
43echo "01" >clientca-cert.srl
44# client
45openssl req -new -nodes \
46 -keyout client-key.pem -out client-cert.csr \
47 -subj "$(subj Client)"
48openssl x509 -days 3560 -req -CA clientca-cert.pem -CAkey clientca-key.pem \
49 -in client-cert.csr -out client-cert.pem
50# client, intermediate
51openssl req -new -nodes \
52 -keyout clientintermediate-key.pem -out clientintermediate-cert.csr \
53 -subj "$(subj ClientIntermediate)"
54openssl x509 -days 3560 -req -CA clientca-cert.pem -CAkey clientca-key.pem \
55 -extfile ext.cnf -extensions client_ca \
56 -in clientintermediate-cert.csr -out clientintermediate-cert.pem
57# client, chain
58openssl req -new -nodes \
59 -keyout clientchain-key.pem -out clientchain-cert.csr \
60 -subj "$(subj ClientChain)"
61openssl x509 -days 3560 -req -CA clientca-cert.pem -CAkey clientca-key.pem \
62 -in clientchain-cert.csr -out clientchain-cert.pem
63cat clientintermediate-cert.pem >>clientchain-cert.pem
diff --git a/plugins/tests/certs/server-cert.pem b/plugins/tests/certs/server-cert.pem
index b84b91d..d1249ef 100644
--- a/plugins/tests/certs/server-cert.pem
+++ b/plugins/tests/certs/server-cert.pem
@@ -1,24 +1,24 @@
1-----BEGIN CERTIFICATE----- 1-----BEGIN CERTIFICATE-----
2MIIEBjCCAu6gAwIBAgIJANbQ5QQrKhUGMA0GCSqGSIb3DQEBCwUAMIGXMQswCQYD 2MIIEETCCAvmgAwIBAgIUZwOhY4myaCUaPek3NM+MxbLG9vwwDQYJKoZIhvcNAQEL
3VQQGEwJERTEQMA4GA1UECAwHQmF2YXJpYTEPMA0GA1UEBwwGTXVuaWNoMRswGQYD 3BQAwgZcxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN
4VQQKDBJNb25pdG9yaW5nIFBsdWdpbnMxGzAZBgNVBAMMEk1vbml0b3JpbmcgUGx1 4dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9u
5Z2luczErMCkGCSqGSIb3DQEJARYcZGV2ZWxAbW9uaXRvcmluZy1wbHVnaW5zLm9y 5aXRvcmluZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5n
6ZzAeFw0xOTAyMTkxNTMxNDRaFw0yOTAyMTYxNTMxNDRaMIGXMQswCQYDVQQGEwJE 6LXBsdWdpbnMub3JnMB4XDTIxMDIyODIxMDIxMVoXDTMwMTEyODIxMDIxMVowgZcx
7RTEQMA4GA1UECAwHQmF2YXJpYTEPMA0GA1UEBwwGTXVuaWNoMRswGQYDVQQKDBJN 7CzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZNdW5pY2gx
8b25pdG9yaW5nIFBsdWdpbnMxGzAZBgNVBAMMEk1vbml0b3JpbmcgUGx1Z2luczEr 8GzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9uaXRvcmlu
9MCkGCSqGSIb3DQEJARYcZGV2ZWxAbW9uaXRvcmluZy1wbHVnaW5zLm9yZzCCASIw 9ZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5nLXBsdWdp
10DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKgV2yp8pQvJuN+aJGdAe6Hd0tja 10bnMub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2/3eBA4WG6xz
11uteCPcNIcM92WLOF69TLTSYon1XDon4tHTh4Z5d4lD8bfsGzFVBmDSgWidhAUf+v 11LfM6xcWywxThb1Rp7XAW3ewQd9/PdoWXEe8BJWlLfyYi1drLMcsDywhLkKmW4Vp9
12EqEXwbp293ej/Frc0pXCvmrz6kI1tWrLtQhL/VdbxFYxhV7JjKb+PY3SxGFpSLPe 121R4PAkiljjrB/ZaUMDLJ1ri3dwX4RvXG7crsU3QWFWCBOrf5V2FTRQ2m/H/KyB/6
13PQ/5SwVndv7rZIwcjseL22K5Uy2TIrkgzzm2pRs/IvoxRybYr/+LGoHyrtJC6AO8 13rVZANsU47HqTFSPiUm2j7P3wx/wtHeYC+qmNG7zZTjAYPYxfKiod0lytTSmb+h54
14ylp8A/etL0gwtUvRnrnZeTQ2pA1uZ5QN3anTL8JP/ZRZYNegIkaawqMtTKbhM6pi 146lxn3+VPEXZAQZlLvPnm/58JnXGrUv7B2yocf5MhKkLJOrGxH2hfwKISfaj2gpOV
15u3/4a3Uppvt0y7vmGfQlYejxCpICnMrvHMpw8L58zv/98AbCGjDU3UwCt6MCAwEA 15m4PUVYiDzCSpq1fPvwbUxIvdO27xprx+mrGOFM6f2UCEOc35w8FSmYiR2yQTnEJK
16AaNTMFEwHQYDVR0OBBYEFG/UH6nGYPlVcM75UXzXBF5GZyrcMB8GA1UdIwQYMBaA 16pbSQD6t1jQIDAQABo1MwUTAdBgNVHQ4EFgQUMeYgglT2aWDlF8KEeF2376AlTGYw
17FG/UH6nGYPlVcM75UXzXBF5GZyrcMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcN 17HwYDVR0jBBgwFoAUMeYgglT2aWDlF8KEeF2376AlTGYwDwYDVR0TAQH/BAUwAwEB
18AQELBQADggEBAGwitJPOnlIKLndNf+iCLMIs0dxsl8kAaejFcjoT0n4ja7Y6Zrqz 18/zANBgkqhkiG9w0BAQsFAAOCAQEAFcEg83rTJdgkp7JLYqK0j8JogSHNlDYchr/r
19VSIidzz9vQWvy24xKJpAOdj/iLRHCUOG+Pf5fA6+/FiuqXr6gE2/lm0eC58BNONr 19VxKBgQwfnjSp5A8d5+uTQ9s3QDabw8v7YeSrzYXbbjuWZ61mnl84tzOQ8LMeESnC
20E5OzjQ/VoQ8RX4hDntgu6FYbaVa/vhwn16igt9qmdNGGZXf2/+DM3JADwyaA4EK8 20CBXRCxB8Ow22WsVTVJq279SGYT+cZrdsmqGVWDi1A0C5kH+XTLAioG5CZmmxemD/
21vm7KdofX9zkxXecHPNvf3jiVLPiDDt6tkGpHPEsyP/yc+RUdltUeZvHfliV0cCuC 21S92ZoRxGyYfg33r+3X6EMcEYtHKGxCUa3EPcPOL4dq2F3nOnyjiWPZm3786H3NY2
22jJX+Fm9ysjSpHIFFr+jUMuMHibWoOD8iy3eYxfCDoWsH488pCbj8MNuAq6vd6DBk 22nsYwrEhAdUFtbYSsV5O0c/Zlc33fmTfh654ab35io1DtwmFo7q8J532dUE007EN0
23bOZxDz43vjWuYMkwXJTxJQh7Pne6kK0vE1g= 23mIQmhdrjNJJHIftgSt0fuN5m48oLOnX7vvkz+X0WLWfVTtMr0w==
24-----END CERTIFICATE----- 24-----END CERTIFICATE-----
diff --git a/plugins/tests/certs/server-key.pem b/plugins/tests/certs/server-key.pem
index 1194755..0de63f8 100644
--- a/plugins/tests/certs/server-key.pem
+++ b/plugins/tests/certs/server-key.pem
@@ -1,28 +1,28 @@
1-----BEGIN PRIVATE KEY----- 1-----BEGIN PRIVATE KEY-----
2MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCoFdsqfKULybjf 2MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDb/d4EDhYbrHMt
3miRnQHuh3dLY2rrXgj3DSHDPdlizhevUy00mKJ9Vw6J+LR04eGeXeJQ/G37BsxVQ 38zrFxbLDFOFvVGntcBbd7BB33892hZcR7wElaUt/JiLV2ssxywPLCEuQqZbhWn3V
4Zg0oFonYQFH/rxKhF8G6dvd3o/xa3NKVwr5q8+pCNbVqy7UIS/1XW8RWMYVeyYym 4Hg8CSKWOOsH9lpQwMsnWuLd3BfhG9cbtyuxTdBYVYIE6t/lXYVNFDab8f8rIH/qt
5/j2N0sRhaUiz3j0P+UsFZ3b+62SMHI7Hi9tiuVMtkyK5IM85tqUbPyL6MUcm2K// 5VkA2xTjsepMVI+JSbaPs/fDH/C0d5gL6qY0bvNlOMBg9jF8qKh3SXK1NKZv6Hnjq
6ixqB8q7SQugDvMpafAP3rS9IMLVL0Z652Xk0NqQNbmeUDd2p0y/CT/2UWWDXoCJG 6XGff5U8RdkBBmUu8+eb/nwmdcatS/sHbKhx/kyEqQsk6sbEfaF/AohJ9qPaCk5Wb
7msKjLUym4TOqYrt/+Gt1Kab7dMu75hn0JWHo8QqSApzK7xzKcPC+fM7//fAGwhow 7g9RViIPMJKmrV8+/BtTEi907bvGmvH6asY4Uzp/ZQIQ5zfnDwVKZiJHbJBOcQkql
81N1MArejAgMBAAECggEANuvdTwanTzC8jaNqHaq+OuemS2E9B8nwsGxtH/zFgvNR 8tJAPq3WNAgMBAAECggEBAIvJDUjQVpXxByL8eazviT5SR0jBf6mC3tTWykQRb7ck
9WZiMPtmrJnTkFWJcV+VPw/iMSAqN4nDHmBugVOb4Z4asxGTKK4T9shXJSnh0rqPU 9/bBEiRrnhDRf3CS9KP4TvO5G8BUU3a2GHYzM08akuKXeiiODidfyfbQ1nUZBAdi9
1000ZsvbmxY6z0+E5TesCJqQ+9GYTY1V357V7JchvaOxIRxWPqg9urHbru8OCtW/I5 10FVFF7tK8YcflkVfpTMOMMSggm6m33fc58sQvmQ/0U85XuJvnOEkeJ9pQJa49e8GR
11Fh5HPUZlgCvlMpjlhyjydIf/oXyVA3RNsXlwe8+2cKuGIrjEzm2j9o3VF0sctTX0 11lpCQImF7ygltHPEz4o8qOtNMuPxiHOxpc517+ozQULZk153NTfGok1XctDFFZ3YX
12ItP8A9qDmDQN7GIWX0MW6gncojpS1omC2wcFsdjj/xfPyiDal1X4aq/2YqG8351c 128okLSfcqZ28mdHYSvI9xf60Cm7cT9tunXHwZ0f1esTFiVYpAp+oTJqtdYxr/fYlL
13YlM/+6Va0u9WWE/i64gASTAVqpMV4Yg8y0gGycuA0QKBgQDbgI2QeLd3FvMcURiU 13oO8G8iIQ7LjdJfgo84PscpKdSRCq3BfnmER1Eyg6hrUCgYEA/0hL5Y/haz/2jYGy
14l3w9qJgw/Jp3jaNC/9LkVGGz4f4lKKB67lPZvI4noMK8GqO/LcXgqP/RY1oJojoA 14aa8yZSuD1ZcWtj7pLKrBQnHPHIHsjSBggWhopvonCFvCjgSS1pOFOUAwMGc0T+Dw
15/6JKVvzYGASZ7VgMoG9bk1AneP1PGdibuTUEwimGlcObxnDFIC/yjwPFu3jIdqdS 15rWo3w8cEUyECl3Bw8gbCWtRXaigzU9TPgCWyx1j5dTopQhLObzS/m7fJFElnYNru
16zZi1RZzyqAogN5y3SBEypSmn9wKBgQDECKsqqlcizmCl8v5aVk875AzGN+DOHZqx 16jqhsUfWS+NKk8a5+A7i9lv4iBLMCgYEA3Jws3Lfj/Xs7LljrvryTMpPthvUGBcyt
17bkmztlnLO/2e2Fmk3G5Vvnui0FYisf8Eq19tUTQCF6lSfJlGQeFAT119wkFZhLu+ 17U9Qmf1Hmur90RP5V1rx4FqPQzIeaGQyZDNIUnkhBSqQZNCts3Rzay7N4uQzk8OEg
18FfLGqoEMH0ijJg/8PpdpFRK3I94YcISoTNN6yxMvE6xdDGfKCt5a+IX5bwQi9Zdc 18S8Llnw76wLwi0SJ4okDtT5tpTR6fcS0M9lGN+zvvfUB4+ul8oub0pMcyme/pywEz
19B242gEc6tQKBgA6tM8n7KFlAIZU9HuWgk2AUC8kKutFPmSD7tgAqXDYI4FNfugs+ 19ap+x3xAQPL8CgYEAiYOBVtTNof9fqdRurh1w8SyipKDx3BRBeQ02c7tozLt0GIWT
20MEEYyHCB4UNujJBV4Ss6YZCAkh6eyD4U2aca1eElCfm40vBVMdzvpqZdAqLtWXxg 20VsJOdXwVIJyFTglKrAnlXvSjwL8nX8wU+eVYyr5fJwSGJ9urC8T2VwVBXW7wTz04
21D9l3mgszrFaYGCY2Fr6jLV9lP5g3xsxUjudf9jSLY9HvpfzjRrMaNATVAoGBALTl 211Zf5GQdlwW8mIHCPATqR6Kj0yVfNN1BX50L0rqWxmRWnQoUzXn/aqQaWfp8CgYAW
22/vYfPMucwKlC5B7++J0e4/7iv6vUu9SyHocdZh1anb9AjPDKjXLIlZT4RhQ8R0XK 229693/zEeR8EejyVkAy/z+RCml0XcPrXg31pusPErihkpwazgIVkDSmTHlmqFpxkc
230wOw5JpttU2uN08TKkbLNk3/vYhbKVjPLjrQSseh8sjDLgsqw1QwIxYnniLVakVY 23C5cX73/UrIbvNoIr9wAUawfrhBsltNpu6MiNKbsTa8LYMRWMFuReAFkTLVf+KWmL
24p+rvjSNrNyqicQCMKQavwgocvSd5lJRTMwxOMezlAoGBAKWj71BX+0CK00/2S6lC 24D2yPtmq1iIvP25UdRJw9t3teKWsWtnZK6HtVNM/r8wKBgQDKlqUpy8r4KK+S2w80
25TcNcuUPG0d8y1czZ4q6tUlG4htwq1FMOpaghATXjkdsOGTLS+H1aA0Kt7Ai9zDhc 25H7rAQJo1DgXsYrgSa2gfppSKro4lm3ltyAfVIrKQKP7uCo9xTGKVQAUPttMs2+17
26/bzOJEJ+jvBXV4Gcs7jl1r/HTKv0tT9ZSI5Vzkida0rfqxDGzcMVlLuCdH0cb8Iu 26nwbwvt7/nG7G1Dk/C/t6b7SJ80VY5b9ZZKIJ0wOjajLufSjPNCe0ZTRn32XusZUn
27N0wdmCAqlQwHR13+F1zrAD7V 27nYGB5/QXYr5WGV9YhAkRsFJYgA==
28-----END PRIVATE KEY----- 28-----END PRIVATE KEY-----
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index 29cb03f..72f2b7c 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
21 21
22$ENV{'LC_TIME'} = "C"; 22$ENV{'LC_TIME'} = "C";
23 23
24my $common_tests = 72; 24my $common_tests = 73;
25my $ssl_only_tests = 8; 25my $ssl_only_tests = 8;
26# Check that all dependent modules are available 26# Check that all dependent modules are available
27eval "use HTTP::Daemon 6.01;"; 27eval "use HTTP::Daemon 6.01;";
@@ -200,6 +200,14 @@ sub run_server {
200 $c->send_basic_header; 200 $c->send_basic_header;
201 $c->send_crlf; 201 $c->send_crlf;
202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); 202 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
203 } elsif ($r->url->path eq "/chunked") {
204 my $chunks = ["chunked", "encoding", "test\n"];
205 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
206 my $chunk = shift @{$chunks};
207 return unless $chunk;
208 sleep(1);
209 return($chunk);
210 }));
203 } else { 211 } else {
204 $c->send_error(HTTP::Status->RC_FORBIDDEN); 212 $c->send_error(HTTP::Status->RC_FORBIDDEN);
205 } 213 }
@@ -228,23 +236,25 @@ SKIP: {
228 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https}; 236 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https};
229 run_common_tests( { command => "$command -p $port_https", ssl => 1 } ); 237 run_common_tests( { command => "$command -p $port_https", ssl => 1 } );
230 238
239 my $expiry = "Thu Nov 28 21:02:11 2030 +0000";
240
231 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 241 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
232 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 242 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
233 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on Fri Feb 16 15:31:44 2029 +0000.", "output ok" ); 243 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on $expiry.", "output ok" );
234 244
235 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 245 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
236 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 246 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
237 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); 247 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
238 248
239 # Expired cert tests 249 # Expired cert tests
240 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 250 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
241 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 251 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
242 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); 252 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
243 253
244 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 254 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
245 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 255 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
246 is( $result->output, 256 is( $result->output,
247 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 11:00:26 2008 +0000.', 257 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 12:00:00 2008 +0000.',
248 "output ok" ); 258 "output ok" );
249 259
250} 260}
@@ -470,7 +480,8 @@ sub run_common_tests {
470 local $SIG{ALRM} = sub { die "alarm\n" }; 480 local $SIG{ALRM} = sub { die "alarm\n" };
471 alarm(2); 481 alarm(2);
472 $result = NPTest->testCmd( $cmd ); 482 $result = NPTest->testCmd( $cmd );
473 alarm(0); }; 483 };
484 alarm(0);
474 isnt( $@, "alarm\n", $cmd ); 485 isnt( $@, "alarm\n", $cmd );
475 is( $result->return_code, 0, $cmd ); 486 is( $result->return_code, 0, $cmd );
476 487
@@ -480,7 +491,8 @@ sub run_common_tests {
480 local $SIG{ALRM} = sub { die "alarm\n" }; 491 local $SIG{ALRM} = sub { die "alarm\n" };
481 alarm(2); 492 alarm(2);
482 $result = NPTest->testCmd( $cmd ); 493 $result = NPTest->testCmd( $cmd );
483 alarm(0); }; 494 };
495 alarm(0);
484 isnt( $@, "alarm\n", $cmd ); 496 isnt( $@, "alarm\n", $cmd );
485 isnt( $result->return_code, 0, $cmd ); 497 isnt( $result->return_code, 0, $cmd );
486 498
@@ -506,4 +518,9 @@ sub run_common_tests {
506 }; 518 };
507 is( $@, "", $cmd ); 519 is( $@, "", $cmd );
508 520
521 $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
522 eval {
523 $result = NPTest->testCmd( $cmd, 5 );
524 };
525 is( $@, "", $cmd );
509} 526}
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 188f5e7..6078b27 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -3,27 +3,20 @@
3# Test check_http by having an actual HTTP server running 3# Test check_http by having an actual HTTP server running
4# 4#
5# To create the https server certificate: 5# To create the https server certificate:
6# openssl req -new -x509 -keyout server-key.pem -out server-cert.pem -days 3650 -nodes 6# ./certs/generate-certs.sh
7# to create a new expired certificate:
8# faketime '2008-01-01 12:00:00' openssl req -new -x509 -keyout expired-key.pem -out expired-cert.pem -days 1 -nodes
9# Country Name (2 letter code) [AU]:DE
10# State or Province Name (full name) [Some-State]:Bavaria
11# Locality Name (eg, city) []:Munich
12# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
13# Organizational Unit Name (eg, section) []:
14# Common Name (e.g. server FQDN or YOUR name) []:Monitoring Plugins
15# Email Address []:devel@monitoring-plugins.org
16 7
17use strict; 8use strict;
18use Test::More; 9use Test::More;
19use NPTest; 10use NPTest;
20use FindBin qw($Bin); 11use FindBin qw($Bin);
12use IO::Socket::INET;
21 13
22$ENV{'LC_TIME'} = "C"; 14$ENV{'LC_TIME'} = "C";
23 15
24my $common_tests = 70; 16my $common_tests = 71;
25my $virtual_port_tests = 8; 17my $virtual_port_tests = 8;
26my $ssl_only_tests = 8; 18my $ssl_only_tests = 12;
19my $chunked_encoding_special_tests = 1;
27# Check that all dependent modules are available 20# Check that all dependent modules are available
28eval "use HTTP::Daemon 6.01;"; 21eval "use HTTP::Daemon 6.01;";
29plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@; 22plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
@@ -39,7 +32,7 @@ if ($@) {
39 plan skip_all => "Missing required module for test: $@"; 32 plan skip_all => "Missing required module for test: $@";
40} else { 33} else {
41 if (-x "./$plugin") { 34 if (-x "./$plugin") {
42 plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests; 35 plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests + $chunked_encoding_special_tests;
43 } else { 36 } else {
44 plan skip_all => "No $plugin compiled"; 37 plan skip_all => "No $plugin compiled";
45 } 38 }
@@ -59,61 +52,110 @@ $HTTP::Daemon::VERSION = "1.00";
59my $port_http = 50000 + int(rand(1000)); 52my $port_http = 50000 + int(rand(1000));
60my $port_https = $port_http + 1; 53my $port_https = $port_http + 1;
61my $port_https_expired = $port_http + 2; 54my $port_https_expired = $port_http + 2;
55my $port_https_clientcert = $port_http + 3;
56my $port_hacked_http = $port_http + 4;
62 57
63# This array keeps sockets around for implementing timeouts 58# This array keeps sockets around for implementing timeouts
64my @persist; 59my @persist;
65 60
66# Start up all servers 61# Start up all servers
67my @pids; 62my @pids;
68my $pid = fork(); 63# Fork a HTTP server
69if ($pid) { 64my $pid = fork;
70 # Parent 65defined $pid or die "Failed to fork";
71 push @pids, $pid; 66if (!$pid) {
72 if (exists $servers->{https}) { 67 undef @pids;
73 # Fork a normal HTTPS server
74 $pid = fork();
75 if ($pid) {
76 # Parent
77 push @pids, $pid;
78 # Fork an expired cert server
79 $pid = fork();
80 if ($pid) {
81 push @pids, $pid;
82 } else {
83 my $d = HTTP::Daemon::SSL->new(
84 LocalPort => $port_https_expired,
85 LocalAddr => "127.0.0.1",
86 SSL_cert_file => "$Bin/certs/expired-cert.pem",
87 SSL_key_file => "$Bin/certs/expired-key.pem",
88 ) || die;
89 print "Please contact https expired at: <URL:", $d->url, ">\n";
90 run_server( $d );
91 exit;
92 }
93 } else {
94 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
95 local $SIG{'PIPE'} = 'IGNORE';
96 my $d = HTTP::Daemon::SSL->new(
97 LocalPort => $port_https,
98 LocalAddr => "127.0.0.1",
99 SSL_cert_file => "$Bin/certs/server-cert.pem",
100 SSL_key_file => "$Bin/certs/server-key.pem",
101 ) || die;
102 print "Please contact https at: <URL:", $d->url, ">\n";
103 run_server( $d );
104 exit;
105 }
106 }
107} else {
108 # Child
109 #print "child\n";
110 my $d = HTTP::Daemon->new( 68 my $d = HTTP::Daemon->new(
111 LocalPort => $port_http, 69 LocalPort => $port_http,
112 LocalAddr => "127.0.0.1", 70 LocalAddr => "127.0.0.1",
113 ) || die; 71 ) || die;
114 print "Please contact http at: <URL:", $d->url, ">\n"; 72 print "Please contact http at: <URL:", $d->url, ">\n";
115 run_server( $d ); 73 run_server( $d );
116 exit; 74 die "webserver stopped";
75}
76push @pids, $pid;
77
78# Fork the hacked HTTP server
79undef $pid;
80$pid = fork;
81defined $pid or die "Failed to fork";
82if (!$pid) {
83 # this is the fork
84 undef @pids;
85 my $socket = new IO::Socket::INET (
86 LocalHost => '0.0.0.0',
87 LocalPort => $port_hacked_http,
88 Proto => 'tcp',
89 Listen => 5,
90 Reuse => 1
91 );
92 die "cannot create socket $!n" unless $socket;
93 my $local_sock = $socket->sockport();
94 print "server waiting for client connection on port $local_sock\n";
95 run_hacked_http_server ( $socket );
96 die "hacked http server stopped";
97}
98push @pids, $pid;
99
100if (exists $servers->{https}) {
101 # Fork a normal HTTPS server
102 $pid = fork;
103 defined $pid or die "Failed to fork";
104 if (!$pid) {
105 undef @pids;
106 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
107 local $SIG{'PIPE'} = 'IGNORE';
108 my $d = HTTP::Daemon::SSL->new(
109 LocalPort => $port_https,
110 LocalAddr => "127.0.0.1",
111 SSL_cert_file => "$Bin/certs/server-cert.pem",
112 SSL_key_file => "$Bin/certs/server-key.pem",
113 ) || die;
114 print "Please contact https at: <URL:", $d->url, ">\n";
115 run_server( $d );
116 die "webserver stopped";
117 }
118 push @pids, $pid;
119
120 # Fork an expired cert server
121 $pid = fork;
122 defined $pid or die "Failed to fork";
123 if (!$pid) {
124 undef @pids;
125 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
126 local $SIG{'PIPE'} = 'IGNORE';
127 my $d = HTTP::Daemon::SSL->new(
128 LocalPort => $port_https_expired,
129 LocalAddr => "127.0.0.1",
130 SSL_cert_file => "$Bin/certs/expired-cert.pem",
131 SSL_key_file => "$Bin/certs/expired-key.pem",
132 ) || die;
133 print "Please contact https expired at: <URL:", $d->url, ">\n";
134 run_server( $d );
135 die "webserver stopped";
136 }
137 push @pids, $pid;
138
139 # Fork an client cert expecting server
140 $pid = fork;
141 defined $pid or die "Failed to fork";
142 if (!$pid) {
143 undef @pids;
144 # closing the connection after -C cert checks make the daemon exit with a sigpipe otherwise
145 local $SIG{'PIPE'} = 'IGNORE';
146 my $d = HTTP::Daemon::SSL->new(
147 LocalPort => $port_https_clientcert,
148 LocalAddr => "127.0.0.1",
149 SSL_cert_file => "$Bin/certs/server-cert.pem",
150 SSL_key_file => "$Bin/certs/server-key.pem",
151 SSL_verify_mode => IO::Socket::SSL->SSL_VERIFY_PEER | IO::Socket::SSL->SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
152 SSL_ca_file => "$Bin/certs/clientca-cert.pem",
153 ) || die;
154 print "Please contact https client cert at: <URL:", $d->url, ">\n";
155 run_server( $d );
156 die "webserver stopped";
157 }
158 push @pids, $pid;
117} 159}
118 160
119# give our webservers some time to startup 161# give our webservers some time to startup
@@ -122,64 +164,105 @@ sleep(3);
122# Run the same server on http and https 164# Run the same server on http and https
123sub run_server { 165sub run_server {
124 my $d = shift; 166 my $d = shift;
125 MAINLOOP: while (my $c = $d->accept ) { 167 while (1) {
126 while (my $r = $c->get_request) { 168 MAINLOOP: while (my $c = $d->accept) {
127 if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) { 169 while (my $r = $c->get_request) {
128 $c->send_basic_header($1); 170 if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) {
129 $c->send_crlf; 171 $c->send_basic_header($1);
130 } elsif ($r->method eq "GET" and $r->url->path =~ m^/file/(.*)^) { 172 $c->send_crlf;
131 $c->send_basic_header; 173 } elsif ($r->method eq "GET" and $r->url->path =~ m^/file/(.*)^) {
132 $c->send_crlf; 174 $c->send_basic_header;
133 $c->send_file_response("$Bin/var/$1"); 175 $c->send_crlf;
134 } elsif ($r->method eq "GET" and $r->url->path eq "/slow") { 176 $c->send_file_response("$Bin/var/$1");
135 $c->send_basic_header; 177 } elsif ($r->method eq "GET" and $r->url->path eq "/slow") {
136 $c->send_crlf; 178 $c->send_basic_header;
137 sleep 1; 179 $c->send_crlf;
138 $c->send_response("slow"); 180 sleep 1;
139 } elsif ($r->url->path eq "/method") { 181 $c->send_response("slow");
140 if ($r->method eq "DELETE") { 182 } elsif ($r->url->path eq "/method") {
141 $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED); 183 if ($r->method eq "DELETE") {
142 } elsif ($r->method eq "foo") { 184 $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED);
143 $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED); 185 } elsif ($r->method eq "foo") {
186 $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED);
187 } else {
188 $c->send_status_line(200, $r->method);
189 }
190 } elsif ($r->url->path eq "/postdata") {
191 $c->send_basic_header;
192 $c->send_crlf;
193 $c->send_response($r->method.":".$r->content);
194 } elsif ($r->url->path eq "/redirect") {
195 $c->send_redirect( "/redirect2" );
196 } elsif ($r->url->path eq "/redir_external") {
197 $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" );
198 } elsif ($r->url->path eq "/redirect2") {
199 $c->send_basic_header;
200 $c->send_crlf;
201 $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
202 } elsif ($r->url->path eq "/redir_timeout") {
203 $c->send_redirect( "/timeout" );
204 } elsif ($r->url->path eq "/timeout") {
205 # Keep $c from being destroyed, but prevent severe leaks
206 unshift @persist, $c;
207 delete($persist[1000]);
208 next MAINLOOP;
209 } elsif ($r->url->path eq "/header_check") {
210 $c->send_basic_header;
211 $c->send_header('foo');
212 $c->send_crlf;
213 } elsif ($r->url->path eq "/virtual_port") {
214 # return sent Host header
215 $c->send_basic_header;
216 $c->send_crlf;
217 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
218 } elsif ($r->url->path eq "/chunked") {
219 my $chunks = ["chunked", "encoding", "test\n"];
220 $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub {
221 my $chunk = shift @{$chunks};
222 return unless $chunk;
223 sleep(1);
224 return($chunk);
225 }));
144 } else { 226 } else {
145 $c->send_status_line(200, $r->method); 227 $c->send_error(HTTP::Status->RC_FORBIDDEN);
146 } 228 }
147 } elsif ($r->url->path eq "/postdata") { 229 $c->close;
148 $c->send_basic_header;
149 $c->send_crlf;
150 $c->send_response($r->method.":".$r->content);
151 } elsif ($r->url->path eq "/redirect") {
152 $c->send_redirect( "/redirect2" );
153 } elsif ($r->url->path eq "/redir_external") {
154 $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" );
155 } elsif ($r->url->path eq "/redirect2") {
156 $c->send_basic_header;
157 $c->send_crlf;
158 $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' ));
159 } elsif ($r->url->path eq "/redir_timeout") {
160 $c->send_redirect( "/timeout" );
161 } elsif ($r->url->path eq "/timeout") {
162 # Keep $c from being destroyed, but prevent severe leaks
163 unshift @persist, $c;
164 delete($persist[1000]);
165 next MAINLOOP;
166 } elsif ($r->url->path eq "/header_check") {
167 $c->send_basic_header;
168 $c->send_header('foo');
169 $c->send_crlf;
170 } elsif ($r->url->path eq "/virtual_port") {
171 # return sent Host header
172 $c->send_basic_header;
173 $c->send_crlf;
174 $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host')));
175 } else {
176 $c->send_error(HTTP::Status->RC_FORBIDDEN);
177 } 230 }
178 $c->close;
179 } 231 }
180 } 232 }
181} 233}
182 234
235sub run_hacked_http_server {
236 my $socket = shift;
237
238 # auto-flush on socket
239 $| = 1;
240
241
242 while(1)
243 {
244 # waiting for a new client connection
245 my $client_socket = $socket->accept();
246
247 # get information about a newly connected client
248 my $client_address = $client_socket->peerhost();
249 my $client_portn = $client_socket->peerport();
250 print "connection from $client_address:$client_portn";
251
252 # read up to 1024 characters from the connected client
253 my $data = "";
254 $client_socket->recv($data, 1024);
255 print "received data: $data";
256
257 # write response data to the connected client
258 $data = "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n";
259 $client_socket->send($data);
260
261 # notify client that response has been sent
262 shutdown($client_socket, 1);
263 }
264}
265
183END { 266END {
184 foreach my $pid (@pids) { 267 foreach my $pid (@pids) {
185 if ($pid) { print "Killing $pid\n"; kill "INT", $pid } 268 if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
@@ -195,30 +278,50 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
195my $result; 278my $result;
196my $command = "./$plugin -H 127.0.0.1"; 279my $command = "./$plugin -H 127.0.0.1";
197 280
281run_chunked_encoding_special_test( {command => "$command -p $port_hacked_http"});
198run_common_tests( { command => "$command -p $port_http" } ); 282run_common_tests( { command => "$command -p $port_http" } );
199SKIP: { 283SKIP: {
200 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https}; 284 skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https};
201 run_common_tests( { command => "$command -p $port_https", ssl => 1 } ); 285 run_common_tests( { command => "$command -p $port_https", ssl => 1 } );
202 286
287 my $expiry = "Thu Nov 28 21:02:11 2030 +0000";
288
203 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 289 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
204 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 290 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
205 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on Fri Feb 16 15:31:44 2029 +0000.", "output ok" ); 291 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on $expiry.", "output ok" );
206 292
207 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 293 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
208 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 294 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
209 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); 295 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
210 296
211 # Expired cert tests 297 # Expired cert tests
212 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 298 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
213 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 299 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
214 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); 300 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(' . quotemeta($expiry) . '\)./', "output ok" );
215 301
216 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 302 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
217 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 303 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
218 is( $result->output, 304 is( $result->output,
219 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 11:00:26 2008 +0000.', 305 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 12:00:00 2008 +0000.',
220 "output ok" ); 306 "output ok" );
221 307
308 # client cert tests
309 my $cmd;
310 $cmd = "$command -p $port_https_clientcert"
311 . " -J \"$Bin/certs/client-cert.pem\""
312 . " -K \"$Bin/certs/client-key.pem\""
313 . " -u /statuscode/200";
314 $result = NPTest->testCmd($cmd);
315 is( $result->return_code, 0, $cmd);
316 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
317
318 $cmd = "$command -p $port_https_clientcert"
319 . " -J \"$Bin/certs/clientchain-cert.pem\""
320 . " -K \"$Bin/certs/clientchain-key.pem\""
321 . " -u /statuscode/200";
322 $result = NPTest->testCmd($cmd);
323 is( $result->return_code, 0, $cmd);
324 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
222} 325}
223 326
224my $cmd; 327my $cmd;
@@ -459,4 +562,20 @@ sub run_common_tests {
459 }; 562 };
460 is( $@, "", $cmd ); 563 is( $@, "", $cmd );
461 564
565 $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'";
566 eval {
567 $result = NPTest->testCmd( $cmd, 5 );
568 };
569 is( $@, "", $cmd );
570}
571
572sub run_chunked_encoding_special_test {
573 my ($opts) = @_;
574 my $command = $opts->{command};
575
576 $cmd = "$command -u / -s 'ChunkedEncodingSpecialTest'";
577 eval {
578 $result = NPTest->testCmd( $cmd, 5 );
579 };
580 is( $@, "", $cmd );
462} 581}
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 54d43d9..b3a0a30 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -8,13 +8,14 @@ use Test::More;
8use NPTest; 8use NPTest;
9 9
10if (-x "./check_procs") { 10if (-x "./check_procs") {
11 plan tests => 50; 11 plan tests => 54;
12} else { 12} else {
13 plan skip_all => "No check_procs compiled"; 13 plan skip_all => "No check_procs compiled";
14} 14}
15 15
16my $result; 16my $result;
17my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin"; 17my $command = "./check_procs --input-file=tests/var/ps-axwo.darwin";
18my $cmd_etime = "./check_procs --input-file=tests/var/ps-axwo.debian";
18 19
19$result = NPTest->testCmd( "$command" ); 20$result = NPTest->testCmd( "$command" );
20is( $result->return_code, 0, "Run with no options" ); 21is( $result->return_code, 0, "Run with no options" );
@@ -33,9 +34,13 @@ is( $result->return_code, 0, "Checking no threshold breeched" );
33is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" ); 34is( $result->output, "PROCS OK: 95 processes | procs=95;100;200;0;", "Output correct" );
34 35
35$result = NPTest->testCmd( "$command -C launchd -c 5" ); 36$result = NPTest->testCmd( "$command -C launchd -c 5" );
36is( $result->return_code, 2, "Checking processes filtered by command name" ); 37is( $result->return_code, 2, "Checking processes matched by command name" );
37is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" ); 38is( $result->output, "PROCS CRITICAL: 6 processes with command name 'launchd' | procs=6;;5;0;", "Output correct" );
38 39
40$result = NPTest->testCmd( "$command -X bash -c 5" );
41is( $result->return_code, 2, "Checking processes excluded by command name" );
42is( $result->output, "PROCS CRITICAL: 95 processes with exclude progs 'bash' | procs=95;;5;0;", "Output correct" );
43
39SKIP: { 44SKIP: {
40 skip 'user with uid 501 required', 4 unless getpwuid(501); 45 skip 'user with uid 501 required', 4 unless getpwuid(501);
41 46
@@ -69,9 +74,21 @@ SKIP: {
69 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); 74 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
70}; 75};
71 76
72$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 77SKIP: {
73is( $result->return_code, 0, "Checking regexp search of arguments" ); 78 skip 'check_procs is compiled with etime format support', 2 if `$command -vvv` =~ m/etime/mx;
74is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" ); 79
80 $result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
81 is( $result->return_code, 0, "Checking regexp search of arguments" );
82 is( $result->output, "PROCS OK: 1 process with regex args 'mdworker.*501' | procs=1;;;0;", "Output correct" );
83}
84
85SKIP: {
86 skip 'check_procs is compiled without etime format support', 2 if `$cmd_etime -vvv` !~ m/etime/mx;
87
88 $result = NPTest->testCmd( "$cmd_etime -m ELAPSED -C apache2 -w 1000 -c 2000" );
89 is( $result->return_code, 2, "Checking elapsed time threshold" );
90 is( $result->output, "ELAPSED CRITICAL: 10 crit, 0 warn out of 10 processes with command name 'apache2' | procs=10;;;0; procs_warn=0;;;0; procs_crit=10;;;0;", "Output correct" );
91}
75 92
76$result = NPTest->testCmd( "$command --vsz 1000000" ); 93$result = NPTest->testCmd( "$command --vsz 1000000" );
77is( $result->return_code, 0, "Checking filter by VSZ" ); 94is( $result->return_code, 0, "Checking filter by VSZ" );
@@ -83,7 +100,7 @@ is( $result->output, 'PROCS OK: 3 processes with RSS >= 100000 | procs=3;;;0;',
83 100
84$result = NPTest->testCmd( "$command -s S" ); 101$result = NPTest->testCmd( "$command -s S" );
85is( $result->return_code, 0, "Checking filter for sleeping processes" ); 102is( $result->return_code, 0, "Checking filter for sleeping processes" );
86like( $result->output, '/^PROCS OK: 44 processes with STATE = S/', "Output correct" ); 103like( $result->output, '/^PROCS OK: 88 processes with STATE = S/', "Output correct" );
87 104
88$result = NPTest->testCmd( "$command -s Z" ); 105$result = NPTest->testCmd( "$command -s Z" );
89is( $result->return_code, 0, "Checking filter for zombies" ); 106is( $result->return_code, 0, "Checking filter for zombies" );
@@ -129,4 +146,3 @@ is( $result->output, 'RSS CRITICAL: 5 crit, 0 warn out of 95 processes [WindowSe
129$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" ); 146$result = NPTest->testCmd( "$command --ereg-argument-array='(nosuchname|nosuch2name)'" );
130is( $result->return_code, 0, "Checking no pipe symbol in output" ); 147is( $result->return_code, 0, "Checking no pipe symbol in output" );
131is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" ); 148is( $result->output, "PROCS OK: 0 processes with regex args '(nosuchname,nosuch2name)' | procs=0;;;0;", "Output correct" );
132
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index 85d6bf5..bfe42e1 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -9,7 +9,7 @@ use NPTest;
9use FindBin qw($Bin); 9use FindBin qw($Bin);
10use POSIX qw/strftime/; 10use POSIX qw/strftime/;
11 11
12my $tests = 67; 12my $tests = 81;
13# Check that all dependent modules are available 13# Check that all dependent modules are available
14eval { 14eval {
15 require NetSNMP::OID; 15 require NetSNMP::OID;
@@ -53,13 +53,13 @@ if ($pid) {
53 #print "child\n"; 53 #print "child\n";
54 54
55 print "Please contact SNMP at: $port_snmp\n"; 55 print "Please contact SNMP at: $port_snmp\n";
56 close(STDERR); # Coment out to debug snmpd problems (most errors sent there are OK) 56 close(STDERR); # Comment out to debug snmpd problems (most errors sent there are OK)
57 exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp"); 57 exec("snmpd -c tests/conf/snmpd.conf -C -f -r udp:$port_snmp");
58} 58}
59 59
60END { 60END {
61 foreach my $pid (@pids) { 61 foreach my $pid (@pids) {
62 if ($pid) { print "Killing $pid\n"; kill "INT", $pid } 62 if ($pid) { print "Killing $pid\n"; kill "INT", $pid }
63 } 63 }
64}; 64};
65 65
@@ -227,7 +227,7 @@ is($res->output, 'SNMP OK - "555\"I said\"" | ', "Check string with a double quo
227 227
228$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.15 -r 'CUSTOM CHECK OK'" ); 228$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.15 -r 'CUSTOM CHECK OK'" );
229is($res->return_code, 0, "String check should check whole string, not a parsed number" ); 229is($res->return_code, 0, "String check should check whole string, not a parsed number" );
230is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check witn numbers returns whole string"); 230is($res->output, 'SNMP OK - "CUSTOM CHECK OK: foo is 12345" | ', "String check with numbers returns whole string");
231 231
232$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" ); 232$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.16 -w -2: -c -3:" );
233is($res->return_code, 0, "Negative integer check OK" ); 233is($res->return_code, 0, "Negative integer check OK" );
@@ -251,9 +251,36 @@ is($res->output, 'SNMP CRITICAL - *-4* | iso.3.6.1.4.1.8072.3.2.67.17=-4;-2:;-3:
251 251
252$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c '~:-6.5'" ); 252$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -c '~:-6.5'" );
253is($res->return_code, 0, "Negative float OK" ); 253is($res->return_code, 0, "Negative float OK" );
254is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;~:-6.5 ', "Negative float OK output" ); 254is($res->output, 'SNMP OK - -6.6 | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;;@-6.5:~ ', "Negative float OK output" );
255 255
256$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w '~:-6.65' -c '~:-6.55'" ); 256$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.18 -w '~:-6.65' -c '~:-6.55'" );
257is($res->return_code, 1, "Negative float WARNING" ); 257is($res->return_code, 1, "Negative float WARNING" );
258is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;~:-6.65;~:-6.55 ', "Negative float WARNING output" ); 258is($res->output, 'SNMP WARNING - *-6.6* | iso.3.6.1.4.1.8072.3.2.67.18=-6.6;@-6.65:~;@-6.55:~ ', "Negative float WARNING output" );
259 259
260$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w '1:100000,-10:20' -c '2:200000,-20:30'" );
261is($res->return_code, 0, "Multiple OIDs with thresholds" );
262like($res->output, '/SNMP OK - \d+ -4 | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1:100000;2:200000 iso.3.6.1.4.1.8072.3.2.67.17=-4;-10:20;-20:30/', "Multiple OIDs with thresholds output" );
263
264$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w '1:100000,-1:2' -c '2:200000,-20:30'" );
265is($res->return_code, 1, "Multiple OIDs with thresholds" );
266like($res->output, '/SNMP WARNING - \d+ \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1:100000;2:200000 iso.3.6.1.4.1.8072.3.2.67.17=-4;-10:20;-20:30/', "Multiple OIDs with thresholds output" );
267
268$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10,.1.3.6.1.4.1.8072.3.2.67.17 -w 1,2 -c 1" );
269is($res->return_code, 2, "Multiple OIDs with some thresholds" );
270like($res->output, '/SNMP CRITICAL - \*\d+\* \*-4\* | iso.3.6.1.4.1.8072.3.2.67.10=\d+c;1;2 iso.3.6.1.4.1.8072.3.2.67.17=-4;;/', "Multiple OIDs with thresholds output" );
271
272$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19");
273is($res->return_code, 0, "Test plain .1.3.6.1.4.1.8072.3.2.67.6 RC" );
274is($res->output,'SNMP OK - 42 | iso.3.6.1.4.1.8072.3.2.67.19=42 ', "Test plain value of .1.3.6.1.4.1.8072.3.2.67.1" );
275
276$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 -M .1");
277is($res->return_code, 0, "Test multiply RC" );
278is($res->output,'SNMP OK - 4.200000 | iso.3.6.1.4.1.8072.3.2.67.19=4.200000 ' , "Test multiply .1 output" );
279
280$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' ");
281is($res->return_code, 0, "Test multiply RC + format" );
282is($res->output, 'SNMP OK - 4.20 | iso.3.6.1.4.1.8072.3.2.67.19=4.20 ', "Test multiply .1 output + format" );
283
284$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.19 --multiplier=.1 -f '%.2f' -w 1");
285is($res->return_code, 1, "Test multiply RC + format + thresholds" );
286is($res->output, 'SNMP WARNING - *4.20* | iso.3.6.1.4.1.8072.3.2.67.19=4.20;1 ', "Test multiply .1 output + format + thresholds" );
diff --git a/plugins/tests/check_snmp_agent.pl b/plugins/tests/check_snmp_agent.pl
index 0e41d57..38912e9 100644
--- a/plugins/tests/check_snmp_agent.pl
+++ b/plugins/tests/check_snmp_agent.pl
@@ -32,11 +32,11 @@ my $multilin5 = 'And now have fun with with this: "C:\\"
32because we\'re not done yet!'; 32because we\'re not done yet!';
33 33
34# Next are arrays of indexes (Type, initial value and increments) 34# Next are arrays of indexes (Type, initial value and increments)
35# 0..16 <---- please update comment when adding/removing fields 35# 0..19 <---- please update comment when adding/removing fields
36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR ); 36my @fields = (ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_UNSIGNED, ASN_UNSIGNED, ASN_COUNTER, ASN_COUNTER64, ASN_UNSIGNED, ASN_COUNTER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER, ASN_OCTET_STR, ASN_OCTET_STR, ASN_INTEGER );
37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6' ); 37my @values = ($multiline, $multilin2, $multilin3, $multilin4, $multilin5, 4294965296, 1000, 4294965296, uint64("18446744073709351616"), int(rand(2**32)), 64000, "stringtests", "3.5", "87.4startswithnumberbutshouldbestring", '555"I said"', 'CUSTOM CHECK OK: foo is 12345', -2, '-4', '-6.6', 42 );
38# undef increments are randomized 38# undef increments are randomized
39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef ); 39my @incrts = (undef, undef, undef, undef, undef, 1000, -500, 1000, 100000, undef, 666, undef, undef, undef, undef, undef, -1, undef, undef, 0 );
40 40
41# Number of elements in our OID 41# Number of elements in our OID
42my $oidelts; 42my $oidelts;
diff --git a/plugins/tests/var/ps-axwo.debian b/plugins/tests/var/ps-axwo.debian
new file mode 100644
index 0000000..5889e9a
--- /dev/null
+++ b/plugins/tests/var/ps-axwo.debian
@@ -0,0 +1,219 @@
1STAT UID PID PPID VSZ RSS %CPU ELAPSED COMMAND COMMAND
2Ss 0 1 0 167244 7144 0.1 26-03:07:26 systemd /lib/systemd/systemd --system --deserialize 17
3S 0 2 0 0 0 0.0 26-03:07:26 kthreadd [kthreadd]
4I< 0 3 2 0 0 0.0 26-03:07:26 rcu_gp [rcu_gp]
5I< 0 4 2 0 0 0.0 26-03:07:26 rcu_par_gp [rcu_par_gp]
6I< 0 6 2 0 0 0.0 26-03:07:26 kworker/0:0H-ev [kworker/0:0H-events_highpri]
7I< 0 9 2 0 0 0.0 26-03:07:26 mm_percpu_wq [mm_percpu_wq]
8S 0 10 2 0 0 0.0 26-03:07:26 rcu_tasks_rude_ [rcu_tasks_rude_]
9S 0 11 2 0 0 0.0 26-03:07:26 rcu_tasks_trace [rcu_tasks_trace]
10S 0 12 2 0 0 0.0 26-03:07:26 ksoftirqd/0 [ksoftirqd/0]
11I 0 13 2 0 0 0.0 26-03:07:26 rcu_sched [rcu_sched]
12S 0 14 2 0 0 0.0 26-03:07:26 migration/0 [migration/0]
13S 0 15 2 0 0 0.0 26-03:07:26 cpuhp/0 [cpuhp/0]
14S 0 16 2 0 0 0.0 26-03:07:26 cpuhp/1 [cpuhp/1]
15S 0 17 2 0 0 0.0 26-03:07:26 migration/1 [migration/1]
16S 0 18 2 0 0 0.0 26-03:07:26 ksoftirqd/1 [ksoftirqd/1]
17I< 0 20 2 0 0 0.0 26-03:07:26 kworker/1:0H-ev [kworker/1:0H-events_highpri]
18S 0 21 2 0 0 0.0 26-03:07:26 cpuhp/2 [cpuhp/2]
19S 0 22 2 0 0 0.0 26-03:07:26 migration/2 [migration/2]
20S 0 23 2 0 0 0.0 26-03:07:26 ksoftirqd/2 [ksoftirqd/2]
21I< 0 25 2 0 0 0.0 26-03:07:26 kworker/2:0H-ev [kworker/2:0H-events_highpri]
22S 0 26 2 0 0 0.0 26-03:07:26 cpuhp/3 [cpuhp/3]
23S 0 27 2 0 0 0.0 26-03:07:26 migration/3 [migration/3]
24S 0 28 2 0 0 0.0 26-03:07:26 ksoftirqd/3 [ksoftirqd/3]
25I< 0 30 2 0 0 0.0 26-03:07:26 kworker/3:0H-ev [kworker/3:0H-events_highpri]
26S 0 35 2 0 0 0.0 26-03:07:26 kdevtmpfs [kdevtmpfs]
27I< 0 36 2 0 0 0.0 26-03:07:26 netns [netns]
28S 0 37 2 0 0 0.0 26-03:07:26 kauditd [kauditd]
29S 0 38 2 0 0 0.0 26-03:07:26 khungtaskd [khungtaskd]
30S 0 39 2 0 0 0.0 26-03:07:26 oom_reaper [oom_reaper]
31I< 0 40 2 0 0 0.0 26-03:07:26 writeback [writeback]
32S 0 41 2 0 0 0.0 26-03:07:26 kcompactd0 [kcompactd0]
33SN 0 42 2 0 0 0.0 26-03:07:26 ksmd [ksmd]
34SN 0 43 2 0 0 0.0 26-03:07:26 khugepaged [khugepaged]
35I< 0 62 2 0 0 0.0 26-03:07:26 kintegrityd [kintegrityd]
36I< 0 63 2 0 0 0.0 26-03:07:26 kblockd [kblockd]
37I< 0 64 2 0 0 0.0 26-03:07:26 blkcg_punt_bio [blkcg_punt_bio]
38I< 0 65 2 0 0 0.0 26-03:07:26 edac-poller [edac-poller]
39I< 0 66 2 0 0 0.0 26-03:07:26 devfreq_wq [devfreq_wq]
40I< 0 67 2 0 0 0.0 26-03:07:26 kworker/2:1H-ev [kworker/2:1H-events_highpri]
41S 0 70 2 0 0 0.3 26-03:07:25 kswapd0 [kswapd0]
42I< 0 71 2 0 0 0.0 26-03:07:25 kthrotld [kthrotld]
43I< 0 72 2 0 0 0.0 26-03:07:25 acpi_thermal_pm [acpi_thermal_pm]
44I< 0 74 2 0 0 0.0 26-03:07:25 ipv6_addrconf [ipv6_addrconf]
45I< 0 80 2 0 0 0.0 26-03:07:25 kworker/3:1H-ev [kworker/3:1H-events_highpri]
46I< 0 84 2 0 0 0.0 26-03:07:25 kstrp [kstrp]
47I< 0 87 2 0 0 0.0 26-03:07:25 zswap-shrink [zswap-shrink]
48I< 0 110 2 0 0 0.0 26-03:07:25 kworker/0:1H-ev [kworker/0:1H-events_highpri]
49I< 0 141 2 0 0 0.0 26-03:07:25 ata_sff [ata_sff]
50S 0 143 2 0 0 0.0 26-03:07:25 scsi_eh_0 [scsi_eh_0]
51I< 0 144 2 0 0 0.0 26-03:07:25 scsi_tmf_0 [scsi_tmf_0]
52S 0 145 2 0 0 0.0 26-03:07:25 scsi_eh_1 [scsi_eh_1]
53I< 0 146 2 0 0 0.0 26-03:07:25 scsi_tmf_1 [scsi_tmf_1]
54S 0 147 2 0 0 0.0 26-03:07:25 scsi_eh_2 [scsi_eh_2]
55I< 0 148 2 0 0 0.0 26-03:07:25 scsi_tmf_2 [scsi_tmf_2]
56S 0 149 2 0 0 0.0 26-03:07:25 scsi_eh_3 [scsi_eh_3]
57I< 0 150 2 0 0 0.0 26-03:07:25 scsi_tmf_3 [scsi_tmf_3]
58S 0 151 2 0 0 0.0 26-03:07:25 scsi_eh_4 [scsi_eh_4]
59I< 0 152 2 0 0 0.0 26-03:07:25 scsi_tmf_4 [scsi_tmf_4]
60S 0 153 2 0 0 0.0 26-03:07:25 scsi_eh_5 [scsi_eh_5]
61I< 0 154 2 0 0 0.0 26-03:07:25 scsi_tmf_5 [scsi_tmf_5]
62S 0 158 2 0 0 0.0 26-03:07:25 card0-crtc0 [card0-crtc0]
63S 0 159 2 0 0 0.0 26-03:07:25 card0-crtc1 [card0-crtc1]
64S 0 160 2 0 0 0.0 26-03:07:25 card0-crtc2 [card0-crtc2]
65I< 0 162 2 0 0 0.0 26-03:07:25 kworker/1:1H-ev [kworker/1:1H-events_highpri]
66S 0 163 2 0 0 0.0 26-03:07:25 scsi_eh_6 [scsi_eh_6]
67I< 0 164 2 0 0 0.0 26-03:07:25 scsi_tmf_6 [scsi_tmf_6]
68S 0 165 2 0 0 0.0 26-03:07:25 usb-storage [usb-storage]
69I< 0 167 2 0 0 0.0 26-03:07:25 uas [uas]
70I< 0 176 2 0 0 0.0 26-03:07:25 kdmflush [kdmflush]
71I< 0 177 2 0 0 0.0 26-03:07:25 kdmflush [kdmflush]
72S 0 202 2 0 0 0.0 26-03:07:24 scsi_eh_7 [scsi_eh_7]
73I< 0 203 2 0 0 0.0 26-03:07:24 scsi_tmf_7 [scsi_tmf_7]
74S 0 204 2 0 0 0.0 26-03:07:24 usb-storage [usb-storage]
75I< 0 232 2 0 0 0.0 26-03:07:23 btrfs-worker [btrfs-worker]
76I< 0 233 2 0 0 0.0 26-03:07:23 btrfs-worker-hi [btrfs-worker-hi]
77I< 0 234 2 0 0 0.0 26-03:07:23 btrfs-delalloc [btrfs-delalloc]
78I< 0 235 2 0 0 0.0 26-03:07:23 btrfs-flush_del [btrfs-flush_del]
79I< 0 236 2 0 0 0.0 26-03:07:23 btrfs-cache [btrfs-cache]
80I< 0 237 2 0 0 0.0 26-03:07:23 btrfs-fixup [btrfs-fixup]
81I< 0 238 2 0 0 0.0 26-03:07:23 btrfs-endio [btrfs-endio]
82I< 0 239 2 0 0 0.0 26-03:07:23 btrfs-endio-met [btrfs-endio-met]
83I< 0 240 2 0 0 0.0 26-03:07:23 btrfs-endio-met [btrfs-endio-met]
84I< 0 241 2 0 0 0.0 26-03:07:23 btrfs-endio-rai [btrfs-endio-rai]
85I< 0 242 2 0 0 0.0 26-03:07:23 btrfs-rmw [btrfs-rmw]
86I< 0 243 2 0 0 0.0 26-03:07:23 btrfs-endio-wri [btrfs-endio-wri]
87I< 0 244 2 0 0 0.0 26-03:07:23 btrfs-freespace [btrfs-freespace]
88I< 0 245 2 0 0 0.0 26-03:07:23 btrfs-delayed-m [btrfs-delayed-m]
89I< 0 246 2 0 0 0.0 26-03:07:23 btrfs-readahead [btrfs-readahead]
90I< 0 247 2 0 0 0.0 26-03:07:23 btrfs-qgroup-re [btrfs-qgroup-re]
91S 0 248 2 0 0 0.0 26-03:07:23 btrfs-cleaner [btrfs-cleaner]
92S 0 249 2 0 0 0.2 26-03:07:23 btrfs-transacti [btrfs-transacti]
93I< 0 317 2 0 0 0.0 26-03:07:22 rpciod [rpciod]
94I< 0 322 2 0 0 0.0 26-03:07:22 xprtiod [xprtiod]
95S 0 381 2 0 0 0.0 26-03:07:22 irq/133-mei_me [irq/133-mei_me]
96S 0 422 2 0 0 0.0 26-03:07:22 watchdogd [watchdogd]
97I< 0 523 2 0 0 0.0 26-03:07:22 led_workqueue [led_workqueue]
98I< 0 583 2 0 0 0.0 26-03:07:22 cryptd [cryptd]
99I< 0 590 2 0 0 0.0 26-03:07:22 ext4-rsv-conver [ext4-rsv-conver]
100Ss 104 693 1 12324 4292 0.5 26-03:07:21 dbus-daemon /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
101Ss 0 731 1 575120 1368 0.0 26-03:07:21 systemd-logind /lib/systemd/systemd-logind
102Ssl 0 1111 1 121248 732 0.0 26-03:07:18 unattended-upgr /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
103S 0 1141 2 0 0 0.0 26-03:07:18 lockd [lockd]
104I< 0 1459 2 0 0 0.0 26-03:07:16 nfsiod [nfsiod]
105S 0 1621 2 0 0 0.0 26-03:07:15 NFSv4 callback [NFSv4 callback]
106Ssl 0 1771 1 1548340 676 0.0 26-03:07:13 libvirtd /usr/sbin/libvirtd
107I< 0 24315 2 0 0 0.0 26-02:49:02 cifsiod [cifsiod]
108I< 0 24316 2 0 0 0.0 26-02:49:02 smb3decryptd [smb3decryptd]
109I< 0 24317 2 0 0 0.0 26-02:49:02 cifsfileinfoput [cifsfileinfoput]
110I< 0 24318 2 0 0 0.0 26-02:49:02 cifsoplockd [cifsoplockd]
111I< 0 24319 2 0 0 0.0 26-02:49:02 cifs-dfscache [cifs-dfscache]
112S 0 24322 2 0 0 0.0 26-02:49:02 cifsd [cifsd]
113I< 0 24413 2 0 0 0.0 26-02:48:57 btrfs-worker [btrfs-worker]
114I< 0 24414 2 0 0 0.0 26-02:48:57 btrfs-worker-hi [btrfs-worker-hi]
115I< 0 24415 2 0 0 0.0 26-02:48:57 btrfs-delalloc [btrfs-delalloc]
116I< 0 24416 2 0 0 0.0 26-02:48:57 btrfs-flush_del [btrfs-flush_del]
117I< 0 24418 2 0 0 0.0 26-02:48:57 btrfs-cache [btrfs-cache]
118I< 0 24419 2 0 0 0.0 26-02:48:57 btrfs-fixup [btrfs-fixup]
119I< 0 24420 2 0 0 0.0 26-02:48:57 btrfs-endio [btrfs-endio]
120I< 0 24421 2 0 0 0.0 26-02:48:57 btrfs-endio-met [btrfs-endio-met]
121I< 0 24422 2 0 0 0.0 26-02:48:57 btrfs-endio-met [btrfs-endio-met]
122I< 0 24423 2 0 0 0.0 26-02:48:57 btrfs-endio-rai [btrfs-endio-rai]
123I< 0 24424 2 0 0 0.0 26-02:48:57 btrfs-rmw [btrfs-rmw]
124I< 0 24425 2 0 0 0.0 26-02:48:57 btrfs-endio-wri [btrfs-endio-wri]
125I< 0 24426 2 0 0 0.0 26-02:48:57 btrfs-freespace [btrfs-freespace]
126I< 0 24427 2 0 0 0.0 26-02:48:57 btrfs-delayed-m [btrfs-delayed-m]
127I< 0 24428 2 0 0 0.0 26-02:48:57 btrfs-readahead [btrfs-readahead]
128I< 0 24429 2 0 0 0.0 26-02:48:57 btrfs-qgroup-re [btrfs-qgroup-re]
129S 0 24450 2 0 0 0.0 26-02:48:53 btrfs-cleaner [btrfs-cleaner]
130S 0 24451 2 0 0 0.0 26-02:48:53 btrfs-transacti [btrfs-transacti]
131I< 0 747708 2 0 0 0.0 16-21:06:20 xfsalloc [xfsalloc]
132I< 0 747709 2 0 0 0.0 16-21:06:20 xfs_mru_cache [xfs_mru_cache]
133S 0 747713 2 0 0 0.0 16-21:06:20 jfsIO [jfsIO]
134S 0 747714 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
135S 0 747715 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
136S 0 747716 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
137S 0 747717 2 0 0 0.0 16-21:06:20 jfsCommit [jfsCommit]
138S 0 747718 2 0 0 0.0 16-21:06:20 jfsSync [jfsSync]
139Ss 0 1071687 1 105976 28304 0.0 3-03:12:31 systemd-journal /lib/systemd/systemd-journald
140Ss 0 1934146 1 25672 4704 0.0 11:19:31 cupsd /usr/sbin/cupsd -l
141Ssl 0 1934148 1 182868 8540 0.0 11:19:31 cups-browsed /usr/sbin/cups-browsed
142S 13 1934155 3392655 5752 88 0.0 11:19:31 pinger (pinger)
143S< 33 1934166 3393034 57996 5460 0.0 11:19:31 apache2 /usr/sbin/apache2 -k start
144S< 33 1934167 3393034 216944 13892 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
145S< 33 1934168 3393034 216944 13756 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
146S< 33 1934169 3393034 216936 13732 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
147S< 33 1934170 3393034 216944 13888 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
148S< 33 1934172 3393034 216944 15388 0.0 11:19:30 apache2 /usr/sbin/apache2 -k start
149S< 33 1934701 3393034 216936 13736 0.0 11:19:29 apache2 /usr/sbin/apache2 -k start
150S< 33 1935056 3393034 216920 13724 0.0 11:19:28 apache2 /usr/sbin/apache2 -k start
151S 7 1936834 1934146 16652 832 0.0 11:18:12 dbus /usr/lib/cups/notifier/dbus dbus://
152S< 33 1955909 3393034 216928 13792 0.0 11:00:25 apache2 /usr/sbin/apache2 -k start
153I< 0 2531464 2 0 0 0.0 06:35:47 kworker/u9:0-i9 [kworker/u9:0-i915_flip]
154I 0 2570506 2 0 0 0.0 06:27:41 kworker/1:0-cgr [kworker/1:0-cgroup_destroy]
155I 0 2596195 2 0 0 0.0 06:21:52 kworker/1:1-eve [kworker/1:1-events]
156I 0 2785341 2 0 0 0.0 03:34:16 kworker/u8:8-bt [kworker/u8:8-btrfs-endio-write]
157I 0 2785520 2 0 0 0.0 03:33:50 kworker/3:0-eve [kworker/3:0-events]
158I 0 2798669 2 0 0 0.0 03:21:09 kworker/u8:5-bt [kworker/u8:5-btrfs-endio-write]
159Ss 0 2803015 1 5616 3108 0.0 03:17:54 cron /usr/sbin/cron -f
160I 0 2845483 2 0 0 0.0 02:38:11 kworker/0:3-eve [kworker/0:3-events]
161I 0 2939490 2 0 0 0.1 01:10:32 kworker/0:0-eve [kworker/0:0-events]
162I 0 2939754 2 0 0 0.0 01:10:26 kworker/u8:1-i9 [kworker/u8:1-i915]
163I 0 2942040 2 0 0 0.0 01:08:02 kworker/u8:7-bt [kworker/u8:7-btrfs-endio-meta]
164S 117 2954268 3392551 40044 5772 0.0 56:37 pickup pickup -l -t unix -u -c
165I 0 2965195 2 0 0 0.0 46:00 kworker/u8:0-bt [kworker/u8:0-btrfs-worker]
166I 0 2977972 2 0 0 0.0 33:54 kworker/u8:2-bt [kworker/u8:2-btrfs-endio-write]
167I 0 2985488 2 0 0 0.0 27:02 kworker/u8:3-bl [kworker/u8:3-blkcg_punt_bio]
168I 0 2987519 2 0 0 1.0 25:15 kworker/2:1-eve [kworker/2:1-events]
169I 0 2987601 2 0 0 0.0 25:03 kworker/u8:9-i9 [kworker/u8:9-i915]
170I< 0 2995218 2 0 0 0.0 18:41 kworker/u9:2-xp [kworker/u9:2-xprtiod]
171I 0 2997170 2 0 0 0.0 16:41 kworker/3:1-rcu [kworker/3:1-rcu_gp]
172I 0 3001264 2 0 0 0.0 13:01 kworker/u8:4-bt [kworker/u8:4-btrfs-endio-write]
173I 0 3004697 2 0 0 0.7 09:41 kworker/2:0-eve [kworker/2:0-events]
174I 0 3010619 2 0 0 1.0 04:29 kworker/2:2-eve [kworker/2:2-events]
175I 0 3014612 2 0 0 0.0 00:41 kworker/3:2-eve [kworker/3:2-events]
176S 0 3015082 2803015 6716 3028 0.0 00:30 cron /usr/sbin/CRON -f
177I 0 3015382 2 0 0 0.0 00:00 kworker/u8:6-bt [kworker/u8:6-btrfs-endio-meta]
178Ss 1 3392068 1 5592 504 0.0 15-02:34:39 atd /usr/sbin/atd -f
179Ssl 0 3392072 1 235796 1740 0.0 15-02:34:39 accounts-daemon /usr/libexec/accounts-daemon
180Ssl 106 3392076 1 315708 6128 0.0 15-02:34:39 colord /usr/libexec/colord
181Ss 0 3392083 1 8120 720 0.0 15-02:34:39 haveged /usr/sbin/haveged --Foreground --verbose=1
182Ss 0 3392090 1 5168 132 0.0 15-02:34:39 blkmapd /usr/sbin/blkmapd
183SNsl 111 3392094 1 155648 440 0.0 15-02:34:39 rtkit-daemon /usr/libexec/rtkit-daemon
184Ssl 0 3392097 1 290168 1352 0.0 15-02:34:39 packagekitd /usr/libexec/packagekitd
185Ss 128 3392100 1 7960 448 0.0 15-02:34:39 rpcbind /sbin/rpcbind -f -w
186Ss 0 3392114 1 13432 616 0.0 15-02:34:39 systemd-machine /lib/systemd/systemd-machined
187Ss 0 3392118 1 13316 848 0.0 15-02:34:39 sshd sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
188Ssl 0 3392124 1 244072 2456 0.0 15-02:34:39 upowerd /usr/libexec/upowerd
189Ssl 0 3392138 1 1634748 10684 0.0 15-02:34:39 containerd /usr/bin/containerd
190Ssl 0 3392139 1 222768 1784 0.0 15-02:34:39 rsyslogd /usr/sbin/rsyslogd -n -iNONE
191Ss 13 3392140 1 3344 152 0.0 15-02:34:39 polipo /usr/bin/polipo -c /etc/polipo/config pidFile=/var/run/polipo/polipo.pid daemonise=true
192Ssl 119 3392156 1 76472 1688 0.0 15-02:34:39 ntpd /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 119:126
193Ss 120 3392168 1 4656 276 0.0 15-02:34:39 rpc.statd /sbin/rpc.statd --no-notify
194Ss 0 3392171 1 5072 432 0.0 15-02:34:39 rpc.mountd /usr/sbin/rpc.mountd --manage-gids
195Ss 0 3392176 1 5008 288 0.0 15-02:34:39 rpc.idmapd /usr/sbin/rpc.idmapd
196Ss 105 3392184 1 15544 6816 3.5 15-02:34:39 avahi-daemon avahi-daemon: running [tsui.local]
197Ss 0 3392186 1 25288 3860 0.0 15-02:34:39 systemd-udevd /lib/systemd/systemd-udevd
198S 105 3392190 3392184 8788 52 0.0 15-02:34:39 avahi-daemon avahi-daemon: chroot helper
199Ssl 0 3392197 1 396120 4188 0.0 15-02:34:39 udisksd /usr/libexec/udisks2/udisksd
200Ssl 0 3392214 1 237504 6632 0.0 15-02:34:39 polkitd /usr/libexec/polkitd --no-debug
201Ss 0 3392284 1 9684 560 0.0 15-02:34:38 xinetd /usr/sbin/xinetd -pidfile /run/xinetd.pid -stayalive -inetd_compat -inetd_ipv6
202Ssl 0 3392285 1 314840 1352 0.0 15-02:34:38 ModemManager /usr/sbin/ModemManager
203Ss 0 3392317 1 2352 140 0.0 15-02:34:38 acpid /usr/sbin/acpid
204S 0 3392400 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
205S 0 3392401 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
206S 0 3392402 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
207S 0 3392403 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
208S 0 3392404 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
209S 0 3392405 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
210S 0 3392407 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
211S 0 3392410 2 0 0 0.0 15-02:34:38 nfsd [nfsd]
212Ss 0 3392551 1 40092 1304 0.0 15-02:34:37 master /usr/lib/postfix/sbin/master -w
213S 117 3392553 3392551 40156 568 0.0 15-02:34:37 qmgr qmgr -l -t unix -u
214Ss 0 3392650 1 63652 4 0.0 15-02:34:36 squid /usr/sbin/squid --foreground -sYC
215Ssl 116 3392652 1 1675196 93848 0.0 15-02:34:36 mariadbd /usr/sbin/mariadbd
216S 13 3392655 3392650 81776 21232 0.0 15-02:34:36 squid (squid-1) --kid squid-1 --foreground -sYC
217S 13 3392657 3392655 5572 68 0.0 15-02:34:36 log_file_daemon (logfile-daemon) /var/log/squid/access.log
218S<s 0 3393034 1 216648 7560 0.0 15-02:34:34 apache2 /usr/sbin/apache2 -k start
219Ss 33 3393037 1 3432 180 0.0 15-02:34:34 htcacheclean /usr/bin/htcacheclean -d 120 -p /var/cache/apache2/mod_cache_disk -l 300M -n
diff --git a/plugins/tests/var/ps_axwo.debian b/plugins/tests/var/ps_axwo.debian
deleted file mode 100644
index 37a2d35..0000000
--- a/plugins/tests/var/ps_axwo.debian
+++ /dev/null
@@ -1,84 +0,0 @@
1STAT UID PID PPID VSZ RSS %CPU COMMAND COMMAND
2S 0 1 0 1504 428 0.0 init init [2]
3SN 0 2 1 0 0 0.0 ksoftirqd/0 [ksoftirqd/0]
4S< 0 3 1 0 0 0.0 events/0 [events/0]
5S< 0 4 3 0 0 0.0 khelper [khelper]
6S< 0 5 3 0 0 0.0 kacpid [kacpid]
7S< 0 38 3 0 0 0.0 kblockd/0 [kblockd/0]
8S 0 48 3 0 0 0.0 pdflush [pdflush]
9S< 0 51 3 0 0 0.0 aio/0 [aio/0]
10S 0 50 1 0 0 0.0 kswapd0 [kswapd0]
11S 0 193 1 0 0 0.0 kseriod [kseriod]
12S 0 214 1 0 0 0.0 scsi_eh_0 [scsi_eh_0]
13S 0 221 1 0 0 0.0 khubd [khubd]
14S 0 299 1 0 0 0.3 kjournald [kjournald]
15S 0 1148 1 0 0 0.0 pciehpd_event [pciehpd_event]
16S 0 1168 1 0 0 0.0 shpchpd_event [shpchpd_event]
17Ss 1 1795 1 1612 276 0.0 portmap /sbin/portmap
18Ss 0 2200 1 1652 568 0.0 vmware-guestd /usr/sbin/vmware-guestd --background /var/run/vmware-guestd.pid
19Ss 0 2209 1 2240 532 0.0 inetd /usr/sbin/inetd
20Ss 0 2319 1 3468 792 0.0 sshd /usr/sbin/sshd
21Ss 0 2323 1 2468 676 0.0 rpc.statd /sbin/rpc.statd
22Ss 1 2332 1 1684 488 0.0 atd /usr/sbin/atd
23Ss 0 2335 1 1764 636 0.0 cron /usr/sbin/cron
24Ss+ 0 2350 1 1500 348 0.0 getty /sbin/getty 38400 tty1
25Ss+ 0 2351 1 1500 348 0.0 getty /sbin/getty 38400 tty2
26Ss+ 0 2352 1 1500 348 0.0 getty /sbin/getty 38400 tty3
27Ss+ 0 2353 1 1500 348 0.0 getty /sbin/getty 38400 tty4
28Ss+ 0 2354 1 1500 348 0.0 getty /sbin/getty 38400 tty5
29Ss+ 0 2355 1 1500 348 0.0 getty /sbin/getty 38400 tty6
30S 0 6907 1 2308 892 0.0 mysqld_safe /bin/sh /usr/bin/mysqld_safe
31S 103 6944 6907 123220 27724 0.0 mysqld /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
32S 0 6945 6907 1488 420 0.0 logger logger -p daemon.err -t mysqld_safe -i -t mysqld
33S 1001 17778 1 6436 1588 0.0 snmpd /usr/sbin/snmpd -u nagios -Lsd -Lf /dev/null -p/var/run/snmpd.pid
34Ss 0 17789 1 9496 5556 0.0 snmptrapd /usr/sbin/snmptrapd -t -m ALL -M /usr/share/snmp/mibs:/usr/local/monitoring/snmp/load -p /var/run/snmptrapd.pid
35Ss 0 847 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
36S 1000 857 847 14616 1832 0.0 sshd sshd: tonvoon@pts/3
37Ss 1000 860 857 2984 1620 0.0 bash -bash
38S 0 868 860 2588 1428 0.0 bash -su
39S+ 1001 877 868 2652 1568 0.0 bash -su
40S 0 6086 3 0 0 0.0 pdflush [pdflush]
41Ss 0 17832 2319 14452 1752 0.0 sshd sshd: tonvoon [priv]
42S 1000 18155 17832 14620 1840 0.0 sshd sshd: tonvoon@pts/0
43Ss 1000 18156 18155 2984 1620 0.0 bash -bash
44S 0 18518 18156 2588 1428 0.0 bash -su
45S 1001 18955 18518 2672 1600 0.0 bash -su
46Ss 0 21683 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
47S 1000 21742 21683 14620 1896 0.0 sshd sshd: tonvoon@pts/1
48Ss 1000 21743 21742 2984 1620 0.0 bash -bash
49S 0 21748 21743 2592 1432 0.0 bash -su
50S 1001 21757 21748 2620 1540 0.0 bash -su
51Ss 0 2334 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
52S 1000 2343 2334 14620 1840 0.0 sshd sshd: tonvoon@pts/2
53Ss 1000 2344 2343 2984 1620 0.0 bash -bash
54S 0 2349 2344 2592 1432 0.0 bash -su
55S+ 1001 2364 2349 2620 1520 0.0 bash -su
56T 1001 2454 2364 2096 1032 0.0 vi vi configure.in.rej
57S+ 1001 8500 21757 69604 52576 0.0 opsview_web_ser /usr/bin/perl -w ./script/opsview_web_server.pl -f -d
58Ss 0 7609 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
59S 1000 7617 7609 14460 1828 0.0 sshd sshd: tonvoon@pts/4
60Ss 1000 7618 7617 2984 1620 0.0 bash -bash
61S 0 7623 7618 2592 1432 0.0 bash -su
62S+ 1001 7632 7623 2620 1528 0.0 bash -su
63Ss 1001 12678 1 20784 17728 0.0 opsviewd opsviewd
64Ss 0 832 1 14512 6360 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
65S 33 842 832 14648 6596 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
66S 33 843 832 14512 6504 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
67S 33 844 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
68S 33 845 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
69S 33 846 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
70Ss 7 4081 1 2464 884 0.0 lpd /usr/sbin/lpd -s
71S 33 26484 832 14512 6476 0.0 apache2 /usr/sbin/apache2 -k start -DSSL
72Ss 1001 22324 1 20252 1612 0.1 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
73Ss 0 23336 2319 14452 1756 0.0 sshd sshd: tonvoon [priv]
74S 1000 23339 23336 14620 1840 0.0 sshd sshd: tonvoon@pts/5
75Ss 1000 23340 23339 2996 1636 0.0 bash -bash
76S 0 23367 23340 3020 1628 0.0 bash bash
77S 1001 23370 23367 3064 1748 0.0 bash bash
78Ss 1001 23783 1 3220 764 0.0 ndo2db /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg
79Ss 1001 23784 1 6428 4948 0.0 import_ndologsd import_ndologsd
80S+ 1001 9803 18955 4132 1936 0.0 ssh ssh altinity@cube02.lei.altinity
81S 1001 22505 22324 20256 1616 0.0 nagios ../../bin/nagios -d /usr/local/nagios/etc/nagios.cfg
82S 1001 22506 22505 1676 608 0.0 check_ping /usr/local/libexec/check_ping -H 192.168.10.23 -w 3000.0,80% -c 5000.0,100% -p 1
83S 1001 22507 22506 1660 492 0.0 ping /bin/ping -n -U -w 10 -c 1 192.168.10.23
84R+ 1001 22508 23370 2308 680 0.0 ps ps axwo stat uid pid ppid vsz rss pcpu comm args
diff --git a/plugins/utils.c b/plugins/utils.c
index ebdae2e..b4214c6 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -589,10 +589,12 @@ char *perfdata (const char *label,
589 xasprintf (&data, "%s;", data); 589 xasprintf (&data, "%s;", data);
590 590
591 if (minp) 591 if (minp)
592 xasprintf (&data, "%s%ld", data, minv); 592 xasprintf (&data, "%s%ld;", data, minv);
593 else
594 xasprintf (&data, "%s;", data);
593 595
594 if (maxp) 596 if (maxp)
595 xasprintf (&data, "%s;%ld", data, maxv); 597 xasprintf (&data, "%s%ld", data, maxv);
596 598
597 return data; 599 return data;
598} 600}
@@ -613,27 +615,27 @@ char *perfdata_uint64 (const char *label,
613 char *data = NULL; 615 char *data = NULL;
614 616
615 if (strpbrk (label, "'= ")) 617 if (strpbrk (label, "'= "))
616 xasprintf (&data, "'%s'=%ld%s;", label, val, uom); 618 xasprintf (&data, "'%s'=%" PRIu64 "%s;", label, val, uom);
617 else 619 else
618 xasprintf (&data, "%s=%ld%s;", label, val, uom); 620 xasprintf (&data, "%s=%" PRIu64 "%s;", label, val, uom);
619 621
620 if (warnp) 622 if (warnp)
621 xasprintf (&data, "%s%lu;", data, warn); 623 xasprintf (&data, "%s%" PRIu64 ";", data, warn);
622 else 624 else
623 xasprintf (&data, "%s;", data); 625 xasprintf (&data, "%s;", data);
624 626
625 if (critp) 627 if (critp)
626 xasprintf (&data, "%s%lu;", data, crit); 628 xasprintf (&data, "%s%" PRIu64 ";", data, crit);
627 else 629 else
628 xasprintf (&data, "%s;", data); 630 xasprintf (&data, "%s;", data);
629 631
630 if (minp) 632 if (minp)
631 xasprintf (&data, "%s%lu;", data, minv); 633 xasprintf (&data, "%s%" PRIu64 ";", data, minv);
632 else 634 else
633 xasprintf (&data, "%s;", data); 635 xasprintf (&data, "%s;", data);
634 636
635 if (maxp) 637 if (maxp)
636 xasprintf (&data, "%s%lu", data, maxv); 638 xasprintf (&data, "%s%" PRIu64, data, maxv);
637 639
638 return data; 640 return data;
639} 641}
@@ -654,27 +656,27 @@ char *perfdata_int64 (const char *label,
654 char *data = NULL; 656 char *data = NULL;
655 657
656 if (strpbrk (label, "'= ")) 658 if (strpbrk (label, "'= "))
657 xasprintf (&data, "'%s'=%ld%s;", label, val, uom); 659 xasprintf (&data, "'%s'=%" PRId64 "%s;", label, val, uom);
658 else 660 else
659 xasprintf (&data, "%s=%ld%s;", label, val, uom); 661 xasprintf (&data, "%s=%" PRId64 "%s;", label, val, uom);
660 662
661 if (warnp) 663 if (warnp)
662 xasprintf (&data, "%s%ld;", data, warn); 664 xasprintf (&data, "%s%" PRId64 ";", data, warn);
663 else 665 else
664 xasprintf (&data, "%s;", data); 666 xasprintf (&data, "%s;", data);
665 667
666 if (critp) 668 if (critp)
667 xasprintf (&data, "%s%ld;", data, crit); 669 xasprintf (&data, "%s%" PRId64 ";", data, crit);
668 else 670 else
669 xasprintf (&data, "%s;", data); 671 xasprintf (&data, "%s;", data);
670 672
671 if (minp) 673 if (minp)
672 xasprintf (&data, "%s%ld;", data, minv); 674 xasprintf (&data, "%s%" PRId64 ";", data, minv);
673 else 675 else
674 xasprintf (&data, "%s;", data); 676 xasprintf (&data, "%s;", data);
675 677
676 if (maxp) 678 if (maxp)
677 xasprintf (&data, "%s%ld", data, maxv); 679 xasprintf (&data, "%s%" PRId64, data, maxv);
678 680
679 return data; 681 return data;
680} 682}
diff --git a/plugins/utils.h b/plugins/utils.h
index 5b54da3..c76b321 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -7,7 +7,7 @@
7/* The purpose of this package is to provide safer alternatives to C 7/* The purpose of this package is to provide safer alternatives to C
8functions that might otherwise be vulnerable to hacking. This 8functions that might otherwise be vulnerable to hacking. This
9currently includes a standard suite of validation routines to be sure 9currently includes a standard suite of validation routines to be sure
10that an string argument acually converts to its intended type and a 10that an string argument actually converts to its intended type and a
11suite of string handling routine that do their own memory management 11suite of string handling routine that do their own memory management
12in order to resist overflow attacks. In addition, a few functions are 12in order to resist overflow attacks. In addition, a few functions are
13provided to standardize version and error reporting across the entire 13provided to standardize version and error reporting across the entire
diff --git a/po/Makevars b/po/Makevars
index 1bf1e0d..b35f5ad 100644
--- a/po/Makevars
+++ b/po/Makevars
@@ -8,7 +8,7 @@ subdir = po
8top_builddir = .. 8top_builddir = ..
9 9
10# These options get passed to xgettext. 10# These options get passed to xgettext.
11XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format 11XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --flag=error:3:c-format --flag=error_at_line:5:c-format --flag=asprintf:2:c-format --flag=vasprintf:2:c-format --no-location
12 12
13# This is the copyright holder that gets inserted into the header of the 13# This is the copyright holder that gets inserted into the header of the
14# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding 14# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
diff --git a/po/de.po b/po/de.po
index 919fae3..d597203 100644
--- a/po/de.po
+++ b/po/de.po
@@ -1,119 +1,86 @@
1# translation of de.po to 1# translation of de.po to
2# German Language Translation File. 2# German Language Translation File.
3# This file is distributed under the same license as the nagios-plugins package. 3# This file is distributed under the same license as the nagios-plugins package.
4# Copyright (C) 2004 Nagios Plugin Development Group. 4# Copyright (C) 2023 Nagios Plugin Development Group.
5# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003, 2004. 5# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003, 2004.
6# 6#
7# 7#
8msgid "" 8msgid ""
9msgstr "" 9msgstr ""
10"Project-Id-Version: nagiosplug\n" 10"Project-Id-Version: PACKAGE VERSION\n"
11"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 11"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
12"POT-Creation-Date: 2014-01-19 16:30-0500\n" 12"POT-Creation-Date: 2023-09-05 00:31+0200\n"
13"PO-Revision-Date: 2004-12-23 17:46+0100\n" 13"PO-Revision-Date: 2004-12-23 17:46+0100\n"
14"Last-Translator: <>\n" 14"Last-Translator: \n"
15"Language-Team: English <en@li.org>\n" 15"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins.org>\n"
16"Language: de\n"
16"MIME-Version: 1.0\n" 17"MIME-Version: 1.0\n"
17"Content-Type: text/plain; charset=iso-8859-1\n" 18"Content-Type: text/plain; charset=UTF-8\n"
18"Content-Transfer-Encoding: 8bit\n" 19"Content-Transfer-Encoding: 8bit\n"
19"Language: en\n" 20"Plural-Forms: nplurals=2; plural=(n > 1);\n"
20"Plural-Forms: nplurals=2; plural=(n > 1);X-Generator: KBabel 1.3.1\n" 21"X-Generator: KBabel 1.3.1\n"
21 22
22#: plugins/check_by_ssh.c:86 plugins/check_cluster.c:76 plugins/check_dig.c:88
23#: plugins/check_disk.c:194 plugins/check_dns.c:102 plugins/check_dummy.c:52
24#: plugins/check_fping.c:93 plugins/check_game.c:82 plugins/check_hpjd.c:103
25#: plugins/check_http.c:167 plugins/check_ldap.c:109 plugins/check_load.c:122
26#: plugins/check_mrtgtraf.c:83 plugins/check_mysql.c:122
27#: plugins/check_nagios.c:91 plugins/check_nt.c:127 plugins/check_ntp.c:770
28#: plugins/check_ntp_peer.c:575 plugins/check_ntp_time.c:552
29#: plugins/check_nwstat.c:173 plugins/check_overcr.c:102
30#: plugins/check_pgsql.c:172 plugins/check_ping.c:95 plugins/check_procs.c:172
31#: plugins/check_radius.c:160 plugins/check_real.c:80 plugins/check_smtp.c:144
32#: plugins/check_snmp.c:240 plugins/check_ssh.c:73 plugins/check_swap.c:110
33#: plugins/check_tcp.c:218 plugins/check_time.c:78 plugins/check_ups.c:122
34#: plugins/check_users.c:77 plugins/negate.c:214 plugins-root/check_dhcp.c:270
35msgid "Could not parse arguments" 23msgid "Could not parse arguments"
36msgstr "Argumente konnten nicht ausgewertet werden" 24msgstr "Argumente konnten nicht ausgewertet werden"
37 25
38#: plugins/check_by_ssh.c:90 plugins/check_dig.c:82 plugins/check_dns.c:95
39#: plugins/check_nagios.c:95 plugins/check_pgsql.c:178 plugins/check_ping.c:99
40#: plugins/check_procs.c:188 plugins/check_snmp.c:336 plugins/negate.c:79
41msgid "Cannot catch SIGALRM" 26msgid "Cannot catch SIGALRM"
42msgstr "Konnte SIGALRM nicht erhalten" 27msgstr "Konnte SIGALRM nicht erhalten"
43 28
44#: plugins/check_by_ssh.c:110 29#, c-format
30msgid "SSH connection failed: %s\n"
31msgstr ""
32
45#, c-format 33#, c-format
46msgid "Remote command execution failed: %s\n" 34msgid "Remote command execution failed: %s\n"
47msgstr "" 35msgstr ""
48 36
49#: plugins/check_by_ssh.c:122
50#, c-format 37#, c-format
51msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n" 38msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n"
52msgstr "" 39msgstr ""
53 40
54#: plugins/check_by_ssh.c:134
55#, c-format 41#, c-format
56msgid "SSH WARNING: could not open %s\n" 42msgid "SSH WARNING: could not open %s\n"
57msgstr "SSH WARNING: Konnte %s nicht öffnen\n" 43msgstr "SSH WARNING: Konnte %s nicht öffnen\n"
58 44
59#: plugins/check_by_ssh.c:143
60#, c-format 45#, c-format
61msgid "%s: Error parsing output\n" 46msgid "%s: Error parsing output\n"
62msgstr "" 47msgstr ""
63 48
64#: plugins/check_by_ssh.c:220 plugins/check_disk.c:476
65#: plugins/check_http.c:278 plugins/check_ldap.c:293 plugins/check_pgsql.c:311
66#: plugins/check_procs.c:437 plugins/check_radius.c:308
67#: plugins/check_real.c:356 plugins/check_smtp.c:581 plugins/check_snmp.c:736
68#: plugins/check_ssh.c:138 plugins/check_tcp.c:505 plugins/check_time.c:302
69#: plugins/check_ups.c:556 plugins/negate.c:164
70msgid "Timeout interval must be a positive integer" 49msgid "Timeout interval must be a positive integer"
71msgstr "Timeout interval muss ein positiver Integer sein" 50msgstr "Timeout interval muss ein positiver Integer sein"
72 51
73#: plugins/check_by_ssh.c:230 plugins/check_pgsql.c:341
74#: plugins/check_radius.c:272 plugins/check_real.c:327
75#: plugins/check_smtp.c:506 plugins/check_tcp.c:511 plugins/check_time.c:296
76#: plugins/check_ups.c:518
77msgid "Port must be a positive integer" 52msgid "Port must be a positive integer"
78msgstr "Port muss ein positiver Integer sein" 53msgstr "Port muss ein positiver Integer sein"
79 54
80#: plugins/check_by_ssh.c:291
81#, fuzzy 55#, fuzzy
82msgid "skip-stdout argument must be an integer" 56msgid "skip-stdout argument must be an integer"
83msgstr "skip-stdout argument muss ein Integer sein" 57msgstr "skip-stdout argument muss ein Integer sein"
84 58
85#: plugins/check_by_ssh.c:299
86#, fuzzy 59#, fuzzy
87msgid "skip-stderr argument must be an integer" 60msgid "skip-stderr argument must be an integer"
88msgstr "skip-stderr argument muss ein Integer sein" 61msgstr "skip-stderr argument muss ein Integer sein"
89 62
90#: plugins/check_by_ssh.c:322
91#, c-format 63#, c-format
92msgid "%s: You must provide a host name\n" 64msgid "%s: You must provide a host name\n"
93msgstr "%s: Hostname muss angegeben werden\n" 65msgstr "%s: Hostname muss angegeben werden\n"
94 66
95#: plugins/check_by_ssh.c:340
96msgid "No remotecmd" 67msgid "No remotecmd"
97msgstr "Kein remotecm" 68msgstr "Kein remotecm"
98 69
99#: plugins/check_by_ssh.c:354
100#, c-format 70#, c-format
101msgid "%s: Argument limit of %d exceeded\n" 71msgid "%s: Argument limit of %d exceeded\n"
102msgstr "" 72msgstr ""
103 73
104#: plugins/check_by_ssh.c:357
105#, fuzzy 74#, fuzzy
106msgid "Can not (re)allocate 'commargv' buffer\n" 75msgid "Can not (re)allocate 'commargv' buffer\n"
107msgstr "Konnte·url·nicht·zuweisen\n" 76msgstr "Konnte·url·nicht·zuweisen\n"
108 77
109#: plugins/check_by_ssh.c:371
110#, c-format 78#, c-format
111msgid "" 79msgid ""
112"%s: In passive mode, you must provide a service name for each command.\n" 80"%s: In passive mode, you must provide a service name for each command.\n"
113msgstr "" 81msgstr ""
114"%s: Im passive mode muss ein Servicename für jeden Befehl angegeben werden.\n" 82"%s: Im passive mode muss ein Servicename für jeden Befehl angegeben werden.\n"
115 83
116#: plugins/check_by_ssh.c:374
117#, fuzzy, c-format 84#, fuzzy, c-format
118msgid "" 85msgid ""
119"%s: In passive mode, you must provide the host short name from the " 86"%s: In passive mode, you must provide the host short name from the "
@@ -122,262 +89,188 @@ msgstr ""
122"%s: Im passive mode muss der \"host short name\" aus der Nagios " 89"%s: Im passive mode muss der \"host short name\" aus der Nagios "
123"Konfiguration angegeben werden\n" 90"Konfiguration angegeben werden\n"
124 91
125#: plugins/check_by_ssh.c:388
126#, fuzzy, c-format 92#, fuzzy, c-format
127msgid "This plugin uses SSH to execute commands on a remote host" 93msgid "This plugin uses SSH to execute commands on a remote host"
128msgstr "" 94msgstr ""
129"Dieses Plugin nutzt SSH um Befehle auf dem entfernten Rechner auszuführen\n" 95"Dieses Plugin nutzt SSH um Befehle auf dem entfernten Rechner auszuführen\n"
130"\n" 96"\n"
131 97
132#: plugins/check_by_ssh.c:403
133msgid "tell ssh to use Protocol 1 [optional]" 98msgid "tell ssh to use Protocol 1 [optional]"
134msgstr "" 99msgstr ""
135 100
136#: plugins/check_by_ssh.c:405
137msgid "tell ssh to use Protocol 2 [optional]" 101msgid "tell ssh to use Protocol 2 [optional]"
138msgstr "" 102msgstr ""
139 103
140#: plugins/check_by_ssh.c:407
141msgid "Ignore all or (if specified) first n lines on STDOUT [optional]" 104msgid "Ignore all or (if specified) first n lines on STDOUT [optional]"
142msgstr "" 105msgstr ""
143 106
144#: plugins/check_by_ssh.c:409
145msgid "Ignore all or (if specified) first n lines on STDERR [optional]" 107msgid "Ignore all or (if specified) first n lines on STDERR [optional]"
146msgstr "" 108msgstr ""
147 109
148#: plugins/check_by_ssh.c:411 110msgid "Exit with an warning, if there is an output on STDERR"
111msgstr ""
112
149msgid "" 113msgid ""
150"tells ssh to fork rather than create a tty [optional]. This will always " 114"tells ssh to fork rather than create a tty [optional]. This will always "
151"return OK if ssh is executed" 115"return OK if ssh is executed"
152msgstr "" 116msgstr ""
153 117
154#: plugins/check_by_ssh.c:413
155msgid "command to execute on the remote machine" 118msgid "command to execute on the remote machine"
156msgstr "" 119msgstr ""
157 120
158#: plugins/check_by_ssh.c:415
159msgid "SSH user name on remote host [optional]" 121msgid "SSH user name on remote host [optional]"
160msgstr "" 122msgstr ""
161 123
162#: plugins/check_by_ssh.c:417
163msgid "identity of an authorized key [optional]" 124msgid "identity of an authorized key [optional]"
164msgstr "" 125msgstr ""
165 126
166#: plugins/check_by_ssh.c:419
167msgid "external command file for monitoring [optional]" 127msgid "external command file for monitoring [optional]"
168msgstr "" 128msgstr ""
169 129
170#: plugins/check_by_ssh.c:421
171msgid "list of monitoring service names, separated by ':' [optional]" 130msgid "list of monitoring service names, separated by ':' [optional]"
172msgstr "" 131msgstr ""
173 132
174#: plugins/check_by_ssh.c:423
175msgid "short name of host in the monitoring configuration [optional]" 133msgid "short name of host in the monitoring configuration [optional]"
176msgstr "" 134msgstr ""
177 135
178#: plugins/check_by_ssh.c:425
179msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]" 136msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]"
180msgstr "" 137msgstr ""
181 138
182#: plugins/check_by_ssh.c:427
183msgid "Tell ssh to use this configfile [optional]" 139msgid "Tell ssh to use this configfile [optional]"
184msgstr "" 140msgstr ""
185 141
186#: plugins/check_by_ssh.c:429
187msgid "Tell ssh to suppress warning and diagnostic messages [optional]" 142msgid "Tell ssh to suppress warning and diagnostic messages [optional]"
188msgstr "" 143msgstr ""
189 144
190#: plugins/check_by_ssh.c:434 145msgid "Make connection problems return UNKNOWN instead of CRITICAL"
146msgstr ""
147
191msgid "The most common mode of use is to refer to a local identity file with" 148msgid "The most common mode of use is to refer to a local identity file with"
192msgstr "" 149msgstr ""
193 150
194#: plugins/check_by_ssh.c:435
195msgid "the '-i' option. In this mode, the identity pair should have a null" 151msgid "the '-i' option. In this mode, the identity pair should have a null"
196msgstr "" 152msgstr ""
197 153
198#: plugins/check_by_ssh.c:436
199msgid "passphrase and the public key should be listed in the authorized_keys" 154msgid "passphrase and the public key should be listed in the authorized_keys"
200msgstr "" 155msgstr ""
201 156
202#: plugins/check_by_ssh.c:437
203msgid "file of the remote host. Usually the key will be restricted to running" 157msgid "file of the remote host. Usually the key will be restricted to running"
204msgstr "" 158msgstr ""
205 159
206#: plugins/check_by_ssh.c:438
207msgid "only one command on the remote server. If the remote SSH server tracks" 160msgid "only one command on the remote server. If the remote SSH server tracks"
208msgstr "" 161msgstr ""
209 162
210#: plugins/check_by_ssh.c:439
211msgid "invocation arguments, the one remote program may be an agent that can" 163msgid "invocation arguments, the one remote program may be an agent that can"
212msgstr "" 164msgstr ""
213 165
214#: plugins/check_by_ssh.c:440
215msgid "execute additional commands as proxy" 166msgid "execute additional commands as proxy"
216msgstr "" 167msgstr ""
217 168
218#: plugins/check_by_ssh.c:442
219msgid "To use passive mode, provide multiple '-C' options, and provide" 169msgid "To use passive mode, provide multiple '-C' options, and provide"
220msgstr "" 170msgstr ""
221 171
222#: plugins/check_by_ssh.c:443
223msgid "" 172msgid ""
224"all of -O, -s, and -n options (servicelist order must match '-C'options)" 173"all of -O, -s, and -n options (servicelist order must match '-C'options)"
225msgstr "" 174msgstr ""
226 175
227#: plugins/check_by_ssh.c:445 plugins/check_cluster.c:261
228#: plugins/check_dig.c:355 plugins/check_disk.c:924 plugins/check_http.c:1560
229#: plugins/check_nagios.c:312 plugins/check_ntp.c:869
230#: plugins/check_ntp_peer.c:705 plugins/check_ntp_time.c:633
231#: plugins/check_procs.c:763 plugins/negate.c:271 plugins/urlize.c:180
232msgid "Examples:" 176msgid "Examples:"
233msgstr "" 177msgstr ""
234 178
235#: plugins/check_by_ssh.c:460 plugins/check_cluster.c:274
236#: plugins/check_dig.c:367 plugins/check_disk.c:941 plugins/check_dns.c:486
237#: plugins/check_dummy.c:122 plugins/check_fping.c:505
238#: plugins/check_game.c:331 plugins/check_hpjd.c:414 plugins/check_http.c:1590
239#: plugins/check_ldap.c:451 plugins/check_load.c:334 plugins/check_mrtg.c:382
240#: plugins/check_mysql.c:569 plugins/check_nagios.c:323 plugins/check_nt.c:774
241#: plugins/check_ntp.c:888 plugins/check_ntp_peer.c:725
242#: plugins/check_ntp_time.c:642 plugins/check_nwstat.c:1685
243#: plugins/check_overcr.c:467 plugins/check_pgsql.c:578
244#: plugins/check_ping.c:603 plugins/check_procs.c:781
245#: plugins/check_radius.c:385 plugins/check_real.c:451
246#: plugins/check_smtp.c:843 plugins/check_snmp.c:1207 plugins/check_ssh.c:309
247#: plugins/check_swap.c:558 plugins/check_tcp.c:684 plugins/check_time.c:371
248#: plugins/check_ups.c:660 plugins/check_users.c:240
249#: plugins/check_ide_smart.c:640 plugins/negate.c:295 plugins/urlize.c:197
250#: plugins-root/check_dhcp.c:1422 plugins-root/check_icmp.c:1354
251msgid "Usage:" 179msgid "Usage:"
252msgstr "" 180msgstr ""
253 181
254#: plugins/check_cluster.c:230
255#, c-format 182#, c-format
256msgid "Host/Service Cluster Plugin for Monitoring" 183msgid "Host/Service Cluster Plugin for Monitoring"
257msgstr "" 184msgstr ""
258 185
259#: plugins/check_cluster.c:236 plugins/check_nt.c:676
260msgid "Options:" 186msgid "Options:"
261msgstr "" 187msgstr ""
262 188
263#: plugins/check_cluster.c:239
264msgid "Check service cluster status" 189msgid "Check service cluster status"
265msgstr "" 190msgstr ""
266 191
267#: plugins/check_cluster.c:241
268msgid "Check host cluster status" 192msgid "Check host cluster status"
269msgstr "" 193msgstr ""
270 194
271#: plugins/check_cluster.c:243
272msgid "Optional prepended text output (i.e. \"Host cluster\")" 195msgid "Optional prepended text output (i.e. \"Host cluster\")"
273msgstr "" 196msgstr ""
274 197
275#: plugins/check_cluster.c:245 plugins/check_cluster.c:248
276msgid "Specifies the range of hosts or services in cluster that must be in a" 198msgid "Specifies the range of hosts or services in cluster that must be in a"
277msgstr "" 199msgstr ""
278 200
279#: plugins/check_cluster.c:246
280msgid "non-OK state in order to return a WARNING status level" 201msgid "non-OK state in order to return a WARNING status level"
281msgstr "" 202msgstr ""
282 203
283#: plugins/check_cluster.c:249
284msgid "non-OK state in order to return a CRITICAL status level" 204msgid "non-OK state in order to return a CRITICAL status level"
285msgstr "" 205msgstr ""
286 206
287#: plugins/check_cluster.c:251
288msgid "The status codes of the hosts or services in the cluster, separated by" 207msgid "The status codes of the hosts or services in the cluster, separated by"
289msgstr "" 208msgstr ""
290 209
291#: plugins/check_cluster.c:252
292msgid "commas" 210msgid "commas"
293msgstr "" 211msgstr ""
294 212
295#: plugins/check_cluster.c:257 plugins/check_game.c:318
296#: plugins/check_http.c:1542 plugins/check_ldap.c:438 plugins/check_mrtg.c:363
297#: plugins/check_mrtgtraf.c:361 plugins/check_mysql.c:558
298#: plugins/check_nt.c:758 plugins/check_ntp.c:865 plugins/check_ntp_peer.c:696
299#: plugins/check_ntp_time.c:626 plugins/check_nwstat.c:1670
300#: plugins/check_overcr.c:456 plugins/check_snmp.c:1178
301#: plugins/check_swap.c:547 plugins/check_ups.c:642 plugins/negate.c:277
302#: plugins-root/check_icmp.c:1329
303msgid "Notes:" 213msgid "Notes:"
304msgstr "" 214msgstr ""
305 215
306#: plugins/check_cluster.c:263
307msgid "" 216msgid ""
308"Will alert critical if there are 3 or more service data points in a non-OK" 217"Will alert critical if there are 3 or more service data points in a non-OK"
309msgstr "" 218msgstr ""
310 219
311#: plugins/check_cluster.c:264 plugins/check_ups.c:639
312msgid "state." 220msgid "state."
313msgstr "" 221msgstr ""
314 222
315#: plugins/check_dig.c:100 plugins/check_dig.c:102
316#, c-format 223#, c-format
317msgid "Looking for: '%s'\n" 224msgid "Looking for: '%s'\n"
318msgstr "" 225msgstr ""
319 226
320#: plugins/check_dig.c:109
321msgid "dig returned an error status" 227msgid "dig returned an error status"
322msgstr "dig hat einen Fehler zurückgegeben" 228msgstr "dig hat einen Fehler zurückgegeben"
323 229
324#: plugins/check_dig.c:134
325msgid "Server not found in ANSWER SECTION" 230msgid "Server not found in ANSWER SECTION"
326msgstr "Server nicht gefunden in ANSWER SECTION" 231msgstr "Server nicht gefunden in ANSWER SECTION"
327 232
328#: plugins/check_dig.c:144
329msgid "No ANSWER SECTION found" 233msgid "No ANSWER SECTION found"
330msgstr "Keine ANSWER SECTION gefunden" 234msgstr "Keine ANSWER SECTION gefunden"
331 235
332#: plugins/check_dig.c:171
333#, fuzzy 236#, fuzzy
334msgid "Probably a non-existent host/domain" 237msgid "Probably a non-existent host/domain"
335msgstr "nicht existierender Host/Domain" 238msgstr "nicht existierender Host/Domain"
336 239
337#: plugins/check_dig.c:233
338#, fuzzy, c-format 240#, fuzzy, c-format
339msgid "Port must be a positive integer - %s" 241msgid "Port must be a positive integer - %s"
340msgstr "Port muss ein positiver Integer sein - %s" 242msgstr "Port muss ein positiver Integer sein - %s"
341 243
342#: plugins/check_dig.c:244
343#, fuzzy, c-format 244#, fuzzy, c-format
344msgid "Warning interval must be a positive integer - %s" 245msgid "Warning interval must be a positive integer - %s"
345msgstr "Warning interval muss ein positiver Integer sein - %s" 246msgstr "Warning interval muss ein positiver Integer sein - %s"
346 247
347#: plugins/check_dig.c:252
348#, fuzzy, c-format 248#, fuzzy, c-format
349msgid "Critical interval must be a positive integer - %s" 249msgid "Critical interval must be a positive integer - %s"
350msgstr "Critical interval muss ein positiver Integer sein - %s" 250msgstr "Critical interval muss ein positiver Integer sein - %s"
351 251
352#: plugins/check_dig.c:260
353#, fuzzy, c-format 252#, fuzzy, c-format
354msgid "Timeout interval must be a positive integer - %s" 253msgid "Timeout interval must be a positive integer - %s"
355msgstr "Timeout interval muss ein positiver Integer sein - %s" 254msgstr "Timeout interval muss ein positiver Integer sein - %s"
356 255
357#: plugins/check_dig.c:325
358#, fuzzy, c-format 256#, fuzzy, c-format
359msgid "This plugin test the DNS service on the specified host using dig" 257msgid "This plugin tests the DNS service on the specified host using dig"
360msgstr "Testet den DNS Dienst auf dem angegebenen Host mit dig" 258msgstr "Testet den DNS Dienst auf dem angegebenen Host mit dig"
361 259
362#: plugins/check_dig.c:338
363msgid "Force dig to only use IPv4 query transport" 260msgid "Force dig to only use IPv4 query transport"
364msgstr "" 261msgstr ""
365 262
366#: plugins/check_dig.c:340
367msgid "Force dig to only use IPv6 query transport" 263msgid "Force dig to only use IPv6 query transport"
368msgstr "" 264msgstr ""
369 265
370#: plugins/check_dig.c:342
371#, fuzzy 266#, fuzzy
372msgid "Machine name to lookup" 267msgid "Machine name to lookup"
373msgstr "zu prüfender Hostname" 268msgstr "zu prüfender Hostname"
374 269
375#: plugins/check_dig.c:344
376#, fuzzy 270#, fuzzy
377msgid "Record type to lookup (default: A)" 271msgid "Record type to lookup (default: A)"
378msgstr "abzufragender Datensatztyp (Default: A)" 272msgstr "abzufragender Datensatztyp (Default: A)"
379 273
380#: plugins/check_dig.c:346
381#, fuzzy 274#, fuzzy
382msgid "" 275msgid ""
383"An address expected to be in the answer section. If not set, uses whatever" 276"An address expected to be in the answer section. If not set, uses whatever"
@@ -385,96 +278,69 @@ msgstr ""
385"Adresse die in der ANSWER SECTION erwartet wird.wenn nicht gesetzt, " 278"Adresse die in der ANSWER SECTION erwartet wird.wenn nicht gesetzt, "
386"ubernommen aus -l" 279"ubernommen aus -l"
387 280
388#: plugins/check_dig.c:347
389msgid "was in -l" 281msgid "was in -l"
390msgstr "" 282msgstr ""
391 283
392#: plugins/check_dig.c:349
393msgid "Pass STRING as argument(s) to dig" 284msgid "Pass STRING as argument(s) to dig"
394msgstr "" 285msgstr ""
395 286
396#: plugins/check_disk.c:216
397#, fuzzy, c-format 287#, fuzzy, c-format
398msgid "DISK %s: %s not found\n" 288msgid "DISK %s: %s not found\n"
399msgstr "%s [%s nicht gefunden]" 289msgstr "%s [%s nicht gefunden]"
400 290
401#: plugins/check_disk.c:216 plugins/check_disk.c:956 plugins/check_dns.c:241
402#: plugins/check_dummy.c:74 plugins/check_mysql.c:299
403#: plugins/check_nagios.c:104 plugins/check_nagios.c:168
404#: plugins/check_nagios.c:172 plugins/check_pgsql.c:601
405#: plugins/check_pgsql.c:618 plugins/check_pgsql.c:627
406#: plugins/check_pgsql.c:642 plugins/check_procs.c:351
407#, c-format 291#, c-format
408msgid "CRITICAL" 292msgid "CRITICAL"
409msgstr "CRITICAL" 293msgstr "CRITICAL"
410 294
411#: plugins/check_disk.c:550
412#, c-format 295#, c-format
413msgid "unit type %s not known\n" 296msgid "unit type %s not known\n"
414msgstr "unbekannter unit type: %s\n" 297msgstr "unbekannter unit type: %s\n"
415 298
416#: plugins/check_disk.c:553
417#, c-format 299#, c-format
418msgid "failed allocating storage for '%s'\n" 300msgid "failed allocating storage for '%s'\n"
419msgstr "konnte keinen Speicher für '%s' reservieren\n" 301msgstr "konnte keinen Speicher für '%s' reservieren\n"
420 302
421#: plugins/check_disk.c:577 plugins/check_disk.c:618 plugins/check_disk.c:626
422#: plugins/check_disk.c:633 plugins/check_disk.c:637 plugins/check_disk.c:677
423#: plugins/check_disk.c:683 plugins/check_disk.c:702 plugins/check_dummy.c:77
424#: plugins/check_dummy.c:80 plugins/check_pgsql.c:643
425#: plugins/check_procs.c:506
426#, c-format 303#, c-format
427msgid "UNKNOWN" 304msgid "UNKNOWN"
428msgstr "UNKNOWN" 305msgstr "UNKNOWN"
429 306
430#: plugins/check_disk.c:577
431msgid "Must set a threshold value before using -p\n" 307msgid "Must set a threshold value before using -p\n"
432msgstr "" 308msgstr ""
433 309
434#: plugins/check_disk.c:618
435msgid "Must set -E before selecting paths\n" 310msgid "Must set -E before selecting paths\n"
436msgstr "" 311msgstr ""
437 312
438#: plugins/check_disk.c:626
439msgid "Must set group value before selecting paths\n" 313msgid "Must set group value before selecting paths\n"
440msgstr "" 314msgstr ""
441 315
442#: plugins/check_disk.c:633
443msgid "" 316msgid ""
444"Paths need to be selected before using -i/-I. Use -A to select all paths " 317"Paths need to be selected before using -i/-I. Use -A to select all paths "
445"explicitly" 318"explicitly"
446msgstr "" 319msgstr ""
447 320
448#: plugins/check_disk.c:637 plugins/check_disk.c:683 plugins/check_procs.c:506
449msgid "Could not compile regular expression" 321msgid "Could not compile regular expression"
450msgstr "" 322msgstr ""
451 323
452#: plugins/check_disk.c:677
453msgid "Must set a threshold value before using -r/-R\n" 324msgid "Must set a threshold value before using -r/-R\n"
454msgstr "" 325msgstr ""
455 326
456#: plugins/check_disk.c:703
457msgid "Regular expression did not match any path or disk" 327msgid "Regular expression did not match any path or disk"
458msgstr "" 328msgstr ""
459 329
460#: plugins/check_disk.c:749
461#, fuzzy 330#, fuzzy
462msgid "Unknown argument" 331msgid "Unknown argument"
463msgstr "Unbekanntes Argument" 332msgstr "Unbekanntes Argument"
464 333
465#: plugins/check_disk.c:783
466#, c-format 334#, c-format
467msgid " for %s\n" 335msgid " for %s\n"
468msgstr "" 336msgstr ""
469 337
470#: plugins/check_disk.c:857
471#, fuzzy 338#, fuzzy
472msgid "" 339msgid ""
473"This plugin checks the amount of used disk space on a mounted file system" 340"This plugin checks the amount of used disk space on a mounted file system"
474msgstr "" 341msgstr ""
475"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem" 342"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem"
476 343
477#: plugins/check_disk.c:858
478#, fuzzy 344#, fuzzy
479msgid "" 345msgid ""
480"and generates an alert if free space is less than one of the threshold values" 346"and generates an alert if free space is less than one of the threshold values"
@@ -482,3575 +348,2937 @@ msgstr ""
482"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 348"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
483"unterschritten wird." 349"unterschritten wird."
484 350
485#: plugins/check_disk.c:868
486msgid "Exit with WARNING status if less than INTEGER units of disk are free" 351msgid "Exit with WARNING status if less than INTEGER units of disk are free"
487msgstr "" 352msgstr ""
488 353
489#: plugins/check_disk.c:870
490msgid "Exit with WARNING status if less than PERCENT of disk space is free" 354msgid "Exit with WARNING status if less than PERCENT of disk space is free"
491msgstr "" 355msgstr ""
492 356
493#: plugins/check_disk.c:872
494msgid "Exit with CRITICAL status if less than INTEGER units of disk are free" 357msgid "Exit with CRITICAL status if less than INTEGER units of disk are free"
495msgstr "" 358msgstr ""
496 359
497#: plugins/check_disk.c:874
498msgid "Exit with CRITICAL status if less than PERCENT of disk space is free" 360msgid "Exit with CRITICAL status if less than PERCENT of disk space is free"
499msgstr "" 361msgstr ""
500 362
501#: plugins/check_disk.c:876
502msgid "Exit with WARNING status if less than PERCENT of inode space is free" 363msgid "Exit with WARNING status if less than PERCENT of inode space is free"
503msgstr "" 364msgstr ""
504 365
505#: plugins/check_disk.c:878
506msgid "Exit with CRITICAL status if less than PERCENT of inode space is free" 366msgid "Exit with CRITICAL status if less than PERCENT of inode space is free"
507msgstr "" 367msgstr ""
508 368
509#: plugins/check_disk.c:880 369msgid ""
510msgid "Path or partition (may be repeated)" 370"Mount point or block device as emitted by the mount(8) command (may be "
371"repeated)"
511msgstr "" 372msgstr ""
512 373
513#: plugins/check_disk.c:882
514msgid "Ignore device (only works if -p unspecified)" 374msgid "Ignore device (only works if -p unspecified)"
515msgstr "" 375msgstr ""
516 376
517#: plugins/check_disk.c:884
518msgid "Clear thresholds" 377msgid "Clear thresholds"
519msgstr "" 378msgstr ""
520 379
521#: plugins/check_disk.c:886
522msgid "For paths or partitions specified with -p, only check for exact paths" 380msgid "For paths or partitions specified with -p, only check for exact paths"
523msgstr "" 381msgstr ""
524 382
525#: plugins/check_disk.c:888
526msgid "Display only devices/mountpoints with errors" 383msgid "Display only devices/mountpoints with errors"
527msgstr "" 384msgstr ""
528 385
529#: plugins/check_disk.c:890
530msgid "Don't account root-reserved blocks into freespace in perfdata" 386msgid "Don't account root-reserved blocks into freespace in perfdata"
531msgstr "" 387msgstr ""
532 388
533#: plugins/check_disk.c:892 389msgid "Display inode usage in perfdata"
390msgstr ""
391
534msgid "" 392msgid ""
535"Group paths. Thresholds apply to (free-)space of all partitions together" 393"Group paths. Thresholds apply to (free-)space of all partitions together"
536msgstr "" 394msgstr ""
537 395
538#: plugins/check_disk.c:894
539msgid "Same as '--units kB'" 396msgid "Same as '--units kB'"
540msgstr "" 397msgstr ""
541 398
542#: plugins/check_disk.c:896
543msgid "Only check local filesystems" 399msgid "Only check local filesystems"
544msgstr "" 400msgstr ""
545 401
546#: plugins/check_disk.c:898
547msgid "" 402msgid ""
548"Only check local filesystems against thresholds. Yet call stat on remote " 403"Only check local filesystems against thresholds. Yet call stat on remote "
549"filesystems" 404"filesystems"
550msgstr "" 405msgstr ""
551 406
552#: plugins/check_disk.c:899
553msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)" 407msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)"
554msgstr "" 408msgstr ""
555 409
556#: plugins/check_disk.c:901 410msgid "Display the (block) device instead of the mount point"
557msgid "Display the mountpoint instead of the partition"
558msgstr "" 411msgstr ""
559 412
560#: plugins/check_disk.c:903
561msgid "Same as '--units MB'" 413msgid "Same as '--units MB'"
562msgstr "" 414msgstr ""
563 415
564#: plugins/check_disk.c:905
565msgid "Explicitly select all paths. This is equivalent to -R '.*'" 416msgid "Explicitly select all paths. This is equivalent to -R '.*'"
566msgstr "" 417msgstr ""
567 418
568#: plugins/check_disk.c:907
569msgid "" 419msgid ""
570"Case insensitive regular expression for path/partition (may be repeated)" 420"Case insensitive regular expression for path/partition (may be repeated)"
571msgstr "" 421msgstr ""
572 422
573#: plugins/check_disk.c:909
574msgid "Regular expression for path or partition (may be repeated)" 423msgid "Regular expression for path or partition (may be repeated)"
575msgstr "" 424msgstr ""
576 425
577#: plugins/check_disk.c:911
578msgid "" 426msgid ""
579"Regular expression to ignore selected path/partition (case insensitive) (may " 427"Regular expression to ignore selected path/partition (case insensitive) (may "
580"be repeated)" 428"be repeated)"
581msgstr "" 429msgstr ""
582 430
583#: plugins/check_disk.c:913
584msgid "" 431msgid ""
585"Regular expression to ignore selected path or partition (may be repeated)" 432"Regular expression to ignore selected path or partition (may be repeated)"
586msgstr "" 433msgstr ""
587 434
588#: plugins/check_disk.c:916 435msgid ""
436"Return OK if no filesystem matches, filesystem does not exist or is "
437"inaccessible."
438msgstr ""
439
440msgid "(Provide this option before -p / -r / --ereg-path if used)"
441msgstr ""
442
589msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 443msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
590msgstr "" 444msgstr ""
591 445
592#: plugins/check_disk.c:919
593msgid "Ignore all filesystems of indicated type (may be repeated)" 446msgid "Ignore all filesystems of indicated type (may be repeated)"
594msgstr "" 447msgstr ""
595 448
596#: plugins/check_disk.c:921
597msgid "Check only filesystems of indicated type (may be repeated)" 449msgid "Check only filesystems of indicated type (may be repeated)"
598msgstr "" 450msgstr ""
599 451
600#: plugins/check_disk.c:926
601msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB" 452msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
602msgstr "" 453msgstr ""
603 454
604#: plugins/check_disk.c:928
605msgid "" 455msgid ""
606"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -" 456"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -"
607"r regex" 457"r regex"
608msgstr "" 458msgstr ""
609 459
610#: plugins/check_disk.c:929
611msgid "" 460msgid ""
612"are grouped which means the freespace thresholds are applied to all disks " 461"are grouped which means the freespace thresholds are applied to all disks "
613"together" 462"together"
614msgstr "" 463msgstr ""
615 464
616#: plugins/check_disk.c:931
617msgid "" 465msgid ""
618"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use " 466"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use "
619"100M/50M" 467"100M/50M"
620msgstr "" 468msgstr ""
621 469
622#: plugins/check_disk.c:957
623#, c-format 470#, c-format
624msgid "%s %s: %s\n" 471msgid "%s %s: %s\n"
625msgstr "" 472msgstr ""
626 473
627#: plugins/check_disk.c:957
628msgid "is not accessible" 474msgid "is not accessible"
629msgstr "" 475msgstr ""
630 476
631#: plugins/check_dns.c:116
632#, fuzzy 477#, fuzzy
633msgid "nslookup returned an error status" 478msgid "nslookup returned an error status"
634msgstr "nslookup hat einen Fehler zurückgegeben" 479msgstr "nslookup hat einen Fehler zurückgegeben"
635 480
636#: plugins/check_dns.c:134
637msgid "Warning plugin error" 481msgid "Warning plugin error"
638msgstr "Warnung Plugin Fehler" 482msgstr "Warnung Plugin Fehler"
639 483
640#: plugins/check_dns.c:154 484#, fuzzy, c-format
485msgid "DNS CRITICAL - '%s' returned empty server string\n"
486msgstr "DNS CRITICAL - '%s' hat einen leeren Hostnamen zurückgegeben\n"
487
488#, fuzzy, c-format
489msgid "DNS CRITICAL - No response from DNS %s\n"
490msgstr "Keine Antwort von DNS %s\n"
491
641#, c-format 492#, c-format
642msgid "DNS CRITICAL - '%s' returned empty host name string\n" 493msgid "DNS CRITICAL - '%s' returned empty host name string\n"
643msgstr "DNS CRITICAL - '%s' hat einen leeren Hostnamen zurückgegeben\n" 494msgstr "DNS CRITICAL - '%s' hat einen leeren Hostnamen zurückgegeben\n"
644 495
645#: plugins/check_dns.c:160
646msgid "Non-authoritative answer:" 496msgid "Non-authoritative answer:"
647msgstr "" 497msgstr ""
648 498
649#: plugins/check_dns.c:201 499#, fuzzy, c-format
500msgid "Domain '%s' was not found by the server\n"
501msgstr "Domäne %s wurde vom Server nicht gefunden\n"
502
650#, fuzzy, c-format 503#, fuzzy, c-format
651msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n" 504msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n"
652msgstr "DNS CRITICAL - '%s' Ausgabeverarbeitung hat keine Adresse ergeben\n" 505msgstr "DNS CRITICAL - '%s' Ausgabeverarbeitung hat keine Adresse ergeben\n"
653 506
654#: plugins/check_dns.c:216
655#, fuzzy, c-format 507#, fuzzy, c-format
656msgid "expected '%s' but got '%s'" 508msgid "expected '%s' but got '%s'"
657msgstr "Erwartet: %s aber: %s erhalten" 509msgstr "Erwartet: %s aber: %s erhalten"
658 510
659#: plugins/check_dns.c:223 511#, fuzzy, c-format
512msgid "Domain '%s' was found by the server: '%s'\n"
513msgstr "Domäne %s wurde vom Server nicht gefunden\n"
514
660#, c-format 515#, c-format
661msgid "server %s is not authoritative for %s" 516msgid "server %s is not authoritative for %s"
662msgstr "Server %s ist nicht autoritativ für %s" 517msgstr "Server %s ist nicht autoritativ für %s"
663 518
664#: plugins/check_dns.c:237 plugins/check_dummy.c:68 plugins/check_nagios.c:182
665#: plugins/check_pgsql.c:638 plugins/check_procs.c:344
666#, c-format 519#, c-format
667msgid "OK" 520msgid "OK"
668msgstr "OK" 521msgstr "OK"
669 522
670#: plugins/check_dns.c:239 plugins/check_dummy.c:71 plugins/check_mysql.c:296
671#: plugins/check_nagios.c:182 plugins/check_pgsql.c:607
672#: plugins/check_pgsql.c:612 plugins/check_pgsql.c:640
673#: plugins/check_procs.c:346
674#, c-format 523#, c-format
675msgid "WARNING" 524msgid "WARNING"
676msgstr "WARNING" 525msgstr "WARNING"
677 526
678#: plugins/check_dns.c:243
679#, fuzzy, c-format 527#, fuzzy, c-format
680msgid "%.3f second response time" 528msgid "%.3f second response time"
681msgid_plural "%.3f seconds response time" 529msgid_plural "%.3f seconds response time"
682msgstr[0] "%.3f Sekunden Antwortzeit " 530msgstr[0] "%.3f Sekunden Antwortzeit "
683msgstr[1] "%.3f Sekunden Antwortzeit " 531msgstr[1] "%.3f Sekunden Antwortzeit "
684 532
685#: plugins/check_dns.c:244
686#, fuzzy, c-format 533#, fuzzy, c-format
687msgid ". %s returns %s" 534msgid ". %s returns %s"
688msgstr "%s hat %s zurückgegeben" 535msgstr "%s hat %s zurückgegeben"
689 536
690#: plugins/check_dns.c:248
691#, c-format 537#, c-format
692msgid "DNS WARNING - %s\n" 538msgid "DNS WARNING - %s\n"
693msgstr "DNS WARNING - %s\n" 539msgstr "DNS WARNING - %s\n"
694 540
695#: plugins/check_dns.c:249 plugins/check_dns.c:252 plugins/check_dns.c:255
696msgid " Probably a non-existent host/domain" 541msgid " Probably a non-existent host/domain"
697msgstr "nicht existierender Host/Domain" 542msgstr "nicht existierender Host/Domain"
698 543
699#: plugins/check_dns.c:251
700#, c-format 544#, c-format
701msgid "DNS CRITICAL - %s\n" 545msgid "DNS CRITICAL - %s\n"
702msgstr "DNS CRITICAL - %s\n" 546msgstr "DNS CRITICAL - %s\n"
703 547
704#: plugins/check_dns.c:254
705#, fuzzy, c-format 548#, fuzzy, c-format
706msgid "DNS UNKNOWN - %s\n" 549msgid "DNS UNKNOWN - %s\n"
707msgstr "DNS UNKNOWN - %s\n" 550msgstr "DNS UNKNOWN - %s\n"
708 551
709#: plugins/check_dns.c:267
710msgid "Note: nslookup is deprecated and may be removed from future releases." 552msgid "Note: nslookup is deprecated and may be removed from future releases."
711msgstr "" 553msgstr ""
712 554
713#: plugins/check_dns.c:268
714msgid "Consider using the `dig' or `host' programs instead. Run nslookup with" 555msgid "Consider using the `dig' or `host' programs instead. Run nslookup with"
715msgstr "" 556msgstr ""
716 557
717#: plugins/check_dns.c:269
718msgid "the `-sil[ent]' option to prevent this message from appearing." 558msgid "the `-sil[ent]' option to prevent this message from appearing."
719msgstr "" 559msgstr ""
720 560
721#: plugins/check_dns.c:274
722#, c-format 561#, c-format
723msgid "No response from DNS %s\n" 562msgid "No response from DNS %s\n"
724msgstr "Keine Antwort von DNS %s\n" 563msgstr "Keine Antwort von DNS %s\n"
725 564
726#: plugins/check_dns.c:278
727#, c-format 565#, c-format
728msgid "DNS %s has no records\n" 566msgid "DNS %s has no records\n"
729msgstr "Nameserver %s hat keine Datensätze\n" 567msgstr "Nameserver %s hat keine Datensätze\n"
730 568
731#: plugins/check_dns.c:286
732#, c-format 569#, c-format
733msgid "Connection to DNS %s was refused\n" 570msgid "Connection to DNS %s was refused\n"
734msgstr "Verbindung zum Nameserver %s wurde verweigert\n" 571msgstr "Verbindung zum Nameserver %s wurde verweigert\n"
735 572
736#: plugins/check_dns.c:290
737#, c-format 573#, c-format
738msgid "Query was refused by DNS server at %s\n" 574msgid "Query was refused by DNS server at %s\n"
739msgstr "" 575msgstr ""
740 576
741#: plugins/check_dns.c:294
742#, c-format 577#, c-format
743msgid "No information returned by DNS server at %s\n" 578msgid "No information returned by DNS server at %s\n"
744msgstr "" 579msgstr ""
745 580
746#: plugins/check_dns.c:300
747#, c-format
748msgid "Domain %s was not found by the server\n"
749msgstr "Domäne %s wurde vom Server nicht gefunden\n"
750
751#: plugins/check_dns.c:304
752msgid "Network is unreachable\n" 581msgid "Network is unreachable\n"
753msgstr "Netzwerk nicht erreichbar\n" 582msgstr "Netzwerk nicht erreichbar\n"
754 583
755#: plugins/check_dns.c:308
756#, c-format 584#, c-format
757msgid "DNS failure for %s\n" 585msgid "DNS failure for %s\n"
758msgstr "DNS Fehler für %s\n" 586msgstr "DNS Fehler für %s\n"
759 587
760#: plugins/check_dns.c:372 plugins/check_dns.c:380 plugins/check_dns.c:387
761#: plugins/check_dns.c:392 plugins/check_dns.c:414 plugins/check_dns.c:422
762#: plugins/check_game.c:211 plugins/check_game.c:219
763msgid "Input buffer overflow\n" 588msgid "Input buffer overflow\n"
764msgstr "Eingabe-Pufferüberlauf\n" 589msgstr "Eingabe-Pufferüberlauf\n"
765 590
766#: plugins/check_dns.c:450
767msgid "" 591msgid ""
768"This plugin uses the nslookup program to obtain the IP address for the given " 592"This plugin uses the nslookup program to obtain the IP address for the given "
769"host/domain query." 593"host/domain query."
770msgstr "" 594msgstr ""
771 595
772#: plugins/check_dns.c:451
773msgid "An optional DNS server to use may be specified." 596msgid "An optional DNS server to use may be specified."
774msgstr "" 597msgstr ""
775 598
776#: plugins/check_dns.c:452
777msgid "" 599msgid ""
778"If no DNS server is specified, the default server(s) specified in /etc/" 600"If no DNS server is specified, the default server(s) specified in /etc/"
779"resolv.conf will be used." 601"resolv.conf will be used."
780msgstr "" 602msgstr ""
781 603
782#: plugins/check_dns.c:462
783msgid "The name or address you want to query" 604msgid "The name or address you want to query"
784msgstr "" 605msgstr ""
785 606
786#: plugins/check_dns.c:464
787msgid "Optional DNS server you want to use for the lookup" 607msgid "Optional DNS server you want to use for the lookup"
788msgstr "" 608msgstr ""
789 609
790#: plugins/check_dns.c:466
791msgid "" 610msgid ""
792"Optional IP-ADDRESS you expect the DNS server to return. HOST must end with" 611"Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"
793msgstr "" 612msgstr ""
794 613
795#: plugins/check_dns.c:467
796msgid "" 614msgid ""
797"a dot (.). This option can be repeated multiple times (Returns OK if any" 615"with a dot (.). This option can be repeated multiple times (Returns OK if any"
798msgstr "" 616msgstr ""
799 617
800#: plugins/check_dns.c:468 618msgid "value matches)."
801msgid ""
802"value match). If multiple addresses are returned at once, you have to match"
803msgstr "" 619msgstr ""
804 620
805#: plugins/check_dns.c:469
806msgid "" 621msgid ""
807"the whole string of addresses separated with commas (sorted alphabetically)." 622"Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"
623msgstr ""
624
625msgid "Cannot be used together with -a"
808msgstr "" 626msgstr ""
809 627
810#: plugins/check_dns.c:471
811msgid "Optionally expect the DNS server to be authoritative for the lookup" 628msgid "Optionally expect the DNS server to be authoritative for the lookup"
812msgstr "" 629msgstr ""
813 630
814#: plugins/check_dns.c:473
815msgid "Return warning if elapsed time exceeds value. Default off" 631msgid "Return warning if elapsed time exceeds value. Default off"
816msgstr "" 632msgstr ""
817 633
818#: plugins/check_dns.c:475
819msgid "Return critical if elapsed time exceeds value. Default off" 634msgid "Return critical if elapsed time exceeds value. Default off"
820msgstr "" 635msgstr ""
821 636
822#: plugins/check_dummy.c:62 637msgid ""
638"Return critical if the list of expected addresses does not match all "
639"addresses"
640msgstr ""
641
642msgid "returned. Default off"
643msgstr ""
644
823msgid "Arguments to check_dummy must be an integer" 645msgid "Arguments to check_dummy must be an integer"
824msgstr "Argument für check_dummy muss ein Integer sein" 646msgstr "Argument für check_dummy muss ein Integer sein"
825 647
826#: plugins/check_dummy.c:82
827#, c-format 648#, c-format
828msgid "Status %d is not a supported error state\n" 649msgid "Status %d is not a supported error state\n"
829msgstr "Status %d ist kein bekannter Fehlerstatus\n" 650msgstr "Status %d ist kein bekannter Fehlerstatus\n"
830 651
831#: plugins/check_dummy.c:104
832msgid "" 652msgid ""
833"This plugin will simply return the state corresponding to the numeric value" 653"This plugin will simply return the state corresponding to the numeric value"
834msgstr "" 654msgstr ""
835 655
836#: plugins/check_dummy.c:106
837msgid "of the <state> argument with optional text" 656msgid "of the <state> argument with optional text"
838msgstr "" 657msgstr ""
839 658
840#: plugins/check_fping.c:125 plugins/check_hpjd.c:128 plugins/check_ping.c:438
841#: plugins/check_swap.c:175 plugins/check_users.c:94 plugins/urlize.c:110
842#, c-format 659#, c-format
843msgid "Could not open pipe: %s\n" 660msgid "Could not open pipe: %s\n"
844msgstr "Pipe: %s konnte nicht geöffnet werden\n" 661msgstr "Pipe: %s konnte nicht geöffnet werden\n"
845 662
846#: plugins/check_fping.c:131 plugins/check_hpjd.c:134 plugins/check_load.c:153
847#: plugins/check_swap.c:181 plugins/check_users.c:100 plugins/urlize.c:116
848#, c-format 663#, c-format
849msgid "Could not open stderr for %s\n" 664msgid "Could not open stderr for %s\n"
850msgstr "Konnte stderr nicht öffnen für: %s\n" 665msgstr "Konnte stderr nicht öffnen für: %s\n"
851 666
852#: plugins/check_fping.c:157
853#, fuzzy 667#, fuzzy
854msgid "FPING UNKNOWN - IP address not found\n" 668msgid "FPING UNKNOWN - IP address not found\n"
855msgstr "FPING UNKNOWN - %s nicht gefunden\n" 669msgstr "FPING UNKNOWN - %s nicht gefunden\n"
856 670
857#: plugins/check_fping.c:160
858msgid "FPING UNKNOWN - invalid commandline argument\n" 671msgid "FPING UNKNOWN - invalid commandline argument\n"
859msgstr "" 672msgstr ""
860 673
861#: plugins/check_fping.c:163
862#, fuzzy 674#, fuzzy
863msgid "FPING UNKNOWN - failed system call\n" 675msgid "FPING UNKNOWN - failed system call\n"
864msgstr "FPING UNKNOWN - %s nicht gefunden\n" 676msgstr "FPING UNKNOWN - %s nicht gefunden\n"
865 677
866#: plugins/check_fping.c:187 678#, fuzzy, c-format
679msgid "FPING %s - %s (rta=%f ms)|%s\n"
680msgstr "FPING %s - %s (verloren=%.0f%% )|%s\n"
681
867#, c-format 682#, c-format
868msgid "FPING UNKNOWN - %s not found\n" 683msgid "FPING UNKNOWN - %s not found\n"
869msgstr "FPING UNKNOWN - %s nicht gefunden\n" 684msgstr "FPING UNKNOWN - %s nicht gefunden\n"
870 685
871#: plugins/check_fping.c:191
872#, c-format 686#, c-format
873msgid "FPING CRITICAL - %s is unreachable\n" 687msgid "FPING CRITICAL - %s is unreachable\n"
874msgstr "FPING CRITICAL - %s ist nicht erreichbar\n" 688msgstr "FPING CRITICAL - %s ist nicht erreichbar\n"
875 689
876#: plugins/check_fping.c:196
877#, fuzzy, c-format 690#, fuzzy, c-format
878msgid "FPING UNKNOWN - %s parameter error\n" 691msgid "FPING UNKNOWN - %s parameter error\n"
879msgstr "FPING UNKNOWN - %s nicht gefunden\n" 692msgstr "FPING UNKNOWN - %s nicht gefunden\n"
880 693
881#: plugins/check_fping.c:200 plugins/check_fping.c:240
882#, c-format 694#, c-format
883msgid "FPING CRITICAL - %s is down\n" 695msgid "FPING CRITICAL - %s is down\n"
884msgstr "FPING CRITICAL - %s ist down\n" 696msgstr "FPING CRITICAL - %s ist down\n"
885 697
886#: plugins/check_fping.c:227
887#, c-format 698#, c-format
888msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n" 699msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"
889msgstr "FPING %s - %s (verloren=%.0f%%, rta=%f ms)|%s %s\n" 700msgstr "FPING %s - %s (verloren=%.0f%%, rta=%f ms)|%s %s\n"
890 701
891#: plugins/check_fping.c:253
892#, c-format 702#, c-format
893msgid "FPING %s - %s (loss=%.0f%% )|%s\n" 703msgid "FPING %s - %s (loss=%.0f%% )|%s\n"
894msgstr "FPING %s - %s (verloren=%.0f%% )|%s\n" 704msgstr "FPING %s - %s (verloren=%.0f%% )|%s\n"
895 705
896#: plugins/check_fping.c:326 plugins/check_fping.c:332
897#: plugins/check_hpjd.c:338 plugins/check_hpjd.c:361 plugins/check_mysql.c:371
898#: plugins/check_mysql.c:455 plugins/check_ntp.c:709
899#: plugins/check_ntp_peer.c:497 plugins/check_ntp_time.c:496
900#: plugins/check_pgsql.c:335 plugins/check_ping.c:295 plugins/check_ping.c:418
901#: plugins/check_radius.c:264 plugins/check_real.c:314
902#: plugins/check_real.c:376 plugins/check_smtp.c:499 plugins/check_smtp.c:641
903#: plugins/check_ssh.c:157 plugins/check_time.c:240 plugins/check_time.c:315
904#: plugins/check_ups.c:504 plugins/check_ups.c:573
905msgid "Invalid hostname/address" 706msgid "Invalid hostname/address"
906msgstr "Ungültige(r) Hostname/Adresse" 707msgstr "Ungültige(r) Hostname/Adresse"
907 708
908#: plugins/check_fping.c:345 plugins/check_ldap.c:353 plugins/check_ping.c:246
909msgid "IPv6 support not available\n" 709msgid "IPv6 support not available\n"
910msgstr "" 710msgstr ""
911 711
912#: plugins/check_fping.c:378
913msgid "Packet size must be a positive integer" 712msgid "Packet size must be a positive integer"
914msgstr "Paketgröße muss ein positiver Integer sein" 713msgstr "Paketgröße muss ein positiver Integer sein"
915 714
916#: plugins/check_fping.c:384
917msgid "Packet count must be a positive integer" 715msgid "Packet count must be a positive integer"
918msgstr "Paketanzahl muss ein positiver Integer sein" 716msgstr "Paketanzahl muss ein positiver Integer sein"
919 717
920#: plugins/check_fping.c:390
921#, fuzzy 718#, fuzzy
922msgid "Target timeout must be a positive integer" 719msgid "Target timeout must be a positive integer"
923msgstr "Warnung time muss ein positiver Integer sein" 720msgstr "Warnung time muss ein positiver Integer sein"
924 721
925#: plugins/check_fping.c:396
926#, fuzzy 722#, fuzzy
927msgid "Interval must be a positive integer" 723msgid "Interval must be a positive integer"
928msgstr "Timeout interval muss ein positiver Integer sein" 724msgstr "Timeout interval muss ein positiver Integer sein"
929 725
930#: plugins/check_fping.c:402 plugins/check_ntp.c:733
931#: plugins/check_ntp_peer.c:524 plugins/check_ntp_time.c:523
932#: plugins/check_radius.c:314 plugins/check_time.c:319
933msgid "Hostname was not supplied" 726msgid "Hostname was not supplied"
934msgstr "" 727msgstr ""
935 728
936#: plugins/check_fping.c:422
937#, c-format 729#, c-format
938msgid "%s: Only one threshold may be packet loss (%s)\n" 730msgid "%s: Only one threshold may be packet loss (%s)\n"
939msgstr "%s: Nur ein Wert darf für paket loss angegeben werden (%s)\n" 731msgstr "%s: Nur ein Wert darf für packet loss angegeben werden (%s)\n"
940 732
941#: plugins/check_fping.c:426
942#, c-format 733#, c-format
943msgid "%s: Only one threshold must be packet loss (%s)\n" 734msgid "%s: Only one threshold must be packet loss (%s)\n"
944msgstr "%s: Nur ein Wert darf für paket loss angegeben werden (%s)\n" 735msgstr "%s: Nur ein Wert darf für packet loss angegeben werden (%s)\n"
945 736
946#: plugins/check_fping.c:458
947msgid "" 737msgid ""
948"This plugin will use the fping command to ping the specified host for a fast " 738"This plugin will use the fping command to ping the specified host for a fast "
949"check" 739"check"
950msgstr "" 740msgstr ""
951 741
952#: plugins/check_fping.c:460
953msgid "Note that it is necessary to set the suid flag on fping." 742msgid "Note that it is necessary to set the suid flag on fping."
954msgstr "" 743msgstr ""
955 744
956#: plugins/check_fping.c:472
957msgid "" 745msgid ""
958"name or IP Address of host to ping (IP Address bypasses name lookup, " 746"name or IP Address of host to ping (IP Address bypasses name lookup, "
959"reducing system load)" 747"reducing system load)"
960msgstr "" 748msgstr ""
961 749
962#: plugins/check_fping.c:474 plugins/check_ping.c:575
963#, fuzzy 750#, fuzzy
964msgid "warning threshold pair" 751msgid "warning threshold pair"
965msgstr "Warning threshold Integer sein" 752msgstr "Warning threshold Integer sein"
966 753
967#: plugins/check_fping.c:476 plugins/check_ping.c:577
968#, fuzzy 754#, fuzzy
969msgid "critical threshold pair" 755msgid "critical threshold pair"
970msgstr "Critical threshold muss ein Integer sein" 756msgstr "Critical threshold muss ein Integer sein"
971 757
972#: plugins/check_fping.c:478 758msgid "Return OK after first successful reply"
759msgstr ""
760
973msgid "size of ICMP packet" 761msgid "size of ICMP packet"
974msgstr "" 762msgstr ""
975 763
976#: plugins/check_fping.c:480
977msgid "number of ICMP packets to send" 764msgid "number of ICMP packets to send"
978msgstr "" 765msgstr ""
979 766
980#: plugins/check_fping.c:482
981msgid "Target timeout (ms)" 767msgid "Target timeout (ms)"
982msgstr "" 768msgstr ""
983 769
984#: plugins/check_fping.c:484
985msgid "Interval (ms) between sending packets" 770msgid "Interval (ms) between sending packets"
986msgstr "" 771msgstr ""
987 772
988#: plugins/check_fping.c:486
989msgid "name or IP Address of sourceip" 773msgid "name or IP Address of sourceip"
990msgstr "" 774msgstr ""
991 775
992#: plugins/check_fping.c:488
993msgid "source interface name" 776msgid "source interface name"
994msgstr "" 777msgstr ""
995 778
996#: plugins/check_fping.c:491
997#, c-format 779#, c-format
998msgid "" 780msgid ""
999"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time " 781"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time "
1000"(ms)" 782"(ms)"
1001msgstr "" 783msgstr ""
1002 784
1003#: plugins/check_fping.c:492
1004msgid "" 785msgid ""
1005"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of" 786"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of"
1006msgstr "" 787msgstr ""
1007 788
1008#: plugins/check_fping.c:493
1009msgid "packet loss to trigger an alarm state." 789msgid "packet loss to trigger an alarm state."
1010msgstr "" 790msgstr ""
1011 791
1012#: plugins/check_fping.c:496
1013msgid "IPv4 is used by default. Specify -6 to use IPv6." 792msgid "IPv4 is used by default. Specify -6 to use IPv6."
1014msgstr "" 793msgstr ""
1015 794
1016#: plugins/check_game.c:111
1017#, c-format 795#, c-format
1018msgid "CRITICAL - Host type parameter incorrect!\n" 796msgid "CRITICAL - Host type parameter incorrect!\n"
1019msgstr "CRITICAL - Host type parameter unkorrekt!\n" 797msgstr "CRITICAL - Host type parameter unkorrekt!\n"
1020 798
1021#: plugins/check_game.c:126
1022#, fuzzy, c-format 799#, fuzzy, c-format
1023msgid "CRITICAL - Host not found\n" 800msgid "CRITICAL - Host not found\n"
1024msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n" 801msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n"
1025 802
1026#: plugins/check_game.c:130
1027#, fuzzy, c-format 803#, fuzzy, c-format
1028msgid "CRITICAL - Game server down or unavailable\n" 804msgid "CRITICAL - Game server down or unavailable\n"
1029msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 805msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
1030 806
1031#: plugins/check_game.c:134
1032#, fuzzy, c-format 807#, fuzzy, c-format
1033msgid "CRITICAL - Game server timeout\n" 808msgid "CRITICAL - Game server timeout\n"
1034msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n" 809msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n"
1035 810
1036#: plugins/check_game.c:297
1037#, c-format 811#, c-format
1038msgid "This plugin tests game server connections with the specified host." 812msgid "This plugin tests game server connections with the specified host."
1039msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 813msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
1040 814
1041#: plugins/check_game.c:307
1042msgid "Optional port of which to connect" 815msgid "Optional port of which to connect"
1043msgstr "" 816msgstr ""
1044 817
1045#: plugins/check_game.c:309
1046msgid "Field number in raw qstat output that contains game name" 818msgid "Field number in raw qstat output that contains game name"
1047msgstr "" 819msgstr ""
1048 820
1049#: plugins/check_game.c:311
1050msgid "Field number in raw qstat output that contains map name" 821msgid "Field number in raw qstat output that contains map name"
1051msgstr "" 822msgstr ""
1052 823
1053#: plugins/check_game.c:313
1054msgid "Field number in raw qstat output that contains ping time" 824msgid "Field number in raw qstat output that contains ping time"
1055msgstr "" 825msgstr ""
1056 826
1057#: plugins/check_game.c:319
1058#, fuzzy 827#, fuzzy
1059msgid "" 828msgid ""
1060"This plugin uses the 'qstat' command, the popular game server status query " 829"This plugin uses the 'qstat' command, the popular game server status query "
1061"tool." 830"tool."
1062msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 831msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
1063 832
1064#: plugins/check_game.c:320
1065msgid "" 833msgid ""
1066"If you don't have the package installed, you will need to download it from" 834"If you don't have the package installed, you will need to download it from"
1067msgstr "" 835msgstr ""
1068 836
1069#: plugins/check_game.c:321 837msgid "https://github.com/multiplay/qstat before you can use this plugin."
1070msgid ""
1071"http://www.activesw.com/people/steve/qstat.html before you can use this "
1072"plugin."
1073msgstr "" 838msgstr ""
1074 839
1075#: plugins/check_hpjd.c:239
1076msgid "Paper Jam" 840msgid "Paper Jam"
1077msgstr "Papierstau" 841msgstr "Papierstau"
1078 842
1079#: plugins/check_hpjd.c:243
1080msgid "Out of Paper" 843msgid "Out of Paper"
1081msgstr "Kein Papier" 844msgstr "Kein Papier"
1082 845
1083#: plugins/check_hpjd.c:248
1084msgid "Printer Offline" 846msgid "Printer Offline"
1085msgstr "Drucker ausgeschaltet" 847msgstr "Drucker ausgeschaltet"
1086 848
1087#: plugins/check_hpjd.c:253
1088msgid "Peripheral Error" 849msgid "Peripheral Error"
1089msgstr "Peripheriefehler" 850msgstr "Peripheriefehler"
1090 851
1091#: plugins/check_hpjd.c:257
1092msgid "Intervention Required" 852msgid "Intervention Required"
1093msgstr "Eingriff benötigt" 853msgstr "Eingriff benötigt"
1094 854
1095#: plugins/check_hpjd.c:261
1096msgid "Toner Low" 855msgid "Toner Low"
1097msgstr "Wenig Toner" 856msgstr "Wenig Toner"
1098 857
1099#: plugins/check_hpjd.c:265
1100msgid "Insufficient Memory" 858msgid "Insufficient Memory"
1101msgstr "Nicht genügend Speicher" 859msgstr "Nicht genügend Speicher"
1102 860
1103#: plugins/check_hpjd.c:269
1104msgid "A Door is Open" 861msgid "A Door is Open"
1105msgstr "Eine Abdeckung ist offen" 862msgstr "Eine Abdeckung ist offen"
1106 863
1107#: plugins/check_hpjd.c:273
1108msgid "Output Tray is Full" 864msgid "Output Tray is Full"
1109msgstr "Ausgabeschacht ist voll" 865msgstr "Ausgabeschacht ist voll"
1110 866
1111#: plugins/check_hpjd.c:277
1112msgid "Data too Slow for Engine" 867msgid "Data too Slow for Engine"
1113msgstr "" 868msgstr ""
1114 869
1115#: plugins/check_hpjd.c:281
1116msgid "Unknown Paper Error" 870msgid "Unknown Paper Error"
1117msgstr "Papierfehler" 871msgstr "Papierfehler"
1118 872
1119#: plugins/check_hpjd.c:286
1120#, c-format 873#, c-format
1121msgid "Printer ok - (%s)\n" 874msgid "Printer ok - (%s)\n"
1122msgstr "Printer ok - (%s)\n" 875msgstr "Printer ok - (%s)\n"
1123 876
1124#: plugins/check_hpjd.c:391 877#, fuzzy
878msgid "Port must be a positive short integer"
879msgstr "Port muss ein positiver Integer sein"
880
1125#, fuzzy 881#, fuzzy
1126msgid "This plugin tests the STATUS of an HP printer with a JetDirect card." 882msgid "This plugin tests the STATUS of an HP printer with a JetDirect card."
1127msgstr "" 883msgstr ""
1128"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect " 884"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect "
1129"Karte.\n" 885"Karte.\n"
1130"Net-snmp muss auf dem ausführenden Computer installiert sein.\n" 886"Net-snmp muss auf dem ausführenden Computer installiert sein.\n"
1131"\n" 887"\n"
1132 888
1133#: plugins/check_hpjd.c:392
1134#, fuzzy 889#, fuzzy
1135msgid "Net-snmp must be installed on the computer running the plugin." 890msgid "Net-snmp must be installed on the computer running the plugin."
1136msgstr "" 891msgstr ""
1137"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect " 892"Dieses Plugin testet den STATUS eines HP Druckers mit einer JetDirect "
1138"Karte.\n" 893"Karte.\n"
1139"Net-snmp muss auf dem ausführenden Computer installiert sein.\n" 894"Net-snmp muss auf dem ausführenden Computer installiert sein.\n"
1140"\n" 895"\n"
1141 896
1142#: plugins/check_hpjd.c:402
1143msgid "The SNMP community name " 897msgid "The SNMP community name "
1144msgstr "" 898msgstr ""
1145 899
1146#: plugins/check_hpjd.c:403
1147#, c-format 900#, c-format
1148msgid "(default=%s)" 901msgid "(default=%s)"
1149msgstr "" 902msgstr ""
1150 903
1151#: plugins/check_http.c:189 904msgid "Specify the port to check "
905msgstr ""
906
907msgid "Disable paper check "
908msgstr ""
909
1152msgid "file does not exist or is not readable" 910msgid "file does not exist or is not readable"
1153msgstr "" 911msgstr ""
1154 912
1155#: plugins/check_http.c:310 plugins/check_http.c:315 plugins/check_http.c:321
1156#: plugins/check_smtp.c:600 plugins/check_tcp.c:576 plugins/check_tcp.c:580
1157#: plugins/check_tcp.c:586
1158msgid "Invalid certificate expiration period" 913msgid "Invalid certificate expiration period"
1159msgstr "Ungültiger Zertifikatsablauftermin" 914msgstr "Ungültiger Zertifikatsablauftermin"
1160 915
1161#: plugins/check_http.c:348
1162msgid "" 916msgid ""
1163"Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 " 917"Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional "
1164"(SSLv3)" 918"'+' suffix)"
1165msgstr "" 919msgstr ""
1166 920
1167#: plugins/check_http.c:354 plugins/check_tcp.c:599
1168#, fuzzy 921#, fuzzy
1169msgid "Invalid option - SSL is not available" 922msgid "Invalid option - SSL is not available"
1170msgstr "Ungültige Option - SSL ist nicht verfügbar\n" 923msgstr "Ungültige Option - SSL ist nicht verfügbar\n"
924
925msgid "Invalid max_redirs count"
926msgstr ""
1171 927
1172#: plugins/check_http.c:375
1173msgid "Invalid onredirect option" 928msgid "Invalid onredirect option"
1174msgstr "" 929msgstr ""
1175 930
1176#: plugins/check_http.c:377
1177#, c-format 931#, c-format
1178msgid "option f:%d \n" 932msgid "option f:%d \n"
1179msgstr "Option f:%d \n" 933msgstr "Option f:%d \n"
1180 934
1181#: plugins/check_http.c:398
1182msgid "Invalid port number" 935msgid "Invalid port number"
1183msgstr "Ungültige Portnummer" 936msgstr "Ungültige Portnummer"
1184 937
1185#: plugins/check_http.c:450
1186#, c-format 938#, c-format
1187msgid "Could Not Compile Regular Expression: %s" 939msgid "Could Not Compile Regular Expression: %s"
1188msgstr "" 940msgstr ""
1189 941
1190#: plugins/check_http.c:464 plugins/check_ntp.c:722
1191#: plugins/check_ntp_peer.c:513 plugins/check_ntp_time.c:512
1192#: plugins/check_smtp.c:621 plugins/check_ssh.c:149 plugins/check_tcp.c:477
1193msgid "IPv6 support not available" 942msgid "IPv6 support not available"
1194msgstr "IPv6 Unterstützung nicht vorhanden" 943msgstr "IPv6 Unterstützung nicht vorhanden"
1195 944
1196#: plugins/check_http.c:529 plugins/check_ping.c:422
1197msgid "You must specify a server address or host name" 945msgid "You must specify a server address or host name"
1198msgstr "Hostname oder Serveradresse muss angegeben werden" 946msgstr "Hostname oder Serveradresse muss angegeben werden"
1199 947
1200#: plugins/check_http.c:543
1201msgid "" 948msgid ""
1202"If you use a client certificate you must also specify a private key file" 949"If you use a client certificate you must also specify a private key file"
1203msgstr "" 950msgstr ""
1204 951
1205#: plugins/check_http.c:667 plugins/check_http.c:835
1206#, fuzzy 952#, fuzzy
1207msgid "HTTP UNKNOWN - Memory allocation error\n" 953msgid "HTTP UNKNOWN - Memory allocation error\n"
1208msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n" 954msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
1209 955
1210#: plugins/check_http.c:739
1211#, fuzzy, c-format 956#, fuzzy, c-format
1212msgid "%sServer date unknown, " 957msgid "%sServer date unknown, "
1213msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n" 958msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n"
1214 959
1215#: plugins/check_http.c:742
1216#, fuzzy, c-format 960#, fuzzy, c-format
1217msgid "%sDocument modification date unknown, " 961msgid "%sDocument modification date unknown, "
1218msgstr "HTTP CRITICAL - Datum der letzten Änderung unbekannt\n" 962msgstr "HTTP CRITICAL - Datum der letzten Änderung unbekannt\n"
1219 963
1220#: plugins/check_http.c:749
1221#, fuzzy, c-format 964#, fuzzy, c-format
1222msgid "%sServer date \"%100s\" unparsable, " 965msgid "%sServer date \"%100s\" unparsable, "
1223msgstr "HTTP CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 966msgstr "HTTP CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
1224 967
1225#: plugins/check_http.c:752
1226#, fuzzy, c-format 968#, fuzzy, c-format
1227msgid "%sDocument date \"%100s\" unparsable, " 969msgid "%sDocument date \"%100s\" unparsable, "
1228msgstr "" 970msgstr ""
1229"HTTP CRITICAL - Dokumentendatum \"%100s\" konnte nicht verarbeitet werden" 971"HTTP CRITICAL - Dokumentendatum \"%100s\" konnte nicht verarbeitet werden"
1230 972
1231#: plugins/check_http.c:755
1232#, fuzzy, c-format 973#, fuzzy, c-format
1233msgid "%sDocument is %d seconds in the future, " 974msgid "%sDocument is %d seconds in the future, "
1234msgstr "HTTP CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 975msgstr "HTTP CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
1235 976
1236#: plugins/check_http.c:760
1237#, fuzzy, c-format 977#, fuzzy, c-format
1238msgid "%sLast modified %.1f days ago, " 978msgid "%sLast modified %.1f days ago, "
1239msgstr "HTTP CRITICAL - Letzte Änderung vor %.1f Tagen\n" 979msgstr "HTTP CRITICAL - Letzte Änderung vor %.1f Tagen\n"
1240 980
1241#: plugins/check_http.c:763
1242#, fuzzy, c-format 981#, fuzzy, c-format
1243msgid "%sLast modified %d:%02d:%02d ago, " 982msgid "%sLast modified %d:%02d:%02d ago, "
1244msgstr "HTTP CRITICAL - Letzte Änderung vor %d:%02d:%02d \n" 983msgstr "HTTP CRITICAL - Letzte Änderung vor %d:%02d:%02d \n"
1245 984
1246#: plugins/check_http.c:876
1247msgid "HTTP CRITICAL - Unable to open TCP socket\n" 985msgid "HTTP CRITICAL - Unable to open TCP socket\n"
1248msgstr "HTTP CRITICAL - Konnte TCP socket nicht öffnen\n" 986msgstr "HTTP CRITICAL - Konnte TCP socket nicht öffnen\n"
987
988#, fuzzy
989msgid "HTTP UNKNOWN - Could not allocate memory for full_page\n"
990msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
1249 991
1250#: plugins/check_http.c:995
1251msgid "HTTP CRITICAL - Error on receive\n" 992msgid "HTTP CRITICAL - Error on receive\n"
1252msgstr "HTTP CRITICAL - Fehler beim Empfangen\n" 993msgstr "HTTP CRITICAL - Fehler beim Empfangen\n"
1253 994
1254#: plugins/check_http.c:1005
1255#, fuzzy 995#, fuzzy
1256msgid "HTTP CRITICAL - No data received from host\n" 996msgid "HTTP CRITICAL - No data received from host\n"
1257msgstr "HTTP CRITICAL - Keine Daten empfangen\n" 997msgstr "HTTP CRITICAL - Keine Daten empfangen\n"
1258 998
1259#: plugins/check_http.c:1056
1260#, fuzzy, c-format 999#, fuzzy, c-format
1261msgid "Invalid HTTP response received from host: %s\n" 1000msgid "Invalid HTTP response received from host: %s\n"
1262msgstr "Ungültige HTTP Antwort von Host empfangen\n" 1001msgstr "Ungültige HTTP Antwort von Host empfangen\n"
1263 1002
1264#: plugins/check_http.c:1060
1265#, fuzzy, c-format 1003#, fuzzy, c-format
1266msgid "Invalid HTTP response received from host on port %d: %s\n" 1004msgid "Invalid HTTP response received from host on port %d: %s\n"
1267msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 1005msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
1006
1007#, c-format
1008msgid ""
1009"%s\n"
1010"%s"
1011msgstr ""
1268 1012
1269#: plugins/check_http.c:1069
1270#, fuzzy, c-format 1013#, fuzzy, c-format
1271msgid "Status line output matched \"%s\" - " 1014msgid "Status line output matched \"%s\" - "
1272msgstr "HTTP OK: Statusausgabe passt auf \"%s\"\n" 1015msgstr "HTTP OK: Statusausgabe passt auf \"%s\"\n"
1273 1016
1274#: plugins/check_http.c:1080
1275#, c-format 1017#, c-format
1276msgid "HTTP CRITICAL: Invalid Status Line (%s)\n" 1018msgid "HTTP CRITICAL: Invalid Status Line (%s)\n"
1277msgstr "HTTP CRITICAL: Ungültige Statusmeldung (%s)\n" 1019msgstr "HTTP CRITICAL: Ungültige Statusmeldung (%s)\n"
1278 1020
1279#: plugins/check_http.c:1087
1280#, c-format 1021#, c-format
1281msgid "HTTP CRITICAL: Invalid Status (%s)\n" 1022msgid "HTTP CRITICAL: Invalid Status (%s)\n"
1282msgstr "HTTP CRITICAL: Ungültiger Status (%s)\n" 1023msgstr "HTTP CRITICAL: Ungültiger Status (%s)\n"
1283 1024
1284#: plugins/check_http.c:1091 plugins/check_http.c:1096
1285#: plugins/check_http.c:1106 plugins/check_http.c:1110
1286#, c-format 1025#, c-format
1287msgid "%s - " 1026msgid "%s - "
1288msgstr "" 1027msgstr ""
1289 1028
1290#: plugins/check_http.c:1129
1291#, fuzzy, c-format 1029#, fuzzy, c-format
1292msgid "%sheader '%s' not found on '%s://%s:%d%s', " 1030msgid "%sheader '%s' not found on '%s://%s:%d%s', "
1293msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1031msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1294 1032
1295#: plugins/check_http.c:1141
1296#, fuzzy, c-format 1033#, fuzzy, c-format
1297msgid "%sstring '%s' not found on '%s://%s:%d%s', " 1034msgid "%sstring '%s' not found on '%s://%s:%d%s', "
1298msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1035msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1299 1036
1300#: plugins/check_http.c:1154
1301#, fuzzy, c-format 1037#, fuzzy, c-format
1302msgid "%spattern not found, " 1038msgid "%spattern not found, "
1303msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1039msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1304 1040
1305#: plugins/check_http.c:1156
1306#, fuzzy, c-format 1041#, fuzzy, c-format
1307msgid "%spattern found, " 1042msgid "%spattern found, "
1308msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n" 1043msgstr "CRITICAL - Muster nicht gefunden%s|%s %s\n"
1309 1044
1310#: plugins/check_http.c:1162
1311#, fuzzy, c-format 1045#, fuzzy, c-format
1312msgid "%sExecute Error: %s, " 1046msgid "%sExecute Error: %s, "
1313msgstr "HTTP CRITICAL - Fehler: %s\n" 1047msgstr "HTTP CRITICAL - Fehler: %s\n"
1314 1048
1315#: plugins/check_http.c:1178
1316#, fuzzy, c-format 1049#, fuzzy, c-format
1317msgid "%spage size %d too large, " 1050msgid "%spage size %d too large, "
1318msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n" 1051msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n"
1319 1052
1320#: plugins/check_http.c:1181
1321#, fuzzy, c-format 1053#, fuzzy, c-format
1322msgid "%spage size %d too small, " 1054msgid "%spage size %d too small, "
1323msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n" 1055msgstr "HTTP WARNING: Seitengröße %d zu klein%s|%s\n"
1324 1056
1325#: plugins/check_http.c:1194
1326#, fuzzy, c-format 1057#, fuzzy, c-format
1327msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s" 1058msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"
1328msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n" 1059msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n"
1329 1060
1330#: plugins/check_http.c:1206
1331#, fuzzy, c-format 1061#, fuzzy, c-format
1332msgid "%s - %d bytes in %.3f second response time %s|%s %s" 1062msgid "%s - %d bytes in %.3f second response time %s|%s %s"
1333msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n" 1063msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n"
1334 1064
1335#: plugins/check_http.c:1244
1336msgid "HTTP UNKNOWN - Could not allocate addr\n" 1065msgid "HTTP UNKNOWN - Could not allocate addr\n"
1337msgstr "HTTP UNKNOWN - Konnte addr nicht zuweisen\n" 1066msgstr "HTTP UNKNOWN - Konnte addr nicht zuweisen\n"
1338 1067
1339#: plugins/check_http.c:1248 plugins/check_http.c:1279
1340#, fuzzy 1068#, fuzzy
1341msgid "HTTP UNKNOWN - Could not allocate URL\n" 1069msgid "HTTP UNKNOWN - Could not allocate URL\n"
1342msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n" 1070msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
1343 1071
1344#: plugins/check_http.c:1257
1345#, c-format 1072#, c-format
1346msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n" 1073msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n"
1347msgstr "" 1074msgstr ""
1348 1075
1349#: plugins/check_http.c:1272
1350#, fuzzy, c-format 1076#, fuzzy, c-format
1351msgid "HTTP UNKNOWN - Empty redirect location%s\n" 1077msgid "HTTP UNKNOWN - Empty redirect location%s\n"
1352msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n" 1078msgstr "HTTP UNKNOWN - Serverdatum unbekannt\n"
1353 1079
1354#: plugins/check_http.c:1322
1355#, c-format 1080#, c-format
1356msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n" 1081msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n"
1357msgstr "" 1082msgstr ""
1358 1083
1359#: plugins/check_http.c:1332
1360#, fuzzy, c-format 1084#, fuzzy, c-format
1361msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n" 1085msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n"
1362msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n" 1086msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n"
1363 1087
1364#: plugins/check_http.c:1340 1088#, fuzzy, c-format
1365#, c-format 1089msgid "HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1366msgid "HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1367msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n" 1090msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n"
1368 1091
1369#: plugins/check_http.c:1361
1370#, fuzzy, c-format 1092#, fuzzy, c-format
1371msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n" 1093msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"
1372msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n" 1094msgstr "HTTP WARNING - Umleitung verursacht eine Schleife - %s://%s:%d%s%s\n"
1373 1095
1374#: plugins/check_http.c:1366
1375#, c-format 1096#, c-format
1376msgid "Redirection to %s://%s:%d%s\n" 1097msgid "Redirection to %s://%s:%d%s\n"
1377msgstr "" 1098msgstr ""
1378 1099
1379#: plugins/check_http.c:1440
1380#, fuzzy 1100#, fuzzy
1381msgid "This plugin tests the HTTP service on the specified host. It can test" 1101msgid "This plugin tests the HTTP service on the specified host. It can test"
1382msgstr "" 1102msgstr ""
1383"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 1103"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
1384"\n" 1104"\n"
1385 1105
1386#: plugins/check_http.c:1441
1387msgid "normal (http) and secure (https) servers, follow redirects, search for" 1106msgid "normal (http) and secure (https) servers, follow redirects, search for"
1388msgstr "" 1107msgstr ""
1389 1108
1390#: plugins/check_http.c:1442
1391msgid "strings and regular expressions, check connection times, and report on" 1109msgid "strings and regular expressions, check connection times, and report on"
1392msgstr "" 1110msgstr ""
1393 1111
1394#: plugins/check_http.c:1443
1395#, fuzzy 1112#, fuzzy
1396msgid "certificate expiration times." 1113msgid "certificate expiration times."
1397msgstr "Clientzertifikat benötigt\n" 1114msgstr "Clientzertifikat benötigt\n"
1115
1116#, c-format
1117msgid "In the first form, make an HTTP request."
1118msgstr ""
1119
1120#, c-format
1121msgid ""
1122"In the second form, connect to the server and check the TLS certificate."
1123msgstr ""
1398 1124
1399#: plugins/check_http.c:1449
1400#, c-format 1125#, c-format
1401msgid "NOTE: One or both of -H and -I must be specified" 1126msgid "NOTE: One or both of -H and -I must be specified"
1402msgstr "" 1127msgstr ""
1403 1128
1404#: plugins/check_http.c:1457
1405msgid "Host name argument for servers using host headers (virtual host)" 1129msgid "Host name argument for servers using host headers (virtual host)"
1406msgstr "" 1130msgstr ""
1407 1131
1408#: plugins/check_http.c:1458
1409msgid "Append a port to include it in the header (eg: example.com:5000)" 1132msgid "Append a port to include it in the header (eg: example.com:5000)"
1410msgstr "" 1133msgstr ""
1411 1134
1412#: plugins/check_http.c:1460
1413msgid "" 1135msgid ""
1414"IP address or name (use numeric address if possible to bypass DNS lookup)." 1136"IP address or name (use numeric address if possible to bypass DNS lookup)."
1415msgstr "" 1137msgstr ""
1416 1138
1417#: plugins/check_http.c:1462
1418msgid "Port number (default: " 1139msgid "Port number (default: "
1419msgstr "" 1140msgstr ""
1420 1141
1421#: plugins/check_http.c:1469
1422msgid "" 1142msgid ""
1423"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents" 1143"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"
1424msgstr "" 1144msgstr ""
1425 1145
1426#: plugins/check_http.c:1470 1146msgid "auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"
1427msgid "auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)." 1147msgstr ""
1148
1149msgid "1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."
1428msgstr "" 1150msgstr ""
1429 1151
1430#: plugins/check_http.c:1472
1431msgid "Enable SSL/TLS hostname extension support (SNI)" 1152msgid "Enable SSL/TLS hostname extension support (SNI)"
1432msgstr "" 1153msgstr ""
1433 1154
1434#: plugins/check_http.c:1474
1435msgid "" 1155msgid ""
1436"Minimum number of days a certificate has to be valid. Port defaults to 443" 1156"Minimum number of days a certificate has to be valid. Port defaults to 443"
1437msgstr "" 1157msgstr ""
1438 1158
1439#: plugins/check_http.c:1475 1159msgid ""
1440msgid "(when this option is used the URL is not checked.)" 1160"(when this option is used the URL is not checked by default. You can use"
1161msgstr ""
1162
1163msgid " --continue-after-certificate to override this behavior)"
1164msgstr ""
1165
1166msgid ""
1167"Allows the HTTP check to continue after performing the certificate check."
1168msgstr ""
1169
1170msgid "Does nothing unless -C is used."
1441msgstr "" 1171msgstr ""
1442 1172
1443#: plugins/check_http.c:1477
1444msgid "Name of file that contains the client certificate (PEM format)" 1173msgid "Name of file that contains the client certificate (PEM format)"
1445msgstr "" 1174msgstr ""
1446 1175
1447#: plugins/check_http.c:1478
1448msgid "to be used in establishing the SSL session" 1176msgid "to be used in establishing the SSL session"
1449msgstr "" 1177msgstr ""
1450 1178
1451#: plugins/check_http.c:1480
1452msgid "Name of file containing the private key (PEM format)" 1179msgid "Name of file containing the private key (PEM format)"
1453msgstr "" 1180msgstr ""
1454 1181
1455#: plugins/check_http.c:1481
1456msgid "matching the client certificate" 1182msgid "matching the client certificate"
1457msgstr "" 1183msgstr ""
1458 1184
1459#: plugins/check_http.c:1485
1460msgid "Comma-delimited list of strings, at least one of them is expected in" 1185msgid "Comma-delimited list of strings, at least one of them is expected in"
1461msgstr "" 1186msgstr ""
1462 1187
1463#: plugins/check_http.c:1486
1464msgid "the first (status) line of the server response (default: " 1188msgid "the first (status) line of the server response (default: "
1465msgstr "" 1189msgstr ""
1466 1190
1467#: plugins/check_http.c:1488
1468msgid "" 1191msgid ""
1469"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)" 1192"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"
1470msgstr "" 1193msgstr ""
1471 1194
1472#: plugins/check_http.c:1490
1473msgid "String to expect in the response headers" 1195msgid "String to expect in the response headers"
1474msgstr "" 1196msgstr ""
1475 1197
1476#: plugins/check_http.c:1492
1477msgid "String to expect in the content" 1198msgid "String to expect in the content"
1478msgstr "" 1199msgstr ""
1479 1200
1480#: plugins/check_http.c:1494
1481msgid "URL to GET or POST (default: /)" 1201msgid "URL to GET or POST (default: /)"
1482msgstr "" 1202msgstr ""
1483 1203
1484#: plugins/check_http.c:1496
1485msgid "URL encoded http POST data" 1204msgid "URL encoded http POST data"
1486msgstr "" 1205msgstr ""
1487 1206
1488#: plugins/check_http.c:1498
1489msgid "Set HTTP method." 1207msgid "Set HTTP method."
1490msgstr "" 1208msgstr ""
1491 1209
1492#: plugins/check_http.c:1500
1493msgid "Don't wait for document body: stop reading after headers." 1210msgid "Don't wait for document body: stop reading after headers."
1494msgstr "" 1211msgstr ""
1495 1212
1496#: plugins/check_http.c:1501
1497msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)" 1213msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)"
1498msgstr "" 1214msgstr ""
1499 1215
1500#: plugins/check_http.c:1503
1501msgid "Warn if document is more than SECONDS old. the number can also be of" 1216msgid "Warn if document is more than SECONDS old. the number can also be of"
1502msgstr "" 1217msgstr ""
1503 1218
1504#: plugins/check_http.c:1504
1505msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days." 1219msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."
1506msgstr "" 1220msgstr ""
1507 1221
1508#: plugins/check_http.c:1506
1509msgid "specify Content-Type header media type when POSTing\n" 1222msgid "specify Content-Type header media type when POSTing\n"
1510msgstr "" 1223msgstr ""
1511 1224
1512#: plugins/check_http.c:1509
1513msgid "Allow regex to span newlines (must precede -r or -R)" 1225msgid "Allow regex to span newlines (must precede -r or -R)"
1514msgstr "" 1226msgstr ""
1515 1227
1516#: plugins/check_http.c:1511
1517msgid "Search page for regex STRING" 1228msgid "Search page for regex STRING"
1518msgstr "" 1229msgstr ""
1519 1230
1520#: plugins/check_http.c:1513
1521msgid "Search page for case-insensitive regex STRING" 1231msgid "Search page for case-insensitive regex STRING"
1522msgstr "" 1232msgstr ""
1523 1233
1524#: plugins/check_http.c:1515
1525msgid "Return CRITICAL if found, OK if not\n" 1234msgid "Return CRITICAL if found, OK if not\n"
1526msgstr "" 1235msgstr ""
1527 1236
1528#: plugins/check_http.c:1518
1529msgid "Username:password on sites with basic authentication" 1237msgid "Username:password on sites with basic authentication"
1530msgstr "" 1238msgstr ""
1531 1239
1532#: plugins/check_http.c:1520
1533msgid "Username:password on proxy-servers with basic authentication" 1240msgid "Username:password on proxy-servers with basic authentication"
1534msgstr "" 1241msgstr ""
1535 1242
1536#: plugins/check_http.c:1522
1537msgid "String to be sent in http header as \"User Agent\"" 1243msgid "String to be sent in http header as \"User Agent\""
1538msgstr "" 1244msgstr ""
1539 1245
1540#: plugins/check_http.c:1524
1541msgid "" 1246msgid ""
1542"Any other tags to be sent in http header. Use multiple times for additional " 1247"Any other tags to be sent in http header. Use multiple times for additional "
1543"headers" 1248"headers"
1544msgstr "" 1249msgstr ""
1545 1250
1546#: plugins/check_http.c:1526
1547msgid "Print additional performance data" 1251msgid "Print additional performance data"
1548msgstr "" 1252msgstr ""
1549 1253
1550#: plugins/check_http.c:1528 1254msgid "Print body content below status line"
1255msgstr ""
1256
1551msgid "Wrap output in HTML link (obsoleted by urlize)" 1257msgid "Wrap output in HTML link (obsoleted by urlize)"
1552msgstr "" 1258msgstr ""
1553 1259
1554#: plugins/check_http.c:1530
1555msgid "How to handle redirected pages. sticky is like follow but stick to the" 1260msgid "How to handle redirected pages. sticky is like follow but stick to the"
1556msgstr "" 1261msgstr ""
1557 1262
1558#: plugins/check_http.c:1531
1559msgid "specified IP address. stickyport also ensures port stays the same." 1263msgid "specified IP address. stickyport also ensures port stays the same."
1560msgstr "" 1264msgstr ""
1561 1265
1562#: plugins/check_http.c:1533 1266#, fuzzy
1267msgid "Maximal number of redirects (default: "
1268msgstr "Ungültige Portnummer"
1269
1563msgid "Minimum page size required (bytes) : Maximum page size required (bytes)" 1270msgid "Minimum page size required (bytes) : Maximum page size required (bytes)"
1564msgstr "" 1271msgstr ""
1565 1272
1566#: plugins/check_http.c:1543
1567#, fuzzy 1273#, fuzzy
1568msgid "This plugin will attempt to open an HTTP connection with the host." 1274msgid "This plugin will attempt to open an HTTP connection with the host."
1569msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 1275msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
1570 1276
1571#: plugins/check_http.c:1544
1572msgid "" 1277msgid ""
1573"Successful connects return STATE_OK, refusals and timeouts return " 1278"Successful connects return STATE_OK, refusals and timeouts return "
1574"STATE_CRITICAL" 1279"STATE_CRITICAL"
1575msgstr "" 1280msgstr ""
1576 1281
1577#: plugins/check_http.c:1545
1578msgid "" 1282msgid ""
1579"other errors return STATE_UNKNOWN. Successful connects, but incorrect " 1283"other errors return STATE_UNKNOWN. Successful connects, but incorrect "
1580"response" 1284"response"
1581msgstr "" 1285msgstr ""
1582 1286
1583#: plugins/check_http.c:1546
1584msgid "" 1287msgid ""
1585"messages from the host result in STATE_WARNING return values. If you are" 1288"messages from the host result in STATE_WARNING return values. If you are"
1586msgstr "" 1289msgstr ""
1587 1290
1588#: plugins/check_http.c:1547
1589msgid "" 1291msgid ""
1590"checking a virtual server that uses 'host headers' you must supply the FQDN" 1292"checking a virtual server that uses 'host headers' you must supply the FQDN"
1591msgstr "" 1293msgstr ""
1592 1294
1593#: plugins/check_http.c:1548
1594msgid "(fully qualified domain name) as the [host_name] argument." 1295msgid "(fully qualified domain name) as the [host_name] argument."
1595msgstr "" 1296msgstr ""
1596 1297
1597#: plugins/check_http.c:1552
1598msgid "This plugin can also check whether an SSL enabled web server is able to" 1298msgid "This plugin can also check whether an SSL enabled web server is able to"
1599msgstr "" 1299msgstr ""
1600 1300
1601#: plugins/check_http.c:1553
1602msgid "serve content (optionally within a specified time) or whether the X509 " 1301msgid "serve content (optionally within a specified time) or whether the X509 "
1603msgstr "" 1302msgstr ""
1604 1303
1605#: plugins/check_http.c:1554
1606msgid "certificate is still valid for the specified number of days." 1304msgid "certificate is still valid for the specified number of days."
1607msgstr "" 1305msgstr ""
1608 1306
1609#: plugins/check_http.c:1556
1610#, fuzzy 1307#, fuzzy
1611msgid "Please note that this plugin does not check if the presented server" 1308msgid "Please note that this plugin does not check if the presented server"
1612msgstr "" 1309msgstr ""
1613"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 1310"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
1614"\n" 1311"\n"
1615 1312
1616#: plugins/check_http.c:1557
1617msgid "certificate matches the hostname of the server, or if the certificate" 1313msgid "certificate matches the hostname of the server, or if the certificate"
1618msgstr "" 1314msgstr ""
1619 1315
1620#: plugins/check_http.c:1558
1621msgid "has a valid chain of trust to one of the locally installed CAs." 1316msgid "has a valid chain of trust to one of the locally installed CAs."
1622msgstr "" 1317msgstr ""
1623 1318
1624#: plugins/check_http.c:1562
1625msgid "" 1319msgid ""
1626"When the 'www.verisign.com' server returns its content within 5 seconds," 1320"When the 'www.verisign.com' server returns its content within 5 seconds,"
1627msgstr "" 1321msgstr ""
1628 1322
1629#: plugins/check_http.c:1563
1630msgid "" 1323msgid ""
1631"a STATE_OK will be returned. When the server returns its content but exceeds" 1324"a STATE_OK will be returned. When the server returns its content but exceeds"
1632msgstr "" 1325msgstr ""
1633 1326
1634#: plugins/check_http.c:1564
1635msgid "" 1327msgid ""
1636"the 5-second threshold, a STATE_WARNING will be returned. When an error " 1328"the 5-second threshold, a STATE_WARNING will be returned. When an error "
1637"occurs," 1329"occurs,"
1638msgstr "" 1330msgstr ""
1639 1331
1640#: plugins/check_http.c:1565
1641msgid "a STATE_CRITICAL will be returned." 1332msgid "a STATE_CRITICAL will be returned."
1642msgstr "" 1333msgstr ""
1643 1334
1644#: plugins/check_http.c:1568
1645msgid "" 1335msgid ""
1646"When the certificate of 'www.verisign.com' is valid for more than 14 days," 1336"When the certificate of 'www.verisign.com' is valid for more than 14 days,"
1647msgstr "" 1337msgstr ""
1648 1338
1649#: plugins/check_http.c:1569 plugins/check_http.c:1575
1650msgid "" 1339msgid ""
1651"a STATE_OK is returned. When the certificate is still valid, but for less " 1340"a STATE_OK is returned. When the certificate is still valid, but for less "
1652"than" 1341"than"
1653msgstr "" 1342msgstr ""
1654 1343
1655#: plugins/check_http.c:1570
1656msgid "" 1344msgid ""
1657"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when" 1345"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"
1658msgstr "" 1346msgstr ""
1659 1347
1660#: plugins/check_http.c:1571
1661#, fuzzy 1348#, fuzzy
1662msgid "the certificate is expired." 1349msgid "the certificate is expired."
1663msgstr "Clientzertifikat benötigt\n" 1350msgstr "Clientzertifikat benötigt\n"
1664 1351
1665#: plugins/check_http.c:1574
1666msgid "" 1352msgid ""
1667"When the certificate of 'www.verisign.com' is valid for more than 30 days," 1353"When the certificate of 'www.verisign.com' is valid for more than 30 days,"
1668msgstr "" 1354msgstr ""
1669 1355
1670#: plugins/check_http.c:1576
1671msgid "30 days, but more than 14 days, a STATE_WARNING is returned." 1356msgid "30 days, but more than 14 days, a STATE_WARNING is returned."
1672msgstr "" 1357msgstr ""
1673 1358
1674#: plugins/check_http.c:1577
1675msgid "" 1359msgid ""
1676"A STATE_CRITICAL will be returned when certificate expires in less than 14 " 1360"A STATE_CRITICAL will be returned when certificate expires in less than 14 "
1677"days" 1361"days"
1678msgstr "" 1362msgstr ""
1679 1363
1680#: plugins/check_ldap.c:133 1364msgid ""
1365"check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j "
1366"CONNECT -H www.verisign.com "
1367msgstr ""
1368
1369msgid ""
1370"all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -"
1371"S(sl) -j CONNECT -H <webserver>"
1372msgstr ""
1373
1374msgid ""
1375"a STATE_CRITICAL will be returned. By adding a colon to the method you can "
1376"set the method used"
1377msgstr ""
1378
1379msgid "inside the proxied connection: -j CONNECT:POST"
1380msgstr ""
1381
1681#, c-format 1382#, c-format
1682msgid "Could not connect to the server at port %i\n" 1383msgid "Could not connect to the server at port %i\n"
1683msgstr "" 1384msgstr ""
1684 1385
1685#: plugins/check_ldap.c:142
1686#, c-format 1386#, c-format
1687msgid "Could not set protocol version %d\n" 1387msgid "Could not set protocol version %d\n"
1688msgstr "" 1388msgstr ""
1689 1389
1690#: plugins/check_ldap.c:157
1691#, fuzzy, c-format 1390#, fuzzy, c-format
1692msgid "Could not init TLS at port %i!\n" 1391msgid "Could not init TLS at port %i!\n"
1693msgstr "Konnte stderr nicht öffnen für: %s\n" 1392msgstr "Konnte stderr nicht öffnen für: %s\n"
1694 1393
1695#: plugins/check_ldap.c:161
1696#, c-format 1394#, c-format
1697msgid "TLS not supported by the libraries!\n" 1395msgid "TLS not supported by the libraries!\n"
1698msgstr "" 1396msgstr ""
1699 1397
1700#: plugins/check_ldap.c:181
1701#, fuzzy, c-format 1398#, fuzzy, c-format
1702msgid "Could not init startTLS at port %i!\n" 1399msgid "Could not init startTLS at port %i!\n"
1703msgstr "Konnte stderr nicht öffnen für: %s\n" 1400msgstr "Konnte stderr nicht öffnen für: %s\n"
1704 1401
1705#: plugins/check_ldap.c:185
1706#, c-format 1402#, c-format
1707msgid "startTLS not supported by the library, needs LDAPv3!\n" 1403msgid "startTLS not supported by the library, needs LDAPv3!\n"
1708msgstr "" 1404msgstr ""
1709 1405
1710#: plugins/check_ldap.c:195
1711#, c-format 1406#, c-format
1712msgid "Could not bind to the LDAP server\n" 1407msgid "Could not bind to the LDAP server\n"
1713msgstr "" 1408msgstr ""
1714 1409
1715#: plugins/check_ldap.c:204
1716#, c-format 1410#, c-format
1717msgid "Could not search/find objectclasses in %s\n" 1411msgid "Could not search/find objectclasses in %s\n"
1718msgstr "" 1412msgstr ""
1719 1413
1720#: plugins/check_ldap.c:227 1414#, fuzzy, c-format
1415msgid "LDAP %s - found %d entries in %.3f seconds|%s %s\n"
1416msgstr "HTTP OK %s - %.3f Sekunde Antwortzeit %s%s|%s %s\n"
1417
1721#, c-format 1418#, c-format
1722msgid "LDAP %s - %.3f seconds response time|%s\n" 1419msgid "LDAP %s - %.3f seconds response time|%s\n"
1723msgstr "" 1420msgstr ""
1724 1421
1725#: plugins/check_ldap.c:339 plugins/check_ldap.c:347
1726#, c-format 1422#, c-format
1727msgid "%s cannot be combined with %s" 1423msgid "%s cannot be combined with %s"
1728msgstr "" 1424msgstr ""
1729 1425
1730#: plugins/check_ldap.c:379
1731msgid "Please specify the host name\n" 1426msgid "Please specify the host name\n"
1732msgstr "" 1427msgstr ""
1733 1428
1734#: plugins/check_ldap.c:382
1735msgid "Please specify the LDAP base\n" 1429msgid "Please specify the LDAP base\n"
1736msgstr "" 1430msgstr ""
1737 1431
1738#: plugins/check_ldap.c:411
1739msgid "ldap attribute to search (default: \"(objectclass=*)\"" 1432msgid "ldap attribute to search (default: \"(objectclass=*)\""
1740msgstr "" 1433msgstr ""
1741 1434
1742#: plugins/check_ldap.c:413
1743msgid "ldap base (eg. ou=my unit, o=my org, c=at" 1435msgid "ldap base (eg. ou=my unit, o=my org, c=at"
1744msgstr "" 1436msgstr ""
1745 1437
1746#: plugins/check_ldap.c:415
1747msgid "ldap bind DN (if required)" 1438msgid "ldap bind DN (if required)"
1748msgstr "" 1439msgstr ""
1749 1440
1750#: plugins/check_ldap.c:417 1441msgid ""
1751msgid "ldap password (if required)" 1442"ldap password (if required, or set the password through environment variable "
1443"'LDAP_PASSWORD')"
1752msgstr "" 1444msgstr ""
1753 1445
1754#: plugins/check_ldap.c:419
1755msgid "use starttls mechanism introduced in protocol version 3" 1446msgid "use starttls mechanism introduced in protocol version 3"
1756msgstr "" 1447msgstr ""
1757 1448
1758#: plugins/check_ldap.c:421
1759msgid "use ldaps (ldap v2 ssl method). this also sets the default port to" 1449msgid "use ldaps (ldap v2 ssl method). this also sets the default port to"
1760msgstr "" 1450msgstr ""
1761 1451
1762#: plugins/check_ldap.c:425
1763msgid "use ldap protocol version 2" 1452msgid "use ldap protocol version 2"
1764msgstr "" 1453msgstr ""
1765 1454
1766#: plugins/check_ldap.c:427
1767msgid "use ldap protocol version 3" 1455msgid "use ldap protocol version 3"
1768msgstr "" 1456msgstr ""
1769 1457
1770#: plugins/check_ldap.c:428
1771msgid "default protocol version:" 1458msgid "default protocol version:"
1772msgstr "" 1459msgstr ""
1773 1460
1774#: plugins/check_ldap.c:439 1461msgid "Number of found entries to result in warning status"
1462msgstr ""
1463
1464msgid "Number of found entries to result in critical status"
1465msgstr ""
1466
1775msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be" 1467msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be"
1776msgstr "" 1468msgstr ""
1777 1469
1778#: plugins/check_ldap.c:440
1779#, c-format 1470#, c-format
1780msgid "" 1471msgid ""
1781" implied (using default port %i) unless --port=636 is specified. In that " 1472" implied (using default port %i) unless --port=636 is specified. In that "
1782"case\n" 1473"case\n"
1783msgstr "" 1474msgstr ""
1784 1475
1785#: plugins/check_ldap.c:441
1786msgid "'SSL on connect' will be used no matter how the plugin was called." 1476msgid "'SSL on connect' will be used no matter how the plugin was called."
1787msgstr "" 1477msgstr ""
1788 1478
1789#: plugins/check_ldap.c:442
1790msgid "" 1479msgid ""
1791"This detection is deprecated, please use 'check_ldap' with the '--starttls' " 1480"This detection is deprecated, please use 'check_ldap' with the '--starttls' "
1792"or '--ssl' flags" 1481"or '--ssl' flags"
1793msgstr "" 1482msgstr ""
1794 1483
1795#: plugins/check_ldap.c:443
1796msgid "to define the behaviour explicitly instead." 1484msgid "to define the behaviour explicitly instead."
1797msgstr "" 1485msgstr ""
1798 1486
1799#: plugins/check_load.c:87 1487msgid "The parameters --warn-entries and --crit-entries are optional."
1488msgstr ""
1489
1800msgid "Warning threshold must be float or float triplet!\n" 1490msgid "Warning threshold must be float or float triplet!\n"
1801msgstr "" 1491msgstr ""
1802 1492
1803#: plugins/check_load.c:132 plugins/check_load.c:148
1804#, c-format 1493#, c-format
1805msgid "Error opening %s\n" 1494msgid "Error opening %s\n"
1806msgstr "" 1495msgstr ""
1807 1496
1808#: plugins/check_load.c:163
1809#, fuzzy, c-format 1497#, fuzzy, c-format
1810msgid "could not parse load from uptime: %s\n" 1498msgid "could not parse load from uptime %s: %d\n"
1811msgstr "Argumente konnten nicht ausgewertet werden" 1499msgstr "Argumente konnten nicht ausgewertet werden"
1812 1500
1813#: plugins/check_load.c:169
1814#, c-format 1501#, c-format
1815msgid "Error code %d returned in %s\n" 1502msgid "Error code %d returned in %s\n"
1816msgstr "" 1503msgstr ""
1817 1504
1818#: plugins/check_load.c:184
1819#, c-format 1505#, c-format
1820msgid "Error in getloadavg()\n" 1506msgid "Error in getloadavg()\n"
1821msgstr "" 1507msgstr ""
1822 1508
1823#: plugins/check_load.c:187 plugins/check_load.c:189
1824#, c-format 1509#, c-format
1825msgid "Error processing %s\n" 1510msgid "Error processing %s\n"
1826msgstr "" 1511msgstr ""
1827 1512
1828#: plugins/check_load.c:198
1829#, c-format 1513#, c-format
1830msgid "load average: %.2f, %.2f, %.2f" 1514msgid "load average: %.2f, %.2f, %.2f"
1831msgstr "" 1515msgstr ""
1832 1516
1833#: plugins/check_load.c:291
1834#, fuzzy, c-format 1517#, fuzzy, c-format
1835msgid "Critical threshold for %d-minute load average is not specified\n" 1518msgid "Critical threshold for %d-minute load average is not specified\n"
1836msgstr "Critical threshold muss ein positiver Integer sein\n" 1519msgstr "Critical threshold muss ein positiver Integer sein\n"
1837 1520
1838#: plugins/check_load.c:293
1839#, fuzzy, c-format 1521#, fuzzy, c-format
1840msgid "Warning threshold for %d-minute load average is not specified\n" 1522msgid "Warning threshold for %d-minute load average is not specified\n"
1841msgstr "Warning threshold muss ein positiver Integer sein\n" 1523msgstr "Warning threshold muss ein positiver Integer sein\n"
1842 1524
1843#: plugins/check_load.c:295
1844#, c-format 1525#, c-format
1845msgid "" 1526msgid ""
1846"Parameter inconsistency: %d-minute \"warning load\" is greater than " 1527"Parameter inconsistency: %d-minute \"warning load\" is greater than "
1847"\"critical load\"\n" 1528"\"critical load\"\n"
1848msgstr "" 1529msgstr ""
1849 1530
1850#: plugins/check_load.c:311
1851#, c-format 1531#, c-format
1852msgid "This plugin tests the current system load average." 1532msgid "This plugin tests the current system load average."
1853msgstr "" 1533msgstr ""
1854 1534
1855#: plugins/check_load.c:321
1856msgid "Exit with WARNING status if load average exceeds WLOADn" 1535msgid "Exit with WARNING status if load average exceeds WLOADn"
1857msgstr "" 1536msgstr ""
1858 1537
1859#: plugins/check_load.c:323
1860msgid "Exit with CRITICAL status if load average exceed CLOADn" 1538msgid "Exit with CRITICAL status if load average exceed CLOADn"
1861msgstr "" 1539msgstr ""
1862 1540
1863#: plugins/check_load.c:324
1864msgid "the load average format is the same used by \"uptime\" and \"w\"" 1541msgid "the load average format is the same used by \"uptime\" and \"w\""
1865msgstr "" 1542msgstr ""
1866 1543
1867#: plugins/check_load.c:326
1868msgid "Divide the load averages by the number of CPUs (when possible)" 1544msgid "Divide the load averages by the number of CPUs (when possible)"
1869msgstr "" 1545msgstr ""
1870 1546
1871#: plugins/check_mrtg.c:75 1547msgid "Number of processes to show when printing the top consuming processes."
1548msgstr ""
1549
1550msgid "NUMBER_OF_PROCS=0 disables this feature. Default value is 0"
1551msgstr ""
1552
1553#, c-format
1554msgid "'%s' exited with non-zero status.\n"
1555msgstr ""
1556
1557#, c-format
1558msgid "some error occurred getting procs list.\n"
1559msgstr ""
1560
1872msgid "Could not parse arguments\n" 1561msgid "Could not parse arguments\n"
1873msgstr "" 1562msgstr ""
1874 1563
1875#: plugins/check_mrtg.c:80
1876#, c-format 1564#, c-format
1877msgid "Unable to open MRTG log file\n" 1565msgid "Unable to open MRTG log file\n"
1878msgstr "" 1566msgstr ""
1879 1567
1880#: plugins/check_mrtg.c:127
1881#, c-format 1568#, c-format
1882msgid "Unable to process MRTG log file\n" 1569msgid "Unable to process MRTG log file\n"
1883msgstr "" 1570msgstr ""
1884 1571
1885#: plugins/check_mrtg.c:135 plugins/check_mrtgtraf.c:136
1886#, c-format 1572#, c-format
1887msgid "MRTG data has expired (%d minutes old)\n" 1573msgid "MRTG data has expired (%d minutes old)\n"
1888msgstr "" 1574msgstr ""
1889 1575
1890#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1891#: plugins/check_mrtgtraf.c:196
1892msgid "Avg" 1576msgid "Avg"
1893msgstr "" 1577msgstr ""
1894 1578
1895#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1896#: plugins/check_mrtgtraf.c:196
1897msgid "Max" 1579msgid "Max"
1898msgstr "" 1580msgstr ""
1899 1581
1900#: plugins/check_mrtg.c:221
1901msgid "Invalid variable number" 1582msgid "Invalid variable number"
1902msgstr "" 1583msgstr ""
1903 1584
1904#: plugins/check_mrtg.c:256
1905#, c-format 1585#, c-format
1906msgid "" 1586msgid ""
1907"%s is not a valid expiration time\n" 1587"%s is not a valid expiration time\n"
1908"Use '%s -h' for additional help\n" 1588"Use '%s -h' for additional help\n"
1909msgstr "" 1589msgstr ""
1910 1590
1911#: plugins/check_mrtg.c:273
1912msgid "Invalid variable number\n" 1591msgid "Invalid variable number\n"
1913msgstr "" 1592msgstr ""
1914 1593
1915#: plugins/check_mrtg.c:300
1916msgid "You must supply the variable number" 1594msgid "You must supply the variable number"
1917msgstr "" 1595msgstr ""
1918 1596
1919#: plugins/check_mrtg.c:321
1920msgid "" 1597msgid ""
1921"This plugin will check either the average or maximum value of one of the" 1598"This plugin will check either the average or maximum value of one of the"
1922msgstr "" 1599msgstr ""
1923 1600
1924#: plugins/check_mrtg.c:322
1925#, fuzzy 1601#, fuzzy
1926msgid "two variables recorded in an MRTG log file." 1602msgid "two variables recorded in an MRTG log file."
1927msgstr "Konnte MRTG Logfile nicht öffnen" 1603msgstr "Konnte MRTG Logfile nicht öffnen"
1928 1604
1929#: plugins/check_mrtg.c:332
1930msgid "The MRTG log file containing the data you want to monitor" 1605msgid "The MRTG log file containing the data you want to monitor"
1931msgstr "" 1606msgstr ""
1932 1607
1933#: plugins/check_mrtg.c:334
1934msgid "Minutes before MRTG data is considered to be too old" 1608msgid "Minutes before MRTG data is considered to be too old"
1935msgstr "" 1609msgstr ""
1936 1610
1937#: plugins/check_mrtg.c:336
1938msgid "Should we check average or maximum values?" 1611msgid "Should we check average or maximum values?"
1939msgstr "" 1612msgstr ""
1940 1613
1941#: plugins/check_mrtg.c:338
1942msgid "Which variable set should we inspect? (1 or 2)" 1614msgid "Which variable set should we inspect? (1 or 2)"
1943msgstr "" 1615msgstr ""
1944 1616
1945#: plugins/check_mrtg.c:340
1946msgid "Threshold value for data to result in WARNING status" 1617msgid "Threshold value for data to result in WARNING status"
1947msgstr "" 1618msgstr ""
1948 1619
1949#: plugins/check_mrtg.c:342
1950msgid "Threshold value for data to result in CRITICAL status" 1620msgid "Threshold value for data to result in CRITICAL status"
1951msgstr "" 1621msgstr ""
1952 1622
1953#: plugins/check_mrtg.c:344
1954msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)" 1623msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)"
1955msgstr "" 1624msgstr ""
1956 1625
1957#: plugins/check_mrtg.c:346
1958msgid "Option units label for data (Example: Packets/Sec, Errors/Sec," 1626msgid "Option units label for data (Example: Packets/Sec, Errors/Sec,"
1959msgstr "" 1627msgstr ""
1960 1628
1961#: plugins/check_mrtg.c:347
1962#, c-format 1629#, c-format
1963msgid "\"Bytes Per Second\", \"%% Utilization\")" 1630msgid "\"Bytes Per Second\", \"%% Utilization\")"
1964msgstr "" 1631msgstr ""
1965 1632
1966#: plugins/check_mrtg.c:350
1967msgid "" 1633msgid ""
1968"If the value exceeds the <vwl> threshold, a WARNING status is returned. If" 1634"If the value exceeds the <vwl> threshold, a WARNING status is returned. If"
1969msgstr "" 1635msgstr ""
1970 1636
1971#: plugins/check_mrtg.c:351
1972msgid "" 1637msgid ""
1973"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If" 1638"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"
1974msgstr "" 1639msgstr ""
1975 1640
1976#: plugins/check_mrtg.c:352
1977msgid "the data in the log file is older than <expire_minutes> old, a WARNING" 1641msgid "the data in the log file is older than <expire_minutes> old, a WARNING"
1978msgstr "" 1642msgstr ""
1979 1643
1980#: plugins/check_mrtg.c:353
1981msgid "status is returned and a warning message is printed." 1644msgid "status is returned and a warning message is printed."
1982msgstr "" 1645msgstr ""
1983 1646
1984#: plugins/check_mrtg.c:356
1985msgid "" 1647msgid ""
1986"This plugin is useful for monitoring MRTG data that does not correspond to" 1648"This plugin is useful for monitoring MRTG data that does not correspond to"
1987msgstr "" 1649msgstr ""
1988 1650
1989#: plugins/check_mrtg.c:357
1990msgid "" 1651msgid ""
1991"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)." 1652"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."
1992msgstr "" 1653msgstr ""
1993 1654
1994#: plugins/check_mrtg.c:358
1995msgid "" 1655msgid ""
1996"It can be used to monitor any kind of data that MRTG is monitoring - errors," 1656"It can be used to monitor any kind of data that MRTG is monitoring - errors,"
1997msgstr "" 1657msgstr ""
1998 1658
1999#: plugins/check_mrtg.c:359
2000msgid "" 1659msgid ""
2001"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows" 1660"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"
2002msgstr "" 1661msgstr ""
2003 1662
2004#: plugins/check_mrtg.c:360
2005msgid "" 1663msgid ""
2006"me to track processor utilization, user connections, drive space, etc and" 1664"me to track processor utilization, user connections, drive space, etc and"
2007msgstr "" 1665msgstr ""
2008 1666
2009#: plugins/check_mrtg.c:361
2010msgid "this plugin works well for monitoring that kind of data as well." 1667msgid "this plugin works well for monitoring that kind of data as well."
2011msgstr "" 1668msgstr ""
2012 1669
2013#: plugins/check_mrtg.c:364
2014msgid "" 1670msgid ""
2015"- This plugin only monitors one of the two variables stored in the MRTG log" 1671"- This plugin only monitors one of the two variables stored in the MRTG log"
2016msgstr "" 1672msgstr ""
2017 1673
2018#: plugins/check_mrtg.c:365
2019msgid "file. If you want to monitor both values you will have to define two" 1674msgid "file. If you want to monitor both values you will have to define two"
2020msgstr "" 1675msgstr ""
2021 1676
2022#: plugins/check_mrtg.c:366
2023msgid "commands with different values for the <variable> argument. Of course," 1677msgid "commands with different values for the <variable> argument. Of course,"
2024msgstr "" 1678msgstr ""
2025 1679
2026#: plugins/check_mrtg.c:367
2027msgid "you can always hack the code to make this plugin work for you..." 1680msgid "you can always hack the code to make this plugin work for you..."
2028msgstr "" 1681msgstr ""
2029 1682
2030#: plugins/check_mrtg.c:368
2031msgid "" 1683msgid ""
2032"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded " 1684"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded "
2033"from" 1685"from"
2034msgstr "" 1686msgstr ""
2035 1687
2036#: plugins/check_mrtgtraf.c:88
2037msgid "Unable to open MRTG log file" 1688msgid "Unable to open MRTG log file"
2038msgstr "Konnte MRTG Logfile nicht öffnen" 1689msgstr "Konnte MRTG Logfile nicht öffnen"
2039 1690
2040#: plugins/check_mrtgtraf.c:130
2041msgid "Unable to process MRTG log file" 1691msgid "Unable to process MRTG log file"
2042msgstr "" 1692msgstr ""
2043 1693
2044#: plugins/check_mrtgtraf.c:194
2045#, c-format 1694#, c-format
2046msgid "%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n" 1695msgid "%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"
2047msgstr "" 1696msgstr ""
2048 1697
2049#: plugins/check_mrtgtraf.c:207
2050#, c-format 1698#, c-format
2051msgid "Traffic %s - %s\n" 1699msgid "Traffic %s - %s\n"
2052msgstr "" 1700msgstr ""
2053 1701
2054#: plugins/check_mrtgtraf.c:335
2055msgid "" 1702msgid ""
2056"This plugin will check the incoming/outgoing transfer rates of a router," 1703"This plugin will check the incoming/outgoing transfer rates of a router,"
2057msgstr "" 1704msgstr ""
2058 1705
2059#: plugins/check_mrtgtraf.c:336
2060msgid "switch, etc recorded in an MRTG log. If the newest log entry is older" 1706msgid "switch, etc recorded in an MRTG log. If the newest log entry is older"
2061msgstr "" 1707msgstr ""
2062 1708
2063#: plugins/check_mrtgtraf.c:337
2064msgid "than <expire_minutes>, a WARNING status is returned. If either the" 1709msgid "than <expire_minutes>, a WARNING status is returned. If either the"
2065msgstr "" 1710msgstr ""
2066 1711
2067#: plugins/check_mrtgtraf.c:338
2068msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in" 1712msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in"
2069msgstr "" 1713msgstr ""
2070 1714
2071#: plugins/check_mrtgtraf.c:339
2072msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed" 1715msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed"
2073msgstr "" 1716msgstr ""
2074 1717
2075#: plugins/check_mrtgtraf.c:340
2076msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results." 1718msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results."
2077msgstr "" 1719msgstr ""
2078 1720
2079#: plugins/check_mrtgtraf.c:350
2080msgid "File to read log from" 1721msgid "File to read log from"
2081msgstr "" 1722msgstr ""
2082 1723
2083#: plugins/check_mrtgtraf.c:352
2084msgid "Minutes after which log expires" 1724msgid "Minutes after which log expires"
2085msgstr "" 1725msgstr ""
2086 1726
2087#: plugins/check_mrtgtraf.c:354
2088msgid "Test average or maximum" 1727msgid "Test average or maximum"
2089msgstr "" 1728msgstr ""
2090 1729
2091#: plugins/check_mrtgtraf.c:356
2092#, fuzzy 1730#, fuzzy
2093msgid "Warning threshold pair <incoming>,<outgoing>" 1731msgid "Warning threshold pair <incoming>,<outgoing>"
2094msgstr "Warning threshold Integer sein" 1732msgstr "Warning threshold Integer sein"
2095 1733
2096#: plugins/check_mrtgtraf.c:358
2097#, fuzzy 1734#, fuzzy
2098msgid "Critical threshold pair <incoming>,<outgoing>" 1735msgid "Critical threshold pair <incoming>,<outgoing>"
2099msgstr "Critical threshold muss ein Integer sein" 1736msgstr "Critical threshold muss ein Integer sein"
2100 1737
2101#: plugins/check_mrtgtraf.c:362
2102msgid "" 1738msgid ""
2103"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from" 1739"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"
2104msgstr "" 1740msgstr ""
2105 1741
2106#: plugins/check_mrtgtraf.c:364
2107msgid "- While MRTG can monitor things other than traffic rates, this" 1742msgid "- While MRTG can monitor things other than traffic rates, this"
2108msgstr "" 1743msgstr ""
2109 1744
2110#: plugins/check_mrtgtraf.c:365
2111msgid " plugin probably won't work with much else without modification." 1745msgid " plugin probably won't work with much else without modification."
2112msgstr "" 1746msgstr ""
2113 1747
2114#: plugins/check_mrtgtraf.c:366
2115msgid "- The calculated i/o rates are a little off from what MRTG actually" 1748msgid "- The calculated i/o rates are a little off from what MRTG actually"
2116msgstr "" 1749msgstr ""
2117 1750
2118#: plugins/check_mrtgtraf.c:367
2119msgid " reports. I'm not sure why this is right now, but will look into it" 1751msgid " reports. I'm not sure why this is right now, but will look into it"
2120msgstr "" 1752msgstr ""
2121 1753
2122#: plugins/check_mrtgtraf.c:368
2123msgid " for future enhancements of this plugin." 1754msgid " for future enhancements of this plugin."
2124msgstr "" 1755msgstr ""
2125 1756
2126#: plugins/check_mrtgtraf.c:378
2127#, c-format 1757#, c-format
2128msgid "Usage" 1758msgid "Usage"
2129msgstr "" 1759msgstr ""
2130 1760
2131#: plugins/check_mysql.c:171
2132#, c-format 1761#, c-format
2133msgid "status store_result error: %s\n" 1762msgid "status store_result error: %s\n"
2134msgstr "" 1763msgstr ""
2135 1764
2136#: plugins/check_mysql.c:202
2137#, c-format 1765#, c-format
2138msgid "slave query error: %s\n" 1766msgid "slave query error: %s\n"
2139msgstr "" 1767msgstr ""
2140 1768
2141#: plugins/check_mysql.c:209
2142#, c-format 1769#, c-format
2143msgid "slave store_result error: %s\n" 1770msgid "slave store_result error: %s\n"
2144msgstr "" 1771msgstr ""
2145 1772
2146#: plugins/check_mysql.c:215
2147msgid "No slaves defined" 1773msgid "No slaves defined"
2148msgstr "" 1774msgstr ""
2149 1775
2150#: plugins/check_mysql.c:223
2151#, c-format 1776#, c-format
2152msgid "slave fetch row error: %s\n" 1777msgid "slave fetch row error: %s\n"
2153msgstr "" 1778msgstr ""
2154 1779
2155#: plugins/check_mysql.c:228
2156#, c-format 1780#, c-format
2157msgid "Slave running: %s" 1781msgid "Slave running: %s"
2158msgstr "" 1782msgstr ""
2159 1783
2160#: plugins/check_mysql.c:505
2161msgid "This program tests connections to a MySQL server" 1784msgid "This program tests connections to a MySQL server"
2162msgstr "" 1785msgstr ""
2163 1786
2164#: plugins/check_mysql.c:516 1787msgid "Ignore authentication failure and check for mysql connectivity only"
1788msgstr ""
1789
2165msgid "Use the specified socket (has no effect if -H is used)" 1790msgid "Use the specified socket (has no effect if -H is used)"
2166msgstr "" 1791msgstr ""
2167 1792
2168#: plugins/check_mysql.c:519
2169msgid "Check database with indicated name" 1793msgid "Check database with indicated name"
2170msgstr "" 1794msgstr ""
2171 1795
2172#: plugins/check_mysql.c:521
2173msgid "Read from the specified client options file" 1796msgid "Read from the specified client options file"
2174msgstr "" 1797msgstr ""
2175 1798
2176#: plugins/check_mysql.c:523
2177msgid "Use a client options group" 1799msgid "Use a client options group"
2178msgstr "" 1800msgstr ""
2179 1801
2180#: plugins/check_mysql.c:525
2181msgid "Connect using the indicated username" 1802msgid "Connect using the indicated username"
2182msgstr "" 1803msgstr ""
2183 1804
2184#: plugins/check_mysql.c:527
2185msgid "Use the indicated password to authenticate the connection" 1805msgid "Use the indicated password to authenticate the connection"
2186msgstr "" 1806msgstr ""
2187 1807
2188#: plugins/check_mysql.c:528
2189msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!" 1808msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"
2190msgstr "" 1809msgstr ""
2191 1810
2192#: plugins/check_mysql.c:529
2193msgid "Your clear-text password could be visible as a process table entry" 1811msgid "Your clear-text password could be visible as a process table entry"
2194msgstr "" 1812msgstr ""
2195 1813
2196#: plugins/check_mysql.c:531
2197msgid "Check if the slave thread is running properly." 1814msgid "Check if the slave thread is running properly."
2198msgstr "" 1815msgstr ""
2199 1816
2200#: plugins/check_mysql.c:533
2201msgid "Exit with WARNING status if slave server is more than INTEGER seconds" 1817msgid "Exit with WARNING status if slave server is more than INTEGER seconds"
2202msgstr "" 1818msgstr ""
2203 1819
2204#: plugins/check_mysql.c:534 plugins/check_mysql.c:537
2205msgid "behind master" 1820msgid "behind master"
2206msgstr "" 1821msgstr ""
2207 1822
2208#: plugins/check_mysql.c:536
2209msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds" 1823msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds"
2210msgstr "" 1824msgstr ""
2211 1825
2212#: plugins/check_mysql.c:539 1826msgid "Use ssl encryption"
2213msgid "Use ssl encryptation"
2214msgstr "" 1827msgstr ""
2215 1828
2216#: plugins/check_mysql.c:541
2217msgid "Path to CA signing the cert" 1829msgid "Path to CA signing the cert"
2218msgstr "" 1830msgstr ""
2219 1831
2220#: plugins/check_mysql.c:543
2221msgid "Path to SSL certificate" 1832msgid "Path to SSL certificate"
2222msgstr "" 1833msgstr ""
2223 1834
2224#: plugins/check_mysql.c:545
2225msgid "Path to private SSL key" 1835msgid "Path to private SSL key"
2226msgstr "" 1836msgstr ""
2227 1837
2228#: plugins/check_mysql.c:547
2229msgid "Path to CA directory" 1838msgid "Path to CA directory"
2230msgstr "" 1839msgstr ""
2231 1840
2232#: plugins/check_mysql.c:549
2233msgid "List of valid SSL ciphers" 1841msgid "List of valid SSL ciphers"
2234msgstr "" 1842msgstr ""
2235 1843
2236#: plugins/check_mysql.c:553
2237msgid "" 1844msgid ""
2238"There are no required arguments. By default, the local database is checked" 1845"There are no required arguments. By default, the local database is checked"
2239msgstr "" 1846msgstr ""
2240 1847
2241#: plugins/check_mysql.c:554
2242msgid "" 1848msgid ""
2243"using the default unix socket. You can force TCP on localhost by using an" 1849"using the default unix socket. You can force TCP on localhost by using an"
2244msgstr "" 1850msgstr ""
2245 1851
2246#: plugins/check_mysql.c:555
2247msgid "IP address or FQDN ('localhost' will use the socket as well)." 1852msgid "IP address or FQDN ('localhost' will use the socket as well)."
2248msgstr "" 1853msgstr ""
2249 1854
2250#: plugins/check_mysql.c:559
2251msgid "You must specify -p with an empty string to force an empty password," 1855msgid "You must specify -p with an empty string to force an empty password,"
2252msgstr "" 1856msgstr ""
2253 1857
2254#: plugins/check_mysql.c:560
2255msgid "overriding any my.cnf settings." 1858msgid "overriding any my.cnf settings."
2256msgstr "" 1859msgstr ""
2257 1860
2258#: plugins/check_nagios.c:104
2259msgid "Cannot open status log for reading!" 1861msgid "Cannot open status log for reading!"
2260msgstr "" 1862msgstr ""
2261 1863
2262#: plugins/check_nagios.c:154
2263#, c-format 1864#, c-format
2264msgid "Found process: %s %s\n" 1865msgid "Found process: %s %s\n"
2265msgstr "" 1866msgstr ""
2266 1867
2267#: plugins/check_nagios.c:168
2268msgid "Could not locate a running Nagios process!" 1868msgid "Could not locate a running Nagios process!"
2269msgstr "" 1869msgstr ""
2270 1870
2271#: plugins/check_nagios.c:172
2272msgid "Cannot parse Nagios log file for valid time" 1871msgid "Cannot parse Nagios log file for valid time"
2273msgstr "" 1872msgstr ""
2274 1873
2275#: plugins/check_nagios.c:183 plugins/check_procs.c:356
2276#, c-format 1874#, c-format
2277msgid "%d process" 1875msgid "%d process"
2278msgid_plural "%d processes" 1876msgid_plural "%d processes"
2279msgstr[0] "" 1877msgstr[0] ""
2280msgstr[1] "" 1878msgstr[1] ""
2281 1879
2282#: plugins/check_nagios.c:186
2283#, c-format 1880#, c-format
2284msgid "status log updated %d second ago" 1881msgid "status log updated %d second ago"
2285msgid_plural "status log updated %d seconds ago" 1882msgid_plural "status log updated %d seconds ago"
2286msgstr[0] "" 1883msgstr[0] ""
2287msgstr[1] "" 1884msgstr[1] ""
2288 1885
2289#: plugins/check_nagios.c:224 plugins/check_nagios.c:253
2290#, fuzzy 1886#, fuzzy
2291msgid "Expiration time must be an integer (seconds)\n" 1887msgid "Expiration time must be an integer (seconds)\n"
2292msgstr "skip lines muss ein Integer sein" 1888msgstr "skip lines muss ein Integer sein"
2293 1889
2294#: plugins/check_nagios.c:260
2295#, fuzzy 1890#, fuzzy
2296msgid "Timeout must be an integer (seconds)\n" 1891msgid "Timeout must be an integer (seconds)\n"
2297msgstr "skip lines muss ein Integer sein" 1892msgstr "skip lines muss ein Integer sein"
2298 1893
2299#: plugins/check_nagios.c:272
2300#, fuzzy 1894#, fuzzy
2301msgid "You must provide the status_log\n" 1895msgid "You must provide the status_log\n"
2302msgstr "%s: Hostname muss angegeben werden\n" 1896msgstr "%s: Hostname muss angegeben werden\n"
2303 1897
2304#: plugins/check_nagios.c:275
2305#, fuzzy 1898#, fuzzy
2306msgid "You must provide a process string\n" 1899msgid "You must provide a process string\n"
2307msgstr "%s: Hostname muss angegeben werden\n" 1900msgstr "%s: Hostname muss angegeben werden\n"
2308 1901
2309#: plugins/check_nagios.c:289
2310#, fuzzy 1902#, fuzzy
2311msgid "" 1903msgid ""
2312"This plugin checks the status of the Nagios process on the local machine" 1904"This plugin checks the status of the Nagios process on the local machine"
2313msgstr "" 1905msgstr ""
2314"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n" 1906"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n"
2315"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 1907"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
2316"unterschritten wird.\n" 1908"unterschritten wird.\n"
2317"\n" 1909"\n"
2318 1910
2319#: plugins/check_nagios.c:290
2320msgid "" 1911msgid ""
2321"The plugin will check to make sure the Nagios status log is no older than" 1912"The plugin will check to make sure the Nagios status log is no older than"
2322msgstr "" 1913msgstr ""
2323 1914
2324#: plugins/check_nagios.c:291
2325msgid "the number of minutes specified by the expires option." 1915msgid "the number of minutes specified by the expires option."
2326msgstr "" 1916msgstr ""
2327 1917
2328#: plugins/check_nagios.c:292
2329msgid "" 1918msgid ""
2330"It also checks the process table for a process matching the command argument." 1919"It also checks the process table for a process matching the command argument."
2331msgstr "" 1920msgstr ""
2332 1921
2333#: plugins/check_nagios.c:302
2334msgid "Name of the log file to check" 1922msgid "Name of the log file to check"
2335msgstr "" 1923msgstr ""
2336 1924
2337#: plugins/check_nagios.c:304
2338msgid "Minutes aging after which logfile is considered stale" 1925msgid "Minutes aging after which logfile is considered stale"
2339msgstr "" 1926msgstr ""
2340 1927
2341#: plugins/check_nagios.c:306
2342msgid "Substring to search for in process arguments" 1928msgid "Substring to search for in process arguments"
2343msgstr "" 1929msgstr ""
2344 1930
2345#: plugins/check_nagios.c:308
2346msgid "Timeout for the plugin in seconds" 1931msgid "Timeout for the plugin in seconds"
2347msgstr "" 1932msgstr ""
2348 1933
2349#: plugins/check_nt.c:142
2350#, c-format 1934#, c-format
2351msgid "Wrong client version - running: %s, required: %s" 1935msgid "Wrong client version - running: %s, required: %s"
2352msgstr "" 1936msgstr ""
2353 1937
2354#: plugins/check_nt.c:153 plugins/check_nt.c:218
2355msgid "missing -l parameters" 1938msgid "missing -l parameters"
2356msgstr "" 1939msgstr ""
2357 1940
2358#: plugins/check_nt.c:155
2359msgid "wrong -l parameter." 1941msgid "wrong -l parameter."
2360msgstr "" 1942msgstr ""
2361 1943
2362#: plugins/check_nt.c:159
2363msgid "CPU Load" 1944msgid "CPU Load"
2364msgstr "" 1945msgstr ""
2365 1946
2366#: plugins/check_nt.c:182
2367#, c-format 1947#, c-format
2368msgid " %lu%% (%lu min average)" 1948msgid " %lu%% (%lu min average)"
2369msgstr "" 1949msgstr ""
2370 1950
2371#: plugins/check_nt.c:184
2372#, c-format 1951#, c-format
2373msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100" 1952msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100"
2374msgstr "" 1953msgstr ""
2375 1954
2376#: plugins/check_nt.c:194
2377msgid "not enough values for -l parameters" 1955msgid "not enough values for -l parameters"
2378msgstr "" 1956msgstr ""
2379 1957
2380#: plugins/check_nt.c:206 1958msgid "wrong -l argument"
2381#, c-format
2382msgid "System Uptime - %u day(s) %u hour(s) %u minute(s)"
2383msgstr "" 1959msgstr ""
2384 1960
2385#: plugins/check_nt.c:220 1961#, c-format
2386msgid "wrong -l argument" 1962msgid "System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"
2387msgstr "" 1963msgstr ""
2388 1964
2389#: plugins/check_nt.c:236
2390#, c-format 1965#, c-format
2391msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)" 1966msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"
2392msgstr "" 1967msgstr ""
2393 1968
2394#: plugins/check_nt.c:239
2395#, c-format 1969#, c-format
2396msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f" 1970msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2397msgstr "" 1971msgstr ""
2398 1972
2399#: plugins/check_nt.c:253
2400msgid "Free disk space : Invalid drive" 1973msgid "Free disk space : Invalid drive"
2401msgstr "" 1974msgstr ""
2402 1975
2403#: plugins/check_nt.c:263
2404msgid "No service/process specified" 1976msgid "No service/process specified"
2405msgstr "" 1977msgstr ""
2406 1978
2407#: plugins/check_nt.c:271 plugins/check_nt.c:284 plugins/check_nt.c:288
2408#: plugins/check_nt.c:622
2409msgid "could not fetch information from server\n" 1979msgid "could not fetch information from server\n"
2410msgstr "" 1980msgstr ""
2411 1981
2412#: plugins/check_nt.c:296
2413#, c-format 1982#, c-format
2414msgid "" 1983msgid ""
2415"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)" 1984"Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"
2416msgstr "" 1985msgstr ""
2417 1986
2418#: plugins/check_nt.c:299
2419#, c-format 1987#, c-format
2420msgid "'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f" 1988msgid "'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"
2421msgstr "" 1989msgstr ""
2422 1990
2423#: plugins/check_nt.c:335 plugins/check_nt.c:420 plugins/check_nt.c:450
2424msgid "No counter specified" 1991msgid "No counter specified"
2425msgstr "" 1992msgstr ""
2426 1993
2427#: plugins/check_nt.c:367
2428msgid "Minimum value contains non-numbers" 1994msgid "Minimum value contains non-numbers"
2429msgstr "" 1995msgstr ""
2430 1996
2431#: plugins/check_nt.c:371
2432msgid "Maximum value contains non-numbers" 1997msgid "Maximum value contains non-numbers"
2433msgstr "" 1998msgstr ""
2434 1999
2435#: plugins/check_nt.c:378
2436msgid "No unit counter specified" 2000msgid "No unit counter specified"
2437msgstr "" 2001msgstr ""
2438 2002
2439#: plugins/check_nt.c:465
2440msgid "Please specify a variable to check" 2003msgid "Please specify a variable to check"
2441msgstr "" 2004msgstr ""
2442 2005
2443#: plugins/check_nt.c:549
2444#, fuzzy 2006#, fuzzy
2445msgid "Server port must be an integer\n" 2007msgid "Server port must be an integer\n"
2446msgstr "skip lines muss ein Integer sein" 2008msgstr "skip lines muss ein Integer sein"
2447 2009
2448#: plugins/check_nt.c:603
2449#, fuzzy 2010#, fuzzy
2450msgid "You must provide a server address or host name" 2011msgid "You must provide a server address or host name"
2451msgstr "Hostname oder Serveradresse muss angegeben werden" 2012msgstr "Hostname oder Serveradresse muss angegeben werden"
2452 2013
2453#: plugins/check_nt.c:609
2454msgid "None" 2014msgid "None"
2455msgstr "" 2015msgstr ""
2456 2016
2457#: plugins/check_nt.c:666
2458msgid "This plugin collects data from the NSClient service running on a" 2017msgid "This plugin collects data from the NSClient service running on a"
2459msgstr "" 2018msgstr ""
2460 2019
2461#: plugins/check_nt.c:667
2462msgid "Windows NT/2000/XP/2003 server." 2020msgid "Windows NT/2000/XP/2003 server."
2463msgstr "" 2021msgstr ""
2464 2022
2465#: plugins/check_nt.c:678
2466msgid "Name of the host to check" 2023msgid "Name of the host to check"
2467msgstr "" 2024msgstr ""
2468 2025
2469#: plugins/check_nt.c:680
2470#, fuzzy 2026#, fuzzy
2471msgid "Optional port number (default: " 2027msgid "Optional port number (default: "
2472msgstr "Ungültige Portnummer" 2028msgstr "Ungültige Portnummer"
2473 2029
2474#: plugins/check_nt.c:683
2475msgid "Password needed for the request" 2030msgid "Password needed for the request"
2476msgstr "" 2031msgstr ""
2477 2032
2478#: plugins/check_nt.c:685 plugins/check_nwstat.c:1661
2479#: plugins/check_overcr.c:432
2480msgid "Threshold which will result in a warning status" 2033msgid "Threshold which will result in a warning status"
2481msgstr "" 2034msgstr ""
2482 2035
2483#: plugins/check_nt.c:687 plugins/check_nwstat.c:1663
2484#: plugins/check_overcr.c:434
2485msgid "Threshold which will result in a critical status" 2036msgid "Threshold which will result in a critical status"
2486msgstr "" 2037msgstr ""
2487 2038
2488#: plugins/check_nt.c:689
2489msgid "Seconds before connection attempt times out (default: " 2039msgid "Seconds before connection attempt times out (default: "
2490msgstr "" 2040msgstr ""
2491 2041
2492#: plugins/check_nt.c:691
2493msgid "Parameters passed to specified check (see below)" 2042msgid "Parameters passed to specified check (see below)"
2494msgstr "" 2043msgstr ""
2495 2044
2496#: plugins/check_nt.c:693
2497msgid "Display options (currently only SHOWALL works)" 2045msgid "Display options (currently only SHOWALL works)"
2498msgstr "" 2046msgstr ""
2499 2047
2500#: plugins/check_nt.c:695
2501msgid "Return UNKNOWN on timeouts" 2048msgid "Return UNKNOWN on timeouts"
2502msgstr "" 2049msgstr ""
2503 2050
2504#: plugins/check_nt.c:698
2505msgid "Print this help screen" 2051msgid "Print this help screen"
2506msgstr "" 2052msgstr ""
2507 2053
2508#: plugins/check_nt.c:700
2509msgid "Print version information" 2054msgid "Print version information"
2510msgstr "" 2055msgstr ""
2511 2056
2512#: plugins/check_nt.c:702
2513msgid "Variable to check" 2057msgid "Variable to check"
2514msgstr "" 2058msgstr ""
2515 2059
2516#: plugins/check_nt.c:703
2517msgid "Valid variables are:" 2060msgid "Valid variables are:"
2518msgstr "" 2061msgstr ""
2519 2062
2520#: plugins/check_nt.c:705
2521msgid "Get the NSClient version" 2063msgid "Get the NSClient version"
2522msgstr "" 2064msgstr ""
2523 2065
2524#: plugins/check_nt.c:706
2525msgid "If -l <version> is specified, will return warning if versions differ." 2066msgid "If -l <version> is specified, will return warning if versions differ."
2526msgstr "" 2067msgstr ""
2527 2068
2528#: plugins/check_nt.c:708
2529msgid "Average CPU load on last x minutes." 2069msgid "Average CPU load on last x minutes."
2530msgstr "" 2070msgstr ""
2531 2071
2532#: plugins/check_nt.c:709
2533msgid "Request a -l parameter with the following syntax:" 2072msgid "Request a -l parameter with the following syntax:"
2534msgstr "" 2073msgstr ""
2535 2074
2536#: plugins/check_nt.c:710
2537msgid "-l <minutes range>,<warning threshold>,<critical threshold>." 2075msgid "-l <minutes range>,<warning threshold>,<critical threshold>."
2538msgstr "" 2076msgstr ""
2539 2077
2540#: plugins/check_nt.c:711
2541msgid "<minute range> should be less than 24*60." 2078msgid "<minute range> should be less than 24*60."
2542msgstr "" 2079msgstr ""
2543 2080
2544#: plugins/check_nt.c:712
2545msgid "" 2081msgid ""
2546"Thresholds are percentage and up to 10 requests can be done in one shot." 2082"Thresholds are percentage and up to 10 requests can be done in one shot."
2547msgstr "" 2083msgstr ""
2548 2084
2549#: plugins/check_nt.c:715
2550msgid "Get the uptime of the machine." 2085msgid "Get the uptime of the machine."
2551msgstr "" 2086msgstr ""
2552 2087
2553#: plugins/check_nt.c:716 2088msgid "-l <unit> "
2554msgid "No specific parameters. No warning or critical threshold" 2089msgstr ""
2090
2091msgid "<unit> = seconds, minutes, hours, or days. (default: minutes)"
2555msgstr "" 2092msgstr ""
2556 2093
2557#: plugins/check_nt.c:718 2094#, fuzzy
2095msgid "Thresholds will use the unit specified above."
2096msgstr ""
2097"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2098"\n"
2099
2558msgid "Size and percentage of disk use." 2100msgid "Size and percentage of disk use."
2559msgstr "" 2101msgstr ""
2560 2102
2561#: plugins/check_nt.c:719
2562msgid "Request a -l parameter containing the drive letter only." 2103msgid "Request a -l parameter containing the drive letter only."
2563msgstr "" 2104msgstr ""
2564 2105
2565#: plugins/check_nt.c:720 plugins/check_nt.c:723
2566msgid "Warning and critical thresholds can be specified with -w and -c." 2106msgid "Warning and critical thresholds can be specified with -w and -c."
2567msgstr "" 2107msgstr ""
2568 2108
2569#: plugins/check_nt.c:722
2570msgid "Memory use." 2109msgid "Memory use."
2571msgstr "" 2110msgstr ""
2572 2111
2573#: plugins/check_nt.c:725
2574msgid "Check the state of one or several services." 2112msgid "Check the state of one or several services."
2575msgstr "" 2113msgstr ""
2576 2114
2577#: plugins/check_nt.c:726 plugins/check_nt.c:735
2578msgid "Request a -l parameters with the following syntax:" 2115msgid "Request a -l parameters with the following syntax:"
2579msgstr "" 2116msgstr ""
2580 2117
2581#: plugins/check_nt.c:727
2582msgid "-l <service1>,<service2>,<service3>,..." 2118msgid "-l <service1>,<service2>,<service3>,..."
2583msgstr "" 2119msgstr ""
2584 2120
2585#: plugins/check_nt.c:728
2586msgid "You can specify -d SHOWALL in case you want to see working services" 2121msgid "You can specify -d SHOWALL in case you want to see working services"
2587msgstr "" 2122msgstr ""
2588 2123
2589#: plugins/check_nt.c:729
2590msgid "in the returned string." 2124msgid "in the returned string."
2591msgstr "" 2125msgstr ""
2592 2126
2593#: plugins/check_nt.c:731
2594msgid "Check if one or several process are running." 2127msgid "Check if one or several process are running."
2595msgstr "" 2128msgstr ""
2596 2129
2597#: plugins/check_nt.c:732
2598msgid "Same syntax as SERVICESTATE." 2130msgid "Same syntax as SERVICESTATE."
2599msgstr "" 2131msgstr ""
2600 2132
2601#: plugins/check_nt.c:734
2602msgid "Check any performance counter of Windows NT/2000." 2133msgid "Check any performance counter of Windows NT/2000."
2603msgstr "" 2134msgstr ""
2604 2135
2605#: plugins/check_nt.c:736
2606msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>" 2136msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>"
2607msgstr "" 2137msgstr ""
2608 2138
2609#: plugins/check_nt.c:737
2610msgid "The <description> parameter is optional and is given to a printf " 2139msgid "The <description> parameter is optional and is given to a printf "
2611msgstr "" 2140msgstr ""
2612 2141
2613#: plugins/check_nt.c:738
2614msgid "output command which requires a float parameter." 2142msgid "output command which requires a float parameter."
2615msgstr "" 2143msgstr ""
2616 2144
2617#: plugins/check_nt.c:739
2618#, c-format 2145#, c-format
2619msgid "If <description> does not include \"%%\", it is used as a label." 2146msgid "If <description> does not include \"%%\", it is used as a label."
2620msgstr "" 2147msgstr ""
2621 2148
2622#: plugins/check_nt.c:740 plugins/check_nt.c:755
2623msgid "Some examples:" 2149msgid "Some examples:"
2624msgstr "" 2150msgstr ""
2625 2151
2626#: plugins/check_nt.c:744
2627msgid "Check any performance counter object of Windows NT/2000." 2152msgid "Check any performance counter object of Windows NT/2000."
2628msgstr "" 2153msgstr ""
2629 2154
2630#: plugins/check_nt.c:745
2631msgid "" 2155msgid ""
2632"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>" 2156"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"
2633msgstr "" 2157msgstr ""
2634 2158
2635#: plugins/check_nt.c:746
2636msgid "<counter object> is a Windows Perfmon Counter object (eg. Process)," 2159msgid "<counter object> is a Windows Perfmon Counter object (eg. Process),"
2637msgstr "" 2160msgstr ""
2638 2161
2639#: plugins/check_nt.c:747
2640msgid "if it is two words, it should be enclosed in quotes" 2162msgid "if it is two words, it should be enclosed in quotes"
2641msgstr "" 2163msgstr ""
2642 2164
2643#: plugins/check_nt.c:748
2644msgid "The returned results will be a comma-separated list of instances on " 2165msgid "The returned results will be a comma-separated list of instances on "
2645msgstr "" 2166msgstr ""
2646 2167
2647#: plugins/check_nt.c:749
2648msgid " the selected computer for that object." 2168msgid " the selected computer for that object."
2649msgstr "" 2169msgstr ""
2650 2170
2651#: plugins/check_nt.c:750
2652msgid "" 2171msgid ""
2653"The purpose of this is to be run from command line to determine what " 2172"The purpose of this is to be run from command line to determine what "
2654"instances" 2173"instances"
2655msgstr "" 2174msgstr ""
2656 2175
2657#: plugins/check_nt.c:751
2658msgid "" 2176msgid ""
2659" are available for monitoring without having to log onto the Windows server" 2177" are available for monitoring without having to log onto the Windows server"
2660msgstr "" 2178msgstr ""
2661 2179
2662#: plugins/check_nt.c:752
2663msgid " to run Perfmon directly." 2180msgid " to run Perfmon directly."
2664msgstr "" 2181msgstr ""
2665 2182
2666#: plugins/check_nt.c:753
2667msgid "" 2183msgid ""
2668"It can also be used in scripts that automatically create the monitoring " 2184"It can also be used in scripts that automatically create the monitoring "
2669"service" 2185"service"
2670msgstr "" 2186msgstr ""
2671 2187
2672#: plugins/check_nt.c:754
2673msgid " configuration files." 2188msgid " configuration files."
2674msgstr "" 2189msgstr ""
2675 2190
2676#: plugins/check_nt.c:756
2677msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process" 2191msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"
2678msgstr "" 2192msgstr ""
2679 2193
2680#: plugins/check_nt.c:759
2681msgid "" 2194msgid ""
2682"- The NSClient service should be running on the server to get any information" 2195"- The NSClient service should be running on the server to get any information"
2683msgstr "" 2196msgstr ""
2684 2197
2685#: plugins/check_nt.c:761
2686msgid "- Critical thresholds should be lower than warning thresholds" 2198msgid "- Critical thresholds should be lower than warning thresholds"
2687msgstr "" 2199msgstr ""
2688 2200
2689#: plugins/check_nt.c:762
2690msgid "- Default port 1248 is sometimes in use by other services. The error" 2201msgid "- Default port 1248 is sometimes in use by other services. The error"
2691msgstr "" 2202msgstr ""
2692 2203
2693#: plugins/check_nt.c:763
2694msgid "" 2204msgid ""
2695"output when this happens contains \"Cannot map xxxxx to protocol number\"." 2205"output when this happens contains \"Cannot map xxxxx to protocol number\"."
2696msgstr "" 2206msgstr ""
2697 2207
2698#: plugins/check_nt.c:764
2699msgid "One fix for this is to change the port to something else on check_nt " 2208msgid "One fix for this is to change the port to something else on check_nt "
2700msgstr "" 2209msgstr ""
2701 2210
2702#: plugins/check_nt.c:765
2703msgid "and on the client service it's connecting to." 2211msgid "and on the client service it's connecting to."
2704msgstr "" 2212msgstr ""
2705 2213
2706#: plugins/check_ntp.c:807 plugins/check_ntp_peer.c:612 2214#, c-format
2707#: plugins/check_ntp_time.c:571 2215msgid "jitter response too large (%lu bytes)\n"
2216msgstr ""
2217
2708msgid "NTP CRITICAL:" 2218msgid "NTP CRITICAL:"
2709msgstr "NTP CRITICAL:" 2219msgstr "NTP CRITICAL:"
2710 2220
2711#: plugins/check_ntp.c:810 plugins/check_ntp_peer.c:615
2712#: plugins/check_ntp_time.c:574
2713msgid "NTP WARNING:" 2221msgid "NTP WARNING:"
2714msgstr "NTP WARNING:" 2222msgstr "NTP WARNING:"
2715 2223
2716#: plugins/check_ntp.c:813 plugins/check_ntp_peer.c:618
2717#: plugins/check_ntp_time.c:577
2718msgid "NTP OK:" 2224msgid "NTP OK:"
2719msgstr "NTP OK:" 2225msgstr "NTP OK:"
2720 2226
2721#: plugins/check_ntp.c:816 plugins/check_ntp_peer.c:621
2722#: plugins/check_ntp_time.c:580
2723msgid "NTP UNKNOWN:" 2227msgid "NTP UNKNOWN:"
2724msgstr "NTP UNKNOWN:" 2228msgstr "NTP UNKNOWN:"
2725 2229
2726#: plugins/check_ntp.c:820 plugins/check_ntp_peer.c:630
2727#: plugins/check_ntp_time.c:584
2728msgid "Offset unknown" 2230msgid "Offset unknown"
2729msgstr "" 2231msgstr ""
2730 2232
2731#: plugins/check_ntp.c:823 plugins/check_ntp_peer.c:633
2732#: plugins/check_ntp_time.c:587
2733msgid "Offset" 2233msgid "Offset"
2734msgstr "" 2234msgstr ""
2735 2235
2736#: plugins/check_ntp.c:844 plugins/check_ntp_peer.c:662
2737#, fuzzy 2236#, fuzzy
2738msgid "This plugin checks the selected ntp server" 2237msgid "This plugin checks the selected ntp server"
2739msgstr "" 2238msgstr ""
2740"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 2239"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2741"\n" 2240"\n"
2742 2241
2743#: plugins/check_ntp.c:854 plugins/check_ntp_peer.c:674
2744#: plugins/check_ntp_time.c:614
2745msgid "Offset to result in warning status (seconds)" 2242msgid "Offset to result in warning status (seconds)"
2746msgstr "" 2243msgstr ""
2747 2244
2748#: plugins/check_ntp.c:856 plugins/check_ntp_peer.c:676
2749#: plugins/check_ntp_time.c:616
2750msgid "Offset to result in critical status (seconds)" 2245msgid "Offset to result in critical status (seconds)"
2751msgstr "" 2246msgstr ""
2752 2247
2753#: plugins/check_ntp.c:858 plugins/check_ntp_peer.c:682
2754#, fuzzy 2248#, fuzzy
2755msgid "Warning threshold for jitter" 2249msgid "Warning threshold for jitter"
2756msgstr "Warning threshold Integer sein" 2250msgstr "Warning threshold Integer sein"
2757 2251
2758#: plugins/check_ntp.c:860 plugins/check_ntp_peer.c:684
2759#, fuzzy 2252#, fuzzy
2760msgid "Critical threshold for jitter" 2253msgid "Critical threshold for jitter"
2761msgstr "Critical threshold muss ein Integer sein" 2254msgstr "Critical threshold muss ein Integer sein"
2762 2255
2763#: plugins/check_ntp.c:870
2764msgid "Normal offset check:" 2256msgid "Normal offset check:"
2765msgstr "" 2257msgstr ""
2766 2258
2767#: plugins/check_ntp.c:873 plugins/check_ntp_peer.c:709
2768msgid "" 2259msgid ""
2769"Check jitter too, avoiding critical notifications if jitter isn't available" 2260"Check jitter too, avoiding critical notifications if jitter isn't available"
2770msgstr "" 2261msgstr ""
2771 2262
2772#: plugins/check_ntp.c:874 plugins/check_ntp_peer.c:710
2773msgid "(See Notes above for more details on thresholds formats):" 2263msgid "(See Notes above for more details on thresholds formats):"
2774msgstr "" 2264msgstr ""
2775 2265
2776#: plugins/check_ntp.c:879 plugins/check_ntp.c:886
2777msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or" 2266msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or"
2778msgstr "" 2267msgstr ""
2779 2268
2780#: plugins/check_ntp.c:880 plugins/check_ntp.c:887
2781msgid "check_ntp_time instead." 2269msgid "check_ntp_time instead."
2782msgstr "" 2270msgstr ""
2783 2271
2784#: plugins/check_ntp_peer.c:625
2785msgid "Server not synchronized" 2272msgid "Server not synchronized"
2786msgstr "" 2273msgstr ""
2787 2274
2788#: plugins/check_ntp_peer.c:627
2789msgid "Server has the LI_ALARM bit set" 2275msgid "Server has the LI_ALARM bit set"
2790msgstr "" 2276msgstr ""
2791 2277
2792#: plugins/check_ntp_peer.c:672
2793msgid "" 2278msgid ""
2794"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized" 2279"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"
2795msgstr "" 2280msgstr ""
2796 2281
2797#: plugins/check_ntp_peer.c:678
2798#, fuzzy 2282#, fuzzy
2799msgid "Warning threshold for stratum of server's synchronization peer" 2283msgid "Warning threshold for stratum of server's synchronization peer"
2800msgstr "Warning threshold Integer sein" 2284msgstr "Warning threshold Integer sein"
2801 2285
2802#: plugins/check_ntp_peer.c:680
2803#, fuzzy 2286#, fuzzy
2804msgid "Critical threshold for stratum of server's synchronization peer" 2287msgid "Critical threshold for stratum of server's synchronization peer"
2805msgstr "Critical threshold muss ein Integer sein" 2288msgstr "Critical threshold muss ein Integer sein"
2806 2289
2807#: plugins/check_ntp_peer.c:686
2808#, fuzzy 2290#, fuzzy
2809msgid "Warning threshold for number of usable time sources (\"truechimers\")" 2291msgid "Warning threshold for number of usable time sources (\"truechimers\")"
2810msgstr "Warning threshold muss ein positiver Integer sein\n" 2292msgstr "Warning threshold muss ein positiver Integer sein\n"
2811 2293
2812#: plugins/check_ntp_peer.c:688
2813#, fuzzy 2294#, fuzzy
2814msgid "Critical threshold for number of usable time sources (\"truechimers\")" 2295msgid "Critical threshold for number of usable time sources (\"truechimers\")"
2815msgstr "Critical threshold muss ein positiver Integer sein\n" 2296msgstr "Critical threshold muss ein positiver Integer sein\n"
2816 2297
2817#: plugins/check_ntp_peer.c:693
2818msgid "This plugin checks an NTP server independent of any commandline" 2298msgid "This plugin checks an NTP server independent of any commandline"
2819msgstr "" 2299msgstr ""
2820 2300
2821#: plugins/check_ntp_peer.c:694
2822msgid "programs or external libraries." 2301msgid "programs or external libraries."
2823msgstr "" 2302msgstr ""
2824 2303
2825#: plugins/check_ntp_peer.c:697
2826#, fuzzy 2304#, fuzzy
2827msgid "Use this plugin to check the health of an NTP server. It supports" 2305msgid "Use this plugin to check the health of an NTP server. It supports"
2828msgstr "" 2306msgstr ""
2829"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 2307"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2830"\n" 2308"\n"
2831 2309
2832#: plugins/check_ntp_peer.c:698
2833msgid "checking the offset with the sync peer, the jitter and stratum. This" 2310msgid "checking the offset with the sync peer, the jitter and stratum. This"
2834msgstr "" 2311msgstr ""
2835 2312
2836#: plugins/check_ntp_peer.c:699
2837msgid "plugin will not check the clock offset between the local host and NTP" 2313msgid "plugin will not check the clock offset between the local host and NTP"
2838msgstr "" 2314msgstr ""
2839 2315
2840#: plugins/check_ntp_peer.c:700
2841msgid "server; please use check_ntp_time for that purpose." 2316msgid "server; please use check_ntp_time for that purpose."
2842msgstr "" 2317msgstr ""
2843 2318
2844#: plugins/check_ntp_peer.c:706
2845msgid "Simple NTP server check:" 2319msgid "Simple NTP server check:"
2846msgstr "" 2320msgstr ""
2847 2321
2848#: plugins/check_ntp_peer.c:713
2849msgid "Only check the number of usable time sources (\"truechimers\"):" 2322msgid "Only check the number of usable time sources (\"truechimers\"):"
2850msgstr "" 2323msgstr ""
2851 2324
2852#: plugins/check_ntp_peer.c:716
2853msgid "Check only stratum:" 2325msgid "Check only stratum:"
2854msgstr "" 2326msgstr ""
2855 2327
2856#: plugins/check_ntp_time.c:602
2857#, fuzzy 2328#, fuzzy
2858msgid "This plugin checks the clock offset with the ntp server" 2329msgid "This plugin checks the clock offset with the ntp server"
2859msgstr "" 2330msgstr ""
2860"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 2331"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
2861"\n" 2332"\n"
2862 2333
2863#: plugins/check_ntp_time.c:612
2864msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found" 2334msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found"
2865msgstr "" 2335msgstr ""
2866 2336
2867#: plugins/check_ntp_time.c:621 2337msgid "Expected offset of the ntp server relative to local server (seconds)"
2338msgstr ""
2339
2868#, fuzzy 2340#, fuzzy
2869msgid "This plugin checks the clock offset between the local host and a" 2341msgid "This plugin checks the clock offset between the local host and a"
2870msgstr "" 2342msgstr ""
2871"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n" 2343"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n"
2872"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 2344"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
2873"unterschritten wird.\n" 2345"unterschritten wird.\n"
2874"\n" 2346"\n"
2875 2347
2876#: plugins/check_ntp_time.c:622
2877msgid "remote NTP server. It is independent of any commandline programs or" 2348msgid "remote NTP server. It is independent of any commandline programs or"
2878msgstr "" 2349msgstr ""
2879 2350
2880#: plugins/check_ntp_time.c:623
2881msgid "external libraries." 2351msgid "external libraries."
2882msgstr "" 2352msgstr ""
2883 2353
2884#: plugins/check_ntp_time.c:627
2885msgid "If you'd rather want to monitor an NTP server, please use" 2354msgid "If you'd rather want to monitor an NTP server, please use"
2886msgstr "" 2355msgstr ""
2887 2356
2888#: plugins/check_ntp_time.c:628
2889msgid "check_ntp_peer." 2357msgid "check_ntp_peer."
2890msgstr "" 2358msgstr ""
2891 2359
2892#: plugins/check_nwstat.c:194 2360msgid "--time-offset is useful for compensating for servers with known"
2361msgstr ""
2362
2363msgid "and expected clock skew."
2364msgstr ""
2365
2893#, c-format 2366#, c-format
2894msgid "NetWare %s: " 2367msgid "NetWare %s: "
2895msgstr "" 2368msgstr ""
2896 2369
2897#: plugins/check_nwstat.c:232
2898#, c-format 2370#, c-format
2899msgid "Up %s," 2371msgid "Up %s,"
2900msgstr "" 2372msgstr ""
2901 2373
2902#: plugins/check_nwstat.c:240
2903#, c-format 2374#, c-format
2904msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100" 2375msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"
2905msgstr "" 2376msgstr ""
2906 2377
2907#: plugins/check_nwstat.c:268
2908#, c-format 2378#, c-format
2909msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;" 2379msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"
2910msgstr "" 2380msgstr ""
2911 2381
2912#: plugins/check_nwstat.c:293
2913#, c-format 2382#, c-format
2914msgid "%s: Long term cache hits = %lu%%" 2383msgid "%s: Long term cache hits = %lu%%"
2915msgstr "" 2384msgstr ""
2916 2385
2917#: plugins/check_nwstat.c:315
2918#, c-format 2386#, c-format
2919msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;" 2387msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"
2920msgstr "" 2388msgstr ""
2921 2389
2922#: plugins/check_nwstat.c:340
2923#, c-format 2390#, c-format
2924msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;" 2391msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"
2925msgstr "" 2392msgstr ""
2926 2393
2927#: plugins/check_nwstat.c:365
2928#, c-format 2394#, c-format
2929msgid "%s: LRU sitting time = %lu minutes" 2395msgid "%s: LRU sitting time = %lu minutes"
2930msgstr "" 2396msgstr ""
2931 2397
2932#: plugins/check_nwstat.c:382 plugins/check_nwstat.c:410
2933#: plugins/check_nwstat.c:437 plugins/check_nwstat.c:470
2934#: plugins/check_nwstat.c:650 plugins/check_nwstat.c:676
2935#: plugins/check_nwstat.c:707 plugins/check_nwstat.c:753
2936#: plugins/check_nwstat.c:777
2937#, c-format 2398#, c-format
2938msgid "CRITICAL - Volume '%s' does not exist!" 2399msgid "CRITICAL - Volume '%s' does not exist!"
2939msgstr "" 2400msgstr ""
2940 2401
2941#: plugins/check_nwstat.c:391
2942#, c-format 2402#, c-format
2943msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;" 2403msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"
2944msgstr "" 2404msgstr ""
2945 2405
2946#: plugins/check_nwstat.c:392 plugins/check_nwstat.c:420
2947#: plugins/check_nwstat.c:447 plugins/check_nwstat.c:659
2948#: plugins/check_nwstat.c:685 plugins/check_nwstat.c:761
2949msgid "Only " 2406msgid "Only "
2950msgstr "" 2407msgstr ""
2951 2408
2952#: plugins/check_nwstat.c:419
2953#, c-format 2409#, c-format
2954msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;" 2410msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"
2955msgstr "" 2411msgstr ""
2956 2412
2957#: plugins/check_nwstat.c:446
2958#, c-format 2413#, c-format
2959msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;" 2414msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"
2960msgstr "" 2415msgstr ""
2961 2416
2962#: plugins/check_nwstat.c:494
2963#, c-format 2417#, c-format
2964msgid "" 2418msgid ""
2965"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100" 2419"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"
2966msgstr "" 2420msgstr ""
2967 2421
2968#: plugins/check_nwstat.c:528
2969#, c-format 2422#, c-format
2970msgid "Directory Services Database is %s (DS version %s)" 2423msgid "Directory Services Database is %s (DS version %s)"
2971msgstr "" 2424msgstr ""
2972 2425
2973#: plugins/check_nwstat.c:545
2974#, c-format 2426#, c-format
2975msgid "Logins are %s" 2427msgid "Logins are %s"
2976msgstr "" 2428msgstr ""
2977 2429
2978#: plugins/check_nwstat.c:545
2979msgid "enabled" 2430msgid "enabled"
2980msgstr "" 2431msgstr ""
2981 2432
2982#: plugins/check_nwstat.c:545
2983msgid "disabled" 2433msgid "disabled"
2984msgstr "" 2434msgstr ""
2985 2435
2986#: plugins/check_nwstat.c:560
2987#, fuzzy 2436#, fuzzy
2988msgid "CRITICAL - NRM Status is bad!" 2437msgid "CRITICAL - NRM Status is bad!"
2989msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 2438msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
2990 2439
2991#: plugins/check_nwstat.c:565
2992msgid "Warning - NRM Status is suspect!" 2440msgid "Warning - NRM Status is suspect!"
2993msgstr "" 2441msgstr ""
2994 2442
2995#: plugins/check_nwstat.c:568
2996msgid "OK - NRM Status is good!" 2443msgid "OK - NRM Status is good!"
2997msgstr "" 2444msgstr ""
2998 2445
2999#: plugins/check_nwstat.c:610
3000#, c-format 2446#, c-format
3001msgid "%lu of %lu (%lu%%) packet receive buffers used" 2447msgid "%lu of %lu (%lu%%) packet receive buffers used"
3002msgstr "" 2448msgstr ""
3003 2449
3004#: plugins/check_nwstat.c:634
3005#, c-format 2450#, c-format
3006msgid "%lu entries in SAP table" 2451msgid "%lu entries in SAP table"
3007msgstr "" 2452msgstr ""
3008 2453
3009#: plugins/check_nwstat.c:636
3010#, c-format 2454#, c-format
3011msgid "%lu entries in SAP table for SAP type %d" 2455msgid "%lu entries in SAP table for SAP type %d"
3012msgstr "" 2456msgstr ""
3013 2457
3014#: plugins/check_nwstat.c:658
3015#, c-format 2458#, c-format
3016msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2459msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3017msgstr "" 2460msgstr ""
3018 2461
3019#: plugins/check_nwstat.c:684
3020#, c-format 2462#, c-format
3021msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2463msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3022msgstr "" 2464msgstr ""
3023 2465
3024#: plugins/check_nwstat.c:730
3025#, c-format 2466#, c-format
3026msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100" 2467msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"
3027msgstr "" 2468msgstr ""
3028 2469
3029#: plugins/check_nwstat.c:761
3030#, c-format 2470#, c-format
3031msgid "%s%lu KB not yet purgeable on volume %s" 2471msgid "%s%lu KB not yet purgeable on volume %s"
3032msgstr "" 2472msgstr ""
3033 2473
3034#: plugins/check_nwstat.c:800
3035#, c-format 2474#, c-format
3036msgid "%lu MB (%lu%%) not yet purgeable on volume %s" 2475msgid "%lu MB (%lu%%) not yet purgeable on volume %s"
3037msgstr "" 2476msgstr ""
3038 2477
3039#: plugins/check_nwstat.c:821
3040#, c-format 2478#, c-format
3041msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0" 2479msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0"
3042msgstr "" 2480msgstr ""
3043 2481
3044#: plugins/check_nwstat.c:846
3045#, c-format 2482#, c-format
3046msgid "%lu abended threads|Abends=%lu;%lu;%lu;;" 2483msgid "%lu abended threads|Abends=%lu;%lu;%lu;;"
3047msgstr "" 2484msgstr ""
3048 2485
3049#: plugins/check_nwstat.c:881
3050#, c-format 2486#, c-format
3051msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu" 2487msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"
3052msgstr "" 2488msgstr ""
3053 2489
3054#: plugins/check_nwstat.c:904
3055msgid "CRITICAL - Time not in sync with network!" 2490msgid "CRITICAL - Time not in sync with network!"
3056msgstr "" 2491msgstr ""
3057 2492
3058#: plugins/check_nwstat.c:907
3059msgid "OK - Time in sync with network!" 2493msgid "OK - Time in sync with network!"
3060msgstr "" 2494msgstr ""
3061 2495
3062#: plugins/check_nwstat.c:930
3063#, c-format 2496#, c-format
3064msgid "LRU sitting time = %lu seconds" 2497msgid "LRU sitting time = %lu seconds"
3065msgstr "" 2498msgstr ""
3066 2499
3067#: plugins/check_nwstat.c:949
3068#, c-format 2500#, c-format
3069msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100" 2501msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"
3070msgstr "" 2502msgstr ""
3071 2503
3072#: plugins/check_nwstat.c:971
3073#, c-format 2504#, c-format
3074msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100" 2505msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"
3075msgstr "" 2506msgstr ""
3076 2507
3077#: plugins/check_nwstat.c:989
3078#, c-format 2508#, c-format
3079msgid "NDS Version %s" 2509msgid "NDS Version %s"
3080msgstr "" 2510msgstr ""
3081 2511
3082#: plugins/check_nwstat.c:1005
3083#, c-format 2512#, c-format
3084msgid "Up %s" 2513msgid "Up %s"
3085msgstr "" 2514msgstr ""
3086 2515
3087#: plugins/check_nwstat.c:1019
3088#, c-format 2516#, c-format
3089msgid "Module %s version %s is loaded" 2517msgid "Module %s version %s is loaded"
3090msgstr "" 2518msgstr ""
3091 2519
3092#: plugins/check_nwstat.c:1022
3093#, c-format 2520#, c-format
3094msgid "Module %s is not loaded" 2521msgid "Module %s is not loaded"
3095msgstr "" 2522msgstr ""
3096 2523
3097#: plugins/check_nwstat.c:1033 plugins/check_nwstat.c:1059
3098#: plugins/check_nwstat.c:1085 plugins/check_nwstat.c:1111
3099#: plugins/check_nwstat.c:1137 plugins/check_nwstat.c:1163
3100#: plugins/check_nwstat.c:1189 plugins/check_nwstat.c:1215
3101#: plugins/check_nwstat.c:1241 plugins/check_nwstat.c:1267
3102#, fuzzy, c-format 2524#, fuzzy, c-format
3103msgid "CRITICAL - Value '%s' does not exist!" 2525msgid "CRITICAL - Value '%s' does not exist!"
3104msgstr "%s [%s nicht gefunden]" 2526msgstr "%s [%s nicht gefunden]"
3105 2527
3106#: plugins/check_nwstat.c:1042 plugins/check_nwstat.c:1068
3107#: plugins/check_nwstat.c:1094 plugins/check_nwstat.c:1120
3108#: plugins/check_nwstat.c:1146 plugins/check_nwstat.c:1172
3109#: plugins/check_nwstat.c:1198 plugins/check_nwstat.c:1224
3110#: plugins/check_nwstat.c:1250 plugins/check_nwstat.c:1276
3111#, c-format 2528#, c-format
3112msgid "%s is %lu|%s=%lu;%lu;%lu;;" 2529msgid "%s is %lu|%s=%lu;%lu;%lu;;"
3113msgstr "" 2530msgstr ""
3114 2531
3115#: plugins/check_nwstat.c:1289 plugins/check_overcr.c:285
3116msgid "Nothing to check!\n" 2532msgid "Nothing to check!\n"
3117msgstr "" 2533msgstr ""
3118 2534
3119#: plugins/check_nwstat.c:1371 plugins/check_overcr.c:355
3120#, fuzzy 2535#, fuzzy
3121msgid "Server port an integer\n" 2536msgid "Server port an integer\n"
3122msgstr "skip lines muss ein Integer sein" 2537msgstr "skip lines muss ein Integer sein"
3123 2538
3124#: plugins/check_nwstat.c:1601
3125msgid "This plugin attempts to contact the MRTGEXT NLM running on a" 2539msgid "This plugin attempts to contact the MRTGEXT NLM running on a"
3126msgstr "" 2540msgstr ""
3127 2541
3128#: plugins/check_nwstat.c:1602
3129msgid "Novell server to gather the requested system information." 2542msgid "Novell server to gather the requested system information."
3130msgstr "" 2543msgstr ""
3131 2544
3132#: plugins/check_nwstat.c:1614 plugins/check_overcr.c:436
3133msgid "Variable to check. Valid variables include:" 2545msgid "Variable to check. Valid variables include:"
3134msgstr "" 2546msgstr ""
3135 2547
3136#: plugins/check_nwstat.c:1615
3137msgid "LOAD1 = 1 minute average CPU load" 2548msgid "LOAD1 = 1 minute average CPU load"
3138msgstr "" 2549msgstr ""
3139 2550
3140#: plugins/check_nwstat.c:1616
3141msgid "LOAD5 = 5 minute average CPU load" 2551msgid "LOAD5 = 5 minute average CPU load"
3142msgstr "" 2552msgstr ""
3143 2553
3144#: plugins/check_nwstat.c:1617
3145msgid "LOAD15 = 15 minute average CPU load" 2554msgid "LOAD15 = 15 minute average CPU load"
3146msgstr "" 2555msgstr ""
3147 2556
3148#: plugins/check_nwstat.c:1618
3149msgid "CSPROCS = number of current service processes (NW 5.x only)" 2557msgid "CSPROCS = number of current service processes (NW 5.x only)"
3150msgstr "" 2558msgstr ""
3151 2559
3152#: plugins/check_nwstat.c:1619
3153msgid "ABENDS = number of abended threads (NW 5.x only)" 2560msgid "ABENDS = number of abended threads (NW 5.x only)"
3154msgstr "" 2561msgstr ""
3155 2562
3156#: plugins/check_nwstat.c:1620
3157msgid "UPTIME = server uptime" 2563msgid "UPTIME = server uptime"
3158msgstr "" 2564msgstr ""
3159 2565
3160#: plugins/check_nwstat.c:1621
3161msgid "LTCH = percent long term cache hits" 2566msgid "LTCH = percent long term cache hits"
3162msgstr "" 2567msgstr ""
3163 2568
3164#: plugins/check_nwstat.c:1622
3165msgid "CBUFF = current number of cache buffers" 2569msgid "CBUFF = current number of cache buffers"
3166msgstr "" 2570msgstr ""
3167 2571
3168#: plugins/check_nwstat.c:1623
3169msgid "CDBUFF = current number of dirty cache buffers" 2572msgid "CDBUFF = current number of dirty cache buffers"
3170msgstr "" 2573msgstr ""
3171 2574
3172#: plugins/check_nwstat.c:1624
3173msgid "DCB = dirty cache buffers as a percentage of the total" 2575msgid "DCB = dirty cache buffers as a percentage of the total"
3174msgstr "" 2576msgstr ""
3175 2577
3176#: plugins/check_nwstat.c:1625
3177msgid "TCB = dirty cache buffers as a percentage of the original" 2578msgid "TCB = dirty cache buffers as a percentage of the original"
3178msgstr "" 2579msgstr ""
3179 2580
3180#: plugins/check_nwstat.c:1626
3181msgid "OFILES = number of open files" 2581msgid "OFILES = number of open files"
3182msgstr "" 2582msgstr ""
3183 2583
3184#: plugins/check_nwstat.c:1627
3185msgid " VMF<vol> = MB of free space on Volume <vol>" 2584msgid " VMF<vol> = MB of free space on Volume <vol>"
3186msgstr "" 2585msgstr ""
3187 2586
3188#: plugins/check_nwstat.c:1628
3189msgid " VMU<vol> = MB used space on Volume <vol>" 2587msgid " VMU<vol> = MB used space on Volume <vol>"
3190msgstr "" 2588msgstr ""
3191 2589
3192#: plugins/check_nwstat.c:1629
3193msgid " VMP<vol> = MB of purgeable space on Volume <vol>" 2590msgid " VMP<vol> = MB of purgeable space on Volume <vol>"
3194msgstr "" 2591msgstr ""
3195 2592
3196#: plugins/check_nwstat.c:1630
3197msgid " VPF<vol> = percent free space on volume <vol>" 2593msgid " VPF<vol> = percent free space on volume <vol>"
3198msgstr "" 2594msgstr ""
3199 2595
3200#: plugins/check_nwstat.c:1631
3201msgid " VKF<vol> = KB of free space on volume <vol>" 2596msgid " VKF<vol> = KB of free space on volume <vol>"
3202msgstr "" 2597msgstr ""
3203 2598
3204#: plugins/check_nwstat.c:1632
3205msgid " VPP<vol> = percent purgeable space on volume <vol>" 2599msgid " VPP<vol> = percent purgeable space on volume <vol>"
3206msgstr "" 2600msgstr ""
3207 2601
3208#: plugins/check_nwstat.c:1633
3209msgid " VKP<vol> = KB of purgeable space on volume <vol>" 2602msgid " VKP<vol> = KB of purgeable space on volume <vol>"
3210msgstr "" 2603msgstr ""
3211 2604
3212#: plugins/check_nwstat.c:1634
3213msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>" 2605msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>"
3214msgstr "" 2606msgstr ""
3215 2607
3216#: plugins/check_nwstat.c:1635
3217msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>" 2608msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>"
3218msgstr "" 2609msgstr ""
3219 2610
3220#: plugins/check_nwstat.c:1636
3221msgid " LRUM = LRU sitting time in minutes" 2611msgid " LRUM = LRU sitting time in minutes"
3222msgstr "" 2612msgstr ""
3223 2613
3224#: plugins/check_nwstat.c:1637
3225msgid " LRUS = LRU sitting time in seconds" 2614msgid " LRUS = LRU sitting time in seconds"
3226msgstr "" 2615msgstr ""
3227 2616
3228#: plugins/check_nwstat.c:1638
3229msgid " DSDB = check to see if DS Database is open" 2617msgid " DSDB = check to see if DS Database is open"
3230msgstr "" 2618msgstr ""
3231 2619
3232#: plugins/check_nwstat.c:1639
3233msgid " DSVER = NDS version" 2620msgid " DSVER = NDS version"
3234msgstr "" 2621msgstr ""
3235 2622
3236#: plugins/check_nwstat.c:1640
3237msgid " UPRB = used packet receive buffers" 2623msgid " UPRB = used packet receive buffers"
3238msgstr "" 2624msgstr ""
3239 2625
3240#: plugins/check_nwstat.c:1641
3241msgid " PUPRB = percent (of max) used packet receive buffers" 2626msgid " PUPRB = percent (of max) used packet receive buffers"
3242msgstr "" 2627msgstr ""
3243 2628
3244#: plugins/check_nwstat.c:1642
3245msgid " SAPENTRIES = number of entries in the SAP table" 2629msgid " SAPENTRIES = number of entries in the SAP table"
3246msgstr "" 2630msgstr ""
3247 2631
3248#: plugins/check_nwstat.c:1643
3249msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>" 2632msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"
3250msgstr "" 2633msgstr ""
3251 2634
3252#: plugins/check_nwstat.c:1644
3253msgid " TSYNC = timesync status" 2635msgid " TSYNC = timesync status"
3254msgstr "" 2636msgstr ""
3255 2637
3256#: plugins/check_nwstat.c:1645
3257msgid " LOGINS = check to see if logins are enabled" 2638msgid " LOGINS = check to see if logins are enabled"
3258msgstr "" 2639msgstr ""
3259 2640
3260#: plugins/check_nwstat.c:1646
3261msgid " CONNS = number of currently licensed connections" 2641msgid " CONNS = number of currently licensed connections"
3262msgstr "" 2642msgstr ""
3263 2643
3264#: plugins/check_nwstat.c:1647
3265msgid " NRMH\t= NRM Summary Status" 2644msgid " NRMH\t= NRM Summary Status"
3266msgstr "" 2645msgstr ""
3267 2646
3268#: plugins/check_nwstat.c:1648
3269msgid " NRMP<stat> = Returns the current value for a NRM health item" 2647msgid " NRMP<stat> = Returns the current value for a NRM health item"
3270msgstr "" 2648msgstr ""
3271 2649
3272#: plugins/check_nwstat.c:1649
3273msgid " NRMM<stat> = Returns the current memory stats from NRM" 2650msgid " NRMM<stat> = Returns the current memory stats from NRM"
3274msgstr "" 2651msgstr ""
3275 2652
3276#: plugins/check_nwstat.c:1650
3277msgid " NRMS<stat> = Returns the current Swapfile stats from NRM" 2653msgid " NRMS<stat> = Returns the current Swapfile stats from NRM"
3278msgstr "" 2654msgstr ""
3279 2655
3280#: plugins/check_nwstat.c:1651
3281msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml" 2656msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"
3282msgstr "" 2657msgstr ""
3283 2658
3284#: plugins/check_nwstat.c:1652
3285msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml" 2659msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"
3286msgstr "" 2660msgstr ""
3287 2661
3288#: plugins/check_nwstat.c:1653
3289msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml" 2662msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"
3290msgstr "" 2663msgstr ""
3291 2664
3292#: plugins/check_nwstat.c:1654
3293msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml" 2665msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"
3294msgstr "" 2666msgstr ""
3295 2667
3296#: plugins/check_nwstat.c:1655
3297msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml" 2668msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"
3298msgstr "" 2669msgstr ""
3299 2670
3300#: plugins/check_nwstat.c:1656
3301msgid "" 2671msgid ""
3302" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml" 2672" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"
3303msgstr "" 2673msgstr ""
3304 2674
3305#: plugins/check_nwstat.c:1657
3306msgid " NLM:<nlm> = check if NLM is loaded and report version" 2675msgid " NLM:<nlm> = check if NLM is loaded and report version"
3307msgstr "" 2676msgstr ""
3308 2677
3309#: plugins/check_nwstat.c:1658
3310msgid " (e.g. NLM:TSANDS.NLM)" 2678msgid " (e.g. NLM:TSANDS.NLM)"
3311msgstr "" 2679msgstr ""
3312 2680
3313#: plugins/check_nwstat.c:1665
3314msgid "Include server version string in results" 2681msgid "Include server version string in results"
3315msgstr "" 2682msgstr ""
3316 2683
3317#: plugins/check_nwstat.c:1671 2684msgid "- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"
3318msgid "- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"
3319msgstr "" 2685msgstr ""
3320 2686
3321#: plugins/check_nwstat.c:1672
3322msgid "" 2687msgid ""
3323" extension for NetWare be loaded on the Novell servers you wish to check." 2688" extension for NetWare be loaded on the Novell servers you wish to check."
3324msgstr "" 2689msgstr ""
3325 2690
3326#: plugins/check_nwstat.c:1673
3327msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)" 2691msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)"
3328msgstr "" 2692msgstr ""
3329 2693
3330#: plugins/check_nwstat.c:1674
3331msgid "" 2694msgid ""
3332"- Values for critical thresholds should be lower than warning thresholds" 2695"- Values for critical thresholds should be lower than warning thresholds"
3333msgstr "" 2696msgstr ""
3334 2697
3335#: plugins/check_nwstat.c:1675
3336msgid "" 2698msgid ""
3337" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, " 2699" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "
3338msgstr "" 2700msgstr ""
3339 2701
3340#: plugins/check_nwstat.c:1676
3341msgid " TCB, LRUS and LRUM." 2702msgid " TCB, LRUS and LRUM."
3342msgstr "" 2703msgstr ""
3343 2704
3344#: plugins/check_overcr.c:123
3345msgid "Unknown error fetching load data\n" 2705msgid "Unknown error fetching load data\n"
3346msgstr "" 2706msgstr ""
3347 2707
3348#: plugins/check_overcr.c:127
3349msgid "Invalid response from server - no load information\n" 2708msgid "Invalid response from server - no load information\n"
3350msgstr "" 2709msgstr ""
3351 2710
3352#: plugins/check_overcr.c:133
3353msgid "Invalid response from server after load 1\n" 2711msgid "Invalid response from server after load 1\n"
3354msgstr "" 2712msgstr ""
3355 2713
3356#: plugins/check_overcr.c:139
3357msgid "Invalid response from server after load 5\n" 2714msgid "Invalid response from server after load 5\n"
3358msgstr "" 2715msgstr ""
3359 2716
3360#: plugins/check_overcr.c:164
3361#, c-format 2717#, c-format
3362msgid "Load %s - %s-min load average = %0.2f" 2718msgid "Load %s - %s-min load average = %0.2f"
3363msgstr "" 2719msgstr ""
3364 2720
3365#: plugins/check_overcr.c:174
3366msgid "Unknown error fetching disk data\n" 2721msgid "Unknown error fetching disk data\n"
3367msgstr "" 2722msgstr ""
3368 2723
3369#: plugins/check_overcr.c:184 plugins/check_overcr.c:236
3370#: plugins/check_overcr.c:240
3371msgid "Invalid response from server\n" 2724msgid "Invalid response from server\n"
3372msgstr "" 2725msgstr ""
3373 2726
3374#: plugins/check_overcr.c:211
3375msgid "Unknown error fetching network status\n" 2727msgid "Unknown error fetching network status\n"
3376msgstr "" 2728msgstr ""
3377 2729
3378#: plugins/check_overcr.c:221
3379#, c-format 2730#, c-format
3380msgid "Net %s - %d connection%s on port %d" 2731msgid "Net %s - %d connection%s on port %d"
3381msgstr "" 2732msgstr ""
3382 2733
3383#: plugins/check_overcr.c:232
3384msgid "Unknown error fetching process status\n" 2734msgid "Unknown error fetching process status\n"
3385msgstr "" 2735msgstr ""
3386 2736
3387#: plugins/check_overcr.c:250
3388#, c-format 2737#, c-format
3389msgid "Process %s - %d instance%s of %s running" 2738msgid "Process %s - %d instance%s of %s running"
3390msgstr "" 2739msgstr ""
3391 2740
3392#: plugins/check_overcr.c:277
3393#, c-format 2741#, c-format
3394msgid "Uptime %s - Up %d days %d hours %d minutes" 2742msgid "Uptime %s - Up %d days %d hours %d minutes"
3395msgstr "" 2743msgstr ""
3396 2744
3397#: plugins/check_overcr.c:419
3398msgid "" 2745msgid ""
3399"This plugin attempts to contact the Over-CR collector daemon running on the" 2746"This plugin attempts to contact the Over-CR collector daemon running on the"
3400msgstr "" 2747msgstr ""
3401 2748
3402#: plugins/check_overcr.c:420
3403msgid "remote UNIX server in order to gather the requested system information." 2749msgid "remote UNIX server in order to gather the requested system information."
3404msgstr "" 2750msgstr ""
3405 2751
3406#: plugins/check_overcr.c:437
3407msgid "LOAD1 = 1 minute average CPU load" 2752msgid "LOAD1 = 1 minute average CPU load"
3408msgstr "" 2753msgstr ""
3409 2754
3410#: plugins/check_overcr.c:438
3411msgid "LOAD5 = 5 minute average CPU load" 2755msgid "LOAD5 = 5 minute average CPU load"
3412msgstr "" 2756msgstr ""
3413 2757
3414#: plugins/check_overcr.c:439
3415msgid "LOAD15 = 15 minute average CPU load" 2758msgid "LOAD15 = 15 minute average CPU load"
3416msgstr "" 2759msgstr ""
3417 2760
3418#: plugins/check_overcr.c:440
3419msgid "DPU<filesys> = percent used disk space on filesystem <filesys>" 2761msgid "DPU<filesys> = percent used disk space on filesystem <filesys>"
3420msgstr "" 2762msgstr ""
3421 2763
3422#: plugins/check_overcr.c:441
3423msgid "PROC<process> = number of running processes with name <process>" 2764msgid "PROC<process> = number of running processes with name <process>"
3424msgstr "" 2765msgstr ""
3425 2766
3426#: plugins/check_overcr.c:442
3427msgid "NET<port> = number of active connections on TCP port <port>" 2767msgid "NET<port> = number of active connections on TCP port <port>"
3428msgstr "" 2768msgstr ""
3429 2769
3430#: plugins/check_overcr.c:443
3431msgid "UPTIME = system uptime in seconds" 2770msgid "UPTIME = system uptime in seconds"
3432msgstr "" 2771msgstr ""
3433 2772
3434#: plugins/check_overcr.c:450
3435msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be" 2773msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be"
3436msgstr "" 2774msgstr ""
3437 2775
3438#: plugins/check_overcr.c:451
3439msgid "running on the remote server." 2776msgid "running on the remote server."
3440msgstr "" 2777msgstr ""
3441 2778
3442#: plugins/check_overcr.c:452
3443msgid "Over-CR can be downloaded from http://www.molitor.org/overcr" 2779msgid "Over-CR can be downloaded from http://www.molitor.org/overcr"
3444msgstr "" 2780msgstr ""
3445 2781
3446#: plugins/check_overcr.c:453
3447msgid "This plugin was tested with version 0.99.53 of the Over-CR collector" 2782msgid "This plugin was tested with version 0.99.53 of the Over-CR collector"
3448msgstr "" 2783msgstr ""
3449 2784
3450#: plugins/check_overcr.c:457
3451msgid "" 2785msgid ""
3452"For the available options, the critical threshold value should always be" 2786"For the available options, the critical threshold value should always be"
3453msgstr "" 2787msgstr ""
3454 2788
3455#: plugins/check_overcr.c:458
3456msgid "" 2789msgid ""
3457"higher than the warning threshold value, EXCEPT with the uptime variable" 2790"higher than the warning threshold value, EXCEPT with the uptime variable"
3458msgstr "" 2791msgstr ""
3459 2792
3460#: plugins/check_pgsql.c:222
3461#, c-format 2793#, c-format
3462msgid "CRITICAL - no connection to '%s' (%s).\n" 2794msgid "CRITICAL - no connection to '%s' (%s).\n"
3463msgstr "" 2795msgstr ""
3464 2796
3465#: plugins/check_pgsql.c:250
3466#, c-format 2797#, c-format
3467msgid " %s - database %s (%f sec.)|%s\n" 2798msgid " %s - database %s (%f sec.)|%s\n"
3468msgstr "" 2799msgstr ""
3469 2800
3470#: plugins/check_pgsql.c:317 plugins/check_time.c:277 plugins/check_time.c:289
3471#: plugins/check_users.c:181
3472msgid "Critical threshold must be a positive integer" 2801msgid "Critical threshold must be a positive integer"
3473msgstr "Critical threshold muss ein positiver Integer sein" 2802msgstr "Critical threshold muss ein positiver Integer sein"
3474 2803
3475#: plugins/check_pgsql.c:323 plugins/check_time.c:258 plugins/check_time.c:282
3476#: plugins/check_users.c:187 plugins/check_users.c:197
3477#: plugins/check_users.c:203
3478msgid "Warning threshold must be a positive integer" 2804msgid "Warning threshold must be a positive integer"
3479msgstr "Warning threshold muss ein positiver Integer sein" 2805msgstr "Warning threshold muss ein positiver Integer sein"
3480 2806
3481#: plugins/check_pgsql.c:347 2807msgid "Database name exceeds the maximum length"
3482msgid "Database name is not valid"
3483msgstr "" 2808msgstr ""
3484 2809
3485#: plugins/check_pgsql.c:353
3486msgid "User name is not valid" 2810msgid "User name is not valid"
3487msgstr "" 2811msgstr ""
3488 2812
3489#: plugins/check_pgsql.c:504
3490#, c-format 2813#, c-format
3491msgid "Test whether a PostgreSQL Database is accepting connections." 2814msgid "Test whether a PostgreSQL Database is accepting connections."
3492msgstr "" 2815msgstr ""
3493 2816
3494#: plugins/check_pgsql.c:516
3495msgid "Database to check " 2817msgid "Database to check "
3496msgstr "" 2818msgstr ""
3497 2819
3498#: plugins/check_pgsql.c:517
3499#, c-format 2820#, c-format
3500msgid "(default: %s)" 2821msgid "(default: %s)\n"
3501msgstr "" 2822msgstr ""
3502 2823
3503#: plugins/check_pgsql.c:519
3504msgid "Login name of user" 2824msgid "Login name of user"
3505msgstr "" 2825msgstr ""
3506 2826
3507#: plugins/check_pgsql.c:521
3508msgid "Password (BIG SECURITY ISSUE)" 2827msgid "Password (BIG SECURITY ISSUE)"
3509msgstr "" 2828msgstr ""
3510 2829
3511#: plugins/check_pgsql.c:523
3512msgid "Connection parameters (keyword = value), see below" 2830msgid "Connection parameters (keyword = value), see below"
3513msgstr "" 2831msgstr ""
3514 2832
3515#: plugins/check_pgsql.c:530
3516msgid "SQL query to run. Only first column in first row will be read" 2833msgid "SQL query to run. Only first column in first row will be read"
3517msgstr "" 2834msgstr ""
3518 2835
3519#: plugins/check_pgsql.c:532 2836msgid "A name for the query, this string is used instead of the query"
2837msgstr ""
2838
2839msgid "in the long output of the plugin"
2840msgstr ""
2841
3520msgid "SQL query value to result in warning status (double)" 2842msgid "SQL query value to result in warning status (double)"
3521msgstr "" 2843msgstr ""
3522 2844
3523#: plugins/check_pgsql.c:534
3524msgid "SQL query value to result in critical status (double)" 2845msgid "SQL query value to result in critical status (double)"
3525msgstr "" 2846msgstr ""
3526 2847
3527#: plugins/check_pgsql.c:539
3528msgid "All parameters are optional." 2848msgid "All parameters are optional."
3529msgstr "" 2849msgstr ""
3530 2850
3531#: plugins/check_pgsql.c:540
3532msgid "" 2851msgid ""
3533"This plugin tests a PostgreSQL DBMS to determine whether it is active and" 2852"This plugin tests a PostgreSQL DBMS to determine whether it is active and"
3534msgstr "" 2853msgstr ""
3535 2854
3536#: plugins/check_pgsql.c:541
3537msgid "accepting queries. In its current operation, it simply connects to the" 2855msgid "accepting queries. In its current operation, it simply connects to the"
3538msgstr "" 2856msgstr ""
3539 2857
3540#: plugins/check_pgsql.c:542
3541msgid "" 2858msgid ""
3542"specified database, and then disconnects. If no database is specified, it" 2859"specified database, and then disconnects. If no database is specified, it"
3543msgstr "" 2860msgstr ""
3544 2861
3545#: plugins/check_pgsql.c:543
3546msgid "" 2862msgid ""
3547"connects to the template1 database, which is present in every functioning" 2863"connects to the template1 database, which is present in every functioning"
3548msgstr "" 2864msgstr ""
3549 2865
3550#: plugins/check_pgsql.c:544
3551msgid "PostgreSQL DBMS." 2866msgid "PostgreSQL DBMS."
3552msgstr "" 2867msgstr ""
3553 2868
3554#: plugins/check_pgsql.c:546
3555msgid "If a query is specified using the -q option, it will be executed after" 2869msgid "If a query is specified using the -q option, it will be executed after"
3556msgstr "" 2870msgstr ""
3557 2871
3558#: plugins/check_pgsql.c:547
3559msgid "connecting to the server. The result from the query has to be numeric." 2872msgid "connecting to the server. The result from the query has to be numeric."
3560msgstr "" 2873msgstr ""
3561 2874
3562#: plugins/check_pgsql.c:548
3563msgid "" 2875msgid ""
3564"Multiple SQL commands, separated by semicolon, are allowed but the result " 2876"Multiple SQL commands, separated by semicolon, are allowed but the result "
3565msgstr "" 2877msgstr ""
3566 2878
3567#: plugins/check_pgsql.c:549
3568msgid "of the last command is taken into account only. The value of the first" 2879msgid "of the last command is taken into account only. The value of the first"
3569msgstr "" 2880msgstr ""
3570 2881
3571#: plugins/check_pgsql.c:550 2882msgid ""
3572msgid "column in the first row is used as the check result." 2883"column in the first row is used as the check result. If a second column is"
2884msgstr ""
2885
2886msgid "present in the result set, this is added to the plugin output with a"
2887msgstr ""
2888
2889msgid ""
2890"prefix of \"Extra Info:\". This information can be displayed in the system"
2891msgstr ""
2892
2893msgid "executing the plugin."
3573msgstr "" 2894msgstr ""
3574 2895
3575#: plugins/check_pgsql.c:552
3576msgid "" 2896msgid ""
3577"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual" 2897"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"
3578msgstr "" 2898msgstr ""
3579 2899
3580#: plugins/check_pgsql.c:553
3581msgid "" 2900msgid ""
3582"for details about how to access internal statistics of the database server." 2901"for details about how to access internal statistics of the database server."
3583msgstr "" 2902msgstr ""
3584 2903
3585#: plugins/check_pgsql.c:555
3586msgid "" 2904msgid ""
3587"For a list of available connection parameters which may be used with the -o" 2905"For a list of available connection parameters which may be used with the -o"
3588msgstr "" 2906msgstr ""
3589 2907
3590#: plugins/check_pgsql.c:556
3591msgid "" 2908msgid ""
3592"command line option, see the documentation for PQconnectdb() in the chapter" 2909"command line option, see the documentation for PQconnectdb() in the chapter"
3593msgstr "" 2910msgstr ""
3594 2911
3595#: plugins/check_pgsql.c:557
3596msgid "" 2912msgid ""
3597"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be" 2913"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"
3598msgstr "" 2914msgstr ""
3599 2915
3600#: plugins/check_pgsql.c:558
3601msgid "" 2916msgid ""
3602"used to specify a service name in pg_service.conf to be used for additional" 2917"used to specify a service name in pg_service.conf to be used for additional"
3603msgstr "" 2918msgstr ""
3604 2919
3605#: plugins/check_pgsql.c:559
3606msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:" 2920msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:"
3607msgstr "" 2921msgstr ""
3608 2922
3609#: plugins/check_pgsql.c:560
3610msgid "-o 'sslmode=require'." 2923msgid "-o 'sslmode=require'."
3611msgstr "" 2924msgstr ""
3612 2925
3613#: plugins/check_pgsql.c:562
3614msgid "" 2926msgid ""
3615"The plugin will connect to a local postmaster if no host is specified. To" 2927"The plugin will connect to a local postmaster if no host is specified. To"
3616msgstr "" 2928msgstr ""
3617 2929
3618#: plugins/check_pgsql.c:563
3619msgid "" 2930msgid ""
3620"connect to a remote host, be sure that the remote postmaster accepts TCP/IP" 2931"connect to a remote host, be sure that the remote postmaster accepts TCP/IP"
3621msgstr "" 2932msgstr ""
3622 2933
3623#: plugins/check_pgsql.c:564
3624msgid "connections (start the postmaster with the -i option)." 2934msgid "connections (start the postmaster with the -i option)."
3625msgstr "" 2935msgstr ""
3626 2936
3627#: plugins/check_pgsql.c:566
3628msgid "" 2937msgid ""
3629"Typically, the monitoring user (unless the --logname option is used) should " 2938"Typically, the monitoring user (unless the --logname option is used) should "
3630"be" 2939"be"
3631msgstr "" 2940msgstr ""
3632 2941
3633#: plugins/check_pgsql.c:567
3634msgid "" 2942msgid ""
3635"able to connect to the database without a password. The plugin can also send" 2943"able to connect to the database without a password. The plugin can also send"
3636msgstr "" 2944msgstr ""
3637 2945
3638#: plugins/check_pgsql.c:568
3639msgid "a password, but no effort is made to obscure or encrypt the password." 2946msgid "a password, but no effort is made to obscure or encrypt the password."
3640msgstr "" 2947msgstr ""
3641 2948
3642#: plugins/check_pgsql.c:601
3643#, c-format 2949#, c-format
3644msgid "QUERY %s - %s: %s.\n" 2950msgid "QUERY %s - %s: %s.\n"
3645msgstr "" 2951msgstr ""
3646 2952
3647#: plugins/check_pgsql.c:601
3648msgid "Error with query" 2953msgid "Error with query"
3649msgstr "" 2954msgstr ""
3650 2955
3651#: plugins/check_pgsql.c:607
3652msgid "No rows returned" 2956msgid "No rows returned"
3653msgstr "" 2957msgstr ""
3654 2958
3655#: plugins/check_pgsql.c:612
3656msgid "No columns returned" 2959msgid "No columns returned"
3657msgstr "" 2960msgstr ""
3658 2961
3659#: plugins/check_pgsql.c:618
3660#, fuzzy 2962#, fuzzy
3661msgid "No data returned" 2963msgid "No data returned"
3662msgstr "Keine Daten empfangen %s\n" 2964msgstr "Keine Daten empfangen %s\n"
3663 2965
3664#: plugins/check_pgsql.c:627
3665msgid "Is not a numeric" 2966msgid "Is not a numeric"
3666msgstr "" 2967msgstr ""
3667 2968
3668#: plugins/check_pgsql.c:644 2969#, fuzzy, c-format
2970msgid "%s returned %f"
2971msgstr "%s hat %s zurückgegeben"
2972
3669#, fuzzy, c-format 2973#, fuzzy, c-format
3670msgid "'%s' returned %f" 2974msgid "'%s' returned %f"
3671msgstr "%s hat %s zurückgegeben" 2975msgstr "%s hat %s zurückgegeben"
3672 2976
3673#: plugins/check_ping.c:141
3674msgid "CRITICAL - Could not interpret output from ping command\n" 2977msgid "CRITICAL - Could not interpret output from ping command\n"
3675msgstr "" 2978msgstr ""
3676 2979
3677#: plugins/check_ping.c:157
3678#, c-format 2980#, c-format
3679msgid "PING %s - %sPacket loss = %d%%" 2981msgid "PING %s - %sPacket loss = %d%%"
3680msgstr "" 2982msgstr ""
3681 2983
3682#: plugins/check_ping.c:160
3683#, c-format 2984#, c-format
3684msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms" 2985msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"
3685msgstr "" 2986msgstr ""
3686 2987
3687#: plugins/check_ping.c:257
3688msgid "Could not realloc() addresses\n" 2988msgid "Could not realloc() addresses\n"
3689msgstr "" 2989msgstr ""
3690 2990
3691#: plugins/check_ping.c:272 plugins/check_ping.c:352
3692#, c-format 2991#, c-format
3693msgid "<max_packets> (%s) must be a non-negative number\n" 2992msgid "<max_packets> (%s) must be a non-negative number\n"
3694msgstr "" 2993msgstr ""
3695 2994
3696#: plugins/check_ping.c:306
3697#, c-format 2995#, c-format
3698msgid "<wpl> (%s) must be an integer percentage\n" 2996msgid "<wpl> (%s) must be an integer percentage\n"
3699msgstr "" 2997msgstr ""
3700 2998
3701#: plugins/check_ping.c:317
3702#, c-format 2999#, c-format
3703msgid "<cpl> (%s) must be an integer percentage\n" 3000msgid "<cpl> (%s) must be an integer percentage\n"
3704msgstr "" 3001msgstr ""
3705 3002
3706#: plugins/check_ping.c:328
3707#, c-format 3003#, c-format
3708msgid "<wrta> (%s) must be a non-negative number\n" 3004msgid "<wrta> (%s) must be a non-negative number\n"
3709msgstr "" 3005msgstr ""
3710 3006
3711#: plugins/check_ping.c:339
3712#, c-format 3007#, c-format
3713msgid "<crta> (%s) must be a non-negative number\n" 3008msgid "<crta> (%s) must be a non-negative number\n"
3714msgstr "" 3009msgstr ""
3715 3010
3716#: plugins/check_ping.c:372
3717#, c-format 3011#, c-format
3718msgid "" 3012msgid ""
3719"%s: Warning threshold must be integer or percentage!\n" 3013"%s: Warning threshold must be integer or percentage!\n"
3720"\n" 3014"\n"
3721msgstr "" 3015msgstr ""
3722 3016
3723#: plugins/check_ping.c:385
3724#, c-format 3017#, c-format
3725msgid "<wrta> was not set\n" 3018msgid "<wrta> was not set\n"
3726msgstr "" 3019msgstr ""
3727 3020
3728#: plugins/check_ping.c:389
3729#, c-format 3021#, c-format
3730msgid "<crta> was not set\n" 3022msgid "<crta> was not set\n"
3731msgstr "" 3023msgstr ""
3732 3024
3733#: plugins/check_ping.c:393
3734#, c-format 3025#, c-format
3735msgid "<wpl> was not set\n" 3026msgid "<wpl> was not set\n"
3736msgstr "" 3027msgstr ""
3737 3028
3738#: plugins/check_ping.c:397
3739#, c-format 3029#, c-format
3740msgid "<cpl> was not set\n" 3030msgid "<cpl> was not set\n"
3741msgstr "" 3031msgstr ""
3742 3032
3743#: plugins/check_ping.c:401
3744#, c-format 3033#, c-format
3745msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n" 3034msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n"
3746msgstr "" 3035msgstr ""
3747 3036
3748#: plugins/check_ping.c:405
3749#, c-format 3037#, c-format
3750msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n" 3038msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n"
3751msgstr "" 3039msgstr ""
3752 3040
3753#: plugins/check_ping.c:442
3754#, c-format 3041#, c-format
3755msgid "Cannot open stderr for %s\n" 3042msgid "Cannot open stderr for %s\n"
3756msgstr "" 3043msgstr ""
3757 3044
3758#: plugins/check_ping.c:492 plugins/check_ping.c:494
3759msgid "System call sent warnings to stderr " 3045msgid "System call sent warnings to stderr "
3760msgstr "" 3046msgstr ""
3761 3047
3762#: plugins/check_ping.c:519
3763#, fuzzy, c-format 3048#, fuzzy, c-format
3764msgid "CRITICAL - Network Unreachable (%s)\n" 3049msgid "CRITICAL - Network Unreachable (%s)\n"
3765msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3050msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3766 3051
3767#: plugins/check_ping.c:521
3768#, fuzzy, c-format 3052#, fuzzy, c-format
3769msgid "CRITICAL - Host Unreachable (%s)\n" 3053msgid "CRITICAL - Host Unreachable (%s)\n"
3770msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3054msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3771 3055
3772#: plugins/check_ping.c:523
3773#, fuzzy, c-format 3056#, fuzzy, c-format
3774msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n" 3057msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"
3775msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3058msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3776 3059
3777#: plugins/check_ping.c:525
3778#, fuzzy, c-format 3060#, fuzzy, c-format
3779msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n" 3061msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"
3780msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3062msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3781 3063
3782#: plugins/check_ping.c:527
3783#, fuzzy, c-format 3064#, fuzzy, c-format
3784msgid "CRITICAL - Network Prohibited (%s)\n" 3065msgid "CRITICAL - Network Prohibited (%s)\n"
3785msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3066msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3786 3067
3787#: plugins/check_ping.c:529
3788#, fuzzy, c-format 3068#, fuzzy, c-format
3789msgid "CRITICAL - Host Prohibited (%s)\n" 3069msgid "CRITICAL - Host Prohibited (%s)\n"
3790msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3070msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3791 3071
3792#: plugins/check_ping.c:531
3793#, fuzzy, c-format 3072#, fuzzy, c-format
3794msgid "CRITICAL - Packet Filtered (%s)\n" 3073msgid "CRITICAL - Packet Filtered (%s)\n"
3795msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3074msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3796 3075
3797#: plugins/check_ping.c:533
3798#, fuzzy, c-format 3076#, fuzzy, c-format
3799msgid "CRITICAL - Host not found (%s)\n" 3077msgid "CRITICAL - Host not found (%s)\n"
3800msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n" 3078msgstr "CRITICAL - Text nicht gefunden%s|%s %s\n"
3801 3079
3802#: plugins/check_ping.c:535
3803#, fuzzy, c-format 3080#, fuzzy, c-format
3804msgid "CRITICAL - Time to live exceeded (%s)\n" 3081msgid "CRITICAL - Time to live exceeded (%s)\n"
3805msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3082msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3806 3083
3807#: plugins/check_ping.c:537
3808#, fuzzy, c-format 3084#, fuzzy, c-format
3809msgid "CRITICAL - Destination Unreachable (%s)\n" 3085msgid "CRITICAL - Destination Unreachable (%s)\n"
3810msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)" 3086msgstr "CRITICAL - Netzwerk nicht erreichbar (%s)"
3811 3087
3812#: plugins/check_ping.c:544
3813msgid "Unable to realloc warn_text\n" 3088msgid "Unable to realloc warn_text\n"
3814msgstr "" 3089msgstr ""
3815 3090
3816#: plugins/check_ping.c:561
3817#, c-format 3091#, c-format
3818msgid "Use ping to check connection statistics for a remote host." 3092msgid "Use ping to check connection statistics for a remote host."
3819msgstr "" 3093msgstr ""
3820 3094
3821#: plugins/check_ping.c:573
3822msgid "host to ping" 3095msgid "host to ping"
3823msgstr "" 3096msgstr ""
3824 3097
3825#: plugins/check_ping.c:579
3826msgid "number of ICMP ECHO packets to send" 3098msgid "number of ICMP ECHO packets to send"
3827msgstr "" 3099msgstr ""
3828 3100
3829#: plugins/check_ping.c:580
3830#, c-format 3101#, c-format
3831msgid "(Default: %d)\n" 3102msgid "(Default: %d)\n"
3832msgstr "" 3103msgstr ""
3833 3104
3834#: plugins/check_ping.c:582
3835msgid "show HTML in the plugin output (obsoleted by urlize)" 3105msgid "show HTML in the plugin output (obsoleted by urlize)"
3836msgstr "" 3106msgstr ""
3837 3107
3838#: plugins/check_ping.c:587
3839msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel" 3108msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"
3840msgstr "" 3109msgstr ""
3841 3110
3842#: plugins/check_ping.c:588
3843msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the" 3111msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"
3844msgstr "" 3112msgstr ""
3845 3113
3846#: plugins/check_ping.c:589
3847msgid "percentage of packet loss to trigger an alarm state." 3114msgid "percentage of packet loss to trigger an alarm state."
3848msgstr "" 3115msgstr ""
3849 3116
3850#: plugins/check_ping.c:592
3851#, fuzzy 3117#, fuzzy
3852msgid "" 3118msgid ""
3853"This plugin uses the ping command to probe the specified host for packet loss" 3119"This plugin uses the ping command to probe the specified host for packet loss"
3854msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3120msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
3855 3121
3856#: plugins/check_ping.c:593
3857msgid "" 3122msgid ""
3858"(percentage) and round trip average (milliseconds). It can produce HTML " 3123"(percentage) and round trip average (milliseconds). It can produce HTML "
3859"output" 3124"output"
3860msgstr "" 3125msgstr ""
3861 3126
3862#: plugins/check_ping.c:594
3863msgid "" 3127msgid ""
3864"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in" 3128"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"
3865msgstr "" 3129msgstr ""
3866 3130
3867#: plugins/check_ping.c:595
3868msgid "the contrib area of the downloads section at http://www.nagios.org/" 3131msgid "the contrib area of the downloads section at http://www.nagios.org/"
3869msgstr "" 3132msgstr ""
3870 3133
3871#: plugins/check_procs.c:193
3872#, c-format 3134#, c-format
3873msgid "CMD: %s\n" 3135msgid "CMD: %s\n"
3874msgstr "" 3136msgstr ""
3875 3137
3876#: plugins/check_procs.c:198
3877msgid "System call sent warnings to stderr" 3138msgid "System call sent warnings to stderr"
3878msgstr "" 3139msgstr ""
3879 3140
3880#: plugins/check_procs.c:326
3881#, c-format 3141#, c-format
3882msgid "Not parseable: %s" 3142msgid "Not parseable: %s"
3883msgstr "" 3143msgstr ""
3884 3144
3885#: plugins/check_procs.c:331
3886#, c-format 3145#, c-format
3887msgid "Unable to read output\n" 3146msgid "Unable to read output\n"
3888msgstr "" 3147msgstr ""
3889 3148
3890#: plugins/check_procs.c:348
3891#, c-format 3149#, c-format
3892msgid "%d warn out of " 3150msgid "%d warn out of "
3893msgstr "" 3151msgstr ""
3894 3152
3895#: plugins/check_procs.c:353
3896#, c-format 3153#, c-format
3897msgid "%d crit, %d warn out of " 3154msgid "%d crit, %d warn out of "
3898msgstr "" 3155msgstr ""
3899 3156
3900#: plugins/check_procs.c:359
3901#, c-format 3157#, c-format
3902msgid " with %s" 3158msgid " with %s"
3903msgstr "" 3159msgstr ""
3904 3160
3905#: plugins/check_procs.c:453
3906#, fuzzy 3161#, fuzzy
3907msgid "Parent Process ID must be an integer!" 3162msgid "Parent Process ID must be an integer!"
3908msgstr "Argument für check_dummy muss ein Integer sein" 3163msgstr "Argument für check_dummy muss ein Integer sein"
3909 3164
3910#: plugins/check_procs.c:459 plugins/check_procs.c:586
3911#, c-format 3165#, c-format
3912msgid "%s%sSTATE = %s" 3166msgid "%s%sSTATE = %s"
3913msgstr "" 3167msgstr ""
3914 3168
3915#: plugins/check_procs.c:468
3916#, fuzzy 3169#, fuzzy
3917msgid "UID was not found" 3170msgid "UID was not found"
3918msgstr "%s [%s nicht gefunden]" 3171msgstr "%s [%s nicht gefunden]"
3919 3172
3920#: plugins/check_procs.c:474
3921#, fuzzy 3173#, fuzzy
3922msgid "User name was not found" 3174msgid "User name was not found"
3923msgstr "%s [%s nicht gefunden]" 3175msgstr "%s [%s nicht gefunden]"
3924 3176
3925#: plugins/check_procs.c:489
3926#, c-format 3177#, c-format
3927msgid "%s%scommand name '%s'" 3178msgid "%s%scommand name '%s'"
3928msgstr "" 3179msgstr ""
3929 3180
3930#: plugins/check_procs.c:524 3181#, c-format
3182msgid "%s%sexclude progs '%s'"
3183msgstr ""
3184
3931#, fuzzy 3185#, fuzzy
3932msgid "RSS must be an integer!" 3186msgid "RSS must be an integer!"
3933msgstr "skip lines muss ein Integer sein" 3187msgstr "skip lines muss ein Integer sein"
3934 3188
3935#: plugins/check_procs.c:531
3936#, fuzzy 3189#, fuzzy
3937msgid "VSZ must be an integer!" 3190msgid "VSZ must be an integer!"
3938msgstr "skip lines muss ein Integer sein" 3191msgstr "skip lines muss ein Integer sein"
3939 3192
3940#: plugins/check_procs.c:539
3941msgid "PCPU must be a float!" 3193msgid "PCPU must be a float!"
3942msgstr "" 3194msgstr ""
3943 3195
3944#: plugins/check_procs.c:563
3945msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!" 3196msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"
3946msgstr "" 3197msgstr ""
3947 3198
3948#: plugins/check_procs.c:694
3949msgid "" 3199msgid ""
3950"Checks all processes and generates WARNING or CRITICAL states if the " 3200"Checks all processes and generates WARNING or CRITICAL states if the "
3951"specified" 3201"specified"
3952msgstr "" 3202msgstr ""
3953 3203
3954#: plugins/check_procs.c:695
3955msgid "" 3204msgid ""
3956"metric is outside the required threshold ranges. The metric defaults to " 3205"metric is outside the required threshold ranges. The metric defaults to "
3957"number" 3206"number"
3958msgstr "" 3207msgstr ""
3959 3208
3960#: plugins/check_procs.c:696
3961msgid "" 3209msgid ""
3962"of processes. Search filters can be applied to limit the processes to check." 3210"of processes. Search filters can be applied to limit the processes to check."
3963msgstr "" 3211msgstr ""
3964 3212
3965#: plugins/check_procs.c:705
3966msgid "Generate warning state if metric is outside this range" 3213msgid "Generate warning state if metric is outside this range"
3967msgstr "" 3214msgstr ""
3968 3215
3969#: plugins/check_procs.c:707
3970msgid "Generate critical state if metric is outside this range" 3216msgid "Generate critical state if metric is outside this range"
3971msgstr "" 3217msgstr ""
3972 3218
3973#: plugins/check_procs.c:709
3974msgid "Check thresholds against metric. Valid types:" 3219msgid "Check thresholds against metric. Valid types:"
3975msgstr "" 3220msgstr ""
3976 3221
3977#: plugins/check_procs.c:710
3978msgid "PROCS - number of processes (default)" 3222msgid "PROCS - number of processes (default)"
3979msgstr "" 3223msgstr ""
3980 3224
3981#: plugins/check_procs.c:711
3982msgid "VSZ - virtual memory size" 3225msgid "VSZ - virtual memory size"
3983msgstr "" 3226msgstr ""
3984 3227
3985#: plugins/check_procs.c:712
3986msgid "RSS - resident set memory size" 3228msgid "RSS - resident set memory size"
3987msgstr "" 3229msgstr ""
3988 3230
3989#: plugins/check_procs.c:713
3990msgid "CPU - percentage CPU" 3231msgid "CPU - percentage CPU"
3991msgstr "" 3232msgstr ""
3992 3233
3993#: plugins/check_procs.c:716
3994msgid "ELAPSED - time elapsed in seconds" 3234msgid "ELAPSED - time elapsed in seconds"
3995msgstr "" 3235msgstr ""
3996 3236
3997#: plugins/check_procs.c:721
3998msgid "Extra information. Up to 3 verbosity levels" 3237msgid "Extra information. Up to 3 verbosity levels"
3999msgstr "" 3238msgstr ""
4000 3239
4001#: plugins/check_procs.c:724
4002msgid "Filter own process the traditional way by PID instead of /proc/pid/exe" 3240msgid "Filter own process the traditional way by PID instead of /proc/pid/exe"
4003msgstr "" 3241msgstr ""
4004 3242
4005#: plugins/check_procs.c:729
4006msgid "Only scan for processes that have, in the output of `ps`, one or" 3243msgid "Only scan for processes that have, in the output of `ps`, one or"
4007msgstr "" 3244msgstr ""
4008 3245
4009#: plugins/check_procs.c:730
4010msgid "more of the status flags you specify (for example R, Z, S, RS," 3246msgid "more of the status flags you specify (for example R, Z, S, RS,"
4011msgstr "" 3247msgstr ""
4012 3248
4013#: plugins/check_procs.c:731
4014msgid "RSZDT, plus others based on the output of your 'ps' command)." 3249msgid "RSZDT, plus others based on the output of your 'ps' command)."
4015msgstr "" 3250msgstr ""
4016 3251
4017#: plugins/check_procs.c:733
4018msgid "Only scan for children of the parent process ID indicated." 3252msgid "Only scan for children of the parent process ID indicated."
4019msgstr "" 3253msgstr ""
4020 3254
4021#: plugins/check_procs.c:735
4022msgid "Only scan for processes with VSZ higher than indicated." 3255msgid "Only scan for processes with VSZ higher than indicated."
4023msgstr "" 3256msgstr ""
4024 3257
4025#: plugins/check_procs.c:737
4026msgid "Only scan for processes with RSS higher than indicated." 3258msgid "Only scan for processes with RSS higher than indicated."
4027msgstr "" 3259msgstr ""
4028 3260
4029#: plugins/check_procs.c:739
4030msgid "Only scan for processes with PCPU higher than indicated." 3261msgid "Only scan for processes with PCPU higher than indicated."
4031msgstr "" 3262msgstr ""
4032 3263
4033#: plugins/check_procs.c:741
4034msgid "Only scan for processes with user name or ID indicated." 3264msgid "Only scan for processes with user name or ID indicated."
4035msgstr "" 3265msgstr ""
4036 3266
4037#: plugins/check_procs.c:743
4038msgid "Only scan for processes with args that contain STRING." 3267msgid "Only scan for processes with args that contain STRING."
4039msgstr "" 3268msgstr ""
4040 3269
4041#: plugins/check_procs.c:745
4042msgid "Only scan for processes with args that contain the regex STRING." 3270msgid "Only scan for processes with args that contain the regex STRING."
4043msgstr "" 3271msgstr ""
4044 3272
4045#: plugins/check_procs.c:747
4046msgid "Only scan for exact matches of COMMAND (without path)." 3273msgid "Only scan for exact matches of COMMAND (without path)."
4047msgstr "" 3274msgstr ""
4048 3275
4049#: plugins/check_procs.c:749 3276msgid "Exclude processes which match this comma separated list"
3277msgstr ""
3278
4050msgid "Only scan for non kernel threads (works on Linux only)." 3279msgid "Only scan for non kernel threads (works on Linux only)."
4051msgstr "" 3280msgstr ""
4052 3281
4053#: plugins/check_procs.c:751
4054#, c-format 3282#, c-format
4055msgid "" 3283msgid ""
4056"\n" 3284"\n"
@@ -4060,7 +3288,6 @@ msgid ""
4060"\n" 3288"\n"
4061msgstr "" 3289msgstr ""
4062 3290
4063#: plugins/check_procs.c:756
4064#, c-format 3291#, c-format
4065msgid "" 3292msgid ""
4066"This plugin checks the number of currently running processes and\n" 3293"This plugin checks the number of currently running processes and\n"
@@ -4071,1144 +3298,993 @@ msgid ""
4071"\n" 3298"\n"
4072msgstr "" 3299msgstr ""
4073 3300
4074#: plugins/check_procs.c:765
4075msgid "Warning if not two processes with command name portsentry." 3301msgid "Warning if not two processes with command name portsentry."
4076msgstr "" 3302msgstr ""
4077 3303
4078#: plugins/check_procs.c:766
4079msgid "Critical if < 2 or > 1024 processes" 3304msgid "Critical if < 2 or > 1024 processes"
4080msgstr "" 3305msgstr ""
4081 3306
4082#: plugins/check_procs.c:768 3307msgid "Critical if not at least 1 process with command sshd"
4083msgid "Warning alert if > 10 processes with command arguments containing"
4084msgstr "" 3308msgstr ""
4085 3309
4086#: plugins/check_procs.c:769 3310msgid "Warning if > 1024 processes with command name sshd."
4087msgid "'/usr/local/bin/perl' and owned by root"
4088msgstr "" 3311msgstr ""
4089 3312
4090#: plugins/check_procs.c:771 3313msgid "Critical if < 1 processes with command name sshd."
4091msgid "Alert if VSZ of any processes over 50K or 100K"
4092msgstr "" 3314msgstr ""
4093 3315
4094#: plugins/check_procs.c:773 3316msgid "Warning alert if > 10 processes with command arguments containing"
4095#, c-format
4096msgid "Alert if CPU of any processes over 10%% or 20%%"
4097msgstr "" 3317msgstr ""
4098 3318
4099#: plugins/check_radius.c:165 3319msgid "'/usr/local/bin/perl' and owned by root"
4100msgid "Config file error"
4101msgstr "" 3320msgstr ""
4102 3321
4103#: plugins/check_radius.c:174 3322msgid "Alert if VSZ of any processes over 50K or 100K"
4104msgid "Out of Memory?"
4105msgstr "" 3323msgstr ""
4106 3324
4107#: plugins/check_radius.c:178 3325msgid "Alert if CPU of any processes over 10% or 20%"
4108msgid "Invalid NAS-Identifier" 3326msgstr ""
3327
3328msgid "Config file error\n"
4109msgstr "" 3329msgstr ""
4110 3330
4111#: plugins/check_radius.c:183 plugins/check_radius.c:185
4112#: plugins/check_radius.c:191
4113#, fuzzy 3331#, fuzzy
4114msgid "Invalid NAS-IP-Address" 3332msgid "Out of Memory?\n"
4115msgstr "Ungültige(r) Hostname/Adresse" 3333msgstr "Kein Papier"
4116 3334
4117#: plugins/check_radius.c:188 3335#, fuzzy
4118msgid "Can't find local IP for NAS-IP-Address" 3336msgid "Invalid NAS-Identifier\n"
4119msgstr "" 3337msgstr "Ungültige(r) Hostname/Adresse"
4120 3338
4121#: plugins/check_radius.c:202 3339#, c-format
4122msgid "Timeout" 3340msgid "gethostname() failed!\n"
4123msgstr "" 3341msgstr ""
4124 3342
4125#: plugins/check_radius.c:204 3343#, fuzzy
4126msgid "Auth Error" 3344msgid "Invalid NAS-IP-Address\n"
3345msgstr "Ungültige(r) Hostname/Adresse"
3346
3347msgid "Timeout\n"
4127msgstr "" 3348msgstr ""
4128 3349
4129#: plugins/check_radius.c:206 3350msgid "Auth Error\n"
4130msgid "Auth Failed"
4131msgstr "" 3351msgstr ""
4132 3352
4133#: plugins/check_radius.c:208 3353#, fuzzy
4134msgid "Bad Response" 3354msgid "Auth Failed\n"
3355msgstr "Fehlgeschlagen"
3356
3357msgid "Bad Response\n"
4135msgstr "" 3358msgstr ""
4136 3359
4137#: plugins/check_radius.c:212 3360msgid "Auth OK\n"
4138msgid "Auth OK"
4139msgstr "" 3361msgstr ""
4140 3362
4141#: plugins/check_radius.c:213
4142#, fuzzy, c-format 3363#, fuzzy, c-format
4143msgid "Unexpected result code %d" 3364msgid "Unexpected result code %d"
4144msgstr "Erwartet: %s aber: %s erhalten" 3365msgstr "Erwartet: %s aber: %s erhalten"
4145 3366
4146#: plugins/check_radius.c:302
4147msgid "Number of retries must be a positive integer" 3367msgid "Number of retries must be a positive integer"
4148msgstr "" 3368msgstr ""
4149 3369
4150#: plugins/check_radius.c:316
4151msgid "User not specified" 3370msgid "User not specified"
4152msgstr "" 3371msgstr ""
4153 3372
4154#: plugins/check_radius.c:318
4155msgid "Password not specified" 3373msgid "Password not specified"
4156msgstr "" 3374msgstr ""
4157 3375
4158#: plugins/check_radius.c:320
4159msgid "Configuration file not specified" 3376msgid "Configuration file not specified"
4160msgstr "" 3377msgstr ""
4161 3378
4162#: plugins/check_radius.c:338
4163#, fuzzy 3379#, fuzzy
4164msgid "Tests to see if a RADIUS server is accepting connections." 3380msgid "Tests to see if a RADIUS server is accepting connections."
4165msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3381msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4166 3382
4167#: plugins/check_radius.c:350
4168msgid "The user to authenticate" 3383msgid "The user to authenticate"
4169msgstr "" 3384msgstr ""
4170 3385
4171#: plugins/check_radius.c:352
4172msgid "Password for authentication (SECURITY RISK)" 3386msgid "Password for authentication (SECURITY RISK)"
4173msgstr "" 3387msgstr ""
4174 3388
4175#: plugins/check_radius.c:354
4176msgid "NAS identifier" 3389msgid "NAS identifier"
4177msgstr "" 3390msgstr ""
4178 3391
4179#: plugins/check_radius.c:356
4180msgid "NAS IP Address" 3392msgid "NAS IP Address"
4181msgstr "" 3393msgstr ""
4182 3394
4183#: plugins/check_radius.c:358
4184msgid "Configuration file" 3395msgid "Configuration file"
4185msgstr "" 3396msgstr ""
4186 3397
4187#: plugins/check_radius.c:360
4188msgid "Response string to expect from the server" 3398msgid "Response string to expect from the server"
4189msgstr "" 3399msgstr ""
4190 3400
4191#: plugins/check_radius.c:362
4192msgid "Number of times to retry a failed connection" 3401msgid "Number of times to retry a failed connection"
4193msgstr "" 3402msgstr ""
4194 3403
4195#: plugins/check_radius.c:367
4196#, fuzzy 3404#, fuzzy
4197msgid "" 3405msgid ""
4198"This plugin tests a RADIUS server to see if it is accepting connections." 3406"This plugin tests a RADIUS server to see if it is accepting connections."
4199msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3407msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4200 3408
4201#: plugins/check_radius.c:368
4202msgid "" 3409msgid ""
4203"The server to test must be specified in the invocation, as well as a user" 3410"The server to test must be specified in the invocation, as well as a user"
4204msgstr "" 3411msgstr ""
4205 3412
4206#: plugins/check_radius.c:369 3413msgid "name and password. A configuration file must be present. The format of"
4207msgid ""
4208"name and password. A configuration file may also be present. The format of"
4209msgstr "" 3414msgstr ""
4210 3415
4211#: plugins/check_radius.c:370
4212msgid "" 3416msgid ""
4213"the configuration file is described in the radiusclient library sources." 3417"the configuration file is described in the radiusclient library sources."
4214msgstr "" 3418msgstr ""
4215 3419
4216#: plugins/check_radius.c:371
4217msgid "The password option presents a substantial security issue because the" 3420msgid "The password option presents a substantial security issue because the"
4218msgstr "" 3421msgstr ""
4219 3422
4220#: plugins/check_radius.c:372
4221msgid "" 3423msgid ""
4222"password can possibly be determined by careful watching of the command line" 3424"password can possibly be determined by careful watching of the command line"
4223msgstr "" 3425msgstr ""
4224 3426
4225#: plugins/check_radius.c:373 3427msgid "in a process listing. This risk is exacerbated because the plugin will"
4226msgid "in a process listing. This risk is exacerbated because the monitor will"
4227msgstr "" 3428msgstr ""
4228 3429
4229#: plugins/check_radius.c:374 3430msgid ""
4230msgid "run the plugin at regular predictable intervals. Please be sure that" 3431"typically be executed at regular predictable intervals. Please be sure that"
4231msgstr "" 3432msgstr ""
4232 3433
4233#: plugins/check_radius.c:375
4234msgid "the password used does not allow access to sensitive system resources." 3434msgid "the password used does not allow access to sensitive system resources."
4235msgstr "" 3435msgstr ""
4236 3436
4237#: plugins/check_real.c:91
4238#, c-format 3437#, c-format
4239msgid "Unable to connect to %s on port %d\n" 3438msgid "Unable to connect to %s on port %d\n"
4240msgstr "" 3439msgstr ""
4241 3440
4242#: plugins/check_real.c:113
4243#, c-format 3441#, c-format
4244msgid "No data received from %s\n" 3442msgid "No data received from %s\n"
4245msgstr "" 3443msgstr ""
4246 3444
4247#: plugins/check_real.c:118 plugins/check_real.c:191
4248#, fuzzy 3445#, fuzzy
4249msgid "Invalid REAL response received from host" 3446msgid "Invalid REAL response received from host"
4250msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3447msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4251 3448
4252#: plugins/check_real.c:120 plugins/check_real.c:193
4253#, c-format 3449#, c-format
4254msgid "Invalid REAL response received from host on port %d\n" 3450msgid "Invalid REAL response received from host on port %d\n"
4255msgstr "" 3451msgstr ""
4256 3452
4257#: plugins/check_real.c:184 plugins/check_tcp.c:311
4258#, c-format 3453#, c-format
4259msgid "No data received from host\n" 3454msgid "No data received from host\n"
4260msgstr "" 3455msgstr ""
4261 3456
4262#: plugins/check_real.c:247
4263#, c-format 3457#, c-format
4264msgid "REAL %s - %d second response time\n" 3458msgid "REAL %s - %d second response time\n"
4265msgstr "" 3459msgstr ""
4266 3460
4267#: plugins/check_real.c:336 plugins/check_ups.c:536
4268msgid "Warning time must be a positive integer" 3461msgid "Warning time must be a positive integer"
4269msgstr "Warnung time muss ein positiver Integer sein" 3462msgstr "Warnung time muss ein positiver Integer sein"
4270 3463
4271#: plugins/check_real.c:345 plugins/check_ups.c:527
4272msgid "Critical time must be a positive integer" 3464msgid "Critical time must be a positive integer"
4273msgstr "Critical time muss ein positiver Integer sein" 3465msgstr "Critical time muss ein positiver Integer sein"
4274 3466
4275#: plugins/check_real.c:381
4276#, fuzzy 3467#, fuzzy
4277msgid "You must provide a server to check" 3468msgid "You must provide a server to check"
4278msgstr "%s: Hostname muss angegeben werden\n" 3469msgstr "%s: Hostname muss angegeben werden\n"
4279 3470
4280#: plugins/check_real.c:413
4281#, fuzzy 3471#, fuzzy
4282msgid "This plugin tests the REAL service on the specified host." 3472msgid "This plugin tests the REAL service on the specified host."
4283msgstr "" 3473msgstr ""
4284"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 3474"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
4285"\n" 3475"\n"
4286 3476
4287#: plugins/check_real.c:425
4288msgid "Connect to this url" 3477msgid "Connect to this url"
4289msgstr "" 3478msgstr ""
4290 3479
4291#: plugins/check_real.c:427
4292#, c-format 3480#, c-format
4293msgid "String to expect in first line of server response (default: %s)\n" 3481msgid "String to expect in first line of server response (default: %s)\n"
4294msgstr "" 3482msgstr ""
4295 3483
4296#: plugins/check_real.c:437
4297#, fuzzy 3484#, fuzzy
4298msgid "This plugin will attempt to open an RTSP connection with the host." 3485msgid "This plugin will attempt to open an RTSP connection with the host."
4299msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3486msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4300 3487
4301#: plugins/check_real.c:438 plugins/check_smtp.c:830 3488msgid "Successful connects return STATE_OK, refusals and timeouts return"
4302msgid "Successul connects return STATE_OK, refusals and timeouts return"
4303msgstr "" 3489msgstr ""
4304 3490
4305#: plugins/check_real.c:439
4306msgid "" 3491msgid ""
4307"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects," 3492"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"
4308msgstr "" 3493msgstr ""
4309 3494
4310#: plugins/check_real.c:440
4311msgid "" 3495msgid ""
4312"but incorrect response messages from the host result in STATE_WARNING return" 3496"but incorrect response messages from the host result in STATE_WARNING return"
4313msgstr "" 3497msgstr ""
4314 3498
4315#: plugins/check_real.c:441
4316msgid "values." 3499msgid "values."
4317msgstr "" 3500msgstr ""
4318 3501
4319#: plugins/check_smtp.c:150 plugins/check_swap.c:265 plugins/check_swap.c:271
4320#, c-format 3502#, c-format
4321msgid "malloc() failed!\n" 3503msgid "malloc() failed!\n"
4322msgstr "" 3504msgstr ""
4323 3505
4324#: plugins/check_smtp.c:154
4325#, c-format 3506#, c-format
4326msgid "gethostname() failed!\n" 3507msgid "CRITICAL - Cannot create SSL context.\n"
4327msgstr "" 3508msgstr ""
4328 3509
4329#: plugins/check_smtp.c:189 plugins/check_smtp.c:213
4330#, c-format 3510#, c-format
4331msgid "recv() failed\n" 3511msgid "recv() failed\n"
4332msgstr "" 3512msgstr ""
4333 3513
4334#: plugins/check_smtp.c:200
4335#, fuzzy, c-format
4336msgid "Invalid SMTP response received from host: %s\n"
4337msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4338
4339#: plugins/check_smtp.c:202
4340#, fuzzy, c-format
4341msgid "Invalid SMTP response received from host on port %d: %s\n"
4342msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
4343
4344#: plugins/check_smtp.c:223
4345#, c-format 3514#, c-format
4346msgid "WARNING - TLS not supported by server\n" 3515msgid "WARNING - TLS not supported by server\n"
4347msgstr "" 3516msgstr ""
4348 3517
4349#: plugins/check_smtp.c:235
4350#, c-format 3518#, c-format
4351msgid "Server does not support STARTTLS\n" 3519msgid "Server does not support STARTTLS\n"
4352msgstr "" 3520msgstr ""
4353 3521
4354#: plugins/check_smtp.c:241
4355#, c-format
4356msgid "CRITICAL - Cannot create SSL context.\n"
4357msgstr ""
4358
4359#: plugins/check_smtp.c:261
4360msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS." 3522msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS."
4361msgstr "" 3523msgstr ""
4362 3524
4363#: plugins/check_smtp.c:266
4364#, c-format 3525#, c-format
4365msgid "sent %s" 3526msgid "sent %s"
4366msgstr "" 3527msgstr ""
4367 3528
4368#: plugins/check_smtp.c:268
4369msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS." 3529msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS."
4370msgstr "" 3530msgstr ""
4371 3531
4372#: plugins/check_smtp.c:303 plugins/check_snmp.c:806 3532#, fuzzy, c-format
3533msgid "Invalid SMTP response received from host: %s\n"
3534msgstr "Ungültige HTTP Antwort von Host empfangen\n"
3535
3536#, fuzzy, c-format
3537msgid "Invalid SMTP response received from host on port %d: %s\n"
3538msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
3539
4373#, c-format 3540#, c-format
4374msgid "Could Not Compile Regular Expression" 3541msgid "Could Not Compile Regular Expression"
4375msgstr "" 3542msgstr ""
4376 3543
4377#: plugins/check_smtp.c:312
4378#, c-format 3544#, c-format
4379msgid "SMTP %s - Invalid response '%s' to command '%s'\n" 3545msgid "SMTP %s - Invalid response '%s' to command '%s'\n"
4380msgstr "" 3546msgstr ""
4381 3547
4382#: plugins/check_smtp.c:316 plugins/check_snmp.c:511
4383#, c-format 3548#, c-format
4384msgid "Execute Error: %s\n" 3549msgid "Execute Error: %s\n"
4385msgstr "" 3550msgstr ""
4386 3551
4387#: plugins/check_smtp.c:330
4388msgid "no authuser specified, " 3552msgid "no authuser specified, "
4389msgstr "" 3553msgstr ""
4390 3554
4391#: plugins/check_smtp.c:335
4392msgid "no authpass specified, " 3555msgid "no authpass specified, "
4393msgstr "" 3556msgstr ""
4394 3557
4395#: plugins/check_smtp.c:342 plugins/check_smtp.c:363 plugins/check_smtp.c:383
4396#: plugins/check_smtp.c:688
4397#, c-format 3558#, c-format
4398msgid "sent %s\n" 3559msgid "sent %s\n"
4399msgstr "" 3560msgstr ""
4400 3561
4401#: plugins/check_smtp.c:345
4402#, fuzzy 3562#, fuzzy
4403msgid "recv() failed after AUTH LOGIN, " 3563msgid "recv() failed after AUTH LOGIN, "
4404msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3564msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4405 3565
4406#: plugins/check_smtp.c:350 plugins/check_smtp.c:371 plugins/check_smtp.c:391
4407#: plugins/check_smtp.c:699
4408#, fuzzy, c-format 3566#, fuzzy, c-format
4409msgid "received %s\n" 3567msgid "received %s\n"
4410msgstr "Keine Daten empfangen %s\n" 3568msgstr "Keine Daten empfangen %s\n"
4411 3569
4412#: plugins/check_smtp.c:354
4413#, fuzzy 3570#, fuzzy
4414msgid "invalid response received after AUTH LOGIN, " 3571msgid "invalid response received after AUTH LOGIN, "
4415msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3572msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4416 3573
4417#: plugins/check_smtp.c:367
4418msgid "recv() failed after sending authuser, " 3574msgid "recv() failed after sending authuser, "
4419msgstr "" 3575msgstr ""
4420 3576
4421#: plugins/check_smtp.c:375
4422#, fuzzy 3577#, fuzzy
4423msgid "invalid response received after authuser, " 3578msgid "invalid response received after authuser, "
4424msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3579msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4425 3580
4426#: plugins/check_smtp.c:387
4427msgid "recv() failed after sending authpass, " 3581msgid "recv() failed after sending authpass, "
4428msgstr "" 3582msgstr ""
4429 3583
4430#: plugins/check_smtp.c:395
4431#, fuzzy 3584#, fuzzy
4432msgid "invalid response received after authpass, " 3585msgid "invalid response received after authpass, "
4433msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3586msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4434 3587
4435#: plugins/check_smtp.c:402
4436msgid "only authtype LOGIN is supported, " 3588msgid "only authtype LOGIN is supported, "
4437msgstr "" 3589msgstr ""
4438 3590
4439#: plugins/check_smtp.c:426
4440#, fuzzy, c-format 3591#, fuzzy, c-format
4441msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n" 3592msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n"
4442msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n" 3593msgstr " - %s - %.3f Sekunden Antwortzeit %s%s|%s %s\n"
4443 3594
4444#: plugins/check_smtp.c:536 plugins/check_smtp.c:548
4445#, c-format 3595#, c-format
4446msgid "Could not realloc() units [%d]\n" 3596msgid "Could not realloc() units [%d]\n"
4447msgstr "" 3597msgstr ""
4448 3598
4449#: plugins/check_smtp.c:556
4450#, fuzzy 3599#, fuzzy
4451msgid "Critical time must be a positive" 3600msgid "Critical time must be a positive"
4452msgstr "Critical time muss ein positiver Integer sein" 3601msgstr "Critical time muss ein positiver Integer sein"
4453 3602
4454#: plugins/check_smtp.c:564
4455#, fuzzy 3603#, fuzzy
4456msgid "Warning time must be a positive" 3604msgid "Warning time must be a positive"
4457msgstr "Warnung time muss ein positiver Integer sein" 3605msgstr "Warnung time muss ein positiver Integer sein"
4458 3606
4459#: plugins/check_smtp.c:611
4460msgid "SSL support not available - install OpenSSL and recompile" 3607msgid "SSL support not available - install OpenSSL and recompile"
4461msgstr "" 3608msgstr ""
4462 3609
4463#: plugins/check_smtp.c:679 plugins/check_smtp.c:684 3610msgid "Set either -s/--ssl/--tls or -S/--starttls"
3611msgstr "Setze entweder -s/--ssl/--tls oder -S/--starttls"
3612
4464#, c-format 3613#, c-format
4465msgid "Connection closed by server before sending QUIT command\n" 3614msgid "Connection closed by server before sending QUIT command\n"
4466msgstr "" 3615msgstr ""
4467 3616
4468#: plugins/check_smtp.c:694
4469#, fuzzy, c-format 3617#, fuzzy, c-format
4470msgid "recv() failed after QUIT." 3618msgid "recv() failed after QUIT."
4471msgstr "Ungültige HTTP Antwort von Host empfangen\n" 3619msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4472 3620
4473#: plugins/check_smtp.c:696
4474#, c-format 3621#, c-format
4475msgid "Connection reset by peer." 3622msgid "Connection reset by peer."
4476msgstr "" 3623msgstr ""
4477 3624
4478#: plugins/check_smtp.c:784
4479#, fuzzy 3625#, fuzzy
4480msgid "This plugin will attempt to open an SMTP connection with the host." 3626msgid "This plugin will attempt to open an SMTP connection with the host."
4481msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 3627msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
4482 3628
4483#: plugins/check_smtp.c:798
4484#, c-format 3629#, c-format
4485msgid " String to expect in first line of server response (default: '%s')\n" 3630msgid " String to expect in first line of server response (default: '%s')\n"
4486msgstr "" 3631msgstr ""
4487 3632
4488#: plugins/check_smtp.c:800
4489msgid "SMTP command (may be used repeatedly)" 3633msgid "SMTP command (may be used repeatedly)"
4490msgstr "" 3634msgstr ""
4491 3635
4492#: plugins/check_smtp.c:802
4493msgid "Expected response to command (may be used repeatedly)" 3636msgid "Expected response to command (may be used repeatedly)"
4494msgstr "" 3637msgstr ""
4495 3638
4496#: plugins/check_smtp.c:804
4497msgid "FROM-address to include in MAIL command, required by Exchange 2000" 3639msgid "FROM-address to include in MAIL command, required by Exchange 2000"
4498msgstr "" 3640msgstr ""
4499 3641
4500#: plugins/check_smtp.c:806
4501msgid "FQDN used for HELO" 3642msgid "FQDN used for HELO"
4502msgstr "" 3643msgstr ""
4503 3644
4504#: plugins/check_smtp.c:809 plugins/check_tcp.c:665 3645msgid "Use PROXY protocol prefix for the connection."
3646msgstr "Benutze PROXY-Protokoll-Präfix für die Verbindung."
3647
4505msgid "Minimum number of days a certificate has to be valid." 3648msgid "Minimum number of days a certificate has to be valid."
4506msgstr "" 3649msgstr ""
4507 3650
4508#: plugins/check_smtp.c:811 3651#, fuzzy
3652msgid "Use SSL/TLS for the connection."
3653msgstr "Benutze SSL/TLS für die Verbindung."
3654
3655#, c-format
3656msgid " Sets default port to %d.\n"
3657msgstr " Setze den Default-Port auf %d.\n"
3658
4509msgid "Use STARTTLS for the connection." 3659msgid "Use STARTTLS for the connection."
4510msgstr "" 3660msgstr "Benutze STARTTLS für die Verbindung."
4511 3661
4512#: plugins/check_smtp.c:815
4513msgid "SMTP AUTH type to check (default none, only LOGIN supported)" 3662msgid "SMTP AUTH type to check (default none, only LOGIN supported)"
4514msgstr "" 3663msgstr ""
4515 3664
4516#: plugins/check_smtp.c:817
4517msgid "SMTP AUTH username" 3665msgid "SMTP AUTH username"
4518msgstr "" 3666msgstr ""
4519 3667
4520#: plugins/check_smtp.c:819
4521msgid "SMTP AUTH password" 3668msgid "SMTP AUTH password"
4522msgstr "" 3669msgstr ""
4523 3670
4524#: plugins/check_smtp.c:821 3671msgid "Send LHLO instead of HELO/EHLO"
3672msgstr ""
3673
4525msgid "Ignore failure when sending QUIT command to server" 3674msgid "Ignore failure when sending QUIT command to server"
4526msgstr "" 3675msgstr ""
4527 3676
4528#: plugins/check_smtp.c:831
4529msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful" 3677msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"
4530msgstr "" 3678msgstr ""
4531 3679
4532#: plugins/check_smtp.c:832
4533msgid "connects, but incorrect response messages from the host result in" 3680msgid "connects, but incorrect response messages from the host result in"
4534msgstr "" 3681msgstr ""
4535 3682
4536#: plugins/check_smtp.c:833
4537msgid "STATE_WARNING return values." 3683msgid "STATE_WARNING return values."
4538msgstr "" 3684msgstr ""
4539 3685
4540#: plugins/check_snmp.c:169 plugins/check_snmp.c:582
4541msgid "Cannot malloc" 3686msgid "Cannot malloc"
4542msgstr "" 3687msgstr ""
4543 3688
4544#: plugins/check_snmp.c:356
4545#, fuzzy, c-format 3689#, fuzzy, c-format
4546msgid "External command error: %s\n" 3690msgid "External command error: %s\n"
4547msgstr "Papierfehler" 3691msgstr "Papierfehler"
4548 3692
4549#: plugins/check_snmp.c:361
4550#, c-format 3693#, c-format
4551msgid "External command error with no output (return code: %d)\n" 3694msgid "External command error with no output (return code: %d)\n"
4552msgstr "" 3695msgstr ""
4553 3696
4554#: plugins/check_snmp.c:464
4555#, fuzzy, c-format 3697#, fuzzy, c-format
4556msgid "No valid data returned (%s)\n" 3698msgid "No valid data returned (%s)\n"
4557msgstr "Keine Daten empfangen %s\n" 3699msgstr "Keine Daten empfangen %s\n"
4558 3700
4559#: plugins/check_snmp.c:475
4560msgid "Time duration between plugin calls is invalid" 3701msgid "Time duration between plugin calls is invalid"
4561msgstr "" 3702msgstr ""
4562 3703
4563#: plugins/check_snmp.c:588
4564msgid "Cannot asprintf()" 3704msgid "Cannot asprintf()"
4565msgstr "" 3705msgstr ""
4566 3706
4567#: plugins/check_snmp.c:594
4568msgid "Cannot realloc()" 3707msgid "Cannot realloc()"
4569msgstr "" 3708msgstr ""
4570 3709
4571#: plugins/check_snmp.c:610
4572msgid "No previous data to calculate rate - assume okay" 3710msgid "No previous data to calculate rate - assume okay"
4573msgstr "" 3711msgstr ""
4574 3712
4575#: plugins/check_snmp.c:751
4576#, fuzzy 3713#, fuzzy
4577msgid "Retries interval must be a positive integer" 3714msgid "Retries interval must be a positive integer"
4578msgstr "Time interval muss ein positiver Integer sein" 3715msgstr "Time interval muss ein positiver Integer sein"
4579 3716
4580#: plugins/check_snmp.c:831 3717#, fuzzy
3718msgid "Exit status must be a positive integer"
3719msgstr "Maxbytes muss ein positiver Integer sein"
3720
4581#, fuzzy, c-format 3721#, fuzzy, c-format
4582msgid "Could not reallocate labels[%d]" 3722msgid "Could not reallocate labels[%d]"
4583msgstr "Konnte addr nicht zuweisen\n" 3723msgstr "Konnte addr nicht zuweisen\n"
4584 3724
4585#: plugins/check_snmp.c:844
4586#, fuzzy 3725#, fuzzy
4587msgid "Could not reallocate labels\n" 3726msgid "Could not reallocate labels\n"
4588msgstr "Konnte·url·nicht·zuweisen\n" 3727msgstr "Konnte·url·nicht·zuweisen\n"
4589 3728
4590#: plugins/check_snmp.c:860
4591#, fuzzy, c-format 3729#, fuzzy, c-format
4592msgid "Could not reallocate units [%d]\n" 3730msgid "Could not reallocate units [%d]\n"
4593msgstr "Konnte·url·nicht·zuweisen\n" 3731msgstr "Konnte·url·nicht·zuweisen\n"
4594 3732
4595#: plugins/check_snmp.c:872
4596msgid "Could not realloc() units\n" 3733msgid "Could not realloc() units\n"
4597msgstr "" 3734msgstr ""
4598 3735
4599#: plugins/check_snmp.c:889
4600#, fuzzy 3736#, fuzzy
4601msgid "Rate multiplier must be a positive integer" 3737msgid "Rate multiplier must be a positive integer"
4602msgstr "Paketgröße muss ein positiver Integer sein" 3738msgstr "Paketgröße muss ein positiver Integer sein"
4603 3739
4604#: plugins/check_snmp.c:947
4605#, fuzzy 3740#, fuzzy
4606msgid "No host specified\n" 3741msgid "No host specified\n"
4607msgstr "" 3742msgstr ""
4608"Kein Hostname angegeben\n" 3743"Kein Hostname angegeben\n"
4609"\n" 3744"\n"
4610 3745
4611#: plugins/check_snmp.c:951
4612#, fuzzy 3746#, fuzzy
4613msgid "No OIDs specified\n" 3747msgid "No OIDs specified\n"
4614msgstr "" 3748msgstr ""
4615"Kein Hostname angegeben\n" 3749"Kein Hostname angegeben\n"
4616"\n" 3750"\n"
4617 3751
4618#: plugins/check_snmp.c:973
4619msgid "Invalid seclevel"
4620msgstr ""
4621
4622#: plugins/check_snmp.c:980 plugins/check_snmp.c:983 plugins/check_snmp.c:1001
4623#, c-format 3752#, c-format
4624msgid "Required parameter: %s\n" 3753msgid "Required parameter: %s\n"
4625msgstr "" 3754msgstr ""
4626 3755
4627#: plugins/check_snmp.c:1022 3756msgid "Invalid seclevel"
3757msgstr ""
3758
4628msgid "Invalid SNMP version" 3759msgid "Invalid SNMP version"
4629msgstr "" 3760msgstr ""
4630 3761
4631#: plugins/check_snmp.c:1039
4632msgid "Unbalanced quotes\n" 3762msgid "Unbalanced quotes\n"
4633msgstr "" 3763msgstr ""
4634 3764
4635#: plugins/check_snmp.c:1088 3765#, c-format
3766msgid "multiplier set (%.1f), but input is not a number: %s"
3767msgstr ""
3768
4636msgid "Check status of remote machines and obtain system information via SNMP" 3769msgid "Check status of remote machines and obtain system information via SNMP"
4637msgstr "" 3770msgstr ""
4638 3771
4639#: plugins/check_snmp.c:1101
4640msgid "Use SNMP GETNEXT instead of SNMP GET" 3772msgid "Use SNMP GETNEXT instead of SNMP GET"
4641msgstr "" 3773msgstr ""
4642 3774
4643#: plugins/check_snmp.c:1103
4644msgid "SNMP protocol version" 3775msgid "SNMP protocol version"
4645msgstr "" 3776msgstr ""
4646 3777
4647#: plugins/check_snmp.c:1105 3778msgid "SNMPv3 context"
3779msgstr ""
3780
4648msgid "SNMPv3 securityLevel" 3781msgid "SNMPv3 securityLevel"
4649msgstr "" 3782msgstr ""
4650 3783
4651#: plugins/check_snmp.c:1107
4652msgid "SNMPv3 auth proto" 3784msgid "SNMPv3 auth proto"
4653msgstr "" 3785msgstr ""
4654 3786
4655#: plugins/check_snmp.c:1109
4656msgid "SNMPv3 priv proto (default DES)" 3787msgid "SNMPv3 priv proto (default DES)"
4657msgstr "" 3788msgstr ""
4658 3789
4659#: plugins/check_snmp.c:1113
4660msgid "Optional community string for SNMP communication" 3790msgid "Optional community string for SNMP communication"
4661msgstr "" 3791msgstr ""
4662 3792
4663#: plugins/check_snmp.c:1114
4664msgid "default is" 3793msgid "default is"
4665msgstr "" 3794msgstr ""
4666 3795
4667#: plugins/check_snmp.c:1116
4668msgid "SNMPv3 username" 3796msgid "SNMPv3 username"
4669msgstr "" 3797msgstr ""
4670 3798
4671#: plugins/check_snmp.c:1118
4672msgid "SNMPv3 authentication password" 3799msgid "SNMPv3 authentication password"
4673msgstr "" 3800msgstr ""
4674 3801
4675#: plugins/check_snmp.c:1120
4676msgid "SNMPv3 privacy password" 3802msgid "SNMPv3 privacy password"
4677msgstr "" 3803msgstr ""
4678 3804
4679#: plugins/check_snmp.c:1124
4680msgid "Object identifier(s) or SNMP variables whose value you wish to query" 3805msgid "Object identifier(s) or SNMP variables whose value you wish to query"
4681msgstr "" 3806msgstr ""
4682 3807
4683#: plugins/check_snmp.c:1126
4684msgid "" 3808msgid ""
4685"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'" 3809"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'"
4686msgstr "" 3810msgstr ""
4687 3811
4688#: plugins/check_snmp.c:1127
4689msgid "for symbolic OIDs.)" 3812msgid "for symbolic OIDs.)"
4690msgstr "" 3813msgstr ""
4691 3814
4692#: plugins/check_snmp.c:1129
4693msgid "Delimiter to use when parsing returned data. Default is" 3815msgid "Delimiter to use when parsing returned data. Default is"
4694msgstr "" 3816msgstr ""
4695 3817
4696#: plugins/check_snmp.c:1130
4697msgid "Any data on the right hand side of the delimiter is considered" 3818msgid "Any data on the right hand side of the delimiter is considered"
4698msgstr "" 3819msgstr ""
4699 3820
4700#: plugins/check_snmp.c:1131
4701msgid "to be the data that should be used in the evaluation." 3821msgid "to be the data that should be used in the evaluation."
4702msgstr "" 3822msgstr ""
4703 3823
4704#: plugins/check_snmp.c:1135 3824msgid "If the check returns a 0 length string or NULL value"
3825msgstr ""
3826
3827msgid "This option allows you to choose what status you want it to exit"
3828msgstr ""
3829
3830msgid "Excluding this option renders the default exit of 3(STATE_UNKNOWN)"
3831msgstr ""
3832
3833msgid "0 = OK"
3834msgstr ""
3835
3836#, fuzzy
3837msgid "1 = WARNING"
3838msgstr "WARNING"
3839
3840#, fuzzy
3841msgid "2 = CRITICAL"
3842msgstr "CRITICAL"
3843
3844#, fuzzy
3845msgid "3 = UNKNOWN"
3846msgstr "UNKNOWN"
3847
4705#, fuzzy 3848#, fuzzy
4706msgid "Warning threshold range(s)" 3849msgid "Warning threshold range(s)"
4707msgstr "Warning threshold Integer sein" 3850msgstr "Warning threshold Integer sein"
4708 3851
4709#: plugins/check_snmp.c:1137
4710#, fuzzy 3852#, fuzzy
4711msgid "Critical threshold range(s)" 3853msgid "Critical threshold range(s)"
4712msgstr "Critical threshold muss ein Integer sein" 3854msgstr "Critical threshold muss ein Integer sein"
4713 3855
4714#: plugins/check_snmp.c:1139
4715msgid "Enable rate calculation. See 'Rate Calculation' below" 3856msgid "Enable rate calculation. See 'Rate Calculation' below"
4716msgstr "" 3857msgstr ""
4717 3858
4718#: plugins/check_snmp.c:1141
4719msgid "" 3859msgid ""
4720"Converts rate per second. For example, set to 60 to convert to per minute" 3860"Converts rate per second. For example, set to 60 to convert to per minute"
4721msgstr "" 3861msgstr ""
4722 3862
4723#: plugins/check_snmp.c:1143 3863msgid "Add/subtract the specified OFFSET to numeric sensor data"
4724msgid "Add/substract the specified OFFSET to numeric sensor data"
4725msgstr "" 3864msgstr ""
4726 3865
4727#: plugins/check_snmp.c:1147
4728msgid "Return OK state (for that OID) if STRING is an exact match" 3866msgid "Return OK state (for that OID) if STRING is an exact match"
4729msgstr "" 3867msgstr ""
4730 3868
4731#: plugins/check_snmp.c:1149
4732msgid "" 3869msgid ""
4733"Return OK state (for that OID) if extended regular expression REGEX matches" 3870"Return OK state (for that OID) if extended regular expression REGEX matches"
4734msgstr "" 3871msgstr ""
4735 3872
4736#: plugins/check_snmp.c:1151
4737msgid "" 3873msgid ""
4738"Return OK state (for that OID) if case-insensitive extended REGEX matches" 3874"Return OK state (for that OID) if case-insensitive extended REGEX matches"
4739msgstr "" 3875msgstr ""
4740 3876
4741#: plugins/check_snmp.c:1153
4742msgid "Invert search result (CRITICAL if found)" 3877msgid "Invert search result (CRITICAL if found)"
4743msgstr "" 3878msgstr ""
4744 3879
4745#: plugins/check_snmp.c:1157
4746msgid "Prefix label for output from plugin" 3880msgid "Prefix label for output from plugin"
4747msgstr "" 3881msgstr ""
4748 3882
4749#: plugins/check_snmp.c:1159
4750msgid "Units label(s) for output data (e.g., 'sec.')." 3883msgid "Units label(s) for output data (e.g., 'sec.')."
4751msgstr "" 3884msgstr ""
4752 3885
4753#: plugins/check_snmp.c:1161
4754msgid "Separates output on multiple OID requests" 3886msgid "Separates output on multiple OID requests"
4755msgstr "" 3887msgstr ""
4756 3888
4757#: plugins/check_snmp.c:1165 3889msgid "Multiplies current value, 0 < n < 1 works as divider, defaults to 1"
4758msgid "Number of retries to be used in the requests" 3890msgstr ""
3891
3892msgid "C-style format string for float values (see option -M)"
3893msgstr ""
3894
3895msgid ""
3896"NOTE the final timeout value is calculated using this formula: "
3897"timeout_interval * retries + 5"
3898msgstr ""
3899
3900msgid "Number of retries to be used in the requests, default: "
4759msgstr "" 3901msgstr ""
4760 3902
4761#: plugins/check_snmp.c:1168
4762msgid "Label performance data with OIDs instead of --label's" 3903msgid "Label performance data with OIDs instead of --label's"
4763msgstr "" 3904msgstr ""
4764 3905
4765#: plugins/check_snmp.c:1173 3906msgid "Tell snmpget to not print errors encountered when parsing MIB files"
3907msgstr ""
3908
4766msgid "" 3909msgid ""
4767"This plugin uses the 'snmpget' command included with the NET-SNMP package." 3910"This plugin uses the 'snmpget' command included with the NET-SNMP package."
4768msgstr "" 3911msgstr ""
4769 3912
4770#: plugins/check_snmp.c:1174
4771msgid "" 3913msgid ""
4772"if you don't have the package installed, you will need to download it from" 3914"if you don't have the package installed, you will need to download it from"
4773msgstr "" 3915msgstr ""
4774 3916
4775#: plugins/check_snmp.c:1175
4776msgid "http://net-snmp.sourceforge.net before you can use this plugin." 3917msgid "http://net-snmp.sourceforge.net before you can use this plugin."
4777msgstr "" 3918msgstr ""
4778 3919
4779#: plugins/check_snmp.c:1179
4780msgid "" 3920msgid ""
4781"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited " 3921"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "
4782msgstr "" 3922msgstr ""
4783 3923
4784#: plugins/check_snmp.c:1180
4785msgid "list (lists with internal spaces must be quoted)." 3924msgid "list (lists with internal spaces must be quoted)."
4786msgstr "" 3925msgstr ""
4787 3926
4788#: plugins/check_snmp.c:1184
4789msgid "" 3927msgid ""
4790"- When checking multiple OIDs, separate ranges by commas like '-w " 3928"- When checking multiple OIDs, separate ranges by commas like '-w "
4791"1:10,1:,:20'" 3929"1:10,1:,:20'"
4792msgstr "" 3930msgstr ""
4793 3931
4794#: plugins/check_snmp.c:1185
4795msgid "- Note that only one string and one regex may be checked at present" 3932msgid "- Note that only one string and one regex may be checked at present"
4796msgstr "" 3933msgstr ""
4797 3934
4798#: plugins/check_snmp.c:1186
4799msgid "" 3935msgid ""
4800"- All evaluation methods other than PR, STR, and SUBSTR expect that the value" 3936"- All evaluation methods other than PR, STR, and SUBSTR expect that the value"
4801msgstr "" 3937msgstr ""
4802 3938
4803#: plugins/check_snmp.c:1187
4804msgid "returned from the SNMP query is an unsigned integer." 3939msgid "returned from the SNMP query is an unsigned integer."
4805msgstr "" 3940msgstr ""
4806 3941
4807#: plugins/check_snmp.c:1190
4808msgid "Rate Calculation:" 3942msgid "Rate Calculation:"
4809msgstr "" 3943msgstr ""
4810 3944
4811#: plugins/check_snmp.c:1191
4812msgid "In many places, SNMP returns counters that are only meaningful when" 3945msgid "In many places, SNMP returns counters that are only meaningful when"
4813msgstr "" 3946msgstr ""
4814 3947
4815#: plugins/check_snmp.c:1192
4816msgid "calculating the counter difference since the last check. check_snmp" 3948msgid "calculating the counter difference since the last check. check_snmp"
4817msgstr "" 3949msgstr ""
4818 3950
4819#: plugins/check_snmp.c:1193
4820msgid "saves the last state information in a file so that the rate per second" 3951msgid "saves the last state information in a file so that the rate per second"
4821msgstr "" 3952msgstr ""
4822 3953
4823#: plugins/check_snmp.c:1194
4824msgid "can be calculated. Use the --rate option to save state information." 3954msgid "can be calculated. Use the --rate option to save state information."
4825msgstr "" 3955msgstr ""
4826 3956
4827#: plugins/check_snmp.c:1195
4828msgid "" 3957msgid ""
4829"On the first run, there will be no prior state - this will return with OK." 3958"On the first run, there will be no prior state - this will return with OK."
4830msgstr "" 3959msgstr ""
4831 3960
4832#: plugins/check_snmp.c:1196
4833msgid "The state is uniquely determined by the arguments to the plugin, so" 3961msgid "The state is uniquely determined by the arguments to the plugin, so"
4834msgstr "" 3962msgstr ""
4835 3963
4836#: plugins/check_snmp.c:1197
4837msgid "changing the arguments will create a new state file." 3964msgid "changing the arguments will create a new state file."
4838msgstr "" 3965msgstr ""
4839 3966
4840#: plugins/check_ssh.c:165
4841#, fuzzy 3967#, fuzzy
4842msgid "Port number must be a positive integer" 3968msgid "Port number must be a positive integer"
4843msgstr "Port muss ein positiver Integer sein" 3969msgstr "Port muss ein positiver Integer sein"
4844 3970
4845#: plugins/check_ssh.c:232
4846#, c-format 3971#, c-format
4847msgid "Server answer: %s" 3972msgid "Server answer: %s"
4848msgstr "" 3973msgstr ""
4849 3974
4850#: plugins/check_ssh.c:251
4851#, c-format 3975#, c-format
4852msgid "SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n" 3976msgid "SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"
3977msgstr ""
3978
3979#, c-format
3980msgid ""
3981"SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"
4853msgstr "" 3982msgstr ""
4854 3983
4855#: plugins/check_ssh.c:260
4856#, c-format 3984#, c-format
4857msgid "SSH OK - %s (protocol %s) | %s\n" 3985msgid "SSH OK - %s (protocol %s) | %s\n"
4858msgstr "" 3986msgstr ""
4859 3987
4860#: plugins/check_ssh.c:281
4861msgid "Try to connect to an SSH server at specified server and port" 3988msgid "Try to connect to an SSH server at specified server and port"
4862msgstr "" 3989msgstr ""
4863 3990
4864#: plugins/check_ssh.c:297
4865msgid "" 3991msgid ""
4866"Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)" 3992"Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"
3993msgstr ""
3994
3995msgid "Alert if protocol doesn't match expected protocol version (ex: 2.0)"
4867msgstr "" 3996msgstr ""
4868 3997
4869#: plugins/check_swap.c:169
4870#, c-format 3998#, c-format
4871msgid "Command: %s\n" 3999msgid "Command: %s\n"
4872msgstr "" 4000msgstr ""
4873 4001
4874#: plugins/check_swap.c:171
4875#, c-format 4002#, c-format
4876msgid "Format: %s\n" 4003msgid "Format: %s\n"
4877msgstr "" 4004msgstr ""
4878 4005
4879#: plugins/check_swap.c:207
4880#, c-format 4006#, c-format
4881msgid "total=%.0f, used=%.0f, free=%.0f\n" 4007msgid "total=%.0f, used=%.0f, free=%.0f\n"
4882msgstr "" 4008msgstr ""
4883 4009
4884#: plugins/check_swap.c:221
4885#, c-format 4010#, c-format
4886msgid "total=%.0f, free=%.0f\n" 4011msgid "total=%.0f, free=%.0f\n"
4887msgstr "" 4012msgstr ""
4888 4013
4889#: plugins/check_swap.c:253
4890msgid "Error getting swap devices\n" 4014msgid "Error getting swap devices\n"
4891msgstr "" 4015msgstr ""
4892 4016
4893#: plugins/check_swap.c:256
4894msgid "SWAP OK: No swap devices defined\n" 4017msgid "SWAP OK: No swap devices defined\n"
4895msgstr "" 4018msgstr ""
4896 4019
4897#: plugins/check_swap.c:277 plugins/check_swap.c:319
4898msgid "swapctl failed: " 4020msgid "swapctl failed: "
4899msgstr "" 4021msgstr ""
4900 4022
4901#: plugins/check_swap.c:278 plugins/check_swap.c:320
4902msgid "Error in swapctl call\n" 4023msgid "Error in swapctl call\n"
4903msgstr "" 4024msgstr ""
4904 4025
4905#: plugins/check_swap.c:357
4906#, c-format 4026#, c-format
4907msgid "SWAP %s - %d%% free (%d MB out of %d MB) %s|" 4027msgid "SWAP %s - %d%% free (%dMB out of %dMB) %s|"
4908msgstr "" 4028msgstr ""
4909 4029
4910#: plugins/check_swap.c:435 4030#, fuzzy
4911msgid "Warning threshold must be integer or percentage!" 4031msgid "Warning threshold percentage must be <= 100!"
4032msgstr "Warning threshold Integer sein"
4033
4034#, fuzzy
4035msgid "Warning threshold be positive integer or percentage!"
4912msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein" 4036msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein"
4913 4037
4914#: plugins/check_swap.c:453 4038#, fuzzy
4915msgid "Critical threshold must be integer or percentage!" 4039msgid "Critical threshold percentage must be <= 100!"
4916msgstr "Critical threshold muss ein Integer oder ein Prozentwert sein!" 4040msgstr "Critical threshold muss ein Integer sein"
4917 4041
4918#: plugins/check_swap.c:507
4919#, fuzzy 4042#, fuzzy
4920msgid "Warning percentage should be more than critical percentage" 4043msgid "Critical threshold be positive integer or percentage!"
4921msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein" 4044msgstr "Critical threshold muss ein Integer oder ein Prozentwert sein!"
4922 4045
4923#: plugins/check_swap.c:511 4046msgid ""
4924msgid "Warning free space should be more than critical free space" 4047"no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
4048"or integer (0-3)."
4925msgstr "" 4049msgstr ""
4926 4050
4927#: plugins/check_swap.c:525 4051#, fuzzy
4052msgid "Warning should be more than critical"
4053msgstr "Warning threshold muss ein Integer oder ein Prozentwert sein"
4054
4928msgid "Check swap space on local machine." 4055msgid "Check swap space on local machine."
4929msgstr "" 4056msgstr ""
4930 4057
4931#: plugins/check_swap.c:535
4932msgid "" 4058msgid ""
4933"Exit with WARNING status if less than INTEGER bytes of swap space are free" 4059"Exit with WARNING status if less than INTEGER bytes of swap space are free"
4934msgstr "" 4060msgstr ""
4935 4061
4936#: plugins/check_swap.c:537
4937msgid "Exit with WARNING status if less than PERCENT of swap space is free" 4062msgid "Exit with WARNING status if less than PERCENT of swap space is free"
4938msgstr "" 4063msgstr ""
4939 4064
4940#: plugins/check_swap.c:539
4941msgid "" 4065msgid ""
4942"Exit with CRITICAL status if less than INTEGER bytes of swap space are free" 4066"Exit with CRITICAL status if less than INTEGER bytes of swap space are free"
4943msgstr "" 4067msgstr ""
4944 4068
4945#: plugins/check_swap.c:541 4069msgid "Exit with CRITICAL status if less than PERCENT of swap space is free"
4946msgid "Exit with CRITCAL status if less than PERCENT of swap space is free"
4947msgstr "" 4070msgstr ""
4948 4071
4949#: plugins/check_swap.c:543
4950msgid "Conduct comparisons for all swap partitions, one by one" 4072msgid "Conduct comparisons for all swap partitions, one by one"
4951msgstr "" 4073msgstr ""
4952 4074
4953#: plugins/check_swap.c:548 4075msgid ""
4076"Resulting state when there is no swap regardless of thresholds. Default:"
4077msgstr ""
4078
4079msgid ""
4080"Both INTEGER and PERCENT thresholds can be specified, they are all checked."
4081msgstr ""
4082
4954msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s." 4083msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."
4955msgstr "" 4084msgstr ""
4956 4085
4957#: plugins/check_tcp.c:206
4958msgid "CRITICAL - Generic check_tcp called with unknown service\n" 4086msgid "CRITICAL - Generic check_tcp called with unknown service\n"
4959msgstr "" 4087msgstr ""
4960 4088
4961#: plugins/check_tcp.c:230
4962msgid "With UDP checks, a send/expect string must be specified." 4089msgid "With UDP checks, a send/expect string must be specified."
4963msgstr "" 4090msgstr ""
4964 4091
4965#: plugins/check_tcp.c:431
4966msgid "No arguments found" 4092msgid "No arguments found"
4967msgstr "" 4093msgstr ""
4968 4094
4969#: plugins/check_tcp.c:534
4970msgid "Maxbytes must be a positive integer" 4095msgid "Maxbytes must be a positive integer"
4971msgstr "Maxbytes muss ein positiver Integer sein" 4096msgstr "Maxbytes muss ein positiver Integer sein"
4972 4097
4973#: plugins/check_tcp.c:552
4974msgid "Refuse must be one of ok, warn, crit" 4098msgid "Refuse must be one of ok, warn, crit"
4975msgstr "" 4099msgstr ""
4976 4100
4977#: plugins/check_tcp.c:562
4978msgid "Mismatch must be one of ok, warn, crit" 4101msgid "Mismatch must be one of ok, warn, crit"
4979msgstr "" 4102msgstr ""
4980 4103
4981#: plugins/check_tcp.c:568
4982msgid "Delay must be a positive integer" 4104msgid "Delay must be a positive integer"
4983msgstr "Delay muss ein positiver Integer sein" 4105msgstr "Delay muss ein positiver Integer sein"
4984 4106
4985#: plugins/check_tcp.c:613
4986#, fuzzy 4107#, fuzzy
4987msgid "You must provide a server address" 4108msgid "You must provide a server address"
4988msgstr "%s: Hostname muss angegeben werden\n" 4109msgstr "%s: Hostname muss angegeben werden\n"
4989 4110
4990#: plugins/check_tcp.c:615
4991#, fuzzy 4111#, fuzzy
4992msgid "Invalid hostname, address or socket" 4112msgid "Invalid hostname, address or socket"
4993msgstr "Ungültige(r) Hostname/Adresse" 4113msgstr "Ungültige(r) Hostname/Adresse"
4994 4114
4995#: plugins/check_tcp.c:629
4996#, fuzzy, c-format 4115#, fuzzy, c-format
4997msgid "" 4116msgid ""
4998"This plugin tests %s connections with the specified host (or unix socket).\n" 4117"This plugin tests %s connections with the specified host (or unix socket).\n"
4999"\n" 4118"\n"
5000msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host." 4119msgstr "Dieses plugin testet Gameserververbindungen zum angegebenen Host."
5001 4120
5002#: plugins/check_tcp.c:642
5003msgid "" 4121msgid ""
5004"Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or " 4122"Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send "
5005"quit option" 4123"or quit option"
5006msgstr "" 4124msgstr ""
5007 4125
5008#: plugins/check_tcp.c:643
5009msgid "Default: nothing added to send, \\r\\n added to end of quit" 4126msgid "Default: nothing added to send, \\r\\n added to end of quit"
5010msgstr "" 4127msgstr ""
5011 4128
5012#: plugins/check_tcp.c:645
5013msgid "String to send to the server" 4129msgid "String to send to the server"
5014msgstr "" 4130msgstr ""
5015 4131
5016#: plugins/check_tcp.c:647
5017msgid "String to expect in server response" 4132msgid "String to expect in server response"
5018msgstr "" 4133msgstr ""
5019 4134
5020#: plugins/check_tcp.c:647
5021msgid "(may be repeated)" 4135msgid "(may be repeated)"
5022msgstr "" 4136msgstr ""
5023 4137
5024#: plugins/check_tcp.c:649
5025msgid "All expect strings need to occur in server response. Default is any" 4138msgid "All expect strings need to occur in server response. Default is any"
5026msgstr "" 4139msgstr ""
5027 4140
5028#: plugins/check_tcp.c:651
5029msgid "String to send server to initiate a clean close of the connection" 4141msgid "String to send server to initiate a clean close of the connection"
5030msgstr "" 4142msgstr ""
5031 4143
5032#: plugins/check_tcp.c:653
5033msgid "Accept TCP refusals with states ok, warn, crit (default: crit)" 4144msgid "Accept TCP refusals with states ok, warn, crit (default: crit)"
5034msgstr "" 4145msgstr ""
5035 4146
5036#: plugins/check_tcp.c:655
5037msgid "" 4147msgid ""
5038"Accept expected string mismatches with states ok, warn, crit (default: warn)" 4148"Accept expected string mismatches with states ok, warn, crit (default: warn)"
5039msgstr "" 4149msgstr ""
5040 4150
5041#: plugins/check_tcp.c:657
5042#, fuzzy 4151#, fuzzy
5043msgid "Hide output from TCP socket" 4152msgid "Hide output from TCP socket"
5044msgstr "Konnte TCP socket nicht öffnen\n" 4153msgstr "Konnte TCP socket nicht öffnen\n"
5045 4154
5046#: plugins/check_tcp.c:659
5047msgid "Close connection once more than this number of bytes are received" 4155msgid "Close connection once more than this number of bytes are received"
5048msgstr "" 4156msgstr ""
5049 4157
5050#: plugins/check_tcp.c:661
5051msgid "Seconds to wait between sending string and polling for response" 4158msgid "Seconds to wait between sending string and polling for response"
5052msgstr "" 4159msgstr ""
5053 4160
5054#: plugins/check_tcp.c:666
5055msgid "1st is #days for warning, 2nd is critical (if not specified - 0)." 4161msgid "1st is #days for warning, 2nd is critical (if not specified - 0)."
5056msgstr "" 4162msgstr ""
5057 4163
5058#: plugins/check_tcp.c:668
5059msgid "Use SSL for the connection." 4164msgid "Use SSL for the connection."
5060msgstr "" 4165msgstr ""
5061 4166
5062#: plugins/check_time.c:102 4167msgid "SSL server_name"
4168msgstr ""
4169
5063#, c-format 4170#, c-format
5064msgid "TIME UNKNOWN - could not connect to server %s, port %d\n" 4171msgid "TIME UNKNOWN - could not connect to server %s, port %d\n"
5065msgstr "" 4172msgstr ""
5066 4173
5067#: plugins/check_time.c:115
5068#, c-format 4174#, c-format
5069msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n" 4175msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n"
5070msgstr "" 4176msgstr ""
5071 4177
5072#: plugins/check_time.c:139
5073#, c-format 4178#, c-format
5074msgid "TIME UNKNOWN - no data received from server %s, port %d\n" 4179msgid "TIME UNKNOWN - no data received from server %s, port %d\n"
5075msgstr "" 4180msgstr ""
5076 4181
5077#: plugins/check_time.c:152
5078#, c-format 4182#, c-format
5079msgid "TIME %s - %d second response time|%s\n" 4183msgid "TIME %s - %d second response time|%s\n"
5080msgstr "" 4184msgstr ""
5081 4185
5082#: plugins/check_time.c:170
5083#, c-format 4186#, c-format
5084msgid "TIME %s - %lu second time difference|%s %s\n" 4187msgid "TIME %s - %lu second time difference|%s %s\n"
5085msgstr "" 4188msgstr ""
5086 4189
5087#: plugins/check_time.c:254
5088msgid "Warning thresholds must be a positive integer" 4190msgid "Warning thresholds must be a positive integer"
5089msgstr "Warning thresholds muss ein positiver Integer sein" 4191msgstr "Warning thresholds muss ein positiver Integer sein"
5090 4192
5091#: plugins/check_time.c:273
5092msgid "Critical thresholds must be a positive integer" 4193msgid "Critical thresholds must be a positive integer"
5093msgstr "Critical thresholds muss ein positiver Integer sein" 4194msgstr "Critical thresholds muss ein positiver Integer sein"
5094 4195
5095#: plugins/check_time.c:339
5096#, fuzzy 4196#, fuzzy
5097msgid "This plugin will check the time on the specified host." 4197msgid "This plugin will check the time on the specified host."
5098msgstr "" 4198msgstr ""
5099"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 4199"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
5100"\n" 4200"\n"
5101 4201
5102#: plugins/check_time.c:351
5103msgid "Use UDP to connect, not TCP" 4202msgid "Use UDP to connect, not TCP"
5104msgstr "" 4203msgstr ""
5105 4204
5106#: plugins/check_time.c:353
5107msgid "Time difference (sec.) necessary to result in a warning status" 4205msgid "Time difference (sec.) necessary to result in a warning status"
5108msgstr "" 4206msgstr ""
5109 4207
5110#: plugins/check_time.c:355
5111msgid "Time difference (sec.) necessary to result in a critical status" 4208msgid "Time difference (sec.) necessary to result in a critical status"
5112msgstr "" 4209msgstr ""
5113 4210
5114#: plugins/check_time.c:357
5115msgid "Response time (sec.) necessary to result in warning status" 4211msgid "Response time (sec.) necessary to result in warning status"
5116msgstr "" 4212msgstr ""
5117 4213
5118#: plugins/check_time.c:359
5119msgid "Response time (sec.) necessary to result in critical status" 4214msgid "Response time (sec.) necessary to result in critical status"
5120msgstr "" 4215msgstr ""
5121 4216
5122#: plugins/check_ups.c:144
5123msgid "On Battery, Low Battery" 4217msgid "On Battery, Low Battery"
5124msgstr "" 4218msgstr ""
5125 4219
5126#: plugins/check_ups.c:149
5127msgid "Online" 4220msgid "Online"
5128msgstr "" 4221msgstr ""
5129 4222
5130#: plugins/check_ups.c:152
5131msgid "On Battery" 4223msgid "On Battery"
5132msgstr "" 4224msgstr ""
5133 4225
5134#: plugins/check_ups.c:156
5135msgid ", Low Battery" 4226msgid ", Low Battery"
5136msgstr "" 4227msgstr ""
5137 4228
5138#: plugins/check_ups.c:160
5139msgid ", Calibrating" 4229msgid ", Calibrating"
5140msgstr "" 4230msgstr ""
5141 4231
5142#: plugins/check_ups.c:163
5143msgid ", Replace Battery" 4232msgid ", Replace Battery"
5144msgstr "" 4233msgstr ""
5145 4234
5146#: plugins/check_ups.c:167
5147msgid ", On Bypass" 4235msgid ", On Bypass"
5148msgstr "" 4236msgstr ""
5149 4237
5150#: plugins/check_ups.c:170
5151msgid ", Overload" 4238msgid ", Overload"
5152msgstr "" 4239msgstr ""
5153 4240
5154#: plugins/check_ups.c:173
5155msgid ", Trimming" 4241msgid ", Trimming"
5156msgstr "" 4242msgstr ""
5157 4243
5158#: plugins/check_ups.c:176
5159msgid ", Boosting" 4244msgid ", Boosting"
5160msgstr "" 4245msgstr ""
5161 4246
5162#: plugins/check_ups.c:179
5163msgid ", Charging" 4247msgid ", Charging"
5164msgstr "" 4248msgstr ""
5165 4249
5166#: plugins/check_ups.c:182
5167msgid ", Discharging" 4250msgid ", Discharging"
5168msgstr "" 4251msgstr ""
5169 4252
5170#: plugins/check_ups.c:185
5171msgid ", Unknown" 4253msgid ", Unknown"
5172msgstr "" 4254msgstr ""
5173 4255
5174#: plugins/check_ups.c:324
5175#, fuzzy 4256#, fuzzy
5176msgid "UPS does not support any available options\n" 4257msgid "UPS does not support any available options\n"
5177msgstr "IPv6 Unterstützung nicht vorhanden" 4258msgstr "IPv6 Unterstützung nicht vorhanden"
5178 4259
5179#: plugins/check_ups.c:348 plugins/check_ups.c:411
5180#, fuzzy 4260#, fuzzy
5181msgid "Invalid response received from host" 4261msgid "Invalid response received from host"
5182msgstr "Ungültige HTTP Antwort von Host empfangen\n" 4262msgstr "Ungültige HTTP Antwort von Host empfangen\n"
4263
4264msgid "UPS name to long for buffer"
4265msgstr ""
5183 4266
5184#: plugins/check_ups.c:420
5185#, fuzzy, c-format 4267#, fuzzy, c-format
5186msgid "CRITICAL - no such UPS '%s' on that host\n" 4268msgid "CRITICAL - no such UPS '%s' on that host\n"
5187msgstr "%s [%s nicht gefunden]" 4269msgstr "%s [%s nicht gefunden]"
5188 4270
5189#: plugins/check_ups.c:430
5190#, fuzzy 4271#, fuzzy
5191msgid "CRITICAL - UPS data is stale" 4272msgid "CRITICAL - UPS data is stale"
5192msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden" 4273msgstr "CRITICAL - Serverdatum \"%100s\" konnte nicht verarbeitet werden"
5193 4274
5194#: plugins/check_ups.c:435
5195#, fuzzy, c-format 4275#, fuzzy, c-format
5196msgid "Unknown error: %s\n" 4276msgid "Unknown error: %s\n"
5197msgstr "Papierfehler" 4277msgstr "Papierfehler"
5198 4278
5199#: plugins/check_ups.c:442
5200msgid "Error: unable to parse variable" 4279msgid "Error: unable to parse variable"
5201msgstr "" 4280msgstr ""
5202 4281
5203#: plugins/check_ups.c:549
5204msgid "Unrecognized UPS variable" 4282msgid "Unrecognized UPS variable"
5205msgstr "" 4283msgstr ""
5206 4284
5207#: plugins/check_ups.c:587
5208msgid "Error : no UPS indicated" 4285msgid "Error : no UPS indicated"
5209msgstr "" 4286msgstr ""
5210 4287
5211#: plugins/check_ups.c:607
5212#, fuzzy 4288#, fuzzy
5213msgid "" 4289msgid ""
5214"This plugin tests the UPS service on the specified host. Network UPS Tools" 4290"This plugin tests the UPS service on the specified host. Network UPS Tools"
@@ -5216,479 +4292,409 @@ msgstr ""
5216"Testet den DNS Dienst auf dem angegebenen Host mit dig\n" 4292"Testet den DNS Dienst auf dem angegebenen Host mit dig\n"
5217"\n" 4293"\n"
5218 4294
5219#: plugins/check_ups.c:608
5220msgid "from www.networkupstools.org must be running for this plugin to work." 4295msgid "from www.networkupstools.org must be running for this plugin to work."
5221msgstr "" 4296msgstr ""
5222 4297
5223#: plugins/check_ups.c:620
5224msgid "Name of UPS" 4298msgid "Name of UPS"
5225msgstr "" 4299msgstr ""
5226 4300
5227#: plugins/check_ups.c:622
5228msgid "Output of temperatures in Celsius" 4301msgid "Output of temperatures in Celsius"
5229msgstr "" 4302msgstr ""
5230 4303
5231#: plugins/check_ups.c:624
5232msgid "Valid values for STRING are" 4304msgid "Valid values for STRING are"
5233msgstr "" 4305msgstr ""
5234 4306
5235#: plugins/check_ups.c:635
5236msgid "" 4307msgid ""
5237"This plugin attempts to determine the status of a UPS (Uninterruptible Power" 4308"This plugin attempts to determine the status of a UPS (Uninterruptible Power"
5238msgstr "" 4309msgstr ""
5239 4310
5240#: plugins/check_ups.c:636
5241msgid "" 4311msgid ""
5242"Supply) on a local or remote host. If the UPS is online or calibrating, the" 4312"Supply) on a local or remote host. If the UPS is online or calibrating, the"
5243msgstr "" 4313msgstr ""
5244 4314
5245#: plugins/check_ups.c:637
5246msgid "" 4315msgid ""
5247"plugin will return an OK state. If the battery is on it will return a WARNING" 4316"plugin will return an OK state. If the battery is on it will return a WARNING"
5248msgstr "" 4317msgstr ""
5249 4318
5250#: plugins/check_ups.c:638
5251msgid "" 4319msgid ""
5252"state. If the UPS is off or has a low battery the plugin will return a " 4320"state. If the UPS is off or has a low battery the plugin will return a "
5253"CRITICAL" 4321"CRITICAL"
5254msgstr "" 4322msgstr ""
5255 4323
5256#: plugins/check_ups.c:643
5257msgid "" 4324msgid ""
5258"You may also specify a variable to check (such as temperature, utility " 4325"You may also specify a variable to check (such as temperature, utility "
5259"voltage," 4326"voltage,"
5260msgstr "" 4327msgstr ""
5261 4328
5262#: plugins/check_ups.c:644
5263msgid "" 4329msgid ""
5264"battery load, etc.) as well as warning and critical thresholds for the value" 4330"battery load, etc.) as well as warning and critical thresholds for the value"
5265msgstr "" 4331msgstr ""
5266 4332
5267#: plugins/check_ups.c:645
5268msgid "" 4333msgid ""
5269"of that variable. If the remote host has multiple UPS that are being " 4334"of that variable. If the remote host has multiple UPS that are being "
5270"monitored" 4335"monitored"
5271msgstr "" 4336msgstr ""
5272 4337
5273#: plugins/check_ups.c:646
5274msgid "you will have to use the --ups option to specify which UPS to check." 4338msgid "you will have to use the --ups option to specify which UPS to check."
5275msgstr "" 4339msgstr ""
5276 4340
5277#: plugins/check_ups.c:648
5278msgid "" 4341msgid ""
5279"This plugin requires that the UPSD daemon distributed with Russell Kroll's" 4342"This plugin requires that the UPSD daemon distributed with Russell Kroll's"
5280msgstr "" 4343msgstr ""
5281 4344
5282#: plugins/check_ups.c:649
5283msgid "" 4345msgid ""
5284"Network UPS Tools be installed on the remote host. If you do not have the" 4346"Network UPS Tools be installed on the remote host. If you do not have the"
5285msgstr "" 4347msgstr ""
5286 4348
5287#: plugins/check_ups.c:650
5288msgid "package installed on your system, you can download it from" 4349msgid "package installed on your system, you can download it from"
5289msgstr "" 4350msgstr ""
5290 4351
5291#: plugins/check_ups.c:651
5292msgid "http://www.networkupstools.org" 4352msgid "http://www.networkupstools.org"
5293msgstr "" 4353msgstr ""
5294 4354
5295#: plugins/check_users.c:110 4355#, fuzzy, c-format
4356msgid "Could not enumerate RD sessions: %d\n"
4357msgstr "Konnte·url·nicht·zuweisen\n"
4358
5296#, c-format 4359#, c-format
5297msgid "# users=%d" 4360msgid "# users=%d"
5298msgstr "" 4361msgstr ""
5299 4362
5300#: plugins/check_users.c:133
5301msgid "Unable to read output" 4363msgid "Unable to read output"
5302msgstr "" 4364msgstr ""
5303 4365
5304#: plugins/check_users.c:140
5305#, c-format 4366#, c-format
5306msgid "USERS %s - %d users currently logged in |%s\n" 4367msgid "USERS %s - %d users currently logged in |%s\n"
5307msgstr "" 4368msgstr ""
5308 4369
5309#: plugins/check_users.c:219
5310#, fuzzy 4370#, fuzzy
5311msgid "This plugin checks the number of users currently logged in on the local" 4371msgid "This plugin checks the number of users currently logged in on the local"
5312msgstr "" 4372msgstr ""
5313"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n" 4373"Dieses Plugin prüft den freien Speicher auf einem gemounteten Filesystem\n"
5314"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte " 4374"und erzeugt einen Alarm wenn einer der angegebenen Schwellwerte "
5315"unterschritten wird.\n" 4375"unterschritten wird.\n"
5316"\n" 4376"\n"
5317 4377
5318#: plugins/check_users.c:220
5319msgid "" 4378msgid ""
5320"system and generates an error if the number exceeds the thresholds specified." 4379"system and generates an error if the number exceeds the thresholds specified."
5321msgstr "" 4380msgstr ""
5322 4381
5323#: plugins/check_users.c:230
5324msgid "Set WARNING status if more than INTEGER users are logged in" 4382msgid "Set WARNING status if more than INTEGER users are logged in"
5325msgstr "" 4383msgstr ""
5326 4384
5327#: plugins/check_users.c:232
5328msgid "Set CRITICAL status if more than INTEGER users are logged in" 4385msgid "Set CRITICAL status if more than INTEGER users are logged in"
5329msgstr "" 4386msgstr ""
5330 4387
5331#: plugins/check_ide_smart.c:256 4388msgid ""
4389"DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."
4390msgstr ""
4391
4392msgid "Nagios-compatible output is now always returned."
4393msgstr ""
4394
4395msgid "SMART commands are broken and have been disabled (See Notes in --help)."
4396msgstr ""
4397
4398msgid ""
4399"DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"
4400msgstr ""
4401
4402msgid "default and will be removed from future releases."
4403msgstr ""
4404
5332#, fuzzy, c-format 4405#, fuzzy, c-format
5333msgid "CRITICAL - Couldn't open device %s: %s\n" 4406msgid "CRITICAL - Couldn't open device %s: %s\n"
5334msgstr "CRITICAL - Device konnte nicht geöffnet werden: %s\n" 4407msgstr "CRITICAL - Device konnte nicht geöffnet werden: %s\n"
5335 4408
5336#: plugins/check_ide_smart.c:261
5337#, c-format 4409#, c-format
5338msgid "CRITICAL - SMART_CMD_ENABLE\n" 4410msgid "CRITICAL - SMART_CMD_ENABLE\n"
5339msgstr "" 4411msgstr ""
5340 4412
5341#: plugins/check_ide_smart.c:323 plugins/check_ide_smart.c:350
5342#, c-format 4413#, c-format
5343msgid "CRITICAL - SMART_READ_VALUES: %s\n" 4414msgid "CRITICAL - SMART_READ_VALUES: %s\n"
5344msgstr "" 4415msgstr ""
5345 4416
5346#: plugins/check_ide_smart.c:421
5347#, c-format 4417#, c-format
5348msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n" 4418msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"
5349msgstr "" 4419msgstr ""
5350 4420
5351#: plugins/check_ide_smart.c:429
5352#, c-format 4421#, c-format
5353msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n" 4422msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"
5354msgstr "" 4423msgstr ""
5355 4424
5356#: plugins/check_ide_smart.c:437
5357#, c-format 4425#, c-format
5358msgid "OK - Operational (%d/%d tests passed)\n" 4426msgid "OK - Operational (%d/%d tests passed)\n"
5359msgstr "" 4427msgstr ""
5360 4428
5361#: plugins/check_ide_smart.c:441
5362#, c-format 4429#, c-format
5363msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n" 4430msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n"
5364msgstr "" 4431msgstr ""
5365 4432
5366#: plugins/check_ide_smart.c:474
5367#, c-format 4433#, c-format
5368msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n" 4434msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"
5369msgstr "" 4435msgstr ""
5370 4436
5371#: plugins/check_ide_smart.c:480
5372#, c-format 4437#, c-format
5373msgid "OffLineCapability=%d {%s %s %s}\n" 4438msgid "OffLineCapability=%d {%s %s %s}\n"
5374msgstr "" 4439msgstr ""
5375 4440
5376#: plugins/check_ide_smart.c:486
5377#, c-format 4441#, c-format
5378msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n" 4442msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"
5379msgstr "" 4443msgstr ""
5380 4444
5381#: plugins/check_ide_smart.c:508 plugins/check_ide_smart.c:532
5382#, c-format 4445#, c-format
5383msgid "CRITICAL - %s: %s\n" 4446msgid "CRITICAL - %s: %s\n"
5384msgstr "" 4447msgstr ""
5385 4448
5386#: plugins/check_ide_smart.c:553 plugins/check_ide_smart.c:580 4449#, c-format
4450msgid "OK - Command sent (%s)\n"
4451msgstr ""
4452
5387#, c-format 4453#, c-format
5388msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n" 4454msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n"
5389msgstr "" 4455msgstr ""
5390 4456
5391#: plugins/check_ide_smart.c:599
5392#, c-format 4457#, c-format
5393msgid "" 4458msgid ""
5394"This plugin checks a local hard drive with the (Linux specific) SMART " 4459"This plugin checks a local hard drive with the (Linux specific) SMART "
5395"interface [http://smartlinux.sourceforge.net/smart/index.php]." 4460"interface [http://smartlinux.sourceforge.net/smart/index.php]."
5396msgstr "" 4461msgstr ""
5397 4462
5398#: plugins/check_ide_smart.c:609
5399msgid "Select device DEVICE" 4463msgid "Select device DEVICE"
5400msgstr "" 4464msgstr ""
5401 4465
5402#: plugins/check_ide_smart.c:610
5403msgid "" 4466msgid ""
5404"Note: if the device is selected with this option, _no_ other options are " 4467"Note: if the device is specified without this option, any further option will"
5405"accepted" 4468msgstr ""
4469
4470msgid "be ignored."
4471msgstr ""
4472
4473msgid ""
4474"The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"
5406msgstr "" 4475msgstr ""
5407 4476
5408#: plugins/check_ide_smart.c:612 4477msgid ""
5409msgid "Perform immediately offline tests" 4478"broken in an underhand manner and have been disabled. You can use smartctl"
5410msgstr "" 4479msgstr ""
5411 4480
5412#: plugins/check_ide_smart.c:614 4481msgid "instead:"
5413msgid "Returns the number of failed tests"
5414msgstr "" 4482msgstr ""
5415 4483
5416#: plugins/check_ide_smart.c:616 4484msgid "-0/--auto-off: use \"smartctl --offlineauto=off\""
5417msgid "Turn on automatic offline tests"
5418msgstr "" 4485msgstr ""
5419 4486
5420#: plugins/check_ide_smart.c:618 4487msgid "-1/--auto-on: use \"smartctl --offlineauto=on\""
5421msgid "Turn off automatic offline tests"
5422msgstr "" 4488msgstr ""
5423 4489
5424#: plugins/check_ide_smart.c:620 4490msgid "-i/--immediate: use \"smartctl --test=offline\""
5425msgid "Output suitable for the monitoring system"
5426msgstr "" 4491msgstr ""
5427 4492
5428#: plugins/negate.c:99
5429#, fuzzy 4493#, fuzzy
5430msgid "No data returned from command\n" 4494msgid "No data returned from command\n"
5431msgstr "Keine Daten empfangen %s\n" 4495msgstr "Keine Daten empfangen %s\n"
5432 4496
5433#: plugins/negate.c:170
5434msgid "" 4497msgid ""
5435"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) " 4498"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
5436"or integer (0-3)." 4499"or integer (0-3)."
5437msgstr "" 4500msgstr ""
5438 4501
5439#: plugins/negate.c:174
5440msgid "" 4502msgid ""
5441"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer (0-" 4503"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer "
5442"3)." 4504"(0-3)."
5443msgstr "" 4505msgstr ""
5444 4506
5445#: plugins/negate.c:180
5446msgid "" 4507msgid ""
5447"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4508"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5448"integer (0-3)." 4509"integer (0-3)."
5449msgstr "" 4510msgstr ""
5450 4511
5451#: plugins/negate.c:185
5452msgid "" 4512msgid ""
5453"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4513"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5454"integer (0-3)." 4514"integer (0-3)."
5455msgstr "" 4515msgstr ""
5456 4516
5457#: plugins/negate.c:190
5458msgid "" 4517msgid ""
5459"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4518"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5460"integer (0-3)." 4519"integer (0-3)."
5461msgstr "" 4520msgstr ""
5462 4521
5463#: plugins/negate.c:217
5464msgid "Require path to command" 4522msgid "Require path to command"
5465msgstr "" 4523msgstr ""
5466 4524
5467#: plugins/negate.c:246
5468msgid "" 4525msgid ""
5469"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)." 4526"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."
5470msgstr "" 4527msgstr ""
5471 4528
5472#: plugins/negate.c:247
5473msgid "Additional switches can be used to control which state becomes what." 4529msgid "Additional switches can be used to control which state becomes what."
5474msgstr "" 4530msgstr ""
5475 4531
5476#: plugins/negate.c:256
5477msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status." 4532msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status."
5478msgstr "" 4533msgstr ""
5479 4534
5480#: plugins/negate.c:258
5481msgid "Custom result on Negate timeouts; see below for STATUS definition\n" 4535msgid "Custom result on Negate timeouts; see below for STATUS definition\n"
5482msgstr "" 4536msgstr ""
5483 4537
5484#: plugins/negate.c:264
5485#, c-format 4538#, c-format
5486msgid "" 4539msgid ""
5487" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n" 4540" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n"
5488msgstr "" 4541msgstr ""
5489 4542
5490#: plugins/negate.c:265
5491#, c-format 4543#, c-format
5492msgid "" 4544msgid ""
5493" quotes. Numeric values are accepted. If nothing is specified, permutes\n" 4545" quotes. Numeric values are accepted. If nothing is specified, permutes\n"
5494msgstr "" 4546msgstr ""
5495 4547
5496#: plugins/negate.c:266
5497#, c-format 4548#, c-format
5498msgid " OK and CRITICAL.\n" 4549msgid " OK and CRITICAL.\n"
5499msgstr "" 4550msgstr ""
5500 4551
5501#: plugins/negate.c:268
5502#, c-format 4552#, c-format
5503msgid "" 4553msgid ""
5504" Substitute output text as well. Will only substitute text in CAPITALS\n" 4554" Substitute output text as well. Will only substitute text in CAPITALS\n"
5505msgstr "" 4555msgstr ""
5506 4556
5507#: plugins/negate.c:273
5508msgid "Run check_ping and invert result. Must use full path to plugin" 4557msgid "Run check_ping and invert result. Must use full path to plugin"
5509msgstr "" 4558msgstr ""
5510 4559
5511#: plugins/negate.c:275
5512msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL" 4560msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL"
5513msgstr "" 4561msgstr ""
5514 4562
5515#: plugins/negate.c:278
5516msgid "" 4563msgid ""
5517"This plugin is a wrapper to take the output of another plugin and invert it." 4564"This plugin is a wrapper to take the output of another plugin and invert it."
5518msgstr "" 4565msgstr ""
5519 4566
5520#: plugins/negate.c:279
5521msgid "The full path of the plugin must be provided." 4567msgid "The full path of the plugin must be provided."
5522msgstr "" 4568msgstr ""
5523 4569
5524#: plugins/negate.c:280
5525msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL." 4570msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL."
5526msgstr "" 4571msgstr ""
5527 4572
5528#: plugins/negate.c:281
5529msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK." 4573msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK."
5530msgstr "" 4574msgstr ""
5531 4575
5532#: plugins/negate.c:282
5533msgid "Otherwise, the output state of the wrapped plugin is unchanged." 4576msgid "Otherwise, the output state of the wrapped plugin is unchanged."
5534msgstr "" 4577msgstr ""
5535 4578
5536#: plugins/negate.c:284
5537msgid "" 4579msgid ""
5538"Using timeout-result, it is possible to override the timeout behaviour or a" 4580"Using timeout-result, it is possible to override the timeout behaviour or a"
5539msgstr "" 4581msgstr ""
5540 4582
5541#: plugins/negate.c:285
5542msgid "plugin by setting the negate timeout a bit lower." 4583msgid "plugin by setting the negate timeout a bit lower."
5543msgstr "" 4584msgstr ""
5544 4585
5545#: plugins/netutils.c:49
5546#, fuzzy, c-format 4586#, fuzzy, c-format
5547msgid "%s - Socket timeout after %d seconds\n" 4587msgid "%s - Socket timeout after %d seconds\n"
5548msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 4588msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5549 4589
5550#: plugins/netutils.c:51
5551#, fuzzy, c-format 4590#, fuzzy, c-format
5552msgid "%s - Abnormal timeout after %d seconds\n" 4591msgid "%s - Abnormal timeout after %d seconds\n"
5553msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 4592msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5554 4593
5555#: plugins/netutils.c:79 plugins/netutils.c:281
5556msgid "Send failed" 4594msgid "Send failed"
5557msgstr "" 4595msgstr ""
5558 4596
5559#: plugins/netutils.c:96 plugins/netutils.c:296
5560#, fuzzy 4597#, fuzzy
5561msgid "No data was received from host!" 4598msgid "No data was received from host!"
5562msgstr "Keine Daten empfangen %s\n" 4599msgstr "Keine Daten empfangen %s\n"
5563 4600
5564#: plugins/netutils.c:204 plugins/netutils.c:240
5565msgid "Socket creation failed" 4601msgid "Socket creation failed"
5566msgstr "" 4602msgstr ""
5567 4603
5568#: plugins/netutils.c:233
5569msgid "Supplied path too long unix domain socket" 4604msgid "Supplied path too long unix domain socket"
5570msgstr "" 4605msgstr ""
5571 4606
5572#: plugins/netutils.c:305
5573msgid "Receive failed" 4607msgid "Receive failed"
5574msgstr "" 4608msgstr ""
5575 4609
5576#: plugins/netutils.c:331 plugins-root/check_dhcp.c:1342
5577#, fuzzy, c-format 4610#, fuzzy, c-format
5578msgid "Invalid hostname/address - %s" 4611msgid "Invalid hostname/address - %s"
5579msgstr "" 4612msgstr ""
5580"Ungültige(r) Name/Adresse: %s\n" 4613"Ungültige(r) Name/Adresse: %s\n"
5581"\n" 4614"\n"
5582 4615
5583#: plugins/popen.c:142
5584#, fuzzy 4616#, fuzzy
5585msgid "Could not malloc argv array in popen()" 4617msgid "Could not malloc argv array in popen()"
5586msgstr "Konnte addr nicht zuweisen\n" 4618msgstr "Konnte addr nicht zuweisen\n"
5587 4619
5588#: plugins/popen.c:152
5589#, fuzzy 4620#, fuzzy
5590msgid "CRITICAL - You need more args!!!" 4621msgid "CRITICAL - You need more args!!!"
5591msgstr "CRITICAL - Fehler: %s\n" 4622msgstr "CRITICAL - Fehler: %s\n"
5592 4623
5593#: plugins/popen.c:209
5594#, fuzzy 4624#, fuzzy
5595msgid "Cannot catch SIGCHLD" 4625msgid "Cannot catch SIGCHLD"
5596msgstr "Konnte SIGALRM nicht erhalten" 4626msgstr "Konnte SIGALRM nicht erhalten"
5597 4627
5598#: plugins/popen.c:304
5599#, fuzzy, c-format 4628#, fuzzy, c-format
5600msgid "CRITICAL - Plugin timed out after %d seconds\n" 4629msgid "CRITICAL - Plugin timed out after %d seconds\n"
5601msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n" 4630msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5602 4631
5603#: plugins/popen.c:307
5604msgid "CRITICAL - popen timeout received, but no child process" 4632msgid "CRITICAL - popen timeout received, but no child process"
5605msgstr "" 4633msgstr ""
5606 4634
5607#: plugins/popen.c:323
5608msgid "sysconf error for _SC_OPEN_MAX"
5609msgstr ""
5610
5611#: plugins/urlize.c:130
5612#, c-format 4635#, c-format
5613msgid "" 4636msgid ""
5614"%s UNKNOWN - No data received from host\n" 4637"%s UNKNOWN - No data received from host\n"
5615"CMD: %s</A>\n" 4638"CMD: %s</A>\n"
5616msgstr "" 4639msgstr ""
5617 4640
5618#: plugins/urlize.c:169
5619msgid "" 4641msgid ""
5620"This plugin wraps the text output of another command (plugin) in HTML <A>" 4642"This plugin wraps the text output of another command (plugin) in HTML <A>"
5621msgstr "" 4643msgstr ""
5622 4644
5623#: plugins/urlize.c:170
5624msgid "" 4645msgid ""
5625"tags, thus displaying the child plugin's output as a clickable link in " 4646"tags, thus displaying the child plugin's output as a clickable link in "
5626"compatible" 4647"compatible"
5627msgstr "" 4648msgstr ""
5628 4649
5629#: plugins/urlize.c:171
5630msgid "" 4650msgid ""
5631"monitoring status screen. This plugin returns the status of the invoked " 4651"monitoring status screen. This plugin returns the status of the invoked "
5632"plugin." 4652"plugin."
5633msgstr "" 4653msgstr ""
5634 4654
5635#: plugins/urlize.c:181
5636msgid "" 4655msgid ""
5637"Pay close attention to quoting to ensure that the shell passes the expected" 4656"Pay close attention to quoting to ensure that the shell passes the expected"
5638msgstr "" 4657msgstr ""
5639 4658
5640#: plugins/urlize.c:182
5641msgid "data to the plugin. For example, in:" 4659msgid "data to the plugin. For example, in:"
5642msgstr "" 4660msgstr ""
5643 4661
5644#: plugins/urlize.c:183
5645msgid "urlize http://example.com/ check_http -H example.com -r 'two words'" 4662msgid "urlize http://example.com/ check_http -H example.com -r 'two words'"
5646msgstr "" 4663msgstr ""
5647 4664
5648#: plugins/urlize.c:184
5649msgid "the shell will remove the single quotes and urlize will see:" 4665msgid "the shell will remove the single quotes and urlize will see:"
5650msgstr "" 4666msgstr ""
5651 4667
5652#: plugins/urlize.c:185
5653msgid "urlize http://example.com/ check_http -H example.com -r two words" 4668msgid "urlize http://example.com/ check_http -H example.com -r two words"
5654msgstr "" 4669msgstr ""
5655 4670
5656#: plugins/urlize.c:186
5657msgid "You probably want:" 4671msgid "You probably want:"
5658msgstr "" 4672msgstr ""
5659 4673
5660#: plugins/urlize.c:187
5661msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\"" 4674msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\""
5662msgstr "" 4675msgstr ""
5663 4676
5664#: plugins/utils.c:174
5665#, fuzzy, c-format
5666msgid "%s - Plugin timed out after %d seconds\n"
5667msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
5668
5669#: plugins/utils.c:469
5670#, fuzzy 4677#, fuzzy
5671msgid "failed realloc in strpcpy\n" 4678msgid "failed realloc in strpcpy\n"
5672msgstr "konnte keinen Speicher für '%s' reservieren\n" 4679msgstr "konnte keinen Speicher für '%s' reservieren\n"
5673 4680
5674#: plugins/utils.c:511
5675#, fuzzy 4681#, fuzzy
5676msgid "failed malloc in strscat\n" 4682msgid "failed malloc in strscat\n"
5677msgstr "konnte keinen Speicher für '%s' reservieren\n" 4683msgstr "konnte keinen Speicher für '%s' reservieren\n"
5678 4684
5679#: plugins/utils.c:531
5680#, fuzzy 4685#, fuzzy
5681msgid "failed malloc in xvasprintf\n" 4686msgid "failed malloc in xvasprintf\n"
5682msgstr "konnte keinen Speicher für '%s' reservieren\n" 4687msgstr "konnte keinen Speicher für '%s' reservieren\n"
4688
4689msgid "sysconf error for _SC_OPEN_MAX\n"
4690msgstr ""
5683 4691
5684#: plugins/utils.h:137
5685#, c-format 4692#, c-format
5686msgid "" 4693msgid ""
5687" %s (-h | --help) for detailed help\n" 4694" %s (-h | --help) for detailed help\n"
5688" %s (-V | --version) for version information\n" 4695" %s (-V | --version) for version information\n"
5689msgstr "" 4696msgstr ""
5690 4697
5691#: plugins/utils.h:141
5692msgid "" 4698msgid ""
5693"\n" 4699"\n"
5694"Options:\n" 4700"Options:\n"
@@ -5698,7 +4704,6 @@ msgid ""
5698" Print version information\n" 4704" Print version information\n"
5699msgstr "" 4705msgstr ""
5700 4706
5701#: plugins/utils.h:148
5702#, c-format 4707#, c-format
5703msgid "" 4708msgid ""
5704" -H, --hostname=ADDRESS\n" 4709" -H, --hostname=ADDRESS\n"
@@ -5707,7 +4712,6 @@ msgid ""
5707" Port number (default: %s)\n" 4712" Port number (default: %s)\n"
5708msgstr "" 4713msgstr ""
5709 4714
5710#: plugins/utils.h:154
5711msgid "" 4715msgid ""
5712" -4, --use-ipv4\n" 4716" -4, --use-ipv4\n"
5713" Use IPv4 connection\n" 4717" Use IPv4 connection\n"
@@ -5715,14 +4719,12 @@ msgid ""
5715" Use IPv6 connection\n" 4719" Use IPv6 connection\n"
5716msgstr "" 4720msgstr ""
5717 4721
5718#: plugins/utils.h:160
5719msgid "" 4722msgid ""
5720" -v, --verbose\n" 4723" -v, --verbose\n"
5721" Show details for command-line debugging (output may be truncated by\n" 4724" Show details for command-line debugging (output may be truncated by\n"
5722"\t\tthe monitoring system)\n" 4725" the monitoring system)\n"
5723msgstr "" 4726msgstr ""
5724 4727
5725#: plugins/utils.h:165
5726msgid "" 4728msgid ""
5727" -w, --warning=DOUBLE\n" 4729" -w, --warning=DOUBLE\n"
5728" Response time to result in warning status (seconds)\n" 4730" Response time to result in warning status (seconds)\n"
@@ -5730,7 +4732,6 @@ msgid ""
5730" Response time to result in critical status (seconds)\n" 4732" Response time to result in critical status (seconds)\n"
5731msgstr "" 4733msgstr ""
5732 4734
5733#: plugins/utils.h:171
5734msgid "" 4735msgid ""
5735" -w, --warning=RANGE\n" 4736" -w, --warning=RANGE\n"
5736" Warning range (format: start:end). Alert if outside this range\n" 4737" Warning range (format: start:end). Alert if outside this range\n"
@@ -5738,14 +4739,18 @@ msgid ""
5738" Critical range\n" 4739" Critical range\n"
5739msgstr "" 4740msgstr ""
5740 4741
5741#: plugins/utils.h:177
5742#, c-format 4742#, c-format
5743msgid "" 4743msgid ""
5744" -t, --timeout=INTEGER\n" 4744" -t, --timeout=INTEGER\n"
5745" Seconds before connection times out (default: %d)\n" 4745" Seconds before connection times out (default: %d)\n"
5746msgstr "" 4746msgstr ""
5747 4747
5748#: plugins/utils.h:182 4748#, c-format
4749msgid ""
4750" -t, --timeout=INTEGER\n"
4751" Seconds before plugin times out (default: %d)\n"
4752msgstr ""
4753
5749msgid "" 4754msgid ""
5750" --extra-opts=[section][@file]\n" 4755" --extra-opts=[section][@file]\n"
5751" Read options from an ini file. See\n" 4756" Read options from an ini file. See\n"
@@ -5753,14 +4758,12 @@ msgid ""
5753" for usage and examples.\n" 4758" for usage and examples.\n"
5754msgstr "" 4759msgstr ""
5755 4760
5756#: plugins/utils.h:190
5757msgid "" 4761msgid ""
5758" See:\n" 4762" See:\n"
5759" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n" 4763" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n"
5760" for THRESHOLD format and examples.\n" 4764" for THRESHOLD format and examples.\n"
5761msgstr "" 4765msgstr ""
5762 4766
5763#: plugins/utils.h:195
5764msgid "" 4767msgid ""
5765"\n" 4768"\n"
5766"Send email to help@monitoring-plugins.org if you have questions regarding\n" 4769"Send email to help@monitoring-plugins.org if you have questions regarding\n"
@@ -5769,7 +4772,6 @@ msgid ""
5769"\n" 4772"\n"
5770msgstr "" 4773msgstr ""
5771 4774
5772#: plugins/utils.h:200
5773msgid "" 4775msgid ""
5774"\n" 4776"\n"
5775"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may " 4777"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may "
@@ -5778,410 +4780,332 @@ msgid ""
5778"For more information about these matters, see the file named COPYING.\n" 4780"For more information about these matters, see the file named COPYING.\n"
5779msgstr "" 4781msgstr ""
5780 4782
5781#: plugins-root/check_dhcp.c:320
5782#, c-format 4783#, c-format
5783msgid "Error: Could not get hardware address of interface '%s'\n" 4784msgid "Error: Could not get hardware address of interface '%s'\n"
5784msgstr "" 4785msgstr ""
5785 4786
5786#: plugins-root/check_dhcp.c:342
5787#, c-format 4787#, c-format
5788msgid "Error: if_nametoindex error - %s.\n" 4788msgid "Error: if_nametoindex error - %s.\n"
5789msgstr "" 4789msgstr ""
5790 4790
5791#: plugins-root/check_dhcp.c:347
5792#, c-format 4791#, c-format
5793msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n" 4792msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"
5794msgstr "" 4793msgstr ""
5795 4794
5796#: plugins-root/check_dhcp.c:352
5797#, c-format 4795#, c-format
5798msgid "" 4796msgid ""
5799"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n" 4797"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"
5800msgstr "" 4798msgstr ""
5801 4799
5802#: plugins-root/check_dhcp.c:357
5803#, c-format 4800#, c-format
5804msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n" 4801msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"
5805msgstr "" 4802msgstr ""
5806 4803
5807#: plugins-root/check_dhcp.c:388
5808#, c-format 4804#, c-format
5809msgid "" 4805msgid ""
5810"Error: can't find unit number in interface_name (%s) - expecting TypeNumber " 4806"Error: can't find unit number in interface_name (%s) - expecting TypeNumber "
5811"eg lnc0.\n" 4807"eg lnc0.\n"
5812msgstr "" 4808msgstr ""
5813 4809
5814#: plugins-root/check_dhcp.c:393 plugins-root/check_dhcp.c:405
5815#, c-format 4810#, c-format
5816msgid "" 4811msgid ""
5817"Error: can't read MAC address from DLPI streams interface for device %s unit " 4812"Error: can't read MAC address from DLPI streams interface for device %s unit "
5818"%d.\n" 4813"%d.\n"
5819msgstr "" 4814msgstr ""
5820 4815
5821#: plugins-root/check_dhcp.c:411
5822#, c-format 4816#, c-format
5823msgid "" 4817msgid ""
5824"Error: can't get MAC address for this architecture. Use the --mac option.\n" 4818"Error: can't get MAC address for this architecture. Use the --mac option.\n"
5825msgstr "" 4819msgstr ""
5826 4820
5827#: plugins-root/check_dhcp.c:430
5828#, c-format 4821#, c-format
5829msgid "Error: Cannot determine IP address of interface %s\n" 4822msgid "Error: Cannot determine IP address of interface %s\n"
5830msgstr "" 4823msgstr ""
5831 4824
5832#: plugins-root/check_dhcp.c:438
5833#, c-format 4825#, c-format
5834msgid "Error: Cannot get interface IP address on this platform.\n" 4826msgid "Error: Cannot get interface IP address on this platform.\n"
5835msgstr "" 4827msgstr ""
5836 4828
5837#: plugins-root/check_dhcp.c:443
5838#, c-format 4829#, c-format
5839msgid "Pretending to be relay client %s\n" 4830msgid "Pretending to be relay client %s\n"
5840msgstr "" 4831msgstr ""
5841 4832
5842#: plugins-root/check_dhcp.c:528
5843#, c-format 4833#, c-format
5844msgid "DHCPDISCOVER to %s port %d\n" 4834msgid "DHCPDISCOVER to %s port %d\n"
5845msgstr "" 4835msgstr ""
5846 4836
5847#: plugins-root/check_dhcp.c:580
5848#, c-format 4837#, c-format
5849msgid "Result=ERROR\n" 4838msgid "Result=ERROR\n"
5850msgstr "" 4839msgstr ""
5851 4840
5852#: plugins-root/check_dhcp.c:586
5853#, c-format 4841#, c-format
5854msgid "Result=OK\n" 4842msgid "Result=OK\n"
5855msgstr "" 4843msgstr ""
5856 4844
5857#: plugins-root/check_dhcp.c:596
5858#, c-format 4845#, c-format
5859msgid "DHCPOFFER from IP address %s" 4846msgid "DHCPOFFER from IP address %s"
5860msgstr "" 4847msgstr ""
5861 4848
5862#: plugins-root/check_dhcp.c:597
5863#, c-format 4849#, c-format
5864msgid " via %s\n" 4850msgid " via %s\n"
5865msgstr "" 4851msgstr ""
5866 4852
5867#: plugins-root/check_dhcp.c:604
5868#, c-format 4853#, c-format
5869msgid "" 4854msgid ""
5870"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n" 4855"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"
5871msgstr "" 4856msgstr ""
5872 4857
5873#: plugins-root/check_dhcp.c:626
5874#, c-format 4858#, c-format
5875msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n" 4859msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n"
5876msgstr "" 4860msgstr ""
5877 4861
5878#: plugins-root/check_dhcp.c:644
5879#, c-format 4862#, c-format
5880msgid "Total responses seen on the wire: %d\n" 4863msgid "Total responses seen on the wire: %d\n"
5881msgstr "" 4864msgstr ""
5882 4865
5883#: plugins-root/check_dhcp.c:645
5884#, fuzzy, c-format 4866#, fuzzy, c-format
5885msgid "Valid responses for this machine: %d\n" 4867msgid "Valid responses for this machine: %d\n"
5886msgstr "Keine Antwort vom Host \n" 4868msgstr "Keine Antwort vom Host \n"
5887 4869
5888#: plugins-root/check_dhcp.c:660
5889#, c-format 4870#, c-format
5890msgid "send_dhcp_packet result: %d\n" 4871msgid "send_dhcp_packet result: %d\n"
5891msgstr "" 4872msgstr ""
5892 4873
5893#: plugins-root/check_dhcp.c:693
5894#, fuzzy, c-format 4874#, fuzzy, c-format
5895msgid "No (more) data received (nfound: %d)\n" 4875msgid "No (more) data received (nfound: %d)\n"
5896msgstr "Keine Daten empfangen %s\n" 4876msgstr "Keine Daten empfangen %s\n"
5897 4877
5898#: plugins-root/check_dhcp.c:712
5899#, c-format 4878#, c-format
5900msgid "recvfrom() failed, " 4879msgid "recvfrom() failed, "
5901msgstr "" 4880msgstr ""
5902 4881
5903#: plugins-root/check_dhcp.c:719
5904#, c-format 4882#, c-format
5905msgid "receive_dhcp_packet() result: %d\n" 4883msgid "receive_dhcp_packet() result: %d\n"
5906msgstr "" 4884msgstr ""
5907 4885
5908#: plugins-root/check_dhcp.c:720
5909#, c-format 4886#, c-format
5910msgid "receive_dhcp_packet() source: %s\n" 4887msgid "receive_dhcp_packet() source: %s\n"
5911msgstr "" 4888msgstr ""
5912 4889
5913#: plugins-root/check_dhcp.c:750
5914#, c-format 4890#, c-format
5915msgid "Error: Could not create socket!\n" 4891msgid "Error: Could not create socket!\n"
5916msgstr "" 4892msgstr ""
5917 4893
5918#: plugins-root/check_dhcp.c:760
5919#, c-format 4894#, c-format
5920msgid "Error: Could not set reuse address option on DHCP socket!\n" 4895msgid "Error: Could not set reuse address option on DHCP socket!\n"
5921msgstr "" 4896msgstr ""
5922 4897
5923#: plugins-root/check_dhcp.c:766
5924#, c-format 4898#, c-format
5925msgid "Error: Could not set broadcast option on DHCP socket!\n" 4899msgid "Error: Could not set broadcast option on DHCP socket!\n"
5926msgstr "" 4900msgstr ""
5927 4901
5928#: plugins-root/check_dhcp.c:775
5929#, c-format 4902#, c-format
5930msgid "" 4903msgid ""
5931"Error: Could not bind socket to interface %s. Check your privileges...\n" 4904"Error: Could not bind socket to interface %s. Check your privileges...\n"
5932msgstr "" 4905msgstr ""
5933 4906
5934#: plugins-root/check_dhcp.c:786
5935#, c-format 4907#, c-format
5936msgid "" 4908msgid ""
5937"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n" 4909"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"
5938msgstr "" 4910msgstr ""
5939 4911
5940#: plugins-root/check_dhcp.c:820
5941#, c-format 4912#, c-format
5942msgid "Requested server address: %s\n" 4913msgid "Requested server address: %s\n"
5943msgstr "" 4914msgstr ""
5944 4915
5945#: plugins-root/check_dhcp.c:882
5946#, c-format 4916#, c-format
5947msgid "Lease Time: Infinite\n" 4917msgid "Lease Time: Infinite\n"
5948msgstr "" 4918msgstr ""
5949 4919
5950#: plugins-root/check_dhcp.c:884
5951#, c-format 4920#, c-format
5952msgid "Lease Time: %lu seconds\n" 4921msgid "Lease Time: %lu seconds\n"
5953msgstr "" 4922msgstr ""
5954 4923
5955#: plugins-root/check_dhcp.c:886
5956#, c-format 4924#, c-format
5957msgid "Renewal Time: Infinite\n" 4925msgid "Renewal Time: Infinite\n"
5958msgstr "" 4926msgstr ""
5959 4927
5960#: plugins-root/check_dhcp.c:888
5961#, c-format 4928#, c-format
5962msgid "Renewal Time: %lu seconds\n" 4929msgid "Renewal Time: %lu seconds\n"
5963msgstr "" 4930msgstr ""
5964 4931
5965#: plugins-root/check_dhcp.c:890
5966#, c-format 4932#, c-format
5967msgid "Rebinding Time: Infinite\n" 4933msgid "Rebinding Time: Infinite\n"
5968msgstr "" 4934msgstr ""
5969 4935
5970#: plugins-root/check_dhcp.c:891
5971#, c-format 4936#, c-format
5972msgid "Rebinding Time: %lu seconds\n" 4937msgid "Rebinding Time: %lu seconds\n"
5973msgstr "" 4938msgstr ""
5974 4939
5975#: plugins-root/check_dhcp.c:919
5976#, c-format 4940#, c-format
5977msgid "Added offer from server @ %s" 4941msgid "Added offer from server @ %s"
5978msgstr "" 4942msgstr ""
5979 4943
5980#: plugins-root/check_dhcp.c:920
5981#, c-format 4944#, c-format
5982msgid " of IP address %s\n" 4945msgid " of IP address %s\n"
5983msgstr "" 4946msgstr ""
5984 4947
5985#: plugins-root/check_dhcp.c:987
5986#, c-format 4948#, c-format
5987msgid "DHCP Server Match: Offerer=%s" 4949msgid "DHCP Server Match: Offerer=%s"
5988msgstr "" 4950msgstr ""
5989 4951
5990#: plugins-root/check_dhcp.c:988
5991#, c-format 4952#, c-format
5992msgid " Requested=%s" 4953msgid " Requested=%s"
5993msgstr "" 4954msgstr ""
5994 4955
5995#: plugins-root/check_dhcp.c:990
5996#, c-format 4956#, c-format
5997msgid " (duplicate)" 4957msgid " (duplicate)"
5998msgstr "" 4958msgstr ""
5999 4959
6000#: plugins-root/check_dhcp.c:991
6001#, c-format 4960#, c-format
6002msgid "\n" 4961msgid "\n"
6003msgstr "" 4962msgstr ""
6004 4963
6005#: plugins-root/check_dhcp.c:1039
6006#, c-format 4964#, c-format
6007msgid "No DHCPOFFERs were received.\n" 4965msgid "No DHCPOFFERs were received.\n"
6008msgstr "" 4966msgstr ""
6009 4967
6010#: plugins-root/check_dhcp.c:1043
6011#, c-format 4968#, c-format
6012msgid "Received %d DHCPOFFER(s)" 4969msgid "Received %d DHCPOFFER(s)"
6013msgstr "" 4970msgstr ""
6014 4971
6015#: plugins-root/check_dhcp.c:1046
6016#, c-format 4972#, c-format
6017msgid ", %s%d of %d requested servers responded" 4973msgid ", %s%d of %d requested servers responded"
6018msgstr "" 4974msgstr ""
6019 4975
6020#: plugins-root/check_dhcp.c:1049
6021#, c-format 4976#, c-format
6022msgid ", requested address (%s) was %soffered" 4977msgid ", requested address (%s) was %soffered"
6023msgstr "" 4978msgstr ""
6024 4979
6025#: plugins-root/check_dhcp.c:1049
6026msgid "not " 4980msgid "not "
6027msgstr "" 4981msgstr ""
6028 4982
6029#: plugins-root/check_dhcp.c:1051
6030#, c-format 4983#, c-format
6031msgid ", max lease time = " 4984msgid ", max lease time = "
6032msgstr "" 4985msgstr ""
6033 4986
6034#: plugins-root/check_dhcp.c:1053
6035#, c-format 4987#, c-format
6036msgid "Infinity" 4988msgid "Infinity"
6037msgstr "" 4989msgstr ""
6038 4990
6039#: plugins-root/check_dhcp.c:1234 4991msgid "Got unexpected non-option argument"
4992msgstr ""
4993
6040#, c-format 4994#, c-format
6041msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n" 4995msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"
6042msgstr "" 4996msgstr ""
6043 4997
6044#: plugins-root/check_dhcp.c:1246
6045#, c-format 4998#, c-format
6046msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n" 4999msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"
6047msgstr "" 5000msgstr ""
6048 5001
6049#: plugins-root/check_dhcp.c:1259
6050#, c-format 5002#, c-format
6051msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n" 5003msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"
6052msgstr "" 5004msgstr ""
6053 5005
6054#: plugins-root/check_dhcp.c:1271
6055#, c-format 5006#, c-format
6056msgid "" 5007msgid ""
6057"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n" 5008"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"
6058msgstr "" 5009msgstr ""
6059 5010
6060#: plugins-root/check_dhcp.c:1295
6061#, c-format 5011#, c-format
6062msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n" 5012msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"
6063msgstr "" 5013msgstr ""
6064 5014
6065#: plugins-root/check_dhcp.c:1374
6066#, c-format 5015#, c-format
6067msgid "Hardware address: " 5016msgid "Hardware address: "
6068msgstr "" 5017msgstr ""
6069 5018
6070#: plugins-root/check_dhcp.c:1390
6071msgid "This plugin tests the availability of DHCP servers on a network." 5019msgid "This plugin tests the availability of DHCP servers on a network."
6072msgstr "" 5020msgstr ""
6073 5021
6074#: plugins-root/check_dhcp.c:1402
6075msgid "IP address of DHCP server that we must hear from" 5022msgid "IP address of DHCP server that we must hear from"
6076msgstr "" 5023msgstr ""
6077 5024
6078#: plugins-root/check_dhcp.c:1404
6079msgid "IP address that should be offered by at least one DHCP server" 5025msgid "IP address that should be offered by at least one DHCP server"
6080msgstr "" 5026msgstr ""
6081 5027
6082#: plugins-root/check_dhcp.c:1406
6083msgid "Seconds to wait for DHCPOFFER before timeout occurs" 5028msgid "Seconds to wait for DHCPOFFER before timeout occurs"
6084msgstr "" 5029msgstr ""
6085 5030
6086#: plugins-root/check_dhcp.c:1408
6087msgid "Interface to to use for listening (i.e. eth0)" 5031msgid "Interface to to use for listening (i.e. eth0)"
6088msgstr "" 5032msgstr ""
6089 5033
6090#: plugins-root/check_dhcp.c:1410
6091msgid "MAC address to use in the DHCP request" 5034msgid "MAC address to use in the DHCP request"
6092msgstr "" 5035msgstr ""
6093 5036
6094#: plugins-root/check_dhcp.c:1412
6095msgid "Unicast testing: mimic a DHCP relay, requires -s" 5037msgid "Unicast testing: mimic a DHCP relay, requires -s"
6096msgstr "" 5038msgstr ""
6097 5039
6098#: plugins-root/check_icmp.c:1295
6099msgid "specify a target" 5040msgid "specify a target"
6100msgstr "" 5041msgstr ""
6101 5042
6102#: plugins-root/check_icmp.c:1297 5043msgid "Use IPv4 (default) or IPv6 to communicate with the targets"
5044msgstr ""
5045
6103#, fuzzy 5046#, fuzzy
6104msgid "warning threshold (currently " 5047msgid "warning threshold (currently "
6105msgstr "Warning threshold Integer sein" 5048msgstr "Warning threshold Integer sein"
6106 5049
6107#: plugins-root/check_icmp.c:1300
6108#, fuzzy 5050#, fuzzy
6109msgid "critical threshold (currently " 5051msgid "critical threshold (currently "
6110msgstr "Critical threshold muss ein Integer sein" 5052msgstr "Critical threshold muss ein Integer sein"
6111 5053
6112#: plugins-root/check_icmp.c:1303
6113#, fuzzy 5054#, fuzzy
6114msgid "specify a source IP address or device name" 5055msgid "specify a source IP address or device name"
6115msgstr "Hostname oder Serveradresse muss angegeben werden" 5056msgstr "Hostname oder Serveradresse muss angegeben werden"
6116 5057
6117#: plugins-root/check_icmp.c:1305
6118msgid "number of packets to send (currently " 5058msgid "number of packets to send (currently "
6119msgstr "" 5059msgstr ""
6120 5060
6121#: plugins-root/check_icmp.c:1308
6122msgid "max packet interval (currently " 5061msgid "max packet interval (currently "
6123msgstr "" 5062msgstr ""
6124 5063
6125#: plugins-root/check_icmp.c:1311
6126msgid "max target interval (currently " 5064msgid "max target interval (currently "
6127msgstr "" 5065msgstr ""
6128 5066
6129#: plugins-root/check_icmp.c:1314
6130msgid "number of alive hosts required for success" 5067msgid "number of alive hosts required for success"
6131msgstr "" 5068msgstr ""
6132 5069
6133#: plugins-root/check_icmp.c:1317
6134msgid "TTL on outgoing packets (currently " 5070msgid "TTL on outgoing packets (currently "
6135msgstr "" 5071msgstr ""
6136 5072
6137#: plugins-root/check_icmp.c:1320
6138msgid "timeout value (seconds, currently " 5073msgid "timeout value (seconds, currently "
6139msgstr "" 5074msgstr ""
6140 5075
6141#: plugins-root/check_icmp.c:1323
6142msgid "Number of icmp data bytes to send" 5076msgid "Number of icmp data bytes to send"
6143msgstr "" 5077msgstr ""
6144 5078
6145#: plugins-root/check_icmp.c:1324
6146msgid "Packet size will be data bytes + icmp header (currently" 5079msgid "Packet size will be data bytes + icmp header (currently"
6147msgstr "" 5080msgstr ""
6148 5081
6149#: plugins-root/check_icmp.c:1326
6150msgid "verbose" 5082msgid "verbose"
6151msgstr "" 5083msgstr ""
6152 5084
6153#: plugins-root/check_icmp.c:1330
6154msgid "The -H switch is optional. Naming a host (or several) to check is not." 5085msgid "The -H switch is optional. Naming a host (or several) to check is not."
6155msgstr "" 5086msgstr ""
6156 5087
6157#: plugins-root/check_icmp.c:1332
6158msgid "" 5088msgid ""
6159"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%" 5089"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"
6160msgstr "" 5090msgstr ""
6161 5091
6162#: plugins-root/check_icmp.c:1333
6163msgid "packet loss. The default values should work well for most users." 5092msgid "packet loss. The default values should work well for most users."
6164msgstr "" 5093msgstr ""
6165 5094
6166#: plugins-root/check_icmp.c:1334
6167msgid "" 5095msgid ""
6168"You can specify different RTA factors using the standardized abbreviations" 5096"You can specify different RTA factors using the standardized abbreviations"
6169msgstr "" 5097msgstr ""
6170 5098
6171#: plugins-root/check_icmp.c:1335
6172msgid "" 5099msgid ""
6173"us (microseconds), ms (milliseconds, default) or just plain s for seconds." 5100"us (microseconds), ms (milliseconds, default) or just plain s for seconds."
6174msgstr "" 5101msgstr ""
6175 5102
6176#: plugins-root/check_icmp.c:1341
6177msgid "The -v switch can be specified several times for increased verbosity." 5103msgid "The -v switch can be specified several times for increased verbosity."
6178msgstr "" 5104msgstr ""
6179 5105
6180#~ msgid "Critical threshold must be integer" 5106#, fuzzy, c-format
6181#~ msgstr "Critical threshold muss ein Integer sein" 5107#~ msgid "%s - Plugin timed out after %d seconds\n"
6182 5108#~ msgstr "CRITICAL - Dokumentendatum ist %d Sekunden in der Zukunft\n"
6183#~ msgid "Warning threshold must be integer"
6184#~ msgstr "Warning threshold Integer sein"
6185 5109
6186#, fuzzy 5110#, fuzzy
6187#~ msgid "Critical Process Count must be an integer!" 5111#~ msgid "Critical Process Count must be an integer!"
@@ -6199,10 +5123,10 @@ msgstr ""
6199#~ msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n" 5123#~ msgstr "CRITICAL - Konnte kein Serverzertifikat erhalten\n"
6200 5124
6201#~ msgid "Invalid HTTP response received from host\n" 5125#~ msgid "Invalid HTTP response received from host\n"
6202#~ msgstr "Ungültige HTTP Antwort von Host empfangen\n" 5126#~ msgstr "Ungültige HTTP Antwort von Host empfangen\n"
6203 5127
6204#~ msgid "Invalid HTTP response received from host on port %d\n" 5128#~ msgid "Invalid HTTP response received from host on port %d\n"
6205#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 5129#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
6206 5130
6207#~ msgid "HTTP CRITICAL: %s\n" 5131#~ msgid "HTTP CRITICAL: %s\n"
6208#~ msgstr "HTTP CRITICAL: %s\n" 5132#~ msgstr "HTTP CRITICAL: %s\n"
@@ -6230,20 +5154,12 @@ msgstr ""
6230#~ msgstr "HTTP CRITICAL - Text nicht gefunden%s|%s %s\n" 5154#~ msgstr "HTTP CRITICAL - Text nicht gefunden%s|%s %s\n"
6231 5155
6232#, fuzzy 5156#, fuzzy
6233#~ msgid "HTTP OK %s - %d bytes in %.3f seconds %s|%s %s\n"
6234#~ msgstr "HTTP OK %s - %.3f Sekunde Antwortzeit %s%s|%s %s\n"
6235
6236#, fuzzy
6237#~ msgid "HTTP UNKNOWN - could not allocate url\n" 5157#~ msgid "HTTP UNKNOWN - could not allocate url\n"
6238#~ msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n" 5158#~ msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
6239
6240#, fuzzy
6241#~ msgid "HTTP UNKNOWN - Could not allocate server_url%s\n"
6242#~ msgstr "HTTP UNKNOWN - Konnte·url·nicht·zuweisen\n"
6243 5159
6244#, fuzzy 5160#, fuzzy
6245#~ msgid "snmpget returned an error status" 5161#~ msgid "snmpget returned an error status"
6246#~ msgstr "dig hat einen Fehler zurückgegeben" 5162#~ msgstr "dig hat einen Fehler zurückgegeben"
6247 5163
6248#, fuzzy 5164#, fuzzy
6249#~ msgid "Invalid critical threshold" 5165#~ msgid "Invalid critical threshold"
@@ -6287,7 +5203,7 @@ msgstr ""
6287#~ " ssh anweisen Protokoll 2 zu verwenden\n" 5203#~ " ssh anweisen Protokoll 2 zu verwenden\n"
6288#~ " -S, --skiplines=n\n" 5204#~ " -S, --skiplines=n\n"
6289#~ " Ignoriere die ersten n Zeilen auf STDERR (um Logon Banner zu " 5205#~ " Ignoriere die ersten n Zeilen auf STDERR (um Logon Banner zu "
6290#~ "unterdrücken)\n" 5206#~ "unterdrücken)\n"
6291#~ " -f\n" 5207#~ " -f\n"
6292#~ " ssh anweisen fork zu nutzen statt ein tty zu erzeugen\n" 5208#~ " ssh anweisen fork zu nutzen statt ein tty zu erzeugen\n"
6293 5209
@@ -6306,13 +5222,13 @@ msgstr ""
6306#~ " short name of host in nagios configuration [optional]\n" 5222#~ " short name of host in nagios configuration [optional]\n"
6307#~ msgstr "" 5223#~ msgstr ""
6308#~ " -C, --command='COMMAND STRING'\n" 5224#~ " -C, --command='COMMAND STRING'\n"
6309#~ " Befehl der auf der entfernten Maschine ausgeführt werden soll\n" 5225#~ " Befehl der auf der entfernten Maschine ausgeführt werden soll\n"
6310#~ " -l, --logname=USERNAME\n" 5226#~ " -l, --logname=USERNAME\n"
6311#~ " SSH user name auf dem entfernten Host [optional]\n" 5227#~ " SSH user name auf dem entfernten Host [optional]\n"
6312#~ " -i, --identity=KEYFILE\n" 5228#~ " -i, --identity=KEYFILE\n"
6313#~ " zu verwendende Schlüsseldatei [optional]\n" 5229#~ " zu verwendende Schlüsseldatei [optional]\n"
6314#~ " -O, --output=FILE\n" 5230#~ " -O, --output=FILE\n"
6315#~ " externe Befehlsdatei für nagios [optional]\n" 5231#~ " externe Befehlsdatei für nagios [optional]\n"
6316#~ " -s, --services=LIST\n" 5232#~ " -s, --services=LIST\n"
6317#~ " Liste von nagios Servicenamen, getrennt durch ':' [optional]\n" 5233#~ " Liste von nagios Servicenamen, getrennt durch ':' [optional]\n"
6318#~ " -n, --name=NAME\n" 5234#~ " -n, --name=NAME\n"
@@ -6349,15 +5265,15 @@ msgstr ""
6349#~ "greater than zero" 5265#~ "greater than zero"
6350#~ msgstr "" 5266#~ msgstr ""
6351#~ "INPUT ERROR: C_DF (%lu) sollte kleiner sein als W_DF (%lu) und beide " 5267#~ "INPUT ERROR: C_DF (%lu) sollte kleiner sein als W_DF (%lu) und beide "
6352#~ "sollten größer als 0 sein" 5268#~ "sollten größer als 0 sein"
6353 5269
6354#, fuzzy 5270#, fuzzy
6355#~ msgid "No response from host on port %d\n" 5271#~ msgid "No response from host on port %d\n"
6356#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 5272#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
6357 5273
6358#, fuzzy 5274#, fuzzy
6359#~ msgid "Invalid response received from host on port %d\n" 5275#~ msgid "Invalid response received from host on port %d\n"
6360#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n" 5276#~ msgstr "Ungültige HTTP Antwort von Host erhalten auf Port %d\n"
6361 5277
6362#~ msgid "%.3f seconds response time (%s)" 5278#~ msgid "%.3f seconds response time (%s)"
6363#~ msgstr "%.3f Sekunden Antwortzeit (%s)" 5279#~ msgstr "%.3f Sekunden Antwortzeit (%s)"
@@ -6372,7 +5288,7 @@ msgstr ""
6372#~ " Exit with CRITICAL status if less than INTEGER --units of disk are " 5288#~ " Exit with CRITICAL status if less than INTEGER --units of disk are "
6373#~ "free\n" 5289#~ "free\n"
6374#~ " -c, --critical=PERCENT%%\n" 5290#~ " -c, --critical=PERCENT%%\n"
6375#~ " Exit with CRITCAL status if less than PERCENT of disk space is free\n" 5291#~ " Exit with CRITICAL status if less than PERCENT of disk space is free\n"
6376#~ " -C, --clear\n" 5292#~ " -C, --clear\n"
6377#~ " Clear thresholds\n" 5293#~ " Clear thresholds\n"
6378#~ msgstr "" 5294#~ msgstr ""
@@ -6385,7 +5301,7 @@ msgstr ""
6385#~ " -c, --critical=PERCENT%%\n" 5301#~ " -c, --critical=PERCENT%%\n"
6386#~ " meldet Status CRITICAL, wenn weniger als PERCENT --Plattenplatz frei\n" 5302#~ " meldet Status CRITICAL, wenn weniger als PERCENT --Plattenplatz frei\n"
6387#~ " -C, --clear\n" 5303#~ " -C, --clear\n"
6388#~ " Schwellwerte löschen\n" 5304#~ " Schwellwerte löschen\n"
6389 5305
6390#~ msgid "" 5306#~ msgid ""
6391#~ "Examples:\n" 5307#~ "Examples:\n"
@@ -6394,7 +5310,7 @@ msgstr ""
6394#~ msgstr "" 5310#~ msgstr ""
6395#~ "Beispiel:\n" 5311#~ "Beispiel:\n"
6396#~ " check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n" 5312#~ " check_disk -w 10% -c 5% -p /tmp -p /var -C -w 100000 -c 50000 -p /\n"
6397#~ " Prüft /tmp und /var mit 10%,5% und / mit 100MB, 50MB\n" 5313#~ " Prüft /tmp und /var mit 10%,5% und / mit 100MB, 50MB\n"
6398 5314
6399#~ msgid "" 5315#~ msgid ""
6400#~ "This plugin uses the nslookup program to obtain the IP address\n" 5316#~ "This plugin uses the nslookup program to obtain the IP address\n"
@@ -6413,10 +5329,7 @@ msgstr ""
6413#~ msgstr "HTTP CRITICAL - Konnte keine SSL Verbindung herstellen\n" 5329#~ msgstr "HTTP CRITICAL - Konnte keine SSL Verbindung herstellen\n"
6414 5330
6415#~ msgid "Client Certificate Required\n" 5331#~ msgid "Client Certificate Required\n"
6416#~ msgstr "Clientzertifikat benötigt\n" 5332#~ msgstr "Clientzertifikat benötigt\n"
6417
6418#~ msgid "Failed"
6419#~ msgstr "Fehlgeschlagen"
6420 5333
6421#~ msgid "CRITICAL - Cannot create SSL context.\n" 5334#~ msgid "CRITICAL - Cannot create SSL context.\n"
6422#~ msgstr "CRITICAL - Konnte SSL Kontext nicht erzeugen.\n" 5335#~ msgstr "CRITICAL - Konnte SSL Kontext nicht erzeugen.\n"
@@ -6426,7 +5339,7 @@ msgstr ""
6426 5339
6427#, fuzzy 5340#, fuzzy
6428#~ msgid "Failed to allocate memory for hostname" 5341#~ msgid "Failed to allocate memory for hostname"
6429#~ msgstr "konnte keinen Speicher für '%s' reservieren\n" 5342#~ msgstr "konnte keinen Speicher für '%s' reservieren\n"
6430 5343
6431#, fuzzy 5344#, fuzzy
6432#~ msgid "CRITICAL - %d of %d hosts are alive\n" 5345#~ msgid "CRITICAL - %d of %d hosts are alive\n"
@@ -6434,7 +5347,7 @@ msgstr ""
6434 5347
6435#, fuzzy 5348#, fuzzy
6436#~ msgid "%s has no address data\n" 5349#~ msgid "%s has no address data\n"
6437#~ msgstr "Nameserver %s hat keine Datensätze\n" 5350#~ msgstr "Nameserver %s hat keine Datensätze\n"
6438 5351
6439#, fuzzy 5352#, fuzzy
6440#~ msgid "CRITICAL - Could not make SSL connection\n" 5353#~ msgid "CRITICAL - Could not make SSL connection\n"
@@ -6446,7 +5359,7 @@ msgstr ""
6446 5359
6447#, fuzzy 5360#, fuzzy
6448#~ msgid "Certificate expires today (%s).\n" 5361#~ msgid "Certificate expires today (%s).\n"
6449#~ msgstr "Clientzertifikat benötigt\n" 5362#~ msgstr "Clientzertifikat benötigt\n"
6450 5363
6451#, fuzzy 5364#, fuzzy
6452#~ msgid "ERROR: Cannot create SSL context.\n" 5365#~ msgid "ERROR: Cannot create SSL context.\n"
@@ -6474,7 +5387,7 @@ msgstr ""
6474#~ msgstr "Time interval muss ein positiver Integer sein" 5387#~ msgstr "Time interval muss ein positiver Integer sein"
6475 5388
6476#~ msgid "check_http: invalid option - SSL is not available\n" 5389#~ msgid "check_http: invalid option - SSL is not available\n"
6477#~ msgstr "check_http: ungültige Option - SSL ist nicht verfügbar\n" 5390#~ msgstr "check_http: ungültige Option - SSL ist nicht verfügbar\n"
6478 5391
6479#~ msgid "invalid hostname/address" 5392#~ msgid "invalid hostname/address"
6480#~ msgstr "Ungültige(r) Hostname/Adresse" 5393#~ msgstr "Ungültige(r) Hostname/Adresse"
diff --git a/po/fr.po b/po/fr.po
index e44cf88..dfc2c5d 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -1,6 +1,6 @@
1# translation of fr.po to 1# translation of fr.po to
2# Messages français pour Nagios Plugins 2# Messages français pour Nagios Plugins
3# Copyright (C) 2003-2004 Nagios Plugin Development Group 3# Copyright (C) 2003-2023 Nagios Plugin Development Group
4# This file is distributed under the same license as the nagiosplug package. 4# This file is distributed under the same license as the nagiosplug package.
5# 5#
6# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003. 6# Karl DeBisschop <kdebisschop@users.sourceforge.net>, 2003.
@@ -8,112 +8,77 @@
8# Thomas Guyot-Sionnest <dermoth@aei.ca>, 2007. 8# Thomas Guyot-Sionnest <dermoth@aei.ca>, 2007.
9msgid "" 9msgid ""
10msgstr "" 10msgstr ""
11"Project-Id-Version: fr\n" 11"Project-Id-Version: PACKAGE VERSION\n"
12"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 12"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
13"POT-Creation-Date: 2014-01-19 16:30-0500\n" 13"POT-Creation-Date: 2023-09-05 00:31+0200\n"
14"PO-Revision-Date: 2010-04-21 23:38-0400\n" 14"PO-Revision-Date: 2010-04-21 23:38-0400\n"
15"Last-Translator: Thomas Guyot-Sionnest <dermoth@aei.ca>\n" 15"Last-Translator: \n"
16"Language-Team: Nagios Plugin Development Mailing List <nagiosplug-" 16"Language-Team: Monitoring Plugin Development Team <devel@monitoring-plugins.org>\n"
17"devel@monitoring-plugins.org>\n" 17"Language: fr\n"
18"Language: \n"
19"MIME-Version: 1.0\n" 18"MIME-Version: 1.0\n"
20"Content-Type: text/plain; charset=UTF-8\n" 19"Content-Type: text/plain; charset=UTF-8\n"
21"Content-Transfer-Encoding: 8bit\n" 20"Content-Transfer-Encoding: 8bit\n"
22"Plural-Forms: nplurals=2; plural=(n != 1);\n" 21"Plural-Forms: nplurals=2; plural=(n != 1);\n"
23"X-Generator: KBabel 1.11.4\n" 22"X-Generator: KBabel 1.11.4\n"
24 23
25#: plugins/check_by_ssh.c:86 plugins/check_cluster.c:76 plugins/check_dig.c:88
26#: plugins/check_disk.c:194 plugins/check_dns.c:102 plugins/check_dummy.c:52
27#: plugins/check_fping.c:93 plugins/check_game.c:82 plugins/check_hpjd.c:103
28#: plugins/check_http.c:167 plugins/check_ldap.c:109 plugins/check_load.c:122
29#: plugins/check_mrtgtraf.c:83 plugins/check_mysql.c:122
30#: plugins/check_nagios.c:91 plugins/check_nt.c:127 plugins/check_ntp.c:770
31#: plugins/check_ntp_peer.c:575 plugins/check_ntp_time.c:552
32#: plugins/check_nwstat.c:173 plugins/check_overcr.c:102
33#: plugins/check_pgsql.c:172 plugins/check_ping.c:95 plugins/check_procs.c:172
34#: plugins/check_radius.c:160 plugins/check_real.c:80 plugins/check_smtp.c:144
35#: plugins/check_snmp.c:240 plugins/check_ssh.c:73 plugins/check_swap.c:110
36#: plugins/check_tcp.c:218 plugins/check_time.c:78 plugins/check_ups.c:122
37#: plugins/check_users.c:77 plugins/negate.c:214 plugins-root/check_dhcp.c:270
38msgid "Could not parse arguments" 24msgid "Could not parse arguments"
39msgstr "Impossible de décomposer les arguments" 25msgstr "Impossible de décomposer les arguments"
40 26
41#: plugins/check_by_ssh.c:90 plugins/check_dig.c:82 plugins/check_dns.c:95
42#: plugins/check_nagios.c:95 plugins/check_pgsql.c:178 plugins/check_ping.c:99
43#: plugins/check_procs.c:188 plugins/check_snmp.c:336 plugins/negate.c:79
44msgid "Cannot catch SIGALRM" 27msgid "Cannot catch SIGALRM"
45msgstr "Impossible d'obtenir le signal SIGALRM" 28msgstr "Impossible d'obtenir le signal SIGALRM"
46 29
47#: plugins/check_by_ssh.c:110 30#, fuzzy, c-format
31msgid "SSH connection failed: %s\n"
32msgstr "L'exécution de la commande à distance %s à échoué\n"
33
48#, c-format 34#, c-format
49msgid "Remote command execution failed: %s\n" 35msgid "Remote command execution failed: %s\n"
50msgstr "L'exécution de la commande à distance %s à échoué\n" 36msgstr "L'exécution de la commande à distance %s à échoué\n"
51 37
52#: plugins/check_by_ssh.c:122
53#, c-format 38#, c-format
54msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n" 39msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n"
55msgstr "" 40msgstr ""
56 41
57#: plugins/check_by_ssh.c:134
58#, c-format 42#, c-format
59msgid "SSH WARNING: could not open %s\n" 43msgid "SSH WARNING: could not open %s\n"
60msgstr "SSH AVERTISSEMENT: impossible d'ouvrir %s\n" 44msgstr "SSH AVERTISSEMENT: impossible d'ouvrir %s\n"
61 45
62#: plugins/check_by_ssh.c:143
63#, c-format 46#, c-format
64msgid "%s: Error parsing output\n" 47msgid "%s: Error parsing output\n"
65msgstr "%s: Erreur d'analyse du résultat\n" 48msgstr "%s: Erreur d'analyse du résultat\n"
66 49
67#: plugins/check_by_ssh.c:220 plugins/check_disk.c:476
68#: plugins/check_http.c:278 plugins/check_ldap.c:293 plugins/check_pgsql.c:311
69#: plugins/check_procs.c:437 plugins/check_radius.c:308
70#: plugins/check_real.c:356 plugins/check_smtp.c:581 plugins/check_snmp.c:736
71#: plugins/check_ssh.c:138 plugins/check_tcp.c:505 plugins/check_time.c:302
72#: plugins/check_ups.c:556 plugins/negate.c:164
73msgid "Timeout interval must be a positive integer" 50msgid "Timeout interval must be a positive integer"
74msgstr "Le délai d'attente doit être un entier positif" 51msgstr "Le délai d'attente doit être un entier positif"
75 52
76#: plugins/check_by_ssh.c:230 plugins/check_pgsql.c:341
77#: plugins/check_radius.c:272 plugins/check_real.c:327
78#: plugins/check_smtp.c:506 plugins/check_tcp.c:511 plugins/check_time.c:296
79#: plugins/check_ups.c:518
80msgid "Port must be a positive integer" 53msgid "Port must be a positive integer"
81msgstr "Le numéro du port doit être un entier positif" 54msgstr "Le numéro du port doit être un entier positif"
82 55
83#: plugins/check_by_ssh.c:291
84msgid "skip-stdout argument must be an integer" 56msgid "skip-stdout argument must be an integer"
85msgstr "Le nombres de lignes à sauter (skip-stdout) doit être un entier" 57msgstr "Le nombres de lignes à sauter (skip-stdout) doit être un entier"
86 58
87#: plugins/check_by_ssh.c:299
88msgid "skip-stderr argument must be an integer" 59msgid "skip-stderr argument must be an integer"
89msgstr "Le nombres de lignes à sauter (skip-stderr) doit être un entier" 60msgstr "Le nombres de lignes à sauter (skip-stderr) doit être un entier"
90 61
91#: plugins/check_by_ssh.c:322
92#, c-format 62#, c-format
93msgid "%s: You must provide a host name\n" 63msgid "%s: You must provide a host name\n"
94msgstr "%s: Vous devez fournir un nom d'hôte\n" 64msgstr "%s: Vous devez fournir un nom d'hôte\n"
95 65
96#: plugins/check_by_ssh.c:340
97msgid "No remotecmd" 66msgid "No remotecmd"
98msgstr "Pas de commande distante" 67msgstr "Pas de commande distante"
99 68
100#: plugins/check_by_ssh.c:354
101#, c-format 69#, c-format
102msgid "%s: Argument limit of %d exceeded\n" 70msgid "%s: Argument limit of %d exceeded\n"
103msgstr "" 71msgstr ""
104 72
105#: plugins/check_by_ssh.c:357
106msgid "Can not (re)allocate 'commargv' buffer\n" 73msgid "Can not (re)allocate 'commargv' buffer\n"
107msgstr "Impossible de réallouer le tampon 'commargv'\n" 74msgstr "Impossible de réallouer le tampon 'commargv'\n"
108 75
109#: plugins/check_by_ssh.c:371
110#, c-format 76#, c-format
111msgid "" 77msgid ""
112"%s: In passive mode, you must provide a service name for each command.\n" 78"%s: In passive mode, you must provide a service name for each command.\n"
113msgstr "" 79msgstr ""
114"%s: En mode passif, vous devez fournir un service pour chaque commande.\n" 80"%s: En mode passif, vous devez fournir un service pour chaque commande.\n"
115 81
116#: plugins/check_by_ssh.c:374
117#, fuzzy, c-format 82#, fuzzy, c-format
118msgid "" 83msgid ""
119"%s: In passive mode, you must provide the host short name from the " 84"%s: In passive mode, you must provide the host short name from the "
@@ -122,471 +87,353 @@ msgstr ""
122"%s: En mode passif, vous devez fournir le nom court du hôte mentionné dans " 87"%s: En mode passif, vous devez fournir le nom court du hôte mentionné dans "
123"la configuration de nagios.\n" 88"la configuration de nagios.\n"
124 89
125#: plugins/check_by_ssh.c:388
126#, c-format 90#, c-format
127msgid "This plugin uses SSH to execute commands on a remote host" 91msgid "This plugin uses SSH to execute commands on a remote host"
128msgstr "Ce plugin utilise SSH pour exécuter des commandes sur un hôte distant" 92msgstr "Ce plugin utilise SSH pour exécuter des commandes sur un hôte distant"
129 93
130#: plugins/check_by_ssh.c:403
131msgid "tell ssh to use Protocol 1 [optional]" 94msgid "tell ssh to use Protocol 1 [optional]"
132msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]" 95msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]"
133 96
134#: plugins/check_by_ssh.c:405
135msgid "tell ssh to use Protocol 2 [optional]" 97msgid "tell ssh to use Protocol 2 [optional]"
136msgstr "dire à ssh d'utiliser le protocole 2 [optionnel]" 98msgstr "dire à ssh d'utiliser le protocole 2 [optionnel]"
137 99
138#: plugins/check_by_ssh.c:407
139msgid "Ignore all or (if specified) first n lines on STDOUT [optional]" 100msgid "Ignore all or (if specified) first n lines on STDOUT [optional]"
140msgstr "" 101msgstr ""
141 102
142#: plugins/check_by_ssh.c:409
143msgid "Ignore all or (if specified) first n lines on STDERR [optional]" 103msgid "Ignore all or (if specified) first n lines on STDERR [optional]"
144msgstr "" 104msgstr ""
145 105
146#: plugins/check_by_ssh.c:411 106msgid "Exit with an warning, if there is an output on STDERR"
107msgstr ""
108
147msgid "" 109msgid ""
148"tells ssh to fork rather than create a tty [optional]. This will always " 110"tells ssh to fork rather than create a tty [optional]. This will always "
149"return OK if ssh is executed" 111"return OK if ssh is executed"
150msgstr "" 112msgstr ""
151 113
152#: plugins/check_by_ssh.c:413
153msgid "command to execute on the remote machine" 114msgid "command to execute on the remote machine"
154msgstr "commande à exécuter sur la machine distante" 115msgstr "commande à exécuter sur la machine distante"
155 116
156#: plugins/check_by_ssh.c:415
157msgid "SSH user name on remote host [optional]" 117msgid "SSH user name on remote host [optional]"
158msgstr "Nom d'utilisateur ssh sur la machine distante [optionnel]" 118msgstr "Nom d'utilisateur ssh sur la machine distante [optionnel]"
159 119
160#: plugins/check_by_ssh.c:417
161msgid "identity of an authorized key [optional]" 120msgid "identity of an authorized key [optional]"
162msgstr "Identité de la clé autorisée [optionnel]" 121msgstr "Identité de la clé autorisée [optionnel]"
163 122
164#: plugins/check_by_ssh.c:419
165#, fuzzy 123#, fuzzy
166msgid "external command file for monitoring [optional]" 124msgid "external command file for monitoring [optional]"
167msgstr "commande externe pour nagios [optionnel]" 125msgstr "commande externe pour nagios [optionnel]"
168 126
169#: plugins/check_by_ssh.c:421
170#, fuzzy 127#, fuzzy
171msgid "list of monitoring service names, separated by ':' [optional]" 128msgid "list of monitoring service names, separated by ':' [optional]"
172msgstr "liste des services nagios, séparés par ':' [optionnel] " 129msgstr "liste des services nagios, séparés par ':' [optionnel] "
173 130
174#: plugins/check_by_ssh.c:423
175#, fuzzy 131#, fuzzy
176msgid "short name of host in the monitoring configuration [optional]" 132msgid "short name of host in the monitoring configuration [optional]"
177msgstr "nom court de l'hôte dans la configuration nagios [optionnel]" 133msgstr "nom court de l'hôte dans la configuration nagios [optionnel]"
178 134
179#: plugins/check_by_ssh.c:425
180msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]" 135msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]"
181msgstr "" 136msgstr ""
182"appelle ssh avec '-o OPTION' (peut être utilisé plusieurs fois) [optionnel]" 137"appelle ssh avec '-o OPTION' (peut être utilisé plusieurs fois) [optionnel]"
183 138
184#: plugins/check_by_ssh.c:427
185#, fuzzy 139#, fuzzy
186msgid "Tell ssh to use this configfile [optional]" 140msgid "Tell ssh to use this configfile [optional]"
187msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]" 141msgstr "dire à ssh d'utiliser le protocole version 1 [optionnel]"
188 142
189#: plugins/check_by_ssh.c:429
190msgid "Tell ssh to suppress warning and diagnostic messages [optional]" 143msgid "Tell ssh to suppress warning and diagnostic messages [optional]"
191msgstr "" 144msgstr ""
192"dire à ssh de supprimer les messages d'erreurs et de diagnostic [optionnel]" 145"dire à ssh de supprimer les messages d'erreurs et de diagnostic [optionnel]"
193 146
194#: plugins/check_by_ssh.c:434 147msgid "Make connection problems return UNKNOWN instead of CRITICAL"
148msgstr ""
149
195msgid "The most common mode of use is to refer to a local identity file with" 150msgid "The most common mode of use is to refer to a local identity file with"
196msgstr "" 151msgstr ""
197 152
198#: plugins/check_by_ssh.c:435
199msgid "the '-i' option. In this mode, the identity pair should have a null" 153msgid "the '-i' option. In this mode, the identity pair should have a null"
200msgstr "" 154msgstr ""
201 155
202#: plugins/check_by_ssh.c:436
203msgid "passphrase and the public key should be listed in the authorized_keys" 156msgid "passphrase and the public key should be listed in the authorized_keys"
204msgstr "" 157msgstr ""
205 158
206#: plugins/check_by_ssh.c:437
207msgid "file of the remote host. Usually the key will be restricted to running" 159msgid "file of the remote host. Usually the key will be restricted to running"
208msgstr "" 160msgstr ""
209 161
210#: plugins/check_by_ssh.c:438
211msgid "only one command on the remote server. If the remote SSH server tracks" 162msgid "only one command on the remote server. If the remote SSH server tracks"
212msgstr "" 163msgstr ""
213 164
214#: plugins/check_by_ssh.c:439
215msgid "invocation arguments, the one remote program may be an agent that can" 165msgid "invocation arguments, the one remote program may be an agent that can"
216msgstr "" 166msgstr ""
217 167
218#: plugins/check_by_ssh.c:440
219msgid "execute additional commands as proxy" 168msgid "execute additional commands as proxy"
220msgstr "" 169msgstr ""
221 170
222#: plugins/check_by_ssh.c:442
223msgid "To use passive mode, provide multiple '-C' options, and provide" 171msgid "To use passive mode, provide multiple '-C' options, and provide"
224msgstr "Pour utiliser le mode passif, utilisez plusieurs fois l'option '-C',et" 172msgstr "Pour utiliser le mode passif, utilisez plusieurs fois l'option '-C',et"
225 173
226#: plugins/check_by_ssh.c:443
227msgid "" 174msgid ""
228"all of -O, -s, and -n options (servicelist order must match '-C'options)" 175"all of -O, -s, and -n options (servicelist order must match '-C'options)"
229msgstr "" 176msgstr ""
230"et les options -O, -s, n (l'ordre des services doit correspondre aux " 177"et les options -O, -s, n (l'ordre des services doit correspondre aux "
231"multiples options '-C)" 178"multiples options '-C)"
232 179
233#: plugins/check_by_ssh.c:445 plugins/check_cluster.c:261
234#: plugins/check_dig.c:355 plugins/check_disk.c:924 plugins/check_http.c:1560
235#: plugins/check_nagios.c:312 plugins/check_ntp.c:869
236#: plugins/check_ntp_peer.c:705 plugins/check_ntp_time.c:633
237#: plugins/check_procs.c:763 plugins/negate.c:271 plugins/urlize.c:180
238msgid "Examples:" 180msgid "Examples:"
239msgstr "Exemples:" 181msgstr "Exemples:"
240 182
241#: plugins/check_by_ssh.c:460 plugins/check_cluster.c:274
242#: plugins/check_dig.c:367 plugins/check_disk.c:941 plugins/check_dns.c:486
243#: plugins/check_dummy.c:122 plugins/check_fping.c:505
244#: plugins/check_game.c:331 plugins/check_hpjd.c:414 plugins/check_http.c:1590
245#: plugins/check_ldap.c:451 plugins/check_load.c:334 plugins/check_mrtg.c:382
246#: plugins/check_mysql.c:569 plugins/check_nagios.c:323 plugins/check_nt.c:774
247#: plugins/check_ntp.c:888 plugins/check_ntp_peer.c:725
248#: plugins/check_ntp_time.c:642 plugins/check_nwstat.c:1685
249#: plugins/check_overcr.c:467 plugins/check_pgsql.c:578
250#: plugins/check_ping.c:603 plugins/check_procs.c:781
251#: plugins/check_radius.c:385 plugins/check_real.c:451
252#: plugins/check_smtp.c:843 plugins/check_snmp.c:1207 plugins/check_ssh.c:309
253#: plugins/check_swap.c:558 plugins/check_tcp.c:684 plugins/check_time.c:371
254#: plugins/check_ups.c:660 plugins/check_users.c:240
255#: plugins/check_ide_smart.c:640 plugins/negate.c:295 plugins/urlize.c:197
256#: plugins-root/check_dhcp.c:1422 plugins-root/check_icmp.c:1354
257msgid "Usage:" 183msgid "Usage:"
258msgstr "Utilisation:" 184msgstr "Utilisation:"
259 185
260#: plugins/check_cluster.c:230
261#, fuzzy, c-format 186#, fuzzy, c-format
262msgid "Host/Service Cluster Plugin for Monitoring" 187msgid "Host/Service Cluster Plugin for Monitoring"
263msgstr "Plugin de Cluster d'Hôte/Service pour Nagios 2" 188msgstr "Plugin de Cluster d'Hôte/Service pour Nagios 2"
264 189
265#: plugins/check_cluster.c:236 plugins/check_nt.c:676
266msgid "Options:" 190msgid "Options:"
267msgstr "Options:" 191msgstr "Options:"
268 192
269#: plugins/check_cluster.c:239
270msgid "Check service cluster status" 193msgid "Check service cluster status"
271msgstr "Vérifie l'état d'un cluster de services" 194msgstr "Vérifie l'état d'un cluster de services"
272 195
273#: plugins/check_cluster.c:241
274msgid "Check host cluster status" 196msgid "Check host cluster status"
275msgstr "Vérifie l'état d'un cluster d'hôtes" 197msgstr "Vérifie l'état d'un cluster d'hôtes"
276 198
277#: plugins/check_cluster.c:243
278msgid "Optional prepended text output (i.e. \"Host cluster\")" 199msgid "Optional prepended text output (i.e. \"Host cluster\")"
279msgstr "Texte optionnel accolé à la sortie (i.e. \"Cluster d'hôtes\")" 200msgstr "Texte optionnel accolé à la sortie (i.e. \"Cluster d'hôtes\")"
280 201
281#: plugins/check_cluster.c:245 plugins/check_cluster.c:248
282msgid "Specifies the range of hosts or services in cluster that must be in a" 202msgid "Specifies the range of hosts or services in cluster that must be in a"
283msgstr "Défini le nombre d'hôtes ou de services du cluster qui doivent être" 203msgstr "Défini le nombre d'hôtes ou de services du cluster qui doivent être"
284 204
285#: plugins/check_cluster.c:246
286msgid "non-OK state in order to return a WARNING status level" 205msgid "non-OK state in order to return a WARNING status level"
287msgstr "dans un état non-OK pour retourner un état AVERTISSEMENT" 206msgstr "dans un état non-OK pour retourner un état AVERTISSEMENT"
288 207
289#: plugins/check_cluster.c:249
290msgid "non-OK state in order to return a CRITICAL status level" 208msgid "non-OK state in order to return a CRITICAL status level"
291msgstr "dans un état non-OK pour retourner un état CRITIQUE" 209msgstr "dans un état non-OK pour retourner un état CRITIQUE"
292 210
293#: plugins/check_cluster.c:251
294msgid "The status codes of the hosts or services in the cluster, separated by" 211msgid "The status codes of the hosts or services in the cluster, separated by"
295msgstr "Les codes d'état des hôtes ou des services du cluster, séparés par des" 212msgstr "Les codes d'état des hôtes ou des services du cluster, séparés par des"
296 213
297#: plugins/check_cluster.c:252
298msgid "commas" 214msgid "commas"
299msgstr "virgules" 215msgstr "virgules"
300 216
301#: plugins/check_cluster.c:257 plugins/check_game.c:318
302#: plugins/check_http.c:1542 plugins/check_ldap.c:438 plugins/check_mrtg.c:363
303#: plugins/check_mrtgtraf.c:361 plugins/check_mysql.c:558
304#: plugins/check_nt.c:758 plugins/check_ntp.c:865 plugins/check_ntp_peer.c:696
305#: plugins/check_ntp_time.c:626 plugins/check_nwstat.c:1670
306#: plugins/check_overcr.c:456 plugins/check_snmp.c:1178
307#: plugins/check_swap.c:547 plugins/check_ups.c:642 plugins/negate.c:277
308#: plugins-root/check_icmp.c:1329
309msgid "Notes:" 217msgid "Notes:"
310msgstr "Notes:" 218msgstr "Notes:"
311 219
312#: plugins/check_cluster.c:263
313msgid "" 220msgid ""
314"Will alert critical if there are 3 or more service data points in a non-OK" 221"Will alert critical if there are 3 or more service data points in a non-OK"
315msgstr "" 222msgstr ""
316 223
317#: plugins/check_cluster.c:264 plugins/check_ups.c:639
318msgid "state." 224msgid "state."
319msgstr "" 225msgstr ""
320 226
321#: plugins/check_dig.c:100 plugins/check_dig.c:102
322#, c-format 227#, c-format
323msgid "Looking for: '%s'\n" 228msgid "Looking for: '%s'\n"
324msgstr "Recherche de: '%s'\n" 229msgstr "Recherche de: '%s'\n"
325 230
326#: plugins/check_dig.c:109
327msgid "dig returned an error status" 231msgid "dig returned an error status"
328msgstr "dig à renvoyé un état d'erreur" 232msgstr "dig à renvoyé un état d'erreur"
329 233
330#: plugins/check_dig.c:134
331msgid "Server not found in ANSWER SECTION" 234msgid "Server not found in ANSWER SECTION"
332msgstr "Le serveur n'a pas été trouvé dans l'ANSWER SECTION" 235msgstr "Le serveur n'a pas été trouvé dans l'ANSWER SECTION"
333 236
334#: plugins/check_dig.c:144
335msgid "No ANSWER SECTION found" 237msgid "No ANSWER SECTION found"
336msgstr "Pas d' ANSWER SECTION trouvé" 238msgstr "Pas d' ANSWER SECTION trouvé"
337 239
338#: plugins/check_dig.c:171
339msgid "Probably a non-existent host/domain" 240msgid "Probably a non-existent host/domain"
340msgstr "Probablement un hôte/domaine inexistant" 241msgstr "Probablement un hôte/domaine inexistant"
341 242
342#: plugins/check_dig.c:233
343#, c-format 243#, c-format
344msgid "Port must be a positive integer - %s" 244msgid "Port must be a positive integer - %s"
345msgstr "Le numéro du port doit être un entier positif - %s" 245msgstr "Le numéro du port doit être un entier positif - %s"
346 246
347#: plugins/check_dig.c:244
348#, c-format 247#, c-format
349msgid "Warning interval must be a positive integer - %s" 248msgid "Warning interval must be a positive integer - %s"
350msgstr "Le seuil d'avertissement doit être un entier positif - %s" 249msgstr "Le seuil d'avertissement doit être un entier positif - %s"
351 250
352#: plugins/check_dig.c:252
353#, c-format 251#, c-format
354msgid "Critical interval must be a positive integer - %s" 252msgid "Critical interval must be a positive integer - %s"
355msgstr "Le seuil critique doit être un entier positif - %s" 253msgstr "Le seuil critique doit être un entier positif - %s"
356 254
357#: plugins/check_dig.c:260
358#, c-format 255#, c-format
359msgid "Timeout interval must be a positive integer - %s" 256msgid "Timeout interval must be a positive integer - %s"
360msgstr "Le délai d'attente doit être un entier positif - %s" 257msgstr "Le délai d'attente doit être un entier positif - %s"
361 258
362#: plugins/check_dig.c:325 259#, fuzzy, c-format
363#, c-format 260msgid "This plugin tests the DNS service on the specified host using dig"
364msgid "This plugin test the DNS service on the specified host using dig"
365msgstr "Ce plugin teste le service DNS sur l'hôte spécifié en utilisant dig" 261msgstr "Ce plugin teste le service DNS sur l'hôte spécifié en utilisant dig"
366 262
367#: plugins/check_dig.c:338
368msgid "Force dig to only use IPv4 query transport" 263msgid "Force dig to only use IPv4 query transport"
369msgstr "" 264msgstr ""
370 265
371#: plugins/check_dig.c:340
372msgid "Force dig to only use IPv6 query transport" 266msgid "Force dig to only use IPv6 query transport"
373msgstr "" 267msgstr ""
374 268
375#: plugins/check_dig.c:342
376msgid "Machine name to lookup" 269msgid "Machine name to lookup"
377msgstr "Nom de machine à rechercher" 270msgstr "Nom de machine à rechercher"
378 271
379#: plugins/check_dig.c:344
380msgid "Record type to lookup (default: A)" 272msgid "Record type to lookup (default: A)"
381msgstr "Type d'enregistrement à rechercher (par défaut: A)" 273msgstr "Type d'enregistrement à rechercher (par défaut: A)"
382 274
383#: plugins/check_dig.c:346
384msgid "" 275msgid ""
385"An address expected to be in the answer section. If not set, uses whatever" 276"An address expected to be in the answer section. If not set, uses whatever"
386msgstr "" 277msgstr ""
387"Une adresse qui devrait se trouver dans la section réponce. Si omit, utilise" 278"Une adresse qui devrait se trouver dans la section réponce. Si omit, utilise"
388 279
389#: plugins/check_dig.c:347
390msgid "was in -l" 280msgid "was in -l"
391msgstr "ce qui est passé au paramètre -l" 281msgstr "ce qui est passé au paramètre -l"
392 282
393#: plugins/check_dig.c:349
394msgid "Pass STRING as argument(s) to dig" 283msgid "Pass STRING as argument(s) to dig"
395msgstr "" 284msgstr ""
396 285
397#: plugins/check_disk.c:216
398#, c-format 286#, c-format
399msgid "DISK %s: %s not found\n" 287msgid "DISK %s: %s not found\n"
400msgstr "DISK %s: %s non trouvé\n" 288msgstr "DISK %s: %s non trouvé\n"
401 289
402#: plugins/check_disk.c:216 plugins/check_disk.c:956 plugins/check_dns.c:241
403#: plugins/check_dummy.c:74 plugins/check_mysql.c:299
404#: plugins/check_nagios.c:104 plugins/check_nagios.c:168
405#: plugins/check_nagios.c:172 plugins/check_pgsql.c:601
406#: plugins/check_pgsql.c:618 plugins/check_pgsql.c:627
407#: plugins/check_pgsql.c:642 plugins/check_procs.c:351
408#, c-format 290#, c-format
409msgid "CRITICAL" 291msgid "CRITICAL"
410msgstr "CRITIQUE" 292msgstr "CRITIQUE"
411 293
412#: plugins/check_disk.c:550
413#, c-format 294#, c-format
414msgid "unit type %s not known\n" 295msgid "unit type %s not known\n"
415msgstr "unité de type %s inconnue\n" 296msgstr "unité de type %s inconnue\n"
416 297
417#: plugins/check_disk.c:553
418#, c-format 298#, c-format
419msgid "failed allocating storage for '%s'\n" 299msgid "failed allocating storage for '%s'\n"
420msgstr "Impossible d'allouer de l'espace pour '%s'\n" 300msgstr "Impossible d'allouer de l'espace pour '%s'\n"
421 301
422#: plugins/check_disk.c:577 plugins/check_disk.c:618 plugins/check_disk.c:626
423#: plugins/check_disk.c:633 plugins/check_disk.c:637 plugins/check_disk.c:677
424#: plugins/check_disk.c:683 plugins/check_disk.c:702 plugins/check_dummy.c:77
425#: plugins/check_dummy.c:80 plugins/check_pgsql.c:643
426#: plugins/check_procs.c:506
427#, c-format 302#, c-format
428msgid "UNKNOWN" 303msgid "UNKNOWN"
429msgstr "INCONNU" 304msgstr "INCONNU"
430 305
431#: plugins/check_disk.c:577
432msgid "Must set a threshold value before using -p\n" 306msgid "Must set a threshold value before using -p\n"
433msgstr "" 307msgstr ""
434 308
435#: plugins/check_disk.c:618
436msgid "Must set -E before selecting paths\n" 309msgid "Must set -E before selecting paths\n"
437msgstr "" 310msgstr ""
438 311
439#: plugins/check_disk.c:626
440msgid "Must set group value before selecting paths\n" 312msgid "Must set group value before selecting paths\n"
441msgstr "" 313msgstr ""
442 314
443#: plugins/check_disk.c:633
444msgid "" 315msgid ""
445"Paths need to be selected before using -i/-I. Use -A to select all paths " 316"Paths need to be selected before using -i/-I. Use -A to select all paths "
446"explicitly" 317"explicitly"
447msgstr "" 318msgstr ""
448 319
449#: plugins/check_disk.c:637 plugins/check_disk.c:683 plugins/check_procs.c:506
450msgid "Could not compile regular expression" 320msgid "Could not compile regular expression"
451msgstr "Impossible de compiler l'expression rationnelle" 321msgstr "Impossible de compiler l'expression rationnelle"
452 322
453#: plugins/check_disk.c:677
454msgid "Must set a threshold value before using -r/-R\n" 323msgid "Must set a threshold value before using -r/-R\n"
455msgstr "" 324msgstr ""
456 325
457#: plugins/check_disk.c:703
458msgid "Regular expression did not match any path or disk" 326msgid "Regular expression did not match any path or disk"
459msgstr "" 327msgstr ""
460 328
461#: plugins/check_disk.c:749
462msgid "Unknown argument" 329msgid "Unknown argument"
463msgstr "Argument inconnu" 330msgstr "Argument inconnu"
464 331
465#: plugins/check_disk.c:783
466#, c-format 332#, c-format
467msgid " for %s\n" 333msgid " for %s\n"
468msgstr " pour %s\n" 334msgstr " pour %s\n"
469 335
470#: plugins/check_disk.c:857
471msgid "" 336msgid ""
472"This plugin checks the amount of used disk space on a mounted file system" 337"This plugin checks the amount of used disk space on a mounted file system"
473msgstr "Ce plugin vérifie la place utilisé sur un système de fichier monté" 338msgstr "Ce plugin vérifie la place utilisé sur un système de fichier monté"
474 339
475#: plugins/check_disk.c:858
476msgid "" 340msgid ""
477"and generates an alert if free space is less than one of the threshold values" 341"and generates an alert if free space is less than one of the threshold values"
478msgstr "" 342msgstr ""
479"et génère une alerte si la place disponible est plus petite qu'un des seuils " 343"et génère une alerte si la place disponible est plus petite qu'un des seuils "
480"fourni" 344"fourni"
481 345
482#: plugins/check_disk.c:868
483msgid "Exit with WARNING status if less than INTEGER units of disk are free" 346msgid "Exit with WARNING status if less than INTEGER units of disk are free"
484msgstr "" 347msgstr ""
485"Sortir avec un résultat AVERTISSEMENT si moins de X unités de disques sont " 348"Sortir avec un résultat AVERTISSEMENT si moins de X unités de disques sont "
486"libres" 349"libres"
487 350
488#: plugins/check_disk.c:870
489msgid "Exit with WARNING status if less than PERCENT of disk space is free" 351msgid "Exit with WARNING status if less than PERCENT of disk space is free"
490msgstr "" 352msgstr ""
491"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent du disque est " 353"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent du disque est "
492"libre" 354"libre"
493 355
494#: plugins/check_disk.c:872
495msgid "Exit with CRITICAL status if less than INTEGER units of disk are free" 356msgid "Exit with CRITICAL status if less than INTEGER units of disk are free"
496msgstr "" 357msgstr ""
497"Sortir avec un résultat CRITIQUE si moins de X unités du disque sont libres" 358"Sortir avec un résultat CRITIQUE si moins de X unités du disque sont libres"
498 359
499#: plugins/check_disk.c:874
500#, fuzzy 360#, fuzzy
501msgid "Exit with CRITICAL status if less than PERCENT of disk space is free" 361msgid "Exit with CRITICAL status if less than PERCENT of disk space is free"
502msgstr "" 362msgstr ""
503"Sortir avec un résultat CRITIQUE si moins de X pour-cent du disque est libre" 363"Sortir avec un résultat CRITIQUE si moins de X pour-cent du disque est libre"
504 364
505#: plugins/check_disk.c:876
506msgid "Exit with WARNING status if less than PERCENT of inode space is free" 365msgid "Exit with WARNING status if less than PERCENT of inode space is free"
507msgstr "" 366msgstr ""
508"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent des inodes " 367"Sortir avec un résultat AVERTISSEMENT si moins de X pour-cent des inodes "
509"sont libres" 368"sont libres"
510 369
511#: plugins/check_disk.c:878
512msgid "Exit with CRITICAL status if less than PERCENT of inode space is free" 370msgid "Exit with CRITICAL status if less than PERCENT of inode space is free"
513msgstr "" 371msgstr ""
514"Sortir avec un résultat CRITIQUE si moins de X pour-cent des inodes sont " 372"Sortir avec un résultat CRITIQUE si moins de X pour-cent des inodes sont "
515"libres" 373"libres"
516 374
517#: plugins/check_disk.c:880 375msgid ""
518msgid "Path or partition (may be repeated)" 376"Mount point or block device as emitted by the mount(8) command (may be "
519msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)" 377"repeated)"
378msgstr ""
520 379
521#: plugins/check_disk.c:882
522msgid "Ignore device (only works if -p unspecified)" 380msgid "Ignore device (only works if -p unspecified)"
523msgstr "Ignorer le périphérique (marche seulement lorsque -p est utilisé)" 381msgstr "Ignorer le périphérique (marche seulement lorsque -p est utilisé)"
524 382
525#: plugins/check_disk.c:884
526msgid "Clear thresholds" 383msgid "Clear thresholds"
527msgstr "Effacer les seuils" 384msgstr "Effacer les seuils"
528 385
529#: plugins/check_disk.c:886
530msgid "For paths or partitions specified with -p, only check for exact paths" 386msgid "For paths or partitions specified with -p, only check for exact paths"
531msgstr "" 387msgstr ""
532 388
533#: plugins/check_disk.c:888
534msgid "Display only devices/mountpoints with errors" 389msgid "Display only devices/mountpoints with errors"
535msgstr "Afficher seulement les périphériques/point de montage avec des erreurs" 390msgstr "Afficher seulement les périphériques/point de montage avec des erreurs"
536 391
537#: plugins/check_disk.c:890
538msgid "Don't account root-reserved blocks into freespace in perfdata" 392msgid "Don't account root-reserved blocks into freespace in perfdata"
539msgstr "" 393msgstr ""
540 394
541#: plugins/check_disk.c:892 395msgid "Display inode usage in perfdata"
396msgstr ""
397
542msgid "" 398msgid ""
543"Group paths. Thresholds apply to (free-)space of all partitions together" 399"Group paths. Thresholds apply to (free-)space of all partitions together"
544msgstr "" 400msgstr ""
545 401
546#: plugins/check_disk.c:894
547msgid "Same as '--units kB'" 402msgid "Same as '--units kB'"
548msgstr "Pareil à '--units kB'" 403msgstr "Pareil à '--units kB'"
549 404
550#: plugins/check_disk.c:896
551msgid "Only check local filesystems" 405msgid "Only check local filesystems"
552msgstr "Vérifier seulement les systèmes de fichiers locaux" 406msgstr "Vérifier seulement les systèmes de fichiers locaux"
553 407
554#: plugins/check_disk.c:898
555msgid "" 408msgid ""
556"Only check local filesystems against thresholds. Yet call stat on remote " 409"Only check local filesystems against thresholds. Yet call stat on remote "
557"filesystems" 410"filesystems"
558msgstr "" 411msgstr ""
559 412
560#: plugins/check_disk.c:899
561msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)" 413msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)"
562msgstr "" 414msgstr ""
563 415
564#: plugins/check_disk.c:901 416#, fuzzy
565msgid "Display the mountpoint instead of the partition" 417msgid "Display the (block) device instead of the mount point"
566msgstr "Afficher le point de montage au lieu de la partition" 418msgstr "Afficher le point de montage au lieu de la partition"
567 419
568#: plugins/check_disk.c:903
569msgid "Same as '--units MB'" 420msgid "Same as '--units MB'"
570msgstr "Pareil à '--units MB'" 421msgstr "Pareil à '--units MB'"
571 422
572#: plugins/check_disk.c:905
573msgid "Explicitly select all paths. This is equivalent to -R '.*'" 423msgid "Explicitly select all paths. This is equivalent to -R '.*'"
574msgstr "" 424msgstr ""
575 425
576#: plugins/check_disk.c:907
577msgid "" 426msgid ""
578"Case insensitive regular expression for path/partition (may be repeated)" 427"Case insensitive regular expression for path/partition (may be repeated)"
579msgstr "" 428msgstr ""
580"Expression rationnelle indépendante de la case pour un répertoire ou une " 429"Expression rationnelle indépendante de la case pour un répertoire ou une "
581"partition (peut être utilisé plusieurs fois)" 430"partition (peut être utilisé plusieurs fois)"
582 431
583#: plugins/check_disk.c:909
584msgid "Regular expression for path or partition (may be repeated)" 432msgid "Regular expression for path or partition (may be repeated)"
585msgstr "" 433msgstr ""
586"Expression rationnelle pour un répertoire ou une partition (peut être " 434"Expression rationnelle pour un répertoire ou une partition (peut être "
587"utilisé plusieurs fois)" 435"utilisé plusieurs fois)"
588 436
589#: plugins/check_disk.c:911
590msgid "" 437msgid ""
591"Regular expression to ignore selected path/partition (case insensitive) (may " 438"Regular expression to ignore selected path/partition (case insensitive) (may "
592"be repeated)" 439"be repeated)"
@@ -594,200 +441,176 @@ msgstr ""
594"Expression rationnelle pour ignorer un répertoire ou une partition (peut " 441"Expression rationnelle pour ignorer un répertoire ou une partition (peut "
595"être utilisé plusieurs fois)" 442"être utilisé plusieurs fois)"
596 443
597#: plugins/check_disk.c:913
598msgid "" 444msgid ""
599"Regular expression to ignore selected path or partition (may be repeated)" 445"Regular expression to ignore selected path or partition (may be repeated)"
600msgstr "" 446msgstr ""
601"Expression rationnelle pour ignorer un répertoire ou une partition (peut " 447"Expression rationnelle pour ignorer un répertoire ou une partition (peut "
602"être utilisé plusieurs fois)" 448"être utilisé plusieurs fois)"
603 449
604#: plugins/check_disk.c:916 450msgid ""
451"Return OK if no filesystem matches, filesystem does not exist or is "
452"inaccessible."
453msgstr ""
454
455msgid "(Provide this option before -p / -r / --ereg-path if used)"
456msgstr ""
457
605msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 458msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
606msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)" 459msgstr "Choisissez octets, kb, MB, GB, TB (par défaut: MB)"
607 460
608#: plugins/check_disk.c:919
609msgid "Ignore all filesystems of indicated type (may be repeated)" 461msgid "Ignore all filesystems of indicated type (may be repeated)"
610msgstr "" 462msgstr ""
611"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué " 463"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
612"(peut être utilisé plusieurs fois)" 464"(peut être utilisé plusieurs fois)"
613 465
614#: plugins/check_disk.c:921
615#, fuzzy 466#, fuzzy
616msgid "Check only filesystems of indicated type (may be repeated)" 467msgid "Check only filesystems of indicated type (may be repeated)"
617msgstr "" 468msgstr ""
618"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué " 469"Ignorer tout les systèmes de fichiers qui correspondent au type indiqué "
619"(peut être utilisé plusieurs fois)" 470"(peut être utilisé plusieurs fois)"
620 471
621#: plugins/check_disk.c:926
622msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB" 472msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
623msgstr "Vérifie /tmp à 10% et /var à 5% et / à 100MB et 50MB" 473msgstr "Vérifie /tmp à 10% et /var à 5% et / à 100MB et 50MB"
624 474
625#: plugins/check_disk.c:928
626msgid "" 475msgid ""
627"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -" 476"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -"
628"r regex" 477"r regex"
629msgstr "" 478msgstr ""
630 479
631#: plugins/check_disk.c:929
632msgid "" 480msgid ""
633"are grouped which means the freespace thresholds are applied to all disks " 481"are grouped which means the freespace thresholds are applied to all disks "
634"together" 482"together"
635msgstr "" 483msgstr ""
636 484
637#: plugins/check_disk.c:931
638msgid "" 485msgid ""
639"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use " 486"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use "
640"100M/50M" 487"100M/50M"
641msgstr "" 488msgstr ""
642 489
643#: plugins/check_disk.c:957
644#, c-format 490#, c-format
645msgid "%s %s: %s\n" 491msgid "%s %s: %s\n"
646msgstr "" 492msgstr ""
647 493
648#: plugins/check_disk.c:957
649msgid "is not accessible" 494msgid "is not accessible"
650msgstr "" 495msgstr ""
651 496
652#: plugins/check_dns.c:116
653msgid "nslookup returned an error status" 497msgid "nslookup returned an error status"
654msgstr "nslookup à retourné un code d'erreur" 498msgstr "nslookup à retourné un code d'erreur"
655 499
656#: plugins/check_dns.c:134
657msgid "Warning plugin error" 500msgid "Warning plugin error"
658msgstr "Alerte erreur de plugin" 501msgstr "Alerte erreur de plugin"
659 502
660#: plugins/check_dns.c:154 503#, fuzzy, c-format
504msgid "DNS CRITICAL - '%s' returned empty server string\n"
505msgstr "DNS CRITIQUE - '%s' à retourné un nom d'hôte vide\n"
506
507#, fuzzy, c-format
508msgid "DNS CRITICAL - No response from DNS %s\n"
509msgstr "Pas de réponse du DNS %s\n"
510
661#, c-format 511#, c-format
662msgid "DNS CRITICAL - '%s' returned empty host name string\n" 512msgid "DNS CRITICAL - '%s' returned empty host name string\n"
663msgstr "DNS CRITIQUE - '%s' à retourné un nom d'hôte vide\n" 513msgstr "DNS CRITIQUE - '%s' à retourné un nom d'hôte vide\n"
664 514
665#: plugins/check_dns.c:160
666msgid "Non-authoritative answer:" 515msgid "Non-authoritative answer:"
667msgstr "Réponse non autoritative:" 516msgstr "Réponse non autoritative:"
668 517
669#: plugins/check_dns.c:201 518#, fuzzy, c-format
519msgid "Domain '%s' was not found by the server\n"
520msgstr "Le domaine %s n'a pas été trouvé par le serveur\n"
521
670#, c-format 522#, c-format
671msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n" 523msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n"
672msgstr "DNS CRITIQUE - '%s' n'a pas retourné d'adresse\n" 524msgstr "DNS CRITIQUE - '%s' n'a pas retourné d'adresse\n"
673 525
674#: plugins/check_dns.c:216
675#, c-format 526#, c-format
676msgid "expected '%s' but got '%s'" 527msgid "expected '%s' but got '%s'"
677msgstr "j'attendais '%s' mais j'ai reçu '%s'" 528msgstr "j'attendais '%s' mais j'ai reçu '%s'"
678 529
679#: plugins/check_dns.c:223 530#, fuzzy, c-format
531msgid "Domain '%s' was found by the server: '%s'\n"
532msgstr "Le domaine %s n'a pas été trouvé par le serveur\n"
533
680#, c-format 534#, c-format
681msgid "server %s is not authoritative for %s" 535msgid "server %s is not authoritative for %s"
682msgstr "serveur %s n'est pas autoritaire pour %s" 536msgstr "serveur %s n'est pas autoritaire pour %s"
683 537
684#: plugins/check_dns.c:237 plugins/check_dummy.c:68 plugins/check_nagios.c:182
685#: plugins/check_pgsql.c:638 plugins/check_procs.c:344
686#, c-format 538#, c-format
687msgid "OK" 539msgid "OK"
688msgstr "OK" 540msgstr "OK"
689 541
690#: plugins/check_dns.c:239 plugins/check_dummy.c:71 plugins/check_mysql.c:296
691#: plugins/check_nagios.c:182 plugins/check_pgsql.c:607
692#: plugins/check_pgsql.c:612 plugins/check_pgsql.c:640
693#: plugins/check_procs.c:346
694#, c-format 542#, c-format
695msgid "WARNING" 543msgid "WARNING"
696msgstr "AVERTISSEMENT" 544msgstr "AVERTISSEMENT"
697 545
698#: plugins/check_dns.c:243
699#, c-format 546#, c-format
700msgid "%.3f second response time" 547msgid "%.3f second response time"
701msgid_plural "%.3f seconds response time" 548msgid_plural "%.3f seconds response time"
702msgstr[0] "%.3f secondes de temps de réponse " 549msgstr[0] "%.3f secondes de temps de réponse "
703msgstr[1] "%.3f secondes de temps de réponse " 550msgstr[1] "%.3f secondes de temps de réponse "
704 551
705#: plugins/check_dns.c:244
706#, c-format 552#, c-format
707msgid ". %s returns %s" 553msgid ". %s returns %s"
708msgstr ". %s renvoie %s" 554msgstr ". %s renvoie %s"
709 555
710#: plugins/check_dns.c:248
711#, c-format 556#, c-format
712msgid "DNS WARNING - %s\n" 557msgid "DNS WARNING - %s\n"
713msgstr "DNS AVERTISSEMENT - %s\n" 558msgstr "DNS AVERTISSEMENT - %s\n"
714 559
715#: plugins/check_dns.c:249 plugins/check_dns.c:252 plugins/check_dns.c:255
716msgid " Probably a non-existent host/domain" 560msgid " Probably a non-existent host/domain"
717msgstr " Probablement un hôte/domaine inexistant" 561msgstr " Probablement un hôte/domaine inexistant"
718 562
719#: plugins/check_dns.c:251
720#, c-format 563#, c-format
721msgid "DNS CRITICAL - %s\n" 564msgid "DNS CRITICAL - %s\n"
722msgstr "DNS CRITIQUE - %s\n" 565msgstr "DNS CRITIQUE - %s\n"
723 566
724#: plugins/check_dns.c:254
725#, c-format 567#, c-format
726msgid "DNS UNKNOWN - %s\n" 568msgid "DNS UNKNOWN - %s\n"
727msgstr "DNS INCONNU - %s\n" 569msgstr "DNS INCONNU - %s\n"
728 570
729#: plugins/check_dns.c:267
730msgid "Note: nslookup is deprecated and may be removed from future releases." 571msgid "Note: nslookup is deprecated and may be removed from future releases."
731msgstr "" 572msgstr ""
732"Note: nslookup est obsolète et pourra être retiré dans les prochaines " 573"Note: nslookup est obsolète et pourra être retiré dans les prochaines "
733"versions." 574"versions."
734 575
735#: plugins/check_dns.c:268
736msgid "Consider using the `dig' or `host' programs instead. Run nslookup with" 576msgid "Consider using the `dig' or `host' programs instead. Run nslookup with"
737msgstr "" 577msgstr ""
738"Veuillez utiliser le programme 'dig' ou 'host' à la place. Faire fonctionner " 578"Veuillez utiliser le programme 'dig' ou 'host' à la place. Faire fonctionner "
739"nslookup avec" 579"nslookup avec"
740 580
741#: plugins/check_dns.c:269
742msgid "the `-sil[ent]' option to prevent this message from appearing." 581msgid "the `-sil[ent]' option to prevent this message from appearing."
743msgstr "L'option '-sil[ent]' empêche l'apparition de ce message." 582msgstr "L'option '-sil[ent]' empêche l'apparition de ce message."
744 583
745#: plugins/check_dns.c:274
746#, c-format 584#, c-format
747msgid "No response from DNS %s\n" 585msgid "No response from DNS %s\n"
748msgstr "Pas de réponse du DNS %s\n" 586msgstr "Pas de réponse du DNS %s\n"
749 587
750#: plugins/check_dns.c:278
751#, c-format 588#, c-format
752msgid "DNS %s has no records\n" 589msgid "DNS %s has no records\n"
753msgstr "Le DNS %s n'a pas d'enregistrements\n" 590msgstr "Le DNS %s n'a pas d'enregistrements\n"
754 591
755#: plugins/check_dns.c:286
756#, c-format 592#, c-format
757msgid "Connection to DNS %s was refused\n" 593msgid "Connection to DNS %s was refused\n"
758msgstr "La connexion au DNS %s à été refusée\n" 594msgstr "La connexion au DNS %s à été refusée\n"
759 595
760#: plugins/check_dns.c:290
761#, c-format 596#, c-format
762msgid "Query was refused by DNS server at %s\n" 597msgid "Query was refused by DNS server at %s\n"
763msgstr "La requête à été refusée par le serveur DNS %s\n" 598msgstr "La requête à été refusée par le serveur DNS %s\n"
764 599
765#: plugins/check_dns.c:294
766#, c-format 600#, c-format
767msgid "No information returned by DNS server at %s\n" 601msgid "No information returned by DNS server at %s\n"
768msgstr "Pas d'information renvoyée par le serveur DNS %s\n" 602msgstr "Pas d'information renvoyée par le serveur DNS %s\n"
769 603
770#: plugins/check_dns.c:300
771#, c-format
772msgid "Domain %s was not found by the server\n"
773msgstr "Le domaine %s n'a pas été trouvé par le serveur\n"
774
775#: plugins/check_dns.c:304
776msgid "Network is unreachable\n" 604msgid "Network is unreachable\n"
777msgstr "Le réseau est inaccessible\n" 605msgstr "Le réseau est inaccessible\n"
778 606
779#: plugins/check_dns.c:308
780#, c-format 607#, c-format
781msgid "DNS failure for %s\n" 608msgid "DNS failure for %s\n"
782msgstr "DNS à échoué pour %s\n" 609msgstr "DNS à échoué pour %s\n"
783 610
784#: plugins/check_dns.c:372 plugins/check_dns.c:380 plugins/check_dns.c:387
785#: plugins/check_dns.c:392 plugins/check_dns.c:414 plugins/check_dns.c:422
786#: plugins/check_game.c:211 plugins/check_game.c:219
787msgid "Input buffer overflow\n" 611msgid "Input buffer overflow\n"
788msgstr "Le tampon d'entrée a débordé\n" 612msgstr "Le tampon d'entrée a débordé\n"
789 613
790#: plugins/check_dns.c:450
791msgid "" 614msgid ""
792"This plugin uses the nslookup program to obtain the IP address for the given " 615"This plugin uses the nslookup program to obtain the IP address for the given "
793"host/domain query." 616"host/domain query."
@@ -795,11 +618,9 @@ msgstr ""
795"Ce plugin utilise le programme nslookup pour obtenir l'adresse IP de l'hôte/" 618"Ce plugin utilise le programme nslookup pour obtenir l'adresse IP de l'hôte/"
796"domaine à interroger." 619"domaine à interroger."
797 620
798#: plugins/check_dns.c:451
799msgid "An optional DNS server to use may be specified." 621msgid "An optional DNS server to use may be specified."
800msgstr "Un serveur DNS à utiliser peut être indiqué." 622msgstr "Un serveur DNS à utiliser peut être indiqué."
801 623
802#: plugins/check_dns.c:452
803msgid "" 624msgid ""
804"If no DNS server is specified, the default server(s) specified in /etc/" 625"If no DNS server is specified, the default server(s) specified in /etc/"
805"resolv.conf will be used." 626"resolv.conf will be used."
@@ -807,193 +628,158 @@ msgstr ""
807"Si aucun serveur DNS n'est spécifié, les serveurs spécifiés dans /etc/resolv." 628"Si aucun serveur DNS n'est spécifié, les serveurs spécifiés dans /etc/resolv."
808"conf seront utilisé." 629"conf seront utilisé."
809 630
810#: plugins/check_dns.c:462
811msgid "The name or address you want to query" 631msgid "The name or address you want to query"
812msgstr "Le nom ou l'adresse que vous voulez interroger" 632msgstr "Le nom ou l'adresse que vous voulez interroger"
813 633
814#: plugins/check_dns.c:464
815msgid "Optional DNS server you want to use for the lookup" 634msgid "Optional DNS server you want to use for the lookup"
816msgstr "Serveur DNS que vous voulez utiliser pour la recherche" 635msgstr "Serveur DNS que vous voulez utiliser pour la recherche"
817 636
818#: plugins/check_dns.c:466 637#, fuzzy
819msgid "" 638msgid ""
820"Optional IP-ADDRESS you expect the DNS server to return. HOST must end with" 639"Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"
821msgstr "" 640msgstr ""
822"Adresse IP que le serveur DNS doit retourner. Les hôtes doivent se terminer " 641"Adresse IP que le serveur DNS doit retourner. Les hôtes doivent se terminer "
823 642
824#: plugins/check_dns.c:467 643#, fuzzy
825msgid "" 644msgid ""
826"a dot (.). This option can be repeated multiple times (Returns OK if any" 645"with a dot (.). This option can be repeated multiple times (Returns OK if any"
827msgstr "avec un point (.). Cette option peut être répétée (Retourne OK si une" 646msgstr "avec un point (.). Cette option peut être répétée (Retourne OK si une"
828 647
829#: plugins/check_dns.c:468 648msgid "value matches)."
830msgid ""
831"value match). If multiple addresses are returned at once, you have to match"
832msgstr "" 649msgstr ""
833"valeur correspond). Si plusieurs adresses sont retournées en même temps,"
834 650
835#: plugins/check_dns.c:469
836msgid "" 651msgid ""
837"the whole string of addresses separated with commas (sorted alphabetically)." 652"Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"
653msgstr ""
654
655msgid "Cannot be used together with -a"
838msgstr "" 656msgstr ""
839"vous devrez toutes les inscrire séparées pas des virgules (en ordre "
840"alphabétique)"
841 657
842#: plugins/check_dns.c:471
843msgid "Optionally expect the DNS server to be authoritative for the lookup" 658msgid "Optionally expect the DNS server to be authoritative for the lookup"
844msgstr "Serveur DNS qui doit normalement être autoritaire pour la recherche" 659msgstr "Serveur DNS qui doit normalement être autoritaire pour la recherche"
845 660
846#: plugins/check_dns.c:473
847msgid "Return warning if elapsed time exceeds value. Default off" 661msgid "Return warning if elapsed time exceeds value. Default off"
848msgstr "" 662msgstr ""
849"Renvoie une alerte si le temps écoulé dépasse la valeur indiquée. Désactivé " 663"Renvoie une alerte si le temps écoulé dépasse la valeur indiquée. Désactivé "
850"par défaut" 664"par défaut"
851 665
852#: plugins/check_dns.c:475
853msgid "Return critical if elapsed time exceeds value. Default off" 666msgid "Return critical if elapsed time exceeds value. Default off"
854msgstr "" 667msgstr ""
855"Renvoie critique si le temps utilisé dépasse la valeur indiquée. Désactivé " 668"Renvoie critique si le temps utilisé dépasse la valeur indiquée. Désactivé "
856"par défaut" 669"par défaut"
857 670
858#: plugins/check_dummy.c:62 671msgid ""
672"Return critical if the list of expected addresses does not match all "
673"addresses"
674msgstr ""
675
676msgid "returned. Default off"
677msgstr ""
678
859msgid "Arguments to check_dummy must be an integer" 679msgid "Arguments to check_dummy must be an integer"
860msgstr "Les arguments pour check_dummy doivent être des entiers" 680msgstr "Les arguments pour check_dummy doivent être des entiers"
861 681
862#: plugins/check_dummy.c:82
863#, c-format 682#, c-format
864msgid "Status %d is not a supported error state\n" 683msgid "Status %d is not a supported error state\n"
865msgstr "Le résultat %d n'est pas un résultat supporté\n" 684msgstr "Le résultat %d n'est pas un résultat supporté\n"
866 685
867#: plugins/check_dummy.c:104
868msgid "" 686msgid ""
869"This plugin will simply return the state corresponding to the numeric value" 687"This plugin will simply return the state corresponding to the numeric value"
870msgstr "" 688msgstr ""
871"Ce plugin renverra simplement l'état correspondant à la valeur numérique" 689"Ce plugin renverra simplement l'état correspondant à la valeur numérique"
872 690
873#: plugins/check_dummy.c:106
874msgid "of the <state> argument with optional text" 691msgid "of the <state> argument with optional text"
875msgstr "du paramètre <state> avec un texte optionnel" 692msgstr "du paramètre <state> avec un texte optionnel"
876 693
877#: plugins/check_fping.c:125 plugins/check_hpjd.c:128 plugins/check_ping.c:438
878#: plugins/check_swap.c:175 plugins/check_users.c:94 plugins/urlize.c:110
879#, c-format 694#, c-format
880msgid "Could not open pipe: %s\n" 695msgid "Could not open pipe: %s\n"
881msgstr "Impossible d'ouvrir le pipe: %s\n" 696msgstr "Impossible d'ouvrir le pipe: %s\n"
882 697
883#: plugins/check_fping.c:131 plugins/check_hpjd.c:134 plugins/check_load.c:153
884#: plugins/check_swap.c:181 plugins/check_users.c:100 plugins/urlize.c:116
885#, c-format 698#, c-format
886msgid "Could not open stderr for %s\n" 699msgid "Could not open stderr for %s\n"
887msgstr "Impossible d'ouvrir la sortie d'erreur standard pour %s\n" 700msgstr "Impossible d'ouvrir la sortie d'erreur standard pour %s\n"
888 701
889#: plugins/check_fping.c:157
890#, fuzzy 702#, fuzzy
891msgid "FPING UNKNOWN - IP address not found\n" 703msgid "FPING UNKNOWN - IP address not found\n"
892msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 704msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
893 705
894#: plugins/check_fping.c:160
895msgid "FPING UNKNOWN - invalid commandline argument\n" 706msgid "FPING UNKNOWN - invalid commandline argument\n"
896msgstr "" 707msgstr ""
897 708
898#: plugins/check_fping.c:163
899#, fuzzy 709#, fuzzy
900msgid "FPING UNKNOWN - failed system call\n" 710msgid "FPING UNKNOWN - failed system call\n"
901msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 711msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
902 712
903#: plugins/check_fping.c:187 713#, fuzzy, c-format
714msgid "FPING %s - %s (rta=%f ms)|%s\n"
715msgstr "FPING %s - %s (perte=%.0f%% )|%s\n"
716
904#, c-format 717#, c-format
905msgid "FPING UNKNOWN - %s not found\n" 718msgid "FPING UNKNOWN - %s not found\n"
906msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 719msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
907 720
908#: plugins/check_fping.c:191
909#, c-format 721#, c-format
910msgid "FPING CRITICAL - %s is unreachable\n" 722msgid "FPING CRITICAL - %s is unreachable\n"
911msgstr "PING CRITIQUE - Hôte inaccessible (%s)\n" 723msgstr "PING CRITIQUE - Hôte inaccessible (%s)\n"
912 724
913#: plugins/check_fping.c:196
914#, fuzzy, c-format 725#, fuzzy, c-format
915msgid "FPING UNKNOWN - %s parameter error\n" 726msgid "FPING UNKNOWN - %s parameter error\n"
916msgstr "PING INCONNU - Hôte non trouvé (%s)\n" 727msgstr "PING INCONNU - Hôte non trouvé (%s)\n"
917 728
918#: plugins/check_fping.c:200 plugins/check_fping.c:240
919#, c-format 729#, c-format
920msgid "FPING CRITICAL - %s is down\n" 730msgid "FPING CRITICAL - %s is down\n"
921msgstr "FPING CRITIQUE - %s est en panne\n" 731msgstr "FPING CRITIQUE - %s est en panne\n"
922 732
923#: plugins/check_fping.c:227
924#, c-format 733#, c-format
925msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n" 734msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"
926msgstr "FPING %s - %s (perte=%.0f%%, rta=%f ms)|%s %s\n" 735msgstr "FPING %s - %s (perte=%.0f%%, rta=%f ms)|%s %s\n"
927 736
928#: plugins/check_fping.c:253
929#, c-format 737#, c-format
930msgid "FPING %s - %s (loss=%.0f%% )|%s\n" 738msgid "FPING %s - %s (loss=%.0f%% )|%s\n"
931msgstr "FPING %s - %s (perte=%.0f%% )|%s\n" 739msgstr "FPING %s - %s (perte=%.0f%% )|%s\n"
932 740
933#: plugins/check_fping.c:326 plugins/check_fping.c:332
934#: plugins/check_hpjd.c:338 plugins/check_hpjd.c:361 plugins/check_mysql.c:371
935#: plugins/check_mysql.c:455 plugins/check_ntp.c:709
936#: plugins/check_ntp_peer.c:497 plugins/check_ntp_time.c:496
937#: plugins/check_pgsql.c:335 plugins/check_ping.c:295 plugins/check_ping.c:418
938#: plugins/check_radius.c:264 plugins/check_real.c:314
939#: plugins/check_real.c:376 plugins/check_smtp.c:499 plugins/check_smtp.c:641
940#: plugins/check_ssh.c:157 plugins/check_time.c:240 plugins/check_time.c:315
941#: plugins/check_ups.c:504 plugins/check_ups.c:573
942msgid "Invalid hostname/address" 741msgid "Invalid hostname/address"
943msgstr "Adresse/Nom d'hôte invalide" 742msgstr "Adresse/Nom d'hôte invalide"
944 743
945#: plugins/check_fping.c:345 plugins/check_ldap.c:353 plugins/check_ping.c:246
946msgid "IPv6 support not available\n" 744msgid "IPv6 support not available\n"
947msgstr "Support IPv6 non disponible\n" 745msgstr "Support IPv6 non disponible\n"
948 746
949#: plugins/check_fping.c:378
950msgid "Packet size must be a positive integer" 747msgid "Packet size must be a positive integer"
951msgstr "La taille du paquet doit être un entier positif" 748msgstr "La taille du paquet doit être un entier positif"
952 749
953#: plugins/check_fping.c:384
954msgid "Packet count must be a positive integer" 750msgid "Packet count must be a positive integer"
955msgstr "Le nombre de paquets doit être un entier positif" 751msgstr "Le nombre de paquets doit être un entier positif"
956 752
957#: plugins/check_fping.c:390
958msgid "Target timeout must be a positive integer" 753msgid "Target timeout must be a positive integer"
959msgstr "Le seuil d'avertissement doit être un entier positif" 754msgstr "Le seuil d'avertissement doit être un entier positif"
960 755
961#: plugins/check_fping.c:396
962msgid "Interval must be a positive integer" 756msgid "Interval must be a positive integer"
963msgstr "Le délai d'attente doit être un entier positif" 757msgstr "Le délai d'attente doit être un entier positif"
964 758
965#: plugins/check_fping.c:402 plugins/check_ntp.c:733
966#: plugins/check_ntp_peer.c:524 plugins/check_ntp_time.c:523
967#: plugins/check_radius.c:314 plugins/check_time.c:319
968msgid "Hostname was not supplied" 759msgid "Hostname was not supplied"
969msgstr "Le nom de l'hôte n'a pas été spécifié" 760msgstr "Le nom de l'hôte n'a pas été spécifié"
970 761
971#: plugins/check_fping.c:422
972#, c-format 762#, c-format
973msgid "%s: Only one threshold may be packet loss (%s)\n" 763msgid "%s: Only one threshold may be packet loss (%s)\n"
974msgstr "" 764msgstr ""
975"%s: Seulement un seuil peut être utilisé pour les pertes de paquets (%s)\n" 765"%s: Seulement un seuil peut être utilisé pour les pertes de paquets (%s)\n"
976 766
977#: plugins/check_fping.c:426
978#, c-format 767#, c-format
979msgid "%s: Only one threshold must be packet loss (%s)\n" 768msgid "%s: Only one threshold must be packet loss (%s)\n"
980msgstr "" 769msgstr ""
981"%s: Seulement un seuil doit être utilisé pour les pertes de paquets (%s)\n" 770"%s: Seulement un seuil doit être utilisé pour les pertes de paquets (%s)\n"
982 771
983#: plugins/check_fping.c:458
984msgid "" 772msgid ""
985"This plugin will use the fping command to ping the specified host for a fast " 773"This plugin will use the fping command to ping the specified host for a fast "
986"check" 774"check"
987msgstr "" 775msgstr ""
988"Ce plugin va utiliser la commande fping pour pinger l'hôte de manière rapide." 776"Ce plugin va utiliser la commande fping pour pinger l'hôte de manière rapide."
989 777
990#: plugins/check_fping.c:460
991msgid "Note that it is necessary to set the suid flag on fping." 778msgid "Note that it is necessary to set the suid flag on fping."
992msgstr "" 779msgstr ""
993"Veuillez noter qu'il est nécessaire de mettre le bit suid sur le programme " 780"Veuillez noter qu'il est nécessaire de mettre le bit suid sur le programme "
994"fping." 781"fping."
995 782
996#: plugins/check_fping.c:472
997msgid "" 783msgid ""
998"name or IP Address of host to ping (IP Address bypasses name lookup, " 784"name or IP Address of host to ping (IP Address bypasses name lookup, "
999"reducing system load)" 785"reducing system load)"
@@ -1001,39 +787,33 @@ msgstr ""
1001"nom ou adresse IP des hôtes à pinger (l'indication d'un adresse IP évite une " 787"nom ou adresse IP des hôtes à pinger (l'indication d'un adresse IP évite une "
1002"recherche sur le nom, ce qui réduit la charge système)" 788"recherche sur le nom, ce qui réduit la charge système)"
1003 789
1004#: plugins/check_fping.c:474 plugins/check_ping.c:575
1005msgid "warning threshold pair" 790msgid "warning threshold pair"
1006msgstr "Valeurs pour le seuil d'avertissement" 791msgstr "Valeurs pour le seuil d'avertissement"
1007 792
1008#: plugins/check_fping.c:476 plugins/check_ping.c:577
1009msgid "critical threshold pair" 793msgid "critical threshold pair"
1010msgstr "Valeurs pour le seuil critique" 794msgstr "Valeurs pour le seuil critique"
1011 795
1012#: plugins/check_fping.c:478 796msgid "Return OK after first successful reply"
797msgstr ""
798
1013msgid "size of ICMP packet" 799msgid "size of ICMP packet"
1014msgstr "taille du paquet ICMP" 800msgstr "taille du paquet ICMP"
1015 801
1016#: plugins/check_fping.c:480
1017msgid "number of ICMP packets to send" 802msgid "number of ICMP packets to send"
1018msgstr "nombre de paquets ICMP à envoyer" 803msgstr "nombre de paquets ICMP à envoyer"
1019 804
1020#: plugins/check_fping.c:482
1021msgid "Target timeout (ms)" 805msgid "Target timeout (ms)"
1022msgstr "" 806msgstr ""
1023 807
1024#: plugins/check_fping.c:484
1025msgid "Interval (ms) between sending packets" 808msgid "Interval (ms) between sending packets"
1026msgstr "" 809msgstr ""
1027 810
1028#: plugins/check_fping.c:486
1029msgid "name or IP Address of sourceip" 811msgid "name or IP Address of sourceip"
1030msgstr "" 812msgstr ""
1031 813
1032#: plugins/check_fping.c:488
1033msgid "source interface name" 814msgid "source interface name"
1034msgstr "" 815msgstr ""
1035 816
1036#: plugins/check_fping.c:491
1037#, c-format 817#, c-format
1038msgid "" 818msgid ""
1039"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time " 819"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time "
@@ -1042,63 +822,50 @@ msgstr ""
1042"Le seuil est <rta>,<pl>%% ou <rta> est le temps moyen pour l'aller retour " 822"Le seuil est <rta>,<pl>%% ou <rta> est le temps moyen pour l'aller retour "
1043"(ms)" 823"(ms)"
1044 824
1045#: plugins/check_fping.c:492
1046msgid "" 825msgid ""
1047"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of" 826"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of"
1048msgstr "" 827msgstr ""
1049"qui déclenche résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le pourcentage " 828"qui déclenche résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le pourcentage "
1050"de" 829"de"
1051 830
1052#: plugins/check_fping.c:493
1053msgid "packet loss to trigger an alarm state." 831msgid "packet loss to trigger an alarm state."
1054msgstr "paquets perdu pour déclencher une alarme." 832msgstr "paquets perdu pour déclencher une alarme."
1055 833
1056#: plugins/check_fping.c:496
1057msgid "IPv4 is used by default. Specify -6 to use IPv6." 834msgid "IPv4 is used by default. Specify -6 to use IPv6."
1058msgstr "" 835msgstr ""
1059 836
1060#: plugins/check_game.c:111
1061#, c-format 837#, c-format
1062msgid "CRITICAL - Host type parameter incorrect!\n" 838msgid "CRITICAL - Host type parameter incorrect!\n"
1063msgstr "CRITIQUE - Argument de type hôte incorrect!\n" 839msgstr "CRITIQUE - Argument de type hôte incorrect!\n"
1064 840
1065#: plugins/check_game.c:126
1066#, c-format 841#, c-format
1067msgid "CRITICAL - Host not found\n" 842msgid "CRITICAL - Host not found\n"
1068msgstr "CRITIQUE - Hôte non trouvé\n" 843msgstr "CRITIQUE - Hôte non trouvé\n"
1069 844
1070#: plugins/check_game.c:130
1071#, c-format 845#, c-format
1072msgid "CRITICAL - Game server down or unavailable\n" 846msgid "CRITICAL - Game server down or unavailable\n"
1073msgstr "CRITIQUE - Serveur de jeux en panne ou non disponible\n" 847msgstr "CRITIQUE - Serveur de jeux en panne ou non disponible\n"
1074 848
1075#: plugins/check_game.c:134
1076#, c-format 849#, c-format
1077msgid "CRITICAL - Game server timeout\n" 850msgid "CRITICAL - Game server timeout\n"
1078msgstr "CRITIQUE - Temps d'attente pour le serveur de jeux dépassé\n" 851msgstr "CRITIQUE - Temps d'attente pour le serveur de jeux dépassé\n"
1079 852
1080#: plugins/check_game.c:297
1081#, c-format 853#, c-format
1082msgid "This plugin tests game server connections with the specified host." 854msgid "This plugin tests game server connections with the specified host."
1083msgstr "Le plugin teste la connexion au serveur de jeux avec l'hôte spécifié." 855msgstr "Le plugin teste la connexion au serveur de jeux avec l'hôte spécifié."
1084 856
1085#: plugins/check_game.c:307
1086msgid "Optional port of which to connect" 857msgid "Optional port of which to connect"
1087msgstr "" 858msgstr ""
1088 859
1089#: plugins/check_game.c:309
1090msgid "Field number in raw qstat output that contains game name" 860msgid "Field number in raw qstat output that contains game name"
1091msgstr "" 861msgstr ""
1092 862
1093#: plugins/check_game.c:311
1094msgid "Field number in raw qstat output that contains map name" 863msgid "Field number in raw qstat output that contains map name"
1095msgstr "" 864msgstr ""
1096 865
1097#: plugins/check_game.c:313
1098msgid "Field number in raw qstat output that contains ping time" 866msgid "Field number in raw qstat output that contains ping time"
1099msgstr "" 867msgstr ""
1100 868
1101#: plugins/check_game.c:319
1102msgid "" 869msgid ""
1103"This plugin uses the 'qstat' command, the popular game server status query " 870"This plugin uses the 'qstat' command, the popular game server status query "
1104"tool." 871"tool."
@@ -1106,789 +873,706 @@ msgstr ""
1106"Ce plugin utilise la commande 'qstat', un programme répandu pour questioner " 873"Ce plugin utilise la commande 'qstat', un programme répandu pour questioner "
1107"les serveurs de jeux." 874"les serveurs de jeux."
1108 875
1109#: plugins/check_game.c:320
1110msgid "" 876msgid ""
1111"If you don't have the package installed, you will need to download it from" 877"If you don't have the package installed, you will need to download it from"
1112msgstr "" 878msgstr ""
1113"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis" 879"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis"
1114 880
1115#: plugins/check_game.c:321 881#, fuzzy
1116msgid "" 882msgid "https://github.com/multiplay/qstat before you can use this plugin."
1117"http://www.activesw.com/people/steve/qstat.html before you can use this "
1118"plugin."
1119msgstr "" 883msgstr ""
1120"http://www.activesw.com/people/steve/qstat.html avant de pouvoir utiliser ce " 884"http://www.activesw.com/people/steve/qstat.html avant de pouvoir utiliser ce "
1121"plugin." 885"plugin."
1122 886
1123#: plugins/check_hpjd.c:239
1124msgid "Paper Jam" 887msgid "Paper Jam"
1125msgstr "Bourrage Papier" 888msgstr "Bourrage Papier"
1126 889
1127#: plugins/check_hpjd.c:243
1128msgid "Out of Paper" 890msgid "Out of Paper"
1129msgstr "Plus de Papier" 891msgstr "Plus de Papier"
1130 892
1131#: plugins/check_hpjd.c:248
1132msgid "Printer Offline" 893msgid "Printer Offline"
1133msgstr "Imprimante hors ligne" 894msgstr "Imprimante hors ligne"
1134 895
1135#: plugins/check_hpjd.c:253
1136msgid "Peripheral Error" 896msgid "Peripheral Error"
1137msgstr "Erreur du périphérique" 897msgstr "Erreur du périphérique"
1138 898
1139#: plugins/check_hpjd.c:257
1140msgid "Intervention Required" 899msgid "Intervention Required"
1141msgstr "Intervention Requise" 900msgstr "Intervention Requise"
1142 901
1143#: plugins/check_hpjd.c:261
1144msgid "Toner Low" 902msgid "Toner Low"
1145msgstr "Toner Faible" 903msgstr "Toner Faible"
1146 904
1147#: plugins/check_hpjd.c:265
1148msgid "Insufficient Memory" 905msgid "Insufficient Memory"
1149msgstr "Mémoire Insuffisante" 906msgstr "Mémoire Insuffisante"
1150 907
1151#: plugins/check_hpjd.c:269
1152msgid "A Door is Open" 908msgid "A Door is Open"
1153msgstr "Une porte est ouverte" 909msgstr "Une porte est ouverte"
1154 910
1155#: plugins/check_hpjd.c:273
1156msgid "Output Tray is Full" 911msgid "Output Tray is Full"
1157msgstr "Le bac de sortie est plein" 912msgstr "Le bac de sortie est plein"
1158 913
1159#: plugins/check_hpjd.c:277
1160msgid "Data too Slow for Engine" 914msgid "Data too Slow for Engine"
1161msgstr "Le données arrivent trop lentement pour l'imprimante" 915msgstr "Le données arrivent trop lentement pour l'imprimante"
1162 916
1163#: plugins/check_hpjd.c:281
1164msgid "Unknown Paper Error" 917msgid "Unknown Paper Error"
1165msgstr "Erreur de papier inconnue" 918msgstr "Erreur de papier inconnue"
1166 919
1167#: plugins/check_hpjd.c:286
1168#, c-format 920#, c-format
1169msgid "Printer ok - (%s)\n" 921msgid "Printer ok - (%s)\n"
1170msgstr "Imprimante ok - (%s)\n" 922msgstr "Imprimante ok - (%s)\n"
1171 923
1172#: plugins/check_hpjd.c:391 924#, fuzzy
925msgid "Port must be a positive short integer"
926msgstr "Le numéro du port doit être un entier positif"
927
1173msgid "This plugin tests the STATUS of an HP printer with a JetDirect card." 928msgid "This plugin tests the STATUS of an HP printer with a JetDirect card."
1174msgstr "Ce plugin teste l'état d'une imprimante HP avec une carte JetDirect." 929msgstr "Ce plugin teste l'état d'une imprimante HP avec une carte JetDirect."
1175 930
1176#: plugins/check_hpjd.c:392
1177msgid "Net-snmp must be installed on the computer running the plugin." 931msgid "Net-snmp must be installed on the computer running the plugin."
1178msgstr "Net-snmp doit être installé sur l'ordinateur qui exécute le plugin." 932msgstr "Net-snmp doit être installé sur l'ordinateur qui exécute le plugin."
1179 933
1180#: plugins/check_hpjd.c:402
1181msgid "The SNMP community name " 934msgid "The SNMP community name "
1182msgstr "Le nom de la communauté SNMP " 935msgstr "Le nom de la communauté SNMP "
1183 936
1184#: plugins/check_hpjd.c:403
1185#, c-format 937#, c-format
1186msgid "(default=%s)" 938msgid "(default=%s)"
1187msgstr "(défaut=%s)" 939msgstr "(défaut=%s)"
1188 940
1189#: plugins/check_http.c:189 941#, fuzzy
942msgid "Specify the port to check "
943msgstr "Nom de l'hôte à vérifier"
944
945#, fuzzy
946msgid "Disable paper check "
947msgstr "Variable a vérifier"
948
1190msgid "file does not exist or is not readable" 949msgid "file does not exist or is not readable"
1191msgstr "" 950msgstr ""
1192 951
1193#: plugins/check_http.c:310 plugins/check_http.c:315 plugins/check_http.c:321
1194#: plugins/check_smtp.c:600 plugins/check_tcp.c:576 plugins/check_tcp.c:580
1195#: plugins/check_tcp.c:586
1196msgid "Invalid certificate expiration period" 952msgid "Invalid certificate expiration period"
1197msgstr "Période d'expiration du certificat invalide" 953msgstr "Période d'expiration du certificat invalide"
1198 954
1199#: plugins/check_http.c:348
1200msgid "" 955msgid ""
1201"Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 " 956"Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional "
1202"(SSLv3)" 957"'+' suffix)"
1203msgstr "" 958msgstr ""
1204 959
1205#: plugins/check_http.c:354 plugins/check_tcp.c:599
1206msgid "Invalid option - SSL is not available" 960msgid "Invalid option - SSL is not available"
1207msgstr "Option invalide - SSL n'est pas disponible" 961msgstr "Option invalide - SSL n'est pas disponible"
1208 962
1209#: plugins/check_http.c:375 963msgid "Invalid max_redirs count"
964msgstr ""
965
1210msgid "Invalid onredirect option" 966msgid "Invalid onredirect option"
1211msgstr "" 967msgstr ""
1212 968
1213#: plugins/check_http.c:377
1214#, c-format 969#, c-format
1215msgid "option f:%d \n" 970msgid "option f:%d \n"
1216msgstr "option f:%d \n" 971msgstr "option f:%d \n"
1217 972
1218#: plugins/check_http.c:398
1219msgid "Invalid port number" 973msgid "Invalid port number"
1220msgstr "Numéro de port invalide" 974msgstr "Numéro de port invalide"
1221 975
1222#: plugins/check_http.c:450
1223#, c-format 976#, c-format
1224msgid "Could Not Compile Regular Expression: %s" 977msgid "Could Not Compile Regular Expression: %s"
1225msgstr "Impossible de compiler l'expression rationnelle: %s" 978msgstr "Impossible de compiler l'expression rationnelle: %s"
1226 979
1227#: plugins/check_http.c:464 plugins/check_ntp.c:722
1228#: plugins/check_ntp_peer.c:513 plugins/check_ntp_time.c:512
1229#: plugins/check_smtp.c:621 plugins/check_ssh.c:149 plugins/check_tcp.c:477
1230msgid "IPv6 support not available" 980msgid "IPv6 support not available"
1231msgstr "Support IPv6 non disponible" 981msgstr "Support IPv6 non disponible"
1232 982
1233#: plugins/check_http.c:529 plugins/check_ping.c:422
1234msgid "You must specify a server address or host name" 983msgid "You must specify a server address or host name"
1235msgstr "Vous devez spécifier une adresse ou un nom d'hôte" 984msgstr "Vous devez spécifier une adresse ou un nom d'hôte"
1236 985
1237#: plugins/check_http.c:543
1238msgid "" 986msgid ""
1239"If you use a client certificate you must also specify a private key file" 987"If you use a client certificate you must also specify a private key file"
1240msgstr "" 988msgstr ""
1241 989
1242#: plugins/check_http.c:667 plugins/check_http.c:835
1243msgid "HTTP UNKNOWN - Memory allocation error\n" 990msgid "HTTP UNKNOWN - Memory allocation error\n"
1244msgstr "HTTP INCONNU - Impossible d'allouer la mémoire\n" 991msgstr "HTTP INCONNU - Impossible d'allouer la mémoire\n"
1245 992
1246#: plugins/check_http.c:739
1247#, c-format 993#, c-format
1248msgid "%sServer date unknown, " 994msgid "%sServer date unknown, "
1249msgstr "%sDate du serveur inconnue, " 995msgstr "%sDate du serveur inconnue, "
1250 996
1251#: plugins/check_http.c:742
1252#, c-format 997#, c-format
1253msgid "%sDocument modification date unknown, " 998msgid "%sDocument modification date unknown, "
1254msgstr "%sDate de modification du document inconnue, " 999msgstr "%sDate de modification du document inconnue, "
1255 1000
1256#: plugins/check_http.c:749
1257#, c-format 1001#, c-format
1258msgid "%sServer date \"%100s\" unparsable, " 1002msgid "%sServer date \"%100s\" unparsable, "
1259msgstr "%sDate du serveur \"%100s\" illisible, " 1003msgstr "%sDate du serveur \"%100s\" illisible, "
1260 1004
1261#: plugins/check_http.c:752
1262#, c-format 1005#, c-format
1263msgid "%sDocument date \"%100s\" unparsable, " 1006msgid "%sDocument date \"%100s\" unparsable, "
1264msgstr "%sDate du document \"%100s\" illisible, " 1007msgstr "%sDate du document \"%100s\" illisible, "
1265 1008
1266#: plugins/check_http.c:755
1267#, c-format 1009#, c-format
1268msgid "%sDocument is %d seconds in the future, " 1010msgid "%sDocument is %d seconds in the future, "
1269msgstr "%sLa date du document est %d secondes dans le futur, " 1011msgstr "%sLa date du document est %d secondes dans le futur, "
1270 1012
1271#: plugins/check_http.c:760
1272#, c-format 1013#, c-format
1273msgid "%sLast modified %.1f days ago, " 1014msgid "%sLast modified %.1f days ago, "
1274msgstr "%sDernière modification %.1f jours auparavant, " 1015msgstr "%sDernière modification %.1f jours auparavant, "
1275 1016
1276#: plugins/check_http.c:763
1277#, c-format 1017#, c-format
1278msgid "%sLast modified %d:%02d:%02d ago, " 1018msgid "%sLast modified %d:%02d:%02d ago, "
1279msgstr "%sDernière modification %d:%02d:%02d auparavant, " 1019msgstr "%sDernière modification %d:%02d:%02d auparavant, "
1280 1020
1281#: plugins/check_http.c:876
1282msgid "HTTP CRITICAL - Unable to open TCP socket\n" 1021msgid "HTTP CRITICAL - Unable to open TCP socket\n"
1283msgstr "HTTP CRITIQUE - Impossible d'ouvrir un socket TCP\n" 1022msgstr "HTTP CRITIQUE - Impossible d'ouvrir un socket TCP\n"
1284 1023
1285#: plugins/check_http.c:995 1024#, fuzzy
1025msgid "HTTP UNKNOWN - Could not allocate memory for full_page\n"
1026msgstr "HTTP INCONNU - Impossible d'allouer une adresse\n"
1027
1286msgid "HTTP CRITICAL - Error on receive\n" 1028msgid "HTTP CRITICAL - Error on receive\n"
1287msgstr "HTTP CRITIQUE - Erreur dans la réception\n" 1029msgstr "HTTP CRITIQUE - Erreur dans la réception\n"
1288 1030
1289#: plugins/check_http.c:1005
1290msgid "HTTP CRITICAL - No data received from host\n" 1031msgid "HTTP CRITICAL - No data received from host\n"
1291msgstr "HTTP CRITIQUE - Pas de données reçues de l'hôte\n" 1032msgstr "HTTP CRITIQUE - Pas de données reçues de l'hôte\n"
1292 1033
1293#: plugins/check_http.c:1056
1294#, c-format 1034#, c-format
1295msgid "Invalid HTTP response received from host: %s\n" 1035msgid "Invalid HTTP response received from host: %s\n"
1296msgstr "Réponse HTTP reçue de l'hôte invalide: %s\n" 1036msgstr "Réponse HTTP reçue de l'hôte invalide: %s\n"
1297 1037
1298#: plugins/check_http.c:1060
1299#, c-format 1038#, c-format
1300msgid "Invalid HTTP response received from host on port %d: %s\n" 1039msgid "Invalid HTTP response received from host on port %d: %s\n"
1301msgstr "Réponse HTTP reçue de l'hôte sur le port %d invalide: %s\n" 1040msgstr "Réponse HTTP reçue de l'hôte sur le port %d invalide: %s\n"
1302 1041
1303#: plugins/check_http.c:1069 1042#, c-format
1043msgid ""
1044"%s\n"
1045"%s"
1046msgstr ""
1047
1304#, c-format 1048#, c-format
1305msgid "Status line output matched \"%s\" - " 1049msgid "Status line output matched \"%s\" - "
1306msgstr "La ligne d'état correspond à \"%s\" - " 1050msgstr "La ligne d'état correspond à \"%s\" - "
1307 1051
1308#: plugins/check_http.c:1080
1309#, c-format 1052#, c-format
1310msgid "HTTP CRITICAL: Invalid Status Line (%s)\n" 1053msgid "HTTP CRITICAL: Invalid Status Line (%s)\n"
1311msgstr "HTTP CRITIQUE: Ligne d'état non valide (%s)\n" 1054msgstr "HTTP CRITIQUE: Ligne d'état non valide (%s)\n"
1312 1055
1313#: plugins/check_http.c:1087
1314#, c-format 1056#, c-format
1315msgid "HTTP CRITICAL: Invalid Status (%s)\n" 1057msgid "HTTP CRITICAL: Invalid Status (%s)\n"
1316msgstr "HTTP CRITIQUE: Etat Invalide (%s)\n" 1058msgstr "HTTP CRITIQUE: Etat Invalide (%s)\n"
1317 1059
1318#: plugins/check_http.c:1091 plugins/check_http.c:1096
1319#: plugins/check_http.c:1106 plugins/check_http.c:1110
1320#, c-format 1060#, c-format
1321msgid "%s - " 1061msgid "%s - "
1322msgstr "" 1062msgstr ""
1323 1063
1324#: plugins/check_http.c:1129
1325#, fuzzy, c-format 1064#, fuzzy, c-format
1326msgid "%sheader '%s' not found on '%s://%s:%d%s', " 1065msgid "%sheader '%s' not found on '%s://%s:%d%s', "
1327msgstr "%schaîne non trouvée, " 1066msgstr "%schaîne non trouvée, "
1328 1067
1329#: plugins/check_http.c:1141
1330#, fuzzy, c-format 1068#, fuzzy, c-format
1331msgid "%sstring '%s' not found on '%s://%s:%d%s', " 1069msgid "%sstring '%s' not found on '%s://%s:%d%s', "
1332msgstr "%schaîne non trouvée, " 1070msgstr "%schaîne non trouvée, "
1333 1071
1334#: plugins/check_http.c:1154
1335#, c-format 1072#, c-format
1336msgid "%spattern not found, " 1073msgid "%spattern not found, "
1337msgstr "%sexpression non trouvée, " 1074msgstr "%sexpression non trouvée, "
1338 1075
1339#: plugins/check_http.c:1156
1340#, c-format 1076#, c-format
1341msgid "%spattern found, " 1077msgid "%spattern found, "
1342msgstr "%sexpression trouvée, " 1078msgstr "%sexpression trouvée, "
1343 1079
1344#: plugins/check_http.c:1162
1345#, c-format 1080#, c-format
1346msgid "%sExecute Error: %s, " 1081msgid "%sExecute Error: %s, "
1347msgstr "%sErreur d'exécution: %s, " 1082msgstr "%sErreur d'exécution: %s, "
1348 1083
1349#: plugins/check_http.c:1178
1350#, c-format 1084#, c-format
1351msgid "%spage size %d too large, " 1085msgid "%spage size %d too large, "
1352msgstr "%sla taille de la page est trop grande (%d), " 1086msgstr "%sla taille de la page est trop grande (%d), "
1353 1087
1354#: plugins/check_http.c:1181
1355#, c-format 1088#, c-format
1356msgid "%spage size %d too small, " 1089msgid "%spage size %d too small, "
1357msgstr "%sla taille de la page est trop petite (%d), " 1090msgstr "%sla taille de la page est trop petite (%d), "
1358 1091
1359#: plugins/check_http.c:1194
1360#, fuzzy, c-format 1092#, fuzzy, c-format
1361msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s" 1093msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"
1362msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s" 1094msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s"
1363 1095
1364#: plugins/check_http.c:1206
1365#, c-format 1096#, c-format
1366msgid "%s - %d bytes in %.3f second response time %s|%s %s" 1097msgid "%s - %d bytes in %.3f second response time %s|%s %s"
1367msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s" 1098msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s"
1368 1099
1369#: plugins/check_http.c:1244
1370msgid "HTTP UNKNOWN - Could not allocate addr\n" 1100msgid "HTTP UNKNOWN - Could not allocate addr\n"
1371msgstr "HTTP INCONNU - Impossible d'allouer une adresse\n" 1101msgstr "HTTP INCONNU - Impossible d'allouer une adresse\n"
1372 1102
1373#: plugins/check_http.c:1248 plugins/check_http.c:1279
1374msgid "HTTP UNKNOWN - Could not allocate URL\n" 1103msgid "HTTP UNKNOWN - Could not allocate URL\n"
1375msgstr "HTTP INCONNU - Impossible d'allouer l'URL\n" 1104msgstr "HTTP INCONNU - Impossible d'allouer l'URL\n"
1376 1105
1377#: plugins/check_http.c:1257
1378#, c-format 1106#, c-format
1379msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n" 1107msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n"
1380msgstr "" 1108msgstr ""
1381"HTTP INCONNU - Impossible de trouver l'endroit de la redirection - %s%s\n" 1109"HTTP INCONNU - Impossible de trouver l'endroit de la redirection - %s%s\n"
1382 1110
1383#: plugins/check_http.c:1272
1384#, c-format 1111#, c-format
1385msgid "HTTP UNKNOWN - Empty redirect location%s\n" 1112msgid "HTTP UNKNOWN - Empty redirect location%s\n"
1386msgstr "HTTP INCONNU - endroit de redirection vide%s\n" 1113msgstr "HTTP INCONNU - endroit de redirection vide%s\n"
1387 1114
1388#: plugins/check_http.c:1322
1389#, c-format 1115#, c-format
1390msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n" 1116msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n"
1391msgstr "" 1117msgstr ""
1392"HTTP INCONNU - Impossible de définir l'endroit de la redirection - %s%s\n" 1118"HTTP INCONNU - Impossible de définir l'endroit de la redirection - %s%s\n"
1393 1119
1394#: plugins/check_http.c:1332
1395#, c-format 1120#, c-format
1396msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n" 1121msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n"
1397msgstr "" 1122msgstr ""
1398"HTTP AVERTISSEMENT - le niveau maximum de redirection %d à été dépassé - " 1123"HTTP AVERTISSEMENT - le niveau maximum de redirection %d à été dépassé - "
1399"%s://%s:%d%s%s\n" 1124"%s://%s:%d%s%s\n"
1400 1125
1401#: plugins/check_http.c:1340 1126#, fuzzy, c-format
1402#, c-format 1127msgid "HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1403msgid "HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1404msgstr "" 1128msgstr ""
1405"HTTP AVERTISSEMENT - la redirection crée une boucle infinie - %s://%s:%d%s" 1129"HTTP AVERTISSEMENT - la redirection crée une boucle infinie - %s://%s:"
1406"%s\n" 1130"%d%s%s\n"
1407 1131
1408#: plugins/check_http.c:1361
1409#, c-format 1132#, c-format
1410msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n" 1133msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"
1411msgstr "HTTP INCONNU - Redirection à un port supérieur à %d - %s://%s:%d%s%s\n" 1134msgstr "HTTP INCONNU - Redirection à un port supérieur à %d - %s://%s:%d%s%s\n"
1412 1135
1413#: plugins/check_http.c:1366
1414#, c-format 1136#, c-format
1415msgid "Redirection to %s://%s:%d%s\n" 1137msgid "Redirection to %s://%s:%d%s\n"
1416msgstr "Redirection vers %s://%s:%d%s\n" 1138msgstr "Redirection vers %s://%s:%d%s\n"
1417 1139
1418#: plugins/check_http.c:1440
1419msgid "This plugin tests the HTTP service on the specified host. It can test" 1140msgid "This plugin tests the HTTP service on the specified host. It can test"
1420msgstr "" 1141msgstr ""
1421"Ce plugin teste le service HTTP sur l'hôte spécifié. Il peut tester les" 1142"Ce plugin teste le service HTTP sur l'hôte spécifié. Il peut tester les"
1422 1143
1423#: plugins/check_http.c:1441
1424msgid "normal (http) and secure (https) servers, follow redirects, search for" 1144msgid "normal (http) and secure (https) servers, follow redirects, search for"
1425msgstr "" 1145msgstr ""
1426"serveurs normaux (http) et sécurisés (https), suivre les redirections, " 1146"serveurs normaux (http) et sécurisés (https), suivre les redirections, "
1427"rechercher des" 1147"rechercher des"
1428 1148
1429#: plugins/check_http.c:1442
1430msgid "strings and regular expressions, check connection times, and report on" 1149msgid "strings and regular expressions, check connection times, and report on"
1431msgstr "" 1150msgstr ""
1432"chaînes de caractères et expressions rationnelles, vérifier le temps de " 1151"chaînes de caractères et expressions rationnelles, vérifier le temps de "
1433"réponse" 1152"réponse"
1434 1153
1435#: plugins/check_http.c:1443
1436msgid "certificate expiration times." 1154msgid "certificate expiration times."
1437msgstr "et rapporter la date d'expiration du certificat." 1155msgstr "et rapporter la date d'expiration du certificat."
1438 1156
1439#: plugins/check_http.c:1449 1157#, c-format
1158msgid "In the first form, make an HTTP request."
1159msgstr ""
1160
1161#, c-format
1162msgid ""
1163"In the second form, connect to the server and check the TLS certificate."
1164msgstr ""
1165
1440#, c-format 1166#, c-format
1441msgid "NOTE: One or both of -H and -I must be specified" 1167msgid "NOTE: One or both of -H and -I must be specified"
1442msgstr "NOTE: les paramètres -H et -I peuvent être spécifiés" 1168msgstr "NOTE: les paramètres -H et -I peuvent être spécifiés"
1443 1169
1444#: plugins/check_http.c:1457
1445msgid "Host name argument for servers using host headers (virtual host)" 1170msgid "Host name argument for servers using host headers (virtual host)"
1446msgstr "" 1171msgstr ""
1447 1172
1448#: plugins/check_http.c:1458
1449msgid "Append a port to include it in the header (eg: example.com:5000)" 1173msgid "Append a port to include it in the header (eg: example.com:5000)"
1450msgstr "" 1174msgstr ""
1451 1175
1452#: plugins/check_http.c:1460
1453msgid "" 1176msgid ""
1454"IP address or name (use numeric address if possible to bypass DNS lookup)." 1177"IP address or name (use numeric address if possible to bypass DNS lookup)."
1455msgstr "" 1178msgstr ""
1456 1179
1457#: plugins/check_http.c:1462
1458msgid "Port number (default: " 1180msgid "Port number (default: "
1459msgstr "Numéro du port (défaut: " 1181msgstr "Numéro du port (défaut: "
1460 1182
1461#: plugins/check_http.c:1469
1462msgid "" 1183msgid ""
1463"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents" 1184"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"
1464msgstr "" 1185msgstr ""
1465 1186
1466#: plugins/check_http.c:1470 1187msgid "auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"
1467msgid "auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)." 1188msgstr ""
1189
1190msgid "1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."
1468msgstr "" 1191msgstr ""
1469 1192
1470#: plugins/check_http.c:1472
1471msgid "Enable SSL/TLS hostname extension support (SNI)" 1193msgid "Enable SSL/TLS hostname extension support (SNI)"
1472msgstr "" 1194msgstr ""
1473 1195
1474#: plugins/check_http.c:1474
1475msgid "" 1196msgid ""
1476"Minimum number of days a certificate has to be valid. Port defaults to 443" 1197"Minimum number of days a certificate has to be valid. Port defaults to 443"
1477msgstr "" 1198msgstr ""
1478"Nombre de jours minimum pour que le certificat soit valide. Port par défaut " 1199"Nombre de jours minimum pour que le certificat soit valide. Port par défaut "
1479"443" 1200"443"
1480 1201
1481#: plugins/check_http.c:1475 1202msgid ""
1482msgid "(when this option is used the URL is not checked.)" 1203"(when this option is used the URL is not checked by default. You can use"
1204msgstr ""
1205
1206msgid " --continue-after-certificate to override this behavior)"
1207msgstr ""
1208
1209msgid ""
1210"Allows the HTTP check to continue after performing the certificate check."
1211msgstr ""
1212
1213msgid "Does nothing unless -C is used."
1483msgstr "" 1214msgstr ""
1484 1215
1485#: plugins/check_http.c:1477
1486msgid "Name of file that contains the client certificate (PEM format)" 1216msgid "Name of file that contains the client certificate (PEM format)"
1487msgstr "" 1217msgstr ""
1488 1218
1489#: plugins/check_http.c:1478
1490msgid "to be used in establishing the SSL session" 1219msgid "to be used in establishing the SSL session"
1491msgstr "" 1220msgstr ""
1492 1221
1493#: plugins/check_http.c:1480
1494msgid "Name of file containing the private key (PEM format)" 1222msgid "Name of file containing the private key (PEM format)"
1495msgstr "" 1223msgstr ""
1496 1224
1497#: plugins/check_http.c:1481
1498msgid "matching the client certificate" 1225msgid "matching the client certificate"
1499msgstr "" 1226msgstr ""
1500 1227
1501#: plugins/check_http.c:1485
1502msgid "Comma-delimited list of strings, at least one of them is expected in" 1228msgid "Comma-delimited list of strings, at least one of them is expected in"
1503msgstr "" 1229msgstr ""
1504"Liste the chaines de charactères séparées par des virgules, au moins une " 1230"Liste the chaines de charactères séparées par des virgules, au moins une "
1505"d'elles" 1231"d'elles"
1506 1232
1507#: plugins/check_http.c:1486
1508msgid "the first (status) line of the server response (default: " 1233msgid "the first (status) line of the server response (default: "
1509msgstr "est attendue dans la première ligne de réponse du serveur (défaut: " 1234msgstr "est attendue dans la première ligne de réponse du serveur (défaut: "
1510 1235
1511#: plugins/check_http.c:1488
1512msgid "" 1236msgid ""
1513"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)" 1237"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"
1514msgstr "" 1238msgstr ""
1515"Si spécifié, surpasse toute autre logique de status (ex: 3xx, 4xx, 5xx)" 1239"Si spécifié, surpasse toute autre logique de status (ex: 3xx, 4xx, 5xx)"
1516 1240
1517#: plugins/check_http.c:1490
1518#, fuzzy 1241#, fuzzy
1519msgid "String to expect in the response headers" 1242msgid "String to expect in the response headers"
1520msgstr "Chaîne de caractères à attendre en réponse" 1243msgstr "Chaîne de caractères à attendre en réponse"
1521 1244
1522#: plugins/check_http.c:1492
1523msgid "String to expect in the content" 1245msgid "String to expect in the content"
1524msgstr "Chaîne de caractère attendue dans le contenu" 1246msgstr "Chaîne de caractère attendue dans le contenu"
1525 1247
1526#: plugins/check_http.c:1494
1527msgid "URL to GET or POST (default: /)" 1248msgid "URL to GET or POST (default: /)"
1528msgstr "URL pour le GET ou le POST (défaut: /)" 1249msgstr "URL pour le GET ou le POST (défaut: /)"
1529 1250
1530#: plugins/check_http.c:1496
1531msgid "URL encoded http POST data" 1251msgid "URL encoded http POST data"
1532msgstr "" 1252msgstr ""
1533 1253
1534#: plugins/check_http.c:1498
1535msgid "Set HTTP method." 1254msgid "Set HTTP method."
1536msgstr "" 1255msgstr ""
1537 1256
1538#: plugins/check_http.c:1500
1539msgid "Don't wait for document body: stop reading after headers." 1257msgid "Don't wait for document body: stop reading after headers."
1540msgstr "" 1258msgstr ""
1541"Ne pas attendre pour le corps du document: arrêter de lire après les entêtes" 1259"Ne pas attendre pour le corps du document: arrêter de lire après les entêtes"
1542 1260
1543#: plugins/check_http.c:1501
1544msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)" 1261msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)"
1545msgstr "(Veuillez noter qu'un HTTP GET ou POST est effectué, pas un HEAD.)" 1262msgstr "(Veuillez noter qu'un HTTP GET ou POST est effectué, pas un HEAD.)"
1546 1263
1547#: plugins/check_http.c:1503
1548msgid "Warn if document is more than SECONDS old. the number can also be of" 1264msgid "Warn if document is more than SECONDS old. the number can also be of"
1549msgstr "" 1265msgstr ""
1550 1266
1551#: plugins/check_http.c:1504
1552msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days." 1267msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."
1553msgstr "" 1268msgstr ""
1554 1269
1555#: plugins/check_http.c:1506
1556msgid "specify Content-Type header media type when POSTing\n" 1270msgid "specify Content-Type header media type when POSTing\n"
1557msgstr "" 1271msgstr ""
1558 1272
1559#: plugins/check_http.c:1509
1560msgid "Allow regex to span newlines (must precede -r or -R)" 1273msgid "Allow regex to span newlines (must precede -r or -R)"
1561msgstr "" 1274msgstr ""
1562 1275
1563#: plugins/check_http.c:1511
1564msgid "Search page for regex STRING" 1276msgid "Search page for regex STRING"
1565msgstr "" 1277msgstr ""
1566 1278
1567#: plugins/check_http.c:1513
1568msgid "Search page for case-insensitive regex STRING" 1279msgid "Search page for case-insensitive regex STRING"
1569msgstr "" 1280msgstr ""
1570 1281
1571#: plugins/check_http.c:1515
1572msgid "Return CRITICAL if found, OK if not\n" 1282msgid "Return CRITICAL if found, OK if not\n"
1573msgstr "" 1283msgstr ""
1574 1284
1575#: plugins/check_http.c:1518
1576msgid "Username:password on sites with basic authentication" 1285msgid "Username:password on sites with basic authentication"
1577msgstr "" 1286msgstr ""
1578 1287
1579#: plugins/check_http.c:1520
1580msgid "Username:password on proxy-servers with basic authentication" 1288msgid "Username:password on proxy-servers with basic authentication"
1581msgstr "" 1289msgstr ""
1582 1290
1583#: plugins/check_http.c:1522
1584msgid "String to be sent in http header as \"User Agent\"" 1291msgid "String to be sent in http header as \"User Agent\""
1585msgstr "" 1292msgstr ""
1586 1293
1587#: plugins/check_http.c:1524
1588msgid "" 1294msgid ""
1589"Any other tags to be sent in http header. Use multiple times for additional " 1295"Any other tags to be sent in http header. Use multiple times for additional "
1590"headers" 1296"headers"
1591msgstr "" 1297msgstr ""
1592 1298
1593#: plugins/check_http.c:1526
1594msgid "Print additional performance data" 1299msgid "Print additional performance data"
1595msgstr "" 1300msgstr ""
1596 1301
1597#: plugins/check_http.c:1528 1302msgid "Print body content below status line"
1303msgstr ""
1304
1598msgid "Wrap output in HTML link (obsoleted by urlize)" 1305msgid "Wrap output in HTML link (obsoleted by urlize)"
1599msgstr "" 1306msgstr ""
1600 1307
1601#: plugins/check_http.c:1530
1602msgid "How to handle redirected pages. sticky is like follow but stick to the" 1308msgid "How to handle redirected pages. sticky is like follow but stick to the"
1603msgstr "" 1309msgstr ""
1604 1310
1605#: plugins/check_http.c:1531
1606msgid "specified IP address. stickyport also ensures port stays the same." 1311msgid "specified IP address. stickyport also ensures port stays the same."
1607msgstr "" 1312msgstr ""
1608 1313
1609#: plugins/check_http.c:1533 1314#, fuzzy
1315msgid "Maximal number of redirects (default: "
1316msgstr "PROCS - nombre de processus (défaut)"
1317
1610msgid "Minimum page size required (bytes) : Maximum page size required (bytes)" 1318msgid "Minimum page size required (bytes) : Maximum page size required (bytes)"
1611msgstr "" 1319msgstr ""
1612 1320
1613#: plugins/check_http.c:1543
1614msgid "This plugin will attempt to open an HTTP connection with the host." 1321msgid "This plugin will attempt to open an HTTP connection with the host."
1615msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte." 1322msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte."
1616 1323
1617#: plugins/check_http.c:1544
1618msgid "" 1324msgid ""
1619"Successful connects return STATE_OK, refusals and timeouts return " 1325"Successful connects return STATE_OK, refusals and timeouts return "
1620"STATE_CRITICAL" 1326"STATE_CRITICAL"
1621msgstr "" 1327msgstr ""
1622 1328
1623#: plugins/check_http.c:1545
1624msgid "" 1329msgid ""
1625"other errors return STATE_UNKNOWN. Successful connects, but incorrect " 1330"other errors return STATE_UNKNOWN. Successful connects, but incorrect "
1626"response" 1331"response"
1627msgstr "" 1332msgstr ""
1628 1333
1629#: plugins/check_http.c:1546
1630msgid "" 1334msgid ""
1631"messages from the host result in STATE_WARNING return values. If you are" 1335"messages from the host result in STATE_WARNING return values. If you are"
1632msgstr "" 1336msgstr ""
1633 1337
1634#: plugins/check_http.c:1547
1635msgid "" 1338msgid ""
1636"checking a virtual server that uses 'host headers' you must supply the FQDN" 1339"checking a virtual server that uses 'host headers' you must supply the FQDN"
1637msgstr "" 1340msgstr ""
1638 1341
1639#: plugins/check_http.c:1548
1640msgid "(fully qualified domain name) as the [host_name] argument." 1342msgid "(fully qualified domain name) as the [host_name] argument."
1641msgstr "" 1343msgstr ""
1642 1344
1643#: plugins/check_http.c:1552
1644msgid "This plugin can also check whether an SSL enabled web server is able to" 1345msgid "This plugin can also check whether an SSL enabled web server is able to"
1645msgstr "" 1346msgstr ""
1646 1347
1647#: plugins/check_http.c:1553
1648msgid "serve content (optionally within a specified time) or whether the X509 " 1348msgid "serve content (optionally within a specified time) or whether the X509 "
1649msgstr "" 1349msgstr ""
1650 1350
1651#: plugins/check_http.c:1554
1652msgid "certificate is still valid for the specified number of days." 1351msgid "certificate is still valid for the specified number of days."
1653msgstr "" 1352msgstr ""
1654 1353
1655#: plugins/check_http.c:1556
1656#, fuzzy 1354#, fuzzy
1657msgid "Please note that this plugin does not check if the presented server" 1355msgid "Please note that this plugin does not check if the presented server"
1658msgstr "Ce plugin vérifie le service ntp sur l'hôte" 1356msgstr "Ce plugin vérifie le service ntp sur l'hôte"
1659 1357
1660#: plugins/check_http.c:1557
1661msgid "certificate matches the hostname of the server, or if the certificate" 1358msgid "certificate matches the hostname of the server, or if the certificate"
1662msgstr "" 1359msgstr ""
1663 1360
1664#: plugins/check_http.c:1558
1665msgid "has a valid chain of trust to one of the locally installed CAs." 1361msgid "has a valid chain of trust to one of the locally installed CAs."
1666msgstr "" 1362msgstr ""
1667 1363
1668#: plugins/check_http.c:1562
1669msgid "" 1364msgid ""
1670"When the 'www.verisign.com' server returns its content within 5 seconds," 1365"When the 'www.verisign.com' server returns its content within 5 seconds,"
1671msgstr "" 1366msgstr ""
1672 1367
1673#: plugins/check_http.c:1563
1674msgid "" 1368msgid ""
1675"a STATE_OK will be returned. When the server returns its content but exceeds" 1369"a STATE_OK will be returned. When the server returns its content but exceeds"
1676msgstr "" 1370msgstr ""
1677 1371
1678#: plugins/check_http.c:1564
1679msgid "" 1372msgid ""
1680"the 5-second threshold, a STATE_WARNING will be returned. When an error " 1373"the 5-second threshold, a STATE_WARNING will be returned. When an error "
1681"occurs," 1374"occurs,"
1682msgstr "" 1375msgstr ""
1683 1376
1684#: plugins/check_http.c:1565
1685msgid "a STATE_CRITICAL will be returned." 1377msgid "a STATE_CRITICAL will be returned."
1686msgstr "" 1378msgstr ""
1687 1379
1688#: plugins/check_http.c:1568
1689msgid "" 1380msgid ""
1690"When the certificate of 'www.verisign.com' is valid for more than 14 days," 1381"When the certificate of 'www.verisign.com' is valid for more than 14 days,"
1691msgstr "" 1382msgstr ""
1692 1383
1693#: plugins/check_http.c:1569 plugins/check_http.c:1575
1694msgid "" 1384msgid ""
1695"a STATE_OK is returned. When the certificate is still valid, but for less " 1385"a STATE_OK is returned. When the certificate is still valid, but for less "
1696"than" 1386"than"
1697msgstr "" 1387msgstr ""
1698 1388
1699#: plugins/check_http.c:1570
1700msgid "" 1389msgid ""
1701"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when" 1390"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"
1702msgstr "" 1391msgstr ""
1703 1392
1704#: plugins/check_http.c:1571
1705msgid "the certificate is expired." 1393msgid "the certificate is expired."
1706msgstr "le certificat est expiré." 1394msgstr "le certificat est expiré."
1707 1395
1708#: plugins/check_http.c:1574
1709msgid "" 1396msgid ""
1710"When the certificate of 'www.verisign.com' is valid for more than 30 days," 1397"When the certificate of 'www.verisign.com' is valid for more than 30 days,"
1711msgstr "" 1398msgstr ""
1712 1399
1713#: plugins/check_http.c:1576
1714msgid "30 days, but more than 14 days, a STATE_WARNING is returned." 1400msgid "30 days, but more than 14 days, a STATE_WARNING is returned."
1715msgstr "" 1401msgstr ""
1716 1402
1717#: plugins/check_http.c:1577
1718msgid "" 1403msgid ""
1719"A STATE_CRITICAL will be returned when certificate expires in less than 14 " 1404"A STATE_CRITICAL will be returned when certificate expires in less than 14 "
1720"days" 1405"days"
1721msgstr "" 1406msgstr ""
1722 1407
1723#: plugins/check_ldap.c:133 1408msgid ""
1409"check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j "
1410"CONNECT -H www.verisign.com "
1411msgstr ""
1412
1413msgid ""
1414"all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -"
1415"S(sl) -j CONNECT -H <webserver>"
1416msgstr ""
1417
1418msgid ""
1419"a STATE_CRITICAL will be returned. By adding a colon to the method you can "
1420"set the method used"
1421msgstr ""
1422
1423msgid "inside the proxied connection: -j CONNECT:POST"
1424msgstr ""
1425
1724#, c-format 1426#, c-format
1725msgid "Could not connect to the server at port %i\n" 1427msgid "Could not connect to the server at port %i\n"
1726msgstr "Impossible de se connecter au serveur port %i\n" 1428msgstr "Impossible de se connecter au serveur port %i\n"
1727 1429
1728#: plugins/check_ldap.c:142
1729#, c-format 1430#, c-format
1730msgid "Could not set protocol version %d\n" 1431msgid "Could not set protocol version %d\n"
1731msgstr "Impossible d'utiliser le protocole version %d\n" 1432msgstr "Impossible d'utiliser le protocole version %d\n"
1732 1433
1733#: plugins/check_ldap.c:157
1734#, c-format 1434#, c-format
1735msgid "Could not init TLS at port %i!\n" 1435msgid "Could not init TLS at port %i!\n"
1736msgstr "Impossible d'initialiser TLS sur le port %i!\n" 1436msgstr "Impossible d'initialiser TLS sur le port %i!\n"
1737 1437
1738#: plugins/check_ldap.c:161
1739#, c-format 1438#, c-format
1740msgid "TLS not supported by the libraries!\n" 1439msgid "TLS not supported by the libraries!\n"
1741msgstr "TLS n'est pas supporté!\n" 1440msgstr "TLS n'est pas supporté!\n"
1742 1441
1743#: plugins/check_ldap.c:181
1744#, c-format 1442#, c-format
1745msgid "Could not init startTLS at port %i!\n" 1443msgid "Could not init startTLS at port %i!\n"
1746msgstr "Impossible d'initialiser startTLS sur le port %i!\n" 1444msgstr "Impossible d'initialiser startTLS sur le port %i!\n"
1747 1445
1748#: plugins/check_ldap.c:185
1749#, c-format 1446#, c-format
1750msgid "startTLS not supported by the library, needs LDAPv3!\n" 1447msgid "startTLS not supported by the library, needs LDAPv3!\n"
1751msgstr "" 1448msgstr ""
1752"startTLS n'est pas supporté par la librairie LDAP, j'ai besoin de LDAPv3!\n" 1449"startTLS n'est pas supporté par la librairie LDAP, j'ai besoin de LDAPv3!\n"
1753 1450
1754#: plugins/check_ldap.c:195
1755#, c-format 1451#, c-format
1756msgid "Could not bind to the LDAP server\n" 1452msgid "Could not bind to the LDAP server\n"
1757msgstr "Impossible de se connecter au serveur LDAP\n" 1453msgstr "Impossible de se connecter au serveur LDAP\n"
1758 1454
1759#: plugins/check_ldap.c:204
1760#, c-format 1455#, c-format
1761msgid "Could not search/find objectclasses in %s\n" 1456msgid "Could not search/find objectclasses in %s\n"
1762msgstr "Impossible de chercher/trouver les objectclasses dans %s\n" 1457msgstr "Impossible de chercher/trouver les objectclasses dans %s\n"
1763 1458
1764#: plugins/check_ldap.c:227 1459#, fuzzy, c-format
1460msgid "LDAP %s - found %d entries in %.3f seconds|%s %s\n"
1461msgstr "%s - %d octets en %.3f secondes de temps de réponse %s|%s %s"
1462
1765#, c-format 1463#, c-format
1766msgid "LDAP %s - %.3f seconds response time|%s\n" 1464msgid "LDAP %s - %.3f seconds response time|%s\n"
1767msgstr "LDAP %s - %.3f secondes de temps de réponse|%s\n" 1465msgstr "LDAP %s - %.3f secondes de temps de réponse|%s\n"
1768 1466
1769#: plugins/check_ldap.c:339 plugins/check_ldap.c:347
1770#, c-format 1467#, c-format
1771msgid "%s cannot be combined with %s" 1468msgid "%s cannot be combined with %s"
1772msgstr "" 1469msgstr ""
1773 1470
1774#: plugins/check_ldap.c:379
1775msgid "Please specify the host name\n" 1471msgid "Please specify the host name\n"
1776msgstr "Veuillez spécifier le nom de l'hôte\n" 1472msgstr "Veuillez spécifier le nom de l'hôte\n"
1777 1473
1778#: plugins/check_ldap.c:382
1779msgid "Please specify the LDAP base\n" 1474msgid "Please specify the LDAP base\n"
1780msgstr "Veuillez spécifier la base LDAP\n" 1475msgstr "Veuillez spécifier la base LDAP\n"
1781 1476
1782#: plugins/check_ldap.c:411
1783msgid "ldap attribute to search (default: \"(objectclass=*)\"" 1477msgid "ldap attribute to search (default: \"(objectclass=*)\""
1784msgstr "" 1478msgstr ""
1785 1479
1786#: plugins/check_ldap.c:413
1787msgid "ldap base (eg. ou=my unit, o=my org, c=at" 1480msgid "ldap base (eg. ou=my unit, o=my org, c=at"
1788msgstr "" 1481msgstr ""
1789 1482
1790#: plugins/check_ldap.c:415
1791msgid "ldap bind DN (if required)" 1483msgid "ldap bind DN (if required)"
1792msgstr "" 1484msgstr ""
1793 1485
1794#: plugins/check_ldap.c:417 1486msgid ""
1795msgid "ldap password (if required)" 1487"ldap password (if required, or set the password through environment variable "
1488"'LDAP_PASSWORD')"
1796msgstr "" 1489msgstr ""
1797 1490
1798#: plugins/check_ldap.c:419
1799msgid "use starttls mechanism introduced in protocol version 3" 1491msgid "use starttls mechanism introduced in protocol version 3"
1800msgstr "utiliser le fonctionnement starttls du protocole version 3" 1492msgstr "utiliser le fonctionnement starttls du protocole version 3"
1801 1493
1802#: plugins/check_ldap.c:421
1803msgid "use ldaps (ldap v2 ssl method). this also sets the default port to" 1494msgid "use ldaps (ldap v2 ssl method). this also sets the default port to"
1804msgstr "" 1495msgstr ""
1805 1496
1806#: plugins/check_ldap.c:425
1807msgid "use ldap protocol version 2" 1497msgid "use ldap protocol version 2"
1808msgstr "utiliser le protocole ldap version 2" 1498msgstr "utiliser le protocole ldap version 2"
1809 1499
1810#: plugins/check_ldap.c:427
1811msgid "use ldap protocol version 3" 1500msgid "use ldap protocol version 3"
1812msgstr "utiliser le protocole ldap version 3" 1501msgstr "utiliser le protocole ldap version 3"
1813 1502
1814#: plugins/check_ldap.c:428
1815msgid "default protocol version:" 1503msgid "default protocol version:"
1816msgstr "version du protocole par défaut:" 1504msgstr "version du protocole par défaut:"
1817 1505
1818#: plugins/check_ldap.c:439 1506#, fuzzy
1507msgid "Number of found entries to result in warning status"
1508msgstr "Décalage résultant en un avertissement (secondes)"
1509
1510#, fuzzy
1511msgid "Number of found entries to result in critical status"
1512msgstr "Décalage résultant en un état critique (secondes)"
1513
1819msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be" 1514msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be"
1820msgstr "" 1515msgstr ""
1821 1516
1822#: plugins/check_ldap.c:440
1823#, c-format 1517#, c-format
1824msgid "" 1518msgid ""
1825" implied (using default port %i) unless --port=636 is specified. In that " 1519" implied (using default port %i) unless --port=636 is specified. In that "
1826"case\n" 1520"case\n"
1827msgstr "" 1521msgstr ""
1828 1522
1829#: plugins/check_ldap.c:441
1830msgid "'SSL on connect' will be used no matter how the plugin was called." 1523msgid "'SSL on connect' will be used no matter how the plugin was called."
1831msgstr "" 1524msgstr ""
1832 1525
1833#: plugins/check_ldap.c:442
1834msgid "" 1526msgid ""
1835"This detection is deprecated, please use 'check_ldap' with the '--starttls' " 1527"This detection is deprecated, please use 'check_ldap' with the '--starttls' "
1836"or '--ssl' flags" 1528"or '--ssl' flags"
1837msgstr "" 1529msgstr ""
1838 1530
1839#: plugins/check_ldap.c:443
1840msgid "to define the behaviour explicitly instead." 1531msgid "to define the behaviour explicitly instead."
1841msgstr "" 1532msgstr ""
1842 1533
1843#: plugins/check_load.c:87 1534msgid "The parameters --warn-entries and --crit-entries are optional."
1535msgstr ""
1536
1844msgid "Warning threshold must be float or float triplet!\n" 1537msgid "Warning threshold must be float or float triplet!\n"
1845msgstr "Le seuil d'alerte doit être un nombre à virgule flottante!\n" 1538msgstr "Le seuil d'alerte doit être un nombre à virgule flottante!\n"
1846 1539
1847#: plugins/check_load.c:132 plugins/check_load.c:148
1848#, c-format 1540#, c-format
1849msgid "Error opening %s\n" 1541msgid "Error opening %s\n"
1850msgstr "Erreur à l'ouverture de %s\n" 1542msgstr "Erreur à l'ouverture de %s\n"
1851 1543
1852#: plugins/check_load.c:163
1853#, fuzzy, c-format 1544#, fuzzy, c-format
1854msgid "could not parse load from uptime: %s\n" 1545msgid "could not parse load from uptime %s: %d\n"
1855msgstr "Lecture des arguments impossible\n" 1546msgstr "Lecture des arguments impossible\n"
1856 1547
1857#: plugins/check_load.c:169
1858#, c-format 1548#, c-format
1859msgid "Error code %d returned in %s\n" 1549msgid "Error code %d returned in %s\n"
1860msgstr "Le code erreur %d à été retourné par %s\n" 1550msgstr "Le code erreur %d à été retourné par %s\n"
1861 1551
1862#: plugins/check_load.c:184
1863#, c-format 1552#, c-format
1864msgid "Error in getloadavg()\n" 1553msgid "Error in getloadavg()\n"
1865msgstr "Erreur dans la fonction getloadavg()\n" 1554msgstr "Erreur dans la fonction getloadavg()\n"
1866 1555
1867#: plugins/check_load.c:187 plugins/check_load.c:189
1868#, c-format 1556#, c-format
1869msgid "Error processing %s\n" 1557msgid "Error processing %s\n"
1870msgstr "Erreur lors de l'utilisation de %s\n" 1558msgstr "Erreur lors de l'utilisation de %s\n"
1871 1559
1872#: plugins/check_load.c:198
1873#, c-format 1560#, c-format
1874msgid "load average: %.2f, %.2f, %.2f" 1561msgid "load average: %.2f, %.2f, %.2f"
1875msgstr "Charge moyenne: %.2f, %.2f, %.2f" 1562msgstr "Charge moyenne: %.2f, %.2f, %.2f"
1876 1563
1877#: plugins/check_load.c:291
1878#, c-format 1564#, c-format
1879msgid "Critical threshold for %d-minute load average is not specified\n" 1565msgid "Critical threshold for %d-minute load average is not specified\n"
1880msgstr "" 1566msgstr ""
1881"Le seuil critique pour la charge système après %d minutes n'est pas " 1567"Le seuil critique pour la charge système après %d minutes n'est pas "
1882"spécifié\n" 1568"spécifié\n"
1883 1569
1884#: plugins/check_load.c:293
1885#, c-format 1570#, c-format
1886msgid "Warning threshold for %d-minute load average is not specified\n" 1571msgid "Warning threshold for %d-minute load average is not specified\n"
1887msgstr "" 1572msgstr ""
1888"Le seuil d'avertissement pour la charge système après %d minutes n'est pas " 1573"Le seuil d'avertissement pour la charge système après %d minutes n'est pas "
1889"spécifié\n" 1574"spécifié\n"
1890 1575
1891#: plugins/check_load.c:295
1892#, c-format 1576#, c-format
1893msgid "" 1577msgid ""
1894"Parameter inconsistency: %d-minute \"warning load\" is greater than " 1578"Parameter inconsistency: %d-minute \"warning load\" is greater than "
@@ -1897,62 +1581,61 @@ msgstr ""
1897"Arguments Incorrects: %d-minute \"alerte charge système\" est plus grand que " 1581"Arguments Incorrects: %d-minute \"alerte charge système\" est plus grand que "
1898"\"alerte critique charge système\"\n" 1582"\"alerte critique charge système\"\n"
1899 1583
1900#: plugins/check_load.c:311
1901#, c-format 1584#, c-format
1902msgid "This plugin tests the current system load average." 1585msgid "This plugin tests the current system load average."
1903msgstr "Ce plugin teste la charge système actuelle." 1586msgstr "Ce plugin teste la charge système actuelle."
1904 1587
1905#: plugins/check_load.c:321
1906msgid "Exit with WARNING status if load average exceeds WLOADn" 1588msgid "Exit with WARNING status if load average exceeds WLOADn"
1907msgstr "" 1589msgstr ""
1908"Sortir avec un résultat AVERTISSEMENT si la charge moyenne dépasse WLOAD" 1590"Sortir avec un résultat AVERTISSEMENT si la charge moyenne dépasse WLOAD"
1909 1591
1910#: plugins/check_load.c:323
1911msgid "Exit with CRITICAL status if load average exceed CLOADn" 1592msgid "Exit with CRITICAL status if load average exceed CLOADn"
1912msgstr "Sortir avec un résultat CRITIQUE si la charge moyenne excède CLOAD" 1593msgstr "Sortir avec un résultat CRITIQUE si la charge moyenne excède CLOAD"
1913 1594
1914#: plugins/check_load.c:324
1915msgid "the load average format is the same used by \"uptime\" and \"w\"" 1595msgid "the load average format is the same used by \"uptime\" and \"w\""
1916msgstr "" 1596msgstr ""
1917 1597
1918#: plugins/check_load.c:326
1919msgid "Divide the load averages by the number of CPUs (when possible)" 1598msgid "Divide the load averages by the number of CPUs (when possible)"
1920msgstr "" 1599msgstr ""
1921 1600
1922#: plugins/check_mrtg.c:75 1601msgid "Number of processes to show when printing the top consuming processes."
1602msgstr ""
1603
1604msgid "NUMBER_OF_PROCS=0 disables this feature. Default value is 0"
1605msgstr ""
1606
1607#, c-format
1608msgid "'%s' exited with non-zero status.\n"
1609msgstr ""
1610
1611#, c-format
1612msgid "some error occurred getting procs list.\n"
1613msgstr ""
1614
1923msgid "Could not parse arguments\n" 1615msgid "Could not parse arguments\n"
1924msgstr "Lecture des arguments impossible\n" 1616msgstr "Lecture des arguments impossible\n"
1925 1617
1926#: plugins/check_mrtg.c:80
1927#, c-format 1618#, c-format
1928msgid "Unable to open MRTG log file\n" 1619msgid "Unable to open MRTG log file\n"
1929msgstr "Impossible d'ouvrir le fichier de log de MRTG\n" 1620msgstr "Impossible d'ouvrir le fichier de log de MRTG\n"
1930 1621
1931#: plugins/check_mrtg.c:127
1932#, c-format 1622#, c-format
1933msgid "Unable to process MRTG log file\n" 1623msgid "Unable to process MRTG log file\n"
1934msgstr "Impossible de traiter le fichier de log de MRTG\n" 1624msgstr "Impossible de traiter le fichier de log de MRTG\n"
1935 1625
1936#: plugins/check_mrtg.c:135 plugins/check_mrtgtraf.c:136
1937#, c-format 1626#, c-format
1938msgid "MRTG data has expired (%d minutes old)\n" 1627msgid "MRTG data has expired (%d minutes old)\n"
1939msgstr "Les données de MRTG on expirées (vieilles de %d minutes)\n" 1628msgstr "Les données de MRTG on expirées (vieilles de %d minutes)\n"
1940 1629
1941#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1942#: plugins/check_mrtgtraf.c:196
1943msgid "Avg" 1630msgid "Avg"
1944msgstr "Moyenne" 1631msgstr "Moyenne"
1945 1632
1946#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1947#: plugins/check_mrtgtraf.c:196
1948msgid "Max" 1633msgid "Max"
1949msgstr "Max" 1634msgstr "Max"
1950 1635
1951#: plugins/check_mrtg.c:221
1952msgid "Invalid variable number" 1636msgid "Invalid variable number"
1953msgstr "Numéro de la variable invalide" 1637msgstr "Numéro de la variable invalide"
1954 1638
1955#: plugins/check_mrtg.c:256
1956#, c-format 1639#, c-format
1957msgid "" 1640msgid ""
1958"%s is not a valid expiration time\n" 1641"%s is not a valid expiration time\n"
@@ -1961,1061 +1644,833 @@ msgstr ""
1961"%s n'est pas un temps d'expiration valide\n" 1644"%s n'est pas un temps d'expiration valide\n"
1962"Utilisez '%s -h' pour de l'aide supplémentaire\n" 1645"Utilisez '%s -h' pour de l'aide supplémentaire\n"
1963 1646
1964#: plugins/check_mrtg.c:273
1965msgid "Invalid variable number\n" 1647msgid "Invalid variable number\n"
1966msgstr "Numéro de la variable invalide\n" 1648msgstr "Numéro de la variable invalide\n"
1967 1649
1968#: plugins/check_mrtg.c:300
1969msgid "You must supply the variable number" 1650msgid "You must supply the variable number"
1970msgstr "Vous devez fournir le numéro de la variable" 1651msgstr "Vous devez fournir le numéro de la variable"
1971 1652
1972#: plugins/check_mrtg.c:321
1973msgid "" 1653msgid ""
1974"This plugin will check either the average or maximum value of one of the" 1654"This plugin will check either the average or maximum value of one of the"
1975msgstr "Ce plugin va vérifier la moyenne ou le maximum d'une " 1655msgstr "Ce plugin va vérifier la moyenne ou le maximum d'une "
1976 1656
1977#: plugins/check_mrtg.c:322
1978msgid "two variables recorded in an MRTG log file." 1657msgid "two variables recorded in an MRTG log file."
1979msgstr "deux variables du fichier de log de MRTG." 1658msgstr "deux variables du fichier de log de MRTG."
1980 1659
1981#: plugins/check_mrtg.c:332
1982msgid "The MRTG log file containing the data you want to monitor" 1660msgid "The MRTG log file containing the data you want to monitor"
1983msgstr "" 1661msgstr ""
1984 1662
1985#: plugins/check_mrtg.c:334
1986msgid "Minutes before MRTG data is considered to be too old" 1663msgid "Minutes before MRTG data is considered to be too old"
1987msgstr "" 1664msgstr ""
1988 1665
1989#: plugins/check_mrtg.c:336
1990msgid "Should we check average or maximum values?" 1666msgid "Should we check average or maximum values?"
1991msgstr "" 1667msgstr ""
1992 1668
1993#: plugins/check_mrtg.c:338
1994msgid "Which variable set should we inspect? (1 or 2)" 1669msgid "Which variable set should we inspect? (1 or 2)"
1995msgstr "" 1670msgstr ""
1996 1671
1997#: plugins/check_mrtg.c:340
1998msgid "Threshold value for data to result in WARNING status" 1672msgid "Threshold value for data to result in WARNING status"
1999msgstr "" 1673msgstr ""
2000 1674
2001#: plugins/check_mrtg.c:342
2002msgid "Threshold value for data to result in CRITICAL status" 1675msgid "Threshold value for data to result in CRITICAL status"
2003msgstr "" 1676msgstr ""
2004 1677
2005#: plugins/check_mrtg.c:344
2006msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)" 1678msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)"
2007msgstr "" 1679msgstr ""
2008 1680
2009#: plugins/check_mrtg.c:346
2010msgid "Option units label for data (Example: Packets/Sec, Errors/Sec," 1681msgid "Option units label for data (Example: Packets/Sec, Errors/Sec,"
2011msgstr "" 1682msgstr ""
2012 1683
2013#: plugins/check_mrtg.c:347
2014#, c-format 1684#, c-format
2015msgid "\"Bytes Per Second\", \"%% Utilization\")" 1685msgid "\"Bytes Per Second\", \"%% Utilization\")"
2016msgstr "" 1686msgstr ""
2017 1687
2018#: plugins/check_mrtg.c:350
2019msgid "" 1688msgid ""
2020"If the value exceeds the <vwl> threshold, a WARNING status is returned. If" 1689"If the value exceeds the <vwl> threshold, a WARNING status is returned. If"
2021msgstr "" 1690msgstr ""
2022 1691
2023#: plugins/check_mrtg.c:351
2024msgid "" 1692msgid ""
2025"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If" 1693"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"
2026msgstr "" 1694msgstr ""
2027 1695
2028#: plugins/check_mrtg.c:352
2029msgid "the data in the log file is older than <expire_minutes> old, a WARNING" 1696msgid "the data in the log file is older than <expire_minutes> old, a WARNING"
2030msgstr "" 1697msgstr ""
2031 1698
2032#: plugins/check_mrtg.c:353
2033msgid "status is returned and a warning message is printed." 1699msgid "status is returned and a warning message is printed."
2034msgstr "" 1700msgstr ""
2035 1701
2036#: plugins/check_mrtg.c:356
2037msgid "" 1702msgid ""
2038"This plugin is useful for monitoring MRTG data that does not correspond to" 1703"This plugin is useful for monitoring MRTG data that does not correspond to"
2039msgstr "" 1704msgstr ""
2040 1705
2041#: plugins/check_mrtg.c:357
2042msgid "" 1706msgid ""
2043"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)." 1707"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."
2044msgstr "" 1708msgstr ""
2045 1709
2046#: plugins/check_mrtg.c:358
2047msgid "" 1710msgid ""
2048"It can be used to monitor any kind of data that MRTG is monitoring - errors," 1711"It can be used to monitor any kind of data that MRTG is monitoring - errors,"
2049msgstr "" 1712msgstr ""
2050 1713
2051#: plugins/check_mrtg.c:359
2052msgid "" 1714msgid ""
2053"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows" 1715"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"
2054msgstr "" 1716msgstr ""
2055 1717
2056#: plugins/check_mrtg.c:360
2057msgid "" 1718msgid ""
2058"me to track processor utilization, user connections, drive space, etc and" 1719"me to track processor utilization, user connections, drive space, etc and"
2059msgstr "" 1720msgstr ""
2060 1721
2061#: plugins/check_mrtg.c:361
2062msgid "this plugin works well for monitoring that kind of data as well." 1722msgid "this plugin works well for monitoring that kind of data as well."
2063msgstr "" 1723msgstr ""
2064 1724
2065#: plugins/check_mrtg.c:364
2066msgid "" 1725msgid ""
2067"- This plugin only monitors one of the two variables stored in the MRTG log" 1726"- This plugin only monitors one of the two variables stored in the MRTG log"
2068msgstr "" 1727msgstr ""
2069"- Ce plugin vérifie seulement une ou deux variables écrites dans un fichier " 1728"- Ce plugin vérifie seulement une ou deux variables écrites dans un fichier "
2070"de log MRTG" 1729"de log MRTG"
2071 1730
2072#: plugins/check_mrtg.c:365
2073msgid "file. If you want to monitor both values you will have to define two" 1731msgid "file. If you want to monitor both values you will have to define two"
2074msgstr "" 1732msgstr ""
2075 1733
2076#: plugins/check_mrtg.c:366
2077msgid "commands with different values for the <variable> argument. Of course," 1734msgid "commands with different values for the <variable> argument. Of course,"
2078msgstr "" 1735msgstr ""
2079 1736
2080#: plugins/check_mrtg.c:367
2081msgid "you can always hack the code to make this plugin work for you..." 1737msgid "you can always hack the code to make this plugin work for you..."
2082msgstr "" 1738msgstr ""
2083 1739
2084#: plugins/check_mrtg.c:368
2085msgid "" 1740msgid ""
2086"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded " 1741"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded "
2087"from" 1742"from"
2088msgstr "" 1743msgstr ""
2089 1744
2090#: plugins/check_mrtgtraf.c:88
2091msgid "Unable to open MRTG log file" 1745msgid "Unable to open MRTG log file"
2092msgstr "Impossible d'ouvrir le fichier de log de MRTG" 1746msgstr "Impossible d'ouvrir le fichier de log de MRTG"
2093 1747
2094#: plugins/check_mrtgtraf.c:130
2095msgid "Unable to process MRTG log file" 1748msgid "Unable to process MRTG log file"
2096msgstr "Impossible de traiter le fichier de log de MRTG" 1749msgstr "Impossible de traiter le fichier de log de MRTG"
2097 1750
2098#: plugins/check_mrtgtraf.c:194 1751#, fuzzy, c-format
2099#, c-format 1752msgid "%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"
2100msgid "%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n"
2101msgstr "%s. Entrée = %0.1f %s, %s. Sortie = %0.1f %s|%s %s\n" 1753msgstr "%s. Entrée = %0.1f %s, %s. Sortie = %0.1f %s|%s %s\n"
2102 1754
2103#: plugins/check_mrtgtraf.c:207
2104#, c-format 1755#, c-format
2105msgid "Traffic %s - %s\n" 1756msgid "Traffic %s - %s\n"
2106msgstr "Trafic %s - %s\n" 1757msgstr "Trafic %s - %s\n"
2107 1758
2108#: plugins/check_mrtgtraf.c:335
2109msgid "" 1759msgid ""
2110"This plugin will check the incoming/outgoing transfer rates of a router," 1760"This plugin will check the incoming/outgoing transfer rates of a router,"
2111msgstr "" 1761msgstr ""
2112"Ce plugin va vérifier le taux de transfert en entrée/sortie d'un routeur," 1762"Ce plugin va vérifier le taux de transfert en entrée/sortie d'un routeur,"
2113 1763
2114#: plugins/check_mrtgtraf.c:336
2115msgid "switch, etc recorded in an MRTG log. If the newest log entry is older" 1764msgid "switch, etc recorded in an MRTG log. If the newest log entry is older"
2116msgstr "" 1765msgstr ""
2117 1766
2118#: plugins/check_mrtgtraf.c:337
2119msgid "than <expire_minutes>, a WARNING status is returned. If either the" 1767msgid "than <expire_minutes>, a WARNING status is returned. If either the"
2120msgstr "" 1768msgstr ""
2121 1769
2122#: plugins/check_mrtgtraf.c:338
2123msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in" 1770msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in"
2124msgstr "" 1771msgstr ""
2125 1772
2126#: plugins/check_mrtgtraf.c:339
2127msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed" 1773msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed"
2128msgstr "" 1774msgstr ""
2129 1775
2130#: plugins/check_mrtgtraf.c:340
2131msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results." 1776msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results."
2132msgstr "" 1777msgstr ""
2133 1778
2134#: plugins/check_mrtgtraf.c:350
2135msgid "File to read log from" 1779msgid "File to read log from"
2136msgstr "" 1780msgstr ""
2137 1781
2138#: plugins/check_mrtgtraf.c:352
2139msgid "Minutes after which log expires" 1782msgid "Minutes after which log expires"
2140msgstr "" 1783msgstr ""
2141 1784
2142#: plugins/check_mrtgtraf.c:354
2143msgid "Test average or maximum" 1785msgid "Test average or maximum"
2144msgstr "" 1786msgstr ""
2145 1787
2146#: plugins/check_mrtgtraf.c:356
2147msgid "Warning threshold pair <incoming>,<outgoing>" 1788msgid "Warning threshold pair <incoming>,<outgoing>"
2148msgstr "Paire de seuils d'avertissement <entrant>,<sortant>" 1789msgstr "Paire de seuils d'avertissement <entrant>,<sortant>"
2149 1790
2150#: plugins/check_mrtgtraf.c:358
2151msgid "Critical threshold pair <incoming>,<outgoing>" 1791msgid "Critical threshold pair <incoming>,<outgoing>"
2152msgstr "Paire de seuils critique <entrant>,<sortant>" 1792msgstr "Paire de seuils critique <entrant>,<sortant>"
2153 1793
2154#: plugins/check_mrtgtraf.c:362
2155msgid "" 1794msgid ""
2156"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from" 1795"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"
2157msgstr "" 1796msgstr ""
2158 1797
2159#: plugins/check_mrtgtraf.c:364
2160msgid "- While MRTG can monitor things other than traffic rates, this" 1798msgid "- While MRTG can monitor things other than traffic rates, this"
2161msgstr "" 1799msgstr ""
2162 1800
2163#: plugins/check_mrtgtraf.c:365
2164msgid " plugin probably won't work with much else without modification." 1801msgid " plugin probably won't work with much else without modification."
2165msgstr "" 1802msgstr ""
2166 1803
2167#: plugins/check_mrtgtraf.c:366
2168msgid "- The calculated i/o rates are a little off from what MRTG actually" 1804msgid "- The calculated i/o rates are a little off from what MRTG actually"
2169msgstr "" 1805msgstr ""
2170 1806
2171#: plugins/check_mrtgtraf.c:367
2172msgid " reports. I'm not sure why this is right now, but will look into it" 1807msgid " reports. I'm not sure why this is right now, but will look into it"
2173msgstr "" 1808msgstr ""
2174 1809
2175#: plugins/check_mrtgtraf.c:368
2176msgid " for future enhancements of this plugin." 1810msgid " for future enhancements of this plugin."
2177msgstr "" 1811msgstr ""
2178 1812
2179#: plugins/check_mrtgtraf.c:378
2180#, c-format 1813#, c-format
2181msgid "Usage" 1814msgid "Usage"
2182msgstr "Utilisation" 1815msgstr "Utilisation"
2183 1816
2184#: plugins/check_mysql.c:171
2185#, fuzzy, c-format 1817#, fuzzy, c-format
2186msgid "status store_result error: %s\n" 1818msgid "status store_result error: %s\n"
2187msgstr "erreur slave store_result: %s\n" 1819msgstr "erreur slave store_result: %s\n"
2188 1820
2189#: plugins/check_mysql.c:202
2190#, c-format 1821#, c-format
2191msgid "slave query error: %s\n" 1822msgid "slave query error: %s\n"
2192msgstr "erreur de requête de l'esclave: %s\n" 1823msgstr "erreur de requête de l'esclave: %s\n"
2193 1824
2194#: plugins/check_mysql.c:209
2195#, c-format 1825#, c-format
2196msgid "slave store_result error: %s\n" 1826msgid "slave store_result error: %s\n"
2197msgstr "erreur slave store_result: %s\n" 1827msgstr "erreur slave store_result: %s\n"
2198 1828
2199#: plugins/check_mysql.c:215
2200msgid "No slaves defined" 1829msgid "No slaves defined"
2201msgstr "Pas d'esclave spécifié" 1830msgstr "Pas d'esclave spécifié"
2202 1831
2203#: plugins/check_mysql.c:223
2204#, c-format 1832#, c-format
2205msgid "slave fetch row error: %s\n" 1833msgid "slave fetch row error: %s\n"
2206msgstr "erreur esclave lecture d'une ligne: %s\n" 1834msgstr "erreur esclave lecture d'une ligne: %s\n"
2207 1835
2208#: plugins/check_mysql.c:228
2209#, c-format 1836#, c-format
2210msgid "Slave running: %s" 1837msgid "Slave running: %s"
2211msgstr "L'esclave fonctionne: %s" 1838msgstr "L'esclave fonctionne: %s"
2212 1839
2213#: plugins/check_mysql.c:505
2214msgid "This program tests connections to a MySQL server" 1840msgid "This program tests connections to a MySQL server"
2215msgstr "Ce plugin teste une connexion vers un serveur MySQL" 1841msgstr "Ce plugin teste une connexion vers un serveur MySQL"
2216 1842
2217#: plugins/check_mysql.c:516 1843msgid "Ignore authentication failure and check for mysql connectivity only"
1844msgstr ""
1845
2218msgid "Use the specified socket (has no effect if -H is used)" 1846msgid "Use the specified socket (has no effect if -H is used)"
2219msgstr "" 1847msgstr ""
2220 1848
2221#: plugins/check_mysql.c:519
2222msgid "Check database with indicated name" 1849msgid "Check database with indicated name"
2223msgstr "" 1850msgstr ""
2224 1851
2225#: plugins/check_mysql.c:521
2226msgid "Read from the specified client options file" 1852msgid "Read from the specified client options file"
2227msgstr "" 1853msgstr ""
2228 1854
2229#: plugins/check_mysql.c:523
2230msgid "Use a client options group" 1855msgid "Use a client options group"
2231msgstr "" 1856msgstr ""
2232 1857
2233#: plugins/check_mysql.c:525
2234msgid "Connect using the indicated username" 1858msgid "Connect using the indicated username"
2235msgstr "" 1859msgstr ""
2236 1860
2237#: plugins/check_mysql.c:527
2238msgid "Use the indicated password to authenticate the connection" 1861msgid "Use the indicated password to authenticate the connection"
2239msgstr "" 1862msgstr ""
2240 1863
2241#: plugins/check_mysql.c:528
2242msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!" 1864msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"
2243msgstr "" 1865msgstr ""
2244 1866
2245#: plugins/check_mysql.c:529
2246msgid "Your clear-text password could be visible as a process table entry" 1867msgid "Your clear-text password could be visible as a process table entry"
2247msgstr "" 1868msgstr ""
2248 1869
2249#: plugins/check_mysql.c:531
2250msgid "Check if the slave thread is running properly." 1870msgid "Check if the slave thread is running properly."
2251msgstr "" 1871msgstr ""
2252 1872
2253#: plugins/check_mysql.c:533
2254msgid "Exit with WARNING status if slave server is more than INTEGER seconds" 1873msgid "Exit with WARNING status if slave server is more than INTEGER seconds"
2255msgstr "" 1874msgstr ""
2256"Sortir avec un résultat AVERTISSEMENT si le serveur esclave est plus de X " 1875"Sortir avec un résultat AVERTISSEMENT si le serveur esclave est plus de X "
2257 1876
2258#: plugins/check_mysql.c:534 plugins/check_mysql.c:537
2259msgid "behind master" 1877msgid "behind master"
2260msgstr "secondes en retard sur le maître" 1878msgstr "secondes en retard sur le maître"
2261 1879
2262#: plugins/check_mysql.c:536
2263msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds" 1880msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds"
2264msgstr "Sortir avec un résultat CRITIQUE si le serveur esclave est plus de X " 1881msgstr "Sortir avec un résultat CRITIQUE si le serveur esclave est plus de X "
2265 1882
2266#: plugins/check_mysql.c:539 1883msgid "Use ssl encryption"
2267msgid "Use ssl encryptation"
2268msgstr "" 1884msgstr ""
2269 1885
2270#: plugins/check_mysql.c:541
2271msgid "Path to CA signing the cert" 1886msgid "Path to CA signing the cert"
2272msgstr "" 1887msgstr ""
2273 1888
2274#: plugins/check_mysql.c:543
2275msgid "Path to SSL certificate" 1889msgid "Path to SSL certificate"
2276msgstr "" 1890msgstr ""
2277 1891
2278#: plugins/check_mysql.c:545
2279msgid "Path to private SSL key" 1892msgid "Path to private SSL key"
2280msgstr "" 1893msgstr ""
2281 1894
2282#: plugins/check_mysql.c:547
2283msgid "Path to CA directory" 1895msgid "Path to CA directory"
2284msgstr "" 1896msgstr ""
2285 1897
2286#: plugins/check_mysql.c:549
2287msgid "List of valid SSL ciphers" 1898msgid "List of valid SSL ciphers"
2288msgstr "" 1899msgstr ""
2289 1900
2290#: plugins/check_mysql.c:553
2291msgid "" 1901msgid ""
2292"There are no required arguments. By default, the local database is checked" 1902"There are no required arguments. By default, the local database is checked"
2293msgstr "" 1903msgstr ""
2294"Il n'y a pas d'arguments nécessaires. Par défaut la base de donnée locale " 1904"Il n'y a pas d'arguments nécessaires. Par défaut la base de donnée locale "
2295"est testée" 1905"est testée"
2296 1906
2297#: plugins/check_mysql.c:554
2298msgid "" 1907msgid ""
2299"using the default unix socket. You can force TCP on localhost by using an" 1908"using the default unix socket. You can force TCP on localhost by using an"
2300msgstr "" 1909msgstr ""
2301 1910
2302#: plugins/check_mysql.c:555
2303msgid "IP address or FQDN ('localhost' will use the socket as well)." 1911msgid "IP address or FQDN ('localhost' will use the socket as well)."
2304msgstr "" 1912msgstr ""
2305 1913
2306#: plugins/check_mysql.c:559
2307msgid "You must specify -p with an empty string to force an empty password," 1914msgid "You must specify -p with an empty string to force an empty password,"
2308msgstr "" 1915msgstr ""
2309 1916
2310#: plugins/check_mysql.c:560
2311msgid "overriding any my.cnf settings." 1917msgid "overriding any my.cnf settings."
2312msgstr "" 1918msgstr ""
2313 1919
2314#: plugins/check_nagios.c:104
2315msgid "Cannot open status log for reading!" 1920msgid "Cannot open status log for reading!"
2316msgstr "Impossible d'ouvrir le fichier status log en lecture!" 1921msgstr "Impossible d'ouvrir le fichier status log en lecture!"
2317 1922
2318#: plugins/check_nagios.c:154
2319#, c-format 1923#, c-format
2320msgid "Found process: %s %s\n" 1924msgid "Found process: %s %s\n"
2321msgstr "Processus trouvé: %s %s\n" 1925msgstr "Processus trouvé: %s %s\n"
2322 1926
2323#: plugins/check_nagios.c:168
2324msgid "Could not locate a running Nagios process!" 1927msgid "Could not locate a running Nagios process!"
2325msgstr "Impossible de trouver un processus Nagios actif!" 1928msgstr "Impossible de trouver un processus Nagios actif!"
2326 1929
2327#: plugins/check_nagios.c:172
2328msgid "Cannot parse Nagios log file for valid time" 1930msgid "Cannot parse Nagios log file for valid time"
2329msgstr "" 1931msgstr ""
2330"Impossible de trouver une date/heure valide dans le fichier de log de Nagios" 1932"Impossible de trouver une date/heure valide dans le fichier de log de Nagios"
2331 1933
2332#: plugins/check_nagios.c:183 plugins/check_procs.c:356
2333#, c-format 1934#, c-format
2334msgid "%d process" 1935msgid "%d process"
2335msgid_plural "%d processes" 1936msgid_plural "%d processes"
2336msgstr[0] "%d processus" 1937msgstr[0] "%d processus"
2337msgstr[1] "%d processus" 1938msgstr[1] "%d processus"
2338 1939
2339#: plugins/check_nagios.c:186
2340#, c-format 1940#, c-format
2341msgid "status log updated %d second ago" 1941msgid "status log updated %d second ago"
2342msgid_plural "status log updated %d seconds ago" 1942msgid_plural "status log updated %d seconds ago"
2343msgstr[0] "status log mis à jour %d secondes auparavant" 1943msgstr[0] "status log mis à jour %d secondes auparavant"
2344msgstr[1] "status log mis à jour %d secondes auparavant" 1944msgstr[1] "status log mis à jour %d secondes auparavant"
2345 1945
2346#: plugins/check_nagios.c:224 plugins/check_nagios.c:253
2347msgid "Expiration time must be an integer (seconds)\n" 1946msgid "Expiration time must be an integer (seconds)\n"
2348msgstr "Le délai d'expiration doit être un entier (en secondes)\n" 1947msgstr "Le délai d'expiration doit être un entier (en secondes)\n"
2349 1948
2350#: plugins/check_nagios.c:260
2351#, fuzzy 1949#, fuzzy
2352msgid "Timeout must be an integer (seconds)\n" 1950msgid "Timeout must be an integer (seconds)\n"
2353msgstr "Le délai d'expiration doit être un entier (en secondes)\n" 1951msgstr "Le délai d'expiration doit être un entier (en secondes)\n"
2354 1952
2355#: plugins/check_nagios.c:272
2356msgid "You must provide the status_log\n" 1953msgid "You must provide the status_log\n"
2357msgstr "Vous devez fournir le status_log\n" 1954msgstr "Vous devez fournir le status_log\n"
2358 1955
2359#: plugins/check_nagios.c:275
2360msgid "You must provide a process string\n" 1956msgid "You must provide a process string\n"
2361msgstr "Vous devez fournir un nom de processus\n" 1957msgstr "Vous devez fournir un nom de processus\n"
2362 1958
2363#: plugins/check_nagios.c:289
2364msgid "" 1959msgid ""
2365"This plugin checks the status of the Nagios process on the local machine" 1960"This plugin checks the status of the Nagios process on the local machine"
2366msgstr "Ce plugin vérifie l'état du processus Nagios sur la machine locale." 1961msgstr "Ce plugin vérifie l'état du processus Nagios sur la machine locale."
2367 1962
2368#: plugins/check_nagios.c:290
2369msgid "" 1963msgid ""
2370"The plugin will check to make sure the Nagios status log is no older than" 1964"The plugin will check to make sure the Nagios status log is no older than"
2371msgstr "Ce plugin vérifie que le status log de Nagios n'est pas plus vieux que" 1965msgstr "Ce plugin vérifie que le status log de Nagios n'est pas plus vieux que"
2372 1966
2373#: plugins/check_nagios.c:291
2374msgid "the number of minutes specified by the expires option." 1967msgid "the number of minutes specified by the expires option."
2375msgstr "le nombre de minutes spécifies par l'option expire." 1968msgstr "le nombre de minutes spécifies par l'option expire."
2376 1969
2377#: plugins/check_nagios.c:292
2378msgid "" 1970msgid ""
2379"It also checks the process table for a process matching the command argument." 1971"It also checks the process table for a process matching the command argument."
2380msgstr "" 1972msgstr ""
2381 1973
2382#: plugins/check_nagios.c:302
2383msgid "Name of the log file to check" 1974msgid "Name of the log file to check"
2384msgstr "Nom du fichier log à vérifier" 1975msgstr "Nom du fichier log à vérifier"
2385 1976
2386#: plugins/check_nagios.c:304
2387msgid "Minutes aging after which logfile is considered stale" 1977msgid "Minutes aging after which logfile is considered stale"
2388msgstr "" 1978msgstr ""
2389 1979
2390#: plugins/check_nagios.c:306
2391msgid "Substring to search for in process arguments" 1980msgid "Substring to search for in process arguments"
2392msgstr "" 1981msgstr ""
2393 1982
2394#: plugins/check_nagios.c:308
2395msgid "Timeout for the plugin in seconds" 1983msgid "Timeout for the plugin in seconds"
2396msgstr "" 1984msgstr ""
2397 1985
2398#: plugins/check_nt.c:142
2399#, c-format 1986#, c-format
2400msgid "Wrong client version - running: %s, required: %s" 1987msgid "Wrong client version - running: %s, required: %s"
2401msgstr "Mauvaise version du client utilisée: %s, nécessaire: %s" 1988msgstr "Mauvaise version du client utilisée: %s, nécessaire: %s"
2402 1989
2403#: plugins/check_nt.c:153 plugins/check_nt.c:218
2404msgid "missing -l parameters" 1990msgid "missing -l parameters"
2405msgstr "Arguments -l manquants" 1991msgstr "Arguments -l manquants"
2406 1992
2407#: plugins/check_nt.c:155
2408msgid "wrong -l parameter." 1993msgid "wrong -l parameter."
2409msgstr "Arguments -l erronés." 1994msgstr "Arguments -l erronés."
2410 1995
2411#: plugins/check_nt.c:159
2412msgid "CPU Load" 1996msgid "CPU Load"
2413msgstr "Charge CPU" 1997msgstr "Charge CPU"
2414 1998
2415#: plugins/check_nt.c:182
2416#, c-format 1999#, c-format
2417msgid " %lu%% (%lu min average)" 2000msgid " %lu%% (%lu min average)"
2418msgstr " %lu%% (%lu moyenne minimale)" 2001msgstr " %lu%% (%lu moyenne minimale)"
2419 2002
2420#: plugins/check_nt.c:184
2421#, c-format 2003#, c-format
2422msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100" 2004msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100"
2423msgstr " '%lu Charge moyenne minimale'=%lu%%;%lu;%lu;0;100" 2005msgstr " '%lu Charge moyenne minimale'=%lu%%;%lu;%lu;0;100"
2424 2006
2425#: plugins/check_nt.c:194
2426msgid "not enough values for -l parameters" 2007msgid "not enough values for -l parameters"
2427msgstr "pas assez de valeur pour l'argument -l" 2008msgstr "pas assez de valeur pour l'argument -l"
2428 2009
2429#: plugins/check_nt.c:206
2430#, c-format
2431msgid "System Uptime - %u day(s) %u hour(s) %u minute(s)"
2432msgstr "Système démarré - %u jour(s) %u heure(s) %u minute(s)"
2433
2434#: plugins/check_nt.c:220
2435msgid "wrong -l argument" 2010msgid "wrong -l argument"
2436msgstr "Argument -l erroné" 2011msgstr "Argument -l erroné"
2437 2012
2438#: plugins/check_nt.c:236 2013#, fuzzy, c-format
2014msgid "System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"
2015msgstr "Système démarré - %u jour(s) %u heure(s) %u minute(s)"
2016
2439#, c-format 2017#, c-format
2440msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)" 2018msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"
2441msgstr "" 2019msgstr ""
2442"%s:\\ - total: %.2f Gb - utilisé: %.2f Gb (%.0f%%) - libre %.2f Gb (%.0f%%)" 2020"%s:\\ - total: %.2f Gb - utilisé: %.2f Gb (%.0f%%) - libre %.2f Gb (%.0f%%)"
2443 2021
2444#: plugins/check_nt.c:239
2445#, c-format 2022#, c-format
2446msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f" 2023msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2447msgstr "'%s:\\ Espace Utilisé'=%.2fGb;%.2f;%.2f;0.00;%.2f" 2024msgstr "'%s:\\ Espace Utilisé'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2448 2025
2449#: plugins/check_nt.c:253
2450msgid "Free disk space : Invalid drive" 2026msgid "Free disk space : Invalid drive"
2451msgstr "Espace disque libre : Lecteur invalide" 2027msgstr "Espace disque libre : Lecteur invalide"
2452 2028
2453#: plugins/check_nt.c:263
2454msgid "No service/process specified" 2029msgid "No service/process specified"
2455msgstr "Pas de service/processus spécifié" 2030msgstr "Pas de service/processus spécifié"
2456 2031
2457#: plugins/check_nt.c:271 plugins/check_nt.c:284 plugins/check_nt.c:288
2458#: plugins/check_nt.c:622
2459msgid "could not fetch information from server\n" 2032msgid "could not fetch information from server\n"
2460msgstr "Impossible d'obtenir l'information depuis le serveur\n" 2033msgstr "Impossible d'obtenir l'information depuis le serveur\n"
2461 2034
2462#: plugins/check_nt.c:296 2035#, fuzzy, c-format
2463#, c-format
2464msgid "" 2036msgid ""
2465"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)" 2037"Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"
2466msgstr "" 2038msgstr ""
2467"Mémoire utilisée: total:%.2f Mb - utilisée: %.2f Mb (%.0f%%) - libre: %.2f " 2039"Mémoire utilisée: total:%.2f Mb - utilisée: %.2f Mb (%.0f%%) - libre: %.2f "
2468"Mb (%.0f%%)" 2040"Mb (%.0f%%)"
2469 2041
2470#: plugins/check_nt.c:299 2042#, fuzzy, c-format
2471#, c-format 2043msgid "'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"
2472msgid "'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f"
2473msgstr "'Mémoire utilisée'=%.2fMb;%.2f;%.2f;0.00;%.2f" 2044msgstr "'Mémoire utilisée'=%.2fMb;%.2f;%.2f;0.00;%.2f"
2474 2045
2475#: plugins/check_nt.c:335 plugins/check_nt.c:420 plugins/check_nt.c:450
2476msgid "No counter specified" 2046msgid "No counter specified"
2477msgstr "Pas de compteur spécifié" 2047msgstr "Pas de compteur spécifié"
2478 2048
2479#: plugins/check_nt.c:367
2480msgid "Minimum value contains non-numbers" 2049msgid "Minimum value contains non-numbers"
2481msgstr "La valeur minimum contient des caractères non numériques" 2050msgstr "La valeur minimum contient des caractères non numériques"
2482 2051
2483#: plugins/check_nt.c:371
2484msgid "Maximum value contains non-numbers" 2052msgid "Maximum value contains non-numbers"
2485msgstr "La valeur maximum contient des caractères non numériques" 2053msgstr "La valeur maximum contient des caractères non numériques"
2486 2054
2487#: plugins/check_nt.c:378
2488msgid "No unit counter specified" 2055msgid "No unit counter specified"
2489msgstr "Pas de compteur spécifié" 2056msgstr "Pas de compteur spécifié"
2490 2057
2491#: plugins/check_nt.c:465
2492msgid "Please specify a variable to check" 2058msgid "Please specify a variable to check"
2493msgstr "Veuillez préciser une variable a vérifier" 2059msgstr "Veuillez préciser une variable a vérifier"
2494 2060
2495#: plugins/check_nt.c:549
2496msgid "Server port must be an integer\n" 2061msgid "Server port must be an integer\n"
2497msgstr "Le port du serveur doit être un nombre entier\n" 2062msgstr "Le port du serveur doit être un nombre entier\n"
2498 2063
2499#: plugins/check_nt.c:603
2500msgid "You must provide a server address or host name" 2064msgid "You must provide a server address or host name"
2501msgstr "Vous devez spécifier une adresse ou un nom d'hôte" 2065msgstr "Vous devez spécifier une adresse ou un nom d'hôte"
2502 2066
2503#: plugins/check_nt.c:609
2504msgid "None" 2067msgid "None"
2505msgstr "Aucun" 2068msgstr "Aucun"
2506 2069
2507#: plugins/check_nt.c:666
2508msgid "This plugin collects data from the NSClient service running on a" 2070msgid "This plugin collects data from the NSClient service running on a"
2509msgstr "" 2071msgstr ""
2510"Ce plugin collecte les données depuis le service NSClient tournant sur un" 2072"Ce plugin collecte les données depuis le service NSClient tournant sur un"
2511 2073
2512#: plugins/check_nt.c:667
2513msgid "Windows NT/2000/XP/2003 server." 2074msgid "Windows NT/2000/XP/2003 server."
2514msgstr "Serveur Windows NT/2000/XP/2003." 2075msgstr "Serveur Windows NT/2000/XP/2003."
2515 2076
2516#: plugins/check_nt.c:678
2517msgid "Name of the host to check" 2077msgid "Name of the host to check"
2518msgstr "Nom de l'hôte à vérifier" 2078msgstr "Nom de l'hôte à vérifier"
2519 2079
2520#: plugins/check_nt.c:680
2521msgid "Optional port number (default: " 2080msgid "Optional port number (default: "
2522msgstr "Numéro de port optionnel (défaut: " 2081msgstr "Numéro de port optionnel (défaut: "
2523 2082
2524#: plugins/check_nt.c:683
2525msgid "Password needed for the request" 2083msgid "Password needed for the request"
2526msgstr "Mot de passe nécessaire pour la requête" 2084msgstr "Mot de passe nécessaire pour la requête"
2527 2085
2528#: plugins/check_nt.c:685 plugins/check_nwstat.c:1661
2529#: plugins/check_overcr.c:432
2530msgid "Threshold which will result in a warning status" 2086msgid "Threshold which will result in a warning status"
2531msgstr "" 2087msgstr ""
2532 2088
2533#: plugins/check_nt.c:687 plugins/check_nwstat.c:1663
2534#: plugins/check_overcr.c:434
2535msgid "Threshold which will result in a critical status" 2089msgid "Threshold which will result in a critical status"
2536msgstr "" 2090msgstr ""
2537 2091
2538#: plugins/check_nt.c:689
2539msgid "Seconds before connection attempt times out (default: " 2092msgid "Seconds before connection attempt times out (default: "
2540msgstr "" 2093msgstr ""
2541 2094
2542#: plugins/check_nt.c:691
2543msgid "Parameters passed to specified check (see below)" 2095msgid "Parameters passed to specified check (see below)"
2544msgstr "" 2096msgstr ""
2545 2097
2546#: plugins/check_nt.c:693
2547msgid "Display options (currently only SHOWALL works)" 2098msgid "Display options (currently only SHOWALL works)"
2548msgstr "" 2099msgstr ""
2549 2100
2550#: plugins/check_nt.c:695
2551msgid "Return UNKNOWN on timeouts" 2101msgid "Return UNKNOWN on timeouts"
2552msgstr "" 2102msgstr ""
2553 2103
2554#: plugins/check_nt.c:698
2555msgid "Print this help screen" 2104msgid "Print this help screen"
2556msgstr "Afficher l'écran d'aide" 2105msgstr "Afficher l'écran d'aide"
2557 2106
2558#: plugins/check_nt.c:700
2559msgid "Print version information" 2107msgid "Print version information"
2560msgstr "Afficher la version" 2108msgstr "Afficher la version"
2561 2109
2562#: plugins/check_nt.c:702
2563msgid "Variable to check" 2110msgid "Variable to check"
2564msgstr "Variable a vérifier" 2111msgstr "Variable a vérifier"
2565 2112
2566#: plugins/check_nt.c:703
2567msgid "Valid variables are:" 2113msgid "Valid variables are:"
2568msgstr "Les variables valides sont" 2114msgstr "Les variables valides sont"
2569 2115
2570#: plugins/check_nt.c:705
2571msgid "Get the NSClient version" 2116msgid "Get the NSClient version"
2572msgstr "Obtenir la version de NSClient" 2117msgstr "Obtenir la version de NSClient"
2573 2118
2574#: plugins/check_nt.c:706
2575msgid "If -l <version> is specified, will return warning if versions differ." 2119msgid "If -l <version> is specified, will return warning if versions differ."
2576msgstr "" 2120msgstr ""
2577"si l'argument -l <version> est spécifié, une alerte AVERTISSEMENT sera " 2121"si l'argument -l <version> est spécifié, une alerte AVERTISSEMENT sera "
2578"renvoyée, si les versions sont différentes." 2122"renvoyée, si les versions sont différentes."
2579 2123
2580#: plugins/check_nt.c:708
2581msgid "Average CPU load on last x minutes." 2124msgid "Average CPU load on last x minutes."
2582msgstr "Moyenne de la charge CPU sur les dernières x minutes." 2125msgstr "Moyenne de la charge CPU sur les dernières x minutes."
2583 2126
2584#: plugins/check_nt.c:709
2585msgid "Request a -l parameter with the following syntax:" 2127msgid "Request a -l parameter with the following syntax:"
2586msgstr "Demande un paramètre -l avec la syntaxe suivante:" 2128msgstr "Demande un paramètre -l avec la syntaxe suivante:"
2587 2129
2588#: plugins/check_nt.c:710
2589msgid "-l <minutes range>,<warning threshold>,<critical threshold>." 2130msgid "-l <minutes range>,<warning threshold>,<critical threshold>."
2590msgstr "-l <plage de minutes>,<seuil d'avertissement>,<seuil critique>." 2131msgstr "-l <plage de minutes>,<seuil d'avertissement>,<seuil critique>."
2591 2132
2592#: plugins/check_nt.c:711
2593msgid "<minute range> should be less than 24*60." 2133msgid "<minute range> should be less than 24*60."
2594msgstr "<plage de minutes> devrait être inférieur à 24*60." 2134msgstr "<plage de minutes> devrait être inférieur à 24*60."
2595 2135
2596#: plugins/check_nt.c:712
2597msgid "" 2136msgid ""
2598"Thresholds are percentage and up to 10 requests can be done in one shot." 2137"Thresholds are percentage and up to 10 requests can be done in one shot."
2599msgstr "" 2138msgstr ""
2600"Les seuils sonts en pourcentage et un maximum de 10 requêtes peuvent être " 2139"Les seuils sonts en pourcentage et un maximum de 10 requêtes peuvent être "
2601"effectuées à la fois." 2140"effectuées à la fois."
2602 2141
2603#: plugins/check_nt.c:715
2604msgid "Get the uptime of the machine." 2142msgid "Get the uptime of the machine."
2605msgstr "Obtenir le temps de service de la machine." 2143msgstr "Obtenir le temps de service de la machine."
2606 2144
2607#: plugins/check_nt.c:716 2145msgid "-l <unit> "
2608msgid "No specific parameters. No warning or critical threshold" 2146msgstr ""
2609msgstr "Pas d'argument spécifique. Pas de seuil d'avertissement ou critique" 2147
2148msgid "<unit> = seconds, minutes, hours, or days. (default: minutes)"
2149msgstr ""
2150
2151#, fuzzy
2152msgid "Thresholds will use the unit specified above."
2153msgstr "Ce plugin va vérifier l'heure sur l'hôte spécifié."
2610 2154
2611#: plugins/check_nt.c:718
2612msgid "Size and percentage of disk use." 2155msgid "Size and percentage of disk use."
2613msgstr "Taille et pourcentage de l'utilisation disque." 2156msgstr "Taille et pourcentage de l'utilisation disque."
2614 2157
2615#: plugins/check_nt.c:719
2616msgid "Request a -l parameter containing the drive letter only." 2158msgid "Request a -l parameter containing the drive letter only."
2617msgstr "Demande un paramètre -l contennant uniquement la lettre du lecteur." 2159msgstr "Demande un paramètre -l contennant uniquement la lettre du lecteur."
2618 2160
2619#: plugins/check_nt.c:720 plugins/check_nt.c:723
2620msgid "Warning and critical thresholds can be specified with -w and -c." 2161msgid "Warning and critical thresholds can be specified with -w and -c."
2621msgstr "Les seuils d'alerte et critiques peuvent être spécifiés avec -w et -c." 2162msgstr "Les seuils d'alerte et critiques peuvent être spécifiés avec -w et -c."
2622 2163
2623#: plugins/check_nt.c:722
2624msgid "Memory use." 2164msgid "Memory use."
2625msgstr "Mémoire utilisée." 2165msgstr "Mémoire utilisée."
2626 2166
2627#: plugins/check_nt.c:725
2628msgid "Check the state of one or several services." 2167msgid "Check the state of one or several services."
2629msgstr "Vérifier l'état d'un ou plusieurs services." 2168msgstr "Vérifier l'état d'un ou plusieurs services."
2630 2169
2631#: plugins/check_nt.c:726 plugins/check_nt.c:735
2632msgid "Request a -l parameters with the following syntax:" 2170msgid "Request a -l parameters with the following syntax:"
2633msgstr "Demande un paramètre -l avec la syntaxe suivante:" 2171msgstr "Demande un paramètre -l avec la syntaxe suivante:"
2634 2172
2635#: plugins/check_nt.c:727
2636msgid "-l <service1>,<service2>,<service3>,..." 2173msgid "-l <service1>,<service2>,<service3>,..."
2637msgstr "-l <service1>,<service2>,<service3>,..." 2174msgstr "-l <service1>,<service2>,<service3>,..."
2638 2175
2639#: plugins/check_nt.c:728
2640msgid "You can specify -d SHOWALL in case you want to see working services" 2176msgid "You can specify -d SHOWALL in case you want to see working services"
2641msgstr "Vous pouvez spécifier -d SHOWALL pour voir les services fonctionnant" 2177msgstr "Vous pouvez spécifier -d SHOWALL pour voir les services fonctionnant"
2642 2178
2643#: plugins/check_nt.c:729
2644msgid "in the returned string." 2179msgid "in the returned string."
2645msgstr "dans la chaîne de caractère renvoyée." 2180msgstr "dans la chaîne de caractère renvoyée."
2646 2181
2647#: plugins/check_nt.c:731
2648msgid "Check if one or several process are running." 2182msgid "Check if one or several process are running."
2649msgstr "Vérifie si un ou plusieurs processus sont démarrés." 2183msgstr "Vérifie si un ou plusieurs processus sont démarrés."
2650 2184
2651#: plugins/check_nt.c:732
2652msgid "Same syntax as SERVICESTATE." 2185msgid "Same syntax as SERVICESTATE."
2653msgstr "Même syntaxe que SERVICESTATE." 2186msgstr "Même syntaxe que SERVICESTATE."
2654 2187
2655#: plugins/check_nt.c:734
2656msgid "Check any performance counter of Windows NT/2000." 2188msgid "Check any performance counter of Windows NT/2000."
2657msgstr "Vérifier n'importe quel compteur de performance sur Windows NT/2000." 2189msgstr "Vérifier n'importe quel compteur de performance sur Windows NT/2000."
2658 2190
2659#: plugins/check_nt.c:736
2660msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>" 2191msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>"
2661msgstr "-l \"\\\\<catégorie>\\\\compteur\",\"<description>" 2192msgstr "-l \"\\\\<catégorie>\\\\compteur\",\"<description>"
2662 2193
2663#: plugins/check_nt.c:737
2664msgid "The <description> parameter is optional and is given to a printf " 2194msgid "The <description> parameter is optional and is given to a printf "
2665msgstr "Le paramètre <description> est optionnel et est passé à la fonction " 2195msgstr "Le paramètre <description> est optionnel et est passé à la fonction "
2666 2196
2667#: plugins/check_nt.c:738
2668msgid "output command which requires a float parameter." 2197msgid "output command which requires a float parameter."
2669msgstr "de sortie printf qui demande un paramètre de type float." 2198msgstr "de sortie printf qui demande un paramètre de type float."
2670 2199
2671#: plugins/check_nt.c:739
2672#, c-format 2200#, c-format
2673msgid "If <description> does not include \"%%\", it is used as a label." 2201msgid "If <description> does not include \"%%\", it is used as a label."
2674msgstr "Si <description> n'inclus pas \"%%\", il est utilisé comme étiquette." 2202msgstr "Si <description> n'inclus pas \"%%\", il est utilisé comme étiquette."
2675 2203
2676#: plugins/check_nt.c:740 plugins/check_nt.c:755
2677msgid "Some examples:" 2204msgid "Some examples:"
2678msgstr "Exemples:" 2205msgstr "Exemples:"
2679 2206
2680#: plugins/check_nt.c:744
2681msgid "Check any performance counter object of Windows NT/2000." 2207msgid "Check any performance counter object of Windows NT/2000."
2682msgstr "Vérifie n'importe quel compteur de performance de Windows NT/2000." 2208msgstr "Vérifie n'importe quel compteur de performance de Windows NT/2000."
2683 2209
2684#: plugins/check_nt.c:745
2685msgid "" 2210msgid ""
2686"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>" 2211"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"
2687msgstr "" 2212msgstr ""
2688 2213
2689#: plugins/check_nt.c:746
2690msgid "<counter object> is a Windows Perfmon Counter object (eg. Process)," 2214msgid "<counter object> is a Windows Perfmon Counter object (eg. Process),"
2691msgstr "" 2215msgstr ""
2692 2216
2693#: plugins/check_nt.c:747
2694msgid "if it is two words, it should be enclosed in quotes" 2217msgid "if it is two words, it should be enclosed in quotes"
2695msgstr "" 2218msgstr ""
2696 2219
2697#: plugins/check_nt.c:748
2698msgid "The returned results will be a comma-separated list of instances on " 2220msgid "The returned results will be a comma-separated list of instances on "
2699msgstr "" 2221msgstr ""
2700 2222
2701#: plugins/check_nt.c:749
2702msgid " the selected computer for that object." 2223msgid " the selected computer for that object."
2703msgstr "" 2224msgstr ""
2704 2225
2705#: plugins/check_nt.c:750
2706msgid "" 2226msgid ""
2707"The purpose of this is to be run from command line to determine what " 2227"The purpose of this is to be run from command line to determine what "
2708"instances" 2228"instances"
2709msgstr "" 2229msgstr ""
2710 2230
2711#: plugins/check_nt.c:751
2712msgid "" 2231msgid ""
2713" are available for monitoring without having to log onto the Windows server" 2232" are available for monitoring without having to log onto the Windows server"
2714msgstr "" 2233msgstr ""
2715 2234
2716#: plugins/check_nt.c:752
2717msgid " to run Perfmon directly." 2235msgid " to run Perfmon directly."
2718msgstr "" 2236msgstr ""
2719 2237
2720#: plugins/check_nt.c:753
2721msgid "" 2238msgid ""
2722"It can also be used in scripts that automatically create the monitoring " 2239"It can also be used in scripts that automatically create the monitoring "
2723"service" 2240"service"
2724msgstr "" 2241msgstr ""
2725 2242
2726#: plugins/check_nt.c:754
2727msgid " configuration files." 2243msgid " configuration files."
2728msgstr "" 2244msgstr ""
2729 2245
2730#: plugins/check_nt.c:756
2731msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process" 2246msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"
2732msgstr "" 2247msgstr ""
2733 2248
2734#: plugins/check_nt.c:759
2735msgid "" 2249msgid ""
2736"- The NSClient service should be running on the server to get any information" 2250"- The NSClient service should be running on the server to get any information"
2737msgstr "" 2251msgstr ""
2738"- Le service NSClient doit rouler sur le serveur pour obtenir les " 2252"- Le service NSClient doit rouler sur le serveur pour obtenir les "
2739"informations" 2253"informations"
2740 2254
2741#: plugins/check_nt.c:761
2742msgid "- Critical thresholds should be lower than warning thresholds" 2255msgid "- Critical thresholds should be lower than warning thresholds"
2743msgstr "" 2256msgstr ""
2744"- Les seuils critiques doivent être plus bas que les seuils d'avertissement" 2257"- Les seuils critiques doivent être plus bas que les seuils d'avertissement"
2745 2258
2746#: plugins/check_nt.c:762
2747msgid "- Default port 1248 is sometimes in use by other services. The error" 2259msgid "- Default port 1248 is sometimes in use by other services. The error"
2748msgstr "" 2260msgstr ""
2749"- Le port par défaut 1248 est parfois utilisé par d'autres services. L'erreur" 2261"- Le port par défaut 1248 est parfois utilisé par d'autres services. L'erreur"
2750 2262
2751#: plugins/check_nt.c:763
2752msgid "" 2263msgid ""
2753"output when this happens contains \"Cannot map xxxxx to protocol number\"." 2264"output when this happens contains \"Cannot map xxxxx to protocol number\"."
2754msgstr "qui en résulte contiens \"Cannot map xxxxx to protocol number\"." 2265msgstr "qui en résulte contiens \"Cannot map xxxxx to protocol number\"."
2755 2266
2756#: plugins/check_nt.c:764
2757msgid "One fix for this is to change the port to something else on check_nt " 2267msgid "One fix for this is to change the port to something else on check_nt "
2758msgstr "" 2268msgstr ""
2759"Une possibilité pour corriger ce problème est de changer le port dans " 2269"Une possibilité pour corriger ce problème est de changer le port dans "
2760"check_nt " 2270"check_nt "
2761 2271
2762#: plugins/check_nt.c:765
2763msgid "and on the client service it's connecting to." 2272msgid "and on the client service it's connecting to."
2764msgstr "et dans le service auquel il se connecte." 2273msgstr "et dans le service auquel il se connecte."
2765 2274
2766#: plugins/check_ntp.c:807 plugins/check_ntp_peer.c:612 2275#, c-format
2767#: plugins/check_ntp_time.c:571 2276msgid "jitter response too large (%lu bytes)\n"
2277msgstr ""
2278
2768msgid "NTP CRITICAL:" 2279msgid "NTP CRITICAL:"
2769msgstr "NTP CRITIQUE:" 2280msgstr "NTP CRITIQUE:"
2770 2281
2771#: plugins/check_ntp.c:810 plugins/check_ntp_peer.c:615
2772#: plugins/check_ntp_time.c:574
2773msgid "NTP WARNING:" 2282msgid "NTP WARNING:"
2774msgstr "NTP AVERTISSEMENT:" 2283msgstr "NTP AVERTISSEMENT:"
2775 2284
2776#: plugins/check_ntp.c:813 plugins/check_ntp_peer.c:618
2777#: plugins/check_ntp_time.c:577
2778msgid "NTP OK:" 2285msgid "NTP OK:"
2779msgstr "NTP OK:" 2286msgstr "NTP OK:"
2780 2287
2781#: plugins/check_ntp.c:816 plugins/check_ntp_peer.c:621
2782#: plugins/check_ntp_time.c:580
2783msgid "NTP UNKNOWN:" 2288msgid "NTP UNKNOWN:"
2784msgstr "NTP INCONNU:" 2289msgstr "NTP INCONNU:"
2785 2290
2786#: plugins/check_ntp.c:820 plugins/check_ntp_peer.c:630
2787#: plugins/check_ntp_time.c:584
2788msgid "Offset unknown" 2291msgid "Offset unknown"
2789msgstr "Décalage inconnu" 2292msgstr "Décalage inconnu"
2790 2293
2791#: plugins/check_ntp.c:823 plugins/check_ntp_peer.c:633
2792#: plugins/check_ntp_time.c:587
2793msgid "Offset" 2294msgid "Offset"
2794msgstr "Décalage" 2295msgstr "Décalage"
2795 2296
2796#: plugins/check_ntp.c:844 plugins/check_ntp_peer.c:662
2797msgid "This plugin checks the selected ntp server" 2297msgid "This plugin checks the selected ntp server"
2798msgstr "Ce plugin vérifie le service ntp sur l'hôte" 2298msgstr "Ce plugin vérifie le service ntp sur l'hôte"
2799 2299
2800#: plugins/check_ntp.c:854 plugins/check_ntp_peer.c:674
2801#: plugins/check_ntp_time.c:614
2802msgid "Offset to result in warning status (seconds)" 2300msgid "Offset to result in warning status (seconds)"
2803msgstr "Décalage résultant en un avertissement (secondes)" 2301msgstr "Décalage résultant en un avertissement (secondes)"
2804 2302
2805#: plugins/check_ntp.c:856 plugins/check_ntp_peer.c:676
2806#: plugins/check_ntp_time.c:616
2807msgid "Offset to result in critical status (seconds)" 2303msgid "Offset to result in critical status (seconds)"
2808msgstr "Décalage résultant en un état critique (secondes)" 2304msgstr "Décalage résultant en un état critique (secondes)"
2809 2305
2810#: plugins/check_ntp.c:858 plugins/check_ntp_peer.c:682
2811msgid "Warning threshold for jitter" 2306msgid "Warning threshold for jitter"
2812msgstr "Seuil d'avertissement pour la variation (jitter)" 2307msgstr "Seuil d'avertissement pour la variation (jitter)"
2813 2308
2814#: plugins/check_ntp.c:860 plugins/check_ntp_peer.c:684
2815msgid "Critical threshold for jitter" 2309msgid "Critical threshold for jitter"
2816msgstr "Seuil critique pour la variation (jitter)" 2310msgstr "Seuil critique pour la variation (jitter)"
2817 2311
2818#: plugins/check_ntp.c:870
2819msgid "Normal offset check:" 2312msgid "Normal offset check:"
2820msgstr "Vérification normale du décalage:" 2313msgstr "Vérification normale du décalage:"
2821 2314
2822#: plugins/check_ntp.c:873 plugins/check_ntp_peer.c:709
2823msgid "" 2315msgid ""
2824"Check jitter too, avoiding critical notifications if jitter isn't available" 2316"Check jitter too, avoiding critical notifications if jitter isn't available"
2825msgstr "" 2317msgstr ""
2826"Vérifier aussi la variation (jitter) en évitant les notifications s'il n'est " 2318"Vérifier aussi la variation (jitter) en évitant les notifications s'il n'est "
2827"pas dispoible" 2319"pas dispoible"
2828 2320
2829#: plugins/check_ntp.c:874 plugins/check_ntp_peer.c:710
2830msgid "(See Notes above for more details on thresholds formats):" 2321msgid "(See Notes above for more details on thresholds formats):"
2831msgstr "" 2322msgstr ""
2832"(Voir les Notes ci-dessus pour plus de détails sur le format des seuils)" 2323"(Voir les Notes ci-dessus pour plus de détails sur le format des seuils)"
2833 2324
2834#: plugins/check_ntp.c:879 plugins/check_ntp.c:886
2835msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or" 2325msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or"
2836msgstr "ATTENTION: check_ntp est périmé, utilisez plutôt check_ntp_peer" 2326msgstr "ATTENTION: check_ntp est périmé, utilisez plutôt check_ntp_peer"
2837 2327
2838#: plugins/check_ntp.c:880 plugins/check_ntp.c:887
2839msgid "check_ntp_time instead." 2328msgid "check_ntp_time instead."
2840msgstr "ou check_ntp_time." 2329msgstr "ou check_ntp_time."
2841 2330
2842#: plugins/check_ntp_peer.c:625
2843msgid "Server not synchronized" 2331msgid "Server not synchronized"
2844msgstr "Le serveur n'est pas synchronisé" 2332msgstr "Le serveur n'est pas synchronisé"
2845 2333
2846#: plugins/check_ntp_peer.c:627
2847msgid "Server has the LI_ALARM bit set" 2334msgid "Server has the LI_ALARM bit set"
2848msgstr "" 2335msgstr ""
2849 2336
2850#: plugins/check_ntp_peer.c:672
2851msgid "" 2337msgid ""
2852"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized" 2338"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"
2853msgstr "" 2339msgstr ""
2854"Retourne INCONNU au lieu de CRITIQUE ou AVERTISSEMENT si le serveur n'est " 2340"Retourne INCONNU au lieu de CRITIQUE ou AVERTISSEMENT si le serveur n'est "
2855"pas synchronisé" 2341"pas synchronisé"
2856 2342
2857#: plugins/check_ntp_peer.c:678
2858#, fuzzy 2343#, fuzzy
2859msgid "Warning threshold for stratum of server's synchronization peer" 2344msgid "Warning threshold for stratum of server's synchronization peer"
2860msgstr "Seuil d'avertissement pour le stratum" 2345msgstr "Seuil d'avertissement pour le stratum"
2861 2346
2862#: plugins/check_ntp_peer.c:680
2863#, fuzzy 2347#, fuzzy
2864msgid "Critical threshold for stratum of server's synchronization peer" 2348msgid "Critical threshold for stratum of server's synchronization peer"
2865msgstr "Seuil critique pour le stratum" 2349msgstr "Seuil critique pour le stratum"
2866 2350
2867#: plugins/check_ntp_peer.c:686
2868msgid "Warning threshold for number of usable time sources (\"truechimers\")" 2351msgid "Warning threshold for number of usable time sources (\"truechimers\")"
2869msgstr "" 2352msgstr ""
2870"Seuil d'avertissement pour le nombre de sources de temps utilisable " 2353"Seuil d'avertissement pour le nombre de sources de temps utilisable "
2871"(\"truechimers\")" 2354"(\"truechimers\")"
2872 2355
2873#: plugins/check_ntp_peer.c:688
2874msgid "Critical threshold for number of usable time sources (\"truechimers\")" 2356msgid "Critical threshold for number of usable time sources (\"truechimers\")"
2875msgstr "" 2357msgstr ""
2876"Seuil critique pour le nombre de sources de temps utilisable (\"truechimers" 2358"Seuil critique pour le nombre de sources de temps utilisable "
2877"\")" 2359"(\"truechimers\")"
2878 2360
2879#: plugins/check_ntp_peer.c:693
2880msgid "This plugin checks an NTP server independent of any commandline" 2361msgid "This plugin checks an NTP server independent of any commandline"
2881msgstr "Ce plugin vérifie un serveur NTP sans recours aux programmes de" 2362msgstr "Ce plugin vérifie un serveur NTP sans recours aux programmes de"
2882 2363
2883#: plugins/check_ntp_peer.c:694
2884msgid "programs or external libraries." 2364msgid "programs or external libraries."
2885msgstr "la ligne de commande ou libraries externes" 2365msgstr "la ligne de commande ou libraries externes"
2886 2366
2887#: plugins/check_ntp_peer.c:697
2888msgid "Use this plugin to check the health of an NTP server. It supports" 2367msgid "Use this plugin to check the health of an NTP server. It supports"
2889msgstr "" 2368msgstr ""
2890"Utilisez ce plugin pour vérifier le service NTP sur l'hôte. Il supporte la" 2369"Utilisez ce plugin pour vérifier le service NTP sur l'hôte. Il supporte la"
2891 2370
2892#: plugins/check_ntp_peer.c:698
2893msgid "checking the offset with the sync peer, the jitter and stratum. This" 2371msgid "checking the offset with the sync peer, the jitter and stratum. This"
2894msgstr "" 2372msgstr ""
2895"vérification du décalage avec le pair se synchronisation, la variation " 2373"vérification du décalage avec le pair se synchronisation, la variation "
2896"(jitter) et le stratum." 2374"(jitter) et le stratum."
2897 2375
2898#: plugins/check_ntp_peer.c:699
2899msgid "plugin will not check the clock offset between the local host and NTP" 2376msgid "plugin will not check the clock offset between the local host and NTP"
2900msgstr "" 2377msgstr ""
2901"Ce plugin ne vérifie pas le décalage entre le serveur local et le serveur" 2378"Ce plugin ne vérifie pas le décalage entre le serveur local et le serveur"
2902 2379
2903#: plugins/check_ntp_peer.c:700
2904msgid "server; please use check_ntp_time for that purpose." 2380msgid "server; please use check_ntp_time for that purpose."
2905msgstr "NTP; utilisez plutôt check_ntp_time à cette fin." 2381msgstr "NTP; utilisez plutôt check_ntp_time à cette fin."
2906 2382
2907#: plugins/check_ntp_peer.c:706
2908msgid "Simple NTP server check:" 2383msgid "Simple NTP server check:"
2909msgstr "Vérification simple du serveur NTP:" 2384msgstr "Vérification simple du serveur NTP:"
2910 2385
2911#: plugins/check_ntp_peer.c:713
2912msgid "Only check the number of usable time sources (\"truechimers\"):" 2386msgid "Only check the number of usable time sources (\"truechimers\"):"
2913msgstr "" 2387msgstr ""
2914 2388
2915#: plugins/check_ntp_peer.c:716
2916msgid "Check only stratum:" 2389msgid "Check only stratum:"
2917msgstr "Vérification du stratum seulement:" 2390msgstr "Vérification du stratum seulement:"
2918 2391
2919#: plugins/check_ntp_time.c:602
2920msgid "This plugin checks the clock offset with the ntp server" 2392msgid "This plugin checks the clock offset with the ntp server"
2921msgstr "Ce plugin vérifie le décalage de l'horloge avec le serveur ntp" 2393msgstr "Ce plugin vérifie le décalage de l'horloge avec le serveur ntp"
2922 2394
2923#: plugins/check_ntp_time.c:612
2924msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found" 2395msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found"
2925msgstr "Retourne INCONNU au lieu de CRITIQUE si le décalage est inconnu" 2396msgstr "Retourne INCONNU au lieu de CRITIQUE si le décalage est inconnu"
2926 2397
2927#: plugins/check_ntp_time.c:621 2398msgid "Expected offset of the ntp server relative to local server (seconds)"
2399msgstr ""
2400
2928msgid "This plugin checks the clock offset between the local host and a" 2401msgid "This plugin checks the clock offset between the local host and a"
2929msgstr "Ce plugin vérifie le décalage de l'horloge entre se serveur local et" 2402msgstr "Ce plugin vérifie le décalage de l'horloge entre se serveur local et"
2930 2403
2931#: plugins/check_ntp_time.c:622
2932msgid "remote NTP server. It is independent of any commandline programs or" 2404msgid "remote NTP server. It is independent of any commandline programs or"
2933msgstr "le serveur NTP distant. Il ne fait aucun recours aux programmes de" 2405msgstr "le serveur NTP distant. Il ne fait aucun recours aux programmes de"
2934 2406
2935#: plugins/check_ntp_time.c:623
2936msgid "external libraries." 2407msgid "external libraries."
2937msgstr "la ligne de commande ou libraries externes." 2408msgstr "la ligne de commande ou libraries externes."
2938 2409
2939#: plugins/check_ntp_time.c:627
2940msgid "If you'd rather want to monitor an NTP server, please use" 2410msgid "If you'd rather want to monitor an NTP server, please use"
2941msgstr "Si vous voulez plutôt surveiller un serveur NTP, veuillez" 2411msgstr "Si vous voulez plutôt surveiller un serveur NTP, veuillez"
2942 2412
2943#: plugins/check_ntp_time.c:628
2944msgid "check_ntp_peer." 2413msgid "check_ntp_peer."
2945msgstr "utiliser check_ntp_peer." 2414msgstr "utiliser check_ntp_peer."
2946 2415
2947#: plugins/check_nwstat.c:194 2416msgid "--time-offset is useful for compensating for servers with known"
2417msgstr ""
2418
2419msgid "and expected clock skew."
2420msgstr ""
2421
2948#, c-format 2422#, c-format
2949msgid "NetWare %s: " 2423msgid "NetWare %s: "
2950msgstr "NetWare %s: " 2424msgstr "NetWare %s: "
2951 2425
2952#: plugins/check_nwstat.c:232
2953#, c-format 2426#, c-format
2954msgid "Up %s," 2427msgid "Up %s,"
2955msgstr "Démarré %s," 2428msgstr "Démarré %s,"
2956 2429
2957#: plugins/check_nwstat.c:240
2958#, c-format 2430#, c-format
2959msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100" 2431msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"
2960msgstr "" 2432msgstr ""
2961"Charge %s - %s %s charge système minimale = %lu%%|charge%s=%lu;%lu;%lu;0;100" 2433"Charge %s - %s %s charge système minimale = %lu%%|charge%s=%lu;%lu;%lu;0;100"
2962 2434
2963#: plugins/check_nwstat.c:268
2964#, c-format 2435#, c-format
2965msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;" 2436msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"
2966msgstr "Conns %s - %lu connections actuelles|Conns=%lu;%lu;%lu;;" 2437msgstr "Conns %s - %lu connections actuelles|Conns=%lu;%lu;%lu;;"
2967 2438
2968#: plugins/check_nwstat.c:293
2969#, c-format 2439#, c-format
2970msgid "%s: Long term cache hits = %lu%%" 2440msgid "%s: Long term cache hits = %lu%%"
2971msgstr "%s: Accès cache longue durée = %lu%%" 2441msgstr "%s: Accès cache longue durée = %lu%%"
2972 2442
2973#: plugins/check_nwstat.c:315
2974#, c-format 2443#, c-format
2975msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;" 2444msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"
2976msgstr "%s: Total des caches tampons= %lu|Caches Tampons=%lu,%lu;%lu;;" 2445msgstr "%s: Total des caches tampons= %lu|Caches Tampons=%lu,%lu;%lu;;"
2977 2446
2978#: plugins/check_nwstat.c:340
2979#, c-format 2447#, c-format
2980msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;" 2448msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"
2981msgstr "%s: cache tampons sales = %lu|caches tampons sales=%lu;%lu;%lu;;" 2449msgstr "%s: cache tampons sales = %lu|caches tampons sales=%lu;%lu;%lu;;"
2982 2450
2983#: plugins/check_nwstat.c:365
2984#, c-format 2451#, c-format
2985msgid "%s: LRU sitting time = %lu minutes" 2452msgid "%s: LRU sitting time = %lu minutes"
2986msgstr "" 2453msgstr ""
2987 2454
2988#: plugins/check_nwstat.c:382 plugins/check_nwstat.c:410
2989#: plugins/check_nwstat.c:437 plugins/check_nwstat.c:470
2990#: plugins/check_nwstat.c:650 plugins/check_nwstat.c:676
2991#: plugins/check_nwstat.c:707 plugins/check_nwstat.c:753
2992#: plugins/check_nwstat.c:777
2993#, c-format 2455#, c-format
2994msgid "CRITICAL - Volume '%s' does not exist!" 2456msgid "CRITICAL - Volume '%s' does not exist!"
2995msgstr "CRITIQUE: Le volume '%s' n'existe pas!" 2457msgstr "CRITIQUE: Le volume '%s' n'existe pas!"
2996 2458
2997#: plugins/check_nwstat.c:391
2998#, c-format 2459#, c-format
2999msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;" 2460msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"
3000msgstr "%s%lu KB libre sur le volume %s|KB libres%s=%lu;%lu;%lu;;" 2461msgstr "%s%lu KB libre sur le volume %s|KB libres%s=%lu;%lu;%lu;;"
3001 2462
3002#: plugins/check_nwstat.c:392 plugins/check_nwstat.c:420
3003#: plugins/check_nwstat.c:447 plugins/check_nwstat.c:659
3004#: plugins/check_nwstat.c:685 plugins/check_nwstat.c:761
3005msgid "Only " 2463msgid "Only "
3006msgstr "Seulement" 2464msgstr "Seulement"
3007 2465
3008#: plugins/check_nwstat.c:419
3009#, c-format 2466#, c-format
3010msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;" 2467msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"
3011msgstr "%s%lu MB libre sur le volume %s|MBlibre%s=%lu;%lu;%lu;;" 2468msgstr "%s%lu MB libre sur le volume %s|MBlibre%s=%lu;%lu;%lu;;"
3012 2469
3013#: plugins/check_nwstat.c:446
3014#, c-format 2470#, c-format
3015msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;" 2471msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"
3016msgstr "" 2472msgstr ""
3017 2473
3018#: plugins/check_nwstat.c:494
3019#, c-format 2474#, c-format
3020msgid "" 2475msgid ""
3021"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100" 2476"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"
@@ -3023,1102 +2478,877 @@ msgstr ""
3023"%lu MB (%lu%%) libre sur le volume %s - total %lu MB|MBlibre%s=%lu;%lu;" 2478"%lu MB (%lu%%) libre sur le volume %s - total %lu MB|MBlibre%s=%lu;%lu;"
3024"%lu;0;100" 2479"%lu;0;100"
3025 2480
3026#: plugins/check_nwstat.c:528
3027#, c-format 2481#, c-format
3028msgid "Directory Services Database is %s (DS version %s)" 2482msgid "Directory Services Database is %s (DS version %s)"
3029msgstr "La base de données Directory Services est %s (DS version %s)" 2483msgstr "La base de données Directory Services est %s (DS version %s)"
3030 2484
3031#: plugins/check_nwstat.c:545
3032#, c-format 2485#, c-format
3033msgid "Logins are %s" 2486msgid "Logins are %s"
3034msgstr "Les logins sont %s" 2487msgstr "Les logins sont %s"
3035 2488
3036#: plugins/check_nwstat.c:545
3037msgid "enabled" 2489msgid "enabled"
3038msgstr "activé" 2490msgstr "activé"
3039 2491
3040#: plugins/check_nwstat.c:545
3041msgid "disabled" 2492msgid "disabled"
3042msgstr "désactivé" 2493msgstr "désactivé"
3043 2494
3044#: plugins/check_nwstat.c:560
3045msgid "CRITICAL - NRM Status is bad!" 2495msgid "CRITICAL - NRM Status is bad!"
3046msgstr "CRITIQUE - le statut NRM est mauvais!" 2496msgstr "CRITIQUE - le statut NRM est mauvais!"
3047 2497
3048#: plugins/check_nwstat.c:565
3049msgid "Warning - NRM Status is suspect!" 2498msgid "Warning - NRM Status is suspect!"
3050msgstr "" 2499msgstr ""
3051 2500
3052#: plugins/check_nwstat.c:568
3053msgid "OK - NRM Status is good!" 2501msgid "OK - NRM Status is good!"
3054msgstr "OK - Le status du NRM est bon!" 2502msgstr "OK - Le status du NRM est bon!"
3055 2503
3056#: plugins/check_nwstat.c:610
3057#, c-format 2504#, c-format
3058msgid "%lu of %lu (%lu%%) packet receive buffers used" 2505msgid "%lu of %lu (%lu%%) packet receive buffers used"
3059msgstr "%lu de %lu (%lu%%) paquets du tampon de réception utilisés" 2506msgstr "%lu de %lu (%lu%%) paquets du tampon de réception utilisés"
3060 2507
3061#: plugins/check_nwstat.c:634
3062#, c-format 2508#, c-format
3063msgid "%lu entries in SAP table" 2509msgid "%lu entries in SAP table"
3064msgstr "%lu entrées dans la table SAP" 2510msgstr "%lu entrées dans la table SAP"
3065 2511
3066#: plugins/check_nwstat.c:636
3067#, c-format 2512#, c-format
3068msgid "%lu entries in SAP table for SAP type %d" 2513msgid "%lu entries in SAP table for SAP type %d"
3069msgstr "%lu entrées dans la table SAP pour le type SAP %d" 2514msgstr "%lu entrées dans la table SAP pour le type SAP %d"
3070 2515
3071#: plugins/check_nwstat.c:658
3072#, c-format 2516#, c-format
3073msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2517msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3074msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;" 2518msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;"
3075 2519
3076#: plugins/check_nwstat.c:684
3077#, c-format 2520#, c-format
3078msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2521msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
3079msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;" 2522msgstr "%s%lu KB effaçables sur le volume %s|Purge%s=%lu;%lu;%lu;;"
3080 2523
3081#: plugins/check_nwstat.c:730
3082#, c-format 2524#, c-format
3083msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100" 2525msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"
3084msgstr "" 2526msgstr ""
3085"%lu MB (%lu%%) effaçables sur le volume %s|Effacable%s=%lu;%lu;%lu;0;100" 2527"%lu MB (%lu%%) effaçables sur le volume %s|Effacable%s=%lu;%lu;%lu;0;100"
3086 2528
3087#: plugins/check_nwstat.c:761
3088#, c-format 2529#, c-format
3089msgid "%s%lu KB not yet purgeable on volume %s" 2530msgid "%s%lu KB not yet purgeable on volume %s"
3090msgstr "%s%lu KB pas encore effaçables sur le volume %s" 2531msgstr "%s%lu KB pas encore effaçables sur le volume %s"
3091 2532
3092#: plugins/check_nwstat.c:800
3093#, c-format 2533#, c-format
3094msgid "%lu MB (%lu%%) not yet purgeable on volume %s" 2534msgid "%lu MB (%lu%%) not yet purgeable on volume %s"
3095msgstr "%lu MB (%lu%%) pas encore effaçables sur le volume %s" 2535msgstr "%lu MB (%lu%%) pas encore effaçables sur le volume %s"
3096 2536
3097#: plugins/check_nwstat.c:821
3098#, c-format 2537#, c-format
3099msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0" 2538msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0"
3100msgstr "" 2539msgstr ""
3101 2540
3102#: plugins/check_nwstat.c:846
3103#, c-format 2541#, c-format
3104msgid "%lu abended threads|Abends=%lu;%lu;%lu;;" 2542msgid "%lu abended threads|Abends=%lu;%lu;%lu;;"
3105msgstr "%lu processus avortés|Avortés=%lu;%lu;%lu;;" 2543msgstr "%lu processus avortés|Avortés=%lu;%lu;%lu;;"
3106 2544
3107#: plugins/check_nwstat.c:881
3108#, c-format 2545#, c-format
3109msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu" 2546msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"
3110msgstr "%lu processus services actuels (%lu max)|Processus=%lu;%lu;%lu;0;%lu" 2547msgstr "%lu processus services actuels (%lu max)|Processus=%lu;%lu;%lu;0;%lu"
3111 2548
3112#: plugins/check_nwstat.c:904
3113msgid "CRITICAL - Time not in sync with network!" 2549msgid "CRITICAL - Time not in sync with network!"
3114msgstr "CRITIQUE - Le temps n'est pas synchronisé avec le réseau!" 2550msgstr "CRITIQUE - Le temps n'est pas synchronisé avec le réseau!"
3115 2551
3116#: plugins/check_nwstat.c:907
3117msgid "OK - Time in sync with network!" 2552msgid "OK - Time in sync with network!"
3118msgstr "OK - Le temps est synchronisé avec le réseau!" 2553msgstr "OK - Le temps est synchronisé avec le réseau!"
3119 2554
3120#: plugins/check_nwstat.c:930
3121#, c-format 2555#, c-format
3122msgid "LRU sitting time = %lu seconds" 2556msgid "LRU sitting time = %lu seconds"
3123msgstr "LRU temps d'attente = %lu secondes" 2557msgstr "LRU temps d'attente = %lu secondes"
3124 2558
3125#: plugins/check_nwstat.c:949
3126#, c-format 2559#, c-format
3127msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100" 2560msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"
3128msgstr "Buffers cache sales = %lu%% du total|DCB=%lu;%lu;%lu;0;100" 2561msgstr "Buffers cache sales = %lu%% du total|DCB=%lu;%lu;%lu;0;100"
3129 2562
3130#: plugins/check_nwstat.c:971
3131#, c-format 2563#, c-format
3132msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100" 2564msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"
3133msgstr "cache tampons totaux= %lu%% de l'original|TCB=%lu;%lu;%lu;0;100" 2565msgstr "cache tampons totaux= %lu%% de l'original|TCB=%lu;%lu;%lu;0;100"
3134 2566
3135#: plugins/check_nwstat.c:989
3136#, c-format 2567#, c-format
3137msgid "NDS Version %s" 2568msgid "NDS Version %s"
3138msgstr "Version NDS %s" 2569msgstr "Version NDS %s"
3139 2570
3140#: plugins/check_nwstat.c:1005
3141#, c-format 2571#, c-format
3142msgid "Up %s" 2572msgid "Up %s"
3143msgstr "Démarré %s" 2573msgstr "Démarré %s"
3144 2574
3145#: plugins/check_nwstat.c:1019
3146#, c-format 2575#, c-format
3147msgid "Module %s version %s is loaded" 2576msgid "Module %s version %s is loaded"
3148msgstr "Le Module %s version %s est chargé" 2577msgstr "Le Module %s version %s est chargé"
3149 2578
3150#: plugins/check_nwstat.c:1022
3151#, c-format 2579#, c-format
3152msgid "Module %s is not loaded" 2580msgid "Module %s is not loaded"
3153msgstr "Le Module %s n'est pas chargé" 2581msgstr "Le Module %s n'est pas chargé"
3154 2582
3155#: plugins/check_nwstat.c:1033 plugins/check_nwstat.c:1059
3156#: plugins/check_nwstat.c:1085 plugins/check_nwstat.c:1111
3157#: plugins/check_nwstat.c:1137 plugins/check_nwstat.c:1163
3158#: plugins/check_nwstat.c:1189 plugins/check_nwstat.c:1215
3159#: plugins/check_nwstat.c:1241 plugins/check_nwstat.c:1267
3160#, c-format 2583#, c-format
3161msgid "CRITICAL - Value '%s' does not exist!" 2584msgid "CRITICAL - Value '%s' does not exist!"
3162msgstr "CRITIQUE: Le valeur '%s' n'existe pas!" 2585msgstr "CRITIQUE: Le valeur '%s' n'existe pas!"
3163 2586
3164#: plugins/check_nwstat.c:1042 plugins/check_nwstat.c:1068
3165#: plugins/check_nwstat.c:1094 plugins/check_nwstat.c:1120
3166#: plugins/check_nwstat.c:1146 plugins/check_nwstat.c:1172
3167#: plugins/check_nwstat.c:1198 plugins/check_nwstat.c:1224
3168#: plugins/check_nwstat.c:1250 plugins/check_nwstat.c:1276
3169#, c-format 2587#, c-format
3170msgid "%s is %lu|%s=%lu;%lu;%lu;;" 2588msgid "%s is %lu|%s=%lu;%lu;%lu;;"
3171msgstr "%s est %lu|%s=%lu;%lu;%lu;;" 2589msgstr "%s est %lu|%s=%lu;%lu;%lu;;"
3172 2590
3173#: plugins/check_nwstat.c:1289 plugins/check_overcr.c:285
3174msgid "Nothing to check!\n" 2591msgid "Nothing to check!\n"
3175msgstr "Rien à vérifier!\n" 2592msgstr "Rien à vérifier!\n"
3176 2593
3177#: plugins/check_nwstat.c:1371 plugins/check_overcr.c:355
3178msgid "Server port an integer\n" 2594msgid "Server port an integer\n"
3179msgstr "Le port du serveur doit être un nombre entier\n" 2595msgstr "Le port du serveur doit être un nombre entier\n"
3180 2596
3181#: plugins/check_nwstat.c:1601
3182msgid "This plugin attempts to contact the MRTGEXT NLM running on a" 2597msgid "This plugin attempts to contact the MRTGEXT NLM running on a"
3183msgstr "Ce plugin essaye de contacter le NLM MRTGEXT qui s'exécute sur" 2598msgstr "Ce plugin essaye de contacter le NLM MRTGEXT qui s'exécute sur"
3184 2599
3185#: plugins/check_nwstat.c:1602
3186msgid "Novell server to gather the requested system information." 2600msgid "Novell server to gather the requested system information."
3187msgstr "un serveur Novell pour récupérer l'information système demandée." 2601msgstr "un serveur Novell pour récupérer l'information système demandée."
3188 2602
3189#: plugins/check_nwstat.c:1614 plugins/check_overcr.c:436
3190msgid "Variable to check. Valid variables include:" 2603msgid "Variable to check. Valid variables include:"
3191msgstr "Variable à vérifier. Les variables valides sont:" 2604msgstr "Variable à vérifier. Les variables valides sont:"
3192 2605
3193#: plugins/check_nwstat.c:1615
3194msgid "LOAD1 = 1 minute average CPU load" 2606msgid "LOAD1 = 1 minute average CPU load"
3195msgstr "" 2607msgstr ""
3196 2608
3197#: plugins/check_nwstat.c:1616
3198msgid "LOAD5 = 5 minute average CPU load" 2609msgid "LOAD5 = 5 minute average CPU load"
3199msgstr "" 2610msgstr ""
3200 2611
3201#: plugins/check_nwstat.c:1617
3202msgid "LOAD15 = 15 minute average CPU load" 2612msgid "LOAD15 = 15 minute average CPU load"
3203msgstr "" 2613msgstr ""
3204 2614
3205#: plugins/check_nwstat.c:1618
3206msgid "CSPROCS = number of current service processes (NW 5.x only)" 2615msgid "CSPROCS = number of current service processes (NW 5.x only)"
3207msgstr "CSPROCS = nombres de processus services actuels (NW 5.x seulement)" 2616msgstr "CSPROCS = nombres de processus services actuels (NW 5.x seulement)"
3208 2617
3209#: plugins/check_nwstat.c:1619
3210msgid "ABENDS = number of abended threads (NW 5.x only)" 2618msgid "ABENDS = number of abended threads (NW 5.x only)"
3211msgstr "" 2619msgstr ""
3212 2620
3213#: plugins/check_nwstat.c:1620
3214msgid "UPTIME = server uptime" 2621msgid "UPTIME = server uptime"
3215msgstr "" 2622msgstr ""
3216 2623
3217#: plugins/check_nwstat.c:1621
3218msgid "LTCH = percent long term cache hits" 2624msgid "LTCH = percent long term cache hits"
3219msgstr "" 2625msgstr ""
3220 2626
3221#: plugins/check_nwstat.c:1622
3222msgid "CBUFF = current number of cache buffers" 2627msgid "CBUFF = current number of cache buffers"
3223msgstr "" 2628msgstr ""
3224 2629
3225#: plugins/check_nwstat.c:1623
3226msgid "CDBUFF = current number of dirty cache buffers" 2630msgid "CDBUFF = current number of dirty cache buffers"
3227msgstr "" 2631msgstr ""
3228 2632
3229#: plugins/check_nwstat.c:1624
3230msgid "DCB = dirty cache buffers as a percentage of the total" 2633msgid "DCB = dirty cache buffers as a percentage of the total"
3231msgstr "" 2634msgstr ""
3232 2635
3233#: plugins/check_nwstat.c:1625
3234msgid "TCB = dirty cache buffers as a percentage of the original" 2636msgid "TCB = dirty cache buffers as a percentage of the original"
3235msgstr "" 2637msgstr ""
3236 2638
3237#: plugins/check_nwstat.c:1626
3238msgid "OFILES = number of open files" 2639msgid "OFILES = number of open files"
3239msgstr "" 2640msgstr ""
3240 2641
3241#: plugins/check_nwstat.c:1627
3242msgid " VMF<vol> = MB of free space on Volume <vol>" 2642msgid " VMF<vol> = MB of free space on Volume <vol>"
3243msgstr "" 2643msgstr ""
3244 2644
3245#: plugins/check_nwstat.c:1628
3246msgid " VMU<vol> = MB used space on Volume <vol>" 2645msgid " VMU<vol> = MB used space on Volume <vol>"
3247msgstr "" 2646msgstr ""
3248 2647
3249#: plugins/check_nwstat.c:1629
3250msgid " VMP<vol> = MB of purgeable space on Volume <vol>" 2648msgid " VMP<vol> = MB of purgeable space on Volume <vol>"
3251msgstr "" 2649msgstr ""
3252 2650
3253#: plugins/check_nwstat.c:1630
3254msgid " VPF<vol> = percent free space on volume <vol>" 2651msgid " VPF<vol> = percent free space on volume <vol>"
3255msgstr "" 2652msgstr ""
3256 2653
3257#: plugins/check_nwstat.c:1631
3258msgid " VKF<vol> = KB of free space on volume <vol>" 2654msgid " VKF<vol> = KB of free space on volume <vol>"
3259msgstr "" 2655msgstr ""
3260 2656
3261#: plugins/check_nwstat.c:1632
3262msgid " VPP<vol> = percent purgeable space on volume <vol>" 2657msgid " VPP<vol> = percent purgeable space on volume <vol>"
3263msgstr "" 2658msgstr ""
3264 2659
3265#: plugins/check_nwstat.c:1633
3266msgid " VKP<vol> = KB of purgeable space on volume <vol>" 2660msgid " VKP<vol> = KB of purgeable space on volume <vol>"
3267msgstr "" 2661msgstr ""
3268 2662
3269#: plugins/check_nwstat.c:1634
3270msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>" 2663msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>"
3271msgstr "" 2664msgstr ""
3272 2665
3273#: plugins/check_nwstat.c:1635
3274msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>" 2666msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>"
3275msgstr "" 2667msgstr ""
3276 2668
3277#: plugins/check_nwstat.c:1636
3278msgid " LRUM = LRU sitting time in minutes" 2669msgid " LRUM = LRU sitting time in minutes"
3279msgstr "" 2670msgstr ""
3280 2671
3281#: plugins/check_nwstat.c:1637
3282msgid " LRUS = LRU sitting time in seconds" 2672msgid " LRUS = LRU sitting time in seconds"
3283msgstr " LRUS = LRU temps d'attente en secondes" 2673msgstr " LRUS = LRU temps d'attente en secondes"
3284 2674
3285#: plugins/check_nwstat.c:1638
3286msgid " DSDB = check to see if DS Database is open" 2675msgid " DSDB = check to see if DS Database is open"
3287msgstr "" 2676msgstr ""
3288 2677
3289#: plugins/check_nwstat.c:1639
3290msgid " DSVER = NDS version" 2678msgid " DSVER = NDS version"
3291msgstr "" 2679msgstr ""
3292 2680
3293#: plugins/check_nwstat.c:1640
3294msgid " UPRB = used packet receive buffers" 2681msgid " UPRB = used packet receive buffers"
3295msgstr " UPRB = paquets du tampon de réception utilisés" 2682msgstr " UPRB = paquets du tampon de réception utilisés"
3296 2683
3297#: plugins/check_nwstat.c:1641
3298msgid " PUPRB = percent (of max) used packet receive buffers" 2684msgid " PUPRB = percent (of max) used packet receive buffers"
3299msgstr "" 2685msgstr ""
3300 2686
3301#: plugins/check_nwstat.c:1642
3302msgid " SAPENTRIES = number of entries in the SAP table" 2687msgid " SAPENTRIES = number of entries in the SAP table"
3303msgstr "" 2688msgstr ""
3304 2689
3305#: plugins/check_nwstat.c:1643
3306msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>" 2690msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"
3307msgstr " SAPENTRIES<n> = entrées dans la table SAP pour le type SAP <n>" 2691msgstr " SAPENTRIES<n> = entrées dans la table SAP pour le type SAP <n>"
3308 2692
3309#: plugins/check_nwstat.c:1644
3310msgid " TSYNC = timesync status" 2693msgid " TSYNC = timesync status"
3311msgstr "" 2694msgstr ""
3312 2695
3313#: plugins/check_nwstat.c:1645
3314msgid " LOGINS = check to see if logins are enabled" 2696msgid " LOGINS = check to see if logins are enabled"
3315msgstr "" 2697msgstr ""
3316 2698
3317#: plugins/check_nwstat.c:1646
3318msgid " CONNS = number of currently licensed connections" 2699msgid " CONNS = number of currently licensed connections"
3319msgstr "" 2700msgstr ""
3320 2701
3321#: plugins/check_nwstat.c:1647
3322msgid " NRMH\t= NRM Summary Status" 2702msgid " NRMH\t= NRM Summary Status"
3323msgstr "" 2703msgstr ""
3324 2704
3325#: plugins/check_nwstat.c:1648
3326msgid " NRMP<stat> = Returns the current value for a NRM health item" 2705msgid " NRMP<stat> = Returns the current value for a NRM health item"
3327msgstr "" 2706msgstr ""
3328 2707
3329#: plugins/check_nwstat.c:1649
3330msgid " NRMM<stat> = Returns the current memory stats from NRM" 2708msgid " NRMM<stat> = Returns the current memory stats from NRM"
3331msgstr "" 2709msgstr ""
3332 2710
3333#: plugins/check_nwstat.c:1650
3334msgid " NRMS<stat> = Returns the current Swapfile stats from NRM" 2711msgid " NRMS<stat> = Returns the current Swapfile stats from NRM"
3335msgstr "" 2712msgstr ""
3336 2713
3337#: plugins/check_nwstat.c:1651
3338msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml" 2714msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"
3339msgstr "" 2715msgstr ""
3340 2716
3341#: plugins/check_nwstat.c:1652
3342msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml" 2717msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"
3343msgstr "" 2718msgstr ""
3344 2719
3345#: plugins/check_nwstat.c:1653
3346msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml" 2720msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"
3347msgstr "" 2721msgstr ""
3348 2722
3349#: plugins/check_nwstat.c:1654
3350msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml" 2723msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"
3351msgstr "" 2724msgstr ""
3352 2725
3353#: plugins/check_nwstat.c:1655
3354msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml" 2726msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"
3355msgstr "" 2727msgstr ""
3356 2728
3357#: plugins/check_nwstat.c:1656
3358msgid "" 2729msgid ""
3359" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml" 2730" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"
3360msgstr "" 2731msgstr ""
3361 2732
3362#: plugins/check_nwstat.c:1657
3363msgid " NLM:<nlm> = check if NLM is loaded and report version" 2733msgid " NLM:<nlm> = check if NLM is loaded and report version"
3364msgstr "" 2734msgstr ""
3365 2735
3366#: plugins/check_nwstat.c:1658
3367msgid " (e.g. NLM:TSANDS.NLM)" 2736msgid " (e.g. NLM:TSANDS.NLM)"
3368msgstr "" 2737msgstr ""
3369 2738
3370#: plugins/check_nwstat.c:1665
3371msgid "Include server version string in results" 2739msgid "Include server version string in results"
3372msgstr "" 2740msgstr ""
3373 2741
3374#: plugins/check_nwstat.c:1671 2742msgid "- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"
3375msgid "- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"
3376msgstr "" 2743msgstr ""
3377 2744
3378#: plugins/check_nwstat.c:1672
3379msgid "" 2745msgid ""
3380" extension for NetWare be loaded on the Novell servers you wish to check." 2746" extension for NetWare be loaded on the Novell servers you wish to check."
3381msgstr "" 2747msgstr ""
3382 2748
3383#: plugins/check_nwstat.c:1673
3384msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)" 2749msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)"
3385msgstr " (disponible depuis http://www.engr.wisc.edu/~drews/mrtg/)" 2750msgstr " (disponible depuis http://www.engr.wisc.edu/~drews/mrtg/)"
3386 2751
3387#: plugins/check_nwstat.c:1674
3388msgid "" 2752msgid ""
3389"- Values for critical thresholds should be lower than warning thresholds" 2753"- Values for critical thresholds should be lower than warning thresholds"
3390msgstr "" 2754msgstr ""
3391 2755
3392#: plugins/check_nwstat.c:1675
3393msgid "" 2756msgid ""
3394" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, " 2757" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "
3395msgstr "" 2758msgstr ""
3396 2759
3397#: plugins/check_nwstat.c:1676
3398msgid " TCB, LRUS and LRUM." 2760msgid " TCB, LRUS and LRUM."
3399msgstr "" 2761msgstr ""
3400 2762
3401#: plugins/check_overcr.c:123
3402msgid "Unknown error fetching load data\n" 2763msgid "Unknown error fetching load data\n"
3403msgstr "" 2764msgstr ""
3404"Erreur inconnue lors de la récupération des données de charge système\n" 2765"Erreur inconnue lors de la récupération des données de charge système\n"
3405 2766
3406#: plugins/check_overcr.c:127
3407msgid "Invalid response from server - no load information\n" 2767msgid "Invalid response from server - no load information\n"
3408msgstr "Réponse invalide du serveur - pas d'information de charge système\n" 2768msgstr "Réponse invalide du serveur - pas d'information de charge système\n"
3409 2769
3410#: plugins/check_overcr.c:133
3411msgid "Invalid response from server after load 1\n" 2770msgid "Invalid response from server after load 1\n"
3412msgstr "Réponse invalide du serveur après charge système à 1 minute\n" 2771msgstr "Réponse invalide du serveur après charge système à 1 minute\n"
3413 2772
3414#: plugins/check_overcr.c:139
3415msgid "Invalid response from server after load 5\n" 2773msgid "Invalid response from server after load 5\n"
3416msgstr "Réponse invalide du serveur après charge système à 5 minute\n" 2774msgstr "Réponse invalide du serveur après charge système à 5 minute\n"
3417 2775
3418#: plugins/check_overcr.c:164
3419#, c-format 2776#, c-format
3420msgid "Load %s - %s-min load average = %0.2f" 2777msgid "Load %s - %s-min load average = %0.2f"
3421msgstr "Charge %s - %s-moyenne minimale de charge système = %0.2f" 2778msgstr "Charge %s - %s-moyenne minimale de charge système = %0.2f"
3422 2779
3423#: plugins/check_overcr.c:174
3424msgid "Unknown error fetching disk data\n" 2780msgid "Unknown error fetching disk data\n"
3425msgstr "Erreur inconnue en récupérant les données des disques\n" 2781msgstr "Erreur inconnue en récupérant les données des disques\n"
3426 2782
3427#: plugins/check_overcr.c:184 plugins/check_overcr.c:236
3428#: plugins/check_overcr.c:240
3429msgid "Invalid response from server\n" 2783msgid "Invalid response from server\n"
3430msgstr "Réponse invalide reçue du serveur\n" 2784msgstr "Réponse invalide reçue du serveur\n"
3431 2785
3432#: plugins/check_overcr.c:211
3433msgid "Unknown error fetching network status\n" 2786msgid "Unknown error fetching network status\n"
3434msgstr "Erreur inconnue lors de la réception de l'état du réseau\n" 2787msgstr "Erreur inconnue lors de la réception de l'état du réseau\n"
3435 2788
3436#: plugins/check_overcr.c:221
3437#, c-format 2789#, c-format
3438msgid "Net %s - %d connection%s on port %d" 2790msgid "Net %s - %d connection%s on port %d"
3439msgstr "Net %s - %d connections%s sur le port %d" 2791msgstr "Net %s - %d connections%s sur le port %d"
3440 2792
3441#: plugins/check_overcr.c:232
3442msgid "Unknown error fetching process status\n" 2793msgid "Unknown error fetching process status\n"
3443msgstr "Erreur inconnue en récupérant l'état des processus\n" 2794msgstr "Erreur inconnue en récupérant l'état des processus\n"
3444 2795
3445#: plugins/check_overcr.c:250
3446#, c-format 2796#, c-format
3447msgid "Process %s - %d instance%s of %s running" 2797msgid "Process %s - %d instance%s of %s running"
3448msgstr "Processus %s - %d instances%s de %s démarrées" 2798msgstr "Processus %s - %d instances%s de %s démarrées"
3449 2799
3450#: plugins/check_overcr.c:277
3451#, c-format 2800#, c-format
3452msgid "Uptime %s - Up %d days %d hours %d minutes" 2801msgid "Uptime %s - Up %d days %d hours %d minutes"
3453msgstr "Temps de fonctionnement %s - Up %d jours %d heures %d minutes" 2802msgstr "Temps de fonctionnement %s - Up %d jours %d heures %d minutes"
3454 2803
3455#: plugins/check_overcr.c:419
3456msgid "" 2804msgid ""
3457"This plugin attempts to contact the Over-CR collector daemon running on the" 2805"This plugin attempts to contact the Over-CR collector daemon running on the"
3458msgstr "" 2806msgstr ""
3459"Ce plugin essaye de joindre le service Over CR tournant sur le serveur UNIX" 2807"Ce plugin essaye de joindre le service Over CR tournant sur le serveur UNIX"
3460 2808
3461#: plugins/check_overcr.c:420
3462msgid "remote UNIX server in order to gather the requested system information." 2809msgid "remote UNIX server in order to gather the requested system information."
3463msgstr "distant afin de récupérer les informations système demandées." 2810msgstr "distant afin de récupérer les informations système demandées."
3464 2811
3465#: plugins/check_overcr.c:437
3466msgid "LOAD1 = 1 minute average CPU load" 2812msgid "LOAD1 = 1 minute average CPU load"
3467msgstr "" 2813msgstr ""
3468 2814
3469#: plugins/check_overcr.c:438
3470msgid "LOAD5 = 5 minute average CPU load" 2815msgid "LOAD5 = 5 minute average CPU load"
3471msgstr "" 2816msgstr ""
3472 2817
3473#: plugins/check_overcr.c:439
3474msgid "LOAD15 = 15 minute average CPU load" 2818msgid "LOAD15 = 15 minute average CPU load"
3475msgstr "" 2819msgstr ""
3476 2820
3477#: plugins/check_overcr.c:440
3478msgid "DPU<filesys> = percent used disk space on filesystem <filesys>" 2821msgid "DPU<filesys> = percent used disk space on filesystem <filesys>"
3479msgstr "" 2822msgstr ""
3480 2823
3481#: plugins/check_overcr.c:441
3482msgid "PROC<process> = number of running processes with name <process>" 2824msgid "PROC<process> = number of running processes with name <process>"
3483msgstr "" 2825msgstr ""
3484 2826
3485#: plugins/check_overcr.c:442
3486msgid "NET<port> = number of active connections on TCP port <port>" 2827msgid "NET<port> = number of active connections on TCP port <port>"
3487msgstr "" 2828msgstr ""
3488 2829
3489#: plugins/check_overcr.c:443
3490msgid "UPTIME = system uptime in seconds" 2830msgid "UPTIME = system uptime in seconds"
3491msgstr "" 2831msgstr ""
3492 2832
3493#: plugins/check_overcr.c:450
3494msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be" 2833msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be"
3495msgstr "Ce plugin requiert que le daemon collecteur Over-CR d'Eric Molitors" 2834msgstr "Ce plugin requiert que le daemon collecteur Over-CR d'Eric Molitors"
3496 2835
3497#: plugins/check_overcr.c:451
3498msgid "running on the remote server." 2836msgid "running on the remote server."
3499msgstr "soit fonctionnel sur le serveur distant" 2837msgstr "soit fonctionnel sur le serveur distant"
3500 2838
3501#: plugins/check_overcr.c:452
3502msgid "Over-CR can be downloaded from http://www.molitor.org/overcr" 2839msgid "Over-CR can be downloaded from http://www.molitor.org/overcr"
3503msgstr "" 2840msgstr ""
3504 2841
3505#: plugins/check_overcr.c:453
3506msgid "This plugin was tested with version 0.99.53 of the Over-CR collector" 2842msgid "This plugin was tested with version 0.99.53 of the Over-CR collector"
3507msgstr "Ce plugin a été testé avec la version 0.99.53 su collecteur Over-CR" 2843msgstr "Ce plugin a été testé avec la version 0.99.53 su collecteur Over-CR"
3508 2844
3509#: plugins/check_overcr.c:457
3510msgid "" 2845msgid ""
3511"For the available options, the critical threshold value should always be" 2846"For the available options, the critical threshold value should always be"
3512msgstr "" 2847msgstr ""
3513"Pour toutes les options disponibles, le seuil critique doit toujours être" 2848"Pour toutes les options disponibles, le seuil critique doit toujours être"
3514 2849
3515#: plugins/check_overcr.c:458
3516msgid "" 2850msgid ""
3517"higher than the warning threshold value, EXCEPT with the uptime variable" 2851"higher than the warning threshold value, EXCEPT with the uptime variable"
3518msgstr "plus grand que le seuil d'alerte SAUF pour l'option uptime" 2852msgstr "plus grand que le seuil d'alerte SAUF pour l'option uptime"
3519 2853
3520#: plugins/check_pgsql.c:222
3521#, c-format 2854#, c-format
3522msgid "CRITICAL - no connection to '%s' (%s).\n" 2855msgid "CRITICAL - no connection to '%s' (%s).\n"
3523msgstr "CRITIQUE - pas de connexion à '%s' (%s).\n" 2856msgstr "CRITIQUE - pas de connexion à '%s' (%s).\n"
3524 2857
3525#: plugins/check_pgsql.c:250
3526#, fuzzy, c-format 2858#, fuzzy, c-format
3527msgid " %s - database %s (%f sec.)|%s\n" 2859msgid " %s - database %s (%f sec.)|%s\n"
3528msgstr " %s - base de données %s (%d sec.)|%s\n" 2860msgstr " %s - base de données %s (%d sec.)|%s\n"
3529 2861
3530#: plugins/check_pgsql.c:317 plugins/check_time.c:277 plugins/check_time.c:289
3531#: plugins/check_users.c:181
3532msgid "Critical threshold must be a positive integer" 2862msgid "Critical threshold must be a positive integer"
3533msgstr "Le seuil critique doit être un entier positif" 2863msgstr "Le seuil critique doit être un entier positif"
3534 2864
3535#: plugins/check_pgsql.c:323 plugins/check_time.c:258 plugins/check_time.c:282
3536#: plugins/check_users.c:187 plugins/check_users.c:197
3537#: plugins/check_users.c:203
3538msgid "Warning threshold must be a positive integer" 2865msgid "Warning threshold must be a positive integer"
3539msgstr "Le seuil d'avertissement doit être un entier positif" 2866msgstr "Le seuil d'avertissement doit être un entier positif"
3540 2867
3541#: plugins/check_pgsql.c:347 2868#, fuzzy
3542msgid "Database name is not valid" 2869msgid "Database name exceeds the maximum length"
3543msgstr "Le nom de la base de données est invalide" 2870msgstr "Le nom de la base de données est invalide"
3544 2871
3545#: plugins/check_pgsql.c:353
3546msgid "User name is not valid" 2872msgid "User name is not valid"
3547msgstr "Le nom de l'utilisateur est invalide" 2873msgstr "Le nom de l'utilisateur est invalide"
3548 2874
3549#: plugins/check_pgsql.c:504
3550#, c-format 2875#, c-format
3551msgid "Test whether a PostgreSQL Database is accepting connections." 2876msgid "Test whether a PostgreSQL Database is accepting connections."
3552msgstr "Teste si une base de données Postgresql accepte les connections." 2877msgstr "Teste si une base de données Postgresql accepte les connections."
3553 2878
3554#: plugins/check_pgsql.c:516
3555msgid "Database to check " 2879msgid "Database to check "
3556msgstr "" 2880msgstr ""
3557 2881
3558#: plugins/check_pgsql.c:517 2882#, fuzzy, c-format
3559#, c-format 2883msgid "(default: %s)\n"
3560msgid "(default: %s)" 2884msgstr "(Défaut: %d)\n"
3561msgstr ""
3562 2885
3563#: plugins/check_pgsql.c:519
3564msgid "Login name of user" 2886msgid "Login name of user"
3565msgstr "Le nom d'un utilisateur" 2887msgstr "Le nom d'un utilisateur"
3566 2888
3567#: plugins/check_pgsql.c:521
3568msgid "Password (BIG SECURITY ISSUE)" 2889msgid "Password (BIG SECURITY ISSUE)"
3569msgstr "" 2890msgstr ""
3570 2891
3571#: plugins/check_pgsql.c:523
3572msgid "Connection parameters (keyword = value), see below" 2892msgid "Connection parameters (keyword = value), see below"
3573msgstr "" 2893msgstr ""
3574 2894
3575#: plugins/check_pgsql.c:530
3576msgid "SQL query to run. Only first column in first row will be read" 2895msgid "SQL query to run. Only first column in first row will be read"
3577msgstr "" 2896msgstr ""
3578 2897
3579#: plugins/check_pgsql.c:532 2898msgid "A name for the query, this string is used instead of the query"
2899msgstr ""
2900
2901msgid "in the long output of the plugin"
2902msgstr ""
2903
3580#, fuzzy 2904#, fuzzy
3581msgid "SQL query value to result in warning status (double)" 2905msgid "SQL query value to result in warning status (double)"
3582msgstr "Décalage résultant en un avertissement (secondes)" 2906msgstr "Décalage résultant en un avertissement (secondes)"
3583 2907
3584#: plugins/check_pgsql.c:534
3585#, fuzzy 2908#, fuzzy
3586msgid "SQL query value to result in critical status (double)" 2909msgid "SQL query value to result in critical status (double)"
3587msgstr "Décalage résultant en un état critique (secondes)" 2910msgstr "Décalage résultant en un état critique (secondes)"
3588 2911
3589#: plugins/check_pgsql.c:539
3590msgid "All parameters are optional." 2912msgid "All parameters are optional."
3591msgstr "" 2913msgstr ""
3592 2914
3593#: plugins/check_pgsql.c:540
3594msgid "" 2915msgid ""
3595"This plugin tests a PostgreSQL DBMS to determine whether it is active and" 2916"This plugin tests a PostgreSQL DBMS to determine whether it is active and"
3596msgstr "" 2917msgstr ""
3597 2918
3598#: plugins/check_pgsql.c:541
3599msgid "accepting queries. In its current operation, it simply connects to the" 2919msgid "accepting queries. In its current operation, it simply connects to the"
3600msgstr "" 2920msgstr ""
3601 2921
3602#: plugins/check_pgsql.c:542
3603msgid "" 2922msgid ""
3604"specified database, and then disconnects. If no database is specified, it" 2923"specified database, and then disconnects. If no database is specified, it"
3605msgstr "" 2924msgstr ""
3606 2925
3607#: plugins/check_pgsql.c:543
3608msgid "" 2926msgid ""
3609"connects to the template1 database, which is present in every functioning" 2927"connects to the template1 database, which is present in every functioning"
3610msgstr "" 2928msgstr ""
3611 2929
3612#: plugins/check_pgsql.c:544
3613msgid "PostgreSQL DBMS." 2930msgid "PostgreSQL DBMS."
3614msgstr "" 2931msgstr ""
3615 2932
3616#: plugins/check_pgsql.c:546
3617msgid "If a query is specified using the -q option, it will be executed after" 2933msgid "If a query is specified using the -q option, it will be executed after"
3618msgstr "" 2934msgstr ""
3619 2935
3620#: plugins/check_pgsql.c:547
3621msgid "connecting to the server. The result from the query has to be numeric." 2936msgid "connecting to the server. The result from the query has to be numeric."
3622msgstr "" 2937msgstr ""
3623 2938
3624#: plugins/check_pgsql.c:548
3625msgid "" 2939msgid ""
3626"Multiple SQL commands, separated by semicolon, are allowed but the result " 2940"Multiple SQL commands, separated by semicolon, are allowed but the result "
3627msgstr "" 2941msgstr ""
3628 2942
3629#: plugins/check_pgsql.c:549
3630msgid "of the last command is taken into account only. The value of the first" 2943msgid "of the last command is taken into account only. The value of the first"
3631msgstr "" 2944msgstr ""
3632 2945
3633#: plugins/check_pgsql.c:550 2946msgid ""
3634msgid "column in the first row is used as the check result." 2947"column in the first row is used as the check result. If a second column is"
2948msgstr ""
2949
2950msgid "present in the result set, this is added to the plugin output with a"
2951msgstr ""
2952
2953msgid ""
2954"prefix of \"Extra Info:\". This information can be displayed in the system"
2955msgstr ""
2956
2957msgid "executing the plugin."
3635msgstr "" 2958msgstr ""
3636 2959
3637#: plugins/check_pgsql.c:552
3638msgid "" 2960msgid ""
3639"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual" 2961"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"
3640msgstr "" 2962msgstr ""
3641 2963
3642#: plugins/check_pgsql.c:553
3643msgid "" 2964msgid ""
3644"for details about how to access internal statistics of the database server." 2965"for details about how to access internal statistics of the database server."
3645msgstr "" 2966msgstr ""
3646 2967
3647#: plugins/check_pgsql.c:555
3648msgid "" 2968msgid ""
3649"For a list of available connection parameters which may be used with the -o" 2969"For a list of available connection parameters which may be used with the -o"
3650msgstr "" 2970msgstr ""
3651 2971
3652#: plugins/check_pgsql.c:556
3653msgid "" 2972msgid ""
3654"command line option, see the documentation for PQconnectdb() in the chapter" 2973"command line option, see the documentation for PQconnectdb() in the chapter"
3655msgstr "" 2974msgstr ""
3656 2975
3657#: plugins/check_pgsql.c:557
3658msgid "" 2976msgid ""
3659"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be" 2977"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"
3660msgstr "" 2978msgstr ""
3661 2979
3662#: plugins/check_pgsql.c:558
3663msgid "" 2980msgid ""
3664"used to specify a service name in pg_service.conf to be used for additional" 2981"used to specify a service name in pg_service.conf to be used for additional"
3665msgstr "" 2982msgstr ""
3666 2983
3667#: plugins/check_pgsql.c:559
3668msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:" 2984msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:"
3669msgstr "" 2985msgstr ""
3670 2986
3671#: plugins/check_pgsql.c:560
3672msgid "-o 'sslmode=require'." 2987msgid "-o 'sslmode=require'."
3673msgstr "" 2988msgstr ""
3674 2989
3675#: plugins/check_pgsql.c:562
3676msgid "" 2990msgid ""
3677"The plugin will connect to a local postmaster if no host is specified. To" 2991"The plugin will connect to a local postmaster if no host is specified. To"
3678msgstr "" 2992msgstr ""
3679"Ce plugin va se connecter sur un postmaster local si aucun hôte n'est " 2993"Ce plugin va se connecter sur un postmaster local si aucun hôte n'est "
3680"spécifié." 2994"spécifié."
3681 2995
3682#: plugins/check_pgsql.c:563
3683msgid "" 2996msgid ""
3684"connect to a remote host, be sure that the remote postmaster accepts TCP/IP" 2997"connect to a remote host, be sure that the remote postmaster accepts TCP/IP"
3685msgstr "" 2998msgstr ""
3686 2999
3687#: plugins/check_pgsql.c:564
3688msgid "connections (start the postmaster with the -i option)." 3000msgid "connections (start the postmaster with the -i option)."
3689msgstr "" 3001msgstr ""
3690 3002
3691#: plugins/check_pgsql.c:566
3692msgid "" 3003msgid ""
3693"Typically, the monitoring user (unless the --logname option is used) should " 3004"Typically, the monitoring user (unless the --logname option is used) should "
3694"be" 3005"be"
3695msgstr "" 3006msgstr ""
3696 3007
3697#: plugins/check_pgsql.c:567
3698msgid "" 3008msgid ""
3699"able to connect to the database without a password. The plugin can also send" 3009"able to connect to the database without a password. The plugin can also send"
3700msgstr "" 3010msgstr ""
3701 3011
3702#: plugins/check_pgsql.c:568
3703msgid "a password, but no effort is made to obscure or encrypt the password." 3012msgid "a password, but no effort is made to obscure or encrypt the password."
3704msgstr "" 3013msgstr ""
3705 3014
3706#: plugins/check_pgsql.c:601
3707#, c-format 3015#, c-format
3708msgid "QUERY %s - %s: %s.\n" 3016msgid "QUERY %s - %s: %s.\n"
3709msgstr "" 3017msgstr ""
3710 3018
3711#: plugins/check_pgsql.c:601
3712msgid "Error with query" 3019msgid "Error with query"
3713msgstr "" 3020msgstr ""
3714 3021
3715#: plugins/check_pgsql.c:607
3716#, fuzzy 3022#, fuzzy
3717msgid "No rows returned" 3023msgid "No rows returned"
3718msgstr "Pas de données valides reçues" 3024msgstr "Pas de données valides reçues"
3719 3025
3720#: plugins/check_pgsql.c:612
3721#, fuzzy 3026#, fuzzy
3722msgid "No columns returned" 3027msgid "No columns returned"
3723msgstr "Pas de données valides reçues" 3028msgstr "Pas de données valides reçues"
3724 3029
3725#: plugins/check_pgsql.c:618
3726#, fuzzy 3030#, fuzzy
3727msgid "No data returned" 3031msgid "No data returned"
3728msgstr "Pas de données valides reçues" 3032msgstr "Pas de données valides reçues"
3729 3033
3730#: plugins/check_pgsql.c:627
3731msgid "Is not a numeric" 3034msgid "Is not a numeric"
3732msgstr "" 3035msgstr ""
3733 3036
3734#: plugins/check_pgsql.c:644 3037#, fuzzy, c-format
3038msgid "%s returned %f"
3039msgstr ". %s renvoie %s"
3040
3735#, fuzzy, c-format 3041#, fuzzy, c-format
3736msgid "'%s' returned %f" 3042msgid "'%s' returned %f"
3737msgstr ". %s renvoie %s" 3043msgstr ". %s renvoie %s"
3738 3044
3739#: plugins/check_ping.c:141
3740msgid "CRITICAL - Could not interpret output from ping command\n" 3045msgid "CRITICAL - Could not interpret output from ping command\n"
3741msgstr "CRITIQUE - Impossible d'interpréter le réponse de la commande ping\n" 3046msgstr "CRITIQUE - Impossible d'interpréter le réponse de la commande ping\n"
3742 3047
3743#: plugins/check_ping.c:157
3744#, c-format 3048#, c-format
3745msgid "PING %s - %sPacket loss = %d%%" 3049msgid "PING %s - %sPacket loss = %d%%"
3746msgstr "PING %s - %s Paquets perdus = %d%%" 3050msgstr "PING %s - %s Paquets perdus = %d%%"
3747 3051
3748#: plugins/check_ping.c:160
3749#, c-format 3052#, c-format
3750msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms" 3053msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"
3751msgstr "PING %s - %s Paquets perdus = %d%%, RTA = %2.2f ms" 3054msgstr "PING %s - %s Paquets perdus = %d%%, RTA = %2.2f ms"
3752 3055
3753#: plugins/check_ping.c:257
3754msgid "Could not realloc() addresses\n" 3056msgid "Could not realloc() addresses\n"
3755msgstr "Impossible de réallouer les adresses\n" 3057msgstr "Impossible de réallouer les adresses\n"
3756 3058
3757#: plugins/check_ping.c:272 plugins/check_ping.c:352
3758#, c-format 3059#, c-format
3759msgid "<max_packets> (%s) must be a non-negative number\n" 3060msgid "<max_packets> (%s) must be a non-negative number\n"
3760msgstr "<max_packets> (%s) doit être un nombre positif\n" 3061msgstr "<max_packets> (%s) doit être un nombre positif\n"
3761 3062
3762#: plugins/check_ping.c:306
3763#, c-format 3063#, c-format
3764msgid "<wpl> (%s) must be an integer percentage\n" 3064msgid "<wpl> (%s) must be an integer percentage\n"
3765msgstr "<wpl> (%s) doit être un pourcentage entier\n" 3065msgstr "<wpl> (%s) doit être un pourcentage entier\n"
3766 3066
3767#: plugins/check_ping.c:317
3768#, c-format 3067#, c-format
3769msgid "<cpl> (%s) must be an integer percentage\n" 3068msgid "<cpl> (%s) must be an integer percentage\n"
3770msgstr "<cpl> (%s) doit être un pourcentage entier\n" 3069msgstr "<cpl> (%s) doit être un pourcentage entier\n"
3771 3070
3772#: plugins/check_ping.c:328
3773#, c-format 3071#, c-format
3774msgid "<wrta> (%s) must be a non-negative number\n" 3072msgid "<wrta> (%s) must be a non-negative number\n"
3775msgstr "<wrta> (%s) doit être un nombre positif\n" 3073msgstr "<wrta> (%s) doit être un nombre positif\n"
3776 3074
3777#: plugins/check_ping.c:339
3778#, c-format 3075#, c-format
3779msgid "<crta> (%s) must be a non-negative number\n" 3076msgid "<crta> (%s) must be a non-negative number\n"
3780msgstr "<crta> (%s) doit être un nombre positif\n" 3077msgstr "<crta> (%s) doit être un nombre positif\n"
3781 3078
3782#: plugins/check_ping.c:372
3783#, c-format 3079#, c-format
3784msgid "" 3080msgid ""
3785"%s: Warning threshold must be integer or percentage!\n" 3081"%s: Warning threshold must be integer or percentage!\n"
3786"\n" 3082"\n"
3787msgstr "%s: Le seuil d'avertissement doit être un entier ou un pourcentage!\n" 3083msgstr "%s: Le seuil d'avertissement doit être un entier ou un pourcentage!\n"
3788 3084
3789#: plugins/check_ping.c:385
3790#, c-format 3085#, c-format
3791msgid "<wrta> was not set\n" 3086msgid "<wrta> was not set\n"
3792msgstr "<wrta> n'a pas été indiqué\n" 3087msgstr "<wrta> n'a pas été indiqué\n"
3793 3088
3794#: plugins/check_ping.c:389
3795#, c-format 3089#, c-format
3796msgid "<crta> was not set\n" 3090msgid "<crta> was not set\n"
3797msgstr "<crta> n'a pas été indiqué\n" 3091msgstr "<crta> n'a pas été indiqué\n"
3798 3092
3799#: plugins/check_ping.c:393
3800#, c-format 3093#, c-format
3801msgid "<wpl> was not set\n" 3094msgid "<wpl> was not set\n"
3802msgstr " <wpl> n'a pas été indiqué\n" 3095msgstr " <wpl> n'a pas été indiqué\n"
3803 3096
3804#: plugins/check_ping.c:397
3805#, c-format 3097#, c-format
3806msgid "<cpl> was not set\n" 3098msgid "<cpl> was not set\n"
3807msgstr "<cpl> n'a pas été indiqué\n" 3099msgstr "<cpl> n'a pas été indiqué\n"
3808 3100
3809#: plugins/check_ping.c:401
3810#, c-format 3101#, c-format
3811msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n" 3102msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n"
3812msgstr "<wrta> (%f) ne peut pas être plus large que <crta> (%f)\n" 3103msgstr "<wrta> (%f) ne peut pas être plus large que <crta> (%f)\n"
3813 3104
3814#: plugins/check_ping.c:405
3815#, c-format 3105#, c-format
3816msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n" 3106msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n"
3817msgstr "<wpl> (%d) ne peut pas être plus large que <cpl> (%d)\n" 3107msgstr "<wpl> (%d) ne peut pas être plus large que <cpl> (%d)\n"
3818 3108
3819#: plugins/check_ping.c:442
3820#, c-format 3109#, c-format
3821msgid "Cannot open stderr for %s\n" 3110msgid "Cannot open stderr for %s\n"
3822msgstr "Impossible d'ouvrir le canal d'erreur standard pour %s\n" 3111msgstr "Impossible d'ouvrir le canal d'erreur standard pour %s\n"
3823 3112
3824#: plugins/check_ping.c:492 plugins/check_ping.c:494
3825msgid "System call sent warnings to stderr " 3113msgid "System call sent warnings to stderr "
3826msgstr "" 3114msgstr ""
3827"Les appel système enverront leurs messages d'avertissement vers le canal " 3115"Les appel système enverront leurs messages d'avertissement vers le canal "
3828"d'erreur standard" 3116"d'erreur standard"
3829 3117
3830#: plugins/check_ping.c:519
3831#, fuzzy, c-format 3118#, fuzzy, c-format
3832msgid "CRITICAL - Network Unreachable (%s)\n" 3119msgid "CRITICAL - Network Unreachable (%s)\n"
3833msgstr "CRITIQUE - Le réseau est inaccessible (%s)" 3120msgstr "CRITIQUE - Le réseau est inaccessible (%s)"
3834 3121
3835#: plugins/check_ping.c:521
3836#, fuzzy, c-format 3122#, fuzzy, c-format
3837msgid "CRITICAL - Host Unreachable (%s)\n" 3123msgid "CRITICAL - Host Unreachable (%s)\n"
3838msgstr "CRITIQUE - Hôte inaccessible (%s)" 3124msgstr "CRITIQUE - Hôte inaccessible (%s)"
3839 3125
3840#: plugins/check_ping.c:523
3841#, fuzzy, c-format 3126#, fuzzy, c-format
3842msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n" 3127msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"
3843msgstr "CRITIQUE - Paquet ICMP incorrect: Port inaccessible (%s)" 3128msgstr "CRITIQUE - Paquet ICMP incorrect: Port inaccessible (%s)"
3844 3129
3845#: plugins/check_ping.c:525
3846#, fuzzy, c-format 3130#, fuzzy, c-format
3847msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n" 3131msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"
3848msgstr "CRITIQUE - Paquet ICMP incorrect: Protocole inaccessible (%s)" 3132msgstr "CRITIQUE - Paquet ICMP incorrect: Protocole inaccessible (%s)"
3849 3133
3850#: plugins/check_ping.c:527
3851#, fuzzy, c-format 3134#, fuzzy, c-format
3852msgid "CRITICAL - Network Prohibited (%s)\n" 3135msgid "CRITICAL - Network Prohibited (%s)\n"
3853msgstr "CRITIQUE - L'accès au réseau est interdit (%s)" 3136msgstr "CRITIQUE - L'accès au réseau est interdit (%s)"
3854 3137
3855#: plugins/check_ping.c:529
3856#, fuzzy, c-format 3138#, fuzzy, c-format
3857msgid "CRITICAL - Host Prohibited (%s)\n" 3139msgid "CRITICAL - Host Prohibited (%s)\n"
3858msgstr "CRITIQUE - L'accès a l'hôte est interdit (%s)" 3140msgstr "CRITIQUE - L'accès a l'hôte est interdit (%s)"
3859 3141
3860#: plugins/check_ping.c:531
3861#, fuzzy, c-format 3142#, fuzzy, c-format
3862msgid "CRITICAL - Packet Filtered (%s)\n" 3143msgid "CRITICAL - Packet Filtered (%s)\n"
3863msgstr "CRITIQUE - Paquet filtré (%s)" 3144msgstr "CRITIQUE - Paquet filtré (%s)"
3864 3145
3865#: plugins/check_ping.c:533
3866#, fuzzy, c-format 3146#, fuzzy, c-format
3867msgid "CRITICAL - Host not found (%s)\n" 3147msgid "CRITICAL - Host not found (%s)\n"
3868msgstr "CRITIQUE - Hôte non trouvé (%s)" 3148msgstr "CRITIQUE - Hôte non trouvé (%s)"
3869 3149
3870#: plugins/check_ping.c:535
3871#, fuzzy, c-format 3150#, fuzzy, c-format
3872msgid "CRITICAL - Time to live exceeded (%s)\n" 3151msgid "CRITICAL - Time to live exceeded (%s)\n"
3873msgstr "CRITIQUE - La durée de vie du paquet est dépassée (%s)" 3152msgstr "CRITIQUE - La durée de vie du paquet est dépassée (%s)"
3874 3153
3875#: plugins/check_ping.c:537
3876#, fuzzy, c-format 3154#, fuzzy, c-format
3877msgid "CRITICAL - Destination Unreachable (%s)\n" 3155msgid "CRITICAL - Destination Unreachable (%s)\n"
3878msgstr "CRITIQUE - Hôte inaccessible (%s)" 3156msgstr "CRITIQUE - Hôte inaccessible (%s)"
3879 3157
3880#: plugins/check_ping.c:544
3881#, fuzzy 3158#, fuzzy
3882msgid "Unable to realloc warn_text\n" 3159msgid "Unable to realloc warn_text\n"
3883msgstr "Impossible de réattribuer le texte d'avertissement" 3160msgstr "Impossible de réattribuer le texte d'avertissement"
3884 3161
3885#: plugins/check_ping.c:561
3886#, c-format 3162#, c-format
3887msgid "Use ping to check connection statistics for a remote host." 3163msgid "Use ping to check connection statistics for a remote host."
3888msgstr "" 3164msgstr ""
3889"Utilise ping pour vérifier les statistiques de connections d'un hôte distant." 3165"Utilise ping pour vérifier les statistiques de connections d'un hôte distant."
3890 3166
3891#: plugins/check_ping.c:573
3892msgid "host to ping" 3167msgid "host to ping"
3893msgstr "hôte à tester" 3168msgstr "hôte à tester"
3894 3169
3895#: plugins/check_ping.c:579
3896msgid "number of ICMP ECHO packets to send" 3170msgid "number of ICMP ECHO packets to send"
3897msgstr "nombre de paquets ICMP à envoyer" 3171msgstr "nombre de paquets ICMP à envoyer"
3898 3172
3899#: plugins/check_ping.c:580
3900#, c-format 3173#, c-format
3901msgid "(Default: %d)\n" 3174msgid "(Default: %d)\n"
3902msgstr "(Défaut: %d)\n" 3175msgstr "(Défaut: %d)\n"
3903 3176
3904#: plugins/check_ping.c:582
3905msgid "show HTML in the plugin output (obsoleted by urlize)" 3177msgid "show HTML in the plugin output (obsoleted by urlize)"
3906msgstr "" 3178msgstr ""
3907 3179
3908#: plugins/check_ping.c:587
3909msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel" 3180msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"
3910msgstr "" 3181msgstr ""
3911"Le seuil est <rta>,<pl>% où <rta> est le temps moyen pour l'aller retour (ms)" 3182"Le seuil est <rta>,<pl>% où <rta> est le temps moyen pour l'aller retour (ms)"
3912 3183
3913#: plugins/check_ping.c:588
3914msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the" 3184msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"
3915msgstr "qui déclenche un résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le " 3185msgstr "qui déclenche un résultat AVERTISSEMENT ou CRITIQUE, et <pl> est le "
3916 3186
3917#: plugins/check_ping.c:589
3918msgid "percentage of packet loss to trigger an alarm state." 3187msgid "percentage of packet loss to trigger an alarm state."
3919msgstr "pourcentage de paquets perdus pour déclencher une alarme." 3188msgstr "pourcentage de paquets perdus pour déclencher une alarme."
3920 3189
3921#: plugins/check_ping.c:592
3922msgid "" 3190msgid ""
3923"This plugin uses the ping command to probe the specified host for packet loss" 3191"This plugin uses the ping command to probe the specified host for packet loss"
3924msgstr "" 3192msgstr ""
3925"Ce plugin utilise la commande ping pour vérifier l'hôte spécifié pour les " 3193"Ce plugin utilise la commande ping pour vérifier l'hôte spécifié pour les "
3926"pertes de paquets" 3194"pertes de paquets"
3927 3195
3928#: plugins/check_ping.c:593
3929msgid "" 3196msgid ""
3930"(percentage) and round trip average (milliseconds). It can produce HTML " 3197"(percentage) and round trip average (milliseconds). It can produce HTML "
3931"output" 3198"output"
3932msgstr "" 3199msgstr ""
3933 3200
3934#: plugins/check_ping.c:594
3935msgid "" 3201msgid ""
3936"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in" 3202"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"
3937msgstr "" 3203msgstr ""
3938 3204
3939#: plugins/check_ping.c:595
3940msgid "the contrib area of the downloads section at http://www.nagios.org/" 3205msgid "the contrib area of the downloads section at http://www.nagios.org/"
3941msgstr "" 3206msgstr ""
3942 3207
3943#: plugins/check_procs.c:193
3944#, c-format 3208#, c-format
3945msgid "CMD: %s\n" 3209msgid "CMD: %s\n"
3946msgstr "Commande: %s\n" 3210msgstr "Commande: %s\n"
3947 3211
3948#: plugins/check_procs.c:198
3949msgid "System call sent warnings to stderr" 3212msgid "System call sent warnings to stderr"
3950msgstr "" 3213msgstr ""
3951"L'appel système à retourné des avertissement vers le canal d'erreur standard" 3214"L'appel système à retourné des avertissement vers le canal d'erreur standard"
3952 3215
3953#: plugins/check_procs.c:326
3954#, c-format 3216#, c-format
3955msgid "Not parseable: %s" 3217msgid "Not parseable: %s"
3956msgstr "Impossible de parcourir les arguments: %s" 3218msgstr "Impossible de parcourir les arguments: %s"
3957 3219
3958#: plugins/check_procs.c:331
3959#, c-format 3220#, c-format
3960msgid "Unable to read output\n" 3221msgid "Unable to read output\n"
3961msgstr "Impossible de lire les données en entrée\n" 3222msgstr "Impossible de lire les données en entrée\n"
3962 3223
3963#: plugins/check_procs.c:348
3964#, c-format 3224#, c-format
3965msgid "%d warn out of " 3225msgid "%d warn out of "
3966msgstr "%d avertissements sur" 3226msgstr "%d avertissements sur"
3967 3227
3968#: plugins/check_procs.c:353
3969#, c-format 3228#, c-format
3970msgid "%d crit, %d warn out of " 3229msgid "%d crit, %d warn out of "
3971msgstr "%d crit, %d alertes sur " 3230msgstr "%d crit, %d alertes sur "
3972 3231
3973#: plugins/check_procs.c:359
3974#, c-format 3232#, c-format
3975msgid " with %s" 3233msgid " with %s"
3976msgstr " avec %s" 3234msgstr " avec %s"
3977 3235
3978#: plugins/check_procs.c:453
3979msgid "Parent Process ID must be an integer!" 3236msgid "Parent Process ID must be an integer!"
3980msgstr "L'identifiant du processus parent doit être un entier!" 3237msgstr "L'identifiant du processus parent doit être un entier!"
3981 3238
3982#: plugins/check_procs.c:459 plugins/check_procs.c:586
3983#, c-format 3239#, c-format
3984msgid "%s%sSTATE = %s" 3240msgid "%s%sSTATE = %s"
3985msgstr "%s%sETAT = %s" 3241msgstr "%s%sETAT = %s"
3986 3242
3987#: plugins/check_procs.c:468
3988msgid "UID was not found" 3243msgid "UID was not found"
3989msgstr "L'UID n'a pas été trouvé" 3244msgstr "L'UID n'a pas été trouvé"
3990 3245
3991#: plugins/check_procs.c:474
3992msgid "User name was not found" 3246msgid "User name was not found"
3993msgstr "L'utilisateur n'a pas été trouvé" 3247msgstr "L'utilisateur n'a pas été trouvé"
3994 3248
3995#: plugins/check_procs.c:489
3996#, c-format 3249#, c-format
3997msgid "%s%scommand name '%s'" 3250msgid "%s%scommand name '%s'"
3998msgstr "%s%snom de la commande '%s'" 3251msgstr "%s%snom de la commande '%s'"
3999 3252
4000#: plugins/check_procs.c:524 3253#, c-format
3254msgid "%s%sexclude progs '%s'"
3255msgstr ""
3256
4001msgid "RSS must be an integer!" 3257msgid "RSS must be an integer!"
4002msgstr "RSS doit être un entier!" 3258msgstr "RSS doit être un entier!"
4003 3259
4004#: plugins/check_procs.c:531
4005msgid "VSZ must be an integer!" 3260msgid "VSZ must be an integer!"
4006msgstr "VSZ doit être un entier!" 3261msgstr "VSZ doit être un entier!"
4007 3262
4008#: plugins/check_procs.c:539
4009msgid "PCPU must be a float!" 3263msgid "PCPU must be a float!"
4010msgstr "PCPU doit être un nombre en virgule flottante!" 3264msgstr "PCPU doit être un nombre en virgule flottante!"
4011 3265
4012#: plugins/check_procs.c:563
4013msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!" 3266msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"
4014msgstr "Metric doit être l'un des PROCS, VSZ, RSS, CPU, ELAPSED!" 3267msgstr "Metric doit être l'un des PROCS, VSZ, RSS, CPU, ELAPSED!"
4015 3268
4016#: plugins/check_procs.c:694
4017msgid "" 3269msgid ""
4018"Checks all processes and generates WARNING or CRITICAL states if the " 3270"Checks all processes and generates WARNING or CRITICAL states if the "
4019"specified" 3271"specified"
4020msgstr "" 3272msgstr ""
4021 3273
4022#: plugins/check_procs.c:695
4023msgid "" 3274msgid ""
4024"metric is outside the required threshold ranges. The metric defaults to " 3275"metric is outside the required threshold ranges. The metric defaults to "
4025"number" 3276"number"
4026msgstr "" 3277msgstr ""
4027 3278
4028#: plugins/check_procs.c:696
4029msgid "" 3279msgid ""
4030"of processes. Search filters can be applied to limit the processes to check." 3280"of processes. Search filters can be applied to limit the processes to check."
4031msgstr "" 3281msgstr ""
4032 3282
4033#: plugins/check_procs.c:705
4034msgid "Generate warning state if metric is outside this range" 3283msgid "Generate warning state if metric is outside this range"
4035msgstr "" 3284msgstr ""
4036 3285
4037#: plugins/check_procs.c:707
4038msgid "Generate critical state if metric is outside this range" 3286msgid "Generate critical state if metric is outside this range"
4039msgstr "" 3287msgstr ""
4040 3288
4041#: plugins/check_procs.c:709
4042msgid "Check thresholds against metric. Valid types:" 3289msgid "Check thresholds against metric. Valid types:"
4043msgstr "" 3290msgstr ""
4044 3291
4045#: plugins/check_procs.c:710
4046msgid "PROCS - number of processes (default)" 3292msgid "PROCS - number of processes (default)"
4047msgstr "PROCS - nombre de processus (défaut)" 3293msgstr "PROCS - nombre de processus (défaut)"
4048 3294
4049#: plugins/check_procs.c:711
4050msgid "VSZ - virtual memory size" 3295msgid "VSZ - virtual memory size"
4051msgstr "VSZ - taille mémoire virtuelle" 3296msgstr "VSZ - taille mémoire virtuelle"
4052 3297
4053#: plugins/check_procs.c:712
4054msgid "RSS - resident set memory size" 3298msgid "RSS - resident set memory size"
4055msgstr "" 3299msgstr ""
4056 3300
4057#: plugins/check_procs.c:713
4058msgid "CPU - percentage CPU" 3301msgid "CPU - percentage CPU"
4059msgstr "CPU - pourcentage du processeur" 3302msgstr "CPU - pourcentage du processeur"
4060 3303
4061#: plugins/check_procs.c:716
4062msgid "ELAPSED - time elapsed in seconds" 3304msgid "ELAPSED - time elapsed in seconds"
4063msgstr "ELAPSED - temps écoulé en secondes" 3305msgstr "ELAPSED - temps écoulé en secondes"
4064 3306
4065#: plugins/check_procs.c:721
4066msgid "Extra information. Up to 3 verbosity levels" 3307msgid "Extra information. Up to 3 verbosity levels"
4067msgstr "informations supplémentaires. Jusqu'à 3 niveaux de verbosité" 3308msgstr "informations supplémentaires. Jusqu'à 3 niveaux de verbosité"
4068 3309
4069#: plugins/check_procs.c:724
4070msgid "Filter own process the traditional way by PID instead of /proc/pid/exe" 3310msgid "Filter own process the traditional way by PID instead of /proc/pid/exe"
4071msgstr "" 3311msgstr ""
4072 3312
4073#: plugins/check_procs.c:729
4074msgid "Only scan for processes that have, in the output of `ps`, one or" 3313msgid "Only scan for processes that have, in the output of `ps`, one or"
4075msgstr "" 3314msgstr ""
4076 3315
4077#: plugins/check_procs.c:730
4078msgid "more of the status flags you specify (for example R, Z, S, RS," 3316msgid "more of the status flags you specify (for example R, Z, S, RS,"
4079msgstr "" 3317msgstr ""
4080 3318
4081#: plugins/check_procs.c:731
4082msgid "RSZDT, plus others based on the output of your 'ps' command)." 3319msgid "RSZDT, plus others based on the output of your 'ps' command)."
4083msgstr "" 3320msgstr ""
4084 3321
4085#: plugins/check_procs.c:733
4086msgid "Only scan for children of the parent process ID indicated." 3322msgid "Only scan for children of the parent process ID indicated."
4087msgstr "" 3323msgstr ""
4088 3324
4089#: plugins/check_procs.c:735
4090msgid "Only scan for processes with VSZ higher than indicated." 3325msgid "Only scan for processes with VSZ higher than indicated."
4091msgstr "" 3326msgstr ""
4092 3327
4093#: plugins/check_procs.c:737
4094msgid "Only scan for processes with RSS higher than indicated." 3328msgid "Only scan for processes with RSS higher than indicated."
4095msgstr "" 3329msgstr ""
4096 3330
4097#: plugins/check_procs.c:739
4098msgid "Only scan for processes with PCPU higher than indicated." 3331msgid "Only scan for processes with PCPU higher than indicated."
4099msgstr "" 3332msgstr ""
4100 3333
4101#: plugins/check_procs.c:741
4102msgid "Only scan for processes with user name or ID indicated." 3334msgid "Only scan for processes with user name or ID indicated."
4103msgstr "" 3335msgstr ""
4104 3336
4105#: plugins/check_procs.c:743
4106msgid "Only scan for processes with args that contain STRING." 3337msgid "Only scan for processes with args that contain STRING."
4107msgstr "" 3338msgstr ""
4108 3339
4109#: plugins/check_procs.c:745
4110msgid "Only scan for processes with args that contain the regex STRING." 3340msgid "Only scan for processes with args that contain the regex STRING."
4111msgstr "" 3341msgstr ""
4112 3342
4113#: plugins/check_procs.c:747
4114msgid "Only scan for exact matches of COMMAND (without path)." 3343msgid "Only scan for exact matches of COMMAND (without path)."
4115msgstr "" 3344msgstr ""
4116 3345
4117#: plugins/check_procs.c:749 3346msgid "Exclude processes which match this comma separated list"
3347msgstr ""
3348
4118msgid "Only scan for non kernel threads (works on Linux only)." 3349msgid "Only scan for non kernel threads (works on Linux only)."
4119msgstr "" 3350msgstr ""
4120 3351
4121#: plugins/check_procs.c:751
4122#, c-format 3352#, c-format
4123msgid "" 3353msgid ""
4124"\n" 3354"\n"
@@ -4133,7 +3363,6 @@ msgstr ""
4133"est à l'intérieur du seuil\n" 3363"est à l'intérieur du seuil\n"
4134"\n" 3364"\n"
4135 3365
4136#: plugins/check_procs.c:756
4137#, c-format 3366#, c-format
4138msgid "" 3367msgid ""
4139"This plugin checks the number of currently running processes and\n" 3368"This plugin checks the number of currently running processes and\n"
@@ -4150,932 +3379,840 @@ msgstr ""
4150"état actuel (ex: 'Z'), ou par le nombre de processus en cours d'exécution\n" 3379"état actuel (ex: 'Z'), ou par le nombre de processus en cours d'exécution\n"
4151"\n" 3380"\n"
4152 3381
4153#: plugins/check_procs.c:765
4154msgid "Warning if not two processes with command name portsentry." 3382msgid "Warning if not two processes with command name portsentry."
4155msgstr "" 3383msgstr ""
4156 3384
4157#: plugins/check_procs.c:766
4158msgid "Critical if < 2 or > 1024 processes" 3385msgid "Critical if < 2 or > 1024 processes"
4159msgstr "" 3386msgstr ""
4160 3387
4161#: plugins/check_procs.c:768 3388msgid "Critical if not at least 1 process with command sshd"
3389msgstr ""
3390
3391msgid "Warning if > 1024 processes with command name sshd."
3392msgstr ""
3393
3394msgid "Critical if < 1 processes with command name sshd."
3395msgstr ""
3396
4162msgid "Warning alert if > 10 processes with command arguments containing" 3397msgid "Warning alert if > 10 processes with command arguments containing"
4163msgstr "" 3398msgstr ""
4164 3399
4165#: plugins/check_procs.c:769
4166msgid "'/usr/local/bin/perl' and owned by root" 3400msgid "'/usr/local/bin/perl' and owned by root"
4167msgstr "" 3401msgstr ""
4168 3402
4169#: plugins/check_procs.c:771
4170msgid "Alert if VSZ of any processes over 50K or 100K" 3403msgid "Alert if VSZ of any processes over 50K or 100K"
4171msgstr "" 3404msgstr ""
4172 3405
4173#: plugins/check_procs.c:773 3406msgid "Alert if CPU of any processes over 10% or 20%"
4174#, c-format
4175msgid "Alert if CPU of any processes over 10%% or 20%%"
4176msgstr "" 3407msgstr ""
4177 3408
4178#: plugins/check_radius.c:165 3409#, fuzzy
4179msgid "Config file error" 3410msgid "Config file error\n"
4180msgstr "Erreur dans le fichier de configuration" 3411msgstr "Erreur dans le fichier de configuration"
4181 3412
4182#: plugins/check_radius.c:174 3413#, fuzzy
4183msgid "Out of Memory?" 3414msgid "Out of Memory?\n"
4184msgstr "Manque de Mémoire?" 3415msgstr "Manque de Mémoire?"
4185 3416
4186#: plugins/check_radius.c:178 3417#, fuzzy
4187msgid "Invalid NAS-Identifier" 3418msgid "Invalid NAS-Identifier\n"
4188msgstr "NAS-Identifier invalide" 3419msgstr "NAS-Identifier invalide"
4189 3420
4190#: plugins/check_radius.c:183 plugins/check_radius.c:185 3421#, c-format
4191#: plugins/check_radius.c:191 3422msgid "gethostname() failed!\n"
4192msgid "Invalid NAS-IP-Address" 3423msgstr "La commande gethostname() à échoué\n"
4193msgstr "NAS-IP-Address invalide"
4194 3424
4195#: plugins/check_radius.c:188 3425#, fuzzy
4196msgid "Can't find local IP for NAS-IP-Address" 3426msgid "Invalid NAS-IP-Address\n"
4197msgstr "Impossible de trouver une addresse IP locale pour le NAS-IP-Address" 3427msgstr "NAS-IP-Address invalide"
4198 3428
4199#: plugins/check_radius.c:202 3429#, fuzzy
4200msgid "Timeout" 3430msgid "Timeout\n"
4201msgstr "Temps dépassé" 3431msgstr "Temps dépassé"
4202 3432
4203#: plugins/check_radius.c:204 3433#, fuzzy
4204msgid "Auth Error" 3434msgid "Auth Error\n"
4205msgstr "Erreur d'authentification" 3435msgstr "Erreur d'authentification"
4206 3436
4207#: plugins/check_radius.c:206 3437#, fuzzy
4208msgid "Auth Failed" 3438msgid "Auth Failed\n"
4209msgstr "L'authentification à échoué" 3439msgstr "L'authentification à échoué"
4210 3440
4211#: plugins/check_radius.c:208 3441#, fuzzy
4212msgid "Bad Response" 3442msgid "Bad Response\n"
4213msgstr "Réponse invalide" 3443msgstr "Réponse invalide"
4214 3444
4215#: plugins/check_radius.c:212 3445#, fuzzy
4216msgid "Auth OK" 3446msgid "Auth OK\n"
4217msgstr "L'authentification à réussi" 3447msgstr "L'authentification à réussi"
4218 3448
4219#: plugins/check_radius.c:213
4220#, c-format 3449#, c-format
4221msgid "Unexpected result code %d" 3450msgid "Unexpected result code %d"
4222msgstr "Résultat inattendu: %d" 3451msgstr "Résultat inattendu: %d"
4223 3452
4224#: plugins/check_radius.c:302
4225msgid "Number of retries must be a positive integer" 3453msgid "Number of retries must be a positive integer"
4226msgstr "Le nombre d'essai doit être un entier positif" 3454msgstr "Le nombre d'essai doit être un entier positif"
4227 3455
4228#: plugins/check_radius.c:316
4229msgid "User not specified" 3456msgid "User not specified"
4230msgstr "L'utilisateur n'a pas été spécifié" 3457msgstr "L'utilisateur n'a pas été spécifié"
4231 3458
4232#: plugins/check_radius.c:318
4233msgid "Password not specified" 3459msgid "Password not specified"
4234msgstr "Le mot de passe n'a pas été spécifié" 3460msgstr "Le mot de passe n'a pas été spécifié"
4235 3461
4236#: plugins/check_radius.c:320
4237msgid "Configuration file not specified" 3462msgid "Configuration file not specified"
4238msgstr "Le fichier de configuration n'a pas été spécifié" 3463msgstr "Le fichier de configuration n'a pas été spécifié"
4239 3464
4240#: plugins/check_radius.c:338
4241msgid "Tests to see if a RADIUS server is accepting connections." 3465msgid "Tests to see if a RADIUS server is accepting connections."
4242msgstr "Teste si un serveur RADIUS accepte les connections." 3466msgstr "Teste si un serveur RADIUS accepte les connections."
4243 3467
4244#: plugins/check_radius.c:350
4245msgid "The user to authenticate" 3468msgid "The user to authenticate"
4246msgstr "" 3469msgstr ""
4247 3470
4248#: plugins/check_radius.c:352
4249msgid "Password for authentication (SECURITY RISK)" 3471msgid "Password for authentication (SECURITY RISK)"
4250msgstr "" 3472msgstr ""
4251 3473
4252#: plugins/check_radius.c:354
4253msgid "NAS identifier" 3474msgid "NAS identifier"
4254msgstr "" 3475msgstr ""
4255 3476
4256#: plugins/check_radius.c:356
4257msgid "NAS IP Address" 3477msgid "NAS IP Address"
4258msgstr "Adresse IP NAS" 3478msgstr "Adresse IP NAS"
4259 3479
4260#: plugins/check_radius.c:358
4261msgid "Configuration file" 3480msgid "Configuration file"
4262msgstr "Fichier de configuration" 3481msgstr "Fichier de configuration"
4263 3482
4264#: plugins/check_radius.c:360
4265msgid "Response string to expect from the server" 3483msgid "Response string to expect from the server"
4266msgstr "" 3484msgstr ""
4267 3485
4268#: plugins/check_radius.c:362
4269msgid "Number of times to retry a failed connection" 3486msgid "Number of times to retry a failed connection"
4270msgstr "" 3487msgstr ""
4271 3488
4272#: plugins/check_radius.c:367
4273msgid "" 3489msgid ""
4274"This plugin tests a RADIUS server to see if it is accepting connections." 3490"This plugin tests a RADIUS server to see if it is accepting connections."
4275msgstr "" 3491msgstr ""
4276"Ce plugin teste un serveur RADIUS afin de vérifier si il accepte les " 3492"Ce plugin teste un serveur RADIUS afin de vérifier si il accepte les "
4277"connections." 3493"connections."
4278 3494
4279#: plugins/check_radius.c:368
4280msgid "" 3495msgid ""
4281"The server to test must be specified in the invocation, as well as a user" 3496"The server to test must be specified in the invocation, as well as a user"
4282msgstr "" 3497msgstr ""
4283 3498
4284#: plugins/check_radius.c:369 3499msgid "name and password. A configuration file must be present. The format of"
4285msgid ""
4286"name and password. A configuration file may also be present. The format of"
4287msgstr "" 3500msgstr ""
4288 3501
4289#: plugins/check_radius.c:370
4290msgid "" 3502msgid ""
4291"the configuration file is described in the radiusclient library sources." 3503"the configuration file is described in the radiusclient library sources."
4292msgstr "" 3504msgstr ""
4293 3505
4294#: plugins/check_radius.c:371
4295msgid "The password option presents a substantial security issue because the" 3506msgid "The password option presents a substantial security issue because the"
4296msgstr "" 3507msgstr ""
4297 3508
4298#: plugins/check_radius.c:372
4299msgid "" 3509msgid ""
4300"password can possibly be determined by careful watching of the command line" 3510"password can possibly be determined by careful watching of the command line"
4301msgstr "" 3511msgstr ""
4302 3512
4303#: plugins/check_radius.c:373 3513msgid "in a process listing. This risk is exacerbated because the plugin will"
4304msgid "in a process listing. This risk is exacerbated because the monitor will"
4305msgstr "" 3514msgstr ""
4306 3515
4307#: plugins/check_radius.c:374 3516msgid ""
4308msgid "run the plugin at regular predictable intervals. Please be sure that" 3517"typically be executed at regular predictable intervals. Please be sure that"
4309msgstr "" 3518msgstr ""
4310 3519
4311#: plugins/check_radius.c:375
4312msgid "the password used does not allow access to sensitive system resources." 3520msgid "the password used does not allow access to sensitive system resources."
4313msgstr "" 3521msgstr ""
4314 3522
4315#: plugins/check_real.c:91
4316#, c-format 3523#, c-format
4317msgid "Unable to connect to %s on port %d\n" 3524msgid "Unable to connect to %s on port %d\n"
4318msgstr "Impossible de se connecter à %s sur le port %d\n" 3525msgstr "Impossible de se connecter à %s sur le port %d\n"
4319 3526
4320#: plugins/check_real.c:113
4321#, c-format 3527#, c-format
4322msgid "No data received from %s\n" 3528msgid "No data received from %s\n"
4323msgstr "Pas de données reçues de %s\n" 3529msgstr "Pas de données reçues de %s\n"
4324 3530
4325#: plugins/check_real.c:118 plugins/check_real.c:191
4326msgid "Invalid REAL response received from host" 3531msgid "Invalid REAL response received from host"
4327msgstr "Réponses REAL invalide reçue de l'hôte" 3532msgstr "Réponses REAL invalide reçue de l'hôte"
4328 3533
4329#: plugins/check_real.c:120 plugins/check_real.c:193
4330#, c-format 3534#, c-format
4331msgid "Invalid REAL response received from host on port %d\n" 3535msgid "Invalid REAL response received from host on port %d\n"
4332msgstr "Réponses REAL invalide reçue de l'hôte sur le port %d\n" 3536msgstr "Réponses REAL invalide reçue de l'hôte sur le port %d\n"
4333 3537
4334#: plugins/check_real.c:184 plugins/check_tcp.c:311
4335#, c-format 3538#, c-format
4336msgid "No data received from host\n" 3539msgid "No data received from host\n"
4337msgstr "Pas de données reçues de l'hôte\n" 3540msgstr "Pas de données reçues de l'hôte\n"
4338 3541
4339#: plugins/check_real.c:247
4340#, c-format 3542#, c-format
4341msgid "REAL %s - %d second response time\n" 3543msgid "REAL %s - %d second response time\n"
4342msgstr "REAL %s - %d secondes de temps de réponse\n" 3544msgstr "REAL %s - %d secondes de temps de réponse\n"
4343 3545
4344#: plugins/check_real.c:336 plugins/check_ups.c:536
4345msgid "Warning time must be a positive integer" 3546msgid "Warning time must be a positive integer"
4346msgstr "Le seuil d'avertissement doit être un entier positif" 3547msgstr "Le seuil d'avertissement doit être un entier positif"
4347 3548
4348#: plugins/check_real.c:345 plugins/check_ups.c:527
4349msgid "Critical time must be a positive integer" 3549msgid "Critical time must be a positive integer"
4350msgstr "Le seuil critique doit être un entier positif" 3550msgstr "Le seuil critique doit être un entier positif"
4351 3551
4352#: plugins/check_real.c:381
4353msgid "You must provide a server to check" 3552msgid "You must provide a server to check"
4354msgstr "Vous devez fournir un serveur à vérifier" 3553msgstr "Vous devez fournir un serveur à vérifier"
4355 3554
4356#: plugins/check_real.c:413
4357msgid "This plugin tests the REAL service on the specified host." 3555msgid "This plugin tests the REAL service on the specified host."
4358msgstr "Ce plugin teste le service REAL sur l'hôte spécifié." 3556msgstr "Ce plugin teste le service REAL sur l'hôte spécifié."
4359 3557
4360#: plugins/check_real.c:425
4361msgid "Connect to this url" 3558msgid "Connect to this url"
4362msgstr "" 3559msgstr ""
4363 3560
4364#: plugins/check_real.c:427
4365#, c-format 3561#, c-format
4366msgid "String to expect in first line of server response (default: %s)\n" 3562msgid "String to expect in first line of server response (default: %s)\n"
4367msgstr "" 3563msgstr ""
4368"Texte attendu dans la première ligne de réponse du serveur (défaut: %s)\n" 3564"Texte attendu dans la première ligne de réponse du serveur (défaut: %s)\n"
4369 3565
4370#: plugins/check_real.c:437
4371msgid "This plugin will attempt to open an RTSP connection with the host." 3566msgid "This plugin will attempt to open an RTSP connection with the host."
4372msgstr "Ce plugin va essayer d'ouvrir un connexion RTSP avec l'hôte." 3567msgstr "Ce plugin va essayer d'ouvrir un connexion RTSP avec l'hôte."
4373 3568
4374#: plugins/check_real.c:438 plugins/check_smtp.c:830 3569msgid "Successful connects return STATE_OK, refusals and timeouts return"
4375msgid "Successul connects return STATE_OK, refusals and timeouts return"
4376msgstr "" 3570msgstr ""
4377 3571
4378#: plugins/check_real.c:439
4379msgid "" 3572msgid ""
4380"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects," 3573"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"
4381msgstr "" 3574msgstr ""
4382 3575
4383#: plugins/check_real.c:440
4384msgid "" 3576msgid ""
4385"but incorrect response messages from the host result in STATE_WARNING return" 3577"but incorrect response messages from the host result in STATE_WARNING return"
4386msgstr "" 3578msgstr ""
4387 3579
4388#: plugins/check_real.c:441
4389msgid "values." 3580msgid "values."
4390msgstr "" 3581msgstr ""
4391 3582
4392#: plugins/check_smtp.c:150 plugins/check_swap.c:265 plugins/check_swap.c:271
4393#, c-format 3583#, c-format
4394msgid "malloc() failed!\n" 3584msgid "malloc() failed!\n"
4395msgstr "l'allocation mémoire à échoué!\n" 3585msgstr "l'allocation mémoire à échoué!\n"
4396 3586
4397#: plugins/check_smtp.c:154
4398#, c-format 3587#, c-format
4399msgid "gethostname() failed!\n" 3588msgid "CRITICAL - Cannot create SSL context.\n"
4400msgstr "La commande gethostname() à échoué\n" 3589msgstr "CRITIQUE - Impossible de créer le contexte SSL.\n"
4401 3590
4402#: plugins/check_smtp.c:189 plugins/check_smtp.c:213
4403#, c-format 3591#, c-format
4404msgid "recv() failed\n" 3592msgid "recv() failed\n"
4405msgstr "La commande recv() à échoué\n" 3593msgstr "La commande recv() à échoué\n"
4406 3594
4407#: plugins/check_smtp.c:200
4408#, c-format
4409msgid "Invalid SMTP response received from host: %s\n"
4410msgstr "Réponse SMTP reçue de l'hôte invalide: %s\n"
4411
4412#: plugins/check_smtp.c:202
4413#, c-format
4414msgid "Invalid SMTP response received from host on port %d: %s\n"
4415msgstr "Réponse SMTP reçue de l'hôte sur le port %d invalide: %s\n"
4416
4417#: plugins/check_smtp.c:223
4418#, c-format 3595#, c-format
4419msgid "WARNING - TLS not supported by server\n" 3596msgid "WARNING - TLS not supported by server\n"
4420msgstr "AVERTISSEMENT: - TLS n'est pas supporté par ce serveur\n" 3597msgstr "AVERTISSEMENT: - TLS n'est pas supporté par ce serveur\n"
4421 3598
4422#: plugins/check_smtp.c:235
4423#, c-format 3599#, c-format
4424msgid "Server does not support STARTTLS\n" 3600msgid "Server does not support STARTTLS\n"
4425msgstr "Le serveur ne supporte pas STARTTLS\n" 3601msgstr "Le serveur ne supporte pas STARTTLS\n"
4426 3602
4427#: plugins/check_smtp.c:241
4428#, c-format
4429msgid "CRITICAL - Cannot create SSL context.\n"
4430msgstr "CRITIQUE - Impossible de créer le contexte SSL.\n"
4431
4432#: plugins/check_smtp.c:261
4433msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS." 3603msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS."
4434msgstr "" 3604msgstr ""
4435 3605
4436#: plugins/check_smtp.c:266
4437#, c-format 3606#, c-format
4438msgid "sent %s" 3607msgid "sent %s"
4439msgstr "envoyé %s" 3608msgstr "envoyé %s"
4440 3609
4441#: plugins/check_smtp.c:268
4442msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS." 3610msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS."
4443msgstr "" 3611msgstr ""
4444 3612
4445#: plugins/check_smtp.c:303 plugins/check_snmp.c:806 3613#, c-format
3614msgid "Invalid SMTP response received from host: %s\n"
3615msgstr "Réponse SMTP reçue de l'hôte invalide: %s\n"
3616
3617#, c-format
3618msgid "Invalid SMTP response received from host on port %d: %s\n"
3619msgstr "Réponse SMTP reçue de l'hôte sur le port %d invalide: %s\n"
3620
4446#, c-format 3621#, c-format
4447msgid "Could Not Compile Regular Expression" 3622msgid "Could Not Compile Regular Expression"
4448msgstr "Impossible de compiler l'expression rationnelle" 3623msgstr "Impossible de compiler l'expression rationnelle"
4449 3624
4450#: plugins/check_smtp.c:312
4451#, c-format 3625#, c-format
4452msgid "SMTP %s - Invalid response '%s' to command '%s'\n" 3626msgid "SMTP %s - Invalid response '%s' to command '%s'\n"
4453msgstr "SMTP %s - réponse invalide de '%s' à la commande '%s'\n" 3627msgstr "SMTP %s - réponse invalide de '%s' à la commande '%s'\n"
4454 3628
4455#: plugins/check_smtp.c:316 plugins/check_snmp.c:511
4456#, c-format 3629#, c-format
4457msgid "Execute Error: %s\n" 3630msgid "Execute Error: %s\n"
4458msgstr "Erreur d'exécution: %s\n" 3631msgstr "Erreur d'exécution: %s\n"
4459 3632
4460#: plugins/check_smtp.c:330
4461msgid "no authuser specified, " 3633msgid "no authuser specified, "
4462msgstr "Pas d'utilisateur pour l'authentification spécifié, " 3634msgstr "Pas d'utilisateur pour l'authentification spécifié, "
4463 3635
4464#: plugins/check_smtp.c:335
4465msgid "no authpass specified, " 3636msgid "no authpass specified, "
4466msgstr "pas de mot de passe spécifié, " 3637msgstr "pas de mot de passe spécifié, "
4467 3638
4468#: plugins/check_smtp.c:342 plugins/check_smtp.c:363 plugins/check_smtp.c:383
4469#: plugins/check_smtp.c:688
4470#, c-format 3639#, c-format
4471msgid "sent %s\n" 3640msgid "sent %s\n"
4472msgstr "envoyé %s\n" 3641msgstr "envoyé %s\n"
4473 3642
4474#: plugins/check_smtp.c:345
4475msgid "recv() failed after AUTH LOGIN, " 3643msgid "recv() failed after AUTH LOGIN, "
4476msgstr "recv() à échoué après AUTH LOGIN, " 3644msgstr "recv() à échoué après AUTH LOGIN, "
4477 3645
4478#: plugins/check_smtp.c:350 plugins/check_smtp.c:371 plugins/check_smtp.c:391
4479#: plugins/check_smtp.c:699
4480#, c-format 3646#, c-format
4481msgid "received %s\n" 3647msgid "received %s\n"
4482msgstr "reçu %s\n" 3648msgstr "reçu %s\n"
4483 3649
4484#: plugins/check_smtp.c:354
4485msgid "invalid response received after AUTH LOGIN, " 3650msgid "invalid response received after AUTH LOGIN, "
4486msgstr "Réponse invalide reçue après AUTH LOGIN, " 3651msgstr "Réponse invalide reçue après AUTH LOGIN, "
4487 3652
4488#: plugins/check_smtp.c:367
4489msgid "recv() failed after sending authuser, " 3653msgid "recv() failed after sending authuser, "
4490msgstr "La commande recv() a échoué après authuser, " 3654msgstr "La commande recv() a échoué après authuser, "
4491 3655
4492#: plugins/check_smtp.c:375
4493msgid "invalid response received after authuser, " 3656msgid "invalid response received after authuser, "
4494msgstr "Réponse invalide reçue après authuser, " 3657msgstr "Réponse invalide reçue après authuser, "
4495 3658
4496#: plugins/check_smtp.c:387
4497msgid "recv() failed after sending authpass, " 3659msgid "recv() failed after sending authpass, "
4498msgstr "la commande recv() à échoué après authpass, " 3660msgstr "la commande recv() à échoué après authpass, "
4499 3661
4500#: plugins/check_smtp.c:395
4501msgid "invalid response received after authpass, " 3662msgid "invalid response received after authpass, "
4502msgstr "Réponse invalide reçue après authpass, " 3663msgstr "Réponse invalide reçue après authpass, "
4503 3664
4504#: plugins/check_smtp.c:402
4505msgid "only authtype LOGIN is supported, " 3665msgid "only authtype LOGIN is supported, "
4506msgstr "seul la méthode d'authentification LOGIN est supportée, " 3666msgstr "seul la méthode d'authentification LOGIN est supportée, "
4507 3667
4508#: plugins/check_smtp.c:426
4509#, c-format 3668#, c-format
4510msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n" 3669msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n"
4511msgstr "SMTP %s - %s%.3f sec. de temps de réponse%s%s|%s\n" 3670msgstr "SMTP %s - %s%.3f sec. de temps de réponse%s%s|%s\n"
4512 3671
4513#: plugins/check_smtp.c:536 plugins/check_smtp.c:548
4514#, c-format 3672#, c-format
4515msgid "Could not realloc() units [%d]\n" 3673msgid "Could not realloc() units [%d]\n"
4516msgstr "Impossible de réallouer des unités [%d]\n" 3674msgstr "Impossible de réallouer des unités [%d]\n"
4517 3675
4518#: plugins/check_smtp.c:556
4519#, fuzzy 3676#, fuzzy
4520msgid "Critical time must be a positive" 3677msgid "Critical time must be a positive"
4521msgstr "Le seuil critique doit être un entier positif" 3678msgstr "Le seuil critique doit être un entier positif"
4522 3679
4523#: plugins/check_smtp.c:564
4524#, fuzzy 3680#, fuzzy
4525msgid "Warning time must be a positive" 3681msgid "Warning time must be a positive"
4526msgstr "Le seuil d'avertissement doit être un entier positif" 3682msgstr "Le seuil d'avertissement doit être un entier positif"
4527 3683
4528#: plugins/check_smtp.c:611
4529msgid "SSL support not available - install OpenSSL and recompile" 3684msgid "SSL support not available - install OpenSSL and recompile"
4530msgstr "SSL n'est pas disponible - installer OpenSSL et recompilez" 3685msgstr "SSL n'est pas disponible - installer OpenSSL et recompilez"
4531 3686
4532#: plugins/check_smtp.c:679 plugins/check_smtp.c:684 3687msgid "Set either -s/--ssl/--tls or -S/--starttls"
3688msgstr "Définissez -s/--ssl/--tls ou -S/--starttls"
3689
4533#, c-format 3690#, c-format
4534msgid "Connection closed by server before sending QUIT command\n" 3691msgid "Connection closed by server before sending QUIT command\n"
4535msgstr "" 3692msgstr ""
4536 3693
4537#: plugins/check_smtp.c:694
4538#, c-format 3694#, c-format
4539msgid "recv() failed after QUIT." 3695msgid "recv() failed after QUIT."
4540msgstr "recv() à échoué après QUIT." 3696msgstr "recv() à échoué après QUIT."
4541 3697
4542#: plugins/check_smtp.c:696
4543#, c-format 3698#, c-format
4544msgid "Connection reset by peer." 3699msgid "Connection reset by peer."
4545msgstr "" 3700msgstr ""
4546 3701
4547#: plugins/check_smtp.c:784
4548msgid "This plugin will attempt to open an SMTP connection with the host." 3702msgid "This plugin will attempt to open an SMTP connection with the host."
4549msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte." 3703msgstr "Ce plugin va essayer d'ouvrir un connexion SMTP avec l'hôte."
4550 3704
4551#: plugins/check_smtp.c:798
4552#, c-format 3705#, c-format
4553msgid " String to expect in first line of server response (default: '%s')\n" 3706msgid " String to expect in first line of server response (default: '%s')\n"
4554msgstr "" 3707msgstr ""
4555" Texte attendu dans la première ligne de réponse du serveur (défaut: " 3708" Texte attendu dans la première ligne de réponse du serveur (défaut: "
4556"'%s')\n" 3709"'%s')\n"
4557 3710
4558#: plugins/check_smtp.c:800
4559msgid "SMTP command (may be used repeatedly)" 3711msgid "SMTP command (may be used repeatedly)"
4560msgstr "Commande SMTP (peut être utilisé plusieurs fois)" 3712msgstr "Commande SMTP (peut être utilisé plusieurs fois)"
4561 3713
4562#: plugins/check_smtp.c:802
4563msgid "Expected response to command (may be used repeatedly)" 3714msgid "Expected response to command (may be used repeatedly)"
4564msgstr "" 3715msgstr ""
4565 3716
4566#: plugins/check_smtp.c:804
4567msgid "FROM-address to include in MAIL command, required by Exchange 2000" 3717msgid "FROM-address to include in MAIL command, required by Exchange 2000"
4568msgstr "" 3718msgstr ""
4569 3719
4570#: plugins/check_smtp.c:806
4571msgid "FQDN used for HELO" 3720msgid "FQDN used for HELO"
4572msgstr "" 3721msgstr ""
4573 3722
4574#: plugins/check_smtp.c:809 plugins/check_tcp.c:665 3723msgid "Use PROXY protocol prefix for the connection."
3724msgstr "Utiliser le préfixe du protocole PROXY pour la connexion."
3725
4575msgid "Minimum number of days a certificate has to be valid." 3726msgid "Minimum number of days a certificate has to be valid."
4576msgstr "Nombre de jours minimum pour que le certificat soit valide." 3727msgstr "Nombre de jours minimum pour que le certificat soit valide."
4577 3728
4578#: plugins/check_smtp.c:811 3729#, fuzzy
3730msgid "Use SSL/TLS for the connection."
3731msgstr "Utiliser SSL/TLS pour la connexion."
3732
3733#, c-format
3734msgid " Sets default port to %d.\n"
3735msgstr " Définit le port par défaut à %d.\n"
3736
4579msgid "Use STARTTLS for the connection." 3737msgid "Use STARTTLS for the connection."
4580msgstr "" 3738msgstr "Utiliser STARTTLS pour la connexion."
4581 3739
4582#: plugins/check_smtp.c:815
4583msgid "SMTP AUTH type to check (default none, only LOGIN supported)" 3740msgid "SMTP AUTH type to check (default none, only LOGIN supported)"
4584msgstr "" 3741msgstr ""
4585 3742
4586#: plugins/check_smtp.c:817
4587msgid "SMTP AUTH username" 3743msgid "SMTP AUTH username"
4588msgstr "" 3744msgstr ""
4589 3745
4590#: plugins/check_smtp.c:819
4591msgid "SMTP AUTH password" 3746msgid "SMTP AUTH password"
4592msgstr "" 3747msgstr ""
4593 3748
4594#: plugins/check_smtp.c:821 3749msgid "Send LHLO instead of HELO/EHLO"
3750msgstr ""
3751
4595msgid "Ignore failure when sending QUIT command to server" 3752msgid "Ignore failure when sending QUIT command to server"
4596msgstr "" 3753msgstr ""
4597 3754
4598#: plugins/check_smtp.c:831
4599msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful" 3755msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"
4600msgstr "" 3756msgstr ""
4601 3757
4602#: plugins/check_smtp.c:832
4603msgid "connects, but incorrect response messages from the host result in" 3758msgid "connects, but incorrect response messages from the host result in"
4604msgstr "" 3759msgstr ""
4605 3760
4606#: plugins/check_smtp.c:833
4607msgid "STATE_WARNING return values." 3761msgid "STATE_WARNING return values."
4608msgstr "" 3762msgstr ""
4609 3763
4610#: plugins/check_snmp.c:169 plugins/check_snmp.c:582
4611msgid "Cannot malloc" 3764msgid "Cannot malloc"
4612msgstr "" 3765msgstr ""
4613 3766
4614#: plugins/check_snmp.c:356
4615#, c-format 3767#, c-format
4616msgid "External command error: %s\n" 3768msgid "External command error: %s\n"
4617msgstr "Erreur d'exécution de commande externe: %s\n" 3769msgstr "Erreur d'exécution de commande externe: %s\n"
4618 3770
4619#: plugins/check_snmp.c:361
4620#, c-format 3771#, c-format
4621msgid "External command error with no output (return code: %d)\n" 3772msgid "External command error with no output (return code: %d)\n"
4622msgstr "" 3773msgstr ""
4623 3774
4624#: plugins/check_snmp.c:464
4625#, fuzzy, c-format 3775#, fuzzy, c-format
4626msgid "No valid data returned (%s)\n" 3776msgid "No valid data returned (%s)\n"
4627msgstr "Pas de données valides reçues" 3777msgstr "Pas de données valides reçues"
4628 3778
4629#: plugins/check_snmp.c:475
4630msgid "Time duration between plugin calls is invalid" 3779msgid "Time duration between plugin calls is invalid"
4631msgstr "" 3780msgstr ""
4632 3781
4633#: plugins/check_snmp.c:588
4634msgid "Cannot asprintf()" 3782msgid "Cannot asprintf()"
4635msgstr "" 3783msgstr ""
4636 3784
4637#: plugins/check_snmp.c:594
4638#, fuzzy 3785#, fuzzy
4639msgid "Cannot realloc()" 3786msgid "Cannot realloc()"
4640msgstr "Impossible de réallouer des unités\n" 3787msgstr "Impossible de réallouer des unités\n"
4641 3788
4642#: plugins/check_snmp.c:610
4643msgid "No previous data to calculate rate - assume okay" 3789msgid "No previous data to calculate rate - assume okay"
4644msgstr "" 3790msgstr ""
4645 3791
4646#: plugins/check_snmp.c:751
4647msgid "Retries interval must be a positive integer" 3792msgid "Retries interval must be a positive integer"
4648msgstr "L'intervalle pour les essais doit être un entier positif" 3793msgstr "L'intervalle pour les essais doit être un entier positif"
4649 3794
4650#: plugins/check_snmp.c:831 3795#, fuzzy
3796msgid "Exit status must be a positive integer"
3797msgstr "Maxbytes doit être un entier positif"
3798
4651#, c-format 3799#, c-format
4652msgid "Could not reallocate labels[%d]" 3800msgid "Could not reallocate labels[%d]"
4653msgstr "Impossible de réallouer des labels[%d]" 3801msgstr "Impossible de réallouer des labels[%d]"
4654 3802
4655#: plugins/check_snmp.c:844
4656msgid "Could not reallocate labels\n" 3803msgid "Could not reallocate labels\n"
4657msgstr "Impossible de réallouer des labels\n" 3804msgstr "Impossible de réallouer des labels\n"
4658 3805
4659#: plugins/check_snmp.c:860
4660#, c-format 3806#, c-format
4661msgid "Could not reallocate units [%d]\n" 3807msgid "Could not reallocate units [%d]\n"
4662msgstr "Impossible de réallouer des unités [%d]\n" 3808msgstr "Impossible de réallouer des unités [%d]\n"
4663 3809
4664#: plugins/check_snmp.c:872
4665msgid "Could not realloc() units\n" 3810msgid "Could not realloc() units\n"
4666msgstr "Impossible de réallouer des unités\n" 3811msgstr "Impossible de réallouer des unités\n"
4667 3812
4668#: plugins/check_snmp.c:889
4669#, fuzzy 3813#, fuzzy
4670msgid "Rate multiplier must be a positive integer" 3814msgid "Rate multiplier must be a positive integer"
4671msgstr "La taille du paquet doit être un entier positif" 3815msgstr "La taille du paquet doit être un entier positif"
4672 3816
4673#: plugins/check_snmp.c:947
4674msgid "No host specified\n" 3817msgid "No host specified\n"
4675msgstr "Pas d'hôte spécifié\n" 3818msgstr "Pas d'hôte spécifié\n"
4676 3819
4677#: plugins/check_snmp.c:951
4678msgid "No OIDs specified\n" 3820msgid "No OIDs specified\n"
4679msgstr "Pas de compteur spécifié\n" 3821msgstr "Pas de compteur spécifié\n"
4680 3822
4681#: plugins/check_snmp.c:973
4682msgid "Invalid seclevel"
4683msgstr ""
4684
4685#: plugins/check_snmp.c:980 plugins/check_snmp.c:983 plugins/check_snmp.c:1001
4686#, c-format 3823#, c-format
4687msgid "Required parameter: %s\n" 3824msgid "Required parameter: %s\n"
4688msgstr "" 3825msgstr ""
4689 3826
4690#: plugins/check_snmp.c:1022 3827msgid "Invalid seclevel"
3828msgstr ""
3829
4691msgid "Invalid SNMP version" 3830msgid "Invalid SNMP version"
4692msgstr "Version de SNMP invalide" 3831msgstr "Version de SNMP invalide"
4693 3832
4694#: plugins/check_snmp.c:1039
4695msgid "Unbalanced quotes\n" 3833msgid "Unbalanced quotes\n"
4696msgstr "Guillemets manquants\n" 3834msgstr "Guillemets manquants\n"
4697 3835
4698#: plugins/check_snmp.c:1088 3836#, c-format
3837msgid "multiplier set (%.1f), but input is not a number: %s"
3838msgstr ""
3839
4699msgid "Check status of remote machines and obtain system information via SNMP" 3840msgid "Check status of remote machines and obtain system information via SNMP"
4700msgstr "" 3841msgstr ""
4701"Vérifie l'état des machines distantes et obtient l'information système via " 3842"Vérifie l'état des machines distantes et obtient l'information système via "
4702"SNMP" 3843"SNMP"
4703 3844
4704#: plugins/check_snmp.c:1101
4705msgid "Use SNMP GETNEXT instead of SNMP GET" 3845msgid "Use SNMP GETNEXT instead of SNMP GET"
4706msgstr "Utiliser SNMP GETNEXT au lieu de SNMP GET" 3846msgstr "Utiliser SNMP GETNEXT au lieu de SNMP GET"
4707 3847
4708#: plugins/check_snmp.c:1103
4709msgid "SNMP protocol version" 3848msgid "SNMP protocol version"
4710msgstr "Version du protocole SNMP" 3849msgstr "Version du protocole SNMP"
4711 3850
4712#: plugins/check_snmp.c:1105 3851#, fuzzy
3852msgid "SNMPv3 context"
3853msgstr "Nom d'utilisateur SNMPv3"
3854
4713msgid "SNMPv3 securityLevel" 3855msgid "SNMPv3 securityLevel"
4714msgstr "Niveau de sécurité SNMPv3 (securityLevel)" 3856msgstr "Niveau de sécurité SNMPv3 (securityLevel)"
4715 3857
4716#: plugins/check_snmp.c:1107
4717msgid "SNMPv3 auth proto" 3858msgid "SNMPv3 auth proto"
4718msgstr "Protocole d'authentification SNMPv3" 3859msgstr "Protocole d'authentification SNMPv3"
4719 3860
4720#: plugins/check_snmp.c:1109
4721msgid "SNMPv3 priv proto (default DES)" 3861msgid "SNMPv3 priv proto (default DES)"
4722msgstr "" 3862msgstr ""
4723 3863
4724#: plugins/check_snmp.c:1113
4725msgid "Optional community string for SNMP communication" 3864msgid "Optional community string for SNMP communication"
4726msgstr "Communauté optionnelle pour la communication SNMP" 3865msgstr "Communauté optionnelle pour la communication SNMP"
4727 3866
4728#: plugins/check_snmp.c:1114
4729msgid "default is" 3867msgid "default is"
4730msgstr "défaut:" 3868msgstr "défaut:"
4731 3869
4732#: plugins/check_snmp.c:1116
4733msgid "SNMPv3 username" 3870msgid "SNMPv3 username"
4734msgstr "Nom d'utilisateur SNMPv3" 3871msgstr "Nom d'utilisateur SNMPv3"
4735 3872
4736#: plugins/check_snmp.c:1118
4737msgid "SNMPv3 authentication password" 3873msgid "SNMPv3 authentication password"
4738msgstr "Mot de passe d'authentification SNMPv3" 3874msgstr "Mot de passe d'authentification SNMPv3"
4739 3875
4740#: plugins/check_snmp.c:1120
4741msgid "SNMPv3 privacy password" 3876msgid "SNMPv3 privacy password"
4742msgstr "Mot de passe de confidentialité SNMPv3" 3877msgstr "Mot de passe de confidentialité SNMPv3"
4743 3878
4744#: plugins/check_snmp.c:1124
4745msgid "Object identifier(s) or SNMP variables whose value you wish to query" 3879msgid "Object identifier(s) or SNMP variables whose value you wish to query"
4746msgstr "" 3880msgstr ""
4747 3881
4748#: plugins/check_snmp.c:1126
4749msgid "" 3882msgid ""
4750"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'" 3883"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'"
4751msgstr "" 3884msgstr ""
4752 3885
4753#: plugins/check_snmp.c:1127
4754msgid "for symbolic OIDs.)" 3886msgid "for symbolic OIDs.)"
4755msgstr "" 3887msgstr ""
4756 3888
4757#: plugins/check_snmp.c:1129
4758msgid "Delimiter to use when parsing returned data. Default is" 3889msgid "Delimiter to use when parsing returned data. Default is"
4759msgstr "" 3890msgstr ""
4760 3891
4761#: plugins/check_snmp.c:1130
4762msgid "Any data on the right hand side of the delimiter is considered" 3892msgid "Any data on the right hand side of the delimiter is considered"
4763msgstr "" 3893msgstr ""
4764 3894
4765#: plugins/check_snmp.c:1131
4766msgid "to be the data that should be used in the evaluation." 3895msgid "to be the data that should be used in the evaluation."
4767msgstr "" 3896msgstr ""
4768 3897
4769#: plugins/check_snmp.c:1135 3898msgid "If the check returns a 0 length string or NULL value"
3899msgstr ""
3900
3901msgid "This option allows you to choose what status you want it to exit"
3902msgstr ""
3903
3904msgid "Excluding this option renders the default exit of 3(STATE_UNKNOWN)"
3905msgstr ""
3906
3907msgid "0 = OK"
3908msgstr ""
3909
3910#, fuzzy
3911msgid "1 = WARNING"
3912msgstr "AVERTISSEMENT"
3913
3914#, fuzzy
3915msgid "2 = CRITICAL"
3916msgstr "CRITIQUE"
3917
3918#, fuzzy
3919msgid "3 = UNKNOWN"
3920msgstr "INCONNU"
3921
4770msgid "Warning threshold range(s)" 3922msgid "Warning threshold range(s)"
4771msgstr "Valeurs pour le seuil d'avertissement" 3923msgstr "Valeurs pour le seuil d'avertissement"
4772 3924
4773#: plugins/check_snmp.c:1137
4774msgid "Critical threshold range(s)" 3925msgid "Critical threshold range(s)"
4775msgstr "Valeurs pour le seuil critique" 3926msgstr "Valeurs pour le seuil critique"
4776 3927
4777#: plugins/check_snmp.c:1139
4778msgid "Enable rate calculation. See 'Rate Calculation' below" 3928msgid "Enable rate calculation. See 'Rate Calculation' below"
4779msgstr "" 3929msgstr ""
4780 3930
4781#: plugins/check_snmp.c:1141
4782msgid "" 3931msgid ""
4783"Converts rate per second. For example, set to 60 to convert to per minute" 3932"Converts rate per second. For example, set to 60 to convert to per minute"
4784msgstr "" 3933msgstr ""
4785 3934
4786#: plugins/check_snmp.c:1143 3935msgid "Add/subtract the specified OFFSET to numeric sensor data"
4787msgid "Add/substract the specified OFFSET to numeric sensor data"
4788msgstr "" 3936msgstr ""
4789 3937
4790#: plugins/check_snmp.c:1147
4791msgid "Return OK state (for that OID) if STRING is an exact match" 3938msgid "Return OK state (for that OID) if STRING is an exact match"
4792msgstr "" 3939msgstr ""
4793 3940
4794#: plugins/check_snmp.c:1149
4795msgid "" 3941msgid ""
4796"Return OK state (for that OID) if extended regular expression REGEX matches" 3942"Return OK state (for that OID) if extended regular expression REGEX matches"
4797msgstr "" 3943msgstr ""
4798 3944
4799#: plugins/check_snmp.c:1151
4800msgid "" 3945msgid ""
4801"Return OK state (for that OID) if case-insensitive extended REGEX matches" 3946"Return OK state (for that OID) if case-insensitive extended REGEX matches"
4802msgstr "" 3947msgstr ""
4803 3948
4804#: plugins/check_snmp.c:1153
4805msgid "Invert search result (CRITICAL if found)" 3949msgid "Invert search result (CRITICAL if found)"
4806msgstr "" 3950msgstr ""
4807 3951
4808#: plugins/check_snmp.c:1157
4809msgid "Prefix label for output from plugin" 3952msgid "Prefix label for output from plugin"
4810msgstr "" 3953msgstr ""
4811 3954
4812#: plugins/check_snmp.c:1159
4813msgid "Units label(s) for output data (e.g., 'sec.')." 3955msgid "Units label(s) for output data (e.g., 'sec.')."
4814msgstr "" 3956msgstr ""
4815 3957
4816#: plugins/check_snmp.c:1161
4817msgid "Separates output on multiple OID requests" 3958msgid "Separates output on multiple OID requests"
4818msgstr "" 3959msgstr ""
4819 3960
4820#: plugins/check_snmp.c:1165 3961msgid "Multiplies current value, 0 < n < 1 works as divider, defaults to 1"
4821msgid "Number of retries to be used in the requests" 3962msgstr ""
3963
3964msgid "C-style format string for float values (see option -M)"
3965msgstr ""
3966
3967msgid ""
3968"NOTE the final timeout value is calculated using this formula: "
3969"timeout_interval * retries + 5"
3970msgstr ""
3971
3972#, fuzzy
3973msgid "Number of retries to be used in the requests, default: "
4822msgstr "Le nombre d'essai pour les requêtes" 3974msgstr "Le nombre d'essai pour les requêtes"
4823 3975
4824#: plugins/check_snmp.c:1168
4825msgid "Label performance data with OIDs instead of --label's" 3976msgid "Label performance data with OIDs instead of --label's"
4826msgstr "" 3977msgstr ""
4827 3978
4828#: plugins/check_snmp.c:1173 3979msgid "Tell snmpget to not print errors encountered when parsing MIB files"
3980msgstr ""
3981
4829msgid "" 3982msgid ""
4830"This plugin uses the 'snmpget' command included with the NET-SNMP package." 3983"This plugin uses the 'snmpget' command included with the NET-SNMP package."
4831msgstr "" 3984msgstr ""
4832 3985
4833#: plugins/check_snmp.c:1174
4834msgid "" 3986msgid ""
4835"if you don't have the package installed, you will need to download it from" 3987"if you don't have the package installed, you will need to download it from"
4836msgstr "" 3988msgstr ""
4837"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis" 3989"Si vous n'avez pas le programme installé, vous devrez le télécharger depuis"
4838 3990
4839#: plugins/check_snmp.c:1175
4840msgid "http://net-snmp.sourceforge.net before you can use this plugin." 3991msgid "http://net-snmp.sourceforge.net before you can use this plugin."
4841msgstr "http://net-snmp.sourceforge.net avant de pouvoir utiliser ce plugin." 3992msgstr "http://net-snmp.sourceforge.net avant de pouvoir utiliser ce plugin."
4842 3993
4843#: plugins/check_snmp.c:1179
4844#, fuzzy 3994#, fuzzy
4845msgid "" 3995msgid ""
4846"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited " 3996"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "
4847msgstr "" 3997msgstr ""
4848"- Des OIDs multiples peuvent être séparées par des virgules ou des espaces" 3998"- Des OIDs multiples peuvent être séparées par des virgules ou des espaces"
4849 3999
4850#: plugins/check_snmp.c:1180
4851#, fuzzy 4000#, fuzzy
4852msgid "list (lists with internal spaces must be quoted)." 4001msgid "list (lists with internal spaces must be quoted)."
4853msgstr "(Les liste avec espaces doivent être entre guillemets). Max:" 4002msgstr "(Les liste avec espaces doivent être entre guillemets). Max:"
4854 4003
4855#: plugins/check_snmp.c:1184
4856msgid "" 4004msgid ""
4857"- When checking multiple OIDs, separate ranges by commas like '-w " 4005"- When checking multiple OIDs, separate ranges by commas like '-w "
4858"1:10,1:,:20'" 4006"1:10,1:,:20'"
4859msgstr "" 4007msgstr ""
4860 4008
4861#: plugins/check_snmp.c:1185
4862msgid "- Note that only one string and one regex may be checked at present" 4009msgid "- Note that only one string and one regex may be checked at present"
4863msgstr "" 4010msgstr ""
4864 4011
4865#: plugins/check_snmp.c:1186
4866msgid "" 4012msgid ""
4867"- All evaluation methods other than PR, STR, and SUBSTR expect that the value" 4013"- All evaluation methods other than PR, STR, and SUBSTR expect that the value"
4868msgstr "" 4014msgstr ""
4869 4015
4870#: plugins/check_snmp.c:1187
4871msgid "returned from the SNMP query is an unsigned integer." 4016msgid "returned from the SNMP query is an unsigned integer."
4872msgstr "" 4017msgstr ""
4873 4018
4874#: plugins/check_snmp.c:1190
4875msgid "Rate Calculation:" 4019msgid "Rate Calculation:"
4876msgstr "" 4020msgstr ""
4877 4021
4878#: plugins/check_snmp.c:1191
4879msgid "In many places, SNMP returns counters that are only meaningful when" 4022msgid "In many places, SNMP returns counters that are only meaningful when"
4880msgstr "" 4023msgstr ""
4881 4024
4882#: plugins/check_snmp.c:1192
4883msgid "calculating the counter difference since the last check. check_snmp" 4025msgid "calculating the counter difference since the last check. check_snmp"
4884msgstr "" 4026msgstr ""
4885 4027
4886#: plugins/check_snmp.c:1193
4887msgid "saves the last state information in a file so that the rate per second" 4028msgid "saves the last state information in a file so that the rate per second"
4888msgstr "" 4029msgstr ""
4889 4030
4890#: plugins/check_snmp.c:1194
4891msgid "can be calculated. Use the --rate option to save state information." 4031msgid "can be calculated. Use the --rate option to save state information."
4892msgstr "" 4032msgstr ""
4893 4033
4894#: plugins/check_snmp.c:1195
4895msgid "" 4034msgid ""
4896"On the first run, there will be no prior state - this will return with OK." 4035"On the first run, there will be no prior state - this will return with OK."
4897msgstr "" 4036msgstr ""
4898 4037
4899#: plugins/check_snmp.c:1196
4900msgid "The state is uniquely determined by the arguments to the plugin, so" 4038msgid "The state is uniquely determined by the arguments to the plugin, so"
4901msgstr "" 4039msgstr ""
4902 4040
4903#: plugins/check_snmp.c:1197
4904msgid "changing the arguments will create a new state file." 4041msgid "changing the arguments will create a new state file."
4905msgstr "" 4042msgstr ""
4906 4043
4907#: plugins/check_ssh.c:165
4908msgid "Port number must be a positive integer" 4044msgid "Port number must be a positive integer"
4909msgstr "Le numéro du port doit être un nombre entier positif" 4045msgstr "Le numéro du port doit être un nombre entier positif"
4910 4046
4911#: plugins/check_ssh.c:232
4912#, c-format 4047#, c-format
4913msgid "Server answer: %s" 4048msgid "Server answer: %s"
4914msgstr "Réponse du serveur: %s" 4049msgstr "Réponse du serveur: %s"
4915 4050
4916#: plugins/check_ssh.c:251 4051#, fuzzy, c-format
4917#, c-format 4052msgid "SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"
4918msgid "SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n" 4053msgstr ""
4054"SSH AVERTISSEMENT - %s (protocole %s) différence de version, attendu'%s'\n"
4055
4056#, fuzzy, c-format
4057msgid ""
4058"SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"
4919msgstr "" 4059msgstr ""
4920"SSH AVERTISSEMENT - %s (protocole %s) différence de version, attendu'%s'\n" 4060"SSH AVERTISSEMENT - %s (protocole %s) différence de version, attendu'%s'\n"
4921 4061
4922#: plugins/check_ssh.c:260
4923#, fuzzy, c-format 4062#, fuzzy, c-format
4924msgid "SSH OK - %s (protocol %s) | %s\n" 4063msgid "SSH OK - %s (protocol %s) | %s\n"
4925msgstr "SSH OK - %s (protocole %s)\n" 4064msgstr "SSH OK - %s (protocole %s)\n"
4926 4065
4927#: plugins/check_ssh.c:281
4928msgid "Try to connect to an SSH server at specified server and port" 4066msgid "Try to connect to an SSH server at specified server and port"
4929msgstr "Essaye de se connecter à un serveur SSH précisé à un port précis" 4067msgstr "Essaye de se connecter à un serveur SSH précisé à un port précis"
4930 4068
4931#: plugins/check_ssh.c:297 4069#, fuzzy
4932msgid "" 4070msgid ""
4933"Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)" 4071"Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"
4072msgstr ""
4073"AVERTISSEMENT si la chaîne ne correspond pas à la version précisée (ex: "
4074"OpenSSH_3.9p1)"
4075
4076#, fuzzy
4077msgid "Alert if protocol doesn't match expected protocol version (ex: 2.0)"
4934msgstr "" 4078msgstr ""
4935"AVERTISSEMENT si la chaîne ne correspond pas à la version précisée (ex: " 4079"AVERTISSEMENT si la chaîne ne correspond pas à la version précisée (ex: "
4936"OpenSSH_3.9p1)" 4080"OpenSSH_3.9p1)"
4937 4081
4938#: plugins/check_swap.c:169
4939#, c-format 4082#, c-format
4940msgid "Command: %s\n" 4083msgid "Command: %s\n"
4941msgstr "Commande: %s\n" 4084msgstr "Commande: %s\n"
4942 4085
4943#: plugins/check_swap.c:171
4944#, c-format 4086#, c-format
4945msgid "Format: %s\n" 4087msgid "Format: %s\n"
4946msgstr "Format: %s\n" 4088msgstr "Format: %s\n"
4947 4089
4948#: plugins/check_swap.c:207
4949#, c-format 4090#, c-format
4950msgid "total=%.0f, used=%.0f, free=%.0f\n" 4091msgid "total=%.0f, used=%.0f, free=%.0f\n"
4951msgstr "total=%.0f, utilisé=%.0f, libre=%.0ff\n" 4092msgstr "total=%.0f, utilisé=%.0f, libre=%.0ff\n"
4952 4093
4953#: plugins/check_swap.c:221
4954#, c-format 4094#, c-format
4955msgid "total=%.0f, free=%.0f\n" 4095msgid "total=%.0f, free=%.0f\n"
4956msgstr "total=%.0f, libre=%.0f\n" 4096msgstr "total=%.0f, libre=%.0f\n"
4957 4097
4958#: plugins/check_swap.c:253
4959msgid "Error getting swap devices\n" 4098msgid "Error getting swap devices\n"
4960msgstr "" 4099msgstr ""
4961 4100
4962#: plugins/check_swap.c:256
4963msgid "SWAP OK: No swap devices defined\n" 4101msgid "SWAP OK: No swap devices defined\n"
4964msgstr "SWAP OK: Pas de périphériques swap définis\n" 4102msgstr "SWAP OK: Pas de périphériques swap définis\n"
4965 4103
4966#: plugins/check_swap.c:277 plugins/check_swap.c:319
4967msgid "swapctl failed: " 4104msgid "swapctl failed: "
4968msgstr "swapctl à échoué:" 4105msgstr "swapctl à échoué:"
4969 4106
4970#: plugins/check_swap.c:278 plugins/check_swap.c:320
4971msgid "Error in swapctl call\n" 4107msgid "Error in swapctl call\n"
4972msgstr "" 4108msgstr ""
4973 4109
4974#: plugins/check_swap.c:357 4110#, fuzzy, c-format
4975#, c-format 4111msgid "SWAP %s - %d%% free (%dMB out of %dMB) %s|"
4976msgid "SWAP %s - %d%% free (%d MB out of %d MB) %s|"
4977msgstr "SWAP %s - %d%% libre (%d MB sur un total de %d MB) %s|" 4112msgstr "SWAP %s - %d%% libre (%d MB sur un total de %d MB) %s|"
4978 4113
4979#: plugins/check_swap.c:435 4114#, fuzzy
4980msgid "Warning threshold must be integer or percentage!" 4115msgid "Warning threshold percentage must be <= 100!"
4116msgstr "Le seuil d'avertissement doit être un entier positif"
4117
4118#, fuzzy
4119msgid "Warning threshold be positive integer or percentage!"
4981msgstr "Le seuil d'avertissement doit être un entier ou un pourcentage!" 4120msgstr "Le seuil d'avertissement doit être un entier ou un pourcentage!"
4982 4121
4983#: plugins/check_swap.c:453 4122#, fuzzy
4984msgid "Critical threshold must be integer or percentage!" 4123msgid "Critical threshold percentage must be <= 100!"
4124msgstr "le seuil critique doit être un entier positif"
4125
4126#, fuzzy
4127msgid "Critical threshold be positive integer or percentage!"
4985msgstr "Le seuil critique doit être un entier ou un pourcentage!" 4128msgstr "Le seuil critique doit être un entier ou un pourcentage!"
4986 4129
4987#: plugins/check_swap.c:507 4130#, fuzzy
4988msgid "Warning percentage should be more than critical percentage" 4131msgid ""
4132"no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
4133"or integer (0-3)."
4989msgstr "" 4134msgstr ""
4990"Le pourcentage d'avertissement doit être plus important que le pourcentage " 4135"Le résultat de temps dépassé doit être un nom d'état valide (OK, WARNING, "
4991"critique" 4136"CRITICAL, UNKNOWN) ou un nombre entier (0-3)."
4992 4137
4993#: plugins/check_swap.c:511 4138#, fuzzy
4994msgid "Warning free space should be more than critical free space" 4139msgid "Warning should be more than critical"
4995msgstr "" 4140msgstr ""
4996"Le seuil d'avertissement pour la place libre doit être plus grand que le " 4141"Le pourcentage d'avertissement doit être plus important que le pourcentage "
4997"seuil critique" 4142"critique"
4998 4143
4999#: plugins/check_swap.c:525
5000msgid "Check swap space on local machine." 4144msgid "Check swap space on local machine."
5001msgstr "Vérifie l'espace swap sur la machine locale." 4145msgstr "Vérifie l'espace swap sur la machine locale."
5002 4146
5003#: plugins/check_swap.c:535
5004msgid "" 4147msgid ""
5005"Exit with WARNING status if less than INTEGER bytes of swap space are free" 4148"Exit with WARNING status if less than INTEGER bytes of swap space are free"
5006msgstr "" 4149msgstr ""
5007"Sortir avec un résultat AVERTISSEMENT si moins de X octets de mémoire " 4150"Sortir avec un résultat AVERTISSEMENT si moins de X octets de mémoire "
5008"virtuelle sont libres" 4151"virtuelle sont libres"
5009 4152
5010#: plugins/check_swap.c:537
5011msgid "Exit with WARNING status if less than PERCENT of swap space is free" 4153msgid "Exit with WARNING status if less than PERCENT of swap space is free"
5012msgstr "" 4154msgstr ""
5013"Sortir avec un résultat AVERTISSEMENT si moins de X pour cent de mémoire " 4155"Sortir avec un résultat AVERTISSEMENT si moins de X pour cent de mémoire "
5014"virtuelle est libre" 4156"virtuelle est libre"
5015 4157
5016#: plugins/check_swap.c:539
5017msgid "" 4158msgid ""
5018"Exit with CRITICAL status if less than INTEGER bytes of swap space are free" 4159"Exit with CRITICAL status if less than INTEGER bytes of swap space are free"
5019msgstr "" 4160msgstr ""
5020"Sortir avec un résultat CRITIQUE si moins de X octets de mémoire virtuelle " 4161"Sortir avec un résultat CRITIQUE si moins de X octets de mémoire virtuelle "
5021"sont libres" 4162"sont libres"
5022 4163
5023#: plugins/check_swap.c:541 4164msgid "Exit with CRITICAL status if less than PERCENT of swap space is free"
5024msgid "Exit with CRITCAL status if less than PERCENT of swap space is free"
5025msgstr "" 4165msgstr ""
5026"Sortir avec un résultat CRITIQUE si moins de X pour cent de mémoire " 4166"Sortir avec un résultat CRITIQUE si moins de X pour cent de mémoire "
5027"virtuelle est libre" 4167"virtuelle est libre"
5028 4168
5029#: plugins/check_swap.c:543
5030msgid "Conduct comparisons for all swap partitions, one by one" 4169msgid "Conduct comparisons for all swap partitions, one by one"
5031msgstr "Vérifier chacune des partitions de mémoire virtuelle séparément" 4170msgstr "Vérifier chacune des partitions de mémoire virtuelle séparément"
5032 4171
5033#: plugins/check_swap.c:548 4172msgid ""
4173"Resulting state when there is no swap regardless of thresholds. Default:"
4174msgstr ""
4175
4176#, fuzzy
4177msgid ""
4178"Both INTEGER and PERCENT thresholds can be specified, they are all checked."
4179msgstr "Les seuils d'alerte et critiques peuvent être spécifiés avec -w et -c."
4180
5034msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s." 4181msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."
5035msgstr "" 4182msgstr ""
5036"Sur AIX, si -a est spécifié, le plugin utilise lsps -a, sinon il utilise " 4183"Sur AIX, si -a est spécifié, le plugin utilise lsps -a, sinon il utilise "
5037"lsps -s." 4184"lsps -s."
5038 4185
5039#: plugins/check_tcp.c:206
5040msgid "CRITICAL - Generic check_tcp called with unknown service\n" 4186msgid "CRITICAL - Generic check_tcp called with unknown service\n"
5041msgstr "" 4187msgstr ""
5042"CRITIQUE -check_tcp version générique utilisé avec un service inconnu\n" 4188"CRITIQUE -check_tcp version générique utilisé avec un service inconnu\n"
5043 4189
5044#: plugins/check_tcp.c:230
5045msgid "With UDP checks, a send/expect string must be specified." 4190msgid "With UDP checks, a send/expect string must be specified."
5046msgstr "" 4191msgstr ""
5047"Avec la surveillance UDP, une chaîne d'envoi et un chaîne de réponse doit " 4192"Avec la surveillance UDP, une chaîne d'envoi et un chaîne de réponse doit "
5048"être spécifiée." 4193"être spécifiée."
5049 4194
5050#: plugins/check_tcp.c:431
5051msgid "No arguments found" 4195msgid "No arguments found"
5052msgstr "Pas de paramètres" 4196msgstr "Pas de paramètres"
5053 4197
5054#: plugins/check_tcp.c:534
5055msgid "Maxbytes must be a positive integer" 4198msgid "Maxbytes must be a positive integer"
5056msgstr "Maxbytes doit être un entier positif" 4199msgstr "Maxbytes doit être un entier positif"
5057 4200
5058#: plugins/check_tcp.c:552
5059msgid "Refuse must be one of ok, warn, crit" 4201msgid "Refuse must be one of ok, warn, crit"
5060msgstr "Refuse doit être parmis ok, warn, crit" 4202msgstr "Refuse doit être parmis ok, warn, crit"
5061 4203
5062#: plugins/check_tcp.c:562
5063msgid "Mismatch must be one of ok, warn, crit" 4204msgid "Mismatch must be one of ok, warn, crit"
5064msgstr "Mismatch doit être parmis ok, warn, crit" 4205msgstr "Mismatch doit être parmis ok, warn, crit"
5065 4206
5066#: plugins/check_tcp.c:568
5067msgid "Delay must be a positive integer" 4207msgid "Delay must be a positive integer"
5068msgstr "Delay doit être un entier positif" 4208msgstr "Delay doit être un entier positif"
5069 4209
5070#: plugins/check_tcp.c:613
5071msgid "You must provide a server address" 4210msgid "You must provide a server address"
5072msgstr "Vous devez fournir une adresse serveur" 4211msgstr "Vous devez fournir une adresse serveur"
5073 4212
5074#: plugins/check_tcp.c:615
5075msgid "Invalid hostname, address or socket" 4213msgid "Invalid hostname, address or socket"
5076msgstr "Adresse/Nom/Socket invalide" 4214msgstr "Adresse/Nom/Socket invalide"
5077 4215
5078#: plugins/check_tcp.c:629
5079#, c-format 4216#, c-format
5080msgid "" 4217msgid ""
5081"This plugin tests %s connections with the specified host (or unix socket).\n" 4218"This plugin tests %s connections with the specified host (or unix socket).\n"
@@ -5084,400 +4221,351 @@ msgstr ""
5084"Ce plugin teste %s connections avec l'hôte spécifié (ou socket unix).\n" 4221"Ce plugin teste %s connections avec l'hôte spécifié (ou socket unix).\n"
5085"\n" 4222"\n"
5086 4223
5087#: plugins/check_tcp.c:642 4224#, fuzzy
5088msgid "" 4225msgid ""
5089"Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or " 4226"Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send "
5090"quit option" 4227"or quit option"
5091msgstr "" 4228msgstr ""
5092"Permet d'utiliser \\n, \\r, \\t ou \\ dans la chaîne de caractères send ou " 4229"Permet d'utiliser \\n, \\r, \\t ou \\ dans la chaîne de caractères send ou "
5093"quit. Doit être placé avant ces dernières." 4230"quit. Doit être placé avant ces dernières."
5094 4231
5095#: plugins/check_tcp.c:643
5096msgid "Default: nothing added to send, \\r\\n added to end of quit" 4232msgid "Default: nothing added to send, \\r\\n added to end of quit"
5097msgstr "" 4233msgstr ""
5098"Par défaut: Rien n'est ajouté à send, \\r\\n est ajouté à la fin de quit" 4234"Par défaut: Rien n'est ajouté à send, \\r\\n est ajouté à la fin de quit"
5099 4235
5100#: plugins/check_tcp.c:645
5101msgid "String to send to the server" 4236msgid "String to send to the server"
5102msgstr "Chaîne de caractères à envoyer au serveur" 4237msgstr "Chaîne de caractères à envoyer au serveur"
5103 4238
5104#: plugins/check_tcp.c:647
5105msgid "String to expect in server response" 4239msgid "String to expect in server response"
5106msgstr "Chaîne de caractères à attendre en réponse" 4240msgstr "Chaîne de caractères à attendre en réponse"
5107 4241
5108#: plugins/check_tcp.c:647
5109msgid "(may be repeated)" 4242msgid "(may be repeated)"
5110msgstr "(peut être utilisé plusieurs fois)" 4243msgstr "(peut être utilisé plusieurs fois)"
5111 4244
5112#: plugins/check_tcp.c:649
5113msgid "All expect strings need to occur in server response. Default is any" 4245msgid "All expect strings need to occur in server response. Default is any"
5114msgstr "" 4246msgstr ""
5115"Toutes les chaînes attendus (expect) doivent être repérés dans la réponse. " 4247"Toutes les chaînes attendus (expect) doivent être repérés dans la réponse. "
5116"Par défaut, n'importe laquelle suffit." 4248"Par défaut, n'importe laquelle suffit."
5117 4249
5118#: plugins/check_tcp.c:651
5119msgid "String to send server to initiate a clean close of the connection" 4250msgid "String to send server to initiate a clean close of the connection"
5120msgstr "Chaîne de caractères à envoyer pour fermer gracieusement la connection" 4251msgstr "Chaîne de caractères à envoyer pour fermer gracieusement la connection"
5121 4252
5122#: plugins/check_tcp.c:653
5123msgid "Accept TCP refusals with states ok, warn, crit (default: crit)" 4253msgid "Accept TCP refusals with states ok, warn, crit (default: crit)"
5124msgstr "" 4254msgstr ""
5125 4255
5126#: plugins/check_tcp.c:655
5127msgid "" 4256msgid ""
5128"Accept expected string mismatches with states ok, warn, crit (default: warn)" 4257"Accept expected string mismatches with states ok, warn, crit (default: warn)"
5129msgstr "" 4258msgstr ""
5130 4259
5131#: plugins/check_tcp.c:657
5132msgid "Hide output from TCP socket" 4260msgid "Hide output from TCP socket"
5133msgstr "Cacher la réponse provenant du socket TCP" 4261msgstr "Cacher la réponse provenant du socket TCP"
5134 4262
5135#: plugins/check_tcp.c:659
5136msgid "Close connection once more than this number of bytes are received" 4263msgid "Close connection once more than this number of bytes are received"
5137msgstr "" 4264msgstr ""
5138 4265
5139#: plugins/check_tcp.c:661
5140msgid "Seconds to wait between sending string and polling for response" 4266msgid "Seconds to wait between sending string and polling for response"
5141msgstr "" 4267msgstr ""
5142 4268
5143#: plugins/check_tcp.c:666
5144msgid "1st is #days for warning, 2nd is critical (if not specified - 0)." 4269msgid "1st is #days for warning, 2nd is critical (if not specified - 0)."
5145msgstr "" 4270msgstr ""
5146 4271
5147#: plugins/check_tcp.c:668
5148msgid "Use SSL for the connection." 4272msgid "Use SSL for the connection."
5149msgstr "" 4273msgstr ""
5150 4274
5151#: plugins/check_time.c:102 4275#, fuzzy
4276msgid "SSL server_name"
4277msgstr "Nom d'utilisateur SNMPv3"
4278
5152#, c-format 4279#, c-format
5153msgid "TIME UNKNOWN - could not connect to server %s, port %d\n" 4280msgid "TIME UNKNOWN - could not connect to server %s, port %d\n"
5154msgstr "TEMPS INCONNU - impossible de se connecter au serveur %s, au port %d\n" 4281msgstr "TEMPS INCONNU - impossible de se connecter au serveur %s, au port %d\n"
5155 4282
5156#: plugins/check_time.c:115
5157#, c-format 4283#, c-format
5158msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n" 4284msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n"
5159msgstr "" 4285msgstr ""
5160"TEMPS INCONNU - impossible d'envoyer une requête UDP au serveur %s, au port " 4286"TEMPS INCONNU - impossible d'envoyer une requête UDP au serveur %s, au port "
5161"%d\n" 4287"%d\n"
5162 4288
5163#: plugins/check_time.c:139
5164#, c-format 4289#, c-format
5165msgid "TIME UNKNOWN - no data received from server %s, port %d\n" 4290msgid "TIME UNKNOWN - no data received from server %s, port %d\n"
5166msgstr "TEMPS INCONNU - pas de données reçues du serveur %s, du port %d\n" 4291msgstr "TEMPS INCONNU - pas de données reçues du serveur %s, du port %d\n"
5167 4292
5168#: plugins/check_time.c:152
5169#, c-format 4293#, c-format
5170msgid "TIME %s - %d second response time|%s\n" 4294msgid "TIME %s - %d second response time|%s\n"
5171msgstr "TEMPS %s - %d secondes de temps de réponse|%s\n" 4295msgstr "TEMPS %s - %d secondes de temps de réponse|%s\n"
5172 4296
5173#: plugins/check_time.c:170
5174#, c-format 4297#, c-format
5175msgid "TIME %s - %lu second time difference|%s %s\n" 4298msgid "TIME %s - %lu second time difference|%s %s\n"
5176msgstr "TEMPS %s - %lu secondes de différence|%s %s\n" 4299msgstr "TEMPS %s - %lu secondes de différence|%s %s\n"
5177 4300
5178#: plugins/check_time.c:254
5179msgid "Warning thresholds must be a positive integer" 4301msgid "Warning thresholds must be a positive integer"
5180msgstr "Les seuils d'avertissement doivent être un entier positif" 4302msgstr "Les seuils d'avertissement doivent être un entier positif"
5181 4303
5182#: plugins/check_time.c:273
5183msgid "Critical thresholds must be a positive integer" 4304msgid "Critical thresholds must be a positive integer"
5184msgstr "Les seuils critiques doivent être un entier positif" 4305msgstr "Les seuils critiques doivent être un entier positif"
5185 4306
5186#: plugins/check_time.c:339
5187msgid "This plugin will check the time on the specified host." 4307msgid "This plugin will check the time on the specified host."
5188msgstr "Ce plugin va vérifier l'heure sur l'hôte spécifié." 4308msgstr "Ce plugin va vérifier l'heure sur l'hôte spécifié."
5189 4309
5190#: plugins/check_time.c:351
5191msgid "Use UDP to connect, not TCP" 4310msgid "Use UDP to connect, not TCP"
5192msgstr "" 4311msgstr ""
5193 4312
5194#: plugins/check_time.c:353
5195msgid "Time difference (sec.) necessary to result in a warning status" 4313msgid "Time difference (sec.) necessary to result in a warning status"
5196msgstr "" 4314msgstr ""
5197 4315
5198#: plugins/check_time.c:355
5199msgid "Time difference (sec.) necessary to result in a critical status" 4316msgid "Time difference (sec.) necessary to result in a critical status"
5200msgstr "" 4317msgstr ""
5201 4318
5202#: plugins/check_time.c:357
5203msgid "Response time (sec.) necessary to result in warning status" 4319msgid "Response time (sec.) necessary to result in warning status"
5204msgstr "" 4320msgstr ""
5205 4321
5206#: plugins/check_time.c:359
5207msgid "Response time (sec.) necessary to result in critical status" 4322msgid "Response time (sec.) necessary to result in critical status"
5208msgstr "" 4323msgstr ""
5209 4324
5210#: plugins/check_ups.c:144
5211msgid "On Battery, Low Battery" 4325msgid "On Battery, Low Battery"
5212msgstr "Sur Batterie, Batterie faible" 4326msgstr "Sur Batterie, Batterie faible"
5213 4327
5214#: plugins/check_ups.c:149
5215msgid "Online" 4328msgid "Online"
5216msgstr "En marche" 4329msgstr "En marche"
5217 4330
5218#: plugins/check_ups.c:152
5219msgid "On Battery" 4331msgid "On Battery"
5220msgstr "Sur Batterie" 4332msgstr "Sur Batterie"
5221 4333
5222#: plugins/check_ups.c:156
5223msgid ", Low Battery" 4334msgid ", Low Battery"
5224msgstr ", Batterie faible" 4335msgstr ", Batterie faible"
5225 4336
5226#: plugins/check_ups.c:160
5227msgid ", Calibrating" 4337msgid ", Calibrating"
5228msgstr ", Calibration" 4338msgstr ", Calibration"
5229 4339
5230#: plugins/check_ups.c:163
5231msgid ", Replace Battery" 4340msgid ", Replace Battery"
5232msgstr ", Remplacer la batterie" 4341msgstr ", Remplacer la batterie"
5233 4342
5234#: plugins/check_ups.c:167
5235msgid ", On Bypass" 4343msgid ", On Bypass"
5236msgstr ", Sur Secteur" 4344msgstr ", Sur Secteur"
5237 4345
5238#: plugins/check_ups.c:170
5239msgid ", Overload" 4346msgid ", Overload"
5240msgstr ", Surcharge" 4347msgstr ", Surcharge"
5241 4348
5242#: plugins/check_ups.c:173
5243msgid ", Trimming" 4349msgid ", Trimming"
5244msgstr ", En Test" 4350msgstr ", En Test"
5245 4351
5246#: plugins/check_ups.c:176
5247msgid ", Boosting" 4352msgid ", Boosting"
5248msgstr "" 4353msgstr ""
5249 4354
5250#: plugins/check_ups.c:179
5251msgid ", Charging" 4355msgid ", Charging"
5252msgstr ", En charge" 4356msgstr ", En charge"
5253 4357
5254#: plugins/check_ups.c:182
5255msgid ", Discharging" 4358msgid ", Discharging"
5256msgstr ", Déchargement" 4359msgstr ", Déchargement"
5257 4360
5258#: plugins/check_ups.c:185
5259msgid ", Unknown" 4361msgid ", Unknown"
5260msgstr ", Inconnu" 4362msgstr ", Inconnu"
5261 4363
5262#: plugins/check_ups.c:324
5263msgid "UPS does not support any available options\n" 4364msgid "UPS does not support any available options\n"
5264msgstr "L'UPS ne supporte aucune des options disponibles\n" 4365msgstr "L'UPS ne supporte aucune des options disponibles\n"
5265 4366
5266#: plugins/check_ups.c:348 plugins/check_ups.c:411
5267msgid "Invalid response received from host" 4367msgid "Invalid response received from host"
5268msgstr "Réponse invalide reçue de l'hôte" 4368msgstr "Réponse invalide reçue de l'hôte"
5269 4369
5270#: plugins/check_ups.c:420 4370msgid "UPS name to long for buffer"
4371msgstr ""
4372
5271#, c-format 4373#, c-format
5272msgid "CRITICAL - no such UPS '%s' on that host\n" 4374msgid "CRITICAL - no such UPS '%s' on that host\n"
5273msgstr "CRITIQUE - pas d'UPS '%s' sur cet hôte\n" 4375msgstr "CRITIQUE - pas d'UPS '%s' sur cet hôte\n"
5274 4376
5275#: plugins/check_ups.c:430
5276msgid "CRITICAL - UPS data is stale" 4377msgid "CRITICAL - UPS data is stale"
5277msgstr "CRITIQUE - les données de l'ups ne sont plus valables" 4378msgstr "CRITIQUE - les données de l'ups ne sont plus valables"
5278 4379
5279#: plugins/check_ups.c:435
5280#, c-format 4380#, c-format
5281msgid "Unknown error: %s\n" 4381msgid "Unknown error: %s\n"
5282msgstr "Erreur inconnue: %s\n" 4382msgstr "Erreur inconnue: %s\n"
5283 4383
5284#: plugins/check_ups.c:442
5285msgid "Error: unable to parse variable" 4384msgid "Error: unable to parse variable"
5286msgstr "Erreur: impossible de lire la variable" 4385msgstr "Erreur: impossible de lire la variable"
5287 4386
5288#: plugins/check_ups.c:549
5289msgid "Unrecognized UPS variable" 4387msgid "Unrecognized UPS variable"
5290msgstr "Variable d'UPS non reconnue" 4388msgstr "Variable d'UPS non reconnue"
5291 4389
5292#: plugins/check_ups.c:587
5293msgid "Error : no UPS indicated" 4390msgid "Error : no UPS indicated"
5294msgstr "Erreur: pas d'UPS indiqué" 4391msgstr "Erreur: pas d'UPS indiqué"
5295 4392
5296#: plugins/check_ups.c:607
5297msgid "" 4393msgid ""
5298"This plugin tests the UPS service on the specified host. Network UPS Tools" 4394"This plugin tests the UPS service on the specified host. Network UPS Tools"
5299msgstr "Ce plugin teste le service UPS sur l'hôte spécifié. Network UPS Tools" 4395msgstr "Ce plugin teste le service UPS sur l'hôte spécifié. Network UPS Tools"
5300 4396
5301#: plugins/check_ups.c:608
5302msgid "from www.networkupstools.org must be running for this plugin to work." 4397msgid "from www.networkupstools.org must be running for this plugin to work."
5303msgstr "" 4398msgstr ""
5304"de www.networkupstools.org doit s'exécuter sur l'hôte pour que ce plugin " 4399"de www.networkupstools.org doit s'exécuter sur l'hôte pour que ce plugin "
5305"fonctionne." 4400"fonctionne."
5306 4401
5307#: plugins/check_ups.c:620
5308msgid "Name of UPS" 4402msgid "Name of UPS"
5309msgstr "" 4403msgstr ""
5310 4404
5311#: plugins/check_ups.c:622
5312msgid "Output of temperatures in Celsius" 4405msgid "Output of temperatures in Celsius"
5313msgstr "Affichage des températures en Celsius" 4406msgstr "Affichage des températures en Celsius"
5314 4407
5315#: plugins/check_ups.c:624
5316msgid "Valid values for STRING are" 4408msgid "Valid values for STRING are"
5317msgstr "Les variables valides pour STRING sont" 4409msgstr "Les variables valides pour STRING sont"
5318 4410
5319#: plugins/check_ups.c:635
5320msgid "" 4411msgid ""
5321"This plugin attempts to determine the status of a UPS (Uninterruptible Power" 4412"This plugin attempts to determine the status of a UPS (Uninterruptible Power"
5322msgstr "" 4413msgstr ""
5323 4414
5324#: plugins/check_ups.c:636
5325msgid "" 4415msgid ""
5326"Supply) on a local or remote host. If the UPS is online or calibrating, the" 4416"Supply) on a local or remote host. If the UPS is online or calibrating, the"
5327msgstr "" 4417msgstr ""
5328 4418
5329#: plugins/check_ups.c:637
5330msgid "" 4419msgid ""
5331"plugin will return an OK state. If the battery is on it will return a WARNING" 4420"plugin will return an OK state. If the battery is on it will return a WARNING"
5332msgstr "" 4421msgstr ""
5333 4422
5334#: plugins/check_ups.c:638
5335msgid "" 4423msgid ""
5336"state. If the UPS is off or has a low battery the plugin will return a " 4424"state. If the UPS is off or has a low battery the plugin will return a "
5337"CRITICAL" 4425"CRITICAL"
5338msgstr "" 4426msgstr ""
5339 4427
5340#: plugins/check_ups.c:643
5341msgid "" 4428msgid ""
5342"You may also specify a variable to check (such as temperature, utility " 4429"You may also specify a variable to check (such as temperature, utility "
5343"voltage," 4430"voltage,"
5344msgstr "" 4431msgstr ""
5345 4432
5346#: plugins/check_ups.c:644
5347msgid "" 4433msgid ""
5348"battery load, etc.) as well as warning and critical thresholds for the value" 4434"battery load, etc.) as well as warning and critical thresholds for the value"
5349msgstr "" 4435msgstr ""
5350 4436
5351#: plugins/check_ups.c:645
5352msgid "" 4437msgid ""
5353"of that variable. If the remote host has multiple UPS that are being " 4438"of that variable. If the remote host has multiple UPS that are being "
5354"monitored" 4439"monitored"
5355msgstr "" 4440msgstr ""
5356 4441
5357#: plugins/check_ups.c:646
5358msgid "you will have to use the --ups option to specify which UPS to check." 4442msgid "you will have to use the --ups option to specify which UPS to check."
5359msgstr "" 4443msgstr ""
5360 4444
5361#: plugins/check_ups.c:648
5362msgid "" 4445msgid ""
5363"This plugin requires that the UPSD daemon distributed with Russell Kroll's" 4446"This plugin requires that the UPSD daemon distributed with Russell Kroll's"
5364msgstr "" 4447msgstr ""
5365 4448
5366#: plugins/check_ups.c:649
5367msgid "" 4449msgid ""
5368"Network UPS Tools be installed on the remote host. If you do not have the" 4450"Network UPS Tools be installed on the remote host. If you do not have the"
5369msgstr "" 4451msgstr ""
5370 4452
5371#: plugins/check_ups.c:650
5372msgid "package installed on your system, you can download it from" 4453msgid "package installed on your system, you can download it from"
5373msgstr "" 4454msgstr ""
5374 4455
5375#: plugins/check_ups.c:651
5376msgid "http://www.networkupstools.org" 4456msgid "http://www.networkupstools.org"
5377msgstr "" 4457msgstr ""
5378 4458
5379#: plugins/check_users.c:110 4459#, fuzzy, c-format
4460msgid "Could not enumerate RD sessions: %d\n"
4461msgstr "Impossible d'utiliser le protocole version %d\n"
4462
5380#, c-format 4463#, c-format
5381msgid "# users=%d" 4464msgid "# users=%d"
5382msgstr "# utilisateurs=%d" 4465msgstr "# utilisateurs=%d"
5383 4466
5384#: plugins/check_users.c:133
5385msgid "Unable to read output" 4467msgid "Unable to read output"
5386msgstr "Impossible de lire les données en entrée" 4468msgstr "Impossible de lire les données en entrée"
5387 4469
5388#: plugins/check_users.c:140
5389#, c-format 4470#, c-format
5390msgid "USERS %s - %d users currently logged in |%s\n" 4471msgid "USERS %s - %d users currently logged in |%s\n"
5391msgstr "UTILISATEURS %s - %d utilisateurs actuellement connectés sur |%s\n" 4472msgstr "UTILISATEURS %s - %d utilisateurs actuellement connectés sur |%s\n"
5392 4473
5393#: plugins/check_users.c:219
5394msgid "This plugin checks the number of users currently logged in on the local" 4474msgid "This plugin checks the number of users currently logged in on the local"
5395msgstr "" 4475msgstr ""
5396"Ce plugin vérifie le nombre d'utilisateurs actuellement connecté sur le " 4476"Ce plugin vérifie le nombre d'utilisateurs actuellement connecté sur le "
5397"système local" 4477"système local"
5398 4478
5399#: plugins/check_users.c:220
5400msgid "" 4479msgid ""
5401"system and generates an error if the number exceeds the thresholds specified." 4480"system and generates an error if the number exceeds the thresholds specified."
5402msgstr "et génère une erreur si le nombre excède le seuil spécifié." 4481msgstr "et génère une erreur si le nombre excède le seuil spécifié."
5403 4482
5404#: plugins/check_users.c:230
5405msgid "Set WARNING status if more than INTEGER users are logged in" 4483msgid "Set WARNING status if more than INTEGER users are logged in"
5406msgstr "" 4484msgstr ""
5407"Sortir avec un résultat AVERTISSEMENT si plus de INTEGER utilisateurs sont " 4485"Sortir avec un résultat AVERTISSEMENT si plus de INTEGER utilisateurs sont "
5408"connectés" 4486"connectés"
5409 4487
5410#: plugins/check_users.c:232
5411msgid "Set CRITICAL status if more than INTEGER users are logged in" 4488msgid "Set CRITICAL status if more than INTEGER users are logged in"
5412msgstr "" 4489msgstr ""
5413"Sortir avec un résultat CRITIQUE si plus de INTEGER utilisateurs sont " 4490"Sortir avec un résultat CRITIQUE si plus de INTEGER utilisateurs sont "
5414"connectés" 4491"connectés"
5415 4492
5416#: plugins/check_ide_smart.c:256 4493msgid ""
4494"DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."
4495msgstr ""
4496
4497msgid "Nagios-compatible output is now always returned."
4498msgstr ""
4499
4500msgid "SMART commands are broken and have been disabled (See Notes in --help)."
4501msgstr ""
4502
4503msgid ""
4504"DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"
4505msgstr ""
4506
4507#, fuzzy
4508msgid "default and will be removed from future releases."
4509msgstr ""
4510"Note: nslookup est obsolète et pourra être retiré dans les prochaines "
4511"versions."
4512
5417#, c-format 4513#, c-format
5418msgid "CRITICAL - Couldn't open device %s: %s\n" 4514msgid "CRITICAL - Couldn't open device %s: %s\n"
5419msgstr "Critique - Impossible d'ouvrir le périphérique %s: %s\n" 4515msgstr "Critique - Impossible d'ouvrir le périphérique %s: %s\n"
5420 4516
5421#: plugins/check_ide_smart.c:261
5422#, c-format 4517#, c-format
5423msgid "CRITICAL - SMART_CMD_ENABLE\n" 4518msgid "CRITICAL - SMART_CMD_ENABLE\n"
5424msgstr "CRITIQUE - SMART_CMD_ENABLE\n" 4519msgstr "CRITIQUE - SMART_CMD_ENABLE\n"
5425 4520
5426#: plugins/check_ide_smart.c:323 plugins/check_ide_smart.c:350
5427#, c-format 4521#, c-format
5428msgid "CRITICAL - SMART_READ_VALUES: %s\n" 4522msgid "CRITICAL - SMART_READ_VALUES: %s\n"
5429msgstr "CRITIQUE - SMART_READ_VALUES: %s\n" 4523msgstr "CRITIQUE - SMART_READ_VALUES: %s\n"
5430 4524
5431#: plugins/check_ide_smart.c:421
5432#, c-format 4525#, c-format
5433msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n" 4526msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"
5434msgstr "" 4527msgstr ""
5435"CRITIQUE - %d État de pré-panne %c Détecté! %d/%d les tests on échoués.\n" 4528"CRITIQUE - %d État de pré-panne %c Détecté! %d/%d les tests on échoués.\n"
5436 4529
5437#: plugins/check_ide_smart.c:429
5438#, c-format 4530#, c-format
5439msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n" 4531msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"
5440msgstr "" 4532msgstr ""
5441"AVERTISSEMENT - %d État de pré-panne %s Détecté! %d/%d les tests on " 4533"AVERTISSEMENT - %d État de pré-panne %s Détecté! %d/%d les tests on "
5442"échoués.\n" 4534"échoués.\n"
5443 4535
5444#: plugins/check_ide_smart.c:437
5445#, c-format 4536#, c-format
5446msgid "OK - Operational (%d/%d tests passed)\n" 4537msgid "OK - Operational (%d/%d tests passed)\n"
5447msgstr "OK - En fonctionnement (%d/%d les tests on été réussi)\n" 4538msgstr "OK - En fonctionnement (%d/%d les tests on été réussi)\n"
5448 4539
5449#: plugins/check_ide_smart.c:441
5450#, c-format 4540#, c-format
5451msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n" 4541msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n"
5452msgstr "ERREUR - État '%d' inconnu. %d/%d les tests on réussi\n" 4542msgstr "ERREUR - État '%d' inconnu. %d/%d les tests on réussi\n"
5453 4543
5454#: plugins/check_ide_smart.c:474
5455#, c-format 4544#, c-format
5456msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n" 4545msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"
5457msgstr "" 4546msgstr ""
5458"Etat Hors Ligne=%d {%s}, Hors Ligne Auto=%s, Temps avant arrêt=%d minutes\n" 4547"Etat Hors Ligne=%d {%s}, Hors Ligne Auto=%s, Temps avant arrêt=%d minutes\n"
5459 4548
5460#: plugins/check_ide_smart.c:480
5461#, c-format 4549#, c-format
5462msgid "OffLineCapability=%d {%s %s %s}\n" 4550msgid "OffLineCapability=%d {%s %s %s}\n"
5463msgstr "Capacité Hors Ligne=%d {%s %s %s}\n" 4551msgstr "Capacité Hors Ligne=%d {%s %s %s}\n"
5464 4552
5465#: plugins/check_ide_smart.c:486
5466#, c-format 4553#, c-format
5467msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n" 4554msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"
5468msgstr "Révision Smart=%d, Somme de contrôle=%d, Capacité Smart=%d {%s %s}\n" 4555msgstr "Révision Smart=%d, Somme de contrôle=%d, Capacité Smart=%d {%s %s}\n"
5469 4556
5470#: plugins/check_ide_smart.c:508 plugins/check_ide_smart.c:532
5471#, c-format 4557#, c-format
5472msgid "CRITICAL - %s: %s\n" 4558msgid "CRITICAL - %s: %s\n"
5473msgstr "CRITIQUE - %s: %s\n" 4559msgstr "CRITIQUE - %s: %s\n"
5474 4560
5475#: plugins/check_ide_smart.c:553 plugins/check_ide_smart.c:580 4561#, fuzzy, c-format
4562msgid "OK - Command sent (%s)\n"
4563msgstr "Commande: %s\n"
4564
5476#, c-format 4565#, c-format
5477msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n" 4566msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n"
5478msgstr "CRITIQUE - SMART_READ_THRESHOLDS: %s\n" 4567msgstr "CRITIQUE - SMART_READ_THRESHOLDS: %s\n"
5479 4568
5480#: plugins/check_ide_smart.c:599
5481#, c-format 4569#, c-format
5482msgid "" 4570msgid ""
5483"This plugin checks a local hard drive with the (Linux specific) SMART " 4571"This plugin checks a local hard drive with the (Linux specific) SMART "
@@ -5486,41 +4574,39 @@ msgstr ""
5486"Ce plugin vérifie un disque dur local à l'aide de l'interface SMART (pour " 4574"Ce plugin vérifie un disque dur local à l'aide de l'interface SMART (pour "
5487"Linux) [http://smartlinux.sourceforge.net/smart/index.php]." 4575"Linux) [http://smartlinux.sourceforge.net/smart/index.php]."
5488 4576
5489#: plugins/check_ide_smart.c:609
5490msgid "Select device DEVICE" 4577msgid "Select device DEVICE"
5491msgstr "" 4578msgstr ""
5492 4579
5493#: plugins/check_ide_smart.c:610
5494msgid "" 4580msgid ""
5495"Note: if the device is selected with this option, _no_ other options are " 4581"Note: if the device is specified without this option, any further option will"
5496"accepted" 4582msgstr ""
4583
4584msgid "be ignored."
4585msgstr ""
4586
4587msgid ""
4588"The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"
5497msgstr "" 4589msgstr ""
5498 4590
5499#: plugins/check_ide_smart.c:612 4591msgid ""
5500msgid "Perform immediately offline tests" 4592"broken in an underhand manner and have been disabled. You can use smartctl"
5501msgstr "" 4593msgstr ""
5502 4594
5503#: plugins/check_ide_smart.c:614 4595msgid "instead:"
5504msgid "Returns the number of failed tests"
5505msgstr "" 4596msgstr ""
5506 4597
5507#: plugins/check_ide_smart.c:616 4598msgid "-0/--auto-off: use \"smartctl --offlineauto=off\""
5508msgid "Turn on automatic offline tests"
5509msgstr "" 4599msgstr ""
5510 4600
5511#: plugins/check_ide_smart.c:618 4601msgid "-1/--auto-on: use \"smartctl --offlineauto=on\""
5512msgid "Turn off automatic offline tests"
5513msgstr "" 4602msgstr ""
5514 4603
5515#: plugins/check_ide_smart.c:620 4604msgid "-i/--immediate: use \"smartctl --test=offline\""
5516msgid "Output suitable for the monitoring system"
5517msgstr "" 4605msgstr ""
5518 4606
5519#: plugins/negate.c:99
5520msgid "No data returned from command\n" 4607msgid "No data returned from command\n"
5521msgstr "Pas de données reçues de la commande\n" 4608msgstr "Pas de données reçues de la commande\n"
5522 4609
5523#: plugins/negate.c:170
5524msgid "" 4610msgid ""
5525"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) " 4611"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
5526"or integer (0-3)." 4612"or integer (0-3)."
@@ -5528,7 +4614,6 @@ msgstr ""
5528"Le résultat de temps dépassé doit être un nom d'état valide (OK, WARNING, " 4614"Le résultat de temps dépassé doit être un nom d'état valide (OK, WARNING, "
5529"CRITICAL, UNKNOWN) ou un nombre entier (0-3)." 4615"CRITICAL, UNKNOWN) ou un nombre entier (0-3)."
5530 4616
5531#: plugins/negate.c:174
5532msgid "" 4617msgid ""
5533"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer " 4618"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer "
5534"(0-3)." 4619"(0-3)."
@@ -5536,7 +4621,6 @@ msgstr ""
5536"Ok doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou un " 4621"Ok doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou un "
5537"nombre entier (0-3)." 4622"nombre entier (0-3)."
5538 4623
5539#: plugins/negate.c:180
5540msgid "" 4624msgid ""
5541"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4625"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5542"integer (0-3)." 4626"integer (0-3)."
@@ -5544,7 +4628,6 @@ msgstr ""
5544"Warning doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou " 4628"Warning doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou "
5545"un nombre entier (0-3)." 4629"un nombre entier (0-3)."
5546 4630
5547#: plugins/negate.c:185
5548msgid "" 4631msgid ""
5549"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4632"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5550"integer (0-3)." 4633"integer (0-3)."
@@ -5552,7 +4635,6 @@ msgstr ""
5552"Critical doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou " 4635"Critical doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou "
5553"un nombre entier (0-3)." 4636"un nombre entier (0-3)."
5554 4637
5555#: plugins/negate.c:190
5556msgid "" 4638msgid ""
5557"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4639"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5558"integer (0-3)." 4640"integer (0-3)."
@@ -5560,33 +4642,27 @@ msgstr ""
5560"Unknown doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou " 4642"Unknown doit être un nom d'état valide (OK, WARNING, CRITICAL, UNKNOWN) ou "
5561"un nombre entier (0-3)." 4643"un nombre entier (0-3)."
5562 4644
5563#: plugins/negate.c:217
5564msgid "Require path to command" 4645msgid "Require path to command"
5565msgstr "Chemin vers la commande requis" 4646msgstr "Chemin vers la commande requis"
5566 4647
5567#: plugins/negate.c:246
5568msgid "" 4648msgid ""
5569"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)." 4649"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."
5570msgstr "" 4650msgstr ""
5571"Inverse le statut d'un plugin (retourne OK pour CRITIQUE et vice-versa)." 4651"Inverse le statut d'un plugin (retourne OK pour CRITIQUE et vice-versa)."
5572 4652
5573#: plugins/negate.c:247
5574msgid "Additional switches can be used to control which state becomes what." 4653msgid "Additional switches can be used to control which state becomes what."
5575msgstr "" 4654msgstr ""
5576"Des options additionnelles peuvent être utilisées pour contrôler quel état " 4655"Des options additionnelles peuvent être utilisées pour contrôler quel état "
5577"devient quoi." 4656"devient quoi."
5578 4657
5579#: plugins/negate.c:256
5580msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status." 4658msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status."
5581msgstr "" 4659msgstr ""
5582"Utilisez un délai de réponse plus long que celui du plugin afin de conserver " 4660"Utilisez un délai de réponse plus long que celui du plugin afin de conserver "
5583"les résultats CRITIQUE" 4661"les résultats CRITIQUE"
5584 4662
5585#: plugins/negate.c:258
5586msgid "Custom result on Negate timeouts; see below for STATUS definition\n" 4663msgid "Custom result on Negate timeouts; see below for STATUS definition\n"
5587msgstr "" 4664msgstr ""
5588 4665
5589#: plugins/negate.c:264
5590#, c-format 4666#, c-format
5591msgid "" 4667msgid ""
5592" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n" 4668" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n"
@@ -5594,129 +4670,99 @@ msgstr ""
5594" STATUS peut être 'OK', 'WARNING', 'CRITICAL' ou 'UNKNOWN' sans les " 4670" STATUS peut être 'OK', 'WARNING', 'CRITICAL' ou 'UNKNOWN' sans les "
5595"simple\n" 4671"simple\n"
5596 4672
5597#: plugins/negate.c:265
5598#, c-format 4673#, c-format
5599msgid "" 4674msgid ""
5600" quotes. Numeric values are accepted. If nothing is specified, permutes\n" 4675" quotes. Numeric values are accepted. If nothing is specified, permutes\n"
5601msgstr " quotes. Les valeurs numériques sont acceptées. Si rien n'est\n" 4676msgstr " quotes. Les valeurs numériques sont acceptées. Si rien n'est\n"
5602 4677
5603#: plugins/negate.c:266
5604#, c-format 4678#, c-format
5605msgid " OK and CRITICAL.\n" 4679msgid " OK and CRITICAL.\n"
5606msgstr " spécifié, inverse OK et CRITIQUE.\n" 4680msgstr " spécifié, inverse OK et CRITIQUE.\n"
5607 4681
5608#: plugins/negate.c:268
5609#, c-format 4682#, c-format
5610msgid "" 4683msgid ""
5611" Substitute output text as well. Will only substitute text in CAPITALS\n" 4684" Substitute output text as well. Will only substitute text in CAPITALS\n"
5612msgstr "" 4685msgstr ""
5613 4686
5614#: plugins/negate.c:273
5615msgid "Run check_ping and invert result. Must use full path to plugin" 4687msgid "Run check_ping and invert result. Must use full path to plugin"
5616msgstr "" 4688msgstr ""
5617"Execute check_ping et inverse le résultat. Le chemin complet du plug-in doit " 4689"Execute check_ping et inverse le résultat. Le chemin complet du plug-in doit "
5618"être spécifié" 4690"être spécifié"
5619 4691
5620#: plugins/negate.c:275
5621msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL" 4692msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL"
5622msgstr "" 4693msgstr ""
5623"Ceci retournera OK au lieu de AVERTISSEMENT et INCONNU au lieu de CRITIQUE" 4694"Ceci retournera OK au lieu de AVERTISSEMENT et INCONNU au lieu de CRITIQUE"
5624 4695
5625#: plugins/negate.c:278
5626msgid "" 4696msgid ""
5627"This plugin is a wrapper to take the output of another plugin and invert it." 4697"This plugin is a wrapper to take the output of another plugin and invert it."
5628msgstr "" 4698msgstr ""
5629"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et " 4699"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et "
5630"l'inverse." 4700"l'inverse."
5631 4701
5632#: plugins/negate.c:279
5633msgid "The full path of the plugin must be provided." 4702msgid "The full path of the plugin must be provided."
5634msgstr "Le chemin complet du plugin doit être spécifié." 4703msgstr "Le chemin complet du plugin doit être spécifié."
5635 4704
5636#: plugins/negate.c:280
5637msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL." 4705msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL."
5638msgstr "Si le plugin executé retourne OK, l'adaptateur retournera CRITIQUE." 4706msgstr "Si le plugin executé retourne OK, l'adaptateur retournera CRITIQUE."
5639 4707
5640#: plugins/negate.c:281
5641msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK." 4708msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK."
5642msgstr "Si le plugin executé retourne CRITIQUE, l'adaptateur retournera OK." 4709msgstr "Si le plugin executé retourne CRITIQUE, l'adaptateur retournera OK."
5643 4710
5644#: plugins/negate.c:282
5645msgid "Otherwise, the output state of the wrapped plugin is unchanged." 4711msgid "Otherwise, the output state of the wrapped plugin is unchanged."
5646msgstr "Autrement, l'état du plugin executé reste inchangé." 4712msgstr "Autrement, l'état du plugin executé reste inchangé."
5647 4713
5648#: plugins/negate.c:284
5649msgid "" 4714msgid ""
5650"Using timeout-result, it is possible to override the timeout behaviour or a" 4715"Using timeout-result, it is possible to override the timeout behaviour or a"
5651msgstr "" 4716msgstr ""
5652 4717
5653#: plugins/negate.c:285
5654msgid "plugin by setting the negate timeout a bit lower." 4718msgid "plugin by setting the negate timeout a bit lower."
5655msgstr "" 4719msgstr ""
5656 4720
5657#: plugins/netutils.c:49
5658#, c-format 4721#, c-format
5659msgid "%s - Socket timeout after %d seconds\n" 4722msgid "%s - Socket timeout after %d seconds\n"
5660msgstr "%s - Le socket n'a pas répondu dans les %d secondes\n" 4723msgstr "%s - Le socket n'a pas répondu dans les %d secondes\n"
5661 4724
5662#: plugins/netutils.c:51
5663#, c-format 4725#, c-format
5664msgid "%s - Abnormal timeout after %d seconds\n" 4726msgid "%s - Abnormal timeout after %d seconds\n"
5665msgstr "%s - Dépassement anormal du temps de réponse après %d secondes\n" 4727msgstr "%s - Dépassement anormal du temps de réponse après %d secondes\n"
5666 4728
5667#: plugins/netutils.c:79 plugins/netutils.c:281
5668msgid "Send failed" 4729msgid "Send failed"
5669msgstr "L'envoi à échoué" 4730msgstr "L'envoi à échoué"
5670 4731
5671#: plugins/netutils.c:96 plugins/netutils.c:296
5672msgid "No data was received from host!" 4732msgid "No data was received from host!"
5673msgstr "Pas de données reçues de l'hôte!" 4733msgstr "Pas de données reçues de l'hôte!"
5674 4734
5675#: plugins/netutils.c:204 plugins/netutils.c:240
5676msgid "Socket creation failed" 4735msgid "Socket creation failed"
5677msgstr "La création du socket à échoué " 4736msgstr "La création du socket à échoué "
5678 4737
5679#: plugins/netutils.c:233
5680msgid "Supplied path too long unix domain socket" 4738msgid "Supplied path too long unix domain socket"
5681msgstr "Le chemin fourni est trop long pour un socket unix" 4739msgstr "Le chemin fourni est trop long pour un socket unix"
5682 4740
5683#: plugins/netutils.c:305
5684msgid "Receive failed" 4741msgid "Receive failed"
5685msgstr "La réception à échoué" 4742msgstr "La réception à échoué"
5686 4743
5687#: plugins/netutils.c:331 plugins-root/check_dhcp.c:1342
5688#, c-format 4744#, c-format
5689msgid "Invalid hostname/address - %s" 4745msgid "Invalid hostname/address - %s"
5690msgstr "Adresse/Nom invalide - %s" 4746msgstr "Adresse/Nom invalide - %s"
5691 4747
5692#: plugins/popen.c:142
5693msgid "Could not malloc argv array in popen()" 4748msgid "Could not malloc argv array in popen()"
5694msgstr "Impossible de réallouer un tableau pour les paramètres dans popen()" 4749msgstr "Impossible de réallouer un tableau pour les paramètres dans popen()"
5695 4750
5696#: plugins/popen.c:152
5697msgid "CRITICAL - You need more args!!!" 4751msgid "CRITICAL - You need more args!!!"
5698msgstr "CRITIQUE - Vous devez spécifier plus d'arguments!!!" 4752msgstr "CRITIQUE - Vous devez spécifier plus d'arguments!!!"
5699 4753
5700#: plugins/popen.c:209
5701msgid "Cannot catch SIGCHLD" 4754msgid "Cannot catch SIGCHLD"
5702msgstr "impossible d'obtenir le signal SIGCHLD" 4755msgstr "impossible d'obtenir le signal SIGCHLD"
5703 4756
5704#: plugins/popen.c:304
5705#, c-format 4757#, c-format
5706msgid "CRITICAL - Plugin timed out after %d seconds\n" 4758msgid "CRITICAL - Plugin timed out after %d seconds\n"
5707msgstr "CRITIQUE - Le plugin n'as pas répondu dans les %d secondes\n" 4759msgstr "CRITIQUE - Le plugin n'as pas répondu dans les %d secondes\n"
5708 4760
5709#: plugins/popen.c:307
5710msgid "CRITICAL - popen timeout received, but no child process" 4761msgid "CRITICAL - popen timeout received, but no child process"
5711msgstr "" 4762msgstr ""
5712"CRITIQUE - le temps d'attente à été dépassé dans la fonction popen, mais il " 4763"CRITIQUE - le temps d'attente à été dépassé dans la fonction popen, mais il "
5713"n'y a pas de processus fils" 4764"n'y a pas de processus fils"
5714 4765
5715#: plugins/popen.c:323
5716msgid "sysconf error for _SC_OPEN_MAX"
5717msgstr ""
5718
5719#: plugins/urlize.c:130
5720#, c-format 4766#, c-format
5721msgid "" 4767msgid ""
5722"%s UNKNOWN - No data received from host\n" 4768"%s UNKNOWN - No data received from host\n"
@@ -5725,7 +4771,6 @@ msgstr ""
5725"%s INCONNU - Pas de données reçues de l'hôte\n" 4771"%s INCONNU - Pas de données reçues de l'hôte\n"
5726"Commande: %s</A>\n" 4772"Commande: %s</A>\n"
5727 4773
5728#: plugins/urlize.c:169
5729#, fuzzy 4774#, fuzzy
5730msgid "" 4775msgid ""
5731"This plugin wraps the text output of another command (plugin) in HTML <A>" 4776"This plugin wraps the text output of another command (plugin) in HTML <A>"
@@ -5733,66 +4778,51 @@ msgstr ""
5733"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et " 4778"Ce plugin est un adaptateur qui prends l'état d'un autre plug-in et "
5734"l'inverse." 4779"l'inverse."
5735 4780
5736#: plugins/urlize.c:170
5737msgid "" 4781msgid ""
5738"tags, thus displaying the child plugin's output as a clickable link in " 4782"tags, thus displaying the child plugin's output as a clickable link in "
5739"compatible" 4783"compatible"
5740msgstr "" 4784msgstr ""
5741 4785
5742#: plugins/urlize.c:171
5743msgid "" 4786msgid ""
5744"monitoring status screen. This plugin returns the status of the invoked " 4787"monitoring status screen. This plugin returns the status of the invoked "
5745"plugin." 4788"plugin."
5746msgstr "" 4789msgstr ""
5747 4790
5748#: plugins/urlize.c:181
5749msgid "" 4791msgid ""
5750"Pay close attention to quoting to ensure that the shell passes the expected" 4792"Pay close attention to quoting to ensure that the shell passes the expected"
5751msgstr "" 4793msgstr ""
5752 4794
5753#: plugins/urlize.c:182
5754msgid "data to the plugin. For example, in:" 4795msgid "data to the plugin. For example, in:"
5755msgstr "" 4796msgstr ""
5756 4797
5757#: plugins/urlize.c:183
5758msgid "urlize http://example.com/ check_http -H example.com -r 'two words'" 4798msgid "urlize http://example.com/ check_http -H example.com -r 'two words'"
5759msgstr "" 4799msgstr ""
5760 4800
5761#: plugins/urlize.c:184
5762msgid "the shell will remove the single quotes and urlize will see:" 4801msgid "the shell will remove the single quotes and urlize will see:"
5763msgstr "" 4802msgstr ""
5764 4803
5765#: plugins/urlize.c:185
5766msgid "urlize http://example.com/ check_http -H example.com -r two words" 4804msgid "urlize http://example.com/ check_http -H example.com -r two words"
5767msgstr "" 4805msgstr ""
5768 4806
5769#: plugins/urlize.c:186
5770msgid "You probably want:" 4807msgid "You probably want:"
5771msgstr "" 4808msgstr ""
5772 4809
5773#: plugins/urlize.c:187
5774msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\"" 4810msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\""
5775msgstr "" 4811msgstr ""
5776 4812
5777#: plugins/utils.c:174
5778#, c-format
5779msgid "%s - Plugin timed out after %d seconds\n"
5780msgstr "%s - Le plugin n'as pas répondu dans les %d secondes\n"
5781
5782#: plugins/utils.c:469
5783msgid "failed realloc in strpcpy\n" 4813msgid "failed realloc in strpcpy\n"
5784msgstr "La fonction realloc à échoué dans strpcpy\n" 4814msgstr "La fonction realloc à échoué dans strpcpy\n"
5785 4815
5786#: plugins/utils.c:511
5787msgid "failed malloc in strscat\n" 4816msgid "failed malloc in strscat\n"
5788msgstr "La fonction malloc à échoué dans strscat\n" 4817msgstr "La fonction malloc à échoué dans strscat\n"
5789 4818
5790#: plugins/utils.c:531
5791#, fuzzy 4819#, fuzzy
5792msgid "failed malloc in xvasprintf\n" 4820msgid "failed malloc in xvasprintf\n"
5793msgstr "La fonction malloc à échoué dans strscat\n" 4821msgstr "La fonction malloc à échoué dans strscat\n"
5794 4822
5795#: plugins/utils.h:137 4823msgid "sysconf error for _SC_OPEN_MAX\n"
4824msgstr ""
4825
5796#, c-format 4826#, c-format
5797msgid "" 4827msgid ""
5798" %s (-h | --help) for detailed help\n" 4828" %s (-h | --help) for detailed help\n"
@@ -5801,7 +4831,6 @@ msgstr ""
5801" %s (-h | --help) pour l'aide détaillée\n" 4831" %s (-h | --help) pour l'aide détaillée\n"
5802" %s (-V | --version) pour les informations relative à la version\n" 4832" %s (-V | --version) pour les informations relative à la version\n"
5803 4833
5804#: plugins/utils.h:141
5805msgid "" 4834msgid ""
5806"\n" 4835"\n"
5807"Options:\n" 4836"Options:\n"
@@ -5817,7 +4846,6 @@ msgstr ""
5817" -V, --version\n" 4846" -V, --version\n"
5818" Afficher les informations relative à la version\n" 4847" Afficher les informations relative à la version\n"
5819 4848
5820#: plugins/utils.h:148
5821#, c-format 4849#, c-format
5822msgid "" 4850msgid ""
5823" -H, --hostname=ADDRESS\n" 4851" -H, --hostname=ADDRESS\n"
@@ -5830,7 +4858,6 @@ msgstr ""
5830" -%c, --port=INTEGER\n" 4858" -%c, --port=INTEGER\n"
5831" Numéro de port (défaut: %s)\n" 4859" Numéro de port (défaut: %s)\n"
5832 4860
5833#: plugins/utils.h:154
5834msgid "" 4861msgid ""
5835" -4, --use-ipv4\n" 4862" -4, --use-ipv4\n"
5836" Use IPv4 connection\n" 4863" Use IPv4 connection\n"
@@ -5842,18 +4869,16 @@ msgstr ""
5842" -6, --use-ipv6\n" 4869" -6, --use-ipv6\n"
5843" Utiliser une connection IPv6\n" 4870" Utiliser une connection IPv6\n"
5844 4871
5845#: plugins/utils.h:160
5846#, fuzzy 4872#, fuzzy
5847msgid "" 4873msgid ""
5848" -v, --verbose\n" 4874" -v, --verbose\n"
5849" Show details for command-line debugging (output may be truncated by\n" 4875" Show details for command-line debugging (output may be truncated by\n"
5850"\t\tthe monitoring system)\n" 4876" the monitoring system)\n"
5851msgstr "" 4877msgstr ""
5852" -v, --verbose\n" 4878" -v, --verbose\n"
5853" Affiche les informations de déboguage en ligne de commande (Nagios peut " 4879" Affiche les informations de déboguage en ligne de commande (Nagios peut "
5854"tronquer la sortie)\n" 4880"tronquer la sortie)\n"
5855 4881
5856#: plugins/utils.h:165
5857msgid "" 4882msgid ""
5858" -w, --warning=DOUBLE\n" 4883" -w, --warning=DOUBLE\n"
5859" Response time to result in warning status (seconds)\n" 4884" Response time to result in warning status (seconds)\n"
@@ -5865,7 +4890,6 @@ msgstr ""
5865" -c, --critical=DOUBLE\n" 4890" -c, --critical=DOUBLE\n"
5866" Temps de réponse résultant en un état critique (secondes)\n" 4891" Temps de réponse résultant en un état critique (secondes)\n"
5867 4892
5868#: plugins/utils.h:171
5869msgid "" 4893msgid ""
5870" -w, --warning=RANGE\n" 4894" -w, --warning=RANGE\n"
5871" Warning range (format: start:end). Alert if outside this range\n" 4895" Warning range (format: start:end). Alert if outside this range\n"
@@ -5878,7 +4902,6 @@ msgstr ""
5878" -c, --critical=RANGE\n" 4902" -c, --critical=RANGE\n"
5879" Seuil critique\n" 4903" Seuil critique\n"
5880 4904
5881#: plugins/utils.h:177
5882#, c-format 4905#, c-format
5883msgid "" 4906msgid ""
5884" -t, --timeout=INTEGER\n" 4907" -t, --timeout=INTEGER\n"
@@ -5887,7 +4910,14 @@ msgstr ""
5887" -t, --timeout=INTEGER\n" 4910" -t, --timeout=INTEGER\n"
5888" Délais de connection en secondes (défaut: %d)\n" 4911" Délais de connection en secondes (défaut: %d)\n"
5889 4912
5890#: plugins/utils.h:182 4913#, fuzzy, c-format
4914msgid ""
4915" -t, --timeout=INTEGER\n"
4916" Seconds before plugin times out (default: %d)\n"
4917msgstr ""
4918" -t, --timeout=INTEGER\n"
4919" Délais de connection en secondes (défaut: %d)\n"
4920
5891#, fuzzy 4921#, fuzzy
5892msgid "" 4922msgid ""
5893" --extra-opts=[section][@file]\n" 4923" --extra-opts=[section][@file]\n"
@@ -5900,7 +4930,6 @@ msgstr ""
5900" https://www.monitoring-plugins.org/doc/extra-opts.html\n" 4930" https://www.monitoring-plugins.org/doc/extra-opts.html\n"
5901" pour les instructions et examples.\n" 4931" pour les instructions et examples.\n"
5902 4932
5903#: plugins/utils.h:190
5904#, fuzzy 4933#, fuzzy
5905msgid "" 4934msgid ""
5906" See:\n" 4935" See:\n"
@@ -5912,7 +4941,6 @@ msgstr ""
5912"html#THRESHOLDFORMAT\n" 4941"html#THRESHOLDFORMAT\n"
5913" pour le format et examples des seuils (THRESHOLD).\n" 4942" pour le format et examples des seuils (THRESHOLD).\n"
5914 4943
5915#: plugins/utils.h:195
5916#, fuzzy 4944#, fuzzy
5917msgid "" 4945msgid ""
5918"\n" 4946"\n"
@@ -5922,14 +4950,12 @@ msgid ""
5922"\n" 4950"\n"
5923msgstr "" 4951msgstr ""
5924"\n" 4952"\n"
5925"Envoyez un email à help@monitoring-plugins.org si vous avez des " 4953"Envoyez un email à help@monitoring-plugins.org si vous avez des questions\n"
5926"questions\n"
5927"reliées à l'utilisation de ce logiciel. Pour envoyer des patches ou suggérer " 4954"reliées à l'utilisation de ce logiciel. Pour envoyer des patches ou suggérer "
5928"des\n" 4955"des\n"
5929"améliorations, envoyez un email à devel@monitoring-plugins.org\n" 4956"améliorations, envoyez un email à devel@monitoring-plugins.org\n"
5930"\n" 4957"\n"
5931 4958
5932#: plugins/utils.h:200
5933#, fuzzy 4959#, fuzzy
5934msgid "" 4960msgid ""
5935"\n" 4961"\n"
@@ -5943,25 +4969,21 @@ msgstr ""
5943"des copies des plugins selon les termes de la GNU General Public License.\n" 4969"des copies des plugins selon les termes de la GNU General Public License.\n"
5944"Pour de plus ample informations, voir le fichier COPYING.\n" 4970"Pour de plus ample informations, voir le fichier COPYING.\n"
5945 4971
5946#: plugins-root/check_dhcp.c:320
5947#, c-format 4972#, c-format
5948msgid "Error: Could not get hardware address of interface '%s'\n" 4973msgid "Error: Could not get hardware address of interface '%s'\n"
5949msgstr "" 4974msgstr ""
5950"Erreur: Impossible d'obtenir l'adresse matérielle pour l'interface '%s'\n" 4975"Erreur: Impossible d'obtenir l'adresse matérielle pour l'interface '%s'\n"
5951 4976
5952#: plugins-root/check_dhcp.c:342
5953#, c-format 4977#, c-format
5954msgid "Error: if_nametoindex error - %s.\n" 4978msgid "Error: if_nametoindex error - %s.\n"
5955msgstr "Erreur: if_nametoindex erreur - %s.\n" 4979msgstr "Erreur: if_nametoindex erreur - %s.\n"
5956 4980
5957#: plugins-root/check_dhcp.c:347
5958#, c-format 4981#, c-format
5959msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n" 4982msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"
5960msgstr "" 4983msgstr ""
5961"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s. erreur sysctl 1 " 4984"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s. erreur sysctl 1 "
5962"- %s.\n" 4985"- %s.\n"
5963 4986
5964#: plugins-root/check_dhcp.c:352
5965#, c-format 4987#, c-format
5966msgid "" 4988msgid ""
5967"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n" 4989"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"
@@ -5969,14 +4991,12 @@ msgstr ""
5969"Erreur: Impossible d'obtenir l'adresse matérielle depuis l'interface %s\n" 4991"Erreur: Impossible d'obtenir l'adresse matérielle depuis l'interface %s\n"
5970" erreur malloc - %s.\n" 4992" erreur malloc - %s.\n"
5971 4993
5972#: plugins-root/check_dhcp.c:357
5973#, c-format 4994#, c-format
5974msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n" 4995msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"
5975msgstr "" 4996msgstr ""
5976"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s erreur sysctl 2 " 4997"Erreur: Impossible d'obtenir l'adresse matérielle depuis %s erreur sysctl 2 "
5977"- %s.\n" 4998"- %s.\n"
5978 4999
5979#: plugins-root/check_dhcp.c:388
5980#, c-format 5000#, c-format
5981msgid "" 5001msgid ""
5982"Error: can't find unit number in interface_name (%s) - expecting TypeNumber " 5002"Error: can't find unit number in interface_name (%s) - expecting TypeNumber "
@@ -5985,7 +5005,6 @@ msgstr ""
5985"Erreur: impossible de trouver le numéro dans le nom de l'interface (%s).\n" 5005"Erreur: impossible de trouver le numéro dans le nom de l'interface (%s).\n"
5986"J'attendais le nom suivi du type ex lnc0.\n" 5006"J'attendais le nom suivi du type ex lnc0.\n"
5987 5007
5988#: plugins-root/check_dhcp.c:393 plugins-root/check_dhcp.c:405
5989#, c-format 5008#, c-format
5990msgid "" 5009msgid ""
5991"Error: can't read MAC address from DLPI streams interface for device %s unit " 5010"Error: can't read MAC address from DLPI streams interface for device %s unit "
@@ -5994,7 +5013,6 @@ msgstr ""
5994"Erreur: impossible de lire l'adresse MAC depuis l'interface DLPI pour le \n" 5013"Erreur: impossible de lire l'adresse MAC depuis l'interface DLPI pour le \n"
5995"périphérique %s numéro %d.\n" 5014"périphérique %s numéro %d.\n"
5996 5015
5997#: plugins-root/check_dhcp.c:411
5998#, c-format 5016#, c-format
5999msgid "" 5017msgid ""
6000"Error: can't get MAC address for this architecture. Use the --mac option.\n" 5018"Error: can't get MAC address for this architecture. Use the --mac option.\n"
@@ -6002,47 +5020,38 @@ msgstr ""
6002"Erreur: impossible d'obtenir l'adresse MAC sur cette architecture. Utilisez " 5020"Erreur: impossible d'obtenir l'adresse MAC sur cette architecture. Utilisez "
6003"l'option --mac.\n" 5021"l'option --mac.\n"
6004 5022
6005#: plugins-root/check_dhcp.c:430
6006#, c-format 5023#, c-format
6007msgid "Error: Cannot determine IP address of interface %s\n" 5024msgid "Error: Cannot determine IP address of interface %s\n"
6008msgstr "Erreur: Impossible d'obtenir l'adresse IP de l'interface %s\n" 5025msgstr "Erreur: Impossible d'obtenir l'adresse IP de l'interface %s\n"
6009 5026
6010#: plugins-root/check_dhcp.c:438
6011#, c-format 5027#, c-format
6012msgid "Error: Cannot get interface IP address on this platform.\n" 5028msgid "Error: Cannot get interface IP address on this platform.\n"
6013msgstr "Erreur: Impossible d'obtenir l'adresse IP sur cette architecture.\n" 5029msgstr "Erreur: Impossible d'obtenir l'adresse IP sur cette architecture.\n"
6014 5030
6015#: plugins-root/check_dhcp.c:443
6016#, c-format 5031#, c-format
6017msgid "Pretending to be relay client %s\n" 5032msgid "Pretending to be relay client %s\n"
6018msgstr "" 5033msgstr ""
6019 5034
6020#: plugins-root/check_dhcp.c:528
6021#, c-format 5035#, c-format
6022msgid "DHCPDISCOVER to %s port %d\n" 5036msgid "DHCPDISCOVER to %s port %d\n"
6023msgstr "DHCPDISCOVER vers %s port %d\n" 5037msgstr "DHCPDISCOVER vers %s port %d\n"
6024 5038
6025#: plugins-root/check_dhcp.c:580
6026#, c-format 5039#, c-format
6027msgid "Result=ERROR\n" 5040msgid "Result=ERROR\n"
6028msgstr "Résultat=ERREUR\n" 5041msgstr "Résultat=ERREUR\n"
6029 5042
6030#: plugins-root/check_dhcp.c:586
6031#, c-format 5043#, c-format
6032msgid "Result=OK\n" 5044msgid "Result=OK\n"
6033msgstr "Résultat=OK\n" 5045msgstr "Résultat=OK\n"
6034 5046
6035#: plugins-root/check_dhcp.c:596
6036#, c-format 5047#, c-format
6037msgid "DHCPOFFER from IP address %s" 5048msgid "DHCPOFFER from IP address %s"
6038msgstr "DHCPOFFER depuis l'adresse IP %s" 5049msgstr "DHCPOFFER depuis l'adresse IP %s"
6039 5050
6040#: plugins-root/check_dhcp.c:597
6041#, c-format 5051#, c-format
6042msgid " via %s\n" 5052msgid " via %s\n"
6043msgstr " depuis %s\n" 5053msgstr " depuis %s\n"
6044 5054
6045#: plugins-root/check_dhcp.c:604
6046#, c-format 5055#, c-format
6047msgid "" 5056msgid ""
6048"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n" 5057"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"
@@ -6050,67 +5059,55 @@ msgstr ""
6050"DHCPOFFER XID (%u) ne correspond pas au DHCPDISCOVER XID (%u) - paquet " 5059"DHCPOFFER XID (%u) ne correspond pas au DHCPDISCOVER XID (%u) - paquet "
6051"ignoré\n" 5060"ignoré\n"
6052 5061
6053#: plugins-root/check_dhcp.c:626
6054#, c-format 5062#, c-format
6055msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n" 5063msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n"
6056msgstr "" 5064msgstr ""
6057"l'adresse matérielle du DHCPOFFER ne correspond pas à la notre paquet " 5065"l'adresse matérielle du DHCPOFFER ne correspond pas à la notre paquet "
6058"ignoré\n" 5066"ignoré\n"
6059 5067
6060#: plugins-root/check_dhcp.c:644
6061#, c-format 5068#, c-format
6062msgid "Total responses seen on the wire: %d\n" 5069msgid "Total responses seen on the wire: %d\n"
6063msgstr "Nombre total de réponses vues: %d\n" 5070msgstr "Nombre total de réponses vues: %d\n"
6064 5071
6065#: plugins-root/check_dhcp.c:645
6066#, c-format 5072#, c-format
6067msgid "Valid responses for this machine: %d\n" 5073msgid "Valid responses for this machine: %d\n"
6068msgstr "Nombre de réponse valides pour cette machine: %d\n" 5074msgstr "Nombre de réponse valides pour cette machine: %d\n"
6069 5075
6070#: plugins-root/check_dhcp.c:660
6071#, c-format 5076#, c-format
6072msgid "send_dhcp_packet result: %d\n" 5077msgid "send_dhcp_packet result: %d\n"
6073msgstr "résultat de send_dchp_packet: %d\n" 5078msgstr "résultat de send_dchp_packet: %d\n"
6074 5079
6075#: plugins-root/check_dhcp.c:693
6076#, c-format 5080#, c-format
6077msgid "No (more) data received (nfound: %d)\n" 5081msgid "No (more) data received (nfound: %d)\n"
6078msgstr "Plus de données reçues (nfound: %d)\n" 5082msgstr "Plus de données reçues (nfound: %d)\n"
6079 5083
6080#: plugins-root/check_dhcp.c:712
6081#, c-format 5084#, c-format
6082msgid "recvfrom() failed, " 5085msgid "recvfrom() failed, "
6083msgstr "recvfrom() a échoué, " 5086msgstr "recvfrom() a échoué, "
6084 5087
6085#: plugins-root/check_dhcp.c:719
6086#, c-format 5088#, c-format
6087msgid "receive_dhcp_packet() result: %d\n" 5089msgid "receive_dhcp_packet() result: %d\n"
6088msgstr "résultat de receive_dchp_packet(): %d\n" 5090msgstr "résultat de receive_dchp_packet(): %d\n"
6089 5091
6090#: plugins-root/check_dhcp.c:720
6091#, c-format 5092#, c-format
6092msgid "receive_dhcp_packet() source: %s\n" 5093msgid "receive_dhcp_packet() source: %s\n"
6093msgstr "source de receive_dchp_packet(): %s\n" 5094msgstr "source de receive_dchp_packet(): %s\n"
6094 5095
6095#: plugins-root/check_dhcp.c:750
6096#, c-format 5096#, c-format
6097msgid "Error: Could not create socket!\n" 5097msgid "Error: Could not create socket!\n"
6098msgstr "Erreur: Impossible de créer un socket!\n" 5098msgstr "Erreur: Impossible de créer un socket!\n"
6099 5099
6100#: plugins-root/check_dhcp.c:760
6101#, c-format 5100#, c-format
6102msgid "Error: Could not set reuse address option on DHCP socket!\n" 5101msgid "Error: Could not set reuse address option on DHCP socket!\n"
6103msgstr "" 5102msgstr ""
6104"Erreur: Impossible de configurer l'option de réutilisation de l'adresse sur\n" 5103"Erreur: Impossible de configurer l'option de réutilisation de l'adresse sur\n"
6105"le socket DHCP!\n" 5104"le socket DHCP!\n"
6106 5105
6107#: plugins-root/check_dhcp.c:766
6108#, c-format 5106#, c-format
6109msgid "Error: Could not set broadcast option on DHCP socket!\n" 5107msgid "Error: Could not set broadcast option on DHCP socket!\n"
6110msgstr "" 5108msgstr ""
6111"Erreur: Impossible de configurer l'option broadcast sur le socket DHCP!\n" 5109"Erreur: Impossible de configurer l'option broadcast sur le socket DHCP!\n"
6112 5110
6113#: plugins-root/check_dhcp.c:775
6114#, c-format 5111#, c-format
6115msgid "" 5112msgid ""
6116"Error: Could not bind socket to interface %s. Check your privileges...\n" 5113"Error: Could not bind socket to interface %s. Check your privileges...\n"
@@ -6118,7 +5115,6 @@ msgstr ""
6118"Erreur: Impossible de connecter le socket à l'interface %s.\n" 5115"Erreur: Impossible de connecter le socket à l'interface %s.\n"
6119"Vérifiez vos droits...\n" 5116"Vérifiez vos droits...\n"
6120 5117
6121#: plugins-root/check_dhcp.c:786
6122#, c-format 5118#, c-format
6123msgid "" 5119msgid ""
6124"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n" 5120"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"
@@ -6126,256 +5122,235 @@ msgstr ""
6126"Erreur: Impossible de se connecter au socket (port %d)! Vérifiez vos " 5122"Erreur: Impossible de se connecter au socket (port %d)! Vérifiez vos "
6127"droits..\n" 5123"droits..\n"
6128 5124
6129#: plugins-root/check_dhcp.c:820
6130#, c-format 5125#, c-format
6131msgid "Requested server address: %s\n" 5126msgid "Requested server address: %s\n"
6132msgstr "Adresse serveur demandée: %s\n" 5127msgstr "Adresse serveur demandée: %s\n"
6133 5128
6134#: plugins-root/check_dhcp.c:882
6135#, c-format 5129#, c-format
6136msgid "Lease Time: Infinite\n" 5130msgid "Lease Time: Infinite\n"
6137msgstr "Durée du Bail: Infini\n" 5131msgstr "Durée du Bail: Infini\n"
6138 5132
6139#: plugins-root/check_dhcp.c:884
6140#, c-format 5133#, c-format
6141msgid "Lease Time: %lu seconds\n" 5134msgid "Lease Time: %lu seconds\n"
6142msgstr "Durée du Bail: %lu secondes\n" 5135msgstr "Durée du Bail: %lu secondes\n"
6143 5136
6144#: plugins-root/check_dhcp.c:886
6145#, c-format 5137#, c-format
6146msgid "Renewal Time: Infinite\n" 5138msgid "Renewal Time: Infinite\n"
6147msgstr "Renouvellement du bail: Infini\n" 5139msgstr "Renouvellement du bail: Infini\n"
6148 5140
6149#: plugins-root/check_dhcp.c:888
6150#, c-format 5141#, c-format
6151msgid "Renewal Time: %lu seconds\n" 5142msgid "Renewal Time: %lu seconds\n"
6152msgstr "Durée du renouvellement = %lu secondes\n" 5143msgstr "Durée du renouvellement = %lu secondes\n"
6153 5144
6154#: plugins-root/check_dhcp.c:890
6155#, c-format 5145#, c-format
6156msgid "Rebinding Time: Infinite\n" 5146msgid "Rebinding Time: Infinite\n"
6157msgstr "Délai de nouvelle demande: Infini\n" 5147msgstr "Délai de nouvelle demande: Infini\n"
6158 5148
6159#: plugins-root/check_dhcp.c:891
6160#, c-format 5149#, c-format
6161msgid "Rebinding Time: %lu seconds\n" 5150msgid "Rebinding Time: %lu seconds\n"
6162msgstr "Délai de nouvelle demande: %lu secondes\n" 5151msgstr "Délai de nouvelle demande: %lu secondes\n"
6163 5152
6164#: plugins-root/check_dhcp.c:919
6165#, c-format 5153#, c-format
6166msgid "Added offer from server @ %s" 5154msgid "Added offer from server @ %s"
6167msgstr "Rajouté offre du serveur @ %s" 5155msgstr "Rajouté offre du serveur @ %s"
6168 5156
6169#: plugins-root/check_dhcp.c:920
6170#, c-format 5157#, c-format
6171msgid " of IP address %s\n" 5158msgid " of IP address %s\n"
6172msgstr "de l'adresse IP %s\n" 5159msgstr "de l'adresse IP %s\n"
6173 5160
6174#: plugins-root/check_dhcp.c:987
6175#, c-format 5161#, c-format
6176msgid "DHCP Server Match: Offerer=%s" 5162msgid "DHCP Server Match: Offerer=%s"
6177msgstr "Correspondance du serveur DHCP: Offrant=%s" 5163msgstr "Correspondance du serveur DHCP: Offrant=%s"
6178 5164
6179#: plugins-root/check_dhcp.c:988
6180#, c-format 5165#, c-format
6181msgid " Requested=%s" 5166msgid " Requested=%s"
6182msgstr " Demandé=%s" 5167msgstr " Demandé=%s"
6183 5168
6184#: plugins-root/check_dhcp.c:990
6185#, c-format 5169#, c-format
6186msgid " (duplicate)" 5170msgid " (duplicate)"
6187msgstr "" 5171msgstr ""
6188 5172
6189#: plugins-root/check_dhcp.c:991
6190#, c-format 5173#, c-format
6191msgid "\n" 5174msgid "\n"
6192msgstr "" 5175msgstr ""
6193 5176
6194#: plugins-root/check_dhcp.c:1039
6195#, c-format 5177#, c-format
6196msgid "No DHCPOFFERs were received.\n" 5178msgid "No DHCPOFFERs were received.\n"
6197msgstr "Pas de DHCPOFFERs reçus.\n" 5179msgstr "Pas de DHCPOFFERs reçus.\n"
6198 5180
6199#: plugins-root/check_dhcp.c:1043
6200#, c-format 5181#, c-format
6201msgid "Received %d DHCPOFFER(s)" 5182msgid "Received %d DHCPOFFER(s)"
6202msgstr "Reçu %d DHCPOFFER(s)" 5183msgstr "Reçu %d DHCPOFFER(s)"
6203 5184
6204#: plugins-root/check_dhcp.c:1046
6205#, c-format 5185#, c-format
6206msgid ", %s%d of %d requested servers responded" 5186msgid ", %s%d of %d requested servers responded"
6207msgstr ", %s%d de %d serveurs ont répondus" 5187msgstr ", %s%d de %d serveurs ont répondus"
6208 5188
6209#: plugins-root/check_dhcp.c:1049
6210#, c-format 5189#, c-format
6211msgid ", requested address (%s) was %soffered" 5190msgid ", requested address (%s) was %soffered"
6212msgstr ", l'adresse demandée (%s) %s été offerte" 5191msgstr ", l'adresse demandée (%s) %s été offerte"
6213 5192
6214#: plugins-root/check_dhcp.c:1049
6215msgid "not " 5193msgid "not "
6216msgstr "n'as pas" 5194msgstr "n'as pas"
6217 5195
6218#: plugins-root/check_dhcp.c:1051
6219#, c-format 5196#, c-format
6220msgid ", max lease time = " 5197msgid ", max lease time = "
6221msgstr ", bail maximum = " 5198msgstr ", bail maximum = "
6222 5199
6223#: plugins-root/check_dhcp.c:1053
6224#, c-format 5200#, c-format
6225msgid "Infinity" 5201msgid "Infinity"
6226msgstr "Infini" 5202msgstr "Infini"
6227 5203
6228#: plugins-root/check_dhcp.c:1234 5204msgid "Got unexpected non-option argument"
5205msgstr ""
5206
6229#, c-format 5207#, c-format
6230msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n" 5208msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"
6231msgstr "" 5209msgstr ""
6232"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans check_ctrl: %s.\n" 5210"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans check_ctrl: %s.\n"
6233 5211
6234#: plugins-root/check_dhcp.c:1246
6235#, c-format 5212#, c-format
6236msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n" 5213msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"
6237msgstr "" 5214msgstr ""
6238"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_ctrl/putmsg(): " 5215"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_ctrl/putmsg(): "
6239"%s.\n" 5216"%s.\n"
6240 5217
6241#: plugins-root/check_dhcp.c:1259
6242#, c-format 5218#, c-format
6243msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n" 5219msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"
6244msgstr "" 5220msgstr ""
6245"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_both/putmsg().\n" 5221"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans put_both/putmsg().\n"
6246 5222
6247#: plugins-root/check_dhcp.c:1271
6248#, c-format 5223#, c-format
6249msgid "" 5224msgid ""
6250"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n" 5225"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"
6251msgstr "" 5226msgstr ""
6252"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_attach_req/open" 5227"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_attach_req/"
6253"(%s..): %s.\n" 5228"open(%s..): %s.\n"
6254 5229
6255#: plugins-root/check_dhcp.c:1295
6256#, c-format 5230#, c-format
6257msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n" 5231msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"
6258msgstr "" 5232msgstr ""
6259"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_bind/check_ctrl" 5233"Erreur: Impossible d'obtenir la MAC par l'API DLPI dans dl_bind/"
6260"(): %s.\n" 5234"check_ctrl(): %s.\n"
6261 5235
6262#: plugins-root/check_dhcp.c:1374
6263#, c-format 5236#, c-format
6264msgid "Hardware address: " 5237msgid "Hardware address: "
6265msgstr "Adresse matérielle: " 5238msgstr "Adresse matérielle: "
6266 5239
6267#: plugins-root/check_dhcp.c:1390
6268msgid "This plugin tests the availability of DHCP servers on a network." 5240msgid "This plugin tests the availability of DHCP servers on a network."
6269msgstr "Ce plugin teste la disponibilité de serveurs DHCP dans un réseau." 5241msgstr "Ce plugin teste la disponibilité de serveurs DHCP dans un réseau."
6270 5242
6271#: plugins-root/check_dhcp.c:1402
6272msgid "IP address of DHCP server that we must hear from" 5243msgid "IP address of DHCP server that we must hear from"
6273msgstr "" 5244msgstr ""
6274 5245
6275#: plugins-root/check_dhcp.c:1404
6276msgid "IP address that should be offered by at least one DHCP server" 5246msgid "IP address that should be offered by at least one DHCP server"
6277msgstr "" 5247msgstr ""
6278 5248
6279#: plugins-root/check_dhcp.c:1406
6280msgid "Seconds to wait for DHCPOFFER before timeout occurs" 5249msgid "Seconds to wait for DHCPOFFER before timeout occurs"
6281msgstr "" 5250msgstr ""
6282 5251
6283#: plugins-root/check_dhcp.c:1408
6284msgid "Interface to to use for listening (i.e. eth0)" 5252msgid "Interface to to use for listening (i.e. eth0)"
6285msgstr "" 5253msgstr ""
6286 5254
6287#: plugins-root/check_dhcp.c:1410
6288msgid "MAC address to use in the DHCP request" 5255msgid "MAC address to use in the DHCP request"
6289msgstr "" 5256msgstr ""
6290 5257
6291#: plugins-root/check_dhcp.c:1412
6292msgid "Unicast testing: mimic a DHCP relay, requires -s" 5258msgid "Unicast testing: mimic a DHCP relay, requires -s"
6293msgstr "" 5259msgstr ""
6294 5260
6295#: plugins-root/check_icmp.c:1295
6296msgid "specify a target" 5261msgid "specify a target"
6297msgstr "" 5262msgstr ""
6298 5263
6299#: plugins-root/check_icmp.c:1297 5264msgid "Use IPv4 (default) or IPv6 to communicate with the targets"
5265msgstr ""
5266
6300msgid "warning threshold (currently " 5267msgid "warning threshold (currently "
6301msgstr "Valeurs pour le seuil d'avertissement (actuellement " 5268msgstr "Valeurs pour le seuil d'avertissement (actuellement "
6302 5269
6303#: plugins-root/check_icmp.c:1300
6304msgid "critical threshold (currently " 5270msgid "critical threshold (currently "
6305msgstr "Valeurs pour le seuil critique (actuellement " 5271msgstr "Valeurs pour le seuil critique (actuellement "
6306 5272
6307#: plugins-root/check_icmp.c:1303
6308msgid "specify a source IP address or device name" 5273msgid "specify a source IP address or device name"
6309msgstr "spécifiez une adresse ou un nom d'hôte" 5274msgstr "spécifiez une adresse ou un nom d'hôte"
6310 5275
6311#: plugins-root/check_icmp.c:1305
6312msgid "number of packets to send (currently " 5276msgid "number of packets to send (currently "
6313msgstr "nombre de paquets à envoyer (actuellement " 5277msgstr "nombre de paquets à envoyer (actuellement "
6314 5278
6315#: plugins-root/check_icmp.c:1308
6316msgid "max packet interval (currently " 5279msgid "max packet interval (currently "
6317msgstr "" 5280msgstr ""
6318 5281
6319#: plugins-root/check_icmp.c:1311
6320msgid "max target interval (currently " 5282msgid "max target interval (currently "
6321msgstr "" 5283msgstr ""
6322 5284
6323#: plugins-root/check_icmp.c:1314
6324msgid "number of alive hosts required for success" 5285msgid "number of alive hosts required for success"
6325msgstr "nombre d'hôtes vivants requis pour réussite" 5286msgstr "nombre d'hôtes vivants requis pour réussite"
6326 5287
6327#: plugins-root/check_icmp.c:1317
6328msgid "TTL on outgoing packets (currently " 5288msgid "TTL on outgoing packets (currently "
6329msgstr "" 5289msgstr ""
6330 5290
6331#: plugins-root/check_icmp.c:1320
6332msgid "timeout value (seconds, currently " 5291msgid "timeout value (seconds, currently "
6333msgstr "" 5292msgstr ""
6334 5293
6335#: plugins-root/check_icmp.c:1323
6336msgid "Number of icmp data bytes to send" 5294msgid "Number of icmp data bytes to send"
6337msgstr "Nombre de paquets ICMP à envoyer" 5295msgstr "Nombre de paquets ICMP à envoyer"
6338 5296
6339#: plugins-root/check_icmp.c:1324
6340msgid "Packet size will be data bytes + icmp header (currently" 5297msgid "Packet size will be data bytes + icmp header (currently"
6341msgstr "" 5298msgstr ""
6342 5299
6343#: plugins-root/check_icmp.c:1326
6344msgid "verbose" 5300msgid "verbose"
6345msgstr "" 5301msgstr ""
6346 5302
6347#: plugins-root/check_icmp.c:1330
6348msgid "The -H switch is optional. Naming a host (or several) to check is not." 5303msgid "The -H switch is optional. Naming a host (or several) to check is not."
6349msgstr "" 5304msgstr ""
6350 5305
6351#: plugins-root/check_icmp.c:1332
6352msgid "" 5306msgid ""
6353"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%" 5307"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"
6354msgstr "" 5308msgstr ""
6355 5309
6356#: plugins-root/check_icmp.c:1333
6357msgid "packet loss. The default values should work well for most users." 5310msgid "packet loss. The default values should work well for most users."
6358msgstr "" 5311msgstr ""
6359 5312
6360#: plugins-root/check_icmp.c:1334
6361msgid "" 5313msgid ""
6362"You can specify different RTA factors using the standardized abbreviations" 5314"You can specify different RTA factors using the standardized abbreviations"
6363msgstr "" 5315msgstr ""
6364 5316
6365#: plugins-root/check_icmp.c:1335
6366msgid "" 5317msgid ""
6367"us (microseconds), ms (milliseconds, default) or just plain s for seconds." 5318"us (microseconds), ms (milliseconds, default) or just plain s for seconds."
6368msgstr "" 5319msgstr ""
6369 5320
6370#: plugins-root/check_icmp.c:1341
6371msgid "The -v switch can be specified several times for increased verbosity." 5321msgid "The -v switch can be specified several times for increased verbosity."
6372msgstr "" 5322msgstr ""
6373 5323
6374#~ msgid "Critical threshold must be integer" 5324#~ msgid "Path or partition (may be repeated)"
6375#~ msgstr "le seuil critique doit être un entier positif" 5325#~ msgstr "Répertoire ou partition (peut être utilisé plusieurs fois)"
6376 5326
6377#~ msgid "Warning threshold must be integer" 5327#~ msgid ""
6378#~ msgstr "Le seuil d'avertissement doit être un entier positif" 5328#~ "value match). If multiple addresses are returned at once, you have to "
5329#~ "match"
5330#~ msgstr ""
5331#~ "valeur correspond). Si plusieurs adresses sont retournées en même temps,"
5332
5333#~ msgid ""
5334#~ "the whole string of addresses separated with commas (sorted "
5335#~ "alphabetically)."
5336#~ msgstr ""
5337#~ "vous devrez toutes les inscrire séparées pas des virgules (en ordre "
5338#~ "alphabétique)"
5339
5340#~ msgid "No specific parameters. No warning or critical threshold"
5341#~ msgstr "Pas d'argument spécifique. Pas de seuil d'avertissement ou critique"
5342
5343#~ msgid "Can't find local IP for NAS-IP-Address"
5344#~ msgstr "Impossible de trouver une addresse IP locale pour le NAS-IP-Address"
5345
5346#~ msgid "Warning free space should be more than critical free space"
5347#~ msgstr ""
5348#~ "Le seuil d'avertissement pour la place libre doit être plus grand que le "
5349#~ "seuil critique"
5350
5351#, c-format
5352#~ msgid "%s - Plugin timed out after %d seconds\n"
5353#~ msgstr "%s - Le plugin n'as pas répondu dans les %d secondes\n"
6379 5354
6380#~ msgid "Critical Process Count must be an integer!" 5355#~ msgid "Critical Process Count must be an integer!"
6381#~ msgstr "Critique Le total des processus doit être un nombre entier!" 5356#~ msgstr "Critique Le total des processus doit être un nombre entier!"
diff --git a/po/monitoring-plugins.pot b/po/monitoring-plugins.pot
index 5bc2363..af48f03 100644
--- a/po/monitoring-plugins.pot
+++ b/po/monitoring-plugins.pot
@@ -8,7 +8,7 @@ msgid ""
8msgstr "" 8msgstr ""
9"Project-Id-Version: PACKAGE VERSION\n" 9"Project-Id-Version: PACKAGE VERSION\n"
10"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n" 10"Report-Msgid-Bugs-To: devel@monitoring-plugins.org\n"
11"POT-Creation-Date: 2014-01-19 16:30-0500\n" 11"POT-Creation-Date: 2023-09-12 01:33+0200\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n" 14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,3942 +18,3163 @@ msgstr ""
18"Content-Transfer-Encoding: 8bit\n" 18"Content-Transfer-Encoding: 8bit\n"
19"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 19"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
20 20
21#: plugins/check_by_ssh.c:86 plugins/check_cluster.c:76 plugins/check_dig.c:88
22#: plugins/check_disk.c:194 plugins/check_dns.c:102 plugins/check_dummy.c:52
23#: plugins/check_fping.c:93 plugins/check_game.c:82 plugins/check_hpjd.c:103
24#: plugins/check_http.c:167 plugins/check_ldap.c:109 plugins/check_load.c:122
25#: plugins/check_mrtgtraf.c:83 plugins/check_mysql.c:122
26#: plugins/check_nagios.c:91 plugins/check_nt.c:127 plugins/check_ntp.c:770
27#: plugins/check_ntp_peer.c:575 plugins/check_ntp_time.c:552
28#: plugins/check_nwstat.c:173 plugins/check_overcr.c:102
29#: plugins/check_pgsql.c:172 plugins/check_ping.c:95 plugins/check_procs.c:172
30#: plugins/check_radius.c:160 plugins/check_real.c:80 plugins/check_smtp.c:144
31#: plugins/check_snmp.c:240 plugins/check_ssh.c:73 plugins/check_swap.c:110
32#: plugins/check_tcp.c:218 plugins/check_time.c:78 plugins/check_ups.c:122
33#: plugins/check_users.c:77 plugins/negate.c:214 plugins-root/check_dhcp.c:270
34msgid "Could not parse arguments" 21msgid "Could not parse arguments"
35msgstr "" 22msgstr ""
36 23
37#: plugins/check_by_ssh.c:90 plugins/check_dig.c:82 plugins/check_dns.c:95
38#: plugins/check_nagios.c:95 plugins/check_pgsql.c:178 plugins/check_ping.c:99
39#: plugins/check_procs.c:188 plugins/check_snmp.c:336 plugins/negate.c:79
40msgid "Cannot catch SIGALRM" 24msgid "Cannot catch SIGALRM"
41msgstr "" 25msgstr ""
42 26
43#: plugins/check_by_ssh.c:110 27#, c-format
28msgid "SSH connection failed: %s\n"
29msgstr ""
30
44#, c-format 31#, c-format
45msgid "Remote command execution failed: %s\n" 32msgid "Remote command execution failed: %s\n"
46msgstr "" 33msgstr ""
47 34
48#: plugins/check_by_ssh.c:122
49#, c-format 35#, c-format
50msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n" 36msgid "%s - check_by_ssh: Remote command '%s' returned status %d\n"
51msgstr "" 37msgstr ""
52 38
53#: plugins/check_by_ssh.c:134
54#, c-format 39#, c-format
55msgid "SSH WARNING: could not open %s\n" 40msgid "SSH WARNING: could not open %s\n"
56msgstr "" 41msgstr ""
57 42
58#: plugins/check_by_ssh.c:143
59#, c-format 43#, c-format
60msgid "%s: Error parsing output\n" 44msgid "%s: Error parsing output\n"
61msgstr "" 45msgstr ""
62 46
63#: plugins/check_by_ssh.c:220 plugins/check_disk.c:476
64#: plugins/check_http.c:278 plugins/check_ldap.c:293 plugins/check_pgsql.c:311
65#: plugins/check_procs.c:437 plugins/check_radius.c:308
66#: plugins/check_real.c:356 plugins/check_smtp.c:581 plugins/check_snmp.c:736
67#: plugins/check_ssh.c:138 plugins/check_tcp.c:505 plugins/check_time.c:302
68#: plugins/check_ups.c:556 plugins/negate.c:164
69msgid "Timeout interval must be a positive integer" 47msgid "Timeout interval must be a positive integer"
70msgstr "" 48msgstr ""
71 49
72#: plugins/check_by_ssh.c:230 plugins/check_pgsql.c:341
73#: plugins/check_radius.c:272 plugins/check_real.c:327
74#: plugins/check_smtp.c:506 plugins/check_tcp.c:511 plugins/check_time.c:296
75#: plugins/check_ups.c:518
76msgid "Port must be a positive integer" 50msgid "Port must be a positive integer"
77msgstr "" 51msgstr ""
78 52
79#: plugins/check_by_ssh.c:291
80msgid "skip-stdout argument must be an integer" 53msgid "skip-stdout argument must be an integer"
81msgstr "" 54msgstr ""
82 55
83#: plugins/check_by_ssh.c:299
84msgid "skip-stderr argument must be an integer" 56msgid "skip-stderr argument must be an integer"
85msgstr "" 57msgstr ""
86 58
87#: plugins/check_by_ssh.c:322
88#, c-format 59#, c-format
89msgid "%s: You must provide a host name\n" 60msgid "%s: You must provide a host name\n"
90msgstr "" 61msgstr ""
91 62
92#: plugins/check_by_ssh.c:340
93msgid "No remotecmd" 63msgid "No remotecmd"
94msgstr "" 64msgstr ""
95 65
96#: plugins/check_by_ssh.c:354
97#, c-format 66#, c-format
98msgid "%s: Argument limit of %d exceeded\n" 67msgid "%s: Argument limit of %d exceeded\n"
99msgstr "" 68msgstr ""
100 69
101#: plugins/check_by_ssh.c:357
102msgid "Can not (re)allocate 'commargv' buffer\n" 70msgid "Can not (re)allocate 'commargv' buffer\n"
103msgstr "" 71msgstr ""
104 72
105#: plugins/check_by_ssh.c:371
106#, c-format 73#, c-format
107msgid "" 74msgid ""
108"%s: In passive mode, you must provide a service name for each command.\n" 75"%s: In passive mode, you must provide a service name for each command.\n"
109msgstr "" 76msgstr ""
110 77
111#: plugins/check_by_ssh.c:374
112#, c-format 78#, c-format
113msgid "" 79msgid ""
114"%s: In passive mode, you must provide the host short name from the " 80"%s: In passive mode, you must provide the host short name from the "
115"monitoring configs.\n" 81"monitoring configs.\n"
116msgstr "" 82msgstr ""
117 83
118#: plugins/check_by_ssh.c:388
119#, c-format 84#, c-format
120msgid "This plugin uses SSH to execute commands on a remote host" 85msgid "This plugin uses SSH to execute commands on a remote host"
121msgstr "" 86msgstr ""
122 87
123#: plugins/check_by_ssh.c:403
124msgid "tell ssh to use Protocol 1 [optional]" 88msgid "tell ssh to use Protocol 1 [optional]"
125msgstr "" 89msgstr ""
126 90
127#: plugins/check_by_ssh.c:405
128msgid "tell ssh to use Protocol 2 [optional]" 91msgid "tell ssh to use Protocol 2 [optional]"
129msgstr "" 92msgstr ""
130 93
131#: plugins/check_by_ssh.c:407
132msgid "Ignore all or (if specified) first n lines on STDOUT [optional]" 94msgid "Ignore all or (if specified) first n lines on STDOUT [optional]"
133msgstr "" 95msgstr ""
134 96
135#: plugins/check_by_ssh.c:409
136msgid "Ignore all or (if specified) first n lines on STDERR [optional]" 97msgid "Ignore all or (if specified) first n lines on STDERR [optional]"
137msgstr "" 98msgstr ""
138 99
139#: plugins/check_by_ssh.c:411 100msgid "Exit with an warning, if there is an output on STDERR"
101msgstr ""
102
140msgid "" 103msgid ""
141"tells ssh to fork rather than create a tty [optional]. This will always " 104"tells ssh to fork rather than create a tty [optional]. This will always "
142"return OK if ssh is executed" 105"return OK if ssh is executed"
143msgstr "" 106msgstr ""
144 107
145#: plugins/check_by_ssh.c:413
146msgid "command to execute on the remote machine" 108msgid "command to execute on the remote machine"
147msgstr "" 109msgstr ""
148 110
149#: plugins/check_by_ssh.c:415
150msgid "SSH user name on remote host [optional]" 111msgid "SSH user name on remote host [optional]"
151msgstr "" 112msgstr ""
152 113
153#: plugins/check_by_ssh.c:417
154msgid "identity of an authorized key [optional]" 114msgid "identity of an authorized key [optional]"
155msgstr "" 115msgstr ""
156 116
157#: plugins/check_by_ssh.c:419
158msgid "external command file for monitoring [optional]" 117msgid "external command file for monitoring [optional]"
159msgstr "" 118msgstr ""
160 119
161#: plugins/check_by_ssh.c:421
162msgid "list of monitoring service names, separated by ':' [optional]" 120msgid "list of monitoring service names, separated by ':' [optional]"
163msgstr "" 121msgstr ""
164 122
165#: plugins/check_by_ssh.c:423
166msgid "short name of host in the monitoring configuration [optional]" 123msgid "short name of host in the monitoring configuration [optional]"
167msgstr "" 124msgstr ""
168 125
169#: plugins/check_by_ssh.c:425
170msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]" 126msgid "Call ssh with '-o OPTION' (may be used multiple times) [optional]"
171msgstr "" 127msgstr ""
172 128
173#: plugins/check_by_ssh.c:427
174msgid "Tell ssh to use this configfile [optional]" 129msgid "Tell ssh to use this configfile [optional]"
175msgstr "" 130msgstr ""
176 131
177#: plugins/check_by_ssh.c:429
178msgid "Tell ssh to suppress warning and diagnostic messages [optional]" 132msgid "Tell ssh to suppress warning and diagnostic messages [optional]"
179msgstr "" 133msgstr ""
180 134
181#: plugins/check_by_ssh.c:434 135msgid "Make connection problems return UNKNOWN instead of CRITICAL"
136msgstr ""
137
182msgid "The most common mode of use is to refer to a local identity file with" 138msgid "The most common mode of use is to refer to a local identity file with"
183msgstr "" 139msgstr ""
184 140
185#: plugins/check_by_ssh.c:435
186msgid "the '-i' option. In this mode, the identity pair should have a null" 141msgid "the '-i' option. In this mode, the identity pair should have a null"
187msgstr "" 142msgstr ""
188 143
189#: plugins/check_by_ssh.c:436
190msgid "passphrase and the public key should be listed in the authorized_keys" 144msgid "passphrase and the public key should be listed in the authorized_keys"
191msgstr "" 145msgstr ""
192 146
193#: plugins/check_by_ssh.c:437
194msgid "file of the remote host. Usually the key will be restricted to running" 147msgid "file of the remote host. Usually the key will be restricted to running"
195msgstr "" 148msgstr ""
196 149
197#: plugins/check_by_ssh.c:438
198msgid "only one command on the remote server. If the remote SSH server tracks" 150msgid "only one command on the remote server. If the remote SSH server tracks"
199msgstr "" 151msgstr ""
200 152
201#: plugins/check_by_ssh.c:439
202msgid "invocation arguments, the one remote program may be an agent that can" 153msgid "invocation arguments, the one remote program may be an agent that can"
203msgstr "" 154msgstr ""
204 155
205#: plugins/check_by_ssh.c:440
206msgid "execute additional commands as proxy" 156msgid "execute additional commands as proxy"
207msgstr "" 157msgstr ""
208 158
209#: plugins/check_by_ssh.c:442
210msgid "To use passive mode, provide multiple '-C' options, and provide" 159msgid "To use passive mode, provide multiple '-C' options, and provide"
211msgstr "" 160msgstr ""
212 161
213#: plugins/check_by_ssh.c:443
214msgid "" 162msgid ""
215"all of -O, -s, and -n options (servicelist order must match '-C'options)" 163"all of -O, -s, and -n options (servicelist order must match '-C'options)"
216msgstr "" 164msgstr ""
217 165
218#: plugins/check_by_ssh.c:445 plugins/check_cluster.c:261
219#: plugins/check_dig.c:355 plugins/check_disk.c:924 plugins/check_http.c:1560
220#: plugins/check_nagios.c:312 plugins/check_ntp.c:869
221#: plugins/check_ntp_peer.c:705 plugins/check_ntp_time.c:633
222#: plugins/check_procs.c:763 plugins/negate.c:271 plugins/urlize.c:180
223msgid "Examples:" 166msgid "Examples:"
224msgstr "" 167msgstr ""
225 168
226#: plugins/check_by_ssh.c:460 plugins/check_cluster.c:274
227#: plugins/check_dig.c:367 plugins/check_disk.c:941 plugins/check_dns.c:486
228#: plugins/check_dummy.c:122 plugins/check_fping.c:505
229#: plugins/check_game.c:331 plugins/check_hpjd.c:414 plugins/check_http.c:1590
230#: plugins/check_ldap.c:451 plugins/check_load.c:334 plugins/check_mrtg.c:382
231#: plugins/check_mysql.c:569 plugins/check_nagios.c:323 plugins/check_nt.c:774
232#: plugins/check_ntp.c:888 plugins/check_ntp_peer.c:725
233#: plugins/check_ntp_time.c:642 plugins/check_nwstat.c:1685
234#: plugins/check_overcr.c:467 plugins/check_pgsql.c:578
235#: plugins/check_ping.c:603 plugins/check_procs.c:781
236#: plugins/check_radius.c:385 plugins/check_real.c:451
237#: plugins/check_smtp.c:843 plugins/check_snmp.c:1207 plugins/check_ssh.c:309
238#: plugins/check_swap.c:558 plugins/check_tcp.c:684 plugins/check_time.c:371
239#: plugins/check_ups.c:660 plugins/check_users.c:240
240#: plugins/check_ide_smart.c:640 plugins/negate.c:295 plugins/urlize.c:197
241#: plugins-root/check_dhcp.c:1422 plugins-root/check_icmp.c:1354
242msgid "Usage:" 169msgid "Usage:"
243msgstr "" 170msgstr ""
244 171
245#: plugins/check_cluster.c:230
246#, c-format 172#, c-format
247msgid "Host/Service Cluster Plugin for Monitoring" 173msgid "Host/Service Cluster Plugin for Monitoring"
248msgstr "" 174msgstr ""
249 175
250#: plugins/check_cluster.c:236 plugins/check_nt.c:676
251msgid "Options:" 176msgid "Options:"
252msgstr "" 177msgstr ""
253 178
254#: plugins/check_cluster.c:239
255msgid "Check service cluster status" 179msgid "Check service cluster status"
256msgstr "" 180msgstr ""
257 181
258#: plugins/check_cluster.c:241
259msgid "Check host cluster status" 182msgid "Check host cluster status"
260msgstr "" 183msgstr ""
261 184
262#: plugins/check_cluster.c:243
263msgid "Optional prepended text output (i.e. \"Host cluster\")" 185msgid "Optional prepended text output (i.e. \"Host cluster\")"
264msgstr "" 186msgstr ""
265 187
266#: plugins/check_cluster.c:245 plugins/check_cluster.c:248
267msgid "Specifies the range of hosts or services in cluster that must be in a" 188msgid "Specifies the range of hosts or services in cluster that must be in a"
268msgstr "" 189msgstr ""
269 190
270#: plugins/check_cluster.c:246
271msgid "non-OK state in order to return a WARNING status level" 191msgid "non-OK state in order to return a WARNING status level"
272msgstr "" 192msgstr ""
273 193
274#: plugins/check_cluster.c:249
275msgid "non-OK state in order to return a CRITICAL status level" 194msgid "non-OK state in order to return a CRITICAL status level"
276msgstr "" 195msgstr ""
277 196
278#: plugins/check_cluster.c:251
279msgid "The status codes of the hosts or services in the cluster, separated by" 197msgid "The status codes of the hosts or services in the cluster, separated by"
280msgstr "" 198msgstr ""
281 199
282#: plugins/check_cluster.c:252
283msgid "commas" 200msgid "commas"
284msgstr "" 201msgstr ""
285 202
286#: plugins/check_cluster.c:257 plugins/check_game.c:318
287#: plugins/check_http.c:1542 plugins/check_ldap.c:438 plugins/check_mrtg.c:363
288#: plugins/check_mrtgtraf.c:361 plugins/check_mysql.c:558
289#: plugins/check_nt.c:758 plugins/check_ntp.c:865 plugins/check_ntp_peer.c:696
290#: plugins/check_ntp_time.c:626 plugins/check_nwstat.c:1670
291#: plugins/check_overcr.c:456 plugins/check_snmp.c:1178
292#: plugins/check_swap.c:547 plugins/check_ups.c:642 plugins/negate.c:277
293#: plugins-root/check_icmp.c:1329
294msgid "Notes:" 203msgid "Notes:"
295msgstr "" 204msgstr ""
296 205
297#: plugins/check_cluster.c:263
298msgid "" 206msgid ""
299"Will alert critical if there are 3 or more service data points in a non-OK" 207"Will alert critical if there are 3 or more service data points in a non-OK"
300msgstr "" 208msgstr ""
301 209
302#: plugins/check_cluster.c:264 plugins/check_ups.c:639
303msgid "state." 210msgid "state."
304msgstr "" 211msgstr ""
305 212
306#: plugins/check_dig.c:100 plugins/check_dig.c:102
307#, c-format 213#, c-format
308msgid "Looking for: '%s'\n" 214msgid "Looking for: '%s'\n"
309msgstr "" 215msgstr ""
310 216
311#: plugins/check_dig.c:109
312msgid "dig returned an error status" 217msgid "dig returned an error status"
313msgstr "" 218msgstr ""
314 219
315#: plugins/check_dig.c:134
316msgid "Server not found in ANSWER SECTION" 220msgid "Server not found in ANSWER SECTION"
317msgstr "" 221msgstr ""
318 222
319#: plugins/check_dig.c:144
320msgid "No ANSWER SECTION found" 223msgid "No ANSWER SECTION found"
321msgstr "" 224msgstr ""
322 225
323#: plugins/check_dig.c:171
324msgid "Probably a non-existent host/domain" 226msgid "Probably a non-existent host/domain"
325msgstr "" 227msgstr ""
326 228
327#: plugins/check_dig.c:233
328#, c-format 229#, c-format
329msgid "Port must be a positive integer - %s" 230msgid "Port must be a positive integer - %s"
330msgstr "" 231msgstr ""
331 232
332#: plugins/check_dig.c:244
333#, c-format 233#, c-format
334msgid "Warning interval must be a positive integer - %s" 234msgid "Warning interval must be a positive integer - %s"
335msgstr "" 235msgstr ""
336 236
337#: plugins/check_dig.c:252
338#, c-format 237#, c-format
339msgid "Critical interval must be a positive integer - %s" 238msgid "Critical interval must be a positive integer - %s"
340msgstr "" 239msgstr ""
341 240
342#: plugins/check_dig.c:260
343#, c-format 241#, c-format
344msgid "Timeout interval must be a positive integer - %s" 242msgid "Timeout interval must be a positive integer - %s"
345msgstr "" 243msgstr ""
346 244
347#: plugins/check_dig.c:325
348#, c-format 245#, c-format
349msgid "This plugin test the DNS service on the specified host using dig" 246msgid "This plugin tests the DNS service on the specified host using dig"
350msgstr "" 247msgstr ""
351 248
352#: plugins/check_dig.c:338
353msgid "Force dig to only use IPv4 query transport" 249msgid "Force dig to only use IPv4 query transport"
354msgstr "" 250msgstr ""
355 251
356#: plugins/check_dig.c:340
357msgid "Force dig to only use IPv6 query transport" 252msgid "Force dig to only use IPv6 query transport"
358msgstr "" 253msgstr ""
359 254
360#: plugins/check_dig.c:342
361msgid "Machine name to lookup" 255msgid "Machine name to lookup"
362msgstr "" 256msgstr ""
363 257
364#: plugins/check_dig.c:344
365msgid "Record type to lookup (default: A)" 258msgid "Record type to lookup (default: A)"
366msgstr "" 259msgstr ""
367 260
368#: plugins/check_dig.c:346
369msgid "" 261msgid ""
370"An address expected to be in the answer section. If not set, uses whatever" 262"An address expected to be in the answer section. If not set, uses whatever"
371msgstr "" 263msgstr ""
372 264
373#: plugins/check_dig.c:347
374msgid "was in -l" 265msgid "was in -l"
375msgstr "" 266msgstr ""
376 267
377#: plugins/check_dig.c:349
378msgid "Pass STRING as argument(s) to dig" 268msgid "Pass STRING as argument(s) to dig"
379msgstr "" 269msgstr ""
380 270
381#: plugins/check_disk.c:216
382#, c-format 271#, c-format
383msgid "DISK %s: %s not found\n" 272msgid "DISK %s: %s not found\n"
384msgstr "" 273msgstr ""
385 274
386#: plugins/check_disk.c:216 plugins/check_disk.c:956 plugins/check_dns.c:241
387#: plugins/check_dummy.c:74 plugins/check_mysql.c:299
388#: plugins/check_nagios.c:104 plugins/check_nagios.c:168
389#: plugins/check_nagios.c:172 plugins/check_pgsql.c:601
390#: plugins/check_pgsql.c:618 plugins/check_pgsql.c:627
391#: plugins/check_pgsql.c:642 plugins/check_procs.c:351
392#, c-format 275#, c-format
393msgid "CRITICAL" 276msgid "CRITICAL"
394msgstr "" 277msgstr ""
395 278
396#: plugins/check_disk.c:550
397#, c-format 279#, c-format
398msgid "unit type %s not known\n" 280msgid "unit type %s not known\n"
399msgstr "" 281msgstr ""
400 282
401#: plugins/check_disk.c:553
402#, c-format 283#, c-format
403msgid "failed allocating storage for '%s'\n" 284msgid "failed allocating storage for '%s'\n"
404msgstr "" 285msgstr ""
405 286
406#: plugins/check_disk.c:577 plugins/check_disk.c:618 plugins/check_disk.c:626
407#: plugins/check_disk.c:633 plugins/check_disk.c:637 plugins/check_disk.c:677
408#: plugins/check_disk.c:683 plugins/check_disk.c:702 plugins/check_dummy.c:77
409#: plugins/check_dummy.c:80 plugins/check_pgsql.c:643
410#: plugins/check_procs.c:506
411#, c-format 287#, c-format
412msgid "UNKNOWN" 288msgid "UNKNOWN"
413msgstr "" 289msgstr ""
414 290
415#: plugins/check_disk.c:577
416msgid "Must set a threshold value before using -p\n" 291msgid "Must set a threshold value before using -p\n"
417msgstr "" 292msgstr ""
418 293
419#: plugins/check_disk.c:618
420msgid "Must set -E before selecting paths\n" 294msgid "Must set -E before selecting paths\n"
421msgstr "" 295msgstr ""
422 296
423#: plugins/check_disk.c:626
424msgid "Must set group value before selecting paths\n" 297msgid "Must set group value before selecting paths\n"
425msgstr "" 298msgstr ""
426 299
427#: plugins/check_disk.c:633
428msgid "" 300msgid ""
429"Paths need to be selected before using -i/-I. Use -A to select all paths " 301"Paths need to be selected before using -i/-I. Use -A to select all paths "
430"explicitly" 302"explicitly"
431msgstr "" 303msgstr ""
432 304
433#: plugins/check_disk.c:637 plugins/check_disk.c:683 plugins/check_procs.c:506
434msgid "Could not compile regular expression" 305msgid "Could not compile regular expression"
435msgstr "" 306msgstr ""
436 307
437#: plugins/check_disk.c:677
438msgid "Must set a threshold value before using -r/-R\n" 308msgid "Must set a threshold value before using -r/-R\n"
439msgstr "" 309msgstr ""
440 310
441#: plugins/check_disk.c:703
442msgid "Regular expression did not match any path or disk" 311msgid "Regular expression did not match any path or disk"
443msgstr "" 312msgstr ""
444 313
445#: plugins/check_disk.c:749
446msgid "Unknown argument" 314msgid "Unknown argument"
447msgstr "" 315msgstr ""
448 316
449#: plugins/check_disk.c:783
450#, c-format 317#, c-format
451msgid " for %s\n" 318msgid " for %s\n"
452msgstr "" 319msgstr ""
453 320
454#: plugins/check_disk.c:857
455msgid "" 321msgid ""
456"This plugin checks the amount of used disk space on a mounted file system" 322"This plugin checks the amount of used disk space on a mounted file system"
457msgstr "" 323msgstr ""
458 324
459#: plugins/check_disk.c:858
460msgid "" 325msgid ""
461"and generates an alert if free space is less than one of the threshold values" 326"and generates an alert if free space is less than one of the threshold values"
462msgstr "" 327msgstr ""
463 328
464#: plugins/check_disk.c:868
465msgid "Exit with WARNING status if less than INTEGER units of disk are free" 329msgid "Exit with WARNING status if less than INTEGER units of disk are free"
466msgstr "" 330msgstr ""
467 331
468#: plugins/check_disk.c:870
469msgid "Exit with WARNING status if less than PERCENT of disk space is free" 332msgid "Exit with WARNING status if less than PERCENT of disk space is free"
470msgstr "" 333msgstr ""
471 334
472#: plugins/check_disk.c:872
473msgid "Exit with CRITICAL status if less than INTEGER units of disk are free" 335msgid "Exit with CRITICAL status if less than INTEGER units of disk are free"
474msgstr "" 336msgstr ""
475 337
476#: plugins/check_disk.c:874
477msgid "Exit with CRITICAL status if less than PERCENT of disk space is free" 338msgid "Exit with CRITICAL status if less than PERCENT of disk space is free"
478msgstr "" 339msgstr ""
479 340
480#: plugins/check_disk.c:876
481msgid "Exit with WARNING status if less than PERCENT of inode space is free" 341msgid "Exit with WARNING status if less than PERCENT of inode space is free"
482msgstr "" 342msgstr ""
483 343
484#: plugins/check_disk.c:878
485msgid "Exit with CRITICAL status if less than PERCENT of inode space is free" 344msgid "Exit with CRITICAL status if less than PERCENT of inode space is free"
486msgstr "" 345msgstr ""
487 346
488#: plugins/check_disk.c:880 347msgid ""
489msgid "Path or partition (may be repeated)" 348"Mount point or block device as emitted by the mount(8) command (may be "
349"repeated)"
490msgstr "" 350msgstr ""
491 351
492#: plugins/check_disk.c:882
493msgid "Ignore device (only works if -p unspecified)" 352msgid "Ignore device (only works if -p unspecified)"
494msgstr "" 353msgstr ""
495 354
496#: plugins/check_disk.c:884
497msgid "Clear thresholds" 355msgid "Clear thresholds"
498msgstr "" 356msgstr ""
499 357
500#: plugins/check_disk.c:886
501msgid "For paths or partitions specified with -p, only check for exact paths" 358msgid "For paths or partitions specified with -p, only check for exact paths"
502msgstr "" 359msgstr ""
503 360
504#: plugins/check_disk.c:888
505msgid "Display only devices/mountpoints with errors" 361msgid "Display only devices/mountpoints with errors"
506msgstr "" 362msgstr ""
507 363
508#: plugins/check_disk.c:890
509msgid "Don't account root-reserved blocks into freespace in perfdata" 364msgid "Don't account root-reserved blocks into freespace in perfdata"
510msgstr "" 365msgstr ""
511 366
512#: plugins/check_disk.c:892 367msgid "Display inode usage in perfdata"
368msgstr ""
369
513msgid "" 370msgid ""
514"Group paths. Thresholds apply to (free-)space of all partitions together" 371"Group paths. Thresholds apply to (free-)space of all partitions together"
515msgstr "" 372msgstr ""
516 373
517#: plugins/check_disk.c:894
518msgid "Same as '--units kB'" 374msgid "Same as '--units kB'"
519msgstr "" 375msgstr ""
520 376
521#: plugins/check_disk.c:896
522msgid "Only check local filesystems" 377msgid "Only check local filesystems"
523msgstr "" 378msgstr ""
524 379
525#: plugins/check_disk.c:898
526msgid "" 380msgid ""
527"Only check local filesystems against thresholds. Yet call stat on remote " 381"Only check local filesystems against thresholds. Yet call stat on remote "
528"filesystems" 382"filesystems"
529msgstr "" 383msgstr ""
530 384
531#: plugins/check_disk.c:899
532msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)" 385msgid "to test if they are accessible (e.g. to detect Stale NFS Handles)"
533msgstr "" 386msgstr ""
534 387
535#: plugins/check_disk.c:901 388msgid "Display the (block) device instead of the mount point"
536msgid "Display the mountpoint instead of the partition"
537msgstr "" 389msgstr ""
538 390
539#: plugins/check_disk.c:903
540msgid "Same as '--units MB'" 391msgid "Same as '--units MB'"
541msgstr "" 392msgstr ""
542 393
543#: plugins/check_disk.c:905
544msgid "Explicitly select all paths. This is equivalent to -R '.*'" 394msgid "Explicitly select all paths. This is equivalent to -R '.*'"
545msgstr "" 395msgstr ""
546 396
547#: plugins/check_disk.c:907
548msgid "" 397msgid ""
549"Case insensitive regular expression for path/partition (may be repeated)" 398"Case insensitive regular expression for path/partition (may be repeated)"
550msgstr "" 399msgstr ""
551 400
552#: plugins/check_disk.c:909
553msgid "Regular expression for path or partition (may be repeated)" 401msgid "Regular expression for path or partition (may be repeated)"
554msgstr "" 402msgstr ""
555 403
556#: plugins/check_disk.c:911
557msgid "" 404msgid ""
558"Regular expression to ignore selected path/partition (case insensitive) (may " 405"Regular expression to ignore selected path/partition (case insensitive) (may "
559"be repeated)" 406"be repeated)"
560msgstr "" 407msgstr ""
561 408
562#: plugins/check_disk.c:913
563msgid "" 409msgid ""
564"Regular expression to ignore selected path or partition (may be repeated)" 410"Regular expression to ignore selected path or partition (may be repeated)"
565msgstr "" 411msgstr ""
566 412
567#: plugins/check_disk.c:916 413msgid ""
414"Return OK if no filesystem matches, filesystem does not exist or is "
415"inaccessible."
416msgstr ""
417
418msgid "(Provide this option before -p / -r / --ereg-path if used)"
419msgstr ""
420
568msgid "Choose bytes, kB, MB, GB, TB (default: MB)" 421msgid "Choose bytes, kB, MB, GB, TB (default: MB)"
569msgstr "" 422msgstr ""
570 423
571#: plugins/check_disk.c:919
572msgid "Ignore all filesystems of indicated type (may be repeated)" 424msgid "Ignore all filesystems of indicated type (may be repeated)"
573msgstr "" 425msgstr ""
574 426
575#: plugins/check_disk.c:921
576msgid "Check only filesystems of indicated type (may be repeated)" 427msgid "Check only filesystems of indicated type (may be repeated)"
577msgstr "" 428msgstr ""
578 429
579#: plugins/check_disk.c:926
580msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB" 430msgid "Checks /tmp and /var at 10% and 5%, and / at 100MB and 50MB"
581msgstr "" 431msgstr ""
582 432
583#: plugins/check_disk.c:928
584msgid "" 433msgid ""
585"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -" 434"Checks all filesystems not matching -r at 100M and 50M. The fs matching the -"
586"r regex" 435"r regex"
587msgstr "" 436msgstr ""
588 437
589#: plugins/check_disk.c:929
590msgid "" 438msgid ""
591"are grouped which means the freespace thresholds are applied to all disks " 439"are grouped which means the freespace thresholds are applied to all disks "
592"together" 440"together"
593msgstr "" 441msgstr ""
594 442
595#: plugins/check_disk.c:931
596msgid "" 443msgid ""
597"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use " 444"Checks /foo for 1000M/500M and /bar for 5/3%. All remaining volumes use "
598"100M/50M" 445"100M/50M"
599msgstr "" 446msgstr ""
600 447
601#: plugins/check_disk.c:957
602#, c-format 448#, c-format
603msgid "%s %s: %s\n" 449msgid "%s %s: %s\n"
604msgstr "" 450msgstr ""
605 451
606#: plugins/check_disk.c:957
607msgid "is not accessible" 452msgid "is not accessible"
608msgstr "" 453msgstr ""
609 454
610#: plugins/check_dns.c:116
611msgid "nslookup returned an error status" 455msgid "nslookup returned an error status"
612msgstr "" 456msgstr ""
613 457
614#: plugins/check_dns.c:134
615msgid "Warning plugin error" 458msgid "Warning plugin error"
616msgstr "" 459msgstr ""
617 460
618#: plugins/check_dns.c:154 461#, c-format
462msgid "DNS CRITICAL - '%s' returned empty server string\n"
463msgstr ""
464
465#, c-format
466msgid "DNS CRITICAL - No response from DNS %s\n"
467msgstr ""
468
619#, c-format 469#, c-format
620msgid "DNS CRITICAL - '%s' returned empty host name string\n" 470msgid "DNS CRITICAL - '%s' returned empty host name string\n"
621msgstr "" 471msgstr ""
622 472
623#: plugins/check_dns.c:160
624msgid "Non-authoritative answer:" 473msgid "Non-authoritative answer:"
625msgstr "" 474msgstr ""
626 475
627#: plugins/check_dns.c:201 476#, c-format
477msgid "Domain '%s' was not found by the server\n"
478msgstr ""
479
628#, c-format 480#, c-format
629msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n" 481msgid "DNS CRITICAL - '%s' msg parsing exited with no address\n"
630msgstr "" 482msgstr ""
631 483
632#: plugins/check_dns.c:216
633#, c-format 484#, c-format
634msgid "expected '%s' but got '%s'" 485msgid "expected '%s' but got '%s'"
635msgstr "" 486msgstr ""
636 487
637#: plugins/check_dns.c:223 488#, c-format
489msgid "Domain '%s' was found by the server: '%s'\n"
490msgstr ""
491
638#, c-format 492#, c-format
639msgid "server %s is not authoritative for %s" 493msgid "server %s is not authoritative for %s"
640msgstr "" 494msgstr ""
641 495
642#: plugins/check_dns.c:237 plugins/check_dummy.c:68 plugins/check_nagios.c:182
643#: plugins/check_pgsql.c:638 plugins/check_procs.c:344
644#, c-format 496#, c-format
645msgid "OK" 497msgid "OK"
646msgstr "" 498msgstr ""
647 499
648#: plugins/check_dns.c:239 plugins/check_dummy.c:71 plugins/check_mysql.c:296
649#: plugins/check_nagios.c:182 plugins/check_pgsql.c:607
650#: plugins/check_pgsql.c:612 plugins/check_pgsql.c:640
651#: plugins/check_procs.c:346
652#, c-format 500#, c-format
653msgid "WARNING" 501msgid "WARNING"
654msgstr "" 502msgstr ""
655 503
656#: plugins/check_dns.c:243
657#, c-format 504#, c-format
658msgid "%.3f second response time" 505msgid "%.3f second response time"
659msgid_plural "%.3f seconds response time" 506msgid_plural "%.3f seconds response time"
660msgstr[0] "" 507msgstr[0] ""
661msgstr[1] "" 508msgstr[1] ""
662 509
663#: plugins/check_dns.c:244
664#, c-format 510#, c-format
665msgid ". %s returns %s" 511msgid ". %s returns %s"
666msgstr "" 512msgstr ""
667 513
668#: plugins/check_dns.c:248
669#, c-format 514#, c-format
670msgid "DNS WARNING - %s\n" 515msgid "DNS WARNING - %s\n"
671msgstr "" 516msgstr ""
672 517
673#: plugins/check_dns.c:249 plugins/check_dns.c:252 plugins/check_dns.c:255
674msgid " Probably a non-existent host/domain" 518msgid " Probably a non-existent host/domain"
675msgstr "" 519msgstr ""
676 520
677#: plugins/check_dns.c:251
678#, c-format 521#, c-format
679msgid "DNS CRITICAL - %s\n" 522msgid "DNS CRITICAL - %s\n"
680msgstr "" 523msgstr ""
681 524
682#: plugins/check_dns.c:254
683#, c-format 525#, c-format
684msgid "DNS UNKNOWN - %s\n" 526msgid "DNS UNKNOWN - %s\n"
685msgstr "" 527msgstr ""
686 528
687#: plugins/check_dns.c:267
688msgid "Note: nslookup is deprecated and may be removed from future releases." 529msgid "Note: nslookup is deprecated and may be removed from future releases."
689msgstr "" 530msgstr ""
690 531
691#: plugins/check_dns.c:268
692msgid "Consider using the `dig' or `host' programs instead. Run nslookup with" 532msgid "Consider using the `dig' or `host' programs instead. Run nslookup with"
693msgstr "" 533msgstr ""
694 534
695#: plugins/check_dns.c:269
696msgid "the `-sil[ent]' option to prevent this message from appearing." 535msgid "the `-sil[ent]' option to prevent this message from appearing."
697msgstr "" 536msgstr ""
698 537
699#: plugins/check_dns.c:274
700#, c-format 538#, c-format
701msgid "No response from DNS %s\n" 539msgid "No response from DNS %s\n"
702msgstr "" 540msgstr ""
703 541
704#: plugins/check_dns.c:278
705#, c-format 542#, c-format
706msgid "DNS %s has no records\n" 543msgid "DNS %s has no records\n"
707msgstr "" 544msgstr ""
708 545
709#: plugins/check_dns.c:286
710#, c-format 546#, c-format
711msgid "Connection to DNS %s was refused\n" 547msgid "Connection to DNS %s was refused\n"
712msgstr "" 548msgstr ""
713 549
714#: plugins/check_dns.c:290
715#, c-format 550#, c-format
716msgid "Query was refused by DNS server at %s\n" 551msgid "Query was refused by DNS server at %s\n"
717msgstr "" 552msgstr ""
718 553
719#: plugins/check_dns.c:294
720#, c-format 554#, c-format
721msgid "No information returned by DNS server at %s\n" 555msgid "No information returned by DNS server at %s\n"
722msgstr "" 556msgstr ""
723 557
724#: plugins/check_dns.c:300
725#, c-format
726msgid "Domain %s was not found by the server\n"
727msgstr ""
728
729#: plugins/check_dns.c:304
730msgid "Network is unreachable\n" 558msgid "Network is unreachable\n"
731msgstr "" 559msgstr ""
732 560
733#: plugins/check_dns.c:308
734#, c-format 561#, c-format
735msgid "DNS failure for %s\n" 562msgid "DNS failure for %s\n"
736msgstr "" 563msgstr ""
737 564
738#: plugins/check_dns.c:372 plugins/check_dns.c:380 plugins/check_dns.c:387
739#: plugins/check_dns.c:392 plugins/check_dns.c:414 plugins/check_dns.c:422
740#: plugins/check_game.c:211 plugins/check_game.c:219
741msgid "Input buffer overflow\n" 565msgid "Input buffer overflow\n"
742msgstr "" 566msgstr ""
743 567
744#: plugins/check_dns.c:450
745msgid "" 568msgid ""
746"This plugin uses the nslookup program to obtain the IP address for the given " 569"This plugin uses the nslookup program to obtain the IP address for the given "
747"host/domain query." 570"host/domain query."
748msgstr "" 571msgstr ""
749 572
750#: plugins/check_dns.c:451
751msgid "An optional DNS server to use may be specified." 573msgid "An optional DNS server to use may be specified."
752msgstr "" 574msgstr ""
753 575
754#: plugins/check_dns.c:452
755msgid "" 576msgid ""
756"If no DNS server is specified, the default server(s) specified in /etc/" 577"If no DNS server is specified, the default server(s) specified in /etc/"
757"resolv.conf will be used." 578"resolv.conf will be used."
758msgstr "" 579msgstr ""
759 580
760#: plugins/check_dns.c:462
761msgid "The name or address you want to query" 581msgid "The name or address you want to query"
762msgstr "" 582msgstr ""
763 583
764#: plugins/check_dns.c:464
765msgid "Optional DNS server you want to use for the lookup" 584msgid "Optional DNS server you want to use for the lookup"
766msgstr "" 585msgstr ""
767 586
768#: plugins/check_dns.c:466
769msgid "" 587msgid ""
770"Optional IP-ADDRESS you expect the DNS server to return. HOST must end with" 588"Optional IP-ADDRESS/CIDR you expect the DNS server to return. HOST must end"
771msgstr "" 589msgstr ""
772 590
773#: plugins/check_dns.c:467
774msgid "" 591msgid ""
775"a dot (.). This option can be repeated multiple times (Returns OK if any" 592"with a dot (.). This option can be repeated multiple times (Returns OK if any"
776msgstr "" 593msgstr ""
777 594
778#: plugins/check_dns.c:468 595msgid "value matches)."
779msgid ""
780"value match). If multiple addresses are returned at once, you have to match"
781msgstr "" 596msgstr ""
782 597
783#: plugins/check_dns.c:469
784msgid "" 598msgid ""
785"the whole string of addresses separated with commas (sorted alphabetically)." 599"Expect the DNS server to return NXDOMAIN (i.e. the domain was not found)"
600msgstr ""
601
602msgid "Cannot be used together with -a"
786msgstr "" 603msgstr ""
787 604
788#: plugins/check_dns.c:471
789msgid "Optionally expect the DNS server to be authoritative for the lookup" 605msgid "Optionally expect the DNS server to be authoritative for the lookup"
790msgstr "" 606msgstr ""
791 607
792#: plugins/check_dns.c:473
793msgid "Return warning if elapsed time exceeds value. Default off" 608msgid "Return warning if elapsed time exceeds value. Default off"
794msgstr "" 609msgstr ""
795 610
796#: plugins/check_dns.c:475
797msgid "Return critical if elapsed time exceeds value. Default off" 611msgid "Return critical if elapsed time exceeds value. Default off"
798msgstr "" 612msgstr ""
799 613
800#: plugins/check_dummy.c:62 614msgid ""
615"Return critical if the list of expected addresses does not match all "
616"addresses"
617msgstr ""
618
619msgid "returned. Default off"
620msgstr ""
621
801msgid "Arguments to check_dummy must be an integer" 622msgid "Arguments to check_dummy must be an integer"
802msgstr "" 623msgstr ""
803 624
804#: plugins/check_dummy.c:82
805#, c-format 625#, c-format
806msgid "Status %d is not a supported error state\n" 626msgid "Status %d is not a supported error state\n"
807msgstr "" 627msgstr ""
808 628
809#: plugins/check_dummy.c:104
810msgid "" 629msgid ""
811"This plugin will simply return the state corresponding to the numeric value" 630"This plugin will simply return the state corresponding to the numeric value"
812msgstr "" 631msgstr ""
813 632
814#: plugins/check_dummy.c:106
815msgid "of the <state> argument with optional text" 633msgid "of the <state> argument with optional text"
816msgstr "" 634msgstr ""
817 635
818#: plugins/check_fping.c:125 plugins/check_hpjd.c:128 plugins/check_ping.c:438
819#: plugins/check_swap.c:175 plugins/check_users.c:94 plugins/urlize.c:110
820#, c-format 636#, c-format
821msgid "Could not open pipe: %s\n" 637msgid "Could not open pipe: %s\n"
822msgstr "" 638msgstr ""
823 639
824#: plugins/check_fping.c:131 plugins/check_hpjd.c:134 plugins/check_load.c:153
825#: plugins/check_swap.c:181 plugins/check_users.c:100 plugins/urlize.c:116
826#, c-format 640#, c-format
827msgid "Could not open stderr for %s\n" 641msgid "Could not open stderr for %s\n"
828msgstr "" 642msgstr ""
829 643
830#: plugins/check_fping.c:157
831msgid "FPING UNKNOWN - IP address not found\n" 644msgid "FPING UNKNOWN - IP address not found\n"
832msgstr "" 645msgstr ""
833 646
834#: plugins/check_fping.c:160
835msgid "FPING UNKNOWN - invalid commandline argument\n" 647msgid "FPING UNKNOWN - invalid commandline argument\n"
836msgstr "" 648msgstr ""
837 649
838#: plugins/check_fping.c:163
839msgid "FPING UNKNOWN - failed system call\n" 650msgid "FPING UNKNOWN - failed system call\n"
840msgstr "" 651msgstr ""
841 652
842#: plugins/check_fping.c:187 653#, c-format
654msgid "FPING %s - %s (rta=%f ms)|%s\n"
655msgstr ""
656
843#, c-format 657#, c-format
844msgid "FPING UNKNOWN - %s not found\n" 658msgid "FPING UNKNOWN - %s not found\n"
845msgstr "" 659msgstr ""
846 660
847#: plugins/check_fping.c:191
848#, c-format 661#, c-format
849msgid "FPING CRITICAL - %s is unreachable\n" 662msgid "FPING CRITICAL - %s is unreachable\n"
850msgstr "" 663msgstr ""
851 664
852#: plugins/check_fping.c:196
853#, c-format 665#, c-format
854msgid "FPING UNKNOWN - %s parameter error\n" 666msgid "FPING UNKNOWN - %s parameter error\n"
855msgstr "" 667msgstr ""
856 668
857#: plugins/check_fping.c:200 plugins/check_fping.c:240
858#, c-format 669#, c-format
859msgid "FPING CRITICAL - %s is down\n" 670msgid "FPING CRITICAL - %s is down\n"
860msgstr "" 671msgstr ""
861 672
862#: plugins/check_fping.c:227
863#, c-format 673#, c-format
864msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n" 674msgid "FPING %s - %s (loss=%.0f%%, rta=%f ms)|%s %s\n"
865msgstr "" 675msgstr ""
866 676
867#: plugins/check_fping.c:253
868#, c-format 677#, c-format
869msgid "FPING %s - %s (loss=%.0f%% )|%s\n" 678msgid "FPING %s - %s (loss=%.0f%% )|%s\n"
870msgstr "" 679msgstr ""
871 680
872#: plugins/check_fping.c:326 plugins/check_fping.c:332
873#: plugins/check_hpjd.c:338 plugins/check_hpjd.c:361 plugins/check_mysql.c:371
874#: plugins/check_mysql.c:455 plugins/check_ntp.c:709
875#: plugins/check_ntp_peer.c:497 plugins/check_ntp_time.c:496
876#: plugins/check_pgsql.c:335 plugins/check_ping.c:295 plugins/check_ping.c:418
877#: plugins/check_radius.c:264 plugins/check_real.c:314
878#: plugins/check_real.c:376 plugins/check_smtp.c:499 plugins/check_smtp.c:641
879#: plugins/check_ssh.c:157 plugins/check_time.c:240 plugins/check_time.c:315
880#: plugins/check_ups.c:504 plugins/check_ups.c:573
881msgid "Invalid hostname/address" 681msgid "Invalid hostname/address"
882msgstr "" 682msgstr ""
883 683
884#: plugins/check_fping.c:345 plugins/check_ldap.c:353 plugins/check_ping.c:246
885msgid "IPv6 support not available\n" 684msgid "IPv6 support not available\n"
886msgstr "" 685msgstr ""
887 686
888#: plugins/check_fping.c:378
889msgid "Packet size must be a positive integer" 687msgid "Packet size must be a positive integer"
890msgstr "" 688msgstr ""
891 689
892#: plugins/check_fping.c:384
893msgid "Packet count must be a positive integer" 690msgid "Packet count must be a positive integer"
894msgstr "" 691msgstr ""
895 692
896#: plugins/check_fping.c:390
897msgid "Target timeout must be a positive integer" 693msgid "Target timeout must be a positive integer"
898msgstr "" 694msgstr ""
899 695
900#: plugins/check_fping.c:396
901msgid "Interval must be a positive integer" 696msgid "Interval must be a positive integer"
902msgstr "" 697msgstr ""
903 698
904#: plugins/check_fping.c:402 plugins/check_ntp.c:733
905#: plugins/check_ntp_peer.c:524 plugins/check_ntp_time.c:523
906#: plugins/check_radius.c:314 plugins/check_time.c:319
907msgid "Hostname was not supplied" 699msgid "Hostname was not supplied"
908msgstr "" 700msgstr ""
909 701
910#: plugins/check_fping.c:422
911#, c-format 702#, c-format
912msgid "%s: Only one threshold may be packet loss (%s)\n" 703msgid "%s: Only one threshold may be packet loss (%s)\n"
913msgstr "" 704msgstr ""
914 705
915#: plugins/check_fping.c:426
916#, c-format 706#, c-format
917msgid "%s: Only one threshold must be packet loss (%s)\n" 707msgid "%s: Only one threshold must be packet loss (%s)\n"
918msgstr "" 708msgstr ""
919 709
920#: plugins/check_fping.c:458
921msgid "" 710msgid ""
922"This plugin will use the fping command to ping the specified host for a fast " 711"This plugin will use the fping command to ping the specified host for a fast "
923"check" 712"check"
924msgstr "" 713msgstr ""
925 714
926#: plugins/check_fping.c:460
927msgid "Note that it is necessary to set the suid flag on fping." 715msgid "Note that it is necessary to set the suid flag on fping."
928msgstr "" 716msgstr ""
929 717
930#: plugins/check_fping.c:472
931msgid "" 718msgid ""
932"name or IP Address of host to ping (IP Address bypasses name lookup, " 719"name or IP Address of host to ping (IP Address bypasses name lookup, "
933"reducing system load)" 720"reducing system load)"
934msgstr "" 721msgstr ""
935 722
936#: plugins/check_fping.c:474 plugins/check_ping.c:575
937msgid "warning threshold pair" 723msgid "warning threshold pair"
938msgstr "" 724msgstr ""
939 725
940#: plugins/check_fping.c:476 plugins/check_ping.c:577
941msgid "critical threshold pair" 726msgid "critical threshold pair"
942msgstr "" 727msgstr ""
943 728
944#: plugins/check_fping.c:478 729msgid "Return OK after first successful reply"
730msgstr ""
731
945msgid "size of ICMP packet" 732msgid "size of ICMP packet"
946msgstr "" 733msgstr ""
947 734
948#: plugins/check_fping.c:480
949msgid "number of ICMP packets to send" 735msgid "number of ICMP packets to send"
950msgstr "" 736msgstr ""
951 737
952#: plugins/check_fping.c:482
953msgid "Target timeout (ms)" 738msgid "Target timeout (ms)"
954msgstr "" 739msgstr ""
955 740
956#: plugins/check_fping.c:484
957msgid "Interval (ms) between sending packets" 741msgid "Interval (ms) between sending packets"
958msgstr "" 742msgstr ""
959 743
960#: plugins/check_fping.c:486
961msgid "name or IP Address of sourceip" 744msgid "name or IP Address of sourceip"
962msgstr "" 745msgstr ""
963 746
964#: plugins/check_fping.c:488
965msgid "source interface name" 747msgid "source interface name"
966msgstr "" 748msgstr ""
967 749
968#: plugins/check_fping.c:491
969#, c-format 750#, c-format
970msgid "" 751msgid ""
971"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time " 752"THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time "
972"(ms)" 753"(ms)"
973msgstr "" 754msgstr ""
974 755
975#: plugins/check_fping.c:492
976msgid "" 756msgid ""
977"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of" 757"which triggers a WARNING or CRITICAL state, and <pl> is the percentage of"
978msgstr "" 758msgstr ""
979 759
980#: plugins/check_fping.c:493
981msgid "packet loss to trigger an alarm state." 760msgid "packet loss to trigger an alarm state."
982msgstr "" 761msgstr ""
983 762
984#: plugins/check_fping.c:496
985msgid "IPv4 is used by default. Specify -6 to use IPv6." 763msgid "IPv4 is used by default. Specify -6 to use IPv6."
986msgstr "" 764msgstr ""
987 765
988#: plugins/check_game.c:111
989#, c-format 766#, c-format
990msgid "CRITICAL - Host type parameter incorrect!\n" 767msgid "CRITICAL - Host type parameter incorrect!\n"
991msgstr "" 768msgstr ""
992 769
993#: plugins/check_game.c:126
994#, c-format 770#, c-format
995msgid "CRITICAL - Host not found\n" 771msgid "CRITICAL - Host not found\n"
996msgstr "" 772msgstr ""
997 773
998#: plugins/check_game.c:130
999#, c-format 774#, c-format
1000msgid "CRITICAL - Game server down or unavailable\n" 775msgid "CRITICAL - Game server down or unavailable\n"
1001msgstr "" 776msgstr ""
1002 777
1003#: plugins/check_game.c:134
1004#, c-format 778#, c-format
1005msgid "CRITICAL - Game server timeout\n" 779msgid "CRITICAL - Game server timeout\n"
1006msgstr "" 780msgstr ""
1007 781
1008#: plugins/check_game.c:297
1009#, c-format 782#, c-format
1010msgid "This plugin tests game server connections with the specified host." 783msgid "This plugin tests game server connections with the specified host."
1011msgstr "" 784msgstr ""
1012 785
1013#: plugins/check_game.c:307
1014msgid "Optional port of which to connect" 786msgid "Optional port of which to connect"
1015msgstr "" 787msgstr ""
1016 788
1017#: plugins/check_game.c:309
1018msgid "Field number in raw qstat output that contains game name" 789msgid "Field number in raw qstat output that contains game name"
1019msgstr "" 790msgstr ""
1020 791
1021#: plugins/check_game.c:311
1022msgid "Field number in raw qstat output that contains map name" 792msgid "Field number in raw qstat output that contains map name"
1023msgstr "" 793msgstr ""
1024 794
1025#: plugins/check_game.c:313
1026msgid "Field number in raw qstat output that contains ping time" 795msgid "Field number in raw qstat output that contains ping time"
1027msgstr "" 796msgstr ""
1028 797
1029#: plugins/check_game.c:319
1030msgid "" 798msgid ""
1031"This plugin uses the 'qstat' command, the popular game server status query " 799"This plugin uses the 'qstat' command, the popular game server status query "
1032"tool." 800"tool."
1033msgstr "" 801msgstr ""
1034 802
1035#: plugins/check_game.c:320
1036msgid "" 803msgid ""
1037"If you don't have the package installed, you will need to download it from" 804"If you don't have the package installed, you will need to download it from"
1038msgstr "" 805msgstr ""
1039 806
1040#: plugins/check_game.c:321 807msgid "https://github.com/multiplay/qstat before you can use this plugin."
1041msgid ""
1042"http://www.activesw.com/people/steve/qstat.html before you can use this "
1043"plugin."
1044msgstr "" 808msgstr ""
1045 809
1046#: plugins/check_hpjd.c:239
1047msgid "Paper Jam" 810msgid "Paper Jam"
1048msgstr "" 811msgstr ""
1049 812
1050#: plugins/check_hpjd.c:243
1051msgid "Out of Paper" 813msgid "Out of Paper"
1052msgstr "" 814msgstr ""
1053 815
1054#: plugins/check_hpjd.c:248
1055msgid "Printer Offline" 816msgid "Printer Offline"
1056msgstr "" 817msgstr ""
1057 818
1058#: plugins/check_hpjd.c:253
1059msgid "Peripheral Error" 819msgid "Peripheral Error"
1060msgstr "" 820msgstr ""
1061 821
1062#: plugins/check_hpjd.c:257
1063msgid "Intervention Required" 822msgid "Intervention Required"
1064msgstr "" 823msgstr ""
1065 824
1066#: plugins/check_hpjd.c:261
1067msgid "Toner Low" 825msgid "Toner Low"
1068msgstr "" 826msgstr ""
1069 827
1070#: plugins/check_hpjd.c:265
1071msgid "Insufficient Memory" 828msgid "Insufficient Memory"
1072msgstr "" 829msgstr ""
1073 830
1074#: plugins/check_hpjd.c:269
1075msgid "A Door is Open" 831msgid "A Door is Open"
1076msgstr "" 832msgstr ""
1077 833
1078#: plugins/check_hpjd.c:273
1079msgid "Output Tray is Full" 834msgid "Output Tray is Full"
1080msgstr "" 835msgstr ""
1081 836
1082#: plugins/check_hpjd.c:277
1083msgid "Data too Slow for Engine" 837msgid "Data too Slow for Engine"
1084msgstr "" 838msgstr ""
1085 839
1086#: plugins/check_hpjd.c:281
1087msgid "Unknown Paper Error" 840msgid "Unknown Paper Error"
1088msgstr "" 841msgstr ""
1089 842
1090#: plugins/check_hpjd.c:286
1091#, c-format 843#, c-format
1092msgid "Printer ok - (%s)\n" 844msgid "Printer ok - (%s)\n"
1093msgstr "" 845msgstr ""
1094 846
1095#: plugins/check_hpjd.c:391 847msgid "Port must be a positive short integer"
848msgstr ""
849
1096msgid "This plugin tests the STATUS of an HP printer with a JetDirect card." 850msgid "This plugin tests the STATUS of an HP printer with a JetDirect card."
1097msgstr "" 851msgstr ""
1098 852
1099#: plugins/check_hpjd.c:392
1100msgid "Net-snmp must be installed on the computer running the plugin." 853msgid "Net-snmp must be installed on the computer running the plugin."
1101msgstr "" 854msgstr ""
1102 855
1103#: plugins/check_hpjd.c:402
1104msgid "The SNMP community name " 856msgid "The SNMP community name "
1105msgstr "" 857msgstr ""
1106 858
1107#: plugins/check_hpjd.c:403
1108#, c-format 859#, c-format
1109msgid "(default=%s)" 860msgid "(default=%s)"
1110msgstr "" 861msgstr ""
1111 862
1112#: plugins/check_http.c:189 863msgid "Specify the port to check "
864msgstr ""
865
866msgid "Disable paper check "
867msgstr ""
868
1113msgid "file does not exist or is not readable" 869msgid "file does not exist or is not readable"
1114msgstr "" 870msgstr ""
1115 871
1116#: plugins/check_http.c:310 plugins/check_http.c:315 plugins/check_http.c:321
1117#: plugins/check_smtp.c:600 plugins/check_tcp.c:576 plugins/check_tcp.c:580
1118#: plugins/check_tcp.c:586
1119msgid "Invalid certificate expiration period" 872msgid "Invalid certificate expiration period"
1120msgstr "" 873msgstr ""
1121 874
1122#: plugins/check_http.c:348
1123msgid "" 875msgid ""
1124"Invalid option - Valid values for SSL Version are 1 (TLSv1), 2 (SSLv2) or 3 " 876"Invalid option - Valid SSL/TLS versions: 2, 3, 1, 1.1, 1.2 (with optional "
1125"(SSLv3)" 877"'+' suffix)"
1126msgstr "" 878msgstr ""
1127 879
1128#: plugins/check_http.c:354 plugins/check_tcp.c:599
1129msgid "Invalid option - SSL is not available" 880msgid "Invalid option - SSL is not available"
1130msgstr "" 881msgstr ""
1131 882
1132#: plugins/check_http.c:375 883msgid "Invalid max_redirs count"
884msgstr ""
885
1133msgid "Invalid onredirect option" 886msgid "Invalid onredirect option"
1134msgstr "" 887msgstr ""
1135 888
1136#: plugins/check_http.c:377
1137#, c-format 889#, c-format
1138msgid "option f:%d \n" 890msgid "option f:%d \n"
1139msgstr "" 891msgstr ""
1140 892
1141#: plugins/check_http.c:398
1142msgid "Invalid port number" 893msgid "Invalid port number"
1143msgstr "" 894msgstr ""
1144 895
1145#: plugins/check_http.c:450
1146#, c-format 896#, c-format
1147msgid "Could Not Compile Regular Expression: %s" 897msgid "Could Not Compile Regular Expression: %s"
1148msgstr "" 898msgstr ""
1149 899
1150#: plugins/check_http.c:464 plugins/check_ntp.c:722
1151#: plugins/check_ntp_peer.c:513 plugins/check_ntp_time.c:512
1152#: plugins/check_smtp.c:621 plugins/check_ssh.c:149 plugins/check_tcp.c:477
1153msgid "IPv6 support not available" 900msgid "IPv6 support not available"
1154msgstr "" 901msgstr ""
1155 902
1156#: plugins/check_http.c:529 plugins/check_ping.c:422
1157msgid "You must specify a server address or host name" 903msgid "You must specify a server address or host name"
1158msgstr "" 904msgstr ""
1159 905
1160#: plugins/check_http.c:543
1161msgid "" 906msgid ""
1162"If you use a client certificate you must also specify a private key file" 907"If you use a client certificate you must also specify a private key file"
1163msgstr "" 908msgstr ""
1164 909
1165#: plugins/check_http.c:667 plugins/check_http.c:835
1166msgid "HTTP UNKNOWN - Memory allocation error\n" 910msgid "HTTP UNKNOWN - Memory allocation error\n"
1167msgstr "" 911msgstr ""
1168 912
1169#: plugins/check_http.c:739
1170#, c-format 913#, c-format
1171msgid "%sServer date unknown, " 914msgid "%sServer date unknown, "
1172msgstr "" 915msgstr ""
1173 916
1174#: plugins/check_http.c:742
1175#, c-format 917#, c-format
1176msgid "%sDocument modification date unknown, " 918msgid "%sDocument modification date unknown, "
1177msgstr "" 919msgstr ""
1178 920
1179#: plugins/check_http.c:749
1180#, c-format 921#, c-format
1181msgid "%sServer date \"%100s\" unparsable, " 922msgid "%sServer date \"%100s\" unparsable, "
1182msgstr "" 923msgstr ""
1183 924
1184#: plugins/check_http.c:752
1185#, c-format 925#, c-format
1186msgid "%sDocument date \"%100s\" unparsable, " 926msgid "%sDocument date \"%100s\" unparsable, "
1187msgstr "" 927msgstr ""
1188 928
1189#: plugins/check_http.c:755
1190#, c-format 929#, c-format
1191msgid "%sDocument is %d seconds in the future, " 930msgid "%sDocument is %d seconds in the future, "
1192msgstr "" 931msgstr ""
1193 932
1194#: plugins/check_http.c:760
1195#, c-format 933#, c-format
1196msgid "%sLast modified %.1f days ago, " 934msgid "%sLast modified %.1f days ago, "
1197msgstr "" 935msgstr ""
1198 936
1199#: plugins/check_http.c:763
1200#, c-format 937#, c-format
1201msgid "%sLast modified %d:%02d:%02d ago, " 938msgid "%sLast modified %d:%02d:%02d ago, "
1202msgstr "" 939msgstr ""
1203 940
1204#: plugins/check_http.c:876
1205msgid "HTTP CRITICAL - Unable to open TCP socket\n" 941msgid "HTTP CRITICAL - Unable to open TCP socket\n"
1206msgstr "" 942msgstr ""
1207 943
1208#: plugins/check_http.c:995 944msgid "HTTP UNKNOWN - Could not allocate memory for full_page\n"
945msgstr ""
946
1209msgid "HTTP CRITICAL - Error on receive\n" 947msgid "HTTP CRITICAL - Error on receive\n"
1210msgstr "" 948msgstr ""
1211 949
1212#: plugins/check_http.c:1005
1213msgid "HTTP CRITICAL - No data received from host\n" 950msgid "HTTP CRITICAL - No data received from host\n"
1214msgstr "" 951msgstr ""
1215 952
1216#: plugins/check_http.c:1056
1217#, c-format 953#, c-format
1218msgid "Invalid HTTP response received from host: %s\n" 954msgid "Invalid HTTP response received from host: %s\n"
1219msgstr "" 955msgstr ""
1220 956
1221#: plugins/check_http.c:1060
1222#, c-format 957#, c-format
1223msgid "Invalid HTTP response received from host on port %d: %s\n" 958msgid "Invalid HTTP response received from host on port %d: %s\n"
1224msgstr "" 959msgstr ""
1225 960
1226#: plugins/check_http.c:1069 961#, c-format
962msgid ""
963"%s\n"
964"%s"
965msgstr ""
966
1227#, c-format 967#, c-format
1228msgid "Status line output matched \"%s\" - " 968msgid "Status line output matched \"%s\" - "
1229msgstr "" 969msgstr ""
1230 970
1231#: plugins/check_http.c:1080
1232#, c-format 971#, c-format
1233msgid "HTTP CRITICAL: Invalid Status Line (%s)\n" 972msgid "HTTP CRITICAL: Invalid Status Line (%s)\n"
1234msgstr "" 973msgstr ""
1235 974
1236#: plugins/check_http.c:1087
1237#, c-format 975#, c-format
1238msgid "HTTP CRITICAL: Invalid Status (%s)\n" 976msgid "HTTP CRITICAL: Invalid Status (%s)\n"
1239msgstr "" 977msgstr ""
1240 978
1241#: plugins/check_http.c:1091 plugins/check_http.c:1096
1242#: plugins/check_http.c:1106 plugins/check_http.c:1110
1243#, c-format 979#, c-format
1244msgid "%s - " 980msgid "%s - "
1245msgstr "" 981msgstr ""
1246 982
1247#: plugins/check_http.c:1129
1248#, c-format 983#, c-format
1249msgid "%sheader '%s' not found on '%s://%s:%d%s', " 984msgid "%sheader '%s' not found on '%s://%s:%d%s', "
1250msgstr "" 985msgstr ""
1251 986
1252#: plugins/check_http.c:1141
1253#, c-format 987#, c-format
1254msgid "%sstring '%s' not found on '%s://%s:%d%s', " 988msgid "%sstring '%s' not found on '%s://%s:%d%s', "
1255msgstr "" 989msgstr ""
1256 990
1257#: plugins/check_http.c:1154
1258#, c-format 991#, c-format
1259msgid "%spattern not found, " 992msgid "%spattern not found, "
1260msgstr "" 993msgstr ""
1261 994
1262#: plugins/check_http.c:1156
1263#, c-format 995#, c-format
1264msgid "%spattern found, " 996msgid "%spattern found, "
1265msgstr "" 997msgstr ""
1266 998
1267#: plugins/check_http.c:1162
1268#, c-format 999#, c-format
1269msgid "%sExecute Error: %s, " 1000msgid "%sExecute Error: %s, "
1270msgstr "" 1001msgstr ""
1271 1002
1272#: plugins/check_http.c:1178
1273#, c-format 1003#, c-format
1274msgid "%spage size %d too large, " 1004msgid "%spage size %d too large, "
1275msgstr "" 1005msgstr ""
1276 1006
1277#: plugins/check_http.c:1181
1278#, c-format 1007#, c-format
1279msgid "%spage size %d too small, " 1008msgid "%spage size %d too small, "
1280msgstr "" 1009msgstr ""
1281 1010
1282#: plugins/check_http.c:1194
1283#, c-format 1011#, c-format
1284msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s" 1012msgid "%s - %d bytes in %.3f second response time %s|%s %s %s %s %s %s %s"
1285msgstr "" 1013msgstr ""
1286 1014
1287#: plugins/check_http.c:1206
1288#, c-format 1015#, c-format
1289msgid "%s - %d bytes in %.3f second response time %s|%s %s" 1016msgid "%s - %d bytes in %.3f second response time %s|%s %s"
1290msgstr "" 1017msgstr ""
1291 1018
1292#: plugins/check_http.c:1244
1293msgid "HTTP UNKNOWN - Could not allocate addr\n" 1019msgid "HTTP UNKNOWN - Could not allocate addr\n"
1294msgstr "" 1020msgstr ""
1295 1021
1296#: plugins/check_http.c:1248 plugins/check_http.c:1279
1297msgid "HTTP UNKNOWN - Could not allocate URL\n" 1022msgid "HTTP UNKNOWN - Could not allocate URL\n"
1298msgstr "" 1023msgstr ""
1299 1024
1300#: plugins/check_http.c:1257
1301#, c-format 1025#, c-format
1302msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n" 1026msgid "HTTP UNKNOWN - Could not find redirect location - %s%s\n"
1303msgstr "" 1027msgstr ""
1304 1028
1305#: plugins/check_http.c:1272
1306#, c-format 1029#, c-format
1307msgid "HTTP UNKNOWN - Empty redirect location%s\n" 1030msgid "HTTP UNKNOWN - Empty redirect location%s\n"
1308msgstr "" 1031msgstr ""
1309 1032
1310#: plugins/check_http.c:1322
1311#, c-format 1033#, c-format
1312msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n" 1034msgid "HTTP UNKNOWN - Could not parse redirect location - %s%s\n"
1313msgstr "" 1035msgstr ""
1314 1036
1315#: plugins/check_http.c:1332
1316#, c-format 1037#, c-format
1317msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n" 1038msgid "HTTP WARNING - maximum redirection depth %d exceeded - %s://%s:%d%s%s\n"
1318msgstr "" 1039msgstr ""
1319 1040
1320#: plugins/check_http.c:1340
1321#, c-format 1041#, c-format
1322msgid "HTTP WARNING - redirection creates an infinite loop - %s://%s:%d%s%s\n" 1042msgid "HTTP CRITICAL - redirection creates an infinite loop - %s://%s:%d%s%s\n"
1323msgstr "" 1043msgstr ""
1324 1044
1325#: plugins/check_http.c:1361
1326#, c-format 1045#, c-format
1327msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n" 1046msgid "HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"
1328msgstr "" 1047msgstr ""
1329 1048
1330#: plugins/check_http.c:1366
1331#, c-format 1049#, c-format
1332msgid "Redirection to %s://%s:%d%s\n" 1050msgid "Redirection to %s://%s:%d%s\n"
1333msgstr "" 1051msgstr ""
1334 1052
1335#: plugins/check_http.c:1440
1336msgid "This plugin tests the HTTP service on the specified host. It can test" 1053msgid "This plugin tests the HTTP service on the specified host. It can test"
1337msgstr "" 1054msgstr ""
1338 1055
1339#: plugins/check_http.c:1441
1340msgid "normal (http) and secure (https) servers, follow redirects, search for" 1056msgid "normal (http) and secure (https) servers, follow redirects, search for"
1341msgstr "" 1057msgstr ""
1342 1058
1343#: plugins/check_http.c:1442
1344msgid "strings and regular expressions, check connection times, and report on" 1059msgid "strings and regular expressions, check connection times, and report on"
1345msgstr "" 1060msgstr ""
1346 1061
1347#: plugins/check_http.c:1443
1348msgid "certificate expiration times." 1062msgid "certificate expiration times."
1349msgstr "" 1063msgstr ""
1350 1064
1351#: plugins/check_http.c:1449 1065#, c-format
1066msgid "In the first form, make an HTTP request."
1067msgstr ""
1068
1069#, c-format
1070msgid ""
1071"In the second form, connect to the server and check the TLS certificate."
1072msgstr ""
1073
1352#, c-format 1074#, c-format
1353msgid "NOTE: One or both of -H and -I must be specified" 1075msgid "NOTE: One or both of -H and -I must be specified"
1354msgstr "" 1076msgstr ""
1355 1077
1356#: plugins/check_http.c:1457
1357msgid "Host name argument for servers using host headers (virtual host)" 1078msgid "Host name argument for servers using host headers (virtual host)"
1358msgstr "" 1079msgstr ""
1359 1080
1360#: plugins/check_http.c:1458
1361msgid "Append a port to include it in the header (eg: example.com:5000)" 1081msgid "Append a port to include it in the header (eg: example.com:5000)"
1362msgstr "" 1082msgstr ""
1363 1083
1364#: plugins/check_http.c:1460
1365msgid "" 1084msgid ""
1366"IP address or name (use numeric address if possible to bypass DNS lookup)." 1085"IP address or name (use numeric address if possible to bypass DNS lookup)."
1367msgstr "" 1086msgstr ""
1368 1087
1369#: plugins/check_http.c:1462
1370msgid "Port number (default: " 1088msgid "Port number (default: "
1371msgstr "" 1089msgstr ""
1372 1090
1373#: plugins/check_http.c:1469
1374msgid "" 1091msgid ""
1375"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents" 1092"Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"
1376msgstr "" 1093msgstr ""
1377 1094
1378#: plugins/check_http.c:1470 1095msgid "auto-negotiation (2 = SSLv2, 3 = SSLv3, 1 = TLSv1, 1.1 = TLSv1.1,"
1379msgid "auto-negotiation (1 = TLSv1, 2 = SSLv2, 3 = SSLv3)." 1096msgstr ""
1097
1098msgid "1.2 = TLSv1.2). With a '+' suffix, newer versions are also accepted."
1380msgstr "" 1099msgstr ""
1381 1100
1382#: plugins/check_http.c:1472
1383msgid "Enable SSL/TLS hostname extension support (SNI)" 1101msgid "Enable SSL/TLS hostname extension support (SNI)"
1384msgstr "" 1102msgstr ""
1385 1103
1386#: plugins/check_http.c:1474
1387msgid "" 1104msgid ""
1388"Minimum number of days a certificate has to be valid. Port defaults to 443" 1105"Minimum number of days a certificate has to be valid. Port defaults to 443"
1389msgstr "" 1106msgstr ""
1390 1107
1391#: plugins/check_http.c:1475 1108msgid ""
1392msgid "(when this option is used the URL is not checked.)" 1109"(when this option is used the URL is not checked by default. You can use"
1110msgstr ""
1111
1112msgid " --continue-after-certificate to override this behavior)"
1113msgstr ""
1114
1115msgid ""
1116"Allows the HTTP check to continue after performing the certificate check."
1117msgstr ""
1118
1119msgid "Does nothing unless -C is used."
1393msgstr "" 1120msgstr ""
1394 1121
1395#: plugins/check_http.c:1477
1396msgid "Name of file that contains the client certificate (PEM format)" 1122msgid "Name of file that contains the client certificate (PEM format)"
1397msgstr "" 1123msgstr ""
1398 1124
1399#: plugins/check_http.c:1478
1400msgid "to be used in establishing the SSL session" 1125msgid "to be used in establishing the SSL session"
1401msgstr "" 1126msgstr ""
1402 1127
1403#: plugins/check_http.c:1480
1404msgid "Name of file containing the private key (PEM format)" 1128msgid "Name of file containing the private key (PEM format)"
1405msgstr "" 1129msgstr ""
1406 1130
1407#: plugins/check_http.c:1481
1408msgid "matching the client certificate" 1131msgid "matching the client certificate"
1409msgstr "" 1132msgstr ""
1410 1133
1411#: plugins/check_http.c:1485
1412msgid "Comma-delimited list of strings, at least one of them is expected in" 1134msgid "Comma-delimited list of strings, at least one of them is expected in"
1413msgstr "" 1135msgstr ""
1414 1136
1415#: plugins/check_http.c:1486
1416msgid "the first (status) line of the server response (default: " 1137msgid "the first (status) line of the server response (default: "
1417msgstr "" 1138msgstr ""
1418 1139
1419#: plugins/check_http.c:1488
1420msgid "" 1140msgid ""
1421"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)" 1141"If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"
1422msgstr "" 1142msgstr ""
1423 1143
1424#: plugins/check_http.c:1490
1425msgid "String to expect in the response headers" 1144msgid "String to expect in the response headers"
1426msgstr "" 1145msgstr ""
1427 1146
1428#: plugins/check_http.c:1492
1429msgid "String to expect in the content" 1147msgid "String to expect in the content"
1430msgstr "" 1148msgstr ""
1431 1149
1432#: plugins/check_http.c:1494
1433msgid "URL to GET or POST (default: /)" 1150msgid "URL to GET or POST (default: /)"
1434msgstr "" 1151msgstr ""
1435 1152
1436#: plugins/check_http.c:1496
1437msgid "URL encoded http POST data" 1153msgid "URL encoded http POST data"
1438msgstr "" 1154msgstr ""
1439 1155
1440#: plugins/check_http.c:1498
1441msgid "Set HTTP method." 1156msgid "Set HTTP method."
1442msgstr "" 1157msgstr ""
1443 1158
1444#: plugins/check_http.c:1500
1445msgid "Don't wait for document body: stop reading after headers." 1159msgid "Don't wait for document body: stop reading after headers."
1446msgstr "" 1160msgstr ""
1447 1161
1448#: plugins/check_http.c:1501
1449msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)" 1162msgid "(Note that this still does an HTTP GET or POST, not a HEAD.)"
1450msgstr "" 1163msgstr ""
1451 1164
1452#: plugins/check_http.c:1503
1453msgid "Warn if document is more than SECONDS old. the number can also be of" 1165msgid "Warn if document is more than SECONDS old. the number can also be of"
1454msgstr "" 1166msgstr ""
1455 1167
1456#: plugins/check_http.c:1504
1457msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days." 1168msgid "the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."
1458msgstr "" 1169msgstr ""
1459 1170
1460#: plugins/check_http.c:1506
1461msgid "specify Content-Type header media type when POSTing\n" 1171msgid "specify Content-Type header media type when POSTing\n"
1462msgstr "" 1172msgstr ""
1463 1173
1464#: plugins/check_http.c:1509
1465msgid "Allow regex to span newlines (must precede -r or -R)" 1174msgid "Allow regex to span newlines (must precede -r or -R)"
1466msgstr "" 1175msgstr ""
1467 1176
1468#: plugins/check_http.c:1511
1469msgid "Search page for regex STRING" 1177msgid "Search page for regex STRING"
1470msgstr "" 1178msgstr ""
1471 1179
1472#: plugins/check_http.c:1513
1473msgid "Search page for case-insensitive regex STRING" 1180msgid "Search page for case-insensitive regex STRING"
1474msgstr "" 1181msgstr ""
1475 1182
1476#: plugins/check_http.c:1515
1477msgid "Return CRITICAL if found, OK if not\n" 1183msgid "Return CRITICAL if found, OK if not\n"
1478msgstr "" 1184msgstr ""
1479 1185
1480#: plugins/check_http.c:1518
1481msgid "Username:password on sites with basic authentication" 1186msgid "Username:password on sites with basic authentication"
1482msgstr "" 1187msgstr ""
1483 1188
1484#: plugins/check_http.c:1520
1485msgid "Username:password on proxy-servers with basic authentication" 1189msgid "Username:password on proxy-servers with basic authentication"
1486msgstr "" 1190msgstr ""
1487 1191
1488#: plugins/check_http.c:1522
1489msgid "String to be sent in http header as \"User Agent\"" 1192msgid "String to be sent in http header as \"User Agent\""
1490msgstr "" 1193msgstr ""
1491 1194
1492#: plugins/check_http.c:1524
1493msgid "" 1195msgid ""
1494"Any other tags to be sent in http header. Use multiple times for additional " 1196"Any other tags to be sent in http header. Use multiple times for additional "
1495"headers" 1197"headers"
1496msgstr "" 1198msgstr ""
1497 1199
1498#: plugins/check_http.c:1526
1499msgid "Print additional performance data" 1200msgid "Print additional performance data"
1500msgstr "" 1201msgstr ""
1501 1202
1502#: plugins/check_http.c:1528 1203msgid "Print body content below status line"
1204msgstr ""
1205
1503msgid "Wrap output in HTML link (obsoleted by urlize)" 1206msgid "Wrap output in HTML link (obsoleted by urlize)"
1504msgstr "" 1207msgstr ""
1505 1208
1506#: plugins/check_http.c:1530
1507msgid "How to handle redirected pages. sticky is like follow but stick to the" 1209msgid "How to handle redirected pages. sticky is like follow but stick to the"
1508msgstr "" 1210msgstr ""
1509 1211
1510#: plugins/check_http.c:1531
1511msgid "specified IP address. stickyport also ensures port stays the same." 1212msgid "specified IP address. stickyport also ensures port stays the same."
1512msgstr "" 1213msgstr ""
1513 1214
1514#: plugins/check_http.c:1533 1215msgid "Maximal number of redirects (default: "
1216msgstr ""
1217
1515msgid "Minimum page size required (bytes) : Maximum page size required (bytes)" 1218msgid "Minimum page size required (bytes) : Maximum page size required (bytes)"
1516msgstr "" 1219msgstr ""
1517 1220
1518#: plugins/check_http.c:1543
1519msgid "This plugin will attempt to open an HTTP connection with the host." 1221msgid "This plugin will attempt to open an HTTP connection with the host."
1520msgstr "" 1222msgstr ""
1521 1223
1522#: plugins/check_http.c:1544
1523msgid "" 1224msgid ""
1524"Successful connects return STATE_OK, refusals and timeouts return " 1225"Successful connects return STATE_OK, refusals and timeouts return "
1525"STATE_CRITICAL" 1226"STATE_CRITICAL"
1526msgstr "" 1227msgstr ""
1527 1228
1528#: plugins/check_http.c:1545
1529msgid "" 1229msgid ""
1530"other errors return STATE_UNKNOWN. Successful connects, but incorrect " 1230"other errors return STATE_UNKNOWN. Successful connects, but incorrect "
1531"response" 1231"response"
1532msgstr "" 1232msgstr ""
1533 1233
1534#: plugins/check_http.c:1546
1535msgid "" 1234msgid ""
1536"messages from the host result in STATE_WARNING return values. If you are" 1235"messages from the host result in STATE_WARNING return values. If you are"
1537msgstr "" 1236msgstr ""
1538 1237
1539#: plugins/check_http.c:1547
1540msgid "" 1238msgid ""
1541"checking a virtual server that uses 'host headers' you must supply the FQDN" 1239"checking a virtual server that uses 'host headers' you must supply the FQDN"
1542msgstr "" 1240msgstr ""
1543 1241
1544#: plugins/check_http.c:1548
1545msgid "(fully qualified domain name) as the [host_name] argument." 1242msgid "(fully qualified domain name) as the [host_name] argument."
1546msgstr "" 1243msgstr ""
1547 1244
1548#: plugins/check_http.c:1552
1549msgid "This plugin can also check whether an SSL enabled web server is able to" 1245msgid "This plugin can also check whether an SSL enabled web server is able to"
1550msgstr "" 1246msgstr ""
1551 1247
1552#: plugins/check_http.c:1553
1553msgid "serve content (optionally within a specified time) or whether the X509 " 1248msgid "serve content (optionally within a specified time) or whether the X509 "
1554msgstr "" 1249msgstr ""
1555 1250
1556#: plugins/check_http.c:1554
1557msgid "certificate is still valid for the specified number of days." 1251msgid "certificate is still valid for the specified number of days."
1558msgstr "" 1252msgstr ""
1559 1253
1560#: plugins/check_http.c:1556
1561msgid "Please note that this plugin does not check if the presented server" 1254msgid "Please note that this plugin does not check if the presented server"
1562msgstr "" 1255msgstr ""
1563 1256
1564#: plugins/check_http.c:1557
1565msgid "certificate matches the hostname of the server, or if the certificate" 1257msgid "certificate matches the hostname of the server, or if the certificate"
1566msgstr "" 1258msgstr ""
1567 1259
1568#: plugins/check_http.c:1558
1569msgid "has a valid chain of trust to one of the locally installed CAs." 1260msgid "has a valid chain of trust to one of the locally installed CAs."
1570msgstr "" 1261msgstr ""
1571 1262
1572#: plugins/check_http.c:1562
1573msgid "" 1263msgid ""
1574"When the 'www.verisign.com' server returns its content within 5 seconds," 1264"When the 'www.verisign.com' server returns its content within 5 seconds,"
1575msgstr "" 1265msgstr ""
1576 1266
1577#: plugins/check_http.c:1563
1578msgid "" 1267msgid ""
1579"a STATE_OK will be returned. When the server returns its content but exceeds" 1268"a STATE_OK will be returned. When the server returns its content but exceeds"
1580msgstr "" 1269msgstr ""
1581 1270
1582#: plugins/check_http.c:1564
1583msgid "" 1271msgid ""
1584"the 5-second threshold, a STATE_WARNING will be returned. When an error " 1272"the 5-second threshold, a STATE_WARNING will be returned. When an error "
1585"occurs," 1273"occurs,"
1586msgstr "" 1274msgstr ""
1587 1275
1588#: plugins/check_http.c:1565
1589msgid "a STATE_CRITICAL will be returned." 1276msgid "a STATE_CRITICAL will be returned."
1590msgstr "" 1277msgstr ""
1591 1278
1592#: plugins/check_http.c:1568
1593msgid "" 1279msgid ""
1594"When the certificate of 'www.verisign.com' is valid for more than 14 days," 1280"When the certificate of 'www.verisign.com' is valid for more than 14 days,"
1595msgstr "" 1281msgstr ""
1596 1282
1597#: plugins/check_http.c:1569 plugins/check_http.c:1575
1598msgid "" 1283msgid ""
1599"a STATE_OK is returned. When the certificate is still valid, but for less " 1284"a STATE_OK is returned. When the certificate is still valid, but for less "
1600"than" 1285"than"
1601msgstr "" 1286msgstr ""
1602 1287
1603#: plugins/check_http.c:1570
1604msgid "" 1288msgid ""
1605"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when" 1289"14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when"
1606msgstr "" 1290msgstr ""
1607 1291
1608#: plugins/check_http.c:1571
1609msgid "the certificate is expired." 1292msgid "the certificate is expired."
1610msgstr "" 1293msgstr ""
1611 1294
1612#: plugins/check_http.c:1574
1613msgid "" 1295msgid ""
1614"When the certificate of 'www.verisign.com' is valid for more than 30 days," 1296"When the certificate of 'www.verisign.com' is valid for more than 30 days,"
1615msgstr "" 1297msgstr ""
1616 1298
1617#: plugins/check_http.c:1576
1618msgid "30 days, but more than 14 days, a STATE_WARNING is returned." 1299msgid "30 days, but more than 14 days, a STATE_WARNING is returned."
1619msgstr "" 1300msgstr ""
1620 1301
1621#: plugins/check_http.c:1577
1622msgid "" 1302msgid ""
1623"A STATE_CRITICAL will be returned when certificate expires in less than 14 " 1303"A STATE_CRITICAL will be returned when certificate expires in less than 14 "
1624"days" 1304"days"
1625msgstr "" 1305msgstr ""
1626 1306
1627#: plugins/check_ldap.c:133 1307msgid ""
1308"check_http -I 192.168.100.35 -p 80 -u https://www.verisign.com/ -S -j "
1309"CONNECT -H www.verisign.com "
1310msgstr ""
1311
1312msgid ""
1313"all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -"
1314"S(sl) -j CONNECT -H <webserver>"
1315msgstr ""
1316
1317msgid ""
1318"a STATE_CRITICAL will be returned. By adding a colon to the method you can "
1319"set the method used"
1320msgstr ""
1321
1322msgid "inside the proxied connection: -j CONNECT:POST"
1323msgstr ""
1324
1628#, c-format 1325#, c-format
1629msgid "Could not connect to the server at port %i\n" 1326msgid "Could not connect to the server at port %i\n"
1630msgstr "" 1327msgstr ""
1631 1328
1632#: plugins/check_ldap.c:142
1633#, c-format 1329#, c-format
1634msgid "Could not set protocol version %d\n" 1330msgid "Could not set protocol version %d\n"
1635msgstr "" 1331msgstr ""
1636 1332
1637#: plugins/check_ldap.c:157
1638#, c-format 1333#, c-format
1639msgid "Could not init TLS at port %i!\n" 1334msgid "Could not init TLS at port %i!\n"
1640msgstr "" 1335msgstr ""
1641 1336
1642#: plugins/check_ldap.c:161
1643#, c-format 1337#, c-format
1644msgid "TLS not supported by the libraries!\n" 1338msgid "TLS not supported by the libraries!\n"
1645msgstr "" 1339msgstr ""
1646 1340
1647#: plugins/check_ldap.c:181
1648#, c-format 1341#, c-format
1649msgid "Could not init startTLS at port %i!\n" 1342msgid "Could not init startTLS at port %i!\n"
1650msgstr "" 1343msgstr ""
1651 1344
1652#: plugins/check_ldap.c:185
1653#, c-format 1345#, c-format
1654msgid "startTLS not supported by the library, needs LDAPv3!\n" 1346msgid "startTLS not supported by the library, needs LDAPv3!\n"
1655msgstr "" 1347msgstr ""
1656 1348
1657#: plugins/check_ldap.c:195
1658#, c-format 1349#, c-format
1659msgid "Could not bind to the LDAP server\n" 1350msgid "Could not bind to the LDAP server\n"
1660msgstr "" 1351msgstr ""
1661 1352
1662#: plugins/check_ldap.c:204
1663#, c-format 1353#, c-format
1664msgid "Could not search/find objectclasses in %s\n" 1354msgid "Could not search/find objectclasses in %s\n"
1665msgstr "" 1355msgstr ""
1666 1356
1667#: plugins/check_ldap.c:227 1357#, c-format
1358msgid "LDAP %s - found %d entries in %.3f seconds|%s %s\n"
1359msgstr ""
1360
1668#, c-format 1361#, c-format
1669msgid "LDAP %s - %.3f seconds response time|%s\n" 1362msgid "LDAP %s - %.3f seconds response time|%s\n"
1670msgstr "" 1363msgstr ""
1671 1364
1672#: plugins/check_ldap.c:339 plugins/check_ldap.c:347
1673#, c-format 1365#, c-format
1674msgid "%s cannot be combined with %s" 1366msgid "%s cannot be combined with %s"
1675msgstr "" 1367msgstr ""
1676 1368
1677#: plugins/check_ldap.c:379
1678msgid "Please specify the host name\n" 1369msgid "Please specify the host name\n"
1679msgstr "" 1370msgstr ""
1680 1371
1681#: plugins/check_ldap.c:382
1682msgid "Please specify the LDAP base\n" 1372msgid "Please specify the LDAP base\n"
1683msgstr "" 1373msgstr ""
1684 1374
1685#: plugins/check_ldap.c:411
1686msgid "ldap attribute to search (default: \"(objectclass=*)\"" 1375msgid "ldap attribute to search (default: \"(objectclass=*)\""
1687msgstr "" 1376msgstr ""
1688 1377
1689#: plugins/check_ldap.c:413
1690msgid "ldap base (eg. ou=my unit, o=my org, c=at" 1378msgid "ldap base (eg. ou=my unit, o=my org, c=at"
1691msgstr "" 1379msgstr ""
1692 1380
1693#: plugins/check_ldap.c:415
1694msgid "ldap bind DN (if required)" 1381msgid "ldap bind DN (if required)"
1695msgstr "" 1382msgstr ""
1696 1383
1697#: plugins/check_ldap.c:417 1384msgid ""
1698msgid "ldap password (if required)" 1385"ldap password (if required, or set the password through environment variable "
1386"'LDAP_PASSWORD')"
1699msgstr "" 1387msgstr ""
1700 1388
1701#: plugins/check_ldap.c:419
1702msgid "use starttls mechanism introduced in protocol version 3" 1389msgid "use starttls mechanism introduced in protocol version 3"
1703msgstr "" 1390msgstr ""
1704 1391
1705#: plugins/check_ldap.c:421
1706msgid "use ldaps (ldap v2 ssl method). this also sets the default port to" 1392msgid "use ldaps (ldap v2 ssl method). this also sets the default port to"
1707msgstr "" 1393msgstr ""
1708 1394
1709#: plugins/check_ldap.c:425
1710msgid "use ldap protocol version 2" 1395msgid "use ldap protocol version 2"
1711msgstr "" 1396msgstr ""
1712 1397
1713#: plugins/check_ldap.c:427
1714msgid "use ldap protocol version 3" 1398msgid "use ldap protocol version 3"
1715msgstr "" 1399msgstr ""
1716 1400
1717#: plugins/check_ldap.c:428
1718msgid "default protocol version:" 1401msgid "default protocol version:"
1719msgstr "" 1402msgstr ""
1720 1403
1721#: plugins/check_ldap.c:439 1404msgid "Number of found entries to result in warning status"
1405msgstr ""
1406
1407msgid "Number of found entries to result in critical status"
1408msgstr ""
1409
1722msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be" 1410msgid "If this plugin is called via 'check_ldaps', method 'STARTTLS' will be"
1723msgstr "" 1411msgstr ""
1724 1412
1725#: plugins/check_ldap.c:440
1726#, c-format 1413#, c-format
1727msgid "" 1414msgid ""
1728" implied (using default port %i) unless --port=636 is specified. In that " 1415" implied (using default port %i) unless --port=636 is specified. In that "
1729"case\n" 1416"case\n"
1730msgstr "" 1417msgstr ""
1731 1418
1732#: plugins/check_ldap.c:441
1733msgid "'SSL on connect' will be used no matter how the plugin was called." 1419msgid "'SSL on connect' will be used no matter how the plugin was called."
1734msgstr "" 1420msgstr ""
1735 1421
1736#: plugins/check_ldap.c:442
1737msgid "" 1422msgid ""
1738"This detection is deprecated, please use 'check_ldap' with the '--starttls' " 1423"This detection is deprecated, please use 'check_ldap' with the '--starttls' "
1739"or '--ssl' flags" 1424"or '--ssl' flags"
1740msgstr "" 1425msgstr ""
1741 1426
1742#: plugins/check_ldap.c:443
1743msgid "to define the behaviour explicitly instead." 1427msgid "to define the behaviour explicitly instead."
1744msgstr "" 1428msgstr ""
1745 1429
1746#: plugins/check_load.c:87 1430msgid "The parameters --warn-entries and --crit-entries are optional."
1431msgstr ""
1432
1747msgid "Warning threshold must be float or float triplet!\n" 1433msgid "Warning threshold must be float or float triplet!\n"
1748msgstr "" 1434msgstr ""
1749 1435
1750#: plugins/check_load.c:132 plugins/check_load.c:148
1751#, c-format 1436#, c-format
1752msgid "Error opening %s\n" 1437msgid "Error opening %s\n"
1753msgstr "" 1438msgstr ""
1754 1439
1755#: plugins/check_load.c:163
1756#, c-format 1440#, c-format
1757msgid "could not parse load from uptime: %s\n" 1441msgid "could not parse load from uptime %s: %d\n"
1758msgstr "" 1442msgstr ""
1759 1443
1760#: plugins/check_load.c:169
1761#, c-format 1444#, c-format
1762msgid "Error code %d returned in %s\n" 1445msgid "Error code %d returned in %s\n"
1763msgstr "" 1446msgstr ""
1764 1447
1765#: plugins/check_load.c:184
1766#, c-format 1448#, c-format
1767msgid "Error in getloadavg()\n" 1449msgid "Error in getloadavg()\n"
1768msgstr "" 1450msgstr ""
1769 1451
1770#: plugins/check_load.c:187 plugins/check_load.c:189
1771#, c-format 1452#, c-format
1772msgid "Error processing %s\n" 1453msgid "Error processing %s\n"
1773msgstr "" 1454msgstr ""
1774 1455
1775#: plugins/check_load.c:198
1776#, c-format 1456#, c-format
1777msgid "load average: %.2f, %.2f, %.2f" 1457msgid "load average: %.2f, %.2f, %.2f"
1778msgstr "" 1458msgstr ""
1779 1459
1780#: plugins/check_load.c:291
1781#, c-format 1460#, c-format
1782msgid "Critical threshold for %d-minute load average is not specified\n" 1461msgid "Critical threshold for %d-minute load average is not specified\n"
1783msgstr "" 1462msgstr ""
1784 1463
1785#: plugins/check_load.c:293
1786#, c-format 1464#, c-format
1787msgid "Warning threshold for %d-minute load average is not specified\n" 1465msgid "Warning threshold for %d-minute load average is not specified\n"
1788msgstr "" 1466msgstr ""
1789 1467
1790#: plugins/check_load.c:295
1791#, c-format 1468#, c-format
1792msgid "" 1469msgid ""
1793"Parameter inconsistency: %d-minute \"warning load\" is greater than " 1470"Parameter inconsistency: %d-minute \"warning load\" is greater than "
1794"\"critical load\"\n" 1471"\"critical load\"\n"
1795msgstr "" 1472msgstr ""
1796 1473
1797#: plugins/check_load.c:311
1798#, c-format 1474#, c-format
1799msgid "This plugin tests the current system load average." 1475msgid "This plugin tests the current system load average."
1800msgstr "" 1476msgstr ""
1801 1477
1802#: plugins/check_load.c:321
1803msgid "Exit with WARNING status if load average exceeds WLOADn" 1478msgid "Exit with WARNING status if load average exceeds WLOADn"
1804msgstr "" 1479msgstr ""
1805 1480
1806#: plugins/check_load.c:323
1807msgid "Exit with CRITICAL status if load average exceed CLOADn" 1481msgid "Exit with CRITICAL status if load average exceed CLOADn"
1808msgstr "" 1482msgstr ""
1809 1483
1810#: plugins/check_load.c:324
1811msgid "the load average format is the same used by \"uptime\" and \"w\"" 1484msgid "the load average format is the same used by \"uptime\" and \"w\""
1812msgstr "" 1485msgstr ""
1813 1486
1814#: plugins/check_load.c:326
1815msgid "Divide the load averages by the number of CPUs (when possible)" 1487msgid "Divide the load averages by the number of CPUs (when possible)"
1816msgstr "" 1488msgstr ""
1817 1489
1818#: plugins/check_mrtg.c:75 1490msgid "Number of processes to show when printing the top consuming processes."
1491msgstr ""
1492
1493msgid "NUMBER_OF_PROCS=0 disables this feature. Default value is 0"
1494msgstr ""
1495
1496#, c-format
1497msgid "'%s' exited with non-zero status.\n"
1498msgstr ""
1499
1500#, c-format
1501msgid "some error occurred getting procs list.\n"
1502msgstr ""
1503
1819msgid "Could not parse arguments\n" 1504msgid "Could not parse arguments\n"
1820msgstr "" 1505msgstr ""
1821 1506
1822#: plugins/check_mrtg.c:80
1823#, c-format 1507#, c-format
1824msgid "Unable to open MRTG log file\n" 1508msgid "Unable to open MRTG log file\n"
1825msgstr "" 1509msgstr ""
1826 1510
1827#: plugins/check_mrtg.c:127
1828#, c-format 1511#, c-format
1829msgid "Unable to process MRTG log file\n" 1512msgid "Unable to process MRTG log file\n"
1830msgstr "" 1513msgstr ""
1831 1514
1832#: plugins/check_mrtg.c:135 plugins/check_mrtgtraf.c:136
1833#, c-format 1515#, c-format
1834msgid "MRTG data has expired (%d minutes old)\n" 1516msgid "MRTG data has expired (%d minutes old)\n"
1835msgstr "" 1517msgstr ""
1836 1518
1837#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1838#: plugins/check_mrtgtraf.c:196
1839msgid "Avg" 1519msgid "Avg"
1840msgstr "" 1520msgstr ""
1841 1521
1842#: plugins/check_mrtg.c:152 plugins/check_mrtgtraf.c:195
1843#: plugins/check_mrtgtraf.c:196
1844msgid "Max" 1522msgid "Max"
1845msgstr "" 1523msgstr ""
1846 1524
1847#: plugins/check_mrtg.c:221
1848msgid "Invalid variable number" 1525msgid "Invalid variable number"
1849msgstr "" 1526msgstr ""
1850 1527
1851#: plugins/check_mrtg.c:256
1852#, c-format 1528#, c-format
1853msgid "" 1529msgid ""
1854"%s is not a valid expiration time\n" 1530"%s is not a valid expiration time\n"
1855"Use '%s -h' for additional help\n" 1531"Use '%s -h' for additional help\n"
1856msgstr "" 1532msgstr ""
1857 1533
1858#: plugins/check_mrtg.c:273
1859msgid "Invalid variable number\n" 1534msgid "Invalid variable number\n"
1860msgstr "" 1535msgstr ""
1861 1536
1862#: plugins/check_mrtg.c:300
1863msgid "You must supply the variable number" 1537msgid "You must supply the variable number"
1864msgstr "" 1538msgstr ""
1865 1539
1866#: plugins/check_mrtg.c:321
1867msgid "" 1540msgid ""
1868"This plugin will check either the average or maximum value of one of the" 1541"This plugin will check either the average or maximum value of one of the"
1869msgstr "" 1542msgstr ""
1870 1543
1871#: plugins/check_mrtg.c:322
1872msgid "two variables recorded in an MRTG log file." 1544msgid "two variables recorded in an MRTG log file."
1873msgstr "" 1545msgstr ""
1874 1546
1875#: plugins/check_mrtg.c:332
1876msgid "The MRTG log file containing the data you want to monitor" 1547msgid "The MRTG log file containing the data you want to monitor"
1877msgstr "" 1548msgstr ""
1878 1549
1879#: plugins/check_mrtg.c:334
1880msgid "Minutes before MRTG data is considered to be too old" 1550msgid "Minutes before MRTG data is considered to be too old"
1881msgstr "" 1551msgstr ""
1882 1552
1883#: plugins/check_mrtg.c:336
1884msgid "Should we check average or maximum values?" 1553msgid "Should we check average or maximum values?"
1885msgstr "" 1554msgstr ""
1886 1555
1887#: plugins/check_mrtg.c:338
1888msgid "Which variable set should we inspect? (1 or 2)" 1556msgid "Which variable set should we inspect? (1 or 2)"
1889msgstr "" 1557msgstr ""
1890 1558
1891#: plugins/check_mrtg.c:340
1892msgid "Threshold value for data to result in WARNING status" 1559msgid "Threshold value for data to result in WARNING status"
1893msgstr "" 1560msgstr ""
1894 1561
1895#: plugins/check_mrtg.c:342
1896msgid "Threshold value for data to result in CRITICAL status" 1562msgid "Threshold value for data to result in CRITICAL status"
1897msgstr "" 1563msgstr ""
1898 1564
1899#: plugins/check_mrtg.c:344
1900msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)" 1565msgid "Type label for data (Examples: Conns, \"Processor Load\", In, Out)"
1901msgstr "" 1566msgstr ""
1902 1567
1903#: plugins/check_mrtg.c:346
1904msgid "Option units label for data (Example: Packets/Sec, Errors/Sec," 1568msgid "Option units label for data (Example: Packets/Sec, Errors/Sec,"
1905msgstr "" 1569msgstr ""
1906 1570
1907#: plugins/check_mrtg.c:347
1908#, c-format 1571#, c-format
1909msgid "\"Bytes Per Second\", \"%% Utilization\")" 1572msgid "\"Bytes Per Second\", \"%% Utilization\")"
1910msgstr "" 1573msgstr ""
1911 1574
1912#: plugins/check_mrtg.c:350
1913msgid "" 1575msgid ""
1914"If the value exceeds the <vwl> threshold, a WARNING status is returned. If" 1576"If the value exceeds the <vwl> threshold, a WARNING status is returned. If"
1915msgstr "" 1577msgstr ""
1916 1578
1917#: plugins/check_mrtg.c:351
1918msgid "" 1579msgid ""
1919"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If" 1580"the value exceeds the <vcl> threshold, a CRITICAL status is returned. If"
1920msgstr "" 1581msgstr ""
1921 1582
1922#: plugins/check_mrtg.c:352
1923msgid "the data in the log file is older than <expire_minutes> old, a WARNING" 1583msgid "the data in the log file is older than <expire_minutes> old, a WARNING"
1924msgstr "" 1584msgstr ""
1925 1585
1926#: plugins/check_mrtg.c:353
1927msgid "status is returned and a warning message is printed." 1586msgid "status is returned and a warning message is printed."
1928msgstr "" 1587msgstr ""
1929 1588
1930#: plugins/check_mrtg.c:356
1931msgid "" 1589msgid ""
1932"This plugin is useful for monitoring MRTG data that does not correspond to" 1590"This plugin is useful for monitoring MRTG data that does not correspond to"
1933msgstr "" 1591msgstr ""
1934 1592
1935#: plugins/check_mrtg.c:357
1936msgid "" 1593msgid ""
1937"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)." 1594"bandwidth usage. (Use the check_mrtgtraf plugin for monitoring bandwidth)."
1938msgstr "" 1595msgstr ""
1939 1596
1940#: plugins/check_mrtg.c:358
1941msgid "" 1597msgid ""
1942"It can be used to monitor any kind of data that MRTG is monitoring - errors," 1598"It can be used to monitor any kind of data that MRTG is monitoring - errors,"
1943msgstr "" 1599msgstr ""
1944 1600
1945#: plugins/check_mrtg.c:359
1946msgid "" 1601msgid ""
1947"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows" 1602"packets/sec, etc. I use MRTG in conjunction with the Novell NLM that allows"
1948msgstr "" 1603msgstr ""
1949 1604
1950#: plugins/check_mrtg.c:360
1951msgid "" 1605msgid ""
1952"me to track processor utilization, user connections, drive space, etc and" 1606"me to track processor utilization, user connections, drive space, etc and"
1953msgstr "" 1607msgstr ""
1954 1608
1955#: plugins/check_mrtg.c:361
1956msgid "this plugin works well for monitoring that kind of data as well." 1609msgid "this plugin works well for monitoring that kind of data as well."
1957msgstr "" 1610msgstr ""
1958 1611
1959#: plugins/check_mrtg.c:364
1960msgid "" 1612msgid ""
1961"- This plugin only monitors one of the two variables stored in the MRTG log" 1613"- This plugin only monitors one of the two variables stored in the MRTG log"
1962msgstr "" 1614msgstr ""
1963 1615
1964#: plugins/check_mrtg.c:365
1965msgid "file. If you want to monitor both values you will have to define two" 1616msgid "file. If you want to monitor both values you will have to define two"
1966msgstr "" 1617msgstr ""
1967 1618
1968#: plugins/check_mrtg.c:366
1969msgid "commands with different values for the <variable> argument. Of course," 1619msgid "commands with different values for the <variable> argument. Of course,"
1970msgstr "" 1620msgstr ""
1971 1621
1972#: plugins/check_mrtg.c:367
1973msgid "you can always hack the code to make this plugin work for you..." 1622msgid "you can always hack the code to make this plugin work for you..."
1974msgstr "" 1623msgstr ""
1975 1624
1976#: plugins/check_mrtg.c:368
1977msgid "" 1625msgid ""
1978"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded " 1626"- MRTG stands for the Multi Router Traffic Grapher. It can be downloaded "
1979"from" 1627"from"
1980msgstr "" 1628msgstr ""
1981 1629
1982#: plugins/check_mrtgtraf.c:88
1983msgid "Unable to open MRTG log file" 1630msgid "Unable to open MRTG log file"
1984msgstr "" 1631msgstr ""
1985 1632
1986#: plugins/check_mrtgtraf.c:130
1987msgid "Unable to process MRTG log file" 1633msgid "Unable to process MRTG log file"
1988msgstr "" 1634msgstr ""
1989 1635
1990#: plugins/check_mrtgtraf.c:194
1991#, c-format 1636#, c-format
1992msgid "%s. In = %0.1f %s, %s. Out = %0.1f %s|%s %s\n" 1637msgid "%s. In = %0.1f %s/s, %s. Out = %0.1f %s/s|%s %s\n"
1993msgstr "" 1638msgstr ""
1994 1639
1995#: plugins/check_mrtgtraf.c:207
1996#, c-format 1640#, c-format
1997msgid "Traffic %s - %s\n" 1641msgid "Traffic %s - %s\n"
1998msgstr "" 1642msgstr ""
1999 1643
2000#: plugins/check_mrtgtraf.c:335
2001msgid "" 1644msgid ""
2002"This plugin will check the incoming/outgoing transfer rates of a router," 1645"This plugin will check the incoming/outgoing transfer rates of a router,"
2003msgstr "" 1646msgstr ""
2004 1647
2005#: plugins/check_mrtgtraf.c:336
2006msgid "switch, etc recorded in an MRTG log. If the newest log entry is older" 1648msgid "switch, etc recorded in an MRTG log. If the newest log entry is older"
2007msgstr "" 1649msgstr ""
2008 1650
2009#: plugins/check_mrtgtraf.c:337
2010msgid "than <expire_minutes>, a WARNING status is returned. If either the" 1651msgid "than <expire_minutes>, a WARNING status is returned. If either the"
2011msgstr "" 1652msgstr ""
2012 1653
2013#: plugins/check_mrtgtraf.c:338
2014msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in" 1654msgid "incoming or outgoing rates exceed the <icl> or <ocl> thresholds (in"
2015msgstr "" 1655msgstr ""
2016 1656
2017#: plugins/check_mrtgtraf.c:339
2018msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed" 1657msgid "Bytes/sec), a CRITICAL status results. If either of the rates exceed"
2019msgstr "" 1658msgstr ""
2020 1659
2021#: plugins/check_mrtgtraf.c:340
2022msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results." 1660msgid "the <iwl> or <owl> thresholds (in Bytes/sec), a WARNING status results."
2023msgstr "" 1661msgstr ""
2024 1662
2025#: plugins/check_mrtgtraf.c:350
2026msgid "File to read log from" 1663msgid "File to read log from"
2027msgstr "" 1664msgstr ""
2028 1665
2029#: plugins/check_mrtgtraf.c:352
2030msgid "Minutes after which log expires" 1666msgid "Minutes after which log expires"
2031msgstr "" 1667msgstr ""
2032 1668
2033#: plugins/check_mrtgtraf.c:354
2034msgid "Test average or maximum" 1669msgid "Test average or maximum"
2035msgstr "" 1670msgstr ""
2036 1671
2037#: plugins/check_mrtgtraf.c:356
2038msgid "Warning threshold pair <incoming>,<outgoing>" 1672msgid "Warning threshold pair <incoming>,<outgoing>"
2039msgstr "" 1673msgstr ""
2040 1674
2041#: plugins/check_mrtgtraf.c:358
2042msgid "Critical threshold pair <incoming>,<outgoing>" 1675msgid "Critical threshold pair <incoming>,<outgoing>"
2043msgstr "" 1676msgstr ""
2044 1677
2045#: plugins/check_mrtgtraf.c:362
2046msgid "" 1678msgid ""
2047"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from" 1679"- MRTG stands for Multi Router Traffic Grapher. It can be downloaded from"
2048msgstr "" 1680msgstr ""
2049 1681
2050#: plugins/check_mrtgtraf.c:364
2051msgid "- While MRTG can monitor things other than traffic rates, this" 1682msgid "- While MRTG can monitor things other than traffic rates, this"
2052msgstr "" 1683msgstr ""
2053 1684
2054#: plugins/check_mrtgtraf.c:365
2055msgid " plugin probably won't work with much else without modification." 1685msgid " plugin probably won't work with much else without modification."
2056msgstr "" 1686msgstr ""
2057 1687
2058#: plugins/check_mrtgtraf.c:366
2059msgid "- The calculated i/o rates are a little off from what MRTG actually" 1688msgid "- The calculated i/o rates are a little off from what MRTG actually"
2060msgstr "" 1689msgstr ""
2061 1690
2062#: plugins/check_mrtgtraf.c:367
2063msgid " reports. I'm not sure why this is right now, but will look into it" 1691msgid " reports. I'm not sure why this is right now, but will look into it"
2064msgstr "" 1692msgstr ""
2065 1693
2066#: plugins/check_mrtgtraf.c:368
2067msgid " for future enhancements of this plugin." 1694msgid " for future enhancements of this plugin."
2068msgstr "" 1695msgstr ""
2069 1696
2070#: plugins/check_mrtgtraf.c:378
2071#, c-format 1697#, c-format
2072msgid "Usage" 1698msgid "Usage"
2073msgstr "" 1699msgstr ""
2074 1700
2075#: plugins/check_mysql.c:171
2076#, c-format 1701#, c-format
2077msgid "status store_result error: %s\n" 1702msgid "status store_result error: %s\n"
2078msgstr "" 1703msgstr ""
2079 1704
2080#: plugins/check_mysql.c:202
2081#, c-format 1705#, c-format
2082msgid "slave query error: %s\n" 1706msgid "slave query error: %s\n"
2083msgstr "" 1707msgstr ""
2084 1708
2085#: plugins/check_mysql.c:209
2086#, c-format 1709#, c-format
2087msgid "slave store_result error: %s\n" 1710msgid "slave store_result error: %s\n"
2088msgstr "" 1711msgstr ""
2089 1712
2090#: plugins/check_mysql.c:215
2091msgid "No slaves defined" 1713msgid "No slaves defined"
2092msgstr "" 1714msgstr ""
2093 1715
2094#: plugins/check_mysql.c:223
2095#, c-format 1716#, c-format
2096msgid "slave fetch row error: %s\n" 1717msgid "slave fetch row error: %s\n"
2097msgstr "" 1718msgstr ""
2098 1719
2099#: plugins/check_mysql.c:228
2100#, c-format 1720#, c-format
2101msgid "Slave running: %s" 1721msgid "Slave running: %s"
2102msgstr "" 1722msgstr ""
2103 1723
2104#: plugins/check_mysql.c:505
2105msgid "This program tests connections to a MySQL server" 1724msgid "This program tests connections to a MySQL server"
2106msgstr "" 1725msgstr ""
2107 1726
2108#: plugins/check_mysql.c:516 1727msgid "Ignore authentication failure and check for mysql connectivity only"
1728msgstr ""
1729
2109msgid "Use the specified socket (has no effect if -H is used)" 1730msgid "Use the specified socket (has no effect if -H is used)"
2110msgstr "" 1731msgstr ""
2111 1732
2112#: plugins/check_mysql.c:519
2113msgid "Check database with indicated name" 1733msgid "Check database with indicated name"
2114msgstr "" 1734msgstr ""
2115 1735
2116#: plugins/check_mysql.c:521
2117msgid "Read from the specified client options file" 1736msgid "Read from the specified client options file"
2118msgstr "" 1737msgstr ""
2119 1738
2120#: plugins/check_mysql.c:523
2121msgid "Use a client options group" 1739msgid "Use a client options group"
2122msgstr "" 1740msgstr ""
2123 1741
2124#: plugins/check_mysql.c:525
2125msgid "Connect using the indicated username" 1742msgid "Connect using the indicated username"
2126msgstr "" 1743msgstr ""
2127 1744
2128#: plugins/check_mysql.c:527
2129msgid "Use the indicated password to authenticate the connection" 1745msgid "Use the indicated password to authenticate the connection"
2130msgstr "" 1746msgstr ""
2131 1747
2132#: plugins/check_mysql.c:528
2133msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!" 1748msgid "IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!"
2134msgstr "" 1749msgstr ""
2135 1750
2136#: plugins/check_mysql.c:529
2137msgid "Your clear-text password could be visible as a process table entry" 1751msgid "Your clear-text password could be visible as a process table entry"
2138msgstr "" 1752msgstr ""
2139 1753
2140#: plugins/check_mysql.c:531
2141msgid "Check if the slave thread is running properly." 1754msgid "Check if the slave thread is running properly."
2142msgstr "" 1755msgstr ""
2143 1756
2144#: plugins/check_mysql.c:533
2145msgid "Exit with WARNING status if slave server is more than INTEGER seconds" 1757msgid "Exit with WARNING status if slave server is more than INTEGER seconds"
2146msgstr "" 1758msgstr ""
2147 1759
2148#: plugins/check_mysql.c:534 plugins/check_mysql.c:537
2149msgid "behind master" 1760msgid "behind master"
2150msgstr "" 1761msgstr ""
2151 1762
2152#: plugins/check_mysql.c:536
2153msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds" 1763msgid "Exit with CRITICAL status if slave server is more then INTEGER seconds"
2154msgstr "" 1764msgstr ""
2155 1765
2156#: plugins/check_mysql.c:539 1766msgid "Use ssl encryption"
2157msgid "Use ssl encryptation"
2158msgstr "" 1767msgstr ""
2159 1768
2160#: plugins/check_mysql.c:541
2161msgid "Path to CA signing the cert" 1769msgid "Path to CA signing the cert"
2162msgstr "" 1770msgstr ""
2163 1771
2164#: plugins/check_mysql.c:543
2165msgid "Path to SSL certificate" 1772msgid "Path to SSL certificate"
2166msgstr "" 1773msgstr ""
2167 1774
2168#: plugins/check_mysql.c:545
2169msgid "Path to private SSL key" 1775msgid "Path to private SSL key"
2170msgstr "" 1776msgstr ""
2171 1777
2172#: plugins/check_mysql.c:547
2173msgid "Path to CA directory" 1778msgid "Path to CA directory"
2174msgstr "" 1779msgstr ""
2175 1780
2176#: plugins/check_mysql.c:549
2177msgid "List of valid SSL ciphers" 1781msgid "List of valid SSL ciphers"
2178msgstr "" 1782msgstr ""
2179 1783
2180#: plugins/check_mysql.c:553
2181msgid "" 1784msgid ""
2182"There are no required arguments. By default, the local database is checked" 1785"There are no required arguments. By default, the local database is checked"
2183msgstr "" 1786msgstr ""
2184 1787
2185#: plugins/check_mysql.c:554
2186msgid "" 1788msgid ""
2187"using the default unix socket. You can force TCP on localhost by using an" 1789"using the default unix socket. You can force TCP on localhost by using an"
2188msgstr "" 1790msgstr ""
2189 1791
2190#: plugins/check_mysql.c:555
2191msgid "IP address or FQDN ('localhost' will use the socket as well)." 1792msgid "IP address or FQDN ('localhost' will use the socket as well)."
2192msgstr "" 1793msgstr ""
2193 1794
2194#: plugins/check_mysql.c:559
2195msgid "You must specify -p with an empty string to force an empty password," 1795msgid "You must specify -p with an empty string to force an empty password,"
2196msgstr "" 1796msgstr ""
2197 1797
2198#: plugins/check_mysql.c:560
2199msgid "overriding any my.cnf settings." 1798msgid "overriding any my.cnf settings."
2200msgstr "" 1799msgstr ""
2201 1800
2202#: plugins/check_nagios.c:104
2203msgid "Cannot open status log for reading!" 1801msgid "Cannot open status log for reading!"
2204msgstr "" 1802msgstr ""
2205 1803
2206#: plugins/check_nagios.c:154
2207#, c-format 1804#, c-format
2208msgid "Found process: %s %s\n" 1805msgid "Found process: %s %s\n"
2209msgstr "" 1806msgstr ""
2210 1807
2211#: plugins/check_nagios.c:168
2212msgid "Could not locate a running Nagios process!" 1808msgid "Could not locate a running Nagios process!"
2213msgstr "" 1809msgstr ""
2214 1810
2215#: plugins/check_nagios.c:172
2216msgid "Cannot parse Nagios log file for valid time" 1811msgid "Cannot parse Nagios log file for valid time"
2217msgstr "" 1812msgstr ""
2218 1813
2219#: plugins/check_nagios.c:183 plugins/check_procs.c:356
2220#, c-format 1814#, c-format
2221msgid "%d process" 1815msgid "%d process"
2222msgid_plural "%d processes" 1816msgid_plural "%d processes"
2223msgstr[0] "" 1817msgstr[0] ""
2224msgstr[1] "" 1818msgstr[1] ""
2225 1819
2226#: plugins/check_nagios.c:186
2227#, c-format 1820#, c-format
2228msgid "status log updated %d second ago" 1821msgid "status log updated %d second ago"
2229msgid_plural "status log updated %d seconds ago" 1822msgid_plural "status log updated %d seconds ago"
2230msgstr[0] "" 1823msgstr[0] ""
2231msgstr[1] "" 1824msgstr[1] ""
2232 1825
2233#: plugins/check_nagios.c:224 plugins/check_nagios.c:253
2234msgid "Expiration time must be an integer (seconds)\n" 1826msgid "Expiration time must be an integer (seconds)\n"
2235msgstr "" 1827msgstr ""
2236 1828
2237#: plugins/check_nagios.c:260
2238msgid "Timeout must be an integer (seconds)\n" 1829msgid "Timeout must be an integer (seconds)\n"
2239msgstr "" 1830msgstr ""
2240 1831
2241#: plugins/check_nagios.c:272
2242msgid "You must provide the status_log\n" 1832msgid "You must provide the status_log\n"
2243msgstr "" 1833msgstr ""
2244 1834
2245#: plugins/check_nagios.c:275
2246msgid "You must provide a process string\n" 1835msgid "You must provide a process string\n"
2247msgstr "" 1836msgstr ""
2248 1837
2249#: plugins/check_nagios.c:289
2250msgid "" 1838msgid ""
2251"This plugin checks the status of the Nagios process on the local machine" 1839"This plugin checks the status of the Nagios process on the local machine"
2252msgstr "" 1840msgstr ""
2253 1841
2254#: plugins/check_nagios.c:290
2255msgid "" 1842msgid ""
2256"The plugin will check to make sure the Nagios status log is no older than" 1843"The plugin will check to make sure the Nagios status log is no older than"
2257msgstr "" 1844msgstr ""
2258 1845
2259#: plugins/check_nagios.c:291
2260msgid "the number of minutes specified by the expires option." 1846msgid "the number of minutes specified by the expires option."
2261msgstr "" 1847msgstr ""
2262 1848
2263#: plugins/check_nagios.c:292
2264msgid "" 1849msgid ""
2265"It also checks the process table for a process matching the command argument." 1850"It also checks the process table for a process matching the command argument."
2266msgstr "" 1851msgstr ""
2267 1852
2268#: plugins/check_nagios.c:302
2269msgid "Name of the log file to check" 1853msgid "Name of the log file to check"
2270msgstr "" 1854msgstr ""
2271 1855
2272#: plugins/check_nagios.c:304
2273msgid "Minutes aging after which logfile is considered stale" 1856msgid "Minutes aging after which logfile is considered stale"
2274msgstr "" 1857msgstr ""
2275 1858
2276#: plugins/check_nagios.c:306
2277msgid "Substring to search for in process arguments" 1859msgid "Substring to search for in process arguments"
2278msgstr "" 1860msgstr ""
2279 1861
2280#: plugins/check_nagios.c:308
2281msgid "Timeout for the plugin in seconds" 1862msgid "Timeout for the plugin in seconds"
2282msgstr "" 1863msgstr ""
2283 1864
2284#: plugins/check_nt.c:142
2285#, c-format 1865#, c-format
2286msgid "Wrong client version - running: %s, required: %s" 1866msgid "Wrong client version - running: %s, required: %s"
2287msgstr "" 1867msgstr ""
2288 1868
2289#: plugins/check_nt.c:153 plugins/check_nt.c:218
2290msgid "missing -l parameters" 1869msgid "missing -l parameters"
2291msgstr "" 1870msgstr ""
2292 1871
2293#: plugins/check_nt.c:155
2294msgid "wrong -l parameter." 1872msgid "wrong -l parameter."
2295msgstr "" 1873msgstr ""
2296 1874
2297#: plugins/check_nt.c:159
2298msgid "CPU Load" 1875msgid "CPU Load"
2299msgstr "" 1876msgstr ""
2300 1877
2301#: plugins/check_nt.c:182
2302#, c-format 1878#, c-format
2303msgid " %lu%% (%lu min average)" 1879msgid " %lu%% (%lu min average)"
2304msgstr "" 1880msgstr ""
2305 1881
2306#: plugins/check_nt.c:184
2307#, c-format 1882#, c-format
2308msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100" 1883msgid " '%lu min avg Load'=%lu%%;%lu;%lu;0;100"
2309msgstr "" 1884msgstr ""
2310 1885
2311#: plugins/check_nt.c:194
2312msgid "not enough values for -l parameters" 1886msgid "not enough values for -l parameters"
2313msgstr "" 1887msgstr ""
2314 1888
2315#: plugins/check_nt.c:206 1889msgid "wrong -l argument"
2316#, c-format
2317msgid "System Uptime - %u day(s) %u hour(s) %u minute(s)"
2318msgstr "" 1890msgstr ""
2319 1891
2320#: plugins/check_nt.c:220 1892#, c-format
2321msgid "wrong -l argument" 1893msgid "System Uptime - %u day(s) %u hour(s) %u minute(s) |uptime=%lu"
2322msgstr "" 1894msgstr ""
2323 1895
2324#: plugins/check_nt.c:236
2325#, c-format 1896#, c-format
2326msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)" 1897msgid "%s:\\ - total: %.2f Gb - used: %.2f Gb (%.0f%%) - free %.2f Gb (%.0f%%)"
2327msgstr "" 1898msgstr ""
2328 1899
2329#: plugins/check_nt.c:239
2330#, c-format 1900#, c-format
2331msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f" 1901msgid "'%s:\\ Used Space'=%.2fGb;%.2f;%.2f;0.00;%.2f"
2332msgstr "" 1902msgstr ""
2333 1903
2334#: plugins/check_nt.c:253
2335msgid "Free disk space : Invalid drive" 1904msgid "Free disk space : Invalid drive"
2336msgstr "" 1905msgstr ""
2337 1906
2338#: plugins/check_nt.c:263
2339msgid "No service/process specified" 1907msgid "No service/process specified"
2340msgstr "" 1908msgstr ""
2341 1909
2342#: plugins/check_nt.c:271 plugins/check_nt.c:284 plugins/check_nt.c:288
2343#: plugins/check_nt.c:622
2344msgid "could not fetch information from server\n" 1910msgid "could not fetch information from server\n"
2345msgstr "" 1911msgstr ""
2346 1912
2347#: plugins/check_nt.c:296
2348#, c-format 1913#, c-format
2349msgid "" 1914msgid ""
2350"Memory usage: total:%.2f Mb - used: %.2f Mb (%.0f%%) - free: %.2f Mb (%.0f%%)" 1915"Memory usage: total:%.2f MB - used: %.2f MB (%.0f%%) - free: %.2f MB (%.0f%%)"
2351msgstr "" 1916msgstr ""
2352 1917
2353#: plugins/check_nt.c:299
2354#, c-format 1918#, c-format
2355msgid "'Memory usage'=%.2fMb;%.2f;%.2f;0.00;%.2f" 1919msgid "'Memory usage'=%.2fMB;%.2f;%.2f;0.00;%.2f"
2356msgstr "" 1920msgstr ""
2357 1921
2358#: plugins/check_nt.c:335 plugins/check_nt.c:420 plugins/check_nt.c:450
2359msgid "No counter specified" 1922msgid "No counter specified"
2360msgstr "" 1923msgstr ""
2361 1924
2362#: plugins/check_nt.c:367
2363msgid "Minimum value contains non-numbers" 1925msgid "Minimum value contains non-numbers"
2364msgstr "" 1926msgstr ""
2365 1927
2366#: plugins/check_nt.c:371
2367msgid "Maximum value contains non-numbers" 1928msgid "Maximum value contains non-numbers"
2368msgstr "" 1929msgstr ""
2369 1930
2370#: plugins/check_nt.c:378
2371msgid "No unit counter specified" 1931msgid "No unit counter specified"
2372msgstr "" 1932msgstr ""
2373 1933
2374#: plugins/check_nt.c:465
2375msgid "Please specify a variable to check" 1934msgid "Please specify a variable to check"
2376msgstr "" 1935msgstr ""
2377 1936
2378#: plugins/check_nt.c:549
2379msgid "Server port must be an integer\n" 1937msgid "Server port must be an integer\n"
2380msgstr "" 1938msgstr ""
2381 1939
2382#: plugins/check_nt.c:603
2383msgid "You must provide a server address or host name" 1940msgid "You must provide a server address or host name"
2384msgstr "" 1941msgstr ""
2385 1942
2386#: plugins/check_nt.c:609
2387msgid "None" 1943msgid "None"
2388msgstr "" 1944msgstr ""
2389 1945
2390#: plugins/check_nt.c:666
2391msgid "This plugin collects data from the NSClient service running on a" 1946msgid "This plugin collects data from the NSClient service running on a"
2392msgstr "" 1947msgstr ""
2393 1948
2394#: plugins/check_nt.c:667
2395msgid "Windows NT/2000/XP/2003 server." 1949msgid "Windows NT/2000/XP/2003 server."
2396msgstr "" 1950msgstr ""
2397 1951
2398#: plugins/check_nt.c:678
2399msgid "Name of the host to check" 1952msgid "Name of the host to check"
2400msgstr "" 1953msgstr ""
2401 1954
2402#: plugins/check_nt.c:680
2403msgid "Optional port number (default: " 1955msgid "Optional port number (default: "
2404msgstr "" 1956msgstr ""
2405 1957
2406#: plugins/check_nt.c:683
2407msgid "Password needed for the request" 1958msgid "Password needed for the request"
2408msgstr "" 1959msgstr ""
2409 1960
2410#: plugins/check_nt.c:685 plugins/check_nwstat.c:1661
2411#: plugins/check_overcr.c:432
2412msgid "Threshold which will result in a warning status" 1961msgid "Threshold which will result in a warning status"
2413msgstr "" 1962msgstr ""
2414 1963
2415#: plugins/check_nt.c:687 plugins/check_nwstat.c:1663
2416#: plugins/check_overcr.c:434
2417msgid "Threshold which will result in a critical status" 1964msgid "Threshold which will result in a critical status"
2418msgstr "" 1965msgstr ""
2419 1966
2420#: plugins/check_nt.c:689
2421msgid "Seconds before connection attempt times out (default: " 1967msgid "Seconds before connection attempt times out (default: "
2422msgstr "" 1968msgstr ""
2423 1969
2424#: plugins/check_nt.c:691
2425msgid "Parameters passed to specified check (see below)" 1970msgid "Parameters passed to specified check (see below)"
2426msgstr "" 1971msgstr ""
2427 1972
2428#: plugins/check_nt.c:693
2429msgid "Display options (currently only SHOWALL works)" 1973msgid "Display options (currently only SHOWALL works)"
2430msgstr "" 1974msgstr ""
2431 1975
2432#: plugins/check_nt.c:695
2433msgid "Return UNKNOWN on timeouts" 1976msgid "Return UNKNOWN on timeouts"
2434msgstr "" 1977msgstr ""
2435 1978
2436#: plugins/check_nt.c:698
2437msgid "Print this help screen" 1979msgid "Print this help screen"
2438msgstr "" 1980msgstr ""
2439 1981
2440#: plugins/check_nt.c:700
2441msgid "Print version information" 1982msgid "Print version information"
2442msgstr "" 1983msgstr ""
2443 1984
2444#: plugins/check_nt.c:702
2445msgid "Variable to check" 1985msgid "Variable to check"
2446msgstr "" 1986msgstr ""
2447 1987
2448#: plugins/check_nt.c:703
2449msgid "Valid variables are:" 1988msgid "Valid variables are:"
2450msgstr "" 1989msgstr ""
2451 1990
2452#: plugins/check_nt.c:705
2453msgid "Get the NSClient version" 1991msgid "Get the NSClient version"
2454msgstr "" 1992msgstr ""
2455 1993
2456#: plugins/check_nt.c:706
2457msgid "If -l <version> is specified, will return warning if versions differ." 1994msgid "If -l <version> is specified, will return warning if versions differ."
2458msgstr "" 1995msgstr ""
2459 1996
2460#: plugins/check_nt.c:708
2461msgid "Average CPU load on last x minutes." 1997msgid "Average CPU load on last x minutes."
2462msgstr "" 1998msgstr ""
2463 1999
2464#: plugins/check_nt.c:709
2465msgid "Request a -l parameter with the following syntax:" 2000msgid "Request a -l parameter with the following syntax:"
2466msgstr "" 2001msgstr ""
2467 2002
2468#: plugins/check_nt.c:710
2469msgid "-l <minutes range>,<warning threshold>,<critical threshold>." 2003msgid "-l <minutes range>,<warning threshold>,<critical threshold>."
2470msgstr "" 2004msgstr ""
2471 2005
2472#: plugins/check_nt.c:711
2473msgid "<minute range> should be less than 24*60." 2006msgid "<minute range> should be less than 24*60."
2474msgstr "" 2007msgstr ""
2475 2008
2476#: plugins/check_nt.c:712
2477msgid "" 2009msgid ""
2478"Thresholds are percentage and up to 10 requests can be done in one shot." 2010"Thresholds are percentage and up to 10 requests can be done in one shot."
2479msgstr "" 2011msgstr ""
2480 2012
2481#: plugins/check_nt.c:715
2482msgid "Get the uptime of the machine." 2013msgid "Get the uptime of the machine."
2483msgstr "" 2014msgstr ""
2484 2015
2485#: plugins/check_nt.c:716 2016msgid "-l <unit> "
2486msgid "No specific parameters. No warning or critical threshold" 2017msgstr ""
2018
2019msgid "<unit> = seconds, minutes, hours, or days. (default: minutes)"
2020msgstr ""
2021
2022msgid "Thresholds will use the unit specified above."
2487msgstr "" 2023msgstr ""
2488 2024
2489#: plugins/check_nt.c:718
2490msgid "Size and percentage of disk use." 2025msgid "Size and percentage of disk use."
2491msgstr "" 2026msgstr ""
2492 2027
2493#: plugins/check_nt.c:719
2494msgid "Request a -l parameter containing the drive letter only." 2028msgid "Request a -l parameter containing the drive letter only."
2495msgstr "" 2029msgstr ""
2496 2030
2497#: plugins/check_nt.c:720 plugins/check_nt.c:723
2498msgid "Warning and critical thresholds can be specified with -w and -c." 2031msgid "Warning and critical thresholds can be specified with -w and -c."
2499msgstr "" 2032msgstr ""
2500 2033
2501#: plugins/check_nt.c:722
2502msgid "Memory use." 2034msgid "Memory use."
2503msgstr "" 2035msgstr ""
2504 2036
2505#: plugins/check_nt.c:725
2506msgid "Check the state of one or several services." 2037msgid "Check the state of one or several services."
2507msgstr "" 2038msgstr ""
2508 2039
2509#: plugins/check_nt.c:726 plugins/check_nt.c:735
2510msgid "Request a -l parameters with the following syntax:" 2040msgid "Request a -l parameters with the following syntax:"
2511msgstr "" 2041msgstr ""
2512 2042
2513#: plugins/check_nt.c:727
2514msgid "-l <service1>,<service2>,<service3>,..." 2043msgid "-l <service1>,<service2>,<service3>,..."
2515msgstr "" 2044msgstr ""
2516 2045
2517#: plugins/check_nt.c:728
2518msgid "You can specify -d SHOWALL in case you want to see working services" 2046msgid "You can specify -d SHOWALL in case you want to see working services"
2519msgstr "" 2047msgstr ""
2520 2048
2521#: plugins/check_nt.c:729
2522msgid "in the returned string." 2049msgid "in the returned string."
2523msgstr "" 2050msgstr ""
2524 2051
2525#: plugins/check_nt.c:731
2526msgid "Check if one or several process are running." 2052msgid "Check if one or several process are running."
2527msgstr "" 2053msgstr ""
2528 2054
2529#: plugins/check_nt.c:732
2530msgid "Same syntax as SERVICESTATE." 2055msgid "Same syntax as SERVICESTATE."
2531msgstr "" 2056msgstr ""
2532 2057
2533#: plugins/check_nt.c:734
2534msgid "Check any performance counter of Windows NT/2000." 2058msgid "Check any performance counter of Windows NT/2000."
2535msgstr "" 2059msgstr ""
2536 2060
2537#: plugins/check_nt.c:736
2538msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>" 2061msgid "-l \"\\\\<performance object>\\\\counter\",\"<description>"
2539msgstr "" 2062msgstr ""
2540 2063
2541#: plugins/check_nt.c:737
2542msgid "The <description> parameter is optional and is given to a printf " 2064msgid "The <description> parameter is optional and is given to a printf "
2543msgstr "" 2065msgstr ""
2544 2066
2545#: plugins/check_nt.c:738
2546msgid "output command which requires a float parameter." 2067msgid "output command which requires a float parameter."
2547msgstr "" 2068msgstr ""
2548 2069
2549#: plugins/check_nt.c:739
2550#, c-format 2070#, c-format
2551msgid "If <description> does not include \"%%\", it is used as a label." 2071msgid "If <description> does not include \"%%\", it is used as a label."
2552msgstr "" 2072msgstr ""
2553 2073
2554#: plugins/check_nt.c:740 plugins/check_nt.c:755
2555msgid "Some examples:" 2074msgid "Some examples:"
2556msgstr "" 2075msgstr ""
2557 2076
2558#: plugins/check_nt.c:744
2559msgid "Check any performance counter object of Windows NT/2000." 2077msgid "Check any performance counter object of Windows NT/2000."
2560msgstr "" 2078msgstr ""
2561 2079
2562#: plugins/check_nt.c:745
2563msgid "" 2080msgid ""
2564"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>" 2081"Syntax: check_nt -H <hostname> -p <port> -v INSTANCES -l <counter object>"
2565msgstr "" 2082msgstr ""
2566 2083
2567#: plugins/check_nt.c:746
2568msgid "<counter object> is a Windows Perfmon Counter object (eg. Process)," 2084msgid "<counter object> is a Windows Perfmon Counter object (eg. Process),"
2569msgstr "" 2085msgstr ""
2570 2086
2571#: plugins/check_nt.c:747
2572msgid "if it is two words, it should be enclosed in quotes" 2087msgid "if it is two words, it should be enclosed in quotes"
2573msgstr "" 2088msgstr ""
2574 2089
2575#: plugins/check_nt.c:748
2576msgid "The returned results will be a comma-separated list of instances on " 2090msgid "The returned results will be a comma-separated list of instances on "
2577msgstr "" 2091msgstr ""
2578 2092
2579#: plugins/check_nt.c:749
2580msgid " the selected computer for that object." 2093msgid " the selected computer for that object."
2581msgstr "" 2094msgstr ""
2582 2095
2583#: plugins/check_nt.c:750
2584msgid "" 2096msgid ""
2585"The purpose of this is to be run from command line to determine what " 2097"The purpose of this is to be run from command line to determine what "
2586"instances" 2098"instances"
2587msgstr "" 2099msgstr ""
2588 2100
2589#: plugins/check_nt.c:751
2590msgid "" 2101msgid ""
2591" are available for monitoring without having to log onto the Windows server" 2102" are available for monitoring without having to log onto the Windows server"
2592msgstr "" 2103msgstr ""
2593 2104
2594#: plugins/check_nt.c:752
2595msgid " to run Perfmon directly." 2105msgid " to run Perfmon directly."
2596msgstr "" 2106msgstr ""
2597 2107
2598#: plugins/check_nt.c:753
2599msgid "" 2108msgid ""
2600"It can also be used in scripts that automatically create the monitoring " 2109"It can also be used in scripts that automatically create the monitoring "
2601"service" 2110"service"
2602msgstr "" 2111msgstr ""
2603 2112
2604#: plugins/check_nt.c:754
2605msgid " configuration files." 2113msgid " configuration files."
2606msgstr "" 2114msgstr ""
2607 2115
2608#: plugins/check_nt.c:756
2609msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process" 2116msgid "check_nt -H 192.168.1.1 -p 1248 -v INSTANCES -l Process"
2610msgstr "" 2117msgstr ""
2611 2118
2612#: plugins/check_nt.c:759
2613msgid "" 2119msgid ""
2614"- The NSClient service should be running on the server to get any information" 2120"- The NSClient service should be running on the server to get any information"
2615msgstr "" 2121msgstr ""
2616 2122
2617#: plugins/check_nt.c:761
2618msgid "- Critical thresholds should be lower than warning thresholds" 2123msgid "- Critical thresholds should be lower than warning thresholds"
2619msgstr "" 2124msgstr ""
2620 2125
2621#: plugins/check_nt.c:762
2622msgid "- Default port 1248 is sometimes in use by other services. The error" 2126msgid "- Default port 1248 is sometimes in use by other services. The error"
2623msgstr "" 2127msgstr ""
2624 2128
2625#: plugins/check_nt.c:763
2626msgid "" 2129msgid ""
2627"output when this happens contains \"Cannot map xxxxx to protocol number\"." 2130"output when this happens contains \"Cannot map xxxxx to protocol number\"."
2628msgstr "" 2131msgstr ""
2629 2132
2630#: plugins/check_nt.c:764
2631msgid "One fix for this is to change the port to something else on check_nt " 2133msgid "One fix for this is to change the port to something else on check_nt "
2632msgstr "" 2134msgstr ""
2633 2135
2634#: plugins/check_nt.c:765
2635msgid "and on the client service it's connecting to." 2136msgid "and on the client service it's connecting to."
2636msgstr "" 2137msgstr ""
2637 2138
2638#: plugins/check_ntp.c:807 plugins/check_ntp_peer.c:612 2139#, c-format
2639#: plugins/check_ntp_time.c:571 2140msgid "jitter response too large (%lu bytes)\n"
2141msgstr ""
2142
2640msgid "NTP CRITICAL:" 2143msgid "NTP CRITICAL:"
2641msgstr "" 2144msgstr ""
2642 2145
2643#: plugins/check_ntp.c:810 plugins/check_ntp_peer.c:615
2644#: plugins/check_ntp_time.c:574
2645msgid "NTP WARNING:" 2146msgid "NTP WARNING:"
2646msgstr "" 2147msgstr ""
2647 2148
2648#: plugins/check_ntp.c:813 plugins/check_ntp_peer.c:618
2649#: plugins/check_ntp_time.c:577
2650msgid "NTP OK:" 2149msgid "NTP OK:"
2651msgstr "" 2150msgstr ""
2652 2151
2653#: plugins/check_ntp.c:816 plugins/check_ntp_peer.c:621
2654#: plugins/check_ntp_time.c:580
2655msgid "NTP UNKNOWN:" 2152msgid "NTP UNKNOWN:"
2656msgstr "" 2153msgstr ""
2657 2154
2658#: plugins/check_ntp.c:820 plugins/check_ntp_peer.c:630
2659#: plugins/check_ntp_time.c:584
2660msgid "Offset unknown" 2155msgid "Offset unknown"
2661msgstr "" 2156msgstr ""
2662 2157
2663#: plugins/check_ntp.c:823 plugins/check_ntp_peer.c:633
2664#: plugins/check_ntp_time.c:587
2665msgid "Offset" 2158msgid "Offset"
2666msgstr "" 2159msgstr ""
2667 2160
2668#: plugins/check_ntp.c:844 plugins/check_ntp_peer.c:662
2669msgid "This plugin checks the selected ntp server" 2161msgid "This plugin checks the selected ntp server"
2670msgstr "" 2162msgstr ""
2671 2163
2672#: plugins/check_ntp.c:854 plugins/check_ntp_peer.c:674
2673#: plugins/check_ntp_time.c:614
2674msgid "Offset to result in warning status (seconds)" 2164msgid "Offset to result in warning status (seconds)"
2675msgstr "" 2165msgstr ""
2676 2166
2677#: plugins/check_ntp.c:856 plugins/check_ntp_peer.c:676
2678#: plugins/check_ntp_time.c:616
2679msgid "Offset to result in critical status (seconds)" 2167msgid "Offset to result in critical status (seconds)"
2680msgstr "" 2168msgstr ""
2681 2169
2682#: plugins/check_ntp.c:858 plugins/check_ntp_peer.c:682
2683msgid "Warning threshold for jitter" 2170msgid "Warning threshold for jitter"
2684msgstr "" 2171msgstr ""
2685 2172
2686#: plugins/check_ntp.c:860 plugins/check_ntp_peer.c:684
2687msgid "Critical threshold for jitter" 2173msgid "Critical threshold for jitter"
2688msgstr "" 2174msgstr ""
2689 2175
2690#: plugins/check_ntp.c:870
2691msgid "Normal offset check:" 2176msgid "Normal offset check:"
2692msgstr "" 2177msgstr ""
2693 2178
2694#: plugins/check_ntp.c:873 plugins/check_ntp_peer.c:709
2695msgid "" 2179msgid ""
2696"Check jitter too, avoiding critical notifications if jitter isn't available" 2180"Check jitter too, avoiding critical notifications if jitter isn't available"
2697msgstr "" 2181msgstr ""
2698 2182
2699#: plugins/check_ntp.c:874 plugins/check_ntp_peer.c:710
2700msgid "(See Notes above for more details on thresholds formats):" 2183msgid "(See Notes above for more details on thresholds formats):"
2701msgstr "" 2184msgstr ""
2702 2185
2703#: plugins/check_ntp.c:879 plugins/check_ntp.c:886
2704msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or" 2186msgid "WARNING: check_ntp is deprecated. Please use check_ntp_peer or"
2705msgstr "" 2187msgstr ""
2706 2188
2707#: plugins/check_ntp.c:880 plugins/check_ntp.c:887
2708msgid "check_ntp_time instead." 2189msgid "check_ntp_time instead."
2709msgstr "" 2190msgstr ""
2710 2191
2711#: plugins/check_ntp_peer.c:625
2712msgid "Server not synchronized" 2192msgid "Server not synchronized"
2713msgstr "" 2193msgstr ""
2714 2194
2715#: plugins/check_ntp_peer.c:627
2716msgid "Server has the LI_ALARM bit set" 2195msgid "Server has the LI_ALARM bit set"
2717msgstr "" 2196msgstr ""
2718 2197
2719#: plugins/check_ntp_peer.c:672
2720msgid "" 2198msgid ""
2721"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized" 2199"Returns UNKNOWN instead of CRITICAL or WARNING if server isn't synchronized"
2722msgstr "" 2200msgstr ""
2723 2201
2724#: plugins/check_ntp_peer.c:678
2725msgid "Warning threshold for stratum of server's synchronization peer" 2202msgid "Warning threshold for stratum of server's synchronization peer"
2726msgstr "" 2203msgstr ""
2727 2204
2728#: plugins/check_ntp_peer.c:680
2729msgid "Critical threshold for stratum of server's synchronization peer" 2205msgid "Critical threshold for stratum of server's synchronization peer"
2730msgstr "" 2206msgstr ""
2731 2207
2732#: plugins/check_ntp_peer.c:686
2733msgid "Warning threshold for number of usable time sources (\"truechimers\")" 2208msgid "Warning threshold for number of usable time sources (\"truechimers\")"
2734msgstr "" 2209msgstr ""
2735 2210
2736#: plugins/check_ntp_peer.c:688
2737msgid "Critical threshold for number of usable time sources (\"truechimers\")" 2211msgid "Critical threshold for number of usable time sources (\"truechimers\")"
2738msgstr "" 2212msgstr ""
2739 2213
2740#: plugins/check_ntp_peer.c:693
2741msgid "This plugin checks an NTP server independent of any commandline" 2214msgid "This plugin checks an NTP server independent of any commandline"
2742msgstr "" 2215msgstr ""
2743 2216
2744#: plugins/check_ntp_peer.c:694
2745msgid "programs or external libraries." 2217msgid "programs or external libraries."
2746msgstr "" 2218msgstr ""
2747 2219
2748#: plugins/check_ntp_peer.c:697
2749msgid "Use this plugin to check the health of an NTP server. It supports" 2220msgid "Use this plugin to check the health of an NTP server. It supports"
2750msgstr "" 2221msgstr ""
2751 2222
2752#: plugins/check_ntp_peer.c:698
2753msgid "checking the offset with the sync peer, the jitter and stratum. This" 2223msgid "checking the offset with the sync peer, the jitter and stratum. This"
2754msgstr "" 2224msgstr ""
2755 2225
2756#: plugins/check_ntp_peer.c:699
2757msgid "plugin will not check the clock offset between the local host and NTP" 2226msgid "plugin will not check the clock offset between the local host and NTP"
2758msgstr "" 2227msgstr ""
2759 2228
2760#: plugins/check_ntp_peer.c:700
2761msgid "server; please use check_ntp_time for that purpose." 2229msgid "server; please use check_ntp_time for that purpose."
2762msgstr "" 2230msgstr ""
2763 2231
2764#: plugins/check_ntp_peer.c:706
2765msgid "Simple NTP server check:" 2232msgid "Simple NTP server check:"
2766msgstr "" 2233msgstr ""
2767 2234
2768#: plugins/check_ntp_peer.c:713
2769msgid "Only check the number of usable time sources (\"truechimers\"):" 2235msgid "Only check the number of usable time sources (\"truechimers\"):"
2770msgstr "" 2236msgstr ""
2771 2237
2772#: plugins/check_ntp_peer.c:716
2773msgid "Check only stratum:" 2238msgid "Check only stratum:"
2774msgstr "" 2239msgstr ""
2775 2240
2776#: plugins/check_ntp_time.c:602
2777msgid "This plugin checks the clock offset with the ntp server" 2241msgid "This plugin checks the clock offset with the ntp server"
2778msgstr "" 2242msgstr ""
2779 2243
2780#: plugins/check_ntp_time.c:612
2781msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found" 2244msgid "Returns UNKNOWN instead of CRITICAL if offset cannot be found"
2782msgstr "" 2245msgstr ""
2783 2246
2784#: plugins/check_ntp_time.c:621 2247msgid "Expected offset of the ntp server relative to local server (seconds)"
2248msgstr ""
2249
2785msgid "This plugin checks the clock offset between the local host and a" 2250msgid "This plugin checks the clock offset between the local host and a"
2786msgstr "" 2251msgstr ""
2787 2252
2788#: plugins/check_ntp_time.c:622
2789msgid "remote NTP server. It is independent of any commandline programs or" 2253msgid "remote NTP server. It is independent of any commandline programs or"
2790msgstr "" 2254msgstr ""
2791 2255
2792#: plugins/check_ntp_time.c:623
2793msgid "external libraries." 2256msgid "external libraries."
2794msgstr "" 2257msgstr ""
2795 2258
2796#: plugins/check_ntp_time.c:627
2797msgid "If you'd rather want to monitor an NTP server, please use" 2259msgid "If you'd rather want to monitor an NTP server, please use"
2798msgstr "" 2260msgstr ""
2799 2261
2800#: plugins/check_ntp_time.c:628
2801msgid "check_ntp_peer." 2262msgid "check_ntp_peer."
2802msgstr "" 2263msgstr ""
2803 2264
2804#: plugins/check_nwstat.c:194 2265msgid "--time-offset is useful for compensating for servers with known"
2266msgstr ""
2267
2268msgid "and expected clock skew."
2269msgstr ""
2270
2805#, c-format 2271#, c-format
2806msgid "NetWare %s: " 2272msgid "NetWare %s: "
2807msgstr "" 2273msgstr ""
2808 2274
2809#: plugins/check_nwstat.c:232
2810#, c-format 2275#, c-format
2811msgid "Up %s," 2276msgid "Up %s,"
2812msgstr "" 2277msgstr ""
2813 2278
2814#: plugins/check_nwstat.c:240
2815#, c-format 2279#, c-format
2816msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100" 2280msgid "Load %s - %s %s-min load average = %lu%%|load%s=%lu;%lu;%lu;0;100"
2817msgstr "" 2281msgstr ""
2818 2282
2819#: plugins/check_nwstat.c:268
2820#, c-format 2283#, c-format
2821msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;" 2284msgid "Conns %s - %lu current connections|Conns=%lu;%lu;%lu;;"
2822msgstr "" 2285msgstr ""
2823 2286
2824#: plugins/check_nwstat.c:293
2825#, c-format 2287#, c-format
2826msgid "%s: Long term cache hits = %lu%%" 2288msgid "%s: Long term cache hits = %lu%%"
2827msgstr "" 2289msgstr ""
2828 2290
2829#: plugins/check_nwstat.c:315
2830#, c-format 2291#, c-format
2831msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;" 2292msgid "%s: Total cache buffers = %lu|Cachebuffers=%lu;%lu;%lu;;"
2832msgstr "" 2293msgstr ""
2833 2294
2834#: plugins/check_nwstat.c:340
2835#, c-format 2295#, c-format
2836msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;" 2296msgid "%s: Dirty cache buffers = %lu|Dirty-Cache-Buffers=%lu;%lu;%lu;;"
2837msgstr "" 2297msgstr ""
2838 2298
2839#: plugins/check_nwstat.c:365
2840#, c-format 2299#, c-format
2841msgid "%s: LRU sitting time = %lu minutes" 2300msgid "%s: LRU sitting time = %lu minutes"
2842msgstr "" 2301msgstr ""
2843 2302
2844#: plugins/check_nwstat.c:382 plugins/check_nwstat.c:410
2845#: plugins/check_nwstat.c:437 plugins/check_nwstat.c:470
2846#: plugins/check_nwstat.c:650 plugins/check_nwstat.c:676
2847#: plugins/check_nwstat.c:707 plugins/check_nwstat.c:753
2848#: plugins/check_nwstat.c:777
2849#, c-format 2303#, c-format
2850msgid "CRITICAL - Volume '%s' does not exist!" 2304msgid "CRITICAL - Volume '%s' does not exist!"
2851msgstr "" 2305msgstr ""
2852 2306
2853#: plugins/check_nwstat.c:391
2854#, c-format 2307#, c-format
2855msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;" 2308msgid "%s%lu KB free on volume %s|KBFree%s=%lu;%lu;%lu;;"
2856msgstr "" 2309msgstr ""
2857 2310
2858#: plugins/check_nwstat.c:392 plugins/check_nwstat.c:420
2859#: plugins/check_nwstat.c:447 plugins/check_nwstat.c:659
2860#: plugins/check_nwstat.c:685 plugins/check_nwstat.c:761
2861msgid "Only " 2311msgid "Only "
2862msgstr "" 2312msgstr ""
2863 2313
2864#: plugins/check_nwstat.c:419
2865#, c-format 2314#, c-format
2866msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;" 2315msgid "%s%lu MB free on volume %s|MBFree%s=%lu;%lu;%lu;;"
2867msgstr "" 2316msgstr ""
2868 2317
2869#: plugins/check_nwstat.c:446
2870#, c-format 2318#, c-format
2871msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;" 2319msgid "%s%lu MB used on volume %s|MBUsed%s=%lu;%lu;%lu;;"
2872msgstr "" 2320msgstr ""
2873 2321
2874#: plugins/check_nwstat.c:494
2875#, c-format 2322#, c-format
2876msgid "" 2323msgid ""
2877"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100" 2324"%lu MB (%lu%%) free on volume %s - total %lu MB|FreeMB%s=%lu;%lu;%lu;0;100"
2878msgstr "" 2325msgstr ""
2879 2326
2880#: plugins/check_nwstat.c:528
2881#, c-format 2327#, c-format
2882msgid "Directory Services Database is %s (DS version %s)" 2328msgid "Directory Services Database is %s (DS version %s)"
2883msgstr "" 2329msgstr ""
2884 2330
2885#: plugins/check_nwstat.c:545
2886#, c-format 2331#, c-format
2887msgid "Logins are %s" 2332msgid "Logins are %s"
2888msgstr "" 2333msgstr ""
2889 2334
2890#: plugins/check_nwstat.c:545
2891msgid "enabled" 2335msgid "enabled"
2892msgstr "" 2336msgstr ""
2893 2337
2894#: plugins/check_nwstat.c:545
2895msgid "disabled" 2338msgid "disabled"
2896msgstr "" 2339msgstr ""
2897 2340
2898#: plugins/check_nwstat.c:560
2899msgid "CRITICAL - NRM Status is bad!" 2341msgid "CRITICAL - NRM Status is bad!"
2900msgstr "" 2342msgstr ""
2901 2343
2902#: plugins/check_nwstat.c:565
2903msgid "Warning - NRM Status is suspect!" 2344msgid "Warning - NRM Status is suspect!"
2904msgstr "" 2345msgstr ""
2905 2346
2906#: plugins/check_nwstat.c:568
2907msgid "OK - NRM Status is good!" 2347msgid "OK - NRM Status is good!"
2908msgstr "" 2348msgstr ""
2909 2349
2910#: plugins/check_nwstat.c:610
2911#, c-format 2350#, c-format
2912msgid "%lu of %lu (%lu%%) packet receive buffers used" 2351msgid "%lu of %lu (%lu%%) packet receive buffers used"
2913msgstr "" 2352msgstr ""
2914 2353
2915#: plugins/check_nwstat.c:634
2916#, c-format 2354#, c-format
2917msgid "%lu entries in SAP table" 2355msgid "%lu entries in SAP table"
2918msgstr "" 2356msgstr ""
2919 2357
2920#: plugins/check_nwstat.c:636
2921#, c-format 2358#, c-format
2922msgid "%lu entries in SAP table for SAP type %d" 2359msgid "%lu entries in SAP table for SAP type %d"
2923msgstr "" 2360msgstr ""
2924 2361
2925#: plugins/check_nwstat.c:658
2926#, c-format 2362#, c-format
2927msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2363msgid "%s%lu KB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
2928msgstr "" 2364msgstr ""
2929 2365
2930#: plugins/check_nwstat.c:684
2931#, c-format 2366#, c-format
2932msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;" 2367msgid "%s%lu MB purgeable on volume %s|Purge%s=%lu;%lu;%lu;;"
2933msgstr "" 2368msgstr ""
2934 2369
2935#: plugins/check_nwstat.c:730
2936#, c-format 2370#, c-format
2937msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100" 2371msgid "%lu MB (%lu%%) purgeable on volume %s|Purgeable%s=%lu;%lu;%lu;0;100"
2938msgstr "" 2372msgstr ""
2939 2373
2940#: plugins/check_nwstat.c:761
2941#, c-format 2374#, c-format
2942msgid "%s%lu KB not yet purgeable on volume %s" 2375msgid "%s%lu KB not yet purgeable on volume %s"
2943msgstr "" 2376msgstr ""
2944 2377
2945#: plugins/check_nwstat.c:800
2946#, c-format 2378#, c-format
2947msgid "%lu MB (%lu%%) not yet purgeable on volume %s" 2379msgid "%lu MB (%lu%%) not yet purgeable on volume %s"
2948msgstr "" 2380msgstr ""
2949 2381
2950#: plugins/check_nwstat.c:821
2951#, c-format 2382#, c-format
2952msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0" 2383msgid "%lu open files|Openfiles=%lu;%lu;%lu;0,0"
2953msgstr "" 2384msgstr ""
2954 2385
2955#: plugins/check_nwstat.c:846
2956#, c-format 2386#, c-format
2957msgid "%lu abended threads|Abends=%lu;%lu;%lu;;" 2387msgid "%lu abended threads|Abends=%lu;%lu;%lu;;"
2958msgstr "" 2388msgstr ""
2959 2389
2960#: plugins/check_nwstat.c:881
2961#, c-format 2390#, c-format
2962msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu" 2391msgid "%lu current service processes (%lu max)|Processes=%lu;%lu;%lu;0;%lu"
2963msgstr "" 2392msgstr ""
2964 2393
2965#: plugins/check_nwstat.c:904
2966msgid "CRITICAL - Time not in sync with network!" 2394msgid "CRITICAL - Time not in sync with network!"
2967msgstr "" 2395msgstr ""
2968 2396
2969#: plugins/check_nwstat.c:907
2970msgid "OK - Time in sync with network!" 2397msgid "OK - Time in sync with network!"
2971msgstr "" 2398msgstr ""
2972 2399
2973#: plugins/check_nwstat.c:930
2974#, c-format 2400#, c-format
2975msgid "LRU sitting time = %lu seconds" 2401msgid "LRU sitting time = %lu seconds"
2976msgstr "" 2402msgstr ""
2977 2403
2978#: plugins/check_nwstat.c:949
2979#, c-format 2404#, c-format
2980msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100" 2405msgid "Dirty cache buffers = %lu%% of the total|DCB=%lu;%lu;%lu;0;100"
2981msgstr "" 2406msgstr ""
2982 2407
2983#: plugins/check_nwstat.c:971
2984#, c-format 2408#, c-format
2985msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100" 2409msgid "Total cache buffers = %lu%% of the original|TCB=%lu;%lu;%lu;0;100"
2986msgstr "" 2410msgstr ""
2987 2411
2988#: plugins/check_nwstat.c:989
2989#, c-format 2412#, c-format
2990msgid "NDS Version %s" 2413msgid "NDS Version %s"
2991msgstr "" 2414msgstr ""
2992 2415
2993#: plugins/check_nwstat.c:1005
2994#, c-format 2416#, c-format
2995msgid "Up %s" 2417msgid "Up %s"
2996msgstr "" 2418msgstr ""
2997 2419
2998#: plugins/check_nwstat.c:1019
2999#, c-format 2420#, c-format
3000msgid "Module %s version %s is loaded" 2421msgid "Module %s version %s is loaded"
3001msgstr "" 2422msgstr ""
3002 2423
3003#: plugins/check_nwstat.c:1022
3004#, c-format 2424#, c-format
3005msgid "Module %s is not loaded" 2425msgid "Module %s is not loaded"
3006msgstr "" 2426msgstr ""
3007 2427
3008#: plugins/check_nwstat.c:1033 plugins/check_nwstat.c:1059
3009#: plugins/check_nwstat.c:1085 plugins/check_nwstat.c:1111
3010#: plugins/check_nwstat.c:1137 plugins/check_nwstat.c:1163
3011#: plugins/check_nwstat.c:1189 plugins/check_nwstat.c:1215
3012#: plugins/check_nwstat.c:1241 plugins/check_nwstat.c:1267
3013#, c-format 2428#, c-format
3014msgid "CRITICAL - Value '%s' does not exist!" 2429msgid "CRITICAL - Value '%s' does not exist!"
3015msgstr "" 2430msgstr ""
3016 2431
3017#: plugins/check_nwstat.c:1042 plugins/check_nwstat.c:1068
3018#: plugins/check_nwstat.c:1094 plugins/check_nwstat.c:1120
3019#: plugins/check_nwstat.c:1146 plugins/check_nwstat.c:1172
3020#: plugins/check_nwstat.c:1198 plugins/check_nwstat.c:1224
3021#: plugins/check_nwstat.c:1250 plugins/check_nwstat.c:1276
3022#, c-format 2432#, c-format
3023msgid "%s is %lu|%s=%lu;%lu;%lu;;" 2433msgid "%s is %lu|%s=%lu;%lu;%lu;;"
3024msgstr "" 2434msgstr ""
3025 2435
3026#: plugins/check_nwstat.c:1289 plugins/check_overcr.c:285
3027msgid "Nothing to check!\n" 2436msgid "Nothing to check!\n"
3028msgstr "" 2437msgstr ""
3029 2438
3030#: plugins/check_nwstat.c:1371 plugins/check_overcr.c:355
3031msgid "Server port an integer\n" 2439msgid "Server port an integer\n"
3032msgstr "" 2440msgstr ""
3033 2441
3034#: plugins/check_nwstat.c:1601
3035msgid "This plugin attempts to contact the MRTGEXT NLM running on a" 2442msgid "This plugin attempts to contact the MRTGEXT NLM running on a"
3036msgstr "" 2443msgstr ""
3037 2444
3038#: plugins/check_nwstat.c:1602
3039msgid "Novell server to gather the requested system information." 2445msgid "Novell server to gather the requested system information."
3040msgstr "" 2446msgstr ""
3041 2447
3042#: plugins/check_nwstat.c:1614 plugins/check_overcr.c:436
3043msgid "Variable to check. Valid variables include:" 2448msgid "Variable to check. Valid variables include:"
3044msgstr "" 2449msgstr ""
3045 2450
3046#: plugins/check_nwstat.c:1615
3047msgid "LOAD1 = 1 minute average CPU load" 2451msgid "LOAD1 = 1 minute average CPU load"
3048msgstr "" 2452msgstr ""
3049 2453
3050#: plugins/check_nwstat.c:1616
3051msgid "LOAD5 = 5 minute average CPU load" 2454msgid "LOAD5 = 5 minute average CPU load"
3052msgstr "" 2455msgstr ""
3053 2456
3054#: plugins/check_nwstat.c:1617
3055msgid "LOAD15 = 15 minute average CPU load" 2457msgid "LOAD15 = 15 minute average CPU load"
3056msgstr "" 2458msgstr ""
3057 2459
3058#: plugins/check_nwstat.c:1618
3059msgid "CSPROCS = number of current service processes (NW 5.x only)" 2460msgid "CSPROCS = number of current service processes (NW 5.x only)"
3060msgstr "" 2461msgstr ""
3061 2462
3062#: plugins/check_nwstat.c:1619
3063msgid "ABENDS = number of abended threads (NW 5.x only)" 2463msgid "ABENDS = number of abended threads (NW 5.x only)"
3064msgstr "" 2464msgstr ""
3065 2465
3066#: plugins/check_nwstat.c:1620
3067msgid "UPTIME = server uptime" 2466msgid "UPTIME = server uptime"
3068msgstr "" 2467msgstr ""
3069 2468
3070#: plugins/check_nwstat.c:1621
3071msgid "LTCH = percent long term cache hits" 2469msgid "LTCH = percent long term cache hits"
3072msgstr "" 2470msgstr ""
3073 2471
3074#: plugins/check_nwstat.c:1622
3075msgid "CBUFF = current number of cache buffers" 2472msgid "CBUFF = current number of cache buffers"
3076msgstr "" 2473msgstr ""
3077 2474
3078#: plugins/check_nwstat.c:1623
3079msgid "CDBUFF = current number of dirty cache buffers" 2475msgid "CDBUFF = current number of dirty cache buffers"
3080msgstr "" 2476msgstr ""
3081 2477
3082#: plugins/check_nwstat.c:1624
3083msgid "DCB = dirty cache buffers as a percentage of the total" 2478msgid "DCB = dirty cache buffers as a percentage of the total"
3084msgstr "" 2479msgstr ""
3085 2480
3086#: plugins/check_nwstat.c:1625
3087msgid "TCB = dirty cache buffers as a percentage of the original" 2481msgid "TCB = dirty cache buffers as a percentage of the original"
3088msgstr "" 2482msgstr ""
3089 2483
3090#: plugins/check_nwstat.c:1626
3091msgid "OFILES = number of open files" 2484msgid "OFILES = number of open files"
3092msgstr "" 2485msgstr ""
3093 2486
3094#: plugins/check_nwstat.c:1627
3095msgid " VMF<vol> = MB of free space on Volume <vol>" 2487msgid " VMF<vol> = MB of free space on Volume <vol>"
3096msgstr "" 2488msgstr ""
3097 2489
3098#: plugins/check_nwstat.c:1628
3099msgid " VMU<vol> = MB used space on Volume <vol>" 2490msgid " VMU<vol> = MB used space on Volume <vol>"
3100msgstr "" 2491msgstr ""
3101 2492
3102#: plugins/check_nwstat.c:1629
3103msgid " VMP<vol> = MB of purgeable space on Volume <vol>" 2493msgid " VMP<vol> = MB of purgeable space on Volume <vol>"
3104msgstr "" 2494msgstr ""
3105 2495
3106#: plugins/check_nwstat.c:1630
3107msgid " VPF<vol> = percent free space on volume <vol>" 2496msgid " VPF<vol> = percent free space on volume <vol>"
3108msgstr "" 2497msgstr ""
3109 2498
3110#: plugins/check_nwstat.c:1631
3111msgid " VKF<vol> = KB of free space on volume <vol>" 2499msgid " VKF<vol> = KB of free space on volume <vol>"
3112msgstr "" 2500msgstr ""
3113 2501
3114#: plugins/check_nwstat.c:1632
3115msgid " VPP<vol> = percent purgeable space on volume <vol>" 2502msgid " VPP<vol> = percent purgeable space on volume <vol>"
3116msgstr "" 2503msgstr ""
3117 2504
3118#: plugins/check_nwstat.c:1633
3119msgid " VKP<vol> = KB of purgeable space on volume <vol>" 2505msgid " VKP<vol> = KB of purgeable space on volume <vol>"
3120msgstr "" 2506msgstr ""
3121 2507
3122#: plugins/check_nwstat.c:1634
3123msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>" 2508msgid " VPNP<vol> = percent not yet purgeable space on volume <vol>"
3124msgstr "" 2509msgstr ""
3125 2510
3126#: plugins/check_nwstat.c:1635
3127msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>" 2511msgid " VKNP<vol> = KB of not yet purgeable space on volume <vol>"
3128msgstr "" 2512msgstr ""
3129 2513
3130#: plugins/check_nwstat.c:1636
3131msgid " LRUM = LRU sitting time in minutes" 2514msgid " LRUM = LRU sitting time in minutes"
3132msgstr "" 2515msgstr ""
3133 2516
3134#: plugins/check_nwstat.c:1637
3135msgid " LRUS = LRU sitting time in seconds" 2517msgid " LRUS = LRU sitting time in seconds"
3136msgstr "" 2518msgstr ""
3137 2519
3138#: plugins/check_nwstat.c:1638
3139msgid " DSDB = check to see if DS Database is open" 2520msgid " DSDB = check to see if DS Database is open"
3140msgstr "" 2521msgstr ""
3141 2522
3142#: plugins/check_nwstat.c:1639
3143msgid " DSVER = NDS version" 2523msgid " DSVER = NDS version"
3144msgstr "" 2524msgstr ""
3145 2525
3146#: plugins/check_nwstat.c:1640
3147msgid " UPRB = used packet receive buffers" 2526msgid " UPRB = used packet receive buffers"
3148msgstr "" 2527msgstr ""
3149 2528
3150#: plugins/check_nwstat.c:1641
3151msgid " PUPRB = percent (of max) used packet receive buffers" 2529msgid " PUPRB = percent (of max) used packet receive buffers"
3152msgstr "" 2530msgstr ""
3153 2531
3154#: plugins/check_nwstat.c:1642
3155msgid " SAPENTRIES = number of entries in the SAP table" 2532msgid " SAPENTRIES = number of entries in the SAP table"
3156msgstr "" 2533msgstr ""
3157 2534
3158#: plugins/check_nwstat.c:1643
3159msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>" 2535msgid " SAPENTRIES<n> = number of entries in the SAP table for SAP type <n>"
3160msgstr "" 2536msgstr ""
3161 2537
3162#: plugins/check_nwstat.c:1644
3163msgid " TSYNC = timesync status" 2538msgid " TSYNC = timesync status"
3164msgstr "" 2539msgstr ""
3165 2540
3166#: plugins/check_nwstat.c:1645
3167msgid " LOGINS = check to see if logins are enabled" 2541msgid " LOGINS = check to see if logins are enabled"
3168msgstr "" 2542msgstr ""
3169 2543
3170#: plugins/check_nwstat.c:1646
3171msgid " CONNS = number of currently licensed connections" 2544msgid " CONNS = number of currently licensed connections"
3172msgstr "" 2545msgstr ""
3173 2546
3174#: plugins/check_nwstat.c:1647
3175msgid " NRMH\t= NRM Summary Status" 2547msgid " NRMH\t= NRM Summary Status"
3176msgstr "" 2548msgstr ""
3177 2549
3178#: plugins/check_nwstat.c:1648
3179msgid " NRMP<stat> = Returns the current value for a NRM health item" 2550msgid " NRMP<stat> = Returns the current value for a NRM health item"
3180msgstr "" 2551msgstr ""
3181 2552
3182#: plugins/check_nwstat.c:1649
3183msgid " NRMM<stat> = Returns the current memory stats from NRM" 2553msgid " NRMM<stat> = Returns the current memory stats from NRM"
3184msgstr "" 2554msgstr ""
3185 2555
3186#: plugins/check_nwstat.c:1650
3187msgid " NRMS<stat> = Returns the current Swapfile stats from NRM" 2556msgid " NRMS<stat> = Returns the current Swapfile stats from NRM"
3188msgstr "" 2557msgstr ""
3189 2558
3190#: plugins/check_nwstat.c:1651
3191msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml" 2559msgid " NSS1<stat> = Statistics from _Admin:Manage_NSS\\GeneralStats.xml"
3192msgstr "" 2560msgstr ""
3193 2561
3194#: plugins/check_nwstat.c:1652
3195msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml" 2562msgid " NSS3<stat> = Statistics from _Admin:Manage_NSS\\NameCache.xml"
3196msgstr "" 2563msgstr ""
3197 2564
3198#: plugins/check_nwstat.c:1653
3199msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml" 2565msgid " NSS4<stat> = Statistics from _Admin:Manage_NSS\\FileStats.xml"
3200msgstr "" 2566msgstr ""
3201 2567
3202#: plugins/check_nwstat.c:1654
3203msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml" 2568msgid " NSS5<stat> = Statistics from _Admin:Manage_NSS\\ObjectCache.xml"
3204msgstr "" 2569msgstr ""
3205 2570
3206#: plugins/check_nwstat.c:1655
3207msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml" 2571msgid " NSS6<stat> = Statistics from _Admin:Manage_NSS\\Thread.xml"
3208msgstr "" 2572msgstr ""
3209 2573
3210#: plugins/check_nwstat.c:1656
3211msgid "" 2574msgid ""
3212" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml" 2575" NSS7<stat> = Statistics from _Admin:Manage_NSS\\AuthorizationCache.xml"
3213msgstr "" 2576msgstr ""
3214 2577
3215#: plugins/check_nwstat.c:1657
3216msgid " NLM:<nlm> = check if NLM is loaded and report version" 2578msgid " NLM:<nlm> = check if NLM is loaded and report version"
3217msgstr "" 2579msgstr ""
3218 2580
3219#: plugins/check_nwstat.c:1658
3220msgid " (e.g. NLM:TSANDS.NLM)" 2581msgid " (e.g. NLM:TSANDS.NLM)"
3221msgstr "" 2582msgstr ""
3222 2583
3223#: plugins/check_nwstat.c:1665
3224msgid "Include server version string in results" 2584msgid "Include server version string in results"
3225msgstr "" 2585msgstr ""
3226 2586
3227#: plugins/check_nwstat.c:1671 2587msgid "- This plugin requires that the MRTGEXT.NLM file from James Drews' MRTG"
3228msgid "- This plugin requres that the MRTGEXT.NLM file from James Drews' MRTG"
3229msgstr "" 2588msgstr ""
3230 2589
3231#: plugins/check_nwstat.c:1672
3232msgid "" 2590msgid ""
3233" extension for NetWare be loaded on the Novell servers you wish to check." 2591" extension for NetWare be loaded on the Novell servers you wish to check."
3234msgstr "" 2592msgstr ""
3235 2593
3236#: plugins/check_nwstat.c:1673
3237msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)" 2594msgid " (available from http://www.engr.wisc.edu/~drews/mrtg/)"
3238msgstr "" 2595msgstr ""
3239 2596
3240#: plugins/check_nwstat.c:1674
3241msgid "" 2597msgid ""
3242"- Values for critical thresholds should be lower than warning thresholds" 2598"- Values for critical thresholds should be lower than warning thresholds"
3243msgstr "" 2599msgstr ""
3244 2600
3245#: plugins/check_nwstat.c:1675
3246msgid "" 2601msgid ""
3247" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, " 2602" when the following variables are checked: VPF, VKF, LTCH, CBUFF, DCB, "
3248msgstr "" 2603msgstr ""
3249 2604
3250#: plugins/check_nwstat.c:1676
3251msgid " TCB, LRUS and LRUM." 2605msgid " TCB, LRUS and LRUM."
3252msgstr "" 2606msgstr ""
3253 2607
3254#: plugins/check_overcr.c:123
3255msgid "Unknown error fetching load data\n" 2608msgid "Unknown error fetching load data\n"
3256msgstr "" 2609msgstr ""
3257 2610
3258#: plugins/check_overcr.c:127
3259msgid "Invalid response from server - no load information\n" 2611msgid "Invalid response from server - no load information\n"
3260msgstr "" 2612msgstr ""
3261 2613
3262#: plugins/check_overcr.c:133
3263msgid "Invalid response from server after load 1\n" 2614msgid "Invalid response from server after load 1\n"
3264msgstr "" 2615msgstr ""
3265 2616
3266#: plugins/check_overcr.c:139
3267msgid "Invalid response from server after load 5\n" 2617msgid "Invalid response from server after load 5\n"
3268msgstr "" 2618msgstr ""
3269 2619
3270#: plugins/check_overcr.c:164
3271#, c-format 2620#, c-format
3272msgid "Load %s - %s-min load average = %0.2f" 2621msgid "Load %s - %s-min load average = %0.2f"
3273msgstr "" 2622msgstr ""
3274 2623
3275#: plugins/check_overcr.c:174
3276msgid "Unknown error fetching disk data\n" 2624msgid "Unknown error fetching disk data\n"
3277msgstr "" 2625msgstr ""
3278 2626
3279#: plugins/check_overcr.c:184 plugins/check_overcr.c:236
3280#: plugins/check_overcr.c:240
3281msgid "Invalid response from server\n" 2627msgid "Invalid response from server\n"
3282msgstr "" 2628msgstr ""
3283 2629
3284#: plugins/check_overcr.c:211
3285msgid "Unknown error fetching network status\n" 2630msgid "Unknown error fetching network status\n"
3286msgstr "" 2631msgstr ""
3287 2632
3288#: plugins/check_overcr.c:221
3289#, c-format 2633#, c-format
3290msgid "Net %s - %d connection%s on port %d" 2634msgid "Net %s - %d connection%s on port %d"
3291msgstr "" 2635msgstr ""
3292 2636
3293#: plugins/check_overcr.c:232
3294msgid "Unknown error fetching process status\n" 2637msgid "Unknown error fetching process status\n"
3295msgstr "" 2638msgstr ""
3296 2639
3297#: plugins/check_overcr.c:250
3298#, c-format 2640#, c-format
3299msgid "Process %s - %d instance%s of %s running" 2641msgid "Process %s - %d instance%s of %s running"
3300msgstr "" 2642msgstr ""
3301 2643
3302#: plugins/check_overcr.c:277
3303#, c-format 2644#, c-format
3304msgid "Uptime %s - Up %d days %d hours %d minutes" 2645msgid "Uptime %s - Up %d days %d hours %d minutes"
3305msgstr "" 2646msgstr ""
3306 2647
3307#: plugins/check_overcr.c:419
3308msgid "" 2648msgid ""
3309"This plugin attempts to contact the Over-CR collector daemon running on the" 2649"This plugin attempts to contact the Over-CR collector daemon running on the"
3310msgstr "" 2650msgstr ""
3311 2651
3312#: plugins/check_overcr.c:420
3313msgid "remote UNIX server in order to gather the requested system information." 2652msgid "remote UNIX server in order to gather the requested system information."
3314msgstr "" 2653msgstr ""
3315 2654
3316#: plugins/check_overcr.c:437
3317msgid "LOAD1 = 1 minute average CPU load" 2655msgid "LOAD1 = 1 minute average CPU load"
3318msgstr "" 2656msgstr ""
3319 2657
3320#: plugins/check_overcr.c:438
3321msgid "LOAD5 = 5 minute average CPU load" 2658msgid "LOAD5 = 5 minute average CPU load"
3322msgstr "" 2659msgstr ""
3323 2660
3324#: plugins/check_overcr.c:439
3325msgid "LOAD15 = 15 minute average CPU load" 2661msgid "LOAD15 = 15 minute average CPU load"
3326msgstr "" 2662msgstr ""
3327 2663
3328#: plugins/check_overcr.c:440
3329msgid "DPU<filesys> = percent used disk space on filesystem <filesys>" 2664msgid "DPU<filesys> = percent used disk space on filesystem <filesys>"
3330msgstr "" 2665msgstr ""
3331 2666
3332#: plugins/check_overcr.c:441
3333msgid "PROC<process> = number of running processes with name <process>" 2667msgid "PROC<process> = number of running processes with name <process>"
3334msgstr "" 2668msgstr ""
3335 2669
3336#: plugins/check_overcr.c:442
3337msgid "NET<port> = number of active connections on TCP port <port>" 2670msgid "NET<port> = number of active connections on TCP port <port>"
3338msgstr "" 2671msgstr ""
3339 2672
3340#: plugins/check_overcr.c:443
3341msgid "UPTIME = system uptime in seconds" 2673msgid "UPTIME = system uptime in seconds"
3342msgstr "" 2674msgstr ""
3343 2675
3344#: plugins/check_overcr.c:450
3345msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be" 2676msgid "This plugin requires that Eric Molitors' Over-CR collector daemon be"
3346msgstr "" 2677msgstr ""
3347 2678
3348#: plugins/check_overcr.c:451
3349msgid "running on the remote server." 2679msgid "running on the remote server."
3350msgstr "" 2680msgstr ""
3351 2681
3352#: plugins/check_overcr.c:452
3353msgid "Over-CR can be downloaded from http://www.molitor.org/overcr" 2682msgid "Over-CR can be downloaded from http://www.molitor.org/overcr"
3354msgstr "" 2683msgstr ""
3355 2684
3356#: plugins/check_overcr.c:453
3357msgid "This plugin was tested with version 0.99.53 of the Over-CR collector" 2685msgid "This plugin was tested with version 0.99.53 of the Over-CR collector"
3358msgstr "" 2686msgstr ""
3359 2687
3360#: plugins/check_overcr.c:457
3361msgid "" 2688msgid ""
3362"For the available options, the critical threshold value should always be" 2689"For the available options, the critical threshold value should always be"
3363msgstr "" 2690msgstr ""
3364 2691
3365#: plugins/check_overcr.c:458
3366msgid "" 2692msgid ""
3367"higher than the warning threshold value, EXCEPT with the uptime variable" 2693"higher than the warning threshold value, EXCEPT with the uptime variable"
3368msgstr "" 2694msgstr ""
3369 2695
3370#: plugins/check_pgsql.c:222
3371#, c-format 2696#, c-format
3372msgid "CRITICAL - no connection to '%s' (%s).\n" 2697msgid "CRITICAL - no connection to '%s' (%s).\n"
3373msgstr "" 2698msgstr ""
3374 2699
3375#: plugins/check_pgsql.c:250
3376#, c-format 2700#, c-format
3377msgid " %s - database %s (%f sec.)|%s\n" 2701msgid " %s - database %s (%f sec.)|%s\n"
3378msgstr "" 2702msgstr ""
3379 2703
3380#: plugins/check_pgsql.c:317 plugins/check_time.c:277 plugins/check_time.c:289
3381#: plugins/check_users.c:181
3382msgid "Critical threshold must be a positive integer" 2704msgid "Critical threshold must be a positive integer"
3383msgstr "" 2705msgstr ""
3384 2706
3385#: plugins/check_pgsql.c:323 plugins/check_time.c:258 plugins/check_time.c:282
3386#: plugins/check_users.c:187 plugins/check_users.c:197
3387#: plugins/check_users.c:203
3388msgid "Warning threshold must be a positive integer" 2707msgid "Warning threshold must be a positive integer"
3389msgstr "" 2708msgstr ""
3390 2709
3391#: plugins/check_pgsql.c:347 2710msgid "Database name exceeds the maximum length"
3392msgid "Database name is not valid"
3393msgstr "" 2711msgstr ""
3394 2712
3395#: plugins/check_pgsql.c:353
3396msgid "User name is not valid" 2713msgid "User name is not valid"
3397msgstr "" 2714msgstr ""
3398 2715
3399#: plugins/check_pgsql.c:504
3400#, c-format 2716#, c-format
3401msgid "Test whether a PostgreSQL Database is accepting connections." 2717msgid "Test whether a PostgreSQL Database is accepting connections."
3402msgstr "" 2718msgstr ""
3403 2719
3404#: plugins/check_pgsql.c:516
3405msgid "Database to check " 2720msgid "Database to check "
3406msgstr "" 2721msgstr ""
3407 2722
3408#: plugins/check_pgsql.c:517
3409#, c-format 2723#, c-format
3410msgid "(default: %s)" 2724msgid "(default: %s)\n"
3411msgstr "" 2725msgstr ""
3412 2726
3413#: plugins/check_pgsql.c:519
3414msgid "Login name of user" 2727msgid "Login name of user"
3415msgstr "" 2728msgstr ""
3416 2729
3417#: plugins/check_pgsql.c:521
3418msgid "Password (BIG SECURITY ISSUE)" 2730msgid "Password (BIG SECURITY ISSUE)"
3419msgstr "" 2731msgstr ""
3420 2732
3421#: plugins/check_pgsql.c:523
3422msgid "Connection parameters (keyword = value), see below" 2733msgid "Connection parameters (keyword = value), see below"
3423msgstr "" 2734msgstr ""
3424 2735
3425#: plugins/check_pgsql.c:530
3426msgid "SQL query to run. Only first column in first row will be read" 2736msgid "SQL query to run. Only first column in first row will be read"
3427msgstr "" 2737msgstr ""
3428 2738
3429#: plugins/check_pgsql.c:532 2739msgid "A name for the query, this string is used instead of the query"
2740msgstr ""
2741
2742msgid "in the long output of the plugin"
2743msgstr ""
2744
3430msgid "SQL query value to result in warning status (double)" 2745msgid "SQL query value to result in warning status (double)"
3431msgstr "" 2746msgstr ""
3432 2747
3433#: plugins/check_pgsql.c:534
3434msgid "SQL query value to result in critical status (double)" 2748msgid "SQL query value to result in critical status (double)"
3435msgstr "" 2749msgstr ""
3436 2750
3437#: plugins/check_pgsql.c:539
3438msgid "All parameters are optional." 2751msgid "All parameters are optional."
3439msgstr "" 2752msgstr ""
3440 2753
3441#: plugins/check_pgsql.c:540
3442msgid "" 2754msgid ""
3443"This plugin tests a PostgreSQL DBMS to determine whether it is active and" 2755"This plugin tests a PostgreSQL DBMS to determine whether it is active and"
3444msgstr "" 2756msgstr ""
3445 2757
3446#: plugins/check_pgsql.c:541
3447msgid "accepting queries. In its current operation, it simply connects to the" 2758msgid "accepting queries. In its current operation, it simply connects to the"
3448msgstr "" 2759msgstr ""
3449 2760
3450#: plugins/check_pgsql.c:542
3451msgid "" 2761msgid ""
3452"specified database, and then disconnects. If no database is specified, it" 2762"specified database, and then disconnects. If no database is specified, it"
3453msgstr "" 2763msgstr ""
3454 2764
3455#: plugins/check_pgsql.c:543
3456msgid "" 2765msgid ""
3457"connects to the template1 database, which is present in every functioning" 2766"connects to the template1 database, which is present in every functioning"
3458msgstr "" 2767msgstr ""
3459 2768
3460#: plugins/check_pgsql.c:544
3461msgid "PostgreSQL DBMS." 2769msgid "PostgreSQL DBMS."
3462msgstr "" 2770msgstr ""
3463 2771
3464#: plugins/check_pgsql.c:546
3465msgid "If a query is specified using the -q option, it will be executed after" 2772msgid "If a query is specified using the -q option, it will be executed after"
3466msgstr "" 2773msgstr ""
3467 2774
3468#: plugins/check_pgsql.c:547
3469msgid "connecting to the server. The result from the query has to be numeric." 2775msgid "connecting to the server. The result from the query has to be numeric."
3470msgstr "" 2776msgstr ""
3471 2777
3472#: plugins/check_pgsql.c:548
3473msgid "" 2778msgid ""
3474"Multiple SQL commands, separated by semicolon, are allowed but the result " 2779"Multiple SQL commands, separated by semicolon, are allowed but the result "
3475msgstr "" 2780msgstr ""
3476 2781
3477#: plugins/check_pgsql.c:549
3478msgid "of the last command is taken into account only. The value of the first" 2782msgid "of the last command is taken into account only. The value of the first"
3479msgstr "" 2783msgstr ""
3480 2784
3481#: plugins/check_pgsql.c:550 2785msgid ""
3482msgid "column in the first row is used as the check result." 2786"column in the first row is used as the check result. If a second column is"
2787msgstr ""
2788
2789msgid "present in the result set, this is added to the plugin output with a"
2790msgstr ""
2791
2792msgid ""
2793"prefix of \"Extra Info:\". This information can be displayed in the system"
2794msgstr ""
2795
2796msgid "executing the plugin."
3483msgstr "" 2797msgstr ""
3484 2798
3485#: plugins/check_pgsql.c:552
3486msgid "" 2799msgid ""
3487"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual" 2800"See the chapter \"Monitoring Database Activity\" of the PostgreSQL manual"
3488msgstr "" 2801msgstr ""
3489 2802
3490#: plugins/check_pgsql.c:553
3491msgid "" 2803msgid ""
3492"for details about how to access internal statistics of the database server." 2804"for details about how to access internal statistics of the database server."
3493msgstr "" 2805msgstr ""
3494 2806
3495#: plugins/check_pgsql.c:555
3496msgid "" 2807msgid ""
3497"For a list of available connection parameters which may be used with the -o" 2808"For a list of available connection parameters which may be used with the -o"
3498msgstr "" 2809msgstr ""
3499 2810
3500#: plugins/check_pgsql.c:556
3501msgid "" 2811msgid ""
3502"command line option, see the documentation for PQconnectdb() in the chapter" 2812"command line option, see the documentation for PQconnectdb() in the chapter"
3503msgstr "" 2813msgstr ""
3504 2814
3505#: plugins/check_pgsql.c:557
3506msgid "" 2815msgid ""
3507"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be" 2816"\"libpq - C Library\" of the PostgreSQL manual. For example, this may be"
3508msgstr "" 2817msgstr ""
3509 2818
3510#: plugins/check_pgsql.c:558
3511msgid "" 2819msgid ""
3512"used to specify a service name in pg_service.conf to be used for additional" 2820"used to specify a service name in pg_service.conf to be used for additional"
3513msgstr "" 2821msgstr ""
3514 2822
3515#: plugins/check_pgsql.c:559
3516msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:" 2823msgid "connection parameters: -o 'service=<name>' or to specify the SSL mode:"
3517msgstr "" 2824msgstr ""
3518 2825
3519#: plugins/check_pgsql.c:560
3520msgid "-o 'sslmode=require'." 2826msgid "-o 'sslmode=require'."
3521msgstr "" 2827msgstr ""
3522 2828
3523#: plugins/check_pgsql.c:562
3524msgid "" 2829msgid ""
3525"The plugin will connect to a local postmaster if no host is specified. To" 2830"The plugin will connect to a local postmaster if no host is specified. To"
3526msgstr "" 2831msgstr ""
3527 2832
3528#: plugins/check_pgsql.c:563
3529msgid "" 2833msgid ""
3530"connect to a remote host, be sure that the remote postmaster accepts TCP/IP" 2834"connect to a remote host, be sure that the remote postmaster accepts TCP/IP"
3531msgstr "" 2835msgstr ""
3532 2836
3533#: plugins/check_pgsql.c:564
3534msgid "connections (start the postmaster with the -i option)." 2837msgid "connections (start the postmaster with the -i option)."
3535msgstr "" 2838msgstr ""
3536 2839
3537#: plugins/check_pgsql.c:566
3538msgid "" 2840msgid ""
3539"Typically, the monitoring user (unless the --logname option is used) should " 2841"Typically, the monitoring user (unless the --logname option is used) should "
3540"be" 2842"be"
3541msgstr "" 2843msgstr ""
3542 2844
3543#: plugins/check_pgsql.c:567
3544msgid "" 2845msgid ""
3545"able to connect to the database without a password. The plugin can also send" 2846"able to connect to the database without a password. The plugin can also send"
3546msgstr "" 2847msgstr ""
3547 2848
3548#: plugins/check_pgsql.c:568
3549msgid "a password, but no effort is made to obscure or encrypt the password." 2849msgid "a password, but no effort is made to obscure or encrypt the password."
3550msgstr "" 2850msgstr ""
3551 2851
3552#: plugins/check_pgsql.c:601
3553#, c-format 2852#, c-format
3554msgid "QUERY %s - %s: %s.\n" 2853msgid "QUERY %s - %s: %s.\n"
3555msgstr "" 2854msgstr ""
3556 2855
3557#: plugins/check_pgsql.c:601
3558msgid "Error with query" 2856msgid "Error with query"
3559msgstr "" 2857msgstr ""
3560 2858
3561#: plugins/check_pgsql.c:607
3562msgid "No rows returned" 2859msgid "No rows returned"
3563msgstr "" 2860msgstr ""
3564 2861
3565#: plugins/check_pgsql.c:612
3566msgid "No columns returned" 2862msgid "No columns returned"
3567msgstr "" 2863msgstr ""
3568 2864
3569#: plugins/check_pgsql.c:618
3570msgid "No data returned" 2865msgid "No data returned"
3571msgstr "" 2866msgstr ""
3572 2867
3573#: plugins/check_pgsql.c:627
3574msgid "Is not a numeric" 2868msgid "Is not a numeric"
3575msgstr "" 2869msgstr ""
3576 2870
3577#: plugins/check_pgsql.c:644 2871#, c-format
2872msgid "%s returned %f"
2873msgstr ""
2874
3578#, c-format 2875#, c-format
3579msgid "'%s' returned %f" 2876msgid "'%s' returned %f"
3580msgstr "" 2877msgstr ""
3581 2878
3582#: plugins/check_ping.c:141
3583msgid "CRITICAL - Could not interpret output from ping command\n" 2879msgid "CRITICAL - Could not interpret output from ping command\n"
3584msgstr "" 2880msgstr ""
3585 2881
3586#: plugins/check_ping.c:157
3587#, c-format 2882#, c-format
3588msgid "PING %s - %sPacket loss = %d%%" 2883msgid "PING %s - %sPacket loss = %d%%"
3589msgstr "" 2884msgstr ""
3590 2885
3591#: plugins/check_ping.c:160
3592#, c-format 2886#, c-format
3593msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms" 2887msgid "PING %s - %sPacket loss = %d%%, RTA = %2.2f ms"
3594msgstr "" 2888msgstr ""
3595 2889
3596#: plugins/check_ping.c:257
3597msgid "Could not realloc() addresses\n" 2890msgid "Could not realloc() addresses\n"
3598msgstr "" 2891msgstr ""
3599 2892
3600#: plugins/check_ping.c:272 plugins/check_ping.c:352
3601#, c-format 2893#, c-format
3602msgid "<max_packets> (%s) must be a non-negative number\n" 2894msgid "<max_packets> (%s) must be a non-negative number\n"
3603msgstr "" 2895msgstr ""
3604 2896
3605#: plugins/check_ping.c:306
3606#, c-format 2897#, c-format
3607msgid "<wpl> (%s) must be an integer percentage\n" 2898msgid "<wpl> (%s) must be an integer percentage\n"
3608msgstr "" 2899msgstr ""
3609 2900
3610#: plugins/check_ping.c:317
3611#, c-format 2901#, c-format
3612msgid "<cpl> (%s) must be an integer percentage\n" 2902msgid "<cpl> (%s) must be an integer percentage\n"
3613msgstr "" 2903msgstr ""
3614 2904
3615#: plugins/check_ping.c:328
3616#, c-format 2905#, c-format
3617msgid "<wrta> (%s) must be a non-negative number\n" 2906msgid "<wrta> (%s) must be a non-negative number\n"
3618msgstr "" 2907msgstr ""
3619 2908
3620#: plugins/check_ping.c:339
3621#, c-format 2909#, c-format
3622msgid "<crta> (%s) must be a non-negative number\n" 2910msgid "<crta> (%s) must be a non-negative number\n"
3623msgstr "" 2911msgstr ""
3624 2912
3625#: plugins/check_ping.c:372
3626#, c-format 2913#, c-format
3627msgid "" 2914msgid ""
3628"%s: Warning threshold must be integer or percentage!\n" 2915"%s: Warning threshold must be integer or percentage!\n"
3629"\n" 2916"\n"
3630msgstr "" 2917msgstr ""
3631 2918
3632#: plugins/check_ping.c:385
3633#, c-format 2919#, c-format
3634msgid "<wrta> was not set\n" 2920msgid "<wrta> was not set\n"
3635msgstr "" 2921msgstr ""
3636 2922
3637#: plugins/check_ping.c:389
3638#, c-format 2923#, c-format
3639msgid "<crta> was not set\n" 2924msgid "<crta> was not set\n"
3640msgstr "" 2925msgstr ""
3641 2926
3642#: plugins/check_ping.c:393
3643#, c-format 2927#, c-format
3644msgid "<wpl> was not set\n" 2928msgid "<wpl> was not set\n"
3645msgstr "" 2929msgstr ""
3646 2930
3647#: plugins/check_ping.c:397
3648#, c-format 2931#, c-format
3649msgid "<cpl> was not set\n" 2932msgid "<cpl> was not set\n"
3650msgstr "" 2933msgstr ""
3651 2934
3652#: plugins/check_ping.c:401
3653#, c-format 2935#, c-format
3654msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n" 2936msgid "<wrta> (%f) cannot be larger than <crta> (%f)\n"
3655msgstr "" 2937msgstr ""
3656 2938
3657#: plugins/check_ping.c:405
3658#, c-format 2939#, c-format
3659msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n" 2940msgid "<wpl> (%d) cannot be larger than <cpl> (%d)\n"
3660msgstr "" 2941msgstr ""
3661 2942
3662#: plugins/check_ping.c:442
3663#, c-format 2943#, c-format
3664msgid "Cannot open stderr for %s\n" 2944msgid "Cannot open stderr for %s\n"
3665msgstr "" 2945msgstr ""
3666 2946
3667#: plugins/check_ping.c:492 plugins/check_ping.c:494
3668msgid "System call sent warnings to stderr " 2947msgid "System call sent warnings to stderr "
3669msgstr "" 2948msgstr ""
3670 2949
3671#: plugins/check_ping.c:519
3672#, c-format 2950#, c-format
3673msgid "CRITICAL - Network Unreachable (%s)\n" 2951msgid "CRITICAL - Network Unreachable (%s)\n"
3674msgstr "" 2952msgstr ""
3675 2953
3676#: plugins/check_ping.c:521
3677#, c-format 2954#, c-format
3678msgid "CRITICAL - Host Unreachable (%s)\n" 2955msgid "CRITICAL - Host Unreachable (%s)\n"
3679msgstr "" 2956msgstr ""
3680 2957
3681#: plugins/check_ping.c:523
3682#, c-format 2958#, c-format
3683msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n" 2959msgid "CRITICAL - Bogus ICMP: Port Unreachable (%s)\n"
3684msgstr "" 2960msgstr ""
3685 2961
3686#: plugins/check_ping.c:525
3687#, c-format 2962#, c-format
3688msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n" 2963msgid "CRITICAL - Bogus ICMP: Protocol Unreachable (%s)\n"
3689msgstr "" 2964msgstr ""
3690 2965
3691#: plugins/check_ping.c:527
3692#, c-format 2966#, c-format
3693msgid "CRITICAL - Network Prohibited (%s)\n" 2967msgid "CRITICAL - Network Prohibited (%s)\n"
3694msgstr "" 2968msgstr ""
3695 2969
3696#: plugins/check_ping.c:529
3697#, c-format 2970#, c-format
3698msgid "CRITICAL - Host Prohibited (%s)\n" 2971msgid "CRITICAL - Host Prohibited (%s)\n"
3699msgstr "" 2972msgstr ""
3700 2973
3701#: plugins/check_ping.c:531
3702#, c-format 2974#, c-format
3703msgid "CRITICAL - Packet Filtered (%s)\n" 2975msgid "CRITICAL - Packet Filtered (%s)\n"
3704msgstr "" 2976msgstr ""
3705 2977
3706#: plugins/check_ping.c:533
3707#, c-format 2978#, c-format
3708msgid "CRITICAL - Host not found (%s)\n" 2979msgid "CRITICAL - Host not found (%s)\n"
3709msgstr "" 2980msgstr ""
3710 2981
3711#: plugins/check_ping.c:535
3712#, c-format 2982#, c-format
3713msgid "CRITICAL - Time to live exceeded (%s)\n" 2983msgid "CRITICAL - Time to live exceeded (%s)\n"
3714msgstr "" 2984msgstr ""
3715 2985
3716#: plugins/check_ping.c:537
3717#, c-format 2986#, c-format
3718msgid "CRITICAL - Destination Unreachable (%s)\n" 2987msgid "CRITICAL - Destination Unreachable (%s)\n"
3719msgstr "" 2988msgstr ""
3720 2989
3721#: plugins/check_ping.c:544
3722msgid "Unable to realloc warn_text\n" 2990msgid "Unable to realloc warn_text\n"
3723msgstr "" 2991msgstr ""
3724 2992
3725#: plugins/check_ping.c:561
3726#, c-format 2993#, c-format
3727msgid "Use ping to check connection statistics for a remote host." 2994msgid "Use ping to check connection statistics for a remote host."
3728msgstr "" 2995msgstr ""
3729 2996
3730#: plugins/check_ping.c:573
3731msgid "host to ping" 2997msgid "host to ping"
3732msgstr "" 2998msgstr ""
3733 2999
3734#: plugins/check_ping.c:579
3735msgid "number of ICMP ECHO packets to send" 3000msgid "number of ICMP ECHO packets to send"
3736msgstr "" 3001msgstr ""
3737 3002
3738#: plugins/check_ping.c:580
3739#, c-format 3003#, c-format
3740msgid "(Default: %d)\n" 3004msgid "(Default: %d)\n"
3741msgstr "" 3005msgstr ""
3742 3006
3743#: plugins/check_ping.c:582
3744msgid "show HTML in the plugin output (obsoleted by urlize)" 3007msgid "show HTML in the plugin output (obsoleted by urlize)"
3745msgstr "" 3008msgstr ""
3746 3009
3747#: plugins/check_ping.c:587
3748msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel" 3010msgid "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average travel"
3749msgstr "" 3011msgstr ""
3750 3012
3751#: plugins/check_ping.c:588
3752msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the" 3013msgid "time (ms) which triggers a WARNING or CRITICAL state, and <pl> is the"
3753msgstr "" 3014msgstr ""
3754 3015
3755#: plugins/check_ping.c:589
3756msgid "percentage of packet loss to trigger an alarm state." 3016msgid "percentage of packet loss to trigger an alarm state."
3757msgstr "" 3017msgstr ""
3758 3018
3759#: plugins/check_ping.c:592
3760msgid "" 3019msgid ""
3761"This plugin uses the ping command to probe the specified host for packet loss" 3020"This plugin uses the ping command to probe the specified host for packet loss"
3762msgstr "" 3021msgstr ""
3763 3022
3764#: plugins/check_ping.c:593
3765msgid "" 3023msgid ""
3766"(percentage) and round trip average (milliseconds). It can produce HTML " 3024"(percentage) and round trip average (milliseconds). It can produce HTML "
3767"output" 3025"output"
3768msgstr "" 3026msgstr ""
3769 3027
3770#: plugins/check_ping.c:594
3771msgid "" 3028msgid ""
3772"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in" 3029"linking to a traceroute CGI contributed by Ian Cass. The CGI can be found in"
3773msgstr "" 3030msgstr ""
3774 3031
3775#: plugins/check_ping.c:595
3776msgid "the contrib area of the downloads section at http://www.nagios.org/" 3032msgid "the contrib area of the downloads section at http://www.nagios.org/"
3777msgstr "" 3033msgstr ""
3778 3034
3779#: plugins/check_procs.c:193
3780#, c-format 3035#, c-format
3781msgid "CMD: %s\n" 3036msgid "CMD: %s\n"
3782msgstr "" 3037msgstr ""
3783 3038
3784#: plugins/check_procs.c:198
3785msgid "System call sent warnings to stderr" 3039msgid "System call sent warnings to stderr"
3786msgstr "" 3040msgstr ""
3787 3041
3788#: plugins/check_procs.c:326
3789#, c-format 3042#, c-format
3790msgid "Not parseable: %s" 3043msgid "Not parseable: %s"
3791msgstr "" 3044msgstr ""
3792 3045
3793#: plugins/check_procs.c:331
3794#, c-format 3046#, c-format
3795msgid "Unable to read output\n" 3047msgid "Unable to read output\n"
3796msgstr "" 3048msgstr ""
3797 3049
3798#: plugins/check_procs.c:348
3799#, c-format 3050#, c-format
3800msgid "%d warn out of " 3051msgid "%d warn out of "
3801msgstr "" 3052msgstr ""
3802 3053
3803#: plugins/check_procs.c:353
3804#, c-format 3054#, c-format
3805msgid "%d crit, %d warn out of " 3055msgid "%d crit, %d warn out of "
3806msgstr "" 3056msgstr ""
3807 3057
3808#: plugins/check_procs.c:359
3809#, c-format 3058#, c-format
3810msgid " with %s" 3059msgid " with %s"
3811msgstr "" 3060msgstr ""
3812 3061
3813#: plugins/check_procs.c:453
3814msgid "Parent Process ID must be an integer!" 3062msgid "Parent Process ID must be an integer!"
3815msgstr "" 3063msgstr ""
3816 3064
3817#: plugins/check_procs.c:459 plugins/check_procs.c:586
3818#, c-format 3065#, c-format
3819msgid "%s%sSTATE = %s" 3066msgid "%s%sSTATE = %s"
3820msgstr "" 3067msgstr ""
3821 3068
3822#: plugins/check_procs.c:468
3823msgid "UID was not found" 3069msgid "UID was not found"
3824msgstr "" 3070msgstr ""
3825 3071
3826#: plugins/check_procs.c:474
3827msgid "User name was not found" 3072msgid "User name was not found"
3828msgstr "" 3073msgstr ""
3829 3074
3830#: plugins/check_procs.c:489
3831#, c-format 3075#, c-format
3832msgid "%s%scommand name '%s'" 3076msgid "%s%scommand name '%s'"
3833msgstr "" 3077msgstr ""
3834 3078
3835#: plugins/check_procs.c:524 3079#, c-format
3080msgid "%s%sexclude progs '%s'"
3081msgstr ""
3082
3836msgid "RSS must be an integer!" 3083msgid "RSS must be an integer!"
3837msgstr "" 3084msgstr ""
3838 3085
3839#: plugins/check_procs.c:531
3840msgid "VSZ must be an integer!" 3086msgid "VSZ must be an integer!"
3841msgstr "" 3087msgstr ""
3842 3088
3843#: plugins/check_procs.c:539
3844msgid "PCPU must be a float!" 3089msgid "PCPU must be a float!"
3845msgstr "" 3090msgstr ""
3846 3091
3847#: plugins/check_procs.c:563
3848msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!" 3092msgid "Metric must be one of PROCS, VSZ, RSS, CPU, ELAPSED!"
3849msgstr "" 3093msgstr ""
3850 3094
3851#: plugins/check_procs.c:694
3852msgid "" 3095msgid ""
3853"Checks all processes and generates WARNING or CRITICAL states if the " 3096"Checks all processes and generates WARNING or CRITICAL states if the "
3854"specified" 3097"specified"
3855msgstr "" 3098msgstr ""
3856 3099
3857#: plugins/check_procs.c:695
3858msgid "" 3100msgid ""
3859"metric is outside the required threshold ranges. The metric defaults to " 3101"metric is outside the required threshold ranges. The metric defaults to "
3860"number" 3102"number"
3861msgstr "" 3103msgstr ""
3862 3104
3863#: plugins/check_procs.c:696
3864msgid "" 3105msgid ""
3865"of processes. Search filters can be applied to limit the processes to check." 3106"of processes. Search filters can be applied to limit the processes to check."
3866msgstr "" 3107msgstr ""
3867 3108
3868#: plugins/check_procs.c:705
3869msgid "Generate warning state if metric is outside this range" 3109msgid "Generate warning state if metric is outside this range"
3870msgstr "" 3110msgstr ""
3871 3111
3872#: plugins/check_procs.c:707
3873msgid "Generate critical state if metric is outside this range" 3112msgid "Generate critical state if metric is outside this range"
3874msgstr "" 3113msgstr ""
3875 3114
3876#: plugins/check_procs.c:709
3877msgid "Check thresholds against metric. Valid types:" 3115msgid "Check thresholds against metric. Valid types:"
3878msgstr "" 3116msgstr ""
3879 3117
3880#: plugins/check_procs.c:710
3881msgid "PROCS - number of processes (default)" 3118msgid "PROCS - number of processes (default)"
3882msgstr "" 3119msgstr ""
3883 3120
3884#: plugins/check_procs.c:711
3885msgid "VSZ - virtual memory size" 3121msgid "VSZ - virtual memory size"
3886msgstr "" 3122msgstr ""
3887 3123
3888#: plugins/check_procs.c:712
3889msgid "RSS - resident set memory size" 3124msgid "RSS - resident set memory size"
3890msgstr "" 3125msgstr ""
3891 3126
3892#: plugins/check_procs.c:713
3893msgid "CPU - percentage CPU" 3127msgid "CPU - percentage CPU"
3894msgstr "" 3128msgstr ""
3895 3129
3896#: plugins/check_procs.c:716
3897msgid "ELAPSED - time elapsed in seconds" 3130msgid "ELAPSED - time elapsed in seconds"
3898msgstr "" 3131msgstr ""
3899 3132
3900#: plugins/check_procs.c:721
3901msgid "Extra information. Up to 3 verbosity levels" 3133msgid "Extra information. Up to 3 verbosity levels"
3902msgstr "" 3134msgstr ""
3903 3135
3904#: plugins/check_procs.c:724
3905msgid "Filter own process the traditional way by PID instead of /proc/pid/exe" 3136msgid "Filter own process the traditional way by PID instead of /proc/pid/exe"
3906msgstr "" 3137msgstr ""
3907 3138
3908#: plugins/check_procs.c:729
3909msgid "Only scan for processes that have, in the output of `ps`, one or" 3139msgid "Only scan for processes that have, in the output of `ps`, one or"
3910msgstr "" 3140msgstr ""
3911 3141
3912#: plugins/check_procs.c:730
3913msgid "more of the status flags you specify (for example R, Z, S, RS," 3142msgid "more of the status flags you specify (for example R, Z, S, RS,"
3914msgstr "" 3143msgstr ""
3915 3144
3916#: plugins/check_procs.c:731
3917msgid "RSZDT, plus others based on the output of your 'ps' command)." 3145msgid "RSZDT, plus others based on the output of your 'ps' command)."
3918msgstr "" 3146msgstr ""
3919 3147
3920#: plugins/check_procs.c:733
3921msgid "Only scan for children of the parent process ID indicated." 3148msgid "Only scan for children of the parent process ID indicated."
3922msgstr "" 3149msgstr ""
3923 3150
3924#: plugins/check_procs.c:735
3925msgid "Only scan for processes with VSZ higher than indicated." 3151msgid "Only scan for processes with VSZ higher than indicated."
3926msgstr "" 3152msgstr ""
3927 3153
3928#: plugins/check_procs.c:737
3929msgid "Only scan for processes with RSS higher than indicated." 3154msgid "Only scan for processes with RSS higher than indicated."
3930msgstr "" 3155msgstr ""
3931 3156
3932#: plugins/check_procs.c:739
3933msgid "Only scan for processes with PCPU higher than indicated." 3157msgid "Only scan for processes with PCPU higher than indicated."
3934msgstr "" 3158msgstr ""
3935 3159
3936#: plugins/check_procs.c:741
3937msgid "Only scan for processes with user name or ID indicated." 3160msgid "Only scan for processes with user name or ID indicated."
3938msgstr "" 3161msgstr ""
3939 3162
3940#: plugins/check_procs.c:743
3941msgid "Only scan for processes with args that contain STRING." 3163msgid "Only scan for processes with args that contain STRING."
3942msgstr "" 3164msgstr ""
3943 3165
3944#: plugins/check_procs.c:745
3945msgid "Only scan for processes with args that contain the regex STRING." 3166msgid "Only scan for processes with args that contain the regex STRING."
3946msgstr "" 3167msgstr ""
3947 3168
3948#: plugins/check_procs.c:747
3949msgid "Only scan for exact matches of COMMAND (without path)." 3169msgid "Only scan for exact matches of COMMAND (without path)."
3950msgstr "" 3170msgstr ""
3951 3171
3952#: plugins/check_procs.c:749 3172msgid "Exclude processes which match this comma separated list"
3173msgstr ""
3174
3953msgid "Only scan for non kernel threads (works on Linux only)." 3175msgid "Only scan for non kernel threads (works on Linux only)."
3954msgstr "" 3176msgstr ""
3955 3177
3956#: plugins/check_procs.c:751
3957#, c-format 3178#, c-format
3958msgid "" 3179msgid ""
3959"\n" 3180"\n"
@@ -3963,7 +3184,6 @@ msgid ""
3963"\n" 3184"\n"
3964msgstr "" 3185msgstr ""
3965 3186
3966#: plugins/check_procs.c:756
3967#, c-format 3187#, c-format
3968msgid "" 3188msgid ""
3969"This plugin checks the number of currently running processes and\n" 3189"This plugin checks the number of currently running processes and\n"
@@ -3974,1568 +3194,1335 @@ msgid ""
3974"\n" 3194"\n"
3975msgstr "" 3195msgstr ""
3976 3196
3977#: plugins/check_procs.c:765
3978msgid "Warning if not two processes with command name portsentry." 3197msgid "Warning if not two processes with command name portsentry."
3979msgstr "" 3198msgstr ""
3980 3199
3981#: plugins/check_procs.c:766
3982msgid "Critical if < 2 or > 1024 processes" 3200msgid "Critical if < 2 or > 1024 processes"
3983msgstr "" 3201msgstr ""
3984 3202
3985#: plugins/check_procs.c:768 3203msgid "Critical if not at least 1 process with command sshd"
3204msgstr ""
3205
3206msgid "Warning if > 1024 processes with command name sshd."
3207msgstr ""
3208
3209msgid "Critical if < 1 processes with command name sshd."
3210msgstr ""
3211
3986msgid "Warning alert if > 10 processes with command arguments containing" 3212msgid "Warning alert if > 10 processes with command arguments containing"
3987msgstr "" 3213msgstr ""
3988 3214
3989#: plugins/check_procs.c:769
3990msgid "'/usr/local/bin/perl' and owned by root" 3215msgid "'/usr/local/bin/perl' and owned by root"
3991msgstr "" 3216msgstr ""
3992 3217
3993#: plugins/check_procs.c:771
3994msgid "Alert if VSZ of any processes over 50K or 100K" 3218msgid "Alert if VSZ of any processes over 50K or 100K"
3995msgstr "" 3219msgstr ""
3996 3220
3997#: plugins/check_procs.c:773 3221msgid "Alert if CPU of any processes over 10% or 20%"
3998#, c-format
3999msgid "Alert if CPU of any processes over 10%% or 20%%"
4000msgstr "" 3222msgstr ""
4001 3223
4002#: plugins/check_radius.c:165 3224msgid "Config file error\n"
4003msgid "Config file error"
4004msgstr "" 3225msgstr ""
4005 3226
4006#: plugins/check_radius.c:174 3227msgid "Out of Memory?\n"
4007msgid "Out of Memory?"
4008msgstr "" 3228msgstr ""
4009 3229
4010#: plugins/check_radius.c:178 3230msgid "Invalid NAS-Identifier\n"
4011msgid "Invalid NAS-Identifier"
4012msgstr "" 3231msgstr ""
4013 3232
4014#: plugins/check_radius.c:183 plugins/check_radius.c:185 3233#, c-format
4015#: plugins/check_radius.c:191 3234msgid "gethostname() failed!\n"
4016msgid "Invalid NAS-IP-Address"
4017msgstr "" 3235msgstr ""
4018 3236
4019#: plugins/check_radius.c:188 3237msgid "Invalid NAS-IP-Address\n"
4020msgid "Can't find local IP for NAS-IP-Address"
4021msgstr "" 3238msgstr ""
4022 3239
4023#: plugins/check_radius.c:202 3240msgid "Timeout\n"
4024msgid "Timeout"
4025msgstr "" 3241msgstr ""
4026 3242
4027#: plugins/check_radius.c:204 3243msgid "Auth Error\n"
4028msgid "Auth Error"
4029msgstr "" 3244msgstr ""
4030 3245
4031#: plugins/check_radius.c:206 3246msgid "Auth Failed\n"
4032msgid "Auth Failed"
4033msgstr "" 3247msgstr ""
4034 3248
4035#: plugins/check_radius.c:208 3249msgid "Bad Response\n"
4036msgid "Bad Response"
4037msgstr "" 3250msgstr ""
4038 3251
4039#: plugins/check_radius.c:212 3252msgid "Auth OK\n"
4040msgid "Auth OK"
4041msgstr "" 3253msgstr ""
4042 3254
4043#: plugins/check_radius.c:213
4044#, c-format 3255#, c-format
4045msgid "Unexpected result code %d" 3256msgid "Unexpected result code %d"
4046msgstr "" 3257msgstr ""
4047 3258
4048#: plugins/check_radius.c:302
4049msgid "Number of retries must be a positive integer" 3259msgid "Number of retries must be a positive integer"
4050msgstr "" 3260msgstr ""
4051 3261
4052#: plugins/check_radius.c:316
4053msgid "User not specified" 3262msgid "User not specified"
4054msgstr "" 3263msgstr ""
4055 3264
4056#: plugins/check_radius.c:318
4057msgid "Password not specified" 3265msgid "Password not specified"
4058msgstr "" 3266msgstr ""
4059 3267
4060#: plugins/check_radius.c:320
4061msgid "Configuration file not specified" 3268msgid "Configuration file not specified"
4062msgstr "" 3269msgstr ""
4063 3270
4064#: plugins/check_radius.c:338
4065msgid "Tests to see if a RADIUS server is accepting connections." 3271msgid "Tests to see if a RADIUS server is accepting connections."
4066msgstr "" 3272msgstr ""
4067 3273
4068#: plugins/check_radius.c:350
4069msgid "The user to authenticate" 3274msgid "The user to authenticate"
4070msgstr "" 3275msgstr ""
4071 3276
4072#: plugins/check_radius.c:352
4073msgid "Password for authentication (SECURITY RISK)" 3277msgid "Password for authentication (SECURITY RISK)"
4074msgstr "" 3278msgstr ""
4075 3279
4076#: plugins/check_radius.c:354
4077msgid "NAS identifier" 3280msgid "NAS identifier"
4078msgstr "" 3281msgstr ""
4079 3282
4080#: plugins/check_radius.c:356
4081msgid "NAS IP Address" 3283msgid "NAS IP Address"
4082msgstr "" 3284msgstr ""
4083 3285
4084#: plugins/check_radius.c:358
4085msgid "Configuration file" 3286msgid "Configuration file"
4086msgstr "" 3287msgstr ""
4087 3288
4088#: plugins/check_radius.c:360
4089msgid "Response string to expect from the server" 3289msgid "Response string to expect from the server"
4090msgstr "" 3290msgstr ""
4091 3291
4092#: plugins/check_radius.c:362
4093msgid "Number of times to retry a failed connection" 3292msgid "Number of times to retry a failed connection"
4094msgstr "" 3293msgstr ""
4095 3294
4096#: plugins/check_radius.c:367
4097msgid "" 3295msgid ""
4098"This plugin tests a RADIUS server to see if it is accepting connections." 3296"This plugin tests a RADIUS server to see if it is accepting connections."
4099msgstr "" 3297msgstr ""
4100 3298
4101#: plugins/check_radius.c:368
4102msgid "" 3299msgid ""
4103"The server to test must be specified in the invocation, as well as a user" 3300"The server to test must be specified in the invocation, as well as a user"
4104msgstr "" 3301msgstr ""
4105 3302
4106#: plugins/check_radius.c:369 3303msgid "name and password. A configuration file must be present. The format of"
4107msgid ""
4108"name and password. A configuration file may also be present. The format of"
4109msgstr "" 3304msgstr ""
4110 3305
4111#: plugins/check_radius.c:370
4112msgid "" 3306msgid ""
4113"the configuration file is described in the radiusclient library sources." 3307"the configuration file is described in the radiusclient library sources."
4114msgstr "" 3308msgstr ""
4115 3309
4116#: plugins/check_radius.c:371
4117msgid "The password option presents a substantial security issue because the" 3310msgid "The password option presents a substantial security issue because the"
4118msgstr "" 3311msgstr ""
4119 3312
4120#: plugins/check_radius.c:372
4121msgid "" 3313msgid ""
4122"password can possibly be determined by careful watching of the command line" 3314"password can possibly be determined by careful watching of the command line"
4123msgstr "" 3315msgstr ""
4124 3316
4125#: plugins/check_radius.c:373 3317msgid "in a process listing. This risk is exacerbated because the plugin will"
4126msgid "in a process listing. This risk is exacerbated because the monitor will"
4127msgstr "" 3318msgstr ""
4128 3319
4129#: plugins/check_radius.c:374 3320msgid ""
4130msgid "run the plugin at regular predictable intervals. Please be sure that" 3321"typically be executed at regular predictable intervals. Please be sure that"
4131msgstr "" 3322msgstr ""
4132 3323
4133#: plugins/check_radius.c:375
4134msgid "the password used does not allow access to sensitive system resources." 3324msgid "the password used does not allow access to sensitive system resources."
4135msgstr "" 3325msgstr ""
4136 3326
4137#: plugins/check_real.c:91
4138#, c-format 3327#, c-format
4139msgid "Unable to connect to %s on port %d\n" 3328msgid "Unable to connect to %s on port %d\n"
4140msgstr "" 3329msgstr ""
4141 3330
4142#: plugins/check_real.c:113
4143#, c-format 3331#, c-format
4144msgid "No data received from %s\n" 3332msgid "No data received from %s\n"
4145msgstr "" 3333msgstr ""
4146 3334
4147#: plugins/check_real.c:118 plugins/check_real.c:191
4148msgid "Invalid REAL response received from host" 3335msgid "Invalid REAL response received from host"
4149msgstr "" 3336msgstr ""
4150 3337
4151#: plugins/check_real.c:120 plugins/check_real.c:193
4152#, c-format 3338#, c-format
4153msgid "Invalid REAL response received from host on port %d\n" 3339msgid "Invalid REAL response received from host on port %d\n"
4154msgstr "" 3340msgstr ""
4155 3341
4156#: plugins/check_real.c:184 plugins/check_tcp.c:311
4157#, c-format 3342#, c-format
4158msgid "No data received from host\n" 3343msgid "No data received from host\n"
4159msgstr "" 3344msgstr ""
4160 3345
4161#: plugins/check_real.c:247
4162#, c-format 3346#, c-format
4163msgid "REAL %s - %d second response time\n" 3347msgid "REAL %s - %d second response time\n"
4164msgstr "" 3348msgstr ""
4165 3349
4166#: plugins/check_real.c:336 plugins/check_ups.c:536
4167msgid "Warning time must be a positive integer" 3350msgid "Warning time must be a positive integer"
4168msgstr "" 3351msgstr ""
4169 3352
4170#: plugins/check_real.c:345 plugins/check_ups.c:527
4171msgid "Critical time must be a positive integer" 3353msgid "Critical time must be a positive integer"
4172msgstr "" 3354msgstr ""
4173 3355
4174#: plugins/check_real.c:381
4175msgid "You must provide a server to check" 3356msgid "You must provide a server to check"
4176msgstr "" 3357msgstr ""
4177 3358
4178#: plugins/check_real.c:413
4179msgid "This plugin tests the REAL service on the specified host." 3359msgid "This plugin tests the REAL service on the specified host."
4180msgstr "" 3360msgstr ""
4181 3361
4182#: plugins/check_real.c:425
4183msgid "Connect to this url" 3362msgid "Connect to this url"
4184msgstr "" 3363msgstr ""
4185 3364
4186#: plugins/check_real.c:427
4187#, c-format 3365#, c-format
4188msgid "String to expect in first line of server response (default: %s)\n" 3366msgid "String to expect in first line of server response (default: %s)\n"
4189msgstr "" 3367msgstr ""
4190 3368
4191#: plugins/check_real.c:437
4192msgid "This plugin will attempt to open an RTSP connection with the host." 3369msgid "This plugin will attempt to open an RTSP connection with the host."
4193msgstr "" 3370msgstr ""
4194 3371
4195#: plugins/check_real.c:438 plugins/check_smtp.c:830 3372msgid "Successful connects return STATE_OK, refusals and timeouts return"
4196msgid "Successul connects return STATE_OK, refusals and timeouts return"
4197msgstr "" 3373msgstr ""
4198 3374
4199#: plugins/check_real.c:439
4200msgid "" 3375msgid ""
4201"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects," 3376"STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful connects,"
4202msgstr "" 3377msgstr ""
4203 3378
4204#: plugins/check_real.c:440
4205msgid "" 3379msgid ""
4206"but incorrect response messages from the host result in STATE_WARNING return" 3380"but incorrect response messages from the host result in STATE_WARNING return"
4207msgstr "" 3381msgstr ""
4208 3382
4209#: plugins/check_real.c:441
4210msgid "values." 3383msgid "values."
4211msgstr "" 3384msgstr ""
4212 3385
4213#: plugins/check_smtp.c:150 plugins/check_swap.c:265 plugins/check_swap.c:271
4214#, c-format 3386#, c-format
4215msgid "malloc() failed!\n" 3387msgid "malloc() failed!\n"
4216msgstr "" 3388msgstr ""
4217 3389
4218#: plugins/check_smtp.c:154
4219#, c-format 3390#, c-format
4220msgid "gethostname() failed!\n" 3391msgid "CRITICAL - Cannot create SSL context.\n"
4221msgstr "" 3392msgstr ""
4222 3393
4223#: plugins/check_smtp.c:189 plugins/check_smtp.c:213
4224#, c-format 3394#, c-format
4225msgid "recv() failed\n" 3395msgid "recv() failed\n"
4226msgstr "" 3396msgstr ""
4227 3397
4228#: plugins/check_smtp.c:200
4229#, c-format
4230msgid "Invalid SMTP response received from host: %s\n"
4231msgstr ""
4232
4233#: plugins/check_smtp.c:202
4234#, c-format
4235msgid "Invalid SMTP response received from host on port %d: %s\n"
4236msgstr ""
4237
4238#: plugins/check_smtp.c:223
4239#, c-format 3398#, c-format
4240msgid "WARNING - TLS not supported by server\n" 3399msgid "WARNING - TLS not supported by server\n"
4241msgstr "" 3400msgstr ""
4242 3401
4243#: plugins/check_smtp.c:235
4244#, c-format 3402#, c-format
4245msgid "Server does not support STARTTLS\n" 3403msgid "Server does not support STARTTLS\n"
4246msgstr "" 3404msgstr ""
4247 3405
4248#: plugins/check_smtp.c:241
4249#, c-format
4250msgid "CRITICAL - Cannot create SSL context.\n"
4251msgstr ""
4252
4253#: plugins/check_smtp.c:261
4254msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS." 3406msgid "SMTP UNKNOWN - Cannot send EHLO command via TLS."
4255msgstr "" 3407msgstr ""
4256 3408
4257#: plugins/check_smtp.c:266
4258#, c-format 3409#, c-format
4259msgid "sent %s" 3410msgid "sent %s"
4260msgstr "" 3411msgstr ""
4261 3412
4262#: plugins/check_smtp.c:268
4263msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS." 3413msgid "SMTP UNKNOWN - Cannot read EHLO response via TLS."
4264msgstr "" 3414msgstr ""
4265 3415
4266#: plugins/check_smtp.c:303 plugins/check_snmp.c:806 3416#, c-format
3417msgid "Invalid SMTP response received from host: %s\n"
3418msgstr ""
3419
3420#, c-format
3421msgid "Invalid SMTP response received from host on port %d: %s\n"
3422msgstr ""
3423
4267#, c-format 3424#, c-format
4268msgid "Could Not Compile Regular Expression" 3425msgid "Could Not Compile Regular Expression"
4269msgstr "" 3426msgstr ""
4270 3427
4271#: plugins/check_smtp.c:312
4272#, c-format 3428#, c-format
4273msgid "SMTP %s - Invalid response '%s' to command '%s'\n" 3429msgid "SMTP %s - Invalid response '%s' to command '%s'\n"
4274msgstr "" 3430msgstr ""
4275 3431
4276#: plugins/check_smtp.c:316 plugins/check_snmp.c:511
4277#, c-format 3432#, c-format
4278msgid "Execute Error: %s\n" 3433msgid "Execute Error: %s\n"
4279msgstr "" 3434msgstr ""
4280 3435
4281#: plugins/check_smtp.c:330
4282msgid "no authuser specified, " 3436msgid "no authuser specified, "
4283msgstr "" 3437msgstr ""
4284 3438
4285#: plugins/check_smtp.c:335
4286msgid "no authpass specified, " 3439msgid "no authpass specified, "
4287msgstr "" 3440msgstr ""
4288 3441
4289#: plugins/check_smtp.c:342 plugins/check_smtp.c:363 plugins/check_smtp.c:383
4290#: plugins/check_smtp.c:688
4291#, c-format 3442#, c-format
4292msgid "sent %s\n" 3443msgid "sent %s\n"
4293msgstr "" 3444msgstr ""
4294 3445
4295#: plugins/check_smtp.c:345
4296msgid "recv() failed after AUTH LOGIN, " 3446msgid "recv() failed after AUTH LOGIN, "
4297msgstr "" 3447msgstr ""
4298 3448
4299#: plugins/check_smtp.c:350 plugins/check_smtp.c:371 plugins/check_smtp.c:391
4300#: plugins/check_smtp.c:699
4301#, c-format 3449#, c-format
4302msgid "received %s\n" 3450msgid "received %s\n"
4303msgstr "" 3451msgstr ""
4304 3452
4305#: plugins/check_smtp.c:354
4306msgid "invalid response received after AUTH LOGIN, " 3453msgid "invalid response received after AUTH LOGIN, "
4307msgstr "" 3454msgstr ""
4308 3455
4309#: plugins/check_smtp.c:367
4310msgid "recv() failed after sending authuser, " 3456msgid "recv() failed after sending authuser, "
4311msgstr "" 3457msgstr ""
4312 3458
4313#: plugins/check_smtp.c:375
4314msgid "invalid response received after authuser, " 3459msgid "invalid response received after authuser, "
4315msgstr "" 3460msgstr ""
4316 3461
4317#: plugins/check_smtp.c:387
4318msgid "recv() failed after sending authpass, " 3462msgid "recv() failed after sending authpass, "
4319msgstr "" 3463msgstr ""
4320 3464
4321#: plugins/check_smtp.c:395
4322msgid "invalid response received after authpass, " 3465msgid "invalid response received after authpass, "
4323msgstr "" 3466msgstr ""
4324 3467
4325#: plugins/check_smtp.c:402
4326msgid "only authtype LOGIN is supported, " 3468msgid "only authtype LOGIN is supported, "
4327msgstr "" 3469msgstr ""
4328 3470
4329#: plugins/check_smtp.c:426
4330#, c-format 3471#, c-format
4331msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n" 3472msgid "SMTP %s - %s%.3f sec. response time%s%s|%s\n"
4332msgstr "" 3473msgstr ""
4333 3474
4334#: plugins/check_smtp.c:536 plugins/check_smtp.c:548
4335#, c-format 3475#, c-format
4336msgid "Could not realloc() units [%d]\n" 3476msgid "Could not realloc() units [%d]\n"
4337msgstr "" 3477msgstr ""
4338 3478
4339#: plugins/check_smtp.c:556
4340msgid "Critical time must be a positive" 3479msgid "Critical time must be a positive"
4341msgstr "" 3480msgstr ""
4342 3481
4343#: plugins/check_smtp.c:564
4344msgid "Warning time must be a positive" 3482msgid "Warning time must be a positive"
4345msgstr "" 3483msgstr ""
4346 3484
4347#: plugins/check_smtp.c:611
4348msgid "SSL support not available - install OpenSSL and recompile" 3485msgid "SSL support not available - install OpenSSL and recompile"
4349msgstr "" 3486msgstr ""
4350 3487
4351#: plugins/check_smtp.c:679 plugins/check_smtp.c:684 3488msgid "Set either -s/--ssl/--tls or -S/--starttls"
3489msgstr ""
3490
4352#, c-format 3491#, c-format
4353msgid "Connection closed by server before sending QUIT command\n" 3492msgid "Connection closed by server before sending QUIT command\n"
4354msgstr "" 3493msgstr ""
4355 3494
4356#: plugins/check_smtp.c:694
4357#, c-format 3495#, c-format
4358msgid "recv() failed after QUIT." 3496msgid "recv() failed after QUIT."
4359msgstr "" 3497msgstr ""
4360 3498
4361#: plugins/check_smtp.c:696
4362#, c-format 3499#, c-format
4363msgid "Connection reset by peer." 3500msgid "Connection reset by peer."
4364msgstr "" 3501msgstr ""
4365 3502
4366#: plugins/check_smtp.c:784
4367msgid "This plugin will attempt to open an SMTP connection with the host." 3503msgid "This plugin will attempt to open an SMTP connection with the host."
4368msgstr "" 3504msgstr ""
4369 3505
4370#: plugins/check_smtp.c:798
4371#, c-format 3506#, c-format
4372msgid " String to expect in first line of server response (default: '%s')\n" 3507msgid " String to expect in first line of server response (default: '%s')\n"
4373msgstr "" 3508msgstr ""
4374 3509
4375#: plugins/check_smtp.c:800
4376msgid "SMTP command (may be used repeatedly)" 3510msgid "SMTP command (may be used repeatedly)"
4377msgstr "" 3511msgstr ""
4378 3512
4379#: plugins/check_smtp.c:802
4380msgid "Expected response to command (may be used repeatedly)" 3513msgid "Expected response to command (may be used repeatedly)"
4381msgstr "" 3514msgstr ""
4382 3515
4383#: plugins/check_smtp.c:804
4384msgid "FROM-address to include in MAIL command, required by Exchange 2000" 3516msgid "FROM-address to include in MAIL command, required by Exchange 2000"
4385msgstr "" 3517msgstr ""
4386 3518
4387#: plugins/check_smtp.c:806
4388msgid "FQDN used for HELO" 3519msgid "FQDN used for HELO"
4389msgstr "" 3520msgstr ""
4390 3521
4391#: plugins/check_smtp.c:809 plugins/check_tcp.c:665 3522msgid "Use PROXY protocol prefix for the connection."
3523msgstr ""
3524
4392msgid "Minimum number of days a certificate has to be valid." 3525msgid "Minimum number of days a certificate has to be valid."
4393msgstr "" 3526msgstr ""
4394 3527
4395#: plugins/check_smtp.c:811 3528msgid "Use SSL/TLS for the connection."
3529msgstr ""
3530
3531#, c-format
3532msgid " Sets default port to %d.\n"
3533msgstr ""
3534
4396msgid "Use STARTTLS for the connection." 3535msgid "Use STARTTLS for the connection."
4397msgstr "" 3536msgstr ""
4398 3537
4399#: plugins/check_smtp.c:815
4400msgid "SMTP AUTH type to check (default none, only LOGIN supported)" 3538msgid "SMTP AUTH type to check (default none, only LOGIN supported)"
4401msgstr "" 3539msgstr ""
4402 3540
4403#: plugins/check_smtp.c:817
4404msgid "SMTP AUTH username" 3541msgid "SMTP AUTH username"
4405msgstr "" 3542msgstr ""
4406 3543
4407#: plugins/check_smtp.c:819
4408msgid "SMTP AUTH password" 3544msgid "SMTP AUTH password"
4409msgstr "" 3545msgstr ""
4410 3546
4411#: plugins/check_smtp.c:821 3547msgid "Send LHLO instead of HELO/EHLO"
3548msgstr ""
3549
4412msgid "Ignore failure when sending QUIT command to server" 3550msgid "Ignore failure when sending QUIT command to server"
4413msgstr "" 3551msgstr ""
4414 3552
4415#: plugins/check_smtp.c:831
4416msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful" 3553msgid "STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful"
4417msgstr "" 3554msgstr ""
4418 3555
4419#: plugins/check_smtp.c:832
4420msgid "connects, but incorrect response messages from the host result in" 3556msgid "connects, but incorrect response messages from the host result in"
4421msgstr "" 3557msgstr ""
4422 3558
4423#: plugins/check_smtp.c:833
4424msgid "STATE_WARNING return values." 3559msgid "STATE_WARNING return values."
4425msgstr "" 3560msgstr ""
4426 3561
4427#: plugins/check_snmp.c:169 plugins/check_snmp.c:582
4428msgid "Cannot malloc" 3562msgid "Cannot malloc"
4429msgstr "" 3563msgstr ""
4430 3564
4431#: plugins/check_snmp.c:356
4432#, c-format 3565#, c-format
4433msgid "External command error: %s\n" 3566msgid "External command error: %s\n"
4434msgstr "" 3567msgstr ""
4435 3568
4436#: plugins/check_snmp.c:361
4437#, c-format 3569#, c-format
4438msgid "External command error with no output (return code: %d)\n" 3570msgid "External command error with no output (return code: %d)\n"
4439msgstr "" 3571msgstr ""
4440 3572
4441#: plugins/check_snmp.c:464
4442#, c-format 3573#, c-format
4443msgid "No valid data returned (%s)\n" 3574msgid "No valid data returned (%s)\n"
4444msgstr "" 3575msgstr ""
4445 3576
4446#: plugins/check_snmp.c:475
4447msgid "Time duration between plugin calls is invalid" 3577msgid "Time duration between plugin calls is invalid"
4448msgstr "" 3578msgstr ""
4449 3579
4450#: plugins/check_snmp.c:588
4451msgid "Cannot asprintf()" 3580msgid "Cannot asprintf()"
4452msgstr "" 3581msgstr ""
4453 3582
4454#: plugins/check_snmp.c:594
4455msgid "Cannot realloc()" 3583msgid "Cannot realloc()"
4456msgstr "" 3584msgstr ""
4457 3585
4458#: plugins/check_snmp.c:610
4459msgid "No previous data to calculate rate - assume okay" 3586msgid "No previous data to calculate rate - assume okay"
4460msgstr "" 3587msgstr ""
4461 3588
4462#: plugins/check_snmp.c:751
4463msgid "Retries interval must be a positive integer" 3589msgid "Retries interval must be a positive integer"
4464msgstr "" 3590msgstr ""
4465 3591
4466#: plugins/check_snmp.c:831 3592msgid "Exit status must be a positive integer"
3593msgstr ""
3594
4467#, c-format 3595#, c-format
4468msgid "Could not reallocate labels[%d]" 3596msgid "Could not reallocate labels[%d]"
4469msgstr "" 3597msgstr ""
4470 3598
4471#: plugins/check_snmp.c:844
4472msgid "Could not reallocate labels\n" 3599msgid "Could not reallocate labels\n"
4473msgstr "" 3600msgstr ""
4474 3601
4475#: plugins/check_snmp.c:860
4476#, c-format 3602#, c-format
4477msgid "Could not reallocate units [%d]\n" 3603msgid "Could not reallocate units [%d]\n"
4478msgstr "" 3604msgstr ""
4479 3605
4480#: plugins/check_snmp.c:872
4481msgid "Could not realloc() units\n" 3606msgid "Could not realloc() units\n"
4482msgstr "" 3607msgstr ""
4483 3608
4484#: plugins/check_snmp.c:889
4485msgid "Rate multiplier must be a positive integer" 3609msgid "Rate multiplier must be a positive integer"
4486msgstr "" 3610msgstr ""
4487 3611
4488#: plugins/check_snmp.c:947
4489msgid "No host specified\n" 3612msgid "No host specified\n"
4490msgstr "" 3613msgstr ""
4491 3614
4492#: plugins/check_snmp.c:951
4493msgid "No OIDs specified\n" 3615msgid "No OIDs specified\n"
4494msgstr "" 3616msgstr ""
4495 3617
4496#: plugins/check_snmp.c:973
4497msgid "Invalid seclevel"
4498msgstr ""
4499
4500#: plugins/check_snmp.c:980 plugins/check_snmp.c:983 plugins/check_snmp.c:1001
4501#, c-format 3618#, c-format
4502msgid "Required parameter: %s\n" 3619msgid "Required parameter: %s\n"
4503msgstr "" 3620msgstr ""
4504 3621
4505#: plugins/check_snmp.c:1022 3622msgid "Invalid seclevel"
3623msgstr ""
3624
4506msgid "Invalid SNMP version" 3625msgid "Invalid SNMP version"
4507msgstr "" 3626msgstr ""
4508 3627
4509#: plugins/check_snmp.c:1039
4510msgid "Unbalanced quotes\n" 3628msgid "Unbalanced quotes\n"
4511msgstr "" 3629msgstr ""
4512 3630
4513#: plugins/check_snmp.c:1088 3631#, c-format
3632msgid "multiplier set (%.1f), but input is not a number: %s"
3633msgstr ""
3634
4514msgid "Check status of remote machines and obtain system information via SNMP" 3635msgid "Check status of remote machines and obtain system information via SNMP"
4515msgstr "" 3636msgstr ""
4516 3637
4517#: plugins/check_snmp.c:1101
4518msgid "Use SNMP GETNEXT instead of SNMP GET" 3638msgid "Use SNMP GETNEXT instead of SNMP GET"
4519msgstr "" 3639msgstr ""
4520 3640
4521#: plugins/check_snmp.c:1103
4522msgid "SNMP protocol version" 3641msgid "SNMP protocol version"
4523msgstr "" 3642msgstr ""
4524 3643
4525#: plugins/check_snmp.c:1105 3644msgid "SNMPv3 context"
3645msgstr ""
3646
4526msgid "SNMPv3 securityLevel" 3647msgid "SNMPv3 securityLevel"
4527msgstr "" 3648msgstr ""
4528 3649
4529#: plugins/check_snmp.c:1107
4530msgid "SNMPv3 auth proto" 3650msgid "SNMPv3 auth proto"
4531msgstr "" 3651msgstr ""
4532 3652
4533#: plugins/check_snmp.c:1109
4534msgid "SNMPv3 priv proto (default DES)" 3653msgid "SNMPv3 priv proto (default DES)"
4535msgstr "" 3654msgstr ""
4536 3655
4537#: plugins/check_snmp.c:1113
4538msgid "Optional community string for SNMP communication" 3656msgid "Optional community string for SNMP communication"
4539msgstr "" 3657msgstr ""
4540 3658
4541#: plugins/check_snmp.c:1114
4542msgid "default is" 3659msgid "default is"
4543msgstr "" 3660msgstr ""
4544 3661
4545#: plugins/check_snmp.c:1116
4546msgid "SNMPv3 username" 3662msgid "SNMPv3 username"
4547msgstr "" 3663msgstr ""
4548 3664
4549#: plugins/check_snmp.c:1118
4550msgid "SNMPv3 authentication password" 3665msgid "SNMPv3 authentication password"
4551msgstr "" 3666msgstr ""
4552 3667
4553#: plugins/check_snmp.c:1120
4554msgid "SNMPv3 privacy password" 3668msgid "SNMPv3 privacy password"
4555msgstr "" 3669msgstr ""
4556 3670
4557#: plugins/check_snmp.c:1124
4558msgid "Object identifier(s) or SNMP variables whose value you wish to query" 3671msgid "Object identifier(s) or SNMP variables whose value you wish to query"
4559msgstr "" 3672msgstr ""
4560 3673
4561#: plugins/check_snmp.c:1126
4562msgid "" 3674msgid ""
4563"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'" 3675"List of MIBS to be loaded (default = none if using numeric OIDs or 'ALL'"
4564msgstr "" 3676msgstr ""
4565 3677
4566#: plugins/check_snmp.c:1127
4567msgid "for symbolic OIDs.)" 3678msgid "for symbolic OIDs.)"
4568msgstr "" 3679msgstr ""
4569 3680
4570#: plugins/check_snmp.c:1129
4571msgid "Delimiter to use when parsing returned data. Default is" 3681msgid "Delimiter to use when parsing returned data. Default is"
4572msgstr "" 3682msgstr ""
4573 3683
4574#: plugins/check_snmp.c:1130
4575msgid "Any data on the right hand side of the delimiter is considered" 3684msgid "Any data on the right hand side of the delimiter is considered"
4576msgstr "" 3685msgstr ""
4577 3686
4578#: plugins/check_snmp.c:1131
4579msgid "to be the data that should be used in the evaluation." 3687msgid "to be the data that should be used in the evaluation."
4580msgstr "" 3688msgstr ""
4581 3689
4582#: plugins/check_snmp.c:1135 3690msgid "If the check returns a 0 length string or NULL value"
3691msgstr ""
3692
3693msgid "This option allows you to choose what status you want it to exit"
3694msgstr ""
3695
3696msgid "Excluding this option renders the default exit of 3(STATE_UNKNOWN)"
3697msgstr ""
3698
3699msgid "0 = OK"
3700msgstr ""
3701
3702msgid "1 = WARNING"
3703msgstr ""
3704
3705msgid "2 = CRITICAL"
3706msgstr ""
3707
3708msgid "3 = UNKNOWN"
3709msgstr ""
3710
4583msgid "Warning threshold range(s)" 3711msgid "Warning threshold range(s)"
4584msgstr "" 3712msgstr ""
4585 3713
4586#: plugins/check_snmp.c:1137
4587msgid "Critical threshold range(s)" 3714msgid "Critical threshold range(s)"
4588msgstr "" 3715msgstr ""
4589 3716
4590#: plugins/check_snmp.c:1139
4591msgid "Enable rate calculation. See 'Rate Calculation' below" 3717msgid "Enable rate calculation. See 'Rate Calculation' below"
4592msgstr "" 3718msgstr ""
4593 3719
4594#: plugins/check_snmp.c:1141
4595msgid "" 3720msgid ""
4596"Converts rate per second. For example, set to 60 to convert to per minute" 3721"Converts rate per second. For example, set to 60 to convert to per minute"
4597msgstr "" 3722msgstr ""
4598 3723
4599#: plugins/check_snmp.c:1143 3724msgid "Add/subtract the specified OFFSET to numeric sensor data"
4600msgid "Add/substract the specified OFFSET to numeric sensor data"
4601msgstr "" 3725msgstr ""
4602 3726
4603#: plugins/check_snmp.c:1147
4604msgid "Return OK state (for that OID) if STRING is an exact match" 3727msgid "Return OK state (for that OID) if STRING is an exact match"
4605msgstr "" 3728msgstr ""
4606 3729
4607#: plugins/check_snmp.c:1149
4608msgid "" 3730msgid ""
4609"Return OK state (for that OID) if extended regular expression REGEX matches" 3731"Return OK state (for that OID) if extended regular expression REGEX matches"
4610msgstr "" 3732msgstr ""
4611 3733
4612#: plugins/check_snmp.c:1151
4613msgid "" 3734msgid ""
4614"Return OK state (for that OID) if case-insensitive extended REGEX matches" 3735"Return OK state (for that OID) if case-insensitive extended REGEX matches"
4615msgstr "" 3736msgstr ""
4616 3737
4617#: plugins/check_snmp.c:1153
4618msgid "Invert search result (CRITICAL if found)" 3738msgid "Invert search result (CRITICAL if found)"
4619msgstr "" 3739msgstr ""
4620 3740
4621#: plugins/check_snmp.c:1157
4622msgid "Prefix label for output from plugin" 3741msgid "Prefix label for output from plugin"
4623msgstr "" 3742msgstr ""
4624 3743
4625#: plugins/check_snmp.c:1159
4626msgid "Units label(s) for output data (e.g., 'sec.')." 3744msgid "Units label(s) for output data (e.g., 'sec.')."
4627msgstr "" 3745msgstr ""
4628 3746
4629#: plugins/check_snmp.c:1161
4630msgid "Separates output on multiple OID requests" 3747msgid "Separates output on multiple OID requests"
4631msgstr "" 3748msgstr ""
4632 3749
4633#: plugins/check_snmp.c:1165 3750msgid "Multiplies current value, 0 < n < 1 works as divider, defaults to 1"
4634msgid "Number of retries to be used in the requests" 3751msgstr ""
3752
3753msgid "C-style format string for float values (see option -M)"
3754msgstr ""
3755
3756msgid ""
3757"NOTE the final timeout value is calculated using this formula: "
3758"timeout_interval * retries + 5"
3759msgstr ""
3760
3761msgid "Number of retries to be used in the requests, default: "
4635msgstr "" 3762msgstr ""
4636 3763
4637#: plugins/check_snmp.c:1168
4638msgid "Label performance data with OIDs instead of --label's" 3764msgid "Label performance data with OIDs instead of --label's"
4639msgstr "" 3765msgstr ""
4640 3766
4641#: plugins/check_snmp.c:1173 3767msgid "Tell snmpget to not print errors encountered when parsing MIB files"
3768msgstr ""
3769
4642msgid "" 3770msgid ""
4643"This plugin uses the 'snmpget' command included with the NET-SNMP package." 3771"This plugin uses the 'snmpget' command included with the NET-SNMP package."
4644msgstr "" 3772msgstr ""
4645 3773
4646#: plugins/check_snmp.c:1174
4647msgid "" 3774msgid ""
4648"if you don't have the package installed, you will need to download it from" 3775"if you don't have the package installed, you will need to download it from"
4649msgstr "" 3776msgstr ""
4650 3777
4651#: plugins/check_snmp.c:1175
4652msgid "http://net-snmp.sourceforge.net before you can use this plugin." 3778msgid "http://net-snmp.sourceforge.net before you can use this plugin."
4653msgstr "" 3779msgstr ""
4654 3780
4655#: plugins/check_snmp.c:1179
4656msgid "" 3781msgid ""
4657"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited " 3782"- Multiple OIDs (and labels) may be indicated by a comma or space-delimited "
4658msgstr "" 3783msgstr ""
4659 3784
4660#: plugins/check_snmp.c:1180
4661msgid "list (lists with internal spaces must be quoted)." 3785msgid "list (lists with internal spaces must be quoted)."
4662msgstr "" 3786msgstr ""
4663 3787
4664#: plugins/check_snmp.c:1184
4665msgid "" 3788msgid ""
4666"- When checking multiple OIDs, separate ranges by commas like '-w " 3789"- When checking multiple OIDs, separate ranges by commas like '-w "
4667"1:10,1:,:20'" 3790"1:10,1:,:20'"
4668msgstr "" 3791msgstr ""
4669 3792
4670#: plugins/check_snmp.c:1185
4671msgid "- Note that only one string and one regex may be checked at present" 3793msgid "- Note that only one string and one regex may be checked at present"
4672msgstr "" 3794msgstr ""
4673 3795
4674#: plugins/check_snmp.c:1186
4675msgid "" 3796msgid ""
4676"- All evaluation methods other than PR, STR, and SUBSTR expect that the value" 3797"- All evaluation methods other than PR, STR, and SUBSTR expect that the value"
4677msgstr "" 3798msgstr ""
4678 3799
4679#: plugins/check_snmp.c:1187
4680msgid "returned from the SNMP query is an unsigned integer." 3800msgid "returned from the SNMP query is an unsigned integer."
4681msgstr "" 3801msgstr ""
4682 3802
4683#: plugins/check_snmp.c:1190
4684msgid "Rate Calculation:" 3803msgid "Rate Calculation:"
4685msgstr "" 3804msgstr ""
4686 3805
4687#: plugins/check_snmp.c:1191
4688msgid "In many places, SNMP returns counters that are only meaningful when" 3806msgid "In many places, SNMP returns counters that are only meaningful when"
4689msgstr "" 3807msgstr ""
4690 3808
4691#: plugins/check_snmp.c:1192
4692msgid "calculating the counter difference since the last check. check_snmp" 3809msgid "calculating the counter difference since the last check. check_snmp"
4693msgstr "" 3810msgstr ""
4694 3811
4695#: plugins/check_snmp.c:1193
4696msgid "saves the last state information in a file so that the rate per second" 3812msgid "saves the last state information in a file so that the rate per second"
4697msgstr "" 3813msgstr ""
4698 3814
4699#: plugins/check_snmp.c:1194
4700msgid "can be calculated. Use the --rate option to save state information." 3815msgid "can be calculated. Use the --rate option to save state information."
4701msgstr "" 3816msgstr ""
4702 3817
4703#: plugins/check_snmp.c:1195
4704msgid "" 3818msgid ""
4705"On the first run, there will be no prior state - this will return with OK." 3819"On the first run, there will be no prior state - this will return with OK."
4706msgstr "" 3820msgstr ""
4707 3821
4708#: plugins/check_snmp.c:1196
4709msgid "The state is uniquely determined by the arguments to the plugin, so" 3822msgid "The state is uniquely determined by the arguments to the plugin, so"
4710msgstr "" 3823msgstr ""
4711 3824
4712#: plugins/check_snmp.c:1197
4713msgid "changing the arguments will create a new state file." 3825msgid "changing the arguments will create a new state file."
4714msgstr "" 3826msgstr ""
4715 3827
4716#: plugins/check_ssh.c:165
4717msgid "Port number must be a positive integer" 3828msgid "Port number must be a positive integer"
4718msgstr "" 3829msgstr ""
4719 3830
4720#: plugins/check_ssh.c:232
4721#, c-format 3831#, c-format
4722msgid "Server answer: %s" 3832msgid "Server answer: %s"
4723msgstr "" 3833msgstr ""
4724 3834
4725#: plugins/check_ssh.c:251
4726#, c-format 3835#, c-format
4727msgid "SSH WARNING - %s (protocol %s) version mismatch, expected '%s'\n" 3836msgid "SSH CRITICAL - %s (protocol %s) version mismatch, expected '%s'\n"
3837msgstr ""
3838
3839#, c-format
3840msgid ""
3841"SSH CRITICAL - %s (protocol %s) protocol version mismatch, expected '%s'\n"
4728msgstr "" 3842msgstr ""
4729 3843
4730#: plugins/check_ssh.c:260
4731#, c-format 3844#, c-format
4732msgid "SSH OK - %s (protocol %s) | %s\n" 3845msgid "SSH OK - %s (protocol %s) | %s\n"
4733msgstr "" 3846msgstr ""
4734 3847
4735#: plugins/check_ssh.c:281
4736msgid "Try to connect to an SSH server at specified server and port" 3848msgid "Try to connect to an SSH server at specified server and port"
4737msgstr "" 3849msgstr ""
4738 3850
4739#: plugins/check_ssh.c:297
4740msgid "" 3851msgid ""
4741"Warn if string doesn't match expected server version (ex: OpenSSH_3.9p1)" 3852"Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)"
3853msgstr ""
3854
3855msgid "Alert if protocol doesn't match expected protocol version (ex: 2.0)"
4742msgstr "" 3856msgstr ""
4743 3857
4744#: plugins/check_swap.c:169
4745#, c-format 3858#, c-format
4746msgid "Command: %s\n" 3859msgid "Command: %s\n"
4747msgstr "" 3860msgstr ""
4748 3861
4749#: plugins/check_swap.c:171
4750#, c-format 3862#, c-format
4751msgid "Format: %s\n" 3863msgid "Format: %s\n"
4752msgstr "" 3864msgstr ""
4753 3865
4754#: plugins/check_swap.c:207
4755#, c-format 3866#, c-format
4756msgid "total=%.0f, used=%.0f, free=%.0f\n" 3867msgid "total=%.0f, used=%.0f, free=%.0f\n"
4757msgstr "" 3868msgstr ""
4758 3869
4759#: plugins/check_swap.c:221
4760#, c-format 3870#, c-format
4761msgid "total=%.0f, free=%.0f\n" 3871msgid "total=%.0f, free=%.0f\n"
4762msgstr "" 3872msgstr ""
4763 3873
4764#: plugins/check_swap.c:253
4765msgid "Error getting swap devices\n" 3874msgid "Error getting swap devices\n"
4766msgstr "" 3875msgstr ""
4767 3876
4768#: plugins/check_swap.c:256
4769msgid "SWAP OK: No swap devices defined\n" 3877msgid "SWAP OK: No swap devices defined\n"
4770msgstr "" 3878msgstr ""
4771 3879
4772#: plugins/check_swap.c:277 plugins/check_swap.c:319
4773msgid "swapctl failed: " 3880msgid "swapctl failed: "
4774msgstr "" 3881msgstr ""
4775 3882
4776#: plugins/check_swap.c:278 plugins/check_swap.c:320
4777msgid "Error in swapctl call\n" 3883msgid "Error in swapctl call\n"
4778msgstr "" 3884msgstr ""
4779 3885
4780#: plugins/check_swap.c:357
4781#, c-format 3886#, c-format
4782msgid "SWAP %s - %d%% free (%d MB out of %d MB) %s|" 3887msgid "SWAP %s - %d%% free (%dMB out of %dMB) %s|"
4783msgstr "" 3888msgstr ""
4784 3889
4785#: plugins/check_swap.c:435 3890msgid "Warning threshold percentage must be <= 100!"
4786msgid "Warning threshold must be integer or percentage!"
4787msgstr "" 3891msgstr ""
4788 3892
4789#: plugins/check_swap.c:453 3893msgid "Warning threshold be positive integer or percentage!"
4790msgid "Critical threshold must be integer or percentage!"
4791msgstr "" 3894msgstr ""
4792 3895
4793#: plugins/check_swap.c:507 3896msgid "Critical threshold percentage must be <= 100!"
4794msgid "Warning percentage should be more than critical percentage"
4795msgstr "" 3897msgstr ""
4796 3898
4797#: plugins/check_swap.c:511 3899msgid "Critical threshold be positive integer or percentage!"
4798msgid "Warning free space should be more than critical free space" 3900msgstr ""
3901
3902msgid ""
3903"no-swap result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
3904"or integer (0-3)."
3905msgstr ""
3906
3907msgid "Warning should be more than critical"
4799msgstr "" 3908msgstr ""
4800 3909
4801#: plugins/check_swap.c:525
4802msgid "Check swap space on local machine." 3910msgid "Check swap space on local machine."
4803msgstr "" 3911msgstr ""
4804 3912
4805#: plugins/check_swap.c:535
4806msgid "" 3913msgid ""
4807"Exit with WARNING status if less than INTEGER bytes of swap space are free" 3914"Exit with WARNING status if less than INTEGER bytes of swap space are free"
4808msgstr "" 3915msgstr ""
4809 3916
4810#: plugins/check_swap.c:537
4811msgid "Exit with WARNING status if less than PERCENT of swap space is free" 3917msgid "Exit with WARNING status if less than PERCENT of swap space is free"
4812msgstr "" 3918msgstr ""
4813 3919
4814#: plugins/check_swap.c:539
4815msgid "" 3920msgid ""
4816"Exit with CRITICAL status if less than INTEGER bytes of swap space are free" 3921"Exit with CRITICAL status if less than INTEGER bytes of swap space are free"
4817msgstr "" 3922msgstr ""
4818 3923
4819#: plugins/check_swap.c:541 3924msgid "Exit with CRITICAL status if less than PERCENT of swap space is free"
4820msgid "Exit with CRITCAL status if less than PERCENT of swap space is free"
4821msgstr "" 3925msgstr ""
4822 3926
4823#: plugins/check_swap.c:543
4824msgid "Conduct comparisons for all swap partitions, one by one" 3927msgid "Conduct comparisons for all swap partitions, one by one"
4825msgstr "" 3928msgstr ""
4826 3929
4827#: plugins/check_swap.c:548 3930msgid ""
3931"Resulting state when there is no swap regardless of thresholds. Default:"
3932msgstr ""
3933
3934msgid ""
3935"Both INTEGER and PERCENT thresholds can be specified, they are all checked."
3936msgstr ""
3937
4828msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s." 3938msgid "On AIX, if -a is specified, uses lsps -a, otherwise uses lsps -s."
4829msgstr "" 3939msgstr ""
4830 3940
4831#: plugins/check_tcp.c:206
4832msgid "CRITICAL - Generic check_tcp called with unknown service\n" 3941msgid "CRITICAL - Generic check_tcp called with unknown service\n"
4833msgstr "" 3942msgstr ""
4834 3943
4835#: plugins/check_tcp.c:230
4836msgid "With UDP checks, a send/expect string must be specified." 3944msgid "With UDP checks, a send/expect string must be specified."
4837msgstr "" 3945msgstr ""
4838 3946
4839#: plugins/check_tcp.c:431
4840msgid "No arguments found" 3947msgid "No arguments found"
4841msgstr "" 3948msgstr ""
4842 3949
4843#: plugins/check_tcp.c:534
4844msgid "Maxbytes must be a positive integer" 3950msgid "Maxbytes must be a positive integer"
4845msgstr "" 3951msgstr ""
4846 3952
4847#: plugins/check_tcp.c:552
4848msgid "Refuse must be one of ok, warn, crit" 3953msgid "Refuse must be one of ok, warn, crit"
4849msgstr "" 3954msgstr ""
4850 3955
4851#: plugins/check_tcp.c:562
4852msgid "Mismatch must be one of ok, warn, crit" 3956msgid "Mismatch must be one of ok, warn, crit"
4853msgstr "" 3957msgstr ""
4854 3958
4855#: plugins/check_tcp.c:568
4856msgid "Delay must be a positive integer" 3959msgid "Delay must be a positive integer"
4857msgstr "" 3960msgstr ""
4858 3961
4859#: plugins/check_tcp.c:613
4860msgid "You must provide a server address" 3962msgid "You must provide a server address"
4861msgstr "" 3963msgstr ""
4862 3964
4863#: plugins/check_tcp.c:615
4864msgid "Invalid hostname, address or socket" 3965msgid "Invalid hostname, address or socket"
4865msgstr "" 3966msgstr ""
4866 3967
4867#: plugins/check_tcp.c:629
4868#, c-format 3968#, c-format
4869msgid "" 3969msgid ""
4870"This plugin tests %s connections with the specified host (or unix socket).\n" 3970"This plugin tests %s connections with the specified host (or unix socket).\n"
4871"\n" 3971"\n"
4872msgstr "" 3972msgstr ""
4873 3973
4874#: plugins/check_tcp.c:642
4875msgid "" 3974msgid ""
4876"Can use \\n, \\r, \\t or \\ in send or quit string. Must come before send or " 3975"Can use \\n, \\r, \\t or \\\\ in send or quit string. Must come before send "
4877"quit option" 3976"or quit option"
4878msgstr "" 3977msgstr ""
4879 3978
4880#: plugins/check_tcp.c:643
4881msgid "Default: nothing added to send, \\r\\n added to end of quit" 3979msgid "Default: nothing added to send, \\r\\n added to end of quit"
4882msgstr "" 3980msgstr ""
4883 3981
4884#: plugins/check_tcp.c:645
4885msgid "String to send to the server" 3982msgid "String to send to the server"
4886msgstr "" 3983msgstr ""
4887 3984
4888#: plugins/check_tcp.c:647
4889msgid "String to expect in server response" 3985msgid "String to expect in server response"
4890msgstr "" 3986msgstr ""
4891 3987
4892#: plugins/check_tcp.c:647
4893msgid "(may be repeated)" 3988msgid "(may be repeated)"
4894msgstr "" 3989msgstr ""
4895 3990
4896#: plugins/check_tcp.c:649
4897msgid "All expect strings need to occur in server response. Default is any" 3991msgid "All expect strings need to occur in server response. Default is any"
4898msgstr "" 3992msgstr ""
4899 3993
4900#: plugins/check_tcp.c:651
4901msgid "String to send server to initiate a clean close of the connection" 3994msgid "String to send server to initiate a clean close of the connection"
4902msgstr "" 3995msgstr ""
4903 3996
4904#: plugins/check_tcp.c:653
4905msgid "Accept TCP refusals with states ok, warn, crit (default: crit)" 3997msgid "Accept TCP refusals with states ok, warn, crit (default: crit)"
4906msgstr "" 3998msgstr ""
4907 3999
4908#: plugins/check_tcp.c:655
4909msgid "" 4000msgid ""
4910"Accept expected string mismatches with states ok, warn, crit (default: warn)" 4001"Accept expected string mismatches with states ok, warn, crit (default: warn)"
4911msgstr "" 4002msgstr ""
4912 4003
4913#: plugins/check_tcp.c:657
4914msgid "Hide output from TCP socket" 4004msgid "Hide output from TCP socket"
4915msgstr "" 4005msgstr ""
4916 4006
4917#: plugins/check_tcp.c:659
4918msgid "Close connection once more than this number of bytes are received" 4007msgid "Close connection once more than this number of bytes are received"
4919msgstr "" 4008msgstr ""
4920 4009
4921#: plugins/check_tcp.c:661
4922msgid "Seconds to wait between sending string and polling for response" 4010msgid "Seconds to wait between sending string and polling for response"
4923msgstr "" 4011msgstr ""
4924 4012
4925#: plugins/check_tcp.c:666
4926msgid "1st is #days for warning, 2nd is critical (if not specified - 0)." 4013msgid "1st is #days for warning, 2nd is critical (if not specified - 0)."
4927msgstr "" 4014msgstr ""
4928 4015
4929#: plugins/check_tcp.c:668
4930msgid "Use SSL for the connection." 4016msgid "Use SSL for the connection."
4931msgstr "" 4017msgstr ""
4932 4018
4933#: plugins/check_time.c:102 4019msgid "SSL server_name"
4020msgstr ""
4021
4934#, c-format 4022#, c-format
4935msgid "TIME UNKNOWN - could not connect to server %s, port %d\n" 4023msgid "TIME UNKNOWN - could not connect to server %s, port %d\n"
4936msgstr "" 4024msgstr ""
4937 4025
4938#: plugins/check_time.c:115
4939#, c-format 4026#, c-format
4940msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n" 4027msgid "TIME UNKNOWN - could not send UDP request to server %s, port %d\n"
4941msgstr "" 4028msgstr ""
4942 4029
4943#: plugins/check_time.c:139
4944#, c-format 4030#, c-format
4945msgid "TIME UNKNOWN - no data received from server %s, port %d\n" 4031msgid "TIME UNKNOWN - no data received from server %s, port %d\n"
4946msgstr "" 4032msgstr ""
4947 4033
4948#: plugins/check_time.c:152
4949#, c-format 4034#, c-format
4950msgid "TIME %s - %d second response time|%s\n" 4035msgid "TIME %s - %d second response time|%s\n"
4951msgstr "" 4036msgstr ""
4952 4037
4953#: plugins/check_time.c:170
4954#, c-format 4038#, c-format
4955msgid "TIME %s - %lu second time difference|%s %s\n" 4039msgid "TIME %s - %lu second time difference|%s %s\n"
4956msgstr "" 4040msgstr ""
4957 4041
4958#: plugins/check_time.c:254
4959msgid "Warning thresholds must be a positive integer" 4042msgid "Warning thresholds must be a positive integer"
4960msgstr "" 4043msgstr ""
4961 4044
4962#: plugins/check_time.c:273
4963msgid "Critical thresholds must be a positive integer" 4045msgid "Critical thresholds must be a positive integer"
4964msgstr "" 4046msgstr ""
4965 4047
4966#: plugins/check_time.c:339
4967msgid "This plugin will check the time on the specified host." 4048msgid "This plugin will check the time on the specified host."
4968msgstr "" 4049msgstr ""
4969 4050
4970#: plugins/check_time.c:351
4971msgid "Use UDP to connect, not TCP" 4051msgid "Use UDP to connect, not TCP"
4972msgstr "" 4052msgstr ""
4973 4053
4974#: plugins/check_time.c:353
4975msgid "Time difference (sec.) necessary to result in a warning status" 4054msgid "Time difference (sec.) necessary to result in a warning status"
4976msgstr "" 4055msgstr ""
4977 4056
4978#: plugins/check_time.c:355
4979msgid "Time difference (sec.) necessary to result in a critical status" 4057msgid "Time difference (sec.) necessary to result in a critical status"
4980msgstr "" 4058msgstr ""
4981 4059
4982#: plugins/check_time.c:357
4983msgid "Response time (sec.) necessary to result in warning status" 4060msgid "Response time (sec.) necessary to result in warning status"
4984msgstr "" 4061msgstr ""
4985 4062
4986#: plugins/check_time.c:359
4987msgid "Response time (sec.) necessary to result in critical status" 4063msgid "Response time (sec.) necessary to result in critical status"
4988msgstr "" 4064msgstr ""
4989 4065
4990#: plugins/check_ups.c:144
4991msgid "On Battery, Low Battery" 4066msgid "On Battery, Low Battery"
4992msgstr "" 4067msgstr ""
4993 4068
4994#: plugins/check_ups.c:149
4995msgid "Online" 4069msgid "Online"
4996msgstr "" 4070msgstr ""
4997 4071
4998#: plugins/check_ups.c:152
4999msgid "On Battery" 4072msgid "On Battery"
5000msgstr "" 4073msgstr ""
5001 4074
5002#: plugins/check_ups.c:156
5003msgid ", Low Battery" 4075msgid ", Low Battery"
5004msgstr "" 4076msgstr ""
5005 4077
5006#: plugins/check_ups.c:160
5007msgid ", Calibrating" 4078msgid ", Calibrating"
5008msgstr "" 4079msgstr ""
5009 4080
5010#: plugins/check_ups.c:163
5011msgid ", Replace Battery" 4081msgid ", Replace Battery"
5012msgstr "" 4082msgstr ""
5013 4083
5014#: plugins/check_ups.c:167
5015msgid ", On Bypass" 4084msgid ", On Bypass"
5016msgstr "" 4085msgstr ""
5017 4086
5018#: plugins/check_ups.c:170
5019msgid ", Overload" 4087msgid ", Overload"
5020msgstr "" 4088msgstr ""
5021 4089
5022#: plugins/check_ups.c:173
5023msgid ", Trimming" 4090msgid ", Trimming"
5024msgstr "" 4091msgstr ""
5025 4092
5026#: plugins/check_ups.c:176
5027msgid ", Boosting" 4093msgid ", Boosting"
5028msgstr "" 4094msgstr ""
5029 4095
5030#: plugins/check_ups.c:179
5031msgid ", Charging" 4096msgid ", Charging"
5032msgstr "" 4097msgstr ""
5033 4098
5034#: plugins/check_ups.c:182
5035msgid ", Discharging" 4099msgid ", Discharging"
5036msgstr "" 4100msgstr ""
5037 4101
5038#: plugins/check_ups.c:185
5039msgid ", Unknown" 4102msgid ", Unknown"
5040msgstr "" 4103msgstr ""
5041 4104
5042#: plugins/check_ups.c:324
5043msgid "UPS does not support any available options\n" 4105msgid "UPS does not support any available options\n"
5044msgstr "" 4106msgstr ""
5045 4107
5046#: plugins/check_ups.c:348 plugins/check_ups.c:411
5047msgid "Invalid response received from host" 4108msgid "Invalid response received from host"
5048msgstr "" 4109msgstr ""
5049 4110
5050#: plugins/check_ups.c:420 4111msgid "UPS name to long for buffer"
4112msgstr ""
4113
5051#, c-format 4114#, c-format
5052msgid "CRITICAL - no such UPS '%s' on that host\n" 4115msgid "CRITICAL - no such UPS '%s' on that host\n"
5053msgstr "" 4116msgstr ""
5054 4117
5055#: plugins/check_ups.c:430
5056msgid "CRITICAL - UPS data is stale" 4118msgid "CRITICAL - UPS data is stale"
5057msgstr "" 4119msgstr ""
5058 4120
5059#: plugins/check_ups.c:435
5060#, c-format 4121#, c-format
5061msgid "Unknown error: %s\n" 4122msgid "Unknown error: %s\n"
5062msgstr "" 4123msgstr ""
5063 4124
5064#: plugins/check_ups.c:442
5065msgid "Error: unable to parse variable" 4125msgid "Error: unable to parse variable"
5066msgstr "" 4126msgstr ""
5067 4127
5068#: plugins/check_ups.c:549
5069msgid "Unrecognized UPS variable" 4128msgid "Unrecognized UPS variable"
5070msgstr "" 4129msgstr ""
5071 4130
5072#: plugins/check_ups.c:587
5073msgid "Error : no UPS indicated" 4131msgid "Error : no UPS indicated"
5074msgstr "" 4132msgstr ""
5075 4133
5076#: plugins/check_ups.c:607
5077msgid "" 4134msgid ""
5078"This plugin tests the UPS service on the specified host. Network UPS Tools" 4135"This plugin tests the UPS service on the specified host. Network UPS Tools"
5079msgstr "" 4136msgstr ""
5080 4137
5081#: plugins/check_ups.c:608
5082msgid "from www.networkupstools.org must be running for this plugin to work." 4138msgid "from www.networkupstools.org must be running for this plugin to work."
5083msgstr "" 4139msgstr ""
5084 4140
5085#: plugins/check_ups.c:620
5086msgid "Name of UPS" 4141msgid "Name of UPS"
5087msgstr "" 4142msgstr ""
5088 4143
5089#: plugins/check_ups.c:622
5090msgid "Output of temperatures in Celsius" 4144msgid "Output of temperatures in Celsius"
5091msgstr "" 4145msgstr ""
5092 4146
5093#: plugins/check_ups.c:624
5094msgid "Valid values for STRING are" 4147msgid "Valid values for STRING are"
5095msgstr "" 4148msgstr ""
5096 4149
5097#: plugins/check_ups.c:635
5098msgid "" 4150msgid ""
5099"This plugin attempts to determine the status of a UPS (Uninterruptible Power" 4151"This plugin attempts to determine the status of a UPS (Uninterruptible Power"
5100msgstr "" 4152msgstr ""
5101 4153
5102#: plugins/check_ups.c:636
5103msgid "" 4154msgid ""
5104"Supply) on a local or remote host. If the UPS is online or calibrating, the" 4155"Supply) on a local or remote host. If the UPS is online or calibrating, the"
5105msgstr "" 4156msgstr ""
5106 4157
5107#: plugins/check_ups.c:637
5108msgid "" 4158msgid ""
5109"plugin will return an OK state. If the battery is on it will return a WARNING" 4159"plugin will return an OK state. If the battery is on it will return a WARNING"
5110msgstr "" 4160msgstr ""
5111 4161
5112#: plugins/check_ups.c:638
5113msgid "" 4162msgid ""
5114"state. If the UPS is off or has a low battery the plugin will return a " 4163"state. If the UPS is off or has a low battery the plugin will return a "
5115"CRITICAL" 4164"CRITICAL"
5116msgstr "" 4165msgstr ""
5117 4166
5118#: plugins/check_ups.c:643
5119msgid "" 4167msgid ""
5120"You may also specify a variable to check (such as temperature, utility " 4168"You may also specify a variable to check (such as temperature, utility "
5121"voltage," 4169"voltage,"
5122msgstr "" 4170msgstr ""
5123 4171
5124#: plugins/check_ups.c:644
5125msgid "" 4172msgid ""
5126"battery load, etc.) as well as warning and critical thresholds for the value" 4173"battery load, etc.) as well as warning and critical thresholds for the value"
5127msgstr "" 4174msgstr ""
5128 4175
5129#: plugins/check_ups.c:645
5130msgid "" 4176msgid ""
5131"of that variable. If the remote host has multiple UPS that are being " 4177"of that variable. If the remote host has multiple UPS that are being "
5132"monitored" 4178"monitored"
5133msgstr "" 4179msgstr ""
5134 4180
5135#: plugins/check_ups.c:646
5136msgid "you will have to use the --ups option to specify which UPS to check." 4181msgid "you will have to use the --ups option to specify which UPS to check."
5137msgstr "" 4182msgstr ""
5138 4183
5139#: plugins/check_ups.c:648
5140msgid "" 4184msgid ""
5141"This plugin requires that the UPSD daemon distributed with Russell Kroll's" 4185"This plugin requires that the UPSD daemon distributed with Russell Kroll's"
5142msgstr "" 4186msgstr ""
5143 4187
5144#: plugins/check_ups.c:649
5145msgid "" 4188msgid ""
5146"Network UPS Tools be installed on the remote host. If you do not have the" 4189"Network UPS Tools be installed on the remote host. If you do not have the"
5147msgstr "" 4190msgstr ""
5148 4191
5149#: plugins/check_ups.c:650
5150msgid "package installed on your system, you can download it from" 4192msgid "package installed on your system, you can download it from"
5151msgstr "" 4193msgstr ""
5152 4194
5153#: plugins/check_ups.c:651
5154msgid "http://www.networkupstools.org" 4195msgid "http://www.networkupstools.org"
5155msgstr "" 4196msgstr ""
5156 4197
5157#: plugins/check_users.c:110 4198#, c-format
4199msgid "Could not enumerate RD sessions: %d\n"
4200msgstr ""
4201
5158#, c-format 4202#, c-format
5159msgid "# users=%d" 4203msgid "# users=%d"
5160msgstr "" 4204msgstr ""
5161 4205
5162#: plugins/check_users.c:133
5163msgid "Unable to read output" 4206msgid "Unable to read output"
5164msgstr "" 4207msgstr ""
5165 4208
5166#: plugins/check_users.c:140
5167#, c-format 4209#, c-format
5168msgid "USERS %s - %d users currently logged in |%s\n" 4210msgid "USERS %s - %d users currently logged in |%s\n"
5169msgstr "" 4211msgstr ""
5170 4212
5171#: plugins/check_users.c:219
5172msgid "This plugin checks the number of users currently logged in on the local" 4213msgid "This plugin checks the number of users currently logged in on the local"
5173msgstr "" 4214msgstr ""
5174 4215
5175#: plugins/check_users.c:220
5176msgid "" 4216msgid ""
5177"system and generates an error if the number exceeds the thresholds specified." 4217"system and generates an error if the number exceeds the thresholds specified."
5178msgstr "" 4218msgstr ""
5179 4219
5180#: plugins/check_users.c:230
5181msgid "Set WARNING status if more than INTEGER users are logged in" 4220msgid "Set WARNING status if more than INTEGER users are logged in"
5182msgstr "" 4221msgstr ""
5183 4222
5184#: plugins/check_users.c:232
5185msgid "Set CRITICAL status if more than INTEGER users are logged in" 4223msgid "Set CRITICAL status if more than INTEGER users are logged in"
5186msgstr "" 4224msgstr ""
5187 4225
5188#: plugins/check_ide_smart.c:256 4226msgid ""
4227"DEPRECATION WARNING: the -q switch (quiet output) is no longer \"quiet\"."
4228msgstr ""
4229
4230msgid "Nagios-compatible output is now always returned."
4231msgstr ""
4232
4233msgid "SMART commands are broken and have been disabled (See Notes in --help)."
4234msgstr ""
4235
4236msgid ""
4237"DEPRECATION WARNING: the -n switch (Nagios-compatible output) is now the"
4238msgstr ""
4239
4240msgid "default and will be removed from future releases."
4241msgstr ""
4242
5189#, c-format 4243#, c-format
5190msgid "CRITICAL - Couldn't open device %s: %s\n" 4244msgid "CRITICAL - Couldn't open device %s: %s\n"
5191msgstr "" 4245msgstr ""
5192 4246
5193#: plugins/check_ide_smart.c:261
5194#, c-format 4247#, c-format
5195msgid "CRITICAL - SMART_CMD_ENABLE\n" 4248msgid "CRITICAL - SMART_CMD_ENABLE\n"
5196msgstr "" 4249msgstr ""
5197 4250
5198#: plugins/check_ide_smart.c:323 plugins/check_ide_smart.c:350
5199#, c-format 4251#, c-format
5200msgid "CRITICAL - SMART_READ_VALUES: %s\n" 4252msgid "CRITICAL - SMART_READ_VALUES: %s\n"
5201msgstr "" 4253msgstr ""
5202 4254
5203#: plugins/check_ide_smart.c:421
5204#, c-format 4255#, c-format
5205msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n" 4256msgid "CRITICAL - %d Harddrive PreFailure%cDetected! %d/%d tests failed.\n"
5206msgstr "" 4257msgstr ""
5207 4258
5208#: plugins/check_ide_smart.c:429
5209#, c-format 4259#, c-format
5210msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n" 4260msgid "WARNING - %d Harddrive Advisor%s Detected. %d/%d tests failed.\n"
5211msgstr "" 4261msgstr ""
5212 4262
5213#: plugins/check_ide_smart.c:437
5214#, c-format 4263#, c-format
5215msgid "OK - Operational (%d/%d tests passed)\n" 4264msgid "OK - Operational (%d/%d tests passed)\n"
5216msgstr "" 4265msgstr ""
5217 4266
5218#: plugins/check_ide_smart.c:441
5219#, c-format 4267#, c-format
5220msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n" 4268msgid "ERROR - Status '%d' unknown. %d/%d tests passed\n"
5221msgstr "" 4269msgstr ""
5222 4270
5223#: plugins/check_ide_smart.c:474
5224#, c-format 4271#, c-format
5225msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n" 4272msgid "OffLineStatus=%d {%s}, AutoOffLine=%s, OffLineTimeout=%d minutes\n"
5226msgstr "" 4273msgstr ""
5227 4274
5228#: plugins/check_ide_smart.c:480
5229#, c-format 4275#, c-format
5230msgid "OffLineCapability=%d {%s %s %s}\n" 4276msgid "OffLineCapability=%d {%s %s %s}\n"
5231msgstr "" 4277msgstr ""
5232 4278
5233#: plugins/check_ide_smart.c:486
5234#, c-format 4279#, c-format
5235msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n" 4280msgid "SmartRevision=%d, CheckSum=%d, SmartCapability=%d {%s %s}\n"
5236msgstr "" 4281msgstr ""
5237 4282
5238#: plugins/check_ide_smart.c:508 plugins/check_ide_smart.c:532
5239#, c-format 4283#, c-format
5240msgid "CRITICAL - %s: %s\n" 4284msgid "CRITICAL - %s: %s\n"
5241msgstr "" 4285msgstr ""
5242 4286
5243#: plugins/check_ide_smart.c:553 plugins/check_ide_smart.c:580 4287#, c-format
4288msgid "OK - Command sent (%s)\n"
4289msgstr ""
4290
5244#, c-format 4291#, c-format
5245msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n" 4292msgid "CRITICAL - SMART_READ_THRESHOLDS: %s\n"
5246msgstr "" 4293msgstr ""
5247 4294
5248#: plugins/check_ide_smart.c:599
5249#, c-format 4295#, c-format
5250msgid "" 4296msgid ""
5251"This plugin checks a local hard drive with the (Linux specific) SMART " 4297"This plugin checks a local hard drive with the (Linux specific) SMART "
5252"interface [http://smartlinux.sourceforge.net/smart/index.php]." 4298"interface [http://smartlinux.sourceforge.net/smart/index.php]."
5253msgstr "" 4299msgstr ""
5254 4300
5255#: plugins/check_ide_smart.c:609
5256msgid "Select device DEVICE" 4301msgid "Select device DEVICE"
5257msgstr "" 4302msgstr ""
5258 4303
5259#: plugins/check_ide_smart.c:610
5260msgid "" 4304msgid ""
5261"Note: if the device is selected with this option, _no_ other options are " 4305"Note: if the device is specified without this option, any further option will"
5262"accepted" 4306msgstr ""
4307
4308msgid "be ignored."
4309msgstr ""
4310
4311msgid ""
4312"The SMART command modes (-i/--immediate, -0/--auto-off and -1/--auto-on) were"
5263msgstr "" 4313msgstr ""
5264 4314
5265#: plugins/check_ide_smart.c:612 4315msgid ""
5266msgid "Perform immediately offline tests" 4316"broken in an underhand manner and have been disabled. You can use smartctl"
5267msgstr "" 4317msgstr ""
5268 4318
5269#: plugins/check_ide_smart.c:614 4319msgid "instead:"
5270msgid "Returns the number of failed tests"
5271msgstr "" 4320msgstr ""
5272 4321
5273#: plugins/check_ide_smart.c:616 4322msgid "-0/--auto-off: use \"smartctl --offlineauto=off\""
5274msgid "Turn on automatic offline tests"
5275msgstr "" 4323msgstr ""
5276 4324
5277#: plugins/check_ide_smart.c:618 4325msgid "-1/--auto-on: use \"smartctl --offlineauto=on\""
5278msgid "Turn off automatic offline tests"
5279msgstr "" 4326msgstr ""
5280 4327
5281#: plugins/check_ide_smart.c:620 4328msgid "-i/--immediate: use \"smartctl --test=offline\""
5282msgid "Output suitable for the monitoring system"
5283msgstr "" 4329msgstr ""
5284 4330
5285#: plugins/negate.c:99
5286msgid "No data returned from command\n" 4331msgid "No data returned from command\n"
5287msgstr "" 4332msgstr ""
5288 4333
5289#: plugins/negate.c:170
5290msgid "" 4334msgid ""
5291"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) " 4335"Timeout result must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) "
5292"or integer (0-3)." 4336"or integer (0-3)."
5293msgstr "" 4337msgstr ""
5294 4338
5295#: plugins/negate.c:174
5296msgid "" 4339msgid ""
5297"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer " 4340"Ok must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or integer "
5298"(0-3)." 4341"(0-3)."
5299msgstr "" 4342msgstr ""
5300 4343
5301#: plugins/negate.c:180
5302msgid "" 4344msgid ""
5303"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4345"Warning must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5304"integer (0-3)." 4346"integer (0-3)."
5305msgstr "" 4347msgstr ""
5306 4348
5307#: plugins/negate.c:185
5308msgid "" 4349msgid ""
5309"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4350"Critical must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5310"integer (0-3)." 4351"integer (0-3)."
5311msgstr "" 4352msgstr ""
5312 4353
5313#: plugins/negate.c:190
5314msgid "" 4354msgid ""
5315"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or " 4355"Unknown must be a valid state name (OK, WARNING, CRITICAL, UNKNOWN) or "
5316"integer (0-3)." 4356"integer (0-3)."
5317msgstr "" 4357msgstr ""
5318 4358
5319#: plugins/negate.c:217
5320msgid "Require path to command" 4359msgid "Require path to command"
5321msgstr "" 4360msgstr ""
5322 4361
5323#: plugins/negate.c:246
5324msgid "" 4362msgid ""
5325"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)." 4363"Negates the status of a plugin (returns OK for CRITICAL and vice-versa)."
5326msgstr "" 4364msgstr ""
5327 4365
5328#: plugins/negate.c:247
5329msgid "Additional switches can be used to control which state becomes what." 4366msgid "Additional switches can be used to control which state becomes what."
5330msgstr "" 4367msgstr ""
5331 4368
5332#: plugins/negate.c:256
5333msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status." 4369msgid "Keep timeout longer than the plugin timeout to retain CRITICAL status."
5334msgstr "" 4370msgstr ""
5335 4371
5336#: plugins/negate.c:258
5337msgid "Custom result on Negate timeouts; see below for STATUS definition\n" 4372msgid "Custom result on Negate timeouts; see below for STATUS definition\n"
5338msgstr "" 4373msgstr ""
5339 4374
5340#: plugins/negate.c:264
5341#, c-format 4375#, c-format
5342msgid "" 4376msgid ""
5343" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n" 4377" STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single\n"
5344msgstr "" 4378msgstr ""
5345 4379
5346#: plugins/negate.c:265
5347#, c-format 4380#, c-format
5348msgid "" 4381msgid ""
5349" quotes. Numeric values are accepted. If nothing is specified, permutes\n" 4382" quotes. Numeric values are accepted. If nothing is specified, permutes\n"
5350msgstr "" 4383msgstr ""
5351 4384
5352#: plugins/negate.c:266
5353#, c-format 4385#, c-format
5354msgid " OK and CRITICAL.\n" 4386msgid " OK and CRITICAL.\n"
5355msgstr "" 4387msgstr ""
5356 4388
5357#: plugins/negate.c:268
5358#, c-format 4389#, c-format
5359msgid "" 4390msgid ""
5360" Substitute output text as well. Will only substitute text in CAPITALS\n" 4391" Substitute output text as well. Will only substitute text in CAPITALS\n"
5361msgstr "" 4392msgstr ""
5362 4393
5363#: plugins/negate.c:273
5364msgid "Run check_ping and invert result. Must use full path to plugin" 4394msgid "Run check_ping and invert result. Must use full path to plugin"
5365msgstr "" 4395msgstr ""
5366 4396
5367#: plugins/negate.c:275
5368msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL" 4397msgid "This will return OK instead of WARNING and UNKNOWN instead of CRITICAL"
5369msgstr "" 4398msgstr ""
5370 4399
5371#: plugins/negate.c:278
5372msgid "" 4400msgid ""
5373"This plugin is a wrapper to take the output of another plugin and invert it." 4401"This plugin is a wrapper to take the output of another plugin and invert it."
5374msgstr "" 4402msgstr ""
5375 4403
5376#: plugins/negate.c:279
5377msgid "The full path of the plugin must be provided." 4404msgid "The full path of the plugin must be provided."
5378msgstr "" 4405msgstr ""
5379 4406
5380#: plugins/negate.c:280
5381msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL." 4407msgid "If the wrapped plugin returns OK, the wrapper will return CRITICAL."
5382msgstr "" 4408msgstr ""
5383 4409
5384#: plugins/negate.c:281
5385msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK." 4410msgid "If the wrapped plugin returns CRITICAL, the wrapper will return OK."
5386msgstr "" 4411msgstr ""
5387 4412
5388#: plugins/negate.c:282
5389msgid "Otherwise, the output state of the wrapped plugin is unchanged." 4413msgid "Otherwise, the output state of the wrapped plugin is unchanged."
5390msgstr "" 4414msgstr ""
5391 4415
5392#: plugins/negate.c:284
5393msgid "" 4416msgid ""
5394"Using timeout-result, it is possible to override the timeout behaviour or a" 4417"Using timeout-result, it is possible to override the timeout behaviour or a"
5395msgstr "" 4418msgstr ""
5396 4419
5397#: plugins/negate.c:285
5398msgid "plugin by setting the negate timeout a bit lower." 4420msgid "plugin by setting the negate timeout a bit lower."
5399msgstr "" 4421msgstr ""
5400 4422
5401#: plugins/netutils.c:49
5402#, c-format 4423#, c-format
5403msgid "%s - Socket timeout after %d seconds\n" 4424msgid "%s - Socket timeout after %d seconds\n"
5404msgstr "" 4425msgstr ""
5405 4426
5406#: plugins/netutils.c:51
5407#, c-format 4427#, c-format
5408msgid "%s - Abnormal timeout after %d seconds\n" 4428msgid "%s - Abnormal timeout after %d seconds\n"
5409msgstr "" 4429msgstr ""
5410 4430
5411#: plugins/netutils.c:79 plugins/netutils.c:281
5412msgid "Send failed" 4431msgid "Send failed"
5413msgstr "" 4432msgstr ""
5414 4433
5415#: plugins/netutils.c:96 plugins/netutils.c:296
5416msgid "No data was received from host!" 4434msgid "No data was received from host!"
5417msgstr "" 4435msgstr ""
5418 4436
5419#: plugins/netutils.c:204 plugins/netutils.c:240
5420msgid "Socket creation failed" 4437msgid "Socket creation failed"
5421msgstr "" 4438msgstr ""
5422 4439
5423#: plugins/netutils.c:233
5424msgid "Supplied path too long unix domain socket" 4440msgid "Supplied path too long unix domain socket"
5425msgstr "" 4441msgstr ""
5426 4442
5427#: plugins/netutils.c:305
5428msgid "Receive failed" 4443msgid "Receive failed"
5429msgstr "" 4444msgstr ""
5430 4445
5431#: plugins/netutils.c:331 plugins-root/check_dhcp.c:1342
5432#, c-format 4446#, c-format
5433msgid "Invalid hostname/address - %s" 4447msgid "Invalid hostname/address - %s"
5434msgstr "" 4448msgstr ""
5435 4449
5436#: plugins/popen.c:142
5437msgid "Could not malloc argv array in popen()" 4450msgid "Could not malloc argv array in popen()"
5438msgstr "" 4451msgstr ""
5439 4452
5440#: plugins/popen.c:152
5441msgid "CRITICAL - You need more args!!!" 4453msgid "CRITICAL - You need more args!!!"
5442msgstr "" 4454msgstr ""
5443 4455
5444#: plugins/popen.c:209
5445msgid "Cannot catch SIGCHLD" 4456msgid "Cannot catch SIGCHLD"
5446msgstr "" 4457msgstr ""
5447 4458
5448#: plugins/popen.c:304
5449#, c-format 4459#, c-format
5450msgid "CRITICAL - Plugin timed out after %d seconds\n" 4460msgid "CRITICAL - Plugin timed out after %d seconds\n"
5451msgstr "" 4461msgstr ""
5452 4462
5453#: plugins/popen.c:307
5454msgid "CRITICAL - popen timeout received, but no child process" 4463msgid "CRITICAL - popen timeout received, but no child process"
5455msgstr "" 4464msgstr ""
5456 4465
5457#: plugins/popen.c:323
5458msgid "sysconf error for _SC_OPEN_MAX"
5459msgstr ""
5460
5461#: plugins/urlize.c:130
5462#, c-format 4466#, c-format
5463msgid "" 4467msgid ""
5464"%s UNKNOWN - No data received from host\n" 4468"%s UNKNOWN - No data received from host\n"
5465"CMD: %s</A>\n" 4469"CMD: %s</A>\n"
5466msgstr "" 4470msgstr ""
5467 4471
5468#: plugins/urlize.c:169
5469msgid "" 4472msgid ""
5470"This plugin wraps the text output of another command (plugin) in HTML <A>" 4473"This plugin wraps the text output of another command (plugin) in HTML <A>"
5471msgstr "" 4474msgstr ""
5472 4475
5473#: plugins/urlize.c:170
5474msgid "" 4476msgid ""
5475"tags, thus displaying the child plugin's output as a clickable link in " 4477"tags, thus displaying the child plugin's output as a clickable link in "
5476"compatible" 4478"compatible"
5477msgstr "" 4479msgstr ""
5478 4480
5479#: plugins/urlize.c:171
5480msgid "" 4481msgid ""
5481"monitoring status screen. This plugin returns the status of the invoked " 4482"monitoring status screen. This plugin returns the status of the invoked "
5482"plugin." 4483"plugin."
5483msgstr "" 4484msgstr ""
5484 4485
5485#: plugins/urlize.c:181
5486msgid "" 4486msgid ""
5487"Pay close attention to quoting to ensure that the shell passes the expected" 4487"Pay close attention to quoting to ensure that the shell passes the expected"
5488msgstr "" 4488msgstr ""
5489 4489
5490#: plugins/urlize.c:182
5491msgid "data to the plugin. For example, in:" 4490msgid "data to the plugin. For example, in:"
5492msgstr "" 4491msgstr ""
5493 4492
5494#: plugins/urlize.c:183
5495msgid "urlize http://example.com/ check_http -H example.com -r 'two words'" 4493msgid "urlize http://example.com/ check_http -H example.com -r 'two words'"
5496msgstr "" 4494msgstr ""
5497 4495
5498#: plugins/urlize.c:184
5499msgid "the shell will remove the single quotes and urlize will see:" 4496msgid "the shell will remove the single quotes and urlize will see:"
5500msgstr "" 4497msgstr ""
5501 4498
5502#: plugins/urlize.c:185
5503msgid "urlize http://example.com/ check_http -H example.com -r two words" 4499msgid "urlize http://example.com/ check_http -H example.com -r two words"
5504msgstr "" 4500msgstr ""
5505 4501
5506#: plugins/urlize.c:186
5507msgid "You probably want:" 4502msgid "You probably want:"
5508msgstr "" 4503msgstr ""
5509 4504
5510#: plugins/urlize.c:187
5511msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\"" 4505msgid "urlize http://example.com/ \"check_http -H example.com -r 'two words'\""
5512msgstr "" 4506msgstr ""
5513 4507
5514#: plugins/utils.c:174
5515#, c-format
5516msgid "%s - Plugin timed out after %d seconds\n"
5517msgstr ""
5518
5519#: plugins/utils.c:469
5520msgid "failed realloc in strpcpy\n" 4508msgid "failed realloc in strpcpy\n"
5521msgstr "" 4509msgstr ""
5522 4510
5523#: plugins/utils.c:511
5524msgid "failed malloc in strscat\n" 4511msgid "failed malloc in strscat\n"
5525msgstr "" 4512msgstr ""
5526 4513
5527#: plugins/utils.c:531
5528msgid "failed malloc in xvasprintf\n" 4514msgid "failed malloc in xvasprintf\n"
5529msgstr "" 4515msgstr ""
5530 4516
5531#: plugins/utils.h:137 4517msgid "sysconf error for _SC_OPEN_MAX\n"
4518msgstr ""
4519
5532#, c-format 4520#, c-format
5533msgid "" 4521msgid ""
5534" %s (-h | --help) for detailed help\n" 4522" %s (-h | --help) for detailed help\n"
5535" %s (-V | --version) for version information\n" 4523" %s (-V | --version) for version information\n"
5536msgstr "" 4524msgstr ""
5537 4525
5538#: plugins/utils.h:141
5539msgid "" 4526msgid ""
5540"\n" 4527"\n"
5541"Options:\n" 4528"Options:\n"
@@ -5545,7 +4532,6 @@ msgid ""
5545" Print version information\n" 4532" Print version information\n"
5546msgstr "" 4533msgstr ""
5547 4534
5548#: plugins/utils.h:148
5549#, c-format 4535#, c-format
5550msgid "" 4536msgid ""
5551" -H, --hostname=ADDRESS\n" 4537" -H, --hostname=ADDRESS\n"
@@ -5554,7 +4540,6 @@ msgid ""
5554" Port number (default: %s)\n" 4540" Port number (default: %s)\n"
5555msgstr "" 4541msgstr ""
5556 4542
5557#: plugins/utils.h:154
5558msgid "" 4543msgid ""
5559" -4, --use-ipv4\n" 4544" -4, --use-ipv4\n"
5560" Use IPv4 connection\n" 4545" Use IPv4 connection\n"
@@ -5562,14 +4547,12 @@ msgid ""
5562" Use IPv6 connection\n" 4547" Use IPv6 connection\n"
5563msgstr "" 4548msgstr ""
5564 4549
5565#: plugins/utils.h:160
5566msgid "" 4550msgid ""
5567" -v, --verbose\n" 4551" -v, --verbose\n"
5568" Show details for command-line debugging (output may be truncated by\n" 4552" Show details for command-line debugging (output may be truncated by\n"
5569"\t\tthe monitoring system)\n" 4553" the monitoring system)\n"
5570msgstr "" 4554msgstr ""
5571 4555
5572#: plugins/utils.h:165
5573msgid "" 4556msgid ""
5574" -w, --warning=DOUBLE\n" 4557" -w, --warning=DOUBLE\n"
5575" Response time to result in warning status (seconds)\n" 4558" Response time to result in warning status (seconds)\n"
@@ -5577,7 +4560,6 @@ msgid ""
5577" Response time to result in critical status (seconds)\n" 4560" Response time to result in critical status (seconds)\n"
5578msgstr "" 4561msgstr ""
5579 4562
5580#: plugins/utils.h:171
5581msgid "" 4563msgid ""
5582" -w, --warning=RANGE\n" 4564" -w, --warning=RANGE\n"
5583" Warning range (format: start:end). Alert if outside this range\n" 4565" Warning range (format: start:end). Alert if outside this range\n"
@@ -5585,14 +4567,18 @@ msgid ""
5585" Critical range\n" 4567" Critical range\n"
5586msgstr "" 4568msgstr ""
5587 4569
5588#: plugins/utils.h:177
5589#, c-format 4570#, c-format
5590msgid "" 4571msgid ""
5591" -t, --timeout=INTEGER\n" 4572" -t, --timeout=INTEGER\n"
5592" Seconds before connection times out (default: %d)\n" 4573" Seconds before connection times out (default: %d)\n"
5593msgstr "" 4574msgstr ""
5594 4575
5595#: plugins/utils.h:182 4576#, c-format
4577msgid ""
4578" -t, --timeout=INTEGER\n"
4579" Seconds before plugin times out (default: %d)\n"
4580msgstr ""
4581
5596msgid "" 4582msgid ""
5597" --extra-opts=[section][@file]\n" 4583" --extra-opts=[section][@file]\n"
5598" Read options from an ini file. See\n" 4584" Read options from an ini file. See\n"
@@ -5600,14 +4586,12 @@ msgid ""
5600" for usage and examples.\n" 4586" for usage and examples.\n"
5601msgstr "" 4587msgstr ""
5602 4588
5603#: plugins/utils.h:190
5604msgid "" 4589msgid ""
5605" See:\n" 4590" See:\n"
5606" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n" 4591" https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT\n"
5607" for THRESHOLD format and examples.\n" 4592" for THRESHOLD format and examples.\n"
5608msgstr "" 4593msgstr ""
5609 4594
5610#: plugins/utils.h:195
5611msgid "" 4595msgid ""
5612"\n" 4596"\n"
5613"Send email to help@monitoring-plugins.org if you have questions regarding\n" 4597"Send email to help@monitoring-plugins.org if you have questions regarding\n"
@@ -5616,7 +4600,6 @@ msgid ""
5616"\n" 4600"\n"
5617msgstr "" 4601msgstr ""
5618 4602
5619#: plugins/utils.h:200
5620msgid "" 4603msgid ""
5621"\n" 4604"\n"
5622"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may " 4605"The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may "
@@ -5625,398 +4608,322 @@ msgid ""
5625"For more information about these matters, see the file named COPYING.\n" 4608"For more information about these matters, see the file named COPYING.\n"
5626msgstr "" 4609msgstr ""
5627 4610
5628#: plugins-root/check_dhcp.c:320
5629#, c-format 4611#, c-format
5630msgid "Error: Could not get hardware address of interface '%s'\n" 4612msgid "Error: Could not get hardware address of interface '%s'\n"
5631msgstr "" 4613msgstr ""
5632 4614
5633#: plugins-root/check_dhcp.c:342
5634#, c-format 4615#, c-format
5635msgid "Error: if_nametoindex error - %s.\n" 4616msgid "Error: if_nametoindex error - %s.\n"
5636msgstr "" 4617msgstr ""
5637 4618
5638#: plugins-root/check_dhcp.c:347
5639#, c-format 4619#, c-format
5640msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n" 4620msgid "Error: Couldn't get hardware address from %s. sysctl 1 error - %s.\n"
5641msgstr "" 4621msgstr ""
5642 4622
5643#: plugins-root/check_dhcp.c:352
5644#, c-format 4623#, c-format
5645msgid "" 4624msgid ""
5646"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n" 4625"Error: Couldn't get hardware address from interface %s. malloc error - %s.\n"
5647msgstr "" 4626msgstr ""
5648 4627
5649#: plugins-root/check_dhcp.c:357
5650#, c-format 4628#, c-format
5651msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n" 4629msgid "Error: Couldn't get hardware address from %s. sysctl 2 error - %s.\n"
5652msgstr "" 4630msgstr ""
5653 4631
5654#: plugins-root/check_dhcp.c:388
5655#, c-format 4632#, c-format
5656msgid "" 4633msgid ""
5657"Error: can't find unit number in interface_name (%s) - expecting TypeNumber " 4634"Error: can't find unit number in interface_name (%s) - expecting TypeNumber "
5658"eg lnc0.\n" 4635"eg lnc0.\n"
5659msgstr "" 4636msgstr ""
5660 4637
5661#: plugins-root/check_dhcp.c:393 plugins-root/check_dhcp.c:405
5662#, c-format 4638#, c-format
5663msgid "" 4639msgid ""
5664"Error: can't read MAC address from DLPI streams interface for device %s unit " 4640"Error: can't read MAC address from DLPI streams interface for device %s unit "
5665"%d.\n" 4641"%d.\n"
5666msgstr "" 4642msgstr ""
5667 4643
5668#: plugins-root/check_dhcp.c:411
5669#, c-format 4644#, c-format
5670msgid "" 4645msgid ""
5671"Error: can't get MAC address for this architecture. Use the --mac option.\n" 4646"Error: can't get MAC address for this architecture. Use the --mac option.\n"
5672msgstr "" 4647msgstr ""
5673 4648
5674#: plugins-root/check_dhcp.c:430
5675#, c-format 4649#, c-format
5676msgid "Error: Cannot determine IP address of interface %s\n" 4650msgid "Error: Cannot determine IP address of interface %s\n"
5677msgstr "" 4651msgstr ""
5678 4652
5679#: plugins-root/check_dhcp.c:438
5680#, c-format 4653#, c-format
5681msgid "Error: Cannot get interface IP address on this platform.\n" 4654msgid "Error: Cannot get interface IP address on this platform.\n"
5682msgstr "" 4655msgstr ""
5683 4656
5684#: plugins-root/check_dhcp.c:443
5685#, c-format 4657#, c-format
5686msgid "Pretending to be relay client %s\n" 4658msgid "Pretending to be relay client %s\n"
5687msgstr "" 4659msgstr ""
5688 4660
5689#: plugins-root/check_dhcp.c:528
5690#, c-format 4661#, c-format
5691msgid "DHCPDISCOVER to %s port %d\n" 4662msgid "DHCPDISCOVER to %s port %d\n"
5692msgstr "" 4663msgstr ""
5693 4664
5694#: plugins-root/check_dhcp.c:580
5695#, c-format 4665#, c-format
5696msgid "Result=ERROR\n" 4666msgid "Result=ERROR\n"
5697msgstr "" 4667msgstr ""
5698 4668
5699#: plugins-root/check_dhcp.c:586
5700#, c-format 4669#, c-format
5701msgid "Result=OK\n" 4670msgid "Result=OK\n"
5702msgstr "" 4671msgstr ""
5703 4672
5704#: plugins-root/check_dhcp.c:596
5705#, c-format 4673#, c-format
5706msgid "DHCPOFFER from IP address %s" 4674msgid "DHCPOFFER from IP address %s"
5707msgstr "" 4675msgstr ""
5708 4676
5709#: plugins-root/check_dhcp.c:597
5710#, c-format 4677#, c-format
5711msgid " via %s\n" 4678msgid " via %s\n"
5712msgstr "" 4679msgstr ""
5713 4680
5714#: plugins-root/check_dhcp.c:604
5715#, c-format 4681#, c-format
5716msgid "" 4682msgid ""
5717"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n" 4683"DHCPOFFER XID (%u) did not match DHCPDISCOVER XID (%u) - ignoring packet\n"
5718msgstr "" 4684msgstr ""
5719 4685
5720#: plugins-root/check_dhcp.c:626
5721#, c-format 4686#, c-format
5722msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n" 4687msgid "DHCPOFFER hardware address did not match our own - ignoring packet\n"
5723msgstr "" 4688msgstr ""
5724 4689
5725#: plugins-root/check_dhcp.c:644
5726#, c-format 4690#, c-format
5727msgid "Total responses seen on the wire: %d\n" 4691msgid "Total responses seen on the wire: %d\n"
5728msgstr "" 4692msgstr ""
5729 4693
5730#: plugins-root/check_dhcp.c:645
5731#, c-format 4694#, c-format
5732msgid "Valid responses for this machine: %d\n" 4695msgid "Valid responses for this machine: %d\n"
5733msgstr "" 4696msgstr ""
5734 4697
5735#: plugins-root/check_dhcp.c:660
5736#, c-format 4698#, c-format
5737msgid "send_dhcp_packet result: %d\n" 4699msgid "send_dhcp_packet result: %d\n"
5738msgstr "" 4700msgstr ""
5739 4701
5740#: plugins-root/check_dhcp.c:693
5741#, c-format 4702#, c-format
5742msgid "No (more) data received (nfound: %d)\n" 4703msgid "No (more) data received (nfound: %d)\n"
5743msgstr "" 4704msgstr ""
5744 4705
5745#: plugins-root/check_dhcp.c:712
5746#, c-format 4706#, c-format
5747msgid "recvfrom() failed, " 4707msgid "recvfrom() failed, "
5748msgstr "" 4708msgstr ""
5749 4709
5750#: plugins-root/check_dhcp.c:719
5751#, c-format 4710#, c-format
5752msgid "receive_dhcp_packet() result: %d\n" 4711msgid "receive_dhcp_packet() result: %d\n"
5753msgstr "" 4712msgstr ""
5754 4713
5755#: plugins-root/check_dhcp.c:720
5756#, c-format 4714#, c-format
5757msgid "receive_dhcp_packet() source: %s\n" 4715msgid "receive_dhcp_packet() source: %s\n"
5758msgstr "" 4716msgstr ""
5759 4717
5760#: plugins-root/check_dhcp.c:750
5761#, c-format 4718#, c-format
5762msgid "Error: Could not create socket!\n" 4719msgid "Error: Could not create socket!\n"
5763msgstr "" 4720msgstr ""
5764 4721
5765#: plugins-root/check_dhcp.c:760
5766#, c-format 4722#, c-format
5767msgid "Error: Could not set reuse address option on DHCP socket!\n" 4723msgid "Error: Could not set reuse address option on DHCP socket!\n"
5768msgstr "" 4724msgstr ""
5769 4725
5770#: plugins-root/check_dhcp.c:766
5771#, c-format 4726#, c-format
5772msgid "Error: Could not set broadcast option on DHCP socket!\n" 4727msgid "Error: Could not set broadcast option on DHCP socket!\n"
5773msgstr "" 4728msgstr ""
5774 4729
5775#: plugins-root/check_dhcp.c:775
5776#, c-format 4730#, c-format
5777msgid "" 4731msgid ""
5778"Error: Could not bind socket to interface %s. Check your privileges...\n" 4732"Error: Could not bind socket to interface %s. Check your privileges...\n"
5779msgstr "" 4733msgstr ""
5780 4734
5781#: plugins-root/check_dhcp.c:786
5782#, c-format 4735#, c-format
5783msgid "" 4736msgid ""
5784"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n" 4737"Error: Could not bind to DHCP socket (port %d)! Check your privileges...\n"
5785msgstr "" 4738msgstr ""
5786 4739
5787#: plugins-root/check_dhcp.c:820
5788#, c-format 4740#, c-format
5789msgid "Requested server address: %s\n" 4741msgid "Requested server address: %s\n"
5790msgstr "" 4742msgstr ""
5791 4743
5792#: plugins-root/check_dhcp.c:882
5793#, c-format 4744#, c-format
5794msgid "Lease Time: Infinite\n" 4745msgid "Lease Time: Infinite\n"
5795msgstr "" 4746msgstr ""
5796 4747
5797#: plugins-root/check_dhcp.c:884
5798#, c-format 4748#, c-format
5799msgid "Lease Time: %lu seconds\n" 4749msgid "Lease Time: %lu seconds\n"
5800msgstr "" 4750msgstr ""
5801 4751
5802#: plugins-root/check_dhcp.c:886
5803#, c-format 4752#, c-format
5804msgid "Renewal Time: Infinite\n" 4753msgid "Renewal Time: Infinite\n"
5805msgstr "" 4754msgstr ""
5806 4755
5807#: plugins-root/check_dhcp.c:888
5808#, c-format 4756#, c-format
5809msgid "Renewal Time: %lu seconds\n" 4757msgid "Renewal Time: %lu seconds\n"
5810msgstr "" 4758msgstr ""
5811 4759
5812#: plugins-root/check_dhcp.c:890
5813#, c-format 4760#, c-format
5814msgid "Rebinding Time: Infinite\n" 4761msgid "Rebinding Time: Infinite\n"
5815msgstr "" 4762msgstr ""
5816 4763
5817#: plugins-root/check_dhcp.c:891
5818#, c-format 4764#, c-format
5819msgid "Rebinding Time: %lu seconds\n" 4765msgid "Rebinding Time: %lu seconds\n"
5820msgstr "" 4766msgstr ""
5821 4767
5822#: plugins-root/check_dhcp.c:919
5823#, c-format 4768#, c-format
5824msgid "Added offer from server @ %s" 4769msgid "Added offer from server @ %s"
5825msgstr "" 4770msgstr ""
5826 4771
5827#: plugins-root/check_dhcp.c:920
5828#, c-format 4772#, c-format
5829msgid " of IP address %s\n" 4773msgid " of IP address %s\n"
5830msgstr "" 4774msgstr ""
5831 4775
5832#: plugins-root/check_dhcp.c:987
5833#, c-format 4776#, c-format
5834msgid "DHCP Server Match: Offerer=%s" 4777msgid "DHCP Server Match: Offerer=%s"
5835msgstr "" 4778msgstr ""
5836 4779
5837#: plugins-root/check_dhcp.c:988
5838#, c-format 4780#, c-format
5839msgid " Requested=%s" 4781msgid " Requested=%s"
5840msgstr "" 4782msgstr ""
5841 4783
5842#: plugins-root/check_dhcp.c:990
5843#, c-format 4784#, c-format
5844msgid " (duplicate)" 4785msgid " (duplicate)"
5845msgstr "" 4786msgstr ""
5846 4787
5847#: plugins-root/check_dhcp.c:991
5848#, c-format 4788#, c-format
5849msgid "\n" 4789msgid "\n"
5850msgstr "" 4790msgstr ""
5851 4791
5852#: plugins-root/check_dhcp.c:1039
5853#, c-format 4792#, c-format
5854msgid "No DHCPOFFERs were received.\n" 4793msgid "No DHCPOFFERs were received.\n"
5855msgstr "" 4794msgstr ""
5856 4795
5857#: plugins-root/check_dhcp.c:1043
5858#, c-format 4796#, c-format
5859msgid "Received %d DHCPOFFER(s)" 4797msgid "Received %d DHCPOFFER(s)"
5860msgstr "" 4798msgstr ""
5861 4799
5862#: plugins-root/check_dhcp.c:1046
5863#, c-format 4800#, c-format
5864msgid ", %s%d of %d requested servers responded" 4801msgid ", %s%d of %d requested servers responded"
5865msgstr "" 4802msgstr ""
5866 4803
5867#: plugins-root/check_dhcp.c:1049
5868#, c-format 4804#, c-format
5869msgid ", requested address (%s) was %soffered" 4805msgid ", requested address (%s) was %soffered"
5870msgstr "" 4806msgstr ""
5871 4807
5872#: plugins-root/check_dhcp.c:1049
5873msgid "not " 4808msgid "not "
5874msgstr "" 4809msgstr ""
5875 4810
5876#: plugins-root/check_dhcp.c:1051
5877#, c-format 4811#, c-format
5878msgid ", max lease time = " 4812msgid ", max lease time = "
5879msgstr "" 4813msgstr ""
5880 4814
5881#: plugins-root/check_dhcp.c:1053
5882#, c-format 4815#, c-format
5883msgid "Infinity" 4816msgid "Infinity"
5884msgstr "" 4817msgstr ""
5885 4818
5886#: plugins-root/check_dhcp.c:1234 4819msgid "Got unexpected non-option argument"
4820msgstr ""
4821
5887#, c-format 4822#, c-format
5888msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n" 4823msgid "Error: DLPI stream API failed to get MAC in check_ctrl: %s.\n"
5889msgstr "" 4824msgstr ""
5890 4825
5891#: plugins-root/check_dhcp.c:1246
5892#, c-format 4826#, c-format
5893msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n" 4827msgid "Error: DLPI stream API failed to get MAC in put_ctrl/putmsg(): %s.\n"
5894msgstr "" 4828msgstr ""
5895 4829
5896#: plugins-root/check_dhcp.c:1259
5897#, c-format 4830#, c-format
5898msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n" 4831msgid "Error: DLPI stream API failed to get MAC in put_both/putmsg().\n"
5899msgstr "" 4832msgstr ""
5900 4833
5901#: plugins-root/check_dhcp.c:1271
5902#, c-format 4834#, c-format
5903msgid "" 4835msgid ""
5904"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n" 4836"Error: DLPI stream API failed to get MAC in dl_attach_req/open(%s..): %s.\n"
5905msgstr "" 4837msgstr ""
5906 4838
5907#: plugins-root/check_dhcp.c:1295
5908#, c-format 4839#, c-format
5909msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n" 4840msgid "Error: DLPI stream API failed to get MAC in dl_bind/check_ctrl(): %s.\n"
5910msgstr "" 4841msgstr ""
5911 4842
5912#: plugins-root/check_dhcp.c:1374
5913#, c-format 4843#, c-format
5914msgid "Hardware address: " 4844msgid "Hardware address: "
5915msgstr "" 4845msgstr ""
5916 4846
5917#: plugins-root/check_dhcp.c:1390
5918msgid "This plugin tests the availability of DHCP servers on a network." 4847msgid "This plugin tests the availability of DHCP servers on a network."
5919msgstr "" 4848msgstr ""
5920 4849
5921#: plugins-root/check_dhcp.c:1402
5922msgid "IP address of DHCP server that we must hear from" 4850msgid "IP address of DHCP server that we must hear from"
5923msgstr "" 4851msgstr ""
5924 4852
5925#: plugins-root/check_dhcp.c:1404
5926msgid "IP address that should be offered by at least one DHCP server" 4853msgid "IP address that should be offered by at least one DHCP server"
5927msgstr "" 4854msgstr ""
5928 4855
5929#: plugins-root/check_dhcp.c:1406
5930msgid "Seconds to wait for DHCPOFFER before timeout occurs" 4856msgid "Seconds to wait for DHCPOFFER before timeout occurs"
5931msgstr "" 4857msgstr ""
5932 4858
5933#: plugins-root/check_dhcp.c:1408
5934msgid "Interface to to use for listening (i.e. eth0)" 4859msgid "Interface to to use for listening (i.e. eth0)"
5935msgstr "" 4860msgstr ""
5936 4861
5937#: plugins-root/check_dhcp.c:1410
5938msgid "MAC address to use in the DHCP request" 4862msgid "MAC address to use in the DHCP request"
5939msgstr "" 4863msgstr ""
5940 4864
5941#: plugins-root/check_dhcp.c:1412
5942msgid "Unicast testing: mimic a DHCP relay, requires -s" 4865msgid "Unicast testing: mimic a DHCP relay, requires -s"
5943msgstr "" 4866msgstr ""
5944 4867
5945#: plugins-root/check_icmp.c:1295
5946msgid "specify a target" 4868msgid "specify a target"
5947msgstr "" 4869msgstr ""
5948 4870
5949#: plugins-root/check_icmp.c:1297 4871msgid "Use IPv4 (default) or IPv6 to communicate with the targets"
4872msgstr ""
4873
5950msgid "warning threshold (currently " 4874msgid "warning threshold (currently "
5951msgstr "" 4875msgstr ""
5952 4876
5953#: plugins-root/check_icmp.c:1300
5954msgid "critical threshold (currently " 4877msgid "critical threshold (currently "
5955msgstr "" 4878msgstr ""
5956 4879
5957#: plugins-root/check_icmp.c:1303
5958msgid "specify a source IP address or device name" 4880msgid "specify a source IP address or device name"
5959msgstr "" 4881msgstr ""
5960 4882
5961#: plugins-root/check_icmp.c:1305
5962msgid "number of packets to send (currently " 4883msgid "number of packets to send (currently "
5963msgstr "" 4884msgstr ""
5964 4885
5965#: plugins-root/check_icmp.c:1308
5966msgid "max packet interval (currently " 4886msgid "max packet interval (currently "
5967msgstr "" 4887msgstr ""
5968 4888
5969#: plugins-root/check_icmp.c:1311
5970msgid "max target interval (currently " 4889msgid "max target interval (currently "
5971msgstr "" 4890msgstr ""
5972 4891
5973#: plugins-root/check_icmp.c:1314
5974msgid "number of alive hosts required for success" 4892msgid "number of alive hosts required for success"
5975msgstr "" 4893msgstr ""
5976 4894
5977#: plugins-root/check_icmp.c:1317
5978msgid "TTL on outgoing packets (currently " 4895msgid "TTL on outgoing packets (currently "
5979msgstr "" 4896msgstr ""
5980 4897
5981#: plugins-root/check_icmp.c:1320
5982msgid "timeout value (seconds, currently " 4898msgid "timeout value (seconds, currently "
5983msgstr "" 4899msgstr ""
5984 4900
5985#: plugins-root/check_icmp.c:1323
5986msgid "Number of icmp data bytes to send" 4901msgid "Number of icmp data bytes to send"
5987msgstr "" 4902msgstr ""
5988 4903
5989#: plugins-root/check_icmp.c:1324
5990msgid "Packet size will be data bytes + icmp header (currently" 4904msgid "Packet size will be data bytes + icmp header (currently"
5991msgstr "" 4905msgstr ""
5992 4906
5993#: plugins-root/check_icmp.c:1326
5994msgid "verbose" 4907msgid "verbose"
5995msgstr "" 4908msgstr ""
5996 4909
5997#: plugins-root/check_icmp.c:1330
5998msgid "The -H switch is optional. Naming a host (or several) to check is not." 4910msgid "The -H switch is optional. Naming a host (or several) to check is not."
5999msgstr "" 4911msgstr ""
6000 4912
6001#: plugins-root/check_icmp.c:1332
6002msgid "" 4913msgid ""
6003"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%" 4914"Threshold format for -w and -c is 200.25,60% for 200.25 msec RTA and 60%"
6004msgstr "" 4915msgstr ""
6005 4916
6006#: plugins-root/check_icmp.c:1333
6007msgid "packet loss. The default values should work well for most users." 4917msgid "packet loss. The default values should work well for most users."
6008msgstr "" 4918msgstr ""
6009 4919
6010#: plugins-root/check_icmp.c:1334
6011msgid "" 4920msgid ""
6012"You can specify different RTA factors using the standardized abbreviations" 4921"You can specify different RTA factors using the standardized abbreviations"
6013msgstr "" 4922msgstr ""
6014 4923
6015#: plugins-root/check_icmp.c:1335
6016msgid "" 4924msgid ""
6017"us (microseconds), ms (milliseconds, default) or just plain s for seconds." 4925"us (microseconds), ms (milliseconds, default) or just plain s for seconds."
6018msgstr "" 4926msgstr ""
6019 4927
6020#: plugins-root/check_icmp.c:1341
6021msgid "The -v switch can be specified several times for increased verbosity." 4928msgid "The -v switch can be specified several times for increased verbosity."
6022msgstr "" 4929msgstr ""
diff --git a/tap/tap.3 b/tap/tap.3
index 4b23c24..dce85fc 100644
--- a/tap/tap.3
+++ b/tap/tap.3
@@ -291,7 +291,7 @@ always returns 0.
291.Xc 291.Xc
292.El 292.El
293.Pp 293.Pp
294For maximum compatability your test program should return a particular 294For maximum compatibility your test program should return a particular
295exit code. This is calculated by 295exit code. This is calculated by
296.Fn exit_status 296.Fn exit_status
297so it is sufficient to always return from 297so it is sufficient to always return from
@@ -309,7 +309,7 @@ directory in the source distribution contains numerous tests of
309functionality, written using 309functionality, written using
310.Nm . 310.Nm .
311Examine them for examples of how to construct test suites. 311Examine them for examples of how to construct test suites.
312.Sh COMPATABILITY 312.Sh COMPATIBILITY
313.Nm 313.Nm
314strives to be compatible with the Perl Test::More and Test::Harness 314strives to be compatible with the Perl Test::More and Test::Harness
315modules. The test suite verifies that 315modules. The test suite verifies that
diff --git a/tap/tap.h b/tap/tap.h
index bd81789..8ee525c 100644
--- a/tap/tap.h
+++ b/tap/tap.h
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting 27/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
28 and requires the caller to add the final comma if they've ommitted 28 and requires the caller to add the final comma if they've omitted
29 the optional arguments */ 29 the optional arguments */
30#ifdef __GNUC__ 30#ifdef __GNUC__
31# define ok(e, test, ...) ((e) ? \ 31# define ok(e, test, ...) ((e) ? \
diff --git a/tools/build_perl_modules b/tools/build_perl_modules
index 5a57a47..b8cd34c 100755
--- a/tools/build_perl_modules
+++ b/tools/build_perl_modules
@@ -140,7 +140,7 @@ my $libs = "$destdir/$prefix/lib:$destdir/$prefix/lib/$Config{archname}";
140 140
141my $topdir = cwd(); 141my $topdir = cwd();
142 142
143# set an initial value if there isnt one already 143# set an initial value if there isn't one already
144# Need to use PERL5LIB to ensure we get pre-installed mods from earlier 144# Need to use PERL5LIB to ensure we get pre-installed mods from earlier
145# tags in the install_order file 145# tags in the install_order file
146$ENV{PERL5LIB} ||= q{}; 146$ENV{PERL5LIB} ||= q{};
@@ -149,8 +149,8 @@ $ENV{PERL5LIB} ||= q{};
149$ENV{PERL_AUTOINSTALL} = "--skipdeps"; 149$ENV{PERL_AUTOINSTALL} = "--skipdeps";
150 150
151# keep a record of how many times a module build is done. This is so they may 151# keep a record of how many times a module build is done. This is so they may
152# be built a second time to include optional prereq's that couldnt 152# be built a second time to include optional prereq's that couldn't
153# previously be built due to circular dependancies 153# previously be built due to circular dependencies
154my %built_modules; 154my %built_modules;
155foreach my $tarball (@tarballs) { 155foreach my $tarball (@tarballs) {
156 ( my $dir = $tarball ) =~ s/\.(?:tgz|tar.gz)$//; 156 ( my $dir = $tarball ) =~ s/\.(?:tgz|tar.gz)$//;
diff --git a/tools/p1.pl b/tools/p1.pl
index 2788dbf..9cbe6dc 100644
--- a/tools/p1.pl
+++ b/tools/p1.pl
@@ -2,7 +2,7 @@
2# 2#
3# Hacked version of the sample code from the perlembedded doco. 3# Hacked version of the sample code from the perlembedded doco.
4# 4#
5# Only major changes are to separate the compiling and cacheing from 5# Only major changes are to separate the compiling and caching from
6# the execution so that the cache can be kept in "non-volatile" parent 6# the execution so that the cache can be kept in "non-volatile" parent
7# process while the execution is done from "volatile" child processes 7# process while the execution is done from "volatile" child processes
8# and that STDOUT is redirected to a file by means of a tied filehandle 8# and that STDOUT is redirected to a file by means of a tied filehandle
diff --git a/tools/tinderbox_build b/tools/tinderbox_build
index 48836b1..1a41f57 100755
--- a/tools/tinderbox_build
+++ b/tools/tinderbox_build
@@ -138,7 +138,7 @@ sub BuildIt {
138# interprets that as the end of the mail, and truncates the log before 138# interprets that as the end of the mail, and truncates the log before
139# it gets to Tinderbox. (terry weismann, chris yeh) 139# it gets to Tinderbox. (terry weismann, chris yeh)
140# 140#
141# This was replaced by a perl 'port' of the above, writen by 141# This was replaced by a perl 'port' of the above, written by
142# preed@netscape.com; good things: no need for system() call, and now it's 142# preed@netscape.com; good things: no need for system() call, and now it's
143# all in perl, so we don't have to do OS checking like before. 143# all in perl, so we don't have to do OS checking like before.
144 144