Update packages

This commit is contained in:
Matt Nadareski
2024-11-26 19:51:39 -05:00
parent 9214a22cc9
commit 6cdc35c82f
4 changed files with 54 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
@@ -31,7 +31,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SabreTools.IO" Version="1.5.1" />
<PackageReference Include="SabreTools.IO" Version="1.6.0" />
</ItemGroup>
</Project>

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using SabreTools.IO.Extensions;
using SabreTools.Models.CueSheets;
@@ -31,7 +32,7 @@ namespace SabreTools.Serialization.Deserializers
string? lastLine = null;
while (true)
{
string? line = lastLine ?? data.ReadQuotedString();
string? line = lastLine ?? ReadUntilNewline(data);
lastLine = null;
// If we have a null line, break from the loop
@@ -141,7 +142,7 @@ namespace SabreTools.Serialization.Deserializers
while (true)
{
string? line = lastLine ?? data.ReadQuotedString();
string? line = lastLine ?? ReadUntilNewline(data);
lastLine = null;
// If we have a null line, break from the loop
@@ -228,7 +229,7 @@ namespace SabreTools.Serialization.Deserializers
while (true)
{
string? line = lastLine ?? data.ReadQuotedString();
string? line = lastLine ?? ReadUntilNewline(data);
lastLine = null;
// If we have a null line, break from the loop
@@ -592,6 +593,52 @@ namespace SabreTools.Serialization.Deserializers
return flag;
}
/// <summary>
/// Read a string until a newline value is found
/// </summary>
/// <param name="data">Stream to pull from</param>
/// <returns>The next line from the data on success, null on error</returns>
private static string? ReadUntilNewline(Stream data)
{
// Validate the input
if (data.Length == 0 || data.Position < 0 || data.Position >= data.Length)
return null;
// Read characters either until a newline or end of file
var lineBuilder = new StringBuilder();
while (data.Position < data.Length)
{
char c = data.ReadChar();
// Handle Windows and old Mac line endings
if (c == '\r')
{
// Handle premature end of stream
if (data.Position >= data.Length)
break;
// Handle Windows line endings
c = data.ReadChar();
if (c == '\n')
break;
// Seek backward if we had old Mac line endings instead
data.Seek(-1, SeekOrigin.Current);
break;
}
// Handle standard line endings
if (c == '\n')
break;
// Handle all other characters
lineBuilder.Append(c);
}
// Return the line without trailing newline
return lineBuilder.ToString();
}
#endregion
}
}

View File

@@ -30,9 +30,9 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.ASN1" Version="1.4.2" />
<PackageReference Include="SabreTools.ASN1" Version="1.5.0" />
<PackageReference Include="SabreTools.Hashing" Version="1.4.0" />
<PackageReference Include="SabreTools.IO" Version="1.5.1" />
<PackageReference Include="SabreTools.IO" Version="1.6.0" />
<PackageReference Include="SabreTools.Models" Version="1.5.3" />
</ItemGroup>

View File

@@ -150,7 +150,6 @@ namespace SabreTools.Serialization.Serializers
// Write the header
writer.WriteValues(longHeader ? HeaderArrayWithRomname : HeaderArrayWithoutRomname);
writer.WriteLine();
// Write out the rows, if they exist
WriteRows(obj.Row, writer, longHeader);