Codebase list gzip / a2016c1
Imported Upstream version 1.4 Bdale Garbee 14 years ago
360 changed file(s) with 21802 addition(s) and 10883 deletion(s). Raw diff Collapse all Expand all
0 1.3.14
0 1.4
0 2010-01-20 Jim Meyering <meyering@redhat.com>
1
2 version 1.4
3 * NEWS: Record release date.
4
5 tests: exercise the segfault fix
6 * tests/helin-segv: New test.
7 * Makefile.am (TESTS): Add it.
8
9 gzip -d: do not clobber stack for valid input on x86_64
10 * unlzw.c (unlzw): Avoid integer overflow.
11 Aki Helin reported the segfault along with an input to trigger the bug.
12 * NEWS (Bug fixes): Mention it.
13
14 maint: avoid a minor "make syntax-check" failure
15 * .x-sc_file_system: Exempt NEWS, since it includes a literal
16 from an old diagnostic.
17
18 maint: remove unused file: README-alpha
19 * README-alpha: Remove unused file.
20
21 build: update gnulib submodule to latest
22
23 2010-01-11 Yuxi Zhang <YZhang@qnx.com>
24
25 gzip -d: use memcpy more often
26 * inflate.c (inflate_codes): Use memcpy (rather than slower
27 memcopy-like code) in more cases.
28
29 2010-01-11 Jim Meyering <meyering@redhat.com>
30
31 build: do not override gnulib-provided AM_CFLAGS options
32 Avoid a warning from automake:
33 lib/Makefile.am:24: AM_CFLAGS multiply defined in condition TRUE ...
34 lib/gnulib.mk:30: ... `AM_CFLAGS' previously defined here
35 lib/Makefile.am:20: `lib/gnulib.mk' included from here
36
37 * lib/Makefile.am (AM_CFLAGS): Append $(WARN_CFLAGS) and
38 $(WERROR_CFLAGS), i.e., use "+=", not "=".
39 This was introduced via 2009-12-17 commit 0341fc22,
40 "build: with --enable-gcc-warnings, use -Werror",
41 but fortunately is not a bug, because the definition
42 it would have overridden was always empty.
43
44 gzip -d would fail with a CRC error...
45 ...for some inputs, and some memcpy implementations. It is possible
46 that an offending input has to be compressed "from FAT filesystem
47 (MS-DOS, OS/2, NT)", since the sole reproducer no longer evokes a
48 CRC error when uncompressed and recompressed on a GNU/Linux system.
49 Also, using an unpatched reverse-memcpy-gzip on over 100,000 inputs
50 on a GNU/Linux system did not turn up another reproducer.
51 * inflate.c (inflate_codes): Don't call memcpy with overlapping regions.
52 Properly detect when source and destination overlap.
53 * tests/memcpy-abuse: New test, to trigger misbehavior.
54 * Makefile.am (TESTS): Add it.
55 * NEWS (Bug fixes): Mention it.
56 Reported by Alain Magloire in
57 http://thread.gmane.org/gmane.comp.gnu.gzip.bugs/307
58
59 2010-01-08 Jim Meyering <meyering@redhat.com>
60
61 tests: switch to gnulib's init.sh test infrastructure
62 * tests/test-lib.sh: Remove file.
63 * tests/init.sh: New file, from gnulib.
64 * tests/trailing-nul: Use the new file.
65 * tests/zdiff: Likewise.
66 * tests/zgrep-f: Likewise.
67 * Makefile.am (EXTRA_DIST): List tests/init.sh, not test-lib.sh.
68
69 build: update gnulib submodule to latest
70
71 2010-01-03 Jim Meyering <meyering@redhat.com>
72
73 maint: record update-copyright options for this package
74 * cfg.mk: Next time, just run "make update-copyright".
75
76 2010-01-01 Jim Meyering <meyering@redhat.com>
77
78 maint: update all FSF copyright year lists to include 2010
79 Use this command:
80 git ls-files |grep -vE '^(\..*|COPYING|gnulib)$' |xargs \
81 env UPDATE_COPYRIGHT_USE_INTERVALS=1 build-aux/update-copyright
82
83 2009-12-31 Jim Meyering <meyering@redhat.com>
84
85 maint: newer gnulib; don't hard-code my GPG key ID
86 * cfg.mk (gpg_key_ID): Remove definition, now that maint.mk automates it.
87 * gnulib: Update to lastest.
88
89 2009-12-30 Jim Meyering <meyering@redhat.com>
90
91 build: update gnulib submodule to latest
92
93 maint: remove lots of obsolete #if...HAVE_* checks
94 Remove many always-true cpp tests like #ifdef HAVE_UNISTD_H,
95 #ifdef HAVE_FCNTL_H and #ifdef SSIZE_MAX.
96 * gzip.c: As above.
97 * gzip.h: Likewise.
98 * inflate.c: Likewise.
99 * tailor.h: Likewise.
100 * unlzw.c: Likewise.
101 * util.c: Likewise.
102 * zip.c: Likewise.
103
104 build: add a syntax-check
105 * cfg.mk (sc_prohibit_obsolete_HAVE_HEADER_H): New rule.
106
107 build: with --enable-gcc-warnings, use -Werror
108 * Makefile.am (AM_CFLAGS): Enable $(WERROR_CFLAGS).
109 * lib/Makefile.am (AM_CFLAGS): Enable both $(WARN_CFLAGS) and
110 $(WERROR_CFLAGS).
111
112 build: quiet warnings from util.c
113 * configure.ac (warnings): Add -Wno-overflow and -Wno-type-limits.
114
115 build: avoid warning about possibly-no-return functions
116 * gzip.h (read_error, write_error): Mark these functions as "no-return".
117
118 build: avoid warning about ignored chown/fchown return value
119 * bootstrap.conf (gnulib_modules): Add ignore-value.
120 * gzip.c: Include "ignore-value.h".
121 (copy_stat): Explicitly ignore chown and fchown failure
122
123 build: update gnulib submodule to latest
124
125 2009-11-20 Jim Meyering <meyering@redhat.com>
126
127 build: unlzw.c: avoid warnings about unused macros
128 * configure.ac: Turn off -Wunused-macros.
129
130 build: avoid warnings about unused macros
131 * unzip.c (LOCTIM): Comment out unused macro.
132 * deflate.c (EQUAL): Remove definition. Use "0" at sole point of use.
133
134 build: util.c: avoid warnings about add_envopt
135 * util.c (add_envopt): The parameter "env" was used for two conflicting
136 purposes. One use required a const char* parameter, while the other
137 was used as an argument to free, which must not be "const".
138 Rename the parameter and use a new local variable for the second role.
139
140 build: avoid many const-related warnings
141 * gzip.c: Add "const" to many variables, to avoid compiler warnings.
142 * util.c (add_envopt): Make 3rd parameter const
143 (gzip_error): Make sole parameter const.
144 * gzip.h: Update prototypes.
145
146 build: avoid warnings from -Wstrict-prototypes
147 * gzip.c (main): Declare using a prototype.
148 (progerror): Likewise. And make parameter const.
149
150 build: use gnulib's fdopendir module
151 * bootstrap.conf (gnulib_modules): Add fdopendir.
152 * gzip.c (treat_dir): Don't depend on HAVE_FDOPENDIR.
153 Gnulib now guarantees its availability.
154 * configure.ac: Don't check for fdopendir here.
155
156 build: enable many warnings
157 * configure.ac: Add support for --enable-gcc-warnings.
158 * bootstrap.conf (gnulib_modules): Add manywarnings.
159 * Makefile.am (AM_CFLAGS): Add (WARN_CFLAGS) # $(WERROR_CFLAGS)
160
161 maint: tweak formatting of bootstrap.conf
162 * bootstrap.conf (gnulib_modules): Unindent list.
163
164 maint: cfg.mk: remove factored-out ftp host/dir definitions
165 * cfg.mk (gnu_ftp_host-alpha, gnu_ftp_host-beta gnu_ftp_host-stable):
166 (gnu_rel_host, url_dir_list): Remove definitions. The defaults,
167 now provided by maint.mk, are the same.
168 * gnulib: Update for latest, including those maint.mk additions.
169
170 build: "make stable" emitted an invalid gnupload command
171 * cfg.mk (gnu_ftp_host-stable): Rename from gnu_ftp_host-major.
172 * README-release: Change another s/major/stable/.
173
0174 2009-10-30 Jim Meyering <meyering@redhat.com>
175
176 post-release administrivia
177 * NEWS: Add header line for next release.
178 * .prev-version: Record previous version.
179 * cfg.mk (old_NEWS_hash): Auto-update.
1180
2181 version 1.3.14
3182 * NEWS: Record release date.
17751775
17761776 -----
17771777
1778 Copyright (C) 1997-2002, 2006-2007, 2009 Free Software Foundation, Inc.
1779
1778 Copyright (C) 1997-2002, 2006-2010 Free Software Foundation, Inc.
17801779 Copyright (C) 1992, 1993 Jean-loup Gailly
17811780
17821781 Copying and distribution of this file, with or without
44 # It is necessary if you want to build targets usually of interest
55 # only to the maintainer.
66
7 # Copyright (C) 2001, 2003, 2006-2009 Free Software Foundation, Inc.
7 # Copyright (C) 2001, 2003, 2006-2010 Free Software Foundation, Inc.
88
99 # This program is free software: you can redistribute it and/or modify
1010 # it under the terms of the GNU General Public License as published by
11 *************************
22
33 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
4 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
55
66 Copying and distribution of this file, with or without modification,
77 are permitted in any medium without royalty provided the copyright
00 # Make gzip (GNU zip).
11
2 # Copyright (C) 1999, 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2010 Free Software Foundation,
3 # Inc.
34
45 # This program is free software; you can redistribute it and/or modify
56 # it under the terms of the GNU General Public License as published by
1819 SUBDIRS = lib doc
1920 ACLOCAL_AMFLAGS = -I m4
2021 AM_CPPFLAGS = -I$(top_srcdir)/lib
22 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
2123
2224 man_MANS = gunzip.1 gzexe.1 gzip.1 \
2325 zcat.1 zcmp.1 zdiff.1 zforce.1 zgrep.1 zless.1 zmore.1 znew.1
3840 tailor.h vms/Makefile.mms vms/gzip.hlp vms/vms.c vms/Readme.vms \
3941 vms/Makefile.vms vms/Makefile.gcc vms/makegzip.com zcat.in zcmp.in zdiff.in \
4042 zegrep.in zfgrep.in zforce.in zgrep.in zless.in zmore.in znew.in \
41 tests/test-lib.sh
43 tests/init.sh
4244
4345 bin_PROGRAMS = gzip
4446 bin_SCRIPTS = gunzip gzexe zcat zcmp zdiff \
101103 @echo 'Test succeeded.'
102104
103105 TESTS = \
106 tests/helin-segv \
107 tests/memcpy-abuse \
104108 tests/trailing-nul \
105109 tests/zdiff \
106110 tests/zgrep-f
11 # @configure_input@
22
33 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
5 # Inc.
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 # Foundation, Inc.
66 # This Makefile.in is free software; the Free Software Foundation
77 # gives unlimited permission to copy and/or distribute it,
88 # with or without modifications, as long as this notice is preserved.
1616
1717 # Make gzip (GNU zip).
1818
19 # Copyright (C) 1999, 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
19 # Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2010 Free Software Foundation,
20 # Inc.
2021
2122 # This program is free software; you can redistribute it and/or modify
2223 # it under the terms of the GNU General Public License as published by
6364 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
6465 am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
6566 $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/calloc.m4 \
67 $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \
6668 $(top_srcdir)/m4/clock_time.m4 \
6769 $(top_srcdir)/m4/close-stream.m4 $(top_srcdir)/m4/close.m4 \
6870 $(top_srcdir)/m4/closein.m4 $(top_srcdir)/m4/closeout.m4 \
69 $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/dos.m4 \
70 $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/errno_h.m4 \
71 $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exitfail.m4 \
72 $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/exponentf.m4 \
73 $(top_srcdir)/m4/exponentl.m4 $(top_srcdir)/m4/extensions.m4 \
74 $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \
75 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fflush.m4 \
76 $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fpending.m4 \
77 $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintf-posix.m4 \
78 $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \
79 $(top_srcdir)/m4/frexp.m4 $(top_srcdir)/m4/frexpl.m4 \
80 $(top_srcdir)/m4/fseeko.m4 $(top_srcdir)/m4/ftello.m4 \
81 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/getpagesize.m4 \
82 $(top_srcdir)/m4/gettime.m4 $(top_srcdir)/m4/gettimeofday.m4 \
83 $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/gnu-make.m4 \
84 $(top_srcdir)/m4/gnulib-common.m4 \
71 $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/d-ino.m4 \
72 $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \
73 $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \
74 $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
75 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \
76 $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \
77 $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \
78 $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \
79 $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-o.m4 \
80 $(top_srcdir)/m4/fcntl-safer.m4 $(top_srcdir)/m4/fcntl.m4 \
81 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fdopendir.m4 \
82 $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/float_h.m4 \
83 $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \
84 $(top_srcdir)/m4/fprintf-posix.m4 $(top_srcdir)/m4/fpurge.m4 \
85 $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \
86 $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \
87 $(top_srcdir)/m4/ftello.m4 \
88 $(top_srcdir)/m4/getcwd-abort-bug.m4 \
89 $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \
90 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \
91 $(top_srcdir)/m4/gettimeofday.m4 $(top_srcdir)/m4/glibc21.m4 \
92 $(top_srcdir)/m4/gnu-make.m4 $(top_srcdir)/m4/gnulib-common.m4 \
8593 $(top_srcdir)/m4/gnulib-comp.m4 \
8694 $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inline.m4 \
8795 $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \
8896 $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \
89 $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/ldexpl.m4 \
90 $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \
91 $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \
92 $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lseek.m4 \
93 $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \
97 $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/lchown.m4 \
98 $(top_srcdir)/m4/ldexpl.m4 $(top_srcdir)/m4/localcharset.m4 \
99 $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \
100 $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/longlong.m4 \
101 $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \
102 $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/manywarnings.m4 \
94103 $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbrtowc.m4 \
95104 $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbstate_t.m4 \
96 $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mmap-anon.m4 \
97 $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/multiarch.m4 \
98 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \
105 $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mempcpy.m4 \
106 $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mkdir.m4 \
107 $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \
108 $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nocrash.m4 \
109 $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \
99110 $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/printf-frexp.m4 \
100111 $(top_srcdir)/m4/printf-frexpl.m4 \
101112 $(top_srcdir)/m4/printf-posix-rpl.m4 \
102113 $(top_srcdir)/m4/printf.m4 $(top_srcdir)/m4/quotearg.m4 \
103 $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/shell.m4 \
114 $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rmdir.m4 \
115 $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/shell.m4 \
104116 $(top_srcdir)/m4/signbit.m4 $(top_srcdir)/m4/size_max.m4 \
105117 $(top_srcdir)/m4/stat-time.m4 $(top_srcdir)/m4/stat.m4 \
106118 $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
107119 $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
108120 $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
109 $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/string_h.m4 \
110 $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \
111 $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/timespec.m4 \
112 $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \
121 $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
122 $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/sys_stat_h.m4 \
123 $(top_srcdir)/m4/sys_time_h.m4 $(top_srcdir)/m4/time_h.m4 \
124 $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/unistd-safer.m4 \
125 $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink.m4 \
113126 $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \
114127 $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \
115 $(top_srcdir)/m4/vfprintf-posix.m4 $(top_srcdir)/m4/wchar.m4 \
116 $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wctype.m4 \
117 $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \
128 $(top_srcdir)/m4/vfprintf-posix.m4 \
129 $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \
130 $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \
131 $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wint_t.m4 \
132 $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xgetcwd.m4 \
118133 $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/yesno.m4 \
119134 $(top_srcdir)/configure.ac
120135 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
338353 EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
339354 ERRNO_H = @ERRNO_H@
340355 EXEEXT = @EXEEXT@
341 FCNTL_H = @FCNTL_H@
342356 FLOAT_H = @FLOAT_H@
343357 GETOPT_H = @GETOPT_H@
344358 GLIBC21 = @GLIBC21@
359 GNULIB_ACOSL = @GNULIB_ACOSL@
360 GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
361 GNULIB_ASINL = @GNULIB_ASINL@
362 GNULIB_ATANL = @GNULIB_ATANL@
345363 GNULIB_ATOLL = @GNULIB_ATOLL@
346364 GNULIB_BTOWC = @GNULIB_BTOWC@
347365 GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
350368 GNULIB_CEILL = @GNULIB_CEILL@
351369 GNULIB_CHOWN = @GNULIB_CHOWN@
352370 GNULIB_CLOSE = @GNULIB_CLOSE@
371 GNULIB_COSL = @GNULIB_COSL@
372 GNULIB_DIRFD = @GNULIB_DIRFD@
353373 GNULIB_DPRINTF = @GNULIB_DPRINTF@
354374 GNULIB_DUP2 = @GNULIB_DUP2@
355375 GNULIB_DUP3 = @GNULIB_DUP3@
356376 GNULIB_ENVIRON = @GNULIB_ENVIRON@
357377 GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
378 GNULIB_EXPL = @GNULIB_EXPL@
358379 GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
359380 GNULIB_FCHDIR = @GNULIB_FCHDIR@
360381 GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
361382 GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
362383 GNULIB_FCLOSE = @GNULIB_FCLOSE@
384 GNULIB_FCNTL = @GNULIB_FCNTL@
385 GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
363386 GNULIB_FFLUSH = @GNULIB_FFLUSH@
364387 GNULIB_FLOORF = @GNULIB_FLOORF@
365388 GNULIB_FLOORL = @GNULIB_FLOORL@
385408 GNULIB_GETDELIM = @GNULIB_GETDELIM@
386409 GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
387410 GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
411 GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
388412 GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
389413 GNULIB_GETLINE = @GNULIB_GETLINE@
390414 GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
415 GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
391416 GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
392417 GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
393418 GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
403428 GNULIB_LDEXPL = @GNULIB_LDEXPL@
404429 GNULIB_LINK = @GNULIB_LINK@
405430 GNULIB_LINKAT = @GNULIB_LINKAT@
431 GNULIB_LOGL = @GNULIB_LOGL@
406432 GNULIB_LSEEK = @GNULIB_LSEEK@
407433 GNULIB_LSTAT = @GNULIB_LSTAT@
408434 GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
409 GNULIB_MATHL = @GNULIB_MATHL@
410435 GNULIB_MBRLEN = @GNULIB_MBRLEN@
411436 GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
412437 GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
432457 GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
433458 GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
434459 GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
460 GNULIB_MKFIFO = @GNULIB_MKFIFO@
435461 GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
462 GNULIB_MKNOD = @GNULIB_MKNOD@
436463 GNULIB_MKNODAT = @GNULIB_MKNODAT@
437464 GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
465 GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
438466 GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
467 GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
439468 GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
440469 GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
441470 GNULIB_OPEN = @GNULIB_OPEN@
443472 GNULIB_PERROR = @GNULIB_PERROR@
444473 GNULIB_PIPE2 = @GNULIB_PIPE2@
445474 GNULIB_POPEN = @GNULIB_POPEN@
475 GNULIB_PREAD = @GNULIB_PREAD@
446476 GNULIB_PRINTF = @GNULIB_PRINTF@
447477 GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
448478 GNULIB_PUTC = @GNULIB_PUTC@
463493 GNULIB_ROUNDF = @GNULIB_ROUNDF@
464494 GNULIB_ROUNDL = @GNULIB_ROUNDL@
465495 GNULIB_RPMATCH = @GNULIB_RPMATCH@
496 GNULIB_SCANDIR = @GNULIB_SCANDIR@
466497 GNULIB_SETENV = @GNULIB_SETENV@
467498 GNULIB_SIGNBIT = @GNULIB_SIGNBIT@
499 GNULIB_SINL = @GNULIB_SINL@
468500 GNULIB_SLEEP = @GNULIB_SLEEP@
469501 GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
470502 GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
503 GNULIB_SQRTL = @GNULIB_SQRTL@
471504 GNULIB_STAT = @GNULIB_STAT@
472505 GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
473506 GNULIB_STPCPY = @GNULIB_STPCPY@
489522 GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
490523 GNULIB_SYMLINK = @GNULIB_SYMLINK@
491524 GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
525 GNULIB_TANL = @GNULIB_TANL@
492526 GNULIB_TRUNC = @GNULIB_TRUNC@
493527 GNULIB_TRUNCF = @GNULIB_TRUNCF@
494528 GNULIB_TRUNCL = @GNULIB_TRUNCL@
497531 GNULIB_UNLINK = @GNULIB_UNLINK@
498532 GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
499533 GNULIB_UNSETENV = @GNULIB_UNSETENV@
534 GNULIB_USLEEP = @GNULIB_USLEEP@
500535 GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
501536 GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
502537 GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
506541 GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
507542 GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
508543 GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
544 GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@
509545 GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
510546 GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
511547 GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
513549 GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
514550 GNULIB_WRITE = @GNULIB_WRITE@
515551 GREP = @GREP@
552 HAVE_ACOSL = @HAVE_ACOSL@
553 HAVE_ALPHASORT = @HAVE_ALPHASORT@
554 HAVE_ASINL = @HAVE_ASINL@
555 HAVE_ATANL = @HAVE_ATANL@
516556 HAVE_ATOLL = @HAVE_ATOLL@
517557 HAVE_BTOWC = @HAVE_BTOWC@
518558 HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@
519559 HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
560 HAVE_CHOWN = @HAVE_CHOWN@
561 HAVE_COSL = @HAVE_COSL@
520562 HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@
521563 HAVE_DECL_ASINL = @HAVE_DECL_ASINL@
522564 HAVE_DECL_ATANL = @HAVE_DECL_ATANL@
523565 HAVE_DECL_COSL = @HAVE_DECL_COSL@
566 HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
524567 HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
525568 HAVE_DECL_EXPL = @HAVE_DECL_EXPL@
526569 HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
553596 HAVE_DUP2 = @HAVE_DUP2@
554597 HAVE_DUP3 = @HAVE_DUP3@
555598 HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
599 HAVE_EXPL = @HAVE_EXPL@
556600 HAVE_FACCESSAT = @HAVE_FACCESSAT@
557601 HAVE_FCHMODAT = @HAVE_FCHMODAT@
558602 HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
559 HAVE_FSEEKO = @HAVE_FSEEKO@
603 HAVE_FCNTL = @HAVE_FCNTL@
604 HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
560605 HAVE_FSTATAT = @HAVE_FSTATAT@
561606 HAVE_FSYNC = @HAVE_FSYNC@
562 HAVE_FTELLO = @HAVE_FTELLO@
563607 HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
564608 HAVE_FUTIMENS = @HAVE_FUTIMENS@
565609 HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@
566610 HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
611 HAVE_GETGROUPS = @HAVE_GETGROUPS@
567612 HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
613 HAVE_GETLOGIN = @HAVE_GETLOGIN@
568614 HAVE_GETOPT_H = @HAVE_GETOPT_H@
569615 HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
570616 HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
575621 HAVE_ISNANL = @HAVE_ISNANL@
576622 HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
577623 HAVE_LCHMOD = @HAVE_LCHMOD@
624 HAVE_LCHOWN = @HAVE_LCHOWN@
578625 HAVE_LINK = @HAVE_LINK@
579626 HAVE_LINKAT = @HAVE_LINKAT@
627 HAVE_LOGL = @HAVE_LOGL@
580628 HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
581629 HAVE_LSTAT = @HAVE_LSTAT@
582630 HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@
583631 HAVE_MBRLEN = @HAVE_MBRLEN@
584632 HAVE_MBRTOWC = @HAVE_MBRTOWC@
585633 HAVE_MBSINIT = @HAVE_MBSINIT@
634 HAVE_MBSLEN = @HAVE_MBSLEN@
586635 HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
587636 HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
588637 HAVE_MEMPCPY = @HAVE_MEMPCPY@
589638 HAVE_MKDIRAT = @HAVE_MKDIRAT@
590639 HAVE_MKDTEMP = @HAVE_MKDTEMP@
640 HAVE_MKFIFO = @HAVE_MKFIFO@
591641 HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
642 HAVE_MKNOD = @HAVE_MKNOD@
592643 HAVE_MKNODAT = @HAVE_MKNODAT@
593644 HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
645 HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
646 HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
594647 HAVE_OPENAT = @HAVE_OPENAT@
595648 HAVE_OS_H = @HAVE_OS_H@
596649 HAVE_PIPE2 = @HAVE_PIPE2@
650 HAVE_PREAD = @HAVE_PREAD@
597651 HAVE_RANDOM_H = @HAVE_RANDOM_H@
598652 HAVE_RANDOM_R = @HAVE_RANDOM_R@
599653 HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
603657 HAVE_REALPATH = @HAVE_REALPATH@
604658 HAVE_RENAMEAT = @HAVE_RENAMEAT@
605659 HAVE_RPMATCH = @HAVE_RPMATCH@
660 HAVE_SCANDIR = @HAVE_SCANDIR@
606661 HAVE_SETENV = @HAVE_SETENV@
607662 HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
608663 HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
609664 HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
665 HAVE_SINL = @HAVE_SINL@
610666 HAVE_SLEEP = @HAVE_SLEEP@
667 HAVE_SQRTL = @HAVE_SQRTL@
611668 HAVE_STDINT_H = @HAVE_STDINT_H@
612669 HAVE_STPCPY = @HAVE_STPCPY@
613670 HAVE_STPNCPY = @HAVE_STPNCPY@
629686 HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
630687 HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
631688 HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
689 HAVE_TANL = @HAVE_TANL@
632690 HAVE_UNISTD_H = @HAVE_UNISTD_H@
633691 HAVE_UNLINKAT = @HAVE_UNLINKAT@
634692 HAVE_UNSETENV = @HAVE_UNSETENV@
635693 HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
694 HAVE_USLEEP = @HAVE_USLEEP@
636695 HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
637696 HAVE_VASPRINTF = @HAVE_VASPRINTF@
638697 HAVE_VDPRINTF = @HAVE_VDPRINTF@
667726 LTLIBOBJS = @LTLIBOBJS@
668727 MAKEINFO = @MAKEINFO@
669728 MKDIR_P = @MKDIR_P@
729 NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
670730 NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
671731 NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
672732 NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
683743 NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
684744 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
685745 NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
746 NEXT_DIRENT_H = @NEXT_DIRENT_H@
686747 NEXT_ERRNO_H = @NEXT_ERRNO_H@
687748 NEXT_FCNTL_H = @NEXT_FCNTL_H@
688749 NEXT_FLOAT_H = @NEXT_FLOAT_H@
718779 REPLACE_CEILL = @REPLACE_CEILL@
719780 REPLACE_CHOWN = @REPLACE_CHOWN@
720781 REPLACE_CLOSE = @REPLACE_CLOSE@
782 REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
721783 REPLACE_DPRINTF = @REPLACE_DPRINTF@
722784 REPLACE_DUP = @REPLACE_DUP@
723785 REPLACE_DUP2 = @REPLACE_DUP2@
724786 REPLACE_FCHDIR = @REPLACE_FCHDIR@
725787 REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
726788 REPLACE_FCLOSE = @REPLACE_FCLOSE@
789 REPLACE_FCNTL = @REPLACE_FCNTL@
790 REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
727791 REPLACE_FFLUSH = @REPLACE_FFLUSH@
728792 REPLACE_FLOORF = @REPLACE_FLOORF@
729793 REPLACE_FLOORL = @REPLACE_FLOORL@
741805 REPLACE_FTELLO = @REPLACE_FTELLO@
742806 REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
743807 REPLACE_GETCWD = @REPLACE_GETCWD@
808 REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
744809 REPLACE_GETLINE = @REPLACE_GETLINE@
745810 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
746811 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
765830 REPLACE_MEMCHR = @REPLACE_MEMCHR@
766831 REPLACE_MEMMEM = @REPLACE_MEMMEM@
767832 REPLACE_MKDIR = @REPLACE_MKDIR@
833 REPLACE_MKFIFO = @REPLACE_MKFIFO@
834 REPLACE_MKNOD = @REPLACE_MKNOD@
768835 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
769836 REPLACE_MKTIME = @REPLACE_MKTIME@
770837 REPLACE_NAN = @REPLACE_NAN@
773840 REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
774841 REPLACE_OPEN = @REPLACE_OPEN@
775842 REPLACE_OPENAT = @REPLACE_OPENAT@
843 REPLACE_OPENDIR = @REPLACE_OPENDIR@
776844 REPLACE_PERROR = @REPLACE_PERROR@
777845 REPLACE_POPEN = @REPLACE_POPEN@
846 REPLACE_PREAD = @REPLACE_PREAD@
778847 REPLACE_PRINTF = @REPLACE_PRINTF@
779848 REPLACE_PUTENV = @REPLACE_PUTENV@
780849 REPLACE_READLINK = @REPLACE_READLINK@
786855 REPLACE_ROUND = @REPLACE_ROUND@
787856 REPLACE_ROUNDF = @REPLACE_ROUNDF@
788857 REPLACE_ROUNDL = @REPLACE_ROUNDL@
858 REPLACE_SETENV = @REPLACE_SETENV@
789859 REPLACE_SIGNBIT = @REPLACE_SIGNBIT@
790860 REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@
861 REPLACE_SLEEP = @REPLACE_SLEEP@
791862 REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
792863 REPLACE_SPRINTF = @REPLACE_SPRINTF@
793864 REPLACE_STAT = @REPLACE_STAT@
806877 REPLACE_TRUNCL = @REPLACE_TRUNCL@
807878 REPLACE_UNLINK = @REPLACE_UNLINK@
808879 REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
880 REPLACE_UNSETENV = @REPLACE_UNSETENV@
881 REPLACE_USLEEP = @REPLACE_USLEEP@
809882 REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
810883 REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
811884 REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
834907 UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
835908 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
836909 VERSION = @VERSION@
837 VOID_UNSETENV = @VOID_UNSETENV@
838 WCHAR_H = @WCHAR_H@
910 WARN_CFLAGS = @WARN_CFLAGS@
839911 WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
840912 WCTYPE_H = @WCTYPE_H@
913 WERROR_CFLAGS = @WERROR_CFLAGS@
841914 WINT_T_SUFFIX = @WINT_T_SUFFIX@
842915 abs_builddir = @abs_builddir@
843916 abs_srcdir = @abs_srcdir@
896969 SUBDIRS = lib doc
897970 ACLOCAL_AMFLAGS = -I m4
898971 AM_CPPFLAGS = -I$(top_srcdir)/lib
972 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
899973 man_MANS = gunzip.1 gzexe.1 gzip.1 \
900974 zcat.1 zcmp.1 zdiff.1 zforce.1 zgrep.1 zless.1 zmore.1 znew.1
901975
915989 sample/zfile tailor.h vms/Makefile.mms vms/gzip.hlp vms/vms.c \
916990 vms/Readme.vms vms/Makefile.vms vms/Makefile.gcc \
917991 vms/makegzip.com zcat.in zcmp.in zdiff.in zegrep.in zfgrep.in \
918 zforce.in zgrep.in zless.in zmore.in znew.in tests/test-lib.sh \
992 zforce.in zgrep.in zless.in zmore.in znew.in tests/init.sh \
919993 $(TESTS)
920994 bin_SCRIPTS = gunzip gzexe zcat zcmp zdiff \
921995 zegrep zfgrep zforce zgrep zless zmore znew
9331007 $(top_srcdir)/ChangeLog $(top_srcdir)/configure $(top_srcdir)/gzip.c
9341008
9351009 TESTS = \
1010 tests/helin-segv \
1011 tests/memcpy-abuse \
9361012 tests/trailing-nul \
9371013 tests/zdiff \
9381014 tests/zgrep-f
14841560 else echo $$f; fi; \
14851561 done | tr '\012\015' ' '`; \
14861562 $(MAKE) $(AM_MAKEFLAGS) $$target AM_MAKEFLAGS='$(AM_MAKEFLAGS) TEST_LOGS="'"$$list"'"'
1563 tests/helin-segv.log: tests/helin-segv
1564 @p='tests/helin-segv'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
1565 tests/memcpy-abuse.log: tests/memcpy-abuse
1566 @p='tests/memcpy-abuse'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
14871567 tests/trailing-nul.log: tests/trailing-nul
14881568 @p='tests/trailing-nul'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
14891569 tests/zdiff.log: tests/zdiff
15721652 top_distdir="$(top_distdir)" distdir="$(distdir)" \
15731653 dist-hook
15741654 -test -n "$(am__skip_mode_fix)" \
1575 || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
1655 || find "$(distdir)" -type d ! -perm -755 \
1656 -exec chmod u+rwx,go+rx {} \; -o \
15761657 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
15771658 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
15781659 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
16151696 distcheck: dist
16161697 case '$(DIST_ARCHIVES)' in \
16171698 *.tar.gz*) \
1618 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
1699 GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
16191700 *.tar.bz2*) \
1620 bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
1701 bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
16211702 *.tar.lzma*) \
1622 unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
1703 lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
16231704 *.tar.xz*) \
16241705 xz -dc $(distdir).tar.xz | $(am__untar) ;;\
16251706 *.tar.Z*) \
16261707 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
16271708 *.shar.gz*) \
1628 GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
1709 GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
16291710 *.zip*) \
16301711 unzip $(distdir).zip ;;\
16311712 esac
00 GNU gzip NEWS -*- outline -*-
1
2 * Noteworthy changes in release 1.4 (2010-01-20) [stable]
3
4 ** Bug fixes
5
6 gzip -d could segfault and/or clobber the stack, possibly leading to
7 arbitrary code execution. This affects x86_64 but not 32-bit systems.
8 This fixes CVE-2010-0001.
9 For more details, see http://bugzilla.redhat.com/554418
10
11 gzip -d would fail with a CRC error for some valid inputs.
12 So far, the only valid input known to exhibit this failure was
13 compressed "from FAT filesystem (MS-DOS, OS/2, NT)". In addition,
14 to trigger the failure, your memcpy implementation must copy in
15 the "reverse" order.
16
117
218 * Noteworthy changes in release 1.3.14 (2009-10-30) [beta]
319
366382
367383 ========================================================================
368384
369 Copyright (C) 1999, 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
385 Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2010 Free Software Foundation,
386 Inc.
370387 Copyright (C) 1992, 1993 Jean-loup Gailly
371388
372389 Permission is granted to copy, distribute and/or modify this document
125125
126126 ========================================================================
127127
128 Copyright (C) 1999, 2001-2002, 2006-2007, 2009 Free Software Foundation, Inc.
128 Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2010 Free Software Foundation,
129 Inc.
129130 Copyright (C) 1992, 1993 Jean-loup Gailly
130131
131132 Permission is granted to copy, distribute and/or modify this document
9696 Darrel R. Hankerson hankedr@mail.auburn.edu
9797 Mark Hanning-Lee markhl@romeo.caltech.edu
9898 Lars Hecking st000002@hrz1.hrz.th-darmstadt.de
99 Aki Helin aki.helin@iki.fi
99100 Ruediger Helsch ruediger@ramz.ing.tu-bs.de
100101 Mark C. Henderson mch@sqwest.wimsey.bc.ca
101102 Karl Heuer karl@kelp.boston.ma.us
7171
7272 ========================================================================
7373
74 Copyright (C) 1999, 2001, 2006, 2009 Free Software Foundation, Inc.
74 Copyright (C) 1999, 2001, 2006, 2009-2010 Free Software Foundation, Inc.
7575 Copyright (C) 1992, 1993 Jean-loup Gailly
7676
7777 Permission is granted to copy, distribute and/or modify this document
00 # generated automatically by aclocal 1.11a -*- Autoconf -*-
11
22 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
66 # with or without modifications, as long as this notice is preserved.
1212
1313 m4_ifndef([AC_AUTOCONF_VERSION],
1414 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
15 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64.69-81c80],,
16 [m4_warning([this file was generated for autoconf 2.64.69-81c80.
15 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65.23-13e35],,
16 [m4_warning([this file was generated for autoconf 2.65.23-13e35.
1717 You have another version of autoconf. It may work, but is not guaranteed to.
1818 If you have problems, you may need to regenerate the build system entirely.
1919 To do so, use the procedure documented by the package, typically `autoreconf'.])])
14671467 m4_include([m4/00gnulib.m4])
14681468 m4_include([m4/alloca.m4])
14691469 m4_include([m4/calloc.m4])
1470 m4_include([m4/chdir-long.m4])
1471 m4_include([m4/chown.m4])
14701472 m4_include([m4/clock_time.m4])
14711473 m4_include([m4/close-stream.m4])
14721474 m4_include([m4/close.m4])
14731475 m4_include([m4/closein.m4])
14741476 m4_include([m4/closeout.m4])
14751477 m4_include([m4/codeset.m4])
1478 m4_include([m4/d-ino.m4])
1479 m4_include([m4/dirent_h.m4])
1480 m4_include([m4/dirfd.m4])
1481 m4_include([m4/dirname.m4])
14761482 m4_include([m4/dos.m4])
1483 m4_include([m4/double-slash-root.m4])
14771484 m4_include([m4/dup2.m4])
14781485 m4_include([m4/errno_h.m4])
14791486 m4_include([m4/error.m4])
14821489 m4_include([m4/exponentf.m4])
14831490 m4_include([m4/exponentl.m4])
14841491 m4_include([m4/extensions.m4])
1492 m4_include([m4/fchdir.m4])
14851493 m4_include([m4/fclose.m4])
1494 m4_include([m4/fcntl-o.m4])
14861495 m4_include([m4/fcntl-safer.m4])
1496 m4_include([m4/fcntl.m4])
14871497 m4_include([m4/fcntl_h.m4])
1498 m4_include([m4/fdopendir.m4])
14881499 m4_include([m4/fflush.m4])
14891500 m4_include([m4/float_h.m4])
14901501 m4_include([m4/fpending.m4])
14961507 m4_include([m4/frexpl.m4])
14971508 m4_include([m4/fseeko.m4])
14981509 m4_include([m4/ftello.m4])
1510 m4_include([m4/getcwd-abort-bug.m4])
1511 m4_include([m4/getcwd-path-max.m4])
1512 m4_include([m4/getcwd.m4])
14991513 m4_include([m4/getopt.m4])
1500 m4_include([m4/getpagesize.m4])
15011514 m4_include([m4/gettime.m4])
15021515 m4_include([m4/gettimeofday.m4])
15031516 m4_include([m4/glibc21.m4])
15111524 m4_include([m4/isnand.m4])
15121525 m4_include([m4/isnanf.m4])
15131526 m4_include([m4/isnanl.m4])
1527 m4_include([m4/lchown.m4])
15141528 m4_include([m4/ldexpl.m4])
15151529 m4_include([m4/localcharset.m4])
15161530 m4_include([m4/locale-fr.m4])
15201534 m4_include([m4/lseek.m4])
15211535 m4_include([m4/lstat.m4])
15221536 m4_include([m4/malloc.m4])
1537 m4_include([m4/manywarnings.m4])
15231538 m4_include([m4/math_h.m4])
15241539 m4_include([m4/mbrtowc.m4])
15251540 m4_include([m4/mbsinit.m4])
15261541 m4_include([m4/mbstate_t.m4])
15271542 m4_include([m4/memchr.m4])
1543 m4_include([m4/mempcpy.m4])
1544 m4_include([m4/memrchr.m4])
1545 m4_include([m4/mkdir.m4])
15281546 m4_include([m4/mmap-anon.m4])
15291547 m4_include([m4/mode_t.m4])
15301548 m4_include([m4/multiarch.m4])
15311549 m4_include([m4/nocrash.m4])
15321550 m4_include([m4/open.m4])
1551 m4_include([m4/openat.m4])
15331552 m4_include([m4/perror.m4])
15341553 m4_include([m4/printf-frexp.m4])
15351554 m4_include([m4/printf-frexpl.m4])
15371556 m4_include([m4/printf.m4])
15381557 m4_include([m4/quotearg.m4])
15391558 m4_include([m4/realloc.m4])
1559 m4_include([m4/rmdir.m4])
1560 m4_include([m4/save-cwd.m4])
15401561 m4_include([m4/shell.m4])
15411562 m4_include([m4/signbit.m4])
15421563 m4_include([m4/size_max.m4])
15481569 m4_include([m4/stdint_h.m4])
15491570 m4_include([m4/stdio_h.m4])
15501571 m4_include([m4/stdlib_h.m4])
1572 m4_include([m4/strdup.m4])
15511573 m4_include([m4/strerror.m4])
15521574 m4_include([m4/string_h.m4])
15531575 m4_include([m4/sys_stat_h.m4])
15561578 m4_include([m4/timespec.m4])
15571579 m4_include([m4/unistd-safer.m4])
15581580 m4_include([m4/unistd_h.m4])
1581 m4_include([m4/unlink.m4])
15591582 m4_include([m4/utimbuf.m4])
15601583 m4_include([m4/utimens.m4])
15611584 m4_include([m4/utimes.m4])
15621585 m4_include([m4/vasnprintf.m4])
15631586 m4_include([m4/vfprintf-posix.m4])
1587 m4_include([m4/warn-on-use.m4])
1588 m4_include([m4/warnings.m4])
15641589 m4_include([m4/wchar.m4])
15651590 m4_include([m4/wchar_t.m4])
15661591 m4_include([m4/wctype.m4])
15671592 m4_include([m4/wint_t.m4])
15681593 m4_include([m4/xalloc.m4])
1594 m4_include([m4/xgetcwd.m4])
15691595 m4_include([m4/xsize.m4])
15701596 m4_include([m4/yesno.m4])
00 /* bits.c -- output variable-length bit strings
11
2 Copyright (C) 1999, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1999, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
22 if 0;
33 # Generate a release announcement message.
44
5 my $VERSION = '2009-10-30 15:59'; # UTC
5 my $VERSION = '2009-11-20 13:36'; # UTC
66 # The definition above must lie within the first 8 lines in order
77 # for the Emacs time-stamp write hook (at end) to update it.
88 # If you change this file with Emacs, please let the write hook
99 # do its job. Otherwise, update this string manually.
1010
11 # Copyright (C) 2002-2009 Free Software Foundation, Inc.
11 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
1212
1313 # This program is free software: you can redistribute it and/or modify
1414 # it under the terms of the GNU General Public License as published by
441441 my @sig_files = map { "$_.sig" } @tarballs;
442442 print_locations ("GPG detached signatures[*]", @url_dir_list, %size,
443443 @sig_files);
444 if ($url_dir_list[0] =~ "gnu\.org")
445 {
446 print "To reduce load on the main server, use a mirror listed at:\n";
447 print " http://www.gnu.org/order/ftp.html\n\n";
448 }
444449
445450 $print_checksums_p
446451 and print_checksums (@sizable);
0 /* -*- buffer-read-only: t -*- vi: set ro: */
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A C macro for declaring that specific arguments must not be NULL.
3 Copyright (C) 2009, 2010 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 General Public License as published
7 by 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 GNU
13 Lesser 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 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
19 that the values passed as arguments n, ..., m must be non-NULL pointers.
20 n = 1 stands for the first argument, n = 2 for the second argument etc. */
21 #ifndef _GL_ARG_NONNULL
22 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
23 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
24 # else
25 # define _GL_ARG_NONNULL(params)
26 # endif
27 #endif
00 #! /bin/sh
11 # Attempt to guess a canonical system name.
22 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
44 # Free Software Foundation, Inc.
55
6 timestamp='2009-09-18'
6 timestamp='2009-12-30'
77
88 # This file is free software; you can redistribute it and/or modify it
99 # under the terms of the GNU General Public License as published by
5555 GNU config.guess ($timestamp)
5656
5757 Originally written by Per Bothner.
58 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
59 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
58 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
59 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
60 Software Foundation, Inc.
6061
6162 This is free software; see the source for copying conditions. There is NO
6263 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
332333 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
333334 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
334335 exit ;;
336 i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
337 echo i386-pc-auroraux${UNAME_RELEASE}
338 exit ;;
335339 i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
336340 eval $set_cc_for_build
337341 SUN_ARCH="i386"
806810 i*:PW*:*)
807811 echo ${UNAME_MACHINE}-pc-pw32
808812 exit ;;
809 *:Interix*:[3456]*)
813 *:Interix*:*)
810814 case ${UNAME_MACHINE} in
811815 x86)
812816 echo i586-pc-interix${UNAME_RELEASE}
813817 exit ;;
814 EM64T | authenticamd | genuineintel)
818 authenticamd | genuineintel | EM64T)
815819 echo x86_64-unknown-interix${UNAME_RELEASE}
816820 exit ;;
817821 IA64)
890894 echo frv-unknown-linux-gnu
891895 exit ;;
892896 i*86:Linux:*:*)
893 echo ${UNAME_MACHINE}-pc-linux-gnu
897 LIBC=gnu
898 eval $set_cc_for_build
899 sed 's/^ //' << EOF >$dummy.c
900 #ifdef __dietlibc__
901 LIBC=dietlibc
902 #endif
903 EOF
904 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
905 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
894906 exit ;;
895907 ia64:Linux:*:*)
896908 echo ${UNAME_MACHINE}-unknown-linux-gnu
917929 #endif
918930 #endif
919931 EOF
920 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
921 /^CPU/{
922 s: ::g
923 p
924 }'`"
932 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
925933 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
926934 ;;
927935 or32:Linux:*:*)
00 #! /bin/sh
11 # Configuration validation subroutine script.
22 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
44 # Free Software Foundation, Inc.
55
6 timestamp='2009-10-07'
6 timestamp='2009-12-31'
77
88 # This file is (in principle) common to ALL GNU software.
99 # The presence of a machine in this file suggests that SOME GNU software
7474 version="\
7575 GNU config.sub ($timestamp)
7676
77 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
78 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
77 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
78 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
79 Software Foundation, Inc.
7980
8081 This is free software; see the source for copying conditions. There is NO
8182 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
294295 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
295296 | spu | strongarm \
296297 | tahoe | thumb | tic4x | tic80 | tron \
298 | ubicom32 \
297299 | v850 | v850e \
298300 | we32k \
299301 | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
380382 | tahoe-* | thumb-* \
381383 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
382384 | tron-* \
385 | ubicom32-* \
383386 | v850-* | v850e-* | vax-* \
384387 | we32k-* \
385388 | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
12531256 # First match some system type aliases
12541257 # that might get confused with valid system types.
12551258 # -solaris* is a basic system type, with this one exception.
1259 -auroraux)
1260 os=-auroraux
1261 ;;
12561262 -solaris1 | -solaris1.*)
12571263 os=`echo $os | sed -e 's|solaris1|sunos4|'`
12581264 ;;
12741280 # -sysv* is not here because it comes later, after sysvr4.
12751281 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
12761282 | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
1277 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
1278 | -kopensolaris* \
1283 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
1284 | -sym* | -kopensolaris* \
12791285 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
12801286 | -aos* | -aros* \
12811287 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
14291435 -dicos*)
14301436 os=-dicos
14311437 ;;
1438 -nacl*)
1439 ;;
14321440 -none)
14331441 ;;
14341442 *)
0 #!/bin/sh
0 #!/bin/sh -e
11 # gendocs.sh -- generate a GNU manual in many formats. This script is
22 # mentioned in maintain.texi. See the help message below for usage details.
33
4 scriptversion=2009-09-09.22
5
6 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 scriptversion=2010-01-02.16
5
6 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
77 # Free Software Foundation, Inc.
88 #
99 # This program is free software: you can redistribute it and/or modify
267267 fi
268268
269269 echo Making .tar.gz for sources...
270 srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null`
270 srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null` || true
271271 tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles
272272 texi_tgz_size=`calcsize $outdir/$PACKAGE.texi.tar.gz`
273273
88 # If you change this file with Emacs, please let the write hook
99 # do its job. Otherwise, update this string manually.
1010
11 # Copyright (C) 2008, 2009 Free Software Foundation, Inc.
11 # Copyright (C) 2008-2010 Free Software Foundation, Inc.
1212
1313 # This program is free software: you can redistribute it and/or modify
1414 # it under the terms of the GNU General Public License as published by
88
99 VERSION=2009-07-21.16; # UTC
1010
11 # Copyright (C) 2009 Free Software Foundation, Inc.
11 # Copyright (C) 2009, 2010 Free Software Foundation, Inc.
1212
1313 # This program is free software: you can redistribute it and/or modify
1414 # it under the terms of the GNU General Public License as published by
00 #!/bin/sh
11 # Sign files and upload them.
22
3 scriptversion=2009-04-28.21; # UTC
3 scriptversion=2009-12-21.21; # UTC
44
55 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
66 #
7272 (#) and empty lines in $conffile are allowed.
7373
7474 Examples:
75 1. Upload automake-1.8.2b.tar.gz and automake-1.8.2b.tar.bz2 to two sites:
76 gnupload --to sources.redhat.com:~ftp/pub/automake \\
77 --to alpha.gnu.org:automake \\
78 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
79
80 2. Same as above, but also create symbolic links to automake-latest.tar.*:
81 gnupload --to sources.redhat.com:~ftp/pub/automake \\
82 --to alpha.gnu.org:automake \\
75 1. Upload foobar-1.0.tar.gz to ftp.gnu.org:
76 gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz
77
78 2. Upload foobar-1.0.tar.gz and foobar-1.0.tar.xz to ftp.gnu.org:
79 gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz foobar-1.0.tar.xz
80
81 3. Same as above, and also create symbolic links to foobar-latest.tar.*:
82 gnupload --to ftp.gnu.org:foobar \\
8383 --symlink-regex \\
84 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
85
86 3. Symlink automake-1.8.2b.tar.gz to automake-latest.tar.gz and
87 automake-1.8.2b.tar.bz2 to automake-latest.tar.bz2 on both sites:
88
89 gnupload --to sources.redhat.com:~ftp/pub/automake \\
90 --to alpha.gnu.org:automake \\
91 --symlink automake-1.8.2b.tar.gz automake-latest.tar.gz \\
92 automake-1.8.2b.tar.bz2 automake-latest.tar.bz2
93
94 4. Delete automake-1.8.2a.tar.gz and .bz2, remove symlink
95 automake-latest.tar.gz and upload automake-1.8.2b.tar.gz:
96
97 gnupload --to sources.redhat.com:~ftp/pub/automake \\
98 --to alpha.gnu.org:automake \\
99 --delete automake-1.8.2a.tar.gz automake-1.8.2a.tar.bz2 \\
100 --rmsymlink automake-latest.tar.gz \\
101 -- \\
102 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
84 foobar-1.0.tar.gz foobar-1.0.tar.xz
85
86 4. Upload foobar-0.9.90.tar.gz to two sites:
87 gnupload --to alpha.gnu.org:foobar \\
88 --to sources.redhat.com:~ftp/pub/foobar \\
89 foobar-0.9.90.tar.gz
90
91 5. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz
92 (the -- terminates the list of files to delete):
93 gnupload --to alpha.gnu.org:foobar \\
94 --to sources.redhat.com:~ftp/pub/foobar \\
95 --delete oopsbar-0.9.91.tar.gz \\
96 -- foobar-0.9.91.tar.gz
97
98 gnupload uses the ncftpput program to do the transfers; if you don't
99 happen to have an ncftp package installed, the ncftpput-ftp script in
100 the build-aux/ directory of the gnulib package
101 (http://savannah.gnu.org/projects/gnulib) may serve as a replacement.
103102
104103 Report bugs to <bug-automake@gnu.org>.
105104 Send patches to <automake-patches@gnu.org>."
0 /* -*- buffer-read-only: t -*- vi: set ro: */
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A C macro for emitting link time warnings.
3 Copyright (C) 1995, 1997, 2000, 2002-2003, 2007, 2009-2010 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
8 by 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 GNU
14 Lesser 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
019 /* GL_LINK_WARNING("literal string") arranges to emit the literal string as
120 a linker warning on most glibc systems.
221 We use a linker warning rather than a preprocessor warning, because
1433 # define GL_LINK_WARNING2(file, line, message) \
1534 GL_LINK_WARNING3 (file ":" #line ": warning: " message)
1635 # define GL_LINK_WARNING3(message) \
17 ({ static const char warning[sizeof (message)] \
18 __attribute__ ((__unused__, \
19 __section__ (".gnu.warning"), \
20 __aligned__ (1))) \
21 = message "\n"; \
22 (void)0; \
36 ({ static const char warning[sizeof (message)] \
37 __attribute__ ((__unused__, \
38 __section__ (".gnu.warning"), \
39 __aligned__ (1))) \
40 = message "\n"; \
41 (void)0; \
2342 })
2443 # else
2544 # define GL_LINK_WARNING(message) ((void) 0)
22 if 0;
33 # Update an FSF copyright year list to include the current year.
44
5 my $VERSION = '2009-10-30.15:57'; # UTC
6
7 # Copyright (C) 2009 Free Software Foundation, Inc.
5 my $VERSION = '2009-12-28.11:09'; # UTC
6
7 # Copyright (C) 2009-2010 Free Software Foundation, Inc.
88 #
99 # This program is free software: you can redistribute it and/or modify
1010 # it under the terms of the GNU General Public License as published by
113113 # are expanded instead.
114114 # 3. For testing purposes, you can set the assumed current year in
115115 # UPDATE_COPYRIGHT_YEAR.
116 # 4. The default maximum line length for a copyright line is 72.
117 # Set UPDATE_COPYRIGHT_MAX_LINE_LENGTH to use a different length.
116118
117119 use strict;
118120 use warnings;
121123 my $circle_c_re = '(?:\([cC]\)|@copyright{}|&copy;)';
122124 my $holder = 'Free Software Foundation, Inc.';
123125 my $prefix_max = 5;
124 my $margin = 72;
126 my $margin = $ENV{UPDATE_COPYRIGHT_MAX_LINE_LENGTH};
127 !$margin || $margin !~ m/^\d+$/
128 and $margin = 72;
129
125130 my $tab_width = 8;
126131
127132 my $this_year = $ENV{UPDATE_COPYRIGHT_YEAR};
1111 # If you change this file with Emacs, please let the write hook
1212 # do its job. Otherwise, update this string manually.
1313
14 # Copyright (C) 2008, 2009 Free Software Foundation, Inc.
14 # Copyright (C) 2008-2010 Free Software Foundation, Inc.
1515
1616 # This program is free software: you can redistribute it and/or modify
1717 # it under the terms of the GNU General Public License as published by
33 # Print a version string.
44 scriptversion=2009-07-21.16; # UTC
55
6 # Copyright (C) 2006-2009 Free Software Foundation, Inc.
6 # Copyright (C) 2006-2010 Free Software Foundation, Inc.
77
88 # This program is free software: you can redistribute it and/or modify
99 # it under the terms of the GNU General Public License as published by
0 /* -*- buffer-read-only: t -*- vi: set ro: */
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A C macro for emitting warnings if a function is used.
3 Copyright (C) 2010 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 General Public License as published
7 by 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 GNU
13 Lesser 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 /* _GL_WARN_ON_USE(function, "literal string") issues a declaration
19 for FUNCTION which will then trigger a compiler warning containing
20 the text of "literal string" anywhere that function is called, if
21 supported by the compiler. If the compiler does not support this
22 feature, the macro expands to an unused extern declaration.
23
24 This macro is useful for marking a function as a potential
25 portability trap, with the intent that "literal string" include
26 instructions on the replacement function that should be used
27 instead. However, one of the reasons that a function is a
28 portability trap is if it has the wrong signature. Declaring
29 FUNCTION with a different signature in C is a compilation error, so
30 this macro must use the same type as any existing declaration so
31 that programs that avoid the problematic FUNCTION do not fail to
32 compile merely because they included a header that poisoned the
33 function. But this implies that _GL_WARN_ON_USE is only safe to
34 use if FUNCTION is known to already have a declaration. Use of
35 this macro implies that there must not be any other macro hiding
36 the declaration of FUNCTION; but undefining FUNCTION first is part
37 of the poisoning process anyway (although for symbols that are
38 provided only via a macro, the result is a compilation error rather
39 than a warning containing "literal string"). Also note that in
40 C++, it is only safe to use if FUNCTION has no overloads.
41
42 For an example, it is possible to poison 'getline' by:
43 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
44 [getline]) in configure.ac, which potentially defines
45 HAVE_RAW_DECL_GETLINE
46 - adding this code to a header that wraps the system <stdio.h>:
47 #undef getline
48 #if HAVE_RAW_DECL_GETLINE
49 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
50 "not universally present; use the gnulib module getline");
51 #endif
52
53 It is not possible to directly poison global variables. But it is
54 possible to write a wrapper accessor function, and poison that
55 (less common usage, like &environ, will cause a compilation error
56 rather than issue the nice warning, but the end result of informing
57 the developer about their portability problem is still achieved):
58 #if HAVE_RAW_DECL_ENVIRON
59 static inline char ***rpl_environ (void) { return &environ; }
60 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
61 # undef environ
62 # define environ (*rpl_environ ())
63 #endif
64 */
65 #ifndef _GL_WARN_ON_USE
66
67 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
68 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
69 # define _GL_WARN_ON_USE(function, message) \
70 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
71
72 # else /* Unsupported. */
73 # define _GL_WARN_ON_USE(function, message) \
74 extern int _gl_warn_on_use
75 # endif
76 #endif
+4310
-1138
configure less more
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.64.69-81c80 for gzip 1.3.14.
2 # Generated by GNU Autoconf 2.65.23-13e35 for gzip 1.4.
33 #
44 # Report bugs to <bug-gzip@gnu.org>.
55 #
66 #
77 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
8 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
9 # Inc.
8 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
9 # Foundation, Inc.
1010 #
1111 #
1212 # This configure script is free software; the Free Software Foundation
551551 # Identity of this package.
552552 PACKAGE_NAME='gzip'
553553 PACKAGE_TARNAME='gzip'
554 PACKAGE_VERSION='1.3.14'
555 PACKAGE_STRING='gzip 1.3.14'
554 PACKAGE_VERSION='1.4'
555 PACKAGE_STRING='gzip 1.4'
556556 PACKAGE_BUGREPORT='bug-gzip@gnu.org'
557557 PACKAGE_URL=''
558558
608608 LIBOBJS
609609 ASCPPFLAGS
610610 ASCPPPOST
611 GNULIB_WARN_CFLAGS
612 WERROR_CFLAGS
611613 LIBGZIP_LTLIBDEPS
612614 LIBGZIP_LIBDEPS
613615 REPLACE_ISWCNTRL
616618 NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H
617619 NEXT_WCTYPE_H
618620 HAVE_ISWCNTRL
621 HAVE_WINT_T
622 HAVE_WCHAR_H
619623 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H
620624 NEXT_WCHAR_H
621 HAVE_WCHAR_H
622 HAVE_WINT_T
625 WARN_CFLAGS
623626 HAVE_UNISTD_H
624627 NEXT_AS_FIRST_DIRECTIVE_UNISTD_H
625628 NEXT_UNISTD_H
698701 HAVE_DECL_MEMRCHR
699702 HAVE_MEMPCPY
700703 HAVE_DECL_MEMMEM
704 HAVE_MBSLEN
701705 GNULIB_STRVERSCMP
702706 GNULIB_STRSIGNAL
703707 GNULIB_STRERROR
734738 LOCALE_FR_UTF8
735739 LOCALE_ZH_CN
736740 LOCALE_JA
737 WCHAR_H
738741 REPLACE_WCWIDTH
739742 REPLACE_WCSNRTOMBS
740743 REPLACE_WCSRTOMBS
771774 GNULIB_BTOWC
772775 NEXT_AS_FIRST_DIRECTIVE_MATH_H
773776 NEXT_MATH_H
774 REPLACE_UTIMENSAT
775 REPLACE_STAT
776 REPLACE_MKDIR
777 REPLACE_LSTAT
778 REPLACE_FUTIMENS
779 REPLACE_FSTATAT
780 REPLACE_FSTAT
781 HAVE_UTIMENSAT
782 HAVE_MKNODAT
783 HAVE_MKFIFOAT
784 HAVE_MKDIRAT
785 HAVE_LSTAT
786 HAVE_LCHMOD
787 HAVE_FUTIMENS
788 HAVE_FSTATAT
789 HAVE_FCHMODAT
790 GNULIB_UTIMENSAT
791 GNULIB_STAT
792 GNULIB_MKNODAT
793 GNULIB_MKFIFOAT
794 GNULIB_MKDIRAT
795 GNULIB_LSTAT
796 GNULIB_LCHMOD
797 GNULIB_FUTIMENS
798 GNULIB_FSTATAT
799 GNULIB_FCHMODAT
800777 LOCALCHARSET_TESTS_ENVIRONMENT
801778 GLIBC21
802779 GNU_MAKE_FALSE
844821 HAVE_DECL_ATANL
845822 HAVE_DECL_ASINL
846823 HAVE_DECL_ACOSL
824 HAVE_TANL
825 HAVE_SQRTL
826 HAVE_SINL
827 HAVE_LOGL
847828 HAVE_ISNANL
848829 HAVE_ISNAND
849830 HAVE_ISNANF
831 HAVE_EXPL
832 HAVE_COSL
833 HAVE_ATANL
834 HAVE_ASINL
835 HAVE_ACOSL
850836 GNULIB_TRUNCL
851837 GNULIB_TRUNCF
852838 GNULIB_TRUNC
839 GNULIB_TANL
840 GNULIB_SQRTL
841 GNULIB_SINL
853842 GNULIB_SIGNBIT
854843 GNULIB_ROUNDL
855844 GNULIB_ROUNDF
856845 GNULIB_ROUND
857 GNULIB_MATHL
846 GNULIB_LOGL
858847 GNULIB_LDEXPL
859848 GNULIB_ISNANL
860849 GNULIB_ISNAND
866855 GNULIB_FREXP
867856 GNULIB_FLOORL
868857 GNULIB_FLOORF
858 GNULIB_EXPL
859 GNULIB_COSL
869860 GNULIB_CEILL
870861 GNULIB_CEILF
862 GNULIB_ATANL
863 GNULIB_ASINL
864 GNULIB_ACOSL
871865 APPLE_UNIVERSAL_BUILD
872866 FLOAT_H
873867 NEXT_AS_FIRST_DIRECTIVE_FLOAT_H
874868 NEXT_FLOAT_H
875 FCNTL_H
876869 NEXT_AS_FIRST_DIRECTIVE_FCNTL_H
877870 NEXT_FCNTL_H
878 REPLACE_OPENAT
879 REPLACE_OPEN
880 HAVE_OPENAT
881 GNULIB_OPENAT
882 GNULIB_OPEN
883871 REPLACE_VSPRINTF
884872 REPLACE_VSNPRINTF
885873 REPLACE_VPRINTF
911899 HAVE_VDPRINTF
912900 HAVE_VASPRINTF
913901 HAVE_RENAMEAT
914 HAVE_FTELLO
915 HAVE_FSEEKO
916902 HAVE_DPRINTF
917903 HAVE_DECL_VSNPRINTF
918904 HAVE_DECL_SNPRINTF
960946 GNULIB_FFLUSH
961947 GNULIB_FCLOSE
962948 GNULIB_DPRINTF
949 REPLACE_OPENAT
950 REPLACE_OPEN
951 REPLACE_FCNTL
952 HAVE_OPENAT
953 HAVE_FCNTL
954 GNULIB_OPENAT
955 GNULIB_OPEN
956 GNULIB_FCNTL
957 REPLACE_UTIMENSAT
958 REPLACE_STAT
959 REPLACE_MKNOD
960 REPLACE_MKFIFO
961 REPLACE_MKDIR
962 REPLACE_LSTAT
963 REPLACE_FUTIMENS
964 REPLACE_FSTATAT
965 REPLACE_FSTAT
966 HAVE_UTIMENSAT
967 HAVE_MKNODAT
968 HAVE_MKNOD
969 HAVE_MKFIFOAT
970 HAVE_MKFIFO
971 HAVE_MKDIRAT
972 HAVE_LSTAT
973 HAVE_LCHMOD
974 HAVE_FUTIMENS
975 HAVE_FSTATAT
976 HAVE_FCHMODAT
977 GNULIB_UTIMENSAT
978 GNULIB_STAT
979 GNULIB_MKNODAT
980 GNULIB_MKNOD
981 GNULIB_MKFIFOAT
982 GNULIB_MKFIFO
983 GNULIB_MKDIRAT
984 GNULIB_LSTAT
985 GNULIB_LCHMOD
986 GNULIB_FUTIMENS
987 GNULIB_FSTATAT
988 GNULIB_FCHMODAT
963989 EOVERFLOW_VALUE
964990 EOVERFLOW_HIDDEN
965991 ENOLINK_VALUE
969995 ERRNO_H
970996 NEXT_AS_FIRST_DIRECTIVE_ERRNO_H
971997 NEXT_ERRNO_H
998 NEXT_AS_FIRST_DIRECTIVE_DIRENT_H
999 NEXT_DIRENT_H
9721000 PRAGMA_SYSTEM_HEADER
9731001 INCLUDE_NEXT_AS_FIRST_DIRECTIVE
9741002 INCLUDE_NEXT
1003 REPLACE_OPENDIR
1004 REPLACE_FDOPENDIR
1005 REPLACE_CLOSEDIR
1006 HAVE_ALPHASORT
1007 HAVE_SCANDIR
1008 HAVE_FDOPENDIR
1009 HAVE_DECL_DIRFD
1010 GNULIB_ALPHASORT
1011 GNULIB_SCANDIR
1012 GNULIB_FDOPENDIR
1013 GNULIB_DIRFD
1014 LIB_CLOCK_GETTIME
9751015 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS
9761016 UNISTD_H_HAVE_WINSOCK2_H
9771017 REPLACE_WRITE
1018 REPLACE_USLEEP
9781019 REPLACE_UNLINKAT
9791020 REPLACE_UNLINK
9801021 REPLACE_SYMLINK
1022 REPLACE_SLEEP
9811023 REPLACE_RMDIR
9821024 REPLACE_READLINK
1025 REPLACE_PREAD
9831026 REPLACE_LSEEK
9841027 REPLACE_LINKAT
9851028 REPLACE_LINK
9861029 REPLACE_LCHOWN
9871030 REPLACE_GETPAGESIZE
1031 REPLACE_GETGROUPS
9881032 REPLACE_GETCWD
9891033 REPLACE_FCHOWNAT
9901034 REPLACE_FCHDIR
9921036 REPLACE_DUP
9931037 REPLACE_CLOSE
9941038 REPLACE_CHOWN
1039 HAVE_USLEEP
9951040 HAVE_UNLINKAT
9961041 HAVE_SYS_PARAM_H
9971042 HAVE_OS_H
10021047 HAVE_SLEEP
10031048 HAVE_READLINKAT
10041049 HAVE_READLINK
1050 HAVE_PREAD
10051051 HAVE_PIPE2
10061052 HAVE_LINKAT
10071053 HAVE_LINK
1054 HAVE_LCHOWN
10081055 HAVE_GETUSERSHELL
10091056 HAVE_GETPAGESIZE
1057 HAVE_GETLOGIN
10101058 HAVE_GETHOSTNAME
1059 HAVE_GETGROUPS
10111060 HAVE_GETDTABLESIZE
10121061 HAVE_GETDOMAINNAME
10131062 HAVE_FTRUNCATE
10171066 HAVE_EUIDACCESS
10181067 HAVE_DUP3
10191068 HAVE_DUP2
1069 HAVE_CHOWN
10201070 GNULIB_WRITE
1071 GNULIB_USLEEP
10211072 GNULIB_UNLINKAT
10221073 GNULIB_UNLINK
10231074 GNULIB_UNISTD_H_SIGPIPE
10281079 GNULIB_RMDIR
10291080 GNULIB_READLINKAT
10301081 GNULIB_READLINK
1082 GNULIB_PREAD
10311083 GNULIB_PIPE2
10321084 GNULIB_LSEEK
10331085 GNULIB_LINKAT
10361088 GNULIB_GETUSERSHELL
10371089 GNULIB_GETPAGESIZE
10381090 GNULIB_GETLOGIN_R
1091 GNULIB_GETLOGIN
10391092 GNULIB_GETHOSTNAME
1093 GNULIB_GETGROUPS
10401094 GNULIB_GETDTABLESIZE
10411095 GNULIB_GETDOMAINNAME
10421096 GNULIB_GETCWD
10511105 GNULIB_DUP2
10521106 GNULIB_CLOSE
10531107 GNULIB_CHOWN
1054 LIB_CLOCK_GETTIME
1055 VOID_UNSETENV
1108 REPLACE_UNSETENV
10561109 REPLACE_STRTOD
1110 REPLACE_SETENV
10571111 REPLACE_REALPATH
10581112 REPLACE_PUTENV
10591113 REPLACE_MKSTEMP
10691123 HAVE_REALPATH
10701124 HAVE_REALLOC_POSIX
10711125 HAVE_RANDOM_R
1126 HAVE_MKSTEMPS
1127 HAVE_MKOSTEMPS
10721128 HAVE_MKOSTEMP
10731129 HAVE_MKDTEMP
10741130 HAVE_MALLOC_POSIX
10861142 GNULIB_REALLOC_POSIX
10871143 GNULIB_RANDOM_R
10881144 GNULIB_PUTENV
1145 GNULIB_MKSTEMPS
10891146 GNULIB_MKSTEMP
1147 GNULIB_MKOSTEMPS
10901148 GNULIB_MKOSTEMP
10911149 GNULIB_MKDTEMP
10921150 GNULIB_MALLOC_POSIX
11991257 enable_silent_rules
12001258 enable_dependency_tracking
12011259 enable_largefile
1260 enable_gcc_warnings
12021261 '
12031262 ac_precious_vars='build_alias
12041263 host_alias
17501809 # Omit some internal or obsolete options to make the list less imposing.
17511810 # This message is too long to be a string in the A/UX 3.1 sh.
17521811 cat <<_ACEOF
1753 \`configure' configures gzip 1.3.14 to adapt to many kinds of systems.
1812 \`configure' configures gzip 1.4 to adapt to many kinds of systems.
17541813
17551814 Usage: $0 [OPTION]... [VAR=VALUE]...
17561815
18201879
18211880 if test -n "$ac_init_help"; then
18221881 case $ac_init_help in
1823 short | recursive ) echo "Configuration of gzip 1.3.14:";;
1882 short | recursive ) echo "Configuration of gzip 1.4:";;
18241883 esac
18251884 cat <<\_ACEOF
18261885
18331892 --disable-dependency-tracking speeds up one-time build
18341893 --enable-dependency-tracking do not reject slow dependency extractors
18351894 --disable-largefile omit support for large files
1895 --enable-gcc-warnings turn on lots of GCC warnings (for developers)
18361896
18371897 Some influential environment variables:
18381898 CC C compiler command
19101970 test -n "$ac_init_help" && exit $ac_status
19111971 if $ac_init_version; then
19121972 cat <<\_ACEOF
1913 gzip configure 1.3.14
1914 generated by GNU Autoconf 2.64.69-81c80
1915
1916 Copyright (C) 2009 Free Software Foundation, Inc.
1973 gzip configure 1.4
1974 generated by GNU Autoconf 2.65.23-13e35
1975
1976 Copyright (C) 2010 Free Software Foundation, Inc.
19171977 This configure script is free software; the Free Software Foundation
19181978 gives unlimited permission to copy, distribute and modify it.
19191979 _ACEOF
23322392
23332393 } # ac_fn_c_check_type
23342394
2395 # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
2396 # ---------------------------------------------
2397 # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
2398 # accordingly.
2399 ac_fn_c_check_decl ()
2400 {
2401 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2402 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
2403 $as_echo_n "checking whether $2 is declared... " >&6; }
2404 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
2405 $as_echo_n "(cached) " >&6
2406 else
2407 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2408 /* end confdefs.h. */
2409 $4
2410 int
2411 main ()
2412 {
2413 #ifndef $2
2414 (void) $2;
2415 #endif
2416
2417 ;
2418 return 0;
2419 }
2420 _ACEOF
2421 if ac_fn_c_try_compile "$LINENO"; then :
2422 eval "$3=yes"
2423 else
2424 eval "$3=no"
2425 fi
2426 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2427 fi
2428 eval ac_res=\$$3
2429 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
2430 $as_echo "$ac_res" >&6; }
2431 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
2432
2433 } # ac_fn_c_check_decl
2434
23352435 # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
23362436 # --------------------------------------------
23372437 # Tries to find the compile-time value of EXPR in a program that includes
25102610
25112611 } # ac_fn_c_compute_int
25122612
2513 # ac_fn_c_check_decl LINENO SYMBOL VAR
2514 # ------------------------------------
2515 # Tests whether SYMBOL is declared, setting cache variable VAR accordingly.
2516 ac_fn_c_check_decl ()
2517 {
2518 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
2519 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5
2520 $as_echo_n "checking whether $2 is declared... " >&6; }
2521 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
2522 $as_echo_n "(cached) " >&6
2523 else
2524 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2525 /* end confdefs.h. */
2526 $4
2527 int
2528 main ()
2529 {
2530 #ifndef $2
2531 (void) $2;
2532 #endif
2533
2534 ;
2535 return 0;
2536 }
2537 _ACEOF
2538 if ac_fn_c_try_compile "$LINENO"; then :
2539 eval "$3=yes"
2540 else
2541 eval "$3=no"
2542 fi
2543 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2544 fi
2545 eval ac_res=\$$3
2546 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
2547 $as_echo "$ac_res" >&6; }
2548 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
2549
2550 } # ac_fn_c_check_decl
2551
25522613 # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
25532614 # ----------------------------------------------------
25542615 # Tries to find if the field MEMBER exists in type AGGR, after including
26092670 This file contains any messages produced by compilers while
26102671 running configure, to aid debugging if configure makes a mistake.
26112672
2612 It was created by gzip $as_me 1.3.14, which was
2613 generated by GNU Autoconf 2.64.69-81c80. Invocation command line was
2673 It was created by gzip $as_me 1.4, which was
2674 generated by GNU Autoconf 2.65.23-13e35. Invocation command line was
26142675
26152676 $ $0 $@
26162677
28882949 >$cache_file
28892950 fi
28902951
2952 as_fn_append ac_func_list " chown"
2953 as_fn_append ac_func_list " fchown"
2954 as_fn_append ac_header_list " dirent.h"
28912955 as_fn_append ac_func_list " dup2"
28922956 as_fn_append ac_header_list " errno.h"
2957 as_fn_append ac_func_list " fchdir"
2958 as_fn_append ac_func_list " fcntl"
28932959 as_fn_append ac_header_list " fcntl.h"
2960 as_fn_append ac_func_list " fdopendir"
28942961 as_fn_append ac_header_list " float.h"
28952962 as_fn_append ac_header_list " stdio_ext.h"
28962963 as_fn_append ac_func_list " __fpending"
29032970 as_fn_append ac_func_list " gettimeofday"
29042971 as_fn_append ac_func_list " nanotime"
29052972 as_fn_append ac_header_list " sys/time.h"
2973 as_fn_append ac_func_list " lchmod"
29062974 as_fn_append ac_func_list " lstat"
29072975 as_fn_append ac_header_list " math.h"
29082976 as_fn_append ac_func_list " mbsinit"
29092977 as_fn_append ac_func_list " mbrtowc"
29102978 as_fn_append ac_header_list " sys/mman.h"
29112979 as_fn_append ac_func_list " mprotect"
2980 as_fn_append ac_header_list " unistd.h"
29122981 gl_printf_safe=yes
29132982 as_fn_append ac_header_list " stddef.h"
29142983 as_fn_append ac_header_list " stdint.h"
29192988 as_fn_append ac_header_list " string.h"
29202989 as_fn_append ac_header_list " sys/stat.h"
29212990 as_fn_append ac_header_list " time.h"
2922 as_fn_append ac_header_list " unistd.h"
29232991 as_fn_append ac_func_list " pipe"
29242992 as_fn_append ac_header_list " utime.h"
29252993 as_fn_append ac_func_list " futimes"
29312999 as_fn_append ac_header_list " wctype.h"
29323000 as_fn_append ac_header_list " limits.h"
29333001 as_fn_append ac_header_list " memory.h"
2934 as_fn_append ac_func_list " chown"
29353002 as_fn_append ac_func_list " fchmod"
2936 as_fn_append ac_func_list " fchown"
2937 as_fn_append ac_func_list " fdopendir"
29383003 as_fn_append ac_func_list " siginterrupt"
29393004 # Check that the precious variables saved in the cache have kept the same
29403005 # value.
30083073
30093074 ac_aux_dir=
30103075 for ac_dir in build-aux "$srcdir"/build-aux; do
3011 for ac_t in install-sh install.sh shtool; do
3012 if test -f "$ac_dir/$ac_t"; then
3013 ac_aux_dir=$ac_dir
3014 ac_install_sh="$ac_aux_dir/$ac_t -c"
3015 break 2
3016 fi
3017 done
3076 if test -f "$ac_dir/install-sh"; then
3077 ac_aux_dir=$ac_dir
3078 ac_install_sh="$ac_aux_dir/install-sh -c"
3079 break
3080 elif test -f "$ac_dir/install.sh"; then
3081 ac_aux_dir=$ac_dir
3082 ac_install_sh="$ac_aux_dir/install.sh -c"
3083 break
3084 elif test -f "$ac_dir/shtool"; then
3085 ac_aux_dir=$ac_dir
3086 ac_install_sh="$ac_aux_dir/shtool install -c"
3087 break
3088 fi
30183089 done
30193090 if test -z "$ac_aux_dir"; then
30203091 as_fn_error "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5
34733544
34743545 # Define the identity of the package.
34753546 PACKAGE='gzip'
3476 VERSION='1.3.14'
3547 VERSION='1.4'
34773548
34783549
34793550 cat >>confdefs.h <<_ACEOF
39103981 ... rest of stderr output deleted ...
39113982 10q' conftest.err >conftest.er1
39123983 cat conftest.er1 >&5
3913 rm -f conftest.er1 conftest.err
39143984 fi
3985 rm -f conftest.er1 conftest.err
39153986 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
39163987 test $ac_status = 0; }
39173988 done
56955766 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
56965767 /* end confdefs.h. */
56975768
5698 # define __EXTENSIONS__ 1
5699 $ac_includes_default
5769 # define __EXTENSIONS__ 1
5770 $ac_includes_default
57005771 int
57015772 main ()
57025773 {
62856356 GNULIB_MALLOC_POSIX=0;
62866357 GNULIB_MKDTEMP=0;
62876358 GNULIB_MKOSTEMP=0;
6359 GNULIB_MKOSTEMPS=0;
62886360 GNULIB_MKSTEMP=0;
6361 GNULIB_MKSTEMPS=0;
62896362 GNULIB_PUTENV=0;
62906363 GNULIB_RANDOM_R=0;
62916364 GNULIB_REALLOC_POSIX=0;
63046377 HAVE_MALLOC_POSIX=1;
63056378 HAVE_MKDTEMP=1;
63066379 HAVE_MKOSTEMP=1;
6380 HAVE_MKOSTEMPS=1;
6381 HAVE_MKSTEMPS=1;
63076382 HAVE_RANDOM_R=1;
63086383 HAVE_REALLOC_POSIX=1;
63096384 HAVE_REALPATH=1;
63196394 REPLACE_MKSTEMP=0;
63206395 REPLACE_PUTENV=0;
63216396 REPLACE_REALPATH=0;
6397 REPLACE_SETENV=0;
63226398 REPLACE_STRTOD=0;
6323 VOID_UNSETENV=0;
6399 REPLACE_UNSETENV=0;
6400
6401 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
6402 $as_echo_n "checking for inline... " >&6; }
6403 if test "${ac_cv_c_inline+set}" = set; then :
6404 $as_echo_n "(cached) " >&6
6405 else
6406 ac_cv_c_inline=no
6407 for ac_kw in inline __inline__ __inline; do
6408 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6409 /* end confdefs.h. */
6410 #ifndef __cplusplus
6411 typedef int foo_t;
6412 static $ac_kw foo_t static_foo () {return 0; }
6413 $ac_kw foo_t foo () {return 0; }
6414 #endif
6415
6416 _ACEOF
6417 if ac_fn_c_try_compile "$LINENO"; then :
6418 ac_cv_c_inline=$ac_kw
6419 fi
6420 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6421 test "$ac_cv_c_inline" != no && break
6422 done
6423
6424 fi
6425 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
6426 $as_echo "$ac_cv_c_inline" >&6; }
6427
6428 case $ac_cv_c_inline in
6429 inline | yes) ;;
6430 *)
6431 case $ac_cv_c_inline in
6432 no) ac_val=;;
6433 *) ac_val=$ac_cv_c_inline;;
6434 esac
6435 cat >>confdefs.h <<_ACEOF
6436 #ifndef __cplusplus
6437 #define inline $ac_val
6438 #endif
6439 _ACEOF
6440 ;;
6441 esac
63246442
63256443
63266444 GNULIB_CHOWN=0;
63376455 GNULIB_GETCWD=0;
63386456 GNULIB_GETDOMAINNAME=0;
63396457 GNULIB_GETDTABLESIZE=0;
6458 GNULIB_GETGROUPS=0;
63406459 GNULIB_GETHOSTNAME=0;
6460 GNULIB_GETLOGIN=0;
63416461 GNULIB_GETLOGIN_R=0;
63426462 GNULIB_GETPAGESIZE=0;
63436463 GNULIB_GETUSERSHELL=0;
63466466 GNULIB_LINKAT=0;
63476467 GNULIB_LSEEK=0;
63486468 GNULIB_PIPE2=0;
6469 GNULIB_PREAD=0;
63496470 GNULIB_READLINK=0;
63506471 GNULIB_READLINKAT=0;
63516472 GNULIB_RMDIR=0;
63566477 GNULIB_UNISTD_H_SIGPIPE=0;
63576478 GNULIB_UNLINK=0;
63586479 GNULIB_UNLINKAT=0;
6480 GNULIB_USLEEP=0;
63596481 GNULIB_WRITE=0;
6360 HAVE_DUP2=1;
6482 HAVE_CHOWN=1;
6483 HAVE_DUP2=1;
63616484 HAVE_DUP3=1;
63626485 HAVE_EUIDACCESS=1;
63636486 HAVE_FACCESSAT=1;
63666489 HAVE_FTRUNCATE=1;
63676490 HAVE_GETDOMAINNAME=1;
63686491 HAVE_GETDTABLESIZE=1;
6492 HAVE_GETGROUPS=1;
63696493 HAVE_GETHOSTNAME=1;
6494 HAVE_GETLOGIN=1;
63706495 HAVE_GETPAGESIZE=1;
63716496 HAVE_GETUSERSHELL=1;
6497 HAVE_LCHOWN=1;
63726498 HAVE_LINK=1;
63736499 HAVE_LINKAT=1;
63746500 HAVE_PIPE2=1;
6501 HAVE_PREAD=1;
63756502 HAVE_READLINK=1;
63766503 HAVE_READLINKAT=1;
63776504 HAVE_SLEEP=1;
63826509 HAVE_OS_H=0;
63836510 HAVE_SYS_PARAM_H=0;
63846511 HAVE_UNLINKAT=1;
6512 HAVE_USLEEP=1;
63856513 REPLACE_CHOWN=0;
63866514 REPLACE_CLOSE=0;
63876515 REPLACE_DUP=0;
63896517 REPLACE_FCHDIR=0;
63906518 REPLACE_FCHOWNAT=0;
63916519 REPLACE_GETCWD=0;
6520 REPLACE_GETGROUPS=0;
63926521 REPLACE_GETPAGESIZE=0;
63936522 REPLACE_LCHOWN=0;
63946523 REPLACE_LINK=0;
63956524 REPLACE_LINKAT=0;
63966525 REPLACE_LSEEK=0;
6526 REPLACE_PREAD=0;
63976527 REPLACE_READLINK=0;
63986528 REPLACE_RMDIR=0;
6529 REPLACE_SLEEP=0;
63996530 REPLACE_SYMLINK=0;
64006531 REPLACE_UNLINK=0;
64016532 REPLACE_UNLINKAT=0;
6533 REPLACE_USLEEP=0;
64026534 REPLACE_WRITE=0;
64036535 UNISTD_H_HAVE_WINSOCK2_H=0;
64046536 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
64056537
6538
6539 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
6540 $as_echo_n "checking for uid_t in sys/types.h... " >&6; }
6541 if test "${ac_cv_type_uid_t+set}" = set; then :
6542 $as_echo_n "(cached) " >&6
6543 else
6544 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6545 /* end confdefs.h. */
6546 #include <sys/types.h>
6547
6548 _ACEOF
6549 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6550 $EGREP "uid_t" >/dev/null 2>&1; then :
6551 ac_cv_type_uid_t=yes
6552 else
6553 ac_cv_type_uid_t=no
6554 fi
6555 rm -f conftest*
6556
6557 fi
6558 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
6559 $as_echo "$ac_cv_type_uid_t" >&6; }
6560 if test $ac_cv_type_uid_t = no; then
6561
6562 $as_echo "#define uid_t int" >>confdefs.h
6563
6564
6565 $as_echo "#define gid_t int" >>confdefs.h
6566
6567 fi
6568
6569 for ac_header in unistd.h
6570 do :
6571 ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default"
6572 if test "x$ac_cv_header_unistd_h" = x""yes; then :
6573 cat >>confdefs.h <<_ACEOF
6574 #define HAVE_UNISTD_H 1
6575 _ACEOF
6576
6577 fi
6578
6579 done
6580
6581 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working chown" >&5
6582 $as_echo_n "checking for working chown... " >&6; }
6583 if test "${ac_cv_func_chown_works+set}" = set; then :
6584 $as_echo_n "(cached) " >&6
6585 else
6586 if test "$cross_compiling" = yes; then :
6587 ac_cv_func_chown_works=no
6588 else
6589 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6590 /* end confdefs.h. */
6591 $ac_includes_default
6592 #include <fcntl.h>
6593
6594 int
6595 main ()
6596 {
6597 char *f = "conftest.chown";
6598 struct stat before, after;
6599
6600 if (creat (f, 0600) < 0)
6601 return 1;
6602 if (stat (f, &before) < 0)
6603 return 1;
6604 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
6605 return 1;
6606 if (stat (f, &after) < 0)
6607 return 1;
6608 return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
6609
6610 ;
6611 return 0;
6612 }
6613 _ACEOF
6614 if ac_fn_c_try_run "$LINENO"; then :
6615 ac_cv_func_chown_works=yes
6616 else
6617 ac_cv_func_chown_works=no
6618 fi
6619 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
6620 conftest.$ac_objext conftest.beam conftest.$ac_ext
6621 fi
6622
6623 rm -f conftest.chown
6624
6625 fi
6626 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_chown_works" >&5
6627 $as_echo "$ac_cv_func_chown_works" >&6; }
6628 if test $ac_cv_func_chown_works = yes; then
6629
6630 $as_echo "#define HAVE_CHOWN 1" >>confdefs.h
6631
6632 fi
6633
6634
6635 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown dereferences symlinks" >&5
6636 $as_echo_n "checking whether chown dereferences symlinks... " >&6; }
6637 if test "${gl_cv_func_chown_follows_symlink+set}" = set; then :
6638 $as_echo_n "(cached) " >&6
6639 else
6640
6641 if test "$cross_compiling" = yes; then :
6642 gl_cv_func_chown_follows_symlink=yes
6643
6644 else
6645 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6646 /* end confdefs.h. */
6647
6648 #include <unistd.h>
6649 #include <stdlib.h>
6650 #include <errno.h>
6651
6652 int
6653 main ()
6654 {
6655 char const *dangling_symlink = "conftest.dangle";
6656
6657 unlink (dangling_symlink);
6658 if (symlink ("conftest.no-such", dangling_symlink))
6659 abort ();
6660
6661 /* Exit successfully on a conforming system,
6662 i.e., where chown must fail with ENOENT. */
6663 exit ( ! (chown (dangling_symlink, getuid (), getgid ()) != 0
6664 && errno == ENOENT));
6665 }
6666
6667 _ACEOF
6668 if ac_fn_c_try_run "$LINENO"; then :
6669 gl_cv_func_chown_follows_symlink=yes
6670 else
6671 gl_cv_func_chown_follows_symlink=no
6672 fi
6673 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
6674 conftest.$ac_objext conftest.beam conftest.$ac_ext
6675 fi
6676
6677
6678
6679 fi
6680 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_follows_symlink" >&5
6681 $as_echo "$gl_cv_func_chown_follows_symlink" >&6; }
6682
6683 if test $gl_cv_func_chown_follows_symlink = no; then
6684
6685 $as_echo "#define CHOWN_MODIFIES_SYMLINK 1" >>confdefs.h
6686
6687 fi
64066688
64076689
64086690
64216703 done
64226704
64236705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716 if test $ac_cv_func_chown = no; then
6717 HAVE_CHOWN=0
6718
6719
6720
6721
6722
6723
6724
6725
6726 gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext"
6727
6728 else
6729 if test $gl_cv_func_chown_follows_symlink = no; then
6730 REPLACE_CHOWN=1
6731
6732
6733
6734
6735
6736
6737
6738
6739 gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext"
6740
6741 fi
6742
6743 if test $ac_cv_func_chown_works = no; then
6744
6745 $as_echo "#define CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE 1" >>confdefs.h
6746
6747 REPLACE_CHOWN=1
6748
6749
6750
6751
6752
6753
6754
6755
6756 gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext"
6757
6758 fi
6759
6760 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown honors trailing slash" >&5
6761 $as_echo_n "checking whether chown honors trailing slash... " >&6; }
6762 if test "${gl_cv_func_chown_slash_works+set}" = set; then :
6763 $as_echo_n "(cached) " >&6
6764 else
6765 touch conftest.file && rm -f conftest.link
6766 if test "$cross_compiling" = yes; then :
6767 gl_cv_func_chown_slash_works="guessing no"
6768 else
6769 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6770 /* end confdefs.h. */
6771
6772 #include <unistd.h>
6773 #include <stdlib.h>
6774 #include <errno.h>
6775
6776 int
6777 main ()
6778 {
6779 if (symlink ("conftest.file", "conftest.link")) return 1;
6780 if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2;
6781
6782 ;
6783 return 0;
6784 }
6785 _ACEOF
6786 if ac_fn_c_try_run "$LINENO"; then :
6787 gl_cv_func_chown_slash_works=yes
6788 else
6789 gl_cv_func_chown_slash_works=no
6790 fi
6791 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
6792 conftest.$ac_objext conftest.beam conftest.$ac_ext
6793 fi
6794
6795 rm -f conftest.link conftest.file
6796 fi
6797 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_slash_works" >&5
6798 $as_echo "$gl_cv_func_chown_slash_works" >&6; }
6799 if test "$gl_cv_func_chown_slash_works" != yes; then
6800
6801 $as_echo "#define CHOWN_TRAILING_SLASH_BUG 1" >>confdefs.h
6802
6803 REPLACE_CHOWN=1
6804
6805
6806
6807
6808
6809
6810
6811
6812 gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext"
6813
6814 fi
6815
6816 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether chown always updates ctime" >&5
6817 $as_echo_n "checking whether chown always updates ctime... " >&6; }
6818 if test "${gl_cv_func_chown_ctime_works+set}" = set; then :
6819 $as_echo_n "(cached) " >&6
6820 else
6821 if test "$cross_compiling" = yes; then :
6822 gl_cv_func_chown_ctime_works="guessing no"
6823 else
6824 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6825 /* end confdefs.h. */
6826
6827 #include <unistd.h>
6828 #include <stdlib.h>
6829 #include <errno.h>
6830 #include <fcntl.h>
6831 #include <sys/stat.h>
6832
6833 int
6834 main ()
6835 {
6836 struct stat st1, st2;
6837 if (close (creat ("conftest.file", 0600))) return 1;
6838 if (stat ("conftest.file", &st1)) return 2;
6839 sleep (1);
6840 if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3;
6841 if (stat ("conftest.file", &st2)) return 4;
6842 if (st2.st_ctime <= st1.st_ctime) return 5;
6843
6844 ;
6845 return 0;
6846 }
6847 _ACEOF
6848 if ac_fn_c_try_run "$LINENO"; then :
6849 gl_cv_func_chown_ctime_works=yes
6850 else
6851 gl_cv_func_chown_ctime_works=no
6852 fi
6853 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
6854 conftest.$ac_objext conftest.beam conftest.$ac_ext
6855 fi
6856
6857 rm -f conftest.file
6858 fi
6859 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_chown_ctime_works" >&5
6860 $as_echo "$gl_cv_func_chown_ctime_works" >&6; }
6861 if test "$gl_cv_func_chown_ctime_works" != yes; then
6862
6863 $as_echo "#define CHOWN_CHANGE_TIME_BUG 1" >>confdefs.h
6864
6865 REPLACE_CHOWN=1
6866
6867
6868
6869
6870
6871
6872
6873
6874 gl_LIBOBJS="$gl_LIBOBJS chown.$ac_objext"
6875
6876 fi
6877
6878 if test $REPLACE_CHOWN = 1 && test $ac_cv_func_fchown = no; then
6879
6880
6881
6882
6883
6884
6885
6886
6887 gl_LIBOBJS="$gl_LIBOBJS fchown-stub.$ac_objext"
6888
6889 fi
6890 fi
6891
6892
6893 GNULIB_DIRFD=0;
6894 GNULIB_FDOPENDIR=0;
6895 GNULIB_SCANDIR=0;
6896 GNULIB_ALPHASORT=0;
6897 HAVE_DECL_DIRFD=1;
6898 HAVE_FDOPENDIR=1;
6899 HAVE_SCANDIR=1;
6900 HAVE_ALPHASORT=1;
6901 REPLACE_CLOSEDIR=0;
6902 REPLACE_FDOPENDIR=0;
6903 REPLACE_OPENDIR=0;
64246904
64256905
64266906
65227002 fi
65237003
65247004 done
7005
7006
7007
7008
7009 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system is Windows or MSDOS" >&5
7010 $as_echo_n "checking whether system is Windows or MSDOS... " >&6; }
7011 if test "${ac_cv_win_or_dos+set}" = set; then :
7012 $as_echo_n "(cached) " >&6
7013 else
7014
7015 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7016 /* end confdefs.h. */
7017
7018 int
7019 main ()
7020 {
7021
7022 #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
7023 neither MSDOS nor Windows
7024 #endif
7025 ;
7026 return 0;
7027 }
7028 _ACEOF
7029 if ac_fn_c_try_compile "$LINENO"; then :
7030 ac_cv_win_or_dos=yes
7031 else
7032 ac_cv_win_or_dos=no
7033 fi
7034 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7035
7036 fi
7037 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_win_or_dos" >&5
7038 $as_echo "$ac_cv_win_or_dos" >&6; }
7039
7040 if test x"$ac_cv_win_or_dos" = xyes; then
7041 ac_fs_accepts_drive_letter_prefix=1
7042 ac_fs_backslash_is_file_name_separator=1
7043 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether drive letter can start relative path" >&5
7044 $as_echo_n "checking whether drive letter can start relative path... " >&6; }
7045 if test "${ac_cv_drive_letter_can_be_relative+set}" = set; then :
7046 $as_echo_n "(cached) " >&6
7047 else
7048
7049 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7050 /* end confdefs.h. */
7051
7052 int
7053 main ()
7054 {
7055
7056 #if defined __CYGWIN__
7057 drive letters are always absolute
7058 #endif
7059 ;
7060 return 0;
7061 }
7062 _ACEOF
7063 if ac_fn_c_try_compile "$LINENO"; then :
7064 ac_cv_drive_letter_can_be_relative=yes
7065 else
7066 ac_cv_drive_letter_can_be_relative=no
7067 fi
7068 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7069
7070 fi
7071 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_drive_letter_can_be_relative" >&5
7072 $as_echo "$ac_cv_drive_letter_can_be_relative" >&6; }
7073 if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
7074 ac_fs_drive_letter_can_be_relative=1
7075 else
7076 ac_fs_drive_letter_can_be_relative=0
7077 fi
7078 else
7079 ac_fs_accepts_drive_letter_prefix=0
7080 ac_fs_backslash_is_file_name_separator=0
7081 ac_fs_drive_letter_can_be_relative=0
7082 fi
7083
7084
7085 cat >>confdefs.h <<_ACEOF
7086 #define FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX $ac_fs_accepts_drive_letter_prefix
7087 _ACEOF
7088
7089
7090
7091
7092
7093 cat >>confdefs.h <<_ACEOF
7094 #define FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR $ac_fs_backslash_is_file_name_separator
7095 _ACEOF
7096
7097
7098
7099 cat >>confdefs.h <<_ACEOF
7100 #define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE $ac_fs_drive_letter_can_be_relative
7101 _ACEOF
7102
7103
7104
7105
7106 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether // is distinct from /" >&5
7107 $as_echo_n "checking whether // is distinct from /... " >&6; }
7108 if test "${gl_cv_double_slash_root+set}" = set; then :
7109 $as_echo_n "(cached) " >&6
7110 else
7111 if test x"$cross_compiling" = xyes ; then
7112 # When cross-compiling, there is no way to tell whether // is special
7113 # short of a list of hosts. However, the only known hosts to date
7114 # that have a distinct // are Apollo DomainOS (too old to port to),
7115 # Cygwin, and z/OS. If anyone knows of another system for which // has
7116 # special semantics and is distinct from /, please report it to
7117 # <bug-gnulib@gnu.org>.
7118 case $host in
7119 *-cygwin | i370-ibm-openedition)
7120 gl_cv_double_slash_root=yes ;;
7121 *)
7122 # Be optimistic and assume that / and // are the same when we
7123 # don't know.
7124 gl_cv_double_slash_root='unknown, assuming no' ;;
7125 esac
7126 else
7127 set x `ls -di / // 2>/dev/null`
7128 if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then
7129 gl_cv_double_slash_root=no
7130 else
7131 gl_cv_double_slash_root=yes
7132 fi
7133 fi
7134 fi
7135 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_double_slash_root" >&5
7136 $as_echo "$gl_cv_double_slash_root" >&6; }
7137 if test "$gl_cv_double_slash_root" = yes; then
7138
7139 $as_echo "#define DOUBLE_SLASH_IS_DISTINCT_ROOT 1" >>confdefs.h
7140
7141 fi
7142
7143
65257144
65267145
65277146
65997218 $as_echo_n "(cached) " >&6
66007219 else
66017220
6602 if test $ac_cv_header_errno_h = yes; then
6603 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7221 if test $ac_cv_header_errno_h = yes; then
7222 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
66047223 /* end confdefs.h. */
66057224 #include <errno.h>
66067225
66077226 _ACEOF
6608 case "$host_os" in
6609 aix*) gl_absname_cpp="$ac_cpp -C" ;;
6610 *) gl_absname_cpp="$ac_cpp" ;;
6611 esac
6612 gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
6613 sed -n '\#/errno.h#{
6614 s#.*"\(.*/errno.h\)".*#\1#
6615 s#^/[^/]#//&#
6616 p
6617 q
6618 }'`'"'
6619 else
6620 gl_cv_next_errno_h='<'errno.h'>'
6621 fi
7227 case "$host_os" in
7228 aix*) gl_absname_cpp="$ac_cpp -C" ;;
7229 *) gl_absname_cpp="$ac_cpp" ;;
7230 esac
7231 gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
7232 sed -n '\#/errno.h#{
7233 s#.*"\(.*/errno.h\)".*#\1#
7234 s#^/[^/]#//&#
7235 p
7236 q
7237 }'`'"'
7238 else
7239 gl_cv_next_errno_h='<'errno.h'>'
7240 fi
66227241
66237242 fi
66247243 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_errno_h" >&5
69487567
69497568
69507569 XGETTEXT_EXTRA_OPTIONS=
7570
7571
7572 GNULIB_FCHMODAT=0;
7573 GNULIB_FSTATAT=0;
7574 GNULIB_FUTIMENS=0;
7575 GNULIB_LCHMOD=0;
7576 GNULIB_LSTAT=0;
7577 GNULIB_MKDIRAT=0;
7578 GNULIB_MKFIFO=0;
7579 GNULIB_MKFIFOAT=0;
7580 GNULIB_MKNOD=0;
7581 GNULIB_MKNODAT=0;
7582 GNULIB_STAT=0;
7583 GNULIB_UTIMENSAT=0;
7584 HAVE_FCHMODAT=1;
7585 HAVE_FSTATAT=1;
7586 HAVE_FUTIMENS=1;
7587 HAVE_LCHMOD=1;
7588 HAVE_LSTAT=1;
7589 HAVE_MKDIRAT=1;
7590 HAVE_MKFIFO=1;
7591 HAVE_MKFIFOAT=1;
7592 HAVE_MKNOD=1;
7593 HAVE_MKNODAT=1;
7594 HAVE_UTIMENSAT=1;
7595 REPLACE_FSTAT=0;
7596 REPLACE_FSTATAT=0;
7597 REPLACE_FUTIMENS=0;
7598 REPLACE_LSTAT=0;
7599 REPLACE_MKDIR=0;
7600 REPLACE_MKFIFO=0;
7601 REPLACE_MKNOD=0;
7602 REPLACE_STAT=0;
7603 REPLACE_UTIMENSAT=0;
7604
7605
7606
7607
7608 GNULIB_FCNTL=0;
7609 GNULIB_OPEN=0;
7610 GNULIB_OPENAT=0;
7611 HAVE_FCNTL=1;
7612 HAVE_OPENAT=1;
7613 REPLACE_FCNTL=0;
7614 REPLACE_OPEN=0;
7615 REPLACE_OPENAT=0;
7616
7617 ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
7618 if test "x$ac_cv_type_mode_t" = x""yes; then :
7619
7620 else
7621
7622 cat >>confdefs.h <<_ACEOF
7623 #define mode_t int
7624 _ACEOF
7625
7626 fi
7627
7628
7629
7630 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for promoted mode_t type" >&5
7631 $as_echo_n "checking for promoted mode_t type... " >&6; }
7632 if test "${gl_cv_promoted_mode_t+set}" = set; then :
7633 $as_echo_n "(cached) " >&6
7634 else
7635
7636 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7637 /* end confdefs.h. */
7638 #include <sys/types.h>
7639 int
7640 main ()
7641 {
7642 typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];
7643 ;
7644 return 0;
7645 }
7646 _ACEOF
7647 if ac_fn_c_try_compile "$LINENO"; then :
7648 gl_cv_promoted_mode_t='int'
7649 else
7650 gl_cv_promoted_mode_t='mode_t'
7651 fi
7652 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7653
7654 fi
7655 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_promoted_mode_t" >&5
7656 $as_echo "$gl_cv_promoted_mode_t" >&6; }
7657
7658 cat >>confdefs.h <<_ACEOF
7659 #define PROMOTED_MODE_T $gl_cv_promoted_mode_t
7660 _ACEOF
7661
69517662
69527663
69537664 GNULIB_DPRINTF=0;
69977708 HAVE_DECL_SNPRINTF=1;
69987709 HAVE_DECL_VSNPRINTF=1;
69997710 HAVE_DPRINTF=1;
7000 HAVE_FSEEKO=1;
7001 HAVE_FTELLO=1;
70027711 HAVE_RENAMEAT=1;
70037712 HAVE_VASPRINTF=1;
70047713 HAVE_VDPRINTF=1;
70327741 REPLACE_VSPRINTF=0;
70337742
70347743
7035 GNULIB_OPEN=0;
7036 GNULIB_OPENAT=0;
7037 HAVE_OPENAT=1;
7038 REPLACE_OPEN=0;
7039 REPLACE_OPENAT=0;
70407744
70417745
70427746
70517755 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
70527756 /* end confdefs.h. */
70537757 #include <sys/types.h>
7054 #include <sys/stat.h>
7055 #include <unistd.h>
7056 #include <fcntl.h>
7057 #ifndef O_NOATIME
7058 #define O_NOATIME 0
7059 #endif
7060 #ifndef O_NOFOLLOW
7061 #define O_NOFOLLOW 0
7062 #endif
7063 static int const constants[] =
7064 {
7065 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
7066 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
7067 };
7758 #include <sys/stat.h>
7759 #include <unistd.h>
7760 #include <fcntl.h>
7761 #ifndef O_NOATIME
7762 #define O_NOATIME 0
7763 #endif
7764 #ifndef O_NOFOLLOW
7765 #define O_NOFOLLOW 0
7766 #endif
7767 static int const constants[] =
7768 {
7769 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
7770 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
7771 };
70687772
70697773 int
70707774 main ()
70717775 {
70727776
7073 int status = !constants;
7074 {
7075 static char const sym[] = "conftest.sym";
7076 if (symlink (".", sym) != 0
7077 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
7078 status |= 32;
7079 unlink (sym);
7080 }
7081 {
7082 static char const file[] = "confdefs.h";
7083 int fd = open (file, O_RDONLY | O_NOATIME);
7084 char c;
7085 struct stat st0, st1;
7086 if (fd < 0
7087 || fstat (fd, &st0) != 0
7088 || sleep (1) != 0
7089 || read (fd, &c, 1) != 1
7090 || close (fd) != 0
7091 || stat (file, &st1) != 0
7092 || st0.st_atime != st1.st_atime)
7093 status |= 64;
7094 }
7095 return status;
7777 int status = !constants;
7778 {
7779 static char const sym[] = "conftest.sym";
7780 if (symlink (".", sym) != 0
7781 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
7782 status |= 32;
7783 unlink (sym);
7784 }
7785 {
7786 static char const file[] = "confdefs.h";
7787 int fd = open (file, O_RDONLY | O_NOATIME);
7788 char c;
7789 struct stat st0, st1;
7790 if (fd < 0
7791 || fstat (fd, &st0) != 0
7792 || sleep (1) != 0
7793 || read (fd, &c, 1) != 1
7794 || close (fd) != 0
7795 || stat (file, &st1) != 0
7796 || st0.st_atime != st1.st_atime)
7797 status |= 64;
7798 }
7799 return status;
70967800 ;
70977801 return 0;
70987802 }
71017805 gl_cv_header_working_fcntl_h=yes
71027806 else
71037807 case $? in #(
7104 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
7105 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
7106 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
7107 *) gl_cv_header_working_fcntl_h='no';;
7108 esac
7808 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
7809 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
7810 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
7811 *) gl_cv_header_working_fcntl_h='no';;
7812 esac
71097813 fi
71107814 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
71117815 conftest.$ac_objext conftest.beam conftest.$ac_ext
71377841
71387842
71397843
7140 ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
7141 if test "x$ac_cv_type_mode_t" = x""yes; then :
7142
7143 else
7144
7145 cat >>confdefs.h <<_ACEOF
7146 #define mode_t int
7147 _ACEOF
7148
7149 fi
7150
7151
7152
7153 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for promoted mode_t type" >&5
7154 $as_echo_n "checking for promoted mode_t type... " >&6; }
7155 if test "${gl_cv_promoted_mode_t+set}" = set; then :
7156 $as_echo_n "(cached) " >&6
7157 else
7158
7159 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7160 /* end confdefs.h. */
7161 #include <sys/types.h>
7162 int
7163 main ()
7164 {
7165 typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];
7166 ;
7167 return 0;
7168 }
7169 _ACEOF
7170 if ac_fn_c_try_compile "$LINENO"; then :
7171 gl_cv_promoted_mode_t='int'
7172 else
7173 gl_cv_promoted_mode_t='mode_t'
7174 fi
7175 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7176
7177 fi
7178 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_promoted_mode_t" >&5
7179 $as_echo "$gl_cv_promoted_mode_t" >&6; }
7180
7181 cat >>confdefs.h <<_ACEOF
7182 #define PROMOTED_MODE_T $gl_cv_promoted_mode_t
7183 _ACEOF
7184
7185
7186 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
7187 $as_echo_n "checking for inline... " >&6; }
7188 if test "${ac_cv_c_inline+set}" = set; then :
7189 $as_echo_n "(cached) " >&6
7190 else
7191 ac_cv_c_inline=no
7192 for ac_kw in inline __inline__ __inline; do
7193 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7194 /* end confdefs.h. */
7195 #ifndef __cplusplus
7196 typedef int foo_t;
7197 static $ac_kw foo_t static_foo () {return 0; }
7198 $ac_kw foo_t foo () {return 0; }
7199 #endif
7200
7201 _ACEOF
7202 if ac_fn_c_try_compile "$LINENO"; then :
7203 ac_cv_c_inline=$ac_kw
7204 fi
7205 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
7206 test "$ac_cv_c_inline" != no && break
7207 done
7208
7209 fi
7210 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
7211 $as_echo "$ac_cv_c_inline" >&6; }
7212
7213 case $ac_cv_c_inline in
7214 inline | yes) ;;
7215 *)
7216 case $ac_cv_c_inline in
7217 no) ac_val=;;
7218 *) ac_val=$ac_cv_c_inline;;
7219 esac
7220 cat >>confdefs.h <<_ACEOF
7221 #ifndef __cplusplus
7222 #define inline $ac_val
7223 #endif
7224 _ACEOF
7225 ;;
7226 esac
7844
72277845
72287846
72297847
89109528 /* end confdefs.h. */
89119529
89129530 /* For now, do not test the preprocessor; as of 2007 there are too many
8913 implementations with broken preprocessors. Perhaps this can
8914 be revisited in 2012. In the meantime, code should not expect
8915 #if to work with literals wider than 32 bits. */
9531 implementations with broken preprocessors. Perhaps this can
9532 be revisited in 2012. In the meantime, code should not expect
9533 #if to work with literals wider than 32 bits. */
89169534 /* Test literals. */
89179535 long long int ll = 9223372036854775807ll;
89189536 long long int nll = -9223372036854775807LL;
89199537 unsigned long long int ull = 18446744073709551615ULL;
89209538 /* Test constant expressions. */
89219539 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
8922 ? 1 : -1)];
9540 ? 1 : -1)];
89239541 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
8924 ? 1 : -1)];
9542 ? 1 : -1)];
89259543 int i = 63;
89269544 int
89279545 main ()
89309548 long long int llmax = 9223372036854775807ll;
89319549 unsigned long long int ullmax = 18446744073709551615ull;
89329550 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
8933 | (llmax / ll) | (llmax % ll)
8934 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
8935 | (ullmax / ull) | (ullmax % ull));
9551 | (llmax / ll) | (llmax % ll)
9552 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
9553 | (ullmax / ull) | (ullmax % ull));
89369554 ;
89379555 return 0;
89389556 }
89399557
89409558 _ACEOF
89419559 if ac_fn_c_try_link "$LINENO"; then :
8942 if test "$cross_compiling" = yes; then :
9560 if test "$cross_compiling" = yes; then :
89439561 ac_cv_type_long_long_int=yes
89449562 else
89459563 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
89469564 /* end confdefs.h. */
89479565 #include <limits.h>
8948 #ifndef LLONG_MAX
8949 # define HALF \
8950 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
8951 # define LLONG_MAX (HALF - 1 + HALF)
8952 #endif
9566 #ifndef LLONG_MAX
9567 # define HALF \
9568 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
9569 # define LLONG_MAX (HALF - 1 + HALF)
9570 #endif
89539571 int
89549572 main ()
89559573 {
89569574 long long int n = 1;
8957 int i;
8958 for (i = 0; ; i++)
8959 {
8960 long long int m = n << i;
8961 if (m >> i != n)
8962 return 1;
8963 if (LLONG_MAX / 2 < m)
8964 break;
8965 }
8966 return 0;
9575 int i;
9576 for (i = 0; ; i++)
9577 {
9578 long long int m = n << i;
9579 if (m >> i != n)
9580 return 1;
9581 if (LLONG_MAX / 2 < m)
9582 break;
9583 }
9584 return 0;
89679585 ;
89689586 return 0;
89699587 }
91569774
91579775
91589776
9777 GNULIB_ACOSL=0;
9778 GNULIB_ASINL=0;
9779 GNULIB_ATANL=0;
91599780 GNULIB_CEILF=0;
91609781 GNULIB_CEILL=0;
9782 GNULIB_COSL=0;
9783 GNULIB_EXPL=0;
91619784 GNULIB_FLOORF=0;
91629785 GNULIB_FLOORL=0;
91639786 GNULIB_FREXP=0;
91699792 GNULIB_ISNAND=0;
91709793 GNULIB_ISNANL=0;
91719794 GNULIB_LDEXPL=0;
9172 GNULIB_MATHL=0;
9795 GNULIB_LOGL=0;
91739796 GNULIB_ROUND=0;
91749797 GNULIB_ROUNDF=0;
91759798 GNULIB_ROUNDL=0;
91769799 GNULIB_SIGNBIT=0;
9800 GNULIB_SINL=0;
9801 GNULIB_SQRTL=0;
9802 GNULIB_TANL=0;
91779803 GNULIB_TRUNC=0;
91789804 GNULIB_TRUNCF=0;
91799805 GNULIB_TRUNCL=0;
9180 HAVE_ISNANF=1;
9806 HAVE_ACOSL=1;
9807 HAVE_ASINL=1;
9808 HAVE_ATANL=1;
9809 HAVE_COSL=1;
9810 HAVE_EXPL=1;
9811 HAVE_ISNANF=1;
91819812 HAVE_ISNAND=1;
91829813 HAVE_ISNANL=1;
9814 HAVE_LOGL=1;
9815 HAVE_SINL=1;
9816 HAVE_SQRTL=1;
9817 HAVE_TANL=1;
91839818 HAVE_DECL_ACOSL=1;
91849819 HAVE_DECL_ASINL=1;
91859820 HAVE_DECL_ATANL=1;
92499884 $as_echo "$gl_cv_var_stdin_large_offset" >&6; }
92509885
92519886
9887 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getcwd (NULL, 0) allocates memory for result" >&5
9888 $as_echo_n "checking whether getcwd (NULL, 0) allocates memory for result... " >&6; }
9889 if test "${gl_cv_func_getcwd_null+set}" = set; then :
9890 $as_echo_n "(cached) " >&6
9891 else
9892 if test "$cross_compiling" = yes; then :
9893
9894 case "$host_os" in
9895 # Guess yes on glibc systems.
9896 *-gnu*) gl_cv_func_getcwd_null="guessing yes";;
9897 # Guess yes on Cygwin.
9898 cygwin*) gl_cv_func_getcwd_null="guessing yes";;
9899 # Guess yes on mingw.
9900 mingw*) gl_cv_func_getcwd_null="guessing yes";;
9901 # If we don't know, assume the worst.
9902 *) gl_cv_func_getcwd_null="guessing no";;
9903 esac
9904
9905 else
9906 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9907 /* end confdefs.h. */
9908
9909 # include <unistd.h>
9910 # ifndef getcwd
9911 char *getcwd ();
9912 # endif
9913
9914 int
9915 main ()
9916 {
9917
9918 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
9919 /* mingw cwd does not start with '/', but getcwd does allocate. */
9920 #else
9921 if (chdir ("/") != 0)
9922 return 1;
9923 else
9924 {
9925 char *f = getcwd (NULL, 0);
9926 return ! (f && f[0] == '/' && !f[1]);
9927 }
9928 #endif
9929
9930 ;
9931 return 0;
9932 }
9933 _ACEOF
9934 if ac_fn_c_try_run "$LINENO"; then :
9935 gl_cv_func_getcwd_null=yes
9936 else
9937 gl_cv_func_getcwd_null=no
9938 fi
9939 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
9940 conftest.$ac_objext conftest.beam conftest.$ac_ext
9941 fi
9942
9943 fi
9944 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getcwd_null" >&5
9945 $as_echo "$gl_cv_func_getcwd_null" >&6; }
9946
9947 ac_fn_c_check_decl "$LINENO" "getcwd" "ac_cv_have_decl_getcwd" "$ac_includes_default"
9948 if test "x$ac_cv_have_decl_getcwd" = x""yes; then :
9949 ac_have_decl=1
9950 else
9951 ac_have_decl=0
9952 fi
9953
9954 cat >>confdefs.h <<_ACEOF
9955 #define HAVE_DECL_GETCWD $ac_have_decl
9956 _ACEOF
9957
9958
92529959
92539960
92549961
92699976 $as_echo_n "(cached) " >&6
92709977 else
92719978
9272 if test $ac_cv_header_getopt_h = yes; then
9273 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9979 if test $ac_cv_header_getopt_h = yes; then
9980 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
92749981 /* end confdefs.h. */
92759982 #include <getopt.h>
92769983
92779984 _ACEOF
9278 case "$host_os" in
9279 aix*) gl_absname_cpp="$ac_cpp -C" ;;
9280 *) gl_absname_cpp="$ac_cpp" ;;
9281 esac
9282 gl_cv_next_getopt_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
9283 sed -n '\#/getopt.h#{
9284 s#.*"\(.*/getopt.h\)".*#\1#
9285 s#^/[^/]#//&#
9286 p
9287 q
9288 }'`'"'
9289 else
9290 gl_cv_next_getopt_h='<'getopt.h'>'
9291 fi
9985 case "$host_os" in
9986 aix*) gl_absname_cpp="$ac_cpp -C" ;;
9987 *) gl_absname_cpp="$ac_cpp" ;;
9988 esac
9989 gl_cv_next_getopt_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
9990 sed -n '\#/getopt.h#{
9991 s#.*"\(.*/getopt.h\)".*#\1#
9992 s#^/[^/]#//&#
9993 p
9994 q
9995 }'`'"'
9996 else
9997 gl_cv_next_getopt_h='<'getopt.h'>'
9998 fi
92929999
929310000 fi
929410001 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_getopt_h" >&5
935010057
935110058 fi
935210059
9353 if false && test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
10060 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
935410061 ac_fn_c_check_decl "$LINENO" "optreset" "ac_cv_have_decl_optreset" "#include <getopt.h>
935510062 "
935610063 if test "x$ac_cv_have_decl_optreset" = x""yes; then :
9357 gl_replace_getopt=yes
9358 fi
10064 ac_have_decl=1
10065 else
10066 ac_have_decl=0
10067 fi
10068
10069 cat >>confdefs.h <<_ACEOF
10070 #define HAVE_DECL_OPTRESET $ac_have_decl
10071 _ACEOF
935910072
936010073 fi
936110074
9362 if test -z "$gl_replace_getopt"; then
10075 if test -z "$gl_replace_getopt"; then
936310076 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt is POSIX compatible" >&5
936410077 $as_echo_n "checking whether getopt is POSIX compatible... " >&6; }
936510078 if test "${gl_cv_func_getopt_posix+set}" = set; then :
938010093 #include <stdlib.h>
938110094 #include <string.h>
938210095
9383 /* The glibc implementation of getopt supports setting optind = 0 as a means
9384 of clearing the internal state, but other implementations don't. */
9385 #if (__GLIBC__ >= 2)
10096 #if !HAVE_DECL_OPTRESET
938610097 # define OPTIND_MIN 0
938710098 #else
938810099 # define OPTIND_MIN 1
940010111 argv[argc++] = "-a";
940110112 argv[argc++] = "foo";
940210113 argv[argc++] = "bar";
10114 argv[argc] = NULL;
940310115 optind = OPTIND_MIN;
940410116 opterr = 0;
940510117
942510137 argv[argc++] = "duck";
942610138 argv[argc++] = "-a";
942710139 argv[argc++] = "bar";
10140 argv[argc] = NULL;
942810141 optind = OPTIND_MIN;
942910142 opterr = 0;
943010143
947710190 if test "${gl_cv_func_getopt_gnu+set}" = set; then :
947810191 $as_echo_n "(cached) " >&6
947910192 else
9480 if test "$cross_compiling" = yes; then :
9481 case "$host_os" in
9482 *-gnu* | mingw*) gl_cv_func_getopt_gnu=no;;
9483 *) gl_cv_func_getopt_gnu=yes;;
10193 # Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
10194 # optstring is necessary for programs like m4 that have POSIX-mandated
10195 # semantics for supporting options interspersed with files.
10196 # Also, since getopt_long is a GNU extension, we require optind=0.
10197 gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes}
10198 POSIXLY_CORRECT=1
10199 export POSIXLY_CORRECT
10200 if test "$cross_compiling" = yes; then :
10201 case $host_os:$ac_cv_have_decl_optreset in
10202 *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
10203 *:yes) gl_cv_func_getopt_gnu=no;;
10204 *) gl_cv_func_getopt_gnu=yes;;
948410205 esac
948510206
948610207 else
948710208 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
948810209 /* end confdefs.h. */
948910210 #include <getopt.h>
9490 #include <stddef.h>
9491 #include <string.h>
10211 #include <stddef.h>
10212 #include <string.h>
10213
949210214 int
949310215 main ()
949410216 {
950710229 }
950810230 /* This code succeeds on glibc 2.8, mingw,
950910231 and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
9510 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin. */
10232 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
951110233 {
9512 char *argv[] = { "program", "-p", "foo", "bar" };
10234 char *argv[] = { "program", "-p", "foo", "bar", NULL };
951310235
951410236 optind = 1;
951510237 if (getopt (4, argv, "p::") != 'p')
952110243 if (optind != 2)
952210244 return 5;
952310245 }
10246 /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
10247 {
10248 char *argv[] = { "program", "foo", "-p", NULL };
10249 optind = 0;
10250 if (getopt (3, argv, "-p") != 1)
10251 return 6;
10252 if (getopt (3, argv, "-p") != 'p')
10253 return 7;
10254 }
952410255 return 0;
952510256
952610257 ;
953610267 conftest.$ac_objext conftest.beam conftest.$ac_ext
953710268 fi
953810269
10270 if test "$gl_had_POSIXLY_CORRECT" != yes; then
10271 { POSIXLY_CORRECT=; unset POSIXLY_CORRECT;}
10272 fi
953910273
954010274 fi
954110275 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getopt_gnu" >&5
961810352 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
961910353 /* end confdefs.h. */
962010354 typedef int * int_ptr;
9621 int foo (int_ptr $ac_kw ip) {
9622 return ip[0];
10355 int foo (int_ptr $ac_kw ip) {
10356 return ip[0];
962310357 }
962410358 int
962510359 main ()
962610360 {
962710361 int s[1];
9628 int * $ac_kw t = s;
9629 t[0] = 0;
9630 return foo(t)
10362 int * $ac_kw t = s;
10363 t[0] = 0;
10364 return foo(t)
963110365 ;
963210366 return 0;
963310367 }
965210386 _ACEOF
965310387 ;;
965410388 esac
10389
965510390
965610391
965710392
967210407 $as_echo_n "(cached) " >&6
967310408 else
967410409
9675 if test $ac_cv_header_sys_time_h = yes; then
9676 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10410 if test $ac_cv_header_sys_time_h = yes; then
10411 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
967710412 /* end confdefs.h. */
967810413 #include <sys/time.h>
967910414
968010415 _ACEOF
9681 case "$host_os" in
9682 aix*) gl_absname_cpp="$ac_cpp -C" ;;
9683 *) gl_absname_cpp="$ac_cpp" ;;
9684 esac
9685 gl_cv_next_sys_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
9686 sed -n '\#/sys/time.h#{
9687 s#.*"\(.*/sys/time.h\)".*#\1#
9688 s#^/[^/]#//&#
9689 p
9690 q
9691 }'`'"'
9692 else
9693 gl_cv_next_sys_time_h='<'sys/time.h'>'
9694 fi
10416 case "$host_os" in
10417 aix*) gl_absname_cpp="$ac_cpp -C" ;;
10418 *) gl_absname_cpp="$ac_cpp" ;;
10419 esac
10420 gl_cv_next_sys_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
10421 sed -n '\#/sys/time.h#{
10422 s#.*"\(.*/sys/time.h\)".*#\1#
10423 s#^/[^/]#//&#
10424 p
10425 q
10426 }'`'"'
10427 else
10428 gl_cv_next_sys_time_h='<'sys/time.h'>'
10429 fi
969510430
969610431 fi
969710432 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_time_h" >&5
972610461 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
972710462 /* end confdefs.h. */
972810463 #if HAVE_SYS_TIME_H
9729 #include <sys/time.h>
9730 #endif
9731 #include <time.h>
10464 #include <sys/time.h>
10465 #endif
10466 #include <time.h>
973210467
973310468 int
973410469 main ()
987610611 esac
987710612
987810613
10614
10615
987910616 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5
988010617 $as_echo_n "checking for nl_langinfo and CODESET... " >&6; }
988110618 if test "${am_cv_langinfo_codeset+set}" = set; then :
995310690
995410691 GLIBC21="$ac_cv_gnu_library_2_1"
995510692
9956
9957
9958 GNULIB_FCHMODAT=0;
9959 GNULIB_FSTATAT=0;
9960 GNULIB_FUTIMENS=0;
9961 GNULIB_LCHMOD=0;
9962 GNULIB_LSTAT=0;
9963 GNULIB_MKDIRAT=0;
9964 GNULIB_MKFIFOAT=0;
9965 GNULIB_MKNODAT=0;
9966 GNULIB_STAT=0;
9967 GNULIB_UTIMENSAT=0;
9968 HAVE_FCHMODAT=1;
9969 HAVE_FSTATAT=1;
9970 HAVE_FUTIMENS=1;
9971 HAVE_LCHMOD=1;
9972 HAVE_LSTAT=1;
9973 HAVE_MKDIRAT=1;
9974 HAVE_MKFIFOAT=1;
9975 HAVE_MKNODAT=1;
9976 HAVE_UTIMENSAT=1;
9977 REPLACE_FSTAT=0;
9978 REPLACE_FSTATAT=0;
9979 REPLACE_FUTIMENS=0;
9980 REPLACE_LSTAT=0;
9981 REPLACE_MKDIR=0;
9982 REPLACE_STAT=0;
9983 REPLACE_UTIMENSAT=0;
998410693
998510694
998610695
1008710796 REPLACE_WCSRTOMBS=0;
1008810797 REPLACE_WCSNRTOMBS=0;
1008910798 REPLACE_WCWIDTH=0;
10090 WCHAR_H='';
1009110799
1009210800
1009310801
1009910807 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1010010808 /* end confdefs.h. */
1010110809 $ac_includes_default
10102 # include <wchar.h>
10810 # include <wchar.h>
1010310811 int
1010410812 main ()
1010510813 {
1047111179 GNULIB_STRERROR=0;
1047211180 GNULIB_STRSIGNAL=0;
1047311181 GNULIB_STRVERSCMP=0;
11182 HAVE_MBSLEN=0;
1047411183 HAVE_DECL_MEMMEM=1;
1047511184 HAVE_MEMPCPY=1;
1047611185 HAVE_DECL_MEMRCHR=1;
1065911368 {
1066011369 int pagesize = getpagesize ();
1066111370 char *two_pages =
10662 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
10663 flags, fd, 0);
11371 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
11372 flags, fd, 0);
1066411373 if (two_pages != (char *)(-1)
10665 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
10666 fence = two_pages + pagesize;
11374 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
11375 fence = two_pages + pagesize;
1066711376 }
1066811377 #endif
1066911378 if (fence)
1071911428 gl_LIBOBJS="$gl_LIBOBJS memchr.$ac_objext"
1072011429
1072111430 fi
11431 fi
11432
11433 ac_fn_c_check_decl "$LINENO" "memrchr" "ac_cv_have_decl_memrchr" "$ac_includes_default"
11434 if test "x$ac_cv_have_decl_memrchr" = x""yes; then :
11435 ac_have_decl=1
11436 else
11437 ac_have_decl=0
11438 fi
11439
11440 cat >>confdefs.h <<_ACEOF
11441 #define HAVE_DECL_MEMRCHR $ac_have_decl
11442 _ACEOF
11443
11444
11445
11446
11447
11448
11449 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unlink honors trailing slashes" >&5
11450 $as_echo_n "checking whether unlink honors trailing slashes... " >&6; }
11451 if test "${gl_cv_func_unlink_works+set}" = set; then :
11452 $as_echo_n "(cached) " >&6
11453 else
11454 touch conftest.file
11455 # Assume that if we have lstat, we can also check symlinks.
11456 if test $ac_cv_func_lstat = yes; then
11457 ln -s conftest.file conftest.lnk
11458 fi
11459 if test "$cross_compiling" = yes; then :
11460 gl_cv_func_unlink_works="guessing no"
11461 else
11462 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11463 /* end confdefs.h. */
11464 #include <unistd.h>
11465 #include <errno.h>
11466
11467 int
11468 main ()
11469 {
11470 if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1;
11471 #if HAVE_LSTAT
11472 if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2;
11473 #endif
11474
11475 ;
11476 return 0;
11477 }
11478 _ACEOF
11479 if ac_fn_c_try_run "$LINENO"; then :
11480 gl_cv_func_unlink_works=yes
11481 else
11482 gl_cv_func_unlink_works=no
11483 fi
11484 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
11485 conftest.$ac_objext conftest.beam conftest.$ac_ext
11486 fi
11487
11488 rm -f conftest.file conftest.lnk
11489 fi
11490 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unlink_works" >&5
11491 $as_echo "$gl_cv_func_unlink_works" >&6; }
11492 if test x"$gl_cv_func_unlink_works" != xyes; then
11493 REPLACE_UNLINK=1
11494
11495
11496
11497
11498
11499
11500
11501
11502 gl_LIBOBJS="$gl_LIBOBJS unlink.$ac_objext"
11503
1072211504 fi
1072311505
1072411506
1103911821
1104011822 fi
1104111823
11042
11043 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether system is Windows or MSDOS" >&5
11044 $as_echo_n "checking whether system is Windows or MSDOS... " >&6; }
11045 if test "${ac_cv_win_or_dos+set}" = set; then :
11046 $as_echo_n "(cached) " >&6
11047 else
11048
11049 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11050 /* end confdefs.h. */
11051
11052 int
11053 main ()
11054 {
11055
11056 #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
11057 neither MSDOS nor Windows
11058 #endif
11059 ;
11060 return 0;
11061 }
11062 _ACEOF
11063 if ac_fn_c_try_compile "$LINENO"; then :
11064 ac_cv_win_or_dos=yes
11065 else
11066 ac_cv_win_or_dos=no
11067 fi
11068 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11069
11070 fi
11071 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_win_or_dos" >&5
11072 $as_echo "$ac_cv_win_or_dos" >&6; }
11073
11074 if test x"$ac_cv_win_or_dos" = xyes; then
11075 ac_fs_accepts_drive_letter_prefix=1
11076 ac_fs_backslash_is_file_name_separator=1
11077 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether drive letter can start relative path" >&5
11078 $as_echo_n "checking whether drive letter can start relative path... " >&6; }
11079 if test "${ac_cv_drive_letter_can_be_relative+set}" = set; then :
11080 $as_echo_n "(cached) " >&6
11081 else
11082
11083 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11084 /* end confdefs.h. */
11085
11086 int
11087 main ()
11088 {
11089
11090 #if defined __CYGWIN__
11091 drive letters are always absolute
11092 #endif
11093 ;
11094 return 0;
11095 }
11096 _ACEOF
11097 if ac_fn_c_try_compile "$LINENO"; then :
11098 ac_cv_drive_letter_can_be_relative=yes
11099 else
11100 ac_cv_drive_letter_can_be_relative=no
11101 fi
11102 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11103
11104 fi
11105 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_drive_letter_can_be_relative" >&5
11106 $as_echo "$ac_cv_drive_letter_can_be_relative" >&6; }
11107 if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
11108 ac_fs_drive_letter_can_be_relative=1
11109 else
11110 ac_fs_drive_letter_can_be_relative=0
11111 fi
11112 else
11113 ac_fs_accepts_drive_letter_prefix=0
11114 ac_fs_backslash_is_file_name_separator=0
11115 ac_fs_drive_letter_can_be_relative=0
11116 fi
11117
11118
11119 cat >>confdefs.h <<_ACEOF
11120 #define FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX $ac_fs_accepts_drive_letter_prefix
11121 _ACEOF
11122
11123
11124
11125
11126
11127 cat >>confdefs.h <<_ACEOF
11128 #define FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR $ac_fs_backslash_is_file_name_separator
11129 _ACEOF
11130
11131
11132
11133 cat >>confdefs.h <<_ACEOF
11134 #define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE $ac_fs_drive_letter_can_be_relative
11135 _ACEOF
11136
11137
1113811824 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5
1113911825 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; }
1114011826 if test "${ac_cv_header_stdbool_h+set}" = set; then :
1114311829 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1114411830 /* end confdefs.h. */
1114511831
11146 #include <stdbool.h>
11147 #ifndef bool
11148 "error: bool is not defined"
11149 #endif
11150 #ifndef false
11151 "error: false is not defined"
11152 #endif
11153 #if false
11154 "error: false is not 0"
11155 #endif
11156 #ifndef true
11157 "error: true is not defined"
11158 #endif
11159 #if true != 1
11160 "error: true is not 1"
11161 #endif
11162 #ifndef __bool_true_false_are_defined
11163 "error: __bool_true_false_are_defined is not defined"
11164 #endif
11165
11166 struct s { _Bool s: 1; _Bool t; } s;
11167
11168 char a[true == 1 ? 1 : -1];
11169 char b[false == 0 ? 1 : -1];
11170 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
11171 char d[(bool) 0.5 == true ? 1 : -1];
11172 bool e = &s;
11173 char f[(_Bool) 0.0 == false ? 1 : -1];
11174 char g[true];
11175 char h[sizeof (_Bool)];
11176 char i[sizeof s.t];
11177 enum { j = false, k = true, l = false * true, m = true * 256 };
11178 _Bool n[m];
11179 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
11180 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
11181 #if defined __xlc__ || defined __GNUC__
11182 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
11183 reported by James Lemley on 2005-10-05; see
11184 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
11185 This test is not quite right, since xlc is allowed to
11186 reject this program, as the initializer for xlcbug is
11187 not one of the forms that C requires support for.
11188 However, doing the test right would require a run-time
11189 test, and that would make cross-compilation harder.
11190 Let us hope that IBM fixes the xlc bug, and also adds
11191 support for this kind of constant expression. In the
11192 meantime, this test will reject xlc, which is OK, since
11193 our stdbool.h substitute should suffice. We also test
11194 this with GCC, where it should work, to detect more
11195 quickly whether someone messes up the test in the
11196 future. */
11197 char digs[] = "0123456789";
11198 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
11199 #endif
11200 /* Catch a bug in an HP-UX C compiler. See
11201 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
11202 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
11203 */
11204 _Bool q = true;
11205 _Bool *pq = &q;
11832 #include <stdbool.h>
11833 #ifndef bool
11834 "error: bool is not defined"
11835 #endif
11836 #ifndef false
11837 "error: false is not defined"
11838 #endif
11839 #if false
11840 "error: false is not 0"
11841 #endif
11842 #ifndef true
11843 "error: true is not defined"
11844 #endif
11845 #if true != 1
11846 "error: true is not 1"
11847 #endif
11848 #ifndef __bool_true_false_are_defined
11849 "error: __bool_true_false_are_defined is not defined"
11850 #endif
11851
11852 struct s { _Bool s: 1; _Bool t; } s;
11853
11854 char a[true == 1 ? 1 : -1];
11855 char b[false == 0 ? 1 : -1];
11856 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
11857 char d[(bool) 0.5 == true ? 1 : -1];
11858 bool e = &s;
11859 char f[(_Bool) 0.0 == false ? 1 : -1];
11860 char g[true];
11861 char h[sizeof (_Bool)];
11862 char i[sizeof s.t];
11863 enum { j = false, k = true, l = false * true, m = true * 256 };
11864 _Bool n[m];
11865 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
11866 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
11867 #if defined __xlc__ || defined __GNUC__
11868 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
11869 reported by James Lemley on 2005-10-05; see
11870 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
11871 This test is not quite right, since xlc is allowed to
11872 reject this program, as the initializer for xlcbug is
11873 not one of the forms that C requires support for.
11874 However, doing the test right would require a run-time
11875 test, and that would make cross-compilation harder.
11876 Let us hope that IBM fixes the xlc bug, and also adds
11877 support for this kind of constant expression. In the
11878 meantime, this test will reject xlc, which is OK, since
11879 our stdbool.h substitute should suffice. We also test
11880 this with GCC, where it should work, to detect more
11881 quickly whether someone messes up the test in the
11882 future. */
11883 char digs[] = "0123456789";
11884 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
11885 #endif
11886 /* Catch a bug in an HP-UX C compiler. See
11887 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
11888 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
11889 */
11890 _Bool q = true;
11891 _Bool *pq = &q;
1120611892
1120711893 int
1120811894 main ()
1120911895 {
1121011896
11211 *pq |= q;
11212 *pq |= ! q;
11213 /* Refer to every declared value, to avoid compiler optimizations. */
11214 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
11215 + !m + !n + !o + !p + !q + !pq);
11897 *pq |= q;
11898 *pq |= ! q;
11899 /* Refer to every declared value, to avoid compiler optimizations. */
11900 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
11901 + !m + !n + !o + !p + !q + !pq);
1121611902
1121711903 ;
1121811904 return 0;
1125911945 /* end confdefs.h. */
1126011946
1126111947 /* For now, do not test the preprocessor; as of 2007 there are too many
11262 implementations with broken preprocessors. Perhaps this can
11263 be revisited in 2012. In the meantime, code should not expect
11264 #if to work with literals wider than 32 bits. */
11948 implementations with broken preprocessors. Perhaps this can
11949 be revisited in 2012. In the meantime, code should not expect
11950 #if to work with literals wider than 32 bits. */
1126511951 /* Test literals. */
1126611952 long long int ll = 9223372036854775807ll;
1126711953 long long int nll = -9223372036854775807LL;
1126811954 unsigned long long int ull = 18446744073709551615ULL;
1126911955 /* Test constant expressions. */
1127011956 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
11271 ? 1 : -1)];
11957 ? 1 : -1)];
1127211958 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
11273 ? 1 : -1)];
11959 ? 1 : -1)];
1127411960 int i = 63;
1127511961 int
1127611962 main ()
1127911965 long long int llmax = 9223372036854775807ll;
1128011966 unsigned long long int ullmax = 18446744073709551615ull;
1128111967 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
11282 | (llmax / ll) | (llmax % ll)
11283 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
11284 | (ullmax / ull) | (ullmax % ull));
11968 | (llmax / ll) | (llmax % ll)
11969 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
11970 | (ullmax / ull) | (ullmax % ull));
1128511971 ;
1128611972 return 0;
1128711973 }
1131011996
1131111997
1131211998
11999
12000 ac_fn_c_check_decl "$LINENO" "strdup" "ac_cv_have_decl_strdup" "$ac_includes_default"
12001 if test "x$ac_cv_have_decl_strdup" = x""yes; then :
12002 ac_have_decl=1
12003 else
12004 ac_have_decl=0
12005 fi
12006
12007 cat >>confdefs.h <<_ACEOF
12008 #define HAVE_DECL_STRDUP $ac_have_decl
12009 _ACEOF
1131312010
1131412011
1131512012
1142512122 $as_echo_n "(cached) " >&6
1142612123 else
1142712124
11428 if test $ac_cv_header_string_h = yes; then
11429 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12125 if test $ac_cv_header_string_h = yes; then
12126 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1143012127 /* end confdefs.h. */
1143112128 #include <string.h>
1143212129
1143312130 _ACEOF
11434 case "$host_os" in
11435 aix*) gl_absname_cpp="$ac_cpp -C" ;;
11436 *) gl_absname_cpp="$ac_cpp" ;;
11437 esac
11438 gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
11439 sed -n '\#/string.h#{
11440 s#.*"\(.*/string.h\)".*#\1#
11441 s#^/[^/]#//&#
11442 p
11443 q
11444 }'`'"'
11445 else
11446 gl_cv_next_string_h='<'string.h'>'
11447 fi
12131 case "$host_os" in
12132 aix*) gl_absname_cpp="$ac_cpp -C" ;;
12133 *) gl_absname_cpp="$ac_cpp" ;;
12134 esac
12135 gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
12136 sed -n '\#/string.h#{
12137 s#.*"\(.*/string.h\)".*#\1#
12138 s#^/[^/]#//&#
12139 p
12140 q
12141 }'`'"'
12142 else
12143 gl_cv_next_string_h='<'string.h'>'
12144 fi
1144812145
1144912146 fi
1145012147 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_string_h" >&5
1160212299 $as_echo_n "(cached) " >&6
1160312300 else
1160412301
11605 if test $ac_cv_header_time_h = yes; then
11606 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12302 if test $ac_cv_header_time_h = yes; then
12303 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1160712304 /* end confdefs.h. */
1160812305 #include <time.h>
1160912306
1161012307 _ACEOF
11611 case "$host_os" in
11612 aix*) gl_absname_cpp="$ac_cpp -C" ;;
11613 *) gl_absname_cpp="$ac_cpp" ;;
11614 esac
11615 gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
11616 sed -n '\#/time.h#{
11617 s#.*"\(.*/time.h\)".*#\1#
11618 s#^/[^/]#//&#
11619 p
11620 q
11621 }'`'"'
11622 else
11623 gl_cv_next_time_h='<'time.h'>'
11624 fi
12308 case "$host_os" in
12309 aix*) gl_absname_cpp="$ac_cpp -C" ;;
12310 *) gl_absname_cpp="$ac_cpp" ;;
12311 esac
12312 gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
12313 sed -n '\#/time.h#{
12314 s#.*"\(.*/time.h\)".*#\1#
12315 s#^/[^/]#//&#
12316 p
12317 q
12318 }'`'"'
12319 else
12320 gl_cv_next_time_h='<'time.h'>'
12321 fi
1162512322
1162612323 fi
1162712324 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_time_h" >&5
1164512342
1164612343
1164712344
11648
11649
11650 { $as_echo "$as_me:${as_lineno-$LINENO}: checking determine whether the utimes function works" >&5
11651 $as_echo_n "checking determine whether the utimes function works... " >&6; }
12345 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the utimes function works" >&5
12346 $as_echo_n "checking whether the utimes function works... " >&6; }
1165212347 if test "${gl_cv_func_working_utimes+set}" = set; then :
1165312348 $as_echo_n "(cached) " >&6
1165412349 else
1168012375 int fd;
1168112376
1168212377 int ok = ((f = fopen (file, "w"))
11683 && fclose (f) == 0
11684 && utimes (file, timeval) == 0
11685 && lstat (file, &sbuf) == 0
11686 && sbuf.st_atime == timeval[0].tv_sec
11687 && sbuf.st_mtime == timeval[1].tv_sec);
12378 && fclose (f) == 0
12379 && utimes (file, timeval) == 0
12380 && lstat (file, &sbuf) == 0
12381 && sbuf.st_atime == timeval[0].tv_sec
12382 && sbuf.st_mtime == timeval[1].tv_sec);
1168812383 unlink (file);
1168912384 if (!ok)
1169012385 exit (1);
1170212397 exit (1);
1170312398
1170412399 ok = (0 <= (fd = open (file, O_WRONLY|O_CREAT, 0444))
11705 && close (fd) == 0
11706 && utimes (file, NULL) == 0);
12400 && close (fd) == 0
12401 && utimes (file, NULL) == 0);
1170712402 unlink (file);
1170812403
1170912404 exit (!ok);
1174112436 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1174212437 /* end confdefs.h. */
1174312438 #if HAVE_SYS_TIME_H
11744 #include <sys/time.h>
11745 #endif
11746 #include <time.h>
11747 #ifdef HAVE_UTIME_H
11748 #include <utime.h>
11749 #endif
12439 #include <sys/time.h>
12440 #endif
12441 #include <time.h>
12442 #ifdef HAVE_UTIME_H
12443 #include <utime.h>
12444 #endif
1175012445
1175112446 int
1175212447 main ()
1178112476
1178212477
1178312478
12479
12480
12481 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether <wchar.h> uses 'inline' correctly" >&5
12482 $as_echo_n "checking whether <wchar.h> uses 'inline' correctly... " >&6; }
12483 if test "${gl_cv_header_wchar_h_correct_inline+set}" = set; then :
12484 $as_echo_n "(cached) " >&6
12485 else
12486 gl_cv_header_wchar_h_correct_inline=yes
12487 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12488 /* end confdefs.h. */
12489
12490 #define wcstod renamed_wcstod
12491 #include <wchar.h>
12492 extern int zero (void);
12493 int main () { return zero(); }
12494
12495 _ACEOF
12496 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
12497 (eval $ac_compile) 2>&5
12498 ac_status=$?
12499 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12500 test $ac_status = 0; }; then
12501 mv conftest.$ac_objext conftest1.$ac_objext
12502 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12503 /* end confdefs.h. */
12504
12505 #define wcstod renamed_wcstod
12506 #include <wchar.h>
12507 int zero (void) { return 0; }
12508
12509 _ACEOF
12510 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
12511 (eval $ac_compile) 2>&5
12512 ac_status=$?
12513 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12514 test $ac_status = 0; }; then
12515 mv conftest.$ac_objext conftest2.$ac_objext
12516 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&5 2>&1; then
12517 :
12518 else
12519 gl_cv_header_wchar_h_correct_inline=no
12520 fi
12521 fi
12522 fi
12523 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
12524
12525 fi
12526 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_wchar_h_correct_inline" >&5
12527 $as_echo "$gl_cv_header_wchar_h_correct_inline" >&6; }
12528 if test $gl_cv_header_wchar_h_correct_inline = no; then
12529 as_fn_error "<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
12530 This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
12531 C99 mode. You have four options:
12532 - Add the flag -fgnu89-inline to CC and reconfigure, or
12533 - Fix your include files, using parts of
12534 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
12535 - Use a gcc version older than 4.3, or
12536 - Don't use the flags -std=c99 or -std=gnu99.
12537 Configuration aborted." "$LINENO" 5
12538 fi
1178412539
1178512540
1178612541
1193712692
1193812693
1193912694 GNULIB_CALLOC_POSIX=1
12695
12696
12697 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether this system has an arbitrary file name length limit" >&5
12698 $as_echo_n "checking whether this system has an arbitrary file name length limit... " >&6; }
12699 if test "${gl_cv_have_arbitrary_file_name_length_limit+set}" = set; then :
12700 $as_echo_n "(cached) " >&6
12701 else
12702 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12703 /* end confdefs.h. */
12704 #include <unistd.h>
12705 #include <limits.h>
12706 #if defined PATH_MAX || defined MAXPATHLEN
12707 have_arbitrary_file_name_length_limit
12708 #endif
12709 _ACEOF
12710 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
12711 $EGREP "have_arbitrary_file_name_length_limit" >/dev/null 2>&1; then :
12712 gl_cv_have_arbitrary_file_name_length_limit=yes
12713 else
12714 gl_cv_have_arbitrary_file_name_length_limit=no
12715 fi
12716 rm -f conftest*
12717
12718 fi
12719 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_have_arbitrary_file_name_length_limit" >&5
12720 $as_echo "$gl_cv_have_arbitrary_file_name_length_limit" >&6; }
12721
12722 if test $gl_cv_have_arbitrary_file_name_length_limit = yes; then
12723
12724
12725
12726
12727
12728
12729
12730
12731 gl_LIBOBJS="$gl_LIBOBJS chdir-long.$ac_objext"
12732
12733
12734
12735 :
12736
12737 fi
12738
12739
12740
12741
12742 GNULIB_CHOWN=1
1194012743
1194112744
1194212745
1207612879
1207712880 :
1207812881
12882 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for d_ino member in directory struct" >&5
12883 $as_echo_n "checking for d_ino member in directory struct... " >&6; }
12884 if test "${gl_cv_struct_dirent_d_ino+set}" = set; then :
12885 $as_echo_n "(cached) " >&6
12886 else
12887 if test "$cross_compiling" = yes; then :
12888 gl_cv_struct_dirent_d_ino=no
12889 else
12890 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12891 /* end confdefs.h. */
12892 #include <sys/types.h>
12893 #include <sys/stat.h>
12894 #include <dirent.h>
12895
12896 int
12897 main ()
12898 {
12899 DIR *dp = opendir (".");
12900 struct dirent *e;
12901 struct stat st;
12902 if (! dp)
12903 return 1;
12904 e = readdir (dp);
12905 return ! (e
12906 && stat (e->d_name, &st) == 0
12907 && e->d_ino == st.st_ino);
12908 ;
12909 return 0;
12910 }
12911 _ACEOF
12912 if ac_fn_c_try_run "$LINENO"; then :
12913 gl_cv_struct_dirent_d_ino=yes
12914 else
12915 gl_cv_struct_dirent_d_ino=no
12916 fi
12917 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
12918 conftest.$ac_objext conftest.beam conftest.$ac_ext
12919 fi
12920
12921 fi
12922 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_struct_dirent_d_ino" >&5
12923 $as_echo "$gl_cv_struct_dirent_d_ino" >&6; }
12924 if test $gl_cv_struct_dirent_d_ino = yes; then
12925
12926 $as_echo "#define D_INO_IN_DIRENT 1" >>confdefs.h
12927
12928 fi
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940 if test $gl_cv_have_include_next = yes; then
12941 gl_cv_next_dirent_h='<'dirent.h'>'
12942 else
12943 { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <dirent.h>" >&5
12944 $as_echo_n "checking absolute name of <dirent.h>... " >&6; }
12945 if test "${gl_cv_next_dirent_h+set}" = set; then :
12946 $as_echo_n "(cached) " >&6
12947 else
12948
12949 if test $ac_cv_header_dirent_h = yes; then
12950 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12951 /* end confdefs.h. */
12952 #include <dirent.h>
12953
12954 _ACEOF
12955 case "$host_os" in
12956 aix*) gl_absname_cpp="$ac_cpp -C" ;;
12957 *) gl_absname_cpp="$ac_cpp" ;;
12958 esac
12959 gl_cv_next_dirent_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
12960 sed -n '\#/dirent.h#{
12961 s#.*"\(.*/dirent.h\)".*#\1#
12962 s#^/[^/]#//&#
12963 p
12964 q
12965 }'`'"'
12966 else
12967 gl_cv_next_dirent_h='<'dirent.h'>'
12968 fi
12969
12970 fi
12971 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_dirent_h" >&5
12972 $as_echo "$gl_cv_next_dirent_h" >&6; }
12973 fi
12974 NEXT_DIRENT_H=$gl_cv_next_dirent_h
12975
12976 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
12977 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
12978 gl_next_as_first_directive='<'dirent.h'>'
12979 else
12980 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
12981 gl_next_as_first_directive=$gl_cv_next_dirent_h
12982 fi
12983 NEXT_AS_FIRST_DIRECTIVE_DIRENT_H=$gl_next_as_first_directive
12984
12985
12986
12987
12988
12989
12990
12991 :
12992
12993
12994
12995
12996
12997
12998
12999 for ac_func in dirfd
13000 do :
13001 ac_fn_c_check_func "$LINENO" "dirfd" "ac_cv_func_dirfd"
13002 if test "x$ac_cv_func_dirfd" = x""yes; then :
13003 cat >>confdefs.h <<_ACEOF
13004 #define HAVE_DIRFD 1
13005 _ACEOF
13006
13007 fi
13008 done
13009
13010 ac_fn_c_check_decl "$LINENO" "dirfd" "ac_cv_have_decl_dirfd" "#include <sys/types.h>
13011 #include <dirent.h>
13012 "
13013 if test "x$ac_cv_have_decl_dirfd" = x""yes; then :
13014 ac_have_decl=1
13015 else
13016 ac_have_decl=0
13017 fi
13018
13019 cat >>confdefs.h <<_ACEOF
13020 #define HAVE_DECL_DIRFD $ac_have_decl
13021 _ACEOF
13022
13023 if test $ac_cv_have_decl_dirfd = no; then
13024 HAVE_DECL_DIRFD=0
13025 fi
13026
13027 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether dirfd is a macro" >&5
13028 $as_echo_n "checking whether dirfd is a macro... " >&6; }
13029 if test "${gl_cv_func_dirfd_macro+set}" = set; then :
13030 $as_echo_n "(cached) " >&6
13031 else
13032 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13033 /* end confdefs.h. */
13034
13035 #include <sys/types.h>
13036 #include <dirent.h>
13037 #ifdef dirfd
13038 dirent_header_defines_dirfd
13039 #endif
13040 _ACEOF
13041 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
13042 $EGREP "dirent_header_defines_dirfd" >/dev/null 2>&1; then :
13043 gl_cv_func_dirfd_macro=yes
13044 else
13045 gl_cv_func_dirfd_macro=no
13046 fi
13047 rm -f conftest*
13048
13049 fi
13050 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_dirfd_macro" >&5
13051 $as_echo "$gl_cv_func_dirfd_macro" >&6; }
13052
13053 # Use the replacement only if we have no function, macro,
13054 # or declaration with that name.
13055 if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$gl_cv_func_dirfd_macro \
13056 = no,no,no; then
13057
13058
13059
13060
13061
13062
13063
13064
13065 for ac_func in dirfd
13066 do :
13067 ac_fn_c_check_func "$LINENO" "dirfd" "ac_cv_func_dirfd"
13068 if test "x$ac_cv_func_dirfd" = x""yes; then :
13069 cat >>confdefs.h <<_ACEOF
13070 #define HAVE_DIRFD 1
13071 _ACEOF
13072
13073 else
13074
13075 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
13076
13077 fi
13078 done
13079
13080
13081 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to get the file descriptor associated with an open DIR*" >&5
13082 $as_echo_n "checking how to get the file descriptor associated with an open DIR*... " >&6; }
13083 if test "${gl_cv_sys_dir_fd_member_name+set}" = set; then :
13084 $as_echo_n "(cached) " >&6
13085 else
13086
13087 dirfd_save_CFLAGS=$CFLAGS
13088 for ac_expr in d_fd dd_fd; do
13089
13090 CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
13091 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13092 /* end confdefs.h. */
13093
13094 #include <sys/types.h>
13095 #include <dirent.h>
13096 int
13097 main ()
13098 {
13099 DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;
13100 ;
13101 return 0;
13102 }
13103 _ACEOF
13104 if ac_fn_c_try_compile "$LINENO"; then :
13105 dir_fd_found=yes
13106
13107 fi
13108 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13109 CFLAGS=$dirfd_save_CFLAGS
13110 test "$dir_fd_found" = yes && break
13111 done
13112 test "$dir_fd_found" = yes || ac_expr=no_such_member
13113
13114 gl_cv_sys_dir_fd_member_name=$ac_expr
13115
13116
13117 fi
13118 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sys_dir_fd_member_name" >&5
13119 $as_echo "$gl_cv_sys_dir_fd_member_name" >&6; }
13120 if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
13121
13122 cat >>confdefs.h <<_ACEOF
13123 #define DIR_FD_MEMBER_NAME $gl_cv_sys_dir_fd_member_name
13124 _ACEOF
13125
13126 fi
13127
13128 fi
13129
13130
13131
13132 GNULIB_DIRFD=1
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143 gl_LIBOBJS="$gl_LIBOBJS basename-lgpl.$ac_objext"
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153 gl_LIBOBJS="$gl_LIBOBJS dirname-lgpl.$ac_objext"
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163 gl_LIBOBJS="$gl_LIBOBJS stripslash.$ac_objext"
13164
13165
13166
13167
13168
13169
13170
13171
13172 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether // is distinct from /" >&5
13173 $as_echo_n "checking whether // is distinct from /... " >&6; }
13174 if test "${gl_cv_double_slash_root+set}" = set; then :
13175 $as_echo_n "(cached) " >&6
13176 else
13177 if test x"$cross_compiling" = xyes ; then
13178 # When cross-compiling, there is no way to tell whether // is special
13179 # short of a list of hosts. However, the only known hosts to date
13180 # that have a distinct // are Apollo DomainOS (too old to port to),
13181 # Cygwin, and z/OS. If anyone knows of another system for which // has
13182 # special semantics and is distinct from /, please report it to
13183 # <bug-gnulib@gnu.org>.
13184 case $host in
13185 *-cygwin | i370-ibm-openedition)
13186 gl_cv_double_slash_root=yes ;;
13187 *)
13188 # Be optimistic and assume that / and // are the same when we
13189 # don't know.
13190 gl_cv_double_slash_root='unknown, assuming no' ;;
13191 esac
13192 else
13193 set x `ls -di / // 2>/dev/null`
13194 if test "$2" = "$4" && wc //dev/null >/dev/null 2>&1; then
13195 gl_cv_double_slash_root=no
13196 else
13197 gl_cv_double_slash_root=yes
13198 fi
13199 fi
13200 fi
13201 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_double_slash_root" >&5
13202 $as_echo "$gl_cv_double_slash_root" >&6; }
13203 if test "$gl_cv_double_slash_root" = yes; then
13204
13205 $as_echo "#define DOUBLE_SLASH_IS_DISTINCT_ROOT 1" >>confdefs.h
13206
13207 fi
13208
1207913209
1208013210
1208113211
1210013230 else
1210113231 if test "$cross_compiling" = yes; then :
1210213232 case "$host_os" in
12103 mingw*) # on this platform, dup2 always returns 0 for success
12104 gl_cv_func_dup2_works=no;;
12105 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
12106 gl_cv_func_dup2_works=no;;
12107 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
12108 # closed fd may yield -EBADF instead of -1 / errno=EBADF.
12109 gl_cv_func_dup2_works=no;;
13233 mingw*) # on this platform, dup2 always returns 0 for success
13234 gl_cv_func_dup2_works=no;;
13235 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
13236 gl_cv_func_dup2_works=no;;
13237 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
13238 # closed fd may yield -EBADF instead of -1 / errno=EBADF.
13239 gl_cv_func_dup2_works=no;;
1211013240 freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
12111 gl_cv_func_dup2_works=no;;
12112 *) gl_cv_func_dup2_works=yes;;
12113 esac
13241 gl_cv_func_dup2_works=no;;
13242 *) gl_cv_func_dup2_works=yes;;
13243 esac
1211413244 else
1211513245 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1211613246 /* end confdefs.h. */
1215113281 if test "$gl_cv_func_dup2_works" = no; then
1215213282
1215313283
12154 REPLACE_DUP2=1
13284 if test $ac_cv_func_dup2 = yes; then
13285 REPLACE_DUP2=1
13286 fi
1215513287
1215613288
1215713289
1216513297
1216613298 fi
1216713299 fi
12168
12169 cat >>confdefs.h <<_ACEOF
12170 #define REPLACE_DUP2 $REPLACE_DUP2
12171 _ACEOF
12172
1217313300
1217413301
1217513302
1223013357
1223113358
1223213359
13360
1223313361 :
1223413362
1223513363
1225913387
1226013388
1226113389
13390
13391 if test $ac_cv_func_fchdir = no; then
13392 REPLACE_FCHDIR=1
13393
13394
13395
13396
13397
13398
13399
13400
13401 gl_LIBOBJS="$gl_LIBOBJS fchdir.$ac_objext"
13402
13403 :
13404
13405 $as_echo "#define REPLACE_FCHDIR 1" >>confdefs.h
13406
13407 REPLACE_OPENDIR=1
13408 REPLACE_CLOSEDIR=1
13409 REPLACE_DUP=1
13410
13411
13412 REPLACE_OPEN=1
13413
13414
13415
13416
13417
13418
13419
13420
13421 gl_LIBOBJS="$gl_LIBOBJS open.$ac_objext"
13422
13423
13424
13425
13426 :
13427
13428
13429
13430
13431 REPLACE_CLOSE=1
13432
13433
13434
13435
13436
13437
13438
13439
13440 gl_LIBOBJS="$gl_LIBOBJS close.$ac_objext"
13441
13442
13443
13444 REPLACE_FCLOSE=1
13445
13446
13447
13448
13449
13450
13451
13452
13453 gl_LIBOBJS="$gl_LIBOBJS fclose.$ac_objext"
13454
13455
13456
13457
13458
13459 if test $ac_cv_func_dup2 = yes; then
13460 REPLACE_DUP2=1
13461 fi
13462
13463
13464
13465
13466
13467
13468
13469
13470 gl_LIBOBJS="$gl_LIBOBJS dup2.$ac_objext"
13471
13472
13473
13474
13475
13476 if test $ac_cv_func_fcntl = no; then
13477 HAVE_FCNTL=0
13478 else
13479 REPLACE_FCNTL=1
13480 fi
13481
13482
13483
13484
13485
13486
13487
13488
13489 gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
13490
13491
13492
13493 :
13494
13495 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open can visit directories" >&5
13496 $as_echo_n "checking whether open can visit directories... " >&6; }
13497 if test "${gl_cv_func_open_directory_works+set}" = set; then :
13498 $as_echo_n "(cached) " >&6
13499 else
13500 if test "$cross_compiling" = yes; then :
13501 gl_cv_func_open_directory_works="guessing no"
13502 else
13503 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13504 /* end confdefs.h. */
13505 #include <fcntl.h>
13506
13507 int
13508 main ()
13509 {
13510 return open(".", O_RDONLY) < 0;
13511 ;
13512 return 0;
13513 }
13514 _ACEOF
13515 if ac_fn_c_try_run "$LINENO"; then :
13516 gl_cv_func_open_directory_works=yes
13517 else
13518 gl_cv_func_open_directory_works=no
13519 fi
13520 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
13521 conftest.$ac_objext conftest.beam conftest.$ac_ext
13522 fi
13523
13524 fi
13525 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_directory_works" >&5
13526 $as_echo "$gl_cv_func_open_directory_works" >&6; }
13527 if test "$gl_cv_func_open_directory_works" != yes; then
13528
13529 $as_echo "#define REPLACE_OPEN_DIRECTORY 1" >>confdefs.h
13530
13531 REPLACE_FSTAT=1
13532 fi
13533 fi
13534
13535
13536
13537 GNULIB_FCHDIR=1
13538
13539
13540
13541
13542
1226213543 GNULIB_FCLOSE=1
13544
13545
13546
13547
13548
13549
13550 if test $ac_cv_func_fcntl = no; then
13551
13552
13553
13554 if test $ac_cv_func_fcntl = no; then
13555 HAVE_FCNTL=0
13556 else
13557 REPLACE_FCNTL=1
13558 fi
13559
13560
13561
13562
13563
13564
13565
13566
13567 gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
13568
13569
13570 else
13571 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl handles F_DUPFD correctly" >&5
13572 $as_echo_n "checking whether fcntl handles F_DUPFD correctly... " >&6; }
13573 if test "${gl_cv_func_fcntl_f_dupfd_works+set}" = set; then :
13574 $as_echo_n "(cached) " >&6
13575 else
13576 if test "$cross_compiling" = yes; then :
13577 # Guess that it works on glibc systems
13578 case $host_os in #((
13579 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
13580 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
13581 esac
13582 else
13583 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13584 /* end confdefs.h. */
13585
13586 #include <fcntl.h>
13587
13588 int
13589 main ()
13590 {
13591 return fcntl (0, F_DUPFD, -1) != -1;
13592
13593 ;
13594 return 0;
13595 }
13596 _ACEOF
13597 if ac_fn_c_try_run "$LINENO"; then :
13598 gl_cv_func_fcntl_f_dupfd_works=yes
13599 else
13600 gl_cv_func_fcntl_f_dupfd_works=no
13601 fi
13602 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
13603 conftest.$ac_objext conftest.beam conftest.$ac_ext
13604 fi
13605
13606 fi
13607 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_works" >&5
13608 $as_echo "$gl_cv_func_fcntl_f_dupfd_works" >&6; }
13609 case $gl_cv_func_fcntl_f_dupfd_works in
13610 *yes) ;;
13611 *)
13612
13613
13614 if test $ac_cv_func_fcntl = no; then
13615 HAVE_FCNTL=0
13616 else
13617 REPLACE_FCNTL=1
13618 fi
13619
13620
13621
13622
13623
13624
13625
13626
13627 gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
13628
13629
13630
13631 $as_echo "#define FCNTL_DUPFD_BUGGY 1" >>confdefs.h
13632 ;;
13633 esac
13634
13635 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fcntl understands F_DUPFD_CLOEXEC" >&5
13636 $as_echo_n "checking whether fcntl understands F_DUPFD_CLOEXEC... " >&6; }
13637 if test "${gl_cv_func_fcntl_f_dupfd_cloexec+set}" = set; then :
13638 $as_echo_n "(cached) " >&6
13639 else
13640 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13641 /* end confdefs.h. */
13642
13643 #include <fcntl.h>
13644 #ifndef F_DUPFD_CLOEXEC
13645 choke me
13646 #endif
13647
13648 int
13649 main ()
13650 {
13651
13652 ;
13653 return 0;
13654 }
13655 _ACEOF
13656 if ac_fn_c_try_compile "$LINENO"; then :
13657 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13658 /* end confdefs.h. */
13659
13660 #ifdef __linux__
13661 /* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
13662 it to support the semantics on older kernels that failed with EINVAL. */
13663 choke me
13664 #endif
13665
13666 int
13667 main ()
13668 {
13669
13670 ;
13671 return 0;
13672 }
13673 _ACEOF
13674 if ac_fn_c_try_compile "$LINENO"; then :
13675 gl_cv_func_fcntl_f_dupfd_cloexec=yes
13676 else
13677 gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"
13678 fi
13679 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13680 else
13681 gl_cv_func_fcntl_f_dupfd_cloexec=no
13682 fi
13683 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13684 fi
13685 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fcntl_f_dupfd_cloexec" >&5
13686 $as_echo "$gl_cv_func_fcntl_f_dupfd_cloexec" >&6; }
13687 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
13688
13689
13690
13691 if test $ac_cv_func_fcntl = no; then
13692 HAVE_FCNTL=0
13693 else
13694 REPLACE_FCNTL=1
13695 fi
13696
13697
13698
13699
13700
13701
13702
13703
13704 gl_LIBOBJS="$gl_LIBOBJS fcntl.$ac_objext"
13705
13706
13707 fi
13708 fi
13709
13710
13711
13712 GNULIB_FCNTL=1
1226313713
1226413714
1226513715
1227913729 $as_echo_n "(cached) " >&6
1228013730 else
1228113731
12282 if test $ac_cv_header_fcntl_h = yes; then
12283 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13732 if test $ac_cv_header_fcntl_h = yes; then
13733 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1228413734 /* end confdefs.h. */
1228513735 #include <fcntl.h>
1228613736
1228713737 _ACEOF
12288 case "$host_os" in
12289 aix*) gl_absname_cpp="$ac_cpp -C" ;;
12290 *) gl_absname_cpp="$ac_cpp" ;;
12291 esac
12292 gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
12293 sed -n '\#/fcntl.h#{
12294 s#.*"\(.*/fcntl.h\)".*#\1#
12295 s#^/[^/]#//&#
12296 p
12297 q
12298 }'`'"'
12299 else
12300 gl_cv_next_fcntl_h='<'fcntl.h'>'
12301 fi
13738 case "$host_os" in
13739 aix*) gl_absname_cpp="$ac_cpp -C" ;;
13740 *) gl_absname_cpp="$ac_cpp" ;;
13741 esac
13742 gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
13743 sed -n '\#/fcntl.h#{
13744 s#.*"\(.*/fcntl.h\)".*#\1#
13745 s#^/[^/]#//&#
13746 p
13747 q
13748 }'`'"'
13749 else
13750 gl_cv_next_fcntl_h='<'fcntl.h'>'
13751 fi
1230213752
1230313753 fi
1230413754 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_fcntl_h" >&5
1231713767
1231813768
1231913769
12320 FCNTL_H='fcntl.h'
12321
1232213770
1232313771
1232413772
1234813796
1234913797 $as_echo "#define GNULIB_FCNTL_SAFER 1" >>confdefs.h
1235013798
13799
13800
13801
13802
13803 if test $ac_cv_func_fdopendir = no; then
13804
13805
13806
13807
13808
13809
13810
13811
13812 gl_LIBOBJS="$gl_LIBOBJS openat-proc.$ac_objext"
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822 gl_LIBOBJS="$gl_LIBOBJS fdopendir.$ac_objext"
13823
13824
13825 :
13826
13827 HAVE_FDOPENDIR=0
13828 else
13829 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fdopendir works" >&5
13830 $as_echo_n "checking whether fdopendir works... " >&6; }
13831 if test "${gl_cv_func_fdopendir_works+set}" = set; then :
13832 $as_echo_n "(cached) " >&6
13833 else
13834 if test "$cross_compiling" = yes; then :
13835 gl_cv_func_fdopendir_works="guessing no"
13836 else
13837 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13838 /* end confdefs.h. */
13839
13840 #include <dirent.h>
13841 #include <fcntl.h>
13842
13843 int
13844 main ()
13845 {
13846 int fd = open ("conftest.c", O_RDONLY);
13847 if (fd < 0) return 2;
13848 return !!fdopendir (fd);
13849 ;
13850 return 0;
13851 }
13852 _ACEOF
13853 if ac_fn_c_try_run "$LINENO"; then :
13854 gl_cv_func_fdopendir_works=yes
13855 else
13856 gl_cv_func_fdopendir_works=no
13857 fi
13858 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
13859 conftest.$ac_objext conftest.beam conftest.$ac_ext
13860 fi
13861
13862 fi
13863 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fdopendir_works" >&5
13864 $as_echo "$gl_cv_func_fdopendir_works" >&6; }
13865 if test "$gl_cv_func_fdopendir_works" != yes; then
13866 REPLACE_FDOPENDIR=1
13867
13868 :
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878 gl_LIBOBJS="$gl_LIBOBJS fdopendir.$ac_objext"
13879
13880 fi
13881 fi
13882
13883
13884
13885 GNULIB_FDOPENDIR=1
1235113886
1235213887
1235313888 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fflush works on input streams" >&5
1236913904 main ()
1237013905 {
1237113906 FILE *f = fopen ("conftest.txt", "r");
12372 char buffer[10];
12373 int fd;
12374 int c;
12375 if (f == NULL)
12376 return 1;
12377 fd = fileno (f);
12378 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
12379 return 2;
12380 /* For deterministic results, ensure f read a bigger buffer. */
12381 if (lseek (fd, 0, SEEK_CUR) == 5)
12382 return 3;
12383 /* POSIX requires fflush-fseek to set file offset of fd. This fails
12384 on BSD systems and on mingw. */
12385 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
12386 return 4;
12387 if (lseek (fd, 0, SEEK_CUR) != 5)
12388 return 5;
12389 /* Verify behaviour of fflush after ungetc. See
12390 <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
12391 /* Verify behaviour of fflush after a backup ungetc. This fails on
12392 mingw. */
12393 c = fgetc (f);
12394 ungetc (c, f);
12395 fflush (f);
12396 if (fgetc (f) != c)
12397 return 6;
12398 /* Verify behaviour of fflush after a non-backup ungetc. This fails
12399 on glibc 2.8 and on BSD systems. */
12400 c = fgetc (f);
12401 ungetc ('@', f);
12402 fflush (f);
12403 if (fgetc (f) != c)
12404 return 7;
12405 return 0;
13907 char buffer[10];
13908 int fd;
13909 int c;
13910 if (f == NULL)
13911 return 1;
13912 fd = fileno (f);
13913 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
13914 return 2;
13915 /* For deterministic results, ensure f read a bigger buffer. */
13916 if (lseek (fd, 0, SEEK_CUR) == 5)
13917 return 3;
13918 /* POSIX requires fflush-fseek to set file offset of fd. This fails
13919 on BSD systems and on mingw. */
13920 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
13921 return 4;
13922 if (lseek (fd, 0, SEEK_CUR) != 5)
13923 return 5;
13924 /* Verify behaviour of fflush after ungetc. See
13925 <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
13926 /* Verify behaviour of fflush after a backup ungetc. This fails on
13927 mingw. */
13928 c = fgetc (f);
13929 ungetc (c, f);
13930 fflush (f);
13931 if (fgetc (f) != c)
13932 return 6;
13933 /* Verify behaviour of fflush after a non-backup ungetc. This fails
13934 on glibc 2.8 and on BSD systems. */
13935 c = fgetc (f);
13936 ungetc ('@', f);
13937 fflush (f);
13938 if (fgetc (f) != c)
13939 return 7;
13940 return 0;
1240613941
1240713942 ;
1240813943 return 0;
1248014015 $as_echo_n "(cached) " >&6
1248114016 else
1248214017
12483 if test $ac_cv_header_float_h = yes; then
12484 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14018 if test $ac_cv_header_float_h = yes; then
14019 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1248514020 /* end confdefs.h. */
1248614021 #include <float.h>
1248714022
1248814023 _ACEOF
12489 case "$host_os" in
12490 aix*) gl_absname_cpp="$ac_cpp -C" ;;
12491 *) gl_absname_cpp="$ac_cpp" ;;
12492 esac
12493 gl_cv_next_float_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
12494 sed -n '\#/float.h#{
12495 s#.*"\(.*/float.h\)".*#\1#
12496 s#^/[^/]#//&#
12497 p
12498 q
12499 }'`'"'
12500 else
12501 gl_cv_next_float_h='<'float.h'>'
12502 fi
14024 case "$host_os" in
14025 aix*) gl_absname_cpp="$ac_cpp -C" ;;
14026 *) gl_absname_cpp="$ac_cpp" ;;
14027 esac
14028 gl_cv_next_float_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
14029 sed -n '\#/float.h#{
14030 s#.*"\(.*/float.h\)".*#\1#
14031 s#^/[^/]#//&#
14032 p
14033 q
14034 }'`'"'
14035 else
14036 gl_cv_next_float_h='<'float.h'>'
14037 fi
1250314038
1250414039 fi
1250514040 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_float_h" >&5
1255014085 $as_echo_n "(cached) " >&6
1255114086 else
1255214087
12553 for ac_expr in \
12554 \
12555 '# glibc2' \
12556 'fp->_IO_write_ptr - fp->_IO_write_base' \
12557 \
12558 '# traditional Unix' \
12559 'fp->_ptr - fp->_base' \
12560 \
12561 '# BSD' \
12562 'fp->_p - fp->_bf._base' \
12563 \
12564 '# SCO, Unixware' \
12565 '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \
12566 \
12567 '# QNX' \
12568 '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
12569 \
12570 '# old glibc?' \
12571 'fp->__bufp - fp->__buffer' \
12572 \
12573 '# old glibc iostream?' \
12574 'fp->_pptr - fp->_pbase' \
12575 \
12576 '# emx+gcc' \
12577 'fp->_ptr - fp->_buffer' \
12578 \
12579 '# VMS' \
12580 '(*fp)->_ptr - (*fp)->_base' \
12581 \
12582 '# e.g., DGUX R4.11; the info is not available' \
12583 1 \
12584 ; do
12585
12586 # Skip each embedded comment.
12587 case "$ac_expr" in '#'*) continue;; esac
12588
12589 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14088 for ac_expr in \
14089 \
14090 '# glibc2' \
14091 'fp->_IO_write_ptr - fp->_IO_write_base' \
14092 \
14093 '# traditional Unix' \
14094 'fp->_ptr - fp->_base' \
14095 \
14096 '# BSD' \
14097 'fp->_p - fp->_bf._base' \
14098 \
14099 '# SCO, Unixware' \
14100 '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \
14101 \
14102 '# QNX' \
14103 '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
14104 \
14105 '# old glibc?' \
14106 'fp->__bufp - fp->__buffer' \
14107 \
14108 '# old glibc iostream?' \
14109 'fp->_pptr - fp->_pbase' \
14110 \
14111 '# emx+gcc' \
14112 'fp->_ptr - fp->_buffer' \
14113 \
14114 '# VMS' \
14115 '(*fp)->_ptr - (*fp)->_base' \
14116 \
14117 '# e.g., DGUX R4.11; the info is not available' \
14118 1 \
14119 ; do
14120
14121 # Skip each embedded comment.
14122 case "$ac_expr" in '#'*) continue;; esac
14123
14124 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1259014125 /* end confdefs.h. */
1259114126 #include <stdio.h>
1259214127 int
1260214137
1260314138 fi
1260414139 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12605 test "$fp_done" = yes && break
12606 done
12607
12608 ac_cv_sys_pending_output_n_bytes=$ac_expr
14140 test "$fp_done" = yes && break
14141 done
14142
14143 ac_cv_sys_pending_output_n_bytes=$ac_expr
1260914144
1261014145
1261114146 fi
1298414519 main ()
1298514520 {
1298614521 FILE *f = fopen ("conftest.txt", "w+");
12987 if (!f) return 1;
12988 if (fputc ('a', f) != 'a') return 2;
12989 rewind (f);
12990 if (fgetc (f) != 'a') return 3;
12991 if (fgetc (f) != EOF) return 4;
12992 if (fpurge (f) != 0) return 5;
12993 if (putc ('b', f) != 'b') return 6;
12994 if (fclose (f) != 0) return 7;
12995 if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
12996 if (fgetc (f) != 'a') return 9;
12997 if (fgetc (f) != 'b') return 10;
12998 if (fgetc (f) != EOF) return 11;
12999 if (fclose (f) != 0) return 12;
13000 if (remove ("conftest.txt") != 0) return 13;
13001 return 0;
14522 if (!f) return 1;
14523 if (fputc ('a', f) != 'a') return 2;
14524 rewind (f);
14525 if (fgetc (f) != 'a') return 3;
14526 if (fgetc (f) != EOF) return 4;
14527 if (fpurge (f) != 0) return 5;
14528 if (putc ('b', f) != 'b') return 6;
14529 if (fclose (f) != 0) return 7;
14530 if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
14531 if (fgetc (f) != 'a') return 9;
14532 if (fgetc (f) != 'b') return 10;
14533 if (fgetc (f) != EOF) return 11;
14534 if (fclose (f) != 0) return 12;
14535 if (remove ("conftest.txt") != 0) return 13;
14536 return 0;
1300214537 ;
1300314538 return 0;
1300414539 }
1337414909
1337514910 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1337614911 /* end confdefs.h. */
13377 [#include <stdio.h>]
14912 #include <stdio.h>
14913
1337814914 int
1337914915 main ()
1338014916 {
1339414930 fi
1339514931 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fseeko" >&5
1339614932 $as_echo "$gl_cv_func_fseeko" >&6; }
13397 if test $gl_cv_func_fseeko = no; then
13398 HAVE_FSEEKO=0
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408 gl_LIBOBJS="$gl_LIBOBJS fseeko.$ac_objext"
13409
13410
13411 REPLACE_FSEEKO=1
13412
13413
13414 elif test $gl_cv_var_stdin_large_offset = no; then
14933 if test $gl_cv_func_fseeko = no \
14934 || test $gl_cv_var_stdin_large_offset = no; then
1341514935
1341614936
1341714937
1346814988 fi
1346914989 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_ftello" >&5
1347014990 $as_echo "$gl_cv_func_ftello" >&6; }
13471 if test $gl_cv_func_ftello = no; then
13472 HAVE_FTELLO=0
14991 if test $gl_cv_func_ftello = no \
14992 || test $gl_cv_var_stdin_large_offset = no; then
1347314993
1347414994
1347514995
1348415004
1348515005 REPLACE_FTELLO=1
1348615006
13487 elif test $gl_cv_var_stdin_large_offset = no; then
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497 gl_LIBOBJS="$gl_LIBOBJS ftello.$ac_objext"
13498
13499
13500 REPLACE_FTELLO=1
13501
1350215007 fi
1350315008
1350415009
1350915014
1351015015
1351115016
13512
13513
13514
13515 $as_echo "#define GNULIB_GETOPT_GNU 1" >>confdefs.h
13516
13517
13518
13519
13520
13521
13522
13523 if test -n "$gl_replace_getopt"; then :
13524
13525
13526
13527 GETOPT_H=getopt.h
13528
13529 $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h
13530
13531
13532
13533 GNULIB_UNISTD_H_GETOPT=1
13534
13535
13536
13537
13538
13539
13540
13541
13542 gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext"
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552 gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext"
13553
13554
13555
13556
13557
13558
13559 fi
13560
13561
15017 gl_abort_bug=no
15018 case $gl_cv_func_getcwd_null,$host_os in
15019 *,mingw*)
15020 gl_cv_func_getcwd_path_max=yes;;
15021 yes,*)
15022
15023
15024
15025 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getcwd handles long file names properly" >&5
15026 $as_echo_n "checking whether getcwd handles long file names properly... " >&6; }
15027 if test "${gl_cv_func_getcwd_path_max+set}" = set; then :
15028 $as_echo_n "(cached) " >&6
15029 else
15030 # Arrange for deletion of the temporary directory this test creates.
15031 ac_clean_files="$ac_clean_files confdir3"
15032 if test "$cross_compiling" = yes; then :
15033 gl_cv_func_getcwd_path_max=no
15034 else
15035 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15036 /* end confdefs.h. */
15037
15038 #include <errno.h>
15039 #include <stdlib.h>
15040 #include <unistd.h>
15041 #include <string.h>
15042 #include <limits.h>
15043 #include <sys/stat.h>
15044 #include <sys/types.h>
15045 #include <fcntl.h>
15046
15047 #ifndef AT_FDCWD
15048 # define AT_FDCWD 0
15049 #endif
15050 #ifdef ENAMETOOLONG
15051 # define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG)
15052 #else
15053 # define is_ENAMETOOLONG(x) 0
15054 #endif
15055
15056 /* Don't get link errors because mkdir is redefined to rpl_mkdir. */
15057 #undef mkdir
15058
15059 #ifndef S_IRWXU
15060 # define S_IRWXU 0700
15061 #endif
15062
15063 /* The length of this name must be 8. */
15064 #define DIR_NAME "confdir3"
15065 #define DIR_NAME_LEN 8
15066 #define DIR_NAME_SIZE (DIR_NAME_LEN + 1)
15067
15068 /* The length of "../". */
15069 #define DOTDOTSLASH_LEN 3
15070
15071 /* Leftover bytes in the buffer, to work around library or OS bugs. */
15072 #define BUF_SLOP 20
15073
15074 int
15075 main ()
15076 {
15077 #ifndef PATH_MAX
15078 /* The Hurd doesn't define this, so getcwd can't exhibit the bug --
15079 at least not on a local file system. And if we were to start worrying
15080 about remote file systems, we'd have to enable the wrapper function
15081 all of the time, just to be safe. That's not worth the cost. */
15082 exit (0);
15083 #elif ((INT_MAX / (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) \
15084 - DIR_NAME_SIZE - BUF_SLOP) \
15085 <= PATH_MAX)
15086 /* FIXME: Assuming there's a system for which this is true,
15087 this should be done in a compile test. */
15088 exit (0);
15089 #else
15090 char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1)
15091 + DIR_NAME_SIZE + BUF_SLOP];
15092 char *cwd = getcwd (buf, PATH_MAX);
15093 size_t initial_cwd_len;
15094 size_t cwd_len;
15095 int fail = 0;
15096 size_t n_chdirs = 0;
15097
15098 if (cwd == NULL)
15099 exit (1);
15100
15101 cwd_len = initial_cwd_len = strlen (cwd);
15102
15103 while (1)
15104 {
15105 size_t dotdot_max = PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN);
15106 char *c = NULL;
15107
15108 cwd_len += DIR_NAME_SIZE;
15109 /* If mkdir or chdir fails, it could be that this system cannot create
15110 any file with an absolute name longer than PATH_MAX, such as cygwin.
15111 If so, leave fail as 0, because the current working directory can't
15112 be too long for getcwd if it can't even be created. For other
15113 errors, be pessimistic and consider that as a failure, too. */
15114 if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0)
15115 {
15116 if (! (errno == ERANGE || is_ENAMETOOLONG (errno)))
15117 fail = 2;
15118 break;
15119 }
15120
15121 if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DIR_NAME_SIZE)
15122 {
15123 c = getcwd (buf, PATH_MAX);
15124 if (!c && errno == ENOENT)
15125 {
15126 fail = 1;
15127 break;
15128 }
15129 if (c || ! (errno == ERANGE || is_ENAMETOOLONG (errno)))
15130 {
15131 fail = 2;
15132 break;
15133 }
15134 }
15135
15136 if (dotdot_max <= cwd_len - initial_cwd_len)
15137 {
15138 if (dotdot_max + DIR_NAME_SIZE < cwd_len - initial_cwd_len)
15139 break;
15140 c = getcwd (buf, cwd_len + 1);
15141 if (!c)
15142 {
15143 if (! (errno == ERANGE || errno == ENOENT
15144 || is_ENAMETOOLONG (errno)))
15145 {
15146 fail = 2;
15147 break;
15148 }
15149 if (AT_FDCWD || errno == ERANGE || errno == ENOENT)
15150 {
15151 fail = 1;
15152 break;
15153 }
15154 }
15155 }
15156
15157 if (c && strlen (c) != cwd_len)
15158 {
15159 fail = 2;
15160 break;
15161 }
15162 ++n_chdirs;
15163 }
15164
15165 /* Leaving behind such a deep directory is not polite.
15166 So clean up here, right away, even though the driving
15167 shell script would also clean up. */
15168 {
15169 size_t i;
15170
15171 /* Try rmdir first, in case the chdir failed. */
15172 rmdir (DIR_NAME);
15173 for (i = 0; i <= n_chdirs; i++)
15174 {
15175 if (chdir ("..") < 0)
15176 break;
15177 if (rmdir (DIR_NAME) != 0)
15178 break;
15179 }
15180 }
15181
15182 exit (fail);
15183 #endif
15184 }
15185
15186 _ACEOF
15187 if ac_fn_c_try_run "$LINENO"; then :
15188 gl_cv_func_getcwd_path_max=yes
15189 else
15190 case $? in
15191 1) gl_cv_func_getcwd_path_max='no, but it is partly working';;
15192 *) gl_cv_func_getcwd_path_max=no;;
15193 esac
15194 fi
15195 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15196 conftest.$ac_objext conftest.beam conftest.$ac_ext
15197 fi
15198
15199
15200 fi
15201 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getcwd_path_max" >&5
15202 $as_echo "$gl_cv_func_getcwd_path_max" >&6; }
15203 case $gl_cv_func_getcwd_path_max in
15204 no,*)
15205
15206 $as_echo "#define HAVE_PARTLY_WORKING_GETCWD 1" >>confdefs.h
15207 ;;
15208 esac
1356215209
1356315210
1356415211
1357315220 fi
1357415221 done
1357515222
13576 if test $ac_cv_func_getpagesize = no; then
13577 HAVE_GETPAGESIZE=0
13578 for ac_header in OS.h
13579 do :
13580 ac_fn_c_check_header_mongrel "$LINENO" "OS.h" "ac_cv_header_OS_h" "$ac_includes_default"
13581 if test "x$ac_cv_header_OS_h" = x""yes; then :
13582 cat >>confdefs.h <<_ACEOF
13583 #define HAVE_OS_H 1
13584 _ACEOF
13585
13586 fi
13587
13588 done
13589
13590 if test $ac_cv_header_OS_h = yes; then
13591 HAVE_OS_H=1
13592 fi
13593 for ac_header in sys/param.h
13594 do :
13595 ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"
13596 if test "x$ac_cv_header_sys_param_h" = x""yes; then :
13597 cat >>confdefs.h <<_ACEOF
13598 #define HAVE_SYS_PARAM_H 1
13599 _ACEOF
13600
13601 fi
13602
13603 done
13604
13605 if test $ac_cv_header_sys_param_h = yes; then
13606 HAVE_SYS_PARAM_H=1
13607 fi
13608 fi
13609 case "$host_os" in
13610 mingw*)
13611 REPLACE_GETPAGESIZE=1
13612
13613
13614
13615
13616
13617
13618
13619
13620 gl_LIBOBJS="$gl_LIBOBJS getpagesize.$ac_objext"
13621
13622 ;;
15223 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getcwd aborts when 4k < cwd_length < 16k" >&5
15224 $as_echo_n "checking whether getcwd aborts when 4k < cwd_length < 16k... " >&6; }
15225 if test "${gl_cv_func_getcwd_abort_bug+set}" = set; then :
15226 $as_echo_n "(cached) " >&6
15227 else
15228 # Remove any remnants of a previous test.
15229 rm -rf confdir-14B---
15230 # Arrange for deletion of the temporary directory this test creates.
15231 ac_clean_files="$ac_clean_files confdir-14B---"
15232 if test "$cross_compiling" = yes; then :
15233 gl_cv_func_getcwd_abort_bug=yes
15234 else
15235 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
15236 /* end confdefs.h. */
15237
15238 #include <stdlib.h>
15239 #include <unistd.h>
15240 #include <limits.h>
15241 #include <string.h>
15242 #include <sys/stat.h>
15243
15244 /* Don't get link errors because mkdir is redefined to rpl_mkdir. */
15245 #undef mkdir
15246
15247 #ifndef S_IRWXU
15248 # define S_IRWXU 0700
15249 #endif
15250
15251 /* FIXME: skip the run-test altogether on systems without getpagesize. */
15252 #if ! HAVE_GETPAGESIZE
15253 # define getpagesize() 0
15254 #endif
15255
15256 /* This size is chosen to be larger than PATH_MAX (4k), yet smaller than
15257 the 16kB pagesize on ia64 linux. Those conditions make the code below
15258 trigger a bug in glibc's getcwd implementation before 2.4.90-10. */
15259 #define TARGET_LEN (5 * 1024)
15260
15261 int
15262 main ()
15263 {
15264 char const *dir_name = "confdir-14B---";
15265 char *cwd;
15266 size_t initial_cwd_len;
15267 int fail = 0;
15268 size_t desired_depth;
15269 size_t d;
15270
15271 /* The bug is triggered when PATH_MAX < getpagesize (), so skip
15272 this relative expensive and invasive test if that's not true. */
15273 if (getpagesize () <= PATH_MAX)
15274 return 0;
15275
15276 cwd = getcwd (NULL, 0);
15277 if (cwd == NULL)
15278 return 0;
15279
15280 initial_cwd_len = strlen (cwd);
15281 free (cwd);
15282 desired_depth = ((TARGET_LEN - 1 - initial_cwd_len)
15283 / (1 + strlen (dir_name)));
15284 for (d = 0; d < desired_depth; d++)
15285 {
15286 if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
15287 {
15288 fail = 3; /* Unable to construct deep hierarchy. */
15289 break;
15290 }
15291 }
15292
15293 /* If libc has the bug in question, this invocation of getcwd
15294 results in a failed assertion. */
15295 cwd = getcwd (NULL, 0);
15296 if (cwd == NULL)
15297 fail = 4; /* getcwd failed. This is ok, and expected. */
15298 free (cwd);
15299
15300 /* Call rmdir first, in case the above chdir failed. */
15301 rmdir (dir_name);
15302 while (0 < d--)
15303 {
15304 if (chdir ("..") < 0)
15305 break;
15306 rmdir (dir_name);
15307 }
15308
15309 return 0;
15310 }
15311
15312 _ACEOF
15313 if ac_fn_c_try_run "$LINENO"; then :
15314 gl_cv_func_getcwd_abort_bug=no
15315 else
15316 gl_cv_func_getcwd_abort_bug=yes
15317 fi
15318 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
15319 conftest.$ac_objext conftest.beam conftest.$ac_ext
15320 fi
15321
15322
15323 fi
15324 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_getcwd_abort_bug" >&5
15325 $as_echo "$gl_cv_func_getcwd_abort_bug" >&6; }
15326 if test $gl_cv_func_getcwd_abort_bug = yes; then :
15327 gl_abort_bug=yes
15328 fi
15329 ;;
1362315330 esac
1362415331
13625
13626
13627 GNULIB_GETPAGESIZE=1
15332 case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in
15333 *yes,yes,no) ;;
15334 *)
15335 REPLACE_GETCWD=1
15336
15337
15338
15339
15340
15341
15342
15343
15344 gl_LIBOBJS="$gl_LIBOBJS getcwd.$ac_objext"
15345
15346
15347
15348
15349 :
15350 ;;
15351 esac
15352
15353
15354
15355 GNULIB_GETCWD=1
15356
15357
15358
15359
15360
15361
15362
15363
15364 $as_echo "#define GNULIB_GETOPT_GNU 1" >>confdefs.h
15365
15366
15367
15368
15369
15370
15371
15372 if test -n "$gl_replace_getopt"; then :
15373
15374
15375
15376 GETOPT_H=getopt.h
15377
15378 $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h
15379
15380
15381
15382 GNULIB_UNISTD_H_GETOPT=1
15383
15384
15385
15386
15387
15388
15389
15390
15391 gl_LIBOBJS="$gl_LIBOBJS getopt.$ac_objext"
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401 gl_LIBOBJS="$gl_LIBOBJS getopt1.$ac_objext"
15402
15403
15404
15405
15406
15407
15408 fi
15409
1362815410
1362915411
1363015412
1365715439 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1365815440 /* end confdefs.h. */
1365915441 #include <sys/time.h>
13660 struct timeval c;
15442 struct timeval c;
1366115443
1366215444 int
1366315445 main ()
1366415446 {
1366515447
13666 int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
13667 int x = f (&c, 0);
13668 return !(x | c.tv_sec | c.tv_usec);
15448 int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
15449 int x = f (&c, 0);
15450 return !(x | c.tv_sec | c.tv_usec);
1366915451
1367015452 ;
1367115453 return 0;
1369515477 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1369615478 /* end confdefs.h. */
1369715479 #include <string.h>
13698 #include <sys/time.h>
13699 #include <time.h>
13700 #include <stdlib.h>
15480 #include <sys/time.h>
15481 #include <time.h>
15482 #include <stdlib.h>
1370115483
1370215484 int
1370315485 main ()
1370415486 {
1370515487
13706 time_t t = 0;
13707 struct tm *lt;
13708 struct tm saved_lt;
13709 struct timeval tv;
13710 lt = localtime (&t);
13711 saved_lt = *lt;
13712 gettimeofday (&tv, NULL);
13713 return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
15488 time_t t = 0;
15489 struct tm *lt;
15490 struct tm saved_lt;
15491 struct timeval tv;
15492 lt = localtime (&t);
15493 saved_lt = *lt;
15494 gettimeofday (&tv, NULL);
15495 return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
1371415496
1371515497 ;
1371615498 return 0;
1384015622 # builds, so use a shell variable to bypass this.
1384115623 GNUmakefile=GNUmakefile
1384215624 ac_config_links="$ac_config_links $GNUmakefile:$GNUmakefile"
15625
1384315626
1384415627
1384515628
1487916662
1488016663
1488116664
16665
16666
16667
16668
16669 for ac_func in lchown
16670 do :
16671 ac_fn_c_check_func "$LINENO" "lchown" "ac_cv_func_lchown"
16672 if test "x$ac_cv_func_lchown" = x""yes; then :
16673 cat >>confdefs.h <<_ACEOF
16674 #define HAVE_LCHOWN 1
16675 _ACEOF
16676
16677 else
16678
16679 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
16680
16681 fi
16682 done
16683
16684
16685 if test $ac_cv_func_lchown = no; then
16686 HAVE_LCHOWN=0
16687 elif test "$gl_cv_func_chown_slash_works" != yes \
16688 || test "$gl_cv_func_chown_ctime_works" != yes; then
16689
16690
16691
16692
16693
16694
16695
16696
16697 gl_LIBOBJS="$gl_LIBOBJS lchown.$ac_objext"
16698
16699 REPLACE_LCHOWN=1
16700 fi
16701
16702
16703
16704 GNULIB_LCHOWN=1
16705
16706
16707
16708
16709
16710
16711
16712
16713
1488216714 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
1488316715
1488416716
1490416736 _ACEOF
1490516737 if ac_fn_c_try_link "$LINENO"; then :
1490616738 if test -s conftest$ac_exeext \
14907 && ./conftest$ac_exeext < conftest.$ac_ext \
14908 && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
14909 gl_cv_func_lseek_pipe=yes
14910 else
14911 gl_cv_func_lseek_pipe=no
14912 fi
16739 && ./conftest$ac_exeext < conftest.$ac_ext \
16740 && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
16741 gl_cv_func_lseek_pipe=yes
16742 else
16743 gl_cv_func_lseek_pipe=no
16744 fi
1491316745 else
1491416746 gl_cv_func_lseek_pipe=no
1491516747 fi
1509316925 $as_echo_n "(cached) " >&6
1509416926 else
1509516927
15096 if test $ac_cv_header_math_h = yes; then
15097 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16928 if test $ac_cv_header_math_h = yes; then
16929 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1509816930 /* end confdefs.h. */
1509916931 #include <math.h>
1510016932
1510116933 _ACEOF
15102 case "$host_os" in
15103 aix*) gl_absname_cpp="$ac_cpp -C" ;;
15104 *) gl_absname_cpp="$ac_cpp" ;;
15105 esac
15106 gl_cv_next_math_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
15107 sed -n '\#/math.h#{
15108 s#.*"\(.*/math.h\)".*#\1#
15109 s#^/[^/]#//&#
15110 p
15111 q
15112 }'`'"'
15113 else
15114 gl_cv_next_math_h='<'math.h'>'
15115 fi
16934 case "$host_os" in
16935 aix*) gl_absname_cpp="$ac_cpp -C" ;;
16936 *) gl_absname_cpp="$ac_cpp" ;;
16937 esac
16938 gl_cv_next_math_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
16939 sed -n '\#/math.h#{
16940 s#.*"\(.*/math.h\)".*#\1#
16941 s#^/[^/]#//&#
16942 p
16943 q
16944 }'`'"'
16945 else
16946 gl_cv_next_math_h='<'math.h'>'
16947 fi
1511616948
1511716949 fi
1511816950 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_math_h" >&5
1513116963
1513216964
1513316965
16966
16967
1513416968 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NAN macro works" >&5
1513516969 $as_echo_n "checking whether NAN macro works... " >&6; }
1513616970 if test "${gl_cv_header_math_nan_works+set}" = set; then :
1514716981 test only needs to fail when NAN is provided but wrong. */
1514816982 float f = 1.0f;
1514916983 #ifdef NAN
15150 f = NAN;
16984 f = NAN;
1515116985 #endif
15152 return f == 0;
16986 return f == 0;
1515316987 ;
1515416988 return 0;
1515516989 }
1517817012 main ()
1517917013 {
1518017014 /* Solaris 10 has a broken definition of HUGE_VAL. */
15181 double d = HUGE_VAL;
15182 return d == 0;
17015 double d = HUGE_VAL;
17016 return d == 0;
1518317017 ;
1518417018 return 0;
1518517019 }
1533817172 fi
1533917173 if test $REPLACE_MBSTATE_T = 1; then
1534017174
15341
15342 WCHAR_H=wchar.h
17175 :
1534317176
1534417177 fi
1534517178
1556717400 fi
1556817401 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
1556917402
15570
15571 WCHAR_H=wchar.h
17403 :
1557217404
1557317405
1557417406
1573017562 fi
1573117563 if test $REPLACE_MBSTATE_T = 1; then
1573217564
15733
15734 WCHAR_H=wchar.h
17565 :
1573517566
1573617567 fi
1573717568
1574417575 fi
1574517576 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
1574617577
15747
15748 WCHAR_H=wchar.h
17578 :
1574917579
1575017580
1575117581
1577017600
1577117601
1577217602 GNULIB_MEMCHR=1
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618 for ac_func in mempcpy
17619 do :
17620 ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy"
17621 if test "x$ac_cv_func_mempcpy" = x""yes; then :
17622 cat >>confdefs.h <<_ACEOF
17623 #define HAVE_MEMPCPY 1
17624 _ACEOF
17625
17626 else
17627
17628 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
17629
17630 fi
17631 done
17632
17633
17634 if test $ac_cv_func_mempcpy = no; then
17635 HAVE_MEMPCPY=0
17636
17637 :
17638
17639 fi
17640
17641
17642
17643 GNULIB_MEMPCPY=1
17644
17645
17646
17647
17648
17649
17650 if test $ac_cv_have_decl_memrchr = no; then
17651 HAVE_DECL_MEMRCHR=0
17652 fi
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662 for ac_func in memrchr
17663 do :
17664 ac_fn_c_check_func "$LINENO" "memrchr" "ac_cv_func_memrchr"
17665 if test "x$ac_cv_func_memrchr" = x""yes; then :
17666 cat >>confdefs.h <<_ACEOF
17667 #define HAVE_MEMRCHR 1
17668 _ACEOF
17669
17670 else
17671
17672 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
17673
17674 fi
17675 done
17676
17677
17678 if test $ac_cv_func_memrchr = no; then
17679 :
17680 fi
17681
17682
17683
17684 GNULIB_MEMRCHR=1
17685
17686
17687
17688 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing slash" >&5
17689 $as_echo_n "checking whether mkdir handles trailing slash... " >&6; }
17690 if test "${gl_cv_func_mkdir_trailing_slash_works+set}" = set; then :
17691 $as_echo_n "(cached) " >&6
17692 else
17693 rm -rf conftest.dir
17694 if test "$cross_compiling" = yes; then :
17695 gl_cv_func_mkdir_trailing_slash_works="guessing no"
17696 else
17697 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17698 /* end confdefs.h. */
17699
17700 # include <sys/types.h>
17701 # include <sys/stat.h>
17702
17703 int
17704 main ()
17705 {
17706 return mkdir ("conftest.dir/", 0700);
17707 ;
17708 return 0;
17709 }
17710 _ACEOF
17711 if ac_fn_c_try_run "$LINENO"; then :
17712 gl_cv_func_mkdir_trailing_slash_works=yes
17713 else
17714 gl_cv_func_mkdir_trailing_slash_works=no
17715 fi
17716 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
17717 conftest.$ac_objext conftest.beam conftest.$ac_ext
17718 fi
17719
17720 rm -rf conftest.dir
17721
17722
17723 fi
17724 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_slash_works" >&5
17725 $as_echo "$gl_cv_func_mkdir_trailing_slash_works" >&6; }
17726 if test "$gl_cv_func_mkdir_trailing_slash_works" != yes; then
17727 REPLACE_MKDIR=1
17728
17729
17730
17731
17732
17733
17734
17735
17736 gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext"
17737
17738 fi
17739
17740 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mkdir handles trailing dot" >&5
17741 $as_echo_n "checking whether mkdir handles trailing dot... " >&6; }
17742 if test "${gl_cv_func_mkdir_trailing_dot_works+set}" = set; then :
17743 $as_echo_n "(cached) " >&6
17744 else
17745 rm -rf conftest.dir
17746 if test "$cross_compiling" = yes; then :
17747 gl_cv_func_mkdir_trailing_dot_works="guessing no"
17748 else
17749 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17750 /* end confdefs.h. */
17751
17752 # include <sys/types.h>
17753 # include <sys/stat.h>
17754
17755 int
17756 main ()
17757 {
17758 return !mkdir ("conftest.dir/./", 0700);
17759 ;
17760 return 0;
17761 }
17762 _ACEOF
17763 if ac_fn_c_try_run "$LINENO"; then :
17764 gl_cv_func_mkdir_trailing_dot_works=yes
17765 else
17766 gl_cv_func_mkdir_trailing_dot_works=no
17767 fi
17768 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
17769 conftest.$ac_objext conftest.beam conftest.$ac_ext
17770 fi
17771
17772 rm -rf conftest.dir
17773
17774
17775 fi
17776 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_mkdir_trailing_dot_works" >&5
17777 $as_echo "$gl_cv_func_mkdir_trailing_dot_works" >&6; }
17778 if test "$gl_cv_func_mkdir_trailing_dot_works" != yes; then
17779 REPLACE_MKDIR=1
17780
17781
17782
17783
17784
17785
17786
17787
17788 gl_LIBOBJS="$gl_LIBOBJS mkdir.$ac_objext"
17789
17790
17791 $as_echo "#define FUNC_MKDIR_DOT_BUG 1" >>confdefs.h
17792
17793 fi
1577317794
1577417795
1577517796
1579717818
1579817819 ;;
1579917820 *)
15800 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5
17821
17822 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether open recognizes a trailing slash" >&5
1580117823 $as_echo_n "checking whether open recognizes a trailing slash... " >&6; }
1580217824 if test "${gl_cv_func_open_slash+set}" = set; then :
1580317825 $as_echo_n "(cached) " >&6
1580417826 else
15805
17827 # Assume that if we have lstat, we can also check symlinks.
17828 if test $ac_cv_func_lstat = yes; then
17829 touch conftest.tmp
17830 ln -s conftest.tmp conftest.lnk
17831 fi
1580617832 if test "$cross_compiling" = yes; then :
1580717833
1580817834 case "$host_os" in
17835 freebsd*) gl_cv_func_open_slash="guessing no" ;;
1580917836 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
1581017837 hpux*) gl_cv_func_open_slash="guessing no" ;;
1581117838 *) gl_cv_func_open_slash="guessing yes" ;;
1582117848 #endif
1582217849 int main ()
1582317850 {
17851 #if HAVE_LSTAT
17852 if (open ("conftest.lnk/", O_RDONLY) != -1) return 2;
17853 #endif
1582417854 return open ("conftest.sl/", O_CREAT, 0600) >= 0;
1582517855 }
1582617856 _ACEOF
1583317863 conftest.$ac_objext conftest.beam conftest.$ac_ext
1583417864 fi
1583517865
15836 rm -f conftest.sl
17866 rm -f conftest.sl conftest.tmp conftest.lnk
1583717867
1583817868 fi
1583917869 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_open_slash" >&5
1587517905
1587617906
1587717907 GNULIB_OPEN=1
17908
17909
17910
17911 GNULIB_OPENAT=1
17912
17913
17914 GNULIB_FCHMODAT=1
17915 GNULIB_FSTATAT=1
17916 GNULIB_MKDIRAT=1
17917
17918
17919 GNULIB_FCHOWNAT=1
17920 GNULIB_UNLINKAT=1
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930 gl_LIBOBJS="$gl_LIBOBJS openat-proc.$ac_objext"
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970 for ac_func in fchmodat fstatat mkdirat openat unlinkat
17971 do :
17972 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
17973 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
17974 eval as_val=\$$as_ac_var
17975 if test "x$as_val" = x""yes; then :
17976 cat >>confdefs.h <<_ACEOF
17977 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
17978 _ACEOF
17979
17980 else
17981
17982 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
17983
17984 fi
17985 done
17986
17987
17988
17989
17990 case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in
17991 yes+yes)
17992 # GNU/Hurd has unlinkat, but it has the same bug as unlink.
17993 if test $REPLACE_UNLINK = 1; then
17994
17995
17996
17997
17998
17999
18000
18001
18002 gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext"
18003
18004 REPLACE_UNLINKAT=1
18005 fi ;;
18006 yes+*)
18007 # Solaris 9 has *at functions, but uniformly mishandles trailing
18008 # slash in all of them.
18009
18010
18011
18012
18013
18014
18015
18016
18017 gl_LIBOBJS="$gl_LIBOBJS openat.$ac_objext"
18018
18019 REPLACE_OPENAT=1
18020
18021
18022
18023
18024
18025
18026
18027
18028 gl_LIBOBJS="$gl_LIBOBJS fstatat.$ac_objext"
18029
18030 REPLACE_FSTATAT=1
18031
18032
18033
18034
18035
18036
18037
18038
18039 gl_LIBOBJS="$gl_LIBOBJS unlinkat.$ac_objext"
18040
18041 REPLACE_UNLINKAT=1
18042 ;;
18043 *)
18044 HAVE_OPENAT=0
18045 HAVE_UNLINKAT=0 # No known system with unlinkat but not openat
18046 HAVE_FSTATAT=0 # No known system with fstatat but not openat
18047
18048
18049
18050 :
18051 ;;
18052 esac
18053 if test $ac_cv_func_fchmodat != yes; then
18054 HAVE_FCHMODAT=0
18055 fi
18056 if test $ac_cv_func_mkdirat != yes; then
18057 HAVE_MKDIRAT=0
18058 fi
18059
18060
18061 ac_fn_c_check_func "$LINENO" "fchownat" "ac_cv_func_fchownat"
18062 if test "x$ac_cv_func_fchownat" = x""yes; then :
18063
18064 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fchownat works with AT_SYMLINK_NOFOLLOW" >&5
18065 $as_echo_n "checking whether fchownat works with AT_SYMLINK_NOFOLLOW... " >&6; }
18066 if test "${gl_cv_func_fchownat_nofollow_works+set}" = set; then :
18067 $as_echo_n "(cached) " >&6
18068 else
18069
18070 gl_dangle=conftest.dangle
18071 # Remove any remnants of a previous test.
18072 rm -f $gl_dangle
18073 # Arrange for deletion of the temporary file this test creates.
18074 ac_clean_files="$ac_clean_files $gl_dangle"
18075 ln -s conftest.no-such $gl_dangle
18076 if test "$cross_compiling" = yes; then :
18077 gl_cv_func_fchownat_nofollow_works=no
18078 else
18079 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
18080 /* end confdefs.h. */
18081
18082 #include <fcntl.h>
18083 #include <unistd.h>
18084 #include <stdlib.h>
18085 #include <errno.h>
18086 #include <sys/types.h>
18087 int
18088 main ()
18089 {
18090 return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (),
18091 AT_SYMLINK_NOFOLLOW) != 0
18092 && errno == ENOENT);
18093 }
18094
18095 _ACEOF
18096 if ac_fn_c_try_run "$LINENO"; then :
18097 gl_cv_func_fchownat_nofollow_works=yes
18098 else
18099 gl_cv_func_fchownat_nofollow_works=no
18100 fi
18101 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
18102 conftest.$ac_objext conftest.beam conftest.$ac_ext
18103 fi
18104
18105
18106 fi
18107 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_fchownat_nofollow_works" >&5
18108 $as_echo "$gl_cv_func_fchownat_nofollow_works" >&6; }
18109 if test $gl_cv_func_fchownat_nofollow_works = no; then :
18110 REPLACE_FCHOWNAT=1
18111
18112 $as_echo "#define FCHOWNAT_NOFOLLOW_BUG 1" >>confdefs.h
18113
18114 fi
18115
18116 else
18117 HAVE_FCHOWNAT=0
18118 fi
18119
18120 if test $REPLACE_CHOWN = 1; then
18121 REPLACE_FCHOWNAT=1
18122 fi
18123 if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then
18124
18125
18126
18127
18128
18129
18130
18131
18132 gl_LIBOBJS="$gl_LIBOBJS fchownat.$ac_objext"
18133
18134 fi
18135
1587818136
1587918137
1588018138
1643918697
1644018698
1644118699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709 for ac_func in rmdir
18710 do :
18711 ac_fn_c_check_func "$LINENO" "rmdir" "ac_cv_func_rmdir"
18712 if test "x$ac_cv_func_rmdir" = x""yes; then :
18713 cat >>confdefs.h <<_ACEOF
18714 #define HAVE_RMDIR 1
18715 _ACEOF
18716
18717 else
18718
18719 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
18720
18721 fi
18722 done
18723
18724
18725 if test $ac_cv_func_rmdir = no; then
18726 REPLACE_RMDIR=1
18727 # If someone lacks rmdir, make configure fail, and request
18728 # a bug report to inform us about it.
18729 if test x"$SKIP_RMDIR_CHECK" != xyes; then
18730 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
18731 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
18732 as_fn_error "Your system lacks the rmdir function.
18733 Please report this, along with the output of \"uname -a\", to the
18734 bug-coreutils@gnu.org mailing list. To continue past this point,
18735 rerun configure with SKIP_RMDIR_CHECK=yes.
18736 E.g., ./configure SKIP_RMDIR_CHECK=yes
18737 See \`config.log' for more details." "$LINENO" 5; }
18738 fi
18739 else
18740 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether rmdir works" >&5
18741 $as_echo_n "checking whether rmdir works... " >&6; }
18742 if test "${gl_cv_func_rmdir_works+set}" = set; then :
18743 $as_echo_n "(cached) " >&6
18744 else
18745 mkdir conftest.dir
18746 touch conftest.file
18747 if test "$cross_compiling" = yes; then :
18748 gl_cv_func_rmdir_works="guessing no"
18749 else
18750 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
18751 /* end confdefs.h. */
18752 #include <stdio.h>
18753 #include <errno.h>
18754 #include <unistd.h>
18755
18756 int
18757 main ()
18758 {
18759 return !rmdir ("conftest.file/") || errno != ENOTDIR
18760 || !rmdir ("conftest.dir/./");
18761 ;
18762 return 0;
18763 }
18764 _ACEOF
18765 if ac_fn_c_try_run "$LINENO"; then :
18766 gl_cv_func_rmdir_works=yes
18767 else
18768 gl_cv_func_rmdir_works=no
18769 fi
18770 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
18771 conftest.$ac_objext conftest.beam conftest.$ac_ext
18772 fi
18773
18774 rm -rf conftest.dir conftest.file
18775 fi
18776 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_rmdir_works" >&5
18777 $as_echo "$gl_cv_func_rmdir_works" >&6; }
18778 if test x"$gl_cv_func_rmdir_works" != xyes; then
18779 REPLACE_RMDIR=1
18780
18781
18782
18783
18784
18785
18786
18787
18788 gl_LIBOBJS="$gl_LIBOBJS rmdir.$ac_objext"
18789
18790 fi
18791 fi
18792
18793
18794
18795 GNULIB_RMDIR=1
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806 gl_LIBOBJS="$gl_LIBOBJS save-cwd.$ac_objext"
18807
18808
18809
18810
18811
1644218812 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for signbit macro" >&5
1644318813 $as_echo_n "checking for signbit macro... " >&6; }
1644418814 if test "${gl_cv_func_signbit+set}" = set; then :
1724419614
1724519615
1724619616
19617
1724719618 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on directories" >&5
1724819619 $as_echo_n "checking whether stat handles trailing slashes on directories... " >&6; }
1724919620 if test "${gl_cv_func_stat_dir_slash+set}" = set; then :
1727919650 fi
1728019651 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_dir_slash" >&5
1728119652 $as_echo "$gl_cv_func_stat_dir_slash" >&6; }
17282 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on files" >&5
19653 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat handles trailing slashes on files" >&5
1728319654 $as_echo_n "checking whether stat handles trailing slashes on files... " >&6; }
1728419655 if test "${gl_cv_func_stat_file_slash+set}" = set; then :
1728519656 $as_echo_n "(cached) " >&6
1728619657 else
1728719658 touch conftest.tmp
19659 # Assume that if we have lstat, we can also check symlinks.
19660 if test $ac_cv_func_lstat = yes; then
19661 ln -s conftest.tmp conftest.lnk
19662 fi
1728819663 if test "$cross_compiling" = yes; then :
1728919664 gl_cv_func_stat_file_slash="guessing no"
1729019665 else
1729519670 int
1729619671 main ()
1729719672 {
17298 struct stat st; return !stat ("conftest.tmp/", &st);
19673 struct stat st;
19674 if (!stat ("conftest.tmp/", &st)) return 1;
19675 #if HAVE_LSTAT
19676 if (!stat ("conftest.lnk/", &st)) return 2;
19677 #endif
19678
1729919679 ;
1730019680 return 0;
1730119681 }
1730919689 conftest.$ac_objext conftest.beam conftest.$ac_ext
1731019690 fi
1731119691
19692 rm -f conftest.tmp conftest.lnk
1731219693 fi
1731319694 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_stat_file_slash" >&5
1731419695 $as_echo "$gl_cv_func_stat_file_slash" >&6; }
1733519716
1733619717 gl_LIBOBJS="$gl_LIBOBJS stat.$ac_objext"
1733719718
19719
1733819720 fi
1733919721
1734019722
1736319745 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1736419746 /* end confdefs.h. */
1736519747
17366 #include <sys/types.h>
17367 #include <sys/stat.h>
17368 #if HAVE_SYS_TIME_H
17369 # include <sys/time.h>
17370 #endif
17371 #include <time.h>
17372 struct timespec ts;
17373 struct stat st;
19748 #include <sys/types.h>
19749 #include <sys/stat.h>
19750 #if HAVE_SYS_TIME_H
19751 # include <sys/time.h>
19752 #endif
19753 #include <time.h>
19754 struct timespec ts;
19755 struct stat st;
1737419756
1737519757 int
1737619758 main ()
1737719759 {
1737819760
17379 st.st_atim = ts;
19761 st.st_atim = ts;
1738019762
1738119763 ;
1738219764 return 0;
1739819780 fi
1739919781 else
1740019782 ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "#include <sys/types.h>
17401 #include <sys/stat.h>
19783 #include <sys/stat.h>
1740219784 "
1740319785 if test "x$ac_cv_member_struct_stat_st_atimespec_tv_nsec" = x""yes; then :
1740419786
1740919791
1741019792 else
1741119793 ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "#include <sys/types.h>
17412 #include <sys/stat.h>
19794 #include <sys/stat.h>
1741319795 "
1741419796 if test "x$ac_cv_member_struct_stat_st_atimensec" = x""yes; then :
1741519797
1742019802
1742119803 else
1742219804 ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "#include <sys/types.h>
17423 #include <sys/stat.h>
19805 #include <sys/stat.h>
1742419806 "
1742519807 if test "x$ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" = x""yes; then :
1742619808
1745419836
1745519837 else
1745619838 ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtimensec" "ac_cv_member_struct_stat_st_birthtimensec" "#include <sys/types.h>
17457 #include <sys/stat.h>
19839 #include <sys/stat.h>
1745819840 "
1745919841 if test "x$ac_cv_member_struct_stat_st_birthtimensec" = x""yes; then :
1746019842
1746519847
1746619848 else
1746719849 ac_fn_c_check_member "$LINENO" "struct stat" "st_birthtim.tv_nsec" "ac_cv_member_struct_stat_st_birthtim_tv_nsec" "#include <sys/types.h>
17468 #include <sys/stat.h>
19850 #include <sys/stat.h>
1746919851 "
1747019852 if test "x$ac_cv_member_struct_stat_st_birthtim_tv_nsec" = x""yes; then :
1747119853
1755419936 $as_echo_n "(cached) " >&6
1755519937 else
1755619938
17557 if test $ac_cv_header_stddef_h = yes; then
17558 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
19939 if test $ac_cv_header_stddef_h = yes; then
19940 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1755919941 /* end confdefs.h. */
1756019942 #include <stddef.h>
1756119943
1756219944 _ACEOF
17563 case "$host_os" in
17564 aix*) gl_absname_cpp="$ac_cpp -C" ;;
17565 *) gl_absname_cpp="$ac_cpp" ;;
17566 esac
17567 gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
17568 sed -n '\#/stddef.h#{
17569 s#.*"\(.*/stddef.h\)".*#\1#
17570 s#^/[^/]#//&#
17571 p
17572 q
17573 }'`'"'
17574 else
17575 gl_cv_next_stddef_h='<'stddef.h'>'
17576 fi
19945 case "$host_os" in
19946 aix*) gl_absname_cpp="$ac_cpp -C" ;;
19947 *) gl_absname_cpp="$ac_cpp" ;;
19948 esac
19949 gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
19950 sed -n '\#/stddef.h#{
19951 s#.*"\(.*/stddef.h\)".*#\1#
19952 s#^/[^/]#//&#
19953 p
19954 q
19955 }'`'"'
19956 else
19957 gl_cv_next_stddef_h='<'stddef.h'>'
19958 fi
1757719959
1757819960 fi
1757919961 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stddef_h" >&5
1764020022 $as_echo_n "(cached) " >&6
1764120023 else
1764220024
17643 if test $ac_cv_header_stdint_h = yes; then
17644 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20025 if test $ac_cv_header_stdint_h = yes; then
20026 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1764520027 /* end confdefs.h. */
1764620028 #include <stdint.h>
1764720029
1764820030 _ACEOF
17649 case "$host_os" in
17650 aix*) gl_absname_cpp="$ac_cpp -C" ;;
17651 *) gl_absname_cpp="$ac_cpp" ;;
17652 esac
17653 gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
17654 sed -n '\#/stdint.h#{
17655 s#.*"\(.*/stdint.h\)".*#\1#
17656 s#^/[^/]#//&#
17657 p
17658 q
17659 }'`'"'
17660 else
17661 gl_cv_next_stdint_h='<'stdint.h'>'
17662 fi
20031 case "$host_os" in
20032 aix*) gl_absname_cpp="$ac_cpp -C" ;;
20033 *) gl_absname_cpp="$ac_cpp" ;;
20034 esac
20035 gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
20036 sed -n '\#/stdint.h#{
20037 s#.*"\(.*/stdint.h\)".*#\1#
20038 s#^/[^/]#//&#
20039 p
20040 q
20041 }'`'"'
20042 else
20043 gl_cv_next_stdint_h='<'stdint.h'>'
20044 fi
1766320045
1766420046 fi
1766520047 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdint_h" >&5
1815320535 for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
1815420536 case $glsuf in
1815520537 '') gltype1='int';;
18156 l) gltype1='long int';;
18157 ll) gltype1='long long int';;
18158 i64) gltype1='__int64';;
18159 u) gltype1='unsigned int';;
18160 ul) gltype1='unsigned long int';;
18161 ull) gltype1='unsigned long long int';;
20538 l) gltype1='long int';;
20539 ll) gltype1='long long int';;
20540 i64) gltype1='__int64';;
20541 u) gltype1='unsigned int';;
20542 ul) gltype1='unsigned long int';;
20543 ull) gltype1='unsigned long long int';;
1816220544 ui64)gltype1='unsigned __int64';;
1816320545 esac
1816420546 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1822520607 for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
1822620608 case $glsuf in
1822720609 '') gltype1='int';;
18228 l) gltype1='long int';;
18229 ll) gltype1='long long int';;
18230 i64) gltype1='__int64';;
18231 u) gltype1='unsigned int';;
18232 ul) gltype1='unsigned long int';;
18233 ull) gltype1='unsigned long long int';;
20610 l) gltype1='long int';;
20611 ll) gltype1='long long int';;
20612 i64) gltype1='__int64';;
20613 u) gltype1='unsigned int';;
20614 ul) gltype1='unsigned long int';;
20615 ull) gltype1='unsigned long long int';;
1823420616 ui64)gltype1='unsigned __int64';;
1823520617 esac
1823620618 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1829120673
1829220674
1829320675
20676
1829420677 if test $gl_cv_have_include_next = yes; then
1829520678 gl_cv_next_stdio_h='<'stdio.h'>'
1829620679 else
1830020683 $as_echo_n "(cached) " >&6
1830120684 else
1830220685
18303 if test $ac_cv_header_stdio_h = yes; then
18304 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20686 if test $ac_cv_header_stdio_h = yes; then
20687 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1830520688 /* end confdefs.h. */
1830620689 #include <stdio.h>
1830720690
1830820691 _ACEOF
18309 case "$host_os" in
18310 aix*) gl_absname_cpp="$ac_cpp -C" ;;
18311 *) gl_absname_cpp="$ac_cpp" ;;
18312 esac
18313 gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
18314 sed -n '\#/stdio.h#{
18315 s#.*"\(.*/stdio.h\)".*#\1#
18316 s#^/[^/]#//&#
18317 p
18318 q
18319 }'`'"'
18320 else
18321 gl_cv_next_stdio_h='<'stdio.h'>'
18322 fi
20692 case "$host_os" in
20693 aix*) gl_absname_cpp="$ac_cpp -C" ;;
20694 *) gl_absname_cpp="$ac_cpp" ;;
20695 esac
20696 gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
20697 sed -n '\#/stdio.h#{
20698 s#.*"\(.*/stdio.h\)".*#\1#
20699 s#^/[^/]#//&#
20700 p
20701 q
20702 }'`'"'
20703 else
20704 gl_cv_next_stdio_h='<'stdio.h'>'
20705 fi
1832320706
1832420707 fi
1832520708 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdio_h" >&5
1835120734
1835220735
1835320736
20737 for gl_func in fseeko ftello; do
20738 as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
20739 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
20740 $as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
20741 if { as_var=$as_gl_Symbol; eval "test \"\${$as_var+set}\" = set"; }; then :
20742 $as_echo_n "(cached) " >&6
20743 else
20744 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20745 /* end confdefs.h. */
20746 #include <stdio.h>
20747
20748 int
20749 main ()
20750 {
20751 #undef $gl_func
20752 (void) $gl_func;
20753 ;
20754 return 0;
20755 }
20756 _ACEOF
20757 if ac_fn_c_try_compile "$LINENO"; then :
20758 eval "$as_gl_Symbol=yes"
20759 else
20760 eval "$as_gl_Symbol=no"
20761 fi
20762 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
20763 fi
20764 eval ac_res=\$$as_gl_Symbol
20765 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
20766 $as_echo "$ac_res" >&6; }
20767 eval as_val=\$$as_gl_Symbol
20768 if test "x$as_val" = x""yes; then :
20769 cat >>confdefs.h <<_ACEOF
20770 #define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
20771 _ACEOF
20772
20773 eval ac_cv_have_decl_$gl_func=yes
20774 fi
20775 done
20776
20777
20778
1835420779
1835520780
1835620781
1836720792 $as_echo_n "(cached) " >&6
1836820793 else
1836920794
18370 if test $ac_cv_header_stdlib_h = yes; then
18371 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20795 if test $ac_cv_header_stdlib_h = yes; then
20796 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1837220797 /* end confdefs.h. */
1837320798 #include <stdlib.h>
1837420799
1837520800 _ACEOF
18376 case "$host_os" in
18377 aix*) gl_absname_cpp="$ac_cpp -C" ;;
18378 *) gl_absname_cpp="$ac_cpp" ;;
18379 esac
18380 gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
18381 sed -n '\#/stdlib.h#{
18382 s#.*"\(.*/stdlib.h\)".*#\1#
18383 s#^/[^/]#//&#
18384 p
18385 q
18386 }'`'"'
18387 else
18388 gl_cv_next_stdlib_h='<'stdlib.h'>'
18389 fi
20801 case "$host_os" in
20802 aix*) gl_absname_cpp="$ac_cpp -C" ;;
20803 *) gl_absname_cpp="$ac_cpp" ;;
20804 esac
20805 gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
20806 sed -n '\#/stdlib.h#{
20807 s#.*"\(.*/stdlib.h\)".*#\1#
20808 s#^/[^/]#//&#
20809 p
20810 q
20811 }'`'"'
20812 else
20813 gl_cv_next_stdlib_h='<'stdlib.h'>'
20814 fi
1839020815
1839120816 fi
1839220817 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_stdlib_h" >&5
1844420869
1844520870
1844620871
20872
20873 if test $gl_cv_func_malloc_posix != yes; then
20874 REPLACE_STRDUP=1
20875
20876
20877
20878
20879
20880
20881
20882
20883 gl_LIBOBJS="$gl_LIBOBJS strdup.$ac_objext"
20884
20885 else
20886
20887
20888
20889
20890
20891
20892
20893
20894 for ac_func in strdup
20895 do :
20896 ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup"
20897 if test "x$ac_cv_func_strdup" = x""yes; then :
20898 cat >>confdefs.h <<_ACEOF
20899 #define HAVE_STRDUP 1
20900 _ACEOF
20901
20902 else
20903
20904 gl_LIBOBJS="$gl_LIBOBJS $ac_func.$ac_objext"
20905
20906 fi
20907 done
20908
20909
20910 fi
20911
20912 if test $ac_cv_have_decl_strdup = no; then
20913 HAVE_DECL_STRDUP=0
20914 fi
20915 :
20916
20917
20918
20919 GNULIB_STRDUP=1
20920
20921
20922
1844720923 if test $REPLACE_STRERROR = 1; then
1844820924
1844920925
1849120967 $as_echo_n "(cached) " >&6
1849220968 else
1849320969
18494 if test $ac_cv_header_sys_stat_h = yes; then
18495 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
20970 if test $ac_cv_header_sys_stat_h = yes; then
20971 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1849620972 /* end confdefs.h. */
1849720973 #include <sys/stat.h>
1849820974
1849920975 _ACEOF
18500 case "$host_os" in
18501 aix*) gl_absname_cpp="$ac_cpp -C" ;;
18502 *) gl_absname_cpp="$ac_cpp" ;;
18503 esac
18504 gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
18505 sed -n '\#/sys/stat.h#{
18506 s#.*"\(.*/sys/stat.h\)".*#\1#
18507 s#^/[^/]#//&#
18508 p
18509 q
18510 }'`'"'
18511 else
18512 gl_cv_next_sys_stat_h='<'sys/stat.h'>'
18513 fi
20976 case "$host_os" in
20977 aix*) gl_absname_cpp="$ac_cpp -C" ;;
20978 *) gl_absname_cpp="$ac_cpp" ;;
20979 esac
20980 gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
20981 sed -n '\#/sys/stat.h#{
20982 s#.*"\(.*/sys/stat.h\)".*#\1#
20983 s#^/[^/]#//&#
20984 p
20985 q
20986 }'`'"'
20987 else
20988 gl_cv_next_sys_stat_h='<'sys/stat.h'>'
20989 fi
1851420990
1851520991 fi
1851620992 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_sys_stat_h" >&5
1856321039
1856421040
1856521041
21042
1856621043 if test $gl_cv_have_include_next = yes; then
1856721044 gl_cv_next_unistd_h='<'unistd.h'>'
1856821045 else
1857221049 $as_echo_n "(cached) " >&6
1857321050 else
1857421051
18575 if test $ac_cv_header_unistd_h = yes; then
18576 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21052 if test $ac_cv_header_unistd_h = yes; then
21053 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1857721054 /* end confdefs.h. */
1857821055 #include <unistd.h>
1857921056
1858021057 _ACEOF
18581 case "$host_os" in
18582 aix*) gl_absname_cpp="$ac_cpp -C" ;;
18583 *) gl_absname_cpp="$ac_cpp" ;;
18584 esac
18585 gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
18586 sed -n '\#/unistd.h#{
18587 s#.*"\(.*/unistd.h\)".*#\1#
18588 s#^/[^/]#//&#
18589 p
18590 q
18591 }'`'"'
18592 else
18593 gl_cv_next_unistd_h='<'unistd.h'>'
18594 fi
21058 case "$host_os" in
21059 aix*) gl_absname_cpp="$ac_cpp -C" ;;
21060 *) gl_absname_cpp="$ac_cpp" ;;
21061 esac
21062 gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
21063 sed -n '\#/unistd.h#{
21064 s#.*"\(.*/unistd.h\)".*#\1#
21065 s#^/[^/]#//&#
21066 p
21067 q
21068 }'`'"'
21069 else
21070 gl_cv_next_unistd_h='<'unistd.h'>'
21071 fi
1859521072
1859621073 fi
1859721074 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_unistd_h" >&5
1862021097
1862121098
1862221099
21100 for gl_func in environ; do
21101 as_gl_Symbol=`$as_echo "gl_cv_have_raw_decl_$gl_func" | $as_tr_sh`
21102 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $gl_func is declared without a macro" >&5
21103 $as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
21104 if { as_var=$as_gl_Symbol; eval "test \"\${$as_var+set}\" = set"; }; then :
21105 $as_echo_n "(cached) " >&6
21106 else
21107 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21108 /* end confdefs.h. */
21109 #include <unistd.h>
21110 /* Some systems declare environ in the wrong header. */
21111 #ifndef __GLIBC__
21112 # include <stdlib.h>
21113 #endif
21114
21115 int
21116 main ()
21117 {
21118 #undef $gl_func
21119 (void) $gl_func;
21120 ;
21121 return 0;
21122 }
21123 _ACEOF
21124 if ac_fn_c_try_compile "$LINENO"; then :
21125 eval "$as_gl_Symbol=yes"
21126 else
21127 eval "$as_gl_Symbol=no"
21128 fi
21129 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21130 fi
21131 eval ac_res=\$$as_gl_Symbol
21132 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
21133 $as_echo "$ac_res" >&6; }
21134 eval as_val=\$$as_gl_Symbol
21135 if test "x$as_val" = x""yes; then :
21136 cat >>confdefs.h <<_ACEOF
21137 #define `$as_echo "HAVE_RAW_DECL_$gl_func" | $as_tr_cpp` 1
21138 _ACEOF
21139
21140 eval ac_cv_have_decl_$gl_func=yes
21141 fi
21142 done
21143
21144
21145
1862321146
1862421147
1862521148
1865421177
1865521178
1865621179
18657 $as_echo "#define GNULIB_UNISTD_SAFER 1" >>confdefs.h
18658
21180
21181 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unlink honors trailing slashes" >&5
21182 $as_echo_n "checking whether unlink honors trailing slashes... " >&6; }
21183 if test "${gl_cv_func_unlink_works+set}" = set; then :
21184 $as_echo_n "(cached) " >&6
21185 else
21186 touch conftest.file
21187 # Assume that if we have lstat, we can also check symlinks.
21188 if test $ac_cv_func_lstat = yes; then
21189 ln -s conftest.file conftest.lnk
21190 fi
21191 if test "$cross_compiling" = yes; then :
21192 gl_cv_func_unlink_works="guessing no"
21193 else
21194 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21195 /* end confdefs.h. */
21196 #include <unistd.h>
21197 #include <errno.h>
21198
21199 int
21200 main ()
21201 {
21202 if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1;
21203 #if HAVE_LSTAT
21204 if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2;
21205 #endif
21206
21207 ;
21208 return 0;
21209 }
21210 _ACEOF
21211 if ac_fn_c_try_run "$LINENO"; then :
21212 gl_cv_func_unlink_works=yes
21213 else
21214 gl_cv_func_unlink_works=no
21215 fi
21216 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
21217 conftest.$ac_objext conftest.beam conftest.$ac_ext
21218 fi
21219
21220 rm -f conftest.file conftest.lnk
21221 fi
21222 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_unlink_works" >&5
21223 $as_echo "$gl_cv_func_unlink_works" >&6; }
21224 if test x"$gl_cv_func_unlink_works" != xyes; then
21225 REPLACE_UNLINK=1
21226
21227
21228
21229
21230
21231
21232
21233
21234 gl_LIBOBJS="$gl_LIBOBJS unlink.$ac_objext"
21235
21236 fi
21237
21238
21239
21240 GNULIB_UNLINK=1
1865921241
1866021242
1866121243
1867321255
1867421256
1867521257
21258
21259 if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
21260 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether futimesat handles NULL file" >&5
21261 $as_echo_n "checking whether futimesat handles NULL file... " >&6; }
21262 if test "${gl_cv_func_futimesat_works+set}" = set; then :
21263 $as_echo_n "(cached) " >&6
21264 else
21265 touch conftest.file
21266 if test "$cross_compiling" = yes; then :
21267 gl_cv_func_futimesat_works="guessing no"
21268 else
21269 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21270 /* end confdefs.h. */
21271
21272 #include <stddef.h>
21273 #include <sys/times.h>
21274
21275 int
21276 main ()
21277 {
21278 int fd = open ("conftest.file", O_RDWR);
21279 if (fd < 0) return 1;
21280 if (futimesat (fd, NULL, NULL)) return 2;
21281
21282 ;
21283 return 0;
21284 }
21285 _ACEOF
21286 if ac_fn_c_try_run "$LINENO"; then :
21287 gl_cv_func_futimesat_works=yes
21288 else
21289 gl_cv_func_futimesat_works=no
21290 fi
21291 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
21292 conftest.$ac_objext conftest.beam conftest.$ac_ext
21293 fi
21294
21295 rm -f conftest.file
21296 fi
21297 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_futimesat_works" >&5
21298 $as_echo "$gl_cv_func_futimesat_works" >&6; }
21299 if test "$gl_cv_func_futimesat_works" != yes; then
21300
21301 $as_echo "#define FUTIMESAT_NULL_BUG 1" >>confdefs.h
21302
21303 fi
21304 fi
1867621305
1867721306
1867821307
1907621705
1907721706
1907821707
19079 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether <wchar.h> is standalone" >&5
19080 $as_echo_n "checking whether <wchar.h> is standalone... " >&6; }
19081 if test "${gl_cv_header_wchar_h_standalone+set}" = set; then :
19082 $as_echo_n "(cached) " >&6
19083 else
19084 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
19085 /* end confdefs.h. */
19086 #include <wchar.h>
19087 wchar_t w;
19088 _ACEOF
19089 if ac_fn_c_try_compile "$LINENO"; then :
19090 gl_cv_header_wchar_h_standalone=yes
19091 else
19092 gl_cv_header_wchar_h_standalone=no
19093 fi
19094 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
19095 fi
19096 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_wchar_h_standalone" >&5
19097 $as_echo "$gl_cv_header_wchar_h_standalone" >&6; }
19098
19099
19100 if test $gt_cv_c_wint_t = yes; then
19101 HAVE_WINT_T=1
19102 else
19103 HAVE_WINT_T=0
19104 fi
19105
19106
19107
19108
19109 if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
19110 WCHAR_H=wchar.h
19111 fi
19112
19113
19114 if test $ac_cv_header_wchar_h = yes; then
19115 HAVE_WCHAR_H=1
19116 else
19117 HAVE_WCHAR_H=0
19118 fi
21708
21709
1911921710
1912021711
1912121712
1913221723 $as_echo_n "(cached) " >&6
1913321724 else
1913421725
19135 if test $ac_cv_header_wchar_h = yes; then
19136 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21726 if test $ac_cv_header_wchar_h = yes; then
21727 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1913721728 /* end confdefs.h. */
1913821729 #include <wchar.h>
1913921730
1914021731 _ACEOF
19141 case "$host_os" in
19142 aix*) gl_absname_cpp="$ac_cpp -C" ;;
19143 *) gl_absname_cpp="$ac_cpp" ;;
19144 esac
19145 gl_cv_next_wchar_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
19146 sed -n '\#/wchar.h#{
19147 s#.*"\(.*/wchar.h\)".*#\1#
19148 s#^/[^/]#//&#
19149 p
19150 q
19151 }'`'"'
19152 else
19153 gl_cv_next_wchar_h='<'wchar.h'>'
19154 fi
21732 case "$host_os" in
21733 aix*) gl_absname_cpp="$ac_cpp -C" ;;
21734 *) gl_absname_cpp="$ac_cpp" ;;
21735 esac
21736 gl_cv_next_wchar_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
21737 sed -n '\#/wchar.h#{
21738 s#.*"\(.*/wchar.h\)".*#\1#
21739 s#^/[^/]#//&#
21740 p
21741 q
21742 }'`'"'
21743 else
21744 gl_cv_next_wchar_h='<'wchar.h'>'
21745 fi
1915521746
1915621747 fi
1915721748 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wchar_h" >&5
1916921760 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H=$gl_next_as_first_directive
1917021761
1917121762
21763
21764 if test $ac_cv_header_wchar_h = yes; then
21765 HAVE_WCHAR_H=1
21766 else
21767 HAVE_WCHAR_H=0
21768 fi
21769
21770
21771
21772 if test $gt_cv_c_wint_t = yes; then
21773 HAVE_WINT_T=1
21774 else
21775 HAVE_WINT_T=0
21776 fi
1917221777
1917321778
1917421779
1927221877 $as_echo_n "(cached) " >&6
1927321878 else
1927421879
19275 if test $ac_cv_header_wctype_h = yes; then
19276 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
21880 if test $ac_cv_header_wctype_h = yes; then
21881 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1927721882 /* end confdefs.h. */
1927821883 #include <wctype.h>
1927921884
1928021885 _ACEOF
19281 case "$host_os" in
19282 aix*) gl_absname_cpp="$ac_cpp -C" ;;
19283 *) gl_absname_cpp="$ac_cpp" ;;
19284 esac
19285 gl_cv_next_wctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
19286 sed -n '\#/wctype.h#{
19287 s#.*"\(.*/wctype.h\)".*#\1#
19288 s#^/[^/]#//&#
19289 p
19290 q
19291 }'`'"'
19292 else
19293 gl_cv_next_wctype_h='<'wctype.h'>'
19294 fi
21886 case "$host_os" in
21887 aix*) gl_absname_cpp="$ac_cpp -C" ;;
21888 *) gl_absname_cpp="$ac_cpp" ;;
21889 esac
21890 gl_cv_next_wctype_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
21891 sed -n '\#/wctype.h#{
21892 s#.*"\(.*/wctype.h\)".*#\1#
21893 s#^/[^/]#//&#
21894 p
21895 q
21896 }'`'"'
21897 else
21898 gl_cv_next_wctype_h='<'wctype.h'>'
21899 fi
1929521900
1929621901 fi
1929721902 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_wctype_h" >&5
1934721952
1934821953
1934921954
21955
21956
21957
21958
21959
21960
21961 gl_LIBOBJS="$gl_LIBOBJS xgetcwd.$ac_objext"
21962
21963
21964
21965
21966
21967
21968
1935021969 for ac_header in stdint.h
1935121970 do :
1935221971 ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default"
1940722026 LIBGZIP_LTLIBDEPS="$gl_ltlibdeps"
1940822027
1940922028
22029
22030 # Check whether --enable-gcc-warnings was given.
22031 if test "${enable_gcc_warnings+set}" = set; then :
22032 enableval=$enable_gcc_warnings; case $enableval in
22033 yes|no) ;;
22034 *) as_fn_error "bad value $enableval for gcc-warnings option" "$LINENO" 5 ;;
22035 esac
22036 gl_gcc_warnings=$enableval
22037 else
22038 gl_gcc_warnings=no
22039
22040 fi
22041
22042
22043 if test "$gl_gcc_warnings" = yes; then
22044 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Werror" >&5
22045 $as_echo_n "checking whether compiler handles -Werror... " >&6; }
22046 if test "${gl_cv_warn__Werror+set}" = set; then :
22047 $as_echo_n "(cached) " >&6
22048 else
22049
22050 save_CPPFLAGS="$CPPFLAGS"
22051 CPPFLAGS="${CPPFLAGS} -Werror"
22052 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22053 /* end confdefs.h. */
22054
22055 int
22056 main ()
22057 {
22058
22059 ;
22060 return 0;
22061 }
22062 _ACEOF
22063 if ac_fn_c_try_cpp "$LINENO"; then :
22064 gl_cv_warn__Werror=yes
22065 else
22066 gl_cv_warn__Werror=no
22067 fi
22068 rm -f conftest.err conftest.$ac_ext
22069 CPPFLAGS="$save_CPPFLAGS"
22070
22071 fi
22072 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Werror" >&5
22073 $as_echo "$gl_cv_warn__Werror" >&6; }
22074 if test "x$gl_cv_warn__Werror" = x""yes; then :
22075 as_fn_append WERROR_CFLAGS " -Werror"
22076 fi
22077
22078
22079
22080 nw=
22081 # This, $nw, is the list of warnings we disable.
22082 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
22083 nw="$nw -Waggregate-return" # anachronistic
22084 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
22085 nw="$nw -Wc++-compat" # We don't care about C++ compilers
22086 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
22087 nw="$nw -Wtraditional" # Warns on #elif which we use often
22088 nw="$nw -Wcast-qual" # Too many warnings for now
22089 nw="$nw -Wconversion" # Too many warnings for now
22090 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
22091 nw="$nw -Wsign-conversion" # Too many warnings for now
22092 nw="$nw -Wtraditional-conversion" # Too many warnings for now
22093 nw="$nw -Wunreachable-code" # Too many warnings for now
22094 nw="$nw -Wpadded" # Our structs are not padded
22095 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
22096 nw="$nw -Wlogical-op" # any use of fwrite provokes this
22097 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
22098 nw="$nw -Wvla" # warnings in gettext.h
22099 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
22100 nw="$nw -Wswitch-enum" # Too many warnings for now
22101 nw="$nw -Wswitch-default" # Too many warnings for now
22102 nw="$nw -Wstack-protector" # not worth working around
22103 # things I might fix soon:
22104 nw="$nw -Wfloat-equal" # sort.c, seq.c
22105 nw="$nw -Wmissing-format-attribute" # copy.c
22106 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
22107 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
22108 nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
22109 # initial problems in gzip
22110 nw="$nw -Wold-style-definition"
22111 nw="$nw -Wshadow"
22112 nw="$nw -Wunused-macros"
22113 # ?? -Wstrict-overflow
22114
22115
22116 gl_manywarn_set=
22117 for gl_manywarn_item in \
22118 -Wall \
22119 -W \
22120 -Wformat-y2k \
22121 -Wformat-nonliteral \
22122 -Wformat-security \
22123 -Winit-self \
22124 -Wmissing-include-dirs \
22125 -Wswitch-default \
22126 -Wswitch-enum \
22127 -Wunused \
22128 -Wunknown-pragmas \
22129 -Wstrict-aliasing \
22130 -Wstrict-overflow \
22131 -Wsystem-headers \
22132 -Wfloat-equal \
22133 -Wtraditional \
22134 -Wtraditional-conversion \
22135 -Wdeclaration-after-statement \
22136 -Wundef \
22137 -Wshadow \
22138 -Wunsafe-loop-optimizations \
22139 -Wpointer-arith \
22140 -Wbad-function-cast \
22141 -Wc++-compat \
22142 -Wcast-qual \
22143 -Wcast-align \
22144 -Wwrite-strings \
22145 -Wconversion \
22146 -Wsign-conversion \
22147 -Wlogical-op \
22148 -Waggregate-return \
22149 -Wstrict-prototypes \
22150 -Wold-style-definition \
22151 -Wmissing-prototypes \
22152 -Wmissing-declarations \
22153 -Wmissing-noreturn \
22154 -Wmissing-format-attribute \
22155 -Wpacked \
22156 -Wpadded \
22157 -Wredundant-decls \
22158 -Wnested-externs \
22159 -Wunreachable-code \
22160 -Winline \
22161 -Winvalid-pch \
22162 -Wlong-long \
22163 -Wvla \
22164 -Wvolatile-register-var \
22165 -Wdisabled-optimization \
22166 -Wstack-protector \
22167 -Woverlength-strings \
22168 -Wbuiltin-macro-redefined \
22169 -Wmudflap \
22170 -Wpacked-bitfield-compat \
22171 -Wsync-nand \
22172 ; do
22173 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
22174 done
22175 # The following are not documented in the manual but are included in
22176 # output from gcc --help=warnings.
22177 for gl_manywarn_item in \
22178 -Wattributes \
22179 -Wcoverage-mismatch \
22180 -Wmultichar \
22181 -Wunused-macros \
22182 ; do
22183 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
22184 done
22185 ws=$gl_manywarn_set
22186
22187
22188 gl_warn_set=
22189 set x $ws; shift
22190 for gl_warn_item
22191 do
22192 case " $nw " in
22193 *" $gl_warn_item "*)
22194 ;;
22195 *)
22196 gl_warn_set="$gl_warn_set $gl_warn_item"
22197 ;;
22198 esac
22199 done
22200 ws=$gl_warn_set
22201
22202 for w in $ws; do
22203 as_gl_Warn=`$as_echo "gl_cv_warn_$w" | $as_tr_sh`
22204 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles $w" >&5
22205 $as_echo_n "checking whether compiler handles $w... " >&6; }
22206 if { as_var=$as_gl_Warn; eval "test \"\${$as_var+set}\" = set"; }; then :
22207 $as_echo_n "(cached) " >&6
22208 else
22209
22210 save_CPPFLAGS="$CPPFLAGS"
22211 CPPFLAGS="${CPPFLAGS} $w"
22212 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22213 /* end confdefs.h. */
22214
22215 int
22216 main ()
22217 {
22218
22219 ;
22220 return 0;
22221 }
22222 _ACEOF
22223 if ac_fn_c_try_cpp "$LINENO"; then :
22224 eval "$as_gl_Warn=yes"
22225 else
22226 eval "$as_gl_Warn=no"
22227 fi
22228 rm -f conftest.err conftest.$ac_ext
22229 CPPFLAGS="$save_CPPFLAGS"
22230
22231 fi
22232 eval ac_res=\$$as_gl_Warn
22233 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
22234 $as_echo "$ac_res" >&6; }
22235 eval as_val=\$$as_gl_Warn
22236 if test "x$as_val" = x""yes; then :
22237 as_fn_append WARN_CFLAGS " $w"
22238 fi
22239
22240 done
22241 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-missing-field-initializers" >&5
22242 $as_echo_n "checking whether compiler handles -Wno-missing-field-initializers... " >&6; }
22243 if test "${gl_cv_warn__Wno_missing_field_initializers+set}" = set; then :
22244 $as_echo_n "(cached) " >&6
22245 else
22246
22247 save_CPPFLAGS="$CPPFLAGS"
22248 CPPFLAGS="${CPPFLAGS} -Wno-missing-field-initializers"
22249 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22250 /* end confdefs.h. */
22251
22252 int
22253 main ()
22254 {
22255
22256 ;
22257 return 0;
22258 }
22259 _ACEOF
22260 if ac_fn_c_try_cpp "$LINENO"; then :
22261 gl_cv_warn__Wno_missing_field_initializers=yes
22262 else
22263 gl_cv_warn__Wno_missing_field_initializers=no
22264 fi
22265 rm -f conftest.err conftest.$ac_ext
22266 CPPFLAGS="$save_CPPFLAGS"
22267
22268 fi
22269 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_missing_field_initializers" >&5
22270 $as_echo "$gl_cv_warn__Wno_missing_field_initializers" >&6; }
22271 if test "x$gl_cv_warn__Wno_missing_field_initializers" = x""yes; then :
22272 as_fn_append WARN_CFLAGS " -Wno-missing-field-initializers"
22273 fi
22274 # We need this one
22275 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-sign-compare" >&5
22276 $as_echo_n "checking whether compiler handles -Wno-sign-compare... " >&6; }
22277 if test "${gl_cv_warn__Wno_sign_compare+set}" = set; then :
22278 $as_echo_n "(cached) " >&6
22279 else
22280
22281 save_CPPFLAGS="$CPPFLAGS"
22282 CPPFLAGS="${CPPFLAGS} -Wno-sign-compare"
22283 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22284 /* end confdefs.h. */
22285
22286 int
22287 main ()
22288 {
22289
22290 ;
22291 return 0;
22292 }
22293 _ACEOF
22294 if ac_fn_c_try_cpp "$LINENO"; then :
22295 gl_cv_warn__Wno_sign_compare=yes
22296 else
22297 gl_cv_warn__Wno_sign_compare=no
22298 fi
22299 rm -f conftest.err conftest.$ac_ext
22300 CPPFLAGS="$save_CPPFLAGS"
22301
22302 fi
22303 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_sign_compare" >&5
22304 $as_echo "$gl_cv_warn__Wno_sign_compare" >&6; }
22305 if test "x$gl_cv_warn__Wno_sign_compare" = x""yes; then :
22306 as_fn_append WARN_CFLAGS " -Wno-sign-compare"
22307 fi
22308 # Too many warnings for now
22309 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-pointer-sign" >&5
22310 $as_echo_n "checking whether compiler handles -Wno-pointer-sign... " >&6; }
22311 if test "${gl_cv_warn__Wno_pointer_sign+set}" = set; then :
22312 $as_echo_n "(cached) " >&6
22313 else
22314
22315 save_CPPFLAGS="$CPPFLAGS"
22316 CPPFLAGS="${CPPFLAGS} -Wno-pointer-sign"
22317 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22318 /* end confdefs.h. */
22319
22320 int
22321 main ()
22322 {
22323
22324 ;
22325 return 0;
22326 }
22327 _ACEOF
22328 if ac_fn_c_try_cpp "$LINENO"; then :
22329 gl_cv_warn__Wno_pointer_sign=yes
22330 else
22331 gl_cv_warn__Wno_pointer_sign=no
22332 fi
22333 rm -f conftest.err conftest.$ac_ext
22334 CPPFLAGS="$save_CPPFLAGS"
22335
22336 fi
22337 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_pointer_sign" >&5
22338 $as_echo "$gl_cv_warn__Wno_pointer_sign" >&6; }
22339 if test "x$gl_cv_warn__Wno_pointer_sign" = x""yes; then :
22340 as_fn_append WARN_CFLAGS " -Wno-pointer-sign"
22341 fi
22342 # Too many warnings for now
22343 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-unused-parameter" >&5
22344 $as_echo_n "checking whether compiler handles -Wno-unused-parameter... " >&6; }
22345 if test "${gl_cv_warn__Wno_unused_parameter+set}" = set; then :
22346 $as_echo_n "(cached) " >&6
22347 else
22348
22349 save_CPPFLAGS="$CPPFLAGS"
22350 CPPFLAGS="${CPPFLAGS} -Wno-unused-parameter"
22351 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22352 /* end confdefs.h. */
22353
22354 int
22355 main ()
22356 {
22357
22358 ;
22359 return 0;
22360 }
22361 _ACEOF
22362 if ac_fn_c_try_cpp "$LINENO"; then :
22363 gl_cv_warn__Wno_unused_parameter=yes
22364 else
22365 gl_cv_warn__Wno_unused_parameter=no
22366 fi
22367 rm -f conftest.err conftest.$ac_ext
22368 CPPFLAGS="$save_CPPFLAGS"
22369
22370 fi
22371 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_unused_parameter" >&5
22372 $as_echo "$gl_cv_warn__Wno_unused_parameter" >&6; }
22373 if test "x$gl_cv_warn__Wno_unused_parameter" = x""yes; then :
22374 as_fn_append WARN_CFLAGS " -Wno-unused-parameter"
22375 fi
22376 # Too many warnings for now
22377 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-overflow" >&5
22378 $as_echo_n "checking whether compiler handles -Wno-overflow... " >&6; }
22379 if test "${gl_cv_warn__Wno_overflow+set}" = set; then :
22380 $as_echo_n "(cached) " >&6
22381 else
22382
22383 save_CPPFLAGS="$CPPFLAGS"
22384 CPPFLAGS="${CPPFLAGS} -Wno-overflow"
22385 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22386 /* end confdefs.h. */
22387
22388 int
22389 main ()
22390 {
22391
22392 ;
22393 return 0;
22394 }
22395 _ACEOF
22396 if ac_fn_c_try_cpp "$LINENO"; then :
22397 gl_cv_warn__Wno_overflow=yes
22398 else
22399 gl_cv_warn__Wno_overflow=no
22400 fi
22401 rm -f conftest.err conftest.$ac_ext
22402 CPPFLAGS="$save_CPPFLAGS"
22403
22404 fi
22405 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_overflow" >&5
22406 $as_echo "$gl_cv_warn__Wno_overflow" >&6; }
22407 if test "x$gl_cv_warn__Wno_overflow" = x""yes; then :
22408 as_fn_append WARN_CFLAGS " -Wno-overflow"
22409 fi
22410 # util.c
22411 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-type-limits" >&5
22412 $as_echo_n "checking whether compiler handles -Wno-type-limits... " >&6; }
22413 if test "${gl_cv_warn__Wno_type_limits+set}" = set; then :
22414 $as_echo_n "(cached) " >&6
22415 else
22416
22417 save_CPPFLAGS="$CPPFLAGS"
22418 CPPFLAGS="${CPPFLAGS} -Wno-type-limits"
22419 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22420 /* end confdefs.h. */
22421
22422 int
22423 main ()
22424 {
22425
22426 ;
22427 return 0;
22428 }
22429 _ACEOF
22430 if ac_fn_c_try_cpp "$LINENO"; then :
22431 gl_cv_warn__Wno_type_limits=yes
22432 else
22433 gl_cv_warn__Wno_type_limits=no
22434 fi
22435 rm -f conftest.err conftest.$ac_ext
22436 CPPFLAGS="$save_CPPFLAGS"
22437
22438 fi
22439 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_type_limits" >&5
22440 $as_echo "$gl_cv_warn__Wno_type_limits" >&6; }
22441 if test "x$gl_cv_warn__Wno_type_limits" = x""yes; then :
22442 as_fn_append WARN_CFLAGS " -Wno-type-limits"
22443 fi
22444 # util.c
22445
22446 # In spite of excluding -Wlogical-op above, it is enabled, as of
22447 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
22448 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -Wno-logical-op" >&5
22449 $as_echo_n "checking whether compiler handles -Wno-logical-op... " >&6; }
22450 if test "${gl_cv_warn__Wno_logical_op+set}" = set; then :
22451 $as_echo_n "(cached) " >&6
22452 else
22453
22454 save_CPPFLAGS="$CPPFLAGS"
22455 CPPFLAGS="${CPPFLAGS} -Wno-logical-op"
22456 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22457 /* end confdefs.h. */
22458
22459 int
22460 main ()
22461 {
22462
22463 ;
22464 return 0;
22465 }
22466 _ACEOF
22467 if ac_fn_c_try_cpp "$LINENO"; then :
22468 gl_cv_warn__Wno_logical_op=yes
22469 else
22470 gl_cv_warn__Wno_logical_op=no
22471 fi
22472 rm -f conftest.err conftest.$ac_ext
22473 CPPFLAGS="$save_CPPFLAGS"
22474
22475 fi
22476 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__Wno_logical_op" >&5
22477 $as_echo "$gl_cv_warn__Wno_logical_op" >&6; }
22478 if test "x$gl_cv_warn__Wno_logical_op" = x""yes; then :
22479 as_fn_append WARN_CFLAGS " -Wno-logical-op"
22480 fi
22481
22482
22483 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -fdiagnostics-show-option" >&5
22484 $as_echo_n "checking whether compiler handles -fdiagnostics-show-option... " >&6; }
22485 if test "${gl_cv_warn__fdiagnostics_show_option+set}" = set; then :
22486 $as_echo_n "(cached) " >&6
22487 else
22488
22489 save_CPPFLAGS="$CPPFLAGS"
22490 CPPFLAGS="${CPPFLAGS} -fdiagnostics-show-option"
22491 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22492 /* end confdefs.h. */
22493
22494 int
22495 main ()
22496 {
22497
22498 ;
22499 return 0;
22500 }
22501 _ACEOF
22502 if ac_fn_c_try_cpp "$LINENO"; then :
22503 gl_cv_warn__fdiagnostics_show_option=yes
22504 else
22505 gl_cv_warn__fdiagnostics_show_option=no
22506 fi
22507 rm -f conftest.err conftest.$ac_ext
22508 CPPFLAGS="$save_CPPFLAGS"
22509
22510 fi
22511 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__fdiagnostics_show_option" >&5
22512 $as_echo "$gl_cv_warn__fdiagnostics_show_option" >&6; }
22513 if test "x$gl_cv_warn__fdiagnostics_show_option" = x""yes; then :
22514 as_fn_append WARN_CFLAGS " -fdiagnostics-show-option"
22515 fi
22516
22517 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler handles -funit-at-a-time" >&5
22518 $as_echo_n "checking whether compiler handles -funit-at-a-time... " >&6; }
22519 if test "${gl_cv_warn__funit_at_a_time+set}" = set; then :
22520 $as_echo_n "(cached) " >&6
22521 else
22522
22523 save_CPPFLAGS="$CPPFLAGS"
22524 CPPFLAGS="${CPPFLAGS} -funit-at-a-time"
22525 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
22526 /* end confdefs.h. */
22527
22528 int
22529 main ()
22530 {
22531
22532 ;
22533 return 0;
22534 }
22535 _ACEOF
22536 if ac_fn_c_try_cpp "$LINENO"; then :
22537 gl_cv_warn__funit_at_a_time=yes
22538 else
22539 gl_cv_warn__funit_at_a_time=no
22540 fi
22541 rm -f conftest.err conftest.$ac_ext
22542 CPPFLAGS="$save_CPPFLAGS"
22543
22544 fi
22545 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_warn__funit_at_a_time" >&5
22546 $as_echo "$gl_cv_warn__funit_at_a_time" >&6; }
22547 if test "x$gl_cv_warn__funit_at_a_time" = x""yes; then :
22548 as_fn_append WARN_CFLAGS " -funit-at-a-time"
22549 fi
22550
22551
22552
22553
22554
22555 $as_echo "#define lint 1" >>confdefs.h
22556
22557
22558 $as_echo "#define _FORTIFY_SOURCE 2" >>confdefs.h
22559
22560
22561 $as_echo "#define GNULIB_PORTCHECK 1" >>confdefs.h
22562
22563
22564 # We use a slightly smaller set of warning options for lib/.
22565 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
22566 nw=
22567 nw="$nw -Wuninitialized"
22568 nw="$nw -Wmissing-prototypes"
22569 nw="$nw -Wold-style-definition"
22570
22571 gl_warn_set=
22572 set x $WARN_CFLAGS; shift
22573 for gl_warn_item
22574 do
22575 case " $nw " in
22576 *" $gl_warn_item "*)
22577 ;;
22578 *)
22579 gl_warn_set="$gl_warn_set $gl_warn_item"
22580 ;;
22581 esac
22582 done
22583 GNULIB_WARN_CFLAGS=$gl_warn_set
22584
22585
22586 fi
1941022587
1941122588 # cc -E produces incorrect asm files on SVR4, so postprocess it.
1941222589 ASCPPPOST="sed '/^ *#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
1974322920 $as_echo "#define STDC_HEADERS 1" >>confdefs.h
1974422921
1974522922 fi
19746
19747
19748
19749
19750
19751
1975222923
1975322924
1975422925
2010623277 if test -n "$gl_LIBOBJS"; then
2010723278 # Remove the extension.
2010823279 sed_drop_objext='s/\.o$//;s/\.obj$//'
20109 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
23280 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
2011023281 gl_libobjs="$gl_libobjs $i.$ac_objext"
2011123282 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
2011223283 done
2012223293 if test -n "$gltests_LIBOBJS"; then
2012323294 # Remove the extension.
2012423295 sed_drop_objext='s/\.o$//;s/\.obj$//'
20125 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
23296 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
2012623297 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
2012723298 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
2012823299 done
2054023711 # report actual input values of CONFIG_FILES etc. instead of their
2054123712 # values after options handling.
2054223713 ac_log="
20543 This file was extended by gzip $as_me 1.3.14, which was
20544 generated by GNU Autoconf 2.64.69-81c80. Invocation command line was
23714 This file was extended by gzip $as_me 1.4, which was
23715 generated by GNU Autoconf 2.65.23-13e35. Invocation command line was
2054523716
2054623717 CONFIG_FILES = $CONFIG_FILES
2054723718 CONFIG_HEADERS = $CONFIG_HEADERS
2061023781 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
2061123782 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
2061223783 ac_cs_version="\\
20613 gzip config.status 1.3.14
20614 configured by $0, generated by GNU Autoconf 2.64.69-81c80,
23784 gzip config.status 1.4
23785 configured by $0, generated by GNU Autoconf 2.65.23-13e35,
2061523786 with options \\"\$ac_cs_config\\"
2061623787
20617 Copyright (C) 2009 Free Software Foundation, Inc.
23788 Copyright (C) 2010 Free Software Foundation, Inc.
2061823789 This config.status script is free software; the Free Software Foundation
2061923790 gives unlimited permission to copy, distribute and modify it."
2062023791
2084424015 t delim
2084524016 :nl
2084624017 h
20847 s/\(.\{148\}\).*/\1/
24018 s/\(.\{148\}\)..*/\1/
2084824019 t more1
2084924020 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
2085024021 p
2085824029 t nl
2085924030 :delim
2086024031 h
20861 s/\(.\{148\}\).*/\1/
24032 s/\(.\{148\}\)..*/\1/
2086224033 t more2
2086324034 s/["\\]/\\&/g; s/^/"/; s/$/"/
2086424035 p
2107824249 [\\/$]*) false;;
2107924250 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
2108024251 esac ||
21081 as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
24252 { as_fn_set_status 1
24253 as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5; };;
2108224254 esac
2108324255 case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
2108424256 as_fn_append ac_file_inputs " '$ac_f'"
2133924511 rm -f "$ac_file"
2134024512
2134124513 # Try a relative symlink, then a hard link, then a copy.
21342 case $srcdir in
24514 case $ac_source in
2134324515 [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;;
2134424516 *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
2134524517 esac
2148224654 exec 5>>config.log
2148324655 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
2148424656 # would make configure fail if this is the last instruction.
21485 $ac_cs_success || as_fn_exit $?
24657 $ac_cs_success || as_fn_exit 1
2148624658 fi
2148724659 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
2148824660 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
00 # Configure template for gzip.
11
2 # Copyright (C) 1999-2002, 2006-2007, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 1999-2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
33
44 # Copyright (C) 1992-1993 Jean-loup Gailly
55
4141 AC_SYS_LARGEFILE
4242
4343 gl_INIT
44
45 AC_ARG_ENABLE([gcc-warnings],
46 [AS_HELP_STRING([--enable-gcc-warnings],
47 [turn on lots of GCC warnings (for developers)])],
48 [case $enableval in
49 yes|no) ;;
50 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
51 esac
52 gl_gcc_warnings=$enableval],
53 [gl_gcc_warnings=no]
54 )
55
56 if test "$gl_gcc_warnings" = yes; then
57 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
58 AC_SUBST([WERROR_CFLAGS])
59
60 nw=
61 # This, $nw, is the list of warnings we disable.
62 nw="$nw -Wdeclaration-after-statement" # too useful to forbid
63 nw="$nw -Waggregate-return" # anachronistic
64 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
65 nw="$nw -Wc++-compat" # We don't care about C++ compilers
66 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
67 nw="$nw -Wtraditional" # Warns on #elif which we use often
68 nw="$nw -Wcast-qual" # Too many warnings for now
69 nw="$nw -Wconversion" # Too many warnings for now
70 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
71 nw="$nw -Wsign-conversion" # Too many warnings for now
72 nw="$nw -Wtraditional-conversion" # Too many warnings for now
73 nw="$nw -Wunreachable-code" # Too many warnings for now
74 nw="$nw -Wpadded" # Our structs are not padded
75 nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
76 nw="$nw -Wlogical-op" # any use of fwrite provokes this
77 nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
78 nw="$nw -Wvla" # warnings in gettext.h
79 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
80 nw="$nw -Wswitch-enum" # Too many warnings for now
81 nw="$nw -Wswitch-default" # Too many warnings for now
82 nw="$nw -Wstack-protector" # not worth working around
83 # things I might fix soon:
84 nw="$nw -Wfloat-equal" # sort.c, seq.c
85 nw="$nw -Wmissing-format-attribute" # copy.c
86 nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
87 nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
88 nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
89 # initial problems in gzip
90 nw="$nw -Wold-style-definition"
91 nw="$nw -Wshadow"
92 nw="$nw -Wunused-macros"
93 # ?? -Wstrict-overflow
94
95 gl_MANYWARN_ALL_GCC([ws])
96 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
97 for w in $ws; do
98 gl_WARN_ADD([$w])
99 done
100 gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
101 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
102 gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
103 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
104 gl_WARN_ADD([-Wno-overflow]) # util.c
105 gl_WARN_ADD([-Wno-type-limits]) # util.c
106
107 # In spite of excluding -Wlogical-op above, it is enabled, as of
108 # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
109 gl_WARN_ADD([-Wno-logical-op])
110
111 gl_WARN_ADD([-fdiagnostics-show-option])
112 gl_WARN_ADD([-funit-at-a-time])
113
114 AC_SUBST([WARN_CFLAGS])
115
116 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
117 AC_DEFINE([_FORTIFY_SOURCE], [2],
118 [enable compile-time and run-time bounds-checking, and some warnings])
119 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
120
121 # We use a slightly smaller set of warning options for lib/.
122 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
123 nw=
124 nw="$nw -Wuninitialized"
125 nw="$nw -Wmissing-prototypes"
126 nw="$nw -Wold-style-definition"
127 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
128 AC_SUBST([GNULIB_WARN_CFLAGS])
129 fi
44130
45131 # cc -E produces incorrect asm files on SVR4, so postprocess it.
46132 ASCPPPOST="sed '/^ *#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
102188 AC_C_CONST
103189 AC_HEADER_STDC
104190 AC_CHECK_HEADERS_ONCE(fcntl.h limits.h memory.h time.h)
105 AC_CHECK_FUNCS_ONCE([chown fchmod fchown fdopendir lstat siginterrupt])
191 AC_CHECK_FUNCS_ONCE([chown fchmod fchown lstat siginterrupt])
106192 AC_HEADER_DIRENT
107193 AC_TYPE_SIGNAL
108194 AC_TYPE_SIZE_T
00 /* deflate.c -- compress data using the deflation algorithm
11
2 Copyright (C) 1999, 2006, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1999, 2006, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
250250 * meaning.
251251 */
252252
253 #define EQUAL 0
254 /* result of memcmp for equal strings */
255
256253 /* ===========================================================================
257254 * Prototypes for local functions.
258255 */
499496 {
500497 /* check that the match is indeed a match */
501498 if (memcmp((char*)window + match,
502 (char*)window + start, length) != EQUAL) {
499 (char*)window + start, length) != 0) {
503500 fprintf(stderr,
504501 " start %d, match %d, length %d\n",
505502 start, match, length);
00 # Make gzip documentation. -*-Makefile-*-
11
2 # Copyright (C) 2006, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
33
44 # This program is free software; you can redistribute it and/or modify
55 # it under the terms of the GNU General Public License as published by
11 # @configure_input@
22
33 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
5 # Inc.
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 # Foundation, Inc.
66 # This Makefile.in is free software; the Free Software Foundation
77 # gives unlimited permission to copy and/or distribute it,
88 # with or without modifications, as long as this notice is preserved.
1616
1717 # Make gzip documentation. -*-Makefile-*-
1818
19 # Copyright (C) 2006, 2009 Free Software Foundation, Inc.
19 # Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
2020
2121 # This program is free software; you can redistribute it and/or modify
2222 # it under the terms of the GNU General Public License as published by
5858 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
5959 am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
6060 $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/calloc.m4 \
61 $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \
6162 $(top_srcdir)/m4/clock_time.m4 \
6263 $(top_srcdir)/m4/close-stream.m4 $(top_srcdir)/m4/close.m4 \
6364 $(top_srcdir)/m4/closein.m4 $(top_srcdir)/m4/closeout.m4 \
64 $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/dos.m4 \
65 $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/errno_h.m4 \
66 $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exitfail.m4 \
67 $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/exponentf.m4 \
68 $(top_srcdir)/m4/exponentl.m4 $(top_srcdir)/m4/extensions.m4 \
69 $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \
70 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fflush.m4 \
71 $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fpending.m4 \
72 $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintf-posix.m4 \
73 $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \
74 $(top_srcdir)/m4/frexp.m4 $(top_srcdir)/m4/frexpl.m4 \
75 $(top_srcdir)/m4/fseeko.m4 $(top_srcdir)/m4/ftello.m4 \
76 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/getpagesize.m4 \
77 $(top_srcdir)/m4/gettime.m4 $(top_srcdir)/m4/gettimeofday.m4 \
78 $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/gnu-make.m4 \
79 $(top_srcdir)/m4/gnulib-common.m4 \
65 $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/d-ino.m4 \
66 $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \
67 $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \
68 $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
69 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \
70 $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \
71 $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \
72 $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \
73 $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-o.m4 \
74 $(top_srcdir)/m4/fcntl-safer.m4 $(top_srcdir)/m4/fcntl.m4 \
75 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fdopendir.m4 \
76 $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/float_h.m4 \
77 $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \
78 $(top_srcdir)/m4/fprintf-posix.m4 $(top_srcdir)/m4/fpurge.m4 \
79 $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \
80 $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \
81 $(top_srcdir)/m4/ftello.m4 \
82 $(top_srcdir)/m4/getcwd-abort-bug.m4 \
83 $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \
84 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \
85 $(top_srcdir)/m4/gettimeofday.m4 $(top_srcdir)/m4/glibc21.m4 \
86 $(top_srcdir)/m4/gnu-make.m4 $(top_srcdir)/m4/gnulib-common.m4 \
8087 $(top_srcdir)/m4/gnulib-comp.m4 \
8188 $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inline.m4 \
8289 $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \
8390 $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \
84 $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/ldexpl.m4 \
85 $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \
86 $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \
87 $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lseek.m4 \
88 $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \
91 $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/lchown.m4 \
92 $(top_srcdir)/m4/ldexpl.m4 $(top_srcdir)/m4/localcharset.m4 \
93 $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \
94 $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/longlong.m4 \
95 $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \
96 $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/manywarnings.m4 \
8997 $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbrtowc.m4 \
9098 $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbstate_t.m4 \
91 $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mmap-anon.m4 \
92 $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/multiarch.m4 \
93 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \
99 $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mempcpy.m4 \
100 $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mkdir.m4 \
101 $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \
102 $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nocrash.m4 \
103 $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \
94104 $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/printf-frexp.m4 \
95105 $(top_srcdir)/m4/printf-frexpl.m4 \
96106 $(top_srcdir)/m4/printf-posix-rpl.m4 \
97107 $(top_srcdir)/m4/printf.m4 $(top_srcdir)/m4/quotearg.m4 \
98 $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/shell.m4 \
108 $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rmdir.m4 \
109 $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/shell.m4 \
99110 $(top_srcdir)/m4/signbit.m4 $(top_srcdir)/m4/size_max.m4 \
100111 $(top_srcdir)/m4/stat-time.m4 $(top_srcdir)/m4/stat.m4 \
101112 $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
102113 $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
103114 $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
104 $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/string_h.m4 \
105 $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \
106 $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/timespec.m4 \
107 $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \
115 $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
116 $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/sys_stat_h.m4 \
117 $(top_srcdir)/m4/sys_time_h.m4 $(top_srcdir)/m4/time_h.m4 \
118 $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/unistd-safer.m4 \
119 $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink.m4 \
108120 $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \
109121 $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \
110 $(top_srcdir)/m4/vfprintf-posix.m4 $(top_srcdir)/m4/wchar.m4 \
111 $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wctype.m4 \
112 $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \
122 $(top_srcdir)/m4/vfprintf-posix.m4 \
123 $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \
124 $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \
125 $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wint_t.m4 \
126 $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xgetcwd.m4 \
113127 $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/yesno.m4 \
114128 $(top_srcdir)/configure.ac
115129 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
221235 EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
222236 ERRNO_H = @ERRNO_H@
223237 EXEEXT = @EXEEXT@
224 FCNTL_H = @FCNTL_H@
225238 FLOAT_H = @FLOAT_H@
226239 GETOPT_H = @GETOPT_H@
227240 GLIBC21 = @GLIBC21@
241 GNULIB_ACOSL = @GNULIB_ACOSL@
242 GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
243 GNULIB_ASINL = @GNULIB_ASINL@
244 GNULIB_ATANL = @GNULIB_ATANL@
228245 GNULIB_ATOLL = @GNULIB_ATOLL@
229246 GNULIB_BTOWC = @GNULIB_BTOWC@
230247 GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
233250 GNULIB_CEILL = @GNULIB_CEILL@
234251 GNULIB_CHOWN = @GNULIB_CHOWN@
235252 GNULIB_CLOSE = @GNULIB_CLOSE@
253 GNULIB_COSL = @GNULIB_COSL@
254 GNULIB_DIRFD = @GNULIB_DIRFD@
236255 GNULIB_DPRINTF = @GNULIB_DPRINTF@
237256 GNULIB_DUP2 = @GNULIB_DUP2@
238257 GNULIB_DUP3 = @GNULIB_DUP3@
239258 GNULIB_ENVIRON = @GNULIB_ENVIRON@
240259 GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
260 GNULIB_EXPL = @GNULIB_EXPL@
241261 GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
242262 GNULIB_FCHDIR = @GNULIB_FCHDIR@
243263 GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
244264 GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
245265 GNULIB_FCLOSE = @GNULIB_FCLOSE@
266 GNULIB_FCNTL = @GNULIB_FCNTL@
267 GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
246268 GNULIB_FFLUSH = @GNULIB_FFLUSH@
247269 GNULIB_FLOORF = @GNULIB_FLOORF@
248270 GNULIB_FLOORL = @GNULIB_FLOORL@
268290 GNULIB_GETDELIM = @GNULIB_GETDELIM@
269291 GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
270292 GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
293 GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
271294 GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
272295 GNULIB_GETLINE = @GNULIB_GETLINE@
273296 GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
297 GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
274298 GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
275299 GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
276300 GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
286310 GNULIB_LDEXPL = @GNULIB_LDEXPL@
287311 GNULIB_LINK = @GNULIB_LINK@
288312 GNULIB_LINKAT = @GNULIB_LINKAT@
313 GNULIB_LOGL = @GNULIB_LOGL@
289314 GNULIB_LSEEK = @GNULIB_LSEEK@
290315 GNULIB_LSTAT = @GNULIB_LSTAT@
291316 GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
292 GNULIB_MATHL = @GNULIB_MATHL@
293317 GNULIB_MBRLEN = @GNULIB_MBRLEN@
294318 GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
295319 GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
315339 GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
316340 GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
317341 GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
342 GNULIB_MKFIFO = @GNULIB_MKFIFO@
318343 GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
344 GNULIB_MKNOD = @GNULIB_MKNOD@
319345 GNULIB_MKNODAT = @GNULIB_MKNODAT@
320346 GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
347 GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
321348 GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
349 GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
322350 GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
323351 GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
324352 GNULIB_OPEN = @GNULIB_OPEN@
326354 GNULIB_PERROR = @GNULIB_PERROR@
327355 GNULIB_PIPE2 = @GNULIB_PIPE2@
328356 GNULIB_POPEN = @GNULIB_POPEN@
357 GNULIB_PREAD = @GNULIB_PREAD@
329358 GNULIB_PRINTF = @GNULIB_PRINTF@
330359 GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
331360 GNULIB_PUTC = @GNULIB_PUTC@
346375 GNULIB_ROUNDF = @GNULIB_ROUNDF@
347376 GNULIB_ROUNDL = @GNULIB_ROUNDL@
348377 GNULIB_RPMATCH = @GNULIB_RPMATCH@
378 GNULIB_SCANDIR = @GNULIB_SCANDIR@
349379 GNULIB_SETENV = @GNULIB_SETENV@
350380 GNULIB_SIGNBIT = @GNULIB_SIGNBIT@
381 GNULIB_SINL = @GNULIB_SINL@
351382 GNULIB_SLEEP = @GNULIB_SLEEP@
352383 GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
353384 GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
385 GNULIB_SQRTL = @GNULIB_SQRTL@
354386 GNULIB_STAT = @GNULIB_STAT@
355387 GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
356388 GNULIB_STPCPY = @GNULIB_STPCPY@
372404 GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
373405 GNULIB_SYMLINK = @GNULIB_SYMLINK@
374406 GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
407 GNULIB_TANL = @GNULIB_TANL@
375408 GNULIB_TRUNC = @GNULIB_TRUNC@
376409 GNULIB_TRUNCF = @GNULIB_TRUNCF@
377410 GNULIB_TRUNCL = @GNULIB_TRUNCL@
380413 GNULIB_UNLINK = @GNULIB_UNLINK@
381414 GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
382415 GNULIB_UNSETENV = @GNULIB_UNSETENV@
416 GNULIB_USLEEP = @GNULIB_USLEEP@
383417 GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
384418 GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
385419 GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
389423 GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
390424 GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
391425 GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
426 GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@
392427 GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
393428 GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
394429 GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
396431 GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
397432 GNULIB_WRITE = @GNULIB_WRITE@
398433 GREP = @GREP@
434 HAVE_ACOSL = @HAVE_ACOSL@
435 HAVE_ALPHASORT = @HAVE_ALPHASORT@
436 HAVE_ASINL = @HAVE_ASINL@
437 HAVE_ATANL = @HAVE_ATANL@
399438 HAVE_ATOLL = @HAVE_ATOLL@
400439 HAVE_BTOWC = @HAVE_BTOWC@
401440 HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@
402441 HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
442 HAVE_CHOWN = @HAVE_CHOWN@
443 HAVE_COSL = @HAVE_COSL@
403444 HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@
404445 HAVE_DECL_ASINL = @HAVE_DECL_ASINL@
405446 HAVE_DECL_ATANL = @HAVE_DECL_ATANL@
406447 HAVE_DECL_COSL = @HAVE_DECL_COSL@
448 HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
407449 HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
408450 HAVE_DECL_EXPL = @HAVE_DECL_EXPL@
409451 HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
436478 HAVE_DUP2 = @HAVE_DUP2@
437479 HAVE_DUP3 = @HAVE_DUP3@
438480 HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
481 HAVE_EXPL = @HAVE_EXPL@
439482 HAVE_FACCESSAT = @HAVE_FACCESSAT@
440483 HAVE_FCHMODAT = @HAVE_FCHMODAT@
441484 HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
442 HAVE_FSEEKO = @HAVE_FSEEKO@
485 HAVE_FCNTL = @HAVE_FCNTL@
486 HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
443487 HAVE_FSTATAT = @HAVE_FSTATAT@
444488 HAVE_FSYNC = @HAVE_FSYNC@
445 HAVE_FTELLO = @HAVE_FTELLO@
446489 HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
447490 HAVE_FUTIMENS = @HAVE_FUTIMENS@
448491 HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@
449492 HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
493 HAVE_GETGROUPS = @HAVE_GETGROUPS@
450494 HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
495 HAVE_GETLOGIN = @HAVE_GETLOGIN@
451496 HAVE_GETOPT_H = @HAVE_GETOPT_H@
452497 HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
453498 HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
458503 HAVE_ISNANL = @HAVE_ISNANL@
459504 HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
460505 HAVE_LCHMOD = @HAVE_LCHMOD@
506 HAVE_LCHOWN = @HAVE_LCHOWN@
461507 HAVE_LINK = @HAVE_LINK@
462508 HAVE_LINKAT = @HAVE_LINKAT@
509 HAVE_LOGL = @HAVE_LOGL@
463510 HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
464511 HAVE_LSTAT = @HAVE_LSTAT@
465512 HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@
466513 HAVE_MBRLEN = @HAVE_MBRLEN@
467514 HAVE_MBRTOWC = @HAVE_MBRTOWC@
468515 HAVE_MBSINIT = @HAVE_MBSINIT@
516 HAVE_MBSLEN = @HAVE_MBSLEN@
469517 HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
470518 HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
471519 HAVE_MEMPCPY = @HAVE_MEMPCPY@
472520 HAVE_MKDIRAT = @HAVE_MKDIRAT@
473521 HAVE_MKDTEMP = @HAVE_MKDTEMP@
522 HAVE_MKFIFO = @HAVE_MKFIFO@
474523 HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
524 HAVE_MKNOD = @HAVE_MKNOD@
475525 HAVE_MKNODAT = @HAVE_MKNODAT@
476526 HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
527 HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
528 HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
477529 HAVE_OPENAT = @HAVE_OPENAT@
478530 HAVE_OS_H = @HAVE_OS_H@
479531 HAVE_PIPE2 = @HAVE_PIPE2@
532 HAVE_PREAD = @HAVE_PREAD@
480533 HAVE_RANDOM_H = @HAVE_RANDOM_H@
481534 HAVE_RANDOM_R = @HAVE_RANDOM_R@
482535 HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
486539 HAVE_REALPATH = @HAVE_REALPATH@
487540 HAVE_RENAMEAT = @HAVE_RENAMEAT@
488541 HAVE_RPMATCH = @HAVE_RPMATCH@
542 HAVE_SCANDIR = @HAVE_SCANDIR@
489543 HAVE_SETENV = @HAVE_SETENV@
490544 HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
491545 HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
492546 HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
547 HAVE_SINL = @HAVE_SINL@
493548 HAVE_SLEEP = @HAVE_SLEEP@
549 HAVE_SQRTL = @HAVE_SQRTL@
494550 HAVE_STDINT_H = @HAVE_STDINT_H@
495551 HAVE_STPCPY = @HAVE_STPCPY@
496552 HAVE_STPNCPY = @HAVE_STPNCPY@
512568 HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
513569 HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
514570 HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
571 HAVE_TANL = @HAVE_TANL@
515572 HAVE_UNISTD_H = @HAVE_UNISTD_H@
516573 HAVE_UNLINKAT = @HAVE_UNLINKAT@
517574 HAVE_UNSETENV = @HAVE_UNSETENV@
518575 HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
576 HAVE_USLEEP = @HAVE_USLEEP@
519577 HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
520578 HAVE_VASPRINTF = @HAVE_VASPRINTF@
521579 HAVE_VDPRINTF = @HAVE_VDPRINTF@
550608 LTLIBOBJS = @LTLIBOBJS@
551609 MAKEINFO = @MAKEINFO@
552610 MKDIR_P = @MKDIR_P@
611 NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
553612 NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
554613 NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
555614 NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
566625 NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
567626 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
568627 NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
628 NEXT_DIRENT_H = @NEXT_DIRENT_H@
569629 NEXT_ERRNO_H = @NEXT_ERRNO_H@
570630 NEXT_FCNTL_H = @NEXT_FCNTL_H@
571631 NEXT_FLOAT_H = @NEXT_FLOAT_H@
601661 REPLACE_CEILL = @REPLACE_CEILL@
602662 REPLACE_CHOWN = @REPLACE_CHOWN@
603663 REPLACE_CLOSE = @REPLACE_CLOSE@
664 REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
604665 REPLACE_DPRINTF = @REPLACE_DPRINTF@
605666 REPLACE_DUP = @REPLACE_DUP@
606667 REPLACE_DUP2 = @REPLACE_DUP2@
607668 REPLACE_FCHDIR = @REPLACE_FCHDIR@
608669 REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
609670 REPLACE_FCLOSE = @REPLACE_FCLOSE@
671 REPLACE_FCNTL = @REPLACE_FCNTL@
672 REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
610673 REPLACE_FFLUSH = @REPLACE_FFLUSH@
611674 REPLACE_FLOORF = @REPLACE_FLOORF@
612675 REPLACE_FLOORL = @REPLACE_FLOORL@
624687 REPLACE_FTELLO = @REPLACE_FTELLO@
625688 REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
626689 REPLACE_GETCWD = @REPLACE_GETCWD@
690 REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
627691 REPLACE_GETLINE = @REPLACE_GETLINE@
628692 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
629693 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
648712 REPLACE_MEMCHR = @REPLACE_MEMCHR@
649713 REPLACE_MEMMEM = @REPLACE_MEMMEM@
650714 REPLACE_MKDIR = @REPLACE_MKDIR@
715 REPLACE_MKFIFO = @REPLACE_MKFIFO@
716 REPLACE_MKNOD = @REPLACE_MKNOD@
651717 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
652718 REPLACE_MKTIME = @REPLACE_MKTIME@
653719 REPLACE_NAN = @REPLACE_NAN@
656722 REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
657723 REPLACE_OPEN = @REPLACE_OPEN@
658724 REPLACE_OPENAT = @REPLACE_OPENAT@
725 REPLACE_OPENDIR = @REPLACE_OPENDIR@
659726 REPLACE_PERROR = @REPLACE_PERROR@
660727 REPLACE_POPEN = @REPLACE_POPEN@
728 REPLACE_PREAD = @REPLACE_PREAD@
661729 REPLACE_PRINTF = @REPLACE_PRINTF@
662730 REPLACE_PUTENV = @REPLACE_PUTENV@
663731 REPLACE_READLINK = @REPLACE_READLINK@
669737 REPLACE_ROUND = @REPLACE_ROUND@
670738 REPLACE_ROUNDF = @REPLACE_ROUNDF@
671739 REPLACE_ROUNDL = @REPLACE_ROUNDL@
740 REPLACE_SETENV = @REPLACE_SETENV@
672741 REPLACE_SIGNBIT = @REPLACE_SIGNBIT@
673742 REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@
743 REPLACE_SLEEP = @REPLACE_SLEEP@
674744 REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
675745 REPLACE_SPRINTF = @REPLACE_SPRINTF@
676746 REPLACE_STAT = @REPLACE_STAT@
689759 REPLACE_TRUNCL = @REPLACE_TRUNCL@
690760 REPLACE_UNLINK = @REPLACE_UNLINK@
691761 REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
762 REPLACE_UNSETENV = @REPLACE_UNSETENV@
763 REPLACE_USLEEP = @REPLACE_USLEEP@
692764 REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
693765 REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
694766 REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
717789 UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
718790 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
719791 VERSION = @VERSION@
720 VOID_UNSETENV = @VOID_UNSETENV@
721 WCHAR_H = @WCHAR_H@
792 WARN_CFLAGS = @WARN_CFLAGS@
722793 WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
723794 WCTYPE_H = @WCTYPE_H@
795 WERROR_CFLAGS = @WERROR_CFLAGS@
724796 WINT_T_SUFFIX = @WINT_T_SUFFIX@
725797 abs_builddir = @abs_builddir@
726798 abs_srcdir = @abs_srcdir@
Binary diff not shown
1010 (version @value{VERSION}, @value{UPDATED}),
1111 and documents commands for compressing and decompressing data.
1212
13 Copyright @copyright{} 1998-1999, 2001-2002, 2006-2007, 2009 Free Software
13 Copyright @copyright{} 1998-1999, 2001-2002, 2006-2007, 2009-2010 Free Software
1414 Foundation, Inc.
1515
1616 Copyright @copyright{} 1992, 1993 Jean-loup Gailly
0 @set UPDATED 28 September 2009
1 @set UPDATED-MONTH September 2009
2 @set EDITION 1.3.14
3 @set VERSION 1.3.14
0 @set UPDATED 3 January 2010
1 @set UPDATED-MONTH January 2010
2 @set EDITION 1.4
3 @set VERSION 1.4
0 @set UPDATED 28 September 2009
1 @set UPDATED-MONTH September 2009
2 @set EDITION 1.3.14
3 @set VERSION 1.3.14
0 @set UPDATED 3 January 2010
1 @set UPDATED-MONTH January 2010
2 @set EDITION 1.4
3 @set VERSION 1.4
2323 PATH=$bindir:$PATH
2424
2525 version="gunzip (gzip) @VERSION@
26 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
26 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
2727 This is free software. You may redistribute copies of it under the terms of
2828 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2929 There is NO WARRANTY, to the extent permitted by law.
3535 IFS=" $tab$nl"
3636
3737 version='gzexe (gzip) @VERSION@
38 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
38 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
3939 This is free software. You may redistribute copies of it under the terms of
4040 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
4141 There is NO WARRANTY, to the extent permitted by law.
00 /* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
11
2 Copyright (C) 1999, 2001-2002, 2006-2007, 2009 Free Software Foundation,
3 Inc.
2 Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2010 Free Software
3 Foundation, Inc.
44 Copyright (C) 1992-1993 Jean-loup Gailly
55
66 This program is free software; you can redistribute it and/or modify
2727 * See the file algorithm.doc for the compression algorithms and file formats.
2828 */
2929
30 static char *license_msg[] = {
30 static char const *const license_msg[] = {
3131 "Copyright (C) 2007 Free Software Foundation, Inc.",
3232 "Copyright (C) 1993 Jean-loup Gailly.",
3333 "This is free software. You may redistribute copies of it under the terms of",
6868
6969 #include "fcntl-safer.h"
7070 #include "getopt.h"
71 #include "ignore-value.h"
7172 #include "stat-time.h"
7273
7374 /* configuration */
7475
75 #ifdef HAVE_FCNTL_H
76 # include <fcntl.h>
77 #endif
78
79 #ifdef HAVE_LIMITS_H
80 # include <limits.h>
81 #endif
82
83 #ifdef HAVE_UNISTD_H
84 # include <unistd.h>
85 #endif
86
87 #if defined STDC_HEADERS || defined HAVE_STDLIB_H
88 # include <stdlib.h>
89 #else
90 extern int errno;
91 #endif
76 #include <fcntl.h>
77 #include <limits.h>
78 #include <unistd.h>
79 #include <stdlib.h>
80 #include <errno.h>
9281
9382 #ifndef NO_DIR
9483 # define NO_DIR 0
202191 off_t ifile_size; /* input file size, -1 for devices (debug only) */
203192 char *env; /* contents of GZIP env variable */
204193 char **args = NULL; /* argv pointer if GZIP env variable defined */
205 char *z_suffix; /* default suffix (can be set with --suffix) */
194 char const *z_suffix; /* default suffix (can be set with --suffix) */
206195 size_t z_len; /* strlen(z_suffix) */
207196
208197 /* The set of signals that are caught. */
326315 /* ======================================================================== */
327316 local void help()
328317 {
329 static char *help_msg[] = {
318 static char const* const help_msg[] = {
330319 "Compress or uncompress FILEs (by default, compress FILES in-place).",
331320 "",
332321 "Mandatory arguments to long options are mandatory for short options too.",
367356 "",
368357 "Report bugs to <bug-gzip@gnu.org>.",
369358 0};
370 char **p = help_msg;
359 char const *const *p = help_msg;
371360
372361 printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
373362 while (*p) printf ("%s\n", *p++);
376365 /* ======================================================================== */
377366 local void license()
378367 {
379 char **p = license_msg;
368 char const *const *p = license_msg;
380369
381370 printf ("%s %s\n", program_name, VERSION);
382371 while (*p) printf ("%s\n", *p++);
390379 printf ("Written by Jean-loup Gailly.\n");
391380 }
392381
393 local void progerror (string)
394 char *string;
382 local void progerror (char const *string)
395383 {
396384 int e = errno;
397385 fprintf (stderr, "%s: ", program_name);
401389 }
402390
403391 /* ======================================================================== */
404 int main (argc, argv)
405 int argc;
406 char **argv;
392 int main (int argc, char **argv)
407393 {
408394 int file_count; /* number of files to process */
409395 size_t proglen; /* length of program_name */
972958 {
973959 int nlen, slen;
974960 char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */
975 static char *known_suffixes[] =
961 static char const *known_suffixes[] =
976962 {NULL, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z",
977963 #ifdef MAX_EXT_CHARS
978964 "z",
979965 #endif
980966 NULL};
981 char **suf = known_suffixes;
967 char const **suf = known_suffixes;
982968
983969 *suf = z_suffix;
984970 if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */
10631049 {
10641050 int ilen; /* strlen(ifname) */
10651051 int z_suffix_errno = 0;
1066 static char *suffixes[] = {NULL, ".gz", ".z", "-z", ".Z", NULL};
1067 char **suf = suffixes;
1068 char *s;
1052 static char const *suffixes[] = {NULL, ".gz", ".z", "-z", ".Z", NULL};
1053 char const **suf = suffixes;
1054 char const *s;
10691055 #ifdef NO_MULTIPLE_DOTS
10701056 char *dot; /* pointer to ifname extension, or NULL */
10711057 #endif
11091095
11101096 /* Search for all suffixes */
11111097 do {
1112 char *s0 = s = *suf;
1098 char const *s0 = s = *suf;
11131099 strcpy (ifname, iname);
11141100 #ifdef NO_MULTIPLE_DOTS
11151101 if (*s == '.') s++;
14501436 {
14511437 ulg crc; /* original crc */
14521438 static int first_time = 1;
1453 static char* methods[MAX_METHODS] = {
1439 static char const *const methods[MAX_METHODS] = {
14541440 "store", /* 0 */
14551441 "compr", /* 1 */
14561442 "pack ", /* 2 */
16791665 #endif
16801666
16811667 #ifndef NO_CHOWN
1668 /* Copy ownership */
16821669 # if HAVE_FCHOWN
1683 fchown (ofd, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
1670 ignore_value (fchown (ofd, ifstat->st_uid, ifstat->st_gid));
16841671 # elif HAVE_CHOWN
1685 chown(ofname, ifstat->st_uid, ifstat->st_gid); /* Copy ownership */
1672 ignore_value (chown (ofname, ifstat->st_uid, ifstat->st_gid));
16861673 # endif
16871674 #endif
16881675
17161703 char nbuf[MAX_PATH_LEN];
17171704 int len;
17181705
1719 #if HAVE_FDOPENDIR
17201706 dirp = fdopendir (fd);
1721 #else
1722 close (fd);
1723 dirp = opendir(dir);
1724 #endif
17251707
17261708 if (dirp == NULL) {
17271709 progerror(dir);
1728 #if HAVE_FDOPENDIR
17291710 close (fd);
1730 #endif
17311711 return ;
17321712 }
17331713 /*
00 /* gzip.h -- common declarations for all gzip modules
11
2 Copyright (C) 1997-1999, 2001, 2006-2007, 2009 Free Software Foundation,
3 Inc.
2 Copyright (C) 1997-1999, 2001, 2006-2007, 2009-2010 Free Software
3 Foundation, Inc.
44
55 Copyright (C) 1992-1993 Jean-loup Gailly.
66
4646 #include <stdio.h>
4747 #include <sys/types.h> /* for off_t */
4848 #include <time.h>
49 #if defined HAVE_STRING_H || defined STDC_HEADERS
50 # include <string.h>
51 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H && !defined __GNUC__
52 # include <memory.h>
53 # endif
54 # define memzero(s, n) memset ((voidp)(s), 0, (n))
55 #else
56 # include <strings.h>
57 # define strchr index
58 # define strrchr rindex
59 # define memcpy(d, s, n) bcopy((s), (d), (n))
60 # define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
61 # define memzero(s, n) bzero((s), (n))
62 #endif
49 #include <string.h>
50 #define memzero(s, n) memset ((voidp)(s), 0, (n))
6351
6452 #ifndef RETSIGTYPE
6553 # define RETSIGTYPE void
328316 extern char *gzip_base_name OF((char *fname));
329317 extern int xunlink OF((char *fname));
330318 extern void make_simple_name OF((char *name));
331 extern char *add_envopt OF((int *argcp, char ***argvp, char *env));
332 extern void gzip_error OF((char *m)) ATTRIBUTE_NORETURN;
319 extern char *add_envopt OF((int *argcp, char ***argvp, char const *env));
320 extern void gzip_error OF((char const *m)) ATTRIBUTE_NORETURN;
333321 extern void xalloc_die OF((void)) ATTRIBUTE_NORETURN;
334 extern void warning OF((char *m));
335 extern void read_error OF((void));
336 extern void write_error OF((void));
322 extern void warning OF((char const *m));
323 extern void read_error OF((void)) ATTRIBUTE_NORETURN;
324 extern void write_error OF((void)) ATTRIBUTE_NORETURN;
337325 extern void display_ratio OF((off_t num, off_t den, FILE *file));
338326 extern void fprint_off OF((FILE *, off_t, int));
339327
00 /* Inflate deflated data
11
2 Copyright (C) 1997-1999, 2002, 2006, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1997-1999, 2002, 2006, 2009-2010 Free Software Foundation,
3 Inc.
34
45 This program is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
116117 #include <config.h>
117118 #include "tailor.h"
118119
119 #if defined STDC_HEADERS || defined HAVE_STDLIB_H
120 # include <stdlib.h>
121 #endif
120 #include <stdlib.h>
122121
123122 #include "gzip.h"
124123 #define slide window
589588 do {
590589 n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
591590 #if !defined(NOMEMCPY) && !defined(DEBUG)
592 if (w - d >= e) /* (this test assumes unsigned comparison) */
591 unsigned int delta = w > d ? w - d : d - w;
592 if (delta >= e)
593593 {
594594 memcpy(slide + w, slide + d, e);
595595 w += e;
00 # Make gzip/lib -*-Makefile-*-
11
2 # Copyright (C) 2006, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
33
44 # This program is free software; you can redistribute it and/or modify
55 # it under the terms of the GNU General Public License as published by
2020
2121 libgzip_a_LIBADD += $(LIBOBJS)
2222 libgzip_a_DEPENDENCIES += $(LIBOBJS)
23 AM_CFLAGS += $(WARN_CFLAGS) $(WERROR_CFLAGS)
2324
2425 match.$(OBJEXT): match.c
2526 cp $(srcdir)/match.c _match.S
11 # @configure_input@
22
33 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
5 # Inc.
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
5 # Foundation, Inc.
66 # This Makefile.in is free software; the Free Software Foundation
77 # gives unlimited permission to copy and/or distribute it,
88 # with or without modifications, as long as this notice is preserved.
1616
1717 # Make gzip/lib -*-Makefile-*-
1818
19 # Copyright (C) 2006, 2009 Free Software Foundation, Inc.
19 # Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
2020
2121 # This program is free software; you can redistribute it and/or modify
2222 # it under the terms of the GNU General Public License as published by
3232 # with this program; if not, write to the Free Software Foundation, Inc.,
3333 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3434
35 # Copyright (C) 2002-2009 Free Software Foundation, Inc.
35 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
3636 #
3737 # This file is free software, distributed under the terms of the GNU
3838 # General Public License. As a special exception to the GNU General
4141 # the same distribution terms as the rest of that program.
4242 #
4343 # Generated by gnulib-tool.
44 # Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libgzip --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=getline --avoid=rpmatch --no-libtool --macro-prefix=gl announce-gen calloc close closein fclose fcntl fcntl-safer fdl fprintf-posix getopt-gnu git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload lstat maintainer-makefile malloc perror printf-posix realloc stat-time sys_stat time update-copyright utimens xalloc yesno
44 # Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libgzip --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=getline --avoid=rpmatch --no-libtool --macro-prefix=gl announce-gen calloc close closein fclose fcntl fcntl-safer fdl fdopendir fprintf-posix getopt-gnu git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload ignore-value lstat maintainer-makefile malloc manywarnings perror printf-posix realloc stat-time sys_stat time update-copyright utimens xalloc yesno
4545
4646
4747
7171 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
7272 am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
7373 $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/calloc.m4 \
74 $(top_srcdir)/m4/chdir-long.m4 $(top_srcdir)/m4/chown.m4 \
7475 $(top_srcdir)/m4/clock_time.m4 \
7576 $(top_srcdir)/m4/close-stream.m4 $(top_srcdir)/m4/close.m4 \
7677 $(top_srcdir)/m4/closein.m4 $(top_srcdir)/m4/closeout.m4 \
77 $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/dos.m4 \
78 $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/errno_h.m4 \
79 $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exitfail.m4 \
80 $(top_srcdir)/m4/exponentd.m4 $(top_srcdir)/m4/exponentf.m4 \
81 $(top_srcdir)/m4/exponentl.m4 $(top_srcdir)/m4/extensions.m4 \
82 $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-safer.m4 \
83 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fflush.m4 \
84 $(top_srcdir)/m4/float_h.m4 $(top_srcdir)/m4/fpending.m4 \
85 $(top_srcdir)/m4/fpieee.m4 $(top_srcdir)/m4/fprintf-posix.m4 \
86 $(top_srcdir)/m4/fpurge.m4 $(top_srcdir)/m4/freading.m4 \
87 $(top_srcdir)/m4/frexp.m4 $(top_srcdir)/m4/frexpl.m4 \
88 $(top_srcdir)/m4/fseeko.m4 $(top_srcdir)/m4/ftello.m4 \
89 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/getpagesize.m4 \
90 $(top_srcdir)/m4/gettime.m4 $(top_srcdir)/m4/gettimeofday.m4 \
91 $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/gnu-make.m4 \
92 $(top_srcdir)/m4/gnulib-common.m4 \
78 $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/d-ino.m4 \
79 $(top_srcdir)/m4/dirent_h.m4 $(top_srcdir)/m4/dirfd.m4 \
80 $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \
81 $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
82 $(top_srcdir)/m4/errno_h.m4 $(top_srcdir)/m4/error.m4 \
83 $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/exponentd.m4 \
84 $(top_srcdir)/m4/exponentf.m4 $(top_srcdir)/m4/exponentl.m4 \
85 $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fchdir.m4 \
86 $(top_srcdir)/m4/fclose.m4 $(top_srcdir)/m4/fcntl-o.m4 \
87 $(top_srcdir)/m4/fcntl-safer.m4 $(top_srcdir)/m4/fcntl.m4 \
88 $(top_srcdir)/m4/fcntl_h.m4 $(top_srcdir)/m4/fdopendir.m4 \
89 $(top_srcdir)/m4/fflush.m4 $(top_srcdir)/m4/float_h.m4 \
90 $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/fpieee.m4 \
91 $(top_srcdir)/m4/fprintf-posix.m4 $(top_srcdir)/m4/fpurge.m4 \
92 $(top_srcdir)/m4/freading.m4 $(top_srcdir)/m4/frexp.m4 \
93 $(top_srcdir)/m4/frexpl.m4 $(top_srcdir)/m4/fseeko.m4 \
94 $(top_srcdir)/m4/ftello.m4 \
95 $(top_srcdir)/m4/getcwd-abort-bug.m4 \
96 $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \
97 $(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/gettime.m4 \
98 $(top_srcdir)/m4/gettimeofday.m4 $(top_srcdir)/m4/glibc21.m4 \
99 $(top_srcdir)/m4/gnu-make.m4 $(top_srcdir)/m4/gnulib-common.m4 \
93100 $(top_srcdir)/m4/gnulib-comp.m4 \
94101 $(top_srcdir)/m4/include_next.m4 $(top_srcdir)/m4/inline.m4 \
95102 $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \
96103 $(top_srcdir)/m4/isnand.m4 $(top_srcdir)/m4/isnanf.m4 \
97 $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/ldexpl.m4 \
98 $(top_srcdir)/m4/localcharset.m4 $(top_srcdir)/m4/locale-fr.m4 \
99 $(top_srcdir)/m4/locale-ja.m4 $(top_srcdir)/m4/locale-zh.m4 \
100 $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/lseek.m4 \
101 $(top_srcdir)/m4/lstat.m4 $(top_srcdir)/m4/malloc.m4 \
104 $(top_srcdir)/m4/isnanl.m4 $(top_srcdir)/m4/lchown.m4 \
105 $(top_srcdir)/m4/ldexpl.m4 $(top_srcdir)/m4/localcharset.m4 \
106 $(top_srcdir)/m4/locale-fr.m4 $(top_srcdir)/m4/locale-ja.m4 \
107 $(top_srcdir)/m4/locale-zh.m4 $(top_srcdir)/m4/longlong.m4 \
108 $(top_srcdir)/m4/lseek.m4 $(top_srcdir)/m4/lstat.m4 \
109 $(top_srcdir)/m4/malloc.m4 $(top_srcdir)/m4/manywarnings.m4 \
102110 $(top_srcdir)/m4/math_h.m4 $(top_srcdir)/m4/mbrtowc.m4 \
103111 $(top_srcdir)/m4/mbsinit.m4 $(top_srcdir)/m4/mbstate_t.m4 \
104 $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mmap-anon.m4 \
105 $(top_srcdir)/m4/mode_t.m4 $(top_srcdir)/m4/multiarch.m4 \
106 $(top_srcdir)/m4/nocrash.m4 $(top_srcdir)/m4/open.m4 \
112 $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/mempcpy.m4 \
113 $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/mkdir.m4 \
114 $(top_srcdir)/m4/mmap-anon.m4 $(top_srcdir)/m4/mode_t.m4 \
115 $(top_srcdir)/m4/multiarch.m4 $(top_srcdir)/m4/nocrash.m4 \
116 $(top_srcdir)/m4/open.m4 $(top_srcdir)/m4/openat.m4 \
107117 $(top_srcdir)/m4/perror.m4 $(top_srcdir)/m4/printf-frexp.m4 \
108118 $(top_srcdir)/m4/printf-frexpl.m4 \
109119 $(top_srcdir)/m4/printf-posix-rpl.m4 \
110120 $(top_srcdir)/m4/printf.m4 $(top_srcdir)/m4/quotearg.m4 \
111 $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/shell.m4 \
121 $(top_srcdir)/m4/realloc.m4 $(top_srcdir)/m4/rmdir.m4 \
122 $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/shell.m4 \
112123 $(top_srcdir)/m4/signbit.m4 $(top_srcdir)/m4/size_max.m4 \
113124 $(top_srcdir)/m4/stat-time.m4 $(top_srcdir)/m4/stat.m4 \
114125 $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stddef_h.m4 \
115126 $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
116127 $(top_srcdir)/m4/stdio_h.m4 $(top_srcdir)/m4/stdlib_h.m4 \
117 $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/string_h.m4 \
118 $(top_srcdir)/m4/sys_stat_h.m4 $(top_srcdir)/m4/sys_time_h.m4 \
119 $(top_srcdir)/m4/time_h.m4 $(top_srcdir)/m4/timespec.m4 \
120 $(top_srcdir)/m4/unistd-safer.m4 $(top_srcdir)/m4/unistd_h.m4 \
128 $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strerror.m4 \
129 $(top_srcdir)/m4/string_h.m4 $(top_srcdir)/m4/sys_stat_h.m4 \
130 $(top_srcdir)/m4/sys_time_h.m4 $(top_srcdir)/m4/time_h.m4 \
131 $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/unistd-safer.m4 \
132 $(top_srcdir)/m4/unistd_h.m4 $(top_srcdir)/m4/unlink.m4 \
121133 $(top_srcdir)/m4/utimbuf.m4 $(top_srcdir)/m4/utimens.m4 \
122134 $(top_srcdir)/m4/utimes.m4 $(top_srcdir)/m4/vasnprintf.m4 \
123 $(top_srcdir)/m4/vfprintf-posix.m4 $(top_srcdir)/m4/wchar.m4 \
124 $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wctype.m4 \
125 $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \
135 $(top_srcdir)/m4/vfprintf-posix.m4 \
136 $(top_srcdir)/m4/warn-on-use.m4 $(top_srcdir)/m4/warnings.m4 \
137 $(top_srcdir)/m4/wchar.m4 $(top_srcdir)/m4/wchar_t.m4 \
138 $(top_srcdir)/m4/wctype.m4 $(top_srcdir)/m4/wint_t.m4 \
139 $(top_srcdir)/m4/xalloc.m4 $(top_srcdir)/m4/xgetcwd.m4 \
126140 $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/yesno.m4 \
127141 $(top_srcdir)/configure.ac
128142 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
144158 am__DEPENDENCIES_1 =
145159 am_libgzip_a_OBJECTS = close-hook.$(OBJEXT) freadahead.$(OBJEXT) \
146160 freading.$(OBJEXT) fseterr.$(OBJEXT) localcharset.$(OBJEXT) \
147 printf-frexp.$(OBJEXT) printf-frexpl.$(OBJEXT) \
148 xalloc-die.$(OBJEXT)
161 openat-die.$(OBJEXT) printf-frexp.$(OBJEXT) \
162 printf-frexpl.$(OBJEXT) xalloc-die.$(OBJEXT)
149163 libgzip_a_OBJECTS = $(am_libgzip_a_OBJECTS)
150164 LTLIBRARIES = $(noinst_LTLIBRARIES)
151165 DEFAULT_INCLUDES = -I.@am__isrc@
247261 EOVERFLOW_VALUE = @EOVERFLOW_VALUE@
248262 ERRNO_H = @ERRNO_H@
249263 EXEEXT = @EXEEXT@
250 FCNTL_H = @FCNTL_H@
251264 FLOAT_H = @FLOAT_H@
252265 GETOPT_H = @GETOPT_H@
253266 GLIBC21 = @GLIBC21@
267 GNULIB_ACOSL = @GNULIB_ACOSL@
268 GNULIB_ALPHASORT = @GNULIB_ALPHASORT@
269 GNULIB_ASINL = @GNULIB_ASINL@
270 GNULIB_ATANL = @GNULIB_ATANL@
254271 GNULIB_ATOLL = @GNULIB_ATOLL@
255272 GNULIB_BTOWC = @GNULIB_BTOWC@
256273 GNULIB_CALLOC_POSIX = @GNULIB_CALLOC_POSIX@
259276 GNULIB_CEILL = @GNULIB_CEILL@
260277 GNULIB_CHOWN = @GNULIB_CHOWN@
261278 GNULIB_CLOSE = @GNULIB_CLOSE@
279 GNULIB_COSL = @GNULIB_COSL@
280 GNULIB_DIRFD = @GNULIB_DIRFD@
262281 GNULIB_DPRINTF = @GNULIB_DPRINTF@
263282 GNULIB_DUP2 = @GNULIB_DUP2@
264283 GNULIB_DUP3 = @GNULIB_DUP3@
265284 GNULIB_ENVIRON = @GNULIB_ENVIRON@
266285 GNULIB_EUIDACCESS = @GNULIB_EUIDACCESS@
286 GNULIB_EXPL = @GNULIB_EXPL@
267287 GNULIB_FACCESSAT = @GNULIB_FACCESSAT@
268288 GNULIB_FCHDIR = @GNULIB_FCHDIR@
269289 GNULIB_FCHMODAT = @GNULIB_FCHMODAT@
270290 GNULIB_FCHOWNAT = @GNULIB_FCHOWNAT@
271291 GNULIB_FCLOSE = @GNULIB_FCLOSE@
292 GNULIB_FCNTL = @GNULIB_FCNTL@
293 GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
272294 GNULIB_FFLUSH = @GNULIB_FFLUSH@
273295 GNULIB_FLOORF = @GNULIB_FLOORF@
274296 GNULIB_FLOORL = @GNULIB_FLOORL@
294316 GNULIB_GETDELIM = @GNULIB_GETDELIM@
295317 GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
296318 GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
319 GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
297320 GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
298321 GNULIB_GETLINE = @GNULIB_GETLINE@
299322 GNULIB_GETLOADAVG = @GNULIB_GETLOADAVG@
323 GNULIB_GETLOGIN = @GNULIB_GETLOGIN@
300324 GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
301325 GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
302326 GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
312336 GNULIB_LDEXPL = @GNULIB_LDEXPL@
313337 GNULIB_LINK = @GNULIB_LINK@
314338 GNULIB_LINKAT = @GNULIB_LINKAT@
339 GNULIB_LOGL = @GNULIB_LOGL@
315340 GNULIB_LSEEK = @GNULIB_LSEEK@
316341 GNULIB_LSTAT = @GNULIB_LSTAT@
317342 GNULIB_MALLOC_POSIX = @GNULIB_MALLOC_POSIX@
318 GNULIB_MATHL = @GNULIB_MATHL@
319343 GNULIB_MBRLEN = @GNULIB_MBRLEN@
320344 GNULIB_MBRTOWC = @GNULIB_MBRTOWC@
321345 GNULIB_MBSCASECMP = @GNULIB_MBSCASECMP@
341365 GNULIB_MEMRCHR = @GNULIB_MEMRCHR@
342366 GNULIB_MKDIRAT = @GNULIB_MKDIRAT@
343367 GNULIB_MKDTEMP = @GNULIB_MKDTEMP@
368 GNULIB_MKFIFO = @GNULIB_MKFIFO@
344369 GNULIB_MKFIFOAT = @GNULIB_MKFIFOAT@
370 GNULIB_MKNOD = @GNULIB_MKNOD@
345371 GNULIB_MKNODAT = @GNULIB_MKNODAT@
346372 GNULIB_MKOSTEMP = @GNULIB_MKOSTEMP@
373 GNULIB_MKOSTEMPS = @GNULIB_MKOSTEMPS@
347374 GNULIB_MKSTEMP = @GNULIB_MKSTEMP@
375 GNULIB_MKSTEMPS = @GNULIB_MKSTEMPS@
348376 GNULIB_OBSTACK_PRINTF = @GNULIB_OBSTACK_PRINTF@
349377 GNULIB_OBSTACK_PRINTF_POSIX = @GNULIB_OBSTACK_PRINTF_POSIX@
350378 GNULIB_OPEN = @GNULIB_OPEN@
352380 GNULIB_PERROR = @GNULIB_PERROR@
353381 GNULIB_PIPE2 = @GNULIB_PIPE2@
354382 GNULIB_POPEN = @GNULIB_POPEN@
383 GNULIB_PREAD = @GNULIB_PREAD@
355384 GNULIB_PRINTF = @GNULIB_PRINTF@
356385 GNULIB_PRINTF_POSIX = @GNULIB_PRINTF_POSIX@
357386 GNULIB_PUTC = @GNULIB_PUTC@
372401 GNULIB_ROUNDF = @GNULIB_ROUNDF@
373402 GNULIB_ROUNDL = @GNULIB_ROUNDL@
374403 GNULIB_RPMATCH = @GNULIB_RPMATCH@
404 GNULIB_SCANDIR = @GNULIB_SCANDIR@
375405 GNULIB_SETENV = @GNULIB_SETENV@
376406 GNULIB_SIGNBIT = @GNULIB_SIGNBIT@
407 GNULIB_SINL = @GNULIB_SINL@
377408 GNULIB_SLEEP = @GNULIB_SLEEP@
378409 GNULIB_SNPRINTF = @GNULIB_SNPRINTF@
379410 GNULIB_SPRINTF_POSIX = @GNULIB_SPRINTF_POSIX@
411 GNULIB_SQRTL = @GNULIB_SQRTL@
380412 GNULIB_STAT = @GNULIB_STAT@
381413 GNULIB_STDIO_H_SIGPIPE = @GNULIB_STDIO_H_SIGPIPE@
382414 GNULIB_STPCPY = @GNULIB_STPCPY@
398430 GNULIB_STRVERSCMP = @GNULIB_STRVERSCMP@
399431 GNULIB_SYMLINK = @GNULIB_SYMLINK@
400432 GNULIB_SYMLINKAT = @GNULIB_SYMLINKAT@
433 GNULIB_TANL = @GNULIB_TANL@
401434 GNULIB_TRUNC = @GNULIB_TRUNC@
402435 GNULIB_TRUNCF = @GNULIB_TRUNCF@
403436 GNULIB_TRUNCL = @GNULIB_TRUNCL@
406439 GNULIB_UNLINK = @GNULIB_UNLINK@
407440 GNULIB_UNLINKAT = @GNULIB_UNLINKAT@
408441 GNULIB_UNSETENV = @GNULIB_UNSETENV@
442 GNULIB_USLEEP = @GNULIB_USLEEP@
409443 GNULIB_UTIMENSAT = @GNULIB_UTIMENSAT@
410444 GNULIB_VASPRINTF = @GNULIB_VASPRINTF@
411445 GNULIB_VDPRINTF = @GNULIB_VDPRINTF@
415449 GNULIB_VPRINTF_POSIX = @GNULIB_VPRINTF_POSIX@
416450 GNULIB_VSNPRINTF = @GNULIB_VSNPRINTF@
417451 GNULIB_VSPRINTF_POSIX = @GNULIB_VSPRINTF_POSIX@
452 GNULIB_WARN_CFLAGS = @GNULIB_WARN_CFLAGS@
418453 GNULIB_WCRTOMB = @GNULIB_WCRTOMB@
419454 GNULIB_WCSNRTOMBS = @GNULIB_WCSNRTOMBS@
420455 GNULIB_WCSRTOMBS = @GNULIB_WCSRTOMBS@
422457 GNULIB_WCWIDTH = @GNULIB_WCWIDTH@
423458 GNULIB_WRITE = @GNULIB_WRITE@
424459 GREP = @GREP@
460 HAVE_ACOSL = @HAVE_ACOSL@
461 HAVE_ALPHASORT = @HAVE_ALPHASORT@
462 HAVE_ASINL = @HAVE_ASINL@
463 HAVE_ATANL = @HAVE_ATANL@
425464 HAVE_ATOLL = @HAVE_ATOLL@
426465 HAVE_BTOWC = @HAVE_BTOWC@
427466 HAVE_CALLOC_POSIX = @HAVE_CALLOC_POSIX@
428467 HAVE_CANONICALIZE_FILE_NAME = @HAVE_CANONICALIZE_FILE_NAME@
468 HAVE_CHOWN = @HAVE_CHOWN@
469 HAVE_COSL = @HAVE_COSL@
429470 HAVE_DECL_ACOSL = @HAVE_DECL_ACOSL@
430471 HAVE_DECL_ASINL = @HAVE_DECL_ASINL@
431472 HAVE_DECL_ATANL = @HAVE_DECL_ATANL@
432473 HAVE_DECL_COSL = @HAVE_DECL_COSL@
474 HAVE_DECL_DIRFD = @HAVE_DECL_DIRFD@
433475 HAVE_DECL_ENVIRON = @HAVE_DECL_ENVIRON@
434476 HAVE_DECL_EXPL = @HAVE_DECL_EXPL@
435477 HAVE_DECL_FPURGE = @HAVE_DECL_FPURGE@
462504 HAVE_DUP2 = @HAVE_DUP2@
463505 HAVE_DUP3 = @HAVE_DUP3@
464506 HAVE_EUIDACCESS = @HAVE_EUIDACCESS@
507 HAVE_EXPL = @HAVE_EXPL@
465508 HAVE_FACCESSAT = @HAVE_FACCESSAT@
466509 HAVE_FCHMODAT = @HAVE_FCHMODAT@
467510 HAVE_FCHOWNAT = @HAVE_FCHOWNAT@
468 HAVE_FSEEKO = @HAVE_FSEEKO@
511 HAVE_FCNTL = @HAVE_FCNTL@
512 HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
469513 HAVE_FSTATAT = @HAVE_FSTATAT@
470514 HAVE_FSYNC = @HAVE_FSYNC@
471 HAVE_FTELLO = @HAVE_FTELLO@
472515 HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
473516 HAVE_FUTIMENS = @HAVE_FUTIMENS@
474517 HAVE_GETDOMAINNAME = @HAVE_GETDOMAINNAME@
475518 HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
519 HAVE_GETGROUPS = @HAVE_GETGROUPS@
476520 HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
521 HAVE_GETLOGIN = @HAVE_GETLOGIN@
477522 HAVE_GETOPT_H = @HAVE_GETOPT_H@
478523 HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
479524 HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
484529 HAVE_ISNANL = @HAVE_ISNANL@
485530 HAVE_ISWCNTRL = @HAVE_ISWCNTRL@
486531 HAVE_LCHMOD = @HAVE_LCHMOD@
532 HAVE_LCHOWN = @HAVE_LCHOWN@
487533 HAVE_LINK = @HAVE_LINK@
488534 HAVE_LINKAT = @HAVE_LINKAT@
535 HAVE_LOGL = @HAVE_LOGL@
489536 HAVE_LONG_LONG_INT = @HAVE_LONG_LONG_INT@
490537 HAVE_LSTAT = @HAVE_LSTAT@
491538 HAVE_MALLOC_POSIX = @HAVE_MALLOC_POSIX@
492539 HAVE_MBRLEN = @HAVE_MBRLEN@
493540 HAVE_MBRTOWC = @HAVE_MBRTOWC@
494541 HAVE_MBSINIT = @HAVE_MBSINIT@
542 HAVE_MBSLEN = @HAVE_MBSLEN@
495543 HAVE_MBSNRTOWCS = @HAVE_MBSNRTOWCS@
496544 HAVE_MBSRTOWCS = @HAVE_MBSRTOWCS@
497545 HAVE_MEMPCPY = @HAVE_MEMPCPY@
498546 HAVE_MKDIRAT = @HAVE_MKDIRAT@
499547 HAVE_MKDTEMP = @HAVE_MKDTEMP@
548 HAVE_MKFIFO = @HAVE_MKFIFO@
500549 HAVE_MKFIFOAT = @HAVE_MKFIFOAT@
550 HAVE_MKNOD = @HAVE_MKNOD@
501551 HAVE_MKNODAT = @HAVE_MKNODAT@
502552 HAVE_MKOSTEMP = @HAVE_MKOSTEMP@
553 HAVE_MKOSTEMPS = @HAVE_MKOSTEMPS@
554 HAVE_MKSTEMPS = @HAVE_MKSTEMPS@
503555 HAVE_OPENAT = @HAVE_OPENAT@
504556 HAVE_OS_H = @HAVE_OS_H@
505557 HAVE_PIPE2 = @HAVE_PIPE2@
558 HAVE_PREAD = @HAVE_PREAD@
506559 HAVE_RANDOM_H = @HAVE_RANDOM_H@
507560 HAVE_RANDOM_R = @HAVE_RANDOM_R@
508561 HAVE_RAWMEMCHR = @HAVE_RAWMEMCHR@
512565 HAVE_REALPATH = @HAVE_REALPATH@
513566 HAVE_RENAMEAT = @HAVE_RENAMEAT@
514567 HAVE_RPMATCH = @HAVE_RPMATCH@
568 HAVE_SCANDIR = @HAVE_SCANDIR@
515569 HAVE_SETENV = @HAVE_SETENV@
516570 HAVE_SIGNED_SIG_ATOMIC_T = @HAVE_SIGNED_SIG_ATOMIC_T@
517571 HAVE_SIGNED_WCHAR_T = @HAVE_SIGNED_WCHAR_T@
518572 HAVE_SIGNED_WINT_T = @HAVE_SIGNED_WINT_T@
573 HAVE_SINL = @HAVE_SINL@
519574 HAVE_SLEEP = @HAVE_SLEEP@
575 HAVE_SQRTL = @HAVE_SQRTL@
520576 HAVE_STDINT_H = @HAVE_STDINT_H@
521577 HAVE_STPCPY = @HAVE_STPCPY@
522578 HAVE_STPNCPY = @HAVE_STPNCPY@
538594 HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
539595 HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
540596 HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
597 HAVE_TANL = @HAVE_TANL@
541598 HAVE_UNISTD_H = @HAVE_UNISTD_H@
542599 HAVE_UNLINKAT = @HAVE_UNLINKAT@
543600 HAVE_UNSETENV = @HAVE_UNSETENV@
544601 HAVE_UNSIGNED_LONG_LONG_INT = @HAVE_UNSIGNED_LONG_LONG_INT@
602 HAVE_USLEEP = @HAVE_USLEEP@
545603 HAVE_UTIMENSAT = @HAVE_UTIMENSAT@
546604 HAVE_VASPRINTF = @HAVE_VASPRINTF@
547605 HAVE_VDPRINTF = @HAVE_VDPRINTF@
576634 LTLIBOBJS = @LTLIBOBJS@
577635 MAKEINFO = @MAKEINFO@
578636 MKDIR_P = @MKDIR_P@
637 NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = @NEXT_AS_FIRST_DIRECTIVE_DIRENT_H@
579638 NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = @NEXT_AS_FIRST_DIRECTIVE_ERRNO_H@
580639 NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = @NEXT_AS_FIRST_DIRECTIVE_FCNTL_H@
581640 NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = @NEXT_AS_FIRST_DIRECTIVE_FLOAT_H@
592651 NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = @NEXT_AS_FIRST_DIRECTIVE_UNISTD_H@
593652 NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = @NEXT_AS_FIRST_DIRECTIVE_WCHAR_H@
594653 NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H = @NEXT_AS_FIRST_DIRECTIVE_WCTYPE_H@
654 NEXT_DIRENT_H = @NEXT_DIRENT_H@
595655 NEXT_ERRNO_H = @NEXT_ERRNO_H@
596656 NEXT_FCNTL_H = @NEXT_FCNTL_H@
597657 NEXT_FLOAT_H = @NEXT_FLOAT_H@
627687 REPLACE_CEILL = @REPLACE_CEILL@
628688 REPLACE_CHOWN = @REPLACE_CHOWN@
629689 REPLACE_CLOSE = @REPLACE_CLOSE@
690 REPLACE_CLOSEDIR = @REPLACE_CLOSEDIR@
630691 REPLACE_DPRINTF = @REPLACE_DPRINTF@
631692 REPLACE_DUP = @REPLACE_DUP@
632693 REPLACE_DUP2 = @REPLACE_DUP2@
633694 REPLACE_FCHDIR = @REPLACE_FCHDIR@
634695 REPLACE_FCHOWNAT = @REPLACE_FCHOWNAT@
635696 REPLACE_FCLOSE = @REPLACE_FCLOSE@
697 REPLACE_FCNTL = @REPLACE_FCNTL@
698 REPLACE_FDOPENDIR = @REPLACE_FDOPENDIR@
636699 REPLACE_FFLUSH = @REPLACE_FFLUSH@
637700 REPLACE_FLOORF = @REPLACE_FLOORF@
638701 REPLACE_FLOORL = @REPLACE_FLOORL@
650713 REPLACE_FTELLO = @REPLACE_FTELLO@
651714 REPLACE_FUTIMENS = @REPLACE_FUTIMENS@
652715 REPLACE_GETCWD = @REPLACE_GETCWD@
716 REPLACE_GETGROUPS = @REPLACE_GETGROUPS@
653717 REPLACE_GETLINE = @REPLACE_GETLINE@
654718 REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
655719 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
674738 REPLACE_MEMCHR = @REPLACE_MEMCHR@
675739 REPLACE_MEMMEM = @REPLACE_MEMMEM@
676740 REPLACE_MKDIR = @REPLACE_MKDIR@
741 REPLACE_MKFIFO = @REPLACE_MKFIFO@
742 REPLACE_MKNOD = @REPLACE_MKNOD@
677743 REPLACE_MKSTEMP = @REPLACE_MKSTEMP@
678744 REPLACE_MKTIME = @REPLACE_MKTIME@
679745 REPLACE_NAN = @REPLACE_NAN@
682748 REPLACE_OBSTACK_PRINTF = @REPLACE_OBSTACK_PRINTF@
683749 REPLACE_OPEN = @REPLACE_OPEN@
684750 REPLACE_OPENAT = @REPLACE_OPENAT@
751 REPLACE_OPENDIR = @REPLACE_OPENDIR@
685752 REPLACE_PERROR = @REPLACE_PERROR@
686753 REPLACE_POPEN = @REPLACE_POPEN@
754 REPLACE_PREAD = @REPLACE_PREAD@
687755 REPLACE_PRINTF = @REPLACE_PRINTF@
688756 REPLACE_PUTENV = @REPLACE_PUTENV@
689757 REPLACE_READLINK = @REPLACE_READLINK@
695763 REPLACE_ROUND = @REPLACE_ROUND@
696764 REPLACE_ROUNDF = @REPLACE_ROUNDF@
697765 REPLACE_ROUNDL = @REPLACE_ROUNDL@
766 REPLACE_SETENV = @REPLACE_SETENV@
698767 REPLACE_SIGNBIT = @REPLACE_SIGNBIT@
699768 REPLACE_SIGNBIT_USING_GCC = @REPLACE_SIGNBIT_USING_GCC@
769 REPLACE_SLEEP = @REPLACE_SLEEP@
700770 REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
701771 REPLACE_SPRINTF = @REPLACE_SPRINTF@
702772 REPLACE_STAT = @REPLACE_STAT@
715785 REPLACE_TRUNCL = @REPLACE_TRUNCL@
716786 REPLACE_UNLINK = @REPLACE_UNLINK@
717787 REPLACE_UNLINKAT = @REPLACE_UNLINKAT@
788 REPLACE_UNSETENV = @REPLACE_UNSETENV@
789 REPLACE_USLEEP = @REPLACE_USLEEP@
718790 REPLACE_UTIMENSAT = @REPLACE_UTIMENSAT@
719791 REPLACE_VASPRINTF = @REPLACE_VASPRINTF@
720792 REPLACE_VDPRINTF = @REPLACE_VDPRINTF@
743815 UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
744816 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
745817 VERSION = @VERSION@
746 VOID_UNSETENV = @VOID_UNSETENV@
747 WCHAR_H = @WCHAR_H@
818 WARN_CFLAGS = @WARN_CFLAGS@
748819 WCHAR_T_SUFFIX = @WCHAR_T_SUFFIX@
749820 WCTYPE_H = @WCTYPE_H@
821 WERROR_CFLAGS = @WERROR_CFLAGS@
750822 WINT_T_SUFFIX = @WINT_T_SUFFIX@
751823 abs_builddir = @abs_builddir@
752824 abs_srcdir = @abs_srcdir@
815887 # http://www.opengroup.org/susv3/utilities/make.html
816888 # for the 2004 POSIX specification]
817889 #endif
818 EXTRA_DIST = alloca.in.h $(top_srcdir)/build-aux/announce-gen calloc.c \
819 calloc.c close.c close-hook.h close-stream.c close-stream.h \
820 closein.c closein.h closeout.c closeout.h dup2.c errno.in.h \
821 error.c error.h exitfail.c exitfail.h fclose.c fcntl.in.h \
822 creat-safer.c fcntl--.h fcntl-safer.h open-safer.c fflush.c \
890 EXTRA_DIST = alloca.in.h $(top_srcdir)/build-aux/announce-gen \
891 $(top_srcdir)/build-aux/arg-nonnull.h calloc.c calloc.c \
892 chdir-long.c chdir-long.h chown.c fchown-stub.c close.c \
893 close-hook.h close-stream.c close-stream.h closein.c closein.h \
894 closeout.c closeout.h dirent.in.h dirfd.c basename-lgpl.c \
895 dirname-lgpl.c dirname.h stripslash.c dup2.c errno.in.h \
896 error.c error.h exitfail.c exitfail.h fchdir.c fclose.c \
897 fcntl.c fcntl.in.h creat-safer.c fcntl--.h fcntl-safer.h \
898 open-safer.c fdopendir.c openat-priv.h openat-proc.c fflush.c \
823899 stdio-impl.h float.in.h fpending.c fpending.h fprintf.c \
824900 fpucw.h fpurge.c stdio-impl.h freadahead.h stdio-impl.h \
825901 freading.h stdio-impl.h frexp.c frexp.c frexpl.c fseeko.c \
826902 stdio-impl.h fseterr.h stdio-impl.h ftello.c \
827 $(top_srcdir)/build-aux/gendocs.sh getopt.c getopt.in.h \
828 getopt1.c getopt_int.h getpagesize.c gettime.c gettimeofday.c \
903 $(top_srcdir)/build-aux/gendocs.sh getcwd.c getopt.c \
904 getopt.in.h getopt1.c getopt_int.h gettime.c gettimeofday.c \
829905 $(top_srcdir)/build-aux/git-version-gen \
830906 $(top_srcdir)/build-aux/gitlog-to-changelog \
831907 $(top_srcdir)/build-aux/gnu-web-doc-update \
832908 $(top_srcdir)/GNUmakefile $(top_srcdir)/build-aux/gnupload \
833909 intprops.h float+.h isnan.c isnand-nolibm.h isnand.c float+.h \
834910 isnan.c isnanf-nolibm.h isnanf.c float+.h isnan.c \
835 isnanl-nolibm.h isnanl.c \
911 isnanl-nolibm.h isnanl.c lchown.c \
836912 $(top_srcdir)/build-aux/link-warning.h config.charset \
837913 ref-add.sin ref-del.sin lseek.c lstat.c $(top_srcdir)/maint.mk \
838914 malloc.c malloc.c math.in.h mbrtowc.c mbsinit.c memchr.c \
839 memchr.valgrind open.c perror.c printf-frexp.h printf-frexp.c \
840 printf-frexpl.h printf.c quotearg.c quotearg.h realloc.c \
841 realloc.c float+.h signbitd.c signbitf.c signbitl.c stat.c \
842 stat-time.h stdbool.in.h stddef.in.h stdint.in.h stdio-write.c \
843 stdio.in.h stdlib.in.h streq.h strerror.c string.in.h \
844 sys_stat.in.h sys_time.in.h time.in.h timespec.h unistd.in.h \
845 dup-safer.c fd-safer.c pipe-safer.c unistd--.h unistd-safer.h \
915 memchr.valgrind mempcpy.c memrchr.c mkdir.c open.c at-func.c \
916 fchmodat.c fchownat.c fstatat.c mkdirat.c openat-priv.h \
917 openat-proc.c openat.c openat.h unlinkat.c perror.c \
918 printf-frexp.h printf-frexp.c printf-frexpl.h printf.c \
919 quotearg.c quotearg.h realloc.c realloc.c rmdir.c same-inode.h \
920 save-cwd.c save-cwd.h float+.h signbitd.c signbitf.c \
921 signbitl.c stat.c stat-time.h stdbool.in.h stddef.in.h \
922 stdint.in.h stdio-write.c stdio.in.h stdlib.in.h strdup.c \
923 streq.h strerror.c string.in.h sys_stat.in.h sys_time.in.h \
924 time.in.h timespec.h unistd.in.h dup-safer.c fd-safer.c \
925 pipe-safer.c unistd--.h unistd-safer.h unlink.c \
846926 $(top_srcdir)/build-aux/update-copyright \
847927 $(top_srcdir)/build-aux/useless-if-before-free utimens.c \
848928 utimens.h asnprintf.c float+.h printf-args.c printf-args.h \
849929 printf-parse.c printf-parse.h vasnprintf.c vasnprintf.h \
850 $(top_srcdir)/build-aux/vc-list-files vfprintf.c wchar.in.h \
851 wctype.in.h xalloc.h xmalloc.c yesno.c yesno.h
852 BUILT_SOURCES = $(ALLOCA_H) configmake.h $(ERRNO_H) $(FCNTL_H) \
853 $(FLOAT_H) $(GETOPT_H) math.h $(STDBOOL_H) $(STDDEF_H) \
854 $(STDINT_H) stdio.h stdlib.h string.h sys/stat.h $(SYS_TIME_H) \
855 time.h unistd.h $(WCHAR_H) $(WCTYPE_H)
930 $(top_srcdir)/build-aux/vc-list-files vfprintf.c \
931 $(top_srcdir)/build-aux/warn-on-use.h wchar.in.h wctype.in.h \
932 xalloc.h xmalloc.c xgetcwd.c xgetcwd.h yesno.c yesno.h
933
934 # The BUILT_SOURCES created by this Makefile snippet are not used via #include
935 # statements but through direct file reference. Therefore this snippet must be
936 # present in all Makefile.am that need it. This is ensured by the applicability
937 # 'all' defined above.
938
939 # The BUILT_SOURCES created by this Makefile snippet are not used via #include
940 # statements but through direct file reference. Therefore this snippet must be
941 # present in all Makefile.am that need it. This is ensured by the applicability
942 # 'all' defined above.
943 BUILT_SOURCES = $(ALLOCA_H) arg-nonnull.h configmake.h dirent.h \
944 $(ERRNO_H) fcntl.h $(FLOAT_H) $(GETOPT_H) link-warning.h \
945 math.h $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h stdlib.h \
946 string.h sys/stat.h $(SYS_TIME_H) time.h unistd.h \
947 warn-on-use.h wchar.h $(WCTYPE_H)
856948 SUFFIXES = .sed .sin
857 MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t errno.h \
858 errno.h-t fcntl.h fcntl.h-t float.h float.h-t getopt.h \
859 getopt.h-t math.h math.h-t stdbool.h stdbool.h-t stddef.h \
860 stddef.h-t stdint.h stdint.h-t stdio.h stdio.h-t stdlib.h \
861 stdlib.h-t string.h string.h-t sys/stat.h sys/stat.h-t \
862 sys/time.h sys/time.h-t time.h time.h-t unistd.h unistd.h-t \
863 wchar.h wchar.h-t wctype.h wctype.h-t _match.S _match.i \
864 match_.s
949 MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arg-nonnull.h \
950 arg-nonnull.h-t dirent.h dirent.h-t errno.h errno.h-t fcntl.h \
951 fcntl.h-t float.h float.h-t getopt.h getopt.h-t link-warning.h \
952 link-warning.h-t math.h math.h-t stdbool.h stdbool.h-t \
953 stddef.h stddef.h-t stdint.h stdint.h-t stdio.h stdio.h-t \
954 stdlib.h stdlib.h-t string.h string.h-t sys/stat.h \
955 sys/stat.h-t sys/time.h sys/time.h-t time.h time.h-t unistd.h \
956 unistd.h-t warn-on-use.h warn-on-use.h-t wchar.h wchar.h-t \
957 wctype.h wctype.h-t _match.S _match.i match_.s
865958 MOSTLYCLEANDIRS = sys
866959 CLEANFILES = configmake.h configmake.h-t charset.alias ref-add.sed \
867960 ref-del.sed
868961 DISTCLEANFILES =
869962 MAINTAINERCLEANFILES =
870963 AM_CPPFLAGS =
871 AM_CFLAGS =
964 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
872965 libgzip_a_SOURCES = close-hook.c freadahead.c freading.c fseterr.c \
873 gettext.h localcharset.h localcharset.c printf-frexp.c \
874 printf-frexpl.c size_max.h verify.h xalloc-die.c xsize.h
966 gettext.h ignore-value.h localcharset.h localcharset.c \
967 openat-die.c printf-frexp.c printf-frexpl.c size_max.h \
968 verify.h xalloc-die.c xsize.h
875969 libgzip_a_LIBADD = $(gl_LIBOBJS) $(LIBOBJS)
876970 libgzip_a_DEPENDENCIES = $(gl_LIBOBJS) $(LIBOBJS)
877 EXTRA_libgzip_a_SOURCES = calloc.c calloc.c close.c close-stream.c \
878 closein.c closeout.c dup2.c error.c exitfail.c fclose.c \
879 creat-safer.c open-safer.c fflush.c fpending.c fprintf.c \
880 fpurge.c frexp.c frexp.c frexpl.c fseeko.c ftello.c getopt.c \
881 getopt1.c getpagesize.c gettime.c gettimeofday.c isnan.c \
882 isnand.c isnan.c isnanf.c isnan.c isnanl.c lseek.c lstat.c \
883 malloc.c malloc.c mbrtowc.c mbsinit.c memchr.c open.c perror.c \
884 printf-frexp.c printf.c quotearg.c realloc.c realloc.c \
885 signbitd.c signbitf.c signbitl.c stat.c stdio-write.c \
886 strerror.c dup-safer.c fd-safer.c pipe-safer.c utimens.c \
971 EXTRA_libgzip_a_SOURCES = calloc.c calloc.c chdir-long.c chown.c \
972 fchown-stub.c close.c close-stream.c closein.c closeout.c \
973 dirfd.c basename-lgpl.c dirname-lgpl.c stripslash.c dup2.c \
974 error.c exitfail.c fchdir.c fclose.c fcntl.c creat-safer.c \
975 open-safer.c fdopendir.c openat-proc.c fflush.c fpending.c \
976 fprintf.c fpurge.c frexp.c frexp.c frexpl.c fseeko.c ftello.c \
977 getcwd.c getopt.c getopt1.c gettime.c gettimeofday.c isnan.c \
978 isnand.c isnan.c isnanf.c isnan.c isnanl.c lchown.c lseek.c \
979 lstat.c malloc.c malloc.c mbrtowc.c mbsinit.c memchr.c \
980 mempcpy.c memrchr.c mkdir.c open.c at-func.c fchmodat.c \
981 fchownat.c fstatat.c mkdirat.c openat-proc.c openat.c \
982 unlinkat.c perror.c printf-frexp.c printf.c quotearg.c \
983 realloc.c realloc.c rmdir.c save-cwd.c signbitd.c signbitf.c \
984 signbitl.c stat.c stdio-write.c strdup.c strerror.c \
985 dup-safer.c fd-safer.c pipe-safer.c unlink.c utimens.c \
887986 asnprintf.c printf-args.c printf-parse.c vasnprintf.c \
888 vfprintf.c xmalloc.c yesno.c
889 LINK_WARNING_H = $(top_srcdir)/build-aux/link-warning.h
987 vfprintf.c xmalloc.c xgetcwd.c yesno.c
988 ARG_NONNULL_H = arg-nonnull.h
989 LINK_WARNING_H = link-warning.h
890990 charset_alias = $(DESTDIR)$(libdir)/charset.alias
891991 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
992 WARN_ON_USE_H = warn-on-use.h
892993 all: $(BUILT_SOURCES) config.h
893994 $(MAKE) $(AM_MAKEFLAGS) all-recursive
894995
9661067
9671068 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/match.Po@am__quote@
9681069 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asnprintf.Po@am__quote@
1070 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/at-func.Po@am__quote@
1071 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename-lgpl.Po@am__quote@
9691072 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/calloc.Po@am__quote@
1073 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chdir-long.Po@am__quote@
1074 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chown.Po@am__quote@
9701075 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close-hook.Po@am__quote@
9711076 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close-stream.Po@am__quote@
9721077 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/close.Po@am__quote@
9731078 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closein.Po@am__quote@
9741079 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closeout.Po@am__quote@
9751080 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/creat-safer.Po@am__quote@
1081 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfd.Po@am__quote@
1082 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirname-lgpl.Po@am__quote@
9761083 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup-safer.Po@am__quote@
9771084 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dup2.Po@am__quote@
9781085 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@
9791086 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exitfail.Po@am__quote@
1087 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchdir.Po@am__quote@
1088 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchmodat.Po@am__quote@
1089 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchown-stub.Po@am__quote@
1090 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fchownat.Po@am__quote@
9801091 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fclose.Po@am__quote@
1092 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcntl.Po@am__quote@
9811093 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer.Po@am__quote@
1094 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@
9821095 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fflush.Po@am__quote@
9831096 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpending.Po@am__quote@
9841097 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fprintf.Po@am__quote@
9891102 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frexpl.Po@am__quote@
9901103 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fseeko.Po@am__quote@
9911104 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fseterr.Po@am__quote@
1105 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatat.Po@am__quote@
9921106 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ftello.Po@am__quote@
1107 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getcwd.Po@am__quote@
9931108 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@
9941109 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@
995 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getpagesize.Po@am__quote@
9961110 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettime.Po@am__quote@
9971111 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettimeofday.Po@am__quote@
9981112 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnan.Po@am__quote@
9991113 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnand.Po@am__quote@
10001114 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnanf.Po@am__quote@
10011115 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isnanl.Po@am__quote@
1116 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lchown.Po@am__quote@
10021117 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localcharset.Po@am__quote@
10031118 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lseek.Po@am__quote@
10041119 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lstat.Po@am__quote@
10061121 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbrtowc.Po@am__quote@
10071122 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbsinit.Po@am__quote@
10081123 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memchr.Po@am__quote@
1124 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempcpy.Po@am__quote@
1125 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memrchr.Po@am__quote@
1126 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdir.Po@am__quote@
1127 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkdirat.Po@am__quote@
10091128 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open-safer.Po@am__quote@
10101129 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/open.Po@am__quote@
1130 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-die.Po@am__quote@
1131 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat-proc.Po@am__quote@
1132 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openat.Po@am__quote@
10111133 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/perror.Po@am__quote@
10121134 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe-safer.Po@am__quote@
10131135 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf-args.Po@am__quote@
10171139 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf.Po@am__quote@
10181140 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quotearg.Po@am__quote@
10191141 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/realloc.Po@am__quote@
1142 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rmdir.Po@am__quote@
1143 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/save-cwd.Po@am__quote@
10201144 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signbitd.Po@am__quote@
10211145 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signbitf.Po@am__quote@
10221146 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signbitl.Po@am__quote@
10231147 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat.Po@am__quote@
10241148 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio-write.Po@am__quote@
1149 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.Po@am__quote@
10251150 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
1151 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@
1152 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@
1153 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlinkat.Po@am__quote@
10261154 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utimens.Po@am__quote@
10271155 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vasnprintf.Po@am__quote@
10281156 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfprintf.Po@am__quote@
10291157 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xalloc-die.Po@am__quote@
1158 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetcwd.Po@am__quote@
10301159 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@
10311160 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yesno.Po@am__quote@
10321161
13951524 cat $(srcdir)/alloca.in.h; \
13961525 } > $@-t && \
13971526 mv -f $@-t $@
1527 # The arg-nonnull.h that gets inserted into generated .h files is the same as
1528 # build-aux/arg-nonnull.h, except that it has the copyright header cut off.
1529 arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h
1530 $(AM_V_GEN)rm -f $@-t $@ && \
1531 sed -n -e '/GL_ARG_NONNULL/,$$p' \
1532 < $(top_srcdir)/build-aux/arg-nonnull.h \
1533 > $@-t && \
1534 mv $@-t $@
13981535
13991536 # Retrieve values of the variables through 'configure' followed by
14001537 # 'make', not directly through 'configure', so that a user who
14501587 rm -f $@; mv $@-t $@; \
14511588 fi
14521589
1590 # We need the following in order to create <dirent.h> when the system
1591 # doesn't have one that works with the given compiler.
1592 dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
1593 $(AM_V_GEN)rm -f $@-t $@ && \
1594 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1595 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1596 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1597 -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
1598 -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \
1599 -e 's|@''GNULIB_FDOPENDIR''@|$(GNULIB_FDOPENDIR)|g' \
1600 -e 's|@''GNULIB_SCANDIR''@|$(GNULIB_SCANDIR)|g' \
1601 -e 's|@''GNULIB_ALPHASORT''@|$(GNULIB_ALPHASORT)|g' \
1602 -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
1603 -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
1604 -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
1605 -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
1606 -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
1607 -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
1608 -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
1609 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1610 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1611 < $(srcdir)/dirent.in.h; \
1612 } > $@-t && \
1613 mv $@-t $@
1614
14531615 # We need the following in order to create <errno.h> when the system
14541616 # doesn't have one that is POSIX compliant.
14551617 errno.h: errno.in.h
14701632
14711633 # We need the following in order to create <fcntl.h> when the system
14721634 # doesn't have one that works with the given compiler.
1473 fcntl.h: fcntl.in.h
1635 fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
14741636 $(AM_V_GEN)rm -f $@-t $@ && \
14751637 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
14761638 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
14771639 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
14781640 -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
1641 -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \
14791642 -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
14801643 -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
1644 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
1645 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
1646 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
14811647 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
14821648 -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
1483 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
14841649 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1650 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
14851651 < $(srcdir)/fcntl.in.h; \
14861652 } > $@-t && \
14871653 mv $@-t $@
15001666
15011667 # We need the following in order to create <getopt.h> when the system
15021668 # doesn't have one that works with the given compiler.
1503 getopt.h: getopt.in.h
1669 getopt.h: getopt.in.h $(ARG_NONNULL_H)
15041670 $(AM_V_GEN)rm -f $@-t $@ && \
15051671 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
15061672 sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
15071673 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
15081674 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
15091675 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
1510 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1676 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
15111677 < $(srcdir)/getopt.in.h; \
15121678 } > $@-t && \
15131679 mv -f $@-t $@
15151681 distclean-local: clean-GNUmakefile
15161682 clean-GNUmakefile:
15171683 test x'$(VPATH)' != x && rm -f $(top_builddir)/GNUmakefile || :
1684 # The link-warning.h that gets inserted into generated .h files is the same as
1685 # build-aux/link-warning.h, except that it has the copyright header cut off.
1686 link-warning.h: $(top_srcdir)/build-aux/link-warning.h
1687 $(AM_V_GEN)rm -f $@-t $@ && \
1688 sed -n -e '/GL_LINK_WARNING/,$$p' \
1689 < $(top_srcdir)/build-aux/link-warning.h \
1690 > $@-t && \
1691 mv $@-t $@
15181692
15191693 # We need the following in order to install a simple file in $(libdir)
15201694 # which is shared with other installed packages. We use a list of referencing
15771751
15781752 # We need the following in order to create <math.h> when the system
15791753 # doesn't have one that works with the given compiler.
1580 math.h: math.in.h
1754 math.h: math.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
15811755 $(AM_V_GEN)rm -f $@-t $@ && \
15821756 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
15831757 sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
15841758 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
15851759 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
1760 -e 's|@''GNULIB_ACOSL''@|$(GNULIB_ACOSL)|g' \
1761 -e 's|@''GNULIB_ASINL''@|$(GNULIB_ASINL)|g' \
1762 -e 's|@''GNULIB_ATANL''@|$(GNULIB_ATANL)|g' \
15861763 -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \
15871764 -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \
1765 -e 's|@''GNULIB_COSL''@|$(GNULIB_COSL)|g' \
1766 -e 's|@''GNULIB_EXPL''@|$(GNULIB_EXPL)|g' \
15881767 -e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \
15891768 -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \
15901769 -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \
15961775 -e 's|@''GNULIB_ISNAND''@|$(GNULIB_ISNAND)|g' \
15971776 -e 's|@''GNULIB_ISNANL''@|$(GNULIB_ISNANL)|g' \
15981777 -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \
1599 -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \
1778 -e 's|@''GNULIB_LOGL''@|$(GNULIB_LOGL)|g' \
16001779 -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \
16011780 -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \
16021781 -e 's|@''GNULIB_ROUNDL''@|$(GNULIB_ROUNDL)|g' \
16031782 -e 's|@''GNULIB_SIGNBIT''@|$(GNULIB_SIGNBIT)|g' \
1783 -e 's|@''GNULIB_SINL''@|$(GNULIB_SINL)|g' \
1784 -e 's|@''GNULIB_SQRTL''@|$(GNULIB_SQRTL)|g' \
1785 -e 's|@''GNULIB_TANL''@|$(GNULIB_TANL)|g' \
16041786 -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \
16051787 -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \
16061788 -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \
1789 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
1790 -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
1791 -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
1792 -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
1793 -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
16071794 -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
16081795 -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
16091796 -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
1797 -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \
1798 -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
1799 -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \
1800 -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
16101801 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
16111802 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
16121803 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
16391830 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
16401831 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
16411832 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1833 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1834 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
16421835 < $(srcdir)/math.in.h; \
16431836 } > $@-t && \
16441837 mv $@-t $@
17011894
17021895 # We need the following in order to create <stdio.h> when the system
17031896 # doesn't have one that works with the given compiler.
1704 stdio.h: stdio.in.h
1897 stdio.h: stdio.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
17051898 $(AM_V_GEN)rm -f $@-t $@ && \
17061899 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
17071900 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
17471940 -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
17481941 -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
17491942 -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
1750 -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
1943 < $(srcdir)/stdio.in.h | \
1944 sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
17511945 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
17521946 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
17531947 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
17861980 -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
17871981 -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
17881982 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1789 < $(srcdir)/stdio.in.h; \
1983 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1984 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
17901985 } > $@-t && \
17911986 mv $@-t $@
17921987
17931988 # We need the following in order to create <stdlib.h> when the system
17941989 # doesn't have one that works with the given compiler.
1795 stdlib.h: stdlib.in.h
1990 stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
17961991 $(AM_V_GEN)rm -f $@-t $@ && \
17971992 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
17981993 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
18062001 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
18072002 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
18082003 -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
2004 -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
18092005 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
2006 -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
18102007 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
18112008 -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
18122009 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
18252022 -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
18262023 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
18272024 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
2025 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
2026 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
18282027 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
18292028 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
18302029 -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
18412040 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
18422041 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
18432042 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
2043 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
18442044 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
1845 -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
2045 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
18462046 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
2047 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
18472048 < $(srcdir)/stdlib.in.h; \
18482049 } > $@-t && \
18492050 mv $@-t $@
18502051
18512052 # We need the following in order to create <string.h> when the system
18522053 # doesn't have one that works with the given compiler.
1853 string.h: string.in.h
2054 string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
18542055 $(AM_V_GEN)rm -f $@-t $@ && \
18552056 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
18562057 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
18892090 -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
18902091 -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
18912092 -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
2093 < $(srcdir)/string.in.h | \
2094 sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
18922095 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
18932096 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
18942097 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
19172120 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
19182121 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
19192122 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1920 < $(srcdir)/string.in.h; \
2123 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)'; \
19212124 } > $@-t && \
19222125 mv $@-t $@
19232126
19242127 # We need the following in order to create <sys/stat.h> when the system
19252128 # has one that is incomplete.
1926 sys/stat.h: sys_stat.in.h
2129 sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
19272130 $(AM_V_at)$(MKDIR_P) sys
19282131 $(AM_V_GEN)rm -f $@-t $@ && \
19292132 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
19362139 -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
19372140 -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
19382141 -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
2142 -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \
19392143 -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \
2144 -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \
19402145 -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \
19412146 -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
19422147 -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \
19462151 -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
19472152 -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
19482153 -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
2154 -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
19492155 -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
2156 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
19502157 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
19512158 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
19522159 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
19542161 -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
19552162 -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
19562163 -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
2164 -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
2165 -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
19572166 -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
19582167 -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
19592168 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
2169 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
19602170 < $(srcdir)/sys_stat.in.h; \
19612171 } > $@-t && \
19622172 mv $@-t $@
19632173
19642174 # We need the following in order to create <sys/time.h> when the system
19652175 # doesn't have one that works with the given compiler.
1966 sys/time.h: sys_time.in.h
2176 sys/time.h: sys_time.in.h $(ARG_NONNULL_H)
19672177 $(AM_V_at)$(MKDIR_P) sys
19682178 $(AM_V_GEN)rm -f $@-t $@ && \
19692179 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
19732183 -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
19742184 -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
19752185 -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
2186 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
19762187 < $(srcdir)/sys_time.in.h; \
19772188 } > $@-t && \
19782189 mv $@-t $@
19792190
19802191 # We need the following in order to create <time.h> when the system
19812192 # doesn't have one that works with the given compiler.
1982 time.h: time.in.h
2193 time.h: time.in.h $(ARG_NONNULL_H)
19832194 $(AM_V_GEN)rm -f $@-t $@ && \
19842195 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
19852196 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
19922203 -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
19932204 -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
19942205 -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
2206 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
19952207 < $(srcdir)/time.in.h; \
19962208 } > $@-t && \
19972209 mv $@-t $@
19982210
19992211 # We need the following in order to create an empty placeholder for
20002212 # <unistd.h> when the system doesn't have one.
2001 unistd.h: unistd.in.h
2213 unistd.h: unistd.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
20022214 $(AM_V_GEN)rm -f $@-t $@ && \
20032215 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
20042216 sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
20192231 -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
20202232 -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
20212233 -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
2234 -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \
20222235 -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
2236 -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \
20232237 -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
20242238 -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
20252239 -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
20282242 -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
20292243 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
20302244 -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
2245 -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
20312246 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
20322247 -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
20332248 -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
20382253 -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
20392254 -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
20402255 -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
2256 -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \
20412257 -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
2258 < $(srcdir)/unistd.in.h | \
2259 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
20422260 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
20432261 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
20442262 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
20482266 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
20492267 -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
20502268 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
2269 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
20512270 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
2271 -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
20522272 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
20532273 -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
2274 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
20542275 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
20552276 -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
20562277 -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
2278 -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
20572279 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
20582280 -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
20592281 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
20602282 -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
20612283 -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
20622284 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
2285 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
20632286 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
20642287 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
20652288 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
20712294 -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
20722295 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
20732296 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
2297 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
20742298 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
20752299 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
20762300 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
20772301 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
20782302 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
2303 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
20792304 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
20802305 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
2306 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
20812307 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
20822308 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
20832309 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
2310 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
20842311 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
20852312 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
20862313 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
20872314 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
2088 < $(srcdir)/unistd.in.h; \
2315 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
2316 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
20892317 } > $@-t && \
20902318 mv $@-t $@
2319 # The warn-on-use.h that gets inserted into generated .h files is the same as
2320 # build-aux/warn-on-use.h, except that it has the copyright header cut off.
2321 warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h
2322 $(AM_V_GEN)rm -f $@-t $@ && \
2323 sed -n -e '/^.ifndef/,$$p' \
2324 < $(top_srcdir)/build-aux/warn-on-use.h \
2325 > $@-t && \
2326 mv $@-t $@
20912327
20922328 # We need the following in order to create <wchar.h> when the system
20932329 # version does not work standalone.
2094 wchar.h: wchar.in.h
2330 wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
20952331 $(AM_V_GEN)rm -f $@-t $@ && \
20962332 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
20972333 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
21342370 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
21352371 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
21362372 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
2373 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
21372374 < $(srcdir)/wchar.in.h; \
21382375 } > $@-t && \
21392376 mv $@-t $@
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Memory allocation on the stack.
33
4 Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
5 Foundation, Inc.
4 Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
5 Inc.
66
77 This program is free software; you can redistribute it and/or modify it
88 under the terms of the GNU General Public License as published
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Formatted output to strings.
3 Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
3 Copyright (C) 1999, 2002, 2006, 2009, 2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
0 /* Define an at-style functions like fstatat, unlinkat, fchownat, etc.
1 Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
19 #include "openat.h"
20 #include "openat-priv.h"
21 #include "save-cwd.h"
22
23 #ifdef AT_FUNC_USE_F1_COND
24 # define CALL_FUNC(F) \
25 (flag == AT_FUNC_USE_F1_COND \
26 ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \
27 : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS))
28 # define VALIDATE_FLAG(F) \
29 if (flag & ~AT_FUNC_USE_F1_COND) \
30 { \
31 errno = EINVAL; \
32 return FUNC_FAIL; \
33 }
34 #else
35 # define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS))
36 # define VALIDATE_FLAG(F) /* empty */
37 #endif
38
39 #ifdef AT_FUNC_RESULT
40 # define FUNC_RESULT AT_FUNC_RESULT
41 #else
42 # define FUNC_RESULT int
43 #endif
44
45 #ifdef AT_FUNC_FAIL
46 # define FUNC_FAIL AT_FUNC_FAIL
47 #else
48 # define FUNC_FAIL -1
49 #endif
50
51 /* Call AT_FUNC_F1 to operate on FILE, which is in the directory
52 open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value,
53 AT_FUNC_POST_FILE_PARAM_DECLS must inlude a parameter named flag;
54 call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than
55 AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT
56 or AT_FUNC_FAIL are defined. If possible, do it without changing the
57 working directory. Otherwise, resort to using save_cwd/fchdir,
58 then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd
59 fails, then give a diagnostic and exit nonzero. */
60 FUNC_RESULT
61 AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
62 {
63 /* Be careful to choose names unlikely to conflict with
64 AT_FUNC_POST_FILE_PARAM_DECLS. */
65 struct saved_cwd saved_cwd;
66 int saved_errno;
67 FUNC_RESULT err;
68
69 VALIDATE_FLAG (flag);
70
71 if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
72 return CALL_FUNC (file);
73
74 {
75 char proc_buf[OPENAT_BUFFER_SIZE];
76 char *proc_file = openat_proc_name (proc_buf, fd, file);
77 if (proc_file)
78 {
79 FUNC_RESULT proc_result = CALL_FUNC (proc_file);
80 int proc_errno = errno;
81 if (proc_file != proc_buf)
82 free (proc_file);
83 /* If the syscall succeeds, or if it fails with an unexpected
84 errno value, then return right away. Otherwise, fall through
85 and resort to using save_cwd/restore_cwd. */
86 if (FUNC_FAIL != proc_result)
87 return proc_result;
88 if (! EXPECTED_ERRNO (proc_errno))
89 {
90 errno = proc_errno;
91 return proc_result;
92 }
93 }
94 }
95
96 if (save_cwd (&saved_cwd) != 0)
97 openat_save_fail (errno);
98 if (0 <= fd && fd == saved_cwd.desc)
99 {
100 /* If saving the working directory collides with the user's
101 requested fd, then the user's fd must have been closed to
102 begin with. */
103 free_cwd (&saved_cwd);
104 errno = EBADF;
105 return FUNC_FAIL;
106 }
107
108 if (fchdir (fd) != 0)
109 {
110 saved_errno = errno;
111 free_cwd (&saved_cwd);
112 errno = saved_errno;
113 return FUNC_FAIL;
114 }
115
116 err = CALL_FUNC (file);
117 saved_errno = (err == FUNC_FAIL ? errno : 0);
118
119 if (restore_cwd (&saved_cwd) != 0)
120 openat_restore_fail (errno);
121
122 free_cwd (&saved_cwd);
123
124 if (saved_errno)
125 errno = saved_errno;
126 return err;
127 }
128 #undef CALL_FUNC
129 #undef FUNC_RESULT
130 #undef FUNC_FAIL
0 /* basename.c -- return the last element in a file name
1
2 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software
3 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 #include "dirname.h"
21
22 #include <string.h>
23
24 /* Return the address of the last file name component of NAME. If
25 NAME has no relative file name components because it is a file
26 system root, return the empty string. */
27
28 char *
29 last_component (char const *name)
30 {
31 char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
32 char const *p;
33 bool saw_slash = false;
34
35 while (ISSLASH (*base))
36 base++;
37
38 for (p = base; *p; p++)
39 {
40 if (ISSLASH (*p))
41 saw_slash = true;
42 else if (saw_slash)
43 {
44 base = p;
45 saw_slash = false;
46 }
47 }
48
49 return (char *) base;
50 }
51
52 /* Return the length of the basename NAME. Typically NAME is the
53 value returned by base_name or last_component. Act like strlen
54 (NAME), except omit all trailing slashes. */
55
56 size_t
57 base_len (char const *name)
58 {
59 size_t len;
60 size_t prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
61
62 for (len = strlen (name); 1 < len && ISSLASH (name[len - 1]); len--)
63 continue;
64
65 if (DOUBLE_SLASH_IS_DISTINCT_ROOT && len == 1
66 && ISSLASH (name[0]) && ISSLASH (name[1]) && ! name[2])
67 return 2;
68
69 if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE && prefix_len
70 && len == prefix_len && ISSLASH (name[prefix_len]))
71 return prefix_len + 1;
72
73 return len;
74 }
00 /* calloc() function that is glibc compatible.
11 This wrapper function is required at least on Tru64 UNIX 5.1 and mingw.
2 Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
2 Copyright (C) 2004-2007, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
4848 else
4949 {
5050 /* Defend against buggy calloc implementations that mishandle
51 size_t overflow. */
51 size_t overflow. */
5252 size_t bytes = n * s;
5353 if (bytes / s != n)
54 {
55 errno = ENOMEM;
56 return NULL;
57 }
54 {
55 errno = ENOMEM;
56 return NULL;
57 }
5858 }
5959 #endif
6060
0 /* provide a chdir function that tries not to fail due to ENAMETOOLONG
1 Copyright (C) 2004-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #include <config.h>
19
20 #include "chdir-long.h"
21
22 #include <assert.h>
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <stdlib.h>
26 #include <stdbool.h>
27 #include <string.h>
28 #include <stdio.h>
29
30 #ifndef PATH_MAX
31 # error "compile this file only if your system defines PATH_MAX"
32 #endif
33
34 /* The results of openat() in this file are not leaked to any
35 single-threaded code that could use stdio.
36 FIXME - if the kernel ever adds support for multi-thread safety for
37 avoiding standard fds, then we should use openat_safer. */
38
39 struct cd_buf
40 {
41 int fd;
42 };
43
44 static inline void
45 cdb_init (struct cd_buf *cdb)
46 {
47 cdb->fd = AT_FDCWD;
48 }
49
50 static inline int
51 cdb_fchdir (struct cd_buf const *cdb)
52 {
53 return fchdir (cdb->fd);
54 }
55
56 static inline void
57 cdb_free (struct cd_buf const *cdb)
58 {
59 if (0 <= cdb->fd)
60 {
61 bool close_fail = close (cdb->fd);
62 assert (! close_fail);
63 }
64 }
65
66 /* Given a file descriptor of an open directory (or AT_FDCWD), CDB->fd,
67 try to open the CDB->fd-relative directory, DIR. If the open succeeds,
68 update CDB->fd with the resulting descriptor, close the incoming file
69 descriptor, and return zero. Upon failure, return -1 and set errno. */
70 static int
71 cdb_advance_fd (struct cd_buf *cdb, char const *dir)
72 {
73 int new_fd = openat (cdb->fd, dir,
74 O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
75 if (new_fd < 0)
76 return -1;
77
78 cdb_free (cdb);
79 cdb->fd = new_fd;
80
81 return 0;
82 }
83
84 /* Return a pointer to the first non-slash in S. */
85 static inline char *
86 find_non_slash (char const *s)
87 {
88 size_t n_slash = strspn (s, "/");
89 return (char *) s + n_slash;
90 }
91
92 /* This is a function much like chdir, but without the PATH_MAX limitation
93 on the length of the directory name. A significant difference is that
94 it must be able to modify (albeit only temporarily) the directory
95 name. It handles an arbitrarily long directory name by operating
96 on manageable portions of the name. On systems without the openat
97 syscall, this means changing the working directory to more and more
98 `distant' points along the long directory name and then restoring
99 the working directory. If any of those attempts to save or restore
100 the working directory fails, this function exits nonzero.
101
102 Note that this function may still fail with errno == ENAMETOOLONG, but
103 only if the specified directory name contains a component that is long
104 enough to provoke such a failure all by itself (e.g. if the component
105 has length PATH_MAX or greater on systems that define PATH_MAX). */
106
107 int
108 chdir_long (char *dir)
109 {
110 int e = chdir (dir);
111 if (e == 0 || errno != ENAMETOOLONG)
112 return e;
113
114 {
115 size_t len = strlen (dir);
116 char *dir_end = dir + len;
117 struct cd_buf cdb;
118 size_t n_leading_slash;
119
120 cdb_init (&cdb);
121
122 /* If DIR is the empty string, then the chdir above
123 must have failed and set errno to ENOENT. */
124 assert (0 < len);
125 assert (PATH_MAX <= len);
126
127 /* Count leading slashes. */
128 n_leading_slash = strspn (dir, "/");
129
130 /* Handle any leading slashes as well as any name that matches
131 the regular expression, m!^//hostname[/]*! . Handling this
132 prefix separately usually results in a single additional
133 cdb_advance_fd call, but it's worthwhile, since it makes the
134 code in the following loop cleaner. */
135 if (n_leading_slash == 2)
136 {
137 int err;
138 /* Find next slash.
139 We already know that dir[2] is neither a slash nor '\0'. */
140 char *slash = memchr (dir + 3, '/', dir_end - (dir + 3));
141 if (slash == NULL)
142 {
143 errno = ENAMETOOLONG;
144 return -1;
145 }
146 *slash = '\0';
147 err = cdb_advance_fd (&cdb, dir);
148 *slash = '/';
149 if (err != 0)
150 goto Fail;
151 dir = find_non_slash (slash + 1);
152 }
153 else if (n_leading_slash)
154 {
155 if (cdb_advance_fd (&cdb, "/") != 0)
156 goto Fail;
157 dir += n_leading_slash;
158 }
159
160 assert (*dir != '/');
161 assert (dir <= dir_end);
162
163 while (PATH_MAX <= dir_end - dir)
164 {
165 int err;
166 /* Find a slash that is PATH_MAX or fewer bytes away from dir.
167 I.e. see if there is a slash that will give us a name of
168 length PATH_MAX-1 or less. */
169 char *slash = memrchr (dir, '/', PATH_MAX);
170 if (slash == NULL)
171 {
172 errno = ENAMETOOLONG;
173 return -1;
174 }
175
176 *slash = '\0';
177 assert (slash - dir < PATH_MAX);
178 err = cdb_advance_fd (&cdb, dir);
179 *slash = '/';
180 if (err != 0)
181 goto Fail;
182
183 dir = find_non_slash (slash + 1);
184 }
185
186 if (dir < dir_end)
187 {
188 if (cdb_advance_fd (&cdb, dir) != 0)
189 goto Fail;
190 }
191
192 if (cdb_fchdir (&cdb) != 0)
193 goto Fail;
194
195 cdb_free (&cdb);
196 return 0;
197
198 Fail:
199 {
200 int saved_errno = errno;
201 cdb_free (&cdb);
202 errno = saved_errno;
203 return -1;
204 }
205 }
206 }
207
208 #if TEST_CHDIR
209
210 # include "closeout.h"
211 # include "error.h"
212
213 char *program_name;
214
215 int
216 main (int argc, char *argv[])
217 {
218 char *line = NULL;
219 size_t n = 0;
220 int len;
221
222 program_name = argv[0];
223 atexit (close_stdout);
224
225 len = getline (&line, &n, stdin);
226 if (len < 0)
227 {
228 int saved_errno = errno;
229 if (feof (stdin))
230 exit (0);
231
232 error (EXIT_FAILURE, saved_errno,
233 "reading standard input");
234 }
235 else if (len == 0)
236 exit (0);
237
238 if (line[len-1] == '\n')
239 line[len-1] = '\0';
240
241 if (chdir_long (line) != 0)
242 error (EXIT_FAILURE, errno,
243 "chdir_long failed: %s", line);
244
245 if (argc <= 1)
246 {
247 /* Using `pwd' here makes sense only if it is a robust implementation,
248 like the one in coreutils after the 2004-04-19 changes. */
249 char const *cmd = "pwd";
250 execlp (cmd, (char *) NULL);
251 error (EXIT_FAILURE, errno, "%s", cmd);
252 }
253
254 fclose (stdin);
255 fclose (stderr);
256
257 exit (EXIT_SUCCESS);
258 }
259 #endif
260
261 /*
262 Local Variables:
263 compile-command: "gcc -DTEST_CHDIR=1 -g -O -W -Wall chdir-long.c libcoreutils.a"
264 End:
265 */
0 /* provide a chdir function that tries not to fail due to ENAMETOOLONG
1 Copyright (C) 2004-2005, 2009-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* Written by Jim Meyering. */
17
18 #include <unistd.h>
19 #include <limits.h>
20
21 #ifndef PATH_MAX
22 # ifdef MAXPATHLEN
23 # define PATH_MAX MAXPATHLEN
24 # endif
25 #endif
26
27 /* On systems without PATH_MAX, presume that chdir accepts
28 arbitrarily long directory names. */
29 #ifndef PATH_MAX
30 # define chdir_long(Dir) chdir (Dir)
31 #else
32 int chdir_long (char *dir);
33 #endif
0 /* provide consistent interface to chown for systems that don't interpret
1 an ID of -1 as meaning `don't change the corresponding ID'.
2
3 Copyright (C) 1997, 2004-2007, 2009-2010 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 /* written by Jim Meyering */
19
20 #include <config.h>
21
22 /* Specification. */
23 #include <unistd.h>
24
25 #include <errno.h>
26 #include <fcntl.h>
27 #include <stdbool.h>
28 #include <string.h>
29 #include <sys/stat.h>
30
31 #if !HAVE_CHOWN
32
33 /* Simple stub that always fails with ENOSYS, for mingw. */
34 int
35 chown (const char *file _GL_UNUSED, uid_t uid _GL_UNUSED,
36 gid_t gid _GL_UNUSED)
37 {
38 errno = ENOSYS;
39 return -1;
40 }
41
42 #else /* HAVE_CHOWN */
43
44 /* Below we refer to the system's chown(). */
45 # undef chown
46
47 /* The results of open() in this file are not used with fchdir,
48 therefore save some unnecessary work in fchdir.c. */
49 # undef open
50 # undef close
51
52 /* Provide a more-closely POSIX-conforming version of chown on
53 systems with one or both of the following problems:
54 - chown doesn't treat an ID of -1 as meaning
55 `don't change the corresponding ID'.
56 - chown doesn't dereference symlinks. */
57
58 int
59 rpl_chown (const char *file, uid_t uid, gid_t gid)
60 {
61 struct stat st;
62 bool stat_valid = false;
63 int result;
64
65 # if CHOWN_CHANGE_TIME_BUG
66 if (gid != (gid_t) -1 || uid != (uid_t) -1)
67 {
68 if (stat (file, &st))
69 return -1;
70 stat_valid = true;
71 }
72 # endif
73
74 # if CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE
75 if (gid == (gid_t) -1 || uid == (uid_t) -1)
76 {
77 /* Stat file to get id(s) that should remain unchanged. */
78 if (!stat_valid && stat (file, &st))
79 return -1;
80 if (gid == (gid_t) -1)
81 gid = st.st_gid;
82 if (uid == (uid_t) -1)
83 uid = st.st_uid;
84 }
85 # endif
86
87 # if CHOWN_MODIFIES_SYMLINK
88 {
89 /* Handle the case in which the system-supplied chown function
90 does *not* follow symlinks. Instead, it changes permissions
91 on the symlink itself. To work around that, we open the
92 file (but this can fail due to lack of read or write permission) and
93 use fchown on the resulting descriptor. */
94 int open_flags = O_NONBLOCK | O_NOCTTY;
95 int fd = open (file, O_RDONLY | open_flags);
96 if (0 <= fd
97 || (errno == EACCES
98 && 0 <= (fd = open (file, O_WRONLY | open_flags))))
99 {
100 int saved_errno;
101 bool fchown_socket_failure;
102
103 result = fchown (fd, uid, gid);
104 saved_errno = errno;
105
106 /* POSIX says fchown can fail with errno == EINVAL on sockets
107 and pipes, so fall back on chown in that case. */
108 fchown_socket_failure =
109 (result != 0 && saved_errno == EINVAL
110 && fstat (fd, &st) == 0
111 && (S_ISFIFO (st.st_mode) || S_ISSOCK (st.st_mode)));
112
113 close (fd);
114
115 if (! fchown_socket_failure)
116 {
117 errno = saved_errno;
118 return result;
119 }
120 }
121 else if (errno != EACCES)
122 return -1;
123 }
124 # endif
125
126 # if CHOWN_TRAILING_SLASH_BUG
127 if (!stat_valid)
128 {
129 size_t len = strlen (file);
130 if (len && file[len - 1] == '/' && stat (file, &st))
131 return -1;
132 }
133 # endif
134
135 result = chown (file, uid, gid);
136
137 # if CHOWN_CHANGE_TIME_BUG
138 if (result == 0 && stat_valid
139 && (uid == st.st_uid || uid == (uid_t) -1)
140 && (gid == st.st_gid || gid == (gid_t) -1))
141 {
142 /* No change in ownership, but at least one argument was not -1,
143 so we are required to update ctime. Since chown succeeded,
144 we assume that chmod will do likewise. Fortunately, on all
145 known systems where a 'no-op' chown skips the ctime update, a
146 'no-op' chmod still does the trick. */
147 result = chmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO
148 | S_ISUID | S_ISGID | S_ISVTX));
149 }
150 # endif
151
152 return result;
153 }
154
155 #endif /* HAVE_CHOWN */
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Hook for making the close() function extensible.
3 Copyright (C) 2009 Free Software Foundation, Inc.
3 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
44 Written by Bruno Haible <bruno@clisp.org>, 2009.
55
66 This program is free software: you can redistribute it and/or modify it
6767 {
6868 /* The link is already in use. */
6969 if (link->private_fn != hook)
70 abort ();
70 abort ();
7171 }
7272 }
7373
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Hook for making the close() function extensible.
3 Copyright (C) 2009 Free Software Foundation, Inc.
3 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
44
55 This program is free software: you can redistribute it and/or modify it
66 under the terms of the GNU General Public License as published
00 /* Close a stream, with nicer error checking than fclose's.
11
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2007, 2008 Free
3 Software Foundation, Inc.
2 Copyright (C) 1998-2002, 2004, 2006-2010 Free Software Foundation, Inc.
43
54 This program is free software: you can redistribute it and/or modify
65 it under the terms of the GNU General Public License as published by
7069 if (prev_fail || (fclose_fail && (some_pending || errno != EBADF)))
7170 {
7271 if (! fclose_fail)
73 errno = 0;
72 errno = 0;
7473 return EOF;
7574 }
7675
00 /* close replacement.
1 Copyright (C) 2008-2009 Free Software Foundation, Inc.
1 Copyright (C) 2008-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Close standard input, rewinding seekable stdin if necessary.
11
2 Copyright (C) 2007 Free Software Foundation, Inc.
2 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
8585 if (freadahead (stdin) > 0)
8686 {
8787 /* Only attempt flush if stdin is seekable, as fflush is entitled to
88 fail on non-seekable streams. */
88 fail on non-seekable streams. */
8989 if (fseeko (stdin, 0, SEEK_CUR) == 0 && fflush (stdin) != 0)
90 fail = true;
90 fail = true;
9191 }
9292 if (close_stream (stdin) != 0)
9393 fail = true;
9494 if (fail)
9595 {
9696 /* Report failure, but defer exit until after closing stdout,
97 since the failure report should still be flushed. */
97 since the failure report should still be flushed. */
9898 char const *close_error = _("error closing file");
9999 if (file_name)
100 error (0, errno, "%s: %s", quotearg_colon (file_name),
101 close_error);
100 error (0, errno, "%s: %s", quotearg_colon (file_name),
101 close_error);
102102 else
103 error (0, errno, "%s", close_error);
103 error (0, errno, "%s", close_error);
104104 }
105105
106106 close_stdout ();
00 /* Close standard input, rewinding seekable stdin if necessary.
11
2 Copyright (C) 2007 Free Software Foundation, Inc.
2 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
00 /* Close standard output and standard error, exiting with a diagnostic on error.
11
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 Free
3 Software Foundation, Inc.
2 Copyright (C) 1998-2002, 2004, 2006, 2008-2010 Free Software Foundation,
3 Inc.
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
110110 {
111111 char const *write_error = _("write error");
112112 if (file_name)
113 error (0, errno, "%s: %s", quotearg_colon (file_name),
114 write_error);
113 error (0, errno, "%s: %s", quotearg_colon (file_name),
114 write_error);
115115 else
116 error (0, errno, "%s", write_error);
116 error (0, errno, "%s", write_error);
117117
118118 _exit (exit_failure);
119119 }
00 /* Close standard output and standard error.
11
2 Copyright (C) 1998, 2000, 2003, 2004, 2006, 2008 Free Software Foundation,
3 Inc.
2 Copyright (C) 1998, 2000, 2003-2004, 2006, 2008-2010 Free Software
3 Foundation, Inc.
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
00 #! /bin/sh
11 # Output a system dependent table of character encoding aliases.
22 #
3 # Copyright (C) 2000-2004, 2006-2009 Free Software Foundation, Inc.
3 # Copyright (C) 2000-2004, 2006-2010 Free Software Foundation, Inc.
44 #
55 # This program is free software; you can redistribute it and/or modify
66 # it under the terms of the GNU General Public License as published by
122122 # List of references, updated during installation:
123123 echo "# Packages using this file: "
124124 case "$os" in
125 linux-gnulibc1*)
126 # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
127 # localcharset.c falls back to using the full locale name
128 # from the environment variables.
129 echo "C ASCII"
130 echo "POSIX ASCII"
131 for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
132 en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
133 en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
134 es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
135 et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
136 fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
137 it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
138 sv_FI sv_SE; do
139 echo "$l ISO-8859-1"
140 echo "$l.iso-8859-1 ISO-8859-1"
141 echo "$l.iso-8859-15 ISO-8859-15"
142 echo "$l.iso-8859-15@euro ISO-8859-15"
143 echo "$l@euro ISO-8859-15"
144 echo "$l.cp-437 CP437"
145 echo "$l.cp-850 CP850"
146 echo "$l.cp-1252 CP1252"
147 echo "$l.cp-1252@euro CP1252"
148 #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
149 echo "$l.utf-8 UTF-8"
150 echo "$l.utf-8@euro UTF-8"
151 done
152 for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
153 sl_SI sr sr_CS sr_YU; do
154 echo "$l ISO-8859-2"
155 echo "$l.iso-8859-2 ISO-8859-2"
156 echo "$l.cp-852 CP852"
157 echo "$l.cp-1250 CP1250"
158 echo "$l.utf-8 UTF-8"
159 done
160 for l in mk mk_MK ru ru_RU; do
161 echo "$l ISO-8859-5"
162 echo "$l.iso-8859-5 ISO-8859-5"
163 echo "$l.koi8-r KOI8-R"
164 echo "$l.cp-866 CP866"
165 echo "$l.cp-1251 CP1251"
166 echo "$l.utf-8 UTF-8"
167 done
168 for l in ar ar_SA; do
169 echo "$l ISO-8859-6"
170 echo "$l.iso-8859-6 ISO-8859-6"
171 echo "$l.cp-864 CP864"
172 #echo "$l.cp-868 CP868" # not a commonly used encoding
173 echo "$l.cp-1256 CP1256"
174 echo "$l.utf-8 UTF-8"
175 done
176 for l in el el_GR gr gr_GR; do
177 echo "$l ISO-8859-7"
178 echo "$l.iso-8859-7 ISO-8859-7"
179 echo "$l.cp-869 CP869"
180 echo "$l.cp-1253 CP1253"
181 echo "$l.cp-1253@euro CP1253"
182 echo "$l.utf-8 UTF-8"
183 echo "$l.utf-8@euro UTF-8"
184 done
185 for l in he he_IL iw iw_IL; do
186 echo "$l ISO-8859-8"
187 echo "$l.iso-8859-8 ISO-8859-8"
188 echo "$l.cp-862 CP862"
189 echo "$l.cp-1255 CP1255"
190 echo "$l.utf-8 UTF-8"
191 done
192 for l in tr tr_TR; do
193 echo "$l ISO-8859-9"
194 echo "$l.iso-8859-9 ISO-8859-9"
195 echo "$l.cp-857 CP857"
196 echo "$l.cp-1254 CP1254"
197 echo "$l.utf-8 UTF-8"
198 done
199 for l in lt lt_LT lv lv_LV; do
200 #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
201 echo "$l ISO-8859-13"
202 done
203 for l in ru_UA uk uk_UA; do
204 echo "$l KOI8-U"
205 done
206 for l in zh zh_CN; do
207 #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
208 echo "$l GB2312"
209 done
210 for l in ja ja_JP ja_JP.EUC; do
211 echo "$l EUC-JP"
212 done
213 for l in ko ko_KR; do
214 echo "$l EUC-KR"
215 done
216 for l in th th_TH; do
217 echo "$l TIS-620"
218 done
219 for l in fa fa_IR; do
220 #echo "$l ISIRI-3342" # a broken encoding
221 echo "$l.utf-8 UTF-8"
222 done
223 ;;
224 linux* | *-gnu*)
225 # With glibc-2.1 or newer, we don't need any canonicalization,
226 # because glibc has iconv and both glibc and libiconv support all
227 # GNU canonical names directly. Therefore, the Makefile does not
228 # need to install the alias file at all.
229 # The following applies only to glibc-2.0.x and older libcs.
230 echo "ISO_646.IRV:1983 ASCII"
231 ;;
232 aix*)
233 echo "ISO8859-1 ISO-8859-1"
234 echo "ISO8859-2 ISO-8859-2"
235 echo "ISO8859-5 ISO-8859-5"
236 echo "ISO8859-6 ISO-8859-6"
237 echo "ISO8859-7 ISO-8859-7"
238 echo "ISO8859-8 ISO-8859-8"
239 echo "ISO8859-9 ISO-8859-9"
240 echo "ISO8859-15 ISO-8859-15"
241 echo "IBM-850 CP850"
242 echo "IBM-856 CP856"
243 echo "IBM-921 ISO-8859-13"
244 echo "IBM-922 CP922"
245 echo "IBM-932 CP932"
246 echo "IBM-943 CP943"
247 echo "IBM-1046 CP1046"
248 echo "IBM-1124 CP1124"
249 echo "IBM-1129 CP1129"
250 echo "IBM-1252 CP1252"
251 echo "IBM-eucCN GB2312"
252 echo "IBM-eucJP EUC-JP"
253 echo "IBM-eucKR EUC-KR"
254 echo "IBM-eucTW EUC-TW"
255 echo "big5 BIG5"
256 echo "GBK GBK"
257 echo "TIS-620 TIS-620"
258 echo "UTF-8 UTF-8"
259 ;;
260 hpux*)
261 echo "iso88591 ISO-8859-1"
262 echo "iso88592 ISO-8859-2"
263 echo "iso88595 ISO-8859-5"
264 echo "iso88596 ISO-8859-6"
265 echo "iso88597 ISO-8859-7"
266 echo "iso88598 ISO-8859-8"
267 echo "iso88599 ISO-8859-9"
268 echo "iso885915 ISO-8859-15"
269 echo "roman8 HP-ROMAN8"
270 echo "arabic8 HP-ARABIC8"
271 echo "greek8 HP-GREEK8"
272 echo "hebrew8 HP-HEBREW8"
273 echo "turkish8 HP-TURKISH8"
274 echo "kana8 HP-KANA8"
275 echo "tis620 TIS-620"
276 echo "big5 BIG5"
277 echo "eucJP EUC-JP"
278 echo "eucKR EUC-KR"
279 echo "eucTW EUC-TW"
280 echo "hp15CN GB2312"
281 #echo "ccdc ?" # what is this?
282 echo "SJIS SHIFT_JIS"
283 echo "utf8 UTF-8"
284 ;;
285 irix*)
286 echo "ISO8859-1 ISO-8859-1"
287 echo "ISO8859-2 ISO-8859-2"
288 echo "ISO8859-5 ISO-8859-5"
289 echo "ISO8859-7 ISO-8859-7"
290 echo "ISO8859-9 ISO-8859-9"
291 echo "eucCN GB2312"
292 echo "eucJP EUC-JP"
293 echo "eucKR EUC-KR"
294 echo "eucTW EUC-TW"
295 ;;
296 osf*)
297 echo "ISO8859-1 ISO-8859-1"
298 echo "ISO8859-2 ISO-8859-2"
299 echo "ISO8859-4 ISO-8859-4"
300 echo "ISO8859-5 ISO-8859-5"
301 echo "ISO8859-7 ISO-8859-7"
302 echo "ISO8859-8 ISO-8859-8"
303 echo "ISO8859-9 ISO-8859-9"
304 echo "ISO8859-15 ISO-8859-15"
305 echo "cp850 CP850"
306 echo "big5 BIG5"
307 echo "dechanyu DEC-HANYU"
308 echo "dechanzi GB2312"
309 echo "deckanji DEC-KANJI"
310 echo "deckorean EUC-KR"
311 echo "eucJP EUC-JP"
312 echo "eucKR EUC-KR"
313 echo "eucTW EUC-TW"
314 echo "GBK GBK"
315 echo "KSC5601 CP949"
316 echo "sdeckanji EUC-JP"
317 echo "SJIS SHIFT_JIS"
318 echo "TACTIS TIS-620"
319 echo "UTF-8 UTF-8"
320 ;;
321 solaris*)
322 echo "646 ASCII"
323 echo "ISO8859-1 ISO-8859-1"
324 echo "ISO8859-2 ISO-8859-2"
325 echo "ISO8859-3 ISO-8859-3"
326 echo "ISO8859-4 ISO-8859-4"
327 echo "ISO8859-5 ISO-8859-5"
328 echo "ISO8859-6 ISO-8859-6"
329 echo "ISO8859-7 ISO-8859-7"
330 echo "ISO8859-8 ISO-8859-8"
331 echo "ISO8859-9 ISO-8859-9"
332 echo "ISO8859-15 ISO-8859-15"
333 echo "koi8-r KOI8-R"
334 echo "ansi-1251 CP1251"
335 echo "BIG5 BIG5"
336 echo "Big5-HKSCS BIG5-HKSCS"
337 echo "gb2312 GB2312"
338 echo "GBK GBK"
339 echo "GB18030 GB18030"
340 echo "cns11643 EUC-TW"
341 echo "5601 EUC-KR"
342 echo "ko_KR.johap92 JOHAB"
343 echo "eucJP EUC-JP"
344 echo "PCK SHIFT_JIS"
345 echo "TIS620.2533 TIS-620"
346 #echo "sun_eu_greek ?" # what is this?
347 echo "UTF-8 UTF-8"
348 ;;
349 freebsd* | os2*)
350 # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
351 # localcharset.c falls back to using the full locale name
352 # from the environment variables.
353 # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
354 # reuse FreeBSD's locale data for OS/2.
355 echo "C ASCII"
356 echo "US-ASCII ASCII"
357 for l in la_LN lt_LN; do
358 echo "$l.ASCII ASCII"
359 done
360 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
361 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
362 lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
363 echo "$l.ISO_8859-1 ISO-8859-1"
364 echo "$l.DIS_8859-15 ISO-8859-15"
365 done
366 for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
367 echo "$l.ISO_8859-2 ISO-8859-2"
368 done
369 for l in la_LN lt_LT; do
370 echo "$l.ISO_8859-4 ISO-8859-4"
371 done
372 for l in ru_RU ru_SU; do
373 echo "$l.KOI8-R KOI8-R"
374 echo "$l.ISO_8859-5 ISO-8859-5"
375 echo "$l.CP866 CP866"
376 done
377 echo "uk_UA.KOI8-U KOI8-U"
378 echo "zh_TW.BIG5 BIG5"
379 echo "zh_TW.Big5 BIG5"
380 echo "zh_CN.EUC GB2312"
381 echo "ja_JP.EUC EUC-JP"
382 echo "ja_JP.SJIS SHIFT_JIS"
383 echo "ja_JP.Shift_JIS SHIFT_JIS"
384 echo "ko_KR.EUC EUC-KR"
385 ;;
386 netbsd*)
387 echo "646 ASCII"
388 echo "ISO8859-1 ISO-8859-1"
389 echo "ISO8859-2 ISO-8859-2"
390 echo "ISO8859-4 ISO-8859-4"
391 echo "ISO8859-5 ISO-8859-5"
392 echo "ISO8859-7 ISO-8859-7"
393 echo "ISO8859-13 ISO-8859-13"
394 echo "ISO8859-15 ISO-8859-15"
395 echo "eucCN GB2312"
396 echo "eucJP EUC-JP"
397 echo "eucKR EUC-KR"
398 echo "eucTW EUC-TW"
399 echo "BIG5 BIG5"
400 echo "SJIS SHIFT_JIS"
401 ;;
402 openbsd*)
403 echo "646 ASCII"
404 echo "ISO8859-1 ISO-8859-1"
405 echo "ISO8859-2 ISO-8859-2"
406 echo "ISO8859-4 ISO-8859-4"
407 echo "ISO8859-5 ISO-8859-5"
408 echo "ISO8859-7 ISO-8859-7"
409 echo "ISO8859-13 ISO-8859-13"
410 echo "ISO8859-15 ISO-8859-15"
411 ;;
412 darwin[56]*)
413 # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
414 # localcharset.c falls back to using the full locale name
415 # from the environment variables.
416 echo "C ASCII"
417 for l in en_AU en_CA en_GB en_US la_LN; do
418 echo "$l.US-ASCII ASCII"
419 done
420 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
421 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
422 nl_NL no_NO pt_PT sv_SE; do
423 echo "$l ISO-8859-1"
424 echo "$l.ISO8859-1 ISO-8859-1"
425 echo "$l.ISO8859-15 ISO-8859-15"
426 done
427 for l in la_LN; do
428 echo "$l.ISO8859-1 ISO-8859-1"
429 echo "$l.ISO8859-15 ISO-8859-15"
430 done
431 for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
432 echo "$l.ISO8859-2 ISO-8859-2"
433 done
434 for l in la_LN lt_LT; do
435 echo "$l.ISO8859-4 ISO-8859-4"
436 done
437 for l in ru_RU; do
438 echo "$l.KOI8-R KOI8-R"
439 echo "$l.ISO8859-5 ISO-8859-5"
440 echo "$l.CP866 CP866"
441 done
442 for l in bg_BG; do
443 echo "$l.CP1251 CP1251"
444 done
445 echo "uk_UA.KOI8-U KOI8-U"
446 echo "zh_TW.BIG5 BIG5"
447 echo "zh_TW.Big5 BIG5"
448 echo "zh_CN.EUC GB2312"
449 echo "ja_JP.EUC EUC-JP"
450 echo "ja_JP.SJIS SHIFT_JIS"
451 echo "ko_KR.EUC EUC-KR"
452 ;;
453 darwin*)
454 # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
455 # useless:
456 # - It returns the empty string when LANG is set to a locale of the
457 # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
458 # LC_CTYPE file.
459 # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
460 # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
461 # - The documentation says:
462 # "... all code that calls BSD system routines should ensure
463 # that the const *char parameters of these routines are in UTF-8
464 # encoding. All BSD system functions expect their string
465 # parameters to be in UTF-8 encoding and nothing else."
466 # It also says
467 # "An additional caveat is that string parameters for files,
468 # paths, and other file-system entities must be in canonical
469 # UTF-8. In a canonical UTF-8 Unicode string, all decomposable
470 # characters are decomposed ..."
471 # but this is not true: You can pass non-decomposed UTF-8 strings
472 # to file system functions, and it is the OS which will convert
473 # them to decomposed UTF-8 before accessing the file system.
474 # - The Apple Terminal application displays UTF-8 by default.
475 # - However, other applications are free to use different encodings:
476 # - xterm uses ISO-8859-1 by default.
477 # - TextEdit uses MacRoman by default.
478 # We prefer UTF-8 over decomposed UTF-8-MAC because one should
479 # minimize the use of decomposed Unicode. Unfortunately, through the
480 # Darwin file system, decomposed UTF-8 strings are leaked into user
481 # space nevertheless.
482 # Then there are also the locales with encodings other than US-ASCII
483 # and UTF-8. These locales can be occasionally useful to users (e.g.
484 # when grepping through ISO-8859-1 encoded text files), when all their
485 # file names are in US-ASCII.
486 echo "ISO8859-1 ISO-8859-1"
487 echo "ISO8859-2 ISO-8859-2"
488 echo "ISO8859-4 ISO-8859-4"
489 echo "ISO8859-5 ISO-8859-5"
490 echo "ISO8859-7 ISO-8859-7"
491 echo "ISO8859-9 ISO-8859-9"
492 echo "ISO8859-13 ISO-8859-13"
493 echo "ISO8859-15 ISO-8859-15"
494 echo "KOI8-R KOI8-R"
495 echo "KOI8-U KOI8-U"
496 echo "CP866 CP866"
497 echo "CP949 CP949"
498 echo "CP1131 CP1131"
499 echo "CP1251 CP1251"
500 echo "eucCN GB2312"
501 echo "GB2312 GB2312"
502 echo "eucJP EUC-JP"
503 echo "eucKR EUC-KR"
504 echo "Big5 BIG5"
505 echo "Big5HKSCS BIG5-HKSCS"
506 echo "GBK GBK"
507 echo "GB18030 GB18030"
508 echo "SJIS SHIFT_JIS"
509 echo "ARMSCII-8 ARMSCII-8"
510 echo "PT154 PT154"
511 #echo "ISCII-DEV ?"
512 echo "* UTF-8"
513 ;;
514 beos* | haiku*)
515 # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
516 echo "* UTF-8"
517 ;;
518 msdosdjgpp*)
519 # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
520 # localcharset.c falls back to using the full locale name
521 # from the environment variables.
522 echo "#"
523 echo "# The encodings given here may not all be correct."
524 echo "# If you find that the encoding given for your language and"
525 echo "# country is not the one your DOS machine actually uses, just"
526 echo "# correct it in this file, and send a mail to"
527 echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
528 echo "# and Bruno Haible <bruno@clisp.org>."
529 echo "#"
530 echo "C ASCII"
531 # ISO-8859-1 languages
532 echo "ca CP850"
533 echo "ca_ES CP850"
534 echo "da CP865" # not CP850 ??
535 echo "da_DK CP865" # not CP850 ??
536 echo "de CP850"
537 echo "de_AT CP850"
538 echo "de_CH CP850"
539 echo "de_DE CP850"
540 echo "en CP850"
541 echo "en_AU CP850" # not CP437 ??
542 echo "en_CA CP850"
543 echo "en_GB CP850"
544 echo "en_NZ CP437"
545 echo "en_US CP437"
546 echo "en_ZA CP850" # not CP437 ??
547 echo "es CP850"
548 echo "es_AR CP850"
549 echo "es_BO CP850"
550 echo "es_CL CP850"
551 echo "es_CO CP850"
552 echo "es_CR CP850"
553 echo "es_CU CP850"
554 echo "es_DO CP850"
555 echo "es_EC CP850"
556 echo "es_ES CP850"
557 echo "es_GT CP850"
558 echo "es_HN CP850"
559 echo "es_MX CP850"
560 echo "es_NI CP850"
561 echo "es_PA CP850"
562 echo "es_PY CP850"
563 echo "es_PE CP850"
564 echo "es_SV CP850"
565 echo "es_UY CP850"
566 echo "es_VE CP850"
567 echo "et CP850"
568 echo "et_EE CP850"
569 echo "eu CP850"
570 echo "eu_ES CP850"
571 echo "fi CP850"
572 echo "fi_FI CP850"
573 echo "fr CP850"
574 echo "fr_BE CP850"
575 echo "fr_CA CP850"
576 echo "fr_CH CP850"
577 echo "fr_FR CP850"
578 echo "ga CP850"
579 echo "ga_IE CP850"
580 echo "gd CP850"
581 echo "gd_GB CP850"
582 echo "gl CP850"
583 echo "gl_ES CP850"
584 echo "id CP850" # not CP437 ??
585 echo "id_ID CP850" # not CP437 ??
586 echo "is CP861" # not CP850 ??
587 echo "is_IS CP861" # not CP850 ??
588 echo "it CP850"
589 echo "it_CH CP850"
590 echo "it_IT CP850"
591 echo "lt CP775"
592 echo "lt_LT CP775"
593 echo "lv CP775"
594 echo "lv_LV CP775"
595 echo "nb CP865" # not CP850 ??
596 echo "nb_NO CP865" # not CP850 ??
597 echo "nl CP850"
598 echo "nl_BE CP850"
599 echo "nl_NL CP850"
600 echo "nn CP865" # not CP850 ??
601 echo "nn_NO CP865" # not CP850 ??
602 echo "no CP865" # not CP850 ??
603 echo "no_NO CP865" # not CP850 ??
604 echo "pt CP850"
605 echo "pt_BR CP850"
606 echo "pt_PT CP850"
607 echo "sv CP850"
608 echo "sv_SE CP850"
609 # ISO-8859-2 languages
610 echo "cs CP852"
611 echo "cs_CZ CP852"
612 echo "hr CP852"
613 echo "hr_HR CP852"
614 echo "hu CP852"
615 echo "hu_HU CP852"
616 echo "pl CP852"
617 echo "pl_PL CP852"
618 echo "ro CP852"
619 echo "ro_RO CP852"
620 echo "sk CP852"
621 echo "sk_SK CP852"
622 echo "sl CP852"
623 echo "sl_SI CP852"
624 echo "sq CP852"
625 echo "sq_AL CP852"
626 echo "sr CP852" # CP852 or CP866 or CP855 ??
627 echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
628 echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
629 # ISO-8859-3 languages
630 echo "mt CP850"
631 echo "mt_MT CP850"
632 # ISO-8859-5 languages
633 echo "be CP866"
634 echo "be_BE CP866"
635 echo "bg CP866" # not CP855 ??
636 echo "bg_BG CP866" # not CP855 ??
637 echo "mk CP866" # not CP855 ??
638 echo "mk_MK CP866" # not CP855 ??
639 echo "ru CP866"
640 echo "ru_RU CP866"
641 echo "uk CP1125"
642 echo "uk_UA CP1125"
643 # ISO-8859-6 languages
644 echo "ar CP864"
645 echo "ar_AE CP864"
646 echo "ar_DZ CP864"
647 echo "ar_EG CP864"
648 echo "ar_IQ CP864"
649 echo "ar_IR CP864"
650 echo "ar_JO CP864"
651 echo "ar_KW CP864"
652 echo "ar_MA CP864"
653 echo "ar_OM CP864"
654 echo "ar_QA CP864"
655 echo "ar_SA CP864"
656 echo "ar_SY CP864"
657 # ISO-8859-7 languages
658 echo "el CP869"
659 echo "el_GR CP869"
660 # ISO-8859-8 languages
661 echo "he CP862"
662 echo "he_IL CP862"
663 # ISO-8859-9 languages
664 echo "tr CP857"
665 echo "tr_TR CP857"
666 # Japanese
667 echo "ja CP932"
668 echo "ja_JP CP932"
669 # Chinese
670 echo "zh_CN GBK"
671 echo "zh_TW CP950" # not CP938 ??
672 # Korean
673 echo "kr CP949" # not CP934 ??
674 echo "kr_KR CP949" # not CP934 ??
675 # Thai
676 echo "th CP874"
677 echo "th_TH CP874"
678 # Other
679 echo "eo CP850"
680 echo "eo_EO CP850"
681 ;;
125 linux-gnulibc1*)
126 # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
127 # localcharset.c falls back to using the full locale name
128 # from the environment variables.
129 echo "C ASCII"
130 echo "POSIX ASCII"
131 for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
132 en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
133 en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
134 es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
135 et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
136 fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
137 it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
138 sv_FI sv_SE; do
139 echo "$l ISO-8859-1"
140 echo "$l.iso-8859-1 ISO-8859-1"
141 echo "$l.iso-8859-15 ISO-8859-15"
142 echo "$l.iso-8859-15@euro ISO-8859-15"
143 echo "$l@euro ISO-8859-15"
144 echo "$l.cp-437 CP437"
145 echo "$l.cp-850 CP850"
146 echo "$l.cp-1252 CP1252"
147 echo "$l.cp-1252@euro CP1252"
148 #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
149 echo "$l.utf-8 UTF-8"
150 echo "$l.utf-8@euro UTF-8"
151 done
152 for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
153 sl_SI sr sr_CS sr_YU; do
154 echo "$l ISO-8859-2"
155 echo "$l.iso-8859-2 ISO-8859-2"
156 echo "$l.cp-852 CP852"
157 echo "$l.cp-1250 CP1250"
158 echo "$l.utf-8 UTF-8"
159 done
160 for l in mk mk_MK ru ru_RU; do
161 echo "$l ISO-8859-5"
162 echo "$l.iso-8859-5 ISO-8859-5"
163 echo "$l.koi8-r KOI8-R"
164 echo "$l.cp-866 CP866"
165 echo "$l.cp-1251 CP1251"
166 echo "$l.utf-8 UTF-8"
167 done
168 for l in ar ar_SA; do
169 echo "$l ISO-8859-6"
170 echo "$l.iso-8859-6 ISO-8859-6"
171 echo "$l.cp-864 CP864"
172 #echo "$l.cp-868 CP868" # not a commonly used encoding
173 echo "$l.cp-1256 CP1256"
174 echo "$l.utf-8 UTF-8"
175 done
176 for l in el el_GR gr gr_GR; do
177 echo "$l ISO-8859-7"
178 echo "$l.iso-8859-7 ISO-8859-7"
179 echo "$l.cp-869 CP869"
180 echo "$l.cp-1253 CP1253"
181 echo "$l.cp-1253@euro CP1253"
182 echo "$l.utf-8 UTF-8"
183 echo "$l.utf-8@euro UTF-8"
184 done
185 for l in he he_IL iw iw_IL; do
186 echo "$l ISO-8859-8"
187 echo "$l.iso-8859-8 ISO-8859-8"
188 echo "$l.cp-862 CP862"
189 echo "$l.cp-1255 CP1255"
190 echo "$l.utf-8 UTF-8"
191 done
192 for l in tr tr_TR; do
193 echo "$l ISO-8859-9"
194 echo "$l.iso-8859-9 ISO-8859-9"
195 echo "$l.cp-857 CP857"
196 echo "$l.cp-1254 CP1254"
197 echo "$l.utf-8 UTF-8"
198 done
199 for l in lt lt_LT lv lv_LV; do
200 #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
201 echo "$l ISO-8859-13"
202 done
203 for l in ru_UA uk uk_UA; do
204 echo "$l KOI8-U"
205 done
206 for l in zh zh_CN; do
207 #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
208 echo "$l GB2312"
209 done
210 for l in ja ja_JP ja_JP.EUC; do
211 echo "$l EUC-JP"
212 done
213 for l in ko ko_KR; do
214 echo "$l EUC-KR"
215 done
216 for l in th th_TH; do
217 echo "$l TIS-620"
218 done
219 for l in fa fa_IR; do
220 #echo "$l ISIRI-3342" # a broken encoding
221 echo "$l.utf-8 UTF-8"
222 done
223 ;;
224 linux* | *-gnu*)
225 # With glibc-2.1 or newer, we don't need any canonicalization,
226 # because glibc has iconv and both glibc and libiconv support all
227 # GNU canonical names directly. Therefore, the Makefile does not
228 # need to install the alias file at all.
229 # The following applies only to glibc-2.0.x and older libcs.
230 echo "ISO_646.IRV:1983 ASCII"
231 ;;
232 aix*)
233 echo "ISO8859-1 ISO-8859-1"
234 echo "ISO8859-2 ISO-8859-2"
235 echo "ISO8859-5 ISO-8859-5"
236 echo "ISO8859-6 ISO-8859-6"
237 echo "ISO8859-7 ISO-8859-7"
238 echo "ISO8859-8 ISO-8859-8"
239 echo "ISO8859-9 ISO-8859-9"
240 echo "ISO8859-15 ISO-8859-15"
241 echo "IBM-850 CP850"
242 echo "IBM-856 CP856"
243 echo "IBM-921 ISO-8859-13"
244 echo "IBM-922 CP922"
245 echo "IBM-932 CP932"
246 echo "IBM-943 CP943"
247 echo "IBM-1046 CP1046"
248 echo "IBM-1124 CP1124"
249 echo "IBM-1129 CP1129"
250 echo "IBM-1252 CP1252"
251 echo "IBM-eucCN GB2312"
252 echo "IBM-eucJP EUC-JP"
253 echo "IBM-eucKR EUC-KR"
254 echo "IBM-eucTW EUC-TW"
255 echo "big5 BIG5"
256 echo "GBK GBK"
257 echo "TIS-620 TIS-620"
258 echo "UTF-8 UTF-8"
259 ;;
260 hpux*)
261 echo "iso88591 ISO-8859-1"
262 echo "iso88592 ISO-8859-2"
263 echo "iso88595 ISO-8859-5"
264 echo "iso88596 ISO-8859-6"
265 echo "iso88597 ISO-8859-7"
266 echo "iso88598 ISO-8859-8"
267 echo "iso88599 ISO-8859-9"
268 echo "iso885915 ISO-8859-15"
269 echo "roman8 HP-ROMAN8"
270 echo "arabic8 HP-ARABIC8"
271 echo "greek8 HP-GREEK8"
272 echo "hebrew8 HP-HEBREW8"
273 echo "turkish8 HP-TURKISH8"
274 echo "kana8 HP-KANA8"
275 echo "tis620 TIS-620"
276 echo "big5 BIG5"
277 echo "eucJP EUC-JP"
278 echo "eucKR EUC-KR"
279 echo "eucTW EUC-TW"
280 echo "hp15CN GB2312"
281 #echo "ccdc ?" # what is this?
282 echo "SJIS SHIFT_JIS"
283 echo "utf8 UTF-8"
284 ;;
285 irix*)
286 echo "ISO8859-1 ISO-8859-1"
287 echo "ISO8859-2 ISO-8859-2"
288 echo "ISO8859-5 ISO-8859-5"
289 echo "ISO8859-7 ISO-8859-7"
290 echo "ISO8859-9 ISO-8859-9"
291 echo "eucCN GB2312"
292 echo "eucJP EUC-JP"
293 echo "eucKR EUC-KR"
294 echo "eucTW EUC-TW"
295 ;;
296 osf*)
297 echo "ISO8859-1 ISO-8859-1"
298 echo "ISO8859-2 ISO-8859-2"
299 echo "ISO8859-4 ISO-8859-4"
300 echo "ISO8859-5 ISO-8859-5"
301 echo "ISO8859-7 ISO-8859-7"
302 echo "ISO8859-8 ISO-8859-8"
303 echo "ISO8859-9 ISO-8859-9"
304 echo "ISO8859-15 ISO-8859-15"
305 echo "cp850 CP850"
306 echo "big5 BIG5"
307 echo "dechanyu DEC-HANYU"
308 echo "dechanzi GB2312"
309 echo "deckanji DEC-KANJI"
310 echo "deckorean EUC-KR"
311 echo "eucJP EUC-JP"
312 echo "eucKR EUC-KR"
313 echo "eucTW EUC-TW"
314 echo "GBK GBK"
315 echo "KSC5601 CP949"
316 echo "sdeckanji EUC-JP"
317 echo "SJIS SHIFT_JIS"
318 echo "TACTIS TIS-620"
319 echo "UTF-8 UTF-8"
320 ;;
321 solaris*)
322 echo "646 ASCII"
323 echo "ISO8859-1 ISO-8859-1"
324 echo "ISO8859-2 ISO-8859-2"
325 echo "ISO8859-3 ISO-8859-3"
326 echo "ISO8859-4 ISO-8859-4"
327 echo "ISO8859-5 ISO-8859-5"
328 echo "ISO8859-6 ISO-8859-6"
329 echo "ISO8859-7 ISO-8859-7"
330 echo "ISO8859-8 ISO-8859-8"
331 echo "ISO8859-9 ISO-8859-9"
332 echo "ISO8859-15 ISO-8859-15"
333 echo "koi8-r KOI8-R"
334 echo "ansi-1251 CP1251"
335 echo "BIG5 BIG5"
336 echo "Big5-HKSCS BIG5-HKSCS"
337 echo "gb2312 GB2312"
338 echo "GBK GBK"
339 echo "GB18030 GB18030"
340 echo "cns11643 EUC-TW"
341 echo "5601 EUC-KR"
342 echo "ko_KR.johap92 JOHAB"
343 echo "eucJP EUC-JP"
344 echo "PCK SHIFT_JIS"
345 echo "TIS620.2533 TIS-620"
346 #echo "sun_eu_greek ?" # what is this?
347 echo "UTF-8 UTF-8"
348 ;;
349 freebsd* | os2*)
350 # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
351 # localcharset.c falls back to using the full locale name
352 # from the environment variables.
353 # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
354 # reuse FreeBSD's locale data for OS/2.
355 echo "C ASCII"
356 echo "US-ASCII ASCII"
357 for l in la_LN lt_LN; do
358 echo "$l.ASCII ASCII"
359 done
360 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
361 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
362 lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
363 echo "$l.ISO_8859-1 ISO-8859-1"
364 echo "$l.DIS_8859-15 ISO-8859-15"
365 done
366 for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
367 echo "$l.ISO_8859-2 ISO-8859-2"
368 done
369 for l in la_LN lt_LT; do
370 echo "$l.ISO_8859-4 ISO-8859-4"
371 done
372 for l in ru_RU ru_SU; do
373 echo "$l.KOI8-R KOI8-R"
374 echo "$l.ISO_8859-5 ISO-8859-5"
375 echo "$l.CP866 CP866"
376 done
377 echo "uk_UA.KOI8-U KOI8-U"
378 echo "zh_TW.BIG5 BIG5"
379 echo "zh_TW.Big5 BIG5"
380 echo "zh_CN.EUC GB2312"
381 echo "ja_JP.EUC EUC-JP"
382 echo "ja_JP.SJIS SHIFT_JIS"
383 echo "ja_JP.Shift_JIS SHIFT_JIS"
384 echo "ko_KR.EUC EUC-KR"
385 ;;
386 netbsd*)
387 echo "646 ASCII"
388 echo "ISO8859-1 ISO-8859-1"
389 echo "ISO8859-2 ISO-8859-2"
390 echo "ISO8859-4 ISO-8859-4"
391 echo "ISO8859-5 ISO-8859-5"
392 echo "ISO8859-7 ISO-8859-7"
393 echo "ISO8859-13 ISO-8859-13"
394 echo "ISO8859-15 ISO-8859-15"
395 echo "eucCN GB2312"
396 echo "eucJP EUC-JP"
397 echo "eucKR EUC-KR"
398 echo "eucTW EUC-TW"
399 echo "BIG5 BIG5"
400 echo "SJIS SHIFT_JIS"
401 ;;
402 openbsd*)
403 echo "646 ASCII"
404 echo "ISO8859-1 ISO-8859-1"
405 echo "ISO8859-2 ISO-8859-2"
406 echo "ISO8859-4 ISO-8859-4"
407 echo "ISO8859-5 ISO-8859-5"
408 echo "ISO8859-7 ISO-8859-7"
409 echo "ISO8859-13 ISO-8859-13"
410 echo "ISO8859-15 ISO-8859-15"
411 ;;
412 darwin[56]*)
413 # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
414 # localcharset.c falls back to using the full locale name
415 # from the environment variables.
416 echo "C ASCII"
417 for l in en_AU en_CA en_GB en_US la_LN; do
418 echo "$l.US-ASCII ASCII"
419 done
420 for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
421 fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
422 nl_NL no_NO pt_PT sv_SE; do
423 echo "$l ISO-8859-1"
424 echo "$l.ISO8859-1 ISO-8859-1"
425 echo "$l.ISO8859-15 ISO-8859-15"
426 done
427 for l in la_LN; do
428 echo "$l.ISO8859-1 ISO-8859-1"
429 echo "$l.ISO8859-15 ISO-8859-15"
430 done
431 for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
432 echo "$l.ISO8859-2 ISO-8859-2"
433 done
434 for l in la_LN lt_LT; do
435 echo "$l.ISO8859-4 ISO-8859-4"
436 done
437 for l in ru_RU; do
438 echo "$l.KOI8-R KOI8-R"
439 echo "$l.ISO8859-5 ISO-8859-5"
440 echo "$l.CP866 CP866"
441 done
442 for l in bg_BG; do
443 echo "$l.CP1251 CP1251"
444 done
445 echo "uk_UA.KOI8-U KOI8-U"
446 echo "zh_TW.BIG5 BIG5"
447 echo "zh_TW.Big5 BIG5"
448 echo "zh_CN.EUC GB2312"
449 echo "ja_JP.EUC EUC-JP"
450 echo "ja_JP.SJIS SHIFT_JIS"
451 echo "ko_KR.EUC EUC-KR"
452 ;;
453 darwin*)
454 # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
455 # useless:
456 # - It returns the empty string when LANG is set to a locale of the
457 # form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
458 # LC_CTYPE file.
459 # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
460 # the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
461 # - The documentation says:
462 # "... all code that calls BSD system routines should ensure
463 # that the const *char parameters of these routines are in UTF-8
464 # encoding. All BSD system functions expect their string
465 # parameters to be in UTF-8 encoding and nothing else."
466 # It also says
467 # "An additional caveat is that string parameters for files,
468 # paths, and other file-system entities must be in canonical
469 # UTF-8. In a canonical UTF-8 Unicode string, all decomposable
470 # characters are decomposed ..."
471 # but this is not true: You can pass non-decomposed UTF-8 strings
472 # to file system functions, and it is the OS which will convert
473 # them to decomposed UTF-8 before accessing the file system.
474 # - The Apple Terminal application displays UTF-8 by default.
475 # - However, other applications are free to use different encodings:
476 # - xterm uses ISO-8859-1 by default.
477 # - TextEdit uses MacRoman by default.
478 # We prefer UTF-8 over decomposed UTF-8-MAC because one should
479 # minimize the use of decomposed Unicode. Unfortunately, through the
480 # Darwin file system, decomposed UTF-8 strings are leaked into user
481 # space nevertheless.
482 # Then there are also the locales with encodings other than US-ASCII
483 # and UTF-8. These locales can be occasionally useful to users (e.g.
484 # when grepping through ISO-8859-1 encoded text files), when all their
485 # file names are in US-ASCII.
486 echo "ISO8859-1 ISO-8859-1"
487 echo "ISO8859-2 ISO-8859-2"
488 echo "ISO8859-4 ISO-8859-4"
489 echo "ISO8859-5 ISO-8859-5"
490 echo "ISO8859-7 ISO-8859-7"
491 echo "ISO8859-9 ISO-8859-9"
492 echo "ISO8859-13 ISO-8859-13"
493 echo "ISO8859-15 ISO-8859-15"
494 echo "KOI8-R KOI8-R"
495 echo "KOI8-U KOI8-U"
496 echo "CP866 CP866"
497 echo "CP949 CP949"
498 echo "CP1131 CP1131"
499 echo "CP1251 CP1251"
500 echo "eucCN GB2312"
501 echo "GB2312 GB2312"
502 echo "eucJP EUC-JP"
503 echo "eucKR EUC-KR"
504 echo "Big5 BIG5"
505 echo "Big5HKSCS BIG5-HKSCS"
506 echo "GBK GBK"
507 echo "GB18030 GB18030"
508 echo "SJIS SHIFT_JIS"
509 echo "ARMSCII-8 ARMSCII-8"
510 echo "PT154 PT154"
511 #echo "ISCII-DEV ?"
512 echo "* UTF-8"
513 ;;
514 beos* | haiku*)
515 # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
516 echo "* UTF-8"
517 ;;
518 msdosdjgpp*)
519 # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
520 # localcharset.c falls back to using the full locale name
521 # from the environment variables.
522 echo "#"
523 echo "# The encodings given here may not all be correct."
524 echo "# If you find that the encoding given for your language and"
525 echo "# country is not the one your DOS machine actually uses, just"
526 echo "# correct it in this file, and send a mail to"
527 echo "# Juan Manuel Guerrero <juan.guerrero@gmx.de>"
528 echo "# and Bruno Haible <bruno@clisp.org>."
529 echo "#"
530 echo "C ASCII"
531 # ISO-8859-1 languages
532 echo "ca CP850"
533 echo "ca_ES CP850"
534 echo "da CP865" # not CP850 ??
535 echo "da_DK CP865" # not CP850 ??
536 echo "de CP850"
537 echo "de_AT CP850"
538 echo "de_CH CP850"
539 echo "de_DE CP850"
540 echo "en CP850"
541 echo "en_AU CP850" # not CP437 ??
542 echo "en_CA CP850"
543 echo "en_GB CP850"
544 echo "en_NZ CP437"
545 echo "en_US CP437"
546 echo "en_ZA CP850" # not CP437 ??
547 echo "es CP850"
548 echo "es_AR CP850"
549 echo "es_BO CP850"
550 echo "es_CL CP850"
551 echo "es_CO CP850"
552 echo "es_CR CP850"
553 echo "es_CU CP850"
554 echo "es_DO CP850"
555 echo "es_EC CP850"
556 echo "es_ES CP850"
557 echo "es_GT CP850"
558 echo "es_HN CP850"
559 echo "es_MX CP850"
560 echo "es_NI CP850"
561 echo "es_PA CP850"
562 echo "es_PY CP850"
563 echo "es_PE CP850"
564 echo "es_SV CP850"
565 echo "es_UY CP850"
566 echo "es_VE CP850"
567 echo "et CP850"
568 echo "et_EE CP850"
569 echo "eu CP850"
570 echo "eu_ES CP850"
571 echo "fi CP850"
572 echo "fi_FI CP850"
573 echo "fr CP850"
574 echo "fr_BE CP850"
575 echo "fr_CA CP850"
576 echo "fr_CH CP850"
577 echo "fr_FR CP850"
578 echo "ga CP850"
579 echo "ga_IE CP850"
580 echo "gd CP850"
581 echo "gd_GB CP850"
582 echo "gl CP850"
583 echo "gl_ES CP850"
584 echo "id CP850" # not CP437 ??
585 echo "id_ID CP850" # not CP437 ??
586 echo "is CP861" # not CP850 ??
587 echo "is_IS CP861" # not CP850 ??
588 echo "it CP850"
589 echo "it_CH CP850"
590 echo "it_IT CP850"
591 echo "lt CP775"
592 echo "lt_LT CP775"
593 echo "lv CP775"
594 echo "lv_LV CP775"
595 echo "nb CP865" # not CP850 ??
596 echo "nb_NO CP865" # not CP850 ??
597 echo "nl CP850"
598 echo "nl_BE CP850"
599 echo "nl_NL CP850"
600 echo "nn CP865" # not CP850 ??
601 echo "nn_NO CP865" # not CP850 ??
602 echo "no CP865" # not CP850 ??
603 echo "no_NO CP865" # not CP850 ??
604 echo "pt CP850"
605 echo "pt_BR CP850"
606 echo "pt_PT CP850"
607 echo "sv CP850"
608 echo "sv_SE CP850"
609 # ISO-8859-2 languages
610 echo "cs CP852"
611 echo "cs_CZ CP852"
612 echo "hr CP852"
613 echo "hr_HR CP852"
614 echo "hu CP852"
615 echo "hu_HU CP852"
616 echo "pl CP852"
617 echo "pl_PL CP852"
618 echo "ro CP852"
619 echo "ro_RO CP852"
620 echo "sk CP852"
621 echo "sk_SK CP852"
622 echo "sl CP852"
623 echo "sl_SI CP852"
624 echo "sq CP852"
625 echo "sq_AL CP852"
626 echo "sr CP852" # CP852 or CP866 or CP855 ??
627 echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
628 echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
629 # ISO-8859-3 languages
630 echo "mt CP850"
631 echo "mt_MT CP850"
632 # ISO-8859-5 languages
633 echo "be CP866"
634 echo "be_BE CP866"
635 echo "bg CP866" # not CP855 ??
636 echo "bg_BG CP866" # not CP855 ??
637 echo "mk CP866" # not CP855 ??
638 echo "mk_MK CP866" # not CP855 ??
639 echo "ru CP866"
640 echo "ru_RU CP866"
641 echo "uk CP1125"
642 echo "uk_UA CP1125"
643 # ISO-8859-6 languages
644 echo "ar CP864"
645 echo "ar_AE CP864"
646 echo "ar_DZ CP864"
647 echo "ar_EG CP864"
648 echo "ar_IQ CP864"
649 echo "ar_IR CP864"
650 echo "ar_JO CP864"
651 echo "ar_KW CP864"
652 echo "ar_MA CP864"
653 echo "ar_OM CP864"
654 echo "ar_QA CP864"
655 echo "ar_SA CP864"
656 echo "ar_SY CP864"
657 # ISO-8859-7 languages
658 echo "el CP869"
659 echo "el_GR CP869"
660 # ISO-8859-8 languages
661 echo "he CP862"
662 echo "he_IL CP862"
663 # ISO-8859-9 languages
664 echo "tr CP857"
665 echo "tr_TR CP857"
666 # Japanese
667 echo "ja CP932"
668 echo "ja_JP CP932"
669 # Chinese
670 echo "zh_CN GBK"
671 echo "zh_TW CP950" # not CP938 ??
672 # Korean
673 echo "kr CP949" # not CP934 ??
674 echo "kr_KR CP949" # not CP934 ??
675 # Thai
676 echo "th CP874"
677 echo "th_TH CP874"
678 # Other
679 echo "eo CP850"
680 echo "eo_EO CP850"
681 ;;
682682 esac
2828 non-IEEE-754 'long double' values. */
2929 #undef CHECK_PRINTF_SAFE
3030
31 /* Define to 1 if chown fails to change ctime when at least one argument was
32 not -1. */
33 #undef CHOWN_CHANGE_TIME_BUG
34
35 /* Define if chown is not POSIX compliant regarding IDs of -1. */
36 #undef CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE
37
38 /* Define if chown modifies symlinks. */
39 #undef CHOWN_MODIFIES_SYMLINK
40
41 /* Define to 1 if chown mishandles trailing slash. */
42 #undef CHOWN_TRAILING_SLASH_BUG
43
3144 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
3245 systems. This function is required for `alloca.c' support on those systems.
3346 */
4861
4962 /* Define as the word index where to find the sign of 'double'. */
5063 #undef DBL_SIGNBIT_WORD
64
65 /* the name of the file descriptor member of DIR */
66 #undef DIR_FD_MEMBER_NAME
67
68 #ifdef DIR_FD_MEMBER_NAME
69 # define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
70 #else
71 # define DIR_TO_FD(Dir_p) -1
72 #endif
73
74
75 /* Define to 1 if // is a file system root distinct from /. */
76 #undef DOUBLE_SLASH_IS_DISTINCT_ROOT
77
78 /* Define if struct dirent has a member d_ino that actually works. */
79 #undef D_INO_IN_DIRENT
80
81 /* Define to 1 if your platform has fchownat, but it cannot perform lchown
82 tasks. */
83 #undef FCHOWNAT_NOFOLLOW_BUG
84
85 /* Define this to 1 if F_DUPFD behavior does not match POSIX */
86 #undef FCNTL_DUPFD_BUGGY
5187
5288 /* Define on systems for which file names may have a so-called `drive letter'
5389 prefix, define this to compute the length of that prefix, including the
75111 /* Define as the word index where to find the sign of 'float'. */
76112 #undef FLT_SIGNBIT_WORD
77113
114 /* Define to 1 if mkdir mistakenly creates a directory given with a trailing
115 dot component. */
116 #undef FUNC_MKDIR_DOT_BUG
117
118 /* Define to 1 if futimesat mishandles a NULL file name. */
119 #undef FUTIMESAT_NULL_BUG
120
78121 /* Define if gettimeofday clobbers the localtime buffer. */
79122 #undef GETTIMEOFDAY_CLOBBERS_LOCALTIME
80123
93136 /* Define to 1 when using the gnulib module open. */
94137 #undef GNULIB_OPEN
95138
139 /* enable some gnulib portability checks */
140 #undef GNULIB_PORTCHECK
141
96142 /* Define to indicate the 'realloc' module. */
97143 #undef GNULIB_REALLOC_GNU
98
99 /* Define to 1 when using the gnulib module unistd-safer. */
100 #undef GNULIB_UNISTD_SAFER
101144
102145 /* Define to 1 if you have 'alloca' after including <alloca.h>, a header that
103146 may be supplied by this distribution. */
150193 don't. */
151194 #undef HAVE_DECL_COPYSIGNL
152195
196 /* Define to 1 if you have the declaration of `dirfd', and to 0 if you don't.
197 */
198 #undef HAVE_DECL_DIRFD
199
153200 /* Define to 1 if you have the declaration of `fpurge', and to 0 if you don't.
154201 */
155202 #undef HAVE_DECL_FPURGE
203
204 /* Define to 1 if you have the declaration of `getcwd', and to 0 if you don't.
205 */
206 #undef HAVE_DECL_GETCWD
156207
157208 /* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you
158209 don't. */
162213 */
163214 #undef HAVE_DECL_GETENV
164215
216 /* Define to 1 if you have the declaration of `memrchr', and to 0 if you
217 don't. */
218 #undef HAVE_DECL_MEMRCHR
219
220 /* Define to 1 if you have the declaration of `optreset', and to 0 if you
221 don't. */
222 #undef HAVE_DECL_OPTRESET
223
224 /* Define to 1 if you have the declaration of `strdup', and to 0 if you don't.
225 */
226 #undef HAVE_DECL_STRDUP
227
165228 /* Define to 1 if you have the declaration of `strerror', and to 0 if you
166229 don't. */
167230 #undef HAVE_DECL_STRERROR
182245 */
183246 #undef HAVE_DIRENT_H
184247
248 /* Define to 1 if you have the `dirfd' function. */
249 #undef HAVE_DIRFD
250
185251 /* Define to 1 if you have the `dup2' function. */
186252 #undef HAVE_DUP2
187253
188254 /* Define to 1 if you have the <errno.h> header file. */
189255 #undef HAVE_ERRNO_H
190256
257 /* Define to 1 if you have the `fchdir' function. */
258 #undef HAVE_FCHDIR
259
191260 /* Define to 1 if you have the `fchmod' function. */
192261 #undef HAVE_FCHMOD
193262
263 /* Define to 1 if you have the `fchmodat' function. */
264 #undef HAVE_FCHMODAT
265
194266 /* Define to 1 if you have the `fchown' function. */
195267 #undef HAVE_FCHOWN
196268
269 /* Define to 1 if you have the `fcntl' function. */
270 #undef HAVE_FCNTL
271
197272 /* Define to 1 if you have the <fcntl.h> header file. */
198273 #undef HAVE_FCNTL_H
199274
214289
215290 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
216291 #undef HAVE_FSEEKO
292
293 /* Define to 1 if you have the `fstatat' function. */
294 #undef HAVE_FSTATAT
217295
218296 /* Define to 1 if you have the `futimens' function. */
219297 #undef HAVE_FUTIMENS
266344 /* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
267345 #undef HAVE_LANGINFO_CODESET
268346
347 /* Define to 1 if you have the `lchmod' function. */
348 #undef HAVE_LCHMOD
349
350 /* Define to 1 if you have the `lchown' function. */
351 #undef HAVE_LCHOWN
352
269353 /* Define if the ldexpl function is available in libc. */
270354 #undef HAVE_LDEXPL_IN_LIBC
271355
313397 /* Define to 1 if you have the <memory.h> header file. */
314398 #undef HAVE_MEMORY_H
315399
400 /* Define to 1 if you have the `mempcpy' function. */
401 #undef HAVE_MEMPCPY
402
403 /* Define to 1 if you have the `memrchr' function. */
404 #undef HAVE_MEMRCHR
405
406 /* Define to 1 if you have the `mkdirat' function. */
407 #undef HAVE_MKDIRAT
408
316409 /* Define to 1 if you have the `mprotect' function. */
317410 #undef HAVE_MPROTECT
318411
325418 /* Define to 1 if you have the `nl_langinfo' function. */
326419 #undef HAVE_NL_LANGINFO
327420
328 /* Define to 1 if you have the <OS.h> header file. */
329 #undef HAVE_OS_H
421 /* Define to 1 if you have the `openat' function. */
422 #undef HAVE_OPENAT
423
424 /* Define to 1 if getcwd works, except it sometimes fails when it shouldn't,
425 setting errno to ERANGE, ENAMETOOLONG, or ENOENT. If __GETCWD_PREFIX is not
426 defined, it doesn't matter whether HAVE_PARTLY_WORKING_GETCWD is defined.
427 */
428 #undef HAVE_PARTLY_WORKING_GETCWD
330429
331430 /* Define to 1 if you have the `pipe' function. */
332431 #undef HAVE_PIPE
333432
334433 /* Define to 1 if you have the <random.h> header file. */
335434 #undef HAVE_RANDOM_H
435
436 /* Define to 1 if environ is declared even after undefining macros. */
437 #undef HAVE_RAW_DECL_ENVIRON
438
439 /* Define to 1 if fseeko is declared even after undefining macros. */
440 #undef HAVE_RAW_DECL_FSEEKO
441
442 /* Define to 1 if ftello is declared even after undefining macros. */
443 #undef HAVE_RAW_DECL_FTELLO
336444
337445 /* Define to 1 if your system has a GNU libc compatible `realloc' function,
338446 and to 0 otherwise. */
341449 /* Define if the 'realloc' function is POSIX compliant. */
342450 #undef HAVE_REALLOC_POSIX
343451
452 /* Define to 1 if you have the `rmdir' function. */
453 #undef HAVE_RMDIR
454
344455 /* Define to 1 if you have the `siginterrupt' function. */
345456 #undef HAVE_SIGINTERRUPT
346457
378489 /* Define to 1 if you have the <stdlib.h> header file. */
379490 #undef HAVE_STDLIB_H
380491
492 /* Define to 1 if you have the `strdup' function. */
493 #undef HAVE_STRDUP
494
381495 /* Define to 1 if you have the `strerror_r' function. */
382496 #undef HAVE_STRERROR_R
383497
435549 */
436550 #undef HAVE_SYS_NDIR_H
437551
438 /* Define to 1 if you have the <sys/param.h> header file. */
439 #undef HAVE_SYS_PARAM_H
440
441552 /* Define to 1 if you have the <sys/socket.h> header file. */
442553 #undef HAVE_SYS_SOCKET_H
443554
458569
459570 /* Define to 1 if you have the <unistd.h> header file. */
460571 #undef HAVE_UNISTD_H
572
573 /* Define to 1 if you have the `unlinkat' function. */
574 #undef HAVE_UNLINKAT
461575
462576 /* Define to 1 if the system has the type `unsigned long long int'. */
463577 #undef HAVE_UNSIGNED_LONG_LONG_INT
644758 'ptrdiff_t'. */
645759 #undef PTRDIFF_T_SUFFIX
646760
647 /* Define to 1 if dup2 returns 0 instead of the target fd. */
648 #undef REPLACE_DUP2
761 /* Define to 1 if gnulib's fchdir() replacement is used. */
762 #undef REPLACE_FCHDIR
649763
650764 /* Define if fprintf is overridden by a POSIX compliant gnulib implementation.
651765 */
658772 /* Define to 1 if stat needs help when passed a file name with a trailing
659773 slash */
660774 #undef REPLACE_FUNC_STAT_FILE
775
776 /* Define to 1 if open() should work around the inability to open a directory.
777 */
778 #undef REPLACE_OPEN_DIRECTORY
661779
662780 /* Define if printf is overridden by a POSIX compliant gnulib implementation.
663781 */
737855 /* Number of bits in a file offset, on hosts where this is settable. */
738856 #undef _FILE_OFFSET_BITS
739857
858 /* enable compile-time and run-time bounds-checking, and some warnings */
859 #undef _FORTIFY_SOURCE
860
740861 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
741862 #undef _LARGEFILE_SOURCE
742863
787908
788909 /* Define to empty if `const' does not conform to ANSI C. */
789910 #undef const
911
912 /* Define to `int' if <sys/types.h> doesn't define. */
913 #undef gid_t
790914
791915 /* Define to rpl_gmtime if the replacement function should be used. */
792916 #undef gmtime
809933 #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
810934 # define __GNUC_STDC_INLINE__ 1
811935 #endif
936
937 /* Define to 1 if the compiler is checking for lint. */
938 #undef lint
812939
813940 /* Define to rpl_localtime if the replacement function should be used. */
814941 #undef localtime
851978 /* Define to `unsigned int' if <sys/types.h> does not define. */
852979 #undef size_t
853980
854 /* Define as a marker that can be attached to function parameter declarations
855 for parameters that are not used. This helps to reduce warnings, such as
856 from GCC -Wunused-parameter. */
981 /* Define to `int' if <sys/types.h> doesn't define. */
982 #undef uid_t
983
984 /* Define as a marker that can be attached to declarations that might not
985 be used. This helps to reduce warnings, such as from
986 GCC -Wunused-parameter. */
857987 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
858 # define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
988 # define _GL_UNUSED __attribute__ ((__unused__))
859989 #else
860 # define _UNUSED_PARAMETER_
861 #endif
862
990 # define _GL_UNUSED
991 #endif
992 /* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
993 is a misnomer outside of parameter lists. */
994 #define _UNUSED_PARAMETER_ _GL_UNUSED
995
00 /* Invoke creat, but avoid some glitches.
11
2 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
2 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
0 /* A GNU-like <dirent.h>.
1 Copyright (C) 2006-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 #ifndef _GL_DIRENT_H
17
18 #if __GNUC__ >= 3
19 @PRAGMA_SYSTEM_HEADER@
20 #endif
21
22 /* The include_next requires a split double-inclusion guard. */
23 #@INCLUDE_NEXT@ @NEXT_DIRENT_H@
24
25 #ifndef _GL_DIRENT_H
26 #define _GL_DIRENT_H
27
28 /* Get ino_t. Needed on some systems, including glibc 2.8. */
29 #include <sys/types.h>
30
31 /* The definition of GL_LINK_WARNING is copied here. */
32
33 /* The definition of _GL_ARG_NONNULL is copied here. */
34
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /* Declare overridden functions. */
41
42 #if @REPLACE_CLOSEDIR@
43 # define closedir rpl_closedir
44 extern int closedir (DIR *) _GL_ARG_NONNULL ((1));
45 #endif
46
47 #if @GNULIB_DIRFD@
48 # if !@HAVE_DECL_DIRFD@ && !defined dirfd
49 /* Return the file descriptor associated with the given directory stream,
50 or -1 if none exists. */
51 extern int dirfd (DIR *dir) _GL_ARG_NONNULL ((1));
52 # endif
53 #elif defined GNULIB_POSIXCHECK
54 # undef dirfd
55 # define dirfd(d) \
56 (GL_LINK_WARNING ("dirfd is unportable - " \
57 "use gnulib module dirfd for portability"), \
58 dirfd (d))
59 #endif
60
61 #if @GNULIB_FDOPENDIR@
62 # if @REPLACE_FDOPENDIR@
63 # undef fdopendir
64 # define fdopendir rpl_fdopendir
65 # endif
66 # if !@HAVE_FDOPENDIR@ || @REPLACE_FDOPENDIR@
67 /* Open a directory stream visiting the given directory file
68 descriptor. Return NULL and set errno if fd is not visiting a
69 directory. On success, this function consumes fd (it will be
70 implicitly closed either by this function or by a subsequent
71 closedir). */
72 extern DIR *fdopendir (int fd);
73 # endif
74 #elif defined GNULIB_POSIXCHECK
75 # undef fdopendir
76 # define fdopendir(f) \
77 (GL_LINK_WARNING ("fdopendir is unportable - " \
78 "use gnulib module fdopendir for portability"), \
79 fdopendir (f))
80 #endif
81
82 #if @REPLACE_OPENDIR@
83 # define opendir rpl_opendir
84 extern DIR * opendir (const char *) _GL_ARG_NONNULL ((1));
85 #endif
86
87 #if @GNULIB_SCANDIR@
88 /* Scan the directory DIR, calling FILTER on each directory entry.
89 Entries for which FILTER returns nonzero are individually malloc'd,
90 sorted using qsort with CMP, and collected in a malloc'd array in
91 *NAMELIST. Returns the number of entries selected, or -1 on error. */
92 # if !@HAVE_SCANDIR@
93 extern int scandir (const char *dir, struct dirent ***namelist,
94 int (*filter) (const struct dirent *),
95 int (*cmp) (const struct dirent **, const struct dirent **))
96 _GL_ARG_NONNULL ((1, 2, 4));
97 # endif
98 #elif defined GNULIB_POSIXCHECK
99 # undef scandir
100 # define scandir(d,n,f,c) \
101 (GL_LINK_WARNING ("scandir is unportable - " \
102 "use gnulib module scandir for portability"), \
103 scandir (d, n, f, c))
104 #endif
105
106 #if @GNULIB_ALPHASORT@
107 /* Compare two 'struct dirent' entries alphabetically. */
108 # if !@HAVE_ALPHASORT@
109 extern int alphasort (const struct dirent **, const struct dirent **)
110 _GL_ARG_NONNULL ((1, 2));
111 # endif
112 #elif defined GNULIB_POSIXCHECK
113 # undef alphasort
114 # define alphasort(a,b) \
115 (GL_LINK_WARNING ("alphasort is unportable - " \
116 "use gnulib module alphasort for portability"), \
117 alphasort (a, b))
118 #endif
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124
125 #endif /* _GL_DIRENT_H */
126 #endif /* _GL_DIRENT_H */
0 /* dirfd.c -- return the file descriptor associated with an open DIR*
1
2 Copyright (C) 2001, 2006, 2008-2010 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 /* Written by Jim Meyering. */
18
19 #include <config.h>
20
21 #include <dirent.h>
22 #include <errno.h>
23
24 int
25 dirfd (DIR *dir_p)
26 {
27 int fd = DIR_TO_FD (dir_p);
28 if (fd == -1)
29 errno = ENOTSUP;
30 return fd;
31 }
0 /* dirname.c -- return all but the last element in a file name
1
2 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software
3 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 #include "dirname.h"
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 /* Return the length of the prefix of FILE that will be used by
26 dir_name. If FILE is in the working directory, this returns zero
27 even though `dir_name (FILE)' will return ".". Works properly even
28 if there are trailing slashes (by effectively ignoring them). */
29
30 size_t
31 dir_len (char const *file)
32 {
33 size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
34 size_t length;
35
36 /* Advance prefix_length beyond important leading slashes. */
37 prefix_length += (prefix_length != 0
38 ? (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
39 && ISSLASH (file[prefix_length]))
40 : (ISSLASH (file[0])
41 ? ((DOUBLE_SLASH_IS_DISTINCT_ROOT
42 && ISSLASH (file[1]) && ! ISSLASH (file[2])
43 ? 2 : 1))
44 : 0));
45
46 /* Strip the basename and any redundant slashes before it. */
47 for (length = last_component (file) - file;
48 prefix_length < length; length--)
49 if (! ISSLASH (file[length - 1]))
50 break;
51 return length;
52 }
53
54
55 /* In general, we can't use the builtin `dirname' function if available,
56 since it has different meanings in different environments.
57 In some environments the builtin `dirname' modifies its argument.
58
59 Return the leading directories part of FILE, allocated with malloc.
60 Works properly even if there are trailing slashes (by effectively
61 ignoring them). Return NULL on failure.
62
63 If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
64 lstat (base_name (FILE)); } will access the same file. Likewise,
65 if the sequence { chdir (dir_name (FILE));
66 rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
67 to "foo" in the same directory FILE was in. */
68
69 char *
70 mdir_name (char const *file)
71 {
72 size_t length = dir_len (file);
73 bool append_dot = (length == 0
74 || (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
75 && length == FILE_SYSTEM_PREFIX_LEN (file)
76 && file[2] != '\0' && ! ISSLASH (file[2])));
77 char *dir = malloc (length + append_dot + 1);
78 if (!dir)
79 return NULL;
80 memcpy (dir, file, length);
81 if (append_dot)
82 dir[length++] = '.';
83 dir[length] = '\0';
84 return dir;
85 }
0 /* Take file names apart into directory and base names.
1
2 Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation,
3 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 #ifndef DIRNAME_H_
19 # define DIRNAME_H_ 1
20
21 # include <stdbool.h>
22 # include <stddef.h>
23
24 # ifndef DIRECTORY_SEPARATOR
25 # define DIRECTORY_SEPARATOR '/'
26 # endif
27
28 # ifndef ISSLASH
29 # define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
30 # endif
31
32 # ifndef FILE_SYSTEM_PREFIX_LEN
33 # if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
34 /* This internal macro assumes ASCII, but all hosts that support drive
35 letters use ASCII. */
36 # define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
37 <= 'z' - 'a')
38 # define FILE_SYSTEM_PREFIX_LEN(Filename) \
39 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
40 # else
41 # define FILE_SYSTEM_PREFIX_LEN(Filename) 0
42 # endif
43 # endif
44
45 # ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
46 # define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
47 # endif
48
49 # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
50 # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
51 # endif
52
53 # if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
54 # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
55 # else
56 # define IS_ABSOLUTE_FILE_NAME(F) \
57 (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
58 # endif
59 # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
60
61 # if GNULIB_DIRNAME
62 char *base_name (char const *file);
63 char *dir_name (char const *file);
64 # endif
65
66 char *mdir_name (char const *file);
67 size_t base_len (char const *file);
68 size_t dir_len (char const *file);
69 char *last_component (char const *file);
70
71 bool strip_trailing_slashes (char *file);
72
73 #endif /* not DIRNAME_H_ */
00 /* Invoke dup, but avoid some glitches.
11
2 Copyright (C) 2001, 2004, 2005, 2006, 2009 Free Software
3 Foundation, Inc.
2 Copyright (C) 2001, 2004-2006, 2009-2010 Free Software Foundation, Inc.
43
54 This program is free software: you can redistribute it and/or modify
65 it under the terms of the GNU General Public License as published by
2221 #include "unistd-safer.h"
2322
2423 #include <fcntl.h>
25
2624 #include <unistd.h>
2725
2826 /* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
3129 int
3230 dup_safer (int fd)
3331 {
34 #if defined F_DUPFD && !REPLACE_FCHDIR
3532 return fcntl (fd, F_DUPFD, STDERR_FILENO + 1);
36 #else
37 /* fd_safer calls us back, but eventually the recursion unwinds and
38 does the right thing. */
39 return fd_safer (dup (fd));
40 #endif
4133 }
00 /* Duplicate an open file descriptor to a specified file descriptor.
11
2 Copyright (C) 1999, 2004, 2005, 2006, 2007, 2009 Free Software
3 Foundation, Inc.
2 Copyright (C) 1999, 2004-2007, 2009-2010 Free Software Foundation, Inc.
43
54 This program is free software: you can redistribute it and/or modify
65 it under the terms of the GNU General Public License as published by
3130 # include <windows.h>
3231 #endif
3332
34 #if REPLACE_DUP2
33 #if HAVE_DUP2
3534
3635 # undef dup2
3736
5251 }
5352 return fd;
5453 }
54 /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
55 http://bugs.winehq.org/show_bug.cgi?id=21289 */
56 if (desired_fd < 0)
57 {
58 errno = EBADF;
59 return -1;
60 }
5561 # endif
5662 result = dup2 (fd, desired_fd);
5763 # ifdef __linux__
6975 /* Correct a cygwin 1.5.x errno value. */
7076 else if (result == -1 && errno == EMFILE)
7177 errno = EBADF;
72 #if REPLACE_FCHDIR
73 if (fd != desired_fd && result == desired_fd)
74 result = _gl_register_dup (fd, desired_fd);
75 #endif
78 # if REPLACE_FCHDIR
79 if (fd != desired_fd && result != -1)
80 result = _gl_register_dup (fd, result);
81 # endif
7682 return result;
7783 }
7884
79 #else /* !REPLACE_DUP2 */
85 #else /* !HAVE_DUP2 */
8086
8187 /* On older platforms, dup2 did not exist. */
8288
101107 int
102108 dup2 (int fd, int desired_fd)
103109 {
104 int result;
105 if (fd == desired_fd)
106 return fcntl (fd, F_GETFL) < 0 ? -1 : fd;
110 int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
111 if (result == -1 || fd == desired_fd)
112 return result;
107113 close (desired_fd);
108114 # ifdef F_DUPFD
109115 result = fcntl (fd, F_DUPFD, desired_fd);
116 # if REPLACE_FCHDIR
117 if (0 <= result)
118 result = _gl_register_dup (fd, result);
119 # endif
110120 # else
111121 result = dupfd (fd, desired_fd);
112122 # endif
113 #if REPLACE_FCHDIR
114 if (0 <= result)
115 result = _gl_register_dup (fd, desired_fd);
116 #endif
123 if (result == -1 && (errno == EMFILE || errno == EINVAL))
124 errno = EBADF;
117125 return result;
118126 }
119 #endif /* !REPLACE_DUP2 */
127 #endif /* !HAVE_DUP2 */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A POSIX-like <errno.h>.
33
4 Copyright (C) 2008-2009 Free Software Foundation, Inc.
4 Copyright (C) 2008-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
00 /* Error handler for noninteractive utilities
1 Copyright (C) 1990-1998, 2000-2007, 2009 Free Software Foundation, Inc.
1 Copyright (C) 1990-1998, 2000-2007, 2009-2010 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 This program is free software: you can redistribute it and/or modify
6969 extern void __error (int status, int errnum, const char *message, ...)
7070 __attribute__ ((__format__ (__printf__, 3, 4)));
7171 extern void __error_at_line (int status, int errnum, const char *file_name,
72 unsigned int line_number, const char *message,
73 ...)
72 unsigned int line_number, const char *message,
73 ...)
7474 __attribute__ ((__format__ (__printf__, 5, 6)));;
7575 # define error __error
7676 # define error_at_line __error_at_line
8585 #else /* not _LIBC */
8686
8787 # include <fcntl.h>
88 # include <unistd.h>
8889
8990 # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
9091 # ifndef HAVE_DECL_STRERROR_R
99100
100101 # if HAVE_STRERROR_R || defined strerror_r
101102 # define __strerror_r strerror_r
102 # endif /* HAVE_STRERROR_R || defined strerror_r */
103 #endif /* not _LIBC */
103 # endif /* HAVE_STRERROR_R || defined strerror_r */
104 #endif /* not _LIBC */
105
106 static inline void
107 flush_stdout (void)
108 {
109 #if !_LIBC && defined F_GETFL
110 int stdout_fd;
111
112 # if GNULIB_FREOPEN_SAFER
113 /* Use of gnulib's freopen-safer module normally ensures that
114 fileno (stdout) == 1
115 whenever stdout is open. */
116 stdout_fd = STDOUT_FILENO;
117 # else
118 /* POSIX states that fileno (stdout) after fclose is unspecified. But in
119 practice it is not a problem, because stdout is statically allocated and
120 the fd of a FILE stream is stored as a field in its allocated memory. */
121 stdout_fd = fileno (stdout);
122 # endif
123 /* POSIX states that fflush (stdout) after fclose is unspecified; it
124 is safe in glibc, but not on all other platforms. fflush (NULL)
125 is always defined, but too draconian. */
126 if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL))
127 #endif
128 fflush (stdout);
129 }
104130
105131 static void
106132 print_errno_message (int errnum)
148174 bool use_malloc = false;
149175
150176 while (1)
151 {
152 if (__libc_use_alloca (len * sizeof (wchar_t)))
153 wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
154 else
155 {
156 if (!use_malloc)
157 wmessage = NULL;
158
159 wchar_t *p = (wchar_t *) realloc (wmessage,
160 len * sizeof (wchar_t));
161 if (p == NULL)
162 {
163 free (wmessage);
164 fputws_unlocked (L"out of memory\n", stderr);
165 return;
166 }
167 wmessage = p;
168 use_malloc = true;
169 }
170
171 memset (&st, '\0', sizeof (st));
172 tmp = message;
173
174 res = mbsrtowcs (wmessage, &tmp, len, &st);
175 if (res != len)
176 break;
177
178 if (__builtin_expect (len >= SIZE_MAX / 2, 0))
179 {
180 /* This really should not happen if everything is fine. */
181 res = (size_t) -1;
182 break;
183 }
184
185 len *= 2;
186 }
177 {
178 if (__libc_use_alloca (len * sizeof (wchar_t)))
179 wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
180 else
181 {
182 if (!use_malloc)
183 wmessage = NULL;
184
185 wchar_t *p = (wchar_t *) realloc (wmessage,
186 len * sizeof (wchar_t));
187 if (p == NULL)
188 {
189 free (wmessage);
190 fputws_unlocked (L"out of memory\n", stderr);
191 return;
192 }
193 wmessage = p;
194 use_malloc = true;
195 }
196
197 memset (&st, '\0', sizeof (st));
198 tmp = message;
199
200 res = mbsrtowcs (wmessage, &tmp, len, &st);
201 if (res != len)
202 break;
203
204 if (__builtin_expect (len >= SIZE_MAX / 2, 0))
205 {
206 /* This really should not happen if everything is fine. */
207 res = (size_t) -1;
208 break;
209 }
210
211 len *= 2;
212 }
187213
188214 if (res == (size_t) -1)
189 {
190 /* The string cannot be converted. */
191 if (use_malloc)
192 {
193 free (wmessage);
194 use_malloc = false;
195 }
196 wmessage = (wchar_t *) L"???";
197 }
215 {
216 /* The string cannot be converted. */
217 if (use_malloc)
218 {
219 free (wmessage);
220 use_malloc = false;
221 }
222 wmessage = (wchar_t *) L"???";
223 }
198224
199225 __vfwprintf (stderr, wmessage, args);
200226
201227 if (use_malloc)
202 free (wmessage);
228 free (wmessage);
203229 }
204230 else
205231 #endif
234260 cancellation. Therefore disable cancellation for now. */
235261 int state = PTHREAD_CANCEL_ENABLE;
236262 __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
237 0);
238 #endif
239
240 #if !_LIBC && defined F_GETFL
241 /* POSIX states that fflush (stdout) after fclose is unspecified; it
242 is safe in glibc, but not on all other platforms. fflush (NULL)
243 is always defined, but too draconian. */
244 if (0 <= fcntl (1, F_GETFL))
245 #endif
246 fflush (stdout);
263 0);
264 #endif
265
266 flush_stdout ();
247267 #ifdef _LIBC
248268 _IO_flockfile (stderr);
249269 #endif
275295
276296 void
277297 error_at_line (int status, int errnum, const char *file_name,
278 unsigned int line_number, const char *message, ...)
298 unsigned int line_number, const char *message, ...)
279299 {
280300 va_list args;
281301
285305 static unsigned int old_line_number;
286306
287307 if (old_line_number == line_number
288 && (file_name == old_file_name
289 || strcmp (old_file_name, file_name) == 0))
290 /* Simply return and print nothing. */
291 return;
308 && (file_name == old_file_name
309 || strcmp (old_file_name, file_name) == 0))
310 /* Simply return and print nothing. */
311 return;
292312
293313 old_file_name = file_name;
294314 old_line_number = line_number;
299319 cancellation. Therefore disable cancellation for now. */
300320 int state = PTHREAD_CANCEL_ENABLE;
301321 __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
302 0);
303 #endif
304
305 #if !_LIBC && defined F_GETFL
306 /* POSIX states that fflush (stdout) after fclose is unspecified; it
307 is safe in glibc, but not on all other platforms. fflush (NULL)
308 is always defined, but too draconian. */
309 if (0 <= fcntl (1, F_GETFL))
310 #endif
311 fflush (stdout);
322 0);
323 #endif
324
325 flush_stdout ();
312326 #ifdef _LIBC
313327 _IO_flockfile (stderr);
314328 #endif
325339
326340 #if _LIBC
327341 __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
328 file_name, line_number);
342 file_name, line_number);
329343 #else
330344 fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
331 file_name, line_number);
345 file_name, line_number);
332346 #endif
333347
334348 va_start (args, message);
00 /* Declaration for error-reporting function
1 Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc.
1 Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 Free Software
2 Foundation, Inc.
23 This file is part of the GNU C Library.
34
45 This program is free software: you can redistribute it and/or modify
1819 #define _ERROR_H 1
1920
2021 #ifndef __attribute__
21 /* This feature is available in gcc versions 2.5 and later. */
22 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
23 # define __attribute__(Spec) /* empty */
24 # endif
25 /* The __-protected variants of `format' and `printf' attributes
26 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
22 /* The __attribute__ feature is available in gcc versions 2.5 and later.
23 The __-protected variants of the attributes 'format' and 'printf' are
24 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
25 We enable __attribute__ only if these are supported too, because
26 gnulib and libintl do '#define printf __printf__' when they override
27 the 'printf' function. */
2728 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
28 # define __format__ format
29 # define __printf__ printf
29 # define __attribute__(Spec) /* empty */
3030 # endif
3131 #endif
3232
33 #ifdef __cplusplus
33 #ifdef __cplusplus
3434 extern "C" {
3535 #endif
3636
4242 __attribute__ ((__format__ (__printf__, 3, 4)));
4343
4444 extern void error_at_line (int __status, int __errnum, const char *__fname,
45 unsigned int __lineno, const char *__format, ...)
45 unsigned int __lineno, const char *__format, ...)
4646 __attribute__ ((__format__ (__printf__, 5, 6)));
4747
4848 /* If NULL, error will flush stdout, then print on stderr the program
5757 variable controls whether this mode is selected or not. */
5858 extern int error_one_per_line;
5959
60 #ifdef __cplusplus
60 #ifdef __cplusplus
6161 }
6262 #endif
6363
00 /* Failure exit status
11
2 Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
2 Copyright (C) 2002, 2003, 2005, 2006, 2007, 2009, 2010 Free Software
3 Foundation, Inc.
34
45 This program is free software: you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
00 /* Failure exit status
11
2 Copyright (C) 2002 Free Software Foundation, Inc.
2 Copyright (C) 2002, 2009, 2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
0 /* fchdir replacement.
1 Copyright (C) 2006-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 #include <config.h>
17
18 /* Specification. */
19 #include <unistd.h>
20
21 #include <assert.h>
22 #include <dirent.h>
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <stdbool.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <sys/stat.h>
30
31 #ifndef REPLACE_OPEN_DIRECTORY
32 # define REPLACE_OPEN_DIRECTORY 0
33 #endif
34
35 #ifndef HAVE_CANONICALIZE_FILE_NAME
36 # if GNULIB_CANONICALIZE || GNULIB_CANONICALIZE_LGPL
37 # define HAVE_CANONICALIZE_FILE_NAME 1
38 # else
39 # define HAVE_CANONICALIZE_FILE_NAME 0
40 # define canonicalize_file_name(name) NULL
41 # endif
42 #endif
43
44 /* This replacement assumes that a directory is not renamed while opened
45 through a file descriptor.
46
47 FIXME: On mingw, this would be possible to enforce if we were to
48 also open a HANDLE to each directory currently visited by a file
49 descriptor, since mingw refuses to rename any in-use file system
50 object. */
51
52 /* Array of file descriptors opened. If REPLACE_OPEN_DIRECTORY or if it points
53 to a directory, it stores info about this directory. */
54 typedef struct
55 {
56 char *name; /* Absolute name of the directory, or NULL. */
57 /* FIXME - add a DIR* member to make dirfd possible on mingw? */
58 } dir_info_t;
59 static dir_info_t *dirs;
60 static size_t dirs_allocated;
61
62 /* Try to ensure dirs has enough room for a slot at index fd; free any
63 contents already in that slot. Return false and set errno to
64 ENOMEM on allocation failure. */
65 static bool
66 ensure_dirs_slot (size_t fd)
67 {
68 if (fd < dirs_allocated)
69 free (dirs[fd].name);
70 else
71 {
72 size_t new_allocated;
73 dir_info_t *new_dirs;
74
75 new_allocated = 2 * dirs_allocated + 1;
76 if (new_allocated <= fd)
77 new_allocated = fd + 1;
78 new_dirs =
79 (dirs != NULL
80 ? (dir_info_t *) realloc (dirs, new_allocated * sizeof *dirs)
81 : (dir_info_t *) malloc (new_allocated * sizeof *dirs));
82 if (new_dirs == NULL)
83 return false;
84 memset (new_dirs + dirs_allocated, 0,
85 (new_allocated - dirs_allocated) * sizeof *dirs);
86 dirs = new_dirs;
87 dirs_allocated = new_allocated;
88 }
89 return true;
90 }
91
92 /* Return the canonical name of DIR in malloc'd storage. */
93 static char *
94 get_name (char const *dir)
95 {
96 char *result;
97 if (REPLACE_OPEN_DIRECTORY || !HAVE_CANONICALIZE_FILE_NAME)
98 {
99 /* The function canonicalize_file_name has not yet been ported
100 to mingw, with all its drive letter and backslash quirks.
101 Fortunately, getcwd is reliable in this case, but we ensure
102 we can get back to where we started before using it. Treat
103 "." as a special case, as it is frequently encountered. */
104 char *cwd = getcwd (NULL, 0);
105 int saved_errno;
106 if (dir[0] == '.' && dir[1] == '\0')
107 return cwd;
108 if (chdir (cwd))
109 return NULL;
110 result = chdir (dir) ? NULL : getcwd (NULL, 0);
111 saved_errno = errno;
112 if (chdir (cwd))
113 abort ();
114 free (cwd);
115 errno = saved_errno;
116 }
117 else
118 {
119 /* Avoid changing the directory. */
120 result = canonicalize_file_name (dir);
121 }
122 return result;
123 }
124
125 /* Hook into the gnulib replacements for open() and close() to keep track
126 of the open file descriptors. */
127
128 /* Close FD, cleaning up any fd to name mapping if fd was visiting a
129 directory. */
130 void
131 _gl_unregister_fd (int fd)
132 {
133 if (fd >= 0 && fd < dirs_allocated)
134 {
135 free (dirs[fd].name);
136 dirs[fd].name = NULL;
137 }
138 }
139
140 /* Mark FD as visiting FILENAME. FD must be non-negative, and refer
141 to an open file descriptor. If REPLACE_OPEN_DIRECTORY is non-zero,
142 this should only be called if FD is visiting a directory. Close FD
143 and return -1 if there is insufficient memory to track the
144 directory name; otherwise return FD. */
145 int
146 _gl_register_fd (int fd, const char *filename)
147 {
148 struct stat statbuf;
149
150 assert (0 <= fd);
151 if (REPLACE_OPEN_DIRECTORY
152 || (fstat (fd, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)))
153 {
154 if (!ensure_dirs_slot (fd)
155 || (dirs[fd].name = get_name (filename)) == NULL)
156 {
157 int saved_errno = errno;
158 close (fd);
159 errno = saved_errno;
160 return -1;
161 }
162 }
163 return fd;
164 }
165
166 /* Mark NEWFD as a duplicate of OLDFD; useful from dup, dup2, dup3,
167 and fcntl. Both arguments must be valid and distinct file
168 descriptors. Close NEWFD and return -1 if OLDFD is tracking a
169 directory, but there is insufficient memory to track the same
170 directory in NEWFD; otherwise return NEWFD. */
171 int
172 _gl_register_dup (int oldfd, int newfd)
173 {
174 assert (0 <= oldfd && 0 <= newfd && oldfd != newfd);
175 if (oldfd < dirs_allocated && dirs[oldfd].name)
176 {
177 /* Duplicated a directory; must ensure newfd is allocated. */
178 if (!ensure_dirs_slot (newfd)
179 || (dirs[newfd].name = strdup (dirs[oldfd].name)) == NULL)
180 {
181 int saved_errno = errno;
182 close (newfd);
183 errno = saved_errno;
184 newfd = -1;
185 }
186 }
187 else if (newfd < dirs_allocated)
188 {
189 /* Duplicated a non-directory; ensure newfd is cleared. */
190 free (dirs[newfd].name);
191 dirs[newfd].name = NULL;
192 }
193 return newfd;
194 }
195
196 /* If FD is currently visiting a directory, then return the name of
197 that directory. Otherwise, return NULL and set errno. */
198 const char *
199 _gl_directory_name (int fd)
200 {
201 if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL)
202 return dirs[fd].name;
203 /* At this point, fd is either invalid, or open but not a directory.
204 If dup2 fails, errno is correctly EBADF. */
205 if (0 <= fd)
206 {
207 if (dup2 (fd, fd) == fd)
208 errno = ENOTDIR;
209 }
210 else
211 errno = EBADF;
212 return NULL;
213 }
214
215 #if REPLACE_OPEN_DIRECTORY
216 /* Return stat information about FD in STATBUF. Needed when
217 rpl_open() used a dummy file to work around an open() that can't
218 normally visit directories. */
219 # undef fstat
220 int
221 rpl_fstat (int fd, struct stat *statbuf)
222 {
223 if (0 <= fd && fd < dirs_allocated && dirs[fd].name != NULL)
224 return stat (dirs[fd].name, statbuf);
225 return fstat (fd, statbuf);
226 }
227 #endif
228
229 /* Override opendir() and closedir(), to keep track of the open file
230 descriptors. Needed because there is a function dirfd(). */
231
232 int
233 rpl_closedir (DIR *dp)
234 #undef closedir
235 {
236 int fd = dirfd (dp);
237 int retval = closedir (dp);
238
239 if (retval >= 0)
240 _gl_unregister_fd (fd);
241 return retval;
242 }
243
244 DIR *
245 rpl_opendir (const char *filename)
246 #undef opendir
247 {
248 DIR *dp;
249
250 dp = opendir (filename);
251 if (dp != NULL)
252 {
253 int fd = dirfd (dp);
254 if (0 <= fd && _gl_register_fd (fd, filename) != fd)
255 {
256 int saved_errno = errno;
257 closedir (dp);
258 errno = saved_errno;
259 return NULL;
260 }
261 }
262 return dp;
263 }
264
265 /* Override dup(), to keep track of open file descriptors. */
266
267 int
268 rpl_dup (int oldfd)
269 #undef dup
270 {
271 int newfd = dup (oldfd);
272
273 if (0 <= newfd)
274 newfd = _gl_register_dup (oldfd, newfd);
275 return newfd;
276 }
277
278
279 /* Implement fchdir() in terms of chdir(). */
280
281 int
282 fchdir (int fd)
283 {
284 const char *name = _gl_directory_name (fd);
285 return name ? chdir (name) : -1;
286 }
0 /* Change the protections of file relative to an open directory.
1 Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #include <config.h>
19
20 #include <sys/stat.h>
21
22 #include <errno.h>
23
24 #ifndef HAVE_LCHMOD
25 /* Use a different name, to avoid conflicting with any
26 system-supplied declaration. */
27 # undef lchmod
28 # define lchmod lchmod_rpl
29 static int
30 lchmod (char const *f _GL_UNUSED, mode_t m _GL_UNUSED)
31 {
32 errno = ENOSYS;
33 return -1;
34 }
35 #endif
36
37 /* Solaris 10 has no function like this.
38 Invoke chmod or lchmod on file, FILE, using mode MODE, in the directory
39 open on descriptor FD. If possible, do it without changing the
40 working directory. Otherwise, resort to using save_cwd/fchdir,
41 then (chmod|lchmod)/restore_cwd. If either the save_cwd or the
42 restore_cwd fails, then give a diagnostic and exit nonzero.
43 Note that an attempt to use a FLAG value of AT_SYMLINK_NOFOLLOW
44 on a system without lchmod support causes this function to fail. */
45
46 #define AT_FUNC_NAME fchmodat
47 #define AT_FUNC_F1 lchmod
48 #define AT_FUNC_F2 chmod
49 #define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
50 #define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode, int flag
51 #define AT_FUNC_POST_FILE_ARGS , mode
52 #include "at-func.c"
0 #include <config.h>
1
2 #include <sys/types.h>
3 #include <errno.h>
4
5 /* A trivial substitute for `fchown'.
6
7 DJGPP 2.03 and earlier (and perhaps later) don't have `fchown',
8 so we pretend no-one has permission for this operation. */
9
10 int
11 fchown (int fd, uid_t uid, gid_t gid)
12 {
13 errno = EPERM;
14 return -1;
15 }
0 /* This function serves as replacement for a missing fchownat function,
1 as well as a work around for the fchownat bug in glibc-2.4:
2 <http://lists.ubuntu.com/archives/ubuntu-users/2006-September/093218.html>
3 when the buggy fchownat-with-AT_SYMLINK_NOFOLLOW operates on a symlink, it
4 mistakenly affects the symlink referent, rather than the symlink itself.
5
6 Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc.
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21 /* written by Jim Meyering */
22
23 #include <config.h>
24
25 #include <unistd.h>
26
27 #include <errno.h>
28 #include <string.h>
29
30 #include "openat.h"
31
32 #if !HAVE_FCHOWNAT
33
34 /* Replacement for Solaris' function by the same name.
35 Invoke chown or lchown on file, FILE, using OWNER and GROUP, in the
36 directory open on descriptor FD. If FLAG is AT_SYMLINK_NOFOLLOW, then
37 use lchown, otherwise, use chown. If possible, do it without changing
38 the working directory. Otherwise, resort to using save_cwd/fchdir,
39 then (chown|lchown)/restore_cwd. If either the save_cwd or the
40 restore_cwd fails, then give a diagnostic and exit nonzero. */
41
42 # define AT_FUNC_NAME fchownat
43 # define AT_FUNC_F1 lchown
44 # define AT_FUNC_F2 chown
45 # define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
46 # define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group, int flag
47 # define AT_FUNC_POST_FILE_ARGS , owner, group
48 # include "at-func.c"
49 # undef AT_FUNC_NAME
50 # undef AT_FUNC_F1
51 # undef AT_FUNC_F2
52 # undef AT_FUNC_USE_F1_COND
53 # undef AT_FUNC_POST_FILE_PARAM_DECLS
54 # undef AT_FUNC_POST_FILE_ARGS
55
56 #else /* HAVE_FCHOWNAT */
57
58 # undef fchownat
59
60 # if FCHOWNAT_NOFOLLOW_BUG
61
62 /* Failure to handle AT_SYMLINK_NOFOLLOW requires the /proc/self/fd or
63 fchdir workaround to call lchown for lchownat, but there is no need
64 to penalize chownat. */
65 static int
66 local_lchownat (int fd, char const *file, uid_t owner, gid_t group);
67
68 # define AT_FUNC_NAME local_lchownat
69 # define AT_FUNC_F1 lchown
70 # define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group
71 # define AT_FUNC_POST_FILE_ARGS , owner, group
72 # include "at-func.c"
73 # undef AT_FUNC_NAME
74 # undef AT_FUNC_F1
75 # undef AT_FUNC_POST_FILE_PARAM_DECLS
76 # undef AT_FUNC_POST_FILE_ARGS
77
78 # endif
79
80 /* Work around bugs with trailing slash, using the same workarounds as
81 chown and lchown. */
82
83 int
84 rpl_fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
85 {
86 # if FCHOWNAT_NOFOLLOW_BUG
87 if (flag == AT_SYMLINK_NOFOLLOW)
88 return local_lchownat (fd, file, owner, group);
89 # endif
90 # if CHOWN_TRAILING_SLASH_BUG
91 {
92 size_t len = strlen (file);
93 struct stat st;
94 if (len && file[len - 1] == '/')
95 {
96 if (statat (fd, file, &st))
97 return -1;
98 if (flag == AT_SYMLINK_NOFOLLOW)
99 return fchownat (fd, file, owner, group, 0);
100 }
101 }
102 # endif
103 return fchownat (fd, file, owner, group, flag);
104 }
105
106 #endif /* HAVE_FCHOWNAT */
00 /* fclose replacement.
1 Copyright (C) 2008 Free Software Foundation, Inc.
1 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Like fcntl.h, but redefine some names to avoid glitches.
11
2 Copyright (C) 2005, 2009 Free Software Foundation, Inc.
2 Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
00 /* Invoke fcntl-like functions, but avoid some glitches.
11
2 Copyright (C) 2005, 2009 Free Software Foundation, Inc.
2 Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
0 /* Provide file descriptor control.
1
2 Copyright (C) 2009, 2010 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 /* Written by Eric Blake <ebb9@byu.net>. */
18
19 #include <config.h>
20
21 /* Specification. */
22 #include <fcntl.h>
23
24 #include <errno.h>
25 #include <limits.h>
26 #include <stdarg.h>
27 #include <unistd.h>
28
29 #if !HAVE_FCNTL
30 # define rpl_fcntl fcntl
31 #endif
32 #undef fcntl
33
34 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
35 /* Get declarations of the Win32 API functions. */
36 # define WIN32_LEAN_AND_MEAN
37 # include <windows.h>
38
39 /* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
40 # define OPEN_MAX_MAX 0x10000
41
42 /* Duplicate OLDFD into the first available slot of at least NEWFD,
43 which must be positive, with FLAGS determining whether the duplicate
44 will be inheritable. */
45 static int
46 dupfd (int oldfd, int newfd, int flags)
47 {
48 /* Mingw has no way to create an arbitrary fd. Iterate until all
49 file descriptors less than newfd are filled up. */
50 HANDLE curr_process = GetCurrentProcess ();
51 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
52 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
53 unsigned int fds_to_close_bound = 0;
54 int result;
55 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
56 int mode;
57
58 if (newfd < 0 || getdtablesize () <= newfd)
59 {
60 errno = EINVAL;
61 return -1;
62 }
63 if (old_handle == INVALID_HANDLE_VALUE
64 || (mode = setmode (oldfd, O_BINARY)) == -1)
65 {
66 /* oldfd is not open, or is an unassigned standard file
67 descriptor. */
68 errno = EBADF;
69 return -1;
70 }
71 setmode (oldfd, mode);
72 flags |= mode;
73
74 for (;;)
75 {
76 HANDLE new_handle;
77 int duplicated_fd;
78 unsigned int index;
79
80 if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
81 old_handle, /* SourceHandle */
82 curr_process, /* TargetProcessHandle */
83 (PHANDLE) &new_handle, /* TargetHandle */
84 (DWORD) 0, /* DesiredAccess */
85 inherit, /* InheritHandle */
86 DUPLICATE_SAME_ACCESS)) /* Options */
87 {
88 /* TODO: Translate GetLastError () into errno. */
89 errno = EMFILE;
90 result = -1;
91 break;
92 }
93 duplicated_fd = _open_osfhandle ((long) new_handle, flags);
94 if (duplicated_fd < 0)
95 {
96 CloseHandle (new_handle);
97 errno = EMFILE;
98 result = -1;
99 break;
100 }
101 if (newfd <= duplicated_fd)
102 {
103 result = duplicated_fd;
104 break;
105 }
106
107 /* Set the bit duplicated_fd in fds_to_close[]. */
108 index = (unsigned int) duplicated_fd / CHAR_BIT;
109 if (fds_to_close_bound <= index)
110 {
111 if (sizeof fds_to_close <= index)
112 /* Need to increase OPEN_MAX_MAX. */
113 abort ();
114 memset (fds_to_close + fds_to_close_bound, '\0',
115 index + 1 - fds_to_close_bound);
116 fds_to_close_bound = index + 1;
117 }
118 fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
119 }
120
121 /* Close the previous fds that turned out to be too small. */
122 {
123 int saved_errno = errno;
124 unsigned int duplicated_fd;
125
126 for (duplicated_fd = 0;
127 duplicated_fd < fds_to_close_bound * CHAR_BIT;
128 duplicated_fd++)
129 if ((fds_to_close[duplicated_fd / CHAR_BIT]
130 >> (duplicated_fd % CHAR_BIT))
131 & 1)
132 close (duplicated_fd);
133
134 errno = saved_errno;
135 }
136
137 # if REPLACE_FCHDIR
138 if (0 <= result)
139 result = _gl_register_dup (oldfd, result);
140 # endif
141 return result;
142 }
143 #endif /* W32 */
144
145 /* Perform the specified ACTION on the file descriptor FD, possibly
146 using the argument ARG further described below. This replacement
147 handles the following actions, and forwards all others on to the
148 native fcntl. An unrecognized ACTION returns -1 with errno set to
149 EINVAL.
150
151 F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
152 If successful, return the duplicate, which will be inheritable;
153 otherwise return -1 and set errno.
154
155 F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
156 target fd. If successful, return the duplicate, which will not be
157 inheritable; otherwise return -1 and set errno.
158
159 F_GETFD - ARG need not be present. If successful, return a
160 non-negative value containing the descriptor flags of FD (only
161 FD_CLOEXEC is portable, but other flags may be present); otherwise
162 return -1 and set errno. */
163
164 int
165 rpl_fcntl (int fd, int action, /* arg */...)
166 {
167 va_list arg;
168 int result = -1;
169 va_start (arg, action);
170 switch (action)
171 {
172
173 #if !HAVE_FCNTL
174 case F_DUPFD:
175 {
176 int target = va_arg (arg, int);
177 result = dupfd (fd, target, 0);
178 break;
179 }
180 #elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
181 case F_DUPFD:
182 {
183 int target = va_arg (arg, int);
184 /* Detect invalid target; needed for cygwin 1.5.x. */
185 if (target < 0 || getdtablesize () <= target)
186 errno = EINVAL;
187 else
188 {
189 result = fcntl (fd, action, target);
190 # if REPLACE_FCHDIR
191 if (0 <= result)
192 result = _gl_register_dup (fd, result);
193 # endif
194 }
195 break;
196 } /* F_DUPFD */
197 #endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */
198
199 case F_DUPFD_CLOEXEC:
200 {
201 int target = va_arg (arg, int);
202
203 #if !HAVE_FCNTL
204 result = dupfd (fd, target, O_CLOEXEC);
205 break;
206 #else /* HAVE_FCNTL */
207 /* Try the system call first, if the headers claim it exists
208 (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
209 may be running with a glibc that has the macro but with an
210 older kernel that does not support it. Cache the
211 information on whether the system call really works, but
212 avoid caching failure if the corresponding F_DUPFD fails
213 for any reason. 0 = unknown, 1 = yes, -1 = no. */
214 static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
215 if (0 <= have_dupfd_cloexec)
216 {
217 result = fcntl (fd, action, target);
218 if (0 <= result || errno != EINVAL)
219 {
220 have_dupfd_cloexec = 1;
221 # if REPLACE_FCHDIR
222 if (0 <= result)
223 result = _gl_register_dup (fd, result);
224 # endif
225 }
226 else
227 {
228 result = rpl_fcntl (fd, F_DUPFD, target);
229 if (result < 0)
230 break;
231 have_dupfd_cloexec = -1;
232 }
233 }
234 else
235 result = rpl_fcntl (fd, F_DUPFD, target);
236 if (0 <= result && have_dupfd_cloexec == -1)
237 {
238 int flags = fcntl (result, F_GETFD);
239 if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
240 {
241 int saved_errno = errno;
242 close (result);
243 errno = saved_errno;
244 result = -1;
245 }
246 }
247 break;
248 #endif /* HAVE_FCNTL */
249 } /* F_DUPFD_CLOEXEC */
250
251 #if !HAVE_FCNTL
252 case F_GETFD:
253 {
254 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
255 HANDLE handle = (HANDLE) _get_osfhandle (fd);
256 DWORD flags;
257 if (handle == INVALID_HANDLE_VALUE
258 || GetHandleInformation (handle, &flags) == 0)
259 errno = EBADF;
260 else
261 result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
262 # else /* !W32 */
263 /* Use dup2 to reject invalid file descriptors. No way to
264 access this information, so punt. */
265 if (0 <= dup2 (fd, fd))
266 result = 0;
267 # endif /* !W32 */
268 break;
269 } /* F_GETFD */
270 #endif /* !HAVE_FCNTL */
271
272 /* Implementing F_SETFD on mingw is not trivial - there is no
273 API for changing the O_NOINHERIT bit on an fd, and merely
274 changing the HANDLE_FLAG_INHERIT bit on the underlying handle
275 can lead to odd state. It may be possible by duplicating the
276 handle, using _open_osfhandle with the right flags, then
277 using dup2 to move the duplicate onto the original, but that
278 is not supported for now. */
279
280 default:
281 {
282 #if HAVE_FCNTL
283 void *p = va_arg (arg, void *);
284 result = fcntl (fd, action, p);
285 #else
286 errno = EINVAL;
287 #endif
288 break;
289 }
290 }
291 va_end (arg);
292 return result;
293 }
00 /* Like <fcntl.h>, but with non-working flags defined to 0.
11
2 Copyright (C) 2006-2009 Free Software Foundation, Inc.
2 Copyright (C) 2006-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
2424 /* Special invocation convention. */
2525
2626 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <unistd.h>
27 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
28 # include <sys/stat.h>
29 #endif
2930 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
3031
3132 #else
3435 #ifndef _GL_FCNTL_H
3536
3637 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <unistd.h>
38 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
39 # include <sys/stat.h>
40 #endif
3941 /* The include_next requires a split double-inclusion guard. */
4042 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
4143
4244 #ifndef _GL_FCNTL_H
4345 #define _GL_FCNTL_H
4446
47 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
48 # include <unistd.h>
49 #endif
50
4551
4652 /* The definition of GL_LINK_WARNING is copied here. */
53
54 /* The definition of _GL_ARG_NONNULL is copied here. */
4755
4856
4957 /* Declare overridden functions. */
5058
5159 #ifdef __cplusplus
5260 extern "C" {
61 #endif
62
63 #if @GNULIB_FCNTL@
64 # if @REPLACE_FCNTL@
65 # undef fcntl
66 # define fcntl rpl_fcntl
67 # endif
68 # if !@HAVE_FCNTL@ || @REPLACE_FCNTL@
69 extern int fcntl (int fd, int action, ...);
70 # endif
71 #elif defined GNULIB_POSIXCHECK
72 # undef fcntl
73 # define fcntl \
74 (GL_LINK_WARNING ("fcntl is not always POSIX compliant - " \
75 "use gnulib module fcntl for portability"), \
76 fcntl)
5377 #endif
5478
5579 #if @GNULIB_OPEN@
5680 # if @REPLACE_OPEN@
5781 # undef open
5882 # define open rpl_open
59 extern int open (const char *filename, int flags, ...);
60 # endif
83 extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1));
84 # endif
85 #elif defined GNULIB_POSIXCHECK
86 # undef open
87 # define open \
88 (GL_LINK_WARNING ("open is not always POSIX compliant - " \
89 "use gnulib module open for portability"), \
90 open)
6191 #endif
6292
6393 #if @GNULIB_OPENAT@
6696 # define openat rpl_openat
6797 # endif
6898 # if !@HAVE_OPENAT@ || @REPLACE_OPENAT@
69 int openat (int fd, char const *file, int flags, /* mode_t mode */ ...);
99 extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
100 _GL_ARG_NONNULL ((2));
70101 # endif
71102 #elif defined GNULIB_POSIXCHECK
72103 # undef openat
73 # define openat(f,u,g) \
104 # define openat \
74105 (GL_LINK_WARNING ("openat is not portable - " \
75106 "use gnulib module openat for portability"), \
76107 openat)
80111 }
81112 #endif
82113
83 /* Fix up the FD_* macros. */
114 /* Fix up the FD_* macros, only known to be missing on mingw. */
84115
85116 #ifndef FD_CLOEXEC
86117 # define FD_CLOEXEC 1
118 #endif
119
120 /* Fix up the supported F_* macros. Intentionally leave other F_*
121 macros undefined. Only known to be missing on mingw. */
122
123 #ifndef F_DUPFD_CLOEXEC
124 # define F_DUPFD_CLOEXEC 0x40000000
125 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
126 # define GNULIB_defined_F_DUPFD_CLOEXEC 1
127 #else
128 # define GNULIB_defined_F_DUPFD_CLOEXEC 0
129 #endif
130
131 #ifndef F_DUPFD
132 # define F_DUPFD 1
133 #endif
134
135 #ifndef F_GETFD
136 # define F_GETFD 2
87137 #endif
88138
89139 /* Fix up the O_* macros. */
00 /* Return a safer copy of a file descriptor.
11
2 Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
2 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
2121 #include "unistd-safer.h"
2222
2323 #include <errno.h>
24
2524 #include <unistd.h>
2625
2726 /* Return FD, unless FD would be a copy of standard input, output, or
0 /* provide a replacement fdopendir function
1 Copyright (C) 2004-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #include <config.h>
19
20 #include <dirent.h>
21
22 #include <stdlib.h>
23 #include <unistd.h>
24
25 #if !HAVE_FDOPENDIR
26
27 # include "openat.h"
28 # include "openat-priv.h"
29 # include "save-cwd.h"
30
31 # if GNULIB_DIRENT_SAFER
32 # include "dirent--.h"
33 # endif
34
35 /* Replacement for Solaris' function by the same name.
36 <http://www.google.com/search?q=fdopendir+site:docs.sun.com>
37 First, try to simulate it via opendir ("/proc/self/fd/FD"). Failing
38 that, simulate it by using fchdir metadata, or by doing
39 save_cwd/fchdir/opendir(".")/restore_cwd.
40 If either the save_cwd or the restore_cwd fails (relatively unlikely),
41 then give a diagnostic and exit nonzero.
42 Otherwise, this function works just like Solaris' fdopendir.
43
44 W A R N I N G:
45 Unlike other fd-related functions, this one effectively consumes
46 its FD parameter. The caller should not close or otherwise
47 manipulate FD if this function returns successfully. Also, this
48 implementation does not guarantee that dirfd(fdopendir(n))==n;
49 the open directory stream may use a clone of FD, or have no
50 associated fd at all. */
51 DIR *
52 fdopendir (int fd)
53 {
54 int saved_errno;
55 DIR *dir;
56
57 char buf[OPENAT_BUFFER_SIZE];
58 char *proc_file = openat_proc_name (buf, fd, ".");
59 if (proc_file)
60 {
61 dir = opendir (proc_file);
62 saved_errno = errno;
63 }
64 else
65 {
66 dir = NULL;
67 saved_errno = EOPNOTSUPP;
68 }
69
70 /* If the syscall fails with an expected errno value, resort to
71 save_cwd/restore_cwd. */
72 if (! dir && EXPECTED_ERRNO (saved_errno))
73 {
74 # if REPLACE_FCHDIR
75 const char *name = _gl_directory_name (fd);
76 if (name)
77 dir = opendir (name);
78 saved_errno = errno;
79 # else /* !REPLACE_FCHDIR */
80 struct saved_cwd saved_cwd;
81 if (save_cwd (&saved_cwd) != 0)
82 openat_save_fail (errno);
83
84 if (fchdir (fd) != 0)
85 {
86 dir = NULL;
87 saved_errno = errno;
88 }
89 else
90 {
91 dir = opendir (".");
92 saved_errno = errno;
93
94 if (restore_cwd (&saved_cwd) != 0)
95 openat_restore_fail (errno);
96 }
97
98 free_cwd (&saved_cwd);
99 # endif /* !REPLACE_FCHDIR */
100 }
101
102 if (dir)
103 close (fd);
104 if (proc_file != buf)
105 free (proc_file);
106 errno = saved_errno;
107 return dir;
108 }
109
110 #else /* HAVE_FDOPENDIR */
111
112 # include <errno.h>
113 # include <sys/stat.h>
114
115 # undef fdopendir
116
117 /* Like fdopendir, but work around GNU/Hurd bug by validating FD. */
118
119 DIR *
120 rpl_fdopendir (int fd)
121 {
122 struct stat st;
123 if (fstat (fd, &st))
124 return NULL;
125 if (!S_ISDIR (st.st_mode))
126 {
127 errno = ENOTDIR;
128 return NULL;
129 }
130 return fdopendir (fd);
131 }
132
133 #endif /* HAVE_FDOPENDIR */
00 /* fflush.c -- allow flushing input streams
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
3838 {
3939 if (fp->_flags & _IO_IN_BACKUP)
4040 /* _IO_free_backup_area is a bit complicated. Simply call fseek. */
41 fseek (fp, 0, SEEK_CUR);
41 fseeko (fp, 0, SEEK_CUR);
4242 }
4343
4444 #else
6262 # elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
6363 /* Nothing to do. */
6464 # else /* other implementations */
65 fseek (fp, 0, SEEK_CUR);
65 fseeko (fp, 0, SEEK_CUR);
6666 # endif
6767 }
6868
9090 update_fpos_cache (FILE *fp, off_t pos)
9191 {
9292 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
93 # if defined __CYGWIN__
94 /* fp_->_offset is typed as an integer. */
9395 fp_->_offset = pos;
96 # else
97 /* fp_->_offset is an fpos_t. */
98 /* Use a union, since on NetBSD, the compilation flags determine
99 whether fpos_t is typedef'd to off_t or a struct containing a
100 single off_t member. */
101 union
102 {
103 fpos_t f;
104 off_t o;
105 } u;
106 u.o = pos;
107 fp_->_offset = u.f;
108 # endif
94109 fp_->_flags |= __SOFF;
95110 #endif
96111 }
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Supplemental information about the floating-point formats.
3 Copyright (C) 2007 Free Software Foundation, Inc.
3 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
44 Written by Bruno Haible <bruno@clisp.org>, 2007.
55
66 This program is free software; you can redistribute it and/or modify
00 /* A correct <float.h>.
11
2 Copyright (C) 2007-2008 Free Software Foundation, Inc.
2 Copyright (C) 2007-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
00 /* fpending.c -- return the number of pending output bytes on a stream
1 Copyright (C) 2000, 2004, 2006, 2007 Free Software Foundation, Inc.
1 Copyright (C) 2000, 2004, 2006-2007, 2009-2010 Free Software Foundation,
2 Inc.
23
34 This program is free software: you can redistribute it and/or modify
45 it under the terms of the GNU General Public License as published by
00 /* Declare __fpending.
11
2 Copyright (C) 2000, 2003, 2005, 2006 Free Software Foundation, Inc.
2 Copyright (C) 2000, 2003, 2005-2006, 2009-2010 Free Software Foundation,
3 Inc.
34
45 This program is free software: you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
00 /* Formatted output to a stream.
1 Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
1 Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
5454 if (fwrite (output, 1, len, fp) < len)
5555 {
5656 if (output != buf)
57 {
58 int saved_errno = errno;
59 free (output);
60 errno = saved_errno;
61 }
57 {
58 int saved_errno = errno;
59 free (output);
60 errno = saved_errno;
61 }
6262 return -1;
6363 }
64
65 if (output != buf)
66 free (output);
6467
6568 if (len > INT_MAX)
6669 {
00 /* Manipulating the FPU control word.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 Written by Bruno Haible <bruno@clisp.org>, 2007.
33
44 This program is free software: you can redistribute it and/or modify
6969 # define FPU_PC_EXTENDED 0x300 /* glibc calls this _FPU_EXTENDED */
7070
7171 # define GET_FPUCW() \
72 ({ fpucw_t _cw; \
73 __asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \
74 _cw; \
72 ({ fpucw_t _cw; \
73 __asm__ __volatile__ ("fnstcw %0" : "=m" (*&_cw)); \
74 _cw; \
7575 })
7676 # define SET_FPUCW(word) \
77 (void)({ fpucw_t _ncw = (word); \
78 __asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \
77 (void)({ fpucw_t _ncw = (word); \
78 __asm__ __volatile__ ("fldcw %0" : : "m" (*&_ncw)); \
7979 })
8080
8181 # define DECL_LONG_DOUBLE_ROUNDING \
8282 fpucw_t oldcw;
8383 # define BEGIN_LONG_DOUBLE_ROUNDING() \
84 (void)(oldcw = GET_FPUCW (), \
84 (void)(oldcw = GET_FPUCW (), \
8585 SET_FPUCW ((oldcw & ~FPU_PC_MASK) | FPU_PC_EXTENDED))
8686 # define END_LONG_DOUBLE_ROUNDING() \
8787 SET_FPUCW (oldcw)
00 /* Flushing buffers of a FILE stream.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
7474 fp_->_p = fp_->_bf._base;
7575 fp_->_r = 0;
7676 fp_->_w = ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
77 ? fp_->_bf._size
78 : 0);
77 ? fp_->_bf._size
78 : 0);
7979 /* Avoid memory leak when there is an active ungetc buffer. */
8080 if (fp_ub._base != NULL)
8181 {
8282 if (fp_ub._base != fp_->_ubuf)
83 free (fp_ub._base);
83 free (fp_ub._base);
8484 fp_ub._base = NULL;
8585 }
8686 return 0;
00 /* Retrieve information about a FILE stream.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
2828 if (fp->_IO_write_ptr > fp->_IO_write_base)
2929 return 0;
3030 return (fp->_IO_read_end - fp->_IO_read_ptr)
31 + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
32 0);
31 + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
32 0);
3333 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
3434 if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
3535 return 0;
3737 return __sreadahead (fp);
3838 # else
3939 return fp_->_r
40 + (HASUB (fp) ? fp_->_ur : 0);
40 + (HASUB (fp) ? fp_->_ur : 0);
4141 # endif
4242 #elif defined __EMX__ /* emx+gcc */
4343 if ((fp->_flags & _IOWRT) != 0)
5656 if (fp->__modeflags & __FLAG_WRITING)
5757 return 0;
5858 return (fp->__bufread - fp->__bufpos)
59 + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0);
59 + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0);
6060 # else
6161 return 0;
6262 # endif
6666 /* fp->_Buf <= fp->_Next <= fp->_Rend,
6767 and fp->_Rend may be overridden by fp->_Rsave. */
6868 return ((fp->_Rsave ? fp->_Rsave : fp->_Rend) - fp->_Next)
69 + (fp->_Mode & 0x4000 /* _MBYTE */
70 ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback
71 : 0);
69 + (fp->_Mode & 0x4000 /* _MBYTE */
70 ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback
71 : 0);
7272 #elif defined __MINT__ /* Atari FreeMiNT */
7373 if (!fp->__mode.__read)
7474 return 0;
7575 return (fp->__pushed_back
76 ? fp->__get_limit - fp->__pushback_bufp + 1
77 : fp->__get_limit - fp->__bufp);
76 ? fp->__get_limit - fp->__pushback_bufp + 1
77 : fp->__get_limit - fp->__bufp);
7878 #elif defined SLOW_BUT_NO_HACKS /* users can define this */
7979 abort ();
8080 return 0;
00 /* Retrieve information about a FILE stream.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Retrieve information about a FILE stream.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
3232 fast macros. */
3333 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
3434 return ((fp->_flags & _IO_NO_WRITES) != 0
35 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
36 && fp->_IO_read_base != NULL));
35 || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
36 && fp->_IO_read_base != NULL));
3737 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
3838 return (fp_->_flags & __SRD) != 0;
3939 #elif defined __EMX__ /* emx+gcc */
4444 return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
4545 #elif defined __QNX__ /* QNX */
4646 return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
47 || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
47 || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
4848 #elif defined __MINT__ /* Atari FreeMiNT */
4949 if (!fp->__mode.__write)
5050 return 1;
00 /* Retrieve information about a FILE stream.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Split a double into fraction and mantissa.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
8484 exponent = 0;
8585 if (x >= L_(1.0))
8686 {
87 /* A positive exponent. */
88 DOUBLE pow2_i; /* = pow2[i] */
89 DOUBLE powh_i; /* = powh[i] */
87 /* A positive exponent. */
88 DOUBLE pow2_i; /* = pow2[i] */
89 DOUBLE powh_i; /* = powh[i] */
9090
91 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
92 x * 2^exponent = argument, x >= 1.0. */
93 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
94 ;
95 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
96 {
97 if (x >= pow2_i)
98 {
99 exponent += (1 << i);
100 x *= powh_i;
101 }
102 else
103 break;
91 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
92 x * 2^exponent = argument, x >= 1.0. */
93 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
94 ;
95 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
96 {
97 if (x >= pow2_i)
98 {
99 exponent += (1 << i);
100 x *= powh_i;
101 }
102 else
103 break;
104104
105 pow2[i] = pow2_i;
106 powh[i] = powh_i;
107 }
108 /* Avoid making x too small, as it could become a denormalized
109 number and thus lose precision. */
110 while (i > 0 && x < pow2[i - 1])
111 {
112 i--;
113 powh_i = powh[i];
114 }
115 exponent += (1 << i);
116 x *= powh_i;
117 /* Here 2^-2^i <= x < 1.0. */
105 pow2[i] = pow2_i;
106 powh[i] = powh_i;
107 }
108 /* Avoid making x too small, as it could become a denormalized
109 number and thus lose precision. */
110 while (i > 0 && x < pow2[i - 1])
111 {
112 i--;
113 powh_i = powh[i];
114 }
115 exponent += (1 << i);
116 x *= powh_i;
117 /* Here 2^-2^i <= x < 1.0. */
118118 }
119119 else
120120 {
121 /* A negative or zero exponent. */
122 DOUBLE pow2_i; /* = pow2[i] */
123 DOUBLE powh_i; /* = powh[i] */
121 /* A negative or zero exponent. */
122 DOUBLE pow2_i; /* = pow2[i] */
123 DOUBLE powh_i; /* = powh[i] */
124124
125 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
126 x * 2^exponent = argument, x < 1.0. */
127 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
128 ;
129 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
130 {
131 if (x < powh_i)
132 {
133 exponent -= (1 << i);
134 x *= pow2_i;
135 }
136 else
137 break;
125 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
126 x * 2^exponent = argument, x < 1.0. */
127 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
128 ;
129 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
130 {
131 if (x < powh_i)
132 {
133 exponent -= (1 << i);
134 x *= pow2_i;
135 }
136 else
137 break;
138138
139 pow2[i] = pow2_i;
140 powh[i] = powh_i;
141 }
142 /* Here 2^-2^i <= x < 1.0. */
139 pow2[i] = pow2_i;
140 powh[i] = powh_i;
141 }
142 /* Here 2^-2^i <= x < 1.0. */
143143 }
144144
145145 /* Invariants: x * 2^exponent = argument, and 2^-2^i <= x < 1.0. */
146146 while (i > 0)
147147 {
148 i--;
149 if (x < powh[i])
150 {
151 exponent -= (1 << i);
152 x *= pow2[i];
153 }
148 i--;
149 if (x < powh[i])
150 {
151 exponent -= (1 << i);
152 x *= pow2[i];
153 }
154154 }
155155 /* Here 0.5 <= x < 1.0. */
156156 }
00 /* Split a 'long double' into fraction and mantissa.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* An fseeko() function that, together with fflush(), is POSIX compliant.
3 Copyright (C) 2007-2009 Free Software Foundation, Inc.
3 Copyright (C) 2007-2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
5151 if ((fp->_flags & __SL64) == 0)
5252 {
5353 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
54 mode; but has an fseeko that requires 64-bit mode. */
54 mode; but has an fseeko that requires 64-bit mode. */
5555 FILE *tmp = fopen ("/dev/null", "r");
5656 if (!tmp)
57 return -1;
57 return -1;
5858 fp->_flags |= __SL64;
5959 fp->_seek64 = tmp->_seek64;
6060 fclose (tmp);
6363 if (fp_->_p == fp_->_bf._base
6464 && fp_->_r == 0
6565 && fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
66 ? fp_->_bf._size
67 : 0)
66 ? fp_->_bf._size
67 : 0)
6868 && fp_ub._base == NULL)
6969 #elif defined __EMX__ /* emx+gcc */
7070 if (fp->_ptr == fp->_buffer
7878 if (((fp->__modeflags & __FLAG_WRITING) == 0
7979 || fp->__bufpos == fp->__bufstart)
8080 && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
81 || fp->__bufpos == fp->__bufread))
81 || fp->__bufpos == fp->__bufread))
8282 #elif defined __QNX__ /* QNX */
8383 if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
8484 && fp->_Rback == fp->_Back + sizeof (fp->_Back)
9393 #endif
9494 {
9595 /* We get here when an fflush() call immediately preceded this one. We
96 know there are no buffers.
97 POSIX requires us to modify the file descriptor's position.
98 But we cannot position beyond end of file here. */
96 know there are no buffers.
97 POSIX requires us to modify the file descriptor's position.
98 But we cannot position beyond end of file here. */
9999 off_t pos =
100 lseek (fileno (fp),
101 whence == SEEK_END && offset > 0 ? 0 : offset,
102 whence);
100 lseek (fileno (fp),
101 whence == SEEK_END && offset > 0 ? 0 : offset,
102 whence);
103103 if (pos == -1)
104 {
104 {
105105 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
106 fp_->_flags &= ~__SOFF;
106 fp_->_flags &= ~__SOFF;
107107 #endif
108 return -1;
109 }
108 return -1;
109 }
110110
111111 #if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
112112 fp->_flags &= ~_IO_EOF_SEEN;
113113 #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
114 # if defined __CYGWIN__
115 /* fp_->_offset is typed as an integer. */
114116 fp_->_offset = pos;
117 # else
118 /* fp_->_offset is an fpos_t. */
119 {
120 /* Use a union, since on NetBSD, the compilation flags
121 determine whether fpos_t is typedef'd to off_t or a struct
122 containing a single off_t member. */
123 union
124 {
125 fpos_t f;
126 off_t o;
127 } u;
128 u.o = pos;
129 fp_->_offset = u.f;
130 }
131 # endif
115132 fp_->_flags |= __SOFF;
116133 fp_->_flags &= ~__SEOF;
117134 #elif defined __EMX__ /* emx+gcc */
123140 fp->__eof = 0;
124141 #endif
125142 /* If we were not requested to position beyond end of file, we're
126 done. */
143 done. */
127144 if (!(whence == SEEK_END && offset > 0))
128 return 0;
145 return 0;
129146 }
130147 return fseeko (fp, offset, whence);
131148 }
00 /* Set the error indicator of a stream.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
6262 fputc ('\0', fp); /* This should set the error indicator. */
6363 fflush (fp); /* Or this. */
6464 if (dup2 (fd2, fd) < 0)
65 /* Whee... we botched the stream and now cannot restore it! */
66 abort ();
65 /* Whee... we botched the stream and now cannot restore it! */
66 abort ();
6767 close (fd2);
6868 }
6969 errno = saved_errno;
00 /* Set the error indicator of a stream.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
0 /* Work around an fstatat bug on Solaris 9.
1
2 Copyright (C) 2006, 2009-2010 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 /* Written by Paul Eggert and Jim Meyering. */
18
19 #include <config.h>
20
21 #include <sys/stat.h>
22
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <string.h>
26
27 #if HAVE_FSTATAT
28
29 # undef fstatat
30
31 /* fstatat should always follow symbolic links that end in /, but on
32 Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified.
33 Likewise, trailing slash on a non-directory should be an error.
34 These are the same problems that lstat.c and stat.c address, so
35 solve it in a similar way. */
36
37 int
38 rpl_fstatat (int fd, char const *file, struct stat *st, int flag)
39 {
40 int result = fstatat (fd, file, st, flag);
41 size_t len;
42
43 if (result != 0)
44 return result;
45 len = strlen (file);
46 if (flag & AT_SYMLINK_NOFOLLOW)
47 {
48 /* Fix lstat behavior. */
49 if (file[len - 1] != '/' || S_ISDIR (st->st_mode))
50 return 0;
51 if (!S_ISLNK (st->st_mode))
52 {
53 errno = ENOTDIR;
54 return -1;
55 }
56 result = fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW);
57 }
58 /* Fix stat behavior. */
59 if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/')
60 {
61 errno = ENOTDIR;
62 return -1;
63 }
64 return result;
65 }
66
67 #else /* !HAVE_FSTATAT */
68
69 /* On mingw, the gnulib <sys/stat.h> defines `stat' as a function-like
70 macro; but using it in AT_FUNC_F2 causes compilation failure
71 because the preprocessor sees a use of a macro that requires two
72 arguments but is only given one. Hence, we need an inline
73 forwarder to get past the preprocessor. */
74 static inline int
75 stat_func (char const *name, struct stat *st)
76 {
77 return stat (name, st);
78 }
79
80 /* Likewise, if there is no native `lstat', then the gnulib
81 <sys/stat.h> defined it as stat, which also needs adjustment. */
82 # if !HAVE_LSTAT
83 # undef lstat
84 # define lstat stat_func
85 # endif
86
87 /* Replacement for Solaris' function by the same name.
88 <http://www.google.com/search?q=fstatat+site:docs.sun.com>
89 First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE").
90 Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd.
91 If either the save_cwd or the restore_cwd fails (relatively unlikely),
92 then give a diagnostic and exit nonzero.
93 Otherwise, this function works just like Solaris' fstatat. */
94
95 # define AT_FUNC_NAME fstatat
96 # define AT_FUNC_F1 lstat
97 # define AT_FUNC_F2 stat_func
98 # define AT_FUNC_USE_F1_COND AT_SYMLINK_NOFOLLOW
99 # define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag
100 # define AT_FUNC_POST_FILE_ARGS , st
101 # include "at-func.c"
102 # undef AT_FUNC_NAME
103 # undef AT_FUNC_F1
104 # undef AT_FUNC_F2
105 # undef AT_FUNC_USE_F1_COND
106 # undef AT_FUNC_POST_FILE_PARAM_DECLS
107 # undef AT_FUNC_POST_FILE_ARGS
108
109 #endif /* !HAVE_FSTATAT */
00 /* An ftello() function that works around platform bugs.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
4040 if ((fp->_flags & __SL64) == 0)
4141 {
4242 /* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
43 mode; but has an ftello that requires 64-bit mode. */
43 mode; but has an ftello that requires 64-bit mode. */
4444 FILE *tmp = fopen ("/dev/null", "r");
4545 if (!tmp)
46 return -1;
46 return -1;
4747 fp->_flags |= __SL64;
4848 fp->_seek64 = tmp->_seek64;
4949 fclose (tmp);
0 /* Copyright (C) 1991-1999, 2004-2010 Free Software Foundation, Inc.
1 This file is part of the GNU C Library.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 #if !_LIBC
17 # include <config.h>
18 # include <unistd.h>
19 #endif
20
21 #include <errno.h>
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <stdbool.h>
25 #include <stddef.h>
26
27 #include <fcntl.h> /* For AT_FDCWD on Solaris 9. */
28
29 /* If this host provides the openat function, then enable
30 code below to make getcwd more efficient and robust. */
31 #ifdef HAVE_OPENAT
32 # define HAVE_OPENAT_SUPPORT 1
33 #else
34 # define HAVE_OPENAT_SUPPORT 0
35 #endif
36
37 #ifndef __set_errno
38 # define __set_errno(val) (errno = (val))
39 #endif
40
41 #include <dirent.h>
42 #ifndef _D_EXACT_NAMLEN
43 # define _D_EXACT_NAMLEN(d) strlen ((d)->d_name)
44 #endif
45 #ifndef _D_ALLOC_NAMLEN
46 # define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)
47 #endif
48
49 #include <unistd.h>
50 #include <stdlib.h>
51 #include <string.h>
52
53 #if _LIBC
54 # ifndef mempcpy
55 # define mempcpy __mempcpy
56 # endif
57 #endif
58
59 #include <limits.h>
60
61 #ifndef MAX
62 # define MAX(a, b) ((a) < (b) ? (b) : (a))
63 #endif
64 #ifndef MIN
65 # define MIN(a, b) ((a) < (b) ? (a) : (b))
66 #endif
67
68 #ifndef PATH_MAX
69 # ifdef MAXPATHLEN
70 # define PATH_MAX MAXPATHLEN
71 # else
72 # define PATH_MAX 1024
73 # endif
74 #endif
75
76 #if D_INO_IN_DIRENT
77 # define MATCHING_INO(dp, ino) ((dp)->d_ino == (ino))
78 #else
79 # define MATCHING_INO(dp, ino) true
80 #endif
81
82 #if !_LIBC
83 # define __getcwd rpl_getcwd
84 # define __lstat lstat
85 # define __closedir closedir
86 # define __opendir opendir
87 # define __readdir readdir
88 #endif
89
90 /* The results of opendir() in this file are not used with dirfd and fchdir,
91 and we do not leak fds to any single-threaded code that could use stdio,
92 therefore save some unnecessary recursion in fchdir.c.
93 FIXME - if the kernel ever adds support for multi-thread safety for
94 avoiding standard fds, then we should use opendir_safer and
95 openat_safer. */
96 #undef opendir
97 #undef closedir
98
99 /* Get the name of the current working directory, and put it in SIZE
100 bytes of BUF. Returns NULL if the directory couldn't be determined or
101 SIZE was too small. If successful, returns BUF. In GNU, if BUF is
102 NULL, an array is allocated with `malloc'; the array is SIZE bytes long,
103 unless SIZE == 0, in which case it is as big as necessary. */
104
105 char *
106 __getcwd (char *buf, size_t size)
107 {
108 /* Lengths of big file name components and entire file names, and a
109 deep level of file name nesting. These numbers are not upper
110 bounds; they are merely large values suitable for initial
111 allocations, designed to be large enough for most real-world
112 uses. */
113 enum
114 {
115 BIG_FILE_NAME_COMPONENT_LENGTH = 255,
116 BIG_FILE_NAME_LENGTH = MIN (4095, PATH_MAX - 1),
117 DEEP_NESTING = 100
118 };
119
120 #if HAVE_OPENAT_SUPPORT
121 int fd = AT_FDCWD;
122 bool fd_needs_closing = false;
123 #else
124 char dots[DEEP_NESTING * sizeof ".." + BIG_FILE_NAME_COMPONENT_LENGTH + 1];
125 char *dotlist = dots;
126 size_t dotsize = sizeof dots;
127 size_t dotlen = 0;
128 #endif
129 DIR *dirstream = NULL;
130 dev_t rootdev, thisdev;
131 ino_t rootino, thisino;
132 char *dir;
133 register char *dirp;
134 struct stat st;
135 size_t allocated = size;
136 size_t used;
137
138 #if HAVE_PARTLY_WORKING_GETCWD
139 /* The system getcwd works, except it sometimes fails when it
140 shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT. If
141 AT_FDCWD is not defined, the algorithm below is O(N**2) and this
142 is much slower than the system getcwd (at least on GNU/Linux).
143 So trust the system getcwd's results unless they look
144 suspicious.
145
146 Use the system getcwd even if we have openat support, since the
147 system getcwd works even when a parent is unreadable, while the
148 openat-based approach does not. */
149
150 # undef getcwd
151 dir = getcwd (buf, size);
152 if (dir || (errno != ERANGE && errno != ENAMETOOLONG && errno != ENOENT))
153 return dir;
154 #endif
155
156 if (size == 0)
157 {
158 if (buf != NULL)
159 {
160 __set_errno (EINVAL);
161 return NULL;
162 }
163
164 allocated = BIG_FILE_NAME_LENGTH + 1;
165 }
166
167 if (buf == NULL)
168 {
169 dir = malloc (allocated);
170 if (dir == NULL)
171 return NULL;
172 }
173 else
174 dir = buf;
175
176 dirp = dir + allocated;
177 *--dirp = '\0';
178
179 if (__lstat (".", &st) < 0)
180 goto lose;
181 thisdev = st.st_dev;
182 thisino = st.st_ino;
183
184 if (__lstat ("/", &st) < 0)
185 goto lose;
186 rootdev = st.st_dev;
187 rootino = st.st_ino;
188
189 while (!(thisdev == rootdev && thisino == rootino))
190 {
191 struct dirent *d;
192 dev_t dotdev;
193 ino_t dotino;
194 bool mount_point;
195 int parent_status;
196 size_t dirroom;
197 size_t namlen;
198 bool use_d_ino = true;
199
200 /* Look at the parent directory. */
201 #if HAVE_OPENAT_SUPPORT
202 fd = openat (fd, "..", O_RDONLY);
203 if (fd < 0)
204 goto lose;
205 fd_needs_closing = true;
206 parent_status = fstat (fd, &st);
207 #else
208 dotlist[dotlen++] = '.';
209 dotlist[dotlen++] = '.';
210 dotlist[dotlen] = '\0';
211 parent_status = __lstat (dotlist, &st);
212 #endif
213 if (parent_status != 0)
214 goto lose;
215
216 if (dirstream && __closedir (dirstream) != 0)
217 {
218 dirstream = NULL;
219 goto lose;
220 }
221
222 /* Figure out if this directory is a mount point. */
223 dotdev = st.st_dev;
224 dotino = st.st_ino;
225 mount_point = dotdev != thisdev;
226
227 /* Search for the last directory. */
228 #if HAVE_OPENAT_SUPPORT
229 dirstream = fdopendir (fd);
230 if (dirstream == NULL)
231 goto lose;
232 /* Reset fd. It may have been closed by fdopendir. */
233 fd = dirfd (dirstream);
234 fd_needs_closing = false;
235 #else
236 dirstream = __opendir (dotlist);
237 if (dirstream == NULL)
238 goto lose;
239 dotlist[dotlen++] = '/';
240 #endif
241 for (;;)
242 {
243 /* Clear errno to distinguish EOF from error if readdir returns
244 NULL. */
245 __set_errno (0);
246 d = __readdir (dirstream);
247
248 /* When we've iterated through all directory entries without finding
249 one with a matching d_ino, rewind the stream and consider each
250 name again, but this time, using lstat. This is necessary in a
251 chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where
252 .., ../.., ../../.., etc. all had the same device number, yet the
253 d_ino values for entries in / did not match those obtained
254 via lstat. */
255 if (d == NULL && errno == 0 && use_d_ino)
256 {
257 use_d_ino = false;
258 rewinddir (dirstream);
259 d = __readdir (dirstream);
260 }
261
262 if (d == NULL)
263 {
264 if (errno == 0)
265 /* EOF on dirstream, which can mean e.g., that the current
266 directory has been removed. */
267 __set_errno (ENOENT);
268 goto lose;
269 }
270 if (d->d_name[0] == '.' &&
271 (d->d_name[1] == '\0' ||
272 (d->d_name[1] == '.' && d->d_name[2] == '\0')))
273 continue;
274
275 if (use_d_ino)
276 {
277 bool match = (MATCHING_INO (d, thisino) || mount_point);
278 if (! match)
279 continue;
280 }
281
282 {
283 int entry_status;
284 #if HAVE_OPENAT_SUPPORT
285 entry_status = fstatat (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW);
286 #else
287 /* Compute size needed for this file name, or for the file
288 name ".." in the same directory, whichever is larger.
289 Room for ".." might be needed the next time through
290 the outer loop. */
291 size_t name_alloc = _D_ALLOC_NAMLEN (d);
292 size_t filesize = dotlen + MAX (sizeof "..", name_alloc);
293
294 if (filesize < dotlen)
295 goto memory_exhausted;
296
297 if (dotsize < filesize)
298 {
299 /* My, what a deep directory tree you have, Grandma. */
300 size_t newsize = MAX (filesize, dotsize * 2);
301 size_t i;
302 if (newsize < dotsize)
303 goto memory_exhausted;
304 if (dotlist != dots)
305 free (dotlist);
306 dotlist = malloc (newsize);
307 if (dotlist == NULL)
308 goto lose;
309 dotsize = newsize;
310
311 i = 0;
312 do
313 {
314 dotlist[i++] = '.';
315 dotlist[i++] = '.';
316 dotlist[i++] = '/';
317 }
318 while (i < dotlen);
319 }
320
321 memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d));
322 entry_status = __lstat (dotlist, &st);
323 #endif
324 /* We don't fail here if we cannot stat() a directory entry.
325 This can happen when (network) file systems fail. If this
326 entry is in fact the one we are looking for we will find
327 out soon as we reach the end of the directory without
328 having found anything. */
329 if (entry_status == 0 && S_ISDIR (st.st_mode)
330 && st.st_dev == thisdev && st.st_ino == thisino)
331 break;
332 }
333 }
334
335 dirroom = dirp - dir;
336 namlen = _D_EXACT_NAMLEN (d);
337
338 if (dirroom <= namlen)
339 {
340 if (size != 0)
341 {
342 __set_errno (ERANGE);
343 goto lose;
344 }
345 else
346 {
347 char *tmp;
348 size_t oldsize = allocated;
349
350 allocated += MAX (allocated, namlen);
351 if (allocated < oldsize
352 || ! (tmp = realloc (dir, allocated)))
353 goto memory_exhausted;
354
355 /* Move current contents up to the end of the buffer.
356 This is guaranteed to be non-overlapping. */
357 dirp = memcpy (tmp + allocated - (oldsize - dirroom),
358 tmp + dirroom,
359 oldsize - dirroom);
360 dir = tmp;
361 }
362 }
363 dirp -= namlen;
364 memcpy (dirp, d->d_name, namlen);
365 *--dirp = '/';
366
367 thisdev = dotdev;
368 thisino = dotino;
369 }
370
371 if (dirstream && __closedir (dirstream) != 0)
372 {
373 dirstream = NULL;
374 goto lose;
375 }
376
377 if (dirp == &dir[allocated - 1])
378 *--dirp = '/';
379
380 #if ! HAVE_OPENAT_SUPPORT
381 if (dotlist != dots)
382 free (dotlist);
383 #endif
384
385 used = dir + allocated - dirp;
386 memmove (dir, dirp, used);
387
388 if (size == 0)
389 /* Ensure that the buffer is only as large as necessary. */
390 buf = realloc (dir, used);
391
392 if (buf == NULL)
393 /* Either buf was NULL all along, or `realloc' failed but
394 we still have the original string. */
395 buf = dir;
396
397 return buf;
398
399 memory_exhausted:
400 __set_errno (ENOMEM);
401 lose:
402 {
403 int save = errno;
404 if (dirstream)
405 __closedir (dirstream);
406 #if HAVE_OPENAT_SUPPORT
407 if (fd_needs_closing)
408 close (fd);
409 #else
410 if (dotlist != dots)
411 free (dotlist);
412 #endif
413 if (buf == NULL)
414 free (dir);
415 __set_errno (save);
416 }
417 return NULL;
418 }
419
420 #ifdef weak_alias
421 weak_alias (__getcwd, getcwd)
422 #endif
00 /* Getopt for GNU.
1 NOTE: getopt is now part of the C library, so if you don't know what
1 NOTE: getopt is part of the C library, so if you don't know what
22 "Keep this file name-space clean" means, talk to drepper@gnu.org
33 before changing it!
4 Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008
5 Free Software Foundation, Inc.
4 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2010 Free Software
5 Foundation, Inc.
66 This file is part of the GNU C Library.
77
88 This program is free software: you can redistribute it and/or modify
4444 # define attribute_hidden
4545 #endif
4646
47 /* Unlike standard Unix `getopt', functions like `getopt_long'
48 let the user intersperse the options with the other arguments.
47 /* This version of `getopt' appears to the caller like standard Unix `getopt'
48 but it behaves differently for the user, since it allows the user
49 to intersperse the options with the other arguments.
4950
5051 As `getopt_long' works, it permutes the elements of ARGV so that,
5152 when it is done, all the options precede everything else. Thus
5354
5455 Using `getopt' or setting the environment variable POSIXLY_CORRECT
5556 disables permutation.
56 Then the application's behavior is completely standard.
57 Then the behavior is completely standard.
5758
5859 GNU application programs can use a third alternative mode in which
5960 they can distinguish the relative order of options and other arguments. */
120121
121122 # ifdef USE_NONOPTION_FLAGS
122123 # define SWAP_FLAGS(ch1, ch2) \
123 if (d->__nonoption_flags_len > 0) \
124 { \
125 char __tmp = __getopt_nonoption_flags[ch1]; \
126 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
127 __getopt_nonoption_flags[ch2] = __tmp; \
124 if (d->__nonoption_flags_len > 0) \
125 { \
126 char __tmp = __getopt_nonoption_flags[ch1]; \
127 __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
128 __getopt_nonoption_flags[ch2] = __tmp; \
128129 }
129130 # else
130131 # define SWAP_FLAGS(ch1, ch2)
131132 # endif
132 #else /* !_LIBC */
133 #else /* !_LIBC */
133134 # define SWAP_FLAGS(ch1, ch2)
134 #endif /* _LIBC */
135 #endif /* _LIBC */
135136
136137 /* Exchange two adjacent subsequences of ARGV.
137138 One subsequence is elements [first_nonopt,last_nonopt)
162163 if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
163164 {
164165 /* We must extend the array. The user plays games with us and
165 presents new arguments. */
166 presents new arguments. */
166167 char *new_str = malloc (top + 1);
167168 if (new_str == NULL)
168 d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
169 d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0;
169170 else
170 {
171 memset (__mempcpy (new_str, __getopt_nonoption_flags,
172 d->__nonoption_flags_max_len),
173 '\0', top + 1 - d->__nonoption_flags_max_len);
174 d->__nonoption_flags_max_len = top + 1;
175 __getopt_nonoption_flags = new_str;
176 }
171 {
172 memset (__mempcpy (new_str, __getopt_nonoption_flags,
173 d->__nonoption_flags_max_len),
174 '\0', top + 1 - d->__nonoption_flags_max_len);
175 d->__nonoption_flags_max_len = top + 1;
176 __getopt_nonoption_flags = new_str;
177 }
177178 }
178179 #endif
179180
180181 while (top > middle && middle > bottom)
181182 {
182183 if (top - middle > middle - bottom)
183 {
184 /* Bottom segment is the short one. */
185 int len = middle - bottom;
186 register int i;
187
188 /* Swap it with the top part of the top segment. */
189 for (i = 0; i < len; i++)
190 {
191 tem = argv[bottom + i];
192 argv[bottom + i] = argv[top - (middle - bottom) + i];
193 argv[top - (middle - bottom) + i] = tem;
194 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
195 }
196 /* Exclude the moved bottom segment from further swapping. */
197 top -= len;
198 }
184 {
185 /* Bottom segment is the short one. */
186 int len = middle - bottom;
187 register int i;
188
189 /* Swap it with the top part of the top segment. */
190 for (i = 0; i < len; i++)
191 {
192 tem = argv[bottom + i];
193 argv[bottom + i] = argv[top - (middle - bottom) + i];
194 argv[top - (middle - bottom) + i] = tem;
195 SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
196 }
197 /* Exclude the moved bottom segment from further swapping. */
198 top -= len;
199 }
199200 else
200 {
201 /* Top segment is the short one. */
202 int len = top - middle;
203 register int i;
204
205 /* Swap it with the bottom part of the bottom segment. */
206 for (i = 0; i < len; i++)
207 {
208 tem = argv[bottom + i];
209 argv[bottom + i] = argv[middle + i];
210 argv[middle + i] = tem;
211 SWAP_FLAGS (bottom + i, middle + i);
212 }
213 /* Exclude the moved top segment from further swapping. */
214 bottom += len;
215 }
201 {
202 /* Top segment is the short one. */
203 int len = top - middle;
204 register int i;
205
206 /* Swap it with the bottom part of the bottom segment. */
207 for (i = 0; i < len; i++)
208 {
209 tem = argv[bottom + i];
210 argv[bottom + i] = argv[middle + i];
211 argv[middle + i] = tem;
212 SWAP_FLAGS (bottom + i, middle + i);
213 }
214 /* Exclude the moved top segment from further swapping. */
215 bottom += len;
216 }
216217 }
217218
218219 /* Update records for the slots the non-options now occupy. */
224225 /* Initialize the internal data when the first call is made. */
225226
226227 static const char *
227 _getopt_initialize (int argc, char **argv, const char *optstring,
228 int posixly_correct, struct _getopt_data *d)
228 _getopt_initialize (int argc _GL_UNUSED,
229 char **argv _GL_UNUSED, const char *optstring,
230 struct _getopt_data *d, int posixly_correct)
229231 {
230232 /* Start processing options with ARGV-element 1 (since ARGV-element 0
231233 is the program name); the sequence of previously skipped
259261 && argc == __libc_argc && argv == __libc_argv)
260262 {
261263 if (d->__nonoption_flags_max_len == 0)
262 {
263 if (__getopt_nonoption_flags == NULL
264 || __getopt_nonoption_flags[0] == '\0')
265 d->__nonoption_flags_max_len = -1;
266 else
267 {
268 const char *orig_str = __getopt_nonoption_flags;
269 int len = d->__nonoption_flags_max_len = strlen (orig_str);
270 if (d->__nonoption_flags_max_len < argc)
271 d->__nonoption_flags_max_len = argc;
272 __getopt_nonoption_flags =
273 (char *) malloc (d->__nonoption_flags_max_len);
274 if (__getopt_nonoption_flags == NULL)
275 d->__nonoption_flags_max_len = -1;
276 else
277 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
278 '\0', d->__nonoption_flags_max_len - len);
279 }
280 }
264 {
265 if (__getopt_nonoption_flags == NULL
266 || __getopt_nonoption_flags[0] == '\0')
267 d->__nonoption_flags_max_len = -1;
268 else
269 {
270 const char *orig_str = __getopt_nonoption_flags;
271 int len = d->__nonoption_flags_max_len = strlen (orig_str);
272 if (d->__nonoption_flags_max_len < argc)
273 d->__nonoption_flags_max_len = argc;
274 __getopt_nonoption_flags =
275 (char *) malloc (d->__nonoption_flags_max_len);
276 if (__getopt_nonoption_flags == NULL)
277 d->__nonoption_flags_max_len = -1;
278 else
279 memset (__mempcpy (__getopt_nonoption_flags, orig_str, len),
280 '\0', d->__nonoption_flags_max_len - len);
281 }
282 }
281283 d->__nonoption_flags_len = d->__nonoption_flags_max_len;
282284 }
283285 else
329331 `flag' field is nonzero, the value of the option's `val' field
330332 if the `flag' field is zero.
331333
334 The elements of ARGV aren't really const, because we permute them.
335 But we pretend they're const in the prototype to be compatible
336 with other systems.
337
332338 LONGOPTS is a vector of `struct option' terminated by an
333339 element containing a name which is zero.
334340
337343 recent call.
338344
339345 If LONG_ONLY is nonzero, '-' as well as '--' can introduce
340 long-named options.
341
342 If POSIXLY_CORRECT is nonzero, behave as if the POSIXLY_CORRECT
343 environment variable were set. */
346 long-named options. */
344347
345348 int
346349 _getopt_internal_r (int argc, char **argv, const char *optstring,
347 const struct option *longopts, int *longind,
348 int long_only, int posixly_correct, struct _getopt_data *d)
350 const struct option *longopts, int *longind,
351 int long_only, struct _getopt_data *d, int posixly_correct)
349352 {
350353 int print_errors = d->opterr;
351354 if (optstring[0] == ':')
359362 if (d->optind == 0 || !d->__initialized)
360363 {
361364 if (d->optind == 0)
362 d->optind = 1; /* Don't scan ARGV[0], the program name. */
363 optstring = _getopt_initialize (argc, argv, optstring,
364 posixly_correct, d);
365 d->optind = 1; /* Don't scan ARGV[0], the program name. */
366 optstring = _getopt_initialize (argc, argv, optstring, d,
367 posixly_correct);
365368 d->__initialized = 1;
366369 }
367370
371374 is only used when the used in the GNU libc. */
372375 #if defined _LIBC && defined USE_NONOPTION_FLAGS
373376 # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \
374 || (d->optind < d->__nonoption_flags_len \
375 && __getopt_nonoption_flags[d->optind] == '1'))
377 || (d->optind < d->__nonoption_flags_len \
378 && __getopt_nonoption_flags[d->optind] == '1'))
376379 #else
377380 # define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0')
378381 #endif
382385 /* Advance to the next ARGV-element. */
383386
384387 /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
385 moved back by the user (who may also have changed the arguments). */
388 moved back by the user (who may also have changed the arguments). */
386389 if (d->__last_nonopt > d->optind)
387 d->__last_nonopt = d->optind;
390 d->__last_nonopt = d->optind;
388391 if (d->__first_nonopt > d->optind)
389 d->__first_nonopt = d->optind;
392 d->__first_nonopt = d->optind;
390393
391394 if (d->__ordering == PERMUTE)
392 {
393 /* If we have just processed some options following some non-options,
394 exchange them so that the options come first. */
395
396 if (d->__first_nonopt != d->__last_nonopt
397 && d->__last_nonopt != d->optind)
398 exchange ((char **) argv, d);
399 else if (d->__last_nonopt != d->optind)
400 d->__first_nonopt = d->optind;
401
402 /* Skip any additional non-options
403 and extend the range of non-options previously skipped. */
404
405 while (d->optind < argc && NONOPTION_P)
406 d->optind++;
407 d->__last_nonopt = d->optind;
408 }
395 {
396 /* If we have just processed some options following some non-options,
397 exchange them so that the options come first. */
398
399 if (d->__first_nonopt != d->__last_nonopt
400 && d->__last_nonopt != d->optind)
401 exchange ((char **) argv, d);
402 else if (d->__last_nonopt != d->optind)
403 d->__first_nonopt = d->optind;
404
405 /* Skip any additional non-options
406 and extend the range of non-options previously skipped. */
407
408 while (d->optind < argc && NONOPTION_P)
409 d->optind++;
410 d->__last_nonopt = d->optind;
411 }
409412
410413 /* The special ARGV-element `--' means premature end of options.
411 Skip it like a null option,
412 then exchange with previous non-options as if it were an option,
413 then skip everything else like a non-option. */
414 Skip it like a null option,
415 then exchange with previous non-options as if it were an option,
416 then skip everything else like a non-option. */
414417
415418 if (d->optind != argc && !strcmp (argv[d->optind], "--"))
416 {
417 d->optind++;
418
419 if (d->__first_nonopt != d->__last_nonopt
420 && d->__last_nonopt != d->optind)
421 exchange ((char **) argv, d);
422 else if (d->__first_nonopt == d->__last_nonopt)
423 d->__first_nonopt = d->optind;
424 d->__last_nonopt = argc;
425
426 d->optind = argc;
427 }
419 {
420 d->optind++;
421
422 if (d->__first_nonopt != d->__last_nonopt
423 && d->__last_nonopt != d->optind)
424 exchange ((char **) argv, d);
425 else if (d->__first_nonopt == d->__last_nonopt)
426 d->__first_nonopt = d->optind;
427 d->__last_nonopt = argc;
428
429 d->optind = argc;
430 }
428431
429432 /* If we have done all the ARGV-elements, stop the scan
430 and back over any non-options that we skipped and permuted. */
433 and back over any non-options that we skipped and permuted. */
431434
432435 if (d->optind == argc)
433 {
434 /* Set the next-arg-index to point at the non-options
435 that we previously skipped, so the caller will digest them. */
436 if (d->__first_nonopt != d->__last_nonopt)
437 d->optind = d->__first_nonopt;
438 return -1;
439 }
436 {
437 /* Set the next-arg-index to point at the non-options
438 that we previously skipped, so the caller will digest them. */
439 if (d->__first_nonopt != d->__last_nonopt)
440 d->optind = d->__first_nonopt;
441 return -1;
442 }
440443
441444 /* If we have come to a non-option and did not permute it,
442 either stop the scan or describe it to the caller and pass it by. */
445 either stop the scan or describe it to the caller and pass it by. */
443446
444447 if (NONOPTION_P)
445 {
446 if (d->__ordering == REQUIRE_ORDER)
447 return -1;
448 d->optarg = argv[d->optind++];
449 return 1;
450 }
448 {
449 if (d->__ordering == REQUIRE_ORDER)
450 return -1;
451 d->optarg = argv[d->optind++];
452 return 1;
453 }
451454
452455 /* We have found another option-ARGV-element.
453 Skip the initial punctuation. */
456 Skip the initial punctuation. */
454457
455458 d->__nextchar = (argv[d->optind] + 1
456 + (longopts != NULL && argv[d->optind][1] == '-'));
459 + (longopts != NULL && argv[d->optind][1] == '-'));
457460 }
458461
459462 /* Decode the current option-ARGV-element. */
473476
474477 if (longopts != NULL
475478 && (argv[d->optind][1] == '-'
476 || (long_only && (argv[d->optind][2]
477 || !strchr (optstring, argv[d->optind][1])))))
479 || (long_only && (argv[d->optind][2]
480 || !strchr (optstring, argv[d->optind][1])))))
478481 {
479482 char *nameend;
480483 const struct option *p;
485488 int option_index;
486489
487490 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
488 /* Do nothing. */ ;
491 /* Do nothing. */ ;
489492
490493 /* Test all long options for either exact match
491 or abbreviated matches. */
494 or abbreviated matches. */
492495 for (p = longopts, option_index = 0; p->name; p++, option_index++)
493 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
494 {
495 if ((unsigned int) (nameend - d->__nextchar)
496 == (unsigned int) strlen (p->name))
497 {
498 /* Exact match found. */
499 pfound = p;
500 indfound = option_index;
501 exact = 1;
502 break;
503 }
504 else if (pfound == NULL)
505 {
506 /* First nonexact match found. */
507 pfound = p;
508 indfound = option_index;
509 }
510 else if (long_only
511 || pfound->has_arg != p->has_arg
512 || pfound->flag != p->flag
513 || pfound->val != p->val)
514 /* Second or later nonexact match found. */
515 ambig = 1;
516 }
496 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
497 {
498 if ((unsigned int) (nameend - d->__nextchar)
499 == (unsigned int) strlen (p->name))
500 {
501 /* Exact match found. */
502 pfound = p;
503 indfound = option_index;
504 exact = 1;
505 break;
506 }
507 else if (pfound == NULL)
508 {
509 /* First nonexact match found. */
510 pfound = p;
511 indfound = option_index;
512 }
513 else if (long_only
514 || pfound->has_arg != p->has_arg
515 || pfound->flag != p->flag
516 || pfound->val != p->val)
517 /* Second or later nonexact match found. */
518 ambig = 1;
519 }
517520
518521 if (ambig && !exact)
519 {
520 if (print_errors)
521 {
522 #if defined _LIBC && defined USE_IN_LIBIO
523 char *buf;
524
525 if (__asprintf (&buf, _("%s: option `%s' is ambiguous\n"),
526 argv[0], argv[d->optind]) >= 0)
527 {
528 _IO_flockfile (stderr);
529
530 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
531 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
532
533 __fxprintf (NULL, "%s", buf);
534
535 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
536 _IO_funlockfile (stderr);
537
538 free (buf);
539 }
540 #else
541 fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
542 argv[0], argv[d->optind]);
543 #endif
544 }
545 d->__nextchar += strlen (d->__nextchar);
546 d->optind++;
547 d->optopt = 0;
548 return '?';
549 }
522 {
523 if (print_errors)
524 {
525 #if defined _LIBC && defined USE_IN_LIBIO
526 char *buf;
527
528 if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"),
529 argv[0], argv[d->optind]) >= 0)
530 {
531 _IO_flockfile (stderr);
532
533 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
534 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
535
536 __fxprintf (NULL, "%s", buf);
537
538 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
539 _IO_funlockfile (stderr);
540
541 free (buf);
542 }
543 #else
544 fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
545 argv[0], argv[d->optind]);
546 #endif
547 }
548 d->__nextchar += strlen (d->__nextchar);
549 d->optind++;
550 d->optopt = 0;
551 return '?';
552 }
550553
551554 if (pfound != NULL)
552 {
553 option_index = indfound;
554 d->optind++;
555 if (*nameend)
556 {
557 /* Don't test has_arg with >, because some C compilers don't
558 allow it to be used on enums. */
559 if (pfound->has_arg)
560 d->optarg = nameend + 1;
561 else
562 {
563 if (print_errors)
564 {
565 #if defined _LIBC && defined USE_IN_LIBIO
566 char *buf;
567 int n;
568 #endif
569
570 if (argv[d->optind - 1][1] == '-')
571 {
572 /* --option */
573 #if defined _LIBC && defined USE_IN_LIBIO
574 n = __asprintf (&buf, _("\
575 %s: option `--%s' doesn't allow an argument\n"),
576 argv[0], pfound->name);
577 #else
578 fprintf (stderr, _("\
579 %s: option `--%s' doesn't allow an argument\n"),
580 argv[0], pfound->name);
581 #endif
582 }
583 else
584 {
585 /* +option or -option */
586 #if defined _LIBC && defined USE_IN_LIBIO
587 n = __asprintf (&buf, _("\
588 %s: option `%c%s' doesn't allow an argument\n"),
589 argv[0], argv[d->optind - 1][0],
590 pfound->name);
591 #else
592 fprintf (stderr, _("\
593 %s: option `%c%s' doesn't allow an argument\n"),
594 argv[0], argv[d->optind - 1][0],
595 pfound->name);
596 #endif
597 }
598
599 #if defined _LIBC && defined USE_IN_LIBIO
600 if (n >= 0)
601 {
602 _IO_flockfile (stderr);
603
604 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
605 ((_IO_FILE *) stderr)->_flags2
606 |= _IO_FLAGS2_NOTCANCEL;
607
608 __fxprintf (NULL, "%s", buf);
609
610 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
611 _IO_funlockfile (stderr);
612
613 free (buf);
614 }
615 #endif
616 }
617
618 d->__nextchar += strlen (d->__nextchar);
619
620 d->optopt = pfound->val;
621 return '?';
622 }
623 }
624 else if (pfound->has_arg == 1)
625 {
626 if (d->optind < argc)
627 d->optarg = argv[d->optind++];
628 else
629 {
630 if (print_errors)
631 {
632 #if defined _LIBC && defined USE_IN_LIBIO
633 char *buf;
634
635 if (__asprintf (&buf, _("\
636 %s: option `%s' requires an argument\n"),
637 argv[0], argv[d->optind - 1]) >= 0)
638 {
639 _IO_flockfile (stderr);
640
641 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
642 ((_IO_FILE *) stderr)->_flags2
643 |= _IO_FLAGS2_NOTCANCEL;
644
645 __fxprintf (NULL, "%s", buf);
646
647 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
648 _IO_funlockfile (stderr);
649
650 free (buf);
651 }
652 #else
653 fprintf (stderr,
654 _("%s: option `%s' requires an argument\n"),
655 argv[0], argv[d->optind - 1]);
656 #endif
657 }
658 d->__nextchar += strlen (d->__nextchar);
659 d->optopt = pfound->val;
660 return optstring[0] == ':' ? ':' : '?';
661 }
662 }
663 d->__nextchar += strlen (d->__nextchar);
664 if (longind != NULL)
665 *longind = option_index;
666 if (pfound->flag)
667 {
668 *(pfound->flag) = pfound->val;
669 return 0;
670 }
671 return pfound->val;
672 }
555 {
556 option_index = indfound;
557 d->optind++;
558 if (*nameend)
559 {
560 /* Don't test has_arg with >, because some C compilers don't
561 allow it to be used on enums. */
562 if (pfound->has_arg)
563 d->optarg = nameend + 1;
564 else
565 {
566 if (print_errors)
567 {
568 #if defined _LIBC && defined USE_IN_LIBIO
569 char *buf;
570 int n;
571 #endif
572
573 if (argv[d->optind - 1][1] == '-')
574 {
575 /* --option */
576 #if defined _LIBC && defined USE_IN_LIBIO
577 n = __asprintf (&buf, _("\
578 %s: option '--%s' doesn't allow an argument\n"),
579 argv[0], pfound->name);
580 #else
581 fprintf (stderr, _("\
582 %s: option '--%s' doesn't allow an argument\n"),
583 argv[0], pfound->name);
584 #endif
585 }
586 else
587 {
588 /* +option or -option */
589 #if defined _LIBC && defined USE_IN_LIBIO
590 n = __asprintf (&buf, _("\
591 %s: option '%c%s' doesn't allow an argument\n"),
592 argv[0], argv[d->optind - 1][0],
593 pfound->name);
594 #else
595 fprintf (stderr, _("\
596 %s: option '%c%s' doesn't allow an argument\n"),
597 argv[0], argv[d->optind - 1][0],
598 pfound->name);
599 #endif
600 }
601
602 #if defined _LIBC && defined USE_IN_LIBIO
603 if (n >= 0)
604 {
605 _IO_flockfile (stderr);
606
607 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
608 ((_IO_FILE *) stderr)->_flags2
609 |= _IO_FLAGS2_NOTCANCEL;
610
611 __fxprintf (NULL, "%s", buf);
612
613 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
614 _IO_funlockfile (stderr);
615
616 free (buf);
617 }
618 #endif
619 }
620
621 d->__nextchar += strlen (d->__nextchar);
622
623 d->optopt = pfound->val;
624 return '?';
625 }
626 }
627 else if (pfound->has_arg == 1)
628 {
629 if (d->optind < argc)
630 d->optarg = argv[d->optind++];
631 else
632 {
633 if (print_errors)
634 {
635 #if defined _LIBC && defined USE_IN_LIBIO
636 char *buf;
637
638 if (__asprintf (&buf, _("\
639 %s: option '%s' requires an argument\n"),
640 argv[0], argv[d->optind - 1]) >= 0)
641 {
642 _IO_flockfile (stderr);
643
644 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
645 ((_IO_FILE *) stderr)->_flags2
646 |= _IO_FLAGS2_NOTCANCEL;
647
648 __fxprintf (NULL, "%s", buf);
649
650 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
651 _IO_funlockfile (stderr);
652
653 free (buf);
654 }
655 #else
656 fprintf (stderr,
657 _("%s: option '%s' requires an argument\n"),
658 argv[0], argv[d->optind - 1]);
659 #endif
660 }
661 d->__nextchar += strlen (d->__nextchar);
662 d->optopt = pfound->val;
663 return optstring[0] == ':' ? ':' : '?';
664 }
665 }
666 d->__nextchar += strlen (d->__nextchar);
667 if (longind != NULL)
668 *longind = option_index;
669 if (pfound->flag)
670 {
671 *(pfound->flag) = pfound->val;
672 return 0;
673 }
674 return pfound->val;
675 }
673676
674677 /* Can't find it as a long option. If this is not getopt_long_only,
675 or the option starts with '--' or is not a valid short
676 option, then it's an error.
677 Otherwise interpret it as a short option. */
678 or the option starts with '--' or is not a valid short
679 option, then it's an error.
680 Otherwise interpret it as a short option. */
678681 if (!long_only || argv[d->optind][1] == '-'
679 || strchr (optstring, *d->__nextchar) == NULL)
680 {
681 if (print_errors)
682 {
683 #if defined _LIBC && defined USE_IN_LIBIO
684 char *buf;
685 int n;
686 #endif
687
688 if (argv[d->optind][1] == '-')
689 {
690 /* --option */
691 #if defined _LIBC && defined USE_IN_LIBIO
692 n = __asprintf (&buf, _("%s: unrecognized option `--%s'\n"),
693 argv[0], d->__nextchar);
694 #else
695 fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
696 argv[0], d->__nextchar);
697 #endif
698 }
699 else
700 {
701 /* +option or -option */
702 #if defined _LIBC && defined USE_IN_LIBIO
703 n = __asprintf (&buf, _("%s: unrecognized option `%c%s'\n"),
704 argv[0], argv[d->optind][0], d->__nextchar);
705 #else
706 fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
707 argv[0], argv[d->optind][0], d->__nextchar);
708 #endif
709 }
710
711 #if defined _LIBC && defined USE_IN_LIBIO
712 if (n >= 0)
713 {
714 _IO_flockfile (stderr);
715
716 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
717 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
718
719 __fxprintf (NULL, "%s", buf);
720
721 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
722 _IO_funlockfile (stderr);
723
724 free (buf);
725 }
726 #endif
727 }
728 d->__nextchar = (char *) "";
729 d->optind++;
730 d->optopt = 0;
731 return '?';
732 }
682 || strchr (optstring, *d->__nextchar) == NULL)
683 {
684 if (print_errors)
685 {
686 #if defined _LIBC && defined USE_IN_LIBIO
687 char *buf;
688 int n;
689 #endif
690
691 if (argv[d->optind][1] == '-')
692 {
693 /* --option */
694 #if defined _LIBC && defined USE_IN_LIBIO
695 n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"),
696 argv[0], d->__nextchar);
697 #else
698 fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
699 argv[0], d->__nextchar);
700 #endif
701 }
702 else
703 {
704 /* +option or -option */
705 #if defined _LIBC && defined USE_IN_LIBIO
706 n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"),
707 argv[0], argv[d->optind][0], d->__nextchar);
708 #else
709 fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
710 argv[0], argv[d->optind][0], d->__nextchar);
711 #endif
712 }
713
714 #if defined _LIBC && defined USE_IN_LIBIO
715 if (n >= 0)
716 {
717 _IO_flockfile (stderr);
718
719 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
720 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
721
722 __fxprintf (NULL, "%s", buf);
723
724 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
725 _IO_funlockfile (stderr);
726
727 free (buf);
728 }
729 #endif
730 }
731 d->__nextchar = (char *) "";
732 d->optind++;
733 d->optopt = 0;
734 return '?';
735 }
733736 }
734737
735738 /* Look at and handle the next short option-character. */
744747
745748 if (temp == NULL || c == ':')
746749 {
747 if (print_errors)
748 {
749 #if defined _LIBC && defined USE_IN_LIBIO
750 char *buf;
751 int n;
752 #endif
753
754 if (d->__posixly_correct)
755 {
756 /* 1003.2 specifies the format of this message. */
757 #if defined _LIBC && defined USE_IN_LIBIO
758 n = __asprintf (&buf, _("%s: illegal option -- %c\n"),
759 argv[0], c);
760 #else
761 fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
762 #endif
763 }
764 else
765 {
766 #if defined _LIBC && defined USE_IN_LIBIO
767 n = __asprintf (&buf, _("%s: invalid option -- %c\n"),
768 argv[0], c);
769 #else
770 fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
771 #endif
772 }
773
774 #if defined _LIBC && defined USE_IN_LIBIO
775 if (n >= 0)
776 {
777 _IO_flockfile (stderr);
778
779 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
780 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
781
782 __fxprintf (NULL, "%s", buf);
783
784 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
785 _IO_funlockfile (stderr);
786
787 free (buf);
788 }
789 #endif
790 }
791 d->optopt = c;
792 return '?';
750 if (print_errors)
751 {
752 #if defined _LIBC && defined USE_IN_LIBIO
753 char *buf;
754 int n;
755 #endif
756
757 #if defined _LIBC && defined USE_IN_LIBIO
758 n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"),
759 argv[0], c);
760 #else
761 fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c);
762 #endif
763
764 #if defined _LIBC && defined USE_IN_LIBIO
765 if (n >= 0)
766 {
767 _IO_flockfile (stderr);
768
769 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
770 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
771
772 __fxprintf (NULL, "%s", buf);
773
774 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
775 _IO_funlockfile (stderr);
776
777 free (buf);
778 }
779 #endif
780 }
781 d->optopt = c;
782 return '?';
793783 }
794784 /* Convenience. Treat POSIX -W foo same as long option --foo */
795785 if (temp[0] == 'W' && temp[1] == ';')
796786 {
797 char *nameend;
798 const struct option *p;
799 const struct option *pfound = NULL;
800 int exact = 0;
801 int ambig = 0;
802 int indfound = 0;
803 int option_index;
804
805 /* This is an option that requires an argument. */
806 if (*d->__nextchar != '\0')
807 {
808 d->optarg = d->__nextchar;
809 /* If we end this ARGV-element by taking the rest as an arg,
810 we must advance to the next element now. */
811 d->optind++;
812 }
813 else if (d->optind == argc)
814 {
815 if (print_errors)
816 {
817 /* 1003.2 specifies the format of this message. */
818 #if defined _LIBC && defined USE_IN_LIBIO
819 char *buf;
820
821 if (__asprintf (&buf,
822 _("%s: option requires an argument -- %c\n"),
823 argv[0], c) >= 0)
824 {
825 _IO_flockfile (stderr);
826
827 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
828 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
829
830 __fxprintf (NULL, "%s", buf);
831
832 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
833 _IO_funlockfile (stderr);
834
835 free (buf);
836 }
837 #else
838 fprintf (stderr, _("%s: option requires an argument -- %c\n"),
839 argv[0], c);
840 #endif
841 }
842 d->optopt = c;
843 if (optstring[0] == ':')
844 c = ':';
845 else
846 c = '?';
847 return c;
848 }
849 else
850 /* We already incremented `d->optind' once;
851 increment it again when taking next ARGV-elt as argument. */
852 d->optarg = argv[d->optind++];
853
854 /* optarg is now the argument, see if it's in the
855 table of longopts. */
856
857 for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
858 nameend++)
859 /* Do nothing. */ ;
860
861 /* Test all long options for either exact match
862 or abbreviated matches. */
863 for (p = longopts, option_index = 0; p->name; p++, option_index++)
864 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
865 {
866 if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
867 {
868 /* Exact match found. */
869 pfound = p;
870 indfound = option_index;
871 exact = 1;
872 break;
873 }
874 else if (pfound == NULL)
875 {
876 /* First nonexact match found. */
877 pfound = p;
878 indfound = option_index;
879 }
880 else
881 /* Second or later nonexact match found. */
882 ambig = 1;
883 }
884 if (ambig && !exact)
885 {
886 if (print_errors)
887 {
888 #if defined _LIBC && defined USE_IN_LIBIO
889 char *buf;
890
891 if (__asprintf (&buf, _("%s: option `-W %s' is ambiguous\n"),
892 argv[0], argv[d->optind]) >= 0)
893 {
894 _IO_flockfile (stderr);
895
896 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
897 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
898
899 __fxprintf (NULL, "%s", buf);
900
901 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
902 _IO_funlockfile (stderr);
903
904 free (buf);
905 }
906 #else
907 fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
908 argv[0], argv[d->optind]);
909 #endif
910 }
911 d->__nextchar += strlen (d->__nextchar);
912 d->optind++;
913 return '?';
914 }
915 if (pfound != NULL)
916 {
917 option_index = indfound;
918 if (*nameend)
919 {
920 /* Don't test has_arg with >, because some C compilers don't
921 allow it to be used on enums. */
922 if (pfound->has_arg)
923 d->optarg = nameend + 1;
924 else
925 {
926 if (print_errors)
927 {
928 #if defined _LIBC && defined USE_IN_LIBIO
929 char *buf;
930
931 if (__asprintf (&buf, _("\
932 %s: option `-W %s' doesn't allow an argument\n"),
933 argv[0], pfound->name) >= 0)
934 {
935 _IO_flockfile (stderr);
936
937 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
938 ((_IO_FILE *) stderr)->_flags2
939 |= _IO_FLAGS2_NOTCANCEL;
940
941 __fxprintf (NULL, "%s", buf);
942
943 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
944 _IO_funlockfile (stderr);
945
946 free (buf);
947 }
948 #else
949 fprintf (stderr, _("\
950 %s: option `-W %s' doesn't allow an argument\n"),
951 argv[0], pfound->name);
952 #endif
953 }
954
955 d->__nextchar += strlen (d->__nextchar);
956 return '?';
957 }
958 }
959 else if (pfound->has_arg == 1)
960 {
961 if (d->optind < argc)
962 d->optarg = argv[d->optind++];
963 else
964 {
965 if (print_errors)
966 {
967 #if defined _LIBC && defined USE_IN_LIBIO
968 char *buf;
969
970 if (__asprintf (&buf, _("\
971 %s: option `%s' requires an argument\n"),
972 argv[0], argv[d->optind - 1]) >= 0)
973 {
974 _IO_flockfile (stderr);
975
976 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
977 ((_IO_FILE *) stderr)->_flags2
978 |= _IO_FLAGS2_NOTCANCEL;
979
980 __fxprintf (NULL, "%s", buf);
981
982 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
983 _IO_funlockfile (stderr);
984
985 free (buf);
986 }
987 #else
988 fprintf (stderr,
989 _("%s: option `%s' requires an argument\n"),
990 argv[0], argv[d->optind - 1]);
991 #endif
992 }
993 d->__nextchar += strlen (d->__nextchar);
994 return optstring[0] == ':' ? ':' : '?';
995 }
996 }
997 d->__nextchar += strlen (d->__nextchar);
998 if (longind != NULL)
999 *longind = option_index;
1000 if (pfound->flag)
1001 {
1002 *(pfound->flag) = pfound->val;
1003 return 0;
1004 }
1005 return pfound->val;
1006 }
1007 d->__nextchar = NULL;
1008 return 'W'; /* Let the application handle it. */
787 char *nameend;
788 const struct option *p;
789 const struct option *pfound = NULL;
790 int exact = 0;
791 int ambig = 0;
792 int indfound = 0;
793 int option_index;
794
795 /* This is an option that requires an argument. */
796 if (*d->__nextchar != '\0')
797 {
798 d->optarg = d->__nextchar;
799 /* If we end this ARGV-element by taking the rest as an arg,
800 we must advance to the next element now. */
801 d->optind++;
802 }
803 else if (d->optind == argc)
804 {
805 if (print_errors)
806 {
807 #if defined _LIBC && defined USE_IN_LIBIO
808 char *buf;
809
810 if (__asprintf (&buf,
811 _("%s: option requires an argument -- '%c'\n"),
812 argv[0], c) >= 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 #else
827 fprintf (stderr,
828 _("%s: option requires an argument -- '%c'\n"),
829 argv[0], c);
830 #endif
831 }
832 d->optopt = c;
833 if (optstring[0] == ':')
834 c = ':';
835 else
836 c = '?';
837 return c;
838 }
839 else
840 /* We already incremented `d->optind' once;
841 increment it again when taking next ARGV-elt as argument. */
842 d->optarg = argv[d->optind++];
843
844 /* optarg is now the argument, see if it's in the
845 table of longopts. */
846
847 for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '=';
848 nameend++)
849 /* Do nothing. */ ;
850
851 /* Test all long options for either exact match
852 or abbreviated matches. */
853 for (p = longopts, option_index = 0; p->name; p++, option_index++)
854 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar))
855 {
856 if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name))
857 {
858 /* Exact match found. */
859 pfound = p;
860 indfound = option_index;
861 exact = 1;
862 break;
863 }
864 else if (pfound == NULL)
865 {
866 /* First nonexact match found. */
867 pfound = p;
868 indfound = option_index;
869 }
870 else
871 /* Second or later nonexact match found. */
872 ambig = 1;
873 }
874 if (ambig && !exact)
875 {
876 if (print_errors)
877 {
878 #if defined _LIBC && defined USE_IN_LIBIO
879 char *buf;
880
881 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
882 argv[0], argv[d->optind]) >= 0)
883 {
884 _IO_flockfile (stderr);
885
886 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
887 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
888
889 __fxprintf (NULL, "%s", buf);
890
891 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
892 _IO_funlockfile (stderr);
893
894 free (buf);
895 }
896 #else
897 fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
898 argv[0], argv[d->optind]);
899 #endif
900 }
901 d->__nextchar += strlen (d->__nextchar);
902 d->optind++;
903 return '?';
904 }
905 if (pfound != NULL)
906 {
907 option_index = indfound;
908 if (*nameend)
909 {
910 /* Don't test has_arg with >, because some C compilers don't
911 allow it to be used on enums. */
912 if (pfound->has_arg)
913 d->optarg = nameend + 1;
914 else
915 {
916 if (print_errors)
917 {
918 #if defined _LIBC && defined USE_IN_LIBIO
919 char *buf;
920
921 if (__asprintf (&buf, _("\
922 %s: option '-W %s' doesn't allow an argument\n"),
923 argv[0], pfound->name) >= 0)
924 {
925 _IO_flockfile (stderr);
926
927 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
928 ((_IO_FILE *) stderr)->_flags2
929 |= _IO_FLAGS2_NOTCANCEL;
930
931 __fxprintf (NULL, "%s", buf);
932
933 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
934 _IO_funlockfile (stderr);
935
936 free (buf);
937 }
938 #else
939 fprintf (stderr, _("\
940 %s: option '-W %s' doesn't allow an argument\n"),
941 argv[0], pfound->name);
942 #endif
943 }
944
945 d->__nextchar += strlen (d->__nextchar);
946 return '?';
947 }
948 }
949 else if (pfound->has_arg == 1)
950 {
951 if (d->optind < argc)
952 d->optarg = argv[d->optind++];
953 else
954 {
955 if (print_errors)
956 {
957 #if defined _LIBC && defined USE_IN_LIBIO
958 char *buf;
959
960 if (__asprintf (&buf, _("\
961 %s: option '%s' requires an argument\n"),
962 argv[0], argv[d->optind - 1]) >= 0)
963 {
964 _IO_flockfile (stderr);
965
966 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
967 ((_IO_FILE *) stderr)->_flags2
968 |= _IO_FLAGS2_NOTCANCEL;
969
970 __fxprintf (NULL, "%s", buf);
971
972 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
973 _IO_funlockfile (stderr);
974
975 free (buf);
976 }
977 #else
978 fprintf (stderr,
979 _("%s: option '%s' requires an argument\n"),
980 argv[0], argv[d->optind - 1]);
981 #endif
982 }
983 d->__nextchar += strlen (d->__nextchar);
984 return optstring[0] == ':' ? ':' : '?';
985 }
986 }
987 d->__nextchar += strlen (d->__nextchar);
988 if (longind != NULL)
989 *longind = option_index;
990 if (pfound->flag)
991 {
992 *(pfound->flag) = pfound->val;
993 return 0;
994 }
995 return pfound->val;
996 }
997 d->__nextchar = NULL;
998 return 'W'; /* Let the application handle it. */
1009999 }
10101000 if (temp[1] == ':')
10111001 {
1012 if (temp[2] == ':')
1013 {
1014 /* This is an option that accepts an argument optionally. */
1015 if (*d->__nextchar != '\0')
1016 {
1017 d->optarg = d->__nextchar;
1018 d->optind++;
1019 }
1020 else
1021 d->optarg = NULL;
1022 d->__nextchar = NULL;
1023 }
1024 else
1025 {
1026 /* This is an option that requires an argument. */
1027 if (*d->__nextchar != '\0')
1028 {
1029 d->optarg = d->__nextchar;
1030 /* If we end this ARGV-element by taking the rest as an arg,
1031 we must advance to the next element now. */
1032 d->optind++;
1033 }
1034 else if (d->optind == argc)
1035 {
1036 if (print_errors)
1037 {
1038 /* 1003.2 specifies the format of this message. */
1039 #if defined _LIBC && defined USE_IN_LIBIO
1040 char *buf;
1041
1042 if (__asprintf (&buf, _("\
1043 %s: option requires an argument -- %c\n"),
1044 argv[0], c) >= 0)
1045 {
1046 _IO_flockfile (stderr);
1047
1048 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
1049 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
1050
1051 __fxprintf (NULL, "%s", buf);
1052
1053 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
1054 _IO_funlockfile (stderr);
1055
1056 free (buf);
1057 }
1058 #else
1059 fprintf (stderr,
1060 _("%s: option requires an argument -- %c\n"),
1061 argv[0], c);
1062 #endif
1063 }
1064 d->optopt = c;
1065 if (optstring[0] == ':')
1066 c = ':';
1067 else
1068 c = '?';
1069 }
1070 else
1071 /* We already incremented `optind' once;
1072 increment it again when taking next ARGV-elt as argument. */
1073 d->optarg = argv[d->optind++];
1074 d->__nextchar = NULL;
1075 }
1002 if (temp[2] == ':')
1003 {
1004 /* This is an option that accepts an argument optionally. */
1005 if (*d->__nextchar != '\0')
1006 {
1007 d->optarg = d->__nextchar;
1008 d->optind++;
1009 }
1010 else
1011 d->optarg = NULL;
1012 d->__nextchar = NULL;
1013 }
1014 else
1015 {
1016 /* This is an option that requires an argument. */
1017 if (*d->__nextchar != '\0')
1018 {
1019 d->optarg = d->__nextchar;
1020 /* If we end this ARGV-element by taking the rest as an arg,
1021 we must advance to the next element now. */
1022 d->optind++;
1023 }
1024 else if (d->optind == argc)
1025 {
1026 if (print_errors)
1027 {
1028 #if defined _LIBC && defined USE_IN_LIBIO
1029 char *buf;
1030
1031 if (__asprintf (&buf, _("\
1032 %s: option requires an argument -- '%c'\n"),
1033 argv[0], c) >= 0)
1034 {
1035 _IO_flockfile (stderr);
1036
1037 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
1038 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
1039
1040 __fxprintf (NULL, "%s", buf);
1041
1042 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
1043 _IO_funlockfile (stderr);
1044
1045 free (buf);
1046 }
1047 #else
1048 fprintf (stderr,
1049 _("%s: option requires an argument -- '%c'\n"),
1050 argv[0], c);
1051 #endif
1052 }
1053 d->optopt = c;
1054 if (optstring[0] == ':')
1055 c = ':';
1056 else
1057 c = '?';
1058 }
1059 else
1060 /* We already incremented `optind' once;
1061 increment it again when taking next ARGV-elt as argument. */
1062 d->optarg = argv[d->optind++];
1063 d->__nextchar = NULL;
1064 }
10761065 }
10771066 return c;
10781067 }
10801069
10811070 int
10821071 _getopt_internal (int argc, char **argv, const char *optstring,
1083 const struct option *longopts, int *longind,
1084 int long_only, int posixly_correct)
1072 const struct option *longopts, int *longind, int long_only,
1073 int posixly_correct)
10851074 {
10861075 int result;
10871076
10881077 getopt_data.optind = optind;
10891078 getopt_data.opterr = opterr;
10901079
1091 result = _getopt_internal_r (argc, argv, optstring, longopts, longind,
1092 long_only, posixly_correct, &getopt_data);
1080 result = _getopt_internal_r (argc, argv, optstring, longopts,
1081 longind, long_only, &getopt_data,
1082 posixly_correct);
10931083
10941084 optind = getopt_data.optind;
10951085 optarg = getopt_data.optarg;
11091099 int
11101100 getopt (int argc, char *const *argv, const char *optstring)
11111101 {
1112 return _getopt_internal (argc, (char **) argv, optstring, NULL, NULL, 0,
1113 POSIXLY_CORRECT);
1102 return _getopt_internal (argc, (char **) argv, optstring,
1103 (const struct option *) 0,
1104 (int *) 0,
1105 0, POSIXLY_CORRECT);
11141106 }
1107
1108 #ifdef _LIBC
1109 int
1110 __posix_getopt (int argc, char *const *argv, const char *optstring)
1111 {
1112 return _getopt_internal (argc, argv, optstring,
1113 (const struct option *) 0,
1114 (int *) 0,
1115 0, 1);
1116 }
1117 #endif
11151118
11161119
11171120 #ifdef TEST
11311134
11321135 c = getopt (argc, argv, "abc:d:0123456789");
11331136 if (c == -1)
1134 break;
1137 break;
11351138
11361139 switch (c)
1137 {
1138 case '0':
1139 case '1':
1140 case '2':
1141 case '3':
1142 case '4':
1143 case '5':
1144 case '6':
1145 case '7':
1146 case '8':
1147 case '9':
1148 if (digit_optind != 0 && digit_optind != this_option_optind)
1149 printf ("digits occur in two different argv-elements.\n");
1150 digit_optind = this_option_optind;
1151 printf ("option %c\n", c);
1152 break;
1153
1154 case 'a':
1155 printf ("option a\n");
1156 break;
1157
1158 case 'b':
1159 printf ("option b\n");
1160 break;
1161
1162 case 'c':
1163 printf ("option c with value `%s'\n", optarg);
1164 break;
1165
1166 case '?':
1167 break;
1168
1169 default:
1170 printf ("?? getopt returned character code 0%o ??\n", c);
1171 }
1140 {
1141 case '0':
1142 case '1':
1143 case '2':
1144 case '3':
1145 case '4':
1146 case '5':
1147 case '6':
1148 case '7':
1149 case '8':
1150 case '9':
1151 if (digit_optind != 0 && digit_optind != this_option_optind)
1152 printf ("digits occur in two different argv-elements.\n");
1153 digit_optind = this_option_optind;
1154 printf ("option %c\n", c);
1155 break;
1156
1157 case 'a':
1158 printf ("option a\n");
1159 break;
1160
1161 case 'b':
1162 printf ("option b\n");
1163 break;
1164
1165 case 'c':
1166 printf ("option c with value '%s'\n", optarg);
1167 break;
1168
1169 case '?':
1170 break;
1171
1172 default:
1173 printf ("?? getopt returned character code 0%o ??\n", c);
1174 }
11721175 }
11731176
11741177 if (optind < argc)
11751178 {
11761179 printf ("non-option ARGV-elements: ");
11771180 while (optind < argc)
1178 printf ("%s ", argv[optind++]);
1181 printf ("%s ", argv[optind++]);
11791182 printf ("\n");
11801183 }
11811184
00 /* Declarations for getopt.
1 Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007,2009
2 Free Software Foundation, Inc.
1 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 Free Software
2 Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 This program is free software: you can redistribute it and/or modify
114114 # define __GNUC_PREREQ(maj, min) (0)
115115 # endif
116116 # if defined __cplusplus && __GNUC_PREREQ (2,8)
117 # define __THROW throw ()
117 # define __THROW throw ()
118118 # else
119119 # define __THROW
120120 # endif
121121 #endif
122
123 /* The definition of _GL_ARG_NONNULL is copied here. */
122124
123125 #ifdef __cplusplus
124126 extern "C" {
162164 zero.
163165
164166 The field `has_arg' is:
165 no_argument (or 0) if the option does not take an argument,
166 required_argument (or 1) if the option requires an argument,
167 optional_argument (or 2) if the option takes an optional argument.
167 no_argument (or 0) if the option does not take an argument,
168 required_argument (or 1) if the option requires an argument,
169 optional_argument (or 2) if the option takes an optional argument.
168170
169171 If the field `flag' is not NULL, it points to a variable that is set
170172 to the value given in the field `val' when the option is found, but
189191
190192 /* Names for the values of the `has_arg' field of `struct option'. */
191193
192 # define no_argument 0
193 # define required_argument 1
194 # define optional_argument 2
195 #endif /* need getopt */
194 # define no_argument 0
195 # define required_argument 1
196 # define optional_argument 2
197 #endif /* need getopt */
196198
197199
198200 /* Get definitions and prototypes for functions to process the
221223 the environment, then do not permute arguments. */
222224
223225 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
224 __THROW;
226 __THROW _GL_ARG_NONNULL ((2, 3));
225227
226228 #ifndef __need_getopt
227229 extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
228 const char *__shortopts,
229 const struct option *__longopts, int *__longind)
230 __THROW;
230 const char *__shortopts,
231 const struct option *__longopts, int *__longind)
232 __THROW _GL_ARG_NONNULL ((2, 3));
231233 extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
232 const char *__shortopts,
233 const struct option *__longopts, int *__longind)
234 __THROW;
234 const char *__shortopts,
235 const struct option *__longopts, int *__longind)
236 __THROW _GL_ARG_NONNULL ((2, 3));
235237
236238 #endif
237239
00 /* getopt_long and getopt_long_only entry points for GNU getopt.
1 Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006,2009
2 Free Software Foundation, Inc.
1 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
2 1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 This program is free software: you can redistribute it and/or modify
3131 #include <stdlib.h>
3232 #endif
3333
34 #ifndef NULL
34 #ifndef NULL
3535 #define NULL 0
3636 #endif
3737
3838 int
3939 getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
40 const struct option *long_options, int *opt_index)
40 const struct option *long_options, int *opt_index)
4141 {
4242 return _getopt_internal (argc, (char **) argv, options, long_options,
43 opt_index, 0, 0);
43 opt_index, 0, 0);
4444 }
4545
4646 int
4747 _getopt_long_r (int argc, char **argv, const char *options,
48 const struct option *long_options, int *opt_index,
49 struct _getopt_data *d)
48 const struct option *long_options, int *opt_index,
49 struct _getopt_data *d)
5050 {
5151 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
52 0, 0, d);
52 0, d, 0);
5353 }
5454
5555 /* Like getopt_long, but '-' as well as '--' can indicate a long option.
5959
6060 int
6161 getopt_long_only (int argc, char *__getopt_argv_const *argv,
62 const char *options,
63 const struct option *long_options, int *opt_index)
62 const char *options,
63 const struct option *long_options, int *opt_index)
6464 {
6565 return _getopt_internal (argc, (char **) argv, options, long_options,
66 opt_index, 1, 0);
66 opt_index, 1, 0);
6767 }
6868
6969 int
7070 _getopt_long_only_r (int argc, char **argv, const char *options,
71 const struct option *long_options, int *opt_index,
72 struct _getopt_data *d)
71 const struct option *long_options, int *opt_index,
72 struct _getopt_data *d)
7373 {
7474 return _getopt_internal_r (argc, argv, options, long_options, opt_index,
75 1, 0, d);
75 1, d, 0);
7676 }
7777
7878
9292 int option_index = 0;
9393 static const struct option long_options[] =
9494 {
95 {"add", 1, 0, 0},
96 {"append", 0, 0, 0},
97 {"delete", 1, 0, 0},
98 {"verbose", 0, 0, 0},
99 {"create", 0, 0, 0},
100 {"file", 1, 0, 0},
101 {0, 0, 0, 0}
95 {"add", 1, 0, 0},
96 {"append", 0, 0, 0},
97 {"delete", 1, 0, 0},
98 {"verbose", 0, 0, 0},
99 {"create", 0, 0, 0},
100 {"file", 1, 0, 0},
101 {0, 0, 0, 0}
102102 };
103103
104104 c = getopt_long (argc, argv, "abc:d:0123456789",
105 long_options, &option_index);
105 long_options, &option_index);
106106 if (c == -1)
107 break;
107 break;
108108
109109 switch (c)
110 {
111 case 0:
112 printf ("option %s", long_options[option_index].name);
113 if (optarg)
114 printf (" with arg %s", optarg);
115 printf ("\n");
116 break;
110 {
111 case 0:
112 printf ("option %s", long_options[option_index].name);
113 if (optarg)
114 printf (" with arg %s", optarg);
115 printf ("\n");
116 break;
117117
118 case '0':
119 case '1':
120 case '2':
121 case '3':
122 case '4':
123 case '5':
124 case '6':
125 case '7':
126 case '8':
127 case '9':
128 if (digit_optind != 0 && digit_optind != this_option_optind)
129 printf ("digits occur in two different argv-elements.\n");
130 digit_optind = this_option_optind;
131 printf ("option %c\n", c);
132 break;
118 case '0':
119 case '1':
120 case '2':
121 case '3':
122 case '4':
123 case '5':
124 case '6':
125 case '7':
126 case '8':
127 case '9':
128 if (digit_optind != 0 && digit_optind != this_option_optind)
129 printf ("digits occur in two different argv-elements.\n");
130 digit_optind = this_option_optind;
131 printf ("option %c\n", c);
132 break;
133133
134 case 'a':
135 printf ("option a\n");
136 break;
134 case 'a':
135 printf ("option a\n");
136 break;
137137
138 case 'b':
139 printf ("option b\n");
140 break;
138 case 'b':
139 printf ("option b\n");
140 break;
141141
142 case 'c':
143 printf ("option c with value `%s'\n", optarg);
144 break;
142 case 'c':
143 printf ("option c with value `%s'\n", optarg);
144 break;
145145
146 case 'd':
147 printf ("option d with value `%s'\n", optarg);
148 break;
146 case 'd':
147 printf ("option d with value `%s'\n", optarg);
148 break;
149149
150 case '?':
151 break;
150 case '?':
151 break;
152152
153 default:
154 printf ("?? getopt returned character code 0%o ??\n", c);
155 }
153 default:
154 printf ("?? getopt returned character code 0%o ??\n", c);
155 }
156156 }
157157
158158 if (optind < argc)
159159 {
160160 printf ("non-option ARGV-elements: ");
161161 while (optind < argc)
162 printf ("%s ", argv[optind++]);
162 printf ("%s ", argv[optind++]);
163163 printf ("\n");
164164 }
165165
00 /* Internal declarations for getopt.
1 Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009
2 Free Software Foundation, Inc.
1 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software
2 Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 This program is free software: you can redistribute it and/or modify
1616 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1717
1818 #ifndef _GETOPT_INT_H
19 #define _GETOPT_INT_H 1
19 #define _GETOPT_INT_H 1
2020
2121 #include <getopt.h>
2222
2323 extern int _getopt_internal (int ___argc, char **___argv,
24 const char *__shortopts,
25 const struct option *__longopts, int *__longind,
26 int __long_only, int __posixly_correct);
24 const char *__shortopts,
25 const struct option *__longopts, int *__longind,
26 int __long_only, int __posixly_correct);
2727
2828
2929 /* Reentrant versions which can handle parsing multiple argument
109109
110110 /* The initializer is necessary to set OPTIND and OPTERR to their
111111 default values and to clear the initialization flag. */
112 #define _GETOPT_DATA_INITIALIZER { 1, 1 }
112 #define _GETOPT_DATA_INITIALIZER { 1, 1 }
113113
114114 extern int _getopt_internal_r (int ___argc, char **___argv,
115 const char *__shortopts,
116 const struct option *__longopts, int *__longind,
117 int __long_only, int __posixly_correct,
118 struct _getopt_data *__data);
115 const char *__shortopts,
116 const struct option *__longopts, int *__longind,
117 int __long_only, struct _getopt_data *__data,
118 int __posixly_correct);
119119
120120 extern int _getopt_long_r (int ___argc, char **___argv,
121 const char *__shortopts,
122 const struct option *__longopts, int *__longind,
123 struct _getopt_data *__data);
121 const char *__shortopts,
122 const struct option *__longopts, int *__longind,
123 struct _getopt_data *__data);
124124
125125 extern int _getopt_long_only_r (int ___argc, char **___argv,
126 const char *__shortopts,
127 const struct option *__longopts,
128 int *__longind,
129 struct _getopt_data *__data);
126 const char *__shortopts,
127 const struct option *__longopts,
128 int *__longind,
129 struct _getopt_data *__data);
130130
131131 #endif /* getopt_int.h */
+0
-39
lib/getpagesize.c less more
0 /* getpagesize emulation for systems where it cannot be done in a C macro.
1
2 Copyright (C) 2007 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 /* Written by Bruno Haible and Martin Lambers. */
18
19 #include <config.h>
20
21 /* Specification. */
22 #include <unistd.h>
23
24 /* This implementation is only for native Win32 systems. */
25 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
26
27 # define WIN32_LEAN_AND_MEAN
28 # include <windows.h>
29
30 int
31 getpagesize (void)
32 {
33 SYSTEM_INFO system_info;
34 GetSystemInfo (&system_info);
35 return system_info.dwPageSize;
36 }
37
38 #endif
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Convenience header for conditional use of GNU <libintl.h>.
3 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc.
3 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software
4 Foundation, Inc.
45
56 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
141142 #endif
142143 static const char *
143144 pgettext_aux (const char *domain,
144 const char *msg_ctxt_id, const char *msgid,
145 int category)
145 const char *msg_ctxt_id, const char *msgid,
146 int category)
146147 {
147148 const char *translation = dcgettext (domain, msg_ctxt_id, category);
148149 if (translation == msg_ctxt_id)
160161 #endif
161162 static const char *
162163 npgettext_aux (const char *domain,
163 const char *msg_ctxt_id, const char *msgid,
164 const char *msgid_plural, unsigned long int n,
165 int category)
164 const char *msg_ctxt_id, const char *msgid,
165 const char *msgid_plural, unsigned long int n,
166 int category)
166167 {
167168 const char *translation =
168169 dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
200201 #endif
201202 static const char *
202203 dcpgettext_expr (const char *domain,
203 const char *msgctxt, const char *msgid,
204 int category)
204 const char *msgctxt, const char *msgid,
205 int category)
205206 {
206207 size_t msgctxt_len = strlen (msgctxt) + 1;
207208 size_t msgid_len = strlen (msgid) + 1;
223224 translation = dcgettext (domain, msg_ctxt_id, category);
224225 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
225226 if (msg_ctxt_id != buf)
226 free (msg_ctxt_id);
227 free (msg_ctxt_id);
227228 #endif
228229 if (translation != msg_ctxt_id)
229 return translation;
230 return translation;
230231 }
231232 return msgid;
232233 }
245246 #endif
246247 static const char *
247248 dcnpgettext_expr (const char *domain,
248 const char *msgctxt, const char *msgid,
249 const char *msgid_plural, unsigned long int n,
250 int category)
249 const char *msgctxt, const char *msgid,
250 const char *msgid_plural, unsigned long int n,
251 int category)
251252 {
252253 size_t msgctxt_len = strlen (msgctxt) + 1;
253254 size_t msgid_len = strlen (msgid) + 1;
269270 translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
270271 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
271272 if (msg_ctxt_id != buf)
272 free (msg_ctxt_id);
273 free (msg_ctxt_id);
273274 #endif
274275 if (!(translation == msg_ctxt_id || translation == msgid_plural))
275 return translation;
276 return translation;
276277 }
277278 return (n == 1 ? msgid : msgid_plural);
278279 }
00 /* gettime -- get the system clock
11
2 Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
2 Copyright (C) 2002, 2004-2007, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Provide gettimeofday for systems that don't have it or for which it's broken.
33
4 Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2009 Free Software
5 Foundation, Inc.
4 Copyright (C) 2001-2003, 2005-2007, 2009-2010 Free Software Foundation, Inc.
65
76 This program is free software; you can redistribute it and/or modify
87 it under the terms of the GNU General Public License as published by
00 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
11 ## Process this file with automake to produce Makefile.in.
2 # Copyright (C) 2002-2009 Free Software Foundation, Inc.
2 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
33 #
44 # This file is free software, distributed under the terms of the GNU
55 # General Public License. As a special exception to the GNU General
88 # the same distribution terms as the rest of that program.
99 #
1010 # Generated by gnulib-tool.
11 # Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libgzip --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=getline --avoid=rpmatch --no-libtool --macro-prefix=gl announce-gen calloc close closein fclose fcntl fcntl-safer fdl fprintf-posix getopt-gnu git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload lstat maintainer-makefile malloc perror printf-posix realloc stat-time sys_stat time update-copyright utimens xalloc yesno
11 # Reproduce by: gnulib-tool --import --dir=. --local-dir=gl --lib=libgzip --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=getline --avoid=rpmatch --no-libtool --macro-prefix=gl announce-gen calloc close closein fclose fcntl fcntl-safer fdl fdopendir fprintf-posix getopt-gnu git-version-gen gitlog-to-changelog gnu-make gnu-web-doc-update gnumakefile gnupload ignore-value lstat maintainer-makefile malloc manywarnings perror printf-posix realloc stat-time sys_stat time update-copyright utimens xalloc yesno
1212
1313 AUTOMAKE_OPTIONS = 1.5 gnits
1414
6060
6161 ## end gnulib module announce-gen
6262
63 ## begin gnulib module arg-nonnull
64
65 # The BUILT_SOURCES created by this Makefile snippet are not used via #include
66 # statements but through direct file reference. Therefore this snippet must be
67 # present in all Makefile.am that need it. This is ensured by the applicability
68 # 'all' defined above.
69
70 BUILT_SOURCES += arg-nonnull.h
71 # The arg-nonnull.h that gets inserted into generated .h files is the same as
72 # build-aux/arg-nonnull.h, except that it has the copyright header cut off.
73 arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h
74 $(AM_V_GEN)rm -f $@-t $@ && \
75 sed -n -e '/GL_ARG_NONNULL/,$$p' \
76 < $(top_srcdir)/build-aux/arg-nonnull.h \
77 > $@-t && \
78 mv $@-t $@
79 MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
80
81 ARG_NONNULL_H=arg-nonnull.h
82
83 EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h
84
85 ## end gnulib module arg-nonnull
86
6387 ## begin gnulib module calloc
6488
6589
77101 EXTRA_libgzip_a_SOURCES += calloc.c
78102
79103 ## end gnulib module calloc-posix
104
105 ## begin gnulib module chdir-long
106
107
108 EXTRA_DIST += chdir-long.c chdir-long.h
109
110 EXTRA_libgzip_a_SOURCES += chdir-long.c
111
112 ## end gnulib module chdir-long
113
114 ## begin gnulib module chown
115
116
117 EXTRA_DIST += chown.c fchown-stub.c
118
119 EXTRA_libgzip_a_SOURCES += chown.c fchown-stub.c
120
121 ## end gnulib module chown
80122
81123 ## begin gnulib module close
82124
183225
184226 ## end gnulib module configmake
185227
228 ## begin gnulib module dirent
229
230 BUILT_SOURCES += dirent.h
231
232 # We need the following in order to create <dirent.h> when the system
233 # doesn't have one that works with the given compiler.
234 dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
235 $(AM_V_GEN)rm -f $@-t $@ && \
236 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
237 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
238 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
239 -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
240 -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \
241 -e 's|@''GNULIB_FDOPENDIR''@|$(GNULIB_FDOPENDIR)|g' \
242 -e 's|@''GNULIB_SCANDIR''@|$(GNULIB_SCANDIR)|g' \
243 -e 's|@''GNULIB_ALPHASORT''@|$(GNULIB_ALPHASORT)|g' \
244 -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
245 -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
246 -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
247 -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
248 -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
249 -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
250 -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
251 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
252 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
253 < $(srcdir)/dirent.in.h; \
254 } > $@-t && \
255 mv $@-t $@
256 MOSTLYCLEANFILES += dirent.h dirent.h-t
257
258 EXTRA_DIST += dirent.in.h
259
260 ## end gnulib module dirent
261
262 ## begin gnulib module dirfd
263
264
265 EXTRA_DIST += dirfd.c
266
267 EXTRA_libgzip_a_SOURCES += dirfd.c
268
269 ## end gnulib module dirfd
270
271 ## begin gnulib module dirname-lgpl
272
273
274 EXTRA_DIST += basename-lgpl.c dirname-lgpl.c dirname.h stripslash.c
275
276 EXTRA_libgzip_a_SOURCES += basename-lgpl.c dirname-lgpl.c stripslash.c
277
278 ## end gnulib module dirname-lgpl
279
186280 ## begin gnulib module dup2
187281
188282
237331
238332 ## end gnulib module exitfail
239333
334 ## begin gnulib module fchdir
335
336
337 EXTRA_DIST += fchdir.c
338
339 EXTRA_libgzip_a_SOURCES += fchdir.c
340
341 ## end gnulib module fchdir
342
240343 ## begin gnulib module fclose
241344
242345
246349
247350 ## end gnulib module fclose
248351
352 ## begin gnulib module fcntl
353
354
355 EXTRA_DIST += fcntl.c
356
357 EXTRA_libgzip_a_SOURCES += fcntl.c
358
359 ## end gnulib module fcntl
360
249361 ## begin gnulib module fcntl-h
250362
251 BUILT_SOURCES += $(FCNTL_H)
363 BUILT_SOURCES += fcntl.h
252364
253365 # We need the following in order to create <fcntl.h> when the system
254366 # doesn't have one that works with the given compiler.
255 fcntl.h: fcntl.in.h
367 fcntl.h: fcntl.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
256368 $(AM_V_GEN)rm -f $@-t $@ && \
257369 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
258370 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
259371 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
260372 -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
373 -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \
261374 -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
262375 -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
376 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
377 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
378 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
263379 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
264380 -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
265 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
266381 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
382 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
267383 < $(srcdir)/fcntl.in.h; \
268384 } > $@-t && \
269385 mv $@-t $@
281397 EXTRA_libgzip_a_SOURCES += creat-safer.c open-safer.c
282398
283399 ## end gnulib module fcntl-safer
400
401 ## begin gnulib module fdopendir
402
403
404 EXTRA_DIST += fdopendir.c openat-priv.h openat-proc.c
405
406 EXTRA_libgzip_a_SOURCES += fdopendir.c openat-proc.c
407
408 ## end gnulib module fdopendir
284409
285410 ## begin gnulib module fflush
286411
413538
414539 ## end gnulib module gendocs
415540
541 ## begin gnulib module getcwd
542
543
544 EXTRA_DIST += getcwd.c
545
546 EXTRA_libgzip_a_SOURCES += getcwd.c
547
548 ## end gnulib module getcwd
549
416550 ## begin gnulib module getopt-posix
417551
418552 BUILT_SOURCES += $(GETOPT_H)
419553
420554 # We need the following in order to create <getopt.h> when the system
421555 # doesn't have one that works with the given compiler.
422 getopt.h: getopt.in.h
556 getopt.h: getopt.in.h $(ARG_NONNULL_H)
423557 $(AM_V_GEN)rm -f $@-t $@ && \
424558 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
425559 sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
426560 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
427561 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
428562 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
429 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
563 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
430564 < $(srcdir)/getopt.in.h; \
431565 } > $@-t && \
432566 mv -f $@-t $@
437571 EXTRA_libgzip_a_SOURCES += getopt.c getopt1.c
438572
439573 ## end gnulib module getopt-posix
440
441 ## begin gnulib module getpagesize
442
443
444 EXTRA_DIST += getpagesize.c
445
446 EXTRA_libgzip_a_SOURCES += getpagesize.c
447
448 ## end gnulib module getpagesize
449574
450575 ## begin gnulib module gettext-h
451576
522647
523648 ## end gnulib module gnupload
524649
650 ## begin gnulib module ignore-value
651
652 libgzip_a_SOURCES += ignore-value.h
653
654 ## end gnulib module ignore-value
655
525656 ## begin gnulib module intprops
526657
527658
556687
557688 ## end gnulib module isnanl-nolibm
558689
690 ## begin gnulib module lchown
691
692
693 EXTRA_DIST += lchown.c
694
695 EXTRA_libgzip_a_SOURCES += lchown.c
696
697 ## end gnulib module lchown
698
559699 ## begin gnulib module link-warning
560700
561 LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
701 # The BUILT_SOURCES created by this Makefile snippet are not used via #include
702 # statements but through direct file reference. Therefore this snippet must be
703 # present in all Makefile.am that need it. This is ensured by the applicability
704 # 'all' defined above.
705
706 BUILT_SOURCES += link-warning.h
707 # The link-warning.h that gets inserted into generated .h files is the same as
708 # build-aux/link-warning.h, except that it has the copyright header cut off.
709 link-warning.h: $(top_srcdir)/build-aux/link-warning.h
710 $(AM_V_GEN)rm -f $@-t $@ && \
711 sed -n -e '/GL_LINK_WARNING/,$$p' \
712 < $(top_srcdir)/build-aux/link-warning.h \
713 > $@-t && \
714 mv $@-t $@
715 MOSTLYCLEANFILES += link-warning.h link-warning.h-t
716
717 LINK_WARNING_H=link-warning.h
562718
563719 EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
564720
686842
687843 # We need the following in order to create <math.h> when the system
688844 # doesn't have one that works with the given compiler.
689 math.h: math.in.h
845 math.h: math.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
690846 $(AM_V_GEN)rm -f $@-t $@ && \
691847 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
692848 sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
693849 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
694850 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
851 -e 's|@''GNULIB_ACOSL''@|$(GNULIB_ACOSL)|g' \
852 -e 's|@''GNULIB_ASINL''@|$(GNULIB_ASINL)|g' \
853 -e 's|@''GNULIB_ATANL''@|$(GNULIB_ATANL)|g' \
695854 -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \
696855 -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \
856 -e 's|@''GNULIB_COSL''@|$(GNULIB_COSL)|g' \
857 -e 's|@''GNULIB_EXPL''@|$(GNULIB_EXPL)|g' \
697858 -e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \
698859 -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \
699860 -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \
705866 -e 's|@''GNULIB_ISNAND''@|$(GNULIB_ISNAND)|g' \
706867 -e 's|@''GNULIB_ISNANL''@|$(GNULIB_ISNANL)|g' \
707868 -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \
708 -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \
869 -e 's|@''GNULIB_LOGL''@|$(GNULIB_LOGL)|g' \
709870 -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \
710871 -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \
711872 -e 's|@''GNULIB_ROUNDL''@|$(GNULIB_ROUNDL)|g' \
712873 -e 's|@''GNULIB_SIGNBIT''@|$(GNULIB_SIGNBIT)|g' \
874 -e 's|@''GNULIB_SINL''@|$(GNULIB_SINL)|g' \
875 -e 's|@''GNULIB_SQRTL''@|$(GNULIB_SQRTL)|g' \
876 -e 's|@''GNULIB_TANL''@|$(GNULIB_TANL)|g' \
713877 -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \
714878 -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \
715879 -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \
880 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
881 -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
882 -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
883 -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
884 -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
716885 -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
717886 -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
718887 -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
888 -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \
889 -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
890 -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \
891 -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
719892 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
720893 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
721894 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
748921 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
749922 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
750923 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
924 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
925 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
751926 < $(srcdir)/math.in.h; \
752927 } > $@-t && \
753928 mv $@-t $@
784959
785960 ## end gnulib module memchr
786961
962 ## begin gnulib module mempcpy
963
964
965 EXTRA_DIST += mempcpy.c
966
967 EXTRA_libgzip_a_SOURCES += mempcpy.c
968
969 ## end gnulib module mempcpy
970
971 ## begin gnulib module memrchr
972
973
974 EXTRA_DIST += memrchr.c
975
976 EXTRA_libgzip_a_SOURCES += memrchr.c
977
978 ## end gnulib module memrchr
979
980 ## begin gnulib module mkdir
981
982
983 EXTRA_DIST += mkdir.c
984
985 EXTRA_libgzip_a_SOURCES += mkdir.c
986
987 ## end gnulib module mkdir
988
787989 ## begin gnulib module open
788990
789991
793995
794996 ## end gnulib module open
795997
998 ## begin gnulib module openat
999
1000
1001 EXTRA_DIST += at-func.c fchmodat.c fchownat.c fstatat.c mkdirat.c openat-priv.h openat-proc.c openat.c openat.h unlinkat.c
1002
1003 EXTRA_libgzip_a_SOURCES += at-func.c fchmodat.c fchownat.c fstatat.c mkdirat.c openat-proc.c openat.c unlinkat.c
1004
1005 ## end gnulib module openat
1006
1007 ## begin gnulib module openat-die
1008
1009 libgzip_a_SOURCES += openat-die.c
1010
1011 ## end gnulib module openat-die
1012
7961013 ## begin gnulib module perror
7971014
7981015
8551072 EXTRA_libgzip_a_SOURCES += realloc.c
8561073
8571074 ## end gnulib module realloc-posix
1075
1076 ## begin gnulib module rmdir
1077
1078
1079 EXTRA_DIST += rmdir.c
1080
1081 EXTRA_libgzip_a_SOURCES += rmdir.c
1082
1083 ## end gnulib module rmdir
1084
1085 ## begin gnulib module same-inode
1086
1087
1088 EXTRA_DIST += same-inode.h
1089
1090 ## end gnulib module same-inode
1091
1092 ## begin gnulib module save-cwd
1093
1094
1095 EXTRA_DIST += save-cwd.c save-cwd.h
1096
1097 EXTRA_libgzip_a_SOURCES += save-cwd.c
1098
1099 ## end gnulib module save-cwd
8581100
8591101 ## begin gnulib module signbit
8601102
9761218
9771219 # We need the following in order to create <stdio.h> when the system
9781220 # doesn't have one that works with the given compiler.
979 stdio.h: stdio.in.h
1221 stdio.h: stdio.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
9801222 $(AM_V_GEN)rm -f $@-t $@ && \
9811223 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
9821224 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
10221264 -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
10231265 -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
10241266 -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
1025 -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
1267 < $(srcdir)/stdio.in.h | \
1268 sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
10261269 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
10271270 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
10281271 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
10611304 -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
10621305 -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
10631306 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1064 < $(srcdir)/stdio.in.h; \
1307 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1308 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
10651309 } > $@-t && \
10661310 mv $@-t $@
10671311 MOSTLYCLEANFILES += stdio.h stdio.h-t
10781322
10791323 # We need the following in order to create <stdlib.h> when the system
10801324 # doesn't have one that works with the given compiler.
1081 stdlib.h: stdlib.in.h
1325 stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
10821326 $(AM_V_GEN)rm -f $@-t $@ && \
10831327 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
10841328 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
10921336 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
10931337 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
10941338 -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
1339 -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
10951340 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
1341 -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
10961342 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
10971343 -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
10981344 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
11111357 -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
11121358 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
11131359 -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
1360 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
1361 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
11141362 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
11151363 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
11161364 -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
11271375 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
11281376 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
11291377 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
1378 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
11301379 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
1131 -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
1380 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
11321381 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1382 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
11331383 < $(srcdir)/stdlib.in.h; \
11341384 } > $@-t && \
11351385 mv $@-t $@
11391389
11401390 ## end gnulib module stdlib
11411391
1392 ## begin gnulib module strdup-posix
1393
1394
1395 EXTRA_DIST += strdup.c
1396
1397 EXTRA_libgzip_a_SOURCES += strdup.c
1398
1399 ## end gnulib module strdup-posix
1400
11421401 ## begin gnulib module streq
11431402
11441403
11611420
11621421 # We need the following in order to create <string.h> when the system
11631422 # doesn't have one that works with the given compiler.
1164 string.h: string.in.h
1423 string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
11651424 $(AM_V_GEN)rm -f $@-t $@ && \
11661425 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
11671426 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
12001459 -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
12011460 -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
12021461 -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
1462 < $(srcdir)/string.in.h | \
1463 sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
12031464 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
12041465 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
12051466 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
12281489 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
12291490 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
12301491 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1231 < $(srcdir)/string.in.h; \
1492 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)'; \
12321493 } > $@-t && \
12331494 mv $@-t $@
12341495 MOSTLYCLEANFILES += string.h string.h-t
12431504
12441505 # We need the following in order to create <sys/stat.h> when the system
12451506 # has one that is incomplete.
1246 sys/stat.h: sys_stat.in.h
1507 sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
12471508 $(AM_V_at)$(MKDIR_P) sys
12481509 $(AM_V_GEN)rm -f $@-t $@ && \
12491510 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
12561517 -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
12571518 -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
12581519 -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
1520 -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \
12591521 -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \
1522 -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \
12601523 -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \
12611524 -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
12621525 -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \
12661529 -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
12671530 -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
12681531 -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
1532 -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
12691533 -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
1534 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
12701535 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
12711536 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
12721537 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
12741539 -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
12751540 -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
12761541 -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
1542 -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
1543 -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
12771544 -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
12781545 -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
12791546 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1547 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
12801548 < $(srcdir)/sys_stat.in.h; \
12811549 } > $@-t && \
12821550 mv $@-t $@
12931561
12941562 # We need the following in order to create <sys/time.h> when the system
12951563 # doesn't have one that works with the given compiler.
1296 sys/time.h: sys_time.in.h
1564 sys/time.h: sys_time.in.h $(ARG_NONNULL_H)
12971565 $(AM_V_at)$(MKDIR_P) sys
12981566 $(AM_V_GEN)rm -f $@-t $@ && \
12991567 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
13031571 -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
13041572 -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
13051573 -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
1574 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
13061575 < $(srcdir)/sys_time.in.h; \
13071576 } > $@-t && \
13081577 mv $@-t $@
13181587
13191588 # We need the following in order to create <time.h> when the system
13201589 # doesn't have one that works with the given compiler.
1321 time.h: time.in.h
1590 time.h: time.in.h $(ARG_NONNULL_H)
13221591 $(AM_V_GEN)rm -f $@-t $@ && \
13231592 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
13241593 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
13311600 -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
13321601 -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
13331602 -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
1603 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
13341604 < $(srcdir)/time.in.h; \
13351605 } > $@-t && \
13361606 mv $@-t $@
13531623
13541624 # We need the following in order to create an empty placeholder for
13551625 # <unistd.h> when the system doesn't have one.
1356 unistd.h: unistd.in.h
1626 unistd.h: unistd.in.h $(LINK_WARNING_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
13571627 $(AM_V_GEN)rm -f $@-t $@ && \
13581628 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
13591629 sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
13741644 -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
13751645 -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
13761646 -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
1647 -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \
13771648 -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
1649 -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \
13781650 -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
13791651 -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
13801652 -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
13831655 -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
13841656 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
13851657 -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
1658 -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
13861659 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
13871660 -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
13881661 -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
13931666 -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
13941667 -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
13951668 -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
1669 -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \
13961670 -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
1671 < $(srcdir)/unistd.in.h | \
1672 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
13971673 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
13981674 -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
13991675 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
14031679 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
14041680 -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
14051681 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
1682 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
14061683 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
1684 -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
14071685 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
14081686 -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
1687 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
14091688 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
14101689 -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
14111690 -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
1691 -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
14121692 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
14131693 -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
14141694 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
14151695 -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
14161696 -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
14171697 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
1698 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
14181699 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
14191700 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
14201701 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
14261707 -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
14271708 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
14281709 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
1710 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
14291711 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
14301712 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
14311713 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
14321714 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
14331715 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
1716 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
14341717 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
14351718 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
1719 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
14361720 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
14371721 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
14381722 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
1723 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
14391724 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
14401725 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
14411726 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
14421727 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1443 < $(srcdir)/unistd.in.h; \
1728 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1729 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
14441730 } > $@-t && \
14451731 mv $@-t $@
14461732 MOSTLYCLEANFILES += unistd.h unistd.h-t
14581744
14591745 ## end gnulib module unistd-safer
14601746
1747 ## begin gnulib module unlink
1748
1749
1750 EXTRA_DIST += unlink.c
1751
1752 EXTRA_libgzip_a_SOURCES += unlink.c
1753
1754 ## end gnulib module unlink
1755
14611756 ## begin gnulib module update-copyright
14621757
14631758
15121807
15131808 ## end gnulib module vfprintf-posix
15141809
1810 ## begin gnulib module warn-on-use
1811
1812 BUILT_SOURCES += warn-on-use.h
1813 # The warn-on-use.h that gets inserted into generated .h files is the same as
1814 # build-aux/warn-on-use.h, except that it has the copyright header cut off.
1815 warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h
1816 $(AM_V_GEN)rm -f $@-t $@ && \
1817 sed -n -e '/^.ifndef/,$$p' \
1818 < $(top_srcdir)/build-aux/warn-on-use.h \
1819 > $@-t && \
1820 mv $@-t $@
1821 MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
1822
1823 WARN_ON_USE_H=warn-on-use.h
1824
1825 EXTRA_DIST += $(top_srcdir)/build-aux/warn-on-use.h
1826
1827 ## end gnulib module warn-on-use
1828
15151829 ## begin gnulib module wchar
15161830
1517 BUILT_SOURCES += $(WCHAR_H)
1831 BUILT_SOURCES += wchar.h
15181832
15191833 # We need the following in order to create <wchar.h> when the system
15201834 # version does not work standalone.
1521 wchar.h: wchar.in.h
1835 wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
15221836 $(AM_V_GEN)rm -f $@-t $@ && \
15231837 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
15241838 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
15611875 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
15621876 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
15631877 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
1878 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
15641879 < $(srcdir)/wchar.in.h; \
15651880 } > $@-t && \
15661881 mv $@-t $@
16101925
16111926 ## end gnulib module xalloc-die
16121927
1928 ## begin gnulib module xgetcwd
1929
1930
1931 EXTRA_DIST += xgetcwd.c xgetcwd.h
1932
1933 EXTRA_libgzip_a_SOURCES += xgetcwd.c
1934
1935 ## end gnulib module xgetcwd
1936
16131937 ## begin gnulib module xsize
16141938
16151939 libgzip_a_SOURCES += xsize.h
0 /* ignore a function return without a compiler warning
1
2 Copyright (C) 2008-2010 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 /* Written by Jim Meyering. */
18
19 /* Use these functions to avoid a warning when using a function declared with
20 gcc's warn_unused_result attribute, but for which you really do want to
21 ignore the result. Traditionally, people have used a "(void)" cast to
22 indicate that a function's return value is deliberately unused. However,
23 if the function is declared with __attribute__((warn_unused_result)),
24 gcc issues a warning even with the cast.
25
26 Caution: most of the time, you really should heed gcc's warning, and
27 check the return value. However, in those exceptional cases in which
28 you're sure you know what you're doing, use this function.
29
30 For the record, here's one of the ignorable warnings:
31 "copy.c:233: warning: ignoring return value of 'fchown',
32 declared with attribute warn_unused_result". */
33
34 static inline void ignore_value (int i) { (void) i; }
35 static inline void ignore_ptr (void* p) { (void) p; }
36 /* FIXME: what about aggregate types? */
00 /* intprops.h -- properties of integer types
11
2 Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free Software
3 Foundation, Inc.
34
45 This program is free software: you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
1617
1718 /* Written by Paul Eggert. */
1819
19 #include <limits.h>
20 #ifndef GL_INTPROPS_H
21 # define GL_INTPROPS_H
22
23 # include <limits.h>
2024
2125 /* The extra casts in the following macros work around compiler bugs,
2226 e.g., in Cray C 5.0.3.0. */
2327
2428 /* True if the arithmetic type T is an integer type. bool counts as
2529 an integer. */
26 #define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
30 # define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
2731
2832 /* True if negative values of the signed integer type T use two's
2933 complement, ones' complement, or signed magnitude representation,
3034 respectively. Much GNU code assumes two's complement, but some
3135 people like to be portable to all possible C hosts. */
32 #define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
33 #define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
34 #define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
36 # define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
37 # define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
38 # define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
3539
3640 /* True if the arithmetic type T is signed. */
37 #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
41 # define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
3842
3943 /* The maximum and minimum values for the integer type T. These
4044 macros have undefined behavior if T is signed and has padding bits.
4145 If this is a problem for you, please let us know how to fix it for
4246 your host. */
43 #define TYPE_MINIMUM(t) \
47 # define TYPE_MINIMUM(t) \
4448 ((t) (! TYPE_SIGNED (t) \
45 ? (t) 0 \
46 : TYPE_SIGNED_MAGNITUDE (t) \
47 ? ~ (t) 0 \
48 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
49 #define TYPE_MAXIMUM(t) \
49 ? (t) 0 \
50 : TYPE_SIGNED_MAGNITUDE (t) \
51 ? ~ (t) 0 \
52 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
53 # define TYPE_MAXIMUM(t) \
5054 ((t) (! TYPE_SIGNED (t) \
51 ? (t) -1 \
52 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
55 ? (t) -1 \
56 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
5357
5458 /* Return zero if T can be determined to be an unsigned type.
5559 Otherwise, return 1.
5761 tighter bound. Otherwise, it overestimates the true bound by one byte
5862 when applied to unsigned types of size 2, 4, 16, ... bytes.
5963 The symbol signed_type_or_expr__ is private to this header file. */
60 #if __GNUC__ >= 2
61 # define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
62 #else
63 # define signed_type_or_expr__(t) 1
64 #endif
64 # if __GNUC__ >= 2
65 # define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
66 # else
67 # define signed_type_or_expr__(t) 1
68 # endif
6569
6670 /* Bound on length of the string representing an integer type or expression T.
6771 Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485;
6872 add 1 for integer division truncation; add 1 more for a minus sign
6973 if needed. */
70 #define INT_STRLEN_BOUND(t) \
74 # define INT_STRLEN_BOUND(t) \
7175 ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \
7276 + signed_type_or_expr__ (t) + 1)
7377
7478 /* Bound on buffer size needed to represent an integer type or expression T,
7579 including the terminating null. */
76 #define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
80 # define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
81
82 #endif /* GL_INTPROPS_H */
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
139139 -Infinity, which have the same exponent. */
140140 m.value = x;
141141 if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD])
142 & (EXP_MASK << EXPBIT0_BIT))
143 == 0)
142 & (EXP_MASK << EXPBIT0_BIT))
143 == 0)
144144 return (memcmp (&m.value, &plus_inf, SIZE) != 0
145 && memcmp (&m.value, &minus_inf, SIZE) != 0);
145 && memcmp (&m.value, &minus_inf, SIZE) != 0);
146146 else
147147 return 0;
148148 }
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2008 Free Software Foundation, Inc.
1 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Test for NaN that does not need libm.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
0 /* Provide a stub lchown function for systems that lack it.
1
2 Copyright (C) 1998-1999, 2002, 2004, 2006-2007, 2009-2010 Free Software
3 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 /* written by Jim Meyering */
19
20 #include <config.h>
21
22 #include <unistd.h>
23
24 #include <errno.h>
25 #include <stdbool.h>
26 #include <string.h>
27 #include <sys/stat.h>
28
29 #if !HAVE_LCHOWN
30
31 /* If the system chown does not follow symlinks, we don't want it
32 replaced by gnulib's chown, which does follow symlinks. */
33 # if CHOWN_MODIFIES_SYMLINK
34 # undef chown
35 # endif
36
37 /* Work just like chown, except when FILE is a symbolic link.
38 In that case, set errno to EOPNOTSUPP and return -1.
39 But if autoconf tests determined that chown modifies
40 symlinks, then just call chown. */
41
42 int
43 lchown (const char *file, uid_t uid, gid_t gid)
44 {
45 # if HAVE_CHOWN
46 # if ! CHOWN_MODIFIES_SYMLINK
47 struct stat stats;
48
49 if (lstat (file, &stats) == 0 && S_ISLNK (stats.st_mode))
50 {
51 errno = EOPNOTSUPP;
52 return -1;
53 }
54 # endif
55
56 return chown (file, uid, gid);
57
58 # else /* !HAVE_CHOWN */
59 errno = ENOSYS;
60 return -1;
61 # endif
62 }
63
64 #else /* HAVE_LCHOWN */
65
66 # undef lchown
67
68 /* Work around trailing slash bugs in lchown. */
69 int
70 rpl_lchown (const char *file, uid_t uid, gid_t gid)
71 {
72 struct stat st;
73 bool stat_valid = false;
74 int result;
75
76 # if CHOWN_CHANGE_TIME_BUG
77 if (gid != (gid_t) -1 || uid != (uid_t) -1)
78 {
79 if (lstat (file, &st))
80 return -1;
81 stat_valid = true;
82 if (!S_ISLNK (st.st_mode))
83 return chown (file, uid, gid);
84 }
85 # endif
86
87 # if CHOWN_TRAILING_SLASH_BUG
88 if (!stat_valid)
89 {
90 size_t len = strlen (file);
91 if (len && file[len - 1] == '/')
92 return chown (file, uid, gid);
93 }
94 # endif
95
96 result = lchown (file, uid, gid);
97
98 # if CHOWN_CHANGE_TIME_BUG && HAVE_LCHMOD
99 if (result == 0 && stat_valid
100 && (uid == st.st_uid || uid == (uid_t) -1)
101 && (gid == st.st_gid || gid == (gid_t) -1))
102 {
103 /* No change in ownership, but at least one argument was not -1,
104 so we are required to update ctime. Since lchown succeeded,
105 we assume that lchmod will do likewise. But if the system
106 lacks lchmod and lutimes, we are out of luck. Oh well. */
107 result = lchmod (file, st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO
108 | S_ISUID | S_ISGID | S_ISVTX));
109 }
110 # endif
111
112 return result;
113 }
114
115 #endif /* HAVE_LCHOWN */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Determine a canonical name for the current locale's character encoding.
33
4 Copyright (C) 2000-2006, 2008-2009 Free Software Foundation, Inc.
4 Copyright (C) 2000-2006, 2008-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
130130 char *file_name;
131131
132132 /* Make it possible to override the charset.alias location. This is
133 necessary for running the testsuite before "make install". */
133 necessary for running the testsuite before "make install". */
134134 dir = getenv ("CHARSETALIASDIR");
135135 if (dir == NULL || dir[0] == '\0')
136 dir = relocate (LIBDIR);
136 dir = relocate (LIBDIR);
137137
138138 /* Concatenate dir and base into freshly allocated file_name. */
139139 {
140 size_t dir_len = strlen (dir);
141 size_t base_len = strlen (base);
142 int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
143 file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
144 if (file_name != NULL)
145 {
146 memcpy (file_name, dir, dir_len);
147 if (add_slash)
148 file_name[dir_len] = DIRECTORY_SEPARATOR;
149 memcpy (file_name + dir_len + add_slash, base, base_len + 1);
150 }
140 size_t dir_len = strlen (dir);
141 size_t base_len = strlen (base);
142 int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
143 file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
144 if (file_name != NULL)
145 {
146 memcpy (file_name, dir, dir_len);
147 if (add_slash)
148 file_name[dir_len] = DIRECTORY_SEPARATOR;
149 memcpy (file_name + dir_len + add_slash, base, base_len + 1);
150 }
151151 }
152152
153153 if (file_name == NULL)
154 /* Out of memory. Treat the file as empty. */
155 cp = "";
154 /* Out of memory. Treat the file as empty. */
155 cp = "";
156156 else
157 {
158 int fd;
159
160 /* Open the file. Reject symbolic links on platforms that support
161 O_NOFOLLOW. This is a security feature. Without it, an attacker
162 could retrieve parts of the contents (namely, the tail of the
163 first line that starts with "* ") of an arbitrary file by placing
164 a symbolic link to that file under the name "charset.alias" in
165 some writable directory and defining the environment variable
166 CHARSETALIASDIR to point to that directory. */
167 fd = open (file_name,
168 O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
169 if (fd < 0)
170 /* File not found. Treat it as empty. */
171 cp = "";
172 else
173 {
174 FILE *fp;
175
176 fp = fdopen (fd, "r");
177 if (fp == NULL)
178 {
179 /* Out of memory. Treat the file as empty. */
180 close (fd);
181 cp = "";
182 }
183 else
184 {
185 /* Parse the file's contents. */
186 char *res_ptr = NULL;
187 size_t res_size = 0;
188
189 for (;;)
190 {
191 int c;
192 char buf1[50+1];
193 char buf2[50+1];
194 size_t l1, l2;
195 char *old_res_ptr;
196
197 c = getc (fp);
198 if (c == EOF)
199 break;
200 if (c == '\n' || c == ' ' || c == '\t')
201 continue;
202 if (c == '#')
203 {
204 /* Skip comment, to end of line. */
205 do
206 c = getc (fp);
207 while (!(c == EOF || c == '\n'));
208 if (c == EOF)
209 break;
210 continue;
211 }
212 ungetc (c, fp);
213 if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
214 break;
215 l1 = strlen (buf1);
216 l2 = strlen (buf2);
217 old_res_ptr = res_ptr;
218 if (res_size == 0)
219 {
220 res_size = l1 + 1 + l2 + 1;
221 res_ptr = (char *) malloc (res_size + 1);
222 }
223 else
224 {
225 res_size += l1 + 1 + l2 + 1;
226 res_ptr = (char *) realloc (res_ptr, res_size + 1);
227 }
228 if (res_ptr == NULL)
229 {
230 /* Out of memory. */
231 res_size = 0;
232 if (old_res_ptr != NULL)
233 free (old_res_ptr);
234 break;
235 }
236 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
237 strcpy (res_ptr + res_size - (l2 + 1), buf2);
238 }
239 fclose (fp);
240 if (res_size == 0)
241 cp = "";
242 else
243 {
244 *(res_ptr + res_size) = '\0';
245 cp = res_ptr;
246 }
247 }
248 }
249
250 free (file_name);
251 }
157 {
158 int fd;
159
160 /* Open the file. Reject symbolic links on platforms that support
161 O_NOFOLLOW. This is a security feature. Without it, an attacker
162 could retrieve parts of the contents (namely, the tail of the
163 first line that starts with "* ") of an arbitrary file by placing
164 a symbolic link to that file under the name "charset.alias" in
165 some writable directory and defining the environment variable
166 CHARSETALIASDIR to point to that directory. */
167 fd = open (file_name,
168 O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
169 if (fd < 0)
170 /* File not found. Treat it as empty. */
171 cp = "";
172 else
173 {
174 FILE *fp;
175
176 fp = fdopen (fd, "r");
177 if (fp == NULL)
178 {
179 /* Out of memory. Treat the file as empty. */
180 close (fd);
181 cp = "";
182 }
183 else
184 {
185 /* Parse the file's contents. */
186 char *res_ptr = NULL;
187 size_t res_size = 0;
188
189 for (;;)
190 {
191 int c;
192 char buf1[50+1];
193 char buf2[50+1];
194 size_t l1, l2;
195 char *old_res_ptr;
196
197 c = getc (fp);
198 if (c == EOF)
199 break;
200 if (c == '\n' || c == ' ' || c == '\t')
201 continue;
202 if (c == '#')
203 {
204 /* Skip comment, to end of line. */
205 do
206 c = getc (fp);
207 while (!(c == EOF || c == '\n'));
208 if (c == EOF)
209 break;
210 continue;
211 }
212 ungetc (c, fp);
213 if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
214 break;
215 l1 = strlen (buf1);
216 l2 = strlen (buf2);
217 old_res_ptr = res_ptr;
218 if (res_size == 0)
219 {
220 res_size = l1 + 1 + l2 + 1;
221 res_ptr = (char *) malloc (res_size + 1);
222 }
223 else
224 {
225 res_size += l1 + 1 + l2 + 1;
226 res_ptr = (char *) realloc (res_ptr, res_size + 1);
227 }
228 if (res_ptr == NULL)
229 {
230 /* Out of memory. */
231 res_size = 0;
232 if (old_res_ptr != NULL)
233 free (old_res_ptr);
234 break;
235 }
236 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
237 strcpy (res_ptr + res_size - (l2 + 1), buf2);
238 }
239 fclose (fp);
240 if (res_size == 0)
241 cp = "";
242 else
243 {
244 *(res_ptr + res_size) = '\0';
245 cp = res_ptr;
246 }
247 }
248 }
249
250 free (file_name);
251 }
252252
253253 #else
254254
255255 # if defined DARWIN7
256256 /* To avoid the trouble of installing a file that is shared by many
257 GNU packages -- many packaging systems have problems with this --,
258 simply inline the aliases here. */
257 GNU packages -- many packaging systems have problems with this --,
258 simply inline the aliases here. */
259259 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
260 "ISO8859-2" "\0" "ISO-8859-2" "\0"
261 "ISO8859-4" "\0" "ISO-8859-4" "\0"
262 "ISO8859-5" "\0" "ISO-8859-5" "\0"
263 "ISO8859-7" "\0" "ISO-8859-7" "\0"
264 "ISO8859-9" "\0" "ISO-8859-9" "\0"
265 "ISO8859-13" "\0" "ISO-8859-13" "\0"
266 "ISO8859-15" "\0" "ISO-8859-15" "\0"
267 "KOI8-R" "\0" "KOI8-R" "\0"
268 "KOI8-U" "\0" "KOI8-U" "\0"
269 "CP866" "\0" "CP866" "\0"
270 "CP949" "\0" "CP949" "\0"
271 "CP1131" "\0" "CP1131" "\0"
272 "CP1251" "\0" "CP1251" "\0"
273 "eucCN" "\0" "GB2312" "\0"
274 "GB2312" "\0" "GB2312" "\0"
275 "eucJP" "\0" "EUC-JP" "\0"
276 "eucKR" "\0" "EUC-KR" "\0"
277 "Big5" "\0" "BIG5" "\0"
278 "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
279 "GBK" "\0" "GBK" "\0"
280 "GB18030" "\0" "GB18030" "\0"
281 "SJIS" "\0" "SHIFT_JIS" "\0"
282 "ARMSCII-8" "\0" "ARMSCII-8" "\0"
283 "PT154" "\0" "PT154" "\0"
284 /*"ISCII-DEV" "\0" "?" "\0"*/
285 "*" "\0" "UTF-8" "\0";
260 "ISO8859-2" "\0" "ISO-8859-2" "\0"
261 "ISO8859-4" "\0" "ISO-8859-4" "\0"
262 "ISO8859-5" "\0" "ISO-8859-5" "\0"
263 "ISO8859-7" "\0" "ISO-8859-7" "\0"
264 "ISO8859-9" "\0" "ISO-8859-9" "\0"
265 "ISO8859-13" "\0" "ISO-8859-13" "\0"
266 "ISO8859-15" "\0" "ISO-8859-15" "\0"
267 "KOI8-R" "\0" "KOI8-R" "\0"
268 "KOI8-U" "\0" "KOI8-U" "\0"
269 "CP866" "\0" "CP866" "\0"
270 "CP949" "\0" "CP949" "\0"
271 "CP1131" "\0" "CP1131" "\0"
272 "CP1251" "\0" "CP1251" "\0"
273 "eucCN" "\0" "GB2312" "\0"
274 "GB2312" "\0" "GB2312" "\0"
275 "eucJP" "\0" "EUC-JP" "\0"
276 "eucKR" "\0" "EUC-KR" "\0"
277 "Big5" "\0" "BIG5" "\0"
278 "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
279 "GBK" "\0" "GBK" "\0"
280 "GB18030" "\0" "GB18030" "\0"
281 "SJIS" "\0" "SHIFT_JIS" "\0"
282 "ARMSCII-8" "\0" "ARMSCII-8" "\0"
283 "PT154" "\0" "PT154" "\0"
284 /*"ISCII-DEV" "\0" "?" "\0"*/
285 "*" "\0" "UTF-8" "\0";
286286 # endif
287287
288288 # if defined VMS
289289 /* To avoid the troubles of an extra file charset.alias_vms in the
290 sources of many GNU packages, simply inline the aliases here. */
290 sources of many GNU packages, simply inline the aliases here. */
291291 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
292 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
293 section 10.7 "Handling Different Character Sets". */
292 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
293 section 10.7 "Handling Different Character Sets". */
294294 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
295 "ISO8859-2" "\0" "ISO-8859-2" "\0"
296 "ISO8859-5" "\0" "ISO-8859-5" "\0"
297 "ISO8859-7" "\0" "ISO-8859-7" "\0"
298 "ISO8859-8" "\0" "ISO-8859-8" "\0"
299 "ISO8859-9" "\0" "ISO-8859-9" "\0"
300 /* Japanese */
301 "eucJP" "\0" "EUC-JP" "\0"
302 "SJIS" "\0" "SHIFT_JIS" "\0"
303 "DECKANJI" "\0" "DEC-KANJI" "\0"
304 "SDECKANJI" "\0" "EUC-JP" "\0"
305 /* Chinese */
306 "eucTW" "\0" "EUC-TW" "\0"
307 "DECHANYU" "\0" "DEC-HANYU" "\0"
308 "DECHANZI" "\0" "GB2312" "\0"
309 /* Korean */
310 "DECKOREAN" "\0" "EUC-KR" "\0";
295 "ISO8859-2" "\0" "ISO-8859-2" "\0"
296 "ISO8859-5" "\0" "ISO-8859-5" "\0"
297 "ISO8859-7" "\0" "ISO-8859-7" "\0"
298 "ISO8859-8" "\0" "ISO-8859-8" "\0"
299 "ISO8859-9" "\0" "ISO-8859-9" "\0"
300 /* Japanese */
301 "eucJP" "\0" "EUC-JP" "\0"
302 "SJIS" "\0" "SHIFT_JIS" "\0"
303 "DECKANJI" "\0" "DEC-KANJI" "\0"
304 "SDECKANJI" "\0" "EUC-JP" "\0"
305 /* Chinese */
306 "eucTW" "\0" "EUC-TW" "\0"
307 "DECHANYU" "\0" "DEC-HANYU" "\0"
308 "DECHANZI" "\0" "GB2312" "\0"
309 /* Korean */
310 "DECKOREAN" "\0" "EUC-KR" "\0";
311311 # endif
312312
313313 # if defined WIN32_NATIVE || defined __CYGWIN__
314314 /* To avoid the troubles of installing a separate file in the same
315 directory as the DLL and of retrieving the DLL's directory at
316 runtime, simply inline the aliases here. */
315 directory as the DLL and of retrieving the DLL's directory at
316 runtime, simply inline the aliases here. */
317317
318318 cp = "CP936" "\0" "GBK" "\0"
319 "CP1361" "\0" "JOHAB" "\0"
320 "CP20127" "\0" "ASCII" "\0"
321 "CP20866" "\0" "KOI8-R" "\0"
322 "CP20936" "\0" "GB2312" "\0"
323 "CP21866" "\0" "KOI8-RU" "\0"
324 "CP28591" "\0" "ISO-8859-1" "\0"
325 "CP28592" "\0" "ISO-8859-2" "\0"
326 "CP28593" "\0" "ISO-8859-3" "\0"
327 "CP28594" "\0" "ISO-8859-4" "\0"
328 "CP28595" "\0" "ISO-8859-5" "\0"
329 "CP28596" "\0" "ISO-8859-6" "\0"
330 "CP28597" "\0" "ISO-8859-7" "\0"
331 "CP28598" "\0" "ISO-8859-8" "\0"
332 "CP28599" "\0" "ISO-8859-9" "\0"
333 "CP28605" "\0" "ISO-8859-15" "\0"
334 "CP38598" "\0" "ISO-8859-8" "\0"
335 "CP51932" "\0" "EUC-JP" "\0"
336 "CP51936" "\0" "GB2312" "\0"
337 "CP51949" "\0" "EUC-KR" "\0"
338 "CP51950" "\0" "EUC-TW" "\0"
339 "CP54936" "\0" "GB18030" "\0"
340 "CP65001" "\0" "UTF-8" "\0";
319 "CP1361" "\0" "JOHAB" "\0"
320 "CP20127" "\0" "ASCII" "\0"
321 "CP20866" "\0" "KOI8-R" "\0"
322 "CP20936" "\0" "GB2312" "\0"
323 "CP21866" "\0" "KOI8-RU" "\0"
324 "CP28591" "\0" "ISO-8859-1" "\0"
325 "CP28592" "\0" "ISO-8859-2" "\0"
326 "CP28593" "\0" "ISO-8859-3" "\0"
327 "CP28594" "\0" "ISO-8859-4" "\0"
328 "CP28595" "\0" "ISO-8859-5" "\0"
329 "CP28596" "\0" "ISO-8859-6" "\0"
330 "CP28597" "\0" "ISO-8859-7" "\0"
331 "CP28598" "\0" "ISO-8859-8" "\0"
332 "CP28599" "\0" "ISO-8859-9" "\0"
333 "CP28605" "\0" "ISO-8859-15" "\0"
334 "CP38598" "\0" "ISO-8859-8" "\0"
335 "CP51932" "\0" "EUC-JP" "\0"
336 "CP51936" "\0" "GB2312" "\0"
337 "CP51949" "\0" "EUC-KR" "\0"
338 "CP51950" "\0" "EUC-TW" "\0"
339 "CP54936" "\0" "GB18030" "\0"
340 "CP65001" "\0" "UTF-8" "\0";
341341 # endif
342342 #endif
343343
370370 codeset = nl_langinfo (CODESET);
371371
372372 # ifdef __CYGWIN__
373 /* Cygwin 2006 does not have locales. nl_langinfo (CODESET) always
373 /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always
374374 returns "US-ASCII". As long as this is not fixed, return the suffix
375375 of the locale name from the environment variables (if present) or
376376 the codepage as a number. */
381381
382382 locale = getenv ("LC_ALL");
383383 if (locale == NULL || locale[0] == '\0')
384 {
385 locale = getenv ("LC_CTYPE");
386 if (locale == NULL || locale[0] == '\0')
387 locale = getenv ("LANG");
388 }
384 {
385 locale = getenv ("LC_CTYPE");
386 if (locale == NULL || locale[0] == '\0')
387 locale = getenv ("LANG");
388 }
389389 if (locale != NULL && locale[0] != '\0')
390 {
391 /* If the locale name contains an encoding after the dot, return
392 it. */
393 const char *dot = strchr (locale, '.');
394
395 if (dot != NULL)
396 {
397 const char *modifier;
398
399 dot++;
400 /* Look for the possible @... trailer and remove it, if any. */
401 modifier = strchr (dot, '@');
402 if (modifier == NULL)
403 return dot;
404 if (modifier - dot < sizeof (buf))
405 {
406 memcpy (buf, dot, modifier - dot);
407 buf [modifier - dot] = '\0';
408 return buf;
409 }
410 }
411 }
412
413 /* Woe32 has a function returning the locale's codepage as a number. */
390 {
391 /* If the locale name contains an encoding after the dot, return
392 it. */
393 const char *dot = strchr (locale, '.');
394
395 if (dot != NULL)
396 {
397 const char *modifier;
398
399 dot++;
400 /* Look for the possible @... trailer and remove it, if any. */
401 modifier = strchr (dot, '@');
402 if (modifier == NULL)
403 return dot;
404 if (modifier - dot < sizeof (buf))
405 {
406 memcpy (buf, dot, modifier - dot);
407 buf [modifier - dot] = '\0';
408 return buf;
409 }
410 }
411 }
412
413 /* Woe32 has a function returning the locale's codepage as a number:
414 GetACP(). This encoding is used by Cygwin, unless the user has set
415 the environment variable CYGWIN=codepage:oem (which very few people
416 do).
417 Output directed to console windows needs to be converted (to
418 GetOEMCP() if the console is using a raster font, or to
419 GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
420 this conversion transparently (see winsup/cygwin/fhandler_console.cc),
421 converting to GetConsoleOutputCP(). This leads to correct results,
422 except when SetConsoleOutputCP has been called and a raster font is
423 in use. */
414424 sprintf (buf, "CP%u", GetACP ());
415425 codeset = buf;
416426 }
432442 {
433443 locale = getenv ("LC_ALL");
434444 if (locale == NULL || locale[0] == '\0')
435 {
436 locale = getenv ("LC_CTYPE");
437 if (locale == NULL || locale[0] == '\0')
438 locale = getenv ("LANG");
439 }
445 {
446 locale = getenv ("LC_CTYPE");
447 if (locale == NULL || locale[0] == '\0')
448 locale = getenv ("LANG");
449 }
440450 }
441451
442452 /* On some old systems, one used to set locale = "iso8859_1". On others,
450460
451461 static char buf[2 + 10 + 1];
452462
453 /* Woe32 has a function returning the locale's codepage as a number. */
463 /* Woe32 has a function returning the locale's codepage as a number:
464 GetACP().
465 When the output goes to a console window, it needs to be provided in
466 GetOEMCP() encoding if the console is using a raster font, or in
467 GetConsoleOutputCP() encoding if it is using a TrueType font.
468 But in GUI programs and for output sent to files and pipes, GetACP()
469 encoding is the best bet. */
454470 sprintf (buf, "CP%u", GetACP ());
455471 codeset = buf;
456472
468484 {
469485 locale = getenv ("LC_CTYPE");
470486 if (locale == NULL || locale[0] == '\0')
471 locale = getenv ("LANG");
487 locale = getenv ("LANG");
472488 }
473489 if (locale != NULL && locale[0] != '\0')
474490 {
476492 const char *dot = strchr (locale, '.');
477493
478494 if (dot != NULL)
479 {
480 const char *modifier;
481
482 dot++;
483 /* Look for the possible @... trailer and remove it, if any. */
484 modifier = strchr (dot, '@');
485 if (modifier == NULL)
486 return dot;
487 if (modifier - dot < sizeof (buf))
488 {
489 memcpy (buf, dot, modifier - dot);
490 buf [modifier - dot] = '\0';
491 return buf;
492 }
493 }
495 {
496 const char *modifier;
497
498 dot++;
499 /* Look for the possible @... trailer and remove it, if any. */
500 modifier = strchr (dot, '@');
501 if (modifier == NULL)
502 return dot;
503 if (modifier - dot < sizeof (buf))
504 {
505 memcpy (buf, dot, modifier - dot);
506 buf [modifier - dot] = '\0';
507 return buf;
508 }
509 }
494510
495511 /* Resolve through the charset.alias file. */
496512 codeset = locale;
499515 {
500516 /* OS/2 has a function returning the locale's codepage as a number. */
501517 if (DosQueryCp (sizeof (cp), cp, &cplen))
502 codeset = "";
518 codeset = "";
503519 else
504 {
505 sprintf (buf, "CP%u", cp[0]);
506 codeset = buf;
507 }
520 {
521 sprintf (buf, "CP%u", cp[0]);
522 codeset = buf;
523 }
508524 }
509525
510526 #endif
518534 *aliases != '\0';
519535 aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
520536 if (strcmp (codeset, aliases) == 0
521 || (aliases[0] == '*' && aliases[1] == '\0'))
537 || (aliases[0] == '*' && aliases[1] == '\0'))
522538 {
523 codeset = aliases + strlen (aliases) + 1;
524 break;
539 codeset = aliases + strlen (aliases) + 1;
540 break;
525541 }
526542
527543 /* Don't return an empty string. GNU libc and GNU libiconv interpret
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Determine a canonical name for the current locale's character encoding.
3 Copyright (C) 2000-2003 Free Software Foundation, Inc.
3 Copyright (C) 2000-2003, 2009-2010 Free Software Foundation, Inc.
44 This file is part of the GNU CHARSET Library.
55
66 This program is free software; you can redistribute it and/or modify
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* An lseek() function that detects pipes.
3 Copyright (C) 2007 Free Software Foundation, Inc.
3 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
00 /* Work around a bug of lstat on some systems
11
2 Copyright (C) 1997-1999, 2000-2006, 2008-2009 Free Software
3 Foundation, Inc.
2 Copyright (C) 1997-2006, 2008-2010 Free Software Foundation, Inc.
43
54 This program is free software: you can redistribute it and/or modify
65 it under the terms of the GNU General Public License as published by
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* malloc() function that is glibc compatible.
33
4 Copyright (C) 1997, 1998, 2006, 2007 Free Software Foundation, Inc.
4 Copyright (C) 1997-1998, 2006-2007, 2009-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
00 /* match.s -- optional optimized asm version of longest match in deflate.c
11
2 Copyright (C) 2002, 2006, 2009 Free Software Foundation, Inc.
2 Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
00 /* A GNU-like <math.h>.
11
2 Copyright (C) 2002-2003, 2007-2009 Free Software Foundation, Inc.
2 Copyright (C) 2002-2003, 2007-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
2828
2929
3030 /* The definition of GL_LINK_WARNING is copied here. */
31
32 /* The definition of _GL_ARG_NONNULL is copied here. */
33
34 /* Helper macros to define a portability warning for the
35 classification macro FUNC called with VALUE. POSIX declares the
36 classification macros with an argument of real-floating (that is,
37 one of float, double, or long double). */
38 #define _GL_WARN_REAL_FLOATING_DECL(func) \
39 static inline int \
40 rpl_ ## func ## f (float f) \
41 { \
42 return func (f); \
43 } \
44 static inline int \
45 rpl_ ## func ## d (double d) \
46 { \
47 return func (d); \
48 } \
49 static inline int \
50 rpl_ ## func ## l (long double l) \
51 { \
52 return func (l); \
53 } \
54 _GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \
55 "use gnulib module " #func " for portability"); \
56 _GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \
57 "use gnulib module " #func " for portability"); \
58 _GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \
59 "use gnulib module " #func " for portability")
60 #define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
61 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \
62 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \
63 : rpl_ ## func ## l (value))
3164
3265
3366 #ifdef __cplusplus
73106 #if @GNULIB_FREXP@
74107 # if @REPLACE_FREXP@
75108 # define frexp rpl_frexp
76 extern double frexp (double x, int *expptr);
109 extern double frexp (double x, int *expptr) _GL_ARG_NONNULL ((2));
77110 # endif
78111 #elif defined GNULIB_POSIXCHECK
79112 # undef frexp
84117 #endif
85118
86119
87 #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@
120 #if @GNULIB_ACOSL@
121 # if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
88122 extern long double acosl (long double x);
89 #endif
90 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
123 # endif
124 #elif defined GNULIB_POSIXCHECK
91125 # undef acosl
92126 # define acosl(x) \
93127 (GL_LINK_WARNING ("acosl is unportable - " \
96130 #endif
97131
98132
99 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@
133 #if @GNULIB_ASINL@
134 # if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@
100135 extern long double asinl (long double x);
101 #endif
102 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
136 # endif
137 #elif defined GNULIB_POSIXCHECK
103138 # undef asinl
104139 # define asinl(x) \
105140 (GL_LINK_WARNING ("asinl is unportable - " \
108143 #endif
109144
110145
111 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@
146 #if @GNULIB_ATANL@
147 # if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@
112148 extern long double atanl (long double x);
113 #endif
114 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
149 # endif
150 #elif defined GNULIB_POSIXCHECK
115151 # undef atanl
116152 # define atanl(x) \
117153 (GL_LINK_WARNING ("atanl is unportable - " \
147183 #endif
148184
149185
150 #if @GNULIB_MATHL@ || (!@HAVE_DECL_COSL@ && !defined cosl)
151 # undef cosl
186 #if @GNULIB_COSL@
187 # if !@HAVE_COSL@
188 # undef cosl
189 # define cosl rpl_cosl
190 # endif
191 # if !@HAVE_COSL@ || !@HAVE_DECL_COSL@
152192 extern long double cosl (long double x);
153 #endif
154 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
193 # endif
194 #elif defined GNULIB_POSIXCHECK
155195 # undef cosl
156196 # define cosl(x) \
157197 (GL_LINK_WARNING ("cosl is unportable - " \
160200 #endif
161201
162202
163 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@
203 #if @GNULIB_EXPL@
204 # if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
164205 extern long double expl (long double x);
165 #endif
166 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
206 # endif
207 #elif defined GNULIB_POSIXCHECK
167208 # undef expl
168209 # define expl(x) \
169210 (GL_LINK_WARNING ("expl is unportable - " \
210251 # define frexpl rpl_frexpl
211252 #endif
212253 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
213 extern long double frexpl (long double x, int *expptr);
254 extern long double frexpl (long double x, int *expptr) _GL_ARG_NONNULL ((2));
214255 #endif
215256 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
216257 # undef frexpl
237278 #endif
238279
239280
240 #if @GNULIB_MATHL@ || (!@HAVE_DECL_LOGL@ && !defined logl)
241 # undef logl
281 #if @GNULIB_LOGL@
282 # if !@HAVE_LOGL@
283 # undef logl
284 # define logl rpl_logl
285 # endif
286 # if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@
242287 extern long double logl (long double x);
243 #endif
244 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
288 # endif
289 #elif defined GNULIB_POSIXCHECK
245290 # undef logl
246291 # define logl(x) \
247292 (GL_LINK_WARNING ("logl is unportable - " \
293338 #endif
294339
295340
296 #if @GNULIB_MATHL@ || (!@HAVE_DECL_SINL@ && !defined sinl)
297 # undef sinl
341 #if @GNULIB_SINL@
342 # if !@HAVE_SINL@
343 # undef sinl
344 # define sinl rpl_sinl
345 # endif
346 # if !@HAVE_SINL@ || !@HAVE_DECL_SINL@
298347 extern long double sinl (long double x);
299 #endif
300 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
348 # endif
349 #elif defined GNULIB_POSIXCHECK
301350 # undef sinl
302351 # define sinl(x) \
303352 (GL_LINK_WARNING ("sinl is unportable - " \
306355 #endif
307356
308357
309 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@
358 #if @GNULIB_SQRTL@
359 # if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@
310360 extern long double sqrtl (long double x);
311 #endif
312 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
361 # endif
362 #elif defined GNULIB_POSIXCHECK
313363 # undef sqrtl
314364 # define sqrtl(x) \
315365 (GL_LINK_WARNING ("sqrtl is unportable - " \
318368 #endif
319369
320370
321 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@
371 #if @GNULIB_TANL@
372 # if !@HAVE_TANL@ || !@HAVE_DECL_TANL@
322373 extern long double tanl (long double x);
323 #endif
324 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
374 # endif
375 #elif defined GNULIB_POSIXCHECK
325376 # undef tanl
326377 # define tanl(x) \
327378 (GL_LINK_WARNING ("tanl is unportable - " \
383434 gl_isfinitef (x))
384435 # endif
385436 #elif defined GNULIB_POSIXCHECK
386 /* How to override a macro? */
437 # if defined isfinite
438 _GL_WARN_REAL_FLOATING_DECL (isfinite);
439 # undef isfinite
440 # define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x)
441 # endif
387442 #endif
388443
389444
399454 gl_isinff (x))
400455 # endif
401456 #elif defined GNULIB_POSIXCHECK
402 /* How to override a macro? */
457 # if defined isinf
458 _GL_WARN_REAL_FLOATING_DECL (isinf);
459 # undef isinf
460 # define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x)
461 # endif
403462 #endif
404463
405464
408467 # if @HAVE_ISNANF@
409468 /* The original <math.h> included above provides a declaration of isnan macro
410469 or (older) isnanf function. */
411 # include <math.h>
412470 # if __GNUC__ >= 4
413471 /* GCC 4.0 and newer provides three built-ins for isnan. */
414472 # undef isnanf
431489 to 'double' numbers earlier but now is a type-generic macro. */
432490 # if @HAVE_ISNAND@
433491 /* The original <math.h> included above provides a declaration of isnan macro. */
434 # include <math.h>
435492 # if __GNUC__ >= 4
436493 /* GCC 4.0 and newer provides three built-ins for isnan. */
437494 # undef isnand
452509 /* Test for NaN for 'long double' numbers. */
453510 # if @HAVE_ISNANL@
454511 /* The original <math.h> included above provides a declaration of isnan macro or (older) isnanl function. */
455 # include <math.h>
456512 # if __GNUC__ >= 4
457513 /* GCC 4.0 and newer provides three built-ins for isnan. */
458514 # undef isnanl
501557 gl_isnan_f (x))
502558 # endif
503559 #elif defined GNULIB_POSIXCHECK
504 /* How to override a macro? */
560 # if defined isnan
561 _GL_WARN_REAL_FLOATING_DECL (isnan);
562 # undef isnan
563 # define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x)
564 # endif
505565 #endif
506566
507567
523583 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
524584 # define gl_signbitf_OPTIMIZED_MACRO
525585 # define gl_signbitf(arg) \
526 ({ union { float _value; \
586 ({ union { float _value; \
527587 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
528 } _m; \
529 _m._value = (arg); \
530 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
588 } _m; \
589 _m._value = (arg); \
590 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
531591 })
532592 # endif
533593 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd
534594 # define gl_signbitd_OPTIMIZED_MACRO
535595 # define gl_signbitd(arg) \
536 ({ union { double _value; \
596 ({ union { double _value; \
537597 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
538 } _m; \
539 _m._value = (arg); \
540 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
598 } _m; \
599 _m._value = (arg); \
600 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
541601 })
542602 # endif
543603 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl
544604 # define gl_signbitl_OPTIMIZED_MACRO
545605 # define gl_signbitl(arg) \
546 ({ union { long double _value; \
606 ({ union { long double _value; \
547607 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
548 } _m; \
549 _m._value = (arg); \
550 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
608 } _m; \
609 _m._value = (arg); \
610 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
551611 })
552612 # endif
553613 # endif
557617 gl_signbitf (x))
558618 # endif
559619 #elif defined GNULIB_POSIXCHECK
560 /* How to override a macro? */
620 # if defined signbit
621 _GL_WARN_REAL_FLOATING_DECL (signbit);
622 # undef signbit
623 # define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x)
624 # endif
561625 #endif
562626
563627
00 /* Convert multibyte character to wide character.
1 Copyright (C) 1999-2002, 2005-2009 Free Software Foundation, Inc.
1 Copyright (C) 1999-2002, 2005-2010 Free Software Foundation, Inc.
22 Written by Bruno Haible <bruno@clisp.org>, 2008.
33
44 This program is free software: you can redistribute it and/or modify
6262 switch (nstate)
6363 {
6464 case 0:
65 p = s;
66 m = n;
67 break;
65 p = s;
66 m = n;
67 break;
6868 case 3:
69 buf[2] = pstate[3];
70 /*FALLTHROUGH*/
69 buf[2] = pstate[3];
70 /*FALLTHROUGH*/
7171 case 2:
72 buf[1] = pstate[2];
73 /*FALLTHROUGH*/
72 buf[1] = pstate[2];
73 /*FALLTHROUGH*/
7474 case 1:
75 buf[0] = pstate[1];
76 p = buf;
77 m = nstate;
78 buf[m++] = s[0];
79 if (n >= 2 && m < 4)
80 {
81 buf[m++] = s[1];
82 if (n >= 3 && m < 4)
83 buf[m++] = s[2];
84 }
85 break;
75 buf[0] = pstate[1];
76 p = buf;
77 m = nstate;
78 buf[m++] = s[0];
79 if (n >= 2 && m < 4)
80 {
81 buf[m++] = s[1];
82 if (n >= 3 && m < 4)
83 buf[m++] = s[2];
84 }
85 break;
8686 default:
87 errno = EINVAL;
88 return (size_t)(-1);
87 errno = EINVAL;
88 return (size_t)(-1);
8989 }
9090
9191 /* Here m > 0. */
9898 int res = mbtowc (pwc, p, m);
9999
100100 if (res >= 0)
101 {
102 if (pwc != NULL && ((*pwc == 0) != (res == 0)))
103 abort ();
104 if (nstate >= (res > 0 ? res : 1))
105 abort ();
106 res -= nstate;
107 pstate[0] = 0;
108 return res;
109 }
101 {
102 if (pwc != NULL && ((*pwc == 0) != (res == 0)))
103 abort ();
104 if (nstate >= (res > 0 ? res : 1))
105 abort ();
106 res -= nstate;
107 pstate[0] = 0;
108 return res;
109 }
110110
111111 /* mbtowc does not distinguish between invalid and incomplete multibyte
112 sequences. But mbrtowc needs to make this distinction.
113 There are two possible approaches:
114 - Use iconv() and its return value.
115 - Use built-in knowledge about the possible encodings.
116 Given the low quality of implementation of iconv() on the systems that
117 lack mbrtowc(), we use the second approach.
118 The possible encodings are:
119 - 8-bit encodings,
120 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
121 - UTF-8.
122 Use specialized code for each. */
112 sequences. But mbrtowc needs to make this distinction.
113 There are two possible approaches:
114 - Use iconv() and its return value.
115 - Use built-in knowledge about the possible encodings.
116 Given the low quality of implementation of iconv() on the systems that
117 lack mbrtowc(), we use the second approach.
118 The possible encodings are:
119 - 8-bit encodings,
120 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
121 - UTF-8.
122 Use specialized code for each. */
123123 if (m >= 4 || m >= MB_CUR_MAX)
124 goto invalid;
124 goto invalid;
125125 /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
126126 {
127 const char *encoding = locale_charset ();
128
129 if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
130 {
131 /* Cf. unistr/u8-mblen.c. */
132 unsigned char c = (unsigned char) p[0];
133
134 if (c >= 0xc2)
135 {
136 if (c < 0xe0)
137 {
138 if (m == 1)
139 goto incomplete;
140 }
141 else if (c < 0xf0)
142 {
143 if (m == 1)
144 goto incomplete;
145 if (m == 2)
146 {
147 unsigned char c2 = (unsigned char) p[1];
148
149 if ((c2 ^ 0x80) < 0x40
150 && (c >= 0xe1 || c2 >= 0xa0)
151 && (c != 0xed || c2 < 0xa0))
152 goto incomplete;
153 }
154 }
155 else if (c <= 0xf4)
156 {
157 if (m == 1)
158 goto incomplete;
159 else /* m == 2 || m == 3 */
160 {
161 unsigned char c2 = (unsigned char) p[1];
162
163 if ((c2 ^ 0x80) < 0x40
164 && (c >= 0xf1 || c2 >= 0x90)
165 && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
166 {
167 if (m == 2)
168 goto incomplete;
169 else /* m == 3 */
170 {
171 unsigned char c3 = (unsigned char) p[2];
172
173 if ((c3 ^ 0x80) < 0x40)
174 goto incomplete;
175 }
176 }
177 }
178 }
179 }
180 goto invalid;
181 }
182
183 /* As a reference for this code, you can use the GNU libiconv
184 implementation. Look for uses of the RET_TOOFEW macro. */
185
186 if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
187 {
188 if (m == 1)
189 {
190 unsigned char c = (unsigned char) p[0];
191
192 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
193 goto incomplete;
194 }
195 if (m == 2)
196 {
197 unsigned char c = (unsigned char) p[0];
198
199 if (c == 0x8f)
200 {
201 unsigned char c2 = (unsigned char) p[1];
202
203 if (c2 >= 0xa1 && c2 < 0xff)
204 goto incomplete;
205 }
206 }
207 goto invalid;
208 }
209 if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
210 || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
211 || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
212 {
213 if (m == 1)
214 {
215 unsigned char c = (unsigned char) p[0];
216
217 if (c >= 0xa1 && c < 0xff)
218 goto incomplete;
219 }
220 goto invalid;
221 }
222 if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
223 {
224 if (m == 1)
225 {
226 unsigned char c = (unsigned char) p[0];
227
228 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
229 goto incomplete;
230 }
231 else /* m == 2 || m == 3 */
232 {
233 unsigned char c = (unsigned char) p[0];
234
235 if (c == 0x8e)
236 goto incomplete;
237 }
238 goto invalid;
239 }
240 if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
241 {
242 if (m == 1)
243 {
244 unsigned char c = (unsigned char) p[0];
245
246 if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
247 goto incomplete;
248 }
249 else /* m == 2 || m == 3 */
250 {
251 unsigned char c = (unsigned char) p[0];
252
253 if (c >= 0x90 && c <= 0xe3)
254 {
255 unsigned char c2 = (unsigned char) p[1];
256
257 if (c2 >= 0x30 && c2 <= 0x39)
258 {
259 if (m == 2)
260 goto incomplete;
261 else /* m == 3 */
262 {
263 unsigned char c3 = (unsigned char) p[2];
264
265 if (c3 >= 0x81 && c3 <= 0xfe)
266 goto incomplete;
267 }
268 }
269 }
270 }
271 goto invalid;
272 }
273 if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
274 {
275 if (m == 1)
276 {
277 unsigned char c = (unsigned char) p[0];
278
279 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
280 || (c >= 0xf0 && c <= 0xf9))
281 goto incomplete;
282 }
283 goto invalid;
284 }
285
286 /* An unknown multibyte encoding. */
287 goto incomplete;
127 const char *encoding = locale_charset ();
128
129 if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
130 {
131 /* Cf. unistr/u8-mblen.c. */
132 unsigned char c = (unsigned char) p[0];
133
134 if (c >= 0xc2)
135 {
136 if (c < 0xe0)
137 {
138 if (m == 1)
139 goto incomplete;
140 }
141 else if (c < 0xf0)
142 {
143 if (m == 1)
144 goto incomplete;
145 if (m == 2)
146 {
147 unsigned char c2 = (unsigned char) p[1];
148
149 if ((c2 ^ 0x80) < 0x40
150 && (c >= 0xe1 || c2 >= 0xa0)
151 && (c != 0xed || c2 < 0xa0))
152 goto incomplete;
153 }
154 }
155 else if (c <= 0xf4)
156 {
157 if (m == 1)
158 goto incomplete;
159 else /* m == 2 || m == 3 */
160 {
161 unsigned char c2 = (unsigned char) p[1];
162
163 if ((c2 ^ 0x80) < 0x40
164 && (c >= 0xf1 || c2 >= 0x90)
165 && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
166 {
167 if (m == 2)
168 goto incomplete;
169 else /* m == 3 */
170 {
171 unsigned char c3 = (unsigned char) p[2];
172
173 if ((c3 ^ 0x80) < 0x40)
174 goto incomplete;
175 }
176 }
177 }
178 }
179 }
180 goto invalid;
181 }
182
183 /* As a reference for this code, you can use the GNU libiconv
184 implementation. Look for uses of the RET_TOOFEW macro. */
185
186 if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
187 {
188 if (m == 1)
189 {
190 unsigned char c = (unsigned char) p[0];
191
192 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
193 goto incomplete;
194 }
195 if (m == 2)
196 {
197 unsigned char c = (unsigned char) p[0];
198
199 if (c == 0x8f)
200 {
201 unsigned char c2 = (unsigned char) p[1];
202
203 if (c2 >= 0xa1 && c2 < 0xff)
204 goto incomplete;
205 }
206 }
207 goto invalid;
208 }
209 if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
210 || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
211 || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
212 {
213 if (m == 1)
214 {
215 unsigned char c = (unsigned char) p[0];
216
217 if (c >= 0xa1 && c < 0xff)
218 goto incomplete;
219 }
220 goto invalid;
221 }
222 if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
223 {
224 if (m == 1)
225 {
226 unsigned char c = (unsigned char) p[0];
227
228 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
229 goto incomplete;
230 }
231 else /* m == 2 || m == 3 */
232 {
233 unsigned char c = (unsigned char) p[0];
234
235 if (c == 0x8e)
236 goto incomplete;
237 }
238 goto invalid;
239 }
240 if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
241 {
242 if (m == 1)
243 {
244 unsigned char c = (unsigned char) p[0];
245
246 if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
247 goto incomplete;
248 }
249 else /* m == 2 || m == 3 */
250 {
251 unsigned char c = (unsigned char) p[0];
252
253 if (c >= 0x90 && c <= 0xe3)
254 {
255 unsigned char c2 = (unsigned char) p[1];
256
257 if (c2 >= 0x30 && c2 <= 0x39)
258 {
259 if (m == 2)
260 goto incomplete;
261 else /* m == 3 */
262 {
263 unsigned char c3 = (unsigned char) p[2];
264
265 if (c3 >= 0x81 && c3 <= 0xfe)
266 goto incomplete;
267 }
268 }
269 }
270 }
271 goto invalid;
272 }
273 if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
274 {
275 if (m == 1)
276 {
277 unsigned char c = (unsigned char) p[0];
278
279 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
280 || (c >= 0xf0 && c <= 0xf9))
281 goto incomplete;
282 }
283 goto invalid;
284 }
285
286 /* An unknown multibyte encoding. */
287 goto incomplete;
288288 }
289289
290290 incomplete:
291291 {
292 size_t k = nstate;
293 /* Here 0 <= k < m < 4. */
294 pstate[++k] = s[0];
295 if (k < m)
296 {
297 pstate[++k] = s[1];
298 if (k < m)
299 pstate[++k] = s[2];
300 }
301 if (k != m)
302 abort ();
292 size_t k = nstate;
293 /* Here 0 <= k < m < 4. */
294 pstate[++k] = s[0];
295 if (k < m)
296 {
297 pstate[++k] = s[1];
298 if (k < m)
299 pstate[++k] = s[2];
300 }
301 if (k != m)
302 abort ();
303303 }
304304 pstate[0] = m;
305305 return (size_t)(-2);
340340
341341 if (!mbsinit (ps))
342342 {
343 /* Parse the rest of the multibyte character byte for byte. */
344 size_t count = 0;
345 for (; n > 0; s++, n--)
346 {
347 wchar_t wc;
348 size_t ret = mbrtowc (&wc, s, 1, ps);
349
350 if (ret == (size_t)(-1))
351 return (size_t)(-1);
352 count++;
353 if (ret != (size_t)(-2))
354 {
355 /* The multibyte character has been completed. */
356 if (pwc != NULL)
357 *pwc = wc;
358 return (wc == 0 ? 0 : count);
359 }
360 }
361 return (size_t)(-2);
343 /* Parse the rest of the multibyte character byte for byte. */
344 size_t count = 0;
345 for (; n > 0; s++, n--)
346 {
347 wchar_t wc;
348 size_t ret = mbrtowc (&wc, s, 1, ps);
349
350 if (ret == (size_t)(-1))
351 return (size_t)(-1);
352 count++;
353 if (ret != (size_t)(-2))
354 {
355 /* The multibyte character has been completed. */
356 if (pwc != NULL)
357 *pwc = wc;
358 return (wc == 0 ? 0 : count);
359 }
360 }
361 return (size_t)(-2);
362362 }
363363 }
364364 # endif
370370
371371 if (ret != (size_t)(-1) && ret != (size_t)(-2))
372372 {
373 if (pwc != NULL)
374 *pwc = wc;
375 if (wc == 0)
376 ret = 0;
373 if (pwc != NULL)
374 *pwc = wc;
375 if (wc == 0)
376 ret = 0;
377377 }
378378 return ret;
379379 }
00 /* Test for initial conversion state.
1 Copyright (C) 2008 Free Software Foundation, Inc.
1 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22 Written by Bruno Haible <bruno@clisp.org>, 2008.
33
44 This program is free software: you can redistribute it and/or modify
0 /* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008
0 /* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2010
11 Free Software Foundation, Inc.
22
33 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
9696 repeated_one |= repeated_one << 31 << 1;
9797 repeated_c |= repeated_c << 31 << 1;
9898 if (8 < sizeof (longword))
99 {
100 size_t i;
99 {
100 size_t i;
101101
102 for (i = 64; i < sizeof (longword) * 8; i *= 2)
103 {
104 repeated_one |= repeated_one << i;
105 repeated_c |= repeated_c << i;
106 }
107 }
102 for (i = 64; i < sizeof (longword) * 8; i *= 2)
103 {
104 repeated_one |= repeated_one << i;
105 repeated_c |= repeated_c << i;
106 }
107 }
108108 }
109109
110110 /* Instead of the traditional loop which tests each byte, we will test a
143143 longword longword1 = *longword_ptr ^ repeated_c;
144144
145145 if ((((longword1 - repeated_one) & ~longword1)
146 & (repeated_one << 7)) != 0)
147 break;
146 & (repeated_one << 7)) != 0)
147 break;
148148 longword_ptr++;
149149 n -= sizeof (longword);
150150 }
161161 for (; n > 0; --n, ++char_ptr)
162162 {
163163 if (*char_ptr == c)
164 return (void *) char_ptr;
164 return (void *) char_ptr;
165165 }
166166
167167 return NULL;
0 /* -*- buffer-read-only: t -*- vi: set ro: */
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Copy memory area and return pointer after last written byte.
3 Copyright (C) 2003, 2007, 2009, 2010 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
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19 #include <config.h>
20
21 /* Specification. */
22 #include <string.h>
23
24 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
25 last written byte. */
26 void *
27 mempcpy (void *dest, const void *src, size_t n)
28 {
29 return (char *) memcpy (dest, src, n) + n;
30 }
0 /* memrchr -- find the last occurrence of a byte in a memory block
1
2 Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2010 Free Software
3 Foundation, Inc.
4
5 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
6 with help from Dan Sahlin (dan@sics.se) and
7 commentary by Jim Blandy (jimb@ai.mit.edu);
8 adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
9 and implemented by Roland McGrath (roland@ai.mit.edu).
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23
24 #if defined _LIBC
25 # include <memcopy.h>
26 #else
27 # include <config.h>
28 # define reg_char char
29 #endif
30
31 #include <string.h>
32 #include <limits.h>
33
34 #undef __memrchr
35 #ifdef _LIBC
36 # undef memrchr
37 #endif
38
39 #ifndef weak_alias
40 # define __memrchr memrchr
41 #endif
42
43 /* Search no more than N bytes of S for C. */
44 void *
45 __memrchr (void const *s, int c_in, size_t n)
46 {
47 /* On 32-bit hardware, choosing longword to be a 32-bit unsigned
48 long instead of a 64-bit uintmax_t tends to give better
49 performance. On 64-bit hardware, unsigned long is generally 64
50 bits already. Change this typedef to experiment with
51 performance. */
52 typedef unsigned long int longword;
53
54 const unsigned char *char_ptr;
55 const longword *longword_ptr;
56 longword repeated_one;
57 longword repeated_c;
58 unsigned reg_char c;
59
60 c = (unsigned char) c_in;
61
62 /* Handle the last few bytes by reading one byte at a time.
63 Do this until CHAR_PTR is aligned on a longword boundary. */
64 for (char_ptr = (const unsigned char *) s + n;
65 n > 0 && (size_t) char_ptr % sizeof (longword) != 0;
66 --n)
67 if (*--char_ptr == c)
68 return (void *) char_ptr;
69
70 longword_ptr = (const longword *) char_ptr;
71
72 /* All these elucidatory comments refer to 4-byte longwords,
73 but the theory applies equally well to any size longwords. */
74
75 /* Compute auxiliary longword values:
76 repeated_one is a value which has a 1 in every byte.
77 repeated_c has c in every byte. */
78 repeated_one = 0x01010101;
79 repeated_c = c | (c << 8);
80 repeated_c |= repeated_c << 16;
81 if (0xffffffffU < (longword) -1)
82 {
83 repeated_one |= repeated_one << 31 << 1;
84 repeated_c |= repeated_c << 31 << 1;
85 if (8 < sizeof (longword))
86 {
87 size_t i;
88
89 for (i = 64; i < sizeof (longword) * 8; i *= 2)
90 {
91 repeated_one |= repeated_one << i;
92 repeated_c |= repeated_c << i;
93 }
94 }
95 }
96
97 /* Instead of the traditional loop which tests each byte, we will test a
98 longword at a time. The tricky part is testing if *any of the four*
99 bytes in the longword in question are equal to c. We first use an xor
100 with repeated_c. This reduces the task to testing whether *any of the
101 four* bytes in longword1 is zero.
102
103 We compute tmp =
104 ((longword1 - repeated_one) & ~longword1) & (repeated_one << 7).
105 That is, we perform the following operations:
106 1. Subtract repeated_one.
107 2. & ~longword1.
108 3. & a mask consisting of 0x80 in every byte.
109 Consider what happens in each byte:
110 - If a byte of longword1 is zero, step 1 and 2 transform it into 0xff,
111 and step 3 transforms it into 0x80. A carry can also be propagated
112 to more significant bytes.
113 - If a byte of longword1 is nonzero, let its lowest 1 bit be at
114 position k (0 <= k <= 7); so the lowest k bits are 0. After step 1,
115 the byte ends in a single bit of value 0 and k bits of value 1.
116 After step 2, the result is just k bits of value 1: 2^k - 1. After
117 step 3, the result is 0. And no carry is produced.
118 So, if longword1 has only non-zero bytes, tmp is zero.
119 Whereas if longword1 has a zero byte, call j the position of the least
120 significant zero byte. Then the result has a zero at positions 0, ...,
121 j-1 and a 0x80 at position j. We cannot predict the result at the more
122 significant bytes (positions j+1..3), but it does not matter since we
123 already have a non-zero bit at position 8*j+7.
124
125 So, the test whether any byte in longword1 is zero is equivalent to
126 testing whether tmp is nonzero. */
127
128 while (n >= sizeof (longword))
129 {
130 longword longword1 = *--longword_ptr ^ repeated_c;
131
132 if ((((longword1 - repeated_one) & ~longword1)
133 & (repeated_one << 7)) != 0)
134 {
135 longword_ptr++;
136 break;
137 }
138 n -= sizeof (longword);
139 }
140
141 char_ptr = (const unsigned char *) longword_ptr;
142
143 /* At this point, we know that either n < sizeof (longword), or one of the
144 sizeof (longword) bytes starting at char_ptr is == c. On little-endian
145 machines, we could determine the first such byte without any further
146 memory accesses, just by looking at the tmp result from the last loop
147 iteration. But this does not work on big-endian machines. Choose code
148 that works in both cases. */
149
150 while (n-- > 0)
151 {
152 if (*--char_ptr == c)
153 return (void *) char_ptr;
154 }
155
156 return NULL;
157 }
158 #ifdef weak_alias
159 weak_alias (__memrchr, memrchr)
160 #endif
0 /* On some systems, mkdir ("foo/", 0700) fails because of the trailing
1 slash. On those systems, this wrapper removes the trailing slash.
2
3 Copyright (C) 2001, 2003, 2006, 2008-2010 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 /* written by Jim Meyering */
19
20 #include <config.h>
21
22 /* Specification. */
23 #include <sys/stat.h>
24
25 #include <errno.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include "dirname.h"
31
32 /* Disable the definition of mkdir to rpl_mkdir (from the <sys/stat.h>
33 substitute) in this file. Otherwise, we'd get an endless recursion. */
34 #undef mkdir
35
36 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
37 Additionally, it declares _mkdir (and depending on compile flags, an
38 alias mkdir), only in the nonstandard io.h. */
39 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
40 # define mkdir(name,mode) _mkdir (name)
41 # define maybe_unused _GL_UNUSED
42 #else
43 # define maybe_unused /* empty */
44 #endif
45
46 /* This function is required at least for NetBSD 1.5.2. */
47
48 int
49 rpl_mkdir (char const *dir, mode_t mode maybe_unused)
50 {
51 int ret_val;
52 char *tmp_dir;
53 size_t len = strlen (dir);
54
55 if (len && dir[len - 1] == '/')
56 {
57 tmp_dir = strdup (dir);
58 if (!tmp_dir)
59 {
60 /* Rather than rely on strdup-posix, we set errno ourselves. */
61 errno = ENOMEM;
62 return -1;
63 }
64 strip_trailing_slashes (tmp_dir);
65 }
66 else
67 {
68 tmp_dir = (char *) dir;
69 }
70 #if FUNC_MKDIR_DOT_BUG
71 /* Additionally, cygwin 1.5 mistakenly creates a directory "d/./". */
72 {
73 char *last = last_component (tmp_dir);
74 if (*last == '.' && (last[1] == '\0'
75 || (last[1] == '.' && last[2] == '\0')))
76 {
77 struct stat st;
78 if (stat (tmp_dir, &st) == 0)
79 errno = EEXIST;
80 return -1;
81 }
82 }
83 #endif /* FUNC_MKDIR_DOT_BUG */
84
85 ret_val = mkdir (tmp_dir, mode);
86
87 if (tmp_dir != dir)
88 free (tmp_dir);
89
90 return ret_val;
91 }
0 /* fd-relative mkdir
1 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #include <config.h>
19
20 #include <unistd.h>
21
22 /* Solaris 10 has no function like this.
23 Create a subdirectory, FILE, with mode MODE, in the directory
24 open on descriptor FD. If possible, do it without changing the
25 working directory. Otherwise, resort to using save_cwd/fchdir,
26 then mkdir/restore_cwd. If either the save_cwd or the restore_cwd
27 fails, then give a diagnostic and exit nonzero. */
28
29 #define AT_FUNC_NAME mkdirat
30 #define AT_FUNC_F1 mkdir
31 #define AT_FUNC_POST_FILE_PARAM_DECLS , mode_t mode
32 #define AT_FUNC_POST_FILE_ARGS , mode
33 #include "at-func.c"
00 /* Invoke open, but avoid some glitches.
11
2 Copyright (C) 2005, 2006, 2008-2009 Free Software Foundation, Inc.
2 Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
3535 va_start (ap, flags);
3636
3737 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
38 creates crashing code when 'mode_t' is smaller than 'int'. */
38 creates crashing code when 'mode_t' is smaller than 'int'. */
3939 mode = va_arg (ap, PROMOTED_MODE_T);
4040
4141 va_end (ap);
00 /* Open a descriptor to a file.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
5656 va_start (arg, flags);
5757
5858 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
59 creates crashing code when 'mode_t' is smaller than 'int'. */
59 creates crashing code when 'mode_t' is smaller than 'int'. */
6060 mode = va_arg (arg, PROMOTED_MODE_T);
6161
6262 va_end (arg);
9393 {
9494 size_t len = strlen (filename);
9595 if (len > 0 && filename[len - 1] == '/')
96 {
97 errno = EISDIR;
98 return -1;
99 }
96 {
97 errno = EISDIR;
98 return -1;
99 }
100100 }
101101 #endif
102102
143143 /* We know len is positive, since open did not fail with ENOENT. */
144144 size_t len = strlen (filename);
145145 if (filename[len - 1] == '/')
146 {
147 struct stat statbuf;
146 {
147 struct stat statbuf;
148148
149 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
150 {
151 close (fd);
152 errno = ENOTDIR;
153 return -1;
154 }
155 }
149 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
150 {
151 close (fd);
152 errno = ENOTDIR;
153 return -1;
154 }
155 }
156156 }
157157 #endif
158158
0 /* Report a save- or restore-cwd failure in our openat replacement and then exit.
1
2 Copyright (C) 2005-2006, 2008-2010 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 #include <config.h>
18
19 #include "openat.h"
20
21 #include <stdlib.h>
22
23 #include "error.h"
24 #include "exitfail.h"
25
26 #include "gettext.h"
27 #define _(msgid) gettext (msgid)
28
29 void
30 openat_save_fail (int errnum)
31 {
32 error (exit_failure, errnum,
33 _("unable to record current working directory"));
34
35 /* The `noreturn' attribute cannot be applied to error, since it returns
36 when its first argument is 0. To help compilers understand that this
37 function does not return, call abort. Also, the abort is a
38 safety feature if exit_failure is 0 (which shouldn't happen). */
39 abort ();
40 }
41
42
43 /* Exit with an error about failure to restore the working directory
44 during an openat emulation. The caller must ensure that fd 2 is
45 not a just-opened fd, even when openat_safer is not in use. */
46
47 void
48 openat_restore_fail (int errnum)
49 {
50 error (exit_failure, errnum,
51 _("failed to return to initial working directory"));
52
53 /* As above. */
54 abort ();
55 }
0 /* Internals for openat-like functions.
1
2 Copyright (C) 2005-2006, 2009-2010 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 /* written by Jim Meyering */
18
19 #ifndef _GL_HEADER_OPENAT_PRIV
20 #define _GL_HEADER_OPENAT_PRIV
21
22 #include <errno.h>
23 #include <stdlib.h>
24
25 #define OPENAT_BUFFER_SIZE 512
26 char *openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file);
27
28 /* Trying to access a BUILD_PROC_NAME file will fail on systems without
29 /proc support, and even on systems *with* ProcFS support. Return
30 nonzero if the failure may be legitimate, e.g., because /proc is not
31 readable, or the particular .../fd/N directory is not present. */
32 #define EXPECTED_ERRNO(Errno) \
33 ((Errno) == ENOTDIR || (Errno) == ENOENT \
34 || (Errno) == EPERM || (Errno) == EACCES \
35 || (Errno) == ENOSYS /* Solaris 8 */ \
36 || (Errno) == EOPNOTSUPP /* FreeBSD */)
37
38 /* Wrapper function shared among linkat and renameat. */
39 int at_func2 (int fd1, char const *file1,
40 int fd2, char const *file2,
41 int (*func) (char const *file1, char const *file2));
42
43 #endif /* _GL_HEADER_OPENAT_PRIV */
0 /* Create /proc/self/fd-related names for subfiles of open directories.
1
2 Copyright (C) 2006, 2009-2010 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 /* Written by Paul Eggert. */
18
19 #include <config.h>
20
21 #include "openat-priv.h"
22
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <fcntl.h>
26
27 #include <stdio.h>
28 #include <string.h>
29 #include <unistd.h>
30
31 #include "dirname.h"
32 #include "intprops.h"
33 #include "same-inode.h"
34 #include "xalloc.h"
35
36 /* The results of open() in this file are not used with fchdir,
37 and we do not leak fds to any single-threaded code that could use stdio,
38 therefore save some unnecessary work in fchdir.c.
39 FIXME - if the kernel ever adds support for multi-thread safety for
40 avoiding standard fds, then we should use open_safer. */
41 #undef open
42 #undef close
43
44 #define PROC_SELF_FD_FORMAT "/proc/self/fd/%d/%s"
45
46 #define PROC_SELF_FD_NAME_SIZE_BOUND(len) \
47 (sizeof PROC_SELF_FD_FORMAT - sizeof "%d%s" \
48 + INT_STRLEN_BOUND (int) + (len) + 1)
49
50
51 /* Set BUF to the expansion of PROC_SELF_FD_FORMAT, using FD and FILE
52 respectively for %d and %s. If successful, return BUF if the
53 result fits in BUF, dynamically allocated memory otherwise. But
54 return NULL if /proc is not reliable. */
55 char *
56 openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
57 {
58 static int proc_status = 0;
59
60 /* Make sure the caller gets ENOENT when appropriate. */
61 if (!*file)
62 {
63 buf[0] = '\0';
64 return buf;
65 }
66
67 if (! proc_status)
68 {
69 /* Set PROC_STATUS to a positive value if /proc/self/fd is
70 reliable, and a negative value otherwise. Solaris 10
71 /proc/self/fd mishandles "..", and any file name might expand
72 to ".." after symbolic link expansion, so avoid /proc/self/fd
73 if it mishandles "..". Solaris 10 has openat, but this
74 problem is exhibited on code that built on Solaris 8 and
75 running on Solaris 10. */
76
77 int proc_self_fd = open ("/proc/self/fd", O_RDONLY);
78 if (proc_self_fd < 0)
79 proc_status = -1;
80 else
81 {
82 struct stat proc_self_fd_dotdot_st;
83 struct stat proc_self_st;
84 char dotdot_buf[PROC_SELF_FD_NAME_SIZE_BOUND (sizeof ".." - 1)];
85 sprintf (dotdot_buf, PROC_SELF_FD_FORMAT, proc_self_fd, "..");
86 proc_status =
87 ((stat (dotdot_buf, &proc_self_fd_dotdot_st) == 0
88 && stat ("/proc/self", &proc_self_st) == 0
89 && SAME_INODE (proc_self_fd_dotdot_st, proc_self_st))
90 ? 1 : -1);
91 close (proc_self_fd);
92 }
93 }
94
95 if (proc_status < 0)
96 return NULL;
97 else
98 {
99 size_t bufsize = PROC_SELF_FD_NAME_SIZE_BOUND (strlen (file));
100 char *result = (bufsize < OPENAT_BUFFER_SIZE ? buf : xmalloc (bufsize));
101 sprintf (result, PROC_SELF_FD_FORMAT, fd, file);
102 return result;
103 }
104 }
0 /* provide a replacement openat function
1 Copyright (C) 2004-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #include <config.h>
19
20 #include "openat.h"
21
22 #include <stdarg.h>
23 #include <stddef.h>
24 #include <string.h>
25 #include <sys/stat.h>
26
27 #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
28 #include "openat-priv.h"
29 #include "save-cwd.h"
30
31 #if HAVE_OPENAT
32
33 # undef openat
34
35 /* Like openat, but work around Solaris 9 bugs with trailing slash. */
36 int
37 rpl_openat (int dfd, char const *filename, int flags, ...)
38 {
39 mode_t mode;
40 int fd;
41
42 mode = 0;
43 if (flags & O_CREAT)
44 {
45 va_list arg;
46 va_start (arg, flags);
47
48 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
49 creates crashing code when 'mode_t' is smaller than 'int'. */
50 mode = va_arg (arg, PROMOTED_MODE_T);
51
52 va_end (arg);
53 }
54
55 #if OPEN_TRAILING_SLASH_BUG
56 /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
57 is specified, then fail.
58 Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
59 says that
60 "A pathname that contains at least one non-slash character and that
61 ends with one or more trailing slashes shall be resolved as if a
62 single dot character ( '.' ) were appended to the pathname."
63 and
64 "The special filename dot shall refer to the directory specified by
65 its predecessor."
66 If the named file already exists as a directory, then
67 - if O_CREAT is specified, open() must fail because of the semantics
68 of O_CREAT,
69 - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
70 <http://www.opengroup.org/susv3/functions/open.html> says that it
71 fails with errno = EISDIR in this case.
72 If the named file does not exist or does not name a directory, then
73 - if O_CREAT is specified, open() must fail since open() cannot create
74 directories,
75 - if O_WRONLY or O_RDWR is specified, open() must fail because the
76 file does not contain a '.' directory. */
77 if (flags & (O_CREAT | O_WRONLY | O_RDWR))
78 {
79 size_t len = strlen (filename);
80 if (len > 0 && filename[len - 1] == '/')
81 {
82 errno = EISDIR;
83 return -1;
84 }
85 }
86 #endif
87
88 fd = openat (dfd, filename, flags, mode);
89
90 #if OPEN_TRAILING_SLASH_BUG
91 /* If the filename ends in a slash and fd does not refer to a directory,
92 then fail.
93 Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
94 says that
95 "A pathname that contains at least one non-slash character and that
96 ends with one or more trailing slashes shall be resolved as if a
97 single dot character ( '.' ) were appended to the pathname."
98 and
99 "The special filename dot shall refer to the directory specified by
100 its predecessor."
101 If the named file without the slash is not a directory, open() must fail
102 with ENOTDIR. */
103 if (fd >= 0)
104 {
105 /* We know len is positive, since open did not fail with ENOENT. */
106 size_t len = strlen (filename);
107 if (filename[len - 1] == '/')
108 {
109 struct stat statbuf;
110
111 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
112 {
113 close (fd);
114 errno = ENOTDIR;
115 return -1;
116 }
117 }
118 }
119 #endif
120
121 return fd;
122 }
123
124 #else /* !HAVE_OPENAT */
125
126 /* Replacement for Solaris' openat function.
127 <http://www.google.com/search?q=openat+site:docs.sun.com>
128 First, try to simulate it via open ("/proc/self/fd/FD/FILE").
129 Failing that, simulate it by doing save_cwd/fchdir/open/restore_cwd.
130 If either the save_cwd or the restore_cwd fails (relatively unlikely),
131 then give a diagnostic and exit nonzero.
132 Otherwise, upon failure, set errno and return -1, as openat does.
133 Upon successful completion, return a file descriptor. */
134 int
135 openat (int fd, char const *file, int flags, ...)
136 {
137 mode_t mode = 0;
138
139 if (flags & O_CREAT)
140 {
141 va_list arg;
142 va_start (arg, flags);
143
144 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
145 creates crashing code when 'mode_t' is smaller than 'int'. */
146 mode = va_arg (arg, PROMOTED_MODE_T);
147
148 va_end (arg);
149 }
150
151 return openat_permissive (fd, file, flags, mode, NULL);
152 }
153
154 /* Like openat (FD, FILE, FLAGS, MODE), but if CWD_ERRNO is
155 nonnull, set *CWD_ERRNO to an errno value if unable to save
156 or restore the initial working directory. This is needed only
157 the first time remove.c's remove_dir opens a command-line
158 directory argument.
159
160 If a previous attempt to restore the current working directory
161 failed, then we must not even try to access a `.'-relative name.
162 It is the caller's responsibility not to call this function
163 in that case. */
164
165 int
166 openat_permissive (int fd, char const *file, int flags, mode_t mode,
167 int *cwd_errno)
168 {
169 struct saved_cwd saved_cwd;
170 int saved_errno;
171 int err;
172 bool save_ok;
173
174 if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
175 return open (file, flags, mode);
176
177 {
178 char buf[OPENAT_BUFFER_SIZE];
179 char *proc_file = openat_proc_name (buf, fd, file);
180 if (proc_file)
181 {
182 int open_result = open (proc_file, flags, mode);
183 int open_errno = errno;
184 if (proc_file != buf)
185 free (proc_file);
186 /* If the syscall succeeds, or if it fails with an unexpected
187 errno value, then return right away. Otherwise, fall through
188 and resort to using save_cwd/restore_cwd. */
189 if (0 <= open_result || ! EXPECTED_ERRNO (open_errno))
190 {
191 errno = open_errno;
192 return open_result;
193 }
194 }
195 }
196
197 save_ok = (save_cwd (&saved_cwd) == 0);
198 if (! save_ok)
199 {
200 if (! cwd_errno)
201 openat_save_fail (errno);
202 *cwd_errno = errno;
203 }
204 if (0 <= fd && fd == saved_cwd.desc)
205 {
206 /* If saving the working directory collides with the user's
207 requested fd, then the user's fd must have been closed to
208 begin with. */
209 free_cwd (&saved_cwd);
210 errno = EBADF;
211 return -1;
212 }
213
214 err = fchdir (fd);
215 saved_errno = errno;
216
217 if (! err)
218 {
219 err = open (file, flags, mode);
220 saved_errno = errno;
221 if (save_ok && restore_cwd (&saved_cwd) != 0)
222 {
223 if (! cwd_errno)
224 {
225 /* Don't write a message to just-created fd 2. */
226 saved_errno = errno;
227 if (err == STDERR_FILENO)
228 close (err);
229 openat_restore_fail (saved_errno);
230 }
231 *cwd_errno = errno;
232 }
233 }
234
235 free_cwd (&saved_cwd);
236 errno = saved_errno;
237 return err;
238 }
239
240 /* Return true if our openat implementation must resort to
241 using save_cwd and restore_cwd. */
242 bool
243 openat_needs_fchdir (void)
244 {
245 bool needs_fchdir = true;
246 int fd = open ("/", O_RDONLY);
247
248 if (0 <= fd)
249 {
250 char buf[OPENAT_BUFFER_SIZE];
251 char *proc_file = openat_proc_name (buf, fd, ".");
252 if (proc_file)
253 {
254 needs_fchdir = false;
255 if (proc_file != buf)
256 free (proc_file);
257 }
258 close (fd);
259 }
260
261 return needs_fchdir;
262 }
263
264 #endif /* !HAVE_OPENAT */
0 /* provide a replacement openat function
1 Copyright (C) 2004-2006, 2008-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 /* written by Jim Meyering */
17
18 #ifndef _GL_HEADER_OPENAT
19 #define _GL_HEADER_OPENAT
20
21 #include <fcntl.h>
22
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <dirent.h>
26 #include <unistd.h>
27 #include <stdbool.h>
28
29 #ifndef __attribute__
30 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
31 # define __attribute__(x) /* empty */
32 # endif
33 #endif
34
35 #ifndef ATTRIBUTE_NORETURN
36 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
37 #endif
38
39 #if !HAVE_OPENAT
40
41 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
42 int *cwd_errno);
43 bool openat_needs_fchdir (void);
44
45 #else
46
47 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
48 openat (Fd, File, Flags, Mode)
49 # define openat_needs_fchdir() false
50
51 #endif
52
53 void openat_restore_fail (int) ATTRIBUTE_NORETURN;
54 void openat_save_fail (int) ATTRIBUTE_NORETURN;
55
56 /* Using these function names makes application code
57 slightly more readable than it would be with
58 fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW). */
59 static inline int
60 chownat (int fd, char const *file, uid_t owner, gid_t group)
61 {
62 return fchownat (fd, file, owner, group, 0);
63 }
64
65 static inline int
66 lchownat (int fd, char const *file, uid_t owner, gid_t group)
67 {
68 return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
69 }
70
71 static inline int
72 chmodat (int fd, char const *file, mode_t mode)
73 {
74 return fchmodat (fd, file, mode, 0);
75 }
76
77 static inline int
78 lchmodat (int fd, char const *file, mode_t mode)
79 {
80 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
81 }
82
83 static inline int
84 statat (int fd, char const *name, struct stat *st)
85 {
86 return fstatat (fd, name, st, 0);
87 }
88
89 static inline int
90 lstatat (int fd, char const *name, struct stat *st)
91 {
92 return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
93 }
94
95 #if GNULIB_FACCESSAT
96 /* For now, there are no wrappers named laccessat or leuidaccessat,
97 since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
98 since access rights on symlinks are of limited utility. */
99
100 static inline int
101 accessat (int fd, char const *file, int mode)
102 {
103 return faccessat (fd, file, mode, 0);
104 }
105
106 static inline int
107 euidaccessat (int fd, char const *file, int mode)
108 {
109 return faccessat (fd, file, mode, AT_EACCESS);
110 }
111 #endif
112
113 #endif /* _GL_HEADER_OPENAT */
00 /* Print a message describing error code.
1 Copyright (C) 2008 Free Software Foundation, Inc.
1 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22 Written by Bruno Haible and Simon Josefsson.
33
44 This program is free software: you can redistribute it and/or modify
00 /* Invoke pipe, but avoid some glitches.
1 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
1 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
3434 {
3535 int i;
3636 for (i = 0; i < 2; i++)
37 {
38 fd[i] = fd_safer (fd[i]);
39 if (fd[i] < 0)
40 {
41 int e = errno;
42 close (fd[1 - i]);
43 errno = e;
44 return -1;
45 }
46 }
37 {
38 fd[i] = fd_safer (fd[i]);
39 if (fd[i] < 0)
40 {
41 int e = errno;
42 close (fd[1 - i]);
43 errno = e;
44 return -1;
45 }
46 }
4747
4848 return 0;
4949 }
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Decomposed printf argument list.
3 Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc.
3 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 Free Software
4 Foundation, Inc.
45
56 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
4344 switch (ap->type)
4445 {
4546 case TYPE_SCHAR:
46 ap->a.a_schar = va_arg (args, /*signed char*/ int);
47 break;
47 ap->a.a_schar = va_arg (args, /*signed char*/ int);
48 break;
4849 case TYPE_UCHAR:
49 ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
50 break;
50 ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
51 break;
5152 case TYPE_SHORT:
52 ap->a.a_short = va_arg (args, /*short*/ int);
53 break;
53 ap->a.a_short = va_arg (args, /*short*/ int);
54 break;
5455 case TYPE_USHORT:
55 ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
56 break;
56 ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
57 break;
5758 case TYPE_INT:
58 ap->a.a_int = va_arg (args, int);
59 break;
59 ap->a.a_int = va_arg (args, int);
60 break;
6061 case TYPE_UINT:
61 ap->a.a_uint = va_arg (args, unsigned int);
62 break;
62 ap->a.a_uint = va_arg (args, unsigned int);
63 break;
6364 case TYPE_LONGINT:
64 ap->a.a_longint = va_arg (args, long int);
65 break;
65 ap->a.a_longint = va_arg (args, long int);
66 break;
6667 case TYPE_ULONGINT:
67 ap->a.a_ulongint = va_arg (args, unsigned long int);
68 break;
68 ap->a.a_ulongint = va_arg (args, unsigned long int);
69 break;
6970 #if HAVE_LONG_LONG_INT
7071 case TYPE_LONGLONGINT:
71 ap->a.a_longlongint = va_arg (args, long long int);
72 break;
72 ap->a.a_longlongint = va_arg (args, long long int);
73 break;
7374 case TYPE_ULONGLONGINT:
74 ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
75 break;
75 ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
76 break;
7677 #endif
7778 case TYPE_DOUBLE:
78 ap->a.a_double = va_arg (args, double);
79 break;
79 ap->a.a_double = va_arg (args, double);
80 break;
8081 case TYPE_LONGDOUBLE:
81 ap->a.a_longdouble = va_arg (args, long double);
82 break;
82 ap->a.a_longdouble = va_arg (args, long double);
83 break;
8384 case TYPE_CHAR:
84 ap->a.a_char = va_arg (args, int);
85 break;
85 ap->a.a_char = va_arg (args, int);
86 break;
8687 #if HAVE_WINT_T
8788 case TYPE_WIDE_CHAR:
88 /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
89 default argument promotions", this is not the case in mingw32,
90 where wint_t is 'unsigned short'. */
91 ap->a.a_wide_char =
92 (sizeof (wint_t) < sizeof (int)
93 ? va_arg (args, int)
94 : va_arg (args, wint_t));
95 break;
89 /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
90 default argument promotions", this is not the case in mingw32,
91 where wint_t is 'unsigned short'. */
92 ap->a.a_wide_char =
93 (sizeof (wint_t) < sizeof (int)
94 ? (wint_t) va_arg (args, int)
95 : va_arg (args, wint_t));
96 break;
9697 #endif
9798 case TYPE_STRING:
98 ap->a.a_string = va_arg (args, const char *);
99 /* A null pointer is an invalid argument for "%s", but in practice
100 it occurs quite frequently in printf statements that produce
101 debug output. Use a fallback in this case. */
102 if (ap->a.a_string == NULL)
103 ap->a.a_string = "(NULL)";
104 break;
99 ap->a.a_string = va_arg (args, const char *);
100 /* A null pointer is an invalid argument for "%s", but in practice
101 it occurs quite frequently in printf statements that produce
102 debug output. Use a fallback in this case. */
103 if (ap->a.a_string == NULL)
104 ap->a.a_string = "(NULL)";
105 break;
105106 #if HAVE_WCHAR_T
106107 case TYPE_WIDE_STRING:
107 ap->a.a_wide_string = va_arg (args, const wchar_t *);
108 /* A null pointer is an invalid argument for "%ls", but in practice
109 it occurs quite frequently in printf statements that produce
110 debug output. Use a fallback in this case. */
111 if (ap->a.a_wide_string == NULL)
112 {
113 static const wchar_t wide_null_string[] =
114 {
115 (wchar_t)'(',
116 (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
117 (wchar_t)')',
118 (wchar_t)0
119 };
120 ap->a.a_wide_string = wide_null_string;
121 }
122 break;
108 ap->a.a_wide_string = va_arg (args, const wchar_t *);
109 /* A null pointer is an invalid argument for "%ls", but in practice
110 it occurs quite frequently in printf statements that produce
111 debug output. Use a fallback in this case. */
112 if (ap->a.a_wide_string == NULL)
113 {
114 static const wchar_t wide_null_string[] =
115 {
116 (wchar_t)'(',
117 (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
118 (wchar_t)')',
119 (wchar_t)0
120 };
121 ap->a.a_wide_string = wide_null_string;
122 }
123 break;
123124 #endif
124125 case TYPE_POINTER:
125 ap->a.a_pointer = va_arg (args, void *);
126 break;
126 ap->a.a_pointer = va_arg (args, void *);
127 break;
127128 case TYPE_COUNT_SCHAR_POINTER:
128 ap->a.a_count_schar_pointer = va_arg (args, signed char *);
129 break;
129 ap->a.a_count_schar_pointer = va_arg (args, signed char *);
130 break;
130131 case TYPE_COUNT_SHORT_POINTER:
131 ap->a.a_count_short_pointer = va_arg (args, short *);
132 break;
132 ap->a.a_count_short_pointer = va_arg (args, short *);
133 break;
133134 case TYPE_COUNT_INT_POINTER:
134 ap->a.a_count_int_pointer = va_arg (args, int *);
135 break;
135 ap->a.a_count_int_pointer = va_arg (args, int *);
136 break;
136137 case TYPE_COUNT_LONGINT_POINTER:
137 ap->a.a_count_longint_pointer = va_arg (args, long int *);
138 break;
138 ap->a.a_count_longint_pointer = va_arg (args, long int *);
139 break;
139140 #if HAVE_LONG_LONG_INT
140141 case TYPE_COUNT_LONGLONGINT_POINTER:
141 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
142 break;
142 ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
143 break;
143144 #endif
144145 #if ENABLE_UNISTDIO
145146 /* The unistdio extensions. */
146147 case TYPE_U8_STRING:
147 ap->a.a_u8_string = va_arg (args, const uint8_t *);
148 /* A null pointer is an invalid argument for "%U", but in practice
149 it occurs quite frequently in printf statements that produce
150 debug output. Use a fallback in this case. */
151 if (ap->a.a_u8_string == NULL)
152 {
153 static const uint8_t u8_null_string[] =
154 { '(', 'N', 'U', 'L', 'L', ')', 0 };
155 ap->a.a_u8_string = u8_null_string;
156 }
157 break;
148 ap->a.a_u8_string = va_arg (args, const uint8_t *);
149 /* A null pointer is an invalid argument for "%U", but in practice
150 it occurs quite frequently in printf statements that produce
151 debug output. Use a fallback in this case. */
152 if (ap->a.a_u8_string == NULL)
153 {
154 static const uint8_t u8_null_string[] =
155 { '(', 'N', 'U', 'L', 'L', ')', 0 };
156 ap->a.a_u8_string = u8_null_string;
157 }
158 break;
158159 case TYPE_U16_STRING:
159 ap->a.a_u16_string = va_arg (args, const uint16_t *);
160 /* A null pointer is an invalid argument for "%lU", but in practice
161 it occurs quite frequently in printf statements that produce
162 debug output. Use a fallback in this case. */
163 if (ap->a.a_u16_string == NULL)
164 {
165 static const uint16_t u16_null_string[] =
166 { '(', 'N', 'U', 'L', 'L', ')', 0 };
167 ap->a.a_u16_string = u16_null_string;
168 }
169 break;
160 ap->a.a_u16_string = va_arg (args, const uint16_t *);
161 /* A null pointer is an invalid argument for "%lU", but in practice
162 it occurs quite frequently in printf statements that produce
163 debug output. Use a fallback in this case. */
164 if (ap->a.a_u16_string == NULL)
165 {
166 static const uint16_t u16_null_string[] =
167 { '(', 'N', 'U', 'L', 'L', ')', 0 };
168 ap->a.a_u16_string = u16_null_string;
169 }
170 break;
170171 case TYPE_U32_STRING:
171 ap->a.a_u32_string = va_arg (args, const uint32_t *);
172 /* A null pointer is an invalid argument for "%llU", but in practice
173 it occurs quite frequently in printf statements that produce
174 debug output. Use a fallback in this case. */
175 if (ap->a.a_u32_string == NULL)
176 {
177 static const uint32_t u32_null_string[] =
178 { '(', 'N', 'U', 'L', 'L', ')', 0 };
179 ap->a.a_u32_string = u32_null_string;
180 }
181 break;
172 ap->a.a_u32_string = va_arg (args, const uint32_t *);
173 /* A null pointer is an invalid argument for "%llU", but in practice
174 it occurs quite frequently in printf statements that produce
175 debug output. Use a fallback in this case. */
176 if (ap->a.a_u32_string == NULL)
177 {
178 static const uint32_t u32_null_string[] =
179 { '(', 'N', 'U', 'L', 'L', ')', 0 };
180 ap->a.a_u32_string = u32_null_string;
181 }
182 break;
182183 #endif
183184 default:
184 /* Unknown type. */
185 return -1;
185 /* Unknown type. */
186 return -1;
186187 }
187188 return 0;
188189 }
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Decomposed printf argument list.
3 Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc.
3 Copyright (C) 1999, 2002-2003, 2006-2007, 2009-2010 Free Software
4 Foundation, Inc.
45
56 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
9495 arg_type type;
9596 union
9697 {
97 signed char a_schar;
98 unsigned char a_uchar;
99 short a_short;
100 unsigned short a_ushort;
101 int a_int;
102 unsigned int a_uint;
103 long int a_longint;
104 unsigned long int a_ulongint;
98 signed char a_schar;
99 unsigned char a_uchar;
100 short a_short;
101 unsigned short a_ushort;
102 int a_int;
103 unsigned int a_uint;
104 long int a_longint;
105 unsigned long int a_ulongint;
105106 #if HAVE_LONG_LONG_INT
106 long long int a_longlongint;
107 unsigned long long int a_ulonglongint;
107 long long int a_longlongint;
108 unsigned long long int a_ulonglongint;
108109 #endif
109 float a_float;
110 double a_double;
111 long double a_longdouble;
112 int a_char;
110 float a_float;
111 double a_double;
112 long double a_longdouble;
113 int a_char;
113114 #if HAVE_WINT_T
114 wint_t a_wide_char;
115 wint_t a_wide_char;
115116 #endif
116 const char* a_string;
117 const char* a_string;
117118 #if HAVE_WCHAR_T
118 const wchar_t* a_wide_string;
119 const wchar_t* a_wide_string;
119120 #endif
120 void* a_pointer;
121 signed char * a_count_schar_pointer;
122 short * a_count_short_pointer;
123 int * a_count_int_pointer;
124 long int * a_count_longint_pointer;
121 void* a_pointer;
122 signed char * a_count_schar_pointer;
123 short * a_count_short_pointer;
124 int * a_count_int_pointer;
125 long int * a_count_longint_pointer;
125126 #if HAVE_LONG_LONG_INT
126 long long int * a_count_longlongint_pointer;
127 long long int * a_count_longlongint_pointer;
127128 #endif
128129 #if ENABLE_UNISTDIO
129130 /* The unistdio extensions. */
130 const uint8_t * a_u8_string;
131 const uint16_t * a_u16_string;
132 const uint32_t * a_u32_string;
131 const uint8_t * a_u8_string;
132 const uint16_t * a_u16_string;
133 const uint32_t * a_u32_string;
133134 #endif
134135 }
135136 a;
00 /* Split a double into fraction and mantissa, for hexadecimal printf.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
9191 exponent = 0;
9292 if (x >= L_(1.0))
9393 {
94 /* A nonnegative exponent. */
95 {
96 DOUBLE pow2_i; /* = pow2[i] */
97 DOUBLE powh_i; /* = powh[i] */
94 /* A nonnegative exponent. */
95 {
96 DOUBLE pow2_i; /* = pow2[i] */
97 DOUBLE powh_i; /* = powh[i] */
9898
99 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
100 x * 2^exponent = argument, x >= 1.0. */
101 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
102 ;
103 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
104 {
105 if (x >= pow2_i)
106 {
107 exponent += (1 << i);
108 x *= powh_i;
109 }
110 else
111 break;
99 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
100 x * 2^exponent = argument, x >= 1.0. */
101 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
102 ;
103 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
104 {
105 if (x >= pow2_i)
106 {
107 exponent += (1 << i);
108 x *= powh_i;
109 }
110 else
111 break;
112112
113 pow2[i] = pow2_i;
114 powh[i] = powh_i;
115 }
116 }
117 /* Here 1.0 <= x < 2^2^i. */
113 pow2[i] = pow2_i;
114 powh[i] = powh_i;
115 }
116 }
117 /* Here 1.0 <= x < 2^2^i. */
118118 }
119119 else
120120 {
121 /* A negative exponent. */
122 {
123 DOUBLE pow2_i; /* = pow2[i] */
124 DOUBLE powh_i; /* = powh[i] */
121 /* A negative exponent. */
122 {
123 DOUBLE pow2_i; /* = pow2[i] */
124 DOUBLE powh_i; /* = powh[i] */
125125
126 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
127 x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1. */
128 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
129 ;
130 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
131 {
132 if (exponent - (1 << i) < MIN_EXP - 1)
133 break;
126 /* Invariants: pow2_i = 2^2^i, powh_i = 2^-2^i,
127 x * 2^exponent = argument, x < 1.0, exponent >= MIN_EXP - 1. */
128 for (i = 0, pow2_i = L_(2.0), powh_i = L_(0.5);
129 ;
130 i++, pow2_i = pow2_i * pow2_i, powh_i = powh_i * powh_i)
131 {
132 if (exponent - (1 << i) < MIN_EXP - 1)
133 break;
134134
135 exponent -= (1 << i);
136 x *= pow2_i;
137 if (x >= L_(1.0))
138 break;
135 exponent -= (1 << i);
136 x *= pow2_i;
137 if (x >= L_(1.0))
138 break;
139139
140 pow2[i] = pow2_i;
141 powh[i] = powh_i;
142 }
143 }
144 /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent,
145 or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */
140 pow2[i] = pow2_i;
141 powh[i] = powh_i;
142 }
143 }
144 /* Here either x < 1.0 and exponent - 2^i < MIN_EXP - 1 <= exponent,
145 or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */
146146
147 if (x < L_(1.0))
148 /* Invariants: x * 2^exponent = argument, x < 1.0 and
149 exponent - 2^i < MIN_EXP - 1 <= exponent. */
150 while (i > 0)
151 {
152 i--;
153 if (exponent - (1 << i) >= MIN_EXP - 1)
154 {
155 exponent -= (1 << i);
156 x *= pow2[i];
157 if (x >= L_(1.0))
158 break;
159 }
160 }
147 if (x < L_(1.0))
148 /* Invariants: x * 2^exponent = argument, x < 1.0 and
149 exponent - 2^i < MIN_EXP - 1 <= exponent. */
150 while (i > 0)
151 {
152 i--;
153 if (exponent - (1 << i) >= MIN_EXP - 1)
154 {
155 exponent -= (1 << i);
156 x *= pow2[i];
157 if (x >= L_(1.0))
158 break;
159 }
160 }
161161
162 /* Here either x < 1.0 and exponent = MIN_EXP - 1,
163 or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */
162 /* Here either x < 1.0 and exponent = MIN_EXP - 1,
163 or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */
164164 }
165165
166166 /* Invariants: x * 2^exponent = argument, and
168168 or 1.0 <= x < 2^2^i and exponent >= MIN_EXP - 1. */
169169 while (i > 0)
170170 {
171 i--;
172 if (x >= pow2[i])
173 {
174 exponent += (1 << i);
175 x *= powh[i];
176 }
171 i--;
172 if (x >= pow2[i])
173 {
174 exponent += (1 << i);
175 x *= powh[i];
176 }
177177 }
178178 /* Here either x < 1.0 and exponent = MIN_EXP - 1,
179179 or 1.0 <= x < 2.0 and exponent >= MIN_EXP - 1. */
00 /* Split a double into fraction and mantissa, for hexadecimal printf.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Split a 'long double' into fraction and mantissa, for hexadecimal printf.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* Split a 'long double' into fraction and mantissa, for hexadecimal printf.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Formatted output to strings.
3 Copyright (C) 1999-2000, 2002-2003, 2006-2008 Free Software Foundation, Inc.
3 Copyright (C) 1999-2000, 2002-2003, 2006-2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
8181 int
8282 PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
8383 {
84 const CHAR_T *cp = format; /* pointer into format */
85 size_t arg_posn = 0; /* number of regular arguments consumed */
86 size_t d_allocated; /* allocated elements of d->dir */
87 size_t a_allocated; /* allocated elements of a->arg */
84 const CHAR_T *cp = format; /* pointer into format */
85 size_t arg_posn = 0; /* number of regular arguments consumed */
86 size_t d_allocated; /* allocated elements of d->dir */
87 size_t a_allocated; /* allocated elements of a->arg */
8888 size_t max_width_length = 0;
8989 size_t max_precision_length = 0;
9090
100100 a->arg = NULL;
101101
102102 #define REGISTER_ARG(_index_,_type_) \
103 { \
104 size_t n = (_index_); \
105 if (n >= a_allocated) \
106 { \
107 size_t memory_size; \
108 argument *memory; \
109 \
110 a_allocated = xtimes (a_allocated, 2); \
111 if (a_allocated <= n) \
112 a_allocated = xsum (n, 1); \
113 memory_size = xtimes (a_allocated, sizeof (argument)); \
114 if (size_overflow_p (memory_size)) \
115 /* Overflow, would lead to out of memory. */ \
116 goto out_of_memory; \
117 memory = (argument *) (a->arg \
118 ? realloc (a->arg, memory_size) \
119 : malloc (memory_size)); \
120 if (memory == NULL) \
121 /* Out of memory. */ \
122 goto out_of_memory; \
123 a->arg = memory; \
124 } \
125 while (a->count <= n) \
126 a->arg[a->count++].type = TYPE_NONE; \
127 if (a->arg[n].type == TYPE_NONE) \
128 a->arg[n].type = (_type_); \
129 else if (a->arg[n].type != (_type_)) \
130 /* Ambiguous type for positional argument. */ \
131 goto error; \
103 { \
104 size_t n = (_index_); \
105 if (n >= a_allocated) \
106 { \
107 size_t memory_size; \
108 argument *memory; \
109 \
110 a_allocated = xtimes (a_allocated, 2); \
111 if (a_allocated <= n) \
112 a_allocated = xsum (n, 1); \
113 memory_size = xtimes (a_allocated, sizeof (argument)); \
114 if (size_overflow_p (memory_size)) \
115 /* Overflow, would lead to out of memory. */ \
116 goto out_of_memory; \
117 memory = (argument *) (a->arg \
118 ? realloc (a->arg, memory_size) \
119 : malloc (memory_size)); \
120 if (memory == NULL) \
121 /* Out of memory. */ \
122 goto out_of_memory; \
123 a->arg = memory; \
124 } \
125 while (a->count <= n) \
126 a->arg[a->count++].type = TYPE_NONE; \
127 if (a->arg[n].type == TYPE_NONE) \
128 a->arg[n].type = (_type_); \
129 else if (a->arg[n].type != (_type_)) \
130 /* Ambiguous type for positional argument. */ \
131 goto error; \
132132 }
133133
134134 while (*cp != '\0')
135135 {
136136 CHAR_T c = *cp++;
137137 if (c == '%')
138 {
139 size_t arg_index = ARG_NONE;
140 DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
141
142 /* Initialize the next directive. */
143 dp->dir_start = cp - 1;
144 dp->flags = 0;
145 dp->width_start = NULL;
146 dp->width_end = NULL;
147 dp->width_arg_index = ARG_NONE;
148 dp->precision_start = NULL;
149 dp->precision_end = NULL;
150 dp->precision_arg_index = ARG_NONE;
151 dp->arg_index = ARG_NONE;
152
153 /* Test for positional argument. */
154 if (*cp >= '0' && *cp <= '9')
155 {
156 const CHAR_T *np;
157
158 for (np = cp; *np >= '0' && *np <= '9'; np++)
159 ;
160 if (*np == '$')
161 {
162 size_t n = 0;
163
164 for (np = cp; *np >= '0' && *np <= '9'; np++)
165 n = xsum (xtimes (n, 10), *np - '0');
166 if (n == 0)
167 /* Positional argument 0. */
168 goto error;
169 if (size_overflow_p (n))
170 /* n too large, would lead to out of memory later. */
171 goto error;
172 arg_index = n - 1;
173 cp = np + 1;
174 }
175 }
176
177 /* Read the flags. */
178 for (;;)
179 {
180 if (*cp == '\'')
181 {
182 dp->flags |= FLAG_GROUP;
183 cp++;
184 }
185 else if (*cp == '-')
186 {
187 dp->flags |= FLAG_LEFT;
188 cp++;
189 }
190 else if (*cp == '+')
191 {
192 dp->flags |= FLAG_SHOWSIGN;
193 cp++;
194 }
195 else if (*cp == ' ')
196 {
197 dp->flags |= FLAG_SPACE;
198 cp++;
199 }
200 else if (*cp == '#')
201 {
202 dp->flags |= FLAG_ALT;
203 cp++;
204 }
205 else if (*cp == '0')
206 {
207 dp->flags |= FLAG_ZERO;
208 cp++;
209 }
210 else
211 break;
212 }
213
214 /* Parse the field width. */
215 if (*cp == '*')
216 {
217 dp->width_start = cp;
218 cp++;
219 dp->width_end = cp;
220 if (max_width_length < 1)
221 max_width_length = 1;
222
223 /* Test for positional argument. */
224 if (*cp >= '0' && *cp <= '9')
225 {
226 const CHAR_T *np;
227
228 for (np = cp; *np >= '0' && *np <= '9'; np++)
229 ;
230 if (*np == '$')
231 {
232 size_t n = 0;
233
234 for (np = cp; *np >= '0' && *np <= '9'; np++)
235 n = xsum (xtimes (n, 10), *np - '0');
236 if (n == 0)
237 /* Positional argument 0. */
238 goto error;
239 if (size_overflow_p (n))
240 /* n too large, would lead to out of memory later. */
241 goto error;
242 dp->width_arg_index = n - 1;
243 cp = np + 1;
244 }
245 }
246 if (dp->width_arg_index == ARG_NONE)
247 {
248 dp->width_arg_index = arg_posn++;
249 if (dp->width_arg_index == ARG_NONE)
250 /* arg_posn wrapped around. */
251 goto error;
252 }
253 REGISTER_ARG (dp->width_arg_index, TYPE_INT);
254 }
255 else if (*cp >= '0' && *cp <= '9')
256 {
257 size_t width_length;
258
259 dp->width_start = cp;
260 for (; *cp >= '0' && *cp <= '9'; cp++)
261 ;
262 dp->width_end = cp;
263 width_length = dp->width_end - dp->width_start;
264 if (max_width_length < width_length)
265 max_width_length = width_length;
266 }
267
268 /* Parse the precision. */
269 if (*cp == '.')
270 {
271 cp++;
272 if (*cp == '*')
273 {
274 dp->precision_start = cp - 1;
275 cp++;
276 dp->precision_end = cp;
277 if (max_precision_length < 2)
278 max_precision_length = 2;
279
280 /* Test for positional argument. */
281 if (*cp >= '0' && *cp <= '9')
282 {
283 const CHAR_T *np;
284
285 for (np = cp; *np >= '0' && *np <= '9'; np++)
286 ;
287 if (*np == '$')
288 {
289 size_t n = 0;
290
291 for (np = cp; *np >= '0' && *np <= '9'; np++)
292 n = xsum (xtimes (n, 10), *np - '0');
293 if (n == 0)
294 /* Positional argument 0. */
295 goto error;
296 if (size_overflow_p (n))
297 /* n too large, would lead to out of memory
298 later. */
299 goto error;
300 dp->precision_arg_index = n - 1;
301 cp = np + 1;
302 }
303 }
304 if (dp->precision_arg_index == ARG_NONE)
305 {
306 dp->precision_arg_index = arg_posn++;
307 if (dp->precision_arg_index == ARG_NONE)
308 /* arg_posn wrapped around. */
309 goto error;
310 }
311 REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
312 }
313 else
314 {
315 size_t precision_length;
316
317 dp->precision_start = cp - 1;
318 for (; *cp >= '0' && *cp <= '9'; cp++)
319 ;
320 dp->precision_end = cp;
321 precision_length = dp->precision_end - dp->precision_start;
322 if (max_precision_length < precision_length)
323 max_precision_length = precision_length;
324 }
325 }
326
327 {
328 arg_type type;
329
330 /* Parse argument type/size specifiers. */
331 {
332 int flags = 0;
333
334 for (;;)
335 {
336 if (*cp == 'h')
337 {
338 flags |= (1 << (flags & 1));
339 cp++;
340 }
341 else if (*cp == 'L')
342 {
343 flags |= 4;
344 cp++;
345 }
346 else if (*cp == 'l')
347 {
348 flags += 8;
349 cp++;
350 }
351 else if (*cp == 'j')
352 {
353 if (sizeof (intmax_t) > sizeof (long))
354 {
355 /* intmax_t = long long */
356 flags += 16;
357 }
358 else if (sizeof (intmax_t) > sizeof (int))
359 {
360 /* intmax_t = long */
361 flags += 8;
362 }
363 cp++;
364 }
365 else if (*cp == 'z' || *cp == 'Z')
366 {
367 /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
368 because the warning facility in gcc-2.95.2 understands
369 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
370 if (sizeof (size_t) > sizeof (long))
371 {
372 /* size_t = long long */
373 flags += 16;
374 }
375 else if (sizeof (size_t) > sizeof (int))
376 {
377 /* size_t = long */
378 flags += 8;
379 }
380 cp++;
381 }
382 else if (*cp == 't')
383 {
384 if (sizeof (ptrdiff_t) > sizeof (long))
385 {
386 /* ptrdiff_t = long long */
387 flags += 16;
388 }
389 else if (sizeof (ptrdiff_t) > sizeof (int))
390 {
391 /* ptrdiff_t = long */
392 flags += 8;
393 }
394 cp++;
395 }
138 {
139 size_t arg_index = ARG_NONE;
140 DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
141
142 /* Initialize the next directive. */
143 dp->dir_start = cp - 1;
144 dp->flags = 0;
145 dp->width_start = NULL;
146 dp->width_end = NULL;
147 dp->width_arg_index = ARG_NONE;
148 dp->precision_start = NULL;
149 dp->precision_end = NULL;
150 dp->precision_arg_index = ARG_NONE;
151 dp->arg_index = ARG_NONE;
152
153 /* Test for positional argument. */
154 if (*cp >= '0' && *cp <= '9')
155 {
156 const CHAR_T *np;
157
158 for (np = cp; *np >= '0' && *np <= '9'; np++)
159 ;
160 if (*np == '$')
161 {
162 size_t n = 0;
163
164 for (np = cp; *np >= '0' && *np <= '9'; np++)
165 n = xsum (xtimes (n, 10), *np - '0');
166 if (n == 0)
167 /* Positional argument 0. */
168 goto error;
169 if (size_overflow_p (n))
170 /* n too large, would lead to out of memory later. */
171 goto error;
172 arg_index = n - 1;
173 cp = np + 1;
174 }
175 }
176
177 /* Read the flags. */
178 for (;;)
179 {
180 if (*cp == '\'')
181 {
182 dp->flags |= FLAG_GROUP;
183 cp++;
184 }
185 else if (*cp == '-')
186 {
187 dp->flags |= FLAG_LEFT;
188 cp++;
189 }
190 else if (*cp == '+')
191 {
192 dp->flags |= FLAG_SHOWSIGN;
193 cp++;
194 }
195 else if (*cp == ' ')
196 {
197 dp->flags |= FLAG_SPACE;
198 cp++;
199 }
200 else if (*cp == '#')
201 {
202 dp->flags |= FLAG_ALT;
203 cp++;
204 }
205 else if (*cp == '0')
206 {
207 dp->flags |= FLAG_ZERO;
208 cp++;
209 }
210 else
211 break;
212 }
213
214 /* Parse the field width. */
215 if (*cp == '*')
216 {
217 dp->width_start = cp;
218 cp++;
219 dp->width_end = cp;
220 if (max_width_length < 1)
221 max_width_length = 1;
222
223 /* Test for positional argument. */
224 if (*cp >= '0' && *cp <= '9')
225 {
226 const CHAR_T *np;
227
228 for (np = cp; *np >= '0' && *np <= '9'; np++)
229 ;
230 if (*np == '$')
231 {
232 size_t n = 0;
233
234 for (np = cp; *np >= '0' && *np <= '9'; np++)
235 n = xsum (xtimes (n, 10), *np - '0');
236 if (n == 0)
237 /* Positional argument 0. */
238 goto error;
239 if (size_overflow_p (n))
240 /* n too large, would lead to out of memory later. */
241 goto error;
242 dp->width_arg_index = n - 1;
243 cp = np + 1;
244 }
245 }
246 if (dp->width_arg_index == ARG_NONE)
247 {
248 dp->width_arg_index = arg_posn++;
249 if (dp->width_arg_index == ARG_NONE)
250 /* arg_posn wrapped around. */
251 goto error;
252 }
253 REGISTER_ARG (dp->width_arg_index, TYPE_INT);
254 }
255 else if (*cp >= '0' && *cp <= '9')
256 {
257 size_t width_length;
258
259 dp->width_start = cp;
260 for (; *cp >= '0' && *cp <= '9'; cp++)
261 ;
262 dp->width_end = cp;
263 width_length = dp->width_end - dp->width_start;
264 if (max_width_length < width_length)
265 max_width_length = width_length;
266 }
267
268 /* Parse the precision. */
269 if (*cp == '.')
270 {
271 cp++;
272 if (*cp == '*')
273 {
274 dp->precision_start = cp - 1;
275 cp++;
276 dp->precision_end = cp;
277 if (max_precision_length < 2)
278 max_precision_length = 2;
279
280 /* Test for positional argument. */
281 if (*cp >= '0' && *cp <= '9')
282 {
283 const CHAR_T *np;
284
285 for (np = cp; *np >= '0' && *np <= '9'; np++)
286 ;
287 if (*np == '$')
288 {
289 size_t n = 0;
290
291 for (np = cp; *np >= '0' && *np <= '9'; np++)
292 n = xsum (xtimes (n, 10), *np - '0');
293 if (n == 0)
294 /* Positional argument 0. */
295 goto error;
296 if (size_overflow_p (n))
297 /* n too large, would lead to out of memory
298 later. */
299 goto error;
300 dp->precision_arg_index = n - 1;
301 cp = np + 1;
302 }
303 }
304 if (dp->precision_arg_index == ARG_NONE)
305 {
306 dp->precision_arg_index = arg_posn++;
307 if (dp->precision_arg_index == ARG_NONE)
308 /* arg_posn wrapped around. */
309 goto error;
310 }
311 REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
312 }
313 else
314 {
315 size_t precision_length;
316
317 dp->precision_start = cp - 1;
318 for (; *cp >= '0' && *cp <= '9'; cp++)
319 ;
320 dp->precision_end = cp;
321 precision_length = dp->precision_end - dp->precision_start;
322 if (max_precision_length < precision_length)
323 max_precision_length = precision_length;
324 }
325 }
326
327 {
328 arg_type type;
329
330 /* Parse argument type/size specifiers. */
331 {
332 int flags = 0;
333
334 for (;;)
335 {
336 if (*cp == 'h')
337 {
338 flags |= (1 << (flags & 1));
339 cp++;
340 }
341 else if (*cp == 'L')
342 {
343 flags |= 4;
344 cp++;
345 }
346 else if (*cp == 'l')
347 {
348 flags += 8;
349 cp++;
350 }
351 else if (*cp == 'j')
352 {
353 if (sizeof (intmax_t) > sizeof (long))
354 {
355 /* intmax_t = long long */
356 flags += 16;
357 }
358 else if (sizeof (intmax_t) > sizeof (int))
359 {
360 /* intmax_t = long */
361 flags += 8;
362 }
363 cp++;
364 }
365 else if (*cp == 'z' || *cp == 'Z')
366 {
367 /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
368 because the warning facility in gcc-2.95.2 understands
369 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
370 if (sizeof (size_t) > sizeof (long))
371 {
372 /* size_t = long long */
373 flags += 16;
374 }
375 else if (sizeof (size_t) > sizeof (int))
376 {
377 /* size_t = long */
378 flags += 8;
379 }
380 cp++;
381 }
382 else if (*cp == 't')
383 {
384 if (sizeof (ptrdiff_t) > sizeof (long))
385 {
386 /* ptrdiff_t = long long */
387 flags += 16;
388 }
389 else if (sizeof (ptrdiff_t) > sizeof (int))
390 {
391 /* ptrdiff_t = long */
392 flags += 8;
393 }
394 cp++;
395 }
396396 #if defined __APPLE__ && defined __MACH__
397 /* On MacOS X 10.3, PRIdMAX is defined as "qd".
398 We cannot change it to "lld" because PRIdMAX must also
399 be understood by the system's printf routines. */
400 else if (*cp == 'q')
401 {
402 if (64 / 8 > sizeof (long))
403 {
404 /* int64_t = long long */
405 flags += 16;
406 }
407 else
408 {
409 /* int64_t = long */
410 flags += 8;
411 }
412 cp++;
413 }
397 /* On MacOS X 10.3, PRIdMAX is defined as "qd".
398 We cannot change it to "lld" because PRIdMAX must also
399 be understood by the system's printf routines. */
400 else if (*cp == 'q')
401 {
402 if (64 / 8 > sizeof (long))
403 {
404 /* int64_t = long long */
405 flags += 16;
406 }
407 else
408 {
409 /* int64_t = long */
410 flags += 8;
411 }
412 cp++;
413 }
414414 #endif
415415 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
416 /* On native Win32, PRIdMAX is defined as "I64d".
417 We cannot change it to "lld" because PRIdMAX must also
418 be understood by the system's printf routines. */
419 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
420 {
421 if (64 / 8 > sizeof (long))
422 {
423 /* __int64 = long long */
424 flags += 16;
425 }
426 else
427 {
428 /* __int64 = long */
429 flags += 8;
430 }
431 cp += 3;
432 }
433 #endif
434 else
435 break;
436 }
437
438 /* Read the conversion character. */
439 c = *cp++;
440 switch (c)
441 {
442 case 'd': case 'i':
416 /* On native Win32, PRIdMAX is defined as "I64d".
417 We cannot change it to "lld" because PRIdMAX must also
418 be understood by the system's printf routines. */
419 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
420 {
421 if (64 / 8 > sizeof (long))
422 {
423 /* __int64 = long long */
424 flags += 16;
425 }
426 else
427 {
428 /* __int64 = long */
429 flags += 8;
430 }
431 cp += 3;
432 }
433 #endif
434 else
435 break;
436 }
437
438 /* Read the conversion character. */
439 c = *cp++;
440 switch (c)
441 {
442 case 'd': case 'i':
443443 #if HAVE_LONG_LONG_INT
444 /* If 'long long' exists and is larger than 'long': */
445 if (flags >= 16 || (flags & 4))
446 type = TYPE_LONGLONGINT;
447 else
448 #endif
449 /* If 'long long' exists and is the same as 'long', we parse
450 "lld" into TYPE_LONGINT. */
451 if (flags >= 8)
452 type = TYPE_LONGINT;
453 else if (flags & 2)
454 type = TYPE_SCHAR;
455 else if (flags & 1)
456 type = TYPE_SHORT;
457 else
458 type = TYPE_INT;
459 break;
460 case 'o': case 'u': case 'x': case 'X':
444 /* If 'long long' exists and is larger than 'long': */
445 if (flags >= 16 || (flags & 4))
446 type = TYPE_LONGLONGINT;
447 else
448 #endif
449 /* If 'long long' exists and is the same as 'long', we parse
450 "lld" into TYPE_LONGINT. */
451 if (flags >= 8)
452 type = TYPE_LONGINT;
453 else if (flags & 2)
454 type = TYPE_SCHAR;
455 else if (flags & 1)
456 type = TYPE_SHORT;
457 else
458 type = TYPE_INT;
459 break;
460 case 'o': case 'u': case 'x': case 'X':
461461 #if HAVE_LONG_LONG_INT
462 /* If 'long long' exists and is larger than 'long': */
463 if (flags >= 16 || (flags & 4))
464 type = TYPE_ULONGLONGINT;
465 else
466 #endif
467 /* If 'unsigned long long' exists and is the same as
468 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
469 if (flags >= 8)
470 type = TYPE_ULONGINT;
471 else if (flags & 2)
472 type = TYPE_UCHAR;
473 else if (flags & 1)
474 type = TYPE_USHORT;
475 else
476 type = TYPE_UINT;
477 break;
478 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
479 case 'a': case 'A':
480 if (flags >= 16 || (flags & 4))
481 type = TYPE_LONGDOUBLE;
482 else
483 type = TYPE_DOUBLE;
484 break;
485 case 'c':
486 if (flags >= 8)
462 /* If 'long long' exists and is larger than 'long': */
463 if (flags >= 16 || (flags & 4))
464 type = TYPE_ULONGLONGINT;
465 else
466 #endif
467 /* If 'unsigned long long' exists and is the same as
468 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
469 if (flags >= 8)
470 type = TYPE_ULONGINT;
471 else if (flags & 2)
472 type = TYPE_UCHAR;
473 else if (flags & 1)
474 type = TYPE_USHORT;
475 else
476 type = TYPE_UINT;
477 break;
478 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
479 case 'a': case 'A':
480 if (flags >= 16 || (flags & 4))
481 type = TYPE_LONGDOUBLE;
482 else
483 type = TYPE_DOUBLE;
484 break;
485 case 'c':
486 if (flags >= 8)
487487 #if HAVE_WINT_T
488 type = TYPE_WIDE_CHAR;
488 type = TYPE_WIDE_CHAR;
489489 #else
490 goto error;
491 #endif
492 else
493 type = TYPE_CHAR;
494 break;
490 goto error;
491 #endif
492 else
493 type = TYPE_CHAR;
494 break;
495495 #if HAVE_WINT_T
496 case 'C':
497 type = TYPE_WIDE_CHAR;
498 c = 'c';
499 break;
500 #endif
501 case 's':
502 if (flags >= 8)
496 case 'C':
497 type = TYPE_WIDE_CHAR;
498 c = 'c';
499 break;
500 #endif
501 case 's':
502 if (flags >= 8)
503503 #if HAVE_WCHAR_T
504 type = TYPE_WIDE_STRING;
504 type = TYPE_WIDE_STRING;
505505 #else
506 goto error;
507 #endif
508 else
509 type = TYPE_STRING;
510 break;
506 goto error;
507 #endif
508 else
509 type = TYPE_STRING;
510 break;
511511 #if HAVE_WCHAR_T
512 case 'S':
513 type = TYPE_WIDE_STRING;
514 c = 's';
515 break;
516 #endif
517 case 'p':
518 type = TYPE_POINTER;
519 break;
520 case 'n':
512 case 'S':
513 type = TYPE_WIDE_STRING;
514 c = 's';
515 break;
516 #endif
517 case 'p':
518 type = TYPE_POINTER;
519 break;
520 case 'n':
521521 #if HAVE_LONG_LONG_INT
522 /* If 'long long' exists and is larger than 'long': */
523 if (flags >= 16 || (flags & 4))
524 type = TYPE_COUNT_LONGLONGINT_POINTER;
525 else
526 #endif
527 /* If 'long long' exists and is the same as 'long', we parse
528 "lln" into TYPE_COUNT_LONGINT_POINTER. */
529 if (flags >= 8)
530 type = TYPE_COUNT_LONGINT_POINTER;
531 else if (flags & 2)
532 type = TYPE_COUNT_SCHAR_POINTER;
533 else if (flags & 1)
534 type = TYPE_COUNT_SHORT_POINTER;
535 else
536 type = TYPE_COUNT_INT_POINTER;
537 break;
522 /* If 'long long' exists and is larger than 'long': */
523 if (flags >= 16 || (flags & 4))
524 type = TYPE_COUNT_LONGLONGINT_POINTER;
525 else
526 #endif
527 /* If 'long long' exists and is the same as 'long', we parse
528 "lln" into TYPE_COUNT_LONGINT_POINTER. */
529 if (flags >= 8)
530 type = TYPE_COUNT_LONGINT_POINTER;
531 else if (flags & 2)
532 type = TYPE_COUNT_SCHAR_POINTER;
533 else if (flags & 1)
534 type = TYPE_COUNT_SHORT_POINTER;
535 else
536 type = TYPE_COUNT_INT_POINTER;
537 break;
538538 #if ENABLE_UNISTDIO
539 /* The unistdio extensions. */
540 case 'U':
541 if (flags >= 16)
542 type = TYPE_U32_STRING;
543 else if (flags >= 8)
544 type = TYPE_U16_STRING;
545 else
546 type = TYPE_U8_STRING;
547 break;
548 #endif
549 case '%':
550 type = TYPE_NONE;
551 break;
552 default:
553 /* Unknown conversion character. */
554 goto error;
555 }
556 }
557
558 if (type != TYPE_NONE)
559 {
560 dp->arg_index = arg_index;
561 if (dp->arg_index == ARG_NONE)
562 {
563 dp->arg_index = arg_posn++;
564 if (dp->arg_index == ARG_NONE)
565 /* arg_posn wrapped around. */
566 goto error;
567 }
568 REGISTER_ARG (dp->arg_index, type);
569 }
570 dp->conversion = c;
571 dp->dir_end = cp;
572 }
573
574 d->count++;
575 if (d->count >= d_allocated)
576 {
577 size_t memory_size;
578 DIRECTIVE *memory;
579
580 d_allocated = xtimes (d_allocated, 2);
581 memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
582 if (size_overflow_p (memory_size))
583 /* Overflow, would lead to out of memory. */
584 goto out_of_memory;
585 memory = (DIRECTIVE *) realloc (d->dir, memory_size);
586 if (memory == NULL)
587 /* Out of memory. */
588 goto out_of_memory;
589 d->dir = memory;
590 }
591 }
539 /* The unistdio extensions. */
540 case 'U':
541 if (flags >= 16)
542 type = TYPE_U32_STRING;
543 else if (flags >= 8)
544 type = TYPE_U16_STRING;
545 else
546 type = TYPE_U8_STRING;
547 break;
548 #endif
549 case '%':
550 type = TYPE_NONE;
551 break;
552 default:
553 /* Unknown conversion character. */
554 goto error;
555 }
556 }
557
558 if (type != TYPE_NONE)
559 {
560 dp->arg_index = arg_index;
561 if (dp->arg_index == ARG_NONE)
562 {
563 dp->arg_index = arg_posn++;
564 if (dp->arg_index == ARG_NONE)
565 /* arg_posn wrapped around. */
566 goto error;
567 }
568 REGISTER_ARG (dp->arg_index, type);
569 }
570 dp->conversion = c;
571 dp->dir_end = cp;
572 }
573
574 d->count++;
575 if (d->count >= d_allocated)
576 {
577 size_t memory_size;
578 DIRECTIVE *memory;
579
580 d_allocated = xtimes (d_allocated, 2);
581 memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
582 if (size_overflow_p (memory_size))
583 /* Overflow, would lead to out of memory. */
584 goto out_of_memory;
585 memory = (DIRECTIVE *) realloc (d->dir, memory_size);
586 if (memory == NULL)
587 /* Out of memory. */
588 goto out_of_memory;
589 d->dir = memory;
590 }
591 }
592592 #if CHAR_T_ONLY_ASCII
593593 else if (!c_isascii (c))
594 {
595 /* Non-ASCII character. Not supported. */
596 goto error;
597 }
594 {
595 /* Non-ASCII character. Not supported. */
596 goto error;
597 }
598598 #endif
599599 }
600600 d->dir[d->count].dir_start = cp;
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Parse printf format string.
3 Copyright (C) 1999, 2002-2003, 2005, 2007 Free Software Foundation, Inc.
3 Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2010 Free Software
4 Foundation, Inc.
45
56 This program is free software; you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
2728
2829
2930 /* Flags */
30 #define FLAG_GROUP 1 /* ' flag */
31 #define FLAG_LEFT 2 /* - flag */
32 #define FLAG_SHOWSIGN 4 /* + flag */
33 #define FLAG_SPACE 8 /* space flag */
34 #define FLAG_ALT 16 /* # flag */
35 #define FLAG_ZERO 32
31 #define FLAG_GROUP 1 /* ' flag */
32 #define FLAG_LEFT 2 /* - flag */
33 #define FLAG_SHOWSIGN 4 /* + flag */
34 #define FLAG_SPACE 8 /* space flag */
35 #define FLAG_ALT 16 /* # flag */
36 #define FLAG_ZERO 32
3637
3738 /* arg_index value indicating that no argument is consumed. */
38 #define ARG_NONE (~(size_t)0)
39 #define ARG_NONE (~(size_t)0)
3940
4041 /* xxx_directive: A parsed directive.
4142 xxx_directives: A parsed format string. */
164165 u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
165166 extern int
166167 u16_printf_parse (const uint16_t *format, u16_directives *d,
167 arguments *a);
168 arguments *a);
168169 extern int
169170 u32_printf_parse (const uint32_t *format, u32_directives *d,
170 arguments *a);
171 arguments *a);
171172 #else
172173 # ifdef STATIC
173174 STATIC
00 /* Formatted output to a stream.
1 Copyright (C) 2007 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* quotearg.c - quote arguments for output
11
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007,
3 2008 Free Software Foundation, Inc.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008,
3 2009, 2010 Free Software Foundation, Inc.
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
9999 {
100100 int e = errno;
101101 struct quoting_options *p = xmemdup (o ? o : &default_quoting_options,
102 sizeof *o);
102 sizeof *o);
103103 errno = e;
104104 return p;
105105 }
201201
202202 static size_t
203203 quotearg_buffer_restyled (char *buffer, size_t buffersize,
204 char const *arg, size_t argsize,
205 enum quoting_style quoting_style, int flags,
206 unsigned int const *quote_these_too,
207 char const *left_quote,
208 char const *right_quote)
204 char const *arg, size_t argsize,
205 enum quoting_style quoting_style, int flags,
206 unsigned int const *quote_these_too,
207 char const *left_quote,
208 char const *right_quote)
209209 {
210210 size_t i;
211211 size_t len = 0;
218218 #define STORE(c) \
219219 do \
220220 { \
221 if (len < buffersize) \
222 buffer[len] = (c); \
223 len++; \
221 if (len < buffersize) \
222 buffer[len] = (c); \
223 len++; \
224224 } \
225225 while (0)
226226
232232 /* Fall through. */
233233 case c_quoting_style:
234234 if (!elide_outer_quotes)
235 STORE ('"');
235 STORE ('"');
236236 backslash_escapes = true;
237237 quote_string = "\"";
238238 quote_string_len = 1;
247247 case clocale_quoting_style:
248248 case custom_quoting_style:
249249 {
250 if (quoting_style != custom_quoting_style)
251 {
252 /* TRANSLATORS:
253 Get translations for open and closing quotation marks.
254
255 The message catalog should translate "`" to a left
256 quotation mark suitable for the locale, and similarly for
257 "'". If the catalog has no translation,
258 locale_quoting_style quotes `like this', and
259 clocale_quoting_style quotes "like this".
260
261 For example, an American English Unicode locale should
262 translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
263 should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
264 MARK). A British English Unicode locale should instead
265 translate these to U+2018 (LEFT SINGLE QUOTATION MARK)
266 and U+2019 (RIGHT SINGLE QUOTATION MARK), respectively.
267
268 If you don't know what to put here, please see
269 <http://en.wikipedia.org/wiki/Quotation_mark#Glyphs>
270 and use glyphs suitable for your language. */
271 left_quote = gettext_quote (N_("`"), quoting_style);
272 right_quote = gettext_quote (N_("'"), quoting_style);
273 }
274 if (!elide_outer_quotes)
275 for (quote_string = left_quote; *quote_string; quote_string++)
276 STORE (*quote_string);
277 backslash_escapes = true;
278 quote_string = right_quote;
279 quote_string_len = strlen (quote_string);
250 if (quoting_style != custom_quoting_style)
251 {
252 /* TRANSLATORS:
253 Get translations for open and closing quotation marks.
254
255 The message catalog should translate "`" to a left
256 quotation mark suitable for the locale, and similarly for
257 "'". If the catalog has no translation,
258 locale_quoting_style quotes `like this', and
259 clocale_quoting_style quotes "like this".
260
261 For example, an American English Unicode locale should
262 translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
263 should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
264 MARK). A British English Unicode locale should instead
265 translate these to U+2018 (LEFT SINGLE QUOTATION MARK)
266 and U+2019 (RIGHT SINGLE QUOTATION MARK), respectively.
267
268 If you don't know what to put here, please see
269 <http://en.wikipedia.org/wiki/Quotation_mark#Glyphs>
270 and use glyphs suitable for your language. */
271 left_quote = gettext_quote (N_("`"), quoting_style);
272 right_quote = gettext_quote (N_("'"), quoting_style);
273 }
274 if (!elide_outer_quotes)
275 for (quote_string = left_quote; *quote_string; quote_string++)
276 STORE (*quote_string);
277 backslash_escapes = true;
278 quote_string = right_quote;
279 quote_string_len = strlen (quote_string);
280280 }
281281 break;
282282
286286 /* Fall through. */
287287 case shell_always_quoting_style:
288288 if (!elide_outer_quotes)
289 STORE ('\'');
289 STORE ('\'');
290290 quote_string = "'";
291291 quote_string_len = 1;
292292 break;
306306 bool is_right_quote = false;
307307
308308 if (backslash_escapes
309 && quote_string_len
310 && i + quote_string_len <= argsize
311 && memcmp (arg + i, quote_string, quote_string_len) == 0)
312 {
313 if (elide_outer_quotes)
314 goto force_outer_quoting_style;
315 is_right_quote = true;
316 }
309 && quote_string_len
310 && i + quote_string_len <= argsize
311 && memcmp (arg + i, quote_string, quote_string_len) == 0)
312 {
313 if (elide_outer_quotes)
314 goto force_outer_quoting_style;
315 is_right_quote = true;
316 }
317317
318318 c = arg[i];
319319 switch (c)
320 {
321 case '\0':
322 if (backslash_escapes)
323 {
324 if (elide_outer_quotes)
325 goto force_outer_quoting_style;
326 STORE ('\\');
327 /* If quote_string were to begin with digits, we'd need to
328 test for the end of the arg as well. However, it's
329 hard to imagine any locale that would use digits in
330 quotes, and set_custom_quoting is documented not to
331 accept them. */
332 if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
333 {
334 STORE ('0');
335 STORE ('0');
336 }
337 c = '0';
338 /* We don't have to worry that this last '0' will be
339 backslash-escaped because, again, quote_string should
340 not start with it and because quote_these_too is
341 documented as not accepting it. */
342 }
343 else if (flags & QA_ELIDE_NULL_BYTES)
344 continue;
345 break;
346
347 case '?':
348 switch (quoting_style)
349 {
350 case shell_always_quoting_style:
351 if (elide_outer_quotes)
352 goto force_outer_quoting_style;
353 break;
354
355 case c_quoting_style:
356 if ((flags & QA_SPLIT_TRIGRAPHS)
357 && i + 2 < argsize && arg[i + 1] == '?')
358 switch (arg[i + 2])
359 {
360 case '!': case '\'':
361 case '(': case ')': case '-': case '/':
362 case '<': case '=': case '>':
363 /* Escape the second '?' in what would otherwise be
364 a trigraph. */
365 if (elide_outer_quotes)
366 goto force_outer_quoting_style;
367 c = arg[i + 2];
368 i += 2;
369 STORE ('?');
370 STORE ('"');
371 STORE ('"');
372 STORE ('?');
373 break;
374
375 default:
376 break;
377 }
378 break;
379
380 default:
381 break;
382 }
383 break;
384
385 case '\a': esc = 'a'; goto c_escape;
386 case '\b': esc = 'b'; goto c_escape;
387 case '\f': esc = 'f'; goto c_escape;
388 case '\n': esc = 'n'; goto c_and_shell_escape;
389 case '\r': esc = 'r'; goto c_and_shell_escape;
390 case '\t': esc = 't'; goto c_and_shell_escape;
391 case '\v': esc = 'v'; goto c_escape;
392 case '\\': esc = c;
393 /* No need to escape the escape if we are trying to elide
394 outer quotes and nothing else is problematic. */
395 if (backslash_escapes && elide_outer_quotes && quote_string_len)
396 goto store_c;
397
398 c_and_shell_escape:
399 if (quoting_style == shell_always_quoting_style
400 && elide_outer_quotes)
401 goto force_outer_quoting_style;
402 /* Fall through. */
403 c_escape:
404 if (backslash_escapes)
405 {
406 c = esc;
407 goto store_escape;
408 }
409 break;
410
411 case '{': case '}': /* sometimes special if isolated */
412 if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1))
413 break;
414 /* Fall through. */
415 case '#': case '~':
416 if (i != 0)
417 break;
418 /* Fall through. */
419 case ' ':
420 case '!': /* special in bash */
421 case '"': case '$': case '&':
422 case '(': case ')': case '*': case ';':
423 case '<':
424 case '=': /* sometimes special in 0th or (with "set -k") later args */
425 case '>': case '[':
426 case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
427 case '`': case '|':
428 /* A shell special character. In theory, '$' and '`' could
429 be the first bytes of multibyte characters, which means
430 we should check them with mbrtowc, but in practice this
431 doesn't happen so it's not worth worrying about. */
432 if (quoting_style == shell_always_quoting_style
433 && elide_outer_quotes)
434 goto force_outer_quoting_style;
435 break;
436
437 case '\'':
438 if (quoting_style == shell_always_quoting_style)
439 {
440 if (elide_outer_quotes)
441 goto force_outer_quoting_style;
442 STORE ('\'');
443 STORE ('\\');
444 STORE ('\'');
445 }
446 break;
447
448 case '%': case '+': case ',': case '-': case '.': case '/':
449 case '0': case '1': case '2': case '3': case '4': case '5':
450 case '6': case '7': case '8': case '9': case ':':
451 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
452 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
453 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
454 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
455 case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
456 case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
457 case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
458 case 'o': case 'p': case 'q': case 'r': case 's': case 't':
459 case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
460 /* These characters don't cause problems, no matter what the
461 quoting style is. They cannot start multibyte sequences.
462 A digit or a special letter would cause trouble if it
463 appeared at the beginning of quote_string because we'd then
464 escape by prepending a backslash. However, it's hard to
465 imagine any locale that would use digits or letters as
466 quotes, and set_custom_quoting is documented not to accept
467 them. Also, a digit or a special letter would cause
468 trouble if it appeared in quote_these_too, but that's also
469 documented as not accepting them. */
470 break;
471
472 default:
473 /* If we have a multibyte sequence, copy it until we reach
474 its end, find an error, or come back to the initial shift
475 state. For C-like styles, if the sequence has
476 unprintable characters, escape the whole sequence, since
477 we can't easily escape single characters within it. */
478 {
479 /* Length of multibyte sequence found so far. */
480 size_t m;
481
482 bool printable;
483
484 if (unibyte_locale)
485 {
486 m = 1;
487 printable = isprint (c) != 0;
488 }
489 else
490 {
491 mbstate_t mbstate;
492 memset (&mbstate, 0, sizeof mbstate);
493
494 m = 0;
495 printable = true;
496 if (argsize == SIZE_MAX)
497 argsize = strlen (arg);
498
499 do
500 {
501 wchar_t w;
502 size_t bytes = mbrtowc (&w, &arg[i + m],
503 argsize - (i + m), &mbstate);
504 if (bytes == 0)
505 break;
506 else if (bytes == (size_t) -1)
507 {
508 printable = false;
509 break;
510 }
511 else if (bytes == (size_t) -2)
512 {
513 printable = false;
514 while (i + m < argsize && arg[i + m])
515 m++;
516 break;
517 }
518 else
519 {
520 /* Work around a bug with older shells that "see" a '\'
521 that is really the 2nd byte of a multibyte character.
522 In practice the problem is limited to ASCII
523 chars >= '@' that are shell special chars. */
524 if ('[' == 0x5b && elide_outer_quotes
525 && quoting_style == shell_always_quoting_style)
526 {
527 size_t j;
528 for (j = 1; j < bytes; j++)
529 switch (arg[i + m + j])
530 {
531 case '[': case '\\': case '^':
532 case '`': case '|':
533 goto force_outer_quoting_style;
534
535 default:
536 break;
537 }
538 }
539
540 if (! iswprint (w))
541 printable = false;
542 m += bytes;
543 }
544 }
545 while (! mbsinit (&mbstate));
546 }
547
548 if (1 < m || (backslash_escapes && ! printable))
549 {
550 /* Output a multibyte sequence, or an escaped
551 unprintable unibyte character. */
552 size_t ilim = i + m;
553
554 for (;;)
555 {
556 if (backslash_escapes && ! printable)
557 {
558 if (elide_outer_quotes)
559 goto force_outer_quoting_style;
560 STORE ('\\');
561 STORE ('0' + (c >> 6));
562 STORE ('0' + ((c >> 3) & 7));
563 c = '0' + (c & 7);
564 }
565 else if (is_right_quote)
566 {
567 STORE ('\\');
568 is_right_quote = false;
569 }
570 if (ilim <= i + 1)
571 break;
572 STORE (c);
573 c = arg[++i];
574 }
575
576 goto store_c;
577 }
578 }
579 }
320 {
321 case '\0':
322 if (backslash_escapes)
323 {
324 if (elide_outer_quotes)
325 goto force_outer_quoting_style;
326 STORE ('\\');
327 /* If quote_string were to begin with digits, we'd need to
328 test for the end of the arg as well. However, it's
329 hard to imagine any locale that would use digits in
330 quotes, and set_custom_quoting is documented not to
331 accept them. */
332 if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
333 {
334 STORE ('0');
335 STORE ('0');
336 }
337 c = '0';
338 /* We don't have to worry that this last '0' will be
339 backslash-escaped because, again, quote_string should
340 not start with it and because quote_these_too is
341 documented as not accepting it. */
342 }
343 else if (flags & QA_ELIDE_NULL_BYTES)
344 continue;
345 break;
346
347 case '?':
348 switch (quoting_style)
349 {
350 case shell_always_quoting_style:
351 if (elide_outer_quotes)
352 goto force_outer_quoting_style;
353 break;
354
355 case c_quoting_style:
356 if ((flags & QA_SPLIT_TRIGRAPHS)
357 && i + 2 < argsize && arg[i + 1] == '?')
358 switch (arg[i + 2])
359 {
360 case '!': case '\'':
361 case '(': case ')': case '-': case '/':
362 case '<': case '=': case '>':
363 /* Escape the second '?' in what would otherwise be
364 a trigraph. */
365 if (elide_outer_quotes)
366 goto force_outer_quoting_style;
367 c = arg[i + 2];
368 i += 2;
369 STORE ('?');
370 STORE ('"');
371 STORE ('"');
372 STORE ('?');
373 break;
374
375 default:
376 break;
377 }
378 break;
379
380 default:
381 break;
382 }
383 break;
384
385 case '\a': esc = 'a'; goto c_escape;
386 case '\b': esc = 'b'; goto c_escape;
387 case '\f': esc = 'f'; goto c_escape;
388 case '\n': esc = 'n'; goto c_and_shell_escape;
389 case '\r': esc = 'r'; goto c_and_shell_escape;
390 case '\t': esc = 't'; goto c_and_shell_escape;
391 case '\v': esc = 'v'; goto c_escape;
392 case '\\': esc = c;
393 /* No need to escape the escape if we are trying to elide
394 outer quotes and nothing else is problematic. */
395 if (backslash_escapes && elide_outer_quotes && quote_string_len)
396 goto store_c;
397
398 c_and_shell_escape:
399 if (quoting_style == shell_always_quoting_style
400 && elide_outer_quotes)
401 goto force_outer_quoting_style;
402 /* Fall through. */
403 c_escape:
404 if (backslash_escapes)
405 {
406 c = esc;
407 goto store_escape;
408 }
409 break;
410
411 case '{': case '}': /* sometimes special if isolated */
412 if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1))
413 break;
414 /* Fall through. */
415 case '#': case '~':
416 if (i != 0)
417 break;
418 /* Fall through. */
419 case ' ':
420 case '!': /* special in bash */
421 case '"': case '$': case '&':
422 case '(': case ')': case '*': case ';':
423 case '<':
424 case '=': /* sometimes special in 0th or (with "set -k") later args */
425 case '>': case '[':
426 case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
427 case '`': case '|':
428 /* A shell special character. In theory, '$' and '`' could
429 be the first bytes of multibyte characters, which means
430 we should check them with mbrtowc, but in practice this
431 doesn't happen so it's not worth worrying about. */
432 if (quoting_style == shell_always_quoting_style
433 && elide_outer_quotes)
434 goto force_outer_quoting_style;
435 break;
436
437 case '\'':
438 if (quoting_style == shell_always_quoting_style)
439 {
440 if (elide_outer_quotes)
441 goto force_outer_quoting_style;
442 STORE ('\'');
443 STORE ('\\');
444 STORE ('\'');
445 }
446 break;
447
448 case '%': case '+': case ',': case '-': case '.': case '/':
449 case '0': case '1': case '2': case '3': case '4': case '5':
450 case '6': case '7': case '8': case '9': case ':':
451 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
452 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
453 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
454 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
455 case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
456 case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
457 case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
458 case 'o': case 'p': case 'q': case 'r': case 's': case 't':
459 case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
460 /* These characters don't cause problems, no matter what the
461 quoting style is. They cannot start multibyte sequences.
462 A digit or a special letter would cause trouble if it
463 appeared at the beginning of quote_string because we'd then
464 escape by prepending a backslash. However, it's hard to
465 imagine any locale that would use digits or letters as
466 quotes, and set_custom_quoting is documented not to accept
467 them. Also, a digit or a special letter would cause
468 trouble if it appeared in quote_these_too, but that's also
469 documented as not accepting them. */
470 break;
471
472 default:
473 /* If we have a multibyte sequence, copy it until we reach
474 its end, find an error, or come back to the initial shift
475 state. For C-like styles, if the sequence has
476 unprintable characters, escape the whole sequence, since
477 we can't easily escape single characters within it. */
478 {
479 /* Length of multibyte sequence found so far. */
480 size_t m;
481
482 bool printable;
483
484 if (unibyte_locale)
485 {
486 m = 1;
487 printable = isprint (c) != 0;
488 }
489 else
490 {
491 mbstate_t mbstate;
492 memset (&mbstate, 0, sizeof mbstate);
493
494 m = 0;
495 printable = true;
496 if (argsize == SIZE_MAX)
497 argsize = strlen (arg);
498
499 do
500 {
501 wchar_t w;
502 size_t bytes = mbrtowc (&w, &arg[i + m],
503 argsize - (i + m), &mbstate);
504 if (bytes == 0)
505 break;
506 else if (bytes == (size_t) -1)
507 {
508 printable = false;
509 break;
510 }
511 else if (bytes == (size_t) -2)
512 {
513 printable = false;
514 while (i + m < argsize && arg[i + m])
515 m++;
516 break;
517 }
518 else
519 {
520 /* Work around a bug with older shells that "see" a '\'
521 that is really the 2nd byte of a multibyte character.
522 In practice the problem is limited to ASCII
523 chars >= '@' that are shell special chars. */
524 if ('[' == 0x5b && elide_outer_quotes
525 && quoting_style == shell_always_quoting_style)
526 {
527 size_t j;
528 for (j = 1; j < bytes; j++)
529 switch (arg[i + m + j])
530 {
531 case '[': case '\\': case '^':
532 case '`': case '|':
533 goto force_outer_quoting_style;
534
535 default:
536 break;
537 }
538 }
539
540 if (! iswprint (w))
541 printable = false;
542 m += bytes;
543 }
544 }
545 while (! mbsinit (&mbstate));
546 }
547
548 if (1 < m || (backslash_escapes && ! printable))
549 {
550 /* Output a multibyte sequence, or an escaped
551 unprintable unibyte character. */
552 size_t ilim = i + m;
553
554 for (;;)
555 {
556 if (backslash_escapes && ! printable)
557 {
558 if (elide_outer_quotes)
559 goto force_outer_quoting_style;
560 STORE ('\\');
561 STORE ('0' + (c >> 6));
562 STORE ('0' + ((c >> 3) & 7));
563 c = '0' + (c & 7);
564 }
565 else if (is_right_quote)
566 {
567 STORE ('\\');
568 is_right_quote = false;
569 }
570 if (ilim <= i + 1)
571 break;
572 STORE (c);
573 c = arg[++i];
574 }
575
576 goto store_c;
577 }
578 }
579 }
580580
581581 if (! ((backslash_escapes || elide_outer_quotes)
582 && quote_these_too
583 && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))
584 && !is_right_quote)
585 goto store_c;
582 && quote_these_too
583 && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))
584 && !is_right_quote)
585 goto store_c;
586586
587587 store_escape:
588588 if (elide_outer_quotes)
589 goto force_outer_quoting_style;
589 goto force_outer_quoting_style;
590590 STORE ('\\');
591591
592592 store_c:
609609 /* Don't reuse quote_these_too, since the addition of outer quotes
610610 sufficiently quotes the specified characters. */
611611 return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
612 quoting_style,
613 flags & ~QA_ELIDE_OUTER_QUOTES, NULL,
614 left_quote, right_quote);
612 quoting_style,
613 flags & ~QA_ELIDE_OUTER_QUOTES, NULL,
614 left_quote, right_quote);
615615 }
616616
617617 /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
625625 ARGSIZE. */
626626 size_t
627627 quotearg_buffer (char *buffer, size_t buffersize,
628 char const *arg, size_t argsize,
629 struct quoting_options const *o)
628 char const *arg, size_t argsize,
629 struct quoting_options const *o)
630630 {
631631 struct quoting_options const *p = o ? o : &default_quoting_options;
632632 int e = errno;
633633 size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
634 p->style, p->flags, p->quote_these_too,
635 p->left_quote, p->right_quote);
634 p->style, p->flags, p->quote_these_too,
635 p->left_quote, p->right_quote);
636636 errno = e;
637637 return r;
638638 }
640640 /* Equivalent to quotearg_alloc (ARG, ARGSIZE, NULL, O). */
641641 char *
642642 quotearg_alloc (char const *arg, size_t argsize,
643 struct quoting_options const *o)
643 struct quoting_options const *o)
644644 {
645645 return quotearg_alloc_mem (arg, argsize, NULL, o);
646646 }
653653 flag. */
654654 char *
655655 quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size,
656 struct quoting_options const *o)
656 struct quoting_options const *o)
657657 {
658658 struct quoting_options const *p = o ? o : &default_quoting_options;
659659 int e = errno;
660660 /* Elide embedded null bytes if we can't return a size. */
661661 int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES);
662662 size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style,
663 flags, p->quote_these_too,
664 p->left_quote,
665 p->right_quote) + 1;
663 flags, p->quote_these_too,
664 p->left_quote,
665 p->right_quote) + 1;
666666 char *buf = xcharalloc (bufsize);
667667 quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags,
668 p->quote_these_too,
669 p->left_quote, p->right_quote);
668 p->quote_these_too,
669 p->left_quote, p->right_quote);
670670 errno = e;
671671 if (size)
672672 *size = bufsize - 1;
718718 to allow for future extensions (using negative values). */
719719 static char *
720720 quotearg_n_options (int n, char const *arg, size_t argsize,
721 struct quoting_options const *options)
721 struct quoting_options const *options)
722722 {
723723 int e = errno;
724724
731731 if (nslots <= n0)
732732 {
733733 /* FIXME: technically, the type of n1 should be `unsigned int',
734 but that evokes an unsuppressible warning from gcc-4.0.1 and
735 older. If gcc ever provides an option to suppress that warning,
736 revert to the original type, so that the test in xalloc_oversized
737 is once again performed only at compile time. */
734 but that evokes an unsuppressible warning from gcc-4.0.1 and
735 older. If gcc ever provides an option to suppress that warning,
736 revert to the original type, so that the test in xalloc_oversized
737 is once again performed only at compile time. */
738738 size_t n1 = n0 + 1;
739739 bool preallocated = (sv == &slotvec0);
740740
741741 if (xalloc_oversized (n1, sizeof *sv))
742 xalloc_die ();
742 xalloc_die ();
743743
744744 slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv);
745745 if (preallocated)
746 *sv = slotvec0;
746 *sv = slotvec0;
747747 memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv);
748748 nslots = n1;
749749 }
754754 /* Elide embedded null bytes since we don't return a size. */
755755 int flags = options->flags | QA_ELIDE_NULL_BYTES;
756756 size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize,
757 options->style, flags,
758 options->quote_these_too,
759 options->left_quote,
760 options->right_quote);
757 options->style, flags,
758 options->quote_these_too,
759 options->left_quote,
760 options->right_quote);
761761
762762 if (size <= qsize)
763763 {
764 sv[n].size = size = qsize + 1;
765 if (val != slot0)
766 free (val);
767 sv[n].val = val = xcharalloc (size);
768 quotearg_buffer_restyled (val, size, arg, argsize, options->style,
769 flags, options->quote_these_too,
770 options->left_quote,
771 options->right_quote);
764 sv[n].size = size = qsize + 1;
765 if (val != slot0)
766 free (val);
767 sv[n].val = val = xcharalloc (size);
768 quotearg_buffer_restyled (val, size, arg, argsize, options->style,
769 flags, options->quote_these_too,
770 options->left_quote,
771 options->right_quote);
772772 }
773773
774774 errno = e;
809809
810810 char *
811811 quotearg_n_style_mem (int n, enum quoting_style s,
812 char const *arg, size_t argsize)
812 char const *arg, size_t argsize)
813813 {
814814 struct quoting_options const o = quoting_options_from_style (s);
815815 return quotearg_n_options (n, arg, argsize, &o);
856856
857857 char *
858858 quotearg_n_custom (int n, char const *left_quote,
859 char const *right_quote, char const *arg)
859 char const *right_quote, char const *arg)
860860 {
861861 return quotearg_n_custom_mem (n, left_quote, right_quote, arg,
862 SIZE_MAX);
862 SIZE_MAX);
863863 }
864864
865865 char *
866866 quotearg_n_custom_mem (int n, char const *left_quote,
867 char const *right_quote,
868 char const *arg, size_t argsize)
867 char const *right_quote,
868 char const *arg, size_t argsize)
869869 {
870870 struct quoting_options o = default_quoting_options;
871871 set_custom_quoting (&o, left_quote, right_quote);
874874
875875 char *
876876 quotearg_custom (char const *left_quote, char const *right_quote,
877 char const *arg)
877 char const *arg)
878878 {
879879 return quotearg_n_custom (0, left_quote, right_quote, arg);
880880 }
881881
882882 char *
883883 quotearg_custom_mem (char const *left_quote, char const *right_quote,
884 char const *arg, size_t argsize)
884 char const *arg, size_t argsize)
885885 {
886886 return quotearg_n_custom_mem (0, left_quote, right_quote, arg,
887 argsize);
888 }
887 argsize);
888 }
00 /* quotearg.h - quote arguments for output
11
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 Free
3 Software Foundation, Inc.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008, 2009, 2010
3 Free Software Foundation, Inc.
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
275275 that has special meaning after a backslash (for example, "\t" for
276276 tab). */
277277 void set_custom_quoting (struct quoting_options *o,
278 char const *left_quote,
279 char const *right_quote);
278 char const *left_quote,
279 char const *right_quote);
280280
281281 /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
282282 argument ARG (of size ARGSIZE), using O to control quoting.
290290 not -1, the style of O does not use backslash escapes, and the
291291 flags of O do not request elision of null bytes.*/
292292 size_t quotearg_buffer (char *buffer, size_t buffersize,
293 char const *arg, size_t argsize,
294 struct quoting_options const *o);
293 char const *arg, size_t argsize,
294 struct quoting_options const *o);
295295
296296 /* Like quotearg_buffer, except return the result in a newly allocated
297297 buffer. It is the caller's responsibility to free the result. The
298298 result will not contain embedded null bytes. */
299299 char *quotearg_alloc (char const *arg, size_t argsize,
300 struct quoting_options const *o);
300 struct quoting_options const *o);
301301
302302 /* Like quotearg_alloc, except that the length of the result,
303303 excluding the terminating null byte, is stored into SIZE if it is
306306 backslash escapes, and the flags of O do not request elision of
307307 null bytes.*/
308308 char *quotearg_alloc_mem (char const *arg, size_t argsize,
309 size_t *size, struct quoting_options const *o);
309 size_t *size, struct quoting_options const *o);
310310
311311 /* Use storage slot N to return a quoted version of the string ARG.
312312 Use the default quoting options.
337337 argument ARG of size ARGSIZE. This is like quotearg_n_style
338338 (N, S, ARG), except it can quote null bytes. */
339339 char *quotearg_n_style_mem (int n, enum quoting_style s,
340 char const *arg, size_t argsize);
340 char const *arg, size_t argsize);
341341
342342 /* Equivalent to quotearg_n_style (0, S, ARG). */
343343 char *quotearg_style (enum quoting_style s, char const *arg);
344344
345345 /* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */
346346 char *quotearg_style_mem (enum quoting_style s,
347 char const *arg, size_t argsize);
347 char const *arg, size_t argsize);
348348
349349 /* Like quotearg (ARG), except also quote any instances of CH.
350350 See set_char_quoting for a description of acceptable CH values. */
364364 set_custom_quoting for a description of acceptable LEFT_QUOTE and
365365 RIGHT_QUOTE values. */
366366 char *quotearg_n_custom (int n, char const *left_quote,
367 char const *right_quote, char const *arg);
367 char const *right_quote, char const *arg);
368368
369369 /* Like quotearg_n_custom (N, LEFT_QUOTE, RIGHT_QUOTE, ARG) except it
370370 can quote null bytes. */
371371 char *quotearg_n_custom_mem (int n, char const *left_quote,
372 char const *right_quote,
373 char const *arg, size_t argsize);
372 char const *right_quote,
373 char const *arg, size_t argsize);
374374
375375 /* Equivalent to quotearg_n_custom (0, LEFT_QUOTE, RIGHT_QUOTE, ARG). */
376376 char *quotearg_custom (char const *left_quote, char const *right_quote,
377 char const *arg);
377 char const *arg);
378378
379379 /* Equivalent to quotearg_n_custom_mem (0, LEFT_QUOTE, RIGHT_QUOTE, ARG,
380 ARGSIZE). */
380 ARGSIZE). */
381381 char *quotearg_custom_mem (char const *left_quote,
382 char const *right_quote,
383 char const *arg, size_t argsize);
382 char const *right_quote,
383 char const *arg, size_t argsize);
384384
385385 /* Free any dynamically allocated memory. */
386386 void quotearg_free (void);
00 /* realloc() function that is glibc compatible.
11
2 Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
2 Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2010 Free Software
3 Foundation, Inc.
34
45 This program is free software: you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
7071 {
7172 #if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
7273 if (n == 0)
73 n = 1;
74 n = 1;
7475 #endif
7576 result = malloc (n);
7677 }
00 # Add this package to a list of references stored in a text file.
11 #
2 # Copyright (C) 2000 Free Software Foundation, Inc.
2 # Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc.
33 #
44 # This program is free software; you can redistribute it and/or modify
55 # it under the terms of the GNU General Public License as published by
00 # Remove this package from a list of references stored in a text file.
11 #
2 # Copyright (C) 2000 Free Software Foundation, Inc.
2 # Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc.
33 #
44 # This program is free software; you can redistribute it and/or modify
55 # it under the terms of the GNU General Public License as published by
0 /* Work around rmdir bugs.
1
2 Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2010 Free Software
3 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 #include <unistd.h>
21
22 #include <errno.h>
23 #include <string.h>
24 #include <sys/stat.h>
25 #include <sys/types.h>
26
27 #undef rmdir
28
29 /* Remove directory DIR.
30 Return 0 if successful, -1 if not. */
31
32 int
33 rpl_rmdir (char const *dir)
34 {
35 #if HAVE_RMDIR
36 /* Work around cygwin 1.5.x bug where rmdir("dir/./") succeeds. */
37 size_t len = strlen (dir);
38 int result;
39 while (len && ISSLASH (dir[len - 1]))
40 len--;
41 if (len && dir[len - 1] == '.' && (1 == len || ISSLASH (dir[len - 2])))
42 {
43 errno = EINVAL;
44 return -1;
45 }
46 result = rmdir (dir);
47 /* Work around mingw bug, where rmdir("file/") fails with EINVAL
48 instead of ENOTDIR. We've already filtered out trailing ., the
49 only reason allowed by POSIX for EINVAL. */
50 if (result == -1 && errno == EINVAL)
51 errno = ENOTDIR;
52 return result;
53
54 #else /* !HAVE_RMDIR */
55 /* rmdir adapted from GNU tar. FIXME: Delete this implementation in
56 2010 if no one reports a system with missing rmdir. */
57 pid_t cpid;
58 int status;
59 struct stat statbuf;
60
61 if (stat (dir, &statbuf) != 0)
62 return -1; /* errno already set */
63
64 if (!S_ISDIR (statbuf.st_mode))
65 {
66 errno = ENOTDIR;
67 return -1;
68 }
69
70 cpid = fork ();
71 switch (cpid)
72 {
73 case -1: /* cannot fork */
74 return -1; /* errno already set */
75
76 case 0: /* child process */
77 execl ("/bin/rmdir", "rmdir", dir, (char *) 0);
78 _exit (1);
79
80 default: /* parent process */
81
82 /* Wait for kid to finish. */
83
84 while (wait (&status) != cpid)
85 /* Do nothing. */ ;
86
87 if (status)
88 {
89
90 /* /bin/rmdir failed. */
91
92 errno = EIO;
93 return -1;
94 }
95 return 0;
96 }
97 #endif /* !HAVE_RMDIR */
98 }
0 /* Determine whether two stat buffers refer to the same file.
1
2 Copyright (C) 2006, 2009-2010 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 #ifndef SAME_INODE_H
18 # define SAME_INODE_H 1
19
20 # define SAME_INODE(Stat_buf_1, Stat_buf_2) \
21 ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
22 && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
23
24 #endif
0 /* save-cwd.c -- Save and restore current working directory.
1
2 Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2010 Free Software
3 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 /* Written by Jim Meyering. */
19
20 #include <config.h>
21
22 #include "save-cwd.h"
23
24 #include <errno.h>
25 #include <fcntl.h>
26 #include <stdbool.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29
30 #include "chdir-long.h"
31 #include "unistd--.h"
32 #include "xgetcwd.h"
33
34 #if GNULIB_FCNTL_SAFER
35 # include "fcntl--.h"
36 #else
37 # define GNULIB_FCNTL_SAFER 0
38 #endif
39
40 /* On systems without the fchdir function (WOE), pretend that open
41 always returns -1 so that save_cwd resorts to using xgetcwd.
42 Since chdir_long requires fchdir, use chdir instead. */
43 #if !HAVE_FCHDIR
44 # undef open
45 # define open(File, Flags) (-1)
46 # undef fchdir
47 # define fchdir(Fd) (abort (), -1)
48 # undef chdir_long
49 # define chdir_long(Dir) chdir (Dir)
50 #endif
51
52 /* Record the location of the current working directory in CWD so that
53 the program may change to other directories and later use restore_cwd
54 to return to the recorded location. This function may allocate
55 space using malloc (via xgetcwd) or leave a file descriptor open;
56 use free_cwd to perform the necessary free or close. Upon failure,
57 no memory is allocated, any locally opened file descriptors are
58 closed; return non-zero -- in that case, free_cwd need not be
59 called, but doing so is ok. Otherwise, return zero.
60
61 The `raison d'etre' for this interface is that the working directory
62 is sometimes inaccessible, and getcwd is not robust or as efficient.
63 So, we prefer to use the open/fchdir approach, but fall back on
64 getcwd if necessary.
65
66 Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
67 SCO Xenix. Also, SunOS 4 and Irix 5.3 provide the function, yet it
68 doesn't work for partitions on which auditing is enabled. If
69 you're still using an obsolete system with these problems, please
70 send email to the maintainer of this code. */
71
72 int
73 save_cwd (struct saved_cwd *cwd)
74 {
75 cwd->name = NULL;
76
77 cwd->desc = open (".", O_RDONLY);
78 if (!GNULIB_FCNTL_SAFER)
79 cwd->desc = fd_safer (cwd->desc);
80 if (cwd->desc < 0)
81 {
82 cwd->name = xgetcwd ();
83 return cwd->name ? 0 : -1;
84 }
85
86 return 0;
87 }
88
89 /* Change to recorded location, CWD, in directory hierarchy.
90 Upon failure, return -1 (errno is set by chdir or fchdir).
91 Upon success, return zero. */
92
93 int
94 restore_cwd (const struct saved_cwd *cwd)
95 {
96 if (0 <= cwd->desc)
97 return fchdir (cwd->desc);
98 else
99 return chdir_long (cwd->name);
100 }
101
102 void
103 free_cwd (struct saved_cwd *cwd)
104 {
105 if (cwd->desc >= 0)
106 close (cwd->desc);
107 free (cwd->name);
108 }
0 /* Save and restore current working directory.
1
2 Copyright (C) 1995, 1997-1998, 2003, 2009-2010 Free Software Foundation,
3 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 /* Written by Jim Meyering. */
19
20 #ifndef SAVE_CWD_H
21 # define SAVE_CWD_H 1
22
23 struct saved_cwd
24 {
25 int desc;
26 char *name;
27 };
28
29 int save_cwd (struct saved_cwd *cwd);
30 int restore_cwd (const struct saved_cwd *cwd);
31 void free_cwd (struct saved_cwd *cwd);
32
33 #endif /* SAVE_CWD_H */
00 /* signbit() macro: Determine the sign bit of a floating-point number.
1 Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* signbit() macro: Determine the sign bit of a floating-point number.
1 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* signbit() macro: Determine the sign bit of a floating-point number.
1 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* size_max.h -- declare SIZE_MAX through system headers
3 Copyright (C) 2005-2006 Free Software Foundation, Inc.
3 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
44 Written by Simon Josefsson.
55
66 This program is free software; you can redistribute it and/or modify
00 /* stat-related time functions.
11
2 Copyright (C) 2005, 2007 Free Software Foundation, Inc.
2 Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
00 /* Work around platform bugs in stat.
1 Copyright (C) 2009 Free Software Foundation, Inc.
1 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
5454 {
5555 size_t len = strlen (name);
5656 if (ISSLASH (name[len - 1]))
57 {
58 errno = ENOTDIR;
59 return -1;
60 }
57 {
58 errno = ENOTDIR;
59 return -1;
60 }
6161 }
6262 #endif /* REPLACE_FUNC_STAT_FILE */
6363 #if REPLACE_FUNC_STAT_DIR
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
2 /* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc.
33 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
44
55 This program is free software; you can redistribute it and/or modify
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
33
4 Copyright (C) 2009 Free Software Foundation, Inc.
4 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc.
2 /* Copyright (C) 2001-2002, 2004-2010 Free Software Foundation, Inc.
33 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
44 This file is part of gnulib.
55
103103 ((signed) \
104104 ? ~ _STDINT_MIN (signed, bits, zero) \
105105 : /* The expression for the unsigned case. The subtraction of (signed) \
106 is a nop in the unsigned case and avoids "signed integer overflow" \
107 warnings in the signed case. */ \
106 is a nop in the unsigned case and avoids "signed integer overflow" \
107 warnings in the signed case. */ \
108108 ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
109109
110110 /* 7.18.1.1. Exact-width integer types */
455455 #undef SIG_ATOMIC_MAX
456456 #define SIG_ATOMIC_MIN \
457457 _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
458 0@SIG_ATOMIC_T_SUFFIX@)
458 0@SIG_ATOMIC_T_SUFFIX@)
459459 #define SIG_ATOMIC_MAX \
460460 _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
461 0@SIG_ATOMIC_T_SUFFIX@)
461 0@SIG_ATOMIC_T_SUFFIX@)
462462
463463
464464 /* size_t limit */
00 /* Implementation details of FILE streams.
1 Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 Copyright (C) 2007-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
2525 # if defined __DragonFly__ /* DragonFly */
2626 /* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
2727 # define fp_ ((struct { struct __FILE_public pub; \
28 struct { unsigned char *_base; int _size; } _bf; \
29 void *cookie; \
30 void *_close; \
31 void *_read; \
32 void *_seek; \
33 void *_write; \
34 struct { unsigned char *_base; int _size; } _ub; \
35 int _ur; \
36 unsigned char _ubuf[3]; \
37 unsigned char _nbuf[1]; \
38 struct { unsigned char *_base; int _size; } _lb; \
39 int _blksize; \
40 fpos_t _offset; \
41 /* More fields, not relevant here. */ \
42 } *) fp)
28 struct { unsigned char *_base; int _size; } _bf; \
29 void *cookie; \
30 void *_close; \
31 void *_read; \
32 void *_seek; \
33 void *_write; \
34 struct { unsigned char *_base; int _size; } _ub; \
35 int _ur; \
36 unsigned char _ubuf[3]; \
37 unsigned char _nbuf[1]; \
38 struct { unsigned char *_base; int _size; } _lb; \
39 int _blksize; \
40 fpos_t _offset; \
41 /* More fields, not relevant here. */ \
42 } *) fp)
4343 /* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
4444 # define _p pub._p
4545 # define _flags pub._flags
7373
7474 # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
7575 # define fp_ ((struct { unsigned char *_ptr; \
76 unsigned char *_base; \
77 unsigned char *_end; \
78 long _cnt; \
79 int _file; \
80 unsigned int _flag; \
81 } *) fp)
76 unsigned char *_base; \
77 unsigned char *_end; \
78 long _cnt; \
79 int _file; \
80 unsigned int _flag; \
81 } *) fp)
8282 # else
8383 # define fp_ fp
8484 # endif
00 /* POSIX compatible FILE stream write function.
1 Copyright (C) 2008-2009 Free Software Foundation, Inc.
1 Copyright (C) 2008-2010 Free Software Foundation, Inc.
22 Written by Bruno Haible <bruno@clisp.org>, 2008.
33
44 This program is free software: you can redistribute it and/or modify
3838 # include <windows.h>
3939
4040 # define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
41 if (ferror (stream)) \
42 return (EXPRESSION); \
43 else \
44 { \
45 RETTYPE ret; \
46 SetLastError (0); \
47 ret = (EXPRESSION); \
41 if (ferror (stream)) \
42 return (EXPRESSION); \
43 else \
44 { \
45 RETTYPE ret; \
46 SetLastError (0); \
47 ret = (EXPRESSION); \
4848 if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \
49 { \
50 int fd = fileno (stream); \
51 if (fd >= 0 \
52 && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
53 { \
54 /* Try to raise signal SIGPIPE. */ \
55 raise (SIGPIPE); \
56 /* If it is currently blocked or ignored, change errno from \
57 EINVAL to EPIPE. */ \
58 errno = EPIPE; \
59 } \
60 } \
61 return ret; \
49 { \
50 int fd = fileno (stream); \
51 if (fd >= 0 \
52 && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
53 { \
54 /* Try to raise signal SIGPIPE. */ \
55 raise (SIGPIPE); \
56 /* If it is currently blocked or ignored, change errno from \
57 EINVAL to EPIPE. */ \
58 errno = EPIPE; \
59 } \
60 } \
61 return ret; \
6262 }
6363
6464 # if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A GNU-like <stdio.h>.
33
4 Copyright (C) 2004, 2007-2009 Free Software Foundation, Inc.
4 Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
3737 #ifndef _GL_STDIO_H
3838 #define _GL_STDIO_H
3939
40 /* Get va_list. Needed on many systems, including glibc 2.8. */
4041 #include <stdarg.h>
42
4143 #include <stddef.h>
4244
43 #if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
44 || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
45 || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
46 || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
47 /* Get off_t and ssize_t. */
48 # include <sys/types.h>
49 #endif
45 /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */
46 #include <sys/types.h>
5047
5148 #ifndef __attribute__
52 /* This feature is available in gcc versions 2.5 and later. */
53 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
54 # define __attribute__(Spec) /* empty */
55 # endif
56 /* The __-protected variants of `format' and `printf' attributes
57 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
49 /* The __attribute__ feature is available in gcc versions 2.5 and later.
50 The __-protected variants of the attributes 'format' and 'printf' are
51 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
52 We enable __attribute__ only if these are supported too, because
53 gnulib and libintl do '#define printf __printf__' when they override
54 the 'printf' function. */
5855 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
59 # define __format__ format
60 # define __printf__ printf
56 # define __attribute__(Spec) /* empty */
6157 # endif
6258 #endif
6359
6460
6561 /* The definition of GL_LINK_WARNING is copied here. */
62
63 /* The definition of _GL_ARG_NONNULL is copied here. */
64
65 /* The definition of _GL_WARN_ON_USE is copied here. */
6666
6767
6868 #ifdef __cplusplus
7575 # endif
7676 # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
7777 extern int dprintf (int fd, const char *format, ...)
78 __attribute__ ((__format__ (__printf__, 2, 3)));
78 __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
7979 # endif
8080 #elif defined GNULIB_POSIXCHECK
8181 # undef dprintf
82 # define dprintf(d,f,a) \
82 # define dprintf \
8383 (GL_LINK_WARNING ("dprintf is unportable - " \
8484 "use gnulib module dprintf for portability"), \
85 dprintf (d, f, a))
85 dprintf)
8686 #endif
8787
8888 #if @GNULIB_FCLOSE@
8989 # if @REPLACE_FCLOSE@
9090 # define fclose rpl_fclose
9191 /* Close STREAM and its underlying file descriptor. */
92 extern int fclose (FILE *stream);
92 extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
9393 # endif
9494 #elif defined GNULIB_POSIXCHECK
9595 # undef fclose
120120 fflush (f))
121121 #endif
122122
123 /* It is very rare that the developer ever has full control of stdin,
124 so any use of gets warrants an unconditional warning. Assume it is
125 always declared, since it is required by C89. */
126 #undef gets
127 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
128
123129 #if @GNULIB_FOPEN@
124130 # if @REPLACE_FOPEN@
125131 # undef fopen
126132 # define fopen rpl_fopen
127 extern FILE * fopen (const char *filename, const char *mode);
133 extern FILE * fopen (const char *filename, const char *mode)
134 _GL_ARG_NONNULL ((1, 2));
128135 # endif
129136 #elif defined GNULIB_POSIXCHECK
130137 # undef fopen
138145 # if @REPLACE_FPRINTF@
139146 # define fprintf rpl_fprintf
140147 extern int fprintf (FILE *fp, const char *format, ...)
141 __attribute__ ((__format__ (__printf__, 2, 3)));
148 __attribute__ ((__format__ (__printf__, 2, 3)))
149 _GL_ARG_NONNULL ((1, 2));
142150 # endif
143151 #elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
144152 # define fprintf rpl_fprintf
145153 extern int fprintf (FILE *fp, const char *format, ...)
146 __attribute__ ((__format__ (__printf__, 2, 3)));
154 __attribute__ ((__format__ (__printf__, 2, 3)))
155 _GL_ARG_NONNULL ((1, 2));
147156 #elif defined GNULIB_POSIXCHECK
148157 # undef fprintf
149158 # define fprintf \
164173 was before the write calls. When discarding pending input, the file
165174 position is advanced to match the end of the previously read input.
166175 Return 0 if successful. Upon error, return -1 and set errno. */
167 extern int fpurge (FILE *gl_stream);
176 extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
168177 # endif
169178 #elif defined GNULIB_POSIXCHECK
170179 # undef fpurge
177186 #if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
178187 # undef fputc
179188 # define fputc rpl_fputc
180 extern int fputc (int c, FILE *stream);
189 extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
181190 #endif
182191
183192 #if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
184193 # undef fputs
185194 # define fputs rpl_fputs
186 extern int fputs (const char *string, FILE *stream);
195 extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
187196 #endif
188197
189198 #if @GNULIB_FREOPEN@
190199 # if @REPLACE_FREOPEN@
191200 # undef freopen
192201 # define freopen rpl_freopen
193 extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
202 extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
203 _GL_ARG_NONNULL ((2, 3));
194204 # endif
195205 #elif defined GNULIB_POSIXCHECK
196206 # undef freopen
200210 freopen (f, m, s))
201211 #endif
202212
203 #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
204 extern int rpl_fseek (FILE *fp, long offset, int whence);
205 # undef fseek
206 # if defined GNULIB_POSIXCHECK
207 # define fseek(f,o,w) \
208 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
209 "on 32-bit platforms - " \
210 "use fseeko function for handling of large files"), \
211 rpl_fseek (f, o, w))
212 # else
213 /* Set up the following warnings, based on which modules are in use.
214 GNU Coding Standards discourage the use of fseek, since it imposes
215 an arbitrary limitation on some 32-bit hosts. Remember that the
216 fseek module depends on the fseeko module, so we only have three
217 cases to consider:
218
219 1. The developer is not using either module. Issue a warning under
220 GNULIB_POSIXCHECK for both functions, to remind them that both
221 functions have bugs on some systems. _GL_NO_LARGE_FILES has no
222 impact on this warning.
223
224 2. The developer is using both modules. They may be unaware of the
225 arbitrary limitations of fseek, so issue a warning under
226 GNULIB_POSIXCHECK. On the other hand, they may be using both
227 modules intentionally, so the developer can define
228 _GL_NO_LARGE_FILES in the compilation units where the use of fseek
229 is safe, to silence the warning.
230
231 3. The developer is using the fseeko module, but not fseek. Gnulib
232 guarantees that fseek will still work around platform bugs in that
233 case, but we presume that the developer is aware of the pitfalls of
234 fseek and was trying to avoid it, so issue a warning even when
235 GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be
236 defined to silence the warning in particular compilation units.
237
238 Most gnulib clients that perform stream operations should fall into
239 category three. */
240
241 #if @GNULIB_FSEEK@
242 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
243 # define _GL_FSEEK_WARN /* Category 2, above. */
244 # undef fseek
245 # endif
246 # if @REPLACE_FSEEK@
247 # undef fseek
213248 # define fseek rpl_fseek
214 # endif
215 #elif defined GNULIB_POSIXCHECK
216 # ifndef fseek
217 # define fseek(f,o,w) \
218 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
219 "on 32-bit platforms - " \
220 "use fseeko function for handling of large files"), \
221 fseek (f, o, w))
249 extern int fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
222250 # endif
223251 #endif
224252
225253 #if @GNULIB_FSEEKO@
254 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
255 # define _GL_FSEEK_WARN /* Category 3, above. */
256 # undef fseek
257 # endif
226258 # if @REPLACE_FSEEKO@
227259 /* Provide fseek, fseeko functions that are aware of a preceding
228260 fflush(), and which detect pipes. */
261 # undef fseeko
229262 # define fseeko rpl_fseeko
230 extern int fseeko (FILE *fp, off_t offset, int whence);
263 extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
231264 # if !@GNULIB_FSEEK@
232265 # undef fseek
233 # define fseek(f,o,w) \
234 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
235 "on 32-bit platforms - " \
236 "use fseeko function for handling of large files"), \
237 fseeko (f, o, w))
266 # define fseek rpl_fseek
267 static inline int _GL_ARG_NONNULL ((1))
268 rpl_fseek (FILE *fp, long offset, int whence)
269 {
270 return fseeko (fp, offset, whence);
271 }
238272 # endif
239273 # endif
240274 #elif defined GNULIB_POSIXCHECK
275 # define _GL_FSEEK_WARN /* Category 1, above. */
276 # undef fseek
241277 # undef fseeko
242 # define fseeko(f,o,w) \
243 (GL_LINK_WARNING ("fseeko is unportable - " \
244 "use gnulib module fseeko for portability"), \
245 fseeko (f, o, w))
246 #endif
247
248 #if @GNULIB_FTELL@ && @REPLACE_FTELL@
249 extern long rpl_ftell (FILE *fp);
250 # undef ftell
251 # if GNULIB_POSIXCHECK
252 # define ftell(f) \
253 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
254 "on 32-bit platforms - " \
255 "use ftello function for handling of large files"), \
256 rpl_ftell (f))
257 # else
278 # if HAVE_RAW_DECL_FSEEKO
279 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
280 "use gnulib module fseeko for portability");
281 # endif
282 #endif
283
284 #ifdef _GL_FSEEK_WARN
285 # undef _GL_FSEEK_WARN
286 /* Here, either fseek is undefined (but C89 guarantees that it is
287 declared), or it is defined as rpl_fseek (declared above). */
288 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
289 "on 32-bit platforms - "
290 "use fseeko function for handling of large files");
291 #endif
292
293 /* See the comments on fseek/fseeko. */
294
295 #if @GNULIB_FTELL@
296 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
297 # define _GL_FTELL_WARN /* Category 2, above. */
298 # undef ftell
299 # endif
300 # if @REPLACE_FTELL@
301 # undef ftell
258302 # define ftell rpl_ftell
259 # endif
260 #elif defined GNULIB_POSIXCHECK
261 # ifndef ftell
262 # define ftell(f) \
263 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
264 "on 32-bit platforms - " \
265 "use ftello function for handling of large files"), \
266 ftell (f))
303 extern long ftell (FILE *fp) _GL_ARG_NONNULL ((1));
267304 # endif
268305 #endif
269306
270307 #if @GNULIB_FTELLO@
308 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
309 # define _GL_FTELL_WARN /* Category 3, above. */
310 # undef ftell
311 # endif
271312 # if @REPLACE_FTELLO@
313 # undef ftello
272314 # define ftello rpl_ftello
273 extern off_t ftello (FILE *fp);
315 extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
274316 # if !@GNULIB_FTELL@
275317 # undef ftell
276 # define ftell(f) \
277 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
278 "on 32-bit platforms - " \
279 "use ftello function for handling of large files"), \
280 ftello (f))
318 # define ftell rpl_ftell
319 static inline long _GL_ARG_NONNULL ((1))
320 rpl_ftell (FILE *f)
321 {
322 return ftello (f);
323 }
281324 # endif
282325 # endif
283326 #elif defined GNULIB_POSIXCHECK
327 # define _GL_FTELL_WARN /* Category 1, above. */
328 # undef ftell
284329 # undef ftello
285 # define ftello(f) \
286 (GL_LINK_WARNING ("ftello is unportable - " \
287 "use gnulib module ftello for portability"), \
288 ftello (f))
330 # if HAVE_RAW_DECL_FTELLO
331 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
332 "use gnulib module ftello for portability");
333 # endif
334 #endif
335
336 #ifdef _GL_FTELL_WARN
337 # undef _GL_FTELL_WARN
338 /* Here, either ftell is undefined (but C89 guarantees that it is
339 declared), or it is defined as rpl_ftell (declared above). */
340 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
341 "on 32-bit platforms - "
342 "use ftello function for handling of large files");
289343 #endif
290344
291345 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
292346 # undef fwrite
293347 # define fwrite rpl_fwrite
294 extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
348 extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
349 _GL_ARG_NONNULL ((1, 4));
295350 #endif
296351
297352 #if @GNULIB_GETDELIM@
303358 Return the number of bytes read and stored at *LINEPTR (not including the
304359 NUL terminator), or -1 on error or EOF. */
305360 extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
306 FILE *stream);
361 FILE *stream)
362 _GL_ARG_NONNULL ((1, 2, 4));
307363 # endif
308364 #elif defined GNULIB_POSIXCHECK
309365 # undef getdelim
310 # define getdelim(l, s, d, f) \
311 (GL_LINK_WARNING ("getdelim is unportable - " \
312 "use gnulib module getdelim for portability"), \
366 # define getdelim(l, s, d, f) \
367 (GL_LINK_WARNING ("getdelim is unportable - " \
368 "use gnulib module getdelim for portability"), \
313369 getdelim (l, s, d, f))
314370 #endif
315371
325381 bytes of space. It is realloc'd as necessary.
326382 Return the number of bytes read and stored at *LINEPTR (not including the
327383 NUL terminator), or -1 on error or EOF. */
328 extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
384 extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
385 _GL_ARG_NONNULL ((1, 2, 3));
329386 # endif
330387 #elif defined GNULIB_POSIXCHECK
331388 # undef getline
332 # define getline(l, s, f) \
333 (GL_LINK_WARNING ("getline is unportable - " \
334 "use gnulib module getline for portability"), \
389 # define getline(l, s, f) \
390 (GL_LINK_WARNING ("getline is unportable - " \
391 "use gnulib module getline for portability"), \
335392 getline (l, s, f))
336393 #endif
337394
348405 memory allocation error, call obstack_alloc_failed_handler. Upon
349406 other error, return -1. */
350407 extern int obstack_printf (struct obstack *obs, const char *format, ...)
351 __attribute__ ((__format__ (__printf__, 2, 3)));
408 __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
352409 extern int obstack_vprintf (struct obstack *obs, const char *format,
353 va_list args)
354 __attribute__ ((__format__ (__printf__, 2, 0)));
410 va_list args)
411 __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
355412 # endif
356413 #endif
357414
375432 # if @REPLACE_POPEN@
376433 # undef popen
377434 # define popen rpl_popen
378 extern FILE *popen (const char *cmd, const char *mode);
435 extern FILE *popen (const char *cmd, const char *mode)
436 _GL_ARG_NONNULL ((1, 2));
379437 # endif
380438 #elif defined GNULIB_POSIXCHECK
381439 # undef popen
390448 /* Don't break __attribute__((format(printf,M,N))). */
391449 # define printf __printf__
392450 extern int printf (const char *format, ...)
393 __attribute__ ((__format__ (__printf__, 1, 2)));
451 __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
394452 # endif
395453 #elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
396454 /* Don't break __attribute__((format(printf,M,N))). */
397455 # define printf __printf__
398456 extern int printf (const char *format, ...)
399 __attribute__ ((__format__ (__printf__, 1, 2)));
457 __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
400458 #elif defined GNULIB_POSIXCHECK
401459 # undef printf
402460 # define printf \
416474 #if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
417475 # undef putc
418476 # define putc rpl_fputc
419 extern int putc (int c, FILE *stream);
477 extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
420478 #endif
421479
422480 #if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
428486 #if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
429487 # undef puts
430488 # define puts rpl_puts
431 extern int puts (const char *string);
489 extern int puts (const char *string) _GL_ARG_NONNULL ((1));
432490 #endif
433491
434492 #if @GNULIB_REMOVE@
435493 # if @REPLACE_REMOVE@
436494 # undef remove
437495 # define remove rpl_remove
438 extern int remove (const char *name);
496 extern int remove (const char *name) _GL_ARG_NONNULL ((1));
439497 # endif
440498 #elif defined GNULIB_POSIXCHECK
441499 # undef remove
442 # define remove(n) \
500 # define remove(n) \
443501 (GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \
444502 "use gnulib module remove for more portability"), \
445503 remove (n))
449507 # if @REPLACE_RENAME@
450508 # undef rename
451509 # define rename rpl_rename
452 extern int rename (const char *old, const char *new);
510 extern int rename (const char *old_filename, const char *new_filename)
511 _GL_ARG_NONNULL ((1, 2));
453512 # endif
454513 #elif defined GNULIB_POSIXCHECK
455514 # undef rename
456 # define rename(o,n) \
515 # define rename(o,n) \
457516 (GL_LINK_WARNING ("rename is buggy on some platforms - " \
458517 "use gnulib module rename for more portability"), \
459518 rename (o, n))
465524 # define renameat rpl_renameat
466525 # endif
467526 # if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
468 extern int renameat (int fd1, char const *file1, int fd2, char const *file2);
527 extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
528 _GL_ARG_NONNULL ((2, 4));
469529 # endif
470530 #elif defined GNULIB_POSIXCHECK
471531 # undef renameat
472 # define renameat(d1,f1,d2,f2) \
532 # define renameat(d1,f1,d2,f2) \
473533 (GL_LINK_WARNING ("renameat is not portable - " \
474534 "use gnulib module renameat for portability"), \
475535 renameat (d1, f1, d2, f2))
481541 # endif
482542 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
483543 extern int snprintf (char *str, size_t size, const char *format, ...)
484 __attribute__ ((__format__ (__printf__, 3, 4)));
544 __attribute__ ((__format__ (__printf__, 3, 4)))
545 _GL_ARG_NONNULL ((3));
485546 # endif
486547 #elif defined GNULIB_POSIXCHECK
487548 # undef snprintf
491552 snprintf)
492553 #endif
493554
555 /* Some people would argue that sprintf should be handled like gets
556 (for example, OpenBSD issues a link warning for both functions),
557 since both can cause security holes due to buffer overruns.
558 However, we believe that sprintf can be used safely, and is more
559 efficient than snprintf in those safe cases; and as proof of our
560 belief, we use sprintf in several gnulib modules. So this header
561 intentionally avoids adding a warning to sprintf except when
562 GNULIB_POSIXCHECK is defined. */
563
494564 #if @GNULIB_SPRINTF_POSIX@
495565 # if @REPLACE_SPRINTF@
496566 # define sprintf rpl_sprintf
497567 extern int sprintf (char *str, const char *format, ...)
498 __attribute__ ((__format__ (__printf__, 2, 3)));
568 __attribute__ ((__format__ (__printf__, 2, 3)))
569 _GL_ARG_NONNULL ((1, 2));
499570 # endif
500571 #elif defined GNULIB_POSIXCHECK
501572 # undef sprintf
517588 *RESULT and return the number of resulting bytes, excluding the trailing
518589 NUL. Upon memory allocation error, or some other error, return -1. */
519590 extern int asprintf (char **result, const char *format, ...)
520 __attribute__ ((__format__ (__printf__, 2, 3)));
591 __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
521592 extern int vasprintf (char **result, const char *format, va_list args)
522 __attribute__ ((__format__ (__printf__, 2, 0)));
593 __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
523594 # endif
524595 #endif
525596
529600 # endif
530601 # if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
531602 extern int vdprintf (int fd, const char *format, va_list args)
532 __attribute__ ((__format__ (__printf__, 2, 0)));
603 __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
533604 # endif
534605 #elif defined GNULIB_POSIXCHECK
535606 # undef vdprintf
543614 # if @REPLACE_VFPRINTF@
544615 # define vfprintf rpl_vfprintf
545616 extern int vfprintf (FILE *fp, const char *format, va_list args)
546 __attribute__ ((__format__ (__printf__, 2, 0)));
617 __attribute__ ((__format__ (__printf__, 2, 0)))
618 _GL_ARG_NONNULL ((1, 2));
547619 # endif
548620 #elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
549621 # define vfprintf rpl_vfprintf
550622 extern int vfprintf (FILE *fp, const char *format, va_list args)
551 __attribute__ ((__format__ (__printf__, 2, 0)));
623 __attribute__ ((__format__ (__printf__, 2, 0)))
624 _GL_ARG_NONNULL ((1, 2));
552625 #elif defined GNULIB_POSIXCHECK
553626 # undef vfprintf
554627 # define vfprintf(s,f,a) \
562635 # if @REPLACE_VPRINTF@
563636 # define vprintf rpl_vprintf
564637 extern int vprintf (const char *format, va_list args)
565 __attribute__ ((__format__ (__printf__, 1, 0)));
638 __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
566639 # endif
567640 #elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
568641 # define vprintf rpl_vprintf
569642 extern int vprintf (const char *format, va_list args)
570 __attribute__ ((__format__ (__printf__, 1, 0)));
643 __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
571644 #elif defined GNULIB_POSIXCHECK
572645 # undef vprintf
573646 # define vprintf(f,a) \
583656 # endif
584657 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
585658 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
586 __attribute__ ((__format__ (__printf__, 3, 0)));
659 __attribute__ ((__format__ (__printf__, 3, 0)))
660 _GL_ARG_NONNULL ((3));
587661 # endif
588662 #elif defined GNULIB_POSIXCHECK
589663 # undef vsnprintf
597671 # if @REPLACE_VSPRINTF@
598672 # define vsprintf rpl_vsprintf
599673 extern int vsprintf (char *str, const char *format, va_list args)
600 __attribute__ ((__format__ (__printf__, 2, 0)));
674 __attribute__ ((__format__ (__printf__, 2, 0)))
675 _GL_ARG_NONNULL ((1, 2));
601676 # endif
602677 #elif defined GNULIB_POSIXCHECK
603678 # undef vsprintf
00 /* A GNU-like <stdlib.h>.
11
2 Copyright (C) 1995, 2001-2004, 2006-2009 Free Software Foundation, Inc.
2 Copyright (C) 1995, 2001-2004, 2006-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
3838 #include <stddef.h>
3939
4040 /* Solaris declares getloadavg() in <sys/loadavg.h>. */
41 #if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
41 #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
4242 # include <sys/loadavg.h>
4343 #endif
4444
4848 # include <random.h>
4949 #endif
5050
51 #if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
51 #if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \
52 || defined GNULIB_POSIXCHECK
5253 # include <stdint.h>
5354 #endif
5455
5556 #if !@HAVE_STRUCT_RANDOM_DATA@
5657 struct random_data
5758 {
58 int32_t *fptr; /* Front pointer. */
59 int32_t *rptr; /* Rear pointer. */
60 int32_t *state; /* Array of state values. */
61 int rand_type; /* Type of random number generator. */
62 int rand_deg; /* Degree of random number generator. */
63 int rand_sep; /* Distance between front and rear. */
64 int32_t *end_ptr; /* Pointer behind state table. */
59 int32_t *fptr; /* Front pointer. */
60 int32_t *rptr; /* Rear pointer. */
61 int32_t *state; /* Array of state values. */
62 int rand_type; /* Type of random number generator. */
63 int rand_deg; /* Degree of random number generator. */
64 int rand_sep; /* Distance between front and rear. */
65 int32_t *end_ptr; /* Pointer behind state table. */
6566 };
6667 #endif
6768
69 #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
70 /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
71 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
72 /* But avoid namespace pollution on glibc systems. */
73 # include <unistd.h>
74 #endif
75
6876 /* The definition of GL_LINK_WARNING is copied here. */
77
78 /* The definition of _GL_ARG_NONNULL is copied here. */
6979
7080
7181 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
90100 # if !@HAVE_ATOLL@
91101 /* Parse a signed decimal integer.
92102 Returns the value of the integer. Errors are not detected. */
93 extern long long atoll (const char *string);
103 extern long long atoll (const char *string) _GL_ARG_NONNULL ((1));
94104 # endif
95105 #elif defined GNULIB_POSIXCHECK
96106 # undef atoll
119129 # define canonicalize_file_name rpl_canonicalize_file_name
120130 # endif
121131 # if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@
122 extern char *canonicalize_file_name (const char *name);
132 extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1));
123133 # endif
124134 #elif defined GNULIB_POSIXCHECK
125135 # undef canonicalize_file_name
135145 The three numbers are the load average of the last 1 minute, the last 5
136146 minutes, and the last 15 minutes, respectively.
137147 LOADAVG is an array of NELEM numbers. */
138 extern int getloadavg (double loadavg[], int nelem);
148 extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1));
139149 # endif
140150 #elif defined GNULIB_POSIXCHECK
141151 # undef getloadavg
158168 For more details see the POSIX:2001 specification.
159169 http://www.opengroup.org/susv3xsh/getsubopt.html */
160170 # if !@HAVE_GETSUBOPT@
161 extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
171 extern int getsubopt (char **optionp, char *const *tokens, char **valuep)
172 _GL_ARG_NONNULL ((1, 2, 3));
162173 # endif
163174 #elif defined GNULIB_POSIXCHECK
164175 # undef getsubopt
189200 they are replaced with a string that makes the directory name unique.
190201 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
191202 The directory is created mode 700. */
192 extern char * mkdtemp (char * /*template*/);
203 extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
193204 # endif
194205 #elif defined GNULIB_POSIXCHECK
195206 # undef mkdtemp
213224 implementation.
214225 Returns the open file descriptor if successful, otherwise -1 and errno
215226 set. */
216 extern int mkostemp (char * /*template*/, int /*flags*/);
227 extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
217228 # endif
218229 #elif defined GNULIB_POSIXCHECK
219230 # undef mkostemp
221232 (GL_LINK_WARNING ("mkostemp is unportable - " \
222233 "use gnulib module mkostemp for portability"), \
223234 mkostemp (t, f))
235 #endif
236
237 #if @GNULIB_MKOSTEMPS@
238 # if !@HAVE_MKOSTEMPS@
239 /* Create a unique temporary file from TEMPLATE.
240 The last six characters of TEMPLATE before a suffix of length
241 SUFFIXLEN must be "XXXXXX";
242 they are replaced with a string that makes the file name unique.
243 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
244 and O_TEXT, O_BINARY (defined in "binary-io.h").
245 The file is then created, with the specified flags, ensuring it didn't exist
246 before.
247 The file is created read-write (mask at least 0600 & ~umask), but it may be
248 world-readable and world-writable (mask 0666 & ~umask), depending on the
249 implementation.
250 Returns the open file descriptor if successful, otherwise -1 and errno
251 set. */
252 extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
253 _GL_ARG_NONNULL ((1));
254 # endif
255 #elif defined GNULIB_POSIXCHECK
256 # undef mkostemps
257 # define mkostemps(t,s,f) \
258 (GL_LINK_WARNING ("mkostemps is unportable - " \
259 "use gnulib module mkostemps for portability"), \
260 mkostemps (t, s, f))
224261 #endif
225262
226263 #if @GNULIB_MKSTEMP@
235272 Returns the open file descriptor if successful, otherwise -1 and errno
236273 set. */
237274 # define mkstemp rpl_mkstemp
238 extern int mkstemp (char * /*template*/);
239 # else
240 /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
241 # include <unistd.h>
275 extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
242276 # endif
243277 #elif defined GNULIB_POSIXCHECK
244278 # undef mkstemp
248282 mkstemp (t))
249283 #endif
250284
285 #if @GNULIB_MKSTEMPS@
286 # if !@HAVE_MKSTEMPS@
287 /* Create a unique temporary file from TEMPLATE.
288 The last six characters of TEMPLATE prior to a suffix of length
289 SUFFIXLEN must be "XXXXXX";
290 they are replaced with a string that makes the file name unique.
291 The file is then created, ensuring it didn't exist before.
292 The file is created read-write (mask at least 0600 & ~umask), but it may be
293 world-readable and world-writable (mask 0666 & ~umask), depending on the
294 implementation.
295 Returns the open file descriptor if successful, otherwise -1 and errno
296 set. */
297 extern int mkstemps (char * /*template*/, int /*suffixlen*/)
298 _GL_ARG_NONNULL ((1));
299 # endif
300 #elif defined GNULIB_POSIXCHECK
301 # undef mkstemps
302 # define mkstemps(t,s) \
303 (GL_LINK_WARNING ("mkstemps is unportable - " \
304 "use gnulib module mkstemps for portability"), \
305 mkstemps (t, s))
306 #endif
307
251308 #if @GNULIB_PUTENV@
252309 # if @REPLACE_PUTENV@
253310 # undef putenv
254311 # define putenv rpl_putenv
255 extern int putenv (char *string);
312 extern int putenv (char *string) _GL_ARG_NONNULL ((1));
256313 # endif
257314 #endif
258315
263320 # define RAND_MAX 2147483647
264321 # endif
265322
266 int srandom_r (unsigned int seed, struct random_data *rand_state);
323 int srandom_r (unsigned int seed, struct random_data *rand_state)
324 _GL_ARG_NONNULL ((2));
267325 int initstate_r (unsigned int seed, char *buf, size_t buf_size,
268 struct random_data *rand_state);
269 int setstate_r (char *arg_state, struct random_data *rand_state);
270 int random_r (struct random_data *buf, int32_t *result);
326 struct random_data *rand_state)
327 _GL_ARG_NONNULL ((2, 4));
328 int setstate_r (char *arg_state, struct random_data *rand_state)
329 _GL_ARG_NONNULL ((1, 2));
330 int random_r (struct random_data *buf, int32_t *result)
331 _GL_ARG_NONNULL ((1, 2));
271332 # endif
272333 #elif defined GNULIB_POSIXCHECK
273334 # undef random_r
274 # define random_r(b,r) \
335 # define random_r(b,r) \
275336 (GL_LINK_WARNING ("random_r is unportable - " \
276337 "use gnulib module random_r for portability"), \
277338 random_r (b,r))
278339 # undef initstate_r
279 # define initstate_r(s,b,sz,r) \
340 # define initstate_r(s,b,sz,r) \
280341 (GL_LINK_WARNING ("initstate_r is unportable - " \
281342 "use gnulib module random_r for portability"), \
282343 initstate_r (s,b,sz,r))
283344 # undef srandom_r
284 # define srandom_r(s,r) \
345 # define srandom_r(s,r) \
285346 (GL_LINK_WARNING ("srandom_r is unportable - " \
286347 "use gnulib module random_r for portability"), \
287348 srandom_r (s,r))
288349 # undef setstate_r
289 # define setstate_r(a,r) \
350 # define setstate_r(a,r) \
290351 (GL_LINK_WARNING ("setstate_r is unportable - " \
291352 "use gnulib module random_r for portability"), \
292353 setstate_r (a,r))
311372 # define realpath rpl_realpath
312373 # endif
313374 # if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
314 extern char *realpath (const char *name, char *resolved);
375 extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1));
315376 # endif
316377 #elif defined GNULIB_POSIXCHECK
317378 # undef realpath
325386 # if !@HAVE_RPMATCH@
326387 /* Test a user response to a question.
327388 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
328 extern int rpmatch (const char *response);
389 extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1));
329390 # endif
330391 #elif defined GNULIB_POSIXCHECK
331392 # undef rpmatch
336397 #endif
337398
338399 #if @GNULIB_SETENV@
339 # if !@HAVE_SETENV@
400 # if @REPLACE_SETENV@
401 # undef setenv
402 # define setenv rpl_setenv
403 # endif
404 # if !@HAVE_SETENV@ || @REPLACE_SETENV@
340405 /* Set NAME to VALUE in the environment.
341406 If REPLACE is nonzero, overwrite an existing value. */
342 extern int setenv (const char *name, const char *value, int replace);
343 # endif
407 extern int setenv (const char *name, const char *value, int replace)
408 _GL_ARG_NONNULL ((1));
409 # endif
410 #elif defined GNULIB_POSIXCHECK
411 # undef setenv
412 # define setenv(n,v,o) \
413 (GL_LINK_WARNING ("setenv is unportable - " \
414 "use gnulib module setenv for portability"), \
415 setenv (n, v, o))
344416 #endif
345417
346418 #if @GNULIB_STRTOD@
349421 # endif
350422 # if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
351423 /* Parse a double from STRING, updating ENDP if appropriate. */
352 extern double strtod (const char *str, char **endp);
424 extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1));
353425 # endif
354426 #elif defined GNULIB_POSIXCHECK
355427 # undef strtod
369441 stored in *ENDPTR.
370442 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
371443 to ERANGE. */
372 extern long long strtoll (const char *string, char **endptr, int base);
444 extern long long strtoll (const char *string, char **endptr, int base)
445 _GL_ARG_NONNULL ((1));
373446 # endif
374447 #elif defined GNULIB_POSIXCHECK
375448 # undef strtoll
389462 stored in *ENDPTR.
390463 Upon overflow, the return value is ULLONG_MAX, and errno is set to
391464 ERANGE. */
392 extern unsigned long long strtoull (const char *string, char **endptr, int base);
465 extern unsigned long long strtoull (const char *string, char **endptr, int base)
466 _GL_ARG_NONNULL ((1));
393467 # endif
394468 #elif defined GNULIB_POSIXCHECK
395469 # undef strtoull
400474 #endif
401475
402476 #if @GNULIB_UNSETENV@
403 # if @HAVE_UNSETENV@
404 # if @VOID_UNSETENV@
405 /* On some systems, unsetenv() returns void.
406 This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */
407 # define unsetenv(name) ((unsetenv)(name), 0)
408 # endif
409 # else
477 # if @REPLACE_UNSETENV@
478 # undef unsetenv
479 # define unsetenv rpl_unsetenv
480 # endif
481 # if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
410482 /* Remove the variable NAME from the environment. */
411 extern int unsetenv (const char *name);
412 # endif
483 extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
484 # endif
485 #elif defined GNULIB_POSIXCHECK
486 # undef unsetenv
487 # define unsetenv(n) \
488 (GL_LINK_WARNING ("unsetenv is unportable - " \
489 "use gnulib module unsetenv for portability"), \
490 unsetenv (n))
413491 #endif
414492
415493 #ifdef __cplusplus
0 /* -*- buffer-read-only: t -*- vi: set ro: */
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007, 2009,
3 2010 Free Software Foundation, Inc.
4
5 This file is part of the GNU C Library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
12 This program 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 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20
21 #ifndef _LIBC
22 # include <config.h>
23 #endif
24
25 /* Get specification. */
26 #include <string.h>
27
28 #include <stdlib.h>
29
30 #undef __strdup
31 #ifdef _LIBC
32 # undef strdup
33 #endif
34
35 #ifndef weak_alias
36 # define __strdup strdup
37 #endif
38
39 /* Duplicate S, returning an identical malloc'd string. */
40 char *
41 __strdup (const char *s)
42 {
43 size_t len = strlen (s) + 1;
44 void *new = malloc (len);
45
46 if (new == NULL)
47 return NULL;
48
49 return (char *) memcpy (new, s, len);
50 }
51 #ifdef libc_hidden_def
52 libc_hidden_def (__strdup)
53 #endif
54 #ifdef weak_alias
55 weak_alias (__strdup, strdup)
56 #endif
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Optimized string comparison.
3 Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc.
3 Copyright (C) 2001-2002, 2007, 2009-2010 Free Software Foundation, Inc.
44
55 This program is free software: you can redistribute it and/or modify it
66 under the terms of the GNU General Public License as published
00 /* strerror.c --- POSIX compatible system error routine
11
2 Copyright (C) 2007-2009 Free Software Foundation, Inc.
2 Copyright (C) 2007-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
333333
334334 if (result == NULL || result[0] == '\0')
335335 {
336 static char const fmt[] = "Unknown error (%d)";
337 static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
338 sprintf (msg_buf, fmt, n);
339 return msg_buf;
336 static char const fmt[] = "Unknown error (%d)";
337 static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
338 sprintf (msg_buf, fmt, n);
339 return msg_buf;
340340 }
341341
342342 return result;
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A GNU-like <string.h>.
33
4 Copyright (C) 1995-1996, 2001-2009 Free Software Foundation, Inc.
4 Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
3232 /* NetBSD 5.0 mis-defines NULL. */
3333 #include <stddef.h>
3434
35 /* MirBSD defines mbslen as a macro. */
36 #if @GNULIB_MBSLEN@ && defined __MirBSD__
37 # include <wchar.h>
38 #endif
39
3540 #ifndef __attribute__
3641 /* This feature is available in gcc versions 2.5 and later. */
3742 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
4550
4651
4752 /* The definition of GL_LINK_WARNING is copied here. */
53
54 /* The definition of _GL_ARG_NONNULL is copied here. */
4855
4956
5057 #ifdef __cplusplus
5764 # if @REPLACE_MEMCHR@
5865 # define memchr rpl_memchr
5966 extern void *memchr (void const *__s, int __c, size_t __n)
60 __attribute__ ((__pure__));
67 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
6168 # endif
6269 #elif defined GNULIB_POSIXCHECK
6370 # undef memchr
7481 # endif
7582 # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
7683 extern void *memmem (void const *__haystack, size_t __haystack_len,
77 void const *__needle, size_t __needle_len)
78 __attribute__ ((__pure__));
84 void const *__needle, size_t __needle_len)
85 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
7986 # endif
8087 #elif defined GNULIB_POSIXCHECK
8188 # undef memmem
9198 #if @GNULIB_MEMPCPY@
9299 # if ! @HAVE_MEMPCPY@
93100 extern void *mempcpy (void *restrict __dest, void const *restrict __src,
94 size_t __n);
101 size_t __n)
102 _GL_ARG_NONNULL ((1, 2));
95103 # endif
96104 #elif defined GNULIB_POSIXCHECK
97105 # undef mempcpy
105113 #if @GNULIB_MEMRCHR@
106114 # if ! @HAVE_DECL_MEMRCHR@
107115 extern void *memrchr (void const *, int, size_t)
108 __attribute__ ((__pure__));
116 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
109117 # endif
110118 #elif defined GNULIB_POSIXCHECK
111119 # undef memrchr
121129 #if @GNULIB_RAWMEMCHR@
122130 # if ! @HAVE_RAWMEMCHR@
123131 extern void *rawmemchr (void const *__s, int __c_in)
124 __attribute__ ((__pure__));
132 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
125133 # endif
126134 #elif defined GNULIB_POSIXCHECK
127135 # undef rawmemchr
134142 /* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
135143 #if @GNULIB_STPCPY@
136144 # if ! @HAVE_STPCPY@
137 extern char *stpcpy (char *restrict __dst, char const *restrict __src);
145 extern char *stpcpy (char *restrict __dst, char const *restrict __src)
146 _GL_ARG_NONNULL ((1, 2));
138147 # endif
139148 #elif defined GNULIB_POSIXCHECK
140149 # undef stpcpy
150159 # if ! @HAVE_STPNCPY@
151160 # define stpncpy gnu_stpncpy
152161 extern char *stpncpy (char *restrict __dst, char const *restrict __src,
153 size_t __n);
162 size_t __n)
163 _GL_ARG_NONNULL ((1, 2));
154164 # endif
155165 #elif defined GNULIB_POSIXCHECK
156166 # undef stpncpy
175185 #if @GNULIB_STRCHRNUL@
176186 # if ! @HAVE_STRCHRNUL@
177187 extern char *strchrnul (char const *__s, int __c_in)
178 __attribute__ ((__pure__));
188 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
179189 # endif
180190 #elif defined GNULIB_POSIXCHECK
181191 # undef strchrnul
192202 # define strdup rpl_strdup
193203 # endif
194204 # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
195 extern char *strdup (char const *__s);
205 extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
196206 # endif
197207 #elif defined GNULIB_POSIXCHECK
198208 # undef strdup
209219 # define strndup rpl_strndup
210220 # endif
211221 # if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
212 extern char *strndup (char const *__string, size_t __n);
222 extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
213223 # endif
214224 #elif defined GNULIB_POSIXCHECK
215225 # undef strndup
225235 #if @GNULIB_STRNLEN@
226236 # if ! @HAVE_DECL_STRNLEN@
227237 extern size_t strnlen (char const *__string, size_t __maxlen)
228 __attribute__ ((__pure__));
238 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
229239 # endif
230240 #elif defined GNULIB_POSIXCHECK
231241 # undef strnlen
252262 #if @GNULIB_STRPBRK@
253263 # if ! @HAVE_STRPBRK@
254264 extern char *strpbrk (char const *__s, char const *__accept)
255 __attribute__ ((__pure__));
265 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
256266 # endif
257267 # if defined GNULIB_POSIXCHECK
258268 /* strpbrk() assumes the second argument is a list of single-byte characters.
314324 See also strtok_r(). */
315325 #if @GNULIB_STRSEP@
316326 # if ! @HAVE_STRSEP@
317 extern char *strsep (char **restrict __stringp, char const *restrict __delim);
327 extern char *strsep (char **restrict __stringp, char const *restrict __delim)
328 _GL_ARG_NONNULL ((1, 2));
318329 # endif
319330 # if defined GNULIB_POSIXCHECK
320331 # undef strsep
335346 #if @GNULIB_STRSTR@
336347 # if @REPLACE_STRSTR@
337348 # define strstr rpl_strstr
338 char *strstr (const char *haystack, const char *needle)
339 __attribute__ ((__pure__));
349 extern char *strstr (const char *haystack, const char *needle)
350 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
340351 # endif
341352 #elif defined GNULIB_POSIXCHECK
342353 /* strstr() does not work with multibyte strings if the locale encoding is
361372 # endif
362373 # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
363374 extern char *strcasestr (const char *haystack, const char *needle)
364 __attribute__ ((__pure__));
375 __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
365376 # endif
366377 #elif defined GNULIB_POSIXCHECK
367378 /* strcasestr() does not work with multibyte strings:
380391 /* Parse S into tokens separated by characters in DELIM.
381392 If S is NULL, the saved pointer in SAVE_PTR is used as
382393 the next starting point. For example:
383 char s[] = "-abc-=-def";
384 char *sp;
385 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
386 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
387 x = strtok_r(NULL, "=", &sp); // x = NULL
388 // s = "abc\0-def\0"
394 char s[] = "-abc-=-def";
395 char *sp;
396 x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
397 x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
398 x = strtok_r(NULL, "=", &sp); // x = NULL
399 // s = "abc\0-def\0"
389400
390401 This is a variant of strtok() that is multithread-safe.
391402
408419 # endif
409420 # if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
410421 extern char *strtok_r (char *restrict s, char const *restrict delim,
411 char **restrict save_ptr);
422 char **restrict save_ptr)
423 _GL_ARG_NONNULL ((2, 3));
412424 # endif
413425 # if defined GNULIB_POSIXCHECK
414426 # undef strtok_r
433445 #if @GNULIB_MBSLEN@
434446 /* Return the number of multibyte characters in the character string STRING.
435447 This considers multibyte characters, unlike strlen, which counts bytes. */
436 extern size_t mbslen (const char *string);
448 # ifdef __MirBSD__ /* MirBSD defines mbslen as a macro. Override it. */
449 # undef mbslen
450 # endif
451 # if @HAVE_MBSLEN@ /* AIX, OSF/1, MirBSD define mbslen already in libc. */
452 # define mbslen rpl_mbslen
453 # endif
454 extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
437455 #endif
438456
439457 #if @GNULIB_MBSNLEN@
440458 /* Return the number of multibyte characters in the character string starting
441459 at STRING and ending at STRING + LEN. */
442 extern size_t mbsnlen (const char *string, size_t len);
460 extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
443461 #endif
444462
445463 #if @GNULIB_MBSCHR@
448466 Unlike strchr(), this function works correctly in multibyte locales with
449467 encodings such as GB18030. */
450468 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
451 extern char * mbschr (const char *string, int c);
469 extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
452470 #endif
453471
454472 #if @GNULIB_MBSRCHR@
457475 Unlike strrchr(), this function works correctly in multibyte locales with
458476 encodings such as GB18030. */
459477 # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
460 extern char * mbsrchr (const char *string, int c);
478 extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
461479 #endif
462480
463481 #if @GNULIB_MBSSTR@
465483 string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
466484 Unlike strstr(), this function works correctly in multibyte locales with
467485 encodings different from UTF-8. */
468 extern char * mbsstr (const char *haystack, const char *needle);
486 extern char * mbsstr (const char *haystack, const char *needle)
487 _GL_ARG_NONNULL ((1, 2));
469488 #endif
470489
471490 #if @GNULIB_MBSCASECMP@
475494 Note: This function may, in multibyte locales, return 0 for strings of
476495 different lengths!
477496 Unlike strcasecmp(), this function works correctly in multibyte locales. */
478 extern int mbscasecmp (const char *s1, const char *s2);
497 extern int mbscasecmp (const char *s1, const char *s2)
498 _GL_ARG_NONNULL ((1, 2));
479499 #endif
480500
481501 #if @GNULIB_MBSNCASECMP@
488508 of different lengths!
489509 Unlike strncasecmp(), this function works correctly in multibyte locales.
490510 But beware that N is not a byte count but a character count! */
491 extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
511 extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
512 _GL_ARG_NONNULL ((1, 2));
492513 #endif
493514
494515 #if @GNULIB_MBSPCASECMP@
501522 smaller length than PREFIX!
502523 Unlike strncasecmp(), this function works correctly in multibyte
503524 locales. */
504 extern char * mbspcasecmp (const char *string, const char *prefix);
525 extern char * mbspcasecmp (const char *string, const char *prefix)
526 _GL_ARG_NONNULL ((1, 2));
505527 #endif
506528
507529 #if @GNULIB_MBSCASESTR@
510532 Note: This function may, in multibyte locales, return success even if
511533 strlen (haystack) < strlen (needle) !
512534 Unlike strcasestr(), this function works correctly in multibyte locales. */
513 extern char * mbscasestr (const char *haystack, const char *needle);
535 extern char * mbscasestr (const char *haystack, const char *needle)
536 _GL_ARG_NONNULL ((1, 2));
514537 #endif
515538
516539 #if @GNULIB_MBSCSPN@
519542 beginning of the string to this occurrence, or to the end of the string
520543 if none exists.
521544 Unlike strcspn(), this function works correctly in multibyte locales. */
522 extern size_t mbscspn (const char *string, const char *accept);
545 extern size_t mbscspn (const char *string, const char *accept)
546 _GL_ARG_NONNULL ((1, 2));
523547 #endif
524548
525549 #if @GNULIB_MBSPBRK@
528552 exists.
529553 Unlike strpbrk(), this function works correctly in multibyte locales. */
530554 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
531 extern char * mbspbrk (const char *string, const char *accept);
555 extern char * mbspbrk (const char *string, const char *accept)
556 _GL_ARG_NONNULL ((1, 2));
532557 #endif
533558
534559 #if @GNULIB_MBSSPN@
537562 beginning of the string to this occurrence, or to the end of the string
538563 if none exists.
539564 Unlike strspn(), this function works correctly in multibyte locales. */
540 extern size_t mbsspn (const char *string, const char *reject);
565 extern size_t mbsspn (const char *string, const char *reject)
566 _GL_ARG_NONNULL ((1, 2));
541567 #endif
542568
543569 #if @GNULIB_MBSSEP@
555581 Caveat: The identity of the delimiting character is lost.
556582
557583 See also mbstok_r(). */
558 extern char * mbssep (char **stringp, const char *delim);
584 extern char * mbssep (char **stringp, const char *delim)
585 _GL_ARG_NONNULL ((1, 2));
559586 #endif
560587
561588 #if @GNULIB_MBSTOK_R@
563590 the character string DELIM.
564591 If STRING is NULL, the saved pointer in SAVE_PTR is used as
565592 the next starting point. For example:
566 char s[] = "-abc-=-def";
567 char *sp;
568 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
569 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
570 x = mbstok_r(NULL, "=", &sp); // x = NULL
571 // s = "abc\0-def\0"
593 char s[] = "-abc-=-def";
594 char *sp;
595 x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
596 x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
597 x = mbstok_r(NULL, "=", &sp); // x = NULL
598 // s = "abc\0-def\0"
572599
573600 Caveat: It modifies the original string.
574601 Caveat: These functions cannot be used on constant strings.
575602 Caveat: The identity of the delimiting character is lost.
576603
577604 See also mbssep(). */
578 extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
605 extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
606 _GL_ARG_NONNULL ((2, 3));
579607 #endif
580608
581609 /* Map any int, typically from errno, into an error message. */
610638
611639 #if @GNULIB_STRVERSCMP@
612640 # if !@HAVE_STRVERSCMP@
613 extern int strverscmp (const char *, const char *);
641 extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
614642 # endif
615643 #elif defined GNULIB_POSIXCHECK
616644 # undef strverscmp
0 /* stripslash.c -- remove redundant trailing slashes from a file name
1
2 Copyright (C) 1990, 2001, 2003-2006, 2009-2010 Free Software Foundation,
3 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 #include "dirname.h"
21
22 /* Remove trailing slashes from FILE. Return true if a trailing slash
23 was removed. This is useful when using file name completion from a
24 shell that adds a "/" after directory names (such as tcsh and
25 bash), because on symlinks to directories, several system calls
26 have different semantics according to whether a trailing slash is
27 present. */
28
29 bool
30 strip_trailing_slashes (char *file)
31 {
32 char *base = last_component (file);
33 char *base_lim;
34 bool had_slash;
35
36 /* last_component returns "" for file system roots, but we need to turn
37 `///' into `/'. */
38 if (! *base)
39 base = file;
40 base_lim = base + base_len (base);
41 had_slash = (*base_lim != '\0');
42 *base_lim = '\0';
43 return had_slash;
44 }
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Provide a more complete sys/stat header file.
3 Copyright (C) 2005-2009 Free Software Foundation, Inc.
3 Copyright (C) 2005-2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
4949 #define _GL_SYS_STAT_H
5050
5151 /* The definition of GL_LINK_WARNING is copied here. */
52
53 /* The definition of _GL_ARG_NONNULL is copied here. */
5254
5355 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
5456 headers that may declare mkdir(). */
296298
297299 #if @GNULIB_FCHMODAT@
298300 # if !@HAVE_FCHMODAT@
299 extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
301 extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
302 _GL_ARG_NONNULL ((2));
300303 # endif
301304 #elif defined GNULIB_POSIXCHECK
302305 # undef fchmodat
309312
310313 #if @REPLACE_FSTAT@
311314 # define fstat rpl_fstat
312 extern int fstat (int fd, struct stat *buf);
315 extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
313316 #endif
314317
315318
319322 # define fstatat rpl_fstatat
320323 # endif
321324 # if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
322 extern int fstatat (int fd, char const *name, struct stat *st, int flags);
325 extern int fstatat (int fd, char const *name, struct stat *st, int flags)
326 _GL_ARG_NONNULL ((2, 3));
323327 # endif
324328 #elif defined GNULIB_POSIXCHECK
325329 # undef fstatat
361365 # define lchmod chmod
362366 # endif
363367 # if 0 /* assume already declared */
364 extern int lchmod (const char *filename, mode_t mode);
368 extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
365369 # endif
366370 #elif defined GNULIB_POSIXCHECK
367371 # undef lchmod
380384 # elif @REPLACE_LSTAT@
381385 # undef lstat
382386 # define lstat rpl_lstat
383 extern int rpl_lstat (const char *name, struct stat *buf);
387 extern int rpl_lstat (const char *name, struct stat *buf)
388 _GL_ARG_NONNULL ((1, 2));
384389 # endif
385390 #elif defined GNULIB_POSIXCHECK
386391 # undef lstat
387 # define lstat(p,b) \
388 (GL_LINK_WARNING ("lstat is unportable - " \
389 "use gnulib module lstat for portability"), \
392 # define lstat(p,b) \
393 (GL_LINK_WARNING ("lstat is unportable - " \
394 "use gnulib module lstat for portability"), \
390395 lstat (p, b))
391396 #endif
392397
394399 #if @REPLACE_MKDIR@
395400 # undef mkdir
396401 # define mkdir rpl_mkdir
397 extern int mkdir (char const *name, mode_t mode);
402 extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
398403 #else
399404 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
400405 Additionally, it declares _mkdir (and depending on compile flags, an
414419
415420 #if @GNULIB_MKDIRAT@
416421 # if !@HAVE_MKDIRAT@
417 extern int mkdirat (int fd, char const *file, mode_t mode);
422 extern int mkdirat (int fd, char const *file, mode_t mode)
423 _GL_ARG_NONNULL ((2));
418424 # endif
419425 #elif defined GNULIB_POSIXCHECK
420426 # undef mkdirat
425431 #endif
426432
427433
434 #if @GNULIB_MKFIFO@
435 # if @REPLACE_MKFIFO@
436 # undef mkfifo
437 # define mkfifo rpl_mkfifo
438 # endif
439 # if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
440 extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
441 # endif
442 #elif defined GNULIB_POSIXCHECK
443 # undef mkfifo
444 # define mkfifo(n,m) \
445 (GL_LINK_WARNING ("mkfifo is not portable - " \
446 "use gnulib module mkfifo for portability"), \
447 mkfifo (n, m))
448 #endif
449
450
428451 #if @GNULIB_MKFIFOAT@
429452 # if !@HAVE_MKFIFOAT@
430 int mkfifoat (int fd, char const *file, mode_t mode);
453 extern int mkfifoat (int fd, char const *file, mode_t mode)
454 _GL_ARG_NONNULL ((2));
431455 # endif
432456 #elif defined GNULIB_POSIXCHECK
433457 # undef mkfifoat
434 # define mkfifoat(d,n,m) \
458 # define mkfifoat(d,n,m) \
435459 (GL_LINK_WARNING ("mkfifoat is not portable - " \
436460 "use gnulib module mkfifoat for portability"), \
437461 mkfifoat (d, n, m))
438462 #endif
439463
440464
465 #if @GNULIB_MKNOD@
466 # if @REPLACE_MKNOD@
467 # undef mknod
468 # define mknod rpl_mknod
469 # endif
470 # if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
471 extern int mknod (char const *file, mode_t mode, dev_t dev)
472 _GL_ARG_NONNULL ((1));
473 # endif
474 #elif defined GNULIB_POSIXCHECK
475 # undef mknod
476 # define mknod(n,m,d) \
477 (GL_LINK_WARNING ("mknod is not portable - " \
478 "use gnulib module mknod for portability"), \
479 mknod (n, m, d))
480 #endif
481
482
441483 #if @GNULIB_MKNODAT@
442484 # if !@HAVE_MKNODAT@
443 int mknodat (int fd, char const *file, mode_t mode, dev_t dev);
485 extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
486 _GL_ARG_NONNULL ((2));
444487 # endif
445488 #elif defined GNULIB_POSIXCHECK
446489 # undef mknodat
447 # define mknodat(f,n,m,d) \
490 # define mknodat(f,n,m,d) \
448491 (GL_LINK_WARNING ("mknodat is not portable - " \
449492 "use gnulib module mkfifoat for portability"), \
450493 mknodat (f, n, m, d))
457500 struct stat. This means that rpl_stat will not be used if the user
458501 does (stat)(a,b). Oh well. */
459502 # undef stat
460 # define stat(name, st) rpl_stat (name, st)
461 extern int stat (const char *name, struct stat *buf);
503 # ifdef _LARGE_FILES
504 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
505 so we have to replace stat64() instead of stat(). */
506 # define stat stat64
507 # undef stat64
508 # define stat64(name, st) rpl_stat (name, st)
509 # else /* !_LARGE_FILES */
510 # define stat(name, st) rpl_stat (name, st)
511 # endif /* !_LARGE_FILES */
512 extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
462513 # endif
463514 #elif defined GNULIB_POSIXCHECK
464515 # undef stat
465 # define stat(p,b) \
466 (GL_LINK_WARNING ("stat is unportable - " \
467 "use gnulib module stat for portability"), \
516 # define stat(p,b) \
517 (GL_LINK_WARNING ("stat is unportable - " \
518 "use gnulib module stat for portability"), \
468519 stat (p, b))
469520 #endif
470521
476527 # endif
477528 # if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
478529 extern int utimensat (int fd, char const *name,
479 struct timespec const times[2], int flag);
530 struct timespec const times[2], int flag)
531 _GL_ARG_NONNULL ((2));
480532 # endif
481533 #elif defined GNULIB_POSIXCHECK
482534 # undef utimensat
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Provide a more complete sys/time.h.
33
4 Copyright (C) 2007-2008 Free Software Foundation, Inc.
4 Copyright (C) 2007-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
4040 # include <time.h>
4141 # endif
4242
43 /* The definition of _GL_ARG_NONNULL is copied here. */
44
4345 #ifdef __cplusplus
4446 extern "C" {
4547 #endif
5557 # if @REPLACE_GETTIMEOFDAY@
5658 # undef gettimeofday
5759 # define gettimeofday rpl_gettimeofday
58 int gettimeofday (struct timeval *restrict, void *restrict);
60 extern int gettimeofday (struct timeval *restrict, void *restrict)
61 _GL_ARG_NONNULL ((1));
5962 # endif
6063
6164 #ifdef __cplusplus
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A more-standard <time.h>.
33
4 Copyright (C) 2007-2009 Free Software Foundation, Inc.
4 Copyright (C) 2007-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
4141 /* NetBSD 5.0 mis-defines NULL. */
4242 #include <stddef.h>
4343
44 /* The definition of _GL_ARG_NONNULL is copied here. */
45
4446 # ifdef __cplusplus
4547 extern "C" {
4648 # endif
6769 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
6870 # if @REPLACE_NANOSLEEP@
6971 # define nanosleep rpl_nanosleep
70 int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
72 extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
73 _GL_ARG_NONNULL ((1));
7174 # endif
7275
7376 /* Return the 'time_t' representation of TP and normalize TP. */
7477 # if @REPLACE_MKTIME@
7578 # define mktime rpl_mktime
76 extern time_t mktime (struct tm *__tp);
79 extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
7780 # endif
7881
7982 /* Convert TIMER to RESULT, assuming local time and UTC respectively. See
8487 # define localtime_r rpl_localtime_r
8588 # undef gmtime_r
8689 # define gmtime_r rpl_gmtime_r
87 struct tm *localtime_r (time_t const *restrict __timer,
88 struct tm *restrict __result);
89 struct tm *gmtime_r (time_t const *restrict __timer,
90 struct tm *restrict __result);
90 extern struct tm *localtime_r (time_t const *restrict __timer,
91 struct tm *restrict __result)
92 _GL_ARG_NONNULL ((1, 2));
93 extern struct tm *gmtime_r (time_t const *restrict __timer,
94 struct tm *restrict __result)
95 _GL_ARG_NONNULL ((1, 2));
9196 # endif
9297
9398 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
96101 # if @REPLACE_STRPTIME@
97102 # undef strptime
98103 # define strptime rpl_strptime
99 char *strptime (char const *restrict __buf, char const *restrict __format,
100 struct tm *restrict __tm);
104 extern char *strptime (char const *restrict __buf,
105 char const *restrict __format,
106 struct tm *restrict __tm)
107 _GL_ARG_NONNULL ((1, 2, 3));
101108 # endif
102109
103110 /* Convert TM to a time_t value, assuming UTC. */
104111 # if @REPLACE_TIMEGM@
105112 # undef timegm
106113 # define timegm rpl_timegm
107 time_t timegm (struct tm *__tm);
114 extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
108115 # endif
109116
110117 /* Encourage applications to avoid unsafe functions that can overrun
00 /* timespec -- System time interface
11
2 Copyright (C) 2000, 2002, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
2 Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2010 Free Software
3 Foundation, Inc.
34
45 This program is free software: you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
2526 timespec_cmp (struct timespec a, struct timespec b)
2627 {
2728 return (a.tv_sec < b.tv_sec ? -1
28 : a.tv_sec > b.tv_sec ? 1
29 : a.tv_nsec < b.tv_nsec ? -1
30 : a.tv_nsec > b.tv_nsec ? 1
31 : 0);
29 : a.tv_sec > b.tv_sec ? 1
30 : a.tv_nsec < b.tv_nsec ? -1
31 : a.tv_nsec > b.tv_nsec ? 1
32 : 0);
3233 }
3334
3435 void gettime (struct timespec *);
00 /* Like unistd.h, but redefine some names to avoid glitches.
11
2 Copyright (C) 2005 Free Software Foundation, Inc.
2 Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
2424
2525 #undef pipe
2626 #define pipe pipe_safer
27
28 #if GNULIB_PIPE2_SAFER
29 # undef pipe2
30 # define pipe2 pipe2_safer
31 #endif
00 /* Invoke unistd-like functions, but avoid some glitches.
11
2 Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
2 Copyright (C) 2001, 2003, 2005, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
1414 You should have received a copy of the GNU General Public License
1515 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1616
17 /* Written by Paul Eggert. */
17 /* Written by Paul Eggert and Eric Blake. */
1818
1919 int dup_safer (int);
2020 int fd_safer (int);
2121 int pipe_safer (int[2]);
22
23 #if GNULIB_FD_SAFER_FLAG
24 int dup_safer_flag (int, int);
25 int fd_safer_flag (int, int);
26 #endif
27
28 #if GNULIB_PIPE2_SAFER
29 int pipe2_safer (int[2], int);
30 #endif
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* Substitute for and wrapper around <unistd.h>.
3 Copyright (C) 2003-2009 Free Software Foundation, Inc.
3 Copyright (C) 2003-2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
3434 #include <stddef.h>
3535
3636 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
37 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
37 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
38 /* But avoid namespace pollution on glibc systems. */
39 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
40 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
41 && ! defined __GLIBC__
3842 # include <stdio.h>
43 #endif
44
45 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
46 /* But avoid namespace pollution on glibc systems. */
47 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
48 # include <fcntl.h>
3949 #endif
4050
4151 /* mingw fails to declare _exit in <unistd.h>. */
4252 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
43 #include <stdlib.h>
44
45 #if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
46 || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
47 || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@))
53 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
54 /* But avoid namespace pollution on glibc systems. */
55 #ifndef __GLIBC__
56 # include <stdlib.h>
57 #endif
58
59 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
60 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
61 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
62 # include <io.h>
63 #endif
64
65 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
66 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
4867 /* Get ssize_t. */
4968 # include <sys/types.h>
5069 #endif
5170
52 /* Get getopt(), optarg, optind, opterr, optopt. */
53 #if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
71 /* Get getopt(), optarg, optind, opterr, optopt.
72 But avoid namespace pollution on glibc systems. */
73 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
5474 # include <getopt.h>
5575 #endif
5676
6080 # include <winsock2.h>
6181 # if !defined _GL_SYS_SOCKET_H
6282 # undef socket
63 # define socket socket_used_without_including_sys_socket_h
83 # define socket socket_used_without_including_sys_socket_h
6484 # undef connect
65 # define connect connect_used_without_including_sys_socket_h
85 # define connect connect_used_without_including_sys_socket_h
6686 # undef accept
67 # define accept accept_used_without_including_sys_socket_h
87 # define accept accept_used_without_including_sys_socket_h
6888 # undef bind
69 # define bind bind_used_without_including_sys_socket_h
89 # define bind bind_used_without_including_sys_socket_h
7090 # undef getpeername
71 # define getpeername getpeername_used_without_including_sys_socket_h
91 # define getpeername getpeername_used_without_including_sys_socket_h
7292 # undef getsockname
73 # define getsockname getsockname_used_without_including_sys_socket_h
93 # define getsockname getsockname_used_without_including_sys_socket_h
7494 # undef getsockopt
75 # define getsockopt getsockopt_used_without_including_sys_socket_h
95 # define getsockopt getsockopt_used_without_including_sys_socket_h
7696 # undef listen
77 # define listen listen_used_without_including_sys_socket_h
97 # define listen listen_used_without_including_sys_socket_h
7898 # undef recv
79 # define recv recv_used_without_including_sys_socket_h
99 # define recv recv_used_without_including_sys_socket_h
80100 # undef send
81 # define send send_used_without_including_sys_socket_h
101 # define send send_used_without_including_sys_socket_h
82102 # undef recvfrom
83 # define recvfrom recvfrom_used_without_including_sys_socket_h
103 # define recvfrom recvfrom_used_without_including_sys_socket_h
84104 # undef sendto
85 # define sendto sendto_used_without_including_sys_socket_h
105 # define sendto sendto_used_without_including_sys_socket_h
86106 # undef setsockopt
87 # define setsockopt setsockopt_used_without_including_sys_socket_h
107 # define setsockopt setsockopt_used_without_including_sys_socket_h
88108 # undef shutdown
89 # define shutdown shutdown_used_without_including_sys_socket_h
109 # define shutdown shutdown_used_without_including_sys_socket_h
90110 # endif
91111 # if !defined _GL_SYS_SELECT_H
92112 # undef select
93 # define select select_used_without_including_sys_select_h
113 # define select select_used_without_including_sys_select_h
94114 # endif
95115 # endif
96116 #endif
97117
98118 /* The definition of GL_LINK_WARNING is copied here. */
119
120 /* The definition of _GL_ARG_NONNULL is copied here. */
121
122 /* The definition of _GL_WARN_ON_USE is copied here. */
99123
100124
101125 /* OS/2 EMX lacks these macros. */
127151
128152 #if @GNULIB_CHOWN@
129153 # if @REPLACE_CHOWN@
130 # ifndef REPLACE_CHOWN
131 # define REPLACE_CHOWN 1
132 # endif
133 # if REPLACE_CHOWN
154 # undef chown
155 # define chown rpl_chown
156 # endif
157 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
134158 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
135159 to GID (if GID is not -1). Follow symbolic links.
136160 Return 0 if successful, otherwise -1 and errno set.
137161 See the POSIX:2001 specification
138162 <http://www.opengroup.org/susv3xsh/chown.html>. */
139 # define chown rpl_chown
140 extern int chown (const char *file, uid_t uid, gid_t gid);
141 # endif
163 extern int chown (const char *file, uid_t uid, gid_t gid)
164 _GL_ARG_NONNULL ((1));
142165 # endif
143166 #elif defined GNULIB_POSIXCHECK
144167 # undef chown
230253 # endif
231254 # endif
232255 #elif defined GNULIB_POSIXCHECK
233 # undef environ
234 # define environ \
235 (GL_LINK_WARNING ("environ is unportable - " \
236 "use gnulib module environ for portability"), \
237 environ)
256 # if HAVE_RAW_DECL_ENVIRON
257 static inline char ***
258 rpl_environ (void)
259 {
260 return &environ;
261 }
262 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
263 "use gnulib module environ for portability");
264 # undef environ
265 # define environ (*rpl_environ ())
266 # endif
238267 #endif
239268
240269
242271 # if !@HAVE_EUIDACCESS@
243272 /* Like access(), except that it uses the effective user id and group id of
244273 the current process. */
245 extern int euidaccess (const char *filename, int mode);
274 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
246275 # endif
247276 #elif defined GNULIB_POSIXCHECK
248277 # undef euidaccess
255284
256285 #if @GNULIB_FACCESSAT@
257286 # if !@HAVE_FACCESSAT@
258 int faccessat (int fd, char const *file, int mode, int flag);
287 extern int faccessat (int fd, char const *file, int mode, int flag)
288 _GL_ARG_NONNULL ((2));
259289 # endif
260290 #elif defined GNULIB_POSIXCHECK
261291 # undef faccessat
262 # define faccessat(d,n,m,f) \
292 # define faccessat(d,n,m,f) \
263293 (GL_LINK_WARNING ("faccessat is not portable - " \
264294 "use gnulib module faccessat for portability"), \
265295 faccessat (d, n, m, f))
276306 extern int fchdir (int /*fd*/);
277307
278308 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
279 extern int _gl_register_fd (int fd, const char *filename);
309 extern int _gl_register_fd (int fd, const char *filename)
310 _GL_ARG_NONNULL ((2));
280311 extern void _gl_unregister_fd (int fd);
281312 extern int _gl_register_dup (int oldfd, int newfd);
282313 extern const char *_gl_directory_name (int fd);
297328 # define fchownat rpl_fchownat
298329 # endif
299330 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
300 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
331 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
332 _GL_ARG_NONNULL ((2));
301333 # endif
302334 #elif defined GNULIB_POSIXCHECK
303335 # undef fchownat
304 # define fchownat(d,n,o,g,f) \
336 # define fchownat(d,n,o,g,f) \
305337 (GL_LINK_WARNING ("fchownat is not portable - " \
306338 "use gnulib module openat for portability"), \
307339 fchownat (d, n, o, g, f))
343375
344376
345377 #if @GNULIB_GETCWD@
346 /* Include the headers that might declare getcwd so that they will not
347 cause confusion if included after this file. */
348 # include <stdlib.h>
349378 # if @REPLACE_GETCWD@
350379 /* Get the name of the current working directory, and put it in SIZE bytes
351380 of BUF.
381410 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
382411 Return 0 if successful, otherwise set errno and return -1. */
383412 # if !@HAVE_GETDOMAINNAME@
384 extern int getdomainname(char *name, size_t len);
413 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
385414 # endif
386415 #elif defined GNULIB_POSIXCHECK
387416 # undef getdomainname
404433 (GL_LINK_WARNING ("getdtablesize is unportable - " \
405434 "use gnulib module getdtablesize for portability"), \
406435 getdtablesize ())
436 #endif
437
438
439 #if @GNULIB_GETGROUPS@
440 # if @REPLACE_GETGROUPS@
441 # undef getgroups
442 # define getgroups rpl_getgroups
443 # endif
444 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
445 /* Return the supplemental groups that the current process belongs to.
446 It is unspecified whether the effective group id is in the list.
447 If N is 0, return the group count; otherwise, N describes how many
448 entries are available in GROUPS. Return -1 and set errno if N is
449 not 0 and not large enough. Fails with ENOSYS on some systems. */
450 int getgroups (int n, gid_t *groups);
451 # endif
452 #elif defined GNULIB_POSIXCHECK
453 # undef getgroups
454 # define getgroups(n,g) \
455 (GL_LINK_WARNING ("getgroups is unportable - " \
456 "use gnulib module getgroups for portability"), \
457 getgroups (n, g))
407458 #endif
408459
409460
420471 # define gethostname rpl_gethostname
421472 # endif
422473 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
423 extern int gethostname(char *name, size_t len);
474 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
424475 # endif
425476 #elif @UNISTD_H_HAVE_WINSOCK2_H@
426477 # undef gethostname
434485 #endif
435486
436487
488 #if @GNULIB_GETLOGIN@
489 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
490 returns NULL with errno set.
491
492 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
493
494 Most programs don't need to use this function, because the information is
495 available through environment variables:
496 ${LOGNAME-$USER} on Unix platforms,
497 $USERNAME on native Windows platforms.
498 */
499 # if !@HAVE_GETLOGIN@
500 extern char *getlogin (void);
501 # endif
502 #elif defined GNULIB_POSIXCHECK
503 # undef getlogin
504 # define getlogin() \
505 (GL_LINK_WARNING ("getlogin is unportable - " \
506 "use gnulib module getlogin for portability"), \
507 getlogin ())
508 #endif
509
510
437511 #if @GNULIB_GETLOGIN_R@
438512 /* Copies the user's login name to NAME.
439513 The array pointed to by NAME has room for SIZE bytes.
443517 provided (this case is hopefully rare but is left open by the POSIX spec).
444518
445519 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
520
521 Most programs don't need to use this function, because the information is
522 available through environment variables:
523 ${LOGNAME-$USER} on Unix platforms,
524 $USERNAME on native Windows platforms.
446525 */
447526 # if !@HAVE_DECL_GETLOGIN_R@
448 extern int getlogin_r (char *name, size_t size);
527 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
449528 # endif
450529 #elif defined GNULIB_POSIXCHECK
451530 # undef getlogin_r
546625
547626 #if @GNULIB_LCHOWN@
548627 # if @REPLACE_LCHOWN@
628 # undef lchown
629 # define lchown rpl_lchown
630 # endif
631 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
549632 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
550633 to GID (if GID is not -1). Do not follow symbolic links.
551634 Return 0 if successful, otherwise -1 and errno set.
552635 See the POSIX:2001 specification
553636 <http://www.opengroup.org/susv3xsh/lchown.html>. */
554 # define lchown rpl_lchown
555 extern int lchown (char const *file, uid_t owner, gid_t group);
637 extern int lchown (char const *file, uid_t owner, gid_t group)
638 _GL_ARG_NONNULL ((1));
556639 # endif
557640 #elif defined GNULIB_POSIXCHECK
558641 # undef lchown
572655 See POSIX:2001 specification
573656 <http://www.opengroup.org/susv3xsh/link.html>. */
574657 # if !@HAVE_LINK@ || @REPLACE_LINK@
575 extern int link (const char *path1, const char *path2);
658 extern int link (const char *path1, const char *path2)
659 _GL_ARG_NONNULL ((1, 2));
576660 # endif
577661 #elif defined GNULIB_POSIXCHECK
578662 # undef link
592676 Return 0 if successful, otherwise -1 and errno set. */
593677 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
594678 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
595 int flag);
679 int flag)
680 _GL_ARG_NONNULL ((2, 4));
596681 # endif
597682 #elif defined GNULIB_POSIXCHECK
598683 # undef linkat
599 # define link(f1,path1,f2,path2,f) \
684 # define linkat(f1,path1,f2,path2,f) \
600685 (GL_LINK_WARNING ("linkat is unportable - " \
601686 "use gnulib module linkat for portability"), \
602687 linkat (f1, path1, f2, path2,f))
632717 # if @HAVE_PIPE2@
633718 # define pipe2 rpl_pipe2
634719 # endif
635 extern int pipe2 (int fd[2], int flags);
720 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
636721 #elif defined GNULIB_POSIXCHECK
637722 # undef pipe2
638723 # define pipe2(f,o) \
642727 #endif
643728
644729
730 #if @GNULIB_PREAD@
731 # if @REPLACE_PREAD@
732 # define pread rpl_pread
733 # endif
734 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
735 Return the number of bytes placed into BUF if successful, otherwise
736 set errno and return -1. 0 indicates EOF. See the POSIX:2001
737 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
738 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
739 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
740 _GL_ARG_NONNULL ((2));
741 # endif
742 #elif defined GNULIB_POSIXCHECK
743 # undef pread
744 # define pread(f,b,s,o) \
745 (GL_LINK_WARNING ("pread is unportable - " \
746 "use gnulib module pread for portability"), \
747 pread (f, b, s, o))
748 #endif
749
750
645751 #if @GNULIB_READLINK@
646752 # if @REPLACE_READLINK@
647753 # define readlink rpl_readlink
652758 See the POSIX:2001 specification
653759 <http://www.opengroup.org/susv3xsh/readlink.html>. */
654760 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
655 extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
761 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
762 _GL_ARG_NONNULL ((1, 2));
656763 # endif
657764 #elif defined GNULIB_POSIXCHECK
658765 # undef readlink
665772
666773 #if @GNULIB_READLINKAT@
667774 # if !@HAVE_READLINKAT@
668 ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
775 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
776 _GL_ARG_NONNULL ((2, 3));
669777 # endif
670778 #elif defined GNULIB_POSIXCHECK
671779 # undef readlinkat
672 # define readlinkat(d,n,b,l) \
780 # define readlinkat(d,n,b,l) \
673781 (GL_LINK_WARNING ("readlinkat is not portable - " \
674782 "use gnulib module symlinkat for portability"), \
675783 readlinkat (d, n, b, l))
680788 # if @REPLACE_RMDIR@
681789 # define rmdir rpl_rmdir
682790 /* Remove the directory DIR. */
683 extern int rmdir (char const *name);
791 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
684792 # endif
685793 #elif defined GNULIB_POSIXCHECK
686794 # undef rmdir
692800
693801
694802 #if @GNULIB_SLEEP@
803 # if @REPLACE_SLEEP@
804 # undef sleep
805 # define sleep rpl_sleep
806 # endif
695807 /* Pause the execution of the current thread for N seconds.
696808 Returns the number of seconds left to sleep.
697809 See the POSIX:2001 specification
698810 <http://www.opengroup.org/susv3xsh/sleep.html>. */
699 # if !@HAVE_SLEEP@
811 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
700812 extern unsigned int sleep (unsigned int n);
701813 # endif
702814 #elif defined GNULIB_POSIXCHECK
714826 # define symlink rpl_symlink
715827 # endif
716828 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
717 int symlink (char const *contents, char const *file);
829 extern int symlink (char const *contents, char const *file)
830 _GL_ARG_NONNULL ((1, 2));
718831 # endif
719832 #elif defined GNULIB_POSIXCHECK
720833 # undef symlink
721 # define symlink(c,n) \
834 # define symlink(c,n) \
722835 (GL_LINK_WARNING ("symlink is not portable - " \
723836 "use gnulib module symlink for portability"), \
724837 symlink (c, n))
727840
728841 #if @GNULIB_SYMLINKAT@
729842 # if !@HAVE_SYMLINKAT@
730 int symlinkat (char const *contents, int fd, char const *file);
843 extern int symlinkat (char const *contents, int fd, char const *file)
844 _GL_ARG_NONNULL ((1, 3));
731845 # endif
732846 #elif defined GNULIB_POSIXCHECK
733847 # undef symlinkat
734 # define symlinkat(c,d,n) \
848 # define symlinkat(c,d,n) \
735849 (GL_LINK_WARNING ("symlinkat is not portable - " \
736850 "use gnulib module symlinkat for portability"), \
737851 symlinkat (c, d, n))
742856 # if @REPLACE_UNLINK@
743857 # undef unlink
744858 # define unlink rpl_unlink
745 extern int unlink (char const *file);
859 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
746860 # endif
747861 #elif defined GNULIB_POSIXCHECK
748862 # undef unlink
759873 # define unlinkat rpl_unlinkat
760874 # endif
761875 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
762 extern int unlinkat (int fd, char const *file, int flag);
876 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
763877 # endif
764878 #elif defined GNULIB_POSIXCHECK
765879 # undef unlinkat
770884 #endif
771885
772886
887 #if @GNULIB_USLEEP@
888 # if @REPLACE_USLEEP@
889 # undef usleep
890 # define usleep rpl_usleep
891 # endif
892 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
893 /* Pause the execution of the current thread for N microseconds.
894 Returns 0 on completion, or -1 on range error.
895 See the POSIX:2001 specification
896 <http://www.opengroup.org/susv3xsh/sleep.html>. */
897 extern int usleep (useconds_t n);
898 # endif
899 #elif defined GNULIB_POSIXCHECK
900 # undef usleep
901 # define usleep(n) \
902 (GL_LINK_WARNING ("usleep is unportable - " \
903 "use gnulib module usleep for portability"), \
904 usleep (n))
905 #endif
906
907
773908 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
774909 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
775910 See the POSIX:2001 specification
776911 <http://www.opengroup.org/susv3xsh/write.html>. */
777912 # undef write
778913 # define write rpl_write
779 extern ssize_t write (int fd, const void *buf, size_t count);
914 extern ssize_t write (int fd, const void *buf, size_t count)
915 _GL_ARG_NONNULL ((2));
780916 #endif
781917
782918
0 /* Work around unlink bugs.
1
2 Copyright (C) 2009, 2010 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 #include <config.h>
18
19 #include <unistd.h>
20
21 #include <errno.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/stat.h>
25
26 #undef unlink
27
28 /* Remove file NAME.
29 Return 0 if successful, -1 if not. */
30
31 int
32 rpl_unlink (char const *name)
33 {
34 /* Work around Solaris 9 bug where unlink("file/") succeeds. */
35 size_t len = strlen (name);
36 int result = 0;
37 if (len && ISSLASH (name[len - 1]))
38 {
39 /* We can't unlink(2) something if it doesn't exist. If it does
40 exist, then it resolved to a directory, due to the trailing
41 slash, and POSIX requires that the unlink attempt to remove
42 that directory (which would leave the symlink dangling).
43 Unfortunately, Solaris 9 is one of the platforms where the
44 root user can unlink directories, and we don't want to
45 cripple this behavior on real directories, even if it is
46 seldom needed (at any rate, it's nicer to let coreutils'
47 unlink(1) give the correct errno for non-root users). But we
48 don't know whether name was an actual directory, or a symlink
49 to a directory; and due to the bug of ignoring trailing
50 slash, Solaris 9 would end up successfully unlinking the
51 symlink instead of the directory. Technically, we could use
52 realpath to find the canonical directory name to attempt
53 deletion on. But that is a lot of work for a corner case; so
54 we instead just use an lstat on the shortened name, and
55 reject symlinks with trailing slashes. The root user of
56 unlink(1) will just have to live with the rule that they
57 can't delete a directory via a symlink. */
58 struct stat st;
59 result = lstat (name, &st);
60 if (result == 0)
61 {
62 /* Trailing NUL will overwrite the trailing slash. */
63 char *short_name = malloc (len);
64 if (!short_name)
65 {
66 errno = EPERM;
67 return -1;
68 }
69 memcpy (short_name, name, len);
70 while (len && ISSLASH (short_name[len - 1]))
71 short_name[--len] = '\0';
72 if (len && (lstat (short_name, &st) || S_ISLNK (st.st_mode)))
73 {
74 free (short_name);
75 errno = EPERM;
76 return -1;
77 }
78 free (short_name);
79 }
80 }
81 if (!result)
82 result = unlink (name);
83 return result;
84 }
0 /* Work around unlinkat bugs on Solaris 9.
1
2 Copyright (C) 2009-2010 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 /* Written by Eric Blake. */
18
19 #include <config.h>
20
21 #include <unistd.h>
22
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <string.h>
26 #include <sys/stat.h>
27
28 #include "openat.h"
29
30 #if HAVE_UNLINKAT
31
32 # undef unlinkat
33
34 /* unlinkat without AT_REMOVEDIR does not honor trailing / on Solaris
35 9. Solve it in a similar manner to unlink. */
36
37 int
38 rpl_unlinkat (int fd, char const *name, int flag)
39 {
40 size_t len;
41 int result = 0;
42 /* rmdir behavior has no problems with trailing slash. */
43 if (flag & AT_REMOVEDIR)
44 return unlinkat (fd, name, flag);
45
46 len = strlen (name);
47 if (len && ISSLASH (name[len - 1]))
48 {
49 /* See the lengthy comment in unlink.c why we disobey the POSIX
50 rule of letting unlink("link-to-dir/") attempt to unlink a
51 directory. */
52 struct stat st;
53 result = lstatat (fd, name, &st);
54 if (result == 0)
55 {
56 /* Trailing NUL will overwrite the trailing slash. */
57 char *short_name = malloc (len);
58 if (!short_name)
59 {
60 errno = EPERM;
61 return -1;
62 }
63 memcpy (short_name, name, len);
64 while (len && ISSLASH (short_name[len - 1]))
65 short_name[--len] = '\0';
66 if (len && (lstatat (fd, short_name, &st) || S_ISLNK (st.st_mode)))
67 {
68 free (short_name);
69 errno = EPERM;
70 return -1;
71 }
72 free (short_name);
73 }
74 }
75 if (!result)
76 result = unlinkat (fd, name, flag);
77 return result;
78 }
79
80 #else /* !HAVE_UNLINKAT */
81
82 /* Replacement for Solaris' function by the same name.
83 <http://www.google.com/search?q=unlinkat+site:docs.sun.com>
84 First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE").
85 Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd.
86 If either the save_cwd or the restore_cwd fails (relatively unlikely),
87 then give a diagnostic and exit nonzero.
88 Otherwise, this function works just like Solaris' unlinkat. */
89
90 # define AT_FUNC_NAME unlinkat
91 # define AT_FUNC_F1 rmdir
92 # define AT_FUNC_F2 unlink
93 # define AT_FUNC_USE_F1_COND AT_REMOVEDIR
94 # define AT_FUNC_POST_FILE_PARAM_DECLS , int flag
95 # define AT_FUNC_POST_FILE_ARGS /* empty */
96 # include "at-func.c"
97 # undef AT_FUNC_NAME
98 # undef AT_FUNC_F1
99 # undef AT_FUNC_F2
100 # undef AT_FUNC_USE_F1_COND
101 # undef AT_FUNC_POST_FILE_PARAM_DECLS
102 # undef AT_FUNC_POST_FILE_ARGS
103
104 #endif /* !HAVE_UNLINKAT */
00 /* Set file access and modification times.
11
2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
3 Software Foundation, Inc.
2 Copyright (C) 2003-2010 Free Software Foundation, Inc.
43
54 This program is free software: you can redistribute it and/or modify it
65 under the terms of the GNU General Public License as published by the
5251 #undef futimens
5352 #undef utimensat
5453
55 #if HAVE_UTIMENSAT || HAVE_FUTIMENS
56 /* Cache variable for whether syscall works; used to avoid calling the
57 syscall if we know it will just fail with ENOSYS. 0 = unknown, 1 =
58 yes, -1 = no. */
59 static int utimensat_works_really;
60 #endif /* HAVE_UTIMENSAT || HAVE_UTIMENSAT */
61
6254 /* Solaris 9 mistakenly succeeds when given a non-directory with a
6355 trailing slash. Force the use of rpl_stat for a fix. */
6456 #ifndef REPLACE_FUNC_STAT_FILE
6557 # define REPLACE_FUNC_STAT_FILE 0
6658 #endif
6759
60 #if HAVE_UTIMENSAT || HAVE_FUTIMENS
61 /* Cache variables for whether the utimensat syscall works; used to
62 avoid calling the syscall if we know it will just fail with ENOSYS,
63 and to avoid unnecessary work in massaging timestamps if the
64 syscall will work. Multiple variables are needed, to distinguish
65 between the following scenarios on Linux:
66 utimensat doesn't exist, or is in glibc but kernel 2.6.18 fails with ENOSYS
67 kernel 2.6.22 and earlier rejects AT_SYMLINK_NOFOLLOW
68 kernel 2.6.25 and earlier reject UTIME_NOW/UTIME_OMIT with non-zero tv_sec
69 kernel 2.6.32 used with xfs or ntfs-3g fail to honor UTIME_OMIT
70 utimensat completely works
71 For each cache variable: 0 = unknown, 1 = yes, -1 = no. */
72 static int utimensat_works_really;
73 static int lutimensat_works_really;
74 #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */
75
6876 /* Validate the requested timestamps. Return 0 if the resulting
6977 timespec can be used for utimensat (after possibly modifying it to
70 work around bugs in utimensat). Return 1 if the timespec needs
71 further adjustment based on stat results for utimes or other less
72 powerful interfaces. Return -1, with errno set to EINVAL, if
78 work around bugs in utimensat). Return a positive value if the
79 timespec needs further adjustment based on stat results: 1 if any
80 adjustment is needed for utimes, and 2 if any adjustment is needed
81 for Linux utimensat. Return -1, with errno set to EINVAL, if
7382 timespec is out of range. */
7483 static int
7584 validate_timespec (struct timespec timespec[2])
7685 {
7786 int result = 0;
87 int utime_omit_count = 0;
7888 assert (timespec);
7989 if ((timespec[0].tv_nsec != UTIME_NOW
8090 && timespec[0].tv_nsec != UTIME_OMIT
8797 return -1;
8898 }
8999 /* Work around Linux kernel 2.6.25 bug, where utimensat fails with
90 EINVAL if tv_sec is not 0 when using the flag values of
91 tv_nsec. */
100 EINVAL if tv_sec is not 0 when using the flag values of tv_nsec.
101 Flag a Linux kernel 2.6.32 bug, where an mtime of UTIME_OMIT
102 fails to bump ctime. */
92103 if (timespec[0].tv_nsec == UTIME_NOW
93104 || timespec[0].tv_nsec == UTIME_OMIT)
94105 {
95106 timespec[0].tv_sec = 0;
96107 result = 1;
108 if (timespec[0].tv_nsec == UTIME_OMIT)
109 utime_omit_count++;
97110 }
98111 if (timespec[1].tv_nsec == UTIME_NOW
99112 || timespec[1].tv_nsec == UTIME_OMIT)
100113 {
101114 timespec[1].tv_sec = 0;
102115 result = 1;
103 }
104 return result;
116 if (timespec[1].tv_nsec == UTIME_OMIT)
117 utime_omit_count++;
118 }
119 return result + (utime_omit_count == 1);
105120 }
106121
107122 /* Normalize any UTIME_NOW or UTIME_OMIT values in *TS, using stat
153168 struct timespec adjusted_timespec[2];
154169 struct timespec *ts = timespec ? adjusted_timespec : NULL;
155170 int adjustment_needed = 0;
171 struct stat st;
156172
157173 if (ts)
158174 {
202218 #if HAVE_UTIMENSAT || HAVE_FUTIMENS
203219 if (0 <= utimensat_works_really)
204220 {
221 int result;
222 # if __linux__
223 /* As recently as Linux kernel 2.6.32 (Dec 2009), several file
224 systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
225 but work if both times are either explicitly specified or
226 UTIME_NOW. Work around it with a preparatory [f]stat prior
227 to calling futimens/utimensat; fortunately, there is not much
228 timing impact due to the extra syscall even on file systems
229 where UTIME_OMIT would have worked. FIXME: Simplify this in
230 2012, when file system bugs are no longer common. */
231 if (adjustment_needed == 2)
232 {
233 if (fd < 0 ? stat (file, &st) : fstat (fd, &st))
234 return -1;
235 if (ts[0].tv_nsec == UTIME_OMIT)
236 ts[0] = get_stat_atime (&st);
237 else if (ts[1].tv_nsec == UTIME_OMIT)
238 ts[1] = get_stat_mtime (&st);
239 /* Note that st is good, in case utimensat gives ENOSYS. */
240 adjustment_needed++;
241 }
242 # endif /* __linux__ */
205243 # if HAVE_UTIMENSAT
206244 if (fd < 0)
207245 {
208 int result = utimensat (AT_FDCWD, file, ts, 0);
246 result = utimensat (AT_FDCWD, file, ts, 0);
209247 # ifdef __linux__
210248 /* Work around a kernel bug:
211249 http://bugzilla.redhat.com/442352
225263 }
226264 # endif /* HAVE_UTIMENSAT */
227265 # if HAVE_FUTIMENS
228 {
229 int result = futimens (fd, timespec);
266 if (0 <= fd)
267 {
268 result = futimens (fd, ts);
230269 # ifdef __linux__
231 /* Work around the same bug as above. */
232 if (0 < result)
233 errno = ENOSYS;
270 /* Work around the same bug as above. */
271 if (0 < result)
272 errno = ENOSYS;
234273 # endif /* __linux__ */
235 if (result == 0 || errno != ENOSYS)
236 {
237 utimensat_works_really = 1;
238 return result;
239 }
240 }
274 if (result == 0 || errno != ENOSYS)
275 {
276 utimensat_works_really = 1;
277 return result;
278 }
279 }
241280 # endif /* HAVE_FUTIMENS */
242281 }
243282 utimensat_works_really = -1;
283 lutimensat_works_really = -1;
244284 #endif /* HAVE_UTIMENSAT || HAVE_FUTIMENS */
245285
246286 /* The platform lacks an interface to set file timestamps with
249289
250290 if (adjustment_needed || (REPLACE_FUNC_STAT_FILE && fd < 0))
251291 {
252 struct stat st;
253 if (fd < 0 ? stat (file, &st) : fstat (fd, &st))
292 if (adjustment_needed != 3
293 && (fd < 0 ? stat (file, &st) : fstat (fd, &st)))
254294 return -1;
255295 if (ts && update_timespec (&st, &ts))
256296 return 0;
289329 worth optimizing, and who knows what other messed-up systems
290330 are out there? So play it safe and fall back on the code
291331 below. */
292 # if HAVE_FUTIMESAT
332 # if HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG
293333 if (futimesat (fd, NULL, t) == 0)
294334 return 0;
295335 # elif HAVE_FUTIMES
301341
302342 if (!file)
303343 {
304 #if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
344 #if ! ((HAVE_FUTIMESAT && !FUTIMESAT_NULL_BUG) \
345 || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
305346 errno = ENOSYS;
306347 #endif
307348 return -1;
379420 worry about bogus return values. */
380421
381422 #if HAVE_UTIMENSAT
382 if (0 <= utimensat_works_really)
383 {
384 int result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW);
423 if (0 <= lutimensat_works_really)
424 {
425 int result;
426 # if __linux__
427 /* As recently as Linux kernel 2.6.32 (Dec 2009), several file
428 systems (xfs, ntfs-3g) have bugs with a single UTIME_OMIT,
429 but work if both times are either explicitly specified or
430 UTIME_NOW. Work around it with a preparatory lstat prior to
431 calling utimensat; fortunately, there is not much timing
432 impact due to the extra syscall even on file systems where
433 UTIME_OMIT would have worked. FIXME: Simplify this in 2012,
434 when file system bugs are no longer common. */
435 if (adjustment_needed == 2)
436 {
437 if (lstat (file, &st))
438 return -1;
439 if (ts[0].tv_nsec == UTIME_OMIT)
440 ts[0] = get_stat_atime (&st);
441 else if (ts[1].tv_nsec == UTIME_OMIT)
442 ts[1] = get_stat_mtime (&st);
443 /* Note that st is good, in case utimensat gives ENOSYS. */
444 adjustment_needed++;
445 }
446 # endif /* __linux__ */
447 result = utimensat (AT_FDCWD, file, ts, AT_SYMLINK_NOFOLLOW);
385448 # ifdef __linux__
386449 /* Work around a kernel bug:
387450 http://bugzilla.redhat.com/442352
396459 if (result == 0 || errno != ENOSYS)
397460 {
398461 utimensat_works_really = 1;
462 lutimensat_works_really = 1;
399463 return result;
400464 }
401465 }
402 utimensat_works_really = -1;
466 lutimensat_works_really = -1;
403467 #endif /* HAVE_UTIMENSAT */
404468
405469 /* The platform lacks an interface to set file timestamps with
408472
409473 if (adjustment_needed || REPLACE_FUNC_STAT_FILE)
410474 {
411 if (lstat (file, &st))
475 if (adjustment_needed != 3 && lstat (file, &st))
412476 return -1;
413477 if (ts && update_timespec (&st, &ts))
414478 return 0;
415479 }
416480
417 #if HAVE_LUTIMES
481 /* On Linux, lutimes is a thin wrapper around utimensat, so there is
482 no point trying lutimes if utimensat failed with ENOSYS. */
483 #if HAVE_LUTIMES && !HAVE_UTIMENSAT
418484 {
419485 struct timeval timeval[2];
420486 struct timeval const *t;
487 int result;
421488 if (ts)
422489 {
423490 timeval[0].tv_sec = ts[0].tv_sec;
429496 else
430497 t = NULL;
431498
432 return lutimes (file, t);
499 result = lutimes (file, t);
500 if (result == 0 || errno != ENOSYS)
501 return result;
433502 }
434 #endif /* HAVE_LUTIMES */
503 #endif /* HAVE_LUTIMES && !HAVE_UTIMENSAT */
435504
436505 /* Out of luck for symlinks, but we still handle regular files. */
437506 if (!(adjustment_needed || REPLACE_FUNC_STAT_FILE) && lstat (file, &st))
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* vsprintf with automatic memory allocation.
3 Copyright (C) 1999, 2002-2009 Free Software Foundation, Inc.
3 Copyright (C) 1999, 2002-2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
6868 # endif
6969 #endif
7070
71 #include <locale.h> /* localeconv() */
72 #include <stdio.h> /* snprintf(), sprintf() */
73 #include <stdlib.h> /* abort(), malloc(), realloc(), free() */
74 #include <string.h> /* memcpy(), strlen() */
75 #include <errno.h> /* errno */
76 #include <limits.h> /* CHAR_BIT */
77 #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
71 #include <locale.h> /* localeconv() */
72 #include <stdio.h> /* snprintf(), sprintf() */
73 #include <stdlib.h> /* abort(), malloc(), realloc(), free() */
74 #include <string.h> /* memcpy(), strlen() */
75 #include <errno.h> /* errno */
76 #include <limits.h> /* CHAR_BIT */
77 #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
7878 #if HAVE_NL_LANGINFO
7979 # include <langinfo.h>
8080 #endif
262262 {
263263 const char *point;
264264 /* Determine it in a multithread-safe way. We know nl_langinfo is
265 multithread-safe on glibc systems, but is not required to be multithread-
266 safe by POSIX. sprintf(), however, is multithread-safe. localeconv()
267 is rarely multithread-safe. */
268 # if HAVE_NL_LANGINFO && __GLIBC__
265 multithread-safe on glibc systems and MacOS X systems, but is not required
266 to be multithread-safe by POSIX. sprintf(), however, is multithread-safe.
267 localeconv() is rarely multithread-safe. */
268 # if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__))
269269 point = nl_langinfo (RADIXCHAR);
270270 # elif 1
271271 char pointbuf[5];
365365 dlen = len1 + len2;
366366 dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t));
367367 if (dp == NULL)
368 return NULL;
368 return NULL;
369369 for (k = len2; k > 0; )
370 dp[--k] = 0;
370 dp[--k] = 0;
371371 for (i = 0; i < len1; i++)
372 {
373 mp_limb_t digit1 = p1[i];
374 mp_twolimb_t carry = 0;
375 for (j = 0; j < len2; j++)
376 {
377 mp_limb_t digit2 = p2[j];
378 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
379 carry += dp[i + j];
380 dp[i + j] = (mp_limb_t) carry;
381 carry = carry >> GMP_LIMB_BITS;
382 }
383 dp[i + len2] = (mp_limb_t) carry;
384 }
372 {
373 mp_limb_t digit1 = p1[i];
374 mp_twolimb_t carry = 0;
375 for (j = 0; j < len2; j++)
376 {
377 mp_limb_t digit2 = p2[j];
378 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
379 carry += dp[i + j];
380 dp[i + j] = (mp_limb_t) carry;
381 carry = carry >> GMP_LIMB_BITS;
382 }
383 dp[i + len2] = (mp_limb_t) carry;
384 }
385385 /* Normalise. */
386386 while (dlen > 0 && dp[dlen - 1] == 0)
387 dlen--;
387 dlen--;
388388 dest->nlimbs = dlen;
389389 dest->limbs = dp;
390390 }
478478 for (;;)
479479 {
480480 if (b_len == 0)
481 /* Division by zero. */
482 abort ();
481 /* Division by zero. */
482 abort ();
483483 if (b_ptr[b_len - 1] == 0)
484 b_len--;
484 b_len--;
485485 else
486 break;
486 break;
487487 }
488488
489489 /* Here m = a_len >= 0 and n = b_len > 0. */
500500 else if (b_len == 1)
501501 {
502502 /* n=1: single precision division.
503 beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */
503 beta^(m-1) <= a < beta^m ==> beta^(m-2) <= a/b < beta^m */
504504 r_ptr = roomptr;
505505 q_ptr = roomptr + 1;
506506 {
507 mp_limb_t den = b_ptr[0];
508 mp_limb_t remainder = 0;
509 const mp_limb_t *sourceptr = a_ptr + a_len;
510 mp_limb_t *destptr = q_ptr + a_len;
511 size_t count;
512 for (count = a_len; count > 0; count--)
513 {
514 mp_twolimb_t num =
515 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
516 *--destptr = num / den;
517 remainder = num % den;
518 }
519 /* Normalise and store r. */
520 if (remainder > 0)
521 {
522 r_ptr[0] = remainder;
523 r_len = 1;
524 }
525 else
526 r_len = 0;
527 /* Normalise q. */
528 q_len = a_len;
529 if (q_ptr[q_len - 1] == 0)
530 q_len--;
507 mp_limb_t den = b_ptr[0];
508 mp_limb_t remainder = 0;
509 const mp_limb_t *sourceptr = a_ptr + a_len;
510 mp_limb_t *destptr = q_ptr + a_len;
511 size_t count;
512 for (count = a_len; count > 0; count--)
513 {
514 mp_twolimb_t num =
515 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
516 *--destptr = num / den;
517 remainder = num % den;
518 }
519 /* Normalise and store r. */
520 if (remainder > 0)
521 {
522 r_ptr[0] = remainder;
523 r_len = 1;
524 }
525 else
526 r_len = 0;
527 /* Normalise q. */
528 q_len = a_len;
529 if (q_ptr[q_len - 1] == 0)
530 q_len--;
531531 }
532532 }
533533 else
534534 {
535535 /* n>1: multiple precision division.
536 beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==>
537 beta^(m-n-1) <= a/b < beta^(m-n+1). */
536 beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n ==>
537 beta^(m-n-1) <= a/b < beta^(m-n+1). */
538538 /* Determine s. */
539539 size_t s;
540540 {
541 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
542 s = 31;
543 if (msd >= 0x10000)
544 {
545 msd = msd >> 16;
546 s -= 16;
547 }
548 if (msd >= 0x100)
549 {
550 msd = msd >> 8;
551 s -= 8;
552 }
553 if (msd >= 0x10)
554 {
555 msd = msd >> 4;
556 s -= 4;
557 }
558 if (msd >= 0x4)
559 {
560 msd = msd >> 2;
561 s -= 2;
562 }
563 if (msd >= 0x2)
564 {
565 msd = msd >> 1;
566 s -= 1;
567 }
541 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
542 s = 31;
543 if (msd >= 0x10000)
544 {
545 msd = msd >> 16;
546 s -= 16;
547 }
548 if (msd >= 0x100)
549 {
550 msd = msd >> 8;
551 s -= 8;
552 }
553 if (msd >= 0x10)
554 {
555 msd = msd >> 4;
556 s -= 4;
557 }
558 if (msd >= 0x4)
559 {
560 msd = msd >> 2;
561 s -= 2;
562 }
563 if (msd >= 0x2)
564 {
565 msd = msd >> 1;
566 s -= 1;
567 }
568568 }
569569 /* 0 <= s < GMP_LIMB_BITS.
570 Copy b, shifting it left by s bits. */
570 Copy b, shifting it left by s bits. */
571571 if (s > 0)
572 {
573 tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
574 if (tmp_roomptr == NULL)
575 {
576 free (roomptr);
577 return NULL;
578 }
579 {
580 const mp_limb_t *sourceptr = b_ptr;
581 mp_limb_t *destptr = tmp_roomptr;
582 mp_twolimb_t accu = 0;
583 size_t count;
584 for (count = b_len; count > 0; count--)
585 {
586 accu += (mp_twolimb_t) *sourceptr++ << s;
587 *destptr++ = (mp_limb_t) accu;
588 accu = accu >> GMP_LIMB_BITS;
589 }
590 /* accu must be zero, since that was how s was determined. */
591 if (accu != 0)
592 abort ();
593 }
594 b_ptr = tmp_roomptr;
595 }
572 {
573 tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
574 if (tmp_roomptr == NULL)
575 {
576 free (roomptr);
577 return NULL;
578 }
579 {
580 const mp_limb_t *sourceptr = b_ptr;
581 mp_limb_t *destptr = tmp_roomptr;
582 mp_twolimb_t accu = 0;
583 size_t count;
584 for (count = b_len; count > 0; count--)
585 {
586 accu += (mp_twolimb_t) *sourceptr++ << s;
587 *destptr++ = (mp_limb_t) accu;
588 accu = accu >> GMP_LIMB_BITS;
589 }
590 /* accu must be zero, since that was how s was determined. */
591 if (accu != 0)
592 abort ();
593 }
594 b_ptr = tmp_roomptr;
595 }
596596 /* Copy a, shifting it left by s bits, yields r.
597 Memory layout:
598 At the beginning: r = roomptr[0..a_len],
599 at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */
597 Memory layout:
598 At the beginning: r = roomptr[0..a_len],
599 at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len] */
600600 r_ptr = roomptr;
601601 if (s == 0)
602 {
603 memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
604 r_ptr[a_len] = 0;
605 }
602 {
603 memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
604 r_ptr[a_len] = 0;
605 }
606606 else
607 {
608 const mp_limb_t *sourceptr = a_ptr;
609 mp_limb_t *destptr = r_ptr;
610 mp_twolimb_t accu = 0;
611 size_t count;
612 for (count = a_len; count > 0; count--)
613 {
614 accu += (mp_twolimb_t) *sourceptr++ << s;
615 *destptr++ = (mp_limb_t) accu;
616 accu = accu >> GMP_LIMB_BITS;
617 }
618 *destptr++ = (mp_limb_t) accu;
619 }
607 {
608 const mp_limb_t *sourceptr = a_ptr;
609 mp_limb_t *destptr = r_ptr;
610 mp_twolimb_t accu = 0;
611 size_t count;
612 for (count = a_len; count > 0; count--)
613 {
614 accu += (mp_twolimb_t) *sourceptr++ << s;
615 *destptr++ = (mp_limb_t) accu;
616 accu = accu >> GMP_LIMB_BITS;
617 }
618 *destptr++ = (mp_limb_t) accu;
619 }
620620 q_ptr = roomptr + b_len;
621621 q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */
622622 {
623 size_t j = a_len - b_len; /* m-n */
624 mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
625 mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
626 mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
627 ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
628 /* Division loop, traversed m-n+1 times.
629 j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */
630 for (;;)
631 {
632 mp_limb_t q_star;
633 mp_limb_t c1;
634 if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
635 {
636 /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */
637 mp_twolimb_t num =
638 ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
639 | r_ptr[j + b_len - 1];
640 q_star = num / b_msd;
641 c1 = num % b_msd;
642 }
643 else
644 {
645 /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */
646 q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
647 /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
648 <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
649 <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
650 {<= beta !}.
651 If yes, jump directly to the subtraction loop.
652 (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
653 <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
654 if (r_ptr[j + b_len] > b_msd
655 || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
656 /* r[j+n] >= b[n-1]+1 or
657 r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
658 carry. */
659 goto subtract;
660 }
661 /* q_star = q*,
662 c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */
663 {
664 mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
665 ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
666 mp_twolimb_t c3 = /* b[n-2] * q* */
667 (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
668 /* While c2 < c3, increase c2 and decrease c3.
669 Consider c3-c2. While it is > 0, decrease it by
670 b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2
671 this can happen only twice. */
672 if (c3 > c2)
673 {
674 q_star = q_star - 1; /* q* := q* - 1 */
675 if (c3 - c2 > b_msdd)
676 q_star = q_star - 1; /* q* := q* - 1 */
677 }
678 }
679 if (q_star > 0)
680 subtract:
681 {
682 /* Subtract r := r - b * q* * beta^j. */
683 mp_limb_t cr;
684 {
685 const mp_limb_t *sourceptr = b_ptr;
686 mp_limb_t *destptr = r_ptr + j;
687 mp_twolimb_t carry = 0;
688 size_t count;
689 for (count = b_len; count > 0; count--)
690 {
691 /* Here 0 <= carry <= q*. */
692 carry =
693 carry
694 + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
695 + (mp_limb_t) ~(*destptr);
696 /* Here 0 <= carry <= beta*q* + beta-1. */
697 *destptr++ = ~(mp_limb_t) carry;
698 carry = carry >> GMP_LIMB_BITS; /* <= q* */
699 }
700 cr = (mp_limb_t) carry;
701 }
702 /* Subtract cr from r_ptr[j + b_len], then forget about
703 r_ptr[j + b_len]. */
704 if (cr > r_ptr[j + b_len])
705 {
706 /* Subtraction gave a carry. */
707 q_star = q_star - 1; /* q* := q* - 1 */
708 /* Add b back. */
709 {
710 const mp_limb_t *sourceptr = b_ptr;
711 mp_limb_t *destptr = r_ptr + j;
712 mp_limb_t carry = 0;
713 size_t count;
714 for (count = b_len; count > 0; count--)
715 {
716 mp_limb_t source1 = *sourceptr++;
717 mp_limb_t source2 = *destptr;
718 *destptr++ = source1 + source2 + carry;
719 carry =
720 (carry
721 ? source1 >= (mp_limb_t) ~source2
722 : source1 > (mp_limb_t) ~source2);
723 }
724 }
725 /* Forget about the carry and about r[j+n]. */
726 }
727 }
728 /* q* is determined. Store it as q[j]. */
729 q_ptr[j] = q_star;
730 if (j == 0)
731 break;
732 j--;
733 }
623 size_t j = a_len - b_len; /* m-n */
624 mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
625 mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
626 mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
627 ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
628 /* Division loop, traversed m-n+1 times.
629 j counts down, b is unchanged, beta/2 <= b[n-1] < beta. */
630 for (;;)
631 {
632 mp_limb_t q_star;
633 mp_limb_t c1;
634 if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
635 {
636 /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow. */
637 mp_twolimb_t num =
638 ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
639 | r_ptr[j + b_len - 1];
640 q_star = num / b_msd;
641 c1 = num % b_msd;
642 }
643 else
644 {
645 /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1]. */
646 q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
647 /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
648 <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
649 <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
650 {<= beta !}.
651 If yes, jump directly to the subtraction loop.
652 (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
653 <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
654 if (r_ptr[j + b_len] > b_msd
655 || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
656 /* r[j+n] >= b[n-1]+1 or
657 r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
658 carry. */
659 goto subtract;
660 }
661 /* q_star = q*,
662 c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta). */
663 {
664 mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
665 ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
666 mp_twolimb_t c3 = /* b[n-2] * q* */
667 (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
668 /* While c2 < c3, increase c2 and decrease c3.
669 Consider c3-c2. While it is > 0, decrease it by
670 b[n-1]*beta+b[n-2]. Because of b[n-1]*beta+b[n-2] >= beta^2/2
671 this can happen only twice. */
672 if (c3 > c2)
673 {
674 q_star = q_star - 1; /* q* := q* - 1 */
675 if (c3 - c2 > b_msdd)
676 q_star = q_star - 1; /* q* := q* - 1 */
677 }
678 }
679 if (q_star > 0)
680 subtract:
681 {
682 /* Subtract r := r - b * q* * beta^j. */
683 mp_limb_t cr;
684 {
685 const mp_limb_t *sourceptr = b_ptr;
686 mp_limb_t *destptr = r_ptr + j;
687 mp_twolimb_t carry = 0;
688 size_t count;
689 for (count = b_len; count > 0; count--)
690 {
691 /* Here 0 <= carry <= q*. */
692 carry =
693 carry
694 + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
695 + (mp_limb_t) ~(*destptr);
696 /* Here 0 <= carry <= beta*q* + beta-1. */
697 *destptr++ = ~(mp_limb_t) carry;
698 carry = carry >> GMP_LIMB_BITS; /* <= q* */
699 }
700 cr = (mp_limb_t) carry;
701 }
702 /* Subtract cr from r_ptr[j + b_len], then forget about
703 r_ptr[j + b_len]. */
704 if (cr > r_ptr[j + b_len])
705 {
706 /* Subtraction gave a carry. */
707 q_star = q_star - 1; /* q* := q* - 1 */
708 /* Add b back. */
709 {
710 const mp_limb_t *sourceptr = b_ptr;
711 mp_limb_t *destptr = r_ptr + j;
712 mp_limb_t carry = 0;
713 size_t count;
714 for (count = b_len; count > 0; count--)
715 {
716 mp_limb_t source1 = *sourceptr++;
717 mp_limb_t source2 = *destptr;
718 *destptr++ = source1 + source2 + carry;
719 carry =
720 (carry
721 ? source1 >= (mp_limb_t) ~source2
722 : source1 > (mp_limb_t) ~source2);
723 }
724 }
725 /* Forget about the carry and about r[j+n]. */
726 }
727 }
728 /* q* is determined. Store it as q[j]. */
729 q_ptr[j] = q_star;
730 if (j == 0)
731 break;
732 j--;
733 }
734734 }
735735 r_len = b_len;
736736 /* Normalise q. */
737737 if (q_ptr[q_len - 1] == 0)
738 q_len--;
738 q_len--;
739739 # if 0 /* Not needed here, since we need r only to compare it with b/2, and
740 b is shifted left by s bits. */
740 b is shifted left by s bits. */
741741 /* Shift r right by s bits. */
742742 if (s > 0)
743 {
744 mp_limb_t ptr = r_ptr + r_len;
745 mp_twolimb_t accu = 0;
746 size_t count;
747 for (count = r_len; count > 0; count--)
748 {
749 accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
750 accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
751 *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
752 }
753 }
743 {
744 mp_limb_t ptr = r_ptr + r_len;
745 mp_twolimb_t accu = 0;
746 size_t count;
747 for (count = r_len; count > 0; count--)
748 {
749 accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
750 accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
751 *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
752 }
753 }
754754 # endif
755755 /* Normalise r. */
756756 while (r_len > 0 && r_ptr[r_len - 1] == 0)
757 r_len--;
757 r_len--;
758758 }
759759 /* Compare r << 1 with b. */
760760 if (r_len > b_len)
763763 size_t i;
764764 for (i = b_len;;)
765765 {
766 mp_limb_t r_i =
767 (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
768 | (i < r_len ? r_ptr[i] << 1 : 0);
769 mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
770 if (r_i > b_i)
771 goto increment_q;
772 if (r_i < b_i)
773 goto keep_q;
774 if (i == 0)
775 break;
776 i--;
766 mp_limb_t r_i =
767 (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
768 | (i < r_len ? r_ptr[i] << 1 : 0);
769 mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
770 if (r_i > b_i)
771 goto increment_q;
772 if (r_i < b_i)
773 goto keep_q;
774 if (i == 0)
775 break;
776 i--;
777777 }
778778 }
779779 if (q_len > 0 && ((q_ptr[0] & 1) != 0))
782782 {
783783 size_t i;
784784 for (i = 0; i < q_len; i++)
785 if (++(q_ptr[i]) != 0)
786 goto keep_q;
785 if (++(q_ptr[i]) != 0)
786 goto keep_q;
787787 q_ptr[q_len++] = 1;
788788 }
789789 keep_q:
812812 {
813813 char *d_ptr = c_ptr;
814814 for (; extra_zeroes > 0; extra_zeroes--)
815 *d_ptr++ = '0';
815 *d_ptr++ = '0';
816816 while (a_len > 0)
817 {
818 /* Divide a by 10^9, in-place. */
819 mp_limb_t remainder = 0;
820 mp_limb_t *ptr = a_ptr + a_len;
821 size_t count;
822 for (count = a_len; count > 0; count--)
823 {
824 mp_twolimb_t num =
825 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
826 *ptr = num / 1000000000;
827 remainder = num % 1000000000;
828 }
829 /* Store the remainder as 9 decimal digits. */
830 for (count = 9; count > 0; count--)
831 {
832 *d_ptr++ = '0' + (remainder % 10);
833 remainder = remainder / 10;
834 }
835 /* Normalize a. */
836 if (a_ptr[a_len - 1] == 0)
837 a_len--;
838 }
817 {
818 /* Divide a by 10^9, in-place. */
819 mp_limb_t remainder = 0;
820 mp_limb_t *ptr = a_ptr + a_len;
821 size_t count;
822 for (count = a_len; count > 0; count--)
823 {
824 mp_twolimb_t num =
825 ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
826 *ptr = num / 1000000000;
827 remainder = num % 1000000000;
828 }
829 /* Store the remainder as 9 decimal digits. */
830 for (count = 9; count > 0; count--)
831 {
832 *d_ptr++ = '0' + (remainder % 10);
833 remainder = remainder / 10;
834 }
835 /* Normalize a. */
836 if (a_ptr[a_len - 1] == 0)
837 a_len--;
838 }
839839 /* Remove leading zeroes. */
840840 while (d_ptr > c_ptr && d_ptr[-1] == '0')
841 d_ptr--;
841 d_ptr--;
842842 /* But keep at least one zero. */
843843 if (d_ptr == c_ptr)
844 *d_ptr++ = '0';
844 *d_ptr++ = '0';
845845 /* Terminate the string. */
846846 *d_ptr = '\0';
847847 }
886886 hi = (int) y;
887887 y -= hi;
888888 if (!(y >= 0.0L && y < 1.0L))
889 abort ();
889 abort ();
890890 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
891891 lo = (int) y;
892892 y -= lo;
893893 if (!(y >= 0.0L && y < 1.0L))
894 abort ();
894 abort ();
895895 m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
896896 }
897897 # else
901901 d = (int) y;
902902 y -= d;
903903 if (!(y >= 0.0L && y < 1.0L))
904 abort ();
904 abort ();
905905 m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d;
906906 }
907907 # endif
913913 hi = (int) y;
914914 y -= hi;
915915 if (!(y >= 0.0L && y < 1.0L))
916 abort ();
916 abort ();
917917 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
918918 lo = (int) y;
919919 y -= lo;
920920 if (!(y >= 0.0L && y < 1.0L))
921 abort ();
921 abort ();
922922 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
923923 }
924924 #if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
974974 hi = (int) y;
975975 y -= hi;
976976 if (!(y >= 0.0 && y < 1.0))
977 abort ();
977 abort ();
978978 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
979979 lo = (int) y;
980980 y -= lo;
981981 if (!(y >= 0.0 && y < 1.0))
982 abort ();
982 abort ();
983983 m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
984984 }
985985 # else
989989 d = (int) y;
990990 y -= d;
991991 if (!(y >= 0.0 && y < 1.0))
992 abort ();
992 abort ();
993993 m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d;
994994 }
995995 # endif
10011001 hi = (int) y;
10021002 y -= hi;
10031003 if (!(y >= 0.0 && y < 1.0))
1004 abort ();
1004 abort ();
10051005 y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
10061006 lo = (int) y;
10071007 y -= lo;
10081008 if (!(y >= 0.0 && y < 1.0))
1009 abort ();
1009 abort ();
10101010 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
10111011 }
10121012 if (!(y == 0.0))
10641064 abs_n = (n >= 0 ? n : -n);
10651065 abs_s = (s >= 0 ? s : -s);
10661066 pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
1067 + abs_s / GMP_LIMB_BITS + 1)
1068 * sizeof (mp_limb_t));
1067 + abs_s / GMP_LIMB_BITS + 1)
1068 * sizeof (mp_limb_t));
10691069 if (pow5_ptr == NULL)
10701070 {
10711071 free (memory);
10781078 if (abs_n > 0)
10791079 {
10801080 static mp_limb_t const small_pow5[13 + 1] =
1081 {
1082 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
1083 48828125, 244140625, 1220703125
1084 };
1081 {
1082 1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
1083 48828125, 244140625, 1220703125
1084 };
10851085 unsigned int n13;
10861086 for (n13 = 0; n13 <= abs_n; n13 += 13)
1087 {
1088 mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
1089 size_t j;
1090 mp_twolimb_t carry = 0;
1091 for (j = 0; j < pow5_len; j++)
1092 {
1093 mp_limb_t digit2 = pow5_ptr[j];
1094 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
1095 pow5_ptr[j] = (mp_limb_t) carry;
1096 carry = carry >> GMP_LIMB_BITS;
1097 }
1098 if (carry > 0)
1099 pow5_ptr[pow5_len++] = (mp_limb_t) carry;
1100 }
1087 {
1088 mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
1089 size_t j;
1090 mp_twolimb_t carry = 0;
1091 for (j = 0; j < pow5_len; j++)
1092 {
1093 mp_limb_t digit2 = pow5_ptr[j];
1094 carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
1095 pow5_ptr[j] = (mp_limb_t) carry;
1096 carry = carry >> GMP_LIMB_BITS;
1097 }
1098 if (carry > 0)
1099 pow5_ptr[pow5_len++] = (mp_limb_t) carry;
1100 }
11011101 }
11021102 s_limbs = abs_s / GMP_LIMB_BITS;
11031103 s_bits = abs_s % GMP_LIMB_BITS;
11051105 {
11061106 /* Multiply with 2^|s|. */
11071107 if (s_bits > 0)
1108 {
1109 mp_limb_t *ptr = pow5_ptr;
1110 mp_twolimb_t accu = 0;
1111 size_t count;
1112 for (count = pow5_len; count > 0; count--)
1113 {
1114 accu += (mp_twolimb_t) *ptr << s_bits;
1115 *ptr++ = (mp_limb_t) accu;
1116 accu = accu >> GMP_LIMB_BITS;
1117 }
1118 if (accu > 0)
1119 {
1120 *ptr = (mp_limb_t) accu;
1121 pow5_len++;
1122 }
1123 }
1108 {
1109 mp_limb_t *ptr = pow5_ptr;
1110 mp_twolimb_t accu = 0;
1111 size_t count;
1112 for (count = pow5_len; count > 0; count--)
1113 {
1114 accu += (mp_twolimb_t) *ptr << s_bits;
1115 *ptr++ = (mp_limb_t) accu;
1116 accu = accu >> GMP_LIMB_BITS;
1117 }
1118 if (accu > 0)
1119 {
1120 *ptr = (mp_limb_t) accu;
1121 pow5_len++;
1122 }
1123 }
11241124 if (s_limbs > 0)
1125 {
1126 size_t count;
1127 for (count = pow5_len; count > 0;)
1128 {
1129 count--;
1130 pow5_ptr[s_limbs + count] = pow5_ptr[count];
1131 }
1132 for (count = s_limbs; count > 0;)
1133 {
1134 count--;
1135 pow5_ptr[count] = 0;
1136 }
1137 pow5_len += s_limbs;
1138 }
1125 {
1126 size_t count;
1127 for (count = pow5_len; count > 0;)
1128 {
1129 count--;
1130 pow5_ptr[s_limbs + count] = pow5_ptr[count];
1131 }
1132 for (count = s_limbs; count > 0;)
1133 {
1134 count--;
1135 pow5_ptr[count] = 0;
1136 }
1137 pow5_len += s_limbs;
1138 }
11391139 pow5.limbs = pow5_ptr;
11401140 pow5.nlimbs = pow5_len;
11411141 if (n >= 0)
1142 {
1143 /* Multiply m with pow5. No division needed. */
1144 z_memory = multiply (m, pow5, &z);
1145 }
1142 {
1143 /* Multiply m with pow5. No division needed. */
1144 z_memory = multiply (m, pow5, &z);
1145 }
11461146 else
1147 {
1148 /* Divide m by pow5 and round. */
1149 z_memory = divide (m, pow5, &z);
1150 }
1147 {
1148 /* Divide m by pow5 and round. */
1149 z_memory = divide (m, pow5, &z);
1150 }
11511151 }
11521152 else
11531153 {
11541154 pow5.limbs = pow5_ptr;
11551155 pow5.nlimbs = pow5_len;
11561156 if (n >= 0)
1157 {
1158 /* n >= 0, s < 0.
1159 Multiply m with pow5, then divide by 2^|s|. */
1160 mpn_t numerator;
1161 mpn_t denominator;
1162 void *tmp_memory;
1163 tmp_memory = multiply (m, pow5, &numerator);
1164 if (tmp_memory == NULL)
1165 {
1166 free (pow5_ptr);
1167 free (memory);
1168 return NULL;
1169 }
1170 /* Construct 2^|s|. */
1171 {
1172 mp_limb_t *ptr = pow5_ptr + pow5_len;
1173 size_t i;
1174 for (i = 0; i < s_limbs; i++)
1175 ptr[i] = 0;
1176 ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
1177 denominator.limbs = ptr;
1178 denominator.nlimbs = s_limbs + 1;
1179 }
1180 z_memory = divide (numerator, denominator, &z);
1181 free (tmp_memory);
1182 }
1157 {
1158 /* n >= 0, s < 0.
1159 Multiply m with pow5, then divide by 2^|s|. */
1160 mpn_t numerator;
1161 mpn_t denominator;
1162 void *tmp_memory;
1163 tmp_memory = multiply (m, pow5, &numerator);
1164 if (tmp_memory == NULL)
1165 {
1166 free (pow5_ptr);
1167 free (memory);
1168 return NULL;
1169 }
1170 /* Construct 2^|s|. */
1171 {
1172 mp_limb_t *ptr = pow5_ptr + pow5_len;
1173 size_t i;
1174 for (i = 0; i < s_limbs; i++)
1175 ptr[i] = 0;
1176 ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
1177 denominator.limbs = ptr;
1178 denominator.nlimbs = s_limbs + 1;
1179 }
1180 z_memory = divide (numerator, denominator, &z);
1181 free (tmp_memory);
1182 }
11831183 else
1184 {
1185 /* n < 0, s > 0.
1186 Multiply m with 2^s, then divide by pow5. */
1187 mpn_t numerator;
1188 mp_limb_t *num_ptr;
1189 num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
1190 * sizeof (mp_limb_t));
1191 if (num_ptr == NULL)
1192 {
1193 free (pow5_ptr);
1194 free (memory);
1195 return NULL;
1196 }
1197 {
1198 mp_limb_t *destptr = num_ptr;
1199 {
1200 size_t i;
1201 for (i = 0; i < s_limbs; i++)
1202 *destptr++ = 0;
1203 }
1204 if (s_bits > 0)
1205 {
1206 const mp_limb_t *sourceptr = m.limbs;
1207 mp_twolimb_t accu = 0;
1208 size_t count;
1209 for (count = m.nlimbs; count > 0; count--)
1210 {
1211 accu += (mp_twolimb_t) *sourceptr++ << s_bits;
1212 *destptr++ = (mp_limb_t) accu;
1213 accu = accu >> GMP_LIMB_BITS;
1214 }
1215 if (accu > 0)
1216 *destptr++ = (mp_limb_t) accu;
1217 }
1218 else
1219 {
1220 const mp_limb_t *sourceptr = m.limbs;
1221 size_t count;
1222 for (count = m.nlimbs; count > 0; count--)
1223 *destptr++ = *sourceptr++;
1224 }
1225 numerator.limbs = num_ptr;
1226 numerator.nlimbs = destptr - num_ptr;
1227 }
1228 z_memory = divide (numerator, pow5, &z);
1229 free (num_ptr);
1230 }
1184 {
1185 /* n < 0, s > 0.
1186 Multiply m with 2^s, then divide by pow5. */
1187 mpn_t numerator;
1188 mp_limb_t *num_ptr;
1189 num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
1190 * sizeof (mp_limb_t));
1191 if (num_ptr == NULL)
1192 {
1193 free (pow5_ptr);
1194 free (memory);
1195 return NULL;
1196 }
1197 {
1198 mp_limb_t *destptr = num_ptr;
1199 {
1200 size_t i;
1201 for (i = 0; i < s_limbs; i++)
1202 *destptr++ = 0;
1203 }
1204 if (s_bits > 0)
1205 {
1206 const mp_limb_t *sourceptr = m.limbs;
1207 mp_twolimb_t accu = 0;
1208 size_t count;
1209 for (count = m.nlimbs; count > 0; count--)
1210 {
1211 accu += (mp_twolimb_t) *sourceptr++ << s_bits;
1212 *destptr++ = (mp_limb_t) accu;
1213 accu = accu >> GMP_LIMB_BITS;
1214 }
1215 if (accu > 0)
1216 *destptr++ = (mp_limb_t) accu;
1217 }
1218 else
1219 {
1220 const mp_limb_t *sourceptr = m.limbs;
1221 size_t count;
1222 for (count = m.nlimbs; count > 0; count--)
1223 *destptr++ = *sourceptr++;
1224 }
1225 numerator.limbs = num_ptr;
1226 numerator.nlimbs = destptr - num_ptr;
1227 }
1228 z_memory = divide (numerator, pow5, &z);
1229 free (num_ptr);
1230 }
12311231 }
12321232 free (pow5_ptr);
12331233 free (memory);
12991299 if (y < 0.5L)
13001300 {
13011301 while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
1302 {
1303 y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
1304 exp -= GMP_LIMB_BITS;
1305 }
1302 {
1303 y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
1304 exp -= GMP_LIMB_BITS;
1305 }
13061306 if (y < (1.0L / (1 << 16)))
1307 {
1308 y *= 1.0L * (1 << 16);
1309 exp -= 16;
1310 }
1307 {
1308 y *= 1.0L * (1 << 16);
1309 exp -= 16;
1310 }
13111311 if (y < (1.0L / (1 << 8)))
1312 {
1313 y *= 1.0L * (1 << 8);
1314 exp -= 8;
1315 }
1312 {
1313 y *= 1.0L * (1 << 8);
1314 exp -= 8;
1315 }
13161316 if (y < (1.0L / (1 << 4)))
1317 {
1318 y *= 1.0L * (1 << 4);
1319 exp -= 4;
1320 }
1317 {
1318 y *= 1.0L * (1 << 4);
1319 exp -= 4;
1320 }
13211321 if (y < (1.0L / (1 << 2)))
1322 {
1323 y *= 1.0L * (1 << 2);
1324 exp -= 2;
1325 }
1322 {
1323 y *= 1.0L * (1 << 2);
1324 exp -= 2;
1325 }
13261326 if (y < (1.0L / (1 << 1)))
1327 {
1328 y *= 1.0L * (1 << 1);
1329 exp -= 1;
1330 }
1327 {
1328 y *= 1.0L * (1 << 1);
1329 exp -= 1;
1330 }
13311331 }
13321332 if (!(y >= 0.5L && y < 1.0L))
13331333 abort ();
13901390 if (y < 0.5)
13911391 {
13921392 while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
1393 {
1394 y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
1395 exp -= GMP_LIMB_BITS;
1396 }
1393 {
1394 y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
1395 exp -= GMP_LIMB_BITS;
1396 }
13971397 if (y < (1.0 / (1 << 16)))
1398 {
1399 y *= 1.0 * (1 << 16);
1400 exp -= 16;
1401 }
1398 {
1399 y *= 1.0 * (1 << 16);
1400 exp -= 16;
1401 }
14021402 if (y < (1.0 / (1 << 8)))
1403 {
1404 y *= 1.0 * (1 << 8);
1405 exp -= 8;
1406 }
1403 {
1404 y *= 1.0 * (1 << 8);
1405 exp -= 8;
1406 }
14071407 if (y < (1.0 / (1 << 4)))
1408 {
1409 y *= 1.0 * (1 << 4);
1410 exp -= 4;
1411 }
1408 {
1409 y *= 1.0 * (1 << 4);
1410 exp -= 4;
1411 }
14121412 if (y < (1.0 / (1 << 2)))
1413 {
1414 y *= 1.0 * (1 << 2);
1415 exp -= 2;
1416 }
1413 {
1414 y *= 1.0 * (1 << 2);
1415 exp -= 2;
1416 }
14171417 if (y < (1.0 / (1 << 1)))
1418 {
1419 y *= 1.0 * (1 << 1);
1420 exp -= 1;
1421 }
1418 {
1419 y *= 1.0 * (1 << 1);
1420 exp -= 1;
1421 }
14221422 }
14231423 if (!(y >= 0.5 && y < 1.0))
14241424 abort ();
14771477
14781478 DCHAR_T *
14791479 VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1480 const FCHAR_T *format, va_list args)
1480 const FCHAR_T *format, va_list args)
14811481 {
14821482 DIRECTIVES d;
14831483 arguments a;
14871487 return NULL;
14881488
14891489 #define CLEANUP() \
1490 free (d.dir); \
1491 if (a.arg) \
1490 free (d.dir); \
1491 if (a.arg) \
14921492 free (a.arg);
14931493
14941494 if (PRINTF_FETCHARGS (args, &a) < 0)
15171517 #if HAVE_ALLOCA
15181518 if (buf_neededlength < 4000 / sizeof (TCHAR_T))
15191519 {
1520 buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
1521 buf_malloced = NULL;
1520 buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
1521 buf_malloced = NULL;
15221522 }
15231523 else
15241524 #endif
15251525 {
1526 size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
1527 if (size_overflow_p (buf_memsize))
1528 goto out_of_memory_1;
1529 buf = (TCHAR_T *) malloc (buf_memsize);
1530 if (buf == NULL)
1531 goto out_of_memory_1;
1532 buf_malloced = buf;
1526 size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
1527 if (size_overflow_p (buf_memsize))
1528 goto out_of_memory_1;
1529 buf = (TCHAR_T *) malloc (buf_memsize);
1530 if (buf == NULL)
1531 goto out_of_memory_1;
1532 buf_malloced = buf;
15331533 }
15341534
15351535 if (resultbuf != NULL)
15361536 {
1537 result = resultbuf;
1538 allocated = *lengthp;
1537 result = resultbuf;
1538 allocated = *lengthp;
15391539 }
15401540 else
15411541 {
1542 result = NULL;
1543 allocated = 0;
1542 result = NULL;
1543 allocated = 0;
15441544 }
15451545 length = 0;
15461546 /* Invariants:
15501550 /* Ensures that allocated >= needed. Aborts through a jump to
15511551 out_of_memory if needed is SIZE_MAX or otherwise too big. */
15521552 #define ENSURE_ALLOCATION(needed) \
1553 if ((needed) > allocated) \
1554 { \
1555 size_t memory_size; \
1556 DCHAR_T *memory; \
1557 \
1558 allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
1559 if ((needed) > allocated) \
1560 allocated = (needed); \
1561 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
1562 if (size_overflow_p (memory_size)) \
1563 goto out_of_memory; \
1564 if (result == resultbuf || result == NULL) \
1565 memory = (DCHAR_T *) malloc (memory_size); \
1566 else \
1567 memory = (DCHAR_T *) realloc (result, memory_size); \
1568 if (memory == NULL) \
1569 goto out_of_memory; \
1570 if (result == resultbuf && length > 0) \
1571 DCHAR_CPY (memory, result, length); \
1572 result = memory; \
1553 if ((needed) > allocated) \
1554 { \
1555 size_t memory_size; \
1556 DCHAR_T *memory; \
1557 \
1558 allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
1559 if ((needed) > allocated) \
1560 allocated = (needed); \
1561 memory_size = xtimes (allocated, sizeof (DCHAR_T)); \
1562 if (size_overflow_p (memory_size)) \
1563 goto out_of_memory; \
1564 if (result == resultbuf || result == NULL) \
1565 memory = (DCHAR_T *) malloc (memory_size); \
1566 else \
1567 memory = (DCHAR_T *) realloc (result, memory_size); \
1568 if (memory == NULL) \
1569 goto out_of_memory; \
1570 if (result == resultbuf && length > 0) \
1571 DCHAR_CPY (memory, result, length); \
1572 result = memory; \
15731573 }
15741574
15751575 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
15761576 {
1577 if (cp != dp->dir_start)
1578 {
1579 size_t n = dp->dir_start - cp;
1580 size_t augmented_length = xsum (length, n);
1581
1582 ENSURE_ALLOCATION (augmented_length);
1583 /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we
1584 need that the format string contains only ASCII characters
1585 if FCHAR_T and DCHAR_T are not the same type. */
1586 if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
1587 {
1588 DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
1589 length = augmented_length;
1590 }
1591 else
1592 {
1593 do
1594 result[length++] = (unsigned char) *cp++;
1595 while (--n > 0);
1596 }
1597 }
1598 if (i == d.count)
1599 break;
1600
1601 /* Execute a single directive. */
1602 if (dp->conversion == '%')
1603 {
1604 size_t augmented_length;
1605
1606 if (!(dp->arg_index == ARG_NONE))
1607 abort ();
1608 augmented_length = xsum (length, 1);
1609 ENSURE_ALLOCATION (augmented_length);
1610 result[length] = '%';
1611 length = augmented_length;
1612 }
1613 else
1614 {
1615 if (!(dp->arg_index != ARG_NONE))
1616 abort ();
1617
1618 if (dp->conversion == 'n')
1619 {
1620 switch (a.arg[dp->arg_index].type)
1621 {
1622 case TYPE_COUNT_SCHAR_POINTER:
1623 *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
1624 break;
1625 case TYPE_COUNT_SHORT_POINTER:
1626 *a.arg[dp->arg_index].a.a_count_short_pointer = length;
1627 break;
1628 case TYPE_COUNT_INT_POINTER:
1629 *a.arg[dp->arg_index].a.a_count_int_pointer = length;
1630 break;
1631 case TYPE_COUNT_LONGINT_POINTER:
1632 *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
1633 break;
1577 if (cp != dp->dir_start)
1578 {
1579 size_t n = dp->dir_start - cp;
1580 size_t augmented_length = xsum (length, n);
1581
1582 ENSURE_ALLOCATION (augmented_length);
1583 /* This copies a piece of FCHAR_T[] into a DCHAR_T[]. Here we
1584 need that the format string contains only ASCII characters
1585 if FCHAR_T and DCHAR_T are not the same type. */
1586 if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
1587 {
1588 DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
1589 length = augmented_length;
1590 }
1591 else
1592 {
1593 do
1594 result[length++] = (unsigned char) *cp++;
1595 while (--n > 0);
1596 }
1597 }
1598 if (i == d.count)
1599 break;
1600
1601 /* Execute a single directive. */
1602 if (dp->conversion == '%')
1603 {
1604 size_t augmented_length;
1605
1606 if (!(dp->arg_index == ARG_NONE))
1607 abort ();
1608 augmented_length = xsum (length, 1);
1609 ENSURE_ALLOCATION (augmented_length);
1610 result[length] = '%';
1611 length = augmented_length;
1612 }
1613 else
1614 {
1615 if (!(dp->arg_index != ARG_NONE))
1616 abort ();
1617
1618 if (dp->conversion == 'n')
1619 {
1620 switch (a.arg[dp->arg_index].type)
1621 {
1622 case TYPE_COUNT_SCHAR_POINTER:
1623 *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
1624 break;
1625 case TYPE_COUNT_SHORT_POINTER:
1626 *a.arg[dp->arg_index].a.a_count_short_pointer = length;
1627 break;
1628 case TYPE_COUNT_INT_POINTER:
1629 *a.arg[dp->arg_index].a.a_count_int_pointer = length;
1630 break;
1631 case TYPE_COUNT_LONGINT_POINTER:
1632 *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
1633 break;
16341634 #if HAVE_LONG_LONG_INT
1635 case TYPE_COUNT_LONGLONGINT_POINTER:
1636 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
1637 break;
1638 #endif
1639 default:
1640 abort ();
1641 }
1642 }
1635 case TYPE_COUNT_LONGLONGINT_POINTER:
1636 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
1637 break;
1638 #endif
1639 default:
1640 abort ();
1641 }
1642 }
16431643 #if ENABLE_UNISTDIO
1644 /* The unistdio extensions. */
1645 else if (dp->conversion == 'U')
1646 {
1647 arg_type type = a.arg[dp->arg_index].type;
1648 int flags = dp->flags;
1649 int has_width;
1650 size_t width;
1651 int has_precision;
1652 size_t precision;
1653
1654 has_width = 0;
1655 width = 0;
1656 if (dp->width_start != dp->width_end)
1657 {
1658 if (dp->width_arg_index != ARG_NONE)
1659 {
1660 int arg;
1661
1662 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
1663 abort ();
1664 arg = a.arg[dp->width_arg_index].a.a_int;
1665 if (arg < 0)
1666 {
1667 /* "A negative field width is taken as a '-' flag
1668 followed by a positive field width." */
1669 flags |= FLAG_LEFT;
1670 width = (unsigned int) (-arg);
1671 }
1672 else
1673 width = arg;
1674 }
1675 else
1676 {
1677 const FCHAR_T *digitp = dp->width_start;
1678
1679 do
1680 width = xsum (xtimes (width, 10), *digitp++ - '0');
1681 while (digitp != dp->width_end);
1682 }
1683 has_width = 1;
1684 }
1685
1686 has_precision = 0;
1687 precision = 0;
1688 if (dp->precision_start != dp->precision_end)
1689 {
1690 if (dp->precision_arg_index != ARG_NONE)
1691 {
1692 int arg;
1693
1694 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
1695 abort ();
1696 arg = a.arg[dp->precision_arg_index].a.a_int;
1697 /* "A negative precision is taken as if the precision
1698 were omitted." */
1699 if (arg >= 0)
1700 {
1701 precision = arg;
1702 has_precision = 1;
1703 }
1704 }
1705 else
1706 {
1707 const FCHAR_T *digitp = dp->precision_start + 1;
1708
1709 precision = 0;
1710 while (digitp != dp->precision_end)
1711 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
1712 has_precision = 1;
1713 }
1714 }
1715
1716 switch (type)
1717 {
1718 case TYPE_U8_STRING:
1719 {
1720 const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
1721 const uint8_t *arg_end;
1722 size_t characters;
1723
1724 if (has_precision)
1725 {
1726 /* Use only PRECISION characters, from the left. */
1727 arg_end = arg;
1728 characters = 0;
1729 for (; precision > 0; precision--)
1730 {
1731 int count = u8_strmblen (arg_end);
1732 if (count == 0)
1733 break;
1734 if (count < 0)
1735 {
1736 if (!(result == resultbuf || result == NULL))
1737 free (result);
1738 if (buf_malloced != NULL)
1739 free (buf_malloced);
1740 CLEANUP ();
1741 errno = EILSEQ;
1742 return NULL;
1743 }
1744 arg_end += count;
1745 characters++;
1746 }
1747 }
1748 else if (has_width)
1749 {
1750 /* Use the entire string, and count the number of
1751 characters. */
1752 arg_end = arg;
1753 characters = 0;
1754 for (;;)
1755 {
1756 int count = u8_strmblen (arg_end);
1757 if (count == 0)
1758 break;
1759 if (count < 0)
1760 {
1761 if (!(result == resultbuf || result == NULL))
1762 free (result);
1763 if (buf_malloced != NULL)
1764 free (buf_malloced);
1765 CLEANUP ();
1766 errno = EILSEQ;
1767 return NULL;
1768 }
1769 arg_end += count;
1770 characters++;
1771 }
1772 }
1773 else
1774 {
1775 /* Use the entire string. */
1776 arg_end = arg + u8_strlen (arg);
1777 /* The number of characters doesn't matter. */
1778 characters = 0;
1779 }
1780
1781 if (has_width && width > characters
1782 && !(dp->flags & FLAG_LEFT))
1783 {
1784 size_t n = width - characters;
1785 ENSURE_ALLOCATION (xsum (length, n));
1786 DCHAR_SET (result + length, ' ', n);
1787 length += n;
1788 }
1644 /* The unistdio extensions. */
1645 else if (dp->conversion == 'U')
1646 {
1647 arg_type type = a.arg[dp->arg_index].type;
1648 int flags = dp->flags;
1649 int has_width;
1650 size_t width;
1651 int has_precision;
1652 size_t precision;
1653
1654 has_width = 0;
1655 width = 0;
1656 if (dp->width_start != dp->width_end)
1657 {
1658 if (dp->width_arg_index != ARG_NONE)
1659 {
1660 int arg;
1661
1662 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
1663 abort ();
1664 arg = a.arg[dp->width_arg_index].a.a_int;
1665 if (arg < 0)
1666 {
1667 /* "A negative field width is taken as a '-' flag
1668 followed by a positive field width." */
1669 flags |= FLAG_LEFT;
1670 width = (unsigned int) (-arg);
1671 }
1672 else
1673 width = arg;
1674 }
1675 else
1676 {
1677 const FCHAR_T *digitp = dp->width_start;
1678
1679 do
1680 width = xsum (xtimes (width, 10), *digitp++ - '0');
1681 while (digitp != dp->width_end);
1682 }
1683 has_width = 1;
1684 }
1685
1686 has_precision = 0;
1687 precision = 0;
1688 if (dp->precision_start != dp->precision_end)
1689 {
1690 if (dp->precision_arg_index != ARG_NONE)
1691 {
1692 int arg;
1693
1694 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
1695 abort ();
1696 arg = a.arg[dp->precision_arg_index].a.a_int;
1697 /* "A negative precision is taken as if the precision
1698 were omitted." */
1699 if (arg >= 0)
1700 {
1701 precision = arg;
1702 has_precision = 1;
1703 }
1704 }
1705 else
1706 {
1707 const FCHAR_T *digitp = dp->precision_start + 1;
1708
1709 precision = 0;
1710 while (digitp != dp->precision_end)
1711 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
1712 has_precision = 1;
1713 }
1714 }
1715
1716 switch (type)
1717 {
1718 case TYPE_U8_STRING:
1719 {
1720 const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
1721 const uint8_t *arg_end;
1722 size_t characters;
1723
1724 if (has_precision)
1725 {
1726 /* Use only PRECISION characters, from the left. */
1727 arg_end = arg;
1728 characters = 0;
1729 for (; precision > 0; precision--)
1730 {
1731 int count = u8_strmblen (arg_end);
1732 if (count == 0)
1733 break;
1734 if (count < 0)
1735 {
1736 if (!(result == resultbuf || result == NULL))
1737 free (result);
1738 if (buf_malloced != NULL)
1739 free (buf_malloced);
1740 CLEANUP ();
1741 errno = EILSEQ;
1742 return NULL;
1743 }
1744 arg_end += count;
1745 characters++;
1746 }
1747 }
1748 else if (has_width)
1749 {
1750 /* Use the entire string, and count the number of
1751 characters. */
1752 arg_end = arg;
1753 characters = 0;
1754 for (;;)
1755 {
1756 int count = u8_strmblen (arg_end);
1757 if (count == 0)
1758 break;
1759 if (count < 0)
1760 {
1761 if (!(result == resultbuf || result == NULL))
1762 free (result);
1763 if (buf_malloced != NULL)
1764 free (buf_malloced);
1765 CLEANUP ();
1766 errno = EILSEQ;
1767 return NULL;
1768 }
1769 arg_end += count;
1770 characters++;
1771 }
1772 }
1773 else
1774 {
1775 /* Use the entire string. */
1776 arg_end = arg + u8_strlen (arg);
1777 /* The number of characters doesn't matter. */
1778 characters = 0;
1779 }
1780
1781 if (has_width && width > characters
1782 && !(dp->flags & FLAG_LEFT))
1783 {
1784 size_t n = width - characters;
1785 ENSURE_ALLOCATION (xsum (length, n));
1786 DCHAR_SET (result + length, ' ', n);
1787 length += n;
1788 }
17891789
17901790 # if DCHAR_IS_UINT8_T
1791 {
1792 size_t n = arg_end - arg;
1793 ENSURE_ALLOCATION (xsum (length, n));
1794 DCHAR_CPY (result + length, arg, n);
1795 length += n;
1796 }
1791 {
1792 size_t n = arg_end - arg;
1793 ENSURE_ALLOCATION (xsum (length, n));
1794 DCHAR_CPY (result + length, arg, n);
1795 length += n;
1796 }
17971797 # else
1798 { /* Convert. */
1799 DCHAR_T *converted = result + length;
1800 size_t converted_len = allocated - length;
1798 { /* Convert. */
1799 DCHAR_T *converted = result + length;
1800 size_t converted_len = allocated - length;
18011801 # if DCHAR_IS_TCHAR
1802 /* Convert from UTF-8 to locale encoding. */
1803 converted =
1804 u8_conv_to_encoding (locale_charset (),
1805 iconveh_question_mark,
1806 arg, arg_end - arg, NULL,
1807 converted, &converted_len);
1802 /* Convert from UTF-8 to locale encoding. */
1803 converted =
1804 u8_conv_to_encoding (locale_charset (),
1805 iconveh_question_mark,
1806 arg, arg_end - arg, NULL,
1807 converted, &converted_len);
18081808 # else
1809 /* Convert from UTF-8 to UTF-16/UTF-32. */
1810 converted =
1811 U8_TO_DCHAR (arg, arg_end - arg,
1812 converted, &converted_len);
1809 /* Convert from UTF-8 to UTF-16/UTF-32. */
1810 converted =
1811 U8_TO_DCHAR (arg, arg_end - arg,
1812 converted, &converted_len);
18131813 # endif
1814 if (converted == NULL)
1815 {
1816 int saved_errno = errno;
1817 if (!(result == resultbuf || result == NULL))
1818 free (result);
1819 if (buf_malloced != NULL)
1820 free (buf_malloced);
1821 CLEANUP ();
1822 errno = saved_errno;
1823 return NULL;
1824 }
1825 if (converted != result + length)
1826 {
1827 ENSURE_ALLOCATION (xsum (length, converted_len));
1828 DCHAR_CPY (result + length, converted, converted_len);
1829 free (converted);
1830 }
1831 length += converted_len;
1832 }
1814 if (converted == NULL)
1815 {
1816 int saved_errno = errno;
1817 if (!(result == resultbuf || result == NULL))
1818 free (result);
1819 if (buf_malloced != NULL)
1820 free (buf_malloced);
1821 CLEANUP ();
1822 errno = saved_errno;
1823 return NULL;
1824 }
1825 if (converted != result + length)
1826 {
1827 ENSURE_ALLOCATION (xsum (length, converted_len));
1828 DCHAR_CPY (result + length, converted, converted_len);
1829 free (converted);
1830 }
1831 length += converted_len;
1832 }
18331833 # endif
18341834
1835 if (has_width && width > characters
1836 && (dp->flags & FLAG_LEFT))
1837 {
1838 size_t n = width - characters;
1839 ENSURE_ALLOCATION (xsum (length, n));
1840 DCHAR_SET (result + length, ' ', n);
1841 length += n;
1842 }
1843 }
1844 break;
1845
1846 case TYPE_U16_STRING:
1847 {
1848 const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string;
1849 const uint16_t *arg_end;
1850 size_t characters;
1851
1852 if (has_precision)
1853 {
1854 /* Use only PRECISION characters, from the left. */
1855 arg_end = arg;
1856 characters = 0;
1857 for (; precision > 0; precision--)
1858 {
1859 int count = u16_strmblen (arg_end);
1860 if (count == 0)
1861 break;
1862 if (count < 0)
1863 {
1864 if (!(result == resultbuf || result == NULL))
1865 free (result);
1866 if (buf_malloced != NULL)
1867 free (buf_malloced);
1868 CLEANUP ();
1869 errno = EILSEQ;
1870 return NULL;
1871 }
1872 arg_end += count;
1873 characters++;
1874 }
1875 }
1876 else if (has_width)
1877 {
1878 /* Use the entire string, and count the number of
1879 characters. */
1880 arg_end = arg;
1881 characters = 0;
1882 for (;;)
1883 {
1884 int count = u16_strmblen (arg_end);
1885 if (count == 0)
1886 break;
1887 if (count < 0)
1888 {
1889 if (!(result == resultbuf || result == NULL))
1890 free (result);
1891 if (buf_malloced != NULL)
1892 free (buf_malloced);
1893 CLEANUP ();
1894 errno = EILSEQ;
1895 return NULL;
1896 }
1897 arg_end += count;
1898 characters++;
1899 }
1900 }
1901 else
1902 {
1903 /* Use the entire string. */
1904 arg_end = arg + u16_strlen (arg);
1905 /* The number of characters doesn't matter. */
1906 characters = 0;
1907 }
1908
1909 if (has_width && width > characters
1910 && !(dp->flags & FLAG_LEFT))
1911 {
1912 size_t n = width - characters;
1913 ENSURE_ALLOCATION (xsum (length, n));
1914 DCHAR_SET (result + length, ' ', n);
1915 length += n;
1916 }
1835 if (has_width && width > characters
1836 && (dp->flags & FLAG_LEFT))
1837 {
1838 size_t n = width - characters;
1839 ENSURE_ALLOCATION (xsum (length, n));
1840 DCHAR_SET (result + length, ' ', n);
1841 length += n;
1842 }
1843 }
1844 break;
1845
1846 case TYPE_U16_STRING:
1847 {
1848 const uint16_t *arg = a.arg[dp->arg_index].a.a_u16_string;
1849 const uint16_t *arg_end;
1850 size_t characters;
1851
1852 if (has_precision)
1853 {
1854 /* Use only PRECISION characters, from the left. */
1855 arg_end = arg;
1856 characters = 0;
1857 for (; precision > 0; precision--)
1858 {
1859 int count = u16_strmblen (arg_end);
1860 if (count == 0)
1861 break;
1862 if (count < 0)
1863 {
1864 if (!(result == resultbuf || result == NULL))
1865 free (result);
1866 if (buf_malloced != NULL)
1867 free (buf_malloced);
1868 CLEANUP ();
1869 errno = EILSEQ;
1870 return NULL;
1871 }
1872 arg_end += count;
1873 characters++;
1874 }
1875 }
1876 else if (has_width)
1877 {
1878 /* Use the entire string, and count the number of
1879 characters. */
1880 arg_end = arg;
1881 characters = 0;
1882 for (;;)
1883 {
1884 int count = u16_strmblen (arg_end);
1885 if (count == 0)
1886 break;
1887 if (count < 0)
1888 {
1889 if (!(result == resultbuf || result == NULL))
1890 free (result);
1891 if (buf_malloced != NULL)
1892 free (buf_malloced);
1893 CLEANUP ();
1894 errno = EILSEQ;
1895 return NULL;
1896 }
1897 arg_end += count;
1898 characters++;
1899 }
1900 }
1901 else
1902 {
1903 /* Use the entire string. */
1904 arg_end = arg + u16_strlen (arg);
1905 /* The number of characters doesn't matter. */
1906 characters = 0;
1907 }
1908
1909 if (has_width && width > characters
1910 && !(dp->flags & FLAG_LEFT))
1911 {
1912 size_t n = width - characters;
1913 ENSURE_ALLOCATION (xsum (length, n));
1914 DCHAR_SET (result + length, ' ', n);
1915 length += n;
1916 }
19171917
19181918 # if DCHAR_IS_UINT16_T
1919 {
1920 size_t n = arg_end - arg;
1921 ENSURE_ALLOCATION (xsum (length, n));
1922 DCHAR_CPY (result + length, arg, n);
1923 length += n;
1924 }
1919 {
1920 size_t n = arg_end - arg;
1921 ENSURE_ALLOCATION (xsum (length, n));
1922 DCHAR_CPY (result + length, arg, n);
1923 length += n;
1924 }
19251925 # else
1926 { /* Convert. */
1927 DCHAR_T *converted = result + length;
1928 size_t converted_len = allocated - length;
1926 { /* Convert. */
1927 DCHAR_T *converted = result + length;
1928 size_t converted_len = allocated - length;
19291929 # if DCHAR_IS_TCHAR
1930 /* Convert from UTF-16 to locale encoding. */
1931 converted =
1932 u16_conv_to_encoding (locale_charset (),
1933 iconveh_question_mark,
1934 arg, arg_end - arg, NULL,
1935 converted, &converted_len);
1930 /* Convert from UTF-16 to locale encoding. */
1931 converted =
1932 u16_conv_to_encoding (locale_charset (),
1933 iconveh_question_mark,
1934 arg, arg_end - arg, NULL,
1935 converted, &converted_len);
19361936 # else
1937 /* Convert from UTF-16 to UTF-8/UTF-32. */
1938 converted =
1939 U16_TO_DCHAR (arg, arg_end - arg,
1940 converted, &converted_len);
1937 /* Convert from UTF-16 to UTF-8/UTF-32. */
1938 converted =
1939 U16_TO_DCHAR (arg, arg_end - arg,
1940 converted, &converted_len);
19411941 # endif
1942 if (converted == NULL)
1943 {
1944 int saved_errno = errno;
1945 if (!(result == resultbuf || result == NULL))
1946 free (result);
1947 if (buf_malloced != NULL)
1948 free (buf_malloced);
1949 CLEANUP ();
1950 errno = saved_errno;
1951 return NULL;
1952 }
1953 if (converted != result + length)
1954 {
1955 ENSURE_ALLOCATION (xsum (length, converted_len));
1956 DCHAR_CPY (result + length, converted, converted_len);
1957 free (converted);
1958 }
1959 length += converted_len;
1960 }
1942 if (converted == NULL)
1943 {
1944 int saved_errno = errno;
1945 if (!(result == resultbuf || result == NULL))
1946 free (result);
1947 if (buf_malloced != NULL)
1948 free (buf_malloced);
1949 CLEANUP ();
1950 errno = saved_errno;
1951 return NULL;
1952 }
1953 if (converted != result + length)
1954 {
1955 ENSURE_ALLOCATION (xsum (length, converted_len));
1956 DCHAR_CPY (result + length, converted, converted_len);
1957 free (converted);
1958 }
1959 length += converted_len;
1960 }
19611961 # endif
19621962
1963 if (has_width && width > characters
1964 && (dp->flags & FLAG_LEFT))
1965 {
1966 size_t n = width - characters;
1967 ENSURE_ALLOCATION (xsum (length, n));
1968 DCHAR_SET (result + length, ' ', n);
1969 length += n;
1970 }
1971 }
1972 break;
1973
1974 case TYPE_U32_STRING:
1975 {
1976 const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string;
1977 const uint32_t *arg_end;
1978 size_t characters;
1979
1980 if (has_precision)
1981 {
1982 /* Use only PRECISION characters, from the left. */
1983 arg_end = arg;
1984 characters = 0;
1985 for (; precision > 0; precision--)
1986 {
1987 int count = u32_strmblen (arg_end);
1988 if (count == 0)
1989 break;
1990 if (count < 0)
1991 {
1992 if (!(result == resultbuf || result == NULL))
1993 free (result);
1994 if (buf_malloced != NULL)
1995 free (buf_malloced);
1996 CLEANUP ();
1997 errno = EILSEQ;
1998 return NULL;
1999 }
2000 arg_end += count;
2001 characters++;
2002 }
2003 }
2004 else if (has_width)
2005 {
2006 /* Use the entire string, and count the number of
2007 characters. */
2008 arg_end = arg;
2009 characters = 0;
2010 for (;;)
2011 {
2012 int count = u32_strmblen (arg_end);
2013 if (count == 0)
2014 break;
2015 if (count < 0)
2016 {
2017 if (!(result == resultbuf || result == NULL))
2018 free (result);
2019 if (buf_malloced != NULL)
2020 free (buf_malloced);
2021 CLEANUP ();
2022 errno = EILSEQ;
2023 return NULL;
2024 }
2025 arg_end += count;
2026 characters++;
2027 }
2028 }
2029 else
2030 {
2031 /* Use the entire string. */
2032 arg_end = arg + u32_strlen (arg);
2033 /* The number of characters doesn't matter. */
2034 characters = 0;
2035 }
2036
2037 if (has_width && width > characters
2038 && !(dp->flags & FLAG_LEFT))
2039 {
2040 size_t n = width - characters;
2041 ENSURE_ALLOCATION (xsum (length, n));
2042 DCHAR_SET (result + length, ' ', n);
2043 length += n;
2044 }
1963 if (has_width && width > characters
1964 && (dp->flags & FLAG_LEFT))
1965 {
1966 size_t n = width - characters;
1967 ENSURE_ALLOCATION (xsum (length, n));
1968 DCHAR_SET (result + length, ' ', n);
1969 length += n;
1970 }
1971 }
1972 break;
1973
1974 case TYPE_U32_STRING:
1975 {
1976 const uint32_t *arg = a.arg[dp->arg_index].a.a_u32_string;
1977 const uint32_t *arg_end;
1978 size_t characters;
1979
1980 if (has_precision)
1981 {
1982 /* Use only PRECISION characters, from the left. */
1983 arg_end = arg;
1984 characters = 0;
1985 for (; precision > 0; precision--)
1986 {
1987 int count = u32_strmblen (arg_end);
1988 if (count == 0)
1989 break;
1990 if (count < 0)
1991 {
1992 if (!(result == resultbuf || result == NULL))
1993 free (result);
1994 if (buf_malloced != NULL)
1995 free (buf_malloced);
1996 CLEANUP ();
1997 errno = EILSEQ;
1998 return NULL;
1999 }
2000 arg_end += count;
2001 characters++;
2002 }
2003 }
2004 else if (has_width)
2005 {
2006 /* Use the entire string, and count the number of
2007 characters. */
2008 arg_end = arg;
2009 characters = 0;
2010 for (;;)
2011 {
2012 int count = u32_strmblen (arg_end);
2013 if (count == 0)
2014 break;
2015 if (count < 0)
2016 {
2017 if (!(result == resultbuf || result == NULL))
2018 free (result);
2019 if (buf_malloced != NULL)
2020 free (buf_malloced);
2021 CLEANUP ();
2022 errno = EILSEQ;
2023 return NULL;
2024 }
2025 arg_end += count;
2026 characters++;
2027 }
2028 }
2029 else
2030 {
2031 /* Use the entire string. */
2032 arg_end = arg + u32_strlen (arg);
2033 /* The number of characters doesn't matter. */
2034 characters = 0;
2035 }
2036
2037 if (has_width && width > characters
2038 && !(dp->flags & FLAG_LEFT))
2039 {
2040 size_t n = width - characters;
2041 ENSURE_ALLOCATION (xsum (length, n));
2042 DCHAR_SET (result + length, ' ', n);
2043 length += n;
2044 }
20452045
20462046 # if DCHAR_IS_UINT32_T
2047 {
2048 size_t n = arg_end - arg;
2049 ENSURE_ALLOCATION (xsum (length, n));
2050 DCHAR_CPY (result + length, arg, n);
2051 length += n;
2052 }
2047 {
2048 size_t n = arg_end - arg;
2049 ENSURE_ALLOCATION (xsum (length, n));
2050 DCHAR_CPY (result + length, arg, n);
2051 length += n;
2052 }
20532053 # else
2054 { /* Convert. */
2055 DCHAR_T *converted = result + length;
2056 size_t converted_len = allocated - length;
2054 { /* Convert. */
2055 DCHAR_T *converted = result + length;
2056 size_t converted_len = allocated - length;
20572057 # if DCHAR_IS_TCHAR
2058 /* Convert from UTF-32 to locale encoding. */
2059 converted =
2060 u32_conv_to_encoding (locale_charset (),
2061 iconveh_question_mark,
2062 arg, arg_end - arg, NULL,
2063 converted, &converted_len);
2058 /* Convert from UTF-32 to locale encoding. */
2059 converted =
2060 u32_conv_to_encoding (locale_charset (),
2061 iconveh_question_mark,
2062 arg, arg_end - arg, NULL,
2063 converted, &converted_len);
20642064 # else
2065 /* Convert from UTF-32 to UTF-8/UTF-16. */
2066 converted =
2067 U32_TO_DCHAR (arg, arg_end - arg,
2068 converted, &converted_len);
2065 /* Convert from UTF-32 to UTF-8/UTF-16. */
2066 converted =
2067 U32_TO_DCHAR (arg, arg_end - arg,
2068 converted, &converted_len);
20692069 # endif
2070 if (converted == NULL)
2071 {
2072 int saved_errno = errno;
2073 if (!(result == resultbuf || result == NULL))
2074 free (result);
2075 if (buf_malloced != NULL)
2076 free (buf_malloced);
2077 CLEANUP ();
2078 errno = saved_errno;
2079 return NULL;
2080 }
2081 if (converted != result + length)
2082 {
2083 ENSURE_ALLOCATION (xsum (length, converted_len));
2084 DCHAR_CPY (result + length, converted, converted_len);
2085 free (converted);
2086 }
2087 length += converted_len;
2088 }
2070 if (converted == NULL)
2071 {
2072 int saved_errno = errno;
2073 if (!(result == resultbuf || result == NULL))
2074 free (result);
2075 if (buf_malloced != NULL)
2076 free (buf_malloced);
2077 CLEANUP ();
2078 errno = saved_errno;
2079 return NULL;
2080 }
2081 if (converted != result + length)
2082 {
2083 ENSURE_ALLOCATION (xsum (length, converted_len));
2084 DCHAR_CPY (result + length, converted, converted_len);
2085 free (converted);
2086 }
2087 length += converted_len;
2088 }
20892089 # endif
20902090
2091 if (has_width && width > characters
2092 && (dp->flags & FLAG_LEFT))
2093 {
2094 size_t n = width - characters;
2095 ENSURE_ALLOCATION (xsum (length, n));
2096 DCHAR_SET (result + length, ' ', n);
2097 length += n;
2098 }
2099 }
2100 break;
2101
2102 default:
2103 abort ();
2104 }
2105 }
2091 if (has_width && width > characters
2092 && (dp->flags & FLAG_LEFT))
2093 {
2094 size_t n = width - characters;
2095 ENSURE_ALLOCATION (xsum (length, n));
2096 DCHAR_SET (result + length, ' ', n);
2097 length += n;
2098 }
2099 }
2100 break;
2101
2102 default:
2103 abort ();
2104 }
2105 }
21062106 #endif
21072107 #if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
2108 else if (dp->conversion == 's'
2108 else if (dp->conversion == 's'
21092109 # if WIDE_CHAR_VERSION
2110 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
2110 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
21112111 # else
2112 && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
2112 && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
21132113 # endif
2114 )
2115 {
2116 /* The normal handling of the 's' directive below requires
2117 allocating a temporary buffer. The determination of its
2118 length (tmp_length), in the case when a precision is
2119 specified, below requires a conversion between a char[]
2120 string and a wchar_t[] wide string. It could be done, but
2121 we have no guarantee that the implementation of sprintf will
2122 use the exactly same algorithm. Without this guarantee, it
2123 is possible to have buffer overrun bugs. In order to avoid
2124 such bugs, we implement the entire processing of the 's'
2125 directive ourselves. */
2126 int flags = dp->flags;
2127 int has_width;
2128 size_t width;
2129 int has_precision;
2130 size_t precision;
2131
2132 has_width = 0;
2133 width = 0;
2134 if (dp->width_start != dp->width_end)
2135 {
2136 if (dp->width_arg_index != ARG_NONE)
2137 {
2138 int arg;
2139
2140 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2141 abort ();
2142 arg = a.arg[dp->width_arg_index].a.a_int;
2143 if (arg < 0)
2144 {
2145 /* "A negative field width is taken as a '-' flag
2146 followed by a positive field width." */
2147 flags |= FLAG_LEFT;
2148 width = (unsigned int) (-arg);
2149 }
2150 else
2151 width = arg;
2152 }
2153 else
2154 {
2155 const FCHAR_T *digitp = dp->width_start;
2156
2157 do
2158 width = xsum (xtimes (width, 10), *digitp++ - '0');
2159 while (digitp != dp->width_end);
2160 }
2161 has_width = 1;
2162 }
2163
2164 has_precision = 0;
2165 precision = 6;
2166 if (dp->precision_start != dp->precision_end)
2167 {
2168 if (dp->precision_arg_index != ARG_NONE)
2169 {
2170 int arg;
2171
2172 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
2173 abort ();
2174 arg = a.arg[dp->precision_arg_index].a.a_int;
2175 /* "A negative precision is taken as if the precision
2176 were omitted." */
2177 if (arg >= 0)
2178 {
2179 precision = arg;
2180 has_precision = 1;
2181 }
2182 }
2183 else
2184 {
2185 const FCHAR_T *digitp = dp->precision_start + 1;
2186
2187 precision = 0;
2188 while (digitp != dp->precision_end)
2189 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
2190 has_precision = 1;
2191 }
2192 }
2114 )
2115 {
2116 /* The normal handling of the 's' directive below requires
2117 allocating a temporary buffer. The determination of its
2118 length (tmp_length), in the case when a precision is
2119 specified, below requires a conversion between a char[]
2120 string and a wchar_t[] wide string. It could be done, but
2121 we have no guarantee that the implementation of sprintf will
2122 use the exactly same algorithm. Without this guarantee, it
2123 is possible to have buffer overrun bugs. In order to avoid
2124 such bugs, we implement the entire processing of the 's'
2125 directive ourselves. */
2126 int flags = dp->flags;
2127 int has_width;
2128 size_t width;
2129 int has_precision;
2130 size_t precision;
2131
2132 has_width = 0;
2133 width = 0;
2134 if (dp->width_start != dp->width_end)
2135 {
2136 if (dp->width_arg_index != ARG_NONE)
2137 {
2138 int arg;
2139
2140 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2141 abort ();
2142 arg = a.arg[dp->width_arg_index].a.a_int;
2143 if (arg < 0)
2144 {
2145 /* "A negative field width is taken as a '-' flag
2146 followed by a positive field width." */
2147 flags |= FLAG_LEFT;
2148 width = (unsigned int) (-arg);
2149 }
2150 else
2151 width = arg;
2152 }
2153 else
2154 {
2155 const FCHAR_T *digitp = dp->width_start;
2156
2157 do
2158 width = xsum (xtimes (width, 10), *digitp++ - '0');
2159 while (digitp != dp->width_end);
2160 }
2161 has_width = 1;
2162 }
2163
2164 has_precision = 0;
2165 precision = 6;
2166 if (dp->precision_start != dp->precision_end)
2167 {
2168 if (dp->precision_arg_index != ARG_NONE)
2169 {
2170 int arg;
2171
2172 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
2173 abort ();
2174 arg = a.arg[dp->precision_arg_index].a.a_int;
2175 /* "A negative precision is taken as if the precision
2176 were omitted." */
2177 if (arg >= 0)
2178 {
2179 precision = arg;
2180 has_precision = 1;
2181 }
2182 }
2183 else
2184 {
2185 const FCHAR_T *digitp = dp->precision_start + 1;
2186
2187 precision = 0;
2188 while (digitp != dp->precision_end)
2189 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
2190 has_precision = 1;
2191 }
2192 }
21932193
21942194 # if WIDE_CHAR_VERSION
2195 /* %s in vasnwprintf. See the specification of fwprintf. */
2196 {
2197 const char *arg = a.arg[dp->arg_index].a.a_string;
2198 const char *arg_end;
2199 size_t characters;
2200
2201 if (has_precision)
2202 {
2203 /* Use only as many bytes as needed to produce PRECISION
2204 wide characters, from the left. */
2195 /* %s in vasnwprintf. See the specification of fwprintf. */
2196 {
2197 const char *arg = a.arg[dp->arg_index].a.a_string;
2198 const char *arg_end;
2199 size_t characters;
2200
2201 if (has_precision)
2202 {
2203 /* Use only as many bytes as needed to produce PRECISION
2204 wide characters, from the left. */
22052205 # if HAVE_MBRTOWC
2206 mbstate_t state;
2207 memset (&state, '\0', sizeof (mbstate_t));
2206 mbstate_t state;
2207 memset (&state, '\0', sizeof (mbstate_t));
22082208 # endif
2209 arg_end = arg;
2210 characters = 0;
2211 for (; precision > 0; precision--)
2212 {
2213 int count;
2209 arg_end = arg;
2210 characters = 0;
2211 for (; precision > 0; precision--)
2212 {
2213 int count;
22142214 # if HAVE_MBRTOWC
2215 count = mbrlen (arg_end, MB_CUR_MAX, &state);
2215 count = mbrlen (arg_end, MB_CUR_MAX, &state);
22162216 # else
2217 count = mblen (arg_end, MB_CUR_MAX);
2217 count = mblen (arg_end, MB_CUR_MAX);
22182218 # endif
2219 if (count == 0)
2220 /* Found the terminating NUL. */
2221 break;
2222 if (count < 0)
2223 {
2224 /* Invalid or incomplete multibyte character. */
2225 if (!(result == resultbuf || result == NULL))
2226 free (result);
2227 if (buf_malloced != NULL)
2228 free (buf_malloced);
2229 CLEANUP ();
2230 errno = EILSEQ;
2231 return NULL;
2232 }
2233 arg_end += count;
2234 characters++;
2235 }
2236 }
2237 else if (has_width)
2238 {
2239 /* Use the entire string, and count the number of wide
2240 characters. */
2219 if (count == 0)
2220 /* Found the terminating NUL. */
2221 break;
2222 if (count < 0)
2223 {
2224 /* Invalid or incomplete multibyte character. */
2225 if (!(result == resultbuf || result == NULL))
2226 free (result);
2227 if (buf_malloced != NULL)
2228 free (buf_malloced);
2229 CLEANUP ();
2230 errno = EILSEQ;
2231 return NULL;
2232 }
2233 arg_end += count;
2234 characters++;
2235 }
2236 }
2237 else if (has_width)
2238 {
2239 /* Use the entire string, and count the number of wide
2240 characters. */
22412241 # if HAVE_MBRTOWC
2242 mbstate_t state;
2243 memset (&state, '\0', sizeof (mbstate_t));
2242 mbstate_t state;
2243 memset (&state, '\0', sizeof (mbstate_t));
22442244 # endif
2245 arg_end = arg;
2246 characters = 0;
2247 for (;;)
2248 {
2249 int count;
2245 arg_end = arg;
2246 characters = 0;
2247 for (;;)
2248 {
2249 int count;
22502250 # if HAVE_MBRTOWC
2251 count = mbrlen (arg_end, MB_CUR_MAX, &state);
2251 count = mbrlen (arg_end, MB_CUR_MAX, &state);
22522252 # else
2253 count = mblen (arg_end, MB_CUR_MAX);
2253 count = mblen (arg_end, MB_CUR_MAX);
22542254 # endif
2255 if (count == 0)
2256 /* Found the terminating NUL. */
2257 break;
2258 if (count < 0)
2259 {
2260 /* Invalid or incomplete multibyte character. */
2261 if (!(result == resultbuf || result == NULL))
2262 free (result);
2263 if (buf_malloced != NULL)
2264 free (buf_malloced);
2265 CLEANUP ();
2266 errno = EILSEQ;
2267 return NULL;
2268 }
2269 arg_end += count;
2270 characters++;
2271 }
2272 }
2273 else
2274 {
2275 /* Use the entire string. */
2276 arg_end = arg + strlen (arg);
2277 /* The number of characters doesn't matter. */
2278 characters = 0;
2279 }
2280
2281 if (has_width && width > characters
2282 && !(dp->flags & FLAG_LEFT))
2283 {
2284 size_t n = width - characters;
2285 ENSURE_ALLOCATION (xsum (length, n));
2286 DCHAR_SET (result + length, ' ', n);
2287 length += n;
2288 }
2289
2290 if (has_precision || has_width)
2291 {
2292 /* We know the number of wide characters in advance. */
2293 size_t remaining;
2255 if (count == 0)
2256 /* Found the terminating NUL. */
2257 break;
2258 if (count < 0)
2259 {
2260 /* Invalid or incomplete multibyte character. */
2261 if (!(result == resultbuf || result == NULL))
2262 free (result);
2263 if (buf_malloced != NULL)
2264 free (buf_malloced);
2265 CLEANUP ();
2266 errno = EILSEQ;
2267 return NULL;
2268 }
2269 arg_end += count;
2270 characters++;
2271 }
2272 }
2273 else
2274 {
2275 /* Use the entire string. */
2276 arg_end = arg + strlen (arg);
2277 /* The number of characters doesn't matter. */
2278 characters = 0;
2279 }
2280
2281 if (has_width && width > characters
2282 && !(dp->flags & FLAG_LEFT))
2283 {
2284 size_t n = width - characters;
2285 ENSURE_ALLOCATION (xsum (length, n));
2286 DCHAR_SET (result + length, ' ', n);
2287 length += n;
2288 }
2289
2290 if (has_precision || has_width)
2291 {
2292 /* We know the number of wide characters in advance. */
2293 size_t remaining;
22942294 # if HAVE_MBRTOWC
2295 mbstate_t state;
2296 memset (&state, '\0', sizeof (mbstate_t));
2295 mbstate_t state;
2296 memset (&state, '\0', sizeof (mbstate_t));
22972297 # endif
2298 ENSURE_ALLOCATION (xsum (length, characters));
2299 for (remaining = characters; remaining > 0; remaining--)
2300 {
2301 wchar_t wc;
2302 int count;
2298 ENSURE_ALLOCATION (xsum (length, characters));
2299 for (remaining = characters; remaining > 0; remaining--)
2300 {
2301 wchar_t wc;
2302 int count;
23032303 # if HAVE_MBRTOWC
2304 count = mbrtowc (&wc, arg, arg_end - arg, &state);
2304 count = mbrtowc (&wc, arg, arg_end - arg, &state);
23052305 # else
2306 count = mbtowc (&wc, arg, arg_end - arg);
2306 count = mbtowc (&wc, arg, arg_end - arg);
23072307 # endif
2308 if (count <= 0)
2309 /* mbrtowc not consistent with mbrlen, or mbtowc
2310 not consistent with mblen. */
2311 abort ();
2312 result[length++] = wc;
2313 arg += count;
2314 }
2315 if (!(arg == arg_end))
2316 abort ();
2317 }
2318 else
2319 {
2308 if (count <= 0)
2309 /* mbrtowc not consistent with mbrlen, or mbtowc
2310 not consistent with mblen. */
2311 abort ();
2312 result[length++] = wc;
2313 arg += count;
2314 }
2315 if (!(arg == arg_end))
2316 abort ();
2317 }
2318 else
2319 {
23202320 # if HAVE_MBRTOWC
2321 mbstate_t state;
2322 memset (&state, '\0', sizeof (mbstate_t));
2321 mbstate_t state;
2322 memset (&state, '\0', sizeof (mbstate_t));
23232323 # endif
2324 while (arg < arg_end)
2325 {
2326 wchar_t wc;
2327 int count;
2324 while (arg < arg_end)
2325 {
2326 wchar_t wc;
2327 int count;
23282328 # if HAVE_MBRTOWC
2329 count = mbrtowc (&wc, arg, arg_end - arg, &state);
2329 count = mbrtowc (&wc, arg, arg_end - arg, &state);
23302330 # else
2331 count = mbtowc (&wc, arg, arg_end - arg);
2331 count = mbtowc (&wc, arg, arg_end - arg);
23322332 # endif
2333 if (count <= 0)
2334 /* mbrtowc not consistent with mbrlen, or mbtowc
2335 not consistent with mblen. */
2336 abort ();
2337 ENSURE_ALLOCATION (xsum (length, 1));
2338 result[length++] = wc;
2339 arg += count;
2340 }
2341 }
2342
2343 if (has_width && width > characters
2344 && (dp->flags & FLAG_LEFT))
2345 {
2346 size_t n = width - characters;
2347 ENSURE_ALLOCATION (xsum (length, n));
2348 DCHAR_SET (result + length, ' ', n);
2349 length += n;
2350 }
2351 }
2333 if (count <= 0)
2334 /* mbrtowc not consistent with mbrlen, or mbtowc
2335 not consistent with mblen. */
2336 abort ();
2337 ENSURE_ALLOCATION (xsum (length, 1));
2338 result[length++] = wc;
2339 arg += count;
2340 }
2341 }
2342
2343 if (has_width && width > characters
2344 && (dp->flags & FLAG_LEFT))
2345 {
2346 size_t n = width - characters;
2347 ENSURE_ALLOCATION (xsum (length, n));
2348 DCHAR_SET (result + length, ' ', n);
2349 length += n;
2350 }
2351 }
23522352 # else
2353 /* %ls in vasnprintf. See the specification of fprintf. */
2354 {
2355 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
2356 const wchar_t *arg_end;
2357 size_t characters;
2353 /* %ls in vasnprintf. See the specification of fprintf. */
2354 {
2355 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
2356 const wchar_t *arg_end;
2357 size_t characters;
23582358 # if !DCHAR_IS_TCHAR
2359 /* This code assumes that TCHAR_T is 'char'. */
2360 typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
2361 TCHAR_T *tmpsrc;
2362 DCHAR_T *tmpdst;
2363 size_t tmpdst_len;
2359 /* This code assumes that TCHAR_T is 'char'. */
2360 typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
2361 TCHAR_T *tmpsrc;
2362 DCHAR_T *tmpdst;
2363 size_t tmpdst_len;
23642364 # endif
2365 size_t w;
2366
2367 if (has_precision)
2368 {
2369 /* Use only as many wide characters as needed to produce
2370 at most PRECISION bytes, from the left. */
2371 # if HAVE_WCRTOMB
2372 mbstate_t state;
2373 memset (&state, '\0', sizeof (mbstate_t));
2365 size_t w;
2366
2367 if (has_precision)
2368 {
2369 /* Use only as many wide characters as needed to produce
2370 at most PRECISION bytes, from the left. */
2371 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2372 mbstate_t state;
2373 memset (&state, '\0', sizeof (mbstate_t));
23742374 # endif
2375 arg_end = arg;
2376 characters = 0;
2377 while (precision > 0)
2378 {
2379 char buf[64]; /* Assume MB_CUR_MAX <= 64. */
2380 int count;
2381
2382 if (*arg_end == 0)
2383 /* Found the terminating null wide character. */
2384 break;
2385 # if HAVE_WCRTOMB
2386 count = wcrtomb (buf, *arg_end, &state);
2375 arg_end = arg;
2376 characters = 0;
2377 while (precision > 0)
2378 {
2379 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2380 int count;
2381
2382 if (*arg_end == 0)
2383 /* Found the terminating null wide character. */
2384 break;
2385 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2386 count = wcrtomb (cbuf, *arg_end, &state);
23872387 # else
2388 count = wctomb (buf, *arg_end);
2388 count = wctomb (cbuf, *arg_end);
23892389 # endif
2390 if (count < 0)
2391 {
2392 /* Cannot convert. */
2393 if (!(result == resultbuf || result == NULL))
2394 free (result);
2395 if (buf_malloced != NULL)
2396 free (buf_malloced);
2397 CLEANUP ();
2398 errno = EILSEQ;
2399 return NULL;
2400 }
2401 if (precision < count)
2402 break;
2403 arg_end++;
2404 characters += count;
2405 precision -= count;
2406 }
2407 }
2390 if (count < 0)
2391 {
2392 /* Cannot convert. */
2393 if (!(result == resultbuf || result == NULL))
2394 free (result);
2395 if (buf_malloced != NULL)
2396 free (buf_malloced);
2397 CLEANUP ();
2398 errno = EILSEQ;
2399 return NULL;
2400 }
2401 if (precision < count)
2402 break;
2403 arg_end++;
2404 characters += count;
2405 precision -= count;
2406 }
2407 }
24082408 # if DCHAR_IS_TCHAR
2409 else if (has_width)
2409 else if (has_width)
24102410 # else
2411 else
2411 else
24122412 # endif
2413 {
2414 /* Use the entire string, and count the number of
2415 bytes. */
2416 # if HAVE_WCRTOMB
2417 mbstate_t state;
2418 memset (&state, '\0', sizeof (mbstate_t));
2413 {
2414 /* Use the entire string, and count the number of
2415 bytes. */
2416 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2417 mbstate_t state;
2418 memset (&state, '\0', sizeof (mbstate_t));
24192419 # endif
2420 arg_end = arg;
2421 characters = 0;
2422 for (;;)
2423 {
2424 char buf[64]; /* Assume MB_CUR_MAX <= 64. */
2425 int count;
2426
2427 if (*arg_end == 0)
2428 /* Found the terminating null wide character. */
2429 break;
2430 # if HAVE_WCRTOMB
2431 count = wcrtomb (buf, *arg_end, &state);
2420 arg_end = arg;
2421 characters = 0;
2422 for (;;)
2423 {
2424 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2425 int count;
2426
2427 if (*arg_end == 0)
2428 /* Found the terminating null wide character. */
2429 break;
2430 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2431 count = wcrtomb (cbuf, *arg_end, &state);
24322432 # else
2433 count = wctomb (buf, *arg_end);
2433 count = wctomb (cbuf, *arg_end);
24342434 # endif
2435 if (count < 0)
2436 {
2437 /* Cannot convert. */
2438 if (!(result == resultbuf || result == NULL))
2439 free (result);
2440 if (buf_malloced != NULL)
2441 free (buf_malloced);
2442 CLEANUP ();
2443 errno = EILSEQ;
2444 return NULL;
2445 }
2446 arg_end++;
2447 characters += count;
2448 }
2449 }
2435 if (count < 0)
2436 {
2437 /* Cannot convert. */
2438 if (!(result == resultbuf || result == NULL))
2439 free (result);
2440 if (buf_malloced != NULL)
2441 free (buf_malloced);
2442 CLEANUP ();
2443 errno = EILSEQ;
2444 return NULL;
2445 }
2446 arg_end++;
2447 characters += count;
2448 }
2449 }
24502450 # if DCHAR_IS_TCHAR
2451 else
2452 {
2453 /* Use the entire string. */
2454 arg_end = arg + local_wcslen (arg);
2455 /* The number of bytes doesn't matter. */
2456 characters = 0;
2457 }
2451 else
2452 {
2453 /* Use the entire string. */
2454 arg_end = arg + local_wcslen (arg);
2455 /* The number of bytes doesn't matter. */
2456 characters = 0;
2457 }
24582458 # endif
24592459
24602460 # if !DCHAR_IS_TCHAR
2461 /* Convert the string into a piece of temporary memory. */
2462 tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
2463 if (tmpsrc == NULL)
2464 goto out_of_memory;
2465 {
2466 TCHAR_T *tmpptr = tmpsrc;
2467 size_t remaining;
2468 # if HAVE_WCRTOMB
2469 mbstate_t state;
2470 memset (&state, '\0', sizeof (mbstate_t));
2461 /* Convert the string into a piece of temporary memory. */
2462 tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
2463 if (tmpsrc == NULL)
2464 goto out_of_memory;
2465 {
2466 TCHAR_T *tmpptr = tmpsrc;
2467 size_t remaining;
2468 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2469 mbstate_t state;
2470 memset (&state, '\0', sizeof (mbstate_t));
24712471 # endif
2472 for (remaining = characters; remaining > 0; )
2473 {
2474 char buf[64]; /* Assume MB_CUR_MAX <= 64. */
2475 int count;
2476
2477 if (*arg == 0)
2478 abort ();
2479 # if HAVE_WCRTOMB
2480 count = wcrtomb (buf, *arg, &state);
2472 for (remaining = characters; remaining > 0; )
2473 {
2474 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2475 int count;
2476
2477 if (*arg == 0)
2478 abort ();
2479 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2480 count = wcrtomb (cbuf, *arg, &state);
24812481 # else
2482 count = wctomb (buf, *arg);
2482 count = wctomb (cbuf, *arg);
24832483 # endif
2484 if (count <= 0)
2485 /* Inconsistency. */
2486 abort ();
2487 memcpy (tmpptr, buf, count);
2488 tmpptr += count;
2489 arg++;
2490 remaining -= count;
2491 }
2492 if (!(arg == arg_end))
2493 abort ();
2494 }
2495
2496 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2497 tmpdst =
2498 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2499 iconveh_question_mark,
2500 tmpsrc, characters,
2501 NULL,
2502 NULL, &tmpdst_len);
2503 if (tmpdst == NULL)
2504 {
2505 int saved_errno = errno;
2506 free (tmpsrc);
2507 if (!(result == resultbuf || result == NULL))
2508 free (result);
2509 if (buf_malloced != NULL)
2510 free (buf_malloced);
2511 CLEANUP ();
2512 errno = saved_errno;
2513 return NULL;
2514 }
2515 free (tmpsrc);
2484 if (count <= 0)
2485 /* Inconsistency. */
2486 abort ();
2487 memcpy (tmpptr, cbuf, count);
2488 tmpptr += count;
2489 arg++;
2490 remaining -= count;
2491 }
2492 if (!(arg == arg_end))
2493 abort ();
2494 }
2495
2496 /* Convert from TCHAR_T[] to DCHAR_T[]. */
2497 tmpdst =
2498 DCHAR_CONV_FROM_ENCODING (locale_charset (),
2499 iconveh_question_mark,
2500 tmpsrc, characters,
2501 NULL,
2502 NULL, &tmpdst_len);
2503 if (tmpdst == NULL)
2504 {
2505 int saved_errno = errno;
2506 free (tmpsrc);
2507 if (!(result == resultbuf || result == NULL))
2508 free (result);
2509 if (buf_malloced != NULL)
2510 free (buf_malloced);
2511 CLEANUP ();
2512 errno = saved_errno;
2513 return NULL;
2514 }
2515 free (tmpsrc);
25162516 # endif
25172517
2518 if (has_width)
2519 {
2518 if (has_width)
2519 {
25202520 # if ENABLE_UNISTDIO
2521 /* Outside POSIX, it's preferrable to compare the width
2522 against the number of _characters_ of the converted
2523 value. */
2524 w = DCHAR_MBSNLEN (result + length, characters);
2521 /* Outside POSIX, it's preferrable to compare the width
2522 against the number of _characters_ of the converted
2523 value. */
2524 w = DCHAR_MBSNLEN (result + length, characters);
25252525 # else
2526 /* The width is compared against the number of _bytes_
2527 of the converted value, says POSIX. */
2528 w = characters;
2526 /* The width is compared against the number of _bytes_
2527 of the converted value, says POSIX. */
2528 w = characters;
25292529 # endif
2530 }
2531 else
2532 /* w doesn't matter. */
2533 w = 0;
2534
2535 if (has_width && width > w
2536 && !(dp->flags & FLAG_LEFT))
2537 {
2538 size_t n = width - w;
2539 ENSURE_ALLOCATION (xsum (length, n));
2540 DCHAR_SET (result + length, ' ', n);
2541 length += n;
2542 }
2530 }
2531 else
2532 /* w doesn't matter. */
2533 w = 0;
2534
2535 if (has_width && width > w
2536 && !(dp->flags & FLAG_LEFT))
2537 {
2538 size_t n = width - w;
2539 ENSURE_ALLOCATION (xsum (length, n));
2540 DCHAR_SET (result + length, ' ', n);
2541 length += n;
2542 }
25432543
25442544 # if DCHAR_IS_TCHAR
2545 if (has_precision || has_width)
2546 {
2547 /* We know the number of bytes in advance. */
2548 size_t remaining;
2549 # if HAVE_WCRTOMB
2550 mbstate_t state;
2551 memset (&state, '\0', sizeof (mbstate_t));
2545 if (has_precision || has_width)
2546 {
2547 /* We know the number of bytes in advance. */
2548 size_t remaining;
2549 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2550 mbstate_t state;
2551 memset (&state, '\0', sizeof (mbstate_t));
25522552 # endif
2553 ENSURE_ALLOCATION (xsum (length, characters));
2554 for (remaining = characters; remaining > 0; )
2555 {
2556 char buf[64]; /* Assume MB_CUR_MAX <= 64. */
2557 int count;
2558
2559 if (*arg == 0)
2560 abort ();
2561 # if HAVE_WCRTOMB
2562 count = wcrtomb (buf, *arg, &state);
2553 ENSURE_ALLOCATION (xsum (length, characters));
2554 for (remaining = characters; remaining > 0; )
2555 {
2556 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2557 int count;
2558
2559 if (*arg == 0)
2560 abort ();
2561 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2562 count = wcrtomb (cbuf, *arg, &state);
25632563 # else
2564 count = wctomb (buf, *arg);
2564 count = wctomb (cbuf, *arg);
25652565 # endif
2566 if (count <= 0)
2567 /* Inconsistency. */
2568 abort ();
2569 memcpy (result + length, buf, count);
2570 length += count;
2571 arg++;
2572 remaining -= count;
2573 }
2574 if (!(arg == arg_end))
2575 abort ();
2576 }
2577 else
2578 {
2579 # if HAVE_WCRTOMB
2580 mbstate_t state;
2581 memset (&state, '\0', sizeof (mbstate_t));
2566 if (count <= 0)
2567 /* Inconsistency. */
2568 abort ();
2569 memcpy (result + length, cbuf, count);
2570 length += count;
2571 arg++;
2572 remaining -= count;
2573 }
2574 if (!(arg == arg_end))
2575 abort ();
2576 }
2577 else
2578 {
2579 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2580 mbstate_t state;
2581 memset (&state, '\0', sizeof (mbstate_t));
25822582 # endif
2583 while (arg < arg_end)
2584 {
2585 char buf[64]; /* Assume MB_CUR_MAX <= 64. */
2586 int count;
2587
2588 if (*arg == 0)
2589 abort ();
2590 # if HAVE_WCRTOMB
2591 count = wcrtomb (buf, *arg, &state);
2583 while (arg < arg_end)
2584 {
2585 char cbuf[64]; /* Assume MB_CUR_MAX <= 64. */
2586 int count;
2587
2588 if (*arg == 0)
2589 abort ();
2590 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
2591 count = wcrtomb (cbuf, *arg, &state);
25922592 # else
2593 count = wctomb (buf, *arg);
2593 count = wctomb (cbuf, *arg);
25942594 # endif
2595 if (count <= 0)
2596 /* Inconsistency. */
2597 abort ();
2598 ENSURE_ALLOCATION (xsum (length, count));
2599 memcpy (result + length, buf, count);
2600 length += count;
2601 arg++;
2602 }
2603 }
2595 if (count <= 0)
2596 /* Inconsistency. */
2597 abort ();
2598 ENSURE_ALLOCATION (xsum (length, count));
2599 memcpy (result + length, cbuf, count);
2600 length += count;
2601 arg++;
2602 }
2603 }
26042604 # else
2605 ENSURE_ALLOCATION (xsum (length, tmpdst_len));
2606 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
2607 free (tmpdst);
2608 length += tmpdst_len;
2605 ENSURE_ALLOCATION (xsum (length, tmpdst_len));
2606 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
2607 free (tmpdst);
2608 length += tmpdst_len;
26092609 # endif
26102610
2611 if (has_width && width > w
2612 && (dp->flags & FLAG_LEFT))
2613 {
2614 size_t n = width - w;
2615 ENSURE_ALLOCATION (xsum (length, n));
2616 DCHAR_SET (result + length, ' ', n);
2617 length += n;
2618 }
2619 }
2620 }
2611 if (has_width && width > w
2612 && (dp->flags & FLAG_LEFT))
2613 {
2614 size_t n = width - w;
2615 ENSURE_ALLOCATION (xsum (length, n));
2616 DCHAR_SET (result + length, ' ', n);
2617 length += n;
2618 }
2619 }
2620 }
26212621 # endif
26222622 #endif
26232623 #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
2624 else if ((dp->conversion == 'a' || dp->conversion == 'A')
2624 else if ((dp->conversion == 'a' || dp->conversion == 'A')
26252625 # if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
2626 && (0
2626 && (0
26272627 # if NEED_PRINTF_DOUBLE
2628 || a.arg[dp->arg_index].type == TYPE_DOUBLE
2628 || a.arg[dp->arg_index].type == TYPE_DOUBLE
26292629 # endif
26302630 # if NEED_PRINTF_LONG_DOUBLE
2631 || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
2631 || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
26322632 # endif
2633 )
2633 )
26342634 # endif
2635 )
2636 {
2637 arg_type type = a.arg[dp->arg_index].type;
2638 int flags = dp->flags;
2639 int has_width;
2640 size_t width;
2641 int has_precision;
2642 size_t precision;
2643 size_t tmp_length;
2644 DCHAR_T tmpbuf[700];
2645 DCHAR_T *tmp;
2646 DCHAR_T *pad_ptr;
2647 DCHAR_T *p;
2648
2649 has_width = 0;
2650 width = 0;
2651 if (dp->width_start != dp->width_end)
2652 {
2653 if (dp->width_arg_index != ARG_NONE)
2654 {
2655 int arg;
2656
2657 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2658 abort ();
2659 arg = a.arg[dp->width_arg_index].a.a_int;
2660 if (arg < 0)
2661 {
2662 /* "A negative field width is taken as a '-' flag
2663 followed by a positive field width." */
2664 flags |= FLAG_LEFT;
2665 width = (unsigned int) (-arg);
2666 }
2667 else
2668 width = arg;
2669 }
2670 else
2671 {
2672 const FCHAR_T *digitp = dp->width_start;
2673
2674 do
2675 width = xsum (xtimes (width, 10), *digitp++ - '0');
2676 while (digitp != dp->width_end);
2677 }
2678 has_width = 1;
2679 }
2680
2681 has_precision = 0;
2682 precision = 0;
2683 if (dp->precision_start != dp->precision_end)
2684 {
2685 if (dp->precision_arg_index != ARG_NONE)
2686 {
2687 int arg;
2688
2689 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
2690 abort ();
2691 arg = a.arg[dp->precision_arg_index].a.a_int;
2692 /* "A negative precision is taken as if the precision
2693 were omitted." */
2694 if (arg >= 0)
2695 {
2696 precision = arg;
2697 has_precision = 1;
2698 }
2699 }
2700 else
2701 {
2702 const FCHAR_T *digitp = dp->precision_start + 1;
2703
2704 precision = 0;
2705 while (digitp != dp->precision_end)
2706 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
2707 has_precision = 1;
2708 }
2709 }
2710
2711 /* Allocate a temporary buffer of sufficient size. */
2712 if (type == TYPE_LONGDOUBLE)
2713 tmp_length =
2714 (unsigned int) ((LDBL_DIG + 1)
2715 * 0.831 /* decimal -> hexadecimal */
2716 )
2717 + 1; /* turn floor into ceil */
2718 else
2719 tmp_length =
2720 (unsigned int) ((DBL_DIG + 1)
2721 * 0.831 /* decimal -> hexadecimal */
2722 )
2723 + 1; /* turn floor into ceil */
2724 if (tmp_length < precision)
2725 tmp_length = precision;
2726 /* Account for sign, decimal point etc. */
2727 tmp_length = xsum (tmp_length, 12);
2728
2729 if (tmp_length < width)
2730 tmp_length = width;
2731
2732 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
2733
2734 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
2735 tmp = tmpbuf;
2736 else
2737 {
2738 size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
2739
2740 if (size_overflow_p (tmp_memsize))
2741 /* Overflow, would lead to out of memory. */
2742 goto out_of_memory;
2743 tmp = (DCHAR_T *) malloc (tmp_memsize);
2744 if (tmp == NULL)
2745 /* Out of memory. */
2746 goto out_of_memory;
2747 }
2748
2749 pad_ptr = NULL;
2750 p = tmp;
2751 if (type == TYPE_LONGDOUBLE)
2752 {
2635 )
2636 {
2637 arg_type type = a.arg[dp->arg_index].type;
2638 int flags = dp->flags;
2639 int has_width;
2640 size_t width;
2641 int has_precision;
2642 size_t precision;
2643 size_t tmp_length;
2644 DCHAR_T tmpbuf[700];
2645 DCHAR_T *tmp;
2646 DCHAR_T *pad_ptr;
2647 DCHAR_T *p;
2648
2649 has_width = 0;
2650 width = 0;
2651 if (dp->width_start != dp->width_end)
2652 {
2653 if (dp->width_arg_index != ARG_NONE)
2654 {
2655 int arg;
2656
2657 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
2658 abort ();
2659 arg = a.arg[dp->width_arg_index].a.a_int;
2660 if (arg < 0)
2661 {
2662 /* "A negative field width is taken as a '-' flag
2663 followed by a positive field width." */
2664 flags |= FLAG_LEFT;
2665 width = (unsigned int) (-arg);
2666 }
2667 else
2668 width = arg;
2669 }
2670 else
2671 {
2672 const FCHAR_T *digitp = dp->width_start;
2673
2674 do
2675 width = xsum (xtimes (width, 10), *digitp++ - '0');
2676 while (digitp != dp->width_end);
2677 }
2678 has_width = 1;
2679 }
2680
2681 has_precision = 0;
2682 precision = 0;
2683 if (dp->precision_start != dp->precision_end)
2684 {
2685 if (dp->precision_arg_index != ARG_NONE)
2686 {
2687 int arg;
2688
2689 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
2690 abort ();
2691 arg = a.arg[dp->precision_arg_index].a.a_int;
2692 /* "A negative precision is taken as if the precision
2693 were omitted." */
2694 if (arg >= 0)
2695 {
2696 precision = arg;
2697 has_precision = 1;
2698 }
2699 }
2700 else
2701 {
2702 const FCHAR_T *digitp = dp->precision_start + 1;
2703
2704 precision = 0;
2705 while (digitp != dp->precision_end)
2706 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
2707 has_precision = 1;
2708 }
2709 }
2710
2711 /* Allocate a temporary buffer of sufficient size. */
2712 if (type == TYPE_LONGDOUBLE)
2713 tmp_length =
2714 (unsigned int) ((LDBL_DIG + 1)
2715 * 0.831 /* decimal -> hexadecimal */
2716 )
2717 + 1; /* turn floor into ceil */
2718 else
2719 tmp_length =
2720 (unsigned int) ((DBL_DIG + 1)
2721 * 0.831 /* decimal -> hexadecimal */
2722 )
2723 + 1; /* turn floor into ceil */
2724 if (tmp_length < precision)
2725 tmp_length = precision;
2726 /* Account for sign, decimal point etc. */
2727 tmp_length = xsum (tmp_length, 12);
2728
2729 if (tmp_length < width)
2730 tmp_length = width;
2731
2732 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
2733
2734 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
2735 tmp = tmpbuf;
2736 else
2737 {
2738 size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
2739
2740 if (size_overflow_p (tmp_memsize))
2741 /* Overflow, would lead to out of memory. */
2742 goto out_of_memory;
2743 tmp = (DCHAR_T *) malloc (tmp_memsize);
2744 if (tmp == NULL)
2745 /* Out of memory. */
2746 goto out_of_memory;
2747 }
2748
2749 pad_ptr = NULL;
2750 p = tmp;
2751 if (type == TYPE_LONGDOUBLE)
2752 {
27532753 # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE
2754 long double arg = a.arg[dp->arg_index].a.a_longdouble;
2755
2756 if (isnanl (arg))
2757 {
2758 if (dp->conversion == 'A')
2759 {
2760 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
2761 }
2762 else
2763 {
2764 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
2765 }
2766 }
2767 else
2768 {
2769 int sign = 0;
2770 DECL_LONG_DOUBLE_ROUNDING
2771
2772 BEGIN_LONG_DOUBLE_ROUNDING ();
2773
2774 if (signbit (arg)) /* arg < 0.0L or negative zero */
2775 {
2776 sign = -1;
2777 arg = -arg;
2778 }
2779
2780 if (sign < 0)
2781 *p++ = '-';
2782 else if (flags & FLAG_SHOWSIGN)
2783 *p++ = '+';
2784 else if (flags & FLAG_SPACE)
2785 *p++ = ' ';
2786
2787 if (arg > 0.0L && arg + arg == arg)
2788 {
2789 if (dp->conversion == 'A')
2790 {
2791 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
2792 }
2793 else
2794 {
2795 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
2796 }
2797 }
2798 else
2799 {
2800 int exponent;
2801 long double mantissa;
2802
2803 if (arg > 0.0L)
2804 mantissa = printf_frexpl (arg, &exponent);
2805 else
2806 {
2807 exponent = 0;
2808 mantissa = 0.0L;
2809 }
2810
2811 if (has_precision
2812 && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
2813 {
2814 /* Round the mantissa. */
2815 long double tail = mantissa;
2816 size_t q;
2817
2818 for (q = precision; ; q--)
2819 {
2820 int digit = (int) tail;
2821 tail -= digit;
2822 if (q == 0)
2823 {
2824 if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
2825 tail = 1 - tail;
2826 else
2827 tail = - tail;
2828 break;
2829 }
2830 tail *= 16.0L;
2831 }
2832 if (tail != 0.0L)
2833 for (q = precision; q > 0; q--)
2834 tail *= 0.0625L;
2835 mantissa += tail;
2836 }
2837
2838 *p++ = '0';
2839 *p++ = dp->conversion - 'A' + 'X';
2840 pad_ptr = p;
2841 {
2842 int digit;
2843
2844 digit = (int) mantissa;
2845 mantissa -= digit;
2846 *p++ = '0' + digit;
2847 if ((flags & FLAG_ALT)
2848 || mantissa > 0.0L || precision > 0)
2849 {
2850 *p++ = decimal_point_char ();
2851 /* This loop terminates because we assume
2852 that FLT_RADIX is a power of 2. */
2853 while (mantissa > 0.0L)
2854 {
2855 mantissa *= 16.0L;
2856 digit = (int) mantissa;
2857 mantissa -= digit;
2858 *p++ = digit
2859 + (digit < 10
2860 ? '0'
2861 : dp->conversion - 10);
2862 if (precision > 0)
2863 precision--;
2864 }
2865 while (precision > 0)
2866 {
2867 *p++ = '0';
2868 precision--;
2869 }
2870 }
2871 }
2872 *p++ = dp->conversion - 'A' + 'P';
2754 long double arg = a.arg[dp->arg_index].a.a_longdouble;
2755
2756 if (isnanl (arg))
2757 {
2758 if (dp->conversion == 'A')
2759 {
2760 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
2761 }
2762 else
2763 {
2764 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
2765 }
2766 }
2767 else
2768 {
2769 int sign = 0;
2770 DECL_LONG_DOUBLE_ROUNDING
2771
2772 BEGIN_LONG_DOUBLE_ROUNDING ();
2773
2774 if (signbit (arg)) /* arg < 0.0L or negative zero */
2775 {
2776 sign = -1;
2777 arg = -arg;
2778 }
2779
2780 if (sign < 0)
2781 *p++ = '-';
2782 else if (flags & FLAG_SHOWSIGN)
2783 *p++ = '+';
2784 else if (flags & FLAG_SPACE)
2785 *p++ = ' ';
2786
2787 if (arg > 0.0L && arg + arg == arg)
2788 {
2789 if (dp->conversion == 'A')
2790 {
2791 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
2792 }
2793 else
2794 {
2795 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
2796 }
2797 }
2798 else
2799 {
2800 int exponent;
2801 long double mantissa;
2802
2803 if (arg > 0.0L)
2804 mantissa = printf_frexpl (arg, &exponent);
2805 else
2806 {
2807 exponent = 0;
2808 mantissa = 0.0L;
2809 }
2810
2811 if (has_precision
2812 && precision < (unsigned int) ((LDBL_DIG + 1) * 0.831) + 1)
2813 {
2814 /* Round the mantissa. */
2815 long double tail = mantissa;
2816 size_t q;
2817
2818 for (q = precision; ; q--)
2819 {
2820 int digit = (int) tail;
2821 tail -= digit;
2822 if (q == 0)
2823 {
2824 if (digit & 1 ? tail >= 0.5L : tail > 0.5L)
2825 tail = 1 - tail;
2826 else
2827 tail = - tail;
2828 break;
2829 }
2830 tail *= 16.0L;
2831 }
2832 if (tail != 0.0L)
2833 for (q = precision; q > 0; q--)
2834 tail *= 0.0625L;
2835 mantissa += tail;
2836 }
2837
2838 *p++ = '0';
2839 *p++ = dp->conversion - 'A' + 'X';
2840 pad_ptr = p;
2841 {
2842 int digit;
2843
2844 digit = (int) mantissa;
2845 mantissa -= digit;
2846 *p++ = '0' + digit;
2847 if ((flags & FLAG_ALT)
2848 || mantissa > 0.0L || precision > 0)
2849 {
2850 *p++ = decimal_point_char ();
2851 /* This loop terminates because we assume
2852 that FLT_RADIX is a power of 2. */
2853 while (mantissa > 0.0L)
2854 {
2855 mantissa *= 16.0L;
2856 digit = (int) mantissa;
2857 mantissa -= digit;
2858 *p++ = digit
2859 + (digit < 10
2860 ? '0'
2861 : dp->conversion - 10);
2862 if (precision > 0)
2863 precision--;
2864 }
2865 while (precision > 0)
2866 {
2867 *p++ = '0';
2868 precision--;
2869 }
2870 }
2871 }
2872 *p++ = dp->conversion - 'A' + 'P';
28732873 # if WIDE_CHAR_VERSION
2874 {
2875 static const wchar_t decimal_format[] =
2876 { '%', '+', 'd', '\0' };
2877 SNPRINTF (p, 6 + 1, decimal_format, exponent);
2878 }
2879 while (*p != '\0')
2880 p++;
2874 {
2875 static const wchar_t decimal_format[] =
2876 { '%', '+', 'd', '\0' };
2877 SNPRINTF (p, 6 + 1, decimal_format, exponent);
2878 }
2879 while (*p != '\0')
2880 p++;
28812881 # else
2882 if (sizeof (DCHAR_T) == 1)
2883 {
2884 sprintf ((char *) p, "%+d", exponent);
2885 while (*p != '\0')
2886 p++;
2887 }
2888 else
2889 {
2890 char expbuf[6 + 1];
2891 const char *ep;
2892 sprintf (expbuf, "%+d", exponent);
2893 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
2894 p++;
2895 }
2882 if (sizeof (DCHAR_T) == 1)
2883 {
2884 sprintf ((char *) p, "%+d", exponent);
2885 while (*p != '\0')
2886 p++;
2887 }
2888 else
2889 {
2890 char expbuf[6 + 1];
2891 const char *ep;
2892 sprintf (expbuf, "%+d", exponent);
2893 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
2894 p++;
2895 }
28962896 # endif
2897 }
2898
2899 END_LONG_DOUBLE_ROUNDING ();
2900 }
2897 }
2898
2899 END_LONG_DOUBLE_ROUNDING ();
2900 }
29012901 # else
2902 abort ();
2902 abort ();
29032903 # endif
2904 }
2905 else
2906 {
2904 }
2905 else
2906 {
29072907 # if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
2908 double arg = a.arg[dp->arg_index].a.a_double;
2909
2910 if (isnand (arg))
2911 {
2912 if (dp->conversion == 'A')
2913 {
2914 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
2915 }
2916 else
2917 {
2918 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
2919 }
2920 }
2921 else
2922 {
2923 int sign = 0;
2924
2925 if (signbit (arg)) /* arg < 0.0 or negative zero */
2926 {
2927 sign = -1;
2928 arg = -arg;
2929 }
2930
2931 if (sign < 0)
2932 *p++ = '-';
2933 else if (flags & FLAG_SHOWSIGN)
2934 *p++ = '+';
2935 else if (flags & FLAG_SPACE)
2936 *p++ = ' ';
2937
2938 if (arg > 0.0 && arg + arg == arg)
2939 {
2940 if (dp->conversion == 'A')
2941 {
2942 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
2943 }
2944 else
2945 {
2946 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
2947 }
2948 }
2949 else
2950 {
2951 int exponent;
2952 double mantissa;
2953
2954 if (arg > 0.0)
2955 mantissa = printf_frexp (arg, &exponent);
2956 else
2957 {
2958 exponent = 0;
2959 mantissa = 0.0;
2960 }
2961
2962 if (has_precision
2963 && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
2964 {
2965 /* Round the mantissa. */
2966 double tail = mantissa;
2967 size_t q;
2968
2969 for (q = precision; ; q--)
2970 {
2971 int digit = (int) tail;
2972 tail -= digit;
2973 if (q == 0)
2974 {
2975 if (digit & 1 ? tail >= 0.5 : tail > 0.5)
2976 tail = 1 - tail;
2977 else
2978 tail = - tail;
2979 break;
2980 }
2981 tail *= 16.0;
2982 }
2983 if (tail != 0.0)
2984 for (q = precision; q > 0; q--)
2985 tail *= 0.0625;
2986 mantissa += tail;
2987 }
2988
2989 *p++ = '0';
2990 *p++ = dp->conversion - 'A' + 'X';
2991 pad_ptr = p;
2992 {
2993 int digit;
2994
2995 digit = (int) mantissa;
2996 mantissa -= digit;
2997 *p++ = '0' + digit;
2998 if ((flags & FLAG_ALT)
2999 || mantissa > 0.0 || precision > 0)
3000 {
3001 *p++ = decimal_point_char ();
3002 /* This loop terminates because we assume
3003 that FLT_RADIX is a power of 2. */
3004 while (mantissa > 0.0)
3005 {
3006 mantissa *= 16.0;
3007 digit = (int) mantissa;
3008 mantissa -= digit;
3009 *p++ = digit
3010 + (digit < 10
3011 ? '0'
3012 : dp->conversion - 10);
3013 if (precision > 0)
3014 precision--;
3015 }
3016 while (precision > 0)
3017 {
3018 *p++ = '0';
3019 precision--;
3020 }
3021 }
3022 }
3023 *p++ = dp->conversion - 'A' + 'P';
2908 double arg = a.arg[dp->arg_index].a.a_double;
2909
2910 if (isnand (arg))
2911 {
2912 if (dp->conversion == 'A')
2913 {
2914 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
2915 }
2916 else
2917 {
2918 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
2919 }
2920 }
2921 else
2922 {
2923 int sign = 0;
2924
2925 if (signbit (arg)) /* arg < 0.0 or negative zero */
2926 {
2927 sign = -1;
2928 arg = -arg;
2929 }
2930
2931 if (sign < 0)
2932 *p++ = '-';
2933 else if (flags & FLAG_SHOWSIGN)
2934 *p++ = '+';
2935 else if (flags & FLAG_SPACE)
2936 *p++ = ' ';
2937
2938 if (arg > 0.0 && arg + arg == arg)
2939 {
2940 if (dp->conversion == 'A')
2941 {
2942 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
2943 }
2944 else
2945 {
2946 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
2947 }
2948 }
2949 else
2950 {
2951 int exponent;
2952 double mantissa;
2953
2954 if (arg > 0.0)
2955 mantissa = printf_frexp (arg, &exponent);
2956 else
2957 {
2958 exponent = 0;
2959 mantissa = 0.0;
2960 }
2961
2962 if (has_precision
2963 && precision < (unsigned int) ((DBL_DIG + 1) * 0.831) + 1)
2964 {
2965 /* Round the mantissa. */
2966 double tail = mantissa;
2967 size_t q;
2968
2969 for (q = precision; ; q--)
2970 {
2971 int digit = (int) tail;
2972 tail -= digit;
2973 if (q == 0)
2974 {
2975 if (digit & 1 ? tail >= 0.5 : tail > 0.5)
2976 tail = 1 - tail;
2977 else
2978 tail = - tail;
2979 break;
2980 }
2981 tail *= 16.0;
2982 }
2983 if (tail != 0.0)
2984 for (q = precision; q > 0; q--)
2985 tail *= 0.0625;
2986 mantissa += tail;
2987 }
2988
2989 *p++ = '0';
2990 *p++ = dp->conversion - 'A' + 'X';
2991 pad_ptr = p;
2992 {
2993 int digit;
2994
2995 digit = (int) mantissa;
2996 mantissa -= digit;
2997 *p++ = '0' + digit;
2998 if ((flags & FLAG_ALT)
2999 || mantissa > 0.0 || precision > 0)
3000 {
3001 *p++ = decimal_point_char ();
3002 /* This loop terminates because we assume
3003 that FLT_RADIX is a power of 2. */
3004 while (mantissa > 0.0)
3005 {
3006 mantissa *= 16.0;
3007 digit = (int) mantissa;
3008 mantissa -= digit;
3009 *p++ = digit
3010 + (digit < 10
3011 ? '0'
3012 : dp->conversion - 10);
3013 if (precision > 0)
3014 precision--;
3015 }
3016 while (precision > 0)
3017 {
3018 *p++ = '0';
3019 precision--;
3020 }
3021 }
3022 }
3023 *p++ = dp->conversion - 'A' + 'P';
30243024 # if WIDE_CHAR_VERSION
3025 {
3026 static const wchar_t decimal_format[] =
3027 { '%', '+', 'd', '\0' };
3028 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3029 }
3030 while (*p != '\0')
3031 p++;
3025 {
3026 static const wchar_t decimal_format[] =
3027 { '%', '+', 'd', '\0' };
3028 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3029 }
3030 while (*p != '\0')
3031 p++;
30323032 # else
3033 if (sizeof (DCHAR_T) == 1)
3034 {
3035 sprintf ((char *) p, "%+d", exponent);
3036 while (*p != '\0')
3037 p++;
3038 }
3039 else
3040 {
3041 char expbuf[6 + 1];
3042 const char *ep;
3043 sprintf (expbuf, "%+d", exponent);
3044 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3045 p++;
3046 }
3033 if (sizeof (DCHAR_T) == 1)
3034 {
3035 sprintf ((char *) p, "%+d", exponent);
3036 while (*p != '\0')
3037 p++;
3038 }
3039 else
3040 {
3041 char expbuf[6 + 1];
3042 const char *ep;
3043 sprintf (expbuf, "%+d", exponent);
3044 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3045 p++;
3046 }
30473047 # endif
3048 }
3049 }
3048 }
3049 }
30503050 # else
3051 abort ();
3051 abort ();
30523052 # endif
3053 }
3054 /* The generated string now extends from tmp to p, with the
3055 zero padding insertion point being at pad_ptr. */
3056 if (has_width && p - tmp < width)
3057 {
3058 size_t pad = width - (p - tmp);
3059 DCHAR_T *end = p + pad;
3060
3061 if (flags & FLAG_LEFT)
3062 {
3063 /* Pad with spaces on the right. */
3064 for (; pad > 0; pad--)
3065 *p++ = ' ';
3066 }
3067 else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
3068 {
3069 /* Pad with zeroes. */
3070 DCHAR_T *q = end;
3071
3072 while (p > pad_ptr)
3073 *--q = *--p;
3074 for (; pad > 0; pad--)
3075 *p++ = '0';
3076 }
3077 else
3078 {
3079 /* Pad with spaces on the left. */
3080 DCHAR_T *q = end;
3081
3082 while (p > tmp)
3083 *--q = *--p;
3084 for (; pad > 0; pad--)
3085 *p++ = ' ';
3086 }
3087
3088 p = end;
3089 }
3090
3091 {
3092 size_t count = p - tmp;
3093
3094 if (count >= tmp_length)
3095 /* tmp_length was incorrectly calculated - fix the
3096 code above! */
3097 abort ();
3098
3099 /* Make room for the result. */
3100 if (count >= allocated - length)
3101 {
3102 size_t n = xsum (length, count);
3103
3104 ENSURE_ALLOCATION (n);
3105 }
3106
3107 /* Append the result. */
3108 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
3109 if (tmp != tmpbuf)
3110 free (tmp);
3111 length += count;
3112 }
3113 }
3053 }
3054 /* The generated string now extends from tmp to p, with the
3055 zero padding insertion point being at pad_ptr. */
3056 if (has_width && p - tmp < width)
3057 {
3058 size_t pad = width - (p - tmp);
3059 DCHAR_T *end = p + pad;
3060
3061 if (flags & FLAG_LEFT)
3062 {
3063 /* Pad with spaces on the right. */
3064 for (; pad > 0; pad--)
3065 *p++ = ' ';
3066 }
3067 else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
3068 {
3069 /* Pad with zeroes. */
3070 DCHAR_T *q = end;
3071
3072 while (p > pad_ptr)
3073 *--q = *--p;
3074 for (; pad > 0; pad--)
3075 *p++ = '0';
3076 }
3077 else
3078 {
3079 /* Pad with spaces on the left. */
3080 DCHAR_T *q = end;
3081
3082 while (p > tmp)
3083 *--q = *--p;
3084 for (; pad > 0; pad--)
3085 *p++ = ' ';
3086 }
3087
3088 p = end;
3089 }
3090
3091 {
3092 size_t count = p - tmp;
3093
3094 if (count >= tmp_length)
3095 /* tmp_length was incorrectly calculated - fix the
3096 code above! */
3097 abort ();
3098
3099 /* Make room for the result. */
3100 if (count >= allocated - length)
3101 {
3102 size_t n = xsum (length, count);
3103
3104 ENSURE_ALLOCATION (n);
3105 }
3106
3107 /* Append the result. */
3108 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
3109 if (tmp != tmpbuf)
3110 free (tmp);
3111 length += count;
3112 }
3113 }
31143114 #endif
31153115 #if (NEED_PRINTF_INFINITE_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
3116 else if ((dp->conversion == 'f' || dp->conversion == 'F'
3117 || dp->conversion == 'e' || dp->conversion == 'E'
3118 || dp->conversion == 'g' || dp->conversion == 'G'
3119 || dp->conversion == 'a' || dp->conversion == 'A')
3120 && (0
3116 else if ((dp->conversion == 'f' || dp->conversion == 'F'
3117 || dp->conversion == 'e' || dp->conversion == 'E'
3118 || dp->conversion == 'g' || dp->conversion == 'G'
3119 || dp->conversion == 'a' || dp->conversion == 'A')
3120 && (0
31213121 # if NEED_PRINTF_DOUBLE
3122 || a.arg[dp->arg_index].type == TYPE_DOUBLE
3122 || a.arg[dp->arg_index].type == TYPE_DOUBLE
31233123 # elif NEED_PRINTF_INFINITE_DOUBLE
3124 || (a.arg[dp->arg_index].type == TYPE_DOUBLE
3125 /* The systems (mingw) which produce wrong output
3126 for Inf, -Inf, and NaN also do so for -0.0.
3127 Therefore we treat this case here as well. */
3128 && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double))
3124 || (a.arg[dp->arg_index].type == TYPE_DOUBLE
3125 /* The systems (mingw) which produce wrong output
3126 for Inf, -Inf, and NaN also do so for -0.0.
3127 Therefore we treat this case here as well. */
3128 && is_infinite_or_zero (a.arg[dp->arg_index].a.a_double))
31293129 # endif
31303130 # if NEED_PRINTF_LONG_DOUBLE
3131 || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
3131 || a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
31323132 # elif NEED_PRINTF_INFINITE_LONG_DOUBLE
3133 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
3134 /* Some systems produce wrong output for Inf,
3135 -Inf, and NaN. Some systems in this category
3136 (IRIX 5.3) also do so for -0.0. Therefore we
3137 treat this case here as well. */
3138 && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
3133 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
3134 /* Some systems produce wrong output for Inf,
3135 -Inf, and NaN. Some systems in this category
3136 (IRIX 5.3) also do so for -0.0. Therefore we
3137 treat this case here as well. */
3138 && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
31393139 # endif
3140 ))
3141 {
3140 ))
3141 {
31423142 # if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE)
3143 arg_type type = a.arg[dp->arg_index].type;
3143 arg_type type = a.arg[dp->arg_index].type;
31443144 # endif
3145 int flags = dp->flags;
3146 int has_width;
3147 size_t width;
3148 int has_precision;
3149 size_t precision;
3150 size_t tmp_length;
3151 DCHAR_T tmpbuf[700];
3152 DCHAR_T *tmp;
3153 DCHAR_T *pad_ptr;
3154 DCHAR_T *p;
3155
3156 has_width = 0;
3157 width = 0;
3158 if (dp->width_start != dp->width_end)
3159 {
3160 if (dp->width_arg_index != ARG_NONE)
3161 {
3162 int arg;
3163
3164 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3165 abort ();
3166 arg = a.arg[dp->width_arg_index].a.a_int;
3167 if (arg < 0)
3168 {
3169 /* "A negative field width is taken as a '-' flag
3170 followed by a positive field width." */
3171 flags |= FLAG_LEFT;
3172 width = (unsigned int) (-arg);
3173 }
3174 else
3175 width = arg;
3176 }
3177 else
3178 {
3179 const FCHAR_T *digitp = dp->width_start;
3180
3181 do
3182 width = xsum (xtimes (width, 10), *digitp++ - '0');
3183 while (digitp != dp->width_end);
3184 }
3185 has_width = 1;
3186 }
3187
3188 has_precision = 0;
3189 precision = 0;
3190 if (dp->precision_start != dp->precision_end)
3191 {
3192 if (dp->precision_arg_index != ARG_NONE)
3193 {
3194 int arg;
3195
3196 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
3197 abort ();
3198 arg = a.arg[dp->precision_arg_index].a.a_int;
3199 /* "A negative precision is taken as if the precision
3200 were omitted." */
3201 if (arg >= 0)
3202 {
3203 precision = arg;
3204 has_precision = 1;
3205 }
3206 }
3207 else
3208 {
3209 const FCHAR_T *digitp = dp->precision_start + 1;
3210
3211 precision = 0;
3212 while (digitp != dp->precision_end)
3213 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
3214 has_precision = 1;
3215 }
3216 }
3217
3218 /* POSIX specifies the default precision to be 6 for %f, %F,
3219 %e, %E, but not for %g, %G. Implementations appear to use
3220 the same default precision also for %g, %G. But for %a, %A,
3221 the default precision is 0. */
3222 if (!has_precision)
3223 if (!(dp->conversion == 'a' || dp->conversion == 'A'))
3224 precision = 6;
3225
3226 /* Allocate a temporary buffer of sufficient size. */
3145 int flags = dp->flags;
3146 int has_width;
3147 size_t width;
3148 int has_precision;
3149 size_t precision;
3150 size_t tmp_length;
3151 DCHAR_T tmpbuf[700];
3152 DCHAR_T *tmp;
3153 DCHAR_T *pad_ptr;
3154 DCHAR_T *p;
3155
3156 has_width = 0;
3157 width = 0;
3158 if (dp->width_start != dp->width_end)
3159 {
3160 if (dp->width_arg_index != ARG_NONE)
3161 {
3162 int arg;
3163
3164 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
3165 abort ();
3166 arg = a.arg[dp->width_arg_index].a.a_int;
3167 if (arg < 0)
3168 {
3169 /* "A negative field width is taken as a '-' flag
3170 followed by a positive field width." */
3171 flags |= FLAG_LEFT;
3172 width = (unsigned int) (-arg);
3173 }
3174 else
3175 width = arg;
3176 }
3177 else
3178 {
3179 const FCHAR_T *digitp = dp->width_start;
3180
3181 do
3182 width = xsum (xtimes (width, 10), *digitp++ - '0');
3183 while (digitp != dp->width_end);
3184 }
3185 has_width = 1;
3186 }
3187
3188 has_precision = 0;
3189 precision = 0;
3190 if (dp->precision_start != dp->precision_end)
3191 {
3192 if (dp->precision_arg_index != ARG_NONE)
3193 {
3194 int arg;
3195
3196 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
3197 abort ();
3198 arg = a.arg[dp->precision_arg_index].a.a_int;
3199 /* "A negative precision is taken as if the precision
3200 were omitted." */
3201 if (arg >= 0)
3202 {
3203 precision = arg;
3204 has_precision = 1;
3205 }
3206 }
3207 else
3208 {
3209 const FCHAR_T *digitp = dp->precision_start + 1;
3210
3211 precision = 0;
3212 while (digitp != dp->precision_end)
3213 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
3214 has_precision = 1;
3215 }
3216 }
3217
3218 /* POSIX specifies the default precision to be 6 for %f, %F,
3219 %e, %E, but not for %g, %G. Implementations appear to use
3220 the same default precision also for %g, %G. But for %a, %A,
3221 the default precision is 0. */
3222 if (!has_precision)
3223 if (!(dp->conversion == 'a' || dp->conversion == 'A'))
3224 precision = 6;
3225
3226 /* Allocate a temporary buffer of sufficient size. */
32273227 # if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
3228 tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
3228 tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : DBL_DIG + 1);
32293229 # elif NEED_PRINTF_INFINITE_DOUBLE && NEED_PRINTF_LONG_DOUBLE
3230 tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0);
3230 tmp_length = (type == TYPE_LONGDOUBLE ? LDBL_DIG + 1 : 0);
32313231 # elif NEED_PRINTF_LONG_DOUBLE
3232 tmp_length = LDBL_DIG + 1;
3232 tmp_length = LDBL_DIG + 1;
32333233 # elif NEED_PRINTF_DOUBLE
3234 tmp_length = DBL_DIG + 1;
3234 tmp_length = DBL_DIG + 1;
32353235 # else
3236 tmp_length = 0;
3236 tmp_length = 0;
32373237 # endif
3238 if (tmp_length < precision)
3239 tmp_length = precision;
3238 if (tmp_length < precision)
3239 tmp_length = precision;
32403240 # if NEED_PRINTF_LONG_DOUBLE
32413241 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
3242 if (type == TYPE_LONGDOUBLE)
3242 if (type == TYPE_LONGDOUBLE)
32433243 # endif
3244 if (dp->conversion == 'f' || dp->conversion == 'F')
3245 {
3246 long double arg = a.arg[dp->arg_index].a.a_longdouble;
3247 if (!(isnanl (arg) || arg + arg == arg))
3248 {
3249 /* arg is finite and nonzero. */
3250 int exponent = floorlog10l (arg < 0 ? -arg : arg);
3251 if (exponent >= 0 && tmp_length < exponent + precision)
3252 tmp_length = exponent + precision;
3253 }
3254 }
3244 if (dp->conversion == 'f' || dp->conversion == 'F')
3245 {
3246 long double arg = a.arg[dp->arg_index].a.a_longdouble;
3247 if (!(isnanl (arg) || arg + arg == arg))
3248 {
3249 /* arg is finite and nonzero. */
3250 int exponent = floorlog10l (arg < 0 ? -arg : arg);
3251 if (exponent >= 0 && tmp_length < exponent + precision)
3252 tmp_length = exponent + precision;
3253 }
3254 }
32553255 # endif
32563256 # if NEED_PRINTF_DOUBLE
32573257 # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
3258 if (type == TYPE_DOUBLE)
3258 if (type == TYPE_DOUBLE)
32593259 # endif
3260 if (dp->conversion == 'f' || dp->conversion == 'F')
3261 {
3262 double arg = a.arg[dp->arg_index].a.a_double;
3263 if (!(isnand (arg) || arg + arg == arg))
3264 {
3265 /* arg is finite and nonzero. */
3266 int exponent = floorlog10 (arg < 0 ? -arg : arg);
3267 if (exponent >= 0 && tmp_length < exponent + precision)
3268 tmp_length = exponent + precision;
3269 }
3270 }
3260 if (dp->conversion == 'f' || dp->conversion == 'F')
3261 {
3262 double arg = a.arg[dp->arg_index].a.a_double;
3263 if (!(isnand (arg) || arg + arg == arg))
3264 {
3265 /* arg is finite and nonzero. */
3266 int exponent = floorlog10 (arg < 0 ? -arg : arg);
3267 if (exponent >= 0 && tmp_length < exponent + precision)
3268 tmp_length = exponent + precision;
3269 }
3270 }
32713271 # endif
3272 /* Account for sign, decimal point etc. */
3273 tmp_length = xsum (tmp_length, 12);
3274
3275 if (tmp_length < width)
3276 tmp_length = width;
3277
3278 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
3279
3280 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
3281 tmp = tmpbuf;
3282 else
3283 {
3284 size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
3285
3286 if (size_overflow_p (tmp_memsize))
3287 /* Overflow, would lead to out of memory. */
3288 goto out_of_memory;
3289 tmp = (DCHAR_T *) malloc (tmp_memsize);
3290 if (tmp == NULL)
3291 /* Out of memory. */
3292 goto out_of_memory;
3293 }
3294
3295 pad_ptr = NULL;
3296 p = tmp;
3272 /* Account for sign, decimal point etc. */
3273 tmp_length = xsum (tmp_length, 12);
3274
3275 if (tmp_length < width)
3276 tmp_length = width;
3277
3278 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
3279
3280 if (tmp_length <= sizeof (tmpbuf) / sizeof (DCHAR_T))
3281 tmp = tmpbuf;
3282 else
3283 {
3284 size_t tmp_memsize = xtimes (tmp_length, sizeof (DCHAR_T));
3285
3286 if (size_overflow_p (tmp_memsize))
3287 /* Overflow, would lead to out of memory. */
3288 goto out_of_memory;
3289 tmp = (DCHAR_T *) malloc (tmp_memsize);
3290 if (tmp == NULL)
3291 /* Out of memory. */
3292 goto out_of_memory;
3293 }
3294
3295 pad_ptr = NULL;
3296 p = tmp;
32973297
32983298 # if NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE
32993299 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
3300 if (type == TYPE_LONGDOUBLE)
3300 if (type == TYPE_LONGDOUBLE)
33013301 # endif
3302 {
3303 long double arg = a.arg[dp->arg_index].a.a_longdouble;
3304
3305 if (isnanl (arg))
3306 {
3307 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3308 {
3309 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
3310 }
3311 else
3312 {
3313 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
3314 }
3315 }
3316 else
3317 {
3318 int sign = 0;
3319 DECL_LONG_DOUBLE_ROUNDING
3320
3321 BEGIN_LONG_DOUBLE_ROUNDING ();
3322
3323 if (signbit (arg)) /* arg < 0.0L or negative zero */
3324 {
3325 sign = -1;
3326 arg = -arg;
3327 }
3328
3329 if (sign < 0)
3330 *p++ = '-';
3331 else if (flags & FLAG_SHOWSIGN)
3332 *p++ = '+';
3333 else if (flags & FLAG_SPACE)
3334 *p++ = ' ';
3335
3336 if (arg > 0.0L && arg + arg == arg)
3337 {
3338 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3339 {
3340 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
3341 }
3342 else
3343 {
3344 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
3345 }
3346 }
3347 else
3348 {
3302 {
3303 long double arg = a.arg[dp->arg_index].a.a_longdouble;
3304
3305 if (isnanl (arg))
3306 {
3307 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3308 {
3309 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
3310 }
3311 else
3312 {
3313 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
3314 }
3315 }
3316 else
3317 {
3318 int sign = 0;
3319 DECL_LONG_DOUBLE_ROUNDING
3320
3321 BEGIN_LONG_DOUBLE_ROUNDING ();
3322
3323 if (signbit (arg)) /* arg < 0.0L or negative zero */
3324 {
3325 sign = -1;
3326 arg = -arg;
3327 }
3328
3329 if (sign < 0)
3330 *p++ = '-';
3331 else if (flags & FLAG_SHOWSIGN)
3332 *p++ = '+';
3333 else if (flags & FLAG_SPACE)
3334 *p++ = ' ';
3335
3336 if (arg > 0.0L && arg + arg == arg)
3337 {
3338 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3339 {
3340 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
3341 }
3342 else
3343 {
3344 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
3345 }
3346 }
3347 else
3348 {
33493349 # if NEED_PRINTF_LONG_DOUBLE
3350 pad_ptr = p;
3351
3352 if (dp->conversion == 'f' || dp->conversion == 'F')
3353 {
3354 char *digits;
3355 size_t ndigits;
3356
3357 digits =
3358 scale10_round_decimal_long_double (arg, precision);
3359 if (digits == NULL)
3360 {
3361 END_LONG_DOUBLE_ROUNDING ();
3362 goto out_of_memory;
3363 }
3364 ndigits = strlen (digits);
3365
3366 if (ndigits > precision)
3367 do
3368 {
3369 --ndigits;
3370 *p++ = digits[ndigits];
3371 }
3372 while (ndigits > precision);
3373 else
3374 *p++ = '0';
3375 /* Here ndigits <= precision. */
3376 if ((flags & FLAG_ALT) || precision > 0)
3377 {
3378 *p++ = decimal_point_char ();
3379 for (; precision > ndigits; precision--)
3380 *p++ = '0';
3381 while (ndigits > 0)
3382 {
3383 --ndigits;
3384 *p++ = digits[ndigits];
3385 }
3386 }
3387
3388 free (digits);
3389 }
3390 else if (dp->conversion == 'e' || dp->conversion == 'E')
3391 {
3392 int exponent;
3393
3394 if (arg == 0.0L)
3395 {
3396 exponent = 0;
3397 *p++ = '0';
3398 if ((flags & FLAG_ALT) || precision > 0)
3399 {
3400 *p++ = decimal_point_char ();
3401 for (; precision > 0; precision--)
3402 *p++ = '0';
3403 }
3404 }
3405 else
3406 {
3407 /* arg > 0.0L. */
3408 int adjusted;
3409 char *digits;
3410 size_t ndigits;
3411
3412 exponent = floorlog10l (arg);
3413 adjusted = 0;
3414 for (;;)
3415 {
3416 digits =
3417 scale10_round_decimal_long_double (arg,
3418 (int)precision - exponent);
3419 if (digits == NULL)
3420 {
3421 END_LONG_DOUBLE_ROUNDING ();
3422 goto out_of_memory;
3423 }
3424 ndigits = strlen (digits);
3425
3426 if (ndigits == precision + 1)
3427 break;
3428 if (ndigits < precision
3429 || ndigits > precision + 2)
3430 /* The exponent was not guessed
3431 precisely enough. */
3432 abort ();
3433 if (adjusted)
3434 /* None of two values of exponent is
3435 the right one. Prevent an endless
3436 loop. */
3437 abort ();
3438 free (digits);
3439 if (ndigits == precision)
3440 exponent -= 1;
3441 else
3442 exponent += 1;
3443 adjusted = 1;
3444 }
3445 /* Here ndigits = precision+1. */
3446 if (is_borderline (digits, precision))
3447 {
3448 /* Maybe the exponent guess was too high
3449 and a smaller exponent can be reached
3450 by turning a 10...0 into 9...9x. */
3451 char *digits2 =
3452 scale10_round_decimal_long_double (arg,
3453 (int)precision - exponent + 1);
3454 if (digits2 == NULL)
3455 {
3456 free (digits);
3457 END_LONG_DOUBLE_ROUNDING ();
3458 goto out_of_memory;
3459 }
3460 if (strlen (digits2) == precision + 1)
3461 {
3462 free (digits);
3463 digits = digits2;
3464 exponent -= 1;
3465 }
3466 else
3467 free (digits2);
3468 }
3469 /* Here ndigits = precision+1. */
3470
3471 *p++ = digits[--ndigits];
3472 if ((flags & FLAG_ALT) || precision > 0)
3473 {
3474 *p++ = decimal_point_char ();
3475 while (ndigits > 0)
3476 {
3477 --ndigits;
3478 *p++ = digits[ndigits];
3479 }
3480 }
3481
3482 free (digits);
3483 }
3484
3485 *p++ = dp->conversion; /* 'e' or 'E' */
3350 pad_ptr = p;
3351
3352 if (dp->conversion == 'f' || dp->conversion == 'F')
3353 {
3354 char *digits;
3355 size_t ndigits;
3356
3357 digits =
3358 scale10_round_decimal_long_double (arg, precision);
3359 if (digits == NULL)
3360 {
3361 END_LONG_DOUBLE_ROUNDING ();
3362 goto out_of_memory;
3363 }
3364 ndigits = strlen (digits);
3365
3366 if (ndigits > precision)
3367 do
3368 {
3369 --ndigits;
3370 *p++ = digits[ndigits];
3371 }
3372 while (ndigits > precision);
3373 else
3374 *p++ = '0';
3375 /* Here ndigits <= precision. */
3376 if ((flags & FLAG_ALT) || precision > 0)
3377 {
3378 *p++ = decimal_point_char ();
3379 for (; precision > ndigits; precision--)
3380 *p++ = '0';
3381 while (ndigits > 0)
3382 {
3383 --ndigits;
3384 *p++ = digits[ndigits];
3385 }
3386 }
3387
3388 free (digits);
3389 }
3390 else if (dp->conversion == 'e' || dp->conversion == 'E')
3391 {
3392 int exponent;
3393
3394 if (arg == 0.0L)
3395 {
3396 exponent = 0;
3397 *p++ = '0';
3398 if ((flags & FLAG_ALT) || precision > 0)
3399 {
3400 *p++ = decimal_point_char ();
3401 for (; precision > 0; precision--)
3402 *p++ = '0';
3403 }
3404 }
3405 else
3406 {
3407 /* arg > 0.0L. */
3408 int adjusted;
3409 char *digits;
3410 size_t ndigits;
3411
3412 exponent = floorlog10l (arg);
3413 adjusted = 0;
3414 for (;;)
3415 {
3416 digits =
3417 scale10_round_decimal_long_double (arg,
3418 (int)precision - exponent);
3419 if (digits == NULL)
3420 {
3421 END_LONG_DOUBLE_ROUNDING ();
3422 goto out_of_memory;
3423 }
3424 ndigits = strlen (digits);
3425
3426 if (ndigits == precision + 1)
3427 break;
3428 if (ndigits < precision
3429 || ndigits > precision + 2)
3430 /* The exponent was not guessed
3431 precisely enough. */
3432 abort ();
3433 if (adjusted)
3434 /* None of two values of exponent is
3435 the right one. Prevent an endless
3436 loop. */
3437 abort ();
3438 free (digits);
3439 if (ndigits == precision)
3440 exponent -= 1;
3441 else
3442 exponent += 1;
3443 adjusted = 1;
3444 }
3445 /* Here ndigits = precision+1. */
3446 if (is_borderline (digits, precision))
3447 {
3448 /* Maybe the exponent guess was too high
3449 and a smaller exponent can be reached
3450 by turning a 10...0 into 9...9x. */
3451 char *digits2 =
3452 scale10_round_decimal_long_double (arg,
3453 (int)precision - exponent + 1);
3454 if (digits2 == NULL)
3455 {
3456 free (digits);
3457 END_LONG_DOUBLE_ROUNDING ();
3458 goto out_of_memory;
3459 }
3460 if (strlen (digits2) == precision + 1)
3461 {
3462 free (digits);
3463 digits = digits2;
3464 exponent -= 1;
3465 }
3466 else
3467 free (digits2);
3468 }
3469 /* Here ndigits = precision+1. */
3470
3471 *p++ = digits[--ndigits];
3472 if ((flags & FLAG_ALT) || precision > 0)
3473 {
3474 *p++ = decimal_point_char ();
3475 while (ndigits > 0)
3476 {
3477 --ndigits;
3478 *p++ = digits[ndigits];
3479 }
3480 }
3481
3482 free (digits);
3483 }
3484
3485 *p++ = dp->conversion; /* 'e' or 'E' */
34863486 # if WIDE_CHAR_VERSION
3487 {
3488 static const wchar_t decimal_format[] =
3489 { '%', '+', '.', '2', 'd', '\0' };
3490 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3491 }
3492 while (*p != '\0')
3493 p++;
3487 {
3488 static const wchar_t decimal_format[] =
3489 { '%', '+', '.', '2', 'd', '\0' };
3490 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3491 }
3492 while (*p != '\0')
3493 p++;
34943494 # else
3495 if (sizeof (DCHAR_T) == 1)
3496 {
3497 sprintf ((char *) p, "%+.2d", exponent);
3498 while (*p != '\0')
3499 p++;
3500 }
3501 else
3502 {
3503 char expbuf[6 + 1];
3504 const char *ep;
3505 sprintf (expbuf, "%+.2d", exponent);
3506 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3507 p++;
3508 }
3495 if (sizeof (DCHAR_T) == 1)
3496 {
3497 sprintf ((char *) p, "%+.2d", exponent);
3498 while (*p != '\0')
3499 p++;
3500 }
3501 else
3502 {
3503 char expbuf[6 + 1];
3504 const char *ep;
3505 sprintf (expbuf, "%+.2d", exponent);
3506 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3507 p++;
3508 }
35093509 # endif
3510 }
3511 else if (dp->conversion == 'g' || dp->conversion == 'G')
3512 {
3513 if (precision == 0)
3514 precision = 1;
3515 /* precision >= 1. */
3516
3517 if (arg == 0.0L)
3518 /* The exponent is 0, >= -4, < precision.
3519 Use fixed-point notation. */
3520 {
3521 size_t ndigits = precision;
3522 /* Number of trailing zeroes that have to be
3523 dropped. */
3524 size_t nzeroes =
3525 (flags & FLAG_ALT ? 0 : precision - 1);
3526
3527 --ndigits;
3528 *p++ = '0';
3529 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3530 {
3531 *p++ = decimal_point_char ();
3532 while (ndigits > nzeroes)
3533 {
3534 --ndigits;
3535 *p++ = '0';
3536 }
3537 }
3538 }
3539 else
3540 {
3541 /* arg > 0.0L. */
3542 int exponent;
3543 int adjusted;
3544 char *digits;
3545 size_t ndigits;
3546 size_t nzeroes;
3547
3548 exponent = floorlog10l (arg);
3549 adjusted = 0;
3550 for (;;)
3551 {
3552 digits =
3553 scale10_round_decimal_long_double (arg,
3554 (int)(precision - 1) - exponent);
3555 if (digits == NULL)
3556 {
3557 END_LONG_DOUBLE_ROUNDING ();
3558 goto out_of_memory;
3559 }
3560 ndigits = strlen (digits);
3561
3562 if (ndigits == precision)
3563 break;
3564 if (ndigits < precision - 1
3565 || ndigits > precision + 1)
3566 /* The exponent was not guessed
3567 precisely enough. */
3568 abort ();
3569 if (adjusted)
3570 /* None of two values of exponent is
3571 the right one. Prevent an endless
3572 loop. */
3573 abort ();
3574 free (digits);
3575 if (ndigits < precision)
3576 exponent -= 1;
3577 else
3578 exponent += 1;
3579 adjusted = 1;
3580 }
3581 /* Here ndigits = precision. */
3582 if (is_borderline (digits, precision - 1))
3583 {
3584 /* Maybe the exponent guess was too high
3585 and a smaller exponent can be reached
3586 by turning a 10...0 into 9...9x. */
3587 char *digits2 =
3588 scale10_round_decimal_long_double (arg,
3589 (int)(precision - 1) - exponent + 1);
3590 if (digits2 == NULL)
3591 {
3592 free (digits);
3593 END_LONG_DOUBLE_ROUNDING ();
3594 goto out_of_memory;
3595 }
3596 if (strlen (digits2) == precision)
3597 {
3598 free (digits);
3599 digits = digits2;
3600 exponent -= 1;
3601 }
3602 else
3603 free (digits2);
3604 }
3605 /* Here ndigits = precision. */
3606
3607 /* Determine the number of trailing zeroes
3608 that have to be dropped. */
3609 nzeroes = 0;
3610 if ((flags & FLAG_ALT) == 0)
3611 while (nzeroes < ndigits
3612 && digits[nzeroes] == '0')
3613 nzeroes++;
3614
3615 /* The exponent is now determined. */
3616 if (exponent >= -4
3617 && exponent < (long)precision)
3618 {
3619 /* Fixed-point notation:
3620 max(exponent,0)+1 digits, then the
3621 decimal point, then the remaining
3622 digits without trailing zeroes. */
3623 if (exponent >= 0)
3624 {
3625 size_t count = exponent + 1;
3626 /* Note: count <= precision = ndigits. */
3627 for (; count > 0; count--)
3628 *p++ = digits[--ndigits];
3629 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3630 {
3631 *p++ = decimal_point_char ();
3632 while (ndigits > nzeroes)
3633 {
3634 --ndigits;
3635 *p++ = digits[ndigits];
3636 }
3637 }
3638 }
3639 else
3640 {
3641 size_t count = -exponent - 1;
3642 *p++ = '0';
3643 *p++ = decimal_point_char ();
3644 for (; count > 0; count--)
3645 *p++ = '0';
3646 while (ndigits > nzeroes)
3647 {
3648 --ndigits;
3649 *p++ = digits[ndigits];
3650 }
3651 }
3652 }
3653 else
3654 {
3655 /* Exponential notation. */
3656 *p++ = digits[--ndigits];
3657 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3658 {
3659 *p++ = decimal_point_char ();
3660 while (ndigits > nzeroes)
3661 {
3662 --ndigits;
3663 *p++ = digits[ndigits];
3664 }
3665 }
3666 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
3510 }
3511 else if (dp->conversion == 'g' || dp->conversion == 'G')
3512 {
3513 if (precision == 0)
3514 precision = 1;
3515 /* precision >= 1. */
3516
3517 if (arg == 0.0L)
3518 /* The exponent is 0, >= -4, < precision.
3519 Use fixed-point notation. */
3520 {
3521 size_t ndigits = precision;
3522 /* Number of trailing zeroes that have to be
3523 dropped. */
3524 size_t nzeroes =
3525 (flags & FLAG_ALT ? 0 : precision - 1);
3526
3527 --ndigits;
3528 *p++ = '0';
3529 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3530 {
3531 *p++ = decimal_point_char ();
3532 while (ndigits > nzeroes)
3533 {
3534 --ndigits;
3535 *p++ = '0';
3536 }
3537 }
3538 }
3539 else
3540 {
3541 /* arg > 0.0L. */
3542 int exponent;
3543 int adjusted;
3544 char *digits;
3545 size_t ndigits;
3546 size_t nzeroes;
3547
3548 exponent = floorlog10l (arg);
3549 adjusted = 0;
3550 for (;;)
3551 {
3552 digits =
3553 scale10_round_decimal_long_double (arg,
3554 (int)(precision - 1) - exponent);
3555 if (digits == NULL)
3556 {
3557 END_LONG_DOUBLE_ROUNDING ();
3558 goto out_of_memory;
3559 }
3560 ndigits = strlen (digits);
3561
3562 if (ndigits == precision)
3563 break;
3564 if (ndigits < precision - 1
3565 || ndigits > precision + 1)
3566 /* The exponent was not guessed
3567 precisely enough. */
3568 abort ();
3569 if (adjusted)
3570 /* None of two values of exponent is
3571 the right one. Prevent an endless
3572 loop. */
3573 abort ();
3574 free (digits);
3575 if (ndigits < precision)
3576 exponent -= 1;
3577 else
3578 exponent += 1;
3579 adjusted = 1;
3580 }
3581 /* Here ndigits = precision. */
3582 if (is_borderline (digits, precision - 1))
3583 {
3584 /* Maybe the exponent guess was too high
3585 and a smaller exponent can be reached
3586 by turning a 10...0 into 9...9x. */
3587 char *digits2 =
3588 scale10_round_decimal_long_double (arg,
3589 (int)(precision - 1) - exponent + 1);
3590 if (digits2 == NULL)
3591 {
3592 free (digits);
3593 END_LONG_DOUBLE_ROUNDING ();
3594 goto out_of_memory;
3595 }
3596 if (strlen (digits2) == precision)
3597 {
3598 free (digits);
3599 digits = digits2;
3600 exponent -= 1;
3601 }
3602 else
3603 free (digits2);
3604 }
3605 /* Here ndigits = precision. */
3606
3607 /* Determine the number of trailing zeroes
3608 that have to be dropped. */
3609 nzeroes = 0;
3610 if ((flags & FLAG_ALT) == 0)
3611 while (nzeroes < ndigits
3612 && digits[nzeroes] == '0')
3613 nzeroes++;
3614
3615 /* The exponent is now determined. */
3616 if (exponent >= -4
3617 && exponent < (long)precision)
3618 {
3619 /* Fixed-point notation:
3620 max(exponent,0)+1 digits, then the
3621 decimal point, then the remaining
3622 digits without trailing zeroes. */
3623 if (exponent >= 0)
3624 {
3625 size_t count = exponent + 1;
3626 /* Note: count <= precision = ndigits. */
3627 for (; count > 0; count--)
3628 *p++ = digits[--ndigits];
3629 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3630 {
3631 *p++ = decimal_point_char ();
3632 while (ndigits > nzeroes)
3633 {
3634 --ndigits;
3635 *p++ = digits[ndigits];
3636 }
3637 }
3638 }
3639 else
3640 {
3641 size_t count = -exponent - 1;
3642 *p++ = '0';
3643 *p++ = decimal_point_char ();
3644 for (; count > 0; count--)
3645 *p++ = '0';
3646 while (ndigits > nzeroes)
3647 {
3648 --ndigits;
3649 *p++ = digits[ndigits];
3650 }
3651 }
3652 }
3653 else
3654 {
3655 /* Exponential notation. */
3656 *p++ = digits[--ndigits];
3657 if ((flags & FLAG_ALT) || ndigits > nzeroes)
3658 {
3659 *p++ = decimal_point_char ();
3660 while (ndigits > nzeroes)
3661 {
3662 --ndigits;
3663 *p++ = digits[ndigits];
3664 }
3665 }
3666 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
36673667 # if WIDE_CHAR_VERSION
3668 {
3669 static const wchar_t decimal_format[] =
3670 { '%', '+', '.', '2', 'd', '\0' };
3671 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3672 }
3673 while (*p != '\0')
3674 p++;
3668 {
3669 static const wchar_t decimal_format[] =
3670 { '%', '+', '.', '2', 'd', '\0' };
3671 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3672 }
3673 while (*p != '\0')
3674 p++;
36753675 # else
3676 if (sizeof (DCHAR_T) == 1)
3677 {
3678 sprintf ((char *) p, "%+.2d", exponent);
3679 while (*p != '\0')
3680 p++;
3681 }
3682 else
3683 {
3684 char expbuf[6 + 1];
3685 const char *ep;
3686 sprintf (expbuf, "%+.2d", exponent);
3687 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3688 p++;
3689 }
3676 if (sizeof (DCHAR_T) == 1)
3677 {
3678 sprintf ((char *) p, "%+.2d", exponent);
3679 while (*p != '\0')
3680 p++;
3681 }
3682 else
3683 {
3684 char expbuf[6 + 1];
3685 const char *ep;
3686 sprintf (expbuf, "%+.2d", exponent);
3687 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3688 p++;
3689 }
36903690 # endif
3691 }
3692
3693 free (digits);
3694 }
3695 }
3696 else
3697 abort ();
3691 }
3692
3693 free (digits);
3694 }
3695 }
3696 else
3697 abort ();
36983698 # else
3699 /* arg is finite. */
3700 if (!(arg == 0.0L))
3701 abort ();
3702
3703 pad_ptr = p;
3704
3705 if (dp->conversion == 'f' || dp->conversion == 'F')
3706 {
3707 *p++ = '0';
3708 if ((flags & FLAG_ALT) || precision > 0)
3709 {
3710 *p++ = decimal_point_char ();
3711 for (; precision > 0; precision--)
3712 *p++ = '0';
3713 }
3714 }
3715 else if (dp->conversion == 'e' || dp->conversion == 'E')
3716 {
3717 *p++ = '0';
3718 if ((flags & FLAG_ALT) || precision > 0)
3719 {
3720 *p++ = decimal_point_char ();
3721 for (; precision > 0; precision--)
3722 *p++ = '0';
3723 }
3724 *p++ = dp->conversion; /* 'e' or 'E' */
3725 *p++ = '+';
3726 *p++ = '0';
3727 *p++ = '0';
3728 }
3729 else if (dp->conversion == 'g' || dp->conversion == 'G')
3730 {
3731 *p++ = '0';
3732 if (flags & FLAG_ALT)
3733 {
3734 size_t ndigits =
3735 (precision > 0 ? precision - 1 : 0);
3736 *p++ = decimal_point_char ();
3737 for (; ndigits > 0; --ndigits)
3738 *p++ = '0';
3739 }
3740 }
3741 else if (dp->conversion == 'a' || dp->conversion == 'A')
3742 {
3743 *p++ = '0';
3744 *p++ = dp->conversion - 'A' + 'X';
3745 pad_ptr = p;
3746 *p++ = '0';
3747 if ((flags & FLAG_ALT) || precision > 0)
3748 {
3749 *p++ = decimal_point_char ();
3750 for (; precision > 0; precision--)
3751 *p++ = '0';
3752 }
3753 *p++ = dp->conversion - 'A' + 'P';
3754 *p++ = '+';
3755 *p++ = '0';
3756 }
3757 else
3758 abort ();
3699 /* arg is finite. */
3700 if (!(arg == 0.0L))
3701 abort ();
3702
3703 pad_ptr = p;
3704
3705 if (dp->conversion == 'f' || dp->conversion == 'F')
3706 {
3707 *p++ = '0';
3708 if ((flags & FLAG_ALT) || precision > 0)
3709 {
3710 *p++ = decimal_point_char ();
3711 for (; precision > 0; precision--)
3712 *p++ = '0';
3713 }
3714 }
3715 else if (dp->conversion == 'e' || dp->conversion == 'E')
3716 {
3717 *p++ = '0';
3718 if ((flags & FLAG_ALT) || precision > 0)
3719 {
3720 *p++ = decimal_point_char ();
3721 for (; precision > 0; precision--)
3722 *p++ = '0';
3723 }
3724 *p++ = dp->conversion; /* 'e' or 'E' */
3725 *p++ = '+';
3726 *p++ = '0';
3727 *p++ = '0';
3728 }
3729 else if (dp->conversion == 'g' || dp->conversion == 'G')
3730 {
3731 *p++ = '0';
3732 if (flags & FLAG_ALT)
3733 {
3734 size_t ndigits =
3735 (precision > 0 ? precision - 1 : 0);
3736 *p++ = decimal_point_char ();
3737 for (; ndigits > 0; --ndigits)
3738 *p++ = '0';
3739 }
3740 }
3741 else if (dp->conversion == 'a' || dp->conversion == 'A')
3742 {
3743 *p++ = '0';
3744 *p++ = dp->conversion - 'A' + 'X';
3745 pad_ptr = p;
3746 *p++ = '0';
3747 if ((flags & FLAG_ALT) || precision > 0)
3748 {
3749 *p++ = decimal_point_char ();
3750 for (; precision > 0; precision--)
3751 *p++ = '0';
3752 }
3753 *p++ = dp->conversion - 'A' + 'P';
3754 *p++ = '+';
3755 *p++ = '0';
3756 }
3757 else
3758 abort ();
37593759 # endif
3760 }
3761
3762 END_LONG_DOUBLE_ROUNDING ();
3763 }
3764 }
3760 }
3761
3762 END_LONG_DOUBLE_ROUNDING ();
3763 }
3764 }
37653765 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
3766 else
3766 else
37673767 # endif
37683768 # endif
37693769 # if NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE
3770 {
3771 double arg = a.arg[dp->arg_index].a.a_double;
3772
3773 if (isnand (arg))
3774 {
3775 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3776 {
3777 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
3778 }
3779 else
3780 {
3781 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
3782 }
3783 }
3784 else
3785 {
3786 int sign = 0;
3787
3788 if (signbit (arg)) /* arg < 0.0 or negative zero */
3789 {
3790 sign = -1;
3791 arg = -arg;
3792 }
3793
3794 if (sign < 0)
3795 *p++ = '-';
3796 else if (flags & FLAG_SHOWSIGN)
3797 *p++ = '+';
3798 else if (flags & FLAG_SPACE)
3799 *p++ = ' ';
3800
3801 if (arg > 0.0 && arg + arg == arg)
3802 {
3803 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3804 {
3805 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
3806 }
3807 else
3808 {
3809 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
3810 }
3811 }
3812 else
3813 {
3770 {
3771 double arg = a.arg[dp->arg_index].a.a_double;
3772
3773 if (isnand (arg))
3774 {
3775 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3776 {
3777 *p++ = 'N'; *p++ = 'A'; *p++ = 'N';
3778 }
3779 else
3780 {
3781 *p++ = 'n'; *p++ = 'a'; *p++ = 'n';
3782 }
3783 }
3784 else
3785 {
3786 int sign = 0;
3787
3788 if (signbit (arg)) /* arg < 0.0 or negative zero */
3789 {
3790 sign = -1;
3791 arg = -arg;
3792 }
3793
3794 if (sign < 0)
3795 *p++ = '-';
3796 else if (flags & FLAG_SHOWSIGN)
3797 *p++ = '+';
3798 else if (flags & FLAG_SPACE)
3799 *p++ = ' ';
3800
3801 if (arg > 0.0 && arg + arg == arg)
3802 {
3803 if (dp->conversion >= 'A' && dp->conversion <= 'Z')
3804 {
3805 *p++ = 'I'; *p++ = 'N'; *p++ = 'F';
3806 }
3807 else
3808 {
3809 *p++ = 'i'; *p++ = 'n'; *p++ = 'f';
3810 }
3811 }
3812 else
3813 {
38143814 # if NEED_PRINTF_DOUBLE
3815 pad_ptr = p;
3816
3817 if (dp->conversion == 'f' || dp->conversion == 'F')
3818 {
3819 char *digits;
3820 size_t ndigits;
3821
3822 digits =
3823 scale10_round_decimal_double (arg, precision);
3824 if (digits == NULL)
3825 goto out_of_memory;
3826 ndigits = strlen (digits);
3827
3828 if (ndigits > precision)
3829 do
3830 {
3831 --ndigits;
3832 *p++ = digits[ndigits];
3833 }
3834 while (ndigits > precision);
3835 else
3836 *p++ = '0';
3837 /* Here ndigits <= precision. */
3838 if ((flags & FLAG_ALT) || precision > 0)
3839 {
3840 *p++ = decimal_point_char ();
3841 for (; precision > ndigits; precision--)
3842 *p++ = '0';
3843 while (ndigits > 0)
3844 {
3845 --ndigits;
3846 *p++ = digits[ndigits];
3847 }
3848 }
3849
3850 free (digits);
3851 }
3852 else if (dp->conversion == 'e' || dp->conversion == 'E')
3853 {
3854 int exponent;
3855
3856 if (arg == 0.0)
3857 {
3858 exponent = 0;
3859 *p++ = '0';
3860 if ((flags & FLAG_ALT) || precision > 0)
3861 {
3862 *p++ = decimal_point_char ();
3863 for (; precision > 0; precision--)
3864 *p++ = '0';
3865 }
3866 }
3867 else
3868 {
3869 /* arg > 0.0. */
3870 int adjusted;
3871 char *digits;
3872 size_t ndigits;
3873
3874 exponent = floorlog10 (arg);
3875 adjusted = 0;
3876 for (;;)
3877 {
3878 digits =
3879 scale10_round_decimal_double (arg,
3880 (int)precision - exponent);
3881 if (digits == NULL)
3882 goto out_of_memory;
3883 ndigits = strlen (digits);
3884
3885 if (ndigits == precision + 1)
3886 break;
3887 if (ndigits < precision
3888 || ndigits > precision + 2)
3889 /* The exponent was not guessed
3890 precisely enough. */
3891 abort ();
3892 if (adjusted)
3893 /* None of two values of exponent is
3894 the right one. Prevent an endless
3895 loop. */
3896 abort ();
3897 free (digits);
3898 if (ndigits == precision)
3899 exponent -= 1;
3900 else
3901 exponent += 1;
3902 adjusted = 1;
3903 }
3904 /* Here ndigits = precision+1. */
3905 if (is_borderline (digits, precision))
3906 {
3907 /* Maybe the exponent guess was too high
3908 and a smaller exponent can be reached
3909 by turning a 10...0 into 9...9x. */
3910 char *digits2 =
3911 scale10_round_decimal_double (arg,
3912 (int)precision - exponent + 1);
3913 if (digits2 == NULL)
3914 {
3915 free (digits);
3916 goto out_of_memory;
3917 }
3918 if (strlen (digits2) == precision + 1)
3919 {
3920 free (digits);
3921 digits = digits2;
3922 exponent -= 1;
3923 }
3924 else
3925 free (digits2);
3926 }
3927 /* Here ndigits = precision+1. */
3928
3929 *p++ = digits[--ndigits];
3930 if ((flags & FLAG_ALT) || precision > 0)
3931 {
3932 *p++ = decimal_point_char ();
3933 while (ndigits > 0)
3934 {
3935 --ndigits;
3936 *p++ = digits[ndigits];
3937 }
3938 }
3939
3940 free (digits);
3941 }
3942
3943 *p++ = dp->conversion; /* 'e' or 'E' */
3815 pad_ptr = p;
3816
3817 if (dp->conversion == 'f' || dp->conversion == 'F')
3818 {
3819 char *digits;
3820 size_t ndigits;
3821
3822 digits =
3823 scale10_round_decimal_double (arg, precision);
3824 if (digits == NULL)
3825 goto out_of_memory;
3826 ndigits = strlen (digits);
3827
3828 if (ndigits > precision)
3829 do
3830 {
3831 --ndigits;
3832 *p++ = digits[ndigits];
3833 }
3834 while (ndigits > precision);
3835 else
3836 *p++ = '0';
3837 /* Here ndigits <= precision. */
3838 if ((flags & FLAG_ALT) || precision > 0)
3839 {
3840 *p++ = decimal_point_char ();
3841 for (; precision > ndigits; precision--)
3842 *p++ = '0';
3843 while (ndigits > 0)
3844 {
3845 --ndigits;
3846 *p++ = digits[ndigits];
3847 }
3848 }
3849
3850 free (digits);
3851 }
3852 else if (dp->conversion == 'e' || dp->conversion == 'E')
3853 {
3854 int exponent;
3855
3856 if (arg == 0.0)
3857 {
3858 exponent = 0;
3859 *p++ = '0';
3860 if ((flags & FLAG_ALT) || precision > 0)
3861 {
3862 *p++ = decimal_point_char ();
3863 for (; precision > 0; precision--)
3864 *p++ = '0';
3865 }
3866 }
3867 else
3868 {
3869 /* arg > 0.0. */
3870 int adjusted;
3871 char *digits;
3872 size_t ndigits;
3873
3874 exponent = floorlog10 (arg);
3875 adjusted = 0;
3876 for (;;)
3877 {
3878 digits =
3879 scale10_round_decimal_double (arg,
3880 (int)precision - exponent);
3881 if (digits == NULL)
3882 goto out_of_memory;
3883 ndigits = strlen (digits);
3884
3885 if (ndigits == precision + 1)
3886 break;
3887 if (ndigits < precision
3888 || ndigits > precision + 2)
3889 /* The exponent was not guessed
3890 precisely enough. */
3891 abort ();
3892 if (adjusted)
3893 /* None of two values of exponent is
3894 the right one. Prevent an endless
3895 loop. */
3896 abort ();
3897 free (digits);
3898 if (ndigits == precision)
3899 exponent -= 1;
3900 else
3901 exponent += 1;
3902 adjusted = 1;
3903 }
3904 /* Here ndigits = precision+1. */
3905 if (is_borderline (digits, precision))
3906 {
3907 /* Maybe the exponent guess was too high
3908 and a smaller exponent can be reached
3909 by turning a 10...0 into 9...9x. */
3910 char *digits2 =
3911 scale10_round_decimal_double (arg,
3912 (int)precision - exponent + 1);
3913 if (digits2 == NULL)
3914 {
3915 free (digits);
3916 goto out_of_memory;
3917 }
3918 if (strlen (digits2) == precision + 1)
3919 {
3920 free (digits);
3921 digits = digits2;
3922 exponent -= 1;
3923 }
3924 else
3925 free (digits2);
3926 }
3927 /* Here ndigits = precision+1. */
3928
3929 *p++ = digits[--ndigits];
3930 if ((flags & FLAG_ALT) || precision > 0)
3931 {
3932 *p++ = decimal_point_char ();
3933 while (ndigits > 0)
3934 {
3935 --ndigits;
3936 *p++ = digits[ndigits];
3937 }
3938 }
3939
3940 free (digits);
3941 }
3942
3943 *p++ = dp->conversion; /* 'e' or 'E' */
39443944 # if WIDE_CHAR_VERSION
3945 {
3946 static const wchar_t decimal_format[] =
3947 /* Produce the same number of exponent digits
3948 as the native printf implementation. */
3945 {
3946 static const wchar_t decimal_format[] =
3947 /* Produce the same number of exponent digits
3948 as the native printf implementation. */
39493949 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
3950 { '%', '+', '.', '3', 'd', '\0' };
3950 { '%', '+', '.', '3', 'd', '\0' };
39513951 # else
3952 { '%', '+', '.', '2', 'd', '\0' };
3952 { '%', '+', '.', '2', 'd', '\0' };
39533953 # endif
3954 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3955 }
3956 while (*p != '\0')
3957 p++;
3954 SNPRINTF (p, 6 + 1, decimal_format, exponent);
3955 }
3956 while (*p != '\0')
3957 p++;
39583958 # else
3959 {
3960 static const char decimal_format[] =
3961 /* Produce the same number of exponent digits
3962 as the native printf implementation. */
3959 {
3960 static const char decimal_format[] =
3961 /* Produce the same number of exponent digits
3962 as the native printf implementation. */
39633963 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
3964 "%+.3d";
3964 "%+.3d";
39653965 # else
3966 "%+.2d";
3966 "%+.2d";
39673967 # endif
3968 if (sizeof (DCHAR_T) == 1)
3969 {
3970 sprintf ((char *) p, decimal_format, exponent);
3971 while (*p != '\0')
3972 p++;
3973 }
3974 else
3975 {
3976 char expbuf[6 + 1];
3977 const char *ep;
3978 sprintf (expbuf, decimal_format, exponent);
3979 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3980 p++;
3981 }
3982 }
3968 if (sizeof (DCHAR_T) == 1)
3969 {
3970 sprintf ((char *) p, decimal_format, exponent);
3971 while (*p != '\0')
3972 p++;
3973 }
3974 else
3975 {
3976 char expbuf[6 + 1];
3977 const char *ep;
3978 sprintf (expbuf, decimal_format, exponent);
3979 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
3980 p++;
3981 }
3982 }
39833983 # endif
3984 }
3985 else if (dp->conversion == 'g' || dp->conversion == 'G')
3986 {
3987 if (precision == 0)
3988 precision = 1;
3989 /* precision >= 1. */
3990
3991 if (arg == 0.0)
3992 /* The exponent is 0, >= -4, < precision.
3993 Use fixed-point notation. */
3994 {
3995 size_t ndigits = precision;
3996 /* Number of trailing zeroes that have to be
3997 dropped. */
3998 size_t nzeroes =
3999 (flags & FLAG_ALT ? 0 : precision - 1);
4000
4001 --ndigits;
4002 *p++ = '0';
4003 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4004 {
4005 *p++ = decimal_point_char ();
4006 while (ndigits > nzeroes)
4007 {
4008 --ndigits;
4009 *p++ = '0';
4010 }
4011 }
4012 }
4013 else
4014 {
4015 /* arg > 0.0. */
4016 int exponent;
4017 int adjusted;
4018 char *digits;
4019 size_t ndigits;
4020 size_t nzeroes;
4021
4022 exponent = floorlog10 (arg);
4023 adjusted = 0;
4024 for (;;)
4025 {
4026 digits =
4027 scale10_round_decimal_double (arg,
4028 (int)(precision - 1) - exponent);
4029 if (digits == NULL)
4030 goto out_of_memory;
4031 ndigits = strlen (digits);
4032
4033 if (ndigits == precision)
4034 break;
4035 if (ndigits < precision - 1
4036 || ndigits > precision + 1)
4037 /* The exponent was not guessed
4038 precisely enough. */
4039 abort ();
4040 if (adjusted)
4041 /* None of two values of exponent is
4042 the right one. Prevent an endless
4043 loop. */
4044 abort ();
4045 free (digits);
4046 if (ndigits < precision)
4047 exponent -= 1;
4048 else
4049 exponent += 1;
4050 adjusted = 1;
4051 }
4052 /* Here ndigits = precision. */
4053 if (is_borderline (digits, precision - 1))
4054 {
4055 /* Maybe the exponent guess was too high
4056 and a smaller exponent can be reached
4057 by turning a 10...0 into 9...9x. */
4058 char *digits2 =
4059 scale10_round_decimal_double (arg,
4060 (int)(precision - 1) - exponent + 1);
4061 if (digits2 == NULL)
4062 {
4063 free (digits);
4064 goto out_of_memory;
4065 }
4066 if (strlen (digits2) == precision)
4067 {
4068 free (digits);
4069 digits = digits2;
4070 exponent -= 1;
4071 }
4072 else
4073 free (digits2);
4074 }
4075 /* Here ndigits = precision. */
4076
4077 /* Determine the number of trailing zeroes
4078 that have to be dropped. */
4079 nzeroes = 0;
4080 if ((flags & FLAG_ALT) == 0)
4081 while (nzeroes < ndigits
4082 && digits[nzeroes] == '0')
4083 nzeroes++;
4084
4085 /* The exponent is now determined. */
4086 if (exponent >= -4
4087 && exponent < (long)precision)
4088 {
4089 /* Fixed-point notation:
4090 max(exponent,0)+1 digits, then the
4091 decimal point, then the remaining
4092 digits without trailing zeroes. */
4093 if (exponent >= 0)
4094 {
4095 size_t count = exponent + 1;
4096 /* Note: count <= precision = ndigits. */
4097 for (; count > 0; count--)
4098 *p++ = digits[--ndigits];
4099 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4100 {
4101 *p++ = decimal_point_char ();
4102 while (ndigits > nzeroes)
4103 {
4104 --ndigits;
4105 *p++ = digits[ndigits];
4106 }
4107 }
4108 }
4109 else
4110 {
4111 size_t count = -exponent - 1;
4112 *p++ = '0';
4113 *p++ = decimal_point_char ();
4114 for (; count > 0; count--)
4115 *p++ = '0';
4116 while (ndigits > nzeroes)
4117 {
4118 --ndigits;
4119 *p++ = digits[ndigits];
4120 }
4121 }
4122 }
4123 else
4124 {
4125 /* Exponential notation. */
4126 *p++ = digits[--ndigits];
4127 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4128 {
4129 *p++ = decimal_point_char ();
4130 while (ndigits > nzeroes)
4131 {
4132 --ndigits;
4133 *p++ = digits[ndigits];
4134 }
4135 }
4136 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
3984 }
3985 else if (dp->conversion == 'g' || dp->conversion == 'G')
3986 {
3987 if (precision == 0)
3988 precision = 1;
3989 /* precision >= 1. */
3990
3991 if (arg == 0.0)
3992 /* The exponent is 0, >= -4, < precision.
3993 Use fixed-point notation. */
3994 {
3995 size_t ndigits = precision;
3996 /* Number of trailing zeroes that have to be
3997 dropped. */
3998 size_t nzeroes =
3999 (flags & FLAG_ALT ? 0 : precision - 1);
4000
4001 --ndigits;
4002 *p++ = '0';
4003 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4004 {
4005 *p++ = decimal_point_char ();
4006 while (ndigits > nzeroes)
4007 {
4008 --ndigits;
4009 *p++ = '0';
4010 }
4011 }
4012 }
4013 else
4014 {
4015 /* arg > 0.0. */
4016 int exponent;
4017 int adjusted;
4018 char *digits;
4019 size_t ndigits;
4020 size_t nzeroes;
4021
4022 exponent = floorlog10 (arg);
4023 adjusted = 0;
4024 for (;;)
4025 {
4026 digits =
4027 scale10_round_decimal_double (arg,
4028 (int)(precision - 1) - exponent);
4029 if (digits == NULL)
4030 goto out_of_memory;
4031 ndigits = strlen (digits);
4032
4033 if (ndigits == precision)
4034 break;
4035 if (ndigits < precision - 1
4036 || ndigits > precision + 1)
4037 /* The exponent was not guessed
4038 precisely enough. */
4039 abort ();
4040 if (adjusted)
4041 /* None of two values of exponent is
4042 the right one. Prevent an endless
4043 loop. */
4044 abort ();
4045 free (digits);
4046 if (ndigits < precision)
4047 exponent -= 1;
4048 else
4049 exponent += 1;
4050 adjusted = 1;
4051 }
4052 /* Here ndigits = precision. */
4053 if (is_borderline (digits, precision - 1))
4054 {
4055 /* Maybe the exponent guess was too high
4056 and a smaller exponent can be reached
4057 by turning a 10...0 into 9...9x. */
4058 char *digits2 =
4059 scale10_round_decimal_double (arg,
4060 (int)(precision - 1) - exponent + 1);
4061 if (digits2 == NULL)
4062 {
4063 free (digits);
4064 goto out_of_memory;
4065 }
4066 if (strlen (digits2) == precision)
4067 {
4068 free (digits);
4069 digits = digits2;
4070 exponent -= 1;
4071 }
4072 else
4073 free (digits2);
4074 }
4075 /* Here ndigits = precision. */
4076
4077 /* Determine the number of trailing zeroes
4078 that have to be dropped. */
4079 nzeroes = 0;
4080 if ((flags & FLAG_ALT) == 0)
4081 while (nzeroes < ndigits
4082 && digits[nzeroes] == '0')
4083 nzeroes++;
4084
4085 /* The exponent is now determined. */
4086 if (exponent >= -4
4087 && exponent < (long)precision)
4088 {
4089 /* Fixed-point notation:
4090 max(exponent,0)+1 digits, then the
4091 decimal point, then the remaining
4092 digits without trailing zeroes. */
4093 if (exponent >= 0)
4094 {
4095 size_t count = exponent + 1;
4096 /* Note: count <= precision = ndigits. */
4097 for (; count > 0; count--)
4098 *p++ = digits[--ndigits];
4099 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4100 {
4101 *p++ = decimal_point_char ();
4102 while (ndigits > nzeroes)
4103 {
4104 --ndigits;
4105 *p++ = digits[ndigits];
4106 }
4107 }
4108 }
4109 else
4110 {
4111 size_t count = -exponent - 1;
4112 *p++ = '0';
4113 *p++ = decimal_point_char ();
4114 for (; count > 0; count--)
4115 *p++ = '0';
4116 while (ndigits > nzeroes)
4117 {
4118 --ndigits;
4119 *p++ = digits[ndigits];
4120 }
4121 }
4122 }
4123 else
4124 {
4125 /* Exponential notation. */
4126 *p++ = digits[--ndigits];
4127 if ((flags & FLAG_ALT) || ndigits > nzeroes)
4128 {
4129 *p++ = decimal_point_char ();
4130 while (ndigits > nzeroes)
4131 {
4132 --ndigits;
4133 *p++ = digits[ndigits];
4134 }
4135 }
4136 *p++ = dp->conversion - 'G' + 'E'; /* 'e' or 'E' */
41374137 # if WIDE_CHAR_VERSION
4138 {
4139 static const wchar_t decimal_format[] =
4140 /* Produce the same number of exponent digits
4141 as the native printf implementation. */
4138 {
4139 static const wchar_t decimal_format[] =
4140 /* Produce the same number of exponent digits
4141 as the native printf implementation. */
41424142 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4143 { '%', '+', '.', '3', 'd', '\0' };
4143 { '%', '+', '.', '3', 'd', '\0' };
41444144 # else
4145 { '%', '+', '.', '2', 'd', '\0' };
4145 { '%', '+', '.', '2', 'd', '\0' };
41464146 # endif
4147 SNPRINTF (p, 6 + 1, decimal_format, exponent);
4148 }
4149 while (*p != '\0')
4150 p++;
4147 SNPRINTF (p, 6 + 1, decimal_format, exponent);
4148 }
4149 while (*p != '\0')
4150 p++;
41514151 # else
4152 {
4153 static const char decimal_format[] =
4154 /* Produce the same number of exponent digits
4155 as the native printf implementation. */
4152 {
4153 static const char decimal_format[] =
4154 /* Produce the same number of exponent digits
4155 as the native printf implementation. */
41564156 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4157 "%+.3d";
4157 "%+.3d";
41584158 # else
4159 "%+.2d";
4159 "%+.2d";
41604160 # endif
4161 if (sizeof (DCHAR_T) == 1)
4162 {
4163 sprintf ((char *) p, decimal_format, exponent);
4164 while (*p != '\0')
4165 p++;
4166 }
4167 else
4168 {
4169 char expbuf[6 + 1];
4170 const char *ep;
4171 sprintf (expbuf, decimal_format, exponent);
4172 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
4173 p++;
4174 }
4175 }
4161 if (sizeof (DCHAR_T) == 1)
4162 {
4163 sprintf ((char *) p, decimal_format, exponent);
4164 while (*p != '\0')
4165 p++;
4166 }
4167 else
4168 {
4169 char expbuf[6 + 1];
4170 const char *ep;
4171 sprintf (expbuf, decimal_format, exponent);
4172 for (ep = expbuf; (*p = *ep) != '\0'; ep++)
4173 p++;
4174 }
4175 }
41764176 # endif
4177 }
4178
4179 free (digits);
4180 }
4181 }
4182 else
4183 abort ();
4177 }
4178
4179 free (digits);
4180 }
4181 }
4182 else
4183 abort ();
41844184 # else
4185 /* arg is finite. */
4186 if (!(arg == 0.0))
4187 abort ();
4188
4189 pad_ptr = p;
4190
4191 if (dp->conversion == 'f' || dp->conversion == 'F')
4192 {
4193 *p++ = '0';
4194 if ((flags & FLAG_ALT) || precision > 0)
4195 {
4196 *p++ = decimal_point_char ();
4197 for (; precision > 0; precision--)
4198 *p++ = '0';
4199 }
4200 }
4201 else if (dp->conversion == 'e' || dp->conversion == 'E')
4202 {
4203 *p++ = '0';
4204 if ((flags & FLAG_ALT) || precision > 0)
4205 {
4206 *p++ = decimal_point_char ();
4207 for (; precision > 0; precision--)
4208 *p++ = '0';
4209 }
4210 *p++ = dp->conversion; /* 'e' or 'E' */
4211 *p++ = '+';
4212 /* Produce the same number of exponent digits as
4213 the native printf implementation. */
4185 /* arg is finite. */
4186 if (!(arg == 0.0))
4187 abort ();
4188
4189 pad_ptr = p;
4190
4191 if (dp->conversion == 'f' || dp->conversion == 'F')
4192 {
4193 *p++ = '0';
4194 if ((flags & FLAG_ALT) || precision > 0)
4195 {
4196 *p++ = decimal_point_char ();
4197 for (; precision > 0; precision--)
4198 *p++ = '0';
4199 }
4200 }
4201 else if (dp->conversion == 'e' || dp->conversion == 'E')
4202 {
4203 *p++ = '0';
4204 if ((flags & FLAG_ALT) || precision > 0)
4205 {
4206 *p++ = decimal_point_char ();
4207 for (; precision > 0; precision--)
4208 *p++ = '0';
4209 }
4210 *p++ = dp->conversion; /* 'e' or 'E' */
4211 *p++ = '+';
4212 /* Produce the same number of exponent digits as
4213 the native printf implementation. */
42144214 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4215 *p++ = '0';
4215 *p++ = '0';
42164216 # endif
4217 *p++ = '0';
4218 *p++ = '0';
4219 }
4220 else if (dp->conversion == 'g' || dp->conversion == 'G')
4221 {
4222 *p++ = '0';
4223 if (flags & FLAG_ALT)
4224 {
4225 size_t ndigits =
4226 (precision > 0 ? precision - 1 : 0);
4227 *p++ = decimal_point_char ();
4228 for (; ndigits > 0; --ndigits)
4229 *p++ = '0';
4230 }
4231 }
4232 else
4233 abort ();
4217 *p++ = '0';
4218 *p++ = '0';
4219 }
4220 else if (dp->conversion == 'g' || dp->conversion == 'G')
4221 {
4222 *p++ = '0';
4223 if (flags & FLAG_ALT)
4224 {
4225 size_t ndigits =
4226 (precision > 0 ? precision - 1 : 0);
4227 *p++ = decimal_point_char ();
4228 for (; ndigits > 0; --ndigits)
4229 *p++ = '0';
4230 }
4231 }
4232 else
4233 abort ();
42344234 # endif
4235 }
4236 }
4237 }
4235 }
4236 }
4237 }
42384238 # endif
42394239
4240 /* The generated string now extends from tmp to p, with the
4241 zero padding insertion point being at pad_ptr. */
4242 if (has_width && p - tmp < width)
4243 {
4244 size_t pad = width - (p - tmp);
4245 DCHAR_T *end = p + pad;
4246
4247 if (flags & FLAG_LEFT)
4248 {
4249 /* Pad with spaces on the right. */
4250 for (; pad > 0; pad--)
4251 *p++ = ' ';
4252 }
4253 else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
4254 {
4255 /* Pad with zeroes. */
4256 DCHAR_T *q = end;
4257
4258 while (p > pad_ptr)
4259 *--q = *--p;
4260 for (; pad > 0; pad--)
4261 *p++ = '0';
4262 }
4263 else
4264 {
4265 /* Pad with spaces on the left. */
4266 DCHAR_T *q = end;
4267
4268 while (p > tmp)
4269 *--q = *--p;
4270 for (; pad > 0; pad--)
4271 *p++ = ' ';
4272 }
4273
4274 p = end;
4275 }
4276
4277 {
4278 size_t count = p - tmp;
4279
4280 if (count >= tmp_length)
4281 /* tmp_length was incorrectly calculated - fix the
4282 code above! */
4283 abort ();
4284
4285 /* Make room for the result. */
4286 if (count >= allocated - length)
4287 {
4288 size_t n = xsum (length, count);
4289
4290 ENSURE_ALLOCATION (n);
4291 }
4292
4293 /* Append the result. */
4294 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
4295 if (tmp != tmpbuf)
4296 free (tmp);
4297 length += count;
4298 }
4299 }
4300 #endif
4301 else
4302 {
4303 arg_type type = a.arg[dp->arg_index].type;
4304 int flags = dp->flags;
4240 /* The generated string now extends from tmp to p, with the
4241 zero padding insertion point being at pad_ptr. */
4242 if (has_width && p - tmp < width)
4243 {
4244 size_t pad = width - (p - tmp);
4245 DCHAR_T *end = p + pad;
4246
4247 if (flags & FLAG_LEFT)
4248 {
4249 /* Pad with spaces on the right. */
4250 for (; pad > 0; pad--)
4251 *p++ = ' ';
4252 }
4253 else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
4254 {
4255 /* Pad with zeroes. */
4256 DCHAR_T *q = end;
4257
4258 while (p > pad_ptr)
4259 *--q = *--p;
4260 for (; pad > 0; pad--)
4261 *p++ = '0';
4262 }
4263 else
4264 {
4265 /* Pad with spaces on the left. */
4266 DCHAR_T *q = end;
4267
4268 while (p > tmp)
4269 *--q = *--p;
4270 for (; pad > 0; pad--)
4271 *p++ = ' ';
4272 }
4273
4274 p = end;
4275 }
4276
4277 {
4278 size_t count = p - tmp;
4279
4280 if (count >= tmp_length)
4281 /* tmp_length was incorrectly calculated - fix the
4282 code above! */
4283 abort ();
4284
4285 /* Make room for the result. */
4286 if (count >= allocated - length)
4287 {
4288 size_t n = xsum (length, count);
4289
4290 ENSURE_ALLOCATION (n);
4291 }
4292
4293 /* Append the result. */
4294 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
4295 if (tmp != tmpbuf)
4296 free (tmp);
4297 length += count;
4298 }
4299 }
4300 #endif
4301 else
4302 {
4303 arg_type type = a.arg[dp->arg_index].type;
4304 int flags = dp->flags;
43054305 #if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4306 int has_width;
4307 size_t width;
4306 int has_width;
4307 size_t width;
43084308 #endif
43094309 #if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4310 int has_precision;
4311 size_t precision;
4310 int has_precision;
4311 size_t precision;
43124312 #endif
43134313 #if NEED_PRINTF_UNBOUNDED_PRECISION
4314 int prec_ourselves;
4314 int prec_ourselves;
43154315 #else
4316 # define prec_ourselves 0
4316 # define prec_ourselves 0
43174317 #endif
43184318 #if NEED_PRINTF_FLAG_LEFTADJUST
4319 # define pad_ourselves 1
4319 # define pad_ourselves 1
43204320 #elif !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4321 int pad_ourselves;
4321 int pad_ourselves;
43224322 #else
4323 # define pad_ourselves 0
4324 #endif
4325 TCHAR_T *fbp;
4326 unsigned int prefix_count;
4327 int prefixes[2] IF_LINT (= { 0 });
4323 # define pad_ourselves 0
4324 #endif
4325 TCHAR_T *fbp;
4326 unsigned int prefix_count;
4327 int prefixes[2] IF_LINT (= { 0 });
43284328 #if !USE_SNPRINTF
4329 size_t tmp_length;
4330 TCHAR_T tmpbuf[700];
4331 TCHAR_T *tmp;
4329 size_t tmp_length;
4330 TCHAR_T tmpbuf[700];
4331 TCHAR_T *tmp;
43324332 #endif
43334333
43344334 #if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4335 has_width = 0;
4336 width = 0;
4337 if (dp->width_start != dp->width_end)
4338 {
4339 if (dp->width_arg_index != ARG_NONE)
4340 {
4341 int arg;
4342
4343 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4344 abort ();
4345 arg = a.arg[dp->width_arg_index].a.a_int;
4346 if (arg < 0)
4347 {
4348 /* "A negative field width is taken as a '-' flag
4349 followed by a positive field width." */
4350 flags |= FLAG_LEFT;
4351 width = (unsigned int) (-arg);
4352 }
4353 else
4354 width = arg;
4355 }
4356 else
4357 {
4358 const FCHAR_T *digitp = dp->width_start;
4359
4360 do
4361 width = xsum (xtimes (width, 10), *digitp++ - '0');
4362 while (digitp != dp->width_end);
4363 }
4364 has_width = 1;
4365 }
4335 has_width = 0;
4336 width = 0;
4337 if (dp->width_start != dp->width_end)
4338 {
4339 if (dp->width_arg_index != ARG_NONE)
4340 {
4341 int arg;
4342
4343 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4344 abort ();
4345 arg = a.arg[dp->width_arg_index].a.a_int;
4346 if (arg < 0)
4347 {
4348 /* "A negative field width is taken as a '-' flag
4349 followed by a positive field width." */
4350 flags |= FLAG_LEFT;
4351 width = (unsigned int) (-arg);
4352 }
4353 else
4354 width = arg;
4355 }
4356 else
4357 {
4358 const FCHAR_T *digitp = dp->width_start;
4359
4360 do
4361 width = xsum (xtimes (width, 10), *digitp++ - '0');
4362 while (digitp != dp->width_end);
4363 }
4364 has_width = 1;
4365 }
43664366 #endif
43674367
43684368 #if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
4369 has_precision = 0;
4370 precision = 6;
4371 if (dp->precision_start != dp->precision_end)
4372 {
4373 if (dp->precision_arg_index != ARG_NONE)
4374 {
4375 int arg;
4376
4377 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4378 abort ();
4379 arg = a.arg[dp->precision_arg_index].a.a_int;
4380 /* "A negative precision is taken as if the precision
4381 were omitted." */
4382 if (arg >= 0)
4383 {
4384 precision = arg;
4385 has_precision = 1;
4386 }
4387 }
4388 else
4389 {
4390 const FCHAR_T *digitp = dp->precision_start + 1;
4391
4392 precision = 0;
4393 while (digitp != dp->precision_end)
4394 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
4395 has_precision = 1;
4396 }
4397 }
4398 #endif
4399
4400 /* Decide whether to handle the precision ourselves. */
4369 has_precision = 0;
4370 precision = 6;
4371 if (dp->precision_start != dp->precision_end)
4372 {
4373 if (dp->precision_arg_index != ARG_NONE)
4374 {
4375 int arg;
4376
4377 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4378 abort ();
4379 arg = a.arg[dp->precision_arg_index].a.a_int;
4380 /* "A negative precision is taken as if the precision
4381 were omitted." */
4382 if (arg >= 0)
4383 {
4384 precision = arg;
4385 has_precision = 1;
4386 }
4387 }
4388 else
4389 {
4390 const FCHAR_T *digitp = dp->precision_start + 1;
4391
4392 precision = 0;
4393 while (digitp != dp->precision_end)
4394 precision = xsum (xtimes (precision, 10), *digitp++ - '0');
4395 has_precision = 1;
4396 }
4397 }
4398 #endif
4399
4400 /* Decide whether to handle the precision ourselves. */
44014401 #if NEED_PRINTF_UNBOUNDED_PRECISION
4402 switch (dp->conversion)
4403 {
4404 case 'd': case 'i': case 'u':
4405 case 'o':
4406 case 'x': case 'X': case 'p':
4407 prec_ourselves = has_precision && (precision > 0);
4408 break;
4409 default:
4410 prec_ourselves = 0;
4411 break;
4412 }
4413 #endif
4414
4415 /* Decide whether to perform the padding ourselves. */
4402 switch (dp->conversion)
4403 {
4404 case 'd': case 'i': case 'u':
4405 case 'o':
4406 case 'x': case 'X': case 'p':
4407 prec_ourselves = has_precision && (precision > 0);
4408 break;
4409 default:
4410 prec_ourselves = 0;
4411 break;
4412 }
4413 #endif
4414
4415 /* Decide whether to perform the padding ourselves. */
44164416 #if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
4417 switch (dp->conversion)
4418 {
4417 switch (dp->conversion)
4418 {
44194419 # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
4420 /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
4421 to perform the padding after this conversion. Functions
4422 with unistdio extensions perform the padding based on
4423 character count rather than element count. */
4424 case 'c': case 's':
4420 /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
4421 to perform the padding after this conversion. Functions
4422 with unistdio extensions perform the padding based on
4423 character count rather than element count. */
4424 case 'c': case 's':
44254425 # endif
44264426 # if NEED_PRINTF_FLAG_ZERO
4427 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
4428 case 'a': case 'A':
4427 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
4428 case 'a': case 'A':
44294429 # endif
4430 pad_ourselves = 1;
4431 break;
4432 default:
4433 pad_ourselves = prec_ourselves;
4434 break;
4435 }
4430 pad_ourselves = 1;
4431 break;
4432 default:
4433 pad_ourselves = prec_ourselves;
4434 break;
4435 }
44364436 #endif
44374437
44384438 #if !USE_SNPRINTF
4439 /* Allocate a temporary buffer of sufficient size for calling
4440 sprintf. */
4441 {
4442 switch (dp->conversion)
4443 {
4444
4445 case 'd': case 'i': case 'u':
4439 /* Allocate a temporary buffer of sufficient size for calling
4440 sprintf. */
4441 {
4442 switch (dp->conversion)
4443 {
4444
4445 case 'd': case 'i': case 'u':
44464446 # if HAVE_LONG_LONG_INT
4447 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4448 tmp_length =
4449 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4450 * 0.30103 /* binary -> decimal */
4451 )
4452 + 1; /* turn floor into ceil */
4453 else
4447 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4448 tmp_length =
4449 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4450 * 0.30103 /* binary -> decimal */
4451 )
4452 + 1; /* turn floor into ceil */
4453 else
44544454 # endif
4455 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4456 tmp_length =
4457 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4458 * 0.30103 /* binary -> decimal */
4459 )
4460 + 1; /* turn floor into ceil */
4461 else
4462 tmp_length =
4463 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4464 * 0.30103 /* binary -> decimal */
4465 )
4466 + 1; /* turn floor into ceil */
4467 if (tmp_length < precision)
4468 tmp_length = precision;
4469 /* Multiply by 2, as an estimate for FLAG_GROUP. */
4470 tmp_length = xsum (tmp_length, tmp_length);
4471 /* Add 1, to account for a leading sign. */
4472 tmp_length = xsum (tmp_length, 1);
4473 break;
4474
4475 case 'o':
4455 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4456 tmp_length =
4457 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4458 * 0.30103 /* binary -> decimal */
4459 )
4460 + 1; /* turn floor into ceil */
4461 else
4462 tmp_length =
4463 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4464 * 0.30103 /* binary -> decimal */
4465 )
4466 + 1; /* turn floor into ceil */
4467 if (tmp_length < precision)
4468 tmp_length = precision;
4469 /* Multiply by 2, as an estimate for FLAG_GROUP. */
4470 tmp_length = xsum (tmp_length, tmp_length);
4471 /* Add 1, to account for a leading sign. */
4472 tmp_length = xsum (tmp_length, 1);
4473 break;
4474
4475 case 'o':
44764476 # if HAVE_LONG_LONG_INT
4477 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4478 tmp_length =
4479 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4480 * 0.333334 /* binary -> octal */
4481 )
4482 + 1; /* turn floor into ceil */
4483 else
4477 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4478 tmp_length =
4479 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4480 * 0.333334 /* binary -> octal */
4481 )
4482 + 1; /* turn floor into ceil */
4483 else
44844484 # endif
4485 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4486 tmp_length =
4487 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4488 * 0.333334 /* binary -> octal */
4489 )
4490 + 1; /* turn floor into ceil */
4491 else
4492 tmp_length =
4493 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4494 * 0.333334 /* binary -> octal */
4495 )
4496 + 1; /* turn floor into ceil */
4497 if (tmp_length < precision)
4498 tmp_length = precision;
4499 /* Add 1, to account for a leading sign. */
4500 tmp_length = xsum (tmp_length, 1);
4501 break;
4502
4503 case 'x': case 'X':
4485 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4486 tmp_length =
4487 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4488 * 0.333334 /* binary -> octal */
4489 )
4490 + 1; /* turn floor into ceil */
4491 else
4492 tmp_length =
4493 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4494 * 0.333334 /* binary -> octal */
4495 )
4496 + 1; /* turn floor into ceil */
4497 if (tmp_length < precision)
4498 tmp_length = precision;
4499 /* Add 1, to account for a leading sign. */
4500 tmp_length = xsum (tmp_length, 1);
4501 break;
4502
4503 case 'x': case 'X':
45044504 # if HAVE_LONG_LONG_INT
4505 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4506 tmp_length =
4507 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4508 * 0.25 /* binary -> hexadecimal */
4509 )
4510 + 1; /* turn floor into ceil */
4511 else
4505 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4506 tmp_length =
4507 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4508 * 0.25 /* binary -> hexadecimal */
4509 )
4510 + 1; /* turn floor into ceil */
4511 else
45124512 # endif
4513 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4514 tmp_length =
4515 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4516 * 0.25 /* binary -> hexadecimal */
4517 )
4518 + 1; /* turn floor into ceil */
4519 else
4520 tmp_length =
4521 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4522 * 0.25 /* binary -> hexadecimal */
4523 )
4524 + 1; /* turn floor into ceil */
4525 if (tmp_length < precision)
4526 tmp_length = precision;
4527 /* Add 2, to account for a leading sign or alternate form. */
4528 tmp_length = xsum (tmp_length, 2);
4529 break;
4530
4531 case 'f': case 'F':
4532 if (type == TYPE_LONGDOUBLE)
4533 tmp_length =
4534 (unsigned int) (LDBL_MAX_EXP
4535 * 0.30103 /* binary -> decimal */
4536 * 2 /* estimate for FLAG_GROUP */
4537 )
4538 + 1 /* turn floor into ceil */
4539 + 10; /* sign, decimal point etc. */
4540 else
4541 tmp_length =
4542 (unsigned int) (DBL_MAX_EXP
4543 * 0.30103 /* binary -> decimal */
4544 * 2 /* estimate for FLAG_GROUP */
4545 )
4546 + 1 /* turn floor into ceil */
4547 + 10; /* sign, decimal point etc. */
4548 tmp_length = xsum (tmp_length, precision);
4549 break;
4550
4551 case 'e': case 'E': case 'g': case 'G':
4552 tmp_length =
4553 12; /* sign, decimal point, exponent etc. */
4554 tmp_length = xsum (tmp_length, precision);
4555 break;
4556
4557 case 'a': case 'A':
4558 if (type == TYPE_LONGDOUBLE)
4559 tmp_length =
4560 (unsigned int) (LDBL_DIG
4561 * 0.831 /* decimal -> hexadecimal */
4562 )
4563 + 1; /* turn floor into ceil */
4564 else
4565 tmp_length =
4566 (unsigned int) (DBL_DIG
4567 * 0.831 /* decimal -> hexadecimal */
4568 )
4569 + 1; /* turn floor into ceil */
4570 if (tmp_length < precision)
4571 tmp_length = precision;
4572 /* Account for sign, decimal point etc. */
4573 tmp_length = xsum (tmp_length, 12);
4574 break;
4575
4576 case 'c':
4513 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4514 tmp_length =
4515 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4516 * 0.25 /* binary -> hexadecimal */
4517 )
4518 + 1; /* turn floor into ceil */
4519 else
4520 tmp_length =
4521 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4522 * 0.25 /* binary -> hexadecimal */
4523 )
4524 + 1; /* turn floor into ceil */
4525 if (tmp_length < precision)
4526 tmp_length = precision;
4527 /* Add 2, to account for a leading sign or alternate form. */
4528 tmp_length = xsum (tmp_length, 2);
4529 break;
4530
4531 case 'f': case 'F':
4532 if (type == TYPE_LONGDOUBLE)
4533 tmp_length =
4534 (unsigned int) (LDBL_MAX_EXP
4535 * 0.30103 /* binary -> decimal */
4536 * 2 /* estimate for FLAG_GROUP */
4537 )
4538 + 1 /* turn floor into ceil */
4539 + 10; /* sign, decimal point etc. */
4540 else
4541 tmp_length =
4542 (unsigned int) (DBL_MAX_EXP
4543 * 0.30103 /* binary -> decimal */
4544 * 2 /* estimate for FLAG_GROUP */
4545 )
4546 + 1 /* turn floor into ceil */
4547 + 10; /* sign, decimal point etc. */
4548 tmp_length = xsum (tmp_length, precision);
4549 break;
4550
4551 case 'e': case 'E': case 'g': case 'G':
4552 tmp_length =
4553 12; /* sign, decimal point, exponent etc. */
4554 tmp_length = xsum (tmp_length, precision);
4555 break;
4556
4557 case 'a': case 'A':
4558 if (type == TYPE_LONGDOUBLE)
4559 tmp_length =
4560 (unsigned int) (LDBL_DIG
4561 * 0.831 /* decimal -> hexadecimal */
4562 )
4563 + 1; /* turn floor into ceil */
4564 else
4565 tmp_length =
4566 (unsigned int) (DBL_DIG
4567 * 0.831 /* decimal -> hexadecimal */
4568 )
4569 + 1; /* turn floor into ceil */
4570 if (tmp_length < precision)
4571 tmp_length = precision;
4572 /* Account for sign, decimal point etc. */
4573 tmp_length = xsum (tmp_length, 12);
4574 break;
4575
4576 case 'c':
45774577 # if HAVE_WINT_T && !WIDE_CHAR_VERSION
4578 if (type == TYPE_WIDE_CHAR)
4579 tmp_length = MB_CUR_MAX;
4580 else
4578 if (type == TYPE_WIDE_CHAR)
4579 tmp_length = MB_CUR_MAX;
4580 else
45814581 # endif
4582 tmp_length = 1;
4583 break;
4584
4585 case 's':
4582 tmp_length = 1;
4583 break;
4584
4585 case 's':
45864586 # if HAVE_WCHAR_T
4587 if (type == TYPE_WIDE_STRING)
4588 {
4587 if (type == TYPE_WIDE_STRING)
4588 {
45894589 # if WIDE_CHAR_VERSION
4590 /* ISO C says about %ls in fwprintf:
4591 "If the precision is not specified or is greater
4592 than the size of the array, the array shall
4593 contain a null wide character."
4594 So if there is a precision, we must not use
4595 wcslen. */
4596 const wchar_t *arg =
4597 a.arg[dp->arg_index].a.a_wide_string;
4598
4599 if (has_precision)
4600 tmp_length = local_wcsnlen (arg, precision);
4601 else
4602 tmp_length = local_wcslen (arg);
4590 /* ISO C says about %ls in fwprintf:
4591 "If the precision is not specified or is greater
4592 than the size of the array, the array shall
4593 contain a null wide character."
4594 So if there is a precision, we must not use
4595 wcslen. */
4596 const wchar_t *arg =
4597 a.arg[dp->arg_index].a.a_wide_string;
4598
4599 if (has_precision)
4600 tmp_length = local_wcsnlen (arg, precision);
4601 else
4602 tmp_length = local_wcslen (arg);
46034603 # else
4604 /* ISO C says about %ls in fprintf:
4605 "If a precision is specified, no more than that
4606 many bytes are written (including shift
4607 sequences, if any), and the array shall contain
4608 a null wide character if, to equal the
4609 multibyte character sequence length given by
4610 the precision, the function would need to
4611 access a wide character one past the end of the
4612 array."
4613 So if there is a precision, we must not use
4614 wcslen. */
4615 /* This case has already been handled above. */
4616 abort ();
4604 /* ISO C says about %ls in fprintf:
4605 "If a precision is specified, no more than that
4606 many bytes are written (including shift
4607 sequences, if any), and the array shall contain
4608 a null wide character if, to equal the
4609 multibyte character sequence length given by
4610 the precision, the function would need to
4611 access a wide character one past the end of the
4612 array."
4613 So if there is a precision, we must not use
4614 wcslen. */
4615 /* This case has already been handled above. */
4616 abort ();
46174617 # endif
4618 }
4619 else
4618 }
4619 else
46204620 # endif
4621 {
4621 {
46224622 # if WIDE_CHAR_VERSION
4623 /* ISO C says about %s in fwprintf:
4624 "If the precision is not specified or is greater
4625 than the size of the converted array, the
4626 converted array shall contain a null wide
4627 character."
4628 So if there is a precision, we must not use
4629 strlen. */
4630 /* This case has already been handled above. */
4631 abort ();
4623 /* ISO C says about %s in fwprintf:
4624 "If the precision is not specified or is greater
4625 than the size of the converted array, the
4626 converted array shall contain a null wide
4627 character."
4628 So if there is a precision, we must not use
4629 strlen. */
4630 /* This case has already been handled above. */
4631 abort ();
46324632 # else
4633 /* ISO C says about %s in fprintf:
4634 "If the precision is not specified or greater
4635 than the size of the array, the array shall
4636 contain a null character."
4637 So if there is a precision, we must not use
4638 strlen. */
4639 const char *arg = a.arg[dp->arg_index].a.a_string;
4640
4641 if (has_precision)
4642 tmp_length = local_strnlen (arg, precision);
4643 else
4644 tmp_length = strlen (arg);
4633 /* ISO C says about %s in fprintf:
4634 "If the precision is not specified or greater
4635 than the size of the array, the array shall
4636 contain a null character."
4637 So if there is a precision, we must not use
4638 strlen. */
4639 const char *arg = a.arg[dp->arg_index].a.a_string;
4640
4641 if (has_precision)
4642 tmp_length = local_strnlen (arg, precision);
4643 else
4644 tmp_length = strlen (arg);
46454645 # endif
4646 }
4647 break;
4648
4649 case 'p':
4650 tmp_length =
4651 (unsigned int) (sizeof (void *) * CHAR_BIT
4652 * 0.25 /* binary -> hexadecimal */
4653 )
4654 + 1 /* turn floor into ceil */
4655 + 2; /* account for leading 0x */
4656 break;
4657
4658 default:
4659 abort ();
4660 }
4661
4662 if (!pad_ourselves)
4663 {
4646 }
4647 break;
4648
4649 case 'p':
4650 tmp_length =
4651 (unsigned int) (sizeof (void *) * CHAR_BIT
4652 * 0.25 /* binary -> hexadecimal */
4653 )
4654 + 1 /* turn floor into ceil */
4655 + 2; /* account for leading 0x */
4656 break;
4657
4658 default:
4659 abort ();
4660 }
4661
4662 if (!pad_ourselves)
4663 {
46644664 # if ENABLE_UNISTDIO
4665 /* Padding considers the number of characters, therefore
4666 the number of elements after padding may be
4667 > max (tmp_length, width)
4668 but is certainly
4669 <= tmp_length + width. */
4670 tmp_length = xsum (tmp_length, width);
4665 /* Padding considers the number of characters, therefore
4666 the number of elements after padding may be
4667 > max (tmp_length, width)
4668 but is certainly
4669 <= tmp_length + width. */
4670 tmp_length = xsum (tmp_length, width);
46714671 # else
4672 /* Padding considers the number of elements,
4673 says POSIX. */
4674 if (tmp_length < width)
4675 tmp_length = width;
4672 /* Padding considers the number of elements,
4673 says POSIX. */
4674 if (tmp_length < width)
4675 tmp_length = width;
46764676 # endif
4677 }
4678
4679 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
4680 }
4681
4682 if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
4683 tmp = tmpbuf;
4684 else
4685 {
4686 size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T));
4687
4688 if (size_overflow_p (tmp_memsize))
4689 /* Overflow, would lead to out of memory. */
4690 goto out_of_memory;
4691 tmp = (TCHAR_T *) malloc (tmp_memsize);
4692 if (tmp == NULL)
4693 /* Out of memory. */
4694 goto out_of_memory;
4695 }
4696 #endif
4697
4698 /* Construct the format string for calling snprintf or
4699 sprintf. */
4700 fbp = buf;
4701 *fbp++ = '%';
4677 }
4678
4679 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
4680 }
4681
4682 if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
4683 tmp = tmpbuf;
4684 else
4685 {
4686 size_t tmp_memsize = xtimes (tmp_length, sizeof (TCHAR_T));
4687
4688 if (size_overflow_p (tmp_memsize))
4689 /* Overflow, would lead to out of memory. */
4690 goto out_of_memory;
4691 tmp = (TCHAR_T *) malloc (tmp_memsize);
4692 if (tmp == NULL)
4693 /* Out of memory. */
4694 goto out_of_memory;
4695 }
4696 #endif
4697
4698 /* Construct the format string for calling snprintf or
4699 sprintf. */
4700 fbp = buf;
4701 *fbp++ = '%';
47024702 #if NEED_PRINTF_FLAG_GROUPING
4703 /* The underlying implementation doesn't support the ' flag.
4704 Produce no grouping characters in this case; this is
4705 acceptable because the grouping is locale dependent. */
4703 /* The underlying implementation doesn't support the ' flag.
4704 Produce no grouping characters in this case; this is
4705 acceptable because the grouping is locale dependent. */
47064706 #else
4707 if (flags & FLAG_GROUP)
4708 *fbp++ = '\'';
4709 #endif
4710 if (flags & FLAG_LEFT)
4711 *fbp++ = '-';
4712 if (flags & FLAG_SHOWSIGN)
4713 *fbp++ = '+';
4714 if (flags & FLAG_SPACE)
4715 *fbp++ = ' ';
4716 if (flags & FLAG_ALT)
4717 *fbp++ = '#';
4718 if (!pad_ourselves)
4719 {
4720 if (flags & FLAG_ZERO)
4721 *fbp++ = '0';
4722 if (dp->width_start != dp->width_end)
4723 {
4724 size_t n = dp->width_end - dp->width_start;
4725 /* The width specification is known to consist only
4726 of standard ASCII characters. */
4727 if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
4728 {
4729 memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T));
4730 fbp += n;
4731 }
4732 else
4733 {
4734 const FCHAR_T *mp = dp->width_start;
4735 do
4736 *fbp++ = (unsigned char) *mp++;
4737 while (--n > 0);
4738 }
4739 }
4740 }
4741 if (!prec_ourselves)
4742 {
4743 if (dp->precision_start != dp->precision_end)
4744 {
4745 size_t n = dp->precision_end - dp->precision_start;
4746 /* The precision specification is known to consist only
4747 of standard ASCII characters. */
4748 if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
4749 {
4750 memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T));
4751 fbp += n;
4752 }
4753 else
4754 {
4755 const FCHAR_T *mp = dp->precision_start;
4756 do
4757 *fbp++ = (unsigned char) *mp++;
4758 while (--n > 0);
4759 }
4760 }
4761 }
4762
4763 switch (type)
4764 {
4707 if (flags & FLAG_GROUP)
4708 *fbp++ = '\'';
4709 #endif
4710 if (flags & FLAG_LEFT)
4711 *fbp++ = '-';
4712 if (flags & FLAG_SHOWSIGN)
4713 *fbp++ = '+';
4714 if (flags & FLAG_SPACE)
4715 *fbp++ = ' ';
4716 if (flags & FLAG_ALT)
4717 *fbp++ = '#';
4718 if (!pad_ourselves)
4719 {
4720 if (flags & FLAG_ZERO)
4721 *fbp++ = '0';
4722 if (dp->width_start != dp->width_end)
4723 {
4724 size_t n = dp->width_end - dp->width_start;
4725 /* The width specification is known to consist only
4726 of standard ASCII characters. */
4727 if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
4728 {
4729 memcpy (fbp, dp->width_start, n * sizeof (TCHAR_T));
4730 fbp += n;
4731 }
4732 else
4733 {
4734 const FCHAR_T *mp = dp->width_start;
4735 do
4736 *fbp++ = (unsigned char) *mp++;
4737 while (--n > 0);
4738 }
4739 }
4740 }
4741 if (!prec_ourselves)
4742 {
4743 if (dp->precision_start != dp->precision_end)
4744 {
4745 size_t n = dp->precision_end - dp->precision_start;
4746 /* The precision specification is known to consist only
4747 of standard ASCII characters. */
4748 if (sizeof (FCHAR_T) == sizeof (TCHAR_T))
4749 {
4750 memcpy (fbp, dp->precision_start, n * sizeof (TCHAR_T));
4751 fbp += n;
4752 }
4753 else
4754 {
4755 const FCHAR_T *mp = dp->precision_start;
4756 do
4757 *fbp++ = (unsigned char) *mp++;
4758 while (--n > 0);
4759 }
4760 }
4761 }
4762
4763 switch (type)
4764 {
47654765 #if HAVE_LONG_LONG_INT
4766 case TYPE_LONGLONGINT:
4767 case TYPE_ULONGLONGINT:
4766 case TYPE_LONGLONGINT:
4767 case TYPE_ULONGLONGINT:
47684768 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
4769 *fbp++ = 'I';
4770 *fbp++ = '6';
4771 *fbp++ = '4';
4772 break;
4769 *fbp++ = 'I';
4770 *fbp++ = '6';
4771 *fbp++ = '4';
4772 break;
47734773 # else
4774 *fbp++ = 'l';
4775 /*FALLTHROUGH*/
4774 *fbp++ = 'l';
4775 /*FALLTHROUGH*/
47764776 # endif
47774777 #endif
4778 case TYPE_LONGINT:
4779 case TYPE_ULONGINT:
4778 case TYPE_LONGINT:
4779 case TYPE_ULONGINT:
47804780 #if HAVE_WINT_T
4781 case TYPE_WIDE_CHAR:
4781 case TYPE_WIDE_CHAR:
47824782 #endif
47834783 #if HAVE_WCHAR_T
4784 case TYPE_WIDE_STRING:
4785 #endif
4786 *fbp++ = 'l';
4787 break;
4788 case TYPE_LONGDOUBLE:
4789 *fbp++ = 'L';
4790 break;
4791 default:
4792 break;
4793 }
4784 case TYPE_WIDE_STRING:
4785 #endif
4786 *fbp++ = 'l';
4787 break;
4788 case TYPE_LONGDOUBLE:
4789 *fbp++ = 'L';
4790 break;
4791 default:
4792 break;
4793 }
47944794 #if NEED_PRINTF_DIRECTIVE_F
4795 if (dp->conversion == 'F')
4796 *fbp = 'f';
4797 else
4798 #endif
4799 *fbp = dp->conversion;
4795 if (dp->conversion == 'F')
4796 *fbp = 'f';
4797 else
4798 #endif
4799 *fbp = dp->conversion;
48004800 #if USE_SNPRINTF
48014801 # if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
4802 fbp[1] = '%';
4803 fbp[2] = 'n';
4804 fbp[3] = '\0';
4802 fbp[1] = '%';
4803 fbp[2] = 'n';
4804 fbp[3] = '\0';
48054805 # else
4806 /* On glibc2 systems from glibc >= 2.3 - probably also older
4807 ones - we know that snprintf's returns value conforms to
4808 ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes.
4809 Therefore we can avoid using %n in this situation.
4810 On glibc2 systems from 2004-10-18 or newer, the use of %n
4811 in format strings in writable memory may crash the program
4812 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
4813 in this situation. */
4814 /* On native Win32 systems (such as mingw), we can avoid using
4815 %n because:
4816 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
4817 snprintf does not write more than the specified number
4818 of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
4819 '4', '5', '6' into buf, not '4', '5', '\0'.)
4820 - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
4821 allows us to recognize the case of an insufficient
4822 buffer size: it returns -1 in this case.
4823 On native Win32 systems (such as mingw) where the OS is
4824 Windows Vista, the use of %n in format strings by default
4825 crashes the program. See
4826 <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
4827 <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
4828 So we should avoid %n in this situation. */
4829 fbp[1] = '\0';
4806 /* On glibc2 systems from glibc >= 2.3 - probably also older
4807 ones - we know that snprintf's returns value conforms to
4808 ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes.
4809 Therefore we can avoid using %n in this situation.
4810 On glibc2 systems from 2004-10-18 or newer, the use of %n
4811 in format strings in writable memory may crash the program
4812 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
4813 in this situation. */
4814 /* On native Win32 systems (such as mingw), we can avoid using
4815 %n because:
4816 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
4817 snprintf does not write more than the specified number
4818 of bytes. (snprintf (buf, 3, "%d %d", 4567, 89) writes
4819 '4', '5', '6' into buf, not '4', '5', '\0'.)
4820 - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
4821 allows us to recognize the case of an insufficient
4822 buffer size: it returns -1 in this case.
4823 On native Win32 systems (such as mingw) where the OS is
4824 Windows Vista, the use of %n in format strings by default
4825 crashes the program. See
4826 <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
4827 <http://msdn2.microsoft.com/en-us/library/ms175782(VS.80).aspx>
4828 So we should avoid %n in this situation. */
4829 fbp[1] = '\0';
48304830 # endif
48314831 #else
4832 fbp[1] = '\0';
4833 #endif
4834
4835 /* Construct the arguments for calling snprintf or sprintf. */
4836 prefix_count = 0;
4837 if (!pad_ourselves && dp->width_arg_index != ARG_NONE)
4838 {
4839 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4840 abort ();
4841 prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
4842 }
4843 if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
4844 {
4845 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4846 abort ();
4847 prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
4848 }
4832 fbp[1] = '\0';
4833 #endif
4834
4835 /* Construct the arguments for calling snprintf or sprintf. */
4836 prefix_count = 0;
4837 if (!pad_ourselves && dp->width_arg_index != ARG_NONE)
4838 {
4839 if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
4840 abort ();
4841 prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
4842 }
4843 if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
4844 {
4845 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4846 abort ();
4847 prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
4848 }
48494849
48504850 #if USE_SNPRINTF
4851 /* The SNPRINTF result is appended after result[0..length].
4852 The latter is an array of DCHAR_T; SNPRINTF appends an
4853 array of TCHAR_T to it. This is possible because
4854 sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
4855 alignof (TCHAR_T) <= alignof (DCHAR_T). */
4851 /* The SNPRINTF result is appended after result[0..length].
4852 The latter is an array of DCHAR_T; SNPRINTF appends an
4853 array of TCHAR_T to it. This is possible because
4854 sizeof (TCHAR_T) divides sizeof (DCHAR_T) and
4855 alignof (TCHAR_T) <= alignof (DCHAR_T). */
48564856 # define TCHARS_PER_DCHAR (sizeof (DCHAR_T) / sizeof (TCHAR_T))
4857 /* Ensure that maxlen below will be >= 2. Needed on BeOS,
4858 where an snprintf() with maxlen==1 acts like sprintf(). */
4859 ENSURE_ALLOCATION (xsum (length,
4860 (2 + TCHARS_PER_DCHAR - 1)
4861 / TCHARS_PER_DCHAR));
4862 /* Prepare checking whether snprintf returns the count
4863 via %n. */
4864 *(TCHAR_T *) (result + length) = '\0';
4865 #endif
4866
4867 for (;;)
4868 {
4869 int count = -1;
4857 /* Ensure that maxlen below will be >= 2. Needed on BeOS,
4858 where an snprintf() with maxlen==1 acts like sprintf(). */
4859 ENSURE_ALLOCATION (xsum (length,
4860 (2 + TCHARS_PER_DCHAR - 1)
4861 / TCHARS_PER_DCHAR));
4862 /* Prepare checking whether snprintf returns the count
4863 via %n. */
4864 *(TCHAR_T *) (result + length) = '\0';
4865 #endif
4866
4867 for (;;)
4868 {
4869 int count = -1;
48704870
48714871 #if USE_SNPRINTF
4872 int retcount = 0;
4873 size_t maxlen = allocated - length;
4874 /* SNPRINTF can fail if its second argument is
4875 > INT_MAX. */
4876 if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
4877 maxlen = INT_MAX / TCHARS_PER_DCHAR;
4878 maxlen = maxlen * TCHARS_PER_DCHAR;
4872 int retcount = 0;
4873 size_t maxlen = allocated - length;
4874 /* SNPRINTF can fail if its second argument is
4875 > INT_MAX. */
4876 if (maxlen > INT_MAX / TCHARS_PER_DCHAR)
4877 maxlen = INT_MAX / TCHARS_PER_DCHAR;
4878 maxlen = maxlen * TCHARS_PER_DCHAR;
48794879 # define SNPRINTF_BUF(arg) \
4880 switch (prefix_count) \
4881 { \
4882 case 0: \
4883 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4884 maxlen, buf, \
4885 arg, &count); \
4886 break; \
4887 case 1: \
4888 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4889 maxlen, buf, \
4890 prefixes[0], arg, &count); \
4891 break; \
4892 case 2: \
4893 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4894 maxlen, buf, \
4895 prefixes[0], prefixes[1], arg, \
4896 &count); \
4897 break; \
4898 default: \
4899 abort (); \
4900 }
4880 switch (prefix_count) \
4881 { \
4882 case 0: \
4883 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4884 maxlen, buf, \
4885 arg, &count); \
4886 break; \
4887 case 1: \
4888 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4889 maxlen, buf, \
4890 prefixes[0], arg, &count); \
4891 break; \
4892 case 2: \
4893 retcount = SNPRINTF ((TCHAR_T *) (result + length), \
4894 maxlen, buf, \
4895 prefixes[0], prefixes[1], arg, \
4896 &count); \
4897 break; \
4898 default: \
4899 abort (); \
4900 }
49014901 #else
49024902 # define SNPRINTF_BUF(arg) \
4903 switch (prefix_count) \
4904 { \
4905 case 0: \
4906 count = sprintf (tmp, buf, arg); \
4907 break; \
4908 case 1: \
4909 count = sprintf (tmp, buf, prefixes[0], arg); \
4910 break; \
4911 case 2: \
4912 count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
4913 arg); \
4914 break; \
4915 default: \
4916 abort (); \
4917 }
4918 #endif
4919
4920 switch (type)
4921 {
4922 case TYPE_SCHAR:
4923 {
4924 int arg = a.arg[dp->arg_index].a.a_schar;
4925 SNPRINTF_BUF (arg);
4926 }
4927 break;
4928 case TYPE_UCHAR:
4929 {
4930 unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
4931 SNPRINTF_BUF (arg);
4932 }
4933 break;
4934 case TYPE_SHORT:
4935 {
4936 int arg = a.arg[dp->arg_index].a.a_short;
4937 SNPRINTF_BUF (arg);
4938 }
4939 break;
4940 case TYPE_USHORT:
4941 {
4942 unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
4943 SNPRINTF_BUF (arg);
4944 }
4945 break;
4946 case TYPE_INT:
4947 {
4948 int arg = a.arg[dp->arg_index].a.a_int;
4949 SNPRINTF_BUF (arg);
4950 }
4951 break;
4952 case TYPE_UINT:
4953 {
4954 unsigned int arg = a.arg[dp->arg_index].a.a_uint;
4955 SNPRINTF_BUF (arg);
4956 }
4957 break;
4958 case TYPE_LONGINT:
4959 {
4960 long int arg = a.arg[dp->arg_index].a.a_longint;
4961 SNPRINTF_BUF (arg);
4962 }
4963 break;
4964 case TYPE_ULONGINT:
4965 {
4966 unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
4967 SNPRINTF_BUF (arg);
4968 }
4969 break;
4903 switch (prefix_count) \
4904 { \
4905 case 0: \
4906 count = sprintf (tmp, buf, arg); \
4907 break; \
4908 case 1: \
4909 count = sprintf (tmp, buf, prefixes[0], arg); \
4910 break; \
4911 case 2: \
4912 count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
4913 arg); \
4914 break; \
4915 default: \
4916 abort (); \
4917 }
4918 #endif
4919
4920 switch (type)
4921 {
4922 case TYPE_SCHAR:
4923 {
4924 int arg = a.arg[dp->arg_index].a.a_schar;
4925 SNPRINTF_BUF (arg);
4926 }
4927 break;
4928 case TYPE_UCHAR:
4929 {
4930 unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
4931 SNPRINTF_BUF (arg);
4932 }
4933 break;
4934 case TYPE_SHORT:
4935 {
4936 int arg = a.arg[dp->arg_index].a.a_short;
4937 SNPRINTF_BUF (arg);
4938 }
4939 break;
4940 case TYPE_USHORT:
4941 {
4942 unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
4943 SNPRINTF_BUF (arg);
4944 }
4945 break;
4946 case TYPE_INT:
4947 {
4948 int arg = a.arg[dp->arg_index].a.a_int;
4949 SNPRINTF_BUF (arg);
4950 }
4951 break;
4952 case TYPE_UINT:
4953 {
4954 unsigned int arg = a.arg[dp->arg_index].a.a_uint;
4955 SNPRINTF_BUF (arg);
4956 }
4957 break;
4958 case TYPE_LONGINT:
4959 {
4960 long int arg = a.arg[dp->arg_index].a.a_longint;
4961 SNPRINTF_BUF (arg);
4962 }
4963 break;
4964 case TYPE_ULONGINT:
4965 {
4966 unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
4967 SNPRINTF_BUF (arg);
4968 }
4969 break;
49704970 #if HAVE_LONG_LONG_INT
4971 case TYPE_LONGLONGINT:
4972 {
4973 long long int arg = a.arg[dp->arg_index].a.a_longlongint;
4974 SNPRINTF_BUF (arg);
4975 }
4976 break;
4977 case TYPE_ULONGLONGINT:
4978 {
4979 unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
4980 SNPRINTF_BUF (arg);
4981 }
4982 break;
4983 #endif
4984 case TYPE_DOUBLE:
4985 {
4986 double arg = a.arg[dp->arg_index].a.a_double;
4987 SNPRINTF_BUF (arg);
4988 }
4989 break;
4990 case TYPE_LONGDOUBLE:
4991 {
4992 long double arg = a.arg[dp->arg_index].a.a_longdouble;
4993 SNPRINTF_BUF (arg);
4994 }
4995 break;
4996 case TYPE_CHAR:
4997 {
4998 int arg = a.arg[dp->arg_index].a.a_char;
4999 SNPRINTF_BUF (arg);
5000 }
5001 break;
4971 case TYPE_LONGLONGINT:
4972 {
4973 long long int arg = a.arg[dp->arg_index].a.a_longlongint;
4974 SNPRINTF_BUF (arg);
4975 }
4976 break;
4977 case TYPE_ULONGLONGINT:
4978 {
4979 unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
4980 SNPRINTF_BUF (arg);
4981 }
4982 break;
4983 #endif
4984 case TYPE_DOUBLE:
4985 {
4986 double arg = a.arg[dp->arg_index].a.a_double;
4987 SNPRINTF_BUF (arg);
4988 }
4989 break;
4990 case TYPE_LONGDOUBLE:
4991 {
4992 long double arg = a.arg[dp->arg_index].a.a_longdouble;
4993 SNPRINTF_BUF (arg);
4994 }
4995 break;
4996 case TYPE_CHAR:
4997 {
4998 int arg = a.arg[dp->arg_index].a.a_char;
4999 SNPRINTF_BUF (arg);
5000 }
5001 break;
50025002 #if HAVE_WINT_T
5003 case TYPE_WIDE_CHAR:
5004 {
5005 wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
5006 SNPRINTF_BUF (arg);
5007 }
5008 break;
5009 #endif
5010 case TYPE_STRING:
5011 {
5012 const char *arg = a.arg[dp->arg_index].a.a_string;
5013 SNPRINTF_BUF (arg);
5014 }
5015 break;
5003 case TYPE_WIDE_CHAR:
5004 {
5005 wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
5006 SNPRINTF_BUF (arg);
5007 }
5008 break;
5009 #endif
5010 case TYPE_STRING:
5011 {
5012 const char *arg = a.arg[dp->arg_index].a.a_string;
5013 SNPRINTF_BUF (arg);
5014 }
5015 break;
50165016 #if HAVE_WCHAR_T
5017 case TYPE_WIDE_STRING:
5018 {
5019 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
5020 SNPRINTF_BUF (arg);
5021 }
5022 break;
5023 #endif
5024 case TYPE_POINTER:
5025 {
5026 void *arg = a.arg[dp->arg_index].a.a_pointer;
5027 SNPRINTF_BUF (arg);
5028 }
5029 break;
5030 default:
5031 abort ();
5032 }
5017 case TYPE_WIDE_STRING:
5018 {
5019 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
5020 SNPRINTF_BUF (arg);
5021 }
5022 break;
5023 #endif
5024 case TYPE_POINTER:
5025 {
5026 void *arg = a.arg[dp->arg_index].a.a_pointer;
5027 SNPRINTF_BUF (arg);
5028 }
5029 break;
5030 default:
5031 abort ();
5032 }
50335033
50345034 #if USE_SNPRINTF
5035 /* Portability: Not all implementations of snprintf()
5036 are ISO C 99 compliant. Determine the number of
5037 bytes that snprintf() has produced or would have
5038 produced. */
5039 if (count >= 0)
5040 {
5041 /* Verify that snprintf() has NUL-terminated its
5042 result. */
5043 if (count < maxlen
5044 && ((TCHAR_T *) (result + length)) [count] != '\0')
5045 abort ();
5046 /* Portability hack. */
5047 if (retcount > count)
5048 count = retcount;
5049 }
5050 else
5051 {
5052 /* snprintf() doesn't understand the '%n'
5053 directive. */
5054 if (fbp[1] != '\0')
5055 {
5056 /* Don't use the '%n' directive; instead, look
5057 at the snprintf() return value. */
5058 fbp[1] = '\0';
5059 continue;
5060 }
5061 else
5062 {
5063 /* Look at the snprintf() return value. */
5064 if (retcount < 0)
5065 {
5066 /* HP-UX 10.20 snprintf() is doubly deficient:
5067 It doesn't understand the '%n' directive,
5068 *and* it returns -1 (rather than the length
5069 that would have been required) when the
5070 buffer is too small. */
5071 size_t bigger_need =
5072 xsum (xtimes (allocated, 2), 12);
5073 ENSURE_ALLOCATION (bigger_need);
5074 continue;
5075 }
5076 else
5077 count = retcount;
5078 }
5079 }
5080 #endif
5081
5082 /* Attempt to handle failure. */
5083 if (count < 0)
5084 {
5085 if (!(result == resultbuf || result == NULL))
5086 free (result);
5087 if (buf_malloced != NULL)
5088 free (buf_malloced);
5089 CLEANUP ();
5090 errno = EINVAL;
5091 return NULL;
5092 }
5035 /* Portability: Not all implementations of snprintf()
5036 are ISO C 99 compliant. Determine the number of
5037 bytes that snprintf() has produced or would have
5038 produced. */
5039 if (count >= 0)
5040 {
5041 /* Verify that snprintf() has NUL-terminated its
5042 result. */
5043 if (count < maxlen
5044 && ((TCHAR_T *) (result + length)) [count] != '\0')
5045 abort ();
5046 /* Portability hack. */
5047 if (retcount > count)
5048 count = retcount;
5049 }
5050 else
5051 {
5052 /* snprintf() doesn't understand the '%n'
5053 directive. */
5054 if (fbp[1] != '\0')
5055 {
5056 /* Don't use the '%n' directive; instead, look
5057 at the snprintf() return value. */
5058 fbp[1] = '\0';
5059 continue;
5060 }
5061 else
5062 {
5063 /* Look at the snprintf() return value. */
5064 if (retcount < 0)
5065 {
5066 /* HP-UX 10.20 snprintf() is doubly deficient:
5067 It doesn't understand the '%n' directive,
5068 *and* it returns -1 (rather than the length
5069 that would have been required) when the
5070 buffer is too small. */
5071 size_t bigger_need =
5072 xsum (xtimes (allocated, 2), 12);
5073 ENSURE_ALLOCATION (bigger_need);
5074 continue;
5075 }
5076 else
5077 count = retcount;
5078 }
5079 }
5080 #endif
5081
5082 /* Attempt to handle failure. */
5083 if (count < 0)
5084 {
5085 if (!(result == resultbuf || result == NULL))
5086 free (result);
5087 if (buf_malloced != NULL)
5088 free (buf_malloced);
5089 CLEANUP ();
5090 errno = EINVAL;
5091 return NULL;
5092 }
50935093
50945094 #if USE_SNPRINTF
5095 /* Handle overflow of the allocated buffer.
5096 If such an overflow occurs, a C99 compliant snprintf()
5097 returns a count >= maxlen. However, a non-compliant
5098 snprintf() function returns only count = maxlen - 1. To
5099 cover both cases, test whether count >= maxlen - 1. */
5100 if ((unsigned int) count + 1 >= maxlen)
5101 {
5102 /* If maxlen already has attained its allowed maximum,
5103 allocating more memory will not increase maxlen.
5104 Instead of looping, bail out. */
5105 if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
5106 goto overflow;
5107 else
5108 {
5109 /* Need at least (count + 1) * sizeof (TCHAR_T)
5110 bytes. (The +1 is for the trailing NUL.)
5111 But ask for (count + 2) * sizeof (TCHAR_T)
5112 bytes, so that in the next round, we likely get
5113 maxlen > (unsigned int) count + 1
5114 and so we don't get here again.
5115 And allocate proportionally, to avoid looping
5116 eternally if snprintf() reports a too small
5117 count. */
5118 size_t n =
5119 xmax (xsum (length,
5120 ((unsigned int) count + 2
5121 + TCHARS_PER_DCHAR - 1)
5122 / TCHARS_PER_DCHAR),
5123 xtimes (allocated, 2));
5124
5125 ENSURE_ALLOCATION (n);
5126 continue;
5127 }
5128 }
5095 /* Handle overflow of the allocated buffer.
5096 If such an overflow occurs, a C99 compliant snprintf()
5097 returns a count >= maxlen. However, a non-compliant
5098 snprintf() function returns only count = maxlen - 1. To
5099 cover both cases, test whether count >= maxlen - 1. */
5100 if ((unsigned int) count + 1 >= maxlen)
5101 {
5102 /* If maxlen already has attained its allowed maximum,
5103 allocating more memory will not increase maxlen.
5104 Instead of looping, bail out. */
5105 if (maxlen == INT_MAX / TCHARS_PER_DCHAR)
5106 goto overflow;
5107 else
5108 {
5109 /* Need at least (count + 1) * sizeof (TCHAR_T)
5110 bytes. (The +1 is for the trailing NUL.)
5111 But ask for (count + 2) * sizeof (TCHAR_T)
5112 bytes, so that in the next round, we likely get
5113 maxlen > (unsigned int) count + 1
5114 and so we don't get here again.
5115 And allocate proportionally, to avoid looping
5116 eternally if snprintf() reports a too small
5117 count. */
5118 size_t n =
5119 xmax (xsum (length,
5120 ((unsigned int) count + 2
5121 + TCHARS_PER_DCHAR - 1)
5122 / TCHARS_PER_DCHAR),
5123 xtimes (allocated, 2));
5124
5125 ENSURE_ALLOCATION (n);
5126 continue;
5127 }
5128 }
51295129 #endif
51305130
51315131 #if NEED_PRINTF_UNBOUNDED_PRECISION
5132 if (prec_ourselves)
5133 {
5134 /* Handle the precision. */
5135 TCHAR_T *prec_ptr =
5132 if (prec_ourselves)
5133 {
5134 /* Handle the precision. */
5135 TCHAR_T *prec_ptr =
51365136 # if USE_SNPRINTF
5137 (TCHAR_T *) (result + length);
5137 (TCHAR_T *) (result + length);
51385138 # else
5139 tmp;
5139 tmp;
51405140 # endif
5141 size_t prefix_count;
5142 size_t move;
5143
5144 prefix_count = 0;
5145 /* Put the additional zeroes after the sign. */
5146 if (count >= 1
5147 && (*prec_ptr == '-' || *prec_ptr == '+'
5148 || *prec_ptr == ' '))
5149 prefix_count = 1;
5150 /* Put the additional zeroes after the 0x prefix if
5151 (flags & FLAG_ALT) || (dp->conversion == 'p'). */
5152 else if (count >= 2
5153 && prec_ptr[0] == '0'
5154 && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'))
5155 prefix_count = 2;
5156
5157 move = count - prefix_count;
5158 if (precision > move)
5159 {
5160 /* Insert zeroes. */
5161 size_t insert = precision - move;
5162 TCHAR_T *prec_end;
5141 size_t prefix_count;
5142 size_t move;
5143
5144 prefix_count = 0;
5145 /* Put the additional zeroes after the sign. */
5146 if (count >= 1
5147 && (*prec_ptr == '-' || *prec_ptr == '+'
5148 || *prec_ptr == ' '))
5149 prefix_count = 1;
5150 /* Put the additional zeroes after the 0x prefix if
5151 (flags & FLAG_ALT) || (dp->conversion == 'p'). */
5152 else if (count >= 2
5153 && prec_ptr[0] == '0'
5154 && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X'))
5155 prefix_count = 2;
5156
5157 move = count - prefix_count;
5158 if (precision > move)
5159 {
5160 /* Insert zeroes. */
5161 size_t insert = precision - move;
5162 TCHAR_T *prec_end;
51635163
51645164 # if USE_SNPRINTF
5165 size_t n =
5166 xsum (length,
5167 (count + insert + TCHARS_PER_DCHAR - 1)
5168 / TCHARS_PER_DCHAR);
5169 length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
5170 ENSURE_ALLOCATION (n);
5171 length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
5172 prec_ptr = (TCHAR_T *) (result + length);
5165 size_t n =
5166 xsum (length,
5167 (count + insert + TCHARS_PER_DCHAR - 1)
5168 / TCHARS_PER_DCHAR);
5169 length += (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
5170 ENSURE_ALLOCATION (n);
5171 length -= (count + TCHARS_PER_DCHAR - 1) / TCHARS_PER_DCHAR;
5172 prec_ptr = (TCHAR_T *) (result + length);
51735173 # endif
51745174
5175 prec_end = prec_ptr + count;
5176 prec_ptr += prefix_count;
5177
5178 while (prec_end > prec_ptr)
5179 {
5180 prec_end--;
5181 prec_end[insert] = prec_end[0];
5182 }
5183
5184 prec_end += insert;
5185 do
5186 *--prec_end = '0';
5187 while (prec_end > prec_ptr);
5188
5189 count += insert;
5190 }
5191 }
5175 prec_end = prec_ptr + count;
5176 prec_ptr += prefix_count;
5177
5178 while (prec_end > prec_ptr)
5179 {
5180 prec_end--;
5181 prec_end[insert] = prec_end[0];
5182 }
5183
5184 prec_end += insert;
5185 do
5186 *--prec_end = '0';
5187 while (prec_end > prec_ptr);
5188
5189 count += insert;
5190 }
5191 }
51925192 #endif
51935193
51945194 #if !USE_SNPRINTF
5195 if (count >= tmp_length)
5196 /* tmp_length was incorrectly calculated - fix the
5197 code above! */
5198 abort ();
5195 if (count >= tmp_length)
5196 /* tmp_length was incorrectly calculated - fix the
5197 code above! */
5198 abort ();
51995199 #endif
52005200
52015201 #if !DCHAR_IS_TCHAR
5202 /* Convert from TCHAR_T[] to DCHAR_T[]. */
5203 if (dp->conversion == 'c' || dp->conversion == 's')
5204 {
5205 /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
5206 TYPE_WIDE_STRING.
5207 The result string is not certainly ASCII. */
5208 const TCHAR_T *tmpsrc;
5209 DCHAR_T *tmpdst;
5210 size_t tmpdst_len;
5211 /* This code assumes that TCHAR_T is 'char'. */
5212 typedef int TCHAR_T_verify
5213 [2 * (sizeof (TCHAR_T) == 1) - 1];
5202 /* Convert from TCHAR_T[] to DCHAR_T[]. */
5203 if (dp->conversion == 'c' || dp->conversion == 's')
5204 {
5205 /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING
5206 TYPE_WIDE_STRING.
5207 The result string is not certainly ASCII. */
5208 const TCHAR_T *tmpsrc;
5209 DCHAR_T *tmpdst;
5210 size_t tmpdst_len;
5211 /* This code assumes that TCHAR_T is 'char'. */
5212 typedef int TCHAR_T_verify
5213 [2 * (sizeof (TCHAR_T) == 1) - 1];
52145214 # if USE_SNPRINTF
5215 tmpsrc = (TCHAR_T *) (result + length);
5215 tmpsrc = (TCHAR_T *) (result + length);
52165216 # else
5217 tmpsrc = tmp;
5217 tmpsrc = tmp;
52185218 # endif
5219 tmpdst =
5220 DCHAR_CONV_FROM_ENCODING (locale_charset (),
5221 iconveh_question_mark,
5222 tmpsrc, count,
5223 NULL,
5224 NULL, &tmpdst_len);
5225 if (tmpdst == NULL)
5226 {
5227 int saved_errno = errno;
5228 if (!(result == resultbuf || result == NULL))
5229 free (result);
5230 if (buf_malloced != NULL)
5231 free (buf_malloced);
5232 CLEANUP ();
5233 errno = saved_errno;
5234 return NULL;
5235 }
5236 ENSURE_ALLOCATION (xsum (length, tmpdst_len));
5237 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
5238 free (tmpdst);
5239 count = tmpdst_len;
5240 }
5241 else
5242 {
5243 /* The result string is ASCII.
5244 Simple 1:1 conversion. */
5219 tmpdst =
5220 DCHAR_CONV_FROM_ENCODING (locale_charset (),
5221 iconveh_question_mark,
5222 tmpsrc, count,
5223 NULL,
5224 NULL, &tmpdst_len);
5225 if (tmpdst == NULL)
5226 {
5227 int saved_errno = errno;
5228 if (!(result == resultbuf || result == NULL))
5229 free (result);
5230 if (buf_malloced != NULL)
5231 free (buf_malloced);
5232 CLEANUP ();
5233 errno = saved_errno;
5234 return NULL;
5235 }
5236 ENSURE_ALLOCATION (xsum (length, tmpdst_len));
5237 DCHAR_CPY (result + length, tmpdst, tmpdst_len);
5238 free (tmpdst);
5239 count = tmpdst_len;
5240 }
5241 else
5242 {
5243 /* The result string is ASCII.
5244 Simple 1:1 conversion. */
52455245 # if USE_SNPRINTF
5246 /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a
5247 no-op conversion, in-place on the array starting
5248 at (result + length). */
5249 if (sizeof (DCHAR_T) != sizeof (TCHAR_T))
5246 /* If sizeof (DCHAR_T) == sizeof (TCHAR_T), it's a
5247 no-op conversion, in-place on the array starting
5248 at (result + length). */
5249 if (sizeof (DCHAR_T) != sizeof (TCHAR_T))
52505250 # endif
5251 {
5252 const TCHAR_T *tmpsrc;
5253 DCHAR_T *tmpdst;
5254 size_t n;
5251 {
5252 const TCHAR_T *tmpsrc;
5253 DCHAR_T *tmpdst;
5254 size_t n;
52555255
52565256 # if USE_SNPRINTF
5257 if (result == resultbuf)
5258 {
5259 tmpsrc = (TCHAR_T *) (result + length);
5260 /* ENSURE_ALLOCATION will not move tmpsrc
5261 (because it's part of resultbuf). */
5262 ENSURE_ALLOCATION (xsum (length, count));
5263 }
5264 else
5265 {
5266 /* ENSURE_ALLOCATION will move the array
5267 (because it uses realloc(). */
5268 ENSURE_ALLOCATION (xsum (length, count));
5269 tmpsrc = (TCHAR_T *) (result + length);
5270 }
5257 if (result == resultbuf)
5258 {
5259 tmpsrc = (TCHAR_T *) (result + length);
5260 /* ENSURE_ALLOCATION will not move tmpsrc
5261 (because it's part of resultbuf). */
5262 ENSURE_ALLOCATION (xsum (length, count));
5263 }
5264 else
5265 {
5266 /* ENSURE_ALLOCATION will move the array
5267 (because it uses realloc(). */
5268 ENSURE_ALLOCATION (xsum (length, count));
5269 tmpsrc = (TCHAR_T *) (result + length);
5270 }
52715271 # else
5272 tmpsrc = tmp;
5273 ENSURE_ALLOCATION (xsum (length, count));
5272 tmpsrc = tmp;
5273 ENSURE_ALLOCATION (xsum (length, count));
52745274 # endif
5275 tmpdst = result + length;
5276 /* Copy backwards, because of overlapping. */
5277 tmpsrc += count;
5278 tmpdst += count;
5279 for (n = count; n > 0; n--)
5280 *--tmpdst = (unsigned char) *--tmpsrc;
5281 }
5282 }
5275 tmpdst = result + length;
5276 /* Copy backwards, because of overlapping. */
5277 tmpsrc += count;
5278 tmpdst += count;
5279 for (n = count; n > 0; n--)
5280 *--tmpdst = (unsigned char) *--tmpsrc;
5281 }
5282 }
52835283 #endif
52845284
52855285 #if DCHAR_IS_TCHAR && !USE_SNPRINTF
5286 /* Make room for the result. */
5287 if (count > allocated - length)
5288 {
5289 /* Need at least count elements. But allocate
5290 proportionally. */
5291 size_t n =
5292 xmax (xsum (length, count), xtimes (allocated, 2));
5293
5294 ENSURE_ALLOCATION (n);
5295 }
5296 #endif
5297
5298 /* Here count <= allocated - length. */
5299
5300 /* Perform padding. */
5286 /* Make room for the result. */
5287 if (count > allocated - length)
5288 {
5289 /* Need at least count elements. But allocate
5290 proportionally. */
5291 size_t n =
5292 xmax (xsum (length, count), xtimes (allocated, 2));
5293
5294 ENSURE_ALLOCATION (n);
5295 }
5296 #endif
5297
5298 /* Here count <= allocated - length. */
5299
5300 /* Perform padding. */
53015301 #if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
5302 if (pad_ourselves && has_width)
5303 {
5304 size_t w;
5302 if (pad_ourselves && has_width)
5303 {
5304 size_t w;
53055305 # if ENABLE_UNISTDIO
5306 /* Outside POSIX, it's preferrable to compare the width
5307 against the number of _characters_ of the converted
5308 value. */
5309 w = DCHAR_MBSNLEN (result + length, count);
5306 /* Outside POSIX, it's preferrable to compare the width
5307 against the number of _characters_ of the converted
5308 value. */
5309 w = DCHAR_MBSNLEN (result + length, count);
53105310 # else
5311 /* The width is compared against the number of _bytes_
5312 of the converted value, says POSIX. */
5313 w = count;
5311 /* The width is compared against the number of _bytes_
5312 of the converted value, says POSIX. */
5313 w = count;
53145314 # endif
5315 if (w < width)
5316 {
5317 size_t pad = width - w;
5318
5319 /* Make room for the result. */
5320 if (xsum (count, pad) > allocated - length)
5321 {
5322 /* Need at least count + pad elements. But
5323 allocate proportionally. */
5324 size_t n =
5325 xmax (xsum3 (length, count, pad),
5326 xtimes (allocated, 2));
5315 if (w < width)
5316 {
5317 size_t pad = width - w;
5318
5319 /* Make room for the result. */
5320 if (xsum (count, pad) > allocated - length)
5321 {
5322 /* Need at least count + pad elements. But
5323 allocate proportionally. */
5324 size_t n =
5325 xmax (xsum3 (length, count, pad),
5326 xtimes (allocated, 2));
53275327
53285328 # if USE_SNPRINTF
5329 length += count;
5330 ENSURE_ALLOCATION (n);
5331 length -= count;
5329 length += count;
5330 ENSURE_ALLOCATION (n);
5331 length -= count;
53325332 # else
5333 ENSURE_ALLOCATION (n);
5333 ENSURE_ALLOCATION (n);
53345334 # endif
5335 }
5336 /* Here count + pad <= allocated - length. */
5337
5338 {
5335 }
5336 /* Here count + pad <= allocated - length. */
5337
5338 {
53395339 # if !DCHAR_IS_TCHAR || USE_SNPRINTF
5340 DCHAR_T * const rp = result + length;
5340 DCHAR_T * const rp = result + length;
53415341 # else
5342 DCHAR_T * const rp = tmp;
5342 DCHAR_T * const rp = tmp;
53435343 # endif
5344 DCHAR_T *p = rp + count;
5345 DCHAR_T *end = p + pad;
5346 DCHAR_T *pad_ptr;
5344 DCHAR_T *p = rp + count;
5345 DCHAR_T *end = p + pad;
5346 DCHAR_T *pad_ptr;
53475347 # if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
5348 if (dp->conversion == 'c'
5349 || dp->conversion == 's')
5350 /* No zero-padding for string directives. */
5351 pad_ptr = NULL;
5352 else
5348 if (dp->conversion == 'c'
5349 || dp->conversion == 's')
5350 /* No zero-padding for string directives. */
5351 pad_ptr = NULL;
5352 else
53535353 # endif
5354 {
5355 pad_ptr = (*rp == '-' ? rp + 1 : rp);
5356 /* No zero-padding of "inf" and "nan". */
5357 if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
5358 || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
5359 pad_ptr = NULL;
5360 }
5361 /* The generated string now extends from rp to p,
5362 with the zero padding insertion point being at
5363 pad_ptr. */
5364
5365 count = count + pad; /* = end - rp */
5366
5367 if (flags & FLAG_LEFT)
5368 {
5369 /* Pad with spaces on the right. */
5370 for (; pad > 0; pad--)
5371 *p++ = ' ';
5372 }
5373 else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
5374 {
5375 /* Pad with zeroes. */
5376 DCHAR_T *q = end;
5377
5378 while (p > pad_ptr)
5379 *--q = *--p;
5380 for (; pad > 0; pad--)
5381 *p++ = '0';
5382 }
5383 else
5384 {
5385 /* Pad with spaces on the left. */
5386 DCHAR_T *q = end;
5387
5388 while (p > rp)
5389 *--q = *--p;
5390 for (; pad > 0; pad--)
5391 *p++ = ' ';
5392 }
5393 }
5394 }
5395 }
5396 #endif
5397
5398 /* Here still count <= allocated - length. */
5354 {
5355 pad_ptr = (*rp == '-' ? rp + 1 : rp);
5356 /* No zero-padding of "inf" and "nan". */
5357 if ((*pad_ptr >= 'A' && *pad_ptr <= 'Z')
5358 || (*pad_ptr >= 'a' && *pad_ptr <= 'z'))
5359 pad_ptr = NULL;
5360 }
5361 /* The generated string now extends from rp to p,
5362 with the zero padding insertion point being at
5363 pad_ptr. */
5364
5365 count = count + pad; /* = end - rp */
5366
5367 if (flags & FLAG_LEFT)
5368 {
5369 /* Pad with spaces on the right. */
5370 for (; pad > 0; pad--)
5371 *p++ = ' ';
5372 }
5373 else if ((flags & FLAG_ZERO) && pad_ptr != NULL)
5374 {
5375 /* Pad with zeroes. */
5376 DCHAR_T *q = end;
5377
5378 while (p > pad_ptr)
5379 *--q = *--p;
5380 for (; pad > 0; pad--)
5381 *p++ = '0';
5382 }
5383 else
5384 {
5385 /* Pad with spaces on the left. */
5386 DCHAR_T *q = end;
5387
5388 while (p > rp)
5389 *--q = *--p;
5390 for (; pad > 0; pad--)
5391 *p++ = ' ';
5392 }
5393 }
5394 }
5395 }
5396 #endif
5397
5398 /* Here still count <= allocated - length. */
53995399
54005400 #if !DCHAR_IS_TCHAR || USE_SNPRINTF
5401 /* The snprintf() result did fit. */
5401 /* The snprintf() result did fit. */
54025402 #else
5403 /* Append the sprintf() result. */
5404 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
5403 /* Append the sprintf() result. */
5404 memcpy (result + length, tmp, count * sizeof (DCHAR_T));
54055405 #endif
54065406 #if !USE_SNPRINTF
5407 if (tmp != tmpbuf)
5408 free (tmp);
5407 if (tmp != tmpbuf)
5408 free (tmp);
54095409 #endif
54105410
54115411 #if NEED_PRINTF_DIRECTIVE_F
5412 if (dp->conversion == 'F')
5413 {
5414 /* Convert the %f result to upper case for %F. */
5415 DCHAR_T *rp = result + length;
5416 size_t rc;
5417 for (rc = count; rc > 0; rc--, rp++)
5418 if (*rp >= 'a' && *rp <= 'z')
5419 *rp = *rp - 'a' + 'A';
5420 }
5421 #endif
5422
5423 length += count;
5424 break;
5425 }
5426 }
5427 }
5412 if (dp->conversion == 'F')
5413 {
5414 /* Convert the %f result to upper case for %F. */
5415 DCHAR_T *rp = result + length;
5416 size_t rc;
5417 for (rc = count; rc > 0; rc--, rp++)
5418 if (*rp >= 'a' && *rp <= 'z')
5419 *rp = *rp - 'a' + 'A';
5420 }
5421 #endif
5422
5423 length += count;
5424 break;
5425 }
5426 }
5427 }
54285428 }
54295429
54305430 /* Add the final NUL. */
54335433
54345434 if (result != resultbuf && length + 1 < allocated)
54355435 {
5436 /* Shrink the allocated memory if possible. */
5437 DCHAR_T *memory;
5438
5439 memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
5440 if (memory != NULL)
5441 result = memory;
5436 /* Shrink the allocated memory if possible. */
5437 DCHAR_T *memory;
5438
5439 memory = (DCHAR_T *) realloc (result, (length + 1) * sizeof (DCHAR_T));
5440 if (memory != NULL)
5441 result = memory;
54425442 }
54435443
54445444 if (buf_malloced != NULL)
00 /* -*- buffer-read-only: t -*- vi: set ro: */
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* vsprintf with automatic memory allocation.
3 Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
3 Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc.
44
55 This program is free software; you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
2626 #include <stddef.h>
2727
2828 #ifndef __attribute__
29 /* This feature is available in gcc versions 2.5 and later. */
30 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
31 # define __attribute__(Spec) /* empty */
32 # endif
33 /* The __-protected variants of `format' and `printf' attributes
34 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
29 /* The __attribute__ feature is available in gcc versions 2.5 and later.
30 The __-protected variants of the attributes 'format' and 'printf' are
31 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
32 We enable __attribute__ only if these are supported too, because
33 gnulib and libintl do '#define printf __printf__' when they override
34 the 'printf' function. */
3535 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
36 # define __format__ format
37 # define __printf__ printf
36 # define __attribute__(Spec) /* empty */
3837 # endif
3938 #endif
4039
00 /* Compile-time assert-like macros.
11
2 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
2 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
109109
110110 #if 4 <= __GNUC__
111111 # define verify(R) \
112 extern int (* verify_function__ (void)) \
113 [__builtin_constant_p (R) && (R) ? 1 : -1]
112 extern int (* verify_function__ (void)) \
113 [__builtin_constant_p (R) && (R) ? 1 : -1]
114114 #endif
115115
116116 * In C++, any struct definition inside sizeof is invalid.
00 /* Formatted output to a stream.
1 Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
1 Copyright (C) 2004, 2006-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
5151 if (fwrite (output, 1, len, fp) < len)
5252 {
5353 if (output != buf)
54 {
55 int saved_errno = errno;
56 free (output);
57 errno = saved_errno;
58 }
54 {
55 int saved_errno = errno;
56 free (output);
57 errno = saved_errno;
58 }
5959 return -1;
6060 }
61
62 if (output != buf)
63 free (output);
6164
6265 if (len > INT_MAX)
6366 {
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
33
4 Copyright (C) 2007-2009 Free Software Foundation, Inc.
4 Copyright (C) 2007-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
3131 @PRAGMA_SYSTEM_HEADER@
3232 #endif
3333
34 #if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
34 #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
3535 /* Special invocation convention:
36 - Inside uClibc header files.
36 - Inside glibc and uClibc header files.
3737 - On HP-UX 11.00 we have a sequence of nested includes
3838 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
3939 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
5656 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
5757 <wchar.h>.
5858 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
59 included before <wchar.h>. */
60 #include <stddef.h>
61 #include <stdio.h>
62 #include <time.h>
59 included before <wchar.h>.
60 But avoid namespace pollution on glibc systems. */
61 #ifndef __GLIBC__
62 # include <stddef.h>
63 # include <stdio.h>
64 # include <time.h>
65 #endif
6366
6467 /* Include the original <wchar.h> if it exists.
6568 Some builds of uClibc lack it. */
7477 #define _GL_WCHAR_H
7578
7679 /* The definition of GL_LINK_WARNING is copied here. */
80
81 /* The definition of _GL_ARG_NONNULL is copied here. */
7782
7883 #ifdef __cplusplus
7984 extern "C" {
198203 # define mbsrtowcs rpl_mbsrtowcs
199204 # endif
200205 # if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
201 extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps);
206 extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
207 _GL_ARG_NONNULL ((2));
202208 # endif
203209 #elif defined GNULIB_POSIXCHECK
204210 # undef mbsrtowcs
216222 # define mbsnrtowcs rpl_mbsnrtowcs
217223 # endif
218224 # if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
219 extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps);
225 extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
226 _GL_ARG_NONNULL ((2));
220227 # endif
221228 #elif defined GNULIB_POSIXCHECK
222229 # undef mbsnrtowcs
252259 # define wcsrtombs rpl_wcsrtombs
253260 # endif
254261 # if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
255 extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps);
262 extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
263 _GL_ARG_NONNULL ((2));
256264 # endif
257265 #elif defined GNULIB_POSIXCHECK
258266 # undef wcsrtombs
270278 # define wcsnrtombs rpl_wcsnrtombs
271279 # endif
272280 # if !@HAVE_WCSNRTOMBS@ || @REPLACE_WCSNRTOMBS@
273 extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps);
281 extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
282 _GL_ARG_NONNULL ((2));
274283 # endif
275284 #elif defined GNULIB_POSIXCHECK
276285 # undef wcsnrtombs
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
33
4 Copyright (C) 2006-2009 Free Software Foundation, Inc.
4 Copyright (C) 2006-2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
6363 # endif
6464 #endif
6565
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69
6670 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
6771 Linux libc5 has <wctype.h> and the functions but they are broken.
6872 Assume all 12 functions are implemented the same way, or not at all. */
7377 refer to system functions like _iswctype that are not in the
7478 standard C library. Rather than try to get ancient buggy
7579 implementations like this to work, just disable them. */
76 # undef iswalnum
77 # undef iswalpha
78 # undef iswblank
79 # undef iswcntrl
80 # undef iswdigit
81 # undef iswgraph
82 # undef iswlower
83 # undef iswprint
84 # undef iswpunct
85 # undef iswspace
86 # undef iswupper
87 # undef iswxdigit
88 # undef towlower
89 # undef towupper
80 # undef iswalnum
81 # undef iswalpha
82 # undef iswblank
83 # undef iswcntrl
84 # undef iswdigit
85 # undef iswgraph
86 # undef iswlower
87 # undef iswprint
88 # undef iswpunct
89 # undef iswspace
90 # undef iswupper
91 # undef iswxdigit
92 # undef towlower
93 # undef towupper
9094
9195 /* Linux libc5 has <wctype.h> and the functions but they are broken. */
92 # if @REPLACE_ISWCNTRL@
93 # define iswalnum rpl_iswalnum
94 # define iswalpha rpl_iswalpha
95 # define iswblank rpl_iswblank
96 # define iswcntrl rpl_iswcntrl
97 # define iswdigit rpl_iswdigit
98 # define iswgraph rpl_iswgraph
99 # define iswlower rpl_iswlower
100 # define iswprint rpl_iswprint
101 # define iswpunct rpl_iswpunct
102 # define iswspace rpl_iswspace
103 # define iswupper rpl_iswupper
104 # define iswxdigit rpl_iswxdigit
105 # define towlower rpl_towlower
106 # define towupper rpl_towupper
107 # endif
96 # if @REPLACE_ISWCNTRL@
97 # define iswalnum rpl_iswalnum
98 # define iswalpha rpl_iswalpha
99 # define iswblank rpl_iswblank
100 # define iswcntrl rpl_iswcntrl
101 # define iswdigit rpl_iswdigit
102 # define iswgraph rpl_iswgraph
103 # define iswlower rpl_iswlower
104 # define iswprint rpl_iswprint
105 # define iswpunct rpl_iswpunct
106 # define iswspace rpl_iswspace
107 # define iswupper rpl_iswupper
108 # define iswxdigit rpl_iswxdigit
109 # define towlower rpl_towlower
110 # define towupper rpl_towupper
111 # endif
108112
109113 static inline int
110114 iswalnum (wint_t wc)
111115 {
112116 return ((wc >= '0' && wc <= '9')
113 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
117 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
114118 }
115119
116120 static inline int
159163 iswpunct (wint_t wc)
160164 {
161165 return (wc >= '!' && wc <= '~'
162 && !((wc >= '0' && wc <= '9')
163 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
166 && !((wc >= '0' && wc <= '9')
167 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
164168 }
165169
166170 static inline int
167171 iswspace (wint_t wc)
168172 {
169173 return (wc == ' ' || wc == '\t'
170 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
174 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
171175 }
172176
173177 static inline int
180184 iswxdigit (wint_t wc)
181185 {
182186 return ((wc >= '0' && wc <= '9')
183 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
187 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
184188 }
185189
186190 static inline wint_t
195199 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
196200 }
197201
198 # endif /* ! HAVE_ISWCNTRL */
199
200 # if defined __MINGW32__
202 #endif /* ! HAVE_ISWCNTRL || REPLACE_ISWCNTRL */
203
204 #if defined __MINGW32__
201205
202206 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
203207 The functions towlower and towupper are implemented in the MSVCRT library
217221 {
218222 return (wint_t) (wchar_t) towlower (wc);
219223 }
220 # define towlower rpl_towlower
224 # define towlower rpl_towlower
221225
222226 static inline wint_t
223227 rpl_towupper (wint_t wc)
224228 {
225229 return (wint_t) (wchar_t) towupper (wc);
226230 }
227 # define towupper rpl_towupper
228
229 # endif
231 # define towupper rpl_towupper
232
233 #endif /* __MINGW32__ */
234
235 #ifdef __cplusplus
236 }
237 #endif
230238
231239 #endif /* _GL_WCTYPE_H */
232240 #endif /* _GL_WCTYPE_H */
00 /* Report a memory allocation failure and exit.
11
2 Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006 Free
3 Software Foundation, Inc.
2 Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2009, 2010
3 Free Software Foundation, Inc.
44
55 This program is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
00 /* xalloc.h -- malloc with out-of-memory checking
11
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
4 Inc.
45
56 This program is free software: you can redistribute it and/or modify
67 it under the terms of the GNU General Public License as published by
104105 # if HAVE_INLINE
105106 # define static_inline static inline
106107 # else
107 void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
108 void *xnrealloc (void *p, size_t n, size_t s);
109 void *x2nrealloc (void *p, size_t *pn, size_t s);
110 char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
108 void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
109 void *xnrealloc (void *p, size_t n, size_t s);
110 void *x2nrealloc (void *p, size_t *pn, size_t s);
111 char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
111112 # endif
112113
113114 # ifdef static_inline
160161 void
161162 append_int (int value)
162163 {
163 if (used == allocated)
164 p = x2nrealloc (p, &allocated, sizeof *p);
165 p[used++] = value;
164 if (used == allocated)
165 p = x2nrealloc (p, &allocated, sizeof *p);
166 p[used++] = value;
166167 }
167168
168169 This causes x2nrealloc to allocate a block of some nonzero size the
180181 void
181182 append_int (int value)
182183 {
183 if (used == allocated)
184 {
185 p = x2nrealloc (p, &allocated1, sizeof *p);
186 allocated = allocated1;
187 }
188 p[used++] = value;
184 if (used == allocated)
185 {
186 p = x2nrealloc (p, &allocated1, sizeof *p);
187 allocated = allocated1;
188 }
189 p[used++] = value;
189190 }
190191
191192 */
198199 if (! p)
199200 {
200201 if (! n)
201 {
202 /* The approximate size to use for initial small allocation
203 requests, when the invoking code specifies an old size of
204 zero. 64 bytes is the largest "small" request for the
205 GNU C library malloc. */
206 enum { DEFAULT_MXFAST = 64 };
207
208 n = DEFAULT_MXFAST / s;
209 n += !n;
210 }
202 {
203 /* The approximate size to use for initial small allocation
204 requests, when the invoking code specifies an old size of
205 zero. 64 bytes is the largest "small" request for the
206 GNU C library malloc. */
207 enum { DEFAULT_MXFAST = 64 };
208
209 n = DEFAULT_MXFAST / s;
210 n += !n;
211 }
211212 }
212213 else
213214 {
214215 /* Set N = ceil (1.5 * N) so that progress is made if N == 1.
215 Check for overflow, so that N * S stays in size_t range.
216 The check is slightly conservative, but an exact check isn't
217 worth the trouble. */
216 Check for overflow, so that N * S stays in size_t range.
217 The check is slightly conservative, but an exact check isn't
218 worth the trouble. */
218219 if ((size_t) -1 / 3 * 2 / s <= n)
219 xalloc_die ();
220 xalloc_die ();
220221 n += (n + 1) / 2;
221222 }
222223
0 /* xgetcwd.c -- return current directory with unlimited length
1
2 Copyright (C) 2001, 2003-2004, 2006-2007, 2009-2010 Free Software
3 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 /* Written by Jim Meyering. */
19
20 #include <config.h>
21
22 #include "xgetcwd.h"
23
24 #include <errno.h>
25 #include <unistd.h>
26
27 #include "xalloc.h"
28
29 /* Return the current directory, newly allocated.
30 Upon an out-of-memory error, call xalloc_die.
31 Upon any other type of error, return NULL. */
32
33 char *
34 xgetcwd (void)
35 {
36 char *cwd = getcwd (NULL, 0);
37 if (! cwd && errno == ENOMEM)
38 xalloc_die ();
39 return cwd;
40 }
0 /* prototype for xgetcwd
1 Copyright (C) 1995, 2001, 2003, 2009-2010 Free Software Foundation, Inc.
2
3 This program is free software: you can redistribute it and/or modify
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
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15
16 extern char *xgetcwd (void);
00 /* xmalloc.c -- malloc with out of memory checking
11
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008-2009 Free Software Foundation,
4 Inc.
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software
4 Foundation, Inc.
55
66 This program is free software: you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
11 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
22 /* xsize.h -- Checked size_t computations.
33
4 Copyright (C) 2003, 2008 Free Software Foundation, Inc.
4 Copyright (C) 2003, 2008, 2009, 2010 Free Software Foundation, Inc.
55
66 This program is free software; you can redistribute it and/or modify
77 it under the terms of the GNU General Public License as published by
00 /* yesno.c -- read a yes/no response from stdin
11
2 Copyright (C) 1990, 1998, 2001, 2003-2008 Free Software Foundation, Inc.
2 Copyright (C) 1990, 1998, 2001, 2003-2010 Free Software Foundation, Inc.
33
44 This program is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
00 /* declare yesno
1 Copyright (C) 2004 Free Software Foundation, Inc.
1 Copyright (C) 2004, 2009-2010 Free Software Foundation, Inc.
22
33 This program is free software: you can redistribute it and/or modify
44 it under the terms of the GNU General Public License as published by
00 # 00gnulib.m4 serial 2
1 dnl Copyright (C) 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # alloca.m4 serial 9
1 dnl Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation,
2 dnl Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
00 # calloc.m4 serial 9
11
2 # Copyright (C) 2004-2009 Free Software Foundation, Inc.
2 # Copyright (C) 2004-2010 Free Software Foundation, Inc.
33 # This file is free software; the Free Software Foundation
44 # gives unlimited permission to copy and/or distribute it,
55 # with or without modifications, as long as this notice is preserved.
1818 [AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1919 AC_CACHE_CHECK([for GNU libc compatible calloc], [ac_cv_func_calloc_0_nonnull],
2020 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
21 [[exit (!calloc (0, 0) || calloc ((size_t) -1 / 8 + 1, 8));]])],
22 [ac_cv_func_calloc_0_nonnull=yes],
23 [ac_cv_func_calloc_0_nonnull=no],
24 [ac_cv_func_calloc_0_nonnull=no])])
21 [[exit (!calloc (0, 0) || calloc ((size_t) -1 / 8 + 1, 8));]])],
22 [ac_cv_func_calloc_0_nonnull=yes],
23 [ac_cv_func_calloc_0_nonnull=no],
24 [ac_cv_func_calloc_0_nonnull=no])])
2525 AS_IF([test $ac_cv_func_calloc_0_nonnull = yes], [$1], [$2])
2626 ])# AC_FUNC_CALLOC
2727
3333 AC_DEFUN([AC_FUNC_CALLOC],
3434 [_AC_FUNC_CALLOC_IF(
3535 [AC_DEFINE([HAVE_CALLOC], [1],
36 [Define to 1 if your system has a GNU libc compatible `calloc'
37 function, and to 0 otherwise.])],
36 [Define to 1 if your system has a GNU libc compatible `calloc'
37 function, and to 0 otherwise.])],
3838 [AC_DEFINE([HAVE_CALLOC], [0])
3939 AC_LIBOBJ([calloc])
4040 AC_DEFINE([calloc], [rpl_calloc],
0 #serial 11
1
2 # Use Gnulib's robust chdir function.
3 # It can handle arbitrarily long directory names, which means
4 # that when it is given the name of an existing directory, it
5 # never fails with ENAMETOOLONG.
6 # Arrange to compile chdir-long.c only on systems that define PATH_MAX.
7
8 dnl Copyright (C) 2004-2007, 2009-2010 Free Software Foundation, Inc.
9 dnl This file is free software; the Free Software Foundation
10 dnl gives unlimited permission to copy and/or distribute it,
11 dnl with or without modifications, as long as this notice is preserved.
12
13 # Written by Jim Meyering.
14
15 AC_DEFUN([gl_FUNC_CHDIR_LONG],
16 [
17 AC_CACHE_CHECK([whether this system has an arbitrary file name length limit],
18 gl_cv_have_arbitrary_file_name_length_limit,
19 [AC_EGREP_CPP([have_arbitrary_file_name_length_limit],
20 [#include <unistd.h>
21 #include <limits.h>
22 #if defined PATH_MAX || defined MAXPATHLEN
23 have_arbitrary_file_name_length_limit
24 #endif],
25 gl_cv_have_arbitrary_file_name_length_limit=yes,
26 gl_cv_have_arbitrary_file_name_length_limit=no)])
27
28 if test $gl_cv_have_arbitrary_file_name_length_limit = yes; then
29 AC_LIBOBJ([chdir-long])
30 gl_PREREQ_CHDIR_LONG
31 fi
32 ])
33
34 AC_DEFUN([gl_PREREQ_CHDIR_LONG],
35 [
36 AC_REQUIRE([AC_C_INLINE])
37 :
38 ])
0 # serial 22
1 # Determine whether we need the chown wrapper.
2
3 dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009-2010 Free Software
4 dnl Foundation, Inc.
5
6 dnl This file is free software; the Free Software Foundation
7 dnl gives unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
9
10 # chown should accept arguments of -1 for uid and gid, and it should
11 # dereference symlinks. If it doesn't, arrange to use the replacement
12 # function.
13
14 # From Jim Meyering.
15
16 AC_DEFUN_ONCE([gl_FUNC_CHOWN],
17 [
18 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
19 AC_REQUIRE([AC_TYPE_UID_T])
20 AC_REQUIRE([AC_FUNC_CHOWN])
21 AC_REQUIRE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK])
22 AC_CHECK_FUNCS_ONCE([chown fchown])
23
24 dnl mingw lacks chown altogether.
25 if test $ac_cv_func_chown = no; then
26 HAVE_CHOWN=0
27 AC_LIBOBJ([chown])
28 else
29 dnl Some old systems treated chown like lchown.
30 if test $gl_cv_func_chown_follows_symlink = no; then
31 REPLACE_CHOWN=1
32 AC_LIBOBJ([chown])
33 fi
34
35 dnl Some old systems tried to use uid/gid -1 literally.
36 if test $ac_cv_func_chown_works = no; then
37 AC_DEFINE([CHOWN_FAILS_TO_HONOR_ID_OF_NEGATIVE_ONE], [1],
38 [Define if chown is not POSIX compliant regarding IDs of -1.])
39 REPLACE_CHOWN=1
40 AC_LIBOBJ([chown])
41 fi
42
43 dnl Solaris 9 ignores trailing slash.
44 dnl FreeBSD 7.2 mishandles trailing slash on symlinks.
45 AC_CACHE_CHECK([whether chown honors trailing slash],
46 [gl_cv_func_chown_slash_works],
47 [touch conftest.file && rm -f conftest.link
48 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
49 #include <unistd.h>
50 #include <stdlib.h>
51 #include <errno.h>
52 ]], [[ if (symlink ("conftest.file", "conftest.link")) return 1;
53 if (chown ("conftest.link/", getuid (), getgid ()) == 0) return 2;
54 ]])],
55 [gl_cv_func_chown_slash_works=yes],
56 [gl_cv_func_chown_slash_works=no],
57 [gl_cv_func_chown_slash_works="guessing no"])
58 rm -f conftest.link conftest.file])
59 if test "$gl_cv_func_chown_slash_works" != yes; then
60 AC_DEFINE([CHOWN_TRAILING_SLASH_BUG], [1],
61 [Define to 1 if chown mishandles trailing slash.])
62 REPLACE_CHOWN=1
63 AC_LIBOBJ([chown])
64 fi
65
66 dnl OpenBSD fails to update ctime if ownership does not change.
67 AC_CACHE_CHECK([whether chown always updates ctime],
68 [gl_cv_func_chown_ctime_works],
69 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
70 #include <unistd.h>
71 #include <stdlib.h>
72 #include <errno.h>
73 #include <fcntl.h>
74 #include <sys/stat.h>
75 ]], [[ struct stat st1, st2;
76 if (close (creat ("conftest.file", 0600))) return 1;
77 if (stat ("conftest.file", &st1)) return 2;
78 sleep (1);
79 if (chown ("conftest.file", st1.st_uid, st1.st_gid)) return 3;
80 if (stat ("conftest.file", &st2)) return 4;
81 if (st2.st_ctime <= st1.st_ctime) return 5;
82 ]])],
83 [gl_cv_func_chown_ctime_works=yes],
84 [gl_cv_func_chown_ctime_works=no],
85 [gl_cv_func_chown_ctime_works="guessing no"])
86 rm -f conftest.file])
87 if test "$gl_cv_func_chown_ctime_works" != yes; then
88 AC_DEFINE([CHOWN_CHANGE_TIME_BUG], [1], [Define to 1 if chown fails
89 to change ctime when at least one argument was not -1.])
90 REPLACE_CHOWN=1
91 AC_LIBOBJ([chown])
92 fi
93
94 if test $REPLACE_CHOWN = 1 && test $ac_cv_func_fchown = no; then
95 AC_LIBOBJ([fchown-stub])
96 fi
97 fi
98 ])
99
100 # Determine whether chown follows symlinks (it should).
101 AC_DEFUN_ONCE([gl_FUNC_CHOWN_FOLLOWS_SYMLINK],
102 [
103 AC_CACHE_CHECK(
104 [whether chown dereferences symlinks],
105 [gl_cv_func_chown_follows_symlink],
106 [
107 AC_RUN_IFELSE([AC_LANG_SOURCE([[
108 #include <unistd.h>
109 #include <stdlib.h>
110 #include <errno.h>
111
112 int
113 main ()
114 {
115 char const *dangling_symlink = "conftest.dangle";
116
117 unlink (dangling_symlink);
118 if (symlink ("conftest.no-such", dangling_symlink))
119 abort ();
120
121 /* Exit successfully on a conforming system,
122 i.e., where chown must fail with ENOENT. */
123 exit ( ! (chown (dangling_symlink, getuid (), getgid ()) != 0
124 && errno == ENOENT));
125 }
126 ]])],
127 [gl_cv_func_chown_follows_symlink=yes],
128 [gl_cv_func_chown_follows_symlink=no],
129 [gl_cv_func_chown_follows_symlink=yes]
130 )
131 ]
132 )
133
134 if test $gl_cv_func_chown_follows_symlink = no; then
135 AC_DEFINE([CHOWN_MODIFIES_SYMLINK], [1],
136 [Define if chown modifies symlinks.])
137 fi
138 ])
00 # clock_time.m4 serial 10
1 dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 #serial 3
1 dnl Copyright (C) 2006-2007 Free Software Foundation, Inc.
1 dnl Copyright (C) 2006-2007, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # close.m4 serial 5
1 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # closein.m4 serial 1
1 dnl Copyright (C) 2007 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # closeout.m4 serial 5
1 dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2010 Free Software Foundation,
2 dnl Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
00 # codeset.m4 serial 4 (gettext-0.18)
1 dnl Copyright (C) 2000-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # serial 11
1
2 dnl From Jim Meyering.
3 dnl
4 dnl Check whether struct dirent has a member named d_ino.
5 dnl
6
7 # Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009-2010 Free Software
8 # Foundation, Inc.
9
10 # This file is free software; the Free Software Foundation
11 # gives unlimited permission to copy and/or distribute it,
12 # with or without modifications, as long as this notice is preserved.
13
14 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
15 [AC_CACHE_CHECK([for d_ino member in directory struct],
16 gl_cv_struct_dirent_d_ino,
17 [AC_RUN_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#include <sys/types.h>
20 #include <sys/stat.h>
21 #include <dirent.h>
22 ]],
23 [[DIR *dp = opendir (".");
24 struct dirent *e;
25 struct stat st;
26 if (! dp)
27 return 1;
28 e = readdir (dp);
29 return ! (e
30 && stat (e->d_name, &st) == 0
31 && e->d_ino == st.st_ino);]])],
32 [gl_cv_struct_dirent_d_ino=yes],
33 [gl_cv_struct_dirent_d_ino=no],
34 [gl_cv_struct_dirent_d_ino=no])])
35 if test $gl_cv_struct_dirent_d_ino = yes; then
36 AC_DEFINE([D_INO_IN_DIRENT], [1],
37 [Define if struct dirent has a member d_ino that actually works.])
38 fi
39 ]
40 )
0 # dirent_h.m4 serial 8
1 dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl Written by Bruno Haible.
7
8 AC_DEFUN([gl_DIRENT_H],
9 [
10 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
11 dnl once only, before all statements that occur in other macros.
12 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
13
14 dnl <dirent.h> is always overridden, because of GNULIB_POSIXCHECK.
15 gl_CHECK_NEXT_HEADERS([dirent.h])
16 ])
17
18 dnl Unconditionally enables the replacement of <dirent.h>.
19 AC_DEFUN([gl_REPLACE_DIRENT_H],
20 [
21 dnl This is a no-op, because <dirent.h> is always overridden.
22 :
23 ])
24
25 AC_DEFUN([gl_DIRENT_MODULE_INDICATOR],
26 [
27 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
28 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
29 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
30 ])
31
32 AC_DEFUN([gl_DIRENT_H_DEFAULTS],
33 [
34 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
35 GNULIB_DIRFD=0; AC_SUBST([GNULIB_DIRFD])
36 GNULIB_FDOPENDIR=0; AC_SUBST([GNULIB_FDOPENDIR])
37 GNULIB_SCANDIR=0; AC_SUBST([GNULIB_SCANDIR])
38 GNULIB_ALPHASORT=0; AC_SUBST([GNULIB_ALPHASORT])
39 dnl Assume proper GNU behavior unless another module says otherwise.
40 HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD])
41 HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR])
42 HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR])
43 HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT])
44 REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR])
45 REPLACE_FDOPENDIR=0; AC_SUBST([REPLACE_FDOPENDIR])
46 REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR])
47 ])
0 # serial 17 -*- Autoconf -*-
1
2 dnl Find out how to get the file descriptor associated with an open DIR*.
3
4 # Copyright (C) 2001-2006, 2008-2010 Free Software Foundation, Inc.
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
9 dnl From Jim Meyering
10
11 AC_DEFUN([gl_FUNC_DIRFD],
12 [
13 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
14 gl_REPLACE_DIRENT_H
15
16 dnl Persuade glibc <dirent.h> to declare dirfd().
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
18
19 dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
20 AC_REQUIRE([AC_PROG_CPP])
21 AC_REQUIRE([AC_PROG_EGREP])
22
23 AC_CHECK_FUNCS([dirfd])
24 AC_CHECK_DECLS([dirfd], , ,
25 [#include <sys/types.h>
26 #include <dirent.h>])
27 if test $ac_cv_have_decl_dirfd = no; then
28 HAVE_DECL_DIRFD=0
29 fi
30
31 AC_CACHE_CHECK([whether dirfd is a macro],
32 gl_cv_func_dirfd_macro,
33 [AC_EGREP_CPP([dirent_header_defines_dirfd], [
34 #include <sys/types.h>
35 #include <dirent.h>
36 #ifdef dirfd
37 dirent_header_defines_dirfd
38 #endif],
39 gl_cv_func_dirfd_macro=yes,
40 gl_cv_func_dirfd_macro=no)])
41
42 # Use the replacement only if we have no function, macro,
43 # or declaration with that name.
44 if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd,$gl_cv_func_dirfd_macro \
45 = no,no,no; then
46 AC_REPLACE_FUNCS([dirfd])
47 AC_CACHE_CHECK(
48 [how to get the file descriptor associated with an open DIR*],
49 gl_cv_sys_dir_fd_member_name,
50 [
51 dirfd_save_CFLAGS=$CFLAGS
52 for ac_expr in d_fd dd_fd; do
53
54 CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
55 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
56 #include <sys/types.h>
57 #include <dirent.h>]],
58 [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
59 [dir_fd_found=yes]
60 )
61 CFLAGS=$dirfd_save_CFLAGS
62 test "$dir_fd_found" = yes && break
63 done
64 test "$dir_fd_found" = yes || ac_expr=no_such_member
65
66 gl_cv_sys_dir_fd_member_name=$ac_expr
67 ]
68 )
69 if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
70 AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME],
71 $gl_cv_sys_dir_fd_member_name,
72 [the name of the file descriptor member of DIR])
73 fi
74 AH_VERBATIM(DIR_TO_FD,
75 [#ifdef DIR_FD_MEMBER_NAME
76 # define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
77 #else
78 # define DIR_TO_FD(Dir_p) -1
79 #endif
80 ])
81 fi
82 ])
0 #serial 8 -*- autoconf -*-
1 dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_DIRNAME],
7 [
8 AC_REQUIRE([gl_DIRNAME_LGPL])
9 AC_LIBOBJ([basename])
10 AC_LIBOBJ([dirname])
11 ])
12
13 AC_DEFUN([gl_DIRNAME_LGPL],
14 [
15 AC_LIBOBJ([basename-lgpl])
16 AC_LIBOBJ([dirname-lgpl])
17 AC_LIBOBJ([stripslash])
18
19 dnl Prerequisites of lib/dirname.h.
20 AC_REQUIRE([gl_AC_DOS])
21 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
22
23 dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
24 dnl lib/stripslash.c.
25 ])
22 # Define some macros required for proper operation of code in lib/*.c
33 # on MSDOS/Windows systems.
44
5 # Copyright (C) 2000, 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # Copyright (C) 2000-2001, 2004-2006, 2009-2010 Free Software Foundation, Inc.
66 # This file is free software; the Free Software Foundation
77 # gives unlimited permission to copy and/or distribute it,
88 # with or without modifications, as long as this notice is preserved.
1313 [
1414 AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
1515 [
16 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
16 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
1717 #if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
1818 neither MSDOS nor Windows
1919 #endif]])],
20 [ac_cv_win_or_dos=yes],
21 [ac_cv_win_or_dos=no])
20 [ac_cv_win_or_dos=yes],
21 [ac_cv_win_or_dos=no])
2222 ])
2323
2424 if test x"$ac_cv_win_or_dos" = xyes; then
2525 ac_fs_accepts_drive_letter_prefix=1
2626 ac_fs_backslash_is_file_name_separator=1
2727 AC_CACHE_CHECK([whether drive letter can start relative path],
28 [ac_cv_drive_letter_can_be_relative],
29 [
30 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
28 [ac_cv_drive_letter_can_be_relative],
29 [
30 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
3131 #if defined __CYGWIN__
3232 drive letters are always absolute
3333 #endif]])],
34 [ac_cv_drive_letter_can_be_relative=yes],
35 [ac_cv_drive_letter_can_be_relative=no])
36 ])
34 [ac_cv_drive_letter_can_be_relative=yes],
35 [ac_cv_drive_letter_can_be_relative=no])
36 ])
3737 if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
38 ac_fs_drive_letter_can_be_relative=1
38 ac_fs_drive_letter_can_be_relative=1
3939 else
40 ac_fs_drive_letter_can_be_relative=0
40 ac_fs_drive_letter_can_be_relative=0
4141 fi
4242 else
4343 ac_fs_accepts_drive_letter_prefix=0
0 # double-slash-root.m4 serial 4 -*- Autoconf -*-
1 dnl Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
7 [
8 AC_REQUIRE([AC_CANONICAL_HOST])
9 AC_CACHE_CHECK([whether // is distinct from /], [gl_cv_double_slash_root],
10 [ if test x"$cross_compiling" = xyes ; then
11 # When cross-compiling, there is no way to tell whether // is special
12 # short of a list of hosts. However, the only known hosts to date
13 # that have a distinct // are Apollo DomainOS (too old to port to),
14 # Cygwin, and z/OS. If anyone knows of another system for which // has
15 # special semantics and is distinct from /, please report it to
16 # <bug-gnulib@gnu.org>.
17 case $host in
18 *-cygwin | i370-ibm-openedition)
19 gl_cv_double_slash_root=yes ;;
20 *)
21 # Be optimistic and assume that / and // are the same when we
22 # don't know.
23 gl_cv_double_slash_root='unknown, assuming no' ;;
24 esac
25 else
26 set x `ls -di / // 2>/dev/null`
27 if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
28 gl_cv_double_slash_root=no
29 else
30 gl_cv_double_slash_root=yes
31 fi
32 fi])
33 if test "$gl_cv_double_slash_root" = yes; then
34 AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
35 [Define to 1 if // is a file system root distinct from /.])
36 fi
37 ])
0 #serial 9
1 dnl Copyright (C) 2002, 2005, 2007, 2009 Free Software Foundation, Inc.
0 #serial 10
1 dnl Copyright (C) 2002, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
2727 return 0;
2828 ])
2929 ],
30 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
31 [case "$host_os" in
32 mingw*) # on this platform, dup2 always returns 0 for success
33 gl_cv_func_dup2_works=no;;
34 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
35 gl_cv_func_dup2_works=no;;
36 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
37 # closed fd may yield -EBADF instead of -1 / errno=EBADF.
38 gl_cv_func_dup2_works=no;;
30 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
31 [case "$host_os" in
32 mingw*) # on this platform, dup2 always returns 0 for success
33 gl_cv_func_dup2_works=no;;
34 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
35 gl_cv_func_dup2_works=no;;
36 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
37 # closed fd may yield -EBADF instead of -1 / errno=EBADF.
38 gl_cv_func_dup2_works=no;;
3939 freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
40 gl_cv_func_dup2_works=no;;
41 *) gl_cv_func_dup2_works=yes;;
42 esac])
40 gl_cv_func_dup2_works=no;;
41 *) gl_cv_func_dup2_works=yes;;
42 esac])
4343 ])
4444 if test "$gl_cv_func_dup2_works" = no; then
4545 gl_REPLACE_DUP2
4646 fi
4747 fi
48 AC_DEFINE_UNQUOTED([REPLACE_DUP2], [$REPLACE_DUP2],
49 [Define to 1 if dup2 returns 0 instead of the target fd.])
5048 ])
5149
5250 AC_DEFUN([gl_REPLACE_DUP2],
5351 [
5452 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
55 REPLACE_DUP2=1
53 if test $ac_cv_func_dup2 = yes; then
54 REPLACE_DUP2=1
55 fi
5656 AC_LIBOBJ([dup2])
5757 ])
00 # errno_h.m4 serial 6
1 dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 #serial 11
0 #serial 12
11
2 # Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004 Free Software
3 # Foundation, Inc.
2 # Copyright (C) 1996-1998, 2001-2004, 2009-2010 Free Software Foundation, Inc.
43 #
54 # This file is free software; the Free Software Foundation
65 # gives unlimited permission to copy and/or distribute it,
1716 AC_DEFUN([gl_PREREQ_ERROR],
1817 [
1918 AC_REQUIRE([AC_FUNC_STRERROR_R])
19 AC_REQUIRE([AC_C_INLINE])
2020 :
2121 ])
00 # exitfail.m4 serial 6
1 dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation,
2 dnl Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
00 # exponentd.m4 serial 1
1 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # exponentf.m4 serial 1
1 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # exponentl.m4 serial 2
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # serial 8 -*- Autoconf -*-
0 # serial 9 -*- Autoconf -*-
11 # Enable extensions on systems that normally disable them.
22
3 # Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
3 # Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc.
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
66 # with or without modifications, as long as this notice is preserved.
1010 # 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
1111 # enough in this area it's likely we'll need to redefine
1212 # AC_USE_SYSTEM_EXTENSIONS for quite some time.
13
14 # If autoconf reports a warning
15 # warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
16 # or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
17 # the fix is
18 # 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
19 # but always AC_REQUIREd,
20 # 2) to ensure that for each occurrence of
21 # AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22 # or
23 # AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
24 # the corresponding gnulib module description has 'extensions' among
25 # its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
26 # invocation occurs in gl_EARLY, not in gl_INIT.
1327
1428 # AC_USE_SYSTEM_EXTENSIONS
1529 # ------------------------
7387 [ac_cv_safe_to_define___extensions__],
7488 [AC_COMPILE_IFELSE(
7589 [AC_LANG_PROGRAM([[
76 # define __EXTENSIONS__ 1
77 ]AC_INCLUDES_DEFAULT])],
90 # define __EXTENSIONS__ 1
91 ]AC_INCLUDES_DEFAULT])],
7892 [ac_cv_safe_to_define___extensions__=yes],
7993 [ac_cv_safe_to_define___extensions__=no])])
8094 test $ac_cv_safe_to_define___extensions__ = yes &&
0 # fchdir.m4 serial 13
1 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_FUNC_FCHDIR],
7 [
8 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
9 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
10 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
11 AC_CHECK_FUNCS_ONCE([fchdir])
12 if test $ac_cv_func_fchdir = no; then
13 REPLACE_FCHDIR=1
14 AC_LIBOBJ([fchdir])
15 gl_PREREQ_FCHDIR
16 AC_DEFINE([REPLACE_FCHDIR], [1],
17 [Define to 1 if gnulib's fchdir() replacement is used.])
18 dnl We must also replace anything that can manipulate a directory fd,
19 dnl to keep our bookkeeping up-to-date. We don't have to replace
20 dnl fstatat, since no platform has fstatat but lacks fchdir.
21 REPLACE_OPENDIR=1
22 REPLACE_CLOSEDIR=1
23 REPLACE_DUP=1
24 gl_REPLACE_OPEN
25 gl_REPLACE_CLOSE
26 gl_REPLACE_DUP2
27 dnl dup3 is already unconditionally replaced
28 gl_REPLACE_FCNTL
29 gl_REPLACE_DIRENT_H
30 AC_CACHE_CHECK([whether open can visit directories],
31 [gl_cv_func_open_directory_works],
32 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>
33 ]], [return open(".", O_RDONLY) < 0;])],
34 [gl_cv_func_open_directory_works=yes],
35 [gl_cv_func_open_directory_works=no],
36 [gl_cv_func_open_directory_works="guessing no"])])
37 if test "$gl_cv_func_open_directory_works" != yes; then
38 AC_DEFINE([REPLACE_OPEN_DIRECTORY], [1], [Define to 1 if open() should
39 work around the inability to open a directory.])
40 REPLACE_FSTAT=1
41 fi
42 fi
43 ])
44
45 # Prerequisites of lib/fchdir.c.
46 AC_DEFUN([gl_PREREQ_FCHDIR], [:])
00 # fclose.m4 serial 2
1 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # fcntl-o.m4 serial 1
1 dnl Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl Written by Paul Eggert.
7
8 # Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
9 # Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
10 # Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
11 AC_DEFUN([gl_FCNTL_O_FLAGS],
12 [
13 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
14 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
15 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
16 [AC_RUN_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[#include <sys/types.h>
19 #include <sys/stat.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #ifndef O_NOATIME
23 #define O_NOATIME 0
24 #endif
25 #ifndef O_NOFOLLOW
26 #define O_NOFOLLOW 0
27 #endif
28 static int const constants[] =
29 {
30 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
31 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
32 };
33 ]],
34 [[
35 int status = !constants;
36 {
37 static char const sym[] = "conftest.sym";
38 if (symlink (".", sym) != 0
39 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
40 status |= 32;
41 unlink (sym);
42 }
43 {
44 static char const file[] = "confdefs.h";
45 int fd = open (file, O_RDONLY | O_NOATIME);
46 char c;
47 struct stat st0, st1;
48 if (fd < 0
49 || fstat (fd, &st0) != 0
50 || sleep (1) != 0
51 || read (fd, &c, 1) != 1
52 || close (fd) != 0
53 || stat (file, &st1) != 0
54 || st0.st_atime != st1.st_atime)
55 status |= 64;
56 }
57 return status;]])],
58 [gl_cv_header_working_fcntl_h=yes],
59 [case $? in #(
60 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
61 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
62 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
63 *) gl_cv_header_working_fcntl_h='no';;
64 esac],
65 [gl_cv_header_working_fcntl_h=cross-compiling])])
66
67 case $gl_cv_header_working_fcntl_h in #(
68 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
69 *) ac_val=1;;
70 esac
71 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
72 [Define to 1 if O_NOATIME works.])
73
74 case $gl_cv_header_working_fcntl_h in #(
75 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
76 *) ac_val=1;;
77 esac
78 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
79 [Define to 1 if O_NOFOLLOW works.])
80 ])
00 #serial 7
1 dnl Copyright (C) 2005-2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # fcntl.m4 serial 3
1 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 # For now, this module ensures that fcntl()
7 # - supports F_DUPFD correctly
8 # - supports or emulates F_DUPFD_CLOEXEC
9 # - supports F_GETFD
10 # Still to be ported to mingw:
11 # - F_SETFD
12 # - F_GETFL, F_SETFL
13 # - F_GETOWN, F_SETOWN
14 # - F_GETLK, F_SETLK, F_SETLKW
15 AC_DEFUN([gl_FUNC_FCNTL],
16 [
17 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
18 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
19 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
20 AC_REQUIRE([AC_CANONICAL_HOST])
21 AC_CHECK_FUNCS_ONCE([fcntl])
22 if test $ac_cv_func_fcntl = no; then
23 gl_REPLACE_FCNTL
24 else
25 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
26 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
27 [gl_cv_func_fcntl_f_dupfd_works],
28 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
29 #include <fcntl.h>
30 ]], [[return fcntl (0, F_DUPFD, -1) != -1;
31 ]])],
32 [gl_cv_func_fcntl_f_dupfd_works=yes],
33 [gl_cv_func_fcntl_f_dupfd_works=no],
34 [# Guess that it works on glibc systems
35 case $host_os in #((
36 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
37 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
38 esac])])
39 case $gl_cv_func_fcntl_f_dupfd_works in
40 *yes) ;;
41 *) gl_REPLACE_FCNTL
42 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
43 behavior does not match POSIX]) ;;
44 esac
45
46 dnl Many systems lack F_DUPFD_CLOEXEC
47 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
48 [gl_cv_func_fcntl_f_dupfd_cloexec],
49 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
50 #include <fcntl.h>
51 #ifndef F_DUPFD_CLOEXEC
52 choke me
53 #endif
54 ]])],
55 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
56 #ifdef __linux__
57 /* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
58 it to support the semantics on older kernels that failed with EINVAL. */
59 choke me
60 #endif
61 ]])],
62 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
63 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
64 [gl_cv_func_fcntl_f_dupfd_cloexec=no])])
65 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
66 gl_REPLACE_FCNTL
67 dnl No witness macro needed for this bug.
68 fi
69 fi
70 ])
71
72 AC_DEFUN([gl_REPLACE_FCNTL],
73 [
74 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
75 AC_CHECK_FUNCS_ONCE([fcntl])
76 if test $ac_cv_func_fcntl = no; then
77 HAVE_FCNTL=0
78 else
79 REPLACE_FCNTL=1
80 fi
81 AC_LIBOBJ([fcntl])
82 ])
0 # serial 6
0 # serial 9
11 # Configure fcntl.h.
2 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
2 dnl Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
33 dnl This file is free software; the Free Software Foundation
44 dnl gives unlimited permission to copy and/or distribute it,
55 dnl with or without modifications, as long as this notice is preserved.
1111 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
1212 AC_REQUIRE([gl_FCNTL_O_FLAGS])
1313 gl_CHECK_NEXT_HEADERS([fcntl.h])
14 FCNTL_H='fcntl.h'
15 AC_SUBST([FCNTL_H])
16 ])
17
18 # Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
19 # Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
20 # Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
21 AC_DEFUN([gl_FCNTL_O_FLAGS],
22 [
23 dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
24 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
25 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
26 [AC_RUN_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <sys/types.h>
29 #include <sys/stat.h>
30 #include <unistd.h>
31 #include <fcntl.h>
32 #ifndef O_NOATIME
33 #define O_NOATIME 0
34 #endif
35 #ifndef O_NOFOLLOW
36 #define O_NOFOLLOW 0
37 #endif
38 static int const constants[] =
39 {
40 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
41 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
42 };
43 ]],
44 [[
45 int status = !constants;
46 {
47 static char const sym[] = "conftest.sym";
48 if (symlink (".", sym) != 0
49 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
50 status |= 32;
51 unlink (sym);
52 }
53 {
54 static char const file[] = "confdefs.h";
55 int fd = open (file, O_RDONLY | O_NOATIME);
56 char c;
57 struct stat st0, st1;
58 if (fd < 0
59 || fstat (fd, &st0) != 0
60 || sleep (1) != 0
61 || read (fd, &c, 1) != 1
62 || close (fd) != 0
63 || stat (file, &st1) != 0
64 || st0.st_atime != st1.st_atime)
65 status |= 64;
66 }
67 return status;]])],
68 [gl_cv_header_working_fcntl_h=yes],
69 [case $? in #(
70 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
71 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
72 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
73 *) gl_cv_header_working_fcntl_h='no';;
74 esac],
75 [gl_cv_header_working_fcntl_h=cross-compiling])])
76
77 case $gl_cv_header_working_fcntl_h in #(
78 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
79 *) ac_val=1;;
80 esac
81 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
82 [Define to 1 if O_NOATIME works.])
83
84 case $gl_cv_header_working_fcntl_h in #(
85 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
86 *) ac_val=1;;
87 esac
88 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
89 [Define to 1 if O_NOFOLLOW works.])
9014 ])
9115
9216 AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
9822
9923 AC_DEFUN([gl_FCNTL_H_DEFAULTS],
10024 [
25 GNULIB_FCNTL=0; AC_SUBST([GNULIB_FCNTL])
10126 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
10227 GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
10328 dnl Assume proper GNU behavior unless another module says otherwise.
29 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
10430 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
31 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
10532 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
10633 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
10734 ])
0 # serial 3
1 # See if we need to provide fdopendir.
2
3 dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 # Written by Eric Blake.
9
10 AC_DEFUN([gl_FUNC_FDOPENDIR],
11 [
12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13 AC_CHECK_FUNCS_ONCE([fdopendir])
14 if test $ac_cv_func_fdopendir = no; then
15 AC_LIBOBJ([openat-proc])
16 AC_LIBOBJ([fdopendir])
17 gl_REPLACE_DIRENT_H
18 HAVE_FDOPENDIR=0
19 else
20 AC_CACHE_CHECK([whether fdopendir works],
21 [gl_cv_func_fdopendir_works],
22 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
23 #include <dirent.h>
24 #include <fcntl.h>
25 ]], [int fd = open ("conftest.c", O_RDONLY);
26 if (fd < 0) return 2;
27 return !!fdopendir (fd);])],
28 [gl_cv_func_fdopendir_works=yes],
29 [gl_cv_func_fdopendir_works=no],
30 [gl_cv_func_fdopendir_works="guessing no"])])
31 if test "$gl_cv_func_fdopendir_works" != yes; then
32 REPLACE_FDOPENDIR=1
33 gl_REPLACE_DIRENT_H
34 AC_LIBOBJ([fdopendir])
35 fi
36 fi
37 ])
00 # fflush.m4 serial 7
11
2 # Copyright (C) 2007-2009 Free Software Foundation, Inc.
2 # Copyright (C) 2007-2010 Free Software Foundation, Inc.
33 # This file is free software; the Free Software Foundation
44 # gives unlimited permission to copy and/or distribute it,
55 # with or without modifications, as long as this notice is preserved.
1919 #include <stdio.h>
2020 #include <unistd.h>
2121 ]], [[FILE *f = fopen ("conftest.txt", "r");
22 char buffer[10];
23 int fd;
24 int c;
25 if (f == NULL)
26 return 1;
27 fd = fileno (f);
28 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
29 return 2;
30 /* For deterministic results, ensure f read a bigger buffer. */
31 if (lseek (fd, 0, SEEK_CUR) == 5)
32 return 3;
33 /* POSIX requires fflush-fseek to set file offset of fd. This fails
34 on BSD systems and on mingw. */
35 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
36 return 4;
37 if (lseek (fd, 0, SEEK_CUR) != 5)
38 return 5;
39 /* Verify behaviour of fflush after ungetc. See
40 <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
41 /* Verify behaviour of fflush after a backup ungetc. This fails on
42 mingw. */
43 c = fgetc (f);
44 ungetc (c, f);
45 fflush (f);
46 if (fgetc (f) != c)
47 return 6;
48 /* Verify behaviour of fflush after a non-backup ungetc. This fails
49 on glibc 2.8 and on BSD systems. */
50 c = fgetc (f);
51 ungetc ('@', f);
52 fflush (f);
53 if (fgetc (f) != c)
54 return 7;
55 return 0;
22 char buffer[10];
23 int fd;
24 int c;
25 if (f == NULL)
26 return 1;
27 fd = fileno (f);
28 if (fd < 0 || fread (buffer, 1, 5, f) != 5)
29 return 2;
30 /* For deterministic results, ensure f read a bigger buffer. */
31 if (lseek (fd, 0, SEEK_CUR) == 5)
32 return 3;
33 /* POSIX requires fflush-fseek to set file offset of fd. This fails
34 on BSD systems and on mingw. */
35 if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
36 return 4;
37 if (lseek (fd, 0, SEEK_CUR) != 5)
38 return 5;
39 /* Verify behaviour of fflush after ungetc. See
40 <http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
41 /* Verify behaviour of fflush after a backup ungetc. This fails on
42 mingw. */
43 c = fgetc (f);
44 ungetc (c, f);
45 fflush (f);
46 if (fgetc (f) != c)
47 return 6;
48 /* Verify behaviour of fflush after a non-backup ungetc. This fails
49 on glibc 2.8 and on BSD systems. */
50 c = fgetc (f);
51 ungetc ('@', f);
52 fflush (f);
53 if (fgetc (f) != c)
54 return 7;
55 return 0;
5656 ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
5757 [dnl Pessimistically assume fflush is broken.
5858 gl_cv_func_fflush_stdin=no])
00 # float_h.m4 serial 3
1 dnl Copyright (C) 2007 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # serial 15
11
2 # Copyright (C) 2000-2001, 2004-2009 Free Software Foundation, Inc.
2 # Copyright (C) 2000-2001, 2004-2010 Free Software Foundation, Inc.
33 # This file is free software; the Free Software Foundation
44 # gives unlimited permission to copy and/or distribute it,
55 # with or without modifications, as long as this notice is preserved.
2525 AC_CHECK_DECLS([__fpending], , , $fp_headers)
2626 if test $ac_cv_func___fpending = no; then
2727 AC_CACHE_CHECK(
28 [how to determine the number of pending output bytes on a stream],
29 ac_cv_sys_pending_output_n_bytes,
28 [how to determine the number of pending output bytes on a stream],
29 ac_cv_sys_pending_output_n_bytes,
3030 [
31 for ac_expr in \
32 \
33 '# glibc2' \
34 'fp->_IO_write_ptr - fp->_IO_write_base' \
35 \
36 '# traditional Unix' \
37 'fp->_ptr - fp->_base' \
38 \
39 '# BSD' \
40 'fp->_p - fp->_bf._base' \
41 \
42 '# SCO, Unixware' \
43 '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \
44 \
45 '# QNX' \
46 '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
47 \
48 '# old glibc?' \
49 'fp->__bufp - fp->__buffer' \
50 \
51 '# old glibc iostream?' \
52 'fp->_pptr - fp->_pbase' \
53 \
54 '# emx+gcc' \
55 'fp->_ptr - fp->_buffer' \
56 \
57 '# VMS' \
58 '(*fp)->_ptr - (*fp)->_base' \
59 \
60 '# e.g., DGUX R4.11; the info is not available' \
61 1 \
62 ; do
31 for ac_expr in \
32 \
33 '# glibc2' \
34 'fp->_IO_write_ptr - fp->_IO_write_base' \
35 \
36 '# traditional Unix' \
37 'fp->_ptr - fp->_base' \
38 \
39 '# BSD' \
40 'fp->_p - fp->_bf._base' \
41 \
42 '# SCO, Unixware' \
43 '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \
44 \
45 '# QNX' \
46 '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
47 \
48 '# old glibc?' \
49 'fp->__bufp - fp->__buffer' \
50 \
51 '# old glibc iostream?' \
52 'fp->_pptr - fp->_pbase' \
53 \
54 '# emx+gcc' \
55 'fp->_ptr - fp->_buffer' \
56 \
57 '# VMS' \
58 '(*fp)->_ptr - (*fp)->_base' \
59 \
60 '# e.g., DGUX R4.11; the info is not available' \
61 1 \
62 ; do
6363
64 # Skip each embedded comment.
65 case "$ac_expr" in '#'*) continue;; esac
64 # Skip each embedded comment.
65 case "$ac_expr" in '#'*) continue;; esac
6666
67 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
68 [[FILE *fp = stdin; (void) ($ac_expr);]])],
69 [fp_done=yes]
70 )
71 test "$fp_done" = yes && break
72 done
67 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
68 [[FILE *fp = stdin; (void) ($ac_expr);]])],
69 [fp_done=yes]
70 )
71 test "$fp_done" = yes && break
72 done
7373
74 ac_cv_sys_pending_output_n_bytes=$ac_expr
74 ac_cv_sys_pending_output_n_bytes=$ac_expr
7575 ]
7676 )
7777 AC_DEFINE_UNQUOTED([PENDING_OUTPUT_N_BYTES],
00 # fpieee.m4 serial 1
1 dnl Copyright (C) 2007 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # fprintf-posix.m4 serial 14
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # fpurge.m4 serial 6
1 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1414 AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
1515 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
1616 ]], [FILE *f = fopen ("conftest.txt", "w+");
17 if (!f) return 1;
18 if (fputc ('a', f) != 'a') return 2;
19 rewind (f);
20 if (fgetc (f) != 'a') return 3;
21 if (fgetc (f) != EOF) return 4;
22 if (fpurge (f) != 0) return 5;
23 if (putc ('b', f) != 'b') return 6;
24 if (fclose (f) != 0) return 7;
25 if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
26 if (fgetc (f) != 'a') return 9;
27 if (fgetc (f) != 'b') return 10;
28 if (fgetc (f) != EOF) return 11;
29 if (fclose (f) != 0) return 12;
30 if (remove ("conftest.txt") != 0) return 13;
31 return 0;])],
17 if (!f) return 1;
18 if (fputc ('a', f) != 'a') return 2;
19 rewind (f);
20 if (fgetc (f) != 'a') return 3;
21 if (fgetc (f) != EOF) return 4;
22 if (fpurge (f) != 0) return 5;
23 if (putc ('b', f) != 'b') return 6;
24 if (fclose (f) != 0) return 7;
25 if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
26 if (fgetc (f) != 'a') return 9;
27 if (fgetc (f) != 'b') return 10;
28 if (fgetc (f) != EOF) return 11;
29 if (fclose (f) != 0) return 12;
30 if (remove ("conftest.txt") != 0) return 13;
31 return 0;])],
3232 [gl_cv_func_fpurge_works=yes], [gl_cv_func_fpurge_works=no],
3333 [gl_cv_func_fpurge_works='guessing no'])])
3434 if test "x$gl_cv_func_fpurge_works" != xyes; then
00 # freading.m4 serial 1
1 dnl Copyright (C) 2007 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # frexp.m4 serial 7
1 dnl Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # frexpl.m4 serial 9
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # fseeko.m4 serial 5
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
0 # fseeko.m4 serial 7
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1414
1515 AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
1616 [
17 AC_TRY_LINK([[#include <stdio.h>]], [fseeko (stdin, 0, 0);],
18 [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
17 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
18 ]], [fseeko (stdin, 0, 0);])],
19 [gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
1920 ])
20 if test $gl_cv_func_fseeko = no; then
21 HAVE_FSEEKO=0
22 gl_REPLACE_FSEEKO
23 elif test $gl_cv_var_stdin_large_offset = no; then
21 if test $gl_cv_func_fseeko = no \
22 || test $gl_cv_var_stdin_large_offset = no; then
2423 gl_REPLACE_FSEEKO
2524 fi
2625 ])
0 # ftello.m4 serial 4
1 dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
0 # ftello.m4 serial 5
1 dnl Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1515 AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello],
1616 [
1717 AC_TRY_LINK([#include <stdio.h>], [ftello (stdin);],
18 [gl_cv_func_ftello=yes], [gl_cv_func_ftello=no])
18 [gl_cv_func_ftello=yes], [gl_cv_func_ftello=no])
1919 ])
20 if test $gl_cv_func_ftello = no; then
21 HAVE_FTELLO=0
22 gl_REPLACE_FTELLO
23 elif test $gl_cv_var_stdin_large_offset = no; then
20 if test $gl_cv_func_ftello = no \
21 || test $gl_cv_var_stdin_large_offset = no; then
2422 gl_REPLACE_FTELLO
2523 fi
2624 ])
0 # serial 2
1 # Determine whether getcwd aborts when the length of the working directory
2 # name is unusually large. Any length between 4k and 16k trigger the bug
3 # when using glibc-2.4.90-9 or older.
4
5 # Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
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
10 # From Jim Meyering
11
12 # gl_FUNC_GETCWD_ABORT_BUG([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
13 AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG],
14 [
15 AC_CHECK_DECLS_ONCE([getcwd])
16 AC_CHECK_FUNCS([getpagesize])
17 AC_CACHE_CHECK([whether getcwd aborts when 4k < cwd_length < 16k],
18 gl_cv_func_getcwd_abort_bug,
19 [# Remove any remnants of a previous test.
20 rm -rf confdir-14B---
21 # Arrange for deletion of the temporary directory this test creates.
22 ac_clean_files="$ac_clean_files confdir-14B---"
23 AC_RUN_IFELSE(
24 [AC_LANG_SOURCE(
25 [[
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <limits.h>
29 #include <string.h>
30 #include <sys/stat.h>
31
32 /* Don't get link errors because mkdir is redefined to rpl_mkdir. */
33 #undef mkdir
34
35 #ifndef S_IRWXU
36 # define S_IRWXU 0700
37 #endif
38
39 /* FIXME: skip the run-test altogether on systems without getpagesize. */
40 #if ! HAVE_GETPAGESIZE
41 # define getpagesize() 0
42 #endif
43
44 /* This size is chosen to be larger than PATH_MAX (4k), yet smaller than
45 the 16kB pagesize on ia64 linux. Those conditions make the code below
46 trigger a bug in glibc's getcwd implementation before 2.4.90-10. */
47 #define TARGET_LEN (5 * 1024)
48
49 int
50 main ()
51 {
52 char const *dir_name = "confdir-14B---";
53 char *cwd;
54 size_t initial_cwd_len;
55 int fail = 0;
56 size_t desired_depth;
57 size_t d;
58
59 /* The bug is triggered when PATH_MAX < getpagesize (), so skip
60 this relative expensive and invasive test if that's not true. */
61 if (getpagesize () <= PATH_MAX)
62 return 0;
63
64 cwd = getcwd (NULL, 0);
65 if (cwd == NULL)
66 return 0;
67
68 initial_cwd_len = strlen (cwd);
69 free (cwd);
70 desired_depth = ((TARGET_LEN - 1 - initial_cwd_len)
71 / (1 + strlen (dir_name)));
72 for (d = 0; d < desired_depth; d++)
73 {
74 if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
75 {
76 fail = 3; /* Unable to construct deep hierarchy. */
77 break;
78 }
79 }
80
81 /* If libc has the bug in question, this invocation of getcwd
82 results in a failed assertion. */
83 cwd = getcwd (NULL, 0);
84 if (cwd == NULL)
85 fail = 4; /* getcwd failed. This is ok, and expected. */
86 free (cwd);
87
88 /* Call rmdir first, in case the above chdir failed. */
89 rmdir (dir_name);
90 while (0 < d--)
91 {
92 if (chdir ("..") < 0)
93 break;
94 rmdir (dir_name);
95 }
96
97 return 0;
98 }
99 ]])],
100 [gl_cv_func_getcwd_abort_bug=no],
101 [gl_cv_func_getcwd_abort_bug=yes],
102 [gl_cv_func_getcwd_abort_bug=yes])
103 ])
104 AS_IF([test $gl_cv_func_getcwd_abort_bug = yes], [$1], [$2])
105 ])
0 # serial 14
1 # Check for several getcwd bugs with long file names.
2 # If so, arrange to compile the wrapper function.
3
4 # This is necessary for at least GNU libc on linux-2.4.19 and 2.4.20.
5 # I've heard that this is due to a Linux kernel bug, and that it has
6 # been fixed between 2.4.21-pre3 and 2.4.21-pre4. */
7
8 # Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc.
9 # This file is free software; the Free Software Foundation
10 # gives unlimited permission to copy and/or distribute it,
11 # with or without modifications, as long as this notice is preserved.
12
13 # From Jim Meyering
14
15 AC_DEFUN([gl_FUNC_GETCWD_PATH_MAX],
16 [
17 AC_CHECK_DECLS_ONCE([getcwd])
18 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
19 AC_CACHE_CHECK([whether getcwd handles long file names properly],
20 gl_cv_func_getcwd_path_max,
21 [# Arrange for deletion of the temporary directory this test creates.
22 ac_clean_files="$ac_clean_files confdir3"
23 AC_RUN_IFELSE(
24 [AC_LANG_SOURCE(
25 [[
26 #include <errno.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <string.h>
30 #include <limits.h>
31 #include <sys/stat.h>
32 #include <sys/types.h>
33 #include <fcntl.h>
34
35 #ifndef AT_FDCWD
36 # define AT_FDCWD 0
37 #endif
38 #ifdef ENAMETOOLONG
39 # define is_ENAMETOOLONG(x) ((x) == ENAMETOOLONG)
40 #else
41 # define is_ENAMETOOLONG(x) 0
42 #endif
43
44 /* Don't get link errors because mkdir is redefined to rpl_mkdir. */
45 #undef mkdir
46
47 #ifndef S_IRWXU
48 # define S_IRWXU 0700
49 #endif
50
51 /* The length of this name must be 8. */
52 #define DIR_NAME "confdir3"
53 #define DIR_NAME_LEN 8
54 #define DIR_NAME_SIZE (DIR_NAME_LEN + 1)
55
56 /* The length of "../". */
57 #define DOTDOTSLASH_LEN 3
58
59 /* Leftover bytes in the buffer, to work around library or OS bugs. */
60 #define BUF_SLOP 20
61
62 int
63 main ()
64 {
65 #ifndef PATH_MAX
66 /* The Hurd doesn't define this, so getcwd can't exhibit the bug --
67 at least not on a local file system. And if we were to start worrying
68 about remote file systems, we'd have to enable the wrapper function
69 all of the time, just to be safe. That's not worth the cost. */
70 exit (0);
71 #elif ((INT_MAX / (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1) \
72 - DIR_NAME_SIZE - BUF_SLOP) \
73 <= PATH_MAX)
74 /* FIXME: Assuming there's a system for which this is true,
75 this should be done in a compile test. */
76 exit (0);
77 #else
78 char buf[PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN + 1)
79 + DIR_NAME_SIZE + BUF_SLOP];
80 char *cwd = getcwd (buf, PATH_MAX);
81 size_t initial_cwd_len;
82 size_t cwd_len;
83 int fail = 0;
84 size_t n_chdirs = 0;
85
86 if (cwd == NULL)
87 exit (1);
88
89 cwd_len = initial_cwd_len = strlen (cwd);
90
91 while (1)
92 {
93 size_t dotdot_max = PATH_MAX * (DIR_NAME_SIZE / DOTDOTSLASH_LEN);
94 char *c = NULL;
95
96 cwd_len += DIR_NAME_SIZE;
97 /* If mkdir or chdir fails, it could be that this system cannot create
98 any file with an absolute name longer than PATH_MAX, such as cygwin.
99 If so, leave fail as 0, because the current working directory can't
100 be too long for getcwd if it can't even be created. For other
101 errors, be pessimistic and consider that as a failure, too. */
102 if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0)
103 {
104 if (! (errno == ERANGE || is_ENAMETOOLONG (errno)))
105 fail = 2;
106 break;
107 }
108
109 if (PATH_MAX <= cwd_len && cwd_len < PATH_MAX + DIR_NAME_SIZE)
110 {
111 c = getcwd (buf, PATH_MAX);
112 if (!c && errno == ENOENT)
113 {
114 fail = 1;
115 break;
116 }
117 if (c || ! (errno == ERANGE || is_ENAMETOOLONG (errno)))
118 {
119 fail = 2;
120 break;
121 }
122 }
123
124 if (dotdot_max <= cwd_len - initial_cwd_len)
125 {
126 if (dotdot_max + DIR_NAME_SIZE < cwd_len - initial_cwd_len)
127 break;
128 c = getcwd (buf, cwd_len + 1);
129 if (!c)
130 {
131 if (! (errno == ERANGE || errno == ENOENT
132 || is_ENAMETOOLONG (errno)))
133 {
134 fail = 2;
135 break;
136 }
137 if (AT_FDCWD || errno == ERANGE || errno == ENOENT)
138 {
139 fail = 1;
140 break;
141 }
142 }
143 }
144
145 if (c && strlen (c) != cwd_len)
146 {
147 fail = 2;
148 break;
149 }
150 ++n_chdirs;
151 }
152
153 /* Leaving behind such a deep directory is not polite.
154 So clean up here, right away, even though the driving
155 shell script would also clean up. */
156 {
157 size_t i;
158
159 /* Try rmdir first, in case the chdir failed. */
160 rmdir (DIR_NAME);
161 for (i = 0; i <= n_chdirs; i++)
162 {
163 if (chdir ("..") < 0)
164 break;
165 if (rmdir (DIR_NAME) != 0)
166 break;
167 }
168 }
169
170 exit (fail);
171 #endif
172 }
173 ]])],
174 [gl_cv_func_getcwd_path_max=yes],
175 [case $? in
176 1) gl_cv_func_getcwd_path_max='no, but it is partly working';;
177 *) gl_cv_func_getcwd_path_max=no;;
178 esac],
179 [gl_cv_func_getcwd_path_max=no])
180 ])
181 case $gl_cv_func_getcwd_path_max in
182 no,*)
183 AC_DEFINE([HAVE_PARTLY_WORKING_GETCWD], [1],
184 [Define to 1 if getcwd works, except it sometimes fails when it shouldn't,
185 setting errno to ERANGE, ENAMETOOLONG, or ENOENT. If __GETCWD_PREFIX
186 is not defined, it doesn't matter whether HAVE_PARTLY_WORKING_GETCWD
187 is defined.]);;
188 esac
189 ])
0 # getcwd.m4 - check for working getcwd that is compatible with glibc
1
2 # Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software
3 # 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 Paul Eggert.
9 # serial 2
10
11 AC_DEFUN([gl_FUNC_GETCWD_NULL],
12 [
13 AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
14 [gl_cv_func_getcwd_null],
15 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
16 # include <unistd.h>
17 # ifndef getcwd
18 char *getcwd ();
19 # endif
20 ]], [[
21 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
22 /* mingw cwd does not start with '/', but getcwd does allocate. */
23 #else
24 if (chdir ("/") != 0)
25 return 1;
26 else
27 {
28 char *f = getcwd (NULL, 0);
29 return ! (f && f[0] == '/' && !f[1]);
30 }
31 #endif
32 ]])],
33 [gl_cv_func_getcwd_null=yes],
34 [gl_cv_func_getcwd_null=no],
35 [[
36 case "$host_os" in
37 # Guess yes on glibc systems.
38 *-gnu*) gl_cv_func_getcwd_null="guessing yes";;
39 # Guess yes on Cygwin.
40 cygwin*) gl_cv_func_getcwd_null="guessing yes";;
41 # Guess yes on mingw.
42 mingw*) gl_cv_func_getcwd_null="guessing yes";;
43 # If we don't know, assume the worst.
44 *) gl_cv_func_getcwd_null="guessing no";;
45 esac
46 ]])])
47 ])
48
49 AC_DEFUN([gl_FUNC_GETCWD],
50 [
51 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
52 AC_REQUIRE([gl_FUNC_GETCWD_NULL])
53 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
54
55 gl_abort_bug=no
56 case $gl_cv_func_getcwd_null,$host_os in
57 *,mingw*)
58 gl_cv_func_getcwd_path_max=yes;;
59 yes,*)
60 gl_FUNC_GETCWD_PATH_MAX
61 gl_FUNC_GETCWD_ABORT_BUG([gl_abort_bug=yes]);;
62 esac
63
64 case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max,$gl_abort_bug in
65 *yes,yes,no) ;;
66 *)
67 REPLACE_GETCWD=1
68 AC_LIBOBJ([getcwd])
69 gl_PREREQ_GETCWD;;
70 esac
71 ])
72
73 # Prerequisites of lib/getcwd.c.
74 AC_DEFUN([gl_PREREQ_GETCWD],
75 [
76 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
77 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
78 :
79 ])
0 # getopt.m4 serial 23
1 dnl Copyright (C) 2002-2006, 2008-2009 Free Software Foundation, Inc.
0 # getopt.m4 serial 24
1 dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
7474 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
7575 fi
7676
77 dnl BSD getopt_long uses an incompatible method to reset option processing,
78 dnl but the testsuite does not show a need to use this 'optreset' variable.
79 if false && test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
80 AC_CHECK_DECL([optreset], [gl_replace_getopt=yes], [],
81 [#include <getopt.h>])
77 dnl BSD getopt_long uses an incompatible method to reset option processing.
78 dnl Existence of the variable, in and of itself, is not a reason to replace
79 dnl getopt, but knowledge of the variable is needed to determine how to
80 dnl reset and whether a reset reparses the environment.
81 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
82 AC_CHECK_DECLS([optreset], [], [],
83 [[#include <getopt.h>]])
8284 fi
8385
8486 dnl mingw's getopt (in libmingwex.a) does weird things when the options
8587 dnl strings starts with '+' and it's not the first call. Some internal state
8688 dnl is left over from earlier calls, and neither setting optind = 0 nor
8789 dnl setting optreset = 1 get rid of this internal state.
90 dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
8891 if test -z "$gl_replace_getopt"; then
8992 AC_CACHE_CHECK([whether getopt is POSIX compatible],
9093 [gl_cv_func_getopt_posix],
9598 #include <stdlib.h>
9699 #include <string.h>
97100
98 /* The glibc implementation of getopt supports setting optind = 0 as a means
99 of clearing the internal state, but other implementations don't. */
100 #if (__GLIBC__ >= 2)
101 #if !HAVE_DECL_OPTRESET
101102 # define OPTIND_MIN 0
102103 #else
103104 # define OPTIND_MIN 1
115116 argv[argc++] = "-a";
116117 argv[argc++] = "foo";
117118 argv[argc++] = "bar";
119 argv[argc] = NULL;
118120 optind = OPTIND_MIN;
119121 opterr = 0;
120122
140142 argv[argc++] = "duck";
141143 argv[argc++] = "-a";
142144 argv[argc++] = "bar";
145 argv[argc] = NULL;
143146 optind = OPTIND_MIN;
144147 opterr = 0;
145148
181184
182185 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
183186 AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu],
184 [AC_RUN_IFELSE(
185 [AC_LANG_PROGRAM([[#include <getopt.h>
186 #include <stddef.h>
187 #include <string.h>]],
188 [[
187 [# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
188 # optstring is necessary for programs like m4 that have POSIX-mandated
189 # semantics for supporting options interspersed with files.
190 # Also, since getopt_long is a GNU extension, we require optind=0.
191 gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes}
192 POSIXLY_CORRECT=1
193 export POSIXLY_CORRECT
194 AC_RUN_IFELSE(
195 [AC_LANG_PROGRAM([[#include <getopt.h>
196 #include <stddef.h>
197 #include <string.h>
198 ]], [[
189199 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
190200 and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
191201 OSF/1 5.1, Solaris 10. */
200210 }
201211 /* This code succeeds on glibc 2.8, mingw,
202212 and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
203 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin. */
213 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
204214 {
205 char *argv[] = { "program", "-p", "foo", "bar" };
215 char *argv[] = { "program", "-p", "foo", "bar", NULL };
206216
207217 optind = 1;
208218 if (getopt (4, argv, "p::") != 'p')
214224 if (optind != 2)
215225 return 5;
216226 }
227 /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
228 {
229 char *argv[] = { "program", "foo", "-p", NULL };
230 optind = 0;
231 if (getopt (3, argv, "-p") != 1)
232 return 6;
233 if (getopt (3, argv, "-p") != 'p')
234 return 7;
235 }
217236 return 0;
218 ]])],
219 [gl_cv_func_getopt_gnu=yes],
220 [gl_cv_func_getopt_gnu=no],
221 [dnl Cross compiling. Guess based on host and declarations.
222 case "$host_os" in
223 *-gnu* | mingw*) gl_cv_func_getopt_gnu=no;;
224 *) gl_cv_func_getopt_gnu=yes;;
237 ]])],
238 [gl_cv_func_getopt_gnu=yes],
239 [gl_cv_func_getopt_gnu=no],
240 [dnl Cross compiling. Guess based on host and declarations.
241 case $host_os:$ac_cv_have_decl_optreset in
242 *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
243 *:yes) gl_cv_func_getopt_gnu=no;;
244 *) gl_cv_func_getopt_gnu=yes;;
225245 esac
226246 ])
247 if test "$gl_had_POSIXLY_CORRECT" != yes; then
248 AS_UNSET([POSIXLY_CORRECT])
249 fi
227250 ])
228251 if test "$gl_cv_func_getopt_gnu" = "no"; then
229252 gl_replace_getopt=yes
+0
-29
m4/getpagesize.m4 less more
0 # getpagesize.m4 serial 7
1 dnl Copyright (C) 2002, 2004-2005, 2007 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_FUNC_GETPAGESIZE],
7 [
8 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 AC_CHECK_FUNCS([getpagesize])
11 if test $ac_cv_func_getpagesize = no; then
12 HAVE_GETPAGESIZE=0
13 AC_CHECK_HEADERS([OS.h])
14 if test $ac_cv_header_OS_h = yes; then
15 HAVE_OS_H=1
16 fi
17 AC_CHECK_HEADERS([sys/param.h])
18 if test $ac_cv_header_sys_param_h = yes; then
19 HAVE_SYS_PARAM_H=1
20 fi
21 fi
22 case "$host_os" in
23 mingw*)
24 REPLACE_GETPAGESIZE=1
25 AC_LIBOBJ([getpagesize])
26 ;;
27 esac
28 ])
00 # gettime.m4 serial 7
1 dnl Copyright (C) 2002, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2004-2006, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # serial 12
11
2 # Copyright (C) 2001-2003, 2005, 2007, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2001-2003, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
33 # This file is free software; the Free Software Foundation
44 # gives unlimited permission to copy and/or distribute it,
55 # with or without modifications, as long as this notice is preserved.
1616 [gl_cv_func_gettimeofday_posix_signature],
1717 [AC_COMPILE_IFELSE(
1818 [AC_LANG_PROGRAM(
19 [[#include <sys/time.h>
20 struct timeval c;
21 ]],
22 [[
23 int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
24 int x = f (&c, 0);
25 return !(x | c.tv_sec | c.tv_usec);
26 ]])],
27 [gl_cv_func_gettimeofday_posix_signature=yes],
28 [gl_cv_func_gettimeofday_posix_signature=no])])
19 [[#include <sys/time.h>
20 struct timeval c;
21 ]],
22 [[
23 int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
24 int x = f (&c, 0);
25 return !(x | c.tv_sec | c.tv_usec);
26 ]])],
27 [gl_cv_func_gettimeofday_posix_signature=yes],
28 [gl_cv_func_gettimeofday_posix_signature=no])])
2929
3030 gl_FUNC_GETTIMEOFDAY_CLOBBER
3131
5555 [gl_cv_func_gettimeofday_clobber],
5656 [AC_RUN_IFELSE(
5757 [AC_LANG_PROGRAM(
58 [[#include <string.h>
59 #include <sys/time.h>
60 #include <time.h>
61 #include <stdlib.h>
62 ]],
63 [[
64 time_t t = 0;
65 struct tm *lt;
66 struct tm saved_lt;
67 struct timeval tv;
68 lt = localtime (&t);
69 saved_lt = *lt;
70 gettimeofday (&tv, NULL);
71 return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
72 ]])],
58 [[#include <string.h>
59 #include <sys/time.h>
60 #include <time.h>
61 #include <stdlib.h>
62 ]],
63 [[
64 time_t t = 0;
65 struct tm *lt;
66 struct tm saved_lt;
67 struct timeval tv;
68 lt = localtime (&t);
69 saved_lt = *lt;
70 gettimeofday (&tv, NULL);
71 return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
72 ]])],
7373 [gl_cv_func_gettimeofday_clobber=no],
7474 [gl_cv_func_gettimeofday_clobber=yes],
7575 dnl When crosscompiling, assume it is broken.
00 # glibc21.m4 serial 4
1 dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1111 AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
1212 [ac_cv_gnu_library_2_1],
1313 [AC_EGREP_CPP([Lucky GNU user],
14 [
14 [
1515 #include <features.h>
1616 #ifdef __GNU_LIBRARY__
1717 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
1818 Lucky GNU user
1919 #endif
2020 #endif
21 ],
22 [ac_cv_gnu_library_2_1=yes],
23 [ac_cv_gnu_library_2_1=no])
21 ],
22 [ac_cv_gnu_library_2_1=yes],
23 [ac_cv_gnu_library_2_1=no])
2424 ]
2525 )
2626 AC_SUBST([GLIBC21])
00 # Determine whether recent-enough GNU Make is being used.
11
2 # Copyright (C) 2007 Free Software Foundation, Inc.
2 # Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
33
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
0 # gnulib-common.m4 serial 11
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
0 # gnulib-common.m4 serial 12
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
2222 # define __GNUC_STDC_INLINE__ 1
2323 #endif])
2424 AH_VERBATIM([unused_parameter],
25 [/* Define as a marker that can be attached to function parameter declarations
26 for parameters that are not used. This helps to reduce warnings, such as
27 from GCC -Wunused-parameter. */
25 [/* Define as a marker that can be attached to declarations that might not
26 be used. This helps to reduce warnings, such as from
27 GCC -Wunused-parameter. */
2828 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
29 # define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
29 # define _GL_UNUSED __attribute__ ((__unused__))
3030 #else
31 # define _UNUSED_PARAMETER_
31 # define _GL_UNUSED
3232 #endif
33 /* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
34 is a misnomer outside of parameter lists. */
35 #define _UNUSED_PARAMETER_ _GL_UNUSED
3336 ])
3437 ])
3538
4750 m4_ifndef([m4_foreach_w],
4851 [m4_define([m4_foreach_w],
4952 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
53
54 # AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH])
55 # ----------------------------------------------------
56 # Backport of autoconf-2.63b's macro.
57 # Remove this macro when we can assume autoconf >= 2.64.
58 m4_ifndef([AS_VAR_IF],
59 [m4_define([AS_VAR_IF],
60 [AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
5061
5162 # AC_PROG_MKDIR_P
5263 # is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
6980 for ac_kw in __restrict __restrict__ _Restrict restrict; do
7081 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
7182 [[typedef int * int_ptr;
72 int foo (int_ptr $ac_kw ip) {
73 return ip[0];
83 int foo (int_ptr $ac_kw ip) {
84 return ip[0];
7485 }]],
7586 [[int s[1];
76 int * $ac_kw t = s;
77 t[0] = 0;
78 return foo(t)]])],
87 int * $ac_kw t = s;
88 t[0] = 0;
89 return foo(t)]])],
7990 [ac_cv_c_restrict=$ac_kw])
8091 test "$ac_cv_c_restrict" != no && break
8192 done
00 # -*- buffer-read-only: t -*- vi: set ro:
11 # DO NOT EDIT! GENERATED AUTOMATICALLY!
22 # DO NOT EDIT! GENERATED AUTOMATICALLY!
3 # Copyright (C) 2002-2009 Free Software Foundation, Inc.
3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
44 #
55 # This file is free software, distributed under the terms of the GNU
66 # General Public License. As a special exception to the GNU General
5252 AC_FUNC_CALLOC
5353 gl_FUNC_CALLOC_POSIX
5454 gl_STDLIB_MODULE_INDICATOR([calloc-posix])
55 gl_FUNC_CHDIR_LONG
56 gl_FUNC_CHOWN
57 gl_UNISTD_MODULE_INDICATOR([chown])
5558 gl_CLOCK_TIME
5659 gl_FUNC_CLOSE
5760 gl_UNISTD_MODULE_INDICATOR([close])
5962 gl_MODULE_INDICATOR([close-stream])
6063 gl_CLOSEIN
6164 gl_CLOSEOUT
65 gl_CHECK_TYPE_STRUCT_DIRENT_D_INO
66 gl_DIRENT_H
67 gl_FUNC_DIRFD
68 gl_DIRENT_MODULE_INDICATOR([dirfd])
69 gl_DIRNAME_LGPL
70 gl_DOUBLE_SLASH_ROOT
6271 gl_FUNC_DUP2
6372 gl_UNISTD_MODULE_INDICATOR([dup2])
6473 gl_HEADER_ERRNO_H
6776 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
6877 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
6978 gl_EXITFAIL
79 gl_FUNC_FCHDIR
80 gl_UNISTD_MODULE_INDICATOR([fchdir])
7081 gl_FUNC_FCLOSE
7182 gl_STDIO_MODULE_INDICATOR([fclose])
83 gl_FUNC_FCNTL
84 gl_FCNTL_MODULE_INDICATOR([fcntl])
7285 gl_FCNTL_H
7386 gl_FCNTL_SAFER
7487 gl_MODULE_INDICATOR([fcntl-safer])
88 gl_FUNC_FDOPENDIR
89 gl_DIRENT_MODULE_INDICATOR([fdopendir])
7590 gl_FUNC_FFLUSH
7691 gl_STDIO_MODULE_INDICATOR([fflush])
7792 gl_FLOAT_H
89104 gl_STDIO_MODULE_INDICATOR([fseeko])
90105 gl_FUNC_FTELLO
91106 gl_STDIO_MODULE_INDICATOR([ftello])
107 gl_FUNC_GETCWD
108 gl_UNISTD_MODULE_INDICATOR([getcwd])
92109 gl_FUNC_GETOPT_GNU
93110 gl_MODULE_INDICATOR([getopt-gnu])
94111 gl_FUNC_GETOPT_POSIX
95 gl_FUNC_GETPAGESIZE
96 gl_UNISTD_MODULE_INDICATOR([getpagesize])
97112 AC_SUBST([LIBINTL])
98113 AC_SUBST([LTLIBINTL])
99114 gl_GETTIME
109124 m4_defn([m4_PACKAGE_VERSION])), [1], [],
110125 [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
111126 [GNUmakefile=$GNUmakefile])])
127 AC_REQUIRE([AC_C_INLINE])
112128 gl_INLINE
113129 gl_FUNC_ISNAND_NO_LIBM
114130 gl_FUNC_ISNANF_NO_LIBM
115131 gl_FUNC_ISNANL_NO_LIBM
132 gl_FUNC_LCHOWN
133 gl_UNISTD_MODULE_INDICATOR([lchown])
116134 gl_LOCALCHARSET
117135 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
118136 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
131149 gl_WCHAR_MODULE_INDICATOR([mbsinit])
132150 gl_FUNC_MEMCHR
133151 gl_STRING_MODULE_INDICATOR([memchr])
152 gl_FUNC_MEMPCPY
153 gl_STRING_MODULE_INDICATOR([mempcpy])
154 gl_FUNC_MEMRCHR
155 gl_STRING_MODULE_INDICATOR([memrchr])
156 gl_FUNC_MKDIR
134157 gl_MULTIARCH
135158 gl_FUNC_OPEN
136159 gl_MODULE_INDICATOR([open])
137160 gl_FCNTL_MODULE_INDICATOR([open])
161 gl_FUNC_OPENAT
138162 gl_FUNC_PERROR
139163 gl_STRING_MODULE_INDICATOR([perror])
140164 gl_FUNC_PRINTF_FREXP
147171 AC_DEFINE([GNULIB_REALLOC_GNU], 1, [Define to indicate the 'realloc' module.])
148172 gl_FUNC_REALLOC_POSIX
149173 gl_STDLIB_MODULE_INDICATOR([realloc-posix])
174 gl_FUNC_RMDIR
175 gl_UNISTD_MODULE_INDICATOR([rmdir])
176 gl_SAVE_CWD
150177 gl_SIGNBIT
151178 gl_MATH_MODULE_INDICATOR([signbit])
152179 gl_SIZE_MAX
159186 gl_STDINT_H
160187 gl_STDIO_H
161188 gl_STDLIB_H
189 gl_FUNC_STRDUP_POSIX
190 gl_STRING_MODULE_INDICATOR([strdup])
162191 gl_FUNC_STRERROR
163192 gl_STRING_MODULE_INDICATOR([strerror])
164193 gl_HEADER_STRING_H
170199 gl_TIMESPEC
171200 gl_UNISTD_H
172201 gl_UNISTD_SAFER
173 gl_MODULE_INDICATOR([unistd-safer])
202 gl_FUNC_UNLINK
203 gl_UNISTD_MODULE_INDICATOR([unlink])
174204 gl_UTIMENS
175205 gl_FUNC_VASNPRINTF
176206 gl_FUNC_VFPRINTF_POSIX
177207 gl_STDIO_MODULE_INDICATOR([vfprintf-posix])
208 AC_SUBST([WARN_CFLAGS])
178209 gl_WCHAR_H
179210 gl_WCTYPE_H
180211 gl_XALLOC
212 gl_XGETCWD
181213 gl_XSIZE
182214 gl_YESNO
183215 m4_ifval(gl_LIBSOURCES_LIST, [
202234 if test -n "$gl_LIBOBJS"; then
203235 # Remove the extension.
204236 sed_drop_objext='s/\.o$//;s/\.obj$//'
205 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
237 for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
206238 gl_libobjs="$gl_libobjs $i.$ac_objext"
207239 gl_ltlibobjs="$gl_ltlibobjs $i.lo"
208240 done
241273 if test -n "$gltests_LIBOBJS"; then
242274 # Remove the extension.
243275 sed_drop_objext='s/\.o$//;s/\.obj$//'
244 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
276 for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
245277 gltests_libobjs="$gltests_libobjs $i.$ac_objext"
246278 gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
247279 done
313345 # gnulib-tool and may be removed by future gnulib-tool invocations.
314346 AC_DEFUN([gl_FILE_LIST], [
315347 build-aux/announce-gen
348 build-aux/arg-nonnull.h
316349 build-aux/gendocs.sh
317350 build-aux/git-version-gen
318351 build-aux/gitlog-to-changelog
322355 build-aux/update-copyright
323356 build-aux/useless-if-before-free
324357 build-aux/vc-list-files
358 build-aux/warn-on-use.h
325359 doc/fdl.texi
326360 doc/gendocs_template
327361 lib/alloca.in.h
328362 lib/asnprintf.c
363 lib/at-func.c
364 lib/basename-lgpl.c
329365 lib/calloc.c
366 lib/chdir-long.c
367 lib/chdir-long.h
368 lib/chown.c
330369 lib/close-hook.c
331370 lib/close-hook.h
332371 lib/close-stream.c
338377 lib/closeout.h
339378 lib/config.charset
340379 lib/creat-safer.c
380 lib/dirent.in.h
381 lib/dirfd.c
382 lib/dirname-lgpl.c
383 lib/dirname.h
341384 lib/dup-safer.c
342385 lib/dup2.c
343386 lib/errno.in.h
345388 lib/error.h
346389 lib/exitfail.c
347390 lib/exitfail.h
391 lib/fchdir.c
392 lib/fchmodat.c
393 lib/fchown-stub.c
394 lib/fchownat.c
348395 lib/fclose.c
349396 lib/fcntl--.h
350397 lib/fcntl-safer.h
398 lib/fcntl.c
351399 lib/fcntl.in.h
352400 lib/fd-safer.c
401 lib/fdopendir.c
353402 lib/fflush.c
354403 lib/float+.h
355404 lib/float.in.h
367416 lib/fseeko.c
368417 lib/fseterr.c
369418 lib/fseterr.h
419 lib/fstatat.c
370420 lib/ftello.c
421 lib/getcwd.c
371422 lib/getopt.c
372423 lib/getopt.in.h
373424 lib/getopt1.c
374425 lib/getopt_int.h
375 lib/getpagesize.c
376426 lib/gettext.h
377427 lib/gettime.c
378428 lib/gettimeofday.c
429 lib/ignore-value.h
379430 lib/intprops.h
380431 lib/isnan.c
381432 lib/isnand-nolibm.h
384435 lib/isnanf.c
385436 lib/isnanl-nolibm.h
386437 lib/isnanl.c
438 lib/lchown.c
387439 lib/localcharset.c
388440 lib/localcharset.h
389441 lib/lseek.c
394446 lib/mbsinit.c
395447 lib/memchr.c
396448 lib/memchr.valgrind
449 lib/mempcpy.c
450 lib/memrchr.c
451 lib/mkdir.c
452 lib/mkdirat.c
397453 lib/open-safer.c
398454 lib/open.c
455 lib/openat-die.c
456 lib/openat-priv.h
457 lib/openat-proc.c
458 lib/openat.c
459 lib/openat.h
399460 lib/perror.c
400461 lib/pipe-safer.c
401462 lib/printf-args.c
412473 lib/realloc.c
413474 lib/ref-add.sin
414475 lib/ref-del.sin
476 lib/rmdir.c
477 lib/same-inode.h
478 lib/save-cwd.c
479 lib/save-cwd.h
415480 lib/signbitd.c
416481 lib/signbitf.c
417482 lib/signbitl.c
425490 lib/stdio-write.c
426491 lib/stdio.in.h
427492 lib/stdlib.in.h
493 lib/strdup.c
428494 lib/streq.h
429495 lib/strerror.c
430496 lib/string.in.h
497 lib/stripslash.c
431498 lib/sys_stat.in.h
432499 lib/sys_time.in.h
433500 lib/time.in.h
435502 lib/unistd--.h
436503 lib/unistd-safer.h
437504 lib/unistd.in.h
505 lib/unlink.c
506 lib/unlinkat.c
438507 lib/utimens.c
439508 lib/utimens.h
440509 lib/vasnprintf.c
445514 lib/wctype.in.h
446515 lib/xalloc-die.c
447516 lib/xalloc.h
517 lib/xgetcwd.c
518 lib/xgetcwd.h
448519 lib/xmalloc.c
449520 lib/xsize.h
450521 lib/yesno.c
452523 m4/00gnulib.m4
453524 m4/alloca.m4
454525 m4/calloc.m4
526 m4/chdir-long.m4
527 m4/chown.m4
455528 m4/clock_time.m4
456529 m4/close-stream.m4
457530 m4/close.m4
458531 m4/closein.m4
459532 m4/closeout.m4
460533 m4/codeset.m4
534 m4/d-ino.m4
535 m4/dirent_h.m4
536 m4/dirfd.m4
537 m4/dirname.m4
461538 m4/dos.m4
539 m4/double-slash-root.m4
462540 m4/dup2.m4
463541 m4/errno_h.m4
464542 m4/error.m4
467545 m4/exponentf.m4
468546 m4/exponentl.m4
469547 m4/extensions.m4
548 m4/fchdir.m4
470549 m4/fclose.m4
550 m4/fcntl-o.m4
471551 m4/fcntl-safer.m4
552 m4/fcntl.m4
472553 m4/fcntl_h.m4
554 m4/fdopendir.m4
473555 m4/fflush.m4
474556 m4/float_h.m4
475557 m4/fpending.m4
481563 m4/frexpl.m4
482564 m4/fseeko.m4
483565 m4/ftello.m4
566 m4/getcwd-abort-bug.m4
567 m4/getcwd-path-max.m4
568 m4/getcwd.m4
484569 m4/getopt.m4
485 m4/getpagesize.m4
486570 m4/gettime.m4
487571 m4/gettimeofday.m4
488572 m4/glibc21.m4
495579 m4/isnand.m4
496580 m4/isnanf.m4
497581 m4/isnanl.m4
582 m4/lchown.m4
498583 m4/ldexpl.m4
499584 m4/localcharset.m4
500585 m4/locale-fr.m4
504589 m4/lseek.m4
505590 m4/lstat.m4
506591 m4/malloc.m4
592 m4/manywarnings.m4
507593 m4/math_h.m4
508594 m4/mbrtowc.m4
509595 m4/mbsinit.m4
510596 m4/mbstate_t.m4
511597 m4/memchr.m4
598 m4/mempcpy.m4
599 m4/memrchr.m4
600 m4/mkdir.m4
512601 m4/mmap-anon.m4
513602 m4/mode_t.m4
514603 m4/multiarch.m4
515604 m4/nocrash.m4
516605 m4/open.m4
606 m4/openat.m4
517607 m4/perror.m4
518608 m4/printf-frexp.m4
519609 m4/printf-frexpl.m4
521611 m4/printf.m4
522612 m4/quotearg.m4
523613 m4/realloc.m4
614 m4/rmdir.m4
615 m4/save-cwd.m4
524616 m4/signbit.m4
525617 m4/size_max.m4
526618 m4/stat-time.m4
531623 m4/stdint_h.m4
532624 m4/stdio_h.m4
533625 m4/stdlib_h.m4
626 m4/strdup.m4
534627 m4/strerror.m4
535628 m4/string_h.m4
536629 m4/sys_stat_h.m4
539632 m4/timespec.m4
540633 m4/unistd-safer.m4
541634 m4/unistd_h.m4
635 m4/unlink.m4
542636 m4/utimbuf.m4
543637 m4/utimens.m4
544638 m4/utimes.m4
545639 m4/vasnprintf.m4
546640 m4/vfprintf-posix.m4
641 m4/warn-on-use.m4
642 m4/warnings.m4
547643 m4/wchar.m4
548644 m4/wchar_t.m4
549645 m4/wctype.m4
550646 m4/wint_t.m4
551647 m4/xalloc.m4
648 m4/xgetcwd.m4
552649 m4/xsize.m4
553650 m4/yesno.m4
554651 top/GNUmakefile
00 # include_next.m4 serial 14
1 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
108108 # be
109109 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
110110 # That way, a header file with the following line:
111 # #@INCLUDE_NEXT@ @NEXT_FOO_H@
111 # #@INCLUDE_NEXT@ @NEXT_FOO_H@
112112 # or
113 # #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
113 # #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
114114 # behaves (after sed substitution) as if it contained
115 # #include_next <foo.h>
115 # #include_next <foo.h>
116116 # even if the compiler does not support include_next.
117117 # The three "///" are to pacify Sun C 5.8, which otherwise would say
118118 # "warning: #include of /usr/include/... may be non-portable".
128128
129129 m4_foreach_w([gl_HEADER_NAME], [$1],
130130 [AS_VAR_PUSHDEF([gl_next_header],
131 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
131 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
132132 if test $gl_cv_have_include_next = yes; then
133133 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
134134 else
135135 AC_CACHE_CHECK(
136 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
137 m4_defn([gl_next_header]),
138 [AS_VAR_PUSHDEF([gl_header_exists],
139 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
140 if test AS_VAR_GET(gl_header_exists) = yes; then
141 AC_LANG_CONFTEST(
142 [AC_LANG_SOURCE(
143 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
144 )])
145 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
146 dnl that contain only a #include of other header files and no
147 dnl non-comment tokens of their own. This leads to a failure to
148 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
149 dnl and others. The workaround is to force preservation of comments
150 dnl through option -C. This ensures all necessary #line directives
151 dnl are present. GCC supports option -C as well.
152 case "$host_os" in
153 aix*) gl_absname_cpp="$ac_cpp -C" ;;
154 *) gl_absname_cpp="$ac_cpp" ;;
155 esac
156 dnl eval is necessary to expand gl_absname_cpp.
157 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
158 dnl so use subshell.
159 AS_VAR_SET([gl_next_header],
160 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
161 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
162 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
163 s#^/[^/]#//&#
164 p
165 q
166 }'`'"'])
167 else
168 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
169 fi
170 AS_VAR_POPDEF([gl_header_exists])])
136 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
137 m4_defn([gl_next_header]),
138 [AS_VAR_PUSHDEF([gl_header_exists],
139 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
140 if test AS_VAR_GET(gl_header_exists) = yes; then
141 AC_LANG_CONFTEST(
142 [AC_LANG_SOURCE(
143 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
144 )])
145 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
146 dnl that contain only a #include of other header files and no
147 dnl non-comment tokens of their own. This leads to a failure to
148 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
149 dnl and others. The workaround is to force preservation of comments
150 dnl through option -C. This ensures all necessary #line directives
151 dnl are present. GCC supports option -C as well.
152 case "$host_os" in
153 aix*) gl_absname_cpp="$ac_cpp -C" ;;
154 *) gl_absname_cpp="$ac_cpp" ;;
155 esac
156 dnl eval is necessary to expand gl_absname_cpp.
157 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
158 dnl so use subshell.
159 AS_VAR_SET([gl_next_header],
160 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
161 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
162 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
163 s#^/[^/]#//&#
164 p
165 q
166 }'`'"'])
167 else
168 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
169 fi
170 AS_VAR_POPDEF([gl_header_exists])])
171171 fi
172172 AC_SUBST(
173173 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
00 # inline.m4 serial 4
1 dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # intmax_t.m4 serial 7
1 dnl Copyright (C) 1997-2004, 2006-2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 1997-2004, 2006-2007, 2009-2010 Free Software Foundation,
2 dnl Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
00 # inttypes_h.m4 serial 9
1 dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # isnand.m4 serial 6
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # isnanf.m4 serial 10
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # isnanl.m4 serial 12
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # serial 15
1 # Determine whether we need the lchown wrapper.
2
3 dnl Copyright (C) 1998, 2001, 2003-2007, 2009-2010 Free Software Foundation,
4 dnl Inc.
5
6 dnl This file is free software; the Free Software Foundation
7 dnl gives unlimited permission to copy and/or distribute it,
8 dnl with or without modifications, as long as this notice is preserved.
9
10 dnl From Jim Meyering.
11 dnl Provide lchown on systems that lack it, and work around bugs
12 dnl on systems that have it.
13
14 AC_DEFUN([gl_FUNC_LCHOWN],
15 [
16 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
17 AC_REQUIRE([gl_FUNC_CHOWN])
18 AC_CHECK_FUNCS_ONCE([lchmod])
19 AC_REPLACE_FUNCS([lchown])
20 if test $ac_cv_func_lchown = no; then
21 HAVE_LCHOWN=0
22 elif test "$gl_cv_func_chown_slash_works" != yes \
23 || test "$gl_cv_func_chown_ctime_works" != yes; then
24 dnl Trailing slash and ctime bugs in chown also occur in lchown.
25 AC_LIBOBJ([lchown])
26 REPLACE_LCHOWN=1
27 fi
28 ])
00 # ldexpl.m4 serial 4
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # localcharset.m4 serial 7
1 dnl Copyright (C) 2002, 2004, 2006, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # locale-fr.m4 serial 11
1 dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # locale-ja.m4 serial 7
1 dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # locale-zh.m4 serial 6
1 dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # longlong.m4 serial 14
1 dnl Copyright (C) 1999-2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 1999-2007, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1919 [AC_LINK_IFELSE(
2020 [_AC_TYPE_LONG_LONG_SNIPPET],
2121 [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
22 dnl If cross compiling, assume the bug isn't important, since
23 dnl nobody cross compiles for this platform as far as we know.
24 AC_RUN_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[@%:@include <limits.h>
27 @%:@ifndef LLONG_MAX
28 @%:@ define HALF \
29 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
30 @%:@ define LLONG_MAX (HALF - 1 + HALF)
31 @%:@endif]],
32 [[long long int n = 1;
33 int i;
34 for (i = 0; ; i++)
35 {
36 long long int m = n << i;
37 if (m >> i != n)
38 return 1;
39 if (LLONG_MAX / 2 < m)
40 break;
41 }
42 return 0;]])],
43 [ac_cv_type_long_long_int=yes],
44 [ac_cv_type_long_long_int=no],
45 [ac_cv_type_long_long_int=yes])],
22 dnl If cross compiling, assume the bug isn't important, since
23 dnl nobody cross compiles for this platform as far as we know.
24 AC_RUN_IFELSE(
25 [AC_LANG_PROGRAM(
26 [[@%:@include <limits.h>
27 @%:@ifndef LLONG_MAX
28 @%:@ define HALF \
29 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
30 @%:@ define LLONG_MAX (HALF - 1 + HALF)
31 @%:@endif]],
32 [[long long int n = 1;
33 int i;
34 for (i = 0; ; i++)
35 {
36 long long int m = n << i;
37 if (m >> i != n)
38 return 1;
39 if (LLONG_MAX / 2 < m)
40 break;
41 }
42 return 0;]])],
43 [ac_cv_type_long_long_int=yes],
44 [ac_cv_type_long_long_int=no],
45 [ac_cv_type_long_long_int=yes])],
4646 [ac_cv_type_long_long_int=no])])
4747 if test $ac_cv_type_long_long_int = yes; then
4848 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
8282 [
8383 AC_LANG_PROGRAM(
8484 [[/* For now, do not test the preprocessor; as of 2007 there are too many
85 implementations with broken preprocessors. Perhaps this can
86 be revisited in 2012. In the meantime, code should not expect
87 #if to work with literals wider than 32 bits. */
85 implementations with broken preprocessors. Perhaps this can
86 be revisited in 2012. In the meantime, code should not expect
87 #if to work with literals wider than 32 bits. */
8888 /* Test literals. */
8989 long long int ll = 9223372036854775807ll;
9090 long long int nll = -9223372036854775807LL;
9191 unsigned long long int ull = 18446744073709551615ULL;
9292 /* Test constant expressions. */
9393 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
94 ? 1 : -1)];
94 ? 1 : -1)];
9595 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
96 ? 1 : -1)];
96 ? 1 : -1)];
9797 int i = 63;]],
9898 [[/* Test availability of runtime routines for shift and division. */
9999 long long int llmax = 9223372036854775807ll;
100100 unsigned long long int ullmax = 18446744073709551615ull;
101101 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
102 | (llmax / ll) | (llmax % ll)
103 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
104 | (ullmax / ull) | (ullmax % ull));]])
102 | (llmax / ll) | (llmax % ll)
103 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
104 | (ullmax / ull) | (ullmax % ull));]])
105105 ])
00 # lseek.m4 serial 4
1 dnl Copyright (C) 2007 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1818 /* Exit with success only if stdin is seekable. */
1919 return lseek (0, (off_t)0, SEEK_CUR) < 0;
2020 }],
21 [if test -s conftest$ac_exeext \
22 && ./conftest$ac_exeext < conftest.$ac_ext \
23 && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
24 gl_cv_func_lseek_pipe=yes
25 else
26 gl_cv_func_lseek_pipe=no
27 fi],
28 [gl_cv_func_lseek_pipe=no])
21 [if test -s conftest$ac_exeext \
22 && ./conftest$ac_exeext < conftest.$ac_ext \
23 && { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
24 gl_cv_func_lseek_pipe=yes
25 else
26 gl_cv_func_lseek_pipe=no
27 fi],
28 [gl_cv_func_lseek_pipe=no])
2929 else
3030 AC_COMPILE_IFELSE([
3131 #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __BEOS__
3232 /* mingw and BeOS mistakenly return 0 when trying to seek on pipes. */
3333 Choke me.
3434 #endif],
35 [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
35 [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
3636 fi])
3737 if test $gl_cv_func_lseek_pipe = no; then
3838 gl_REPLACE_LSEEK
4545 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
4646 REPLACE_LSEEK=1
4747 AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
48 [Define to 1 if lseek does not detect pipes.])
48 [Define to 1 if lseek does not detect pipes.])
4949 ])
00 # serial 20
11
2 # Copyright (C) 1997-2001, 2003-2009 Free Software Foundation, Inc.
2 # Copyright (C) 1997-2001, 2003-2010 Free Software Foundation, Inc.
33 #
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
00 # malloc.m4 serial 9
1 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # manywarnings.m4 serial 1
1 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl From Simon Josefsson
7
8 # gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR)
9 # --------------------------------------------------
10 # Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR.
11 # Elements separated by whitespace. In set logic terms, the function
12 # does OUTVAR = LISTVAR \ REMOVEVAR.
13 AC_DEFUN([gl_MANYWARN_COMPLEMENT],
14 [
15 gl_warn_set=
16 set x $2; shift
17 for gl_warn_item
18 do
19 case " $3 " in
20 *" $gl_warn_item "*)
21 ;;
22 *)
23 gl_warn_set="$gl_warn_set $gl_warn_item"
24 ;;
25 esac
26 done
27 $1=$gl_warn_set
28 ])
29
30 # gl_MANYWARN_ALL_GCC(VARIABLE)
31 # -----------------------------
32 # Add all documented GCC (currently as per version 4.4) warning
33 # parameters to variable VARIABLE. Note that you need to test them
34 # using gl_WARN_ADD if you want to make sure your gcc understands it.
35 AC_DEFUN([gl_MANYWARN_ALL_GCC],
36 [
37 gl_manywarn_set=
38 for gl_manywarn_item in \
39 -Wall \
40 -W \
41 -Wformat-y2k \
42 -Wformat-nonliteral \
43 -Wformat-security \
44 -Winit-self \
45 -Wmissing-include-dirs \
46 -Wswitch-default \
47 -Wswitch-enum \
48 -Wunused \
49 -Wunknown-pragmas \
50 -Wstrict-aliasing \
51 -Wstrict-overflow \
52 -Wsystem-headers \
53 -Wfloat-equal \
54 -Wtraditional \
55 -Wtraditional-conversion \
56 -Wdeclaration-after-statement \
57 -Wundef \
58 -Wshadow \
59 -Wunsafe-loop-optimizations \
60 -Wpointer-arith \
61 -Wbad-function-cast \
62 -Wc++-compat \
63 -Wcast-qual \
64 -Wcast-align \
65 -Wwrite-strings \
66 -Wconversion \
67 -Wsign-conversion \
68 -Wlogical-op \
69 -Waggregate-return \
70 -Wstrict-prototypes \
71 -Wold-style-definition \
72 -Wmissing-prototypes \
73 -Wmissing-declarations \
74 -Wmissing-noreturn \
75 -Wmissing-format-attribute \
76 -Wpacked \
77 -Wpadded \
78 -Wredundant-decls \
79 -Wnested-externs \
80 -Wunreachable-code \
81 -Winline \
82 -Winvalid-pch \
83 -Wlong-long \
84 -Wvla \
85 -Wvolatile-register-var \
86 -Wdisabled-optimization \
87 -Wstack-protector \
88 -Woverlength-strings \
89 -Wbuiltin-macro-redefined \
90 -Wmudflap \
91 -Wpacked-bitfield-compat \
92 -Wsync-nand \
93 ; do
94 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
95 done
96 # The following are not documented in the manual but are included in
97 # output from gcc --help=warnings.
98 for gl_manywarn_item in \
99 -Wattributes \
100 -Wcoverage-mismatch \
101 -Wmultichar \
102 -Wunused-macros \
103 ; do
104 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
105 done
106 $1=$gl_manywarn_set
107 ])
0 # math_h.m4 serial 14
1 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
0 # math_h.m4 serial 16
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
77 [
88 AC_REQUIRE([gl_MATH_H_DEFAULTS])
99 gl_CHECK_NEXT_HEADERS([math.h])
10 AC_REQUIRE([AC_C_INLINE])
11
1012 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
1113 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
1214 [[/* Solaris 10 has a broken definition of NAN. Other platforms
1416 test only needs to fail when NAN is provided but wrong. */
1517 float f = 1.0f;
1618 #ifdef NAN
17 f = NAN;
19 f = NAN;
1820 #endif
19 return f == 0;]])],
21 return f == 0;]])],
2022 [gl_cv_header_math_nan_works=yes],
2123 [gl_cv_header_math_nan_works=no])])
2224 if test $gl_cv_header_math_nan_works = no; then
2527 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
2628 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
2729 [[/* Solaris 10 has a broken definition of HUGE_VAL. */
28 double d = HUGE_VAL;
29 return d == 0;]])],
30 double d = HUGE_VAL;
31 return d == 0;]])],
3032 [gl_cv_header_math_huge_val_works=yes],
3133 [gl_cv_header_math_huge_val_works=no])])
3234 if test $gl_cv_header_math_huge_val_works = no; then
4345
4446 AC_DEFUN([gl_MATH_H_DEFAULTS],
4547 [
48 GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
49 GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
50 GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
4651 GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
4752 GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
53 GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
54 GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
4855 GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
4956 GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
5057 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
5663 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
5764 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
5865 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
59 GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL])
66 GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
6067 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
6168 GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
6269 GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
6370 GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
71 GNULIB_SINL=0; AC_SUBST([GNULIB_SINL])
72 GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL])
73 GNULIB_TANL=0; AC_SUBST([GNULIB_TANL])
6474 GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC])
6575 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
6676 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
6777 dnl Assume proper GNU behavior unless another module says otherwise.
78 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
79 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
80 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
81 HAVE_COSL=1; AC_SUBST([HAVE_COSL])
82 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
6883 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
6984 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
7085 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
86 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
87 HAVE_SINL=1; AC_SUBST([HAVE_SINL])
88 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
89 HAVE_TANL=1; AC_SUBST([HAVE_TANL])
7190 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
7291 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
7392 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
00 # mbrtowc.m4 serial 16
1 dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation,
2 dnl Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
00 # mbsinit.m4 serial 3
1 dnl Copyright (C) 2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # mbstate_t.m4 serial 12
1 dnl Copyright (C) 2000-2002, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2000-2002, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1717
1818 AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
1919 [AC_COMPILE_IFELSE(
20 [AC_LANG_PROGRAM(
21 [AC_INCLUDES_DEFAULT[
22 # include <wchar.h>]],
23 [[mbstate_t x; return sizeof x;]])],
24 [ac_cv_type_mbstate_t=yes],
25 [ac_cv_type_mbstate_t=no])])
20 [AC_LANG_PROGRAM(
21 [AC_INCLUDES_DEFAULT[
22 # include <wchar.h>]],
23 [[mbstate_t x; return sizeof x;]])],
24 [ac_cv_type_mbstate_t=yes],
25 [ac_cv_type_mbstate_t=no])])
2626 if test $ac_cv_type_mbstate_t = yes; then
2727 AC_DEFINE([HAVE_MBSTATE_T], [1],
28 [Define to 1 if <wchar.h> declares mbstate_t.])
28 [Define to 1 if <wchar.h> declares mbstate_t.])
2929 else
3030 AC_DEFINE([mbstate_t], [int],
31 [Define to a type if <wchar.h> does not define.])
31 [Define to a type if <wchar.h> does not define.])
3232 fi
3333 ])
00 # memchr.m4 serial 7
1 dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
5252 {
5353 int pagesize = getpagesize ();
5454 char *two_pages =
55 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
56 flags, fd, 0);
55 (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
56 flags, fd, 0);
5757 if (two_pages != (char *)(-1)
58 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
59 fence = two_pages + pagesize;
58 && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
59 fence = two_pages + pagesize;
6060 }
6161 #endif
6262 if (fence)
0 # mempcpy.m4 serial 10
1 dnl Copyright (C) 2003-2004, 2006-2007, 2009-2010 Free Software Foundation,
2 dnl Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_MEMPCPY],
8 [
9 dnl Persuade glibc <string.h> to declare mempcpy().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11
12 dnl The mempcpy() declaration in lib/string.in.h uses 'restrict'.
13 AC_REQUIRE([AC_C_RESTRICT])
14
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
16 AC_REPLACE_FUNCS([mempcpy])
17 if test $ac_cv_func_mempcpy = no; then
18 HAVE_MEMPCPY=0
19 gl_PREREQ_MEMPCPY
20 fi
21 ])
22
23 # Prerequisites of lib/mempcpy.c.
24 AC_DEFUN([gl_PREREQ_MEMPCPY], [
25 :
26 ])
0 # memrchr.m4 serial 9
1 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation,
2 dnl Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_MEMRCHR],
8 [
9 dnl Persuade glibc <string.h> to declare memrchr().
10 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
11
12 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
13 AC_CHECK_DECLS_ONCE([memrchr])
14 if test $ac_cv_have_decl_memrchr = no; then
15 HAVE_DECL_MEMRCHR=0
16 fi
17
18 AC_REPLACE_FUNCS([memrchr])
19 if test $ac_cv_func_memrchr = no; then
20 gl_PREREQ_MEMRCHR
21 fi
22 ])
23
24 # Prerequisites of lib/memrchr.c.
25 AC_DEFUN([gl_PREREQ_MEMRCHR], [:])
0 # serial 9
1
2 # Copyright (C) 2001, 2003-2004, 2006, 2008-2010 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 # On some systems, mkdir ("foo/", 0700) fails because of the trailing slash.
8 # On others, mkdir ("foo/./", 0700) mistakenly succeeds.
9 # On such systems, arrange to use a wrapper function.
10 AC_DEFUN([gl_FUNC_MKDIR],
11 [dnl
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 AC_CACHE_CHECK([whether mkdir handles trailing slash],
15 [gl_cv_func_mkdir_trailing_slash_works],
16 [rm -rf conftest.dir
17 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
18 # include <sys/types.h>
19 # include <sys/stat.h>
20 ]], [return mkdir ("conftest.dir/", 0700);])],
21 [gl_cv_func_mkdir_trailing_slash_works=yes],
22 [gl_cv_func_mkdir_trailing_slash_works=no],
23 [gl_cv_func_mkdir_trailing_slash_works="guessing no"])
24 rm -rf conftest.dir
25 ]
26 )
27 if test "$gl_cv_func_mkdir_trailing_slash_works" != yes; then
28 REPLACE_MKDIR=1
29 AC_LIBOBJ([mkdir])
30 fi
31
32 AC_CACHE_CHECK([whether mkdir handles trailing dot],
33 [gl_cv_func_mkdir_trailing_dot_works],
34 [rm -rf conftest.dir
35 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
36 # include <sys/types.h>
37 # include <sys/stat.h>
38 ]], [return !mkdir ("conftest.dir/./", 0700);])],
39 [gl_cv_func_mkdir_trailing_dot_works=yes],
40 [gl_cv_func_mkdir_trailing_dot_works=no],
41 [gl_cv_func_mkdir_trailing_dot_works="guessing no"])
42 rm -rf conftest.dir
43 ]
44 )
45 if test "$gl_cv_func_mkdir_trailing_dot_works" != yes; then
46 REPLACE_MKDIR=1
47 AC_LIBOBJ([mkdir])
48 AC_DEFINE([FUNC_MKDIR_DOT_BUG], [1], [Define to 1 if mkdir mistakenly
49 creates a directory given with a trailing dot component.])
50 fi
51 ])
00 # mmap-anon.m4 serial 8
1 dnl Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # mode_t.m4 serial 2
1 dnl Copyright (C) 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # multiarch.m4 serial 5
1 dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # nocrash.m4 serial 2
1 dnl Copyright (C) 2005, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # open.m4 serial 7
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
0 # open.m4 serial 8
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1212 ;;
1313 *)
1414 dnl open("foo/") should not create a file when the file name has a
15 dnl trailing slash.
15 dnl trailing slash. FreeBSD only has the problem on symlinks.
16 AC_CHECK_FUNCS_ONCE([lstat])
1617 AC_CACHE_CHECK([whether open recognizes a trailing slash],
1718 [gl_cv_func_open_slash],
18 [
19 [# Assume that if we have lstat, we can also check symlinks.
20 if test $ac_cv_func_lstat = yes; then
21 touch conftest.tmp
22 ln -s conftest.tmp conftest.lnk
23 fi
1924 AC_TRY_RUN([
2025 #include <fcntl.h>
2126 #if HAVE_UNISTD_H
2328 #endif
2429 int main ()
2530 {
31 #if HAVE_LSTAT
32 if (open ("conftest.lnk/", O_RDONLY) != -1) return 2;
33 #endif
2634 return open ("conftest.sl/", O_CREAT, 0600) >= 0;
2735 }], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
2836 [
2937 changequote(,)dnl
3038 case "$host_os" in
39 freebsd*) gl_cv_func_open_slash="guessing no" ;;
3140 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
3241 hpux*) gl_cv_func_open_slash="guessing no" ;;
3342 *) gl_cv_func_open_slash="guessing yes" ;;
3443 esac
3544 changequote([,])dnl
3645 ])
37 rm -f conftest.sl
46 rm -f conftest.sl conftest.tmp conftest.lnk
3847 ])
3948 case "$gl_cv_func_open_slash" in
4049 *no)
0 # serial 27
1 # See if we need to use our replacement for Solaris' openat et al functions.
2
3 dnl Copyright (C) 2004-2010 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 # Written by Jim Meyering.
9
10 AC_DEFUN([gl_FUNC_OPENAT],
11 [
12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13 GNULIB_OPENAT=1
14
15 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
16 GNULIB_FCHMODAT=1
17 GNULIB_FSTATAT=1
18 GNULIB_MKDIRAT=1
19
20 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
21 GNULIB_FCHOWNAT=1
22 GNULIB_UNLINKAT=1
23
24 AC_LIBOBJ([openat-proc])
25 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
26 AC_CHECK_FUNCS_ONCE([lchmod])
27 AC_REPLACE_FUNCS([fchmodat fstatat mkdirat openat unlinkat])
28 AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
29 AC_REQUIRE([gl_FUNC_UNLINK])
30 case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in
31 yes+yes)
32 # GNU/Hurd has unlinkat, but it has the same bug as unlink.
33 if test $REPLACE_UNLINK = 1; then
34 AC_LIBOBJ([unlinkat])
35 REPLACE_UNLINKAT=1
36 fi ;;
37 yes+*)
38 # Solaris 9 has *at functions, but uniformly mishandles trailing
39 # slash in all of them.
40 AC_LIBOBJ([openat])
41 REPLACE_OPENAT=1
42 AC_LIBOBJ([fstatat])
43 REPLACE_FSTATAT=1
44 AC_LIBOBJ([unlinkat])
45 REPLACE_UNLINKAT=1
46 ;;
47 *)
48 HAVE_OPENAT=0
49 HAVE_UNLINKAT=0 # No known system with unlinkat but not openat
50 HAVE_FSTATAT=0 # No known system with fstatat but not openat
51 gl_PREREQ_OPENAT;;
52 esac
53 if test $ac_cv_func_fchmodat != yes; then
54 HAVE_FCHMODAT=0
55 fi
56 if test $ac_cv_func_mkdirat != yes; then
57 HAVE_MKDIRAT=0
58 fi
59 gl_FUNC_FCHOWNAT
60 ])
61
62 # gl_FUNC_FCHOWNAT_DEREF_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]])
63 AC_DEFUN([gl_FUNC_FCHOWNAT_DEREF_BUG],
64 [
65 AC_CACHE_CHECK([whether fchownat works with AT_SYMLINK_NOFOLLOW],
66 gl_cv_func_fchownat_nofollow_works,
67 [
68 gl_dangle=conftest.dangle
69 # Remove any remnants of a previous test.
70 rm -f $gl_dangle
71 # Arrange for deletion of the temporary file this test creates.
72 ac_clean_files="$ac_clean_files $gl_dangle"
73 ln -s conftest.no-such $gl_dangle
74 AC_RUN_IFELSE(
75 [AC_LANG_SOURCE(
76 [[
77 #include <fcntl.h>
78 #include <unistd.h>
79 #include <stdlib.h>
80 #include <errno.h>
81 #include <sys/types.h>
82 int
83 main ()
84 {
85 return (fchownat (AT_FDCWD, "$gl_dangle", -1, getgid (),
86 AT_SYMLINK_NOFOLLOW) != 0
87 && errno == ENOENT);
88 }
89 ]])],
90 [gl_cv_func_fchownat_nofollow_works=yes],
91 [gl_cv_func_fchownat_nofollow_works=no],
92 [gl_cv_func_fchownat_nofollow_works=no],
93 )
94 ])
95 AS_IF([test $gl_cv_func_fchownat_nofollow_works = no], [$1], [$2])
96 ])
97
98 # If we have the fchownat function, and it has the bug (in glibc-2.4)
99 # that it dereferences symlinks even with AT_SYMLINK_NOFOLLOW, then
100 # use the replacement function.
101 # Also use the replacement function if fchownat is simply not available.
102 AC_DEFUN([gl_FUNC_FCHOWNAT],
103 [
104 AC_REQUIRE([gl_FUNC_CHOWN])
105 AC_CHECK_FUNC([fchownat],
106 [gl_FUNC_FCHOWNAT_DEREF_BUG([REPLACE_FCHOWNAT=1
107 AC_DEFINE([FCHOWNAT_NOFOLLOW_BUG], [1], [Define to 1 if your
108 platform has fchownat, but it cannot perform lchown tasks.])])],
109 [HAVE_FCHOWNAT=0])
110 if test $REPLACE_CHOWN = 1; then
111 REPLACE_FCHOWNAT=1
112 fi
113 if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then
114 AC_LIBOBJ([fchownat])
115 fi
116 ])
117
118 AC_DEFUN([gl_PREREQ_OPENAT],
119 [
120 AC_REQUIRE([AC_C_INLINE])
121 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
122 :
123 ])
00 # perror.m4 serial 1
1 dnl Copyright (C) 2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # printf-frexp.m4 serial 3
1 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # printf-frexpl.m4 serial 6
1 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # printf-posix-rpl.m4 serial 3
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # printf.m4 serial 33
1 dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # quotearg.m4 serial 8
1 dnl Copyright (C) 2002, 2004-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2004-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # realloc.m4 serial 9
1 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # rmdir.m4 serial 7
1 dnl Copyright (C) 2002, 2005, 2009-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_FUNC_RMDIR],
7 [
8 AC_REQUIRE([gl_AC_DOS])
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 dnl FIXME: simplify this module in 2010 if no one reports a missing rmdir
11 AC_REPLACE_FUNCS([rmdir])
12 if test $ac_cv_func_rmdir = no; then
13 REPLACE_RMDIR=1
14 # If someone lacks rmdir, make configure fail, and request
15 # a bug report to inform us about it.
16 if test x"$SKIP_RMDIR_CHECK" != xyes; then
17 AC_MSG_FAILURE([Your system lacks the rmdir function.
18 Please report this, along with the output of "uname -a", to the
19 bug-coreutils@gnu.org mailing list. To continue past this point,
20 rerun configure with SKIP_RMDIR_CHECK=yes.
21 E.g., ./configure SKIP_RMDIR_CHECK=yes])
22 fi
23 else
24 dnl Detect cygwin 1.5.x bug.
25 AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
26 [mkdir conftest.dir
27 touch conftest.file
28 AC_RUN_IFELSE(
29 [AC_LANG_PROGRAM(
30 [[#include <stdio.h>
31 #include <errno.h>
32 #include <unistd.h>
33 ]], [[return !rmdir ("conftest.file/") || errno != ENOTDIR
34 || !rmdir ("conftest.dir/./");]])],
35 [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no],
36 [gl_cv_func_rmdir_works="guessing no"])
37 rm -rf conftest.dir conftest.file])
38 if test x"$gl_cv_func_rmdir_works" != xyes; then
39 REPLACE_RMDIR=1
40 AC_LIBOBJ([rmdir])
41 fi
42 fi
43 ])
0 # serial 9
1 dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_SAVE_CWD],
7 [
8 AC_LIBOBJ([save-cwd])
9 dnl Prerequisites for lib/save-cwd.c.
10 AC_CHECK_FUNCS_ONCE([fchdir])
11 ])
00 # Check for a working shell.
11
2 # Copyright (C) 2000-2001, 2007, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2000-2001, 2007, 2009-2010 Free Software Foundation, Inc.
33 # This program is free software; you can redistribute it and/or modify
44 # it under the terms of the GNU General Public License as published by
55 # the Free Software Foundation; either version 3, or (at your option)
00 # signbit.m4 serial 6
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # size_max.m4 serial 9
1 dnl Copyright (C) 2003, 2005-2006, 2008-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003, 2005-2006, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # Checks for stat-related time functions.
11
2 # Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009 Free Software
2 # Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2010 Free Software
33 # Foundation, Inc.
44
55 # This file is free software; the Free Software Foundation
2626 [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
2727 [ac_cv_typeof_struct_stat_st_atim_is_struct_timespec],
2828 [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])])
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])])
4444 if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then
4545 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.])
46 [Define to 1 if the type of the st_atim member of a struct stat is
47 struct timespec.])
4848 fi],
4949 [AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec], [],
5050 [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>])],
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>])],
5656 [#include <sys/types.h>
57 #include <sys/stat.h>])],
57 #include <sys/stat.h>])],
5858 [#include <sys/types.h>
5959 #include <sys/stat.h>])
6060 ])
7575 AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec], [],
7676 [AC_CHECK_MEMBERS([struct stat.st_birthtimensec], [],
7777 [AC_CHECK_MEMBERS([struct stat.st_birthtim.tv_nsec], [], [],
78 [#include <sys/types.h>
79 #include <sys/stat.h>])],
78 [#include <sys/types.h>
79 #include <sys/stat.h>])],
8080 [#include <sys/types.h>
81 #include <sys/stat.h>])],
81 #include <sys/stat.h>])],
8282 [#include <sys/types.h>
8383 #include <sys/stat.h>])
8484 ])
0 # serial 2
0 # serial 4
11
2 # Copyright (C) 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2009, 2010 Free Software Foundation, Inc.
33 #
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
1010 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1111 AC_REQUIRE([gl_AC_DOS])
1212 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13 AC_CHECK_FUNCS_ONCE([lstat])
1314 dnl mingw is the only known platform where stat(".") and stat("./") differ
1415 AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
1516 [gl_cv_func_stat_dir_slash],
2324 *) gl_cv_func_stat_dir_slash="guessing yes";;
2425 esac])])
2526 dnl Solaris 9 mistakenly succeeds on stat("file/")
27 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
2628 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
2729 [gl_cv_func_stat_file_slash],
2830 [touch conftest.tmp
31 # Assume that if we have lstat, we can also check symlinks.
32 if test $ac_cv_func_lstat = yes; then
33 ln -s conftest.tmp conftest.lnk
34 fi
2935 AC_RUN_IFELSE(
3036 [AC_LANG_PROGRAM(
3137 [[#include <sys/stat.h>
32 ]], [[struct stat st; return !stat ("conftest.tmp/", &st);]])],
38 ]], [[struct stat st;
39 if (!stat ("conftest.tmp/", &st)) return 1;
40 #if HAVE_LSTAT
41 if (!stat ("conftest.lnk/", &st)) return 2;
42 #endif
43 ]])],
3344 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
34 [gl_cv_func_stat_file_slash="guessing no"])])
45 [gl_cv_func_stat_file_slash="guessing no"])
46 rm -f conftest.tmp conftest.lnk])
3547 case $gl_cv_func_stat_dir_slash in
3648 *no) REPLACE_STAT=1
3749 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
4456 esac
4557 if test $REPLACE_STAT = 1; then
4658 AC_LIBOBJ([stat])
59 dnl Prerequisites of lib/stat.c.
60 AC_REQUIRE([AC_C_INLINE])
4761 fi
4862 ])
00 # Check for stdbool.h that conforms to C99.
11
2 dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
2 dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
33 dnl This file is free software; the Free Software Foundation
44 dnl gives unlimited permission to copy and/or distribute it,
55 dnl with or without modifications, as long as this notice is preserved.
3737 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
3838 [ac_cv_header_stdbool_h],
3939 [AC_TRY_COMPILE(
40 [
41 #include <stdbool.h>
42 #ifndef bool
43 "error: bool is not defined"
44 #endif
45 #ifndef false
46 "error: false is not defined"
47 #endif
48 #if false
49 "error: false is not 0"
50 #endif
51 #ifndef true
52 "error: true is not defined"
53 #endif
54 #if true != 1
55 "error: true is not 1"
56 #endif
57 #ifndef __bool_true_false_are_defined
58 "error: __bool_true_false_are_defined is not defined"
59 #endif
40 [
41 #include <stdbool.h>
42 #ifndef bool
43 "error: bool is not defined"
44 #endif
45 #ifndef false
46 "error: false is not defined"
47 #endif
48 #if false
49 "error: false is not 0"
50 #endif
51 #ifndef true
52 "error: true is not defined"
53 #endif
54 #if true != 1
55 "error: true is not 1"
56 #endif
57 #ifndef __bool_true_false_are_defined
58 "error: __bool_true_false_are_defined is not defined"
59 #endif
6060
61 struct s { _Bool s: 1; _Bool t; } s;
61 struct s { _Bool s: 1; _Bool t; } s;
6262
63 char a[true == 1 ? 1 : -1];
64 char b[false == 0 ? 1 : -1];
65 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
66 char d[(bool) 0.5 == true ? 1 : -1];
67 bool e = &s;
68 char f[(_Bool) 0.0 == false ? 1 : -1];
69 char g[true];
70 char h[sizeof (_Bool)];
71 char i[sizeof s.t];
72 enum { j = false, k = true, l = false * true, m = true * 256 };
73 _Bool n[m];
74 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
75 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
76 #if defined __xlc__ || defined __GNUC__
77 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
78 reported by James Lemley on 2005-10-05; see
79 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
80 This test is not quite right, since xlc is allowed to
81 reject this program, as the initializer for xlcbug is
82 not one of the forms that C requires support for.
83 However, doing the test right would require a run-time
84 test, and that would make cross-compilation harder.
85 Let us hope that IBM fixes the xlc bug, and also adds
86 support for this kind of constant expression. In the
87 meantime, this test will reject xlc, which is OK, since
88 our stdbool.h substitute should suffice. We also test
89 this with GCC, where it should work, to detect more
90 quickly whether someone messes up the test in the
91 future. */
92 char digs[] = "0123456789";
93 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
94 #endif
95 /* Catch a bug in an HP-UX C compiler. See
96 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
97 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
98 */
99 _Bool q = true;
100 _Bool *pq = &q;
101 ],
102 [
103 *pq |= q;
104 *pq |= ! q;
105 /* Refer to every declared value, to avoid compiler optimizations. */
106 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
107 + !m + !n + !o + !p + !q + !pq);
108 ],
109 [ac_cv_header_stdbool_h=yes],
110 [ac_cv_header_stdbool_h=no])])
63 char a[true == 1 ? 1 : -1];
64 char b[false == 0 ? 1 : -1];
65 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
66 char d[(bool) 0.5 == true ? 1 : -1];
67 bool e = &s;
68 char f[(_Bool) 0.0 == false ? 1 : -1];
69 char g[true];
70 char h[sizeof (_Bool)];
71 char i[sizeof s.t];
72 enum { j = false, k = true, l = false * true, m = true * 256 };
73 _Bool n[m];
74 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
75 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
76 #if defined __xlc__ || defined __GNUC__
77 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
78 reported by James Lemley on 2005-10-05; see
79 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
80 This test is not quite right, since xlc is allowed to
81 reject this program, as the initializer for xlcbug is
82 not one of the forms that C requires support for.
83 However, doing the test right would require a run-time
84 test, and that would make cross-compilation harder.
85 Let us hope that IBM fixes the xlc bug, and also adds
86 support for this kind of constant expression. In the
87 meantime, this test will reject xlc, which is OK, since
88 our stdbool.h substitute should suffice. We also test
89 this with GCC, where it should work, to detect more
90 quickly whether someone messes up the test in the
91 future. */
92 char digs[] = "0123456789";
93 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
94 #endif
95 /* Catch a bug in an HP-UX C compiler. See
96 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
97 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
98 */
99 _Bool q = true;
100 _Bool *pq = &q;
101 ],
102 [
103 *pq |= q;
104 *pq |= ! q;
105 /* Refer to every declared value, to avoid compiler optimizations. */
106 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
107 + !m + !n + !o + !p + !q + !pq);
108 ],
109 [ac_cv_header_stdbool_h=yes],
110 [ac_cv_header_stdbool_h=no])])
111111 AC_CHECK_TYPES([_Bool])
112112 if test $ac_cv_header_stdbool_h = yes; then
113113 AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
00 dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
11 # stddef_h.m4 serial 1
2 dnl Copyright (C) 2009 Free Software Foundation, Inc.
2 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
33 dnl This file is free software; the Free Software Foundation
44 dnl gives unlimited permission to copy and/or distribute it,
55 dnl with or without modifications, as long as this notice is preserved.
00 # stdint.m4 serial 34
1 dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
395395 for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
396396 case $glsuf in
397397 '') gltype1='int';;
398 l) gltype1='long int';;
399 ll) gltype1='long long int';;
400 i64) gltype1='__int64';;
401 u) gltype1='unsigned int';;
402 ul) gltype1='unsigned long int';;
403 ull) gltype1='unsigned long long int';;
398 l) gltype1='long int';;
399 ll) gltype1='long long int';;
400 i64) gltype1='__int64';;
401 u) gltype1='unsigned int';;
402 ul) gltype1='unsigned long int';;
403 ull) gltype1='unsigned long long int';;
404404 ui64)gltype1='unsigned __int64';;
405405 esac
406406 AC_COMPILE_IFELSE(
00 # stdint_h.m4 serial 8
1 dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # stdio_h.m4 serial 21
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
0 # stdio_h.m4 serial 23
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
66 AC_DEFUN([gl_STDIO_H],
77 [
88 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
9 AC_REQUIRE([AC_C_INLINE])
910 gl_CHECK_NEXT_HEADERS([stdio.h])
1011 dnl No need to create extra modules for these functions. Everyone who uses
1112 dnl <stdio.h> likely needs them.
2930 AC_LIBOBJ([stdio-write])
3031 fi
3132 ])
33
34 dnl Check for declarations of anything we want to poison if the
35 dnl corresponding gnulib module is not in use, and which is not
36 dnl guaranteed by C89.
37 gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
38 ]], [fseeko ftello])
3239 ])
3340
3441 AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
8895 HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
8996 HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
9097 HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
91 HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
92 HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
9398 HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
9499 HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
95100 HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
139144 choke me
140145 # endif
141146 #endif]])],
142 [gl_cv_var_stdin_large_offset=yes],
143 [gl_cv_var_stdin_large_offset=no])])
147 [gl_cv_var_stdin_large_offset=yes],
148 [gl_cv_var_stdin_large_offset=no])])
144149 ])
0 # stdlib_h.m4 serial 20
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
0 # stdlib_h.m4 serial 21
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
4040 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
4141 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
4242 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
43 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
4344 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
45 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
4446 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
4547 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
4648 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
6062 HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
6163 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
6264 HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
65 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
66 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
6367 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
6468 HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
6569 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
7579 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
7680 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
7781 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
82 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
7883 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
79 VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
84 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
8085 ])
0 # strdup.m4 serial 11
1
2 dnl Copyright (C) 2002-2010 Free Software Foundation, Inc.
3
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 AC_DEFUN([gl_FUNC_STRDUP],
9 [
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
11 AC_REPLACE_FUNCS([strdup])
12 AC_CHECK_DECLS_ONCE([strdup])
13 if test $ac_cv_have_decl_strdup = no; then
14 HAVE_DECL_STRDUP=0
15 fi
16 gl_PREREQ_STRDUP
17 ])
18
19 AC_DEFUN([gl_FUNC_STRDUP_POSIX],
20 [
21 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
22 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
23 if test $gl_cv_func_malloc_posix != yes; then
24 REPLACE_STRDUP=1
25 AC_LIBOBJ([strdup])
26 else
27 AC_REPLACE_FUNCS([strdup])
28 fi
29 AC_CHECK_DECLS_ONCE([strdup])
30 if test $ac_cv_have_decl_strdup = no; then
31 HAVE_DECL_STRDUP=0
32 fi
33 gl_PREREQ_STRDUP
34 ])
35
36 # Prerequisites of lib/strdup.c.
37 AC_DEFUN([gl_PREREQ_STRDUP], [:])
00 # strerror.m4 serial 9
1 dnl Copyright (C) 2002, 2007-2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # Configure a GNU-like replacement for <string.h>.
11
2 # Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2007-2010 Free Software Foundation, Inc.
33 # This file is free software; the Free Software Foundation
44 # gives unlimited permission to copy and/or distribute it,
55 # with or without modifications, as long as this notice is preserved.
66
7 # serial 9
7 # serial 10
88
99 # Written by Paul Eggert.
1010
6363 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
6464 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
6565 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
66 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
66 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
67 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
6768 dnl Assume proper GNU behavior unless another module says otherwise.
68 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
69 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
70 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
71 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
72 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
73 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
74 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
75 HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
76 HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
77 HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
78 HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
79 HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
80 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
81 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
82 HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
83 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
84 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
85 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
86 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
87 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
88 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
89 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
90 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
91 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
92 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
93 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
94 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
69 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
70 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
71 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
72 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
73 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
74 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
75 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
76 HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
77 HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
78 HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
79 HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
80 HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
81 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
82 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
83 HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
84 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
85 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
86 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
87 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
88 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
89 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
90 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
91 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
92 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
93 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
94 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
95 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
9596 ])
0 # sys_stat_h.m4 serial 19 -*- Autoconf -*-
1 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
0 # sys_stat_h.m4 serial 21 -*- Autoconf -*-
1 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
4444 GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
4545 GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT])
4646 GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT])
47 GNULIB_MKFIFO=0; AC_SUBST([GNULIB_MKFIFO])
4748 GNULIB_MKFIFOAT=0; AC_SUBST([GNULIB_MKFIFOAT])
49 GNULIB_MKNOD=0; AC_SUBST([GNULIB_MKNOD])
4850 GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT])
4951 GNULIB_STAT=0; AC_SUBST([GNULIB_STAT])
5052 GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT])
5557 HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
5658 HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
5759 HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
60 HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO])
5861 HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
62 HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
5963 HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
6064 HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
6165 REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
6367 REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
6468 REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
6569 REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
70 REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO])
71 REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD])
6672 REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
6773 REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT])
6874 ])
00 # Configure a replacement for <sys/time.h>.
1 # serial 2
12
2 # Copyright (C) 2007 Free Software Foundation, Inc.
3 # Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
34 # This file is free software; the Free Software Foundation
45 # gives unlimited permission to copy and/or distribute it,
56 # with or without modifications, as long as this notice is preserved.
1718 AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
1819 [
1920 AC_REQUIRE([AC_C_RESTRICT])
21 AC_CHECK_HEADERS_ONCE([sys/time.h])
2022 gl_CHECK_NEXT_HEADERS([sys/time.h])
2123
2224 if test $ac_cv_header_sys_time_h = yes; then
2931 AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
3032 [AC_COMPILE_IFELSE(
3133 [AC_LANG_PROGRAM(
32 [[#if HAVE_SYS_TIME_H
33 #include <sys/time.h>
34 #endif
35 #include <time.h>
36 ]],
37 [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
34 [[#if HAVE_SYS_TIME_H
35 #include <sys/time.h>
36 #endif
37 #include <time.h>
38 ]],
39 [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
3840 [gl_cv_sys_struct_timeval=yes],
3941 [gl_cv_sys_struct_timeval=no])])
4042 if test $gl_cv_sys_struct_timeval = yes; then
00 # Configure a more-standard replacement for <time.h>.
11
2 # Copyright (C) 2000-2001, 2003-2007, 2009 Free Software Foundation, Inc.
2 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
33
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
4444 [gl_cv_sys_struct_timespec_in_time_h],
4545 [AC_COMPILE_IFELSE(
4646 [AC_LANG_PROGRAM(
47 [[#include <time.h>
48 ]],
49 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
47 [[#include <time.h>
48 ]],
49 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
5050 [gl_cv_sys_struct_timespec_in_time_h=yes],
5151 [gl_cv_sys_struct_timespec_in_time_h=no])])
5252
5858 AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
5959 [gl_cv_sys_struct_timespec_in_sys_time_h],
6060 [AC_COMPILE_IFELSE(
61 [AC_LANG_PROGRAM(
62 [[#include <sys/time.h>
63 ]],
64 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
65 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
66 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
61 [AC_LANG_PROGRAM(
62 [[#include <sys/time.h>
63 ]],
64 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
65 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
66 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
6767 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
6868 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
6969 fi
00 #serial 14
11
2 # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software
3 # Foundation, Inc.
2 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
43
54 # This file is free software; the Free Software Foundation
65 # gives unlimited permission to copy and/or distribute it,
00 #serial 8
1 dnl Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # unistd_h.m4 serial 31
1 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
0 # unistd_h.m4 serial 38
1 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
1010 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
1111 dnl once only, before all statements that occur in other macros.
1212 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
13 AC_REQUIRE([AC_C_INLINE])
1314
1415 gl_CHECK_NEXT_HEADERS([unistd.h])
1516
2021 HAVE_UNISTD_H=0
2122 fi
2223 AC_SUBST([HAVE_UNISTD_H])
24
25 dnl Check for declarations of anything we want to poison if the
26 dnl corresponding gnulib module is not in use.
27 gl_WARN_ON_USE_PREPARE([[#include <unistd.h>
28 /* Some systems declare environ in the wrong header. */
29 #ifndef __GLIBC__
30 # include <stdlib.h>
31 #endif
32 ]], [environ])
2333 ])
2434
2535 AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
4555 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
4656 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
4757 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
58 GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
4859 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
60 GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
4961 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
5062 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
5163 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
5466 GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
5567 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
5668 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
69 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
5770 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
5871 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
5972 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
6477 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
6578 GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
6679 GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
80 GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
6781 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
6882 dnl Assume proper GNU behavior unless another module says otherwise.
83 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
6984 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
7085 HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
7186 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
7590 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
7691 HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME])
7792 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
93 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
7894 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
95 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
7996 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
8097 HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL])
98 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
8199 HAVE_LINK=1; AC_SUBST([HAVE_LINK])
82100 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
83101 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
102 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
84103 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
85104 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
86105 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
91110 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
92111 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
93112 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
113 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
94114 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
95115 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
96116 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
98118 REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
99119 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
100120 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
121 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
101122 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
102123 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
103124 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
104125 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
105126 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
127 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
106128 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
107129 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
130 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
108131 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
109132 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
110133 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
134 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
111135 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
112136 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
113137 UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
0 # unlink.m4 serial 3
1 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_FUNC_UNLINK],
7 [
8 AC_REQUIRE([gl_AC_DOS])
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 dnl Detect Solaris 9 and FreeBSD 7.2 bug.
11 AC_CACHE_CHECK([whether unlink honors trailing slashes],
12 [gl_cv_func_unlink_works],
13 [touch conftest.file
14 # Assume that if we have lstat, we can also check symlinks.
15 if test $ac_cv_func_lstat = yes; then
16 ln -s conftest.file conftest.lnk
17 fi
18 AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM(
20 [[#include <unistd.h>
21 #include <errno.h>
22 ]], [[if (!unlink ("conftest.file/") || errno != ENOTDIR) return 1;
23 #if HAVE_LSTAT
24 if (!unlink ("conftest.lnk/") || errno != ENOTDIR) return 2;
25 #endif
26 ]])],
27 [gl_cv_func_unlink_works=yes], [gl_cv_func_unlink_works=no],
28 [gl_cv_func_unlink_works="guessing no"])
29 rm -f conftest.file conftest.lnk])
30 if test x"$gl_cv_func_unlink_works" != xyes; then
31 REPLACE_UNLINK=1
32 AC_LIBOBJ([unlink])
33 fi
34 ])
00 # serial 9
11
2 # Copyright (C) 1998-2001, 2003-2004, 2007, 2009 Free Software
3 # Foundation, Inc.
2 # Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2010 Free Software Foundation,
3 # Inc.
44 #
55 # This file is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1818 AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf],
1919 [AC_COMPILE_IFELSE(
2020 [AC_LANG_PROGRAM(
21 [[#if HAVE_SYS_TIME_H
22 #include <sys/time.h>
23 #endif
24 #include <time.h>
25 #ifdef HAVE_UTIME_H
26 #include <utime.h>
27 #endif
28 ]],
29 [[static struct utimbuf x; x.actime = x.modtime;]])],
21 [[#if HAVE_SYS_TIME_H
22 #include <sys/time.h>
23 #endif
24 #include <time.h>
25 #ifdef HAVE_UTIME_H
26 #include <utime.h>
27 #endif
28 ]],
29 [[static struct utimbuf x; x.actime = x.modtime;]])],
3030 [gl_cv_sys_struct_utimbuf=yes],
3131 [gl_cv_sys_struct_utimbuf=no])])
3232
0 dnl Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
1 dnl Software Foundation, Inc.
0 dnl Copyright (C) 2003-2010 Free Software Foundation, Inc.
21 dnl This file is free software; the Free Software Foundation
32 dnl gives unlimited permission to copy and/or distribute it,
43 dnl with or without modifications, as long as this notice is preserved.
54
6 dnl serial 3
5 dnl serial 4
76
87 AC_DEFUN([gl_UTIMENS],
98 [
1413 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
1514 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
1615 AC_CHECK_FUNCS_ONCE([futimes futimesat futimens utimensat lutimes])
16
17 if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
18 dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time). It is not
19 dnl standardized, but Solaris implemented it first and uses it as
20 dnl its only means to set fd time.
21 AC_CACHE_CHECK([whether futimesat handles NULL file],
22 [gl_cv_func_futimesat_works],
23 [touch conftest.file
24 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
25 #include <stddef.h>
26 #include <sys/times.h>
27 ]], [[ int fd = open ("conftest.file", O_RDWR);
28 if (fd < 0) return 1;
29 if (futimesat (fd, NULL, NULL)) return 2;
30 ]])],
31 [gl_cv_func_futimesat_works=yes],
32 [gl_cv_func_futimesat_works=no],
33 [gl_cv_func_futimesat_works="guessing no"])
34 rm -f conftest.file])
35 if test "$gl_cv_func_futimesat_works" != yes; then
36 AC_DEFINE([FUTIMESAT_NULL_BUG], [1],
37 [Define to 1 if futimesat mishandles a NULL file name.])
38 fi
39 fi
1740 ])
00 # Detect some bugs in glibc's implementation of utimes.
1 # serial 2
12
2 dnl Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
3 dnl Copyright (C) 2003-2005, 2009-2010 Free Software Foundation, Inc.
34 dnl This file is free software; the Free Software Foundation
45 dnl gives unlimited permission to copy and/or distribute it,
56 dnl with or without modifications, as long as this notice is preserved.
1819
1920 AC_DEFUN([gl_FUNC_UTIMES],
2021 [
21 AC_CACHE_CHECK([determine whether the utimes function works],
22 gl_cv_func_working_utimes,
22 AC_CACHE_CHECK([whether the utimes function works],
23 [gl_cv_func_working_utimes],
2324 [
2425 AC_RUN_IFELSE([AC_LANG_SOURCE([[
2526 #include <sys/types.h>
4344 int fd;
4445
4546 int ok = ((f = fopen (file, "w"))
46 && fclose (f) == 0
47 && utimes (file, timeval) == 0
48 && lstat (file, &sbuf) == 0
49 && sbuf.st_atime == timeval[0].tv_sec
50 && sbuf.st_mtime == timeval[1].tv_sec);
47 && fclose (f) == 0
48 && utimes (file, timeval) == 0
49 && lstat (file, &sbuf) == 0
50 && sbuf.st_atime == timeval[0].tv_sec
51 && sbuf.st_mtime == timeval[1].tv_sec);
5152 unlink (file);
5253 if (!ok)
5354 exit (1);
6566 exit (1);
6667
6768 ok = (0 <= (fd = open (file, O_WRONLY|O_CREAT, 0444))
68 && close (fd) == 0
69 && utimes (file, NULL) == 0);
69 && close (fd) == 0
70 && utimes (file, NULL) == 0);
7071 unlink (file);
7172
7273 exit (!ok);
00 # vasnprintf.m4 serial 29
1 dnl Copyright (C) 2002-2004, 2006-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # vfprintf-posix.m4 serial 14
1 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
0 # warn-on-use.m4 serial 1
1 dnl Copyright (C) 2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 # gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
7 # ---------------------------------------
8 # For each whitespace-separated element in the list of NAMES, define
9 # HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
10 # even after being undefined as a macro.
11 #
12 # See warn-on-use.h for some hints on how to poison function names, as
13 # well as ideas on poisoning global variables and macros. NAMES may
14 # include global variables, but remember that only functions work with
15 # _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single
16 # header, but if the replacement header pulls in other headers because
17 # some systems declare functions in the wrong header, then INCLUDES
18 # should do likewise.
19 #
20 # If you assume C89, then it is generally safe to assume declarations
21 # for functions declared in that standard (such as gets) without
22 # needing gl_WARN_ON_USE_PREPARE.
23 AC_DEFUN([gl_WARN_ON_USE_PREPARE],
24 [
25 m4_foreach_w([gl_decl], [$2],
26 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
27 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
28 undefining macros.])])dnl
29 for gl_func in m4_flatten([$2]); do
30 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
31 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
32 [gl_Symbol],
33 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
34 [@%:@undef $gl_func
35 (void) $gl_func;])],
36 [AS_VAR_SET([gl_Symbol], [yes])], [AS_VAR_SET([gl_Symbol], [no])])])
37 AS_VAR_IF([gl_Symbol], [yes],
38 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
39 dnl shortcut - if the raw declaration exists, then set a cache
40 dnl variable to allow skipping any later AC_CHECK_DECL efforts
41 eval ac_cv_have_decl_$gl_func=yes])
42 AS_VAR_POPDEF([gl_Symbol])dnl
43 done
44 ])
0 # warnings.m4 serial 2
1 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 dnl From Simon Josefsson
7
8 # gl_AS_VAR_APPEND(VAR, VALUE)
9 # ----------------------------
10 # Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
11 m4_ifdef([AS_VAR_APPEND],
12 [m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
13 [m4_define([gl_AS_VAR_APPEND],
14 [AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
15
16 # gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
17 # ------------------------------------------------
18 # Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
19 # gl_WARN_ADD([-Wparentheses]).
20 AC_DEFUN([gl_WARN_ADD],
21 [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_$1])dnl
22 AC_CACHE_CHECK([whether compiler handles $1], [gl_Warn], [
23 save_CPPFLAGS="$CPPFLAGS"
24 CPPFLAGS="${CPPFLAGS} $1"
25 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
26 [AS_VAR_SET([gl_Warn], [yes])],
27 [AS_VAR_SET([gl_Warn], [no])])
28 CPPFLAGS="$save_CPPFLAGS"
29 ])
30 AS_VAR_PUSHDEF([gl_Flags], m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]))dnl
31 AS_VAR_IF([gl_Warn], [yes], [gl_AS_VAR_APPEND([gl_Flags], [" $1"])])
32 AS_VAR_POPDEF([gl_Flags])dnl
33 AS_VAR_POPDEF([gl_Warn])dnl
34 m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
35 ])
00 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
11
2 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
2 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
33 dnl This file is free software; the Free Software Foundation
44 dnl gives unlimited permission to copy and/or distribute it,
55 dnl with or without modifications, as long as this notice is preserved.
66
77 dnl Written by Eric Blake.
88
9 # wchar.m4 serial 25
9 # wchar.m4 serial 30
1010
1111 AC_DEFUN([gl_WCHAR_H],
1212 [
1313 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
14 AC_CACHE_CHECK([whether <wchar.h> is standalone],
15 [gl_cv_header_wchar_h_standalone],
16 [AC_COMPILE_IFELSE([[#include <wchar.h>
17 wchar_t w;]],
18 [gl_cv_header_wchar_h_standalone=yes],
19 [gl_cv_header_wchar_h_standalone=no])])
14 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
15 dnl Prepare for creating substitute <wchar.h>.
16 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
17 dnl character support).
18 dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
19 AC_CHECK_HEADERS_ONCE([wchar.h])
20 gl_CHECK_NEXT_HEADERS([wchar.h])
21 if test $ac_cv_header_wchar_h = yes; then
22 HAVE_WCHAR_H=1
23 else
24 HAVE_WCHAR_H=0
25 fi
26 AC_SUBST([HAVE_WCHAR_H])
2027
2128 AC_REQUIRE([gt_TYPE_WINT_T])
2229 if test $gt_cv_c_wint_t = yes; then
2532 HAVE_WINT_T=0
2633 fi
2734 AC_SUBST([HAVE_WINT_T])
35 ])
2836
29 dnl If <stddef.h> is replaced, then <wchar.h> must also be replaced.
30 AC_REQUIRE([gl_STDDEF_H])
31
32 if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
33 WCHAR_H=wchar.h
37 dnl Check whether <wchar.h> is usable at all.
38 AC_DEFUN([gl_WCHAR_H_INLINE_OK],
39 [
40 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
41 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
42 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
43 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
44 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
45 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
46 [gl_cv_header_wchar_h_correct_inline],
47 [gl_cv_header_wchar_h_correct_inline=yes
48 AC_LANG_CONFTEST([
49 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
50 #include <wchar.h>
51 extern int zero (void);
52 int main () { return zero(); }
53 ]])])
54 if AC_TRY_EVAL([ac_compile]); then
55 mv conftest.$ac_objext conftest1.$ac_objext
56 AC_LANG_CONFTEST([
57 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
58 #include <wchar.h>
59 int zero (void) { return 0; }
60 ]])])
61 if AC_TRY_EVAL([ac_compile]); then
62 mv conftest.$ac_objext conftest2.$ac_objext
63 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
64 :
65 else
66 gl_cv_header_wchar_h_correct_inline=no
67 fi
68 fi
69 fi
70 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
71 ])
72 if test $gl_cv_header_wchar_h_correct_inline = no; then
73 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
74 This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
75 C99 mode. You have four options:
76 - Add the flag -fgnu89-inline to CC and reconfigure, or
77 - Fix your include files, using parts of
78 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
79 - Use a gcc version older than 4.3, or
80 - Don't use the flags -std=c99 or -std=gnu99.
81 Configuration aborted.])
3482 fi
35
36 dnl Prepare for creating substitute <wchar.h>.
37 dnl Do it always: WCHAR_H may be empty here but can be set later.
38 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
39 dnl character support).
40 AC_CHECK_HEADERS_ONCE([wchar.h])
41 if test $ac_cv_header_wchar_h = yes; then
42 HAVE_WCHAR_H=1
43 else
44 HAVE_WCHAR_H=0
45 fi
46 AC_SUBST([HAVE_WCHAR_H])
47 gl_CHECK_NEXT_HEADERS([wchar.h])
4883 ])
4984
5085 dnl Unconditionally enables the replacement of <wchar.h>.
5186 AC_DEFUN([gl_REPLACE_WCHAR_H],
5287 [
53 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
54 WCHAR_H=wchar.h
88 dnl This is a no-op, because <wchar.h> is always overridden.
89 :
5590 ])
5691
5792 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
98133 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
99134 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
100135 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
101 WCHAR_H=''; AC_SUBST([WCHAR_H])
102136 ])
00 # wchar_t.m4 serial 3 (gettext-0.18)
1 dnl Copyright (C) 2002-2003, 2008, 2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
11
22 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
33
4 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
4 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
55 dnl This file is free software; the Free Software Foundation
66 dnl gives unlimited permission to copy and/or distribute it,
77 dnl with or without modifications, as long as this notice is preserved.
00 # wint_t.m4 serial 4 (gettext-0.18)
1 dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # xalloc.m4 serial 16
1 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2010 Free Software
2 dnl Foundation, Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
0 #serial 6
1 dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc.
2 dnl This file is free software; the Free Software Foundation
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 AC_DEFUN([gl_XGETCWD],
7 [
8 AC_LIBOBJ([xgetcwd])
9
10 AC_REQUIRE([gl_FUNC_GETCWD])
11 ])
00 # xsize.m4 serial 4
1 dnl Copyright (C) 2003-2004, 2008 Free Software Foundation, Inc.
1 dnl Copyright (C) 2003-2004, 2008-2010 Free Software Foundation, Inc.
22 dnl This file is free software; the Free Software Foundation
33 dnl gives unlimited permission to copy and/or distribute it,
44 dnl with or without modifications, as long as this notice is preserved.
00 # yesno.m4 serial 5
1 dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
1 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2010 Free Software Foundation,
2 dnl Inc.
23 dnl This file is free software; the Free Software Foundation
34 dnl gives unlimited permission to copy and/or distribute it,
45 dnl with or without modifications, as long as this notice is preserved.
11 # This Makefile fragment tries to be general-purpose enough to be
22 # used by many projects via the gnulib maintainer-makefile module.
33
4 ## Copyright (C) 2001-2009 Free Software Foundation, Inc.
4 ## Copyright (C) 2001-2010 Free Software Foundation, Inc.
55 ##
66 ## This program is free software: you can redistribute it and/or modify
77 ## it under the terms of the GNU General Public License as published by
2929 $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable)
3030 GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
3131
32 # cfg.mk must define the gpg_key_ID used by this package.
3332 GIT = git
3433 VC = $(GIT)
3534 VC-tag = git tag -s -m '$(VERSION)' -u '$(gpg_key_ID)'
3635
3736 VC_LIST = $(build_aux)/vc-list-files -C $(srcdir)
3837
38 # You can override this variable in cfg.mk to set your own regexp
39 # matching files to ignore.
40 VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$
41
3942 VC_LIST_EXCEPT = \
4043 $(VC_LIST) | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
41 else grep -Ev "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi
44 else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
45 | grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)'
4246
4347 ifeq ($(origin prev_version_file), undefined)
4448 prev_version_file = $(srcdir)/.prev-version
6266 # Old releases are stored here.
6367 release_archive_dir ?= ../release
6468
69 # Override gnu_rel_host and url_dir_list in cfg.mk if these are not right.
70 # Use alpha.gnu.org for alpha and beta releases.
71 # Use ftp.gnu.org for stable releases.
72 gnu_ftp_host-alpha = alpha.gnu.org
73 gnu_ftp_host-beta = alpha.gnu.org
74 gnu_ftp_host-stable = ftp.gnu.org
75 gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE))
76
77 ifeq ($(gnu_rel_host),ftp.gnu.org)
78 url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE)
79 else
80 url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE)
81 endif
82
83 # Override this in cfg.mk if you are using a different format in your
84 # NEWS file.
85 today = $(shell date +%Y-%m-%d)
86 news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)'
87
6588 # Prevent programs like 'sort' from considering distinct strings to be equal.
6689 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
6790 export LC_ALL = C
156179 1>&2; exit 1; } || :
157180
158181 # Pass EXIT_*, not number, to usage, exit, and error (when exiting)
182 # Convert all uses automatically, via these two commands:
183 # git grep -l '\<exit *(1)' \
184 # | grep -vEf .x-sc_prohibit_magic_number_exit \
185 # | xargs --no-run-if-empty \
186 # perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/'
187 # git grep -l '\<exit *(0)' \
188 # | grep -vEf .x-sc_prohibit_magic_number_exit \
189 # | xargs --no-run-if-empty \
190 # perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
159191 sc_prohibit_magic_number_exit:
160 @re='\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
192 @re='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
161193 msg='use EXIT_* values rather than magic number' \
162194 $(_prohibit_regexp)
163195
256288 sc_prohibit_assert_without_use:
257289 @h='<assert.h>' re='\<assert *\(' $(_header_without_use)
258290
291 # Prohibit the inclusion of close-stream.h without an actual use.
292 sc_prohibit_close_stream_without_use:
293 @h='"close-stream.h"' re='\<close_stream *\(' $(_header_without_use)
294
259295 # Prohibit the inclusion of getopt.h without an actual use.
260296 sc_prohibit_getopt_without_use:
261297 @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
282318 sc_prohibit_error_without_use:
283319 @h='"error.h"' \
284320 re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
321 $(_header_without_use)
322
323 # Don't include xalloc.h unless you use one of its functions.
324 # Consider these symbols:
325 # perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
326 # perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/xalloc.h
327 # Divide into two sets on case, and filter each through this:
328 # | sort | perl -MRegexp::Assemble -le \
329 # 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
330 # Note this was produced by the above:
331 # _xa1 = \
332 #x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
333 # But we can do better, in at least two ways:
334 # 1) take advantage of two "dup"-suffixed strings:
335 # x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
336 # 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
337 # "char|[cmz]"
338 # x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
339 _xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
340 _xa2 = X([CZ]|N?M)ALLOC
341 sc_prohibit_xalloc_without_use:
342 @h='"xalloc.h"' \
343 re='\<($(_xa1)|$(_xa2)) *\('\
285344 $(_header_without_use)
286345
287346 sc_prohibit_safe_read_without_use:
440499 @re='either ''version [^3]' msg='GPL vN, N!=3' \
441500 $(_prohibit_regexp)
442501
502 # Require the latest GFDL. Two regexp, since some .texi files end up
503 # line wrapping between 'Free Documentation License,' and 'Version'.
504 _GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
505 sc_GFDL_version:
506 @re='$(_GFDL_regexp)' msg='GFDL vN, N!=3' \
507 $(_prohibit_regexp)
508
443509 cvs_keywords = \
444510 Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
445511
462528 msg='do not define S_IS* macros; include <sys/stat.h>' \
463529 $(_prohibit_regexp)
464530
465 # Each program that uses proper_name_utf8 must link with
466 # one of the ICONV libraries.
531 # Each program that uses proper_name_utf8 must link with one of the
532 # ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
533 # The perl -0777 invocation below extracts the possibly-multi-line
534 # definition of LDADD from the appropriate Makefile.am and exits 0
535 # when it contains "ICONV".
467536 sc_proper_name_utf8_requires_ICONV:
468537 @progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
469538 if test "x$$progs" != x; then \
470539 fail=0; \
471540 for p in $$progs; do \
472541 dir=$$(dirname "$$p"); \
542 perl -0777 \
543 -ne 'exit !(/^LDADD =(.+?[^\\]\n)/ms && $$1 =~ /ICONV/)' \
544 $$dir/Makefile.am && continue; \
473545 base=$$(basename "$$p" .c); \
474546 grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
475547 || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
495567 NEWS_hash = \
496568 $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
497569 $(srcdir)/NEWS \
498 | grep -v '^Copyright .*Free Software' \
570 | perl -0777 -pe \
571 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \
499572 | md5sum - \
500573 | sed 's/ .*//')
501574
517590 # to emit a definition for each substituted variable.
518591 # We use perl rather than "grep -nE ..." to exempt a single
519592 # use of an @...@-delimited variable name in src/Makefile.am.
520 sc_makefile_check:
521 @perl -ne '/\@[A-Z_0-9]+\@/ && !/^cu_install_program =/' \
593 # Allow the package to add exceptions via a hook in cfg.mk;
594 # for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by
595 # setting this to ' && !/PRAGMA_SYSTEM_HEADER/'.
596 _makefile_at_at_check_exceptions ?=
597 sc_makefile_at_at_check:
598 @perl -ne '/\@[A-Z_0-9]+\@/'$(_makefile_at_at_check_exceptions) \
522599 -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
523600 $$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
524601 && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
525602
526 news-date-check: NEWS
527 today=`date +%Y-%m-%d`; \
528 if head $(srcdir)/NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
603 news-check: NEWS
604 if head $(srcdir)/NEWS | grep -E $(news-check-regexp) \
529605 >/dev/null; then \
530606 :; \
531607 else \
532 echo "version or today's date is not in NEWS" 1>&2; \
608 echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \
533609 exit 1; \
534610 fi
535611
633709 rm vc-diffs; \
634710 fi
635711
636 # Use this to make sure we don't run these programs when building
637 # from a virgin tgz file, below.
638 null_AM_MAKEFLAGS = \
639 ACLOCAL=false \
640 AUTOCONF=false \
641 AUTOMAKE=false \
642 AUTOHEADER=false \
643 MAKEINFO=false
644
645 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
646
647712 rel-files = $(DIST_ARCHIVES)
648713
649714 gnulib_dir ?= $(srcdir)/gnulib
650715 gnulib-version = $$(cd $(gnulib_dir) && git describe)
651716 bootstrap-tools ?= autoconf,automake,gnulib
717
718 # If it's not already specified, derive the GPG key ID from
719 # the signed tag we've just applied to mark this release.
720 gpg_key_ID ?= \
721 $$(git cat-file tag v$(VERSION) > .ann-sig \
722 && gpgv .ann-sig - < /dev/null 2>&1 \
723 | sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig)
652724
653725 announcement: NEWS ChangeLog $(rel-files)
654726 @$(build_aux)/announce-gen \
657729 --prev=$(PREV_VERSION) \
658730 --curr=$(VERSION) \
659731 --gpg-key-id=$(gpg_key_ID) \
660 --news=NEWS \
732 --news=$(srcdir)/NEWS \
661733 --bootstrap-tools=$(bootstrap-tools) \
662734 --gnulib-version=$(gnulib-version) \
663735 --no-print-checksums \
676748 @echo "$(build_aux)/gnupload $(GNUPLOADFLAGS) \\"
677749 @echo " --to $(gnu_rel_host):$(PACKAGE) \\"
678750 @echo " $(rel-files)"
679 @echo '# send the /tmp/announcement e-mail'
751 @echo '# send the ~/announce-$(my_distdir) e-mail'
680752 @echo =====================================
681753 @echo =====================================
682754
709781 || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
710782 || :
711783 $(MAKE) vc-diff-check
712 $(MAKE) news-date-check
784 $(MAKE) news-check
713785 $(MAKE) distcheck
714786 $(MAKE) dist XZ_OPT=-9ev
715 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
787 $(MAKE) $(release-prep-hook) RELEASE_TYPE=$@
788 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
789
790 # Override this in cfg.mk if you follow different procedures.
791 release-prep-hook ?= release-prep
792
793 .PHONY: release-prep
794 release-prep:
795 case $$RELEASE_TYPE in alpha|beta|stable) ;; \
796 *) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac
797 $(MAKE) -s announcement > ~/announce-$(my_distdir)
716798 if test -d $(release_archive_dir); then \
717799 ln $(rel-files) $(release_archive_dir); \
718800 chmod a-w $(rel-files); \
719801 fi
720 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
721802 echo $(VERSION) > $(prev_version_file)
722803 $(MAKE) update-NEWS-hash
723804 perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
724805 $(emit-commit-log) > .ci-msg
725806 $(VC) commit -F .ci-msg -a
807 rm .ci-msg
726808
727809 .PHONY: web-manual
728810 web-manual:
00 /* revision.h -- define the version number
11
2 Copyright (C) 1998-1999, 2001-2002, 2006, 2009 Free Software Foundation,
3 Inc.
2 Copyright (C) 1998-1999, 2001-2002, 2006, 2009-2010 Free Software
3 Foundation, Inc.
44 Copyright (C) 1992-1993 Jean-loup Gailly.
55
66 This program is free software; you can redistribute it and/or modify
00 /* tailor.h -- target dependent definitions
11
2 Copyright (C) 1997-1999, 2002, 2006, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1997-1999, 2002, 2006, 2009-2010 Free Software Foundation,
3 Inc.
34 Copyright (C) 1992-1993 Jean-loup Gailly
45
56 This program is free software; you can redistribute it and/or modify
199200 #endif
200201
201202 #if defined(ATARI) || defined(atarist)
202 # ifndef STDC_HEADERS
203 # define STDC_HEADERS
204 # define HAVE_UNISTD_H
205 # define HAVE_DIRENT_H
206 # endif
207203 # define ASMV
208204 # define OS_CODE 0x05
209205 # ifdef TOSFS
0 #!/bin/sh
1 # Before gzip-1.4, gzip -d would segfault on some inputs.
2
3 # Copyright (C) 2010 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 # limit so don't run it by default.
18
19 if test "$VERBOSE" = yes; then
20 set -x
21 gzip --version
22 fi
23
24 : ${srcdir=.}
25 . "$srcdir/tests/init.sh"; path_prepend_ .
26
27 # This test case was provided by Aki Helin.
28 printf '\037\235\220\0\0\0\304' > helin.gz || framework_failure
29 printf '\0\0' > exp || framework_failure
30
31 fail=0
32
33 gzip -dc helin.gz > out || fail=1
34 compare out exp || fail=1
35
36 Exit $fail
0 # source this file; set up for tests
1
2 # Copyright (C) 2009, 2010 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 # Using this file in a test
18 # =========================
19 #
20 # The typical skeleton of a test looks like this:
21 #
22 # #!/bin/sh
23 # : ${srcdir=.}
24 # . "$srcdir/init.sh"; path_prepend_ .
25 # Execute some commands.
26 # Note that these commands are executed in a subdirectory, therefore you
27 # need to prepend "../" to relative filenames in the build directory.
28 # Set the exit code 0 for success, 77 for skipped, or 1 or other for failure.
29 # Use the skip_ and fail_ functions to print a diagnostic and then exit
30 # with the corresponding exit code.
31 # Exit $?
32
33 # Executing a test that uses this file
34 # ====================================
35 #
36 # Running a single test:
37 # $ make check TESTS=test-foo.sh
38 #
39 # Running a single test, with verbose output:
40 # $ make check TESTS=test-foo.sh VERBOSE=yes
41 #
42 # Running a single test, with single-stepping:
43 # 1. Go into a sub-shell:
44 # $ bash
45 # 2. Set relevant environment variables from TESTS_ENVIRONMENT in the
46 # Makefile:
47 # $ export srcdir=../../tests # this is an example
48 # 3. Execute the commands from the test, copy&pasting them one by one:
49 # $ . "$srcdir/init.sh"; path_prepend_ .
50 # ...
51 # 4. Finally
52 # $ exit
53
54 # We use a trap below for cleanup. This requires us to go through
55 # hoops to get the right exit status transported through the handler.
56 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
57 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
58 # sh inside this function.
59 Exit () { set +e; (exit $1); exit $1; }
60
61 fail_() { echo "$ME_: failed test: $@" 1>&2; Exit 1; }
62 skip_() { echo "$ME_: skipped test: $@" 1>&2; Exit 77; }
63
64 # This is a stub function that is run upon trap (upon regular exit and
65 # interrupt). Override it with a per-test function, e.g., to unmount
66 # a partition, or to undo any other global state changes.
67 cleanup_() { :; }
68
69 if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
70 compare() { diff -u "$@"; }
71 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
72 compare() { cmp -s "$@"; }
73 else
74 compare() { cmp "$@"; }
75 fi
76
77 # An arbitrary prefix to help distinguish test directories.
78 testdir_prefix_() { printf gt; }
79
80 # Run the user-overridable cleanup_ function, remove the temporary
81 # directory and exit with the incoming value of $?.
82 remove_tmp_()
83 {
84 __st=$?
85 cleanup_
86 # cd out of the directory we're about to remove
87 cd "$initial_cwd_" || cd / || cd /tmp
88 chmod -R u+rwx "$test_dir_"
89 # If removal fails and exit status was to be 0, then change it to 1.
90 rm -rf "$test_dir_" || { test $__st = 0 && __st=1; }
91 exit $__st
92 }
93
94 # Use this function to prepend to PATH an absolute name for each
95 # specified, possibly-$initial_cwd_relative, directory.
96 path_prepend_()
97 {
98 while test $# != 0; do
99 path_dir_=$1
100 case $path_dir_ in
101 '') fail_ "invalid path dir: '$1'";;
102 /*) abs_path_dir_=$path_dir_;;
103 *) abs_path_dir_=`cd "$initial_cwd_/$path_dir_" && echo "$PWD"` \
104 || fail_ "invalid path dir: $path_dir_";;
105 esac
106 case $abs_path_dir_ in
107 *:*) fail_ "invalid path dir: '$abs_path_dir_'";;
108 esac
109 PATH="$abs_path_dir_:$PATH"
110 shift
111 done
112 export PATH
113 }
114
115 setup_()
116 {
117 test "$VERBOSE" = yes && set -x
118
119 initial_cwd_=$PWD
120 ME_=`expr "./$0" : '.*/\(.*\)$'`
121
122 pfx_=`testdir_prefix_`
123 test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \
124 || fail_ "failed to create temporary directory in $initial_cwd_"
125 cd "$test_dir_"
126
127 # This pair of trap statements ensures that the temporary directory,
128 # $test_dir_, is removed upon exit as well as upon catchable signal.
129 trap remove_tmp_ 0
130 trap 'Exit $?' 1 2 13 15
131 }
132
133 # Create a temporary directory, much like mktemp -d does.
134 # Written by Jim Meyering.
135 #
136 # Usage: mktempd_ /tmp phoey.XXXXXXXXXX
137 #
138 # First, try to use the mktemp program.
139 # Failing that, we'll roll our own mktemp-like function:
140 # - try to get random bytes from /dev/urandom
141 # - failing that, generate output from a combination of quickly-varying
142 # sources and gzip. Ignore non-varying gzip header, and extract
143 # "random" bits from there.
144 # - given those bits, map to file-name bytes using tr, and try to create
145 # the desired directory.
146 # - make only $MAX_TRIES_ attempts
147
148 # Helper function. Print $N pseudo-random bytes from a-zA-Z0-9.
149 rand_bytes_()
150 {
151 n_=$1
152
153 # Maybe try openssl rand -base64 $n_prime_|tr '+/=\012' abcd first?
154 # But if they have openssl, they probably have mktemp, too.
155
156 chars_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
157 dev_rand_=/dev/urandom
158 if test -r "$dev_rand_"; then
159 # Note: 256-length($chars_) == 194; 3 copies of $chars_ is 186 + 8 = 194.
160 dd ibs=$n_ count=1 if=$dev_rand_ 2>/dev/null \
161 | tr -c $chars_ 01234567$chars_$chars_$chars_
162 return
163 fi
164
165 n_plus_50_=`expr $n_ + 50`
166 cmds_='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n'
167 data_=` (eval "$cmds_") 2>&1 | gzip `
168
169 # Ensure that $data_ has length at least 50+$n_
170 while :; do
171 len_=`echo "$data_"|wc -c`
172 test $n_plus_50_ -le $len_ && break;
173 data_=` (echo "$data_"; eval "$cmds_") 2>&1 | gzip `
174 done
175
176 echo "$data_" \
177 | dd bs=1 skip=50 count=$n_ 2>/dev/null \
178 | tr -c $chars_ 01234567$chars_$chars_$chars_
179 }
180
181 mktempd_()
182 {
183 case $# in
184 2);;
185 *) fail_ "Usage: $ME DIR TEMPLATE";;
186 esac
187
188 destdir_=$1
189 template_=$2
190
191 MAX_TRIES_=4
192
193 # Disallow any trailing slash on specified destdir:
194 # it would subvert the post-mktemp "case"-based destdir test.
195 case $destdir_ in
196 /) ;;
197 */) fail_ "invalid destination dir: remove trailing slash(es)";;
198 esac
199
200 case $template_ in
201 *XXXX) ;;
202 *) fail_ "invalid template: $template_ (must have a suffix of at least 4 X's)";;
203 esac
204
205 fail=0
206
207 # First, try to use mktemp.
208 d=`env -u TMPDIR mktemp -d -t -p "$destdir_" "$template_" 2>/dev/null` \
209 || fail=1
210
211 # The resulting name must be in the specified directory.
212 case $d in "$destdir_"*);; *) fail=1;; esac
213
214 # It must have created the directory.
215 test -d "$d" || fail=1
216
217 # It must have 0700 permissions. Handle sticky "S" bits.
218 perms=`ls -dgo "$d" 2>/dev/null|tr S -` || fail=1
219 case $perms in drwx------*) ;; *) fail=1;; esac
220
221 test $fail = 0 && {
222 echo "$d"
223 return
224 }
225
226 # If we reach this point, we'll have to create a directory manually.
227
228 # Get a copy of the template without its suffix of X's.
229 base_template_=`echo "$template_"|sed 's/XX*$//'`
230
231 # Calculate how many X's we've just removed.
232 template_length_=`echo "$template_" | wc -c`
233 nx_=`echo "$base_template_" | wc -c`
234 nx_=`expr $template_length_ - $nx_`
235
236 err_=
237 i_=1
238 while :; do
239 X_=`rand_bytes_ $nx_`
240 candidate_dir_="$destdir_/$base_template_$X_"
241 err_=`mkdir -m 0700 "$candidate_dir_" 2>&1` \
242 && { echo "$candidate_dir_"; return; }
243 test $MAX_TRIES_ -le $i_ && break;
244 i_=`expr $i_ + 1`
245 done
246 fail_ "$err_"
247 }
248
249 # If you want to override the testdir_prefix_ function,
250 # or to add more utility functions, use this file.
251 test -f "$srcdir/init.cfg" \
252 && . "$srcdir/init.cfg"
253
254 setup_ "$@"
0 #!/bin/sh
1 # Before gzip-1.4, this the use of memcpy in inflate_codes could
2 # mistakenly operate on overlapping regions. Exercise that code.
3
4 # Copyright (C) 2010 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 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 # limit so don't run it by default.
19
20 if test "$VERBOSE" = yes; then
21 set -x
22 gzip --version
23 fi
24
25 : ${srcdir=.}
26 . "$srcdir/tests/init.sh"; path_prepend_ .
27
28 # The input must be larger than 32KiB and slightly
29 # less uniform than e.g., all zeros.
30 printf wxy%032767d 0 | tee in | gzip > in.gz || framework_failure
31
32 fail=0
33
34 # Before the fix, this would call memcpy with overlapping regions.
35 gzip -dc in.gz > out || fail=1
36
37 compare in out || fail=1
38
39 Exit $fail
+0
-397
tests/test-lib.sh less more
0 # source this file; set up for tests
1
2 # Copyright (C) 2009 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 # Skip this test if the shell lacks support for functions.
18 unset function_test
19 eval 'function_test() { return 11; }; function_test'
20 if test $? != 11; then
21 echo "$0: /bin/sh lacks support for functions; skipping this test." 1>&2
22 Exit 77
23 fi
24
25 skip_test_()
26 {
27 echo "$0: skipping test: $@" | head -1 1>&9
28 echo "$0: skipping test: $@" 1>&2
29 Exit 77
30 }
31
32 getlimits_()
33 {
34 eval $(getlimits)
35 test "$INT_MAX" ||
36 error_ "Error running getlimits"
37 }
38
39 require_acl_()
40 {
41 getfacl --version < /dev/null > /dev/null 2>&1 \
42 && setfacl --version < /dev/null > /dev/null 2>&1 \
43 || skip_test_ "This test requires getfacl and setfacl."
44
45 id -u bin > /dev/null 2>&1 \
46 || skip_test_ "This test requires a local user named bin."
47 }
48
49 # Skip this test if we're not in SELinux "enforcing" mode.
50 require_selinux_enforcing_()
51 {
52 test "$(getenforce)" = Enforcing \
53 || skip_test_ "This test is useful only with SELinux in Enforcing mode."
54 }
55
56
57 require_openat_support_()
58 {
59 # Skip this test if your system has neither the openat-style functions
60 # nor /proc/self/fd support with which to emulate them.
61 test -z "$CONFIG_HEADER" \
62 && skip_test_ 'internal error: CONFIG_HEADER not defined'
63
64 _skip=yes
65 grep '^#define HAVE_OPENAT' "$CONFIG_HEADER" > /dev/null && _skip=no
66 test -d /proc/self/fd && _skip=no
67 if test $_skip = yes; then
68 skip_test_ 'this system lacks openat support'
69 fi
70 }
71
72 require_ulimit_()
73 {
74 ulimit_works=yes
75 # Expect to be able to exec a program in 10MB of virtual memory,
76 # but not in 20KB. I chose "date". It must not be a shell built-in
77 # function, so you can't use echo, printf, true, etc.
78 # Of course, in coreutils, I could use $top_builddir/src/true,
79 # but this should be able to work for other projects, too.
80 ( ulimit -v 10000; date ) > /dev/null 2>&1 || ulimit_works=no
81 ( ulimit -v 20; date ) > /dev/null 2>&1 && ulimit_works=no
82
83 test $ulimit_works = no \
84 && skip_test_ "this shell lacks ulimit support"
85 }
86
87 require_readable_root_()
88 {
89 test -r / || skip_test_ "/ is not readable"
90 }
91
92 # Skip the current test if strace is not available or doesn't work
93 # with the named syscall. Usage: require_strace_ unlink
94 require_strace_()
95 {
96 test $# = 1 || framework_failure
97
98 strace -V < /dev/null > /dev/null 2>&1 ||
99 skip_test_ 'no strace program'
100
101 strace -qe "$1" echo > /dev/null 2>&1 ||
102 skip_test_ 'strace -qe "'"$1"'" does not work'
103 }
104
105 # Require a controlling input `terminal'.
106 require_controlling_input_terminal_()
107 {
108 tty -s || have_input_tty=no
109 test -t 0 || have_input_tty=no
110 if test "$have_input_tty" = no; then
111 skip_test_ 'requires controlling input terminal
112 This test must have a controlling input "terminal", so it may not be
113 run via "batch", "at", or "ssh". On some systems, it may not even be
114 run in the background.'
115 fi
116 }
117
118 require_built_()
119 {
120 skip_=no
121 for i in "$@"; do
122 case " $built_programs " in
123 *" $i "*) ;;
124 *) echo "$i: not built" 1>&2; skip_=yes ;;
125 esac
126 done
127
128 test $skip_ = yes && skip_test_ "required program(s) not built"
129 }
130
131 uid_is_privileged_()
132 {
133 # Make sure id -u succeeds.
134 my_uid=$(id -u) \
135 || { echo "$0: cannot run \`id -u'" 1>&2; return 1; }
136
137 # Make sure it gives valid output.
138 case $my_uid in
139 0) ;;
140 *[!0-9]*)
141 echo "$0: invalid output (\`$my_uid') from \`id -u'" 1>&2
142 return 1 ;;
143 *) return 1 ;;
144 esac
145 }
146
147 get_process_status_()
148 {
149 sed -n '/^State:[ ]*\([[:alpha:]]\).*/s//\1/p' /proc/$1/status
150 }
151
152 # Convert an ls-style permission string, like drwxr----x and -rw-r-x-wx
153 # to the equivalent chmod --mode (-m) argument, (=,u=rwx,g=r,o=x and
154 # =,u=rw,g=rx,o=wx). Ignore ACLs.
155 rwx_to_mode_()
156 {
157 case $# in
158 1) rwx=$1;;
159 *) echo "$0: wrong number of arguments" 1>&2
160 echo "Usage: $0 ls-style-mode-string" 1>&2
161 return;;
162 esac
163
164 case $rwx in
165 [ld-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxtT-]) ;;
166 [ld-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxsS-][rwx-][rwx-][rwxtT-][+.]) ;;
167 *) echo "$0: invalid mode string: $rwx" 1>&2; return;;
168 esac
169
170 # Perform these conversions:
171 # S s
172 # s xs
173 # T t
174 # t xt
175 # The `T' and `t' ones are only valid for `other'.
176 s='s/S/@/;s/s/x@/;s/@/s/'
177 t='s/T/@/;s/t/x@/;s/@/t/'
178
179 u=`echo $rwx|sed 's/^.\(...\).*/,u=\1/;s/-//g;s/^,u=$//;'$s`
180 g=`echo $rwx|sed 's/^....\(...\).*/,g=\1/;s/-//g;s/^,g=$//;'$s`
181 o=`echo $rwx|sed 's/^.......\(...\).*/,o=\1/;s/-//g;s/^,o=$//;'$s';'$t`
182 echo "=$u$g$o"
183 }
184
185 skip_if_()
186 {
187 case $1 in
188 root) skip_test_ must be run as root ;;
189 non-root) skip_test_ must be run as non-root ;;
190 *) ;; # FIXME?
191 esac
192 }
193
194 require_selinux_()
195 {
196 case `ls -Zd .` in
197 '? .'|'unlabeled .')
198 skip_test_ "this system (or maybe just" \
199 "the current file system) lacks SELinux support"
200 ;;
201 esac
202 }
203
204 very_expensive_()
205 {
206 if test "$RUN_VERY_EXPENSIVE_TESTS" != yes; then
207 skip_test_ 'very expensive: disabled by default
208 This test is very expensive, so it is disabled by default.
209 To run it anyway, rerun make check with the RUN_VERY_EXPENSIVE_TESTS
210 environment variable set to yes. E.g.,
211
212 env RUN_VERY_EXPENSIVE_TESTS=yes make check
213 '
214 fi
215 }
216
217 expensive_()
218 {
219 if test "$RUN_EXPENSIVE_TESTS" != yes; then
220 skip_test_ 'expensive: disabled by default
221 This test is relatively expensive, so it is disabled by default.
222 To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
223 environment variable set to yes. E.g.,
224
225 env RUN_EXPENSIVE_TESTS=yes make check
226 '
227 fi
228 }
229
230 require_root_()
231 {
232 uid_is_privileged_ || skip_test_ "must be run as root"
233 NON_ROOT_USERNAME=${NON_ROOT_USERNAME=nobody}
234 NON_ROOT_GROUP=${NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)}
235 }
236
237 skip_if_root_() { uid_is_privileged_ && skip_test_ "must be run as non-root"; }
238 error_() { echo "$0: $@" 1>&2; Exit 1; }
239 framework_failure() { error_ 'failure in testing framework'; }
240
241 # Set `groups' to a space-separated list of at least two groups
242 # of which the user is a member.
243 require_membership_in_two_groups_()
244 {
245 test $# = 0 || framework_failure
246
247 groups=${COREUTILS_GROUPS-`(id -G || /usr/xpg4/bin/id -G) 2>/dev/null`}
248 case "$groups" in
249 *' '*) ;;
250 *) skip_test_ 'requires membership in two groups
251 this test requires that you be a member of more than one group,
252 but running `id -G'\'' either failed or found just one. If you really
253 are a member of at least two groups, then rerun this test with
254 COREUTILS_GROUPS set in your environment to the space-separated list
255 of group names or numbers. E.g.,
256
257 env COREUTILS_GROUPS='users cdrom' make check
258
259 '
260 ;;
261 esac
262 }
263
264 # Is /proc/$PID/status supported?
265 require_proc_pid_status_()
266 {
267 sleep 2 &
268 local pid=$!
269 sleep .5
270 grep '^State:[ ]*[S]' /proc/$pid/status > /dev/null 2>&1 ||
271 skip_test_ "/proc/$pid/status: missing or 'different'"
272 kill $pid
273 }
274
275 # Does the current (working-dir) file system support sparse files?
276 require_sparse_support_()
277 {
278 test $# = 0 || framework_failure
279 # Test whether we can create a sparse file.
280 # For example, on Darwin6.5 with a file system of type hfs, it's not possible.
281 # NTFS requires 128K before a hole appears in a sparse file.
282 t=sparse.$$
283 dd bs=1 seek=128K of=$t < /dev/null 2> /dev/null
284 set x `du -sk $t`
285 kb_size=$2
286 rm -f $t
287 if test $kb_size -ge 128; then
288 skip_test_ 'this file system does not support sparse files'
289 fi
290 }
291
292 mkfifo_or_skip_()
293 {
294 test $# = 1 || framework_failure
295 if ! mkfifo "$1"; then
296 # Make an exception of this case -- usually we interpret framework-creation
297 # failure as a test failure. However, in this case, when running on a SunOS
298 # system using a disk NFS mounted from OpenBSD, the above fails like this:
299 # mkfifo: cannot make fifo `fifo-10558': Not owner
300 skip_test_ 'NOTICE: unable to create test prerequisites'
301 fi
302 }
303
304 # Disable the current test if the working directory seems to have
305 # the setgid bit set.
306 skip_if_setgid_()
307 {
308 setgid_tmpdir=setgid-$$
309 (umask 77; mkdir $setgid_tmpdir)
310 perms=$(stat --printf %A $setgid_tmpdir)
311 rmdir $setgid_tmpdir
312 case $perms in
313 drwx------);;
314 drwxr-xr-x);; # Windows98 + DJGPP 2.03
315 *) skip_test_ 'this directory has the setgid bit set';;
316 esac
317 }
318
319 skip_if_mcstransd_is_running_()
320 {
321 test $# = 0 || framework_failure
322
323 # When mcstransd is running, you'll see only the 3-component
324 # version of file-system context strings. Detect that,
325 # and if it's running, skip this test.
326 __ctx=$(stat --printf='%C\n' .) || framework_failure
327 case $__ctx in
328 *:*:*:*) ;; # four components is ok
329 *) # anything else probably means mcstransd is running
330 skip_test_ "unexpected context '$__ctx'; turn off mcstransd" ;;
331 esac
332 }
333
334 # Skip the current test if umask doesn't work as usual.
335 # This test should be run in the temporary directory that ends
336 # up being removed via the trap commands.
337 working_umask_or_skip_()
338 {
339 umask 022
340 touch file1 file2
341 chmod 644 file2
342 perms=`ls -l file1 file2 | sed 's/ .*//' | uniq`
343 rm -f file1 file2
344
345 case $perms in
346 *'
347 '*) skip_test_ 'your build directory has unusual umask semantics'
348 esac
349 }
350
351 # We use a trap below for cleanup. This requires us to go through
352 # hoops to get the right exit status transported through the signal.
353 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
354 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
355 # sh inside this function.
356 Exit ()
357 {
358 set +e
359 (exit $1)
360 exit $1
361 }
362
363 test_dir_=$(pwd)
364
365 this_test_() { echo "./$0" | sed 's,.*/,,'; }
366 this_test=$(this_test_)
367
368 # This is a stub function that is run upon trap (upon regular exit and
369 # interrupt). Override it with a per-test function, e.g., to unmount
370 # a partition, or to undo any other global state changes.
371 cleanup_() { :; }
372
373 t_=$(mktemp -d --tmp="$test_dir_" gz-$this_test.XXXXXXXXXX)\
374 || error_ "failed to create temporary directory in $test_dir_"
375
376 remove_tmp_()
377 {
378 __st=$?
379 cleanup_
380 cd "$test_dir_" && chmod -R u+rwx "$t_" && rm -rf "$t_" && exit $__st
381 }
382
383 # Run each test from within a temporary sub-directory named after the
384 # test itself, and arrange to remove it upon exception or normal exit.
385 trap remove_tmp_ 0
386 trap 'Exit $?' 1 2 13 15
387
388 cd "$t_" || error_ "failed to cd to $t_"
389
390 if ( diff --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
391 compare() { diff -u "$@"; }
392 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) 2>&1 > /dev/null; then
393 compare() { cmp -s "$@"; }
394 else
395 compare() { cmp "$@"; }
396 fi
11 # gzip accepts trailing NUL bytes; don't fail if there is exactly one.
22 # Before gzip-1.4, this would fail.
33
4 # Copyright (C) 2009 Free Software Foundation, Inc.
4 # Copyright (C) 2009-2010 Free Software Foundation, Inc.
55
66 # This program is free software: you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
2222 gzip --version
2323 fi
2424
25 . $srcdir/tests/test-lib.sh
25 : ${srcdir=.}
26 . "$srcdir/tests/init.sh"; path_prepend_ .
2627
2728 (echo 0 | gzip; printf '\0') > 0.gz || framework_failure
2829 (echo 00 | gzip; printf '\0\0') > 00.gz || framework_failure
11 # Exercise zdiff with two compressed inputs.
22 # Before gzip-1.4, this would fail.
33
4 # Copyright (C) 2009 Free Software Foundation, Inc.
4 # Copyright (C) 2009-2010 Free Software Foundation, Inc.
55
66 # This program is free software: you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
2222 zdiff --version
2323 fi
2424
25 . $srcdir/tests/test-lib.sh
25 : ${srcdir=.}
26 . "$srcdir/tests/init.sh"; path_prepend_ .
2627
2728 echo a > a || framework_failure
2829 echo b > b || framework_failure
11 # Ensure that zgrep -f - works like grep -f -
22 # Before gzip-1.4, it would fail.
33
4 # Copyright (C) 2009 Free Software Foundation, Inc.
4 # Copyright (C) 2009-2010 Free Software Foundation, Inc.
55
66 # This program is free software: you can redistribute it and/or modify
77 # it under the terms of the GNU General Public License as published by
2222 zgrep --version
2323 fi
2424
25 . $srcdir/tests/test-lib.sh
25 : ${srcdir=.}
26 . "$srcdir/tests/init.sh"; path_prepend_ .
2627
2728 echo needle > n || framework_failure
2829 echo needle > haystack || framework_failure
00 /* trees.c -- output deflated data using Huffman coding
11
2 Copyright (C) 1997-1999, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1997-1999, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
99 #include <config.h>
1010 #include "tailor.h"
1111
12 #ifdef HAVE_UNISTD_H
13 # include <unistd.h>
14 #endif
15 #ifdef HAVE_FCNTL_H
16 # include <fcntl.h>
17 #endif
12 #include <unistd.h>
13 #include <fcntl.h>
1814
1915 #include "gzip.h"
2016 #include "lzw.h"
243239 int o;
244240
245241 resetbuf:
246 e = insize-(o = (posbits>>3));
242 o = posbits >> 3;
243 e = o <= insize ? insize - o : 0;
247244
248245 for (i = 0 ; i < e ; ++i) {
249246 inbuf[i] = inbuf[i+o];
00 /* unpack.c -- decompress files in pack format.
11
2 Copyright (C) 1997, 1999, 2006, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1997, 1999, 2006, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
00 /* unzip.c -- decompress files in gzip or pkzip format.
11
2 Copyright (C) 1997-1999, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1997-1999, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
3838 #define CRPFLG 1 /* bit for encrypted entry */
3939 #define EXTFLG 8 /* bit for extended local header */
4040 #define LOCHOW 8 /* offset of compression method */
41 #define LOCTIM 10 /* file mod time (for decryption) */
41 /* #define LOCTIM 10 UNUSED file mod time (for decryption) */
4242 #define LOCCRC 14 /* offset of crc */
4343 #define LOCSIZ 18 /* offset of compressed size */
4444 #define LOCLEN 22 /* offset of uncompressed length */
00 /* util.c -- utility functions for gzip support
11
2 Copyright (C) 1997-1999, 2001-2002, 2006, 2009 Free Software Foundation,
3 Inc.
2 Copyright (C) 1997-1999, 2001-2002, 2006, 2009-2010 Free Software
3 Foundation, Inc.
44 Copyright (C) 1992-1993 Jean-loup Gailly
55
66 This program is free software; you can redistribute it and/or modify
2323
2424 #include "tailor.h"
2525
26 #ifdef HAVE_LIMITS_H
27 # include <limits.h>
28 #endif
29 #ifdef HAVE_UNISTD_H
30 # include <unistd.h>
31 #endif
32 #ifdef HAVE_FCNTL_H
33 # include <fcntl.h>
34 #endif
35
36 #if defined STDC_HEADERS || defined HAVE_STDLIB_H
37 # include <stdlib.h>
38 #else
39 extern int errno;
40 #endif
26 #include <limits.h>
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <stdlib.h>
30 #include <errno.h>
4131
4232 #include "gzip.h"
4333 #include "crypt.h"
145135 voidp buf;
146136 unsigned int cnt;
147137 {
148 #ifdef SSIZE_MAX
149 if (SSIZE_MAX < cnt)
150 cnt = SSIZE_MAX;
151 #endif
138 if (INT_MAX < cnt)
139 cnt = INT_MAX;
152140 return read (fd, buf, cnt);
153141 }
154142
159147 voidp buf;
160148 unsigned int cnt;
161149 {
162 #ifdef SSIZE_MAX
163 if (SSIZE_MAX < cnt)
164 cnt = SSIZE_MAX;
165 #endif
150 if (INT_MAX < cnt)
151 cnt = INT_MAX;
166152 return write (fd, buf, cnt);
167153 }
168154
296282 } while (p != name);
297283 }
298284
299
300 #if !defined HAVE_STRING_H && !defined STDC_HEADERS
301
302 /* Provide missing strspn and strcspn functions. */
303
304 # ifndef __STDC__
305 # define const
306 # endif
307
308 int strspn OF((const char *s, const char *accept));
309 int strcspn OF((const char *s, const char *reject));
310
311 /* ========================================================================
312 * Return the length of the maximum initial segment
313 * of s which contains only characters in accept.
314 */
315 int strspn(s, accept)
316 const char *s;
317 const char *accept;
318 {
319 register const char *p;
320 register const char *a;
321 register int count = 0;
322
323 for (p = s; *p != '\0'; ++p) {
324 for (a = accept; *a != '\0'; ++a) {
325 if (*p == *a) break;
326 }
327 if (*a == '\0') return count;
328 ++count;
329 }
330 return count;
331 }
332
333 /* ========================================================================
334 * Return the length of the maximum inital segment of s
335 * which contains no characters from reject.
336 */
337 int strcspn(s, reject)
338 const char *s;
339 const char *reject;
340 {
341 register int count = 0;
342
343 while (*s != '\0') {
344 if (strchr(reject, *s++) != NULL) return count;
345 ++count;
346 }
347 return count;
348 }
349
350 #endif
351
352285 /* ========================================================================
353286 * Add an environment variable (if any) before argv, and update argc.
354287 * Return the expanded environment variable to be freed later, or NULL
356289 */
357290 #define SEPARATOR " \t" /* separators in env variable */
358291
359 char *add_envopt(argcp, argvp, env)
360 int *argcp; /* pointer to argc */
361 char ***argvp; /* pointer to argv */
362 char *env; /* name of environment variable */
292 char *add_envopt(
293 int *argcp, /* pointer to argc */
294 char ***argvp, /* pointer to argv */
295 char const *envvar_name) /* name of environment variable */
363296 {
364297 char *p; /* running pointer through env variable */
365298 char **oargv; /* runs through old argv array */
366299 char **nargv; /* runs through new argv array */
367300 int oargc = *argcp; /* old argc */
368301 int nargc = 0; /* number of arguments in env variable */
369
370 env = (char*)getenv(env);
371 if (env == NULL) return NULL;
372
373 env = xstrdup (env);
374
375 for (p = env; *p; nargc++ ) { /* move through env */
302 char *env_val;
303
304 env_val = getenv(envvar_name);
305 if (env_val == NULL) return NULL;
306
307 env_val = xstrdup (env_val);
308
309 for (p = env_val; *p; nargc++ ) { /* move through env_val */
376310 p += strspn(p, SEPARATOR); /* skip leading separators */
377311 if (*p == '\0') break;
378312
380314 if (*p) *p++ = '\0'; /* mark it */
381315 }
382316 if (nargc == 0) {
383 free(env);
317 free(env_val);
384318 return NULL;
385319 }
386320 *argcp += nargc;
397331 *(nargv++) = *(oargv++);
398332
399333 /* Then copy the environment args */
400 for (p = env; nargc > 0; nargc--) {
334 for (p = env_val; nargc > 0; nargc--) {
401335 p += strspn(p, SEPARATOR); /* skip separators */
402336 *(nargv++) = p; /* store start */
403337 while (*p++) ; /* skip over word */
406340 /* Finally copy the old args and add a NULL (usual convention) */
407341 while (oargc--) *(nargv++) = *(oargv++);
408342 *nargv = NULL;
409 return env;
343 return env_val;
410344 }
411345
412346 /* ========================================================================
413347 * Error handlers.
414348 */
415349 void
416 gzip_error (m)
417 char *m;
350 gzip_error (char const *m)
418351 {
419352 fprintf (stderr, "\n%s: %s: %s\n", program_name, ifname, m);
420353 abort_gzip();
427360 abort_gzip ();
428361 }
429362
430 void warning (m)
431 char *m;
363 void warning (char const *m)
432364 {
433365 WARN ((stderr, "%s: %s: warning: %s\n", program_name, ifname, m));
434366 }
2323 PATH=$bindir:$PATH
2424
2525 version="zcat (gzip) @VERSION@
26 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
26 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
2727 This is free software. You may redistribute copies of it under the terms of
2828 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2929 There is NO WARRANTY, to the extent permitted by law.
2323 PATH=$bindir:$PATH
2424
2525 version="zcmp (gzip) @VERSION@
26 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
26 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
2727 This is free software. You may redistribute copies of it under the terms of
2828 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2929 There is NO WARRANTY, to the extent permitted by law.
3030 esac
3131
3232 version="z$prog (gzip) @VERSION@
33 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
33 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
3434 This is free software. You may redistribute copies of it under the terms of
3535 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
3636 There is NO WARRANTY, to the extent permitted by law.
2929 PATH=$bindir:$PATH; export PATH
3030
3131 version="zforce (gzip) @VERSION@
32 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
32 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
3333 This is free software. You may redistribute copies of it under the terms of
3434 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
3535 There is NO WARRANTY, to the extent permitted by law.
2828 grep='${GREP-grep}'
2929
3030 version='zgrep (gzip) @VERSION@
31 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
31 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
3232 This is free software. You may redistribute copies of it under the terms of
3333 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
3434 There is NO WARRANTY, to the extent permitted by law.
00 /* zip.c -- compress files to the gzip or pkzip format
11
2 Copyright (C) 1997-1999, 2006-2007, 2009 Free Software Foundation, Inc.
2 Copyright (C) 1997-1999, 2006-2007, 2009-2010 Free Software Foundation, Inc.
33 Copyright (C) 1992-1993 Jean-loup Gailly
44
55 This program is free software; you can redistribute it and/or modify
2323 #include "gzip.h"
2424 #include "crypt.h"
2525
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29 #ifdef HAVE_FCNTL_H
30 # include <fcntl.h>
31 #endif
26 #include <unistd.h>
27 #include <fcntl.h>
3228
3329 local ulg crc; /* crc on uncompressed file data */
3430 off_t header_bytes; /* number of bytes in gzip header */
2222 PATH=$bindir:$PATH; export PATH
2323
2424 version="zless (gzip) @VERSION@
25 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
25 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
2626 This is free software. You may redistribute copies of it under the terms of
2727 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2828 There is NO WARRANTY, to the extent permitted by law.
2323 PATH=$bindir:$PATH; export PATH
2424
2525 version="zmore (gzip) @VERSION@
26 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
26 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
2727 This is free software. You may redistribute copies of it under the terms of
2828 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2929 There is NO WARRANTY, to the extent permitted by law.
2323 PATH=$bindir:$PATH; export PATH
2424
2525 version="znew (gzip) @VERSION@
26 Copyright (C) 2007, 2009 Free Software Foundation, Inc.
26 Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc.
2727 This is free software. You may redistribute copies of it under the terms of
2828 the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
2929 There is NO WARRANTY, to the extent permitted by law.