From 89fbc8d186378cd72ab3e9a259073d45b7b993ad Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 16 Feb 2023 21:56:22 +0100 Subject: Change how whitespace in subtitles is handled. Previously we would discard any whitespace subtitle content we found. This had the side-effect of making a verification test fail (checking that at least one subtitle is in each reel; blank subtitles are often used to avoid this warning). Here we take any subtitle content, whitespace or not, inside a or node which I think is a little more correct. --- src/subtitle_asset.cc | 6 +++++- src/util.cc | 13 ------------- src/util.h | 5 ----- 3 files changed, 5 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc index f707c665..4baa7b06 100644 --- a/src/subtitle_asset.cc +++ b/src/subtitle_asset.cc @@ -324,7 +324,11 @@ SubtitleAsset::parse_subtitles (xmlpp::Element const * node, vector& void SubtitleAsset::maybe_add_subtitle (string text, vector const & parse_state, float space_before, Standard standard) { - if (empty_or_white_space (text)) { + auto wanted = [](ParseState const& ps) { + return ps.type && (ps.type.get() == ParseState::Type::TEXT || ps.type.get() == ParseState::Type::IMAGE); + }; + + if (find_if(parse_state.begin(), parse_state.end(), wanted) == parse_state.end()) { return; } diff --git a/src/util.cc b/src/util.cc index b58035ea..9cc35ad6 100644 --- a/src/util.cc +++ b/src/util.cc @@ -158,19 +158,6 @@ dcp::make_digest (boost::filesystem::path filename, function progr } -bool -dcp::empty_or_white_space (string s) -{ - for (size_t i = 0; i < s.length(); ++i) { - if (s[i] != ' ' && s[i] != '\n' && s[i] != '\t') { - return false; - } - } - - return true; -} - - void dcp::init (optional given_resources_directory) { diff --git a/src/util.h b/src/util.h index 451957d8..8261a812 100644 --- a/src/util.h +++ b/src/util.h @@ -84,11 +84,6 @@ extern std::string make_digest (boost::filesystem::path filename, boost::functio extern std::string make_digest (ArrayData data); -/** @param s A string - * @return true if the string contains only space, newline or tab characters, or is empty - */ -extern bool empty_or_white_space (std::string s); - extern bool ids_equal (std::string a, std::string b); extern std::string remove_urn_uuid (std::string raw); -- cgit v1.2.3