Skip to content

Commit 7f6ce10

Browse files
Bugfix
* enclosed occurrences are correctly handled when using a single extractor with multiple streams
1 parent 47c7310 commit 7f6ce10

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/extractor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ bool extractor_c_set_stream(extractor_c * self, stream_c * stream){
279279
self->miners[m]->set_stream(self->miners[m], self->stream);
280280
}
281281

282+
self->last_max = 0;
283+
282284
pthread_mutex_unlock(&(self->mutex_extractor));
283285

284286
return true;

tests/enclosed.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,25 @@ void identical_ranges(void **arg) {
269269
test_match(ex, 1, fullpath, 2);
270270
}
271271

272+
/**
273+
* Tests whether enclosed occurrences are handled correctly when using multiple
274+
* streams with a single extractor.
275+
*
276+
* @param arg whatever cmocka passes here
277+
*/
278+
void stream_reset(void **arg) {
279+
const char *fullpath = make_file("abc abc");
280+
const char *globs[] = {
281+
"abc",
282+
NULL
283+
};
284+
extractor_c *ex = make_extractor(globs);
285+
ex->set_flags(ex, E_NO_ENCLOSED_OCCURRENCES);
286+
287+
test_match(ex, 1, fullpath, 2);
288+
test_match(ex, 1, fullpath, 2);
289+
}
290+
272291
/**
273292
* Destroys created extractors and deletes created files.
274293
*/
@@ -317,7 +336,8 @@ int main(int argc, char *argv[]) {
317336
cmocka_unit_test(single_batch),
318337
cmocka_unit_test(multi_batch),
319338
cmocka_unit_test(small_batch),
320-
cmocka_unit_test(identical_ranges)
339+
cmocka_unit_test(identical_ranges),
340+
cmocka_unit_test(stream_reset)
321341
};
322342

323343
atexit(cleanup);

0 commit comments

Comments
 (0)