From b1e40455ed949c226b6b172f323101ba82666790 Mon Sep 17 00:00:00 2001 From: Martin Herkt Date: Thu, 22 Nov 2012 03:25:41 +0100 Subject: [PATCH] ASS: Fix script header Previously, Aegisub wrote its "Script generated by" lines without a semicolon to mark them as comments. As a result, it prepended these lines every time a script was loaded and then saved again. Fix. Also fix a bug that caused the ASS parser to treat comments before the [Script Info] section as non-blank lines, therefore inserting a duplicate section header whenever such comments were present. --- aegisub/src/ass_parser.cpp | 8 ++++---- aegisub/src/subtitle_format_ass.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aegisub/src/ass_parser.cpp b/aegisub/src/ass_parser.cpp index f1bf28432..aee97d94d 100644 --- a/aegisub/src/ass_parser.cpp +++ b/aegisub/src/ass_parser.cpp @@ -66,16 +66,16 @@ void AssParser::ParseAttachmentLine(wxString const& data) { } void AssParser::ParseScriptInfoLine(wxString const& data) { - // If the first nonblank line isn't a header pretend it starts with [Script Info] - if (target->Line.empty()) - target->Line.push_back(*new AssEntry("[Script Info]", "[Script Info]")); - if (data.StartsWith(";")) { // Skip stupid comments added by other programs // Of course, we'll add our own in place later... ;) return; } + // If the first nonblank line isn't a header pretend it starts with [Script Info] + if (target->Line.empty()) + target->Line.push_back(*new AssEntry("[Script Info]", "[Script Info]")); + if (data.StartsWith("ScriptType:")) { wxString versionString = data.Mid(11).Trim(true).Trim(false).Lower(); int trueVersion; diff --git a/aegisub/src/subtitle_format_ass.cpp b/aegisub/src/subtitle_format_ass.cpp index f28991e57..72a7b5cce 100644 --- a/aegisub/src/subtitle_format_ass.cpp +++ b/aegisub/src/subtitle_format_ass.cpp @@ -86,8 +86,8 @@ void AssSubtitleFormat::ReadFile(AssFile *target, wxString const& filename, wxSt void AssSubtitleFormat::WriteFile(const AssFile *src, wxString const& filename, wxString const& encoding) const { TextFileWriter file(filename, encoding); - file.WriteLineToFile(wxString("Script generated by Aegisub ") + GetAegisubLongVersionString()); - file.WriteLineToFile("http://www.aegisub.org/"); + file.WriteLineToFile(wxString("; Script generated by Aegisub ") + GetAegisubLongVersionString()); + file.WriteLineToFile("; http://www.aegisub.org/"); bool ssa = filename.Right(4).Lower() == ".ssa";