summaryrefslogtreecommitdiffstats
path: root/scanners/which-asm.sh
blob: 116e44f89d96c4e41ac0877988aaca9edf08f53b (plain)
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
#!/bin/bash

scanner="Which-Asm"

workdir="$1"
src="$2"

WHICHASM=whichasm

declare -i count
count=0
if [ -d "$src" ]
then
        find "$src" \( -name '*\.[cCsShH]' \
             -o -name '*\.cc' \
             -o -name '*\.cxx' \
             -o -name '*\.cpp' \
             \) -print > /tmp/$$
        if [ -s /tmp/$$ ]
        then
                count=$(cat /tmp/$$ | (
                        count=0
                        read line
                        while [ ! -z $line ]
                        do
                                res=$(${WHICHASM} $line)
                                if [ "$(echo $res | grep ^error:)" ] || \
                                   [ "$(echo $res | grep '.*: unknown')" ]
                                then
                                        true
                                else
                                        count+=1
                                fi
                                read line
                        done
                        echo $count
                ))
        fi
        rm -f /tmp/$$
else
        count="-1"
fi
echo "${scanner}: $count"