diff options
180 files changed, 4796 insertions, 1901 deletions
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh index 8cab8f6cdf..3c5ca768b7 100755 --- a/build-aux/gendocs.sh +++ b/build-aux/gendocs.sh @@ -2,7 +2,7 @@ # gendocs.sh -- generate a GNU manual in many formats. This script is # mentioned in maintain.texi. See the help message below for usage details. -scriptversion=2010-05-04.09 +scriptversion=2010-09-17.07 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. @@ -44,7 +44,7 @@ unset use_texi2html version="gendocs.sh $scriptversion -Copyright 2009 Free Software Foundation, Inc. +Copyright 2010 Free Software Foundation, Inc. There is NO warranty. You may redistribute this software under the terms of the GNU General Public License. For more information about these matters, see the files named COPYING." @@ -95,16 +95,16 @@ If a manual's Texinfo sources are spread across several directories, first copy or symlink all Texinfo sources into a single directory. (Part of the script's work is to make a tar.gz of the sources.) -You can set the environment variables MAKEINFO, TEXI2DVI, and DVIPS to -control the programs that get executed, and GENDOCS_TEMPLATE_DIR to -control where the gendocs_template file is looked for. (With --docbook, -the environment variables DOCBOOK2HTML, DOCBOOK2PDF, DOCBOOK2PS, and -DOCBOOK2TXT are also respected.) +You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML, and +DVIPS to control the programs that get executed, and +GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is +looked for. With --docbook, the environment variables DOCBOOK2HTML, +DOCBOOK2PDF, DOCBOOK2PS, and DOCBOOK2TXT are also respected. -By default, makeinfo is run in the default (English) locale, since -that's the language of most Texinfo manuals. If you happen to have a -non-English manual and non-English web site, see the SETLANG setting -in the source. +By default, makeinfo and texi2dvi are run in the default (English) +locale, since that's the language of most Texinfo manuals. If you +happen to have a non-English manual and non-English web site, see the +SETLANG setting in the source. Email bug reports or enhancement requests to bug-texinfo@gnu.org. " @@ -177,8 +177,8 @@ if test ! -r $GENDOCS_TEMPLATE_DIR/gendocs_template; then fi case $outdir in - /*) dotdot_outdir="$outdir";; - *) dotdot_outdir="../$outdir";; + /*) abs_outdir=$outdir;; + *) abs_outdir=$srcdir/$outdir;; esac echo Generating output formats for $srcfile @@ -186,13 +186,13 @@ echo Generating output formats for $srcfile cmd="$SETLANG $MAKEINFO -o $PACKAGE.info \"$srcfile\"" echo "Generating info files... ($cmd)" eval "$cmd" -mkdir -p $outdir/ -tar czf $outdir/$PACKAGE.info.tar.gz $PACKAGE.info* -info_tgz_size=`calcsize $outdir/$PACKAGE.info.tar.gz` +mkdir -p "$outdir/" +tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info* +info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"` # do not mv the info files, there's no point in having them available # separately on the web. -cmd="${TEXI2DVI} \"$srcfile\"" +cmd="$SETLANG ${TEXI2DVI} \"$srcfile\"" echo "Generating dvi ... ($cmd)" eval "$cmd" @@ -201,26 +201,26 @@ echo Generating postscript... ${DVIPS} $PACKAGE -o gzip -f -9 $PACKAGE.ps ps_gz_size=`calcsize $PACKAGE.ps.gz` -mv $PACKAGE.ps.gz $outdir/ +mv $PACKAGE.ps.gz "$outdir/" # compress/finish dvi: gzip -f -9 $PACKAGE.dvi dvi_gz_size=`calcsize $PACKAGE.dvi.gz` -mv $PACKAGE.dvi.gz $outdir/ +mv $PACKAGE.dvi.gz "$outdir/" -cmd="${TEXI2DVI} --pdf \"$srcfile\"" +cmd="$SETLANG ${TEXI2DVI} --pdf \"$srcfile\"" echo "Generating pdf ... ($cmd)" eval "$cmd" pdf_size=`calcsize $PACKAGE.pdf` -mv $PACKAGE.pdf $outdir/ +mv $PACKAGE.pdf "$outdir/" cmd="$SETLANG $MAKEINFO -o $PACKAGE.txt --no-split --no-headers \"$srcfile\"" echo "Generating ASCII... ($cmd)" eval "$cmd" ascii_size=`calcsize $PACKAGE.txt` -gzip -f -9 -c $PACKAGE.txt >$outdir/$PACKAGE.txt.gz -ascii_gz_size=`calcsize $outdir/$PACKAGE.txt.gz` -mv $PACKAGE.txt $outdir/ +gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz" +ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"` +mv $PACKAGE.txt "$outdir/" html_split() { @@ -232,12 +232,12 @@ html_split() ( cd ${split_html_dir} || exit 1 ln -sf ${PACKAGE}.html index.html - tar -czf $dotdot_outdir/${PACKAGE}.html_$1.tar.gz -- *.html + tar -czf "$abs_outdir/${PACKAGE}.html_$1.tar.gz" -- *.html ) - eval html_$1_tgz_size=`calcsize $outdir/${PACKAGE}.html_$1.tar.gz` - rm -f $outdir/html_$1/*.html - mkdir -p $outdir/html_$1/ - mv ${split_html_dir}/*.html $outdir/html_$1/ + eval html_$1_tgz_size=`calcsize "$outdir/${PACKAGE}.html_$1.tar.gz"` + rm -f "$outdir"/html_$1/*.html + mkdir -p "$outdir/html_$1/" + mv ${split_html_dir}/*.html "$outdir/html_$1/" rmdir ${split_html_dir} } @@ -248,9 +248,9 @@ if test -z "$use_texi2html"; then rm -rf $PACKAGE.html # in case a directory is left over eval "$cmd" html_mono_size=`calcsize $PACKAGE.html` - gzip -f -9 -c $PACKAGE.html >$outdir/$PACKAGE.html.gz - html_mono_gz_size=`calcsize $outdir/$PACKAGE.html.gz` - mv $PACKAGE.html $outdir/ + gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz" + html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"` + mv $PACKAGE.html "$outdir/" cmd="$SETLANG $MAKEINFO --html -o $PACKAGE.html $htmlarg \"$srcfile\"" echo "Generating html by node... ($cmd)" @@ -258,12 +258,12 @@ if test -z "$use_texi2html"; then split_html_dir=$PACKAGE.html ( cd ${split_html_dir} || exit 1 - tar -czf $dotdot_outdir/${PACKAGE}.html_node.tar.gz -- *.html + tar -czf "$abs_outdir/${PACKAGE}.html_node.tar.gz" -- *.html ) - html_node_tgz_size=`calcsize $outdir/${PACKAGE}.html_node.tar.gz` - rm -f $outdir/html_node/*.html - mkdir -p $outdir/html_node/ - mv ${split_html_dir}/*.html $outdir/html_node/ + html_node_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node.tar.gz"` + rm -f "$outdir"/html_node/*.html + mkdir -p "$outdir/html_node/" + mv ${split_html_dir}/*.html "$outdir/html_node/" rmdir ${split_html_dir} else cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $htmlarg \"$srcfile\"" @@ -271,9 +271,9 @@ else rm -rf $PACKAGE.html # in case a directory is left over eval "$cmd" html_mono_size=`calcsize $PACKAGE.html` - gzip -f -9 -c $PACKAGE.html >$outdir/$PACKAGE.html.gz - html_mono_gz_size=`calcsize $outdir/$PACKAGE.html.gz` - mv $PACKAGE.html $outdir/ + gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz" + html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"` + mv $PACKAGE.html "$outdir/" html_split node html_split chapter @@ -282,51 +282,54 @@ fi echo Making .tar.gz for sources... d=`dirname $srcfile` -srcfiles=`ls $d/*.texinfo $d/*.texi $d/*.txi $d/*.eps 2>/dev/null` || true -tar cvzfh $outdir/$PACKAGE.texi.tar.gz $srcfiles -texi_tgz_size=`calcsize $outdir/$PACKAGE.texi.tar.gz` +( + cd "$d" + srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null` || true + tar cvzfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles +) +texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"` if test -n "$docbook"; then cmd="$SETLANG $MAKEINFO -o - --docbook \"$srcfile\" > ${srcdir}/$PACKAGE-db.xml" echo "Generating docbook XML... ($cmd)" eval "$cmd" docbook_xml_size=`calcsize $PACKAGE-db.xml` - gzip -f -9 -c $PACKAGE-db.xml >$outdir/$PACKAGE-db.xml.gz - docbook_xml_gz_size=`calcsize $outdir/$PACKAGE-db.xml.gz` - mv $PACKAGE-db.xml $outdir/ + gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz" + docbook_xml_gz_size=`calcsize "$outdir/$PACKAGE-db.xml.gz"` + mv $PACKAGE-db.xml "$outdir/" - cmd="${DOCBOOK2HTML} -o $split_html_db_dir ${outdir}/$PACKAGE-db.xml" + cmd="${DOCBOOK2HTML} -o $split_html_db_dir \"${outdir}/$PACKAGE-db.xml\"" echo "Generating docbook HTML... ($cmd)" eval "$cmd" split_html_db_dir=html_node_db ( cd ${split_html_db_dir} || exit 1 - tar -czf $dotdot_outdir/${PACKAGE}.html_node_db.tar.gz -- *.html + tar -czf "$abs_outdir/${PACKAGE}.html_node_db.tar.gz" -- *.html ) - html_node_db_tgz_size=`calcsize $outdir/${PACKAGE}.html_node_db.tar.gz` - rm -f $outdir/html_node_db/*.html - mkdir -p $outdir/html_node_db - mv ${split_html_db_dir}/*.html $outdir/html_node_db/ + html_node_db_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node_db.tar.gz"` + rm -f "$outdir"/html_node_db/*.html + mkdir -p "$outdir/html_node_db" + mv ${split_html_db_dir}/*.html "$outdir/html_node_db/" rmdir ${split_html_db_dir} - cmd="${DOCBOOK2TXT} ${outdir}/$PACKAGE-db.xml" + cmd="${DOCBOOK2TXT} \"${outdir}/$PACKAGE-db.xml\"" echo "Generating docbook ASCII... ($cmd)" eval "$cmd" docbook_ascii_size=`calcsize $PACKAGE-db.txt` - mv $PACKAGE-db.txt $outdir/ + mv $PACKAGE-db.txt "$outdir/" - cmd="${DOCBOOK2PS} ${outdir}/$PACKAGE-db.xml" + cmd="${DOCBOOK2PS} \"${outdir}/$PACKAGE-db.xml\"" echo "Generating docbook PS... ($cmd)" eval "$cmd" - gzip -f -9 -c $PACKAGE-db.ps >$outdir/$PACKAGE-db.ps.gz - docbook_ps_gz_size=`calcsize $outdir/$PACKAGE-db.ps.gz` - mv $PACKAGE-db.ps $outdir/ + gzip -f -9 -c $PACKAGE-db.ps >"$outdir/$PACKAGE-db.ps.gz" + docbook_ps_gz_size=`calcsize "$outdir/$PACKAGE-db.ps.gz"` + mv $PACKAGE-db.ps "$outdir/" - cmd="${DOCBOOK2PDF} ${outdir}/$PACKAGE-db.xml" + cmd="${DOCBOOK2PDF} \"${outdir}/$PACKAGE-db.xml\"" echo "Generating docbook PDF... ($cmd)" eval "$cmd" docbook_pdf_size=`calcsize $PACKAGE-db.pdf` - mv $PACKAGE-db.pdf $outdir/ + mv $PACKAGE-db.pdf "$outdir/" fi echo "Writing index file..." @@ -363,7 +366,7 @@ sed \ -e "s,%%SCRIPTURL%%,$scripturl,g" \ -e "s!%%SCRIPTNAME%%!$prog!g" \ -e "$CONDS" \ -$GENDOCS_TEMPLATE_DIR/gendocs_template >$outdir/index.html +$GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html" echo "Done, see $outdir/ subdirectory for new files." diff --git a/build-aux/pmccabe2html b/build-aux/pmccabe2html index 3f887adc7d..28117af240 100644 --- a/build-aux/pmccabe2html +++ b/build-aux/pmccabe2html @@ -1,4 +1,4 @@ -# pmccabe2html - AWK script to convert pmccabe output to html +# pmccabe2html - AWK script to convert pmccabe output to html -*- awk -*- # Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. @@ -22,15 +22,16 @@ # Typical Invocation is from a Makefile.am: # # cyclo-$(PACKAGE).html: -# $(PMCCABE) ${top_srcdir}/lib/*.[ch] \ -# | sort -nr \ -# | $(AWK) -f ${top_srcdir}/build-aux/pmccabe2html \ -# -v lang=html -v name="$(PACKAGE_NAME)" \ -# -v vcurl="http://git.savannah.gnu.org/gitweb/?p=$(PACKAGE).git;a=blob;f=%FILENAME%;hb=HEAD" \ -# -v url="http://www.gnu.org/software/$(PACKAGE)/" \ -# -v css=${top_srcdir}/build-aux/pmccabe.css \ -# > $@-tmp -# mv $@-tmp $@ +# $(PMCCABE) ${top_srcdir}/src/*.[ch] \ +# | sort -nr \ +# | $(AWK) -f ${top_srcdir}/build-aux/pmccabe2html \ +# -v lang=html -v name="$(PACKAGE_NAME)" \ +# -v vcurl="http://git.savannah.gnu.org/gitweb/?p=$(PACKAGE).git;a=blob;f=%FILENAME%;hb=HEAD" \ +# -v url="http://www.gnu.org/software/$(PACKAGE)/" \ +# -v css=${top_srcdir}/build-aux/pmccabe.css \ +# -v cut_dir=${top_srcdir}/ \ +# > $@-tmp +# mv $@-tmp $@ # # The variables available are: # lang output language, either 'html' or 'wiki' @@ -55,7 +56,6 @@ BEGIN { cyclo_simple_max = 10 cyclo_moderate_max = 20 cyclo_high_max = 50 - cut_dir = "/../" source_file_link_tmpl = vcurl # HTML options diff --git a/doc/fdl-1.3.texi b/doc/fdl-1.3.texi index 8805f1a47d..fc19ddddfa 100644 --- a/doc/fdl-1.3.texi +++ b/doc/fdl-1.3.texi @@ -92,16 +92,16 @@ An image format is not Transparent if used for any substantial amount of text. A copy that is not ``Transparent'' is called ``Opaque''. Examples of suitable formats for Transparent copies include plain -@sc{ascii} without markup, Texinfo input format, La@TeX{} input -format, @acronym{SGML} or @acronym{XML} using a publicly available -@acronym{DTD}, and standard-conforming simple @acronym{HTML}, -PostScript or @acronym{PDF} designed for human modification. Examples -of transparent image formats include @acronym{PNG}, @acronym{XCF} and -@acronym{JPG}. Opaque formats include proprietary formats that can be -read and edited only by proprietary word processors, @acronym{SGML} or -@acronym{XML} for which the @acronym{DTD} and/or processing tools are -not generally available, and the machine-generated @acronym{HTML}, -PostScript or @acronym{PDF} produced by some word processors for +ASCII without markup, Texinfo input format, La@TeX{} input +format, SGML or XML using a publicly available +DTD, and standard-conforming simple HTML, +PostScript or PDF designed for human modification. Examples +of transparent image formats include PNG, XCF and +JPG. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, SGML or +XML for which the DTD and/or processing tools are +not generally available, and the machine-generated HTML, +PostScript or PDF produced by some word processors for output purposes only. The ``Title Page'' means, for a printed book, the title page itself, diff --git a/gl/Makefile.am b/gl/Makefile.am index ed9126174d..e1b67d75da 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -38,6 +38,16 @@ libgnu_la_LIBADD = $(gl_LTLIBOBJS) libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS) EXTRA_libgnu_la_SOURCES = libgnu_la_LDFLAGS = $(AM_LDFLAGS) +libgnu_la_LDFLAGS += -no-undefined +libgnu_la_LDFLAGS += $(GETADDRINFO_LIB) +libgnu_la_LDFLAGS += $(HOSTENT_LIB) +libgnu_la_LDFLAGS += $(INET_NTOP_LIB) +libgnu_la_LDFLAGS += $(INET_PTON_LIB) +libgnu_la_LDFLAGS += $(LIBSOCKET) +libgnu_la_LDFLAGS += $(LIB_CLOCK_GETTIME) +libgnu_la_LDFLAGS += $(LTLIBINTL) +libgnu_la_LDFLAGS += $(LTLIBREADLINE) +libgnu_la_LDFLAGS += $(SERVENT_LIB) ## begin gnulib module accept @@ -120,6 +130,7 @@ arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \ @@ -214,6 +225,7 @@ errno.h: errno.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ @@ -259,6 +271,7 @@ float.h: float.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ < $(srcdir)/float.in.h; \ } > $@-t && \ @@ -278,6 +291,15 @@ EXTRA_libgnu_la_SOURCES += fseeko.c ## end gnulib module fseeko +## begin gnulib module ftello + + +EXTRA_DIST += ftello.c stdio-impl.h + +EXTRA_libgnu_la_SOURCES += ftello.c + +## end gnulib module ftello + ## begin gnulib module gendocs @@ -418,6 +440,15 @@ EXTRA_DIST += $(top_srcdir)/maint.mk ## end gnulib module maintainer-makefile +## begin gnulib module malloc-posix + + +EXTRA_DIST += malloc.c + +EXTRA_libgnu_la_SOURCES += malloc.c + +## end gnulib module malloc-posix + ## begin gnulib module memchr @@ -444,6 +475,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \ -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \ -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \ @@ -475,6 +507,7 @@ netinet/in.h: netinet_in.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ < $(srcdir)/netinet_in.in.h; \ @@ -624,6 +657,7 @@ stdarg.h: stdarg.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \ < $(srcdir)/stdarg.in.h; \ } > $@-t && \ @@ -663,6 +697,7 @@ stddef.h: stddef.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ @@ -687,6 +722,7 @@ stdint.h: stdint.in.h sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ @@ -728,6 +764,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ @@ -838,7 +875,9 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ + -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \ -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ @@ -861,15 +900,15 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \ -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ + -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \ -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ + -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ - -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ - -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ @@ -878,7 +917,6 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ - -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ @@ -889,9 +927,12 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ + -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ + -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ @@ -928,6 +969,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \ -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \ @@ -1019,6 +1061,7 @@ sys/select.h: sys_select.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \ -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \ -e 's|@''GNULIB_SELECT''@|$(GNULIB_SELECT)|g' \ @@ -1048,6 +1091,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ @@ -1096,6 +1140,7 @@ sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ @@ -1155,6 +1200,7 @@ sys/time.h: sys_time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \ -e 's/@''GNULIB_GETTIMEOFDAY''@/$(GNULIB_GETTIMEOFDAY)/g' \ -e 's/@''HAVE_GETTIMEOFDAY''@/$(HAVE_GETTIMEOFDAY)/g' \ @@ -1183,6 +1229,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \ -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \ @@ -1197,6 +1244,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ + -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ @@ -1230,6 +1278,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ @@ -1415,6 +1464,7 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \ diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h index f7c3bc728a..84a4006789 100644 --- a/gl/arpa_inet.in.h +++ b/gl/arpa_inet.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc under MinGW. diff --git a/gl/errno.in.h b/gl/errno.in.h index 140e5d1346..7ebaddcfc2 100644 --- a/gl/errno.in.h +++ b/gl/errno.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_ERRNO_H@ @@ -98,6 +99,7 @@ /* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. + Likewise, on NonStop Kernel, EDQUOT is not defined. Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. @@ -150,6 +152,11 @@ # define GNULIB_defined_ESTALE 1 # endif +# ifndef EDQUOT +# define EDQUOT 2010 +# define GNULIB_defined_EDQUOT 1 +# endif + # ifndef ECANCELED # define ECANCELED 2008 # define GNULIB_defined_ECANCELED 1 diff --git a/gl/float.in.h b/gl/float.in.h index caf822f1d0..a68ec61a96 100644 --- a/gl/float.in.h +++ b/gl/float.in.h @@ -20,6 +20,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_FLOAT_H@ diff --git a/gl/ftello.c b/gl/ftello.c new file mode 100644 index 0000000000..098e36ae58 --- /dev/null +++ b/gl/ftello.c @@ -0,0 +1,77 @@ +/* An ftello() function that works around platform bugs. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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> + +/* Specification. */ +#include <stdio.h> + +/* Get lseek. */ +#include <unistd.h> + +#include "stdio-impl.h" + +off_t +ftello (FILE *fp) +#undef ftello +#if !HAVE_FTELLO +# undef ftell +# define ftello ftell +#endif +{ +#if LSEEK_PIPE_BROKEN + /* mingw gives bogus answers rather than failure on non-seekable files. */ + if (lseek (fileno (fp), 0, SEEK_CUR) == -1) + return -1; +#endif + +#if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */ + /* The Solaris stdio leaves the _IOREAD flag set after reading from a file + reaches EOF and the program then starts writing to the file. ftello + gets confused by this. */ + if (fp_->_flag & _IOWRT) + { + off_t pos; + + /* Call ftello nevertheless, for the side effects that it does on fp. */ + ftello (fp); + + /* Compute the file position ourselves. */ + pos = llseek (fileno (fp), (off_t) 0, SEEK_CUR); + if (pos >= 0) + { + if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL) + pos += fp_->_ptr - fp_->_base; + } + return pos; + } +#endif + +#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 ftello 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 + return ftello (fp); +} diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c index 6aa676c89c..4734606a47 100644 --- a/gl/getaddrinfo.c +++ b/gl/getaddrinfo.c @@ -59,6 +59,9 @@ # define WIN32_NATIVE #endif +/* gl_sockets_startup */ +#include "sockets.h" + #ifdef WIN32_NATIVE typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, const struct addrinfo*, @@ -101,6 +104,8 @@ use_win32_p (void) return 0; } + gl_sockets_startup (SOCKETS_1_1); + return 1; } #endif diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4 index d02a039363..e4325ac660 100644 --- a/gl/m4/errno_h.m4 +++ b/gl/m4/errno_h.m4 @@ -1,5 +1,5 @@ -# errno_h.m4 serial 6 -dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. +# errno_h.m4 serial 7 +dnl Copyright (C) 2004, 2006, 2008-2010 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. @@ -37,6 +37,9 @@ booboo #if !defined ESTALE booboo #endif +#if !defined EDQUOT +booboo +#endif #if !defined ECANCELED booboo #endif diff --git a/gl/m4/error.m4 b/gl/m4/error.m4 index 9f1307a428..dd5a197b6e 100644 --- a/gl/m4/error.m4 +++ b/gl/m4/error.m4 @@ -1,4 +1,4 @@ -#serial 12 +#serial 13 # Copyright (C) 1996-1998, 2001-2004, 2009-2010 Free Software Foundation, Inc. # @@ -13,6 +13,23 @@ AC_DEFUN([gl_ERROR], gl_PREREQ_ERROR ]) +# Redefine AC_FUNC_ERROR_AT_LINE, because it is no longer maintained in +# Autoconf. +AC_DEFUN([AC_FUNC_ERROR_AT_LINE], +[ + AC_LIBSOURCES([error.h, error.c])dnl + AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <error.h>]], + [[error_at_line (0, 0, "", 0, "an error occurred");]])], + [ac_cv_lib_error_at_line=yes], + [ac_cv_lib_error_at_line=no])]) + if test $ac_cv_lib_error_at_line = no; then + AC_LIBOBJ([error]) + fi +]) + # Prerequisites of lib/error.c. AC_DEFUN([gl_PREREQ_ERROR], [ diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4 index a74a0d957f..f6099db405 100644 --- a/gl/m4/float_h.m4 +++ b/gl/m4/float_h.m4 @@ -1,4 +1,4 @@ -# float_h.m4 serial 3 +# float_h.m4 serial 4 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,7 @@ AC_DEFUN([gl_FLOAT_H], AC_REQUIRE([AC_CANONICAL_HOST]) FLOAT_H= case "$host_os" in - beos* | openbsd*) + beos* | openbsd* | mirbsd*) FLOAT_H=float.h gl_CHECK_NEXT_HEADERS([float.h]) ;; diff --git a/gl/m4/ftello.m4 b/gl/m4/ftello.m4 new file mode 100644 index 0000000000..33201a0107 --- /dev/null +++ b/gl/m4/ftello.m4 @@ -0,0 +1,130 @@ +# ftello.m4 serial 8 +dnl Copyright (C) 2007-2010 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_FTELLO], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_STDIN_LARGE_OFFSET]) + + dnl Persuade glibc <stdio.h> to declare ftello(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stdio.h>]], + [[ftello (stdin);]])], + [gl_cv_func_ftello=yes], + [gl_cv_func_ftello=no]) + ]) + if test $gl_cv_func_ftello = no; then + HAVE_FTELLO=0 + else + if test $gl_cv_var_stdin_large_offset = no; then + REPLACE_FTELLO=1 + else + dnl Detect bug on Solaris. + dnl ftell and ftello produce incorrect results after putc that followed a + dnl getc call that reached EOF on Solaris. This is because the _IOREAD + dnl flag does not get cleared in this case, even though _IOWRT gets set, + dnl and ftell and ftello look whether the _IOREAD flag is set. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether ftello works], + [gl_cv_func_ftello_works], + [ + dnl Initial guess, used when cross-compiling or when /dev/tty cannot + dnl be opened. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris. + solaris*) gl_cv_func_ftello_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_ftello_works="guessing yes" ;; + esac +changequote([,])dnl + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#define TESTFILE "conftest.tmp" +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + return 70; + if (fwrite ("foogarsh", 1, 8, fp) < 8) + return 71; + if (fclose (fp)) + return 72; + + /* The file's contents is now "foogarsh". */ + + /* Try writing after reading to EOF. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + return 73; + if (fseek (fp, -1, SEEK_END)) + return 74; + if (!(getc (fp) == 'h')) + return 1; + if (!(getc (fp) == EOF)) + return 2; + if (!(ftell (fp) == 8)) + return 3; + if (!(ftell (fp) == 8)) + return 4; + if (!(putc ('!', fp) == '!')) + return 5; + if (!(ftell (fp) == 9)) + return 6; + if (!(fclose (fp) == 0)) + return 7; + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + return 75; + { + char buf[10]; + if (!(fread (buf, 1, 10, fp) == 9)) + return 10; + if (!(memcmp (buf, "foogarsh!", 9) == 0)) + return 11; + } + if (!(fclose (fp) == 0)) + return 12; + + /* The file's contents is now "foogarsh!". */ + + return 0; +}]])], + [gl_cv_func_ftello_works=yes], + [gl_cv_func_ftello_works=no], [:]) + ]) + case "$gl_cv_func_ftello_works" in + *yes) ;; + *) + REPLACE_FTELLO=1 + AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1], + [Define to 1 if the system's ftello function has the Solaris bug.]) + ;; + esac + fi + fi + if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then + gl_REPLACE_FTELLO + fi +]) + +AC_DEFUN([gl_REPLACE_FTELLO], +[ + AC_LIBOBJ([ftello]) +]) diff --git a/gl/m4/getpagesize.m4 b/gl/m4/getpagesize.m4 new file mode 100644 index 0000000000..313ad7fa26 --- /dev/null +++ b/gl/m4/getpagesize.m4 @@ -0,0 +1,33 @@ +# getpagesize.m4 serial 8 +dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_GETPAGESIZE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS([getpagesize]) + if test $ac_cv_func_getpagesize = no; then + HAVE_GETPAGESIZE=0 + AC_CHECK_HEADERS([OS.h]) + if test $ac_cv_header_OS_h = yes; then + HAVE_OS_H=1 + fi + AC_CHECK_HEADERS([sys/param.h]) + if test $ac_cv_header_sys_param_h = yes; then + HAVE_SYS_PARAM_H=1 + fi + fi + case "$host_os" in + mingw*) + REPLACE_GETPAGESIZE=1 + AC_LIBOBJ([getpagesize]) + ;; + esac + dnl Also check whether it's declared. + dnl mingw has getpagesize() in libgcc.a but doesn't declare it. + AC_CHECK_DECL([getpagesize], , [HAVE_DECL_GETPAGESIZE=0]) +]) diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index a9cec83bc5..0987814cfe 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -10,8 +10,8 @@ # # This file represents the specification of how gnulib-tool is used. # It acts as a cache: It is written and read by gnulib-tool. -# In projects using CVS, this file is meant to be stored in CVS, -# like the configure.ac and various Makefile.am files. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. # Specification in the form of a command-line invocation: diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 3db9b2553b..201ec0f99a 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -12,7 +12,8 @@ # This file represents the compiled summary of the specification in # gnulib-cache.m4. It lists the computed macro invocations that need # to be invoked from configure.ac. -# In projects using CVS, this file can be treated like other built files. +# In projects that use version control, this file can be treated like +# other built files. # This macro should be invoked from ./configure.ac, in the section @@ -36,6 +37,8 @@ AC_DEFUN([gl_EARLY], # Code from module arpa_inet-tests: # Code from module autobuild: AB_INIT + # Code from module binary-io: + # Code from module binary-io-tests: # Code from module bind: # Code from module c++defs: # Code from module c-ctype: @@ -55,6 +58,9 @@ AC_DEFUN([gl_EARLY], # Code from module fseeko: AC_REQUIRE([AC_FUNC_FSEEKO]) # Code from module fseeko-tests: + # Code from module ftello: + AC_REQUIRE([AC_FUNC_FSEEKO]) + # Code from module ftello-tests: # Code from module gendocs: # Code from module getaddrinfo: # Code from module getaddrinfo-tests: @@ -62,6 +68,7 @@ AC_DEFUN([gl_EARLY], # Code from module getdelim-tests: # Code from module getline: # Code from module getline-tests: + # Code from module getpagesize: # Code from module getpass-gnu: # Code from module gettext-h: # Code from module gettime: @@ -84,6 +91,7 @@ AC_DEFUN([gl_EARLY], # Code from module lseek: # Code from module lseek-tests: # Code from module maintainer-makefile: + # Code from module malloc-posix: # Code from module manywarnings: # Code from module memchr: # Code from module memchr-tests: @@ -112,6 +120,7 @@ AC_DEFUN([gl_EARLY], # Code from module snprintf: # Code from module snprintf-tests: # Code from module socket: + # Code from module socketlib: # Code from module sockets: # Code from module sockets-tests: # Code from module socklen: @@ -240,6 +249,9 @@ AC_SUBST([LTALLOCA]) # Code from module fseeko: gl_FUNC_FSEEKO gl_STDIO_MODULE_INDICATOR([fseeko]) + # Code from module ftello: + gl_FUNC_FTELLO + gl_STDIO_MODULE_INDICATOR([ftello]) # Code from module gendocs: # Code from module getaddrinfo: gl_GETADDRINFO @@ -297,6 +309,9 @@ AC_SUBST([LTALLOCA]) # Code from module maintainer-makefile: AC_CONFIG_COMMANDS_PRE([m4_ifdef([AH_HEADER], [AC_SUBST([CONFIG_INCLUDE], m4_defn([AH_HEADER]))])]) + # Code from module malloc-posix: + gl_FUNC_MALLOC_POSIX + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) # Code from module manywarnings: # Code from module memchr: gl_FUNC_MEMCHR @@ -374,6 +389,8 @@ AC_SUBST([LTALLOCA]) SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1 fi gl_SYS_SOCKET_MODULE_INDICATOR([socket]) + # Code from module socketlib: + gl_SOCKETLIB # Code from module sockets: gl_SOCKETS # Code from module socklen: @@ -477,10 +494,17 @@ changequote([, ])dnl gl_module_indicator_condition=$gltests_WITNESS m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) gl_FUNC_UNGETC_WORKS + gl_FUNC_UNGETC_WORKS + gl_FUNC_GETPAGESIZE + gl_UNISTD_MODULE_INDICATOR([getpagesize]) AC_C_BIGENDIAN AC_C_BIGENDIAN gl_FUNC_IOCTL gl_SYS_IOCTL_MODULE_INDICATOR([ioctl]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h]) gt_TYPE_WCHAR_T gt_TYPE_WINT_T @@ -619,6 +643,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/float+.h lib/float.in.h lib/fseeko.c + lib/ftello.c lib/gai_strerror.c lib/getaddrinfo.c lib/getdelim.c @@ -633,6 +658,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/intprops.h lib/listen.c lib/lseek.c + lib/malloc.c lib/memchr.c lib/memchr.valgrind lib/minmax.h @@ -698,9 +724,11 @@ AC_DEFUN([gl_FILE_LIST], [ m4/fclose.m4 m4/float_h.m4 m4/fseeko.m4 + m4/ftello.m4 m4/getaddrinfo.m4 m4/getdelim.m4 m4/getline.m4 + m4/getpagesize.m4 m4/getpass.m4 m4/gettime.m4 m4/gettimeofday.m4 @@ -734,6 +762,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/servent.m4 m4/size_max.m4 m4/snprintf.m4 + m4/socketlib.m4 m4/sockets.m4 m4/socklen.m4 m4/sockpfaf.m4 @@ -770,11 +799,17 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-alignof.c tests/test-alloca-opt.c tests/test-arpa_inet.c + tests/test-binary-io.c + tests/test-binary-io.sh tests/test-c-ctype.c tests/test-errno.c tests/test-fseeko.c tests/test-fseeko.sh tests/test-fseeko2.sh + tests/test-ftello.c + tests/test-ftello.sh + tests/test-ftello2.sh + tests/test-ftello3.c tests/test-getaddrinfo.c tests/test-getdelim.c tests/test-getline.c @@ -808,6 +843,7 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-sys_socket.c tests/test-sys_stat.c tests/test-sys_time.c + tests/test-sys_wait.h tests/test-time.c tests/test-unistd.c tests/test-update-copyright.sh @@ -820,7 +856,9 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-version-etc.sh tests/test-wchar.c tests/zerosize-ptr.h + tests=lib/binary-io.h tests=lib/dummy.c + tests=lib/getpagesize.c tests=lib/ioctl.c tests=lib/sys_ioctl.in.h tests=lib/verify.h diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4 index 1111041129..7104b3089a 100644 --- a/gl/m4/hostent.m4 +++ b/gl/m4/hostent.m4 @@ -1,5 +1,5 @@ -# hostent.m4 serial 1 -dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# hostent.m4 serial 2 +dnl Copyright (C) 2008, 2010 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. @@ -28,12 +28,16 @@ AC_DEFUN([gl_HOSTENT], [gl_cv_w32_gethostbyname=no gl_save_LIBS="$LIBS" LIBS="$LIBS -lws2_32" - AC_TRY_LINK([ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ #ifdef HAVE_WINSOCK2_H #include <winsock2.h> #endif #include <stddef.h> -], [gethostbyname(NULL);], [gl_cv_w32_gethostbyname=yes]) + ]], + [[gethostbyname(NULL);]])], + [gl_cv_w32_gethostbyname=yes]) LIBS="$gl_save_LIBS" ]) if test "$gl_cv_w32_gethostbyname" = "yes"; then diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4 index c7e0672f60..e37eb0567d 100644 --- a/gl/m4/include_next.m4 +++ b/gl/m4/include_next.m4 @@ -1,4 +1,4 @@ -# include_next.m4 serial 14 +# include_next.m4 serial 16 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -24,6 +24,13 @@ dnl does not warn about some things, and on some systems (Solaris and Interix) dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead dnl of plain '__STDC__'. +dnl +dnl PRAGMA_COLUMNS can be used in files that override system header files, so +dnl as to avoid compilation errors on HP NonStop systems when the gnulib file +dnl is included by a system header file that does a "#pragma COLUMNS 80" (which +dnl has the effect of truncating the lines of that file and all files that it +dnl includes to 80 columns) and the gnulib file has lines longer than 80 +dnl columns. AC_DEFUN([gl_INCLUDE_NEXT], [ @@ -68,10 +75,11 @@ EOF EOF gl_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" - AC_COMPILE_IFELSE([#include <conftest.h>], +dnl We intentionally avoid using AC_LANG_SOURCE here. + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], [gl_cv_have_include_next=yes], [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" - AC_COMPILE_IFELSE([#include <conftest.h>], + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], [gl_cv_have_include_next=buggy], [gl_cv_have_include_next=no]) ]) @@ -97,6 +105,24 @@ EOF AC_SUBST([INCLUDE_NEXT]) AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) AC_SUBST([PRAGMA_SYSTEM_HEADER]) + AC_CACHE_CHECK([whether system header files limit the line length], + [gl_cv_pragma_columns], + [dnl HP NonStop systems, which define __TANDEM, have this misfeature. + AC_EGREP_CPP([choke me], + [ +#ifdef __TANDEM +choke me +#endif + ], + [gl_cv_pragma_columns=yes], + [gl_cv_pragma_columns=no]) + ]) + if test $gl_cv_pragma_columns = yes; then + PRAGMA_COLUMNS="#pragma COLUMNS 10000" + else + PRAGMA_COLUMNS= + fi + AC_SUBST([PRAGMA_COLUMNS]) ]) # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) @@ -185,3 +211,7 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS], [$gl_next_as_first_directive]) AS_VAR_POPDEF([gl_next_header])]) ]) + +# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; +# this fallback is safe for all earlier autoconf versions. +m4_define_default([AC_LANG_DEFINES_PROVIDED]) diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4 index 975caac506..493e4a9328 100644 --- a/gl/m4/intmax_t.m4 +++ b/gl/m4/intmax_t.m4 @@ -1,4 +1,4 @@ -# intmax_t.m4 serial 7 +# intmax_t.m4 serial 8 dnl Copyright (C) 1997-2004, 2006-2007, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Paul Eggert. -AC_PREREQ([2.13]) +AC_PREREQ([2.53]) # Define intmax_t to 'long' or 'long long' # if it is not already defined in <stdint.h> or <inttypes.h>. @@ -38,7 +38,9 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gl_AC_HEADER_STDINT_H]) AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ #include <stddef.h> #include <stdlib.h> #if HAVE_STDINT_H_WITH_UINTMAX @@ -47,7 +49,10 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], #if HAVE_INTTYPES_H_WITH_UINTMAX #include <inttypes.h> #endif -], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) + ]], + [[intmax_t x = -1; return !x;]])], + [gt_cv_c_intmax_t=yes], + [gt_cv_c_intmax_t=no])]) if test $gt_cv_c_intmax_t = yes; then AC_DEFINE([HAVE_INTMAX_T], [1], [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4 index 782d77ed8b..9d8f926926 100644 --- a/gl/m4/inttypes_h.m4 +++ b/gl/m4/inttypes_h.m4 @@ -1,4 +1,4 @@ -# inttypes_h.m4 serial 9 +# inttypes_h.m4 serial 10 dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,12 +12,15 @@ dnl From Paul Eggert. AC_DEFUN([gl_AC_HEADER_INTTYPES_H], [ AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], - [AC_TRY_COMPILE( - [#include <sys/types.h> -#include <inttypes.h>], - [uintmax_t i = (uintmax_t) -1; return !i;], - [gl_cv_header_inttypes_h=yes], - [gl_cv_header_inttypes_h=no])]) + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <sys/types.h> +#include <inttypes.h> + ]], + [[uintmax_t i = (uintmax_t) -1; return !i;]])], + [gl_cv_header_inttypes_h=yes], + [gl_cv_header_inttypes_h=no])]) if test $gl_cv_header_inttypes_h = yes; then AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4 index ebb30528bd..294db72e13 100644 --- a/gl/m4/lib-ld.m4 +++ b/gl/m4/lib-ld.m4 @@ -1,4 +1,4 @@ -# lib-ld.m4 serial 4 (gettext-0.18) +# lib-ld.m4 serial 5 (gettext-0.18.2) dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -31,15 +31,14 @@ AC_REQUIRE([AC_CANONICAL_HOST])dnl # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } fi ac_prog=ld if test "$GCC" = yes; then diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4 index c73bd8e3a4..2ea9d6d073 100644 --- a/gl/m4/lib-link.m4 +++ b/gl/m4/lib-link.m4 @@ -1,4 +1,4 @@ -# lib-link.m4 serial 21 (gettext-0.18) +# lib-link.m4 serial 25 (gettext-0.18.2) dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,9 +18,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" @@ -58,9 +58,9 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. @@ -85,7 +85,8 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; *) LIBS="$LIB[]NAME $LIBS" ;; esac - AC_TRY_LINK([$3], [$4], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[$3]], [[$4]])], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) LIBS="$ac_save_LIBS" @@ -157,15 +158,15 @@ dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar dnl macro call that searches for libname. AC_DEFUN([AC_LIB_FROMPACKAGE], [ - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_frompackage_]NAME, [$2]) popdef([NAME]) pushdef([PACK],[$2]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) popdef([PACKUP]) popdef([PACK]) ]) @@ -178,14 +179,14 @@ dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ @@ -242,7 +243,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then diff --git a/gl/m4/lseek.m4 b/gl/m4/lseek.m4 index 9bf4dc2d04..b0612c7e17 100644 --- a/gl/m4/lseek.m4 +++ b/gl/m4/lseek.m4 @@ -1,4 +1,4 @@ -# lseek.m4 serial 5 +# lseek.m4 serial 6 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,15 +10,13 @@ AC_DEFUN([gl_FUNC_LSEEK], 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([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> /* for off_t */ #include <stdio.h> /* for SEEK_CUR */ -#include <unistd.h> -int main () -{ +#include <unistd.h>]], [[ /* 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 \ && test 1 = "`echo hi \ @@ -29,11 +27,11 @@ int main () fi], [gl_cv_func_lseek_pipe=no]) else - AC_COMPILE_IFELSE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __BEOS__ /* mingw and BeOS mistakenly return 0 when trying to seek on pipes. */ Choke me. -#endif], +#endif]])], [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no]) fi]) if test $gl_cv_func_lseek_pipe = no; then diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4 index 910ac92292..7a749254a1 100644 --- a/gl/m4/malloc.m4 +++ b/gl/m4/malloc.m4 @@ -1,25 +1,40 @@ -# malloc.m4 serial 9 +# malloc.m4 serial 12 dnl Copyright (C) 2007, 2009, 2010 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_GNU +# ------------------ +# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if +# it is not. +AC_DEFUN([gl_FUNC_MALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. + _AC_FUNC_MALLOC_IF( + [AC_DEFINE([HAVE_MALLOC_GNU], [1], + [Define to 1 if your system has a GNU libc compatible 'malloc' + function, and to 0 otherwise.])], + [AC_DEFINE([HAVE_MALLOC_GNU], [0]) + gl_REPLACE_MALLOC + ]) +]) + # 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_STDLIB_H_DEFAULTS]) 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 + gl_REPLACE_MALLOC fi - AC_SUBST([HAVE_MALLOC_POSIX]) ]) # Test whether malloc, realloc, calloc are POSIX compliant, @@ -32,10 +47,20 @@ AC_DEFUN([gl_CHECK_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]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[]], + [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + choke me + #endif + ]])], + [gl_cv_func_malloc_posix=yes], + [gl_cv_func_malloc_posix=no]) ]) ]) + +AC_DEFUN([gl_REPLACE_MALLOC], +[ + AC_LIBOBJ([malloc]) + REPLACE_MALLOC=1 +]) diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4 index ab773b8129..b05a79a026 100644 --- a/gl/m4/memchr.m4 +++ b/gl/m4/memchr.m4 @@ -1,4 +1,4 @@ -# memchr.m4 serial 8 +# memchr.m4 serial 9 dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -62,6 +62,8 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], strcpy (fence - 9, "12345678"); if (memchr (fence - 9, 0, 79) != fence - 1) return 2; + if (memchr (fence - 1, 0, 3) != fence - 1) + return 3; } return 0; ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], diff --git a/gl/m4/minmax.m4 b/gl/m4/minmax.m4 index d9e9cecfd7..a5c42dea0f 100644 --- a/gl/m4/minmax.m4 +++ b/gl/m4/minmax.m4 @@ -1,10 +1,10 @@ -# minmax.m4 serial 3 -dnl Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. +# minmax.m4 serial 4 +dnl Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_PREREQ([2.52]) +AC_PREREQ([2.53]) AC_DEFUN([gl_MINMAX], [ @@ -28,8 +28,11 @@ AC_DEFUN([gl_MINMAX_IN_HEADER], m4_pushdef([HEADER], AS_TR_CPP([$1])) AC_CACHE_CHECK([whether <$1> defines MIN and MAX], [gl_cv_minmax_in_]header, - [AC_TRY_COMPILE([#include <$1> -int x = MIN (42, 17);], [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <$1> + int x = MIN (42, 17);]], + [[]])], [gl_cv_minmax_in_]header[=yes], [gl_cv_minmax_in_]header[=no])]) if test $gl_cv_minmax_in_[]header = yes; then diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4 index ebca5364c4..e850862c01 100644 --- a/gl/m4/printf.m4 +++ b/gl/m4/printf.m4 @@ -1,4 +1,4 @@ -# printf.m4 serial 33 +# printf.m4 serial 35 dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,8 @@ AC_DEFUN([gl_PRINTF_SIZES_C99], AC_CACHE_CHECK([whether printf supports size specifiers as in C99], [gl_cv_func_printf_sizes_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stddef.h> #include <stdio.h> #include <string.h> @@ -50,34 +51,36 @@ int main () || strcmp (buf, "1.5 33") != 0) return 1; return 0; -}], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no], - [ +}]])], + [gl_cv_func_printf_sizes_c99=yes], + [gl_cv_func_printf_sizes_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; - darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_printf_sizes_c99="guessing no";; - openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; - solaris*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_sizes_c99="guessing no";; - netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_sizes_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; + darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_printf_sizes_c99="guessing no";; + openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; + solaris*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_sizes_c99="guessing no";; + netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_sizes_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -92,7 +95,8 @@ AC_DEFUN([gl_PRINTF_LONG_DOUBLE], AC_CACHE_CHECK([whether printf supports 'long double' arguments], [gl_cv_func_printf_long_double], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[10000]; @@ -111,16 +115,18 @@ int main () || strcmp (buf, "1.75 33") != 0) return 1; return 0; -}], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no], - [ +}]])], + [gl_cv_func_printf_long_double=yes], + [gl_cv_func_printf_long_double=no], + [ changequote(,)dnl - case "$host_os" in - beos*) gl_cv_func_printf_long_double="guessing no";; - mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; - *) gl_cv_func_printf_long_double="guessing yes";; - esac + case "$host_os" in + beos*) gl_cv_func_printf_long_double="guessing no";; + mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; + *) gl_cv_func_printf_long_double="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -136,7 +142,8 @@ AC_DEFUN([gl_PRINTF_INFINITE], AC_CACHE_CHECK([whether printf supports infinite 'double' arguments], [gl_cv_func_printf_infinite], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static int @@ -201,32 +208,34 @@ int main () || strcmp (buf, "-0") != 0) return 1; return 0; -}], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no], - [ +}]])], + [gl_cv_func_printf_infinite=yes], + [gl_cv_func_printf_infinite=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; - darwin*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; - hpux*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_infinite="guessing no";; - netbsd*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_infinite="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_infinite="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; + darwin*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; + hpux*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite="guessing no";; + netbsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_infinite="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_infinite="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -252,7 +261,8 @@ AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE], AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], [gl_cv_func_printf_infinite_long_double], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ ]GL_NOCRASH[ #include <float.h> #include <stdio.h> @@ -414,38 +424,38 @@ int main () } #endif return 0; -}], - [gl_cv_func_printf_infinite_long_double=yes], - [gl_cv_func_printf_infinite_long_double=no], - [ +}]])], + [gl_cv_func_printf_infinite_long_double=yes], + [gl_cv_func_printf_infinite_long_double=no], + [ changequote(,)dnl - case "$host_cpu" in - # Guess no on ia64, x86_64, i386. - ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; - *) - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; - darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; - hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_infinite_long_double="guessing no";; - netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_infinite_long_double="guessing no";; - esac - ;; - esac + case "$host_cpu" in + # Guess no on ia64, x86_64, i386. + ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; + *) + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; + darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; + hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite_long_double="guessing no";; + netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_infinite_long_double="guessing no";; + esac + ;; + esac changequote([,])dnl - ]) + ]) ]) ;; *) @@ -466,7 +476,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_A], AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], [gl_cv_func_printf_directive_a], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -512,26 +523,28 @@ int main () && strcmp (buf, "0x8.0p-2") != 0)) return 1; return 0; -}], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no], - [ - case "$host_os" in - # Guess yes on glibc >= 2.5 systems. - *-gnu*) - AC_EGREP_CPP([BZ2908], [ - #include <features.h> - #ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2) - BZ2908 - #endif - #endif - ], - [gl_cv_func_printf_directive_a="guessing yes"], - [gl_cv_func_printf_directive_a="guessing no"]) - ;; - # If we don't know, assume the worst. - *) gl_cv_func_printf_directive_a="guessing no";; - esac - ]) +}]])], + [gl_cv_func_printf_directive_a=yes], + [gl_cv_func_printf_directive_a=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.5 systems. + *-gnu*) + AC_EGREP_CPP([BZ2908], [ + #include <features.h> + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2) + BZ2908 + #endif + #endif + ], + [gl_cv_func_printf_directive_a="guessing yes"], + [gl_cv_func_printf_directive_a="guessing no"]) + ;; + # If we don't know, assume the worst. + *) gl_cv_func_printf_directive_a="guessing no";; + esac + ]) ]) ]) @@ -546,7 +559,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_F], AC_CACHE_CHECK([whether printf supports the 'F' directive], [gl_cv_func_printf_directive_f], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -563,26 +577,28 @@ int main () || strcmp (buf, "1234") != 0) return 1; return 0; -}], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no], - [ +}]])], + [gl_cv_func_printf_directive_f=yes], + [gl_cv_func_printf_directive_f=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; - darwin*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";; - solaris*) gl_cv_func_printf_directive_f="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_directive_f="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; + darwin*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";; + solaris*) gl_cv_func_printf_directive_f="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_directive_f="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -597,7 +613,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N], AC_CACHE_CHECK([whether printf supports the 'n' directive], [gl_cv_func_printf_directive_n], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char fmtstring[10]; @@ -614,14 +631,16 @@ int main () || count != 4) return 1; return 0; -}], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], - [ +}]])], + [gl_cv_func_printf_directive_n=yes], + [gl_cv_func_printf_directive_n=no], + [ changequote(,)dnl - case "$host_os" in - *) gl_cv_func_printf_directive_n="guessing yes";; - esac + case "$host_os" in + *) gl_cv_func_printf_directive_n="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -639,7 +658,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS], AC_CACHE_CHECK([whether printf supports the 'ls' directive], [gl_cv_func_printf_directive_ls], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ /* 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 @@ -687,19 +707,21 @@ int main () return 1; } return 0; -}], [gl_cv_func_printf_directive_ls=yes], [gl_cv_func_printf_directive_ls=no], - [ +}]])], + [gl_cv_func_printf_directive_ls=yes], + [gl_cv_func_printf_directive_ls=no], + [ changequote(,)dnl - case "$host_os" in - openbsd*) gl_cv_func_printf_directive_ls="guessing no";; - irix*) gl_cv_func_printf_directive_ls="guessing no";; - solaris*) gl_cv_func_printf_directive_ls="guessing no";; - cygwin*) gl_cv_func_printf_directive_ls="guessing no";; - beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; - *) gl_cv_func_printf_directive_ls="guessing yes";; - esac + case "$host_os" in + openbsd*) gl_cv_func_printf_directive_ls="guessing no";; + irix*) gl_cv_func_printf_directive_ls="guessing no";; + solaris*) gl_cv_func_printf_directive_ls="guessing no";; + cygwin*) gl_cv_func_printf_directive_ls="guessing no";; + beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; + *) gl_cv_func_printf_directive_ls="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -714,7 +736,8 @@ AC_DEFUN([gl_PRINTF_POSITIONS], AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], [gl_cv_func_printf_positions], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> /* The string "%2$d %1$d", with dollar characters protected from the shell's @@ -725,18 +748,20 @@ int main () { sprintf (buf, format, 33, 55); return (strcmp (buf, "55 33") != 0); -}], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no], - [ +}]])], + [gl_cv_func_printf_positions=yes], + [gl_cv_func_printf_positions=no], + [ changequote(,)dnl - case "$host_os" in - netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) - gl_cv_func_printf_positions="guessing no";; - beos*) gl_cv_func_printf_positions="guessing no";; - mingw* | pw*) gl_cv_func_printf_positions="guessing no";; - *) gl_cv_func_printf_positions="guessing yes";; - esac + case "$host_os" in + netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) + gl_cv_func_printf_positions="guessing no";; + beos*) gl_cv_func_printf_positions="guessing no";; + mingw* | pw*) gl_cv_func_printf_positions="guessing no";; + *) gl_cv_func_printf_positions="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -751,7 +776,8 @@ AC_DEFUN([gl_PRINTF_FLAG_GROUPING], AC_CACHE_CHECK([whether printf supports the grouping flag], [gl_cv_func_printf_flag_grouping], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -761,17 +787,19 @@ int main () || buf[strlen (buf) - 1] != '9') return 1; return 0; -}], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no], - [ +}]])], + [gl_cv_func_printf_flag_grouping=yes], + [gl_cv_func_printf_flag_grouping=no], + [ changequote(,)dnl - case "$host_os" in - cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; - netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; - mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; - *) gl_cv_func_printf_flag_grouping="guessing yes";; - esac + case "$host_os" in + cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; + netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; + mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; + *) gl_cv_func_printf_flag_grouping="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -787,7 +815,8 @@ AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], [gl_cv_func_printf_flag_leftadjust], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -798,7 +827,7 @@ int main () || strcmp (buf, "ab c") != 0) return 1; return 0; -}], +}]])], [gl_cv_func_printf_flag_leftadjust=yes], [gl_cv_func_printf_flag_leftadjust=no], [ @@ -828,7 +857,8 @@ AC_DEFUN([gl_PRINTF_FLAG_ZERO], AC_CACHE_CHECK([whether printf supports the zero flag correctly], [gl_cv_func_printf_flag_zero], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -839,19 +869,21 @@ int main () && strcmp (buf, " infinity") != 0)) return 1; return 0; -}], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no], - [ +}]])], + [gl_cv_func_printf_flag_zero=yes], + [gl_cv_func_printf_flag_zero=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_flag_zero="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_flag_zero="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_flag_zero="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_flag_zero="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -868,7 +900,8 @@ AC_DEFUN([gl_PRINTF_PRECISION], AC_CACHE_CHECK([whether printf supports large precisions], [gl_cv_func_printf_precision], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[5000]; @@ -881,17 +914,19 @@ int main () if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) return 1; return 0; -}], [gl_cv_func_printf_precision=yes], [gl_cv_func_printf_precision=no], - [ +}]])], + [gl_cv_func_printf_precision=yes], + [gl_cv_func_printf_precision=no], + [ changequote(,)dnl - case "$host_os" in - # Guess no only on native Win32 and BeOS systems. - mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; - beos*) gl_cv_func_printf_precision="guessing no" ;; - *) gl_cv_func_printf_precision="guessing yes" ;; - esac + case "$host_os" in + # Guess no only on native Win32 and BeOS systems. + mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; + beos*) gl_cv_func_printf_precision="guessing no" ;; + *) gl_cv_func_printf_precision="guessing yes" ;; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1031,7 +1066,8 @@ AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], AC_CACHE_CHECK([whether snprintf truncates the result as in C99], [gl_cv_func_snprintf_truncation_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -1042,47 +1078,49 @@ int main () if (memcmp (buf, "45\0DEF", 6) != 0) return 1; return 0; -}], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no], - [ +}]])], + [gl_cv_func_snprintf_truncation_c99=yes], + [gl_cv_func_snprintf_truncation_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; - darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; - hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on OSF/1 >= 5. - osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_truncation_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; + darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; + hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on OSF/1 >= 5. + osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_snprintf_truncation_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1101,14 +1139,15 @@ dnl } dnl --------------------------------------------------------------------- dnl Result is gl_cv_func_snprintf_retval_c99. -AC_DEFUN([gl_SNPRINTF_RETVAL_C99], +AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], [gl_cv_func_snprintf_retval_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -1118,39 +1157,41 @@ int main () if (snprintf (buf, 3, "%d %d", 4567, 89) != 7) return 1; return 0; -}], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no], - [ +}]])], + [gl_cv_func_snprintf_retval_c99=yes], + [gl_cv_func_snprintf_retval_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; - darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_snprintf_retval_c99="guessing no";; - openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";; - solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; - aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_retval_c99="guessing no";; - netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_retval_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; + darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_snprintf_retval_c99="guessing no";; + openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";; + solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; + aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_retval_c99="guessing no";; + netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_snprintf_retval_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1165,7 +1206,8 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], [gl_cv_func_snprintf_directive_n], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char fmtstring[10]; @@ -1181,40 +1223,42 @@ int main () if (count != 6) return 1; return 0; -}], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no], - [ +}]])], + [gl_cv_func_snprintf_directive_n=yes], + [gl_cv_func_snprintf_directive_n=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; - darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";; - solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; - aix*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on OSF/1 >= 5. - osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; - osf*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_directive_n="guessing no";; - netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_directive_n="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_directive_n="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; + darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";; + solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; + aix*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on OSF/1 >= 5. + osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; + osf*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_directive_n="guessing no";; + netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_directive_n="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_snprintf_directive_n="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1229,17 +1273,18 @@ AC_DEFUN([gl_SNPRINTF_SIZE1], AC_CACHE_CHECK([whether snprintf respects a size of 1], [gl_cv_func_snprintf_size1], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> int main() { static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; snprintf (buf, 1, "%d", 12345); return buf[1] != 'E'; -}], - [gl_cv_func_snprintf_size1=yes], - [gl_cv_func_snprintf_size1=no], - [gl_cv_func_snprintf_size1="guessing yes"]) +}]])], + [gl_cv_func_snprintf_size1=yes], + [gl_cv_func_snprintf_size1=no], + [gl_cv_func_snprintf_size1="guessing yes"]) ]) ]) @@ -1286,7 +1331,8 @@ AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99], AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], [gl_cv_func_vsnprintf_zerosize_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdarg.h> #include <stdio.h> static int my_snprintf (char *buf, int size, const char *format, ...) @@ -1303,43 +1349,43 @@ int main() static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; my_snprintf (buf, 0, "%d", 12345); return buf[0] != 'D'; -}], - [gl_cv_func_vsnprintf_zerosize_c99=yes], - [gl_cv_func_vsnprintf_zerosize_c99=no], - [ +}]])], + [gl_cv_func_vsnprintf_zerosize_c99=yes], + [gl_cv_func_vsnprintf_zerosize_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Cygwin. - cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on mingw. - mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on mingw. + mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1401,7 +1447,7 @@ dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . dnl Solaris 10 . . # # # . . # . . . # . . . . . . . . dnl Solaris 2.6 ... 9 # . # # # # . # . . . # . . . . . . . . dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # -dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . +dnl AIX 5.2, 7.1 . . # # # . . . . . . # . . . . . . . . dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . . . . . dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # diff --git a/gl/m4/realloc.m4 b/gl/m4/realloc.m4 index dc30235c17..01c1234f7e 100644 --- a/gl/m4/realloc.m4 +++ b/gl/m4/realloc.m4 @@ -1,23 +1,44 @@ -# realloc.m4 serial 9 +# realloc.m4 serial 11 dnl Copyright (C) 2007, 2009, 2010 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_GNU +# ------------------- +# Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace +# realloc if it is not. +AC_DEFUN([gl_FUNC_REALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + dnl _AC_FUNC_REALLOC_IF is defined in Autoconf. + _AC_FUNC_REALLOC_IF( + [AC_DEFINE([HAVE_REALLOC_GNU], [1], + [Define to 1 if your system has a GNU libc compatible 'realloc' + function, and to 0 otherwise.])], + [AC_DEFINE([HAVE_REALLOC_GNU], [0]) + gl_REPLACE_REALLOC + ]) +])# gl_FUNC_REALLOC_GNU + # 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_STDLIB_H_DEFAULTS]) 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 + gl_REPLACE_REALLOC fi - AC_SUBST([HAVE_REALLOC_POSIX]) +]) + +AC_DEFUN([gl_REPLACE_REALLOC], +[ + AC_LIBOBJ([realloc]) + REPLACE_REALLOC=1 ]) diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4 index 2ed961a439..2486511aad 100644 --- a/gl/m4/servent.m4 +++ b/gl/m4/servent.m4 @@ -1,5 +1,5 @@ -# servent.m4 serial 1 -dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# servent.m4 serial 2 +dnl Copyright (C) 2008, 2010 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. @@ -30,12 +30,16 @@ AC_DEFUN([gl_SERVENT], [gl_cv_w32_getservbyname=no gl_save_LIBS="$LIBS" LIBS="$LIBS -lws2_32" - AC_TRY_LINK([ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ #ifdef HAVE_WINSOCK2_H #include <winsock2.h> #endif #include <stddef.h> -], [getservbyname(NULL,NULL);], [gl_cv_w32_getservbyname=yes]) + ]], + [[getservbyname(NULL,NULL);]])], + [gl_cv_w32_getservbyname=yes]) LIBS="$gl_save_LIBS" ]) if test "$gl_cv_w32_getservbyname" = "yes"; then diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4 index ce992db1f1..f3b1a9dfb2 100644 --- a/gl/m4/size_max.m4 +++ b/gl/m4/size_max.m4 @@ -1,4 +1,4 @@ -# size_max.m4 serial 9 +# size_max.m4 serial 10 dnl Copyright (C) 2003, 2005-2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,10 +34,14 @@ Found it if test $fits_in_uint = 1; then dnl Even though SIZE_MAX fits in an unsigned int, it must be of type dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. - AC_TRY_COMPILE([#include <stddef.h> - extern size_t foo; - extern unsigned long foo; - ], [], [fits_in_uint=0]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stddef.h> + extern size_t foo; + extern unsigned long foo; + ]], + [[]])], + [fits_in_uint=0]) fi dnl We cannot use 'expr' to simplify this expression, because 'expr' dnl works only with 'long' integers in the host environment, while we diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4 new file mode 100644 index 0000000000..7bf02b5aee --- /dev/null +++ b/gl/m4/socketlib.m4 @@ -0,0 +1,86 @@ +# socketlib.m4 serial 1 +dnl Copyright (C) 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl gl_SOCKETLIB +dnl Determines the library to use for socket functions. +dnl Sets and AC_SUBSTs LIBSOCKET. + +AC_DEFUN([gl_SOCKETLIB], +[ + gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H + LIBSOCKET= + if test $HAVE_WINSOCK2_H = 1; then + dnl Native Windows API (not Cygwin). + AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], + [gl_cv_func_wsastartup], [ + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lws2_32" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_WINSOCK2_H +# include <winsock2.h> +#endif]], [[ + WORD wVersionRequested = MAKEWORD(1, 1); + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + WSACleanup ();]])], + gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) + LIBS="$gl_save_LIBS" + ]) + if test "$gl_cv_func_wsastartup" = "yes"; then + AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) + LIBSOCKET='-lws2_32' + fi + else + dnl Unix API. + dnl Solaris has most socket functions in libsocket. + dnl Haiku has most socket functions in libnetwork. + dnl BeOS has most socket functions in libnet. + AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ + gl_cv_lib_socket= + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [], + [gl_save_LIBS="$LIBS" + LIBS="$gl_save_LIBS -lsocket" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lsocket"]) + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnetwork" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lnetwork"]) + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnet" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lnet"]) + fi + fi + LIBS="$gl_save_LIBS" + ]) + if test -z "$gl_cv_lib_socket"; then + gl_cv_lib_socket="none needed" + fi + ]) + if test "$gl_cv_lib_socket" != "none needed"; then + LIBSOCKET="$gl_cv_lib_socket" + fi + fi + AC_SUBST([LIBSOCKET]) +]) diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4 index aefb936079..ba9a563d8e 100644 --- a/gl/m4/sockets.m4 +++ b/gl/m4/sockets.m4 @@ -1,4 +1,4 @@ -# sockets.m4 serial 6 +# sockets.m4 serial 7 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,80 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_SOCKETS], [ AC_REQUIRE([AC_C_INLINE]) - - gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H - LIBSOCKET= - if test $HAVE_WINSOCK2_H = 1; then - dnl Native Windows API (not Cygwin). - AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], - [gl_cv_func_wsastartup], [ - gl_save_LIBS="$LIBS" - LIBS="$LIBS -lws2_32" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_WINSOCK2_H -# include <winsock2.h> -#endif]], [[ - WORD wVersionRequested = MAKEWORD(1, 1); - WSADATA wsaData; - int err = WSAStartup(wVersionRequested, &wsaData); - WSACleanup ();]])], - gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) - LIBS="$gl_save_LIBS" - ]) - if test "$gl_cv_func_wsastartup" = "yes"; then - AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) - LIBSOCKET='-lws2_32' - fi - else - dnl Unix API. - dnl Solaris has most socket functions in libsocket. - dnl Haiku has most socket functions in libnetwork. - dnl BeOS has most socket functions in libnet. - AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ - gl_cv_lib_socket= - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [], - [gl_save_LIBS="$LIBS" - LIBS="$gl_save_LIBS -lsocket" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [gl_cv_lib_socket="-lsocket"]) - if test -z "$gl_cv_lib_socket"; then - LIBS="$gl_save_LIBS -lnetwork" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [gl_cv_lib_socket="-lnetwork"]) - if test -z "$gl_cv_lib_socket"; then - LIBS="$gl_save_LIBS -lnet" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [gl_cv_lib_socket="-lnet"]) - fi - fi - LIBS="$gl_save_LIBS" - ]) - if test -z "$gl_cv_lib_socket"; then - gl_cv_lib_socket="none needed" - fi - ]) - if test "$gl_cv_lib_socket" != "none needed"; then - LIBSOCKET="$gl_cv_lib_socket" - fi - fi - AC_SUBST([LIBSOCKET]) + AC_REQUIRE([gl_SOCKETLIB]) gl_PREREQ_SOCKETS ]) diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4 index 2933d4b890..d0d6baab55 100644 --- a/gl/m4/socklen.m4 +++ b/gl/m4/socklen.m4 @@ -1,4 +1,4 @@ -# socklen.m4 serial 7 +# socklen.m4 serial 8 dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,8 +8,9 @@ dnl From Albert Chin, Windows fixes from Simon Josefsson. dnl Check for socklen_t: historically on BSD it is an int, and in dnl POSIX 1g it is a type of its own, but some platforms use different -dnl types for the argument to getsockopt, getpeername, etc. So we -dnl have to test to find something that will work. +dnl types for the argument to getsockopt, getpeername, etc.: +dnl HP-UX 10.20, IRIX 6.5, Interix 3.5, BeOS. +dnl So we have to test to find something that will work. dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find dnl it there first. That file is included by gnulib's sys_socket.in.h, which diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4 index 8a0c236038..8806705ae2 100644 --- a/gl/m4/sockpfaf.m4 +++ b/gl/m4/sockpfaf.m4 @@ -47,6 +47,9 @@ AC_DEFUN([gl_SOCKET_FAMILIES], #endif #ifdef HAVE_WINSOCK2_H #include <winsock2.h> +#endif +#ifdef HAVE_WS2TCPIP_H +#include <ws2tcpip.h> #endif]], [[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; if (&x && &y && &z) return 0;]])], diff --git a/gl/m4/stdarg.m4 b/gl/m4/stdarg.m4 index 5c87bd8b5f..8a62f2e844 100644 --- a/gl/m4/stdarg.m4 +++ b/gl/m4/stdarg.m4 @@ -1,4 +1,4 @@ -# stdarg.m4 serial 3 +# stdarg.m4 serial 4 dnl Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -13,12 +13,16 @@ AC_DEFUN([gl_STDARG_H], NEXT_STDARG_H='<stdarg.h>'; AC_SUBST([NEXT_STDARG_H]) AC_MSG_CHECKING([for va_copy]) AC_CACHE_VAL([gl_cv_func_va_copy], [ - AC_TRY_COMPILE([#include <stdarg.h>], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stdarg.h>]], + [[ #ifndef va_copy void (*func) (va_list, va_list) = va_copy; #endif -], - [gl_cv_func_va_copy=yes], [gl_cv_func_va_copy=no])]) + ]])], + [gl_cv_func_va_copy=yes], + [gl_cv_func_va_copy=no])]) AC_MSG_RESULT([$gl_cv_func_va_copy]) if test $gl_cv_func_va_copy = no; then dnl Provide a substitute. @@ -47,12 +51,16 @@ void (*func) (va_list, va_list) = va_copy; dnl Provide a substitute in <config.h>, either __va_copy or as a simple dnl assignment. gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [ - AC_TRY_COMPILE([#include <stdarg.h>], [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stdarg.h>]], + [[ #ifndef __va_copy error, bail out #endif -], - [gl_cv_func___va_copy=yes], [gl_cv_func___va_copy=no])]) + ]])], + [gl_cv_func___va_copy=yes], + [gl_cv_func___va_copy=no])]) if test $gl_cv_func___va_copy = yes; then AC_DEFINE([va_copy], [__va_copy], [Define as a macro for copying va_list variables.]) diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4 index 3d672d7476..1efe59ea1c 100644 --- a/gl/m4/stdbool.m4 +++ b/gl/m4/stdbool.m4 @@ -5,6 +5,8 @@ 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. +#serial 3 + # Prepare for substituting <stdbool.h> if it is not supported. AC_DEFUN([AM_STDBOOL_H], @@ -31,82 +33,68 @@ AC_DEFUN([AM_STDBOOL_H], # AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) -# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf -# have this macro built-in. +# This version of the macro is needed in autoconf <= 2.67. Autoconf has +# it built in since 2.60, but we want the tweaks from the 2.68 version +# to avoid rejecting xlc and clang due to relying on extensions. AC_DEFUN([AC_HEADER_STDBOOL], [AC_CACHE_CHECK([for stdbool.h that conforms to C99], [ac_cv_header_stdbool_h], - [AC_TRY_COMPILE( - [ - #include <stdbool.h> - #ifndef bool - "error: bool is not defined" - #endif - #ifndef false - "error: false is not defined" - #endif - #if false - "error: false is not 0" - #endif - #ifndef true - "error: true is not defined" - #endif - #if true != 1 - "error: true is not 1" - #endif - #ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" - #endif + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include <stdbool.h> + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif - struct s { _Bool s: 1; _Bool t; } s; + struct s { _Bool s: 1; _Bool t; } s; - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; - #if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a run-time - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); - #endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - ], - [ - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - ], + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + ]], + [[ + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + ]])], [ac_cv_header_stdbool_h=yes], [ac_cv_header_stdbool_h=no])]) AC_CHECK_TYPES([_Bool]) diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4 index 1cc57e6e96..c5e813a96d 100644 --- a/gl/m4/stdint.m4 +++ b/gl/m4/stdint.m4 @@ -1,4 +1,4 @@ -# stdint.m4 serial 34 +# stdint.m4 serial 35 dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -309,7 +309,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], dnl config.h.in, dnl - extra AC_SUBST calls, so that the right substitutions are made. m4_foreach_w([gltype], [$1], - [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), [Define to the number of bits in type ']gltype['.])]) for gltype in $1 ; do AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], @@ -334,7 +334,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], eval BITSIZEOF_${GLTYPE}=\$result done m4_foreach_w([gltype], [$1], - [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) + [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) ]) dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) @@ -347,7 +347,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], dnl config.h.in, dnl - extra AC_SUBST calls, so that the right substitutions are made. m4_foreach_w([gltype], [$1], - [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), [Define to 1 if ']gltype[' is a signed integer type.])]) for gltype in $1 ; do AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], @@ -367,7 +367,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], fi done m4_foreach_w([gltype], [$1], - [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) + [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) ]) dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) @@ -380,7 +380,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], dnl config.h.in, dnl - extra AC_SUBST calls, so that the right substitutions are made. m4_foreach_w([gltype], [$1], - [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], + [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], [Define to l, ll, u, ul, ull, etc., as suitable for constants of type ']gltype['.])]) for gltype in $1 ; do @@ -419,7 +419,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) done m4_foreach_w([gltype], [$1], - [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) + [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) ]) dnl gl_STDINT_INCLUDES diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4 index b8e3c6cc71..670c0cc2bf 100644 --- a/gl/m4/stdint_h.m4 +++ b/gl/m4/stdint_h.m4 @@ -1,4 +1,4 @@ -# stdint_h.m4 serial 8 +# stdint_h.m4 serial 9 dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,12 +12,13 @@ dnl From Paul Eggert. AC_DEFUN([gl_AC_HEADER_STDINT_H], [ AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], - [AC_TRY_COMPILE( - [#include <sys/types.h> -#include <stdint.h>], - [uintmax_t i = (uintmax_t) -1; return !i;], - [gl_cv_header_stdint_h=yes], - [gl_cv_header_stdint_h=no])]) + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/types.h> + #include <stdint.h>]], + [[uintmax_t i = (uintmax_t) -1; return !i;]])], + [gl_cv_header_stdint_h=yes], + [gl_cv_header_stdint_h=no])]) if test $gl_cv_header_stdint_h = yes; then AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], [Define if <stdint.h> exists, doesn't clash with <sys/types.h>, diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4 index dd84796d2c..e4697ce213 100644 --- a/gl/m4/stdlib_h.m4 +++ b/gl/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 28 +# stdlib_h.m4 serial 31 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,7 +33,7 @@ AC_DEFUN([gl_STDLIB_H], #if HAVE_RANDOM_H # include <random.h> #endif - ]], [atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp + ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt unsetenv]) @@ -50,6 +50,7 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], AC_DEFUN([gl_STDLIB_H_DEFAULTS], [ + GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT]) GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) @@ -72,16 +73,16 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD]) GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL]) GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL]) + GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX]) GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) dnl Assume proper GNU behavior unless another module says otherwise. + HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) - HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX]) HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) - HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX]) HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) @@ -89,7 +90,6 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) - HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX]) HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) @@ -100,9 +100,12 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) + REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) + REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) + REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4 index b88ba94da1..a45a10a9ee 100644 --- a/gl/m4/time_h.m4 +++ b/gl/m4/time_h.m4 @@ -2,6 +2,8 @@ # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. +# serial 2 + # 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. @@ -24,7 +26,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY], ]) dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared -dnl in time.h or sys/time.h. +dnl in time.h, sys/time.h, or pthread.h. AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], [ @@ -41,6 +43,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], TIME_H_DEFINES_STRUCT_TIMESPEC=0 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then TIME_H_DEFINES_STRUCT_TIMESPEC=1 else @@ -55,10 +58,24 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 + else + AC_CACHE_CHECK([for struct timespec in <pthread.h>], + [gl_cv_sys_struct_timespec_in_pthread_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <pthread.h> + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_pthread_h=yes], + [gl_cv_sys_struct_timespec_in_pthread_h=no])]) + if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 + fi fi fi AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) + AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) ]) AC_DEFUN([gl_TIME_MODULE_INDICATOR], diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4 index ed804e664b..a133e6ad58 100644 --- a/gl/m4/wchar_t.m4 +++ b/gl/m4/wchar_t.m4 @@ -1,4 +1,4 @@ -# wchar_t.m4 serial 3 (gettext-0.18) +# wchar_t.m4 serial 4 (gettext-0.18.2) dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,9 +11,13 @@ dnl Prerequisite: AC_PROG_CC AC_DEFUN([gt_TYPE_WCHAR_T], [ AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_TRY_COMPILE([#include <stddef.h> - wchar_t foo = (wchar_t)'\0';], , - [gt_cv_c_wchar_t=yes], [gt_cv_c_wchar_t=no])]) + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stddef.h> + wchar_t foo = (wchar_t)'\0';]], + [[]])], + [gt_cv_c_wchar_t=yes], + [gt_cv_c_wchar_t=no])]) if test $gt_cv_c_wchar_t = yes; then AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) fi diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4 index a6c7d15cb5..58ef865565 100644 --- a/gl/m4/wint_t.m4 +++ b/gl/m4/wint_t.m4 @@ -1,4 +1,4 @@ -# wint_t.m4 serial 4 (gettext-0.18) +# wint_t.m4 serial 5 (gettext-0.18.2) dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,7 +11,9 @@ 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([ + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ /* 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 @@ -20,8 +22,10 @@ AC_DEFUN([gt_TYPE_WINT_T], #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])]) + 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 diff --git a/gl/malloc.c b/gl/malloc.c new file mode 100644 index 0000000000..4fa38ee41b --- /dev/null +++ b/gl/malloc.c @@ -0,0 +1,60 @@ +/* malloc() function that is glibc compatible. + + Copyright (C) 1997-1998, 2006-2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute 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 Jim Meyering and Bruno Haible */ + +#include <config.h> +/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ +#ifdef malloc +# define NEED_MALLOC_GNU 1 +# undef malloc +/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ +#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU +# define NEED_MALLOC_GNU 1 +#endif + +/* Specification. */ +#include <stdlib.h> + +#include <errno.h> + +/* Call the system's malloc below. */ +#undef malloc + +/* Allocate an N-byte block of memory from the heap. + If N is zero, allocate a 1-byte block. */ + +void * +rpl_malloc (size_t n) +{ + void *result; + +#if NEED_MALLOC_GNU + if (n == 0) + n = 1; +#endif + + result = malloc (n); + +#if !HAVE_MALLOC_POSIX + if (result == NULL) + errno = ENOMEM; +#endif + + return result; +} diff --git a/gl/netdb.in.h b/gl/netdb.in.h index f800cac876..b0c553ef0d 100644 --- a/gl/netdb.in.h +++ b/gl/netdb.in.h @@ -25,6 +25,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if @HAVE_NETDB_H@ diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h index 7f0ff42143..4b0710fb8d 100644 --- a/gl/netinet_in.in.h +++ b/gl/netinet_in.in.h @@ -20,6 +20,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if @HAVE_NETINET_IN_H@ diff --git a/gl/read-file.c b/gl/read-file.c index cc82bab98c..8d70880e7d 100644 --- a/gl/read-file.c +++ b/gl/read-file.c @@ -20,7 +20,16 @@ #include "read-file.h" -/* Get realloc, free. */ +/* Get fstat. */ +#include <sys/stat.h> + +/* Get ftello. */ +#include <stdio.h> + +/* Get SIZE_MAX. */ +#include <stdint.h> + +/* Get malloc, realloc, free. */ #include <stdlib.h> /* Get errno. */ @@ -36,50 +45,99 @@ fread_file (FILE * stream, size_t * length) { char *buf = NULL; size_t alloc = 0; - size_t size = 0; - int save_errno; - - for (;;) - { - size_t count; - size_t requested; - - if (size + BUFSIZ + 1 > alloc) - { - char *new_buf; - - alloc += alloc / 2; - if (alloc < size + BUFSIZ + 1) - alloc = size + BUFSIZ + 1; - new_buf = realloc (buf, alloc); - if (!new_buf) - { - save_errno = errno; + /* For a regular file, allocate a buffer that has exactly the right + size. This avoids the need to do dynamic reallocations later. */ + { + struct stat st; + + if (fstat (fileno (stream), &st) >= 0 && S_ISREG (st.st_mode)) + { + off_t pos = ftello (stream); + + if (pos >= 0 && pos < st.st_size) + { + off_t alloc_off = st.st_size - pos; + + if (SIZE_MAX <= alloc_off) + { + errno = ENOMEM; + return NULL; + } + + alloc = alloc_off + 1; + + buf = malloc (alloc); + if (!buf) + /* errno is ENOMEM. */ + return NULL; + } + } + } + + { + size_t size = 0; /* number of bytes read so far */ + int save_errno; + + for (;;) + { + size_t count; + size_t requested; + + if (size + BUFSIZ + 1 > alloc) + { + char *new_buf; + size_t new_alloc = alloc + alloc / 2; + + /* Check against overflow. */ + if (new_alloc < alloc) + { + save_errno = ENOMEM; + break; + } + + alloc = new_alloc; + if (alloc < size + BUFSIZ + 1) + alloc = size + BUFSIZ + 1; + + new_buf = realloc (buf, alloc); + if (!new_buf) + { + save_errno = errno; + break; + } + + buf = new_buf; + } + + requested = alloc - size - 1; + count = fread (buf + size, 1, requested, stream); + size += count; + + if (count != requested) + { + save_errno = errno; + if (ferror (stream)) break; - } - buf = new_buf; - } - - requested = alloc - size - 1; - count = fread (buf + size, 1, requested, stream); - size += count; - - if (count != requested) - { - save_errno = errno; - if (ferror (stream)) - break; - buf[size] = '\0'; - *length = size; - return buf; - } - } - - free (buf); - errno = save_errno; - return NULL; + /* Shrink the allocated memory if possible. */ + if (size + 1 < alloc) + { + char *smaller_buf = realloc (buf, size + 1); + if (smaller_buf != NULL) + buf = smaller_buf; + } + + buf[size] = '\0'; + *length = size; + return buf; + } + } + + free (buf); + errno = save_errno; + return NULL; + } } static char * diff --git a/gl/realloc.c b/gl/realloc.c index 36aeecc41b..053208f375 100644 --- a/gl/realloc.c +++ b/gl/realloc.c @@ -23,11 +23,14 @@ /* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ #ifdef realloc # define NEED_REALLOC_GNU 1 +/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ +#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU +# 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 + The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ +#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU # define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 #endif diff --git a/gl/select.c b/gl/select.c index 0c0e3eefc9..2e99f96001 100644 --- a/gl/select.c +++ b/gl/select.c @@ -132,6 +132,8 @@ win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits, if (avail) read = TRUE; } + else if (GetLastError () == ERROR_BROKEN_PIPE) + ; else { @@ -246,7 +248,7 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, wait_timeout = INFINITE; else { - wait_timeout = timeout->tv_sec + timeout->tv_usec / 1000; + wait_timeout = timeout->tv_sec * 1000 + timeout->tv_usec / 1000; /* select is also used as a portable usleep. */ if (!rfds && !wfds && !xfds) diff --git a/gl/stdarg.in.h b/gl/stdarg.in.h index 3e0c49d1cb..8b88449e2f 100644 --- a/gl/stdarg.in.h +++ b/gl/stdarg.in.h @@ -20,6 +20,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STDARG_H@ diff --git a/gl/stddef.in.h b/gl/stddef.in.h index 08778a2336..6642d49e2a 100644 --- a/gl/stddef.in.h +++ b/gl/stddef.in.h @@ -26,6 +26,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_wchar_t || defined __need_size_t \ || defined __need_ptrdiff_t || defined __need_NULL \ diff --git a/gl/stdint.in.h b/gl/stdint.in.h index 5da5f17886..9e81110ae3 100644 --- a/gl/stdint.in.h +++ b/gl/stdint.in.h @@ -26,6 +26,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* When including a system file that in turn includes <inttypes.h>, use the system <inttypes.h>, not our substitute. This avoids @@ -475,8 +476,9 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - /* wchar_t limits */ /* Get WCHAR_MIN, WCHAR_MAX. - This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested - includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes + This include is not on the top, above, because on OSF/1 4.0 we have a + sequence of nested includes + <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes <stdint.h> and assumes its types are already defined. */ #if ! (defined WCHAR_MIN && defined WCHAR_MAX) # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H diff --git a/gl/stdio.in.h b/gl/stdio.in.h index c43848eeef..fedcdfcc25 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h @@ -19,6 +19,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_FILE || defined __need___FILE /* Special invocation convention inside glibc header files. */ @@ -265,7 +266,8 @@ _GL_CXXALIASWARN (freopen); #elif defined GNULIB_POSIXCHECK # undef freopen /* Assume freopen is always declared. */ -_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - " +_GL_WARN_ON_USE (freopen, + "freopen on Win32 platforms is not POSIX compatible - " "use gnulib module freopen for portability"); #endif @@ -661,7 +663,7 @@ _GL_FUNCDECL_RPL (printf, int, (const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (printf, printf, int, (const char *format, ...)); +_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); # endif # define GNULIB_overrides_printf 1 # else diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h index d74c2518ba..6fe75d330f 100644 --- a/gl/stdlib.in.h +++ b/gl/stdlib.in.h @@ -18,6 +18,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_malloc_and_calloc /* Special invocation convention inside glibc header files. */ @@ -38,6 +39,11 @@ /* NetBSD 5.0 mis-defines NULL. */ #include <stddef.h> +/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */ +#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS +# include <sys/wait.h> +#endif + /* Solaris declares getloadavg() in <sys/loadavg.h>. */ #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ # include <sys/loadavg.h> @@ -74,6 +80,12 @@ struct random_data # include <unistd.h> #endif +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(Spec) /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ @@ -95,6 +107,23 @@ struct random_data #endif +#if @GNULIB__EXIT@ +/* Terminate the current process with the given return code, without running + the 'atexit' handlers. */ +# if !@HAVE__EXIT@ +_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); +# endif +_GL_CXXALIAS_SYS (_Exit, void, (int status)); +_GL_CXXALIASWARN (_Exit); +#elif defined GNULIB_POSIXCHECK +# undef _Exit +# if HAVE_RAW_DECL__EXIT +_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " + "use gnulib module _Exit for portability"); +# endif +#endif + + #if @GNULIB_ATOLL@ /* Parse a signed decimal integer. Returns the value of the integer. Errors are not detected. */ @@ -112,7 +141,7 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - " #endif #if @GNULIB_CALLOC_POSIX@ -# if !@HAVE_CALLOC_POSIX@ +# if @REPLACE_CALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef calloc # define calloc rpl_calloc @@ -149,7 +178,8 @@ _GL_CXXALIASWARN (canonicalize_file_name); #elif defined GNULIB_POSIXCHECK # undef canonicalize_file_name # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME -_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " +_GL_WARN_ON_USE (canonicalize_file_name, + "canonicalize_file_name is unportable - " "use gnulib module canonicalize-lgpl for portability"); # endif #endif @@ -218,7 +248,7 @@ _GL_WARN_ON_USE (ptsname, "grantpt is not portable - " #endif #if @GNULIB_MALLOC_POSIX@ -# if !@HAVE_MALLOC_POSIX@ +# if @REPLACE_MALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef malloc # define malloc rpl_malloc @@ -477,7 +507,7 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " #if @GNULIB_REALLOC_POSIX@ -# if !@HAVE_REALLOC_POSIX@ +# if @REPLACE_REALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef realloc # define realloc rpl_realloc @@ -652,7 +682,7 @@ _GL_CXXALIASWARN (unlockpt); #elif defined GNULIB_POSIXCHECK # undef unlockpt # if HAVE_RAW_DECL_UNLOCKPT -_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - " +_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " "use gnulib module unlockpt for portability"); # endif #endif diff --git a/gl/strerror.c b/gl/strerror.c index b0df778489..6e1c0b0ebb 100644 --- a/gl/strerror.c +++ b/gl/strerror.c @@ -32,6 +32,9 @@ # include "intprops.h" +/* Use the system functions, not the gnulib overrides in this file. */ +# undef sprintf + # undef strerror # if ! HAVE_DECL_STRERROR # define strerror(n) NULL @@ -319,6 +322,12 @@ rpl_strerror (int n) break; # endif +# if GNULIB_defined_EDQUOT + case EDQUOT: + msg = "Disk quota exceeded"; + break; +# endif + # if GNULIB_defined_ECANCELED case ECANCELED: msg = "Operation canceled"; diff --git a/gl/string.in.h b/gl/string.in.h index 13c0f09520..3d3af3349a 100644 --- a/gl/string.in.h +++ b/gl/string.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STRING_H@ @@ -41,12 +42,20 @@ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) # define __attribute__(Spec) /* empty */ # endif +#endif /* The attribute __pure__ was added in gcc 2.96. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) -# define __pure__ /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ #endif +/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) \ + && ! defined __GLIBC__ +# include <unistd.h> +#endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ @@ -62,13 +71,13 @@ # define memchr rpl_memchr # endif _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else # if ! @HAVE_MEMCHR@ _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -102,7 +111,8 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " _GL_FUNCDECL_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len)); @@ -111,7 +121,8 @@ _GL_CXXALIAS_RPL (memmem, void *, _GL_FUNCDECL_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); # endif _GL_CXXALIAS_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, @@ -152,7 +163,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -182,7 +193,7 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -229,6 +240,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " #if @GNULIB_STPNCPY@ # if @REPLACE_STPNCPY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpncpy # define stpncpy rpl_stpncpy # endif _GL_FUNCDECL_RPL (stpncpy, char *, @@ -272,7 +284,7 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " #if @GNULIB_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -306,6 +318,10 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); # else +# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup + /* strdup exists as a function and as a macro. Get rid of the macro. */ +# undef strdup +# endif # if !(@HAVE_DECL_STRDUP@ || defined strdup) _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); # endif @@ -378,13 +394,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " # define strnlen rpl_strnlen # endif _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); # else # if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); @@ -414,7 +430,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: @@ -514,7 +530,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - " # define strstr rpl_strstr # endif _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); # else @@ -556,14 +572,16 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " # endif _GL_FUNCDECL_RPL (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strcasestr, char *, (const char *haystack, const char *needle)); # else # if ! @HAVE_STRCASESTR@ _GL_FUNCDECL_SYS (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * strcasestr (const char *, const char *); } @@ -764,11 +782,10 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) #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! + ignoring case. If the two match, return a pointer to the first byte + after this prefix in STRING. Otherwise, return NULL. + Note: This function may, in multibyte locales, return non-NULL if STRING + is of smaller length than PREFIX! Unlike strncasecmp(), this function works correctly in multibyte locales. */ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) diff --git a/gl/sys_select.in.h b/gl/sys_select.in.h index 0f1bd370b2..4ce48e2f8d 100644 --- a/gl/sys_select.in.h +++ b/gl/sys_select.in.h @@ -18,6 +18,7 @@ # if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ # endif +@PRAGMA_COLUMNS@ /* On OSF/1, <sys/types.h> and <sys/time.h> include <sys/select.h>. Simply delegate to the system's header in this case. */ diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h index fc105e63da..8fded705cf 100644 --- a/gl/sys_socket.in.h +++ b/gl/sys_socket.in.h @@ -26,6 +26,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H /* Special invocation convention: @@ -122,8 +123,8 @@ struct sockaddr_storage adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your code may not run on older Windows releases then. My Windows 2000 box was not able to run the code, for example. The situation is - slightly confusing because: - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp + slightly confusing because + <http://msdn.microsoft.com/en-us/library/ms738520> suggests that getaddrinfo should be available on all Windows releases. */ diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h index dc7ef51171..f0c61c15c5 100644 --- a/gl/sys_stat.in.h +++ b/gl/sys_stat.in.h @@ -24,6 +24,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_system_sys_stat_h /* Special invocation convention. */ @@ -594,7 +595,8 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - " # else /* !_LARGE_FILES */ # define stat(name, st) rpl_stat (name, st) # endif /* !_LARGE_FILES */ -_GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2)); +_GL_EXTERN_C int stat (const char *name, struct stat *buf) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef stat diff --git a/gl/sys_time.in.h b/gl/sys_time.in.h index c4c2eb5e87..0689bcb2e6 100644 --- a/gl/sys_time.in.h +++ b/gl/sys_time.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined _GL_SYS_TIME_H @@ -88,7 +89,7 @@ _GL_CXXALIASWARN (gettimeofday); # undef gettimeofday # if HAVE_RAW_DECL_GETTIMEOFDAY _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " - "use gnulib module gettimeofday for portability"); + "use gnulib module gettimeofday for portability"); # endif # endif diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index db45629f20..9aaf714ca7 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -96,6 +96,21 @@ EXTRA_DIST += test-arpa_inet.c ## end gnulib module arpa_inet-tests +## begin gnulib module binary-io + +libtests_a_SOURCES += binary-io.h + +## end gnulib module binary-io + +## begin gnulib module binary-io-tests + +TESTS += test-binary-io.sh +check_PROGRAMS += test-binary-io + +EXTRA_DIST += test-binary-io.sh test-binary-io.c macros.h + +## end gnulib module binary-io-tests + ## begin gnulib module c++defs # The BUILT_SOURCES created by this Makefile snippet are not used via #include @@ -146,6 +161,15 @@ EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh signature.h macros.h ## end gnulib module fseeko-tests +## begin gnulib module ftello-tests + +TESTS += test-ftello.sh test-ftello2.sh test-ftello3 +check_PROGRAMS += test-ftello test-ftello3 +MOSTLYCLEANFILES += t-ftello3.tmp +EXTRA_DIST += test-ftello.c test-ftello.sh test-ftello2.sh test-ftello3.c signature.h macros.h + +## end gnulib module ftello-tests + ## begin gnulib module getaddrinfo-tests TESTS += test-getaddrinfo @@ -173,6 +197,15 @@ EXTRA_DIST += test-getline.c signature.h macros.h ## end gnulib module getline-tests +## begin gnulib module getpagesize + + +EXTRA_DIST += getpagesize.c + +EXTRA_libtests_a_SOURCES += getpagesize.c + +## end gnulib module getpagesize + ## begin gnulib module gettimeofday-tests TESTS += test-gettimeofday @@ -323,7 +356,7 @@ EXTRA_DIST += test-stdio.c TESTS += test-stdlib check_PROGRAMS += test-stdlib -EXTRA_DIST += test-stdlib.c +EXTRA_DIST += test-stdlib.c test-sys_wait.h ## end gnulib module stdlib-tests @@ -356,6 +389,7 @@ sys/ioctl.h: sys_ioctl.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \ -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \ -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \ @@ -432,7 +466,7 @@ EXTRA_DIST += test-unistd.c ## begin gnulib module update-copyright-tests TESTS += test-update-copyright.sh -TESTS_ENVIRONMENT += PATH='$(abs_aux_dir)'$(PATH_SEPARATOR)"$$PATH" +TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)' EXTRA_DIST += test-update-copyright.sh ## end gnulib module update-copyright-tests @@ -450,7 +484,7 @@ EXTRA_DIST += test-vasnprintf.c macros.h TESTS += test-vc-list-files-git.sh TESTS += test-vc-list-files-cvs.sh -TESTS_ENVIRONMENT += PATH='$(abs_aux_dir)'$(PATH_SEPARATOR)"$$PATH" +TESTS_ENVIRONMENT += abs_aux_dir='$(abs_aux_dir)' EXTRA_DIST += test-vc-list-files-git.sh test-vc-list-files-cvs.sh init.sh ## end gnulib module vc-list-files-tests diff --git a/gl/tests/binary-io.h b/gl/tests/binary-io.h new file mode 100644 index 0000000000..5451fd48f4 --- /dev/null +++ b/gl/tests/binary-io.h @@ -0,0 +1,66 @@ +/* Binary mode I/O. + Copyright (C) 2001, 2003, 2005, 2008, 2009, 2010 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 _BINARY_H +#define _BINARY_H + +/* For systems that distinguish between text and binary I/O. + O_BINARY is usually declared in <fcntl.h>. */ +#include <fcntl.h> + +/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...', + so we include it here first. */ +#include <stdio.h> + +#if !defined O_BINARY && defined _O_BINARY + /* For MSC-compatible compilers. */ +# define O_BINARY _O_BINARY +# define O_TEXT _O_TEXT +#endif +#if defined __BEOS__ || defined __HAIKU__ + /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ +# undef O_BINARY +# undef O_TEXT +#endif + +/* SET_BINARY (fd); + changes the file descriptor fd to perform binary I/O. */ +#if O_BINARY +# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ +# include <io.h> /* declares setmode() */ +# else +# define setmode _setmode +# undef fileno +# define fileno _fileno +# endif +# ifdef __DJGPP__ +# include <unistd.h> /* declares isatty() */ + /* Avoid putting stdin/stdout in binary mode if it is connected to + the console, because that would make it impossible for the user + to interrupt the program through Ctrl-C or Ctrl-Break. */ +# define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0)) +# else +# define SET_BINARY(fd) ((void) setmode (fd, O_BINARY)) +# endif +#else + /* On reasonable systems, binary I/O is the default. */ +# undef O_BINARY +# define O_BINARY 0 +# define SET_BINARY(fd) /* do nothing */ ((void) 0) +#endif + +#endif /* _BINARY_H */ diff --git a/gl/tests/getpagesize.c b/gl/tests/getpagesize.c new file mode 100644 index 0000000000..cc2526870f --- /dev/null +++ b/gl/tests/getpagesize.c @@ -0,0 +1,39 @@ +/* getpagesize emulation for systems where it cannot be done in a C macro. + + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Bruno Haible and Martin Lambers. */ + +#include <config.h> + +/* Specification. */ +#include <unistd.h> + +/* This implementation is only for native Win32 systems. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN +# include <windows.h> + +int +getpagesize (void) +{ + SYSTEM_INFO system_info; + GetSystemInfo (&system_info); + return system_info.dwPageSize; +} + +#endif diff --git a/gl/tests/init.sh b/gl/tests/init.sh index ef0957c1d8..a57de77a2f 100644 --- a/gl/tests/init.sh +++ b/gl/tests/init.sh @@ -57,6 +57,41 @@ # 4. Finally # $ exit +ME_=`expr "./$0" : '.*/\(.*\)$'` + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the handler. +# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function. +Exit () { set +e; (exit $1); exit $1; } + +# Print warnings (e.g., about skipped and failed tests) to this file number. +# Override by defining to say, 9, in init.cfg, and putting say, +# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition +# of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# This is useful when using automake's parallel tests mode, to print +# the reason for skip/failure to console, rather than to the .log files. +: ${stderr_fileno_=2} + +warn_() { echo "$@" 1>&$stderr_fileno_; } +fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } +skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } +framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 99; } + +# Sanitize this shell to POSIX mode, if possible. +DUALCASE=1; export DUALCASE +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; + esac +fi + # We require $(...) support unconditionally. # We require a few additional shell features only when $EXEEXT is nonempty, # in order to support automatic $EXEEXT emulation: @@ -68,44 +103,90 @@ # shells until we find one that passes. If one is found, re-exec it. # If no acceptable shell is found, skip the current test. # +# The "...set -x; P=1 true 2>err..." test is to disqualify any shell that +# emits "P=1" into err, as /bin/sh from SunOS 5.11 and OpenBSD 4.7 do. +# # Use "9" to indicate success (rather than 0), in case some shell acts # like Solaris 10's /bin/sh but exits successfully instead of with status 2. +# Eval this code in a subshell to determine a shell's suitability. +# 10 - passes all tests; ok to use +# 9 - ok, but enabling "set -x" corrupts application stderr; prefer higher score +# ? - not ok gl_shell_test_script_=' test $(echo y) = y || exit 1 -test -z "$EXEEXT" && exit 9 +score_=10 +if test "$VERBOSE" = yes; then + test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9 +fi +test -z "$EXEEXT" && exit $score_ shopt -s expand_aliases alias a-b="echo zoo" v=abx test ${v%x} = ab \ && test ${v#a} = bx \ && test $(a-b) = zoo \ - && exit 9 + && exit $score_ ' if test "x$1" = "x--no-reexec"; then shift else - # 'eval'ing the above code makes Solaris 10's /bin/sh exit with $? set to 2. - # It does not evaluate any of the code after the "unexpected" `('. Thus, - # we must run it in a subshell. - ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 - if test $? = 9; then - : # The current shell is adequate. No re-exec required. - else - # Search for a shell that meets our requirements. - for re_shell_ in "${CONFIG_SHELL:-no_shell}" /bin/sh bash dash zsh pdksh fail - do - test "$re_shell_" = no_shell && continue - test "$re_shell_" = fail && skip_ failed to find an adequate shell + # Assume a working shell. Export to subshells (setup_ needs this). + gl_set_x_corrupts_stderr_=false + export gl_set_x_corrupts_stderr_ + + # Record the first marginally acceptable shell. + marginal_= + + # Search for a shell that meets our requirements. + for re_shell_ in __current__ "${CONFIG_SHELL:-no_shell}" \ + /bin/sh bash dash zsh pdksh fail + do + test "$re_shell_" = no_shell && continue + + # If we've made it all the way to the sentinel, "fail" without + # finding even a marginal shell, skip this test. + if test "$re_shell_" = fail; then + test -z "$marginal_" && skip_ failed to find an adequate shell + re_shell_=$marginal_ + break + fi + + # When testing the current shell, simply "eval" the test code. + # Otherwise, run it via $re_shell_ -c ... + if test "$re_shell_" = __current__; then + # 'eval'ing this code makes Solaris 10's /bin/sh exit with + # $? set to 2. It does not evaluate any of the code after the + # "unexpected" first `('. Thus, we must run it in a subshell. + ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 + else "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null - if test $? = 9; then - # Found an acceptable shell. - exec "$re_shell_" "$0" --no-reexec "$@" - echo "$ME_: exec failed" 1>&2 - exit 127 - fi - done + fi + + st_=$? + + # $re_shell_ works just fine. Use it. + test $st_ = 10 && break + + # If this is our first marginally acceptable shell, remember it. + if test "$st_:$marginal_" = 9: ; then + marginal_="$re_shell_" + gl_set_x_corrupts_stderr_=true + fi + done + + if test "$re_shell_" != __current__; then + # Found a usable shell. Preserve -v and -x. + case $- in + *v*x* | *x*v*) opts_=-vx ;; + *v*) opts_=-v ;; + *x*) opts_=-x ;; + *) opts_= ;; + esac + exec "$re_shell_" $opts_ "$0" --no-reexec "$@" + echo "$ME_: exec failed" 1>&2 + exit 127 fi fi @@ -118,26 +199,6 @@ test -n "$EXEEXT" && shopt -s expand_aliases : ${MALLOC_PERTURB_=87} export MALLOC_PERTURB_ -# We use a trap below for cleanup. This requires us to go through -# hoops to get the right exit status transported through the handler. -# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. -# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 -# sh inside this function. -Exit () { set +e; (exit $1); exit $1; } - -# Print warnings (e.g., about skipped and failed tests) to this file number. -# Override by defining to say, 9, in init.cfg, and putting say, -# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition -# of TESTS_ENVIRONMENT in your tests/Makefile.am file. -# This is useful when using automake's parallel tests mode, to print -# the reason for skip/failure to console, rather than to the .log files. -: ${stderr_fileno_=2} - -warn_() { echo "$@" 1>&$stderr_fileno_; } -fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } -skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } -framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 1; } - # This is a stub function that is run upon trap (upon regular exit and # interrupt). Override it with a per-test function, e.g., to unmount # a partition, or to undo any other global state changes. @@ -179,6 +240,11 @@ find_exe_basenames_() feb_result_= feb_sp_= for feb_file_ in $feb_dir_/*.exe; do + # If there was no *.exe file, or there existed a file named "*.exe" that + # was deleted between the above glob expansion and the existence test + # below, just skip it. + test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \ + && continue case $feb_file_ in *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;; *) # Remove leading file name components as well as the .exe suffix. @@ -196,7 +262,7 @@ find_exe_basenames_() # For each file name of the form PROG.exe, create an alias named # PROG that simply invokes PROG.exe, then return 0. If any selected # file name or the directory name, $1, contains an unexpected character, -# define no function and return 1. +# define no alias and return 1. create_exe_shims_() { case $EXEEXT in @@ -244,19 +310,29 @@ path_prepend_() setup_() { - test "$VERBOSE" = yes && set -x + if test "$VERBOSE" = yes; then + # Test whether set -x may cause the selected shell to corrupt an + # application's stderr. Many do, including zsh-4.3.10 and the /bin/sh + # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5. + # If enabling verbose output this way would cause trouble, simply + # issue a warning and refrain. + if $gl_set_x_corrupts_stderr_; then + warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr" + else + set -x + fi + fi initial_cwd_=$PWD - ME_=`expr "./$0" : '.*/\(.*\)$'` pfx_=`testdir_prefix_` test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \ || fail_ "failed to create temporary directory in $initial_cwd_" cd "$test_dir_" - # These trap statements ensure that the temporary directory, $test_dir_, - # is removed upon exit as well as upon receipt of any of the listed signals. - trap remove_tmp_ 0 + # This trap statement, along with a trap on 0 below, ensure that the + # temporary directory, $test_dir_, is removed upon exit as well as + # upon receipt of any of the listed signals. for sig_ in 1 2 3 13 15; do eval "trap 'Exit $(expr $sig_ + 128)' $sig_" done @@ -384,3 +460,6 @@ test -f "$srcdir/init.cfg" \ && . "$srcdir/init.cfg" setup_ "$@" +# This trap is here, rather than in the setup_ function, because some +# shells run the exit trap at shell function exit, rather than script exit. +trap remove_tmp_ 0 diff --git a/gl/tests/sys_ioctl.in.h b/gl/tests/sys_ioctl.in.h index 7ff04391be..871b676981 100644 --- a/gl/tests/sys_ioctl.in.h +++ b/gl/tests/sys_ioctl.in.h @@ -20,6 +20,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #if @HAVE_SYS_IOCTL_H@ diff --git a/gl/tests/test-binary-io.c b/gl/tests/test-binary-io.c new file mode 100644 index 0000000000..125150b21f --- /dev/null +++ b/gl/tests/test-binary-io.c @@ -0,0 +1,64 @@ +/* Test of binary mode I/O. + Copyright (C) 2005, 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#include "binary-io.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +int +main () +{ + /* Test the O_BINARY macro. */ + { + int fd = + open ("t-bin-out2.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); + if (write (fd, "Hello\n", 6) < 0) + exit (1); + close (fd); + } + { + struct stat statbuf; + if (stat ("t-bin-out2.tmp", &statbuf) < 0) + exit (1); + ASSERT (statbuf.st_size == 6); + } + unlink ("t-bin-out2.tmp"); + + /* Test the SET_BINARY macro. */ + SET_BINARY (1); + fputs ("Hello\n", stdout); + fclose (stdout); + fclose (stderr); + { + struct stat statbuf; + if (stat ("t-bin-out1.tmp", &statbuf) < 0) + exit (1); + ASSERT (statbuf.st_size == 6); + } + + return 0; +} diff --git a/gl/tests/test-binary-io.sh b/gl/tests/test-binary-io.sh new file mode 100755 index 0000000000..33e128c309 --- /dev/null +++ b/gl/tests/test-binary-io.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp" +./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/gl/tests/test-ftello.c b/gl/tests/test-ftello.c new file mode 100644 index 0000000000..5fae570f28 --- /dev/null +++ b/gl/tests/test-ftello.c @@ -0,0 +1,118 @@ +/* Test of ftello() function. + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (ftello, off_t, (FILE *)); + +#include "binary-io.h" +#include "macros.h" + +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif + +int +main (int argc, char **argv _GL_UNUSED) +{ + int ch; + /* Assume stdin is seekable iff argc > 1. */ + if (argc == 1) + { + ASSERT (ftell (stdin) == -1); + ASSERT (ftello (stdin) == -1); + return 0; + } + + /* mingw ftell is unreliable on text mode input. */ + SET_BINARY (0); + + /* Simple tests. For each test, make sure ftell and ftello agree. */ + ASSERT (ftell (stdin) == 0); + ASSERT (ftello (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + ASSERT (ftello (stdin) == 1); + + /* Test ftell after ungetc of read input. */ + ch = ungetc ('#', stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 0); + ASSERT (ftello (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + ASSERT (ftello (stdin) == 1); + + /* Test ftell after fseek. */ + ASSERT (fseek (stdin, 2, SEEK_SET) == 0); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + + /* Test ftell after random ungetc. */ + ch = fgetc (stdin); + ASSERT (ch == '/'); + ch = ungetc ('@', stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + + ch = fgetc (stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 3); + ASSERT (ftello (stdin) == 3); + + if (2 < argc) + { + if (FUNC_UNGETC_BROKEN) + { + fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n", + stderr); + return 77; + } + /* Test ftell after ungetc without read. */ + ASSERT (fseek (stdin, 0, SEEK_CUR) == 0); + ASSERT (ftell (stdin) == 3); + ASSERT (ftello (stdin) == 3); + + ch = ungetc ('~', stdin); + ASSERT (ch == '~'); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + } + +#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */ + /* Test ftell beyond end of file. */ + ASSERT (fseek (stdin, 0, SEEK_END) == 0); + ch = ftello (stdin); + ASSERT (fseek (stdin, 10, SEEK_END) == 0); + ASSERT (ftell (stdin) == ch + 10); + ASSERT (ftello (stdin) == ch + 10); +#endif + + return 0; +} diff --git a/gl/tests/test-ftello.sh b/gl/tests/test-ftello.sh new file mode 100755 index 0000000000..33d2e838db --- /dev/null +++ b/gl/tests/test-ftello.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test-ftello${EXEEXT} 1 < "$srcdir/test-ftello.sh" || exit 1 +echo hi | ./test-ftello${EXEEXT} || exit 1 +exit 0 diff --git a/gl/tests/test-ftello2.sh b/gl/tests/test-ftello2.sh new file mode 100755 index 0000000000..ba750b003d --- /dev/null +++ b/gl/tests/test-ftello2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ./test-ftello${EXEEXT} 1 2 < "$srcdir/test-ftello2.sh" diff --git a/gl/tests/test-ftello3.c b/gl/tests/test-ftello3.c new file mode 100644 index 0000000000..b07ba64610 --- /dev/null +++ b/gl/tests/test-ftello3.c @@ -0,0 +1,78 @@ +/* Test of ftello() function. + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include <string.h> + +#include "macros.h" + +#define TESTFILE "t-ftello3.tmp" + +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + goto skip; + if (fwrite ("foogarsh", 1, 8, fp) < 8) + goto skip; + if (fclose (fp)) + goto skip; + + /* The file's contents is now "foogarsh". */ + + /* Try writing after reading to EOF. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + goto skip; + if (fseek (fp, -1, SEEK_END)) + goto skip; + ASSERT (getc (fp) == 'h'); + ASSERT (getc (fp) == EOF); + ASSERT (ftello (fp) == 8); + ASSERT (ftello (fp) == 8); + ASSERT (putc ('!', fp) == '!'); + ASSERT (ftello (fp) == 9); + ASSERT (fclose (fp) == 0); + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + goto skip; + { + char buf[10]; + ASSERT (fread (buf, 1, 10, fp) == 9); + ASSERT (memcmp (buf, "foogarsh!", 9) == 0); + } + ASSERT (fclose (fp) == 0); + + /* The file's contents is now "foogarsh!". */ + + remove (TESTFILE); + return 0; + + skip: + fprintf (stderr, "Skipping test: prerequisite file operations failed.\n"); + remove (TESTFILE); + return 77; +} diff --git a/gl/tests/test-getaddrinfo.c b/gl/tests/test-getaddrinfo.c index bd245b427b..15d6569b4a 100644 --- a/gl/tests/test-getaddrinfo.c +++ b/gl/tests/test-getaddrinfo.c @@ -161,25 +161,6 @@ simple (char const *host, char const *service) int main (void) { -#if _WIN32 - { - WORD requested; - WSADATA data; - int err; - - requested = MAKEWORD (1, 1); - err = WSAStartup (requested, &data); - if (err != 0) - return 1; - - if (data.wVersion < requested) - { - WSACleanup (); - return 2; - } - } -#endif - return simple (HOST1, SERV1) + simple (HOST2, SERV2) + simple (HOST3, SERV3) diff --git a/gl/tests/test-memchr.c b/gl/tests/test-memchr.c index a801614079..05e1bfaed2 100644 --- a/gl/tests/test-memchr.c +++ b/gl/tests/test-memchr.c @@ -57,6 +57,7 @@ main (void) ASSERT (MEMCHR (input + 1, 'a', n - 1) == input + n - 1); ASSERT (MEMCHR (input + 1, 'e', n - 1) == input + n - 2); + ASSERT (MEMCHR (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2); ASSERT (MEMCHR (input, 'f', n) == NULL); ASSERT (MEMCHR (input, '\0', n) == NULL); @@ -87,25 +88,37 @@ main (void) /* Check that memchr() does not read past the first occurrence of the byte being searched. See the Austin Group's clarification - <http://www.opengroup.org/austin/docs/austin_454.txt>. */ + <http://www.opengroup.org/austin/docs/austin_454.txt>. + Test both '\0' and something else, since some implementations + special-case searching for NUL. + */ { char *page_boundary = (char *) zerosize_ptr (); + /* Too small, and we miss cache line boundary tests; too large, + and the test takes cubically longer to complete. */ + int limit = 257; if (page_boundary != NULL) { - for (n = 1; n <= 500; n++) + for (n = 1; n <= limit; n++) { char *mem = page_boundary - n; memset (mem, 'X', n); ASSERT (MEMCHR (mem, 'U', n) == NULL); + ASSERT (MEMCHR (mem, 0, n) == NULL); { size_t i; + size_t k; for (i = 0; i < n; i++) { mem[i] = 'U'; - ASSERT (MEMCHR (mem, 'U', 4000) == mem + i); + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 'U', k) == mem + i); + mem[i] = 0; + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 0, k) == mem + i); mem[i] = 'X'; } } diff --git a/gl/tests/test-netdb.c b/gl/tests/test-netdb.c index 5f2bcd4e52..697bbc8dbf 100644 --- a/gl/tests/test-netdb.c +++ b/gl/tests/test-netdb.c @@ -1,5 +1,5 @@ /* Test of <netdb.h> substitute. - Copyright (C) 2007-2010 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ /* Check that the 'struct hostent' type is defined. */ struct hostent t1; +/* Check that the 'socklen_t' type is defined. */ +socklen_t t2; + int main (void) { diff --git a/gl/tests/test-read-file.c b/gl/tests/test-read-file.c index 0a0bf6882e..daa61668c6 100644 --- a/gl/tests/test-read-file.c +++ b/gl/tests/test-read-file.c @@ -52,11 +52,23 @@ main (void) err = 1; } - /* Assume FILE1 is a regular file or a symlink to a regular file. */ - if (len != statbuf.st_size) + if (S_ISREG (statbuf.st_mode)) { - fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1); - err = 1; + /* FILE1 is a regular file or a symlink to a regular file. */ + if (len != statbuf.st_size) + { + fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1); + err = 1; + } + } + else + { + /* Assume FILE1 is not empty. */ + if (len == 0) + { + fprintf (stderr, "Read nothing from %s\n", FILE1); + err = 1; + } } free (out); } diff --git a/gl/tests/test-stdbool.c b/gl/tests/test-stdbool.c index fcb534de4c..2103d8bab9 100644 --- a/gl/tests/test-stdbool.c +++ b/gl/tests/test-stdbool.c @@ -16,6 +16,17 @@ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +/* We want this test to succeed even when using gcc's -Werror; but to + do that requires a pragma that didn't exist before 4.3.0. */ +#ifndef __GNUC__ +# define ADDRESS_CHECK_OKAY +#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) +/* No way to silence -Waddress. */ +#else +# pragma GCC diagnostic ignored "-Waddress" +# define ADDRESS_CHECK_OKAY +#endif + #include <config.h> #include <stdbool.h> @@ -39,49 +50,31 @@ "error: __bool_true_false_are_defined is not defined" #endif -#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>. */ +/* Several tests cannot be guaranteed with gnulib's <stdbool.h>, at + least, not for all compilers and compiler options. */ +#if HAVE_STDBOOL_H || defined __GNUC__ struct s { _Bool s: 1; _Bool t; } s; #endif char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; -#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>, at least, -not for all compilers. */ +#if HAVE_STDBOOL_H || defined __GNUC__ /* See above. */ char d[(bool) 0.5 == true ? 1 : -1]; +# ifdef ADDRESS_CHECK_OKAY bool e = &s; +# endif char f[(_Bool) 0.0 == false ? 1 : -1]; #endif char g[true]; char h[sizeof (_Bool)]; -#if 0 /* See above. */ +#if HAVE_STDBOOL_H || defined __GNUC__ /* See above. */ char i[sizeof s.t]; #endif enum { j = false, k = true, l = false * true, m = true * 256 }; _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>. */ -#if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a run-time - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -#endif -#endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html @@ -92,5 +85,11 @@ _Bool *pq = &q; int main () { - return 0; + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This is a runtime test, since a corresponding compile-time + test would rely on initializer extensions. */ + char digs[] = "0123456789"; + return &(digs + 5)[-2 + (bool) 1] != &digs[4]; } diff --git a/gl/tests/test-stddef.c b/gl/tests/test-stddef.c index d047e57b65..2c392c7547 100644 --- a/gl/tests/test-stddef.c +++ b/gl/tests/test-stddef.c @@ -31,6 +31,20 @@ size_t c = 2; per POSIX 2008. */ verify (sizeof NULL == sizeof (void *)); +/* Check that offsetof produces integer constants with correct type. */ +struct d +{ + char e; + char f; +}; +/* Solaris 10 has a bug where offsetof is under-parenthesized, and + cannot be used as an arbitrary expression. However, since it is + unlikely to bite real code, we ignore that short-coming. */ +/* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */ +verify (sizeof (offsetof (struct d, e)) == sizeof (size_t)); +verify (offsetof (struct d, e) < -1); /* Must be unsigned. */ +verify (offsetof (struct d, f) == 1); + int main (void) { diff --git a/gl/tests/test-stdlib.c b/gl/tests/test-stdlib.c index 4bd8715f3d..1e7956b68c 100644 --- a/gl/tests/test-stdlib.c +++ b/gl/tests/test-stdlib.c @@ -22,22 +22,33 @@ #include "verify.h" -int exitcode; +/* Check that EXIT_SUCCESS is 0, per POSIX. */ +static int exitcode = EXIT_SUCCESS; +#if EXIT_SUCCESS +"oops" +#endif + +/* Check for GNU value (not guaranteed by POSIX, but is guaranteed by + gnulib). */ +#if EXIT_FAILURE != 1 +"oops" +#endif /* Check that NULL can be passed through varargs as a pointer type, per POSIX 2008. */ verify (sizeof NULL == sizeof (void *)); +#if GNULIB_TEST_SYSTEM_POSIX +# include "test-sys_wait.h" +#else +# define test_sys_wait_macros() 0 +#endif + int main (void) { - /* Check that some macros are defined and different integer constants. */ - switch (exitcode) - { - case EXIT_SUCCESS: - case EXIT_FAILURE: - break; - } - - return 0; + if (test_sys_wait_macros ()) + return 1; + + return exitcode; } diff --git a/gl/tests/test-sys_socket.c b/gl/tests/test-sys_socket.c index badf308b7a..e976ff6a7b 100644 --- a/gl/tests/test-sys_socket.c +++ b/gl/tests/test-sys_socket.c @@ -1,5 +1,5 @@ /* Test of <sys/socket.h> substitute. - Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +27,9 @@ int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; #endif +/* Check that the 'socklen_t' type is defined. */ +socklen_t t1; + int main (void) { @@ -49,5 +52,9 @@ main (void) x.ss_family = 42; i = 42; + /* Tell the compiler that these variables are used. */ + (void) x; + (void) i; + return 0; } diff --git a/gl/tests/test-sys_wait.h b/gl/tests/test-sys_wait.h new file mode 100644 index 0000000000..bb10450867 --- /dev/null +++ b/gl/tests/test-sys_wait.h @@ -0,0 +1,53 @@ +/* Test of macros shared between <sys/wait.h> and <stdlib.h>. + Copyright (C) 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Eric Blake <ebb9@byu.net>, 2010. */ + +static int +test_sys_wait_macros (void) +{ + /* Check subset of <sys/wait.h> macros that must be visible here. + Note that some of these macros are only portable when operating + on an lvalue. */ + int i; + for (i = 0; i < 0x8000; i = (i ? i << 1 : 1)) + { + /* POSIX requires that for all valid process statuses, that + exactly one of these three macros is true. But not all + possible 16-bit values map to valid process status. + Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits + to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80 + or 0x8000 to flag that core was also dumped. Since we don't + know which byte is WIFEXITED, we skip the both possible bits + that can signal core dump. */ + if (i == 0x80) + continue; + if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1) + return 1; + } + i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i); + + switch (i) + { +#if 0 + /* Gnulib doesn't guarantee these, yet. */ + case WNOHANG: + case WUNTRACED: +#endif + break; + } + return 0; +} diff --git a/gl/tests/test-update-copyright.sh b/gl/tests/test-update-copyright.sh index 2d1022a999..fbf4f23bb4 100755 --- a/gl/tests/test-update-copyright.sh +++ b/gl/tests/test-update-copyright.sh @@ -23,6 +23,9 @@ else compare() { cmp "$@"; } fi +# Ensure the update-copyright program gets found. +PATH=$abs_aux_dir:$PATH + TMP_BASE=update-copyright.test trap 'rm -f $TMP_BASE*' 0 1 2 3 15 @@ -47,6 +50,13 @@ echo a > $TMP-in exit 77 } +# Skip this test if Perl is too old. FIXME: 5.8.0 is just a guess. +# We have a report that 5.6.1 is inadequate and that 5.8.0 works. +perl -e 'require 5.8.0' || { + echo '$0: skipping this test; Perl version is too old' 1>&2 + exit 77 +} + # Do not let a different envvar setting perturb results. UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72 export UPDATE_COPYRIGHT_MAX_LINE_LENGTH diff --git a/gl/tests/test-vc-list-files-cvs.sh b/gl/tests/test-vc-list-files-cvs.sh index 43a3b3fd36..017b8d2460 100755 --- a/gl/tests/test-vc-list-files-cvs.sh +++ b/gl/tests/test-vc-list-files-cvs.sh @@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ : ${srcdir=.} -. "$srcdir/init.sh"; path_prepend_ . +. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" . tmpdir=vc-cvs repo=`pwd`/$tmpdir/repo diff --git a/gl/tests/test-vc-list-files-git.sh b/gl/tests/test-vc-list-files-git.sh index 47576258bc..262d2ea3d2 100755 --- a/gl/tests/test-vc-list-files-git.sh +++ b/gl/tests/test-vc-list-files-git.sh @@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ : ${srcdir=.} -. "$srcdir/init.sh"; path_prepend_ . +. "$srcdir/init.sh"; path_prepend_ "$abs_aux_dir" . tmpdir=vc-git-$$ GIT_DIR= GIT_WORK_TREE=; unset GIT_DIR GIT_WORK_TREE diff --git a/gl/tests/test-verify.c b/gl/tests/test-verify.c index 47eae2b4f3..3f89ba9058 100644 --- a/gl/tests/test-verify.c +++ b/gl/tests/test-verify.c @@ -42,7 +42,8 @@ enum item = verify_true (1 == 1) * 0 + 17 /* should be ok */ }; -int function (int n) +static int +function (int n) { #if EXP_FAIL == 3 verify (n >= 0); /* should give ERROR: non-constant expression */ diff --git a/gl/time.in.h b/gl/time.in.h index 8e364feb82..1d34416f56 100644 --- a/gl/time.in.h +++ b/gl/time.in.h @@ -19,6 +19,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* Don't get in the way of glibc when it includes time.h merely to declare a few standard symbols, rather than to declare all the @@ -48,10 +49,20 @@ /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in <sys/time.h> - (e.g., FreeBSD circa 1997). */ + (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the + pthreads-win32 library defines it in <pthread.h>. */ # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ # include <sys/time.h> +# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ +# include <pthread.h> +/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */ +# undef asctime_r +# undef ctime_r +# undef gmtime_r +# undef localtime_r +# undef rand_r +# undef strtok_r # else # ifdef __cplusplus diff --git a/gl/timespec.h b/gl/timespec.h index 81b342300e..175de7f263 100644 --- a/gl/timespec.h +++ b/gl/timespec.h @@ -22,15 +22,39 @@ # include <time.h> /* Return negative, zero, positive if A < B, A == B, A > B, respectively. - Assume the nanosecond components are in range, or close to it. */ + + For each time stamp T, this code assumes that either: + + * T.tv_nsec is in the range 0..999999999; or + * T.tv_sec corresponds to a valid leap second on a host that supports + leap seconds, and T.tv_nsec is in the range 1000000000..1999999999; or + * T.tv_sec is the minimum time_t value and T.tv_nsec is -1; or + T.tv_sec is the maximum time_t value and T.tv_nsec is 2000000000. + This allows for special struct timespec values that are less or + greater than all possible valid time stamps. + + In all these cases, it is safe to subtract two tv_nsec values and + convert the result to integer without worrying about overflow on + any platform of interest to the GNU project, since all such + platforms have 32-bit int or wider. + + Replacing "(int) (a.tv_nsec - b.tv_nsec)" with something like + "a.tv_nsec < b.tv_nsec ? -1 : a.tv_nsec > b.tv_nsec" would cause + this function to work in some cases where the above assumption is + violated, but not in all cases (e.g., a.tv_sec==1, a.tv_nsec==-2, + b.tv_sec==0, b.tv_nsec==999999999) and is arguably not worth the + extra instructions. Using a subtraction has the advantage of + detecting some invalid cases on platforms that detect integer + overflow. + + The (int) cast avoids a gcc -Wconversion warning. */ + static inline int timespec_cmp (struct timespec a, struct timespec b) { return (a.tv_sec < b.tv_sec ? -1 : a.tv_sec > b.tv_sec ? 1 - : a.tv_nsec < b.tv_nsec ? -1 - : a.tv_nsec > b.tv_nsec ? 1 - : 0); + : (int) (a.tv_nsec - b.tv_nsec)); } void gettime (struct timespec *); diff --git a/gl/unistd.in.h b/gl/unistd.in.h index 7914f22814..fb44e48158 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h @@ -18,6 +18,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* Special invocation convention: - On mingw, several headers, including <winsock2.h>, include <unistd.h>, @@ -1097,7 +1098,7 @@ _GL_CXXALIASWARN (readlinkat); # undef readlinkat # if HAVE_RAW_DECL_READLINKAT _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " - "use gnulib module symlinkat for portability"); + "use gnulib module readlinkat for portability"); # endif #endif diff --git a/gl/wchar.in.h b/gl/wchar.in.h index 88d47dbc09..c0ff224478 100644 --- a/gl/wchar.in.h +++ b/gl/wchar.in.h @@ -29,6 +29,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H /* Special invocation convention: diff --git a/lib/build-aux/config.rpath b/lib/build-aux/config.rpath index c547c68825..17298f2348 100755 --- a/lib/build-aux/config.rpath +++ b/lib/build-aux/config.rpath @@ -2,7 +2,7 @@ # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # -# Copyright 1996-2007 Free Software Foundation, Inc. +# Copyright 1996-2010 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 # @@ -47,7 +47,7 @@ for cc_temp in $CC""; do done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` -# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. +# Code taken from libtool.m4's _LT_COMPILER_PIC. wl= if test "$GCC" = yes; then @@ -64,7 +64,7 @@ else ;; esac ;; - mingw* | cygwin* | pw32* | os2*) + mingw* | cygwin* | pw32* | os2* | cegcc*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' @@ -76,7 +76,13 @@ else ;; linux* | k*bsd*-gnu) case $cc_basename in - icc* | ecc*) + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) wl='-Wl,' ;; pgcc | pgf77 | pgf90) @@ -124,7 +130,7 @@ else esac fi -# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= @@ -132,7 +138,7 @@ hardcode_direct=no hardcode_minus_L=no case "$host_os" in - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. @@ -158,7 +164,7 @@ if test "$with_gnu_ld" = yes; then # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in - aix3* | aix4* | aix5*) + aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no @@ -182,7 +188,7 @@ if test "$with_gnu_ld" = yes; then ld_shlibs=no fi ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -254,7 +260,7 @@ else hardcode_direct=unsupported fi ;; - aix4* | aix5*) + aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. @@ -264,7 +270,7 @@ else # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. - case $host_os in aix4.[23]|aix4.[23].*|aix5*) + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes @@ -326,7 +332,7 @@ else ;; bsdi[45]*) ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is @@ -494,7 +500,7 @@ else fi # Check dynamic linker characteristics -# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. # Unlike libtool.m4, here we don't care about _all_ names of the library, but # only about the one the linker finds when passed -lNAME. This is the last # element of library_names_spec in libtool.m4, or possibly two of them if the @@ -505,7 +511,7 @@ case "$host_os" in aix3*) library_names_spec='$libname.a' ;; - aix4* | aix5*) + aix[4-9]*) library_names_spec='$libname$shrext' ;; amigaos*) @@ -517,7 +523,7 @@ case "$host_os" in bsdi[45]*) library_names_spec='$libname$shrext' ;; - cygwin* | mingw* | pw32*) + cygwin* | mingw* | pw32* | cegcc*) shrext=.dll library_names_spec='$libname.dll.a $libname.lib' ;; diff --git a/lib/gl/Makefile.am b/lib/gl/Makefile.am index 1e7b7d79f6..423ad33ab0 100644 --- a/lib/gl/Makefile.am +++ b/lib/gl/Makefile.am @@ -38,6 +38,9 @@ liblgnu_la_LIBADD = $(lgl_LTLIBOBJS) liblgnu_la_DEPENDENCIES = $(lgl_LTLIBOBJS) EXTRA_liblgnu_la_SOURCES = liblgnu_la_LDFLAGS = $(AM_LDFLAGS) +liblgnu_la_LDFLAGS += -no-undefined +liblgnu_la_LDFLAGS += $(LIBSOCKET) +liblgnu_la_LDFLAGS += $(LTLIBINTL) ## begin gnulib module alignof @@ -155,6 +158,7 @@ errno.h: errno.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ @@ -182,6 +186,7 @@ float.h: float.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ < $(srcdir)/float.in.h; \ } > $@-t && \ @@ -201,6 +206,15 @@ EXTRA_liblgnu_la_SOURCES += fseeko.c ## end gnulib module fseeko +## begin gnulib module ftello + + +EXTRA_DIST += ftello.c stdio-impl.h + +EXTRA_liblgnu_la_SOURCES += ftello.c + +## end gnulib module ftello + ## begin gnulib module gettext # This is for those projects which use "gettextize --intl" to put a source-code @@ -239,6 +253,15 @@ EXTRA_liblgnu_la_SOURCES += lseek.c ## end gnulib module lseek +## begin gnulib module malloc-posix + + +EXTRA_DIST += malloc.c + +EXTRA_liblgnu_la_SOURCES += malloc.c + +## end gnulib module malloc-posix + ## begin gnulib module memchr @@ -274,6 +297,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \ -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \ -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \ @@ -363,6 +387,7 @@ stddef.h: stddef.in.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ @@ -387,6 +412,7 @@ stdint.h: stdint.in.h sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ @@ -428,6 +454,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ @@ -538,7 +565,9 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ + -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \ -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ @@ -561,15 +590,15 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \ -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ + -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \ -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ + -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ - -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ - -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ @@ -578,7 +607,6 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ - -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ @@ -589,9 +617,12 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ + -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ + -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ + -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ @@ -628,6 +659,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \ -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \ @@ -718,6 +750,7 @@ strings.h: strings.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \ @@ -753,6 +786,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ @@ -801,6 +835,7 @@ sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ @@ -858,6 +893,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \ -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \ @@ -872,6 +908,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ + -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ @@ -907,6 +944,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ @@ -1077,6 +1115,7 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \ diff --git a/lib/gl/errno.in.h b/lib/gl/errno.in.h index 579348cc3b..4994ebfa48 100644 --- a/lib/gl/errno.in.h +++ b/lib/gl/errno.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_ERRNO_H@ @@ -98,6 +99,7 @@ /* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. + Likewise, on NonStop Kernel, EDQUOT is not defined. Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. @@ -150,6 +152,11 @@ # define GNULIB_defined_ESTALE 1 # endif +# ifndef EDQUOT +# define EDQUOT 2010 +# define GNULIB_defined_EDQUOT 1 +# endif + # ifndef ECANCELED # define ECANCELED 2008 # define GNULIB_defined_ECANCELED 1 diff --git a/lib/gl/float.in.h b/lib/gl/float.in.h index dc1f6ce6db..c0ddaa518a 100644 --- a/lib/gl/float.in.h +++ b/lib/gl/float.in.h @@ -20,6 +20,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_FLOAT_H@ diff --git a/lib/gl/ftello.c b/lib/gl/ftello.c new file mode 100644 index 0000000000..f4beeea881 --- /dev/null +++ b/lib/gl/ftello.c @@ -0,0 +1,77 @@ +/* An ftello() function that works around platform bugs. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <stdio.h> + +/* Get lseek. */ +#include <unistd.h> + +#include "stdio-impl.h" + +off_t +ftello (FILE *fp) +#undef ftello +#if !HAVE_FTELLO +# undef ftell +# define ftello ftell +#endif +{ +#if LSEEK_PIPE_BROKEN + /* mingw gives bogus answers rather than failure on non-seekable files. */ + if (lseek (fileno (fp), 0, SEEK_CUR) == -1) + return -1; +#endif + +#if FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE /* Solaris */ + /* The Solaris stdio leaves the _IOREAD flag set after reading from a file + reaches EOF and the program then starts writing to the file. ftello + gets confused by this. */ + if (fp_->_flag & _IOWRT) + { + off_t pos; + + /* Call ftello nevertheless, for the side effects that it does on fp. */ + ftello (fp); + + /* Compute the file position ourselves. */ + pos = llseek (fileno (fp), (off_t) 0, SEEK_CUR); + if (pos >= 0) + { + if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL) + pos += fp_->_ptr - fp_->_base; + } + return pos; + } +#endif + +#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 ftello 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 + return ftello (fp); +} diff --git a/lib/gl/m4/codeset.m4 b/lib/gl/m4/codeset.m4 index a53c04260c..f722b2e86a 100644 --- a/lib/gl/m4/codeset.m4 +++ b/lib/gl/m4/codeset.m4 @@ -1,4 +1,4 @@ -# codeset.m4 serial 4 (gettext-0.18) +# codeset.m4 serial 5 (gettext-0.18.2) dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,10 +9,12 @@ dnl From Bruno Haible. AC_DEFUN([AM_LANGINFO_CODESET], [ AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], - [AC_TRY_LINK([#include <langinfo.h>], - [char* cs = nl_langinfo(CODESET); return !cs;], - [am_cv_langinfo_codeset=yes], - [am_cv_langinfo_codeset=no]) + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <langinfo.h>]], + [[char* cs = nl_langinfo(CODESET); return !cs;]])], + [am_cv_langinfo_codeset=yes], + [am_cv_langinfo_codeset=no]) ]) if test $am_cv_langinfo_codeset = yes; then AC_DEFINE([HAVE_LANGINFO_CODESET], [1], diff --git a/lib/gl/m4/errno_h.m4 b/lib/gl/m4/errno_h.m4 index d02a039363..e4325ac660 100644 --- a/lib/gl/m4/errno_h.m4 +++ b/lib/gl/m4/errno_h.m4 @@ -1,5 +1,5 @@ -# errno_h.m4 serial 6 -dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. +# errno_h.m4 serial 7 +dnl Copyright (C) 2004, 2006, 2008-2010 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. @@ -37,6 +37,9 @@ booboo #if !defined ESTALE booboo #endif +#if !defined EDQUOT +booboo +#endif #if !defined ECANCELED booboo #endif diff --git a/lib/gl/m4/fcntl-o.m4 b/lib/gl/m4/fcntl-o.m4 index d416a61c85..1adacc8ab7 100644 --- a/lib/gl/m4/fcntl-o.m4 +++ b/lib/gl/m4/fcntl-o.m4 @@ -1,4 +1,4 @@ -# fcntl-o.m4 serial 1 +# fcntl-o.m4 serial 2 dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,7 +12,11 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_FCNTL_O_FLAGS], [ dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW. - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes + dnl AC_GNU_SOURCE. + m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], + [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], + [AC_REQUIRE([AC_GNU_SOURCE])]) AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( diff --git a/lib/gl/m4/float_h.m4 b/lib/gl/m4/float_h.m4 index a74a0d957f..f6099db405 100644 --- a/lib/gl/m4/float_h.m4 +++ b/lib/gl/m4/float_h.m4 @@ -1,4 +1,4 @@ -# float_h.m4 serial 3 +# float_h.m4 serial 4 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,7 +10,7 @@ AC_DEFUN([gl_FLOAT_H], AC_REQUIRE([AC_CANONICAL_HOST]) FLOAT_H= case "$host_os" in - beos* | openbsd*) + beos* | openbsd* | mirbsd*) FLOAT_H=float.h gl_CHECK_NEXT_HEADERS([float.h]) ;; diff --git a/lib/gl/m4/ftello.m4 b/lib/gl/m4/ftello.m4 new file mode 100644 index 0000000000..33201a0107 --- /dev/null +++ b/lib/gl/m4/ftello.m4 @@ -0,0 +1,130 @@ +# ftello.m4 serial 8 +dnl Copyright (C) 2007-2010 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_FTELLO], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([gl_STDIN_LARGE_OFFSET]) + + dnl Persuade glibc <stdio.h> to declare ftello(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_CACHE_CHECK([for ftello], [gl_cv_func_ftello], + [ + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stdio.h>]], + [[ftello (stdin);]])], + [gl_cv_func_ftello=yes], + [gl_cv_func_ftello=no]) + ]) + if test $gl_cv_func_ftello = no; then + HAVE_FTELLO=0 + else + if test $gl_cv_var_stdin_large_offset = no; then + REPLACE_FTELLO=1 + else + dnl Detect bug on Solaris. + dnl ftell and ftello produce incorrect results after putc that followed a + dnl getc call that reached EOF on Solaris. This is because the _IOREAD + dnl flag does not get cleared in this case, even though _IOWRT gets set, + dnl and ftell and ftello look whether the _IOREAD flag is set. + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CACHE_CHECK([whether ftello works], + [gl_cv_func_ftello_works], + [ + dnl Initial guess, used when cross-compiling or when /dev/tty cannot + dnl be opened. +changequote(,)dnl + case "$host_os" in + # Guess no on Solaris. + solaris*) gl_cv_func_ftello_works="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_ftello_works="guessing yes" ;; + esac +changequote([,])dnl + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#define TESTFILE "conftest.tmp" +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + return 70; + if (fwrite ("foogarsh", 1, 8, fp) < 8) + return 71; + if (fclose (fp)) + return 72; + + /* The file's contents is now "foogarsh". */ + + /* Try writing after reading to EOF. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + return 73; + if (fseek (fp, -1, SEEK_END)) + return 74; + if (!(getc (fp) == 'h')) + return 1; + if (!(getc (fp) == EOF)) + return 2; + if (!(ftell (fp) == 8)) + return 3; + if (!(ftell (fp) == 8)) + return 4; + if (!(putc ('!', fp) == '!')) + return 5; + if (!(ftell (fp) == 9)) + return 6; + if (!(fclose (fp) == 0)) + return 7; + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + return 75; + { + char buf[10]; + if (!(fread (buf, 1, 10, fp) == 9)) + return 10; + if (!(memcmp (buf, "foogarsh!", 9) == 0)) + return 11; + } + if (!(fclose (fp) == 0)) + return 12; + + /* The file's contents is now "foogarsh!". */ + + return 0; +}]])], + [gl_cv_func_ftello_works=yes], + [gl_cv_func_ftello_works=no], [:]) + ]) + case "$gl_cv_func_ftello_works" in + *yes) ;; + *) + REPLACE_FTELLO=1 + AC_DEFINE([FTELLO_BROKEN_AFTER_SWITCHING_FROM_READ_TO_WRITE], [1], + [Define to 1 if the system's ftello function has the Solaris bug.]) + ;; + esac + fi + fi + if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then + gl_REPLACE_FTELLO + fi +]) + +AC_DEFUN([gl_REPLACE_FTELLO], +[ + AC_LIBOBJ([ftello]) +]) diff --git a/lib/gl/m4/getpagesize.m4 b/lib/gl/m4/getpagesize.m4 new file mode 100644 index 0000000000..313ad7fa26 --- /dev/null +++ b/lib/gl/m4/getpagesize.m4 @@ -0,0 +1,33 @@ +# getpagesize.m4 serial 8 +dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_GETPAGESIZE], +[ + AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_CHECK_FUNCS([getpagesize]) + if test $ac_cv_func_getpagesize = no; then + HAVE_GETPAGESIZE=0 + AC_CHECK_HEADERS([OS.h]) + if test $ac_cv_header_OS_h = yes; then + HAVE_OS_H=1 + fi + AC_CHECK_HEADERS([sys/param.h]) + if test $ac_cv_header_sys_param_h = yes; then + HAVE_SYS_PARAM_H=1 + fi + fi + case "$host_os" in + mingw*) + REPLACE_GETPAGESIZE=1 + AC_LIBOBJ([getpagesize]) + ;; + esac + dnl Also check whether it's declared. + dnl mingw has getpagesize() in libgcc.a but doesn't declare it. + AC_CHECK_DECL([getpagesize], , [HAVE_DECL_GETPAGESIZE=0]) +]) diff --git a/lib/gl/m4/gettext.m4 b/lib/gl/m4/gettext.m4 index f84e6a5d75..979c52c196 100644 --- a/lib/gl/m4/gettext.m4 +++ b/lib/gl/m4/gettext.m4 @@ -1,4 +1,4 @@ -# gettext.m4 serial 63 (gettext-0.18) +# gettext.m4 serial 64 (gettext-0.18.2) dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -157,12 +157,18 @@ changequote([,])dnl fi AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], - [AC_TRY_LINK([#include <libintl.h> + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <libintl.h> $gt_revision_test_code extern int _nl_msg_cat_cntr; -extern int *_nl_domain_bindings;], - [bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], +extern int *_nl_domain_bindings; + ]], + [[ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings + ]])], [eval "$gt_func_gnugettext_libc=yes"], [eval "$gt_func_gnugettext_libc=no"])]) @@ -183,35 +189,47 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_b gt_save_LIBS="$LIBS" LIBS="$LIBS $LIBINTL" dnl Now see whether libintl exists and does not depend on libiconv. - AC_TRY_LINK([#include <libintl.h> + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <libintl.h> $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif -const char *_nl_expand_alias (const char *);], - [bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], +const char *_nl_expand_alias (const char *); + ]], + [[ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") + ]])], [eval "$gt_func_gnugettext_libintl=yes"], [eval "$gt_func_gnugettext_libintl=no"]) dnl Now see whether libintl exists and depends on libiconv. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then LIBS="$LIBS $LIBICONV" - AC_TRY_LINK([#include <libintl.h> + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <libintl.h> $gt_revision_test_code extern int _nl_msg_cat_cntr; extern #ifdef __cplusplus "C" #endif -const char *_nl_expand_alias (const char *);], - [bindtextdomain ("", ""); -return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], - [LIBINTL="$LIBINTL $LIBICONV" - LTLIBINTL="$LTLIBINTL $LTLIBICONV" - eval "$gt_func_gnugettext_libintl=yes" - ]) +const char *_nl_expand_alias (const char *); + ]], + [[ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") + ]])], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + ]) fi CPPFLAGS="$gt_save_CPPFLAGS" LIBS="$gt_save_LIBS"]) diff --git a/lib/gl/m4/gnulib-cache.m4 b/lib/gl/m4/gnulib-cache.m4 index 5129198896..24590151e2 100644 --- a/lib/gl/m4/gnulib-cache.m4 +++ b/lib/gl/m4/gnulib-cache.m4 @@ -10,8 +10,8 @@ # # This file represents the specification of how gnulib-tool is used. # It acts as a cache: It is written and read by gnulib-tool. -# In projects using CVS, this file is meant to be stored in CVS, -# like the configure.ac and various Makefile.am files. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. # Specification in the form of a command-line invocation: diff --git a/lib/gl/m4/gnulib-comp.m4 b/lib/gl/m4/gnulib-comp.m4 index 02eb40d030..733ed45f3b 100644 --- a/lib/gl/m4/gnulib-comp.m4 +++ b/lib/gl/m4/gnulib-comp.m4 @@ -12,7 +12,8 @@ # This file represents the compiled summary of the specification in # gnulib-cache.m4. It lists the computed macro invocations that need # to be invoked from configure.ac. -# In projects using CVS, this file can be treated like other built files. +# In projects that use version control, this file can be treated like +# other built files. # This macro should be invoked from ./configure.ac, in the section @@ -29,6 +30,8 @@ AC_DEFUN([lgl_EARLY], # Code from module alloca-opt: # Code from module alloca-opt-tests: # Code from module arg-nonnull: + # Code from module binary-io: + # Code from module binary-io-tests: # Code from module byteswap: # Code from module byteswap-tests: # Code from module c++defs: @@ -43,8 +46,12 @@ AC_DEFUN([lgl_EARLY], # Code from module fseeko: AC_REQUIRE([AC_FUNC_FSEEKO]) # Code from module fseeko-tests: + # Code from module ftello: + AC_REQUIRE([AC_FUNC_FSEEKO]) + # Code from module ftello-tests: # Code from module func: # Code from module func-tests: + # Code from module getpagesize: # Code from module gettext: # Code from module gettext-h: # Code from module havelib: @@ -53,6 +60,7 @@ AC_DEFUN([lgl_EARLY], # Code from module lib-msvc-compat: # Code from module lib-symbol-versions: # Code from module lseek: + # Code from module malloc-posix: # Code from module memchr: # Code from module memchr-tests: # Code from module memmem-simple: @@ -66,6 +74,7 @@ AC_DEFUN([lgl_EARLY], # Code from module size_max: # Code from module snprintf: # Code from module snprintf-tests: + # Code from module socketlib: # Code from module sockets: # Code from module sockets-tests: # Code from module socklen: @@ -140,11 +149,14 @@ AC_DEFUN([lgl_INIT], # Code from module fseeko: gl_FUNC_FSEEKO gl_STDIO_MODULE_INDICATOR([fseeko]) + # Code from module ftello: + gl_FUNC_FTELLO + gl_STDIO_MODULE_INDICATOR([ftello]) # Code from module func: gl_FUNC # Code from module gettext: dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. - AM_GNU_GETTEXT_VERSION([0.18]) + AM_GNU_GETTEXT_VERSION([0.18.1]) # Code from module gettext-h: AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) @@ -157,6 +169,9 @@ AC_DEFUN([lgl_INIT], # Code from module lseek: gl_FUNC_LSEEK gl_UNISTD_MODULE_INDICATOR([lseek]) + # Code from module malloc-posix: + gl_FUNC_MALLOC_POSIX + gl_STDLIB_MODULE_INDICATOR([malloc-posix]) # Code from module memchr: gl_FUNC_MEMCHR gl_STRING_MODULE_INDICATOR([memchr]) @@ -179,6 +194,8 @@ AC_DEFUN([lgl_INIT], # Code from module snprintf: gl_FUNC_SNPRINTF gl_STDIO_MODULE_INDICATOR([snprintf]) + # Code from module socketlib: + gl_SOCKETLIB # Code from module sockets: gl_SOCKETS # Code from module socklen: @@ -278,6 +295,13 @@ changequote([, ])dnl gl_module_indicator_condition=$lgltests_WITNESS m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) gl_FUNC_UNGETC_WORKS + gl_FUNC_UNGETC_WORKS + gl_FUNC_GETPAGESIZE + gl_UNISTD_MODULE_INDICATOR([getpagesize]) + dnl Check for prerequisites for memory fence checks. + gl_FUNC_MMAP_ANON + AC_CHECK_HEADERS_ONCE([sys/mman.h]) + AC_CHECK_FUNCS_ONCE([mprotect]) gt_TYPE_WCHAR_T gt_TYPE_WINT_T AC_CHECK_FUNCS_ONCE([shutdown]) @@ -390,8 +414,10 @@ AC_DEFUN([lgl_FILE_LIST], [ lib/float+.h lib/float.in.h lib/fseeko.c + lib/ftello.c lib/gettext.h lib/lseek.c + lib/malloc.c lib/memchr.c lib/memchr.valgrind lib/memmem.c @@ -443,7 +469,9 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/fcntl-o.m4 m4/float_h.m4 m4/fseeko.m4 + m4/ftello.m4 m4/func.m4 + m4/getpagesize.m4 m4/gettext.m4 m4/glibc2.m4 m4/glibc21.m4 @@ -483,6 +511,7 @@ AC_DEFUN([lgl_FILE_LIST], [ m4/realloc.m4 m4/size_max.m4 m4/snprintf.m4 + m4/socketlib.m4 m4/sockets.m4 m4/socklen.m4 m4/sockpfaf.m4 @@ -517,12 +546,18 @@ AC_DEFUN([lgl_FILE_LIST], [ tests/macros.h tests/signature.h tests/test-alloca-opt.c + tests/test-binary-io.c + tests/test-binary-io.sh tests/test-byteswap.c tests/test-c-ctype.c tests/test-errno.c tests/test-fseeko.c tests/test-fseeko.sh tests/test-fseeko2.sh + tests/test-ftello.c + tests/test-ftello.sh + tests/test-ftello2.sh + tests/test-ftello3.c tests/test-func.c tests/test-memchr.c tests/test-netdb.c @@ -539,6 +574,7 @@ AC_DEFUN([lgl_FILE_LIST], [ tests/test-strverscmp.c tests/test-sys_socket.c tests/test-sys_stat.c + tests/test-sys_wait.h tests/test-time.c tests/test-unistd.c tests/test-vasnprintf.c @@ -548,7 +584,9 @@ AC_DEFUN([lgl_FILE_LIST], [ tests/test-vsnprintf.c tests/test-wchar.c tests/zerosize-ptr.h + tests=lib/binary-io.h tests=lib/dummy.c + tests=lib/getpagesize.c tests=lib/intprops.h tests=lib/verify.h ]) diff --git a/lib/gl/m4/iconv.m4 b/lib/gl/m4/iconv.m4 index 4c68472135..425145c0ae 100644 --- a/lib/gl/m4/iconv.m4 +++ b/lib/gl/m4/iconv.m4 @@ -1,4 +1,4 @@ -# iconv.m4 serial 10 (gettext-0.18.1) +# iconv.m4 serial 15 (gettext-0.18.2) dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -30,27 +30,35 @@ AC_DEFUN([AM_ICONV_LINK], dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first - dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no - AC_TRY_LINK([#include <stdlib.h> -#include <iconv.h>], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <stdlib.h> +#include <iconv.h> + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], [am_cv_func_iconv=yes]) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" - AC_TRY_LINK([#include <stdlib.h> -#include <iconv.h>], - [iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd);], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <stdlib.h> +#include <iconv.h> + ]], + [[iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);]])], [am_cv_lib_iconv=yes] [am_cv_func_iconv=yes]) LIBS="$am_save_LIBS" @@ -58,12 +66,14 @@ AC_DEFUN([AM_ICONV_LINK], ]) if test "$am_cv_func_iconv" = yes; then AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ - dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. + dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, + dnl Solaris 10. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <iconv.h> #include <string.h> int main () @@ -106,6 +116,24 @@ int main () return 1; } } + /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304"; + static char buf[2] = { (char)0xDE, (char)0xAD }; + const char *inptr = input; + size_t inbytesleft = 1; + char *outptr = buf; + size_t outbytesleft = 1; + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) + return 1; + } + } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { @@ -138,11 +166,17 @@ int main () && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) return 1; return 0; -}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], - [case "$host_os" in +}]])], + [am_cv_func_iconv_works=yes], + [am_cv_func_iconv_works=no], + [ +changequote(,)dnl + case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; - esac]) + esac +changequote([,])dnl + ]) LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in @@ -173,13 +207,30 @@ int main () dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to dnl avoid warnings like dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". -m4_version_prereq([2.64],[AC_DEFUN_ONCE],[AC_DEFUN])([AM_ICONV], +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [m4_ifdef([gl_00GNULIB], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])])) +gl_iconv_AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL([am_cv_proto_iconv], [ - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ #include <stdlib.h> #include <iconv.h> extern @@ -191,7 +242,10 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si #else size_t iconv(); #endif -], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) + ]], + [[]])], + [am_cv_proto_iconv_arg1=""], + [am_cv_proto_iconv_arg1="const"]) am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([ diff --git a/lib/gl/m4/include_next.m4 b/lib/gl/m4/include_next.m4 index c7e0672f60..e37eb0567d 100644 --- a/lib/gl/m4/include_next.m4 +++ b/lib/gl/m4/include_next.m4 @@ -1,4 +1,4 @@ -# include_next.m4 serial 14 +# include_next.m4 serial 16 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -24,6 +24,13 @@ dnl does not warn about some things, and on some systems (Solaris and Interix) dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead dnl of plain '__STDC__'. +dnl +dnl PRAGMA_COLUMNS can be used in files that override system header files, so +dnl as to avoid compilation errors on HP NonStop systems when the gnulib file +dnl is included by a system header file that does a "#pragma COLUMNS 80" (which +dnl has the effect of truncating the lines of that file and all files that it +dnl includes to 80 columns) and the gnulib file has lines longer than 80 +dnl columns. AC_DEFUN([gl_INCLUDE_NEXT], [ @@ -68,10 +75,11 @@ EOF EOF gl_save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" - AC_COMPILE_IFELSE([#include <conftest.h>], +dnl We intentionally avoid using AC_LANG_SOURCE here. + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], [gl_cv_have_include_next=yes], [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" - AC_COMPILE_IFELSE([#include <conftest.h>], + AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], [gl_cv_have_include_next=buggy], [gl_cv_have_include_next=no]) ]) @@ -97,6 +105,24 @@ EOF AC_SUBST([INCLUDE_NEXT]) AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) AC_SUBST([PRAGMA_SYSTEM_HEADER]) + AC_CACHE_CHECK([whether system header files limit the line length], + [gl_cv_pragma_columns], + [dnl HP NonStop systems, which define __TANDEM, have this misfeature. + AC_EGREP_CPP([choke me], + [ +#ifdef __TANDEM +choke me +#endif + ], + [gl_cv_pragma_columns=yes], + [gl_cv_pragma_columns=no]) + ]) + if test $gl_cv_pragma_columns = yes; then + PRAGMA_COLUMNS="#pragma COLUMNS 10000" + else + PRAGMA_COLUMNS= + fi + AC_SUBST([PRAGMA_COLUMNS]) ]) # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) @@ -185,3 +211,7 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS], [$gl_next_as_first_directive]) AS_VAR_POPDEF([gl_next_header])]) ]) + +# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; +# this fallback is safe for all earlier autoconf versions. +m4_define_default([AC_LANG_DEFINES_PROVIDED]) diff --git a/lib/gl/m4/intdiv0.m4 b/lib/gl/m4/intdiv0.m4 index 289c4df5ed..9b27ff1b79 100644 --- a/lib/gl/m4/intdiv0.m4 +++ b/lib/gl/m4/intdiv0.m4 @@ -1,5 +1,5 @@ -# intdiv0.m4 serial 3 (gettext-0.18) -dnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc. +# intdiv0.m4 serial 4 (gettext-0.18.2) +dnl Copyright (C) 2002, 2007-2008, 2010 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. @@ -29,7 +29,8 @@ changequote(,)dnl esac changequote([,])dnl if test -z "$gt_cv_int_divbyzero_sigfpe"; then - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdlib.h> #include <signal.h> @@ -61,7 +62,9 @@ int main () nan = y / y; exit (1); } -], [gt_cv_int_divbyzero_sigfpe=yes], [gt_cv_int_divbyzero_sigfpe=no], +]])], + [gt_cv_int_divbyzero_sigfpe=yes], + [gt_cv_int_divbyzero_sigfpe=no], [ # Guess based on the CPU. changequote(,)dnl diff --git a/lib/gl/m4/intl.m4 b/lib/gl/m4/intl.m4 index 335b23c20c..d84bc4a9b4 100644 --- a/lib/gl/m4/intl.m4 +++ b/lib/gl/m4/intl.m4 @@ -1,5 +1,5 @@ -# intl.m4 serial 17 (gettext-0.18) -dnl Copyright (C) 1995-2009 Free Software Foundation, Inc. +# intl.m4 serial 17b +dnl Copyright (C) 1995-2010 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. @@ -17,7 +17,7 @@ dnl Authors: dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009. -AC_PREREQ([2.52]) +AC_PREREQ([2.53]) dnl Checks for all prerequisites of the intl subdirectory, dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, @@ -220,9 +220,10 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE], AC_REQUIRE([gt_INTTYPES_PRI])dnl AC_REQUIRE([gl_LOCK])dnl - AC_TRY_LINK( - [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], - [], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]], + [[]])], [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define to 1 if the compiler understands __builtin_expect.])]) @@ -279,11 +280,16 @@ dnl Check whether a function is declared. AC_DEFUN([gt_CHECK_DECL], [ AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1], - [AC_TRY_COMPILE([$2], [ + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[$2]], + [[ #ifndef $1 char *p = (char *) $1; #endif -], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) + ]])], + [ac_cv_have_decl_$1=yes], + [ac_cv_have_decl_$1=no])]) if test $ac_cv_have_decl_$1 = yes; then gt_value=1 else diff --git a/lib/gl/m4/intlmacosx.m4 b/lib/gl/m4/intlmacosx.m4 index dd91025962..f0f7c98726 100644 --- a/lib/gl/m4/intlmacosx.m4 +++ b/lib/gl/m4/intlmacosx.m4 @@ -1,4 +1,4 @@ -# intlmacosx.m4 serial 3 (gettext-0.18) +# intlmacosx.m4 serial 4 (gettext-0.18.2) dnl Copyright (C) 2004-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -22,8 +22,10 @@ AC_DEFUN([gt_INTL_MACOSX], [gt_cv_func_CFPreferencesCopyAppValue], [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>], - [CFPreferencesCopyAppValue(NULL, NULL)], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <CoreFoundation/CFPreferences.h>]], + [[CFPreferencesCopyAppValue(NULL, NULL)]])], [gt_cv_func_CFPreferencesCopyAppValue=yes], [gt_cv_func_CFPreferencesCopyAppValue=no]) LIBS="$gt_save_LIBS"]) @@ -35,7 +37,10 @@ AC_DEFUN([gt_INTL_MACOSX], AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], [gt_save_LIBS="$LIBS" LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" - AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <CoreFoundation/CFLocale.h>]], + [[CFLocaleCopyCurrent();]])], [gt_cv_func_CFLocaleCopyCurrent=yes], [gt_cv_func_CFLocaleCopyCurrent=no]) LIBS="$gt_save_LIBS"]) diff --git a/lib/gl/m4/intmax.m4 b/lib/gl/m4/intmax.m4 index 74aaaf5ed6..2c0f2afe59 100644 --- a/lib/gl/m4/intmax.m4 +++ b/lib/gl/m4/intmax.m4 @@ -1,4 +1,4 @@ -# intmax.m4 serial 5 (gettext-0.18) +# intmax.m4 serial 6 (gettext-0.18.2) dnl Copyright (C) 2002-2005, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -13,7 +13,9 @@ AC_DEFUN([gt_TYPE_INTMAX_T], AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gl_AC_HEADER_STDINT_H]) AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ #include <stddef.h> #include <stdlib.h> #if HAVE_STDINT_H_WITH_UINTMAX @@ -22,8 +24,9 @@ AC_DEFUN([gt_TYPE_INTMAX_T], #if HAVE_INTTYPES_H_WITH_UINTMAX #include <inttypes.h> #endif -], [intmax_t x = -1; - return !x;], + ]], + [[intmax_t x = -1; + return !x;]])], [gt_cv_c_intmax_t=yes], [gt_cv_c_intmax_t=no])]) if test $gt_cv_c_intmax_t = yes; then diff --git a/lib/gl/m4/intmax_t.m4 b/lib/gl/m4/intmax_t.m4 index 975caac506..493e4a9328 100644 --- a/lib/gl/m4/intmax_t.m4 +++ b/lib/gl/m4/intmax_t.m4 @@ -1,4 +1,4 @@ -# intmax_t.m4 serial 7 +# intmax_t.m4 serial 8 dnl Copyright (C) 1997-2004, 2006-2007, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Paul Eggert. -AC_PREREQ([2.13]) +AC_PREREQ([2.53]) # Define intmax_t to 'long' or 'long long' # if it is not already defined in <stdint.h> or <inttypes.h>. @@ -38,7 +38,9 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) AC_REQUIRE([gl_AC_HEADER_STDINT_H]) AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ #include <stddef.h> #include <stdlib.h> #if HAVE_STDINT_H_WITH_UINTMAX @@ -47,7 +49,10 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T], #if HAVE_INTTYPES_H_WITH_UINTMAX #include <inttypes.h> #endif -], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) + ]], + [[intmax_t x = -1; return !x;]])], + [gt_cv_c_intmax_t=yes], + [gt_cv_c_intmax_t=no])]) if test $gt_cv_c_intmax_t = yes; then AC_DEFINE([HAVE_INTMAX_T], [1], [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) diff --git a/lib/gl/m4/inttypes-pri.m4 b/lib/gl/m4/inttypes-pri.m4 index 718a4f4e19..ee96bcd978 100644 --- a/lib/gl/m4/inttypes-pri.m4 +++ b/lib/gl/m4/inttypes-pri.m4 @@ -1,4 +1,4 @@ -# inttypes-pri.m4 serial 6 (gettext-0.18) +# inttypes-pri.m4 serial 7 (gettext-0.18.2) dnl Copyright (C) 1997-2002, 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. -AC_PREREQ([2.52]) +AC_PREREQ([2.53]) # Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI* # macros to non-string values. This is the case on AIX 4.3.3. @@ -18,11 +18,17 @@ AC_DEFUN([gt_INTTYPES_PRI], AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], [gt_cv_inttypes_pri_broken], [ - AC_TRY_COMPILE([#include <inttypes.h> + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <inttypes.h> #ifdef PRId32 char *p = PRId32; #endif -], [], [gt_cv_inttypes_pri_broken=no], [gt_cv_inttypes_pri_broken=yes]) + ]], + [[]])], + [gt_cv_inttypes_pri_broken=no], + [gt_cv_inttypes_pri_broken=yes]) ]) fi if test "$gt_cv_inttypes_pri_broken" = yes; then diff --git a/lib/gl/m4/inttypes_h.m4 b/lib/gl/m4/inttypes_h.m4 index 782d77ed8b..9d8f926926 100644 --- a/lib/gl/m4/inttypes_h.m4 +++ b/lib/gl/m4/inttypes_h.m4 @@ -1,4 +1,4 @@ -# inttypes_h.m4 serial 9 +# inttypes_h.m4 serial 10 dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,12 +12,15 @@ dnl From Paul Eggert. AC_DEFUN([gl_AC_HEADER_INTTYPES_H], [ AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], - [AC_TRY_COMPILE( - [#include <sys/types.h> -#include <inttypes.h>], - [uintmax_t i = (uintmax_t) -1; return !i;], - [gl_cv_header_inttypes_h=yes], - [gl_cv_header_inttypes_h=no])]) + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <sys/types.h> +#include <inttypes.h> + ]], + [[uintmax_t i = (uintmax_t) -1; return !i;]])], + [gl_cv_header_inttypes_h=yes], + [gl_cv_header_inttypes_h=no])]) if test $gl_cv_header_inttypes_h = yes; then AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, diff --git a/lib/gl/m4/lcmessage.m4 b/lib/gl/m4/lcmessage.m4 index 1a705431a9..232da73b69 100644 --- a/lib/gl/m4/lcmessage.m4 +++ b/lib/gl/m4/lcmessage.m4 @@ -1,4 +1,4 @@ -# lcmessage.m4 serial 6 (gettext-0.18) +# lcmessage.m4 serial 7 (gettext-0.18.2) dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -22,8 +22,12 @@ dnl Ulrich Drepper <drepper@cygnus.com>, 1995. AC_DEFUN([gt_LC_MESSAGES], [ AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES], - [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], - [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])]) + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <locale.h>]], + [[return LC_MESSAGES]])], + [gt_cv_val_LC_MESSAGES=yes], + [gt_cv_val_LC_MESSAGES=no])]) if test $gt_cv_val_LC_MESSAGES = yes; then AC_DEFINE([HAVE_LC_MESSAGES], [1], [Define if your <locale.h> file defines LC_MESSAGES.]) diff --git a/lib/gl/m4/ld-version-script.m4 b/lib/gl/m4/ld-version-script.m4 index 43c1ef12f9..8fd8c8995c 100644 --- a/lib/gl/m4/ld-version-script.m4 +++ b/lib/gl/m4/ld-version-script.m4 @@ -1,4 +1,4 @@ -# ld-version-script.m4 serial 1 +# ld-version-script.m4 serial 2 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,7 +34,7 @@ VERS_2 { global: sym; } VERS_1; EOF - AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [have_ld_version_script=yes], [have_ld_version_script=no]) rm -f conftest.map LDFLAGS="$save_LDFLAGS" diff --git a/lib/gl/m4/lib-ld.m4 b/lib/gl/m4/lib-ld.m4 index ebb30528bd..294db72e13 100644 --- a/lib/gl/m4/lib-ld.m4 +++ b/lib/gl/m4/lib-ld.m4 @@ -1,4 +1,4 @@ -# lib-ld.m4 serial 4 (gettext-0.18) +# lib-ld.m4 serial 5 (gettext-0.18.2) dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -31,15 +31,14 @@ AC_REQUIRE([AC_CANONICAL_HOST])dnl # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } fi ac_prog=ld if test "$GCC" = yes; then diff --git a/lib/gl/m4/lib-link.m4 b/lib/gl/m4/lib-link.m4 index c73bd8e3a4..2ea9d6d073 100644 --- a/lib/gl/m4/lib-link.m4 +++ b/lib/gl/m4/lib-link.m4 @@ -1,4 +1,4 @@ -# lib-link.m4 serial 21 (gettext-0.18) +# lib-link.m4 serial 25 (gettext-0.18.2) dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,9 +18,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" @@ -58,9 +58,9 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. @@ -85,7 +85,8 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; *) LIBS="$LIB[]NAME $LIBS" ;; esac - AC_TRY_LINK([$3], [$4], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[$3]], [[$4]])], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) LIBS="$ac_save_LIBS" @@ -157,15 +158,15 @@ dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar dnl macro call that searches for libname. AC_DEFUN([AC_LIB_FROMPACKAGE], [ - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_frompackage_]NAME, [$2]) popdef([NAME]) pushdef([PACK],[$2]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) popdef([PACKUP]) popdef([PACK]) ]) @@ -178,14 +179,14 @@ dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ @@ -242,7 +243,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then diff --git a/lib/gl/m4/lock.m4 b/lib/gl/m4/lock.m4 index 9da8465ebf..f71c66459e 100644 --- a/lib/gl/m4/lock.m4 +++ b/lib/gl/m4/lock.m4 @@ -1,4 +1,4 @@ -# lock.m4 serial 10 (gettext-0.18) +# lock.m4 serial 11 (gettext-0.18.2) dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,13 +18,17 @@ AC_DEFUN([gl_LOCK], [], [#include <pthread.h>]) # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. - AC_TRY_COMPILE([#include <pthread.h>], - [#if __FreeBSD__ == 4 + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM( + [[#include <pthread.h>]], + [[ +#if __FreeBSD__ == 4 error "No, in FreeBSD 4.0 recursive mutexes actually don't work." #else int x = (int)PTHREAD_MUTEX_RECURSIVE; return !x; -#endif], +#endif + ]])], [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])]) fi diff --git a/lib/gl/m4/lseek.m4 b/lib/gl/m4/lseek.m4 index 9bf4dc2d04..b0612c7e17 100644 --- a/lib/gl/m4/lseek.m4 +++ b/lib/gl/m4/lseek.m4 @@ -1,4 +1,4 @@ -# lseek.m4 serial 5 +# lseek.m4 serial 6 dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,15 +10,13 @@ AC_DEFUN([gl_FUNC_LSEEK], 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([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> /* for off_t */ #include <stdio.h> /* for SEEK_CUR */ -#include <unistd.h> -int main () -{ +#include <unistd.h>]], [[ /* 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 \ && test 1 = "`echo hi \ @@ -29,11 +27,11 @@ int main () fi], [gl_cv_func_lseek_pipe=no]) else - AC_COMPILE_IFELSE([ + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) || defined __BEOS__ /* mingw and BeOS mistakenly return 0 when trying to seek on pipes. */ Choke me. -#endif], +#endif]])], [gl_cv_func_lseek_pipe=yes], [gl_cv_func_lseek_pipe=no]) fi]) if test $gl_cv_func_lseek_pipe = no; then diff --git a/lib/gl/m4/malloc.m4 b/lib/gl/m4/malloc.m4 index 910ac92292..7a749254a1 100644 --- a/lib/gl/m4/malloc.m4 +++ b/lib/gl/m4/malloc.m4 @@ -1,25 +1,40 @@ -# malloc.m4 serial 9 +# malloc.m4 serial 12 dnl Copyright (C) 2007, 2009, 2010 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_GNU +# ------------------ +# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if +# it is not. +AC_DEFUN([gl_FUNC_MALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. + _AC_FUNC_MALLOC_IF( + [AC_DEFINE([HAVE_MALLOC_GNU], [1], + [Define to 1 if your system has a GNU libc compatible 'malloc' + function, and to 0 otherwise.])], + [AC_DEFINE([HAVE_MALLOC_GNU], [0]) + gl_REPLACE_MALLOC + ]) +]) + # 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_STDLIB_H_DEFAULTS]) 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 + gl_REPLACE_MALLOC fi - AC_SUBST([HAVE_MALLOC_POSIX]) ]) # Test whether malloc, realloc, calloc are POSIX compliant, @@ -32,10 +47,20 @@ AC_DEFUN([gl_CHECK_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]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[]], + [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + choke me + #endif + ]])], + [gl_cv_func_malloc_posix=yes], + [gl_cv_func_malloc_posix=no]) ]) ]) + +AC_DEFUN([gl_REPLACE_MALLOC], +[ + AC_LIBOBJ([malloc]) + REPLACE_MALLOC=1 +]) diff --git a/lib/gl/m4/memchr.m4 b/lib/gl/m4/memchr.m4 index ab773b8129..b05a79a026 100644 --- a/lib/gl/m4/memchr.m4 +++ b/lib/gl/m4/memchr.m4 @@ -1,4 +1,4 @@ -# memchr.m4 serial 8 +# memchr.m4 serial 9 dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -62,6 +62,8 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], strcpy (fence - 9, "12345678"); if (memchr (fence - 9, 0, 79) != fence - 1) return 2; + if (memchr (fence - 1, 0, 3) != fence - 1) + return 3; } return 0; ]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], diff --git a/lib/gl/m4/memmem.m4 b/lib/gl/m4/memmem.m4 index c6506ee5c8..553a81cedd 100644 --- a/lib/gl/m4/memmem.m4 +++ b/lib/gl/m4/memmem.m4 @@ -1,4 +1,4 @@ -# memmem.m4 serial 14 +# memmem.m4 serial 16 dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009, 2010 Free Software dnl Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -16,6 +16,45 @@ AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], AC_CHECK_DECLS_ONCE([memmem]) if test $ac_cv_have_decl_memmem = no; then HAVE_DECL_MEMMEM=0 + else + dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. + AC_CACHE_CHECK([whether memmem works], + [gl_cv_func_memmem_works_always], + [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include <string.h> /* for memmem */ +#define P "_EF_BF_BD" +#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P +#define NEEDLE P P P P P +]], [[return !!memmem (HAYSTACK, strlen (HAYSTACK), NEEDLE, strlen (NEEDLE)); + ]])], + [gl_cv_func_memmem_works_always=yes], + [gl_cv_func_memmem_works_always=no], + [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. Assume that it + dnl works on all other platforms, even if it is not linear. + AC_EGREP_CPP([Lucky user], + [ +#ifdef __GNU_LIBRARY__ + #include <features.h> + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2) + Lucky user + #endif +#elif defined __CYGWIN__ + #include <cygwin/version.h> + #if CYGWIN_VERSION_DLL_MAJOR >= 1007 && CYGWIN_VERSION_DLL_MINOR > 7 + Lucky user + #endif +#else + Lucky user +#endif + ], + [gl_cv_func_memmem_works_always=yes], + [gl_cv_func_memmem_works_always="guessing no"]) + ]) + ]) + if test "$gl_cv_func_memmem_works_always" != yes; then + REPLACE_MEMMEM=1 + AC_LIBOBJ([memmem]) + fi fi gl_PREREQ_MEMMEM ]) # gl_FUNC_MEMMEM_SIMPLE @@ -24,21 +63,22 @@ dnl Additionally, check that memmem is efficient and handles empty needles. AC_DEFUN([gl_FUNC_MEMMEM], [ AC_REQUIRE([gl_FUNC_MEMMEM_SIMPLE]) - if test $ac_cv_have_decl_memmem = yes; then + if test $HAVE_MEMMEM = 1 && test $REPLACE_MEMMEM = 0; then AC_CACHE_CHECK([whether memmem works in linear time], - [gl_cv_func_memmem_works], + [gl_cv_func_memmem_works_fast], [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <signal.h> /* for signal */ #include <string.h> /* for memmem */ #include <stdlib.h> /* for malloc */ #include <unistd.h> /* for alarm */ +static void quit (int sig) { exit (sig + 128); } ]], [[size_t m = 1000000; char *haystack = (char *) malloc (2 * m + 1); char *needle = (char *) malloc (m + 1); void *result = 0; /* Failure to compile this test due to missing alarm is okay, since all such platforms (mingw) also lack memmem. */ - signal (SIGALRM, SIG_DFL); + signal (SIGALRM, quit); alarm (5); /* Check for quadratic performance. */ if (haystack && needle) @@ -51,29 +91,29 @@ AC_DEFUN([gl_FUNC_MEMMEM], } /* Check for empty needle behavior. */ return !result || !memmem ("a", 1, 0, 0);]])], - [gl_cv_func_memmem_works=yes], [gl_cv_func_memmem_works=no], - [dnl Only glibc >= 2.9 and cygwin >= 1.7.0 are known to have a - dnl memmem that works in linear time. + [gl_cv_func_memmem_works_fast=yes], [gl_cv_func_memmem_works_fast=no], + [dnl Only glibc > 2.12 and cygwin > 1.7.7 are known to have a + dnl bug-free memmem that works in linear time. AC_EGREP_CPP([Lucky user], [ #include <features.h> #ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2) + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2) Lucky user #endif #endif #ifdef __CYGWIN__ #include <cygwin/version.h> - #if CYGWIN_VERSION_DLL_MAJOR >= 1007 + #if CYGWIN_VERSION_DLL_MAJOR >= 1007 && CYGWIN_VERSION_DLL_MINOR > 7 Lucky user #endif #endif ], - [gl_cv_func_memmem_works=yes], - [gl_cv_func_memmem_works="guessing no"]) + [gl_cv_func_memmem_works_fast=yes], + [gl_cv_func_memmem_works_fast="guessing no"]) ]) ]) - if test "$gl_cv_func_memmem_works" != yes; then + if test "$gl_cv_func_memmem_works_fast" != yes; then REPLACE_MEMMEM=1 AC_LIBOBJ([memmem]) fi diff --git a/lib/gl/m4/minmax.m4 b/lib/gl/m4/minmax.m4 index d9e9cecfd7..a5c42dea0f 100644 --- a/lib/gl/m4/minmax.m4 +++ b/lib/gl/m4/minmax.m4 @@ -1,10 +1,10 @@ -# minmax.m4 serial 3 -dnl Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc. +# minmax.m4 serial 4 +dnl Copyright (C) 2005, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -AC_PREREQ([2.52]) +AC_PREREQ([2.53]) AC_DEFUN([gl_MINMAX], [ @@ -28,8 +28,11 @@ AC_DEFUN([gl_MINMAX_IN_HEADER], m4_pushdef([HEADER], AS_TR_CPP([$1])) AC_CACHE_CHECK([whether <$1> defines MIN and MAX], [gl_cv_minmax_in_]header, - [AC_TRY_COMPILE([#include <$1> -int x = MIN (42, 17);], [], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <$1> + int x = MIN (42, 17);]], + [[]])], [gl_cv_minmax_in_]header[=yes], [gl_cv_minmax_in_]header[=no])]) if test $gl_cv_minmax_in_[]header = yes; then diff --git a/lib/gl/m4/printf-posix.m4 b/lib/gl/m4/printf-posix.m4 index 1eacf95ac8..2dc52a4862 100644 --- a/lib/gl/m4/printf-posix.m4 +++ b/lib/gl/m4/printf-posix.m4 @@ -1,4 +1,4 @@ -# printf-posix.m4 serial 5 (gettext-0.18) +# printf-posix.m4 serial 6 (gettext-0.18.2) dnl Copyright (C) 2003, 2007, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -14,7 +14,8 @@ AC_DEFUN([gt_PRINTF_POSIX], AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], gt_cv_func_printf_posix, [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> /* The string "%2$d %1$d", with dollar characters protected from the shell's @@ -25,16 +26,18 @@ int main () { sprintf (buf, format, 33, 55); return (strcmp (buf, "55 33") != 0); -}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, - [ - AC_EGREP_CPP([notposix], [ +}]])], + [gt_cv_func_printf_posix=yes], + [gt_cv_func_printf_posix=no], + [ + AC_EGREP_CPP([notposix], [ #if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ notposix #endif - ], - [gt_cv_func_printf_posix="guessing no"], - [gt_cv_func_printf_posix="guessing yes"]) - ]) + ], + [gt_cv_func_printf_posix="guessing no"], + [gt_cv_func_printf_posix="guessing yes"]) + ]) ]) case $gt_cv_func_printf_posix in *yes) diff --git a/lib/gl/m4/printf.m4 b/lib/gl/m4/printf.m4 index ebca5364c4..e850862c01 100644 --- a/lib/gl/m4/printf.m4 +++ b/lib/gl/m4/printf.m4 @@ -1,4 +1,4 @@ -# printf.m4 serial 33 +# printf.m4 serial 35 dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,8 @@ AC_DEFUN([gl_PRINTF_SIZES_C99], AC_CACHE_CHECK([whether printf supports size specifiers as in C99], [gl_cv_func_printf_sizes_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stddef.h> #include <stdio.h> #include <string.h> @@ -50,34 +51,36 @@ int main () || strcmp (buf, "1.5 33") != 0) return 1; return 0; -}], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no], - [ +}]])], + [gl_cv_func_printf_sizes_c99=yes], + [gl_cv_func_printf_sizes_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; - darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_printf_sizes_c99="guessing no";; - openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; - solaris*) gl_cv_func_printf_sizes_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_sizes_c99="guessing no";; - netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_sizes_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; + darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_printf_sizes_c99="guessing no";; + openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; + solaris*) gl_cv_func_printf_sizes_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_sizes_c99="guessing no";; + netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_sizes_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -92,7 +95,8 @@ AC_DEFUN([gl_PRINTF_LONG_DOUBLE], AC_CACHE_CHECK([whether printf supports 'long double' arguments], [gl_cv_func_printf_long_double], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[10000]; @@ -111,16 +115,18 @@ int main () || strcmp (buf, "1.75 33") != 0) return 1; return 0; -}], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no], - [ +}]])], + [gl_cv_func_printf_long_double=yes], + [gl_cv_func_printf_long_double=no], + [ changequote(,)dnl - case "$host_os" in - beos*) gl_cv_func_printf_long_double="guessing no";; - mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; - *) gl_cv_func_printf_long_double="guessing yes";; - esac + case "$host_os" in + beos*) gl_cv_func_printf_long_double="guessing no";; + mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; + *) gl_cv_func_printf_long_double="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -136,7 +142,8 @@ AC_DEFUN([gl_PRINTF_INFINITE], AC_CACHE_CHECK([whether printf supports infinite 'double' arguments], [gl_cv_func_printf_infinite], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static int @@ -201,32 +208,34 @@ int main () || strcmp (buf, "-0") != 0) return 1; return 0; -}], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no], - [ +}]])], + [gl_cv_func_printf_infinite=yes], + [gl_cv_func_printf_infinite=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; - darwin*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; - hpux*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_infinite="guessing no";; - netbsd*) gl_cv_func_printf_infinite="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_infinite="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_infinite="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; + darwin*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; + hpux*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite="guessing no";; + netbsd*) gl_cv_func_printf_infinite="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_infinite="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_infinite="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -252,7 +261,8 @@ AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE], AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], [gl_cv_func_printf_infinite_long_double], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ ]GL_NOCRASH[ #include <float.h> #include <stdio.h> @@ -414,38 +424,38 @@ int main () } #endif return 0; -}], - [gl_cv_func_printf_infinite_long_double=yes], - [gl_cv_func_printf_infinite_long_double=no], - [ +}]])], + [gl_cv_func_printf_infinite_long_double=yes], + [gl_cv_func_printf_infinite_long_double=no], + [ changequote(,)dnl - case "$host_cpu" in - # Guess no on ia64, x86_64, i386. - ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; - *) - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; - darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; - hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_infinite_long_double="guessing no";; - netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_infinite_long_double="guessing no";; - esac - ;; - esac + case "$host_cpu" in + # Guess no on ia64, x86_64, i386. + ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; + *) + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; + darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; + hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_printf_infinite_long_double="guessing no";; + netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_infinite_long_double="guessing no";; + esac + ;; + esac changequote([,])dnl - ]) + ]) ]) ;; *) @@ -466,7 +476,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_A], AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], [gl_cv_func_printf_directive_a], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -512,26 +523,28 @@ int main () && strcmp (buf, "0x8.0p-2") != 0)) return 1; return 0; -}], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no], - [ - case "$host_os" in - # Guess yes on glibc >= 2.5 systems. - *-gnu*) - AC_EGREP_CPP([BZ2908], [ - #include <features.h> - #ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2) - BZ2908 - #endif - #endif - ], - [gl_cv_func_printf_directive_a="guessing yes"], - [gl_cv_func_printf_directive_a="guessing no"]) - ;; - # If we don't know, assume the worst. - *) gl_cv_func_printf_directive_a="guessing no";; - esac - ]) +}]])], + [gl_cv_func_printf_directive_a=yes], + [gl_cv_func_printf_directive_a=no], + [ + case "$host_os" in + # Guess yes on glibc >= 2.5 systems. + *-gnu*) + AC_EGREP_CPP([BZ2908], [ + #include <features.h> + #ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2) + BZ2908 + #endif + #endif + ], + [gl_cv_func_printf_directive_a="guessing yes"], + [gl_cv_func_printf_directive_a="guessing no"]) + ;; + # If we don't know, assume the worst. + *) gl_cv_func_printf_directive_a="guessing no";; + esac + ]) ]) ]) @@ -546,7 +559,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_F], AC_CACHE_CHECK([whether printf supports the 'F' directive], [gl_cv_func_printf_directive_f], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -563,26 +577,28 @@ int main () || strcmp (buf, "1234") != 0) return 1; return 0; -}], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no], - [ +}]])], + [gl_cv_func_printf_directive_f=yes], + [gl_cv_func_printf_directive_f=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on FreeBSD >= 6. - freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; - darwin*) gl_cv_func_printf_directive_f="guessing yes";; - # Guess yes on Solaris >= 2.10. - solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";; - solaris*) gl_cv_func_printf_directive_f="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_directive_f="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on FreeBSD >= 6. + freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; + darwin*) gl_cv_func_printf_directive_f="guessing yes";; + # Guess yes on Solaris >= 2.10. + solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";; + solaris*) gl_cv_func_printf_directive_f="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_directive_f="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -597,7 +613,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N], AC_CACHE_CHECK([whether printf supports the 'n' directive], [gl_cv_func_printf_directive_n], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char fmtstring[10]; @@ -614,14 +631,16 @@ int main () || count != 4) return 1; return 0; -}], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], - [ +}]])], + [gl_cv_func_printf_directive_n=yes], + [gl_cv_func_printf_directive_n=no], + [ changequote(,)dnl - case "$host_os" in - *) gl_cv_func_printf_directive_n="guessing yes";; - esac + case "$host_os" in + *) gl_cv_func_printf_directive_n="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -639,7 +658,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS], AC_CACHE_CHECK([whether printf supports the 'ls' directive], [gl_cv_func_printf_directive_ls], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ /* 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 @@ -687,19 +707,21 @@ int main () return 1; } return 0; -}], [gl_cv_func_printf_directive_ls=yes], [gl_cv_func_printf_directive_ls=no], - [ +}]])], + [gl_cv_func_printf_directive_ls=yes], + [gl_cv_func_printf_directive_ls=no], + [ changequote(,)dnl - case "$host_os" in - openbsd*) gl_cv_func_printf_directive_ls="guessing no";; - irix*) gl_cv_func_printf_directive_ls="guessing no";; - solaris*) gl_cv_func_printf_directive_ls="guessing no";; - cygwin*) gl_cv_func_printf_directive_ls="guessing no";; - beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; - *) gl_cv_func_printf_directive_ls="guessing yes";; - esac + case "$host_os" in + openbsd*) gl_cv_func_printf_directive_ls="guessing no";; + irix*) gl_cv_func_printf_directive_ls="guessing no";; + solaris*) gl_cv_func_printf_directive_ls="guessing no";; + cygwin*) gl_cv_func_printf_directive_ls="guessing no";; + beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; + *) gl_cv_func_printf_directive_ls="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -714,7 +736,8 @@ AC_DEFUN([gl_PRINTF_POSITIONS], AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], [gl_cv_func_printf_positions], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> /* The string "%2$d %1$d", with dollar characters protected from the shell's @@ -725,18 +748,20 @@ int main () { sprintf (buf, format, 33, 55); return (strcmp (buf, "55 33") != 0); -}], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no], - [ +}]])], + [gl_cv_func_printf_positions=yes], + [gl_cv_func_printf_positions=no], + [ changequote(,)dnl - case "$host_os" in - netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) - gl_cv_func_printf_positions="guessing no";; - beos*) gl_cv_func_printf_positions="guessing no";; - mingw* | pw*) gl_cv_func_printf_positions="guessing no";; - *) gl_cv_func_printf_positions="guessing yes";; - esac + case "$host_os" in + netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) + gl_cv_func_printf_positions="guessing no";; + beos*) gl_cv_func_printf_positions="guessing no";; + mingw* | pw*) gl_cv_func_printf_positions="guessing no";; + *) gl_cv_func_printf_positions="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -751,7 +776,8 @@ AC_DEFUN([gl_PRINTF_FLAG_GROUPING], AC_CACHE_CHECK([whether printf supports the grouping flag], [gl_cv_func_printf_flag_grouping], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -761,17 +787,19 @@ int main () || buf[strlen (buf) - 1] != '9') return 1; return 0; -}], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no], - [ +}]])], + [gl_cv_func_printf_flag_grouping=yes], + [gl_cv_func_printf_flag_grouping=no], + [ changequote(,)dnl - case "$host_os" in - cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; - netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; - mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; - *) gl_cv_func_printf_flag_grouping="guessing yes";; - esac + case "$host_os" in + cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; + netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; + mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; + *) gl_cv_func_printf_flag_grouping="guessing yes";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -787,7 +815,8 @@ AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST], AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], [gl_cv_func_printf_flag_leftadjust], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -798,7 +827,7 @@ int main () || strcmp (buf, "ab c") != 0) return 1; return 0; -}], +}]])], [gl_cv_func_printf_flag_leftadjust=yes], [gl_cv_func_printf_flag_leftadjust=no], [ @@ -828,7 +857,8 @@ AC_DEFUN([gl_PRINTF_FLAG_ZERO], AC_CACHE_CHECK([whether printf supports the zero flag correctly], [gl_cv_func_printf_flag_zero], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -839,19 +869,21 @@ int main () && strcmp (buf, " infinity") != 0)) return 1; return 0; -}], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no], - [ +}]])], + [gl_cv_func_printf_flag_zero=yes], + [gl_cv_func_printf_flag_zero=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_printf_flag_zero="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_printf_flag_zero="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_printf_flag_zero="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_printf_flag_zero="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -868,7 +900,8 @@ AC_DEFUN([gl_PRINTF_PRECISION], AC_CACHE_CHECK([whether printf supports large precisions], [gl_cv_func_printf_precision], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[5000]; @@ -881,17 +914,19 @@ int main () if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) return 1; return 0; -}], [gl_cv_func_printf_precision=yes], [gl_cv_func_printf_precision=no], - [ +}]])], + [gl_cv_func_printf_precision=yes], + [gl_cv_func_printf_precision=no], + [ changequote(,)dnl - case "$host_os" in - # Guess no only on native Win32 and BeOS systems. - mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; - beos*) gl_cv_func_printf_precision="guessing no" ;; - *) gl_cv_func_printf_precision="guessing yes" ;; - esac + case "$host_os" in + # Guess no only on native Win32 and BeOS systems. + mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; + beos*) gl_cv_func_printf_precision="guessing no" ;; + *) gl_cv_func_printf_precision="guessing yes" ;; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1031,7 +1066,8 @@ AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99], AC_CACHE_CHECK([whether snprintf truncates the result as in C99], [gl_cv_func_snprintf_truncation_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -1042,47 +1078,49 @@ int main () if (memcmp (buf, "45\0DEF", 6) != 0) return 1; return 0; -}], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no], - [ +}]])], + [gl_cv_func_snprintf_truncation_c99=yes], + [gl_cv_func_snprintf_truncation_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; - darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on HP-UX >= 11. - hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; - hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on OSF/1 >= 5. - osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; - osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_truncation_c99="guessing no";; - netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_truncation_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; + darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on HP-UX >= 11. + hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; + hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on OSF/1 >= 5. + osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; + osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_truncation_c99="guessing no";; + netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_snprintf_truncation_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1101,14 +1139,15 @@ dnl } dnl --------------------------------------------------------------------- dnl Result is gl_cv_func_snprintf_retval_c99. -AC_DEFUN([gl_SNPRINTF_RETVAL_C99], +AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99], [ AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], [gl_cv_func_snprintf_retval_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char buf[100]; @@ -1118,39 +1157,41 @@ int main () if (snprintf (buf, 3, "%d %d", 4567, 89) != 7) return 1; return 0; -}], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no], - [ +}]])], + [gl_cv_func_snprintf_retval_c99=yes], + [gl_cv_func_snprintf_retval_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; - darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on OpenBSD >= 3.9. - openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) - gl_cv_func_snprintf_retval_c99="guessing no";; - openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";; - solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; - aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_retval_c99="guessing no";; - netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_retval_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; + darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on OpenBSD >= 3.9. + openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) + gl_cv_func_snprintf_retval_c99="guessing no";; + openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";; + solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; + aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_retval_c99="guessing no";; + netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_snprintf_retval_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1165,7 +1206,8 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N], AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], [gl_cv_func_snprintf_directive_n], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #include <string.h> static char fmtstring[10]; @@ -1181,40 +1223,42 @@ int main () if (count != 6) return 1; return 0; -}], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no], - [ +}]])], + [gl_cv_func_snprintf_directive_n=yes], + [gl_cv_func_snprintf_directive_n=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; - darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";; - solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; - aix*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on OSF/1 >= 5. - osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; - osf*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_snprintf_directive_n="guessing no";; - netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_snprintf_directive_n="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_snprintf_directive_n="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; + darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";; + solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; + aix*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on OSF/1 >= 5. + osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; + osf*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_snprintf_directive_n="guessing no";; + netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_snprintf_directive_n="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_snprintf_directive_n="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1229,17 +1273,18 @@ AC_DEFUN([gl_SNPRINTF_SIZE1], AC_CACHE_CHECK([whether snprintf respects a size of 1], [gl_cv_func_snprintf_size1], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> int main() { static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; snprintf (buf, 1, "%d", 12345); return buf[1] != 'E'; -}], - [gl_cv_func_snprintf_size1=yes], - [gl_cv_func_snprintf_size1=no], - [gl_cv_func_snprintf_size1="guessing yes"]) +}]])], + [gl_cv_func_snprintf_size1=yes], + [gl_cv_func_snprintf_size1=no], + [gl_cv_func_snprintf_size1="guessing yes"]) ]) ]) @@ -1286,7 +1331,8 @@ AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99], AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], [gl_cv_func_vsnprintf_zerosize_c99], [ - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdarg.h> #include <stdio.h> static int my_snprintf (char *buf, int size, const char *format, ...) @@ -1303,43 +1349,43 @@ int main() static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; my_snprintf (buf, 0, "%d", 12345); return buf[0] != 'D'; -}], - [gl_cv_func_vsnprintf_zerosize_c99=yes], - [gl_cv_func_vsnprintf_zerosize_c99=no], - [ +}]])], + [gl_cv_func_vsnprintf_zerosize_c99=yes], + [gl_cv_func_vsnprintf_zerosize_c99=no], + [ changequote(,)dnl - case "$host_os" in - # Guess yes on glibc systems. - *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on FreeBSD >= 5. - freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Cygwin. - cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on Solaris >= 2.6. - solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on AIX >= 4. - aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on IRIX >= 6.5. - irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on BeOS. - beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # Guess yes on mingw. - mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; - # If we don't know, assume the worst. - *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; - esac + case "$host_os" in + # Guess yes on glibc systems. + *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on FreeBSD >= 5. + freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on MacOS X >= 10.3. + darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Cygwin. + cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on Solaris >= 2.6. + solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on AIX >= 4. + aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on IRIX >= 6.5. + irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on NetBSD >= 3. + netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) + gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on BeOS. + beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # Guess yes on mingw. + mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; + # If we don't know, assume the worst. + *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; + esac changequote([,])dnl - ]) + ]) ]) ]) @@ -1401,7 +1447,7 @@ dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . dnl Solaris 10 . . # # # . . # . . . # . . . . . . . . dnl Solaris 2.6 ... 9 # . # # # # . # . . . # . . . . . . . . dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # -dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . +dnl AIX 5.2, 7.1 . . # # # . . . . . . # . . . . . . . . dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . . . . . dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # diff --git a/lib/gl/m4/progtest.m4 b/lib/gl/m4/progtest.m4 index 2d804ac99d..9ffa5c0202 100644 --- a/lib/gl/m4/progtest.m4 +++ b/lib/gl/m4/progtest.m4 @@ -1,4 +1,4 @@ -# progtest.m4 serial 6 (gettext-0.18) +# progtest.m4 serial 7 (gettext-0.18.2) dnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -27,15 +27,14 @@ AC_DEFUN([AM_PATH_PROG_WITH_TEST], # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } fi # Find out how to test for executable files. Don't use a zero-byte file, diff --git a/lib/gl/m4/realloc.m4 b/lib/gl/m4/realloc.m4 index dc30235c17..01c1234f7e 100644 --- a/lib/gl/m4/realloc.m4 +++ b/lib/gl/m4/realloc.m4 @@ -1,23 +1,44 @@ -# realloc.m4 serial 9 +# realloc.m4 serial 11 dnl Copyright (C) 2007, 2009, 2010 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_GNU +# ------------------- +# Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace +# realloc if it is not. +AC_DEFUN([gl_FUNC_REALLOC_GNU], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + dnl _AC_FUNC_REALLOC_IF is defined in Autoconf. + _AC_FUNC_REALLOC_IF( + [AC_DEFINE([HAVE_REALLOC_GNU], [1], + [Define to 1 if your system has a GNU libc compatible 'realloc' + function, and to 0 otherwise.])], + [AC_DEFINE([HAVE_REALLOC_GNU], [0]) + gl_REPLACE_REALLOC + ]) +])# gl_FUNC_REALLOC_GNU + # 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_STDLIB_H_DEFAULTS]) 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 + gl_REPLACE_REALLOC fi - AC_SUBST([HAVE_REALLOC_POSIX]) +]) + +AC_DEFUN([gl_REPLACE_REALLOC], +[ + AC_LIBOBJ([realloc]) + REPLACE_REALLOC=1 ]) diff --git a/lib/gl/m4/size_max.m4 b/lib/gl/m4/size_max.m4 index ce992db1f1..f3b1a9dfb2 100644 --- a/lib/gl/m4/size_max.m4 +++ b/lib/gl/m4/size_max.m4 @@ -1,4 +1,4 @@ -# size_max.m4 serial 9 +# size_max.m4 serial 10 dnl Copyright (C) 2003, 2005-2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,10 +34,14 @@ Found it if test $fits_in_uint = 1; then dnl Even though SIZE_MAX fits in an unsigned int, it must be of type dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. - AC_TRY_COMPILE([#include <stddef.h> - extern size_t foo; - extern unsigned long foo; - ], [], [fits_in_uint=0]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stddef.h> + extern size_t foo; + extern unsigned long foo; + ]], + [[]])], + [fits_in_uint=0]) fi dnl We cannot use 'expr' to simplify this expression, because 'expr' dnl works only with 'long' integers in the host environment, while we diff --git a/lib/gl/m4/socketlib.m4 b/lib/gl/m4/socketlib.m4 new file mode 100644 index 0000000000..7bf02b5aee --- /dev/null +++ b/lib/gl/m4/socketlib.m4 @@ -0,0 +1,86 @@ +# socketlib.m4 serial 1 +dnl Copyright (C) 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl gl_SOCKETLIB +dnl Determines the library to use for socket functions. +dnl Sets and AC_SUBSTs LIBSOCKET. + +AC_DEFUN([gl_SOCKETLIB], +[ + gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H + LIBSOCKET= + if test $HAVE_WINSOCK2_H = 1; then + dnl Native Windows API (not Cygwin). + AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], + [gl_cv_func_wsastartup], [ + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lws2_32" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#ifdef HAVE_WINSOCK2_H +# include <winsock2.h> +#endif]], [[ + WORD wVersionRequested = MAKEWORD(1, 1); + WSADATA wsaData; + int err = WSAStartup(wVersionRequested, &wsaData); + WSACleanup ();]])], + gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) + LIBS="$gl_save_LIBS" + ]) + if test "$gl_cv_func_wsastartup" = "yes"; then + AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) + LIBSOCKET='-lws2_32' + fi + else + dnl Unix API. + dnl Solaris has most socket functions in libsocket. + dnl Haiku has most socket functions in libnetwork. + dnl BeOS has most socket functions in libnet. + AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ + gl_cv_lib_socket= + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [], + [gl_save_LIBS="$LIBS" + LIBS="$gl_save_LIBS -lsocket" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lsocket"]) + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnetwork" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lnetwork"]) + if test -z "$gl_cv_lib_socket"; then + LIBS="$gl_save_LIBS -lnet" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern +#ifdef __cplusplus +"C" +#endif +char setsockopt();]], [[setsockopt();]])], + [gl_cv_lib_socket="-lnet"]) + fi + fi + LIBS="$gl_save_LIBS" + ]) + if test -z "$gl_cv_lib_socket"; then + gl_cv_lib_socket="none needed" + fi + ]) + if test "$gl_cv_lib_socket" != "none needed"; then + LIBSOCKET="$gl_cv_lib_socket" + fi + fi + AC_SUBST([LIBSOCKET]) +]) diff --git a/lib/gl/m4/sockets.m4 b/lib/gl/m4/sockets.m4 index aefb936079..ba9a563d8e 100644 --- a/lib/gl/m4/sockets.m4 +++ b/lib/gl/m4/sockets.m4 @@ -1,4 +1,4 @@ -# sockets.m4 serial 6 +# sockets.m4 serial 7 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,80 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_SOCKETS], [ AC_REQUIRE([AC_C_INLINE]) - - gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H - LIBSOCKET= - if test $HAVE_WINSOCK2_H = 1; then - dnl Native Windows API (not Cygwin). - AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32], - [gl_cv_func_wsastartup], [ - gl_save_LIBS="$LIBS" - LIBS="$LIBS -lws2_32" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ -#ifdef HAVE_WINSOCK2_H -# include <winsock2.h> -#endif]], [[ - WORD wVersionRequested = MAKEWORD(1, 1); - WSADATA wsaData; - int err = WSAStartup(wVersionRequested, &wsaData); - WSACleanup ();]])], - gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no) - LIBS="$gl_save_LIBS" - ]) - if test "$gl_cv_func_wsastartup" = "yes"; then - AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.]) - LIBSOCKET='-lws2_32' - fi - else - dnl Unix API. - dnl Solaris has most socket functions in libsocket. - dnl Haiku has most socket functions in libnetwork. - dnl BeOS has most socket functions in libnet. - AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [ - gl_cv_lib_socket= - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [], - [gl_save_LIBS="$LIBS" - LIBS="$gl_save_LIBS -lsocket" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [gl_cv_lib_socket="-lsocket"]) - if test -z "$gl_cv_lib_socket"; then - LIBS="$gl_save_LIBS -lnetwork" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [gl_cv_lib_socket="-lnetwork"]) - if test -z "$gl_cv_lib_socket"; then - LIBS="$gl_save_LIBS -lnet" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern -#ifdef __cplusplus -"C" -#endif -char setsockopt();]], [[setsockopt();]])], - [gl_cv_lib_socket="-lnet"]) - fi - fi - LIBS="$gl_save_LIBS" - ]) - if test -z "$gl_cv_lib_socket"; then - gl_cv_lib_socket="none needed" - fi - ]) - if test "$gl_cv_lib_socket" != "none needed"; then - LIBSOCKET="$gl_cv_lib_socket" - fi - fi - AC_SUBST([LIBSOCKET]) + AC_REQUIRE([gl_SOCKETLIB]) gl_PREREQ_SOCKETS ]) diff --git a/lib/gl/m4/socklen.m4 b/lib/gl/m4/socklen.m4 index 2933d4b890..d0d6baab55 100644 --- a/lib/gl/m4/socklen.m4 +++ b/lib/gl/m4/socklen.m4 @@ -1,4 +1,4 @@ -# socklen.m4 serial 7 +# socklen.m4 serial 8 dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,8 +8,9 @@ dnl From Albert Chin, Windows fixes from Simon Josefsson. dnl Check for socklen_t: historically on BSD it is an int, and in dnl POSIX 1g it is a type of its own, but some platforms use different -dnl types for the argument to getsockopt, getpeername, etc. So we -dnl have to test to find something that will work. +dnl types for the argument to getsockopt, getpeername, etc.: +dnl HP-UX 10.20, IRIX 6.5, Interix 3.5, BeOS. +dnl So we have to test to find something that will work. dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find dnl it there first. That file is included by gnulib's sys_socket.in.h, which diff --git a/lib/gl/m4/sockpfaf.m4 b/lib/gl/m4/sockpfaf.m4 index 8a0c236038..8806705ae2 100644 --- a/lib/gl/m4/sockpfaf.m4 +++ b/lib/gl/m4/sockpfaf.m4 @@ -47,6 +47,9 @@ AC_DEFUN([gl_SOCKET_FAMILIES], #endif #ifdef HAVE_WINSOCK2_H #include <winsock2.h> +#endif +#ifdef HAVE_WS2TCPIP_H +#include <ws2tcpip.h> #endif]], [[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; if (&x && &y && &z) return 0;]])], diff --git a/lib/gl/m4/stdbool.m4 b/lib/gl/m4/stdbool.m4 index 3d672d7476..1efe59ea1c 100644 --- a/lib/gl/m4/stdbool.m4 +++ b/lib/gl/m4/stdbool.m4 @@ -5,6 +5,8 @@ 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. +#serial 3 + # Prepare for substituting <stdbool.h> if it is not supported. AC_DEFUN([AM_STDBOOL_H], @@ -31,82 +33,68 @@ AC_DEFUN([AM_STDBOOL_H], # AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) -# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf -# have this macro built-in. +# This version of the macro is needed in autoconf <= 2.67. Autoconf has +# it built in since 2.60, but we want the tweaks from the 2.68 version +# to avoid rejecting xlc and clang due to relying on extensions. AC_DEFUN([AC_HEADER_STDBOOL], [AC_CACHE_CHECK([for stdbool.h that conforms to C99], [ac_cv_header_stdbool_h], - [AC_TRY_COMPILE( - [ - #include <stdbool.h> - #ifndef bool - "error: bool is not defined" - #endif - #ifndef false - "error: false is not defined" - #endif - #if false - "error: false is not 0" - #endif - #ifndef true - "error: true is not defined" - #endif - #if true != 1 - "error: true is not 1" - #endif - #ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" - #endif + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ + #include <stdbool.h> + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif - struct s { _Bool s: 1; _Bool t; } s; + struct s { _Bool s: 1; _Bool t; } s; - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - bool e = &s; - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; - #if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a run-time - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); - #endif - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - ], - [ - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - ], + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + ]], + [[ + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + ]])], [ac_cv_header_stdbool_h=yes], [ac_cv_header_stdbool_h=no])]) AC_CHECK_TYPES([_Bool]) diff --git a/lib/gl/m4/stdint.m4 b/lib/gl/m4/stdint.m4 index 1cc57e6e96..c5e813a96d 100644 --- a/lib/gl/m4/stdint.m4 +++ b/lib/gl/m4/stdint.m4 @@ -1,4 +1,4 @@ -# stdint.m4 serial 34 +# stdint.m4 serial 35 dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -309,7 +309,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], dnl config.h.in, dnl - extra AC_SUBST calls, so that the right substitutions are made. m4_foreach_w([gltype], [$1], - [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), [Define to the number of bits in type ']gltype['.])]) for gltype in $1 ; do AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], @@ -334,7 +334,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF], eval BITSIZEOF_${GLTYPE}=\$result done m4_foreach_w([gltype], [$1], - [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) + [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) ]) dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) @@ -347,7 +347,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], dnl config.h.in, dnl - extra AC_SUBST calls, so that the right substitutions are made. m4_foreach_w([gltype], [$1], - [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), + [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), [Define to 1 if ']gltype[' is a signed integer type.])]) for gltype in $1 ; do AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], @@ -367,7 +367,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED], fi done m4_foreach_w([gltype], [$1], - [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) + [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) ]) dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) @@ -380,7 +380,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], dnl config.h.in, dnl - extra AC_SUBST calls, so that the right substitutions are made. m4_foreach_w([gltype], [$1], - [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], + [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], [Define to l, ll, u, ul, ull, etc., as suitable for constants of type ']gltype['.])]) for gltype in $1 ; do @@ -419,7 +419,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) done m4_foreach_w([gltype], [$1], - [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) + [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) ]) dnl gl_STDINT_INCLUDES diff --git a/lib/gl/m4/stdint_h.m4 b/lib/gl/m4/stdint_h.m4 index b8e3c6cc71..670c0cc2bf 100644 --- a/lib/gl/m4/stdint_h.m4 +++ b/lib/gl/m4/stdint_h.m4 @@ -1,4 +1,4 @@ -# stdint_h.m4 serial 8 +# stdint_h.m4 serial 9 dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,12 +12,13 @@ dnl From Paul Eggert. AC_DEFUN([gl_AC_HEADER_STDINT_H], [ AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], - [AC_TRY_COMPILE( - [#include <sys/types.h> -#include <stdint.h>], - [uintmax_t i = (uintmax_t) -1; return !i;], - [gl_cv_header_stdint_h=yes], - [gl_cv_header_stdint_h=no])]) + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <sys/types.h> + #include <stdint.h>]], + [[uintmax_t i = (uintmax_t) -1; return !i;]])], + [gl_cv_header_stdint_h=yes], + [gl_cv_header_stdint_h=no])]) if test $gl_cv_header_stdint_h = yes; then AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], [Define if <stdint.h> exists, doesn't clash with <sys/types.h>, diff --git a/lib/gl/m4/stdlib_h.m4 b/lib/gl/m4/stdlib_h.m4 index dd84796d2c..e4697ce213 100644 --- a/lib/gl/m4/stdlib_h.m4 +++ b/lib/gl/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 28 +# stdlib_h.m4 serial 31 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,7 +33,7 @@ AC_DEFUN([gl_STDLIB_H], #if HAVE_RANDOM_H # include <random.h> #endif - ]], [atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp + ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt unsetenv]) @@ -50,6 +50,7 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], AC_DEFUN([gl_STDLIB_H_DEFAULTS], [ + GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT]) GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) @@ -72,16 +73,16 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD]) GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL]) GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL]) + GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX]) GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) dnl Assume proper GNU behavior unless another module says otherwise. + HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) - HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX]) HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) - HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX]) HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) @@ -89,7 +90,6 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) - HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX]) HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) @@ -100,9 +100,12 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) + REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) + REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) + REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) diff --git a/lib/gl/m4/threadlib.m4 b/lib/gl/m4/threadlib.m4 index 05cc4ffab9..423c17c768 100644 --- a/lib/gl/m4/threadlib.m4 +++ b/lib/gl/m4/threadlib.m4 @@ -1,4 +1,4 @@ -# threadlib.m4 serial 5 (gettext-0.18) +# threadlib.m4 serial 8 (gettext-0.18.2) dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,6 +9,11 @@ dnl From Bruno Haible. dnl gl_THREADLIB dnl ------------ dnl Tests for a multithreading library to be used. +dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO +dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the +dnl default is 'no', otherwise it is system dependent. In both cases, the user +dnl can change the choice through the options --enable-threads=choice or +dnl --disable-threads. dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, dnl USE_PTH_THREADS, USE_WIN32_THREADS dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use @@ -44,10 +49,12 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY], [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], [AC_REQUIRE([AC_GNU_SOURCE])]) dnl Check for multithreading. - m4_divert_text([DEFAULTS], [gl_use_threads_default=]) + m4_ifdef([gl_THREADLIB_DEFAULT_NO], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])], + [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) AC_ARG_ENABLE([threads], -AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) -AC_HELP_STRING([--disable-threads], [build without multithread safety]), +AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AC_HELP_STRING([--disable-threads], [build without multithread safety])]), [gl_use_threads=$enableval], [if test -n "$gl_use_threads_default"; then gl_use_threads="$gl_use_threads_default" @@ -80,7 +87,7 @@ changequote([,])dnl # groks <pthread.h>. cc also understands the flag -pthread, but # we don't use it because 1. gcc-2.95 doesn't understand -pthread, # 2. putting a flag into CPPFLAGS that has an effect on the linker - # causes the AC_TRY_LINK test below to succeed unexpectedly, + # causes the AC_LINK_IFELSE test below to succeed unexpectedly, # leading to wrong values of LIBTHREAD and LTLIBTHREAD. CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; @@ -111,18 +118,25 @@ AC_DEFUN([gl_THREADLIB_BODY], [gl_cv_have_weak], [gl_cv_have_weak=no dnl First, test whether the compiler accepts it syntactically. - AC_TRY_LINK([extern void xyzzy (); -#pragma weak xyzzy], [xyzzy();], [gl_cv_have_weak=maybe]) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[extern void xyzzy (); +#pragma weak xyzzy]], + [[xyzzy();]])], + [gl_cv_have_weak=maybe]) if test $gl_cv_have_weak = maybe; then dnl Second, test whether it actually works. On Cygwin 1.7.2, with dnl gcc 4.3, symbols declared weak always evaluate to the address 0. - AC_TRY_RUN([ + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ #include <stdio.h> #pragma weak fputs int main () { return (fputs == NULL); -}], [gl_cv_have_weak=yes], [gl_cv_have_weak=no], +}]])], + [gl_cv_have_weak=yes], + [gl_cv_have_weak=no], [dnl When cross-compiling, assume that only ELF platforms support dnl weak symbols. AC_EGREP_CPP([Extensible Linking Format], @@ -148,9 +162,11 @@ int main () # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist # in libc. IRIX 6.5 has the first one in both libc and libpthread, but # the second one only in libpthread, and lock.c needs it. - AC_TRY_LINK([#include <pthread.h>], - [pthread_mutex_lock((pthread_mutex_t*)0); - pthread_mutexattr_init((pthread_mutexattr_t*)0);], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include <pthread.h>]], + [[pthread_mutex_lock((pthread_mutex_t*)0); + pthread_mutexattr_init((pthread_mutexattr_t*)0);]])], [gl_have_pthread=yes]) # Test for libpthread by looking for pthread_kill. (Not pthread_self, # since it is defined as a macro on OSF/1.) @@ -203,9 +219,13 @@ int main () gl_have_solaristhread= gl_save_LIBS="$LIBS" LIBS="$LIBS -lthread" - AC_TRY_LINK([#include <thread.h> -#include <synch.h>], - [thr_self();], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[ +#include <thread.h> +#include <synch.h> + ]], + [[thr_self();]])], [gl_have_solaristhread=yes]) LIBS="$gl_save_LIBS" if test -n "$gl_have_solaristhread"; then @@ -230,8 +250,10 @@ int main () AC_LIB_LINKFLAGS([pth]) gl_have_pth= gl_save_LIBS="$LIBS" - LIBS="$LIBS -lpth" - AC_TRY_LINK([#include <pth.h>], [pth_self();], [gl_have_pth=yes]) + LIBS="$LIBS $LIBPTH" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])], + [gl_have_pth=yes]) LIBS="$gl_save_LIBS" if test -n "$gl_have_pth"; then gl_threads_api=pth diff --git a/lib/gl/m4/time_h.m4 b/lib/gl/m4/time_h.m4 index b88ba94da1..a45a10a9ee 100644 --- a/lib/gl/m4/time_h.m4 +++ b/lib/gl/m4/time_h.m4 @@ -2,6 +2,8 @@ # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. +# serial 2 + # 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. @@ -24,7 +26,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY], ]) dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared -dnl in time.h or sys/time.h. +dnl in time.h, sys/time.h, or pthread.h. AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], [ @@ -41,6 +43,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], TIME_H_DEFINES_STRUCT_TIMESPEC=0 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then TIME_H_DEFINES_STRUCT_TIMESPEC=1 else @@ -55,10 +58,24 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 + else + AC_CACHE_CHECK([for struct timespec in <pthread.h>], + [gl_cv_sys_struct_timespec_in_pthread_h], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <pthread.h> + ]], + [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], + [gl_cv_sys_struct_timespec_in_pthread_h=yes], + [gl_cv_sys_struct_timespec_in_pthread_h=no])]) + if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 + fi fi fi AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) + AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) ]) AC_DEFUN([gl_TIME_MODULE_INDICATOR], diff --git a/lib/gl/m4/visibility.m4 b/lib/gl/m4/visibility.m4 index 077c4765ec..19cd8f3d3e 100644 --- a/lib/gl/m4/visibility.m4 +++ b/lib/gl/m4/visibility.m4 @@ -1,5 +1,5 @@ -# visibility.m4 serial 3 (gettext-0.18) -dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. +# visibility.m4 serial 4 (gettext-0.18.2) +dnl Copyright (C) 2005, 2008, 2010 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. @@ -33,7 +33,8 @@ AC_DEFUN([gl_VISIBILITY], AC_CACHE_VAL([gl_cv_cc_vis_werror], [ gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -Werror" - AC_TRY_COMPILE([], [], + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], [gl_cv_cc_vis_werror=yes], [gl_cv_cc_vis_werror=no]) CFLAGS="$gl_save_CFLAGS"]) @@ -51,13 +52,15 @@ AC_DEFUN([gl_VISIBILITY], if test $gl_cv_cc_vis_werror = yes; then CFLAGS="$CFLAGS -Werror" fi - AC_TRY_COMPILE( - [extern __attribute__((__visibility__("hidden"))) int hiddenvar; - extern __attribute__((__visibility__("default"))) int exportedvar; - extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void); - void dummyfunc (void) {}], - [], + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void) {} + ]], + [[]])], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) CFLAGS="$gl_save_CFLAGS"]) diff --git a/lib/gl/m4/wchar_t.m4 b/lib/gl/m4/wchar_t.m4 index ed804e664b..a133e6ad58 100644 --- a/lib/gl/m4/wchar_t.m4 +++ b/lib/gl/m4/wchar_t.m4 @@ -1,4 +1,4 @@ -# wchar_t.m4 serial 3 (gettext-0.18) +# wchar_t.m4 serial 4 (gettext-0.18.2) dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,9 +11,13 @@ dnl Prerequisite: AC_PROG_CC AC_DEFUN([gt_TYPE_WCHAR_T], [ AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_TRY_COMPILE([#include <stddef.h> - wchar_t foo = (wchar_t)'\0';], , - [gt_cv_c_wchar_t=yes], [gt_cv_c_wchar_t=no])]) + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include <stddef.h> + wchar_t foo = (wchar_t)'\0';]], + [[]])], + [gt_cv_c_wchar_t=yes], + [gt_cv_c_wchar_t=no])]) if test $gt_cv_c_wchar_t = yes; then AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) fi diff --git a/lib/gl/m4/wint_t.m4 b/lib/gl/m4/wint_t.m4 index a6c7d15cb5..58ef865565 100644 --- a/lib/gl/m4/wint_t.m4 +++ b/lib/gl/m4/wint_t.m4 @@ -1,4 +1,4 @@ -# wint_t.m4 serial 4 (gettext-0.18) +# wint_t.m4 serial 5 (gettext-0.18.2) dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -11,7 +11,9 @@ 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([ + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[ /* 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 @@ -20,8 +22,10 @@ AC_DEFUN([gt_TYPE_WINT_T], #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])]) + 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 diff --git a/lib/gl/malloc.c b/lib/gl/malloc.c new file mode 100644 index 0000000000..02ca9f7c84 --- /dev/null +++ b/lib/gl/malloc.c @@ -0,0 +1,60 @@ +/* malloc() function that is glibc compatible. + + Copyright (C) 1997-1998, 2006-2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser 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 Jim Meyering and Bruno Haible */ + +#include <config.h> +/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ +#ifdef malloc +# define NEED_MALLOC_GNU 1 +# undef malloc +/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ +#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU +# define NEED_MALLOC_GNU 1 +#endif + +/* Specification. */ +#include <stdlib.h> + +#include <errno.h> + +/* Call the system's malloc below. */ +#undef malloc + +/* Allocate an N-byte block of memory from the heap. + If N is zero, allocate a 1-byte block. */ + +void * +rpl_malloc (size_t n) +{ + void *result; + +#if NEED_MALLOC_GNU + if (n == 0) + n = 1; +#endif + + result = malloc (n); + +#if !HAVE_MALLOC_POSIX + if (result == NULL) + errno = ENOMEM; +#endif + + return result; +} diff --git a/lib/gl/netdb.in.h b/lib/gl/netdb.in.h index 343fff9ce1..4f6fef31f1 100644 --- a/lib/gl/netdb.in.h +++ b/lib/gl/netdb.in.h @@ -25,6 +25,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if @HAVE_NETDB_H@ diff --git a/lib/gl/read-file.c b/lib/gl/read-file.c index 3d27d7193c..38b26e47c8 100644 --- a/lib/gl/read-file.c +++ b/lib/gl/read-file.c @@ -20,7 +20,16 @@ #include "read-file.h" -/* Get realloc, free. */ +/* Get fstat. */ +#include <sys/stat.h> + +/* Get ftello. */ +#include <stdio.h> + +/* Get SIZE_MAX. */ +#include <stdint.h> + +/* Get malloc, realloc, free. */ #include <stdlib.h> /* Get errno. */ @@ -36,50 +45,99 @@ fread_file (FILE * stream, size_t * length) { char *buf = NULL; size_t alloc = 0; - size_t size = 0; - int save_errno; - - for (;;) - { - size_t count; - size_t requested; - - if (size + BUFSIZ + 1 > alloc) - { - char *new_buf; - - alloc += alloc / 2; - if (alloc < size + BUFSIZ + 1) - alloc = size + BUFSIZ + 1; - new_buf = realloc (buf, alloc); - if (!new_buf) - { - save_errno = errno; + /* For a regular file, allocate a buffer that has exactly the right + size. This avoids the need to do dynamic reallocations later. */ + { + struct stat st; + + if (fstat (fileno (stream), &st) >= 0 && S_ISREG (st.st_mode)) + { + off_t pos = ftello (stream); + + if (pos >= 0 && pos < st.st_size) + { + off_t alloc_off = st.st_size - pos; + + if (SIZE_MAX <= alloc_off) + { + errno = ENOMEM; + return NULL; + } + + alloc = alloc_off + 1; + + buf = malloc (alloc); + if (!buf) + /* errno is ENOMEM. */ + return NULL; + } + } + } + + { + size_t size = 0; /* number of bytes read so far */ + int save_errno; + + for (;;) + { + size_t count; + size_t requested; + + if (size + BUFSIZ + 1 > alloc) + { + char *new_buf; + size_t new_alloc = alloc + alloc / 2; + + /* Check against overflow. */ + if (new_alloc < alloc) + { + save_errno = ENOMEM; + break; + } + + alloc = new_alloc; + if (alloc < size + BUFSIZ + 1) + alloc = size + BUFSIZ + 1; + + new_buf = realloc (buf, alloc); + if (!new_buf) + { + save_errno = errno; + break; + } + + buf = new_buf; + } + + requested = alloc - size - 1; + count = fread (buf + size, 1, requested, stream); + size += count; + + if (count != requested) + { + save_errno = errno; + if (ferror (stream)) break; - } - buf = new_buf; - } - - requested = alloc - size - 1; - count = fread (buf + size, 1, requested, stream); - size += count; - - if (count != requested) - { - save_errno = errno; - if (ferror (stream)) - break; - buf[size] = '\0'; - *length = size; - return buf; - } - } - - free (buf); - errno = save_errno; - return NULL; + /* Shrink the allocated memory if possible. */ + if (size + 1 < alloc) + { + char *smaller_buf = realloc (buf, size + 1); + if (smaller_buf != NULL) + buf = smaller_buf; + } + + buf[size] = '\0'; + *length = size; + return buf; + } + } + + free (buf); + errno = save_errno; + return NULL; + } } static char * diff --git a/lib/gl/realloc.c b/lib/gl/realloc.c index f67e79d36a..2201385a6f 100644 --- a/lib/gl/realloc.c +++ b/lib/gl/realloc.c @@ -23,11 +23,14 @@ /* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ #ifdef realloc # define NEED_REALLOC_GNU 1 +/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ +#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU +# 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 + The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ +#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU # define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 #endif diff --git a/lib/gl/stddef.in.h b/lib/gl/stddef.in.h index c8900d5fee..4f25aeeb08 100644 --- a/lib/gl/stddef.in.h +++ b/lib/gl/stddef.in.h @@ -26,6 +26,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_wchar_t || defined __need_size_t \ || defined __need_ptrdiff_t || defined __need_NULL \ diff --git a/lib/gl/stdint.in.h b/lib/gl/stdint.in.h index 3f14433832..1da1635c62 100644 --- a/lib/gl/stdint.in.h +++ b/lib/gl/stdint.in.h @@ -26,6 +26,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* When including a system file that in turn includes <inttypes.h>, use the system <inttypes.h>, not our substitute. This avoids @@ -475,8 +476,9 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - /* wchar_t limits */ /* Get WCHAR_MIN, WCHAR_MAX. - This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested - includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes + This include is not on the top, above, because on OSF/1 4.0 we have a + sequence of nested includes + <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes <stdint.h> and assumes its types are already defined. */ #if ! (defined WCHAR_MIN && defined WCHAR_MAX) # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H diff --git a/lib/gl/stdio.in.h b/lib/gl/stdio.in.h index fcca1b3626..3f34727e0b 100644 --- a/lib/gl/stdio.in.h +++ b/lib/gl/stdio.in.h @@ -19,6 +19,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_FILE || defined __need___FILE /* Special invocation convention inside glibc header files. */ @@ -265,7 +266,8 @@ _GL_CXXALIASWARN (freopen); #elif defined GNULIB_POSIXCHECK # undef freopen /* Assume freopen is always declared. */ -_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - " +_GL_WARN_ON_USE (freopen, + "freopen on Win32 platforms is not POSIX compatible - " "use gnulib module freopen for portability"); #endif @@ -661,7 +663,7 @@ _GL_FUNCDECL_RPL (printf, int, (const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1))); -_GL_CXXALIAS_RPL (printf, printf, int, (const char *format, ...)); +_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); # endif # define GNULIB_overrides_printf 1 # else diff --git a/lib/gl/stdlib.in.h b/lib/gl/stdlib.in.h index 89af73265b..bc43725d12 100644 --- a/lib/gl/stdlib.in.h +++ b/lib/gl/stdlib.in.h @@ -18,6 +18,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_malloc_and_calloc /* Special invocation convention inside glibc header files. */ @@ -38,6 +39,11 @@ /* NetBSD 5.0 mis-defines NULL. */ #include <stddef.h> +/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */ +#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS +# include <sys/wait.h> +#endif + /* Solaris declares getloadavg() in <sys/loadavg.h>. */ #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ # include <sys/loadavg.h> @@ -74,6 +80,12 @@ struct random_data # include <unistd.h> #endif +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(Spec) /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ @@ -95,6 +107,23 @@ struct random_data #endif +#if @GNULIB__EXIT@ +/* Terminate the current process with the given return code, without running + the 'atexit' handlers. */ +# if !@HAVE__EXIT@ +_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); +# endif +_GL_CXXALIAS_SYS (_Exit, void, (int status)); +_GL_CXXALIASWARN (_Exit); +#elif defined GNULIB_POSIXCHECK +# undef _Exit +# if HAVE_RAW_DECL__EXIT +_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " + "use gnulib module _Exit for portability"); +# endif +#endif + + #if @GNULIB_ATOLL@ /* Parse a signed decimal integer. Returns the value of the integer. Errors are not detected. */ @@ -112,7 +141,7 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - " #endif #if @GNULIB_CALLOC_POSIX@ -# if !@HAVE_CALLOC_POSIX@ +# if @REPLACE_CALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef calloc # define calloc rpl_calloc @@ -149,7 +178,8 @@ _GL_CXXALIASWARN (canonicalize_file_name); #elif defined GNULIB_POSIXCHECK # undef canonicalize_file_name # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME -_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " +_GL_WARN_ON_USE (canonicalize_file_name, + "canonicalize_file_name is unportable - " "use gnulib module canonicalize-lgpl for portability"); # endif #endif @@ -218,7 +248,7 @@ _GL_WARN_ON_USE (ptsname, "grantpt is not portable - " #endif #if @GNULIB_MALLOC_POSIX@ -# if !@HAVE_MALLOC_POSIX@ +# if @REPLACE_MALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef malloc # define malloc rpl_malloc @@ -477,7 +507,7 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " #if @GNULIB_REALLOC_POSIX@ -# if !@HAVE_REALLOC_POSIX@ +# if @REPLACE_REALLOC@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef realloc # define realloc rpl_realloc @@ -652,7 +682,7 @@ _GL_CXXALIASWARN (unlockpt); #elif defined GNULIB_POSIXCHECK # undef unlockpt # if HAVE_RAW_DECL_UNLOCKPT -_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - " +_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " "use gnulib module unlockpt for portability"); # endif #endif diff --git a/lib/gl/str-two-way.h b/lib/gl/str-two-way.h index fa6eba04bc..830edc6734 100644 --- a/lib/gl/str-two-way.h +++ b/lib/gl/str-two-way.h @@ -95,26 +95,37 @@ A critical factorization has the property that the local period equals the global period. All strings have at least one critical factorization with the left half smaller than the global period. + And while some strings have more than one critical factorization, + it is provable that with an ordered alphabet, at least one of the + critical factorizations corresponds to a maximal suffix. Given an ordered alphabet, a critical factorization can be computed in linear time, with 2 * NEEDLE_LEN comparisons, by computing the - larger of two ordered maximal suffixes. The ordered maximal - suffixes are determined by lexicographic comparison of + shorter of two ordered maximal suffixes. The ordered maximal + suffixes are determined by lexicographic comparison while tracking periodicity. */ static size_t critical_factorization (const unsigned char *needle, size_t needle_len, size_t *period) { - /* Index of last byte of left half, or SIZE_MAX. */ + /* Index of last byte of left half. */ size_t max_suffix, max_suffix_rev; size_t j; /* Index into NEEDLE for current candidate suffix. */ size_t k; /* Offset into current period. */ size_t p; /* Intermediate period. */ unsigned char a, b; /* Current comparison bytes. */ + /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered + out 0-length needles. */ + if (needle_len < 3) + { + *period = 1; + return needle_len - 1; + } + /* Invariants: - 0 <= j < NEEDLE_LEN - 1 - -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) + 1 <= j < NEEDLE_LEN - 1 + 0 <= max_suffix{,_rev} < j min(max_suffix, max_suffix_rev) < global period of NEEDLE 1 <= p <= global period of NEEDLE p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] @@ -122,9 +133,8 @@ critical_factorization (const unsigned char *needle, size_t needle_len, */ /* Perform lexicographic search. */ - max_suffix = SIZE_MAX; - j = 0; - k = p = 1; + max_suffix = 0; + j = k = p = 1; while (j + k < needle_len) { a = CANON_ELEMENT (needle[j + k]); @@ -157,9 +167,8 @@ critical_factorization (const unsigned char *needle, size_t needle_len, *period = p; /* Perform reverse lexicographic search. */ - max_suffix_rev = SIZE_MAX; - j = 0; - k = p = 1; + max_suffix_rev = 0; + j = k = p = 1; while (j + k < needle_len) { a = CANON_ELEMENT (needle[j + k]); @@ -190,8 +199,20 @@ critical_factorization (const unsigned char *needle, size_t needle_len, } } - /* Choose the longer suffix. Return the first byte of the right - half, rather than the last byte of the left half. */ + /* Choose the shorter suffix. Return the index of the first byte of + the right half, rather than the last byte of the left half. + + For some examples, 'banana' has two critical factorizations, both + exposed by the two lexicographic extreme suffixes of 'anana' and + 'nana', where both suffixes have a period of 2. On the other + hand, with 'aab' and 'bba', both strings have a single critical + factorization of the last byte, with the suffix having a period + of 1. While the maximal lexicographic suffix of 'aab' is 'b', + the maximal lexicographic suffix of 'bba' is 'ba', which is not a + critical factorization. Conversely, the maximal reverse + lexicographic suffix of 'a' works for 'bba', but not 'ab' for + 'aab'. The shorter suffix of the two will always be a critical + factorization. */ if (max_suffix_rev + 1 < max_suffix + 1) return max_suffix + 1; *period = p; @@ -226,9 +247,9 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, first. */ if (CMP_FUNC (needle, needle + period, suffix) == 0) { - /* Entire needle is periodic; a mismatch can only advance by the - period, so use memory to avoid rescanning known occurrences - of the period. */ + /* Entire needle is periodic; a mismatch in the left half can + only advance by the period, so use memory to avoid rescanning + known occurrences of the period in the right half. */ size_t memory = 0; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) @@ -330,9 +351,9 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, first. */ if (CMP_FUNC (needle, needle + period, suffix) == 0) { - /* Entire needle is periodic; a mismatch can only advance by the - period, so use memory to avoid rescanning known occurrences - of the period. */ + /* Entire needle is periodic; a mismatch in the left half can + only advance by the period, so use memory to avoid rescanning + known occurrences of the period in the right half. */ size_t memory = 0; size_t shift; j = 0; @@ -349,8 +370,8 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, a byte out of place, there can be no match until after the mismatch. */ shift = needle_len - period; - memory = 0; } + memory = 0; j += shift; continue; } diff --git a/lib/gl/string.in.h b/lib/gl/string.in.h index 2ebe17f590..6c94178924 100644 --- a/lib/gl/string.in.h +++ b/lib/gl/string.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STRING_H@ @@ -41,12 +42,20 @@ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) # define __attribute__(Spec) /* empty */ # endif +#endif /* The attribute __pure__ was added in gcc 2.96. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96) -# define __pure__ /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ #endif +/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ +/* But avoid namespace pollution on glibc systems. */ +#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) \ + && ! defined __GLIBC__ +# include <unistd.h> +#endif /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ @@ -62,13 +71,13 @@ # define memchr rpl_memchr # endif _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else # if ! @HAVE_MEMCHR@ _GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -102,7 +111,8 @@ _GL_WARN_ON_USE (memchr, "memchr has platform-specific bugs - " _GL_FUNCDECL_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); _GL_CXXALIAS_RPL (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len)); @@ -111,7 +121,8 @@ _GL_CXXALIAS_RPL (memmem, void *, _GL_FUNCDECL_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, void const *__needle, size_t __needle_len) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 3))); # endif _GL_CXXALIAS_SYS (memmem, void *, (void const *__haystack, size_t __haystack_len, @@ -152,7 +163,7 @@ _GL_WARN_ON_USE (mempcpy, "mempcpy is unportable - " #if @GNULIB_MEMRCHR@ # if ! @HAVE_DECL_MEMRCHR@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -182,7 +193,7 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - " #if @GNULIB_RAWMEMCHR@ # if ! @HAVE_RAWMEMCHR@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -229,6 +240,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " #if @GNULIB_STPNCPY@ # if @REPLACE_STPNCPY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef stpncpy # define stpncpy rpl_stpncpy # endif _GL_FUNCDECL_RPL (stpncpy, char *, @@ -272,7 +284,7 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings " #if @GNULIB_STRCHRNUL@ # if ! @HAVE_STRCHRNUL@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif /* On some systems, this function is defined as an overloaded function: @@ -306,6 +318,10 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); # else +# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup + /* strdup exists as a function and as a macro. Get rid of the macro. */ +# undef strdup +# endif # if !(@HAVE_DECL_STRDUP@ || defined strdup) _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); # endif @@ -378,13 +394,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " # define strnlen rpl_strnlen # endif _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); # else # if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1))); # endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); @@ -414,7 +430,7 @@ _GL_WARN_ON_USE (strcspn, "strcspn cannot work correctly on character strings " #if @GNULIB_STRPBRK@ # if ! @HAVE_STRPBRK@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: @@ -514,7 +530,7 @@ _GL_WARN_ON_USE (strsep, "strsep is unportable - " # define strstr rpl_strstr # endif _GL_FUNCDECL_RPL (strstr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) + _GL_ATTRIBUTE_PURE _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strstr, char *, (const char *haystack, const char *needle)); # else @@ -556,14 +572,16 @@ _GL_WARN_ON_USE (strstr, "strstr is quadratic on many systems, and cannot " # endif _GL_FUNCDECL_RPL (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (strcasestr, char *, (const char *haystack, const char *needle)); # else # if ! @HAVE_STRCASESTR@ _GL_FUNCDECL_SYS (strcasestr, char *, (const char *haystack, const char *needle) - __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2))); + _GL_ATTRIBUTE_PURE + _GL_ARG_NONNULL ((1, 2))); # endif /* On some systems, this function is defined as an overloaded function: extern "C++" { const char * strcasestr (const char *, const char *); } @@ -764,11 +782,10 @@ _GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) #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! + ignoring case. If the two match, return a pointer to the first byte + after this prefix in STRING. Otherwise, return NULL. + Note: This function may, in multibyte locales, return non-NULL if STRING + is of smaller length than PREFIX! Unlike strncasecmp(), this function works correctly in multibyte locales. */ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) diff --git a/lib/gl/strings.in.h b/lib/gl/strings.in.h index 4eff2f04f0..fb1f19014d 100644 --- a/lib/gl/strings.in.h +++ b/lib/gl/strings.in.h @@ -21,6 +21,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* The include_next requires a split double-inclusion guard. */ #@INCLUDE_NEXT@ @NEXT_STRINGS_H@ diff --git a/lib/gl/sys_socket.in.h b/lib/gl/sys_socket.in.h index b63b0c4f22..6bed6cc4f1 100644 --- a/lib/gl/sys_socket.in.h +++ b/lib/gl/sys_socket.in.h @@ -26,6 +26,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H /* Special invocation convention: @@ -122,8 +123,8 @@ struct sockaddr_storage adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your code may not run on older Windows releases then. My Windows 2000 box was not able to run the code, for example. The situation is - slightly confusing because: - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp + slightly confusing because + <http://msdn.microsoft.com/en-us/library/ms738520> suggests that getaddrinfo should be available on all Windows releases. */ diff --git a/lib/gl/sys_stat.in.h b/lib/gl/sys_stat.in.h index 80b9c47ddf..4203a5899f 100644 --- a/lib/gl/sys_stat.in.h +++ b/lib/gl/sys_stat.in.h @@ -24,6 +24,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_system_sys_stat_h /* Special invocation convention. */ @@ -594,7 +595,8 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - " # else /* !_LARGE_FILES */ # define stat(name, st) rpl_stat (name, st) # endif /* !_LARGE_FILES */ -_GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2)); +_GL_EXTERN_C int stat (const char *name, struct stat *buf) + _GL_ARG_NONNULL ((1, 2)); # endif #elif defined GNULIB_POSIXCHECK # undef stat diff --git a/lib/gl/tests/Makefile.am b/lib/gl/tests/Makefile.am index 4d792a4b08..928377522f 100644 --- a/lib/gl/tests/Makefile.am +++ b/lib/gl/tests/Makefile.am @@ -79,6 +79,21 @@ EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h ## end gnulib module arg-nonnull +## begin gnulib module binary-io + +libtests_a_SOURCES += binary-io.h + +## end gnulib module binary-io + +## begin gnulib module binary-io-tests + +TESTS += test-binary-io.sh +check_PROGRAMS += test-binary-io + +EXTRA_DIST += test-binary-io.sh test-binary-io.c macros.h + +## end gnulib module binary-io-tests + ## begin gnulib module byteswap-tests TESTS += test-byteswap @@ -137,6 +152,15 @@ EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh signature.h macros.h ## end gnulib module fseeko-tests +## begin gnulib module ftello-tests + +TESTS += test-ftello.sh test-ftello2.sh test-ftello3 +check_PROGRAMS += test-ftello test-ftello3 +MOSTLYCLEANFILES += t-ftello3.tmp +EXTRA_DIST += test-ftello.c test-ftello.sh test-ftello2.sh test-ftello3.c signature.h macros.h + +## end gnulib module ftello-tests + ## begin gnulib module func-tests TESTS += test-func @@ -145,6 +169,15 @@ EXTRA_DIST += test-func.c macros.h ## end gnulib module func-tests +## begin gnulib module getpagesize + + +EXTRA_DIST += getpagesize.c + +EXTRA_libtests_a_SOURCES += getpagesize.c + +## end gnulib module getpagesize + ## begin gnulib module intprops @@ -230,7 +263,7 @@ EXTRA_DIST += test-stdio.c TESTS += test-stdlib check_PROGRAMS += test-stdlib -EXTRA_DIST += test-stdlib.c +EXTRA_DIST += test-stdlib.c test-sys_wait.h ## end gnulib module stdlib-tests diff --git a/lib/gl/tests/binary-io.h b/lib/gl/tests/binary-io.h new file mode 100644 index 0000000000..5451fd48f4 --- /dev/null +++ b/lib/gl/tests/binary-io.h @@ -0,0 +1,66 @@ +/* Binary mode I/O. + Copyright (C) 2001, 2003, 2005, 2008, 2009, 2010 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 _BINARY_H +#define _BINARY_H + +/* For systems that distinguish between text and binary I/O. + O_BINARY is usually declared in <fcntl.h>. */ +#include <fcntl.h> + +/* The MSVC7 <stdio.h> doesn't like to be included after '#define fileno ...', + so we include it here first. */ +#include <stdio.h> + +#if !defined O_BINARY && defined _O_BINARY + /* For MSC-compatible compilers. */ +# define O_BINARY _O_BINARY +# define O_TEXT _O_TEXT +#endif +#if defined __BEOS__ || defined __HAIKU__ + /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ +# undef O_BINARY +# undef O_TEXT +#endif + +/* SET_BINARY (fd); + changes the file descriptor fd to perform binary I/O. */ +#if O_BINARY +# if defined __EMX__ || defined __DJGPP__ || defined __CYGWIN__ +# include <io.h> /* declares setmode() */ +# else +# define setmode _setmode +# undef fileno +# define fileno _fileno +# endif +# ifdef __DJGPP__ +# include <unistd.h> /* declares isatty() */ + /* Avoid putting stdin/stdout in binary mode if it is connected to + the console, because that would make it impossible for the user + to interrupt the program through Ctrl-C or Ctrl-Break. */ +# define SET_BINARY(fd) ((void) (!isatty (fd) ? (setmode (fd, O_BINARY), 0) : 0)) +# else +# define SET_BINARY(fd) ((void) setmode (fd, O_BINARY)) +# endif +#else + /* On reasonable systems, binary I/O is the default. */ +# undef O_BINARY +# define O_BINARY 0 +# define SET_BINARY(fd) /* do nothing */ ((void) 0) +#endif + +#endif /* _BINARY_H */ diff --git a/lib/gl/tests/getpagesize.c b/lib/gl/tests/getpagesize.c new file mode 100644 index 0000000000..cc2526870f --- /dev/null +++ b/lib/gl/tests/getpagesize.c @@ -0,0 +1,39 @@ +/* getpagesize emulation for systems where it cannot be done in a C macro. + + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Bruno Haible and Martin Lambers. */ + +#include <config.h> + +/* Specification. */ +#include <unistd.h> + +/* This implementation is only for native Win32 systems. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ + +# define WIN32_LEAN_AND_MEAN +# include <windows.h> + +int +getpagesize (void) +{ + SYSTEM_INFO system_info; + GetSystemInfo (&system_info); + return system_info.dwPageSize; +} + +#endif diff --git a/lib/gl/tests/init.sh b/lib/gl/tests/init.sh index ef0957c1d8..a57de77a2f 100644 --- a/lib/gl/tests/init.sh +++ b/lib/gl/tests/init.sh @@ -57,6 +57,41 @@ # 4. Finally # $ exit +ME_=`expr "./$0" : '.*/\(.*\)$'` + +# We use a trap below for cleanup. This requires us to go through +# hoops to get the right exit status transported through the handler. +# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. +# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 +# sh inside this function. +Exit () { set +e; (exit $1); exit $1; } + +# Print warnings (e.g., about skipped and failed tests) to this file number. +# Override by defining to say, 9, in init.cfg, and putting say, +# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition +# of TESTS_ENVIRONMENT in your tests/Makefile.am file. +# This is useful when using automake's parallel tests mode, to print +# the reason for skip/failure to console, rather than to the .log files. +: ${stderr_fileno_=2} + +warn_() { echo "$@" 1>&$stderr_fileno_; } +fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } +skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } +framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 99; } + +# Sanitize this shell to POSIX mode, if possible. +DUALCASE=1; export DUALCASE +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; + esac +fi + # We require $(...) support unconditionally. # We require a few additional shell features only when $EXEEXT is nonempty, # in order to support automatic $EXEEXT emulation: @@ -68,44 +103,90 @@ # shells until we find one that passes. If one is found, re-exec it. # If no acceptable shell is found, skip the current test. # +# The "...set -x; P=1 true 2>err..." test is to disqualify any shell that +# emits "P=1" into err, as /bin/sh from SunOS 5.11 and OpenBSD 4.7 do. +# # Use "9" to indicate success (rather than 0), in case some shell acts # like Solaris 10's /bin/sh but exits successfully instead of with status 2. +# Eval this code in a subshell to determine a shell's suitability. +# 10 - passes all tests; ok to use +# 9 - ok, but enabling "set -x" corrupts application stderr; prefer higher score +# ? - not ok gl_shell_test_script_=' test $(echo y) = y || exit 1 -test -z "$EXEEXT" && exit 9 +score_=10 +if test "$VERBOSE" = yes; then + test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9 +fi +test -z "$EXEEXT" && exit $score_ shopt -s expand_aliases alias a-b="echo zoo" v=abx test ${v%x} = ab \ && test ${v#a} = bx \ && test $(a-b) = zoo \ - && exit 9 + && exit $score_ ' if test "x$1" = "x--no-reexec"; then shift else - # 'eval'ing the above code makes Solaris 10's /bin/sh exit with $? set to 2. - # It does not evaluate any of the code after the "unexpected" `('. Thus, - # we must run it in a subshell. - ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 - if test $? = 9; then - : # The current shell is adequate. No re-exec required. - else - # Search for a shell that meets our requirements. - for re_shell_ in "${CONFIG_SHELL:-no_shell}" /bin/sh bash dash zsh pdksh fail - do - test "$re_shell_" = no_shell && continue - test "$re_shell_" = fail && skip_ failed to find an adequate shell + # Assume a working shell. Export to subshells (setup_ needs this). + gl_set_x_corrupts_stderr_=false + export gl_set_x_corrupts_stderr_ + + # Record the first marginally acceptable shell. + marginal_= + + # Search for a shell that meets our requirements. + for re_shell_ in __current__ "${CONFIG_SHELL:-no_shell}" \ + /bin/sh bash dash zsh pdksh fail + do + test "$re_shell_" = no_shell && continue + + # If we've made it all the way to the sentinel, "fail" without + # finding even a marginal shell, skip this test. + if test "$re_shell_" = fail; then + test -z "$marginal_" && skip_ failed to find an adequate shell + re_shell_=$marginal_ + break + fi + + # When testing the current shell, simply "eval" the test code. + # Otherwise, run it via $re_shell_ -c ... + if test "$re_shell_" = __current__; then + # 'eval'ing this code makes Solaris 10's /bin/sh exit with + # $? set to 2. It does not evaluate any of the code after the + # "unexpected" first `('. Thus, we must run it in a subshell. + ( eval "$gl_shell_test_script_" ) > /dev/null 2>&1 + else "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null - if test $? = 9; then - # Found an acceptable shell. - exec "$re_shell_" "$0" --no-reexec "$@" - echo "$ME_: exec failed" 1>&2 - exit 127 - fi - done + fi + + st_=$? + + # $re_shell_ works just fine. Use it. + test $st_ = 10 && break + + # If this is our first marginally acceptable shell, remember it. + if test "$st_:$marginal_" = 9: ; then + marginal_="$re_shell_" + gl_set_x_corrupts_stderr_=true + fi + done + + if test "$re_shell_" != __current__; then + # Found a usable shell. Preserve -v and -x. + case $- in + *v*x* | *x*v*) opts_=-vx ;; + *v*) opts_=-v ;; + *x*) opts_=-x ;; + *) opts_= ;; + esac + exec "$re_shell_" $opts_ "$0" --no-reexec "$@" + echo "$ME_: exec failed" 1>&2 + exit 127 fi fi @@ -118,26 +199,6 @@ test -n "$EXEEXT" && shopt -s expand_aliases : ${MALLOC_PERTURB_=87} export MALLOC_PERTURB_ -# We use a trap below for cleanup. This requires us to go through -# hoops to get the right exit status transported through the handler. -# So use `Exit STATUS' instead of `exit STATUS' inside of the tests. -# Turn off errexit here so that we don't trip the bug with OSF1/Tru64 -# sh inside this function. -Exit () { set +e; (exit $1); exit $1; } - -# Print warnings (e.g., about skipped and failed tests) to this file number. -# Override by defining to say, 9, in init.cfg, and putting say, -# "export ...ENVVAR_SETTINGS...; exec 9>&2; $(SHELL)" in the definition -# of TESTS_ENVIRONMENT in your tests/Makefile.am file. -# This is useful when using automake's parallel tests mode, to print -# the reason for skip/failure to console, rather than to the .log files. -: ${stderr_fileno_=2} - -warn_() { echo "$@" 1>&$stderr_fileno_; } -fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } -skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } -framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 1; } - # This is a stub function that is run upon trap (upon regular exit and # interrupt). Override it with a per-test function, e.g., to unmount # a partition, or to undo any other global state changes. @@ -179,6 +240,11 @@ find_exe_basenames_() feb_result_= feb_sp_= for feb_file_ in $feb_dir_/*.exe; do + # If there was no *.exe file, or there existed a file named "*.exe" that + # was deleted between the above glob expansion and the existence test + # below, just skip it. + test "x$feb_file_" = "x$feb_dir_/*.exe" && test ! -f "$feb_file_" \ + && continue case $feb_file_ in *[!-a-zA-Z/0-9_.+]*) feb_fail_=1; break;; *) # Remove leading file name components as well as the .exe suffix. @@ -196,7 +262,7 @@ find_exe_basenames_() # For each file name of the form PROG.exe, create an alias named # PROG that simply invokes PROG.exe, then return 0. If any selected # file name or the directory name, $1, contains an unexpected character, -# define no function and return 1. +# define no alias and return 1. create_exe_shims_() { case $EXEEXT in @@ -244,19 +310,29 @@ path_prepend_() setup_() { - test "$VERBOSE" = yes && set -x + if test "$VERBOSE" = yes; then + # Test whether set -x may cause the selected shell to corrupt an + # application's stderr. Many do, including zsh-4.3.10 and the /bin/sh + # from SunOS 5.11, OpenBSD 4.7 and Irix 5.x and 6.5. + # If enabling verbose output this way would cause trouble, simply + # issue a warning and refrain. + if $gl_set_x_corrupts_stderr_; then + warn_ "using SHELL=$SHELL with 'set -x' corrupts stderr" + else + set -x + fi + fi initial_cwd_=$PWD - ME_=`expr "./$0" : '.*/\(.*\)$'` pfx_=`testdir_prefix_` test_dir_=`mktempd_ "$initial_cwd_" "$pfx_-$ME_.XXXX"` \ || fail_ "failed to create temporary directory in $initial_cwd_" cd "$test_dir_" - # These trap statements ensure that the temporary directory, $test_dir_, - # is removed upon exit as well as upon receipt of any of the listed signals. - trap remove_tmp_ 0 + # This trap statement, along with a trap on 0 below, ensure that the + # temporary directory, $test_dir_, is removed upon exit as well as + # upon receipt of any of the listed signals. for sig_ in 1 2 3 13 15; do eval "trap 'Exit $(expr $sig_ + 128)' $sig_" done @@ -384,3 +460,6 @@ test -f "$srcdir/init.cfg" \ && . "$srcdir/init.cfg" setup_ "$@" +# This trap is here, rather than in the setup_ function, because some +# shells run the exit trap at shell function exit, rather than script exit. +trap remove_tmp_ 0 diff --git a/lib/gl/tests/test-binary-io.c b/lib/gl/tests/test-binary-io.c new file mode 100644 index 0000000000..125150b21f --- /dev/null +++ b/lib/gl/tests/test-binary-io.c @@ -0,0 +1,64 @@ +/* Test of binary mode I/O. + Copyright (C) 2005, 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Bruno Haible <bruno@clisp.org>, 2005. */ + +#include <config.h> + +#include "binary-io.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include "macros.h" + +int +main () +{ + /* Test the O_BINARY macro. */ + { + int fd = + open ("t-bin-out2.tmp", O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0600); + if (write (fd, "Hello\n", 6) < 0) + exit (1); + close (fd); + } + { + struct stat statbuf; + if (stat ("t-bin-out2.tmp", &statbuf) < 0) + exit (1); + ASSERT (statbuf.st_size == 6); + } + unlink ("t-bin-out2.tmp"); + + /* Test the SET_BINARY macro. */ + SET_BINARY (1); + fputs ("Hello\n", stdout); + fclose (stdout); + fclose (stderr); + { + struct stat statbuf; + if (stat ("t-bin-out1.tmp", &statbuf) < 0) + exit (1); + ASSERT (statbuf.st_size == 6); + } + + return 0; +} diff --git a/lib/gl/tests/test-binary-io.sh b/lib/gl/tests/test-binary-io.sh new file mode 100755 index 0000000000..33e128c309 --- /dev/null +++ b/lib/gl/tests/test-binary-io.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles t-bin-out1.tmp t-bin-out2.tmp" +./test-binary-io${EXEEXT} > t-bin-out1.tmp || exit 1 + +rm -fr $tmpfiles + +exit 0 diff --git a/lib/gl/tests/test-ftello.c b/lib/gl/tests/test-ftello.c new file mode 100644 index 0000000000..5fae570f28 --- /dev/null +++ b/lib/gl/tests/test-ftello.c @@ -0,0 +1,118 @@ +/* Test of ftello() function. + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Bruno Haible <bruno@clisp.org>, 2007. */ + +#include <config.h> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include "signature.h" +SIGNATURE_CHECK (ftello, off_t, (FILE *)); + +#include "binary-io.h" +#include "macros.h" + +#ifndef FUNC_UNGETC_BROKEN +# define FUNC_UNGETC_BROKEN 0 +#endif + +int +main (int argc, char **argv _GL_UNUSED) +{ + int ch; + /* Assume stdin is seekable iff argc > 1. */ + if (argc == 1) + { + ASSERT (ftell (stdin) == -1); + ASSERT (ftello (stdin) == -1); + return 0; + } + + /* mingw ftell is unreliable on text mode input. */ + SET_BINARY (0); + + /* Simple tests. For each test, make sure ftell and ftello agree. */ + ASSERT (ftell (stdin) == 0); + ASSERT (ftello (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + ASSERT (ftello (stdin) == 1); + + /* Test ftell after ungetc of read input. */ + ch = ungetc ('#', stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 0); + ASSERT (ftello (stdin) == 0); + + ch = fgetc (stdin); + ASSERT (ch == '#'); + ASSERT (ftell (stdin) == 1); + ASSERT (ftello (stdin) == 1); + + /* Test ftell after fseek. */ + ASSERT (fseek (stdin, 2, SEEK_SET) == 0); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + + /* Test ftell after random ungetc. */ + ch = fgetc (stdin); + ASSERT (ch == '/'); + ch = ungetc ('@', stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + + ch = fgetc (stdin); + ASSERT (ch == '@'); + ASSERT (ftell (stdin) == 3); + ASSERT (ftello (stdin) == 3); + + if (2 < argc) + { + if (FUNC_UNGETC_BROKEN) + { + fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n", + stderr); + return 77; + } + /* Test ftell after ungetc without read. */ + ASSERT (fseek (stdin, 0, SEEK_CUR) == 0); + ASSERT (ftell (stdin) == 3); + ASSERT (ftello (stdin) == 3); + + ch = ungetc ('~', stdin); + ASSERT (ch == '~'); + ASSERT (ftell (stdin) == 2); + ASSERT (ftello (stdin) == 2); + } + +#if !defined __MINT__ /* FreeMiNT has problems seeking past end of file */ + /* Test ftell beyond end of file. */ + ASSERT (fseek (stdin, 0, SEEK_END) == 0); + ch = ftello (stdin); + ASSERT (fseek (stdin, 10, SEEK_END) == 0); + ASSERT (ftell (stdin) == ch + 10); + ASSERT (ftello (stdin) == ch + 10); +#endif + + return 0; +} diff --git a/lib/gl/tests/test-ftello.sh b/lib/gl/tests/test-ftello.sh new file mode 100755 index 0000000000..33d2e838db --- /dev/null +++ b/lib/gl/tests/test-ftello.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test-ftello${EXEEXT} 1 < "$srcdir/test-ftello.sh" || exit 1 +echo hi | ./test-ftello${EXEEXT} || exit 1 +exit 0 diff --git a/lib/gl/tests/test-ftello2.sh b/lib/gl/tests/test-ftello2.sh new file mode 100755 index 0000000000..ba750b003d --- /dev/null +++ b/lib/gl/tests/test-ftello2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ./test-ftello${EXEEXT} 1 2 < "$srcdir/test-ftello2.sh" diff --git a/lib/gl/tests/test-ftello3.c b/lib/gl/tests/test-ftello3.c new file mode 100644 index 0000000000..b07ba64610 --- /dev/null +++ b/lib/gl/tests/test-ftello3.c @@ -0,0 +1,78 @@ +/* Test of ftello() function. + Copyright (C) 2007-2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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> + +/* None of the files accessed by this test are large, so disable the + fseek link warning if we are not using the gnulib fseek module. */ +#define _GL_NO_LARGE_FILES +#include <stdio.h> + +#include <string.h> + +#include "macros.h" + +#define TESTFILE "t-ftello3.tmp" + +int +main (void) +{ + FILE *fp; + + /* Create a file with some contents. */ + fp = fopen (TESTFILE, "w"); + if (fp == NULL) + goto skip; + if (fwrite ("foogarsh", 1, 8, fp) < 8) + goto skip; + if (fclose (fp)) + goto skip; + + /* The file's contents is now "foogarsh". */ + + /* Try writing after reading to EOF. */ + fp = fopen (TESTFILE, "r+"); + if (fp == NULL) + goto skip; + if (fseek (fp, -1, SEEK_END)) + goto skip; + ASSERT (getc (fp) == 'h'); + ASSERT (getc (fp) == EOF); + ASSERT (ftello (fp) == 8); + ASSERT (ftello (fp) == 8); + ASSERT (putc ('!', fp) == '!'); + ASSERT (ftello (fp) == 9); + ASSERT (fclose (fp) == 0); + fp = fopen (TESTFILE, "r"); + if (fp == NULL) + goto skip; + { + char buf[10]; + ASSERT (fread (buf, 1, 10, fp) == 9); + ASSERT (memcmp (buf, "foogarsh!", 9) == 0); + } + ASSERT (fclose (fp) == 0); + + /* The file's contents is now "foogarsh!". */ + + remove (TESTFILE); + return 0; + + skip: + fprintf (stderr, "Skipping test: prerequisite file operations failed.\n"); + remove (TESTFILE); + return 77; +} diff --git a/lib/gl/tests/test-memchr.c b/lib/gl/tests/test-memchr.c index a801614079..05e1bfaed2 100644 --- a/lib/gl/tests/test-memchr.c +++ b/lib/gl/tests/test-memchr.c @@ -57,6 +57,7 @@ main (void) ASSERT (MEMCHR (input + 1, 'a', n - 1) == input + n - 1); ASSERT (MEMCHR (input + 1, 'e', n - 1) == input + n - 2); + ASSERT (MEMCHR (input + 1, 0x789abc00 | 'e', n - 1) == input + n - 2); ASSERT (MEMCHR (input, 'f', n) == NULL); ASSERT (MEMCHR (input, '\0', n) == NULL); @@ -87,25 +88,37 @@ main (void) /* Check that memchr() does not read past the first occurrence of the byte being searched. See the Austin Group's clarification - <http://www.opengroup.org/austin/docs/austin_454.txt>. */ + <http://www.opengroup.org/austin/docs/austin_454.txt>. + Test both '\0' and something else, since some implementations + special-case searching for NUL. + */ { char *page_boundary = (char *) zerosize_ptr (); + /* Too small, and we miss cache line boundary tests; too large, + and the test takes cubically longer to complete. */ + int limit = 257; if (page_boundary != NULL) { - for (n = 1; n <= 500; n++) + for (n = 1; n <= limit; n++) { char *mem = page_boundary - n; memset (mem, 'X', n); ASSERT (MEMCHR (mem, 'U', n) == NULL); + ASSERT (MEMCHR (mem, 0, n) == NULL); { size_t i; + size_t k; for (i = 0; i < n; i++) { mem[i] = 'U'; - ASSERT (MEMCHR (mem, 'U', 4000) == mem + i); + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 'U', k) == mem + i); + mem[i] = 0; + for (k = i + 1; k < n + limit; k++) + ASSERT (MEMCHR (mem, 0, k) == mem + i); mem[i] = 'X'; } } diff --git a/lib/gl/tests/test-netdb.c b/lib/gl/tests/test-netdb.c index 5f2bcd4e52..697bbc8dbf 100644 --- a/lib/gl/tests/test-netdb.c +++ b/lib/gl/tests/test-netdb.c @@ -1,5 +1,5 @@ /* Test of <netdb.h> substitute. - Copyright (C) 2007-2010 Free Software Foundation, Inc. + Copyright (C) 2007-2008, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,9 @@ /* Check that the 'struct hostent' type is defined. */ struct hostent t1; +/* Check that the 'socklen_t' type is defined. */ +socklen_t t2; + int main (void) { diff --git a/lib/gl/tests/test-read-file.c b/lib/gl/tests/test-read-file.c index 0a0bf6882e..daa61668c6 100644 --- a/lib/gl/tests/test-read-file.c +++ b/lib/gl/tests/test-read-file.c @@ -52,11 +52,23 @@ main (void) err = 1; } - /* Assume FILE1 is a regular file or a symlink to a regular file. */ - if (len != statbuf.st_size) + if (S_ISREG (statbuf.st_mode)) { - fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1); - err = 1; + /* FILE1 is a regular file or a symlink to a regular file. */ + if (len != statbuf.st_size) + { + fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len, FILE1); + err = 1; + } + } + else + { + /* Assume FILE1 is not empty. */ + if (len == 0) + { + fprintf (stderr, "Read nothing from %s\n", FILE1); + err = 1; + } } free (out); } diff --git a/lib/gl/tests/test-stdbool.c b/lib/gl/tests/test-stdbool.c index fcb534de4c..2103d8bab9 100644 --- a/lib/gl/tests/test-stdbool.c +++ b/lib/gl/tests/test-stdbool.c @@ -16,6 +16,17 @@ /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ +/* We want this test to succeed even when using gcc's -Werror; but to + do that requires a pragma that didn't exist before 4.3.0. */ +#ifndef __GNUC__ +# define ADDRESS_CHECK_OKAY +#elif __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) +/* No way to silence -Waddress. */ +#else +# pragma GCC diagnostic ignored "-Waddress" +# define ADDRESS_CHECK_OKAY +#endif + #include <config.h> #include <stdbool.h> @@ -39,49 +50,31 @@ "error: __bool_true_false_are_defined is not defined" #endif -#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>. */ +/* Several tests cannot be guaranteed with gnulib's <stdbool.h>, at + least, not for all compilers and compiler options. */ +#if HAVE_STDBOOL_H || defined __GNUC__ struct s { _Bool s: 1; _Bool t; } s; #endif char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; -#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>, at least, -not for all compilers. */ +#if HAVE_STDBOOL_H || defined __GNUC__ /* See above. */ char d[(bool) 0.5 == true ? 1 : -1]; +# ifdef ADDRESS_CHECK_OKAY bool e = &s; +# endif char f[(_Bool) 0.0 == false ? 1 : -1]; #endif char g[true]; char h[sizeof (_Bool)]; -#if 0 /* See above. */ +#if HAVE_STDBOOL_H || defined __GNUC__ /* See above. */ char i[sizeof s.t]; #endif enum { j = false, k = true, l = false * true, m = true * 256 }; _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; -#if 0 /* Cannot be guaranteed with gnulib's <stdbool.h>. */ -#if defined __xlc__ || defined __GNUC__ - /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 - reported by James Lemley on 2005-10-05; see - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - This test is not quite right, since xlc is allowed to - reject this program, as the initializer for xlcbug is - not one of the forms that C requires support for. - However, doing the test right would require a run-time - test, and that would make cross-compilation harder. - Let us hope that IBM fixes the xlc bug, and also adds - support for this kind of constant expression. In the - meantime, this test will reject xlc, which is OK, since - our stdbool.h substitute should suffice. We also test - this with GCC, where it should work, to detect more - quickly whether someone messes up the test in the - future. */ - char digs[] = "0123456789"; - int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); -#endif -#endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html @@ -92,5 +85,11 @@ _Bool *pq = &q; int main () { - return 0; + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This is a runtime test, since a corresponding compile-time + test would rely on initializer extensions. */ + char digs[] = "0123456789"; + return &(digs + 5)[-2 + (bool) 1] != &digs[4]; } diff --git a/lib/gl/tests/test-stddef.c b/lib/gl/tests/test-stddef.c index d047e57b65..2c392c7547 100644 --- a/lib/gl/tests/test-stddef.c +++ b/lib/gl/tests/test-stddef.c @@ -31,6 +31,20 @@ size_t c = 2; per POSIX 2008. */ verify (sizeof NULL == sizeof (void *)); +/* Check that offsetof produces integer constants with correct type. */ +struct d +{ + char e; + char f; +}; +/* Solaris 10 has a bug where offsetof is under-parenthesized, and + cannot be used as an arbitrary expression. However, since it is + unlikely to bite real code, we ignore that short-coming. */ +/* verify (sizeof offsetof (struct d, e) == sizeof (size_t)); */ +verify (sizeof (offsetof (struct d, e)) == sizeof (size_t)); +verify (offsetof (struct d, e) < -1); /* Must be unsigned. */ +verify (offsetof (struct d, f) == 1); + int main (void) { diff --git a/lib/gl/tests/test-stdlib.c b/lib/gl/tests/test-stdlib.c index 4bd8715f3d..1e7956b68c 100644 --- a/lib/gl/tests/test-stdlib.c +++ b/lib/gl/tests/test-stdlib.c @@ -22,22 +22,33 @@ #include "verify.h" -int exitcode; +/* Check that EXIT_SUCCESS is 0, per POSIX. */ +static int exitcode = EXIT_SUCCESS; +#if EXIT_SUCCESS +"oops" +#endif + +/* Check for GNU value (not guaranteed by POSIX, but is guaranteed by + gnulib). */ +#if EXIT_FAILURE != 1 +"oops" +#endif /* Check that NULL can be passed through varargs as a pointer type, per POSIX 2008. */ verify (sizeof NULL == sizeof (void *)); +#if GNULIB_TEST_SYSTEM_POSIX +# include "test-sys_wait.h" +#else +# define test_sys_wait_macros() 0 +#endif + int main (void) { - /* Check that some macros are defined and different integer constants. */ - switch (exitcode) - { - case EXIT_SUCCESS: - case EXIT_FAILURE: - break; - } - - return 0; + if (test_sys_wait_macros ()) + return 1; + + return exitcode; } diff --git a/lib/gl/tests/test-sys_socket.c b/lib/gl/tests/test-sys_socket.c index badf308b7a..e976ff6a7b 100644 --- a/lib/gl/tests/test-sys_socket.c +++ b/lib/gl/tests/test-sys_socket.c @@ -1,5 +1,5 @@ /* Test of <sys/socket.h> substitute. - Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +27,9 @@ int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR }; #endif +/* Check that the 'socklen_t' type is defined. */ +socklen_t t1; + int main (void) { @@ -49,5 +52,9 @@ main (void) x.ss_family = 42; i = 42; + /* Tell the compiler that these variables are used. */ + (void) x; + (void) i; + return 0; } diff --git a/lib/gl/tests/test-sys_wait.h b/lib/gl/tests/test-sys_wait.h new file mode 100644 index 0000000000..bb10450867 --- /dev/null +++ b/lib/gl/tests/test-sys_wait.h @@ -0,0 +1,53 @@ +/* Test of macros shared between <sys/wait.h> and <stdlib.h>. + Copyright (C) 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General 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 Eric Blake <ebb9@byu.net>, 2010. */ + +static int +test_sys_wait_macros (void) +{ + /* Check subset of <sys/wait.h> macros that must be visible here. + Note that some of these macros are only portable when operating + on an lvalue. */ + int i; + for (i = 0; i < 0x8000; i = (i ? i << 1 : 1)) + { + /* POSIX requires that for all valid process statuses, that + exactly one of these three macros is true. But not all + possible 16-bit values map to valid process status. + Traditionally, 8 of the bits are for WIFEXITED, 7 of the bits + to tell between WIFSIGNALED and WIFSTOPPED, and either 0x80 + or 0x8000 to flag that core was also dumped. Since we don't + know which byte is WIFEXITED, we skip the both possible bits + that can signal core dump. */ + if (i == 0x80) + continue; + if (!!WIFSIGNALED (i) + !!WIFEXITED (i) + !!WIFSTOPPED (i) != 1) + return 1; + } + i = WEXITSTATUS (i) + WSTOPSIG (i) + WTERMSIG (i); + + switch (i) + { +#if 0 + /* Gnulib doesn't guarantee these, yet. */ + case WNOHANG: + case WUNTRACED: +#endif + break; + } + return 0; +} diff --git a/lib/gl/tests/test-verify.c b/lib/gl/tests/test-verify.c index 47eae2b4f3..3f89ba9058 100644 --- a/lib/gl/tests/test-verify.c +++ b/lib/gl/tests/test-verify.c @@ -42,7 +42,8 @@ enum item = verify_true (1 == 1) * 0 + 17 /* should be ok */ }; -int function (int n) +static int +function (int n) { #if EXP_FAIL == 3 verify (n >= 0); /* should give ERROR: non-constant expression */ diff --git a/lib/gl/time.in.h b/lib/gl/time.in.h index 7e86161299..8b93a3ee1d 100644 --- a/lib/gl/time.in.h +++ b/lib/gl/time.in.h @@ -19,6 +19,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* Don't get in the way of glibc when it includes time.h merely to declare a few standard symbols, rather than to declare all the @@ -48,10 +49,20 @@ /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in <sys/time.h> - (e.g., FreeBSD circa 1997). */ + (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the + pthreads-win32 library defines it in <pthread.h>. */ # if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ # include <sys/time.h> +# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@ +# include <pthread.h> +/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */ +# undef asctime_r +# undef ctime_r +# undef gmtime_r +# undef localtime_r +# undef rand_r +# undef strtok_r # else # ifdef __cplusplus diff --git a/lib/gl/unistd.in.h b/lib/gl/unistd.in.h index 29f7fbaa9e..e636163e1d 100644 --- a/lib/gl/unistd.in.h +++ b/lib/gl/unistd.in.h @@ -18,6 +18,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ /* Special invocation convention: - On mingw, several headers, including <winsock2.h>, include <unistd.h>, @@ -1097,7 +1098,7 @@ _GL_CXXALIASWARN (readlinkat); # undef readlinkat # if HAVE_RAW_DECL_READLINKAT _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " - "use gnulib module symlinkat for portability"); + "use gnulib module readlinkat for portability"); # endif #endif diff --git a/lib/gl/wchar.in.h b/lib/gl/wchar.in.h index ed582e5d02..568ef3206b 100644 --- a/lib/gl/wchar.in.h +++ b/lib/gl/wchar.in.h @@ -29,6 +29,7 @@ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +@PRAGMA_COLUMNS@ #if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H /* Special invocation convention: diff --git a/libextra/gl/gnulib.mk b/libextra/gl/gnulib.mk index 110246fd42..9b88b00222 100644 --- a/libextra/gl/gnulib.mk +++ b/libextra/gl/gnulib.mk @@ -21,6 +21,7 @@ libxgnu_la_LIBADD = $(xgl_LTLIBOBJS) libxgnu_la_DEPENDENCIES = $(xgl_LTLIBOBJS) EXTRA_libxgnu_la_SOURCES = libxgnu_la_LDFLAGS = $(AM_LDFLAGS) +libxgnu_la_LDFLAGS += -no-undefined ## begin gnulib module crypto/hmac-md5 diff --git a/libextra/gl/m4/gnulib-cache.m4 b/libextra/gl/m4/gnulib-cache.m4 index 221da5c6ac..ad8c687dbc 100644 --- a/libextra/gl/m4/gnulib-cache.m4 +++ b/libextra/gl/m4/gnulib-cache.m4 @@ -10,8 +10,8 @@ # # This file represents the specification of how gnulib-tool is used. # It acts as a cache: It is written and read by gnulib-tool. -# In projects using CVS, this file is meant to be stored in CVS, -# like the configure.ac and various Makefile.am files. +# In projects that use version control, this file is meant to be put under +# version control, like the configure.ac and various Makefile.am files. # Specification in the form of a command-line invocation: diff --git a/libextra/gl/m4/gnulib-comp.m4 b/libextra/gl/m4/gnulib-comp.m4 index b497cc3bd7..d02a7275fc 100644 --- a/libextra/gl/m4/gnulib-comp.m4 +++ b/libextra/gl/m4/gnulib-comp.m4 @@ -12,7 +12,8 @@ # This file represents the compiled summary of the specification in # gnulib-cache.m4. It lists the computed macro invocations that need # to be invoked from configure.ac. -# In projects using CVS, this file can be treated like other built files. +# In projects that use version control, this file can be treated like +# other built files. # This macro should be invoked from ./configure.ac, in the section diff --git a/libextra/gl/m4/ld-version-script.m4 b/libextra/gl/m4/ld-version-script.m4 index 43c1ef12f9..8fd8c8995c 100644 --- a/libextra/gl/m4/ld-version-script.m4 +++ b/libextra/gl/m4/ld-version-script.m4 @@ -1,4 +1,4 @@ -# ld-version-script.m4 serial 1 +# ld-version-script.m4 serial 2 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,7 +34,7 @@ VERS_2 { global: sym; } VERS_1; EOF - AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [have_ld_version_script=yes], [have_ld_version_script=no]) rm -f conftest.map LDFLAGS="$save_LDFLAGS" diff --git a/libextra/gl/m4/lib-ld.m4 b/libextra/gl/m4/lib-ld.m4 index ebb30528bd..294db72e13 100644 --- a/libextra/gl/m4/lib-ld.m4 +++ b/libextra/gl/m4/lib-ld.m4 @@ -1,4 +1,4 @@ -# lib-ld.m4 serial 4 (gettext-0.18) +# lib-ld.m4 serial 5 (gettext-0.18.2) dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -31,15 +31,14 @@ AC_REQUIRE([AC_CANONICAL_HOST])dnl # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh + # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which + # contains only /bin. Note that ksh looks also at the FPATH variable, + # so we have to set that as well for the test. + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ + || PATH_SEPARATOR=';' + } fi ac_prog=ld if test "$GCC" = yes; then diff --git a/libextra/gl/m4/lib-link.m4 b/libextra/gl/m4/lib-link.m4 index c73bd8e3a4..2ea9d6d073 100644 --- a/libextra/gl/m4/lib-link.m4 +++ b/libextra/gl/m4/lib-link.m4 @@ -1,4 +1,4 @@ -# lib-link.m4 serial 21 (gettext-0.18) +# lib-link.m4 serial 25 (gettext-0.18.2) dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -18,9 +18,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" @@ -58,9 +58,9 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([Name],[m4_translit([$1],[./+-], [____])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. @@ -85,7 +85,8 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; *) LIBS="$LIB[]NAME $LIBS" ;; esac - AC_TRY_LINK([$3], [$4], + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[$3]], [[$4]])], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) LIBS="$ac_save_LIBS" @@ -157,15 +158,15 @@ dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar dnl macro call that searches for libname. AC_DEFUN([AC_LIB_FROMPACKAGE], [ - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_frompackage_]NAME, [$2]) popdef([NAME]) pushdef([PACK],[$2]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) + m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) popdef([PACKUP]) popdef([PACK]) ]) @@ -178,14 +179,14 @@ dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ @@ -242,7 +243,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then @@ -103,6 +103,12 @@ endif # Override this in cfg.mk if you are using a different format in your # NEWS file. today = $(shell date +%Y-%m-%d) + +# Select which lines of NEWS are searched for $(news-check-regexp). +# This is a sed line number spec. The default says that we search +# lines 1..10 of NEWS for $(news-check-regexp). +# If you want to search only line 3 or only lines 20-22, use "3" or "20,22". +news-check-lines-spec ?= 1,10 news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)' # Prevent programs like 'sort' from considering distinct strings to be equal. @@ -662,8 +668,9 @@ sc_prohibit_always_true_header_tests: @or=$(gl_header_upper_case_or_); \ re="HAVE_($$or)_H"; \ prohibit='\<'"$$re"'\>' \ - halt='do not test the above HAVE_<header>_H symbol(s);\n'\ -' with the corresponding gnulib module, they are always true' \ + halt=$$(printf '%s\n' \ + 'do not test the above HAVE_<header>_H symbol(s);' \ + ' with the corresponding gnulib module, they are always true') \ $(_sc_search_regexp) # ================================================================== @@ -874,8 +881,8 @@ sc_makefile_at_at_check: && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : news-check: NEWS - if head $(srcdir)/NEWS | grep -E $(news-check-regexp) \ - >/dev/null; then \ + if sed -n $(news-check-lines-spec)p $(srcdir)/NEWS \ + | grep -E $(news-check-regexp) >/dev/null; then \ :; \ else \ echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ @@ -948,7 +955,7 @@ writable-files: test "$$fail" && exit 1 || : ; \ fi -v_etc_file = lib/version-etc.c +v_etc_file = $(gnulib_dir)/lib/version-etc.c sample-test = tests/sample-test texi = doc/$(PACKAGE).texi # Make sure that the copyright date in $(v_etc_file) is up to date. @@ -1006,9 +1013,10 @@ sc_Wundef_boolean: sc_vulnerable_makefile_CVE-2009-4029: @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \ in_files=$$(find $(srcdir) -name Makefile.in) \ - halt='the above files are vulnerable; beware of running\n'\ -'"make dist*" rules, and upgrade to fixed automake\n'\ -'see http://bugzilla.redhat.com/542609 for details' \ + halt=$$(printf '%s\n' \ + 'the above files are vulnerable; beware of running' \ + ' "make dist*" rules, and upgrade to fixed automake' \ + ' see http://bugzilla.redhat.com/542609 for details') \ $(_sc_search_regexp) vc-diff-check: |