Skip to content

Conversation

@tobiolo
Copy link
Contributor

@tobiolo tobiolo commented May 1, 2025

No description provided.

@tobiolo tobiolo force-pushed the regex-stdcpp branch 4 times, most recently from b68ee3c to 2280f2f Compare May 1, 2025 09:41
@lauft lauft self-assigned this May 1, 2025
@lauft lauft requested a review from Copilot May 1, 2025 21:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the UNIX regex API with the Standard C++ regex library to improve portability and modernize the code.

  • Removed platform-specific regex tests and updated them to use standard regex patterns.
  • Replaced legacy <regex.h> with in the header file and updated the regex type.
  • Modified the regex compilation and matching methods in the implementation file to use std::regex and associated APIs.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/rx.t.cpp Updated regex tests to rely solely on standard regex patterns.
src/RX.h Replaced <regex.h> with and updated the _regex member type.
src/RX.cpp Converted legacy regex functions to std::regex API for compile/match.

@lauft
Copy link
Member

lauft commented May 2, 2025

LGTM, I am all in favor of using standards. For Timewarrior, this is fine, it is not expecting regex strings on the command line.

However, this may be an issue for Taskwarrior users? 👉🏻 @djmitche

src/RX.cpp Outdated
Comment on lines 104 to 107
std::string::const_iterator search_start(in.cbegin());
std::string::const_iterator search_end(in.cend());

while (std::regex_search(search_start, search_end, sm, _regex)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified quite a bit!

Copy link
Contributor Author

@tobiolo tobiolo May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback! It can be written a lot nicer than this.

ut.ok (r9.match (start, end, text), "e there are matches");
ut.is (start.size (), (size_t) 6, "e == 6 matches");

#if defined(DARWIN) || defined(CYGWIN) || defined(FREEBSD) || defined(OPENBSD)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting a bunch of test cases doesn't fill me with confidence! It looks like, at least for these platforms, some of the allowed syntax changes. The details of the changes should certainly be documented and tested, and we can evaluate the impact on Taskwarrior from there.

In particular, if \d doesn't work to match a digit anymore, that might affect a lot of users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue seems to be solved, too. I just had to stick with ECMAScript grammar that supports all test cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! In that case, is this change expected to have no user-visible impact?

Copy link
Contributor Author

@tobiolo tobiolo May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell from Ecmascript at cppreference.com there is no user-visible impact. The ECMAScript grammar seems to cover the use cases.

@tobiolo tobiolo force-pushed the regex-stdcpp branch 2 times, most recently from 0804d06 to d8ff51b Compare May 2, 2025 22:57
@tobiolo
Copy link
Contributor Author

tobiolo commented May 2, 2025

This would be ready to go from my side :-) Thanks for your reviews so far!

@djmitche djmitche merged commit 8ad3646 into GothenburgBitFactory:master May 3, 2025
8 checks passed
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