Add-ons: add fallback code for compilers without working <regex>
This is another place where the add-on code uses regexps, and so far I had forgotten to add the fallback code for compilers that don't support <regex> as per the C++11 standard.
This commit is contained in:
parent
1f2ba814a4
commit
39bf5d6b8a
1 changed files with 8 additions and 0 deletions
|
@ -338,11 +338,19 @@ Addon::MetadataParser::parseLicenseNode(const SGPath& addonPath,
|
|||
"however it starts with '" + licenseFile_s[0] + "'");
|
||||
}
|
||||
|
||||
#ifdef HAVE_WORKING_STD_REGEX
|
||||
std::regex winDriveRegexp("([a-zA-Z]:).*");
|
||||
std::smatch results;
|
||||
|
||||
if (std::regex_match(licenseFile_s, results, winDriveRegexp)) {
|
||||
string winDrive = results.str(1);
|
||||
#else // all this 'else' clause should be removed once we actually require C++11
|
||||
if (licenseFile_s.size() >= 2 &&
|
||||
(('a' <= licenseFile_s[0] && licenseFile_s[0] <= 'z') ||
|
||||
('A' <= licenseFile_s[0] && licenseFile_s[0] <= 'Z')) &&
|
||||
licenseFile_s[1] == ':') {
|
||||
string winDrive = licenseFile_s.substr(0, 2);
|
||||
#endif
|
||||
throw errors::error_loading_metadata_file(
|
||||
"in add-on metadata file '" + metadataFile.utf8Str() + "': the "
|
||||
"value of /addon/license/file must be relative to the add-on folder, "
|
||||
|
|
Loading…
Add table
Reference in a new issue