This has me stumped
I have a large C source file which has a variable that must always be added to like this:
CycleCounter += SomeValue
The some value isn't important.
There are several hundred lines like this in the code in a source file with several thousand lines. I'm trying to ensure all assignments are with added and accidentally assigned or subtracted.
I want find all occurrences where CycleCounter is not followed by a '+' or some white space and a '+'
I tried this expression :
CycleCounter\s*[^+]
but in this example it also matches where a '+' does occur.
It matches case 1 as well but I only want it to match cases 2 & 3 which do not have a trailing '+'.
if (postbyte & 0x80)
{
switch (postbyte & 0x1F)
{
case 0: // Post inc by 1
ea = (*xfreg16[Register]);
(*xfreg16[Register])++;
CycleCounter+=NatEmuCycles21; // good. expression correctly ignored this
break;
case 1: // post in by 2
ea = (*xfreg16[Register]);
(*xfreg16[Register]) += 2;
CycleCounter += NatEmuCycles32; // good. expression incorrectly identified
break;
case 2: // pre dec by 1
(*xfreg16[Register]) -= 1;
ea = (*xfreg16[Register]);
CycleCounter -= NatEmuCycles21; // mistake, subtracted. expression correctly identified
break;
case 3: // pre dec by 2
(*xfreg16[Register]) -= 2;
ea = (*xfreg16[Register]);
CycleCounter = NatEmuCycles32; // mistake, assigned. expression correctly identified
break;
case 4: // no offset
ea = (*xfreg16[Register]);
break;
CycleCounter(?!\s*[+]=)