File indexing completed on 2024-12-08 12:46:43
0001 #!/usr/bin/env ruby 0002 # Copyright (C) 2011 Harald Sitter <sitter@kde.org> 0003 # 0004 # This library is free software; you can redistribute it and/or 0005 # modify it under the terms of the GNU Lesser General Public 0006 # License as published by the Free Software Foundation; either 0007 # version 2.1 of the License, or (at your option) any later version. 0008 # 0009 # This library is distributed in the hope that it will be useful, 0010 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 # Lesser General Public License for more details. 0013 # 0014 # You should have received a copy of the GNU Lesser General Public 0015 # License along with this library. If not, see <http://www.gnu.org/licenses/>. 0016 0017 for file in Dir.glob("src/**") 0018 line_count = 1 0019 has_open_ifdef = false 0020 0021 next if File.directory?(file) 0022 0023 File.open(file, 'r').each_line do | line | 0024 if line =~ /#\s*ifdef\s*__GNUC__\s*/ 0025 has_open_ifdef = true 0026 end 0027 0028 if line =~ /#\s*endif\s*/ 0029 has_open_ifdef = false 0030 end 0031 0032 if line =~ /#\s*warning\s*/ and not has_open_ifdef 0033 raise("unprotected warning in (#{file}:#{line_count}), please add #ifdef __GNUC__") 0034 end 0035 0036 line_count += 1 0037 end 0038 end 0039 0040 puts ("All good :)")