Consider this program, which tries to match zero or more space characters in a string of length zero:
// $ cat empty-str.c
#include "re.h"
#include "assert.h"
int main() {
int matchlength = 0;
int pos = re_match("\\s*", "", &matchlength);
assert(pos != -1);
return 0;
}
When compiled with re.c and executed, the assertion fails:
$ gcc empty-str.c re.c
$ ./a.out
a.out: empty-str.c:7: main: Assertion `pos != -1' failed.
Aborted (core dumped)
It is an interesting question about what the result of a successful match for an empty string should be. My take on it is that it should not report a failure for matching (i.e. the return value must not be negative), but the length of the match should be zero.