static bool ParseLimitedWhitespace(string input, ref int pos, int maxNewlinesToConsume)
{
int end = pos;
int consumedNewlines = 0;
while (end < input.Length && consumedNewlines < maxNewlinesToConsume)
{
char thisChar = input[end];
if (thisChar == '\r')
{
end++;
consumedNewlines++;
if (end < input.Length && input[end] == '\n')
{
// Windows newline - just consume it
end++;
}
}
else if (thisChar == '\n')
{
// Unix newline
end++;
consumedNewlines++;
}
else if (char.IsWhiteSpace(thisChar))
{
// Consume the whitespace
end++;
}
else
{
break;
}
}
var found = pos != end;
pos = end;
return found;
}
static bool ParseChar(string input, ref int pos, char c)