MULTILINE doesn't match CRLF
- Dominant language
- C++
- Stars
- 5.5k
- Forks
- 816
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 2
Description
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
#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.
Contributor guide
Assessment
This issue has not been assessed yet.