Skip to content

Conversation

@NWilson
Copy link
Member

@NWilson NWilson commented Jun 2, 2025

Part of #549

@NWilson NWilson force-pushed the user/niwilson/erroroffset-tests branch from 08775ee to cccf7bd Compare June 2, 2025 12:49
@NWilson NWilson marked this pull request as ready for review June 2, 2025 13:30
@NWilson NWilson merged commit 7c7a274 into master Jul 19, 2025
35 checks passed
@NWilson NWilson deleted the user/niwilson/erroroffset-tests branch July 19, 2025 13:41
orlitzky added a commit to orlitzky/php-src that referenced this pull request Nov 5, 2025
In the latest version of libpcre2, the offsets appearing in some
"compilation failed" warnings have increased by one, as a result of

  PCRE2Project/pcre2#756

This is causing spurious test failures, so in this commit we replace
the hard-coded offsets by %d to match any integer.

Gentoo-bug: https://bugs.gentoo.org/965018
orlitzky added a commit to orlitzky/php-src that referenced this pull request Nov 5, 2025
In the latest version of libpcre2, the offsets appearing in some
"compilation failed" warnings have increased by one, as a result of

  PCRE2Project/pcre2#756

This is causing spurious test failures, so in this commit we replace
the hard-coded offsets by a regex that matches both values.

Gentoo-bug: https://bugs.gentoo.org/965018
iluuu1994 pushed a commit to php/php-src that referenced this pull request Nov 7, 2025
In the latest version of libpcre2, the offsets appearing in some
"compilation failed" warnings have increased by one, as a result of

  PCRE2Project/pcre2#756

This is causing spurious test failures, so in this commit we replace
the hard-coded offsets by a regex that matches both values.

Gentoo-bug: https://bugs.gentoo.org/965018

Closes GH-20397
@jirislaby
Copy link

If I pass ".*.*$*X" to pcre2_compile(), I get erroroffset at 6 (X) now. It used to be 5 (*). Is this expected?

@NWilson
Copy link
Member Author

NWilson commented Dec 12, 2025

In Perl, if I try the regex:

my $regex = qr/.*.*$*X/;

The error message is $* is no longer supported as of Perl 5.30 which contains no character offset.

However if I try the (similar) my $regex = qr/.*.*\K*X/ the error message is:

\K* matches null string many times in regex; marked by <-- HERE in m/.*.*\K* <-- HERE X/

Perl's error offset is consistently pointing to the caret position in between the * and X.

In pcre2test the same test gives:

$ ./pcre2test
PCRE2 version 10.48-DEV 2025-10-21 (8-bit)
  re> /.*.*$*X/
Failed: error 109 at offset 6: quantifier does not follow a repeatable item
        here: .*.*$* |<--| X

I am satisfied that this is consistent with the way Perl reports error messages, with the offset just to the right of the error.

The change was intentional. I apologise if this has caused problems for your application.

In a future version of PCRE2, I plan to add a function to retrieve the "error direction" to improve on the current "error offset". The error direction would indicate to text-based applications whether the error is <-- HERE to the left of the offset, or HERE --> to the right. I have considered adding a start/end position to the offset (for highlighting), but I have not heard any demand for that yet.

@jirislaby
Copy link

The change was intentional. I apologise if this has caused problems for your application.

Fine by me. Except the reporting has to be different for 10.47+ and earlier versions...

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.

3 participants