rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # @author Howard Chen |
| 4 | # @brief if the input file violate rules, return 1, else 0 |
| 5 | # |
| 6 | |
| 7 | if [ $# != 1 ] || [ ! -f $F ] || [ ! ${F##*.} = "c" ] |
| 8 | then |
| 9 | echo "usage: wimac_rul.sh <c_source>" |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | |
| 14 | F=$1 |
| 15 | CMD_P=$(cat -n $F | grep @nostrict-g) |
| 16 | if [ "$CMD_P" != "" ] |
| 17 | then |
| 18 | echo "[PASS]: $F" |
| 19 | exit 0 |
| 20 | fi |
| 21 | |
| 22 | LINES=$(cat -n $F | sed -e /@nostrict/d | sed -e /\#include/d | gcc -E - | grep extern | sed -e /@nostrict/d ) |
| 23 | |
| 24 | if [ "$LINES" != "" ] |
| 25 | then |
| 26 | echo "" |
| 27 | echo "" |
| 28 | echo "[FAIL]: $F" |
| 29 | echo "$LINES" |
| 30 | echo "--------------------------------------------------------------------------------" |
| 31 | exit 1 |
| 32 | else |
| 33 | echo "[PASS]: $F" |
| 34 | exit 0 |
| 35 | fi |
| 36 | |