File: check_include_def.sh

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (55 lines) | stat: -rwxr-xr-x 1,802 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /bin/bash -e
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-22 Bradley M. Bell
# ----------------------------------------------------------------------------
if [ ! -e "bin/check_include_def.sh" ]
then
   echo "bin/check_include_def.sh: must be executed from its parent directory"
   exit 1
fi
# ---------------------------------------------------------------------------
echo "Differences between include file names and ifndef at top directives."
echo "Also make sure same ifndef not used by two different files."
echo "-------------------------------------------------------------------"
list=`git ls-files | sed -n -e '/\.hpp$/p'`
different='no'
for file_name in $list
do
   dir=`echo $file_name | sed -e 's|/[^/]*$||'`
   name=`echo $file_name | sed -e 's|^.*/||'`
   first_dir=`echo $dir | sed -e 's|/.*||'`
   #
   macro_name=`sed -n -e '/^# *ifndef *CPPAD_[0-9A-Z_]*_HPP$/p' $file_name | \
      sed -e 's|^# *ifndef *||'`
   check=`echo $file_name | tr [a-zA-Z/.] [A-Za-z__]`
   #
   if [ "$first_dir" == 'include' ]
   then
      check=`echo $check | sed -e 's|INCLUDE_||'`
   else
      check="CPPAD_$check"
   fi
   #
   if [ "$macro_name" == '' ]
   then
      echo "file_name=$file_name"
      echo 'Cannot find  ^# *ifndef *CPPAD_[0-9A-Z_]*_HPP'
      different='yes'
   elif [ "$macro_name" != "$check" ]
   then
      echo " file_name=$file_name"
      echo "macro_name=$macro_name"
      different='yes'
   fi
done
#
echo "-------------------------------------------------------------------"
if [ $different = 'yes' ]
then
   echo "Error: nothing should be between the two dashed lines above"
   exit 1
else
   echo "Ok: nothing is between the two dashed lines above"
   exit 0
fi