Ancestry.Daisy.Language.WhitespaceEater.TrimLeadingSpaces C# (CSharp) Method

TrimLeadingSpaces() static private method

static private TrimLeadingSpaces ( string line, int lineCnt ) : TrimResult
line string
lineCnt int
return TrimResult
        internal static TrimResult TrimLeadingSpaces(string line, int lineCnt)
        {
            var whitespaceType = 'a';
            var cursor = 0;
            for(;cursor<line.Length; ++cursor)
            {
                var c = line[cursor];
                if(c == ' ' || c == '\t')
                {
                    if(whitespaceType == 'a')
                    {
                        whitespaceType = c;
                    }
                    else if(c != whitespaceType)
                    {
                        throw new InconsistentWhitespaceException(string.Format("Line {0} has mixed use of leading tabs and spaces",lineCnt));
                    }
                }
                else
                {
                    break;
                }
            }
            return new TrimResult() {
                    Line = line.Substring(cursor),
                    Trimmed = cursor,
                    WhitespaceType = whitespaceType
                };
        }