int knh_ResultSet_findColumn(Ctx *ctx, knh_ResultSet_t *o, knh_bytes_t name) { size_t i = 0; for(i = 0; i < DP(o)->column_size; i++) { if(knh_bytes_strcasecmp(S_tobytes(DP(o)->column[i].name), name) == 0) return i; } return -1; }
static METHOD knh__String_endsWith__IgnoreCase(Ctx *ctx, knh_sfp_t *sfp) { knh_bytes_t base = knh_String_tobytes(sfp[0].s); knh_bytes_t expr = knh_String_tobytes(sfp[1].s); int res = 0; if(expr.len < base.len) { base = knh_bytes_last(base, base.len - expr.len); res = (knh_bytes_strcasecmp(base, expr) == 0); } KNH_RETURN_Boolean(ctx, sfp, res); }
static METHOD knh__String_lastIndexOf__IgnoreCase(Ctx *ctx, knh_sfp_t *sfp) { knh_bytes_t base = knh_String_tobytes(sfp[0].s); knh_bytes_t delim = knh_String_tobytes(sfp[1].s); knh_intptr_t loc = base.len - delim.len; for(; loc >= 0; loc--) { if(base.buf[loc] != delim.buf[loc]) continue; knh_bytes_t sub = knh_bytes_offlen(base, loc, delim.len); if(knh_bytes_strcasecmp(sub, delim) == 0) break; } if (loc >= 0 && !knh_String_isASCII(sfp[0].s)) { base.len = (size_t)loc; loc = knh_bytes_mlen(base); } KNH_RETURN_Int(ctx, sfp, loc); }
static METHOD knh__String_equals__IgnoreCase(Ctx *ctx, knh_sfp_t *sfp) { KNH_RETURN_Boolean(ctx, sfp, ((sfp[0].s)->size == (sfp[1].s)->size && knh_bytes_strcasecmp(knh_String_tobytes(sfp[0].s), knh_String_tobytes(sfp[1].s))== 0)); }
KNHAPI(knh_bool_t) knh_bytes_equalsIgnoreCase(knh_bytes_t v1, knh_bytes_t v2) { return (v1.len == v2.len && knh_bytes_strcasecmp(v1, v2) == 0); }