From f70d56bf74e395dbaf3f6bb7cf49ea9564585b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Fri, 20 Dec 2024 15:11:37 -0300 Subject: [PATCH] Bug fixed versioning. --- src/lib/mrvFl/mrvVersioning.cpp | 51 +++++++++++++++++---------------- src/po/de.po | 2 +- src/po/en.po | 2 +- src/po/es.po | 2 +- src/po/fr.po | 2 +- src/po/hi_IN.po | 2 +- src/po/it.po | 2 +- src/po/pt.po | 2 +- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/lib/mrvFl/mrvVersioning.cpp b/src/lib/mrvFl/mrvVersioning.cpp index 97886d62b..4da8f3da5 100644 --- a/src/lib/mrvFl/mrvVersioning.cpp +++ b/src/lib/mrvFl/mrvVersioning.cpp @@ -30,10 +30,12 @@ namespace mrv { std::string regex_escape(const std::string& input) { - static const std::regex special_chars(R"([.^$|()[]{}*+?\\])"); // Special regex characters - return std::regex_replace(input, special_chars, R"(\$&)"); // Prefix with '\' + static const std::regex special_chars( + R"([.^$|()[]{}*+?\\])"); // Special regex characters + return std::regex_replace( + input, special_chars, R"(\$&)"); // Prefix with '\' } - + const std::regex version_regex(const ViewerUI* ui, const bool verbose) { std::regex expr; @@ -46,7 +48,8 @@ namespace mrv if (orig.size() < 5) { - regex_string = "([\\w\\d/:\\-]*?[\\._\\-]*" + orig + ")(\\d+)([\\w\\d\\./]*)"; + regex_string = + "([\\w\\d/:\\-]*?[\\._\\-]*" + orig + ")(\\d+)([\\w\\d\\./]*)"; if (verbose) { std::string msg = tl::string::Format( @@ -78,8 +81,8 @@ namespace mrv } std::string media_version( - ViewerUI* ui, const file::Path& path, int sum, - const bool first_or_last, const file::Path& otioPath) + ViewerUI* ui, const file::Path& path, int sum, const bool first_or_last, + const file::Path& otioPath) { const std::regex& expr = version_regex(ui, true); if (std::regex_match("", expr)) @@ -94,13 +97,13 @@ namespace mrv std::string msg; std::string file = mrv::file::normalizePath(path.get()); - while ((first_or_last || found == false) && - tries <= max_tries) + while ((first_or_last || found == false) && tries <= max_tries) { std::string::const_iterator tstart = file.begin(); std::string::const_iterator tend = file.end(); std::smatch what; - std::regex_constants::match_flag_type flags = std::regex_constants::match_default; + std::regex_constants::match_flag_type flags = + std::regex_constants::match_default; newfile.clear(); try @@ -120,14 +123,15 @@ namespace mrv // We don't allow negative versions int num = std::stoi(version) + sum; - if (num < 0) num = 0; - + if (num < 0) + num = 0; + char buf[128]; snprintf(buf, 128, "%0*d", padding, num); msg = tl::string::Format( - _("Iteration {0} will check version={1}")) - .arg(iter) - .arg(buf); + _("Iteration {0} will check version={1}")) + .arg(iter) + .arg(buf); LOG_INFO(msg); newfile += buf; } @@ -136,7 +140,7 @@ namespace mrv tstart = what[3].first; // Move start position // Ensure overlap if necessary - flags |= std::regex_constants::match_prev_avail; + flags |= std::regex_constants::match_prev_avail; ++iter; } @@ -152,7 +156,6 @@ namespace mrv newfile += suffix; - if (file::isReadable(newfile)) { loadfile = newfile; @@ -160,34 +163,34 @@ namespace mrv if (!first_or_last) break; } - + file = newfile; } catch (const std::regex_error& e) { - std::string err = tl::string::Format( - _("Regular expression error: {0}")).arg(e.what()); + std::string err = + tl::string::Format(_("Regular expression error: {0}")) + .arg(e.what()); LOG_ERROR(err); } - ++tries; } - if (otioPath != path) + if (found && otioPath != path) { tl::file::Path newClipPath(loadfile); if (!replaceClipPath(newClipPath, ui)) { std::string err = tl::string::Format(_("Could not replace {0} with {1}")) - .arg(path.get()) - .arg(newClipPath.get()); + .arg(path.get()) + .arg(newClipPath.get()); LOG_ERROR(err); return loadfile; } } - + return loadfile; } diff --git a/src/po/de.po b/src/po/de.po index 5b02f1927..0f3a0262c 100644 --- a/src/po/de.po +++ b/src/po/de.po @@ -1,4 +1,4 @@ -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v0.7.7\n" diff --git a/src/po/en.po b/src/po/en.po index 823a2dfc4..5e7f7ff20 100644 --- a/src/po/en.po +++ b/src/po/en.po @@ -1,7 +1,7 @@ # English translations for mrv2 package. # This file is distributed under the same license as the mrv2 package. # Automatically generated, 2024. -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v1.1.6\n" diff --git a/src/po/es.po b/src/po/es.po index b79bd8a73..9d3b134d1 100644 --- a/src/po/es.po +++ b/src/po/es.po @@ -2,7 +2,7 @@ # Traducciones al español para el paquete mrv2. # This file is distributed under the same license as the mrv2 package. # Gonzalo Garramuño , 2023. -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v1.2.8\n" diff --git a/src/po/fr.po b/src/po/fr.po index 7f35c2984..152baf0a7 100644 --- a/src/po/fr.po +++ b/src/po/fr.po @@ -1,7 +1,7 @@ # French translations for mrv2 package # This file is distributed under the same license as the mrv2 package. # Gonzalo Garramuño , 2023. -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v1.2.6\n" diff --git a/src/po/hi_IN.po b/src/po/hi_IN.po index 114bc83db..80a5adb6e 100644 --- a/src/po/hi_IN.po +++ b/src/po/hi_IN.po @@ -1,7 +1,7 @@ # Hindi translations for mrv2 package. # This file is distributed under the same license as the mrv2 package. # Automatically generated, 2024. -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v1.2.7\n" diff --git a/src/po/it.po b/src/po/it.po index c39b48bf7..b77502aaf 100644 --- a/src/po/it.po +++ b/src/po/it.po @@ -1,7 +1,7 @@ # Italian translations for mrv2 package # This file is distributed under the same license as the mrv2 package. # Gonzalo Garramuño , 2023. -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v1.2.7nReport-Msgid-Bugs-To: ggarra13@gmail.com\n" diff --git a/src/po/pt.po b/src/po/pt.po index 9b864dac1..09133ee95 100644 --- a/src/po/pt.po +++ b/src/po/pt.po @@ -1,7 +1,7 @@ # Portuguese translations for mrv2 package # This file is distributed under the same license as the mrv2 package. # Gonzalo Garramuño , 2023. -# +# msgid "" msgstr "" "Project-Id-Version: mrv2 v1.2.7\n"