Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

src_convention_check.sh 2.0 KB

You have to be logged in to leave a comment. Sign In
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
  1. #!/usr/bin/env bash
  2. #
  3. # Script to run the C naming convention enforcer to determine if
  4. # some functions are misnamed or misplaced. All results are written
  5. # to /tmp/gmt unless -o is used.
  6. #
  7. # admin/src_convention_check.sh [-e] [-f] [-o] [-v] [-w]
  8. #
  9. if [ ! -d cmake ]; then
  10. echo "Must be run from top-level gmt directory"
  11. exit 1
  12. fi
  13. # Set up the temp and possibly output directory
  14. rm -rf /tmp/gmt
  15. mkdir -p /tmp/gmt
  16. # Create 3 include files based on current gmt function status
  17. # 1. Create the list of current API prototype (GMT_*) functions from gmt.h
  18. # [The tr command is there to protect against bad declarations like int *get_integer. (There should be a space after the *)]
  19. egrep '^EXTERN_MSC' src/gmt.h | awk -F'(' '{print $1}' | awk '{print $NF}' | tr '*' ' ' | awk '{printf "\t\"%s\",\n", $1}' > /tmp/gmt/api.h
  20. # 2. Create the list of current prototype (gmt_*) functions from gmt_prototypes.h
  21. egrep '^EXTERN_MSC' src/gmt_prototypes.h | awk -F'(' '{print $1}' | awk '{print $NF}' | tr '*' ' ' | awk '{printf "\t\"%s\",\n", $1}' > /tmp/gmt/prototypes.h
  22. # 3. Create the list of current prototype (gmtlib_*) functions from gmt_internals.h
  23. egrep '^EXTERN_MSC' src/gmt_internals.h | awk -F'(' '{print $1}' | awk '{print $NF}' | tr '*' ' ' | awk '{printf "\t\"%s\",\n", $1}' > /tmp/gmt/internals.h
  24. # Create list ofboth classic and modern mode module functions
  25. gmt --show-modules > /tmp/gmt/all_modules.lis
  26. gmt --show-classic >> /tmp/gmt/all_modules.lis
  27. echo "gmtread" >> /tmp/gmt/all_modules.lis
  28. echo "gmtwrite" >> /tmp/gmt/all_modules.lis
  29. egrep '^EXTERN_MSC' src/gmt_compat.c | awk -F'(' '{print $1}' | awk '{print substr($NF,5)}' >> /tmp/gmt/all_modules.lis
  30. sort -u /tmp/gmt/all_modules.lis | awk '{printf "\t\"%s\",\n", $1}' > /tmp/gmt/modules.h
  31. gcc admin/src_convention_check.c -o /tmp/src_convention_check
  32. find src -name '*.c' | egrep -v 'triangle.c|mergesort.c|test|example|demo|kiss|ssrfpack|stripack|s_rint|qsort.c|cm4_functions' > /tmp/gmt/c_codes.lis
  33. /tmp/src_convention_check $* `cat /tmp/gmt/c_codes.lis`
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...