From 59e2d4d3c9e6bf472f3d42a8dc616b39a7156930 Mon Sep 17 00:00:00 2001 From: ivo Date: Tue, 31 Jul 2007 07:45:06 +0000 Subject: 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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23955 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/checktree.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'TOOLS') diff --git a/TOOLS/checktree.sh b/TOOLS/checktree.sh index ec539fd9a6..6f6b97940d 100755 --- a/TOOLS/checktree.sh +++ b/TOOLS/checktree.sh @@ -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 -- cgit v1.2.3