runme.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. set -e
  3. # Midnight Commander - find an 'include' duplicates in src/ and lib/ subdirs
  4. #
  5. # Copyright (C) 2011, 2013
  6. # The Free Software Foundation, Inc.
  7. #
  8. # Written by:
  9. # Ilia Maslakov <il.smind@gmail.com>, 2011
  10. # Yury V. Zaytsev <yury@shurup.com>, 2011
  11. # Slava Zanko <slavazanko@gmail.com>, 2013
  12. #
  13. # This file is part of the Midnight Commander.
  14. #
  15. # The Midnight Commander is free software: you can redistribute it
  16. # and/or modify it under the terms of the GNU General Public License as
  17. # published by the Free Software Foundation, either version 3 of the License,
  18. # or (at your option) any later version.
  19. #
  20. # The Midnight Commander is distributed in the hope that it will be useful,
  21. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. # GNU General Public License for more details.
  24. #
  25. # You should have received a copy of the GNU General Public License
  26. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(dirname $(pwd))))}
  28. #*** include section (source functions, for example) *******************
  29. #*** file scope functions **********************************************
  30. findIncludeDupsInDir() {
  31. dir_name=$1; shift
  32. for i in $(find "${dir_name}" -name '*.[ch]'); do
  33. file_name=$(echo $i | ${SED-sed} 's@'"${MC_SOURCE_ROOT_DIR}/"'@@g')
  34. [ $(grep "^\s*${file_name}$" -c "${MC_SOURCE_ROOT_DIR}/maint/utils/find-dup-includes/exclude-list.cfg") -ne 0 ] && continue
  35. "${MC_SOURCE_ROOT_DIR}/maint/utils/find-dup-includes/find-in-one-file.pl" "${i}"
  36. done
  37. }
  38. #*** main code *********************************************************
  39. findIncludeDupsInDir "${MC_SOURCE_ROOT_DIR}/src"
  40. findIncludeDupsInDir "${MC_SOURCE_ROOT_DIR}/lib"