mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Merge build info with head.
This commit is contained in:
commit
8e9648a972
10
.hgignore
10
.hgignore
@ -10,12 +10,20 @@ config.log
|
||||
config.status
|
||||
config.status.lineno
|
||||
autom4te.cache
|
||||
tags
|
||||
TAGS
|
||||
**/tags
|
||||
**/TAGS
|
||||
lib/.deps
|
||||
lib/*.o
|
||||
lib/alloca.h
|
||||
lib/libgnu.a
|
||||
lib/unistd.h
|
||||
lib/stdbool.h
|
||||
lib/stdint.h
|
||||
lib/stdio.h
|
||||
lib/stdlib.h
|
||||
lib/string.h
|
||||
lib/wchar.h
|
||||
md5/.deps
|
||||
md5/*.o
|
||||
@ -30,8 +38,6 @@ src/config.h
|
||||
src/config.h.in
|
||||
src/wget
|
||||
src/cscope.out
|
||||
src/tags
|
||||
src/TAGS
|
||||
src/libunittest.a
|
||||
src/version.c
|
||||
doc/stamp-vti
|
||||
|
62
ChangeLog
62
ChangeLog
@ -1,7 +1,69 @@
|
||||
2008-05-29 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* po/*.po: Updated from TP (the 1.11.3 set).
|
||||
|
||||
* po/POTFILES.in: Added some more files from lib/, remove
|
||||
src/xmalloc.c.
|
||||
|
||||
* po/quot.sed, po/boldquot.sed: Automatic handling of quotearg's `
|
||||
and '.
|
||||
|
||||
2008-05-15 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* NEWS: Entry for --ask-password.
|
||||
|
||||
2008-05-14 Joao Ferreira <joao@joaoff.com>
|
||||
|
||||
* src/main.c, src/http.c, src/ftp.c: -nc is now working in
|
||||
conjunction with '-O file'.
|
||||
|
||||
2008-05-12 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* NEWS: Translations and -N/-O.
|
||||
|
||||
2008-04-30 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* NEWS: Added documentation for changes made in 1.11.2.
|
||||
|
||||
2008-04-30 Steven Schubiger <stsc@members.fsf.org>
|
||||
|
||||
* lib/getdelim.c, lib/getline.c, lib/getpass.c,
|
||||
lib/getpass.h, lib/realloc.c, lib/stdio.h,
|
||||
lib/stdio.in.h, lib/stdlib.h, lib/stdlib.in.h: Imported
|
||||
from gnulib.
|
||||
* m4/eoverflow.m4, m4/extensions.m4, m4/getdelim.m4,
|
||||
m4/getline.m4, m4/getpass.m4, m4/malloc.m4, m4/realloc.m4,
|
||||
m4/stdio_h.m4, m4/stdlib_h.m4: Imported from gnulib.
|
||||
* md5/stdint.h: Imported from gnulib.
|
||||
|
||||
* GNUmakefile: Updated from gnulib.
|
||||
* lib/Makefile.am, lib/getopt.c, lib/unistd.in.h: Updated
|
||||
from gnulib.
|
||||
* m4/gnulib-cache.m4, m4/gnulib-common.m4, m4/gnulib-comp.m4,
|
||||
m4/include_next.m4, m4/unistd_h.m4: Updated from gnulib.
|
||||
* md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-common.m4,
|
||||
md5/m4/gnulib-comp.m4, md5/m4/include_next.m4, md5/m4/md5.m4,
|
||||
md5/m4/stdint.m4, md5/md5.c, md5/md5.h, md5/stdint.in.h,
|
||||
md5/wchar.in.h: Updated from gnulib.
|
||||
|
||||
2008-04-14 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* GNUmakefile, lib/Makefile.am, lib/error.c, lib/error.h,
|
||||
lib/exitfail.c, lib/exitfail.h, lib/getopt.c, lib/intprops.h,
|
||||
lib/quote.c, lib/quote.h, lib/quotearg.c, lib/quotearg.h,
|
||||
lib/stdlib.in.h, lib/strerror.c, lib/string.in.h,
|
||||
lib/unistd.in.h, lib/wchar.in.h, lib/wctype.in.h,
|
||||
lib/xalloc-die.c, lib/xalloc.h, lib/xmalloc.c, m4/error.m4,
|
||||
m4/exitfail.m4, m4/extensions.m4, m4/gnulib-cache.m4,
|
||||
m4/gnulib-comp.m4, m4/include_next.m4, m4/inline.m4,
|
||||
m4/mbrtowc.m4, m4/mbstate_t.m4, m4/quote.m4, m4/quotearg.m4,
|
||||
m4/stdlib_h.m4, m4/strerror.m4, m4/string_h.m4, m4/unistd_h.m4,
|
||||
m4/wchar.m4, m4/wctype.m4, m4/wint_t.m4, m4/xalloc.m4,
|
||||
md5/Makefile.am, md5/m4/gnulib-cache.m4, md5/m4/gnulib-comp.m4,
|
||||
md5/m4/include_next.m4, md5/m4/md5.m4, md5/m4/stdint.m4,
|
||||
md5/md5.c, md5/md5.h, md5/stdint.in.h, md5/wchar.in.h: Update
|
||||
from Gnulib, and add the "quote" module.
|
||||
|
||||
2008-03-20 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* ABOUT-NLS: Reinstated, but with a message mentioning that
|
||||
|
60
GNUmakefile
60
GNUmakefile
@ -1,21 +1,22 @@
|
||||
# Having a separate GNUmakefile lets me `include' the dynamically
|
||||
# generated rules created via Makefile.maint as well as Makefile.maint itself.
|
||||
# generated rules created via cfg.mk (package-local configuration)
|
||||
# as well as maint.mk (generic maintainer rules).
|
||||
# This makefile is used only if you run GNU Make.
|
||||
# It is necessary if you want to build targets usually of interest
|
||||
# only to the maintainer.
|
||||
|
||||
# Copyright (C) 2001, 2003, 2006, 2007 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# Copyright (C) 2001, 2003, 2006-2008 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
#
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@ -29,24 +30,55 @@ else
|
||||
SHELL = sh
|
||||
endif
|
||||
|
||||
# If the user runs GNU make but has not yet run ./configure,
|
||||
# give them a diagnostic.
|
||||
_have-Makefile := $(shell test -f Makefile && echo yes)
|
||||
ifeq ($(_have-Makefile),yes)
|
||||
|
||||
# Make tar archive easier to reproduce.
|
||||
export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
|
||||
|
||||
# Ran autoreconf and configure or not?
|
||||
have-Makefile := $(shell test -f Makefile && echo yes)
|
||||
ifeq ($(have-Makefile),yes)
|
||||
|
||||
include Makefile
|
||||
-include $(srcdir)/maint-cfg.mk
|
||||
|
||||
# Some projects override e.g., _autoreconf here.
|
||||
-include $(srcdir)/cfg.mk
|
||||
include $(srcdir)/maint.mk
|
||||
|
||||
# Allow cfg.mk to override these.
|
||||
_build-aux ?= build-aux
|
||||
_autoreconf ?= autoreconf
|
||||
|
||||
# Ensure that $(VERSION) is up to date for dist-related targets, but not
|
||||
# for others: rerunning autoreconf and recompiling everything isn't cheap.
|
||||
_have-git-version-gen := \
|
||||
$(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
|
||||
ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
|
||||
_is-dist-target = $(filter-out %clean, \
|
||||
$(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS)))
|
||||
ifneq (,$(_is-dist-target))
|
||||
_curr-ver := $(shell cd $(srcdir) && ./$(_build-aux)/git-version-gen \
|
||||
$(srcdir)/.tarball-version)
|
||||
ifneq ($(_curr-ver),$(VERSION))
|
||||
$(info INFO: running autoreconf for new version string: $(_curr-ver))
|
||||
_dummy := $(shell cd $(srcdir) && rm -rf autom4te.cache .version \
|
||||
&& $(_autoreconf))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
.DEFAULT_GOAL := abort-due-to-no-makefile
|
||||
srcdir = .
|
||||
|
||||
-include ./maint-cfg.mk
|
||||
# The package can override .DEFAULT_GOAL to run actions like autoreconf.
|
||||
-include ./cfg.mk
|
||||
include ./maint.mk
|
||||
|
||||
ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
|
||||
$(MAKECMDGOALS): abort-due-to-no-makefile
|
||||
endif
|
||||
|
||||
abort-due-to-no-makefile:
|
||||
@echo There seems to be no Makefile in this directory. 1>&2
|
||||
@echo "You must run ./configure before running \`make'." 1>&2
|
||||
|
13
NEWS
13
NEWS
@ -6,12 +6,17 @@ See the end for copying conditions.
|
||||
|
||||
Please send GNU Wget bug reports to <bug-wget@gnu.org>.
|
||||
|
||||
* Changes in Wget (MAINLINE).
|
||||
* Changes in Wget 1.12 (MAINLINE)
|
||||
|
||||
** Gnulib is now used to provide code for certain portability aspects in
|
||||
GNU Wget.
|
||||
** --ask-password option (and associated wgetrc command) added to
|
||||
support password prompts at the console.
|
||||
|
||||
** Wget uses Automake now as part of its build infrastructure.
|
||||
|
||||
* Changes in Wget 1.11.3
|
||||
|
||||
** Downgraded -N with -O to a warning, rather than an error.
|
||||
|
||||
** Translation updates
|
||||
|
||||
* Changes in Wget 1.11.2
|
||||
|
||||
|
@ -193,7 +193,6 @@ gl_INIT
|
||||
dnl
|
||||
dnl Checks for library functions.
|
||||
dnl
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_MMAP
|
||||
AC_FUNC_FSEEKO
|
||||
AC_CHECK_FUNCS(strptime timegm snprintf vsnprintf vasprintf drand48)
|
||||
|
@ -1,3 +1,26 @@
|
||||
2008-06-13 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* wget.texi (Mailing List): The wget-notify mailing list no longer
|
||||
receives commit notifications from the source repository.
|
||||
(Internet Relay Chat): Activity isn't quite so low any more,
|
||||
remove notice to that effect.
|
||||
|
||||
2008-05-17 Steven Schubiger <stsc@members.fsf.org>
|
||||
|
||||
* wget.texi (Download Options): Change documentation to reflect
|
||||
the new default value for --prefer-family.
|
||||
(Wgetrc Commands): Same, for prefer_family wgetrc command.
|
||||
|
||||
2008-05-12 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* wget.texi (Download Options): -N with -O downgraded to a
|
||||
warning.
|
||||
|
||||
2008-04-30 Steven Schubiger <stsc@members.fsf.org>
|
||||
|
||||
* wget.texi <Download Options>: Document the --ask-password
|
||||
option.
|
||||
|
||||
2008-04-27 Micah Cowan <micah@cowan.name>
|
||||
|
||||
* wget.texi (Download Options) <-O>: Elaborate on why certain
|
||||
|
@ -553,9 +553,8 @@ immediately, and @emph{all} downloaded content will be written there.
|
||||
|
||||
For this reason, @samp{-N} (for timestamp-checking) is not supported
|
||||
in combination with @samp{-O}: since @var{file} is always newly
|
||||
created, it will always have a very new timestamp. Contrary to some
|
||||
users' expectations, the combination has never worked, and as of
|
||||
version 1.11, it results in an error.
|
||||
created, it will always have a very new timestamp. A warning will be
|
||||
issued if this combination is used.
|
||||
|
||||
Similarly, using @samp{-r} or @samp{-p} with @samp{-O} may not work as
|
||||
you expect: Wget won't just download the first file to @var{file} and
|
||||
@ -951,10 +950,10 @@ or to deal with broken network configuration. Only one of
|
||||
same time. Neither option is available in Wget compiled without IPv6
|
||||
support.
|
||||
|
||||
@item --prefer-family=IPv4/IPv6/none
|
||||
@item --prefer-family=none/IPv4/IPv6
|
||||
When given a choice of several addresses, connect to the addresses
|
||||
with specified address family first. IPv4 addresses are preferred by
|
||||
default.
|
||||
with specified address family first. The address order returned by
|
||||
DNS is used without change by default.
|
||||
|
||||
This avoids spurious errors and connect attempts when accessing hosts
|
||||
that resolve to both IPv6 and IPv4 addresses from IPv4 networks. For
|
||||
@ -990,12 +989,16 @@ Specify the username @var{user} and password @var{password} for both
|
||||
using the @samp{--ftp-user} and @samp{--ftp-password} options for
|
||||
@sc{ftp} connections and the @samp{--http-user} and @samp{--http-password}
|
||||
options for @sc{http} connections.
|
||||
|
||||
@item --ask-password
|
||||
Prompt for a password for each connection established. Cannot be specified
|
||||
when @samp{--password} is being used, because they are mutually exclusive.
|
||||
@end table
|
||||
|
||||
@node Directory Options
|
||||
@section Directory Options
|
||||
|
||||
@table @samp
|
||||
@table @samp
|
||||
@item -nd
|
||||
@itemx --no-directories
|
||||
Do not create a hierarchy of directories when retrieving recursively.
|
||||
@ -2846,11 +2849,11 @@ Use POST as the method for all HTTP requests and send the contents of
|
||||
@var{file} in the request body. The same as
|
||||
@samp{--post-file=@var{file}}.
|
||||
|
||||
@item prefer_family = IPv4/IPv6/none
|
||||
@item prefer_family = none/IPv4/IPv6
|
||||
When given a choice of several addresses, connect to the addresses
|
||||
with specified address family first. IPv4 addresses are preferred by
|
||||
default. The same as @samp{--prefer-family}, which see for a detailed
|
||||
discussion of why this is useful.
|
||||
with specified address family first. The address order returned by
|
||||
DNS is used without change by default. The same as @samp{--prefer-family},
|
||||
which see for a detailed discussion of why this is useful.
|
||||
|
||||
@item private_key = @var{file}
|
||||
Set the private key file to @var{file}. The same as
|
||||
@ -3402,11 +3405,9 @@ The mailing list is archived at
|
||||
@url{http://news.gmane.org/gmane.comp.web.wget.patches}.
|
||||
|
||||
Finally, there is the @email{wget-notify@@addictivecode.org} mailing
|
||||
list. This is a non-discussion list that receives commit notifications
|
||||
from the source repository, and also bug report-change notifications.
|
||||
This is the highest-traffic list for Wget, and is recommended only for
|
||||
people who are seriously interested in ongoing Wget development.
|
||||
Subscription is through the @code{mailman} interface at
|
||||
list. This is a non-discussion list that receives bug report-change
|
||||
notifications from the bug-tracker. Unlike for the other mailing lists,
|
||||
subscription is through the @code{mailman} interface at
|
||||
@url{http://addictivecode.org/mailman/listinfo/wget-notify}.
|
||||
|
||||
@node Internet Relay Chat
|
||||
@ -3415,9 +3416,8 @@ Subscription is through the @code{mailman} interface at
|
||||
@cindex IRC
|
||||
@cindex #wget
|
||||
|
||||
While, at the time of this writing, there is very low activity, we do
|
||||
have a support channel set up via IRC at @code{irc.freenode.org},
|
||||
@code{#wget}. Come check it out!
|
||||
In addition to the mailinglists, we also have a support channel set up
|
||||
via IRC at @code{irc.freenode.org}, @code{#wget}. Come check it out!
|
||||
|
||||
@node Reporting Bugs
|
||||
@section Reporting Bugs
|
||||
|
397
lib/Makefile.am
397
lib/Makefile.am
@ -1,6 +1,6 @@
|
||||
## DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||
## Process this file with automake to produce Makefile.in.
|
||||
# Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
@ -9,7 +9,7 @@
|
||||
# the same distribution terms as the rest of that program.
|
||||
#
|
||||
# Generated by gnulib-tool.
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --no-libtool --macro-prefix=gl c-ctype getopt maintainer-makefile
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --no-libtool --macro-prefix=gl alloca c-ctype getopt getpass-gnu maintainer-makefile quote quotearg
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.5 gnits
|
||||
|
||||
@ -34,12 +34,85 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
|
||||
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
|
||||
EXTRA_libgnu_a_SOURCES =
|
||||
|
||||
## begin gnulib module alloca
|
||||
|
||||
|
||||
EXTRA_DIST += alloca.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += alloca.c
|
||||
|
||||
libgnu_a_LIBADD += @ALLOCA@
|
||||
libgnu_a_DEPENDENCIES += @ALLOCA@
|
||||
## end gnulib module alloca
|
||||
|
||||
## begin gnulib module alloca-opt
|
||||
|
||||
BUILT_SOURCES += $(ALLOCA_H)
|
||||
|
||||
# We need the following in order to create <alloca.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
alloca.h: alloca.in.h
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
cat $(srcdir)/alloca.in.h; \
|
||||
} > $@-t
|
||||
mv -f $@-t $@
|
||||
MOSTLYCLEANFILES += alloca.h alloca.h-t
|
||||
|
||||
EXTRA_DIST += alloca.in.h
|
||||
|
||||
## end gnulib module alloca-opt
|
||||
|
||||
## begin gnulib module c-ctype
|
||||
|
||||
libgnu_a_SOURCES += c-ctype.h c-ctype.c
|
||||
|
||||
## end gnulib module c-ctype
|
||||
|
||||
## begin gnulib module error
|
||||
|
||||
|
||||
EXTRA_DIST += error.c error.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += error.c
|
||||
|
||||
## end gnulib module error
|
||||
|
||||
## begin gnulib module exitfail
|
||||
|
||||
|
||||
EXTRA_DIST += exitfail.c exitfail.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += exitfail.c
|
||||
|
||||
## end gnulib module exitfail
|
||||
|
||||
## begin gnulib module fseeko
|
||||
|
||||
|
||||
EXTRA_DIST += fseeko.c stdio-impl.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += fseeko.c
|
||||
|
||||
## end gnulib module fseeko
|
||||
|
||||
## begin gnulib module getdelim
|
||||
|
||||
|
||||
EXTRA_DIST += getdelim.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += getdelim.c
|
||||
|
||||
## end gnulib module getdelim
|
||||
|
||||
## begin gnulib module getline
|
||||
|
||||
|
||||
EXTRA_DIST += getline.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += getline.c
|
||||
|
||||
## end gnulib module getline
|
||||
|
||||
## begin gnulib module getopt
|
||||
|
||||
BUILT_SOURCES += $(GETOPT_H)
|
||||
@ -59,12 +132,38 @@ EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
|
||||
|
||||
## end gnulib module getopt
|
||||
|
||||
## begin gnulib module getpass-gnu
|
||||
|
||||
|
||||
EXTRA_DIST += getpass.c getpass.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += getpass.c
|
||||
|
||||
## end gnulib module getpass-gnu
|
||||
|
||||
## begin gnulib module gettext-h
|
||||
|
||||
libgnu_a_SOURCES += gettext.h
|
||||
|
||||
## end gnulib module gettext-h
|
||||
|
||||
## begin gnulib module gnumakefile
|
||||
|
||||
distclean-local: clean-GNUmakefile
|
||||
clean-GNUmakefile:
|
||||
test x'$(VPATH)' != x && rm -f $(top_builddir)/GNUmakefile || :
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/GNUmakefile
|
||||
|
||||
## end gnulib module gnumakefile
|
||||
|
||||
## begin gnulib module intprops
|
||||
|
||||
|
||||
EXTRA_DIST += intprops.h
|
||||
|
||||
## end gnulib module intprops
|
||||
|
||||
## begin gnulib module link-warning
|
||||
|
||||
LINK_WARNING_H=$(top_srcdir)/./link-warning.h
|
||||
@ -73,12 +172,48 @@ EXTRA_DIST += $(top_srcdir)/./link-warning.h
|
||||
|
||||
## end gnulib module link-warning
|
||||
|
||||
## begin gnulib module lseek
|
||||
|
||||
|
||||
EXTRA_DIST += lseek.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += lseek.c
|
||||
|
||||
## end gnulib module lseek
|
||||
|
||||
## begin gnulib module maintainer-makefile
|
||||
|
||||
EXTRA_DIST += $(top_srcdir)/./GNUmakefile $(top_srcdir)/./maint.mk
|
||||
EXTRA_DIST += $(top_srcdir)/maint.mk
|
||||
|
||||
## end gnulib module maintainer-makefile
|
||||
|
||||
## begin gnulib module quote
|
||||
|
||||
|
||||
EXTRA_DIST += quote.c quote.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += quote.c
|
||||
|
||||
## end gnulib module quote
|
||||
|
||||
## begin gnulib module quotearg
|
||||
|
||||
|
||||
EXTRA_DIST += quotearg.c quotearg.h
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += quotearg.c
|
||||
|
||||
## end gnulib module quotearg
|
||||
|
||||
## begin gnulib module realloc-posix
|
||||
|
||||
|
||||
EXTRA_DIST += realloc.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += realloc.c
|
||||
|
||||
## end gnulib module realloc-posix
|
||||
|
||||
## begin gnulib module stdbool
|
||||
|
||||
BUILT_SOURCES += $(STDBOOL_H)
|
||||
@ -97,6 +232,195 @@ EXTRA_DIST += stdbool.in.h
|
||||
|
||||
## end gnulib module stdbool
|
||||
|
||||
## begin gnulib module stdio
|
||||
|
||||
BUILT_SOURCES += stdio.h
|
||||
|
||||
# We need the following in order to create <stdio.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
stdio.h: stdio.in.h
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
|
||||
-e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
|
||||
-e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
|
||||
-e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
|
||||
-e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
|
||||
-e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
|
||||
-e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
|
||||
-e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
|
||||
-e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
|
||||
-e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
|
||||
-e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
|
||||
-e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
|
||||
-e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
|
||||
-e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
|
||||
-e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
|
||||
-e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
|
||||
-e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
|
||||
-e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
|
||||
-e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
|
||||
-e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
|
||||
-e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
|
||||
-e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
|
||||
-e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
|
||||
-e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
|
||||
-e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
|
||||
-e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
|
||||
-e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
|
||||
-e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
|
||||
-e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
|
||||
-e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
|
||||
-e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
|
||||
-e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
|
||||
-e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
|
||||
-e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
|
||||
-e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
|
||||
-e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
|
||||
-e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
|
||||
-e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
|
||||
-e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
|
||||
-e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
|
||||
-e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
|
||||
-e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
< $(srcdir)/stdio.in.h; \
|
||||
} > $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += stdio.h stdio.h-t
|
||||
|
||||
EXTRA_DIST += stdio.in.h
|
||||
|
||||
## end gnulib module stdio
|
||||
|
||||
## begin gnulib module stdlib
|
||||
|
||||
BUILT_SOURCES += stdlib.h
|
||||
|
||||
# We need the following in order to create <stdlib.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
stdlib.h: stdlib.in.h
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
|
||||
-e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
|
||||
-e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
|
||||
-e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
|
||||
-e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
|
||||
-e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
|
||||
-e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
|
||||
-e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
|
||||
-e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
|
||||
-e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
|
||||
-e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
|
||||
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
|
||||
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
|
||||
-e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
|
||||
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
|
||||
-e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
|
||||
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
|
||||
-e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
|
||||
-e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
|
||||
-e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
|
||||
-e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
|
||||
-e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
|
||||
-e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
|
||||
-e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
|
||||
-e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
|
||||
-e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
< $(srcdir)/stdlib.in.h; \
|
||||
} > $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += stdlib.h stdlib.h-t
|
||||
|
||||
EXTRA_DIST += stdlib.in.h
|
||||
|
||||
## end gnulib module stdlib
|
||||
|
||||
## begin gnulib module strerror
|
||||
|
||||
|
||||
EXTRA_DIST += strerror.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += strerror.c
|
||||
|
||||
## end gnulib module strerror
|
||||
|
||||
## begin gnulib module string
|
||||
|
||||
BUILT_SOURCES += string.h
|
||||
|
||||
# We need the following in order to create <string.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
string.h: string.in.h
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
|
||||
-e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
|
||||
-e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
|
||||
-e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
|
||||
-e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \
|
||||
-e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \
|
||||
-e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \
|
||||
-e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \
|
||||
-e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \
|
||||
-e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \
|
||||
-e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \
|
||||
-e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \
|
||||
-e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \
|
||||
-e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \
|
||||
-e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \
|
||||
-e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \
|
||||
-e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
|
||||
-e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
|
||||
-e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
|
||||
-e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \
|
||||
-e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
|
||||
-e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
|
||||
-e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
|
||||
-e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
|
||||
-e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
|
||||
-e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
|
||||
-e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
|
||||
-e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \
|
||||
-e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \
|
||||
-e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \
|
||||
-e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
|
||||
-e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
|
||||
-e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
|
||||
-e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
|
||||
-e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
|
||||
-e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
|
||||
-e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
|
||||
-e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
|
||||
-e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
|
||||
-e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
|
||||
-e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
|
||||
-e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \
|
||||
-e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
|
||||
-e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
|
||||
-e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
|
||||
-e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
|
||||
-e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
|
||||
-e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
|
||||
-e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
|
||||
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
|
||||
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
|
||||
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
|
||||
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
|
||||
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
|
||||
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
< $(srcdir)/string.in.h; \
|
||||
} > $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += string.h string.h-t
|
||||
|
||||
EXTRA_DIST += string.in.h
|
||||
|
||||
## end gnulib module string
|
||||
|
||||
## begin gnulib module unistd
|
||||
|
||||
BUILT_SOURCES += unistd.h
|
||||
@ -111,6 +435,7 @@ unistd.h: unistd.in.h
|
||||
-e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
|
||||
-e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
|
||||
-e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
|
||||
-e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
|
||||
-e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
|
||||
-e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
|
||||
-e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
|
||||
@ -125,12 +450,14 @@ unistd.h: unistd.in.h
|
||||
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
|
||||
-e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
|
||||
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
|
||||
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
|
||||
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
|
||||
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
|
||||
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
|
||||
-e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
|
||||
-e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
|
||||
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
|
||||
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
|
||||
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
|
||||
-e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
|
||||
< $(srcdir)/unistd.in.h; \
|
||||
@ -142,6 +469,70 @@ EXTRA_DIST += unistd.in.h
|
||||
|
||||
## end gnulib module unistd
|
||||
|
||||
## begin gnulib module wchar
|
||||
|
||||
BUILT_SOURCES += $(WCHAR_H)
|
||||
|
||||
# We need the following in order to create <wchar.h> when the system
|
||||
# version does not work standalone.
|
||||
wchar.h: wchar.in.h
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
|
||||
-e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
|
||||
-e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
|
||||
-e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
|
||||
-e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
|
||||
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
|
||||
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
|
||||
< $(srcdir)/wchar.in.h; \
|
||||
} > $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += wchar.h wchar.h-t
|
||||
|
||||
EXTRA_DIST += wchar.in.h
|
||||
|
||||
## end gnulib module wchar
|
||||
|
||||
## begin gnulib module wctype
|
||||
|
||||
BUILT_SOURCES += $(WCTYPE_H)
|
||||
|
||||
# We need the following in order to create <wctype.h> when the system
|
||||
# doesn't have one that works with the given compiler.
|
||||
wctype.h: wctype.in.h
|
||||
rm -f $@-t $@
|
||||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
|
||||
-e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
|
||||
-e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
|
||||
-e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
|
||||
-e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
|
||||
-e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
|
||||
< $(srcdir)/wctype.in.h; \
|
||||
} > $@-t
|
||||
mv $@-t $@
|
||||
MOSTLYCLEANFILES += wctype.h wctype.h-t
|
||||
|
||||
EXTRA_DIST += wctype.in.h
|
||||
|
||||
## end gnulib module wctype
|
||||
|
||||
## begin gnulib module xalloc
|
||||
|
||||
|
||||
EXTRA_DIST += xalloc.h xmalloc.c
|
||||
|
||||
EXTRA_libgnu_a_SOURCES += xmalloc.c
|
||||
|
||||
## end gnulib module xalloc
|
||||
|
||||
## begin gnulib module xalloc-die
|
||||
|
||||
libgnu_a_SOURCES += xalloc-die.c
|
||||
|
||||
## end gnulib module xalloc-die
|
||||
|
||||
|
||||
mostlyclean-local: mostlyclean-generic
|
||||
@for dir in '' $(MOSTLYCLEANDIRS); do \
|
||||
|
@ -21,21 +21,22 @@
|
||||
allocating any. It is a good idea to use alloca(0) in
|
||||
your main control loop, etc. to force garbage collection. */
|
||||
|
||||
#include "wget.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <alloca.h>
|
||||
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef emacs
|
||||
#include "blockinput.h"
|
||||
# include "lisp.h"
|
||||
# include "blockinput.h"
|
||||
# ifdef EMACS_FREE
|
||||
# undef free
|
||||
# define free EMACS_FREE
|
||||
# endif
|
||||
#else
|
||||
# define memory_full() abort ()
|
||||
#endif
|
||||
|
||||
/* If compiling with GCC 2, this file's not needed. */
|
||||
@ -43,57 +44,33 @@
|
||||
|
||||
/* If someone has defined alloca as a macro,
|
||||
there must be some other way alloca is supposed to work. */
|
||||
#ifndef alloca
|
||||
# ifndef alloca
|
||||
|
||||
#ifdef emacs
|
||||
#ifdef static
|
||||
# ifdef emacs
|
||||
# ifdef static
|
||||
/* actually, only want this if static is defined as ""
|
||||
-- this is for usg, in which emacs must undefine static
|
||||
in order to make unexec workable
|
||||
*/
|
||||
#ifndef STACK_DIRECTION
|
||||
# ifndef STACK_DIRECTION
|
||||
you
|
||||
lose
|
||||
-- must know STACK_DIRECTION at compile-time
|
||||
#endif /* STACK_DIRECTION undefined */
|
||||
#endif /* static */
|
||||
#endif /* emacs */
|
||||
/* Using #error here is not wise since this file should work for
|
||||
old and obscure compilers. */
|
||||
# endif /* STACK_DIRECTION undefined */
|
||||
# endif /* static */
|
||||
# endif /* emacs */
|
||||
|
||||
/* If your stack is a linked list of frames, you have to
|
||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
long i00afunc ();
|
||||
#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
#else
|
||||
#define ADDRESS_FUNCTION(arg) &(arg)
|
||||
#endif
|
||||
|
||||
#if __STDC__
|
||||
typedef void *pointer;
|
||||
#else
|
||||
typedef char *pointer;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
/* Different portions of Emacs need to call different versions of
|
||||
malloc. The Emacs executable needs alloca to call xmalloc, because
|
||||
ordinary malloc isn't protected from input signals. On the other
|
||||
hand, the utilities in lib-src need alloca to call malloc; some of
|
||||
them are very simple, and don't have an xmalloc routine.
|
||||
|
||||
Non-Emacs programs expect this to call xmalloc.
|
||||
|
||||
Callers below should use malloc. */
|
||||
|
||||
#ifndef emacs
|
||||
#define malloc xmalloc
|
||||
#define free xfree
|
||||
#endif
|
||||
extern pointer malloc ();
|
||||
# define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
|
||||
# else
|
||||
# define ADDRESS_FUNCTION(arg) &(arg)
|
||||
# endif
|
||||
|
||||
/* Define STACK_DIRECTION if you know the direction of stack
|
||||
growth for your system; otherwise it will be automatically
|
||||
@ -103,42 +80,42 @@ extern pointer malloc ();
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
|
||||
#ifndef STACK_DIRECTION
|
||||
#define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
#endif
|
||||
# ifndef STACK_DIRECTION
|
||||
# define STACK_DIRECTION 0 /* Direction unknown. */
|
||||
# endif
|
||||
|
||||
#if STACK_DIRECTION != 0
|
||||
# if STACK_DIRECTION != 0
|
||||
|
||||
#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
# define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
|
||||
|
||||
#else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
# else /* STACK_DIRECTION == 0; need run-time code. */
|
||||
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
#define STACK_DIR stack_dir
|
||||
static int stack_dir; /* 1 or -1 once known. */
|
||||
# define STACK_DIR stack_dir
|
||||
|
||||
static void
|
||||
find_stack_direction ()
|
||||
find_stack_direction (void)
|
||||
{
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
static char *addr = NULL; /* Address of first `dummy', once known. */
|
||||
auto char dummy; /* To get stack address. */
|
||||
|
||||
if (addr == NULL)
|
||||
{ /* Initial entry. */
|
||||
{ /* Initial entry. */
|
||||
addr = ADDRESS_FUNCTION (dummy);
|
||||
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
find_stack_direction (); /* Recurse once. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second entry. */
|
||||
if (ADDRESS_FUNCTION (dummy) > addr)
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
stack_dir = 1; /* Stack grew upward. */
|
||||
else
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
stack_dir = -1; /* Stack grew downward. */
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* STACK_DIRECTION == 0 */
|
||||
# endif /* STACK_DIRECTION == 0 */
|
||||
|
||||
/* An "alloca header" is used to:
|
||||
(a) chain together all alloca'ed blocks;
|
||||
@ -147,21 +124,21 @@ find_stack_direction ()
|
||||
It is very important that sizeof(header) agree with malloc
|
||||
alignment chunk size. The following default should work okay. */
|
||||
|
||||
#ifndef ALIGN_SIZE
|
||||
#define ALIGN_SIZE sizeof(double)
|
||||
#endif
|
||||
# ifndef ALIGN_SIZE
|
||||
# define ALIGN_SIZE sizeof(double)
|
||||
# endif
|
||||
|
||||
typedef union hdr
|
||||
{
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
char align[ALIGN_SIZE]; /* To force sizeof(header). */
|
||||
struct
|
||||
{
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
union hdr *next; /* For chaining headers. */
|
||||
char *deep; /* For stack depth measure. */
|
||||
} h;
|
||||
} header;
|
||||
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
|
||||
/* Return a pointer to at least SIZE bytes of storage,
|
||||
which will be automatically reclaimed upon exit from
|
||||
@ -170,87 +147,92 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */
|
||||
caller, but that method cannot be made to work for some
|
||||
implementations of C, for example under Gould's UTX/32. */
|
||||
|
||||
pointer
|
||||
alloca (size)
|
||||
unsigned size;
|
||||
void *
|
||||
alloca (size_t size)
|
||||
{
|
||||
auto char probe; /* Probes stack depth: */
|
||||
auto char probe; /* Probes stack depth: */
|
||||
register char *depth = ADDRESS_FUNCTION (probe);
|
||||
|
||||
#if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
# if STACK_DIRECTION == 0
|
||||
if (STACK_DIR == 0) /* Unknown growth direction. */
|
||||
find_stack_direction ();
|
||||
#endif
|
||||
# endif
|
||||
|
||||
/* Reclaim garbage, defined as all alloca'd storage that
|
||||
was allocated from deeper in the stack than currently. */
|
||||
|
||||
{
|
||||
register header *hp; /* Traverses linked list. */
|
||||
register header *hp; /* Traverses linked list. */
|
||||
|
||||
#ifdef emacs
|
||||
# ifdef emacs
|
||||
BLOCK_INPUT;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
for (hp = last_alloca_header; hp != NULL;)
|
||||
if ((STACK_DIR > 0 && hp->h.deep > depth)
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|| (STACK_DIR < 0 && hp->h.deep < depth))
|
||||
{
|
||||
register header *np = hp->h.next;
|
||||
|
||||
free ((pointer) hp); /* Collect garbage. */
|
||||
free (hp); /* Collect garbage. */
|
||||
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
hp = np; /* -> next header. */
|
||||
}
|
||||
else
|
||||
break; /* Rest are not deeper. */
|
||||
break; /* Rest are not deeper. */
|
||||
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
last_alloca_header = hp; /* -> last valid storage. */
|
||||
|
||||
#ifdef emacs
|
||||
# ifdef emacs
|
||||
UNBLOCK_INPUT;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
|
||||
if (size == 0)
|
||||
return NULL; /* No allocation required. */
|
||||
return NULL; /* No allocation required. */
|
||||
|
||||
/* Allocate combined header + user data storage. */
|
||||
|
||||
{
|
||||
register pointer new = malloc (sizeof (header) + size);
|
||||
/* Address of header. */
|
||||
register header *new;
|
||||
|
||||
if (new == 0)
|
||||
abort();
|
||||
size_t combined_size = sizeof (header) + size;
|
||||
if (combined_size < sizeof (header))
|
||||
memory_full ();
|
||||
|
||||
((header *) new)->h.next = last_alloca_header;
|
||||
((header *) new)->h.deep = depth;
|
||||
new = malloc (combined_size);
|
||||
|
||||
last_alloca_header = (header *) new;
|
||||
if (! new)
|
||||
memory_full ();
|
||||
|
||||
new->h.next = last_alloca_header;
|
||||
new->h.deep = depth;
|
||||
|
||||
last_alloca_header = new;
|
||||
|
||||
/* User storage begins just after header. */
|
||||
|
||||
return (pointer) ((char *) new + sizeof (header));
|
||||
return (void *) (new + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
# if defined (CRAY) && defined (CRAY_STACKSEG_END)
|
||||
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
# include <stdio.h>
|
||||
# endif
|
||||
|
||||
#ifndef CRAY_STACK
|
||||
#define CRAY_STACK
|
||||
#ifndef CRAY2
|
||||
# ifndef CRAY_STACK
|
||||
# define CRAY_STACK
|
||||
# ifndef CRAY2
|
||||
/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
|
||||
struct stack_control_header
|
||||
{
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
long shgrow:32; /* Number of times stack has grown. */
|
||||
long shaseg:32; /* Size of increments to stack. */
|
||||
long shhwm:32; /* High water mark of stack. */
|
||||
long shsize:32; /* Current size of stack (all segments). */
|
||||
};
|
||||
|
||||
/* The stack segment linkage control information occurs at
|
||||
@ -262,21 +244,21 @@ struct stack_control_header
|
||||
|
||||
struct stack_segment_linkage
|
||||
{
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long ss[0200]; /* 0200 overflow words. */
|
||||
long sssize:32; /* Number of words in this segment. */
|
||||
long ssbase:32; /* Offset to stack base. */
|
||||
long:32;
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long sspseg:32; /* Offset to linkage control of previous
|
||||
segment of stack. */
|
||||
long:32;
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long sstcpt:32; /* Pointer to task common address block. */
|
||||
long sscsnm; /* Private control structure number for
|
||||
microtasking. */
|
||||
long ssusr1; /* Reserved for user. */
|
||||
long ssusr2; /* Reserved for user. */
|
||||
long sstpid; /* Process ID for pid based multi-tasking. */
|
||||
long ssgvup; /* Pointer to multitasking thread giveup. */
|
||||
long sscray[7]; /* Reserved for Cray Research. */
|
||||
long ssa0;
|
||||
long ssa1;
|
||||
long ssa2;
|
||||
@ -295,32 +277,32 @@ struct stack_segment_linkage
|
||||
long sss7;
|
||||
};
|
||||
|
||||
#else /* CRAY2 */
|
||||
# else /* CRAY2 */
|
||||
/* The following structure defines the vector of words
|
||||
returned by the STKSTAT library routine. */
|
||||
struct stk_stat
|
||||
{
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
long now; /* Current total stack size. */
|
||||
long maxc; /* Amount of contiguous space which would
|
||||
be required to satisfy the maximum
|
||||
stack demand to date. */
|
||||
long high_water; /* Stack high-water mark. */
|
||||
long overflows; /* Number of stack overflow ($STKOFEN) calls. */
|
||||
long hits; /* Number of internal buffer hits. */
|
||||
long extends; /* Number of block extensions. */
|
||||
long stko_mallocs; /* Block allocations by $STKOFEN. */
|
||||
long underflows; /* Number of stack underflow calls ($STKRETN). */
|
||||
long stko_free; /* Number of deallocations by $STKRETN. */
|
||||
long stkm_free; /* Number of deallocations by $STKMRET. */
|
||||
long segments; /* Current number of stack segments. */
|
||||
long maxs; /* Maximum number of stack segments so far. */
|
||||
long pad_size; /* Stack pad size. */
|
||||
long current_address; /* Current stack segment address. */
|
||||
long current_size; /* Current stack segment size. This
|
||||
number is actually corrupted by STKSTAT to
|
||||
include the fifteen word trailer area. */
|
||||
long initial_address; /* Address of initial segment. */
|
||||
long initial_size; /* Size of initial segment. */
|
||||
};
|
||||
|
||||
/* The following structure describes the data structure which trails
|
||||
@ -329,13 +311,13 @@ struct stk_stat
|
||||
|
||||
struct stk_trailer
|
||||
{
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long this_address; /* Address of this block. */
|
||||
long this_size; /* Size of this block (does not include
|
||||
this trailer). */
|
||||
long unknown2;
|
||||
long unknown3;
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long link; /* Address of trailer block of previous
|
||||
segment. */
|
||||
long unknown5;
|
||||
long unknown6;
|
||||
long unknown7;
|
||||
@ -348,10 +330,10 @@ struct stk_trailer
|
||||
long unknown14;
|
||||
};
|
||||
|
||||
#endif /* CRAY2 */
|
||||
#endif /* not CRAY_STACK */
|
||||
# endif /* CRAY2 */
|
||||
# endif /* not CRAY_STACK */
|
||||
|
||||
#ifdef CRAY2
|
||||
# ifdef CRAY2
|
||||
/* Determine a "stack measure" for an arbitrary ADDRESS.
|
||||
I doubt that "lint" will like this much. */
|
||||
|
||||
@ -373,8 +355,8 @@ i00afunc (long *address)
|
||||
/* Set up the iteration. */
|
||||
|
||||
trailer = (struct stk_trailer *) (status.current_address
|
||||
+ status.current_size
|
||||
- 15);
|
||||
+ status.current_size
|
||||
- 15);
|
||||
|
||||
/* There must be at least one stack segment. Therefore it is
|
||||
a fatal error if "trailer" is null. */
|
||||
@ -389,10 +371,10 @@ i00afunc (long *address)
|
||||
block = (long *) trailer->this_address;
|
||||
size = trailer->this_size;
|
||||
if (block == 0 || size == 0)
|
||||
abort ();
|
||||
abort ();
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
if ((block <= address) && (address < (block + size)))
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Set the result to the offset in this segment and add the sizes
|
||||
@ -408,7 +390,7 @@ i00afunc (long *address)
|
||||
do
|
||||
{
|
||||
if (trailer->this_size <= 0)
|
||||
abort ();
|
||||
abort ();
|
||||
result += trailer->this_size;
|
||||
trailer = (struct stk_trailer *) trailer->link;
|
||||
}
|
||||
@ -422,7 +404,7 @@ i00afunc (long *address)
|
||||
return (result);
|
||||
}
|
||||
|
||||
#else /* not CRAY2 */
|
||||
# else /* not CRAY2 */
|
||||
/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
|
||||
Determine the number of the cell within the stack,
|
||||
given the address of the cell. The purpose of this
|
||||
@ -467,11 +449,11 @@ i00afunc (long address)
|
||||
|
||||
while (!(this_segment <= address && address <= stkl))
|
||||
{
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
|
||||
#endif
|
||||
# endif
|
||||
if (pseg == 0)
|
||||
break;
|
||||
break;
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
@ -488,9 +470,9 @@ i00afunc (long address)
|
||||
|
||||
while (pseg != 0)
|
||||
{
|
||||
#ifdef DEBUG_I00AFUNC
|
||||
# ifdef DEBUG_I00AFUNC
|
||||
fprintf (stderr, "%011o %011o\n", pseg, size);
|
||||
#endif
|
||||
# endif
|
||||
stkl = stkl - pseg;
|
||||
ssptr = (struct stack_segment_linkage *) stkl;
|
||||
size = ssptr->sssize;
|
||||
@ -500,8 +482,8 @@ i00afunc (long address)
|
||||
return (result);
|
||||
}
|
||||
|
||||
#endif /* not CRAY2 */
|
||||
#endif /* CRAY */
|
||||
# endif /* not CRAY2 */
|
||||
# endif /* CRAY */
|
||||
|
||||
#endif /* no alloca */
|
||||
#endif /* not GCC version 2 */
|
||||
# endif /* no alloca */
|
||||
#endif /* not GCC version 3 */
|
56
lib/alloca.in.h
Normal file
56
lib/alloca.in.h
Normal file
@ -0,0 +1,56 @@
|
||||
/* Memory allocation on the stack.
|
||||
|
||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published
|
||||
by the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
USA. */
|
||||
|
||||
/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
|
||||
means there is a real alloca function. */
|
||||
#ifndef _GL_ALLOCA_H
|
||||
#define _GL_ALLOCA_H
|
||||
|
||||
/* alloca (N) returns a pointer to N bytes of memory
|
||||
allocated on the stack, which will last until the function returns.
|
||||
Use of alloca should be avoided:
|
||||
- inside arguments of function calls - undefined behaviour,
|
||||
- in inline functions - the allocation may actually last until the
|
||||
calling function returns,
|
||||
- for huge N (say, N >= 65536) - you never know how large (or small)
|
||||
the stack is, and when the stack cannot fulfill the memory allocation
|
||||
request, the program just crashes.
|
||||
*/
|
||||
|
||||
#ifndef alloca
|
||||
# ifdef __GNUC__
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined _AIX
|
||||
# define alloca __alloca
|
||||
# elif defined _MSC_VER
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined __DECC && defined __VMS
|
||||
# define alloca __ALLOCA
|
||||
# else
|
||||
# include <stddef.h>
|
||||
# ifdef __cplusplus
|
||||
extern "C"
|
||||
# endif
|
||||
void *alloca (size_t);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* _GL_ALLOCA_H */
|
338
lib/error.c
Normal file
338
lib/error.c
Normal file
@ -0,0 +1,338 @@
|
||||
/* Error handler for noninteractive utilities
|
||||
Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !_LIBC && ENABLE_NLS
|
||||
# include "gettext.h"
|
||||
# define _(msgid) gettext (msgid)
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
# include <stdbool.h>
|
||||
# include <stdint.h>
|
||||
# include <wchar.h>
|
||||
# define mbsrtowcs __mbsrtowcs
|
||||
#endif
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
# define _(String) String
|
||||
#endif
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
void (*error_print_progname) (void);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
unsigned int error_message_count;
|
||||
|
||||
#ifdef _LIBC
|
||||
/* In the GNU C library, there is a predefined variable for this. */
|
||||
|
||||
# define program_name program_invocation_name
|
||||
# include <errno.h>
|
||||
# include <limits.h>
|
||||
# include <libio/libioP.h>
|
||||
|
||||
/* In GNU libc we want do not want to use the common name `error' directly.
|
||||
Instead make it a weak alias. */
|
||||
extern void __error (int status, int errnum, const char *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message,
|
||||
...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||
# define error __error
|
||||
# define error_at_line __error_at_line
|
||||
|
||||
# include <libio/iolibio.h>
|
||||
# define fflush(s) INTUSE(_IO_fflush) (s)
|
||||
# undef putc
|
||||
# define putc(c, fp) INTUSE(_IO_putc) (c, fp)
|
||||
|
||||
# include <bits/libc-lock.h>
|
||||
|
||||
#else /* not _LIBC */
|
||||
|
||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||
# ifndef HAVE_DECL_STRERROR_R
|
||||
"this configure-time declaration test was not run"
|
||||
# endif
|
||||
char *strerror_r ();
|
||||
# endif
|
||||
|
||||
/* The calling program should define program_name and set it to the
|
||||
name of the executing program. */
|
||||
extern char *program_name;
|
||||
|
||||
# if HAVE_STRERROR_R || defined strerror_r
|
||||
# define __strerror_r strerror_r
|
||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||
#endif /* not _LIBC */
|
||||
|
||||
static void
|
||||
print_errno_message (int errnum)
|
||||
{
|
||||
char const *s;
|
||||
|
||||
#if defined HAVE_STRERROR_R || _LIBC
|
||||
char errbuf[1024];
|
||||
# if STRERROR_R_CHAR_P || _LIBC
|
||||
s = __strerror_r (errnum, errbuf, sizeof errbuf);
|
||||
# else
|
||||
if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0)
|
||||
s = errbuf;
|
||||
else
|
||||
s = 0;
|
||||
# endif
|
||||
#else
|
||||
s = strerror (errnum);
|
||||
#endif
|
||||
|
||||
#if !_LIBC
|
||||
if (! s)
|
||||
s = _("Unknown system error");
|
||||
#endif
|
||||
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, ": %s", s);
|
||||
#else
|
||||
fprintf (stderr, ": %s", s);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
error_tail (int status, int errnum, const char *message, va_list args)
|
||||
{
|
||||
#if _LIBC
|
||||
if (_IO_fwide (stderr, 0) > 0)
|
||||
{
|
||||
# define ALLOCA_LIMIT 2000
|
||||
size_t len = strlen (message) + 1;
|
||||
wchar_t *wmessage = NULL;
|
||||
mbstate_t st;
|
||||
size_t res;
|
||||
const char *tmp;
|
||||
bool use_malloc = false;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||
else
|
||||
{
|
||||
if (!use_malloc)
|
||||
wmessage = NULL;
|
||||
|
||||
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||
len * sizeof (wchar_t));
|
||||
if (p == NULL)
|
||||
{
|
||||
free (wmessage);
|
||||
fputws_unlocked (L"out of memory\n", stderr);
|
||||
return;
|
||||
}
|
||||
wmessage = p;
|
||||
use_malloc = true;
|
||||
}
|
||||
|
||||
memset (&st, '\0', sizeof (st));
|
||||
tmp = message;
|
||||
|
||||
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||
if (res != len)
|
||||
break;
|
||||
|
||||
if (__builtin_expect (len >= SIZE_MAX / 2, 0))
|
||||
{
|
||||
/* This really should not happen if everything is fine. */
|
||||
res = (size_t) -1;
|
||||
break;
|
||||
}
|
||||
|
||||
len *= 2;
|
||||
}
|
||||
|
||||
if (res == (size_t) -1)
|
||||
{
|
||||
/* The string cannot be converted. */
|
||||
if (use_malloc)
|
||||
{
|
||||
free (wmessage);
|
||||
use_malloc = false;
|
||||
}
|
||||
wmessage = (wchar_t *) L"???";
|
||||
}
|
||||
|
||||
__vfwprintf (stderr, wmessage, args);
|
||||
|
||||
if (use_malloc)
|
||||
free (wmessage);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
vfprintf (stderr, message, args);
|
||||
va_end (args);
|
||||
|
||||
++error_message_count;
|
||||
if (errnum)
|
||||
print_errno_message (errnum);
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, "\n");
|
||||
#else
|
||||
putc ('\n', stderr);
|
||||
#endif
|
||||
fflush (stderr);
|
||||
if (status)
|
||||
exit (status);
|
||||
}
|
||||
|
||||
|
||||
/* Print the program name and error message MESSAGE, which is a printf-style
|
||||
format string with optional args.
|
||||
If ERRNUM is nonzero, print its corresponding system error message.
|
||||
Exit with status STATUS if it is nonzero. */
|
||||
void
|
||||
error (int status, int errnum, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, "%s: ", program_name);
|
||||
#else
|
||||
fprintf (stderr, "%s: ", program_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
int error_one_per_line;
|
||||
|
||||
void
|
||||
error_at_line (int status, int errnum, const char *file_name,
|
||||
unsigned int line_number, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (error_one_per_line)
|
||||
{
|
||||
static const char *old_file_name;
|
||||
static unsigned int old_line_number;
|
||||
|
||||
if (old_line_number == line_number
|
||||
&& (file_name == old_file_name
|
||||
|| strcmp (old_file_name, file_name) == 0))
|
||||
/* Simply return and print nothing. */
|
||||
return;
|
||||
|
||||
old_file_name = file_name;
|
||||
old_line_number = line_number;
|
||||
}
|
||||
|
||||
#if defined _LIBC && defined __libc_ptf_call
|
||||
/* We do not want this call to be cut short by a thread
|
||||
cancellation. Therefore disable cancellation for now. */
|
||||
int state = PTHREAD_CANCEL_ENABLE;
|
||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||
0);
|
||||
#endif
|
||||
|
||||
fflush (stdout);
|
||||
#ifdef _LIBC
|
||||
_IO_flockfile (stderr);
|
||||
#endif
|
||||
if (error_print_progname)
|
||||
(*error_print_progname) ();
|
||||
else
|
||||
{
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, "%s:", program_name);
|
||||
#else
|
||||
fprintf (stderr, "%s:", program_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if _LIBC
|
||||
__fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
|
||||
file_name, line_number);
|
||||
#else
|
||||
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
|
||||
file_name, line_number);
|
||||
#endif
|
||||
|
||||
va_start (args, message);
|
||||
error_tail (status, errnum, message, args);
|
||||
|
||||
#ifdef _LIBC
|
||||
_IO_funlockfile (stderr);
|
||||
# ifdef __libc_ptf_call
|
||||
__libc_ptf_call (pthread_setcancelstate, (state, NULL), 0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _LIBC
|
||||
/* Make the weak alias. */
|
||||
# undef error
|
||||
# undef error_at_line
|
||||
weak_alias (__error, error)
|
||||
weak_alias (__error_at_line, error_at_line)
|
||||
#endif
|
65
lib/error.h
Normal file
65
lib/error.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* Declaration for error-reporting function
|
||||
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _ERROR_H
|
||||
#define _ERROR_H 1
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Print a message with `fprintf (stderr, FORMAT, ...)';
|
||||
if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
|
||||
If STATUS is nonzero, terminate the program with `exit (STATUS)'. */
|
||||
|
||||
extern void error (int __status, int __errnum, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
extern void error_at_line (int __status, int __errnum, const char *__fname,
|
||||
unsigned int __lineno, const char *__format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||
|
||||
/* If NULL, error will flush stdout, then print on stderr the program
|
||||
name, a colon and a space. Otherwise, error will call this
|
||||
function without parameters instead. */
|
||||
extern void (*error_print_progname) (void);
|
||||
|
||||
/* This variable is incremented each time `error' is called. */
|
||||
extern unsigned int error_message_count;
|
||||
|
||||
/* Sometimes we want to have at most one error per line. This
|
||||
variable controls whether this mode is selected or not. */
|
||||
extern int error_one_per_line;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* error.h */
|
24
lib/exitfail.c
Normal file
24
lib/exitfail.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "exitfail.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int volatile exit_failure = EXIT_FAILURE;
|
18
lib/exitfail.h
Normal file
18
lib/exitfail.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* Failure exit status
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
extern int volatile exit_failure;
|
113
lib/fseeko.c
Normal file
113
lib/fseeko.c
Normal file
@ -0,0 +1,113 @@
|
||||
/* An fseeko() function that, together with fflush(), is POSIX compliant.
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <stdio.h>
|
||||
|
||||
/* Get off_t and lseek. */
|
||||
#include <unistd.h>
|
||||
|
||||
#include "stdio-impl.h"
|
||||
|
||||
#undef fseeko
|
||||
#if !HAVE_FSEEKO
|
||||
# undef fseek
|
||||
# define fseeko fseek
|
||||
#endif
|
||||
|
||||
int
|
||||
rpl_fseeko (FILE *fp, off_t offset, int whence)
|
||||
{
|
||||
#if LSEEK_PIPE_BROKEN
|
||||
/* mingw gives bogus answers rather than failure on non-seekable files. */
|
||||
if (lseek (fileno (fp), 0, SEEK_CUR) == -1)
|
||||
return EOF;
|
||||
#endif
|
||||
|
||||
/* These tests are based on fpurge.c. */
|
||||
#if defined _IO_ferror_unlocked || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Linux libc5 */
|
||||
if (fp->_IO_read_end == fp->_IO_read_ptr
|
||||
&& fp->_IO_write_ptr == fp->_IO_write_base
|
||||
&& fp->_IO_save_base == NULL)
|
||||
#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
|
||||
# if defined __SL64 && defined __SCLE /* Cygwin */
|
||||
if ((fp->_flags & __SL64) == 0)
|
||||
{
|
||||
/* Cygwin 1.5.0 through 1.5.24 failed to open stdin in 64-bit
|
||||
mode; but has an fseeko that requires 64-bit mode. */
|
||||
FILE *tmp = fopen ("/dev/null", "r");
|
||||
if (!tmp)
|
||||
return -1;
|
||||
fp->_flags |= __SL64;
|
||||
fp->_seek64 = tmp->_seek64;
|
||||
fclose (tmp);
|
||||
}
|
||||
# endif
|
||||
if (fp_->_p == fp_->_bf._base
|
||||
&& fp_->_r == 0
|
||||
&& fp_->_w == ((fp_->_flags & (__SLBF | __SNBF | __SRD)) == 0 /* fully buffered and not currently reading? */
|
||||
? fp_->_bf._size
|
||||
: 0)
|
||||
&& fp_ub._base == NULL)
|
||||
#elif defined __EMX__ /* emx+gcc */
|
||||
if (fp->_ptr == fp->_buffer
|
||||
&& fp->_rcount == 0
|
||||
&& fp->_wcount == 0
|
||||
&& fp->_ungetc_count == 0)
|
||||
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
|
||||
if (fp_->_ptr == fp_->_base
|
||||
&& (fp_->_ptr == NULL || fp_->_cnt == 0))
|
||||
#elif defined __UCLIBC__ /* uClibc */
|
||||
if (((fp->__modeflags & __FLAG_WRITING) == 0
|
||||
|| fp->__bufpos == fp->__bufstart)
|
||||
&& ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0
|
||||
|| fp->__bufpos == fp->__bufread))
|
||||
#elif defined __QNX__ /* QNX */
|
||||
if ((fp->_Mode & _MWRITE ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
|
||||
&& fp->_Rback == fp->_Back + sizeof (fp->_Back)
|
||||
&& fp->_Rsave == NULL)
|
||||
#else
|
||||
#error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib."
|
||||
#endif
|
||||
{
|
||||
off_t pos = lseek (fileno (fp), offset, whence);
|
||||
if (pos == -1)
|
||||
{
|
||||
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
|
||||
fp_->_flags &= ~__SOFF;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
|
||||
fp_->_offset = pos;
|
||||
fp_->_flags |= __SOFF;
|
||||
fp_->_flags &= ~__SEOF;
|
||||
#elif defined __EMX__ /* emx+gcc */
|
||||
fp->_flags &= ~_IOEOF;
|
||||
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
|
||||
fp->_flag &= ~_IOEOF;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
return fseeko (fp, offset, whence);
|
||||
}
|
130
lib/getdelim.c
Normal file
130
lib/getdelim.c
Normal file
@ -0,0 +1,130 @@
|
||||
/* getdelim.c --- Implementation of replacement getdelim function.
|
||||
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 2008 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 3, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
/* Ported from glibc by Simon Josefsson. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
#ifndef SSIZE_MAX
|
||||
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
||||
#endif
|
||||
#if !HAVE_FLOCKFILE
|
||||
# undef flockfile
|
||||
# define flockfile(x) ((void) 0)
|
||||
#endif
|
||||
#if !HAVE_FUNLOCKFILE
|
||||
# undef funlockfile
|
||||
# define funlockfile(x) ((void) 0)
|
||||
#endif
|
||||
|
||||
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
||||
NUL-terminate it). *LINEPTR is a pointer returned from malloc (or
|
||||
NULL), pointing to *N characters of space. It is realloc'ed as
|
||||
necessary. Returns the number of characters read (not including
|
||||
the null terminator), or -1 on error or EOF. */
|
||||
|
||||
ssize_t
|
||||
getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||
{
|
||||
ssize_t result;
|
||||
size_t cur_len = 0;
|
||||
|
||||
if (lineptr == NULL || n == NULL || fp == NULL)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
flockfile (fp);
|
||||
|
||||
if (*lineptr == NULL || *n == 0)
|
||||
{
|
||||
char *new_lineptr;
|
||||
*n = 120;
|
||||
new_lineptr = (char *) realloc (*lineptr, *n);
|
||||
if (new_lineptr == NULL)
|
||||
{
|
||||
result = -1;
|
||||
goto unlock_return;
|
||||
}
|
||||
*lineptr = new_lineptr;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = getc (fp);
|
||||
if (i == EOF)
|
||||
{
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make enough space for len+1 (for final NUL) bytes. */
|
||||
if (cur_len + 1 >= *n)
|
||||
{
|
||||
size_t needed_max =
|
||||
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
|
||||
size_t needed = 2 * *n + 1; /* Be generous. */
|
||||
char *new_lineptr;
|
||||
|
||||
if (needed_max < needed)
|
||||
needed = needed_max;
|
||||
if (cur_len + 1 >= needed)
|
||||
{
|
||||
result = -1;
|
||||
errno = EOVERFLOW;
|
||||
goto unlock_return;
|
||||
}
|
||||
|
||||
new_lineptr = (char *) realloc (*lineptr, needed);
|
||||
if (new_lineptr == NULL)
|
||||
{
|
||||
result = -1;
|
||||
goto unlock_return;
|
||||
}
|
||||
|
||||
*lineptr = new_lineptr;
|
||||
*n = needed;
|
||||
}
|
||||
|
||||
(*lineptr)[cur_len] = i;
|
||||
cur_len++;
|
||||
|
||||
if (i == delimiter)
|
||||
break;
|
||||
}
|
||||
(*lineptr)[cur_len] = '\0';
|
||||
result = cur_len ? cur_len : result;
|
||||
|
||||
unlock_return:
|
||||
funlockfile (fp); /* doesn't set errno */
|
||||
|
||||
return result;
|
||||
}
|
29
lib/getline.c
Normal file
29
lib/getline.c
Normal file
@ -0,0 +1,29 @@
|
||||
/* getline.c --- Implementation of replacement getline function.
|
||||
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 3, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301, USA. */
|
||||
|
||||
/* Written by Simon Josefsson. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
ssize_t
|
||||
getline (char **lineptr, size_t *n, FILE *stream)
|
||||
{
|
||||
return getdelim (lineptr, n, '\n', stream);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
NOTE: getopt is now part of the C library, so if you don't know what
|
||||
"Keep this file name-space clean" means, talk to drepper@gnu.org
|
||||
before changing it!
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006
|
||||
Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -30,10 +30,6 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __VMS
|
||||
# include <unixlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <libintl.h>
|
||||
#else
|
||||
|
231
lib/getpass.c
Normal file
231
lib/getpass.c
Normal file
@ -0,0 +1,231 @@
|
||||
/* Copyright (C) 1992-2001, 2003, 2004, 2005, 2006, 2007 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _LIBC
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "getpass.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#if HAVE_DECL___FSETLOCKING && HAVE___FSETLOCKING
|
||||
# if HAVE_STDIO_EXT_H
|
||||
# include <stdio_ext.h>
|
||||
# endif
|
||||
#else
|
||||
# define __fsetlocking(stream, type) /* empty */
|
||||
#endif
|
||||
|
||||
#if HAVE_TERMIOS_H
|
||||
# include <termios.h>
|
||||
#endif
|
||||
|
||||
#if USE_UNLOCKED_IO
|
||||
# include "unlocked-io.h"
|
||||
#else
|
||||
# if !HAVE_DECL_FFLUSH_UNLOCKED
|
||||
# undef fflush_unlocked
|
||||
# define fflush_unlocked(x) fflush (x)
|
||||
# endif
|
||||
# if !HAVE_DECL_FLOCKFILE
|
||||
# undef flockfile
|
||||
# define flockfile(x) ((void) 0)
|
||||
# endif
|
||||
# if !HAVE_DECL_FUNLOCKFILE
|
||||
# undef funlockfile
|
||||
# define funlockfile(x) ((void) 0)
|
||||
# endif
|
||||
# if !HAVE_DECL_FPUTS_UNLOCKED
|
||||
# undef fputs_unlocked
|
||||
# define fputs_unlocked(str,stream) fputs (str, stream)
|
||||
# endif
|
||||
# if !HAVE_DECL_PUTC_UNLOCKED
|
||||
# undef putc_unlocked
|
||||
# define putc_unlocked(c,stream) putc (c, stream)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* It is desirable to use this bit on systems that have it.
|
||||
The only bit of terminal state we want to twiddle is echoing, which is
|
||||
done in software; there is no need to change the state of the terminal
|
||||
hardware. */
|
||||
|
||||
#ifndef TCSASOFT
|
||||
# define TCSASOFT 0
|
||||
#endif
|
||||
|
||||
static void
|
||||
call_fclose (void *arg)
|
||||
{
|
||||
if (arg != NULL)
|
||||
fclose (arg);
|
||||
}
|
||||
|
||||
char *
|
||||
getpass (const char *prompt)
|
||||
{
|
||||
FILE *tty;
|
||||
FILE *in, *out;
|
||||
struct termios s, t;
|
||||
bool tty_changed = false;
|
||||
static char *buf;
|
||||
static size_t bufsize;
|
||||
ssize_t nread;
|
||||
|
||||
/* Try to write to and read from the terminal if we can.
|
||||
If we can't open the terminal, use stderr and stdin. */
|
||||
|
||||
tty = fopen ("/dev/tty", "w+");
|
||||
if (tty == NULL)
|
||||
{
|
||||
in = stdin;
|
||||
out = stderr;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We do the locking ourselves. */
|
||||
__fsetlocking (tty, FSETLOCKING_BYCALLER);
|
||||
|
||||
out = in = tty;
|
||||
}
|
||||
|
||||
flockfile (out);
|
||||
|
||||
/* Turn echoing off if it is on now. */
|
||||
#if HAVE_TCGETATTR
|
||||
if (tcgetattr (fileno (in), &t) == 0)
|
||||
{
|
||||
/* Save the old one. */
|
||||
s = t;
|
||||
/* Tricky, tricky. */
|
||||
t.c_lflag &= ~(ECHO | ISIG);
|
||||
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &t) == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Write the prompt. */
|
||||
fputs_unlocked (prompt, out);
|
||||
fflush_unlocked (out);
|
||||
|
||||
/* Read the password. */
|
||||
nread = getline (&buf, &bufsize, in);
|
||||
|
||||
/* According to the C standard, input may not be followed by output
|
||||
on the same stream without an intervening call to a file
|
||||
positioning function. Suppose in == out; then without this fseek
|
||||
call, on Solaris, HP-UX, AIX, OSF/1, the previous input gets
|
||||
echoed, whereas on IRIX, the following newline is not output as
|
||||
it should be. POSIX imposes similar restrictions if fileno (in)
|
||||
== fileno (out). The POSIX restrictions are tricky and change
|
||||
from POSIX version to POSIX version, so play it safe and invoke
|
||||
fseek even if in != out. */
|
||||
fseeko (out, 0, SEEK_CUR);
|
||||
|
||||
if (buf != NULL)
|
||||
{
|
||||
if (nread < 0)
|
||||
buf[0] = '\0';
|
||||
else if (buf[nread - 1] == '\n')
|
||||
{
|
||||
/* Remove the newline. */
|
||||
buf[nread - 1] = '\0';
|
||||
if (tty_changed)
|
||||
{
|
||||
/* Write the newline that was not echoed. */
|
||||
putc_unlocked ('\n', out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Restore the original setting. */
|
||||
#if HAVE_TCSETATTR
|
||||
if (tty_changed)
|
||||
tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &s);
|
||||
#endif
|
||||
|
||||
funlockfile (out);
|
||||
|
||||
call_fclose (tty);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
#else /* W32 native */
|
||||
|
||||
/* Windows implementation by Martin Lambers <marlam@marlam.de>,
|
||||
improved by Simon Josefsson. */
|
||||
|
||||
/* For PASS_MAX. */
|
||||
#include <limits.h>
|
||||
/* For _getch(). */
|
||||
#include <conio.h>
|
||||
/* For strdup(). */
|
||||
#include <string.h>
|
||||
|
||||
#ifndef PASS_MAX
|
||||
# define PASS_MAX 512
|
||||
#endif
|
||||
|
||||
char *
|
||||
getpass (const char *prompt)
|
||||
{
|
||||
char getpassbuf[PASS_MAX + 1];
|
||||
size_t i = 0;
|
||||
int c;
|
||||
|
||||
if (prompt)
|
||||
{
|
||||
fputs (prompt, stderr);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
c = _getch ();
|
||||
if (c == '\r')
|
||||
{
|
||||
getpassbuf[i] = '\0';
|
||||
break;
|
||||
}
|
||||
else if (i < PASS_MAX)
|
||||
{
|
||||
getpassbuf[i++] = c;
|
||||
}
|
||||
|
||||
if (i >= PASS_MAX)
|
||||
{
|
||||
getpassbuf[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prompt)
|
||||
{
|
||||
fputs ("\r\n", stderr);
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
return strdup (getpassbuf);
|
||||
}
|
||||
#endif
|
31
lib/getpass.h
Normal file
31
lib/getpass.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* getpass.h -- Read a password of arbitrary length from /dev/tty or stdin.
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Contributed by Simon Josefsson <jas@extundo.com>, 2004.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef GETPASS_H
|
||||
# define GETPASS_H
|
||||
|
||||
/* Get getpass declaration, if available. */
|
||||
# include <unistd.h>
|
||||
|
||||
# if defined HAVE_DECL_GETPASS && !HAVE_DECL_GETPASS
|
||||
/* Read a password of arbitrary length from /dev/tty or stdin. */
|
||||
char *getpass (const char *prompt);
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* GETPASS_H */
|
77
lib/intprops.h
Normal file
77
lib/intprops.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* intprops.h -- properties of integer types
|
||||
|
||||
Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert. */
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
/* The extra casts in the following macros work around compiler bugs,
|
||||
e.g., in Cray C 5.0.3.0. */
|
||||
|
||||
/* True if the arithmetic type T is an integer type. bool counts as
|
||||
an integer. */
|
||||
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
|
||||
|
||||
/* True if negative values of the signed integer type T use two's
|
||||
complement, ones' complement, or signed magnitude representation,
|
||||
respectively. Much GNU code assumes two's complement, but some
|
||||
people like to be portable to all possible C hosts. */
|
||||
#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
|
||||
#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
|
||||
#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
|
||||
|
||||
/* True if the arithmetic type T is signed. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
|
||||
/* The maximum and minimum values for the integer type T. These
|
||||
macros have undefined behavior if T is signed and has padding bits.
|
||||
If this is a problem for you, please let us know how to fix it for
|
||||
your host. */
|
||||
#define TYPE_MINIMUM(t) \
|
||||
((t) (! TYPE_SIGNED (t) \
|
||||
? (t) 0 \
|
||||
: TYPE_SIGNED_MAGNITUDE (t) \
|
||||
? ~ (t) 0 \
|
||||
: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
|
||||
#define TYPE_MAXIMUM(t) \
|
||||
((t) (! TYPE_SIGNED (t) \
|
||||
? (t) -1 \
|
||||
: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
|
||||
|
||||
/* Return zero if T can be determined to be an unsigned type.
|
||||
Otherwise, return 1.
|
||||
When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
|
||||
tighter bound. Otherwise, it overestimates the true bound by one byte
|
||||
when applied to unsigned types of size 2, 4, 16, ... bytes.
|
||||
The symbol signed_type_or_expr__ is private to this header file. */
|
||||
#if __GNUC__ >= 2
|
||||
# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
|
||||
#else
|
||||
# define signed_type_or_expr__(t) 1
|
||||
#endif
|
||||
|
||||
/* Bound on length of the string representing an integer type or expression T.
|
||||
Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485;
|
||||
add 1 for integer division truncation; add 1 more for a minus sign
|
||||
if needed. */
|
||||
#define INT_STRLEN_BOUND(t) \
|
||||
((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \
|
||||
+ signed_type_or_expr__ (t) + 1)
|
||||
|
||||
/* Bound on buffer size needed to represent an integer type or expression T,
|
||||
including the terminating null. */
|
||||
#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
|
62
lib/lseek.c
Normal file
62
lib/lseek.c
Normal file
@ -0,0 +1,62 @@
|
||||
/* An lseek() function that detects pipes.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include <unistd.h>
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* Windows platforms. */
|
||||
/* Get GetFileType. */
|
||||
# include <windows.h>
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
||||
#undef lseek
|
||||
|
||||
off_t
|
||||
rpl_lseek (int fd, off_t offset, int whence)
|
||||
{
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
/* mingw lseek mistakenly succeeds on pipes, sockets, and terminals. */
|
||||
HANDLE h = (HANDLE) _get_osfhandle (fd);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
if (GetFileType (h) != FILE_TYPE_DISK)
|
||||
{
|
||||
errno = ESPIPE;
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
/* BeOS lseek mistakenly succeeds on pipes... */
|
||||
struct stat statbuf;
|
||||
if (fstat (fd, &statbuf) < 0)
|
||||
return -1;
|
||||
if (!S_ISREG (statbuf.st_mode))
|
||||
{
|
||||
errno = ESPIPE;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return lseek (fd, offset, whence);
|
||||
}
|
40
lib/quote.c
Normal file
40
lib/quote.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* quote.c - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "quotearg.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* Return an unambiguous printable representation of NAME,
|
||||
allocated in slot N, suitable for diagnostics. */
|
||||
char const *
|
||||
quote_n (int n, char const *name)
|
||||
{
|
||||
return quotearg_n_style (n, locale_quoting_style, name);
|
||||
}
|
||||
|
||||
/* Return an unambiguous printable representation of NAME,
|
||||
suitable for diagnostics. */
|
||||
char const *
|
||||
quote (char const *name)
|
||||
{
|
||||
return quote_n (0, name);
|
||||
}
|
21
lib/quote.h
Normal file
21
lib/quote.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* quote.h - prototypes for quote.c
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
char const *quote_n (int n, char const *name);
|
||||
char const *quote (char const *name);
|
816
lib/quotearg.c
Normal file
816
lib/quotearg.c
Normal file
@ -0,0 +1,816 @@
|
||||
/* quotearg.c - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007,
|
||||
2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "quotearg.h"
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
#define N_(msgid) msgid
|
||||
|
||||
#if !HAVE_MBRTOWC
|
||||
/* Disable multibyte processing entirely. Since MB_CUR_MAX is 1, the
|
||||
other macros are defined only for documentation and to satisfy C
|
||||
syntax. */
|
||||
# undef MB_CUR_MAX
|
||||
# define MB_CUR_MAX 1
|
||||
# undef mbstate_t
|
||||
# define mbstate_t int
|
||||
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
|
||||
# define iswprint(wc) isprint ((unsigned char) (wc))
|
||||
# undef HAVE_MBSINIT
|
||||
#endif
|
||||
|
||||
#if !defined mbsinit && !HAVE_MBSINIT
|
||||
# define mbsinit(ps) 1
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
#define INT_BITS (sizeof (int) * CHAR_BIT)
|
||||
|
||||
struct quoting_options
|
||||
{
|
||||
/* Basic quoting style. */
|
||||
enum quoting_style style;
|
||||
|
||||
/* Additional flags. Bitwise combination of enum quoting_flags. */
|
||||
int flags;
|
||||
|
||||
/* Quote the characters indicated by this bit vector even if the
|
||||
quoting style would not normally require them to be quoted. */
|
||||
unsigned int quote_these_too[(UCHAR_MAX / INT_BITS) + 1];
|
||||
};
|
||||
|
||||
/* Names of quoting styles. */
|
||||
char const *const quoting_style_args[] =
|
||||
{
|
||||
"literal",
|
||||
"shell",
|
||||
"shell-always",
|
||||
"c",
|
||||
"c-maybe",
|
||||
"escape",
|
||||
"locale",
|
||||
"clocale",
|
||||
0
|
||||
};
|
||||
|
||||
/* Correspondences to quoting style names. */
|
||||
enum quoting_style const quoting_style_vals[] =
|
||||
{
|
||||
literal_quoting_style,
|
||||
shell_quoting_style,
|
||||
shell_always_quoting_style,
|
||||
c_quoting_style,
|
||||
c_maybe_quoting_style,
|
||||
escape_quoting_style,
|
||||
locale_quoting_style,
|
||||
clocale_quoting_style
|
||||
};
|
||||
|
||||
/* The default quoting options. */
|
||||
static struct quoting_options default_quoting_options;
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *
|
||||
clone_quoting_options (struct quoting_options *o)
|
||||
{
|
||||
int e = errno;
|
||||
struct quoting_options *p = xmemdup (o ? o : &default_quoting_options,
|
||||
sizeof *o);
|
||||
errno = e;
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style
|
||||
get_quoting_style (struct quoting_options *o)
|
||||
{
|
||||
return (o ? o : &default_quoting_options)->style;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void
|
||||
set_quoting_style (struct quoting_options *o, enum quoting_style s)
|
||||
{
|
||||
(o ? o : &default_quoting_options)->style = s;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int
|
||||
set_char_quoting (struct quoting_options *o, char c, int i)
|
||||
{
|
||||
unsigned char uc = c;
|
||||
unsigned int *p =
|
||||
(o ? o : &default_quoting_options)->quote_these_too + uc / INT_BITS;
|
||||
int shift = uc % INT_BITS;
|
||||
int r = (*p >> shift) & 1;
|
||||
*p ^= ((i & 1) ^ r) << shift;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options flag to I, which can be a
|
||||
bitwise combination of enum quoting_flags, or 0 for default
|
||||
behavior. Return the old value. */
|
||||
int
|
||||
set_quoting_flags (struct quoting_options *o, int i)
|
||||
{
|
||||
int r;
|
||||
if (!o)
|
||||
o = &default_quoting_options;
|
||||
r = o->flags;
|
||||
o->flags = i;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Return quoting options for STYLE, with no extra quoting. */
|
||||
static struct quoting_options
|
||||
quoting_options_from_style (enum quoting_style style)
|
||||
{
|
||||
struct quoting_options o;
|
||||
o.style = style;
|
||||
o.flags = 0;
|
||||
memset (o.quote_these_too, 0, sizeof o.quote_these_too);
|
||||
return o;
|
||||
}
|
||||
|
||||
/* MSGID approximates a quotation mark. Return its translation if it
|
||||
has one; otherwise, return either it or "\"", depending on S. */
|
||||
static char const *
|
||||
gettext_quote (char const *msgid, enum quoting_style s)
|
||||
{
|
||||
char const *translation = _(msgid);
|
||||
if (translation == msgid && s == clocale_quoting_style)
|
||||
translation = "\"";
|
||||
return translation;
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using QUOTING_STYLE, FLAGS, and
|
||||
QUOTE_THESE_TOO to control quoting.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE.
|
||||
|
||||
This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG,
|
||||
ARGSIZE, O), except it breaks O into its component pieces and is
|
||||
not careful about errno. */
|
||||
|
||||
static size_t
|
||||
quotearg_buffer_restyled (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
enum quoting_style quoting_style, int flags,
|
||||
unsigned int const *quote_these_too)
|
||||
{
|
||||
size_t i;
|
||||
size_t len = 0;
|
||||
char const *quote_string = 0;
|
||||
size_t quote_string_len = 0;
|
||||
bool backslash_escapes = false;
|
||||
bool unibyte_locale = MB_CUR_MAX == 1;
|
||||
bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0;
|
||||
|
||||
#define STORE(c) \
|
||||
do \
|
||||
{ \
|
||||
if (len < buffersize) \
|
||||
buffer[len] = (c); \
|
||||
len++; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
switch (quoting_style)
|
||||
{
|
||||
case c_maybe_quoting_style:
|
||||
quoting_style = c_quoting_style;
|
||||
elide_outer_quotes = true;
|
||||
/* Fall through. */
|
||||
case c_quoting_style:
|
||||
if (!elide_outer_quotes)
|
||||
STORE ('"');
|
||||
backslash_escapes = true;
|
||||
quote_string = "\"";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case escape_quoting_style:
|
||||
backslash_escapes = true;
|
||||
elide_outer_quotes = false;
|
||||
break;
|
||||
|
||||
case locale_quoting_style:
|
||||
case clocale_quoting_style:
|
||||
{
|
||||
/* TRANSLATORS:
|
||||
Get translations for open and closing quotation marks.
|
||||
|
||||
The message catalog should translate "`" to a left
|
||||
quotation mark suitable for the locale, and similarly for
|
||||
"'". If the catalog has no translation,
|
||||
locale_quoting_style quotes `like this', and
|
||||
clocale_quoting_style quotes "like this".
|
||||
|
||||
For example, an American English Unicode locale should
|
||||
translate "`" to U+201C (LEFT DOUBLE QUOTATION MARK), and
|
||||
should translate "'" to U+201D (RIGHT DOUBLE QUOTATION
|
||||
MARK). A British English Unicode locale should instead
|
||||
translate these to U+2018 (LEFT SINGLE QUOTATION MARK) and
|
||||
U+2019 (RIGHT SINGLE QUOTATION MARK), respectively.
|
||||
|
||||
If you don't know what to put here, please see
|
||||
<http://en.wikipedia.org/wiki/Quotation_mark#Glyphs>
|
||||
and use glyphs suitable for your language. */
|
||||
|
||||
char const *left = gettext_quote (N_("`"), quoting_style);
|
||||
char const *right = gettext_quote (N_("'"), quoting_style);
|
||||
if (!elide_outer_quotes)
|
||||
for (quote_string = left; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
backslash_escapes = true;
|
||||
quote_string = right;
|
||||
quote_string_len = strlen (quote_string);
|
||||
}
|
||||
break;
|
||||
|
||||
case shell_quoting_style:
|
||||
quoting_style = shell_always_quoting_style;
|
||||
elide_outer_quotes = true;
|
||||
/* Fall through. */
|
||||
case shell_always_quoting_style:
|
||||
if (!elide_outer_quotes)
|
||||
STORE ('\'');
|
||||
quote_string = "'";
|
||||
quote_string_len = 1;
|
||||
break;
|
||||
|
||||
case literal_quoting_style:
|
||||
elide_outer_quotes = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
for (i = 0; ! (argsize == SIZE_MAX ? arg[i] == '\0' : i == argsize); i++)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned char esc;
|
||||
|
||||
if (backslash_escapes
|
||||
&& quote_string_len
|
||||
&& i + quote_string_len <= argsize
|
||||
&& memcmp (arg + i, quote_string, quote_string_len) == 0)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
}
|
||||
|
||||
c = arg[i];
|
||||
switch (c)
|
||||
{
|
||||
case '\0':
|
||||
if (backslash_escapes)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
if (i + 1 < argsize && '0' <= arg[i + 1] && arg[i + 1] <= '9')
|
||||
{
|
||||
STORE ('0');
|
||||
STORE ('0');
|
||||
}
|
||||
c = '0';
|
||||
}
|
||||
else if (flags & QA_ELIDE_NULL_BYTES)
|
||||
continue;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
switch (quoting_style)
|
||||
{
|
||||
case shell_always_quoting_style:
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
break;
|
||||
|
||||
case c_quoting_style:
|
||||
if ((flags & QA_SPLIT_TRIGRAPHS)
|
||||
&& i + 2 < argsize && arg[i + 1] == '?')
|
||||
switch (arg[i + 2])
|
||||
{
|
||||
case '!': case '\'':
|
||||
case '(': case ')': case '-': case '/':
|
||||
case '<': case '=': case '>':
|
||||
/* Escape the second '?' in what would otherwise be
|
||||
a trigraph. */
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
c = arg[i + 2];
|
||||
i += 2;
|
||||
STORE ('?');
|
||||
STORE ('"');
|
||||
STORE ('"');
|
||||
STORE ('?');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\a': esc = 'a'; goto c_escape;
|
||||
case '\b': esc = 'b'; goto c_escape;
|
||||
case '\f': esc = 'f'; goto c_escape;
|
||||
case '\n': esc = 'n'; goto c_and_shell_escape;
|
||||
case '\r': esc = 'r'; goto c_and_shell_escape;
|
||||
case '\t': esc = 't'; goto c_and_shell_escape;
|
||||
case '\v': esc = 'v'; goto c_escape;
|
||||
case '\\': esc = c;
|
||||
/* No need to escape the escape if we are trying to elide
|
||||
outer quotes and nothing else is problematic. */
|
||||
if (backslash_escapes && elide_outer_quotes && quote_string_len)
|
||||
goto store_c;
|
||||
|
||||
c_and_shell_escape:
|
||||
if (quoting_style == shell_always_quoting_style
|
||||
&& elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
/* Fall through. */
|
||||
c_escape:
|
||||
if (backslash_escapes)
|
||||
{
|
||||
c = esc;
|
||||
goto store_escape;
|
||||
}
|
||||
break;
|
||||
|
||||
case '{': case '}': /* sometimes special if isolated */
|
||||
if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1))
|
||||
break;
|
||||
/* Fall through. */
|
||||
case '#': case '~':
|
||||
if (i != 0)
|
||||
break;
|
||||
/* Fall through. */
|
||||
case ' ':
|
||||
case '!': /* special in bash */
|
||||
case '"': case '$': case '&':
|
||||
case '(': case ')': case '*': case ';':
|
||||
case '<':
|
||||
case '=': /* sometimes special in 0th or (with "set -k") later args */
|
||||
case '>': case '[':
|
||||
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
|
||||
case '`': case '|':
|
||||
/* A shell special character. In theory, '$' and '`' could
|
||||
be the first bytes of multibyte characters, which means
|
||||
we should check them with mbrtowc, but in practice this
|
||||
doesn't happen so it's not worth worrying about. */
|
||||
if (quoting_style == shell_always_quoting_style
|
||||
&& elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
if (quoting_style == shell_always_quoting_style)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\'');
|
||||
STORE ('\\');
|
||||
STORE ('\'');
|
||||
}
|
||||
break;
|
||||
|
||||
case '%': case '+': case ',': case '-': case '.': case '/':
|
||||
case '0': case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9': case ':':
|
||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
||||
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
|
||||
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
|
||||
case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
|
||||
case 'Y': case 'Z': case ']': case '_': case 'a': case 'b':
|
||||
case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
||||
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
|
||||
case 'o': case 'p': case 'q': case 'r': case 's': case 't':
|
||||
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
|
||||
/* These characters don't cause problems, no matter what the
|
||||
quoting style is. They cannot start multibyte sequences. */
|
||||
break;
|
||||
|
||||
default:
|
||||
/* If we have a multibyte sequence, copy it until we reach
|
||||
its end, find an error, or come back to the initial shift
|
||||
state. For C-like styles, if the sequence has
|
||||
unprintable characters, escape the whole sequence, since
|
||||
we can't easily escape single characters within it. */
|
||||
{
|
||||
/* Length of multibyte sequence found so far. */
|
||||
size_t m;
|
||||
|
||||
bool printable;
|
||||
|
||||
if (unibyte_locale)
|
||||
{
|
||||
m = 1;
|
||||
printable = isprint (c) != 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mbstate_t mbstate;
|
||||
memset (&mbstate, 0, sizeof mbstate);
|
||||
|
||||
m = 0;
|
||||
printable = true;
|
||||
if (argsize == SIZE_MAX)
|
||||
argsize = strlen (arg);
|
||||
|
||||
do
|
||||
{
|
||||
wchar_t w;
|
||||
size_t bytes = mbrtowc (&w, &arg[i + m],
|
||||
argsize - (i + m), &mbstate);
|
||||
if (bytes == 0)
|
||||
break;
|
||||
else if (bytes == (size_t) -1)
|
||||
{
|
||||
printable = false;
|
||||
break;
|
||||
}
|
||||
else if (bytes == (size_t) -2)
|
||||
{
|
||||
printable = false;
|
||||
while (i + m < argsize && arg[i + m])
|
||||
m++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Work around a bug with older shells that "see" a '\'
|
||||
that is really the 2nd byte of a multibyte character.
|
||||
In practice the problem is limited to ASCII
|
||||
chars >= '@' that are shell special chars. */
|
||||
if ('[' == 0x5b && elide_outer_quotes
|
||||
&& quoting_style == shell_always_quoting_style)
|
||||
{
|
||||
size_t j;
|
||||
for (j = 1; j < bytes; j++)
|
||||
switch (arg[i + m + j])
|
||||
{
|
||||
case '[': case '\\': case '^':
|
||||
case '`': case '|':
|
||||
goto force_outer_quoting_style;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! iswprint (w))
|
||||
printable = false;
|
||||
m += bytes;
|
||||
}
|
||||
}
|
||||
while (! mbsinit (&mbstate));
|
||||
}
|
||||
|
||||
if (1 < m || (backslash_escapes && ! printable))
|
||||
{
|
||||
/* Output a multibyte sequence, or an escaped
|
||||
unprintable unibyte character. */
|
||||
size_t ilim = i + m;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (backslash_escapes && ! printable)
|
||||
{
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
STORE ('0' + (c >> 6));
|
||||
STORE ('0' + ((c >> 3) & 7));
|
||||
c = '0' + (c & 7);
|
||||
}
|
||||
if (ilim <= i + 1)
|
||||
break;
|
||||
STORE (c);
|
||||
c = arg[++i];
|
||||
}
|
||||
|
||||
goto store_c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! ((backslash_escapes || elide_outer_quotes)
|
||||
&& quote_these_too
|
||||
&& quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))))
|
||||
goto store_c;
|
||||
|
||||
store_escape:
|
||||
if (elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
STORE ('\\');
|
||||
|
||||
store_c:
|
||||
STORE (c);
|
||||
}
|
||||
|
||||
if (len == 0 && quoting_style == shell_always_quoting_style
|
||||
&& elide_outer_quotes)
|
||||
goto force_outer_quoting_style;
|
||||
|
||||
if (quote_string && !elide_outer_quotes)
|
||||
for (; *quote_string; quote_string++)
|
||||
STORE (*quote_string);
|
||||
|
||||
if (len < buffersize)
|
||||
buffer[len] = '\0';
|
||||
return len;
|
||||
|
||||
force_outer_quoting_style:
|
||||
/* Don't reuse quote_these_too, since the addition of outer quotes
|
||||
sufficiently quotes the specified characters. */
|
||||
return quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
quoting_style,
|
||||
flags & ~QA_ELIDE_OUTER_QUOTES, NULL);
|
||||
}
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is SIZE_MAX, use the string length of the argument for
|
||||
ARGSIZE. */
|
||||
size_t
|
||||
quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
int e = errno;
|
||||
size_t r = quotearg_buffer_restyled (buffer, buffersize, arg, argsize,
|
||||
p->style, p->flags, p->quote_these_too);
|
||||
errno = e;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Equivalent to quotearg_alloc (ARG, ARGSIZE, NULL, O). */
|
||||
char *
|
||||
quotearg_alloc (char const *arg, size_t argsize,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
return quotearg_alloc_mem (arg, argsize, NULL, o);
|
||||
}
|
||||
|
||||
/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly
|
||||
allocated storage containing the quoted string, and store the
|
||||
resulting size into *SIZE, if non-NULL. The result can contain
|
||||
embedded null bytes only if ARGSIZE is not SIZE_MAX, SIZE is not
|
||||
NULL, and set_quoting_flags has not set the null byte elision
|
||||
flag. */
|
||||
char *
|
||||
quotearg_alloc_mem (char const *arg, size_t argsize, size_t *size,
|
||||
struct quoting_options const *o)
|
||||
{
|
||||
struct quoting_options const *p = o ? o : &default_quoting_options;
|
||||
int e = errno;
|
||||
/* Elide embedded null bytes if we can't return a size. */
|
||||
int flags = p->flags | (size ? 0 : QA_ELIDE_NULL_BYTES);
|
||||
size_t bufsize = quotearg_buffer_restyled (0, 0, arg, argsize, p->style,
|
||||
flags, p->quote_these_too) + 1;
|
||||
char *buf = xcharalloc (bufsize);
|
||||
quotearg_buffer_restyled (buf, bufsize, arg, argsize, p->style, flags,
|
||||
p->quote_these_too);
|
||||
errno = e;
|
||||
if (size)
|
||||
*size = bufsize - 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* A storage slot with size and pointer to a value. */
|
||||
struct slotvec
|
||||
{
|
||||
size_t size;
|
||||
char *val;
|
||||
};
|
||||
|
||||
/* Preallocate a slot 0 buffer, so that the caller can always quote
|
||||
one small component of a "memory exhausted" message in slot 0. */
|
||||
static char slot0[256];
|
||||
static unsigned int nslots = 1;
|
||||
static struct slotvec slotvec0 = {sizeof slot0, slot0};
|
||||
static struct slotvec *slotvec = &slotvec0;
|
||||
|
||||
void
|
||||
quotearg_free (void)
|
||||
{
|
||||
struct slotvec *sv = slotvec;
|
||||
unsigned int i;
|
||||
for (i = 1; i < nslots; i++)
|
||||
free (sv[i].val);
|
||||
if (sv[0].val != slot0)
|
||||
{
|
||||
free (sv[0].val);
|
||||
slotvec0.size = sizeof slot0;
|
||||
slotvec0.val = slot0;
|
||||
}
|
||||
if (sv != &slotvec0)
|
||||
{
|
||||
free (sv);
|
||||
slotvec = &slotvec0;
|
||||
}
|
||||
nslots = 1;
|
||||
}
|
||||
|
||||
/* Use storage slot N to return a quoted version of argument ARG.
|
||||
ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a
|
||||
null-terminated string.
|
||||
OPTIONS specifies the quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. N is deliberately declared with type "int"
|
||||
to allow for future extensions (using negative values). */
|
||||
static char *
|
||||
quotearg_n_options (int n, char const *arg, size_t argsize,
|
||||
struct quoting_options const *options)
|
||||
{
|
||||
int e = errno;
|
||||
|
||||
unsigned int n0 = n;
|
||||
struct slotvec *sv = slotvec;
|
||||
|
||||
if (n < 0)
|
||||
abort ();
|
||||
|
||||
if (nslots <= n0)
|
||||
{
|
||||
/* FIXME: technically, the type of n1 should be `unsigned int',
|
||||
but that evokes an unsuppressible warning from gcc-4.0.1 and
|
||||
older. If gcc ever provides an option to suppress that warning,
|
||||
revert to the original type, so that the test in xalloc_oversized
|
||||
is once again performed only at compile time. */
|
||||
size_t n1 = n0 + 1;
|
||||
bool preallocated = (sv == &slotvec0);
|
||||
|
||||
if (xalloc_oversized (n1, sizeof *sv))
|
||||
xalloc_die ();
|
||||
|
||||
slotvec = sv = xrealloc (preallocated ? NULL : sv, n1 * sizeof *sv);
|
||||
if (preallocated)
|
||||
*sv = slotvec0;
|
||||
memset (sv + nslots, 0, (n1 - nslots) * sizeof *sv);
|
||||
nslots = n1;
|
||||
}
|
||||
|
||||
{
|
||||
size_t size = sv[n].size;
|
||||
char *val = sv[n].val;
|
||||
/* Elide embedded null bytes since we don't return a size. */
|
||||
int flags = options->flags | QA_ELIDE_NULL_BYTES;
|
||||
size_t qsize = quotearg_buffer_restyled (val, size, arg, argsize,
|
||||
options->style, flags,
|
||||
options->quote_these_too);
|
||||
|
||||
if (size <= qsize)
|
||||
{
|
||||
sv[n].size = size = qsize + 1;
|
||||
if (val != slot0)
|
||||
free (val);
|
||||
sv[n].val = val = xcharalloc (size);
|
||||
quotearg_buffer_restyled (val, size, arg, argsize, options->style,
|
||||
flags, options->quote_these_too);
|
||||
}
|
||||
|
||||
errno = e;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n (int n, char const *arg)
|
||||
{
|
||||
return quotearg_n_options (n, arg, SIZE_MAX, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_mem (int n, char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_n_options (n, arg, argsize, &default_quoting_options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg (char const *arg)
|
||||
{
|
||||
return quotearg_n (0, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_mem (char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_n_mem (0, arg, argsize);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style (int n, enum quoting_style s, char const *arg)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, SIZE_MAX, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize)
|
||||
{
|
||||
struct quoting_options const o = quoting_options_from_style (s);
|
||||
return quotearg_n_options (n, arg, argsize, &o);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style (enum quoting_style s, char const *arg)
|
||||
{
|
||||
return quotearg_n_style (0, s, arg);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_style_mem (enum quoting_style s, char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_n_style_mem (0, s, arg, argsize);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char_mem (char const *arg, size_t argsize, char ch)
|
||||
{
|
||||
struct quoting_options options;
|
||||
options = default_quoting_options;
|
||||
set_char_quoting (&options, ch, 1);
|
||||
return quotearg_n_options (0, arg, argsize, &options);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_char (char const *arg, char ch)
|
||||
{
|
||||
return quotearg_char_mem (arg, SIZE_MAX, ch);
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon (char const *arg)
|
||||
{
|
||||
return quotearg_char (arg, ':');
|
||||
}
|
||||
|
||||
char *
|
||||
quotearg_colon_mem (char const *arg, size_t argsize)
|
||||
{
|
||||
return quotearg_char_mem (arg, argsize, ':');
|
||||
}
|
305
lib/quotearg.h
Normal file
305
lib/quotearg.h
Normal file
@ -0,0 +1,305 @@
|
||||
/* quotearg.h - quote arguments for output
|
||||
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2006, 2008 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paul Eggert <eggert@twinsun.com> */
|
||||
|
||||
#ifndef QUOTEARG_H_
|
||||
# define QUOTEARG_H_ 1
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
/* Basic quoting styles. For each style, an example is given on the
|
||||
input strings "simple", "\0 \t\n'\"\033?""?/\\", and "a:b", using
|
||||
quotearg_buffer, quotearg_mem, and quotearg_colon_mem with that
|
||||
style and the default flags and quoted characters. Note that the
|
||||
examples are shown here as valid C strings rather than what
|
||||
displays on a terminal (with "??/" as a trigraph for "\\"). */
|
||||
enum quoting_style
|
||||
{
|
||||
/* Output names as-is (ls --quoting-style=literal). Can result in
|
||||
embedded null bytes if QA_ELIDE_NULL_BYTES is not in
|
||||
effect.
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "\0 \t\n'\"\033??/\\", "a:b"
|
||||
quotearg:
|
||||
"simple", " \t\n'\"\033??/\\", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", " \t\n'\"\033??/\\", "a:b"
|
||||
*/
|
||||
literal_quoting_style,
|
||||
|
||||
/* Quote names for the shell if they contain shell metacharacters
|
||||
or would cause ambiguous output (ls --quoting-style=shell).
|
||||
Can result in embedded null bytes if QA_ELIDE_NULL_BYTES is not
|
||||
in effect.
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "'\0 \t\n'\\''\"\033??/\\'", "a:b"
|
||||
quotearg:
|
||||
"simple", "' \t\n'\\''\"\033??/\\'", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", "' \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
*/
|
||||
shell_quoting_style,
|
||||
|
||||
/* Quote names for the shell, even if they would normally not
|
||||
require quoting (ls --quoting-style=shell-always). Can result
|
||||
in embedded null bytes if QA_ELIDE_NULL_BYTES is not in effect.
|
||||
Behaves like shell_quoting_style if QA_ELIDE_OUTER_QUOTES is in
|
||||
effect.
|
||||
|
||||
quotearg_buffer:
|
||||
"'simple'", "'\0 \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
quotearg:
|
||||
"'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
quotearg_colon:
|
||||
"'simple'", "' \t\n'\\''\"\033??/\\'", "'a:b'"
|
||||
*/
|
||||
shell_always_quoting_style,
|
||||
|
||||
/* Quote names as for a C language string (ls --quoting-style=c).
|
||||
Behaves like c_maybe_quoting_style if QA_ELIDE_OUTER_QUOTES is
|
||||
in effect. Split into consecutive strings if
|
||||
QA_SPLIT_TRIGRAPHS.
|
||||
|
||||
quotearg_buffer:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg_colon:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
|
||||
*/
|
||||
c_quoting_style,
|
||||
|
||||
/* Like c_quoting_style except omit the surrounding double-quote
|
||||
characters if no quoted characters are encountered.
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
|
||||
quotearg:
|
||||
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
*/
|
||||
c_maybe_quoting_style,
|
||||
|
||||
/* Like c_quoting_style except always omit the surrounding
|
||||
double-quote characters (ls --quoting-style=escape).
|
||||
|
||||
quotearg_buffer:
|
||||
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
|
||||
quotearg:
|
||||
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a:b"
|
||||
quotearg_colon:
|
||||
"simple", "\\0 \\t\\n'\"\\033??/\\\\", "a\\:b"
|
||||
*/
|
||||
escape_quoting_style,
|
||||
|
||||
/* Like clocale_quoting_style, but quote `like this' instead of
|
||||
"like this" in the default C locale (ls --quoting-style=locale).
|
||||
|
||||
LC_MESSAGES=C
|
||||
quotearg_buffer:
|
||||
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
|
||||
quotearg:
|
||||
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a:b'"
|
||||
quotearg_colon:
|
||||
"`simple'", "`\\0 \\t\\n\\'\"\\033??/\\\\'", "`a\\:b'"
|
||||
|
||||
LC_MESSAGES=pt_PT.utf8
|
||||
quotearg_buffer:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg_colon:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
|
||||
*/
|
||||
locale_quoting_style,
|
||||
|
||||
/* Like c_quoting_style except use quotation marks appropriate for
|
||||
the locale (ls --quoting-style=clocale).
|
||||
|
||||
LC_MESSAGES=C
|
||||
quotearg_buffer:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a:b\""
|
||||
quotearg_colon:
|
||||
"\"simple\"", "\"\\0 \\t\\n'\\\"\\033??/\\\\\"", "\"a\\:b\""
|
||||
|
||||
LC_MESSAGES=pt_PT.utf8
|
||||
quotearg_buffer:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a:b\302\273"
|
||||
quotearg_colon:
|
||||
"\302\253simple\302\273",
|
||||
"\302\253\\0 \\t\\n'\"\\033??/\\\\\302\253", "\302\253a\\:b\302\273"
|
||||
*/
|
||||
clocale_quoting_style
|
||||
};
|
||||
|
||||
/* Flags for use in set_quoting_flags. */
|
||||
enum quoting_flags
|
||||
{
|
||||
/* Always elide null bytes from styles that do not quote them,
|
||||
even when the length of the result is available to the
|
||||
caller. */
|
||||
QA_ELIDE_NULL_BYTES = 0x01,
|
||||
|
||||
/* Omit the surrounding quote characters if no escaped characters
|
||||
are encountered. Note that if no other character needs
|
||||
escaping, then neither does the escape character. */
|
||||
QA_ELIDE_OUTER_QUOTES = 0x02,
|
||||
|
||||
/* In the c_quoting_style and c_maybe_quoting_style, split ANSI
|
||||
trigraph sequences into concatenated strings (for example,
|
||||
"?""?/" rather than "??/", which could be confused with
|
||||
"\\"). */
|
||||
QA_SPLIT_TRIGRAPHS = 0x04
|
||||
};
|
||||
|
||||
/* For now, --quoting-style=literal is the default, but this may change. */
|
||||
# ifndef DEFAULT_QUOTING_STYLE
|
||||
# define DEFAULT_QUOTING_STYLE literal_quoting_style
|
||||
# endif
|
||||
|
||||
/* Names of quoting styles and their corresponding values. */
|
||||
extern char const *const quoting_style_args[];
|
||||
extern enum quoting_style const quoting_style_vals[];
|
||||
|
||||
struct quoting_options;
|
||||
|
||||
/* The functions listed below set and use a hidden variable
|
||||
that contains the default quoting style options. */
|
||||
|
||||
/* Allocate a new set of quoting options, with contents initially identical
|
||||
to O if O is not null, or to the default if O is null.
|
||||
It is the caller's responsibility to free the result. */
|
||||
struct quoting_options *clone_quoting_options (struct quoting_options *o);
|
||||
|
||||
/* Get the value of O's quoting style. If O is null, use the default. */
|
||||
enum quoting_style get_quoting_style (struct quoting_options *o);
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting style to S. */
|
||||
void set_quoting_style (struct quoting_options *o, enum quoting_style s);
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options for character C to I.
|
||||
Return the old value. Currently, the only values defined for I are
|
||||
0 (the default) and 1 (which means to quote the character even if
|
||||
it would not otherwise be quoted). */
|
||||
int set_char_quoting (struct quoting_options *o, char c, int i);
|
||||
|
||||
/* In O (or in the default if O is null),
|
||||
set the value of the quoting options flag to I, which can be a
|
||||
bitwise combination of enum quoting_flags, or 0 for default
|
||||
behavior. Return the old value. */
|
||||
int set_quoting_flags (struct quoting_options *o, int i);
|
||||
|
||||
/* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of
|
||||
argument ARG (of size ARGSIZE), using O to control quoting.
|
||||
If O is null, use the default.
|
||||
Terminate the output with a null character, and return the written
|
||||
size of the output, not counting the terminating null.
|
||||
If BUFFERSIZE is too small to store the output string, return the
|
||||
value that would have been returned had BUFFERSIZE been large enough.
|
||||
If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
|
||||
On output, BUFFER might contain embedded null bytes if ARGSIZE was
|
||||
not -1, the style of O does not use backslash escapes, and the
|
||||
flags of O do not request elision of null bytes.*/
|
||||
size_t quotearg_buffer (char *buffer, size_t buffersize,
|
||||
char const *arg, size_t argsize,
|
||||
struct quoting_options const *o);
|
||||
|
||||
/* Like quotearg_buffer, except return the result in a newly allocated
|
||||
buffer. It is the caller's responsibility to free the result. The
|
||||
result will not contain embedded null bytes. */
|
||||
char *quotearg_alloc (char const *arg, size_t argsize,
|
||||
struct quoting_options const *o);
|
||||
|
||||
/* Like quotearg_alloc, except that the length of the result,
|
||||
excluding the terminating null byte, is stored into SIZE if it is
|
||||
non-NULL. The result might contain embedded null bytes if ARGSIZE
|
||||
was not -1, SIZE was not NULL, the style of O does not use
|
||||
backslash escapes, and the flags of O do not request elision of
|
||||
null bytes.*/
|
||||
char *quotearg_alloc_mem (char const *arg, size_t argsize,
|
||||
size_t *size, struct quoting_options const *o);
|
||||
|
||||
/* Use storage slot N to return a quoted version of the string ARG.
|
||||
Use the default quoting options.
|
||||
The returned value points to static storage that can be
|
||||
reused by the next call to this function with the same value of N.
|
||||
N must be nonnegative. The output of all functions in the
|
||||
quotearg_n family are guaranteed to not contain embedded null
|
||||
bytes.*/
|
||||
char *quotearg_n (int n, char const *arg);
|
||||
|
||||
/* Equivalent to quotearg_n (0, ARG). */
|
||||
char *quotearg (char const *arg);
|
||||
|
||||
/* Use storage slot N to return a quoted version of the argument ARG
|
||||
of size ARGSIZE. This is like quotearg_n (N, ARG), except it can
|
||||
quote null bytes. */
|
||||
char *quotearg_n_mem (int n, char const *arg, size_t argsize);
|
||||
|
||||
/* Equivalent to quotearg_n_mem (0, ARG, ARGSIZE). */
|
||||
char *quotearg_mem (char const *arg, size_t argsize);
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the string ARG.
|
||||
This is like quotearg_n (N, ARG), except that it uses S with no other
|
||||
options to specify the quoting method. */
|
||||
char *quotearg_n_style (int n, enum quoting_style s, char const *arg);
|
||||
|
||||
/* Use style S and storage slot N to return a quoted version of the
|
||||
argument ARG of size ARGSIZE. This is like quotearg_n_style
|
||||
(N, S, ARG), except it can quote null bytes. */
|
||||
char *quotearg_n_style_mem (int n, enum quoting_style s,
|
||||
char const *arg, size_t argsize);
|
||||
|
||||
/* Equivalent to quotearg_n_style (0, S, ARG). */
|
||||
char *quotearg_style (enum quoting_style s, char const *arg);
|
||||
|
||||
/* Equivalent to quotearg_n_style_mem (0, S, ARG, ARGSIZE). */
|
||||
char *quotearg_style_mem (enum quoting_style s,
|
||||
char const *arg, size_t argsize);
|
||||
|
||||
/* Like quotearg (ARG), except also quote any instances of CH. */
|
||||
char *quotearg_char (char const *arg, char ch);
|
||||
|
||||
/* Like quotearg_char (ARG, CH), except it can quote null bytes. */
|
||||
char *quotearg_char_mem (char const *arg, size_t argsize, char ch);
|
||||
|
||||
/* Equivalent to quotearg_char (ARG, ':'). */
|
||||
char *quotearg_colon (char const *arg);
|
||||
|
||||
/* Like quotearg_colon (ARG), except it can quote null bytes. */
|
||||
char *quotearg_colon_mem (char const *arg, size_t argsize);
|
||||
|
||||
/* Free any dynamically allocated memory. */
|
||||
void quotearg_free (void);
|
||||
|
||||
#endif /* !QUOTEARG_H_ */
|
87
lib/realloc.c
Normal file
87
lib/realloc.c
Normal file
@ -0,0 +1,87 @@
|
||||
/* realloc() function that is glibc compatible.
|
||||
|
||||
Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* written by Jim Meyering and Bruno Haible */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */
|
||||
#ifdef realloc
|
||||
# define NEED_REALLOC_GNU 1
|
||||
#endif
|
||||
|
||||
/* Infer the properties of the system's malloc function.
|
||||
Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
|
||||
#if GNULIB_MALLOC_GNU && !defined malloc
|
||||
# define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1
|
||||
#endif
|
||||
|
||||
/* Below we want to call the system's malloc and realloc.
|
||||
Undefine the symbols here so that including <stdlib.h> provides a
|
||||
declaration of malloc(), not of rpl_malloc(), and likewise for realloc. */
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
||||
/* Specification. */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* Below we want to call the system's malloc and realloc.
|
||||
Undefine the symbols, if they were defined by gnulib's <stdlib.h>
|
||||
replacement. */
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. If N is zero, change it to 1. If P is NULL,
|
||||
use malloc. */
|
||||
|
||||
void *
|
||||
rpl_realloc (void *p, size_t n)
|
||||
{
|
||||
void *result;
|
||||
|
||||
#if NEED_REALLOC_GNU
|
||||
if (n == 0)
|
||||
{
|
||||
n = 1;
|
||||
|
||||
/* In theory realloc might fail, so don't rely on it to free. */
|
||||
free (p);
|
||||
p = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p == NULL)
|
||||
{
|
||||
#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
#endif
|
||||
result = malloc (n);
|
||||
}
|
||||
else
|
||||
result = realloc (p, n);
|
||||
|
||||
#if !HAVE_REALLOC_POSIX
|
||||
if (result == NULL)
|
||||
errno = ENOMEM;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -58,7 +58,7 @@
|
||||
|
||||
/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
|
||||
definitions below, but temporarily we have to #undef them. */
|
||||
#ifdef __BEOS__
|
||||
#if defined __BEOS__ && !defined __HAIKU__
|
||||
# include <OS.h> /* defines bool but not _Bool */
|
||||
# undef false
|
||||
# undef true
|
||||
@ -73,7 +73,7 @@
|
||||
(see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
|
||||
(see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
|
||||
enum; this ensures that '_Bool' promotes to 'int'. */
|
||||
#if defined __cplusplus || defined __BEOS__
|
||||
#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
|
||||
/* A compiler known to have 'bool'. */
|
||||
/* If the compiler already has both 'bool' and '_Bool', we can assume they
|
||||
are the same types. */
|
||||
|
94
lib/stdio-impl.h
Normal file
94
lib/stdio-impl.h
Normal file
@ -0,0 +1,94 @@
|
||||
/* Implementation details of FILE streams.
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Many stdio implementations have the same logic and therefore can share
|
||||
the same implementation of stdio extension API, except that some fields
|
||||
have different naming conventions, or their access requires some casts. */
|
||||
|
||||
|
||||
/* BSD stdio derived implementations. */
|
||||
|
||||
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
|
||||
|
||||
# if defined __DragonFly__ /* DragonFly */
|
||||
/* See <http://www.dragonflybsd.org/cvsweb/src/lib/libc/stdio/priv_stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
|
||||
# define fp_ ((struct { struct __FILE_public pub; \
|
||||
struct { unsigned char *_base; int _size; } _bf; \
|
||||
void *cookie; \
|
||||
void *_close; \
|
||||
void *_read; \
|
||||
void *_seek; \
|
||||
void *_write; \
|
||||
struct { unsigned char *_base; int _size; } _ub; \
|
||||
int _ur; \
|
||||
unsigned char _ubuf[3]; \
|
||||
unsigned cahr _nbuf[1]; \
|
||||
struct { unsigned char *_base; int _size; } _lb; \
|
||||
int _blksize; \
|
||||
fpos_t _offset; \
|
||||
/* More fields, not relevant here. */ \
|
||||
} *) fp)
|
||||
/* See <http://www.dragonflybsd.org/cvsweb/src/include/stdio.h?rev=HEAD&content-type=text/x-cvsweb-markup>. */
|
||||
# define _p pub._p
|
||||
# define _flags pub._flags
|
||||
# define _r pub._r
|
||||
# define _w pub._w
|
||||
# else
|
||||
# define fp_ fp
|
||||
# endif
|
||||
|
||||
# if defined __NetBSD__ || defined __OpenBSD__ /* NetBSD, OpenBSD */
|
||||
/* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
|
||||
and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
|
||||
struct __sfileext
|
||||
{
|
||||
struct __sbuf _ub; /* ungetc buffer */
|
||||
/* More fields, not relevant here. */
|
||||
};
|
||||
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
|
||||
# else /* FreeBSD, DragonFly, MacOS X, Cygwin */
|
||||
# define fp_ub fp->_ub
|
||||
# endif
|
||||
|
||||
# define HASUB(fp) (fp_ub._base != NULL)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* SystemV derived implementations. */
|
||||
|
||||
#if defined _IOERR
|
||||
|
||||
# if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
|
||||
# define fp_ ((struct { unsigned char *_ptr; \
|
||||
unsigned char *_base; \
|
||||
unsigned char *_end; \
|
||||
long _cnt; \
|
||||
int _file; \
|
||||
unsigned int _flag; \
|
||||
} *) fp)
|
||||
# else
|
||||
# define fp_ fp
|
||||
# endif
|
||||
|
||||
# if defined _SCO_DS /* OpenServer */
|
||||
# define _cnt __cnt
|
||||
# define _ptr __ptr
|
||||
# define _base __base
|
||||
# define _flag __flag
|
||||
# endif
|
||||
|
||||
#endif
|
382
lib/stdio.in.h
Normal file
382
lib/stdio.in.h
Normal file
@ -0,0 +1,382 @@
|
||||
/* A GNU-like <stdio.h>.
|
||||
|
||||
Copyright (C) 2004, 2007-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#if defined __need_FILE || defined __need___FILE
|
||||
/* Special invocation convention inside glibc header files. */
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_STDIO_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _GL_STDIO_H
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_STDIO_H@
|
||||
|
||||
#ifndef _GL_STDIO_H
|
||||
#define _GL_STDIO_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
|
||||
|| (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
|
||||
|| (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
|
||||
|| (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
|
||||
/* Get off_t and ssize_t. */
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The __-protected variants of `format' and `printf' attributes
|
||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||
# define __format__ format
|
||||
# define __printf__ printf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_FPRINTF_POSIX@
|
||||
# if @REPLACE_FPRINTF@
|
||||
# define fprintf rpl_fprintf
|
||||
extern int fprintf (FILE *fp, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fprintf
|
||||
# define fprintf \
|
||||
(GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
|
||||
"use gnulib module fprintf-posix for portable " \
|
||||
"POSIX compliance"), \
|
||||
fprintf)
|
||||
#endif
|
||||
|
||||
#if @GNULIB_VFPRINTF_POSIX@
|
||||
# if @REPLACE_VFPRINTF@
|
||||
# define vfprintf rpl_vfprintf
|
||||
extern int vfprintf (FILE *fp, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vfprintf
|
||||
# define vfprintf(s,f,a) \
|
||||
(GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
|
||||
"use gnulib module vfprintf-posix for portable " \
|
||||
"POSIX compliance"), \
|
||||
vfprintf (s, f, a))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_PRINTF_POSIX@
|
||||
# if @REPLACE_PRINTF@
|
||||
/* Don't break __attribute__((format(printf,M,N))). */
|
||||
# define printf __printf__
|
||||
extern int printf (const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef printf
|
||||
# define printf \
|
||||
(GL_LINK_WARNING ("printf is not always POSIX compliant - " \
|
||||
"use gnulib module printf-posix for portable " \
|
||||
"POSIX compliance"), \
|
||||
printf)
|
||||
/* Don't break __attribute__((format(printf,M,N))). */
|
||||
# define format(kind,m,n) format (__##kind##__, m, n)
|
||||
# define __format__(kind,m,n) __format__ (__##kind##__, m, n)
|
||||
# define ____printf____ __printf__
|
||||
# define ____scanf____ __scanf__
|
||||
# define ____strftime____ __strftime__
|
||||
# define ____strfmon____ __strfmon__
|
||||
#endif
|
||||
|
||||
#if @GNULIB_VPRINTF_POSIX@
|
||||
# if @REPLACE_VPRINTF@
|
||||
# define vprintf rpl_vprintf
|
||||
extern int vprintf (const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 1, 0)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vprintf
|
||||
# define vprintf(f,a) \
|
||||
(GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
|
||||
"use gnulib module vprintf-posix for portable " \
|
||||
"POSIX compliance"), \
|
||||
vprintf (f, a))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_SNPRINTF@
|
||||
# if @REPLACE_SNPRINTF@
|
||||
# define snprintf rpl_snprintf
|
||||
# endif
|
||||
# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
|
||||
extern int snprintf (char *str, size_t size, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef snprintf
|
||||
# define snprintf \
|
||||
(GL_LINK_WARNING ("snprintf is unportable - " \
|
||||
"use gnulib module snprintf for portability"), \
|
||||
snprintf)
|
||||
#endif
|
||||
|
||||
#if @GNULIB_VSNPRINTF@
|
||||
# if @REPLACE_VSNPRINTF@
|
||||
# define vsnprintf rpl_vsnprintf
|
||||
# endif
|
||||
# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
|
||||
extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 3, 0)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vsnprintf
|
||||
# define vsnprintf(b,s,f,a) \
|
||||
(GL_LINK_WARNING ("vsnprintf is unportable - " \
|
||||
"use gnulib module vsnprintf for portability"), \
|
||||
vsnprintf (b, s, f, a))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_SPRINTF_POSIX@
|
||||
# if @REPLACE_SPRINTF@
|
||||
# define sprintf rpl_sprintf
|
||||
extern int sprintf (char *str, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef sprintf
|
||||
# define sprintf \
|
||||
(GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
|
||||
"use gnulib module sprintf-posix for portable " \
|
||||
"POSIX compliance"), \
|
||||
sprintf)
|
||||
#endif
|
||||
|
||||
#if @GNULIB_VSPRINTF_POSIX@
|
||||
# if @REPLACE_VSPRINTF@
|
||||
# define vsprintf rpl_vsprintf
|
||||
extern int vsprintf (char *str, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef vsprintf
|
||||
# define vsprintf(b,f,a) \
|
||||
(GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
|
||||
"use gnulib module vsprintf-posix for portable " \
|
||||
"POSIX compliance"), \
|
||||
vsprintf (b, f, a))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_VASPRINTF@
|
||||
# if @REPLACE_VASPRINTF@
|
||||
# define asprintf rpl_asprintf
|
||||
# define vasprintf rpl_vasprintf
|
||||
# endif
|
||||
# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
|
||||
/* Write formatted output to a string dynamically allocated with malloc().
|
||||
If the memory allocation succeeds, store the address of the string in
|
||||
*RESULT and return the number of resulting bytes, excluding the trailing
|
||||
NUL. Upon memory allocation error, or some other error, return -1. */
|
||||
extern int asprintf (char **result, const char *format, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
extern int vasprintf (char **result, const char *format, va_list args)
|
||||
__attribute__ ((__format__ (__printf__, 2, 0)));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FOPEN@
|
||||
# if @REPLACE_FOPEN@
|
||||
# define fopen rpl_fopen
|
||||
extern FILE * fopen (const char *filename, const char *mode);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fopen
|
||||
# define fopen(f,m) \
|
||||
(GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
|
||||
"use gnulib module fopen for portability"), \
|
||||
fopen (f, m))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FREOPEN@
|
||||
# if @REPLACE_FREOPEN@
|
||||
# define freopen rpl_freopen
|
||||
extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef freopen
|
||||
# define freopen(f,m,s) \
|
||||
(GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
|
||||
"use gnulib module freopen for portability"), \
|
||||
freopen (f, m, s))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FSEEKO@
|
||||
# if @REPLACE_FSEEKO@
|
||||
/* Provide fseek, fseeko functions that are aware of a preceding
|
||||
fflush(), and which detect pipes. */
|
||||
# define fseeko rpl_fseeko
|
||||
extern int fseeko (FILE *fp, off_t offset, int whence);
|
||||
# define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fseeko
|
||||
# define fseeko(f,o,w) \
|
||||
(GL_LINK_WARNING ("fseeko is unportable - " \
|
||||
"use gnulib module fseeko for portability"), \
|
||||
fseeko (f, o, w))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
|
||||
extern int rpl_fseek (FILE *fp, long offset, int whence);
|
||||
# undef fseek
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# define fseek(f,o,w) \
|
||||
(GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
|
||||
"on 32-bit platforms - " \
|
||||
"use fseeko function for handling of large files"), \
|
||||
rpl_fseek (f, o, w))
|
||||
# else
|
||||
# define fseek rpl_fseek
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# ifndef fseek
|
||||
# define fseek(f,o,w) \
|
||||
(GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
|
||||
"on 32-bit platforms - " \
|
||||
"use fseeko function for handling of large files"), \
|
||||
fseek (f, o, w))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FTELLO@
|
||||
# if @REPLACE_FTELLO@
|
||||
# define ftello rpl_ftello
|
||||
extern off_t ftello (FILE *fp);
|
||||
# define ftell(fp) ftello (fp)
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef ftello
|
||||
# define ftello(f) \
|
||||
(GL_LINK_WARNING ("ftello is unportable - " \
|
||||
"use gnulib module ftello for portability"), \
|
||||
ftello (f))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FTELL@ && @REPLACE_FTELL@
|
||||
extern long rpl_ftell (FILE *fp);
|
||||
# undef ftell
|
||||
# if GNULIB_POSIXCHECK
|
||||
# define ftell(f) \
|
||||
(GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
|
||||
"on 32-bit platforms - " \
|
||||
"use ftello function for handling of large files"), \
|
||||
rpl_ftell (f))
|
||||
# else
|
||||
# define ftell rpl_ftell
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# ifndef ftell
|
||||
# define ftell(f) \
|
||||
(GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
|
||||
"on 32-bit platforms - " \
|
||||
"use ftello function for handling of large files"), \
|
||||
ftell (f))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_FFLUSH@
|
||||
# if @REPLACE_FFLUSH@
|
||||
# define fflush rpl_fflush
|
||||
/* Flush all pending data on STREAM according to POSIX rules. Both
|
||||
output and seekable input streams are supported.
|
||||
Note! LOSS OF DATA can occur if fflush is applied on an input stream
|
||||
that is _not_seekable_ or on an update stream that is _not_seekable_
|
||||
and in which the most recent operation was input. Seekability can
|
||||
be tested with lseek(fileno(fp),0,SEEK_CUR). */
|
||||
extern int fflush (FILE *gl_stream);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef fflush
|
||||
# define fflush(f) \
|
||||
(GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
|
||||
"use gnulib module fflush for portable " \
|
||||
"POSIX compliance"), \
|
||||
fflush (f))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_GETDELIM@
|
||||
# if !@HAVE_DECL_GETDELIM@
|
||||
/* Read input, up to (and including) the next occurrence of DELIMITER, from
|
||||
STREAM, store it in *LINEPTR (and NUL-terminate it).
|
||||
*LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
|
||||
bytes of space. It is realloc'd as necessary.
|
||||
Return the number of bytes read and stored at *LINEPTR (not including the
|
||||
NUL terminator), or -1 on error or EOF. */
|
||||
extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
|
||||
FILE *stream);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getdelim
|
||||
# define getdelim(l, s, d, f) \
|
||||
(GL_LINK_WARNING ("getdelim is unportable - " \
|
||||
"use gnulib module getdelim for portability"), \
|
||||
getdelim (l, s, d, f))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_GETLINE@
|
||||
# if @REPLACE_GETLINE@
|
||||
# undef getline
|
||||
# define getline rpl_getline
|
||||
# endif
|
||||
# if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
|
||||
/* Read a line, up to (and including) the next newline, from STREAM, store it
|
||||
in *LINEPTR (and NUL-terminate it).
|
||||
*LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
|
||||
bytes of space. It is realloc'd as necessary.
|
||||
Return the number of bytes read and stored at *LINEPTR (not including the
|
||||
NUL terminator), or -1 on error or EOF. */
|
||||
extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getline
|
||||
# define getline(l, s, f) \
|
||||
(GL_LINK_WARNING ("getline is unportable - " \
|
||||
"use gnulib module getline for portability"), \
|
||||
getline (l, s, f))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GL_STDIO_H */
|
||||
#endif /* _GL_STDIO_H */
|
||||
#endif
|
240
lib/stdlib.in.h
Normal file
240
lib/stdlib.in.h
Normal file
@ -0,0 +1,240 @@
|
||||
/* A GNU-like <stdlib.h>.
|
||||
|
||||
Copyright (C) 1995, 2001-2004, 2006-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if defined __need_malloc_and_calloc
|
||||
/* Special invocation convention inside glibc header files. */
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _GL_STDLIB_H
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
|
||||
|
||||
#ifndef _GL_STDLIB_H
|
||||
#define _GL_STDLIB_H
|
||||
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
|
||||
/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
|
||||
#ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
#endif
|
||||
/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
|
||||
with proper operation of xargs. */
|
||||
#ifndef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#elif EXIT_FAILURE != 1
|
||||
# undef EXIT_FAILURE
|
||||
# define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MALLOC_POSIX@
|
||||
# if !@HAVE_MALLOC_POSIX@
|
||||
# undef malloc
|
||||
# define malloc rpl_malloc
|
||||
extern void * malloc (size_t size);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef malloc
|
||||
# define malloc(s) \
|
||||
(GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
|
||||
"use gnulib module malloc-posix for portability"), \
|
||||
malloc (s))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_REALLOC_POSIX@
|
||||
# if !@HAVE_REALLOC_POSIX@
|
||||
# undef realloc
|
||||
# define realloc rpl_realloc
|
||||
extern void * realloc (void *ptr, size_t size);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef realloc
|
||||
# define realloc(p,s) \
|
||||
(GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
|
||||
"use gnulib module realloc-posix for portability"), \
|
||||
realloc (p, s))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_CALLOC_POSIX@
|
||||
# if !@HAVE_CALLOC_POSIX@
|
||||
# undef calloc
|
||||
# define calloc rpl_calloc
|
||||
extern void * calloc (size_t nmemb, size_t size);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef calloc
|
||||
# define calloc(n,s) \
|
||||
(GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \
|
||||
"use gnulib module calloc-posix for portability"), \
|
||||
calloc (n, s))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_GETSUBOPT@
|
||||
/* Assuming *OPTIONP is a comma separated list of elements of the form
|
||||
"token" or "token=value", getsubopt parses the first of these elements.
|
||||
If the first element refers to a "token" that is member of the given
|
||||
NULL-terminated array of tokens:
|
||||
- It replaces the comma with a NUL byte, updates *OPTIONP to point past
|
||||
the first option and the comma, sets *VALUEP to the value of the
|
||||
element (or NULL if it doesn't contain an "=" sign),
|
||||
- It returns the index of the "token" in the given array of tokens.
|
||||
Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
|
||||
For more details see the POSIX:2001 specification.
|
||||
http://www.opengroup.org/susv3xsh/getsubopt.html */
|
||||
# if !@HAVE_GETSUBOPT@
|
||||
extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getsubopt
|
||||
# define getsubopt(o,t,v) \
|
||||
(GL_LINK_WARNING ("getsubopt is unportable - " \
|
||||
"use gnulib module getsubopt for portability"), \
|
||||
getsubopt (o, t, v))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MKDTEMP@
|
||||
# if !@HAVE_MKDTEMP@
|
||||
/* Create a unique temporary directory from TEMPLATE.
|
||||
The last six characters of TEMPLATE must be "XXXXXX";
|
||||
they are replaced with a string that makes the directory name unique.
|
||||
Returns TEMPLATE, or a null pointer if it cannot get a unique name.
|
||||
The directory is created mode 700. */
|
||||
extern char * mkdtemp (char * /*template*/);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkdtemp
|
||||
# define mkdtemp(t) \
|
||||
(GL_LINK_WARNING ("mkdtemp is unportable - " \
|
||||
"use gnulib module mkdtemp for portability"), \
|
||||
mkdtemp (t))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_MKSTEMP@
|
||||
# if @REPLACE_MKSTEMP@
|
||||
/* Create a unique temporary file from TEMPLATE.
|
||||
The last six characters of TEMPLATE must be "XXXXXX";
|
||||
they are replaced with a string that makes the file name unique.
|
||||
The file is then created, ensuring it didn't exist before.
|
||||
The file is created read-write (mask at least 0600 & ~umask), but it may be
|
||||
world-readable and world-writable (mask 0666 & ~umask), depending on the
|
||||
implementation.
|
||||
Returns the open file descriptor if successful, otherwise -1 and errno
|
||||
set. */
|
||||
# define mkstemp rpl_mkstemp
|
||||
extern int mkstemp (char * /*template*/);
|
||||
# else
|
||||
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mkstemp
|
||||
# define mkstemp(t) \
|
||||
(GL_LINK_WARNING ("mkstemp is unportable - " \
|
||||
"use gnulib module mkstemp for portability"), \
|
||||
mkstemp (t))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_PUTENV@
|
||||
# if @REPLACE_PUTENV@
|
||||
# undef putenv
|
||||
# define putenv rpl_putenv
|
||||
extern int putenv (char *string);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_RPMATCH@
|
||||
# if !@HAVE_RPMATCH@
|
||||
/* Test a user response to a question.
|
||||
Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
|
||||
extern int rpmatch (const char *response);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef rpmatch
|
||||
# define rpmatch(r) \
|
||||
(GL_LINK_WARNING ("rpmatch is unportable - " \
|
||||
"use gnulib module rpmatch for portability"), \
|
||||
rpmatch (r))
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_SETENV@
|
||||
# if !@HAVE_SETENV@
|
||||
/* Set NAME to VALUE in the environment.
|
||||
If REPLACE is nonzero, overwrite an existing value. */
|
||||
extern int setenv (const char *name, const char *value, int replace);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_UNSETENV@
|
||||
# if @HAVE_UNSETENV@
|
||||
# if @VOID_UNSETENV@
|
||||
/* On some systems, unsetenv() returns void.
|
||||
This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4. */
|
||||
# define unsetenv(name) ((unsetenv)(name), 0)
|
||||
# endif
|
||||
# else
|
||||
/* Remove the variable NAME from the environment. */
|
||||
extern int unsetenv (const char *name);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_STRTOD@
|
||||
# if @REPLACE_STRTOD@
|
||||
# define strtod rpl_strtod
|
||||
# endif
|
||||
# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
|
||||
/* Parse a double from STRING, updating ENDP if appropriate. */
|
||||
extern double strtod (const char *str, char **endp);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strtod
|
||||
# define strtod(s, e) \
|
||||
(GL_LINK_WARNING ("strtod is unportable - " \
|
||||
"use gnulib module strtod for portability"), \
|
||||
strtod (s, e))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GL_STDLIB_H */
|
||||
#endif /* _GL_STDLIB_H */
|
||||
#endif
|
49
lib/strerror.c
Normal file
49
lib/strerror.c
Normal file
@ -0,0 +1,49 @@
|
||||
/* strerror.c --- POSIX compatible system error routine
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if REPLACE_STRERROR
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
# include "intprops.h"
|
||||
|
||||
# undef strerror
|
||||
# if ! HAVE_DECL_STRERROR
|
||||
# define strerror(n) NULL
|
||||
# endif
|
||||
|
||||
char *
|
||||
rpl_strerror (int n)
|
||||
{
|
||||
char *result = strerror (n);
|
||||
|
||||
if (result == NULL || result[0] == '\0')
|
||||
{
|
||||
static char const fmt[] = "Unknown error (%d)";
|
||||
static char mesg[sizeof fmt + INT_STRLEN_BOUND (n)];
|
||||
sprintf (mesg, fmt, n);
|
||||
return mesg;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
585
lib/string.in.h
Normal file
585
lib/string.in.h
Normal file
@ -0,0 +1,585 @@
|
||||
/* A GNU-like <string.h>.
|
||||
|
||||
Copyright (C) 1995-1996, 2001-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
#ifndef _GL_STRING_H
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_STRING_H@
|
||||
|
||||
#ifndef _GL_STRING_H
|
||||
#define _GL_STRING_H
|
||||
|
||||
|
||||
#ifndef __attribute__
|
||||
/* This feature is available in gcc versions 2.5 and later. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
# define __attribute__(Spec) /* empty */
|
||||
# endif
|
||||
/* The attribute __pure__ was added in gcc 2.96. */
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
|
||||
# define __pure__ /* empty */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Return the first occurrence of NEEDLE in HAYSTACK. */
|
||||
#if @GNULIB_MEMMEM@
|
||||
# if @REPLACE_MEMMEM@
|
||||
# define memmem rpl_memmem
|
||||
# endif
|
||||
# if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
|
||||
extern void *memmem (void const *__haystack, size_t __haystack_len,
|
||||
void const *__needle, size_t __needle_len)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef memmem
|
||||
# define memmem(a,al,b,bl) \
|
||||
(GL_LINK_WARNING ("memmem is unportable and often quadratic - " \
|
||||
"use gnulib module memmem-simple for portability, " \
|
||||
"and module memmem for speed" ), \
|
||||
memmem (a, al, b, bl))
|
||||
#endif
|
||||
|
||||
/* Copy N bytes of SRC to DEST, return pointer to bytes after the
|
||||
last written byte. */
|
||||
#if @GNULIB_MEMPCPY@
|
||||
# if ! @HAVE_MEMPCPY@
|
||||
extern void *mempcpy (void *restrict __dest, void const *restrict __src,
|
||||
size_t __n);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef mempcpy
|
||||
# define mempcpy(a,b,n) \
|
||||
(GL_LINK_WARNING ("mempcpy is unportable - " \
|
||||
"use gnulib module mempcpy for portability"), \
|
||||
mempcpy (a, b, n))
|
||||
#endif
|
||||
|
||||
/* Search backwards through a block for a byte (specified as an int). */
|
||||
#if @GNULIB_MEMRCHR@
|
||||
# if ! @HAVE_DECL_MEMRCHR@
|
||||
extern void *memrchr (void const *, int, size_t)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef memrchr
|
||||
# define memrchr(a,b,c) \
|
||||
(GL_LINK_WARNING ("memrchr is unportable - " \
|
||||
"use gnulib module memrchr for portability"), \
|
||||
memrchr (a, b, c))
|
||||
#endif
|
||||
|
||||
/* Find the first occurrence of C in S. More efficient than
|
||||
memchr(S,C,N), at the expense of undefined behavior if C does not
|
||||
occur within N bytes. */
|
||||
#if @GNULIB_RAWMEMCHR@
|
||||
# if ! @HAVE_RAWMEMCHR@
|
||||
extern void *rawmemchr (void const *__s, int __c_in)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef rawmemchr
|
||||
# define rawmemchr(a,b) \
|
||||
(GL_LINK_WARNING ("rawmemchr is unportable - " \
|
||||
"use gnulib module rawmemchr for portability"), \
|
||||
rawmemchr (a, b))
|
||||
#endif
|
||||
|
||||
/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
|
||||
#if @GNULIB_STPCPY@
|
||||
# if ! @HAVE_STPCPY@
|
||||
extern char *stpcpy (char *restrict __dst, char const *restrict __src);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stpcpy
|
||||
# define stpcpy(a,b) \
|
||||
(GL_LINK_WARNING ("stpcpy is unportable - " \
|
||||
"use gnulib module stpcpy for portability"), \
|
||||
stpcpy (a, b))
|
||||
#endif
|
||||
|
||||
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
|
||||
last non-NUL byte written into DST. */
|
||||
#if @GNULIB_STPNCPY@
|
||||
# if ! @HAVE_STPNCPY@
|
||||
# define stpncpy gnu_stpncpy
|
||||
extern char *stpncpy (char *restrict __dst, char const *restrict __src,
|
||||
size_t __n);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stpncpy
|
||||
# define stpncpy(a,b,n) \
|
||||
(GL_LINK_WARNING ("stpncpy is unportable - " \
|
||||
"use gnulib module stpncpy for portability"), \
|
||||
stpncpy (a, b, n))
|
||||
#endif
|
||||
|
||||
#if defined GNULIB_POSIXCHECK
|
||||
/* strchr() does not work with multibyte strings if the locale encoding is
|
||||
GB18030 and the character to be searched is a digit. */
|
||||
# undef strchr
|
||||
# define strchr(s,c) \
|
||||
(GL_LINK_WARNING ("strchr cannot work correctly on character strings " \
|
||||
"in some multibyte locales - " \
|
||||
"use mbschr if you care about internationalization"), \
|
||||
strchr (s, c))
|
||||
#endif
|
||||
|
||||
/* Find the first occurrence of C in S or the final NUL byte. */
|
||||
#if @GNULIB_STRCHRNUL@
|
||||
# if ! @HAVE_STRCHRNUL@
|
||||
extern char *strchrnul (char const *__s, int __c_in)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strchrnul
|
||||
# define strchrnul(a,b) \
|
||||
(GL_LINK_WARNING ("strchrnul is unportable - " \
|
||||
"use gnulib module strchrnul for portability"), \
|
||||
strchrnul (a, b))
|
||||
#endif
|
||||
|
||||
/* Duplicate S, returning an identical malloc'd string. */
|
||||
#if @GNULIB_STRDUP@
|
||||
# if ! @HAVE_DECL_STRDUP@ && ! defined strdup
|
||||
extern char *strdup (char const *__s);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strdup
|
||||
# define strdup(a) \
|
||||
(GL_LINK_WARNING ("strdup is unportable - " \
|
||||
"use gnulib module strdup for portability"), \
|
||||
strdup (a))
|
||||
#endif
|
||||
|
||||
/* Return a newly allocated copy of at most N bytes of STRING. */
|
||||
#if @GNULIB_STRNDUP@
|
||||
# if ! @HAVE_STRNDUP@
|
||||
# undef strndup
|
||||
# define strndup rpl_strndup
|
||||
# endif
|
||||
# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
|
||||
extern char *strndup (char const *__string, size_t __n);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strndup
|
||||
# define strndup(a,n) \
|
||||
(GL_LINK_WARNING ("strndup is unportable - " \
|
||||
"use gnulib module strndup for portability"), \
|
||||
strndup (a, n))
|
||||
#endif
|
||||
|
||||
/* Find the length (number of bytes) of STRING, but scan at most
|
||||
MAXLEN bytes. If no '\0' terminator is found in that many bytes,
|
||||
return MAXLEN. */
|
||||
#if @GNULIB_STRNLEN@
|
||||
# if ! @HAVE_DECL_STRNLEN@
|
||||
extern size_t strnlen (char const *__string, size_t __maxlen)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strnlen
|
||||
# define strnlen(a,n) \
|
||||
(GL_LINK_WARNING ("strnlen is unportable - " \
|
||||
"use gnulib module strnlen for portability"), \
|
||||
strnlen (a, n))
|
||||
#endif
|
||||
|
||||
#if defined GNULIB_POSIXCHECK
|
||||
/* strcspn() assumes the second argument is a list of single-byte characters.
|
||||
Even in this simple case, it does not work with multibyte strings if the
|
||||
locale encoding is GB18030 and one of the characters to be searched is a
|
||||
digit. */
|
||||
# undef strcspn
|
||||
# define strcspn(s,a) \
|
||||
(GL_LINK_WARNING ("strcspn cannot work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbscspn if you care about internationalization"), \
|
||||
strcspn (s, a))
|
||||
#endif
|
||||
|
||||
/* Find the first occurrence in S of any character in ACCEPT. */
|
||||
#if @GNULIB_STRPBRK@
|
||||
# if ! @HAVE_STRPBRK@
|
||||
extern char *strpbrk (char const *__s, char const *__accept)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
/* strpbrk() assumes the second argument is a list of single-byte characters.
|
||||
Even in this simple case, it does not work with multibyte strings if the
|
||||
locale encoding is GB18030 and one of the characters to be searched is a
|
||||
digit. */
|
||||
# undef strpbrk
|
||||
# define strpbrk(s,a) \
|
||||
(GL_LINK_WARNING ("strpbrk cannot work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbspbrk if you care about internationalization"), \
|
||||
strpbrk (s, a))
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strpbrk
|
||||
# define strpbrk(s,a) \
|
||||
(GL_LINK_WARNING ("strpbrk is unportable - " \
|
||||
"use gnulib module strpbrk for portability"), \
|
||||
strpbrk (s, a))
|
||||
#endif
|
||||
|
||||
#if defined GNULIB_POSIXCHECK
|
||||
/* strspn() assumes the second argument is a list of single-byte characters.
|
||||
Even in this simple case, it cannot work with multibyte strings. */
|
||||
# undef strspn
|
||||
# define strspn(s,a) \
|
||||
(GL_LINK_WARNING ("strspn cannot work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbsspn if you care about internationalization"), \
|
||||
strspn (s, a))
|
||||
#endif
|
||||
|
||||
#if defined GNULIB_POSIXCHECK
|
||||
/* strrchr() does not work with multibyte strings if the locale encoding is
|
||||
GB18030 and the character to be searched is a digit. */
|
||||
# undef strrchr
|
||||
# define strrchr(s,c) \
|
||||
(GL_LINK_WARNING ("strrchr cannot work correctly on character strings " \
|
||||
"in some multibyte locales - " \
|
||||
"use mbsrchr if you care about internationalization"), \
|
||||
strrchr (s, c))
|
||||
#endif
|
||||
|
||||
/* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
|
||||
If one is found, overwrite it with a NUL, and advance *STRINGP
|
||||
to point to the next char after it. Otherwise, set *STRINGP to NULL.
|
||||
If *STRINGP was already NULL, nothing happens.
|
||||
Return the old value of *STRINGP.
|
||||
|
||||
This is a variant of strtok() that is multithread-safe and supports
|
||||
empty fields.
|
||||
|
||||
Caveat: It modifies the original string.
|
||||
Caveat: These functions cannot be used on constant strings.
|
||||
Caveat: The identity of the delimiting character is lost.
|
||||
Caveat: It doesn't work with multibyte strings unless all of the delimiter
|
||||
characters are ASCII characters < 0x30.
|
||||
|
||||
See also strtok_r(). */
|
||||
#if @GNULIB_STRSEP@
|
||||
# if ! @HAVE_STRSEP@
|
||||
extern char *strsep (char **restrict __stringp, char const *restrict __delim);
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef strsep
|
||||
# define strsep(s,d) \
|
||||
(GL_LINK_WARNING ("strsep cannot work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbssep if you care about internationalization"), \
|
||||
strsep (s, d))
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strsep
|
||||
# define strsep(s,d) \
|
||||
(GL_LINK_WARNING ("strsep is unportable - " \
|
||||
"use gnulib module strsep for portability"), \
|
||||
strsep (s, d))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_STRSTR@
|
||||
# if @REPLACE_STRSTR@
|
||||
# define strstr rpl_strstr
|
||||
char *strstr (const char *haystack, const char *needle)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
/* strstr() does not work with multibyte strings if the locale encoding is
|
||||
different from UTF-8:
|
||||
POSIX says that it operates on "strings", and "string" in POSIX is defined
|
||||
as a sequence of bytes, not of characters. */
|
||||
# undef strstr
|
||||
# define strstr(a,b) \
|
||||
(GL_LINK_WARNING ("strstr is quadratic on many systems, and cannot " \
|
||||
"work correctly on character strings in most " \
|
||||
"multibyte locales - " \
|
||||
"use mbsstr if you care about internationalization, " \
|
||||
"or use strstr if you care about speed"), \
|
||||
strstr (a, b))
|
||||
#endif
|
||||
|
||||
/* Find the first occurrence of NEEDLE in HAYSTACK, using case-insensitive
|
||||
comparison. */
|
||||
#if @GNULIB_STRCASESTR@
|
||||
# if @REPLACE_STRCASESTR@
|
||||
# define strcasestr rpl_strcasestr
|
||||
# endif
|
||||
# if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
|
||||
extern char *strcasestr (const char *haystack, const char *needle)
|
||||
__attribute__ ((__pure__));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
/* strcasestr() does not work with multibyte strings:
|
||||
It is a glibc extension, and glibc implements it only for unibyte
|
||||
locales. */
|
||||
# undef strcasestr
|
||||
# define strcasestr(a,b) \
|
||||
(GL_LINK_WARNING ("strcasestr does work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbscasestr if you care about " \
|
||||
"internationalization, or use c-strcasestr if you want " \
|
||||
"a locale independent function"), \
|
||||
strcasestr (a, b))
|
||||
#endif
|
||||
|
||||
/* Parse S into tokens separated by characters in DELIM.
|
||||
If S is NULL, the saved pointer in SAVE_PTR is used as
|
||||
the next starting point. For example:
|
||||
char s[] = "-abc-=-def";
|
||||
char *sp;
|
||||
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||
x = strtok_r(NULL, "=", &sp); // x = NULL
|
||||
// s = "abc\0-def\0"
|
||||
|
||||
This is a variant of strtok() that is multithread-safe.
|
||||
|
||||
For the POSIX documentation for this function, see:
|
||||
http://www.opengroup.org/susv3xsh/strtok.html
|
||||
|
||||
Caveat: It modifies the original string.
|
||||
Caveat: These functions cannot be used on constant strings.
|
||||
Caveat: The identity of the delimiting character is lost.
|
||||
Caveat: It doesn't work with multibyte strings unless all of the delimiter
|
||||
characters are ASCII characters < 0x30.
|
||||
|
||||
See also strsep(). */
|
||||
#if @GNULIB_STRTOK_R@
|
||||
# if ! @HAVE_DECL_STRTOK_R@
|
||||
extern char *strtok_r (char *restrict s, char const *restrict delim,
|
||||
char **restrict save_ptr);
|
||||
# endif
|
||||
# if defined GNULIB_POSIXCHECK
|
||||
# undef strtok_r
|
||||
# define strtok_r(s,d,p) \
|
||||
(GL_LINK_WARNING ("strtok_r cannot work correctly on character strings " \
|
||||
"in multibyte locales - " \
|
||||
"use mbstok_r if you care about internationalization"), \
|
||||
strtok_r (s, d, p))
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strtok_r
|
||||
# define strtok_r(s,d,p) \
|
||||
(GL_LINK_WARNING ("strtok_r is unportable - " \
|
||||
"use gnulib module strtok_r for portability"), \
|
||||
strtok_r (s, d, p))
|
||||
#endif
|
||||
|
||||
|
||||
/* The following functions are not specified by POSIX. They are gnulib
|
||||
extensions. */
|
||||
|
||||
#if @GNULIB_MBSLEN@
|
||||
/* Return the number of multibyte characters in the character string STRING.
|
||||
This considers multibyte characters, unlike strlen, which counts bytes. */
|
||||
extern size_t mbslen (const char *string);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSNLEN@
|
||||
/* Return the number of multibyte characters in the character string starting
|
||||
at STRING and ending at STRING + LEN. */
|
||||
extern size_t mbsnlen (const char *string, size_t len);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCHR@
|
||||
/* Locate the first single-byte character C in the character string STRING,
|
||||
and return a pointer to it. Return NULL if C is not found in STRING.
|
||||
Unlike strchr(), this function works correctly in multibyte locales with
|
||||
encodings such as GB18030. */
|
||||
# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
|
||||
extern char * mbschr (const char *string, int c);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSRCHR@
|
||||
/* Locate the last single-byte character C in the character string STRING,
|
||||
and return a pointer to it. Return NULL if C is not found in STRING.
|
||||
Unlike strrchr(), this function works correctly in multibyte locales with
|
||||
encodings such as GB18030. */
|
||||
# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
|
||||
extern char * mbsrchr (const char *string, int c);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSSTR@
|
||||
/* Find the first occurrence of the character string NEEDLE in the character
|
||||
string HAYSTACK. Return NULL if NEEDLE is not found in HAYSTACK.
|
||||
Unlike strstr(), this function works correctly in multibyte locales with
|
||||
encodings different from UTF-8. */
|
||||
extern char * mbsstr (const char *haystack, const char *needle);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCASECMP@
|
||||
/* Compare the character strings S1 and S2, ignoring case, returning less than,
|
||||
equal to or greater than zero if S1 is lexicographically less than, equal to
|
||||
or greater than S2.
|
||||
Note: This function may, in multibyte locales, return 0 for strings of
|
||||
different lengths!
|
||||
Unlike strcasecmp(), this function works correctly in multibyte locales. */
|
||||
extern int mbscasecmp (const char *s1, const char *s2);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSNCASECMP@
|
||||
/* Compare the initial segment of the character string S1 consisting of at most
|
||||
N characters with the initial segment of the character string S2 consisting
|
||||
of at most N characters, ignoring case, returning less than, equal to or
|
||||
greater than zero if the initial segment of S1 is lexicographically less
|
||||
than, equal to or greater than the initial segment of S2.
|
||||
Note: This function may, in multibyte locales, return 0 for initial segments
|
||||
of different lengths!
|
||||
Unlike strncasecmp(), this function works correctly in multibyte locales.
|
||||
But beware that N is not a byte count but a character count! */
|
||||
extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSPCASECMP@
|
||||
/* Compare the initial segment of the character string STRING consisting of
|
||||
at most mbslen (PREFIX) characters with the character string PREFIX,
|
||||
ignoring case, returning less than, equal to or greater than zero if this
|
||||
initial segment is lexicographically less than, equal to or greater than
|
||||
PREFIX.
|
||||
Note: This function may, in multibyte locales, return 0 if STRING is of
|
||||
smaller length than PREFIX!
|
||||
Unlike strncasecmp(), this function works correctly in multibyte
|
||||
locales. */
|
||||
extern char * mbspcasecmp (const char *string, const char *prefix);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCASESTR@
|
||||
/* Find the first occurrence of the character string NEEDLE in the character
|
||||
string HAYSTACK, using case-insensitive comparison.
|
||||
Note: This function may, in multibyte locales, return success even if
|
||||
strlen (haystack) < strlen (needle) !
|
||||
Unlike strcasestr(), this function works correctly in multibyte locales. */
|
||||
extern char * mbscasestr (const char *haystack, const char *needle);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSCSPN@
|
||||
/* Find the first occurrence in the character string STRING of any character
|
||||
in the character string ACCEPT. Return the number of bytes from the
|
||||
beginning of the string to this occurrence, or to the end of the string
|
||||
if none exists.
|
||||
Unlike strcspn(), this function works correctly in multibyte locales. */
|
||||
extern size_t mbscspn (const char *string, const char *accept);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSPBRK@
|
||||
/* Find the first occurrence in the character string STRING of any character
|
||||
in the character string ACCEPT. Return the pointer to it, or NULL if none
|
||||
exists.
|
||||
Unlike strpbrk(), this function works correctly in multibyte locales. */
|
||||
# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
|
||||
extern char * mbspbrk (const char *string, const char *accept);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSSPN@
|
||||
/* Find the first occurrence in the character string STRING of any character
|
||||
not in the character string REJECT. Return the number of bytes from the
|
||||
beginning of the string to this occurrence, or to the end of the string
|
||||
if none exists.
|
||||
Unlike strspn(), this function works correctly in multibyte locales. */
|
||||
extern size_t mbsspn (const char *string, const char *reject);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSSEP@
|
||||
/* Search the next delimiter (multibyte character listed in the character
|
||||
string DELIM) starting at the character string *STRINGP.
|
||||
If one is found, overwrite it with a NUL, and advance *STRINGP to point
|
||||
to the next multibyte character after it. Otherwise, set *STRINGP to NULL.
|
||||
If *STRINGP was already NULL, nothing happens.
|
||||
Return the old value of *STRINGP.
|
||||
|
||||
This is a variant of mbstok_r() that supports empty fields.
|
||||
|
||||
Caveat: It modifies the original string.
|
||||
Caveat: These functions cannot be used on constant strings.
|
||||
Caveat: The identity of the delimiting character is lost.
|
||||
|
||||
See also mbstok_r(). */
|
||||
extern char * mbssep (char **stringp, const char *delim);
|
||||
#endif
|
||||
|
||||
#if @GNULIB_MBSTOK_R@
|
||||
/* Parse the character string STRING into tokens separated by characters in
|
||||
the character string DELIM.
|
||||
If STRING is NULL, the saved pointer in SAVE_PTR is used as
|
||||
the next starting point. For example:
|
||||
char s[] = "-abc-=-def";
|
||||
char *sp;
|
||||
x = mbstok_r(s, "-", &sp); // x = "abc", sp = "=-def"
|
||||
x = mbstok_r(NULL, "-=", &sp); // x = "def", sp = NULL
|
||||
x = mbstok_r(NULL, "=", &sp); // x = NULL
|
||||
// s = "abc\0-def\0"
|
||||
|
||||
Caveat: It modifies the original string.
|
||||
Caveat: These functions cannot be used on constant strings.
|
||||
Caveat: The identity of the delimiting character is lost.
|
||||
|
||||
See also mbssep(). */
|
||||
extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
|
||||
#endif
|
||||
|
||||
/* Map any int, typically from errno, into an error message. */
|
||||
#if @GNULIB_STRERROR@
|
||||
# if @REPLACE_STRERROR@
|
||||
# undef strerror
|
||||
# define strerror rpl_strerror
|
||||
extern char *strerror (int);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strerror
|
||||
# define strerror(e) \
|
||||
(GL_LINK_WARNING ("strerror is unportable - " \
|
||||
"use gnulib module strerror to guarantee non-NULL result"), \
|
||||
strerror (e))
|
||||
#endif
|
||||
|
||||
#if @GNULIB_STRSIGNAL@
|
||||
# if @REPLACE_STRSIGNAL@
|
||||
# define strsignal rpl_strsignal
|
||||
# endif
|
||||
# if ! @HAVE_DECL_STRSIGNAL@ || @REPLACE_STRSIGNAL@
|
||||
extern char *strsignal (int __sig);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strsignal
|
||||
# define strsignal(a) \
|
||||
(GL_LINK_WARNING ("strsignal is unportable - " \
|
||||
"use gnulib module strsignal for portability"), \
|
||||
strsignal (a))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GL_STRING_H */
|
||||
#endif /* _GL_STRING_H */
|
@ -1,5 +1,5 @@
|
||||
/* Substitute for and wrapper around <unistd.h>.
|
||||
Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -86,6 +86,26 @@ extern int dup2 (int oldfd, int newfd);
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_ENVIRON@
|
||||
# if !@HAVE_DECL_ENVIRON@
|
||||
/* Set of environment variables and values. An array of strings of the form
|
||||
"VARIABLE=VALUE", terminated with a NULL. */
|
||||
# if defined __APPLE__ && defined __MACH__
|
||||
# include <crt_externs.h>
|
||||
# define environ (*_NSGetEnviron ())
|
||||
# else
|
||||
extern char **environ;
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef environ
|
||||
# define environ \
|
||||
(GL_LINK_WARNING ("environ is unportable - " \
|
||||
"use gnulib module environ for portability"), \
|
||||
environ)
|
||||
#endif
|
||||
|
||||
|
||||
#if @GNULIB_FCHDIR@
|
||||
# if @REPLACE_FCHDIR@
|
||||
|
||||
@ -181,7 +201,10 @@ extern int getlogin_r (char *name, size_t size);
|
||||
|
||||
|
||||
#if @GNULIB_GETPAGESIZE@
|
||||
# if !@HAVE_GETPAGESIZE@
|
||||
# if @REPLACE_GETPAGESIZE@
|
||||
# define getpagesize rpl_getpagesize
|
||||
extern int getpagesize (void);
|
||||
# elif !@HAVE_GETPAGESIZE@
|
||||
/* This is for POSIX systems. */
|
||||
# if !defined getpagesize && defined _SC_PAGESIZE
|
||||
# if ! (defined __VMS && __VMS_VER < 70000000)
|
||||
|
91
lib/wchar.in.h
Normal file
91
lib/wchar.in.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
|
||||
|
||||
Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Eric Blake. */
|
||||
|
||||
/*
|
||||
* ISO C 99 <wchar.h> for platforms that have issues.
|
||||
* <http://www.opengroup.org/susv3xbd/wchar.h.html>
|
||||
*
|
||||
* For now, this just ensures proper prerequisite inclusion order and
|
||||
* the declaration of wcwidth().
|
||||
*/
|
||||
|
||||
#ifdef __need_mbstate_t
|
||||
/* Special invocation convention inside uClibc header files. */
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _GL_WCHAR_H
|
||||
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Include the original <wchar.h> if it exists.
|
||||
Some builds of uClibc lack it. */
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#if @HAVE_WCHAR_H@
|
||||
# @INCLUDE_NEXT@ @NEXT_WCHAR_H@
|
||||
#endif
|
||||
|
||||
#ifndef _GL_WCHAR_H
|
||||
#define _GL_WCHAR_H
|
||||
|
||||
/* The definition of GL_LINK_WARNING is copied here. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Return the number of screen columns needed for WC. */
|
||||
#if @GNULIB_WCWIDTH@
|
||||
# if @REPLACE_WCWIDTH@
|
||||
# undef wcwidth
|
||||
# define wcwidth rpl_wcwidth
|
||||
extern int wcwidth (wchar_t);
|
||||
# else
|
||||
# if !defined wcwidth && !@HAVE_DECL_WCWIDTH@
|
||||
/* wcwidth exists but is not declared. */
|
||||
extern int wcwidth (int /* actually wchar_t */);
|
||||
# endif
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef wcwidth
|
||||
# define wcwidth(w) \
|
||||
(GL_LINK_WARNING ("wcwidth is unportable - " \
|
||||
"use gnulib module wcwidth for portability"), \
|
||||
wcwidth (w))
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GL_WCHAR_H */
|
||||
#endif /* _GL_WCHAR_H */
|
||||
#endif
|
178
lib/wctype.in.h
Normal file
178
lib/wctype.in.h
Normal file
@ -0,0 +1,178 @@
|
||||
/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
|
||||
|
||||
Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* Written by Bruno Haible and Paul Eggert. */
|
||||
|
||||
/*
|
||||
* ISO C 99 <wctype.h> for platforms that lack it.
|
||||
* <http://www.opengroup.org/susv3xbd/wctype.h.html>
|
||||
*
|
||||
* iswctype, towctrans, towlower, towupper, wctrans, wctype,
|
||||
* wctrans_t, and wctype_t are not yet implemented.
|
||||
*/
|
||||
|
||||
#ifndef _GL_WCTYPE_H
|
||||
|
||||
#if @HAVE_WINT_T@
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
|
||||
Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
included before <wchar.h>. */
|
||||
# include <stddef.h>
|
||||
# include <stdio.h>
|
||||
# include <time.h>
|
||||
# include <wchar.h>
|
||||
#endif
|
||||
|
||||
/* Include the original <wctype.h> if it exists.
|
||||
BeOS 5 has the functions but no <wctype.h>. */
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#if @HAVE_WCTYPE_H@
|
||||
# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
|
||||
#endif
|
||||
|
||||
#ifndef _GL_WCTYPE_H
|
||||
#define _GL_WCTYPE_H
|
||||
|
||||
#if @HAVE_WINT_T@
|
||||
typedef wint_t __wctype_wint_t;
|
||||
#else
|
||||
typedef int __wctype_wint_t;
|
||||
#endif
|
||||
|
||||
/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
|
||||
Linux libc5 has <wctype.h> and the functions but they are broken.
|
||||
Assume all 12 functions are implemented the same way, or not at all. */
|
||||
#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
|
||||
|
||||
/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
|
||||
undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
|
||||
refer to system functions like _iswctype that are not in the
|
||||
standard C library. Rather than try to get ancient buggy
|
||||
implementations like this to work, just disable them. */
|
||||
# undef iswalnum
|
||||
# undef iswalpha
|
||||
# undef iswblank
|
||||
# undef iswcntrl
|
||||
# undef iswdigit
|
||||
# undef iswgraph
|
||||
# undef iswlower
|
||||
# undef iswprint
|
||||
# undef iswpunct
|
||||
# undef iswspace
|
||||
# undef iswupper
|
||||
# undef iswxdigit
|
||||
|
||||
/* Linux libc5 has <wctype.h> and the functions but they are broken. */
|
||||
# if @REPLACE_ISWCNTRL@
|
||||
# define iswalnum rpl_iswalnum
|
||||
# define iswalpha rpl_iswalpha
|
||||
# define iswblank rpl_iswblank
|
||||
# define iswcntrl rpl_iswcntrl
|
||||
# define iswdigit rpl_iswdigit
|
||||
# define iswgraph rpl_iswgraph
|
||||
# define iswlower rpl_iswlower
|
||||
# define iswprint rpl_iswprint
|
||||
# define iswpunct rpl_iswpunct
|
||||
# define iswspace rpl_iswspace
|
||||
# define iswupper rpl_iswupper
|
||||
# define iswxdigit rpl_iswxdigit
|
||||
# endif
|
||||
|
||||
static inline int
|
||||
iswalnum (__wctype_wint_t wc)
|
||||
{
|
||||
return ((wc >= '0' && wc <= '9')
|
||||
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswalpha (__wctype_wint_t wc)
|
||||
{
|
||||
return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswblank (__wctype_wint_t wc)
|
||||
{
|
||||
return wc == ' ' || wc == '\t';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswcntrl (__wctype_wint_t wc)
|
||||
{
|
||||
return (wc & ~0x1f) == 0 || wc == 0x7f;
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswdigit (__wctype_wint_t wc)
|
||||
{
|
||||
return wc >= '0' && wc <= '9';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswgraph (__wctype_wint_t wc)
|
||||
{
|
||||
return wc >= '!' && wc <= '~';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswlower (__wctype_wint_t wc)
|
||||
{
|
||||
return wc >= 'a' && wc <= 'z';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswprint (__wctype_wint_t wc)
|
||||
{
|
||||
return wc >= ' ' && wc <= '~';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswpunct (__wctype_wint_t wc)
|
||||
{
|
||||
return (wc >= '!' && wc <= '~'
|
||||
&& !((wc >= '0' && wc <= '9')
|
||||
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswspace (__wctype_wint_t wc)
|
||||
{
|
||||
return (wc == ' ' || wc == '\t'
|
||||
|| wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswupper (__wctype_wint_t wc)
|
||||
{
|
||||
return wc >= 'A' && wc <= 'Z';
|
||||
}
|
||||
|
||||
static inline int
|
||||
iswxdigit (__wctype_wint_t wc)
|
||||
{
|
||||
return ((wc >= '0' && wc <= '9')
|
||||
|| ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
|
||||
}
|
||||
|
||||
# endif /* ! HAVE_ISWCNTRL */
|
||||
|
||||
#endif /* _GL_WCTYPE_H */
|
||||
#endif /* _GL_WCTYPE_H */
|
41
lib/xalloc-die.c
Normal file
41
lib/xalloc-die.c
Normal file
@ -0,0 +1,41 @@
|
||||
/* Report a memory allocation failure and exit.
|
||||
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "xalloc.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "error.h"
|
||||
#include "exitfail.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
void
|
||||
xalloc_die (void)
|
||||
{
|
||||
error (exit_failure, 0, "%s", _("memory exhausted"));
|
||||
|
||||
/* The `noreturn' cannot be given to error, since it may return if
|
||||
its first argument is 0. To help compilers understand the
|
||||
xalloc_die does not return, call abort. Also, the abort is a
|
||||
safety feature if exit_failure is 0 (which shouldn't happen). */
|
||||
abort ();
|
||||
}
|
280
lib/xalloc.h
Normal file
280
lib/xalloc.h
Normal file
@ -0,0 +1,280 @@
|
||||
/* xalloc.h -- malloc with out-of-memory checking
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef XALLOC_H_
|
||||
# define XALLOC_H_
|
||||
|
||||
# include <stddef.h>
|
||||
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
|
||||
# ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_NORETURN
|
||||
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
|
||||
# endif
|
||||
|
||||
# ifndef ATTRIBUTE_MALLOC
|
||||
# if __GNUC__ >= 3
|
||||
# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
||||
# else
|
||||
# define ATTRIBUTE_MALLOC
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* This function is always triggered when memory is exhausted.
|
||||
It must be defined by the application, either explicitly
|
||||
or by using gnulib's xalloc-die module. This is the
|
||||
function to call when one wants the program to die because of a
|
||||
memory allocation failure. */
|
||||
extern void xalloc_die (void) ATTRIBUTE_NORETURN;
|
||||
|
||||
void *xmalloc (size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xzalloc (size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xrealloc (void *p, size_t s);
|
||||
void *x2realloc (void *p, size_t *pn);
|
||||
void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC;
|
||||
char *xstrdup (char const *str) ATTRIBUTE_MALLOC;
|
||||
|
||||
/* Return 1 if an array of N objects, each of size S, cannot exist due
|
||||
to size arithmetic overflow. S must be positive and N must be
|
||||
nonnegative. This is a macro, not an inline function, so that it
|
||||
works correctly even when SIZE_MAX < N.
|
||||
|
||||
By gnulib convention, SIZE_MAX represents overflow in size
|
||||
calculations, so the conservative dividend to use here is
|
||||
SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
|
||||
However, malloc (SIZE_MAX) fails on all known hosts where
|
||||
sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
|
||||
exactly-SIZE_MAX allocations on such hosts; this avoids a test and
|
||||
branch when S is known to be 1. */
|
||||
# define xalloc_oversized(n, s) \
|
||||
((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
|
||||
|
||||
|
||||
/* In the following macros, T must be an elementary or structure/union or
|
||||
typedef'ed type, or a pointer to such a type. To apply one of the
|
||||
following macros to a function pointer or array type, you need to typedef
|
||||
it first and use the typedef name. */
|
||||
|
||||
/* Allocate an object of type T dynamically, with error checking. */
|
||||
/* extern t *XMALLOC (typename t); */
|
||||
# define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
|
||||
|
||||
/* Allocate memory for N elements of type T, with error checking. */
|
||||
/* extern t *XNMALLOC (size_t n, typename t); */
|
||||
# define XNMALLOC(n, t) \
|
||||
((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
|
||||
|
||||
/* Allocate an object of type T dynamically, with error checking,
|
||||
and zero it. */
|
||||
/* extern t *XZALLOC (typename t); */
|
||||
# define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
|
||||
|
||||
/* Allocate memory for N elements of type T, with error checking,
|
||||
and zero it. */
|
||||
/* extern t *XCALLOC (size_t n, typename t); */
|
||||
# define XCALLOC(n, t) \
|
||||
((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
|
||||
|
||||
|
||||
# if HAVE_INLINE
|
||||
# define static_inline static inline
|
||||
# else
|
||||
void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
|
||||
void *xnrealloc (void *p, size_t n, size_t s);
|
||||
void *x2nrealloc (void *p, size_t *pn, size_t s);
|
||||
char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
|
||||
# endif
|
||||
|
||||
# ifdef static_inline
|
||||
|
||||
/* Allocate an array of N objects, each with S bytes of memory,
|
||||
dynamically, with error checking. S must be nonzero. */
|
||||
|
||||
static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
|
||||
static_inline void *
|
||||
xnmalloc (size_t n, size_t s)
|
||||
{
|
||||
if (xalloc_oversized (n, s))
|
||||
xalloc_die ();
|
||||
return xmalloc (n * s);
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to an array of N
|
||||
objects each of S bytes, with error checking. S must be nonzero. */
|
||||
|
||||
static_inline void *
|
||||
xnrealloc (void *p, size_t n, size_t s)
|
||||
{
|
||||
if (xalloc_oversized (n, s))
|
||||
xalloc_die ();
|
||||
return xrealloc (p, n * s);
|
||||
}
|
||||
|
||||
/* If P is null, allocate a block of at least *PN such objects;
|
||||
otherwise, reallocate P so that it contains more than *PN objects
|
||||
each of S bytes. *PN must be nonzero unless P is null, and S must
|
||||
be nonzero. Set *PN to the new number of objects, and return the
|
||||
pointer to the new block. *PN is never set to zero, and the
|
||||
returned pointer is never null.
|
||||
|
||||
Repeated reallocations are guaranteed to make progress, either by
|
||||
allocating an initial block with a nonzero size, or by allocating a
|
||||
larger block.
|
||||
|
||||
In the following implementation, nonzero sizes are increased by a
|
||||
factor of approximately 1.5 so that repeated reallocations have
|
||||
O(N) overall cost rather than O(N**2) cost, but the
|
||||
specification for this function does not guarantee that rate.
|
||||
|
||||
Here is an example of use:
|
||||
|
||||
int *p = NULL;
|
||||
size_t used = 0;
|
||||
size_t allocated = 0;
|
||||
|
||||
void
|
||||
append_int (int value)
|
||||
{
|
||||
if (used == allocated)
|
||||
p = x2nrealloc (p, &allocated, sizeof *p);
|
||||
p[used++] = value;
|
||||
}
|
||||
|
||||
This causes x2nrealloc to allocate a block of some nonzero size the
|
||||
first time it is called.
|
||||
|
||||
To have finer-grained control over the initial size, set *PN to a
|
||||
nonzero value before calling this function with P == NULL. For
|
||||
example:
|
||||
|
||||
int *p = NULL;
|
||||
size_t used = 0;
|
||||
size_t allocated = 0;
|
||||
size_t allocated1 = 1000;
|
||||
|
||||
void
|
||||
append_int (int value)
|
||||
{
|
||||
if (used == allocated)
|
||||
{
|
||||
p = x2nrealloc (p, &allocated1, sizeof *p);
|
||||
allocated = allocated1;
|
||||
}
|
||||
p[used++] = value;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
static_inline void *
|
||||
x2nrealloc (void *p, size_t *pn, size_t s)
|
||||
{
|
||||
size_t n = *pn;
|
||||
|
||||
if (! p)
|
||||
{
|
||||
if (! n)
|
||||
{
|
||||
/* The approximate size to use for initial small allocation
|
||||
requests, when the invoking code specifies an old size of
|
||||
zero. 64 bytes is the largest "small" request for the
|
||||
GNU C library malloc. */
|
||||
enum { DEFAULT_MXFAST = 64 };
|
||||
|
||||
n = DEFAULT_MXFAST / s;
|
||||
n += !n;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set N = ceil (1.5 * N) so that progress is made if N == 1.
|
||||
Check for overflow, so that N * S stays in size_t range.
|
||||
The check is slightly conservative, but an exact check isn't
|
||||
worth the trouble. */
|
||||
if ((size_t) -1 / 3 * 2 / s <= n)
|
||||
xalloc_die ();
|
||||
n += (n + 1) / 2;
|
||||
}
|
||||
|
||||
*pn = n;
|
||||
return xrealloc (p, n * s);
|
||||
}
|
||||
|
||||
/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
|
||||
except it returns char *. */
|
||||
|
||||
static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
|
||||
static_inline char *
|
||||
xcharalloc (size_t n)
|
||||
{
|
||||
return XNMALLOC (n, char);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
|
||||
/* C++ does not allow conversions from void * to other pointer types
|
||||
without a cast. Use templates to work around the problem when
|
||||
possible. */
|
||||
|
||||
template <typename T> inline T *
|
||||
xrealloc (T *p, size_t s)
|
||||
{
|
||||
return (T *) xrealloc ((void *) p, s);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
xnrealloc (T *p, size_t n, size_t s)
|
||||
{
|
||||
return (T *) xnrealloc ((void *) p, n, s);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
x2realloc (T *p, size_t *pn)
|
||||
{
|
||||
return (T *) x2realloc ((void *) p, pn);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
x2nrealloc (T *p, size_t *pn, size_t s)
|
||||
{
|
||||
return (T *) x2nrealloc ((void *) p, pn, s);
|
||||
}
|
||||
|
||||
template <typename T> inline T *
|
||||
xmemdup (T const *p, size_t s)
|
||||
{
|
||||
return (T *) xmemdup ((void const *) p, s);
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
#endif /* !XALLOC_H_ */
|
122
lib/xmalloc.c
Normal file
122
lib/xmalloc.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* xmalloc.c -- malloc with out of memory checking
|
||||
|
||||
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
||||
1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if ! HAVE_INLINE
|
||||
# define static_inline
|
||||
#endif
|
||||
#include "xalloc.h"
|
||||
#undef static_inline
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
/* 1 if calloc is known to be compatible with GNU calloc. This
|
||||
matters if we are not also using the calloc module, which defines
|
||||
HAVE_CALLOC and supports the GNU API even on non-GNU platforms. */
|
||||
#if defined HAVE_CALLOC || defined __GLIBC__
|
||||
enum { HAVE_GNU_CALLOC = 1 };
|
||||
#else
|
||||
enum { HAVE_GNU_CALLOC = 0 };
|
||||
#endif
|
||||
|
||||
/* Allocate N bytes of memory dynamically, with error checking. */
|
||||
|
||||
void *
|
||||
xmalloc (size_t n)
|
||||
{
|
||||
void *p = malloc (n);
|
||||
if (!p && n != 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Change the size of an allocated block of memory P to N bytes,
|
||||
with error checking. */
|
||||
|
||||
void *
|
||||
xrealloc (void *p, size_t n)
|
||||
{
|
||||
p = realloc (p, n);
|
||||
if (!p && n != 0)
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* If P is null, allocate a block of at least *PN bytes; otherwise,
|
||||
reallocate P so that it contains more than *PN bytes. *PN must be
|
||||
nonzero unless P is null. Set *PN to the new block's size, and
|
||||
return the pointer to the new block. *PN is never set to zero, and
|
||||
the returned pointer is never null. */
|
||||
|
||||
void *
|
||||
x2realloc (void *p, size_t *pn)
|
||||
{
|
||||
return x2nrealloc (p, pn, 1);
|
||||
}
|
||||
|
||||
/* Allocate S bytes of zeroed memory dynamically, with error checking.
|
||||
There's no need for xnzalloc (N, S), since it would be equivalent
|
||||
to xcalloc (N, S). */
|
||||
|
||||
void *
|
||||
xzalloc (size_t s)
|
||||
{
|
||||
return memset (xmalloc (s), 0, s);
|
||||
}
|
||||
|
||||
/* Allocate zeroed memory for N elements of S bytes, with error
|
||||
checking. S must be nonzero. */
|
||||
|
||||
void *
|
||||
xcalloc (size_t n, size_t s)
|
||||
{
|
||||
void *p;
|
||||
/* Test for overflow, since some calloc implementations don't have
|
||||
proper overflow checks. But omit overflow and size-zero tests if
|
||||
HAVE_GNU_CALLOC, since GNU calloc catches overflow and never
|
||||
returns NULL if successful. */
|
||||
if ((! HAVE_GNU_CALLOC && xalloc_oversized (n, s))
|
||||
|| (! (p = calloc (n, s)) && (HAVE_GNU_CALLOC || n != 0)))
|
||||
xalloc_die ();
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Clone an object P of size S, with error checking. There's no need
|
||||
for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
|
||||
need for an arithmetic overflow check. */
|
||||
|
||||
void *
|
||||
xmemdup (void const *p, size_t s)
|
||||
{
|
||||
return memcpy (xmalloc (s), p, s);
|
||||
}
|
||||
|
||||
/* Clone STRING. */
|
||||
|
||||
char *
|
||||
xstrdup (char const *string)
|
||||
{
|
||||
return xmemdup (string, strlen (string) + 1);
|
||||
}
|
46
m4/alloca.m4
Normal file
46
m4/alloca.m4
Normal file
@ -0,0 +1,46 @@
|
||||
# alloca.m4 serial 8
|
||||
dnl Copyright (C) 2002-2004, 2006, 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_ALLOCA],
|
||||
[
|
||||
dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
|
||||
AC_REQUIRE([AC_PROG_CPP])
|
||||
AC_REQUIRE([AC_PROG_EGREP])
|
||||
|
||||
AC_REQUIRE([AC_FUNC_ALLOCA])
|
||||
if test $ac_cv_func_alloca_works = no; then
|
||||
gl_PREREQ_ALLOCA
|
||||
fi
|
||||
|
||||
# Define an additional variable used in the Makefile substitution.
|
||||
if test $ac_cv_working_alloca_h = yes; then
|
||||
AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
|
||||
AC_EGREP_CPP([Need own alloca], [
|
||||
#if defined __GNUC__ || defined _AIX || defined _MSC_VER
|
||||
Need own alloca
|
||||
#endif
|
||||
], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
|
||||
])
|
||||
if test $gl_cv_rpl_alloca = yes; then
|
||||
dnl OK, alloca can be implemented through a compiler built-in.
|
||||
AC_DEFINE([HAVE_ALLOCA], 1,
|
||||
[Define to 1 if you have 'alloca' after including <alloca.h>,
|
||||
a header that may be supplied by this distribution.])
|
||||
ALLOCA_H=alloca.h
|
||||
else
|
||||
dnl alloca exists as a library function, i.e. it is slow and probably
|
||||
dnl a memory leak. Don't define HAVE_ALLOCA in this case.
|
||||
ALLOCA_H=
|
||||
fi
|
||||
else
|
||||
ALLOCA_H=alloca.h
|
||||
fi
|
||||
AC_SUBST([ALLOCA_H])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/alloca.c.
|
||||
# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
|
||||
AC_DEFUN([gl_PREREQ_ALLOCA], [:])
|
70
m4/eoverflow.m4
Normal file
70
m4/eoverflow.m4
Normal file
@ -0,0 +1,70 @@
|
||||
# eoverflow.m4 serial 2
|
||||
dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
|
||||
# POSIX. But some systems (like AIX 3) don't define it, and some systems
|
||||
# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
|
||||
|
||||
# Define EOVERFLOW as a C macro and as a substituted macro in such a way that
|
||||
# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
|
||||
# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
|
||||
# value.
|
||||
|
||||
AC_DEFUN([gl_EOVERFLOW],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])dnl
|
||||
|
||||
AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
|
||||
AC_EGREP_CPP(yes,[
|
||||
#include <errno.h>
|
||||
#ifdef EOVERFLOW
|
||||
yes
|
||||
#endif
|
||||
], have_eoverflow=1)
|
||||
if test -n "$have_eoverflow"; then
|
||||
dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
|
||||
ac_cv_decl_EOVERFLOW=yes
|
||||
else
|
||||
AC_EGREP_CPP(yes,[
|
||||
#define _XOPEN_SOURCE_EXTENDED 1
|
||||
#include <errno.h>
|
||||
#ifdef EOVERFLOW
|
||||
yes
|
||||
#endif
|
||||
], have_eoverflow=1)
|
||||
if test -n "$have_eoverflow"; then
|
||||
dnl EOVERFLOW exists but is hidden.
|
||||
dnl Define it to the same value.
|
||||
AC_COMPUTE_INT([ac_cv_decl_EOVERFLOW], [EOVERFLOW], [
|
||||
#define _XOPEN_SOURCE_EXTENDED 1
|
||||
#include <errno.h>
|
||||
/* The following two lines are a workaround against an autoconf-2.52 bug. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
])
|
||||
else
|
||||
dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
|
||||
dnl don't define it as EINVAL, because snprintf() callers want to
|
||||
dnl distinguish EINVAL and EOVERFLOW.
|
||||
ac_cv_decl_EOVERFLOW=E2BIG
|
||||
fi
|
||||
fi
|
||||
])
|
||||
if test "$ac_cv_decl_EOVERFLOW" != yes; then
|
||||
AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
|
||||
[Define as good substitute value for EOVERFLOW.])
|
||||
EOVERFLOW="$ac_cv_decl_EOVERFLOW"
|
||||
AC_SUBST(EOVERFLOW)
|
||||
fi
|
||||
])
|
||||
|
||||
dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
|
||||
dnl Remove this when we can assume autoconf >= 2.61.
|
||||
m4_ifdef([AC_COMPUTE_INT], [], [
|
||||
AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
|
||||
])
|
22
m4/error.m4
Normal file
22
m4/error.m4
Normal file
@ -0,0 +1,22 @@
|
||||
#serial 11
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004 Free Software
|
||||
# Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_ERROR],
|
||||
[
|
||||
AC_FUNC_ERROR_AT_LINE
|
||||
dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]).
|
||||
gl_PREREQ_ERROR
|
||||
])
|
||||
|
||||
# Prerequisites of lib/error.c.
|
||||
AC_DEFUN([gl_PREREQ_ERROR],
|
||||
[
|
||||
AC_REQUIRE([AC_FUNC_STRERROR_R])
|
||||
:
|
||||
])
|
13
m4/exitfail.m4
Normal file
13
m4/exitfail.m4
Normal file
@ -0,0 +1,13 @@
|
||||
# exitfail.m4 serial 6
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_EXITFAIL],
|
||||
[
|
||||
AC_LIBOBJ([exitfail])
|
||||
|
||||
dnl No prerequisites of lib/exitfail.c.
|
||||
:
|
||||
])
|
82
m4/extensions.m4
Normal file
82
m4/extensions.m4
Normal file
@ -0,0 +1,82 @@
|
||||
# serial 5 -*- Autoconf -*-
|
||||
# Enable extensions on systems that normally disable them.
|
||||
|
||||
# Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
|
||||
# Autoconf. Perhaps we can remove this once we can assume Autoconf
|
||||
# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
|
||||
# enough in this area it's likely we'll need to redefine
|
||||
# AC_USE_SYSTEM_EXTENSIONS for quite some time.
|
||||
|
||||
# AC_USE_SYSTEM_EXTENSIONS
|
||||
# ------------------------
|
||||
# Enable extensions on systems that normally disable them,
|
||||
# typically due to standards-conformance issues.
|
||||
# Remember that #undef in AH_VERBATIM gets replaced with #define by
|
||||
# AC_DEFINE. The goal here is to define all known feature-enabling
|
||||
# macros, then, if reports of conflicts are made, disable macros that
|
||||
# cause problems on some platforms (such as __EXTENSIONS__).
|
||||
AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
|
||||
[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
|
||||
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
|
||||
|
||||
AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
|
||||
if test "$MINIX" = yes; then
|
||||
AC_DEFINE([_POSIX_SOURCE], [1],
|
||||
[Define to 1 if you need to in order for `stat' and other
|
||||
things to work.])
|
||||
AC_DEFINE([_POSIX_1_SOURCE], [2],
|
||||
[Define to 2 if the system does not provide POSIX.1 features
|
||||
except with this defined.])
|
||||
AC_DEFINE([_MINIX], [1],
|
||||
[Define to 1 if on MINIX.])
|
||||
fi
|
||||
|
||||
AH_VERBATIM([__EXTENSIONS__],
|
||||
[/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
])
|
||||
AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
|
||||
[ac_cv_safe_to_define___extensions__],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[
|
||||
# define __EXTENSIONS__ 1
|
||||
]AC_INCLUDES_DEFAULT])],
|
||||
[ac_cv_safe_to_define___extensions__=yes],
|
||||
[ac_cv_safe_to_define___extensions__=no])])
|
||||
test $ac_cv_safe_to_define___extensions__ = yes &&
|
||||
AC_DEFINE([__EXTENSIONS__])
|
||||
AC_DEFINE([_ALL_SOURCE])
|
||||
AC_DEFINE([_GNU_SOURCE])
|
||||
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
|
||||
AC_DEFINE([_TANDEM_SOURCE])
|
||||
])# AC_USE_SYSTEM_EXTENSIONS
|
||||
|
||||
# gl_USE_SYSTEM_EXTENSIONS
|
||||
# ------------------------
|
||||
# Enable extensions on systems that normally disable them,
|
||||
# typically due to standards-conformance issues.
|
||||
AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS],
|
||||
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])])
|
34
m4/fseeko.m4
Normal file
34
m4/fseeko.m4
Normal file
@ -0,0 +1,34 @@
|
||||
# fseeko.m4 serial 4
|
||||
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_FSEEKO],
|
||||
[
|
||||
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
|
||||
|
||||
dnl Persuade glibc <stdio.h> to declare fseeko().
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
AC_CACHE_CHECK([for fseeko], [gl_cv_func_fseeko],
|
||||
[
|
||||
AC_TRY_LINK([#include <stdio.h>], [fseeko (stdin, 0, 0);],
|
||||
[gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
|
||||
])
|
||||
if test $gl_cv_func_fseeko = no; then
|
||||
HAVE_FSEEKO=0
|
||||
gl_REPLACE_FSEEKO
|
||||
elif test $gl_cv_var_stdin_large_offset = no; then
|
||||
gl_REPLACE_FSEEKO
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_REPLACE_FSEEKO],
|
||||
[
|
||||
AC_LIBOBJ([fseeko])
|
||||
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
||||
REPLACE_FSEEKO=1
|
||||
])
|
34
m4/getdelim.m4
Normal file
34
m4/getdelim.m4
Normal file
@ -0,0 +1,34 @@
|
||||
# getdelim.m4 serial 5
|
||||
|
||||
dnl Copyright (C) 2005, 2006, 2007 Free Software dnl Foundation, Inc.
|
||||
dnl
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_PREREQ([2.59])
|
||||
|
||||
AC_DEFUN([gl_FUNC_GETDELIM],
|
||||
[
|
||||
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
||||
|
||||
dnl Persuade glibc <stdio.h> to declare getdelim().
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
AC_REPLACE_FUNCS([getdelim])
|
||||
AC_CHECK_DECLS_ONCE([getdelim])
|
||||
|
||||
if test $ac_cv_func_getdelim = no; then
|
||||
gl_PREREQ_GETDELIM
|
||||
fi
|
||||
|
||||
if test $ac_cv_have_decl_getdelim = no; then
|
||||
HAVE_DECL_GETDELIM=0
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/getdelim.c.
|
||||
AC_DEFUN([gl_PREREQ_GETDELIM],
|
||||
[
|
||||
AC_CHECK_FUNCS([flockfile funlockfile])
|
||||
])
|
81
m4/getline.m4
Normal file
81
m4/getline.m4
Normal file
@ -0,0 +1,81 @@
|
||||
# getline.m4 serial 18
|
||||
|
||||
dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007 Free
|
||||
dnl Software Foundation, Inc.
|
||||
dnl
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_PREREQ([2.59])
|
||||
|
||||
dnl See if there's a working, system-supplied version of the getline function.
|
||||
dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
|
||||
dnl have a function by that name in -linet that doesn't have anything
|
||||
dnl to do with the function we need.
|
||||
AC_DEFUN([gl_FUNC_GETLINE],
|
||||
[
|
||||
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
||||
|
||||
dnl Persuade glibc <stdio.h> to declare getline().
|
||||
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
||||
|
||||
AC_CHECK_DECLS_ONCE([getline])
|
||||
|
||||
gl_getline_needs_run_time_check=no
|
||||
AC_CHECK_FUNC(getline,
|
||||
dnl Found it in some library. Verify that it works.
|
||||
gl_getline_needs_run_time_check=yes,
|
||||
am_cv_func_working_getline=no)
|
||||
if test $gl_getline_needs_run_time_check = yes; then
|
||||
AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
|
||||
[echo fooN |tr -d '\012'|tr N '\012' > conftest.data
|
||||
AC_TRY_RUN([
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
int main ()
|
||||
{ /* Based on a test program from Karl Heuer. */
|
||||
char *line = NULL;
|
||||
size_t siz = 0;
|
||||
int len;
|
||||
FILE *in = fopen ("./conftest.data", "r");
|
||||
if (!in)
|
||||
return 1;
|
||||
len = getline (&line, &siz, in);
|
||||
exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
|
||||
}
|
||||
], am_cv_func_working_getline=yes dnl The library version works.
|
||||
, am_cv_func_working_getline=no dnl The library version does NOT work.
|
||||
, dnl We're cross compiling. Assume it works on glibc2 systems.
|
||||
[AC_EGREP_CPP([Lucky GNU user],
|
||||
[
|
||||
#include <features.h>
|
||||
#ifdef __GNU_LIBRARY__
|
||||
#if (__GLIBC__ >= 2)
|
||||
Lucky GNU user
|
||||
#endif
|
||||
#endif
|
||||
],
|
||||
[am_cv_func_working_getline=yes],
|
||||
[am_cv_func_working_getline=no])]
|
||||
)])
|
||||
fi
|
||||
|
||||
if test $ac_cv_have_decl_getline = no; then
|
||||
HAVE_DECL_GETLINE=0
|
||||
fi
|
||||
|
||||
if test $am_cv_func_working_getline = no; then
|
||||
REPLACE_GETLINE=1
|
||||
AC_LIBOBJ([getline])
|
||||
|
||||
gl_PREREQ_GETLINE
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/getline.c.
|
||||
AC_DEFUN([gl_PREREQ_GETLINE],
|
||||
[
|
||||
gl_FUNC_GETDELIM
|
||||
])
|
@ -1,5 +1,5 @@
|
||||
# getopt.m4 serial 13
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# getopt.m4 serial 14
|
||||
dnl Copyright (C) 2002-2006, 2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -46,7 +46,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
||||
if test -z "$GETOPT_H"; then
|
||||
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM([#include <getopt.h>],
|
||||
[AC_LANG_PROGRAM([[#include <getopt.h>]],
|
||||
[[
|
||||
char *myargv[3];
|
||||
myargv[0] = "conftest";
|
||||
|
47
m4/getpass.m4
Normal file
47
m4/getpass.m4
Normal file
@ -0,0 +1,47 @@
|
||||
# getpass.m4 serial 10
|
||||
dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# Provide a getpass() function if the system doesn't have it.
|
||||
AC_DEFUN([gl_FUNC_GETPASS],
|
||||
[
|
||||
AC_REPLACE_FUNCS(getpass)
|
||||
AC_CHECK_DECLS_ONCE(getpass)
|
||||
if test $ac_cv_func_getpass = no; then
|
||||
gl_PREREQ_GETPASS
|
||||
fi
|
||||
])
|
||||
|
||||
# Provide the GNU getpass() implementation. It supports passwords of
|
||||
# arbitrary length (not just 8 bytes as on HP-UX).
|
||||
AC_DEFUN([gl_FUNC_GETPASS_GNU],
|
||||
[
|
||||
AC_CHECK_DECLS_ONCE(getpass)
|
||||
dnl TODO: Detect when GNU getpass() is already found in glibc.
|
||||
AC_LIBOBJ(getpass)
|
||||
gl_PREREQ_GETPASS
|
||||
dnl We must choose a different name for our function, since on ELF systems
|
||||
dnl an unusable getpass() in libc.so would override our getpass() if it is
|
||||
dnl compiled into a shared library.
|
||||
AC_DEFINE([getpass], [gnu_getpass],
|
||||
[Define to a replacement function name for getpass().])
|
||||
])
|
||||
|
||||
# Prerequisites of lib/getpass.c.
|
||||
AC_DEFUN([gl_PREREQ_GETPASS], [
|
||||
AC_CHECK_HEADERS_ONCE(stdio_ext.h termios.h)
|
||||
AC_CHECK_FUNCS_ONCE(__fsetlocking tcgetattr tcsetattr)
|
||||
AC_CHECK_DECLS([__fsetlocking],,,
|
||||
[#include <stdio.h>
|
||||
#if HAVE_STDIO_EXT_H
|
||||
#include <stdio_ext.h>
|
||||
#endif])
|
||||
AC_CHECK_DECLS_ONCE([fflush_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([flockfile])
|
||||
AC_CHECK_DECLS_ONCE([fputs_unlocked])
|
||||
AC_CHECK_DECLS_ONCE([funlockfile])
|
||||
AC_CHECK_DECLS_ONCE([putc_unlocked])
|
||||
:
|
||||
])
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
@ -15,11 +15,11 @@
|
||||
|
||||
|
||||
# Specification in the form of a command-line invocation:
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --no-libtool --macro-prefix=gl c-ctype getopt maintainer-makefile
|
||||
# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=. --no-libtool --macro-prefix=gl alloca c-ctype getopt getpass-gnu maintainer-makefile quote quotearg
|
||||
|
||||
# Specification in the form of a few gnulib-tool.m4 macro invocations:
|
||||
gl_LOCAL_DIR([])
|
||||
gl_MODULES([c-ctype getopt maintainer-makefile])
|
||||
gl_MODULES([alloca c-ctype getopt getpass-gnu maintainer-makefile quote quotearg])
|
||||
gl_AVOID([])
|
||||
gl_SOURCE_BASE([lib])
|
||||
gl_M4_BASE([m4])
|
||||
|
@ -1,9 +1,28 @@
|
||||
# gnulib-common.m4 serial 3
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
# gnulib-common.m4 serial 5
|
||||
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# gl_COMMON
|
||||
# is expanded unconditionally through gnulib-tool magic.
|
||||
AC_DEFUN([gl_COMMON], [
|
||||
dnl Use AC_REQUIRE here, so that the code is expanded once only.
|
||||
AC_REQUIRE([gl_COMMON_BODY])
|
||||
])
|
||||
AC_DEFUN([gl_COMMON_BODY], [
|
||||
AH_VERBATIM([isoc99_inline],
|
||||
[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
|
||||
the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
|
||||
earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
|
||||
__APPLE__ && __MACH__ test for MacOS X.
|
||||
__APPLE_CC__ tests for the Apple compiler and its version.
|
||||
__STDC_VERSION__ tests for the C99 mode. */
|
||||
#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
|
||||
# define __GNUC_STDC_INLINE__ 1
|
||||
#endif])
|
||||
])
|
||||
|
||||
# gl_MODULE_INDICATOR([modulename])
|
||||
# defines a C macro indicating the presence of the given module.
|
||||
AC_DEFUN([gl_MODULE_INDICATOR],
|
||||
@ -12,6 +31,13 @@ AC_DEFUN([gl_MODULE_INDICATOR],
|
||||
[Define to 1 when using the gnulib module ]$1[.])
|
||||
])
|
||||
|
||||
# m4_foreach_w
|
||||
# is a backport of autoconf-2.59c's m4_foreach_w.
|
||||
# Remove this macro when we can assume autoconf >= 2.60.
|
||||
m4_ifndef([m4_foreach_w],
|
||||
[m4_define([m4_foreach_w],
|
||||
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
|
||||
|
||||
# AC_PROG_MKDIR_P
|
||||
# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
|
||||
# Remove this macro when we can assume autoconf >= 2.60.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||
# Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
@ -25,29 +25,82 @@ AC_DEFUN([gl_EARLY],
|
||||
m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
|
||||
m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
|
||||
AC_REQUIRE([AC_PROG_RANLIB])
|
||||
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
||||
AC_REQUIRE([AC_FUNC_FSEEKO])
|
||||
])
|
||||
|
||||
# This macro should be invoked from ./configure.ac, in the section
|
||||
# "Check for header files, types and library functions".
|
||||
AC_DEFUN([gl_INIT],
|
||||
[
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
|
||||
AM_CONDITIONAL([GL_COND_LIBTOOL], [false])
|
||||
gl_cond_libtool=false
|
||||
gl_libdeps=
|
||||
gl_ltlibdeps=
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
|
||||
m4_pushdef([gl_LIBSOURCES_LIST], [])
|
||||
m4_pushdef([gl_LIBSOURCES_DIR], [])
|
||||
gl_COMMON
|
||||
gl_source_base='lib'
|
||||
gl_EOVERFLOW
|
||||
gl_FUNC_ALLOCA
|
||||
gl_ERROR
|
||||
m4_ifdef([AM_XGETTEXT_OPTION],
|
||||
[AM_XGETTEXT_OPTION([--flag=error:3:c-format])
|
||||
AM_XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
|
||||
gl_EXITFAIL
|
||||
gl_FUNC_FSEEKO
|
||||
gl_STDIO_MODULE_INDICATOR([fseeko])
|
||||
gl_FUNC_GETDELIM
|
||||
gl_STDIO_MODULE_INDICATOR([getdelim])
|
||||
gl_FUNC_GETLINE
|
||||
gl_STDIO_MODULE_INDICATOR([getline])
|
||||
gl_GETOPT
|
||||
gl_FUNC_GETPASS_GNU
|
||||
AC_SUBST([LIBINTL])
|
||||
AC_SUBST([LTLIBINTL])
|
||||
# Autoconf 2.61a.99 and earlier don't support linking a file only
|
||||
# in VPATH builds. But since GNUmakefile is for maintainer use
|
||||
# only, it does not matter if we skip the link with older autoconf.
|
||||
# Automake 1.10.1 and earlier try to remove GNUmakefile in non-VPATH
|
||||
# builds, so use a shell variable to bypass this.
|
||||
GNUmakefile=GNUmakefile
|
||||
m4_if(m4_version_compare([2.61a.100],
|
||||
m4_defn([m4_PACKAGE_VERSION])), [1], [],
|
||||
[AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [],
|
||||
[GNUmakefile=$GNUmakefile])])
|
||||
gl_INLINE
|
||||
gl_FUNC_LSEEK
|
||||
gl_UNISTD_MODULE_INDICATOR([lseek])
|
||||
gl_QUOTE
|
||||
gl_QUOTEARG
|
||||
gl_FUNC_REALLOC_POSIX
|
||||
gl_STDLIB_MODULE_INDICATOR([realloc-posix])
|
||||
AM_STDBOOL_H
|
||||
gl_STDIO_H
|
||||
gl_STDLIB_H
|
||||
gl_FUNC_STRERROR
|
||||
gl_STRING_MODULE_INDICATOR([strerror])
|
||||
gl_HEADER_STRING_H
|
||||
gl_UNISTD_H
|
||||
LIBGNU_LIBDEPS="$gl_libdeps"
|
||||
AC_SUBST([LIBGNU_LIBDEPS])
|
||||
LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
|
||||
AC_SUBST([LIBGNU_LTLIBDEPS])
|
||||
gl_WCHAR_H
|
||||
gl_WCTYPE_H
|
||||
gl_XALLOC
|
||||
m4_ifval(gl_LIBSOURCES_LIST, [
|
||||
m4_syscmd([test ! -d ]gl_LIBSOURCES_DIR[ ||
|
||||
for gl_file in ]gl_LIBSOURCES_LIST[ ; do
|
||||
if test ! -r ]gl_LIBSOURCES_DIR[/$gl_file ; then
|
||||
echo "missing file ]gl_LIBSOURCES_DIR[/$gl_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
done])dnl
|
||||
m4_if(m4_sysval, [0], [],
|
||||
[AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
|
||||
])
|
||||
m4_popdef([gl_LIBSOURCES_DIR])
|
||||
m4_popdef([gl_LIBSOURCES_LIST])
|
||||
m4_popdef([AC_LIBSOURCES])
|
||||
m4_popdef([AC_REPLACE_FUNCS])
|
||||
m4_popdef([AC_LIBOBJ])
|
||||
@ -65,6 +118,49 @@ AC_DEFUN([gl_INIT],
|
||||
AC_SUBST([gl_LIBOBJS], [$gl_libobjs])
|
||||
AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs])
|
||||
])
|
||||
gltests_libdeps=
|
||||
gltests_ltlibdeps=
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
|
||||
m4_pushdef([gltests_LIBSOURCES_LIST], [])
|
||||
m4_pushdef([gltests_LIBSOURCES_DIR], [])
|
||||
gl_COMMON
|
||||
gl_source_base='tests'
|
||||
m4_ifval(gltests_LIBSOURCES_LIST, [
|
||||
m4_syscmd([test ! -d ]gltests_LIBSOURCES_DIR[ ||
|
||||
for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
|
||||
if test ! -r ]gltests_LIBSOURCES_DIR[/$gl_file ; then
|
||||
echo "missing file ]gltests_LIBSOURCES_DIR[/$gl_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
done])dnl
|
||||
m4_if(m4_sysval, [0], [],
|
||||
[AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
|
||||
])
|
||||
m4_popdef([gltests_LIBSOURCES_DIR])
|
||||
m4_popdef([gltests_LIBSOURCES_LIST])
|
||||
m4_popdef([AC_LIBSOURCES])
|
||||
m4_popdef([AC_REPLACE_FUNCS])
|
||||
m4_popdef([AC_LIBOBJ])
|
||||
AC_CONFIG_COMMANDS_PRE([
|
||||
gltests_libobjs=
|
||||
gltests_ltlibobjs=
|
||||
if test -n "$gltests_LIBOBJS"; then
|
||||
# Remove the extension.
|
||||
sed_drop_objext='s/\.o$//;s/\.obj$//'
|
||||
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
|
||||
gltests_libobjs="$gltests_libobjs $i.$ac_objext"
|
||||
gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
|
||||
done
|
||||
fi
|
||||
AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs])
|
||||
AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs])
|
||||
])
|
||||
LIBGNU_LIBDEPS="$gl_libdeps"
|
||||
AC_SUBST([LIBGNU_LIBDEPS])
|
||||
LIBGNU_LTLIBDEPS="$gl_ltlibdeps"
|
||||
AC_SUBST([LIBGNU_LTLIBDEPS])
|
||||
])
|
||||
|
||||
# Like AC_LIBOBJ, except that the module name goes
|
||||
@ -82,15 +178,41 @@ AC_DEFUN([gl_REPLACE_FUNCS], [
|
||||
])
|
||||
|
||||
# Like AC_LIBSOURCES, except the directory where the source file is
|
||||
# expected is derived from the gnulib-tool parametrization,
|
||||
# expected is derived from the gnulib-tool parameterization,
|
||||
# and alloca is special cased (for the alloca-opt module).
|
||||
# We could also entirely rely on EXTRA_lib..._SOURCES.
|
||||
AC_DEFUN([gl_LIBSOURCES], [
|
||||
m4_foreach([_gl_NAME], [$1], [
|
||||
m4_if(_gl_NAME, [alloca.c], [], [
|
||||
m4_syscmd([test -r lib/]_gl_NAME[ || test ! -d lib])dnl
|
||||
m4_if(m4_sysval, [0], [],
|
||||
[AC_FATAL([missing lib/]_gl_NAME)])
|
||||
m4_define([gl_LIBSOURCES_DIR], [lib])
|
||||
m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ])
|
||||
])
|
||||
])
|
||||
])
|
||||
|
||||
# Like AC_LIBOBJ, except that the module name goes
|
||||
# into gltests_LIBOBJS instead of into LIBOBJS.
|
||||
AC_DEFUN([gltests_LIBOBJ], [
|
||||
AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl
|
||||
gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext"
|
||||
])
|
||||
|
||||
# Like AC_REPLACE_FUNCS, except that the module name goes
|
||||
# into gltests_LIBOBJS instead of into LIBOBJS.
|
||||
AC_DEFUN([gltests_REPLACE_FUNCS], [
|
||||
m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
|
||||
AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)])
|
||||
])
|
||||
|
||||
# Like AC_LIBSOURCES, except the directory where the source file is
|
||||
# expected is derived from the gnulib-tool parameterization,
|
||||
# and alloca is special cased (for the alloca-opt module).
|
||||
# We could also entirely rely on EXTRA_lib..._SOURCES.
|
||||
AC_DEFUN([gltests_LIBSOURCES], [
|
||||
m4_foreach([_gl_NAME], [$1], [
|
||||
m4_if(_gl_NAME, [alloca.c], [], [
|
||||
m4_define([gltests_LIBSOURCES_DIR], [tests])
|
||||
m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ])
|
||||
])
|
||||
])
|
||||
])
|
||||
@ -98,21 +220,74 @@ AC_DEFUN([gl_LIBSOURCES], [
|
||||
# This macro records the list of files which have been installed by
|
||||
# gnulib-tool and may be removed by future gnulib-tool invocations.
|
||||
AC_DEFUN([gl_FILE_LIST], [
|
||||
build-aux/GNUmakefile
|
||||
build-aux/link-warning.h
|
||||
build-aux/maint.mk
|
||||
lib/alloca.c
|
||||
lib/alloca.in.h
|
||||
lib/c-ctype.c
|
||||
lib/c-ctype.h
|
||||
lib/error.c
|
||||
lib/error.h
|
||||
lib/exitfail.c
|
||||
lib/exitfail.h
|
||||
lib/fseeko.c
|
||||
lib/getdelim.c
|
||||
lib/getline.c
|
||||
lib/getopt.c
|
||||
lib/getopt.in.h
|
||||
lib/getopt1.c
|
||||
lib/getopt_int.h
|
||||
lib/getpass.c
|
||||
lib/getpass.h
|
||||
lib/gettext.h
|
||||
lib/intprops.h
|
||||
lib/lseek.c
|
||||
lib/quote.c
|
||||
lib/quote.h
|
||||
lib/quotearg.c
|
||||
lib/quotearg.h
|
||||
lib/realloc.c
|
||||
lib/stdbool.in.h
|
||||
lib/stdio-impl.h
|
||||
lib/stdio.in.h
|
||||
lib/stdlib.in.h
|
||||
lib/strerror.c
|
||||
lib/string.in.h
|
||||
lib/unistd.in.h
|
||||
lib/wchar.in.h
|
||||
lib/wctype.in.h
|
||||
lib/xalloc-die.c
|
||||
lib/xalloc.h
|
||||
lib/xmalloc.c
|
||||
m4/alloca.m4
|
||||
m4/eoverflow.m4
|
||||
m4/error.m4
|
||||
m4/exitfail.m4
|
||||
m4/extensions.m4
|
||||
m4/fseeko.m4
|
||||
m4/getdelim.m4
|
||||
m4/getline.m4
|
||||
m4/getopt.m4
|
||||
m4/getpass.m4
|
||||
m4/gnulib-common.m4
|
||||
m4/include_next.m4
|
||||
m4/inline.m4
|
||||
m4/lseek.m4
|
||||
m4/malloc.m4
|
||||
m4/mbrtowc.m4
|
||||
m4/mbstate_t.m4
|
||||
m4/quote.m4
|
||||
m4/quotearg.m4
|
||||
m4/realloc.m4
|
||||
m4/stdbool.m4
|
||||
m4/stdio_h.m4
|
||||
m4/stdlib_h.m4
|
||||
m4/strerror.m4
|
||||
m4/string_h.m4
|
||||
m4/unistd_h.m4
|
||||
m4/wchar.m4
|
||||
m4/wctype.m4
|
||||
m4/wint_t.m4
|
||||
m4/xalloc.m4
|
||||
top/GNUmakefile
|
||||
top/maint.mk
|
||||
])
|
||||
|
@ -1,5 +1,5 @@
|
||||
# include_next.m4 serial 4
|
||||
dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
# include_next.m4 serial 6
|
||||
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -63,12 +63,15 @@ EOF
|
||||
# The three "///" are to pacify Sun C 5.8, which otherwise would say
|
||||
# "warning: #include of /usr/include/... may be non-portable".
|
||||
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
|
||||
# Note: This macro assumes that the header file is not empty after
|
||||
# preprocessing, i.e. it does not only define preprocessor macros but also
|
||||
# provides some type/enum definitions or function/variable declarations.
|
||||
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
|
||||
[
|
||||
AC_REQUIRE([gl_INCLUDE_NEXT])
|
||||
AC_CHECK_HEADERS_ONCE([$1])
|
||||
|
||||
AC_FOREACH([gl_HEADER_NAME], [$1],
|
||||
m4_foreach_w([gl_HEADER_NAME], [$1],
|
||||
[AS_VAR_PUSHDEF([gl_next_header],
|
||||
[gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
|
||||
if test $gl_cv_have_include_next = yes; then
|
||||
|
40
m4/inline.m4
Normal file
40
m4/inline.m4
Normal file
@ -0,0 +1,40 @@
|
||||
# inline.m4 serial 3
|
||||
dnl Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Test for the 'inline' keyword or equivalent.
|
||||
dnl Define 'inline' to a supported equivalent, or to nothing if not supported,
|
||||
dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an
|
||||
dnl equivalent is effectively supported, i.e. if the compiler is likely to
|
||||
dnl drop unused 'static inline' functions.
|
||||
AC_DEFUN([gl_INLINE],
|
||||
[
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
AC_CACHE_CHECK([whether the compiler generally respects inline],
|
||||
[gl_cv_c_inline_effective],
|
||||
[if test $ac_cv_c_inline = no; then
|
||||
gl_cv_c_inline_effective=no
|
||||
else
|
||||
dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
|
||||
dnl specified.
|
||||
dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
|
||||
dnl depends on optimization flags, which can be in CFLAGS.
|
||||
dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM([[]],
|
||||
[[#ifdef __NO_INLINE__
|
||||
#error "inline is not effective"
|
||||
#endif]])],
|
||||
[gl_cv_c_inline_effective=yes],
|
||||
[gl_cv_c_inline_effective=no])
|
||||
fi
|
||||
])
|
||||
if test $gl_cv_c_inline_effective = yes; then
|
||||
AC_DEFINE([HAVE_INLINE], 1,
|
||||
[Define to 1 if the compiler supports one of the keywords
|
||||
'inline', '__inline__', '__inline' and effectively inlines
|
||||
functions marked as such.])
|
||||
fi
|
||||
])
|
50
m4/lseek.m4
Normal file
50
m4/lseek.m4
Normal file
@ -0,0 +1,50 @@
|
||||
# lseek.m4 serial 4
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_LSEEK],
|
||||
[
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_CACHE_CHECK([whether lseek detects pipes], [gl_cv_func_lseek_pipe],
|
||||
[if test $cross_compiling = no; then
|
||||
AC_LINK_IFELSE([
|
||||
#include <sys/types.h> /* for off_t */
|
||||
#include <stdio.h> /* for SEEK_CUR */
|
||||
#include <unistd.h>
|
||||
int main ()
|
||||
{
|
||||
/* Exit with success only if stdin is seekable. */
|
||||
return lseek (0, (off_t)0, SEEK_CUR) < 0;
|
||||
}],
|
||||
[if test -s conftest$ac_exeext \
|
||||
&& ./conftest$ac_exeext < conftest.$ac_ext \
|
||||
&& { echo hi | ./conftest$ac_exeext; test $? = 1; }; then
|
||||
gl_cv_func_lseek_pipe=yes
|
||||
else
|
||||
gl_cv_func_lseek_pipe=no
|
||||
fi],
|
||||
[gl_cv_func_lseek_pipe=no])
|
||||
else
|
||||
AC_COMPILE_IFELSE([
|
||||
#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __BEOS__
|
||||
/* mingw and BeOS mistakenly return 0 when trying to seek on pipes. */
|
||||
Choke me.
|
||||
#endif],
|
||||
[gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no])
|
||||
fi])
|
||||
if test $gl_cv_func_lseek_pipe = no; then
|
||||
gl_REPLACE_LSEEK
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_REPLACE_LSEEK],
|
||||
[
|
||||
AC_LIBOBJ([lseek])
|
||||
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
||||
REPLACE_LSEEK=1
|
||||
AC_DEFINE([LSEEK_PIPE_BROKEN], [1],
|
||||
[Define to 1 if lseek does not detect pipes.])
|
||||
])
|
41
m4/malloc.m4
Normal file
41
m4/malloc.m4
Normal file
@ -0,0 +1,41 @@
|
||||
# malloc.m4 serial 8
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# gl_FUNC_MALLOC_POSIX
|
||||
# --------------------
|
||||
# Test whether 'malloc' is POSIX compliant (sets errno to ENOMEM when it
|
||||
# fails), and replace malloc if it is not.
|
||||
AC_DEFUN([gl_FUNC_MALLOC_POSIX],
|
||||
[
|
||||
AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
|
||||
if test $gl_cv_func_malloc_posix = yes; then
|
||||
HAVE_MALLOC_POSIX=1
|
||||
AC_DEFINE([HAVE_MALLOC_POSIX], 1,
|
||||
[Define if the 'malloc' function is POSIX compliant.])
|
||||
else
|
||||
AC_LIBOBJ([malloc])
|
||||
HAVE_MALLOC_POSIX=0
|
||||
fi
|
||||
AC_SUBST([HAVE_MALLOC_POSIX])
|
||||
])
|
||||
|
||||
# Test whether malloc, realloc, calloc are POSIX compliant,
|
||||
# Set gl_cv_func_malloc_posix to yes or no accordingly.
|
||||
AC_DEFUN([gl_CHECK_MALLOC_POSIX],
|
||||
[
|
||||
AC_CACHE_CHECK([whether malloc, realloc, calloc are POSIX compliant],
|
||||
[gl_cv_func_malloc_posix],
|
||||
[
|
||||
dnl It is too dangerous to try to allocate a large amount of memory:
|
||||
dnl some systems go to their knees when you do that. So assume that
|
||||
dnl all Unix implementations of the function are POSIX compliant.
|
||||
AC_TRY_COMPILE([],
|
||||
[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
choke me
|
||||
#endif
|
||||
], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no])
|
||||
])
|
||||
])
|
31
m4/mbrtowc.m4
Normal file
31
m4/mbrtowc.m4
Normal file
@ -0,0 +1,31 @@
|
||||
# mbrtowc.m4 serial 8
|
||||
dnl Copyright (C) 2001-2002, 2004-2005 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Paul Eggert
|
||||
|
||||
dnl This file can be removed, and gl_FUNC_MBRTOWC replaced with
|
||||
dnl AC_FUNC_MBRTOWC, when autoconf 2.60 can be assumed everywhere.
|
||||
|
||||
AC_DEFUN([gl_FUNC_MBRTOWC],
|
||||
[
|
||||
dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
|
||||
AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
|
||||
gl_cv_func_mbrtowc,
|
||||
[AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <wchar.h>]],
|
||||
[[wchar_t wc;
|
||||
char const s[] = "";
|
||||
size_t n = 1;
|
||||
mbstate_t state;
|
||||
return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
|
||||
gl_cv_func_mbrtowc=yes,
|
||||
gl_cv_func_mbrtowc=no)])
|
||||
if test $gl_cv_func_mbrtowc = yes; then
|
||||
AC_DEFINE([HAVE_MBRTOWC], 1,
|
||||
[Define to 1 if mbrtowc and mbstate_t are properly declared.])
|
||||
fi
|
||||
])
|
30
m4/mbstate_t.m4
Normal file
30
m4/mbstate_t.m4
Normal file
@ -0,0 +1,30 @@
|
||||
# mbstate_t.m4 serial 10
|
||||
dnl Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# From Paul Eggert.
|
||||
|
||||
# BeOS 5 has <wchar.h> but does not define mbstate_t,
|
||||
# so you can't declare an object of that type.
|
||||
# Check for this incompatibility with Standard C.
|
||||
|
||||
# AC_TYPE_MBSTATE_T
|
||||
# -----------------
|
||||
AC_DEFUN([AC_TYPE_MBSTATE_T],
|
||||
[AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[AC_INCLUDES_DEFAULT[
|
||||
# include <wchar.h>]],
|
||||
[[mbstate_t x; return sizeof x;]])],
|
||||
[ac_cv_type_mbstate_t=yes],
|
||||
[ac_cv_type_mbstate_t=no])])
|
||||
if test $ac_cv_type_mbstate_t = yes; then
|
||||
AC_DEFINE([HAVE_MBSTATE_T], 1,
|
||||
[Define to 1 if <wchar.h> declares mbstate_t.])
|
||||
else
|
||||
AC_DEFINE([mbstate_t], int,
|
||||
[Define to a type if <wchar.h> does not define.])
|
||||
fi])
|
13
m4/quote.m4
Normal file
13
m4/quote.m4
Normal file
@ -0,0 +1,13 @@
|
||||
# quote.m4 serial 5
|
||||
dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_QUOTE],
|
||||
[
|
||||
AC_LIBOBJ([quote])
|
||||
|
||||
dnl Prerequisites of lib/quote.c.
|
||||
dnl (none)
|
||||
])
|
15
m4/quotearg.m4
Normal file
15
m4/quotearg.m4
Normal file
@ -0,0 +1,15 @@
|
||||
# quotearg.m4 serial 6
|
||||
dnl Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_QUOTEARG],
|
||||
[
|
||||
AC_LIBOBJ([quotearg])
|
||||
|
||||
dnl Prerequisites of lib/quotearg.c.
|
||||
AC_CHECK_FUNCS_ONCE([mbsinit])
|
||||
AC_TYPE_MBSTATE_T
|
||||
gl_FUNC_MBRTOWC
|
||||
])
|
23
m4/realloc.m4
Normal file
23
m4/realloc.m4
Normal file
@ -0,0 +1,23 @@
|
||||
# realloc.m4 serial 8
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# gl_FUNC_REALLOC_POSIX
|
||||
# ---------------------
|
||||
# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
|
||||
# fails), and replace realloc if it is not.
|
||||
AC_DEFUN([gl_FUNC_REALLOC_POSIX],
|
||||
[
|
||||
AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
|
||||
if test $gl_cv_func_malloc_posix = yes; then
|
||||
HAVE_REALLOC_POSIX=1
|
||||
AC_DEFINE([HAVE_REALLOC_POSIX], 1,
|
||||
[Define if the 'realloc' function is POSIX compliant.])
|
||||
else
|
||||
AC_LIBOBJ([realloc])
|
||||
HAVE_REALLOC_POSIX=0
|
||||
fi
|
||||
AC_SUBST([HAVE_REALLOC_POSIX])
|
||||
])
|
85
m4/stdio_h.m4
Normal file
85
m4/stdio_h.m4
Normal file
@ -0,0 +1,85 @@
|
||||
# stdio_h.m4 serial 10
|
||||
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_STDIO_H],
|
||||
[
|
||||
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
||||
gl_CHECK_NEXT_HEADERS([stdio.h])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
|
||||
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_STDIO_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
|
||||
GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX])
|
||||
GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
|
||||
GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
|
||||
GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
|
||||
GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
|
||||
GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
|
||||
GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
|
||||
GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
|
||||
GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
|
||||
GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
|
||||
GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
|
||||
GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
|
||||
GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
|
||||
GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
|
||||
GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
|
||||
GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
|
||||
GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
|
||||
REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
|
||||
REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF])
|
||||
REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF])
|
||||
REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
|
||||
HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
|
||||
REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF])
|
||||
HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
|
||||
REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
|
||||
REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
|
||||
HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
|
||||
REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
|
||||
REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
|
||||
REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
|
||||
HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
|
||||
REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO])
|
||||
REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK])
|
||||
HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
|
||||
REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO])
|
||||
REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL])
|
||||
REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
|
||||
HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM])
|
||||
HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE])
|
||||
REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE])
|
||||
])
|
||||
|
||||
dnl Code shared by fseeko and ftello. Determine if large files are supported,
|
||||
dnl but stdin does not start as a large file by default.
|
||||
AC_DEFUN([gl_STDIN_LARGE_OFFSET],
|
||||
[
|
||||
AC_CACHE_CHECK([whether stdin defaults to large file offsets],
|
||||
[gl_cv_var_stdin_large_offset],
|
||||
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
|
||||
[[#if defined __SL64 && defined __SCLE /* cygwin */
|
||||
/* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
|
||||
fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
|
||||
it is easier to do a version check than building a runtime test. */
|
||||
# include <cygwin/version.h>
|
||||
# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
|
||||
choke me
|
||||
# endif
|
||||
#endif]])],
|
||||
[gl_cv_var_stdin_large_offset=yes],
|
||||
[gl_cv_var_stdin_large_offset=no])])
|
||||
])
|
47
m4/stdlib_h.m4
Normal file
47
m4/stdlib_h.m4
Normal file
@ -0,0 +1,47 @@
|
||||
# stdlib_h.m4 serial 7
|
||||
dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_STDLIB_H],
|
||||
[
|
||||
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
|
||||
gl_CHECK_NEXT_HEADERS([stdlib.h])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
|
||||
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_STDLIB_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
|
||||
GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
|
||||
GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
|
||||
GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
|
||||
GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
|
||||
GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
|
||||
GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
|
||||
GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
|
||||
GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
|
||||
GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
|
||||
GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX])
|
||||
HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
|
||||
HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
|
||||
HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
|
||||
HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
|
||||
HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
|
||||
HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
|
||||
HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
|
||||
HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV])
|
||||
REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
|
||||
REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
|
||||
REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
|
||||
VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
|
||||
])
|
47
m4/strerror.m4
Normal file
47
m4/strerror.m4
Normal file
@ -0,0 +1,47 @@
|
||||
# strerror.m4 serial 8
|
||||
dnl Copyright (C) 2002, 2007-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_FUNC_STRERROR],
|
||||
[
|
||||
AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
|
||||
if test $gl_cv_func_working_strerror = no; then
|
||||
AC_LIBOBJ([strerror])
|
||||
AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
|
||||
[Define this to 1 if strerror is broken.])
|
||||
fi
|
||||
])
|
||||
|
||||
# Like gl_FUNC_STRERROR, except prepare for separate compilation (no AC_LIBOBJ).
|
||||
AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
|
||||
[
|
||||
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
|
||||
AC_CACHE_CHECK([for working strerror function],
|
||||
[gl_cv_func_working_strerror],
|
||||
[AC_RUN_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <string.h>
|
||||
]],
|
||||
[[return !*strerror (-2);]])],
|
||||
[gl_cv_func_working_strerror=yes],
|
||||
[gl_cv_func_working_strerror=no],
|
||||
[dnl Assume crossbuild works if it compiles.
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[#include <string.h>
|
||||
]],
|
||||
[[return !*strerror (-2);]])],
|
||||
[gl_cv_func_working_strerror=yes],
|
||||
[gl_cv_func_working_strerror=no])])])
|
||||
if test $gl_cv_func_working_strerror = no ; then
|
||||
REPLACE_STRERROR=1
|
||||
gl_PREREQ_STRERROR
|
||||
fi
|
||||
])
|
||||
|
||||
# Prerequisites of lib/strerror.c.
|
||||
AC_DEFUN([gl_PREREQ_STRERROR], [
|
||||
AC_CHECK_DECLS([strerror])
|
||||
])
|
89
m4/string_h.m4
Normal file
89
m4/string_h.m4
Normal file
@ -0,0 +1,89 @@
|
||||
# Configure a GNU-like replacement for <string.h>.
|
||||
|
||||
# Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
|
||||
# Written by Paul Eggert.
|
||||
|
||||
AC_DEFUN([gl_HEADER_STRING_H],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default behavior below is expanded
|
||||
dnl once only, before all statements that occur in other macros.
|
||||
AC_REQUIRE([gl_HEADER_STRING_H_BODY])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_HEADER_STRING_H_BODY],
|
||||
[
|
||||
AC_REQUIRE([AC_C_RESTRICT])
|
||||
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
|
||||
gl_CHECK_NEXT_HEADERS([string.h])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_STRING_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
|
||||
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
|
||||
GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
|
||||
GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR])
|
||||
GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR])
|
||||
GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY])
|
||||
GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
|
||||
GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
|
||||
GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP])
|
||||
GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP])
|
||||
GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN])
|
||||
GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK])
|
||||
GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP])
|
||||
GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR])
|
||||
GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR])
|
||||
GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R])
|
||||
GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN])
|
||||
GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN])
|
||||
GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR])
|
||||
GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR])
|
||||
GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR])
|
||||
GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP])
|
||||
GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP])
|
||||
GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP])
|
||||
GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR])
|
||||
GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN])
|
||||
GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK])
|
||||
GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN])
|
||||
GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP])
|
||||
GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
|
||||
GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
|
||||
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
|
||||
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
|
||||
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
|
||||
HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
|
||||
HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
|
||||
HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
|
||||
HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
|
||||
HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP])
|
||||
HAVE_STRNDUP=1; AC_SUBST([HAVE_STRNDUP])
|
||||
HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP])
|
||||
HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN])
|
||||
HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK])
|
||||
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
|
||||
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
|
||||
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
|
||||
HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
|
||||
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
|
||||
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
|
||||
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
|
||||
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
|
||||
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
|
||||
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
|
||||
])
|
@ -1,5 +1,5 @@
|
||||
# unistd_h.m4 serial 10
|
||||
dnl Copyright (C) 2006-2007 Free Software Foundation, Inc.
|
||||
# unistd_h.m4 serial 11
|
||||
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -34,6 +34,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
|
||||
GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
|
||||
GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
|
||||
GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
|
||||
GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
|
||||
GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
|
||||
@ -49,12 +50,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
|
||||
HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
|
||||
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
|
||||
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
|
||||
HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
|
||||
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
|
||||
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
|
||||
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
|
||||
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
|
||||
REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
|
||||
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
|
||||
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
|
||||
REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
|
||||
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
|
||||
])
|
||||
|
54
m4/wchar.m4
Normal file
54
m4/wchar.m4
Normal file
@ -0,0 +1,54 @@
|
||||
dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
|
||||
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Written by Eric Blake.
|
||||
|
||||
# wchar.m4 serial 4
|
||||
|
||||
AC_DEFUN([gl_WCHAR_H],
|
||||
[
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
AC_CACHE_CHECK([whether <wchar.h> is standalone],
|
||||
[gl_cv_header_wchar_h_standalone],
|
||||
[AC_COMPILE_IFELSE([[#include <wchar.h>
|
||||
wchar_t w;]],
|
||||
[gl_cv_header_wchar_h_standalone=yes],
|
||||
[gl_cv_header_wchar_h_standalone=no])])
|
||||
if test $gl_cv_header_wchar_h_standalone != yes; then
|
||||
WCHAR_H=wchar.h
|
||||
fi
|
||||
|
||||
dnl Prepare for creating substitute <wchar.h>.
|
||||
dnl Do it always: WCHAR_H may be empty here but can be set later.
|
||||
dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
|
||||
dnl character support).
|
||||
AC_CHECK_HEADERS_ONCE([wchar.h])
|
||||
if test $ac_cv_header_wchar_h = yes; then
|
||||
HAVE_WCHAR_H=1
|
||||
else
|
||||
HAVE_WCHAR_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_WCHAR_H])
|
||||
gl_CHECK_NEXT_HEADERS([wchar.h])
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
|
||||
[
|
||||
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
||||
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
||||
GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
||||
])
|
||||
|
||||
AC_DEFUN([gl_WCHAR_H_DEFAULTS],
|
||||
[
|
||||
GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
|
||||
dnl Assume proper GNU behavior unless another module says otherwise.
|
||||
HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
|
||||
REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
|
||||
WCHAR_H=
|
||||
AC_SUBST([WCHAR_H])
|
||||
])
|
74
m4/wctype.m4
Normal file
74
m4/wctype.m4
Normal file
@ -0,0 +1,74 @@
|
||||
# wctype.m4 serial 2
|
||||
|
||||
dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
|
||||
|
||||
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Written by Paul Eggert.
|
||||
|
||||
AC_DEFUN([gl_WCTYPE_H],
|
||||
[
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_CHECK_FUNCS_ONCE([iswcntrl])
|
||||
if test $ac_cv_func_iswcntrl = yes; then
|
||||
HAVE_ISWCNTRL=1
|
||||
else
|
||||
HAVE_ISWCNTRL=0
|
||||
fi
|
||||
AC_SUBST([HAVE_ISWCNTRL])
|
||||
AC_CHECK_HEADERS_ONCE([wctype.h])
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
|
||||
AC_REQUIRE([gt_TYPE_WINT_T])
|
||||
if test $gt_cv_c_wint_t = yes; then
|
||||
HAVE_WINT_T=1
|
||||
else
|
||||
HAVE_WINT_T=0
|
||||
fi
|
||||
AC_SUBST([HAVE_WINT_T])
|
||||
|
||||
WCTYPE_H=wctype.h
|
||||
if test $ac_cv_header_wctype_h = yes; then
|
||||
if test $ac_cv_func_iswcntrl = yes; then
|
||||
dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
|
||||
dnl The other functions are likely broken in the same way.
|
||||
AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
|
||||
[
|
||||
AC_TRY_RUN([#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
int main () { return iswprint ('x') == 0; }],
|
||||
[gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
|
||||
[AC_TRY_COMPILE([#include <stdlib.h>
|
||||
#if __GNU_LIBRARY__ == 1
|
||||
Linux libc5 i18n is broken.
|
||||
#endif], [],
|
||||
[gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no])
|
||||
])
|
||||
])
|
||||
if test $gl_cv_func_iswcntrl_works = yes; then
|
||||
WCTYPE_H=
|
||||
fi
|
||||
fi
|
||||
dnl Compute NEXT_WCTYPE_H even if WCTYPE_H is empty,
|
||||
dnl for the benefit of builds from non-distclean directories.
|
||||
gl_CHECK_NEXT_HEADERS([wctype.h])
|
||||
HAVE_WCTYPE_H=1
|
||||
else
|
||||
HAVE_WCTYPE_H=0
|
||||
fi
|
||||
AC_SUBST([HAVE_WCTYPE_H])
|
||||
AC_SUBST([WCTYPE_H])
|
||||
|
||||
if test "$gl_cv_func_iswcntrl_works" = no; then
|
||||
REPLACE_ISWCNTRL=1
|
||||
else
|
||||
REPLACE_ISWCNTRL=0
|
||||
fi
|
||||
AC_SUBST([REPLACE_ISWCNTRL])
|
||||
])
|
28
m4/wint_t.m4
Normal file
28
m4/wint_t.m4
Normal file
@ -0,0 +1,28 @@
|
||||
# wint_t.m4 serial 2 (gettext-0.17)
|
||||
dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
dnl Test whether <wchar.h> has the 'wint_t' type.
|
||||
dnl Prerequisite: AC_PROG_CC
|
||||
|
||||
AC_DEFUN([gt_TYPE_WINT_T],
|
||||
[
|
||||
AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
|
||||
[AC_TRY_COMPILE([
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
|
||||
before <wchar.h>. */
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <wchar.h>
|
||||
wint_t foo = (wchar_t)'\0';], ,
|
||||
gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
|
||||
if test $gt_cv_c_wint_t = yes; then
|
||||
AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
|
||||
fi
|
||||
])
|
24
m4/xalloc.m4
Normal file
24
m4/xalloc.m4
Normal file
@ -0,0 +1,24 @@
|
||||
# xalloc.m4 serial 16
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_XALLOC],
|
||||
[
|
||||
AC_LIBOBJ([xmalloc])
|
||||
|
||||
gl_PREREQ_XALLOC
|
||||
gl_PREREQ_XMALLOC
|
||||
])
|
||||
|
||||
# Prerequisites of lib/xalloc.h.
|
||||
AC_DEFUN([gl_PREREQ_XALLOC], [
|
||||
AC_REQUIRE([gl_INLINE])
|
||||
:
|
||||
])
|
||||
|
||||
# Prerequisites of lib/xmalloc.c.
|
||||
AC_DEFUN([gl_PREREQ_XMALLOC], [
|
||||
:
|
||||
])
|
2
maint.mk
2
maint.mk
@ -20,7 +20,7 @@
|
||||
ME := maint.mk
|
||||
|
||||
# List of all C-like source code files that will be tested for
|
||||
# stylistic "errors". You may want to define this to something
|
||||
# stylistic "errors". You may want to define this to something
|
||||
# more complex in Makefile.cfg.
|
||||
C_SOURCES ?= $(shell find . -name '*.[chly]')
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
## DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||
## Process this file with automake to produce Makefile.in.
|
||||
# Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
|
@ -1,9 +1,28 @@
|
||||
# gnulib-common.m4 serial 3
|
||||
dnl Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
# gnulib-common.m4 serial 4
|
||||
dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# gl_COMMON
|
||||
# is expanded unconditionally through gnulib-tool magic.
|
||||
AC_DEFUN([gl_COMMON], [
|
||||
dnl Use AC_REQUIRE here, so that the code is expanded once only.
|
||||
AC_REQUIRE([gl_COMMON_BODY])
|
||||
])
|
||||
AC_DEFUN([gl_COMMON_BODY], [
|
||||
AH_VERBATIM([isoc99_inline],
|
||||
[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
|
||||
the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
|
||||
earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
|
||||
__APPLE__ && __MACH__ test for MacOS X.
|
||||
__APPLE_CC__ tests for the Apple compiler and its version.
|
||||
__STDC_VERSION__ tests for the C99 mode. */
|
||||
#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
|
||||
# define __GNUC_STDC_INLINE__ 1
|
||||
#endif])
|
||||
])
|
||||
|
||||
# gl_MODULE_INDICATOR([modulename])
|
||||
# defines a C macro indicating the presence of the given module.
|
||||
AC_DEFUN([gl_MODULE_INDICATOR],
|
||||
|
@ -1,5 +1,5 @@
|
||||
# DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||
# Copyright (C) 2004-2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software, distributed under the terms of the GNU
|
||||
# General Public License. As a special exception to the GNU General
|
||||
@ -31,21 +31,17 @@ AC_DEFUN([md5_EARLY],
|
||||
# "Check for header files, types and library functions".
|
||||
AC_DEFUN([md5_INIT],
|
||||
[
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([md5_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([md5_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([md5_LIBSOURCES]))
|
||||
AM_CONDITIONAL([GL_COND_LIBTOOL], [false])
|
||||
gl_cond_libtool=false
|
||||
gl_libdeps=
|
||||
gl_ltlibdeps=
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([md5_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([md5_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([md5_LIBSOURCES]))
|
||||
gl_source_base='md5'
|
||||
gl_MD5
|
||||
gl_STDINT_H
|
||||
gl_WCHAR_H
|
||||
LIBMD5_LIBDEPS="$gl_libdeps"
|
||||
AC_SUBST([LIBMD5_LIBDEPS])
|
||||
LIBMD5_LTLIBDEPS="$gl_ltlibdeps"
|
||||
AC_SUBST([LIBMD5_LTLIBDEPS])
|
||||
m4_popdef([AC_LIBSOURCES])
|
||||
m4_popdef([AC_REPLACE_FUNCS])
|
||||
m4_popdef([AC_LIBOBJ])
|
||||
@ -63,6 +59,33 @@ AC_DEFUN([md5_INIT],
|
||||
AC_SUBST([md5_LIBOBJS], [$md5_libobjs])
|
||||
AC_SUBST([md5_LTLIBOBJS], [$md5_ltlibobjs])
|
||||
])
|
||||
gltests_libdeps=
|
||||
gltests_ltlibdeps=
|
||||
m4_pushdef([AC_LIBOBJ], m4_defn([md5tests_LIBOBJ]))
|
||||
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([md5tests_REPLACE_FUNCS]))
|
||||
m4_pushdef([AC_LIBSOURCES], m4_defn([md5tests_LIBSOURCES]))
|
||||
gl_source_base='tests'
|
||||
m4_popdef([AC_LIBSOURCES])
|
||||
m4_popdef([AC_REPLACE_FUNCS])
|
||||
m4_popdef([AC_LIBOBJ])
|
||||
AC_CONFIG_COMMANDS_PRE([
|
||||
md5tests_libobjs=
|
||||
md5tests_ltlibobjs=
|
||||
if test -n "$md5tests_LIBOBJS"; then
|
||||
# Remove the extension.
|
||||
sed_drop_objext='s/\.o$//;s/\.obj$//'
|
||||
for i in `for i in $md5tests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
|
||||
md5tests_libobjs="$md5tests_libobjs $i.$ac_objext"
|
||||
md5tests_ltlibobjs="$md5tests_ltlibobjs $i.lo"
|
||||
done
|
||||
fi
|
||||
AC_SUBST([md5tests_LIBOBJS], [$md5tests_libobjs])
|
||||
AC_SUBST([md5tests_LTLIBOBJS], [$md5tests_ltlibobjs])
|
||||
])
|
||||
LIBMD5_LIBDEPS="$gl_libdeps"
|
||||
AC_SUBST([LIBMD5_LIBDEPS])
|
||||
LIBMD5_LTLIBDEPS="$gl_ltlibdeps"
|
||||
AC_SUBST([LIBMD5_LTLIBDEPS])
|
||||
])
|
||||
|
||||
# Like AC_LIBOBJ, except that the module name goes
|
||||
@ -72,6 +95,13 @@ AC_DEFUN([md5_LIBOBJ], [
|
||||
md5_LIBOBJS="$md5_LIBOBJS $1.$ac_objext"
|
||||
])
|
||||
|
||||
# m4_foreach_w is provided by autoconf-2.59c and later.
|
||||
# This definition is to accommodate developers using versions
|
||||
# of autoconf older than that.
|
||||
m4_ifndef([m4_foreach_w],
|
||||
[m4_define([m4_foreach_w],
|
||||
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
|
||||
|
||||
# Like AC_REPLACE_FUNCS, except that the module name goes
|
||||
# into md5_LIBOBJS instead of into LIBOBJS.
|
||||
AC_DEFUN([md5_REPLACE_FUNCS], [
|
||||
@ -93,6 +123,41 @@ AC_DEFUN([md5_LIBSOURCES], [
|
||||
])
|
||||
])
|
||||
|
||||
# Like AC_LIBOBJ, except that the module name goes
|
||||
# into md5tests_LIBOBJS instead of into LIBOBJS.
|
||||
AC_DEFUN([md5tests_LIBOBJ], [
|
||||
AS_LITERAL_IF([$1], [md5tests_LIBSOURCES([$1.c])])dnl
|
||||
md5tests_LIBOBJS="$md5tests_LIBOBJS $1.$ac_objext"
|
||||
])
|
||||
|
||||
# m4_foreach_w is provided by autoconf-2.59c and later.
|
||||
# This definition is to accommodate developers using versions
|
||||
# of autoconf older than that.
|
||||
m4_ifndef([m4_foreach_w],
|
||||
[m4_define([m4_foreach_w],
|
||||
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
|
||||
|
||||
# Like AC_REPLACE_FUNCS, except that the module name goes
|
||||
# into md5tests_LIBOBJS instead of into LIBOBJS.
|
||||
AC_DEFUN([md5tests_REPLACE_FUNCS], [
|
||||
m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl
|
||||
AC_CHECK_FUNCS([$1], , [md5tests_LIBOBJ($ac_func)])
|
||||
])
|
||||
|
||||
# Like AC_LIBSOURCES, except the directory where the source file is
|
||||
# expected is derived from the gnulib-tool parametrization,
|
||||
# and alloca is special cased (for the alloca-opt module).
|
||||
# We could also entirely rely on EXTRA_lib..._SOURCES.
|
||||
AC_DEFUN([md5tests_LIBSOURCES], [
|
||||
m4_foreach([_gl_NAME], [$1], [
|
||||
m4_if(_gl_NAME, [alloca.c], [], [
|
||||
m4_syscmd([test -r tests/]_gl_NAME[ || test ! -d tests])dnl
|
||||
m4_if(m4_sysval, [0], [],
|
||||
[AC_FATAL([missing tests/]_gl_NAME)])
|
||||
])
|
||||
])
|
||||
])
|
||||
|
||||
# This macro records the list of files which have been installed by
|
||||
# gnulib-tool and may be removed by future gnulib-tool invocations.
|
||||
AC_DEFUN([md5_FILE_LIST], [
|
||||
|
@ -1,5 +1,5 @@
|
||||
# include_next.m4 serial 4
|
||||
dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
||||
# include_next.m4 serial 6
|
||||
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -63,12 +63,15 @@ EOF
|
||||
# The three "///" are to pacify Sun C 5.8, which otherwise would say
|
||||
# "warning: #include of /usr/include/... may be non-portable".
|
||||
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
|
||||
# Note: This macro assumes that the header file is not empty after
|
||||
# preprocessing, i.e. it does not only define preprocessor macros but also
|
||||
# provides some type/enum definitions or function/variable declarations.
|
||||
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
|
||||
[
|
||||
AC_REQUIRE([gl_INCLUDE_NEXT])
|
||||
AC_CHECK_HEADERS_ONCE([$1])
|
||||
|
||||
AC_FOREACH([gl_HEADER_NAME], [$1],
|
||||
m4_foreach_w([gl_HEADER_NAME], [$1],
|
||||
[AS_VAR_PUSHDEF([gl_next_header],
|
||||
[gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
|
||||
if test $gl_cv_have_include_next = yes; then
|
||||
|
@ -1,5 +1,5 @@
|
||||
# md5.m4 serial 9
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
# md5.m4 serial 10
|
||||
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -10,5 +10,6 @@ AC_DEFUN([gl_MD5],
|
||||
|
||||
dnl Prerequisites of lib/md5.c.
|
||||
AC_REQUIRE([AC_C_BIGENDIAN])
|
||||
AC_REQUIRE([AC_C_INLINE])
|
||||
:
|
||||
])
|
||||
|
@ -1,5 +1,5 @@
|
||||
# stdint.m4 serial 29
|
||||
dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
|
||||
# stdint.m4 serial 30
|
||||
dnl Copyright (C) 2001-2008 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
@ -240,7 +240,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
|
||||
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
|
||||
dnl config.h.in,
|
||||
dnl - extra AC_SUBST calls, so that the right substitutions are made.
|
||||
AC_FOREACH([gltype], [$1],
|
||||
m4_foreach_w([gltype], [$1],
|
||||
[AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
|
||||
[Define to the number of bits in type ']gltype['.])])
|
||||
for gltype in $1 ; do
|
||||
@ -265,7 +265,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
|
||||
AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
|
||||
eval BITSIZEOF_${GLTYPE}=\$result
|
||||
done
|
||||
AC_FOREACH([gltype], [$1],
|
||||
m4_foreach_w([gltype], [$1],
|
||||
[AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
|
||||
])
|
||||
|
||||
@ -278,7 +278,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
|
||||
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
|
||||
dnl config.h.in,
|
||||
dnl - extra AC_SUBST calls, so that the right substitutions are made.
|
||||
AC_FOREACH([gltype], [$1],
|
||||
m4_foreach_w([gltype], [$1],
|
||||
[AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
|
||||
[Define to 1 if ']gltype[' is a signed integer type.])])
|
||||
for gltype in $1 ; do
|
||||
@ -298,7 +298,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
|
||||
eval HAVE_SIGNED_${GLTYPE}=0
|
||||
fi
|
||||
done
|
||||
AC_FOREACH([gltype], [$1],
|
||||
m4_foreach_w([gltype], [$1],
|
||||
[AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
|
||||
])
|
||||
|
||||
@ -311,7 +311,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
|
||||
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
|
||||
dnl config.h.in,
|
||||
dnl - extra AC_SUBST calls, so that the right substitutions are made.
|
||||
AC_FOREACH([gltype], [$1],
|
||||
m4_foreach_w([gltype], [$1],
|
||||
[AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
|
||||
[Define to l, ll, u, ul, ull, etc., as suitable for
|
||||
constants of type ']gltype['.])])
|
||||
@ -350,7 +350,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
|
||||
eval ${GLTYPE}_SUFFIX=\$result
|
||||
AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], $result)
|
||||
done
|
||||
AC_FOREACH([gltype], [$1],
|
||||
m4_foreach_w([gltype], [$1],
|
||||
[AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
|
||||
])
|
||||
|
||||
|
30
md5/md5.c
30
md5/md5.c
@ -1,6 +1,6 @@
|
||||
/* Functions to compute MD5 message digest of files or memory blocks.
|
||||
according to the definition of MD5 in RFC 1321 from April 1992.
|
||||
Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2006
|
||||
Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2006,2008
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -80,27 +80,31 @@ md5_init_ctx (struct md5_ctx *ctx)
|
||||
ctx->buflen = 0;
|
||||
}
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result
|
||||
must be in little endian byte order.
|
||||
/* Copy the 4 byte value from v into the memory location pointed to by *cp,
|
||||
If your architecture allows unaligned access this is equivalent to
|
||||
* (uint32_t *) cp = v */
|
||||
static inline void
|
||||
set_uint32 (char *cp, uint32_t v)
|
||||
{
|
||||
memcpy (cp, &v, sizeof v);
|
||||
}
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result
|
||||
must be in little endian byte order. */
|
||||
void *
|
||||
md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
((uint32_t *) resbuf)[0] = SWAP (ctx->A);
|
||||
((uint32_t *) resbuf)[1] = SWAP (ctx->B);
|
||||
((uint32_t *) resbuf)[2] = SWAP (ctx->C);
|
||||
((uint32_t *) resbuf)[3] = SWAP (ctx->D);
|
||||
char *r = resbuf;
|
||||
set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
|
||||
set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
|
||||
set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
|
||||
set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
|
||||
|
||||
return resbuf;
|
||||
}
|
||||
|
||||
/* Process the remaining bytes in the internal buffer and the usual
|
||||
prolog according to the standard and write the result to RESBUF.
|
||||
|
||||
IMPORTANT: On some systems it is required that RESBUF is correctly
|
||||
aligned for a 32-bit value. */
|
||||
prolog according to the standard and write the result to RESBUF. */
|
||||
void *
|
||||
md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
|
||||
{
|
||||
|
12
md5/md5.h
12
md5/md5.h
@ -1,6 +1,6 @@
|
||||
/* Declaration of functions and data types used for MD5 sum computing
|
||||
library functions.
|
||||
Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006
|
||||
Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006,2008
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -93,19 +93,13 @@ extern void __md5_process_bytes (const void *buffer, size_t len,
|
||||
/* Process the remaining bytes in the buffer and put result from CTX
|
||||
in first 16 bytes following RESBUF. The result is always in little
|
||||
endian byte order, so that a byte-wise output yields to the wanted
|
||||
ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
|
||||
boundary. */
|
||||
ASCII representation of the message digest. */
|
||||
extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
|
||||
|
||||
|
||||
/* Put result from CTX in first 16 bytes following RESBUF. The result is
|
||||
always in little endian byte order, so that a byte-wise output yields
|
||||
to the wanted ASCII representation of the message digest.
|
||||
|
||||
IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
|
||||
boundary. */
|
||||
to the wanted ASCII representation of the message digest. */
|
||||
extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
|
||||
|
||||
|
||||
|
@ -23,6 +23,12 @@
|
||||
|
||||
#ifndef _GL_STDINT_H
|
||||
|
||||
/* When including a system file that in turn includes <inttypes.h>,
|
||||
use the system <inttypes.h>, not our substitute. This avoids
|
||||
problems with (for example) VMS, whose <sys/bitypes.h> includes
|
||||
<inttypes.h>. */
|
||||
#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
|
||||
|
||||
/* Get those types that are already defined in other system include
|
||||
files, so that we can "#define int8_t signed char" below without
|
||||
worrying about a later system include file containing a "typedef
|
||||
@ -66,9 +72,7 @@
|
||||
/* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
|
||||
int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__.
|
||||
<inttypes.h> also defines intptr_t and uintptr_t. */
|
||||
# define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
# undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
|
||||
#elif @HAVE_SYS_INTTYPES_H@
|
||||
/* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
|
||||
the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */
|
||||
@ -91,6 +95,8 @@
|
||||
|
||||
#endif
|
||||
|
||||
#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
|
||||
|
||||
/* Minimum and maximum values for a integer type under the usual assumption.
|
||||
Return an unspecified value if BITS == 0, adding a check to pacify
|
||||
picky compilers. */
|
||||
|
@ -26,6 +26,14 @@
|
||||
* the declaration of wcwidth().
|
||||
*/
|
||||
|
||||
#ifdef __need_mbstate_t
|
||||
/* Special invocation convention inside glibc header files. */
|
||||
|
||||
#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
|
||||
|
||||
#else
|
||||
/* Normal invocation convention. */
|
||||
|
||||
#ifndef _GL_WCHAR_H
|
||||
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
@ -80,3 +88,4 @@ extern int wcwidth (int /* actually wchar_t */);
|
||||
|
||||
#endif /* _GL_WCHAR_H */
|
||||
#endif /* _GL_WCHAR_H */
|
||||
#endif
|
||||
|
@ -3,7 +3,10 @@
|
||||
# 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
# Package source files
|
||||
lib/error.c
|
||||
lib/getopt.c
|
||||
lib/quotearg.c
|
||||
lib/xalloc-die.c
|
||||
src/cmpt.c
|
||||
src/connect.c
|
||||
src/convert.c
|
||||
@ -32,4 +35,3 @@ src/retr.c
|
||||
src/spider.c
|
||||
src/url.c
|
||||
src/utils.c
|
||||
src/xmalloc.c
|
||||
|
@ -1,3 +1,7 @@
|
||||
# For quotearg:
|
||||
s/^`$/“[1m/
|
||||
s/^'$/”[0m/
|
||||
|
||||
s/"\([^"]*\)"/“\1”/g
|
||||
s/`\([^`']*\)'/‘\1’/g
|
||||
s/ '\([^`']*\)' / ‘\1’ /g
|
||||
|
1077
po/en@boldquot.po
1077
po/en@boldquot.po
File diff suppressed because it is too large
Load Diff
1074
po/en@quot.po
1074
po/en@quot.po
File diff suppressed because it is too large
Load Diff
857
po/en_GB.po
857
po/en_GB.po
File diff suppressed because it is too large
Load Diff
1074
po/en_US.po
1074
po/en_US.po
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user