-
Notifications
You must be signed in to change notification settings - Fork 0
/
CHECKSTR
executable file
·64 lines (63 loc) · 2.08 KB
/
CHECKSTR
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
#**************************************************************
# Copyright (C) 2006-2009 Hewlett-Packard Development Company, L.P.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***************************************************************
PROG=$(basename $0)
DATA=_strings.data
PASS=checkstr.OK
WC=$(wc -l < $DATA) || exit 1
ERRS=0
# echo "$PROG: validating phrase seeds in license strings..."
for i in $(seq 1 $WC) ; do
LINE=$(head -n $i $DATA | tail -n 1)
if echo "${LINE}" | egrep -iq "^\[=NULL=\]" ; then
continue
fi
KEY=$(echo "$LINE" | awk -F\" '{print $2}')
# License string can contain `:`
REST=$(expr "$LINE" : '\[.*\] _.*: \(.*\)$')
TAG=$(expr "$LINE" : '\[.*\] \(.*\): ')
# echo LINE $i: key $KEY tag $TAG rest $REST
if [ -f checkstr.OK ]; then
# grep -qx "$TAG" $PASS && echo "$TAG: OK" && continue
grep -qx "$TAG" $PASS && continue
fi
## printf "$LINE\nLINE %03d: " $i
if echo "$REST" | egrep -iq "$KEY" ; then
X=1 # echo "OK (egrep)"
elif echo "$REST" | fgrep -iq "$KEY" ; then
X=1 # echo "OK (fgrep)"
else
CH1=$(echo $KEY | cut -c1)
OTH=$(echo $KEY | cut -c2-)
KLUDGE="${CH1})${OTH}"
if echo "$LINE" | fgrep -iq "$KLUDGE" ; then
X=1 # echo "OK (kludge \"$KLUDGE\")"
else
echo "$PROG: Key \"$KEY\" NOT FOUND in entry below:"
echo "$LINE"
ERRS=$((ERRS+1))
fi
fi
done
if [ $ERRS -eq 0 ] ; then
WILD=$(egrep '(=SOME=|=ANY=|=FEW=)' $DATA | wc -l)
printf "$PROG: %d phrases, %d contain wild-cards\n" $WC $WILD
exit 0
fi
echo "$PROG: Error count = $ERRS"
exit 1