Commit b4df2417 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Review and fix regular expressions of the form /^foo|bar$/.

Replace regular expressions with simple string comparisons where possible. Use '(?:subregexp)' instead of '(subregexp)' wherever possible. 'dlls/gdi' does not have a win16drv subdirectory anymore so simplify regular expressions accordingly.
parent 40692f2a
...@@ -1199,7 +1199,7 @@ sub parse_c_function { ...@@ -1199,7 +1199,7 @@ sub parse_c_function {
'long(?=\s+double\b|\s+int\b|\s+long\b))(?=\b)', 'long(?=\s+double\b|\s+int\b|\s+long\b))(?=\b)',
\$_, \$line, \$column, \$match)) \$_, \$line, \$column, \$match))
{ {
if($match =~ /^extern|static$/) { if($match =~ /^(?:extern|static)$/) {
if(!$linkage) { if(!$linkage) {
$linkage = $match; $linkage = $match;
} }
...@@ -1956,13 +1956,13 @@ sub parse_c_variable { ...@@ -1956,13 +1956,13 @@ sub parse_c_variable {
'long(?=\s+double\b|\s+int\b|\s+long\b))(?=\b)', 'long(?=\s+double\b|\s+int\b|\s+long\b))(?=\b)',
\$_, \$line, \$column, \$match)) \$_, \$line, \$column, \$match))
{ {
if ($match =~ /^extern|static$/) { if ($match =~ /^(?:extern|static)$/) {
if (!$linkage) { if (!$linkage) {
$linkage = $match; $linkage = $match;
} else { } else {
$self->_parse_c_warning($_, $line, $column, "repeated linkage (ignored): $match"); $self->_parse_c_warning($_, $line, $column, "repeated linkage (ignored): $match");
} }
} elsif ($match =~ /^signed|unsigned$/) { } elsif ($match =~ /^(?:signed|unsigned)$/) {
if (!$sign) { if (!$sign) {
$sign = "$match "; $sign = "$match ";
} else { } else {
......
...@@ -103,15 +103,15 @@ sub line { ...@@ -103,15 +103,15 @@ sub line {
$progress .= "$tool: "; $progress .= "$tool: ";
} }
if($tool =~ /^cd|make$/) { if($tool =~ /^(?:cd|make)$/) {
# Nothing # Nothing
} elsif($tool =~ /^ld$/) { } elsif($tool eq "ld"/) {
foreach my $file (@{$read_files}) { foreach my $file (@{$read_files}) {
$output->lazy_progress("${progress}reading '$file'"); $output->lazy_progress("${progress}reading '$file'");
} }
my $file = $$write_files[0]; my $file = $$write_files[0];
$output->progress("$progress: writing '$file'"); $output->progress("$progress: writing '$file'");
} elsif($tool =~ /^rm$/) { } elsif($tool eq "rm") {
foreach my $file (@{$remove_files}) { foreach my $file (@{$remove_files}) {
$output->lazy_progress("${progress}removing '$file'"); $output->lazy_progress("${progress}removing '$file'");
} }
...@@ -160,13 +160,13 @@ sub line { ...@@ -160,13 +160,13 @@ sub line {
# Nothing # Nothing
} elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) { } elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) {
# Nothing # Nothing
} elsif($tool =~ /^gcc|ld$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) { } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
$tool = "ld"; $tool = "ld";
ld_output($1, $_) ld_output($1, $_)
} elsif($tool =~ /^gcc|ld$/ && s/^(.*?)ld:\s*//) { } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.*?)ld:\s*//) {
$tool = "ld"; $tool = "ld";
ld_output("", $_) ld_output("", $_)
} elsif($tool =~ /^gcc|ld$/ && s/^collect2:\s*//) { } elsif($tool =~ /^(?:gcc|ld)$/ && s/^collect2:\s*//) {
$tool = "ld"; $tool = "ld";
ld_output("collect2", $_); ld_output("collect2", $_);
} elsif($tool eq "gcc" && s/^(.+?\.[chly]):\s*//) { } elsif($tool eq "gcc" && s/^(.+?\.[chly]):\s*//) {
......
...@@ -57,7 +57,7 @@ sub read_spec_file($) { ...@@ -57,7 +57,7 @@ sub read_spec_file($) {
/^$/ && next; # skip empty lines /^$/ && next; # skip empty lines
if($header) { if($header) {
if(/^\d+|@/) { if(/^(?:\d+|@)/) {
$header = 0; $header = 0;
$lookahead = 1; $lookahead = 1;
} }
...@@ -478,7 +478,7 @@ sub _generate_dsp($$) { ...@@ -478,7 +478,7 @@ sub _generate_dsp($$) {
my @header_files = @{$modules{$module}{header_files}}; my @header_files = @{$modules{$module}{header_files}};
my @resource_files = @{$modules{$module}{resource_files}}; my @resource_files = @{$modules{$module}{resource_files}};
if ($project !~ /^(?:wine(?:_unicode)?|wine(?:build|runtests|test))$/ && if ($project !~ /^wine(?:_unicode|build|runtests|test)?$/ &&
$project !~ /^(?:gdi32|ntdll|user32)_.+?$/ && $project !~ /^(?:gdi32|ntdll|user32)_.+?$/ &&
$project !~ /_test$/) $project !~ /_test$/)
{ {
...@@ -489,7 +489,7 @@ sub _generate_dsp($$) { ...@@ -489,7 +489,7 @@ sub _generate_dsp($$) {
my $no_cpp = 1; my $no_cpp = 1;
my $no_msvc_headers = 1; my $no_msvc_headers = 1;
if ($project =~ /^(?:wine(?:runtests|test))$/ || $project =~ /_test$/) { if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
$no_msvc_headers = 0; $no_msvc_headers = 0;
} }
...@@ -684,15 +684,15 @@ sub _generate_dsp($$) { ...@@ -684,15 +684,15 @@ sub _generate_dsp($$) {
push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\""; push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\"";
push @defines2, qw(__i386__ _X86_); push @defines2, qw(__i386__ _X86_);
if($project =~ /^gdi32_(?:enhmfdrv|mfdrv|win16drv)$/) { if($project =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
push @includes, ".."; push @includes, "..";
} }
if($project =~ /^user32_(?:windows)$/) { if($project eq "user32_windows") {
push @includes, "..\\dlls\\user"; push @includes, "..\\dlls\\user";
} }
if($project =~ /^user32_dde$/) { if($project eq "user32_dde") {
push @includes, ".."; push @includes, "..";
} }
...@@ -700,7 +700,7 @@ sub _generate_dsp($$) { ...@@ -700,7 +700,7 @@ sub _generate_dsp($$) {
push @includes, "$msvc_wine_dir\\$output_dir"; push @includes, "$msvc_wine_dir\\$output_dir";
} }
if (!$msvc_headers || $project =~ /^winetest$/) { if (!$msvc_headers || $project eq "winetest") {
push @includes, $wine_include_dir; push @includes, $wine_include_dir;
} }
} }
......
...@@ -442,7 +442,7 @@ sub parse_spec_file { ...@@ -442,7 +442,7 @@ sub parse_spec_file {
} else { } else {
$$module_external_calling_convention{$module}{"\@$ordinal"} = "extern"; $$module_external_calling_convention{$module}{"\@$ordinal"} = "extern";
} }
} elsif(/^(\d+|@)\s+(equate|variable)/) { } elsif(/^(?:\d+|@)\s+(?:equate|variable)/) {
# ignore # ignore
} else { } else {
my $next_line = <IN>; my $next_line = <IN>;
......
...@@ -75,14 +75,14 @@ if($options->spec_files || $options->winetest) { ...@@ -75,14 +75,14 @@ if($options->spec_files || $options->winetest) {
/^$/ && next; # skip empty lines /^$/ && next; # skip empty lines
if($header) { if($header) {
if(/^\d+|@/) { if(/^(?:\d+|@)/) {
$header = 0; $header = 0;
$lookahead = 1; $lookahead = 1;
} }
next; next;
} }
if(/^(@|\d+)\s+stdcall\s+(\w+)\s*\(\s*([^\)]*)\s*\)/) { if(/^(\d+|@)\s+stdcall\s+(\w+)\s*\(\s*([^\)]*)\s*\)/) {
my $ordinal = $1; my $ordinal = $1;
my $name = $2; my $name = $2;
my @args = split(/\s+/, $3); my @args = split(/\s+/, $3);
...@@ -559,7 +559,7 @@ if($options->stub_statistics) { ...@@ -559,7 +559,7 @@ if($options->stub_statistics) {
foreach my $external_name ($winapi->all_functions_in_module($module)) { foreach my $external_name ($winapi->all_functions_in_module($module)) {
my $external_calling_convention = my $external_calling_convention =
$winapi->function_external_calling_convention_in_module($module, $external_name); $winapi->function_external_calling_convention_in_module($module, $external_name);
if($external_calling_convention !~ /^forward|stub$/) { if($external_calling_convention !~ /^(?:forward|stub)$/) {
if($module_pseudo_stub{$module}{$external_name}) { if($module_pseudo_stub{$module}{$external_name}) {
$external_calling_convention = "pseudo_stub"; $external_calling_convention = "pseudo_stub";
} }
......
...@@ -71,7 +71,7 @@ sub get_spec_file_type($) { ...@@ -71,7 +71,7 @@ sub get_spec_file_type($) {
/^$/ && next; /^$/ && next;
if($header) { if($header) {
if(/^\d+|@/) { $header = 0; $lookahead = 1; } if(/^(?:\d+|@)/) { $header = 0; $lookahead = 1; }
next; next;
} }
......
...@@ -207,7 +207,7 @@ sub global_report($) { ...@@ -207,7 +207,7 @@ sub global_report($) {
my @messages; my @messages;
foreach my $name (sort(keys(%$conditionals))) { foreach my $name (sort(keys(%$conditionals))) {
if($name =~ /^const|inline|size_t$/) { next; } if($name =~ /^(?:const|inline|size_t)$/) { next; }
if(0 && !$$conditional_found{$name}) { if(0 && !$$conditional_found{$name}) {
push @messages, "config.h.in: conditional $name not used\n"; push @messages, "config.h.in: conditional $name not used\n";
......
...@@ -477,7 +477,7 @@ foreach my $file (@c_files) { ...@@ -477,7 +477,7 @@ foreach my $file (@c_files) {
if($options->config) { if($options->config) {
if(!$nativeapi->is_conditional($_)) { if(!$nativeapi->is_conditional($_)) {
if(/^HAVE_/ && !/^HAVE_(IPX|MESAGL|BUGGY_MESAGL|WINE_CONSTRUCTOR)$/) if(/^HAVE_/ && !/^HAVE_(?:IPX|MESAGL|BUGGY_MESAGL|WINE_CONSTRUCTOR)$/)
{ {
$output->write("$file: $_ is not declared as a conditional\n"); $output->write("$file: $_ is not declared as a conditional\n");
} }
...@@ -556,7 +556,7 @@ foreach my $file (@c_files) { ...@@ -556,7 +556,7 @@ foreach my $file (@c_files) {
if($check_protection && $header) { if($check_protection && $header) {
if((-e "$wine_dir/include/$header" || -e "$wine_dir/$file_dir/$header")) { if((-e "$wine_dir/include/$header" || -e "$wine_dir/$file_dir/$header")) {
if($header !~ /^(oleauto\.h|win(?:base|def|error|gdi|nls|nt|user)\.h)$/ && if($header !~ /^(?:oleauto\.h|win(?:base|def|error|gdi|nls|nt|user)\.h)$/ &&
$file_dir !~ /tests$/) $file_dir !~ /tests$/)
{ {
$output->write("$file: #include \<$header\> is a local include\n"); $output->write("$file: #include \<$header\> is a local include\n");
......
...@@ -304,15 +304,15 @@ sub calling_convention16($) { ...@@ -304,15 +304,15 @@ sub calling_convention16($) {
} }
local $_ = $self->calling_convention; local $_ = $self->calling_convention;
if(/^__cdecl$/) { if($_ eq "__cdecl") {
return "cdecl"; return "cdecl";
} elsif(/^VFWAPIV|WINAPIV$/) { } elsif(/^(?:VFWAPIV|WINAPIV)$/) {
if(!defined($suffix)) { return undef; } if(!defined($suffix)) { return undef; }
return "pascal$suffix"; # FIXME: Is this correct? return "pascal$suffix"; # FIXME: Is this correct?
} elsif(/^__stdcall|VFWAPI|WINAPI|CALLBACK$/) { } elsif(/^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
if(!defined($suffix)) { return undef; } if(!defined($suffix)) { return undef; }
return "pascal$suffix"; return "pascal$suffix";
} elsif(/^__asm$/) { } elsif($_ eq "__asm") {
return "asm"; return "asm";
} else { } else {
return "cdecl"; return "cdecl";
...@@ -323,13 +323,13 @@ sub calling_convention32($) { ...@@ -323,13 +323,13 @@ sub calling_convention32($) {
my $self = shift; my $self = shift;
local $_ = $self->calling_convention; local $_ = $self->calling_convention;
if(/^__cdecl$/) { if($_ eq "__cdecl") {
return "cdecl"; return "cdecl";
} elsif(/^VFWAPIV|WINAPIV$/) { } elsif(/^(?:VFWAPIV|WINAPIV)$/) {
return "varargs"; return "varargs";
} elsif(/^__stdcall|VFWAPI|WINAPI|CALLBACK$/) { } elsif(/^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
return "stdcall"; return "stdcall";
} elsif(/^__asm$/) { } elsif($_ eq "__asm") {
return "asm"; return "asm";
} else { } else {
return "cdecl"; return "cdecl";
......
...@@ -108,39 +108,39 @@ sub _check_function($$$$$$) { ...@@ -108,39 +108,39 @@ sub _check_function($$$$$$) {
} }
my $segmented = 0; my $segmented = 0;
if(defined($implemented_return_kind) && $implemented_return_kind =~ /^segptr|segstr$/) { if(defined($implemented_return_kind) && $implemented_return_kind =~ /^seg[sp]tr$/) {
$segmented = 1; $segmented = 1;
} }
my $implemented_calling_convention; my $implemented_calling_convention;
if($winapi->name eq "win16") { if($winapi->name eq "win16") {
if($calling_convention =~ /^__cdecl$/) { if($calling_convention eq "__cdecl") {
$implemented_calling_convention = "cdecl"; $implemented_calling_convention = "cdecl";
} elsif($calling_convention =~ /^VFWAPIV|WINAPIV$/) { } elsif($calling_convention =~ /^(?:VFWAPIV|WINAPIV)$/) {
$implemented_calling_convention = "varargs"; $implemented_calling_convention = "varargs";
} elsif($calling_convention =~ /^__stdcall|VFWAPI|WINAPI|CALLBACK$/) { } elsif($calling_convention =~ /^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
if(defined($implemented_return_kind) && $implemented_return_kind =~ /^s_word|word|void$/) { if(defined($implemented_return_kind) && $implemented_return_kind =~ /^(?:s_word|word|void)$/) {
$implemented_calling_convention = "pascal16"; $implemented_calling_convention = "pascal16";
} else { } else {
$implemented_calling_convention = "pascal"; $implemented_calling_convention = "pascal";
} }
} elsif($calling_convention =~ /^__asm$/) { } elsif($calling_convention eq "__asm") {
$implemented_calling_convention = "asm"; $implemented_calling_convention = "asm";
} else { } else {
$implemented_calling_convention = "cdecl"; $implemented_calling_convention = "cdecl";
} }
} elsif($winapi->name eq "win32") { } elsif($winapi->name eq "win32") {
if($calling_convention =~ /^__cdecl$/) { if($calling_convention eq "__cdecl") {
$implemented_calling_convention = "cdecl"; $implemented_calling_convention = "cdecl";
} elsif($calling_convention =~ /^VFWAPIV|WINAPIV$/) { } elsif($calling_convention =~ /^(?:VFWAPIV|WINAPIV)$/) {
$implemented_calling_convention = "varargs"; $implemented_calling_convention = "varargs";
} elsif($calling_convention =~ /^__stdcall|VFWAPI|WINAPI|CALLBACK$/) { } elsif($calling_convention =~ /^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
if(defined($implemented_return_kind) && $implemented_return_kind =~ /^longlong$/) { if(defined($implemented_return_kind) && $implemented_return_kind eq "longlong") {
$implemented_calling_convention = "stdcall"; # FIXME: Check entry flags $implemented_calling_convention = "stdcall"; # FIXME: Check entry flags
} else { } else {
$implemented_calling_convention = "stdcall"; $implemented_calling_convention = "stdcall";
} }
} elsif($calling_convention =~ /^__asm$/) { } elsif($calling_convention eq "__asm") {
$implemented_calling_convention = "asm"; $implemented_calling_convention = "asm";
} else { } else {
$implemented_calling_convention = "cdecl"; $implemented_calling_convention = "cdecl";
...@@ -166,7 +166,7 @@ sub _check_function($$$$$$) { ...@@ -166,7 +166,7 @@ sub _check_function($$$$$$) {
elsif($implemented_calling_convention ne $declared_calling_convention && elsif($implemented_calling_convention ne $declared_calling_convention &&
$implemented_calling_convention ne "asm" && $implemented_calling_convention ne "asm" &&
!($declared_calling_convention =~ /^pascal/ && $forbidden_return_type) && !($declared_calling_convention =~ /^pascal/ && $forbidden_return_type) &&
!($implemented_calling_convention =~ /^cdecl|varargs$/ && $declared_calling_convention =~ /^cdecl|varargs$/)) !($implemented_calling_convention =~ /^(?:cdecl|varargs)$/ && $declared_calling_convention =~ /^(?:cdecl|varargs)$/))
{ {
if($options->calling_convention && ( if($options->calling_convention && (
($options->calling_convention_win16 && $winapi->name eq "win16") || ($options->calling_convention_win16 && $winapi->name eq "win16") ||
...@@ -203,7 +203,7 @@ sub _check_function($$$$$$) { ...@@ -203,7 +203,7 @@ sub _check_function($$$$$$) {
$#argument_types--; $#argument_types--;
} }
if($internal_name =~ /^NTDLL__ftol|NTDLL__CIpow$/) { # FIXME: Kludge if($internal_name =~ /^(?:NTDLL__ftol|NTDLL__CIpow)$/) { # FIXME: Kludge
# ignore # ignore
} else { } else {
my $n = 0; my $n = 0;
...@@ -230,7 +230,7 @@ sub _check_function($$$$$$) { ...@@ -230,7 +230,7 @@ sub _check_function($$$$$$) {
if(defined($kind) && $kind eq "struct16") { if(defined($kind) && $kind eq "struct16") {
$n+=4; $n+=4;
("long", "long", "long", "long"); ("long", "long", "long", "long");
} elsif(defined($kind) && $kind =~ /^(?:longlong)$/) { } elsif(defined($kind) && $kind eq "longlong") {
$n+=2; $n+=2;
("long", "long"); ("long", "long");
} else { } else {
...@@ -246,8 +246,8 @@ sub _check_function($$$$$$) { ...@@ -246,8 +246,8 @@ sub _check_function($$$$$$) {
for my $n (0..$#argument_kinds) { for my $n (0..$#argument_kinds) {
if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; } if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; }
if($argument_kinds[$n] =~ /^segptr|segstr$/ || if($argument_kinds[$n] =~ /^seg[ps]tr$/ ||
$declared_argument_kinds[$n] =~ /^segptr|segstr$/) $declared_argument_kinds[$n] =~ /^seg[ps]tr$/)
{ {
$segmented = 1; $segmented = 1;
} }
...@@ -334,10 +334,10 @@ sub _check_statements($$$) { ...@@ -334,10 +334,10 @@ sub _check_statements($$$) {
my $called_name = $1; my $called_name = $1;
my $channel = $2; my $channel = $2;
my $called_arguments = $3; my $called_arguments = $3;
if($called_name =~ /^if|for|while|switch|sizeof$/) { if($called_name =~ /^(?:if|for|while|switch|sizeof)$/) {
# Nothing # Nothing
} elsif($called_name =~ /^ERR|FIXME|MSG|TRACE|WARN$/) { } elsif($called_name =~ /^(?:ERR|FIXME|MSG|TRACE|WARN)$/) {
if($first_debug_message && $called_name =~ /^FIXME|TRACE$/) { if($first_debug_message && $called_name =~ /^(?:FIXME|TRACE)$/) {
$first_debug_message = 0; $first_debug_message = 0;
if($called_arguments =~ /^\"\((.*?)\)(.*?)\"\s*,\s*(.*?)$/) { if($called_arguments =~ /^\"\((.*?)\)(.*?)\"\s*,\s*(.*?)$/) {
my $formating = $1; my $formating = $1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment