Skip to content

Commit

Permalink
しょぼいカレンダーの話数正規表現を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashNephy committed Jun 16, 2021
1 parent e51a180 commit 9c42730
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions AnnictRecorder/SyoboCalApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ namespace SyoboCal
float_t countEnd = 0;

// 複数話同時放送の場合 SubTitle フィールドに #[\d\.]+~#[\d\.]+ という形式で格納されている
const auto subTitle = node.child_value("SubTitle");
const auto subTitleRegex = std::regex(R"(^#([\d\.]+)~#([\d\.]+)$)");
if (std::cmatch match; std::regex_match(subTitle, match, subTitleRegex))
// マルチバイトな正規表現に難があるので wchar を経由する
const auto subTitle = Multi2Wide(node.child_value("SubTitle"));
const auto subTitleRegex = std::wregex(LR"(^#([\d\.]+)~#([\d\.]+)$)");
if (std::wcmatch match; std::regex_match(subTitle.c_str(), match, subTitleRegex))
{
countStart = strtof(match[1].str().c_str(), nullptr);
countEnd = strtof(match[2].str().c_str(), nullptr);
countStart = static_cast<float_t>(_wtof(match[1].str().c_str()));
countEnd = static_cast<float_t>(_wtof(match[2].str().c_str()));
}
// 通常 (単話放送) 時
else
Expand Down

0 comments on commit 9c42730

Please sign in to comment.