diff --git a/maint/dupincludes.pl b/maint/find-dup-includes/find-in-one-file.pl similarity index 82% rename from maint/dupincludes.pl rename to maint/find-dup-includes/find-in-one-file.pl index da8e06e44..bb0e19120 100755 --- a/maint/dupincludes.pl +++ b/maint/find-dup-includes/find-in-one-file.pl @@ -34,18 +34,20 @@ if (!open (FILE, "$filename")) { exit 1; } +my $lineno=1; foreach () { if (/^\s*#\s*include\s*<(.*)>/) { if (defined $sys_includes{$1}) { - print "$filename: duplicate <$1>\n"; + print "$filename:$lineno: duplicate <$1> (line no ".$sys_includes{$1}.")\n"; } else { - $sys_includes{$1} = 1; + $sys_includes{$1} = $lineno; } } elsif (/^\s*#\s*include\s*"(.*)"/) { if (defined $loc_includes{$1}) { - print "$filename: duplicate \"$1\"\n"; + print "$filename:$lineno: duplicate \"$1\" (line no ".$loc_includes{$1}.")\n"; } else { - $loc_includes{$1} = 1; + $loc_includes{$1} = $lineno; } } + $lineno++; } diff --git a/maint/find-dup-includes/runme.sh b/maint/find-dup-includes/runme.sh new file mode 100755 index 000000000..cd7206d65 --- /dev/null +++ b/maint/find-dup-includes/runme.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +set -e + +# Midnight Commander - find an 'include' duplicates in src/ and lib/ subdirs +# +# Copyright (C) 2011, 2013 +# The Free Software Foundation, Inc. +# +# Written by: +# Ilia Maslakov , 2011 +# Yury V. Zaytsev , 2011 +# Slava Zanko , 2013 +# +# This file is part of the Midnight Commander. +# +# The Midnight Commander is free software: you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# The Midnight Commander is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(pwd)))} + +#*** include section (source functions, for example) ******************* + +#*** file scope functions ********************************************** + +findIncludeDupsInDir() { + dir_name=$1; shift + + for i in $(find "${dir_name}" -name '*.[ch]'); do + file_name=$(echo $i | sed 's@'"${MC_SOURCE_ROOT_DIR}/"'@@g') + [ $(grep "^\s*${file_name}$" -c "${MC_SOURCE_ROOT_DIR}/maint/find-dup-includes/exclude-list.cfg") -ne 0 ] && continue + "${MC_SOURCE_ROOT_DIR}/maint/find-dup-includes/find-in-one-file.pl" "${i}" + done +} + +#*** main code ********************************************************* + +findIncludeDupsInDir "${MC_SOURCE_ROOT_DIR}/src" +findIncludeDupsInDir "${MC_SOURCE_ROOT_DIR}/lib" diff --git a/maint/testdup.sh b/maint/testdup.sh deleted file mode 100755 index 2c36236cb..000000000 --- a/maint/testdup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -echo "test src/*" -for i in `find src -name '*.[ch]'`; do - ./maint/dupincludes.pl $i -done - -echo "test lib/*" -for i in `find lib -name '*.[ch]'`; do - ./maint/dupincludes.pl $i -done - diff --git a/maint/utils/find-dup-includes/exclude-list.cfg b/maint/utils/find-dup-includes/exclude-list.cfg new file mode 100644 index 000000000..e50506910 --- /dev/null +++ b/maint/utils/find-dup-includes/exclude-list.cfg @@ -0,0 +1,3 @@ +src/filemanager/mountlist.c +src/vfs/smbfs/helpers/lib/netmask.c +lib/tty/key.c