Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

slre regex miss match

while using slre regex library I have found a strange thing. When I pass to the slre_match function a buffer where string, after s_len charachetrs doesn't end with NULL it doesnt work properly. Here is my example:
i32ResCode = slre_match(READ_ACCESS, CommandStrings.p8Command, CommandStrings.u32Length, CapturedAccessor, 5, 0);
READ_ACCESS = "0-9 [ \r]"
CommandStrings.p8Command is a pointer to buffer: "p w 0\r0\r"
CommandStrings.u32Length = 6
CapturedAccessor is an array of 5 elements

after processing it, i32ResCode is equal to 7.
Can anyone explain me how? How it could read 7 charachters with a length of 6? And whats more how it could find any match?


there is a bug in READ_ACCESS printed above, because of special charachetr "?"
it should look like that:
[0-9 ]
[ \r]
of course without those enters at the end of line


  • SergeySergey Dublin, Ireland

    You have to capture the match.
    Something like const char *regex = "([0-9])[ \\r]";

  • But I want to get SLRE_NO_MATCH result in this case.

  • SergeySergey Dublin, Ireland

    If you update the unit_test.c with your failing case, and send a PR, that would be most helpful!

  • Can you explain me what I should do? It is part of code of embedded device, so it would be rather hard to make an unit test.

  • SergeySergey Dublin, Ireland

    Basically, update SLRE's unit_test.c to demonstrate the bug, and send me a GitHub pull request. We'll fix the bug.

Sign In or Register to comment.