mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix single-line SMDB corner case
This commit is contained in:
@@ -100,17 +100,32 @@ namespace SabreTools.Library.Tools
|
|||||||
// For everything else, we need to read it
|
// For everything else, we need to read it
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the first two non-whitespace, non-comment lines to check
|
// Get the first two non-whitespace, non-comment lines to check, if possible
|
||||||
StreamReader sr = File.OpenText(filename);
|
string first = string.Empty, second = string.Empty;
|
||||||
string first = sr.ReadLine().ToLowerInvariant();
|
|
||||||
while (string.IsNullOrWhiteSpace(first) || first.StartsWith("<!--"))
|
|
||||||
first = sr.ReadLine().ToLowerInvariant();
|
|
||||||
|
|
||||||
string second = sr.ReadLine().ToLowerInvariant();
|
try
|
||||||
while (string.IsNullOrWhiteSpace(second) || second.StartsWith("<!--"))
|
{
|
||||||
second = sr.ReadLine().ToLowerInvariant();
|
using (StreamReader sr = File.OpenText(filename))
|
||||||
|
{
|
||||||
|
first = sr.ReadLine().ToLowerInvariant();
|
||||||
|
while ((string.IsNullOrWhiteSpace(first) || first.StartsWith("<!--"))
|
||||||
|
&& !sr.EndOfStream)
|
||||||
|
{
|
||||||
|
first = sr.ReadLine().ToLowerInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
sr.Dispose();
|
if (!sr.EndOfStream)
|
||||||
|
{
|
||||||
|
second = sr.ReadLine().ToLowerInvariant();
|
||||||
|
while (string.IsNullOrWhiteSpace(second) || second.StartsWith("<!--")
|
||||||
|
&& !sr.EndOfStream)
|
||||||
|
{
|
||||||
|
second = sr.ReadLine().ToLowerInvariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
// If we have an XML-based DAT
|
// If we have an XML-based DAT
|
||||||
if (first.Contains("<?xml") && first.Contains("?>"))
|
if (first.Contains("<?xml") && first.Contains("?>"))
|
||||||
|
|||||||
Reference in New Issue
Block a user