BitVecFuzzyMatch
- Function
- August 22, 2025
Table of Contents
BitVecFuzzyMatch
BitVecFuzzyMatch
Description
Fuzzy pattern matching allowing up to N mismatches. Useful for approximate pattern matching with error tolerance.
Parameters
Name | Direction | Description |
---|---|---|
bv | in | Bitvector to search in |
pattern | in | Pattern to search for |
max_errors | in | Maximum number of mismatches allowed |
Usage example (from documentation)
u64 index = BitVecFuzzyMatch(&data, &pattern, 2); // Allow 2 errors
Usage example (Cross-references)
- In
BitVec.c:1561
:
}
u64 BitVecFuzzyMatch(BitVec *bv, BitVec *pattern, u64 max_errors) {
ValidateBitVec(bv);
ValidateBitVec(pattern);
// BitVecFuzzyMatch tests
bool test_bitvec_fuzzy_match_basic(void) {
printf("Testing BitVecFuzzyMatch basic functionality\n");
BitVec source = BitVecInit();
BitVecPush(&pattern, true);
u64 pos = BitVecFuzzyMatch(&source, &pattern, 0);
result = result && (pos == 6);
// Test with 1 error allowed
pos = BitVecFuzzyMatch(&source, &pattern, 1);
result = result && (pos == 0); // Should match 110 with 1 error
// BitVecFuzzyMatch tests
bool test_bitvec_fuzzy_match_basic(void) {
printf("Testing BitVecFuzzyMatch basic functionality\n");
BitVec source = BitVecInit();
BitVecPush(&pattern, true);
u64 pos = BitVecFuzzyMatch(&source, &pattern, 0);
result = result && (pos == 6);
// Test with 1 error allowed
pos = BitVecFuzzyMatch(&source, &pattern, 1);
result = result && (pos == 0); // Should match 110 with 1 error