diff options
Diffstat (limited to 'lptree.c')
-rw-r--r-- | lptree.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -1198,10 +1198,12 @@ static int lp_match (lua_State *L) { | |||
1198 | size_t i = initposition(L, l); | 1198 | size_t i = initposition(L, l); |
1199 | int ptop = lua_gettop(L); | 1199 | int ptop = lua_gettop(L); |
1200 | Labelset labelf; /* labeled failure */ | 1200 | Labelset labelf; /* labeled failure */ |
1201 | const char *sfail = NULL; /* labeled failure */ | ||
1201 | lua_pushnil(L); /* initialize subscache */ | 1202 | lua_pushnil(L); /* initialize subscache */ |
1202 | lua_pushlightuserdata(L, capture); /* initialize caplistidx */ | 1203 | lua_pushlightuserdata(L, capture); /* initialize caplistidx */ |
1203 | lua_getfenv(L, 1); /* initialize penvidx */ | 1204 | lua_getfenv(L, 1); /* initialize penvidx */ |
1204 | r = match(L, s, s + i, s + l, code, capture, ptop, &labelf); /* labeled failure */ | 1205 | r = match(L, s, s + i, s + l, code, capture, ptop, &labelf, &sfail); /* labeled failure */ |
1206 | /*printf("sfail = %s\n", sfail);*/ | ||
1205 | if (r == NULL) { /* labeled failure begin */ | 1207 | if (r == NULL) { /* labeled failure begin */ |
1206 | int j = 0; | 1208 | int j = 0; |
1207 | int n = 1; | 1209 | int n = 1; |
@@ -1210,10 +1212,12 @@ static int lp_match (lua_State *L) { | |||
1210 | if (labelf & (1 << j)) { | 1212 | if (labelf & (1 << j)) { |
1211 | lua_pushinteger(L, j); | 1213 | lua_pushinteger(L, j); |
1212 | n++; | 1214 | n++; |
1215 | break; /* Changing the semantics: only one label */ | ||
1213 | } | 1216 | } |
1214 | j++; | 1217 | j++; |
1215 | } | 1218 | } |
1216 | return n; | 1219 | lua_pushstring(L, sfail); /* Pushing the subject where the failure occurred */ |
1220 | return n + 1; | ||
1217 | } /* labeled failure end */ | 1221 | } /* labeled failure end */ |
1218 | return getcaptures(L, s, r, ptop); | 1222 | return getcaptures(L, s, r, ptop); |
1219 | } | 1223 | } |