File: sym_valid.sh

package info (click to toggle)
libmawk 1.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,188 kB
  • sloc: ansic: 27,046; awk: 1,154; yacc: 1,054; makefile: 488; sh: 365
file content (44 lines) | stat: -rwxr-xr-x 827 bytes parent folder | download | duplicates (4)
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/sh

# symbol validation; this script lists globally visible symbols with missing
# prefix and persistent states (global vars)

# ./gloals.sh is in libporty work/c99scripts/globals.sh

list_macros()
{
	awk -v "fn=$1" '
		/^[ \t]*#define[ \t]*/ {
			name=$0
			sub("^[ \t]*#define[ \t]*", "", name)
			sub("[ \t(].*", "", name)
			print "macro", name, "(" fn ":" NR ")"
		}
		
	' < $1
}

(
echo ""
echo "### missing prefix ###"

(for n in *.c
do
	echo $n >&2
	./globals.sh -g -I../.. -I.. -DLMAWK_VER=\"1\" $n
done

# list macros in the headers
for n in *.h
do
	list_macros $n
done
) | awk '($2 ~ "^mawk_") || ($2 ~ "^Mawk_") || ($2 ~ "^libmawk_") || /CLASS extern/ || ($2 == "main") { next } { print $0 }'

echo ""
echo "### persistent state ###"
for n in *.c
do
	./globals.sh -s -I../.. -I.. -DLMAWK_VER=\"1\" $n
done
)