Update NSRegularExpression.m to fix reversed flag

The Cocoa callback block takes a pointer to a "stop" flag, but the ICU callback expects a return value with the opposite meaning (keepGoing). This error caused any longer-running regex to abort when it ran long enough to generate a callback instead of continuing as it should.
This commit is contained in:
Doug Simons 2024-12-04 12:59:29 -07:00 committed by GitHub
parent 2de7793dbc
commit f1ad19691e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -371,17 +371,20 @@ static UBool
callback(const void *context, int32_t steps)
{
BOOL stop = NO;
BOOL keepGoing = YES;
GSRegexBlock block = (GSRegexBlock)context;
if (NULL == context)
{
return FALSE;
return TRUE; // keep going if there is no callback block
}
CALL_BLOCK(block, nil, NSMatchingProgress, &stop);
return stop;
keepGoing = !stop; // keep going if callback block didn't request a stop
return keepGoing;
}
#define DEFAULT_WORK_LIMIT 1500
/**
* The work limit specifies the number of iterations the matcher will do before