#!/root/bin/gtkmenuplus

#-------------------------------------------
configure = noicons
configure=endsubmenu
mTESTFILE = $0 # required
#mDIR = nest/2/3/4/5A
include = lib/common.gtkmenuplus
configure=noerrorconsoleonly
#-------------------------------------------

# Non-regression bug fix test:
#% Bug fixed in commit 1fc37a58.
#
# Before the fix the last line in this file (cmd=) triggers a
# segmentation fault.
#
#% After the fix this test should display a fatal error message
#% "line too long after variable expansion"
#% if max line size <= 512 or no error message since
#% commit db8878e increased max line size to 1023.

RECENTFILE=/tmp/$mTESTFILE.log
activationlogfile=$RECENTFILE

BLACKLIST="@blacklist@|Item=Shutdown"

A0==echo '\$'0 # enter $0 as $A0
BEGIN=BEGIN{RS=\"#[{]}\";IGNORECASE=1}
SELECT={gsub(/^\n|\n$/,X);a[++n]=$A0\"\n\"RT}
END_BLACKLIST=END{delete a[n];for(i=1;i<n;i++)print a[i]>FILENAME}
APPLY_BLACKLIST=gawk '$BEGIN/$BLACKLIST/{next}$SELECT$END_BLACKLIST' '$RECENTFILE'

END_SORT=END{delete a[n];asort(a,b,\"cmp\");for(i=1;i<n;i++)print b[i]>FILENAME}
ALPHA_CMP_FUNC=function cmp(i1,v1,i2,v2,  a1,a2){split(v1,a1,/item=|\n/);split(v2,a2,/item=|\n/);gsub(/_/,X,a1[2]);gsub(/_/,X,a2[2])
BY_ALPHA_ASC =$ALPHA_CMP_FUNC;return a1[3]<a2[3]?-1:(a1[3]==a2[3]?0:1)}
APPLY_SORT_BY_ALPHA_ASC   =gawk -o/tmp/by-alpha-asc.awk '$BEGIN$SELECT$END_SORT$BY_ALPHA_ASC' '$RECENTFILE'

cmd=sh -c ": @blacklist@;""$APPLY_BLACKLIST;""$APPLY_SORT_BY_ALPHA_ASC;"
