roman | 9cd677d | 2022-09-12 10:11:50 +0200 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
Radek Krejci | cc3a1b6 | 2020-07-20 07:43:08 +0200 | [diff] [blame] | 2 | |
| 3 | RETVAL=0 |
| 4 | |
Radek Krejci | 92769a7 | 2020-11-19 20:57:32 +0100 | [diff] [blame] | 5 | # params - paths to the source files to search |
| 6 | SRC="$*" |
Radek Krejci | cc3a1b6 | 2020-07-20 07:43:08 +0200 | [diff] [blame] | 7 | |
| 8 | # param FUNC - name of the function in compat to check |
Christian Hopps | 6f32621 | 2021-03-23 12:37:29 -0400 | [diff] [blame] | 9 | check_compat_func () { |
Radek Krejci | cc3a1b6 | 2020-07-20 07:43:08 +0200 | [diff] [blame] | 10 | FILES=`grep -rE "([^[:alnum:]]|^)$1\([^\)]+\)" --include=\*.{c,h} $SRC | cut -d: -f1 | uniq` |
| 11 | for f in $FILES; do |
| 12 | grep -q "#include \"compat.h\"" $f |
| 13 | if [ $? -ne 0 ]; then |
| 14 | echo "Missing #include \"compat.h\" in file $f for function $1()" |
| 15 | RETVAL=$((RETVAL+1)) |
| 16 | fi |
| 17 | done |
| 18 | } |
| 19 | |
Christian Hopps | 6f32621 | 2021-03-23 12:37:29 -0400 | [diff] [blame] | 20 | check_compat_macro () { |
Michal Vasko | c5a2283 | 2020-08-20 13:21:33 +0200 | [diff] [blame] | 21 | FILES=`grep -rE "([^[:alnum:]]|^)$1([^[:alnum:]]|$)" --include=\*.{c,h} $SRC | cut -d: -f1 | uniq` |
| 22 | for f in $FILES; do |
| 23 | grep -q "#include \"compat.h\"" $f |
| 24 | if [ $? -ne 0 ]; then |
| 25 | echo "Missing #include \"compat.h\" in file $f for macro $1" |
| 26 | RETVAL=$((RETVAL+1)) |
| 27 | fi |
| 28 | done |
| 29 | } |
| 30 | |
Michal Vasko | 938a3a5 | 2021-05-25 09:02:52 +0200 | [diff] [blame] | 31 | check_compat_func vdprintf |
Radek Krejci | cc3a1b6 | 2020-07-20 07:43:08 +0200 | [diff] [blame] | 32 | check_compat_func asprintf |
Michal Vasko | 938a3a5 | 2021-05-25 09:02:52 +0200 | [diff] [blame] | 33 | check_compat_func vasprintf |
Radek Krejci | cc3a1b6 | 2020-07-20 07:43:08 +0200 | [diff] [blame] | 34 | check_compat_func getline |
| 35 | check_compat_func strndup |
| 36 | check_compat_func strnstr |
Michal Vasko | 938a3a5 | 2021-05-25 09:02:52 +0200 | [diff] [blame] | 37 | check_compat_func strdupa |
| 38 | check_compat_func strchrnul |
| 39 | check_compat_func get_current_dir_name |
| 40 | check_compat_func pthread_mutex_timedlock |
Michal Vasko | c5a2283 | 2020-08-20 13:21:33 +0200 | [diff] [blame] | 41 | check_compat_func UNUSED |
| 42 | check_compat_macro _PACKED |
Radek Krejci | cc3a1b6 | 2020-07-20 07:43:08 +0200 | [diff] [blame] | 43 | |
| 44 | exit $RETVAL |