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
#!/bin/sh
# Find duplicate function definitions across C source files
# Pure shell implementation for portability
echo "Scanning for duplicate function definitions...\n"
# Create temporary directory
TMPDIR="/tmp/scan_$$"
mkdir -p "$TMPDIR"
trap "rm -rf $TMPDIR" EXIT
# Extract all function definitions to temp files
find src pim -name "*.c" 2>/dev/null | while read file; do
grep "^[a-zA-Z_][a-zA-Z0-9_]*(" "$file" 2>/dev/null | sed 's/(.*//' | while read func; do
echo "$file" >> "$TMPDIR/$func" 2>/dev/null || true
done
done
# Find functions defined in multiple files
FOUND_DUP=0
ls "$TMPDIR"/* 2>/dev/null | while read func; do
[ ! -f "$func" ] && continue
lines=$(wc -l < "$func")
if [ "$lines" -gt 1 ]; then
if [ $FOUND_DUP -eq 0 ]; then
echo "Duplicate functions found:\n"
FOUND_DUP=1
fi
name=$(basename "$func")
echo " $name:"
sed 's/^/ - /' "$func"
echo ""
fi
done
if [ $FOUND_DUP -eq 0 ]; then
echo "✓ No duplicate function definitions found."
fi