URL:
https://svn.lrde.epita.fr/svn/lrde-tools/trunk
ChangeLog:
2007-11-15 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Tool for checking guards of header files of a project.
* README: Add description.
* src/check-guards: New.
---
README | 3 +++
src/check-guards | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
Index: trunk/src/check-guards
===================================================================
--- trunk/src/check-guards (revision 0)
+++ trunk/src/check-guards (revision 454)
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Utility to check guards of header files.
+# Usage : ./check-guards BASE SUB...
+#
+# - BASE : Specify the root of the project.
+# For example, here an header file :
+# /home/user/proj1/prj/module1/header.hh
+# The path '/home/user/proj1/' should be used
+# if the expected guard for this file is
+# "PRJ_MODULE1_HEADER_HH".
+# Warning! BASE must end with one '/'
+#
+# - SUB : Specify the element you want to verify.
+# Those element can be either directories or files
+# and are expected to be located in BASE.
+#
+############################################################
+
+base_dir=$1
+shift
+loc=$@
+
+for sub in $loc
+ do
+ for file in $(find ${base_dir}$sub -name '*.hh')
+ do
+ expr1=$(echo "${file##$base_dir}" | tr "[:lower:]"
"[:upper:]" | tr "[:punct:]" "_")
+ expr2=$(cat $file | grep "#ifndef" | grep HH | cut -d ' ' -f 2)
+ expr3=$(cat $file | grep "# define" | grep HH | cut -d ' ' -f 3)
+ expr4=$(cat $file | grep "#endif" | grep HH | cut -d ' ' -f 4)
+ if [ "$expr1" = "$expr2" -a "$expr1" =
"$expr2" -a "$expr1" = "$expr2" ]; then
+ res=OK
+ else
+ res="KO, should be $expr1"
+ fi
+ echo "${file##$base_dir} : $res"
+ done
+done
\ No newline at end of file
Property changes on: trunk/src/check-guards
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/README
===================================================================
--- trunk/README (revision 453)
+++ trunk/README (revision 454)
@@ -139,6 +139,9 @@
** src/apatche
Send patches to a mailing list.
+** src/check-gards
+Check recursivly all the guards of header files.
+
** src/g2b
Change the compression system from Gzip to Bzip2.