MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / l_strcmp

Function l_strcmp

other_src/lua/src/lvm.cpp:205–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

luaV_lessthanFunction · 0.70
lessequalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected