source:
branches/2014/dev_r4650_UKMO10_Tidally_Meaned_Diagnostics/NEMOGCM/TOOLS/MISCELLANEOUS/chk_ifdef.sh
@
5989
Last change on this file since 5989 was 5989, checked in by deazer, 9 years ago | |
---|---|
|
|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[5407] | 1 | #!/bin/bash |
2 | # | |
3 | # check the propper syntax of C preprocessor directives. | |
4 | # for example: | |
5 | #if defined key_traldf_c3d && key_traldf_smag | |
6 | # is not good and should be | |
7 | #if defined key_traldf_c3d && defined key_traldf_smag | |
8 | # | |
9 | # use: go to TOOLS/MISCELLANEOUS/ and simply execute: | |
10 | # ./chk_ifdef.sh | |
11 | # | |
12 | set -u | |
13 | # | |
14 | grep -r "^ *#if" ../../NEMO | grep -v "~:" > tmp$$ # get each lines of the code starting with #if | |
15 | grep -r "^ *#elif" ../../NEMO | grep -v "~:" >> tmp$$ # get each lines of the code starting with #elif | |
16 | # | |
17 | for ll in $( seq 1 $( cat tmp$$ | wc -l ) ) # for each of these lines | |
18 | do | |
19 | lll=$( sed -n -e "${ll}p" tmp$$ ) | |
20 | nbdef=$( echo $lll | grep -o defined | wc -l ) # number of occurences of "defined" | |
21 | nband=$( echo $lll | grep -o "&&" | wc -l ) # number of occurences of "&&" | |
22 | nbor=$( echo $lll | grep -o "||" | wc -l ) # number of occurences of "||" | |
23 | [ $nbdef -ne $(( $nband + $nbor + 1 )) ] && echo $lll # print bad line | |
24 | done | |
25 | rm -f tmp$$ | |
26 | ||
27 | # | |
28 | # add other basic tests | |
29 | # | |
30 | grep -ir ":,:.*ji,jj" * | grep -v "~:" | |
31 | grep -ir "ji,jj.*:,:" * | grep -v "~:" |
Note: See TracBrowser
for help on using the repository browser.