Move an utility for found the include duplicates to maint/find-dup-includes subdirectory.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2013-04-09 12:55:51 +03:00
parent a2c9c0309a
commit 88d7c9b91b
4 changed files with 58 additions and 16 deletions

View File

@ -34,18 +34,20 @@ if (!open (FILE, "$filename")) {
exit 1;
}
my $lineno=1;
foreach (<FILE>) {
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++;
}

View File

@ -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 <il.smind@gmail.com>, 2011
# Yury V. Zaytsev <yury@shurup.com>, 2011
# Slava Zanko <slavazanko@gmail.com>, 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 <http://www.gnu.org/licenses/>.
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"

View File

@ -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

View File

@ -0,0 +1,3 @@
src/filemanager/mountlist.c
src/vfs/smbfs/helpers/lib/netmask.c
lib/tty/key.c