]> source.dussan.org Git - rspamd.git/commitdiff
Indicies in lua starts from 1.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Apr 2015 17:20:45 +0000 (18:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Apr 2015 17:20:45 +0000 (18:20 +0100)
src/lua/lua_trie.c
test/lua/unit/trie.lua

index 3a07fa3b191a7bd24a4f5d3ce9d80a67ca57edd9..35abdff3d68f777fb84675cee31fd0ba3bf4f1bc 100644 (file)
@@ -134,7 +134,7 @@ lua_trie_callback (int strnum, int textpos, void *context)
 
        /* Function */
        lua_pushvalue (L, 3);
-       lua_pushnumber (L, strnum);
+       lua_pushnumber (L, strnum + 1);
        lua_pushnumber (L, textpos);
 
        if (lua_pcall (L, 2, 1, 0) != 0) {
index 6fa7573f93802e35a0992680e823c9191f99156b..5191d9e261e21960e1dae1b3dcae2e3b4bfadc88 100644 (file)
@@ -16,10 +16,10 @@ context("Trie search functions", function()
     assert_not_nil(trie, "cannot create trie")
     
     local cases = {
-      {'test', true, {{4, 0}, {4, 1}}},
-      {'she test test', true, {{3, 3}, {3, 2}, {8, 0}, {8, 1}, {13, 0}, {13, 1}}},
+      {'test', true, {{4, 1}, {4, 2}}},
+      {'she test test', true, {{3, 4}, {3, 3}, {8, 1}, {8, 2}, {13, 1}, {13, 2}}},
       {'non-existent', false},
-      {'str\0ing test', true, {{7, 4}, {12, 0}, {12, 1}}},
+      {'str\0ing test', true, {{7, 5}, {12, 1}, {12, 2}}},
     }
     
     local function comparetables(t1, t2)