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.

diff --git a/tools/winapi/c_parser.pm b/tools/winapi/c_parser.pm
index 4b56ff4..b8f7d54 100644
--- a/tools/winapi/c_parser.pm
+++ b/tools/winapi/c_parser.pm
@@ -1199,7 +1199,7 @@
 			  'long(?=\s+double\b|\s+int\b|\s+long\b))(?=\b)',
 			  \$_, \$line, \$column, \$match))
     {
-	if($match =~ /^extern|static$/) {
+	if($match =~ /^(?:extern|static)$/) {
 	    if(!$linkage) {
 		$linkage = $match;
 	    }
@@ -1956,13 +1956,13 @@
 			  'long(?=\s+double\b|\s+int\b|\s+long\b))(?=\b)',
 			  \$_, \$line, \$column, \$match))
     {
-	if ($match =~ /^extern|static$/) {
+	if ($match =~ /^(?:extern|static)$/) {
 	    if (!$linkage) {
 		$linkage = $match;
 	    } else {
 		$self->_parse_c_warning($_, $line, $column, "repeated linkage (ignored): $match");
 	    }
-	} elsif ($match =~ /^signed|unsigned$/) {
+	} elsif ($match =~ /^(?:signed|unsigned)$/) {
 	    if (!$sign) {
 		$sign = "$match ";
 	    } else {
diff --git a/tools/winapi/make_parser.pm b/tools/winapi/make_parser.pm
index 527ee66..5d433f1 100644
--- a/tools/winapi/make_parser.pm
+++ b/tools/winapi/make_parser.pm
@@ -103,15 +103,15 @@
 	    $progress .= "$tool: ";
 	}
 
-	if($tool =~ /^cd|make$/) {
+	if($tool =~ /^(?:cd|make)$/) {
 	    # Nothing
-	} elsif($tool =~ /^ld$/) {
+	} elsif($tool eq "ld"/) {
 	    foreach my $file (@{$read_files}) {
 		$output->lazy_progress("${progress}reading '$file'");
 	    }
 	    my $file = $$write_files[0];
 	    $output->progress("$progress: writing '$file'");
-	} elsif($tool =~ /^rm$/) {
+	} elsif($tool eq "rm") {
 	    foreach my $file (@{$remove_files}) {
 		$output->lazy_progress("${progress}removing '$file'");
 	    }
@@ -160,13 +160,13 @@
 	# Nothing
     } elsif($tool eq "gcc" && /^(?:In file included |\s*)from (.+?):(\d+)[,:]$/) {
 	# Nothing
-    } elsif($tool =~ /^gcc|ld$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
+    } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.+?\.s?o)(?:\(.*?\))?:\s*//) {
 	$tool = "ld";
 	ld_output($1, $_)
-    } elsif($tool =~ /^gcc|ld$/ && s/^(.*?)ld:\s*//) {
+    } elsif($tool =~ /^(?:gcc|ld)$/ && s/^(.*?)ld:\s*//) {
 	$tool = "ld";
 	ld_output("", $_)
-    } elsif($tool =~ /^gcc|ld$/ && s/^collect2:\s*//) {
+    } elsif($tool =~ /^(?:gcc|ld)$/ && s/^collect2:\s*//) {
 	$tool = "ld";
 	ld_output("collect2", $_);
     } elsif($tool eq "gcc" && s/^(.+?\.[chly]):\s*//) {
diff --git a/tools/winapi/msvcmaker b/tools/winapi/msvcmaker
index 1eaeb56..f4e6e4a 100755
--- a/tools/winapi/msvcmaker
+++ b/tools/winapi/msvcmaker
@@ -57,7 +57,7 @@
 	/^$/ && next;         # skip empty lines
 
 	if($header)  {
-	    if(/^\d+|@/) {
+	    if(/^(?:\d+|@)/) {
 		$header = 0;
 		$lookahead = 1;
 	    }
@@ -478,7 +478,7 @@
     my @header_files = @{$modules{$module}{header_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 !~ /_test$/)
     {
@@ -489,7 +489,7 @@
 
     my $no_cpp = 1;
     my $no_msvc_headers = 1;
-    if ($project =~ /^(?:wine(?:runtests|test))$/ || $project =~ /_test$/) {
+    if ($project =~ /^wine(?:runtests|test)$/ || $project =~ /_test$/) {
 	$no_msvc_headers = 0;
     }
 
@@ -684,23 +684,23 @@
 	    push @defines2, "__WINETEST_OUTPUT_DIR=\\\"$output_dir\\\"";
 	    push @defines2, qw(__i386__ _X86_);
 
-	    if($project =~ /^gdi32_(?:enhmfdrv|mfdrv|win16drv)$/) {
+	    if($project =~ /^gdi32_(?:enhmfdrv|mfdrv)$/) {
 		push @includes, "..";
 	    }
 
-	    if($project =~ /^user32_(?:windows)$/) {
+	    if($project eq "user32_windows") {
 		push @includes, "..\\dlls\\user";
 	    }
 
-	    if($project =~ /^user32_dde$/) {
+	    if($project eq "user32_dde") {
 		push @includes, "..";
 	    }
 
 	    if ($project =~ /_test$/) {
 		push @includes, "$msvc_wine_dir\\$output_dir";
-	    } 
+	    }
 
-	    if (!$msvc_headers || $project =~ /^winetest$/) {
+	    if (!$msvc_headers || $project eq "winetest") {
 		push @includes, $wine_include_dir;
 	    }
 	}
diff --git a/tools/winapi/winapi.pm b/tools/winapi/winapi.pm
index 3e9d793..256e88f 100644
--- a/tools/winapi/winapi.pm
+++ b/tools/winapi/winapi.pm
@@ -442,7 +442,7 @@
             } else {
                 $$module_external_calling_convention{$module}{"\@$ordinal"} = "extern";
             }
-	} elsif(/^(\d+|@)\s+(equate|variable)/) {
+	} elsif(/^(?:\d+|@)\s+(?:equate|variable)/) {
 	    # ignore
 	} else {
 	    my $next_line = <IN>;
diff --git a/tools/winapi/winapi_extract b/tools/winapi/winapi_extract
index 9781995..7497ef2 100755
--- a/tools/winapi/winapi_extract
+++ b/tools/winapi/winapi_extract
@@ -75,14 +75,14 @@
 	    /^$/ && next;         # skip empty lines
 
 	    if($header)  {
-	        if(/^\d+|@/) {
+	        if(/^(?:\d+|@)/) {
 		    $header = 0;
 		    $lookahead = 1;
 		}
 		next;
 	    }
 
-	    if(/^(@|\d+)\s+stdcall\s+(\w+)\s*\(\s*([^\)]*)\s*\)/) {
+	    if(/^(\d+|@)\s+stdcall\s+(\w+)\s*\(\s*([^\)]*)\s*\)/) {
 		my $ordinal = $1;
 		my $name = $2;
 		my @args = split(/\s+/, $3);
@@ -559,7 +559,7 @@
              foreach my $external_name ($winapi->all_functions_in_module($module)) {
 		 my $external_calling_convention =
 		     $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}) {
 			 $external_calling_convention = "pseudo_stub";
 		     }
diff --git a/tools/winapi_check/modules.pm b/tools/winapi_check/modules.pm
index 6f2b990..06121b9 100644
--- a/tools/winapi_check/modules.pm
+++ b/tools/winapi_check/modules.pm
@@ -71,7 +71,7 @@
 	/^$/ && next;
 
 	if($header)  {
-	    if(/^\d+|@/) { $header = 0; $lookahead = 1; }
+	    if(/^(?:\d+|@)/) { $header = 0; $lookahead = 1; }
 	    next;
 	}
 
diff --git a/tools/winapi_check/nativeapi.pm b/tools/winapi_check/nativeapi.pm
index 198a767..4b8b80b 100644
--- a/tools/winapi_check/nativeapi.pm
+++ b/tools/winapi_check/nativeapi.pm
@@ -207,7 +207,7 @@
 
     my @messages;
     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}) {
 	    push @messages, "config.h.in: conditional $name not used\n";
diff --git a/tools/winapi_check/winapi_check b/tools/winapi_check/winapi_check
index 7467502..7d980e9 100755
--- a/tools/winapi_check/winapi_check
+++ b/tools/winapi_check/winapi_check
@@ -477,7 +477,7 @@
 
 	if($options->config) {
 	    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");
 		}
@@ -556,7 +556,7 @@
 
 		if($check_protection && $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$/)
 			{
 			    $output->write("$file: #include \<$header\> is a local include\n");
diff --git a/tools/winapi_check/winapi_function.pm b/tools/winapi_check/winapi_function.pm
index 6b4065e..688651a 100644
--- a/tools/winapi_check/winapi_function.pm
+++ b/tools/winapi_check/winapi_function.pm
@@ -304,15 +304,15 @@
     }
 
     local $_ = $self->calling_convention;
-    if(/^__cdecl$/) {
+    if($_ eq "__cdecl") {
 	return "cdecl";
-    } elsif(/^VFWAPIV|WINAPIV$/) {
+    } elsif(/^(?:VFWAPIV|WINAPIV)$/) {
 	if(!defined($suffix)) { return undef; }
 	return "pascal$suffix"; # FIXME: Is this correct?
-    } elsif(/^__stdcall|VFWAPI|WINAPI|CALLBACK$/) {
+    } elsif(/^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
 	if(!defined($suffix)) { return undef; }
 	return "pascal$suffix";
-    } elsif(/^__asm$/) {
+    } elsif($_ eq "__asm") {
 	return "asm";
     } else {
 	return "cdecl";
@@ -323,13 +323,13 @@
     my $self = shift;
 
     local $_ = $self->calling_convention;
-    if(/^__cdecl$/) {
+    if($_ eq "__cdecl") {
 	return "cdecl";
-    } elsif(/^VFWAPIV|WINAPIV$/) {
+    } elsif(/^(?:VFWAPIV|WINAPIV)$/) {
 	return "varargs";
-    } elsif(/^__stdcall|VFWAPI|WINAPI|CALLBACK$/) {
+    } elsif(/^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
 	return "stdcall";
-    } elsif(/^__asm$/) {
+    } elsif($_ eq "__asm") {
 	return "asm";
     } else {
 	return "cdecl";
diff --git a/tools/winapi_check/winapi_local.pm b/tools/winapi_check/winapi_local.pm
index a30c7c6..aa83bf3 100644
--- a/tools/winapi_check/winapi_local.pm
+++ b/tools/winapi_check/winapi_local.pm
@@ -108,39 +108,39 @@
     }
 
     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;
     }
 
     my $implemented_calling_convention;
     if($winapi->name eq "win16") {
-	if($calling_convention =~ /^__cdecl$/) {
+	if($calling_convention eq "__cdecl") {
 	    $implemented_calling_convention = "cdecl";
-	} elsif($calling_convention =~ /^VFWAPIV|WINAPIV$/) {
+	} elsif($calling_convention =~ /^(?:VFWAPIV|WINAPIV)$/) {
 	    $implemented_calling_convention = "varargs";
-	} elsif($calling_convention =~ /^__stdcall|VFWAPI|WINAPI|CALLBACK$/) {
-	    if(defined($implemented_return_kind) && $implemented_return_kind =~ /^s_word|word|void$/) {
+	} elsif($calling_convention =~ /^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
+	    if(defined($implemented_return_kind) && $implemented_return_kind =~ /^(?:s_word|word|void)$/) {
 		$implemented_calling_convention = "pascal16";
 	    } else {
 		$implemented_calling_convention = "pascal";
 	    }
-	} elsif($calling_convention =~ /^__asm$/) {
+	} elsif($calling_convention eq "__asm") {
     	    $implemented_calling_convention = "asm";
 	} else {
     	    $implemented_calling_convention = "cdecl";
 	}
     } elsif($winapi->name eq "win32") {
-	if($calling_convention =~ /^__cdecl$/) {
+	if($calling_convention eq "__cdecl") {
 	    $implemented_calling_convention = "cdecl";
-	} elsif($calling_convention =~ /^VFWAPIV|WINAPIV$/) {
+	} elsif($calling_convention =~ /^(?:VFWAPIV|WINAPIV)$/) {
 	    $implemented_calling_convention = "varargs";
-	} elsif($calling_convention =~ /^__stdcall|VFWAPI|WINAPI|CALLBACK$/) {
-	    if(defined($implemented_return_kind) && $implemented_return_kind =~ /^longlong$/) {
+	} elsif($calling_convention =~ /^(?:__stdcall|VFWAPI|WINAPI|CALLBACK)$/) {
+	    if(defined($implemented_return_kind) && $implemented_return_kind eq "longlong") {
 		$implemented_calling_convention = "stdcall"; # FIXME: Check entry flags
 	    } else {
 		$implemented_calling_convention = "stdcall";
 	    }
-	} elsif($calling_convention =~ /^__asm$/) {
+	} elsif($calling_convention eq "__asm") {
     	    $implemented_calling_convention = "asm";
 	} else {
 	    $implemented_calling_convention = "cdecl";
@@ -166,7 +166,7 @@
     elsif($implemented_calling_convention ne $declared_calling_convention &&
        $implemented_calling_convention ne "asm" &&
        !($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 && (
             ($options->calling_convention_win16 && $winapi->name eq "win16") ||
@@ -203,7 +203,7 @@
 	$#argument_types--;
     }
 
-    if($internal_name =~ /^NTDLL__ftol|NTDLL__CIpow$/) { # FIXME: Kludge
+    if($internal_name =~ /^(?:NTDLL__ftol|NTDLL__CIpow)$/) { # FIXME: Kludge
 	# ignore
     } else {
 	my $n = 0;
@@ -230,7 +230,7 @@
 	    if(defined($kind) && $kind eq "struct16") {
 		$n+=4;
 		("long", "long", "long", "long");
-	    } elsif(defined($kind) && $kind =~ /^(?:longlong)$/) {
+	    } elsif(defined($kind) && $kind eq "longlong") {
 		$n+=2;
 		("long", "long");
 	    } else {
@@ -246,8 +246,8 @@
 	for my $n (0..$#argument_kinds) {
 	    if(!defined($argument_kinds[$n]) || !defined($declared_argument_kinds[$n])) { next; }
 
-	    if($argument_kinds[$n] =~ /^segptr|segstr$/ ||
-	       $declared_argument_kinds[$n] =~ /^segptr|segstr$/)
+	    if($argument_kinds[$n] =~ /^seg[ps]tr$/ ||
+	       $declared_argument_kinds[$n] =~ /^seg[ps]tr$/)
 	    {
 		$segmented = 1;
 	    }
@@ -334,10 +334,10 @@
 	    my $called_name = $1;
 	    my $channel = $2;
 	    my $called_arguments = $3;
-	    if($called_name =~ /^if|for|while|switch|sizeof$/) {
+	    if($called_name =~ /^(?:if|for|while|switch|sizeof)$/) {
 		# Nothing
-	    } elsif($called_name =~ /^ERR|FIXME|MSG|TRACE|WARN$/) {
-		if($first_debug_message && $called_name =~ /^FIXME|TRACE$/) {
+	    } elsif($called_name =~ /^(?:ERR|FIXME|MSG|TRACE|WARN)$/) {
+		if($first_debug_message && $called_name =~ /^(?:FIXME|TRACE)$/) {
 		    $first_debug_message = 0;
 		    if($called_arguments =~ /^\"\((.*?)\)(.*?)\"\s*,\s*(.*?)$/) {
 			my $formating = $1;