Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delimeter -> delimiter #400

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/AsmResolver/IO/BinaryStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,54 +350,54 @@ public byte[] ReadToEnd()
}

/// <summary>
/// Reads bytes from the input stream until the provided delimeter byte is reached.
/// Reads bytes from the input stream until the provided delimiter byte is reached.
/// </summary>
/// <param name="delimeter">The delimeter byte to stop at.</param>
/// <returns>The read bytes, including the delimeter if it was found.</returns>
public byte[] ReadBytesUntil(byte delimeter) => ReadBytesUntil(delimeter, true);
/// <param name="delimiter">The delimiter byte to stop at.</param>
/// <returns>The read bytes, including the delimiter if it was found.</returns>
public byte[] ReadBytesUntil(byte delimiter) => ReadBytesUntil(delimiter, true);

/// <summary>
/// Reads bytes from the input stream until the provided delimeter byte is reached.
/// Reads bytes from the input stream until the provided delimiter byte is reached.
/// </summary>
/// <param name="delimeter">The delimeter byte to stop at.</param>
/// <param name="includeDelimeterInReturn">
/// <c>true</c> if the final delimeter should be included in the return value, <c>false</c> otherwise.
/// <param name="delimiter">The delimiter byte to stop at.</param>
/// <param name="includeDelimiterInReturn">
/// <c>true</c> if the final delimiter should be included in the return value, <c>false</c> otherwise.
/// </param>
/// <returns>The read bytes.</returns>
/// <remarks>
/// This function always consumes the delimeter from the input stream if it is present, regardless of the value
/// of <paramref name="includeDelimeterInReturn"/>.
/// This function always consumes the delimiter from the input stream if it is present, regardless of the value
/// of <paramref name="includeDelimiterInReturn"/>.
/// </remarks>
public byte[] ReadBytesUntil(byte delimeter, bool includeDelimeterInReturn)
public byte[] ReadBytesUntil(byte delimiter, bool includeDelimiterInReturn)
{
var lookahead = Fork();
bool hasConsumedDelimeter = lookahead.AdvanceUntil(delimeter, includeDelimeterInReturn);
bool hasConsumedDelimiter = lookahead.AdvanceUntil(delimiter, includeDelimiterInReturn);

byte[] buffer = new byte[lookahead.RelativeOffset - RelativeOffset];
ReadBytes(buffer, 0, buffer.Length);

if (hasConsumedDelimeter)
if (hasConsumedDelimiter)
ReadByte();

return buffer;
}

/// <summary>
/// Advances the reader until the provided delimeter byte is reached.
/// Advances the reader until the provided delimiter byte is reached.
/// </summary>
/// <param name="delimeter">The delimeter byte to stop at.</param>
/// <param name="consumeDelimeter">
/// <c>true</c> if the final delimeter should be consumed if available, <c>false</c> otherwise.
/// <param name="delimiter">The delimiter byte to stop at.</param>
/// <param name="consumeDelimiter">
/// <c>true</c> if the final delimiter should be consumed if available, <c>false</c> otherwise.
/// </param>
/// <returns><c>true</c> if the delimeter byte was found and consumed, <c>false</c> otherwise.</returns>
public bool AdvanceUntil(byte delimeter, bool consumeDelimeter)
/// <returns><c>true</c> if the delimiter byte was found and consumed, <c>false</c> otherwise.</returns>
public bool AdvanceUntil(byte delimiter, bool consumeDelimiter)
{
while (RelativeOffset < Length)
{
byte b = ReadByte();
if (b == delimeter)
if (b == delimiter)
{
if (!consumeDelimeter)
if (!consumeDelimiter)
{
RelativeOffset--;
return true;
Expand Down