math: Don't match longer function names

The comparison here is a bit naive, so "n" matches "ncr", so
technically

   math 'n(2, 3)'

is equivalent to

   math 'ncr(2, 3)'

Work towards #7508.
This commit is contained in:
Fabian Homborg 2020-11-26 12:32:46 +01:00
parent 6d98939445
commit 903a9fbf0c

View File

@ -222,7 +222,7 @@ static const te_builtin *find_builtin(const char *name, int len) {
return std::strncmp(lhs.name, rhs, len) < 0;
});
// We need to compare again because we might have gotten the first "larger" element.
if (found != end && std::strncmp(found->name, name, len) == 0) return found;
if (found != end && std::strncmp(found->name, name, len) == 0 && found->name[len] == 0) return found;
return nullptr;
}