webbuild-functions: some optimizations of sed parsing functions

This commit is contained in:
Silvan Calarco 2016-07-04 21:39:40 +02:00
parent 2c09744bbd
commit ee1a94af6f
2 changed files with 10 additions and 7 deletions

View File

@ -253,8 +253,10 @@ function parse_patch_output() {
}
function parse_build_output() {
#s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;
sed "s|\r.*||;
s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;s|\\\|\\\\\\\|g;s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
s|\\\|\\\\\\\|g;s|<|\&lt;|g;
s|[[:cntrl:]]\[[0-9;]*m||g;
s|&lt;font|<font|g;
s|&lt;/font|</font|g;
s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|;
@ -267,8 +269,10 @@ function parse_build_output() {
}
function parse_generic_output() {
# s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;
sed "s|\r.*||;
s|\(.\{10000\}\).*|\1 [CUT - LONG LINE]|;s|<|\&lt;|g;s|[[:cntrl:]]\[[0-9;]*m||g;
s|<|\&lt;|g;
s|[[:cntrl:]]\[[0-9;]*m||g;
s|&lt;font|<font|g;
s|&lt;/font|</font|g;
s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|;
@ -278,13 +282,12 @@ function parse_generic_output() {
function google_search() {
while read line; do
local SEARCH_STRING=`echo "$line" | sed "s|.*%SRCURL%\(.*\)%SRCURLEND%.*|\1|"`
if [ "$SEARCH_STRING" = "$line" ]; then
if [ "${line/\%SRCURL\%}" == "${line}" ]; then
echo "$line"
else
SEARCH_STRING=`echo $SEARCH_STRING | sed "s|\&lt;|<|"`
local SEARCH_STRING=`echo "$line" | sed "s|.*%SRCURL%\(.*\)%SRCURLEND%.*|\1|;s|\&lt;|<|"`
local SEARCH_STRING_ENCODED=`cgi_encodevar "$1 $SEARCH_STRING"`
echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"http://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|g"
echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"https://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|g"
fi
done
}

View File

@ -59,7 +59,7 @@ function showlog() {
tail -n +0 -f $f --pid $PROCESSPID | stdbuf -oL sed "s|<\([/]pre>\)|\&lt;\1|g"
echo -n "<!-- ENDSCROLL -->"
else
if [ $LOGFILESIZE -lt 2097152 ]; then
if [ $LOGFILESIZE -lt 12097152 ]; then
if [ -r $f ]; then
cat $f | parse_build_output $PACKAGE
else