MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / LookupCaseFold

Function LookupCaseFold

extern/re2/re2/parse.cc:272–297  ·  view source on GitHub ↗

Searches the case folding tables and returns the CaseFold* that contains r. If there isn't one, returns the CaseFold* with smallest f->lo bigger than r. If there isn't one, returns NULL.

Source from the content-addressed store, hash-verified

270// If there isn't one, returns the CaseFold* with smallest f->lo bigger than r.
271// If there isn't one, returns NULL.
272const CaseFold* LookupCaseFold(const CaseFold *f, int n, Rune r) {
273 const CaseFold* ef = f + n;
274
275 // Binary search for entry containing r.
276 while (n > 0) {
277 int m = n/2;
278 if (f[m].lo <= r && r <= f[m].hi)
279 return &f[m];
280 if (r < f[m].lo) {
281 n = m;
282 } else {
283 f += m+1;
284 n -= m+1;
285 }
286 }
287
288 // There is no entry that contains r, but f points
289 // where it would have been. Unless f points at
290 // the end of the array, it points at the next entry
291 // after r.
292 if (f < ef)
293 return f;
294
295 // No entry contains r; no entry contains runes > r.
296 return NULL;
297}
298
299// Returns the result of applying the fold f to the rune r.
300Rune ApplyFold(const CaseFold *f, Rune r) {

Callers 3

CycleFoldRuneFunction · 0.85
AddFoldedRangeFunction · 0.85
ToLowerRuneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected