LUA_FUNCTION_DEF (text, hex);
LUA_FUNCTION_DEF (text, gc);
LUA_FUNCTION_DEF (text, eq);
+LUA_FUNCTION_DEF (text, lt);
static const struct luaL_reg textlib_f[] = {
LUA_INTERFACE_DEF (text, fromstring),
{"__tostring", lua_text_str},
{"__gc", lua_text_gc},
{"__eq", lua_text_eq},
+ {"__lt", lua_text_lt},
{NULL, NULL}
};
return 1;
}
+static gint
+lua_text_lt (lua_State *L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_lua_text *t1 = lua_check_text (L, 1),
+ *t2 = lua_check_text (L, 2);
+
+ if (t1 && t2) {
+ if (t1->len == t2->len) {
+ lua_pushboolean (L, memcmp (t1->start, t2->start, t1->len) < 0);
+ }
+ else {
+ lua_pushboolean (L, t1->len < t2->len);
+ }
+ }
+
+ return 1;
+}
+
static gint
lua_text_wipe (lua_State *L)
{