]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
maint: share useful functions from general.m4sh.
authorGary V. Vaughan <gary@gnu.org>
Sat, 19 Nov 2011 11:01:28 +0000 (18:01 +0700)
committerGary V. Vaughan <gary@gnu.org>
Thu, 8 Dec 2011 08:56:49 +0000 (15:56 +0700)
* 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>
build-aux/general.m4sh
build-aux/ltmain.m4sh
tests/getopt-m4sh.at

index 566dc39a1f7ccff92ba7ee3d4ea7a5848ec31dbc..eeda222ad3d475b05f6d0365481f6ee03e37fb31 100644 (file)
@@ -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.
index 160d8af68bc02aa96b8afa5482871878e6236419..b88c9840cf65e2e811d5e784efce8d856926d989 100644 (file)
@@ -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 ()
index 5eec5c23ea669bad0de35682754e25e3fd5ab34f..81160db15e67fe3692d5efb8bf06a99d8af71d72 100644 (file)
@@ -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])