[PR #80] Replace org.apache.regexp package with java.util.regex #107

Open
opened 2026-01-24 11:40:49 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/php/pftt2/pull/80
Author: @cmb69
Created: 10/17/2019
Status: 🔄 Open

Base: masterHead: regex


📝 Commits (2)

  • 61ed20c Replace org.apache.regexp package with java.util.regex
  • ddf5b24 Fix handling of %c%c sequences in EXPECTF sections

📊 Changes

14 files changed (+59 additions, -4500 deletions)

View changed files

📝 src/com/github/mattficken/io/StringUtil.java (+3 -9)
📝 src/com/mostc/pftt/model/core/PhptTestCase.java (+51 -106)
📝 src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java (+5 -26)
src/com/mostc/pftt/util/apache/regexp/CharacterArrayCharacterIterator.java (+0 -74)
src/com/mostc/pftt/util/apache/regexp/CharacterIterator.java (+0 -40)
src/com/mostc/pftt/util/apache/regexp/RE.java (+0 -1830)
src/com/mostc/pftt/util/apache/regexp/RECompiler.java (+0 -1468)
src/com/mostc/pftt/util/apache/regexp/REDebugCompiler.java (+0 -283)
src/com/mostc/pftt/util/apache/regexp/REProgram.java (+0 -182)
src/com/mostc/pftt/util/apache/regexp/RESyntaxException.java (+0 -41)
src/com/mostc/pftt/util/apache/regexp/REUtil.java (+0 -59)
src/com/mostc/pftt/util/apache/regexp/ReaderCharacterIterator.java (+0 -163)
src/com/mostc/pftt/util/apache/regexp/StreamCharacterIterator.java (+0 -159)
src/com/mostc/pftt/util/apache/regexp/StringCharacterIterator.java (+0 -60)

📄 Description

The former is ancient, unmaintained, non-standard, and doesn't really
support Perl regular expressions (which may be used by PHPTs), and
appears to be grossly buggy. Therefore we replace it with the Java SE
regular expression package, which is already used elsewhere anyway.

We also simplify the conversion of EXPECTF strings to regexps by doing
simple string replacements instead of regexp replacements, and make the
matching more strict by actually anchoring the pattern to avoid false
negatives.

Finally, we remove the regex debug stuff, since none of it is supported
by java.util.regex; if necessary, we will have to use a debugger.

This fixes #79.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/php/pftt2/pull/80 **Author:** [@cmb69](https://github.com/cmb69) **Created:** 10/17/2019 **Status:** 🔄 Open **Base:** `master` ← **Head:** `regex` --- ### 📝 Commits (2) - [`61ed20c`](https://github.com/php/pftt2/commit/61ed20cc505c947c56e90ce6eb0fc7553d130171) Replace org.apache.regexp package with java.util.regex - [`ddf5b24`](https://github.com/php/pftt2/commit/ddf5b24e8d2908b39c03e34a1d931f710e5ee6bf) Fix handling of %c%c sequences in EXPECTF sections ### 📊 Changes **14 files changed** (+59 additions, -4500 deletions) <details> <summary>View changed files</summary> 📝 `src/com/github/mattficken/io/StringUtil.java` (+3 -9) 📝 `src/com/mostc/pftt/model/core/PhptTestCase.java` (+51 -106) 📝 `src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner.java` (+5 -26) ➖ `src/com/mostc/pftt/util/apache/regexp/CharacterArrayCharacterIterator.java` (+0 -74) ➖ `src/com/mostc/pftt/util/apache/regexp/CharacterIterator.java` (+0 -40) ➖ `src/com/mostc/pftt/util/apache/regexp/RE.java` (+0 -1830) ➖ `src/com/mostc/pftt/util/apache/regexp/RECompiler.java` (+0 -1468) ➖ `src/com/mostc/pftt/util/apache/regexp/REDebugCompiler.java` (+0 -283) ➖ `src/com/mostc/pftt/util/apache/regexp/REProgram.java` (+0 -182) ➖ `src/com/mostc/pftt/util/apache/regexp/RESyntaxException.java` (+0 -41) ➖ `src/com/mostc/pftt/util/apache/regexp/REUtil.java` (+0 -59) ➖ `src/com/mostc/pftt/util/apache/regexp/ReaderCharacterIterator.java` (+0 -163) ➖ `src/com/mostc/pftt/util/apache/regexp/StreamCharacterIterator.java` (+0 -159) ➖ `src/com/mostc/pftt/util/apache/regexp/StringCharacterIterator.java` (+0 -60) </details> ### 📄 Description The former is ancient, unmaintained, non-standard, and doesn't really support Perl regular expressions (which may be used by PHPTs), and appears to be grossly buggy. Therefore we replace it with the Java SE regular expression package, which is already used elsewhere anyway. We also simplify the conversion of EXPECTF strings to regexps by doing simple string replacements instead of regexp replacements, and make the matching more strict by actually anchoring the pattern to avoid false negatives. Finally, we remove the regex debug stuff, since none of it is supported by java.util.regex; if necessary, we will have to use a debugger. This fixes #79. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-24 11:40:49 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: php/pftt2#107