* build-aux/ltmain.m4sh (func_append, func_append_quoted) (func_arith, func_len): Removed from here... * build-aux/general.m4sh (func_append, func_append_quoted) (func_arith, func_len): ...and added to here. (func_dirname, func_dirname_and_basename, func_normal_abspath) (func_relative_path): Use func_append. * tests/getopt-m4sh.at (_LT_AT_FALLBACK_FUNC_EXTRACT): Removed. Fallback functions are now in any m4sh generated file automatically.
Signed-off-by: Gary V. Vaughan <g...@gnu.org> --- build-aux/general.m4sh | 42 ++++++++++++++++++++++++++++++++++++++---- build-aux/ltmain.m4sh | 31 ------------------------------- tests/getopt-m4sh.at | 14 -------------- 3 files changed, 38 insertions(+), 49 deletions(-) diff --git a/build-aux/general.m4sh b/build-aux/general.m4sh index 566dc39..eeda222 100644 --- a/build-aux/general.m4sh +++ b/build-aux/general.m4sh @@ -73,6 +73,40 @@ IFS=" $lt_nl" dirname='s|/[^/]*$||' basename='s|^.*/||' + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1=\$$1\$2" +} # func_append may be replaced by extended shell implementation + + +# func_append_quoted var value +# Quote VALUE and append to the end of shell variable VAR, separated +# by a space. +func_append_quoted () +{ + func_quote_for_eval "$2" + eval "$1=\$$1\\ \$func_quote_for_eval_result" +} # func_append_quoted may be replaced by extended shell implementation + + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$@"` +} # func_arith may be replaced by extended shell implementation + + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` +} # func_len may be replaced by extended shell implementation + + # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. @@ -82,7 +116,7 @@ func_dirname () if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else - func_dirname_result=$func_dirname_result$2 + func_append func_dirname_result $2 fi } # func_dirname may be replaced by extended shell implementation @@ -113,7 +147,7 @@ func_dirname_and_basename () if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else - func_dirname_result=$func_dirname_result$2 + func_append func_dirname_result $2 fi func_basename_result=`$ECHO "$1" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation @@ -212,7 +246,7 @@ func_normal_abspath () ;; *) # Actual path component, append it. - func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent + func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" ;; esac done @@ -268,7 +302,7 @@ func_relative_path () func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test -n "$func_stripname_result"; then - func_relative_path_result=$func_relative_path_result/$func_stripname_result + func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return `.' else relative path. diff --git a/build-aux/ltmain.m4sh b/build-aux/ltmain.m4sh index 160d8af..b88c984 100644 --- a/build-aux/ltmain.m4sh +++ b/build-aux/ltmain.m4sh @@ -148,37 +148,6 @@ extracted_serial=0 # left over by shells. exec_cmd= -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1=\$$1\$2" -} # func_append may be replaced by extended shell implementation - -# func_append_quoted var value -# Quote VALUE and append to the end of shell variable VAR, separated -# by a space. -func_append_quoted () -{ - func_quote_for_eval "$2" - eval "$1=\$$1\\ \$func_quote_for_eval_result" -} # func_append_quoted may be replaced by extended shell implementation - - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$@"` -} # func_arith may be replaced by extended shell implementation - - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` -} # func_len may be replaced by extended shell implementation - # func_lo2o object func_lo2o () diff --git a/tests/getopt-m4sh.at b/tests/getopt-m4sh.at index 5eec5c2..81160db 100644 --- a/tests/getopt-m4sh.at +++ b/tests/getopt-m4sh.at @@ -53,18 +53,6 @@ $SED "s|@LN_S\@|$LN_S|g;s|@SED\@|$SED|g" t-options > options ])# _LT_AT_GETOPT_M4SH_SETUP -# _LT_AT_FALLBACK_FUNC_EXTRACT(FUNC-NAME) -# --------------------------------------- -# Extract the fallback function FUNC-NAME from ltmain.m4sh -m4_define([_LT_AT_FALLBACK_FUNC_EXTRACT], -[dnl {{ -$SED '/^# func_dirname /q' options > options.tmp -echo '# func_append var value' >> options.tmp -$SED -n '/^$1 ()/,/^} # $1 /p' $abs_top_srcdir/build-aux/ltmain.m4sh >> options.tmp -$SED '1,/^# func_dirname/d' options >> options.tmp -rm -f options && mv options.tmp options]) - - # _LT_AT_EXTENDED_SHELL_FUNC_EXTRACT(FUNC-NAME) # --------------------------------------------- # Extract the 'Extended-shell'-decorated function FUNC-NAME from libtool @@ -157,7 +145,6 @@ third ]]) _LT_AT_GETOPT_M4SH_SETUP -_LT_AT_FALLBACK_FUNC_EXTRACT(func_append) AT_CHECK([$SHELL ./options -a "first --append second" -athird], 0, [expout]) @@ -176,7 +163,6 @@ third ]]) _LT_AT_GETOPT_M4SH_SETUP -_LT_AT_FALLBACK_FUNC_EXTRACT(func_append) _LT_AT_XSI_FUNC_EXTRACT(func_append) AT_CHECK([$SHELL ./options -a "first --append second" -athird], 0, [expout]) -- 1.7.7.4 Cheers, -- Gary V. Vaughan (gary AT gnu DOT org)