Merge branch '4459_sed'

* 4459_sed:
  Replaced unportable 'inplace' sed command
  Use configure detected or user specified sed in build system
  Ticket #4459: usage of 'sed' in build system/makefiles is not portable.
This commit is contained in:
Andrew Borodin 2023-05-20 20:06:54 +03:00
commit 2e3e3a3775
11 changed files with 43 additions and 32 deletions

View File

@ -65,38 +65,46 @@ CPPCHECK_SED_FILTER = \
-e "/Skipping configuration '.*' since the value of '.*' is unknown./d"
cppcheck:
$(CPPCHECK_CMD) --enable=all $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=all $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT).tmp
cppcheck-all: cppcheck
cppcheck-information:
$(CPPCHECK_CMD) --enable=information $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)information.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)information.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=information $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)information.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)information.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)information.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)all.$(CPPCHECK_OUT_EXT).tmp
cppcheck-performance:
$(CPPCHECK_CMD) --enable=performance $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)performance.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)performance.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=performance $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)performance.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)performance.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)performance.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)performance.$(CPPCHECK_OUT_EXT).tmp
cppcheck-portability:
$(CPPCHECK_CMD) --enable=portability $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)portability.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)portability.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=portability $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)portability.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)portability.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)portability.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)portability.$(CPPCHECK_OUT_EXT).tmp
cppcheck-style:
$(CPPCHECK_CMD) --enable=style $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)style.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)style.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=style $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)style.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)style.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)style.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)style.$(CPPCHECK_OUT_EXT).tmp
cppcheck-warning:
$(CPPCHECK_CMD) --enable=warning $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)warning.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)warning.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=warning $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)warning.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)warning.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)warning.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)warning.$(CPPCHECK_OUT_EXT).tmp
cppcheck-unusedFunction:
$(CPPCHECK_CMD) --enable=unusedFunction $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)unusedFunction.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)unusedFunction.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=unusedFunction $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)unusedFunction.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)unusedFunction.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)unusedFunction.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)unusedFunction.$(CPPCHECK_OUT_EXT).tmp
cppcheck-missingInclude:
$(CPPCHECK_CMD) --enable=missingInclude $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)missingInclude.$(CPPCHECK_OUT_EXT);
$(SED) -i $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)missingInclude.$(CPPCHECK_OUT_EXT)
$(CPPCHECK_CMD) --enable=missingInclude $(CPPCHECK_DIRS) 2>$(CPPCHECK_OUT_PREFIX)missingInclude.$(CPPCHECK_OUT_EXT).tmp;
$(SED) $(CPPCHECK_SED_FILTER) $(CPPCHECK_OUT_PREFIX)missingInclude.$(CPPCHECK_OUT_EXT).tmp > $(CPPCHECK_OUT_PREFIX)missingInclude.$(CPPCHECK_OUT_EXT)
rm -f $(CPPCHECK_OUT_PREFIX)missingInclude.$(CPPCHECK_OUT_EXT).tmp
cppcheck-split-all: \
cppcheck-information \

View File

@ -13,7 +13,7 @@ rm -f INSTALL && ln -s doc/INSTALL
# Generate po/POTFILES.in
${XGETTEXT:-xgettext} --keyword=_ --keyword=N_ --keyword=Q_ --output=- \
`find . -name '*.[ch]'` | sed -ne '/^#:/{s/#://;s/:[0-9]*/\
`find . -name '*.[ch]'` | ${SED-sed} -ne '/^#:/{s/#://;s/:[0-9]*/\
/g;s/ //g;p;}' | \
grep -v '^$' | sort | uniq >po/POTFILES.in

View File

