Changeset View
Changeset View
Standalone View
Standalone View
head/usr.bin/patch/pch.c
Show First 20 Lines • Show All 581 Lines • ▼ Show 20 Lines | if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) { | ||||
} | } | ||||
p_context = 100; | p_context = 100; | ||||
p_hunk_beg = p_input_line + 1; | p_hunk_beg = p_input_line + 1; | ||||
while (p_end < p_max) { | while (p_end < p_max) { | ||||
line_beginning = ftello(pfp); | line_beginning = ftello(pfp); | ||||
len = pgets(true); | len = pgets(true); | ||||
p_input_line++; | p_input_line++; | ||||
if (len == 0) { | if (len == 0) { | ||||
if (p_max - p_end < 4) { | |||||
/* assume blank lines got chopped */ | |||||
strlcpy(buf, " \n", buf_size); | |||||
} else { | |||||
if (repl_beginning && repl_could_be_missing) { | if (repl_beginning && repl_could_be_missing) { | ||||
repl_missing = true; | repl_missing = true; | ||||
goto hunk_done; | goto hunk_done; | ||||
} | } | ||||
fatal("unexpected end of file in patch\n"); | fatal("unexpected end of file in patch\n"); | ||||
} | |||||
} | } | ||||
p_end++; | p_end++; | ||||
if (p_end >= hunkmax) | if (p_end >= hunkmax) | ||||
fatal("Internal error: hunk larger than hunk " | fatal("Internal error: hunk larger than hunk " | ||||
"buffer size"); | "buffer size"); | ||||
p_char[p_end] = *buf; | p_char[p_end] = *buf; | ||||
p_line[p_end] = NULL; | p_line[p_end] = NULL; | ||||
switch (*buf) { | switch (*buf) { | ||||
▲ Show 20 Lines • Show All 1,057 Lines • Show Last 20 Lines |