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

X3: Fix on_success dispatcher inverted iterator const/mutability #711

Conversation

Kojoley
Copy link
Collaborator

@Kojoley Kojoley commented Jan 13, 2022

Instead of usual [current, end) pair it receives [before, current) pair.

Fixes #703 (comment)

Instead of usual `[current, end)` pair it receives `[before, current)` pair.
@Kojoley Kojoley force-pushed the x3-on_success-dispatcher-inverted-iterator-mutability branch from f967d9a to facd2ee Compare January 14, 2022 15:44
@Kojoley Kojoley merged commit 2f5c2cb into boostorg:develop Jan 15, 2022
@Kojoley Kojoley deleted the x3-on_success-dispatcher-inverted-iterator-mutability branch January 15, 2022 17:28
jktjkt pushed a commit to CESNET/netconf-cli that referenced this pull request Jan 18, 2022
New Boost does not revert iterators in some cases, so reverting must be
done manually.

About the command_completion change: I have no idea, but the 1.77 fix
works for 1.78.

This actually needs this patch
boostorg/spirit#711. No idea how to inject that
to the CI.

Issue: boostorg/spirit#703 (comment)
Change-Id: I2d1266b1f8b893f180ae36842bdfdb35c5629ea4
jktjkt added a commit to CESNET/netconf-cli that referenced this pull request Jun 21, 2023
Up to Boost 1.77, it was enough to just call this from the `on_success`
handler:

 _pass(context) = false;

...and the spirit-x3 core would auto-revert the iterators. The sky was
pink and the unicorns were flying with their horns upright. Starting
with 1.78, though, the auto-reposition of the input iterators was
removed, which necessitated resetting them by hand. However, this
required casting away the constness of the `after` iterator because the
function signature was just wrong, passing a non-const iterator
reference for the `before` iterator (which we do not need to modify),
and a const one for the `after` iterator that we do want to modify.
Functions with a non-const reference to the `after` iterator wouldbe
silently ignored ("hey, it's just a function that I'm not calling, no
***** given").

That was fixed in 1.80, but we want to make sure that we work on the
latest Fedora which only has Boost 1.78, even though upstream already
released Boost 1.82.

Fix that by using `const` function signatures, but cast that const away
at runtime.

Also for consistency, always overwrite that iterator whenever rejecting
the input -- no matter whether the current version of Boost needs it or
not, and even in cases where the previous version of code would "just"
reject parsing, but keep the after iterator on its new value.

Bug: boostorg/spirit#711
Bug: boostorg/spirit#703
Fixes: 5b8e282 Fix for Boost 1.78
Change-Id: Ib603db643a086e0351a4d74082505329ab8944cb
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

Successfully merging this pull request may close these issues.

X3: Rules no longer roll back iterator when forced to fail in an on_success handler
1 participant