internal virtual int ParseHunk(int ptr, int end) { byte[] buf = file.buf; if (RawParseUtils.Match(buf, ptr, LITERAL) >= 0) { type = BinaryHunk.Type.LITERAL_DEFLATED; length = RawParseUtils.ParseBase10(buf, ptr + LITERAL.Length, null); } else { if (RawParseUtils.Match(buf, ptr, DELTA) >= 0) { type = BinaryHunk.Type.DELTA_DEFLATED; length = RawParseUtils.ParseBase10(buf, ptr + DELTA.Length, null); } else { // Not a valid binary hunk. Signal to the caller that // we cannot parse any further and that this line should // be treated otherwise. // return(-1); } } ptr = RawParseUtils.NextLF(buf, ptr); // Skip until the first blank line; that is the end of the binary // encoded information in this hunk. To save time we don't do a // validation of the binary data at this point. // while (ptr < end) { bool empty = (buf[ptr] == '\n') || (buf[ptr] == '\r' && ptr + 1 < end && buf[ptr + 1] == '\n'); ptr = RawParseUtils.NextLF(buf, ptr); if (empty) { break; } } return(ptr); }
internal virtual int ParseHunk(int ptr, int end) { byte[] buf = file.buf; if (RawParseUtils.Match(buf, ptr, LITERAL) >= 0) { type = BinaryHunk.Type.LITERAL_DEFLATED; length = RawParseUtils.ParseBase10(buf, ptr + LITERAL.Length, null); } else { if (RawParseUtils.Match(buf, ptr, DELTA) >= 0) { type = BinaryHunk.Type.DELTA_DEFLATED; length = RawParseUtils.ParseBase10(buf, ptr + DELTA.Length, null); } else { // Not a valid binary hunk. Signal to the caller that // we cannot parse any further and that this line should // be treated otherwise. // return -1; } } ptr = RawParseUtils.NextLF(buf, ptr); // Skip until the first blank line; that is the end of the binary // encoded information in this hunk. To save time we don't do a // validation of the binary data at this point. // while (ptr < end) { bool empty = buf[ptr] == '\n'; ptr = RawParseUtils.NextLF(buf, ptr); if (empty) { break; } } return ptr; }