Open octavian-nita opened 7 years ago
I'm running into similar thing. Normally I get 0 for the remaining non-matches, but in another case I get 204s.
One way to address it would be to have an num_matches out parameter that let the API user know how far to read in the resulting matches set. (Or simply return matches as a vector, allowing for results without a max match set.)
The number of matches is equal to the length of the pattern if fuzzy_match() returns true. Otherwise the number of matches stored is lower than the length of the pattern and the match is considered invalid anyway IMHO.
After compiling the C++ matcher using
gcc
(which comes with the latest version ofCode::Blocks
) and running the resulting program, I noticed that the finalmatches
array contains (at some positions, different from the match locations) randomuint8_t
values.I also noticed that some match arrays don't seem to be properly initialized:
uint8_t matches[256];
,uint8_t bestRecursiveMatches[256];
anduint8_t recursiveMatches[256];
. Now, it's been a long while since I last touched C/C++ but I think the idea is that auto/static arrays get allocated but not automatically initialized to 0 or whatever (as opposed to class member arrays). I may, of course, be mistaken... :)The code: