From e504faeb384997620f72c0892f00f46b304566ff Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 2 Nov 2018 14:42:50 +0100 Subject: [PATCH] tinyexpr: Add Comments --- src/tinyexpr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index 74d98d761..214273ae2 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -191,6 +191,7 @@ static const te_variable *find_builtin(const char *name, int len) { const auto end = std::end(functions); const te_variable *found = std::lower_bound(std::begin(functions), end, name, [len](const te_variable &lhs, const char *rhs) { + // The length is important because that's where the parens start return strncmp(lhs.name, rhs, len) < 0; }); // We need to compare again because we might have gotten the first "larger" element. @@ -242,6 +243,7 @@ void next_token(state *s) { } else { /* Look for an operator or special character. */ switch (s->next++[0]) { + // The "te_fun2" casts are necessary to pick the right overload. case '+': s->type = TOK_INFIX; s->function = (const void *)(te_fun2) add; break; case '-': s->type = TOK_INFIX; s->function = (const void *)(te_fun2) sub; break; case '*': s->type = TOK_INFIX; s->function = (const void *)(te_fun2) mul; break;