GitSharp.Core.Patch.Patch.ParseFile C# (CSharp) Méthode

ParseFile() private méthode

private ParseFile ( byte buf, int c, int end ) : int
buf byte
c int
end int
Résultat int
        private int ParseFile(byte[] buf, int c, int end)
        {
            while (c < end)
            {
                if (FileHeader.isHunkHdr(buf, c, end) >= 1)
                {
                    // If we find a disconnected hunk header we might
                    // have missed a file header previously. The hunk
                    // isn't valid without knowing where it comes from.
                    //
                    error(buf, c, "Hunk disconnected from file");
                    c = RawParseUtils.nextLF(buf, c);
                    continue;
                }

                // Valid git style patch?
                //
                if (RawParseUtils.match(buf, c, DiffGit) >= 0)
                {
                    return ParseDiffGit(buf, c, end);
                }
                if (RawParseUtils.match(buf, c, DiffCc) >= 0)
                {
                    return ParseDiffCombined(DiffCc, buf, c, end);
                }
                if (RawParseUtils.match(buf, c, DiffCombined) >= 0)
                {
                    return ParseDiffCombined(DiffCombined, buf, c, end);
                }

                // Junk between files? Leading junk? Traditional
                // (non-git generated) patch?
                //
                int n = RawParseUtils.nextLF(buf, c);
                if (n >= end)
                {
                    // Patches cannot be only one line long. This must be
                    // trailing junk that we should ignore.
                    //
                    return end;
                }

                if (n - c < 6)
                {
                    // A valid header must be at least 6 bytes on the
                    // first line, e.g. "--- a/b\n".
                    //
                    c = n;
                    continue;
                }

                if (RawParseUtils.match(buf, c, FileHeader.OLD_NAME) >= 0 &&
                    RawParseUtils.match(buf, n, FileHeader.NEW_NAME) >= 0)
                {
                    // Probably a traditional patch. Ensure we have at least
                    // a "@@ -0,0" smelling line next. We only check the "@@ -".
                    //
                    int f = RawParseUtils.nextLF(buf, n);
                    if (f >= end)
                        return end;
                    if (FileHeader.isHunkHdr(buf, f, end) == 1)
                        return ParseTraditionalPatch(buf, c, end);
                }

                c = n;
            }
            return c;
        }