mbox series

[0/3] Fun with cpp word regex

Message ID pull.1054.git.1633589461.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series Fun with cpp word regex | expand

Message

Philippe Blain via GitGitGadget Oct. 7, 2021, 6:50 a.m. UTC
The cpp word regex driver is a bit too loose and can match too much text
where the intent is to match only a number. The first patch fixes that.

The other two patches add support for digit separators and the spaceship
operator <=> (generalized comparison operator).

I left out support for hexadecimal floating point constants because that
would require to tighten the regex even more to avoid that entire
expressions are treated as single tokens.

Johannes Sixt (3):
  userdiff: tighten cpp word regex
  userdiff: permit the digit-separating single-quote in numbers
  userdiff: learn the C++ spaceship operator

 userdiff.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)


base-commit: 225bc32a989d7a22fa6addafd4ce7dcd04675dbf
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1054%2Fj6t%2Ffun-with-cpp-word-regex-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1054/j6t/fun-with-cpp-word-regex-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1054

Comments

Ævar Arnfjörð Bjarmason Oct. 7, 2021, 9:14 a.m. UTC | #1
On Thu, Oct 07 2021, Johannes Sixt via GitGitGadget wrote:

> The cpp word regex driver is a bit too loose and can match too much text
> where the intent is to match only a number. The first patch fixes that.
>
> The other two patches add support for digit separators and the spaceship
> operator <=> (generalized comparison operator).
>
> I left out support for hexadecimal floating point constants because that
> would require to tighten the regex even more to avoid that entire
> expressions are treated as single tokens.
>
> Johannes Sixt (3):
>   userdiff: tighten cpp word regex
>   userdiff: permit the digit-separating single-quote in numbers
>   userdiff: learn the C++ spaceship operator
>
>  userdiff.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

I haven't dug into the C++ syntax here, I trust you know what you're
doing there.

But some tests in t/t4034/cpp/* would be great, and seem from the files
easy to add. E.g. wouldn't changing:

    a<b a<=b a>b a>=b


to:

    a<b a<=b a>b a>=b a<=>b

Give you an updated regression test for your 3/3? Similar changes can be
done for 1-2/3.
Johannes Sixt Oct. 7, 2021, 4:40 p.m. UTC | #2
Am 07.10.21 um 11:14 schrieb Ævar Arnfjörð Bjarmason:
> But some tests in t/t4034/cpp/* would be great, and seem from the files
> easy to add. E.g. wouldn't changing:

Ah, I didn't notice that we actually have tests for word-diff. I'll look
into it and resubmit.

-- Hannes