@ -71,6 +71,7 @@ dnl ############################################################################
dnl Check for programs
dnl ############################################################################
AC_PROG_SED
PKG_PROG_PKG_CONFIG
AC_PROG_INSTALL
AC_PROG_LN_S
@ -709,7 +710,8 @@ po/Makefile.in
dnl https://stackoverflow.com/questions/30897170/ac-subst-does-not-expand-variable/30932102#30932102
AC_CONFIG_FILES(
[misc/syntax/Syntax], [sed -i -e "s%\${prefix}%$PREFIX%" misc/syntax/Syntax], [export PREFIX=$prefix]
[misc/syntax/Syntax], [${SED-sed} -e "s%\${prefix}%$PREFIX%" misc/syntax/Syntax > misc/syntax/Syntax.tmp && \
mv -f misc/syntax/Syntax.tmp misc/syntax/Syntax], [export PREFIX=$prefix]
)
AC_CONFIG_FILES([

View File

@ -19,14 +19,14 @@ EXTRA_DIST = \
$(noinst_DATA)
mc.csh: $(top_builddir)/config.status $(srcdir)/mc.csh.in
sed "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.csh.in > mc.csh
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.csh.in > mc.csh
mc.sh: $(top_builddir)/config.status $(srcdir)/mc.sh.in
sed "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.sh.in > mc.sh
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.sh.in > mc.sh
mc-wrapper.csh: $(top_builddir)/config.status $(srcdir)/mc-wrapper.csh.in
sed "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.csh.in > mc-wrapper.csh
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.csh.in > mc-wrapper.csh
mc-wrapper.sh: $(top_builddir)/config.status $(srcdir)/mc-wrapper.sh.in
sed "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.sh.in > mc-wrapper.sh
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.sh.in > mc-wrapper.sh

View File

@ -13,12 +13,12 @@ MAN_DATE_CMD = \
mc.1: $(srcdir)/mc.1.in
MAN_FILE=$<; MAN_DATE=$$($(MAN_DATE_CMD)); \
sed $(SED_PARAMETERS) $< > $@
$(SED) $(SED_PARAMETERS) $< > $@
mcedit.1: $(srcdir)/mcedit.1.in
MAN_FILE=$<; MAN_DATE=$$($(MAN_DATE_CMD)); \
sed $(SED_PARAMETERS) $< > $@
$(SED) $(SED_PARAMETERS) $< > $@
mcview.1: $(srcdir)/mcview.1.in
MAN_FILE=$<; MAN_DATE=$$($(MAN_DATE_CMD)); \
sed $(SED_PARAMETERS) $< > $@
$(SED) $(SED_PARAMETERS) $< > $@

View File

@ -49,7 +49,7 @@ AC_DEFUN([mc_G_MODULE_SUPPORTED], [
esac
if test -n "$lib"; then
lib1=`echo $i | sed 's/^-l//'`
lib1=`echo $i | ${SED-sed} 's/^-l//'`
if test -f "$GLIB_LIBDIR/lib${lib1}.a"; then
add="$GLIB_LIBDIR/lib${lib1}.a"
else

View File

@ -10,7 +10,7 @@ dnl @modified Andrew Borodin <aborodin@vmail.ru>
AC_DEFUN([mc_VERSION],[
if test -f ${srcdir}/mc-version.h; then
VERSION=$(grep '^#define MC_CURRENT_VERSION' ${srcdir}/mc-version.h | sed 's/.*"\(.*\)"$/\1/')
VERSION=$(grep '^#define MC_CURRENT_VERSION' ${srcdir}/mc-version.h | ${SED-sed} 's/.*"\(.*\)"$/\1/')
else
VERSION="unknown"
fi

View File

@ -37,7 +37,7 @@ findIncludeDupsInDir() {
dir_name=$1; shift
for i in $(find "${dir_name}" -name '*.[ch]'); do
file_name=$(echo $i | sed 's@'"${MC_SOURCE_ROOT_DIR}/"'@@g')
file_name=$(echo $i | ${SED-sed} 's@'"${MC_SOURCE_ROOT_DIR}/"'@@g')
[ $(grep "^\s*${file_name}$" -c "${MC_SOURCE_ROOT_DIR}/maint/utils/find-dup-includes/exclude-list.cfg") -ne 0 ] && continue
"${MC_SOURCE_ROOT_DIR}/maint/utils/find-dup-includes/find-in-one-file.pl" "${i}"
done

View File

@ -9,7 +9,7 @@ LINE="Copyright (C)"
for i in "$SOURCES"; do
# replace year: XXXX-YYYY -> XXXX-ZZZZ
# add year: XXXX -> XXXX-ZZZZ
sed -i -e "
${SED-sed} -i -e "
1,20 {
/$LINE/s/-[0-9]\{4\}$/-$YEAR/
};
@ -19,4 +19,5 @@ for i in "$SOURCES"; do
done
# special case
sed -i -e "/$LINE/s/-[0-9]\{4\} the/-$YEAR the/" src/editor/editwidget.c
${SED-sed} -e "/$LINE/s/-[0-9]\{4\} the/-$YEAR the/" src/editor/editwidget.c > src/editor/editwidget.c.tmp && \
mv -f src/editor/editwidget.c.tmp src/editor/editwidget.c

View File

@ -1,7 +1,7 @@
update-po: Makefile
$(MAKE) $(DOMAIN).pot-update && \
sed \
$(SED) \
-e '/#, fuzzy/d' \
-e 's/Project-Id-Version: PACKAGE VERSION/Project-Id-Version: $(PACKAGE) $(VERSION)/' \
-e 's/^"Plural-Forms: nplurals=INTEGER;/# "Plural-Forms: nplurals=INTEGER;/' \

View File

@ -63,7 +63,7 @@ SHOR_MC_VERSION="${PREV_MC_VERSION}"
if [ -r "${VERSION_FILE}" ]
then
PREV_MC_VERSION=`sed -n 's/^#define MC_CURRENT_VERSION "\(.*\)"$/\1/p' "${VERSION_FILE}"`
PREV_MC_VERSION=`${SED-sed} -n 's/^#define MC_CURRENT_VERSION "\(.*\)"$/\1/p' "${VERSION_FILE}"`
CURR_MC_VERSION="${PREV_MC_VERSION}"
SHOR_MC_VERSION="${PREV_MC_VERSION}"
fi