>From 584ef464a310638f94a79e9b4710fde41c884e7d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 28 Feb 2024 11:23:17 +0100 Subject: [PATCH 1/3] gnulib-tool: Avoid references to functions that get defined later. * gnulib-tool (func_fatal_error, func_warning, func_readlink): Move before func_gnulib_dir. --- ChangeLog | 6 +++++ gnulib-tool | 70 ++++++++++++++++++++++++++--------------------------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index af3af3707e..af0835269f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-02-28 Bruno Haible + + 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 isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta. diff --git a/gnulib-tool b/gnulib-tool index 029a8cf377..2e10abcfcc 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -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: -- 2.34.1