Hi. Bruno Haible <br...@clisp.org> wrote:
> - if REG_NEWLINE is not set, '.' matches newline but '^' does not match > after the newline. This is indeed the desired behavior, but regex isn't following it. REG_NEWLINE being set gets translated into preg->newline_anchor. Starting at line 620, regexec.c relates to it: | /* If initial states with non-begbuf contexts have no elements, | the regex must be anchored. If preg->newline_anchor is set, | we'll never use init_state_nl, so do not check it. */ | if (dfa->init_state->nodes.nelem == 0 | && dfa->init_state_word->nodes.nelem == 0 | && (dfa->init_state_nl->nodes.nelem == 0 | || !preg->newline_anchor)) | { | if (start != 0 && last_start != 0) | return REG_NOMATCH; | start = last_start = 0; | } (As a side note, I don't think the comment matches the code.) In my case, preg->newline_anchor is zero (correctly), but dfa->init_state->nodes.nelem is not, so this body isn't executed. Making the test for preg->newline_anchor the first thing causes my test case to work correctly but breaks the gawk test suite. In other words, I think the bug is somewhere in this area, but I don't understand the regex internals enough to fix it. dfa will also need looking at. Thanks, Arnold