MCPcopy Create free account
hub / github.com/defold/defold / l_strcmp

Function l_strcmp

engine/lua/src/lua/lvm.c:199–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197
198
199static int l_strcmp (const TString *ls, const TString *rs) {
200 const char *l = getstr(ls);
201 size_t ll = ls->tsv.len;
202 const char *r = getstr(rs);
203 size_t lr = rs->tsv.len;
204 for (;;) {
205 int temp = strcoll(l, r);
206 if (temp != 0) return temp;
207 else { /* strings are equal up to a `\0' */
208 size_t len = strlen(l); /* index of first `\0' in both strings */
209 if (len == lr) /* r is finished? */
210 return (len == ll) ? 0 : 1;
211 else if (len == ll) /* l is finished? */
212 return -1; /* l is smaller than r (because r is not finished) */
213 /* both strings longer than `len'; go on comparing (after the `\0') */
214 len++;
215 l += len; ll -= len; r += len; lr -= len;
216 }
217 }
218}
219
220
221int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {

Callers 2

luaV_lessthanFunction · 0.85
lessequalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected