Add script 'apply-sa-compile-utf8-patch.sh' and patchfile to apply a patch to '/usr/bin/sa-compile' to get rid of warning 'Wide character in print at /usr/bin/sa-compile line 433 , <> line 2405'.
This commit is contained in:
parent
29570469f4
commit
e34a18e335
164
apply-sa-compile-utf8-patch.sh
Executable file
164
apply-sa-compile-utf8-patch.sh
Executable file
@ -0,0 +1,164 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
script_name="$(basename $(realpath $0))"
|
||||
working_dir="$(dirname $(realpath $0))"
|
||||
|
||||
LOCK_DIR="/tmp/$(basename $0).$$.LOCK"
|
||||
log_file="${LOCK_DIR}/${script_name%%.*}.log"
|
||||
|
||||
|
||||
# ----------
|
||||
# Script specific variable settings
|
||||
# ----------
|
||||
|
||||
patch_file="${working_dir}/files/sa-compile.utf8.patch"
|
||||
orig_file="/usr/bin/sa-compile"
|
||||
|
||||
|
||||
# ----------
|
||||
# Base Function(s)
|
||||
# ----------
|
||||
|
||||
clean_up() {
|
||||
|
||||
# Perform program exit housekeeping
|
||||
rm -rf "$LOCK_DIR"
|
||||
blank_line
|
||||
exit $1
|
||||
}
|
||||
|
||||
echononl(){
|
||||
if $terminal ; then
|
||||
echo X\\c > /tmp/shprompt$$
|
||||
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
|
||||
echo -e -n " $*\\c" 1>&2
|
||||
else
|
||||
echo -e -n " $*" 1>&2
|
||||
fi
|
||||
rm /tmp/shprompt$$
|
||||
fi
|
||||
}
|
||||
|
||||
fatal(){
|
||||
echo ""
|
||||
if $terminal ; then
|
||||
echo -e " [ \033[31m\033[1mFatal\033[m ] $*"
|
||||
else
|
||||
echo -e " [ Fatal ] $*"
|
||||
fi
|
||||
echo ""
|
||||
if $terminal ; then
|
||||
echo -e " \033[1mScript terminated\033[m.."
|
||||
else
|
||||
echo -e " Script terminated.."
|
||||
fi
|
||||
echo ""
|
||||
rm -rf $LOCK_DIR
|
||||
exit 1
|
||||
}
|
||||
|
||||
error (){
|
||||
echo ""
|
||||
if $terminal ; then
|
||||
echo -e " [ \033[31m\033[1mError\033[m ] $*"
|
||||
else
|
||||
echo " [ Error ] $*"
|
||||
fi
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
echo_done() {
|
||||
if $terminal ; then
|
||||
echo -e "\033[75G[ \033[32mdone\033[m ]"
|
||||
fi
|
||||
}
|
||||
|
||||
echo_skipped() {
|
||||
if $terminal ; then
|
||||
echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]"
|
||||
fi
|
||||
}
|
||||
|
||||
echo_failed(){
|
||||
if $terminal ; then
|
||||
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
|
||||
fi
|
||||
}
|
||||
|
||||
blank_line() {
|
||||
if $terminal ; then
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# ----------
|
||||
# - Jobhandling
|
||||
# ----------
|
||||
|
||||
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
|
||||
# -
|
||||
trap clean_up SIGHUP SIGINT SIGTERM
|
||||
|
||||
# - Create lock directory '$LOCK_DIR"
|
||||
#
|
||||
mkdir "$LOCK_DIR"
|
||||
|
||||
|
||||
# ----------
|
||||
# - Some checks ..
|
||||
# ----------
|
||||
|
||||
# - Running in a terminal?
|
||||
# -
|
||||
if [[ -t 1 ]] ; then
|
||||
terminal=true
|
||||
else
|
||||
terminal=false
|
||||
fi
|
||||
|
||||
|
||||
# - Original file to patch and patch file present?
|
||||
# -
|
||||
if [[ ! -f "$orig_file" ]]; then
|
||||
fatal "Original File to patch '$orig_file' not found!"
|
||||
fi
|
||||
|
||||
if [[ ! -f "$patch_file" ]]; then
|
||||
fatal "Patchfile '$patch_file' not found!"
|
||||
fi
|
||||
|
||||
|
||||
# ==========
|
||||
# - Begin Main Script
|
||||
# ==========
|
||||
|
||||
# ----------
|
||||
# - Headline
|
||||
# ----------
|
||||
|
||||
if $terminal ; then
|
||||
echo ""
|
||||
echo -e "\033[1m----------\033[m"
|
||||
echo -e "\033[32m\033[1mRunning script \033[m\033[1m$script_name\033[32m .. \033[m"
|
||||
echo -e "\033[1m----------\033[m"
|
||||
fi
|
||||
|
||||
blank_line
|
||||
echononl "Apply patch \033[1m$(basename "$patch_file")\033[m to '$orig_file'.."
|
||||
patch --silent --forward --reject-file - -p0 "$orig_file" "$patch_file" > $log_file
|
||||
if [[ $? -gt 0 ]]; then
|
||||
if $(grep -q "Skipping patch" "$log_file" 2> /dev/null) ; then
|
||||
echo_skipped
|
||||
else
|
||||
echo_failed
|
||||
error "$(cat "$log_file")"
|
||||
fi
|
||||
else
|
||||
echo_done
|
||||
fi
|
||||
|
||||
|
||||
blank_line
|
||||
clean_up 0
|
11
files/sa-compile.utf8.patch
Normal file
11
files/sa-compile.utf8.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- /usr/bin/sa-compile 2018-10-01 08:44:58.000000000 +0200
|
||||
+++ /root/sa-compile-new 2019-05-09 13:03:18.248787745 +0200
|
||||
@@ -391,6 +391,8 @@
|
||||
open(my $re, ">scanner${numscans}.re")
|
||||
or die "cannot create scanner${numscans}.re: $!";
|
||||
|
||||
+ binmode($re, "encoding(UTF-8)");
|
||||
+
|
||||
print $re <<EOT or die "error writing: $!";
|
||||
#define NULL ((char*) 0)
|
||||
#define YYCTYPE unsigned char
|
Loading…
Reference in New Issue
Block a user