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

Add utf8_hop functions that return error detection #22689

Merged
merged 6 commits into from
Oct 28, 2024

Commits on Oct 21, 2024

  1. regen/embed.pl: Handle m with p flags

    Prior to this commit these were illegal.  This allows it when there is
    no pesky thread context in the way.
    
    This causes embed.fnc to generate macro 'Perl_foo' #defined to be  macro
    'foo'.  This could be used to easily convert existing macros into having
    long names should that become a name space pollution problem.
    
    But more immediately, we have scattered around, various one line
    functions that simply call something else.  Those were typically created
    to preserve the pre-existing API should someone be using the long name,
    and the implementation changed.
    
    This commit allows those (that don't use thread context) to be
    conveniently replaced by a macro.  The next couple commits will do that
    for a couple of them.
    khwilliamson committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    e90920a View commit details
    Browse the repository at this point in the history
  2. Add utf8_hop_back_overshoot()

    This is like plain utf8_hop_back() except it returns how many
    characters the request would have overshot the edge if it had been
    allowed to go beyond the edge.
    
    This allows the caller to do error handling.
    
    The code has to be changed to be more careful (than before this commit)
    with counting the actual number of characters consumed in the hop.
    khwilliamson committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    eed9d14 View commit details
    Browse the repository at this point in the history
  3. utf8_hop_forward: Do nothing if distance is 0

    There is a subtle difference here with existing behavior.  Most of the
    time a zero hop already does nothing; but if the initial conditions were
    that we were starting the hop past the edge, a runtime error was raised,
    even though the action was a no-op.  Its arguable what to do in this
    case, but I believe the new behavior is more correct, and it paves the
    way for future commits where it is more clearly more correct.
    
    This adds a conditional and indents the code within the new block,
    removing now-redundant conditionals.
    khwilliamson committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    db9fb9b View commit details
    Browse the repository at this point in the history
  4. utf8_hop_forward: Break from loop instead of returning early

    This is in preparation for a future commit where we will need to do
    finish-up work before returning.
    khwilliamson committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    b2f4fc1 View commit details
    Browse the repository at this point in the history
  5. Add utf8_hop_forward_overshoot()

    This is like plain utf8_hop_forward() except it returns how many
    characters the request would have overshot the edge if it had been
    allowed to go beyond the edge.
    
    This allows the caller to do error handling.
    
    The code has to be changed to be more careful (than before this commit)
    with counting the actual number of characters consumed in the hop.
    khwilliamson committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    215cdde View commit details
    Browse the repository at this point in the history
  6. Add utf8_hop_overshoot()

    This is like utf8_hop_safe(), but also returns the number of characters
    that would have overshot the edge if it had been allowed to go beyond
    the edge
    khwilliamson committed Oct 21, 2024
    Configuration menu
    Copy the full SHA
    e7aac80 View commit details
    Browse the repository at this point in the history