Comments (6)
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.
This should be closed no?
from tiny-regex-c.
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.
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.
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.
/* 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)
- matchlen may be wrong HOT 5
- Incorrect results for repeat operators HOT 3
- I ported this to rust HOT 1
- Add Precompiled Regex Code Generator HOT 4
- Python random tests are failing but CI is passing
- regex compilation is making things slower? HOT 1
- support for non-greedy `*?` and `+?`
- Wrong match length? HOT 3
- Error on isdigit, isalpha, isspace with char > 127
- re_matchp succeeds only for the first string compared to a pattern HOT 1
- vcpkg installion windows - length is not changing in return
- support for {n,m},repeat N to M times? HOT 1
- Software vulnerabilities detected during code analysis with ESBMC-WR tool HOT 1
- fix pattern '[1-5-]+' against '123-'
- Do not support {n, m} feature. HOT 1
- Not only does [^blah] not work but the non-inverted [blah] doesn't work either HOT 1
- Cannot match end-of-pattern match
- re. HOT 1
- Match of `\\s*` on empty string reports `pos == -1`, i.e., no match, while it should report `pos == 0` and `matchlength == 0`
- Migrate all test scripts to Python v3 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiny-regex-c.