diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 84d94e290..4d067133f 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -597,27 +597,22 @@ void AssFile::InsertAttachment (wxString filename) { InsertAttachment(newAttach); } -wxString AssFile::GetScriptInfo(const wxString _key) { - wxString key = _key;; +wxString AssFile::GetScriptInfo(wxString key) { key.Lower(); key += ":"; - std::list::iterator cur; bool GotIn = false; - for (cur=Line.begin();cur!=Line.end();cur++) { + for (std::list::iterator cur = Line.begin(); cur != Line.end(); ++cur) { if ((*cur)->group == "[Script Info]") { GotIn = true; wxString curText = (*cur)->GetEntryData(); curText.Lower(); - if (curText.StartsWith(key)) { - wxString result = curText.Mid(key.length()); - result.Trim(false); - result.Trim(true); - return result; - } + wxString value; + if (curText.StartsWith(key, &value)) + return value.Trim(true).Trim(false); } - else if (GotIn) break; + else if (GotIn) return ""; } return ""; diff --git a/aegisub/src/ass_file.h b/aegisub/src/ass_file.h index 322e8a28b..96c6f57a1 100644 --- a/aegisub/src/ass_file.h +++ b/aegisub/src/ass_file.h @@ -155,7 +155,7 @@ public: /// Get the value in a [Script Info] key as int. int GetScriptInfoAsInt(const wxString key); /// Get the value in a [Script Info] key as string. - wxString GetScriptInfo(const wxString key); + wxString GetScriptInfo(wxString key); /// Set the value of a [Script Info] key. Adds it if it doesn't exist. void SetScriptInfo(wxString const& key, wxString const& value); // Add a ";" comment in the [Script Info] section