diff options
Diffstat (limited to 'lptree.c')
-rw-r--r-- | lptree.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -1142,13 +1142,23 @@ static int lp_match (lua_State *L) { | |||
1142 | const char *s = luaL_checklstring(L, SUBJIDX, &l); | 1142 | const char *s = luaL_checklstring(L, SUBJIDX, &l); |
1143 | size_t i = initposition(L, l); | 1143 | size_t i = initposition(L, l); |
1144 | int ptop = lua_gettop(L); | 1144 | int ptop = lua_gettop(L); |
1145 | Labelset labelf; /* labeled failure */ | ||
1145 | lua_pushnil(L); /* initialize subscache */ | 1146 | lua_pushnil(L); /* initialize subscache */ |
1146 | lua_pushlightuserdata(L, capture); /* initialize caplistidx */ | 1147 | lua_pushlightuserdata(L, capture); /* initialize caplistidx */ |
1147 | lua_getfenv(L, 1); /* initialize penvidx */ | 1148 | lua_getfenv(L, 1); /* initialize penvidx */ |
1148 | r = match(L, s, s + i, s + l, code, capture, ptop); | 1149 | r = match(L, s, s + i, s + l, code, capture, ptop, &labelf); |
1149 | if (r == NULL) { | 1150 | if (r == NULL) { |
1151 | int j = 0; | ||
1152 | int n = 1; | ||
1150 | lua_pushnil(L); | 1153 | lua_pushnil(L); |
1151 | return 1; | 1154 | while (j < (int) MAXLABELS) { |
1155 | if (labelf & (1 << j)) { | ||
1156 | lua_pushinteger(L, j); | ||
1157 | n++; | ||
1158 | } | ||
1159 | j++; | ||
1160 | } | ||
1161 | return n; | ||
1152 | } | 1162 | } |
1153 | return getcaptures(L, s, r, ptop); | 1163 | return getcaptures(L, s, r, ptop); |
1154 | } | 1164 | } |