diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-03-09 00:11:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-03-09 00:11:38 +0100 |
| commit | 80313b07095814f0178be70bc0651c1e052decea (patch) | |
| tree | 5ea002e29340ee342344affce277aa0cd941d7db /src/lib/util.cc | |
| parent | 82f87c7711fb664b06b04d44792ed3820b3d1e01 (diff) | |
| parent | 04b5957318df591f56e0a5d39720df143dc8230d (diff) | |
Merge branch 'main' into v2.17.x
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 01a7f0248..ef15b90e5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1120,7 +1120,6 @@ word_wrap(string input, int columns) } - #ifdef DCPOMATIC_GROK void setup_grok_library_path() @@ -1147,3 +1146,31 @@ setup_grok_library_path() setenv("LD_LIBRARY_PATH", new_path.c_str(), 1); } #endif + +string +screen_names_to_string(vector<string> names) +{ + if (names.empty()) { + return {}; + } + + auto number = [](string const& s) { + return s.find_first_not_of("0123456789") == string::npos; + }; + + if (std::find_if(names.begin(), names.end(), [number](string const& s) { return !number(s); }) == names.end()) { + std::sort(names.begin(), names.end(), [](string const& a, string const& b) { + return dcp::raw_convert<int>(a) < dcp::raw_convert<int>(b); + }); + } else { + std::sort(names.begin(), names.end()); + } + + string result; + for (auto const& name: names) { + result += name + ", "; + } + + return result.substr(0, result.length() - 2); +} + |
