You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	Fix shims with more than one function.
Each subsequent function would double every line in the C module. Move the loop to detect shimmed functions down to prevent this issues.
This commit is contained in:
		| @@ -208,6 +208,7 @@ | ||||
|                         <commit subject="Add shim feature for unit tests."/> | ||||
|                         <commit subject="Add local process shim."/> | ||||
|                         <commit subject="Add log shim."/> | ||||
|                         <commit subject="Fix shims with more than one function."/> | ||||
|  | ||||
|                         <p>Add local processs shim.</p> | ||||
|                     </release-item> | ||||
|   | ||||
| @@ -401,31 +401,33 @@ sub run | ||||
|  | ||||
|                                     foreach my $strLine (split("\n", $strShimModuleSrc)) | ||||
|                                     { | ||||
|                                         # Renamed shimmed functions | ||||
|                                         foreach my $strFunction (@{$rhShim->{$strShimModule}{&TESTDEF_HARNESS_SHIM_FUNCTION}}) | ||||
|                                         # If shimmed function declaration construction is in progress | ||||
|                                         if (defined($strFunctionShim)) | ||||
|                                         { | ||||
|                                             # If shimmed function declaration construction is in progress | ||||
|                                             if (defined($strFunctionShim)) | ||||
|                                             # When the beginning of the function block is found, output both the constructed | ||||
|                                             # declaration and the renamed implementation. | ||||
|                                             if ($strLine =~ /^{/) | ||||
|                                             { | ||||
|                                                 # When the beginning of the function block is found, output both the constructed | ||||
|                                                 # declaration and the renamed implementation. | ||||
|                                                 if ($strLine =~ /^{/) | ||||
|                                                 { | ||||
|                                                     push(@stryShimModuleSrcRenamed, trim($strFunctionDeclaration) . ";"); | ||||
|                                                     push(@stryShimModuleSrcRenamed, $strFunctionShim); | ||||
|                                                     push(@stryShimModuleSrcRenamed, $strLine); | ||||
|                                                 push(@stryShimModuleSrcRenamed, trim($strFunctionDeclaration) . ";"); | ||||
|                                                 push(@stryShimModuleSrcRenamed, $strFunctionShim); | ||||
|                                                 push(@stryShimModuleSrcRenamed, $strLine); | ||||
|  | ||||
|                                                     $strFunctionShim = undef; | ||||
|                                                 } | ||||
|                                                 # Else keep constructing the declaration and implementation | ||||
|                                                 else | ||||
|                                                 { | ||||
|                                                     $strFunctionDeclaration .= "${strLine}\n"; | ||||
|                                                     $strFunctionShim .= "${strLine}\n"; | ||||
|                                                 } | ||||
|                                                 $strFunctionShim = undef; | ||||
|                                             } | ||||
|                                             # Else search for shimmed functions | ||||
|                                             # Else keep constructing the declaration and implementation | ||||
|                                             else | ||||
|                                             { | ||||
|                                                 $strFunctionDeclaration .= "${strLine}\n"; | ||||
|                                                 $strFunctionShim .= "${strLine}\n"; | ||||
|                                             } | ||||
|                                         } | ||||
|                                         # Else search for shimmed functions | ||||
|                                         else | ||||
|                                         { | ||||
|                                             # Rename shimmed functions | ||||
|                                             my $bFound = false; | ||||
|  | ||||
|                                             foreach my $strFunction (@{$rhShim->{$strShimModule}{&TESTDEF_HARNESS_SHIM_FUNCTION}}) | ||||
|                                             { | ||||
|                                                 # If the function to shim is static then we need to create a declaration with the | ||||
|                                                 # original name so references to the original name in the C module will compile. | ||||
| @@ -439,12 +441,16 @@ sub run | ||||
|  | ||||
|                                                     $strLine =~ s/^${strFunction}\(/${strFunction}_SHIMMED\(/; | ||||
|                                                     $strFunctionShim = "${strLineLast}\n${strLine}\n"; | ||||
|  | ||||
|                                                     $bFound = true; | ||||
|                                                     last; | ||||
|                                                 } | ||||
|                                                 # Else just append the line | ||||
|                                                 else | ||||
|                                                 { | ||||
|                                                     push(@stryShimModuleSrcRenamed, $strLine); | ||||
|                                                 } | ||||
|                                             } | ||||
|  | ||||
|                                             # If the function was not found then just append the line | ||||
|                                             if (!$bFound) | ||||
|                                             { | ||||
|                                                 push(@stryShimModuleSrcRenamed, $strLine); | ||||
|                                             } | ||||
|                                         } | ||||
|                                     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user