Giter Club home page Giter Club logo

Comments (6)

monolifed avatar monolifed commented on September 1, 2024 1
static int matchquestion(regex_t p, regex_t* pattern, const char* text)
{
  // end of pattern
  if(p.type == UNUSED)
    return 1;
  // already matches without optional part
  if (matchpattern(pattern, text))
      return 1;
  // optional part matches; advance
  if (*text && matchone(p, *text))
    return matchpattern(pattern, text + 1);
  return 0;
}

I hope this works better than the last time
(It still fails some of the make test tests)

Edit:
I believe first one \d+\w?\D\d fails because it generates strings for \d+\w?\d\d
The second a?b[ac*]*.?[\]+[?]? fails because of the part [\]+[?] (\] is not handled so the first ] ends the class)

from tiny-regex-c.

kokke avatar kokke commented on September 1, 2024 1

@monolifed

This should be closed no?

from tiny-regex-c.

kokke avatar kokke commented on September 1, 2024

Hi @tobermory - thanks for reporting this issue.

I agree, "X?Z" should not match "Z".
This is a bug in the question-mark matching code, but I am not quite sure how to fix it.

For now, I will add your failing test-case to the list of hand-picked tests in the test-suite.
At least that makes it visible that something is failing in that area.
That also means I can track when it gets fixed -- that's a start.

If you have time to look at it, feel free to submit a Pull Request fixing the issue.

Regarding the index-difference between the iterative and the recursive version -- that looks suspicious, I agree.

from tiny-regex-c.

kokke avatar kokke commented on September 1, 2024

Hi @monolifed and thanks for contributing :)

I am not near a computer now, but I will review your suggested changes and try to see if I can make sense of the failing cases.

from tiny-regex-c.

kokke avatar kokke commented on September 1, 2024

Hey @monolifed - I just had a few minutes to look at this again.
I think I agree with your diagnosis of the first failing case:

pattern '\d+\w?\D\d': FAIL : doesn't match '18' as expected [0x31, 0x38].

'18' does indeed not match \d+\w?\D\d, so something is wrong with the input data being generated.
Should be possible to find the problem and fix that in the Python code.

Haven't had the time to look at the second failing case yet, but your explanation sounds plausible. Failing to handle the backspace as a character-class [\] would explain the failure.

I will try to review ASAP, but I may not have the time before the end of this week.

I suggest you make a pull request containing the changes, which I will then merge.
That way, you get proper attribution for the fix :)

from tiny-regex-c.

monolifed avatar monolifed commented on September 1, 2024
        /* Copy characters inside [..] to buffer */
        while (    (pattern[++i] != ']')
                && (pattern[i]   != '\0')) /* Missing ] */
        {
          if (ccl_bufidx >= MAX_CHAR_CLASS_LEN) {
              //fputs("exceeded internal buffer!\n", stderr);
              return 0;
          }
+++          if (pattern[i] == '\\')
+++            ccl_buf[ccl_bufidx++] = pattern[i++];
          ccl_buf[ccl_bufidx++] = pattern[i];
        }

this seems to fix unhandled \] in char-class but there is a possibility of overflow
(ccl_bufidx == MAX_CHAR_CLASS_LEN - 1 && pattern[i] == '\')

from tiny-regex-c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.