diff --git a/scripts/check_header_guards.py b/scripts/check_header_guards.py new file mode 100644 index 000000000..bece10e9c --- /dev/null +++ b/scripts/check_header_guards.py @@ -0,0 +1,35 @@ +import os + + +PATH = "../src/" + + +def check_file(filename): + file = open(filename) + while 1: + line = file.readline() + if len(line) == 0: + break + if line[0] == "/" or line[0] == "*" or line[0] == "\r" or line[0] == "\n" or line[0] == "\t": + continue + if line[:7] == "#ifndef": + hg = "#ifndef " + ("_".join(filename.split(PATH)[1].split("/"))[:-2]).upper() + "_H" + if line[:-1] != hg: + print "Wrong header guard in " + filename + else: + print "Missing header guard in " + filename + break + file.close() + + + +def check_dir(dir): + list = os.listdir(dir) + for file in list: + if os.path.isdir(dir+file): + if file != "external" and file != "generated": + check_dir(dir+file+"/") + elif file[-2:] == ".h" and file != "keynames.h": + check_file(dir+file) + +check_dir(PATH) diff --git a/src/base/detect.h b/src/base/detect.h index ca2efb9cd..534339ddf 100644 --- a/src/base/detect.h +++ b/src/base/detect.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef BASELIB_FILE_CONFIG_H -#define BASELIB_FILE_CONFIG_H +#ifndef BASE_DETECT_H +#define BASE_DETECT_H /* this file detected the family, platform and architecture diff --git a/src/base/tl/algorithm.h b/src/base/tl/algorithm.h index 4a165db09..c5cd74c39 100644 --- a/src/base/tl/algorithm.h +++ b/src/base/tl/algorithm.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_ALGORITHM_HPP -#define TL_FILE_ALGORITHM_HPP +#ifndef BASE_TL_ALGORITHM_H +#define BASE_TL_ALGORITHM_H #include "range.h" diff --git a/src/base/tl/allocator.h b/src/base/tl/allocator.h index f6d8fc34d..d12347e30 100644 --- a/src/base/tl/allocator.h +++ b/src/base/tl/allocator.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_ALLOCATOR_HPP -#define TL_FILE_ALLOCATOR_HPP +#ifndef BASE_TL_ALLOCATOR_H +#define BASE_TL_ALLOCATOR_H template class allocator_default diff --git a/src/base/tl/array.h b/src/base/tl/array.h index 6aff3c714..0cee2afc7 100644 --- a/src/base/tl/array.h +++ b/src/base/tl/array.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_ARRAY_HPP -#define TL_FILE_ARRAY_HPP +#ifndef BASE_TL_ARRAY_H +#define BASE_TL_ARRAY_H #include "range.h" #include "allocator.h" diff --git a/src/base/tl/base.h b/src/base/tl/base.h index 59951c68c..2fcb14eb8 100644 --- a/src/base/tl/base.h +++ b/src/base/tl/base.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_BASE_HPP -#define TL_FILE_BASE_HPP +#ifndef BASE_TL_BASE_H +#define BASE_TL_BASE_H #include diff --git a/src/base/tl/range.h b/src/base/tl/range.h index 3c1c89f37..25047d31f 100644 --- a/src/base/tl/range.h +++ b/src/base/tl/range.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_RANGE_HPP -#define TL_FILE_RANGE_HPP +#ifndef BASE_TL_RANGE_H +#define BASE_TL_RANGE_H #include "base.h" diff --git a/src/base/tl/sorted_array.h b/src/base/tl/sorted_array.h index 7c45cf286..94ccd5438 100644 --- a/src/base/tl/sorted_array.h +++ b/src/base/tl/sorted_array.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_SORTED_ARRAY_HPP -#define TL_FILE_SORTED_ARRAY_HPP +#ifndef BASE_TL_SORTED_ARRAY_H +#define BASE_TL_SORTED_ARRAY_H #include "algorithm.h" #include "array.h" diff --git a/src/base/tl/string.h b/src/base/tl/string.h index 96c2dc66b..18fab4d41 100644 --- a/src/base/tl/string.h +++ b/src/base/tl/string.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef TL_FILE_STRING_HPP -#define TL_FILE_STRING_HPP +#ifndef BASE_TL_STRING_H +#define BASE_TL_STRING_H #include "base.h" #include "allocator.h" diff --git a/src/engine/shared/config.h b/src/engine/shared/config.h index 4720ddb39..9a524d22e 100644 --- a/src/engine/shared/config.h +++ b/src/engine/shared/config.h @@ -1,7 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef ENGINE_SHARED_E_CONFIG_H -#define ENGINE_SHARED_E_CONFIG_H +#ifndef ENGINE_SHARED_CONFIG_H +#define ENGINE_SHARED_CONFIG_H struct CConfiguration { diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 857494052..8dec21028 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -1,8 +1,8 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef ENGINE_SHARED_E_CONFIG_VARIABLES_H -#define ENGINE_SHARED_E_CONFIG_VARIABLES_H -#undef ENGINE_SHARED_E_CONFIG_VARIABLES_H // this file will be included several times +#ifndef ENGINE_SHARED_CONFIG_VARIABLES_H +#define ENGINE_SHARED_CONFIG_VARIABLES_H +#undef ENGINE_SHARED_CONFIG_VARIABLES_H // this file will be included several times // TODO: remove this #include "././game/variables.h"