From eece9692d707ccb20356ec06955f8308c4e59ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 17 Dec 2023 14:18:48 +0100 Subject: New upstream version 4.19 --- Makefile.in | 1 + build-aux/ltmain.sh | 855 +++++++++++++++++++++++++++++++++---------------- configure | 380 +++++++++++++++------- configure.ac | 2 +- doc/api.rst | 5 +- doc/changelog.rst | 28 ++ doc/generator.cpp | 2 +- doc/inline_list.rst | 4 +- doc/option_parsing.rst | 167 +++++----- doc/string_ops.rst | 2 +- include/Makefile.am | 2 +- include/Makefile.in | 3 +- include/libHX/cast.h | 129 ++++++++ include/libHX/defs.h | 115 +------ include/libHX/misc.h | 3 + include/libHX/option.h | 10 +- m4/libtool.m4 | 227 +++++++------ m4/ltoptions.m4 | 4 +- m4/ltsugar.m4 | 2 +- m4/ltversion.m4 | 13 +- m4/lt~obsolete.m4 | 4 +- src/Makefile.am | 17 +- src/Makefile.in | 126 ++++---- src/analyze.sh | 3 + src/internal.h | 5 +- src/libHX.map | 5 + src/opt.c | 64 ++-- src/proc.c | 2 +- src/rtcheck.c | 274 ---------------- src/socket.c | 12 +- src/string.c | 68 +++- src/tc-dir.c | 2 +- src/tc-format.c | 2 +- src/tc-list.c | 18 +- src/tc-memmem.c | 2 +- src/tc-misc.c | 6 +- src/tc-option.c | 68 ++-- src/tc-realpath.c | 15 +- src/tc-shconfig.c | 4 +- src/tc-string.c | 173 ++++------ src/tc-switchuser.c | 8 +- src/tx-option.cpp | 6 +- src/uxcompat.h | 104 ++++++ 43 files changed, 1665 insertions(+), 1277 deletions(-) create mode 100644 include/libHX/cast.h create mode 100755 src/analyze.sh delete mode 100644 src/rtcheck.c create mode 100644 src/uxcompat.h diff --git a/Makefile.in b/Makefile.in index b3403df..e7860e2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -275,6 +275,7 @@ EGREP = @EGREP@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ 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 , 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 . +# 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 +# , and GPL version 2 or later +# . 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: +# ## ------ ## @@ -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 +# , and GPL version 2 or later +# . 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 . +# Please report bugs or propose patches to: +# -# 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 '_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 '_result', escaped +# suitably for 'eval'. +# +# The '_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/configure b/configure index 090101d..a5cc895 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for libHX 4.17. +# Generated by GNU Autoconf 2.71 for libHX 4.19. # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, @@ -618,8 +618,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libHX' PACKAGE_TARNAME='libhx' -PACKAGE_VERSION='4.17' -PACKAGE_STRING='libHX 4.17' +PACKAGE_VERSION='4.19' +PACKAGE_STRING='libHX 4.19' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -686,6 +686,7 @@ MANIFEST_TOOL RANLIB DLLTOOL OBJDUMP +FILECMD LN_S NM ac_ct_DUMPBIN @@ -1374,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 4.17 to adapt to many kinds of systems. +\`configure' configures libHX 4.19 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1445,7 +1446,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libHX 4.17:";; + short | recursive ) echo "Configuration of libHX 4.19:";; esac cat <<\_ACEOF @@ -1560,7 +1561,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libHX configure 4.17 +libHX configure 4.19 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2194,7 +2195,7 @@ 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 4.17, which was +It was created by libHX $as_me 4.19, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3683,7 +3684,7 @@ fi # Define the identity of the package. PACKAGE='libhx' - VERSION='4.17' + VERSION='4.19' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -5901,8 +5902,8 @@ esac -macro_version='2.4.6' -macro_revision='2.4.6' +macro_version='2.4.7' +macro_revision='2.4.7' @@ -6530,13 +6531,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 @@ -6674,7 +6675,7 @@ esac 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" ;; @@ -6778,7 +6779,7 @@ else $as_nop 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` @@ -6821,7 +6822,7 @@ else $as_nop 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 @@ -7026,6 +7027,114 @@ 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 @@ -7169,7 +7278,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 ;; @@ -7203,14 +7312,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 @@ -7224,7 +7333,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' @@ -7271,7 +7380,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 ;; @@ -7644,13 +7753,29 @@ 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 + + + + + + +# 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. + @@ -8067,7 +8192,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'" @@ -8085,20 +8210,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'"\ @@ -8122,7 +8247,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};"\ @@ -8140,9 +8265,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 @@ -8345,7 +8470,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|'') ;; #( @@ -8470,7 +8595,7 @@ ia64-*-hpux*) ac_status=$? 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 ;; @@ -8491,7 +8616,7 @@ ia64-*-hpux*) 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" ;; @@ -8503,7 +8628,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" ;; @@ -8529,7 +8654,7 @@ mips64*-*linux*) 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" ;; @@ -8537,7 +8662,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" ;; @@ -8545,7 +8670,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" ;; @@ -8569,14 +8694,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) ac_status=$? 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" ;; @@ -8684,7 +8809,7 @@ printf "%s\n" "$lt_cv_cc_needs_belf" >&6; } ac_status=$? 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*) @@ -9467,8 +9592,8 @@ 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 @@ -9495,17 +9620,12 @@ printf "%s\n" "$lt_cv_ld_force_load" >&6; } _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 @@ -9903,8 +10023,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 @@ -10416,7 +10536,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' @@ -10839,15 +10959,15 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries 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*) @@ -10899,7 +11019,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries 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 ... @@ -11011,6 +11131,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]*) @@ -11025,7 +11146,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) @@ -11068,7 +11189,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 @@ -11080,7 +11201,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 @@ -11096,7 +11217,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 @@ -11228,7 +11349,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 @@ -11499,12 +11620,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 @@ -11545,7 +11666,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. @@ -11586,8 +11707,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 @@ -11621,7 +11742,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 @@ -11872,6 +11993,7 @@ printf "%s\n" "$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*) @@ -12564,7 +12686,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" ;; @@ -12574,14 +12696,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' @@ -12600,7 +12722,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 @@ -12637,7 +12759,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' ;; @@ -12670,7 +12792,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 @@ -13823,30 +13945,41 @@ striplib= old_striplib= { 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 -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" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } +if test -z "$STRIP"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } 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" + { 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" { 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 + ;; + 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 + fi + ;; + *) + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 printf "%s\n" "no" >&6; } - ;; - esac + ;; + esac + fi fi @@ -14616,8 +14749,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=' ' @@ -14708,11 +14841,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 @@ -14747,6 +14880,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*) @@ -14777,7 +14911,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 @@ -14914,7 +15048,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 @@ -15054,13 +15188,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' @@ -15717,7 +15851,7 @@ lt_prog_compiler_static_CXX= ;; esac ;; - freebsd* | dragonfly*) + freebsd* | dragonfly* | midnightbsd*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) @@ -15800,7 +15934,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' @@ -16187,7 +16321,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries 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*) @@ -16195,7 +16329,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries ;; cygwin* | mingw* | cegcc*) case $cc_basename in - cl*) + cl* | icl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) @@ -16543,7 +16677,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*) @@ -16552,14 +16686,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' @@ -16578,7 +16712,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 @@ -16615,7 +16749,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' ;; @@ -16647,7 +16781,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 @@ -18635,7 +18769,7 @@ 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 4.17, which was +This file was extended by libHX $as_me 4.19, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -18703,7 +18837,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -libHX config.status 4.17 +libHX config.status 4.19 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" @@ -18866,6 +19000,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"`' @@ -18874,6 +19009,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"`' @@ -19048,6 +19184,7 @@ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ +FILECMD \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ @@ -19056,7 +19193,6 @@ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ -AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ @@ -20045,6 +20181,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 @@ -20069,8 +20208,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 @@ -20460,7 +20602,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" || diff --git a/configure.ac b/configure.ac index bb658ea..a41566a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libHX], [4.17]) +AC_INIT([libHX], [4.19]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/api.rst b/doc/api.rst index a645fdd..84feaa6 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -3,12 +3,13 @@ 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. +* M column: Lowest possible version with the same ABI (minus cv qualification). +* F column: First version that the function name was in use. ====== ====== ====== ======================================== RMV MinVer FirstA Name ====== ====== ====== ======================================== +4.18 4.18 4.18 HX_getopt5 4.16 4.16 4.16 HX_strtoull_nsec 4.15 4.15 4.15 HX_flpr 4.15 4.15 4.15 HX_flprf diff --git a/doc/changelog.rst b/doc/changelog.rst index 2e0cf0f..8903a72 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,3 +1,31 @@ +v4.19 (2023-12-01) +================== + +Fixes: + +* string: fixed HX_strtoull_unit with negative fractions producing 0 + sometimes +* opt: fix HX_getopt losing argv on HXOPT_KEEP_ARGV + + +v4.18 (2023-11-27) +================== + +Enhancements: + +* opt: new HX_getopt5 API for the parser with untangled in and out variables + +Fixes: + +* string: HX_strtoull_units handles negative values now (like strtoull) +* string: HX_strtoull_units & HX_strtoull_(n)sec now set errno=ERANGE for + nonrepresentable results + +Behavioral changes: + +* string: HX_strtoull_sec rejects unitless numbers now + + v4.17 (2023-11-12) ================== diff --git a/doc/generator.cpp b/doc/generator.cpp index 6c64f80..0889cfd 100644 --- a/doc/generator.cpp +++ b/doc/generator.cpp @@ -35,7 +35,7 @@ class rdgen { fi end(void) { return fi(*this); }; }; -int main(int argc, const char **argv) +int main(int argc, char **argv) { for (auto x : rdgen(argc)) printf("%d\n", x); diff --git a/doc/inline_list.rst b/doc/inline_list.rst index e60e89f..3e4cb7c 100644 --- a/doc/inline_list.rst +++ b/doc/inline_list.rst @@ -195,7 +195,7 @@ HXdeque: .. code-block:: c - int main(int argc, const char **argv) + int main(int argc, char **argv) { struct HXdeque *dq = HXdeque_init(); while (--argc) @@ -212,7 +212,7 @@ HXdeque: char *data; }; - int main(int main, const char **argv) + int main(int main, char **argv) { HXLIST_HEAD(lh); while (--argc) { diff --git a/doc/option_parsing.rst b/doc/option_parsing.rst index 9205c2b..2dced82 100644 --- a/doc/option_parsing.rst +++ b/doc/option_parsing.rst @@ -2,22 +2,22 @@ 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. +Characteristics: + +* short options: + * bundling of argument-free options (``-a -b -c`` -> ``-abc``) + * squashing of argument-requiring options (``-a foo`` -> ``-afoo``) +* GNU long options with space or equals sign (``--foo bar``, ``--foo=bar``) +* proper recognition of the lone dash (often used to indicate stdin/stdout) +* recognition of the double dash as option list terminator +* offers POSIX strictness where the option list terminates at the first + non-option argument +* option passthrough +* the parse function is one-shot; there is no context object (like popt), + no global state (like getopt) and no ``while`` loop (either of the two others) +* exclusively uses an option table +* value storing is performed through pointers in the option table +* or user-provided callbacks can be invoked per option Synopsis @@ -37,7 +37,7 @@ Synopsis const char *help, *htyp; }; - int HX_getopt(const struct HXoption *options_table, int *argc, const char ***argv, unsigned int flags); + int HX_getopt5(const struct HXoption *options_table, char **argv, int *new_argc, char ***new_argv, unsigned int flags); The various fields of ``struct HXoption`` are: @@ -51,10 +51,10 @@ The various fields of ``struct HXoption`` are: ``type`` The type of the entry, essentially denoting the type of the target - variable. + variable (``ptr``). ``val`` - An integer value to be stored into ``*(int *)ptr`` when the option type + An integer value to be stored into ``*(int *)ptr`` if the option type is ``HXTYPE_IVAL``. ``ptr`` @@ -80,18 +80,14 @@ The various fields of ``struct HXoption`` are: 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 +Due to the amount of fields, it is advised to use C99/C++20 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 ======== @@ -206,13 +202,13 @@ 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 +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! + ``*(int *)ptr`` pointer. The referenced variable must be + initialized. ``HXOPT_DEC`` Perform a decrement on the pointee. Same requirements as ``HXOPT_INC``. @@ -271,19 +267,22 @@ Invoking the parser .. code-block:: c - int HX_getopt(const struct HXoption *options_table, int *argc, const char ***argv, unsigned int flags);HX_getopt + int HX_getopt5(const struct HXoption *options_table, char **argv, int *new_argc, char **new_argv, unsigned int flags); + int HX_getopt(const struct HXoption *options_table, int *argc, char ***argv, unsigned int flags); -``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``: +``HX_getopt5`` is the central parsing function. ``options_table`` specifies +the options that the parser will recognize. ``argv`` must be a NULL-terminated +array of C strings. + +If ``new_argv`` is non-NULL, the leftover arguments will be output as a new +string vector on success. (That array can be freed with ``HX_zvecfree``). If +``new_argc`` is non-NULL, the argument count for new_argv will be output too. + +The ``flags`` argument control the general behavior of ``HX_getopt``: ``HXOPT_PTHRU`` - “Passthrough mode”. Any unknown options are not “eaten” and are instead - passed back into the resulting argv array. + “Passthrough mode”. Any unknown options are passed through into + ``new_argv``. ``HXOPT_QUIET`` Do not print any diagnostics when encountering errors in the user's @@ -302,7 +301,7 @@ updated accordingly. Additional flags can control the exact behavior of implicit when the environment variable ``POSIXLY_CORRECT`` is set. ``HXOPT_KEEP_ARGV`` - Do not modify ``argc`` and ``argv`` at all. + Do not set ``*new_argc`` and ``*new_argv`` at all. The return value can be one of the following: @@ -328,6 +327,15 @@ The return value can be one of the following: negative non-zero Failure on behalf of lower-level calls; errno. +``HX_getopt`` is an older API where ``argv`` is both used for input and output. +It recognizes additional flags/has additional behavior: + +``HXOPT_KEEP_ARGV`` + ``argc`` and ``argv`` is not updated. + +``HXOPT_DESTROY_OLD`` + Call ``HX_zvecfree`` on ``argv`` before updating it. + Pitfalls ======== @@ -341,33 +349,28 @@ The following is an example of a possible pitfall regarding ``HXTYPE_STRDQ``: static struct HXdeque *dq; - static bool get_options(int *argc, const char ***argv) + int main(int argc, char **argv) { + dq = HXdeque_init(); 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; + if (HX_getopt5(options_table, *argv, &argc, &argv, + HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + /* ... */ + HX_zvecfree(argv); + return EXIT_SUCCESS; } 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. +problem and have it doing the right thing, the ``static`` qualifier on the +options table must be removed, so that the table is built when that line +executes. -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 ----------- @@ -409,7 +412,7 @@ GNU getopt sample.[#f5] #include #include - int main(int argc, const char **argv) + int main(int argc, char **argv) { int aflag = 0; int bflag = 0; @@ -423,9 +426,8 @@ GNU getopt sample.[#f5] HXOPT_TABLEEND, }; - if (HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR) != - HXOPT_ERR_SUCCESS) - + if (HX_getopt5(options_table, argv, &argc, &argv, + HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) return EXIT_FAILURE; printf("aflag = %d, bflag = %d, cvalue = %s\n", @@ -434,6 +436,7 @@ GNU getopt sample.[#f5] while (*++argv != NULL) printf("Non-option argument %s\n", *argv); + HX_zvecfree(argv); return EXIT_SUCCESS; } @@ -534,42 +537,43 @@ the callback function in ``cb``. {.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. +used to select the next set of accepted options. .. code-block:: c - static bool get_cakes(int *argc, const char ***argv) + static int get_cakes(int *argc, char ***argv) { - struct HXoption option_table[] = { + struct HXoption cake_table[] = { ... }; - return HX_getopt(cake_table, argc, argv, - HXOPT_USAGEONERR | HXOPT_DESTROY_OLD) == HXOPT_ERR_SUCCESS; + if (HX_getopt5(cake_table, *argv, &argc, &argv, + HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + /* ... */ + HX_zvecfree(argv); + return EXIT_SUCCESS; } - static bool get_fruit(int *argc, const char ***argv) + static int fruit_main(int argc, char **argv) { struct HXoption fruit_table[] = { ... }; - return HX_getopt(fruit_table, argc, argv, - HXOPT_USAGEONERR | HXOPT_DESTROY_OLD) == HXOPT_ERR_SUCCESS; + if (HX_getopt5(fruit_table, *argv, &argc, &argv, + HXOPT_PTHRU) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + /* ... */ + HX_zvecfree(argv); + return EXIT_SUCCESS; } - static bool get_options(int *argc, const char ***argv) + int main(int argc, char **argv) { int cake = 0, fruit = 0; struct HXoption option_table[] = { @@ -577,11 +581,10 @@ be freed. {.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; + if (HX_getopt5(option_table, *argv, &argc, &argv, + HXOPT_PTHRU) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + int ret = cake ? cake_main(argc, argv) : fruit_main(argc, argv); + HX_zvecfree(argv); + return EXIT_FAILURE; } diff --git a/doc/string_ops.rst b/doc/string_ops.rst index d818d2d..91da2f6 100644 --- a/doc/string_ops.rst +++ b/doc/string_ops.rst @@ -64,7 +64,7 @@ Extraction .. code-block:: c - int main(int argc, const char **argv) + int main(int argc, char **argv) { if (foo()) fprintf(stderr, "%s: Special condition occurred.\n", diff --git a/include/Makefile.am b/include/Makefile.am index dd74f9a..62ad527 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,6 +1,6 @@ # -*- Makefile -*- -nobase_include_HEADERS = libHX.h \ +nobase_include_HEADERS = libHX.h libHX/cast.h \ libHX/ctype_helper.h libHX/defs.h libHX/deque.h libHX/init.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 \ diff --git a/include/Makefile.in b/include/Makefile.in index 40582cf..8e02ba6 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -202,6 +202,7 @@ EGREP = @EGREP@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -302,7 +303,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -nobase_include_HEADERS = libHX.h \ +nobase_include_HEADERS = libHX.h libHX/cast.h \ libHX/ctype_helper.h libHX/defs.h libHX/deque.h libHX/init.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 \ diff --git a/include/libHX/cast.h b/include/libHX/cast.h new file mode 100644 index 0000000..cb2cba5 --- /dev/null +++ b/include/libHX/cast.h @@ -0,0 +1,129 @@ +#ifndef _LIBHX_CAST_H +#define _LIBHX_CAST_H 1 + +#ifdef __cplusplus +# ifndef const_cast +# define const_cast(T, x) const_cast(x) +# endif +# ifndef static_cast +# define static_cast(T, x) static_cast(x) +# endif +# define const_cast1(type, expr) const_cast(expr) +# define const_cast2(type, expr) const_cast(expr) +# define const_cast3(type, expr) const_cast(expr) + +template +static __inline__ new_type signed_cast(const char *expr) +{ + return reinterpret_cast(expr); +} + +template +static __inline__ new_type signed_cast(const signed char *expr) +{ + return reinterpret_cast(expr); +} + +template +static __inline__ new_type signed_cast(const unsigned char *expr) +{ + return reinterpret_cast(expr); +} + +template +static __inline__ new_type signed_cast(char *expr) +{ + return reinterpret_cast(expr); +} + +template +static __inline__ new_type signed_cast(signed char *expr) +{ + return reinterpret_cast(expr); +} + +template +static __inline__ new_type signed_cast(unsigned char *expr) +{ + return reinterpret_cast(expr); +} + +#else + /* N.B. signed_cast<> does not exist in C++. */ +# define __signed_cast_compatible(a, b) \ + __builtin_choose_expr( \ + __builtin_types_compatible_p(b, const char *) || \ + __builtin_types_compatible_p(b, const signed char *) || \ + __builtin_types_compatible_p(b, const unsigned char *), \ + /* if src has a const qualifier */ \ + __builtin_types_compatible_p(a, const char *) || \ + __builtin_types_compatible_p(a, const signed char *) || \ + __builtin_types_compatible_p(a, const unsigned char *), \ + /* and if it has none... */ \ + __builtin_types_compatible_p(a, const char *) || \ + __builtin_types_compatible_p(a, const signed char *) || \ + __builtin_types_compatible_p(a, const unsigned char *) || \ + __builtin_types_compatible_p(a, char *) || \ + __builtin_types_compatible_p(a, signed char *) || \ + __builtin_types_compatible_p(a, unsigned char *) \ + ) + +# if defined(__GNUC__) && !defined(__clang__) && !defined(signed_cast) +# define signed_cast(type, expr) ({ \ + BUILD_BUG_ON(!__signed_cast_compatible(__typeof__(type), __typeof__(expr))); \ + (type)(expr); \ + }) +# endif +# if defined(__GNUC__) && !defined(__clang__) && !defined(static_cast) +# define static_cast(type, expr) \ + ((struct { type x; }){(expr)}.x) +# endif +# if defined(__GNUC__) && !defined(__clang__) && !defined(const_cast1) + /* + * The idea starts with (in abstract notation) + * typeof deref typeof expr + * To deref something, we need an object, which we can get by + * creating a temporary aggregate, such as a union, of which + * the member is accessed and dereferenced. + * *(union { __typeof__(expr) x; }){init}.x + * union has two nice properties: + * - with an additional dummy member, we do not have to + * initialize x according to its type, which, if expr is + * an array type, may want extra braces. + * - and with that dummy member, we also avoid the ugly + * "literal 0 is implicitly convertible to a pointer". + * Unfortunately, this all requires C99 compound initializers. + * That's ok - gcc and clang only treat it as a warning even + * under strict C89 - and if you still force strict C89 on + * yourself, you have a lot to answer for either way. + */ +# define __const_cast_strip(ptrs, expr) \ + __typeof__(ptrs(union { int z; __typeof__(expr) x; }){0}.x) +# define __const_cast_p(ptrs, new_type, expr) ((new_type)( \ + (expr) + \ + BUILD_BUG_ON_EXPR(!__builtin_types_compatible_p(__const_cast_strip(ptrs, expr), __const_cast_strip(ptrs, new_type))) \ + )) +# define const_cast1(new_type, expr) __const_cast_p(*, new_type, expr) +# define const_cast2(new_type, expr) __const_cast_p(**, new_type, expr) +# define const_cast3(new_type, expr) __const_cast_p(***, new_type, expr) +# endif +# ifndef signed_cast +# define signed_cast(type, expr) ((type)(expr)) +# endif +# ifndef static_cast +# define static_cast(type, expr) ((type)(expr)) +# endif +# ifndef const_cast +# define const_cast(type, expr) ((type)(expr)) +# endif +# ifndef const_cast1 +# define const_cast1(type, expr) ((type)(expr)) +# define const_cast2(type, expr) ((type)(expr)) +# define const_cast3(type, expr) ((type)(expr)) +# endif +# ifndef reinterpret_cast +# define reinterpret_cast(type, expr) ((type)(expr)) +# endif +#endif + +#endif /* _LIBHX_CAST_H */ diff --git a/include/libHX/defs.h b/include/libHX/defs.h index 9d17019..31c818f 100644 --- a/include/libHX/defs.h +++ b/include/libHX/defs.h @@ -1,6 +1,7 @@ #ifndef _LIBHX_DEFS_H #define _LIBHX_DEFS_H 1 +#include #ifdef __cplusplus # define HXsizeof_member(type, member) sizeof(type::member) # if __cplusplus >= 201100L @@ -13,123 +14,9 @@ # include # define containerof(var, T, member) reinterpret_cast::type>::value, std::add_const::type, T>::type *>(reinterpret_cast::type>::value, const char, char>::type *>(var) - offsetof(T, member)) # endif -# ifndef static_cast -# define static_cast(T, x) static_cast(x) -# endif - -template -static __inline__ new_type signed_cast(const char *expr) -{ - return reinterpret_cast(expr); -} - -template -static __inline__ new_type signed_cast(const signed char *expr) -{ - return reinterpret_cast(expr); -} - -template -static __inline__ new_type signed_cast(const unsigned char *expr) -{ - return reinterpret_cast(expr); -} - -template -static __inline__ new_type signed_cast(char *expr) -{ - return reinterpret_cast(expr); -} - -template -static __inline__ new_type signed_cast(signed char *expr) -{ - return reinterpret_cast(expr); -} - -template -static __inline__ new_type signed_cast(unsigned char *expr) -{ - return reinterpret_cast(expr); -} #else # define HXsizeof_member(type, member) sizeof(((type *)NULL)->member) # define HXtypeof_member(type, member) __typeof__(((type *)NULL)->member) - /* N.B. signed_cast<> does not exist in C++. */ -# define __signed_cast_compatible(a, b) \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(b, const char *) || \ - __builtin_types_compatible_p(b, const signed char *) || \ - __builtin_types_compatible_p(b, const unsigned char *), \ - /* if src has a const qualifier */ \ - __builtin_types_compatible_p(a, const char *) || \ - __builtin_types_compatible_p(a, const signed char *) || \ - __builtin_types_compatible_p(a, const unsigned char *), \ - /* and if it has none... */ \ - __builtin_types_compatible_p(a, const char *) || \ - __builtin_types_compatible_p(a, const signed char *) || \ - __builtin_types_compatible_p(a, const unsigned char *) || \ - __builtin_types_compatible_p(a, char *) || \ - __builtin_types_compatible_p(a, signed char *) || \ - __builtin_types_compatible_p(a, unsigned char *) \ - ) - -# if defined(__GNUC__) && !defined(__clang__) && !defined(signed_cast) -# define signed_cast(type, expr) ({ \ - BUILD_BUG_ON(!__signed_cast_compatible(__typeof__(type), __typeof__(expr))); \ - (type)(expr); \ - }) -# endif -# if defined(__GNUC__) && !defined(__clang__) && !defined(static_cast) -# define static_cast(type, expr) \ - ((struct { type x; }){(expr)}.x) -# endif -# if defined(__GNUC__) && !defined(__clang__) && !defined(const_cast1) - /* - * The idea starts with (in abstract notation) - * typeof deref typeof expr - * To deref something, we need an object, which we can get by - * creating a temporary aggregate, such as a union, of which - * the member is accessed and dereferenced. - * *(union { __typeof__(expr) x; }){init}.x - * union has two nice properties: - * - with an additional dummy member, we do not have to - * initialize x according to its type, which, if expr is - * an array type, may want extra braces. - * - and with that dummy member, we also avoid the ugly - * "literal 0 is implicitly convertible to a pointer". - * Unfortunately, this all requires C99 compound initializers. - * That's ok - gcc and clang only treat it as a warning even - * under strict C89 - and if you still force strict C89 on - * yourself, you have a lot to answer for either way. - */ -# define __const_cast_strip(ptrs, expr) \ - __typeof__(ptrs(union { int z; __typeof__(expr) x; }){0}.x) -# define __const_cast_p(ptrs, new_type, expr) ((new_type)( \ - (expr) + \ - BUILD_BUG_ON_EXPR(!__builtin_types_compatible_p(__const_cast_strip(ptrs, expr), __const_cast_strip(ptrs, new_type))) \ - )) -# define const_cast1(new_type, expr) __const_cast_p(*, new_type, expr) -# define const_cast2(new_type, expr) __const_cast_p(**, new_type, expr) -# define const_cast3(new_type, expr) __const_cast_p(***, new_type, expr) -# endif -# ifndef signed_cast -# define signed_cast(type, expr) ((type)(expr)) -# endif -# ifndef static_cast -# define static_cast(type, expr) ((type)(expr)) -# endif -# ifndef const_cast -# define const_cast(type, expr) ((type)(expr)) -# endif -# ifndef const_cast1 -# define const_cast1(type, expr) ((type)(expr)) -# define const_cast2(type, expr) ((type)(expr)) -# define const_cast3(type, expr) ((type)(expr)) -# endif -# ifndef reinterpret_cast -# define reinterpret_cast(type, expr) ((type)(expr)) -# endif # ifndef containerof # include # define containerof(var, type, member) reinterpret_cast(type *, \ diff --git a/include/libHX/misc.h b/include/libHX/misc.h index 1d49c7f..ac381dc 100644 --- a/include/libHX/misc.h +++ b/include/libHX/misc.h @@ -79,7 +79,10 @@ extern struct timespec *HX_timespec_mulf(struct timespec *, extern struct timeval *HX_timeval_sub(struct timeval *, const struct timeval *, const struct timeval *); extern long HX_time_compare(const struct stat *, const struct stat *, char); +#ifndef LIBHX_ZVECFREE_DECLARATION +#define LIBHX_ZVECFREE_DECLARATION extern void HX_zvecfree(char **); +#endif /* * RAND.C diff --git a/include/libHX/option.h b/include/libHX/option.h index 40cc6e7..ef9c626 100644 --- a/include/libHX/option.h +++ b/include/libHX/option.h @@ -8,6 +8,7 @@ # include # include #endif +#include #ifdef __cplusplus extern "C" { @@ -228,8 +229,13 @@ struct HXoption { const char *help, *htyp; }; -extern int HX_getopt(const struct HXoption *, int *, const char ***, - unsigned int); +#ifndef LIBHX_ZVECFREE_DECLARATION +#define LIBHX_ZVECFREE_DECLARATION +extern void HX_zvecfree(char **); +#endif +extern int HX_getopt(const struct HXoption *, int *, char ***, unsigned int); +extern int HX_getopt5(const struct HXoption *, char **argv, int *nargc, char ***nargv, unsigned int flags); +#define HX_getopt(a, b, c, d) HX_getopt((a), (b), const_cast3(char ***, (c)), (d)) extern void HX_getopt_help(const struct HXoptcb *, FILE *); extern void HX_getopt_help_cb(const struct HXoptcb *); extern void HX_getopt_usage(const struct HXoptcb *, FILE *); 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 . ]) -# 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 diff --git a/src/Makefile.am b/src/Makefile.am index ac68f74..676cd73 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,15 +5,11 @@ AM_CFLAGS = ${regular_CFLAGS} AM_CXXFLAGS = ${regular_CXXFLAGS} lib_LTLIBRARIES = libHX.la -if HAVE_DLFCN_H -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 proc.c \ rand.c socket.c string.c time.c libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} ${libsocket_LIBS} -libHX_la_LDFLAGS = -no-undefined -version-info 38:0:6 +libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7 if WITH_GNU_LD libHX_la_LDFLAGS += -Wl,--version-script=${srcdir}/libHX.map endif @@ -24,21 +20,14 @@ libHX_la_SOURCES += ux-file.c ux-mmap.c libHX_la_LIBADD += -lws2_32 endif -libHX_rtcheck_la_SOURCES = rtcheck.c -libHX_rtcheck_la_LIBADD = ${libdl_LIBS} -libHX_rtcheck_la_LDFLAGS = -no-undefined -avoid-version -module -if WITH_GNU_LD -libHX_rtcheck_la_LDFLAGS += -Wl,--version-script=${srcdir}/libHX.map -endif - -EXTRA_DIST = internal.h map_int.h libHX.map +EXTRA_DIST = internal.h map_int.h libHX.map uxcompat.h analyze.sh 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-socket tc-strchr2 tc-string tc-strquote \ tc-switchuser tc-time -TESTS = tc-format tc-strchr2 tc-strquote +TESTS = tc-format tc-option tc-strchr2 tc-string tc-strquote tc_cast_CFLAGS = ${AM_CFLAGS} -std=gnu99 tc_cast_LDADD = libHX.la -lm tc_compile_LDADD = libHX.la diff --git a/src/Makefile.in b/src/Makefile.in index d349749..7e1bd81 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -90,11 +90,9 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ 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 -@MINGW32_TRUE@am__append_4 = -lws2_32 -@WITH_GNU_LD_TRUE@am__append_5 = -Wl,--version-script=${srcdir}/libHX.map +@WITH_GNU_LD_TRUE@am__append_1 = -Wl,--version-script=${srcdir}/libHX.map +@MINGW32_TRUE@am__append_2 = ux-file.c ux-mmap.c +@MINGW32_TRUE@am__append_3 = -lws2_32 check_PROGRAMS = tc-compile$(EXEEXT) tc-cast$(EXEEXT) \ tc-deque$(EXEEXT) tc-dir$(EXEEXT) tc-format$(EXEEXT) \ tc-io$(EXEEXT) tc-list$(EXEEXT) tc-list2$(EXEEXT) \ @@ -104,15 +102,15 @@ check_PROGRAMS = tc-compile$(EXEEXT) tc-cast$(EXEEXT) \ 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 \ +TESTS = tc-format$(EXEEXT) tc-option$(EXEEXT) tc-strchr2$(EXEEXT) \ + tc-string$(EXEEXT) tc-strquote$(EXEEXT) $(am__EXEEXT_2) +@HAVE_CXX_TRUE@am__append_4 = 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 -@HAVE_CXX_TRUE@am__append_7 = tx-strchr2 tx-strquote +@HAVE_CXX_TRUE@am__append_5 = tx-strchr2 tx-strquote subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/gcc4_visibility.m4 \ @@ -182,14 +180,6 @@ am__v_lt_1 = libHX_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libHX_la_LDFLAGS) $(LDFLAGS) -o $@ -libHX_rtcheck_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_libHX_rtcheck_la_OBJECTS = rtcheck.lo -libHX_rtcheck_la_OBJECTS = $(am_libHX_rtcheck_la_OBJECTS) -libHX_rtcheck_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(libHX_rtcheck_la_LDFLAGS) $(LDFLAGS) \ - -o $@ -@HAVE_DLFCN_H_TRUE@am_libHX_rtcheck_la_rpath = -rpath $(libdir) tc_cast_SOURCES = tc-cast.c tc_cast_OBJECTS = tc_cast-tc-cast.$(OBJEXT) tc_cast_DEPENDENCIES = libHX.la @@ -351,19 +341,18 @@ 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)/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 \ @@ -411,31 +400,31 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) 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-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-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 \ +SOURCES = $(libHX_la_SOURCES) tc-cast.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-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) \ - $(am__tx_strchr2_SOURCES_DIST) $(am__tx_string_SOURCES_DIST) \ - $(am__tx_strquote_SOURCES_DIST) $(am__tx_time_SOURCES_DIST) + $(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) tc-cast.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-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) $(am__tx_strchr2_SOURCES_DIST) \ + $(am__tx_string_SOURCES_DIST) $(am__tx_strquote_SOURCES_DIST) \ + $(am__tx_time_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -672,6 +661,7 @@ EGREP = @EGREP@ ETAGS = @ETAGS@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FILECMD = @FILECMD@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ @@ -775,18 +765,14 @@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include AM_CFLAGS = ${regular_CFLAGS} AM_CXXFLAGS = ${regular_CXXFLAGS} -lib_LTLIBRARIES = libHX.la $(am__append_1) +lib_LTLIBRARIES = libHX.la libHX_la_SOURCES = deque.c dl.c format.c io.c map.c mc.c misc.c opt.c \ - proc.c rand.c socket.c string.c time.c $(am__append_3) + proc.c rand.c socket.c string.c time.c $(am__append_2) libHX_la_LIBADD = ${libdl_LIBS} -lm ${libpthread_LIBS} ${librt_LIBS} \ - ${libsocket_LIBS} $(am__append_4) -libHX_la_LDFLAGS = -no-undefined -version-info 38:0:6 $(am__append_2) + ${libsocket_LIBS} $(am__append_3) +libHX_la_LDFLAGS = -no-undefined -version-info 39:0:7 $(am__append_1) EXTRA_libHX_la_DEPENDENCIES = libHX.map -libHX_rtcheck_la_SOURCES = rtcheck.c -libHX_rtcheck_la_LIBADD = ${libdl_LIBS} -libHX_rtcheck_la_LDFLAGS = -no-undefined -avoid-version -module \ - $(am__append_5) -EXTRA_DIST = internal.h map_int.h libHX.map +EXTRA_DIST = internal.h map_int.h libHX.map uxcompat.h analyze.sh tc_cast_CFLAGS = ${AM_CFLAGS} -std=gnu99 tc_cast_LDADD = libHX.la -lm tc_compile_LDADD = libHX.la @@ -923,9 +909,6 @@ clean-libLTLIBRARIES: libHX.la: $(libHX_la_OBJECTS) $(libHX_la_DEPENDENCIES) $(EXTRA_libHX_la_DEPENDENCIES) $(AM_V_CCLD)$(libHX_la_LINK) -rpath $(libdir) $(libHX_la_OBJECTS) $(libHX_la_LIBADD) $(LIBS) -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) - 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) @@ -1098,7 +1081,6 @@ distclean-compile: @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 @@ -1446,6 +1428,13 @@ tc-format.log: tc-format$(EXEEXT) --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-option.log: tc-option$(EXEEXT) + @p='tc-option$(EXEEXT)'; \ + b='tc-option'; \ + $(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'; \ @@ -1453,6 +1442,13 @@ tc-strchr2.log: tc-strchr2$(EXEEXT) --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-string.log: tc-string$(EXEEXT) + @p='tc-string$(EXEEXT)'; \ + b='tc-string'; \ + $(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-strquote.log: tc-strquote$(EXEEXT) @p='tc-strquote$(EXEEXT)'; \ b='tc-strquote'; \ @@ -1581,7 +1577,6 @@ distclean: distclean-am -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 @@ -1681,7 +1676,6 @@ maintainer-clean: maintainer-clean-am -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 diff --git a/src/analyze.sh b/src/analyze.sh new file mode 100755 index 0000000..042998f --- /dev/null +++ b/src/analyze.sh @@ -0,0 +1,3 @@ +#!/bin/sh +f="--analyze -Xanalyzer -analyzer-output=text -Wall -g3" +make -k check CC=clang CXX=clang++ CFLAGS="$f" CXXFLAGS="$f" diff --git a/src/internal.h b/src/internal.h index 0465d81..f7d83d8 100644 --- a/src/internal.h +++ b/src/internal.h @@ -11,15 +11,12 @@ #include "config.h" #include +#include #include #include #ifdef __cplusplus /* Only for our dual C/C++ testsuites */ -# define const_cast(type, expr) const_cast(expr) -# define const_cast1(type, expr) const_cast(expr) -# define const_cast2(type, expr) const_cast(expr) -# define const_cast3(type, expr) const_cast(expr) # define dynamic_cast(type, expr) dynamic_cast(expr) # define signed_cast(type, expr) signed_cast(expr) # define reinterpret_cast(type, expr) reinterpret_cast(expr) diff --git a/src/libHX.map b/src/libHX.map index 37bfe0f..374a881 100644 --- a/src/libHX.map +++ b/src/libHX.map @@ -178,3 +178,8 @@ LIBHX_4.16 { global: HX_strtoull_nsec; } LIBHX_4.15; + +LIBHX_4.18 { +global: + HX_getopt5; +} LIBHX_4.16; diff --git a/src/opt.c b/src/opt.c index f91785d..ab482ad 100644 --- a/src/opt.c +++ b/src/opt.c @@ -20,6 +20,7 @@ #include #include #include +#undef HX_getopt #include "internal.h" /* Definitions */ @@ -697,16 +698,19 @@ static int HX_getopt_normal(const char *cur, const struct HX_getopt_vars *par) return HXOPT_S_NORMAL | HXOPT_I_ADVARG; } -EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, - const char ***argv, unsigned int flags) +EXPORT_SYMBOL int HX_getopt5(const struct HXoption *table, char **orig_argv, + int *new_argc, char ***new_argv, unsigned int flags) { struct HX_getopt_vars ps; - const char **opt = *argv; + const char **opt = const_cast(const char **, orig_argv); int state = HXOPT_S_NORMAL; int ret = -ENOMEM; - unsigned int argk; - const char *cur; + unsigned int argk = 0; + if (new_argc != nullptr) + *new_argc = 0; + if (new_argv != nullptr) + *new_argv = nullptr; memset(&ps, 0, sizeof(ps)); ps.remaining = HXdeque_init(); if (ps.remaining == NULL) { @@ -714,7 +718,7 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, goto out; } ps.flags = flags; - ps.arg0 = **argv; + ps.arg0 = *opt; ps.cbi.table = table; if (*opt != NULL) { @@ -733,7 +737,7 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, if (posix_me_harder()) ps.flags |= HXOPT_RQ_ORDER; - for (cur = *opt; cur != NULL; ) { + for (const char *cur = *opt; cur != NULL; ) { if (state == HXOPT_S_TWOLONG) state = HX_getopt_twolong(opt, &ps); else if (state == HXOPT_S_LONG) @@ -764,33 +768,19 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, state &= ~HXOPT_I_MASK; } - if (!(ps.flags & HXOPT_KEEP_ARGV)) { - const char **nvec = reinterpret_cast(const char **, - HXdeque_to_vec(ps.remaining, &argk)); - if (nvec == NULL) { + if (new_argv != nullptr) { + *new_argv = reinterpret_cast(char **, HXdeque_to_vec(ps.remaining, &argk)); + if (*new_argv == nullptr) { ret = -errno; goto out; } - if (ps.flags & HXOPT_DESTROY_OLD) - /* - * Only the "true, original" argv is stored on the - * stack - the argv that HX_getopt() produces is on - * the heap, so the %HXOPT_DESTROY_OLD flag should be - * passed when you use passthrough chaining, i.e. all - * but the first call to HX_getopt() should have this - * set. - */ - HX_zvecfree(const_cast2(char **, *argv)); - - *argv = nvec; - if (argc != NULL) - *argc = argk; - /* pointers are owned by nvec/argv now */ + if (new_argc != nullptr) + *new_argc = argk; + /* pointers are owned by new_argv now, so free only the deque head */ HXdeque_free(ps.remaining); ps.remaining = nullptr; } ret = HXOPT_ERR_SUCCESS; - out: if (ret == HXOPT_ERR_SUCCESS) { } else if (ret < 0) { @@ -808,6 +798,26 @@ EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, return ret; } +EXPORT_SYMBOL int HX_getopt(const struct HXoption *table, int *argc, + char ***argv, unsigned int flags) +{ + int new_argc = 0; + char **new_argv = nullptr; + int ret = HX_getopt5(table, *argv, &new_argc, + flags & HXOPT_KEEP_ARGV ? nullptr : &new_argv, flags); + if (ret != HXOPT_ERR_SUCCESS) + return ret; + if (flags & HXOPT_KEEP_ARGV) + // NO_CREATE_NEW / DESTROY_NEW + new_argv = *argv; + else if (flags & HXOPT_DESTROY_OLD) + HX_zvecfree(*argv); + if (argc != nullptr) + *argc = new_argc; + *argv = new_argv; + return ret; +} + EXPORT_SYMBOL void HX_getopt_help(const struct HXoptcb *cbi, FILE *nfp) { FILE *fp = (nfp == NULL) ? stderr : nfp; diff --git a/src/proc.c b/src/proc.c index 801023b..c8957b6 100644 --- a/src/proc.c +++ b/src/proc.c @@ -103,7 +103,7 @@ EXPORT_SYMBOL enum HXproc_su_status HXproc_switch_user(const char *user, const c #else -EXPORT_SYMBOL int HXproc_switch_user(const char *user, const char *group) +EXPORT_SYMBOL enum HXproc_su_status HXproc_switch_user(const char *user, const char *group) { return -ENOSYS; } diff --git a/src/rtcheck.c b/src/rtcheck.c deleted file mode 100644 index 6f04baa..0000000 --- a/src/rtcheck.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Additional runtime checks - * Copyright Jan Engelhardt, 2011 - * - * 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. - * - * libHX_rtcheck.so is a library supposed to be used together with the - * LD_PRELOAD environment variable to dynamically add extra checks. - */ -#define _GNU_SOURCE 1 -#ifdef HAVE_DLFCN_H -#include -#ifdef RTLD_NEXT - -#include -#include -#include -#include -#include -#include "internal.h" - -#define call_next(f) \ - ((__typeof__(f) *)dlsym(RTLD_NEXT, #f)) - -#define stub_head(f, args, invoke) \ - EXPORT_SYMBOL __typeof__(f invoke) f args \ - { \ - if (HXrefchk_count <= 0) \ - fprintf(stderr, "%s: HX_init has not been called!\n", \ - __func__); - -#define stub_tail(f, params) \ - return call_next(f) params; \ - } - -#define stub(f, args, invoke, params) \ - stub_head(f, args, invoke) \ - stub_tail(f, params) - -#define stubv(f, args, params) \ - EXPORT_SYMBOL void f args \ - { \ - if (HXrefchk_count <= 0) \ - fprintf(stderr, "%s: HX_init has not been called!\n", \ - __func__); \ - call_next(f) params; \ - } - -#define stub0(f) stub(f, (void), (), ()) -#define stub1(f, args) stub(f, args, (0), (a)) -#define stub1v(f, args) stubv(f, args, (a)) -#define stub2(f, args) stub(f, args, (0, 0), (a, b)) -#define stub2v(f, args) stubv(f, args, (a, b)) -#define stub3(f, args) stub(f, args, (0, 0, 0), (a, b, c)) -#define stub3v(f, args) stubv(f, args, (a, b, c)) -#define stub4(f, args) stub(f, args, (0, 0, 0, 0), (a, b, c, d)) -#define stub5(f, args) stub(f, args, (0, 0, 0, 0, 0), (a, b, c, d, e)) - -static pthread_mutex_t HXrefchk_lock = PTHREAD_MUTEX_INITIALIZER; -static unsigned long HXrefchk_count; - -EXPORT_SYMBOL int HX_init(void) -{ - /* - * The real HX_init has its own reference count check, but that - * variable is not exported that we could test it, so the counter needs - * to be replicated here. - */ - pthread_mutex_lock(&HXrefchk_lock); - if (HXrefchk_count == 0) { - printf("# " PACKAGE_NAME " " PACKAGE_VERSION - " runtime checker active\n"); - call_next(HX_init)(); - } - ++HXrefchk_count; - pthread_mutex_unlock(&HXrefchk_lock); - return 1; -} - -EXPORT_SYMBOL void HX_exit(void) -{ - pthread_mutex_lock(&HXrefchk_lock); - if (HXrefchk_count == 0) - fprintf(stderr, "%s: reference count is already zero!\n", __func__); - else - --HXrefchk_count; - pthread_mutex_unlock(&HXrefchk_lock); - call_next(HX_exit)(); -} - -/* deque.h */ -stub0(HXdeque_init); -stub2(HXdeque_push, (struct HXdeque *a, const void *b)); -stub2(HXdeque_unshift, (struct HXdeque *a, const void *b)); -stub1(HXdeque_pop, (struct HXdeque *a)); -stub1(HXdeque_shift, (struct HXdeque *a)); -stub2(HXdeque_move, (struct HXdeque_node *a, struct HXdeque_node *b)); -stub2(HXdeque_find, (struct HXdeque *a, const void *b)); -stub2(HXdeque_get, (struct HXdeque *a, const void *b)); -stub1(HXdeque_del, (struct HXdeque_node *a)); -stub1v(HXdeque_free, (struct HXdeque *a)); -stub2v(HXdeque_genocide2, (struct HXdeque *a, void (*b)(void *))); -stub2(HXdeque_to_vec, (const struct HXdeque *a, unsigned int *b)); - -/* io.h */ -stub1(HXdir_open, (const char *a)); -stub1(HXdir_read, (struct HXdir *a)); -stub1v(HXdir_close, (struct HXdir *a)); -/* HX_copy_dir: has varargs */ -/* HX_copy_file: has varargs */ -stub2(HX_mkdir, (const char *a, unsigned int b)); -stub2(HX_readlink, (hxmc_t **a, const char *b)); -stub3(HX_realpath, (hxmc_t **a, const char *b, unsigned int c)); -stub1(HX_rrmdir, (const char *a)); - -stub3(HXio_fullread, (int a, void *b, size_t c)); -stub3(HXio_fullwrite, (int a, const void *b, size_t c)); - -/* map.h */ -stub2(HXmap_init, (enum HXmap_type a, unsigned int b)); -stub5(HXmap_init5, (enum HXmap_type a, unsigned int b, - const struct HXmap_ops *c, size_t d, size_t e)); -stub3(HXmap_add, (struct HXmap *a, const void *b, const void *c)); -stub2(HXmap_find, (const struct HXmap *a, const void *b)); -stub2(HXmap_get, (const struct HXmap *a, const void *b)); -stub2(HXmap_del, (struct HXmap *a, const void *b)); -stub1(HXmap_keysvalues, (const struct HXmap *a)); -stub2(HXmap_travinit, (const struct HXmap *a, unsigned int b)); -stub1(HXmap_traverse, (struct HXmap_trav *a)); -stub1v(HXmap_travfree, (struct HXmap_trav *a)); -stub3v(HXmap_qfe, (const struct HXmap *a, - bool (*b)(const struct HXmap_node *, void *), void *c)); -stub1v(HXmap_free, (struct HXmap *a)); - -/* misc.h */ -stub1(HX_dlopen, (const char *a)); -stub2(HX_dlsym, (void *a, const char *b)); -stub1v(HX_dlclose, (void *a)); -stub0(HX_dlerror); - -stub1(HX_ffs, (unsigned long a)); -stub1(HX_fls, (unsigned long a)); -stub3(HX_hexdump, (FILE *a, const void *b, unsigned int c)); -stub3(HX_timespec_add, (struct timespec *a, const struct timespec *b, - const struct timespec *c)); -stub1(HX_timespec_isneg, (const struct timespec *a)); -stub3(HX_timespec_mul, (struct timespec *a, const struct timespec *b, int c)); -stub3(HX_timespec_mulf, (struct timespec *a, const struct timespec *b, - double c)); -stub2(HX_timespec_neg, (struct timespec *a, const struct timespec *b)); -stub3(HX_timespec_sub, (struct timespec *a, const struct timespec *b, - const struct timespec *c)); -stub3(HX_timeval_sub, (struct timeval *a, const struct timeval *b, - const struct timeval *c)); -stub3(HX_time_compare, (const struct stat *a, const struct stat *b, char c)); -stub1v(HX_zvecfree, (char **a)); - -stub0(HX_rand); -stub2(HX_irand, (unsigned int a, unsigned int b)); -stub2(HX_drand, (double a, double b)); - -/* option.h */ -stub0(HXformat_init); -stub1v(HXformat_free, (struct HXformat_map *a)); -stub4(HXformat_add, (struct HXformat_map *a, const char *b, const void *c, - unsigned int d)); -stub3(HXformat_aprintf, (const struct HXformat_map *a, hxmc_t **b, - const char *c)); -stub4(HXformat_sprintf, (const struct HXformat_map *a, char *b, size_t c, - const char *d)); -stub3(HXformat_fprintf, (const struct HXformat_map *a, FILE *b, - const char *c)); - -stub4(HX_getopt, (const struct HXoption *a, int *b, const char ***c, - unsigned int d)); -/* HX_getopt_help: not really public */ -/* HX_getopt_help_cb: not really public */ -/* HX_getopt_usage: not really public */ -/* HX_getopt_usage_cb: not really public */ -stub2(HX_shconfig, (const char *a, const struct HXoption *b)); -stub1(HX_shconfig_map, (const char *a)); -stub4(HX_shconfig_pv, (const char **a, const char *b, const struct HXoption *c, - unsigned int d)); -stub1v(HX_shconfig_free, (const struct HXoption *a)); - -/* proc.h */ -stub2(HXproc_run_async, (const char *const *a, struct HXproc *b)); -stub2(HXproc_run_sync, (const char *const *a, unsigned int b)); -stub1(HXproc_wait, (struct HXproc *a)); - -/* string.h */ -static __inline__ struct memcont *HXmc_base(const hxmc_t *p) -{ - return containerof(p, struct memcont, data); -} - -static __inline__ void HXmc_check(const char *func, const void *cv) -{ - const struct memcont *c; - - if (cv == NULL) - return; - c = HXmc_base(cv); - if (c->id != HXMC_IDENT) - fprintf(stderr, "%s: %p is not a HXmc object!\n", func, cv); -} - -stub1(HXmc_strinit, (const char *a)); -stub2(HXmc_meminit, (const void *a, size_t b)); - -stub_head(HXmc_strcpy, (hxmc_t **a, const char *b), (0, 0)) -{ - if (*a != NULL) - HXmc_check(__func__, *a); -} -stub_tail(HXmc_strcpy, (a, b)) - -stub_head(HXmc_memcpy, (hxmc_t **a, const void *b, size_t c), (0, 0, 0)) -{ - if (*a != NULL) - HXmc_check(__func__, *a); -} -stub_tail(HXmc_memcpy, (a, b, c)) - -stub_head(HXmc_length, (const hxmc_t *a), (0)) -{ - if (a != NULL) - HXmc_check(__func__, a); -} -stub_tail(HXmc_length, (a)) - -stub2(HXmc_setlen, (hxmc_t **a, size_t b)); -stub2(HXmc_trunc, (hxmc_t **a, size_t b)); -stub2(HXmc_strcat, (hxmc_t **a, const char *b)); -stub3(HXmc_memcat, (hxmc_t **a, const void *b, size_t c)); -stub2(HXmc_strpcat, (hxmc_t **a, const char *b)); -stub3(HXmc_mempcat, (hxmc_t **a, const void *b, size_t c)); -stub3(HXmc_strins, (hxmc_t **a, size_t b, const char *c)); -stub4(HXmc_memins, (hxmc_t **a, size_t b, const void *c, size_t d)); -stub3(HXmc_memdel, (hxmc_t *a, size_t b, size_t c)); -stub1v(HXmc_free, (hxmc_t *a)); -stub1v(HXmc_zvecfree, (hxmc_t **a)); - -stub1(HX_basename, (const char *a)); -stub1(HX_basename_exact, (const char *a)); -stub1(HX_chomp, (char *a)); -stub1(HX_dirname, (const char *a)); -stub2(HX_getl, (hxmc_t **a, FILE *b)); -stub4(HX_memmem, (const void *a, size_t b, const void *c, size_t d)); -stub4(HX_split, (const char *a, const char *b, int *c, int d)); -stub4(HX_split_inplace, (char *a, const char *b, int *c, int d)); -stub4(HX_split_fixed, (char *a, const char *b, int c, char **d)); -stub1(HX_stpltrim, (const char *a)); -stub1(HX_stprtrim, (char *a)); -stub3(HX_strbchr, (const char *a, const char *b, char c)); -stub2(HX_strclone, (char **a, const char *b)); -stub1(HX_strlower, (char *a)); -stub1(HX_strltrim, (char *a)); -stub3(HX_strmid, (const char *a, long b, long c)); -stub2(HX_strndup, (const char *a, size_t b)); -stub2(HX_strnlen, (const char *a, size_t b)); -stub3(HX_strquote, (const char *a, unsigned int b, char **c)); -stub2(HX_strrcspn, (const char *a, const char *b)); -stub1(HX_strrev, (char *a)); -stub1(HX_strrtrim, (char *a)); -stub2(HX_strsep, (char **a, const char *b)); -stub2(HX_strsep2, (char **a, const char *b)); -stub1(HX_strupper, (char *a)); - -#endif /* RTLD_NEXT */ -#endif /* HAVE_DLFCN_H */ diff --git a/src/socket.c b/src/socket.c index e2ad9ed..9fdd903 100644 --- a/src/socket.c +++ b/src/socket.c @@ -394,13 +394,15 @@ EXPORT_SYMBOL int HX_socket_from_env(const struct addrinfo *ai, const char *intf } top_fd = x; } - for (int fd = 3; fd < top_fd; ++fd) - if (try_sk_from_env(fd, ai, intf) == fd) { + for (int fd = 3; fd < top_fd; ++fd) { + if (try_sk_from_env(fd, ai, intf) != fd) + continue; #ifdef SOCK_CLOEXEC - fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC); + if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC) != 0) + /* ignore */; #endif - return fd; - } + return fd; + } errno = ENOENT; return -1; } diff --git a/src/string.c b/src/string.c index 4abd694..06066ce 100644 --- a/src/string.c +++ b/src/string.c @@ -980,6 +980,7 @@ EXPORT_SYMBOL double HX_strtod_unit(const char *s, char **out_end, unsigned int if (end == s) { if (out_end != nullptr) *out_end = end; + errno = 0; return q; } while (HX_isspace(*end)) @@ -988,10 +989,12 @@ EXPORT_SYMBOL double HX_strtod_unit(const char *s, char **out_end, unsigned int if (pwr == 0) { if (out_end != nullptr) *out_end = const_cast(char *, end); + errno = 0; return q; } if (out_end != nullptr) *out_end = const_cast(char *, end + 1); + errno = 0; return q * pow(exponent, pwr); } @@ -1001,17 +1004,45 @@ EXPORT_SYMBOL unsigned long long HX_strtoull_unit(const char *s, char *end; unsigned long long ipart; unsigned int pwr = 0; + bool neg = false; while (HX_isspace(*s)) ++s; + if (*s == '-') { + /* + * "-5k": While (-5ULL) * 1000 is the same as (-5000ULL) under + * modulo arithmetic, the expression `ipart >= ULLONG_MAX / + * exponent` depends on seeing the true value (5 rather than + * (-5ULL).) + */ + neg = true; + ++s; + } + errno = 0; ipart = strtoull(s, &end, 10); + if (ipart == ULLONG_MAX && errno == ERANGE) + return ipart; 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) + if (!hi_ok || !lo_ok) { + errno = ERANGE; return ULLONG_MAX; - return q; + } + /* + * https://eel.is/c++draft/conv.fpint: values unrepresentable + * in the target type (such as forcing -5.2f into a uint) is + * UB. Thus check for range and apply the negation after the + * conversion to ULL. + */ + if (q > ULLONG_MAX) { + errno = ERANGE; + return ULLONG_MAX; + } + unsigned long long r = q; + errno = 0; + return neg ? -r : r; } if (exponent == 0) exponent = 1000; @@ -1021,7 +1052,8 @@ EXPORT_SYMBOL unsigned long long HX_strtoull_unit(const char *s, if (pwr == 0) { if (out_end != nullptr) *out_end = end; - return ipart; + errno = 0; + return neg ? -ipart: ipart; } if (out_end != nullptr) *out_end = const_cast(char *, end + 1); @@ -1032,11 +1064,13 @@ EXPORT_SYMBOL unsigned long long HX_strtoull_unit(const char *s, } ipart *= exponent; } - return ipart; + errno = 0; + return neg ? -ipart : ipart; } -#define SECONDS_PER_YEAR 31557600 -#define SECONDS_PER_MONTH 2629800 +/* Numbers also used by systemd — the focus is on longterm averages */ +#define SECONDS_PER_YEAR 31557600 /* 365.25 days */ +#define SECONDS_PER_MONTH 2629800 /* 1/12th of that year = 30.4375 days */ #define NSEC_PER_SECOND 1000000000ULL static const struct { @@ -1071,7 +1105,6 @@ static const struct { {"µs", 3, 0, 1000}, {"nsec", 4, 0, 1}, {"ns", 2, 0, 1}, - {"", 0, 1, NSEC_PER_SECOND}, }; static unsigned long long HX_strtoull_time(const char *s, char **out_end, bool nsec) @@ -1081,10 +1114,13 @@ static unsigned long long HX_strtoull_time(const char *s, char **out_end, bool n while (*s != '\0') { while (HX_isspace(*s)) ++s; + const char *numbegin = s; if (*s == '-') break; char *end = nullptr; unsigned long long num = strtoull(s, &end, 10); + if (num == ULLONG_MAX && errno == ERANGE) + return num; double frac = 0; bool have_frac = *end == '.'; if (have_frac) @@ -1100,13 +1136,25 @@ static unsigned long long HX_strtoull_time(const char *s, char **out_end, bool n time_multiplier[i].len) == 0 && !HX_isalpha(s[time_multiplier[i].len])) break; - if (i == ARRAY_SIZE(time_multiplier)) + if (i == ARRAY_SIZE(time_multiplier)) { + if ((!have_frac && num == 0) || (have_frac && frac == 0)) + /* 0 is the same no matter what unit, take it */ + continue; + s = numbegin; break; + } unsigned long long mult = nsec ? time_multiplier[i].ns_mult : time_multiplier[i].s_mult; - if (have_frac) + if (have_frac) { quant += frac * mult; - else + } else { + if (mult > 0 && num >= ULLONG_MAX / mult) { + if (out_end != nullptr) + *out_end = const_cast(char *, numbegin); + errno = ERANGE; + return ULLONG_MAX; + } quant += num * mult; + } s += time_multiplier[i].len; } if (out_end != nullptr) diff --git a/src/tc-dir.c b/src/tc-dir.c index ec44977..7f987bc 100644 --- a/src/tc-dir.c +++ b/src/tc-dir.c @@ -22,7 +22,7 @@ static void lookatdir(const char *dname) HXdir_close(dh); } -int main(int argc, const char **argv) +int main(int argc, char **argv) { if (HX_init() <= 0) return EXIT_FAILURE; diff --git a/src/tc-format.c b/src/tc-format.c index ed8e6d4..5c5c6e6 100644 --- a/src/tc-format.c +++ b/src/tc-format.c @@ -73,7 +73,7 @@ static int t_format(int argc) return EXIT_SUCCESS; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret; diff --git a/src/tc-list.c b/src/tc-list.c index e8a30b6..d31a5c7 100644 --- a/src/tc-list.c +++ b/src/tc-list.c @@ -10,6 +10,7 @@ #include #include #include +#include "internal.h" struct text_object { struct HXlist_head list; @@ -64,13 +65,14 @@ static void l_traverse(void) static void l_dump(bool pop) { static const char *const msg[] = {"Shifting", "Popping"}; - struct text_object *obj; unsigned int i = 0; - while ((obj = (pop ? - HXclist_pop(&strings_ct, struct text_object, list) : - HXclist_shift(&strings_ct, struct text_object, list) - )) != NULL) { + while (true) { + struct text_object *obj = pop ? + HXclist_pop(&strings_ct, struct text_object, list) : + HXclist_shift(&strings_ct, struct text_object, list); + if (obj == nullptr) + break; printf("%s item %u (\"%s\")\n", msg[pop], ++i, obj->id); #ifdef __cplusplus delete obj; @@ -138,7 +140,7 @@ static void l_shift(void) #pragma GCC diagnostic pop } -static int runner(int argc, const char **argv) +static int runner(int argc, char **argv) { unsigned int max = 10; @@ -157,10 +159,10 @@ static int runner(int argc, const char **argv) return EXIT_SUCCESS; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret = runner(argc, argv); - if (ret != EXIT_FAILURE) + if (ret == EXIT_FAILURE) fprintf(stderr, "FAILED\n"); return ret; } diff --git a/src/tc-memmem.c b/src/tc-memmem.c index 1a56f1b..6115aec 100644 --- a/src/tc-memmem.c +++ b/src/tc-memmem.c @@ -78,7 +78,7 @@ static int runner(void) int main(void) { int ret = runner(); - if (ret != EXIT_FAILURE) + if (ret == EXIT_FAILURE) fprintf(stderr, "FAILED\n"); return ret; } diff --git a/src/tc-misc.c b/src/tc-misc.c index d422f21..1677807 100644 --- a/src/tc-misc.c +++ b/src/tc-misc.c @@ -8,7 +8,7 @@ #include #include -static int runner(int argc, const char **argv) +static int runner(int argc, char **argv) { unsigned int n; struct stat sa, sb; @@ -43,10 +43,10 @@ static int runner(int argc, const char **argv) return EXIT_SUCCESS; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret = runner(argc, argv); - if (ret != EXIT_FAILURE) + if (ret == EXIT_FAILURE) fprintf(stderr, "FAILED\n"); return ret; } diff --git a/src/tc-option.c b/src/tc-option.c index 83271e0..8e99b19 100644 --- a/src/tc-option.c +++ b/src/tc-option.c @@ -11,6 +11,7 @@ #include #include #include +#include "internal.h" static int opt_v = 0, opt_mask = 0; static char *opt_kstr = NULL; @@ -64,45 +65,69 @@ static struct HXoption table[] = { HXOPT_TABLEEND, }; -static void dump_argv(const char **v) +static void dump_argv(char **v) { while (*v != NULL) printf("[%s] ", *v++); printf("\n"); } -static void t_pthru(void) +static int t_pthru(void) { const char *argv[] = { "ARGV0", "-Zomg", "-GZfoo", "bar", "--unknown-f=13.37", "--unknown-a", "foo", "bar", NULL }; - const char **argp = argv; - int argc = ARRAY_SIZE(argv) - 1; + char **nargv = nullptr; + int nargc = 0; printf("PTHRU test:\n"); - HX_getopt(table, &argc, &argp, HXOPT_USAGEONERR | HXOPT_PTHRU); - dump_argv(argp); + if (HX_getopt5(table, const_cast(char **, argv), &nargc, &nargv, + HXOPT_USAGEONERR | HXOPT_PTHRU) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + printf("argc = %d\n", nargc); + dump_argv(nargv); printf("\n"); + HX_zvecfree(nargv); + return EXIT_SUCCESS; } -static void t_empty_argv(void) +static int t_empty_argv(void) { - const char *zero_argv[] = {NULL}, **zero_argp = zero_argv; - int zero_argc = 0; + char *zero_argv[] = {nullptr}; + char **new_argv = nullptr; printf("Testing argv={NULL}\n"); - HX_getopt(table, &zero_argc, &zero_argp, HXOPT_USAGEONERR); + if (HX_getopt5(table, zero_argv, nullptr, &new_argv, + HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + HX_zvecfree(new_argv); + return EXIT_SUCCESS; } -int main(int argc, const char **argv) +static int t_keep_argv(void) { - if (HX_init() <= 0) + static const char *const one_argv[] = {"what", nullptr}; + const char **argv = const_cast2(const char **, one_argv); + if (HX_getopt(table, nullptr, &argv, HXOPT_KEEP_ARGV) != HXOPT_ERR_SUCCESS) return EXIT_FAILURE; - printf("Return value of HX_getopt: %d\n", - HX_getopt(table, &argc, &argv, HXOPT_USAGEONERR)); - t_empty_argv(); + return argv == one_argv ? EXIT_SUCCESS : EXIT_FAILURE; +} + +static int runner(int argc, char **argv) +{ + char **nargv = nullptr; + int ret = HX_getopt5(table, argv, &argc, &nargv, HXOPT_USAGEONERR); + printf("Return value of HX_getopt: %d\n", ret); + if (ret == EXIT_SUCCESS) + HX_zvecfree(nargv); + ret = t_empty_argv(); + if (ret != EXIT_SUCCESS) + return ret; + ret = t_keep_argv(); + if (ret != EXIT_SUCCESS) + return ret; printf("Either-or is: %s\n", opt_eitheror[opt_dst]); printf("values: D=%lf I=%d L=%ld S=%s\n", @@ -110,9 +135,16 @@ int main(int argc, const char **argv) printf("Verbosity level: %d\n", opt_v); printf("Mask: 0x%08X\n", opt_mask); printf("mcstr: >%s<\n", opt_mcstr); + return t_pthru(); +} - t_pthru(); - +int main(int argc, char **argv) +{ + if (HX_init() <= 0) + return EXIT_FAILURE; + int ret = runner(argc, argv); + if (ret != EXIT_SUCCESS) + printf("FAILED\n"); HX_exit(); - return EXIT_SUCCESS; + return ret; } diff --git a/src/tc-realpath.c b/src/tc-realpath.c index 23609ca..b71c127 100644 --- a/src/tc-realpath.c +++ b/src/tc-realpath.c @@ -8,6 +8,7 @@ #include #include #include +#include "internal.h" static unsigned int rp_flags; static unsigned int rp_absolute; @@ -24,9 +25,9 @@ static const struct HXoption rp_option_table[] = { HXOPT_TABLEEND, }; -static bool rp_get_options(int *argc, const char ***argv) +static bool rp_get_options(char **oargv, int *argc, char ***argv) { - if (HX_getopt(rp_option_table, argc, argv, HXOPT_USAGEONERR) != + if (HX_getopt5(rp_option_table, oargv, argc, argv, HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) return false; rp_flags = HX_REALPATH_DEFAULT; @@ -47,18 +48,19 @@ static void t_1(void) HXmc_free(tmp); } -int main(int argc, const char **argv) +int main(int argc, char **oargv) { + char **argv = nullptr; hxmc_t *res; int ret; - if (!rp_get_options(&argc, &argv)) + if (!rp_get_options(oargv, &argc, &argv)) return EXIT_FAILURE; t_1(); res = NULL; - while (--argc > 0) { - ret = HX_realpath(&res, *++argv, rp_flags); + for (int i = 1; i < argc; ++i) { + ret = HX_realpath(&res, argv[argc], rp_flags); if (ret < 0) { perror("HX_realpath"); printf("\n"); @@ -66,5 +68,6 @@ int main(int argc, const char **argv) printf("%s\n", res); } } + HX_zvecfree(argv); return EXIT_SUCCESS; } diff --git a/src/tc-shconfig.c b/src/tc-shconfig.c index 3717c15..0dde4c5 100644 --- a/src/tc-shconfig.c +++ b/src/tc-shconfig.c @@ -44,7 +44,7 @@ static int t_shconfig2(const char *file) return EXIT_SUCCESS; } -static int runner(int argc, const char **argv) +static int runner(int argc, char **argv) { int ret; @@ -61,7 +61,7 @@ static int runner(int argc, const char **argv) return EXIT_SUCCESS; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret = runner(argc, argv); if (ret != EXIT_SUCCESS) diff --git a/src/tc-string.c b/src/tc-string.c index 1c7ed09..e7f90c2 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -197,93 +197,6 @@ static void t_split2(void) HX_zvecfree(a); } -/* avoid these being inlined */ -extern char *f_strlcpy_str(char *, const char *, size_t); -extern char *f_strlcpy_mem(char *, const char *, size_t); - -EXPORT_SYMBOL char *f_strlcpy_str(char *d, const char *s, size_t n) -{ - if (n == 0) - return d; - strncpy(d, s, n); - d[n-1] = '\0'; - return d; -} - -EXPORT_SYMBOL char *f_strlcpy_mem(char *dest, const char *src, size_t dsize) -{ - size_t slen = strlen(src); - if (slen < dsize) - return static_cast(char *, memcpy(dest, src, slen + 1)); - if (dsize > 0) { - memcpy(dest, src, dsize - 1); - dest[dsize-1] = '\0'; - } - return dest; -} - -static const char s_lorem_ipsum[] = /* 1368 chars */ -"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo " -"ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis " -"parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, " -"pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec " -"pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, " -"rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede " -"mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper " -"nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, " -"consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra " -"quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. " -"Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur " -"ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, " -"tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing " -"sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit " -"id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut " -"libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros " -"faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec " -"sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit " -"cursus nunc,"; - -static void t_strlcpy(void) -{ - static const size_t picksizes[] = - {4, 8, 16, 32, 64, 80, 128, 256, 1024, 2048}; - char ibuf[2048], obuf[2048]; - size_t ipick, opick, k, runs = 10000000 + HX_irand(0, 1); - struct timespec start, stop, d1, d2, d3; - - for (ipick = 0; ipick < ARRAY_SIZE(picksizes); ++ipick) { - /* Select string size */ - HX_strlcpy(ibuf, s_lorem_ipsum, picksizes[ipick]); - - for (opick = 0; opick < ARRAY_SIZE(picksizes); ++opick) { - /* Select buffer size */ - clock_gettime(CLOCK_MONOTONIC, &start); - for (k = 0; k < runs; ++k) - f_strlcpy_str(reinterpret_cast(char *, obuf), - ibuf, picksizes[opick]); - clock_gettime(CLOCK_MONOTONIC, &stop); - HX_timespec_sub(&d1, &stop, &start); - - clock_gettime(CLOCK_MONOTONIC, &start); - for (k = 0; k < runs; ++k) - f_strlcpy_mem(reinterpret_cast(char *, obuf), - ibuf, picksizes[opick]); - clock_gettime(CLOCK_MONOTONIC, &stop); - HX_timespec_sub(&d2, &stop, &start); - - HX_timespec_sub(&d3, &d1, &d2); - printf("%4zu->%4zu: " HX_TIMESPEC_FMT - " (str=" HX_TIMESPEC_FMT - " mem=" HX_TIMESPEC_FMT ")\n", - strlen(ibuf), picksizes[opick], - HX_TIMESPEC_EXP(&d3), - HX_TIMESPEC_EXP(&d1), - HX_TIMESPEC_EXP(&d2) - ); - } - } -} - static void t_strlcpy2(void) { char a[3] = {49, 49, 49}; @@ -381,8 +294,8 @@ static int t_units_strto(void) unsigned long long expect_out; const char expect_rem[8]; } vt[] = { - {"-5k", 1000, ULLONG_MAX, "-5k"}, - {" -5.2k", 1000, ULLONG_MAX, "-5.2k"}, + {"-5k", 1000, -5000ULL, ""}, + {" -5.2k", 1000, -5200ULL, ""}, {"1", 9999, 1, ""}, {"1024", 9999, 1ULL << 10, ""}, {"1048576", 9999, 1ULL << 20, ""}, @@ -403,6 +316,10 @@ static int t_units_strto(void) {"1T", 1024, 1ULL << 40, ""}, {"1P", 1024, 1ULL << 50, ""}, {"1E", 1024, 1ULL << 60, ""}, + {"15E", 1024, 15ULL << 60, ""}, + {"16E", 1024, ULLONG_MAX, ""}, + {"16.0E", 1024, ULLONG_MAX, ""}, + {"1Z", 1024, ULLONG_MAX, ""}, {"0", 0, 0, ""}, {"0k", 0, 0, ""}, {"0 Z", 0, 0, ""}, @@ -412,18 +329,28 @@ static int t_units_strto(void) {"0.00000000000000001E", 1024, 11, ""}, {"1.525444GiB", 1000, 1525444000, "iB"}, {"1.525444GiB", 1024, 1637933022, "iB"}, + {"2M4k", 1000, 2000000, "4k"}, + {"18446744073709551614", 0, 18446744073709551614ULL, ""}, + {"18446744073709551615", 0, ULLONG_MAX, ""}, + {"18446744073709551616", 0, ULLONG_MAX, ""}, + {"-18446744073709551614", 0, 2, ""}, + {"-18446744073709551615", 0, 1, ""}, + {"-18446744073709551616", 0, ULLONG_MAX, ""}, }; 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("Observed: %s -> %llu __ %s\n", vt[i].input, q, end); + if (q != vt[i].expect_out || strcmp(end, vt[i].expect_rem) != 0) { + printf("Expected: %s -> %llu __ %s\n", vt[i].input, + vt[i].expect_out, vt[i].expect_rem); return EXIT_FAILURE; + } } return EXIT_SUCCESS; } -static void t_time_units(void) +static int t_time_units(void) { static const struct { unsigned long long input; @@ -432,10 +359,13 @@ static void t_time_units(void) } 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"}, + {34819200, HXUNIT_WEEKS, "57weeks4d"}, + {34819200, HXUNIT_MONTHS, "13months7d7h30min"}, + {34819200, HXUNIT_MONTHS | HXUNIT_WEEKS, "13months1week7h30min"}, + {34819200, HXUNIT_YEARS, "1y37d18h"}, + {34819200, HXUNIT_YEARS | HXUNIT_WEEKS, "1y5weeks2d18h"}, + {34819200, HXUNIT_YEARS | HXUNIT_MONTHS, "1y1month7d7h30min"}, + {34819200, HXUNIT_YEARS | HXUNIT_MONTHS | HXUNIT_WEEKS, "1y1month1week7h30min"}, {2678400, HXUNIT_MONTHS, "1month13h30min"}, {2592000, HXUNIT_MONTHS, "30d"}, {608400, HXUNIT_WEEKS, "1week1h"}, @@ -449,41 +379,55 @@ static void t_time_units(void) 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); + printf("Observed: %llus => \"%s\"\n", vt[i].input, ret); + if (strcmp(ret, vt[i].expect_out) != 0) { + printf("Expected: \"%s\"\n", vt[i].expect_out); + return EXIT_FAILURE; + } } + return EXIT_SUCCESS; } -static void t_time_strto(void) +static int t_time_strto(void) { #define NS_PER_S 1000000000ULL static const struct { const char *input; unsigned long long expect_s, expect_ns; - const char expect_rem[8]; + const char expect_rem[16]; } vt[] = { {"29µs", 0, 29000, ""}, {"1y", 31557600, NS_PER_S * 31557600, ""}, {"1y1month1week1d1h1min1s ", 31557600+2629800+86400*8+3600+60+1, NS_PER_S * (31557600+2629800+86400*8+3600+60+1), ""}, {" -1d", 0, 0, "-1d"}, - {"1 -", 1, NS_PER_S, "-"}, + {"1 -", 0, 0, "1 -"}, {"12.5 hours .5 hours 240 minutes 25200 seconds", 86400, NS_PER_S * 86400, ""}, {"1s", 1, NS_PER_S, ""}, {"1min", 60, 60 * NS_PER_S, ""}, {"0", 0, 0, ""}, + {"0.0", 0, 0, ""}, + {"1s0", 1, NS_PER_S, ""}, + {"1s0.0", 1, NS_PER_S, ""}, + {"1s1s", 2, 2 * NS_PER_S, ""}, + {"1s1", 1, 1 * NS_PER_S, "1"}, + {"584542046091y", ULLONG_MAX, ULLONG_MAX, "584542046091y"}, }; 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); unsigned long long qn = HX_strtoull_nsec(vt[i].input, &end); - printf("\"%s\" => %llus [%lluns] + \"%s\"\n", vt[i].input, q, qn, end); - if (q != vt[i].expect_s || qn != vt[i].expect_ns) - printf("\tBUG: expected %llus [%lluns]\n", vt[i].expect_s, vt[i].expect_ns); - if (strcmp(end, vt[i].expect_rem) != 0) - printf("\tBUG: expected remainder \"%s\"\n", vt[i].expect_rem); + printf("Observed: \"%s\" => %llus [%lluns] + \"%s\"\n", vt[i].input, q, qn, end); + if (q != vt[i].expect_s || qn != vt[i].expect_ns) { + printf("Expected: %llus [%lluns]\n", vt[i].expect_s, vt[i].expect_ns); + return EXIT_FAILURE; + } + if (strcmp(end, vt[i].expect_rem) != 0) { + printf("Expected: remainder \"%s\"\n", vt[i].expect_rem); + return EXIT_FAILURE; + } } + return EXIT_SUCCESS; } static int t_strmid(void) @@ -515,7 +459,7 @@ static int t_strmid(void) #undef T } -static int runner(int argc, const char **argv) +static int runner(int argc, char **argv) { hxmc_t *tx = NULL; const char *file = (argc >= 2) ? argv[1] : "tx-string.cpp"; @@ -559,19 +503,22 @@ static int runner(int argc, const char **argv) ret = t_units_strto(); if (ret != EXIT_SUCCESS) return EXIT_FAILURE; - t_time_units(); - t_time_strto(); - t_strlcpy(); + ret = t_time_units(); + if (ret != EXIT_SUCCESS) + return EXIT_FAILURE; + ret = t_time_strto(); + if (ret != EXIT_SUCCESS) + return EXIT_FAILURE; t_strlcpy2(); HXmc_free(tx); HX_exit(); return EXIT_SUCCESS; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret = runner(argc, argv); - if (ret != EXIT_FAILURE) + if (ret == EXIT_FAILURE) fprintf(stderr, "FAILED\n"); return ret; } diff --git a/src/tc-switchuser.c b/src/tc-switchuser.c index 4cc5604..e5d2c25 100644 --- a/src/tc-switchuser.c +++ b/src/tc-switchuser.c @@ -19,9 +19,10 @@ static const struct HXoption options_table[] = { HXOPT_TABLEEND, }; -static int runner(int argc, const char **argv) +static int runner(int argc, char **argv) { - HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR); + if (HX_getopt(options_table, &argc, &argv, HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; const char *user = user_name != NULL ? user_name : "-"; const char *group = group_name != NULL ? group_name : "-"; switch (HXproc_switch_user(user_name, group_name)) { @@ -62,10 +63,11 @@ static int runner(int argc, const char **argv) break; } } + HX_zvecfree(argv); return EXIT_SUCCESS; } -int main(int argc, const char **argv) +int main(int argc, char **argv) { int ret = runner(argc, argv); if (ret != EXIT_SUCCESS) diff --git a/src/tx-option.cpp b/src/tx-option.cpp index b70110f..248ab7c 100644 --- a/src/tx-option.cpp +++ b/src/tx-option.cpp @@ -12,8 +12,10 @@ static const struct HXoption t[] = { HXOPT_TABLEEND, }; -int main(int argc, const char **argv) +int main(int argc, char **argv) { - HX_getopt(t, &argc, &argv, HXOPT_USAGEONERR); + if (HX_getopt(t, &argc, &argv, HXOPT_USAGEONERR) != HXOPT_ERR_SUCCESS) + return EXIT_FAILURE; + HX_zvecfree(argv); return EXIT_SUCCESS; } diff --git a/src/uxcompat.h b/src/uxcompat.h new file mode 100644 index 0000000..e735c50 --- /dev/null +++ b/src/uxcompat.h @@ -0,0 +1,104 @@ +#ifndef _LIBHX_UXCOMPAT_H +#define _LIBHX_UXCOMPAT_H 1 + +#if defined(__cplusplus) && __cplusplus >= 201100UL +# include +# include +#else +# include +# include +#endif +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ENOSYS +# define ENOSYS 38 /* Function not implemented */ +#endif + +#ifndef S_IFLNK +# define S_IFLNK 0xA000 +#endif +#ifndef S_IFSOCK +# define S_IFSOCK 0xC000 +#endif +#ifndef S_IFBLK +# define S_IFBLK 0x6000 +#endif +#ifndef S_IFCHR +# define S_IFCHR 0x2000 +#endif +#ifndef S_IFIFO +# define S_IFIFO 0x1000 +#endif +#ifndef S_ISBLK +# define S_ISBLK(__mode) (((__mode) & S_IFMT) == S_IFBLK) +#endif +#ifndef S_ISCHR +# define S_ISCHR(__mode) (((__mode) & S_IFMT) == S_IFCHR) +#endif +#ifndef S_ISDIR +# define S_ISDIR(__mode) (((__mode) & S_IFMT) == S_IFDIR) +#endif +#ifndef S_ISREG +# define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG) +#endif +#ifndef S_ISLNK +# define S_ISLNK(__mode) (((__mode) & S_IFMT) == S_IFLNK) +#endif +#ifndef S_ISFIFO +# define S_ISFIFO(__mode) (((__mode) & S_IFMT) == S_IFIFO) +#endif +#ifndef S_ISSOCK +# define S_ISSOCK(__mode) (((__mode) & S_IFMT) == S_IFSOCK) +#endif +#ifndef S_IRGRP +# define S_IRGRP 00040 +#endif +#ifndef S_IWGRP +# define S_IWGRP 00020 +#endif +#ifndef S_IROTH +# define S_IROTH 00004 +#endif +#ifndef S_IWOTH +# define S_IWOTH 00002 +#endif + +struct stat; + +/* + * UX-FILE.C + */ +extern int chown(const char *, long, long); +extern int fchmod(int, long); +extern int fchown(int, long, long); +extern int lchown(const char *, long, long); +extern int lstat(const char *, struct stat *); +extern int mkfifo(const char *, long); +extern int mknod(const char *, long, long); +extern int readlink(const char *, char *, size_t); +extern int symlink(const char *, const char *); + +/* + * UX-MMAP.C + */ +#ifdef _WIN32 +# define MAP_FAILED reinterpret_cast(void *, static_cast(intptr_t, -1)) +# define PROT_NONE 0x0 +# define PROT_READ 0x1 +# define PROT_WRITE 0x2 +# define PROT_EXEC 0x4 +# define MAP_SHARED 0x1 +# define MAP_PRIVATE 0x2 +extern void *mmap(void *, size_t, int, int, int, off_t); +extern int munmap(void *, size_t); +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* _LIBHX_UXCOMPAT_H */ -- cgit v1.2.3