diff options
135 files changed, 14515 insertions, 33365 deletions
@@ -12,6 +12,7 @@ Makefile.in /build-aux/ /config.* /configure +/configure~ /libtool stamp-h1 diff --git a/LICENSE.MIT b/LICENSE.MIT new file mode 100644 index 0000000..26f131d --- /dev/null +++ b/LICENSE.MIT @@ -0,0 +1,20 @@ +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE.WTFPL b/LICENSE.WTFPL deleted file mode 100644 index 5a8e332..0000000 --- a/LICENSE.WTFPL +++ /dev/null @@ -1,14 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - diff --git a/Makefile.am b/Makefile.am index 519aa55..6c9d27e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ PACKAGE = ${PACKAGE_NAME} ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc include src +SUBDIRS = include src pkgconfig_DATA = libHX.pc @@ -15,8 +15,8 @@ packext = .tar.xz .PHONY: tarball tarball: # do not use mkdir_p here. - mkdir ${tmpdir}; - pushd ${top_srcdir} && git archive --prefix=${PACKAGE_NAME}-${PACKAGE_VERSION}/ HEAD | tar -C ${tmpdir} -x && popd; - pushd ${tmpdir}/${PACKAGE_NAME}-${PACKAGE_VERSION} && ./autogen.sh && pushd doc/ && ./generate && popd && popd; - tar --use=${packer} -C ${tmpdir} -cf ${PACKAGE_NAME}-${PACKAGE_VERSION}${packext} --owner=root --group=root ${PACKAGE_NAME}-${PACKAGE_VERSION}/; - rm -Rf ${tmpdir}; + mkdir ${tmpdir} + cd ${top_srcdir} && git archive --prefix=${PACKAGE_NAME}-${PACKAGE_VERSION}/ HEAD | tar -C ${tmpdir} -x + cd ${tmpdir}/${PACKAGE_NAME}-${PACKAGE_VERSION} && autoreconf -fi && rm -Rf autom4te.cache + tar --use=${packer} -C ${tmpdir} -cf ${PACKAGE_NAME}-${PACKAGE_VERSION}${packext} --owner=root --group=root ${PACKAGE_NAME}-${PACKAGE_VERSION}/ + rm -Rf ${tmpdir} diff --git a/Makefile.in b/Makefile.in index 514d39f..b720a82 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. +# Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2017 Free Software Foundation, Inc. +# Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -169,9 +169,9 @@ am__recursive_targets = \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - cscope distdir dist dist-all distcheck -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ - $(LISP)config.h.in + cscope distdir distdir-am dist dist-all distcheck +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ + config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -188,9 +188,6 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/libHX.pc.in $(top_srcdir)/build-aux/ar-lib \ @@ -240,6 +237,8 @@ am__relativize = \ GZIP_ENV = --best DIST_ARCHIVES = $(distdir).tar.xz DIST_TARGETS = dist-xz +# Exists only to be overridden by the user if desired. +AM_DISTCHECK_DVI_TARGET = dvi distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' @@ -255,8 +254,9 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ @@ -271,8 +271,10 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -288,7 +290,6 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -LYX = @LYX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ @@ -365,6 +366,7 @@ psdir = @psdir@ regular_CFLAGS = @regular_CFLAGS@ regular_CPPFLAGS = @regular_CPPFLAGS@ regular_CXXFLAGS = @regular_CXXFLAGS@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -374,7 +376,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = doc include src +SUBDIRS = include src pkgconfig_DATA = libHX.pc tmpdir := $(shell mktemp -dtu) packer = xz @@ -404,8 +406,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -569,8 +571,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am -distdir: $(DISTFILES) +distdir-am: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -649,6 +653,10 @@ dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) +dist-zstd: distdir + tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst + $(am__post_remove_distdir) + dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @@ -691,6 +699,8 @@ distcheck: dist eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ + *.tar.zst*) \ + zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) @@ -706,7 +716,7 @@ distcheck: dist $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ - && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ @@ -871,18 +881,19 @@ uninstall-am: uninstall-pkgconfigDATA am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-generic \ - distclean-hdr distclean-libtool distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-pkgconfigDATA \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-pkgconfigDATA + dist-xz dist-zip dist-zstd distcheck distclean \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ + ps ps-am tags tags-am uninstall uninstall-am \ + uninstall-pkgconfigDATA .PRECIOUS: Makefile @@ -892,11 +903,11 @@ ${pkgconfig_DATA}: ${top_builddir}/config.status .PHONY: tarball tarball: # do not use mkdir_p here. - mkdir ${tmpdir}; - pushd ${top_srcdir} && git archive --prefix=${PACKAGE_NAME}-${PACKAGE_VERSION}/ HEAD | tar -C ${tmpdir} -x && popd; - pushd ${tmpdir}/${PACKAGE_NAME}-${PACKAGE_VERSION} && ./autogen.sh && pushd doc/ && ./generate && popd && popd; - tar --use=${packer} -C ${tmpdir} -cf ${PACKAGE_NAME}-${PACKAGE_VERSION}${packext} --owner=root --group=root ${PACKAGE_NAME}-${PACKAGE_VERSION}/; - rm -Rf ${tmpdir}; + mkdir ${tmpdir} + cd ${top_srcdir} && git archive --prefix=${PACKAGE_NAME}-${PACKAGE_VERSION}/ HEAD | tar -C ${tmpdir} -x + cd ${tmpdir}/${PACKAGE_NAME}-${PACKAGE_VERSION} && autoreconf -fi && rm -Rf autom4te.cache + tar --use=${packer} -C ${tmpdir} -cf ${PACKAGE_NAME}-${PACKAGE_VERSION}${packext} --owner=root --group=root ${PACKAGE_NAME}-${PACKAGE_VERSION}/ + rm -Rf ${tmpdir} # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..3ac5e61 --- /dev/null +++ b/README.rst @@ -0,0 +1,8 @@ +libHX collects many useful day-to-day functions, intended to reduce the amount +of otherwise repeatedly open-coded instructions. + +It has maps, deques, linked lists, string formatting and autoresizing, option +and config file parsing, type checking casts (for C), directory traversal, etc. + +There is more documentation in the aptly-named directory ``doc``. +The entrypoint is `doc/libHX_Documentation.rst <doc/libHX_Documentation.rst>`_. diff --git a/README.txt b/README.txt deleted file mode 100644 index 2b0f729..0000000 --- a/README.txt +++ /dev/null @@ -1,77 +0,0 @@ - -libHX is a C library (with some C++ bindings available) that provides data -structures and functions commonly needed, such as maps, deques, linked lists, -string formatting and autoresizing, option and config file parsing, type -checking casts and more. - -libHX aids in quickly writing up C and C++ data processing programs, by -consolidating tasks that often happen to be open-coded, such as (simple) config -file reading, option parsing, directory traversal, and others, into a library. -The focus is on reducing the amount of time (and secondarily, the amount of -code) a developer has to spend for otherwise implementing such. - - -Components (by all means not all) - - • Documentation (see doc/libHX_Documentation.pdf) - - • maps/sets (HXmap_*) - - Originally created to provide a data structure like Perl's associative - arrays. Multiple models and underlying storage data structures are - available (unordered hash-based map, ordered rbtree). - - • linked lists (HXdeque_*, HXlist_*, HXclist_*) - - Doubly-linked lists are suitable for both providing stack and queue - functionality. Different implementations are available for use, depending - on situation. - - • directory handling (HXdir_*) - - HXdir provides for opendir-readdir-closedir semantics. Windows uses a - different kind, so it had to be naturally covered up. On the other hand, - Solaris's readdir() implementation is nasty in terms of memory management. - HXdir covers up these discrepancies and provides a sane Linux-style - readdir. - - Convenience functions mkdir (create all missing parents), rrmdir (rm -Rf) - are also available. - - • string formatter with placeholders (HXformat_*) - - HXformat is something in the direction of printf(), but the argument list - is not implemented by means of varargs, so is flexible even beyond compile - time. You can change the format string — in fact, just let the user - configuration provide it — without having to worry about argument - evaluation problems. Positional and optional arguments are simply freely - choosable. - - • memory containers, auto-sizing string ops (HXmc_*) - - At the cost of slightly increased number memory allocations as you work - with the buffers, the hmc collection of functions provide scripting-level - semantics for strings. Appending to a string is simply hmc_strcat(&s, - "123") [cf. $s .= "123"], without having to worry about overflowing a - buffer. - - • option parsing (HXoption_*) - - Put blunt, libpopt failed to do some elementary things and there was no - maintainer to fix it. Well, it's packaged with rpm which already diverged - in all distros. - HXoption is table- and callback-based, much like popt. - - • shellconfig parser (HXshconfig_*) - - Parsers shconfig files. Their format is a subset of shell code. Files in / - etc/sysconfig are commonly shconfig-style. - - • common string operations - - basename, chomp, dirname, getl(ine), split, strlower/-upper, str*trim, - strsep, strsep2, etc. - -This page was last modified: 2011-01-15 16:41 UTC libHX.sf.net - -# Generated using `w3m -dump libhx.sf.net` and slightly editing it. @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.15.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.5 -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,13 +14,13 @@ m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, -[m4_warning([this file was generated for autoconf 2.69. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],, +[m4_warning([this file was generated for autoconf 2.71. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2017 Free Software Foundation, Inc. +# Copyright (C) 2002-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.15' +[am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15.1], [], +m4_if([$1], [1.16.5], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15.1])dnl +[AM_AUTOMAKE_VERSION([1.16.5])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) -# Copyright (C) 2011-2017 Free Software Foundation, Inc. +# Copyright (C) 2011-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -118,7 +118,7 @@ AC_SUBST([AR])dnl # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -170,7 +170,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -201,7 +201,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -392,13 +392,12 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. - # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], @@ -406,49 +405,43 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + AS_CASE([$CONFIG_FILES], + [*\'*], [eval set x "$CONFIG_FILES"], + [*], [set x $CONFIG_FILES]) shift - for mf + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf do # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line + am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`AS_DIRNAME(["$am_mf"])` + am_filepart=`AS_BASENAME(["$am_mf"])` + AM_RUN_LOG([cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles]) || am_rc=$? done + if test $am_rc -ne 0; then + AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE="gmake" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking).]) + fi + AS_UNSET([am_dirpart]) + AS_UNSET([am_filepart]) + AS_UNSET([am_mf]) + AS_UNSET([am_rc]) + rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS @@ -457,18 +450,17 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each '.P' file that we will -# need in order to bootstrap the dependency handling code. +# This code is only required when automatic dependency tracking is enabled. +# This creates each '.Po' and '.Plo' makefile fragment that we'll need in +# order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) + [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -496,6 +488,10 @@ m4_defn([AC_PROG_CC]) # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl +m4_ifdef([_$0_ALREADY_INIT], + [m4_fatal([$0 expanded multiple times +]m4_defn([_$0_ALREADY_INIT]))], + [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -532,7 +528,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( - m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl @@ -555,8 +551,8 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: -# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> -# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> +# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> +# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. @@ -584,6 +580,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi +AC_SUBST([CTAGS]) +if test -z "$ETAGS"; then + ETAGS=etags +fi +AC_SUBST([ETAGS]) +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi +AC_SUBST([CSCOPE]) + AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This @@ -623,7 +633,7 @@ END Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: <http://www.gnu.org/software/coreutils/>. +that behaves properly: <https://www.gnu.org/software/coreutils/>. If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM @@ -633,6 +643,7 @@ END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi +AM_SILENT_RULES([yes]) dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. @@ -665,7 +676,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -686,7 +697,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2017 Free Software Foundation, Inc. +# Copyright (C) 2003-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -707,7 +718,7 @@ AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -715,49 +726,42 @@ AC_SUBST([am__leading_dot])]) # AM_MAKE_INCLUDE() # ----------------- -# Check to see how make treats includes. +# Check whether make has an 'include' directive that can support all +# the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' +[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) +cat > confinc.mk << 'END' am__doit: - @echo this is the am__doit target + @echo this is the am__doit target >confinc.out .PHONY: am__doit END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) + AS_CASE([$?:`cat confinc.out 2>/dev/null`], + ['0:this is the am__doit target'], + [AS_CASE([$s], + [BSD], [am__include='.include' am__quote='"'], + [am__include='include' am__quote=''])]) + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +AC_MSG_RESULT([${_am_result}]) +AC_SUBST([am__include])]) +AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2017 Free Software Foundation, Inc. +# Copyright (C) 1997-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -778,12 +782,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac + MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then @@ -796,7 +795,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -825,7 +824,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -872,7 +871,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -891,7 +890,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -972,7 +971,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2017 Free Software Foundation, Inc. +# Copyright (C) 2009-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1032,7 +1031,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2017 Free Software Foundation, Inc. +# Copyright (C) 2001-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1060,7 +1059,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2017 Free Software Foundation, Inc. +# Copyright (C) 2006-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1079,7 +1078,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2017 Free Software Foundation, Inc. +# Copyright (C) 2004-2021 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/assorted/Makefile.in b/assorted/Makefile.in deleted file mode 100644 index 3c33bcb..0000000 --- a/assorted/Makefile.in +++ /dev/null @@ -1,602 +0,0 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2017 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# -*- Makefile -*- - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -noinst_PROGRAMS = unit2any$(EXEEXT) -subdir = assorted -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -PROGRAMS = $(noinst_PROGRAMS) -unit2any_SOURCES = unit2any.c -unit2any_OBJECTS = unit2any.$(OBJEXT) -unit2any_DEPENDENCIES = ../src/libHX.la -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = unit2any.c -DIST_SOURCES = unit2any.c -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags -am__DIST_COMMON = $(srcdir)/Makefile.in \ - $(top_srcdir)/build-aux/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -LYX = @LYX@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libdl_LIBS = @libdl_LIBS@ -libexecdir = @libexecdir@ -libpthread_LIBS = @libpthread_LIBS@ -librt_LIBS = @librt_LIBS@ -libsocket_LIBS = @libsocket_LIBS@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgconfigdir = @pkgconfigdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -regular_CFLAGS = @regular_CFLAGS@ -regular_CPPFLAGS = @regular_CPPFLAGS@ -regular_CXXFLAGS = @regular_CXXFLAGS@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CPPFLAGS = -I${top_srcdir}/include -unit2any_LDADD = ../src/libHX.la -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign assorted/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign assorted/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstPROGRAMS: - @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - -unit2any$(EXEEXT): $(unit2any_OBJECTS) $(unit2any_DEPENDENCIES) $(EXTRA_unit2any_DEPENDENCIES) - @rm -f unit2any$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(unit2any_OBJECTS) $(unit2any_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unit2any.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ - mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ - ctags-am distclean distclean-compile distclean-generic \ - distclean-libtool distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 62a89e1..0000000 --- a/autogen.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -autoreconf -fi; -rm -Rf autom4te*.cache; diff --git a/build-aux/ar-lib b/build-aux/ar-lib index 05094d3..c349042 100755 --- a/build-aux/ar-lib +++ b/build-aux/ar-lib @@ -2,9 +2,9 @@ # Wrapper for Microsoft lib.exe me=ar-lib -scriptversion=2012-03-01.08; # UTC +scriptversion=2019-07-04.01; # UTC -# Copyright (C) 2010-2017 Free Software Foundation, Inc. +# Copyright (C) 2010-2021 Free Software Foundation, Inc. # Written by Peter Rosin <peda@lysator.liu.se>. # # This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ scriptversion=2012-03-01.08; # UTC # GNU General 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -53,7 +53,7 @@ func_file_conv () MINGW*) file_conv=mingw ;; - CYGWIN*) + CYGWIN* | MSYS*) file_conv=cygwin ;; *) @@ -65,7 +65,7 @@ func_file_conv () mingw) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; - cygwin) + cygwin | msys) file=`cygpath -m "$file" || echo "$file"` ;; wine) @@ -224,10 +224,11 @@ elif test -n "$extract"; then esac done else - $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member - do - $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $? - done + $AR -NOLOGO -LIST "$archive" | tr -d '\r' | sed -e 's/\\/\\\\/g' \ + | while read member + do + $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $? + done fi elif test -n "$quick$replace"; then diff --git a/build-aux/compile b/build-aux/compile index 2ab71e4..df363c8 100755 --- a/build-aux/compile +++ b/build-aux/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2021 Free Software Foundation, Inc. # Written by Tom Tromey <tromey@cygnus.com>. # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2016-01-11.22; # UTC # GNU General 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -53,7 +53,7 @@ func_file_conv () MINGW*) file_conv=mingw ;; - CYGWIN*) + CYGWIN* | MSYS*) file_conv=cygwin ;; *) @@ -67,7 +67,7 @@ func_file_conv () mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; - cygwin/*) + cygwin/* | msys/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) @@ -340,7 +340,7 @@ exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/build-aux/config.guess b/build-aux/config.guess index 1bf683d..8fbd7fe 100755 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -1,8 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2017-05-27' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2021-06-03' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +17,7 @@ timestamp='2017-05-27' # General 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/>. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,11 +29,19 @@ timestamp='2017-05-27' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -39,7 +49,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,7 +94,8 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +# Just in case it came from the environment. +GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -96,60 +107,84 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case $UNAME_SYSTEM in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include <stdarg.h> + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac @@ -162,10 +197,11 @@ case "${UNAME_MACHINE}" in ;; esac test -f /etc/SuSE-release -o -f /.buildenv && VENDOR=suse +test -f /etc/os-release && grep -q suse /etc/os-release && VENDOR=suse # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -177,32 +213,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-${VENDOR}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-${VENDOR}-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -218,10 +254,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -229,47 +265,68 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-${VENDOR}-bitrig${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-${VENDOR}-openbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-secbsd$UNAME_RELEASE + ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-${VENDOR}-libertybsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-libertybsd$UNAME_RELEASE + ;; + *:MidnightBSD:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-ekkobsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-solidbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-${VENDOR}-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=powerpc-${VENDOR}-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-mirbsd${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-sortix - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-twizzler + ;; + *:Redox:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-redox + ;; + mips:OSF1:*.*) + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -283,7 +340,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in + case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") @@ -320,84 +377,76 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-${VENDOR}-sysv4 - exit ;; + GUESS=m68k-${VENDOR}-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-amigaos - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-morphos - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-${VENDOR}-riscos - exit ;; + GUESS=arm-${VENDOR}-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null @@ -405,41 +454,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 + case `/bin/arch` in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -449,44 +501,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-${VENDOR}-mint${UNAME_RELEASE} - exit ;; + GUESS=m68k-${VENDOR}-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -495,95 +547,96 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux${UNAME_RELEASE} + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> main() @@ -594,77 +647,77 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=rs6000-ibm-aix + ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in + case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in + case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include <stdlib.h> @@ -697,13 +750,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -722,15 +775,15 @@ EOF HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int main () @@ -755,38 +808,38 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) - echo hppa1.1-hp-bsd - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-${VENDOR}-osf1mk + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-${VENDOR}-osf1mk else - echo ${UNAME_MACHINE}-${VENDOR}-osf1 + GUESS=$UNAME_MACHINE-${VENDOR}-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -794,140 +847,145 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-${VENDOR}-bsdi${UNAME_RELEASE} - exit ;; + GUESS=sparc-${VENDOR}-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-bsdi${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-${VENDOR}-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-${VENDOR}-freebsd$FREEBSD_REL-gnueabihf + fi + ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo ${UNAME_PROCESSOR}-${VENDOR}-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-${VENDOR}-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case $UNAME_MACHINE in x86) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-${VENDOR}-interix${UNAME_RELEASE} - exit ;; + GUESS=x86_64-${VENDOR}-interix$UNAME_RELEASE + ;; IA64) - echo ia64-${VENDOR}-interix${UNAME_RELEASE} - exit ;; + GUESS=ia64-${VENDOR}-interix$UNAME_RELEASE + ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-${VENDOR}-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-${VENDOR}-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-${VENDOR}-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-${VENDOR}-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-${VENDOR}-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-${VENDOR}-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-${VENDOR}-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} - exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix - exit ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-${VENDOR}-$GNU_SYS$GNU_REL-$LIBC + ;; + *:Minix:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-minix + ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -938,183 +996,225 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabi + GUESS=$UNAME_MACHINE-${VENDOR}-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}eabihf + GUESS=$UNAME_MACHINE-${VENDOR}-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-${VENDOR}-linux-${LIBC}"; exit; } + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-${VENDOR}-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; openrisc*:Linux:*:*) - echo or1k-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=or1k-${VENDOR}-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=sparc-${VENDOR}-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=hppa64-${VENDOR}-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-${VENDOR}-linux-${LIBC} ;; - PA8*) echo hppa2.0-${VENDOR}-linux-${LIBC} ;; - *) echo hppa-${VENDOR}-linux-${LIBC} ;; + PA7*) GUESS=hppa1.1-${VENDOR}-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-${VENDOR}-linux-$LIBC ;; + *) GUESS=hppa-${VENDOR}-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=powerpc64-${VENDOR}-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=powerpc-${VENDOR}-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=powerpc64le-${VENDOR}-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-${VENDOR}-linux-${LIBC} - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=powerpcle-${VENDOR}-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} - exit ;; + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI=${LIBC}x32 + fi + fi + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-linux-${LIBC} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-${VENDOR}-stop - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-stop + ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-atheos - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-atheos + ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-${VENODR}-lynxos${UNAME_RELEASE} - exit ;; + GUESS=i386-${VENDOR}-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in @@ -1122,12 +1222,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1137,11 +1237,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo ${UNAME_MACHINE}-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1149,31 +1249,31 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-${VENODR}-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + GUESS=i860-${VENDOR}-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) @@ -1181,9 +1281,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1192,259 +1292,434 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; + GUESS=m68k-${VENDOR}-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; + GUESS=sparc-${VENDOR}-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; + GUESS=rs6000-${VENDOR}-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-${VENDOR}-lynxos${UNAME_RELEASE} - exit ;; + GUESS=powerpc-${VENDOR}-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; + ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-${VENDOR}-sysv${UNAME_RELEASE} + GUESS=mips-${VENDOR}-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; + GUESS=i586-pc-haiku + ;; x86_64:Haiku:*:*) - echo x86_64-${VENDOR}-haiku - exit ;; + GUESS=x86_64-${VENDOR}-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} - exit ;; + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; + GUESS=i386-pc-qnx + ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; + NSV-*:NONSTOP_KERNEL:*:*) + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} - exit ;; + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = 386; then + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo ${UNAME_MACHINE}-${VENDOR}-plan9 - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-${VENDOR}-tops10 - exit ;; + GUESS=pdp10-${VENDOR}-tops10 + ;; *:TENEX:*:*) - echo pdp10-${VENDOR}-tenex - exit ;; + GUESS=pdp10-${VENDOR}-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-${VENDOR}-tops20 - exit ;; + GUESS=pdp10-${VENDOR}-tops20 + ;; *:ITS:*:*) - echo pdp10-${VENDOR}-its - exit ;; + GUESS=pdp10-${VENDOR}-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-${VENDOR}-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos - exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-aros + ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-${VENDOR}-esx - exit ;; + GUESS=$UNAME_MACHINE-${VENDOR}-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-${VENDOR}-onefs - exit ;; + GUESS=x86_64-${VENDOR}-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-${VENDOR}-unleashed$UNAME_RELEASE + ;; +esac + +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" <<EOF +#ifdef _SEQUENT_ +#include <sys/types.h> +#include <sys/utsname.h> +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include <signal.h> +#if defined(_SIZE_T_) || defined(SIGLOST) +#include <sys/utsname.h> +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include <sys/param.h> +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case $UNAME_MACHINE:$UNAME_SYSTEM in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <<EOF + +NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize +the system type. Please install a C compiler and try again. +EOF + ;; esac cat >&2 <<EOF -$0: unable to guess system type This script (version $timestamp), has failed to recognize the -operating system you are using. If your script is old, overwrite -config.guess and config.sub with the latest versions from: +operating system you are using. If your script is old, overwrite *all* +copies of config.guess and config.sub with the latest versions from: - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub +EOF + +our_year=`echo $timestamp | sed 's,-.*,,'` +thisyear=`date +%Y` +# shellcheck disable=SC2003 +script_age=`expr "$thisyear" - "$our_year"` +if test "$script_age" -lt 3 ; then + cat >&2 <<EOF If $0 has already been updated, send the following data and any information you think might be pertinent to config-patches@gnu.org to @@ -1467,16 +1742,17 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/build-aux/config.sub b/build-aux/config.sub index 0399c1a..d74fb6d 100755 --- a/build-aux/config.sub +++ b/build-aux/config.sub @@ -1,8 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2017-04-02' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2021-08-14' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +17,7 @@ timestamp='2017-04-02' # General 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/>. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +35,7 @@ timestamp='2017-04-02' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,6 +52,13 @@ timestamp='2017-04-02' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -57,7 +66,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,12 +98,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1258 +119,1181 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <<EOF +$1 +EOF +IFS=$saved_IFS -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos +# Separate into logical components for further validation +case $1 in + *-*-*-*-*) + echo Invalid configuration \`"$1"\': more than four components >&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=-none + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 + cpu=m68k + vendor=motorola ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) + cpu=mips + vendor=sgi + case $basic_os in + irix*) ;; *) - os=-irix4 + basic_os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint + cpu=m68000 + vendor=convergent ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; - -ns2*) - os=-nextstep2 + ns2*) + basic_os=nextstep2 ;; *) - os=-nextstep3 + basic_os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem + cpu=np1 + vendor=gould ;; op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; pbd) - basic_machine=sparc-tti + cpu=sparc + vendor=tti ;; pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 - ;; - pc98) - basic_machine=i386-pc - ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=m68k + vendor=tti ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc - ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc - ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc - ;; - pentium4) - basic_machine=i786-pc - ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + pc532) + cpu=ns32k + vendor=pc532 ;; pn) - basic_machine=pn-gould - ;; - power) basic_machine=power-ibm - ;; - ppc | ppcbe) basic_machine=powerpc-unknown - ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + cpu=pn + vendor=gould ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown - ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + power) + cpu=power + vendor=ibm ;; ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff + cpu=i386 + vendor=ibm ;; rm[46]00) - basic_machine=mips-siemens + cpu=mips + vendor=siemens ;; rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390) - basic_machine=s390-ibm - ;; - s390-*) - basic_machine=s390-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - s390x) - basic_machine=s390x-ibm - ;; - s390x-*) - basic_machine=s390x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + cpu=romp + vendor=ibm ;; sde) - basic_machine=mipsisa32-sde - os=-elf + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - sei) - basic_machine=mips-sei - os=-seiux + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - sequent) - basic_machine=i386-sequent + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - sh) - basic_machine=sh-hitachi - os=-hms + w65) + cpu=w65 + vendor=wdc ;; - sh5el) - basic_machine=sh5le-unknown + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - sh64) - basic_machine=sh64-unknown + none) + cpu=none + vendor=none ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - spur) - basic_machine=spur-unknown + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <<EOF +$basic_machine +EOF + IFS=$saved_IFS ;; - st2000) - basic_machine=m68k-tandem + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + cpu=$basic_machine + vendor=pc ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" + pc98) + cpu=i386 + vendor=pc ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - sun2) - basic_machine=m68000-sun + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + basic_os=${basic_os:-unicosmp} ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 + c90-unknown | c90-cray) + vendor=cray + basic_os=${Basic_os:-unicos} ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 + fx80-unknown) + vendor=alliant ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 + romp-unknown) + vendor=ibm ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 + mmix-unknown) + vendor=knuth ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 + rs6000-unknown) + vendor=ibm ;; - sun3 | sun3-*) - basic_machine=m68k-sun + vax-unknown) + vendor=dec ;; - sun4) - basic_machine=sparc-sun + pdp11-unknown) + vendor=dec ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun + we32k-unknown) + vendor=att ;; - sv1) - basic_machine=sv1-cray - os=-unicos + cydra-unknown) + vendor=cydrome ;; - symmetry) - basic_machine=i386-sequent - os=-dynix + i370-ibm*) + vendor=ibm ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos + orion-unknown) + vendor=highlevel ;; - t90) - basic_machine=t90-cray - os=-unicos + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu + + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + basic_os=${basic_os:-bosx} ;; - tx39) - basic_machine=mipstx39-unknown + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - tx39el) - basic_machine=mipstx39el-unknown + blackfin-*) + cpu=bfin + basic_os=linux ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 + c54x-*) + cpu=tic54x ;; - tower | tower-32) - basic_machine=m68k-ncr + c55x-*) + cpu=tic55x ;; - tpf) - basic_machine=s390x-ibm - os=-tpf + c6x-*) + cpu=tic6x ;; - udi29k) - basic_machine=a29k-amd - os=-udi + e500v[12]-*) + cpu=powerpc + basic_os=${basic_os}"spe" ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 + mips3*-*) + cpu=mips64 ;; - v810 | necv810) - basic_machine=v810-nec - os=-none + ms1-*) + cpu=mt ;; - vaxv) - basic_machine=vax-dec - os=-sysv + m68knommu-*) + cpu=m68k + basic_os=linux ;; - vms) - basic_machine=vax-dec - os=-vms + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu + openrisc-*) + cpu=or32 ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks + parisc-*) + cpu=hppa + basic_os=linux ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - wasm32) - basic_machine=wasm32-unknown + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - w65*) - basic_machine=w65-wdc - os=-none + pentium4-*) + cpu=i786 ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf + pc98-*) + cpu=i386 ;; - xbox) - basic_machine=i686-pc - os=-mingw32 + ppc-* | ppcbe-*) + cpu=powerpc ;; - xps | xps100) - basic_machine=xps100-honeywell + ppcle-* | powerpclittle-*) + cpu=powerpcle ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ppc64-*) + cpu=powerpc64 ;; - ymp) - basic_machine=ymp-cray - os=-unicos + ppc64le-* | powerpc64little-*) + cpu=powerpc64le ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim + sb1-*) + cpu=mipsisa64sb1 ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim + sb1el-*) + cpu=mipsisa64sb1el ;; - none) - basic_machine=none-none - os=-none + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + spur-*) + cpu=spur ;; - op50n) - basic_machine=hppa1.1-oki + strongarm-* | thumb-*) + cpu=arm ;; - op60c) - basic_machine=hppa1.1-oki + tx39-*) + cpu=mipstx39 ;; - romp) - basic_machine=romp-ibm + tx39el-*) + cpu=mipstx39el ;; - mmix) - basic_machine=mmix-knuth + x64-*) + cpu=x86_64 ;; - rs6000) - basic_machine=rs6000-ibm + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; - vax) - basic_machine=vax-dec + arm64-*) + cpu=aarch64 ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + basic_os=${basic_os:-elf} ;; - pdp11) - basic_machine=pdp11-dec + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis ;; - we32k) - basic_machine=we32k-att + cris-* | etrax*-*) + cpu=cris + vendor=axis ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + crx-*) + basic_os=${basic_os:-elf} ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun + neo-tandem) + cpu=neo + vendor=tandem ;; - cydra) - basic_machine=cydra-cydrome + nse-tandem) + cpu=nse + vendor=tandem ;; - orion) - basic_machine=orion-highlevel + nsr-tandem) + cpu=nsr + vendor=tandem ;; - orion105) - basic_machine=clipper-highlevel + nsv-tandem) + cpu=nsv + vendor=tandem ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + nsx-tandem) + cpu=nsx + vendor=tandem ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + mipsallegrexel-sony) + cpu=mipsallegrexel + vendor=sony ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + tile*-*) + basic_os=${basic_os:-linux-gnu} ;; + *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb | arc32 | arc64 \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 | loongarchx32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r3 | mipsisa32r3el \ + | mipsisa32r5 | mipsisa32r5el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r3 | mipsisa64r3el \ + | mipsisa64r5 | mipsisa64r5el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1369,203 +1301,215 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <<EOF +$basic_os +EOF + IFS=$saved_IFS + ;; + # Default OS when just kernel was specified + nto*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto|qnx|'` + ;; + linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|linux|gnu|'` + ;; + *) + kernel= + os=$basic_os ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` +esac + +# Now, normalize the OS (knowing we just have one component, it's not a kernel, +# etc.) +case $os in + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -solaris) - os=-solaris2 + bluegene*) + os=cnk ;; - -svr4*) - os=-sysv4 + solaris1 | solaris1.*) + os=`echo "$os" | sed -e 's|solaris1|sunos4|'` ;; - -unixware*) - os=-sysv4.2uw + solaris) + os=solaris2 ;; - -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + unixware*) + os=sysv4.2uw ;; - # First accept the basic system types. - # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. - # -sysv* is not here because it comes later, after sysvr4. - -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* | -plan9* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* | -cloudabi* | -sortix* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ - | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=-nto$os - ;; - esac + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose ;; - -nto-qnx*) + # Some version numbers need modification + chorusos*) + os=chorusos ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` + isc) + os=isc2.2 ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + sco6) + os=sco5v6 ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + sco5) + os=sco3.2v5 ;; - -linux-dietlibc) - os=-linux-dietlibc + sco4) + os=sco3.2v4 ;; - -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` + sco3.2.[4-9]*) + os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'` ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + sco*v* | scout) + # Don't match below ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + sco*) + os=sco3.2v2 ;; - -opened*) - os=-openedition + psos*) + os=psos ;; - -os400*) - os=-os400 + qnx*) + os=qnx ;; - -wince*) - os=-wince + hiux*) + os=hiuxwe2 ;; - -osfrose*) - os=-osfrose + lynx*178) + os=lynxos178 ;; - -osf*) - os=-osf + lynx*5) + os=lynxos5 ;; - -utek*) - os=-bsd + lynxos*) + # don't get caught up in next wildcard ;; - -dynix*) - os=-bsd + lynx*) + os=lynxos ;; - -acis*) - os=-aos + mac[0-9]*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -atheos*) - os=-atheos + opened*) + os=openedition ;; - -syllable*) - os=-syllable + os400*) + os=os400 ;; - -386bsd) - os=-bsd + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -ctix* | -uts*) - os=-sysv + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -nova*) - os=-rtmk-nova + wince*) + os=wince ;; - -ns2 ) - os=-nextstep2 + utek*) + os=bsd ;; - -nsk*) - os=-nsk + dynix*) + os=bsd ;; - # Preserve the version number of sinix5. - -sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` + acis*) + os=aos ;; - -sinix*) - os=-sysv4 + atheos*) + os=atheos ;; - -tpf*) - os=-tpf + syllable*) + os=syllable ;; - -triton*) - os=-sysv3 + 386bsd) + os=bsd ;; - -oss*) - os=-sysv3 + ctix* | uts*) + os=sysv ;; - -svr4) - os=-sysv4 + nova*) + os=rtmk-nova ;; - -svr3) - os=-sysv3 + ns2) + os=nextstep2 ;; - -sysvr4) - os=-sysv4 + # Preserve the version number of sinix5. + sinix5.*) + os=`echo "$os" | sed -e 's|sinix|sysv|'` ;; - # This must come after -sysvr4. - -sysv*) + sinix*) + os=sysv4 ;; - -ose*) - os=-ose + tpf*) + os=tpf ;; - -es1800*) - os=-ose + triton*) + os=sysv3 ;; - -xenix) - os=-xenix + oss*) + os=sysv3 ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + svr4*) + os=sysv4 ;; - -aros*) - os=-aros + svr3) + os=sysv3 ;; - -zvmoe) - os=-zvmoe + sysvr4) + os=sysv4 ;; - -dicos*) - os=-dicos + ose*) + os=ose ;; - -nacl*) + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -ios) + dicos*) + os=dicos ;; - -none) + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $cpu in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1578,264 +1522,362 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; pru-*) - os=-elf + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | relibc* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - -os400*) + s390-* | s390x-*) vendor=ibm ;; - -ptx*) + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/build-aux/depcomp b/build-aux/depcomp index b39f98f..715e343 100755 --- a/build-aux/depcomp +++ b/build-aux/depcomp @@ -1,9 +1,9 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Copyright (C) 1999-2021 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ scriptversion=2016-01-11.22; # UTC # GNU General 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -783,7 +783,7 @@ exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/build-aux/install-sh b/build-aux/install-sh index 0360b79..ec298b5 100755 --- a/build-aux/install-sh +++ b/build-aux/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2016-01-11.22; # UTC +scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -69,6 +69,11 @@ posix_mkdir= # Desired mode of installed file. mode=0755 +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 + +backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= @@ -99,18 +104,28 @@ Options: --version display version info and exit. -c (ignored) - -C install only if different (preserve the last data modification time) + -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. + -p pass -p to $cpprog. -s $stripprog installed files. + -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG + +By default, rm is invoked with -f; when overridden with RMPROG, +it's up to you to specify -f if you want it. + +If -S is not specified, no backups are attempted. + +Email bug reports to bug-automake@gnu.org. +Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do @@ -137,8 +152,13 @@ while test $# -ne 0; do -o) chowncmd="$chownprog $2" shift;; + -p) cpprog="$cpprog -p";; + -s) stripcmd=$stripprog;; + -S) backupsuffix="$2" + shift;; + -t) is_target_a_directory=always dst_arg=$2 @@ -255,6 +275,10 @@ do dstdir=$dst test -d "$dstdir" dstdir_status=$? + # Don't chown directories that already exist. + if test $dstdir_status = 0; then + chowncmd="" + fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command @@ -271,15 +295,18 @@ do fi dst=$dst_arg - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. + # If destination is a directory, append the input filename. if test -d "$dst"; then if test "$is_target_a_directory" = never; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst - dst=$dstdir/`basename "$src"` + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac dstdir_status=0 else dstdir=`dirname "$dst"` @@ -288,27 +315,16 @@ do fi fi + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; - - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac - # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then @@ -318,43 +334,49 @@ do fi posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; esac if @@ -365,7 +387,7 @@ do then : else - # The umask is ridiculous, or mkdir does not conform to POSIX, + # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. @@ -394,7 +416,7 @@ do prefixes= else if $posix_mkdir; then - (umask=$mkdir_umask && + (umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 @@ -427,14 +449,25 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -460,6 +493,13 @@ do then rm -f "$dsttmp" else + # If $backupsuffix is set, and the file being installed + # already exists, attempt a backup. Don't worry if it fails, + # e.g., if mv doesn't support -f. + if test -n "$backupsuffix" && test -f "$dst"; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi + # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || @@ -474,9 +514,9 @@ do # file should still install successfully. { test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || + $doit $rmcmd "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 @@ -493,7 +533,7 @@ do done # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/build-aux/ltmain.sh b/build-aux/ltmain.sh index 0f0a2da..2a50d7f 100755 --- a/build-aux/ltmain.sh +++ b/build-aux/ltmain.sh @@ -1,12 +1,12 @@ -#! /bin/sh +#! /usr/bin/env sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in -## by inline-source v2014-01-03.01 +## by inline-source v2019-02-19.15 -# libtool (GNU libtool) 2.4.6 +# libtool (GNU libtool) 2.4.7 # Provide generalized library-building support services. # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 -# Copyright (C) 1996-2015 Free Software Foundation, Inc. +# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -31,8 +31,8 @@ PROGRAM=libtool PACKAGE=libtool -VERSION=2.4.6 -package_revision=2.4.6 +VERSION=2.4.7 +package_revision=2.4.7 ## ------ ## @@ -64,34 +64,25 @@ package_revision=2.4.6 # libraries, which are installed to $pkgauxdir. # Set a version string for this script. -scriptversion=2015-01-20.17; # UTC +scriptversion=2019-02-19.15; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 -# Copyright (C) 2004-2015 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. - -# As a special exception to the GNU General Public License, if you distribute -# this file as part of a program or library that is built using GNU Libtool, -# you may include this file under the same distribution terms that you use -# for the rest of that program. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU -# General 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/>. +# This is free software. There is NO warranty; not even for +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Copyright (C) 2004-2019, 2021 Bootstrap Authors +# +# This file is dual licensed under the terms of the MIT license +# <https://opensource.org/license/MIT>, and GPL version 2 or later +# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of +# these licenses when using or redistributing this software or any of +# the files within it. See the URLs above, or the file `LICENSE` +# included in the Bootstrap distribution for the full license texts. -# Please report bugs or propose patches to gary@gnu.org. +# Please report bugs or propose patches to: +# <https://github.com/gnulib-modules/bootstrap/issues> ## ------ ## @@ -139,9 +130,12 @@ do _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# These NLS vars are set unconditionally (bootstrap issue #24). Unset those +# in case the environment reset is needed later and the $save_* variant is not +# defined (see the code above). +LC_ALL=C +LANGUAGE=C +export LANGUAGE LC_ALL # Make sure IFS has a sensible default sp=' ' @@ -159,6 +153,26 @@ if test "${PATH_SEPARATOR+set}" != set; then fi +# func_unset VAR +# -------------- +# Portably unset VAR. +# In some shells, an 'unset VAR' statement leaves a non-zero return +# status if VAR is already unset, which might be problematic if the +# statement is used at the end of a function (thus poisoning its return +# value) or when 'set -e' is active (causing even a spurious abort of +# the script in this case). +func_unset () +{ + { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } +} + + +# Make sure CDPATH doesn't cause `cd` commands to output the target dir. +func_unset CDPATH + +# Make sure ${,E,F}GREP behave sanely. +func_unset GREP_OPTIONS + ## ------------------------- ## ## Locate command utilities. ## @@ -259,7 +273,7 @@ test -z "$SED" && { rm -f conftest.in conftest.tmp conftest.nl conftest.out } - func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin + func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" rm -f conftest.sed SED=$func_path_progs_result } @@ -295,7 +309,7 @@ test -z "$GREP" && { rm -f conftest.in conftest.tmp conftest.nl conftest.out } - func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin + func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" GREP=$func_path_progs_result } @@ -360,6 +374,35 @@ sed_double_backslash="\ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" +# require_check_ifs_backslash +# --------------------------- +# Check if we can use backslash as IFS='\' separator, and set +# $check_ifs_backshlash_broken to ':' or 'false'. +require_check_ifs_backslash=func_require_check_ifs_backslash +func_require_check_ifs_backslash () +{ + _G_save_IFS=$IFS + IFS='\' + _G_check_ifs_backshlash='a\\b' + for _G_i in $_G_check_ifs_backshlash + do + case $_G_i in + a) + check_ifs_backshlash_broken=false + ;; + '') + break + ;; + *) + check_ifs_backshlash_broken=: + break + ;; + esac + done + IFS=$_G_save_IFS + require_check_ifs_backslash=: +} + ## ----------------- ## ## Global variables. ## @@ -580,16 +623,16 @@ if test yes = "$_G_HAVE_PLUSEQ_OP"; then { $debug_cmd - func_quote_for_eval "$2" - eval "$1+=\\ \$func_quote_for_eval_result" + func_quote_arg pretty "$2" + eval "$1+=\\ \$func_quote_arg_result" }' else func_append_quoted () { $debug_cmd - func_quote_for_eval "$2" - eval "$1=\$$1\\ \$func_quote_for_eval_result" + func_quote_arg pretty "$2" + eval "$1=\$$1\\ \$func_quote_arg_result" } fi @@ -1091,85 +1134,203 @@ func_relative_path () } -# func_quote_for_eval ARG... -# -------------------------- -# Aesthetically quote ARGs to be evaled later. -# This function returns two values: -# i) func_quote_for_eval_result -# double-quoted, suitable for a subsequent eval -# ii) func_quote_for_eval_unquoted_result -# has all characters that are still active within double -# quotes backslashified. -func_quote_for_eval () +# func_quote_portable EVAL ARG +# ---------------------------- +# Internal function to portably implement func_quote_arg. Note that we still +# keep attention to performance here so we as much as possible try to avoid +# calling sed binary (so far O(N) complexity as long as func_append is O(1)). +func_quote_portable () { $debug_cmd - func_quote_for_eval_unquoted_result= - func_quote_for_eval_result= - while test 0 -lt $#; do - case $1 in - *[\\\`\"\$]*) - _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; - *) - _G_unquoted_arg=$1 ;; - esac - if test -n "$func_quote_for_eval_unquoted_result"; then - func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" - else - func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" + $require_check_ifs_backslash + + func_quote_portable_result=$2 + + # one-time-loop (easy break) + while true + do + if $1; then + func_quote_portable_result=`$ECHO "$2" | $SED \ + -e "$sed_double_quote_subst" -e "$sed_double_backslash"` + break fi - case $_G_unquoted_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting, command substitution and variable expansion - # for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - _G_quoted_arg=\"$_G_unquoted_arg\" + # Quote for eval. + case $func_quote_portable_result in + *[\\\`\"\$]*) + # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string + # contains the shell wildcard characters. + case $check_ifs_backshlash_broken$func_quote_portable_result in + :*|*[\[\*\?]*) + func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ + | $SED "$sed_quote_subst"` + break + ;; + esac + + func_quote_portable_old_IFS=$IFS + for _G_char in '\' '`' '"' '$' + do + # STATE($1) PREV($2) SEPARATOR($3) + set start "" "" + func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy + IFS=$_G_char + for _G_part in $func_quote_portable_result + do + case $1 in + quote) + func_append func_quote_portable_result "$3$2" + set quote "$_G_part" "\\$_G_char" + ;; + start) + set first "" "" + func_quote_portable_result= + ;; + first) + set quote "$_G_part" "" + ;; + esac + done + done + IFS=$func_quote_portable_old_IFS ;; - *) - _G_quoted_arg=$_G_unquoted_arg - ;; + *) ;; esac - - if test -n "$func_quote_for_eval_result"; then - func_append func_quote_for_eval_result " $_G_quoted_arg" - else - func_append func_quote_for_eval_result "$_G_quoted_arg" - fi - shift + break done + + func_quote_portable_unquoted_result=$func_quote_portable_result + case $func_quote_portable_result in + # double-quote args containing shell metacharacters to delay + # word splitting, command substitution and variable expansion + # for a subsequent eval. + # many bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_portable_result=\"$func_quote_portable_result\" + ;; + esac } -# func_quote_for_expand ARG -# ------------------------- -# Aesthetically quote ARG to be evaled later; same as above, -# but do not quote variable references. -func_quote_for_expand () -{ - $debug_cmd +# func_quotefast_eval ARG +# ----------------------- +# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', +# but optimized for speed. Result is stored in $func_quotefast_eval. +if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then + printf -v _GL_test_printf_tilde %q '~' + if test '\~' = "$_GL_test_printf_tilde"; then + func_quotefast_eval () + { + printf -v func_quotefast_eval_result %q "$1" + } + else + # Broken older Bash implementations. Make those faster too if possible. + func_quotefast_eval () + { + case $1 in + '~'*) + func_quote_portable false "$1" + func_quotefast_eval_result=$func_quote_portable_result + ;; + *) + printf -v func_quotefast_eval_result %q "$1" + ;; + esac + } + fi +else + func_quotefast_eval () + { + func_quote_portable false "$1" + func_quotefast_eval_result=$func_quote_portable_result + } +fi - case $1 in - *[\\\`\"]*) - _G_arg=`$ECHO "$1" | $SED \ - -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; - *) - _G_arg=$1 ;; + +# func_quote_arg MODEs ARG +# ------------------------ +# Quote one ARG to be evaled later. MODEs argument may contain zero or more +# specifiers listed below separated by ',' character. This function returns two +# values: +# i) func_quote_arg_result +# double-quoted (when needed), suitable for a subsequent eval +# ii) func_quote_arg_unquoted_result +# has all characters that are still active within double +# quotes backslashified. Available only if 'unquoted' is specified. +# +# Available modes: +# ---------------- +# 'eval' (default) +# - escape shell special characters +# 'expand' +# - the same as 'eval'; but do not quote variable references +# 'pretty' +# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might +# be used later in func_quote to get output like: 'echo "a b"' instead +# of 'echo a\ b'. This is slower than default on some shells. +# 'unquoted' +# - produce also $func_quote_arg_unquoted_result which does not contain +# wrapping double-quotes. +# +# Examples for 'func_quote_arg pretty,unquoted string': +# +# string | *_result | *_unquoted_result +# ------------+-----------------------+------------------- +# " | \" | \" +# a b | "a b" | a b +# "a b" | "\"a b\"" | \"a b\" +# * | "*" | * +# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" +# +# Examples for 'func_quote_arg pretty,unquoted,expand string': +# +# string | *_result | *_unquoted_result +# --------------+---------------------+-------------------- +# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" +func_quote_arg () +{ + _G_quote_expand=false + case ,$1, in + *,expand,*) + _G_quote_expand=: + ;; esac - case $_G_arg in - # Double-quote args containing shell metacharacters to delay - # word splitting and command substitution for a subsequent eval. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - _G_arg=\"$_G_arg\" + case ,$1, in + *,pretty,*|*,expand,*|*,unquoted,*) + func_quote_portable $_G_quote_expand "$2" + func_quote_arg_result=$func_quote_portable_result + func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result + ;; + *) + # Faster quote-for-eval for some shells. + func_quotefast_eval "$2" + func_quote_arg_result=$func_quotefast_eval_result ;; esac +} + - func_quote_for_expand_result=$_G_arg +# func_quote MODEs ARGs... +# ------------------------ +# Quote all ARGs to be evaled later and join them into single command. See +# func_quote_arg's description for more info. +func_quote () +{ + $debug_cmd + _G_func_quote_mode=$1 ; shift + func_quote_result= + while test 0 -lt $#; do + func_quote_arg "$_G_func_quote_mode" "$1" + if test -n "$func_quote_result"; then + func_append func_quote_result " $func_quote_arg_result" + else + func_append func_quote_result "$func_quote_arg_result" + fi + shift + done } @@ -1215,8 +1376,8 @@ func_show_eval () _G_cmd=$1 _G_fail_exp=${2-':'} - func_quote_for_expand "$_G_cmd" - eval "func_notquiet $func_quote_for_expand_result" + func_quote_arg pretty,expand "$_G_cmd" + eval "func_notquiet $func_quote_arg_result" $opt_dry_run || { eval "$_G_cmd" @@ -1241,8 +1402,8 @@ func_show_eval_locale () _G_fail_exp=${2-':'} $opt_quiet || { - func_quote_for_expand "$_G_cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$_G_cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || { @@ -1369,30 +1530,26 @@ func_lt_ver () # End: #! /bin/sh -# Set a version string for this script. -scriptversion=2014-01-07.03; # UTC - # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 -# Copyright (C) 2010-2015 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. There is NO -# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This is free software. There is NO warranty; not even for +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# Copyright (C) 2010-2019, 2021 Bootstrap Authors +# +# This file is dual licensed under the terms of the MIT license +# <https://opensource.org/license/MIT>, and GPL version 2 or later +# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of +# these licenses when using or redistributing this software or any of +# the files within it. See the URLs above, or the file `LICENSE` +# included in the Bootstrap distribution for the full license texts. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# Please report bugs or propose patches to: +# <https://github.com/gnulib-modules/bootstrap/issues> -# Please report bugs or propose patches to gary@gnu.org. +# Set a version string for this script. +scriptversion=2019-02-19.15; # UTC ## ------ ## @@ -1415,7 +1572,7 @@ scriptversion=2014-01-07.03; # UTC # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file -# starting with '# Written by ' and ending with '# warranty; '. +# starting with '# Written by ' and ending with '# Copyright'. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the @@ -1427,7 +1584,7 @@ scriptversion=2014-01-07.03; # UTC # to display verbose messages only when your user has specified # '--verbose'. # -# After sourcing this file, you can plug processing for additional +# After sourcing this file, you can plug in processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. @@ -1476,8 +1633,8 @@ fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## # This section contains functions for adding, removing, and running hooks -# to the main code. A hook is just a named list of of function, that can -# be run in order later on. +# in the main code. A hook is just a list of function names that can be +# run in order later on. # func_hookable FUNC_NAME # ----------------------- @@ -1510,7 +1667,8 @@ func_add_hook () # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ -# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. +# Remove HOOK_FUNC from the list of hook functions to be called by +# FUNC_NAME. func_remove_hook () { $debug_cmd @@ -1519,10 +1677,28 @@ func_remove_hook () } +# func_propagate_result FUNC_NAME_A FUNC_NAME_B +# --------------------------------------------- +# If the *_result variable of FUNC_NAME_A _is set_, assign its value to +# *_result variable of FUNC_NAME_B. +func_propagate_result () +{ + $debug_cmd + + func_propagate_result_result=: + if eval "test \"\${${1}_result+set}\" = set" + then + eval "${2}_result=\$${1}_result" + else + func_propagate_result_result=false + fi +} + + # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. -# It is assumed that the list of hook functions contains nothing more +# It's assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. @@ -1532,22 +1708,19 @@ func_run_hooks () case " $hookable_fns " in *" $1 "*) ;; - *) func_fatal_error "'$1' does not support hook funcions.n" ;; + *) func_fatal_error "'$1' does not support hook functions." ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do - eval $_G_hook '"$@"' - - # store returned options list back into positional - # parameters for next 'cmd' execution. - eval _G_hook_result=\$${_G_hook}_result - eval set dummy "$_G_hook_result"; shift + func_unset "${_G_hook}_result" + eval $_G_hook '${1+"$@"}' + func_propagate_result $_G_hook func_run_hooks + if $func_propagate_result_result; then + eval set dummy "$func_run_hooks_result"; shift + fi done - - func_quote_for_eval ${1+"$@"} - func_run_hooks_result=$func_quote_for_eval_result } @@ -1557,10 +1730,18 @@ func_run_hooks () ## --------------- ## # In order to add your own option parsing hooks, you must accept the -# full positional parameter list in your hook function, remove any -# options that you action, and then pass back the remaining unprocessed -# options in '<hooked_function_name>_result', escaped suitably for -# 'eval'. Like this: +# full positional parameter list from your hook function. You may remove +# or edit any options that you action, and then pass back the remaining +# unprocessed options in '<hooked_function_name>_result', escaped +# suitably for 'eval'. +# +# The '<hooked_function_name>_result' variable is automatically unset +# before your hook gets called; for best performance, only set the +# *_result variable when necessary (i.e. don't call the 'func_quote' +# function unnecessarily because it can be an expensive operation on some +# machines). +# +# Like this: # # my_options_prep () # { @@ -1570,9 +1751,8 @@ func_run_hooks () # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' -# -# func_quote_for_eval ${1+"$@"} -# my_options_prep_result=$func_quote_for_eval_result +# # No change in '$@' (ignored completely by this hook). Leave +# # my_options_prep_result variable intact. # } # func_add_hook func_options_prep my_options_prep # @@ -1581,25 +1761,36 @@ func_run_hooks () # { # $debug_cmd # -# # Note that for efficiency, we parse as many options as we can +# args_changed=false +# +# # Note that, for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in -# --silent|-s) opt_silent=: ;; +# --silent|-s) opt_silent=: +# args_changed=: +# ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift +# args_changed=: # ;; -# *) set dummy "$_G_opt" "$*"; shift; break ;; +# *) # Make sure the first unrecognised option "$_G_opt" +# # is added back to "$@" in case we need it later, +# # if $args_changed was set to 'true'. +# set dummy "$_G_opt" ${1+"$@"}; shift; break ;; # esac # done # -# func_quote_for_eval ${1+"$@"} -# my_silent_option_result=$func_quote_for_eval_result +# # Only call 'func_quote' here if we processed at least one argument. +# if $args_changed; then +# func_quote eval ${1+"$@"} +# my_silent_option_result=$func_quote_result +# fi # } # func_add_hook func_parse_options my_silent_option # @@ -1610,17 +1801,26 @@ func_run_hooks () # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." -# -# func_quote_for_eval ${1+"$@"} -# my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # -# You'll alse need to manually amend $usage_message to reflect the extra +# You'll also need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. +# func_options_finish [ARG]... +# ---------------------------- +# Finishing the option parse loop (call 'func_options' hooks ATM). +func_options_finish () +{ + $debug_cmd + + func_run_hooks func_options ${1+"$@"} + func_propagate_result func_run_hooks func_options_finish +} + + # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the @@ -1630,17 +1830,27 @@ func_options () { $debug_cmd - func_options_prep ${1+"$@"} - eval func_parse_options \ - ${func_options_prep_result+"$func_options_prep_result"} - eval func_validate_options \ - ${func_parse_options_result+"$func_parse_options_result"} + _G_options_quoted=false - eval func_run_hooks func_options \ - ${func_validate_options_result+"$func_validate_options_result"} + for my_func in options_prep parse_options validate_options options_finish + do + func_unset func_${my_func}_result + func_unset func_run_hooks_result + eval func_$my_func '${1+"$@"}' + func_propagate_result func_$my_func func_options + if $func_propagate_result_result; then + eval set dummy "$func_options_result"; shift + _G_options_quoted=: + fi + done - # save modified positional parameters for caller - func_options_result=$func_run_hooks_result + $_G_options_quoted || { + # As we (func_options) are top-level options-parser function and + # nobody quoted "$@" for us yet, we need to do it explicitly for + # caller. + func_quote eval ${1+"$@"} + func_options_result=$func_quote_result + } } @@ -1649,9 +1859,8 @@ func_options () # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and -# needs to propogate that back to rest of this script, then the complete -# modified list must be put in 'func_run_hooks_result' before -# returning. +# needs to propagate that back to rest of this script, then the complete +# modified list must be put in 'func_run_hooks_result' before returning. func_hookable func_options_prep func_options_prep () { @@ -1662,9 +1871,7 @@ func_options_prep () opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} - - # save modified positional parameters for caller - func_options_prep_result=$func_run_hooks_result + func_propagate_result func_run_hooks func_options_prep } @@ -1676,25 +1883,32 @@ func_parse_options () { $debug_cmd - func_parse_options_result= - + _G_parse_options_requote=false # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} - - # Adjust func_parse_options positional parameters to match - eval set dummy "$func_run_hooks_result"; shift + func_propagate_result func_run_hooks func_parse_options + if $func_propagate_result_result; then + eval set dummy "$func_parse_options_result"; shift + # Even though we may have changed "$@", we passed the "$@" array + # down into the hook and it quoted it for us (because we are in + # this if-branch). No need to quote it again. + _G_parse_options_requote=false + fi # Break out of the loop if we already parsed every option. test $# -gt 0 || break + # We expect that one of the options parsed in this function matches + # and thus we remove _G_opt from "$@" and need to re-quote. + _G_match_parse_options=: _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' - func_echo "enabling shell trace mode" + func_echo "enabling shell trace mode" >&2 $debug_cmd ;; @@ -1704,7 +1918,10 @@ func_parse_options () ;; --warnings|--warning|-W) - test $# = 0 && func_missing_arg $_G_opt && break + if test $# = 0 && func_missing_arg $_G_opt; then + _G_parse_options_requote=: + break + fi case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above @@ -1757,15 +1974,24 @@ func_parse_options () shift ;; - --) break ;; + --) _G_parse_options_requote=: ; break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + *) set dummy "$_G_opt" ${1+"$@"}; shift + _G_match_parse_options=false + break + ;; esac + + if $_G_match_parse_options; then + _G_parse_options_requote=: + fi done - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - func_parse_options_result=$func_quote_for_eval_result + if $_G_parse_options_requote; then + # save modified positional parameters for caller + func_quote eval ${1+"$@"} + func_parse_options_result=$func_quote_result + fi } @@ -1782,12 +2008,10 @@ func_validate_options () test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} + func_propagate_result func_run_hooks func_validate_options # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE - - # save modified positional parameters for caller - func_validate_options_result=$func_run_hooks_result } @@ -1843,8 +2067,8 @@ func_missing_arg () # func_split_equals STRING # ------------------------ -# Set func_split_equals_lhs and func_split_equals_rhs shell variables after -# splitting STRING at the '=' sign. +# Set func_split_equals_lhs and func_split_equals_rhs shell variables +# after splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ @@ -1859,8 +2083,9 @@ then func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} - test "x$func_split_equals_lhs" = "x$1" \ - && func_split_equals_rhs= + if test "x$func_split_equals_lhs" = "x$1"; then + func_split_equals_rhs= + fi }' else # ...otherwise fall back to using expr, which is often a shell builtin. @@ -1870,7 +2095,7 @@ else func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= - test "x$func_split_equals_lhs" = "x$1" \ + test "x$func_split_equals_lhs=" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals @@ -1896,7 +2121,7 @@ else { $debug_cmd - func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` + func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt @@ -1938,31 +2163,44 @@ func_usage_message () # func_version # ------------ # Echo version message to standard output and exit. +# The version message is extracted from the calling file's header +# comments, with leading '# ' stripped: +# 1. First display the progname and version +# 2. Followed by the header comment line matching /^# Written by / +# 3. Then a blank line followed by the first following line matching +# /^# Copyright / +# 4. Immediately followed by any lines between the previous matches, +# except lines preceding the intervening completely blank line. +# For example, see the header comments of this file. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' - /(C)/!b go - :more - /\./!{ - N - s|\n# | | - b more - } - :go - /^# Written by /,/# warranty; / { - s|^# || - s|^# *$|| - s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| - p + /^# Written by /!b + s|^# ||; p; n + + :fwd2blnk + /./ { + n + b fwd2blnk } - /^# Written by / { - s|^# || - p + p; n + + :holdwrnt + s|^# || + s|^# *$|| + /^Copyright /!{ + /./H + n + b holdwrnt } - /^warranty; /q' < "$progpath" + + s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| + G + s|\(\n\)\n*|\1|g + p; q' < "$progpath" exit $? } @@ -1972,12 +2210,12 @@ func_version () # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) -# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" +# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. -scriptversion='(GNU libtool) 2.4.6' +scriptversion='(GNU libtool) 2.4.7' # func_echo ARG... @@ -2068,7 +2306,7 @@ include the following information: compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) - version: $progname (GNU libtool) 2.4.6 + version: $progname (GNU libtool) 2.4.7 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` @@ -2124,7 +2362,7 @@ fi # a configuration failure hint, and exit. func_fatal_configuration () { - func__fatal_error ${1+"$@"} \ + func_fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } @@ -2270,6 +2508,8 @@ libtool_options_prep () nonopt= preserve_args= + _G_rc_lt_options_prep=: + # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) @@ -2293,11 +2533,16 @@ libtool_options_prep () uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; + *) + _G_rc_lt_options_prep=false + ;; esac - # Pass back the list of options. - func_quote_for_eval ${1+"$@"} - libtool_options_prep_result=$func_quote_for_eval_result + if $_G_rc_lt_options_prep; then + # Pass back the list of options. + func_quote eval ${1+"$@"} + libtool_options_prep_result=$func_quote_result + fi } func_add_hook func_options_prep libtool_options_prep @@ -2309,9 +2554,12 @@ libtool_parse_options () { $debug_cmd + _G_rc_lt_parse_options=false + # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do + _G_match_lt_parse_options=: _G_opt=$1 shift case $_G_opt in @@ -2386,15 +2634,20 @@ libtool_parse_options () func_append preserve_args " $_G_opt" ;; - # An option not handled by this hook function: - *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; + # An option not handled by this hook function: + *) set dummy "$_G_opt" ${1+"$@"} ; shift + _G_match_lt_parse_options=false + break + ;; esac + $_G_match_lt_parse_options && _G_rc_lt_parse_options=: done - - # save modified positional parameters for caller - func_quote_for_eval ${1+"$@"} - libtool_parse_options_result=$func_quote_for_eval_result + if $_G_rc_lt_parse_options; then + # save modified positional parameters for caller + func_quote eval ${1+"$@"} + libtool_parse_options_result=$func_quote_result + fi } func_add_hook func_parse_options libtool_parse_options @@ -2451,8 +2704,8 @@ libtool_validate_options () } # Pass back the unparsed argument list - func_quote_for_eval ${1+"$@"} - libtool_validate_options_result=$func_quote_for_eval_result + func_quote eval ${1+"$@"} + libtool_validate_options_result=$func_quote_result } func_add_hook func_validate_options libtool_validate_options @@ -3418,8 +3671,8 @@ func_mode_compile () esac done - func_quote_for_eval "$libobj" - test "X$libobj" != "X$func_quote_for_eval_result" \ + func_quote_arg pretty "$libobj" + test "X$libobj" != "X$func_quote_arg_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" @@ -3492,8 +3745,8 @@ compiler." func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result - func_quote_for_eval "$srcfile" - qsrcfile=$func_quote_for_eval_result + func_quote_arg pretty "$srcfile" + qsrcfile=$func_quote_arg_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then @@ -3648,7 +3901,8 @@ This mode accepts the following additional options: -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking - -Wc,FLAG pass FLAG directly to the compiler + -Wc,FLAG + -Xcompiler FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. @@ -3754,6 +4008,8 @@ The following components of LINK-COMMAND are treated specially: -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler + -Wa,FLAG + -Xassembler FLAG pass linker-specific FLAG directly to the assembler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) @@ -4096,8 +4352,8 @@ func_mode_install () case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. - func_quote_for_eval "$nonopt" - install_prog="$func_quote_for_eval_result " + func_quote_arg pretty "$nonopt" + install_prog="$func_quote_arg_result " arg=$1 shift else @@ -4107,8 +4363,8 @@ func_mode_install () # The real first argument should be the name of the installation program. # Aesthetically quote it. - func_quote_for_eval "$arg" - func_append install_prog "$func_quote_for_eval_result" + func_quote_arg pretty "$arg" + func_append install_prog "$func_quote_arg_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; @@ -4165,12 +4421,12 @@ func_mode_install () esac # Aesthetically quote the argument. - func_quote_for_eval "$arg" - func_append install_prog " $func_quote_for_eval_result" + func_quote_arg pretty "$arg" + func_append install_prog " $func_quote_arg_result" if test -n "$arg2"; then - func_quote_for_eval "$arg2" + func_quote_arg pretty "$arg2" fi - func_append install_shared_prog " $func_quote_for_eval_result" + func_append install_shared_prog " $func_quote_arg_result" done test -z "$install_prog" && \ @@ -4181,8 +4437,8 @@ func_mode_install () if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else - func_quote_for_eval "$install_override_mode" - func_append install_shared_prog " -m $func_quote_for_eval_result" + func_quote_arg pretty "$install_override_mode" + func_append install_shared_prog " -m $func_quote_arg_result" fi fi @@ -4478,8 +4734,8 @@ func_mode_install () relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { - func_quote_for_expand "$relink_command" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$relink_command" + eval "func_echo $func_quote_arg_result" } if eval "$relink_command"; then : else @@ -5258,7 +5514,8 @@ else if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" - qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` + func_quote_arg pretty "$ECHO" + qECHO=$func_quote_arg_result $ECHO "\ # A function that is used when there is no print builtin or printf. @@ -5268,7 +5525,7 @@ func_fallback_echo () \$1 _LTECHO_EOF' } - ECHO=\"$qECHO\" + ECHO=$qECHO fi # Very basic option parsing. These options are (a) specific to @@ -6611,9 +6868,9 @@ func_mode_link () while test "$#" -gt 0; do arg=$1 shift - func_quote_for_eval "$arg" - qarg=$func_quote_for_eval_unquoted_result - func_append libtool_args " $func_quote_for_eval_result" + func_quote_arg pretty,unquoted "$arg" + qarg=$func_quote_arg_unquoted_result + func_append libtool_args " $func_quote_arg_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then @@ -6849,6 +7106,13 @@ func_mode_link () prev= continue ;; + xassembler) + func_append compiler_flags " -Xassembler $qarg" + prev= + func_append compile_command " -Xassembler $qarg" + func_append finalize_command " -Xassembler $qarg" + continue + ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" @@ -7019,7 +7283,7 @@ func_mode_link () # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; @@ -7039,7 +7303,7 @@ func_mode_link () esac elif test X-lc_r = "X$arg"; then case $host in - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -7069,8 +7333,20 @@ func_mode_link () prev=xcompiler continue ;; - - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. + -pthread) + case $host in + *solaris2*) ;; + *) + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) func_append new_inherited_linker_flags " $arg" ;; + esac + ;; + esac + continue + ;; + -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" @@ -7211,9 +7487,9 @@ func_mode_link () save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs - func_quote_for_eval "$flag" - func_append arg " $func_quote_for_eval_result" - func_append compiler_flags " $func_quote_for_eval_result" + func_quote_arg pretty "$flag" + func_append arg " $func_quote_arg_result" + func_append compiler_flags " $func_quote_arg_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" @@ -7227,16 +7503,21 @@ func_mode_link () save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs - func_quote_for_eval "$flag" - func_append arg " $wl$func_quote_for_eval_result" - func_append compiler_flags " $wl$func_quote_for_eval_result" - func_append linker_flags " $func_quote_for_eval_result" + func_quote_arg pretty "$flag" + func_append arg " $wl$func_quote_arg_result" + func_append compiler_flags " $wl$func_quote_arg_result" + func_append linker_flags " $func_quote_arg_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; + -Xassembler) + prev=xassembler + continue + ;; + -Xcompiler) prev=xcompiler continue @@ -7254,8 +7535,8 @@ func_mode_link () # -msg_* for osf cc -msg_*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; # Flags to be passed through unchanged, with rationale: @@ -7272,12 +7553,17 @@ func_mode_link () # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization + # -specs=* GCC specs files # -stdlib=* select c++ std lib with clang + # -fsanitize=* Clang/GCC memory and address sanitizer + # -fuse-ld=* Linker select flags for GCC + # -Wa,* Pass flags directly to the assembler -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ + -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" @@ -7298,15 +7584,15 @@ func_mode_link () continue else # Otherwise treat like 'Some other compiler flag' below - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result fi ;; # Some other compiler flag. -* | +*) - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; *.$objext) @@ -7426,8 +7712,8 @@ func_mode_link () *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. - func_quote_for_eval "$arg" - arg=$func_quote_for_eval_result + func_quote_arg pretty "$arg" + arg=$func_quote_arg_result ;; esac # arg @@ -8632,7 +8918,7 @@ func_mode_link () test CXX = "$tagname" && { case $host_os in linux*) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi @@ -8805,7 +9091,7 @@ func_mode_link () # case $version_type in # correct linux to gnu/linux during the next big refactor - darwin|freebsd-elf|linux|osf|windows|none) + darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor @@ -8896,7 +9182,7 @@ func_mode_link () versuffix=.$current.$revision ;; - freebsd-elf) + freebsd-elf | midnightbsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision @@ -9122,7 +9408,7 @@ func_mode_link () *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; - *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) @@ -9933,8 +10219,8 @@ EOF for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? @@ -10027,8 +10313,8 @@ EOF eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { - func_quote_for_expand "$cmd" - eval "func_echo $func_quote_for_expand_result" + func_quote_arg expand,pretty "$cmd" + eval "func_echo $func_quote_arg_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? @@ -10502,12 +10788,13 @@ EOF elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + func_quote_arg pretty "$var_value" + relink_command="$var=$func_quote_arg_result; export $var; $relink_command" fi done - relink_command="(cd `pwd`; $relink_command)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + func_quote eval cd "`pwd`" + func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" + relink_command=$func_quote_arg_unquoted_result fi # Only actually do things if not in dry run mode. @@ -10747,13 +11034,15 @@ EOF elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else - func_quote_for_eval "$var_value" - relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + func_quote_arg pretty,unquoted "$var_value" + relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" fi done # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" - relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` + func_quote eval cd "`pwd`" + relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + func_quote_arg pretty,unquoted "$relink_command" + relink_command=$func_quote_arg_unquoted_result if test yes = "$hardcode_automatic"; then relink_command= fi diff --git a/build-aux/missing b/build-aux/missing index c6e3795..1fe1611 100755 --- a/build-aux/missing +++ b/build-aux/missing @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1996-2017 Free Software Foundation, Inc. +# Copyright (C) 1996-2021 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2016-01-11.22; # UTC # GNU General 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -101,9 +101,9 @@ else exit $st fi -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software +perl_URL=https://www.perl.org/ +flex_URL=https://github.com/westes/flex +gnu_software_URL=https://www.gnu.org/software program_details () { @@ -207,7 +207,7 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \ exit $st # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/build-aux/test-driver b/build-aux/test-driver index 8e63ebd..0fa6395 100755 --- a/build-aux/test-driver +++ b/build-aux/test-driver @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2016-01-11.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2011-2017 Free Software Foundation, Inc. +# Copyright (C) 2011-2021 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ scriptversion=2016-01-11.22; # UTC # GNU General 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/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -42,11 +42,13 @@ print_usage () { cat <<END Usage: - test-driver --test-name=NAME --log-file=PATH --trs-file=PATH - [--expect-failure={yes|no}] [--color-tests={yes|no}] - [--enable-hard-errors={yes|no}] [--] + test-driver --test-name NAME --log-file PATH --trs-file PATH + [--expect-failure {yes|no}] [--color-tests {yes|no}] + [--enable-hard-errors {yes|no}] [--] TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS] + The '--test-name', '--log-file' and '--trs-file' options are mandatory. +See the GNU Automake documentation for information. END } @@ -59,7 +61,7 @@ enable_hard_errors=yes while test $# -gt 1; do arg=${1%=*} val=${1#*=} - if [ $arg == $val ]; then + if [ $arg = $val ]; then val=$2 shift fi @@ -75,7 +77,7 @@ while test $# -gt 1; do --) break;; -*) usage_error "invalid option: '$1'";; esac - [[ $arg != $val ]] && shift + [ $arg != $val ] && shift done missing_opts= @@ -108,8 +110,11 @@ trap "st=130; $do_exit" 2 trap "st=141; $do_exit" 13 trap "st=143; $do_exit" 15 -# Test script is run here. -"$@" >$log_file 2>&1 +# Test script is run here. We create the file first, then append to it, +# to ameliorate tests themselves also writing to the log file. Our tests +# don't, but others can (automake bug#35762). +: >"$log_file" +"$@" >>"$log_file" 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then @@ -131,7 +136,7 @@ esac # know whether the test passed or failed simply by looking at the '.log' # file, without the need of also peaking into the corresponding '.trs' # file (automake bug#11814). -echo "$res $test_name (exit status: $estatus)" >>$log_file +echo "$res $test_name (exit status: $estatus)" >>"$log_file" # Report outcome to console. echo "${col}${res}${std}: $test_name" @@ -145,7 +150,7 @@ echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC0" diff --git a/config.h.in b/config.h.in index 614b52f..112ecb4 100644 --- a/config.h.in +++ b/config.h.in @@ -24,18 +24,27 @@ /* Define to 1 if you have the `getppid' function. */ #undef HAVE_GETPPID +/* Define to 1 if you have the `initgroups' function. */ +#undef HAVE_INITGROUPS + /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the `pipe' function. */ #undef HAVE_PIPE +/* Define to 1 if you have the `posix_fadvise' function. */ +#undef HAVE_POSIX_FADVISE + +/* Define to 1 if you have the `setgid' function. */ +#undef HAVE_SETGID + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the <stdio.h> header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the <stdlib.h> header file. */ #undef HAVE_STDLIB_H @@ -84,6 +93,9 @@ /* Define to 1 if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have the <sys/un.h> header file. */ +#undef HAVE_SYS_UN_H + /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H @@ -126,7 +138,9 @@ /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* Version number of package */ @@ -1,9 +1,10 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for libHX 3.25. +# Generated by GNU Autoconf 2.71 for libHX 4.10. # # -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, +# Inc. # # # This configure script is free software; the Free Software Foundation @@ -14,14 +15,16 @@ # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else +else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( @@ -31,46 +34,46 @@ esac fi + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi +if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then +if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || @@ -79,13 +82,6 @@ if test "${PATH_SEPARATOR+set}" != set; then fi -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( @@ -94,8 +90,12 @@ case $0 in #(( for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS @@ -107,30 +107,10 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. @@ -152,20 +132,22 @@ esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 +printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + as_bourne_compatible="as_nop=: +if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST -else +else \$as_nop case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( @@ -185,12 +167,15 @@ as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : +if ( set x; as_fn_ret_success y && test x = \"\$1\" ) +then : -else +else \$as_nop exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 +blah=\$(echo \$(echo blah)) +test x\"\$blah\" = xblah || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO @@ -205,30 +190,38 @@ test -x / || exit 1" test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : + if (eval "$as_required") 2>/dev/null +then : as_have_required=yes -else +else $as_nop as_have_required=no fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null +then : -else +else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base + as_shell=$as_dir$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null +then : CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null +then : break 2 fi fi @@ -236,14 +229,21 @@ fi esac as_found=false done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } IFS=$as_save_IFS +if $as_found +then : +else $as_nop + if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null +then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi +fi - if test "x$CONFIG_SHELL" != x; then : + + if test "x$CONFIG_SHELL" != x +then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also @@ -261,18 +261,19 @@ esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." + if test x$as_have_required = xno +then : + printf "%s\n" "$0: This script requires a shell more modern than all" + printf "%s\n" "$0: the shells that I found on your system." + if test ${ZSH_VERSION+y} ; then + printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" + printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, + printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." @@ -299,6 +300,7 @@ as_fn_unset () } as_unset=as_fn_unset + # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -316,6 +318,14 @@ as_fn_exit () as_fn_set_status $1 exit $1 } # as_fn_exit +# as_fn_nop +# --------- +# Do nothing but, unlike ":", preserve the value of $?. +as_fn_nop () +{ + return $? +} +as_nop=as_fn_nop # as_fn_mkdir_p # ------------- @@ -330,7 +340,7 @@ as_fn_mkdir_p () as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -339,7 +349,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | +printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -378,12 +388,13 @@ as_fn_executable_p () # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : eval 'as_fn_append () { eval $1+=\$2 }' -else +else $as_nop as_fn_append () { eval $1=\$$1\$2 @@ -395,18 +406,27 @@ fi # as_fn_append # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : eval 'as_fn_arith () { as_val=$(( $* )) }' -else +else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith +# as_fn_nop +# --------- +# Do nothing but, unlike ":", preserve the value of $?. +as_fn_nop () +{ + return $? +} +as_nop=as_fn_nop # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- @@ -418,9 +438,9 @@ as_fn_error () as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $2" >&2 + printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -447,7 +467,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | +printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -491,7 +511,7 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall @@ -505,6 +525,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits exit } + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) @@ -518,6 +542,13 @@ case `echo -n x` in #((((( ECHO_N='-n';; esac +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + + rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -587,47 +618,43 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libHX' PACKAGE_TARNAME='libhx' -PACKAGE_VERSION='3.25' -PACKAGE_STRING='libHX 3.25' +PACKAGE_VERSION='4.10' +PACKAGE_STRING='libHX 4.10' PACKAGE_BUGREPORT='' PACKAGE_URL='' # Factoring default headers for most tests. ac_includes_default="\ -#include <stdio.h> -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> +#include <stddef.h> +#ifdef HAVE_STDIO_H +# include <stdio.h> #endif -#ifdef HAVE_SYS_STAT_H -# include <sys/stat.h> -#endif -#ifdef STDC_HEADERS +#ifdef HAVE_STDLIB_H # include <stdlib.h> -# include <stddef.h> -#else -# ifdef HAVE_STDLIB_H -# include <stdlib.h> -# endif #endif #ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include <memory.h> -# endif # include <string.h> #endif -#ifdef HAVE_STRINGS_H -# include <strings.h> -#endif #ifdef HAVE_INTTYPES_H # include <inttypes.h> #endif #ifdef HAVE_STDINT_H # include <stdint.h> #endif +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif #ifdef HAVE_UNISTD_H # include <unistd.h> #endif" +ac_header_c_list= ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS @@ -635,11 +662,6 @@ LIBOBJS regular_CXXFLAGS regular_CFLAGS regular_CPPFLAGS -BUILD_DOCS_FALSE -BUILD_DOCS_TRUE -LYX -B_PROC_FALSE -B_PROC_TRUE libsocket_LIBS libpthread_LIBS librt_LIBS @@ -654,7 +676,6 @@ MINGW32_TRUE HAVE_CXX_FALSE HAVE_CXX_TRUE CXXCPP -CPP LT_SYS_LIBRARY_PATH OTOOL64 OTOOL @@ -665,6 +686,7 @@ MANIFEST_TOOL RANLIB DLLTOOL OBJDUMP +FILECMD LN_S NM ac_ct_DUMPBIN @@ -698,7 +720,6 @@ am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE -am__quote am__include DEPDIR OBJEXT @@ -712,6 +733,9 @@ AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V +CSCOPE +ETAGS +CTAGS am__untar am__tar AMTAR @@ -754,6 +778,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -772,7 +797,8 @@ PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR -SHELL' +SHELL +am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking @@ -800,7 +826,6 @@ CXX CXXFLAGS CCC LT_SYS_LIBRARY_PATH -CPP CXXCPP' @@ -840,6 +865,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -869,8 +895,6 @@ do *) ac_optarg=yes ;; esac - # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; @@ -911,9 +935,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" @@ -937,9 +961,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" @@ -1092,6 +1116,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1141,9 +1174,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" @@ -1157,9 +1190,9 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: \`$ac_useropt'" ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" @@ -1203,9 +1236,9 @@ Try \`$0 --help' for more information" *) # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; @@ -1221,7 +1254,7 @@ if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1229,7 +1262,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1285,7 +1318,7 @@ $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | +printf "%s\n" X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -1342,7 +1375,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libHX 3.25 to adapt to many kinds of systems. +\`configure' configures libHX 4.10 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1382,6 +1415,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1412,7 +1446,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libHX 3.25:";; + short | recursive ) echo "Configuration of libHX 4.10:";; esac cat <<\_ACEOF @@ -1458,7 +1492,6 @@ Some influential environment variables: CXXFLAGS C++ compiler flags LT_SYS_LIBRARY_PATH User-defined run-time library search path. - CPP C preprocessor CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help @@ -1480,9 +1513,9 @@ if test "$ac_init_help" = "recursive"; then case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -1510,7 +1543,8 @@ esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. + # Check for configure.gnu first; this name is used for a wrapper for + # Metaconfig's "Configure" on case-insensitive file systems. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive @@ -1518,7 +1552,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix echo && $SHELL "$ac_srcdir/configure" --help=recursive else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done @@ -1527,10 +1561,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libHX configure 3.25 -generated by GNU Autoconf 2.69 +libHX configure 4.10 +generated by GNU Autoconf 2.71 -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2021 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1547,14 +1581,14 @@ fi ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext + rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1562,14 +1596,15 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then : + } && test -s conftest.$ac_objext +then : ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1585,14 +1620,14 @@ fi ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext + rm -f conftest.$ac_objext conftest.beam if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1600,14 +1635,15 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err - } && test -s conftest.$ac_objext; then : + } && test -s conftest.$ac_objext +then : ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1623,14 +1659,14 @@ fi ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1638,17 +1674,18 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext - }; then : + } +then : ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1670,120 +1707,44 @@ fi ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : eval "$3=yes" -else +else $as_nop eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +printf %s "checking for $2... " >&6; } +if eval test \${$3+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case <limits.h> declares $2. @@ -1791,16 +1752,9 @@ else #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - <limits.h> exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif + which can conflict with char $2 (); below. */ +#include <limits.h> #undef $2 /* Override any GCC internal prototype to avoid an error. @@ -1818,24 +1772,25 @@ choke me #endif int -main () +main (void) { return $2 (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : eval "$3=yes" -else +else $as_nop eval "$3=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func @@ -1852,7 +1807,7 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1860,14 +1815,15 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err - }; then : + } +then : ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1883,14 +1839,14 @@ fi ac_fn_cxx_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -1898,17 +1854,18 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext - }; then : + } +then : ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 @@ -1923,92 +1880,48 @@ fi } # ac_fn_cxx_try_link -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that +# executables *can* be run. +ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: program exited with status $ac_status" >&5 + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval -} # ac_fn_c_check_header_mongrel +} # ac_fn_c_try_run # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- @@ -2024,7 +1937,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main () +main (void) { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; @@ -2034,14 +1947,15 @@ return test_array [0]; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main () +main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; @@ -2051,9 +1965,10 @@ return test_array [0]; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_hi=$ac_mid; break -else +else $as_nop as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= @@ -2061,14 +1976,14 @@ else fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done -else +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main () +main (void) { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; @@ -2078,14 +1993,15 @@ return test_array [0]; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int -main () +main (void) { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; @@ -2095,9 +2011,10 @@ return test_array [0]; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_lo=$ac_mid; break -else +else $as_nop as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= @@ -2105,14 +2022,14 @@ else fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done -else +else $as_nop ac_lo= ac_hi= fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val @@ -2120,7 +2037,7 @@ while test "x$ac_lo" != "x$ac_hi"; do /* end confdefs.h. */ $4 int -main () +main (void) { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; @@ -2130,12 +2047,13 @@ return test_array [0]; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_hi=$ac_mid -else +else $as_nop as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; @@ -2145,12 +2063,12 @@ esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } +static long int longval (void) { return $2; } +static unsigned long int ulongval (void) { return $2; } #include <stdio.h> #include <stdlib.h> int -main () +main (void) { FILE *f = fopen ("conftest.val", "w"); @@ -2178,9 +2096,10 @@ main () return 0; } _ACEOF -if ac_fn_c_try_run "$LINENO"; then : +if ac_fn_c_try_run "$LINENO" +then : echo >>conftest.val; read $3 <conftest.val; ac_retval=0 -else +else $as_nop ac_retval=1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ @@ -2200,16 +2119,17 @@ rm -f conftest.val ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -$as_echo_n "checking for $2.$3... " >&6; } -if eval \${$4+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +printf %s "checking for $2.$3... " >&6; } +if eval test \${$4+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int -main () +main (void) { static $2 ac_aggr; if (ac_aggr.$3) @@ -2218,14 +2138,15 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : eval "$4=yes" -else +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int -main () +main (void) { static $2 ac_aggr; if (sizeof ac_aggr.$3) @@ -2234,29 +2155,50 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : eval "$4=yes" -else +else $as_nop eval "$4=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi eval ac_res=\$$4 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member +ac_configure_args_raw= +for ac_arg +do + case $ac_arg in + *\'*) + ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append ac_configure_args_raw " '$ac_arg'" +done + +case $ac_configure_args_raw in + *$as_nl*) + ac_safe_unquote= ;; + *) + ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. + ac_unsafe_a="$ac_unsafe_z#~" + ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" + ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; +esac + cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libHX $as_me 3.25, which was -generated by GNU Autoconf 2.69. Invocation command line was +It was created by libHX $as_me 4.10, which was +generated by GNU Autoconf 2.71. Invocation command line was - $ $0 $@ + $ $0$ac_configure_args_raw _ACEOF exec 5>>config.log @@ -2289,8 +2231,12 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + printf "%s\n" "PATH: $as_dir" done IFS=$as_save_IFS @@ -2325,7 +2271,7 @@ do | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; @@ -2360,11 +2306,13 @@ done # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? + # Sanitize IFS. + IFS=" "" $as_nl" # Save into config.log some information that might help in debugging. { echo - $as_echo "## ---------------- ## + printf "%s\n" "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo @@ -2375,8 +2323,8 @@ trap 'exit_status=$? case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( @@ -2400,7 +2348,7 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - $as_echo "## ----------------- ## + printf "%s\n" "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo @@ -2408,14 +2356,14 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - $as_echo "$ac_var='\''$ac_val'\''" + printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## + printf "%s\n" "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo @@ -2423,15 +2371,15 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; do eval ac_val=\$$ac_var case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac - $as_echo "$ac_var='\''$ac_val'\''" + printf "%s\n" "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then - $as_echo "## ----------- ## + printf "%s\n" "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo @@ -2439,8 +2387,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; echo fi test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" + printf "%s\n" "$as_me: caught signal $ac_signal" + printf "%s\n" "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && @@ -2454,63 +2402,48 @@ ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h -$as_echo "/* confdefs.h */" > confdefs.h +printf "%s\n" "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF +printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF +printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF +printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF +printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF +printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF +printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac + ac_site_files="$CONFIG_SITE" elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site + ac_site_files="$prefix/share/config.site $prefix/etc/config.site" else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site + ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" + +for ac_site_file in $ac_site_files do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} + case $ac_site_file in #( + */*) : + ;; #( + *) : + ac_site_file=./$ac_site_file ;; +esac + if test -f "$ac_site_file" && test -r "$ac_site_file"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi @@ -2520,19 +2453,650 @@ if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +printf "%s\n" "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +printf "%s\n" "$as_me: creating cache $cache_file" >&6;} >$cache_file fi +# Test code for whether the C compiler supports C89 (global declarations) +ac_c_conftest_c89_globals=' +/* Does the compiler advertise C89 conformance? + Do not test the value of __STDC__, because some compilers set it to 0 + while being otherwise adequately conformant. */ +#if !defined __STDC__ +# error "Compiler does not advertise C89 conformance" +#endif + +#include <stddef.h> +#include <stdarg.h> +struct stat; +/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ +struct buf { int x; }; +struct buf * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not \xHH hex character constants. + These do not provoke an error unfortunately, instead are silently treated + as an "x". The following induces an error, until -std is added to get + proper ANSI mode. Curiously \x00 != x always comes out true, for an + array size at least. It is necessary to write \x00 == 0 to get something + that is true only with -std. */ +int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) '\''x'\'' +int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), + int, int);' + +# Test code for whether the C compiler supports C89 (body of main). +ac_c_conftest_c89_main=' +ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); +' + +# Test code for whether the C compiler supports C99 (global declarations) +ac_c_conftest_c99_globals=' +// Does the compiler advertise C99 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L +# error "Compiler does not advertise C99 conformance" +#endif + +#include <stdbool.h> +extern int puts (const char *); +extern int printf (const char *, ...); +extern int dprintf (int, const char *, ...); +extern void *malloc (size_t); + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +// dprintf is used instead of fprintf to avoid needing to declare +// FILE and stderr. +#define debug(...) dprintf (2, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + #error "your preprocessor is broken" +#endif +#if BIG_OK +#else + #error "your preprocessor is broken" +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static bool +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str = ""; + int number = 0; + float fnumber = 0; + + while (*format) + { + switch (*format++) + { + case '\''s'\'': // string + str = va_arg (args_copy, const char *); + break; + case '\''d'\'': // int + number = va_arg (args_copy, int); + break; + case '\''f'\'': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); + + return *str && number && fnumber; +} +' + +# Test code for whether the C compiler supports C99 (body of main). +ac_c_conftest_c99_main=' + // Check bool. + _Bool success = false; + success |= (argc != 0); + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[0] = argv[0][0]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' + || dynamic_array[ni.number - 1] != 543); +' + +# Test code for whether the C compiler supports C11 (global declarations) +ac_c_conftest_c11_globals=' +// Does the compiler advertise C11 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L +# error "Compiler does not advertise C11 conformance" +#endif + +// Check _Alignas. +char _Alignas (double) aligned_as_double; +char _Alignas (0) no_special_alignment; +extern char aligned_as_int; +char _Alignas (0) _Alignas (int) aligned_as_int; + +// Check _Alignof. +enum +{ + int_alignment = _Alignof (int), + int_array_alignment = _Alignof (int[100]), + char_alignment = _Alignof (char) +}; +_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); + +// Check _Noreturn. +int _Noreturn does_not_return (void) { for (;;) continue; } + +// Check _Static_assert. +struct test_static_assert +{ + int x; + _Static_assert (sizeof (int) <= sizeof (long int), + "_Static_assert does not work in struct"); + long int y; +}; + +// Check UTF-8 literals. +#define u8 syntax error! +char const utf8_literal[] = u8"happens to be ASCII" "another string"; + +// Check duplicate typedefs. +typedef long *long_ptr; +typedef long int *long_ptr; +typedef long_ptr long_ptr; + +// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. +struct anonymous +{ + union { + struct { int i; int j; }; + struct { int k; long int l; } w; + }; + int m; +} v1; +' + +# Test code for whether the C compiler supports C11 (body of main). +ac_c_conftest_c11_main=' + _Static_assert ((offsetof (struct anonymous, i) + == offsetof (struct anonymous, w.k)), + "Anonymous union alignment botch"); + v1.i = 2; + v1.w.k = 5; + ok |= v1.i != 5; +' + +# Test code for whether the C compiler supports C11 (complete). +ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} +${ac_c_conftest_c99_globals} +${ac_c_conftest_c11_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + ${ac_c_conftest_c99_main} + ${ac_c_conftest_c11_main} + return ok; +} +" + +# Test code for whether the C compiler supports C99 (complete). +ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} +${ac_c_conftest_c99_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + ${ac_c_conftest_c99_main} + return ok; +} +" + +# Test code for whether the C compiler supports C89 (complete). +ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_c_conftest_c89_main} + return ok; +} +" + +# Test code for whether the C++ compiler supports C++98 (global declarations) +ac_cxx_conftest_cxx98_globals=' +// Does the compiler advertise C++98 conformance? +#if !defined __cplusplus || __cplusplus < 199711L +# error "Compiler does not advertise C++98 conformance" +#endif + +// These inclusions are to reject old compilers that +// lack the unsuffixed header files. +#include <cstdlib> +#include <exception> + +// <cassert> and <cstring> are *not* freestanding headers in C++98. +extern void assert (int); +namespace std { + extern int strcmp (const char *, const char *); +} + +// Namespaces, exceptions, and templates were all added after "C++ 2.0". +using std::exception; +using std::strcmp; + +namespace { + +void test_exception_syntax() +{ + try { + throw "test"; + } catch (const char *s) { + // Extra parentheses suppress a warning when building autoconf itself, + // due to lint rules shared with more typical C programs. + assert (!(strcmp) (s, "test")); + } +} + +template <typename T> struct test_template +{ + T const val; + explicit test_template(T t) : val(t) {} + template <typename U> T add(U u) { return static_cast<T>(u) + val; } +}; + +} // anonymous namespace +' + +# Test code for whether the C++ compiler supports C++98 (body of main) +ac_cxx_conftest_cxx98_main=' + assert (argc); + assert (! argv[0]); +{ + test_exception_syntax (); + test_template<double> tt (2.0); + assert (tt.add (4) == 6.0); + assert (true && !false); +} +' + +# Test code for whether the C++ compiler supports C++11 (global declarations) +ac_cxx_conftest_cxx11_globals=' +// Does the compiler advertise C++ 2011 conformance? +#if !defined __cplusplus || __cplusplus < 201103L +# error "Compiler does not advertise C++11 conformance" +#endif + +namespace cxx11test +{ + constexpr int get_val() { return 20; } + + struct testinit + { + int i; + double d; + }; + + class delegate + { + public: + delegate(int n) : n(n) {} + delegate(): delegate(2354) {} + + virtual int getval() { return this->n; }; + protected: + int n; + }; + + class overridden : public delegate + { + public: + overridden(int n): delegate(n) {} + virtual int getval() override final { return this->n * 2; } + }; + + class nocopy + { + public: + nocopy(int i): i(i) {} + nocopy() = default; + nocopy(const nocopy&) = delete; + nocopy & operator=(const nocopy&) = delete; + private: + int i; + }; + + // for testing lambda expressions + template <typename Ret, typename Fn> Ret eval(Fn f, Ret v) + { + return f(v); + } + + // for testing variadic templates and trailing return types + template <typename V> auto sum(V first) -> V + { + return first; + } + template <typename V, typename... Args> auto sum(V first, Args... rest) -> V + { + return first + sum(rest...); + } +} +' + +# Test code for whether the C++ compiler supports C++11 (body of main) +ac_cxx_conftest_cxx11_main=' +{ + // Test auto and decltype + auto a1 = 6538; + auto a2 = 48573953.4; + auto a3 = "String literal"; + + int total = 0; + for (auto i = a3; *i; ++i) { total += *i; } + + decltype(a2) a4 = 34895.034; +} +{ + // Test constexpr + short sa[cxx11test::get_val()] = { 0 }; +} +{ + // Test initializer lists + cxx11test::testinit il = { 4323, 435234.23544 }; +} +{ + // Test range-based for + int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, + 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; + for (auto &x : array) { x += 23; } +} +{ + // Test lambda expressions + using cxx11test::eval; + assert (eval ([](int x) { return x*2; }, 21) == 42); + double d = 2.0; + assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0); + assert (d == 5.0); + assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0); + assert (d == 5.0); +} +{ + // Test use of variadic templates + using cxx11test::sum; + auto a = sum(1); + auto b = sum(1, 2); + auto c = sum(1.0, 2.0, 3.0); +} +{ + // Test constructor delegation + cxx11test::delegate d1; + cxx11test::delegate d2(); + cxx11test::delegate d3(45); +} +{ + // Test override and final + cxx11test::overridden o1(55464); +} +{ + // Test nullptr + char *c = nullptr; +} +{ + // Test template brackets + test_template<::test_template<int>> v(test_template<int>(12)); +} +{ + // Unicode literals + char const *utf8 = u8"UTF-8 string \u2500"; + char16_t const *utf16 = u"UTF-8 string \u2500"; + char32_t const *utf32 = U"UTF-32 string \u2500"; +} +' + +# Test code for whether the C compiler supports C++11 (complete). +ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals} +${ac_cxx_conftest_cxx11_globals} + +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_cxx_conftest_cxx98_main} + ${ac_cxx_conftest_cxx11_main} + return ok; +} +" + +# Test code for whether the C compiler supports C++98 (complete). +ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals} +int +main (int argc, char **argv) +{ + int ok = 0; + ${ac_cxx_conftest_cxx98_main} + return ok; +} +" + +as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H" +as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H" +as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H" +as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H" +as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H" +as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H" +as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" +as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" +as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H" + +# Auxiliary files required by this configure script. +ac_aux_files="config.guess config.sub ltmain.sh ar-lib compile missing install-sh" + +# Locations in which to look for auxiliary files. +ac_aux_dir_candidates="${srcdir}/build-aux" + +# Search for a directory containing all of the required auxiliary files, +# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates. +# If we don't find one directory that contains all the files we need, +# we report the set of missing files from the *first* directory in +# $ac_aux_dir_candidates and give up. +ac_missing_aux_files="" +ac_first_candidate=: +printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5 +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in $ac_aux_dir_candidates +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + as_found=: + + printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5 + ac_aux_dir_found=yes + ac_install_sh= + for ac_aux in $ac_aux_files + do + # As a special case, if "install-sh" is required, that requirement + # can be satisfied by any of "install-sh", "install.sh", or "shtool", + # and $ac_install_sh is set appropriately for whichever one is found. + if test x"$ac_aux" = x"install-sh" + then + if test -f "${as_dir}install-sh"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5 + ac_install_sh="${as_dir}install-sh -c" + elif test -f "${as_dir}install.sh"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5 + ac_install_sh="${as_dir}install.sh -c" + elif test -f "${as_dir}shtool"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5 + ac_install_sh="${as_dir}shtool install -c" + else + ac_aux_dir_found=no + if $ac_first_candidate; then + ac_missing_aux_files="${ac_missing_aux_files} install-sh" + else + break + fi + fi + else + if test -f "${as_dir}${ac_aux}"; then + printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5 + else + ac_aux_dir_found=no + if $ac_first_candidate; then + ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}" + else + break + fi + fi + fi + done + if test "$ac_aux_dir_found" = yes; then + ac_aux_dir="$as_dir" + break + fi + ac_first_candidate=false + + as_found=false +done +IFS=$as_save_IFS +if $as_found +then : + +else $as_nop + as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 +fi + + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +if test -f "${ac_aux_dir}config.guess"; then + ac_config_guess="$SHELL ${ac_aux_dir}config.guess" +fi +if test -f "${ac_aux_dir}config.sub"; then + ac_config_sub="$SHELL ${ac_aux_dir}config.sub" +fi +if test -f "$ac_aux_dir/configure"; then + ac_configure="$SHELL ${ac_aux_dir}configure" +fi + # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false @@ -2543,12 +3107,12 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) @@ -2557,24 +3121,24 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -2584,11 +3148,12 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' + and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2601,39 +3166,13 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_aux_dir= -for ac_dir in build-aux "$srcdir"/build-aux; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi -done -if test -z "$ac_aux_dir"; then - as_fn_error $? "cannot find install-sh, install.sh, or shtool in build-aux \"$srcdir\"/build-aux" "$LINENO" 5 -fi -# These three variables are undocumented and unsupported, -# and are intended to be withdrawn in a future Autoconf release. -# They can cause serious problems if a builder's source tree is in a directory -# whose full name contains unusual characters. -ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. -ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. -ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. +ac_config_headers="$ac_config_headers config.h" -ac_config_headers="$ac_config_headers config.h" -# Find a good install program. We prefer a C program (faster), + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install @@ -2647,20 +3186,25 @@ ac_config_headers="$ac_config_headers config.h" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 -$as_echo_n "checking for a BSD-compatible install... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +printf %s "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if ${ac_cv_path_install+:} false; then : - $as_echo_n "(cached) " >&6 -else +if test ${ac_cv_path_install+y} +then : + printf %s "(cached) " >&6 +else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in #(( - ./ | .// | /[cC]/* | \ + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + # Account for fact that we put trailing slashes in our PATH walk. +case $as_dir in #(( + ./ | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; @@ -2670,13 +3214,13 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then if test $ac_prog = install && - grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && - grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else @@ -2684,12 +3228,12 @@ case $as_dir/ in #(( echo one > conftest.one echo two > conftest.two mkdir conftest.dir - if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then - ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c" break 3 fi fi @@ -2705,7 +3249,7 @@ IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi - if test "${ac_cv_path_install+set}" = set; then + if test ${ac_cv_path_install+y}; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a @@ -2715,8 +3259,8 @@ fi INSTALL=$ac_install_sh fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 -$as_echo "$INSTALL" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +printf "%s\n" "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -2726,10 +3270,10 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -am__api_version='1.15' +am__api_version='1.16' -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 -$as_echo_n "checking whether build environment is sane... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +printf %s "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -2783,8 +3327,8 @@ else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= @@ -2803,26 +3347,23 @@ test "$program_suffix" != NONE && # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' -program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` +program_transform_name=`printf "%s\n" "$program_transform_name" | sed "$ac_script"` + # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` -if test x"${MISSING+set}" != xset; then - case $am_aux_dir in - *\ * | *\ *) - MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; - *) - MISSING="\${SHELL} $am_aux_dir/missing" ;; - esac + + if test x"${MISSING+set}" != xset; then + MISSING="\${SHELL} '$am_aux_dir/missing'" fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +printf "%s\n" "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then @@ -2842,11 +3383,12 @@ if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else @@ -2854,11 +3396,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2869,11 +3415,11 @@ fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -2882,11 +3428,12 @@ if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else @@ -2894,11 +3441,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -2909,11 +3460,11 @@ fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then @@ -2921,8 +3472,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP @@ -2934,25 +3485,31 @@ fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 -$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5 +printf %s "checking for a race-free mkdir -p... " >&6; } if test -z "$MKDIR_P"; then - if ${ac_cv_path_mkdir+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${ac_cv_path_mkdir+y} +then : + printf %s "(cached) " >&6 +else $as_nop as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue - case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( - 'mkdir (GNU coreutils) '* | \ - 'mkdir (coreutils) '* | \ + as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue + case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir ('*'coreutils) '* | \ + 'BusyBox '* | \ 'mkdir (fileutils) '4.1*) - ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext break 3;; esac done @@ -2963,7 +3520,7 @@ IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version - if test "${ac_cv_path_mkdir+set}" = set; then + if test ${ac_cv_path_mkdir+y}; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a @@ -2973,18 +3530,19 @@ fi MKDIR_P="$ac_install_sh -d" fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 -$as_echo "$MKDIR_P" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +printf "%s\n" "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AWK+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else @@ -2992,11 +3550,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3007,24 +3569,25 @@ fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +printf "%s\n" "$AWK" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi test -n "$AWK" && break done -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else +ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval test \${ac_cv_prog_make_${ac_make}_set+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @@ -3040,12 +3603,12 @@ esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } SET_MAKE= else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi @@ -3059,7 +3622,8 @@ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : +if test ${enable_silent_rules+y} +then : enableval=$enable_silent_rules; fi @@ -3069,12 +3633,13 @@ case $enable_silent_rules in # ((( *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +printf %s "checking whether $am_make supports nested variables... " >&6; } +if test ${am_cv_make_support_nested_variables+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if printf "%s\n" 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 @@ -3086,8 +3651,8 @@ else am_cv_make_support_nested_variables=no fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' @@ -3119,17 +3684,13 @@ fi # Define the identity of the package. PACKAGE='libhx' - VERSION='3.25' + VERSION='4.10' -cat >>confdefs.h <<_ACEOF -#define PACKAGE "$PACKAGE" -_ACEOF +printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h -cat >>confdefs.h <<_ACEOF -#define VERSION "$VERSION" -_ACEOF +printf "%s\n" "#define VERSION \"$VERSION\"" >>confdefs.h # Some tools Automake needs. @@ -3149,8 +3710,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: -# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> -# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> +# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> +# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The @@ -3165,8 +3726,8 @@ _am_tools='gnutar pax cpio none' - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to create a pax tar archive" >&5 -$as_echo_n "checking how to create a pax tar archive... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to create a pax tar archive" >&5 +printf %s "checking how to create a pax tar archive... " >&6; } # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. @@ -3241,17 +3802,32 @@ $as_echo_n "checking how to create a pax tar archive... " >&6; } done rm -rf conftest.dir - if ${am_cv_prog_tar_pax+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${am_cv_prog_tar_pax+y} +then : + printf %s "(cached) " >&6 +else $as_nop am_cv_prog_tar_pax=$_am_tool fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_pax" >&5 -$as_echo "$am_cv_prog_tar_pax" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_pax" >&5 +printf "%s\n" "$am_cv_prog_tar_pax" >&6; } + + + +# Variables for tags utilities; see am/tags.am +if test -z "$CTAGS"; then + CTAGS=ctags +fi +if test -z "$ETAGS"; then + ETAGS=etags +fi + +if test -z "$CSCOPE"; then + CSCOPE=cscope +fi @@ -3286,7 +3862,7 @@ END Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation -that behaves properly: <http://www.gnu.org/software/coreutils/>. +that behaves properly: <https://www.gnu.org/software/coreutils/>. If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM @@ -3296,6 +3872,56 @@ END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi +# Check whether --enable-silent-rules was given. +if test ${enable_silent_rules+y} +then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=0;; +esac +am_make=${MAKE-make} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +printf %s "checking whether $am_make supports nested variables... " >&6; } +if test ${am_cv_make_support_nested_variables+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if printf "%s\n" 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + + + + + + + + + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3305,11 +3931,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3317,11 +3944,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3332,11 +3963,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -3345,11 +3976,12 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -3357,11 +3989,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3372,11 +4008,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_CC" = x; then @@ -3384,8 +4020,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC @@ -3398,11 +4034,12 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3410,11 +4047,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3425,11 +4066,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -3438,11 +4079,12 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3451,15 +4093,19 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3475,18 +4121,18 @@ if test $ac_prog_rejected = yes; then # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -3497,11 +4143,12 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else @@ -3509,11 +4156,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3524,11 +4175,11 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -3541,11 +4192,12 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else @@ -3553,11 +4205,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -3568,11 +4224,11 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -3584,34 +4240,138 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. +set dummy ${ac_tool_prefix}clang; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}clang" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +printf "%s\n" "$CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "clang", so it can be a program name with args. +set dummy clang; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CC+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="clang" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +printf "%s\n" "$ac_ct_CC" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi +else + CC="$ac_cv_prog_CC" fi fi -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -for ac_option in --version -v -V -qversion; do +for ac_option in --version -v -V -qversion -version; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -3621,7 +4381,7 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done @@ -3629,7 +4389,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; @@ -3641,9 +4401,9 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +printf %s "checking whether the C compiler works... " >&6; } +ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" @@ -3664,11 +4424,12 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -3685,7 +4446,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -3701,44 +4462,46 @@ do done test "$ac_cv_exeext" = no && ac_cv_exeext= -else +else $as_nop ac_file='' fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 +if test -z "$ac_file" +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +printf %s "checking for C compiler default output file name... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +printf "%s\n" "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +printf %s "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -3752,15 +4515,15 @@ for ac_file in conftest.exe conftest conftest.*; do * ) break;; esac done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +printf "%s\n" "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext @@ -3769,7 +4532,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdio.h> int -main () +main (void) { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; @@ -3781,8 +4544,8 @@ _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +printf %s "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in @@ -3790,10 +4553,10 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in @@ -3801,39 +4564,40 @@ $as_echo "$ac_try_echo"; } >&5 *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +printf "%s\n" "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +printf %s "checking for suffix of object files... " >&6; } +if test ${ac_cv_objext+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; @@ -3847,11 +4611,12 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -3860,31 +4625,32 @@ $as_echo "$ac_try_echo"; } >&5 break;; esac done -else - $as_echo "$as_me: failed program was:" >&5 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +printf "%s\n" "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 +printf %s "checking whether the compiler supports GNU C... " >&6; } +if test ${ac_cv_c_compiler_gnu+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { #ifndef __GNUC__ choke me @@ -3894,29 +4660,33 @@ main () return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_compiler_gnu=yes -else +else $as_nop ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi -ac_test_CFLAGS=${CFLAGS+set} +ac_test_CFLAGS=${CFLAGS+y} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +printf %s "checking whether $CC accepts -g... " >&6; } +if test ${ac_cv_prog_cc_g+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no @@ -3925,57 +4695,60 @@ else /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_cv_prog_cc_g=yes -else +else $as_nop CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : -else +else $as_nop ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_cv_prog_cc_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +printf "%s\n" "$ac_cv_prog_cc_g" >&6; } +if test $ac_test_CFLAGS; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then @@ -3990,94 +4763,144 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no +ac_prog_cc_stdc=no +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 +printf %s "checking for $CC option to enable C11 features... " >&6; } +if test ${ac_cv_prog_cc_c11+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c11=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <stdarg.h> -#include <stdio.h> -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +$ac_c_conftest_c11_program +_ACEOF +for ac_arg in '' -std=gnu11 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c11=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c11" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; +if test "x$ac_cv_prog_cc_c11" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c11" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 +printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } + CC="$CC $ac_cv_prog_cc_c11" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 + ac_prog_cc_stdc=c11 +fi +fi +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 +printf %s "checking for $CC option to enable C99 features... " >&6; } +if test ${ac_cv_prog_cc_c99+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c99_program +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC +fi -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} +if test "x$ac_cv_prog_cc_c99" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c99" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } + CC="$CC $ac_cv_prog_cc_c99" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 + ac_prog_cc_stdc=c99 +fi +fi +if test x$ac_prog_cc_stdc = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 +printf %s "checking for $CC option to enable C89 features... " >&6; } +if test ${ac_cv_prog_cc_c89+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_c_conftest_c89_program _ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : + if ac_fn_c_try_compile "$LINENO" +then : ac_cv_prog_cc_c89=$ac_arg fi -rm -f core conftest.err conftest.$ac_objext +rm -f core conftest.err conftest.$ac_objext conftest.beam test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC - fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : +if test "x$ac_cv_prog_cc_c89" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cc_c89" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } + CC="$CC $ac_cv_prog_cc_c89" +fi + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 + ac_prog_cc_stdc=c89 +fi fi ac_ext=c @@ -4086,21 +4909,23 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_ext=c + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 -$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } -if ${am_cv_prog_cc_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +printf %s "checking whether $CC understands -c and -o together... " >&6; } +if test ${am_cv_prog_cc_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; @@ -4128,8 +4953,8 @@ _ACEOF rm -f core conftest* unset am_i fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 -$as_echo "$am_cv_prog_cc_c_o" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +printf "%s\n" "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. @@ -4148,48 +4973,49 @@ DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" - -am_make=${MAKE-make} -cat > confinc << 'END' +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +printf %s "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' am__doit: - @echo this is the am__doit target + @echo this is the am__doit target >confinc.out .PHONY: am__doit END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from 'make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +printf "%s\n" "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then : +if test ${enable_dependency_tracking+y} +then : enableval=$enable_dependency_tracking; fi @@ -4210,11 +5036,12 @@ fi depcc="$CC" am_compiler_list= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CC_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +printf %s "checking dependency style of $depcc... " >&6; } +if test ${am_cv_CC_dependencies_compiler_type+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For @@ -4321,8 +5148,8 @@ else fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +printf "%s\n" "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if @@ -4337,6 +5164,12 @@ fi + + + + + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4347,15 +5180,16 @@ if test -z "$CXX"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else @@ -4363,11 +5197,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4378,11 +5216,11 @@ fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -$as_echo "$CXX" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +printf "%s\n" "$CXX" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -4391,15 +5229,16 @@ fi fi if test -z "$CXX"; then ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else @@ -4407,11 +5246,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4422,11 +5265,11 @@ fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -$as_echo "$ac_ct_CXX" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +printf "%s\n" "$ac_ct_CXX" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -4438,8 +5281,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX @@ -4449,7 +5292,7 @@ fi fi fi # Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do @@ -4459,7 +5302,7 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 +printf "%s\n" "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then @@ -4469,20 +5312,21 @@ $as_echo "$ac_try_echo"; } >&5 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 -$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if ${ac_cv_cxx_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5 +printf %s "checking whether the compiler supports GNU C++... " >&6; } +if test ${ac_cv_cxx_compiler_gnu+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { #ifndef __GNUC__ choke me @@ -4492,29 +5336,33 @@ main () return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO" +then : ac_compiler_gnu=yes -else +else $as_nop ac_compiler_gnu=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; } +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi -ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_test_CXXFLAGS=${CXXFLAGS+y} ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -$as_echo_n "checking whether $CXX accepts -g... " >&6; } -if ${ac_cv_prog_cxx_g+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +printf %s "checking whether $CXX accepts -g... " >&6; } +if test ${ac_cv_prog_cxx_g+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no @@ -4523,57 +5371,60 @@ else /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO" +then : ac_cv_prog_cxx_g=yes -else +else $as_nop CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO" +then : -else +else $as_nop ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO" +then : ac_cv_prog_cxx_g=yes fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -$as_echo "$ac_cv_prog_cxx_g" >&6; } -if test "$ac_test_CXXFLAGS" = set; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +printf "%s\n" "$ac_cv_prog_cxx_g" >&6; } +if test $ac_test_CXXFLAGS; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then @@ -4588,6 +5439,100 @@ else CXXFLAGS= fi fi +ac_prog_cxx_stdcxx=no +if test x$ac_prog_cxx_stdcxx = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 +printf %s "checking for $CXX option to enable C++11 features... " >&6; } +if test ${ac_cv_prog_cxx_11+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cxx_11=no +ac_save_CXX=$CXX +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_cxx_conftest_cxx11_program +_ACEOF +for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA +do + CXX="$ac_save_CXX $ac_arg" + if ac_fn_cxx_try_compile "$LINENO" +then : + ac_cv_prog_cxx_cxx11=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cxx_cxx11" != "xno" && break +done +rm -f conftest.$ac_ext +CXX=$ac_save_CXX +fi + +if test "x$ac_cv_prog_cxx_cxx11" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cxx_cxx11" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5 +printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } + CXX="$CXX $ac_cv_prog_cxx_cxx11" +fi + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 + ac_prog_cxx_stdcxx=cxx11 +fi +fi +if test x$ac_prog_cxx_stdcxx = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 +printf %s "checking for $CXX option to enable C++98 features... " >&6; } +if test ${ac_cv_prog_cxx_98+y} +then : + printf %s "(cached) " >&6 +else $as_nop + ac_cv_prog_cxx_98=no +ac_save_CXX=$CXX +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_cxx_conftest_cxx98_program +_ACEOF +for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA +do + CXX="$ac_save_CXX $ac_arg" + if ac_fn_cxx_try_compile "$LINENO" +then : + ac_cv_prog_cxx_cxx98=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam + test "x$ac_cv_prog_cxx_cxx98" != "xno" && break +done +rm -f conftest.$ac_ext +CXX=$ac_save_CXX +fi + +if test "x$ac_cv_prog_cxx_cxx98" = xno +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +printf "%s\n" "unsupported" >&6; } +else $as_nop + if test "x$ac_cv_prog_cxx_cxx98" = x +then : + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +printf "%s\n" "none needed" >&6; } +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5 +printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } + CXX="$CXX $ac_cv_prog_cxx_cxx98" +fi + ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98 + ac_prog_cxx_stdcxx=cxx98 +fi +fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4596,11 +5541,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 -$as_echo_n "checking dependency style of $depcc... " >&6; } -if ${am_cv_CXX_dependencies_compiler_type+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +printf %s "checking dependency style of $depcc... " >&6; } +if test ${am_cv_CXX_dependencies_compiler_type+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For @@ -4707,8 +5653,8 @@ else fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 -$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +printf "%s\n" "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if @@ -4723,7 +5669,8 @@ fi # Check whether --enable-silent-rules was given. -if test "${enable_silent_rules+set}" = set; then : +if test ${enable_silent_rules+y} +then : enableval=$enable_silent_rules; fi @@ -4733,12 +5680,13 @@ case $enable_silent_rules in # ((( *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 -$as_echo_n "checking whether $am_make supports nested variables... " >&6; } -if ${am_cv_make_support_nested_variables+:} false; then : - $as_echo_n "(cached) " >&6 -else - if $as_echo 'TRUE=$(BAR$(V)) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +printf %s "checking whether $am_make supports nested variables... " >&6; } +if test ${am_cv_make_support_nested_variables+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if printf "%s\n" 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 @@ -4750,8 +5698,8 @@ else am_cv_make_support_nested_variables=no fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 -$as_echo "$am_cv_make_support_nested_variables" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +printf "%s\n" "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' @@ -4762,16 +5710,18 @@ fi AM_BACKSLASH='\' -if test -n "$ac_tool_prefix"; then + + if test -n "$ac_tool_prefix"; then for ac_prog in ar lib "link -lib" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else @@ -4779,11 +5729,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4794,11 +5748,11 @@ fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +printf "%s\n" "$AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -4811,11 +5765,12 @@ if test -z "$AR"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else @@ -4823,11 +5778,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -4838,11 +5797,11 @@ fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +printf "%s\n" "$ac_ct_AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -4854,8 +5813,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR @@ -4864,11 +5823,12 @@ fi : ${AR=ar} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 -$as_echo_n "checking the archiver ($AR) interface... " >&6; } -if ${am_cv_ar_interface+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5 +printf %s "checking the archiver ($AR) interface... " >&6; } +if test ${am_cv_ar_interface+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4880,12 +5840,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu /* end confdefs.h. */ int some_variable = 0; _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=ar @@ -4894,7 +5855,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5 (eval $am_ar_try) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then am_cv_ar_interface=lib @@ -4905,7 +5866,7 @@ if ac_fn_c_try_compile "$LINENO"; then : rm -f conftest.lib libconftest.a fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4913,8 +5874,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 -$as_echo "$am_cv_ar_interface" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5 +printf "%s\n" "$am_cv_ar_interface" >&6; } case $am_cv_ar_interface in ar) @@ -4934,7 +5895,8 @@ unknown) esac # Check whether --enable-static was given. -if test "${enable_static+set}" = set; then : +if test ${enable_static+y} +then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; @@ -4952,7 +5914,7 @@ if test "${enable_static+set}" = set; then : IFS=$lt_save_ifs ;; esac -else +else $as_nop enable_static=no fi @@ -4964,20 +5926,17 @@ fi -enable_dlopen=yes - - - case `pwd` in *\ * | *\ *) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 -$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac -macro_version='2.4.6' -macro_revision='2.4.6' +macro_version='2.4.7' +macro_revision='2.4.7' + @@ -4993,26 +5952,29 @@ macro_revision='2.4.6' ltmain=$ac_aux_dir/ltmain.sh -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : - $as_echo_n "(cached) " >&6 -else + + # Make sure we can run config.sub. +$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5 + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +printf %s "checking build system type... " >&6; } +if test ${ac_cv_build+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_build_alias=$build_alias test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` + ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 +ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5 fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +printf "%s\n" "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; @@ -5031,21 +5993,22 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +printf %s "checking host system type... " >&6; } +if test ${ac_cv_host+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` || + as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5 fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +printf "%s\n" "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; @@ -5085,8 +6048,8 @@ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 -$as_echo_n "checking how to print strings... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +printf %s "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then @@ -5112,12 +6075,12 @@ func_echo_all () } case $ECHO in - printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 -$as_echo "printf" >&6; } ;; - print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 -$as_echo "print -r" >&6; } ;; - *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 -$as_echo "cat" >&6; } ;; + printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +printf "%s\n" "printf" >&6; } ;; + print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +printf "%s\n" "print -r" >&6; } ;; + *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +printf "%s\n" "cat" >&6; } ;; esac @@ -5133,11 +6096,12 @@ esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +printf %s "checking for a sed that does not truncate output... " >&6; } +if test ${ac_cv_path_SED+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" @@ -5151,10 +6115,15 @@ else for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in sed gsed + do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + ac_path_SED="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED @@ -5163,13 +6132,13 @@ case `"$ac_path_SED" --version 2>&1` in ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 - $as_echo_n 0123456789 >"conftest.in" + printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" + printf "%s\n" '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -5197,8 +6166,8 @@ else fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +printf "%s\n" "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed @@ -5215,11 +6184,12 @@ Xsed="$SED -e 1s/^X//" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +printf %s "checking for grep that handles long lines and -e... " >&6; } +if test ${ac_cv_path_GREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST @@ -5227,10 +6197,15 @@ else for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in grep ggrep + do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP @@ -5239,13 +6214,13 @@ case `"$ac_path_GREP" --version 2>&1` in ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 - $as_echo_n 0123456789 >"conftest.in" + printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" + printf "%s\n" 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -5273,16 +6248,17 @@ else fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +printf "%s\n" "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +printf %s "checking for egrep... " >&6; } +if test ${ac_cv_path_EGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else @@ -5293,10 +6269,15 @@ else for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in egrep + do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP @@ -5305,13 +6286,13 @@ case `"$ac_path_EGREP" --version 2>&1` in ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 - $as_echo_n 0123456789 >"conftest.in" + printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" + printf "%s\n" 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -5340,16 +6321,17 @@ fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +printf "%s\n" "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 -$as_echo_n "checking for fgrep... " >&6; } -if ${ac_cv_path_FGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +printf %s "checking for fgrep... " >&6; } +if test ${ac_cv_path_FGREP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else @@ -5360,10 +6342,15 @@ else for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in fgrep; do + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in fgrep + do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP @@ -5372,13 +6359,13 @@ case `"$ac_path_FGREP" --version 2>&1` in ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 - $as_echo_n 0123456789 >"conftest.in" + printf %s 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" - $as_echo 'FGREP' >> "conftest.nl" + printf "%s\n" 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val @@ -5407,8 +6394,8 @@ fi fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 -$as_echo "$ac_cv_path_FGREP" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +printf "%s\n" "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" @@ -5433,17 +6420,18 @@ test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : +if test ${with_gnu_ld+y} +then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes -else +else $as_nop with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +printf %s "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw @@ -5472,15 +6460,16 @@ $as_echo_n "checking for ld used by $CC... " >&6; } ;; esac elif test yes = "$with_gnu_ld"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +printf %s "checking for GNU ld... " >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +printf %s "checking for non-GNU ld... " >&6; } fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else +if test ${lt_cv_path_LD+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do @@ -5509,18 +6498,19 @@ fi LD=$lt_cv_path_LD if test -n "$LD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -$as_echo "$LD" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +printf "%s\n" "$LD" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +printf %s "checking if the linker ($LD) is GNU ld... " >&6; } +if test ${lt_cv_prog_gnu_ld+y} +then : + printf %s "(cached) " >&6 +else $as_nop # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 </dev/null` in *GNU* | *'with BFD'*) @@ -5531,8 +6521,8 @@ case `$LD -v 2>&1 </dev/null` in ;; esac fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5 +printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld @@ -5543,11 +6533,12 @@ with_gnu_ld=$lt_cv_prog_gnu_ld -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 -$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if ${lt_cv_path_NM+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if test ${lt_cv_path_NM+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM @@ -5572,13 +6563,13 @@ else mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac - case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 @@ -5597,8 +6588,8 @@ else : ${lt_cv_path_NM=no} fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 -$as_echo "$lt_cv_path_NM" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +printf "%s\n" "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else @@ -5611,11 +6602,12 @@ else do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DUMPBIN+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else @@ -5623,11 +6615,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -5638,11 +6634,11 @@ fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 -$as_echo "$DUMPBIN" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +printf "%s\n" "$DUMPBIN" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -5655,11 +6651,12 @@ if test -z "$DUMPBIN"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DUMPBIN+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else @@ -5667,11 +6664,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -5682,11 +6683,11 @@ fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 -$as_echo "$ac_ct_DUMPBIN" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +printf "%s\n" "$ac_ct_DUMPBIN" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -5698,15 +6699,15 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi - case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; @@ -5727,11 +6728,12 @@ test -z "$NM" && NM=nm -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 -$as_echo_n "checking the name lister ($NM) interface... " >&6; } -if ${lt_cv_nm_interface+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +printf %s "checking the name lister ($NM) interface... " >&6; } +if test ${lt_cv_nm_interface+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) @@ -5747,26 +6749,27 @@ else fi rm -f conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 -$as_echo "$lt_cv_nm_interface" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +printf "%s\n" "$lt_cv_nm_interface" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 -$as_echo_n "checking whether ln -s works... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +printf %s "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 -$as_echo "no, using $LN_S" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +printf "%s\n" "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 -$as_echo_n "checking the maximum length of command line arguments... " >&6; } -if ${lt_cv_sys_max_cmd_len+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +printf %s "checking the maximum length of command line arguments... " >&6; } +if test ${lt_cv_sys_max_cmd_len+y} +then : + printf %s "(cached) " >&6 +else $as_nop i=0 teststring=ABCD @@ -5808,7 +6811,7 @@ else lt_cv_sys_max_cmd_len=8192; ;; - bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -5851,7 +6854,7 @@ else sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi @@ -5893,11 +6896,11 @@ else fi if test -n "$lt_cv_sys_max_cmd_len"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 -$as_echo "$lt_cv_sys_max_cmd_len" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 -$as_echo "none" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 +printf "%s\n" "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len @@ -5941,11 +6944,12 @@ esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 -$as_echo_n "checking how to convert $build file names to $host format... " >&6; } -if ${lt_cv_to_host_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +printf %s "checking how to convert $build file names to $host format... " >&6; } +if test ${lt_cv_to_host_file_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop case $host in *-*-mingw* ) case $build in @@ -5981,18 +6985,19 @@ esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 -$as_echo "$lt_cv_to_host_file_cmd" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 -$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } -if ${lt_cv_to_tool_file_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +printf %s "checking how to convert $build file names to toolchain format... " >&6; } +if test ${lt_cv_to_tool_file_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in @@ -6008,22 +7013,23 @@ esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 -$as_echo "$lt_cv_to_tool_file_cmd" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 -$as_echo_n "checking for $LD option to reload object files... " >&6; } -if ${lt_cv_ld_reload_flag+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +printf %s "checking for $LD option to reload object files... " >&6; } +if test ${lt_cv_ld_reload_flag+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_ld_reload_flag='-r' fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 -$as_echo "$lt_cv_ld_reload_flag" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +printf "%s\n" "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; @@ -6054,13 +7060,122 @@ esac if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args. +set dummy ${ac_tool_prefix}file; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_FILECMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$FILECMD"; then + ac_cv_prog_FILECMD="$FILECMD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_FILECMD="${ac_tool_prefix}file" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +FILECMD=$ac_cv_prog_FILECMD +if test -n "$FILECMD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FILECMD" >&5 +printf "%s\n" "$FILECMD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_FILECMD"; then + ac_ct_FILECMD=$FILECMD + # Extract the first word of "file", so it can be a program name with args. +set dummy file; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_FILECMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if test -n "$ac_ct_FILECMD"; then + ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_FILECMD="file" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD +if test -n "$ac_ct_FILECMD"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5 +printf "%s\n" "$ac_ct_FILECMD" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_ct_FILECMD" = x; then + FILECMD=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + FILECMD=$ac_ct_FILECMD + fi +else + FILECMD="$ac_cv_prog_FILECMD" +fi + + + + + + + +if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else @@ -6068,11 +7183,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6083,11 +7202,11 @@ fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +printf "%s\n" "$OBJDUMP" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -6096,11 +7215,12 @@ if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OBJDUMP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else @@ -6108,11 +7228,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6123,11 +7247,11 @@ fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +printf "%s\n" "$ac_ct_OBJDUMP" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then @@ -6135,8 +7259,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP @@ -6155,11 +7279,12 @@ test -z "$OBJDUMP" && OBJDUMP=objdump -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 -$as_echo_n "checking how to recognize dependent libraries... " >&6; } -if ${lt_cv_deplibs_check_method+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +printf %s "checking how to recognize dependent libraries... " >&6; } +if test ${lt_cv_deplibs_check_method+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' @@ -6185,7 +7310,7 @@ beos*) bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_cmd='$FILECMD -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; @@ -6219,14 +7344,14 @@ darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac @@ -6240,7 +7365,7 @@ haiku*) ;; hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' @@ -6287,7 +7412,7 @@ netbsd*) newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; @@ -6355,8 +7480,8 @@ os2*) esac fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 -$as_echo "$lt_cv_deplibs_check_method" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +printf "%s\n" "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no @@ -6400,11 +7525,12 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else @@ -6412,11 +7538,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6427,11 +7557,11 @@ fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +printf "%s\n" "$DLLTOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -6440,11 +7570,12 @@ if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DLLTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else @@ -6452,11 +7583,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6467,11 +7602,11 @@ fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +printf "%s\n" "$ac_ct_DLLTOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then @@ -6479,8 +7614,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL @@ -6500,11 +7635,12 @@ test -z "$DLLTOOL" && DLLTOOL=dlltool -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 -$as_echo_n "checking how to associate runtime and link libraries... " >&6; } -if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +printf %s "checking how to associate runtime and link libraries... " >&6; } +if test ${lt_cv_sharedlib_from_linklib_cmd+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in @@ -6527,8 +7663,8 @@ cygwin* | mingw* | pw32* | cegcc*) esac fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 -$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO @@ -6543,11 +7679,12 @@ if test -n "$ac_tool_prefix"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else @@ -6555,11 +7692,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6570,11 +7711,11 @@ fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 -$as_echo "$AR" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +printf "%s\n" "$AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -6587,11 +7728,12 @@ if test -z "$AR"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_AR+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_AR+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else @@ -6599,11 +7741,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6614,11 +7760,11 @@ fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 -$as_echo "$ac_ct_AR" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +printf "%s\n" "$ac_ct_AR" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -6630,8 +7776,8 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR @@ -6639,42 +7785,60 @@ esac fi : ${AR=ar} -: ${AR_FLAGS=cru} +# Use ARFLAGS variable as AR's operation code to sync the variable naming with +# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have +# higher priority because thats what people were doing historically (setting +# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS +# variable obsoleted/removed. +test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} +lt_ar_flags=$AR_FLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 -$as_echo_n "checking for archiver @FILE support... " >&6; } -if ${lt_cv_ar_at_file+:} false; then : - $as_echo_n "(cached) " >&6 -else + + +# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override +# by AR_FLAGS because that was never working and AR_FLAGS is about to die. + + + + + + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +printf %s "checking for archiver @FILE support... " >&6; } +if test ${lt_cv_ar_at_file+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. @@ -6682,7 +7846,7 @@ if ac_fn_c_try_compile "$LINENO"; then : { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ @@ -6691,11 +7855,11 @@ if ac_fn_c_try_compile "$LINENO"; then : rm -f conftest.* libconftest.a fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 -$as_echo "$lt_cv_ar_at_file" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +printf "%s\n" "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= @@ -6712,11 +7876,12 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else @@ -6724,11 +7889,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6739,11 +7908,11 @@ fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 -$as_echo "$STRIP" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +printf "%s\n" "$STRIP" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -6752,11 +7921,12 @@ if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_STRIP+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_STRIP+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else @@ -6764,11 +7934,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6779,11 +7953,11 @@ fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 -$as_echo "$ac_ct_STRIP" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +printf "%s\n" "$ac_ct_STRIP" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then @@ -6791,8 +7965,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP @@ -6811,11 +7985,12 @@ test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_RANLIB+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else @@ -6823,11 +7998,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6838,11 +8017,11 @@ fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +printf "%s\n" "$RANLIB" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -6851,11 +8030,12 @@ if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_RANLIB+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else @@ -6863,11 +8043,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -6878,11 +8062,11 @@ fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +printf "%s\n" "$ac_ct_RANLIB" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then @@ -6890,8 +8074,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB @@ -6980,11 +8164,12 @@ compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 -$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if ${lt_cv_sys_global_symbol_pipe+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +printf %s "checking command to parse $NM output from $compiler object... " >&6; } +if test ${lt_cv_sys_global_symbol_pipe+y} +then : + printf %s "(cached) " >&6 +else $as_nop # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] @@ -7039,7 +8224,7 @@ esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. - lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" @@ -7057,20 +8242,20 @@ fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ @@ -7094,7 +8279,7 @@ for ac_symprfx in "" "_"; do if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. - # Also find C++ and __fastcall symbols from MSVC++, + # Also find C++ and __fastcall symbols from MSVC++ or ICC, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ @@ -7112,9 +8297,9 @@ for ac_symprfx in "" "_"; do " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -7136,14 +8321,14 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then @@ -7212,7 +8397,7 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi @@ -7247,11 +8432,11 @@ if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 -$as_echo "failed" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +printf "%s\n" "failed" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 -$as_echo "ok" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +printf "%s\n" "ok" >&6; } fi # Response file support. @@ -7297,13 +8482,14 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 -$as_echo_n "checking for sysroot... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +printf %s "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. -if test "${with_sysroot+set}" = set; then : +if test ${with_sysroot+y} +then : withval=$with_sysroot; -else +else $as_nop with_sysroot=no fi @@ -7316,29 +8502,30 @@ case $with_sysroot in #( fi ;; #( /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 -$as_echo "$with_sysroot" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +printf "%s\n" "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 -$as_echo "${lt_sysroot:-no}" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +printf "%s\n" "${lt_sysroot:-no}" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 -$as_echo_n "checking for a working dd... " >&6; } -if ${ac_cv_path_lt_DD+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +printf %s "checking for a working dd... " >&6; } +if test ${ac_cv_path_lt_DD+y} +then : + printf %s "(cached) " >&6 +else $as_nop printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} @@ -7349,10 +8536,15 @@ if test -z "$lt_DD"; then for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in dd; do + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_prog in dd + do for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" + ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ @@ -7372,15 +8564,16 @@ fi rm -f conftest.i conftest2.i conftest.out fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 -$as_echo "$ac_cv_path_lt_DD" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +printf "%s\n" "$ac_cv_path_lt_DD" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 -$as_echo_n "checking how to truncate binary pipes... " >&6; } -if ${lt_cv_truncate_bin+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +printf %s "checking how to truncate binary pipes... " >&6; } +if test ${lt_cv_truncate_bin+y} +then : + printf %s "(cached) " >&6 +else $as_nop printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= @@ -7391,8 +8584,8 @@ fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 -$as_echo "$lt_cv_truncate_bin" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +printf "%s\n" "$lt_cv_truncate_bin" >&6; } @@ -7415,7 +8608,8 @@ func_cc_basename () } # Check whether --enable-libtool-lock was given. -if test "${enable_libtool_lock+set}" = set; then : +if test ${enable_libtool_lock+y} +then : enableval=$enable_libtool_lock; fi @@ -7431,9 +8625,9 @@ ia64-*-hpux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; @@ -7451,10 +8645,10 @@ ia64-*-hpux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; @@ -7466,7 +8660,7 @@ ia64-*-hpux*) ;; esac else - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; @@ -7489,10 +8683,10 @@ mips64*-*linux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; @@ -7500,7 +8694,7 @@ mips64*-*linux*) emul="${emul}64" ;; esac - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; @@ -7508,7 +8702,7 @@ mips64*-*linux*) emul="${emul}ltsmip" ;; esac - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; @@ -7530,16 +8724,16 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; @@ -7593,11 +8787,12 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 -$as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if ${lt_cv_cc_needs_belf+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +printf %s "checking whether the C compiler needs -belf... " >&6; } +if test ${lt_cv_cc_needs_belf+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7608,19 +8803,20 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : lt_cv_cc_needs_belf=yes -else +else $as_nop lt_cv_cc_needs_belf=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -7629,8 +8825,8 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 -$as_echo "$lt_cv_cc_needs_belf" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS @@ -7643,9 +8839,9 @@ $as_echo "$lt_cv_cc_needs_belf" >&6; } if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) @@ -7680,11 +8876,12 @@ need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_MANIFEST_TOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else @@ -7692,11 +8889,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7707,11 +8908,11 @@ fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 -$as_echo "$MANIFEST_TOOL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +printf "%s\n" "$MANIFEST_TOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -7720,11 +8921,12 @@ if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else @@ -7732,11 +8934,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7747,11 +8953,11 @@ fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 -$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then @@ -7759,8 +8965,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL @@ -7770,11 +8976,12 @@ else fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 -$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } -if ${lt_cv_path_mainfest_tool+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if test ${lt_cv_path_mainfest_tool+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out @@ -7784,8 +8991,8 @@ else fi rm -f conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 -$as_echo "$lt_cv_path_mainfest_tool" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi @@ -7800,11 +9007,12 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_DSYMUTIL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else @@ -7812,11 +9020,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7827,11 +9039,11 @@ fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 -$as_echo "$DSYMUTIL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +printf "%s\n" "$DSYMUTIL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -7840,11 +9052,12 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_DSYMUTIL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else @@ -7852,11 +9065,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7867,11 +9084,11 @@ fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 -$as_echo "$ac_ct_DSYMUTIL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +printf "%s\n" "$ac_ct_DSYMUTIL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then @@ -7879,8 +9096,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL @@ -7892,11 +9109,12 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_NMEDIT+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else @@ -7904,11 +9122,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7919,11 +9141,11 @@ fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 -$as_echo "$NMEDIT" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +printf "%s\n" "$NMEDIT" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -7932,11 +9154,12 @@ if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_NMEDIT+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else @@ -7944,11 +9167,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -7959,11 +9186,11 @@ fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 -$as_echo "$ac_ct_NMEDIT" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +printf "%s\n" "$ac_ct_NMEDIT" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then @@ -7971,8 +9198,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT @@ -7984,11 +9211,12 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_LIPO+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else @@ -7996,11 +9224,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8011,11 +9243,11 @@ fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 -$as_echo "$LIPO" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +printf "%s\n" "$LIPO" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -8024,11 +9256,12 @@ if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_LIPO+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_LIPO+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else @@ -8036,11 +9269,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8051,11 +9288,11 @@ fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 -$as_echo "$ac_ct_LIPO" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +printf "%s\n" "$ac_ct_LIPO" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then @@ -8063,8 +9300,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO @@ -8076,11 +9313,12 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else @@ -8088,11 +9326,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8103,11 +9345,11 @@ fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 -$as_echo "$OTOOL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +printf "%s\n" "$OTOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -8116,11 +9358,12 @@ if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OTOOL+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else @@ -8128,11 +9371,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8143,11 +9390,11 @@ fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 -$as_echo "$ac_ct_OTOOL" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +printf "%s\n" "$ac_ct_OTOOL" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then @@ -8155,8 +9402,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL @@ -8168,11 +9415,12 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_OTOOL64+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else @@ -8180,11 +9428,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8195,11 +9447,11 @@ fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 -$as_echo "$OTOOL64" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +printf "%s\n" "$OTOOL64" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -8208,11 +9460,12 @@ if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_prog_ac_ct_OTOOL64+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else @@ -8220,11 +9473,15 @@ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 break 2 fi done @@ -8235,11 +9492,11 @@ fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 -$as_echo "$ac_ct_OTOOL64" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +printf "%s\n" "$ac_ct_OTOOL64" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then @@ -8247,8 +9504,8 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 @@ -8283,11 +9540,12 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 -$as_echo_n "checking for -single_module linker flag... " >&6; } -if ${lt_cv_apple_cc_single_mod+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +printf %s "checking for -single_module linker flag... " >&6; } +if test ${lt_cv_apple_cc_single_mod+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override @@ -8316,14 +9574,15 @@ else rm -f conftest.* fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 -$as_echo "$lt_cv_apple_cc_single_mod" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 -$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if ${lt_cv_ld_exported_symbols_list+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +printf %s "checking for -exported_symbols_list linker flag... " >&6; } +if test ${lt_cv_ld_exported_symbols_list+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym @@ -8332,39 +9591,41 @@ else /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : lt_cv_ld_exported_symbols_list=yes -else +else $as_nop lt_cv_ld_exported_symbols_list=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 -$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 -$as_echo_n "checking for -force_load linker flag... " >&6; } -if ${lt_cv_ld_force_load+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +printf %s "checking for -force_load linker flag... " >&6; } +if test ${lt_cv_ld_force_load+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 - echo "$AR cru libconftest.a conftest.o" >&5 - $AR cru libconftest.a conftest.o 2>&5 + echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5 + $AR $AR_FLAGS libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF @@ -8384,24 +9645,19 @@ _LT_EOF rm -rf conftest.dSYM fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 -$as_echo "$lt_cv_ld_force_load" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +printf "%s\n" "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; - 10.[012][,.]*) - _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + darwin*) + case $MACOSX_DEPLOYMENT_TARGET,$host in + 10.[012],*|,*powerpc*-darwin[5-8]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + *) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac @@ -8456,286 +9712,43 @@ func_munge_path_list () esac } -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes +ac_header= ac_cache= +for ac_item in $ac_header_c_list do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - + if test $ac_cache; then + ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" + if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then + printf "%s\n" "#define $ac_item 1" >> confdefs.h + fi + ac_header= ac_cache= + elif test $ac_header; then + ac_cache=$ac_item + else + ac_header=$ac_item + fi done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <float.h> - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <string.h> -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : -else - ac_cv_header_stdc=no -fi -rm -f conftest* -fi -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : -else - ac_cv_header_stdc=no -fi -rm -f conftest* -fi +if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes +then : -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ctype.h> -#include <stdlib.h> -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif +printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF +if test "x$ac_cv_header_dlfcn_h" = xyes +then : + printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h fi -done - - -for ac_header in dlfcn.h -do : - ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default -" -if test "x$ac_cv_header_dlfcn_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_DLFCN_H 1 -_ACEOF - -fi - -done - @@ -8755,12 +9768,15 @@ func_stripname_cnf () + enable_dlopen=no + enable_win32_dll=no # Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then : +if test ${enable_shared+y} +then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; @@ -8778,7 +9794,7 @@ if test "${enable_shared+set}" = set; then : IFS=$lt_save_ifs ;; esac -else +else $as_nop enable_shared=yes fi @@ -8793,7 +9809,8 @@ fi # Check whether --with-pic was given. -if test "${with_pic+set}" = set; then : +if test ${with_pic+y} +then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; @@ -8810,7 +9827,7 @@ if test "${with_pic+set}" = set; then : IFS=$lt_save_ifs ;; esac -else +else $as_nop pic_mode=default fi @@ -8822,7 +9839,8 @@ fi # Check whether --enable-fast-install was given. -if test "${enable_fast_install+set}" = set; then : +if test ${enable_fast_install+y} +then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; @@ -8840,7 +9858,7 @@ if test "${enable_fast_install+set}" = set; then : IFS=$lt_save_ifs ;; esac -else +else $as_nop enable_fast_install=yes fi @@ -8854,11 +9872,12 @@ fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 -$as_echo_n "checking which variant of shared library versioning to provide... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +printf %s "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. -if test "${with_aix_soname+set}" = set; then : +if test ${with_aix_soname+y} +then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; @@ -8867,18 +9886,19 @@ if test "${with_aix_soname+set}" = set; then : ;; esac lt_cv_with_aix_soname=$with_aix_soname -else - if ${lt_cv_with_aix_soname+:} false; then : - $as_echo_n "(cached) " >&6 -else +else $as_nop + if test ${lt_cv_with_aix_soname+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 -$as_echo "$with_aix_soname" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +printf "%s\n" "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', @@ -8960,11 +9980,12 @@ if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 -$as_echo_n "checking for objdir... " >&6; } -if ${lt_cv_objdir+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +printf %s "checking for objdir... " >&6; } +if test ${lt_cv_objdir+y} +then : + printf %s "(cached) " >&6 +else $as_nop rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then @@ -8975,17 +9996,15 @@ else fi rmdir .libs 2>/dev/null fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 -$as_echo "$lt_cv_objdir" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +printf "%s\n" "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir -cat >>confdefs.h <<_ACEOF -#define LT_OBJDIR "$lt_cv_objdir/" -_ACEOF +printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h @@ -9006,8 +10025,8 @@ esac ofile=libtool can_build_shared=yes -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). +# All known linkers require a '.a' archive for static linking (except MSVC and +# ICC, which need '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld @@ -9031,11 +10050,12 @@ test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 -$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +printf %s "checking for ${ac_tool_prefix}file... " >&6; } +if test ${lt_cv_path_MAGIC_CMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. @@ -9084,11 +10104,11 @@ fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +printf "%s\n" "$MAGIC_CMD" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -9097,11 +10117,12 @@ fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 -$as_echo_n "checking for file... " >&6; } -if ${lt_cv_path_MAGIC_CMD+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +printf %s "checking for file... " >&6; } +if test ${lt_cv_path_MAGIC_CMD+y} +then : + printf %s "(cached) " >&6 +else $as_nop case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. @@ -9150,11 +10171,11 @@ fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 -$as_echo "$MAGIC_CMD" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +printf "%s\n" "$MAGIC_CMD" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi @@ -9239,11 +10260,12 @@ if test yes = "$GCC"; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 -$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if test ${lt_cv_prog_compiler_rtti_exceptions+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext @@ -9274,8 +10296,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 -$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" @@ -9516,7 +10538,7 @@ lt_prog_compiler_static= lt_prog_compiler_static='-qstaticlink' ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' @@ -9632,26 +10654,28 @@ case $host_os in ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +printf %s "checking for $compiler option to produce PIC... " >&6; } +if test ${lt_cv_prog_compiler_pic+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 -$as_echo "$lt_cv_prog_compiler_pic" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if ${lt_cv_prog_compiler_pic_works+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if test ${lt_cv_prog_compiler_pic_works+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext @@ -9682,8 +10706,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in @@ -9711,11 +10735,12 @@ fi # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test ${lt_cv_prog_compiler_static_works+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" @@ -9739,8 +10764,8 @@ else LDFLAGS=$save_LDFLAGS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 -$as_echo "$lt_cv_prog_compiler_static_works" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : @@ -9754,11 +10779,12 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest @@ -9801,19 +10827,20 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest @@ -9856,8 +10883,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 -$as_echo "$lt_cv_prog_compiler_c_o" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; } @@ -9865,19 +10892,19 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +printf %s "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +printf "%s\n" "$hard_links" >&6; } if test no = "$hard_links"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -9889,8 +10916,8 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= @@ -9934,15 +10961,15 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie case $host_os in cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time + # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) + # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; openbsd* | bitrig*) @@ -9994,7 +11021,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie whole_archive_flag_spec= fi supports_anon_versioning=no - case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in + case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... @@ -10106,6 +11133,7 @@ _LT_EOF emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes + file_list_spec='@' ;; interix[3-9]*) @@ -10120,7 +11148,7 @@ _LT_EOF # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) @@ -10163,7 +11191,7 @@ _LT_EOF compiler_needs_object=yes ;; esac - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes @@ -10175,7 +11203,7 @@ _LT_EOF if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi @@ -10191,7 +11219,7 @@ _LT_EOF archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi @@ -10323,7 +11351,7 @@ _LT_EOF if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no @@ -10445,21 +11473,23 @@ _LT_EOF if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${lt_cv_aix_libpath_+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -10474,7 +11504,7 @@ if ac_fn_c_try_link "$LINENO"; then : lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib @@ -10498,21 +11528,23 @@ fi if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if ${lt_cv_aix_libpath_+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${lt_cv_aix_libpath_+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -10527,7 +11559,7 @@ if ac_fn_c_try_link "$LINENO"; then : lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib @@ -10590,12 +11622,12 @@ fi cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in - cl*) - # Native MSVC + cl* | icl*) + # Native MSVC or ICC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes @@ -10636,7 +11668,7 @@ fi fi' ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. @@ -10677,8 +11709,8 @@ fi output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" - archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" - module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + archive_expsym_cmds="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no @@ -10712,7 +11744,7 @@ fi ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes @@ -10778,11 +11810,12 @@ fi # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 -$as_echo_n "checking if $CC understands -b... " >&6; } -if ${lt_cv_prog_compiler__b+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +printf %s "checking if $CC understands -b... " >&6; } +if test ${lt_cv_prog_compiler__b+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" @@ -10806,8 +11839,8 @@ else LDFLAGS=$save_LDFLAGS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 -$as_echo "$lt_cv_prog_compiler__b" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +printf "%s\n" "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' @@ -10847,28 +11880,30 @@ fi # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 -$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } -if ${lt_cv_irix_exported_symbol+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if test ${lt_cv_irix_exported_symbol+y} +then : + printf %s "(cached) " >&6 +else $as_nop save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : lt_cv_irix_exported_symbol=yes -else +else $as_nop lt_cv_irix_exported_symbol=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 -$as_echo "$lt_cv_irix_exported_symbol" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi @@ -10960,6 +11995,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes + file_list_spec='@' ;; osf3*) @@ -11148,8 +12184,8 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 -$as_echo "$ld_shlibs" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +printf "%s\n" "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld @@ -11185,18 +12221,19 @@ x|xyes) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +printf %s "checking whether -lc should be explicitly linked in... " >&6; } +if test ${lt_cv_archive_cmds_need_lc+y} +then : + printf %s "(cached) " >&6 +else $as_nop $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest @@ -11214,7 +12251,7 @@ else if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no @@ -11228,8 +12265,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac @@ -11388,8 +12425,8 @@ esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +printf %s "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in @@ -11651,7 +12688,7 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; @@ -11661,14 +12698,14 @@ cygwin* | mingw* | pw32* | cegcc*) ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC + *,cl* | *,icl*) + # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' @@ -11687,7 +12724,7 @@ cygwin* | mingw* | pw32* | cegcc*) done IFS=$lt_save_ifs # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form @@ -11724,7 +12761,7 @@ cygwin* | mingw* | pw32* | cegcc*) ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; @@ -11757,7 +12794,7 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then @@ -11950,9 +12987,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${lt_cv_shlibpath_overrides_runpath+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir @@ -11962,19 +13000,21 @@ else /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : +if ac_fn_c_try_link "$LINENO" +then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null +then : lt_cv_shlibpath_overrides_runpath=yes fi fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir @@ -12206,8 +13246,8 @@ uts4*) dynamic_linker=no ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +printf "%s\n" "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" @@ -12328,8 +13368,8 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +printf %s "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || @@ -12353,8 +13393,8 @@ else # directories. hardcode_action=unsupported fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 -$as_echo "$hardcode_action" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +printf "%s\n" "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then @@ -12398,11 +13438,12 @@ else darwin*) # if libdl is installed we need to link against it - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +printf %s "checking for dlopen in -ldl... " >&6; } +if test ${ac_cv_lib_dl_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12411,32 +13452,31 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char dlopen (); int -main () +main (void) { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : ac_cv_lib_dl_dlopen=yes -else +else $as_nop ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes +then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl -else +else $as_nop lt_cv_dlopen=dyld lt_cv_dlopen_libs= @@ -12456,14 +13496,16 @@ fi *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = xyes; then : +if test "x$ac_cv_func_shl_load" = xyes +then : lt_cv_dlopen=shl_load -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 -$as_echo_n "checking for shl_load in -ldld... " >&6; } -if ${ac_cv_lib_dld_shl_load+:} false; then : - $as_echo_n "(cached) " >&6 -else +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +printf %s "checking for shl_load in -ldld... " >&6; } +if test ${ac_cv_lib_dld_shl_load+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12472,41 +13514,42 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char shl_load (); int -main () +main (void) { return shl_load (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : ac_cv_lib_dld_shl_load=yes -else +else $as_nop ac_cv_lib_dld_shl_load=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 -$as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = xyes; then : +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes +then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld -else +else $as_nop ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = xyes; then : +if test "x$ac_cv_func_dlopen" = xyes +then : lt_cv_dlopen=dlopen -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 -$as_echo_n "checking for dlopen in -ldl... " >&6; } -if ${ac_cv_lib_dl_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +printf %s "checking for dlopen in -ldl... " >&6; } +if test ${ac_cv_lib_dl_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12515,37 +13558,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char dlopen (); int -main () +main (void) { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : ac_cv_lib_dl_dlopen=yes -else +else $as_nop ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 -$as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = xyes; then : +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes +then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 -$as_echo_n "checking for dlopen in -lsvld... " >&6; } -if ${ac_cv_lib_svld_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +printf %s "checking for dlopen in -lsvld... " >&6; } +if test ${ac_cv_lib_svld_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12554,37 +13597,37 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char dlopen (); int -main () +main (void) { return dlopen (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : ac_cv_lib_svld_dlopen=yes -else +else $as_nop ac_cv_lib_svld_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 -$as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = xyes; then : +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes +then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 -$as_echo_n "checking for dld_link in -ldld... " >&6; } -if ${ac_cv_lib_dld_dld_link+:} false; then : - $as_echo_n "(cached) " >&6 -else +else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +printf %s "checking for dld_link in -ldld... " >&6; } +if test ${ac_cv_lib_dld_dld_link+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12593,30 +13636,29 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char dld_link (); int -main () +main (void) { return dld_link (); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : ac_cv_lib_dld_dld_link=yes -else +else $as_nop ac_cv_lib_dld_dld_link=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 -$as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = xyes; then : +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes +then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi @@ -12655,11 +13697,12 @@ fi save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 -$as_echo_n "checking whether a program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +printf %s "checking whether a program can dlopen itself... " >&6; } +if test ${lt_cv_dlopen_self+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else @@ -12738,7 +13781,7 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? @@ -12756,16 +13799,17 @@ rm -fr conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 -$as_echo "$lt_cv_dlopen_self" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +printf "%s\n" "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 -$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if ${lt_cv_dlopen_self_static+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +printf %s "checking whether a statically linked program can dlopen itself... " >&6; } +if test ${lt_cv_dlopen_self_static+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else @@ -12844,7 +13888,7 @@ _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? @@ -12862,8 +13906,8 @@ rm -fr conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 -$as_echo "$lt_cv_dlopen_self_static" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +printf "%s\n" "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS @@ -12901,32 +13945,43 @@ fi striplib= old_striplib= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 -$as_echo_n "checking whether stripping libraries is possible... " >&6; } -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP"; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +printf %s "checking whether stripping libraries is possible... " >&6; } +if test -z "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +else + if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + else + case $host_os in + darwin*) + # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + ;; + freebsd*) + if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + fi + ;; + *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + ;; + esac + fi fi @@ -12941,13 +13996,13 @@ fi # Report what library types will actually be built - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 -$as_echo_n "checking if libtool supports shared libraries... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 -$as_echo "$can_build_shared" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +printf %s "checking if libtool supports shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +printf "%s\n" "$can_build_shared" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 -$as_echo_n "checking whether to build shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +printf %s "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and @@ -12971,15 +14026,15 @@ $as_echo_n "checking whether to build shared libraries... " >&6; } fi ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 -$as_echo "$enable_shared" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +printf "%s\n" "$enable_shared" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 -$as_echo_n "checking whether to build static libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +printf %s "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 -$as_echo "$enable_static" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +printf "%s\n" "$enable_static" >&6; } @@ -13001,36 +14056,32 @@ ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +printf %s "checking how to run the C++ preprocessor... " >&6; } if test -z "$CXXCPP"; then - if ${ac_cv_prog_CXXCPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CXXCPP needs to be expanded - for CXXCPP in "$CXX -E" "/lib/cpp" + if test ${ac_cv_prog_CXXCPP+y} +then : + printf %s "(cached) " >&6 +else $as_nop + # Double quotes because $CXX needs to be expanded + for CXXCPP in "$CXX -E" cpp /lib/cpp do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif +#include <limits.h> Syntax error _ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : +if ac_fn_cxx_try_cpp "$LINENO" +then : -else +else $as_nop # Broken: fails on valid input. continue fi @@ -13042,10 +14093,11 @@ rm -f conftest.err conftest.i conftest.$ac_ext /* end confdefs.h. */ #include <ac_nonexistent.h> _ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : +if ac_fn_cxx_try_cpp "$LINENO" +then : # Broken: success on invalid input. continue -else +else $as_nop # Passes both tests. ac_preproc_ok=: break @@ -13055,7 +14107,8 @@ rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : +if $ac_preproc_ok +then : break fi @@ -13067,29 +14120,24 @@ fi else ac_cv_prog_CXXCPP=$CXXCPP fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -$as_echo "$CXXCPP" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +printf "%s\n" "$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif +#include <limits.h> Syntax error _ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : +if ac_fn_cxx_try_cpp "$LINENO" +then : -else +else $as_nop # Broken: fails on valid input. continue fi @@ -13101,10 +14149,11 @@ rm -f conftest.err conftest.i conftest.$ac_ext /* end confdefs.h. */ #include <ac_nonexistent.h> _ACEOF -if ac_fn_cxx_try_cpp "$LINENO"; then : +if ac_fn_cxx_try_cpp "$LINENO" +then : # Broken: success on invalid input. continue -else +else $as_nop # Passes both tests. ac_preproc_ok=: break @@ -13114,11 +14163,12 @@ rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : +if $ac_preproc_ok +then : -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +else $as_nop + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi @@ -13254,17 +14304,18 @@ cc_basename=$func_cc_basename_result # Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : +if test ${with_gnu_ld+y} +then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes -else +else $as_nop with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +printf %s "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw @@ -13293,15 +14344,16 @@ $as_echo_n "checking for ld used by $CC... " >&6; } ;; esac elif test yes = "$with_gnu_ld"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +printf %s "checking for GNU ld... " >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +printf %s "checking for non-GNU ld... " >&6; } fi -if ${lt_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else +if test ${lt_cv_path_LD+y} +then : + printf %s "(cached) " >&6 +else $as_nop if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do @@ -13330,18 +14382,19 @@ fi LD=$lt_cv_path_LD if test -n "$LD"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 -$as_echo "$LD" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +printf "%s\n" "$LD" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${lt_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +printf %s "checking if the linker ($LD) is GNU ld... " >&6; } +if test ${lt_cv_prog_gnu_ld+y} +then : + printf %s "(cached) " >&6 +else $as_nop # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 </dev/null` in *GNU* | *'with BFD'*) @@ -13352,8 +14405,8 @@ case `$LD -v 2>&1 </dev/null` in ;; esac fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5 -$as_echo "$lt_cv_prog_gnu_ld" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5 +printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld @@ -13407,8 +14460,8 @@ with_gnu_ld=$lt_cv_prog_gnu_ld fi # PORTME: fill in a description of your system's C++ link characteristics - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } ld_shlibs_CXX=yes case $host_os in aix3*) @@ -13546,21 +14599,23 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if ${lt_cv_aix_libpath__CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${lt_cv_aix_libpath__CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO" +then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -13575,7 +14630,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib @@ -13600,21 +14655,23 @@ fi if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else - if ${lt_cv_aix_libpath__CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${lt_cv_aix_libpath__CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : +if ac_fn_cxx_try_link "$LINENO" +then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { @@ -13629,7 +14686,7 @@ if ac_fn_cxx_try_link "$LINENO"; then : lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath__CXX"; then lt_cv_aix_libpath__CXX=/usr/lib:/lib @@ -13694,8 +14751,8 @@ fi cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC + ,cl* | no,cl* | ,icl* | no,icl*) + # Native MSVC or ICC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_CXX=' ' @@ -13786,11 +14843,11 @@ fi output_verbose_link_cmd=func_echo_all archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" - archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" - module_expsym_cmds_CXX="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + archive_expsym_cmds_CXX="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds_CXX="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" if test yes != "$lt_cv_apple_cc_single_mod"; then archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" - archive_expsym_cmds_CXX="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + archive_expsym_cmds_CXX="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi else @@ -13825,6 +14882,7 @@ fi emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds_CXX='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes_CXX=yes + file_list_spec_CXX='@' ;; dgux*) @@ -13855,7 +14913,7 @@ fi archive_cmds_need_lc_CXX=no ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions ld_shlibs_CXX=yes @@ -13992,7 +15050,7 @@ fi # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds_CXX='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in @@ -14132,13 +15190,13 @@ fi archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 no_undefined_flag_CXX=' -zdefs' @@ -14480,8 +15538,8 @@ fi ;; esac - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -$as_echo "$ld_shlibs_CXX" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +printf "%s\n" "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no GCC_CXX=$GXX @@ -14519,7 +15577,7 @@ esac if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. @@ -14795,7 +15853,7 @@ lt_prog_compiler_static_CXX= ;; esac ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) @@ -14878,7 +15936,7 @@ lt_prog_compiler_static_CXX= lt_prog_compiler_static_CXX='-qstaticlink' ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 lt_prog_compiler_pic_CXX='-KPIC' @@ -15000,26 +16058,28 @@ case $host_os in ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } -if ${lt_cv_prog_compiler_pic_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +printf %s "checking for $compiler option to produce PIC... " >&6; } +if test ${lt_cv_prog_compiler_pic_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_CXX" >&6; } lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 -$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } -if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } +if test ${lt_cv_prog_compiler_pic_works_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_pic_works_CXX=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext @@ -15050,8 +16110,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_pic_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works_CXX"; then case $lt_prog_compiler_pic_CXX in @@ -15073,11 +16133,12 @@ fi # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 -$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if test ${lt_cv_prog_compiler_static_works_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_static_works_CXX=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" @@ -15101,8 +16162,8 @@ else LDFLAGS=$save_LDFLAGS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_static_works_CXX" >&6; } if test yes = "$lt_cv_prog_compiler_static_works_CXX"; then : @@ -15113,11 +16174,12 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest @@ -15160,16 +16222,17 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 -$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if test ${lt_cv_prog_compiler_c_o_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_prog_compiler_c_o_CXX=no $RM -r conftest 2>/dev/null mkdir conftest @@ -15212,8 +16275,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 -$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +printf "%s\n" "$lt_cv_prog_compiler_c_o_CXX" >&6; } @@ -15221,19 +16284,19 @@ $as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o_CXX" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 -$as_echo_n "checking if we can lock with hard links... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +printf %s "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 -$as_echo "$hard_links" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +printf "%s\n" "$hard_links" >&6; } if test no = "$hard_links"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -15242,8 +16305,8 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 -$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' @@ -15260,7 +16323,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + export_symbols_cmds_CXX='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) @@ -15268,7 +16331,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie ;; cygwin* | mingw* | cegcc*) case $cc_basename in - cl*) + cl* | icl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) @@ -15282,8 +16345,8 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 -$as_echo "$ld_shlibs_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +printf "%s\n" "$ld_shlibs_CXX" >&6; } test no = "$ld_shlibs_CXX" && can_build_shared=no with_gnu_ld_CXX=$with_gnu_ld @@ -15310,18 +16373,19 @@ x|xyes) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 -$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } -if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +printf %s "checking whether -lc should be explicitly linked in... " >&6; } +if test ${lt_cv_archive_cmds_need_lc_CXX+y} +then : + printf %s "(cached) " >&6 +else $as_nop $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest @@ -15339,7 +16403,7 @@ else if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc_CXX=no @@ -15353,8 +16417,8 @@ else $RM conftest* fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 -$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5 +printf "%s\n" "$lt_cv_archive_cmds_need_lc_CXX" >&6; } archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX ;; esac @@ -15423,8 +16487,8 @@ esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 -$as_echo_n "checking dynamic linker characteristics... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +printf %s "checking dynamic linker characteristics... " >&6; } library_names_spec= libname_spec='lib$name' @@ -15615,7 +16679,7 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; mingw* | cegcc*) @@ -15624,14 +16688,14 @@ cygwin* | mingw* | pw32* | cegcc*) ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC + *,cl* | *,icl*) + # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' @@ -15650,7 +16714,7 @@ cygwin* | mingw* | pw32* | cegcc*) done IFS=$lt_save_ifs # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form @@ -15687,7 +16751,7 @@ cygwin* | mingw* | pw32* | cegcc*) ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; @@ -15719,7 +16783,7 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then @@ -15912,9 +16976,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH - if ${lt_cv_shlibpath_overrides_runpath+:} false; then : - $as_echo_n "(cached) " >&6 -else + if test ${lt_cv_shlibpath_overrides_runpath+y} +then : + printf %s "(cached) " >&6 +else $as_nop lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir @@ -15924,19 +16989,21 @@ else /* end confdefs.h. */ int -main () +main (void) { ; return 0; } _ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : +if ac_fn_cxx_try_link "$LINENO" +then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null +then : lt_cv_shlibpath_overrides_runpath=yes fi fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir @@ -16168,8 +17235,8 @@ uts4*) dynamic_linker=no ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 -$as_echo "$dynamic_linker" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +printf "%s\n" "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" @@ -16233,8 +17300,8 @@ configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 -$as_echo_n "checking how to hardcode library paths into programs... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +printf %s "checking how to hardcode library paths into programs... " >&6; } hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || test -n "$runpath_var_CXX" || @@ -16258,8 +17325,8 @@ else # directories. hardcode_action_CXX=unsupported fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 -$as_echo "$hardcode_action_CXX" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 +printf "%s\n" "$hardcode_action_CXX" >&6; } if test relink = "$hardcode_action_CXX" || test yes = "$inherit_rpath_CXX"; then @@ -16320,6 +17387,13 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +saved_CXXFLAGS="$CXXFLAGS" +regular_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_REENTRANT" +regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \ + -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \ + -Wformat=2 -pipe $visibility_CFLAGS" +regular_CXXFLAGS="-Wall -Wno-pointer-arith -Wredundant-decls -pipe \ + $visibility_CFLAGS" # # Check whether there really is a C++ compiler. # It is not mandatory to compile libHX, but we want to know. @@ -16334,19 +17408,57 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { return 0; ; return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_cxx_try_compile "$LINENO" +then : ac_cv_cxx=yes -else +else $as_nop ac_cv_cxx=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking available C++ standard" >&5 +printf %s "checking available C++ standard... " >&6; } +cxxmode="" +for i in "c++20" "c++17"; do + if test "$i" = "c++20" && test -n "$COVERITY" +then : + continue +fi + CXXFLAGS="$saved_CXXFLAGS -std=$i" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO" +then : + cxxmode="$i" +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + if test -n "$cxxmode" +then : + break +fi +done +CXXFLAGS="$saved_CXXFLAGS" +if test -n "$cxxmode" +then : + + regular_CXXFLAGS="$regular_CXXFLAGS -std=$cxxmode" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cxxmode" >&5 +printf "%s\n" "$cxxmode" >&6; } + +else $as_nop + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5 +printf "%s\n" "none" >&6; } + +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -16362,8 +17474,8 @@ else fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mingw32" >&5 -$as_echo_n "checking for mingw32... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for mingw32" >&5 +printf %s "checking for mingw32... " >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -16374,22 +17486,23 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int -main () +main (void) { return __MINGW32__; ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_mingw32=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - ac_cv_mingw32=no; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +if ac_fn_c_try_compile "$LINENO" +then : + ac_cv_mingw32=yes; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } +else $as_nop + ac_cv_mingw32=no; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -16407,9 +17520,10 @@ fi # Check whether --with-pkgconfigdir was given. -if test "${with_pkgconfigdir+set}" = set; then : +if test ${with_pkgconfigdir+y} +then : withval=$with_pkgconfigdir; pkgconfigdir="$withval" -else +else $as_nop pkgconfigdir='${libdir}/pkgconfig' fi @@ -16424,28 +17538,30 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu saved_CFLAGS="$CFLAGS" CFLAGS="$saved_CFLAGS -fvisibility=hidden" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler accepts -fvisibility=hidden" >&5 -$as_echo_n "checking whether compiler accepts -fvisibility=hidden... " >&6; } -if ${ac_cv_fvisibility_hidden+:} false; then : - $as_echo_n "(cached) " >&6 -else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler accepts -fvisibility=hidden" >&5 +printf %s "checking whether compiler accepts -fvisibility=hidden... " >&6; } +if test ${ac_cv_fvisibility_hidden+y} +then : + printf %s "(cached) " >&6 +else $as_nop cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO" +then : ac_cv_fvisibility_hidden=yes -else +else $as_nop ac_cv_fvisibility_hidden=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fvisibility_hidden" >&5 -$as_echo "$ac_cv_fvisibility_hidden" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fvisibility_hidden" >&5 +printf "%s\n" "$ac_cv_fvisibility_hidden" >&6; } if test "$ac_cv_fvisibility_hidden" = "yes"; then -$as_echo "#define HAVE_VISIBILITY_HIDDEN 1" >>confdefs.h +printf "%s\n" "#define HAVE_VISIBILITY_HIDDEN 1" >>confdefs.h visibility_CFLAGS="-fvisibility=hidden" fi @@ -16467,18 +17583,24 @@ fi LIBS_system="$LIBS" -for ac_header in dlfcn.h sys/resource.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF +ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" +if test "x$ac_cv_header_dlfcn_h" = xyes +then : + printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h fi +ac_fn_c_check_header_compile "$LINENO" "sys/resource.h" "ac_cv_header_sys_resource_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_resource_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_RESOURCE_H 1" >>confdefs.h -done +fi +ac_fn_c_check_header_compile "$LINENO" "sys/un.h" "ac_cv_header_sys_un_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_un_h" = xyes +then : + printf "%s\n" "#define HAVE_SYS_UN_H 1" >>confdefs.h + +fi if test "$ac_cv_header_dlfcn_h" = "yes"; then HAVE_DLFCN_H_TRUE= @@ -16488,11 +17610,12 @@ else HAVE_DLFCN_H_FALSE= fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 -$as_echo_n "checking for library containing dlopen... " >&6; } -if ${ac_cv_search_dlopen+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 +printf %s "checking for library containing dlopen... " >&6; } +if test ${ac_cv_search_dlopen+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -16500,57 +17623,60 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char dlopen (); int -main () +main (void) { return dlopen (); ; return 0; } _ACEOF -for ac_lib in '' dl; do +for ac_lib in '' dl +do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_c_try_link "$LINENO" +then : ac_cv_search_dlopen=$ac_res fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext - if ${ac_cv_search_dlopen+:} false; then : + if test ${ac_cv_search_dlopen+y} +then : break fi done -if ${ac_cv_search_dlopen+:} false; then : +if test ${ac_cv_search_dlopen+y} +then : -else +else $as_nop ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 -$as_echo "$ac_cv_search_dlopen" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +printf "%s\n" "$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen -if test "$ac_res" != no; then : +if test "$ac_res" != no +then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" libdl_LIBS="$LIBS"; LIBS="$LIBS_system" fi # glibc < 2.17 has it in librt, mingw-w64 has it in libpthread -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 -$as_echo_n "checking for library containing clock_gettime... " >&6; } -if ${ac_cv_search_clock_gettime+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 +printf %s "checking for library containing clock_gettime... " >&6; } +if test ${ac_cv_search_clock_gettime+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -16558,56 +17684,59 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char clock_gettime (); int -main () +main (void) { return clock_gettime (); ; return 0; } _ACEOF -for ac_lib in '' rt pthread; do +for ac_lib in '' rt pthread +do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_c_try_link "$LINENO" +then : ac_cv_search_clock_gettime=$ac_res fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext - if ${ac_cv_search_clock_gettime+:} false; then : + if test ${ac_cv_search_clock_gettime+y} +then : break fi done -if ${ac_cv_search_clock_gettime+:} false; then : +if test ${ac_cv_search_clock_gettime+y} +then : -else +else $as_nop ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 -$as_echo "$ac_cv_search_clock_gettime" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 +printf "%s\n" "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime -if test "$ac_res" != no; then : +if test "$ac_res" != no +then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" librt_LIBS="$LIBS"; LIBS="$LIBS_system" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_mutex_lock" >&5 -$as_echo_n "checking for library containing pthread_mutex_lock... " >&6; } -if ${ac_cv_search_pthread_mutex_lock+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_mutex_lock" >&5 +printf %s "checking for library containing pthread_mutex_lock... " >&6; } +if test ${ac_cv_search_pthread_mutex_lock+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -16615,46 +17744,48 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char pthread_mutex_lock (); int -main () +main (void) { return pthread_mutex_lock (); ; return 0; } _ACEOF -for ac_lib in '' pthread; do +for ac_lib in '' pthread +do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_c_try_link "$LINENO" +then : ac_cv_search_pthread_mutex_lock=$ac_res fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext - if ${ac_cv_search_pthread_mutex_lock+:} false; then : + if test ${ac_cv_search_pthread_mutex_lock+y} +then : break fi done -if ${ac_cv_search_pthread_mutex_lock+:} false; then : +if test ${ac_cv_search_pthread_mutex_lock+y} +then : -else +else $as_nop ac_cv_search_pthread_mutex_lock=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_mutex_lock" >&5 -$as_echo "$ac_cv_search_pthread_mutex_lock" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_mutex_lock" >&5 +printf "%s\n" "$ac_cv_search_pthread_mutex_lock" >&6; } ac_res=$ac_cv_search_pthread_mutex_lock -if test "$ac_res" != no; then : +if test "$ac_res" != no +then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" libpthread_LIBS="$LIBS"; LIBS="$LIBS_system" fi @@ -16662,11 +17793,12 @@ fi libsocket_ok=0 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5 -$as_echo_n "checking for library containing getaddrinfo... " >&6; } -if ${ac_cv_search_getaddrinfo+:} false; then : - $as_echo_n "(cached) " >&6 -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing getaddrinfo" >&5 +printf %s "checking for library containing getaddrinfo... " >&6; } +if test ${ac_cv_search_getaddrinfo+y} +then : + printf %s "(cached) " >&6 +else $as_nop ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -16674,53 +17806,55 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif char getaddrinfo (); int -main () +main (void) { return getaddrinfo (); ; return 0; } _ACEOF -for ac_lib in '' socket; do +for ac_lib in '' socket +do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - if ac_fn_c_try_link "$LINENO"; then : + if ac_fn_c_try_link "$LINENO" +then : ac_cv_search_getaddrinfo=$ac_res fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext - if ${ac_cv_search_getaddrinfo+:} false; then : + if test ${ac_cv_search_getaddrinfo+y} +then : break fi done -if ${ac_cv_search_getaddrinfo+:} false; then : +if test ${ac_cv_search_getaddrinfo+y} +then : -else +else $as_nop ac_cv_search_getaddrinfo=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5 -$as_echo "$ac_cv_search_getaddrinfo" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_getaddrinfo" >&5 +printf "%s\n" "$ac_cv_search_getaddrinfo" >&6; } ac_res=$ac_cv_search_getaddrinfo -if test "$ac_res" != no; then : +if test "$ac_res" != no +then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" libsocket_LIBS="$LIBS"; LIBS="$LIBS_system"; libsocket_ok=1 fi if test $libsocket_ok = 0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking non-standard libraries containing getaddrinfo" >&5 -$as_echo_n "checking non-standard libraries containing getaddrinfo... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking non-standard libraries containing getaddrinfo" >&5 +printf %s "checking non-standard libraries containing getaddrinfo... " >&6; } LIBS="$LIBS_system -lws2_32"; cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -16730,19 +17864,20 @@ $as_echo_n "checking non-standard libraries containing getaddrinfo... " >&6; } int main(void) { return getaddrinfo(NULL, NULL, NULL, NULL); } _ACEOF -if ac_fn_c_try_link "$LINENO"; then : +if ac_fn_c_try_link "$LINENO" +then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: -lws2_32" >&5 -$as_echo "-lws2_32" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -lws2_32" >&5 +printf "%s\n" "-lws2_32" >&6; } libsocket_LIBS="$libsocket_LIBS $LIBS"; -else +else $as_nop - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext LIBS="$LIBS_system"; fi; @@ -16752,17 +17887,19 @@ fi; # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 -$as_echo_n "checking size of void *... " >&6; } -if ${ac_cv_sizeof_void_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : - -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 +printf %s "checking size of void *... " >&6; } +if test ${ac_cv_sizeof_void_p+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default" +then : + +else $as_nop if test "$ac_cv_type_void_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void *) See \`config.log' for more details" "$LINENO" 5; } else @@ -16771,31 +17908,31 @@ See \`config.log' for more details" "$LINENO" 5; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 -$as_echo "$ac_cv_sizeof_void_p" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 +printf "%s\n" "$ac_cv_sizeof_void_p" >&6; } -cat >>confdefs.h <<_ACEOF -#define SIZEOF_VOID_P $ac_cv_sizeof_void_p -_ACEOF +printf "%s\n" "#define SIZEOF_VOID_P $ac_cv_sizeof_void_p" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char *" >&5 -$as_echo_n "checking size of char *... " >&6; } -if ${ac_cv_sizeof_char_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p" "$ac_includes_default"; then : - -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of char *" >&5 +printf %s "checking size of char *... " >&6; } +if test ${ac_cv_sizeof_char_p+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p" "$ac_includes_default" +then : + +else $as_nop if test "$ac_cv_type_char_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (char *) See \`config.log' for more details" "$LINENO" 5; } else @@ -16804,31 +17941,31 @@ See \`config.log' for more details" "$LINENO" 5; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char_p" >&5 -$as_echo "$ac_cv_sizeof_char_p" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char_p" >&5 +printf "%s\n" "$ac_cv_sizeof_char_p" >&6; } -cat >>confdefs.h <<_ACEOF -#define SIZEOF_CHAR_P $ac_cv_sizeof_char_p -_ACEOF +printf "%s\n" "#define SIZEOF_CHAR_P $ac_cv_sizeof_char_p" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct x *" >&5 -$as_echo_n "checking size of struct x *... " >&6; } -if ${ac_cv_sizeof_struct_x_p+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct x *))" "ac_cv_sizeof_struct_x_p" "$ac_includes_default"; then : - -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of struct x *" >&5 +printf %s "checking size of struct x *... " >&6; } +if test ${ac_cv_sizeof_struct_x_p+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct x *))" "ac_cv_sizeof_struct_x_p" "$ac_includes_default" +then : + +else $as_nop if test "$ac_cv_type_struct_x_p" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (struct x *) See \`config.log' for more details" "$LINENO" 5; } else @@ -16837,31 +17974,31 @@ See \`config.log' for more details" "$LINENO" 5; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_x_p" >&5 -$as_echo "$ac_cv_sizeof_struct_x_p" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_x_p" >&5 +printf "%s\n" "$ac_cv_sizeof_struct_x_p" >&6; } -cat >>confdefs.h <<_ACEOF -#define SIZEOF_STRUCT_X_P $ac_cv_sizeof_struct_x_p -_ACEOF +printf "%s\n" "#define SIZEOF_STRUCT_X_P $ac_cv_sizeof_struct_x_p" >>confdefs.h # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of struct x **" >&5 -$as_echo_n "checking size of struct x **... " >&6; } -if ${ac_cv_sizeof_struct_x_pp+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct x **))" "ac_cv_sizeof_struct_x_pp" "$ac_includes_default"; then : - -else +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of struct x **" >&5 +printf %s "checking size of struct x **... " >&6; } +if test ${ac_cv_sizeof_struct_x_pp+y} +then : + printf %s "(cached) " >&6 +else $as_nop + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (struct x **))" "ac_cv_sizeof_struct_x_pp" "$ac_includes_default" +then : + +else $as_nop if test "$ac_cv_type_struct_x_pp" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (struct x **) See \`config.log' for more details" "$LINENO" 5; } else @@ -16870,14 +18007,12 @@ See \`config.log' for more details" "$LINENO" 5; } fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_x_pp" >&5 -$as_echo "$ac_cv_sizeof_struct_x_pp" >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_struct_x_pp" >&5 +printf "%s\n" "$ac_cv_sizeof_struct_x_pp" >&6; } -cat >>confdefs.h <<_ACEOF -#define SIZEOF_STRUCT_X_PP $ac_cv_sizeof_struct_x_pp -_ACEOF +printf "%s\n" "#define SIZEOF_STRUCT_X_PP $ac_cv_sizeof_struct_x_pp" >>confdefs.h if test "$ac_cv_sizeof_void_p" != "$ac_cv_sizeof_char_p" || @@ -16893,11 +18028,10 @@ ac_fn_c_check_member "$LINENO" "struct timespec" "tv_nsec" "ac_cv_member_struct_ #include <time.h> " -if test "x$ac_cv_member_struct_timespec_tv_nsec" = xyes; then : +if test "x$ac_cv_member_struct_timespec_tv_nsec" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_TIMESPEC_TV_NSEC 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_TIMESPEC_TV_NSEC 1" >>confdefs.h fi @@ -16907,11 +18041,10 @@ ac_fn_c_check_member "$LINENO" "struct timeval" "tv_usec" "ac_cv_member_struct_t #include <time.h> " -if test "x$ac_cv_member_struct_timeval_tv_usec" = xyes; then : +if test "x$ac_cv_member_struct_timeval_tv_usec" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_TIMEVAL_TV_USEC 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_TIMEVAL_TV_USEC 1" >>confdefs.h fi @@ -16921,11 +18054,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimensec" "ac_cv_member_struct #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_mtimensec" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_mtimensec" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1" >>confdefs.h fi @@ -16935,11 +18067,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_mtim" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIM 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_MTIM 1" >>confdefs.h fi @@ -16949,11 +18080,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec" "ac_cv_member_struct #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_mtimespec" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_mtimespec" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIMESPEC 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_MTIMESPEC 1" >>confdefs.h fi @@ -16963,11 +18093,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_mtime" "ac_cv_member_struct_sta #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_mtime" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_mtime" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_MTIME 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_MTIME 1" >>confdefs.h fi @@ -16977,11 +18106,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_otimensec" "ac_cv_member_struct #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_otimensec" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_otimensec" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_OTIMENSEC 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_OTIMENSEC 1" >>confdefs.h fi @@ -16991,11 +18119,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_otim" "ac_cv_member_struct_stat #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_otim" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_otim" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_OTIM 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_OTIM 1" >>confdefs.h fi @@ -17005,11 +18132,10 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_otimespec" "ac_cv_member_struct #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_otimespec" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_otimespec" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_OTIMESPEC 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_OTIMESPEC 1" >>confdefs.h fi @@ -17019,109 +18145,88 @@ ac_fn_c_check_member "$LINENO" "struct stat" "st_otime" "ac_cv_member_struct_sta #include <time.h> " -if test "x$ac_cv_member_struct_stat_st_otime" = xyes; then : +if test "x$ac_cv_member_struct_stat_st_otime" = xyes +then : -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_STAT_ST_OTIME 1 -_ACEOF +printf "%s\n" "#define HAVE_STRUCT_STAT_ST_OTIME 1" >>confdefs.h fi -for ac_func in fork execv execvp pipe -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - b_proc="1" +ac_fn_c_check_func "$LINENO" "fork" "ac_cv_func_fork" +if test "x$ac_cv_func_fork" = xyes +then : + printf "%s\n" "#define HAVE_FORK 1" >>confdefs.h + fi -done +ac_fn_c_check_func "$LINENO" "execv" "ac_cv_func_execv" +if test "x$ac_cv_func_execv" = xyes +then : + printf "%s\n" "#define HAVE_EXECV 1" >>confdefs.h -for ac_func in getegid geteuid getpid getppid -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF +fi +ac_fn_c_check_func "$LINENO" "execvp" "ac_cv_func_execvp" +if test "x$ac_cv_func_execvp" = xyes +then : + printf "%s\n" "#define HAVE_EXECVP 1" >>confdefs.h fi -done +ac_fn_c_check_func "$LINENO" "pipe" "ac_cv_func_pipe" +if test "x$ac_cv_func_pipe" = xyes +then : + printf "%s\n" "#define HAVE_PIPE 1" >>confdefs.h - if test "$b_proc" = 1; then - B_PROC_TRUE= - B_PROC_FALSE='#' -else - B_PROC_TRUE='#' - B_PROC_FALSE= fi +ac_fn_c_check_func "$LINENO" "posix_fadvise" "ac_cv_func_posix_fadvise" +if test "x$ac_cv_func_posix_fadvise" = xyes +then : + printf "%s\n" "#define HAVE_POSIX_FADVISE 1" >>confdefs.h +fi -for ac_prog in lyx -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_LYX+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$LYX"; then - ac_cv_prog_LYX="$LYX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_LYX="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS +ac_fn_c_check_func "$LINENO" "getegid" "ac_cv_func_getegid" +if test "x$ac_cv_func_getegid" = xyes +then : + printf "%s\n" "#define HAVE_GETEGID 1" >>confdefs.h fi +ac_fn_c_check_func "$LINENO" "geteuid" "ac_cv_func_geteuid" +if test "x$ac_cv_func_geteuid" = xyes +then : + printf "%s\n" "#define HAVE_GETEUID 1" >>confdefs.h + fi -LYX=$ac_cv_prog_LYX -if test -n "$LYX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LYX" >&5 -$as_echo "$LYX" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +ac_fn_c_check_func "$LINENO" "getpid" "ac_cv_func_getpid" +if test "x$ac_cv_func_getpid" = xyes +then : + printf "%s\n" "#define HAVE_GETPID 1" >>confdefs.h + fi +ac_fn_c_check_func "$LINENO" "getppid" "ac_cv_func_getppid" +if test "x$ac_cv_func_getppid" = xyes +then : + printf "%s\n" "#define HAVE_GETPPID 1" >>confdefs.h +fi - test -n "$LYX" && break -done +ac_fn_c_check_func "$LINENO" "initgroups" "ac_cv_func_initgroups" +if test "x$ac_cv_func_initgroups" = xyes +then : + printf "%s\n" "#define HAVE_INITGROUPS 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "setgid" "ac_cv_func_setgid" +if test "x$ac_cv_func_setgid" = xyes +then : + printf "%s\n" "#define HAVE_SETGID 1" >>confdefs.h - if test -n "$LYX"; then - BUILD_DOCS_TRUE= - BUILD_DOCS_FALSE='#' -else - BUILD_DOCS_TRUE='#' - BUILD_DOCS_FALSE= fi -regular_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_REENTRANT" -regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \ - -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \ - -Wformat=2 -pipe $visibility_CFLAGS" -regular_CXXFLAGS="-Wall -Wno-pointer-arith -Wredundant-decls -pipe \ - $visibility_CFLAGS"; -ac_config_files="$ac_config_files Makefile assorted/Makefile doc/Makefile src/Makefile include/Makefile libHX.pc" +ac_config_files="$ac_config_files Makefile src/Makefile include/Makefile libHX.pc" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -17150,8 +18255,8 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( @@ -17181,15 +18286,15 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; /^ac_cv_env_/b end t clear :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +printf "%s\n" "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else @@ -17203,8 +18308,8 @@ $as_echo "$as_me: updating cache $cache_file" >&6;} fi fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -17221,7 +18326,7 @@ U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" @@ -17232,14 +18337,14 @@ LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 -$as_echo_n "checking that generated files are newer than configure... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +printf %s "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 -$as_echo "done" >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: done" >&5 +printf "%s\n" "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' @@ -17276,21 +18381,13 @@ if test -z "${HAVE_DLFCN_H_TRUE}" && test -z "${HAVE_DLFCN_H_FALSE}"; then as_fn_error $? "conditional \"HAVE_DLFCN_H\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${B_PROC_TRUE}" && test -z "${B_PROC_FALSE}"; then - as_fn_error $? "conditional \"B_PROC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${BUILD_DOCS_TRUE}" && test -z "${BUILD_DOCS_FALSE}"; then - as_fn_error $? "conditional \"BUILD_DOCS\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL @@ -17313,14 +18410,16 @@ cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : +as_nop=: +if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 +then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST -else +else $as_nop case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( @@ -17330,46 +18429,46 @@ esac fi + +# Reset variables that may have inherited troublesome values from +# the environment. + +# IFS needs to be set, to space, tab, and newline, in precisely that order. +# (If _AS_PATH_WALK were called with IFS unset, it would have the +# side effect of setting IFS to empty, thus disabling word splitting.) +# Quoting is to prevent editors from complaining about space-tab. as_nl=' ' export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi +IFS=" "" $as_nl" + +PS1='$ ' +PS2='> ' +PS4='+ ' + +# Ensure predictable behavior from utilities with locale-dependent output. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# We cannot yet rely on "unset" to work, but we need these variables +# to be unset--not just set to an empty or harmless value--now, to +# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct +# also avoids known problems related to "unset" and subshell syntax +# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). +for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH +do eval test \${$as_var+y} \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done + +# Ensure that fds 0, 1, and 2 are open. +if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi +if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi +if (exec 3>&2) ; then :; else exec 2>/dev/null; fi # The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then +if ${PATH_SEPARATOR+false} :; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || @@ -17378,13 +18477,6 @@ if test "${PATH_SEPARATOR+set}" != set; then fi -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( @@ -17393,8 +18485,12 @@ case $0 in #(( for as_dir in $PATH do IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + test -r "$as_dir$0" && as_myself=$as_dir$0 && break done IFS=$as_save_IFS @@ -17406,30 +18502,10 @@ if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] @@ -17442,13 +18518,14 @@ as_fn_error () as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $2" >&2 + printf "%s\n" "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error + # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. @@ -17475,18 +18552,20 @@ as_fn_unset () { eval $1=; unset $1;} } as_unset=as_fn_unset + # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null +then : eval 'as_fn_append () { eval $1+=\$2 }' -else +else $as_nop as_fn_append () { eval $1=\$$1\$2 @@ -17498,12 +18577,13 @@ fi # as_fn_append # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null +then : eval 'as_fn_arith () { as_val=$(( $* )) }' -else +else $as_nop as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` @@ -17534,7 +18614,7 @@ as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | +printf "%s\n" X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q @@ -17556,6 +18636,10 @@ as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits + +# Determine whether it's possible to make 'echo' print without a newline. +# These variables are no longer used directly by Autoconf, but are AC_SUBSTed +# for compatibility with existing Makefiles. ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) @@ -17569,6 +18653,12 @@ case `echo -n x` in #((((( ECHO_N='-n';; esac +# For backward compatibility with old third-party macros, we provide +# the shell variables $as_echo and $as_echo_n. New code should use +# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. +as_echo='printf %s\n' +as_echo_n='printf %s' + rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file @@ -17610,7 +18700,7 @@ as_fn_mkdir_p () as_dirs= while :; do case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" @@ -17619,7 +18709,7 @@ $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | +printf "%s\n" X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -17681,8 +18771,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libHX $as_me 3.25, which was -generated by GNU Autoconf 2.69. Invocation command line was +This file was extended by libHX $as_me 4.10, which was +generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -17744,14 +18834,16 @@ $config_commands Report bugs to the package provider." _ACEOF +ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` +ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libHX config.status 3.25 -configured by $0, generated by GNU Autoconf 2.69, +libHX config.status 4.10 +configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" -Copyright (C) 2012 Free Software Foundation, Inc. +Copyright (C) 2021 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -17791,15 +18883,15 @@ do -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; + printf "%s\n" "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; + printf "%s\n" "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" @@ -17807,7 +18899,7 @@ do --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; @@ -17816,7 +18908,7 @@ do as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; + printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; @@ -17844,7 +18936,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" @@ -17858,7 +18950,7 @@ exec 5>>config.log sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX - $as_echo "$ac_log" + printf "%s\n" "$ac_log" } >&5 _ACEOF @@ -17866,7 +18958,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" +AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout @@ -17910,6 +19002,7 @@ lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_q lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +FILECMD='`$ECHO "$FILECMD" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' @@ -17918,6 +19011,7 @@ want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' @@ -18092,6 +19186,7 @@ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ +FILECMD \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ @@ -18100,7 +19195,6 @@ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ -AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ @@ -18261,8 +19355,6 @@ do "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "assorted/Makefile") CONFIG_FILES="$CONFIG_FILES assorted/Makefile" ;; - "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "libHX.pc") CONFIG_FILES="$CONFIG_FILES libHX.pc" ;; @@ -18277,9 +19369,9 @@ done # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers - test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands + test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files + test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers + test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree @@ -18615,7 +19707,7 @@ do esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done @@ -18623,17 +19715,17 @@ do # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +printf "%s\n" "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | + ac_sed_conf_input=`printf "%s\n" "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac @@ -18650,7 +19742,7 @@ $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | +printf "%s\n" X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -18674,9 +19766,9 @@ $as_echo X"$ac_file" | case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; @@ -18738,8 +19830,8 @@ ac_sed_dataroot=' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' @@ -18783,9 +19875,9 @@ test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" @@ -18801,20 +19893,20 @@ which seems to be undefined. Please make sure it is defined" >&2;} # if test x"$ac_file" != x-; then { - $as_echo "/* $configure_input */" \ + printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else - $as_echo "/* $configure_input */" \ + printf "%s\n" "/* $configure_input */" >&1 \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi @@ -18834,7 +19926,7 @@ $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$_am_arg" | +printf "%s\n" X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -18854,8 +19946,8 @@ $as_echo X"$_am_arg" | s/.*/./; q'`/stamp-h$_am_stamp_count ;; - :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 -$as_echo "$as_me: executing $ac_file commands" >&6;} + :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +printf "%s\n" "$as_me: executing $ac_file commands" >&6;} ;; esac @@ -18865,29 +19957,35 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac shift - for mf + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf do # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named 'Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line + am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -18905,53 +20003,50 @@ $as_echo X"$mf" | q } s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running 'make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "$am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +printf "%s\n" X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } - /^X\(\/\/\)$/{ + /^X\/\(\/\/\)$/{ s//\1/ q } - /^X\(\/\).*/{ + /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? done + if test $am_rc -ne 0; then + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk } ;; "libtool":C) @@ -19088,6 +20183,9 @@ to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd +# A file(cmd) program that detects file types. +FILECMD=$lt_FILECMD + # An object symbol dumper. OBJDUMP=$lt_OBJDUMP @@ -19112,8 +20210,11 @@ sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR +# Flags to create an archive (by configure). +lt_ar_flags=$lt_ar_flags + # Flags to create an archive. -AR_FLAGS=$lt_AR_FLAGS +AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"} # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec @@ -19495,6 +20596,7 @@ _LT_EOF esac + ltmain=$ac_aux_dir/ltmain.sh @@ -19502,7 +20604,7 @@ ltmain=$ac_aux_dir/ltmain.sh # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ + $SED '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || @@ -19697,7 +20799,8 @@ if test "$no_create" != yes; then $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi + diff --git a/configure.ac b/configure.ac index 119bd7f..10c01b7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libHX], [3.25]) +AC_INIT([libHX], [4.10]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) @@ -11,9 +11,15 @@ AC_PROG_CXX m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_DISABLE_STATIC -AC_LIBTOOL_DLOPEN AM_PROG_LIBTOOL +saved_CXXFLAGS="$CXXFLAGS" +regular_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_REENTRANT" +regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \ + -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \ + -Wformat=2 -pipe $visibility_CFLAGS" +regular_CXXFLAGS="-Wall -Wno-pointer-arith -Wredundant-decls -pipe \ + $visibility_CFLAGS" # # Check whether there really is a C++ compiler. # It is not mandatory to compile libHX, but we want to know. @@ -22,6 +28,21 @@ AC_LANG_PUSH([C++]) AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([], [return 0;])], [ac_cv_cxx=yes], [ac_cv_cxx=no]) +AC_MSG_CHECKING([available C++ standard]) +cxxmode="" +for i in "c++20" "c++17"; do + AS_IF([test "$i" = "c++20" && test -n "$COVERITY"], [continue]) + CXXFLAGS="$saved_CXXFLAGS -std=$i" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [cxxmode="$i"]) + AS_IF([test -n "$cxxmode"], [break]) +done +CXXFLAGS="$saved_CXXFLAGS" +AS_IF([test -n "$cxxmode"], [ + regular_CXXFLAGS="$regular_CXXFLAGS -std=$cxxmode" + AC_MSG_RESULT([$cxxmode]) +], [ + AC_MSG_RESULT([none]) +]) AC_LANG_POP([C++]) AM_CONDITIONAL([HAVE_CXX], [test "$ac_cv_cxx" = yes]) @@ -44,7 +65,7 @@ CHECK_GCC_FVISIBILITY AM_CONDITIONAL([WITH_GNU_LD], [test "$with_gnu_ld" = yes]) LIBS_system="$LIBS" -AC_CHECK_HEADERS([dlfcn.h sys/resource.h]) +AC_CHECK_HEADERS([dlfcn.h sys/resource.h sys/un.h]) AM_CONDITIONAL([HAVE_DLFCN_H], [test "$ac_cv_header_dlfcn_h" = "yes"]) AC_SEARCH_LIBS([dlopen], [dl], [libdl_LIBS="$LIBS"; LIBS="$LIBS_system"]) AC_SUBST([libdl_LIBS]) @@ -103,22 +124,12 @@ AC_CHECK_MEMBERS( #include <sys/time.h> #include <time.h> ]) -AC_CHECK_FUNCS([fork execv execvp pipe], [b_proc="1"]) +AC_CHECK_FUNCS([fork execv execvp pipe posix_fadvise]) AC_CHECK_FUNCS([getegid geteuid getpid getppid]) -AM_CONDITIONAL([B_PROC], [test "$b_proc" = 1]) - -AC_CHECK_PROGS([LYX], [lyx]) -AM_CONDITIONAL([BUILD_DOCS], [test -n "$LYX"]) +AC_CHECK_FUNCS([initgroups setgid]) -regular_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_REENTRANT" -regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \ - -Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \ - -Wformat=2 -pipe $visibility_CFLAGS" -regular_CXXFLAGS="-Wall -Wno-pointer-arith -Wredundant-decls -pipe \ - $visibility_CFLAGS"; AC_SUBST([regular_CPPFLAGS]) AC_SUBST([regular_CFLAGS]) AC_SUBST([regular_CXXFLAGS]) -AC_CONFIG_FILES([Makefile assorted/Makefile doc/Makefile src/Makefile - include/Makefile libHX.pc]) +AC_CONFIG_FILES([Makefile src/Makefile include/Makefile libHX.pc]) AC_OUTPUT diff --git a/debian/changelog b/debian/changelog index 619b056..16df304 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,20 @@ +libhx (4.10-1) unstable; urgency=medium + + * New upstream release. + * Declare compliance with Debian Policy 4.6.2.0 (No changes needed). + * Fix lintian overrides. + * debian/watch: + - Bump standard version to 4. + - Switch to new download URL. + * debian/copyright: + - Refresh years. + - Add year 2023 to myself. + * Refresh symbols files. + * debian/libhx-dev.lintian-overrides: + - Add override for no-code-sections. + + -- Jörg Frings-Fürst <debian@jff.email> Thu, 09 Feb 2023 14:03:13 +0100 + libhx (3.25-2) unstable; urgency=medium * debian/control: diff --git a/debian/control b/debian/control index f0c65a7..98ef1be 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Priority: optional Maintainer: Jörg Frings-Fürst <debian@jff.email> Build-Depends: debhelper-compat (= 13) -Standards-Version: 4.5.0 +Standards-Version: 4.6.2.0 Section: libs Rules-Requires-Root: no Homepage: https://inai.de/projects/libhx/ diff --git a/debian/copyright b/debian/copyright index 817eb20..b879cf7 100644 --- a/debian/copyright +++ b/debian/copyright @@ -9,7 +9,7 @@ License: LGPL-2.1+ Files: debian/* Copyright: 2007-2014 Bastian Kleineidam <calvin@debian.org> - 2015-2020 Jörg Frings-Fürst <debian@jff.email> + 2015-2023 Jörg Frings-Fürst <debian@jff.email> License: GPL-3+ Files: debian/patches/* @@ -19,7 +19,7 @@ License: LGPL-2.1+ Files: build-aux/* m4/* -Copyright: 1992-2017 Free Software Foundation, Inc. +Copyright: 1992-2022 Free Software Foundation, Inc. License: GPL-2+ Files: src/tc-*.c diff --git a/debian/libhx-dev.lintian-overrides b/debian/libhx-dev.lintian-overrides index 15979c8..586a22d 100644 --- a/debian/libhx-dev.lintian-overrides +++ b/debian/libhx-dev.lintian-overrides @@ -1,4 +1,5 @@ # libHX_rtcheck is used to enable more internal checks dynamically libhx-dev: package-name-doesnt-match-sonames libHX-rtcheck libhx-dev: shared-library-lacks-version usr/lib/x86_64-linux-gnu/libHX_rtcheck.so libHX_rtcheck.so -libhx-dev: shared-library-lacks-prerequisites usr/lib/x86_64-linux-gnu/libHX_rtcheck.so +libhx-dev: shared-library-lacks-prerequisites [usr/lib/x86_64-linux-gnu/libHX_rtcheck.so] +libhx-dev: no-code-sections diff --git a/debian/libhx-dev.symbols b/debian/libhx-dev.symbols index abfb1ac..82ae111 100644 --- a/debian/libhx-dev.symbols +++ b/debian/libhx-dev.symbols @@ -1,3 +1,7 @@ libHX_rtcheck.so libhx-dev #MINVER# * Build-Depends-Package: libhx-dev LIBHX_3.25@LIBHX_3.25 3.25 + LIBHX_3.27@LIBHX_3.27 4.7 + LIBHX_4.2@LIBHX_4.2 4.7 + LIBHX_4.3@LIBHX_4.3 4.7 + LIBHX_4.9@LIBHX_4.9 4.10 diff --git a/debian/libhx-doc.doc-base b/debian/libhx-doc.doc-base index cb00bc2..88de3f3 100644 --- a/debian/libhx-doc.doc-base +++ b/debian/libhx-doc.doc-base @@ -6,4 +6,4 @@ Abstract: API documentation and tutorial for the libhx Section: Programming/C Format: PDF -Files: /usr/share/doc/libhx-doc/libHX_Documentation.pdf.gz +Files: /usr/share/doc/libhx-doc/libHX_Documentation.rst diff --git a/debian/libhx-doc.docs b/debian/libhx-doc.docs index 2389dc7..66eb2fe 100644 --- a/debian/libhx-doc.docs +++ b/debian/libhx-doc.docs @@ -1,6 +1,2 @@ +doc/*.rst doc/assorted.txt -doc/libHX_Documentation.pdf -doc/dirstamp.txt -doc/ux-file.txt -doc/ux-mmap.txt -doc/api.txt diff --git a/debian/libhx-doc.lintian-overrides b/debian/libhx-doc.lintian-overrides new file mode 100644 index 0000000..b5f698a --- /dev/null +++ b/debian/libhx-doc.lintian-overrides @@ -0,0 +1 @@ +libhx-doc: duplicate-changelog-files diff --git a/debian/libhx32.symbols b/debian/libhx32.symbols index 4e58b1d..4921f2a 100644 --- a/debian/libhx32.symbols +++ b/debian/libhx32.symbols @@ -22,6 +22,7 @@ libHX.so.32 libhx32 #MINVER# HX_getopt_usage_cb@LIBHX_3.25 3.25 HX_hexdump@LIBHX_3.25 3.25 HX_init@LIBHX_3.25 3.25 + HX_ipaddr_is_local@LIBHX_4.9 4.10 HX_irand@LIBHX_3.25 3.25 HX_memmem@LIBHX_3.25 3.25 HX_mkdir@LIBHX_3.25 3.25 @@ -29,10 +30,15 @@ libHX.so.32 libhx32 #MINVER# HX_readlink@LIBHX_3.25 3.25 HX_realpath@LIBHX_3.25 3.25 HX_rrmdir@LIBHX_3.25 3.25 + HX_sendfile@LIBHX_4.3 4.7 HX_shconfig@LIBHX_3.25 3.25 HX_shconfig_free@LIBHX_3.25 3.25 HX_shconfig_map@LIBHX_3.25 3.25 HX_shconfig_pv@LIBHX_3.25 3.25 + HX_slurp_fd@LIBHX_3.27 4.7 + HX_slurp_file@LIBHX_3.27 4.7 + HX_sockaddr_is_local@LIBHX_4.9 4.10 + HX_socket_from_env@LIBHX_3.27 4.7 HX_split@LIBHX_3.25 3.25 HX_split_fixed@LIBHX_3.25 3.25 HX_split_inplace@LIBHX_3.25 3.25 @@ -55,6 +61,9 @@ libHX.so.32 libhx32 #MINVER# HX_strrtrim@LIBHX_3.25 3.25 HX_strsep2@LIBHX_3.25 3.25 HX_strsep@LIBHX_3.25 3.25 + HX_strtod_unit@LIBHX_4.2 4.7 + HX_strtoull_sec@LIBHX_4.3 4.7 + HX_strtoull_unit@LIBHX_4.2 4.7 HX_strupper@LIBHX_3.25 3.25 HX_time_compare@LIBHX_3.25 3.25 HX_timespec_add@LIBHX_3.25 3.25 @@ -64,6 +73,9 @@ libHX.so.32 libhx32 #MINVER# HX_timespec_neg@LIBHX_3.25 3.25 HX_timespec_sub@LIBHX_3.25 3.25 HX_timeval_sub@LIBHX_3.25 3.25 + HX_unit_seconds@LIBHX_4.3 4.7 + HX_unit_size@LIBHX_4.2 4.7 + HX_unit_size_cu@LIBHX_4.2 4.7 HX_zvecfree@LIBHX_3.25 3.25 HXdeque_del@LIBHX_3.25 3.25 HXdeque_find@LIBHX_3.25 3.25 @@ -80,6 +92,9 @@ libHX.so.32 libhx32 #MINVER# HXdir_close@LIBHX_3.25 3.25 HXdir_open@LIBHX_3.25 3.25 HXdir_read@LIBHX_3.25 3.25 + HXformat3_aprintf@LIBHX_4.9 4.10 + HXformat3_fprintf@LIBHX_4.9 4.10 + HXformat3_sprintf@LIBHX_4.9 4.10 HXformat_add@LIBHX_3.25 3.25 HXformat_aprintf@LIBHX_3.25 3.25 HXformat_fprintf@LIBHX_3.25 3.25 @@ -122,5 +137,11 @@ libHX.so.32 libhx32 #MINVER# HXmc_zvecfree@LIBHX_3.25 3.25 HXproc_run_async@LIBHX_3.25 3.25 HXproc_run_sync@LIBHX_3.25 3.25 + HXproc_switch_user@LIBHX_3.27 4.7 + HXproc_top_fd@LIBHX_3.27 4.7 HXproc_wait@LIBHX_3.25 3.25 LIBHX_3.25@LIBHX_3.25 3.25 + LIBHX_3.27@LIBHX_3.27 4.7 + LIBHX_4.2@LIBHX_4.2 4.7 + LIBHX_4.3@LIBHX_4.3 4.7 + LIBHX_4.9@LIBHX_4.9 4.10 diff --git a/debian/not-installed b/debian/not-installed index 68cbb21..831a487 100644 --- a/debian/not-installed +++ b/debian/not-installed @@ -1,2 +1,2 @@ usr/lib/*/*.la -usr/share/doc/libhx/libHX_Documentation.pdf +#usr/share/doc/libhx/libHX_Documentation.pdf diff --git a/debian/patches/hurd-path-max-define b/debian/patches/hurd-path-max-define index da80024..d6b0cdb 100644 --- a/debian/patches/hurd-path-max-define +++ b/debian/patches/hurd-path-max-define @@ -7,9 +7,9 @@ Index: trunk/src/io.c =================================================================== --- trunk.orig/src/io.c +++ trunk/src/io.c -@@ -31,6 +31,11 @@ - #include <libHX/string.h> - #include "internal.h" +@@ -39,6 +39,11 @@ + # define O_CLOEXEC 0 + #endif +#ifndef PATH_MAX +#define PATH_MAX 4096 /* Hurd does not define PATH_MAX in limits.h */ diff --git a/debian/rules b/debian/rules index 4101bc0..ad51b7c 100755 --- a/debian/rules +++ b/debian/rules @@ -13,7 +13,7 @@ override_dh_auto_configure: override_dh_installchangelogs: # install custom changelog - dh_installchangelogs doc/changelog.txt + dh_installchangelogs doc/changelog.rst override_dh_makeshlibs: dh_makeshlibs diff --git a/debian/watch b/debian/watch index 1343f88..b16de01 100644 --- a/debian/watch +++ b/debian/watch @@ -1,3 +1,3 @@ # watch control file for uscan -version=3 -http://sf.net/libhx/libHX-(.*)\.tar\.xz +version=4 +https://inai.de/files/libhx/libHX-(.*).tar.xz diff --git a/doc/.gitignore b/doc/.gitignore deleted file mode 100644 index 2789f42..0000000 --- a/doc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.lyx~ -*.pdf diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 14eba9f..0000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -# -*- Makefile -*- - -if BUILD_DOCS -dist_doc_DATA = libHX_Documentation.pdf -endif - -libHX_Documentation.pdf: libHX_Documentation.lyx - srcdir="${srcdir}" ${srcdir}/generate; - -EXTRA_DIST = libHX_Documentation.lyx api.txt changelog.txt - -install-data-local: - if test -e libHX_Documentation.pdf; then \ - ${MKDIR_P} "${DESTDIR}${docdir}" || exit 1; \ - ${INSTALL_DATA} libHX_Documentation.pdf "${DESTDIR}${docdir}" || exit $$?; \ - fi diff --git a/doc/Makefile.in b/doc/Makefile.in deleted file mode 100644 index e3d240c..0000000 --- a/doc/Makefile.in +++ /dev/null @@ -1,518 +0,0 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2017 Free Software Foundation, Inc. - -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -# -*- Makefile -*- - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = doc -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__dist_doc_DATA_DIST) \ - $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -SOURCES = -DIST_SOURCES = -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__dist_doc_DATA_DIST = libHX_Documentation.pdf -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -am__installdirs = "$(DESTDIR)$(docdir)" -DATA = $(dist_doc_DATA) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -am__DIST_COMMON = $(srcdir)/Makefile.in -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -LYX = @LYX@ -MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RANLIB = @RANLIB@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libdl_LIBS = @libdl_LIBS@ -libexecdir = @libexecdir@ -libpthread_LIBS = @libpthread_LIBS@ -librt_LIBS = @librt_LIBS@ -libsocket_LIBS = @libsocket_LIBS@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgconfigdir = @pkgconfigdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -regular_CFLAGS = @regular_CFLAGS@ -regular_CPPFLAGS = @regular_CPPFLAGS@ -regular_CXXFLAGS = @regular_CXXFLAGS@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -@BUILD_DOCS_TRUE@dist_doc_DATA = libHX_Documentation.pdf -EXTRA_DIST = libHX_Documentation.lyx api.txt changelog.txt -all: all-am - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign doc/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs -install-dist_docDATA: $(dist_doc_DATA) - @$(NORMAL_INSTALL) - @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \ - fi; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \ - done - -uninstall-dist_docDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir) -tags TAGS: - -ctags CTAGS: - -cscope cscopelist: - - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(DATA) -installdirs: - for dir in "$(DESTDIR)$(docdir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -f Makefile -distclean-am: clean-am distclean-generic - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: install-data-local install-dist_docDATA - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-generic mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-dist_docDATA - -.MAKE: install-am install-strip - -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - cscopelist-am ctags-am distclean distclean-generic \ - distclean-libtool distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am \ - install-data-local install-dist_docDATA install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags-am uninstall uninstall-am uninstall-dist_docDATA - -.PRECIOUS: Makefile - - -libHX_Documentation.pdf: libHX_Documentation.lyx - srcdir="${srcdir}" ${srcdir}/generate; - -install-data-local: - if test -e libHX_Documentation.pdf; then \ - ${MKDIR_P} "${DESTDIR}${docdir}" || exit 1; \ - ${INSTALL_DATA} libHX_Documentation.pdf "${DESTDIR}${docdir}" || exit $$?; \ - fi - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/doc/api.rst b/doc/api.rst new file mode 100644 index 0000000..5f009cc --- /dev/null +++ b/doc/api.rst @@ -0,0 +1,376 @@ +Function reference +================== + +* R column: Recommend version number to use in ``PKG_CONFIG_CHECK`` in + projects using libHX. Includes important bugfixes. +* M column: Lowest possible version with the same function signature. +* F column: Function first seen in version, possibly with different API. + +====== ====== ====== ======================================== +RMV MinVer FirstA Name +====== ====== ====== ======================================== +4.9 4.9 4.9 HX_sockaddr_is_local +4.9 4.9 4.9 HX_ipaddr_is_local +4.7 4.7 4.7 HXQUOTE_BASE64IMAP +4.7 4.7 4.7 HXQUOTE_BASE64URL +4.3 4.3 4.3 HX_unit_seconds +4.3 4.3 4.3 HX_strtoull_sec +4.2 4.2 4.2 HX_unit_size +4.2 4.2 4.2 HX_unit_size_cu +4.2 4.2 4.2 HX_strtod_unit +4.2 4.2 4.2 HX_strtoull_unit +3.27 3.27 3.27 HXOPT_KEEP_ARGV +3.27 3.27 3.27 HXproc_top_fd +3.27 3.27 3.27 HXproc_switch_user +3.27 3.27 3.27 HXPROC_SU_SUCCESS +3.27 3.27 3.27 HXPROC_SU_NOOP +3.27 3.27 3.27 HXPROC_USER_NOT_FOUND +3.27 3.27 3.27 HXPROC_GROUP_NOT_FOUND +3.27 3.27 3.27 HXPROC_SETUID_FAILED +3.27 3.27 3.27 HXPROC_SETGID_FAILED +3.27 3.27 3.27 HXPROC_INITGROUPS_FAILED +3.27 3.27 3.27 HX_slurp_fd +3.27 3.27 3.27 HX_slurp_file +3.25 3.25 3.25 HX_split_fixed +3.25 3.25 3.25 HX_split_inplace +3.22 3.22 3.22 HXQUOTE_SQLBQUOTE +3.21 3.21 3.21 xml_getnsprop +3.19 3.19 3.19 HXQUOTE_SQLSQUOTE +3.18 3.18 3.18 HX_stpltrim +3.17 3.17 3.17 HX_LONGLONG_FMT +3.17 3.17 3.17 HX_SIZET_FMT +3.16 3.16 3.16 container_of +3.16 3.16 3.16 wxCDF +3.16 3.16 3.16 wxDSPAN +3.15 3.15 3.15 HXQUOTE_URIENC +3.15 3.15 3.15 HX_strchr2 +3.13 3.13 3.13 DEMOTE_TO_PTR +3.13 3.13 3.13 HXTYPE_SIZE_T +3.13 3.13 3.13 HX_TIMESPEC_EXP +3.13 3.13 3.13 HX_TIMESPEC_FMT +3.13 3.13 3.13 HX_TIMEVAL_EXP +3.13 3.13 3.13 HX_TIMEVAL_FMT +3.13 3.13 3.13 HX_timespec_add +3.13 3.13 3.13 HX_timespec_isneg +3.13 3.13 3.13 HX_timespec_mul +3.13 3.13 3.13 HX_timespec_mulf +3.13 3.13 3.13 HX_timespec_neg +3.13 3.13 3.13 HX_timespec_sub +3.13 3.13 3.13 HX_timeval_sub +3.12 3.12 1.10.0 HX_mkdir +3.12 3.12 3.12 HX_strndup +3.12 3.12 3.12 HX_strnlen +3.12 3.0 3.0 HXMAP_CDATA +3.12 3.0 3.0 HXMAP_CKEY +3.12 3.0 3.0 HXMAP_SCDATA +3.12 3.0 3.0 HXMAP_SCKEY +3.12 3.0 3.0 HXMAP_SDATA +3.12 3.0 3.0 HXMAP_SINGULAR +3.12 3.0 3.0 HXMAP_SKEY +3.12 3.12 3.12 HXOPT_ERR_SUCCESS +3.12 3.12 3.12 HXOPT_ERR_SYS +3.12 3.12 3.12 HXOPTCB_BY_LONG +3.12 3.12 3.12 HXOPTCB_BY_SHORT +3.12 3.0 1.10.0 HXformat_aprintf +3.12 3.0 1.10.0 HXformat_fprintf +3.12 3.0 1.10.0 HXformat_sprintf +3.11 3.11 3.11 HXQUOTE_BASE64 +3.10 3.10 3.10 BUILD_BUG_ON_EXPR +3.10 3.10 3.10 HX_readlink +3.10 3.10 3.10 HX_realpath +3.9.1 3.9 3.9 HXio_fullread +3.9.1 3.9 3.9 HXio_fullwrite +3.9 3.9 3.9 HXMAP_NONE +3.7 3.7 3.7 HXlist_for_each_rev +3.7 3.7 3.7 HXlist_for_each_rev_safe +3.7 3.7 1.22 xml_newnode +3.7 1.15 1.15 HXclist_pop +3.7 1.15 1.15 HXclist_shift +3.7 1.10.0 1.10.0 HX_ffs +3.7 1.10.0 1.10.0 HX_zveclen +3.7 1.10.0 1.10.0 HXdir_close +3.7 1.10.0 1.10.0 HXdir_open +3.7 1.10.0 1.10.0 HXdir_read +3.6 3.6 3.1 HXbitmap_clear +3.6 3.6 3.1 HXbitmap_set +3.6 3.6 3.1 HXbitmap_test +3.6 1.10.0 1.10.0 HX_split +3.5 3.5 3.5 HXMAP_NOFLAGS +3.5 3.5 3.5 HXQUOTE_LDAPFLT +3.5 3.5 3.5 HXQUOTE_LDAPRDN +3.5 3.5 3.5 HXSIZEOF_Z16 +3.5 2.2 2.2 HXproc_run_async +3.5 2.2 2.2 HXproc_run_sync +3.4 3.4 3.4 HX_exit +3.4 3.4 3.4 HX_init +3.4 3.4 3.4 HX_memmem +3.4 3.4 3.4 HXlist_empty +3.3 3.3 3.3 HX_drand +3.3 3.3 3.3 HX_shconfig_map +3.3 3.3 3.3 HXdeque_genocide2 +3.3 3.3 3.3 HXmc_zvecfree +3.3 1.10.0 1.10.0 HX_shconfig +3.3 1.10.0 1.10.0 HX_shconfig_pv +3.2 3.2 3.2 HXQUOTE_DQUOTE +3.2 3.2 3.2 HXQUOTE_HTML +3.2 3.2 3.2 HXQUOTE_SQUOTE +3.2 3.2 3.2 HXTYPE_MCSTR +3.2 3.2 3.2 HX_strquote +3.1 3.1 3.1 HXbitmap_size +3.1 1.25 1.25 HXmc_strcpy +3.0.1 3.0 3.0 HXmap_add +3.0.1 3.0 3.0 HXmap_del +3.0.1 3.0 3.0 HXmap_del<> +3.0.1 3.0 3.0 HXmap_find +3.0.1 3.0 3.0 HXmap_get +3.0.1 3.0 3.0 HXmap_get<> +3.0.1 3.0 3.0 HXmap_qfe +3.0.1 3.0 3.0 HXmap_traverse +3.0.1 3.0 3.0 HXmap_travinit +3.0 3.0 3.0 HXMAPT_DEFAULT +3.0 3.0 3.0 HXMAPT_HASH +3.0 3.0 3.0 HXMAPT_ORDERED +3.0 3.0 3.0 HXMAPT_RBTREE +3.0 3.0 3.0 HXMAP_DTRAV +3.0 3.0 3.0 HXMAP_NOREPLACE +3.0 3.0 3.0 HXhash_djb2 +3.0 3.0 3.0 HXhash_jlookup3 +3.0 3.0 3.0 HXhash_jlookup3s +3.0 3.0 3.0 HXmap_free +3.0 3.0 3.0 HXmap_init +3.0 3.0 3.0 HXmap_init5 +3.0 3.0 3.0 HXmap_keysvalues +3.0 3.0 3.0 HXmap_travfree +3.0 3.0 3.0 HXsizeof_member +3.0 3.0 3.0 HXtypeof_member +3.0 3.0 1.10.0 HXformat_add +3.0 3.0 1.10.0 HXformat_free +3.0 3.0 1.10.0 HXformat_init +2.9 2.9 2.9 HX_basename_exact +2.9 2.2 2.2 HX_split4 +2.9 1.10.0 1.10.0 HX_basename +2.8 2.8 2.8 HXPROC_NULL_STDERR +2.8 2.8 2.8 HXPROC_NULL_STDIN +2.8 2.8 2.8 HXPROC_NULL_STDOUT +2.6 2.6 2.6 HX_fls +2.6 2.6 2.6 wxACV +2.6 2.6 2.6 wxDPOS +2.6 2.6 2.6 wxDSIZE +2.6 2.6 2.6 wxfu8 +2.6 2.6 2.6 wxfv8 +2.6 2.6 2.6 wxtu8 +2.6 2.6 2.6 xml_strcasecmp +2.3 1.25 1.25 HXmc_length +2.2 2.2 2.2 HXPROC_A0 +2.2 2.2 2.2 HXPROC_EXECV +2.2 2.2 2.2 HXPROC_STDERR +2.2 2.2 2.2 HXPROC_STDIN +2.2 2.2 2.2 HXPROC_STDOUT +2.2 2.2 2.2 HXPROC_VERBOSE +2.2 2.2 2.2 HXSIZEOF_Z32 +2.2 2.2 2.2 HXSIZEOF_Z64 +2.2 2.2 2.2 HX_STRINGIFY +2.2 2.2 2.2 HXproc_wait +2.2 2.0 2.0 const_cast1 +2.2 2.0 2.0 const_cast2 +2.2 2.0 2.0 const_cast3 +2.1 2.0 2.0 static_cast +2.0 2.0 2.0 HX_isalnum +2.0 2.0 2.0 HX_isalpha +2.0 2.0 2.0 HX_isdigit +2.0 2.0 2.0 HX_islower +2.0 2.0 2.0 HX_isprint +2.0 2.0 2.0 HX_isspace +2.0 2.0 2.0 HX_isupper +2.0 2.0 2.0 HX_isxdigit +2.0 2.0 2.0 HX_tolower +2.0 2.0 2.0 HX_toupper +2.0 2.0 2.0 HXmc_setlen +2.0 2.0 2.0 const_cast +2.0 2.0 2.0 containerof +2.0 2.0 2.0 reinterpret_cast +2.0 2.0 2.0 signed_cast<> +2.0 1.23 1.23 signed_cast +2.0 1.10.0 1.10.0 HX_strmid +1.28 1.28 1.28 HXTYPE_INT16 +1.28 1.28 1.28 HXTYPE_INT32 +1.28 1.28 1.28 HXTYPE_INT64 +1.28 1.28 1.28 HXTYPE_INT8 +1.28 1.28 1.28 HXTYPE_UINT16 +1.28 1.28 1.28 HXTYPE_UINT32 +1.28 1.28 1.28 HXTYPE_UINT64 +1.28 1.28 1.28 HXTYPE_UINT8 +1.26 1.26 1.26 HX_hexdump +1.26 1.26 1.26 HX_time_compare +1.25 1.25 1.25 HX_getl +1.25 1.25 1.25 HXmc_free +1.25 1.25 1.25 HXmc_memcat +1.25 1.25 1.25 HXmc_memcpy +1.25 1.25 1.25 HXmc_memdel +1.25 1.25 1.25 HXmc_meminit +1.25 1.25 1.25 HXmc_memins +1.25 1.25 1.25 HXmc_mempcat +1.25 1.25 1.25 HXmc_strcat +1.25 1.25 1.25 HXmc_strinit +1.25 1.25 1.25 HXmc_strins +1.25 1.25 1.25 HXmc_strpcat +1.25 1.25 1.25 HXmc_trunc +1.23 1.23 1.23 ARRAY_SIZE +1.23 1.23 1.23 BUILD_BUG_ON +1.23 1.23 1.23 O_BINARY +1.23 1.23 1.23 S_IRUGO +1.23 1.23 1.23 S_IRWXUGO +1.23 1.23 1.23 S_IWUGO +1.23 1.23 1.23 S_IXUGO +1.22 1.22 1.22 xml_getprop +1.22 1.22 1.22 xml_newprop +1.22 1.22 1.22 xml_strcmp +1.18 1.18 1.18 HXlist_for_each_entry_rev +1.17 1.17 1.17 HXclist_del +1.17 1.17 1.17 HXlist_entry +1.17 1.17 1.17 HXlist_for_each_entry_safe +1.17 1.17 1.17 HXlist_for_each_safe +1.17 1.17 1.15 HXclist_init +1.17 1.17 1.15 HXlist_init +1.15 1.15 1.15 HXCLIST_HEAD +1.15 1.15 1.15 HXCLIST_HEAD_INIT +1.15 1.15 1.15 HXLIST_HEAD +1.15 1.15 1.15 HXLIST_HEAD_INIT +1.15 1.15 1.15 HXclist_push +1.15 1.15 1.15 HXclist_unshift +1.15 1.15 1.15 HXlist_add +1.15 1.15 1.15 HXlist_add_tail +1.15 1.15 1.15 HXlist_del +1.15 1.15 1.15 HXlist_for_each +1.15 1.15 1.15 HXlist_for_each_entry +1.10.0 1.10.0 1.10.0 HXFORMAT_IMMED +1.10.0 1.10.0 1.10.0 HXF_GID +1.10.0 1.10.0 1.10.0 HXF_KEEP +1.10.0 1.10.0 1.10.0 HXF_UID +1.10.0 1.10.0 1.10.0 HXOPT_AND +1.10.0 1.10.0 1.10.0 HXOPT_AUTOHELP +1.10.0 1.10.0 1.10.0 HXOPT_DEC +1.10.0 1.10.0 1.10.0 HXOPT_DESTROY_OLD +1.10.0 1.10.0 1.10.0 HXOPT_ERR_MIS +1.10.0 1.10.0 1.10.0 HXOPT_ERR_UNKN +1.10.0 1.10.0 1.10.0 HXOPT_ERR_VOID +1.10.0 1.10.0 1.10.0 HXOPT_HELPONERR +1.10.0 1.10.0 1.10.0 HXOPT_INC +1.10.0 1.10.0 1.10.0 HXOPT_NOT +1.10.0 1.10.0 1.10.0 HXOPT_OPTIONAL +1.10.0 1.10.0 1.10.0 HXOPT_OR +1.10.0 1.10.0 1.10.0 HXOPT_PTHRU +1.10.0 1.10.0 1.10.0 HXOPT_QUIET +1.10.0 1.10.0 1.10.0 HXOPT_TABLEEND +1.10.0 1.10.0 1.10.0 HXOPT_USAGEONERR +1.10.0 1.10.0 1.10.0 HXOPT_XOR +1.10.0 1.10.0 1.10.0 HXTYPE_BOOL +1.10.0 1.10.0 1.10.0 HXTYPE_CHAR +1.10.0 1.10.0 1.10.0 HXTYPE_DOUBLE +1.10.0 1.10.0 1.10.0 HXTYPE_FLOAT +1.10.0 1.10.0 1.10.0 HXTYPE_INT +1.10.0 1.10.0 1.10.0 HXTYPE_LLONG +1.10.0 1.10.0 1.10.0 HXTYPE_LONG +1.10.0 1.10.0 1.10.0 HXTYPE_NONE +1.10.0 1.10.0 1.10.0 HXTYPE_SHORT +1.10.0 1.10.0 1.10.0 HXTYPE_STRDQ +1.10.0 1.10.0 1.10.0 HXTYPE_STRING +1.10.0 1.10.0 1.10.0 HXTYPE_STRP +1.10.0 1.10.0 1.10.0 HXTYPE_SVAL +1.10.0 1.10.0 1.10.0 HXTYPE_UCHAR +1.10.0 1.10.0 1.10.0 HXTYPE_UINT +1.10.0 1.10.0 1.10.0 HXTYPE_ULLONG +1.10.0 1.10.0 1.10.0 HXTYPE_ULONG +1.10.0 1.10.0 1.10.0 HXTYPE_USHORT +1.10.0 1.10.0 1.10.0 HXTYPE_VAL +1.10.0 1.10.0 1.10.0 HX_chomp +1.10.0 1.10.0 1.10.0 HX_copy_dir +1.10.0 1.10.0 1.10.0 HX_copy_file +1.10.0 1.10.0 1.10.0 HX_dirname +1.10.0 1.10.0 1.10.0 HX_dlclose +1.10.0 1.10.0 1.10.0 HX_dlerror +1.10.0 1.10.0 1.10.0 HX_dlopen +1.10.0 1.10.0 1.10.0 HX_dlsym +1.10.0 1.10.0 1.10.0 HX_dlsym<> +1.10.0 1.10.0 1.10.0 HX_getopt +1.10.0 1.10.0 1.10.0 HX_getopt_help +1.10.0 1.10.0 1.10.0 HX_getopt_usage +1.10.0 1.10.0 1.10.0 HX_irand +1.10.0 1.10.0 1.10.0 HX_memdup +1.10.0 1.10.0 1.10.0 HX_memdup<> +1.10.0 1.10.0 1.10.0 HX_rand +1.10.0 1.10.0 1.10.0 HX_rrmdir +1.10.0 1.10.0 1.10.0 HX_shconfig_free +1.10.0 1.10.0 1.10.0 HX_split5 +1.10.0 1.10.0 1.10.0 HX_strbchr +1.10.0 1.10.0 1.10.0 HX_strclone +1.10.0 1.10.0 1.10.0 HX_strdup +1.10.0 1.10.0 1.10.0 HX_strlcat +1.10.0 1.10.0 1.10.0 HX_strlcpy +1.10.0 1.10.0 1.10.0 HX_strlncat +1.10.0 1.10.0 1.10.0 HX_strlower +1.10.0 1.10.0 1.10.0 HX_strltrim +1.10.0 1.10.0 1.10.0 HX_strrcspn +1.10.0 1.10.0 1.10.0 HX_strrev +1.10.0 1.10.0 1.10.0 HX_strrtrim +1.10.0 1.10.0 1.10.0 HX_strsep +1.10.0 1.10.0 1.10.0 HX_strsep2 +1.10.0 1.10.0 1.10.0 HX_strupper +1.10.0 1.10.0 1.10.0 HX_zvecfree +1.10.0 1.10.0 1.10.0 HXdeque_del +1.10.0 1.10.0 1.10.0 HXdeque_find +1.10.0 1.10.0 1.10.0 HXdeque_free +1.10.0 1.10.0 1.10.0 HXdeque_get +1.10.0 1.10.0 1.10.0 HXdeque_init +1.10.0 1.10.0 1.10.0 HXdeque_move +1.10.0 1.10.0 1.10.0 HXdeque_pop +1.10.0 1.10.0 1.10.0 HXdeque_push +1.10.0 1.10.0 1.10.0 HXdeque_shift +1.10.0 1.10.0 1.10.0 HXdeque_to_vec +1.10.0 1.10.0 1.10.0 HXdeque_to_vec<> +1.10.0 1.10.0 1.10.0 HXdeque_unshift +1.10.0 1.10.0 1.10.0 SHCONF_ONE +====== ====== ====== ======================================== + + +Struct reference +================ + +====== ====== ================================================ +MinVer FirstA +====== ====== ================================================ +2.0 2.0 struct HXdeque_node.sptr +1.10.0 1.10.0 struct HXdeque_node +1.10.0 1.10.0 struct HXdeque +1.15 1.15 struct HXclist_head +1.15 1.15 struct HXlist_head +3.0 3.0 struct HXmap +3.0 3.0 struct HXmap_ops +3.0 3.0 struct HXmap_node +3.12 1.10.0 struct HXoptcb +3.12 1.10.0 struct HXoption +2.2 2.2 struct HXproc_ops +2.2 2.2 struct HXproc +====== ====== ================================================ + + +Header reference +================ + +====== =================================== +MinVer Name +====== =================================== +3.9 libHX/io.h +3.4 libHX/init.h +3.0 libHX/map.h +2.6 libHX/wx_helper.hpp +2.2 libHX/proc.h +2.0 libHX/ctype_helper.h +1.23 libHX/misc.h +1.23 libHX/defs.h +1.22 libHX/xml_helper.h +1.15 libHX/string.h +1.15 libHX/option.h +1.15 libHX/list.h +1.15 libHX/deque.h +====== =================================== diff --git a/doc/api.txt b/doc/api.txt deleted file mode 100644 index 4649515..0000000 --- a/doc/api.txt +++ /dev/null @@ -1,353 +0,0 @@ - -Table of contents -================= -1. Symbol reference -2. Header reference - - -Function reference -================== - -R column: Recommend version number to use in PKG_CONFIG_CHECK in -projects using libHX. Includes important bugfixes. -M column: Lowest possible version with the same function signature. -F column: Function first seen in version, possibly with different API. - -RMV MinVer FirstA Name ----------------------------------------------------------------------- -3.25 3.25 3.25 HX_split_fixed -3.25 3.25 3.25 HX_split_inplace -3.22 3.22 3.22 HXQUOTE_SQLBQUOTE -3.21 3.21 3.21 xml_getnsprop -3.19 3.19 3.19 HXQUOTE_SQLSQUOTE -3.18 3.18 3.18 HX_stpltrim -3.17 3.17 3.17 HX_LONGLONG_FMT -3.17 3.17 3.17 HX_SIZET_FMT -3.16 3.16 3.16 container_of -3.16 3.16 3.16 wxCDF -3.16 3.16 3.16 wxDSPAN -3.15 3.15 3.15 HXQUOTE_URIENC -3.15 3.15 3.15 HX_strchr2 -3.13 3.13 3.13 DEMOTE_TO_PTR -3.13 3.13 3.13 HXTYPE_SIZE_T -3.13 3.13 3.13 HX_TIMESPEC_EXP -3.13 3.13 3.13 HX_TIMESPEC_FMT -3.13 3.13 3.13 HX_TIMEVAL_EXP -3.13 3.13 3.13 HX_TIMEVAL_FMT -3.13 3.13 3.13 HX_timespec_add -3.13 3.13 3.13 HX_timespec_isneg -3.13 3.13 3.13 HX_timespec_mul -3.13 3.13 3.13 HX_timespec_mulf -3.13 3.13 3.13 HX_timespec_neg -3.13 3.13 3.13 HX_timespec_sub -3.13 3.13 3.13 HX_timeval_sub -3.12 3.12 1.10.0 HX_mkdir -3.12 3.12 3.12 HX_strndup -3.12 3.12 3.12 HX_strnlen -3.12 3.0 3.0 HXMAP_CDATA -3.12 3.0 3.0 HXMAP_CKEY -3.12 3.0 3.0 HXMAP_SCDATA -3.12 3.0 3.0 HXMAP_SCKEY -3.12 3.0 3.0 HXMAP_SDATA -3.12 3.0 3.0 HXMAP_SINGULAR -3.12 3.0 3.0 HXMAP_SKEY -3.12 3.12 3.12 HXOPT_ERR_SUCCESS -3.12 3.12 3.12 HXOPT_ERR_SYS -3.12 3.12 3.12 HXOPTCB_BY_LONG -3.12 3.12 3.12 HXOPTCB_BY_SHORT -3.12 3.0 1.10.0 HXformat_aprintf -3.12 3.0 1.10.0 HXformat_fprintf -3.12 3.0 1.10.0 HXformat_sprintf -3.11 3.11 3.11 HXQUOTE_BASE64 -3.10 3.10 3.10 BUILD_BUG_ON_EXPR -3.10 3.10 3.10 HX_readlink -3.10 3.10 3.10 HX_realpath -3.9.1 3.9 3.9 HXio_fullread -3.9.1 3.9 3.9 HXio_fullwrite -3.9 3.9 3.9 HXMAP_NONE -3.7 3.7 3.7 HXlist_for_each_rev -3.7 3.7 3.7 HXlist_for_each_rev_safe -3.7 3.7 1.22 xml_newnode -3.7 1.15 1.15 HXclist_pop -3.7 1.15 1.15 HXclist_shift -3.7 1.10.0 1.10.0 HX_ffs -3.7 1.10.0 1.10.0 HX_zveclen -3.7 1.10.0 1.10.0 HXdir_close -3.7 1.10.0 1.10.0 HXdir_open -3.7 1.10.0 1.10.0 HXdir_read -3.6 3.6 3.1 HXbitmap_clear -3.6 3.6 3.1 HXbitmap_set -3.6 3.6 3.1 HXbitmap_test -3.6 1.10.0 1.10.0 HX_split -3.5 3.5 3.5 HXMAP_NOFLAGS -3.5 3.5 3.5 HXQUOTE_LDAPFLT -3.5 3.5 3.5 HXQUOTE_LDAPRDN -3.5 3.5 3.5 HXSIZEOF_Z16 -3.5 2.2 2.2 HXproc_run_async -3.5 2.2 2.2 HXproc_run_sync -3.4 3.4 3.4 HX_exit -3.4 3.4 3.4 HX_init -3.4 3.4 3.4 HX_memmem -3.4 3.4 3.4 HXlist_empty -3.3 3.3 3.3 HX_drand -3.3 3.3 3.3 HX_shconfig_map -3.3 3.3 3.3 HXdeque_genocide2 -3.3 3.3 3.3 HXmc_zvecfree -3.3 1.10.0 1.10.0 HX_shconfig -3.3 1.10.0 1.10.0 HX_shconfig_pv -3.2 3.2 3.2 HXQUOTE_DQUOTE -3.2 3.2 3.2 HXQUOTE_HTML -3.2 3.2 3.2 HXQUOTE_SQUOTE -3.2 3.2 3.2 HXTYPE_MCSTR -3.2 3.2 3.2 HX_strquote -3.1 3.1 3.1 HXbitmap_size -3.1 1.25 1.25 HXmc_strcpy -3.0.1 3.0 3.0 HXmap_add -3.0.1 3.0 3.0 HXmap_del -3.0.1 3.0 3.0 HXmap_del<> -3.0.1 3.0 3.0 HXmap_find -3.0.1 3.0 3.0 HXmap_get -3.0.1 3.0 3.0 HXmap_get<> -3.0.1 3.0 3.0 HXmap_qfe -3.0.1 3.0 3.0 HXmap_traverse -3.0.1 3.0 3.0 HXmap_travinit -3.0 3.0 3.0 HXMAPT_DEFAULT -3.0 3.0 3.0 HXMAPT_HASH -3.0 3.0 3.0 HXMAPT_ORDERED -3.0 3.0 3.0 HXMAPT_RBTREE -3.0 3.0 3.0 HXMAP_DTRAV -3.0 3.0 3.0 HXMAP_NOREPLACE -3.0 3.0 3.0 HXhash_djb2 -3.0 3.0 3.0 HXhash_jlookup3 -3.0 3.0 3.0 HXhash_jlookup3s -3.0 3.0 3.0 HXmap_free -3.0 3.0 3.0 HXmap_init -3.0 3.0 3.0 HXmap_init5 -3.0 3.0 3.0 HXmap_keysvalues -3.0 3.0 3.0 HXmap_travfree -3.0 3.0 3.0 HXsizeof_member -3.0 3.0 3.0 HXtypeof_member -3.0 3.0 1.10.0 HXformat_add -3.0 3.0 1.10.0 HXformat_free -3.0 3.0 1.10.0 HXformat_init -2.9 2.9 2.9 HX_basename_exact -2.9 2.2 2.2 HX_split4 -2.9 1.10.0 1.10.0 HX_basename -2.8 2.8 2.8 HXPROC_NULL_STDERR -2.8 2.8 2.8 HXPROC_NULL_STDIN -2.8 2.8 2.8 HXPROC_NULL_STDOUT -2.6 2.6 2.6 HX_fls -2.6 2.6 2.6 wxACV -2.6 2.6 2.6 wxDPOS -2.6 2.6 2.6 wxDSIZE -2.6 2.6 2.6 wxfu8 -2.6 2.6 2.6 wxfv8 -2.6 2.6 2.6 wxtu8 -2.6 2.6 2.6 xml_strcasecmp -2.3 1.25 1.25 HXmc_length -2.2 2.2 2.2 HXPROC_A0 -2.2 2.2 2.2 HXPROC_EXECV -2.2 2.2 2.2 HXPROC_STDERR -2.2 2.2 2.2 HXPROC_STDIN -2.2 2.2 2.2 HXPROC_STDOUT -2.2 2.2 2.2 HXPROC_VERBOSE -2.2 2.2 2.2 HXSIZEOF_Z32 -2.2 2.2 2.2 HXSIZEOF_Z64 -2.2 2.2 2.2 HX_STRINGIFY -2.2 2.2 2.2 HXproc_wait -2.2 2.0 2.0 const_cast1 -2.2 2.0 2.0 const_cast2 -2.2 2.0 2.0 const_cast3 -2.1 2.0 2.0 static_cast -2.0 2.0 2.0 HX_isalnum -2.0 2.0 2.0 HX_isalpha -2.0 2.0 2.0 HX_isdigit -2.0 2.0 2.0 HX_islower -2.0 2.0 2.0 HX_isprint -2.0 2.0 2.0 HX_isspace -2.0 2.0 2.0 HX_isupper -2.0 2.0 2.0 HX_isxdigit -2.0 2.0 2.0 HX_tolower -2.0 2.0 2.0 HX_toupper -2.0 2.0 2.0 HXmc_setlen -2.0 2.0 2.0 const_cast -2.0 2.0 2.0 containerof -2.0 2.0 2.0 reinterpret_cast -2.0 2.0 2.0 signed_cast<> -2.0 1.23 1.23 signed_cast -2.0 1.10.0 1.10.0 HX_strmid -1.28 1.28 1.28 HXTYPE_INT16 -1.28 1.28 1.28 HXTYPE_INT32 -1.28 1.28 1.28 HXTYPE_INT64 -1.28 1.28 1.28 HXTYPE_INT8 -1.28 1.28 1.28 HXTYPE_UINT16 -1.28 1.28 1.28 HXTYPE_UINT32 -1.28 1.28 1.28 HXTYPE_UINT64 -1.28 1.28 1.28 HXTYPE_UINT8 -1.26 1.26 1.26 HX_hexdump -1.26 1.26 1.26 HX_time_compare -1.25 1.25 1.25 HX_getl -1.25 1.25 1.25 HXmc_free -1.25 1.25 1.25 HXmc_memcat -1.25 1.25 1.25 HXmc_memcpy -1.25 1.25 1.25 HXmc_memdel -1.25 1.25 1.25 HXmc_meminit -1.25 1.25 1.25 HXmc_memins -1.25 1.25 1.25 HXmc_mempcat -1.25 1.25 1.25 HXmc_strcat -1.25 1.25 1.25 HXmc_strinit -1.25 1.25 1.25 HXmc_strins -1.25 1.25 1.25 HXmc_strpcat -1.25 1.25 1.25 HXmc_trunc -1.23 1.23 1.23 ARRAY_SIZE -1.23 1.23 1.23 BUILD_BUG_ON -1.23 1.23 1.23 O_BINARY -1.23 1.23 1.23 S_IRUGO -1.23 1.23 1.23 S_IRWXUGO -1.23 1.23 1.23 S_IWUGO -1.23 1.23 1.23 S_IXUGO -1.22 1.22 1.22 xml_getprop -1.22 1.22 1.22 xml_newprop -1.22 1.22 1.22 xml_strcmp -1.18 1.18 1.18 HXlist_for_each_entry_rev -1.17 1.17 1.17 HXclist_del -1.17 1.17 1.17 HXlist_entry -1.17 1.17 1.17 HXlist_for_each_entry_safe -1.17 1.17 1.17 HXlist_for_each_safe -1.17 1.17 1.15 HXclist_init -1.17 1.17 1.15 HXlist_init -1.15 1.15 1.15 HXCLIST_HEAD -1.15 1.15 1.15 HXCLIST_HEAD_INIT -1.15 1.15 1.15 HXLIST_HEAD -1.15 1.15 1.15 HXLIST_HEAD_INIT -1.15 1.15 1.15 HXclist_push -1.15 1.15 1.15 HXclist_unshift -1.15 1.15 1.15 HXlist_add -1.15 1.15 1.15 HXlist_add_tail -1.15 1.15 1.15 HXlist_del -1.15 1.15 1.15 HXlist_for_each -1.15 1.15 1.15 HXlist_for_each_entry -1.10.0 1.10.0 1.10.0 HXFORMAT_IMMED -1.10.0 1.10.0 1.10.0 HXF_GID -1.10.0 1.10.0 1.10.0 HXF_KEEP -1.10.0 1.10.0 1.10.0 HXF_UID -1.10.0 1.10.0 1.10.0 HXOPT_AND -1.10.0 1.10.0 1.10.0 HXOPT_AUTOHELP -1.10.0 1.10.0 1.10.0 HXOPT_DEC -1.10.0 1.10.0 1.10.0 HXOPT_DESTROY_OLD -1.10.0 1.10.0 1.10.0 HXOPT_ERR_MIS -1.10.0 1.10.0 1.10.0 HXOPT_ERR_UNKN -1.10.0 1.10.0 1.10.0 HXOPT_ERR_VOID -1.10.0 1.10.0 1.10.0 HXOPT_HELPONERR -1.10.0 1.10.0 1.10.0 HXOPT_INC -1.10.0 1.10.0 1.10.0 HXOPT_NOT -1.10.0 1.10.0 1.10.0 HXOPT_OPTIONAL -1.10.0 1.10.0 1.10.0 HXOPT_OR -1.10.0 1.10.0 1.10.0 HXOPT_PTHRU -1.10.0 1.10.0 1.10.0 HXOPT_QUIET -1.10.0 1.10.0 1.10.0 HXOPT_TABLEEND -1.10.0 1.10.0 1.10.0 HXOPT_USAGEONERR -1.10.0 1.10.0 1.10.0 HXOPT_XOR -1.10.0 1.10.0 1.10.0 HXTYPE_BOOL -1.10.0 1.10.0 1.10.0 HXTYPE_CHAR -1.10.0 1.10.0 1.10.0 HXTYPE_DOUBLE -1.10.0 1.10.0 1.10.0 HXTYPE_FLOAT -1.10.0 1.10.0 1.10.0 HXTYPE_INT -1.10.0 1.10.0 1.10.0 HXTYPE_LLONG -1.10.0 1.10.0 1.10.0 HXTYPE_LONG -1.10.0 1.10.0 1.10.0 HXTYPE_NONE -1.10.0 1.10.0 1.10.0 HXTYPE_SHORT -1.10.0 1.10.0 1.10.0 HXTYPE_STRDQ -1.10.0 1.10.0 1.10.0 HXTYPE_STRING -1.10.0 1.10.0 1.10.0 HXTYPE_STRP -1.10.0 1.10.0 1.10.0 HXTYPE_SVAL -1.10.0 1.10.0 1.10.0 HXTYPE_UCHAR -1.10.0 1.10.0 1.10.0 HXTYPE_UINT -1.10.0 1.10.0 1.10.0 HXTYPE_ULLONG -1.10.0 1.10.0 1.10.0 HXTYPE_ULONG -1.10.0 1.10.0 1.10.0 HXTYPE_USHORT -1.10.0 1.10.0 1.10.0 HXTYPE_VAL -1.10.0 1.10.0 1.10.0 HX_chomp -1.10.0 1.10.0 1.10.0 HX_copy_dir -1.10.0 1.10.0 1.10.0 HX_copy_file -1.10.0 1.10.0 1.10.0 HX_dirname -1.10.0 1.10.0 1.10.0 HX_dlclose -1.10.0 1.10.0 1.10.0 HX_dlerror -1.10.0 1.10.0 1.10.0 HX_dlopen -1.10.0 1.10.0 1.10.0 HX_dlsym -1.10.0 1.10.0 1.10.0 HX_dlsym<> -1.10.0 1.10.0 1.10.0 HX_getopt -1.10.0 1.10.0 1.10.0 HX_getopt_help -1.10.0 1.10.0 1.10.0 HX_getopt_usage -1.10.0 1.10.0 1.10.0 HX_irand -1.10.0 1.10.0 1.10.0 HX_memdup -1.10.0 1.10.0 1.10.0 HX_memdup<> -1.10.0 1.10.0 1.10.0 HX_rand -1.10.0 1.10.0 1.10.0 HX_rrmdir -1.10.0 1.10.0 1.10.0 HX_shconfig_free -1.10.0 1.10.0 1.10.0 HX_split5 -1.10.0 1.10.0 1.10.0 HX_strbchr -1.10.0 1.10.0 1.10.0 HX_strclone -1.10.0 1.10.0 1.10.0 HX_strdup -1.10.0 1.10.0 1.10.0 HX_strlcat -1.10.0 1.10.0 1.10.0 HX_strlcpy -1.10.0 1.10.0 1.10.0 HX_strlncat -1.10.0 1.10.0 1.10.0 HX_strlower -1.10.0 1.10.0 1.10.0 HX_strltrim -1.10.0 1.10.0 1.10.0 HX_strrcspn -1.10.0 1.10.0 1.10.0 HX_strrev -1.10.0 1.10.0 1.10.0 HX_strrtrim -1.10.0 1.10.0 1.10.0 HX_strsep -1.10.0 1.10.0 1.10.0 HX_strsep2 -1.10.0 1.10.0 1.10.0 HX_strupper -1.10.0 1.10.0 1.10.0 HX_zvecfree -1.10.0 1.10.0 1.10.0 HXdeque_del -1.10.0 1.10.0 1.10.0 HXdeque_find -1.10.0 1.10.0 1.10.0 HXdeque_free -1.10.0 1.10.0 1.10.0 HXdeque_get -1.10.0 1.10.0 1.10.0 HXdeque_init -1.10.0 1.10.0 1.10.0 HXdeque_move -1.10.0 1.10.0 1.10.0 HXdeque_pop -1.10.0 1.10.0 1.10.0 HXdeque_push -1.10.0 1.10.0 1.10.0 HXdeque_shift -1.10.0 1.10.0 1.10.0 HXdeque_to_vec -1.10.0 1.10.0 1.10.0 HXdeque_to_vec<> -1.10.0 1.10.0 1.10.0 HXdeque_unshift -1.10.0 1.10.0 1.10.0 SHCONF_ONE - - -Struct reference -================ -MinVer FirstA -2.0 2.0 struct HXdeque_node.sptr -1.10.0 1.10.0 struct HXdeque_node -1.10.0 1.10.0 struct HXdeque -1.15 1.15 struct HXclist_head -1.15 1.15 struct HXlist_head -3.0 3.0 struct HXmap -3.0 3.0 struct HXmap_ops -3.0 3.0 struct HXmap_node -3.12 1.10.0 struct HXoptcb -3.12 1.10.0 struct HXoption -2.2 2.2 struct HXproc_ops -2.2 2.2 struct HXproc - - -Header reference -================ - -MinVer Name -------------------------------------------- -3.9 libHX/io.h -3.4 libHX/init.h -3.0 libHX/map.h -2.6 libHX/wx_helper.hpp -2.2 libHX/proc.h -2.0 libHX/ctype_helper.h -1.23 libHX/misc.h -1.23 libHX/defs.h -1.22 libHX/xml_helper.h -1.15 libHX/string.h -1.15 libHX/option.h -1.15 libHX/list.h -1.15 libHX/deque.h diff --git a/doc/bitmaps.rst b/doc/bitmaps.rst new file mode 100644 index 0000000..18a992d --- /dev/null +++ b/doc/bitmaps.rst @@ -0,0 +1,49 @@ +======= +Bitmaps +======= + +.. code-block:: c + + #include <libHX/misc.h> + + size_t HXbitmap_size(type array, unsigned int bits); + void HXbitmap_set(type *bmap, unsigned int bit); + void HXbitmap_clear(type *bmap, unsigned int bit); + bool HXbitmap_test(type *bmap, unsigned int bit); + +All of these four are implemented as macros, so they can be used with any +integer type that is desired to be used. + +``HXbitmap_size`` + Returns the amount of ``type``-based integers that would be needed to + hold an array of the requested amount of bits. + +``HXbitmap_set`` + Sets the specific bit in the bitmap. + +``HXbitmap_clear`` + Clears the specific bit in this bitmap. + +``HXbitmap_test`` + Tests for the specific bit and returns true if it is set, otherwise + false. + + +Example +======= + +.. code-block:: c + + #include <stdlib.h> + #include <string.h> + #include <libHX/misc.h> + + int main(void) + { + unsigned long bitmap[HXbitmap_size(unsigned long, 128)]; + + memset(bitmap, 0, sizeof(bitmap)); + HXbitmap_set(bitmap, 49); + return HXbitmap_get(bitmap, HX_irand(0, 128)) ? + EXIT_SUCCESS : EXIT_FAILURE; + } diff --git a/doc/changelog.rst b/doc/changelog.rst new file mode 100644 index 0000000..9a1590c --- /dev/null +++ b/doc/changelog.rst @@ -0,0 +1,176 @@ +v4.10 (2023-01-29) +================== + +Fixes: + +* format: plug a memory leak relating to func_entry_clone +* Resolve mingw build failure + + +v4.9 (2023-01-23) +================= + +Enhancements: + +* socket: add sockaddr_is_local, ipaddr_is_local functions + +Fixes: + +* format: avoid return value truncation from HXformat_aprintf, HXformat_sprintf +* format: avoid calling HXmc_length on a non-hxmc object +* format: add new variations of printf functions returning ssize_t +* Resolve Coverity-SCAN reports + + +v4.8 (2022-12-03) +================= + +Enhancements: + +* io: call posix_fadvise when slurping files + +Fixes: + +* io: fix garbling of slurped data when read from an unknown-size source + + +v4.7 (2022-10-21) +================= + +Enhancements: + +* string: new quoting modes HXQUOTE_BASE64URL & HXQUOTE_BASE64IMAP + +Fixes: + +* socket: make HX_socket_from_env functional on OpenBSD + + +v4.6 (2022-06-27) +================= + +Enhancements: + +* HX_slurp_fd/HX_slurp_file now supports reading from files reporting their + own size as 0 (e.g. ttys, /proc special files). + + +v4.5 (2022-04-10) +================= + +Fixes: + +* Resolve a number of cov-scan reported warnings. + + +v4.4 (2022-03-15) +================= + +Fixes: + +* Build fixes for the mingw environment. + + +v4.3 (2022-03-14) +================= + +Enhancements: + +* string: New functions ``HX_strtoull_sec``, ``HX_unit_seconds`` for converting + between second-based time durations and human-readable durations like + 129600 <-> 1d12h. +* io: New function ``HX_sendfile``. +* io: raise buffer size for ``HX_copy_file`` from 1 kiB to 64 kiB + + +v4.2 (2021-10-17) +================= + +Enhancements: + +* string: New functions ``HX_strtod_unit``, ``HX_strtoull_unit``, + ``HX_unit_size``, ``HX_unit_size_cu`` for converting between + sizes and human-readable sizes like 1457664 <-> "1.45M"/"1.39M". + + +v4.1 (2021-10-13) +================= + +Fixes: + +* io: fix a use-after-free in conjunction with HX_realpath / + fix missing NULLing of a pointer within HX_readlink + + +v4.0 (2021-10-03) +================= + +Enhancements: + +* lib: add ``HX_slurp_fd``, ``HX_slurp_file`` +* proc: add ``HXproc_switch_user`` +* proc: add ``HXproc_top_fd`` +* socket: add ``HX_socket_from_env`` +* opt: add ``HXOPT_KEEP_ARGV`` flag + +Fixes: + +* proc: re-close pipes when ``HXproc_build_pipes`` failed + + +v3.26 (2021-08-03) +================== + +Fixes: + +* io: cure a potential infinite loop on EOF with HXio_fullread() +* io: HXio_fullread() now returns actual bytes read rather than bytes requested +* time: rectified HX_timeval_sub producing wrong results + +Changes: + +* nullptr checks were added to HXshconfig_free, HXformat_free, HXdeque_free and + HXmap_free to make their behavior be in line with free(3). +* Documentation has been switched to reStructured Text. + + +v3.25 (2020-05-14) +================== + +Fixes: + +* string: fix out-of-bounds access when calling ``HX_strlcpy(x,y,0)`` + +Changes: + +* string: ``HX_split4`` renamed to ``HX_split_inplace`` +* string: ``HX_split5`` renamed to ``HX_split_fixed`` +* defs.h: removed partially implementation of ``FIELD_SIZEOF`` +* defs.h: removed custom ``offsetof`` definition; you will need to include + ``<stddef.h>`` or ``<cstddef>`` now. + + +v3.24 (2018-10-17) +================== + +Fixes: + +* defs: avoid compiler warning when using ``HX_list_for_each`` in C++ +* opt: synchronize ``HXOPT_AUTOHELP`` C behavior to C++ mode + + +v3.23 (2018-08-28) +================== + +Enhancements: + +* opt: the option parser now recognizes long option abbreviations +* io: use modern ``readdir`` rather than ``readdir_r`` + + +v3.22 (2014-08-25) +================== + +Enhancements: + +* string: add the ``HXQUOTE_SQLBQUOTE`` quoting variant diff --git a/doc/changelog.txt b/doc/changelog.txt deleted file mode 100644 index ffe75c1..0000000 --- a/doc/changelog.txt +++ /dev/null @@ -1,556 +0,0 @@ - -v3.25 (2020-05-14) -================== -Fixes: -* string: fix out-of-bounds access when calling HX_strlcpy(x,y,0) -Changes: -* string: HX_split4 renamed to HX_split_inplace -* string: HX_split5 renamed to HX_split_fixed -* defs.h: removed partially implementation of FIELD_SIZEOF -* defs.h: removed custom offsetof definition; you will need to include - <stddef.h> or <cstddef> now. - - -v3.24 (2018-10-17) -================== -Fixes: -- defs: avoid compiler warning when using HX_list_for_each when used in C++ -- opt: synchronize HXOPT_AUTOHELP C behavior to C++ mode - - -v3.23 (2018-08-28) -================== -Enhancements: -- opt: the option parser now recognizes long option abbreviations -- io: use modern readdir rather than readdir_r - - -v3.22 (2014-08-25) -================== -Enhancements: -- string: add the HXQUOTE_SQLBQUOTE quoting variant - - -v3.21 (2014-06-02) -================== -Enhancements: -- HXformat_add() now supports HXTYPE_MCSTR objects (with and without - HXTYPE_IMMED) -- libxml_helper: New xml_getnsprop() function that gets the value of a - property (element attribute) by namespace prefix - - -v3.20 (2014-04-18) -================== -Enhancements: -- resolve some link errors when built with Solaris ld - - -v3.19 (2014-02-21) -================== -Enhancements: -- string: add the HXQUOTE_SQLSQUOTE quoting variant -Internal changes: -- format: rework function calling code to support extending with functions - - -v3.18 (2014-03-01) -================== -Enhancements: -- string: add the HX_stpltrim function -Fixes: -- Make HX_strltrim move the correct number of bytes -Changes: -- remove wxCFF from wx_helper.hpp - - -v3.17 (2013-11-16) -================== -Enhancements: -- defs: add HX_SIZET_FMT and HX_LONGLONG_FMT -- support for Win64 -Fixes: -- compile warnings on mingw were addressed - - -v3.16 (2013-09-29) -================== -Enhancements: -- format: remove 256-char format key length limit -Fixes: -- compile errors on mingw were addressed - - -v3.15 (2013-03-07) -================== -Enhancements: -- string: add HX_strchr2 -- string: add HXQUOTE_URIENC mechanism for HX_strquote -Changes: -- defs: HXsizeof_member becomes FIELD_SIZEOF - (to match the Linux kernel's macro name) - - -v3.14.1 (2012-12-31) -==================== -Fixes: -- Restore forward-sorting order of ordered maps - (revert "map: always have needle as second argument") - - -v3.14 (2012-11-14) -================== -Fixes: -- io: use pathconf(3) to determine dirent size for dir traversal -- rand: avoid division by zero when calling HX_irand with lo==hi -- time: use C++ static_cast syntax for C++ mode -- headers: improve operability with C89 compile mode - - -v3.13 (2012-07-28) -================== -Enhancements: -- defs: add DEMOTE_TO_PTR -- option: new HXOPT_RQ_ORDER flag, allows unconditional POSIX-style parsing - (parsing terminates at first non-option encountered) -- option: add HXTYPE_SIZE_T -- time: add functions and macros for arithmetic and handling of timespec - with support for negative time values - * time: add HX_TIMESPEC_{EXP,FMT} - * time: add HX_TIMEVAL_{EXP,FMT} - * time: add the HX_timespec_isneg function - * time: add the HX_timespec_neg function - * time: add the HX_timespec_add function - * time: add the HX_timespec_mul function - * time: add the HX_timespec_mulf function -Changes: -- io: remove HX_REALPATH_SYMLINK -- time: rename HX_diff_timespec to HX_timespec_sub (old ABI kept) -- time: rename HX_diff_timeval to HX_timeval_sub (old ABI kept) -- string: make HX_memmem consider the special case of search_length=0 -- string: optimize search_length=1 case in HX_memmem -- string: speed up HX_memmem searches for search_length >=2 - - -v3.12.1 (2011-12-15) -==================== -Fixes: -- build: make build error-free when using -Wl,--no-undefined -- string: make HX_strdup(NULL) valid again - - -v3.12 (2010-12-03) -================== -Fixes: -- defs: resolve warning for users of const_cast*() when using -Wextra -- format: error handling for HXformat2_aprintf -- option: do not omit dashes when passthru'ing unknown two-part long opts -- option: do not omit arg following unknown unknown two-part long opts in pthru -- option: do run callback on HXTYPE_BOOL -- option: correct passthrough of squashed unknown short options -- option: do not stop early when printing help/usage -- option: avoid crash when passing an empty argv -- option: avoid crash when passing NULL for struct HXoptcb.arg0 -Enhancements: -- build: deactivate type-checking of the *_cast() macros for clang due to a - compiler bug involving nested structs-in-typeofs -- option: allow argc=NULL on HX_getopt -- option: error handling for HX_getopt -- option: support POSIXLY_CORRECT environment variable -- string: add a HX_strndup function -- string: add a HX_strnlen function -- mc: use an implicit minimum allocated length -Changes: -- format: renamed HXformat2_[afs]printf back to HXformat_[afs]printf -- io: add mode argument to HX_mkdir -- map: avoid 1<<31 in constants -- option: remove struct HXoptcb.arg0 -- option: remove struct HXoptcb.match_{ln,sh} by .flags -- option: let HX_getopt return code indicate system failure states -- option: remove struct HXoption.sval (replaced by .uptr) -- string: unline HX_strdup, HX_strlcat, HX_strlcpy, HX_strnlcat - - -v3.11 (2011-07-25) -================== -Enhancements: -- A LD_PRELOAD-able library libHX_rtcheck.so that adds global state correctness - checks, was added. -- add a HXQUOTE_BASE64 to HX_strquote -Changes: -- HX_strquote will return NULL for unknown types now instead of just - returning the input pointer - - -v3.10.1 (2011-04-06) -==================== -Fixes: -- defs: BUILD_BUG_ON_EXPR had erroneously returned 1 - - -v3.10 (2011-04-05) -================== -Fixes: -- build: resolve autoconf-2.68 warnings -- format: do not split arguments in %(lower) and %(upper) -Changes: -- defs: add array type checking in ARRAY_SIZE -- opt: use non-zero sentinel marker -- string: make HX_getl more resilient against errors -Enhancements: -- defs: add BUILD_BUG_ON_EXPR -- format: provide a %(substr) function -- io: add HX_readlink (zero-terminating mc-output readlink) -- io: add HX_realpath (supports relative-path output) - - -v3.9.1 (2011-01-17) -=================== -Fixes: -- libHX/io.h was not copied on `make install`, which has been fixed - - -v3.9 (2011-01-15) -================= -Fixes: -- Added missing __cplusplus guards to libHX/io.h -- Added missing includes to libHX/string.h -- Use __typeof__ in includes -Changes: -- For filesystem/filehandle-related functions, io.h should now be included - in userspace programs instead of misc.h -- libHX.so is now built with a symvers map file -Enhancements: -- hxdirstamp: new development helper program for library users - (Note to distros: should be in libHX-devel; it is only used during builds) -- io: new functions HXio_full{read,write} - - -v3.8 (2010-12-01) -================= -This was supposed to go into 3.7 but I forgot to merge in time.. -Changes: -- hexdump: colorize characters 0x00 thru 0x1F in tty mode - - -v3.7 (2010-12-01) -================= -Changes: -- libxml_helper: redo xml_newnode to take a parent and value string -- list: unify naming of reverse-direction functions -- misc: HX_zveclen now returns unsigned from (previous: int) -- dir: HXdir functions now work with struct HXdir * instead of void * -Fixes: -- list: avoid potential shadow warning when using HXclist_{shift,pop} -Enhancements: -- doc: add doc/api.txt that lists the minimum required versions for symbols - - -v3.6 (2010-08-16) -================= -Fixed: -- bitmap: set/clear/test had no effect due to wrong type selection -- bitmap: avoid left-shift larger than type on 64-bit -- string: fixed buffer overflow in HX_split when too few fields were present - in the input - - -v3.5 (2010-08-01) -================= -Fixed: -- format2: failure to skip escaped char in "%(echo foo\ bar)" was corrected -- proc: properly check for HXPROC_STDx--HXPROC_STDx_NULL overlap -- strquote: do not cause allocation with invalid format numbers -Enhancements: -- format2: add the %(exec) function -- format2: add the %(shell) function -- format2: security feature for %(exec) and %(shell) -- format2: add the %(snl) function -- string: HX_strquote gained HXQUOTE_LDAPFLT (LDAP search filter) support -- string: HX_strquote gained HXQUOTE_LDAPRDN (LDAP relative DN) support -Changes: -- format1: removed older formatter in favor of format2 -- format2: add check for empty key -- format2: function-specific delimiters -- format2: do nest-counting even with normal parentheses -- format2: check for zero-argument function calls -- hashmap: do not needlessy change TID when no reshape was done -- string: HX_basename (the fast variant) now recognizes the root directory -- string: HX_basename now returns the trailing component with slashes - instead of everything after the last slash (which may have been nothing) - - -v3.4 (2010-04-03) -================= -Changes: -- add explicit initialize/deinitialize functions HX_init, HX_exit -Enhancements: -- add the HX_memmem function -- add the HXlist_empty function -- documentation updates: HXlist traversal - - -v3.3 (2010-01-20) -================= -Bug fixes: -- format: fix incorrect copying of non-expanded % strings -- proc: avoid calling close(-1) to not trip up valgrind -- shconfig: fix incorrect parsing of "\'" -- shconfig: fix incorrect processing of "\"\\\0BCD" -- shconfig: be more strict with syntax -Enhancements: -- deque: add HXdeque_genocide2 -- format2: new format string (make-style) support -- mc: add HXmc_zvecfree -- shconfig: add HX_shconfig_map to return all entries of a shconfig file -- rand: add HX_drand ('double'-type bounds and return value) -- rand: avoid some function call overhead in HX_irand - - -v3.2 (2009-10-11) -================= -Enhancements: -- opt: add HXTYPE_MCSTR for storing into hxmc_t *s -- string: add HX_strquote - - -v3.1 (2009-09-13) -================= -Enhancements: -- added HXbitmap_* functions -Fixes: -- mc: HXmc_strcpy produced a zero-length string when NULL was copied - - -v3.0.1 (2009-08-31) -=================== -Fixes: -- map: avoid underflow in value-based tree comparison - - -v3.0 (2009-08-27) -================= -Changes: -- automatically skip building testcases if C++ compiler not available - (reminder: libHX itself does not require a C++ compiler) -- arbtree: HXbtree was removed in favor of the new HXmap -- clist: clist.h moved into list.h -- format: HXformat_* now uses struct HXformat_map, - so that it does not tie itself to HXbtree -- mc: fix an alignment-induced overallocation -- rand: use faster modulo-based variant for numbers within RAND_MAX range -- rand: use libc rand() almost exclusively, only use /dev/urandom for seed -Enhancements: -- defs: add HXsizeof_member and HXtypeof_member -- map: new map API, with hash-based maps and classic rbtree-based maps -- time: add time delta functions (HX_diff_timeval/HX_diff_timespec) -Fixes: -- format: memory leaks fixes in HXformat - - -v2.9 (2009-07-11) -================= -Fixes: -- string: fixed number of fields and trailing NULL in HX_split4 -Enhancements: -- string: add HX_basename_exact - - -v2.8 (2009-07-01) -================= -Enhancements: -- HXproc now knows about HXPROC_NULL_*, which can be used to discard I/O -- HXproc: expressly prohibit HXPROC_STD* for HXproc_run_sync - - -v2.7 (2009-04-08) -================= -Fixes: -- install missing wx_helper.hpp - - -v2.6 (2009-03-28) -================= -Documentation: -- install documentation -- update project URLs -- add section about Miscellaneous functions -Changes: -- arbtree: add "flat view" operation -- misc: added HX_fls -- misc: make HX_time_compare otime-capable -- add wx_helper.hpp - - -v2.5 (2009-02-11) -================= -Fixes: -- proc: fix fd setup when the standard channels are already closed - - -v2.4 (2009-02-05) -================= -Documentation updates. A few internal cleanups, nothing user-visible. - - -v2.3 (2009-01-13) -================= -Fixes: -- defs: only use __builtin_offsetof with GCC >= 4 -- misc: fix time_compare on FreeBSD to actually use mtimespec -- mc: handle HXmc_length(NULL) -- dir: do not cause directory traversal to restart after 2^32 entries - - -v2.2 (2009-01-01) -================= -Fixes: -- defs/cast: avoid warning between conversion from type[] to type * -- defs/cast: add fallback defs for const_castN() -- arbtree: correctly set errno (to ENOENT) in HXbtree_find and _get -- string: document behavior details of HX_basename - -Changes: -- removed old HX_vfsystem - -Enhancements: -- defs: add HXSIZEOF_Z* -- defs: add HX_STRINGIFY -- proc: initial code -- string: add HX_split4 function - - -v2.1 (2008-12-23) -================= -- defs: fix bogus offsetof macro for non-GCC -- defs: add a pair of guarding parentheses in static_cast() -- doc: generate PDF file from LyX document - - -v2.0 (2008-12-23) -================= -Fixes: -- arbtree: reject illegal flag combinations -- arbtree: correctly set errno in HXbtree_find and HXbtree_get -- arbtree: do not return dangling pointer in HXbtree_del -- defs: add a working offsetof() and containerof() for C++ mode -- defs: use GCC's __builtin_offsetof -- defs: resolve warnings with signed_cast() for char* -> const char* conversions -- dir: HX_rrmdir: do not stop on error -- opt: fix interpretation of strings during conversion to bool - (all strings that were not empty and not 0 were interpreted as "true", - and this included the strings "no", "off" and "false", which should - actually have mapped to, well, "false".) -- rand: use autoconf to detect presence of unix functions -- string: replace HX_strrev implementation by one that does not allocate - - -New feature: Type-checking casts. -- defs: enable type-checking signed_cast() -- defs: add signed_cast<> for C++ mode -- defs: rewrite static_cast() to not cause -Wshadow warnings when nested -- defs: rewrite const_cast() to do type checking - (actually, const_cast1(), cosnt_cast2() and const_cast3() were introduced. - const_cast() is kept to not break program compilation.) - - -New misc code: -- ctype_helper: initial version -- deque: add struct HXdeque_node->char *sptr as a typed variant for ptr -- mc: add HXmc_setlen() -- opt: HXTYPE_BOOL and HXTYPE_NONE now take int * (instead of unsigned int *) - - -New arbtree code: -- arbtree: add struct HXbtree_node->char *skey and char *sdata -- arbtree: support arbitrary key/data duplication -- arbtree: add HXbtree_init2 - - -Removals: -- mc: remove HXmc_dup - [you can use HXmc_meminit(old, HXmc_length(old))] -- string: HX_strmid behavior changed for length=0 - [no more "remaining string", now returns a zero-length string] - - -v1.28 (2008-11-18) -================== -- add HXTYPE_{U,}INT{8,16,32,64} -- add includedir to cflags (libHX.pc) - - -v1.27 (2008-12-23) -================== -No functional changes for Linux platforms. - -- build: fixed compile errors with i586-mingw32msvc cross compile -- regenerated the Makefile.in files in the tarball with an updated - version of automake-tranquility so that they are now - POSIX-compliant and work with BSD make - - -v1.26 (2008-10-12) -================== -- add HX_hexdump() for debugging within programs -- fix double free in the error path of HX_getopt() when a long option preceded - a short option of which the latter had problems (i.e. missing argument) -- add actual typechecking to signed_cast() -- add typechecking to static_cast(), - (but this is normally disabled to avoid compile interruption) - - -v1.25 (2008-09-07) -================== -- install missing misc.h -- HXmc: pointer was not automatically updated after hmc_trunc() -- HXmc: rename functions and put them into the HX* namespace (API change) -- HXmc: make code resistant to memory allocation failure - - -v1.23 (2008-09-02) -================== -- code cleanup: misc.h has been split off libHX.h -- add defs.h - - -v1.22 (2008-07-16) -================== -- need to use lstat() on directory operations such as mkdir and rrmdir -- use RTLD_LAZY when opening dynamic libraries -- add libxml_helper - - -v1.18 (2008-06-10) -================== -- implement reverse iterating through HXlist -- remove deprecated HXlist_init_head() and HXclist_init_head() - [replaced by HXlist_init() and HXclist_init()] -- added HX_ffs() - - -v1.17 (2008-05-08) -================== -- HXlist: added HXlist_for_each_safe, HXlist_for_each_entry_safe -- HXclist: added HXclist_del - - -v1.15 (2008-04-04) -================== -- HXformat: add %(ifempty) and %(ifnempty) tags -- libHX.h: split into {arbtree,deque,option,string}.h (and libHX.h) -- Add inline-doubly-linked-list data structures - - -v1.10.2 (2007-12-06) -==================== -- [r105]: pass up NULL from memory allocation error -- [r108]: only return success on EEXIST when HXF_KEEP was given -- [r112]: HX_dirname() incorrectly computed the path - - -v1.10.1 (2007-09-17) -==================== -- [r96]: Fix output of line-wrapped help text -- tarball: in libHX 1.10.0 I forgot to provide the configure - sorry - (but you could regenerate it using ./autogen.sh if you have autotools) diff --git a/doc/dirstamp.rst b/doc/dirstamp.rst new file mode 100644 index 0000000..fe69d26 --- /dev/null +++ b/doc/dirstamp.rst @@ -0,0 +1,7 @@ +Improved dirstamp +================= + +.. code-block:: makefile + + dirstamp.lst: + [ ! -e $@ -o -n "$(find dir/ -newer $@ -print -quit)" ] && touch $@ || :; diff --git a/doc/dirstamp.txt b/doc/dirstamp.txt deleted file mode 100644 index 92c1696..0000000 --- a/doc/dirstamp.txt +++ /dev/null @@ -1,4 +0,0 @@ -Improved dirstamp: - -dirstamp.lst: - [ ! -e $@ -o -n "$(find dir/ -newer $@ -print -quit)" ] && touch $@ || :; diff --git a/doc/files_and_dirs.rst b/doc/files_and_dirs.rst new file mode 100644 index 0000000..a4fdc59 --- /dev/null +++ b/doc/files_and_dirs.rst @@ -0,0 +1,190 @@ +=========================== +File and directory handling +=========================== + + +Directory traversal +=================== + +libHX provides a minimal readdir-style wrapper for cross-platform directory +traversal. This is needed because the Win32 platforms does not have readdir, +and there is some housekeeping to do on Unixish platforms, since the dirent +structure needs allocation of a path-specific size. + +.. code-block:: c + + #include <libHX/io.h> + + struct HXdir *HXdir_open(const char *directory); + const char *HXdir_read(struct HXdir *handle); + void HXdir_close(struct HXdir *handle); + +``HXdir_open`` returns a pointer to its private data area, or ``NULL`` upon +failure, in which case ``errno`` is preserved from the underlying system calls. +``HXdir_read`` causes the next entry from the directory to be fetched. The +pointer returned by ``HXdir_read`` must not be freed, and the data is +overwritten in subsequent calls to the same handle. If you want to keep it +around, you will have to duplicate it yourself. ``HXdir_close`` will close the +directory and free the private data it held. + + +Example +------- + +.. code-block:: c + + #include <errno.h> + #include <stdio.h> + #include <libHX/io.h> + + struct HXdir *dh; + if ((dh = HXdir_open(".")) == NULL) { + fprintf(stderr, "Could not open directory: %s\n", strerror(errno)); + return; + } + while ((dentry = HXdir_read(dh)) != NULL) + printf("%s\n", dentry); + HXdir_close(dh); + +This sample will open the current directory, and print out all entries as it +iterates over them. + + +Operation on directory entries +============================== + +.. code-block:: c + + #include <libHX/io.h> + + int HX_readlink(hxmc_t **buf, const char *path); + int HX_realpath(hxmc_t **buf, const char *path, unsigned int flags); + +``HX_readlink`` calls through to readlink to read the target of a symbolic +link, and stores the result in the memory container referenced by ``*buf`` +(similar to ``HX_getl`` semantics). If ``*buf`` is ``NULL``, a new container +will be allocated and a pointer to it stored in ``*buf``. The container's +content is naturally zero-terminated automatically. The return value of the +function will be the length of the link target, or negative to indicate the +system error value. + +``HX_realpath`` will normalize the given path by transforming various path +components into alternate descriptions. The flags parameter controls its +actions: + +``HX_REALPATH_DEFAULT`` + A mnemonic for a set of standard flags: ``HX_REALPATH_SELF | + HX_REALPATH_PARENT``. Note that ``HX_REALPATH_ABSOLUTE``, which would + also be required to get libc's ``realpath``(3) behavior, is not + included in the set. + +``HX_REALPATH_ABSOLUTE`` + Requests that the output path shall be absolute. In the absence of this + flag, an absolute output path will only be produced if the input path + is also absolute. + +``HX_REALPATH_SELF`` + Request resolution of `.` path components. + +``HX_REALPATH_PARENT` + Request resolution of `..` path components. + +The result is stored in a memory container whose pointer is returned through +``*buf``. The return value of the function will be negative to indicate a +possible system error, or be positive non-zero for success. + + +Operations on directories +========================= + +.. code-block:: c + + #include <libHX/io.h> + + int HX_mkdir(const char *path, unsigned int mode); + int HX_rrmdir(const char *path); + +``HX_mkdir`` will create the directory given by path and all its parents that +do not exist yet using the given mode. It is equivalent to the ``mkdir -p`` +shell command. It will return >0 for success, or ``-errno`` on error. + +``HX_rrmdir`` also maps to an operation commonly done on the shell, ``rm -Rf``, +deleting the directory given by path, including all files within it and its +subdirectories. Errors during deletion are ignored, but if there was any, the +errno value of the first one is returned negated. + + +Operations on files +=================== + +.. code-block:: c + + #include <libHX/io.h> + + #define HXF_KEEP ... + #define HXF_UID ... + #define HXF_GID ... + + int HX_copy_file(const char *src, const char *dest, unsigned int flags, ...); + int HX_copy_dir(const char *src, const char *dest, unsigned int flags, ...); + char *HX_slurp_fd(int fd, size_t *outsize); + char *HX_slurp_file(const char *file, size_t *outsize); + +``HX_copy_file`` + Copies one named file to a new location. Possible ``flags`` are + ``HXF_KEEP``, ``HXF_UID`` and ``HXF_GID``. Error checking by + ``HX_copy_file`` is flakey. ``HX_copy_file`` will return >0 on success, + or ``-errno`` on failure. Errors can arise from the use of the syscalls + ``open``, ``read`` and ``write``. The return value of ``fchmod``, which + is used to set the UID and GID, is actually ignored, which means + verifying that the owner has been set cannot be detected with + ``HX_copy_file`` alone (historic negligience?). + +``HXF_KEEP`` + Do not overwrite existing files. + +``HXF_UID`` + Change the new file's owner to the UID given in the varargs section + (...). ``HXF_UID`` is processed before ``HXF_GID``. + +``HXF_GID`` + Change the new file's group owner to the GID given in the varargs + section. This is processed after ``HXF_UID``. + +``HX_copy_dir`` + Copies one named directory to a new location, recursively. + (Uses ``HX_copy_file`` and ``HX_copy_dir``.) Error checking by + ``HX_copy_dir`` is flakey. + +``HX_slurp_fd`` + Reads all remaining bytes from the given filedescriptor ``fd`` and + returns a pointer to a newly-allocated content buffer. If ``outsize`` + is not ``NULL``, the size of the buffer will be written to it. The + buffer is always terminated by a gratuitious NUL (not counted in + ``outsize``). Once no longer needed, the buffer should be released with + ``free``. + +``HX_slurp_file`` + Reads all bytes from the given filename and returns a pointer to the + content buffer. Inherits all the characteristics from ``HX_slurp_fd``. + + +Filedescriptor helpers +====================== + +.. code-block:: c + + #include <libHX/io.h> + + ssize_t HXio_fullread(int fd, void *buf, size_t size, unsigned int flags); + ssize_t HXio_fullwrite(int fd, const void *buf, size_t size, unsigned int flags); + ssize_t HX_sendfile(int dst, int src, size_t count); + +Since plain ``read``(2) and ``write``(2) may process only part of the buffer — +even more likely so with sockets —, libHX provides two functions that calls +these in a loop to retry said operations until the full amount has been +processed. Since read and write can also be used with socket file descriptors, +so can these. + +``HX_sendfile`` wraps ``sendfile``(2) for the same reason; in addition, it +falls back to a read-write loop on platforms which do not offer sendfile. diff --git a/doc/generate b/doc/generate deleted file mode 100755 index 3fd48cf..0000000 --- a/doc/generate +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -ex - -if [ -z "$srcdir" ]; then - srcdir="."; -fi; -rm -f libHX_Documentation.pdf -lyx -e pdf2 "$srcdir/libHX_Documentation.lyx" || : -# lyx-2.3.2 does not work with texlive-babel-2017.135.3 -# """ -# Package babel Error: You haven't specified a language option. -# ...ry to proceed from here, type x to quit.) -# -# You need to specify a language, either as a global option -# or as an optional argument to the \usepackage command; -# You shouldn't try to proceed form here, type x to quit. -# """ -# babel you so stupid for breaking backward comapt. - -test -e libHX_Documentation.pdf diff --git a/doc/helper_headers.rst b/doc/helper_headers.rst new file mode 100644 index 0000000..7b4c083 --- /dev/null +++ b/doc/helper_headers.rst @@ -0,0 +1,128 @@ +============== +Helper headers +============== + +ctype helpers +============= + +Functions from the ``<ctype.h>`` header, including, but not limited to, +``isalpha``, ``tolower``, and so forth, are defined to take an ``int`` as first +argument. C strings consist of ``char``s, which may either be ``signed`` or +``unsigned``. It does not matter for *characters_* but since ``char``s are +implicitly convertible to *numbers*, one needs to explicitly cast chars to +unsigned before feeding them to ``isalpha``. + +.. code-block:: c + + /* “hyvää yötä”, UTF-8 encoded */ + + const char h[] = {'h', 'y', 'v', 0xc3, 0xa4, 0xc3, 0xa4, ' ', + 'y', 0xc3, 0xb6, 't', 0xc3, 0xa4}; + +libHX's ctype_helper.h therefore provides wrappers with a different function +signature that does the intended test. It does so by always taking ``unsigned +char``. The implication is that EOF cannot be passed to ``HX_isalpha`` — not +that there is a good reason to do so in the first place. + +.. code-block:: c + + #include <libHX/ctype_helper.h> + + bool HX_isalnum(unsigned char c); + bool HX_isalpha(unsigned char c); + bool HX_isdigit(unsigned char c); + bool HX_islower(unsigned char c); + bool HX_isprint(unsigned char c); + bool HX_isspace(unsigned char c); + bool HX_isupper(unsigned char c); + bool HX_isxdigit(unsigned char c); + unsigned char HX_tolower(unsigned char c); + unsigned char HX_toupper(unsigned char c); + +The ``HX_is*`` functions also differ from ctype's in that they return ``bool`` +instead of ``int``. Not all functions from ``ctype.h`` are present either; +``isascii``, ``isblank``, ``iscntrl``, ``isgraph``, ``ispunct`` and +``isxdigit`` have been omitted as the author has never needed them to this +date. + + +libxml2 helpers +=============== + +libxml2 defines a type called ``xmlChar`` for use within its strings. +``xmlChar`` is typedef'ed to ``unsigned char`` by libxml2, causing compiler warnings related to +differing signedness whenever interacting with strings from the +outside world, which are usually just a pointer to char. Because +casting is a real chore, ``libxml_helper.h`` will do it by +providing some wrappers with better argument types. + +.. code-block:: c + + #include <libHX/libxml_helper.h> + + int xml_strcmp(const xmlChar *a, const char *b); + int xml_strcasecmp(const xmlChar *a, const char *b); + + char *xml_getprop(xmlNode *node, const char *attr); + char *xml_getnsprop(xmlNode *node, const char *nsprefix, const char *attr); + xmlAttr *xml_newprop(xmlNode *node, const char *attr); + xmlNode *xml_newnode(xmlNode *parent, const char *name, const char *value); + xmlAttr *xml_setprop(xmlNode *node, const char *name, const char *value); + +The functions map to ``strcmp``, ``strcasecmp``, ``xmlGetProp``, +``xmlNewPropxmlNewProp``, ``xmlNewTextNodexmlNewTextNode`` and +``xmlSetPropxmlSetProp``, respectively. + +``xml_getnsprop`` works similar to ``xmlGetNsProp``, but instead of taking a +namespace URI, it does a lookup by namespace prefix. The argument order is also +different compared to ``xmlGetNsProp``. + + +wxWidgets +========= + +.. code-block:: c++ + + #include <libHX/wx_helper.hpp> + +Shortcut macros +--------------- + +``wxACV`` + Expands to ``wxALIGN_CENTER_VERTICAL``. + +``wxCDF`` + Expands to a set of common dialog flags for wxDialogs, which includes + ``wxDEFAULT_FRAME_STYLE`` and a flag such that the dialog does not + create a new window in the task bar (``wxFRAME_NO_TASKBAR``). + +``wxDPOS`` + Expands to ``wxDefaultPosition``. + +``wxDSIZE`` + Expands to ``wxDefaultSize``. + +``wxDSPAN`` + Expands to ``wxDefaultSpan``. + +String conversion +----------------- + +.. code-block:: c++ + + wxString wxfu8(const char *); + wxString wxfv8(const char *); + const char *wxtu8(const wxString &); + +``wxfu8`` + Converts a UTF-8 string to a ``wxString`` object. + +``wxfv8`` + Converts a UTF-8 string to an entity usable by ``wxPrintf``. + +``wxtu8`` + Converts a wxString to a pointer to char usable by ``printf``. Note + that the validity of the pointer is very limited and usually does not + extend beyond the statement in which it is used. Hence, storing the + pointer in a variable (``const char *p = wxtu8(s);``) will make ``p`` + dangling as soon as the assignment has been completed. diff --git a/doc/history.rst b/doc/history.rst new file mode 100644 index 0000000..674b39f --- /dev/null +++ b/doc/history.rst @@ -0,0 +1,22 @@ +History +======= + +The origins of libHX trace back, even crossing a language boundary, to when the +author started on using Perl in 1999. Some tasks were just too damn useful to +be open-coded every time. Two such examples are what is these days known as +``HX_basename`` and ``HX_mkdir``. The name does not relate to anyone's +initials; it is a result of a truncation of the author's nick used years ago. + +Around the beginning of 2003, the author also started on the C programming +language and soon the small library was converted from Perl to C. The libHX +library as of today is the result of working with C ever since, and naturally +grew from there to support whatever the author was in need of. + +The “correct” name for libHX is with an uppercase “H” and uppercase “X”, and +the same is used for filenames, such as “libHX.so”[#lowercase] + +.. [#lowercase] Software projects may choose to entirely lowercase the project + name for use in filenames, such as the Linux kernel which is + released as ``linux-${version}.tar.bz2``, or the project may + choose to keep the name for filenames, like Mesa and SDL do. + libHX is of the latter. diff --git a/doc/init.rst b/doc/init.rst new file mode 100644 index 0000000..ebaa4d8 --- /dev/null +++ b/doc/init.rst @@ -0,0 +1,17 @@ +Initialization +============== + +.. code-block:: c + + #include <libHX/init.h> + + int HX_init(void); + void HX_exit(void); + +Before using the library's functions, ``HX_init`` must be called. This function +will initialize any needed state libHX needs for itself, if any. It is designed +to be invoked multiple times, such as for example, from different libraries +linking to libHX itself, and will refcount. On success, >0 is returned. If +there was an error, it will return a negative error code or zero. ``HX_exit`` +is the logical counterpart of notifying that the library is no longer used. + diff --git a/doc/inline_clist.rst b/doc/inline_clist.rst new file mode 100644 index 0000000..f7bf138 --- /dev/null +++ b/doc/inline_clist.rst @@ -0,0 +1,59 @@ +================================= +Counted inline doubly-linked list +================================= + +clist is the inline doubly-linked list cousin of the inline doubly-linked list, +extended by a counter to retrieve the number of elements in the list in O(1) +time. This is also why all operations always require the list head. For +traversal of clists, use the corresponding HXlist macros. + +Synopsis +======== + +.. code-block:: c + + #include <libHX/list.h> + + struct HXclist_head { + /* public readonly: */ + unsigned int items; + /* Undocumented fields are considered “private” */ + }; + + HXCLIST_HEAD_INIT(name); + HXCLIST_HEAD(name); + void HXclist_init(struct HXclist_head *head); + void HXclist_unshift(struct HXclist_head *head, struct HXlist_head *new_node); + void HXclist_push(struct HXclist_head *head, struct HXlist_head *new_node); + type HXclist_pop(struct HXclist_head *head, type, member); + type HXclist_shift(struct HXclist_head *head, type, member); + void HXclist_del(struct HXclist_head *head, struct HXlist_chead *node); + +``HXCLIST_HEAD_INIT`` + Macro that expands to the static initializer for a clist. + +``HXCLIST_HEAD`` + Macro that expands to the definition of a clist head, with + initialization. + +``HXclist_init`` + Initializes a clist. This function is generally used when the head has + been allocated from the heap. + +``HXclist_unshift`` + Adds the node to the front of the list. + +``HXclist_push`` + Adds the node to the end of the list. + +``HXclist_pop`` + Removes the last node in the list and returns it. + +``HXclist_shift`` + Removes the first node in the list and returns it. + +``HXclist_del`` + Deletes the node from the list. + +The list count in the clist head is updated whenever a modification is done on +the clist through these functions. diff --git a/doc/inline_list.rst b/doc/inline_list.rst new file mode 100644 index 0000000..e60e89f --- /dev/null +++ b/doc/inline_list.rst @@ -0,0 +1,253 @@ +========================= +Inline doubly-linked list +========================= + +Classical linked-list implementations, such as HXdeque, either store the actual +data within a node, or indirectly through a pointer, but the “inline +doubly-linked list” instead does it reverse and has the list head within the +data structure. + +A classic linked-list implementations with direct/indirect data blocks may look +like so: + +.. code-block:: c + + struct package_desc { + char *package_name; + int version; + + }; + + struct classic_direct_node { + struct classic_direct_node *next, *prev; + struct package_desc direct_data; + }; + struct classic_indirect_node { + struct classic_indirect_node *next, *prev; + void *indirect_data; + }; + +Whereas in an inline list, the list head (next,prev pointers) inlined into the data +block: + +.. code-block:: c + + struct package_desc { + struct HXlist_head list; + char *package_name; + int version; + }; + +At first glance, an inline list does not look much different from ``struct +classic_direct_data``, it is mostly a viewpoint decision which struct is in the +foreground. + + +Synopsis +======== + +.. code-block:: c + + #include <libHX/list.h> + + struct HXlist_head {struct HXlist_head + /* All fields considered private */ + }; + + HXLIST_HEAD_INIT(name); + HXLIST_HEAD(name); + void HXlist_init(struct HXlist_head *list); + void HXlist_add(struct HXlist_head *list, struct HXlist_head *elem); + void HXlist_add_tail(struct HXlist_head *list, struct HXlist_head *elem); + void HXlist_del(struct HXlist_head *element); + bool HXlist_empty(const struct HXlist_head *list); + +``HXLIST_HEAD_INIT`` + This macro expands to the static initializer for a list head. + +``HXLIST_HEAD`` + This macro expands to the definition of a list head (i.e. ``struct + HXlist_head name = HXLIST_HEAD_INIT;``). + +``HXlist_init`` + Initializes the list head. This function is generally used when the + list head is on the heap where the static initializer cannot be used. + +``HXlist_add`` + Adds ``elem`` to the front of the list. + +``HXlist_add_tail`` + Adds ``elem`` to the end of the list. + +``HXlist_del`` + Deletes the given element from the list. + +``HXlist_empty`` + Tests whether the list is empty. (Note: For clists, you could also use + ``clist->items == 0``). + + +Traversal +========= + +Traversal is implemented using macros that expand to ``for()`` statements which +can syntactically be used like them, i.e. curly braces may be omitted if only +a single statement is in the body of the loop. + +The head parameter specifies the list head (``struct HXlist_head``), ``pos`` +specifies an iterator, also of type ``struct HXlist_head``. Lists can either be +traversed in forward direction, or, using the ``*_rev`` variants, in reverse +direction. The ``*_safe`` variants use a temporary ``n`` to hold the next +object in the list, which is needed when ``pos`` itself is going to be +inaccessible at the end of the block, through, for example, freeing its +encompassing object. + +.. code-block:: c + + HXlist_for_each(pos, head) + HXlist_for_each_rev(pos, head) + HXlist_for_each_safe(pos, n, head) + HXlist_for_each_rev_safe(pos, n, head) + +``HXlist_for_each`` + Forward iteration over the list heads. + +``HXlist_for_each_rev`` + Reverse iteration over the list heads. + +``HXlist_for_each_safe`` + Forward iteration over the list heads that is safe against freeing pos. + +``HXlist_for_each_rev_safe`` + Reverse iteration over the list heads that is safe against freeing pos. + +The ``*_entry`` variants use an iterator ``pos`` of the type of the +encompassing object (e.g. ``struct item`` in below's example), so that the +manual ``HXlist_entry`` invocation is not needed. ``member`` is the name of the +list structure embedded into the item. + +.. code-block:: c + + HXlist_for_each_entry(pos, head, member)HXlist_for_each_entry + HXlist_for_each_entry_rev(pos, head, member)HXlist_for_each_entry_rev + HXlist_for_each_entry_safe(pos, n, head, member)HXlist_for_each_entry_safe + +``HXlist_for_each_entry`` + Forward iteration over the list elements. + +``HXlist_for_each_entry_rev`` + Reverse iteration over the list elements. + +``HXlist_for_each_entry_safe`` + Forward iteration over the list elements that is safe against freeing + ``pos``. + + +Examples +======== + +.. code-block:: c + + struct item { + struct HXlist_head anchor; + char name[32]; + }; + + struct HXlist_head *e; + struct item *i, *j; + HXLIST_HEAD(list); + + i = malloc(sizeof(*i)); + HXlist_init(&e->anchor); + strcpy(i->name, "foo"); + HXlist_add_tail(&list, &i->anchor); + + i = malloc(sizeof(*i)); + HXlist_init(&e->anchor); + strcpy(i->name, "bar"); + HXlist_add_tail(&list, &i->anchor); + + HXlist_for_each(e, &list) { + i = HXlist_entry(e, typeof(*i), anchor); + printf("e=%p i=%p name=%s\n", e, i, i->name); + } + + HXlist_for_each_entry(i, &list, anchor) + printf("i=%p name=%s\n", i, i->name); + + HXlist_for_each_entry_rev(i, &list, anchor) + printf("i=%p name=%s\n", i, i->name); + + HXlist_for_each_entry_safe(i, j, &list, anchor) { + printf("i=%p name=%s\n", i, i->name); + free(i); + } + + +When to use HXdeque/HXlist +========================== + +The choice whether to use HXdeque or HXlist/HXclist depends on whether one +wants the list head handling on the developer or on the library. Especially for +“atomic” and “small” data, it might be easier to just let HXdeque do the +management. Compare the following two code examples to store strings in a +HXdeque: + +.. code-block:: c + + int main(int argc, const char **argv) + { + struct HXdeque *dq = HXdeque_init(); + while (--argc) + HXdeque_push(dq, ++argv); + return 0; + } + +...and to store strings in a HXlist: + +.. code-block:: c + + struct element { + struct HXlist_head list; + char *data; + }; + + int main(int main, const char **argv) + { + HXLIST_HEAD(lh); + while (--argc) { + struct element *e = malloc(sizeof(*e)); + e->data = *++argv; + HXlist_init(&e->list); + HXlist_add_tail(&e->list); + } + return 0; + } + +These examples assume that ``argv`` is persistent, which, for the sample, is +true. + +With HXlist, one needs to have a struct with a ``HXlist_head`` in it, and if +one does not already have such a struct, e.g. by means of wanting to store more +than just one value, one will need to create it first, as shown, and this may +lead to an expansion of code. + +This however does not mean that HXlist is the better solution over HXdeque for +data already available in a struct. As each struct has a ``list_head`` that is +unique to the node, it is not possible to share this data. Trying to add a +HXlist_head to another list is not going to end well, while HXdeque has no +problem with this as list heads are detached from the actual data in HXdeque. + +Data can be added multiple times in a HXdeque without ill effects: + +.. code-block:: c + + struct point p = {15, 30}; + HXdeque_push(dq, &p); + HXdeque_push(dq, &p); + +To support this, an extra allocation is needed on the other hand. In a HXlist, +to store *n* elements of compound data (e.g. ``struct point``), *n* allocations +are needed, assuming the list head is a stack object, and the points are not. +HXdeque will need at least *2n+1* allocations, *n* for the nodes, *n* for the +points and another for the head. diff --git a/doc/install.rst b/doc/install.rst new file mode 100644 index 0000000..a0931b4 --- /dev/null +++ b/doc/install.rst @@ -0,0 +1,50 @@ +============ +Installation +============ + +libHX uses GNU autotools as a build environment, which means that +all you have to run as a end-user is the configure with any +options that you need, plus the usual make and make install as +desired. + +Pay attention to multi-lib Linux distributions where you most +likely need to specify a different libdir instead of using the +default “lib”. In case of the Debian-style multi-arch/multi-lib +proposal (http://wiki.debian.org/Multiarch):: + +.. code-block:: sh + + ./configure --libdir='${prefix}/lib/x86_64-linux-gnu' + +and the classic-style 32-64 2-lib distributions:: + +.. code-block:: sh + + ./configure --libdir='${prefix}/lib64' + +Requirements +------------ + +* GNU C Compiler 3.3.5 or newer. Other compilers (non-GCC) have + not been tested in months — use at your own risk. + +* approximately 80–160 KB of disk space on Linux for the shared + library (depends on platform) and header files. + +A C++ compiler is only needed if you want to build the C++ test +programs that come with libHX. By default, if there is no C++ +compiler present, these will not be built. + +* No external libraries are needed for compilation of libHX. + Helper files, like libxml_helper.h, may reference their include + files, but they are not used during compilation. + + +Portability notice +================== + +libHX runs on contemporary versions of Linux and Windows. It ought to work on +Solaris and the BSD distributions, but this is not build-tested at this time. + +C99 is mandatory. The integer type ``int`` should at best have 32 bits at +least. diff --git a/doc/libHX_Documentation.lyx b/doc/libHX_Documentation.lyx deleted file mode 100644 index 9e2e9f5..0000000 --- a/doc/libHX_Documentation.lyx +++ /dev/null @@ -1,24663 +0,0 @@ -#LyX 2.3 created this file. For more info see http://www.lyx.org/ -\lyxformat 544 -\begin_document -\begin_header -\save_transient_properties true -\origin unavailable -\textclass article -\use_default_options true -\maintain_unincluded_children false -\language english -\language_package default -\inputencoding utf8 -\fontencoding global -\font_roman "lmodern" "default" -\font_sans "lmss" "default" -\font_typewriter "lmtt" "default" -\font_math "auto" "auto" -\font_default_family default -\use_non_tex_fonts false -\font_sc false -\font_osf false -\font_sf_scale 100 100 -\font_tt_scale 100 100 -\use_microtype false -\use_dash_ligatures true -\graphics default -\default_output_format default -\output_sync 0 -\bibtex_command default -\index_command default -\paperfontsize 12 -\spacing single -\use_hyperref true -\pdf_bookmarks false -\pdf_bookmarksnumbered false -\pdf_bookmarksopen false -\pdf_bookmarksopenlevel 1 -\pdf_breaklinks false -\pdf_pdfborder true -\pdf_colorlinks false -\pdf_backref page -\pdf_pdfusetitle true -\papersize a4paper -\use_geometry true -\use_package amsmath 1 -\use_package amssymb 1 -\use_package cancel 1 -\use_package esint 1 -\use_package mathdots 1 -\use_package mathtools 1 -\use_package mhchem 1 -\use_package stackrel 1 -\use_package stmaryrd 1 -\use_package undertilde 1 -\cite_engine natbib -\cite_engine_type numerical -\biblio_style plainnat -\use_bibtopic false -\use_indices false -\paperorientation portrait -\suppress_date false -\justification true -\use_refstyle 0 -\use_minted 0 -\index Index -\shortcut idx -\color #008000 -\end_index -\leftmargin 2cm -\topmargin 2cm -\rightmargin 2cm -\bottommargin 2cm -\secnumdepth 3 -\tocdepth 1 -\paragraph_separation indent -\paragraph_indentation default -\is_math_indent 0 -\math_numbering_side default -\quotes_style english -\dynamic_quotes 0 -\papercolumns 1 -\papersides 1 -\paperpagestyle default -\tracking_changes false -\output_changes false -\html_math_output 0 -\html_css_as_file 0 -\html_be_strict false -\end_header - -\begin_body - -\begin_layout Title -libHX 3.25 -\begin_inset Newline newline -\end_inset - -Documentation -\end_layout - -\begin_layout Standard -\begin_inset VSpace defskip -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset CommandInset toc -LatexCommand tableofcontents - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Introduction -\end_layout - -\begin_layout Standard -libHX collects many useful day-to-day functions, intended to reduce the - amount of otherwise repeatedly open-coded instructions. -\end_layout - -\begin_layout Section -Overview -\end_layout - -\begin_layout Itemize -Maps (key-value pairs) (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:maps" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Originally created to provide a data structure like Perl's associative arrays. - Different map types and characteristics are available, such as hash-based - or the traditional rbtree. -\end_layout - -\begin_layout Itemize -Deques (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:deque" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Double-ended queues, implemented as a doubly-linked list with sentinels, - are suitable for both providing stack and queue functionality. -\end_layout - -\begin_layout Itemize -Inline doubly-linked list, uncounted and counted (sections -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:list" - -\end_inset - - and -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:clist" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Light-weight linked lists as used in the Linux kernel. -\end_layout - -\begin_layout Itemize -Common string operations (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:strings" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -basename, chomp, dirname, getl(ine), split, strlcat/strlcpy, strlower/-upper, - str*trim, strsep, etc. -\end_layout - -\begin_layout Itemize -Memory containers, auto-sizing string operations (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:mc" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Scripting-like invocation for string handling -\begin_inset space ~ -\end_inset - -— automatically doing (re)allocations as needed. -\end_layout - -\begin_layout Itemize -String formatter (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:format" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -HXfmt is a small template system for by-name variable expansion. - It can be used to substitute placeholders in format strings supplied by - the user by appropriate expanded values defined by the program. -\end_layout - -\begin_layout Itemize -Directory creation, traversal, removal, and file copying (sections -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:dir-ops1" - -\end_inset - -, -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:dir-ops2" - -\end_inset - - and -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:file-ops" - -\end_inset - -) -\end_layout - -\begin_layout Itemize -Option parsing (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:option" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Table-/callback-based option parser that works similar to Perl's -\family typewriter -Getopt::Long -\family default - -\begin_inset space ~ -\end_inset - -— no open-coding but a single -\begin_inset Quotes eld -\end_inset - -atomic -\begin_inset Quotes erd -\end_inset - - invocation. -\end_layout - -\begin_layout Itemize -Shell-style config parser (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:shconf" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Configuration file reader for Shell-style -\begin_inset Quotes eld -\end_inset - -configuration -\begin_inset Quotes erd -\end_inset - - files with key-value pairs, as usually foudn in -\family typewriter -/etc\SpecialChar breakableslash -sysconfig -\family default -. -\end_layout - -\begin_layout Itemize -Random number gathering (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:random" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Convenient wrapper that uses kernel-provided RNG devices when available. -\end_layout - -\begin_layout Itemize -External process invocation (section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:proc" - -\end_inset - -) -\begin_inset Newline newline -\end_inset - -Setting up pipes for the standard file descriptors for sending/capturing - data to/from a program. -\end_layout - -\begin_layout Itemize - -\shape italic -a bit more beyond that ... - Miscellaneous -\end_layout - -\begin_layout Section -Resources -\end_layout - -\begin_layout Standard -As of this writing, the repository is located at -\end_layout - -\begin_layout Itemize -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -git://libhx.git.sf.net/gitroot/libhx/libhx -\end_layout - -\end_inset - - -\begin_inset space ~ -\end_inset - -— clone URL -\end_layout - -\begin_layout Itemize -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -http://libhx.git.sf.net/ -\end_layout - -\end_inset - - -\begin_inset space ~ -\end_inset - -— gitweb interface -\end_layout - -\begin_layout Itemize -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -http://libhx.sf.net/ -\end_layout - -\end_inset - - -\begin_inset space ~ -\end_inset - -— home page (and link to tarballs) -\end_layout - -\begin_layout Itemize -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -http://freecode.com/projects/libhx/ -\end_layout - -\end_inset - - -\begin_inset space ~ -\end_inset - -— Freecode page (useful for automatic notification of new releases) -\end_layout - -\begin_layout Section -Installation -\end_layout - -\begin_layout Standard -libHX uses GNU autotools as a build environment, which means that all you - have to run as a end-user is the -\family typewriter -configure -\family default - with any options that you need, plus the usual -\family typewriter -make -\family default - and -\family typewriter -make install -\family default - as desired. -\end_layout - -\begin_layout Standard -Pay attention to multi-lib Linux distributions where you most likely need - to specify a different libdir instead of using the default -\begin_inset Quotes eld -\end_inset - -lib -\begin_inset Quotes erd -\end_inset - -. - In case of the Debian-style multi-arch/multi-lib proposal ( -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -http://wiki.debian.org/Multiarch -\end_layout - -\end_inset - -): -\end_layout - -\begin_layout LyX-Code -$ -\series bold -./configure --libdir='${prefix}/lib/x86_64-linux-gnu' -\end_layout - -\begin_layout Standard -and the classic-style 32-64 2-lib distributions: -\end_layout - -\begin_layout LyX-Code -$ -\series bold -./configure --libdir='${prefix}/lib64' -\end_layout - -\begin_layout Subsection -Requirements -\end_layout - -\begin_layout Itemize -GNU C Compiler 3.3.5 or newer. - Other compilers (non-GCC) have not been tested in months -\begin_inset space ~ -\end_inset - -— use at your own risk. -\end_layout - -\begin_layout Itemize -approximately 80–160 -\begin_inset space ~ -\end_inset - -KB of disk space on Linux for the shared library (depends on platform) and - header files. -\end_layout - -\begin_layout Standard -A C++ compiler is only needed if you want to build the C++ test programs - that come with libHX. - By default, if there is no C++ compiler present, these will not be built. -\end_layout - -\begin_layout Itemize -No external libraries are needed for compilation of libHX. - Helper files, like -\family typewriter -libxml_\SpecialChar softhyphen -helper.h -\family default -, may reference their include files, but they are not used during compilation. -\end_layout - -\begin_layout Section -Portability notice -\end_layout - -\begin_layout Standard -libHX runs on contemporary versions of Linux, Solaris and the three BSD - distributions. - It might even work on Microsoft Windows, but this is not tested very often, - if at all. - Overly old systems, especially Unices, are not within focus. - While AIX -\begin_inset space ~ -\end_inset - -5.3 might still classify as contemporary, strangelets like -\begin_inset Quotes eld -\end_inset - -Ultrix -\begin_inset Quotes erd -\end_inset - - or -\begin_inset Quotes eld -\end_inset - -Dynix -\begin_inset Quotes erd -\end_inset - - you can find in the autotools-related file -\family typewriter -config.guess -\family default - are some that are definitely not. -\end_layout - -\begin_layout Standard -Furthermore, a compiler that understands the C99 or GNU89 standard is required. - The integer type -\begin_inset Quotes eld -\end_inset - -int -\begin_inset Quotes erd -\end_inset - - should at best have 32 bits at least. - There is no ultra-portable version as of this writing, but feel free to - start one akin to the -\begin_inset Quotes eld -\end_inset - -p -\begin_inset Quotes erd -\end_inset - - variants of OpenBSD software such as OpenSSH. -\end_layout - -\begin_layout Section -History -\end_layout - -\begin_layout Standard -The origins of libHX trace back, even crossing a language boundary, to when - the author started on using Perl in 1999. - Some tasks were just too damn useful to be open-coded every time. - Two such examples are what is these days known as -\family typewriter -HX_basename -\family default - and -\family typewriter -HX_mkdir -\family default -. - The name does not relate to anyone's initials; it is a result of a truncation - of the author's nick used years ago. -\end_layout - -\begin_layout Standard -Around the beginning of 2003, the author also started on the C programming - language and soon the small library was converted from Perl to C. - The libHX library as of today is the result of working with C ever since, - and naturally grew from there to support whatever the author was in need - of. -\end_layout - -\begin_layout Standard -The -\begin_inset Quotes eld -\end_inset - -correct -\begin_inset Quotes erd -\end_inset - - name for libHX is with an uppercase -\begin_inset Quotes eld -\end_inset - -H -\begin_inset Quotes erd -\end_inset - - and uppercase -\begin_inset Quotes eld -\end_inset - -X -\begin_inset Quotes erd -\end_inset - -, and the same is used for filenames, such as -\begin_inset Quotes eld -\end_inset - -libHX.so -\begin_inset Quotes erd -\end_inset - - -\begin_inset Foot -status open - -\begin_layout Plain Layout -Software projects may choose to entirely lowercase the project name for - use in filenames, such as the Linux kernel which is released as -\family typewriter -linux-${ -\family default -\shape italic -version -\family typewriter -\shape default -}.tar.bz2 -\family default -, or the project may choose to keep the name for filenames, like Mesa and - SDL do. - libHX is of the latter. -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Part -General -\end_layout - -\begin_layout Standard -Many functions are prefixed with -\begin_inset Quotes eld -\end_inset - - -\family typewriter -HX_ -\family default - -\begin_inset Quotes erd -\end_inset - - or -\begin_inset Quotes eld -\end_inset - - -\family typewriter -HXsubsys_ -\family default - -\begin_inset Quotes erd -\end_inset - -, as are structures (sometimes without underscores, be sure to check the - syntax and names), to avoid name clashes with possibly existing files. - Functions that are not tied to a specific data structure such as most of - the string functions (see chapter -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:strings" - -\end_inset - -) use the subsystem-less prefix, -\begin_inset Quotes eld -\end_inset - - -\family typewriter -HX_ -\family default - -\begin_inset Quotes erd -\end_inset - -. - Functions from a clearly-defined subsystem, such as map or deque, augment - the base prefix by a suffix, forming e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\begin_inset Quotes eld -\end_inset - - -\family typewriter -HXmap_ -\family default - -\begin_inset Quotes erd -\end_inset - -. -\end_layout - -\begin_layout Section -Initialization -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/init.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_init( -\series bold -void -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX_init -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HX_exit( -\series bold -void -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX_exit -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Before using the library's functions, -\family typewriter -HX_init -\family default - must be called. - This function will initialize any needed state libHX needs for itself, - if any. - It is designed to be invoked multiple times, such as for example, from - different libraries linking to libHX itself, and will refcount. - On success, >0 is returned. - If there was an error, it will return a negative error code or zero. - -\family typewriter -HX_exit -\family default - is the logical counterpart of notifying that the library is no longer used. -\end_layout - -\begin_layout Section -Type-checking casts -\end_layout - -\begin_layout Standard -The C++ language provides so-called -\begin_inset Quotes eld -\end_inset - -new-style casts -\begin_inset Quotes erd -\end_inset - -, referring to the four template-looking invocations -\family typewriter -static_cast<> -\family default -, -\family typewriter -const_cast<> -\family default -, -\family typewriter -reinterpret_cast<> -\family default - and -\family typewriter -dynamic_cast<> -\family default -. - No such blessing was given to the C language, but still, even using macros - that expand to the olde cast make it much easier to find casts in source - code and annotate why something was casted, which is already an improvement. -\begin_inset space ~ -\end_inset - -— Actually, it -\shape italic -is -\shape default - possible to do a some type checking, using some GCC extensions, which augments - these macros from their documentary nature to an actual safety measure. -\end_layout - -\begin_layout Subsection - -\family typewriter -reinterpret_cast -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -reinterpret_cast -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -reinterpret_cast() -\family default - maps directly to the old-style typecast, -\family typewriter -(type)(expr) -\family default -, and causes the bit pattern for the expr rvalue to be -\begin_inset Quotes eld -\end_inset - -reinterpreted -\begin_inset Quotes erd -\end_inset - - as a new type. - You will notice that -\begin_inset Quotes eld -\end_inset - -reinterpret -\begin_inset Quotes erd -\end_inset - - is the longest of all the -\family typewriter -*_cast -\family default - names, and can easily cause your line to grow to 80 columns (the good maximum - in many style guides). - As a side effect, it is a good indicator that something potentially dangerous - might be going on, for example converting intergers from/to pointer. -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/defs.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/defs.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold - -\begin_inset Newline newline -\end_inset - -int -\series default - i; -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -Tree with numeric keys -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - -tree = HXhashmap_init(0); -\begin_inset Newline newline -\end_inset - - -\series bold -for -\series default - (i = 0; i < 6; ++i) -\begin_inset Newline newline -\end_inset - - HXmap_add(tree, -\series bold -reinterpret_cast -\series default -( -\series bold -void * -\series default -, -\begin_inset Newline newline -\end_inset - - -\series bold -static_cast -\series default -( -\series bold -long -\series default -, i)), my_data); -\end_layout - -\begin_layout Subsection - -\family typewriter -signed_cast -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -signed_cast -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -This tag is for annotating that the cast was solely done to change the signednes -s of pointers to char -\begin_inset space ~ -\end_inset - -— and only those. - No integers etc. - The intention is to facilitate working with libraries that use -\family typewriter -unsigned char -\begin_inset space ~ -\end_inset - -* -\family default - pointers, such as libcrypto and libssl (from the OpenSSL project) or libxml2, - for example. - See table -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "tab:defs-signed_cast" - -\end_inset - - for the allowed conversions. - C++ does -\shape italic -not -\shape default - actually have a -\family typewriter -signed_cast<> -\family default -, and one would have to use -\family typewriter -reinterpret_cast<> -\family default - to do the conversion, because -\family typewriter -static_cast<> -\family default - does not allow conversion from -\family typewriter -const char -\begin_inset space ~ -\end_inset - -* -\family default - to -\family typewriter -const unsigned char -\begin_inset space ~ -\end_inset - -* -\family default -, for example. - (libHX's -\family typewriter -static_cast() -\family default - would also throw at least a compiler warning about the different signedness.) - libHX does provide a -\family typewriter -signed_cast<> -\family default - for C++ though. - This is where -\family typewriter -signed_cast -\family default - comes in. -\end_layout - -\begin_layout Standard -\begin_inset Float table -wide false -sideways false -status open - -\begin_layout Plain Layout -\align center -\begin_inset Tabular -<lyxtabular version="3" rows="7" columns="7"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -From -\backslash - To -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -c* -\series default -section -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -sc* -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -uc* -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -Cc* -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -Csc* -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -Cuc* -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -char * -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -signed char * -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -unsigned char * -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -const char * -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -const signed char * -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -const unsigned char * -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -– -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\checkmark$ -\end_inset - - -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -\begin_inset CommandInset label -LatexCommand label -name "tab:defs-signed_cast" - -\end_inset - -Accepted conversions for -\family typewriter -signed_cast() -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Subsection - -\family typewriter -static_cast -\begin_inset CommandInset label -LatexCommand label -name "subsec:defs-static_cast" - -\end_inset - - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -static_cast -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Just like C++'s -\family typewriter -static_cast<> -\family default -, libHX's -\family typewriter -static_cast() -\family default - verifies that -\family typewriter -expr -\family default - can be implicitly converted to the new type (by a simple -\family typewriter -b -\begin_inset space ~ -\end_inset - -= -\begin_inset space ~ -\end_inset - -a -\family default -). - Such is mainly useful for forcing a specific type, as is needed in varargs - functions such as -\family typewriter -printf -\family default -, and where the conversion actually incurs other side effects, such as truncatio -n or promotion: -\end_layout - -\begin_layout LyX-Code - -\series bold -/* -\family roman -\series default -\shape italic -Convert to a type printf knows about -\family default -\series bold -\shape default - */ -\begin_inset Newline newline -\end_inset - -uint64_t -\series default - x = something; -\begin_inset Newline newline -\end_inset - -printf("%llu -\backslash -n", -\series bold -static_cast -\series default -( -\series bold -unsigned long long -\series default -, x)); -\end_layout - -\begin_layout Standard -Because there is no format specifier for -\family typewriter -uint64_t -\family default - for -\family typewriter -printf -\family default -, a conversion to an accepted type is necessary to not cause undefined behavior. - The author has seen code that did, for example, -\family typewriter -printf("%u") -\family default - on a -\begin_inset Quotes eld -\end_inset - -long -\begin_inset Quotes erd -\end_inset - -, which only works on architectures where -\family typewriter -sizeof(unsigned int) -\family default - happens to equal -\family typewriter -sizeof(unsigned long) -\family default -, such as x86_32. - On x86_64, an -\family typewriter -unsigned long -\family default - is usually twice as big as an -\family typewriter -unsigned int -\family default -, so that 8 bytes are pushed onto the stack, but -\family typewriter -printf -\family default - only unshifts 4 bytes because the developer used -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%u -\family default - -\begin_inset Quotes erd -\end_inset - -, leading to misreading the next variable on the stack. -\end_layout - -\begin_layout LyX-Code - -\series bold -/* -\family roman -\series default -\shape italic -Force promotion -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold -double -\series default - a_quarter = -\series bold -static_cast -\series default -( -\series bold -double -\series default -, 1) / 4; -\end_layout - -\begin_layout Standard -Were -\begin_inset Quotes eld -\end_inset - -1 -\begin_inset Quotes erd -\end_inset - - not promoted to double, the result in -\family typewriter -q -\family default - would be zero because 1/4 is just an integer division, yielding zero. - By making one of the operands a floating-point quantity, the compiler will - instruct the FPU to compute the result. - Of course, one could have also written -\begin_inset Quotes eld -\end_inset - - -\family typewriter -1.0 -\family default - -\begin_inset Quotes erd -\end_inset - - instead of -\family typewriter -static_cast(double, 1) -\family default -, but this is left for the programmer to decide which style s/he prefers. -\end_layout - -\begin_layout LyX-Code - -\series bold -/* -\family roman -\series default -\shape italic -Force truncation before invoking second sqrt -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold -double -\series default - f = sqrt( -\series bold -static_cast -\series default -( -\series bold -int -\series default -, 10 * sqrt(3.0 / 4))); -\end_layout - -\begin_layout Standard -And here, the conversion from -\family typewriter -double -\family default - to -\family typewriter -int -\family default - incurs a (wanted) truncation of the decimal fraction, that is, rounding - down for positive numbers, and rounding up for negative numbers. -\end_layout - -\begin_layout Subsubsection -Allowed conversions -\end_layout - -\begin_layout Itemize - -\series bold -Numbers -\series default - -\begin_inset Newline newline -\end_inset - -Conversion between numeric types, such as -\family typewriter -char -\family default -, -\family typewriter -short -\family default -, -\family typewriter -int -\family default -, -\family typewriter -long -\family default -, -\family typewriter -long long -\family default -, -\family typewriter -int -\shape italic -N -\shape default -_t -\family default -, both their signed and unsigned variants, -\family typewriter -float -\family default - and -\family typewriter -double -\family default -. -\end_layout - -\begin_layout Itemize - -\series bold -Generic Pointer -\series default - -\begin_inset Newline newline -\end_inset - -Conversion from -\family typewriter -type -\begin_inset space ~ -\end_inset - -* -\family default - to and from -\family typewriter -void -\begin_inset space ~ -\end_inset - -* -\family default -. - (Where -\family typewriter -type -\family default - may very well be a type with further indirection.) -\end_layout - -\begin_layout Itemize - -\series bold -Generic Pointer (const) -\begin_inset Newline newline -\end_inset - - -\series default -Conversion from -\family typewriter -const type -\begin_inset space ~ -\end_inset - -* -\family default - to and from -\family typewriter -const void -\begin_inset space ~ -\end_inset - -* -\family default -. -\end_layout - -\begin_layout Subsection - -\family typewriter -const_cast -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -const_cast -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -const_cast -\family default - allows to add or remove -\begin_inset Quotes eld -\end_inset - -const -\begin_inset Quotes erd -\end_inset - - qualifiers from the type a pointer is pointing to. - Due to technical limitations, it could not be implemented to support arbitrary - indirection. - Instead, -\family typewriter -const_cast -\family default - comes in three variants, to be used for indirection levels of 1 to 3: -\end_layout - -\begin_layout Itemize - -\family typewriter -\series bold -const_cast -\series default -1( -\series bold -type -\begin_inset space ~ -\end_inset - -* -\series default -, expr) -\family default - with -\family typewriter -\series bold -typeof -\series default -(expr) -\begin_inset space ~ -\end_inset - -= -\series bold -type -\begin_inset space ~ -\end_inset - -* -\family default -\series default -. - (Similarly for any combinations of const.) -\end_layout - -\begin_layout Itemize - -\family typewriter -\series bold -const_cast -\series default -2( -\series bold -type -\begin_inset space ~ -\end_inset - -** -\series default -, expr) with -\series bold -typeof -\series default -(expr) -\begin_inset space ~ -\end_inset - -= -\series bold -type -\begin_inset space ~ -\end_inset - -** -\family default -\series default - (and all combinations of const in all possible locations). -\end_layout - -\begin_layout Itemize - -\family typewriter -\series bold -const_cast -\series default -3( -\series bold -type -\begin_inset space ~ -\end_inset - -*** -\series default -, expr) with -\series bold -typeof -\series default -(expr) -\begin_inset space ~ -\end_inset - -= -\series bold -type -\begin_inset space ~ -\end_inset - -*** -\family default -\series default - (and all combinations...). -\end_layout - -\begin_layout Standard -As indirection levels above 3 are really unlikely -\begin_inset Foot -status open - -\begin_layout Plain Layout -See -\begin_inset Quotes eld -\end_inset - -Three Star Programmer -\begin_inset Quotes erd -\end_inset - - -\end_layout - -\end_inset - -, having only these three type-checking cast macros was deemed sufficient. - The only place where libHX even uses a level\SpecialChar nobreakdash -3 indirection is in the option - parser. -\end_layout - -\begin_layout Standard -\begin_inset Float table -placement H -wide false -sideways false -status open - -\begin_layout Plain Layout -\align center -\begin_inset Tabular -<lyxtabular version="3" rows="2" columns="2"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int ** -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int *const * -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -const int ** -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -const int *const * -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Accepted expr/target types for -\family typewriter -const_cast2 -\family default -; example for the -\begin_inset Quotes eld -\end_inset - -int -\begin_inset Quotes erd -\end_inset - - type -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Plain Layout -\align center -Conversion is permitted when expression and target type are from the table. -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -It is currently not possible to use -\family typewriter -const_cast -\family default -1/2/3 on pointers to structures whose member structure is unknown. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Macros -\end_layout - -\begin_layout Standard -All macros in this section are available through -\family typewriter -#include <libHX/defs.h> -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/defs.h -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Subsection -Preprocessor -\end_layout - -\begin_layout LyX-Code - -\series bold -#define -\series default - HX_STRINGIFY(s) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_STRINGIFY -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Transforms the expansion of the argument -\family typewriter -s -\family default - into a C string. -\end_layout - -\begin_layout Subsection -Sizes -\end_layout - -\begin_layout LyX-Code - -\series bold -#define -\series default - HXSIZEOF_Z16 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXSIZEOF_Z16 -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -#define -\series default - HXSIZEOF_Z32 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXSIZEOF_Z32 -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -#define -\series default - HXSIZEOF_Z64 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXSIZEOF_Z64 -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Expands to the size needed for a buffer (including ' -\family typewriter - -\backslash -0 -\family default -') to hold the base-10 string representation of a 16\SpecialChar nobreakdash -, 32\SpecialChar nobreakdash - or 64\SpecialChar nobreakdash -bit integer. -\end_layout - -\begin_layout Subsection -Locators -\end_layout - -\begin_layout LyX-Code -output_type -\series bold -* -\series default -containerof( -\series bold -input_type * -\series default -ptr, output_type, member); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -containerof -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -size_t -\series default - HXsizeof_member(struct_type, member); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXsizeof_member -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -output_type HXtypeof_member(struct_type, member); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXtypeof_member -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -containerof -\family default - will return a pointer to the struct in which -\family typewriter -ptr -\family default - is contained as the given member. -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - foo { -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - bar; -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - baz; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static void -\series default - test( -\series bold -int * -\series default -ptr) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - foo -\series bold -* -\series default -self = containerof(baz, -\series bold -struct -\series default - foo, baz); -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Standard - -\family typewriter -HXsizeof_member -\family default - and -\family typewriter -HXtypeof_member -\family default - are shortcuts (mainly for the C language) to get the size or type of a - named member in a given struct: -\end_layout - -\begin_layout LyX-Code - -\series bold -char -\series default - padding[FIELD_SIZEOF( -\series bold -struct -\series default - foo, baz)]; -\end_layout - -\begin_layout Standard -In C++, one can simply use -\family typewriter -sizeof(foo::baz) -\family default - and -\family typewriter -decltype(foo::baz) -\family default -. -\end_layout - -\begin_layout Subsection -Array size -\end_layout - -\begin_layout LyX-Code - -\series bold -size_t -\series default - ARRAY_SIZE( -\series bold -type -\series default - array -\series bold -[] -\series default -); -\series bold -/* -\family roman -\series default -\shape italic -implemented as a macro -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -ARRAY_SIZE -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Returns the number of elements in -\family typewriter -array -\family default -. - This only works with true arrays ( -\family typewriter -type[] -\family default -), and will not output a meaningful value when used with a pointer-to-element - ( -\family typewriter -type -\begin_inset space ~ -\end_inset - -* -\family default -), which is often used for array access too. -\end_layout - -\begin_layout Subsection -Compile-time build checks -\end_layout - -\begin_layout LyX-Code - -\series bold -int -\series default - BUILD_BUG_ON_EXPR( -\series bold -bool -\series default - condition); -\series bold -/* -\family roman -\series default -\shape italic -implemented as a macro -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -BUILD_BUG_ON_EXPR -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - BUILD_BUG_ON( -\series bold -bool -\series default - condition); -\series bold -/* -\family roman -\series default -\shape italic -implemented as a macro -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -BUILD_BUG_ON -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Causes the compiler to fail when -\family typewriter -condition -\family default - evaluates to true. - If not implemented for a compiler, it will be a no-op. - -\family typewriter -BUILD_BUG_ON -\family default - is meant to be used as a standalone statement, while -\family typewriter -BUILD_\SpecialChar softhyphen -BUG_\SpecialChar softhyphen -ON_\SpecialChar softhyphen -EXPR -\family default - is for when a check is to occur within an expression, that latter of which - is useful for within macros when one cannot, or does not want to use multiple - statements. -\end_layout - -\begin_layout LyX-Code -type DEMOTE_TO_PTR(type expr); -\series bold -/* -\family roman -\series default -\shape italic -macro -\family default -\series bold -\shape default - */ -\end_layout - -\begin_layout Standard -Changes the type of expr to pointer type: If -\family typewriter -expr -\family default - of array type class, changes it to a pointer to the first element. - If -\family typewriter -expr -\family default - of function type class, changes it to a pointer to the function. -\end_layout - -\begin_layout LyX-Code - -\series bold -int -\series default - main( -\series bold -void -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -int (* -\series default -fp -\series bold -) -\series default -( -\series bold -void -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -char -\series default - a -\series bold -[ -\series default -123 -\series bold -] -\series default -; -\begin_inset Newline newline -\end_inset - -DEMOTE_TO_PTR(main); -\series bold -/* -\family roman -\series default -\shape italic -yields -\series bold -int (*) -\series default -( -\series bold -void -\series default -); -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - -DEMOTE_TO_PTR(fp); -\series bold -/* -\series default -also yields -\family roman -\series bold -\shape italic -int (*) -\series default -( -\series bold -void -\series default -); -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - -DEMOTE_TO_PTR(a); -\series bold -/* -\series default -yields -\family roman -\series bold -\shape italic -char * -\family default -\shape default - */ -\end_layout - -\begin_layout Subsection -UNIX file modes -\end_layout - -\begin_layout LyX-Code - -\series bold -#define -\series default - S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -S_IRUGO -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -#define -\series default - S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -S_IWUGO -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -#define -\series default - S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -S_IXUGO -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -#define -\series default - S_IRWXUGO (S_IRUGO | S_IWUGO | S_IXUGO) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -S_IRWXUGO -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -The defines make it vastly easier to specify permissions for large group - of users. - For example, if one wanted to create a file with the permissions -\family typewriter -rw-r--r-- -\family default - (ignoring the umask in this description), -\family typewriter -S_IRUSR -\begin_inset space ~ -\end_inset - -| S_IWUSR -\family default - can now be used instead of the longer -\family typewriter -S_IRUSR -\begin_inset space ~ -\end_inset - -| S_IWUSR -\begin_inset space ~ -\end_inset - -| S_IRGRP -\begin_inset space ~ -\end_inset - -| S_IROTH -\family default -. -\end_layout - -\begin_layout Subsection -VC runtime format specifiers -\end_layout - -\begin_layout Standard -The Microsoft Visual C runtime (a weak libc) uses non-standard format specifiers - for certain types. - Whereas C99 specifies -\begin_inset Quotes eld -\end_inset - -z -\begin_inset Quotes erd -\end_inset - - for -\family typewriter -size_t -\family default - and -\begin_inset Quotes eld -\end_inset - -ll -\begin_inset Quotes erd -\end_inset - - for long long, MSVCRT users must use -\begin_inset Quotes eld -\end_inset - -I -\begin_inset Quotes erd -\end_inset - - and -\begin_inset Quotes eld -\end_inset - -I64 -\begin_inset Quotes erd -\end_inset - - (forming -\family typewriter -%Id -\family default - instead of -\family typewriter -%zd -\family default - for -\family typewriter -ssize_t -\family default -, for example). - libHX provides two convenience macros for this: -\end_layout - -\begin_layout LyX-Code - -\series bold -#define -\series default - HX_SIZET_FMT "z" -\family roman -\shape italic - or -\family default -\shape default -"I" -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_SIZET_FMT -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -#define -\series default - HX_LONGLONG_FMT "ll" -\family roman -\shape italic - or -\family default -\shape default -"I64" -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_LONGLONG_FMT -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -These may be used together with printf or scanf: -\end_layout - -\begin_layout LyX-Code -printf("struct timespec is of size %" HX_SIZET_FMT "u -\backslash -n", -\begin_inset Newline newline -\end_inset - - -\series bold -sizeof -\series default -(struct timespec)); -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Miscellaneous functions -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/misc.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/misc.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_ffs( -\series bold -unsigned long -\series default - z); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_ffs -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_fls( -\series bold -unsigned long -\series default - z); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_fls -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HX_hexdump( -\series bold -FILE * -\series default -fp, -\series bold -const void * -\series default -ptr, -\series bold -unsigned int -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_hexdump -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HX_zvecfree( -\series bold -char ** -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_zvecfree -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - HX_zveclen( -\series bold -const char *const * -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_zveclen -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_ffs -\family default - Finds the first (lowest-significant) bit in a value and returns its position, - or -1 to indicate failure. -\end_layout - -\begin_layout Description - -\family typewriter -HX_fls -\family default - Finds the last (most-significant) bit in a value and returns its position, - or -1 to indicate failure. -\end_layout - -\begin_layout Description - -\family typewriter -HX_hexdump -\family default - Outputs a nice pretty-printed hex and ASCII dump to the filedescriptor - -\family typewriter -fp -\family default -. - -\family typewriter -ptr -\family default - is the memory area, of which -\family typewriter -len -\family default - bytes will be dumped. -\end_layout - -\begin_layout Description - -\family typewriter -HX_zvecfree -\family default - Frees the supplied Z-vector array. - (Frees all array elements from the first element to (excluding) the first - -\family typewriter -NULL -\family default - element.) -\end_layout - -\begin_layout Description - -\family typewriter -HX_zveclen -\family default - Counts the number of array elements until the first -\family typewriter -NULL -\family default - array element is seen, and returns this number. -\end_layout - -\begin_layout Section -Time functions -\end_layout - -\begin_layout Standard -Time in POSIX systems is represented in -\family typewriter -struct timespec -\family default -. - This structure is composed of two members: one integer for the number of - full seconds in the time value, and one integer for the number of nanoseconds - that remain when subtracting the full seconds from the time value. - POSIX leaves it unspecified how negative time is to be represented with - this structure, so I have devised an algebra for use with the same struct - that gives negative time support. -\end_layout - -\begin_layout Standard -Since integers often cannot store negative zero (due to e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - -use of 2s complements in the language implementation), we will store the - minus sign in the nanosecond member if the integral second part is zero. - This gives us the property that we can test for negative time by looking - for whether at least one member of the structure is negative. - Also, we want to avoid storing the minus in both members to somewhat aid - the pretty-printing construct often seen, -\end_layout - -\begin_layout LyX-Code -printf("%ld.%09ld -\backslash -n", (long)ts.tv_sec, ts.tv_nsec); -\end_layout - -\begin_layout Standard -The number of combinations of a (non-zero) negative number, zero and a (non-zero -) positive number is small, so we can actually just exhaustively list them - all. -\begin_inset Separator latexpar -\end_inset - - -\end_layout - -\begin_layout Standard -\noindent -\align center -\begin_inset Tabular -<lyxtabular version="3" rows="4" columns="6"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Representation -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -Time value -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -T -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -R -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -T -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ -1,-1\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -illegal -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ 0,-1\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout --0.1 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ 1,-1\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -illegal -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ -1,0\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout --1.0 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ 0,0\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0.0 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ 1,0\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1.0 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ -1,1\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout --1.1 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ 0,1\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -0.1 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -\begin_inset Formula $\left\{ 1,1\right\} $ -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout -1.1 -\begin_inset space \thinspace{} -\end_inset - -s -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Standard -The set of so-extended valid timespecs is therefore: -\end_layout - -\begin_layout Standard -\begin_inset Formula -\[ -K=\left\{ \left(i,f\right):i,f\in\mathbb{Z}\wedge i\neq0\wedge0\leq f<10^{9}\right\} \cup\left\{ \left(i,f\right):i=0\wedge f\in\mathbb{Z}\wedge-10^{9}<f<10^{9}\right\} -\] - -\end_inset - - -\end_layout - -\begin_layout Subsection -Function list -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/misc.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_timespec_isneg( -\series bold -const struct -\series default - timespec -\series bold -* -\series default -p); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_timespec_isneg -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - timespec -\series bold -* -\series default -HX_timespec_neg( -\series bold -struct -\series default - timespec -\series bold -* -\series default -result, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - timespec -\series bold -* -\series default -p); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_timespec_neg -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - timespec -\series bold -* -\series default -HX_timespec_add( -\series bold -struct -\series default - timespec -\series bold -* -\series default -result, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - timespec -\series bold -* -\series default -p, -\series bold -const struct -\series default - timespec -\series bold -* -\series default -q); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_timespec_add -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - timespec -\series bold -* -\series default -HX_timespec_sub( -\series bold -struct -\series default - timespec -\series bold -* -\series default -delta, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - timespec -\series bold -* -\series default -p, -\series bold -const struct -\series default - timespec -\series bold -* -\series default -q); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_timespec_sub -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - timespec -\series bold -* -\series default -HX_timespec_mul( -\series bold -struct -\series default - timespec -\series bold -* -\series default -delta, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - timespec -\series bold -* -\series default -p, -\series bold -int -\series default - f); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_timespec_mul -\end_layout - -\end_inset - - -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - timespec -\series bold -* -\series default -HX_timespec_mulf( -\series bold -struct -\series default - timespec -\series bold -* -\series default -delta, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - timespec -\series bold -* -\series default -p, -\series bold -double -\series default - f); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_timespec_mulf -\end_layout - -\end_inset - - -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - timeval -\series bold -* -\series default -HX_timeval_sub( -\series bold -struct -\series default - timeval -\series bold -* -\series default -delta, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - timeval -\series bold -* -\series default -p, -\series bold -const struct -\series default - timeval -\series bold -* -\series default -q); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_timeval_sub -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_time_compare( -\series bold -const struct -\series default - stat -\series bold -* -\series default -a, -\series bold -const struct -\series default - stat -\series bold -* -\series default -b, -\series bold -int -\series default - mode); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_time_compare -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_timespec_isneg -\family default - Determines whether a timespec structure represents (non-zero) negative - time. -\end_layout - -\begin_layout Description - -\family typewriter -HX_timespec_neg -\family default - Computes the negation of the time specified by -\family typewriter -p -\family default -. - -\family typewriter -result -\family default - and -\family typewriter -p -\family default - may point to the same structure. -\end_layout - -\begin_layout Description - -\family typewriter -HX_timespec_add -\family default - Calculates the sum of the two times specified by -\family typewriter -p -\family default - and -\family typewriter -q -\family default -, which are of type -\family typewriter -struct timespec -\family default -. - Any of -\family typewriter -result -\family default -, -\family typewriter -p -\family default - and -\family typewriter -q -\family default - may point to the same structure. -\end_layout - -\begin_layout Description - -\family typewriter -HX_timespec_sub -\family default - Calculates the difference between the two timepoints p and q, which are - of type -\family typewriter -struct timespec -\family default - (nanosecond granularity). -\end_layout - -\begin_layout Description - -\family typewriter -HX_timespec_mul -\family default - Multiplies the time quantum in -\family typewriter -p -\family default - by -\family typewriter -f -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_timespec_mulf -\family default - Multiplies the time quantum in -\family typewriter -p -\family default - by -\family typewriter -f -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_timeval_sub -\family default - Calculates the difference between the two timepoints p and q, which are - of type -\family typewriter -struct timeval -\family default - (microsecnod granularity). -\end_layout - -\begin_layout Description - -\family typewriter -HX_time_compare -\family default - Compares the timestamps from two -\family typewriter -struct stat -\family default -s. - -\family typewriter -mode -\family default - indicates which field is compared, which can either be -\family typewriter -'a' -\family default - for the access time, -\family typewriter -'c' -\family default - for the inode change time, -\family typewriter -'m' -\family default - for the modification time, or -\family typewriter -'o' -\family default - for the creation time (where available). - Returns a negative number if the time in -\family typewriter -a -\family default - is less than -\family typewriter -b -\family default -, zero when they are equal, or a positive number greater than zero if -\family typewriter -a -\family default - is greater than -\family typewriter -b -\family default -. -\end_layout - -\begin_layout Standard -The macros -\family typewriter -HX_TIMESPEC_FMT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_TIMESPEC_FMT -\end_layout - -\end_inset - - and -\family typewriter -HX_TIMESPEC_EXP -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_TIMESPEC_EXP -\end_layout - -\end_inset - - can be used for passing and printing a -\family typewriter -struct timespec -\family default - using the * -\family typewriter -printf -\family default - function family: -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - timespec p; -\begin_inset Newline newline -\end_inset - -clock_gettime(CLOCK_MONOTONIC, &p); -\begin_inset Newline newline -\end_inset - -printf("Now: " HX_TIMESPEC_FMT, HX_TIMESPEC_EXP(&p)); -\end_layout - -\begin_layout Standard -Similarly, -\family typewriter -HX_TIMEVAL_FMT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_TIMEVAL_FMT -\end_layout - -\end_inset - - and -\family typewriter -HX_TIMEVAL_EXP -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_TIMEVAL_EXP -\end_layout - -\end_inset - - exist for the older -\family typewriter -struct timeval -\family default -. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Bitmaps -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/misc.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -size_t -\series default - HXbitmap_size( -\series bold -type -\series default - array, -\series bold -unsigned int -\series default - bits); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXbitmap_size -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXbitmap_set( -\series bold -type * -\series default -bmap, -\series bold -unsigned int -\series default - bit); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXbitmap_set -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXbitmap_clear( -\series bold -type * -\series default -bmap, -\series bold -unsigned int -\series default - bit); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXbitmap_clear -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HXbitmap_test( -\series bold -type * -\series default -bmap, -\series bold -unsigned int -\series default - bit); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXbitmap_test -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -All of these four are implemented as macros, so they can be used with any - integer type that is desired to be used. -\end_layout - -\begin_layout Description - -\family typewriter -HXbitmap_size -\family default - Returns the amount of -\begin_inset Quotes eld -\end_inset - -type -\begin_inset Quotes erd -\end_inset - --based integers that would be needed to hold an array of the requested amount - of bits. -\end_layout - -\begin_layout Description - -\family typewriter -HXbitmap_set -\family default - Set the specific bit in the bitmap. -\end_layout - -\begin_layout Description - -\family typewriter -HXbitmap_clear -\family default - Clear the specific bit in this bitmap. -\end_layout - -\begin_layout Description - -\family typewriter -HXbitmap_test -\family default - Test for the specific bit and returns -\family typewriter -true -\family default - if it is set, otherwise -\family typewriter -false -\family default -. -\end_layout - -\begin_layout Subsubsection -Example -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <stdlib.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <string.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/misc.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - main( -\series bold -void -\series default -) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned long -\series default - bitmap -\series bold -[ -\series default -HXbitmap_size( -\series bold -unsigned long -\series default -, 128) -\series bold -] -\series default -; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - memset(bitmap, 0, sizeof(bitmap)); -\begin_inset Newline newline -\end_inset - - HXbitmap_set(bitmap, 49); -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - HXbitmap_get(bitmap, HX_irand(0, 128)) ? -\begin_inset Newline newline -\end_inset - - EXIT_SUCCESS : EXIT_FAILURE; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Part -Data structures -\end_layout - -\begin_layout Section -Maps -\begin_inset CommandInset label -LatexCommand label -name "sec:maps" - -\end_inset - - -\end_layout - -\begin_layout Standard -A map is a collection of key-value pairs. - (Some languages, such as Perl, also call them -\begin_inset Quotes eld -\end_inset - -associative array -\begin_inset Quotes erd -\end_inset - - or just -\begin_inset Quotes eld -\end_inset - -hash -\begin_inset Quotes erd -\end_inset - -, however, the underlying storage mechanism may not be an array or a hash, - however.) Each key is unique and has an associated value. - Keys can be any data desired; HXmap allows to specify your own key and - data handling functions so they can be strings, raw pointers, or complex - structures. -\end_layout - -\begin_layout Standard -To access any map-related functions, -\family typewriter -#include <libHX\SpecialChar breakableslash -map.h> -\family default -. -\end_layout - -\begin_layout Subsection -Structural definition -\begin_inset CommandInset label -LatexCommand label -name "subsec:maps-def" - -\end_inset - - -\end_layout - -\begin_layout Standard -The -\family typewriter -HXmap -\family default - structure is a near-opaque type. - Unlike the predecessor map implementation -\family typewriter -struct HXbtree -\family default - from libHX 2.x, the 3.x API exposes much less fields. -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXmap { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXmap -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - items, flags; -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Description - -\family typewriter -items -\family default - The number of items in the tree. - This field tracks the number of items in the map and is used to report - the number of elements to the user, and is updated whenever an element - is inserted or removed from the map. - The field must not be changed by user. -\end_layout - -\begin_layout Description - -\family typewriter -flags -\family default - The current behavior flags for the map. - While implementation-private bits are exposed, only -\family typewriter -HXMAP_NOREPLACE -\family default - is currently allowed to be (un)set by the developer while a map exists. -\end_layout - -\begin_layout Standard -For retrieving elements from a tree, some functions work with -\family typewriter -struct HXmap_node -\family default -, which is defined as follows: -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXmap_node { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXmap_node -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -union -\series default - { -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -key; -\begin_inset Newline newline -\end_inset - - -\series bold -const char *const -\series default - skey; -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - - -\series bold -union -\series default - { -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -data; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -sdata; -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Description - -\family typewriter -key -\family default - The so-called primary key, which uniquely identifies an element (a key-value - pair) in the map. - The memory portions that make up the key must not be modified. - (If the key changes, so does its hash value and/or position index, and - without taking that into account, writing to the key directly is going - to end up with an inconsistent state. - To change the key, you will need to delete the element and reinsert it - with its new key.) -\end_layout - -\begin_layout Description - -\family typewriter -skey -\family default - A convenience type field for when the map's keys are C strings. - It is useful for use with e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -printf -\family default - or other varargs function, which would otherwise require casting of the - -\family typewriter -void -\begin_inset space ~ -\end_inset - -*key -\family default - member to -\family typewriter -const char -\begin_inset space ~ -\end_inset - -* -\family default - first. -\end_layout - -\begin_layout Description - -\family typewriter -data -\family default - The data associated with the key. -\end_layout - -\begin_layout Description - -\family typewriter -sdata -\family default - Convenience type field. -\end_layout - -\begin_layout Subsection -Map initialization -\end_layout - -\begin_layout Standard -During initialization, you specify the underlying storage type by selecting - a given constructor function. - All further operations are done through the unified HXmap API which uses - a form of virtual calls internally. -\end_layout - -\begin_layout Standard -Currently, there are two distinct map types in libHX. - There are a handful of selectable symbols, though. - Abstract types are: -\end_layout - -\begin_layout Description - -\family typewriter -HXMAPT_DEFAULT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAPT_DEFAULT -\end_layout - -\end_inset - - No further preferences or guarantees; selects any map type that the libHX - maintainer deemed fast. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAPT_ORDERED -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAPT_ORDERED -\end_layout - -\end_inset - - The map shall use a data structure that provides ordered traversal. -\end_layout - -\begin_layout Standard -Specific types include: -\end_layout - -\begin_layout Description - -\family typewriter -HXMAPT_HASH -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_MAPT_HASH -\end_layout - -\end_inset - - Hash-based map -\begin_inset space ~ -\end_inset - -– Amortized -\begin_inset Formula $\mathcal{O}\left(1\right)$ -\end_inset - - insertion, lookup and deletion; unordered. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAPT_RBTREE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_MAPT_RBTREE -\end_layout - -\end_inset - - Red-black binary tree -\begin_inset space ~ -\end_inset - -– -\begin_inset Formula $\mathcal{O}\left(\log\left(n\right)\right)$ -\end_inset - - insertion, lookup and deletion; ordered. -\end_layout - -\begin_layout Standard -These can then be used with the initialization functions: -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXmap -\series bold -* -\series default -HXmap_init( -\series bold -unsigned int -\series default - type, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_init -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXmap -\series bold -* -\series default -HXmap_init5( -\series bold -unsigned int -\series default - type, -\series bold -unsigned int -\series default - flags, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - HXmap_ops -\series bold -* -\series default -ops, -\series bold -size_t -\series default - key_size, -\series bold -size_t -\series default - data_size); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_init5 -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Both the -\family typewriter -*_init -\family default - and -\family typewriter -*_init5 -\family default - variant creates a new map; the latter function allows to specify the operations - in detail as well as key and data size, which may become necessary when - using data sets which have their own way of being managed. - The -\family typewriter -flags -\family default - parameter can contain any of the following: -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_NONE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_NONE -\end_layout - -\end_inset - - This is just a mnemonic for the value 0, indicating no flags. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_NOREPLACE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_NOREPLACE -\end_layout - -\end_inset - - If a key already exists and another add operation is attempted, the key's - associated value will be replaced by the new value. - If this flag is absent, -\family typewriter --EEXIST -\family default - is returned. - This flag is allowed to be subsequently changed by the developer if so - desired, using bit logic such as -\family typewriter -map->flags &= ~HXMAP_NOREPLACE; -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_SKEY -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_SKEY -\end_layout - -\end_inset - - Notifies the constructor that keys will be C-style strings. - The flag presets the -\family typewriter -k_compare -\family default - operation to use -\family typewriter -strcmp -\family default -. - In the flag's absence, direct value comparison will be used if the key - size is specified as zero (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - -with the -\family typewriter -HXhashmap_\SpecialChar softhyphen -init4 -\family default - function call), or -\family typewriter -memcmp -\family default - if the key size is non-zero. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_CKEY -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_CKEY -\end_layout - -\end_inset - - Instructs the map to make copies of keys when they are added to the map. - This is required when the buffer holding the key changes or goes out of - scope. - The flag presets the -\family typewriter -k_clone -\family default - and -\family typewriter -k_free -\family default - operations to -\family typewriter -HX_memdup -\family default - and -\family typewriter -free -\family default -, and as such, the -\family typewriter -key_size -\family default - parameter must not be zero. - If however, -\family typewriter -HXMAP_SKEY -\family default - is also specified, -\family typewriter -HX_strdup -\family default - and -\family typewriter -free -\family default - will be used and -\family typewriter -key_size -\family default - must be zero. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_SDATA -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_SDATA -\end_layout - -\end_inset - - Notifies the constructor that data will be C-style strings. - This sets up the -\family typewriter -d_clone -\family default - and -\family typewriter -d_free -\family default - operations. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_CDATA -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_CDATA -\end_layout - -\end_inset - - Instructs the map to make copies of the data when new entries are added - to the map. - This is required when the buffer holding the data either goes out of scope, - or you want to keep the original contents instead of just a pointer. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_SCKEY -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_SCKEY -\end_layout - -\end_inset - - Mnemonic for the combination of -\family typewriter -HXMAP_\SpecialChar softhyphen -SKEY -\family default - OR'ed with -\family typewriter -HXMAP_\SpecialChar softhyphen -CKEY -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_SCDATA -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_SCDATA -\end_layout - -\end_inset - - Mnemonic for the combination of -\family typewriter -HXMAP_\SpecialChar softhyphen -SDATA -\family default - OR'ed with -\family typewriter -HXMAP_\SpecialChar softhyphen -SDATA -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_SINGULAR -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_SINGULAR -\end_layout - -\end_inset - - Specifies that the -\begin_inset Quotes eld -\end_inset - -map -\begin_inset Quotes erd -\end_inset - - is only used as a set, i. -\begin_inset space \thinspace{} -\end_inset - -e. -\begin_inset space \space{} -\end_inset - -it does not store any values, only keys. - Henceforth, the -\family typewriter -value -\family default - argument to -\family typewriter -HXmap_add -\family default - must always be -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Subsection -Flag combinations -\end_layout - -\begin_layout Standard -This subsection highlights the way -\family typewriter -HXMAP_SKEY -\family default - interacts with -\family typewriter -HXMAP_CKEY -\family default - and the key size. - The copy semantics are the same for -\family typewriter -HXMAP_SDATA -\family default - and -\family typewriter -HXMAP_CDATA -\family default -. -\end_layout - -\begin_layout Subsubsection* - -\family typewriter -HXMAP_SKEY -\family default - is unset, -\family typewriter -HXMAP_CKEY -\family default - is unset -\end_layout - -\begin_layout Standard -The -\family typewriter -key_size -\family default - parameter at the time of map construction is ignored. - The pointer value of the -\family typewriter -key -\family default - parameter for the -\family typewriter -HXmap_add -\family default - call is directly stored in the tree, and this is the key that uniquely - identifies the map entry and which is used for comparisons. - This may be used if you intend to directly map pointer values. -\end_layout - -\begin_layout LyX-Code -static struct something *x = ..., *y = ...; -\begin_inset Newline newline -\end_inset - -HXmap_add(map, &x[0], "foo"); -\begin_inset Newline newline -\end_inset - -HXmap_add(map, &x[1], "bar"); -\end_layout - -\begin_layout Subsubsection* - -\family typewriter -HXMAP_SKEY -\family default - is set, -\family typewriter -HXMAP_CKEY -\family default - is unset -\end_layout - -\begin_layout Standard -The -\family typewriter -key_size -\family default - parameter at the time of map construction is ignored. - The pointer value of the -\family typewriter -key -\family default - parameter for the -\family typewriter -HXmap_add -\family default - call is directly stored in the tree, but it is the C string -\shape italic -pointed to -\shape default - by the -\family typewriter -key -\family default - parameter that serves as the key. -\end_layout - -\begin_layout Subsubsection* - -\family typewriter -HXMAP_SKEY -\family default - is set, -\family typewriter -HXMAP_CKEY -\family default - is set -\end_layout - -\begin_layout Standard -The -\family typewriter -key_size -\family default - parameter at the time of map construction is ignored. - The string pointed to by the key parameter will be duplicated, and the - resulting pointer will be stored in the tree. - Again, it is the pointed-to string that is the key. -\end_layout - -\begin_layout Subsubsection* - -\family typewriter -HXMAP_SKEY -\family default - is unset, -\family typewriter -HXMAP_CKEY -\family default - is set -\end_layout - -\begin_layout Standard -The memory block pointed to by the key parameter will be duplicated. - The -\family typewriter -key_size -\family default - parameter must be non-zero for this to successfully work. -\end_layout - -\begin_layout Subsubsection* -With separate ops -\end_layout - -\begin_layout Standard -However, when a custom -\family typewriter -struct HXmap_ops -\family default - is provided in the call to -\family typewriter -HXmap_init5 -\family default -, any of these semantics can be overridden. - Particularly, since your own ops can practically ignore -\family typewriter -key_size -\family default -, it could be set to any value. -\end_layout - -\begin_layout Subsection -Key-data operations -\end_layout - -\begin_layout Standard -The -\family typewriter -HXMAP_SKEY -\family default -\SpecialChar breakableslash - -\family typewriter -CKEY -\family default -\SpecialChar breakableslash - -\family typewriter -SDATA -\family default -\SpecialChar breakableslash - -\family typewriter -CDATA -\family default - flags are generally sufficient to set up common maps where keys and/or - data are C strings or simple binary data where -\family typewriter -memdup -\family default -/ -\family typewriter -memcmp -\family default - is enough. - Where the provided mechanisms are not cutting it, an extra -\family typewriter -HXmap_ops -\family default - structure with functions specialized in handling the keys and/or data has - to be used as an argument to the initialization function call. -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXmap_ops { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXmap_ops -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int (* -\series default -k_compare -\series bold -) -\series default -( -\series bold -const void * -\series default -, -\series bold -const void * -\series default -, -\series bold -size_t -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -void *(* -\series default -k_clone -\series bold -) -\series default -( -\series bold -const void * -\series default -, -\series bold -size_t -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -void (* -\series default -k_free -\series bold -) -\series default -( -\series bold -void * -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -void *(* -\series default -d_clone -\series bold -) -\series default -( -\series bold -const void * -\series default -, -\series bold -size_t -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -void (* -\series default -d_free -\series bold -) -\series default -( -\series bold -void * -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned long (* -\series default -k_hash -\series bold -) -\series default -( -\series bold -const void * -\series default -, -\series bold -size_t -\series default -); -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Description - -\family typewriter -k_compare -\family default - Function to compare two keys. - The return value is the same as that of -\family typewriter -memcmp -\family default - or -\family typewriter -strcmp -\family default -: negative values indicate that the first key is -\begin_inset Quotes eld -\end_inset - -less than -\begin_inset Quotes erd -\end_inset - - the second, zero indicates that both keys are equal, and positive values - indicate that the first key is -\begin_inset Quotes eld -\end_inset - -greater than -\begin_inset Quotes erd -\end_inset - - the second. - The size argument in third position is provided so that -\family typewriter -memcmp -\family default -, which wants a size parameter, can directly be used without having to write - an own function. -\end_layout - -\begin_layout Description - -\family typewriter -k_clone -\family default - Function that will clone (duplicate) a key. - This is used for keys that will be added to the tree, and potentially also - for state-keeping during traversal of the map. - It is valid that this clone function simply returns the value of the pointer - it was actually passed; this is used by default for maps without -\family typewriter -HXMAP_CKEY -\family default - for example. -\end_layout - -\begin_layout Description - -\family typewriter -k_free -\family default - Function to free a key. - In most cases it defaults to -\family typewriter -free -\family default -(3), but in case you are using complex structs, more cleanup may be needed. -\end_layout - -\begin_layout Description - -\family typewriter -d_clone -\family default - Same as -\family typewriter -k_clone -\family default -, but for data. -\end_layout - -\begin_layout Description - -\family typewriter -d_free -\family default - Same as -\family typewriter -k_free -\family default -, but for data. -\end_layout - -\begin_layout Description - -\family typewriter -k_hash -\family default - Specifies an alternate hash function. - Only to be used with hash-based maps. - Hashmaps default to using the DJB2 string hash function when -\family typewriter -HXMAP_SKEY -\family default - is given, or otherwise the Jenkins' lookup3 hash function. -\end_layout - -\begin_layout Standard -libHX exports two hash functions that you can select for -\family typewriter -struct HXmap_ops -\family default -'s -\family typewriter -k_hash -\family default - if the default for a given flag combination is not to your liking. -\end_layout - -\begin_layout Description - -\family typewriter -HXhash_jlookup3 -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXhash_jlookup3 -\end_layout - -\end_inset - - Bob Jenkins's lookup3 hash. -\end_layout - -\begin_layout Description - -\family typewriter -HXhash_djb2 -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXhash_djb2 -\end_layout - -\end_inset - - DJB2 string hash. -\end_layout - -\begin_layout Subsection -Map operations -\end_layout - -\begin_layout LyX-Code - -\series bold -int -\series default - HXmap_add( -\series bold -struct -\series default - HXmap -\series bold -* -\series default -, -\series bold -const void * -\series default -key, -\series bold -const void * -\series default -value); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_add -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - HXmap_node -\series bold -* -\series default -HXmap_find( -\series bold -const struct -\series default - HXmap -\series bold -* -\series default -, -\series bold -const void * -\series default -key); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_find -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HXmap_get( -\series bold -const struct -\series default - HXmap -\series bold -* -\series default -, -\series bold -const void * -\series default -key); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_get -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HXmap_del( -\series bold -struct -\series default - HXmap -\series bold -* -\series default -, -\series bold -const void * -\series default -key); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_del -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXmap_free( -\series bold -struct -\series default - HXmap -\series bold -* -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_free -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXmap_node -\series bold -* -\series default -HXmap_keysvalues( -\series bold -const struct -\series default - HXmap -\series bold -* -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_keysvalues -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_add -\family default - -\family typewriter -A -\family default -dds a new node to the tree using the given key and data. - When an element is in the map, the key may not be modified, as doing so - could possibly invalidate the internal location of the element, or its - ordering with respect to other elements. - If you need to change the key, you will have to delete the element from - the tree and re-insert it. - On error, -\family typewriter --errno -\family default - will be returned. -\begin_inset Newline newline -\end_inset - -When -\family typewriter -HXMAP_SINGULAR -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_SINGULAR -\end_layout - -\end_inset - - is in effect, -\family typewriter -value -\family default - must be -\family typewriter -NULL -\family default -, or -\family typewriter --EINVAL -\family default - is returned. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_find -\family default - Finds the node for the given key. - The key can be read from the node using -\family typewriter -node->key -\family default - or -\family typewriter -node->skey -\family default - (convenience alias for -\family typewriter -key -\family default -, but with a type of -\family typewriter -const char -\begin_inset space ~ -\end_inset - -* -\family default -), and the data by using -\family typewriter -node->data -\family default - or -\family typewriter -node->sdata -\family default -. - (see section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:maps-def" - -\end_inset - -). -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_get -\family default - Get is a find operation directly returning -\family typewriter -node->data -\family default - instead of the node itself. - Since -\family typewriter -HXmap_get -\family default - may legitimately return -\family typewriter -NULL -\family default - if -\family typewriter -NULL -\family default - was stored in the tree as the data for a given key, only -\family typewriter -errno -\family default - will really tell whether the node was found or not; in the latter case, - -\family typewriter -errno -\family default - is set to -\family typewriter -ENOENT -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_del -\family default - Removes an element from the map and returns the data value that was associated - with it. - When an error occurred, or the element was not found, -\family typewriter -NULL -\family default - is returned. - Because -\family typewriter -NULL -\family default - can be a valid data value, -\family typewriter -errno -\family default - can be checked for non-zero. - -\family typewriter -errno -\family default - will be -\family typewriter --ENOENT -\family default - if the element was not found, or zero when everything was ok. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_free -\family default - The function will delete all elements in the map and free memory it holds. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_keysvalues -\family default - Returns all key-value-pairs in an array of the size as many items were - in the map ( -\family typewriter -map->items -\family default -) at the time it was called. - The memory must be freed using -\family typewriter -free -\family default -(3) when it is no longer needed. - The order elements in the array follows the traverser notes (see below), - unless otherwise specified. -\end_layout - -\begin_layout Subsection -Map traversal -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXmap_trav -\series bold -* -\series default -HXmap_travinit( -\series bold -const struct -\series default - HXmap -\series bold -* -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - HXmap_node -\series bold -* -\series default -HXmap_traverse( -\series bold -struct -\series default - HXmap_trav -\series bold -* -\series default -iterator); -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXmap_travfree( -\series bold -struct -\series default - HXmap_trav -\series bold -* -\series default -iterator); -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXmap_qfe( -\series bold -const struct -\series default - HXmap -\series bold -* -\series default -, -\series bold -bool (* -\series default -fn -\series bold -) -\series default -( -\series bold -const struct -\series default - HXmap_node -\series bold -* -\series default -, -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -arg), -\series bold -void * -\series default -arg); -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_travinit -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_travinit -\end_layout - -\end_inset - - Initializes a traverser (a. -\begin_inset space \thinspace{} -\end_inset - -k. -\begin_inset space \thinspace{} -\end_inset - -a. -\begin_inset space \space{} -\end_inset - -iterator) for the map, and returns a pointer to it. - -\family typewriter -NULL -\family default - will be returned in case of an error, such as memory allocation failure. - Traversers are returned even if the map has zero elements. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_traverse -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_traverse -\end_layout - -\end_inset - - Returns a pointer to a -\family typewriter -struct HXmap_node -\family default - for the next element -\begin_inset space ~ -\end_inset - -\SpecialChar breakableslash - key-value pair from the map, or -\family typewriter -NULL -\family default - if there are no more entries. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_travfree -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_travfree -\end_layout - -\end_inset - - Release the memory associated with a traverser. -\end_layout - -\begin_layout Description - -\family typewriter -HXmap_qfe -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmap_qfe -\end_layout - -\end_inset - - The -\begin_inset Quotes eld -\end_inset - -quick foreach -\begin_inset Quotes erd -\end_inset - -. - Iterates over all map elements in the fastest possible manner, but has - the restriction that no modifications to the map are allowed. - Furthermore, a separate function to handle each visited node, is required. - (Hence this is also called -\begin_inset Quotes eld -\end_inset - -closed traversal -\begin_inset Quotes erd -\end_inset - -, because one cannot access the stack frame of the original function which - called -\family typewriter -HXmap_qfe -\family default -.) The user-defined function returns a bool which indicates whether traversal - shall continue or not. -\end_layout - -\begin_layout Standard -Flags for -\family typewriter -HXmap_travinit -\family default -: -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_NOFLAGS -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_NOFLAGS -\end_layout - -\end_inset - - A mnemonic for no flags, and is defined to be -\family typewriter -0 -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXMAP_DTRAV -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXMAP_DTRAV -\end_layout - -\end_inset - - Enable support for deletion during traversal. - As it can make traversal slower, it needs to be explicitly specified for - cases where it is needed, to not penalize cases where it is not. -\end_layout - -\begin_layout Standard -WARNING: Modifying the map while a traverser is active is implementation-specifi -c behavior! libHX generally ensures that there will be no undefined behavior - (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - -crashes), but there is no guarantee that elements will be returned exactly - once. - There are fundamental cases that one should be aware of: -\end_layout - -\begin_layout Itemize -An element is inserted before where the traverser is currently positioned - at. - The element may not be returned in subsequent calls to -\family typewriter -HXmap_traverse -\family default - on an already-active traverser. -\end_layout - -\begin_layout Itemize -Insertion or deletion may cause internal data structure to re-layout. -\begin_inset Separator latexpar -\end_inset - - -\end_layout - -\begin_deeper -\begin_layout Itemize -Traversers of ordered data structures may choose to rebuild their state. -\end_layout - -\begin_layout Itemize -Traversers of unordered data structures would run risk to return more than - once, or not at all. -\end_layout - -\end_deeper -\begin_layout Standard -Descriptions for different map types follow. -\end_layout - -\begin_layout Description -Hashmaps On -\family typewriter -HXmap_add -\family default -, an element may be inserted in a position that is before where the traverser - is currently positioned. - Such elements will not be returned in the remaining calls to -\family typewriter -HXmap_traverse -\family default -. - The insertion or deletion of an element may cause the internal data structure - to re-layout itself. - When this happens, the traverser will stop, so as to not return entries - twice. -\end_layout - -\begin_layout Description -Binary -\begin_inset space ~ -\end_inset - -trees Elements may be added before the traverser's position. - These elements will not be returned in subsequent traversion calls. - If the data structure changes as a result of an addition or deletion, the - traverser will rebuild its state and continue traversal transparently. - Because elements in a binary tree are ordered, that is, element positions - may not change with respect to another when the tree is rebalanced, there - is no risk of returning entries more than once. - Nor will elements that are sorted after the current traverser's position - not be returned (= -\begin_inset space ~ -\end_inset - -they will be returned, because they cannot get reordered to before the traverser - like in a hash map). - The HX rbtree implementation also has proper handling for when the node - which is currently visiting is deleted. -\end_layout - -\begin_layout Subsection -RB-tree Limitations -\end_layout - -\begin_layout Standard -The implementation has a theoretical minimum on the maximum number of nodes, - -\begin_inset Formula $2^{24}=16{,}777{,}216$ -\end_inset - -. - A worst-case tree with this many elements already has a height of 48 ( -\family typewriter -RBT_MAXDEP -\family default -), which is the maximum height currently supported. - The larger the height is that HXrbtree is supposed to handle, the more - memory (linear increase) it needs. - All functions that build or keep a path reserve memory for -\family typewriter -RBT_MAXDEP -\family default - nodes; on x86_64 this is 9 bytes per -\begin_inset Formula $\langle$ -\end_inset - -node, direction -\begin_inset Formula $\rangle$ -\end_inset - - pair, amounting to 432 bytes for path tracking alone. - It may not sound like a lot to many, but given that kernel people can limit - their stack usage to 4096 bytes is impressive alone -\end_layout - -\begin_layout Standard -\begin_inset Foot -status open - -\begin_layout Plain Layout -Not always of course. - Linux kernels are often configured to use an 8K stack because some components - still use a lot of stack space, but even 8K is still damn good. -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Subsection -Examples -\end_layout - -\begin_layout Subsubsection -Case-insensitive ordering -\end_layout - -\begin_layout Standard -The correct way: -\end_layout - -\begin_layout LyX-Code - -\series bold -static int -\series default - my_strcasecmp( -\series bold -const void * -\series default -a, -\series bold -const void * -\series default -b, -\series bold -size_t -\series default - z) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - strcasecmp(a, b); -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static const struct -\series default - HXmap_ops icase = { -\begin_inset Newline newline -\end_inset - - .k_compare = my_strcasecmp, -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - -HXmap_init5(HXMAPT_RBTREE, HXMAP_SKEY, &icase, 0, -\shape italic -dsize -\shape default -); -\end_layout - -\begin_layout Standard -A hackish way (which wholly depends on the C implementation and use of extra - safeguards is a must): -\end_layout - -\begin_layout LyX-Code - -\series bold -static const struct -\series default - HXmap_ops icase = { -\begin_inset Newline newline -\end_inset - - .k_compare = ( -\series bold -void * -\series default -)strcasecmp, -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - -BUILD_BUG_ON( -\series bold -sizeof -\series default -(DEMOTE_TO_PTR(strcasecmp)) > -\series bold -sizeof -\series default -(void *)); -\begin_inset Newline newline -\end_inset - -BUILD_BUG_ON( -\series bold -sizeof -\series default -(DEMOTE_TO_PTR(strcasecmp)) > -\series bold -sizeof -\series default -(icase.k_compare)); -\begin_inset Newline newline -\end_inset - -HXmap_init5(HXMAPT_RBTREE, HXMAP_SKEY, &icase, 0, -\shape italic -dsize -\shape default -); -\end_layout - -\begin_layout Subsubsection -Reverse sorting order -\end_layout - -\begin_layout Standard -Any function that behaves like -\family typewriter -strcmp -\family default - can be used. - It merely has to return negative when -\begin_inset Formula $a<b$ -\end_inset - -, zero on -\begin_inset Formula $a=b$ -\end_inset - -, and positive non-zero when -\begin_inset Formula $a>b$ -\end_inset - -. -\end_layout - -\begin_layout LyX-Code - -\series bold -static int -\series default - strcmp_rev( -\series bold -const void * -\series default -a, -\series bold -const void * -\series default -b, -\series bold -size_t -\series default - z) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -z is provided for cases when things are raw memory blocks. - -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - strcmp(b, a); -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static const struct -\series default - HXmap_ops rev = { -\begin_inset Newline newline -\end_inset - - .k_compare = strcmp_rev, -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - -HXmap_init5(HXMAPT_RBTREE, HXMAP_SKEY, &rev, 0, -\shape italic -dsize -\shape default -); -\end_layout - -\begin_layout Subsubsection -Keys with non-unique data -\begin_inset CommandInset label -LatexCommand label -name "subsec:maps-examples-bigkey" - -\end_inset - - -\end_layout - -\begin_layout Standard -Keys can actually store non-unique data, as long as this extra fields does - not actually contribute to the logical key -\begin_inset space ~ -\end_inset - -— the parts that do uniquely identify it. - In the following example, the -\family typewriter -notes -\family default - member may be part of struct package, which is the key as far as HXmap - is concerned, but still, only the name and versions are used to identify - it. -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - package { -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -name; -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - major_version; -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - minor_version; -\begin_inset Newline newline -\end_inset - - -\series bold -char -\series default - notes -\series bold -[ -\series default -64 -\series bold -] -\series default -; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static int -\series default - package_cmp( -\series bold -const void * -\series default -a, -\series bold -const void * -\series default -b) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - package -\series bold -* -\series default -p = a, -\series bold -* -\series default -q = b; -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - ret; -\begin_inset Newline newline -\end_inset - - ret = strcmp(p->name, q->name); -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (ret != 0) -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - ret; -\begin_inset Newline newline -\end_inset - - ret = p->major_version - q->major_version; -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (ret != 0) -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - ret; -\begin_inset Newline newline -\end_inset - - ret = p->minor_version - q->minor_version; -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (ret != 0) -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - ret; -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - 0; -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static const struct -\series default - HXmap_ops package_ops = { -\begin_inset Newline newline -\end_inset - - .k_compare = package_cmp, -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXmap_init5(HXMAPT_RBTREE, -\shape italic -flags -\shape default -, &package_ops, -\begin_inset Newline newline -\end_inset - - -\series bold -sizeof -\series default -( -\series bold -struct -\series default - package), -\shape italic -dsize -\shape default -); -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Doubly-linked list -\begin_inset CommandInset label -LatexCommand label -name "sec:deque" - -\end_inset - - -\end_layout - -\begin_layout Standard -HXdeque is a data structure for a doubly-linked non-circular -\family typewriter -NULL -\family default --sentineled list. - Despite being named a deque, which is short for double-ended queue, and - which may be implemented using an array, HXdeque is in fact using a linked - list to provide its deque functionality. - Furthermore, a dedicated root structure and decidated node structures with - indirect data referencing are used. -\end_layout - -\begin_layout Subsection -Structural definition -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/deque.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/deque.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXdeque -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -first, -\series bold -* -\series default -last; -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - items; -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -ptr; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque_node { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXdeque_node -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -next, -\series bold -* -\series default -prev; -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -parent; -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -ptr; -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Standard -The -\family typewriter -ptr -\family default - member in -\family typewriter -struct HXdeque -\family default - provides room for an arbitrary custom user-supplied pointer. - -\family typewriter -items -\family default - will reflect the number of elements in the list, and must not be modified. - -\family typewriter -first -\family default - and -\family typewriter -last -\family default - provide entrypoints to the list's ends. -\end_layout - -\begin_layout Standard - -\family typewriter -ptr -\family default - within -\family typewriter -struct HXdeque_node -\family default - is the pointer to the user's data. - It may be modified and used at will by the user. - See example section -\begin_inset space ~ -\end_inset - -. -\end_layout - -\begin_layout Subsection -Constructor, destructors -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -HXdeque_init( -\series bold -void -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_init -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXdeque_free( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_free -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXdeque_genocide( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_genocide -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXdeque_genocide2( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq, -\series bold -void (* -\series default -xfree -\series bold -) -\series default -( -\series bold -void * -\series default -)); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_genocide2 -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void ** -\series default -HXdeque_to_vec( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq, -\series bold -unsigned int * -\series default -num); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_to_vec -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -To allocate a new empty list, use -\family typewriter -HXdeque_init -\family default -. - -\family typewriter -HXdeque_free -\family default - will free the list (including all nodes owned by the list), but not the - data pointers. -\end_layout - -\begin_layout Standard - -\family typewriter -HXdeque_genocide -\family default - is a variant that will not only destroy the list, but also calls a freeing - function -\family typewriter -free() -\family default - on all stored data pointers. - This puts a number of restrictions on the characteristics of the list: - all data pointers must have been obtained with -\family typewriter -malloc -\family default -, -\family typewriter -calloc -\family default - or -\family typewriter -realloc -\family default - before, and no data pointer must exist twice in the list. - The function is more efficient than an open-coded loop over all nodes calling - -\family typewriter -HXdeque_del -\family default -. -\end_layout - -\begin_layout Standard -A generic variant is available with -\family typewriter -HXdeque_genocide2 -\family default -, which takes a pointer to an appropriate freeing function. - -\family typewriter -HXdeque_genocide -\family default - is thus equivalent to -\family typewriter -HXdeque_genocide2(dq, free) -\family default -. -\end_layout - -\begin_layout Standard -To convert a linked list to a -\family typewriter -NULL -\family default --terminated array, -\family typewriter -HXdeque_to_vec -\family default - can be used. - If -\family typewriter -num -\family default - is not -\family typewriter -NULL -\family default -, the number of elements excluding the -\family typewriter -NULL -\family default - sentinel, is stored in -\family typewriter -*num -\family default -. -\end_layout - -\begin_layout Subsection -Addition and removal -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -HXdeque_push( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq, -\series bold -void * -\series default -ptr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_push -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -HXdeque_unshift( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq, -\series bold -void * -\series default -ptr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_unshift -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HXdeque_pop( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_pop -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HXdeque_shift( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_shift -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -HXdeque_move( -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -target, -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -node); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_move -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HXdeque_del( -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -node); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_del -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HXdeque_\SpecialChar softhyphen -push -\family default - and -\family typewriter -HXdeque_\SpecialChar softhyphen -unshift -\family default - add the data item in a new node at the end ( -\begin_inset Quotes eld -\end_inset - -push -\begin_inset Quotes erd -\end_inset - -) or as the new first element ( -\begin_inset Quotes eld -\end_inset - -unshift -\begin_inset Quotes erd -\end_inset - - as Perl calls it), respectively. - The functions will return the new node on success, or -\family typewriter -NULL -\family default - on failure and -\family typewriter -errno -\family default - will be set. - The node is owned by the list. -\end_layout - -\begin_layout Standard - -\family typewriter -HXdeque_\SpecialChar softhyphen -pop -\family default - and -\family typewriter -HXdeque_\SpecialChar softhyphen -shift -\family default - remove the last ( -\begin_inset Quotes eld -\end_inset - -pop -\begin_inset Quotes erd -\end_inset - -) or first ( -\begin_inset Quotes eld -\end_inset - -shift -\begin_inset Quotes erd -\end_inset - -) node, respectively, and return the data pointer that was stored in the - data. -\end_layout - -\begin_layout Standard - -\family typewriter -HXdeque_\SpecialChar softhyphen -move -\family default - will unlink a node from its list, and reinsert it after the given target - node, which may be in a different list. -\end_layout - -\begin_layout Standard -Deleting a node is accomplished by calling -\family typewriter -HXdeque_del -\family default - on it. - The data pointer stored in the node is not freed, but returned. -\end_layout - -\begin_layout Subsection -Iteration -\end_layout - -\begin_layout Standard -Iterating over a HXdeque linked list is done manually and without additional - overhead of function calls: -\end_layout - -\begin_layout LyX-Code - -\series bold -const struct -\series default - HXdeque_node -\series bold -* -\series default -node; -\begin_inset Newline newline -\end_inset - - -\series bold -for -\series default - (node = dq->first; node != NULL; node = node->next) -\begin_inset Newline newline -\end_inset - - do_something(node->ptr); -\end_layout - -\begin_layout Subsection -Searching -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXdeque_node -\series bold -* -\series default -HXdeque_find( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq, -\series bold -const void * -\series default -ptr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_find -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HXdeque_get( -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq, -\series bold -void * -\series default -ptr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXdeque_get -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HXdeque_find -\family default - searches for the node which contains -\family typewriter -ptr -\family default -, and does so by beginning at the start of the list. - If no node is found, -\family typewriter -NULL -\family default - is returned. - If a pointer is more than once in the list, any node may be returned. -\end_layout - -\begin_layout Standard - -\family typewriter -HXdeque_get -\family default - will further return the data pointer stored in the node -\begin_inset space ~ -\end_inset - -— however, since that is just what the -\family typewriter -ptr -\family default - argument is, the function practically only checks for existence of -\family typewriter -ptr -\family default - in the list. -\end_layout - -\begin_layout Subsection -Examples -\end_layout - -\begin_layout Standard - -\series bold -\begin_inset Float figure -placement h -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <stdlib.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <string.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/defs.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/deque.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <pwd.h> -\begin_inset Newline newline -\end_inset - - -\series bold - -\begin_inset Newline newline -\end_inset - -int -\series default - main( -\series bold -void -\series default -) -\begin_inset Newline newline -\end_inset - -{ -\series bold - -\begin_inset Newline newline -\end_inset - - -\series default - -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq = HXdeque_init(); -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - passwd *pw; -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -unsigned int -\series default - elem; -\begin_inset Newline newline -\end_inset - - -\series bold -char ** -\series default -users; -\family default - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - setpwent(); -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - ((pw = getpwent()) != NULL) -\begin_inset Newline newline -\end_inset - - HXdeque_push(dq, HX_strdup(pw->pw_name)); -\begin_inset Newline newline -\end_inset - - endpwent(); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - users = -\series bold -reinterpret_cast -\series default -( -\series bold -char ** -\series default -, HXdeque_to_vec(dq, &elem)); -\begin_inset Newline newline -\end_inset - - HXdeque_free(dq); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - qsort(users, elem, -\series bold -sizeof -\series default -(*users), -\series bold -static_cast -\series default -( -\series bold -void * -\series default -, strcmp)); -\begin_inset Newline newline -\end_inset - - return 0; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Example use of HXdeque to store and sort a list -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -In this example, all usernames are obtained from NSS, and put into a list. - -\family typewriter -HX_strdup -\family default - is used, because -\family typewriter -getpwent -\family default - will overwrite the buffer it uses to store its results. - The list is then converted to an array, and the list is freed (because - it is not need it anymore). - -\family typewriter -HXdeque_genocide -\family default - must not be used here, because it would free all the data pointers (strings - here) that were just inserted into the list. - Finally, the list is sorted using the well-known -\family typewriter -qsort -\family default - function. - Because -\family typewriter -strcmp -\family default - takes two -\family typewriter -const char -\begin_inset space ~ -\end_inset - -* -\family default - arguments, but -\family typewriter -qsort -\family default - mandates a function taking two -\family typewriter -const void -\begin_inset space ~ -\end_inset - -* -\family default -, a cast can be used to silence the compiler. - This only works because we know that the array consists of a bunch of -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default - pointers, so -\family typewriter -strcmp -\family default - will work. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Inline doubly-linked list -\begin_inset CommandInset label -LatexCommand label -name "sec:list" - -\end_inset - - -\end_layout - -\begin_layout Standard -Classical linked-list implementations, such as HXdeque, either store the - actual data within a node, or indirectly through a pointer, but the -\begin_inset Quotes eld -\end_inset - -inline doubly-linked list -\begin_inset Quotes erd -\end_inset - - instead does it reverse and has the list head within the data structure. -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement h -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -struct -\series default - package_desc { -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -package_name; -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - version; -\end_layout - -\begin_layout LyX-Code -}; -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - classic_direct_node { -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - classic_direct_node -\series bold -* -\series default -next, -\series bold -* -\series default -prev; -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - package_desc direct_data; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - classic_indirect_node { -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - classic_indirect_node -\series bold -* -\series default -next, -\series bold -* -\series default -prev; -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -indirect_data; -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Classic linked-list implementations with direct/indirect data blocks. -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -struct -\series default - package_desc { -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXlist_head list; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -package_name; -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - version; -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -List head (next,prev pointers) inlined into the data block -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -At first glance, an inline list does not look much different from -\family typewriter -struct classic_\SpecialChar softhyphen -direct_\SpecialChar softhyphen -data -\family default -, it is mostly a viewpoint decision which struct is in the foreground. -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/list.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/list.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXlist_head { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXlist_head -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -All fields considered private -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXLIST_HEAD_INIT(name); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXLIST_HEAD_INIT -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXLIST_HEAD(name); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXLIST_HEAD -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXlist_init( -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -list); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_init -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXlist_add( -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -list, -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -elem); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_add -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXlist_add_tail( -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -list, -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -elem); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_add_tail -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXlist_del( -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -element); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_del -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HXlist_empty( -\series bold -const struct -\series default - HXlist_head -\series bold -* -\series default -list); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_empty -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXLIST_HEAD_INIT -\family default - This macro expands to the static initializer for a list head. -\end_layout - -\begin_layout Description - -\family typewriter -HXLIST_HEAD -\family default - This macro expands to the definition of a list head (i. -\begin_inset space \thinspace{} -\end_inset - -e. -\begin_inset space \space{} -\end_inset - - -\family typewriter -struct HXlist_head name = HXLIST_HEAD_INIT; -\family default -) -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_init -\family default - Initializes the list head. - This function is generally used when the list head is on the heap where - the static initializer cannot be used. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_add -\family default - Adds -\family typewriter -elem -\family default - to the front of the list. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_add_tail -\family default - Adds -\family typewriter -elem -\family default - to the end of the list. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_del -\family default - Deletes the given element from the list. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_empty -\family default - Tests whether the list is empty. - Note: For clists, you could also use -\family typewriter -clist->items == 0 -\family default -. -\end_layout - -\begin_layout Subsection -Traversal -\end_layout - -\begin_layout Standard -Traversal is implemented using macros that expand to for() statements which - can syntactically be used like them, i. -\begin_inset space \thinspace{} -\end_inset - -e. -\begin_inset space \space{} -\end_inset - -curly braces may be omitted if only a single statement is in the body of - the loop. -\end_layout - -\begin_layout Standard -The -\family typewriter -head -\family default - parameter specifies the list head ( -\family typewriter -struct HXlist_head -\family default -), -\family typewriter -pos -\family default - specifies an iterator, also of type -\family typewriter -struct HXlist_head -\family default -. - Lists can either be traversed in forward direction, or, using the -\family typewriter -_rev -\family default - variants, in reverse direction. - The -\family typewriter -_safe -\family default - variants use a temporary -\family typewriter -n -\family default - to hold the next object in the list, which is needed when pos itself is - going to be inaccessible at the end of the block, through, for example, - freeing its encompassing object. -\end_layout - -\begin_layout LyX-Code -HXlist_for_each(pos, head) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_rev(pos, head) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each_rev -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_safe(pos, n, head) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each_safe -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_rev_safe(pos, n, head) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each_rev_safe -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each -\family default - Forward iteration over the list heads. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each_rev -\family default - Reverse iteration over the list heads. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each_safe -\family default - Forward iteration over the list heads that is safe against freeing -\family typewriter -pos -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each_rev_safe -\family default - Reverse iteration over the list heads that is safe against freeing -\family typewriter -pos -\family default -. -\end_layout - -\begin_layout Standard -The -\family typewriter -_entry -\family default - variants use an iterator -\family typewriter -pos -\family default - of the type of the encompassing object (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -struct item -\family default - in below's example), so that the manual -\family typewriter -HXlist_entry -\family default - invocation is not needed. - -\family typewriter -member -\family default - is the name of the list structure embedded into the item. -\end_layout - -\begin_layout LyX-Code -HXlist_for_each_entry(pos, head, member) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each_entry -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_entry_rev(pos, head, member) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each_entry_rev -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_entry_safe(pos, n, head, member) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXlist_for_each_entry_safe -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each_entry -\family default - Forward iteration over the list elements. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each_entry_rev -\family default - Reverse iteration over the list elements. -\end_layout - -\begin_layout Description - -\family typewriter -HXlist_for_each_entry_safe -\family default - Forward iteration over the list elements that is safe against freeing -\family typewriter -pos -\family default -. -\end_layout - -\begin_layout Subsection -Examples -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - item { -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXlist_head anchor; -\begin_inset Newline newline -\end_inset - - -\series bold -char -\series default - name -\series bold -[ -\series default -32 -\series bold -] -\series default -; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -e; -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - item -\series bold -* -\series default -i, -\series bold -* -\series default -j; -\begin_inset Newline newline -\end_inset - -HXLIST_HEAD(list); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -i = malloc( -\series bold -sizeof -\series default -( -\series bold -* -\series default -i)); -\begin_inset Newline newline -\end_inset - -HXlist_init(&e->anchor); -\begin_inset Newline newline -\end_inset - -strcpy(i->name, "foo"); -\begin_inset Newline newline -\end_inset - -HXlist_add_tail(&list, &i->anchor); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -i = malloc( -\series bold -sizeof -\series default -( -\series bold -* -\series default -i)); -\begin_inset Newline newline -\end_inset - -HXlist_init(&e->anchor); -\begin_inset Newline newline -\end_inset - -strcpy(i->name, "bar"); -\begin_inset Newline newline -\end_inset - -HXlist_add_tail(&list, &i->anchor); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each(e, &list) { -\begin_inset Newline newline -\end_inset - - i = HXlist_entry(e, -\series bold -typeof -\series default -( -\series bold -* -\series default -i), anchor); -\begin_inset Newline newline -\end_inset - - printf("e=%p i=%p name=%s -\backslash -n", e, i, i->name); -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_entry(i, &list, anchor) -\begin_inset Newline newline -\end_inset - - printf("i=%p name=%s -\backslash -n", i, i->name); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_entry_rev(i, &list, anchor) -\begin_inset Newline newline -\end_inset - - printf("i=%p name=%s -\backslash -n", i, i->name); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXlist_for_each_entry_safe(i, j, &list, anchor) { -\begin_inset Newline newline -\end_inset - - printf("i=%p name=%s -\backslash -n", i, i->name); -\begin_inset Newline newline -\end_inset - - free(i); -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Subsection -When to use HXdeque/HXlist -\end_layout - -\begin_layout Standard -The choice whether to use HXdeque or HXlist/HXclist depends on whether one - wants the list head handling on the developer or on the library. - Especially for -\begin_inset Quotes eld -\end_inset - -atomic -\begin_inset Quotes erd -\end_inset - - and -\begin_inset Quotes eld -\end_inset - -small -\begin_inset Quotes erd -\end_inset - - data, it might be easier to just let HXdeque do the management. - Compare the following two code examples to store strings: -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -int -\series default - main( -\family typewriter -\series bold -int -\series default - argc, -\series bold -const char ** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdeque -\series bold -* -\series default -dq = HXdeque_init(); -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - (--argc) -\begin_inset Newline newline -\end_inset - - HXdeque_push(dq, ++argv); -\begin_inset Newline newline -\end_inset - - -\family default -\series bold -return -\family typewriter -\series default - 0; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Storing strings in a HXdeque -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -struct -\series default - element { -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXlist_head list; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\family typewriter -\series default -data; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - main( -\series bold -int -\series default - main, -\series bold -const char ** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - HXLIST_HEAD(lh); -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - (--argc) { -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - element -\series bold -* -\series default -e = malloc( -\family default -\series bold -sizeof -\family typewriter -\series default -(*e)); -\begin_inset Newline newline -\end_inset - - e->data = *++argv; -\begin_inset Newline newline -\end_inset - - HXlist_init(&e->list); -\begin_inset Newline newline -\end_inset - - HXlist_add_tail(&e->list); -\begin_inset Newline newline -\end_inset - - } -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - 0; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Storing strings in a HXlist -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -These examples assume that -\family typewriter -argv -\family default - is persistent, which, for the sample, is true. -\end_layout - -\begin_layout Standard -With HXlist, one needs to have a struct with a HXlist_head in it, and if - one does not already have such a struct -\begin_inset space ~ -\end_inset - -—e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - -by means of wanting to store more than just one value -\begin_inset space ~ -\end_inset - -— one will need to create it first, as shown, and this may lead to an expansion - of code. -\end_layout - -\begin_layout Standard -This however does not mean that HXlist is the better solution over HXdeque - for data already available in a struct. - As each struct has a list_head that is unique to the node, it is not possible - to share this data. - Trying to add a HXlist_head to another list is not going to end well, while - HXdeque has no problem with this as list heads are detached from the actual - data in HXdeque. -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -struct -\series default - point p = {15, 30}; -\begin_inset Newline newline -\end_inset - -HXdeque_push(dq, &p); -\begin_inset Newline newline -\end_inset - -HXdeque_push(dq, &p); -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Data can be added multiple times in a HXdeque without ill effects -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -To support this, an extra allocation is needed on the other hand. - In a HXlist, to store -\begin_inset Formula $n$ -\end_inset - - elements of compound data (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -struct point -\family default -), -\begin_inset Formula $n$ -\end_inset - - allocations are needed, assuming the list head is a stack object, and the - points are not. - HXdeque will need at least -\begin_inset Formula $2n+1$ -\end_inset - - allocations, -\begin_inset Formula $n$ -\end_inset - - for the nodes, -\begin_inset Formula $n$ -\end_inset - - for the points and another for the head. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Counted inline doubly-linked list -\begin_inset CommandInset label -LatexCommand label -name "sec:clist" - -\end_inset - - -\end_layout - -\begin_layout Standard -clist is the inline doubly-linked list from chapter -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "sec:list" - -\end_inset - -, extended by a counter to retrieve the number of elements in the list in - -\begin_inset Formula $\mathcal{O}\left(1\right)$ -\end_inset - - time. - This is also why all operations always require the list head. - For traversal of clists, use the corresponding HXlist macros. -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/list.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/list.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXclist_head { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXclist_head -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -public readonly: -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - items; -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -Undocumented fields are considered -\begin_inset Quotes eld -\end_inset - -private -\begin_inset Quotes erd -\end_inset - - -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXCLIST_HEAD_INIT(name); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXCLIST_HEAD_INIT -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -HXCLIST_HEAD(name); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXCLIST_HEAD -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXclist_init( -\series bold -struct -\series default - HXclist_head -\series bold -* -\series default -head); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXclist_init -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXclist_unshift( -\series bold -struct -\series default - HXclist_head -\series bold -* -\series default -head, -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -new_node); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXclist_unshift -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXclist_push( -\series bold -struct -\series default - HXclist_head -\series bold -* -\series default -head, -\series bold -struct -\series default - HXlist_head -\series bold -* -\series default -new_node); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXclist_push -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -type -\series default - HXclist_pop( -\series bold -struct -\series default - HXclist_head -\series bold -* -\series default -head, -\series bold -type -\series default -, member); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXclist_pop -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -type -\series default - HXclist_shift( -\series bold -struct -\series default - HXclist_head -\series bold -* -\series default -head, -\series bold -type -\series default -, member); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXclist_shift -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXclist_del( -\series bold -struct -\series default - HXclist_head -\series bold -* -\series default -head, -\series bold -struct -\series default -HXlist_chead -\series bold -* -\series default -node); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXclist_del -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXCLIST_HEAD_INIT -\family default - Macro that expands to the static initializer for a clist. -\end_layout - -\begin_layout Description - -\family typewriter -HXCLIST_HEAD -\family default - Macro that expands to the definition of a clist head, with initialization. -\end_layout - -\begin_layout Description - -\family typewriter -HXclist_init -\family default - Initializes a clist. - This function is generally used when the head has been allocated from the - heap. -\end_layout - -\begin_layout Description - -\family typewriter -HXclist_unshift -\family default - Adds the node to the front of the list. -\end_layout - -\begin_layout Description - -\family typewriter -HXclist_push -\family default - Adds the node to the end of the list. -\end_layout - -\begin_layout Description - -\family typewriter -HXclist_pop -\family default - Removes the last node in the list and returns it. -\end_layout - -\begin_layout Description - -\family typewriter -HXclist_shift -\family default - Removes the first node in the list and returns it. -\end_layout - -\begin_layout Description - -\family typewriter -HXclist_del -\family default - Deletes the node from the list. -\end_layout - -\begin_layout Standard -The list count in the clist head is updated whenever a modification is done - on the clist through these functions. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Part -Strings and memory -\end_layout - -\begin_layout Section -String operations -\begin_inset CommandInset label -LatexCommand label -name "sec:strings" - -\end_inset - - -\end_layout - -\begin_layout Standard -Some string functions are merely present in libHX because they are otherwise - unportable; some are only in the C libraries of the BSDs, some only in - GNU libc. -\end_layout - -\begin_layout Subsection -Locating chars -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HX_memmem( -\series bold -const void * -\series default -haystack, -\series bold -size_t -\series default - hsize, -\begin_inset Newline newline -\end_inset - - -\series bold -const void * -\series default -needle, -\series bold -size_t -\series default - nsize); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_memmem -\end_layout - -\end_inset - - -\series bold - -\begin_inset Newline newline -\end_inset - -char * -\series default -HX_strbchr( -\series bold -const char * -\series default -start, -\series bold -const char * -\series default -now, -\series bold -char -\series default - delimiter); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_strbchr -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strchr2( -\series bold -const char * -\series default -s, -\series bold -const char * -\series default -accept); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_strchr2 -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -size_t -\series default - HX_strrcspn( -\series bold -const char * -\series default -s, -\series bold -const char * -\series default -reject); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_strccspn -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_memmem -\family default - Analogous to -\family typewriter -strstr -\family default -(3), -\family typewriter -memmem -\family default - tries to locate the memory block pointed to by -\family typewriter -needle -\family default - (which is of length -\family typewriter -nsize -\family default -) in the block pointed to by -\family typewriter -haystack -\family default - (which is of size -\family typewriter -hsize -\family default -). - It returns a pointer to the first occurrence in -\family typewriter -haystack -\family default -, or -\family typewriter -NULL -\family default - when it was not found. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strbchr -\family default - Searches the character specified by -\family typewriter -delimiter -\family default - in the range from -\family typewriter -now -\family default - to -\family typewriter -start -\family default -. - It works like -\family typewriter -strrchr -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -strrchr -\end_layout - -\end_inset - -, but begins at -\family typewriter -now -\family default - rather than the end of the string. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strchr2 -\family default - This function searches the string -\family typewriter -s -\family default - for any set of bytes that are not specified in the second argument, -\family typewriter -n -\family default -. - In this regard, the function is the opposite to -\family typewriter -strpbrk -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -strpbrk -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strrcspn -\family default - Works like -\family typewriter -strcspn -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -strcspn -\end_layout - -\end_inset - -, but processes the string from end to start. -\end_layout - -\begin_layout Subsection -Extraction -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_basename( -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_basename -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_basename_exact( -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_basename_exact -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_dirname( -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_dirname -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strmid( -\series bold -const char * -\series default -s, -\series bold -long -\series default - offset, -\series bold -long -\series default - length); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strmid -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_basename -\family default - Returns a pointer to the basename portion of the supplied path -\family typewriter -s -\family default -. - The result of this function is never -\family typewriter -NULL -\family default -, and must never be freed either. - Trailing slashes are not stripped, to avoid having to do an allocation. - In other words, -\family typewriter -basename("/mnt/") -\family default - will return -\begin_inset Quotes eld -\end_inset - - -\family typewriter -mnt/ -\family default - -\begin_inset Quotes erd -\end_inset - -. - If you need to have the slashes stripped, use -\family typewriter -HX_basename_exact -\family default -. - A possible use for this function is, for example, to derive a logging prefix - from -\family typewriter -argv[0] -\family default -. -\end_layout - -\begin_layout LyX-Code - -\series bold -int -\series default - main( -\series bold -int -\series default - argc, -\series bold -const char ** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (foo()) -\end_layout - -\begin_layout LyX-Code - fprintf(stderr, "%s: Special condition occurred. -\backslash -n", -\begin_inset Newline newline -\end_inset - - HX_basename(argv[0])); -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - 0; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Description - -\family typewriter -HX_basename_exact -\family default - The accurate and safe version of -\family typewriter -HX_basename -\family default - that deals with trailing slashes correctly and produces the same result - as -\family typewriter -dirname -\family default -(3). - It returns a pointer to a newly-allocated string that must be freed when - done using. - -\family typewriter -NULL -\family default - may be returned in case of an allocation error. -\end_layout - -\begin_layout Description - -\family typewriter -HX_dirname -\family default - Returns a pointer to a new string that contains the directory name portion - (everything except basename). - When done using the string, it must be freed to avoid memory leaks. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strmid -\family default - Extract a substring of -\family typewriter -length -\family default - characters from -\family typewriter -s -\family default -, beginning at -\family typewriter -offset -\family default -. - If -\family typewriter -offset -\family default - is negative, counting beings from the end of the string; -\begin_inset Formula $-1$ -\end_inset - - is the last character (not the -\family typewriter -' -\backslash -0' -\family default - byte). - If -\family typewriter -length -\family default - is negative, it will leave out that many characters off the end. - The function returns a pointer to a new string, and the user has to free - it. -\end_layout - -\begin_layout Subsection -In-place transformations -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_chomp( -\series bold -char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_chomp -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -size_t -\series default - HX_strltrim( -\series bold -char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strltrim -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_stpltrim( -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_stpltrim -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strlower( -\series bold -char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strlower -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strrev( -\series bold -char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strrev -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -size_t -\series default - HX_strrtrim( -\series bold -char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strrtrim -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strupper( -\series bold -char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strupper -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_chomp -\family default - Removes the characters -\family typewriter -' -\backslash -r' -\family default - and -\family typewriter -' -\backslash -n' -\family default - from the right edge of the string. - Returns the original argument. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strltrim -\family default - Trim all whitespace (characters on which -\family typewriter -isspace -\family default -(3) return true) on the left edge of the string. - Returns the number of characters that were stripped. -\end_layout - -\begin_layout Description - -\family typewriter -HX_stpltrim -\family default - Returns a pointer to the first non-whitespace character in -\family typewriter -s -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strlower -\family default - Transforms all characters in the string -\family typewriter -s -\family default - into lowercase using -\family typewriter -tolower -\family default -(3). - Returns the original argument. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strrev -\family default - Reverse the string in-place. - Returns the original argument. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strrtrim -\family default - Trim all whitespace on the right edge of the string. - Returns the number of characters that were stripped. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strupper -\family default - Transforms all characters in the string -\family typewriter -s -\family default - into uppercase using -\family typewriter -toupper -\family default -(3). - Returns the original argument. -\end_layout - -\begin_layout Subsection -Out-of-place quoting transforms -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strquote( -\series bold -const char * -\series default -s, -\series bold -unsigned int -\series default - type, -\series bold -char ** -\series default -free_me); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_strquote -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HX_strquote -\family default - will escape metacharacters in a string according to -\family typewriter -type -\family default -, and returns the escaped result. -\end_layout - -\begin_layout Standard -Possible values for -\family typewriter -type -\family default -: -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_SQUOTE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_SQUOTE -\end_layout - -\end_inset - - Escape all single quotes and backslashes in a string with a backslash. - ( -\begin_inset Quotes eld -\end_inset - -Ol' -\backslash -Backslash -\begin_inset Quotes erd -\end_inset - - -\begin_inset Formula $\rightarrow$ -\end_inset - - -\begin_inset Quotes eld -\end_inset - -Ol -\backslash -' -\backslash - -\backslash -Backslash -\begin_inset Quotes erd -\end_inset - -) -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_DQUOTE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_DQUOTE -\end_layout - -\end_inset - - Escape all double quotes and backslahes in a string with the backslash - method. - ( -\begin_inset Quotes eld -\end_inset - -Ol -\begin_inset Quotes erd -\end_inset - - -\backslash -Backslash -\begin_inset Quotes erd -\end_inset - - -\begin_inset Formula $\rightarrow$ -\end_inset - - -\begin_inset Quotes eld -\end_inset - -Ol -\backslash - -\begin_inset Quotes erd -\end_inset - - -\backslash - -\backslash -Backslash -\begin_inset Quotes erd -\end_inset - -) -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_HTML -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_HTML -\end_layout - -\end_inset - - Escape ' -\family typewriter -< -\family default -', ' -\family typewriter -> -\family default -', ' -\family typewriter -& -\family default -' and ' -\family typewriter -" -\family default -' by their respective HTML entities -\family typewriter -< -\family default -, -\family typewriter -> -\family default -, -\family typewriter -& -\family default - and -\family typewriter -" -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_LDAPFLT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_LDAPFLT -\end_layout - -\end_inset - - Escape the string using backslash-plus-hexcode notation as described in - RFC 4515 -\begin_inset Foot -status open - -\begin_layout Plain Layout -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -http://tools.ietf.org/html/rfc4515 -\end_layout - -\end_inset - - -\end_layout - -\end_inset - -, to make it suitable for use in an LDAP search filter. -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_LDAPRDN -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_LDAPRDN -\end_layout - -\end_inset - - Escape the string using backslash-plus-hexcode notation as described in - RFC 4514 -\begin_inset Foot -status open - -\begin_layout Plain Layout -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -http://tools.ietf.org/html/rfc4514 -\end_layout - -\end_inset - - -\end_layout - -\end_inset - -, to make it suitable for use in an LDAP Relative Distinguished Name. -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_BASE64 -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_BASE64 -\end_layout - -\end_inset - - Transform the string to BASE64, as described in RFC 4648 -\begin_inset Foot -status open - -\begin_layout Plain Layout -\begin_inset Flex URL -status collapsed - -\begin_layout Plain Layout - -http://tools.ietf.org/html/rfc4648 -\end_layout - -\end_inset - - -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_URIENC -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_URIENC -\end_layout - -\end_inset - - Escape the string so that it becomes a valid part for an URI. -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_SQLSQUOTE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_SQLSQUOTE -\end_layout - -\end_inset - - Escape all single quotes in the string by double single-quotes, as required - for using it in a single-quoted SQL string. - No surrounding quotes will be generated to facilitate concatenating of - -\family typewriter -HX_strquote -\family default - results. -\end_layout - -\begin_layout Description - -\family typewriter -HXQUOTE_SQLBQUOTE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXQUOTE_SQLBQUOTE -\end_layout - -\end_inset - - Escape all backticks in the string by double backticks, as required for - using it in a backtick-quoted SQL string (used for table names and columns). - No surrounding ticks will be generated to facilitate concatenation. -\end_layout - -\begin_layout Standard -Specifying an unrecognized type will result in -\family typewriter -NULL -\family default - being returned and -\family typewriter -errno -\family default - be set to -\family typewriter -EINVAL -\family default -. -\end_layout - -\begin_layout Standard -If -\family typewriter -free_me -\family default - is -\family typewriter -NULL -\family default -, the function will always allocate memory, even if the string needs no - quoting. - The program then has to free the result: -\end_layout - -\begin_layout LyX-Code - -\series bold -char * -\series default -s = HX_strquote("<head>", HXQUOTE_HTML, NULL); -\begin_inset Newline newline -\end_inset - -printf("%s -\backslash -n", s); -\begin_inset Newline newline -\end_inset - -free(s); -\end_layout - -\begin_layout Standard -If -\family typewriter -free_me -\family default - is not -\family typewriter -NULL -\family default - however, the function will put the pointer to the memory area into -\family typewriter -*free_me -\family default -, if the string needed quoting. - The program then has to free that after it is done with the quoted result: -\end_layout - -\begin_layout LyX-Code - -\series bold -char * -\series default -tmp = NULL; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -s = HX_strquote("head", HXQUOTE_HTML, &tmp); -\begin_inset Newline newline -\end_inset - -printf("%s -\backslash -n", s); -\begin_inset Newline newline -\end_inset - -free(tmp); -\end_layout - -\begin_layout Standard - -\family typewriter -tmp -\family default - could be -\family typewriter -NULL -\family default -, and since -\family typewriter -free(NULL) -\family default - is not an error, this is perfectly valid. - Furthermore, if -\family typewriter -*free_me -\family default - is not -\family typewriter -NULL -\family default - by the time -\family typewriter -HX_strquote -\family default - is called, the function will free it. - This makes it possible to call -\family typewriter -HX_strquote -\family default - in succession without -\family typewriter -free -\family default -s in between: -\end_layout - -\begin_layout LyX-Code - -\series bold -char * -\series default -tmp = NULL; -\begin_inset Newline newline -\end_inset - -printf("%s -\backslash -n", HX_strquote("<html>", HXQUOTE_HTML, &tmp)); -\begin_inset Newline newline -\end_inset - -printf("%s -\backslash -n", HX_strquote("<head>", HXQUOTE_HTML, &tmp)); -\begin_inset Newline newline -\end_inset - -free(tmp); -\end_layout - -\begin_layout Subsection -Tokenizing -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char ** -\series default -HX_split( -\series bold -const char * -\series default -s, -\series bold -const char * -\series default -delimiters, -\begin_inset Newline newline -\end_inset - - -\series bold -size_t * -\series default -fields, -\series bold -int -\series default - max); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_split -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char ** -\series default -HX_split_inplace( -\series bold -char * -\series default -s, -\series bold -const char * -\series default -delimiters, -\series bold -int * -\series default -fields, -\series bold -int -\series default - max); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_split_inplace -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_split_fixed( -\series bold -char * -\series default -s, -\series bold -const char * -\series default -delimiters, -\series bold -int -\series default - max, -\series bold -char ** -\series default -arr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_split_fixed -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strsep( -\series bold -char ** -\series default -sp, -\series bold -const char * -\series default -delimiters); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strsep -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strsep2( -\series bold -char ** -\series default -sp, -\series bold -const char * -\series default -dstr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strsep2 -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_split -\family default - Split the string -\family typewriter -s -\family default - on any characters from the -\begin_inset Quotes eld -\end_inset - - -\family typewriter -delimiters -\family default - -\begin_inset Quotes erd -\end_inset - - string. - Both the substrings and the array holding the pointers to these substrings - will be allocated as required; the original string is not modified. - If -\family typewriter -max -\family default - is larger than zero, produces no more than -\family typewriter -max -\family default - fields. - If -\family typewriter -fields -\family default - is not -\family typewriter -NULL -\family default -, the number of elements produced will be stored in -\family typewriter -*fields -\family default -. - The result is a -\family typewriter -NULL -\family default --terminated array of -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default -, and the user needs to free it when done with it, using -\family typewriter -HX_zvecfree -\family default - or equivalent. - An empty string (zero-length string) for -\family typewriter -s -\family default - yields a single field. -\end_layout - -\begin_layout Description - -\family typewriter -HX_split_inplace -\family default - Split the string -\family typewriter -s -\family default - in-place on any characters from the -\begin_inset Quotes eld -\end_inset - - -\family typewriter -delimiters -\family default - -\begin_inset Quotes erd -\end_inset - - string. - The array that will be holding the pointers to the substrings will be allocated - and needs to be freed by the user, using -\family typewriter -free -\family default -(3). - The -\family typewriter -fields -\family default - and -\family typewriter -max -\family default - arguments work as with -\family typewriter -HX_split -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_split_fixed -\family default - Split the string -\family typewriter -s -\family default - in-place on any characters from the -\begin_inset Quotes eld -\end_inset - - -\family typewriter -delimiters -\family default - -\begin_inset Quotes erd -\end_inset - - string. - The array for the substring pointers must be provided by the user through - the -\family typewriter -arr -\family default - argument. - -\family typewriter -max -\family default - must be the number of elements in the array or less. - The array will not be -\family typewriter -NULL -\family default --terminated -\begin_inset Foot -status open - -\begin_layout Plain Layout -An implementation may however decide to put NULL in the unassigned fields, - but this is implementation and situation-specific. - Do not rely on it. -\end_layout - -\end_inset - -. - The number of fields produced is returned. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strsep -\family default - Extract tokens from a string. -\begin_inset Newline newline -\end_inset - -This implementation of -\family typewriter -strsep -\family default - has been added since the function is non-standard (according to the manpage, - conforms to BSD4.4 only) and may not be available on every operating system. -\begin_inset Newline newline -\end_inset - -This function extracts tokens, separated by one of the characters in -\family typewriter -delimiters -\family default -. - The string is modified in-place and thus must be writable. - The delimiters in the string are then overwritten with -\family typewriter -' -\backslash -0' -\family default -, -\family typewriter -*sp -\family default - is advanced to the character after the delimiter, and the original pointer - is returned. - After the final token, -\family typewriter -strsep -\family default - will return -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strsep2 -\family default - Like -\family typewriter -HX_strsep -\family default -, but -\family typewriter -dstr -\family default - is not an array of delimiting characters, but an entire substring that - acts as a delimiter. -\end_layout - -\begin_layout Subsection -Size-bounded string ops -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strlcat( -\series bold -char * -\series default -dest, -\series bold -const char * -\series default -src, -\series bold -size_t -\series default - length); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strlcat -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strlcpy( -\series bold -char * -\series default -dest, -\series bold -const char * -\series default -src, -\series bold -size_t -\series default - length); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strlcpy -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strlncat( -\series bold -char * -\series default -dest, -\series bold -const char * -\series default -src, -\series bold -size_t -\series default - dlen, -\series bold -size_t -\series default - slen); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strlncat -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -size_t -\series default - HX_strnlen( -\series bold -const char * -\series default -src, -\series bold -size_t -\series default - max); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_strnlen -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HX_strlcat -\family default - and -\family typewriter -HX_strlcpy -\family default - provide implementations of the BSD-originating -\family typewriter -strlcat -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -strlcat -\end_layout - -\end_inset - - and -\family typewriter -strlcpy -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -strlcpy -\end_layout - -\end_inset - -. - -\family typewriter -strlcat -\family default - and -\family typewriter -strlcpy -\family default - are less error-prone variants for -\family typewriter -strncat -\family default - and -\family typewriter -strncpy -\family default - as they always take the length of the entire buffer specified by -\family typewriter -dest -\family default -, instead of just the length that is to be written. - The functions guarantee that the buffer is -\family typewriter -' -\backslash -0' -\family default --terminated. -\end_layout - -\begin_layout Standard - -\family typewriter -HX_strnlen -\family default - will return the length of the input string or the upper bound given by - -\family typewriter -max -\family default -, whichever is less. - It will not attempt to access more than this many bytes in the input buffer. -\end_layout - -\begin_layout Subsection -Allocation-related -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -HX_memdup( -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - length); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_memdup -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strdup( -\series bold -const char * -\series default -str); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strdup -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -HX_strndup( -\series bold -const char * -\series default -str, -\series bold -size_t -\series default - max); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_strndup -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold - -\begin_inset Note Greyedout -status open - -\begin_layout Plain Layout - -\family typewriter -\series bold -char * -\series default -HX_strclone( -\series bold -char ** -\series default -pa, -\series bold -const char * -\series default -pb); -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_strclone -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold - -\begin_inset Newline newline -\end_inset - -#ifdef -\series default - __cplusplus -\begin_inset Newline newline -\end_inset - - -\series bold -template<typename type> type -\series default - HX_memdup( -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - length); -\begin_inset Newline newline -\end_inset - - -\series bold -#endif -\end_layout - -\begin_layout Description - -\family typewriter -HX_memdup -\family default - Duplicates -\family typewriter -length -\family default - bytes from the memory area pointed to by -\family typewriter -ptr -\family default - and returns a pointer to the new memory block. - -\family typewriter -ptr -\family default - may not be -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strdup -\family default - Duplicates the string. - The function is equivalent to -\family typewriter -strdup -\family default -, but the latter may not be available on all platforms. - -\family typewriter -str -\family default - may be -\family typewriter -NULL -\family default -, in which case -\family typewriter -NULL -\family default - is also returned. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strndup -\family default - Duplicates the input string, but copies at most -\family typewriter -max -\family default - characters. - (The resulting string will be NUL-terminated of course.) -\family typewriter -str -\family default - may not be -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HX_strclone -\family default - Copies the string pointed to by -\family typewriter -pb -\family default - into -\family typewriter -*pa -\family default -. - If -\family typewriter -*pa -\family default - was not -\family typewriter -NULL -\family default - by the time -\family typewriter -HX_strclone -\family default - was called, the string is freed before a new one is allocated. - The function returns -\family typewriter -NULL -\family default - and sets -\family typewriter -errno -\family default - to -\family typewriter -EINVAL -\family default - if -\family typewriter -pb -\family default - is -\family typewriter -NULL -\family default - (this way it can be freed), or, if -\family typewriter -malloc -\family default - fails, returns -\family typewriter -NULL -\family default - and leaves -\family typewriter -errno -\family default - at what -\family typewriter -malloc -\family default - set it to. -\begin_inset Newline newline -\end_inset - -The use of this function is deprecated, albeit no replacement is proposed. -\end_layout - -\begin_layout Subsection -Examples -\end_layout - -\begin_layout Subsubsection -Using HX_split_fixed -\begin_inset CommandInset label -LatexCommand label -name "subsec:string-ex-HX_split_fixed" - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HX_split_fixed -\family default - is often used just with scoped automatic-storage variables and where the - field count of interest is fixed, as the example for parsing -\family typewriter -/etc/passwd -\family default - shows: -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -field[8]; -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -line = NULL; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - (HX_getl(&line, fp) != NULL) { -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (HX_split_fixed(line, ":", ARRAY_SIZE(field), field) < 7) { -\begin_inset Newline newline -\end_inset - - fprintf(stderr, "That does not look like a valid line. -\backslash -n"); -\begin_inset Newline newline -\end_inset - - -\series bold -continue -\series default -; -\begin_inset Newline newline -\end_inset - - } -\begin_inset Newline newline -\end_inset - - printf("Username: %s -\backslash -n", field[0]); -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Subsubsection -Using HX_split_inplace -\end_layout - -\begin_layout Standard -Where the number of fields is not previously known and/or estimatable, but - the string can be modified in place, one uses -\family typewriter -HX_split_inplace -\family default - as follows: -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <errno.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - (HX_getl(&line, fp) != NULL) { -\begin_inset Newline newline -\end_inset - - -\series bold -char ** -\series default -field = HX_split_inplace(line, ":", NULL, 0); -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (field == NULL) { -\begin_inset Newline newline -\end_inset - - fprintf(stderr, "Badness! %s -\backslash -n", strerror(errno)); -\begin_inset Newline newline -\end_inset - - -\series bold -break -\series default -; -\begin_inset Newline newline -\end_inset - - } -\begin_inset Newline newline -\end_inset - - printf("Username: %s -\backslash -n", field[0]); -\begin_inset Newline newline -\end_inset - - free(field); -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Subsubsection -Using HX_split -\end_layout - -\begin_layout Standard -Where the string is not modifiable in-place, one has to resort to using - the full-fledged -\family typewriter -HX_split -\family default - that allocates space for each substring. -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <errno.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - (HX_getl(&line, fp) != NULL) { -\begin_inset Newline newline -\end_inset - - -\series bold -char ** -\series default -field = HX_split(line, ":", NULL, 0); -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (field == NULL) { -\begin_inset Newline newline -\end_inset - - fprintf(stderr, "Badness. - %s -\backslash -n", strerror(errno)); -\begin_inset Newline newline -\end_inset - - break; -\begin_inset Newline newline -\end_inset - - } -\begin_inset Newline newline -\end_inset - - printf("Username: %s -\backslash -n", field[0]); -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -Suppose -\begin_inset Quotes eld -\end_inset - -callme -\begin_inset Quotes erd -\end_inset - - needs the original string -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - callme(line); -\begin_inset Newline newline -\end_inset - - HX_zvecfree(field); -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Subsubsection -Using HX_strsep -\end_layout - -\begin_layout Standard - -\family typewriter -HX_strsep -\family default - provides for thread- and reentrant-safe tokenizing a string where strtok - from the C standard would otherwise fail. -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char -\series default - line -\series bold -[] -\series default - = "root:x:0:0:root:/root:/bin/bash"; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -wp, -\series bold -* -\series default -p; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -wp = line; -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - ((p = HX_strsep(&wp, ":")) != NULL) -\begin_inset Newline newline -\end_inset - - printf("%s -\backslash -n", p) -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Memory containers -\begin_inset CommandInset label -LatexCommand label -name "sec:mc" - -\end_inset - - -\end_layout - -\begin_layout Standard -The HXmc series of functions provide scripting-like semantics for strings, - especially automatically resizing the buffer on demand. - They can also be used to store a binary block of data together with its - length. - (Hence the name: mc = memory container.) -\end_layout - -\begin_layout Standard -The benefit of using the HXmc functions is that one does not have to meticulousl -y watch buffer and string sizes anymore. -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout Paragraph -/* Step -\begin_inset space ~ -\end_inset - -1 */ -\end_layout - -\begin_layout LyX-Code - -\series bold -char -\series default - buf -\series bold -[ -\family roman -\series default -\shape italic -whatever was believed to be long enough -\family default -\series bold -\shape default -] -\series default - = "helloworld"; -\end_layout - -\begin_layout LyX-Code - -\series bold -if -\series default - (strlen(buf) + strlen(".txt") < -\series bold -sizeof -\series default -(buf)) -\begin_inset Newline newline -\end_inset - - strcat(s, ".txt"); -\end_layout - -\begin_layout Paragraph -/* Step -\begin_inset space ~ -\end_inset - -2 */ -\end_layout - -\begin_layout LyX-Code - -\series bold -char -\series default - buf -\series bold -[ -\family roman -\series default -\shape italic -long_enough -\family default -\series bold -\shape default -] -\series default - = "helloworld"; -\end_layout - -\begin_layout LyX-Code -strlcat(s, ".txt", -\series bold -sizeof -\series default -(buf)); -\end_layout - -\begin_layout Paragraph -/* Step -\begin_inset space ~ -\end_inset - -3 */ -\end_layout - -\begin_layout LyX-Code -hxmc_t -\series bold -* -\series default -buf = HXmc_strinit("helloworld"); -\begin_inset Newline newline -\end_inset - -HXmc_strcat(&s, ".txt"); -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Improvement of string safety over time -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -This makes it quite similar to the string operations (and append seems to - be the most commonly used one to me) supported in scripting languages that - also do without a size argument. - The essential part of such memory containers is that their internal (hidden) - metadata structure contains the length of the memory block in the container. - For binary data this may be the norm, but for C-style strings, the stored - and auto-updated length field serves as an accelerator cache. - For more details, see -\family typewriter -HXmc_length -\family default -. -\end_layout - -\begin_layout Standard -Of course, the automatic management of memory comes with a bit of overhead - as the string expands beyond its preallocated region. - Such may be mitigated by doing explicit (re)sizing. -\end_layout - -\begin_layout Subsection -Structural overview -\end_layout - -\begin_layout Standard -HXmc functions do not actually return a pointer to the memory container - (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -struct -\family default -) itself, but a pointer to the data block. - Conversely, input parameters to HXmc functions will be the data block pointer. - It is of type -\family typewriter -hxmc_t -\begin_inset space ~ -\end_inset - -* -\family default -, which is typedef'ed to -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default - and inherits all properties and privileges of -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default -. - Pointer arithmetic is thus supported. - It also means you can just pass it to functions that take a -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default - without having to do a member access like -\family typewriter -s.c_str -\family default -. - The drawback is that many functions operating on the memory container need - a -\family typewriter -hxmc_t -\begin_inset space ~ -\end_inset - -** -\family default - (a level-two indirection), because not only does the memory block move, - but also the memory container itself. - This is due to the implementation of the container metadata which immediately - and always precedes the writable memory block. -\end_layout - -\begin_layout Standard -HXmc ensures that the data block is terminated by a NUL ( -\family typewriter -' -\backslash -0' -\family default -) byte (unless you trash it), so you do not have to, and of course, to be - on the safe side. - But, the automatic NUL byte is not part of the region allocated by the - user. - That is, when one uses the classic approach with -\family typewriter -malloc(4096) -\family default -, the user will have control of 4096 bytes and has to stuff the NUL byte - in there somehow on his own; for strings this means the maximum string - length is 4095. - Requesting space for a 4096-byte sized HXmc container gives you the possibility - to use all 4096 bytes for the string, because HXmc provides a NUL byte. -\end_layout - -\begin_layout Standard -By the way, -\family typewriter -hxmc_t -\family default - is the -\shape italic -only -\shape default - typedef in this entire library, to distinguish it from regular -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default - that does not have a backing memory cointainer. -\end_layout - -\begin_layout Subsection -Constructors, destructors -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/string.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/string.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_strinit( -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmc_strinit -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_meminit( -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - size); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmc_meminit -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_strinit -\family default - Creates a new hxmc_t object from the supplied string and returns it. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_meminit -\family default - Creates a new hxmc_t object from the supplied memory buffer of the given - size and returns it. - -\family typewriter -HXmc_meminit(NULL, len) -\family default - may be used to obtain an empty container with a preallocated region of - -\family typewriter -len -\family default - bytes (zero is accepted for -\family typewriter -len -\family default -). -\end_layout - -\begin_layout LyX-Code - -\series bold -void -\series default - HXmc_free(hxmc_t -\series bold -* -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmc_free -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXmc_zvecfree(hxmc_t -\series bold -** -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmc_zvecfree -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_free -\family default - Frees the hxmc object. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_zvecfree -\family default - Frees all hxmc objects in the NULL-terminated array, and finally frees - the array itself, similar to -\family typewriter -HX_zvecfree -\family default -. -\end_layout - -\begin_layout Subsection -Data manipulation -\end_layout - -\begin_layout Subsubsection -Binary-based -\end_layout - -\begin_layout LyX-Code -hxmc_t -\series bold -* -\series default -HXmc_trunc(hxmc_t -\series bold -** -\series default -mc, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_trunc -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_setlen(hxmc_t -\series bold -** -\series default -mc, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_setlen -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_memcpy(hxmc_t -\series bold -** -\series default -mc, -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_memcpy -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_memcat(hxmc_t -\series bold -** -\series default -mc, -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_memcat -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_mempcat(hxmc_t -\series bold -** -\series default -mc, -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_mempcat -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_memins(hxmc_t -\series bold -** -\series default -mc, -\series bold -size_t -\series default - pos, -\series bold -const void * -\series default -ptr, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_memins -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_memdel(hxmc_t -\series bold -** -\series default -mc, -\series bold -size_t -\series default - pos, -\series bold -size_t -\series default - len); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_memdel -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -When -\family typewriter -ptr -\family default - is -\family typewriter -NULL -\family default -, each call behaves as if -\family typewriter -len -\family default - would be zero. - Specifically, no undefined behavior will result of the use of -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_trunc -\family default - Truncates the container's data to -\family typewriter -len -\family default - size. - If -\family typewriter -len -\family default - is greater than the current data size of the container, the length is in - fact -\shape italic -not -\shape default - updated, but a reallocation may be triggered, which can be used to do explicit - allocation. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_setlen -\family default - Set the data length, doing a reallocation of the memory container if needed. - The newly available bytes are uninitialized. - Make use of this function when letting 3rd party functions write to the - buffer, but it should not be used with -\family typewriter -HXmc_str* -\family default -(), -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_memcpy -\family default - Truncates the container's data and copies -\family typewriter -len -\family default - bytes from the memory area pointed to by -\family typewriter -ptr -\family default - to the container. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_memcat -\family default - Concatenates (appends) -\family typewriter -len -\family default - bytes from the memory area pointed to by -\family typewriter -ptr -\family default - to the container's data. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_mempcat -\family default - Prepends -\family typewriter -len -\family default - bytes from the memory area pointed to by -\family typewriter -ptr -\family default - to the container's data. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_memins -\family default - Prepends -\family typewriter -len -\family default - bytes from the memory area pointed to by -\family typewriter -ptr -\family default - to the -\family typewriter -pos -\family default -'th byte of the container's data. -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_memdel -\family default - Deletes -\family typewriter -len -\family default - bytes from the container beginning at position -\family typewriter -pos -\family default -. -\end_layout - -\begin_layout Standard -In case of a memory allocation failure, the -\family typewriter -HXmc_* -\family default - functions will return -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Subsubsection -String-based -\end_layout - -\begin_layout Standard -The string-based functions correspond to their binary-based equivalents - with a -\family typewriter -len -\family default - argument of -\family typewriter -strlen(s) -\family default -. -\end_layout - -\begin_layout LyX-Code -hxmc_t -\series bold -* -\series default -HXmc_strcpy(hxmc_t -\series bold -** -\series default -mc, -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_strcpy -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_strcat(hxmc_t -\series bold -** -\series default -mc, -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_strcat -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_strpcat(hxmc_t -\series bold -** -\series default -mc, -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXmc_strpcat -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -hxmc_t -\series bold -* -\series default -HXmc_strins(hxmc_t -\series bold -** -\series default -mc, -\series bold -size_t -\series default - pos, -\series bold -const char * -\series default -s); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXmc_strins -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_strcpy -\family default - Copies the string pointed to by -\family typewriter -s -\family default - into the memory container given by -\family typewriter -mc -\family default -. - If -\family typewriter -mc -\family default - is -\family typewriter -NULL -\family default -, the memory container will be deallocated, that is, -\family typewriter -*mc -\family default - becomes -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Subsubsection -From auxiliary sources -\end_layout - -\begin_layout LyX-Code -hxmc_t -\series bold -* -\series default -HX_getl(hxmc_t -\series bold -** -\series default -mc, FILE -\series bold -* -\series default -fp); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_getl -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_getl -\family default - Read the next line from -\family typewriter -fp -\family default - and store the result in the container. - Returns -\family typewriter -NULL -\family default - on error, or when end of file occurs while no characters have been read. -\end_layout - -\begin_layout Subsection -Container properties -\end_layout - -\begin_layout LyX-Code - -\series bold -size_t -\series default - HXmc_length( -\series bold -const -\series default - hxmc_t -\series bold -** -\series default -mc); -\end_layout - -\begin_layout Description - -\family typewriter -HXmc_length -\family default - Returns the length of the memory container. - This is not always equal to the actual string length. - For example, if -\family typewriter -HX_chomp -\family default - was used on an MC-backed string, -\family typewriter -strlen -\family default - will return less than -\family typewriter -HXmc_length -\family default - if newline control characters ( -\family typewriter -' -\backslash -r' -\family default - and -\family typewriter -' -\backslash -n' -\family default -) were removed. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Format templates -\begin_inset CommandInset label -LatexCommand label -name "sec:format" - -\end_inset - - -\end_layout - -\begin_layout Standard -HXfmt is a small template system for by-name variable expansion. - It can be used to substitute placeholders in format strings supplied by - the user by appropriate expanded values defined by the program. - Such can be used to allow for flexible configuration files that define - key-value mappings such as -\end_layout - -\begin_layout LyX-Code -detect_peer = ping6 -c1 %(ADDR) -\begin_inset Newline newline -\end_inset - -#detect_peer = nmap -sP %(ADDR) | grep -Eq "appears to be up" -\end_layout - -\begin_layout Standard -Consider for example a monitoring daemon that allows the administrator to - specify a program of his choice with which to detect whether a peer is - alive or not. - The user can choose any program that is desired, but evidently needs to - pass the address to be tested to the program. - This is where the daemon will do a substitution of the string -\begin_inset Quotes eld -\end_inset - - -\family typewriter -ping -c1 %(ADDR) -\family default - -\begin_inset Quotes erd -\end_inset - - it read from the config file, and put the actual address in it before finally - executing the command. -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout LyX-Code -printf("%s has %u files -\backslash -n", user, num); -\begin_inset Newline newline -\end_inset - -printf("%2$u files belong to %1$s -\backslash -n", num, user); -\end_layout - -\begin_layout Plain Layout -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%s -\family default - -\begin_inset Quotes erd -\end_inset - - (or -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%1$s -\family default - -\begin_inset Quotes erd -\end_inset - - here) specifies how large -\begin_inset Quotes eld -\end_inset - -user -\begin_inset Quotes erd -\end_inset - - is -\begin_inset space ~ -\end_inset - -— -\family typewriter -sizeof(const char *) -\family default - in this case. - If that is missing, there is no way to know the offset of -\begin_inset Quotes eld -\end_inset - - -\family typewriter -num -\family default - -\begin_inset Quotes erd -\end_inset - - relative to -\begin_inset Quotes eld -\end_inset - - -\family typewriter -user -\family default - -\begin_inset Quotes erd -\end_inset - -, making varargs retrieval impossible. -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout - -\family typewriter -printf -\family default - positional parameters -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -printf -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -printf -\end_layout - -\end_inset - -, at least from GNU libc, has something vaguely similar: positional parameters -\begin_inset Index idx -status open - -\begin_layout Plain Layout -positional parameters -\end_layout - -\end_inset - -. - They have inherent drawbacks, though. - One is of course the question of portability, but there is a bigger issue. - All parameters must be specified, otherwise there is no way to determine - the location of all following objects following the missing one on the - stack in a varargs-function like -\family typewriter -printf -\family default -., which makes it unsuitable to be used with templates where omitting some - placeholders is allowed. -\end_layout - -\begin_layout Subsection -Initialization, use and deallocation -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/option.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/option.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -HXformat_init( -\series bold -void -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXformat_init -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXformat_free( -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXformat_free -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HXformat_add( -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table, -\series bold -const char * -\series default -key, -\begin_inset Newline newline -\end_inset - - -\series bold -const void * -\series default -ptr, -\series bold -unsigned int -\series default - ptr_type); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXformat_add -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HXformat_init -\family default - will allocate and set up a simple string-to-string map that is used for - the underlying storage, and returns it. -\end_layout - -\begin_layout Standard -To release the substitution table and memory associated with it, call -\family typewriter -HXformat_free -\family default -. -\end_layout - -\begin_layout Standard - -\family typewriter -HXformat_add -\family default - is used to add substitution entries. - One can also specify other types such as numeral types. - -\family typewriter -ptr_type -\family default - describes the type behind -\family typewriter -ptr -\family default - and are constants from -\family typewriter -option.h -\family default - (cf. -\begin_inset space \space{} -\end_inset - -section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-types" - -\end_inset - -) -\begin_inset space ~ -\end_inset - -— not all constants can be used, though, and their meaning also differs - from what -\family typewriter -HX_getopt -\family default - or -\family typewriter -HX_shconfig -\family default - use them for -\begin_inset space ~ -\end_inset - -— the two could be seen as -\begin_inset Quotes eld -\end_inset - -read -\begin_inset Quotes erd -\end_inset - - operations, while HXformat is a write operation. -\end_layout - -\begin_layout Subsubsection -Immediate types -\end_layout - -\begin_layout Standard -\begin_inset Quotes eld -\end_inset - -Immediate types -\begin_inset Quotes erd -\end_inset - - are resolved when -\family typewriter -HXformat_add -\family default - is called, that is, they are copied and inserted into the tree, and are - subsequently independent from any changes to variables in the program. - Because the HXopt-originating type name, that is, -\family typewriter -HXTYPE_* -\family default -, is also used for deferred types, the constant -\family typewriter -HXFORMAT_IMMED -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXFORMAT_IMMED -\end_layout - -\end_inset - - -\family default - needs to be specified on some types to denote an immediate value. -\end_layout - -\begin_layout Itemize - -\family typewriter -HXTYPE_STRING -\family default - -\begin_inset space ~ -\end_inset - -— -\family typewriter -ptr -\family default - is a -\family typewriter -const char * -\family default -. -\end_layout - -\begin_layout Itemize - -\family typewriter -HXTYPE_ -\family default -{ -\family typewriter -U -\family default -,}{ -\family typewriter -CHAR -\family default -, -\family typewriter -SHORT -\family default -, -\family typewriter -INT -\family default -, -\family typewriter -LONG -\family default -, -\family typewriter -LLONG -\family default -} -\family typewriter - | HXFORMAT_IMMED -\family default - -\begin_inset space ~ -\end_inset - -— mapping to the standard types -\end_layout - -\begin_layout Subsubsection -Deferred types -\end_layout - -\begin_layout Standard -\begin_inset Quotes eld -\end_inset - -Deferred types -\begin_inset Quotes erd -\end_inset - - are resolved on every invocation of a formatter function ( -\family typewriter -HXformat_*printf -\family default -). - The expansions may be changed by modifying the underlying variable pointed - to, but the pointer must remain valid and its pointee not go out of scope. - Figure -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "fig:hxformat-immediate-deferred" - -\end_inset - - shows the difference in a code sample. -\end_layout - -\begin_layout Itemize - -\family typewriter -HXTYPE_STRP -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_STRP -\end_layout - -\end_inset - - -\begin_inset space ~ -\end_inset - -— -\family typewriter -ptr -\family default - is a -\family typewriter -const char *const * -\family default -; the pointer resolution is deferred until the formatter is called with - one of the -\family typewriter -HXformat_*printf -\family default - functions. - Deferred in the sense it is always resolved anew. - -\end_layout - -\begin_layout Itemize - -\family typewriter -HXTYPE_BOOL -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_BOOL -\end_layout - -\end_inset - - -\begin_inset space ~ -\end_inset - -— -\family typewriter -ptr -\family default - is a -\family typewriter -const int -\begin_inset space ~ -\end_inset - -* -\family default -. -\end_layout - -\begin_layout Itemize - -\family typewriter -HXTYPE_ -\family default -{ -\family typewriter -U -\family default -,}{ -\family typewriter -CHAR -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_CHAR -\end_layout - -\end_inset - - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UCHAR -\end_layout - -\end_inset - -, -\family typewriter -SHORT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_SHORT -\end_layout - -\end_inset - - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_USHORT -\end_layout - -\end_inset - -, -\family typewriter -INT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT -\end_layout - -\end_inset - - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT -\end_layout - -\end_inset - -, -\family typewriter -LONG -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_LONG -\end_layout - -\end_inset - - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_ULONG -\end_layout - -\end_inset - -, -\family typewriter -LLONG -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_LLONG -\end_layout - -\end_inset - - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_ULLONG -\end_layout - -\end_inset - -} -\begin_inset space ~ -\end_inset - -— mapping to the standard types with one indirection (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -int -\begin_inset space ~ -\end_inset - -* -\family default -) -\end_layout - -\begin_layout Itemize - -\family typewriter -HXTYPE_ -\family default -{ -\family typewriter -FLOAT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_FLOAT -\end_layout - -\end_inset - -, -\family typewriter -DOUBLE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_DOUBLE -\end_layout - -\end_inset - -} -\begin_inset space ~ -\end_inset - -— mapping to the two floating-point types with one indirection (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -double -\begin_inset space ~ -\end_inset - -* -\family default -) -\end_layout - -\begin_layout Subsection -Invoking the formatter -\end_layout - -\begin_layout LyX-Code - -\series bold -int -\series default - HXformat_aprintf( -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table, hxmc_t -\series bold -** -\series default -dest, -\series bold -const char * -\series default -template); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXformat_aprintf -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HXformat_sprintf( -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table, -\series bold -char * -\series default -dest, -\series bold -size_t -\series default - size, -\series bold -const char * -\series default -template); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXformat_sprintf -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HXformat_fprintf( -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table, FILE -\series bold -* -\series default -filp, -\series bold -const char * -\series default -template); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXformat_fprintf -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXformat_aprintf -\family default - Substitute placeholders in -\family typewriter -template -\family default - using the given table. - This will produce a string in a HX memory container ( -\family typewriter -hxmc_t -\family default -), and the pointer is put into -\family typewriter -*dest -\family default -. - The caller will be responsible for freeing it later when it is done using - the result. -\end_layout - -\begin_layout Description - -\family typewriter -HXformat_sprintf -\family default - Do substitution and store the expanded result in the buffer -\family typewriter -dest -\family default - which is of size -\family typewriter -size -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXformat_fprintf -\family default - Do substituion and directly output the expansion to the given stdio stream. -\end_layout - -\begin_layout Standard -On success, the length of the expanded string is returned, excluding the - trailing -\family typewriter -' -\backslash -0' -\family default -. - While -\family typewriter -HXformat_sprintf -\family default - will not write more than -\family typewriter -size -\family default - bytes (including the -\family typewriter -' -\backslash -0' -\family default -), the length it would have taken is returned, similar to what -\family typewriter -sprintf -\family default - does. - On error, negative errno is returned. -\end_layout - -\begin_layout Standard -The HXformat function family recognizes make-style like functions and recursive - expansion, described below. -\end_layout - -\begin_layout Subsection -Functions -\end_layout - -\begin_layout Standard -To expand a variable, one uses a syntax like -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%(NAME) -\family default - -\begin_inset Quotes erd -\end_inset - - in the format string. - Recursive expansion like -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%(%(USER)) -\family default - -\begin_inset Quotes erd -\end_inset - - is supported; assuming -\family typewriter -%(USER) -\family default - would expand to -\begin_inset Quotes eld -\end_inset - -linux -\begin_inset Quotes erd -\end_inset - -, HXformat would try to resolve -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%(linux) -\family default - -\begin_inset Quotes erd -\end_inset - - next. - Besides these variable substitutions, HXformat also provides function calls - whose syntax is -\begin_inset Quotes eld -\end_inset - - -\family typewriter -%(nameOfFunction parameters[...]) -\family default - -\begin_inset Quotes erd -\end_inset - -. - Parameters can be any text, including variables. - Paramters are separated from another by a delimiter specific to each function. - See this list for details: -\end_layout - -\begin_layout Itemize - -\family typewriter -%(env -\family default - -\shape italic -variable -\family typewriter -\shape default -) -\begin_inset Newline newline -\end_inset - - -\family default -The -\family typewriter -env -\family default - function expands to the string that is stored in the environmental variable - by the given name. -\end_layout - -\begin_layout Itemize - -\family typewriter -%(exec -\family default -\shape italic -command -\family typewriter -\shape default - -\family default -[ -\shape italic -args -\shape default -...] -\family typewriter -) -\family default - -\begin_inset Newline newline -\end_inset - -The -\family typewriter -exec -\family default - function expands to the standard output of the command. - The command is directly run without shell invocation, so no special character - expansion (wildcards, etc.) takes place. - stdin is set to -\family typewriter -/dev\SpecialChar breakableslash -null -\family default -. - The parameter delimiter is the space character. - To be able to use this function -\begin_inset space ~ -\end_inset - -— as it is relevant to security -\begin_inset space ~ -\end_inset - -— the fmt table needs to have a key called -\begin_inset Quotes eld -\end_inset - - -\family typewriter -/libhx/exec -\family default - -\begin_inset Quotes erd -\end_inset - -. - See example -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "fig:hxformat-exec" - -\end_inset - - for details. -\end_layout - -\begin_layout Itemize - -\family typewriter -%(if -\family default -\shape italic -condition -\family typewriter -\shape default -, -\family default -[ -\shape italic -then -\shape default -][ -\family typewriter -, -\family default -[ -\shape italic -else -\shape default -]] -\family typewriter -) -\family default - -\begin_inset Newline newline -\end_inset - -If the condition parameter expands to a string of non-zero length, the function - expands to the -\begin_inset Quotes eld -\end_inset - -then -\begin_inset Quotes erd -\end_inset - - block, otherwise the -\begin_inset Quotes eld -\end_inset - -else -\begin_inset Quotes erd -\end_inset - - block. - The delimiter used is a comma. -\end_layout - -\begin_layout Itemize - -\family typewriter -%(lower -\family default -\shape italic -text -\family typewriter -\shape default -) -\family default -, -\family typewriter -%(upper -\family default -\shape italic -text -\family typewriter -\shape default -) -\family default - -\begin_inset Newline newline -\end_inset - -Lowercases or uppercases the supplied argument. - As these functions are meant to take only one argument, there is no delimiter - defined that would need escaping if multiple arguments were supposed to - be passed. - -\family typewriter -%(lower a,b) -\family default - is equivalent to -\family typewriter -%(lower "a,b") -\family default -. -\end_layout - -\begin_layout Itemize - -\family typewriter -%(shell -\family default -\shape italic -command -\family typewriter -\shape default - -\family default -[ -\shape italic -args -\shape default -...] -\family typewriter -) -\family default - -\begin_inset Newline newline -\end_inset - -Similar to -\family typewriter -%(exec) -\family default -, but invokes the shell inbetween (i. -\begin_inset space \thinspace{} -\end_inset - -e. -\begin_inset space \space{} -\end_inset - -` -\family typewriter -sh -c ' -\family default -\shape italic -command -\shape default -... -\family typewriter -' -\family default -`) such that special characters, redirection, and so on can be used. -\end_layout - -\begin_layout Itemize - -\family typewriter -%(substr -\family default -\shape italic -text -\family typewriter -\shape default -, -\family default -\shape italic -offset -\shape default -[ -\family typewriter -, -\family default -\shape italic -length -\shape default -] -\family typewriter -) -\family default - -\begin_inset Newline newline -\end_inset - -Extracts a substring out of the given text, starting at -\shape italic -offset -\shape default - and running for the given length. - If no length is given, will extract until the end of the string. - If -\shape italic -offset -\shape default - is negative, it specifies the offset from the end of the string. - If -\shape italic -length -\shape default - is negative, that many characters are left off the end. -\end_layout - -\begin_layout Itemize - -\family typewriter -%(snl -\family default -\shape italic -text -\family typewriter -\shape default -) -\family default - -\begin_inset Newline newline -\end_inset - -Strips trailing newlines from text and replaces any other newline by a space. - What happens implicity in Makefiles' -\family typewriter -$(shell -\family default -... -\family typewriter -) -\family default - statements usually is explicitly separate in libHX. -\end_layout - -\begin_layout Subsection -Examples -\end_layout - -\begin_layout Standard -\begin_inset Float figure -placement H -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -const char * -\series default -b = "Hello World"; -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -char -\series default - c -\family default -\series bold -[] -\family typewriter -\series default - = "Hello World"; -\family default - -\begin_inset Newline newline -\end_inset - - -\family typewriter -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table = HXformat_init(); -\begin_inset Newline newline -\end_inset - -HXformat_add(table, "%(GREETING1)", b, HXTYPE_STRING); -\begin_inset Newline newline -\end_inset - -HXformat_add(table, "%(GREETING2)", &c, HXTYPE_STRP); -\begin_inset Newline newline -\end_inset - -b = NULL; -\begin_inset Newline newline -\end_inset - -snprintf(c, -\family default -\series bold -sizeof -\family typewriter -\series default -(c), "Hello Home"); -\begin_inset Newline newline -\end_inset - -HXformat_aprintf(...); -\end_layout - -\begin_layout Plain Layout -Upon calling -\family typewriter -HXformat_*printf -\family default -, -\family typewriter -%(GREETING1) -\family default - will expand to -\begin_inset Quotes eld -\end_inset - -Hello World -\begin_inset Quotes erd -\end_inset - - whereas -\family typewriter -%(GREETING2) -\family default - will expand to -\begin_inset Quotes eld -\end_inset - -Hello Home -\begin_inset Quotes erd -\end_inset - -. -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -\begin_inset CommandInset label -LatexCommand label -name "fig:hxformat-immediate-deferred" - -\end_inset - -Immediate and deferred resolution -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Float figure -wide false -sideways false -status open - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXformat_map -\series bold -* -\series default -table = HXformat_init(); -\begin_inset Newline newline -\end_inset - -HXformat_add(table, "/libhx/exec", NULL, HXTYPE_IMMED); -\begin_inset Newline newline -\end_inset - -HXformat_aprintf(table, &result, "%(exec uname -s)"); -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -\begin_inset CommandInset label -LatexCommand label -name "fig:hxformat-exec" - -\end_inset - -Using the -\family typewriter -%(exec) -\family default - function -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Part -Filesystem operations -\end_layout - -\begin_layout Section -Dentry operations -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include <libHX/io.h> -\series default - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_readlink(hxmc_t -\series bold -** -\series default -buf, -\series bold -const char * -\series default -path); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_readlink -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_realpath(hxmc_t -\series bold -** -\series default -buf, -\series bold -const char * -\series default -path, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_realpath -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HX_readlink -\family default - calls through to -\family typewriter -readlink -\family default - to read the target of a symbolic link, and stores the result in the memory - container referenced by -\family typewriter -*buf -\family default - (similar to -\family typewriter -HX_getl -\family default - semantics). - If -\family typewriter -*buf -\family default - is -\family typewriter -NULL -\family default -, a new container will be allocated and a pointer to it stored in -\family typewriter -*buf -\family default -. - The container's content is naturally zero-terminated automatically. - The return value of the function will be the length of the link target, - or negative to indicate the system error value. -\end_layout - -\begin_layout Standard - -\family typewriter -HX_realpath -\family default - will normalize the given path by transforming various path components into - alternate descriptions. - The -\family typewriter -flags -\family default - parameter controls its actions: -\end_layout - -\begin_layout Description - -\family typewriter -HX_REALPATH_DEFAULT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_REALPATH_DEFAULT -\end_layout - -\end_inset - - A mnemonic for a set of standard flags: -\family typewriter -HX_\SpecialChar softhyphen -REALPATH_\SpecialChar softhyphen -SELF -\begin_inset space ~ -\end_inset - -| HX_\SpecialChar softhyphen -REALPATH_\SpecialChar softhyphen -PARENT -\family default -. - Note that -\family typewriter -HX_\SpecialChar softhyphen -REALPATH_\SpecialChar softhyphen -ABSOLUTE -\family default -, which would also be required to get libc's -\family typewriter -realpath -\family default -(3) behavior, is not included in the set. -\end_layout - -\begin_layout Description - -\family typewriter -HX_REALPATH_ABSOLUTE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_REALPATH_ABSOLUTE -\end_layout - -\end_inset - - Requests that the output path shall be absolute. - In the absence of this flag, an absolute output path will only be produced - if the input path is also absolute. -\end_layout - -\begin_layout Description - -\family typewriter -HX_REALPATH_SELF -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_REALPATH_SELF -\end_layout - -\end_inset - - Request resolution of -\begin_inset Quotes eld -\end_inset - -. -\begin_inset Quotes erd -\end_inset - - path components. -\end_layout - -\begin_layout Description - -\family typewriter -HX_REALPATH_PARENT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_REALPATH_PARENT -\end_layout - -\end_inset - - Request resolution of -\begin_inset Quotes eld -\end_inset - -.. -\begin_inset Quotes erd -\end_inset - - path components. -\end_layout - -\begin_layout Standard -The result is stored in a memory container whose pointer is returned through - -\family typewriter -*buf -\family default -. - The return value of the function will be negative to indicate a possible - system error, or be positive non-zero for success. -\end_layout - -\begin_layout Section -Directory traversal -\begin_inset CommandInset label -LatexCommand label -name "sec:dir-ops1" - -\end_inset - - -\end_layout - -\begin_layout Standard -libHX provides a minimal readdir-style wrapper for cross-platform directory - traversal. - This is needed because the Win32 platforms does not have readdir, and there - is some housekeeping to do on Unixish platforms, since the -\family typewriter -dirent -\family default - structure needs allocation of a path-specific size. -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/io.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/io.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdir -\series bold -* -\series default -HXdir_open( -\series bold -const char * -\series default -directory); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXdir_open -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -const char * -\series default -HXdir_read( -\series bold -struct -\series default - HXdir -\series bold -* -\series default -handle); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXdir_read -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -void -\series default - HXdir_close( -\series bold -struct -\series default - HXdir -\series bold -* -\series default -handle); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXdir_close -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HXdir_open -\family default - returns a pointer to its private data area, or -\family typewriter -NULL -\family default - upon failure, in which case -\family typewriter -errno -\family default - is preserved from the underlying system calls. - -\family typewriter -HXdir_read -\family default - causes the next entry from the directory to be fetched. - The pointer returned by -\family typewriter -HXdir_read -\family default - must not be freed, and the data is overwritten in subsequent calls to the - same handle. - If you want to keep it around, you will have to duplicate it yourself. - -\family typewriter -HXdir_close -\family default - will close the directory and free the private data it held. -\end_layout - -\begin_layout Subsection -Example -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <errno.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/io.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXdir -\series bold -* -\series default -dh; -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - ((dh = HXdir_open(".")) == NULL) { -\begin_inset Newline newline -\end_inset - - fprintf(stderr, "Could not open directory: %s -\backslash -n", strerror(errno)); -\begin_inset Newline newline -\end_inset - - return; -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - ((dentry = HXdir_read(dh)) != NULL) -\begin_inset Newline newline -\end_inset - - printf("%s -\backslash -n", dentry); -\begin_inset Newline newline -\end_inset - -HXdir_close(dh); -\end_layout - -\begin_layout Standard -This sample will open the current directory, and print out all entries as - it iterates over them. -\end_layout - -\begin_layout Section -Directory operations -\begin_inset CommandInset label -LatexCommand label -name "sec:dir-ops2" - -\end_inset - - -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/io.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/io.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_mkdir( -\series bold -const char * -\series default -path, -\series bold -unsigned int -\series default - mode); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -HX_mkdir -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_rrmdir( -\series bold -const char * -\series default -path); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_rrmdir -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HX_mkdir -\family default - will create the directory given by -\family typewriter -path -\family default - and all its parents that do not exist yet using the given -\family typewriter -mode -\family default -. - It is equivalent to the ` -\family typewriter -mkdir -p -\family default -` shell command. - It will return >0 for success, or -\family typewriter --errno -\family default - on error. -\end_layout - -\begin_layout Standard - -\family typewriter -HX_rrmdir -\family default - also maps to an operation commonly done on the shell, ` -\family typewriter -rm -Rf -\family default -`, deleting the directory given by -\family typewriter -path -\family default -, including all files within it and its subdirectories. - Errors during deletion are ignored, but if there was any, the errno value - of the first one is returned negated. -\end_layout - -\begin_layout Section -File operations -\begin_inset CommandInset label -LatexCommand label -name "sec:file-ops" - -\end_inset - - -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/io.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/io.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_copy_file( -\series bold -const char * -\series default -src, -\series bold -const char * -\series default -dest, -\series bold -unsigned int -\series default - flags, ...); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_copy_file -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_copy_dir( -\series bold -const char * -\series default -src, -\series bold -const char * -\series default -dest, -\series bold -unsigned int -\series default - flags, ...); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_copy_dir -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Possible flags that can be used with the functions: -\end_layout - -\begin_layout Description - -\family typewriter -HXF_KEEP -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXF_KEEP -\end_layout - -\end_inset - - Do not overwrite existing files. -\end_layout - -\begin_layout Description - -\family typewriter -HXF_UID -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXF_UID -\end_layout - -\end_inset - - Change the new file's owner to the UID given in the varargs section ( -\family typewriter -... -\family default -). - -\family typewriter -HXF_UID -\family default - is processed before -\family typewriter -HXF_GID -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXF_GID -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXF_GID -\end_layout - -\end_inset - - Change the new file's group owner to the GID given in the varargs section. - This is processed after -\family typewriter -HXF_UID -\family default -. -\end_layout - -\begin_layout Standard -Error checking is flakey. -\end_layout - -\begin_layout Standard - -\family typewriter -HX_copy_file -\family default - will return >0 on success, or -\family typewriter --errno -\family default - on failure. - Errors can arise from the use of the syscalls -\family typewriter -open -\family default -, -\family typewriter -read -\family default - and -\family typewriter -write -\family default -. - The return value of -\family typewriter -fchmod -\family default -, which is used to set the UID and GID, is actually ignored, which means - verifying that the owner has been set cannot be detected with -\family typewriter -HX_copy_file -\family default - alone (historic negligience?). -\end_layout - -\begin_layout Subsection -Filedescriptor I/O -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/io.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/io.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -ssize_t -\series default - HXio_fullread( -\series bold -int -\series default - fd, -\series bold -void * -\series default -buf, -\series bold -size_t -\series default - size, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXio_fullread -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -ssize_t -\series default - HXio_fullwrite( -\series bold -int -\series default - fd, -\series bold -const void * -\series default -buf, -\series bold -size_t -\series default - size, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXio_fullwrite -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -Since plain -\family typewriter -read -\family default -(2) and -\family typewriter -write -\family default -(2) may process only part of the buffer -\begin_inset space ~ -\end_inset - -— even more likely so with sockets -\begin_inset space ~ -\end_inset - -—, libHX provides two functions that calls these in a loop to retry said - operations until the full amount has been processed. - Since -\family typewriter -read -\family default - and -\family typewriter -write -\family default - can also be used with socket file descriptors, so can these. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Part -Options and Configuration Files -\end_layout - -\begin_layout Section -Option parsing -\begin_inset CommandInset label -LatexCommand label -name "sec:option" - -\end_inset - - -\end_layout - -\begin_layout Standard -libHX uses a table-based approach like libpopt -\begin_inset Foot -status open - -\begin_layout Plain Layout -The alternative would be an iterative, open-coded approach like -\family typewriter -getopt -\family default -(3) requires. -\end_layout - -\end_inset - -. - It provides for both long and short options and the different styles associated - with them, such as absence or presence of an equals sign for long options - ( -\family typewriter ---foo=bar -\family default - and -\family typewriter ---foo bar -\family default -), bundling (writing -\family typewriter --abc -\family default - for non-argument taking options -\family typewriter --a -b -c -\family default -), squashing (writing -\family typewriter --fbar -\family default - for an argument-requiring option -\family typewriter --f -\begin_inset space ~ -\end_inset - -bar -\family default -). - The -\begin_inset Quotes eld -\end_inset - -lone dash -\begin_inset Quotes erd -\end_inset - - that is often used to indicate standard input or standard output, is correctly - handled -\begin_inset Foot -status open - -\begin_layout Plain Layout -popt failed to do this for a long time. -\end_layout - -\end_inset - -, as in -\family typewriter --f -\begin_inset space ~ -\end_inset - -- -\family default -. -\end_layout - -\begin_layout Standard -A table-based approach allows for the parser to run as one atomic block - of code (callbacks are, by definition, -\begin_inset Quotes eld -\end_inset - -special -\begin_inset Quotes erd -\end_inset - - exceptions), making it more opaque than an open-coded -\family typewriter -getopt -\family default -(3) loop. - You give it your argument vector and the table, snip the finger (call the - parser function once), and it is done. - In getopt on the other hand, the -\family typewriter -getopt -\family default - function returns for every argument it parsed and needs to be called repeatedly. -\end_layout - -\begin_layout Subsection -Synopsis -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-synopsis" - -\end_inset - - -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/option.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/option.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXoption { -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -struct HXoption -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -const char -\series default - *ln; -\begin_inset Newline newline -\end_inset - - -\series bold -char -\series default - sh; -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - type; -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -ptr, -\series bold -* -\series default -uptr; -\begin_inset Newline newline -\end_inset - - -\series bold -void (* -\series default -cb -\series bold -) -\series default -( -\series bold -const struct -\series default - HXoptcb -\series bold -* -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - val; -\begin_inset Newline newline -\end_inset - - -\series bold -const char * -\series default -help, -\series bold -* -\series default -htyp; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_getopt( -\series bold -const struct -\series default - HXoption -\series bold -* -\series default -options_table, -\series bold -int * -\series default -argc, -\begin_inset Newline newline -\end_inset - - -\series bold -const char *** -\series default -argv, -\series bold -unsigned int -\series default - flags); -\end_layout - -\begin_layout Standard -The various fields of -\family typewriter -struct HXoption -\family default - are: -\end_layout - -\begin_layout Description - -\family typewriter -ln -\family default - The long option name, if any. - May be -\family typewriter -NULL -\family default - if none is to be assigned for this entry. -\end_layout - -\begin_layout Description - -\family typewriter -sh -\family default - The short option name/character, if any. - May be -\family typewriter -' -\backslash -0' -\family default - if none is to be assigned for this entry. -\end_layout - -\begin_layout Description - -\family typewriter -type -\family default - The type of the entry, essentially denoting the type of the target variable. -\end_layout - -\begin_layout Description - -\family typewriter -val -\family default - An integer value to be stored into -\family typewriter -*(int -\begin_inset space ~ -\end_inset - -*)ptr -\family default - when -\family typewriter -HXTYPE_IVAL -\family default - is used. -\end_layout - -\begin_layout Description - -\family typewriter -ptr -\family default - A pointer to the variable so that the option parser can store the requested - data in it. - The pointer may be -\family typewriter -NULL -\family default - in which case no data is stored (but -\family typewriter -cb -\family default - is still called if defined, with the data). -\end_layout - -\begin_layout Description - -\family typewriter -uptr -\family default - A user-supplied pointer. - Its value is passed verbatim to the callback, and may be used for any purpose - the user wishes. - If -\family typewriter -type -\family default - is -\family typewriter -HXTYPE_SVAL -\family default -, it is the value in -\family typewriter -uptr -\family default - that will be used to populate -\family typewriter -*(const char -\begin_inset space ~ -\end_inset - -**)ptr -\family default -. - (The original -\family typewriter -.sval -\family default - field has been removed in libHX 3.12.) -\end_layout - -\begin_layout Description - -\family typewriter -cb -\family default - If not -\family typewriter -NULL -\family default -, call out to the referenced function after the option has been parsed (and - the results possibly be stored in -\family typewriter -ptr -\family default -) -\end_layout - -\begin_layout Description - -\family typewriter -help -\family default - A help string that is shown for the option when the option table is dumped - by request (e. -\begin_inset space \thinspace{} -\end_inset - -g. -\begin_inset space \space{} -\end_inset - - -\family typewriter -yourprgram --help -\family default -) -\end_layout - -\begin_layout Description - -\family typewriter -htyp -\family default - String containing a keyword to aid the user in understanding the available - options during dump. - See examples. -\end_layout - -\begin_layout Standard -Due to the amount of fields, it is advised to use C99 named initializers - to populate a struct, as they allow to omit unspecified fields, and assume - no specific order of the members: -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - HXoption e = {.sh = 'f', .help = "Force"}; -\end_layout - -\begin_layout Standard -It is a sad fact that C++ has not gotten around to implement these yet. - It is advised to put the option parsing code into a separate -\family typewriter -.c -\family default - file that can then be compiled in C99 rather than C++ mode. -\end_layout - -\begin_layout Subsection -Type map -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-types" - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXTYPE_NONE -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXTYPE_NONE -\end_layout - -\end_inset - - -\family default -\series default - The option does not take any argument, but the presence of the option may - be record by setting the -\family typewriter -*(int -\begin_inset space ~ -\end_inset - -*)ptr -\family default - to 1. - Other rules apply when -\family typewriter -HXOPT_\SpecialChar softhyphen -INC -\family default - or -\family typewriter -HXOPT_\SpecialChar softhyphen -DEC -\family default - are specified as flags (see section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-flags" - -\end_inset - -). -\end_layout - -\begin_layout Description - -\family typewriter -HXTYPE_VAL -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXTYPE_VAL -\end_layout - -\end_inset - - -\family default -\series default - Use the integer value specified by -\family typewriter -ival -\family default - and store it in -\family typewriter -*(int -\begin_inset space ~ -\end_inset - -*)ptr -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXTYPE_SVAL -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXTYPE_SVAL -\end_layout - -\end_inset - - -\family default -\series default - Use the memory location specified by -\family typewriter -sval -\family default - and store it in -\family typewriter -*(const char -\begin_inset space ~ -\end_inset - -**)ptr -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXTYPE_BOOL -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXTYPE_BOOL -\end_layout - -\end_inset - - -\family default -\series default - Interpret the supplied argument as a boolean descriptive (must be -\begin_inset Quotes eld -\end_inset - -yes -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - -no -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - -on -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - -off -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - -true -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - -false -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - -0 -\begin_inset Quotes erd -\end_inset - - or -\begin_inset Quotes eld -\end_inset - -1 -\begin_inset Quotes erd -\end_inset - -) and store the result in -\family typewriter -*(int -\begin_inset space ~ -\end_inset - -*)ptr -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXTYPE_STRING -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_STRING -\end_layout - -\end_inset - - -\family default - The argument string is duplicated to a new memory region and the resulting - pointer stored into -\family typewriter -*(char -\begin_inset space ~ -\end_inset - -**)ptr -\family default -. - This incurs an allocation so that subsequently modifying the original argument - string in any way will not falsely propagate. -\end_layout - -\begin_layout Description - -\family typewriter -HXTYPE_STRDQ -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXTYPE_STRDQ -\end_layout - -\end_inset - - -\family default -\series default - The argument string is duplicated to a new memory region and the resulting - pointer is added to the given HXdeque. - Note that you often need to use deferred initialization of the options - table to avoid putting -\family typewriter -NULL -\family default - into the entry. - See section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-pitfalls-static" - -\end_inset - -. -\end_layout - -\begin_layout Standard -The following table lists the types that map to the common integral and - floating-point types. - Signed and unsigned integeral types are processed using -\family typewriter -strtol -\family default - and -\family typewriter -strtoul -\family default -, respectively. - -\family typewriter -strtol -\family default - and -\family typewriter -strtoul -\family default - will be called with automatic base detection. - This usually means that a leading -\begin_inset Quotes eld -\end_inset - -0 -\begin_inset Quotes erd -\end_inset - - indicates the string is given in octal (8) base, a leading -\begin_inset Quotes eld -\end_inset - -0x -\begin_inset Quotes erd -\end_inset - - indicates hexadecimal (16) base, and decimal (10) otherwise. - -\family typewriter -HXTYPE_\SpecialChar softhyphen -LLONG -\family default -, -\family typewriter - HXTYPE_\SpecialChar softhyphen -ULLONG -\family default -, -\family typewriter - HXTYPE_\SpecialChar softhyphen -INT64 -\family default - and -\family typewriter - HXTYPE_\SpecialChar softhyphen -UINT64 -\family default - use -\family typewriter - strtoll -\family default - and/or -\family typewriter - strtoull -\family default -, which may not be available on all platforms. -\begin_inset Separator latexpar -\end_inset - - -\end_layout - -\begin_layout Standard -\align center -\begin_inset Float table -placement H -wide false -sideways false -status open - -\begin_layout Plain Layout -\align center -\begin_inset Tabular -<lyxtabular version="3" rows="12" columns="4"> -<features tabularvalignment="middle"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="bottom"> -<column alignment="center" valignment="top"> -<column alignment="center" valignment="top"> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -\series bold -type -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -Type of pointee -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -type -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\series bold -Type of pointee -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_CHAR -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_CHAR -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -char -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT8 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT8 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int8_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UCHAR -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UCHAR -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -unsigned char -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT8 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT8 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -uint8_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_SHORT -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_SHORT -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -short -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT16 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT16 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int16_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_USHORT -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_USHORT -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -unsigned short -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT16 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT16 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -uint16_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT32 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT32 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int32_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -unsigned int -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT32 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT32 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -uint32_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_LONG -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_LONG -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -long -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT64 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_INT64 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -int64_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_ULONG -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_ULONG -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -unsigned long -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT64 -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_UINT64 -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -uint64_t -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_LLONG -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_LLONG -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -long long -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_FLOAT -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_FLOAT -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -float -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_ULLONG -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_ULLONG -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -unsigned long long -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_DOUBLE -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_DOUBLE -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -double -\end_layout - -\end_inset -</cell> -</row> -<row> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_SIZE_T -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXTYPE_SIZE_T -\end_layout - -\end_inset - - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\family typewriter -size_t -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\end_layout - -\end_inset -</cell> -<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none"> -\begin_inset Text - -\begin_layout Plain Layout - -\end_layout - -\end_inset -</cell> -</row> -</lyxtabular> - -\end_inset - - -\end_layout - -\begin_layout Plain Layout -\begin_inset Caption Standard - -\begin_layout Plain Layout -Integral and floating-point types for the libHX option parser -\end_layout - -\end_inset - - -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HXTYPE_\SpecialChar softhyphen -FLOAT -\family default - and -\family typewriter -HXTYPE_\SpecialChar softhyphen -DOUBLE -\family default - make use of -\family typewriter -strtod -\family default - ( -\family typewriter -strtof -\family default - is not used). - A corresponding -\family typewriter -type -\family default - for the -\begin_inset Quotes eld -\end_inset - -long double -\begin_inset Quotes erd -\end_inset - - format is not specified, but may be implemented on behalf of the user via - a callback (see section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-example-cb" - -\end_inset - -). -\end_layout - -\begin_layout Subsection -Flags -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-flags" - -\end_inset - - -\end_layout - -\begin_layout Standard -Flags can be combined into the -\family typewriter -type -\family default - parameter by OR'ing them. - It is valid to not specify any flags at all, but most flags collide with - one another. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_INC -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_INC -\end_layout - -\end_inset - - -\family default -\series default - Perform an increment on the memory location specified by the -\family typewriter -*(int -\begin_inset space ~ -\end_inset - -*)ptr -\family default - pointer. - Make sure the referenced variable is initialized before! -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_DEC -\family default -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXOPT_DEC -\end_layout - -\end_inset - - -\series default - Perform a decrement on the pointee. -\end_layout - -\begin_layout Standard -Only one of -\family typewriter -HXOPT_\SpecialChar softhyphen -INC -\family default - and -\family typewriter -HXOPT_\SpecialChar softhyphen -DEC -\family default - may be specified at a time, and they require that the base type is -\family typewriter -HXTYPE_\SpecialChar softhyphen -NONE -\family default -, or they will have no effect. - An example may be found in section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-example-incdec" - -\end_inset - -. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_NOT -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_NOT -\end_layout - -\end_inset - - -\family default -\series default - Binary negation of the argument directly after reading it from the command - line into memory. - Any of the three following operations are executed with the already-negated - value. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_OR -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXOPT_OR -\end_layout - -\end_inset - - -\family default -\series default - Binary -\begin_inset Quotes eld -\end_inset - -OR -\begin_inset Quotes erd -\end_inset - -s the pointee with the specified\SpecialChar breakableslash -transformed value. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_AND -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_AND -\end_layout - -\end_inset - - -\family default -\series default - Binary -\begin_inset Quotes eld -\end_inset - -AND -\begin_inset Quotes erd -\end_inset - -s the pointee with the specified\SpecialChar breakableslash -transformed value. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_XOR -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_XOR -\end_layout - -\end_inset - - -\family default -\series default - Binary -\begin_inset Quotes eld -\end_inset - -XOR -\begin_inset Quotes erd -\end_inset - -s the pointee with the specified\SpecialChar breakableslash -transformed value. -\end_layout - -\begin_layout Standard -Only one of ( -\family typewriter -HXOPT_OR -\family default -, -\family typewriter -HXOPT_\SpecialChar softhyphen -AND -\family default -, -\family typewriter -HXOPT_\SpecialChar softhyphen -XOR -\family default -) may be specified at a time, but they can be used with any integral -\family typewriter -type -\family default - ( -\family typewriter -HXTYPE_\SpecialChar softhyphen -UINT -\family default -, -\family typewriter -HXTYPE_\SpecialChar softhyphen -ULONG -\family default -, etc.). - An example can be found in section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-example-mask" - -\end_inset - -. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_OPTIONAL -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_OPTIONAL -\end_layout - -\end_inset - - -\family default -\series default - This flag allows for an option to take zero or one argument. - Needless to say that this can be confusing to the user. - -\shape italic -iptables -\shape default -'s -\begin_inset Quotes eld -\end_inset - - -\family typewriter --L -\family default - -\begin_inset Quotes erd -\end_inset - - option for example is one of this kind (though it does not use the libHX - option parser). - When this flag is used, -\begin_inset Quotes eld -\end_inset - - -\family typewriter --f -b -\family default - -\begin_inset Quotes erd -\end_inset - - is interpreted as -\family typewriter --f -\family default - without an argument, as is -\begin_inset Quotes eld -\end_inset - - -\family typewriter --f --bar -\family default - -\begin_inset Quotes erd -\end_inset - - -\begin_inset space ~ -\end_inset - -— things that look like an option take precedence over an option with an - optional argument. - -\begin_inset Quotes eld -\end_inset - - -\family typewriter --f - -\family default - -\begin_inset Quotes erd -\end_inset - - of course denotes an option with an argument, as -\begin_inset Quotes eld -\end_inset - - -\family typewriter -- -\family default - -\begin_inset Quotes erd -\end_inset - - is used to indicate standard input/output. -\end_layout - -\begin_layout Subsection -Special entries -\end_layout - -\begin_layout Standard -HXopt provides two special entries via macros: -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_AUTOHELP -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_AUTOHELP -\end_layout - -\end_inset - - -\family default -\series default - Adds entries to recognize -\begin_inset Quotes eld -\end_inset - - -\family typewriter --? -\family default - -\begin_inset Quotes erd -\end_inset - - and -\begin_inset Quotes eld -\end_inset - - -\family typewriter ---help -\family default - -\begin_inset Quotes erd -\end_inset - - that will display the (long-format) help screen, and -\begin_inset Quotes eld -\end_inset - - -\family typewriter ---usage -\family default - -\begin_inset Quotes erd -\end_inset - - that will display the short option syntax overview. - All three options will exit the program afterwards. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_TABLEEND -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_TABLEEND -\end_layout - -\end_inset - - -\family default -\series default - This sentinel marks the end of the table and is required on all tables. - (See examples for details.) -\end_layout - -\begin_layout Subsection -Invoking the parser -\end_layout - -\begin_layout LyX-Code - -\series bold -int -\series default - HX_getopt( -\series bold -const struct -\series default - HXoption -\series bold -* -\series default -options_table, -\series bold -int * -\series default -argc, -\begin_inset Newline newline -\end_inset - - -\series bold -const char *** -\series default -argv, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_getopt -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard - -\family typewriter -HX_getopt -\family default - is the actual parsing function. - It takes the option table, and a pointer to your -\family typewriter -argc -\family default - and -\family typewriter -argv -\family default - variables that you get from the -\family typewriter -main -\family default - function. - The parser will, unlike GNU getopt, literally -\begin_inset Quotes eld -\end_inset - -eat -\begin_inset Quotes erd -\end_inset - - all options and their arguments, leaving only non-options in -\family typewriter -argv -\family default -, and -\family typewriter -argc -\family default - updated, when finished. - This is similar to how Perl's -\begin_inset Quotes eld -\end_inset - -Getopt::Long -\begin_inset Quotes erd -\end_inset - - module works. - Additional flags can control the exact behavior of -\family typewriter -HX_getopt -\family default -: -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_PTHRU -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_PTHRU -\end_layout - -\end_inset - - -\family default -\series default - -\begin_inset Quotes eld -\end_inset - -Passthrough mode -\begin_inset Quotes erd -\end_inset - -. - Any unknown options are not -\begin_inset Quotes eld -\end_inset - -eaten -\begin_inset Quotes erd -\end_inset - - and are instead passed back into the resulting -\family typewriter -argv -\family default - array. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_QUIET -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_QUIET -\end_layout - -\end_inset - - -\family default -\series default - Do not print any diagnostics when encountering errors in the user's input. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_HELPONERR -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXOPT_HELPONERR -\end_layout - -\end_inset - - -\family default -\series default - Display the (long-format) help when an error, such as an unknown option - or a violation of syntax, is encountered. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_USAGEONERR -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXOPT_USAGEONERR -\end_layout - -\end_inset - - -\family default -\series default - Display the short-format usage syntax when an error is encountered. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_RQ_ORDER -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXOPT_RQ_ORDER -\end_layout - -\end_inset - - Specifying this option terminates option processing when the first non-option - argument in -\family typewriter -argv -\family default - is encountered. - This behavior is also implicit when the environment variable -\family typewriter -POSIXLY_CORRECT -\family default - is set. -\end_layout - -\begin_layout Standard -The return value can be one of the following: -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_ERR_SUCCESS -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXOPT_ERR_SUCCESS -\end_layout - -\end_inset - - Parsing was successful. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_ERR_UNKN -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_ERR_UNKN -\end_layout - -\end_inset - - -\family default -\series default - An unknown option was encountered. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_ERR_VOID -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_ERR_VOID -\end_layout - -\end_inset - - -\family default -\series default - An argument was given for an option which does not allow one. - In practice this only happens with -\begin_inset Quotes eld -\end_inset - - -\family typewriter ---foo=bar -\family default - -\begin_inset Quotes erd -\end_inset - - when -\family typewriter ---foo -\family default - is of type -\family typewriter -HXTYPE_\SpecialChar softhyphen -NONE -\family default -, -\family typewriter -HXTYPE_\SpecialChar softhyphen -VAL -\family default - or -\family typewriter -HXTYPE_\SpecialChar softhyphen -SVAL -\family default -. - This does not affect -\begin_inset Quotes eld -\end_inset - - -\family typewriter ---foo bar -\family default - -\begin_inset Quotes erd -\end_inset - -, because this can be unambiguously interpreted as -\begin_inset Quotes eld -\end_inset - - -\family typewriter -bar -\family default - -\begin_inset Quotes erd -\end_inset - - being a remaining argument to the program. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_ERR_MIS -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_ERR_MIS -\end_layout - -\end_inset - - -\family default -\series default - Missing argument for an option that requires one. -\end_layout - -\begin_layout Description - -\family typewriter -HXOPT_ERR_AMBIG -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXOPT_ERR_AMBIG -\end_layout - -\end_inset - - -\family default -\series default - An abbreviation of a long option was ambiguous. -\end_layout - -\begin_layout Description -negative -\begin_inset space ~ -\end_inset - -non-zero Failure on behalf of lower-level calls; errno. -\end_layout - -\begin_layout Subsection -Pitfalls -\end_layout - -\begin_layout Subsubsection -Staticness of tables -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-pitfalls-static" - -\end_inset - - -\end_layout - -\begin_layout Standard -The following is an example of a possible pitfall regarding -\family typewriter -HXTYPE_\SpecialChar softhyphen -STRDQ -\family default -: -\end_layout - -\begin_layout LyX-Code - -\series bold -static struct -\series default - HXdeque -\series bold -* -\series default -dq; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static bool -\series default - get_options( -\series bold -int * -\series default -argc, -\series bold -const char *** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -static const struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.sh = 'N', .type = HXTYPE_STRDQ, .q_strdq = dq, -\begin_inset Newline newline -\end_inset - - .help = "Add name"}, -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - HX_getopt(options_table, argc, argv, HXOPT_USAGEONERR) == -\begin_inset Newline newline -\end_inset - - HXOPT_ERR_SUCCESS; -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - main( -\series bold -int -\series default - argc, -\series bold -const char ** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - dq = HXdeque_init(); -\begin_inset Newline newline -\end_inset - - get_options(&argc, &argv); -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - 0; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Standard -The problem here is that -\family typewriter -options_\SpecialChar softhyphen -table -\family default - is, due to the -\family typewriter -static -\family default - keyword, initialized at compile-time where -\family typewriter -dq -\family default - is still -\family typewriter -NULL -\family default -. - To counter this problem and have it doing the right thing, you must remove - the -\family typewriter -static -\family default - qualifier on the options table when used with -\family typewriter -HXTYPE_\SpecialChar softhyphen -STRDQ -\family default -, so that it will be evaluated when it is first executed. -\end_layout - -\begin_layout Standard -It was not deemed worthwhile to have -\family typewriter -HXTYPE_\SpecialChar softhyphen -STRDQ -\family default - take an indirect HXdeque ( -\family typewriter -struct HXdeque -\begin_inset space ~ -\end_inset - -** -\family default -) instead just to bypass this issue. - (Live with it.) -\end_layout - -\begin_layout Subsection -Limitations -\end_layout - -\begin_layout Standard -The HX option parser has been influenced by both popt and Getopt::Long, - but eventually, there are differences: -\end_layout - -\begin_layout Itemize -Long options with a single dash ( -\begin_inset Quotes eld -\end_inset - - -\family typewriter --foo bar -\family default - -\begin_inset Quotes erd -\end_inset - -). - This unsupported syntax clashes very easily with support for option bundling - or squashing. - In case of bundling, -\begin_inset Quotes eld -\end_inset - - -\family typewriter --foo -\family default - -\begin_inset Quotes erd -\end_inset - - might actually be -\begin_inset Quotes eld -\end_inset - - -\family typewriter --f -o -o -\family default - -\begin_inset Quotes erd -\end_inset - -, or -\begin_inset Quotes eld -\end_inset - - -\family typewriter --f oo -\family default - -\begin_inset Quotes erd -\end_inset - - in case of squashing. - It also introduces redundant ways to specify options, which is not in the - spirit of the author. -\end_layout - -\begin_layout Itemize -Options using a -\begin_inset Quotes eld -\end_inset - - -\family typewriter -+ -\family default - -\begin_inset Quotes erd -\end_inset - - as a prefix, as in -\begin_inset Quotes eld -\end_inset - - -\family typewriter -+foo -\family default - -\begin_inset Quotes erd -\end_inset - -. - Xterm for example uses it as a way to negate an option. - In the author's opinion, using one character to specify options is enough -\begin_inset space ~ -\end_inset - -— by GNU standards, a negator is named -\begin_inset Quotes eld -\end_inset - - -\family typewriter ---no-foo -\family default - -\begin_inset Quotes erd -\end_inset - -. - Even Microsoft stuck to a single option introducing character (that would - be -\begin_inset Quotes eld -\end_inset - - -\family typewriter -/ -\family default - -\begin_inset Quotes erd -\end_inset - -). -\end_layout - -\begin_layout Itemize -Table nesting like implemented in popt. - HXopt has no provision for nested tables, as the need has not come up yet. - It does however support chained processing (see section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-example-chained" - -\end_inset - -). - You cannot do nested tables even with callbacks, as the new -\family typewriter -argv -\family default - array is only put in place shortly before -\family typewriter -HX_getopt -\family default - returns. -\end_layout - -\begin_layout Subsection -Examples -\end_layout - -\begin_layout Subsubsection -Basic example -\end_layout - -\begin_layout Standard -The following code snippet should provide an equivalent of the GNU getopt - sample -\begin_inset Foot -status open - -\begin_layout Plain Layout -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -http://www.gnu.org/software/libtool/manual/libc/Example-of-Getopt.html -\backslash -#Example-of-Getopt -\end_layout - -\end_inset - - -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <stdio.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <stdilb.h> -\begin_inset Newline newline -\end_inset - - -\series bold -#include -\series default - <libHX/option.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - main( -\series bold -int -\series default - argc, -\series bold -const char ** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - aflag = 0; -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - bflag = 0; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -cflag = NULL; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.sh = 'a', .type = HXTYPE_NONE, .ptr = &aflag}, -\begin_inset Newline newline -\end_inset - - {.sh = 'b', .type = HXTYPE_NONE, .ptr = &bflag}, -\begin_inset Newline newline -\end_inset - - {.sh = 'c', .type = HXTYPE_STRING, .ptr = &cflag}, -\begin_inset Newline newline -\end_inset - - HXOPT_AUTOHELP, -\end_layout - -\begin_layout LyX-Code - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR) != -\begin_inset Newline newline -\end_inset - - HXOPT_ERR_SUCCESS) -\end_layout - -\begin_layout LyX-Code - -\series bold -return -\series default - EXIT_FAILURE; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - printf("aflag = %d, bflag = %d, cvalue = %s -\backslash -n", -\begin_inset Newline newline -\end_inset - - aflag, bflag, cvalue); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -while -\series default - (*++argv != NULL) -\begin_inset Newline newline -\end_inset - - printf("Non-option argument %s -\backslash -n", *argv); -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - EXIT_SUCCESS; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Subsubsection -Verbosity levels -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-example-incdec" - -\end_inset - - -\end_layout - -\begin_layout LyX-Code - -\series bold -static int -\series default - verbosity = 1; -\series bold -/* -\family roman -\series default -\shape italic -somewhat silent by default -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold -static const struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.sh = 'q', .type = HXTYPE_NONE | HXOPT_DEC, .q_int = &verbosity, -\begin_inset Newline newline -\end_inset - - .help = "Reduce verbosity"}, -\begin_inset Newline newline -\end_inset - - {.sh = 'v', .type = HXTYPE_NONE | HXOPT_INC, .q_int = &verbosity, -\begin_inset Newline newline -\end_inset - - .help = "Increase verbosity"}, -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Standard -This sample option table makes it possible to turn the verbosity of the - program up or down, depending on whether the user specified -\family typewriter --q -\family default - or -\family typewriter --v -\family default -. - By passing multiple -\family typewriter --v -\family default - flags, the verbosity can be turned up even more. - The range depends on the -\begin_inset Quotes eld -\end_inset - - -\family typewriter -int -\family default - -\begin_inset Quotes erd -\end_inset - - data type for your particular platform and compiler; if you want to have - the verbosity capped at a specific level, you will need to use an extra - callback: -\end_layout - -\begin_layout LyX-Code - -\series bold -static int -\series default - verbosity = 1; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static void -\series default - v_check( -\series bold -const struct -\series default - HXoptcb -\series bold -* -\series default -cbi) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (verbosity < 0) -\begin_inset Newline newline -\end_inset - - verbosity = 0; -\begin_inset Newline newline -\end_inset - - -\series bold -else if -\series default - (verbosity > 4) -\begin_inset Newline newline -\end_inset - - verbosity = 4; -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static const struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.sh = 'q', .type = HXTYPE_NONE | HXOPT_DEC, .q_int = &verbosity, -\begin_inset Newline newline -\end_inset - - .cb = v_check, .help = "Lower verbosity"}, -\begin_inset Newline newline -\end_inset - - {.sh = 'v', .type = HXTYPE_NONE | HXOPT_INC, .q_int = &verbosity, -\begin_inset Newline newline -\end_inset - - .cb = v_check, .help = "Raise verbosity"}, -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Subsubsection -Mask operations -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-example-mask" - -\end_inset - - -\end_layout - -\begin_layout LyX-Code - -\series bold -/* -\family roman -\series default -\shape italic -run on all CPU cores by default -\family default -\series bold -\shape default - * -\series default -/ -\begin_inset Newline newline -\end_inset - - -\series bold -static unsigned int -\series default - cpu_mask = ~0U -\series bold -; -\begin_inset Newline newline -\end_inset - -/* -\family roman -\series default -\shape italic -use no network connections by default -\family default -\shape default - -\series bold -*/ -\begin_inset Newline newline -\end_inset - -static unsigned int -\series default - net_mask = 0; -\series bold - -\begin_inset Newline newline -\end_inset - -static struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.sh = 'c', .type = HXTYPE_UINT | HXOPT_NOT | HXOPT_AND, -\begin_inset Newline newline -\end_inset - - .q_uint = &cpu_mask, -\begin_inset Newline newline -\end_inset - - .help = "Mask of cores to exclude", .htyp = "cpu_mask"}, -\begin_inset Newline newline -\end_inset - - {.sh = 'n', .type = HXTYPE_UINT | HXOPT_OR, .q_uint = &net_mask, -\end_layout - -\begin_layout LyX-Code - .help = "Mask of network channels to additionally use", -\begin_inset Newline newline -\end_inset - - .htyp = "channel_mask"}, -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Standard -What this options table does is -\family typewriter -cpu_mask &= ~x -\family default - and -\family typewriter -net_mask |= y -\family default -, the classic operations of clearing and setting bits. -\end_layout - -\begin_layout Subsubsection -Support for non-standard actions -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-example-cb" - -\end_inset - - -\end_layout - -\begin_layout Standard -Supporting additional types or custom storage formats is easy, by simply - using -\family typewriter -HXTYPE_\SpecialChar softhyphen -STRING -\family default -, -\family typewriter -NULL -\family default - as the data pointer (usually by not specifying it at all), the pointer - to your data in the user-specified pointer -\family typewriter -uptr -\family default -, and the callback function in -\family typewriter -cb -\family default -. -\end_layout - -\begin_layout LyX-Code - -\series bold -struct -\series default - fixed_point { -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - integral; -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - fraction; -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static struct -\series default - fixed_point number; -\end_layout - -\begin_layout LyX-Code -\begin_inset Newline newline -\end_inset - - -\series bold -static void -\series default - fixed_point_parse -\series bold -(const struct -\series default - HXoptcb -\series bold - -\series default -*cbi) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -end; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - number.integral = strtol(cbi->data, &end, 0); -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (*end == ' -\backslash -0') -\begin_inset Newline newline -\end_inset - - number.fraction = 0; -\begin_inset Newline newline -\end_inset - - -\series bold -else if -\series default - (*end == '.') -\begin_inset Newline newline -\end_inset - - number.fraction = strtoul(end + 1, NULL, 0); -\begin_inset Newline newline -\end_inset - - -\series bold -else -\series default - -\begin_inset Newline newline -\end_inset - - fprintf(stderr, "Illegal input. -\backslash -n"); -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\series bold - -\begin_inset Newline newline -\end_inset - -static const struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.sh = 'n', .type = HXTYPE_STRING, .cb = fixed_point_parse, -\begin_inset Newline newline -\end_inset - - .uptr = &number, .help = "Do this or that", -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\end_layout - -\begin_layout LyX-Code -}; -\end_layout - -\begin_layout Subsubsection -Chained argument processing -\begin_inset CommandInset label -LatexCommand label -name "subsec:option-example-chained" - -\end_inset - - -\end_layout - -\begin_layout Standard -On the first run, only -\family typewriter ---cake -\family default - and -\family typewriter ---fruit -\family default - is considered, which is then used to select the next set of accepted options. - Note that -\family typewriter -HXOPT_\SpecialChar softhyphen -DESTROY_\SpecialChar softhyphen -OLD -\family default - is used here, which causes the argv that is produced by the first invocation - of -\family typewriter -HX_getopt -\family default - in the -\family typewriter -get_options -\family default - function to be freed as it gets replaced by a new argv again by -\family typewriter -HX_getopt -\family default - in -\family typewriter -get_cakes -\family default -\SpecialChar breakableslash - -\family typewriter -get_fruit -\family default -. - -\family typewriter -HXOPT_\SpecialChar softhyphen -DESTROY_\SpecialChar softhyphen -OLD -\family default - is however -\shape italic -not -\shape default - specified in the first invocation, because the initial argv resides on - the stack and cannot be freed. -\end_layout - -\begin_layout LyX-Code - -\series bold -static bool -\series default - get_cakes( -\series bold -int * -\series default -argc, -\series bold -const char *** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXoption option_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - ... -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - HX_getopt(cake_table, argc, argv, -\begin_inset Newline newline -\end_inset - - HXOPT_USAGEONERR | HXOPT_DESTROY_OLD) == HXOPT_ERR_SUCCESS; -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static bool -\series default - get_fruit( -\series bold -int * -\series default -argc, -\series bold -const char *** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXoption fruit_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - ... -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - HX_getopt(fruit_table, argc, argv, -\begin_inset Newline newline -\end_inset - - HXOPT_USAGEONERR | HXOPT_DESTROY_OLD) == HXOPT_ERR_SUCCESS; -\begin_inset Newline newline -\end_inset - -} -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -static bool -\series default - get_options( -\series bold -int * -\series default -argc, -\series bold -const char *** -\series default -argv) -\begin_inset Newline newline -\end_inset - -{ -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - cake = 0, fruit = 0; -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXoption option_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.ln = "cake", .type = HXTYPE_NONE, .ptr = &cake}, -\begin_inset Newline newline -\end_inset - - {.ln = "fruit", .type = HXTYPE_NONE, .ptr = &fruit}, -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - - }; -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (HX_getopt(option_table, argc, argv, HXOPT_PTHRU) != -\begin_inset Newline newline -\end_inset - - HXOPT_ERR_SUCCESS) -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - false; -\begin_inset Newline newline -\end_inset - - -\series bold -if -\series default - (cake) -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - get_cakes(argc, argv); -\begin_inset Newline newline -\end_inset - - -\series bold -else if -\series default - (fruit) -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - get_fruit(argc, argv); -\begin_inset Newline newline -\end_inset - - -\series bold -return -\series default - false; -\begin_inset Newline newline -\end_inset - -} -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Shell-style configuration file parser -\begin_inset CommandInset label -LatexCommand label -name "sec:shconf" - -\end_inset - - -\end_layout - -\begin_layout Standard -libHX provides functions to read shell-style configuration files. - Such files are common, for example, in -\family typewriter -/etc/sysconfig -\family default - on Linux systems. - The format is pretty basic; it only knows about -\begin_inset Quotes eld -\end_inset - - -\family typewriter -key=value -\family default - -\begin_inset Quotes erd -\end_inset - - pairs and does not even have sections like INI files. - Not relying on any features however makes them quite interchangable as - the syntax is accepted by Unix Shells. -\end_layout - -\begin_layout Standard -Lines beginning with a hash mark ( -\family typewriter -# -\family default -) are ignored, as are empty lines and unrecognized keys. -\end_layout - -\begin_layout LyX-Code - -\series bold -# Minimum / maximum values for automatic UID selection -\series default - -\begin_inset Newline newline -\end_inset - -UID_MIN=100 -\begin_inset Newline newline -\end_inset - -UID_MAX=65000 -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -# Home directory base -\series default - -\begin_inset Newline newline -\end_inset - -HOME="/home" -\begin_inset Newline newline -\end_inset - -#HOME="/export/home" -\end_layout - -\begin_layout Standard -Any form of variable or parameter substitution or expansion is highly implementa -tion specific, and is not supported in libHX's reader. - Even Shell users should not rely on it as you never know in which context - the configuration files are evaluated. - Still, you will have to escape specific sequences like you would need to - in Shell. - The use of single quotes is acceptable. - That means: -\end_layout - -\begin_layout LyX-Code -AMOUNT="US -\backslash -$5" -\begin_inset Newline newline -\end_inset - -AMOUNT='US$5' -\end_layout - -\begin_layout Subsection -Synopsis -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/option.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/option.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_shconfig( -\series bold -const char * -\series default -file, -\series bold -const struct -\series default - HXoption -\series bold -* -\series default -table); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_shconfig -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_shconfig_pv( -\series bold -const char ** -\series default -path_vec, -\series bold -const char * -\series default -file, -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - HXoption -\series bold -* -\series default -table, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_shconfig_pv -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXmap -\series bold -* -\series default -HX_shconfig_map( -\series bold -const char * -\series default -file); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_shconfig_map -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -The shconfig parser reuses -\family typewriter -struct HXoption -\family default - that fits very well in specifying name-pointer associations. - -\family typewriter -HX_shconfig -\family default - will read the given file using the key-to-pointer mappings from the table - to store the variable contents. - Of -\family typewriter -struct HXoption -\family default -, described in section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-synopsis" - -\end_inset - -, only the -\begin_inset Quotes eld -\end_inset - - -\family typewriter -ln -\family default - -\begin_inset Quotes erd -\end_inset - -, -\begin_inset Quotes eld -\end_inset - - -\family typewriter -type -\family default - -\begin_inset Quotes erd -\end_inset - - and -\begin_inset Quotes eld -\end_inset - - -\family typewriter -ptr -\family default - -\begin_inset Quotes erd -\end_inset - - fields are used. - The list of accepted types is described in section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:option-types" - -\end_inset - -. -\end_layout - -\begin_layout Standard -To parse a file, call -\family typewriter -HX_shconfig -\family default - function with the corresponding parameters. - If you want to read configuration files from different paths, i. -\begin_inset space \thinspace{} -\end_inset - -e. -\begin_inset space \space{} -\end_inset - -to build up on default values, you can use -\family typewriter -HX_shconfig_pv -\family default - -\begin_inset Foot -status open - -\begin_layout Plain Layout -pv = path vector -\end_layout - -\end_inset - -, which is a variant for reading a file from multiple locations. - Its purpose is to facilitate reading system-wide settings which are then - overriden by a file in the users home directory, for example (per-setting-overr -ide). - It is also possible to do per-file-override, that is, a file in the home - directory has higher precedence than a system-wide one in such a way that - the system-wide configuration file is not even read. - This is accomplished by traversing the paths in the -\begin_inset Quotes eld -\end_inset - -other -\begin_inset Quotes erd -\end_inset - - direction (actually you have to turn the array around) and stopping at - the first existing file by use of the -\family typewriter -SHCONF_\SpecialChar softhyphen -ONE -\family default - flag. -\end_layout - -\begin_layout Standard - -\family typewriter -HX_shconfig_map -\family default - will return all entries from the file in a HXmap, usable for parsing arbitrary - keys without having to specify any static key table. -\end_layout - -\begin_layout Description - -\family typewriter -SHCONF_ONE -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -SHCONF_ONE -\end_layout - -\end_inset - - -\family default -\series default - Parsing files will stop after one file has been successfully parsed. - This allows for a -\begin_inset Quotes eld -\end_inset - -personal overrides system config -\begin_inset Quotes erd -\end_inset - - style. -\end_layout - -\begin_layout Standard -The call to -\family typewriter -HX_shconfig -\family default - will either return >0 for success, 0 for no success (actually, this is - never returned) and -\family typewriter --errno -\family default - for an error. -\end_layout - -\begin_layout Subsection -Example -\end_layout - -\begin_layout Subsubsection -Per-setting-override -\end_layout - -\begin_layout Standard -This example sources key-value pairs from a configuration file in a system - location ( -\family typewriter -/etc -\family default -) first, before overriding specific keys with new values from the file in - the home directory. -\end_layout - -\begin_layout LyX-Code - -\series bold -long -\series default - uid_min, uid_max; -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -passwd_file; -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXoption options_table -\series bold -[] -\series default - = { -\begin_inset Newline newline -\end_inset - - {.ln = "UID_MIN", .type = HXTYPE_LONG, .ptr = &uid_min}, -\begin_inset Newline newline -\end_inset - - {.ln = "UID_MAX", .type = HXTYPE_LONG, .ptr = &uid_max}, -\begin_inset Newline newline -\end_inset - - {.ln = "PWD_FILE", .type = HXTYPE_STRING, .ptr = &passwd_file}, -\begin_inset Newline newline -\end_inset - - HXOPT_TABLEEND, -\begin_inset Newline newline -\end_inset - -}; -\begin_inset Newline newline -\end_inset - - -\series bold -const char * -\series default -home = getenv("HOME"); -\begin_inset Newline newline -\end_inset - - -\series bold -const char * -\series default -paths -\series bold -[] -\series default - = {"/etc", home, NULL}; -\begin_inset Newline newline -\end_inset - -HX_shconfig(paths, "test.cf", options_table, 0); -\end_layout - -\begin_layout Subsubsection -Per-file-override -\end_layout - -\begin_layout Standard -This particular example reads from the file in the home directory first - (if it exists), but stops after it has been successfull, so any subsequent - locations listed in the -\family typewriter -paths -\family default - variable are not read. - This has the effect that the file from the home directory has the highest - priority too like in the previous example, but without any keys from the - system files. - Note the -\family typewriter -SHCONF_ONE -\family default - flag. -\end_layout - -\begin_layout LyX-Code - -\series bold -const char * -\series default -home = getenv("HOME"); -\begin_inset Newline newline -\end_inset - - -\series bold -const char * -\series default -paths -\series bold -[] -\series default - = {home, "/usr/local/etc", "/etc", NULL}; -\begin_inset Newline newline -\end_inset - -HX_shconfig_pv(paths, "test.cf", options_table, SHCONF_ONE); -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Part -Systems-related components -\end_layout - -\begin_layout Section -Random numbers -\begin_inset CommandInset label -LatexCommand label -name "sec:random" - -\end_inset - - -\end_layout - -\begin_layout Subsection -Function overview -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/misc.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/misc.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HX_rand( -\series bold -void -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_rand -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - HX_irand( -\series bold -unsigned int -\series default - min, -\series bold -unsigned int -\series default - max); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_irand -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -double -\series default - HX_drand( -\series bold -double -\series default - min, -\series bold -double -\series default - max); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_drand -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HX_rand -\family default - Retrieve the next random number. -\end_layout - -\begin_layout Description - -\family typewriter -HX_irand -\family default - Retrieve the next random number and fold it so that -\begin_inset Formula $\textit{min}\le n<\textit{max}$ -\end_inset - -, where min and max are unsigned integers. -\end_layout - -\begin_layout Description - -\family typewriter -HX_drand -\family default - Retrieve the next random number and fold it so that -\begin_inset Formula $\textit{min}\le n<\textit{max}$ -\end_inset - -, where min and max are double-precision floating point numbers. -\end_layout - -\begin_layout Subsection -Implementation information -\end_layout - -\begin_layout Standard -On systems that provide operating system-level random number generators, - predominantly Linux and Unix-alikes such as BSD and Solaris, these will - be used when they are available and random numbers are requested through - -\family typewriter -HX_rand -\family default - or -\family typewriter -HX_irand -\family default -. -\end_layout - -\begin_layout Standard -On Linux, Solaris and the BSDs, this is -\family typewriter -/dev/urandom -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -/dev/urandom -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Standard -If no random number generating device is available (and libHX configured - to use it), it will fall back to using the libc's -\family typewriter -rand -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -rand -\end_layout - -\end_inset - - function. - If libc is selected for random number generation, -\family typewriter -srand -\family default - will be called on library initialization with what is believed to be good - defaults -\begin_inset space ~ -\end_inset - -— usually this will be before a program's -\family typewriter -main -\family default - function with normal linking, but may actually happen later when used with - -\family typewriter -dlopen -\family default -. - The initial seed would be the current microtime when -\family typewriter -gettimeofday -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -gettimeofday -\end_layout - -\end_inset - - -\family default - is available, or just the seconds with -\family typewriter -time -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -time -\end_layout - -\end_inset - -. - To counter the problem of different programs potentially using the same - seed within a time window of a second due to the limited granularity of - standard -\family typewriter -time -\family default -, the seed is augmented by process ID and parent process ID where available. -\end_layout - -\begin_layout Standard - -\family typewriter -/dev/random -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -/dev/random -\end_layout - -\end_inset - - -\family default - is not used on Linux because it may block during read, and -\family typewriter -/dev/urandom -\family default - is just as good when there is entropy available. - If you need definitive PRNG -\begin_inset Index idx -status open - -\begin_layout Plain Layout -PRNG -\end_layout - -\end_inset - - security, perhaps use one from a crypto suite such as OpenSSL. -\end_layout - -\begin_layout Standard -\begin_inset Newpage clearpage -\end_inset - - -\end_layout - -\begin_layout Section -Process management -\begin_inset CommandInset label -LatexCommand label -name "sec:proc" - -\end_inset - - -\end_layout - -\begin_layout Standard -The process code is experimental at this stage (just moved from the pam_mount - codebase). - As it also relies on the POSIX functions -\family typewriter -fork -\family default -, -\family typewriter -execv -\family default -, -\family typewriter -execvp -\family default - and -\family typewriter -pipe -\family default -(2), so it may not be available everywhere. - Where this is the case, the functions will return -\family typewriter --ENOSYS -\family default -. -\end_layout - -\begin_layout Subsection -Process metadata structure -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/proc.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/proc.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXproc { -\begin_inset Newline newline -\end_inset - - -\series bold -const struct -\series default - HXproc_ops -\series bold -* -\series default -p_ops; -\begin_inset Newline newline -\end_inset - - -\series bold -void * -\series default -p_data; -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned int -\series default - p_flags; -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -/* -\family roman -\series default -\shape italic -Following members should only be read -\family default -\series bold -\shape default - */ -\series default - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - p_stdin, p_stdout, p_stderr; -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - p_pid; -\begin_inset Newline newline -\end_inset - - -\series bold -char -\series default - p_status; -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - p_exited, p_terminated; -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Standard -When creating a new process with the intent of running it asynchronously - (using -\family typewriter -HXproc_\SpecialChar softhyphen -run_\SpecialChar softhyphen -async -\family default -), the first three fields must be filled in by the user. -\end_layout - -\begin_layout Description - -\family typewriter -p_ops -\family default - A table of callbacks, generally used for setting and/or restoring signals - before/after execution. - This member may be -\family typewriter -NULL -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -p_data -\family default - Free pointer for the user to supply. - Will be passed to the callback functions when they are invoked. -\end_layout - -\begin_layout Description - -\family typewriter -p_flags -\family default - Process creation flags, see below. -\end_layout - -\begin_layout Standard -After the subprocess has been started, -\family typewriter -HXproc_run_async -\family default - will have filled in some fields: -\end_layout - -\begin_layout Description - -\family typewriter -p_stdin -\family default - If -\family typewriter -HXPROC_STDIN -\family default - was specified in -\family typewriter -p_flags -\family default -, -\family typewriter -p_stdin -\family default - will be assigned the write side file descriptor of the subprocess's to-be - stdin. - The subprocess will get the read side file descriptor in this member. - This is so that the correct fd is used in when -\family typewriter -p_ops->p_postfork -\family default - is called. -\end_layout - -\begin_layout Description - -\family typewriter -p_stdout -\family default - If -\family typewriter -HXPROC_STDOUT -\family default - is specified in -\family typewriter -p_flags -\family default -, -\family typewriter -p_stdout -\family default - will be assigned the read side file descriptor of the subprocess's to-be - stdout. - The subprocess will get the write side file descriptor in this member. -\end_layout - -\begin_layout Description - -\family typewriter -p_stderr -\family default - If -\family typewriter -HXPROC_STDERR -\family default - is specified in -\family typewriter -p_flags -\family default -, -\family typewriter -p_stderr -\family default - will be assigned the read side file descriptor of the subprocess's to-be - stderr, and the subprocess will get the write side fd. -\end_layout - -\begin_layout Description - -\family typewriter -p_pid -\family default - The process ID of the spawned process. -\end_layout - -\begin_layout Standard -Upon calling -\family typewriter -HXproc_wait -\family default -, further fields will have been filled when the function returns: -\end_layout - -\begin_layout Description - -\family typewriter -p_exited -\family default - Whether the process exited normally (cf. -\begin_inset space \space{} -\end_inset - -signalled\SpecialChar breakableslash -terminated). -\end_layout - -\begin_layout Description - -\family typewriter -p_terminated -\family default - Whether the process was terminated (signalled). -\end_layout - -\begin_layout Description - -\family typewriter -p_status -\family default - The exit status of the process or the termination signal. -\end_layout - -\begin_layout Subsubsection -Flags -\begin_inset CommandInset label -LatexCommand label -name "subsec:proc-pflags" - -\end_inset - - -\end_layout - -\begin_layout Standard -Possible values for the -\family typewriter -p_flags -\family default - member are: -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_STDIN -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_STDIN -\end_layout - -\end_inset - - -\family default -\series default - The subprocess's stdin file descriptor shall be connected to the master - program, that is, not inherit the stdin of the master. - Cannot be used for -\family typewriter -HXproc_\SpecialChar softhyphen -run_\SpecialChar softhyphen -sync -\family default - (because there would be no one to provide data in a sync operation). -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_STDOUT -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXPROC_STDOUT -\end_layout - -\end_inset - - -\family default -\series default - Connect the stdout file descriptor of the subprocess with the master. - Cannot be used for -\family typewriter -HXproc_run_sync -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_STDERR -\series medium - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\series medium -HXPROC_STDERR -\end_layout - -\end_inset - - -\family default -\series default - Connect the stderr file descriptor of the subprocess with the master. - Cannot be used for -\family typewriter -HXproc_run_sync -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_NULL_STDIN -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_NULL_STDIN -\end_layout - -\end_inset - - The subprocess's stdin file descriptor shall be connected to -\family typewriter -/dev\SpecialChar breakableslash -null -\family default -. - -\family typewriter -HXPROC_\SpecialChar softhyphen -STDIN -\family default - and -\family typewriter -HXPROC_\SpecialChar softhyphen -NULL_\SpecialChar softhyphen -STDIN -\family default - are mutually exclusive. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_NULL_STDOUT -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_NULL_STDOUT -\end_layout - -\end_inset - - Connect the stdout file descriptor of the subprocess to -\family typewriter -/dev\SpecialChar breakableslash -null -\family default -, thereby essentially discarding its output. - -\family typewriter -HXPROC_\SpecialChar softhyphen -STDOUT -\family default - and -\family typewriter -HXPROC_\SpecialChar softhyphen -NULL_\SpecialChar softhyphen -STDOUT -\family default - are mutuall exclusive. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_NULL_STDERR -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_NULL_STDERR -\end_layout - -\end_inset - - Connect the stderr file descriptor of the subprocess to -\family typewriter -/dev\SpecialChar breakableslash -null -\family default -, thereby essentially discarding its output. - -\family typewriter -HXPROC_\SpecialChar softhyphen -STDERR -\family default - and -\family typewriter -HXPROC_\SpecialChar softhyphen -NULL_\SpecialChar softhyphen -STDERR -\family default - are mutually exclusive. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_VERBOSE -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_VERBOSE -\end_layout - -\end_inset - - Have the subprocess print an error message to stderr if exec'ing returned - an error. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_A0 -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_A0 -\end_layout - -\end_inset - - -\family typewriter -argv[0] -\family default - refers to program file, while -\family typewriter -argv[1] -\family default - to the program invocation name, with -\family typewriter -argv[2] -\family default - being the arguments. - Without this flag, -\family typewriter -argv[0] -\family default - will be both the program file and program invocation name, and arguments - begin at -\family typewriter -argv[1] -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -HXPROC_EXECV -\family default - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HXPROC_EXECV -\end_layout - -\end_inset - - Normally, -\family typewriter -execvp -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -execvp -\end_layout - -\end_inset - - will be used which scans -\family typewriter -$PATH -\family default - for the program. - Use this flag to use -\family typewriter -execv -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -execv -\end_layout - -\end_inset - - instead, which will not do such thing. -\end_layout - -\begin_layout Subsection -Callbacks -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/proc.h> -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -struct -\series default - HXproc_ops { -\begin_inset Newline newline -\end_inset - - -\series bold -void (* -\series default -p_prefork -\series bold -) -\series default -( -\series bold -void * -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -void (* -\series default -p_postfork -\series bold -) -\series default -( -\series bold -void * -\series default -); -\begin_inset Newline newline -\end_inset - - -\series bold -void (* -\series default -p_complete -\series bold -) -\series default -( -\series bold -void * -\series default -); -\begin_inset Newline newline -\end_inset - -}; -\end_layout - -\begin_layout Standard - -\family typewriter -struct HXproc_ops -\family default - provides a way to run user-specified functions just before the fork, after, - and when the process has been waited for. - They can be used to set and/or restore signals as needed, for example. - The function pointers can be -\family typewriter -NULL -\family default -. - The -\family typewriter -p_data -\family default - member is passed as an argument. -\end_layout - -\begin_layout Description - -\family typewriter -p_prefork -\family default - Run immediately before calling -\family typewriter -fork -\family default -(2). - This is useful, for taking any action regarding signals, like setting -\family typewriter -SIGCHLD -\family default - to -\family typewriter -SIG_DFL -\family default -, or -\family typewriter -SIGPIPE -\family default - to -\family typewriter -SIG_IGN -\family default -, for example. -\end_layout - -\begin_layout Description - -\family typewriter -p_postfork -\family default - Run in the subprocess (and only there) after forking. - Useful to do a -\family typewriter -setuid -\family default -(2) or other change in privilege level. -\end_layout - -\begin_layout Description - -\family typewriter -p_complete -\family default - Run in -\family typewriter -HXproc_wait -\family default - when the process has been waited for. - Useful to restore the signal handler(s). -\end_layout - -\begin_layout Subsection -Process control -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/proc.h> -\begin_inset Newline newline -\end_inset - - -\series bold - -\begin_inset Newline newline -\end_inset - -int -\series default - HXproc_run_async( -\series bold -const char *const * -\series default -argv, -\series bold -struct -\series default - HXproc -\series bold -* -\series default -proc); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXproc_run_async -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HXproc_run_sync( -\series bold -const char *const * -\series default -argv, -\series bold -unsigned int -\series default - flags); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXproc_run_sync -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - HXproc_wait( -\series bold -struct -\series default - HXproc -\series bold -* -\series default -proc); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HXproc_wait -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -HXproc_run_async -\family default - Start a subprocess according to the parameters in -\family typewriter -proc -\family default -. - Returns a negative errno code if something went wrong, or positive non-zero - on success. -\end_layout - -\begin_layout Description - -\family typewriter -HXproc_run_sync -\family default - Start a subprocess synchronously, similar to calling -\family typewriter -system -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -system -\end_layout - -\end_inset - -, but with the luxury of being able to specify arguments as separate strings - (via argv) rather than one big command line that is run through the shell. - -\family typewriter -flags -\family default - is a value composed of the HXproc flags mentioned above in section -\begin_inset space ~ -\end_inset - - -\begin_inset CommandInset ref -LatexCommand ref -reference "subsec:proc-pflags" - -\end_inset - -. - -\family typewriter -HXPROC_STDIN -\family default -, -\family typewriter -HXPROC_STDOUT -\family default - and -\family typewriter -HXPROC_STDERR -\family default - are ignored because there would be no one in a synchronous execution that - could supply data to these file descriptors or read from them -\begin_inset Foot -status open - -\begin_layout Plain Layout -Even for threads, please just use the async model. -\end_layout - -\end_inset - -. -\end_layout - -\begin_layout Description - -\family typewriter -HXproc_wait -\family default - Wait for a subprocess to terminate, if it has not already. - It will also retrieve the exit status of the process and store it in the - -\family typewriter -struct HXproc -\family default -. -\end_layout - -\begin_layout Standard -Return value will be positive non-zero on success, or negative on error. - Underlying system function's errors are returned, plus: -\end_layout - -\begin_layout Description - -\family sans -EINVAL -\family default - Flags were not accepted. -\end_layout - -\begin_layout Section -Helper headers -\end_layout - -\begin_layout Subsection -ctype helpers -\end_layout - -\begin_layout Standard -Functions from the -\family typewriter -<ctype.h> -\family default - header, including, but not limited to, -\family typewriter -isalpha -\family default -, -\family typewriter -tolower -\family default -, and so forth, are defined to take an -\begin_inset Quotes eld -\end_inset - - -\family typewriter -int -\family default - -\begin_inset Quotes erd -\end_inset - - as first argument. - Strings used in C programs are usually -\begin_inset Quotes eld -\end_inset - - -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default - -\begin_inset Quotes erd -\end_inset - -, without any -\begin_inset Quotes eld -\end_inset - - -\family typewriter -signed -\family default - -\begin_inset Quotes erd -\end_inset - - or -\begin_inset Quotes eld -\end_inset - - -\family typewriter -unsigned -\family default - -\begin_inset Quotes erd -\end_inset - - qualifier. - By a high-level view, which also matches daily common sense, characters - (a. -\begin_inset space \thinspace{} -\end_inset - -k. -\begin_inset space \thinspace{} -\end_inset - -a. -\begin_inset space \space{} -\end_inset - -letters) have no notion of signedness -\begin_inset space ~ -\end_inset - -— there is no -\begin_inset Quotes eld -\end_inset - -positive -\begin_inset Quotes erd -\end_inset - - or -\begin_inset Quotes eld -\end_inset - -negative -\begin_inset Quotes erd -\end_inset - - -\begin_inset Quotes eld -\end_inset - -A -\begin_inset Quotes erd -\end_inset - - in at least the Latin alphabet that is mapped into the ASCII set. - In fact, -\family typewriter -char -\begin_inset space ~ -\end_inset - -* -\family default - could either be -\family typewriter -signed char -\begin_inset space ~ -\end_inset - -* -\family default - or -\family typewriter -unsigned char -\begin_inset space ~ -\end_inset - -* -\family default -, depending on the compiler settings. - Only when you start interpreting and using characters as a number does - such become important. - -\end_layout - -\begin_layout Standard -There come the problems. - Characters are in the same class as numbers in C, that is, can be implicitly - converted from or to a -\begin_inset Quotes eld -\end_inset - -number -\begin_inset Quotes erd -\end_inset - - (in this case, their ASCII code point) without causing a compiler warning. - That may be practical in some cases, but is also a bit -\begin_inset Quotes eld -\end_inset - -unfortunate -\begin_inset Quotes erd -\end_inset - -. - Characters, when interpreted as the 8-bit signed numeric quantity they - are implicitly convertable to, run from 0 to 127 and \SpecialChar nobreakdash -128 to \SpecialChar nobreakdash -1. - Since the -\family typewriter -isalpha -\family default - function and others from -\family typewriter -ctype.h -\family default - take a (signed) -\family typewriter -int -\family default - as argument means that values fed to -\family typewriter -isalpha -\family default - are sign-extended, preserving negative values. -\end_layout - -\begin_layout LyX-Code - -\series bold -/* -\family roman -\series default -\shape italic - -\begin_inset Quotes eld -\end_inset - -hyvää yötä -\begin_inset Quotes erd -\end_inset - -, UTF-8 encoded -\family default -\series bold -\shape default - */ -\end_layout - -\begin_layout LyX-Code - -\series bold -const char -\series default -h -\series bold -[] -\series default - = {'h', 'y', 'v', 0xc3, 0xa4, 0xc3, 0xa4, ' ', -\begin_inset Newline newline -\end_inset - - 'y', 0xc3, 0xb6, 't', 0xc3, 0xa4}; -\end_layout - -\begin_layout Standard -When you now pass -\family typewriter -h[3] -\family default - to -\family typewriter -isalpha -\family default - for example (regardless of whether doing so actually produces a meaningful - result), the CPU is instructed to copy -\begin_inset Quotes eld -\end_inset - -0xc3 -\begin_inset Quotes erd -\end_inset - - into a register and sign-extend it (because -\begin_inset Quotes eld -\end_inset - -char -\begin_inset Quotes erd -\end_inset - - is often -\begin_inset Quotes eld -\end_inset - -signed char -\begin_inset Quotes erd -\end_inset - -, see above), producing 0xffffffc3 (\SpecialChar nobreakdash -61). - But passing \SpecialChar nobreakdash -61 is not what was intended. -\end_layout - -\begin_layout Standard -libHX's -\family typewriter -ctype_helper.h -\family default - therefore provides wrappers with a different function signature that uses - zero extension (not sign extension) by means of using an -\family typewriter -unsigned -\family default - quantity. - Currently this is -\family typewriter - unsigned char -\family default -, because -\family typewriter -isalpha -\family default -'s domain only goes from 0–255. - The implication is that you cannot pass -\family typewriter -EOF -\family default - to -\family typewriter -HX_isalpha -\family default -. -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/ctype_helper.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/ctype_helper.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isalnum( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_isalnum -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isalpha( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_isalpha -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isdigit( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_isdigit -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_islower( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_islower -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isprint( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_isprint -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isspace( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_isspace -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isupper( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -HX_isupper -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -bool -\series default - HX_isxdigit( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_isxdigit -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned char -\series default - HX_tolower( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_tolower -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -unsigned char -\series default - HX_toupper( -\series bold -unsigned char -\series default - c); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -HX_toupper -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -The -\family typewriter -is* -\family default - functions also differ from ctype's in that they return -\family typewriter -bool -\family default - instead of -\family typewriter -int -\family default -. - Not all functions from -\family typewriter -ctype.h -\family default - are present either; -\family typewriter -isascii -\family default -, -\family typewriter -isblank -\family default -, -\family typewriter -iscntrl -\family default -, -\family typewriter -isgraph -\family default -, -\family typewriter -ispunct -\family default - and -\family typewriter -isxdigit -\family default - have been omitted as the author has never needed them so far. -\end_layout - -\begin_layout Subsection -libxml2 helpers -\end_layout - -\begin_layout Standard -libxml2 uses an -\begin_inset Quotes eld -\end_inset - - -\family typewriter -xmlChar -\family default - -\begin_inset Quotes erd -\end_inset - - type as an underlying type for the strings that it reads and outputs. - -\family typewriter -xmlChar -\family default - is typedef'ed to -\family typewriter -unsigned char -\family default - by libxml2, causing compiler warnings related to differing signedness whenever - interacting with strings from the outside world, which are usually just - a pointer to -\family typewriter -char -\family default -. - Because casting would be a real chore, -\family typewriter -libxml_helper.h -\family default - will do it by providing some wrappers with better argument types. -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/libxml_helper.h> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/libxml_helper.h -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - xml_strcmp( -\series bold -const -\series default - xmlChar -\series bold -* -\series default -a, -\series bold -const char * -\series default -b); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xml_strcmp -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -int -\series default - xml_strcasecmp( -\series bold -const -\series default - xmlChar -\series bold -* -\series default -a, -\series bold -const char * -\series default -b); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xml_strcasecmp -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -char * -\series default -xml_getprop(xmlNode -\series bold -* -\series default -node, -\series bold -const char * -\series default -attr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xml_getprop -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -char *xml_getnsprop( -\series bold -xmlNode * -\series default -node, -\series bold -const char * -\series default -nsprefix, -\series bold -const char * -\series default -attr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout -xml_getnsprop -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -xmlAttr -\series bold -* -\series default -xml_newprop(xmlNode -\series bold -* -\series default -node, -\series bold -const char * -\series default -attr); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xml_newprop -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -xmlNode -\series bold -* -\series default -xml_newnode(xmlNode -\series bold -* -\series default -parent, -\series bold -const char * -\series default -name, -\series bold -const char * -\series default -value); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -xml_newnode -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -xmlAttr -\series bold -* -\series default -xml_setprop(xmlNode -\series bold -* -\series default -node, -\series bold -const char * -\series default -name, -\series bold -const char * -\series default -value); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -\size normal -\color none -xml_setprop -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Standard -The functions map to -\family typewriter -strcmp -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -strcmp -\end_layout - -\end_inset - -, -\family typewriter -strcasecmp -\family default -(3) -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -strcasecmp -\end_layout - -\end_inset - -, -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xmlGetProp -\end_layout - -\end_inset - - -\family typewriter -xmlGetProp -\family default -, -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xmlNewProp -\end_layout - -\end_inset - - -\family typewriter -xmlNewProp -\family default -, -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xmlNewTextNode -\end_layout - -\end_inset - - -\family typewriter -xml\SpecialChar softhyphen -New\SpecialChar softhyphen -Text\SpecialChar softhyphen -Node -\family default - and -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -xmlSetProp -\end_layout - -\end_inset - - -\family typewriter -xml\SpecialChar softhyphen -Set\SpecialChar softhyphen -Prop -\family default -, respectively. -\end_layout - -\begin_layout Standard - -\family typewriter -xml_getnsprop -\family default - works similar to -\family typewriter -xmlGetNsProp -\family default -, but instead of taking a namespace URI, it does a lookup by namespace prefix. - The argument order is also different compared to -\family typewriter -xmlGetNsProp -\family default -. -\end_layout - -\begin_layout Subsection -wxWidgets -\end_layout - -\begin_layout LyX-Code - -\series bold -#include -\series default - <libHX/wx_helper.hpp> -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -libHX/wx_helper.hpp -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Subsubsection -Shortcut macros -\end_layout - -\begin_layout Description -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxACV -\end_layout - -\end_inset - - -\family typewriter -wxACV -\family default - Expands to -\family typewriter - -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxALIGN_CENTER_VERTICAL -\end_layout - -\end_inset - -wxALIGN_CENTER_VERTICAL -\end_layout - -\begin_layout Description -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxCDF -\end_layout - -\end_inset - - -\family typewriter -wxCDF -\family default - Expands to a set of common dialog flags for -\family typewriter -wxDialog -\family default -s, which includes -\family typewriter -wxDEFAULT_\SpecialChar softhyphen -FRAME_\SpecialChar softhyphen -STYLE -\family default - and a flag such that the dialog does not create a new window in the task - bar ( -\family typewriter -wxFRAME_\SpecialChar softhyphen -NO_\SpecialChar softhyphen -TASKBAR -\family default -). -\end_layout - -\begin_layout Description -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxDPOS -\end_layout - -\end_inset - - -\family typewriter -wxDPOS -\family default - Expands to -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxDefaultPosition -\end_layout - -\end_inset - - -\family typewriter -wxDefaultPosition -\family default -. -\end_layout - -\begin_layout Description -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxDSIZE -\end_layout - -\end_inset - - -\family typewriter -wxDSIZE -\family default - Expands to -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxDefaultSize -\end_layout - -\end_inset - - -\family typewriter -wxDefaultSize -\family default -. -\end_layout - -\begin_layout Description -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxDSPAN -\end_layout - -\end_inset - - -\family typewriter -wxDSPAN -\family default - Expands to -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxDefaultSpan -\end_layout - -\end_inset - - -\family typewriter -wxDefaultSpan -\family default -. -\end_layout - -\begin_layout Subsubsection -String conversion -\end_layout - -\begin_layout LyX-Code -wxString wxfu8( -\series bold -const char * -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxfu8 -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - -wxString wxfv8( -\series bold -const char * -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxfv8 -\end_layout - -\end_inset - - -\begin_inset Newline newline -\end_inset - - -\series bold -const char * -\series default -wxtu8( -\series bold -const -\series default - wxString -\series bold -& -\series default -); -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxtu8 -\end_layout - -\end_inset - - -\end_layout - -\begin_layout Description - -\family typewriter -wxfu8 -\family default - Converts an UTF-8 string to a -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxString -\end_layout - -\end_inset - - -\family typewriter -wxString -\family default - object. -\end_layout - -\begin_layout Description - -\family typewriter -wxfv8 -\family default - Converts an UTF-8 string to an entity usable by -\begin_inset Index idx -status open - -\begin_layout Plain Layout - -\family typewriter -wxPrintf -\end_layout - -\end_inset - - -\family typewriter -wxPrintf -\family default -. -\end_layout - -\begin_layout Description - -\family typewriter -wxtu8 -\family default - Converts a wxString to a pointer to char usable by -\family typewriter -printf -\family default -. - Note that the validity of the pointer is very limited and usually does - not extend the statement in which it is used. - Hence storing the pointer in a variable ( -\begin_inset Quotes eld -\end_inset - - -\family typewriter -const char *p = wxtu8(s); -\family default - -\begin_inset Quotes erd -\end_inset - -) will make -\family typewriter -p -\family default - pointing to an invalid region as soon as the assignment is done. -\end_layout - -\begin_layout Part -\start_of_appendix -Appendix -\end_layout - -\begin_layout Standard -\begin_inset CommandInset index_print -LatexCommand printindex -type "idx" -name "Index" -literal "true" - -\end_inset - - -\end_layout - -\end_body -\end_document diff --git a/doc/libHX_Documentation.pdf b/doc/libHX_Documentation.pdf Binary files differdeleted file mode 100644 index 673a851..0000000 --- a/doc/libHX_Documentation.pdf +++ /dev/null diff --git a/doc/libHX_Documentation.rst b/doc/libHX_Documentation.rst new file mode 100644 index 0000000..710e265 --- /dev/null +++ b/doc/libHX_Documentation.rst @@ -0,0 +1,142 @@ +=================== +libHX Documentation +=================== + +libHX collects many useful day-to-day functions, intended to reduce the amount +of otherwise repeatedly open-coded instructions. + +Overview +======== + +* Maps (key-value pairs) + + Originally created to provide a data structure like Perl's associative + arrays. Different map types and characteristics are available, such as + hash-based or the traditional rbtree. + +* Linked lists (Deques) + + Double-ended queues, implemented as a doubly-linked list with sentinels, are + suitable for both providing stack and queue functionality. + +* Inline doubly-linked list, uncounted and counted + + Light-weight linked lists as used in the Linux kernel. + +* Common string operations + + ``basename``, ``chomp``, ``dirname``, ``getl``/``getline``, ``split``, + ``strlcat``/``strlcpy``, ``strlower``/``strupper``, ``str*trim``, ``strsep``, + etc. + +* Memory container, auto-sizing string operations + + Scripting-like invocation for string handling — automatically doing + (re)allocations as needed. + +* String formatter (Format templates) + + HXfmt is a template system for by-name variable expansion. It can be used to + substitute placeholders in format strings supplied by the user by appropriate + expanded values defined by the program. + +* Directory functions + + Directory creation, traversal, removal, and file copying. + +* Option parsing + + Table-/callback-based option parser that works similar to Perl's + Getopt::Long — no open-coding but a single “atomic” invocation. + +* Shell-style config parser + + Configuration file reader for Shell-style “configuration” files + with key-value pairs, as usually foudn in ``/etc/sysconfig``. + +* Random number gathering + + Convenient wrapper that uses kernel-provided RNG devices when + available. + +* External process invocation + + Setting up pipes for the standard file descriptors for + sending/capturing data to/from a program. + +* a bit more beyond that ... Miscellaneous + + +General reading +=============== + +* `Installation <install.rst>`_ (if you do not have a binray package from a + distro yet) +* `History <history.rst>`_ remarks + + +First things first +================== + +Many functions are prefixed with ``HX_`` or ``HXsubsys_``, as are structures +(sometimes without underscores, be sure to check the syntax and names), to +avoid name clashes with possibly existing files. Functions that are not tied to +a specific data structure such as most of the string functions use the +subsystem-less prefix, ``HX_``. Functions from a clearly-defined subsystem, +such as map or deque, augment the base prefix by a suffix, forming e.g. +``HXmap_``. + +* `Library initialization <init.rst>`_ + + +Data structures +=============== + +* `Bitmaps <bitmaps.rst>`_ +* `Maps <maps.rst>`_ +* `Linked lists <linked_list.rst>`_ +* `Inline lists <inline_list.rst>`_ +* `Counted inline lists <inline_clist.rst>`_ + + +Strings and memory +================== + +* `String operations <string_ops.rst>`_ +* `Memory containers <memory_container.rst>`_ +* `String formatter <string_formatter.rst>`_ +* Everything with `Files and directories <files_and_dirs.rst>`_ + + +Options and configuration files +=============================== + +* `Option parsing <option_parsing.rst>`_ +* `Shell-style config file parser <shconfig.rst>`_ + + +Systems-related components +========================== + +* `Time functions <time_functions.rst>`_ +* `Random numbers <random_number.rst>`_ +* `Process functions <process_functions.rst>`_ + + +Miscellaneous +============= + +* `Type-checking casts <typechecking_casts.rst>`_ +* `Helper headers <helper_headers.rst>`_ for other software +* `Macros <macros.rst>`_ +* `Misc functions <misc_functions.rst>`_ that did not fit in any other category + + +Resources +========= + +As of this writing, the repository is located at + +* git://git.inai.de/libhx — clone URL + +* https://inai.de/projects/libhx/ — home page (and link to tarballs) diff --git a/doc/linked_list.rst b/doc/linked_list.rst new file mode 100644 index 0000000..accf7d4 --- /dev/null +++ b/doc/linked_list.rst @@ -0,0 +1,171 @@ +================== +Doubly-linked list +================== + +HXdeque is a data structure for a doubly-linked non-circular +``NULL``-sentineled list. Despite being named a deque, which is short for +double-ended queue, and which may be implemented using an array, HXdeque is in +fact using a linked list to provide its deque functionality. Furthermore, a +dedicated root structure and decidated node structures with indirect data +referencing are used. + + +Structural definition +===================== + +.. code-block:: c + + #include <libHX/deque.h> + + struct HXdeque { + struct HXdeque_node *first, *last; + unsigned int items; + void *ptr; + }; + + struct HXdeque_node { + struct HXdeque_node *next, *prev; + struct HXdeque *parent; + void *ptr; + }; + +The ``ptr`` member in ``struct HXdeque`` provides room for an arbitrary custom +user-supplied pointer. items will reflect the number of elements in the list, +and must not be modified. ``first`` and ``last`` provide entrypoints to the +list's ends. + +``ptr`` within ``struct HXdeque_node`` is the pointer to the user's data. It +may be modified and used at will by the user. See example section. + + +Constructor, destructors +======================== + +.. code-block:: c + + struct HXdeque *HXdeque_init(void); + void HXdeque_free(struct HXdeque *dq); + void HXdeque_genocide(struct HXdeque *dq); + void HXdeque_genocide2(struct HXdeque *dq, void (*xfree)(void *)); + void **HXdeque_to_vec(struct HXdeque *dq, unsigned int *num); + +To allocate a new empty list, use ``HXdeque_init``. ``HXdeque_free`` will free +the list (including all nodes owned by the list), but not the data pointers. + +``HXdeque_genocide`` is a variant that will not only destroy the list, but also +calls a freeing function ``free``() on all stored data pointers. This puts a +number of restrictions on the characteristics of the list: all data pointers +must have been obtained with ``malloc``, ``calloc`` or ``realloc`` before, and +no data pointer must exist twice in the list. The function is more efficient +than an open-coded loop over all nodes calling ``HXdeque_del``. + +A generic variant is available with ``HXdeque_genocide2``, which takes a +pointer to an appropriate freeing function. ``HXdeque_genocide`` is thus +equivalent to ``HXdeque_genocide2(dq, free)``. + +To convert a linked list to a ``NULL``-terminated array, ``HXdeque_to_vec`` can +be used. If ``num`` is not ``NULL``, the number of elements excluding the +``NULL`` sentinel, is stored in ``*num``. + + +Addition and removal +==================== + +.. code-block:: c + + struct HXdeque_node *HXdeque_push(struct HXdeque *dq, void *ptr); + struct HXdeque_node *HXdeque_unshift(struct HXdeque *dq, void *ptr); + void *HXdeque_pop(struct HXdeque *dq); + void *HXdeque_shift(struct HXdeque *dq); + struct HXdeque *HXdeque_move(struct HXdeque_node *target, struct HXdeque_node *node); + void *HXdeque_del(struct HXdeque_node *node); + +``HXdeque_push`` and ``HXdeque_unshift`` add the data item in a new node at the +end (“push”) or as the new first element (“unshift” as Perl calls it), +respectively. The functions will return the new node on success, or ``NULL`` on +failure and errno will be set. The node is owned by the list. + +``HXdeque_pop`` and ``HXdeque_shift`` remove the last (“pop”) or first +(“shift”) node, respectively, and return the data pointer that was stored in +the data. + +``HXdeque_move`` will unlink a node from its list, and reinsert it after the +given target node, which may be in a different list. + +Deleting a node is accomplished by calling ``HXdeque_del`` on it. The data +pointer stored in the node is not freed, but returned. + + +Iteration +========= + +Iterating over a HXdeque linked list is done manually and without additional +overhead of function calls: + +.. code-block:: c + + const struct HXdeque_node *node; + for (node = dq->first; node != NULL; node = node->next) + do_something(node->ptr); + + +Searching +========= + +.. code-block:: c + + struct HXdeque_node *HXdeque_find(struct HXdeque *dq, const void *ptr); + void *HXdeque_get(struct HXdeque *dq, void *ptr); + +``HXdeque_find`` searches for the node which contains ``ptr``, and does so by +beginning at the start of the list. If no node is found, ``NULL`` is returned. +If a pointer is more than once in the list, any node may be returned. + +``HXdeque_get`` will further return the data pointer stored in the node — +however, since that is just what the ptr argument is, the function practically +only checks for existence of ``ptr`` in the list. + + +Example: Using HXdeque to store and sort a list +=============================================== + +.. code-block:: c + + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <libHX/defs.h> + #include <libHX/deque.h> + #include <libHX/string.h> + #include <pwd.h> + + int main(void) + { + struct HXdeque *dq = HXdeque_init(); + struct passwd *pw; + unsigned int elem; + char **users; + + setpwent(); + while ((pw = getpwent()) != NULL) + HXdeque_push(dq, HX_strdup(pw->pw_name)); + endpwent(); + + users = reinterpret_cast(char **, HXdeque_to_vec(dq, &elem)); + HXdeque_free(dq); + + qsort(users, elem, sizeof(*users), static_cast(void *, strcmp)); + return 0; + } + +In this example, all usernames are obtained from NSS, and put into a list. +``HX_strdup`` is used, because ``getpwent`` will overwrite the buffer it uses +to store its results. The list is then converted to an array, and the list is +freed (because it is not need it anymore). ``HXdeque_genocide`` must not be +used here, because it would free all the data pointers (strings here) that were +just inserted into the list. Finally, the list is sorted. Because ``strcmp`` +takes two ``const char *`` arguments, but qsort mandates a function taking two +``const void *``, a cast can be used to silence the compiler. This only works +if and when ``char *`` pointers have the same size as ``void *``, and because +we know that the array consists of ``char *`` pointers, and not somehting else; +therefore, ``strcmp`` will work. diff --git a/doc/macros.rst b/doc/macros.rst new file mode 100644 index 0000000..752f81e --- /dev/null +++ b/doc/macros.rst @@ -0,0 +1,149 @@ +====== +Macros +====== + +All macros in this section are available through ``#include <libHX/defs.h>``. + +Preprocessor +============ + +.. code-block:: c + + #define HX_STRINGIFY(s)HX_STRINGIFY + +Transforms the expansion of the argument ``s`` into a C string. + + +Sizes +===== + +.. code-block:: c + + #define HXSIZEOF_Z16 + #define HXSIZEOF_Z32 + #define HXSIZEOF_Z64 + +Expands to the size needed for a buffer (including ``\0``) to hold the base-10 +string representation of 16‑, 32‑ or 64‑bit integer (either signed or +unsigned), respectively. + +Locators +======== + +.. code-block:: c + + output_type *containerof(input_type *ptr, output_type, member); + + size_t HXsizeof_member(struct_type, member); + output_type HXtypeof_member(struct_type, member); + +``containerof`` will return a pointer to the struct in which ``ptr`` is +contained as the given member. (In C++, it is required that the encompassing +``output_type`` has so-called "standard layout", but to date I have never found +an implementation where this matters.) + +.. code-block:: c + + struct foo { + int bar; + int baz; + }; + + static void test(int *ptr) + { + struct foo *self = containerof(baz, struct foo, baz); + } + +``HXsizeof_member`` and ``HXtypeof_member`` are shortcuts (mainly for the C +language) to get the size or type of a named member in a given struct: + +.. code-block:: c + + char padding[FIELD_SIZEOF(struct foo, baz)]; + +In C++, one can simply use ``sizeof(foo::baz)`` and ``decltype(foo::baz)``. + + +Array size +========== + +.. code-block:: c + + size_t ARRAY_SIZE(type array[]); /* implemented as a macro */ + +Returns the number of elements in array. This only works with true arrays +(``type[]``), and will fail to compile when passed a pointer-to-element +(``type *``), which is often used for array access too. + + +Compile-time build checks +========================= + +.. code-block:: c + + int BUILD_BUG_ON_EXPR(bool condition); /* implemented as a macro */ + void BUILD_BUG_ON(bool condition); /* implemented as a macro */ + +Causes the compiler to fail when condition evaluates to true. If not +implemented for a compiler, it will be a no-op. ``BUILD_BUG_ON`` is meant to be +used as a standalone statement, while ``BUILD_BUG_ON_EXPR`` is for when a check +is to occur within an expression, that latter of which is useful for within +macros when one cannot, or does not want to use multiple statements. + +.. code-block:: c + + type DEMOTE_TO_PTR(type expr); /* macro */ + +Changes the type of ``expr`` to pointer type. If ``expr`` is of array type +class, changes it to a pointer to the first element. If ``expr`` is of function +type class, changes it to a pointer to the function. + +.. code-block:: c + + int main(void); + int (*fp)(void); + char a[123]; + DEMOTE_TO_PTR(main); /* yields int (*)(void); */ + DEMOTE_TO_PTR(fp); /* also yields int (*)(void); */ + DEMOTE_TO_PTR(a); /* yields char * */ + + +UNIX file modes +=============== + +.. code-block:: c + + #define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)S_IRUGO + #define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)S_IWUGO + #define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)S_IXUGO + #define S_IRWXUGO (S_IRUGO | S_IWUGO | S_IXUGO)S_IRWXUGO + +The defines make it vastly easier to specify permissions for large group of +users. For example, if one wanted to create a file with the permissions +``rw-r--r--`` (ignoring the umask in this description), ``S_IRUSR | S_IWUSR`` +can now be used instead of the longer ``S_IRUSR | S_IWUSR | S_IRGRP | +S_IROTH``. + + +VC runtime format specifiers +============================ + +The Microsoft Visual C runtime (a weak libc) uses non-standard format +specifiers for certain types. Whereas C99 specifies ``z`` for ``size_t`` and +``ll`` for ``long long``, MSVCRT users must use ``I`` and ``I64`` (forming +``%Id`` instead of ``%zd`` for ``ssize_t``, for example). libHX provides two +convenience macros for this: + +.. code-block:: c + + #define HX_SIZET_FMT "z" or "I"HX_SIZET_FMT + #define HX_LONGLONG_FMT "ll" or "I64"HX_LONGLONG_FMT + +These may be used together with ``printf`` or ``scanf``: + +.. code-block:: c + + printf("struct timespec is of size %" HX_SIZET_FMT "u\n", + sizeof(struct timespec)); + +Take note that mingw-w64's libc *does* adhere to POSIX and so, %z can be used. diff --git a/doc/maps.rst b/doc/maps.rst new file mode 100644 index 0000000..68eca60 --- /dev/null +++ b/doc/maps.rst @@ -0,0 +1,525 @@ +==== +Maps +==== + +A map is a collection of key-value pairs. (Some languages, such as Perl, also +call them “associative array” or just “hash”, however, the underlying storage +mechanism may not be an array or a hash, however.) Each key is unique and has +an associated value. Keys can be any data desired; HXmap allows to specify your +own key and data handling functions so they can be strings, raw pointers, or +complex structures. + +To access any map-related functions, ``#include <libHX/map.h>``. + + +Structural definition +===================== + +The HXmap structure is a near-opaque type. Unlike the predecessor map +implementation struct HXbtree from libHX 2.x, the 3.x API exposes much less +fields. + +.. code-block:: c + + struct HXmap { + unsigned int items, flags; + }; + +``items`` + The number of items in the tree. This field tracks the number of items + in the map and is used to report the number of elements to the user, + and is updated whenever an element is inserted or removed from the map. + The field must not be changed by the user. + +``flags`` + The current behavior flags for the map. While implementation-private + bits are exposed, only ``HXMAP_NOREPLACE`` is currently allowed to be + (un)set by the user while a map exists. + +For retrieving elements from a tree, some functions work with ``struct +HXmap_node``, which is defined as follows: + +.. code-block:: c + + struct HXmap_node { + union { + void *key; + const char *const skey; + }; + union { + void *data; + char *sdata; + }; + }; + +``key`` + The so-called primary key, which uniquely identifies an element (a + key-value pair) in the map. The memory portions that make up the key + must not be modified. (If the key changes, so does its hash value + and/or position index, and without taking that into account, writing to + the key directly is going to end up with an inconsistent state. To + change the key, you will need to delete the element and reinsert it + with its new key.) + +``skey`` + A convenience type field for when the map's keys are C strings. It is + useful for use with e.g. ``printf`` or other varargs function, which + would otherwise require explicit and noisy casting of the ``void *key`` + member to ``const char *`` first. + +``data`` + The data associated with the key. + +``sdata`` + Convenience type field. + + +Map initialization +================== + +During initialization, you specify the underlying storage type by selecting a +given constructor function. All further operations are done through the unified +HXmap API which uses a form of virtual calls internally. + +Currently, there are two distinct map types in libHX. There are a handful of +selectable symbols, though. Abstract types are: + +``HXMAPT_DEFAULT`` + No further preferences or guarantees; selects any data structure that the + libHX maintainer deemed fast. + +``HXMAPT_ORDERED`` + The map shall use a data structure that provides ordered traversal. + +Specific types include: + +``HXMAPT_HASH`` + Hash-based map – Amortized O(1) insertion, lookup and deletion; + unordered. + +``HXMAPT_RBTREE`` + Red-black binary tree – O(log(n)) insertion, lookup and deletion; + ordered. + +These can then be used with the initialization functions: + +.. code-block:: c + + struct HXmap *HXmap_init(unsigned int type, unsigned int flags); + struct HXmap *HXmap_init5(unsigned int type, unsigned int flags, const struct HXmap_ops *ops, size_t key_size, size_t data_size); + +Both the *init* and *init5* variant creates a new map; the latter function +allows to specify the operations in detail as well as key and data size, which +may become necessary when using data sets which have their own way of being +managed. The flags parameter can contain any of the following: + +``HXMAP_NONE`` + This is just a mnemonic for the value 0, indicating no flags. + +``HXMAP_NOREPLACE`` + If a key already exists and another add operation is attempted, the + key's associated value will be replaced by the new value. If this flag + is absent, ``-EEXIST`` is returned. This flag is allowed to be + subsequently changed by the user if so desired, using bit logic such as + ``map->flags &= ~HXMAP_NOREPLACE;``. + +``HXMAP_SKEY`` + Notifies the constructor that keys will be C-style strings. The flag + presets the ``k_compare`` operation to use ``strcmp``. In the flag's + absence, direct value comparison will be used if the key size is + specified as zero (e.g. with the ``HXhashmap_init4`` function call), or + ``memcmp`` if the key size is non-zero. + +``HXMAP_CKEY`` + Instructs the map to make copies of keys when they are added to the + map. This is required when the buffer holding the key changes or goes + out of scope. The flag presets the ``k_clone`` and ``k_free`` + operations to ``HX_memdup`` and ``free``, and as such, the ``key_size`` + parameter must not be zero. If however, ``HXMAP_SKEY`` is also + specified, ``HX_strdup`` and ``free`` will be used and ``key_size`` + must be ``zero``. + +``HXMAP_SDATA`` + Notifies the constructor that data will be C-style strings. This sets + up the ``d_clone`` and ``d_free`` operations. + +``HXMAP_CDATA`` + Instructs the map to make copies of the data when new entries are added + to the map. This is required when the buffer holding the data either + goes out of scope, or you want to keep the original contents instead of + just a pointer. + +``HXMAP_SCKEY`` + Mnemonic for the combination of ``HXMAP_SKEY | HXMAP_CKEY``. + +``HXMAP_SCDATA`` + Mnemonic for the combination of ``HXMAP_SDATA | HXMAP_SDATA``. + +``HXMAP_SINGULAR`` + Specifies that the “map” is only used as a set, i.e. it does not store + any values, only keys. Henceforth, the value argument to ``HXmap_add`` + must always be ``NULL``. + + +Flag combinations +================= + +This subsection highlights the way ``HXMAP_SKEY`` interacts with ``HXMAP_CKEY`` +and the key size. The copy semantics are the same for ``HXMAP_SDATA`` and +``HXMAP_CDATA``. + +HXMAP_SKEY unset, HXMAP_CKEY unset +---------------------------------- + +The ``key_size`` parameter at the time of map construction is ignored. The +pointer value of the key parameter for the ``HXmap_add`` call is directly +stored in the tree, and this is the key that uniquely identifies the map entry +and which is used for comparisons. This may be used if you intend to directly +map pointer values. + +.. code-block:: c + + static struct something *x = ..., *y = ...; + HXmap_add(map, &x[0], "foo"); + HXmap_add(map, &x[1], "bar"); + +HXMAP_SKEY set, HXMAP_CKEY unset +-------------------------------- + +The ``key_size`` parameter at the time of map construction is ignored. The +pointer value of the key parameter for the HXmap_add call is directly stored in +the tree, but it is the C string pointed to by the key parameter that serves as +the key. + +HXMAP_SKEY set, HXMAP_CKEY set +------------------------------ + +The ``key_size`` parameter at the time of map construction is ignored. The +string pointed to by the key parameter will be duplicated, and the resulting +pointer will be stored in the tree. Again, it is the pointed-to string that is +the key. + +HXMAP_SKEY unset, HXMAP_CKEY set +-------------------------------- + +The memory block pointed to by the key parameter will be duplicated. The +``key_size`` parameter must be non-zero for this to successfully work. + +With separate ops +----------------- + +However, when a custom ``struct HXmap_ops`` is provided in the call to +``HXmap_init5``, any of these semantics can be overridden. Particularly, since +your own ops can practically ignore ``key_size``, it could be set to any value. + + +Key-data operations +=================== + +The ``HXMAP_SKEY/CKEY/SDATA/CDATA`` flags are generally sufficient to set up +common maps where keys and/or data are C strings or simple binary data where +``memdup``/``memcmp`` is enough. Where the provided mechanisms are not cutting +it, an extra ``HXmap_ops`` structure with functions specialized in handling the +keys and/or data has to be used as an argument to the initialization function +call. + +.. code-block:: c + + struct HXmap_ops { + int (*k_compare)(const void *, const void *, size_t); + void *(*k_clone)(const void *, size_t); + void (*k_free)(void *); + void *(*d_clone)(const void *, size_t); + void (*d_free)(void *); + unsigned long (*k_hash)(const void *, size_t); + }; + +``k_compare`` + Function to compare two keys. The return value is the same as that of + ``memcmp`` or ``strcmp``: negative values indicate that the first key + is “less than” the second, zero indicates that both keys are equal, and + positive values indicate that the first key is “greater than” the + second. The ``size`` argument in third position is provided so that + ``memcmp``, which wants a size parameter, can directly be used without + having to write an own function. (This also means strcmp can't be + directly plugged in due to a function signature mismatch.) + +``k_clone`` + Function that will clone (duplicate) a key. This is used for keys that + will be added to the tree, and potentially also for state-keeping + during traversal of the map. It is valid that this clone function + simply returns the value of the pointer it was actually passed; this is + used by default for maps without ``HXMAP_CKEY`` for example. + +``k_free`` + Function to free a key. In most cases it defaults to ``free``(3), but + in case you are using complex structs, more cleanup may be needed. + +``d_clone`` + Same idea as ``k_clone``, but for data. + +``d_free`` + Same idea as ``k_free``, but for data. + +``k_hash`` + Specifies an alternate hash function. Only to be used with hash-based + maps. Hashmaps default to using the DJB2 string hash function when + ``HXMAP_SKEY`` is given, or otherwise the Jenkins' lookup3 hash + function. + +libHX exports two hash functions that you can select for ``struct HXmap_ops``'s +``k_hash`` if the default for a given flag combination is not to your liking. + +``HXhash_jlookup3`` + Bob Jenkins's lookup3 hash. + +``HXhash_djb2`` + DJB2 string hash. + + +Map operations +============== + +.. code-block:: c + + int HXmap_add(struct HXmap *, const void *key, const void *value); + const struct HXmap_node *HXmap_find(const struct HXmap *, const void *key); + void *HXmap_get(const struct HXmap *, const void *key); + void *HXmap_del(struct HXmap *, const void *key); + void HXmap_free(struct HXmap *); + struct HXmap_node *HXmap_keysvalues(const struct HXmap *); + +``HXmap_add`` + Adds a new node to the tree using the given key and data. When an + element is in the map, the key may not be modified, as doing so could + possibly invalidate the internal location of the element, or its + ordering with respect to other elements. If you need to change the key, + you will have to delete the element from the tree and re-insert it. On + error, -errno will be returned. + + When ``HXMAP_SINGULAR`` is in effect, value must be ``NULL``, else + ``-EINVAL`` is returned. + +``HXmap_find`` + Finds the node for the given key. The key can be read from the node + using ``node->key`` or ``node->skey`` (convenience alias for key, but + with a type of ``const char *``), and the data by using ``node->data`` + or ``node->sdata``. + +``HXmap_get`` + Get is a find operation directly returning ``node->data`` instead of + the node itself. Since ``HXmap_get`` may legitimately return ``NULL`` + if ``NULL`` was stored in the tree as the data for a given key, only + ``errno`` will really tell whether the node was found or not; in the + latter case, ``errno`` is set to ``ENOENT``. + +``HXmap_del`` + Removes an element from the map and returns the data value that was + associated with it. When an error occurred, or the element was not + found, ``NULL`` is returned. Because ``NULL`` can be a valid data + value, ``errno`` can be checked for non-zero. ``errno`` will be + ``-ENOENT`` if the element was not found, or zero when everything was + ok. + +``HXmap_free`` + The function will delete all elements in the map and free memory it + holds. + +``HXmap_keysvalues`` + Returns all key-value-pairs in an array of the size as many items were + in the map (map->items) at the time it was called. The memory must be + freed using ``free``(3) when it is no longer needed. The order elements + in the array follows the traverser notes (see below), unless otherwise + specified. + + +Map traversal +============= + +.. code-block:: c + + struct HXmap_trav *HXmap_travinit(const struct HXmap *); + const struct HXmap_node *HXmap_traverse(struct HXmap_trav *iterator); + void HXmap_travfree(struct HXmap_trav *iterator); + void HXmap_qfe(const struct HXmap *, bool (*fn)(const struct HXmap_node *, void *arg), void *arg); + +``HXmap_travinit`` + Initializes a traverser (a.k.a. iterator) for the map, and returns a + pointer to it. ``NULL`` will be returned in case of an error, such as + memory allocation failure. Traversers are returned even if the map has + zero elements. + +``HXmap_traverse`` + Returns a pointer to a ``struct HXmap_node`` for the next element / + key-value pair from the map, or ``NULL`` if there are no more entries. + +``HXmap_travfree`` + Releases the memory associated with a traverser. + +``HXmap_qfe`` + The “quick foreach”. Iterates over all map elements in the fastest + possible manner, but has the restriction that no modifications to the + map are allowed. Furthermore, a separate function to handle each + visited node, is required. (Hence this is also called “closed + traversal”, because one cannot access the stack frame of the original + function which called ``HXmap_qfe``.) The user-defined function returns + a bool which indicates whether traversal shall continue or not. + +Flags for ``HXmap_travinit``: + +``HXMAP_NOFLAGS`` + A mnemonic for no flags, and is defined to 0. + +``HXMAP_DTRAV`` + Enable support for deletion during traversal. As it can make traversal + slower, it needs to be explicitly specified for cases where it is + needed, to not penalize cases where it is not. + +WARNING: Modifying the map while a traverser is active is +implementation-specific behavior! libHX generally ensures that there will be no +undefined behavior (e.g. crashes), but there is no guarantee that elements +will be returned exactly once. There are fundamental cases that one should be +aware of: + +* An element is inserted before where the traverser is currently positioned at. + The element may not be returned in subsequent calls to ``HXmap_traverse`` on + an already-active traverser. + +* Insertion or deletion may cause internal data structure to re-layout. + + * Traversers of ordered data structures may choose to rebuild + their state. + + * Traversers of unordered data structures would run risk to + return more than once, or not at all. + +Descriptions for different map types follow. + +:Hashmaps: + On ```HXmap_add`, an element may be inserted in a position that is + before where the traverser is currently positioned. Such elements will + not be returned in the remaining calls to ``HXmap_traverse``. The + insertion or deletion of an element may cause the internal data + structure to re-layout itself. When this happens, the traverser will + stop, so as to not return entries twice. + +:Binary trees: + Elements may be added before the traverser's position. These elements + will not be returned in subsequent traversion calls. If the data + structure changes as a result of an addition or deletion, the traverser + will rebuild its state and continue traversal transparently. Because + elements in a binary tree are ordered, that is, element positions may + not change with respect to another when the tree is rebalanced, there + is no risk of returning entries more than once. Nor will elements that + are sorted after the current traverser's position not be returned + (= they will be returned, because they cannot get reordered to before + the traverser like in a hash map). The HX rbtree implementation also + has proper handling for when the node which is currently visiting is + deleted. + + +RB-tree Limitations +=================== + +The implementation has a theoretical minimum on the maximum number of nodes, +2^{24}=16{,}777{,}216. A worst-case tree with this many elements already has a +height of 48 (RBT_MAXDEP), which is the maximum height currently supported. The +larger the height is that HXrbtree is supposed to handle, the more memory +(linear increase) it needs. All functions that build or keep a path reserve +memory for RBT_MAXDEP nodes; on x86_64, this is 9 bytes per <node, direction> +pair, amounting to 432 bytes for path tracking alone. It may not sound like a +lot to many, but given that kernel developers try to limit their stack usage to +some 4096 bytes is impressive alone. + + +Examples +======== + +Case-insensitive ordering +------------------------- + +The correct way: + +.. code-block:: c + + static int my_strcasecmp(const void *a, const void *b, size_t z) { + return strcasecmp(a, b); + } + static const struct HXmap_ops icase = { + .k_compare = my_strcasecmp, + }; + HXmap_init5(HXMAPT_RBTREE, HXMAP_SKEY, &icase, 0, dsize); + +A hackish way (which wholly depends on the C implementation and use of extra +safeguards is a must): + +.. code-block:: c + + static const struct HXmap_ops icase = { + .k_compare = (void *)strcasecmp, + }; + BUILD_BUG_ON(sizeof(DEMOTE_TO_PTR(strcasecmp)) > sizeof(void *)); + BUILD_BUG_ON(sizeof(DEMOTE_TO_PTR(strcasecmp)) > sizeof(icase.k_compare)); + HXmap_init5(HXMAPT_RBTREE, HXMAP_SKEY, &icase, 0, dsize); + + +Reverse sorting order +--------------------- + +Any function that behaves like strcmp can be used. It merely has to return +negative when ``a<b``, zero on ``a==b``, and positive non-zero when ``a>b``. + +.. code-block:: c + + static int strcmp_rev(const void *a, const void *b, size_t z) + { + /* z is provided for cases when things are raw memory blocks. */ + return strcmp(b, a); + } + + static const struct HXmap_ops rev = { + .k_compare = strcmp_rev, + }; + HXmap_init5(HXMAPT_RBTREE, HXMAP_SKEY, &rev, 0, dsize); + + +Keys with non-unique data +------------------------- + +Keys can actually store non-unique data, as long as this extra fields does not +actually contribute to the logical key — the parts that do uniquely identify +it. In the following example, the notes member may be part of struct package, +which is the key as far as HXmap is concerned, but still, only the name and +versions are used to identify it. + +.. code-block:: c + + struct package { + char *name; + unsigned int major_version; + unsigned int minor_version; + char notes[64]; + }; + + static int package_cmp(const void *a, const void *b) + { + const struct package *p = a, *q = b; + int ret; + ret = strcmp(p->name, q->name); + if (ret != 0) + return ret; + ret = p->major_version - q->major_version; + if (ret != 0) + return ret; + ret = p->minor_version - q->minor_version; + if (ret != 0) + return ret; + return 0; + } + + static const struct HXmap_ops package_ops = { + .k_compare = package_cmp, + }; + + HXmap_init5(HXMAPT_RBTREE, flags, &package_ops, + sizeof(struct package), dsize); diff --git a/doc/memory_container.rst b/doc/memory_container.rst new file mode 100644 index 0000000..a1608ca --- /dev/null +++ b/doc/memory_container.rst @@ -0,0 +1,197 @@ +================= +Memory containers +================= + +The HXmc series of functions provide scripting-like semantics for strings, +especially automatically resizing the buffer on demand. They can also be used +to store a binary block of data together with its length. (Hence the name: mc = +memory container.) + +The benefit of using the HXmc functions is that one does not have to +meticulously watch buffer and string sizes anymore. + +Improvement of string safety over time: + +.. code-block:: c + + /* Step 1 */ + + char buf[long_enough] = "helloworld"; + if (strlen(buf) + strlen(".txt") < sizeof(buf)) + strcat(s, ".txt"); /* may go over end of buffer */ + + /* Step 2 */ + + char buf[long_enough] = "helloworld"; + strlcat(s, ".txt", sizeof(buf)); /* may truncate */ + + /* Step 3 */ + + hxmc_t *buf = HXmc_strinit("helloworld"); + HXmc_strcat(&s, ".txt"); + +This makes it quite similar to the string operations (and append seems to be +the most commonly used one to me) supported in scripting languages that also do +without a size argument. The essential part of such memory containers is that +their internal (hidden) metadata structure contains the length of the memory +block in the container. For binary data this may be the norm, but for C-style +strings, the stored and auto-updated length field serves as an accelerator +cache. For more details, see ``HXmc_length``. + +Of course, the automatic management of memory comes with a bit of overhead as +the string expands beyond its preallocated region. Such may be mitigated by +doing explicit (re)sizing. + + +Structural overview +=================== + +HXmc functions do not actually return a pointer to the memory container (e.g. +struct) itself, but a pointer to the data block. Conversely, input parameters +to HXmc functions will be the data block pointer. It is of type ``hxmc_t *``, +which is typedef'ed to ``char *`` and therefore has properties of a char +pointer. Pointer arithmetic is thus supported. It also means you can just pass +it to functions that take a ``char *`` without having to do a member access +like ``s.c_str()`` in C++. The drawback is that many functions operating on the +memory container need a ``hxmc_t **`` (a level-two indirection), because not +only does the memory block move, but also the memory container itself. This is +due to the implementation of the container metadata which immediately and +always precedes the writable memory block. + +HXmc ensures that the data block is terminated by the \0 byte (unless you trash +it), so you do not have to, and of course, to be on the safe side. But, the +automatic \0 byte is not part of the region allocated by the user. That is, +when one uses the classic approach with ``malloc(4096)``, the user will have +control of 4096 bytes and has to stuff the \0 byte in there somehow on his own; +for strings this means the maximum string length is 4095. Requesting space for +a 4096-byte sized HXmc container gives you the possibility to use all 4096 +bytes for the string, because HXmc provides a \0 byte. + +By the way, ``hxmc_t`` is the only typedef in this entire library, to +distinguish it from regular ``char *`` that does not have a backing memory +cointainer. + +Constructors, destructors +========================= + +.. code-block:: c + + #include <libHX/string.h> + + hxmc_t *HXmc_strinit(const char *s); + hxmc_t *HXmc_meminit(const void *ptr, size_t size); + void HXmc_free(hxmc_t *s); + void HXmc_zvecfree(hxmc_t **s); + +``HXmc_strinit`` + Creates a new ``hxmc_t`` object from the supplied string and returns + it. + +``HXmc_meminit`` + Creates a new ``hxmc_t`` object from the supplied memory buffer of the + given size and returns it. ``HXmc_meminit(NULL, len)`` may be used to + obtain an empty container with a preallocated region of len bytes (zero + is accepted for ``len``). + +``HXmc_free`` + Frees the hxmc object. + +``HXmc_zvecfree`` + Frees all hxmc objects in the ``NULL``-terminated array, and finally + frees the array itself, similar to ``HX_zvecfree``. + +Data manipulation +================= + +Binary-based +------------ + +.. code-block:: c + + hxmc_t *HXmc_trunc(hxmc_t **mc, size_t len);HXmc_trunc + hxmc_t *HXmc_setlen(hxmc_t **mc, size_t len);HXmc_setlen + hxmc_t *HXmc_memcpy(hxmc_t **mc, const void *ptr, size_t len); + hxmc_t *HXmc_memcat(hxmc_t **mc, const void *ptr, size_t len); + hxmc_t *HXmc_mempcat(hxmc_t **mc, const void *ptr, size_t len); + hxmc_t *HXmc_memins(hxmc_t **mc, size_t pos, const void *ptr, size_t len); + hxmc_t *HXmc_memdel(hxmc_t **mc, size_t pos, size_t len); + +When ``ptr`` is ``NULL``, each call behaves as if ``len`` would be ``zero``. +Specifically, no undefined behavior will result of the use of ``NULL``. + +``HXmc_trunc`` + Truncates the container's data to ``len`` size. If ``len`` is greater + than the current data size of the container, the length is in fact not + updated, but a reallocation may be triggered, which can be used to do + explicit allocation. + +``HXmc_setlen`` + Sets the data length, doing a reallocation of the memory container if + needed. The newly available bytes are uninitialized. Make use of this + function when letting 3rd party functions write to the buffer, but it + should not be used with ``HXmc_str*``. + +``HXmc_memcpy`` + Truncates the container's data and copies ``len`` bytes from the memory + area pointed to by ``ptr`` to the container. + +``HXmc_memcat`` + Concatenates (appends) ``len`` bytes from the memory area pointed to by + ``ptr`` to the container's data. + +``HXmc_mempcat`` + Prepends ``len`` bytes from the memory area pointed to by ``ptr`` to + the container's data. + +``HXmc_memins`` + Prepends ``len`` bytes from the memory area pointed to by ``ptr`` to + the ``pos``'th byte of the container's data. + +``HXmc_memdel`` + Deletes ``len`` bytes from the container beginning at position ``pos``. + +In case of a memory allocation failure, the ``HXmc_*`` functions will return +``NULL``. + +String-based +------------ + +The string-based functions correspond to their binary-based equivalents with a +len argument of strlen(s). + +.. code-block:: c + + hxmc_t *HXmc_strcpy(hxmc_t **mc, const char *s); + hxmc_t *HXmc_strcat(hxmc_t **mc, const char *s); + hxmc_t *HXmc_strpcat(hxmc_t **mc, const char *s); + hxmc_t *HXmc_strins(hxmc_t **mc, size_t pos, const char *s); + +``HXmc_strcpy`` + Copies the string pointed to by ``s`` into the memory container given + by ``mc``. If ``mc`` is ``NULL``, the memory container will be + deallocated, that is, ``*mc`` becomes ``NULL``. + +From auxiliary sources +---------------------- + +.. code-block:: c + + hxmc_t *HX_getl(hxmc_t **mc, FILE *fp);HX_getl + +``HX_getl`` + Reads the next line from ``fp`` and store the result in the container. + Returns ``NULL`` on error, or when end of file occurs while no + characters have been read. + +Container properties +-------------------- + +.. code-block:: c + + size_t HXmc_length(const hxmc_t **mc); + +``HXmc_length`` + Returns the length of the memory container. This is not always equal to + the actual string length. For example, if ``HX_chomp`` was used on an + MC-backed string, ``strlen`` will return less than ``HXmc_length`` if + newline control characters (``\r`` and ``\n``) were removed. diff --git a/doc/misc_functions.rst b/doc/misc_functions.rst new file mode 100644 index 0000000..43dacfe --- /dev/null +++ b/doc/misc_functions.rst @@ -0,0 +1,39 @@ +======================= +Miscellaneous functions +======================= + +.. code-block:: c + + #include <libHX/misc.h> + + int HX_ffs(unsigned long z); + int HX_fls(unsigned long z); + + void HX_zvecfree(char **); + unsigned int HX_zveclen(const char *const *); + +``HX_ffs`` + Finds the first (lowest-significant) bit in a value and returns its + position, or ``-1`` to indicate failure. + +``HX_fls`` + Finds the last (most-significant) bit in a value and returns its + position, or ``-1`` to indicate failure. + +``HX_zvecfree`` + Frees the supplied Z-vector array. (Frees all array elements from the + first element to (excluding) the first ``NULL`` element.) + +``HX_zveclen`` + Counts the number of array elements until the first ``NULL`` array + element is seen, and returns this number. + +.. code-block:: c + + #include <libHX/io.h> + void HX_hexdump(FILE *fp, const void *ptr, unsigned int len); + +``HX_hexdump`` + Outputs a nice pretty-printed hex and ASCII dump to the filedescriptor + ``fp``. ``ptr`` is the memory area, of which ``len`` bytes will be + dumped. diff --git a/doc/option_parsing.rst b/doc/option_parsing.rst new file mode 100644 index 0000000..9205c2b --- /dev/null +++ b/doc/option_parsing.rst @@ -0,0 +1,587 @@ +============== +Option parsing +============== + +libHX uses a table-based approach like libpopt[#f3]. It provides for both long +and short options and the different styles associated with them, such as +absence or presence of an equals sign for long options (``--foo=bar`` and ``--foo +bar``), bundling (writing ``-abc`` for non-argument taking options ``-a -b -c``), +squashing (writing ``-fbar`` for an argument-requiring option ``-f bar``). The “lone +dash” that is often used to indicate standard input or standard output, is +correctly handled[#f4], as in ``-f -``. + +.. [#f3] The alternative would be an iterative, open-coded approach like + ``getopt``(3) requires. + +.. [#f4] popt failed to do this for a long time. + +A table-based approach allows for the parser to run as one unit, quite unlike +the open-coded ``getopt``(3) loop where the function returns for every argument +it parsed and needs to be called repeatedly. + + +Synopsis +======== + +.. code-block:: c + + #include <libHX/option.h> + + struct HXoption { + const char *ln; + char sh; + unsigned int type; + void *ptr, *uptr; + void (*cb)(const struct HXoptcb *); + int val; + const char *help, *htyp; + }; + + int HX_getopt(const struct HXoption *options_table, int *argc, const char ***argv, unsigned int flags); + +The various fields of ``struct HXoption`` are: + +``ln`` + The long option name, if any. May be ``NULL`` if none is to be assigned + for this entry. + +``sh`` + The short option name/character, if any. May be '``\0``' if none is to + be assigned for this entry. + +``type`` + The type of the entry, essentially denoting the type of the target + variable. + +``val`` + An integer value to be stored into ``*(int *)ptr`` when the option type + is ``HXTYPE_IVAL``. + +``ptr`` + A pointer to the variable so that the option parser can store the + requested data in it. The pointer may be ``NULL``, in which case no + data is stored (but ``cb`` is still called if defined, with the data). + +``uptr`` + A user-supplied pointer. Its value is passed verbatim to the callback, + and may be used for any purpose the user wishes. If the option type is + ``HXTYPE_SVAL``, it is the value in uptr that will be used to populate + ``*(const char **)ptr``. + +``cb`` + If not ``NULL``, call out to the referenced function after the option + has been parsed (and the results possibly be stored in ``ptr``). + +``help`` + A help string that is shown for the option when the option table is + dumped by request (e.g. ``yourprgram --help``). + +``htyp`` + String containing a keyword to aid the user in understanding the + available options during dump. See examples. + +Due to the amount of fields, it is advised to use C99 named initializers to +populate a struct, as they allow to omit unspecified fields, and assume no +specific order of the members: + +.. code-block:: c + + struct HXoption e = {.sh = 'f', .help = "Force"}; + +It is a sad fact that C++ has not gotten around to implement named initializers +as of C++17. It is possible to put the option parsing code into a separate C +source file that can then be compiled in C99 rather than C++ mode. + + +Type map +======== + +``HXTYPE_NONE`` + The option does not take any argument, but the presence of the option + may be record by setting ``*(int *)ptr`` to ``1``. Other rules apply + when ``HXOPT_INC`` or ``HXOPT_DEC`` are specified as flags. + +``HXTYPE_VAL`` + Use the integer value specified by ``ival`` and store it in + ``*(int *)ptr``. + +``HXTYPE_SVAL`` + Use the memory location specified by ``sval`` and store it in ``*(const + char **)ptr``. OUTDATED. + +``HXTYPE_BOOL`` + Interpret the supplied argument as a boolean descriptive (must be + ``yes``, ``no``, ``on``, ``off``, ``true``, ``false``, ``0`` or ``1``) + and store the result in ``*(int *)ptr``. + +``HXTYPE_STRING`` + The argument string is duplicated to a new memory region and the + resulting pointer stored into ``*(char **)ptr``. This incurs an + allocation so that subsequently modifying the original argument string + in any way will not falsely propagate. + +``HXTYPE_STRDQ`` + The argument string is duplicated to a new memory region and the + resulting pointer is added to the given HXdeque. Note that you often + need to use deferred initialization of the options table to avoid + putting ``NULL`` into the entry. See section about pitfalls. + +The following overview lists the types that map to the common integral and +floating-point types. Signed and unsigned integeral types are processed using +``strtol`` and ``strtoul``, respectively. ``strtol`` and ``strtoul`` will be +called with automatic base detection. This usually means that a leading ``0`` +indicates the string is given in octal base, a leading ``0x`` indicates +hexadecimal base, and decimal otherwise. ``HXTYPE_LLONG``, ``HXTYPE_ULLONG``, +``HXTYPE_INT64`` and ``HXTYPE_UINT64`` use ``strtoll`` and/or ``strtoull``, +which may not be available on all platforms. + +``HXTYPE_CHAR`` + maps to ``char`` + +``HXTYPE_UCHAR`` + maps to ``unsigned char`` + +``HXTYPE_SHORT`` + maps to ``short`` + +``HXTYPE_USHORT`` + maps to ``unsigned short`` + +``HXTYPE_INT`` + maps to ``int`` + +``HXTYPE_UINT`` + maps to ``unsigned int`` + +``HXTYPE_LONG`` + maps to ``long`` + +``HXTYPE_ULONG`` + maps to ``unsigned long`` + +``HXTYPE_LLONG`` + maps to ``long long`` + +``HXTYPE_ULLONG`` + maps to ``unsigned long long`` + +``HXTYPE_SIZE_T`` + maps to ``size_t`` + +``HXTYPE_FLOAT`` + maps to ``float`` + +``HXTYPE_DOUBLE`` + maps to ``double`` + +``HXTYPE_INT8`` + maps to ``int8_t`` + +``HXTYPE_UINT8`` + maps to ``uint8_t`` + +``HXTYPE_INT16`` + maps to ``int16_t`` + +``HXTYPE_UINT16`` + maps to ``uint16_t`` + +``HXTYPE_INT32`` + maps to ``int32_t`` + +``HXTYPE_UINT32`` + maps to ``uint32_t`` + +``HXTYPE_INT64`` + maps to ``int64_t`` + +``HXTYPE_UINT64`` + maps to ``uint64_t`` + +``HXTYPE_FLOAT`` and ``HXTYPE_DOUBLE`` make use of ``strtod`` (``strtof`` is +not used). A corresponding type for the ``long double`` format is not +specified, but may be implemented on behalf of the user via a callback. + + +Flags +===== + +Flags can be combined into the type parameter by OR'ing them. It is valid to +not specify any flags at all, but most flags collide with one another. + +``HXOPT_INC`` + Perform an increment on the memory location specified by the + ``*(int *)ptr`` pointer. Make sure the referenced variable is + initialized beforehand! + +``HXOPT_DEC`` + Perform a decrement on the pointee. Same requirements as ``HXOPT_INC``. + +Only one of ``HXOPT_INC`` and ``HXOPT_DEC`` may be specified at a time, +and they require that the base type is ``HXTYPE_NONE``, or they will +have no effect. An example may be found below. + +``HXOPT_NOT`` + Binary negation of the argument directly after reading it from the + command line into memory. Any of the three following operations are + executed with the already-negated value. + +``HXOPT_OR`` + Apply bitwise OR on the pointee with the specified/transformed value. + +``HXOPT_AND`` + Apply bitwise AND on the pointee with the specified/transformed value. + +``HXOPT_XOR`` + Apply bitwise XOR on the pointee with the specified/transformed value. + +Only one of ``HXOPT_OR``, ``HXOPT_AND`` and ``HXOPT_XOR`` may be specified at +a time, but they can be used with any integral type (``HXTYPE_UINT``, +``HXTYPE_ULONG``, etc.). An example can be found below. + +``HXOPT_OPTIONAL`` + This flag allows for an option to take zero or one argument. Needless + to say that this can be confusing to the user. iptables's ``-L`` option + for example is one of this kind (though it does not use the libHX + option parser). When this flag is used, ``-f -b`` is interpreted as + ``-f`` without an argument, as is ``-f --bar`` — things that look like + an option take precedence over an option with an optional argument. + ``-f -`` of course denotes an option with an argument, as ``-`` is + often used to indicate standard input/output. + + +Special entries +=============== + +HXopt provides two special entries via macros: + +``HXOPT_AUTOHELP`` + Adds entries to recognize ``-?`` and ``--help`` that will display the + (long-format) help screen, and ``--usage`` that will display the short + option syntax overview. All three options will exit the program + afterwards. + +``HXOPT_TABLEEND`` + This sentinel marks the end of the table and is required on all tables. + (See examples for details.) + + +Invoking the parser +=================== + +.. code-block:: c + + int HX_getopt(const struct HXoption *options_table, int *argc, const char ***argv, unsigned int flags);HX_getopt + +``HX_getopt`` is the actual parsing function. It takes the option table, and a +pointer to your argc and argv variables that you get from the main function. +The parser will, by default, consume all options and their arguments, similar +to Perl's ``Getopt::Long`` module. ``*argv`` is then updated to point to a new +array of strings (to be deallocated with ``HX_zvecfree``) and ``*argc`` is +updated accordingly. Additional flags can control the exact behavior of +``HX_getopt``: + +``HXOPT_PTHRU`` + “Passthrough mode”. Any unknown options are not “eaten” and are instead + passed back into the resulting argv array. + +``HXOPT_QUIET`` + Do not print any diagnostics when encountering errors in the user's + input. + +``HXOPT_HELPONERR`` + Display the (long-format) help when an error, such as an unknown option + or a violation of syntax, is encountered. + +``HXOPT_USAGEONERR`` + Display the short-format usage syntax when an error is encountered. + +``HXOPT_RQ_ORDER`` + Specifying this option terminates option processing when the first + non-option argument in argv is encountered. This behavior is also + implicit when the environment variable ``POSIXLY_CORRECT`` is set. + +``HXOPT_KEEP_ARGV`` + Do not modify ``argc`` and ``argv`` at all. + +The return value can be one of the following: + +``HXOPT_ERR_SUCCESS`` + Parsing was successful. + +``HXOPT_ERR_UNKN`` + An unknown option was encountered. + +``HXOPT_ERR_VOID`` + An argument was given for an option which does not allow one. In + practice this only happens with ``--foo=bar`` when ``--foo`` is of type + ``HXTYPE_NONE``, ``HXTYPE_VAL`` or ``HXTYPE_SVAL``. This does not + affect ``--foo bar``, because this can be unambiguously interpreted as + ``bar`` being a remaining argument to the program. + +``HXOPT_ERR_MIS`` + Missing argument for an option that requires one. + +``HXOPT_ERR_AMBIG`` + An abbreviation of a long option was ambiguous. + +negative non-zero + Failure on behalf of lower-level calls; errno. + + +Pitfalls +======== + +Staticness of tables +-------------------- + +The following is an example of a possible pitfall regarding ``HXTYPE_STRDQ``: + +.. code-block:: c + + static struct HXdeque *dq; + + static bool get_options(int *argc, const char ***argv) + { + static const struct HXoption options_table[] = { + {.sh = 'N', .type = HXTYPE_STRDQ, .ptr = dq, + .help = "Add name"}, + HXOPT_TABLEEND, + }; + return HX_getopt(options_table, argc, argv, HXOPT_USAGEONERR) == + HXOPT_ERR_SUCCESS; + } + + int main(int argc, const char **argv) + { + dq = HXdeque_init(); + get_options(&argc, &argv); + return 0; + } + +The problem here is that ``options_table`` is, due to the static keyword, +initialized at compile-time when ``dq`` is still ``NULL``. To counter this +problem and have it doing the right thing, you must remove the static qualifier +on the options table when used with ``HXTYPE_STRDQ``, so that it will be +evaluated when it is first executed. + +It was not deemed worthwhile to have ``HXTYPE_STRDQ`` take an indirect +``HXdeque`` (``struct HXdeque **``) instead just to bypass this issue. (Live +with it.) + +Limitations +----------- + +The HX option parser has been influenced by both popt and Getopt::Long, but +eventually, there are differences: + +* Long options with a single dash (``-foo bar``). This unsupported + syntax clashes easily with support for option bundling or squashing. In case + of bundling, ``-foo`` might actually be ``-f -o -o``, or ``-f oo`` in case of + squashing. It also introduces redundant ways to specify options, which is not + in the spirit of the author. + +* Options using a ``+`` as a prefix, as in ``+foo``. Xterm for + example uses it as a way to negate an option. In the author's opinion, using + one character to specify options is enough — by GNU standards, a negator is + named ``--no-foo``. + +* Table nesting like implemented in popt. HXopt has no provision for nested + tables, as the need has not come up yet. It does however support chained + processing. You cannot do nested tables even with callbacks, as the new argv + array is only put in place shortly before ``HX_getopt`` returns. + + +Examples +======== + +Basic example +------------- + +The following code snippet should provide an equivalent of the +GNU getopt sample.[#f5] + +.. [#f5] http://www.gnu.org/software/libtool/manual/libc/Example-of-Getopt.html\#Example-of-Getopt + +.. code-block:: c + + #include <stdio.h> + #include <stdilb.h> + #include <libHX/option.h> + + int main(int argc, const char **argv) + { + int aflag = 0; + int bflag = 0; + char *cflag = NULL; + + struct HXoption options_table[] = { + {.sh = 'a', .type = HXTYPE_NONE, .ptr = &aflag}, + {.sh = 'b', .type = HXTYPE_NONE, .ptr = &bflag}, + {.sh = 'c', .type = HXTYPE_STRING, .ptr = &cflag}, + HXOPT_AUTOHELP, + HXOPT_TABLEEND, + }; + + if (HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR) != + HXOPT_ERR_SUCCESS) + + return EXIT_FAILURE; + + printf("aflag = %d, bflag = %d, cvalue = %s\n", + aflag, bflag, cvalue); + + while (*++argv != NULL) + printf("Non-option argument %s\n", *argv); + + return EXIT_SUCCESS; + } + +Verbosity levels +---------------- + +.. code-block:: c + + static int verbosity = 1; /* somewhat silent by default */ + static const struct HXoption options_table[] = { + {.sh = 'q', .type = HXTYPE_NONE | HXOPT_DEC, .ptr = &verbosity, + .help = "Reduce verbosity"}, + {.sh = 'v', .type = HXTYPE_NONE | HXOPT_INC, .ptr = &verbosity, + .help = "Increase verbosity"}, + HXOPT_TABLEEND, + }; + +This sample option table makes it possible to turn the verbosity of the program +up or down, depending on whether the user specified ``-q`` or ``-v``. By passing +multiple ``-v`` flags, the verbosity can be turned up even more. The range depends +on the ``int`` data type for your particular platform and compiler; if you want +to have the verbosity capped at a specific level, you will need to use an extra +callback: + +.. code-block:: c + + static int verbosity = 1; + + static void v_check(const struct HXoptcb *cbi) + { + if (verbosity < 0) + verbosity = 0; + else if (verbosity > 4) + verbosity = 4; + } + + static const struct HXoption options_table[] = { + {.sh = 'q', .type = HXTYPE_NONE | HXOPT_DEC, .ptr = &verbosity, + .cb = v_check, .help = "Lower verbosity"}, + {.sh = 'v', .type = HXTYPE_NONE | HXOPT_INC, .ptr = &verbosity, + .cb = v_check, .help = "Raise verbosity"}, + HXOPT_TABLEEND, + }; + +Mask operations +--------------- + +.. code-block:: c + + /* run on all CPU cores by default */ + static unsigned int cpu_mask = ~0U; + /* use no network connections by default */ + static unsigned int net_mask = 0; + static struct HXoption options_table[] = { + {.sh = 'c', .type = HXTYPE_UINT | HXOPT_NOT | HXOPT_AND, .ptr = &cpu_mask, + .help = "Mask of cores to exclude", .htyp = "cpu_mask"}, + {.sh = 'n', .type = HXTYPE_UINT | HXOPT_OR, .ptr = &net_mask, + + .help = "Mask of network channels to additionally use", + .htyp = "channel_mask"}, + HXOPT_TABLEEND, + }; + +What this options table does is ``cpu_mask &= ~x`` and ``net_mask |= y``, the +classic operations of clearing and setting bits. + +Support for non-standard actions +-------------------------------- + +Supporting additional types or custom storage formats is easy, by simply using +``HXTYPE_STRING``, ``NULL`` as the data pointer (usually by not specifying it +at all), the pointer to your data in the user-specified pointer ``uptr``, and +the callback function in ``cb``. + +.. code-block:: c + + struct fixed_point { + int integral; + unsigned int fraction; + }; + + static struct fixed_point number; + + static void fixed_point_parse(const struct HXoptcb *cbi) + { + char *end; + + number.integral = strtol(cbi->data, &end, 0); + if (*end == '\0') + number.fraction = 0; + else if (*end == '.') + number.fraction = strtoul(end + 1, NULL, 0); + else + fprintf(stderr, "Illegal input.\n"); + } + + static const struct HXoption options_table[] = { + {.sh = 'n', .type = HXTYPE_STRING, .cb = fixed_point_parse, + .uptr = &number, .help = "Do this or that", + HXOPT_TABLEEND, + + }; + +Chained argument processing +--------------------------- + +On the first run, only ``--cake`` and ``--fruit`` is considered, which is then +used to select the next set of accepted options. Note that +``HXOPT_DESTROY_OLD`` is used here, which causes the ``argv`` that is produced +by the first invocation of ``HX_getopt`` in the ``get_options`` function to be +freed as it gets replaced by a new argv again by ``HX_getopt`` in +``get_cakes``/``get_fruit``. ``HXOPT_DESTROY_OLD`` is however not specified in +the first invocation, because the initial argv resides on the stack and cannot +be freed. + +.. code-block:: c + + static bool get_cakes(int *argc, const char ***argv) + { + struct HXoption option_table[] = { + ... + }; + return HX_getopt(cake_table, argc, argv, + HXOPT_USAGEONERR | HXOPT_DESTROY_OLD) == HXOPT_ERR_SUCCESS; + } + + static bool get_fruit(int *argc, const char ***argv) + { + struct HXoption fruit_table[] = { + ... + }; + return HX_getopt(fruit_table, argc, argv, + HXOPT_USAGEONERR | HXOPT_DESTROY_OLD) == HXOPT_ERR_SUCCESS; + } + + static bool get_options(int *argc, const char ***argv) + { + int cake = 0, fruit = 0; + struct HXoption option_table[] = { + {.ln = "cake", .type = HXTYPE_NONE, .ptr = &cake}, + {.ln = "fruit", .type = HXTYPE_NONE, .ptr = &fruit}, + HXOPT_TABLEEND, + }; + if (HX_getopt(option_table, argc, argv, HXOPT_PTHRU) != HXOPT_ERR_SUCCESS) + return false; + if (cake) + return get_cakes(argc, argv); + else if (fruit) + return get_fruit(argc, argv); + return false; + } diff --git a/doc/process_management.rst b/doc/process_management.rst new file mode 100644 index 0000000..8fe282b --- /dev/null +++ b/doc/process_management.rst @@ -0,0 +1,233 @@ +================== +Process management +================== + +Historic note: The process code comes from a time before posix_spawn. It also +relies on the POSIX functions ``fork``, ``execv``, ``execvp`` and ``pipe``, so +it may not be available everywhere. Where this is the case, the functions will +return ``-ENOSYS``. + +Process metadata structure +========================== + +.. code-block:: c + + #include <libHX/proc.h> + + struct HXproc { + const struct HXproc_ops *p_ops; + void *p_data; + unsigned int p_flags; + + /* Following members should only be read */ + int p_stdin, p_stdout, p_stderr; + int p_pid; + char p_status; + bool p_exited, p_terminated; + }; + +When creating a new process with the intent of running it asynchronously (using +``HXproc_run_async``), the first three fields must be filled in by the user. + +``p_ops`` + A table of callbacks, generally used for setting and/or + restoring signals before/after execution. This member may be + ``NULL``. + +``p_data`` + The user may provide a pointer of his choosing. It will be + passed the callback functions when invoked. + +``p_flags`` + Process creation flags, see below. + +After the subprocess has been started, ``HXproc_run_async`` will have filled in +some fields: + +``p_stdin`` + If ``HXPROC_STDIN`` was specified in ``p_flags``, ``p_stdin`` will be + assigned the write side file descriptor of the subprocess's to-be + stdin. The subprocess will get the read side file descriptor in this + member. This is so that the correct fd is used in when + ``p_ops->p_postfork`` is called. + +``p_stdout`` + If ``HXPROC_STDOUT`` is specified in ``p_flags``, ``p_stdout`` will be + assigned the read side file descriptor of the subprocess's to-be + stdout. The subprocess will get the write side file descriptor value + from this member. + +``p_stderr`` + If ``HXPROC_STDERR`` is specified in ``p_flags``, ``p_stderr`` will be + assigned the read side file descriptor of the subprocess's to-be stderr, and + the subprocess will get the write side fd. + +``p_pid`` + The process ID of the spawned process. + +Upon calling ``HXproc_wait``, further fields will have been filled when the +function returns: + +``p_exited`` + Whether the process exited normally (cf. signalled/terminated). + +``p_terminated`` + Whether the process was terminated (signalled). + +``p_status`` + The exit status of the process or the termination signal. + +Flags +----- + +Possible values for the ``p_flags`` member are: + +``HXPROC_STDIN`` + The subprocess's stdin file descriptor shall be connected to the master + program, that is, not inherit the stdin of the master. Cannot be used + with ``HXproc_run_sync`` (because there would be no one to provide data + in a sync operation). + +``HXPROC_STDOUT`` + Connect the stdout file descriptor of the subprocess with the master. + Cannot be used with ``HXproc_run_sync``. + +``HXPROC_STDERR`` + Connect the stderr file descriptor of the subprocess with the master. + Cannot be used with ``HXproc_run_sync``. + +``HXPROC_NULL_STDIN`` + The subprocess's stdin file descriptor shall be connected to + ``/dev/null``. ``HXPROC_STDIN`` and ``HXPROC_NULL_STDIN`` are mutually + exclusive. + +``HXPROC_NULL_STDOUT`` + Connect the stdout file descriptor of the subprocess to ``/dev/null``, + thereby essentially discarding its output. ``HXPROC_STDOUT`` and + ``HXPROC_NULL_STDOUT`` are mutually exclusive. + +``HXPROC_NULL_STDERR`` + Connect the stderr file descriptor of the subprocess to ``/dev/null``, + thereby essentially discarding its output. ``HXPROC_STDERR`` and + ``HXPROC_NULL_STDERR`` are mutually exclusive. + +``HXPROC_VERBOSE`` + Have the subprocess print an error message to stderr if exec'ing + returned an error. + +``HXPROC_A0`` + ``argv[0]`` refers to program file, while ``argv[1]`` to the program + invocation name, with ``argv[2]`` being the first argument, etc. + Without this flag, ``argv[0]`` will be both the program file and + program invocation name, and arguments begin at ``argv[1]``. + +``HXPROC_EXECV`` + Normally, ``execvp`` will be used which scans ``$PATH for the program. + Use this flag to use ``execv`` instead, which will not do such thing. + +Callbacks +========= + +.. code-block:: c + + #include <libHX/proc.h> + + struct HXproc_ops { + void (*p_prefork)(void *); + void (*p_postfork)(void *); + void (*p_complete)(void *); + }; + +``struct HXproc_ops`` provides a way to run user-specified functions just +before the fork, after, and when the process has been waited for. They can be +used to set and/or restore signals as needed, for example. The function +pointers can be ``NULL``. The ``p_data`` member is passed as an argument. + +``p_prefork`` + Run immediately before calling ``fork``. This is useful for taking any + action regarding signals, like setting ``SIGCHLD`` to ``SIG_DFL``, or + ``SIGPIPE`` to ``SIG_IGN``, for example. + +``p_postfork`` + Run in the subprocess (and only there) after forking. Useful + to do a ``setuid`` or other change in privilege level. + +``p_complete`` + Run in ``HXproc_wait`` when the process has been waited for. + Useful to restore the signal handler(s). + +Process control +=============== + +.. code-block:: c + + #include <libHX/proc.h> + + int HXproc_run_async(const char *const *argv, struct HXproc *proc); + int HXproc_run_sync(const char *const *argv, unsigned int flags); + int HXproc_wait(struct HXproc *proc); + +``HXproc_run_async`` + Start a subprocess according to the parameters in proc. Returns a + negative errno code if something went wrong, or positive non-zero on + success. + +``HXproc_run_sync`` + Start a subprocess synchronously, similar to calling ``system``, but + with the luxury of being able to specify arguments as separate strings + (via argv) rather than one big command line that is run through the + shell. ``flags`` is a value composed of the HXproc flags mentioned + above. ``HXPROC_STDIN``, ``HXPROC_STDOUT`` and ``HXPROC_STDERR`` are ignored + because there would be no one in a synchronous execution that + could supply data to these file descriptors or read from them.[#f1]_ + +.. [#f1] Even for threads, please just use the async model. + +``HXproc_wait`` + Wait for a subprocess to terminate, if it has not already. It will also + retrieve the exit status of the process and store it in the ``struct + HXproc``. + +The return value will be positive non-zero on success, or negative on +error. Underlying system function's errors are returned, plus: + +``EINVAL`` + Flags were not accepted. + + +User identity control +===================== + +.. code-block: c + + #include <libHX/proc.h> + + int HXproc_switch_user(const char *user, const char *group); + +``HXproc_switch_user`` is a wrapper for changing process identity to an +unprivileged user. This utilizes ``setuid``, and possibly ``setgid`` plus +``initgroups``. + +``user`` can either be a username or a numeric UID in string form, the latter +of which will be parsed with strtoul in automatic base. If ``user`` is ``NULL`` +or the empty string, no change of process user identity occurs. + +``group`` can likewise be a name or GID. When ``group`` is ``NULL``, the +process group(s) will change to the the user's group(s) — both primary and +secondary — provided a user was specified (see above). When ``gruop`` is the +empty string, no change of process group identity occurs. + + +Process information +=================== + +.. code-block:: c + + #include <libHX/proc.h> + + int HXproc_top_fd(void); + +``HXproc_top_fd`` + This function gives a heuristic for the highest fd in the process. + The returned number may be higher than the highest live fd actually. + On error, negative errno is returned. diff --git a/doc/random_numbers.rst b/doc/random_numbers.rst new file mode 100644 index 0000000..2b87d5d --- /dev/null +++ b/doc/random_numbers.rst @@ -0,0 +1,32 @@ +============== +Random numbers +============== + +Function overview +================= + +.. code-block:: c + + #include <libHX/misc.h> + + int HX_rand(void); + unsigned int HX_irand(unsigned int min, unsigned int max); + double HX_drand(double min, double max); + +``HX_rand`` + Retrieve the next random number. + +``HX_irand`` + Retrieve the next random number and fold it such that *min <= n < max*. + +``HX_drand`` + Retrieve the next random number and fold it such that *min <= n < max*. + +Implementation information +========================== + +``/dev/urandom`` will be used to seed the libc-level number generator. + +``/dev/random`` is not used on Linux because it may block during read, and +/dev/urandom is just as good when there is entropy available. If you need +definitive PRNG security, perhaps use one from a crypto suite such as OpenSSL. diff --git a/doc/shconfig.rst b/doc/shconfig.rst new file mode 100644 index 0000000..2e30a60 --- /dev/null +++ b/doc/shconfig.rst @@ -0,0 +1,116 @@ +===================================== +Shell-style configuration file parser +===================================== + +libHX provides functions to read shell-style configuration files. Such files +are common, for example, in ``/etc/sysconfig`` on Linux systems. The format is +pretty basic; it only knows about ``key=value`` pairs and does not even have +sections like INI files. Not relying on any features however makes them quite +interchangable as the syntax is accepted by Unix Shells. + +Lines beginning with a hash mark (``#``) are ignored, as are empty lines and +unrecognized keys. + +.. code-block:: sh + + # Minimum / maximum values for automatic UID selection + UID_MIN=100 + UID_MAX=65000 + + # Home directory base + HOME="/home" + #HOME="/export/home" + +Any form of variable or parameter substitution or expansion is highly +implementation specific, and is not supported in libHX's reader. Even Shell +users should not rely on it as you never know in which context the +configuration files are evaluated. Still, you will have to escape specific +sequences like you would need to in Shell. The use of single quotes is +acceptable. That means:: + +.. code-block:: sh + + AMOUNT="US\$5" + AMOUNT='US$5' + +Synopsis +======== + +.. code-block:: c + + #include <libHX/option.h> + + int HX_shconfig(const char *file, const struct HXoption *table); + int HX_shconfig_pv(const char **path_vec, const char *file, const struct HXoption *table, unsigned int flags); + struct HXmap *HX_shconfig_map(const char *file); + +The shconfig parser reuses ``struct HXoption`` that fits very well in +specifying name-pointer associations. ``HX_shconfig`` will read the given file +using the key-to-pointer mappings from the table to store the variable +contents. Of ``struct HXoption``, only the ``ln``, ``type`` and ``ptr`` fields +are used. The list of accepted types is described in +section [subsec:option-types]. + +To parse a file, call ``HX_shconfig`` function with the corresponding +parameters. If you want to read configuration files from different paths, i.e. +to build up on default values, you can use ``HX_shconfig_pv``, which is a +variant for reading a file from multiple locations. Its purpose is to +facilitate reading system-wide settings which are then overriden by a file in +the users home directory, for example (per-setting-override). It is also +possible to do per-file-override, that is, a file in the home directory has +higher precedence than a system-wide one in such a way that the system-wide +configuration file is not even read. This is accomplished by traversing the +paths in the “other” direction (actually you have to turn the array around) and +stopping at the first existing file by use of the ``SHCONF_ONE`` flag. + +.. [#f2] pv = path vector + +``HX_shconfig_map`` will return all entries from the file in a HXmap, usable +for parsing arbitrary keys without having to specify any static key table. + +``SHCONF_ONE`` + Parsing files will stop after one file has been successfully parsed. + This allows for a “personal overrides system config” style. + +The call to ``HX_shconfig`` will either return >0 for success, 0 for no success +(actually, this is never returned) and ``-errno`` for an error. + +Example +======= + +Per-setting-override +-------------------- + +This example sources key-value pairs from a configuration file in a system +location (``/etc``) first, before overriding specific keys with new values from the +file in the home directory. + +.. code-block:: c + + long uid_min, uid_max; + char *passwd_file; + struct HXoption options_table[] = { + {.ln = "UID_MIN", .type = HXTYPE_LONG, .ptr = &uid_min}, + {.ln = "UID_MAX", .type = HXTYPE_LONG, .ptr = &uid_max}, + {.ln = "PWD_FILE", .type = HXTYPE_STRING, .ptr = &passwd_file}, + HXOPT_TABLEEND, + }; + const char *home = getenv("HOME"); + const char *paths[] = {"/etc", home, NULL}; + HX_shconfig(paths, "test.cf", options_table, 0); + +Per-file-override +----------------- + +This particular example reads from the file in the home directory first (if it +exists), but stops after it has been successful, so any subsequent locations +listed in the paths variable are not read. This has the effect that the file +from the home directory has the highest priority too like in the previous +example, but without any keys from the system files. Note the ``SHCONF_ONE`` +flag. + +.. code-block:: c + + const char *home = getenv("HOME"); + const char *paths[] = {home, "/usr/local/etc", "/etc", NULL}; + HX_shconfig_pv(paths, "test.cf", options_table, SHCONF_ONE); diff --git a/doc/slurp.c b/doc/slurp.c deleted file mode 100644 index f0b047d..0000000 --- a/doc/slurp.c +++ /dev/null @@ -1,38 +0,0 @@ -static void *p_slurp(const char *file, size_t *outsize) -{ - struct stat sb; - int ret = 0, fd = open(file, O_RDONLY | O_BINARY); - void *buf = NULL; - ssize_t rdret; - - if (fd < 0) { - fprintf(stderr, "ERROR: Slurping %s failed: %s\n", - file, strerror(errno)); - return NULL; - } - if (fstat(fd, &buf) < 0) { - ret = errno; - perror("fstat"); - goto out; - } - *outsize = sb.st_size; /* truncate if need be */ - buf = malloc(*outsize); - if (buf == NULL) { - ret = errno; - perror("malloc"); - goto out; - } - rdret = read(fd, buf, *outsize); - if (rdret < 0) { - ret = errno; - perror("read"); - free(buf); - } else { - *outsize = rdret; - } - out: - close(fd); - errno = ret; - return buf; -} - diff --git a/doc/socket_functions.rst b/doc/socket_functions.rst new file mode 100644 index 0000000..ead0f08 --- /dev/null +++ b/doc/socket_functions.rst @@ -0,0 +1,34 @@ +================ +Socket functions +================ + +.. code-block:: c + + #include <libHX/socket.h> + + int HX_socket_from_env(const struct addrinfo *ai, const char *intf); + int HX_sockaddr_is_local(const struct sockaddr *, socklen_t, unsigned int flags); + int HX_ipaddr_is_local(const char *, unsigned int flags); + +``HX_socket_from_env`` + The function looks up the current process's file descriptors for a + socket that is listening and which matches the given addrinfo and + (optionally) intf if the latter is not NULL``. Upon success, the fd + number is returned, or -1 if no file descriptor matched. No errors are + signalled. + +``HX_sockaddr_is_local`` + Attempts to determine if the given socket address refers to a local + address. This function may be helpful in determining whether a process + should spend any time (or not) on compressing data before sending to a + peer. The definition of "local" is generally dependent upon the network + APIs. The ``flags`` parameter can contain ``AI_V4MAPPED`` if + IPv4-mapped IPv6 addresses should be recognized. The function returns + >0 if the address is considered local, 0 if not, and any other + negative value for a system error that makes the result + indeterminate. + +``HX_ipaddr_is_local`` + Takes a text representation of an IPv6/IPv4 address and, after + transformation, calls ``HX_sockaddr_is_local``. ``flags`` and + return value behave the same as that. diff --git a/doc/string_formatter.rst b/doc/string_formatter.rst new file mode 100644 index 0000000..77badf8 --- /dev/null +++ b/doc/string_formatter.rst @@ -0,0 +1,211 @@ +======================= +String format templates +======================= + +HXfmt is a template system for by-name variable expansion. It can be used to +substitute placeholders in format strings supplied by the user by appropriate +expanded values defined by the program. Such can be used to allow for flexible +configuration files that define key-value mappings such as + +:: + + detect_peer = ping6 -c1 %(ADDR) + #detect_peer = nmap -sP %(ADDR) | grep -Eq "appears to be up" + +Consider, for example, a monitoring daemon that allows the administrator to +specify a program of his choice with which to detect whether a peer is alive or +not. The user can choose any program that is desired, but evidently needs to +pass the address to be tested to the program. This is where the daemon will do +a substitution of the string ``ping -c1 %(ADDR)`` it read from the config file, +and put the actual address in it before finally executing the command. + +.. code-block:: c + + printf("%s has %u files\n", user, num); + printf("%2$u files belong to %1$s\n", num, user); + +``%s`` (or ``%1$s`` here) specifies how large ``user`` is — ``sizeof(const char +*)`` in this case. If that is missing, there is no way to know the offset of +``num`` relative to ``user``, making varargs retrieval impossible. + +``printf``, at least from GNU libc, has something vaguely similar: positional +parameters. They have inherent drawbacks, though. One is of course the question +of portability, but there is a bigger issue. All parameters must be specified, +otherwise there is no way to determine the location of all following objects +following the missing one on the stack in a varargs-function like printf, which +makes it unsuitable to be used with templates where omitting some placeholders +is allowed. + +Initialization, use and deallocation +==================================== + +.. code-block:: c + + #include <libHX/option.h> + + struct HXformat_map *HXformat_init(void); + void HXformat_free(struct HXformat_map *table); + int HXformat_add(struct HXformat_map *table, const char *key, const void *ptr, unsigned int ptr_type); + +``HXformat_init`` will allocate and set up a string-to-string map that is used +for the underlying storage, and returns it. + +To release the substitution table and memory associated with it, call +``HXformat_free``. + +``HXformat_add`` is used to add substitution entries. One can also specify +other types such as numeric types. ``ptr_type`` describes the type behind +``ptr`` and the constants are the same from ``option.h`` (cf. section on +optionp arsing) — not all constants can be used, though, and their meaning also +differs from what ``HX_getopt`` or ``HX_shconfig`` use them for — the two could +be seen as “read” operations, while ``HXformat`` is a write operation. + +Immediate types +=============== + +“Immediate types” are resolved when ``HXformat_add`` is called, that is, they +are copied and inserted into the tree, and are subsequently independent from +any changes to variables in the program. Because the HXopt-originating type +name, i.e. ``HXTYPE_*``, is also used for deferred types, the constant +``HXFORMAT_IMMED`` needs to be specified on some types to denote an immediate +value. + +* ``HXTYPE_STRING`` — ptr is a ``const char *``. + +* ``HXTYPE_{U,}{CHAR,SHORT,INT,LONG,LLONG} | HXFORMAT_IMMED`` — + mapping to the standard typesk + +Deferred types +============== + +“Deferred types” are resolved on every invocation of a formatter function +(``HXformat_*printf``). The expansions may be changed by modifying the +underlying variable pointed to, but the pointer must remain valid and its +pointee not go out of scope. Code samples are provided below. + +* ``HXTYPE_STRP`` — ptr is a ``const char *const *``; the + pointer resolution is deferred until the formatter is called with one of the + ``HXformat_*printf`` functions. Deferred in the sense it is always resolved + anew. + +* ``HXTYPE_BOOL`` — ptr is a ``const int *``. + +* ``HXTYPE_{U,}..``, ``HXTYPE_FLOAT``, ``HXTYPE_DOUBLE`` — mapping to the + standard types with one indirection (e.g. ``int *``). + +Invoking the formatter +====================== + +.. code-block:: c + + int HXformat_aprintf(struct HXformat_map *table, hxmc_t **dest, const char *template); + int HXformat_sprintf(struct HXformat_map *table, char *dest, size_t size, const char *template); + int HXformat_fprintf(struct HXformat_map *table, FILE *filp, const char *template); + +``HXformat_aprintf`` + Substitutes placeholders in template using the given table. This will + produce a string in a HX memory container (``hxmc_t``), and the pointer + is placed into ``*dest``. The caller will be responsible for freeing it + later when it is done using the result. + +``HXformat_sprintf`` + Does substitution and stores the expanded result in the buffer ``dest`` + which is of size ``size``. + +``HXformat_fprintf`` + Does substituion and directly outputs the expansion to the given stdio + stream. + +On success, the length of the expanded string is returned (only up to a maximum +of SSIZE_MAX), excluding the trailing ``\0``. While ``HXformat_sprintf`` will +not write more than ``size`` bytes (including the ``\0``), the length it would +have taken is returned, similar to what sprintf does. On error, ``-errno`` is +returned. + +The HXformat function family recognizes make-style like functions and recursive +expansion, described below. + +Functions +========= + +To expand a variable, one uses a syntax like ``%(NAME)`` in the format string. +Recursive expansion like ``%(%(USER))`` is supported; assuming ``%(USER)`` +would expand to ``linux``, HXformat would try to resolve ``%(linux)`` next. +Besides these variable substitutions, HXformat also provides function calls +whose syntax isx ``%(nameOfFunction parameters[...])``. Parameters can be any +text, including variables. Paramters are separated from another by a delimiter +specific to each function. See this list for details: + +* ``%(env variable)`` + + The ``env`` function expands to the string that is stored in the + environmental variable by the given name. + +* ``%(exec command [args...])`` + + The ``exec`` function expands to the standard output of the command. The + command is directly run without shell invocation, so no special character + expansion (wildcards, etc.) takes place. stdin is set to ``/dev/null``. The + parameter delimiter is the space character. To be able to use this function — + as it is relevant to security — the fmt table needs to have a key + with the magic value ``/libhx/exec``. + +* ``%(if condition,[then][,[else]])`` + + If the condition parameter expands to a string of non-zero length, the + function expands to the ``then`` block, otherwise the ``else`` block. The + delimiter used is a comma. + +* ``%(lower text)``, ``%(upper text)`` + + Lowercases or uppercases the supplied argument. As these functions are meant + to take only one argument, there is no delimiter defined that would need + escaping if multiple arguments were supposed to be passed. ``%(lower a,b)`` + is equivalent to ``%(lower "a,b")``. + +* ``%(shell command [args...])`` + + Similar to ``%(exec)``, but invokes the shell inbetween (i.e. ``sh -c + 'command...'``) such that special characters, redirection, and so on can be + used. + +* ``%(substr text,offset[,length])`` + + Extracts a substring out of the given text, starting at offset and running + for the given length. If no length is given, will extract until the end of + the string. If ``offset`` is negative, it specifies the offset from the end + of the string. If ``length`` is negative, that many characters are left off + the end. + +* ``%(snl text)`` + + Strips trailing newlines from text and replaces any other newline by a space. + What happens implicity in Makefiles' ``$(shell ...)`` statements usually is + explicitly separate in libHX. + +Example: Immediate and deferred resolution +========================================== + +.. code-block:: c + + const char *b = "Hello World"; + char c[] = "Hello World"; + struct HXformat_map *table = HXformat_init(); + HXformat_add(table, "%(GREETING1)", b, HXTYPE_STRING); + HXformat_add(table, "%(GREETING2)", &c, HXTYPE_STRP); + b = NULL; + snprintf(c, sizeof(c), "Hello Home"); + HXformat_aprintf(...); + +Upon calling ``HXformat_*printf``, ``%(GREETING1)`` will expand to ``Hello +World`` whereas ``%(GREETING2)`` will expand to ``Hello Home``. + + +Example: Using the %(exec) function +=================================== + +.. code-block:: c + + struct HXformat_map *table = HXformat_init(); + HXformat_add(table, "/libhx/exec", NULL, HXTYPE_IMMED); + HXformat_aprintf(table, &result, "%(exec uname -s)"); diff --git a/doc/string_ops.rst b/doc/string_ops.rst new file mode 100644 index 0000000..9bb711f --- /dev/null +++ b/doc/string_ops.rst @@ -0,0 +1,569 @@ +================= +String operations +================= + +Some string functions are merely present in libHX because they are otherwise +unportable; some are only in the C libraries of the BSDs, some only in GNU +libc. + + +Locating chars +============== + +.. code-block:: c + + #include <libHX/string.h> + + void *HX_memmem(const void *haystack, size_t hsize, const void *needle, size_t nsize); + char *HX_strbchr(const char *start, const char *now, char delimiter); + char *HX_strchr2(const char *s, const char *accept); + size_t HX_strrcspn(const char *s, const char *reject); + +``HX_memmem`` + Analogous to ``strstr``(3), ``memmem`` tries to locate the memory block + pointed to by ``needle`` (which is of length ``nsize``) in the block + pointed to by ``haystack`` (which is of size ``hsize``). It returns a + pointer to the first occurrence in ``haystack``, or ``NULL`` when it + was not found. + +``HX_strbchr`` + Searches the character specified by delimiter in the range from ``now`` + to ``start``. It works like ``strrchr``(3), but begins at ``now`` + rather than the ``end`` of the string. + +``HX_strchr2`` + This function searches the string ``s`` for any set of bytes that are + not specified in the second argument, ``n``. In this regard, the + function is the opposite to ``strpbrk``(3). + +``HX_strrcspn`` + Works like ``strcspn``(3), but processes the string from ``end`` to + ``start``. + + +Extraction +========== + +.. code-block:: c + + #include <libHX/string.h> + + char *HX_basename(const char *s); + char *HX_basename_exact(const char *s); + char *HX_dirname(const char *s); + char *HX_strmid(const char *s, long offset, long length); + +``HX_basename`` + Returns a pointer to the basename portion of the supplied path ``s``. + The result of this function is never ``NULL``, and must never be freed + either. Trailing slashes are not stripped, to avoid having to do an + allocation. In other words, ``HX_basename("/mnt/")`` will return + ``mnt/``. If you need to have the slashes stripped, use + ``HX_basename_exact``. A possible use for this function is, for + example, to derive a logging prefix from ``argv[0]``. + +.. code-block:: c + + int main(int argc, const char **argv) + { + if (foo()) + fprintf(stderr, "%s: Special condition occurred.\n", + HX_basename(argv[0])); + return 0; + } + +``HX_basename_exact`` + The accurate and safe version of ``HX_basename`` that deals with + trailing slashes correctly and produces the same result as + ``dirname``(3). It returns a pointer to a newly-allocated string that + must be freed when done using. ``NULL`` may be returned in case of an + allocation error. + +``HX_dirname`` + Returns a pointer to a new string that contains the directory name + portion (everything except basename). When done using the string, it + must be freed to avoid memory leaks. + +``HX_strmid`` + Extract a substring of length characters from ``s``, beginning at + ``offset``. If ``offset`` is negative, counting beings from the end of + the string; -1 is the last character (not the ``'\0'`` byte). If + ``length`` is negative, it will leave out that many characters off the + end. The function returns a pointer to a new string, and the user has + to free it. + + +In-place transformations +======================== + +.. code-block:: c + + #include <libHX/string.h> + + char *HX_chomp(char *s); + size_t HX_strltrim(char *s); + char *HX_stpltrim(const char *s); + char *HX_strlower(char *s); + char *HX_strrev(char *s); + size_t HX_strrtrim(char *s); + char *HX_strupper(char *s); + +``HX_chomp`` + Removes the characters ``'\r'`` and ``'\n'`` from the right edge of the + string. Returns the original argument. + +``HX_strltrim`` + Trims all whitespace (characters on which ``isspace``(3) returns true) + on the left edge of the string. Returns the number of characters that + were stripped. + +``HX_stpltrim`` + Returns a pointer to the first non-whitespace character in ``s``. + +``HX_strlower`` + Transforms all characters in the string ``s`` into lowercase using + ``tolower``(3). Returns the original argument. + +``HX_strrev`` + Reverse the string in-place. Returns the original argument. + +``HX_strrtrim`` + Trim all whitespace on the right edge of the string. Returns the number + of characters that were stripped. + +``HX_strupper`` + Transforms all characters in the string ``s`` into uppercase using + ``toupper``(3). Returns the original argument. + + +Out-of-place quoting transforms +=============================== + +.. code-block:: c + + #include <libHX/string.h> + + char *HX_strquote(const char *s, unsigned int type, char **free_me); + +``HX_strquote`` will escape metacharacters in a string according to type, and +returns the escaped result. + +Possible values for type: + +``HXQUOTE_SQUOTE`` + Escapes all single quotes and backslashes in a string with a backslash. + (``Ol' \Backslash`` becomes ``Ol\' \\Backslash``.) + +``HXQUOTE_DQUOTE`` + Escapes all double quotes and backslahes in a string with the backslash + method. (``Ol” \Backslash`` becomes ``Ol\” \\Backslash``.) + +``HXQUOTE_HTML`` + Escapes ``'<'``, ``'>'``, ``'&'`` and ``'"'`` by their respective HTML + entities, ``<``, ``>``, ``&`` and ``"``. + +``HXQUOTE_LDAPFLT`` + Escapes the string using backslash-plus-hexcode notation as described + in `RFC 4515`_, to make it suitable for use in an LDAP search + filter. + +``HXQUOTE_LDAPRDN`` + Escapes the string using backslash-plus-hexcode notation as described + in `RFC 4514`_, to make it suitable for use in an LDAP Relative + Distinguished Name. + +``HXQUOTE_BASE64`` + Transforms the string to BASE64, as described in `RFC 4648`_. + +``HXQUOTE_BASE64URL`` + Transforms the string to base64url, as described in `RFC 4648`_. + +``HXQUOTE_BASE64IMAP`` + Transforms the string to base64 for IMAP, as described in `RFC 3501`_. + +``HXQUOTE_URIENC`` + Escapes the string so that it becomes a valid part for an URI. + +``HXQUOTE_SQLSQUOTE`` + Escapes all single quotes in the string by double single-quotes, as + required for using it in a single-quoted SQL string. No surrounding + quotes will be generated to facilitate concatenating of HX_strquote + results. + +``HXQUOTE_SQLBQUOTE`` + Escape all backticks in the string by double backticks, as required for + using it in a backtick-quoted SQL string (used for table names and + columns). No surrounding ticks will be generated to facilitate + concatenation. + +.. _RFC 4514: http://tools.ietf.org/html/rfc4514 +.. _RFC 4515: http://tools.ietf.org/html/rfc4515 +.. _RFC 4648: http://tools.ietf.org/html/rfc4648 + +Specifying an unrecognized type will result in ``NULL`` being returned and +``errno`` be set to ``EINVAL``. + +If ``free_me`` is ``NULL``, the function will always allocate memory, even if +the string needs no quoting. The program then has to free the result: + +.. code-block:: c + + char *s = HX_strquote("<head>", HXQUOTE_HTML, NULL); + printf("%s\n", s); + free(s); + +If ``free_me`` is not ``NULL`` however, the function will put the pointer to +the memory area into ``*free_me``, if the string needed quoting. The program +then has to free that after it is done with the quoted result: + +.. code-block:: c + + char *tmp = NULL; + char *s = HX_strquote("head", HXQUOTE_HTML, &tmp); + printf("%s\n", s); + free(tmp); + +``tmp`` could be ``NULL``, and since ``free(NULL)`` is not an error, this is +perfectly valid. Furthermore, if ``*free_me`` is not ``NULL`` by the time +``HX_strquote`` is called, the function will free it. This makes it possible to +call ``HX_strquote`` in succession without explicit free calls in between: + +.. code-block:: c + + char *tmp = NULL; + printf("%s\n", HX_strquote("<html>", HXQUOTE_HTML, &tmp)); + printf("%s\n", HX_strquote("<head>", HXQUOTE_HTML, &tmp)); + free(tmp); + + +Tokenizing +========== + +.. code-block:: c + + #include <libHX/string.h>libHX/string.h + + char **HX_split(const char *s, const char *delimiters, size_t *fields, int max); + char **HX_split_inplace(char *s, const char *delimiters, int *fields, int max); + int HX_split_fixed(char *s, const char *delimiters, int max, char **arr); + char *HX_strsep(char **sp, const char *delimiters); + char *HX_strsep2(char **sp, const char *dstr); + +``HX_split`` + Splits the string ``s`` on any characters from the ``delimiters`` + string. Both the substrings and the array holding the pointers to these + substrings will be allocated as required; the original string is not + modified. If ``max`` is larger than zero, produces no more than ``max`` + fields. If ``fields`` is not ``NULL``, the number of elements produced + will be stored in ``*fields``. The result is a NULL-terminated array of + ``char *``s, and the user needs to free it when done with it, using + ``HX_zvecfree`` or equivalent. An empty string (zero-length string) for + ``s`` yields a single field. + +``HX_split_inplace`` + Splits the string ``s`` in-place on any characters from the + ``delimiters`` string. The resulting array will hold pointers to parts + of the original string. The array itself needs to be freed by the user, + using ``free``(3), the individual elements must not be freed. The + ``fields`` and ``max`` arguments work as with ``HX_split``. + +``HX_split_fixed`` + Splits the string ``s`` in-place on any characters from the + ``delimiters`` string. The array for the substring pointers must be + provided by the user through the ``arr`` argument. ``max`` must be the + number of elements in the array, or less. The array will *not* be + NULL-terminated[#fixfoot]. The number of fields produced is returned. + +.. [#fixfoot] An implementation may however decide to put ``NULL`` in the + unassigned fields, but this is implementation-dependent. + +``HX_strsep`` + Extract tokens from a string. This implementation of strsep has been + added since the function is non-standard (according to the manpage, + conforms to BSD4.4 only) and may not be available on every operating + system. This function extracts tokens, separated by one of the + characters in ``delimiters``. The string is modified in-place and thus + must be mutable. The delimiters in the string are then overwritten with + ``'\0'``, ``*sp`` is advanced to the character after the delimiter, and + the original pointer is returned. After the final token, ``HX_strsep`` + will return ``NULL``. + +``HX_strsep2`` + Like ``HX_strsep``, but ``dstr`` is not an array of delimiting + characters, but an entire substring that acts as one delimiter. + + +Size-bounded string operations +============================== + +.. code-block:: c + + #include <libHX/string.h> + + char *HX_strlcat(char *dest, const char *src, size_t length); + char *HX_strlcpy(char *dest, const char *src, size_t length); + char *HX_strlncat(char *dest, const char *src, size_t dlen, size_t slen); + size_t HX_strnlen(const char *src, size_t max); + +``HX_strlcat`` and ``HX_strlcpy`` provide implementations of the +BSD-originating ``strlcat``(3) and ``strlcpy``(3) functions. ``strlcat`` and +``strlcpy`` are less error-prone variants for ``strncat`` and ``strncpy`` as +they always take the length of the entire buffer specified by ``dest``, instead +of just the length that is to be written. The functions guarantee that the +buffer is ``'\0'``-terminated. + +``HX_strnlen`` will return the length of the input string or the upper bound +given by ``max``, whichever is less. It will not attempt to access more than +this many bytes in the input buffer. + + +Allocation-related +================== + +.. code-block:: c + + #include <libHX/string.h> + + void *HX_memdup(const void *ptr, size_t length); + char *HX_strdup(const char *str); + char *HX_strndup(const char *str, size_t max); + char *HX_strclone(char **pa, const char *pb); + + #ifdef __cplusplus + template<typename type> type HX_memdup(const void *ptr, size_t length); + #endif + +``HX_memdup`` + Duplicates `length` bytes from the memory area pointed to by ``ptr`` + and returns a pointer to the new memory block. ``ptr`` may not be + ``NULL``. + +``HX_strdup`` + Duplicates the string. The function is equivalent to ``strdup``, but + the latter may not be available on all platforms. ``str`` may be + ``NULL``, in which case ``NULL`` is also returned. + +``HX_strndup`` + Duplicates the input string, but copies at most ``max`` characters. + (The resulting string will be ``NUL``-terminated of course.) ``str`` + may not be ``NULL``. + +``HX_strclone`` + Copies the string pointed to by ``pb`` into ``*pa``. If ``*pa`` was not + ``NULL`` by the time ``HX_strclone`` was called, the string is freed + before a new one is allocated. The function returns ``NULL`` and sets + ``errno`` to ``EINVAL`` if ``pb`` is ``NULL`` (this way it can be + freed), or, if ``malloc`` fails, returns ``NULL`` and leaves ``errno`` + at what ``malloc`` had set it to. The use of this function is + deprecated, albeit no replacement is proposed. + + +Numbers to human-readable sizes with units +========================================== + +.. code-block:: c + + #include <libHX/string.h> + + char *HX_unit_size(char *out, size_t outsize, unsigned long long number, + unsigned int divisor, unsigned int cutoff); + char *HX_unit_size_cu(char *out, size_t outsize, + unsigned long long number, unsigned int divisor); + +``HX_unit_size`` takes an arbitrary number and and produces a more +readily-readable shortened (string) representation with a unit suffix. It does +this by dividing ``number`` by ``pow(divisor, i)`` for some integer _i_ such +that the resulting (integer) quotient is the highest possible value _v_ that is +less than ``cutoff``. This value _v_ is then emitted into ``out`` together with +the corresponding SI prefix. + +In other words, ``cutoff`` is the value when it attempts to do another +iteration of the division. For example, if the cutoff is set at 8192, +then 8191 will stay as-is, but 8192 is reduced to "8K". The popular +``wget`` utility implements a cutoff of 1024. + +Note that the SI prefix for one iteration (i==1), i.e. kilo, is a lower-case +``'k'``. If you need consistent upper-case output in your program, (i.e. K/M/G +instead of k/M/G), use a subsequent call to ``HX_strupper``. + +When ``divisor`` is 0, it defaults to 1000. When ``cutoff`` is 0, an +implementation-defined cutoff point is used. When ``cutoff`` is less than +``divisor``, the result is implementation-defined. + +The output number of ``HX_unit_size`` is always integer; no fractions are +emitted. This is rooted in the following idea: + +* An output like ``1G`` is quite broad and some precision would be nice. The + author has historically preferred 3 digits instead of just 2, thanks to wget + and rsync. + +* ``1.34G`` has the same string length as ``1340M``, i.e. both occupy the same + visual space in console outputs, but the latter has another digit of + precision. + +* By ditching fractions this way, ``HX_unit_size`` also sidesteps the issue of + excess digits being emitted (usually up to 5) from the trivial use (by + wget/rsync) of ``printf("%.2f", v)``. + +(With regard to the 1.34G-vs-1340M argument, do note that, to actually receive +"``1340M``" as output, you need to set a conveniently high cutoff value such +as 10000. Otherwise, you might get "``1G``".) + +The ``HX_unit_size_cu`` function will instead mimic the behavior of coreutils +(/usr/bin/df, /usr/bin/ls). That is, it divides ``number`` by ``pow(divisor, +i)`` for some integer _i_ such that the resulting (real) quotient is +less-than-or-equal ``divisor-1``. It rounds the value up to the next integer if +the fractional part is >90%, and if the quotient is greater-or-equal 10, the +fractional part is stripped and not emitted to ``out``. + +In practice, the rounding up of ``HX_unit_size_cu`` lends itself to display +occupying sizes, whereas the implicit rounding down (of integer divisions) +in ``HX_unit_size`` lend itself to sizes in progress meters. + + +Unit-suffixed numbers to full numbers +===================================== + +.. code-block:: c + + #include <libHX/string.h> + + double HX_strtod_unit(const char *s, char **end, + unsigned int exponent); + unsigned long long HX_strtoull_unit(const char *s, char **end, + unsigned int exponent); + +The ``HX_strtod_unit`` and ``HX_strtoull_unit`` functions behave similar to +``strtod`` and ``strtoul``, respectively, in that they convert the initial part +of the string in ``s`` to a ``double`` and ``unsigned long long``, +respectively, and apply the selected multiplication factor from ``exponent`` in +resolving an optional unit suffix. + +Upon overflow, ``errno`` is set to ``ERANGE`` just like the stdlib functions. +Unlike some implementations of ``strtoul``, negative numbers are outright +rejected. + +.. code-block:: c + + unsigned long long bytes = HX_strtoull_unit("1.5G", NULL, 1024); + + +Conversion from/to human-readable durations with units +====================================================== + +.. code-block:: c + + #include <libHX/string.h> + + unsigned long long HX_strtoull_sec(const char *s, char **end); + char *HX_unit_seconds(char *out, size_t outsize, + unsigned long long seconds, + unsigned int flags); + +``HX_strtoull_sec`` converts a time duration with units, such as ``"15min30s"`` +into an all-seconds value. The recognized unit strings are: ``years``, +``year``, ``y``, ``months``, ``month``, ``days``, ``day``, ``d``, ``hours``, +``hour``, ``h``, ``minutes``, ``minute``, ``min``, ``seconds``, ``second``, +``s`` and the empty string (for seconds). When parsing stops at any point, +``*end`` is set to the location, similar to how the ``strtoull`` C function +would. + +One year is defined to be 365.25 days of 86400 seconds; one month is defined to +be 1/12 such a year. This is consistent with the units employed by systemd. + +``HX_unit_seconds`` is the reverse and transforms the duration given by +``seconds`` into a string representation broken into days, hours, minutes, and +remaining seconds as appropriate. By default, only the d/h/min/s units are +emitted. The ``flags`` argument specifies if any other units should be emitted; +``HXUNIT_YEARS``, ``HXUNIT_MONTHS`` and ``HXUNIT_WEEKS`` are available. + + +Examples +======== + +Using HX_split_fixed +-------------------- + +``HX_split_fixed`` is often used just with scoped automatic-storage variables +and where the field count of interest is fixed, as the example for parsing +``/etc/passwd`` shows: + +.. code-block:: c + + #include <stdio.h> + #include <libHX/string.h> + + char *field[8]; + hxmc_t *line = NULL; + + while (HX_getl(&line, fp) != NULL) { + if (HX_split_fixed(line, ":", ARRAY_SIZE(field), field) < 7) { + fprintf(stderr, "That does not look like a valid line.\n"); + continue; + } + printf("Username: %s\n", field[0]); + } + +Using HX_split_inplace +---------------------- + +Where the number of fields is not previously known and/or estimatable, but the +string can be modified in place, one uses ``HX_split_inplace`` as follows: + +.. code-block:: c + + #include <errno.h> + #include <stdio.h> + #include <libHX/string.h> + + while (HX_getl(&line, fp) != NULL) { + char **field = HX_split_inplace(line, ":", NULL, 0); + if (field == NULL) { + fprintf(stderr, "Badness! %s\n", strerror(errno)); + break; + } + printf("Username: %s\n", field[0]); + free(field); + } + +Using HX_split +-------------- + +Where the string is not modifiable in-place, one has to resort to using the +full-fledged ``HX_split`` that allocates space for each substring. + +.. code-block:: c + + #include <errno.h> + #include <stdio.h> + #include <libHX/string.h> + + while (HX_getl(&line, fp) != NULL) { + char **field = HX_split(line, ":", NULL, 0); + if (field == NULL) { + fprintf(stderr, "Badness. %s\n", strerror(errno)); + break; + } + printf("Username: %s\n", field[0]); + /* Suppose “callme” needs the original string */ + callme(line); + HX_zvecfree(field); + } + +Using HX_strsep +--------------- + +``HX_strsep`` provides for thread- and reentrant-safe tokenizing a string where +strtok from the C standard would otherwise fail. + +.. code-block:: c + + #include <stdio.h> + #include <libHX/string.h> + + char line[] = "root:x:0:0:root:/root:/bin/bash"; + char *wp, *p; + + wp = line; + while ((p = HX_strsep(&wp, ":")) != NULL) + printf("%s\n", p) diff --git a/doc/strlcpy-timing.rst b/doc/strlcpy-timing.rst new file mode 100644 index 0000000..17c7892 --- /dev/null +++ b/doc/strlcpy-timing.rst @@ -0,0 +1,111 @@ +strncpy fills the buffer with \0s if there is room left, which can build up +runtime if the buffer is much larger than the string to be copied. The turning +point on i7-4600U is about when the buffer is 3 times larger or more than the +string. Copying a M-char string into a buffer of size N with different +strategies turned out as follows, not favorably for switching to memcpy +approach: + +M->N: [str minus mem] (str=walltime, mem=walltime) + +:: + + 3-> 4: 0.-18010833 (str=0.053766602 mem=0.071777435) + 3-> 8: 0.-02276861 (str=0.069214041 mem=0.071490902) + 3-> 16: 0.-02594396 (str=0.069160485 mem=0.071754881) + 3-> 32: 0.-06119749 (str=0.064986286 mem=0.071106035) + 3-> 64: 0.-10011776 (str=0.062121350 mem=0.072133126) + 3-> 80: 0.000049152 (str=0.071466420 mem=0.071417268) + 3-> 128: 0.-10057727 (str=0.062143411 mem=0.072201138) + 3-> 256: 0.006148232 (str=0.077881866 mem=0.071733634) + 3->1024: 0.133625167 (str=0.206994485 mem=0.073369318) + 3->2048: 0.335047756 (str=0.405503204 mem=0.070455448) + 7-> 4: 0.-28288138 (str=0.046614065 mem=0.074902203) + 7-> 8: 0.-20974635 (str=0.052778755 mem=0.073753390) + 7-> 16: 0.-06903916 (str=0.068165128 mem=0.075069044) + 7-> 32: 0.-11161234 (str=0.064787697 mem=0.075948931) + 7-> 64: 0.-12026108 (str=0.061544945 mem=0.073571053) + 7-> 80: 0.-01877441 (str=0.072047713 mem=0.073925154) + 7-> 128: 0.-11343544 (str=0.062557326 mem=0.073900870) + 7-> 256: 0.005472409 (str=0.079922333 mem=0.074449924) + 7->1024: 0.133164952 (str=0.206290338 mem=0.073125386) + 7->2048: 0.329050142 (str=0.403909643 mem=0.074859501) + 15-> 4: 0.-28134891 (str=0.046436269 mem=0.074571160) + 15-> 8: 0.-26808385 (str=0.047722251 mem=0.074530636) + 15-> 16: 0.-21857806 (str=0.052866161 mem=0.074723967) + 15-> 32: 0.-15183331 (str=0.058903617 mem=0.074086948) + 15-> 64: 0.-06020317 (str=0.068661890 mem=0.074682207) + 15-> 80: 0.-13077126 (str=0.061986539 mem=0.075063665) + 15-> 128: 0.-05110583 (str=0.069024087 mem=0.074134670) + 15-> 256: 0.010346893 (str=0.085920728 mem=0.075573835) + 15->1024: 0.130128294 (str=0.203516720 mem=0.073388426) + 15->2048: 0.384323201 (str=0.459435357 mem=0.075112156) + 31-> 4: 0.-40592735 (str=0.043398064 mem=0.083990799) + 31-> 8: 0.-40405756 (str=0.043312982 mem=0.083718738) + 31-> 16: 0.-42308714 (str=0.044729400 mem=0.087038114) + 31-> 32: 0.-14127856 (str=0.056652936 mem=0.070780792) + 31-> 64: 0.-01889875 (str=0.069010683 mem=0.070900558) + 31-> 80: 0.001793133 (str=0.072637736 mem=0.070844603) + 31-> 128: 0.-02607933 (str=0.068334098 mem=0.070942031) + 31-> 256: 0.018139903 (str=0.088753971 mem=0.070614068) + 31->1024: 0.133949645 (str=0.204402776 mem=0.070453131) + 31->2048: 0.398049056 (str=0.468551187 mem=0.070502131) + 63-> 4: 0.-40166921 (str=0.043758420 mem=0.083925341) + 63-> 8: 0.-40966732 (str=0.043495110 mem=0.084461842) + 63-> 16: 0.-43784039 (str=0.043770941 mem=0.087554980) + 63-> 32: 0.-31256988 (str=0.046623389 mem=0.077880377) + 63-> 64: 0.-13997348 (str=0.068499638 mem=0.082496986) + 63-> 80: 0.-13916305 (str=0.068620538 mem=0.082536843) + 63-> 128: 0.-08328403 (str=0.074551339 mem=0.082879742) + 63-> 256: 0.004095734 (str=0.087035878 mem=0.082940144) + 63->1024: 0.151451020 (str=0.233770899 mem=0.082319879) + 63->2048: 0.355839456 (str=0.438594030 mem=0.082754574) + 79-> 4: 0.-53092708 (str=0.045118918 mem=0.098211626) + 79-> 8: 0.-54340043 (str=0.043908506 mem=0.098248549) + 79-> 16: 0.-57213292 (str=0.043950458 mem=0.101163750) + 79-> 32: 0.-44929075 (str=0.047104201 mem=0.092033276) + 79-> 64: 0.-40841792 (str=0.060369798 mem=0.101211590) + 79-> 80: 0.-34512567 (str=0.072643063 mem=0.107155630) + 79-> 128: 0.-26004050 (str=0.081177431 mem=0.107181481) + 79-> 256: 0.-14164733 (str=0.093010965 mem=0.107175698) + 79->1024: 0.131262747 (str=0.238379553 mem=0.107116806) + 79->2048: 0.337908136 (str=0.444999897 mem=0.107091761) + 127-> 4: 0.-53463038 (str=0.044954314 mem=0.098417352) + 127-> 8: 0.-54030635 (str=0.044154075 mem=0.098184710) + 127-> 16: 0.-56778235 (str=0.044743552 mem=0.101521787) + 127-> 32: 0.-44858267 (str=0.047231395 mem=0.092089662) + 127-> 64: 0.-42149730 (str=0.059234517 mem=0.101384247) + 127-> 80: 0.-45513663 (str=0.062055806 mem=0.107569469) + 127-> 128: 0.-23468852 (str=0.083671245 mem=0.107140097) + 127-> 256: 0.-04999520 (str=0.102026030 mem=0.107025550) + 127->1024: 0.139261976 (str=0.246475516 mem=0.107213540) + 127->2048: 0.345950301 (str=0.453134545 mem=0.107184244) + 255-> 4: 0.-70209659 (str=0.044940128 mem=0.115149787) + 255-> 8: 0.-71166235 (str=0.044243636 mem=0.115409871) + 255-> 16: 0.-73994321 (str=0.044365563 mem=0.118359884) + 255-> 32: 0.-61137064 (str=0.047746212 mem=0.108883276) + 255-> 64: 0.-58453794 (str=0.059850772 mem=0.118304566) + 255-> 80: 0.-61859639 (str=0.062199397 mem=0.124059036) + 255-> 128: 0.-42561423 (str=0.081341036 mem=0.123902459) + 255-> 256: 0.-35252238 (str=0.127124980 mem=0.162377218) + 255->1024: 0.097331464 (str=0.259751271 mem=0.162419807) + 255->2048: 0.305789595 (str=0.468141377 mem=0.162351782) + 1023-> 4: 0.-161452842 (str=0.043764021 mem=0.205216863) + 1023-> 8: 0.-155095262 (str=0.043698735 mem=0.198793997) + 1023-> 16: 0.-153207918 (str=0.043675714 mem=0.196883632) + 1023-> 32: 0.-152565254 (str=0.047438108 mem=0.200003362) + 1023-> 64: 0.-144192775 (str=0.058773300 mem=0.202966075) + 1023-> 80: 0.-149929950 (str=0.062432021 mem=0.212361971) + 1023-> 128: 0.-132285886 (str=0.080313089 mem=0.212598975) + 1023-> 256: 0.-133526587 (str=0.108033655 mem=0.241560242) + 1023->1024: 0.-90772704 (str=0.311350193 mem=0.402122897) + 1023->2048: 0.088417585 (str=0.490594175 mem=0.402176590) + 1368-> 4: 0.-211901350 (str=0.044167308 mem=0.256068658) + 1368-> 8: 0.-203185010 (str=0.044571028 mem=0.247756038) + 1368-> 16: 0.-200207782 (str=0.044133973 mem=0.244341755) + 1368-> 32: 0.-202440240 (str=0.047977200 mem=0.250417440) + 1368-> 64: 0.-193238434 (str=0.058934429 mem=0.252172863) + 1368-> 80: 0.-200936170 (str=0.062169785 mem=0.263105955) + 1368-> 128: 0.-181397289 (str=0.081740755 mem=0.263138044) + 1368-> 256: 0.-183151788 (str=0.107983466 mem=0.291135254) + 1368->1024: 0.-142070533 (str=0.292431947 mem=0.434502480) + 1368->2048: 0.-16089517 (str=0.508519291 mem=0.524608808) diff --git a/doc/strlcpy-timing.txt b/doc/strlcpy-timing.txt deleted file mode 100644 index 56ed40c..0000000 --- a/doc/strlcpy-timing.txt +++ /dev/null @@ -1,109 +0,0 @@ -strncpy fills the buffer with \0s if there is room left, which can build up -runtime if the buffer is much larger than the string to be copied. The turning -point on i7-4600U is about when the buffer is 3 times larger or more than the -string. Copying a M-char string into a buffer of size N with different -strategies turned out as follows, not favorably for switching to memcpy -approach: - -M->N: [str minus mem] (str=walltime, mem=walltime) - - 3-> 4: 0.-18010833 (str=0.053766602 mem=0.071777435) - 3-> 8: 0.-02276861 (str=0.069214041 mem=0.071490902) - 3-> 16: 0.-02594396 (str=0.069160485 mem=0.071754881) - 3-> 32: 0.-06119749 (str=0.064986286 mem=0.071106035) - 3-> 64: 0.-10011776 (str=0.062121350 mem=0.072133126) - 3-> 80: 0.000049152 (str=0.071466420 mem=0.071417268) - 3-> 128: 0.-10057727 (str=0.062143411 mem=0.072201138) - 3-> 256: 0.006148232 (str=0.077881866 mem=0.071733634) - 3->1024: 0.133625167 (str=0.206994485 mem=0.073369318) - 3->2048: 0.335047756 (str=0.405503204 mem=0.070455448) - 7-> 4: 0.-28288138 (str=0.046614065 mem=0.074902203) - 7-> 8: 0.-20974635 (str=0.052778755 mem=0.073753390) - 7-> 16: 0.-06903916 (str=0.068165128 mem=0.075069044) - 7-> 32: 0.-11161234 (str=0.064787697 mem=0.075948931) - 7-> 64: 0.-12026108 (str=0.061544945 mem=0.073571053) - 7-> 80: 0.-01877441 (str=0.072047713 mem=0.073925154) - 7-> 128: 0.-11343544 (str=0.062557326 mem=0.073900870) - 7-> 256: 0.005472409 (str=0.079922333 mem=0.074449924) - 7->1024: 0.133164952 (str=0.206290338 mem=0.073125386) - 7->2048: 0.329050142 (str=0.403909643 mem=0.074859501) - 15-> 4: 0.-28134891 (str=0.046436269 mem=0.074571160) - 15-> 8: 0.-26808385 (str=0.047722251 mem=0.074530636) - 15-> 16: 0.-21857806 (str=0.052866161 mem=0.074723967) - 15-> 32: 0.-15183331 (str=0.058903617 mem=0.074086948) - 15-> 64: 0.-06020317 (str=0.068661890 mem=0.074682207) - 15-> 80: 0.-13077126 (str=0.061986539 mem=0.075063665) - 15-> 128: 0.-05110583 (str=0.069024087 mem=0.074134670) - 15-> 256: 0.010346893 (str=0.085920728 mem=0.075573835) - 15->1024: 0.130128294 (str=0.203516720 mem=0.073388426) - 15->2048: 0.384323201 (str=0.459435357 mem=0.075112156) - 31-> 4: 0.-40592735 (str=0.043398064 mem=0.083990799) - 31-> 8: 0.-40405756 (str=0.043312982 mem=0.083718738) - 31-> 16: 0.-42308714 (str=0.044729400 mem=0.087038114) - 31-> 32: 0.-14127856 (str=0.056652936 mem=0.070780792) - 31-> 64: 0.-01889875 (str=0.069010683 mem=0.070900558) - 31-> 80: 0.001793133 (str=0.072637736 mem=0.070844603) - 31-> 128: 0.-02607933 (str=0.068334098 mem=0.070942031) - 31-> 256: 0.018139903 (str=0.088753971 mem=0.070614068) - 31->1024: 0.133949645 (str=0.204402776 mem=0.070453131) - 31->2048: 0.398049056 (str=0.468551187 mem=0.070502131) - 63-> 4: 0.-40166921 (str=0.043758420 mem=0.083925341) - 63-> 8: 0.-40966732 (str=0.043495110 mem=0.084461842) - 63-> 16: 0.-43784039 (str=0.043770941 mem=0.087554980) - 63-> 32: 0.-31256988 (str=0.046623389 mem=0.077880377) - 63-> 64: 0.-13997348 (str=0.068499638 mem=0.082496986) - 63-> 80: 0.-13916305 (str=0.068620538 mem=0.082536843) - 63-> 128: 0.-08328403 (str=0.074551339 mem=0.082879742) - 63-> 256: 0.004095734 (str=0.087035878 mem=0.082940144) - 63->1024: 0.151451020 (str=0.233770899 mem=0.082319879) - 63->2048: 0.355839456 (str=0.438594030 mem=0.082754574) - 79-> 4: 0.-53092708 (str=0.045118918 mem=0.098211626) - 79-> 8: 0.-54340043 (str=0.043908506 mem=0.098248549) - 79-> 16: 0.-57213292 (str=0.043950458 mem=0.101163750) - 79-> 32: 0.-44929075 (str=0.047104201 mem=0.092033276) - 79-> 64: 0.-40841792 (str=0.060369798 mem=0.101211590) - 79-> 80: 0.-34512567 (str=0.072643063 mem=0.107155630) - 79-> 128: 0.-26004050 (str=0.081177431 mem=0.107181481) - 79-> 256: 0.-14164733 (str=0.093010965 mem=0.107175698) - 79->1024: 0.131262747 (str=0.238379553 mem=0.107116806) - 79->2048: 0.337908136 (str=0.444999897 mem=0.107091761) - 127-> 4: 0.-53463038 (str=0.044954314 mem=0.098417352) - 127-> 8: 0.-54030635 (str=0.044154075 mem=0.098184710) - 127-> 16: 0.-56778235 (str=0.044743552 mem=0.101521787) - 127-> 32: 0.-44858267 (str=0.047231395 mem=0.092089662) - 127-> 64: 0.-42149730 (str=0.059234517 mem=0.101384247) - 127-> 80: 0.-45513663 (str=0.062055806 mem=0.107569469) - 127-> 128: 0.-23468852 (str=0.083671245 mem=0.107140097) - 127-> 256: 0.-04999520 (str=0.102026030 mem=0.107025550) - 127->1024: 0.139261976 (str=0.246475516 mem=0.107213540) - 127->2048: 0.345950301 (str=0.453134545 mem=0.107184244) - 255-> 4: 0.-70209659 (str=0.044940128 mem=0.115149787) - 255-> 8: 0.-71166235 (str=0.044243636 mem=0.115409871) - 255-> 16: 0.-73994321 (str=0.044365563 mem=0.118359884) - 255-> 32: 0.-61137064 (str=0.047746212 mem=0.108883276) - 255-> 64: 0.-58453794 (str=0.059850772 mem=0.118304566) - 255-> 80: 0.-61859639 (str=0.062199397 mem=0.124059036) - 255-> 128: 0.-42561423 (str=0.081341036 mem=0.123902459) - 255-> 256: 0.-35252238 (str=0.127124980 mem=0.162377218) - 255->1024: 0.097331464 (str=0.259751271 mem=0.162419807) - 255->2048: 0.305789595 (str=0.468141377 mem=0.162351782) -1023-> 4: 0.-161452842 (str=0.043764021 mem=0.205216863) -1023-> 8: 0.-155095262 (str=0.043698735 mem=0.198793997) -1023-> 16: 0.-153207918 (str=0.043675714 mem=0.196883632) -1023-> 32: 0.-152565254 (str=0.047438108 mem=0.200003362) -1023-> 64: 0.-144192775 (str=0.058773300 mem=0.202966075) -1023-> 80: 0.-149929950 (str=0.062432021 mem=0.212361971) -1023-> 128: 0.-132285886 (str=0.080313089 mem=0.212598975) -1023-> 256: 0.-133526587 (str=0.108033655 mem=0.241560242) -1023->1024: 0.-90772704 (str=0.311350193 mem=0.402122897) -1023->2048: 0.088417585 (str=0.490594175 mem=0.402176590) -1368-> 4: 0.-211901350 (str=0.044167308 mem=0.256068658) -1368-> 8: 0.-203185010 (str=0.044571028 mem=0.247756038) -1368-> 16: 0.-200207782 (str=0.044133973 mem=0.244341755) -1368-> 32: 0.-202440240 (str=0.047977200 mem=0.250417440) -1368-> 64: 0.-193238434 (str=0.058934429 mem=0.252172863) -1368-> 80: 0.-200936170 (str=0.062169785 mem=0.263105955) -1368-> 128: 0.-181397289 (str=0.081740755 mem=0.263138044) -1368-> 256: 0.-183151788 (str=0.107983466 mem=0.291135254) -1368->1024: 0.-142070533 (str=0.292431947 mem=0.434502480) -1368->2048: 0.-16089517 (str=0.508519291 mem=0.524608808) diff --git a/doc/time_functions.rst b/doc/time_functions.rst new file mode 100644 index 0000000..d9a57a1 --- /dev/null +++ b/doc/time_functions.rst @@ -0,0 +1,125 @@ +============== +Time functions +============== + +Time in POSIX systems is represented in ``struct timespec``. This structure is +composed of two members: one integer for the number of full seconds in the time +value, and one integer for the number of nanoseconds that remain when +subtracting the full seconds from the time value. POSIX leaves it unspecified +how negative time is to be represented with this structure, so I have devised +an algebra for use with the same struct that gives negative time support. + +Since integers often cannot store negative zero (due to e.g. use of 2s +complements in the language implementation), we will store the minus sign in +the nanosecond member if the integral second part is zero. This gives us the +property that we can test for negative time by looking for whether at least one +member of the structure is negative. Also, we want to avoid storing the minus +in both members to somewhat aid the pretty-printing construct often seen, + +.. code-block:: c + + printf("%ld.%09ld\n", (long)ts.tv_sec, ts.tv_nsec); + +The number of combinations of a (non-zero) negative number, zero and a +(non-zero) positive number is small, so we can actually just exhaustively list +them all. + ++----------------+------------+ +| Representation | Time value | ++================+============+ +| {-1, -1} | illegal | ++----------------+------------+ +| {-1, 0} | -1.0 s | ++----------------+------------+ +| {-1, 1} | -1.1 s | ++----------------+------------+ +| { 0, -1} | -0.1 s | ++----------------+------------+ +| { 0, 0} | 0.0 s | ++----------------+------------+ +| { 0, 1} | 0.1 s | ++----------------+------------+ +| { 1, -1} | illegal | ++----------------+------------+ +| { 1, 0} | 1.0 s | ++----------------+------------+ +| { 1, 1} | 1.1 s | ++----------------+------------+ + +Function list +============= + +.. code-block:: c + + #include <libHX/misc.h> + + bool HX_timespec_isneg(const struct timespec *p); + + struct timespec *HX_timespec_neg(struct timespec *result, + const struct timespec *p); + + struct timespec *HX_timespec_add(struct timespec *result, + const struct timespec *p, const struct timespec *q); + + struct timespec *HX_timespec_sub(struct timespec *delta, + const struct timespec *p, const struct timespec *q); + + struct timespec *HX_timespec_mul(struct timespec *delta, + const struct timespec *p, int f); + + struct timespec *HX_timespec_mulf(struct timespec *delta, + const struct timespec *p, double f); + + struct timeval *HX_timeval_sub(struct timeval *delta, + const struct timeval *p, const struct timeval *q); + + int HX_time_compare(const struct stat *a, const struct stat *b, + int mode); + +``HX_timespec_isneg`` + Determines whether a timespec structure represents (non-zero) negative + time. + +``HX_timespec_neg`` + Computes the negation of the time specified by ``p``. ``result`` and + ``p`` may point to the same structure. + +``HX_timespec_add`` + Calculates the sum of the two times specified by ``p`` and ``q``, which + are of type ``struct timespec``. Any and all of ``result``, ``p`` and + ``q`` may point to the same structure. + +``HX_timespec_sub`` + Calculates the difference between the two timepoints ``p`` and ``q``, + which are of type ``struct timespec`` (nanosecond granularity). + +``HX_timespec_mul`` + Multiplies the time quantum in ``p`` by ``f``. + +``HX_timespec_mulf`` + Multiplies the time quantum in ``p`` by ``f``. + +``HX_timeval_sub`` + Calculates the difference between the two timepoints ``p`` and ``q``, + which are of type ``struct timeval`` (microsecnod granularity). + +``HX_time_compare`` + Compares the timestamps from two struct stats. ``mode`` indicates which + field is compared, which can either be ``'a'`` for the access time, + ``'c'`` for the inode change time, ``'m'`` for the modification time, + or ``'o'`` for the creation time (where available). Returns a negative + number if the time in ``a`` is less than ``b``, zero when they are + equal, or a positive number greater than zero if ``a`` is greater than + ``b``. + +The macros ``HX_TIMESPEC_FMT`` and ``HX_TIMESPEC_EXP`` can be used for passing +and printing a ``struct timespec`` using the ``*printf`` function family: + +.. code-block:: c + + struct timespec p; + clock_gettime(CLOCK_MONOTONIC, &p); + printf("Now: " HX_TIMESPEC_FMT, HX_TIMESPEC_EXP(&p)); + +Similarly, ``HX_TIMEVAL_FMT`` and ``HX_TIMEVAL_EXP`` exist for the older +``struct timeval``. diff --git a/doc/typecheck_casts.rst b/doc/typecheck_casts.rst new file mode 100644 index 0000000..b7f882e --- /dev/null +++ b/doc/typecheck_casts.rst @@ -0,0 +1,178 @@ +=================== +Type-checking casts +=================== + +The C++ language provides “new-style casts”, referring to the four +template-looking invocations ``static_cast<>``, ``const_cast<>``, +``reinterpret_cast<>`` and ``dynamic_cast<>``. No such blessing was given to +the C language, but still, even using macros that expand to the olde cast make +it much easier to find casts in source code and annotate why something was +casted, which is already an improvement. — Actually, it is possible to do a +some type checking, using some GCC extensions, which augments these macros from +their documentary nature to an actual safety measure. + + +``reinterpret_cast`` +==================== + +``reinterpret_cast()`` maps directly to the old-style typecast, +``(type)(expr)``, and causes the bit pattern for the ``expr`` rvalue to be +“reinterpreted” as a new type. You will notice that “reinterpret” is the +longest of all the ``*_cast`` names, and can easily cause lines to grow beyond +80 columns (the good maximum in many style guides). As a side effect, it is a +good indicator that something potentially dangerous might be going on, for +example converting intergers from/to pointer. + +.. code-block:: c + + #include <libHX/defs.h> + + int i; + /* Tree with numeric keys */ + tree = HXhashmap_init(0); + for (i = 0; i < 6; ++i) + HXmap_add(tree, reinterpret_cast(void *, + static_cast(long, i)), my_data); + + +``signed_cast`` +=============== + +This tag is for annotating that the cast was solely done to change the +signedness of pointers to char — and only those. No integers etc. The intention +is to facilitate working with libraries that use ``unsigned char *`` pointers, +such as libcrypto and libssl (from the OpenSSL project) or libxml2, for +example. See table [tab:defs-signed_cast] for the allowed conversions. C++ does +not actually have a ``signed_cast<>``, and one would have to use +``reinterpret_cast<>`` to do the conversion, because ``static_cast<>`` does not +allow conversion from ``const char *`` to ``const unsigned char *``, for +example. (libHX's ``static_cast()`` would also throw at least a compiler +warning about the different signedness.) This is where signed_cast comes in. +(libHX provides a ``signed_cast<>`` for C++ though.) + +.. table :: Accepted conversions for ``signed_cast()`` + ++-----------------------+----+-----+-----+-----+------+------+ +| From \ To | c* | sc* | uc* | Cc* | Csc* | Cuc* | ++=======================+====+=====+=====+=====+======+======+ +| char * | ok | ok | ok | ok | ok | ok | ++-----------------------+----+-----+-----+-----+------+------+ +| signed char * | ok | ok | ok | ok | ok | ok | ++-----------------------+----+-----+-----+-----+------+------+ +| unsigned char * | ok | ok | ok | ok | ok | ok | ++-----------------------+----+-----+-----+-----+------+------+ +| const char * | – | – | - | ok | ok | ok | ++-----------------------+----+-----+-----+-----+------+------+ +| const signed char * | – | – | – | ok | ok | ok | ++-----------------------+----+-----+-----+-----+------+------+ +| const unsigned char * | – | – | – | ok | ok | ok | ++-----------------------+----+-----+-----+-----+------+------+ + + +``static_cast`` +=============== + +Just like C++'s ``static_cast<>``, libHX's ``static_cast()`` verifies that +``expr`` can be implicitly converted to the new type (by a simple ``b = a``). +Such is mainly useful for forcing a specific type, as is needed in varargs +functions such as ``printf``, and where the conversion actually incurs other +side effects, such as truncation or promotion: + +.. code-block:: c + + /* Convert to a type printf knows about */ + uint64_t x = something; + printf("%llu\n", static_cast(unsigned long long, x)); + +Because there is no format specifier for ``uint64_t`` for ``printf`` (well yes, +there is ``PRIu64``), a conversion to an accepted type is necessary to not +cause undefined behavior. Code that does, for example, ``printf("%u")`` on a +``long`` only happens to work on architectures where ``sizeof(unsigned int) == +sizeof(unsigned long)``, such as i386. On x86_64, an ``unsigned long`` is +usually twice as big as an ``unsigned int``, so that 8 bytes are pushed onto +the stack, but printf only unshifts 4 bytes because the developer indicated +``%u``, leading to misreading the next variable on the stack. + +.. code-block:: c + + /* Force promotion */ + double a_quarter = static_cast(double, 1) / 4; + +Were ``1`` not promoted to double, the result in ``q`` would be zero because +``1/4`` is just an integer division, yielding zero. By making one of the +operands a floating-point quantity, the compiler will instruct the FPU to +compute the result. Of course, one could have also written ``1.0`` instead of +``static_cast(double, 1)``, but this is left for the programmer to decide which +style s/he prefers. + +.. code-block:: c + + /* Force truncation before invoking second sqrt */ + double f = sqrt(static_cast(int, 10 * sqrt(3.0 / 4))); + +And here, the conversion from ``double`` to ``int`` incurs a (wanted) +truncation of the decimal fraction, that is, rounding down for positive +numbers, and rounding up for negative numbers. + +Allowed conversions +------------------- + +* Numbers + + Conversion between numeric types, such as ``char``, ``short``, ``int``, + ``long``, ``long long``, ``intN_t``, both their signed and unsigned variants, + ``float`` and ``double``. + +* Generic Pointer + + Conversion from ``type *`` to and from ``void *``. (Where type may very + well be a type with further indirection.) + +* Generic Pointer (const) + + Conversion from ``const type *`` to and from ``const void *``. + +Limitations +----------- + +Because the implementation of our ``static_cast`` involves a C99 compound +literals and those are not constant expressions, ``static_cast`` cannot be used +in such contexts. (Cf. `GCC issue 105510 +<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105510#c3>`_). + +.. code-block:: c + + static const int a = static_cast(int, 1U); + +Furthermore, because an implicit assignment is used in the implementation, it +can trigger `-Wsign-conversion` warnings. + + +``const_cast`` +============== + +const_cast allows to add or remove “const” qualifiers from the +type a pointer is pointing to. Due to technical limitations, it +could not be implemented to support arbitrary indirection. +Instead, const_cast comes in three variants, to be used for +indirection levels of 1 to 3: + +* ``const_cast1(type *, expr)`` with ``typeof(expr) = type *``. + (Similarly for any combinations of const.) + +* ``const_cast2(type **, expr)`` with ``typeof(expr) = type **`` (and all + combinations of const in all possible locations). + +* ``const_cast3(type ***, expr)`` with ``typeof(expr) = type ***`` (and all + combinations...). + +As indirection levels above 3 are really unlikely[#f3], having only these three +type-checking cast macros was deemed sufficient. The only place where libHX +even uses a level‑3 indirection is in the option parser. + +.. [#t3] See “Three Star Programmer” + +Conversion is permitted when expression and target type are from the table. + +It is currently not possible to use const_cast1/2/3 on pointers to structures +whose member structure is unknown. diff --git a/doc/ux-file.rst b/doc/ux-file.rst new file mode 100644 index 0000000..ae21c56 --- /dev/null +++ b/doc/ux-file.rst @@ -0,0 +1,31 @@ +====================================== +ux-file - Unix compatibility functions +====================================== + +Date authored: 2006-02-25 + +Description +=========== + +libHX provides some dummy Unix functions for platforms where they are not +available. They mostly return `-ENOSYS`. + +Synopsis +======== + +.. code-block:: c + + #include <libHX.h> + + int chown(const char *PATH, long UID, long GID); + int fchmod(int FD, long PERM); + int fchown(int FD, long UID, long GID); + int lchown(const char *PATH, long UID, long GID); + int lstat(const char *PATH, struct stat *SB); + int mkfifo(const char *PATH, long MODE); + int mknod(const char *PATH, long MODE, long DEV); + int readlink(const char *PATH, char *DEST, size_t LEN); + int symlink(const char *SRC, const char *DEST); + +``lstat()`` + Maps to ``stat()`` under Win32. diff --git a/doc/ux-file.txt b/doc/ux-file.txt deleted file mode 100644 index 2f32247..0000000 --- a/doc/ux-file.txt +++ /dev/null @@ -1,30 +0,0 @@ -=============================================================================== -ux-file - Unix compatibility functions 2006-02-25 - - -DESCRIPTION - - libHX provides some dummy Unix functions for platforms where they are not - available. They mostly return -ENOSYS. - - -SYNOPSIS - - #include <libHX.h> - - int chown(const char *PATH, long UID, long GID); - int fchmod(int FD, long PERM); - int fchown(int FD, long UID, long GID); - int lchown(const char *PATH, long UID, long GID); - int lstat(const char *PATH, struct stat *SB); - int mkfifo(const char *PATH, long MODE); - int mknod(const char *PATH, long MODE, long DEV); - int readlink(const char *PATH, char *DEST, size_t LEN); - int symlink(const char *SRC, const char *DEST); - - -lstat() - - Maps to stat() under Win32. - -=============================================================================== diff --git a/doc/ux-mmap.rst b/doc/ux-mmap.rst new file mode 100644 index 0000000..c59421c --- /dev/null +++ b/doc/ux-mmap.rst @@ -0,0 +1,27 @@ +====================================== +ux-mmap - Unix compatibility functions +====================================== + +Date authored: 2006-02-25 + +Description +=========== + +libHX provides a Linux-style ``mmap()`` function for Win32. + +Synopsis +======== + +.. code-block:: c + + #include <libHX.h> + + void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset); + +``mmap()`` + + See the Linux manual page ``mmap``(2) for details. Many flags described + in ``mmap``(2) do not work. What does work: ``PROT_NONE``, + ``PROT_READ``, ``PROT_WRITE``, ``PROT_EXEC`` (only WinXP SP2 or + WinServer2003 SP1 or up), ``MAP_SHARED`` and ``MAP_PRIVATE``. + ``MAP_SHARED`` is the default if no ``MAP_PRIVATE`` is given. diff --git a/doc/ux-mmap.txt b/doc/ux-mmap.txt deleted file mode 100644 index 43f5ac9..0000000 --- a/doc/ux-mmap.txt +++ /dev/null @@ -1,26 +0,0 @@ -=============================================================================== -ux-mmap - Unix compatibility functions 2006-02-25 - - -DESCRIPTION - - libHX provides a Linux-style mmap() function for Win32. - - -SYNOPSIS - - #include <libHX.h> - - void *mmap(void *START, size_t LENGTH, int PROT, int FLAGS, int FD, - off_t OFFSET); - - -mmap() - - See the Linux manual page mmap(2) for details. Many flags described in - mmap(2) do not work. What does work: PROT_NONE, PROT_READ, PROT_WRITE, - PROT_EXEC (only WinPX SP2 or WinServer2003 SP1 or up), MAP_SHARED and - MAP_PRIVATE. MAP_SHARED is the default if no MAP_PRIVATE is given. - - -=============================================================================== diff --git a/dvconfigure b/dvconfigure deleted file mode 100755 index 58dfbb6..0000000 --- a/dvconfigure +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -topdir="${0%/*}"; -abstopdir=$(readlink -f "$topdir"); -if [ ! -e "${topdir}/configure" ]; then - pushd "$topdir"; - ./autogen.sh; - popd; -fi; -exec "$topdir/configure" CFLAGS="-O0 -ggdb3" CXXFLAGS="-O0 -ggdb3" "$@"; diff --git a/include/Makefile.am b/include/Makefile.am index b70eebd..dd74f9a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,7 +2,6 @@ nobase_include_HEADERS = libHX.h \ libHX/ctype_helper.h libHX/defs.h libHX/deque.h libHX/init.h \ - libHX/io.h libHX/list.h \ - libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/string.h \ + libHX/intdiff.hpp libHX/io.h libHX/list.h \ + libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/socket.h libHX/string.h \ libHX/libxml_helper.h libHX/wx_helper.hpp - diff --git a/include/Makefile.in b/include/Makefile.in index f485a2b..525f047 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. +# Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2017 Free Software Foundation, Inc. +# Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -169,8 +169,6 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ @@ -184,8 +182,9 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ @@ -200,8 +199,10 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -217,7 +218,6 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -LYX = @LYX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ @@ -294,6 +294,7 @@ psdir = @psdir@ regular_CFLAGS = @regular_CFLAGS@ regular_CPPFLAGS = @regular_CPPFLAGS@ regular_CXXFLAGS = @regular_CXXFLAGS@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -304,8 +305,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ nobase_include_HEADERS = libHX.h \ libHX/ctype_helper.h libHX/defs.h libHX/deque.h libHX/init.h \ - libHX/io.h libHX/list.h \ - libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/string.h \ + libHX/intdiff.hpp libHX/io.h libHX/list.h \ + libHX/map.h libHX/misc.h libHX/option.h libHX/proc.h libHX/socket.h libHX/string.h \ libHX/libxml_helper.h libHX/wx_helper.hpp all: all-am @@ -328,8 +329,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -422,8 +423,10 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am -distdir: $(DISTFILES) +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ diff --git a/include/libHX/defs.h b/include/libHX/defs.h index 1ace518..9d17019 100644 --- a/include/libHX/defs.h +++ b/include/libHX/defs.h @@ -10,8 +10,8 @@ # endif # ifndef containerof # include <cstddef> -# define containerof(var, type, member) reinterpret_cast<type *>( \ - reinterpret_cast<char *>(var) - offsetof(type, member)) +# include <type_traits> +# define containerof(var, T, member) reinterpret_cast<std::conditional<std::is_const<std::remove_pointer<decltype(var)>::type>::value, std::add_const<T>::type, T>::type *>(reinterpret_cast<std::conditional<std::is_const<std::remove_pointer<decltype(var)>::type>::value, const char, char>::type *>(var) - offsetof(T, member)) # endif # ifndef static_cast # define static_cast(T, x) static_cast<T>(x) @@ -213,15 +213,15 @@ static __inline__ new_type signed_cast(unsigned char *expr) # define container_of(v, s, m) containerof((v), s, m) #endif -#ifdef _WIN32 +#if !defined(_WIN32) || (defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO + 0 > 0) /* * Sufficiently old versions of the VC runtime do not even support %ll. */ -# define HX_LONGLONG_FMT "I64" -# define HX_SIZET_FMT "I" -#else # define HX_LONGLONG_FMT "ll" # define HX_SIZET_FMT "z" +#else +# define HX_LONGLONG_FMT "I64" +# define HX_SIZET_FMT "I" #endif #endif /* _LIBHX_DEFS_H */ diff --git a/include/libHX/intdiff.hpp b/include/libHX/intdiff.hpp new file mode 100644 index 0000000..17300a1 --- /dev/null +++ b/include/libHX/intdiff.hpp @@ -0,0 +1,24 @@ +#ifndef LIBHX_INTDIFF_HPP +#define LIBHX_INTDIFF_HPP 1 +#include <algorithm> +namespace HX { +template<typename AIter, typename BIter, typename XIter, + typename YIter, typename ZIter> +void set_intersect_diff(AIter a_first, AIter a_last, BIter b_first, + BIter b_last, XIter xptr, YIter yptr, ZIter zptr) +{ + while ((a_first != a_last) && (b_first != b_last)) { + if (*a_first < *b_first) + *xptr++ = *a_first++; + else if (*b_first < *a_first) + *yptr++ = *b_first++; + else { + *zptr++ = *a_first++; + ++b_first; + } + } + std::copy(a_first, a_last, xptr); + std::copy(b_first, b_last, yptr); +} +} +#endif diff --git a/include/libHX/io.h b/include/libHX/io.h index c86af72..7e0c7d3 100644 --- a/include/libHX/io.h +++ b/include/libHX/io.h @@ -1,6 +1,7 @@ #ifndef _LIBHX_IO_H #define _LIBHX_IO_H 1 +#include <stdio.h> #include <sys/types.h> #ifdef __cplusplus @@ -35,9 +36,16 @@ extern int HX_mkdir(const char *, unsigned int); extern int HX_readlink(hxmc_t **, const char *); extern int HX_realpath(hxmc_t **, const char *, unsigned int); extern int HX_rrmdir(const char *); +extern ssize_t HX_sendfile(int dst, int src, size_t count); +extern char *HX_slurp_fd(int fd, size_t *outsize); +extern char *HX_slurp_file(const char *file, size_t *outsize); extern ssize_t HXio_fullread(int, void *, size_t); extern ssize_t HXio_fullwrite(int, const void *, size_t); +#ifndef HX_HEXDUMP_DECLARATION +#define HX_HEXDUMP_DECLARATION 1 +extern void HX_hexdump(FILE *, const void *, unsigned int); +#endif #ifdef __cplusplus } /* extern "C" */ diff --git a/include/libHX/misc.h b/include/libHX/misc.h index adebf22..23607d2 100644 --- a/include/libHX/misc.h +++ b/include/libHX/misc.h @@ -35,11 +35,11 @@ extern "C" { #define HX_TIMESPEC_FMT "%ld.%09ld" #define HX_TIMEVAL_FMT "%ld.%06ld" #ifdef __cplusplus -# define HX_TIMESPEC_EXP(p) static_cast<long>((p)->tv_sec), (p)->tv_nsec -# define HX_TIMEVAL_EXP(p) static_cast<long>((p)->tv_sec), (p)->tv_usec +# define HX_TIMESPEC_EXP(p) static_cast<long>((p)->tv_sec), static_cast<long>((p)->tv_nsec) +# define HX_TIMEVAL_EXP(p) static_cast<long>((p)->tv_sec), static_cast<long>((p)->tv_usec) #else -# define HX_TIMESPEC_EXP(p) static_cast(long, (p)->tv_sec), (p)->tv_nsec -# define HX_TIMEVAL_EXP(p) static_cast(long, (p)->tv_sec), (p)->tv_usec +# define HX_TIMESPEC_EXP(p) static_cast(long, (p)->tv_sec), static_cast(long, (p)->tv_nsec) +# define HX_TIMEVAL_EXP(p) static_cast(long, (p)->tv_sec), static_cast(long, (p)->tv_usec) #endif struct stat; @@ -59,7 +59,10 @@ extern const char *HX_dlerror(void); */ extern int HX_ffs(unsigned long); extern int HX_fls(unsigned long); +#ifndef HX_HEXDUMP_DECLARATION +#define HX_HEXDUMP_DECLARATION 1 extern void HX_hexdump(FILE *, const void *, unsigned int); +#endif extern bool HX_timespec_isneg(const struct timespec *); extern struct timespec *HX_timespec_neg(struct timespec *, const struct timespec *); diff --git a/include/libHX/option.h b/include/libHX/option.h index 82255d3..40cc6e7 100644 --- a/include/libHX/option.h +++ b/include/libHX/option.h @@ -27,12 +27,12 @@ extern struct HXformat_map *HXformat_init(void); extern void HXformat_free(struct HXformat_map *); extern int HXformat_add(struct HXformat_map *, const char *, const void *, unsigned int); -extern int HXformat_aprintf(const struct HXformat_map *, - hxmc_t **, const char *); -extern int HXformat_sprintf(const struct HXformat_map *, - char *, size_t, const char *); -extern int HXformat_fprintf(const struct HXformat_map *, - FILE *, const char *); +#define HXformat_aprintf(a, b, c) HXformat3_aprintf((a), (b), (c)) +#define HXformat_fprintf(a, b, c) HXformat3_fprintf((a), (b), (c)) +#define HXformat_sprintf(a, b, c, d) HXformat3_sprintf((a), (b), (c), (d)) +extern ssize_t HXformat3_aprintf(const struct HXformat_map *, hxmc_t **, const char *); +extern ssize_t HXformat3_fprintf(const struct HXformat_map *, FILE *, const char *); +extern ssize_t HXformat3_sprintf(const struct HXformat_map *, char *, size_t, const char *); /* * OPT.C @@ -77,7 +77,7 @@ extern int HXformat_fprintf(const struct HXformat_map *, * Type expected of struct HXoption.ptr is given in (). * HX_getopt (o) and HXformat_* (f) support different sets, marked with []. */ -enum HX_option_type { +enum { HXTYPE_NONE = 0, HXTYPE_VAL, HXTYPE_SVAL, @@ -110,7 +110,6 @@ enum HX_option_type { HXTYPE_XSNTMARK, HXTYPE_XHELP, /* 30 */ HXTYPE_SIZE_T, -}; /** * Extra flags to be OR'ed into struct HXoption.type. @@ -125,7 +124,6 @@ enum HX_option_type { * %HXOPT_AND: AND *ptr by argument * %HXOPT_XOR: XOR *ptr by argument */ -enum { HXOPT_OPTIONAL = 1 << 6, HXOPT_INC = 1 << 7, HXOPT_DEC = 1 << 8, @@ -144,6 +142,7 @@ enum { * %HXOPT_USAGEONERR: print out short usage when a parsing error occurs * %HXOPT_RQ_ORDER: require option order/POSIX mode: * first non-option terminates option processing + * %HXOPT_KEEP_ARGV: do not replace argc/argv at all */ enum { HXOPT_PTHRU = 1 << 0, @@ -152,6 +151,7 @@ enum { HXOPT_HELPONERR = 1 << 3, HXOPT_USAGEONERR = 1 << 4, HXOPT_RQ_ORDER = 1 << 5, + HXOPT_KEEP_ARGV = 1 << 6, }; /** diff --git a/include/libHX/proc.h b/include/libHX/proc.h index cb682ed..fb17d5e 100644 --- a/include/libHX/proc.h +++ b/include/libHX/proc.h @@ -21,6 +21,16 @@ enum { HXPROC_NULL_STDERR = 1 << 8, }; +enum HXproc_su_status { + HXPROC_INITGROUPS_FAILED = -5, + HXPROC_SETGID_FAILED = -4, + HXPROC_SETUID_FAILED = -3, + HXPROC_GROUP_NOT_FOUND = -2, + HXPROC_USER_NOT_FOUND = -1, + HXPROC_SU_NOOP = 0, + HXPROC_SU_SUCCESS = 1, +}; + struct HXproc_ops { void (*p_prefork)(void *); void (*p_postfork)(void *); @@ -41,6 +51,8 @@ struct HXproc { extern int HXproc_run_async(const char *const *, struct HXproc *); extern int HXproc_run_sync(const char *const *, unsigned int); extern int HXproc_wait(struct HXproc *); +extern enum HXproc_su_status HXproc_switch_user(const char *user, const char *group); +extern int HXproc_top_fd(void); #ifdef __cplusplus } /* extern "C" */ diff --git a/include/libHX/socket.h b/include/libHX/socket.h new file mode 100644 index 0000000..e9db77f --- /dev/null +++ b/include/libHX/socket.h @@ -0,0 +1,23 @@ +#ifndef _LIBHX_SOCKET_H +#define _LIBHX_SOCKET_H 1 + +#ifdef _WIN32 +# include <ws2tcpip.h> +#else +# include <netdb.h> +# include <sys/socket.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern int HX_socket_from_env(const struct addrinfo *, const char *intf); +extern int HX_sockaddr_is_local(const struct sockaddr *, socklen_t, unsigned int flags); +extern int HX_ipaddr_is_local(const char *, unsigned int flags); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* _LIBHX_SOCKET_H */ diff --git a/include/libHX/string.h b/include/libHX/string.h index 4dc4c11..9e78cd0 100644 --- a/include/libHX/string.h +++ b/include/libHX/string.h @@ -28,9 +28,17 @@ enum { HXQUOTE_URIENC, HXQUOTE_SQLSQUOTE, HXQUOTE_SQLBQUOTE, + HXQUOTE_BASE64URL, + HXQUOTE_BASE64IMAP, _HXQUOTE_MAX, }; +enum { + HXUNIT_YEARS = 0x1U, + HXUNIT_MONTHS = 0x2U, + HXUNIT_WEEKS = 0x4U, +}; + #ifndef __libhx_internal_hxmc_t_defined #define __libhx_internal_hxmc_t_defined 1 typedef char hxmc_t; @@ -90,6 +98,12 @@ extern size_t HX_strrtrim(char *); extern char *HX_strsep(char **, const char *); extern char *HX_strsep2(char **, const char *); extern char *HX_strupper(char *); +extern double HX_strtod_unit(const char *, char **, unsigned int exponent); +extern unsigned long long HX_strtoull_unit(const char *, char **, unsigned int exponent); +extern char *HX_unit_size(char *out, size_t bufsize, unsigned long long size, unsigned int divisor, unsigned int cutoff); +extern char *HX_unit_size_cu(char *out, size_t bufsize, unsigned long long size, unsigned int divisor); +extern unsigned long long HX_strtoull_sec(const char *s, char **); +extern char *HX_unit_seconds(char *out, size_t bufsize, unsigned long long seconds, unsigned int flags); static __inline__ void *HX_memdup(const void *buf, size_t len) { diff --git a/m4/libtool.m4 b/m4/libtool.m4 index 4e87d34..717e769 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -1,6 +1,7 @@ # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # -# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. +# Copyright (C) 1996-2001, 2003-2019, 2021-2022 Free Software +# Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives @@ -31,7 +32,7 @@ m4_define([_LT_COPYING], [dnl # along with this program. If not, see <http://www.gnu.org/licenses/>. ]) -# serial 58 LT_INIT +# serial 59 LT_INIT # LT_PREREQ(VERSION) @@ -181,6 +182,7 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_DECL_FILECMD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl @@ -219,8 +221,8 @@ esac ofile=libtool can_build_shared=yes -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). +# All known linkers require a '.a' archive for static linking (except MSVC and +# ICC, which need '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld @@ -777,7 +779,7 @@ _LT_EOF # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" \ + $SED '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || @@ -1041,8 +1043,8 @@ int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD - echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD - $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$AR $AR_FLAGS libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR $AR_FLAGS libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF @@ -1066,17 +1068,12 @@ _LT_EOF _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; - 10.[[012]][[,.]]*) - _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + darwin*) + case $MACOSX_DEPLOYMENT_TARGET,$host in + 10.[[012]],*|,*powerpc*-darwin[[5-8]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + *) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac @@ -1125,12 +1122,12 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES], output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], [ if test yes != "$lt_cv_apple_cc_single_mod"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else @@ -1244,7 +1241,8 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], -[AC_MSG_CHECKING([for sysroot]) +[m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot @@ -1261,7 +1259,7 @@ case $with_sysroot in #( fi ;; #( /*) - lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` ;; #( no|'') ;; #( @@ -1291,7 +1289,7 @@ ia64-*-hpux*) # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; @@ -1308,7 +1306,7 @@ ia64-*-hpux*) echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test yes = "$lt_cv_prog_gnu_ld"; then - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; @@ -1320,7 +1318,7 @@ ia64-*-hpux*) ;; esac else - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; @@ -1342,7 +1340,7 @@ mips64*-*linux*) echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then emul=elf - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; @@ -1350,7 +1348,7 @@ mips64*-*linux*) emul="${emul}64" ;; esac - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; @@ -1358,7 +1356,7 @@ mips64*-*linux*) emul="${emul}ltsmip" ;; esac - case `/usr/bin/file conftest.$ac_objext` in + case `$FILECMD conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; @@ -1378,14 +1376,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; @@ -1453,7 +1451,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in + case `$FILECMD conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) @@ -1492,9 +1490,22 @@ need_locks=$enable_libtool_lock m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} -: ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +# Use ARFLAGS variable as AR's operation code to sync the variable naming with +# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have +# higher priority because thats what people were doing historically (setting +# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS +# variable obsoleted/removed. + +test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr} +lt_ar_flags=$AR_FLAGS +_LT_DECL([], [lt_ar_flags], [0], [Flags to create an archive (by configure)]) + +# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override +# by AR_FLAGS because that was never working and AR_FLAGS is about to die. +_LT_DECL([], [AR_FLAGS], [\@S|@{ARFLAGS-"\@S|@lt_ar_flags"}], + [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no @@ -1713,7 +1724,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=8192; ;; - bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -1756,7 +1767,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi @@ -2206,26 +2217,35 @@ m4_defun([_LT_CMD_STRIPLIB], striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) +if test -z "$STRIP"; then + AC_MSG_RESULT([no]) else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP"; then + if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) + else + case $host_os in + darwin*) + # FIXME - insert some real tests, host_os isn't really good enough striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) - else + ;; + freebsd*) + if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then + old_striplib="$STRIP --strip-debug" + striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac + ;; + esac + fi fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) @@ -2548,7 +2568,7 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; @@ -2558,14 +2578,14 @@ m4_if([$1], [],[ ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC + *,cl* | *,icl*) + # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' @@ -2584,7 +2604,7 @@ m4_if([$1], [],[ done IFS=$lt_save_ifs # Convert to MSYS style. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form @@ -2621,7 +2641,7 @@ m4_if([$1], [],[ ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; @@ -2654,7 +2674,7 @@ dgux*) shlibpath_var=LD_LIBRARY_PATH ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then @@ -3453,7 +3473,7 @@ beos*) bsdi[[45]]*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' - lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_cmd='$FILECMD -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; @@ -3487,14 +3507,14 @@ darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; -freebsd* | dragonfly*) +freebsd* | dragonfly* | midnightbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac @@ -3508,7 +3528,7 @@ haiku*) ;; hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' @@ -3555,7 +3575,7 @@ netbsd*) newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; @@ -3682,13 +3702,13 @@ else mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac - case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 @@ -3714,7 +3734,7 @@ else # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) - case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; @@ -3954,7 +3974,7 @@ esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. - lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" @@ -3972,20 +3992,20 @@ fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ @@ -4009,7 +4029,7 @@ for ac_symprfx in "" "_"; do if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. - # Also find C++ and __fastcall symbols from MSVC++, + # Also find C++ and __fastcall symbols from MSVC++ or ICC, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ @@ -4027,9 +4047,9 @@ for ac_symprfx in "" "_"; do " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi - lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -4316,7 +4336,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) @@ -4399,7 +4419,7 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' @@ -4735,7 +4755,7 @@ m4_if([$1], [CXX], [ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' @@ -4918,7 +4938,7 @@ m4_if([$1], [CXX], [ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) @@ -4926,7 +4946,7 @@ m4_if([$1], [CXX], [ ;; cygwin* | mingw* | cegcc*) case $cc_basename in - cl*) + cl* | icl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) @@ -4983,15 +5003,15 @@ dnl Note also adjust exclude_expsyms for C++ above. case $host_os in cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time + # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) + # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; openbsd* | bitrig*) @@ -5043,7 +5063,7 @@ dnl Note also adjust exclude_expsyms for C++ above. _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no - case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + case `$LD -v | $SED -e 's/([[^)]]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... @@ -5155,6 +5175,7 @@ _LT_EOF emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' ;; interix[[3-9]]*) @@ -5169,7 +5190,7 @@ _LT_EOF # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) @@ -5212,7 +5233,7 @@ _LT_EOF _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes @@ -5224,7 +5245,7 @@ _LT_EOF if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi @@ -5240,7 +5261,7 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi @@ -5372,7 +5393,7 @@ _LT_EOF if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no @@ -5555,12 +5576,12 @@ _LT_EOF cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in - cl*) - # Native MSVC + cl* | icl*) + # Native MSVC or ICC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes @@ -5601,7 +5622,7 @@ _LT_EOF fi' ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. @@ -5649,7 +5670,7 @@ _LT_EOF ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes @@ -5860,6 +5881,7 @@ _LT_EOF emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' ;; osf3*) @@ -6630,8 +6652,8 @@ if test yes != "$_lt_caught_CXX_error"; then cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC + ,cl* | no,cl* | ,icl* | no,icl*) + # Native MSVC or ICC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' @@ -6729,6 +6751,7 @@ if test yes != "$_lt_caught_CXX_error"; then emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' ;; dgux*) @@ -6759,7 +6782,7 @@ if test yes != "$_lt_caught_CXX_error"; then _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes @@ -6896,7 +6919,7 @@ if test yes != "$_lt_caught_CXX_error"; then # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in @@ -7036,13 +7059,13 @@ if test yes != "$_lt_caught_CXX_error"; then _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) - case `$CC -V 2>&1 | sed 5q` in + case `$CC -V 2>&1 | $SED 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' @@ -8188,6 +8211,14 @@ _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) +# _LT_DECL_FILECMD +# ---------------- +# Check for a file(cmd) program that can be used to detect file type and magic +m4_defun([_LT_DECL_FILECMD], +[AC_CHECK_TOOL([FILECMD], [file], [:]) +_LT_DECL([], [FILECMD], [1], [A file(cmd) program that detects file types]) +])# _LD_DECL_FILECMD + # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 index 94b0829..b0b5e9c 100644 --- a/m4/ltoptions.m4 +++ b/m4/ltoptions.m4 @@ -1,7 +1,7 @@ # Helper functions for option handling. -*- Autoconf -*- # -# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software -# Foundation, Inc. +# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2022 Free +# Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4 index 48bc934..902508b 100644 --- a/m4/ltsugar.m4 +++ b/m4/ltsugar.m4 @@ -1,6 +1,6 @@ # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # -# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 index fa04b52..b155d0a 100644 --- a/m4/ltversion.m4 +++ b/m4/ltversion.m4 @@ -1,6 +1,7 @@ # ltversion.m4 -- version numbers -*- Autoconf -*- # -# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation, +# Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives @@ -9,15 +10,15 @@ # @configure_input@ -# serial 4179 ltversion.m4 +# serial 4245 ltversion.m4 # This file is part of GNU Libtool -m4_define([LT_PACKAGE_VERSION], [2.4.6]) -m4_define([LT_PACKAGE_REVISION], [2.4.6]) +m4_define([LT_PACKAGE_VERSION], [2.4.7]) +m4_define([LT_PACKAGE_REVISION], [2.4.7]) AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.4.6' -macro_revision='2.4.6' +[macro_version='2.4.7' +macro_revision='2.4.7' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4 index c6b26f8..0f7a875 100644 --- a/m4/lt~obsolete.m4 +++ b/m4/lt~obsolete.m4 @@ -1,7 +1,7 @@ # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # -# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software -# Foundation, Inc. +# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2022 Free +# Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives @@ -0,0 +1,12 @@ +#!/bin/sh +topdir="${0%/*}" +if [ "$topdir" = "$0" ]; then + topdir=. +fi +abstopdir=$(readlink -f "$topdir") +if [ ! -e "${topdir}/configure" ]; then + cd "$topdir" + autoreconf -fi + cd - +fi +exec "$topdir/configure" CFLAGS="-O0 -ggdb3" CXXFLAGS="-O0 -ggdb3" "$@" diff --git a/src/.gitignore b/src/.gitignore index 5658aee..89edb97 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -4,6 +4,8 @@ /t?-deque /t?-dir /t?-format +/t?-intdiff +/t?-io /t?-link /t?-list /t?-list2 @@ -17,9 +19,11 @@ /t?-rand /t?-realpath /t?-shconfig +/t?-socket /t?-strchr2 /t?-string /t?-strquote +/t?-switchuser /t?-time # automake tests diff --git a/src/Makefile.am b/src/Makefile.am index 73a6bdb..921e6b7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,10 +10,10 @@ lib_LTLIBRARIES += libHX_rtcheck.la endif libHX_la_SOURCES = deque.c dl.c format.c io.c map.c \ - mc.c misc.c opt.c \ - rand.c string.c time.c -libHX_la_LIBADD = ${libdl_LIBS} ${libpthread_LIBS} ${librt_LIBS} -libHX_la_LDFLAGS = -no-undefined -version-info 32:0:0 + mc.c misc.c opt.c proc.c \ + rand.c socket.c string.c time.c +libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} +libHX_la_LDFLAGS = -no-undefined -version-info 36:0:4 if WITH_GNU_LD libHX_la_LDFLAGS += -Wl,--version-script=${srcdir}/libHX.map endif @@ -21,9 +21,7 @@ EXTRA_libHX_la_DEPENDENCIES = libHX.map if MINGW32 libHX_la_SOURCES += ux-file.c ux-mmap.c -endif -if B_PROC -libHX_la_SOURCES += proc.c +libHX_la_LIBADD += -lws2_32 endif libHX_rtcheck_la_SOURCES = rtcheck.c @@ -35,17 +33,18 @@ endif EXTRA_DIST = internal.h map_int.h libHX.map -check_PROGRAMS = tc-compile tc-cast tc-deque tc-dir tc-format tc-link \ +check_PROGRAMS = tc-compile tc-cast tc-deque tc-dir tc-format tc-io \ tc-list tc-list2 tc-map tc-memmem tc-misc tc-netio \ tc-option tc-proc tc-rand tc-realpath \ - tc-shconfig tc-strchr2 tc-string tc-strquote tc-time -TESTS = tc-strchr2 tc-strquote + tc-shconfig tc-socket tc-strchr2 tc-string tc-strquote \ + tc-switchuser tc-time +TESTS = tc-format tc-strchr2 tc-strquote tc_cast_CFLAGS = ${AM_CFLAGS} -std=gnu99 tc_cast_LDADD = libHX.la -lm tc_compile_LDADD = libHX.la tc_dir_LDADD = libHX.la tc_format_LDADD = libHX.la -tc_link_LDADD = libHX.la +tc_io_LDADD = libHX.la tc_list_LDADD = libHX.la tc_list2_LDADD = libHX.la tc_list2_CFLAGS = ${AM_CFLAGS} -O2 -fstrict-aliasing @@ -58,25 +57,28 @@ tc_proc_LDADD = libHX.la tc_rand_LDADD = libHX.la tc_realpath_LDADD = libHX.la tc_shconfig_LDADD = libHX.la +tc_socket_LDADD = libHX.la tc_strchr2_LDADD = libHX.la tc_string_LDADD = libHX.la tc_strquote_LDADD = libHX.la +tc_switchuser_LDADD = libHX.la tc_time_LDADD = libHX.la if HAVE_CXX -check_PROGRAMS += tx-compile tx-cast tx-deque tx-dir tx-list tx-list2 \ +check_PROGRAMS += tx-compile tx-cast tx-deque tx-dir \ + tx-intdiff tx-list tx-list2 \ tx-misc tx-netio \ tx-option tx-proc tx-rand tx-strchr2 tx-string \ tx-strquote tx-time TESTS += tx-strchr2 tx-strquote tx_cast_SOURCES = tx-cast.cpp -tx_cast_CXXFLAGS = ${AM_CXXFLAGS} -std=c++98 tx_cast_LDADD = libHX.la -lm tx_compile_SOURCES = tx-compile.cpp tx_compile_LDADD = libHX.la tx_deque_SOURCES = tx-deque.cpp tx_dir_SOURCES = tx-dir.cpp tx_dir_LDADD = libHX.la +tx_intdiff_SOURCES = tx-intdiff.cpp tx_list_SOURCES = tx-list.cpp tx_list_LDADD = libHX.la tx_list2_SOURCES = tx-list2.cpp diff --git a/src/Makefile.in b/src/Makefile.in index 632d4ab..8257e20 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15.1 from Makefile.am. +# Makefile.in generated by automake 1.16.5 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2017 Free Software Foundation, Inc. +# Copyright (C) 1994-2021 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -93,18 +93,21 @@ host_triplet = @host@ @HAVE_DLFCN_H_TRUE@am__append_1 = libHX_rtcheck.la @WITH_GNU_LD_TRUE@am__append_2 = -Wl,--version-script=${srcdir}/libHX.map @MINGW32_TRUE@am__append_3 = ux-file.c ux-mmap.c -@B_PROC_TRUE@am__append_4 = proc.c +@MINGW32_TRUE@am__append_4 = -lws2_32 @WITH_GNU_LD_TRUE@am__append_5 = -Wl,--version-script=${srcdir}/libHX.map check_PROGRAMS = tc-compile$(EXEEXT) tc-cast$(EXEEXT) \ tc-deque$(EXEEXT) tc-dir$(EXEEXT) tc-format$(EXEEXT) \ - tc-link$(EXEEXT) tc-list$(EXEEXT) tc-list2$(EXEEXT) \ + tc-io$(EXEEXT) tc-list$(EXEEXT) tc-list2$(EXEEXT) \ tc-map$(EXEEXT) tc-memmem$(EXEEXT) tc-misc$(EXEEXT) \ tc-netio$(EXEEXT) tc-option$(EXEEXT) tc-proc$(EXEEXT) \ tc-rand$(EXEEXT) tc-realpath$(EXEEXT) tc-shconfig$(EXEEXT) \ - tc-strchr2$(EXEEXT) tc-string$(EXEEXT) tc-strquote$(EXEEXT) \ - tc-time$(EXEEXT) $(am__EXEEXT_1) -TESTS = tc-strchr2$(EXEEXT) tc-strquote$(EXEEXT) $(am__EXEEXT_2) -@HAVE_CXX_TRUE@am__append_6 = tx-compile tx-cast tx-deque tx-dir tx-list tx-list2 \ + tc-socket$(EXEEXT) tc-strchr2$(EXEEXT) tc-string$(EXEEXT) \ + tc-strquote$(EXEEXT) tc-switchuser$(EXEEXT) tc-time$(EXEEXT) \ + $(am__EXEEXT_1) +TESTS = tc-format$(EXEEXT) tc-strchr2$(EXEEXT) tc-strquote$(EXEEXT) \ + $(am__EXEEXT_2) +@HAVE_CXX_TRUE@am__append_6 = tx-compile tx-cast tx-deque tx-dir \ +@HAVE_CXX_TRUE@ tx-intdiff tx-list tx-list2 \ @HAVE_CXX_TRUE@ tx-misc tx-netio \ @HAVE_CXX_TRUE@ tx-option tx-proc tx-rand tx-strchr2 tx-string \ @HAVE_CXX_TRUE@ tx-strquote tx-time @@ -123,6 +126,14 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = +@HAVE_CXX_TRUE@am__EXEEXT_1 = tx-compile$(EXEEXT) tx-cast$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-deque$(EXEEXT) tx-dir$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-intdiff$(EXEEXT) tx-list$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-list2$(EXEEXT) tx-misc$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-netio$(EXEEXT) tx-option$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-proc$(EXEEXT) tx-rand$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-strchr2$(EXEEXT) tx-string$(EXEEXT) \ +@HAVE_CXX_TRUE@ tx-strquote$(EXEEXT) tx-time$(EXEEXT) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -154,14 +165,14 @@ am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libHX_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__libHX_la_SOURCES_DIST = deque.c dl.c format.c io.c map.c mc.c \ - misc.c opt.c rand.c string.c time.c ux-file.c ux-mmap.c proc.c + misc.c opt.c proc.c rand.c socket.c string.c time.c ux-file.c \ + ux-mmap.c @MINGW32_TRUE@am__objects_1 = ux-file.lo ux-mmap.lo -@B_PROC_TRUE@am__objects_2 = proc.lo am_libHX_la_OBJECTS = deque.lo dl.lo format.lo io.lo map.lo mc.lo \ - misc.lo opt.lo rand.lo string.lo time.lo $(am__objects_1) \ - $(am__objects_2) + misc.lo opt.lo proc.lo rand.lo socket.lo string.lo time.lo \ + $(am__objects_1) libHX_la_OBJECTS = $(am_libHX_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -178,14 +189,6 @@ libHX_rtcheck_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_CFLAGS) $(CFLAGS) $(libHX_rtcheck_la_LDFLAGS) $(LDFLAGS) \ -o $@ @HAVE_DLFCN_H_TRUE@am_libHX_rtcheck_la_rpath = -rpath $(libdir) -@HAVE_CXX_TRUE@am__EXEEXT_1 = tx-compile$(EXEEXT) tx-cast$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-deque$(EXEEXT) tx-dir$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-list$(EXEEXT) tx-list2$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-misc$(EXEEXT) tx-netio$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-option$(EXEEXT) tx-proc$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-rand$(EXEEXT) tx-strchr2$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-string$(EXEEXT) tx-strquote$(EXEEXT) \ -@HAVE_CXX_TRUE@ tx-time$(EXEEXT) tc_cast_SOURCES = tc-cast.c tc_cast_OBJECTS = tc_cast-tc-cast.$(OBJEXT) tc_cast_DEPENDENCIES = libHX.la @@ -204,9 +207,9 @@ tc_dir_DEPENDENCIES = libHX.la tc_format_SOURCES = tc-format.c tc_format_OBJECTS = tc-format.$(OBJEXT) tc_format_DEPENDENCIES = libHX.la -tc_link_SOURCES = tc-link.c -tc_link_OBJECTS = tc-link.$(OBJEXT) -tc_link_DEPENDENCIES = libHX.la +tc_io_SOURCES = tc-io.c +tc_io_OBJECTS = tc-io.$(OBJEXT) +tc_io_DEPENDENCIES = libHX.la tc_list_SOURCES = tc-list.c tc_list_OBJECTS = tc-list.$(OBJEXT) tc_list_DEPENDENCIES = libHX.la @@ -243,6 +246,9 @@ tc_realpath_DEPENDENCIES = libHX.la tc_shconfig_SOURCES = tc-shconfig.c tc_shconfig_OBJECTS = tc-shconfig.$(OBJEXT) tc_shconfig_DEPENDENCIES = libHX.la +tc_socket_SOURCES = tc-socket.c +tc_socket_OBJECTS = tc-socket.$(OBJEXT) +tc_socket_DEPENDENCIES = libHX.la tc_strchr2_SOURCES = tc-strchr2.c tc_strchr2_OBJECTS = tc-strchr2.$(OBJEXT) tc_strchr2_DEPENDENCIES = libHX.la @@ -252,16 +258,16 @@ tc_string_DEPENDENCIES = libHX.la tc_strquote_SOURCES = tc-strquote.c tc_strquote_OBJECTS = tc-strquote.$(OBJEXT) tc_strquote_DEPENDENCIES = libHX.la +tc_switchuser_SOURCES = tc-switchuser.c +tc_switchuser_OBJECTS = tc-switchuser.$(OBJEXT) +tc_switchuser_DEPENDENCIES = libHX.la tc_time_SOURCES = tc-time.c tc_time_OBJECTS = tc-time.$(OBJEXT) tc_time_DEPENDENCIES = libHX.la am__tx_cast_SOURCES_DIST = tx-cast.cpp -@HAVE_CXX_TRUE@am_tx_cast_OBJECTS = tx_cast-tx-cast.$(OBJEXT) +@HAVE_CXX_TRUE@am_tx_cast_OBJECTS = tx-cast.$(OBJEXT) tx_cast_OBJECTS = $(am_tx_cast_OBJECTS) @HAVE_CXX_TRUE@tx_cast_DEPENDENCIES = libHX.la -tx_cast_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(tx_cast_CXXFLAGS) \ - $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ am__tx_compile_SOURCES_DIST = tx-compile.cpp @HAVE_CXX_TRUE@am_tx_compile_OBJECTS = tx-compile.$(OBJEXT) tx_compile_OBJECTS = $(am_tx_compile_OBJECTS) @@ -274,6 +280,10 @@ am__tx_dir_SOURCES_DIST = tx-dir.cpp @HAVE_CXX_TRUE@am_tx_dir_OBJECTS = tx-dir.$(OBJEXT) tx_dir_OBJECTS = $(am_tx_dir_OBJECTS) @HAVE_CXX_TRUE@tx_dir_DEPENDENCIES = libHX.la +am__tx_intdiff_SOURCES_DIST = tx-intdiff.cpp +@HAVE_CXX_TRUE@am_tx_intdiff_OBJECTS = tx-intdiff.$(OBJEXT) +tx_intdiff_OBJECTS = $(am_tx_intdiff_OBJECTS) +tx_intdiff_LDADD = $(LDADD) am__tx_list_SOURCES_DIST = tx-list.cpp @HAVE_CXX_TRUE@am_tx_list_OBJECTS = tx-list.$(OBJEXT) tx_list_OBJECTS = $(am_tx_list_OBJECTS) @@ -335,7 +345,34 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/deque.Plo ./$(DEPDIR)/dl.Plo \ + ./$(DEPDIR)/format.Plo ./$(DEPDIR)/io.Plo ./$(DEPDIR)/map.Plo \ + ./$(DEPDIR)/mc.Plo ./$(DEPDIR)/misc.Plo ./$(DEPDIR)/opt.Plo \ + ./$(DEPDIR)/proc.Plo ./$(DEPDIR)/rand.Plo \ + ./$(DEPDIR)/rtcheck.Plo ./$(DEPDIR)/socket.Plo \ + ./$(DEPDIR)/string.Plo ./$(DEPDIR)/tc-compile.Po \ + ./$(DEPDIR)/tc-deque.Po ./$(DEPDIR)/tc-dir.Po \ + ./$(DEPDIR)/tc-format.Po ./$(DEPDIR)/tc-io.Po \ + ./$(DEPDIR)/tc-list.Po ./$(DEPDIR)/tc-map.Po \ + ./$(DEPDIR)/tc-memmem.Po ./$(DEPDIR)/tc-misc.Po \ + ./$(DEPDIR)/tc-netio.Po ./$(DEPDIR)/tc-option.Po \ + ./$(DEPDIR)/tc-proc.Po ./$(DEPDIR)/tc-rand.Po \ + ./$(DEPDIR)/tc-realpath.Po ./$(DEPDIR)/tc-shconfig.Po \ + ./$(DEPDIR)/tc-socket.Po ./$(DEPDIR)/tc-strchr2.Po \ + ./$(DEPDIR)/tc-string.Po ./$(DEPDIR)/tc-strquote.Po \ + ./$(DEPDIR)/tc-switchuser.Po ./$(DEPDIR)/tc-time.Po \ + ./$(DEPDIR)/tc_cast-tc-cast.Po \ + ./$(DEPDIR)/tc_list2-tc-list2.Po ./$(DEPDIR)/time.Plo \ + ./$(DEPDIR)/tx-cast.Po ./$(DEPDIR)/tx-compile.Po \ + ./$(DEPDIR)/tx-deque.Po ./$(DEPDIR)/tx-dir.Po \ + ./$(DEPDIR)/tx-intdiff.Po ./$(DEPDIR)/tx-list.Po \ + ./$(DEPDIR)/tx-misc.Po ./$(DEPDIR)/tx-netio.Po \ + ./$(DEPDIR)/tx-option.Po ./$(DEPDIR)/tx-proc.Po \ + ./$(DEPDIR)/tx-rand.Po ./$(DEPDIR)/tx-strchr2.Po \ + ./$(DEPDIR)/tx-string.Po ./$(DEPDIR)/tx-strquote.Po \ + ./$(DEPDIR)/tx-time.Po ./$(DEPDIR)/tx_list2-tx-list2.Po \ + ./$(DEPDIR)/ux-file.Plo ./$(DEPDIR)/ux-mmap.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -374,23 +411,25 @@ am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libHX_la_SOURCES) $(libHX_rtcheck_la_SOURCES) tc-cast.c \ - tc-compile.c tc-deque.c tc-dir.c tc-format.c tc-link.c \ - tc-list.c tc-list2.c tc-map.c tc-memmem.c tc-misc.c tc-netio.c \ + tc-compile.c tc-deque.c tc-dir.c tc-format.c tc-io.c tc-list.c \ + tc-list2.c tc-map.c tc-memmem.c tc-misc.c tc-netio.c \ tc-option.c tc-proc.c tc-rand.c tc-realpath.c tc-shconfig.c \ - tc-strchr2.c tc-string.c tc-strquote.c tc-time.c \ - $(tx_cast_SOURCES) $(tx_compile_SOURCES) $(tx_deque_SOURCES) \ - $(tx_dir_SOURCES) $(tx_list_SOURCES) $(tx_list2_SOURCES) \ + tc-socket.c tc-strchr2.c tc-string.c tc-strquote.c \ + tc-switchuser.c tc-time.c $(tx_cast_SOURCES) \ + $(tx_compile_SOURCES) $(tx_deque_SOURCES) $(tx_dir_SOURCES) \ + $(tx_intdiff_SOURCES) $(tx_list_SOURCES) $(tx_list2_SOURCES) \ $(tx_misc_SOURCES) $(tx_netio_SOURCES) $(tx_option_SOURCES) \ $(tx_proc_SOURCES) $(tx_rand_SOURCES) $(tx_strchr2_SOURCES) \ $(tx_string_SOURCES) $(tx_strquote_SOURCES) $(tx_time_SOURCES) DIST_SOURCES = $(am__libHX_la_SOURCES_DIST) \ $(libHX_rtcheck_la_SOURCES) tc-cast.c tc-compile.c tc-deque.c \ - tc-dir.c tc-format.c tc-link.c tc-list.c tc-list2.c tc-map.c \ + tc-dir.c tc-format.c tc-io.c tc-list.c tc-list2.c tc-map.c \ tc-memmem.c tc-misc.c tc-netio.c tc-option.c tc-proc.c \ - tc-rand.c tc-realpath.c tc-shconfig.c tc-strchr2.c tc-string.c \ - tc-strquote.c tc-time.c $(am__tx_cast_SOURCES_DIST) \ - $(am__tx_compile_SOURCES_DIST) $(am__tx_deque_SOURCES_DIST) \ - $(am__tx_dir_SOURCES_DIST) $(am__tx_list_SOURCES_DIST) \ + tc-rand.c tc-realpath.c tc-shconfig.c tc-socket.c tc-strchr2.c \ + tc-string.c tc-strquote.c tc-switchuser.c tc-time.c \ + $(am__tx_cast_SOURCES_DIST) $(am__tx_compile_SOURCES_DIST) \ + $(am__tx_deque_SOURCES_DIST) $(am__tx_dir_SOURCES_DIST) \ + $(am__tx_intdiff_SOURCES_DIST) $(am__tx_list_SOURCES_DIST) \ $(am__tx_list2_SOURCES_DIST) $(am__tx_misc_SOURCES_DIST) \ $(am__tx_netio_SOURCES_DIST) $(am__tx_option_SOURCES_DIST) \ $(am__tx_proc_SOURCES_DIST) $(am__tx_rand_SOURCES_DIST) \ @@ -418,8 +457,6 @@ am__define_uniq_tagged_files = \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` -ETAGS = etags -CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no @@ -575,6 +612,7 @@ am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` +AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)' RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck @HAVE_CXX_TRUE@am__EXEEXT_2 = tx-strchr2$(EXEEXT) tx-strquote$(EXEEXT) @@ -613,8 +651,9 @@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ -CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CSCOPE = @CSCOPE@ +CTAGS = @CTAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ @@ -629,8 +668,10 @@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ +ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -646,7 +687,6 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ -LYX = @LYX@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ @@ -723,6 +763,7 @@ psdir = @psdir@ regular_CFLAGS = @regular_CFLAGS@ regular_CPPFLAGS = @regular_CPPFLAGS@ regular_CXXFLAGS = @regular_CXXFLAGS@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -736,9 +777,10 @@ AM_CFLAGS = ${regular_CFLAGS} AM_CXXFLAGS = ${regular_CXXFLAGS} lib_LTLIBRARIES = libHX.la $(am__append_1) libHX_la_SOURCES = deque.c dl.c format.c io.c map.c mc.c misc.c opt.c \ - rand.c string.c time.c $(am__append_3) $(am__append_4) -libHX_la_LIBADD = ${libdl_LIBS} ${libpthread_LIBS} ${librt_LIBS} -libHX_la_LDFLAGS = -no-undefined -version-info 32:0:0 $(am__append_2) + proc.c rand.c socket.c string.c time.c $(am__append_3) +libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} \ + $(am__append_4) +libHX_la_LDFLAGS = -no-undefined -version-info 36:0:4 $(am__append_2) EXTRA_libHX_la_DEPENDENCIES = libHX.map libHX_rtcheck_la_SOURCES = rtcheck.c libHX_rtcheck_la_LIBADD = ${libdl_LIBS} @@ -750,7 +792,7 @@ tc_cast_LDADD = libHX.la -lm tc_compile_LDADD = libHX.la tc_dir_LDADD = libHX.la tc_format_LDADD = libHX.la -tc_link_LDADD = libHX.la +tc_io_LDADD = libHX.la tc_list_LDADD = libHX.la tc_list2_LDADD = libHX.la tc_list2_CFLAGS = ${AM_CFLAGS} -O2 -fstrict-aliasing @@ -763,18 +805,20 @@ tc_proc_LDADD = libHX.la tc_rand_LDADD = libHX.la tc_realpath_LDADD = libHX.la tc_shconfig_LDADD = libHX.la +tc_socket_LDADD = libHX.la tc_strchr2_LDADD = libHX.la tc_string_LDADD = libHX.la tc_strquote_LDADD = libHX.la +tc_switchuser_LDADD = libHX.la tc_time_LDADD = libHX.la @HAVE_CXX_TRUE@tx_cast_SOURCES = tx-cast.cpp -@HAVE_CXX_TRUE@tx_cast_CXXFLAGS = ${AM_CXXFLAGS} -std=c++98 @HAVE_CXX_TRUE@tx_cast_LDADD = libHX.la -lm @HAVE_CXX_TRUE@tx_compile_SOURCES = tx-compile.cpp @HAVE_CXX_TRUE@tx_compile_LDADD = libHX.la @HAVE_CXX_TRUE@tx_deque_SOURCES = tx-deque.cpp @HAVE_CXX_TRUE@tx_dir_SOURCES = tx-dir.cpp @HAVE_CXX_TRUE@tx_dir_LDADD = libHX.la +@HAVE_CXX_TRUE@tx_intdiff_SOURCES = tx-intdiff.cpp @HAVE_CXX_TRUE@tx_list_SOURCES = tx-list.cpp @HAVE_CXX_TRUE@tx_list_LDADD = libHX.la @HAVE_CXX_TRUE@tx_list2_SOURCES = tx-list2.cpp @@ -819,8 +863,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -832,6 +876,15 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ @@ -873,15 +926,6 @@ libHX.la: $(libHX_la_OBJECTS) $(libHX_la_DEPENDENCIES) $(EXTRA_libHX_la_DEPENDEN libHX_rtcheck.la: $(libHX_rtcheck_la_OBJECTS) $(libHX_rtcheck_la_DEPENDENCIES) $(EXTRA_libHX_rtcheck_la_DEPENDENCIES) $(AM_V_CCLD)$(libHX_rtcheck_la_LINK) $(am_libHX_rtcheck_la_rpath) $(libHX_rtcheck_la_OBJECTS) $(libHX_rtcheck_la_LIBADD) $(LIBS) -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list - tc-cast$(EXEEXT): $(tc_cast_OBJECTS) $(tc_cast_DEPENDENCIES) $(EXTRA_tc_cast_DEPENDENCIES) @rm -f tc-cast$(EXEEXT) $(AM_V_CCLD)$(tc_cast_LINK) $(tc_cast_OBJECTS) $(tc_cast_LDADD) $(LIBS) @@ -902,9 +946,9 @@ tc-format$(EXEEXT): $(tc_format_OBJECTS) $(tc_format_DEPENDENCIES) $(EXTRA_tc_fo @rm -f tc-format$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tc_format_OBJECTS) $(tc_format_LDADD) $(LIBS) -tc-link$(EXEEXT): $(tc_link_OBJECTS) $(tc_link_DEPENDENCIES) $(EXTRA_tc_link_DEPENDENCIES) - @rm -f tc-link$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(tc_link_OBJECTS) $(tc_link_LDADD) $(LIBS) +tc-io$(EXEEXT): $(tc_io_OBJECTS) $(tc_io_DEPENDENCIES) $(EXTRA_tc_io_DEPENDENCIES) + @rm -f tc-io$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tc_io_OBJECTS) $(tc_io_LDADD) $(LIBS) tc-list$(EXEEXT): $(tc_list_OBJECTS) $(tc_list_DEPENDENCIES) $(EXTRA_tc_list_DEPENDENCIES) @rm -f tc-list$(EXEEXT) @@ -950,6 +994,10 @@ tc-shconfig$(EXEEXT): $(tc_shconfig_OBJECTS) $(tc_shconfig_DEPENDENCIES) $(EXTRA @rm -f tc-shconfig$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tc_shconfig_OBJECTS) $(tc_shconfig_LDADD) $(LIBS) +tc-socket$(EXEEXT): $(tc_socket_OBJECTS) $(tc_socket_DEPENDENCIES) $(EXTRA_tc_socket_DEPENDENCIES) + @rm -f tc-socket$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tc_socket_OBJECTS) $(tc_socket_LDADD) $(LIBS) + tc-strchr2$(EXEEXT): $(tc_strchr2_OBJECTS) $(tc_strchr2_DEPENDENCIES) $(EXTRA_tc_strchr2_DEPENDENCIES) @rm -f tc-strchr2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tc_strchr2_OBJECTS) $(tc_strchr2_LDADD) $(LIBS) @@ -962,13 +1010,17 @@ tc-strquote$(EXEEXT): $(tc_strquote_OBJECTS) $(tc_strquote_DEPENDENCIES) $(EXTRA @rm -f tc-strquote$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tc_strquote_OBJECTS) $(tc_strquote_LDADD) $(LIBS) +tc-switchuser$(EXEEXT): $(tc_switchuser_OBJECTS) $(tc_switchuser_DEPENDENCIES) $(EXTRA_tc_switchuser_DEPENDENCIES) + @rm -f tc-switchuser$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(tc_switchuser_OBJECTS) $(tc_switchuser_LDADD) $(LIBS) + tc-time$(EXEEXT): $(tc_time_OBJECTS) $(tc_time_DEPENDENCIES) $(EXTRA_tc_time_DEPENDENCIES) @rm -f tc-time$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tc_time_OBJECTS) $(tc_time_LDADD) $(LIBS) tx-cast$(EXEEXT): $(tx_cast_OBJECTS) $(tx_cast_DEPENDENCIES) $(EXTRA_tx_cast_DEPENDENCIES) @rm -f tx-cast$(EXEEXT) - $(AM_V_CXXLD)$(tx_cast_LINK) $(tx_cast_OBJECTS) $(tx_cast_LDADD) $(LIBS) + $(AM_V_CXXLD)$(CXXLINK) $(tx_cast_OBJECTS) $(tx_cast_LDADD) $(LIBS) tx-compile$(EXEEXT): $(tx_compile_OBJECTS) $(tx_compile_DEPENDENCIES) $(EXTRA_tx_compile_DEPENDENCIES) @rm -f tx-compile$(EXEEXT) @@ -982,6 +1034,10 @@ tx-dir$(EXEEXT): $(tx_dir_OBJECTS) $(tx_dir_DEPENDENCIES) $(EXTRA_tx_dir_DEPENDE @rm -f tx-dir$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(tx_dir_OBJECTS) $(tx_dir_LDADD) $(LIBS) +tx-intdiff$(EXEEXT): $(tx_intdiff_OBJECTS) $(tx_intdiff_DEPENDENCIES) $(EXTRA_tx_intdiff_DEPENDENCIES) + @rm -f tx-intdiff$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(tx_intdiff_OBJECTS) $(tx_intdiff_LDADD) $(LIBS) + tx-list$(EXEEXT): $(tx_list_OBJECTS) $(tx_list_DEPENDENCIES) $(EXTRA_tx_list_DEPENDENCIES) @rm -f tx-list$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(tx_list_OBJECTS) $(tx_list_LDADD) $(LIBS) @@ -1032,57 +1088,67 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deque.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dl.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rand.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtcheck.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-compile.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-deque.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-dir.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-format.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-link.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-list.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-map.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-memmem.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-misc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-netio.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-option.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-proc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-rand.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-realpath.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-shconfig.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-strchr2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-string.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-strquote.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-time.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc_cast-tc-cast.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc_list2-tc-list2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-compile.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-deque.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-dir.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-list.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-misc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-netio.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-option.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-proc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-rand.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-strchr2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-string.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-strquote.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-time.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx_cast-tx-cast.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx_list2-tx-list2.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ux-file.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ux-mmap.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deque.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dl.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mc.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rand.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtcheck.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-compile.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-deque.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-dir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-format.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-io.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-list.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-map.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-memmem.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-misc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-netio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-option.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-proc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-rand.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-realpath.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-shconfig.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-socket.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-strchr2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-string.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-strquote.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-switchuser.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-time.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc_cast-tc-cast.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc_list2-tc-list2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-cast.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-compile.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-deque.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-dir.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-intdiff.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-list.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-misc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-netio.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-option.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-proc.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-rand.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-strchr2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-string.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-strquote.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx-time.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tx_list2-tx-list2.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ux-file.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ux-mmap.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -1160,20 +1226,6 @@ tc_list2-tc-list2.obj: tc-list2.c @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< -tx_cast-tx-cast.o: tx-cast.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tx_cast_CXXFLAGS) $(CXXFLAGS) -MT tx_cast-tx-cast.o -MD -MP -MF $(DEPDIR)/tx_cast-tx-cast.Tpo -c -o tx_cast-tx-cast.o `test -f 'tx-cast.cpp' || echo '$(srcdir)/'`tx-cast.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tx_cast-tx-cast.Tpo $(DEPDIR)/tx_cast-tx-cast.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tx-cast.cpp' object='tx_cast-tx-cast.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tx_cast_CXXFLAGS) $(CXXFLAGS) -c -o tx_cast-tx-cast.o `test -f 'tx-cast.cpp' || echo '$(srcdir)/'`tx-cast.cpp - -tx_cast-tx-cast.obj: tx-cast.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tx_cast_CXXFLAGS) $(CXXFLAGS) -MT tx_cast-tx-cast.obj -MD -MP -MF $(DEPDIR)/tx_cast-tx-cast.Tpo -c -o tx_cast-tx-cast.obj `if test -f 'tx-cast.cpp'; then $(CYGPATH_W) 'tx-cast.cpp'; else $(CYGPATH_W) '$(srcdir)/tx-cast.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tx_cast-tx-cast.Tpo $(DEPDIR)/tx_cast-tx-cast.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='tx-cast.cpp' object='tx_cast-tx-cast.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tx_cast_CXXFLAGS) $(CXXFLAGS) -c -o tx_cast-tx-cast.obj `if test -f 'tx-cast.cpp'; then $(CYGPATH_W) 'tx-cast.cpp'; else $(CYGPATH_W) '$(srcdir)/tx-cast.cpp'; fi` - tx_list2-tx-list2.o: tx-list2.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tx_list2_CXXFLAGS) $(CXXFLAGS) -MT tx_list2-tx-list2.o -MD -MP -MF $(DEPDIR)/tx_list2-tx-list2.Tpo -c -o tx_list2-tx-list2.o `test -f 'tx-list2.cpp' || echo '$(srcdir)/'`tx-list2.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tx_list2-tx-list2.Tpo $(DEPDIR)/tx_list2-tx-list2.Po @@ -1353,7 +1405,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ - echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ @@ -1366,7 +1418,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS) fi; \ $$success || exit 1 -check-TESTS: +check-TESTS: $(check_PROGRAMS) @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @@ -1387,6 +1439,13 @@ recheck: all $(check_PROGRAMS) am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? +tc-format.log: tc-format$(EXEEXT) + @p='tc-format$(EXEEXT)'; \ + b='tc-format'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) tc-strchr2.log: tc-strchr2$(EXEEXT) @p='tc-strchr2$(EXEEXT)'; \ b='tc-strchr2'; \ @@ -1429,8 +1488,10 @@ tx-strquote.log: tx-strquote$(EXEEXT) @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am -distdir: $(DISTFILES) +distdir-am: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -1465,6 +1526,8 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(LTLIBRARIES) +install-checkPROGRAMS: install-libLTLIBRARIES + installdirs: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ @@ -1508,7 +1571,61 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ clean-libtool mostlyclean-am distclean: distclean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/deque.Plo + -rm -f ./$(DEPDIR)/dl.Plo + -rm -f ./$(DEPDIR)/format.Plo + -rm -f ./$(DEPDIR)/io.Plo + -rm -f ./$(DEPDIR)/map.Plo + -rm -f ./$(DEPDIR)/mc.Plo + -rm -f ./$(DEPDIR)/misc.Plo + -rm -f ./$(DEPDIR)/opt.Plo + -rm -f ./$(DEPDIR)/proc.Plo + -rm -f ./$(DEPDIR)/rand.Plo + -rm -f ./$(DEPDIR)/rtcheck.Plo + -rm -f ./$(DEPDIR)/socket.Plo + -rm -f ./$(DEPDIR)/string.Plo + -rm -f ./$(DEPDIR)/tc-compile.Po + -rm -f ./$(DEPDIR)/tc-deque.Po + -rm -f ./$(DEPDIR)/tc-dir.Po + -rm -f ./$(DEPDIR)/tc-format.Po + -rm -f ./$(DEPDIR)/tc-io.Po + -rm -f ./$(DEPDIR)/tc-list.Po + -rm -f ./$(DEPDIR)/tc-map.Po + -rm -f ./$(DEPDIR)/tc-memmem.Po + -rm -f ./$(DEPDIR)/tc-misc.Po + -rm -f ./$(DEPDIR)/tc-netio.Po + -rm -f ./$(DEPDIR)/tc-option.Po + -rm -f ./$(DEPDIR)/tc-proc.Po + -rm -f ./$(DEPDIR)/tc-rand.Po + -rm -f ./$(DEPDIR)/tc-realpath.Po + -rm -f ./$(DEPDIR)/tc-shconfig.Po + -rm -f ./$(DEPDIR)/tc-socket.Po + -rm -f ./$(DEPDIR)/tc-strchr2.Po + -rm -f ./$(DEPDIR)/tc-string.Po + -rm -f ./$(DEPDIR)/tc-strquote.Po + -rm -f ./$(DEPDIR)/tc-switchuser.Po + -rm -f ./$(DEPDIR)/tc-time.Po + -rm -f ./$(DEPDIR)/tc_cast-tc-cast.Po + -rm -f ./$(DEPDIR)/tc_list2-tc-list2.Po + -rm -f ./$(DEPDIR)/time.Plo + -rm -f ./$(DEPDIR)/tx-cast.Po + -rm -f ./$(DEPDIR)/tx-compile.Po + -rm -f ./$(DEPDIR)/tx-deque.Po + -rm -f ./$(DEPDIR)/tx-dir.Po + -rm -f ./$(DEPDIR)/tx-intdiff.Po + -rm -f ./$(DEPDIR)/tx-list.Po + -rm -f ./$(DEPDIR)/tx-misc.Po + -rm -f ./$(DEPDIR)/tx-netio.Po + -rm -f ./$(DEPDIR)/tx-option.Po + -rm -f ./$(DEPDIR)/tx-proc.Po + -rm -f ./$(DEPDIR)/tx-rand.Po + -rm -f ./$(DEPDIR)/tx-strchr2.Po + -rm -f ./$(DEPDIR)/tx-string.Po + -rm -f ./$(DEPDIR)/tx-strquote.Po + -rm -f ./$(DEPDIR)/tx-time.Po + -rm -f ./$(DEPDIR)/tx_list2-tx-list2.Po + -rm -f ./$(DEPDIR)/ux-file.Plo + -rm -f ./$(DEPDIR)/ux-mmap.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1554,7 +1671,61 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/deque.Plo + -rm -f ./$(DEPDIR)/dl.Plo + -rm -f ./$(DEPDIR)/format.Plo + -rm -f ./$(DEPDIR)/io.Plo + -rm -f ./$(DEPDIR)/map.Plo + -rm -f ./$(DEPDIR)/mc.Plo + -rm -f ./$(DEPDIR)/misc.Plo + -rm -f ./$(DEPDIR)/opt.Plo + -rm -f ./$(DEPDIR)/proc.Plo + -rm -f ./$(DEPDIR)/rand.Plo + -rm -f ./$(DEPDIR)/rtcheck.Plo + -rm -f ./$(DEPDIR)/socket.Plo + -rm -f ./$(DEPDIR)/string.Plo + -rm -f ./$(DEPDIR)/tc-compile.Po + -rm -f ./$(DEPDIR)/tc-deque.Po + -rm -f ./$(DEPDIR)/tc-dir.Po + -rm -f ./$(DEPDIR)/tc-format.Po + -rm -f ./$(DEPDIR)/tc-io.Po + -rm -f ./$(DEPDIR)/tc-list.Po + -rm -f ./$(DEPDIR)/tc-map.Po + -rm -f ./$(DEPDIR)/tc-memmem.Po + -rm -f ./$(DEPDIR)/tc-misc.Po + -rm -f ./$(DEPDIR)/tc-netio.Po + -rm -f ./$(DEPDIR)/tc-option.Po + -rm -f ./$(DEPDIR)/tc-proc.Po + -rm -f ./$(DEPDIR)/tc-rand.Po + -rm -f ./$(DEPDIR)/tc-realpath.Po + -rm -f ./$(DEPDIR)/tc-shconfig.Po + -rm -f ./$(DEPDIR)/tc-socket.Po + -rm -f ./$(DEPDIR)/tc-strchr2.Po + -rm -f ./$(DEPDIR)/tc-string.Po + -rm -f ./$(DEPDIR)/tc-strquote.Po + -rm -f ./$(DEPDIR)/tc-switchuser.Po + -rm -f ./$(DEPDIR)/tc-time.Po + -rm -f ./$(DEPDIR)/tc_cast-tc-cast.Po + -rm -f ./$(DEPDIR)/tc_list2-tc-list2.Po + -rm -f ./$(DEPDIR)/time.Plo + -rm -f ./$(DEPDIR)/tx-cast.Po + -rm -f ./$(DEPDIR)/tx-compile.Po + -rm -f ./$(DEPDIR)/tx-deque.Po + -rm -f ./$(DEPDIR)/tx-dir.Po + -rm -f ./$(DEPDIR)/tx-intdiff.Po + -rm -f ./$(DEPDIR)/tx-list.Po + -rm -f ./$(DEPDIR)/tx-misc.Po + -rm -f ./$(DEPDIR)/tx-netio.Po + -rm -f ./$(DEPDIR)/tx-option.Po + -rm -f ./$(DEPDIR)/tx-proc.Po + -rm -f ./$(DEPDIR)/tx-rand.Po + -rm -f ./$(DEPDIR)/tx-strchr2.Po + -rm -f ./$(DEPDIR)/tx-string.Po + -rm -f ./$(DEPDIR)/tx-strquote.Po + -rm -f ./$(DEPDIR)/tx-time.Po + -rm -f ./$(DEPDIR)/tx_list2-tx-list2.Po + -rm -f ./$(DEPDIR)/ux-file.Plo + -rm -f ./$(DEPDIR)/ux-mmap.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1575,17 +1746,17 @@ uninstall-am: uninstall-libLTLIBRARIES .MAKE: check-am install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ - clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ - clean-libtool cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am \ - install-libLTLIBRARIES install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \ + check-am clean clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ recheck tags tags-am uninstall uninstall-am \ diff --git a/src/deque.c b/src/deque.c index 3ff7dc9..bc39e0e 100644 --- a/src/deque.c +++ b/src/deque.c @@ -122,6 +122,8 @@ EXPORT_SYMBOL void *HXdeque_del(struct HXdeque_node *node) EXPORT_SYMBOL void HXdeque_free(struct HXdeque *dq) { + if (dq == NULL) + return; struct HXdeque_node *node, *next; for (node = dq->first; node != NULL; node = next) { next = node->next; diff --git a/src/format.c b/src/format.c index 0c463b0..25c09d6 100644 --- a/src/format.c +++ b/src/format.c @@ -16,6 +16,12 @@ #include <unistd.h> #include <libHX.h> #include "internal.h" +#undef HXformat_aprintf +#undef HXformat_fprintf +#undef HXformat_sprintf +extern int HXformat_aprintf(const struct HXformat_map *, hxmc_t **, const char *); +extern int HXformat_sprintf(const struct HXformat_map *, char *, size_t, const char *); +extern int HXformat_fprintf(const struct HXformat_map *, FILE *, const char *); /* To make it easier on the highlighter */ #define C_OPEN '(' @@ -97,10 +103,13 @@ static void *func_entry_clone(const void *data, size_t size) static const struct HXmap_ops func_entry_ops = { .d_clone = func_entry_clone, + .d_free = free, }; EXPORT_SYMBOL void HXformat_free(struct HXformat_map *blk) { + if (blk == NULL) + return; HXmap_free(blk->vars); HXmap_free(blk->funcs); free(blk); @@ -295,7 +304,6 @@ static hxmc_t *HXformat2_snl(int argc, const hxmc_t *const *argv, static hxmc_t *HXformat2_substr(int argc, const hxmc_t *const *argv, const struct HXformat_map *blk) { - ssize_t offset, length, z; hxmc_t *ret; char *end; @@ -304,44 +312,27 @@ static hxmc_t *HXformat2_substr(int argc, const hxmc_t *const *argv, return &HXformat2_nexp; } - offset = strtoll(argv[1], &end, 0); + long w = LONG_MAX, v = strtol(argv[1], &end, 0); if (*end != '\0') { fprintf(stderr, "HXformat2-substr: found garbage in " "offset specification\n"); return &HXformat2_nexp; } - - z = strlen(argv[0]); - if (offset < 0) - offset = z + offset; - if (offset >= z) - return &HXformat2_nexp; - - if (argc == 2) { - if (offset < 0) - offset = 0; - length = z - offset; - } else { - length = strtoll(argv[2], &end, 0); + if (argc >= 3) { + w = strtol(argv[2], &end, 0); if (*end != '\0') { fprintf(stderr, "HXformat2-substr; found garbage in " "length specification\n"); return &HXformat2_nexp; } - if (length < 0) - length/*end*/ = z + length; - else - length/*end*/ = offset + length; - if (offset < 0) - offset = 0; } - if (length <= 0) + size_t start = 0, tocopy = HX_substr_helper(strlen(argv[0]), v, w, &start); + if (tocopy == 0) return &HXformat2_nexp; - - ret = HXmc_meminit(NULL, length); + ret = HXmc_meminit(NULL, tocopy); if (ret == NULL) return &HXformat2_nexp; - if (HXmc_memcpy(&ret, &argv[0][offset], length) == NULL) { + if (HXmc_memcpy(&ret, &argv[0][start], tocopy) == NULL) { HXmc_free(ret); return &HXformat2_nexp; } @@ -641,6 +632,13 @@ EXPORT_SYMBOL struct HXformat_map *HXformat_init(void) EXPORT_SYMBOL int HXformat_aprintf(const struct HXformat_map *blk, hxmc_t **resultp, const char *fmt) { + ssize_t ret = HXformat3_aprintf(blk, resultp, fmt); + return ret > INT_MAX ? INT_MAX : ret; +} + +EXPORT_SYMBOL ssize_t HXformat3_aprintf(const struct HXformat_map *blk, + hxmc_t **resultp, const char *fmt) +{ hxmc_t *ex, *ts, *out; const char *current; int ret = 0; @@ -677,7 +675,8 @@ EXPORT_SYMBOL int HXformat_aprintf(const struct HXformat_map *blk, } *resultp = out; - return HXmc_length(out); + size_t xl = HXmc_length(out); + return xl > SSIZE_MAX ? SSIZE_MAX : xl; out: ret = -errno; @@ -688,10 +687,17 @@ EXPORT_SYMBOL int HXformat_aprintf(const struct HXformat_map *blk, EXPORT_SYMBOL int HXformat_fprintf(const struct HXformat_map *ftable, FILE *filp, const char *fmt) { + ssize_t ret = HXformat3_fprintf(ftable, filp, fmt); + return ret > INT_MAX ? INT_MAX : ret; +} + +EXPORT_SYMBOL ssize_t HXformat3_fprintf(const struct HXformat_map *ftable, + FILE *filp, const char *fmt) +{ hxmc_t *str; - int ret; + ssize_t ret; - if ((ret = HXformat_aprintf(ftable, &str, fmt)) <= 0) + if ((ret = HXformat3_aprintf(ftable, &str, fmt)) <= 0) return ret; errno = 0; if (fputs(str, filp) < 0) @@ -703,8 +709,15 @@ EXPORT_SYMBOL int HXformat_fprintf(const struct HXformat_map *ftable, EXPORT_SYMBOL int HXformat_sprintf(const struct HXformat_map *ftable, char *dest, size_t size, const char *fmt) { + ssize_t ret = HXformat3_sprintf(ftable, dest, size, fmt); + return ret > INT_MAX ? INT_MAX : ret; +} + +EXPORT_SYMBOL ssize_t HXformat3_sprintf(const struct HXformat_map *ftable, + char *dest, size_t size, const char *fmt) +{ hxmc_t *str; - int ret; + ssize_t ret; if ((ret = HXformat_aprintf(ftable, &str, fmt)) < 0) return ret; @@ -713,7 +726,7 @@ EXPORT_SYMBOL int HXformat_sprintf(const struct HXformat_map *ftable, return 0; } strncpy(dest, str, size); - ret = HXmc_length(dest); + size_t xl = strlen(dest); HXmc_free(str); - return ret; + return xl > SSIZE_MAX ? SSIZE_MAX : xl; } diff --git a/src/internal.h b/src/internal.h index d348520..0465d81 100644 --- a/src/internal.h +++ b/src/internal.h @@ -10,6 +10,7 @@ #define LIBHX_INTERNAL_H 1 #include "config.h" +#include <stdint.h> #include <libHX/defs.h> #include <libHX/string.h> @@ -42,6 +43,9 @@ #define MAXLNLEN 1024 /* max length for usual line */ #define HXMC_IDENT 0x200571AF +#if !defined(__cplusplus) +# define nullptr NULL +#endif struct memcont { size_t alloc, length; @@ -53,5 +57,6 @@ struct timespec; struct timeval; extern hxmc_t *HXparse_dequote_fmt(const char *, const char *, const char **); +extern size_t HX_substr_helper(size_t, long, long, size_t *); #endif /* LIBHX_INTERNAL_H */ @@ -7,6 +7,9 @@ * General Public License as published by the Free Software Foundation; * either version 2.1 or (at your option) any later version. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include <sys/stat.h> #include <errno.h> #include <fcntl.h> @@ -14,6 +17,7 @@ #include <stdarg.h> #include <stdbool.h> #include <stddef.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -25,12 +29,18 @@ # include <dirent.h> # include <unistd.h> #endif +#if __linux__ +# include <sys/sendfile.h> +#endif #include <libHX/ctype_helper.h> #include <libHX/defs.h> #include <libHX/io.h> #include <libHX/misc.h> #include <libHX/string.h> #include "internal.h" +#ifndef O_CLOEXEC +# define O_CLOEXEC 0 +#endif struct HXdir { #if defined _WIN32 @@ -47,22 +57,23 @@ struct HXdir { static int mkdir_gen(const char *d, unsigned int mode) { struct stat sb; - if (lstat(d, &sb) < 0) { #if defined(_WIN32) - if (mkdir(d) < 0) + if (mkdir(d) == 0) #else - if (mkdir(d, mode) < 0) /* use umask() for permissions */ + if (mkdir(d, mode) == 0) /* use umask() for permissions */ #endif - return -errno; - } else { + return 1; + if (errno != EEXIST) + return -errno; + if (lstat(d, &sb) == 0) { #if defined(_WIN32) - if ((sb.st_mode & S_IFDIR) != S_IFDIR) + if (sb.st_mode & S_IFDIR) #else - if (!S_ISDIR(sb.st_mode)) + if (S_ISDIR(sb.st_mode)) #endif - return -errno; + return 0; } - return 1; + return -EEXIST; } EXPORT_SYMBOL struct HXdir *HXdir_open(const char *s) @@ -159,46 +170,77 @@ EXPORT_SYMBOL void HXdir_close(struct HXdir *d) EXPORT_SYMBOL int HX_copy_file(const char *src, const char *dest, unsigned int opts, ...) { - char buf[MAXLNLEN]; + static const size_t bufsize = 0x10000; + void *buf; unsigned int extra_flags = 0; - int dd, eax = 0, sd, l; + int srcfd, dstfd; - if ((sd = open(src, O_RDONLY | O_BINARY)) < 0) + buf = malloc(bufsize); + if (buf == nullptr) + return -errno; + srcfd = open(src, O_RDONLY | O_BINARY); + if (srcfd < 0) { + free(buf); return -errno; + } if (opts & HXF_KEEP) extra_flags = O_EXCL; - dd = open(dest, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC | - extra_flags, S_IRUGO | S_IWUGO); - if (dd < 0) { - eax = errno; - close(sd); - errno = eax; - if (extra_flags != 0 && eax == EEXIST) - return 1; - return -errno; + dstfd = open(dest, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC | + extra_flags, S_IRUGO | S_IWUGO); + if (dstfd < 0) { + int saved_errno = errno; + free(buf); + close(srcfd); + return -(errno = saved_errno); } - while ((l = read(sd, buf, MAXLNLEN)) > 0 && write(dd, buf, l) > 0) - ; - close(sd); - if (opts & (HXF_UID | HXF_GID)) { struct stat sb; long uid, gid; va_list argp; va_start(argp, opts); - fstat(dd, &sb); + if (fstat(dstfd, &sb) < 0) { + int saved_errno = errno; + unlink(dest); + close(dstfd); + close(srcfd); + free(buf); + va_end(argp); + return -(errno = saved_errno); + } uid = sb.st_uid; gid = sb.st_gid; if (opts & HXF_UID) uid = va_arg(argp, long); if (opts & HXF_GID) gid = va_arg(argp, long); - if (fchown(dd, uid, gid) < 0) - {}; + if (fchown(dstfd, uid, gid) < 0) { + int saved_errno = errno; + unlink(dest); + close(dstfd); + close(srcfd); + free(buf); + va_end(argp); + return -(errno = saved_errno); + } va_end(argp); } - close(dd); + + while (true) { + ssize_t rdret = HX_sendfile(dstfd, srcfd, SIZE_MAX); + if (rdret == 0) + break; + if (rdret < 0 && errno != EINTR) { + int saved_errno = errno; + close(srcfd); + close(dstfd); + free(buf); + return -(errno = saved_errno); + } + } + close(srcfd); + close(dstfd); + free(buf); return 1; } @@ -228,8 +270,8 @@ EXPORT_SYMBOL int HX_copy_dir(const char *src, const char *dest, continue; snprintf(fsrc, MAXFNLEN, "%s/%s", src, fn); snprintf(fdest, MAXFNLEN, "%s/%s", dest, fn); - - lstat(fsrc, &sb); + if (lstat(fsrc, &sb) < 0) + continue; sb.st_mode &= 0777; /* clear SUID/GUID/Sticky bits */ if (S_ISREG(sb.st_mode)) { @@ -242,17 +284,20 @@ EXPORT_SYMBOL int HX_copy_dir(const char *src, const char *dest, memset(pt, '\0', MAXFNLEN); if (readlink(fsrc, pt, MAXFNLEN - 1) < MAXFNLEN - 1) if (symlink(pt, fdest) < 0) - {}; + /* ignore */; } else if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) { - mknod(fdest, sb.st_mode, sb.st_dev); + if (mknod(fdest, sb.st_mode, sb.st_dev) < 0) + /* ignore */; } else if (S_ISFIFO(sb.st_mode)) { - mkfifo(fdest, sb.st_mode); + if (mkfifo(fdest, sb.st_mode) < 0) + /* ignore */; } if (lchown(fdest, uid, gid) < 0) - {}; + /* ignore */; if (!S_ISLNK(sb.st_mode)) - chmod(fdest, sb.st_mode); + if (chmod(fdest, sb.st_mode) < 0) + /* ignore */; } HXdir_close(dt); @@ -285,12 +330,12 @@ EXPORT_SYMBOL int HX_mkdir(const char *idir, unsigned int mode) if (dir[i] == '/') { strncpy(buf, dir, i); buf[i] = '\0'; - if ((v = mkdir_gen(buf, mode)) <= 0) + if ((v = mkdir_gen(buf, mode)) < 0) return v; } else if (i == len - 1) { strncpy(buf, dir, len); buf[len] = '\0'; - if ((v = mkdir_gen(buf, mode)) <= 0) + if ((v = mkdir_gen(buf, mode)) < 0) return v; } } @@ -300,27 +345,43 @@ EXPORT_SYMBOL int HX_mkdir(const char *idir, unsigned int mode) /* Readlink - with a trailing zero (provided by HXmc) */ EXPORT_SYMBOL int HX_readlink(hxmc_t **target, const char *path) { - bool dnull = *target == NULL; - char *tb; - int ret; + bool allocate = *target == NULL; + size_t linkbuf_size; - if (dnull) { - *target = HXmc_meminit(NULL, PATH_MAX); + if (allocate) { + linkbuf_size = 32; + *target = HXmc_meminit(NULL, 32); if (*target == NULL) return -errno; + } else { + linkbuf_size = HXmc_length(*target); } - tb = *target; - ret = readlink(path, tb, PATH_MAX); - if (ret < 0) { - ret = -errno; - if (!dnull) { - HXmc_free(*target); - *target = NULL; + while (true) { + ssize_t ret = readlink(path, *target, linkbuf_size); + if (ret < 0) { + int saved_errno = errno; + if (allocate) { + HXmc_free(*target); + *target = nullptr; + } + return -(errno = saved_errno); + } + if (static_cast(size_t, ret) < linkbuf_size) { + (*target)[ret] = '\0'; // please cov-scan + HXmc_setlen(target, ret); // \0 set here anyway + return ret; + } + linkbuf_size *= 2; + if (HXmc_setlen(target, linkbuf_size) == NULL) { + int saved_errno = errno; + if (allocate) { + HXmc_free(*target); + *target = nullptr; + } + return -(errno = saved_errno); } - return ret; } - HXmc_setlen(target, ret); - return ret; + return 0; } /** @@ -449,7 +510,7 @@ EXPORT_SYMBOL int HX_realpath(hxmc_t **dest_pptr, const char *path, ret = HX_realpath_symres(&state, path); if (ret == -EINVAL) continue; - else if (ret < 0) + else if (ret <= 0) goto out; path = state.path; } @@ -533,31 +594,185 @@ EXPORT_SYMBOL int HX_rrmdir(const char *dir) EXPORT_SYMBOL ssize_t HXio_fullread(int fd, void *vbuf, size_t size) { char *buf = vbuf; - size_t rem = size; - ssize_t ret; + size_t done = 0; + if (size > SSIZE_MAX) + size = SSIZE_MAX; - while (rem > 0) { - ret = read(fd, buf, rem); + while (done < size) { + ssize_t ret = read(fd, buf, size - done); if (ret < 0) return ret; - rem -= ret; + else if (ret == 0) + break; + done += ret; buf += ret; } - return size; + return done; } EXPORT_SYMBOL ssize_t HXio_fullwrite(int fd, const void *vbuf, size_t size) { const char *buf = vbuf; - size_t rem = size; - ssize_t ret; + size_t done = 0; + if (size > SSIZE_MAX) + size = SSIZE_MAX; - while (rem > 0) { - ret = write(fd, buf, rem); + while (done < size) { + ssize_t ret = write(fd, buf, size - done); if (ret < 0) return ret; - rem -= ret; + else if (ret == 0) + break; + done += ret; buf += ret; } - return size; + return done; +} + +#if __linux__ +static ssize_t HX_sendfile_linux(int dst, int src, size_t count) +{ + long pagesize = sysconf(_SC_PAGE_SIZE); + size_t xfersize; + ssize_t ret, xferd = 0; + + if (pagesize < 0) + pagesize = 4096; + xfersize = SSIZE_MAX - pagesize; + if (count > xfersize) + count = xfersize; + while ((ret = sendfile(dst, src, nullptr, count)) > 0) + xferd += ret; + if (xferd > 0) + return xferd; + if (ret < 0) + return -errno; + return 0; +} +#endif + +static ssize_t HX_sendfile_rw(int dst, int src, size_t count) +{ + static const size_t bufsize = 0x10000; + size_t xferd = 0; + ssize_t ret; + void *buf = malloc(bufsize); + if (buf == nullptr) + return -ENOMEM; + if (count > SSIZE_MAX) + count = SSIZE_MAX; + while (count > 0) { + size_t readsize = bufsize; + if (count < readsize) + readsize = count; + ret = HXio_fullread(src, buf, readsize); + if (ret < 0) { + errno = -ret; + break; + } + ret = HXio_fullwrite(dst, buf, ret); + if (ret < 0) { + errno = -ret; + break; + } + xferd += ret; + count -= ret; + } + free(buf); + if (xferd > 0) + return xferd; + if (ret < 0) + return -errno; + return 0; +} + +EXPORT_SYMBOL ssize_t HX_sendfile(int dst, int src, size_t count) +{ +#if __linux__ + ssize_t ret = HX_sendfile_linux(dst, src, count); + if (ret != -ENOSYS) + return ret; +#endif + return HX_sendfile_rw(dst, src, count); +} + +EXPORT_SYMBOL char *HX_slurp_fd(int fd, size_t *outsize) +{ + struct stat sb; + if (fstat(fd, &sb) < 0) + return NULL; + if (sb.st_size == 0) { + /* e.g. ttys (S_ISCHR) or special procfs files */ + size_t bufsize = 4096, offset = 0; + char *buf = malloc(bufsize); + if (buf == nullptr) + return nullptr; + ssize_t rdret; + while ((rdret = read(fd, buf + offset, bufsize - 1 - offset)) > 0) { + offset += rdret; + /* + * Make it so that the next read call is not called + * with an exceptionally small size. + */ + if (bufsize - offset >= 4095) + continue; + if (bufsize > SSIZE_MAX) + /* No more doubling */ + break; + bufsize *= 2; + void *nbuf = realloc(buf, bufsize + 1); + if (nbuf == nullptr) { + int se = errno; + free(buf); + errno = se; + return nullptr; + } + buf = nbuf; + } + buf[offset] = '\0'; + if (outsize != nullptr) + *outsize = offset; + return buf; + } + size_t fsize = sb.st_size; /* may truncate from loff_t to size_t */ + if (fsize == SIZE_MAX) + --fsize; +#ifdef HAVE_POSIX_FADVISE + if (fsize > 0 && posix_fadvise(fd, 0, fsize, + POSIX_FADV_SEQUENTIAL) != 0) + /* ignore */; +#endif + char *buf = malloc(fsize + 1); + if (buf == NULL) + return NULL; + ssize_t rdret = HXio_fullread(fd, buf, fsize); + if (rdret < 0) { + int se = errno; + free(buf); + errno = se; + return NULL; + } + buf[rdret] = '\0'; + if (outsize != NULL) + *outsize = rdret; + return buf; +} + +EXPORT_SYMBOL char *HX_slurp_file(const char *file, size_t *outsize) +{ + int fd = open(file, O_RDONLY | O_BINARY | O_CLOEXEC); + if (fd < 0) + return NULL; + size_t tmpsize; + if (outsize == NULL) + outsize = &tmpsize; + char *buf = HX_slurp_fd(fd, outsize); + if (buf == NULL) { + int se = errno; + close(fd); + errno = se; + return NULL; + } + close(fd); + return buf; } diff --git a/src/libHX.map b/src/libHX.map index d5ea9c7..c4cef55 100644 --- a/src/libHX.map +++ b/src/libHX.map @@ -126,3 +126,36 @@ global: local: *; }; + +LIBHX_3.27 { +global: + HX_socket_from_env; + HX_slurp_fd; + HX_slurp_file; + HXproc_switch_user; + HXproc_top_fd; +} LIBHX_3.25; + +LIBHX_4.2 { +global: + HX_strtod_unit; + HX_strtoull_unit; + HX_unit_size; + HX_unit_size_cu; +} LIBHX_3.27; + +LIBHX_4.3 { +global: + HX_sendfile; + HX_unit_seconds; + HX_strtoull_sec; +} LIBHX_4.2; + +LIBHX_4.9 { +global: + HXformat3_aprintf; + HXformat3_fprintf; + HXformat3_sprintf; + HX_ipaddr_is_local; + HX_sockaddr_is_local; +} LIBHX_4.3; @@ -102,6 +102,8 @@ static void HXrbtree_free(struct HXrbtree *btree) EXPORT_SYMBOL void HXmap_free(struct HXmap *xmap) { + if (xmap == NULL) + return; void *vmap = xmap; const struct HXmap_private *map = vmap; @@ -1302,11 +1304,12 @@ static struct HXrbnode *HXrbtrav_rewalk(struct HXrbtrav *trav) trav->current = trav->path[--trav->depth]; if (trav->current == NULL) fprintf(stderr, "btrav_rewalk: problem: current==NULL\n"); - HXrbtrav_checkpoint(trav, trav->current); + else + HXrbtrav_checkpoint(trav, trav->current); } trav->tid = btree->tid; - if (go_next) + if (trav->current != nullptr && go_next) return HXrbtrav_next(trav); else return trav->current; @@ -8,6 +8,7 @@ * either version 2.1 or (at your option) any later version. */ #include <stddef.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -20,10 +21,12 @@ static __inline__ size_t __HXmc_request(size_t len) return sizeof(struct memcont) + len + 1; } -static __inline__ void HXmc_check(const struct memcont *c) +static __inline__ int HXmc_check(const struct memcont *c) { - if (c->id != HXMC_IDENT) + int err = c->id != HXMC_IDENT; + if (err != 0) fprintf(stderr, "libHX-mc error: not a hxmc object!\n"); + return err; } static __inline__ struct memcont *HXmc_base(const hxmc_t *p) @@ -61,7 +64,8 @@ EXPORT_SYMBOL hxmc_t *HXmc_memcpy(hxmc_t **vp, const void *ptr, size_t len) struct memcont *ctx; if (*vp != NULL) { ctx = HXmc_base(*vp); - HXmc_check(ctx); + if (HXmc_check(ctx) != 0) + return nullptr; if (ctx->alloc < len) { ctx = realloc(ctx, __HXmc_request(len)); if (ctx == NULL) @@ -79,11 +83,13 @@ EXPORT_SYMBOL hxmc_t *HXmc_memcpy(hxmc_t **vp, const void *ptr, size_t len) if (ptr == NULL) { ctx->length = 0; ctx->data[0] = '\0'; + // coverity[leaked_storage] return *vp = ctx->data; } memcpy(ctx->data, ptr, ctx->length = len); ctx->data[len] = '\0'; + // coverity[leaked_storage] return *vp = ctx->data; } @@ -94,7 +100,8 @@ EXPORT_SYMBOL size_t HXmc_length(const hxmc_t *vp) if (vp == NULL) return 0; ctx = HXmc_base(vp); - HXmc_check(ctx); + if (HXmc_check(ctx) != 0) + return SIZE_MAX; return ctx->length; } @@ -113,7 +120,8 @@ EXPORT_SYMBOL hxmc_t *HXmc_trunc(hxmc_t **vp, size_t len) { struct memcont *ctx = HXmc_base(*vp); - HXmc_check(ctx); + if (HXmc_check(ctx) != 0) + return nullptr; if (len > ctx->alloc) { ctx = realloc(ctx, __HXmc_request(len)); if (ctx == NULL) @@ -123,6 +131,7 @@ EXPORT_SYMBOL hxmc_t *HXmc_trunc(hxmc_t **vp, size_t len) ctx->data[len] = '\0'; ctx->length = len; } + // coverity[leaked_storage] return *vp = ctx->data; } @@ -138,7 +147,8 @@ EXPORT_SYMBOL hxmc_t *HXmc_memcat(hxmc_t **vp, const void *ptr, size_t len) struct memcont *ctx = HXmc_base(*vp); size_t nl = ctx->length + len; - HXmc_check(ctx); + if (HXmc_check(ctx) != 0) + return nullptr; if (nl > ctx->alloc) { ctx = realloc(ctx, __HXmc_request(nl)); if (ctx == NULL) @@ -146,11 +156,13 @@ EXPORT_SYMBOL hxmc_t *HXmc_memcat(hxmc_t **vp, const void *ptr, size_t len) ctx->alloc = nl; } if (ptr == NULL) + // coverity[leaked_storage] return *vp = ctx->data; memcpy(ctx->data + ctx->length, ptr, len); ctx->length = nl; ctx->data[nl] = '\0'; + // coverity[leaked_storage] return *vp = ctx->data; } @@ -186,7 +198,8 @@ EXPORT_SYMBOL hxmc_t *HXmc_memins(hxmc_t **vp, size_t pos, const void *ptr, struct memcont *ctx = HXmc_base(*vp); size_t nl = ctx->length + len; - HXmc_check(ctx); + if (HXmc_check(ctx) != 0) + return nullptr; if (ctx->alloc < nl) { ctx = realloc(ctx, __HXmc_request(nl)); if (ctx == NULL) @@ -200,14 +213,15 @@ EXPORT_SYMBOL hxmc_t *HXmc_memins(hxmc_t **vp, size_t pos, const void *ptr, memcpy(ctx->data + pos, ptr, len); ctx->length += len; ctx->data[ctx->length] = '\0'; + // coverity[leaked_storage] return *vp = ctx->data; } EXPORT_SYMBOL hxmc_t *HXmc_memdel(hxmc_t *vp, size_t pos, size_t len) { struct memcont *ctx = HXmc_base(vp); - HXmc_check(ctx); - + if (HXmc_check(ctx) != 0) + return nullptr; if (pos + len > ctx->length) len = ctx->length - pos; @@ -224,7 +238,8 @@ EXPORT_SYMBOL void HXmc_free(hxmc_t *vp) if (vp == NULL) return; ctx = HXmc_base(vp); - HXmc_check(ctx); + if (HXmc_check(ctx) != 0) + return; free(ctx); } @@ -547,8 +547,12 @@ static int HX_getopt_long(const char *cur, struct HX_getopt_vars *par) key = HX_strdup(cur); if (key == NULL) return -errno; - value = strchr(key, '='); + if (value == nullptr) { + /* Cannot happen because state is always !S_TWOLONG */ + free(key); + return -EINVAL; + } *value++ = '\0'; par->cbi.current = lookup_long_pfx(par->cbi.table, key + 2); if (par->cbi.current == &HXopt_ambig_prefix) { @@ -699,14 +703,16 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, struct HX_getopt_vars ps; const char **opt = *argv; int state = HXOPT_S_NORMAL; - int ret = HXOPT_ERR_SUCCESS; + int ret = -ENOMEM; unsigned int argk; const char *cur; memset(&ps, 0, sizeof(ps)); ps.remaining = HXdeque_init(); - if (ps.remaining == NULL) + if (ps.remaining == NULL) { + ret = -errno; goto out; + } ps.flags = flags; ps.arg0 = **argv; ps.cbi.table = table; @@ -714,17 +720,19 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, if (*opt != NULL) { /* put argv[0] back */ char *arg = HX_strdup(*opt++); - if (arg == NULL) - goto out_errno; + if (arg == NULL) { + ret = -errno; + goto out; + } if (HXdeque_push(ps.remaining, arg) == NULL) { free(arg); - goto out_errno; + ret = -errno; + goto out; } } if (posix_me_harder()) ps.flags |= HXOPT_RQ_ORDER; - for (cur = *opt; cur != NULL; ) { if (state == HXOPT_S_TWOLONG) state = HX_getopt_twolong(opt, &ps); @@ -739,11 +747,11 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, if (state < 0) { ret = state; - break; + goto out; } if (state & HXOPT_I_ERROR) { ret = state & ~HXOPT_I_ERROR; - break; + goto out; } if (state & HXOPT_I_ASSIGN) do_assign(&ps.cbi, ps.arg0); @@ -756,12 +764,13 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, state &= ~HXOPT_I_MASK; } - out: - if (ret == HXOPT_ERR_SUCCESS) { + if (!(ps.flags & HXOPT_KEEP_ARGV)) { const char **nvec = reinterpret_cast(const char **, HXdeque_to_vec(ps.remaining, &argk)); - if (nvec == NULL) - goto out_errno; + if (nvec == NULL) { + ret = -errno; + goto out; + } if (ps.flags & HXOPT_DESTROY_OLD) /* * Only the "true, original" argv is stored on the @@ -776,6 +785,14 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, *argv = nvec; if (argc != NULL) *argc = argk; + /* pointers are owned by nvec/argv now */ + HXdeque_free(ps.remaining); + ps.remaining = nullptr; + } + ret = HXOPT_ERR_SUCCESS; + + out: + if (ret == HXOPT_ERR_SUCCESS) { } else if (ret < 0) { if (!(ps.flags & HXOPT_QUIET)) fprintf(stderr, "%s: %s\n", __func__, strerror(errno)); @@ -786,13 +803,9 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, else if (ps.flags & HXOPT_USAGEONERR) HX_getopt_usage(&ps.cbi, stderr); } - - HXdeque_free(ps.remaining); + if (ps.remaining != nullptr) + HXdeque_genocide2(ps.remaining, free); return ret; - - out_errno: - ret = -errno; - goto out; } EXPORT_SYMBOL void HX_getopt_help(const struct HXoptcb *cbi, FILE *nfp) @@ -1011,6 +1024,8 @@ EXPORT_SYMBOL int HX_shconfig_pv(const char **path, const char *file, EXPORT_SYMBOL void HX_shconfig_free(const struct HXoption *table) { + if (table == NULL) + return; for (; table->ln != NULL; ++table) { char **ptr = table->ptr; if (table->type == HXTYPE_STRING && @@ -7,42 +7,118 @@ * General Public License as published by the Free Software Foundation; * either version 2.1 or (at your option) any later version. */ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "internal.h" - -#if !defined(HAVE_FORK) || !defined(HAVE_PIPE) || !defined(HAVE_EXECV) || \ - !defined(HAVE_EXECVP) #include <errno.h> +#include <limits.h> +#include <unistd.h> +#ifdef HAVE_SYS_RESOURCE_H +# include <sys/resource.h> +#endif #include <libHX/proc.h> +#ifdef _WIN32 +# include <winsock2.h> +#endif -struct HXproc; +#if defined(HAVE_INITGROUPS) && defined(HAVE_SETGID) +#include <grp.h> +#include <pwd.h> +#include <stdbool.h> +#include <stdlib.h> +#include <unistd.h> -EXPORT_SYMBOL int HXproc_run_async(const char *const *argv, struct HXproc *p) +static int HXproc_switch_gid(const struct passwd *pw, gid_t gr_gid) { - return -ENOSYS; + bool do_setgid = getgid() != gr_gid || getegid() != gr_gid; + if (do_setgid && setgid(gr_gid) != 0) { + if (errno == 0) + errno = -EINVAL; + return HXPROC_SETGID_FAILED; + } + if (pw == NULL) + return do_setgid ? HXPROC_SU_SUCCESS : HXPROC_SU_NOOP; + + /* pw!=NULL: user switch requested, do initgroups now. */ + + if (geteuid() == pw->pw_uid) { + /* + * Target identity (usually unprivileged) already reached. + * initgroups is unlikely to succeed. + */ + if (initgroups(pw->pw_name, gr_gid) < 0) + /* ignore */; + return do_setgid ? HXPROC_SU_SUCCESS : HXPROC_SU_NOOP; + } + if (initgroups(pw->pw_name, gr_gid) != 0) + return HXPROC_INITGROUPS_FAILED; + return do_setgid ? HXPROC_SU_SUCCESS : HXPROC_SU_NOOP; } -EXPORT_SYMBOL int HXproc_run_sync(const char *const *argv, unsigned int flags) +static int HXproc_switch_group(const struct passwd *pw, const char *group) { - /* Might use system() here... */ - return -ENOSYS; + char *end; + unsigned long gid = strtoul(group, &end, 10); + const struct group *gr = *end == '\0' ? getgrgid(gid) : getgrnam(group); + if (gr == NULL) { + if (errno == 0) + errno = ENOENT; + return HXPROC_GROUP_NOT_FOUND; + } + return HXproc_switch_gid(pw, gr->gr_gid); } -EXPORT_SYMBOL int HXproc_wait(struct HXproc *p) +EXPORT_SYMBOL int HXproc_switch_user(const char *user, const char *group) +{ + const struct passwd *pw = NULL; + if (user != NULL && *user != '\0') { + char *end; + unsigned long uid = strtoul(user, &end, 10); + pw = *end == '\0' ? getpwuid(uid) : getpwnam(user); + if (pw == NULL) { + if (errno == 0) + errno = ENOENT; + return HXPROC_USER_NOT_FOUND; + } + } + int ret = HXPROC_SU_NOOP; + if (group != NULL && *group != '\0') { + ret = HXproc_switch_group(pw, group); + if (ret < 0) + return ret; + } else if (group == NULL && pw != NULL) { + ret = HXproc_switch_gid(pw, pw->pw_gid); + if (ret < 0) + return ret; + } + bool do_setuid = pw != NULL && (getuid() != pw->pw_uid || geteuid() != pw->pw_uid); + if (do_setuid && setuid(pw->pw_uid) != 0) { + if (errno == 0) + errno = -EINVAL; + return HXPROC_SETUID_FAILED; + } + return do_setuid ? HXPROC_SU_SUCCESS : ret; +} + +#else + +EXPORT_SYMBOL int HXproc_switch_user(const char *user, const char *group) { return -ENOSYS; } -#else /* HAVE_FORK, HAVE_PIPE, HAVE_EXECVE */ +#endif /* HAVE_lots */ +#if defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_EXECV) && \ + defined(HAVE_EXECVP) #include <sys/wait.h> #include <fcntl.h> -#include <errno.h> +#include <stdbool.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <libHX/defs.h> -#include <libHX/proc.h> #include "internal.h" #ifdef _WIN32 @@ -88,18 +164,20 @@ HXproc_build_pipes(const struct HXproc *proc, int (*p)[2]) */ static void HXproc_close_pipes(int (*p)[2]) { +#define xc(fd) do { close(fd); (fd) = -1; } while (false) if (p[0][0] >= 0) - close(p[0][0]); + xc(p[0][0]); if (p[0][1] >= 0) - close(p[0][1]); + xc(p[0][1]); if (p[1][0] >= 0) - close(p[1][0]); + xc(p[1][0]); if (p[1][1] >= 0) - close(p[1][1]); + xc(p[1][1]); if (p[2][0] >= 0) - close(p[2][0]); + xc(p[2][0]); if (p[2][1] >= 0) - close(p[2][1]); + xc(p[2][1]); +#undef xc } /** @@ -113,29 +191,27 @@ EXPORT_SYMBOL int HXproc_run_async(const char *const *argv, struct HXproc *proc) { int pipes[3][2], nullfd = -1, ret, saved_errno; - unsigned int t; if (argv == NULL || *argv == NULL) return -EFAULT; - - proc->p_stdin = proc->p_stdout = proc->p_stderr = -1; - - t = (proc->p_flags & (HXPROC_STDIN | HXPROC_NULL_STDIN)) == - (HXPROC_STDIN | HXPROC_NULL_STDIN); - t |= (proc->p_flags & (HXPROC_STDOUT | HXPROC_NULL_STDOUT)) == - (HXPROC_STDOUT | HXPROC_NULL_STDOUT); - t |= (proc->p_flags & (HXPROC_STDERR | HXPROC_NULL_STDERR)) == - (HXPROC_STDERR | HXPROC_NULL_STDERR); - if (t > 0) + if ((proc->p_flags & (HXPROC_STDIN | HXPROC_NULL_STDIN)) == + (HXPROC_STDIN | HXPROC_NULL_STDIN)) + return -EINVAL; + if ((proc->p_flags & (HXPROC_STDOUT | HXPROC_NULL_STDOUT)) == + (HXPROC_STDOUT | HXPROC_NULL_STDOUT)) + return -EINVAL; + if ((proc->p_flags & (HXPROC_STDERR | HXPROC_NULL_STDERR)) == + (HXPROC_STDERR | HXPROC_NULL_STDERR)) return -EINVAL; - if (proc->p_flags & (HXPROC_NULL_STDIN | HXPROC_NULL_STDOUT | HXPROC_NULL_STDERR)) { if ((nullfd = open(NULL_DEVICE, O_RDWR)) < 0) return -errno; } + proc->p_stdin = proc->p_stdout = proc->p_stderr = -1; if ((ret = HXproc_build_pipes(proc, pipes)) <= 0) { saved_errno = errno; + HXproc_close_pipes(pipes); if (nullfd >= 0) close(nullfd); errno = saved_errno; @@ -183,17 +259,17 @@ HXproc_run_async(const char *const *argv, struct HXproc *proc) */ HXproc_close_pipes(pipes); if ((proc->p_flags & (HXPROC_STDIN | HXPROC_NULL_STDIN)) && - proc->p_stdin != STDIN_FILENO) { + proc->p_stdin >= 0 && proc->p_stdin != STDIN_FILENO) { dup2(proc->p_stdin, STDIN_FILENO); close(proc->p_stdin); } if ((proc->p_flags & (HXPROC_STDOUT | HXPROC_NULL_STDOUT)) && - proc->p_stdout != STDOUT_FILENO) { + proc->p_stdout >= 0 && proc->p_stdout != STDOUT_FILENO) { dup2(proc->p_stdout, STDOUT_FILENO); close(proc->p_stdout); } if ((proc->p_flags & (HXPROC_STDERR | HXPROC_NULL_STDERR)) && - proc->p_stderr != STDERR_FILENO) { + proc->p_stderr >= 0 && proc->p_stderr != STDERR_FILENO) { dup2(proc->p_stderr, STDERR_FILENO); close(proc->p_stderr); } @@ -223,7 +299,8 @@ HXproc_run_async(const char *const *argv, struct HXproc *proc) close(pipes[2][1]); proc->p_stderr = pipes[2][0]; } - + if (nullfd >= 0) + close(nullfd); return 1; } @@ -266,4 +343,41 @@ EXPORT_SYMBOL int HXproc_wait(struct HXproc *proc) return static_cast(unsigned char, proc->p_status); } +#else + +EXPORT_SYMBOL int HXproc_run_async(const char *const *argv, struct HXproc *p) +{ + return -ENOSYS; +} + +EXPORT_SYMBOL int HXproc_run_sync(const char *const *argv, unsigned int flags) +{ + /* Might use system() here... */ + return -ENOSYS; +} + +EXPORT_SYMBOL int HXproc_wait(struct HXproc *p) +{ + return -ENOSYS; +} + #endif /* HAVE_lots */ + +EXPORT_SYMBOL int HXproc_top_fd(void) +{ +#ifndef _WIN32 + struct rlimit r; + if (getrlimit(RLIMIT_NOFILE, &r) == 0) { + if (r.rlim_max > INT_MAX) + r.rlim_max = INT_MAX; + return r.rlim_max; + } + long v = sysconf(_SC_OPEN_MAX); + if (v >= 0) { + if (v > INT_MAX) + v = INT_MAX; + return v; + } +#endif + return FD_SETSIZE; +} diff --git a/src/socket.c b/src/socket.c new file mode 100644 index 0000000..ced884a --- /dev/null +++ b/src/socket.c @@ -0,0 +1,305 @@ +/* + * Socket-related functions + * Copyright Jan Engelhardt, 2021 + * + * This file is part of libHX. libHX is free software; you can + * redistribute it and/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. + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include <errno.h> +#include <limits.h> +#include <stdlib.h> +#include <string.h> +#ifdef _WIN32 +# include <ws2tcpip.h> +#else +# include <netdb.h> +# include <unistd.h> +# include <netinet/in.h> +# include <sys/socket.h> +#endif +#ifdef HAVE_SYS_UN_H +# include <sys/un.h> +#endif +#ifdef __linux__ +# include <linux/rtnetlink.h> +#endif +#ifdef __OpenBSD__ +# include <net/route.h> +#endif +#include <libHX/proc.h> +#include <libHX/socket.h> +#include "internal.h" +#ifdef _WIN32 +# define STUPIDWIN(x) reinterpret_cast(char *, (x)) +#else +# define STUPIDWIN(x) (x) +#endif +#if defined(__sunos__) && !defined(SO_PROTOCOL) +# define SO_PROTOCOL SO_PROTOTYPE +#endif +#ifndef AI_V4MAPPED +# define AI_V4MAPPED 0 +#endif + +static int try_sk_from_env(int fd, const struct addrinfo *ai, const char *intf) +{ + int value = 0; + socklen_t optlen = sizeof(value); + int ret = getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, STUPIDWIN(&value), &optlen); + if (ret < 0 && errno != ENOPROTOOPT) + /* + * E.g. OpenBSD's getsockopt does not recognize this - even + * though the flag with the same name exists and is known. + */ + return -1; + if (ret == 0 && value == 0) + return -1; +#ifdef _WIN32 + WSAPROTOCOL_INFO protinfo; + optlen = sizeof(protinfo); + ret = getsockopt(fd, SOL_SOCKET, SO_PROTOCOL_INFO, STUPIDWIN(&protinfo), &optlen); + if (ret < 0 || protinfo.iAddressFamily != ai->ai_family || + protinfo.iSocketType != ai->ai_socktype || + protinfo.iProtocol != ai->ai_protocol) + return -1; +#else + optlen = sizeof(value); + ret = getsockopt(fd, SOL_SOCKET, SO_DOMAIN, &value, &optlen); + if (ret < 0 || value != ai->ai_family) + return -1; + optlen = sizeof(value); + ret = getsockopt(fd, SOL_SOCKET, SO_TYPE, &value, &optlen); + if (ret < 0 || value != ai->ai_socktype) + return -1; + optlen = sizeof(value); + ret = getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &value, &optlen); + if (ret < 0 || value != ai->ai_protocol) + return -1; +#endif + struct sockaddr_storage addr; + memset(&addr, 0, sizeof(addr)); + optlen = sizeof(addr); + ret = getsockname(fd, (struct sockaddr *)&addr, &optlen); + if (ret < 0) + return -1; + if (sizeof(addr) < optlen) + optlen = sizeof(addr); + if (optlen != ai->ai_addrlen || memcmp(&addr, ai->ai_addr, optlen) != 0) + return -1; + if (intf == nullptr) + return fd; +#ifdef SO_BINDTODEVICE + char ifname[32]; + optlen = sizeof(ifname); + ret = getsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, ifname, &optlen); + if (ret < 0) + return -1; + else if (optlen < sizeof(ifname)) + ifname[optlen] = '\0'; + else + ifname[sizeof(ifname)-1] = '\0'; + if (strcmp(intf, ifname) != 0) + return -1; +#endif + return fd; +} + +EXPORT_SYMBOL int HX_socket_from_env(const struct addrinfo *ai, const char *intf) +{ + int top_fd; + const char *env_limit = getenv("LISTEN_FDS"); + if (env_limit != nullptr) { + long x = strtol(env_limit, nullptr, 0); + if (x > INT_MAX - 3) + x = INT_MAX - 3; + top_fd = 3 + x; + } else { + env_limit = getenv("HX_LISTEN_TOP_FD"); + long x; + if (env_limit != nullptr) { + x = strtol(env_limit, nullptr, 0); + if (x > INT_MAX) + x = INT_MAX; + } else { + x = HXproc_top_fd(); + } + top_fd = x; + } + for (int fd = 3; fd < top_fd; ++fd) + if (try_sk_from_env(fd, ai, intf) == fd) + return fd; + errno = ENOENT; + return -1; +} + +#ifdef __linux__ +static int linux_sockaddr_local3(int sk, const void *buf, size_t bufsize) +{ + if (send(sk, buf, bufsize, 0) < 0) + return -errno; + char rsp[4096]; + ssize_t ret = recv(sk, rsp, sizeof(rsp), 0); + if (ret < 0) + return -errno; + else if (static_cast(size_t, ret) < sizeof(struct nlmsghdr)) + return -EIO; + struct nlmsghdr nlh; + memcpy(&nlh, rsp, sizeof(nlh)); + if (!NLMSG_OK(&nlh, ret)) + return -EIO; + const struct rtmsg *rtm = static_cast(void *, rsp + NLMSG_HDRLEN); + return rtm->rtm_type == RTN_LOCAL; +} + +static int linux_sockaddr_local2(const struct sockaddr *sa, socklen_t sl) +{ + int sk = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); + if (sk < 0) + return -errno; + struct { + struct nlmsghdr nh; + struct rtmsg rth; + char attrbuf[4096]; + } req; + memset(&req, 0, sizeof(req)); + req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.rth)); + req.nh.nlmsg_flags = NLM_F_REQUEST; + req.nh.nlmsg_type = RTM_GETROUTE; + req.rth.rtm_family = sa->sa_family; + req.rth.rtm_protocol = RTPROT_UNSPEC; + req.rth.rtm_type = RTN_UNSPEC; + req.rth.rtm_scope = RT_SCOPE_UNIVERSE; + req.rth.rtm_table = RT_TABLE_UNSPEC; + struct rtattr *rta = reinterpret_cast(struct rtattr *, + reinterpret_cast(char *, &req) + NLMSG_ALIGN(req.nh.nlmsg_len)); + rta->rta_type = RTA_DST; + + int ret = -ENODATA; + if (sa->sa_family == AF_INET6) { + const struct in6_addr *ad = &reinterpret_cast(const struct sockaddr_in6 *, sa)->sin6_addr; + req.rth.rtm_dst_len = 16; + rta->rta_len = RTA_LENGTH(16); + req.nh.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + rta->rta_len; + memcpy(RTA_DATA(rta), ad, 16); + } else if (sa->sa_family == AF_INET) { + struct in_addr ad = reinterpret_cast(const struct sockaddr_in *, sa)->sin_addr; + req.rth.rtm_dst_len = 4; + rta->rta_len = RTA_LENGTH(4); + req.nh.nlmsg_len = NLMSG_ALIGN(req.nh.nlmsg_len) + rta->rta_len; + memcpy(RTA_DATA(rta), &ad, 4); + } + ret = linux_sockaddr_local3(sk, &req, req.nh.nlmsg_len); + close(sk); + return ret; +} +#endif + +#ifdef __OpenBSD__ +static int openbsd_sockaddr_local3(int rsk, const void *buf, size_t bufsize) +{ + ssize_t ret = send(rsk, buf, bufsize, 0); + if (ret < 0) + return -errno; + else if (ret != bufsize) + return -EIO; + struct rt_msghdr rsp; + do { + ret = recv(rsk, &rsp, sizeof(rsp), 0); + } while (ret > 0 && (rsp.rtm_version != RTM_VERSION || + rsp.rtm_seq != 1 || rsp.rtm_pid != getpid())); + return rsp.rtm_flags & RTF_LOCAL; +} + +static int openbsd_sockaddr_local2(const struct sockaddr *sa, socklen_t sl) +{ + int sk = socket(AF_ROUTE, SOCK_RAW, AF_UNSPEC); + if (sk < 0) + return -errno; + struct { + struct rt_msghdr rtm; + char ab[512]; + } req; + memset(&req, 0, sizeof(req)); + req.rtm.rtm_type = RTM_GET; + req.rtm.rtm_version = RTM_VERSION; + req.rtm.rtm_flags = RTF_STATIC | RTF_UP | RTF_HOST | RTF_GATEWAY; + req.rtm.rtm_seq = 1; + req.rtm.rtm_addrs = /*RTA_IFP |*/ RTA_DST; + req.rtm.rtm_tableid = getrtable(); + req.rtm.rtm_hdrlen = sizeof(req.rtm); + memcpy(req.ab, sa, sl); + req.rtm.rtm_msglen = sizeof(req.rtm) + sl; + int ret = openbsd_sockaddr_local3(sk, &req, req.rtm.rtm_msglen); + close(sk); + return ret; +} +#endif + +EXPORT_SYMBOL int HX_sockaddr_is_local(const struct sockaddr *sa, socklen_t sl, + unsigned int flags) +{ + struct sockaddr_in xl = {}; + + if (sa->sa_family == AF_INET6) { + if (sl < sizeof(struct sockaddr_in6)) + return -EINVAL; + } else if (sa->sa_family == AF_INET) { + if (sl < sizeof(struct sockaddr_in)) + return -EINVAL; + } +#ifdef HAVE_SYS_UN_H + else if (sa->sa_family == AF_UNIX) { + if (sl < sizeof(struct sockaddr_un)) + return 1; + } +#endif + else { + return -EPROTONOSUPPORT; + } + if (flags & AI_V4MAPPED && sa->sa_family == AF_INET6) { + /* + * Preprocess mapped addresses, becuase kernel interfaces do + * not support them. + */ + const struct in6_addr *ad = &reinterpret_cast(const struct sockaddr_in6 *, sa)->sin6_addr; + static const uint8_t mappedv4[] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff}; + if (memcmp(ad, mappedv4, 12) == 0) { + xl.sin_family = AF_INET; + memcpy(&xl.sin_addr, &ad->s6_addr[12], 4); + sa = reinterpret_cast(struct sockaddr *, &xl); + sl = sizeof(xl); + } + } +#if defined(__linux__) + return linux_sockaddr_local2(sa, sl); +#elif defined(__OpenBSD__) + return openbsd_sockaddr_local2(sa, sl); +#else + if (sa->sa_family == AF_INET) { + struct in_addr a = reinterpret_cast(const struct sockaddr_in *, sa)->sin_addr; + return ntohl(a.s_addr) >> 24 == 127; + } else if (sa->sa_family == AF_INET6) { + return IN6_IS_ADDR_LOOPBACK(&reinterpret_cast(const struct sockaddr_in6 *, sa)->sin6_addr); + } +#endif + return -EPROTONOSUPPORT; +} + +EXPORT_SYMBOL int HX_ipaddr_is_local(const char *addr, unsigned int flags) +{ + struct addrinfo hints = {.ai_flags = flags & AI_V4MAPPED}; + struct addrinfo *r = nullptr; + int err = getaddrinfo(addr, nullptr, &hints, &r); + if (err != 0) { + freeaddrinfo(r); + return 0; + } + int lcl = HX_sockaddr_is_local(r->ai_addr, r->ai_addrlen, hints.ai_flags); + freeaddrinfo(r); + return lcl; +} diff --git a/src/string.c b/src/string.c index 354a409..ae19271 100644 --- a/src/string.c +++ b/src/string.c @@ -8,6 +8,8 @@ * either version 2.1 or (at your option) any later version. */ #include <errno.h> +#include <limits.h> +#include <math.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> @@ -25,6 +27,7 @@ * all others pass through */ enum HX_quote_selector { + HXQUOTE_ALWAYS, HXQUOTE_ACCEPT, HXQUOTE_REJECT, }; @@ -40,11 +43,6 @@ struct HX_quote_rule { static const char HX_hexenc[16] = "0123456789ABCDEF"; -static __inline__ unsigned int min_uint(unsigned int a, unsigned int b) -{ - return (a < b) ? a : b; -} - EXPORT_SYMBOL char *HX_basename(const char *s) { const char *p; @@ -214,6 +212,8 @@ EXPORT_SYMBOL char **HX_split(const char *str, const char *delim, *cp = max; ret = malloc(sizeof(char *) * (*cp + 1)); + if (ret == nullptr) + return nullptr; ret[*cp] = NULL; { @@ -381,20 +381,48 @@ EXPORT_SYMBOL char *HX_stpltrim(const char *p) return const_cast1(char *, p); } +/** + * Helper for substr() function for dealing with negative off/len values + * @z: total length of string + * @offset: n>=0 specifies offset from the start, + * n<0 specifies offset from the end + * @len: "length"; n>=0 specifies length to copy (from @offset), + * n<0 specifies the byte relative to the end at which to stop + * + * @abstart: (result) absolute start + * @retval: (result) absolute length to copy (from *@abstart) + */ +size_t HX_substr_helper(size_t z, long offset, long len, size_t *start) +{ + if (offset >= 0) + *start = offset; + else if (offset == LONG_MIN) + *start = z + -static_cast(size_t, LONG_MIN); + else + *start = z >= static_cast(unsigned long, -offset) ? z + offset : z; + + size_t end; + if (len >= 0) + end = *start < SIZE_MAX - len ? *start + len : SIZE_MAX; + else if (len == LONG_MIN) + end = z + -static_cast(unsigned long, LONG_MIN); + else + end = z >= static_cast(unsigned long, -len) ? z + len : 0; + if (end > z) + end = z; + return end > *start ? end - *start : 0; +} + /* supports negative offsets like scripting languages */ EXPORT_SYMBOL char *HX_strmid(const char *expr, long offset, long length) { - char *buffer; - - if (offset < 0) - offset = strlen(expr) + offset; - if (length < 0) - length = strlen(expr) - offset + length; - if ((buffer = malloc(length + 1)) == NULL) + size_t start = 0, tocopy = HX_substr_helper(strlen(expr), offset, length, &start); + char *buffer = malloc(tocopy + 1); + if (buffer == nullptr) return NULL; - - expr += offset; - return HX_strlcpy(buffer, expr, length + 1); + memcpy(buffer, &expr[start], tocopy); + buffer[tocopy] = '\0'; + return buffer; } EXPORT_SYMBOL char *HX_strndup(const char *src, size_t size) @@ -605,14 +633,16 @@ HX_quote_sqlbackslash(char *dest, const char *src, const char *trm) * Encode @src into BASE-64 according to RFC 4648 and write result to @dest, * which must be of appropriate size, plus one for a trailing NUL. */ -static char *HX_quote_base64(char *d, const char *s) +static char *HX_quote_base64(char *d, const char *s, char x1, char x2) { - static const char a[] = + char a[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz0123456789+/"; + "abcdefghijklmnopqrstuvwxyz0123456789??"; size_t len = strlen(s); char *ret = d; + a[62] = x1; + a[63] = x2; while (len > 0) { if (len >= 3) { len -= 3; @@ -761,6 +791,8 @@ static size_t HX_quoted_size(const char *s, unsigned int type) case HXQUOTE_LDAPRDN: return HX_qsize_bsr(s, HX_quote_rules[type].chars, 2); case HXQUOTE_BASE64: + case HXQUOTE_BASE64URL: + case HXQUOTE_BASE64IMAP: return (strlen(s) + 2) / 3 * 4; case HXQUOTE_URIENC: return HX_qsize_bsa(s, HX_quote_rules[type].chars, 2); @@ -772,7 +804,7 @@ static size_t HX_quoted_size(const char *s, unsigned int type) EXPORT_SYMBOL char *HX_strquote(const char *src, unsigned int type, char **free_me) { - const struct HX_quote_rule *rule; + const struct HX_quote_rule *rule = nullptr; bool do_quote; char *tmp; @@ -781,15 +813,19 @@ EXPORT_SYMBOL char *HX_strquote(const char *src, unsigned int type, return NULL; } /* If quote_chars is NULL, it is clear all chars are to be encoded. */ - rule = &HX_quote_rules[type]; - if (type >= ARRAY_SIZE(HX_quote_rules) || rule->chars == NULL) + if (type >= ARRAY_SIZE(HX_quote_rules)) { do_quote = true; - else if (rule->selector == HXQUOTE_REJECT) - do_quote = strpbrk(src, rule->chars) != NULL; - else if (rule->selector == HXQUOTE_ACCEPT) - do_quote = HX_strchr2(src, rule->chars) != NULL; - else - do_quote = false; + } else { + rule = &HX_quote_rules[type]; + if (rule->selector == HXQUOTE_ALWAYS) + do_quote = true; + else if (rule->selector == HXQUOTE_REJECT) + do_quote = strpbrk(src, rule->chars) != NULL; + else if (rule->selector == HXQUOTE_ACCEPT) + do_quote = HX_strchr2(src, rule->chars) != NULL; + else + do_quote = false; + } /* * free_me == NULL implies that we always allocate, even if * there is nothing to quote. @@ -819,7 +855,11 @@ EXPORT_SYMBOL char *HX_strquote(const char *src, unsigned int type, case HXQUOTE_LDAPRDN: return HX_quote_ldap(*free_me, src, rule->chars); case HXQUOTE_BASE64: - return HX_quote_base64(*free_me, src); + return HX_quote_base64(*free_me, src, '+', '/'); + case HXQUOTE_BASE64URL: + return HX_quote_base64(*free_me, src, '-', '_'); + case HXQUOTE_BASE64IMAP: + return HX_quote_base64(*free_me, src, '+', ','); case HXQUOTE_URIENC: return HX_quote_urlenc(*free_me, src); case HXQUOTE_SQLSQUOTE: @@ -836,3 +876,289 @@ EXPORT_SYMBOL char *HX_strupper(char *orig) *expr = HX_toupper(*expr); return orig; } + +EXPORT_SYMBOL char *HX_unit_size(char *buf, size_t bufsize, + unsigned long long size, unsigned int divisor, unsigned int cutoff) +{ + static const char unit_names[] = "\0kMGTPEZYRQ"; + unsigned int unit_idx = 0; + if (divisor == 0) + divisor = 1000; + if (cutoff == 0) { + cutoff = 10000; + if (cutoff < divisor) + cutoff = divisor; + } + while (unit_idx < ARRAY_SIZE(unit_names) - 1 && size >= cutoff) { + ++unit_idx; + size /= divisor; + } + snprintf(buf, bufsize, "%llu%.1s", size, &unit_names[unit_idx]); + return buf; +} + +static inline unsigned long long p_90(unsigned long long x) +{ + /* Perform x*9/10, but without the risk of overflow. */ + return x - x / 10 - !!(x % 10); +} + +EXPORT_SYMBOL char *HX_unit_size_cu(char *buf, size_t bufsize, + unsigned long long orig_size, unsigned int divisor) +{ + /* No floating point. Take that, coreutils! */ + static const char unit_names[] = "\0kMGTPEZYRQ"; + unsigned int unit_idx = 0, last_rem = 0; + unsigned long long size = orig_size, gpow = 1, grand_rem; + if (divisor == 0) + divisor = 1000; + + while (unit_idx < ARRAY_SIZE(unit_names) - 1 && size >= divisor) { + ++unit_idx; + last_rem = size % divisor; + size /= divisor; + gpow *= divisor; + } + if (unit_idx == 0) { + snprintf(buf, bufsize, "%llu%.1s", size, &unit_names[unit_idx]); + return buf; + } + grand_rem = orig_size - size * gpow; + if (grand_rem != 0) { + if (grand_rem > p_90(gpow)) { + ++size; + last_rem = 0; + } else { + last_rem *= 10; + last_rem /= divisor; + ++last_rem; + if (last_rem == 10 || (size >= 10 && last_rem > 0)) { + ++size; + last_rem = 0; + } + } + if (unit_idx < ARRAY_SIZE(unit_names) - 1 && size == divisor) { + /* ++size from above may brought size to @divisor again */ + ++unit_idx; + size /= divisor; + } + } + if (size >= 10 && last_rem == 0) + snprintf(buf, bufsize, "%llu%.1s", size, &unit_names[unit_idx]); + else + snprintf(buf, bufsize, "%llu.%01u%.1s", size, last_rem, &unit_names[unit_idx]); + return buf; +} + +static unsigned int suffix_power(char u) +{ + switch (HX_toupper(u)) { + case 'K': return 1; + case 'M': return 2; + case 'G': return 3; + case 'T': return 4; + case 'P': return 5; + case 'E': return 6; + case 'Z': return 7; + case 'Y': return 8; + case 'R': return 9; + case 'Q': return 10; + default: return 0; + } +} + +EXPORT_SYMBOL double HX_strtod_unit(const char *s, char **out_end, unsigned int exponent) +{ + char *end; + double q; + + while (HX_isspace(*s)) + ++s; + q = strtod(s, &end); + if (exponent == 0) + exponent = 1000; + if (end == s) { + if (out_end != nullptr) + *out_end = end; + return q; + } + while (HX_isspace(*end)) + ++end; + unsigned int pwr = suffix_power(*end); + if (pwr == 0) { + if (out_end != nullptr) + *out_end = const_cast(char *, end); + return q; + } + if (out_end != nullptr) + *out_end = const_cast(char *, end + 1); + return q * pow(exponent, pwr); +} + +EXPORT_SYMBOL unsigned long long HX_strtoull_unit(const char *s, + char **out_end, unsigned int exponent) +{ + char *end; + unsigned long long ipart; + unsigned int pwr = 0; + + while (HX_isspace(*s)) + ++s; + ipart = strtoull(s, &end, 10); + if (*end == '.') { + double q = HX_strtod_unit(s, out_end, exponent); + bool lo_ok = q >= nextafter(-static_cast(double, ULLONG_MAX), 0); + bool hi_ok = q <= nextafter(static_cast(double, ULLONG_MAX), 0); + if (!hi_ok || !lo_ok) + return ULLONG_MAX; + return q; + } + if (exponent == 0) + exponent = 1000; + while (HX_isspace(*end)) + ++end; + pwr = suffix_power(*end); + if (pwr == 0) { + if (out_end != nullptr) + *out_end = end; + return ipart; + } + if (out_end != nullptr) + *out_end = const_cast(char *, end + 1); + while (pwr-- > 0) { + if (ipart >= ULLONG_MAX / exponent) { + errno = ERANGE; + return ULLONG_MAX; + } + ipart *= exponent; + } + return ipart; +} + +#define SECONDS_PER_YEAR 31557600 +#define SECONDS_PER_MONTH 2629800 + +static const struct { + const char name[8]; + unsigned int len; + uint32_t mult; +} time_multiplier[] = { + {"seconds", 7, 1}, + {"second", 6, 1}, + {"sec", 3, 1}, + {"s", 1, 1}, + {"minutes", 7, 60}, + {"minute", 6, 60}, + {"min", 3, 60}, + {"hours", 5, 3600}, + {"hour", 4, 3600}, + {"h", 1, 3600}, + {"days", 4, 86400}, + {"day", 3, 86400}, + {"d", 1, 86400}, + {"weeks", 5, 604800}, + {"week", 4, 604800}, + {"months", 6, SECONDS_PER_MONTH}, + {"month", 5, SECONDS_PER_MONTH}, + {"years", 5, SECONDS_PER_YEAR}, + {"year", 4, SECONDS_PER_YEAR}, + {"y", 1, SECONDS_PER_YEAR}, +}; + +EXPORT_SYMBOL unsigned long long HX_strtoull_sec(const char *s, char **out_end) +{ + unsigned long long seconds = 0; + + while (*s != '\0') { + while (HX_isspace(*s)) + ++s; + if (*s == '-') { + break; + } + char *end = nullptr; + unsigned long long num = strtoull(s, &end, 10); + if (end == s) + break; + s = end; + while (HX_isspace(*s)) + ++s; + if (!HX_isalpha(*s)) { + seconds += num; + continue; + } + unsigned int i; + for (i = 0; i < ARRAY_SIZE(time_multiplier); ++i) + if (strncmp(s, time_multiplier[i].name, + time_multiplier[i].len) == 0 && + !HX_isalpha(s[time_multiplier[i].len])) + break; + if (i == ARRAY_SIZE(time_multiplier)) + break; + seconds += num * time_multiplier[i].mult; + s += time_multiplier[i].len; + } + if (out_end != nullptr) + *out_end = const_cast(char *, s); + return seconds; +} + +EXPORT_SYMBOL char *HX_unit_seconds(char *out, size_t outsize, + unsigned long long secs, unsigned int flags) +{ + unsigned long years = 0, months = 0, weeks = 0, days, hours, mins; + char buf[HXSIZEOF_Z64+4]; + if (flags & HXUNIT_YEARS) { + years = secs / SECONDS_PER_YEAR; + secs %= SECONDS_PER_YEAR; + } + if (flags & HXUNIT_MONTHS) { + months = secs / SECONDS_PER_MONTH; + secs %= SECONDS_PER_MONTH; + } + if (flags & HXUNIT_WEEKS) { + weeks = secs / 604800; + secs %= 604800; + } + days = secs / 86400; + secs %= 86400; + hours = secs / 3600; + secs %= 3600; + mins = secs / 60; + secs %= 60; + *out = '\0'; + if (years > 0) { + snprintf(buf, ARRAY_SIZE(buf), "%luy", years); + HX_strlcat(out, buf, outsize); + } + if (months == 1) { + HX_strlcat(out, "1month", outsize); + } else if (months > 0) { + snprintf(buf, ARRAY_SIZE(buf), "%lumonths", months); + HX_strlcat(out, buf, outsize); + } + if (weeks == 1) { + HX_strlcat(out, "1week", outsize); + } else if (weeks > 0) { + snprintf(buf, ARRAY_SIZE(buf), "%luweeks", weeks); + HX_strlcat(out, buf, outsize); + } + if (days > 0) { + snprintf(buf, ARRAY_SIZE(buf), "%lud", days); + HX_strlcat(out, buf, outsize); + } + if (hours > 0) { + snprintf(buf, ARRAY_SIZE(buf), "%luh", hours); + HX_strlcat(out, buf, outsize); + } + if (mins > 0) { + snprintf(buf, ARRAY_SIZE(buf), "%lumin", mins); + HX_strlcat(out, buf, outsize); + } + if (secs > 0 || + (years == 0 && months == 0 && weeks == 0 && + days == 0 && hours == 0 && mins == 0)) { + snprintf(buf, ARRAY_SIZE(buf), "%llus", secs); + HX_strlcat(out, buf, outsize); + } + return out; +} diff --git a/src/tc-cast.c b/src/tc-cast.c index 422054c..2c58805 100644 --- a/src/tc-cast.c +++ b/src/tc-cast.c @@ -1,11 +1,4 @@ -/* - * Testing for compile error in the cast helpers - * written by Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #include <math.h> #include <stdint.h> #include <stdio.h> diff --git a/src/tc-compile.c b/src/tc-compile.c index 657f4f7..d2b0d09 100644 --- a/src/tc-compile.c +++ b/src/tc-compile.c @@ -10,11 +10,11 @@ int main(void) { - unsigned long long bmllong[HXbitmap_size(unsigned long long, 256)]; - unsigned long bmlong[HXbitmap_size(unsigned long, 256)]; - unsigned int bmint[HXbitmap_size(unsigned int, 256)]; - unsigned short bmshort[HXbitmap_size(unsigned short, 256)]; - unsigned char bmchar[HXbitmap_size(unsigned char, 256)]; + unsigned long long bmllong[HXbitmap_size(unsigned long long, 256)] = {0}; + unsigned long bmlong[HXbitmap_size(unsigned long, 256)] = {0}; + unsigned int bmint[HXbitmap_size(unsigned int, 256)] = {0}; + unsigned short bmshort[HXbitmap_size(unsigned short, 256)] = {0}; + unsigned char bmchar[HXbitmap_size(unsigned char, 256)] = {0}; if (HX_init() <= 0) abort(); diff --git a/src/tc-dir.c b/src/tc-dir.c index d2e3885..12cbacd 100644 --- a/src/tc-dir.c +++ b/src/tc-dir.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #ifndef __cplusplus # include <stdio.h> # include <stdlib.h> diff --git a/src/tc-format.c b/src/tc-format.c index ad067ee..ed8e6d4 100644 --- a/src/tc-format.c +++ b/src/tc-format.c @@ -1,11 +1,4 @@ -/* - * formatter test program - * Copyright by Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -55,7 +48,7 @@ static const char *const fmt2_strings[] = { NULL, }; -static void t_format(int argc) +static int t_format(int argc) { struct HXformat_map *fmt = HXformat_init(); const char *const *s; @@ -70,9 +63,14 @@ static void t_format(int argc) HXformat_add(fmt, "TWOARG", "a, b", HXTYPE_STRING | HXFORMAT_IMMED); ++argc; printf("# HXformat2\n"); - for (s = fmt2_strings; *s != NULL; ++s) - HXformat_fprintf(fmt, stdout, *s); + for (s = fmt2_strings; *s != NULL; ++s) { + char buf[80]; + if (HXformat_sprintf(fmt, buf, ARRAY_SIZE(buf), *s) < 0 || + HXformat_fprintf(fmt, stdout, *s) < 0) + return EXIT_FAILURE; + } HXformat_free(fmt); + return EXIT_SUCCESS; } int main(int argc, const char **argv) @@ -84,7 +82,7 @@ int main(int argc, const char **argv) fprintf(stderr, "HX_init: %s\n", strerror(-ret)); return EXIT_FAILURE; } - t_format(argc); + ret = t_format(argc); HX_exit(); - return EXIT_SUCCESS; + return ret; } diff --git a/src/tc-io.c b/src/tc-io.c new file mode 100644 index 0000000..639ebcc --- /dev/null +++ b/src/tc-io.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: MIT +#include <errno.h> +#include <fcntl.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <libHX/io.h> +#include "internal.h" + +static void sf(void) +{ + int src = open("tc-io.c", O_RDONLY); + if (src < 0) + return; + int dst = open("/dev/null", O_WRONLY); + if (dst < 0) { + close(src); + return; + } + ssize_t ret = HX_sendfile(dst, src, SIZE_MAX); + printf("sendfile transferred %zd bytes\n", ret); + close(dst); + close(src); +} + +int main(void) +{ + size_t z; + char *s = HX_slurp_file("tc-io.c", &z); + if (s == nullptr) { + fprintf(stderr, "HX_slurp_file: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + printf("%s\n", s); + printf("Dumped %zu bytes\n", z); + free(s); + s = HX_slurp_file("/proc/version", &z); + if (s == nullptr) { + fprintf(stderr, "HX_slurp_file: %s\n", strerror(errno)); + return EXIT_FAILURE; + } + printf(">%s<\n", s); + free(s); + + sf(); + int ret = HX_copy_file("tc-io.c", "tciocopy.txt", 0); + if (ret <= 0) { + fprintf(stderr, "HX_copy_file: %s\n", strerror(errno)); + } else { + fprintf(stderr, "copy_file ok\n"); + unlink("tciocopy.txt"); + } + return 0; +} diff --git a/src/tc-link.c b/src/tc-link.c deleted file mode 100644 index f20bfd7..0000000 --- a/src/tc-link.c +++ /dev/null @@ -1,156 +0,0 @@ -#include <stdlib.h> -#include <libHX.h> -#include "internal.h" - -static void *funcs[] = { - HXdeque_init, - HXdeque_push, - HXdeque_pop, - HXdeque_unshift, - HXdeque_shift, - HXdeque_move, - HXdeque_del, - HXdeque_free, - HXdeque_find, - HXdeque_get, - HXdeque_genocide2, - HXdeque_to_vec, - HX_dlopen, - HX_dlsym, - HX_dlclose, - HX_dlerror, - HXformat_init, - HXformat_free, - HXformat_add, - HXformat_aprintf, - HXformat_fprintf, - HXformat_sprintf, - HXdir_open, - HXdir_read, - HXdir_close, - HX_copy_file, - HX_copy_dir, - HX_mkdir, - HX_readlink, - HX_realpath, - HX_rrmdir, - HXio_fullread, - HXio_fullwrite, - HXmap_free, - HXhash_jlookup3, - HXhash_jlookup3s, - HXhash_djb2, - HXmap_init5, - HXmap_init, - HXmap_find, - HXmap_get, - HXmap_add, - HXmap_del, - HXmap_keysvalues, - HXmap_travinit, - HXmap_traverse, - HXmap_travfree, - HXmap_qfe, - HXmc_strinit, - HXmc_meminit, - HXmc_strcpy, - HXmc_memcpy, - HXmc_length, - HXmc_setlen, - HXmc_trunc, - HXmc_strcat, - HXmc_memcat, - HXmc_strpcat, - HXmc_mempcat, - HXmc_strins, - HXmc_memins, - HXmc_memdel, - HXmc_free, - HXmc_zvecfree, - HX_ffs, - HX_fls, - HX_hexdump, - HX_zvecfree, - HX_getopt, - HX_getopt_help, - HX_getopt_help_cb, - HX_getopt_usage, - HX_getopt_usage_cb, - HX_shconfig, - HX_shconfig_map, - HX_shconfig_pv, - HX_shconfig_free, - HXproc_run_async, - HXproc_run_sync, - HXproc_wait, - HX_init, - HX_exit, - HX_rand, - HX_drand, - HX_irand, - HX_basename, - HX_basename_exact, - HX_chomp, - HX_dirname, - HX_getl, - HX_memmem, - HX_split, - HX_split_fixed, - HX_split_inplace, - HX_stpltrim, - HX_strbchr, - HX_strchr2, - HX_strclone, - HX_strdup, - HX_strlcat, - HX_strlcpy, - HX_strlncat, - HX_strlower, - HX_strltrim, - HX_strmid, - HX_strndup, - HX_strnlen, - HX_strrcspn, - HX_strrev, - HX_strrtrim, - HX_strsep, - HX_strsep2, - HX_strquote, - HX_strupper, - HX_time_compare, -#ifdef HAVE_STRUCT_TIMESPEC_TV_NSEC - HX_timespec_add, - HX_timespec_isneg, - HX_timespec_mul, - HX_timespec_mulf, - HX_timespec_neg, - HX_timespec_sub, -#endif -#ifdef HAVE_STRUCT_TIMEVAL_TV_USEC - HX_timeval_sub, -#endif -#ifdef _WIN32 - chown, - fchmod, - fchown, - lchown, - lstat, - mkfifo, - mknod, - readlink, - symlink, - mmap, - munmap, -#endif -}; - -int main(void) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(funcs); ++i) - printf("%p ", funcs[i]); - printf("\n"); - printf("There are %" HX_SIZET_FMT "u exported functions\n", ARRAY_SIZE(funcs)); - return EXIT_SUCCESS; -} diff --git a/src/tc-list.c b/src/tc-list.c index c30f5aa..e0087e3 100644 --- a/src/tc-list.c +++ b/src/tc-list.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #ifdef __cplusplus # include <cstdio> # include <cstdlib> @@ -39,6 +33,8 @@ static void l_init(unsigned int max, bool unshift) obj = new struct text_object; #else obj = malloc(sizeof(*obj)); + if (obj == NULL) + abort(); #endif HXlist_init(&obj->list); obj->id[0] = HX_irand('a', 'z'+1); @@ -111,6 +107,8 @@ static void l_empty(void) static void l_shift(void) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" /* Check for -Wshadow warnings */ struct object { int value; @@ -130,6 +128,7 @@ static void l_shift(void) HXclist_push(&clh, &q.anchor); x = p = HXclist_pop(&clh, struct object, anchor); printf("%d\n", p->value); +#pragma GCC diagnostic pop } int main(int argc, const char **argv) diff --git a/src/tc-list2.c b/src/tc-list2.c index f41861b..d70ada2 100644 --- a/src/tc-list2.c +++ b/src/tc-list2.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #include <stdio.h> #include <stdlib.h> #include <libHX/list.h> diff --git a/src/tc-map.c b/src/tc-map.c index 8a22259..0037c83 100644 --- a/src/tc-map.c +++ b/src/tc-map.c @@ -1,11 +1,4 @@ -/* - * Test for libHX's maps - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #include "config.h" #include <errno.h> #include <math.h> @@ -25,6 +18,7 @@ #include <sys/time.h> #include "internal.h" #include "map_int.h" +#pragma GCC diagnostic ignored "-Wunused-const-variable" union HXpoly { struct HXmap *map; @@ -60,12 +54,14 @@ static void tmap_printf(const char *fmt, ...) va_end(args); } -static void tmap_time(struct timeval *tv) +static void tmap_time(struct timespec *tv) { #ifdef HAVE_SYS_RESOURCE_H struct rusage r; - if (getrusage(RUSAGE_SELF, &r) == 0) - *tv = r.ru_utime; + if (getrusage(RUSAGE_SELF, &r) == 0) { + tv->tv_sec = r.ru_utime.tv_sec; + tv->tv_nsec = r.ru_utime.tv_usec * 1000; + } #else memset(tv, 0, sizeof(*tv)); #endif @@ -134,7 +130,7 @@ static void tmap_flush(struct HXmap *map, bool verbose) static void tmap_add_speed(struct HXmap *map) { - struct timeval start, stop, delta; + struct timespec start, stop, delta; unsigned int threshold; tmap_printf("MAP test 1: Timing add operation\n"); @@ -143,20 +139,20 @@ static void tmap_add_speed(struct HXmap *map) do { tmap_add_rand(map, 1); tmap_time(&stop); - HX_timeval_sub(&delta, &stop, &start); + HX_timespec_sub(&delta, &stop, &start); } while (!(delta.tv_sec >= 1 || map->items >= 1000000)); - tmap_printf("%u elements in " HX_TIMEVAL_FMT + tmap_printf("%u elements in " HX_TIMESPEC_FMT " (plus time measurement overhead)\n", - map->items, HX_TIMEVAL_EXP(&delta)); + map->items, HX_TIMESPEC_EXP(&delta)); threshold = map->items; tmap_flush(map, false); tmap_time(&start); tmap_add_rand(map, threshold); tmap_time(&stop); - HX_timeval_sub(&delta, &stop, &start); - tmap_printf("%u elements in " HX_TIMEVAL_FMT " (w/o overhead)\n", - map->items, HX_TIMEVAL_EXP(&delta)); + HX_timespec_sub(&delta, &stop, &start); + tmap_printf("%u elements in " HX_TIMESPEC_FMT " (w/o overhead)\n", + map->items, HX_TIMESPEC_EXP(&delta)); tmap_ipop(); } @@ -167,7 +163,7 @@ static bool tmap_each_fn(const struct HXmap_node *node, void *arg) static void tmap_trav_speed(struct HXmap *map) { - struct timeval start, stop, delta, delta2; + struct timespec start, stop, delta, delta2; const struct HXmap_node *node; struct HXmap_trav *iter; @@ -178,17 +174,17 @@ static void tmap_trav_speed(struct HXmap *map) while ((node = HXmap_traverse(iter)) != NULL) ; tmap_time(&stop); - HX_timeval_sub(&delta, &stop, &start); + HX_timespec_sub(&delta, &stop, &start); HXmap_travfree(iter); - tmap_printf("Open traversal of %u nodes: " HX_TIMEVAL_FMT "s\n", - map->items, HX_TIMEVAL_EXP(&delta)); + tmap_printf("Open traversal of %u nodes: " HX_TIMESPEC_FMT "s\n", + map->items, HX_TIMESPEC_EXP(&delta)); tmap_time(&start); HXmap_qfe(map, tmap_each_fn, NULL); tmap_time(&stop); - HX_timeval_sub(&delta, &stop, &start); - tmap_printf("QFE traversal of %u nodes: " HX_TIMEVAL_FMT "s\n", - map->items, HX_TIMEVAL_EXP(&delta)); + HX_timespec_sub(&delta, &stop, &start); + tmap_printf("QFE traversal of %u nodes: " HX_TIMESPEC_FMT "s\n", + map->items, HX_TIMESPEC_EXP(&delta)); tmap_ipop(); tmap_printf("MAP test 2a: Timing lookup\n"); @@ -198,14 +194,14 @@ static void tmap_trav_speed(struct HXmap *map) while ((node = HXmap_traverse(iter)) != NULL) HXmap_find(map, node->key); tmap_time(&stop); - HX_timeval_sub(&delta2, &stop, &start); + HX_timespec_sub(&delta2, &stop, &start); HXmap_travfree(iter); /* delta2 includes traversal time */ start = delta; stop = delta2; - HX_timeval_sub(&delta, &stop, &start); - tmap_printf("Lookup of %u nodes: " HX_TIMEVAL_FMT "s\n", - map->items, HX_TIMEVAL_EXP(&delta)); + HX_timespec_sub(&delta, &stop, &start); + tmap_printf("Lookup of %u nodes: " HX_TIMESPEC_FMT "s\n", + map->items, HX_TIMESPEC_EXP(&delta)); tmap_ipop(); } @@ -222,7 +218,7 @@ static void tmap_flat(const struct HXmap *map) abort(); } for (i = 0; i < map->items; ++i) - tmap_printf("%u. %s -> %s\n", i, nodes[i].key, nodes[i].data); + tmap_printf("%u. %s -> %s\n", i, nodes[i].skey, nodes[i].sdata); tmap_ipop(); free(nodes); } diff --git a/src/tc-memmem.c b/src/tc-memmem.c index 342500f..a4f272e 100644 --- a/src/tc-memmem.c +++ b/src/tc-memmem.c @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT /* * speed test HX_memmem - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. */ #include <stdio.h> #include <stdlib.h> @@ -35,6 +31,7 @@ static void long_scan(void) printf("long_scan: filler2=%p p=%p\n", filler2, p); HX_timespec_sub(&delta, &stop, &start); printf("long_scan: " HX_TIMESPEC_FMT "\n", HX_TIMESPEC_EXP(&delta)); + free(filler2); } int main(void) diff --git a/src/tc-misc.c b/src/tc-misc.c index cb985a3..5b043d4 100644 --- a/src/tc-misc.c +++ b/src/tc-misc.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #ifndef __cplusplus # include <stdlib.h> #else @@ -38,7 +32,8 @@ int main(int argc, const char **argv) if (stat(argv[1], &sa) < 0 || stat(argv[2], &sb) < 0) perror("stat"); - printf("Difference: %ld\n", HX_time_compare(&sa, &sb, 'm')); + else + printf("Difference: %ld\n", HX_time_compare(&sa, &sb, 'm')); } HX_exit(); diff --git a/src/tc-netio.c b/src/tc-netio.c index 45a6efc..5d3c22e 100644 --- a/src/tc-netio.c +++ b/src/tc-netio.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #define WIN32_LEAN_AND_MEAN 1 #ifdef __cplusplus # include <cstdlib> diff --git a/src/tc-option.c b/src/tc-option.c index aa6f12c..db3d3f4 100644 --- a/src/tc-option.c +++ b/src/tc-option.c @@ -1,10 +1,7 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2022 Jan Engelhardt /* * option parser test program - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. */ #include <errno.h> #include <stdio.h> diff --git a/src/tc-proc.c b/src/tc-proc.c index 7ec982f..19c8b18 100644 --- a/src/tc-proc.c +++ b/src/tc-proc.c @@ -1,16 +1,12 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #ifdef __cplusplus # include <cerrno> +# include <cstdio> # include <cstdlib> # include <cstring> #else # include <errno.h> +# include <stdio.h> # include <stdlib.h> # include <string.h> #endif @@ -56,6 +52,7 @@ int main(void) { if (HX_init() <= 0) abort(); + printf("top fd: %d\n", HXproc_top_fd()); /* let it fail - test verbosity */ HXproc_run_sync(t_args1 + 2, HXPROC_VERBOSE); diff --git a/src/tc-rand.c b/src/tc-rand.c index 3af45d0..149f18e 100644 --- a/src/tc-rand.c +++ b/src/tc-rand.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #include <stdio.h> #include <stdlib.h> #include <time.h> diff --git a/src/tc-realpath.c b/src/tc-realpath.c index 5dd9aa2..23609ca 100644 --- a/src/tc-realpath.c +++ b/src/tc-realpath.c @@ -1,16 +1,13 @@ +// SPDX-License-Identifier: MIT /* * Test utility for libHX's realpath - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <libHX/io.h> #include <libHX/option.h> +#include <libHX/string.h> static unsigned int rp_flags; static unsigned int rp_absolute; @@ -42,6 +39,14 @@ static bool rp_get_options(int *argc, const char ***argv) return true; } +static void t_1(void) +{ + hxmc_t *tmp = HXmc_strinit(""); + /* two components, so that HX_readlink gets called twice */ + HX_realpath(&tmp, "/dev/tty", HX_REALPATH_DEFAULT); + HXmc_free(tmp); +} + int main(int argc, const char **argv) { hxmc_t *res; @@ -49,6 +54,7 @@ int main(int argc, const char **argv) if (!rp_get_options(&argc, &argv)) return EXIT_FAILURE; + t_1(); res = NULL; while (--argc > 0) { diff --git a/src/tc-shconfig.c b/src/tc-shconfig.c index 8a31c45..556f90f 100644 --- a/src/tc-shconfig.c +++ b/src/tc-shconfig.c @@ -1,13 +1,9 @@ /* A=b;C="d" ; E="F;" ; F= G=Z */ +// SPDX-License-Identifier: MIT /* * shconfig test program - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. */ #include <errno.h> #include <stdio.h> diff --git a/src/tc-socket.c b/src/tc-socket.c new file mode 100644 index 0000000..9c73d24 --- /dev/null +++ b/src/tc-socket.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <libHX/defs.h> +#include <libHX/socket.h> +#ifndef _WIN32 +# include <netdb.h> +#endif +#ifndef AI_V4MAPPED +# define AI_V4MAPPED 0 +#endif + +int main(void) +{ + static const char *addrs[] = { + "::1", "::2", "::ffff:127.0.0.1", "::", + "127.0.0.1", "127.0.0.2", "1.1.1.1", "255.255.255.255", + }; + for (size_t i = 0; i < ARRAY_SIZE(addrs); ++i) { + printf("%-16s\t", addrs[i]); + int lcl = HX_ipaddr_is_local(addrs[i], AI_V4MAPPED); + if (lcl < 0) { + printf("%s\n", strerror(-lcl)); + return EXIT_FAILURE; + } + printf("%d\n", lcl); + } + return EXIT_SUCCESS; +} diff --git a/src/tc-strchr2.c b/src/tc-strchr2.c index 6e0eaad..ad37f37 100644 --- a/src/tc-strchr2.c +++ b/src/tc-strchr2.c @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT /* * Behavior Correctness Test for HX_strchr2 - * Copyright Jan Engelhardt, 2013 - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. */ #include <libHX/string.h> diff --git a/src/tc-string.c b/src/tc-string.c index 6e85f66..77235c2 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -1,11 +1,5 @@ /* long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing */ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #ifndef __cplusplus # include <assert.h> # include <errno.h> @@ -90,9 +84,12 @@ static void t_strncat(void) { char data[5] = "DATA"; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation" if (snprintf(data, sizeof(data), "12345678") >= static_cast(ssize_t, sizeof(data))) printf("Not enough space\n"); +#pragma GCC diagnostic pop printf("String: >%s<\n", data); HX_strlcat(data, "pqrstuv__", 2); @@ -271,11 +268,13 @@ static void t_strlcpy(void) HX_timespec_sub(&d2, &stop, &start); HX_timespec_sub(&d3, &d1, &d2); - printf("%4zu->%4zu: %1ld.%09ld (str=%ld.%09ld mem=%ld.%09ld)\n", + printf("%4zu->%4zu: " HX_TIMESPEC_FMT + " (str=" HX_TIMESPEC_FMT + " mem=" HX_TIMESPEC_FMT ")\n", strlen(ibuf), picksizes[opick], - static_cast(long, d3.tv_sec), d3.tv_nsec, - static_cast(long, d1.tv_sec), d1.tv_nsec, - static_cast(long, d2.tv_sec), d2.tv_nsec + HX_TIMESPEC_EXP(&d3), + HX_TIMESPEC_EXP(&d1), + HX_TIMESPEC_EXP(&d2) ); } } @@ -288,6 +287,222 @@ static void t_strlcpy2(void) assert(a[0] == 49 && a[0] == a[1] && a[1] == a[2]); } +static void t_units(void) +{ + static const struct { + unsigned long long num; + const char exp_1024[6], exp_1000[6]; + } vt[] = { + {1023, "1023", "1023"}, + {1024, "1024", "1024"}, + {1945, "1945", "1945"}, + {1946, "1946", "1946"}, + {1022975, "998k", "1022k"}, + {1022976, "999k", "1022k"}, + {1022977, "999k", "1022k"}, + {1047552, "1023k", "1047k"}, + {1047553, "1023k", "1047k"}, + {1992294, "1945k", "1992k"}, + {1992295, "1945k", "1992k"}, + {1072693248, "1023M", "1072M"}, + {1072693249, "1023M", "1072M"}, + {ULLONG_MAX, "15E", "18E"}, + }; + char buf[HXSIZEOF_Z64+3]; + printf("unit_size:\n"); + + for (size_t i = 0; i < ARRAY_SIZE(vt); ++i) { + HX_unit_size(buf, ARRAY_SIZE(buf), vt[i].num, 1024, 9120); + printf("\t%llu -> %s\n", vt[i].num, buf); + if (strcmp(buf, vt[i].exp_1024) != 0) { + printf("\texpected %s\n", vt[i].exp_1024); + abort(); + } + HX_unit_size(buf, ARRAY_SIZE(buf), vt[i].num, 1000, 9120); + printf("\t%llu -> %s\n", vt[i].num, buf); + if (strcmp(buf, vt[i].exp_1000) != 0) { + printf("\texpected %s\n", vt[i].exp_1000); + abort(); + } + } +} + +static void t_units_cu(void) +{ + static const struct { + unsigned long long num; + const char exp_1024[6], exp_1000[6]; + } vt[] = { + {1023, "1023", "1.1k"}, + {1024, "1.0k", "1.1k"}, + {1945, "1.9k", "2.0k"}, + {1946, "2.0k", "2.0k"}, + {1022975, "999k", "1.1M"}, + {1022976, "999k", "1.1M"}, + {1022977, "1000k", "1.1M"}, + {1047552, "1023k", "1.1M"}, + {1047553, "1.0M", "1.1M"}, + {1992294, "1.9M", "2.0M"}, + {1992295, "2.0M", "2.0M"}, + {1072693248, "1023M", "1.1G"}, + {1072693249, "1.0G", "1.1G"}, + {ULLONG_MAX, "16E", "19E"}, + }; + char buf[80]; + printf("unit_size_cu:\n"); + + for (size_t i = 0; i < ARRAY_SIZE(vt); ++i) { + HX_unit_size_cu(buf, ARRAY_SIZE(buf), vt[i].num, 1024); + printf("\t%llu -> %s\n", vt[i].num, buf); + if (strcmp(buf, vt[i].exp_1024) != 0) { + printf("\texpected %s\n", vt[i].exp_1024); + abort(); + } + HX_unit_size_cu(buf, ARRAY_SIZE(buf), vt[i].num, 1000); + printf("\t%llu -> %s\n", vt[i].num, buf); + if (strcmp(buf, vt[i].exp_1000) != 0) { + printf("\texpected %s\n", vt[i].exp_1000); + abort(); + } + } +} + +static void t_units_strto(void) +{ + static const struct { + const char input[24]; + unsigned int exponent; + unsigned long long expect_out; + const char expect_rem[8]; + } vt[] = { + {"-5k", 1000, ULLONG_MAX, "-5k"}, + {" -5.2k", 1000, ULLONG_MAX, "-5.2k"}, + {"1", 9999, 1, ""}, + {"1024", 9999, 1ULL << 10, ""}, + {"1048576", 9999, 1ULL << 20, ""}, + {"1073741824", 9999, 1ULL << 30, ""}, + {"1099511627776", 9999, 1ULL << 40, ""}, + {"1125899906842624", 9999, 1ULL << 50, ""}, + {"1152921504606846976", 9999, 1ULL << 60, ""}, + {"18446744073709551615", 9, ULLONG_MAX, ""}, + {"1k", 1000, 1000ULL, ""}, + {"1M", 1000, 1000000ULL, ""}, + {"1G", 1000, 1000000000ULL, ""}, + {"1T", 1000, 1000000000000ULL, ""}, + {"1P", 1000, 1000000000000000ULL, ""}, + {"1E", 1000, 1000000000000000000ULL, ""}, + {"1k", 1024, 1ULL << 10, ""}, + {"1M", 1024, 1ULL << 20, ""}, + {"1G", 1024, 1ULL << 30, ""}, + {"1T", 1024, 1ULL << 40, ""}, + {"1P", 1024, 1ULL << 50, ""}, + {"1E", 1024, 1ULL << 60, ""}, + {"0", 0, 0, ""}, + {"0k", 0, 0, ""}, + {"0 Z", 0, 0, ""}, + {"0.1k", 1000, 100, ""}, + {"0.1k", 1024, 102, ""}, + {" 0.1k", 1024, 102, ""}, + {"0.00000000000000001E", 1024, 11, ""}, + {"1.525444GiB", 1000, 1525444000, "iB"}, + {"1.525444GiB", 1024, 1637933022, "iB"}, + }; + char *end; + for (size_t i = 0; i < ARRAY_SIZE(vt); ++i) { + unsigned long long q = HX_strtoull_unit(vt[i].input, &end, vt[i].exponent); + printf("%s -> %llu __ %s\n", vt[i].input, q, end); + if (q != vt[i].expect_out || strcmp(end, vt[i].expect_rem) != 0) + printf("BUG\n"); + } +} + +static void t_time_units(void) +{ + static const struct { + unsigned long long input; + unsigned int flags; + const char expect_out[24]; + } vt[] = { + {31536000, 0, "365d"}, + {31622400, 0, "366d"}, + {31622400, HXUNIT_YEARS, "1y18h"}, + {31622400, HXUNIT_MONTHS, "1y"}, + {31622400, HXUNIT_WEEKS, "1y"}, + {31622400, HXUNIT_MONTHS | HXUNIT_WEEKS, "1y"}, + {2678400, HXUNIT_MONTHS, "1month13h30min"}, + {2592000, HXUNIT_MONTHS, "30d"}, + {608400, HXUNIT_WEEKS, "1week1h"}, + {90061, 0, "1d1h1min1s"}, + {3692, 0, "1h1min32s"}, + {67, 0, "1min7s"}, + {1, 0, "1s"}, + {0, 0, "0s"}, + }; + printf("===== HX_unit_seconds\n"); + for (size_t i = 0; i < ARRAY_SIZE(vt); ++i) { + char out[60]; + char *ret = HX_unit_seconds(out, ARRAY_SIZE(out), vt[i].input, vt[i].flags); + printf("%llus => \"%s\"\n", vt[i].input, ret); + if (strcmp(ret, vt[i].expect_out) != 0) + printf("\tBUG, expected \"%s\"\n", vt[i].expect_out); + } +} + +static void t_time_strto(void) +{ + static const struct { + const char *input; + unsigned long long expect_out; + const char expect_rem[4]; + } vt[] = { + {"1y1month1week1d1h1min1s ", 31557600+2629800+86400*8+3600+60+1, ""}, + {" -1d", 0, "-1d"}, + {"1 -", 1, "-"}, + {"1s", 1, ""}, + {"1min", 60, ""}, + {"0", 0, ""}, + }; + char *end; + printf("===== t_time_strto\n"); + for (size_t i = 0; i < ARRAY_SIZE(vt); ++i) { + unsigned long long q = HX_strtoull_sec(vt[i].input, &end); + printf("\"%s\" => %llus + \"%s\"\n", vt[i].input, q, end); + if (q != vt[i].expect_out) + printf("\tBUG: expected %llus\n", vt[i].expect_out); + if (strcmp(end, vt[i].expect_rem) != 0) + printf("\tBUG: expected remainder \"%s\"\n", vt[i].expect_rem); + } +} + +static int t_strmid(void) +{ +#define T(spar,opar,lpar,xpar) do { \ + char *s = HX_strmid((spar), (opar), (lpar)); \ + if (s == nullptr) \ + return EXIT_FAILURE; \ + int ret = strcmp(s, (xpar)); \ + if (ret != 0) { \ + fprintf(stderr, "Faillure: substr %s,%d,%d = %s\n", \ + (spar), static_cast(int, (opar)), static_cast(int, (lpar)), s); \ + free(s); \ + return ret; \ + } \ + free(s); \ + } while (false) + + T("Hello World", -12, 5, ""); + T("bark", -3, -1, "ar"); + T("cake", -3, -3, ""); + T("cake", -3, -4, ""); + T("fun", 0, 0, ""); + T("bark", 0, 1, "b"); + T("bark", 0, 5, "bark"); + T("bark", -4, 1, "b"); + T("bark", -4, 5, "bark"); + return EXIT_SUCCESS; +#undef T +} + int main(int argc, const char **argv) { hxmc_t *tx = NULL; @@ -296,6 +511,9 @@ int main(int argc, const char **argv) if (HX_init() <= 0) abort(); + int ret = t_strmid(); + if (ret != EXIT_SUCCESS) + return EXIT_FAILURE; fp = fopen(file, "r"); if (fp == NULL) { @@ -316,6 +534,11 @@ int main(int argc, const char **argv) t_strtrim(); t_split(); t_split2(); + t_units(); + t_units_cu(); + t_units_strto(); + t_time_units(); + t_time_strto(); t_strlcpy(); t_strlcpy2(); HXmc_free(tx); diff --git a/src/tc-strquote.c b/src/tc-strquote.c index f26ff54..ef357d1 100644 --- a/src/tc-strquote.c +++ b/src/tc-strquote.c @@ -1,10 +1,6 @@ +// SPDX-License-Identifier: MIT /* * Behavior Correctness Test for HX_strquote - * Copyright Jan Engelhardt, 2013 - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. */ #include <stdbool.h> #include <stdio.h> @@ -26,6 +22,10 @@ static const char input4[] = "http://user:pass@host.de/~path/file(msvc);stuff. static const char output4[] = "http%3A%2F%2Fuser%3Apass%40host.de%2F~path%2Ffile%28msvc%29%3Bstuff.php%3Fquery%5Bphpindex%5D%3Dvalue%26another%3Done%3Bstuff"; static const char input5[] = "echo hello `echo world`"; static const char output5[] = "echo hello ``echo world``"; +static const char input6[] = "\xfb\xef\xff"; +static const char output6[] = "++//"; +static const char input7[] = "\xfb\xef\xff"; +static const char output7[] = "--__"; static int test(const char *input, unsigned int mode, const char *expect) { @@ -65,6 +65,8 @@ int main(void) tst(input3, HXQUOTE_BASE64, output3c); tst(input4, HXQUOTE_URIENC, output4); tst(input5, HXQUOTE_SQLBQUOTE, output5); + tst(input6, HXQUOTE_BASE64, output6); + tst(input7, HXQUOTE_BASE64URL, output7); return 0; #undef tst } diff --git a/src/tc-switchuser.c b/src/tc-switchuser.c new file mode 100644 index 0000000..1763527 --- /dev/null +++ b/src/tc-switchuser.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: MIT +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <libHX/defs.h> +#include <libHX/option.h> +#include <libHX/proc.h> +#if defined(HAVE_INITGROUPS) + +static char *user_name, *group_name; +static const struct HXoption options_table[] = { + {.sh = 'u', .type = HXTYPE_STRING, .ptr = &user_name}, + {.sh = 'g', .type = HXTYPE_STRING, .ptr= &group_name}, + HXOPT_TABLEEND, +}; + +int main(int argc, const char **argv) +{ + HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR); + const char *user = user_name != NULL ? user_name : "-"; + const char *group = group_name != NULL ? group_name : "-"; + switch (HXproc_switch_user(user_name, group_name)) { + case HXPROC_USER_NOT_FOUND: + if (user_name == NULL) + abort(); /* impossible outcomes */ + printf("No such user \"%s\": %s\n", user_name, strerror(errno)); + break; + case HXPROC_GROUP_NOT_FOUND: + if (group_name == NULL || *group_name == '\0') + abort(); /* impossible outcome */ + printf("No such group \"%s\": %s\n", group_name, strerror(errno)); + break; + case HXPROC_SETUID_FAILED: + printf("setuid %s: %s\n", user, strerror(errno)); + break; + case HXPROC_SETGID_FAILED: + printf("setgid %s: %s\n", group, strerror(errno)); + break; + case HXPROC_INITGROUPS_FAILED: + printf("initgroups for %s: %s\n", user, strerror(errno)); + break; + case HXPROC_SU_NOOP: + printf("No action was performed./User identity already reached.\n"); + /* fallthrough */ + case HXPROC_SU_SUCCESS: { + gid_t list[64] = {-1}; + int numgroups = getgroups(ARRAY_SIZE(list), list); + printf("Identity now: uid %lu euid %lu gid %lu egid %lu\n", + static_cast(unsigned long, getuid()), + static_cast(unsigned long, geteuid()), + static_cast(unsigned long, getgid()), + static_cast(unsigned long, getegid())); + printf("Secondary groups:"); + for (int i = 0; i < numgroups; ++i) + printf(" %lu", static_cast(unsigned long, list[i])); + printf("\n"); + break; + } + } + return EXIT_SUCCESS; +} +#else +int main(void) +{ + return EXIT_SUCCESS; +} +#endif diff --git a/src/tc-time.c b/src/tc-time.c index e842e77..5097cde 100644 --- a/src/tc-time.c +++ b/src/tc-time.c @@ -1,10 +1,5 @@ -/* - * Copyright Jan Engelhardt, 2012 - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT +#include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> @@ -26,7 +21,7 @@ static const int NANOSECOND = 1000000000; static const long long NANOSECOND_LL = 1000000000; static const unsigned int clock_id = CLOCK_THREAD_CPUTIME_ID; static const unsigned int step = 1000; -static const unsigned int step_mul = 10000000; +static const long step_mul = 10000000; static const struct timespec pairs[] = { {-1, 700000000}, {-1, 400000000}, {-1, 0}, @@ -36,10 +31,12 @@ static const struct timespec pairs[] = { }; /* - * Variant that uses full 64 bit division and is thus slower on - * a handful of hardware. + * The playing fields it not level at all! + * HX_timespec_add_DIVQ benefits from inlining and near jumps, + * while HX_timespec_add has to go via PLT, and also has the PIC tax. + * It is actually worse by 7% on i7-8250U/-m64. */ -static struct timespec *HX_timespec_add_FDIV(struct timespec *r, +static struct timespec *HX_timespec_add_DIVQ(struct timespec *r, const struct timespec *a, const struct timespec *b) { long long p, q; @@ -105,6 +102,20 @@ HX_timespec_mulf_S(struct timespec *r, const struct timespec *a, double f) return r; } +static void test_basic(void) +{ + struct timeval a = {1, 769298}, b = {2, 430520}, c; + struct timespec p = {1, 769298000}, q = {2, 430520000}, r; + HX_timeval_sub(&c, &b, &a); + HX_timespec_sub(&r, &q, &p); + printf(HX_TIMEVAL_FMT "\n", HX_TIMEVAL_EXP(&c)); + printf(HX_TIMESPEC_FMT "\n", HX_TIMESPEC_EXP(&r)); + assert(c.tv_sec == 0); + assert(c.tv_usec == 661222); + assert(r.tv_sec == 0); + assert(r.tv_nsec == 661222000); +} + static void test_same(void) { static const struct timespec zero = {0, 0}; @@ -205,9 +216,9 @@ static void test_add(void) for (a = pairs; a < pairs + ARRAY_SIZE(pairs); ++a) { for (b = pairs; b < pairs + ARRAY_SIZE(pairs); ++b) { HX_timespec_add(&r, a, b); - print_op2(&r, a, "+N", b); - HX_timespec_add_FDIV(&s, a, b); - print_op2(&r, a, "+F", b); + print_op2(&r, a, "+L", b); + HX_timespec_add_DIVQ(&s, a, b); + print_op2(&r, a, "+Q", b); if (r.tv_sec != s.tv_sec || r.tv_nsec != s.tv_nsec) abort(); HX_timespec_sub(&r, a, b); @@ -288,7 +299,7 @@ static void test_adds(void) { printf("# Test addition speed\n"); test_adds_1("normal: ", HX_timespec_add); - test_adds_1("fulldiv: ", HX_timespec_add_FDIV); + test_adds_1("div64: ", HX_timespec_add_DIVQ); printf("\n"); } @@ -335,11 +346,10 @@ static void test_mul(void) static void test_muls_1i(const char *text, mul_func_t fn) { struct timespec r, s, start, delta; - unsigned int i; printf("%s", text); clock_gettime(clock_id, &start); - for (i = 0; i < step_mul; ++i) { + for (time_t i = 0; i < step_mul; ++i) { r.tv_sec = -i; r.tv_nsec = -i / 4; (*fn)(&s, &r, 7); @@ -352,11 +362,10 @@ static void test_muls_1i(const char *text, mul_func_t fn) static void test_muls_1f(const char *text, mulf_func_t fn) { struct timespec r, s, start, delta; - unsigned int i; printf("%s", text); clock_gettime(clock_id, &start); - for (i = 0; i < step_mul; ++i) { + for (time_t i = 0; i < step_mul; ++i) { r.tv_sec = -i; r.tv_nsec = -i / 4; (*fn)(&s, &r, 7); @@ -382,6 +391,7 @@ int main(void) if (HX_init() <= 0) abort(); + test_basic(); test_same(); test_neg(); test_add(); diff --git a/src/tc-xml.c b/src/tc-xml.c index 07cf3b3..49b24ad 100644 --- a/src/tc-xml.c +++ b/src/tc-xml.c @@ -1,10 +1,4 @@ -/* - * Copyright Jan Engelhardt - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the WTF Public License version 2 or - * (at your option) any later version. - */ +// SPDX-License-Identifier: MIT #include <stdbool.h> #include <stdio.h> #include <libxml/parser.h> @@ -6,6 +6,7 @@ * General Public License as published by the Free Software Foundation; * either version 2.1 or (at your option) any later version. */ +#include <stdint.h> #include <sys/stat.h> #include <sys/time.h> #include <stdbool.h> @@ -39,38 +40,13 @@ HX_timespec_neg(struct timespec *r, const struct timespec *a) EXPORT_SYMBOL struct timespec *HX_timespec_add(struct timespec *r, const struct timespec *a, const struct timespec *b) { - /* - * Split the value represented by the struct into two - * independent values that can be added individually. - */ - long nsec[2]; - nsec[0] = (a->tv_sec < 0) ? -a->tv_nsec : a->tv_nsec; - nsec[1] = (b->tv_sec < 0) ? -b->tv_nsec : b->tv_nsec; - - r->tv_sec = a->tv_sec + b->tv_sec; - r->tv_nsec = nsec[0] + nsec[1]; - if (r->tv_nsec >= NANOSECOND) { - ++r->tv_sec; - r->tv_nsec -= NANOSECOND; - } else if (r->tv_nsec <= -NANOSECOND) { - --r->tv_sec; - r->tv_nsec += NANOSECOND; - } - - /* Combine again */ - if (r->tv_sec < 0) { - if (r->tv_nsec < 0) { - r->tv_nsec = -r->tv_nsec; - } else if (r->tv_nsec > 0) { - if (++r->tv_sec == 0) - r->tv_nsec = -NANOSECOND + r->tv_nsec; - else - r->tv_nsec = NANOSECOND - r->tv_nsec; - } - } else if (r->tv_sec > 0 && r->tv_nsec < 0) { - --r->tv_sec; - r->tv_nsec = NANOSECOND + r->tv_nsec; - } + long aa = a->tv_sec * NANOSECOND_LL + + ((a->tv_sec >= 0) ? a->tv_nsec : -a->tv_nsec); + long bb = b->tv_sec * NANOSECOND_LL + + ((b->tv_sec >= 0) ? b->tv_nsec : -b->tv_nsec); + long rr = aa + bb; + r->tv_sec = rr / NANOSECOND; + r->tv_nsec = ((r->tv_sec < 0) ? -rr : rr) % NANOSECOND; return r; } @@ -119,20 +95,14 @@ HX_timespec_mulf(struct timespec *r, const struct timespec *a, double f) EXPORT_SYMBOL struct timeval *HX_timeval_sub(struct timeval *delta, const struct timeval *future, const struct timeval *past) { - delta->tv_sec = future->tv_sec - past->tv_sec; - delta->tv_usec = future->tv_usec - past->tv_usec; - if (future->tv_sec < past->tv_sec || (future->tv_sec == past->tv_sec && - future->tv_usec < past->tv_usec)) { - if (future->tv_usec > past->tv_usec) { - delta->tv_usec = -MICROSECOND + delta->tv_usec; - ++delta->tv_sec; - } - if (delta->tv_sec < 0) - delta->tv_usec *= -1; - } else if (delta->tv_usec < 0) { - delta->tv_usec += MICROSECOND; - --delta->tv_sec; - } + struct timespec d, f, p; + f.tv_sec = future->tv_sec; + f.tv_nsec = future->tv_usec * 1000; + p.tv_sec = past->tv_sec; + p.tv_nsec = past->tv_usec * 1000; + HX_timespec_sub(&d, &f, &p); + delta->tv_sec = d.tv_sec; + delta->tv_usec = d.tv_nsec / 1000; return delta; } #endif diff --git a/src/tx-intdiff.cpp b/src/tx-intdiff.cpp new file mode 100644 index 0000000..cd8ec7a --- /dev/null +++ b/src/tx-intdiff.cpp @@ -0,0 +1,24 @@ +#include <cstdio> +#include <iterator> +#include <vector> +#include <libHX/intdiff.hpp> +int main() +{ + std::vector<int> a{1, 2, 5}; + std::vector<long> b{2, 3, 4, 5}; + std::vector<float> comm, left, right; + + HX::set_intersect_diff(a.cbegin(), a.cend(), b.cbegin(), b.cend(), + std::back_inserter(comm), std::back_inserter(left), + std::back_inserter(right)); + for (auto e : comm) + printf("%f,", e); + printf("\n"); + for (auto e : left) + printf("%f,", e); + printf("\n"); + for (auto e : right) + printf("%f,", e); + printf("\n"); + return 0; +} diff --git a/src/tx-option.cpp b/src/tx-option.cpp index 55e3566..b70110f 100644 --- a/src/tx-option.cpp +++ b/src/tx-option.cpp @@ -5,7 +5,9 @@ #endif #include <libHX/option.h> +static unsigned int g_verbose; static const struct HXoption t[] = { + {nullptr, 'v', HXTYPE_NONE | HXOPT_INC, &g_verbose}, HXOPT_AUTOHELP, HXOPT_TABLEEND, }; |