hyperscan icon indicating copy to clipboard operation
hyperscan copied to clipboard

MULTILINE doesn't match CRLF

Open BiBi-Abc opened this issue 5 years ago • 3 comments

I was testing hyperscan and chimera to match some text. With this regex:

^hello$

and this text (WITH CRLF):

test
hello
testing

there are no matches found. Keep in mind this only occurs with CRLF.

It's compiled using MULTILINE flag.

Here is fully reproducible code:

#include <iostream>
#include "hs.h"
int matchHandler(unsigned int id, unsigned long long from, unsigned long long to, unsigned int flags, void* context)
{
	std::cout << "Matched to " << to << "\n";
	return 0;
}
int main()
{
	hs_database* database = nullptr;
	hs_compile_error* compileError = nullptr;
	hs_compile("^hello$", HS_FLAG_MULTILINE, HS_MODE_BLOCK, nullptr, &database, &compileError);

	hs_scratch* scratch = nullptr;
	hs_alloc_scratch(database, &scratch);

	const char* data = "test\r\nhello\r\ntesting"; // Works switching \r to \n
	hs_scan(database, data, strlen(data), 0, scratch, matchHandler, nullptr);
}

This also happens on Chimera.

I would greatly appreciate it if there was a fix for either of the 2.

BiBi-Abc avatar Sep 29 '20 22:09 BiBi-Abc

I doubt this is an issue with Hyperscan.

What's your testing environment? I think \r\n is regarded a a newline only on Windows system.

xiangwang1 avatar Sep 30 '20 02:09 xiangwang1

I'm using Windows.

BiBi-Abc avatar Sep 30 '20 03:09 BiBi-Abc

I have this problem too on centos 7 I hope to deal with it as soon as possible

rationa1 avatar Mar 01 '23 06:03 rationa1