Пример #1
0
        private DiffColumnHeader[] ReadDiffHunkHeader()
        {
            PushPosition();
            int colNum = Skip(HunkHeader);

            Skip();
            var headers = new DiffColumnHeader[colNum];

            for (int i = 0; i < colNum; ++i)
            {
                var action = DiffColumnAction.Remove;
                if (CheckValue('-'))
                {
                    action = DiffColumnAction.Remove;
                    Skip();
                }
                else if (CheckValue('+'))
                {
                    action = DiffColumnAction.Add;
                    Skip();
                }
                int space = FindSpace();
                int comma = FindComma(space - Position);
                if (comma != -1)
                {
                    var lineNumber = int.Parse(
                        ReadStringUpTo(comma, 1),
                        NumberStyles.Integer,
                        CultureInfo.InvariantCulture);
                    var lineCount = int.Parse(
                        ReadStringUpTo(space, 1),
                        NumberStyles.Integer,
                        CultureInfo.InvariantCulture);
                    headers[i] = new DiffColumnHeader(action, lineNumber, lineCount);
                }
                else
                {
                    var lineNumberStr = ReadStringUpTo(space, 1);
                    var lineNumber    = int.Parse(
                        lineNumberStr,
                        NumberStyles.Integer,
                        CultureInfo.InvariantCulture);
                    headers[i] = new DiffColumnHeader(action, lineNumber, 1);
                }
            }
            PopPosition();
            return(headers);
        }
Пример #2
0
 private DiffColumnHeader[] ReadDiffHunkHeader()
 {
     PushPosition();
     int colNum = Skip(HunkHeader);
     Skip();
     var headers = new DiffColumnHeader[colNum];
     for(int i = 0; i < colNum; ++i)
     {
         var action = DiffColumnAction.Remove;
         if(CheckValue('-'))
         {
             action = DiffColumnAction.Remove;
             Skip();
         }
         else if(CheckValue('+'))
         {
             action = DiffColumnAction.Add;
             Skip();
         }
         int space = FindSpace();
         int comma = FindComma(space - Position);
         if(comma != -1)
         {
             var lineNumber = int.Parse(
                 ReadStringUpTo(comma, 1),
                 NumberStyles.Integer,
                 CultureInfo.InvariantCulture);
             var lineCount = int.Parse(
                 ReadStringUpTo(space, 1),
                 NumberStyles.Integer,
                 CultureInfo.InvariantCulture);
             headers[i] = new DiffColumnHeader(action, lineNumber, lineCount);
         }
         else
         {
             var lineNumberStr = ReadStringUpTo(space, 1);
             var lineNumber = int.Parse(
                 lineNumberStr,
                 NumberStyles.Integer,
                 CultureInfo.InvariantCulture);
             headers[i] = new DiffColumnHeader(action, lineNumber, 1);
         }
     }
     PopPosition();
     return headers;
 }