summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary V. Vaughan <gary@gnu.org>2011-11-19 18:01:28 +0700
committerGary V. Vaughan <gary@gnu.org>2011-12-08 15:56:49 +0700
commit6bb8312ccf3f2505ad7d4b2f1572ea749c138623 (patch)
tree0c4629d4e5b063ae369c51a693da998cc04d3000
parentd5bcbf5f85ac1b4f5de75b7fec86ba220651c95e (diff)
downloadlibtool-6bb8312ccf3f2505ad7d4b2f1572ea749c138623.tar.gz
maint: share useful functions from general.m4sh.
* 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 <gary@gnu.org>
-rw-r--r--build-aux/general.m4sh42
-rw-r--r--build-aux/ltmain.m4sh31
-rw-r--r--tests/getopt-m4sh.at14
3 files changed, 38 insertions, 49 deletions
diff --git a/build-aux/general.m4sh b/build-aux/general.m4sh
index 566dc39a..eeda222a 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 160d8af6..b88c9840 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 5eec5c23..81160db1 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])