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

[regex-ripout] part 2/n #431

Merged
merged 17 commits into from
Mar 16, 2022
Merged

Conversation

strega-nil
Copy link
Contributor

No description provided.

also rename reformat_version -> format_version_for_nugetref
src/vcpkg/tools.cpp Outdated Show resolved Hide resolved
src/vcpkg/tools.cpp Outdated Show resolved Hide resolved
src/vcpkg/versions.cpp Outdated Show resolved Hide resolved
@@ -25,25 +25,57 @@ namespace vcpkg
std::string sha512;
};

static Optional<std::array<int, 3>> parse_version_string(const std::string& version_as_string)
// /\d+\.\d+(\.\d+)?/
static Optional<std::array<int, 3>> parse_version_string(StringView string_version)
Copy link
Member

Choose a reason for hiding this comment

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

While I have outstanding changes to tools.cpp, this change will not create issues for me.

src/vcpkg/versions.cpp Outdated Show resolved Hide resolved
src/vcpkg/tools.cpp Show resolved Hide resolved
src/vcpkg/versions.cpp Outdated Show resolved Hide resolved
}

// /(\d+)(\.\d+|$)(\.\d+)?.*/
bool try_parse_external_dot_version(ParsedExternalVersion& out, StringView version)
Copy link
Member

Choose a reason for hiding this comment

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

This needs a test consisting of at least all the current values from vcpkgTools.xml.

Copy link
Member

Choose a reason for hiding this comment

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

This API is different in character than our other try_parse_Xxx functions in that they tend to return a structure (or write to a structure) that owns its data, while the lifetime of the data fed to this is tied to the caller. I'm a little worried of someone doing:

    try_parse_external_dot_version(x, something_that_returns_std_string())

Would it make sense to make ParsedExternalVersion have strings rather than StringViews inside?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to not do that, but I will if you insist. This is mostly an implementation detail function that's been pulled out into it's own thing.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's reasonable; do we want a new name like "try_extract" rather than "try_parse" to indicate this ownership difference? ("I think you're being paranoid Bill" is a reasonable answer ;))

src/vcpkg/versions.cpp Show resolved Hide resolved
src/vcpkg/commands.autocomplete.cpp Show resolved Hide resolved
Additionally, this includes a change to be more correct:
&#x<hex>; is now considered a character reference.
src/vcpkg/versions.cpp Outdated Show resolved Hide resolved
@strega-nil-ms strega-nil-ms force-pushed the regex-ripout-2 branch 2 times, most recently from e05d570 to 5143398 Compare March 15, 2022 05:06
strega-nil and others added 4 commits March 15, 2022 15:13
# Conflicts:
#	include/vcpkg/base/strings.h
#	src/vcpkg/commands.autocomplete.cpp
#	src/vcpkg/sourceparagraph.cpp
Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

This approval is conditional on removing the now unused <charconv> include; everything else are nitpicks.

include/vcpkg/base/strings.h Outdated Show resolved Hide resolved
src/vcpkg/export.ifw.cpp Outdated Show resolved Hide resolved
src/vcpkg/export.ifw.cpp Outdated Show resolved Hide resolved
src/vcpkg/export.ifw.cpp Outdated Show resolved Hide resolved
src/vcpkg/export.ifw.cpp Outdated Show resolved Hide resolved
src/vcpkg/export.ifw.cpp Outdated Show resolved Hide resolved
src/vcpkg/metrics.cpp Outdated Show resolved Hide resolved
src/vcpkg/metrics.cpp Outdated Show resolved Hide resolved
src/vcpkg/metrics.cpp Outdated Show resolved Hide resolved
@BillyONeal
Copy link
Member

Thanks for adding tests :D

* put is_hex_digit and is_word_char into parserbase
* try_parse_external_*_version -> try_extract_external_*_version
* add ZERO_MAC constant
* add consts to `last`
* make `is_character_ref` a function
@strega-nil-ms strega-nil-ms merged commit 460b058 into microsoft:main Mar 16, 2022
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