[MPlayer-cvslog] r23955 - trunk/TOOLS/checktree.sh

ivo subversion at mplayerhq.hu
Tue Jul 31 09:45:07 CEST 2007


Author: ivo
Date: Tue Jul 31 09:45:06 2007
New Revision: 23955

Log:
Test for reserved identifiers.

Identifiers with two initial underscores or an initial underscore followed by
an uppercase letter are reserved globally for use by the compiler.


Modified:
   trunk/TOOLS/checktree.sh

Modified: trunk/TOOLS/checktree.sh
==============================================================================
--- trunk/TOOLS/checktree.sh	(original)
+++ trunk/TOOLS/checktree.sh	Tue Jul 31 09:45:06 2007
@@ -27,6 +27,7 @@ _charset=no
 _stupid=no
 _showcont=no
 _gnu=no
+_res=no
 
 _color=yes
 _head=yes
@@ -54,6 +55,7 @@ enable_all_tests() {
     _charset=yes
     _stupid=yes
     _gnu=yes
+    _res=yes
 }
 
 disable_all_tests() {
@@ -67,6 +69,7 @@ disable_all_tests() {
     _charset=no
     _stupid=no
     _gnu=no
+    _res=no
 }
 
 printoption() {
@@ -109,6 +112,7 @@ for i in "$@"; do
         printoption "charset   " "test for wrong charset" "$_charset"
         printoption "stupid    " "test for stupid code" "$_stupid"
         printoption "gnu       " "test for GNUisms" "$_gnu"
+        printoption "res       " "test for reserved identifiers" "$_res"
         echo
         printoption "all       " "enable all tests" "no"
         echo  "                   (-noall can be specified as -none)"
@@ -217,6 +221,12 @@ for i in "$@"; do
     -nognu)
         _gnu=no
         ;;
+    -res)
+        _res=yes
+        ;;
+    -nores)
+        _res=no
+        ;;
     -*)
         echo "unknown option: $i" >&2
         exit 0
@@ -243,6 +253,12 @@ fi
 
 filelist=`all_filenames`
 
+if [ "$_stupid" = "yes" -o "$_res" = "yes" ] ; then
+    # generate 'shortlist' to avoid false positives in xpm files, docs, etc,
+    # when one only needs to check .c and .h files
+    chfilelist=`echo $filelist | tr ' ' '\n' | grep "[\.][ch]$"`
+fi
+
 if [ "$_showcont" = "yes" ]; then
   _diffopts="-u"
   _grepopts="-n -I"
@@ -315,6 +331,14 @@ fi
 
 # -----------------------------------------------------------------------------
 
+if [ "$_res" = "yes" ]; then
+    printhead "checking for reserved identifiers ..."
+    grep $_grepopts "#[ $TAB]*define[ $TAB]\+_[[:upper:]].*" $chfilelist
+    grep $_grepopts "#[ $TAB]*define[ $TAB]\+__.*" $chfilelist
+fi
+
+# -----------------------------------------------------------------------------
+
 if [ "$_charset" = "yes" ]; then
     printhead "checking bad charsets ..."
     for I in $filelist ; do
@@ -335,9 +359,6 @@ fi
 if [ "$_stupid" = "yes" ]; then
     printhead "checking for stupid code ..."
 
-    # avoid false-positives in xpm files, docs, etc, only check .c and .h files
-    chfilelist=`echo $filelist | tr ' ' '\n' | grep "[\.][ch]$"`
-
   if [ -n "$chfilelist" ]; then
     for i in calloc malloc realloc memalign av_malloc av_mallocz faad_malloc \
              lzo_malloc safe_malloc mpeg2_malloc _ogg_malloc; do



More information about the MPlayer-cvslog mailing list