]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool: Avoid references to functions that get defined later.
authorBruno Haible <bruno@clisp.org>
Wed, 28 Feb 2024 10:23:17 +0000 (11:23 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 28 Feb 2024 10:24:03 +0000 (11:24 +0100)
* gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
before func_gnulib_dir.

ChangeLog
gnulib-tool

index af3af3707ec44d77d6290f640a6fceaf0312f34b..af0835269fe2b6986604d1380785aeb07d0ee68c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-28  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool: Avoid references to functions that get defined later.
+       * gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
+       before func_gnulib_dir.
+
 2024-02-27  Bruno Haible  <bruno@clisp.org>
 
        isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
index 029a8cf377ad8d8f2d9e54061bf2f20496ad2eef..2e10abcfccf39dac7daae2378412b9920b441314 100755 (executable)
@@ -421,6 +421,41 @@ func_exit ()
   (exit $1); exit $1
 }
 
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+# Input:
+# - progname                 name of this program
+func_fatal_error ()
+{
+  echo "$progname: *** $1" 1>&2
+  echo "$progname: *** Stop." 1>&2
+  func_exit 1
+}
+
+# func_warning message
+# Outputs to stderr a warning message,
+func_warning ()
+{
+  echo "gnulib-tool: warning: $1" 1>&2
+}
+
+# func_readlink SYMLINK
+# outputs the target of the given symlink.
+if (type readlink) > /dev/null 2>&1; then
+  func_readlink ()
+  {
+    # Use the readlink program from GNU coreutils.
+    readlink "$1"
+  }
+else
+  func_readlink ()
+  {
+    # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
+    # would do the wrong thing if the link target contains " -> ".
+    LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
+  }
+fi
+
 # func_gnulib_dir
 # locates the directory where the gnulib repository lives
 # Input:
@@ -672,41 +707,6 @@ else
   fast_func_remove_suffix=false
 fi
 
-# func_fatal_error message
-# outputs to stderr a fatal error message, and terminates the program.
-# Input:
-# - progname                 name of this program
-func_fatal_error ()
-{
-  echo "$progname: *** $1" 1>&2
-  echo "$progname: *** Stop." 1>&2
-  func_exit 1
-}
-
-# func_warning message
-# Outputs to stderr a warning message,
-func_warning ()
-{
-  echo "gnulib-tool: warning: $1" 1>&2
-}
-
-# func_readlink SYMLINK
-# outputs the target of the given symlink.
-if (type readlink) > /dev/null 2>&1; then
-  func_readlink ()
-  {
-    # Use the readlink program from GNU coreutils.
-    readlink "$1"
-  }
-else
-  func_readlink ()
-  {
-    # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
-    # would do the wrong thing if the link target contains " -> ".
-    LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
-  }
-fi
-
 # func_relativize DIR1 DIR2
 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
 # Input: