Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.{0,99} and .* behave differently on short input #284

Closed
jorendorff opened this issue May 19, 2023 · 2 comments
Closed

.{0,99} and .* behave differently on short input #284

jorendorff opened this issue May 19, 2023 · 2 comments

Comments

@jorendorff
Copy link

Add these lines to test/test_syntax.c:

  x2("^\\s*B\\n\\s*M\\s*.{0,99}\\R", "B\n  M;\n", 0, 7);
  x2("^\\s*B\\n\\s*M\\s*.*\\R", "B\n  M;\n", 0, 7);

The output is:

OK: /^\s*B\n\s*M\s*.{0,99}\R/ 'B
  M;
'
FAIL: /^\s*B\n\s*M\s*.*\R/ 'B
  M;
'

RESULT   SUCC:  172,  FAIL: 1,  ERROR: 0      (by Oniguruma 6.9.8)

I think both regexes should match.

@tonco-miyazawa
Copy link

Below is another sample code.

  // issue 284
  x2("\\A.*\\R", "\n", 0, 1);       // .*   FAIL
  x2("\\A\\O*\\R", "\n", 0, 1);     //      FAIL
  x2("\\A\\n*\\R", "\n", 0, 1);     //      FAIL
  x2("\\A\\R*\\R", "\n", 0, 1);
  x2("\\At*\\R", "\n", 0, 1);

  x2("\\A.{0,99}\\R", "\n", 0, 1);   // {0,99}
  x2("\\A\\O{0,99}\\R", "\n", 0, 1);
  x2("\\A\\n{0,99}\\R", "\n", 0, 1);
  x2("\\A\\R{0,99}\\R", "\n", 0, 1);
  x2("\\At{0,99}\\R", "\n", 0, 1);

  x2("\\A.*\\n", "\n", 0, 1);       //  \n
  x2("\\A.{0,99}\\n", "\n", 0, 1);

  x2("\\A.*\\O", "\n", 0, 1);       //  \O 
  x2("\\A.{0,99}\\O", "\n", 0, 1);

  x2("\\A.*\\s", "\n", 0, 1);       //  \s
  x2("\\A.{0,99}\\s", "\n", 0, 1);

@kkos
Copy link
Owner

kkos commented May 20, 2023

It did indeed FAIL in the first three cases.
I will look into the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants