- | hh | H | hp | hxx | hpp | HPP | h\+\+ | tcc
- /x;
-# Regexps to match files with the given characteristics.
-my $file_no_preprocess_regex = qr/
- $cc_regex.+?
- \.(?: $source_no_preprocess_regex)\b
- /x;
-my $file_preprocess_regex = qr/
- $cc_regex.+?
- \.(?: $header_preprocess_regex
- | $source_preprocess_regex)\b
- /x;
-my $file_compile_link_regex = qr/
- $cc_regex.+?
- \.(?: $source_preprocess_regex
- | $source_no_preprocess_regex)\b
- /x;
-my $file_compile_regex = qr/
- $cc_regex.+?
- \.(?: $source_preprocess_compile_regex
- | $source_no_preprocess_compile_regex)\b
- /x;
-my $file_no_compile_regex = qr/
- $cc_regex.+
- \.(?: $source_preprocess_no_compile_regex
- | $source_no_preprocess_no_compile_regex)\b
- /x;
-my $file_compile_cpp_regex = qr/
- $cc_regex.+
- \.(?: $source_preprocess_compile_cpp_regex
- | $source_no_preprocess_compile_cpp_regex)\b
+ qw( hh H hp hxx hpp HPP h++ tcc ),
+);
+
+# Hashes for fast extensions lookup to check if a file falls in one of these
+# categories.
+my %extensions_no_preprocess = map { $_ => 1 } (
+ @source_no_preprocess,
+);
+my %extensions_preprocess = map { $_ => 1 } (
+ @header_preprocess,
+ @source_preprocess,
+);
+my %extensions_compile_link = map { $_ => 1 } (
+ @source_preprocess,
+ @source_no_preprocess,
+);
+my %extensions_compile = map { $_ => 1 } (
+ @source_preprocess_compile,
+ @source_no_preprocess_compile,
+);
+my %extensions_no_compile = map { $_ => 1 } (
+ @source_preprocess_no_compile,
+ @source_no_preprocess_no_compile,
+);
+my %extensions_compile_cpp = map { $_ => 1 } (
+ @source_preprocess_compile_cpp,
+ @source_no_preprocess_compile_cpp,
+);
+my %extension = map { $_ => 1 } (
+ @source_no_preprocess,
+ @source_no_preprocess_compile,
+ @source_no_preprocess_compile_cpp,
+ @source_no_preprocess_no_compile,
+ @header_preprocess,
+ @source_preprocess,
+ @source_preprocess_compile,
+ @source_preprocess_compile_cpp,
+ @source_preprocess_no_compile,
+);
+
+# Regexp to match file extensions.
+my $file_extension_regex = qr/
+ \s
+ \S+ # Filename without extension.
+ \.
+ ([^\\.\s]+) # File extension.
+ (?=\s|\\) # At end of word. Can't use \b because some files have non
+ # word characters at the end and because \b matches double
+ # extensions (like .cpp.o). Works always as all lines are
+ # terminated with "\n".