Giter Club home page Giter Club logo

Comments (4)

firasuke avatar firasuke commented on June 14, 2024 1

Sorry for the trouble this may have caused. Glad you found this and shared it with us! An update will be released soon after a more testing to verify everything.

Yeah, no worries. Thanks for your time and effort on this project.

Keep up the good work!

from ugrep.

genivia-inc avatar genivia-inc commented on June 14, 2024

I don't think that is a problem caused by any combinations of options, because none of the other options have any effect on the context. If anything differs or matters, it is the pattern itself, which is also modified with -w to match words using anchors.

Since we don't have your test case, you need to help us out here a bit. Can you be a bit more specific? Are after contexts always missing, or in some cases and when?

from ugrep.

firasuke avatar firasuke commented on June 14, 2024

Here's the pattern I am using.

With grep:
image

With ugrep:
image

from ugrep.

genivia-inc avatar genivia-inc commented on June 14, 2024

Looks like there is an "off by one" problem, where the match position counter is off by one and that messes with the context position that no longer aligns. I also see the issue with .*, but not with different patterns even when those match the same initial part of a pattern. To show the differences, note the second search shows the context:

image

With a bit of tracing I found out that the difference between these cases is observable only in parts that actually do not match, like in the after context line. The internal pointer/position is moved by one so the context is no longer the same.

So it flew under the radar since pattern matching is OK, but the after contexts are not when this pattern is used. The "off by one" problem is triggered with the initial used of .* in a pattern and affects the after context (in most cases it appears to affect the after context after the last match, not in between matches, but not 100% sure).

The fix is actually very simple. The "off by one" happens in the pattern matcher, which is in an optimization that scans ahead when nothing possibly matches. The fixed version is correct:

image

Sorry for the trouble this may have caused. Glad you found this and shared it with us! An update will be released soon after a more testing to verify everything.

from ugrep.

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.