I am trying to understand the below code. But I am not getting it. Basically, the below code currently checks for if condition in a c or cpp file.
if ($perl_version_ok &&
$line =~ /^\+(.*)\b($Constant|[A-Z_][A-Z0-9_]*)\s*($Compare)\s*($LvalOrFunc)/) {
# Throw error
}
where Constant is any macro or any constant value; LvalOrFunc is any variable or function call; Compare is the operations like !=, == ,&& , etc
The if checks for codes like this if(CONST_VALUE == x), where CONST_VALUE is some macros. In this case its true and goes inside if condition.
But I want to check for the opposite if(x == CONST_VALUE ), and then throw error.
Please help in understanding this piece of line and how to achieve the desired result.
Note: The code is from linux kernel dir, available here: https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl
Line number of the code: 5483