version 1.45, 2014/11/25 10:26:07 |
version 1.46, 2014/11/26 10:11:21 |
|
|
if (!*s) |
if (!*s) |
malformed(); |
malformed(); |
p_ptrn_lines = strtolinenum(s, &s) - p_first + 1; |
p_ptrn_lines = strtolinenum(s, &s) - p_first + 1; |
|
if (p_ptrn_lines < 0) |
|
malformed(); |
} else if (p_first) |
} else if (p_first) |
p_ptrn_lines = 1; |
p_ptrn_lines = 1; |
else { |
else { |
p_ptrn_lines = 0; |
p_ptrn_lines = 0; |
p_first = 1; |
p_first = 1; |
} |
} |
|
if (p_first >= LINENUM_MAX - p_ptrn_lines || |
|
p_ptrn_lines >= LINENUM_MAX - 6) |
|
malformed(); |
|
|
/* we need this much at least */ |
/* we need this much at least */ |
p_max = p_ptrn_lines + 6; |
p_max = p_ptrn_lines + 6; |
|
|
malformed(); |
malformed(); |
p_repl_lines = strtolinenum(s, &s) - |
p_repl_lines = strtolinenum(s, &s) - |
p_newfirst + 1; |
p_newfirst + 1; |
|
if (p_repl_lines < 0) |
|
malformed(); |
} else if (p_newfirst) |
} else if (p_newfirst) |
p_repl_lines = 1; |
p_repl_lines = 1; |
else { |
else { |
p_repl_lines = 0; |
p_repl_lines = 0; |
p_newfirst = 1; |
p_newfirst = 1; |
} |
} |
|
if (p_newfirst >= LINENUM_MAX - p_repl_lines || |
|
p_repl_lines >= LINENUM_MAX - p_end) |
|
malformed(); |
p_max = p_repl_lines + p_end; |
p_max = p_repl_lines + p_end; |
if (p_max > MAXHUNKSIZE) |
if (p_max > MAXHUNKSIZE) |
fatal("hunk too large (%ld lines) at line %ld: %s", |
fatal("hunk too large (%ld lines) at line %ld: %s", |
|
|
s++; |
s++; |
if (*s != '@') |
if (*s != '@') |
malformed(); |
malformed(); |
|
if (p_first >= LINENUM_MAX - p_ptrn_lines || |
|
p_newfirst > LINENUM_MAX - p_repl_lines || |
|
p_ptrn_lines >= LINENUM_MAX - p_repl_lines - 1) |
|
malformed(); |
if (!p_ptrn_lines) |
if (!p_ptrn_lines) |
p_first++; /* do append rather than insert */ |
p_first++; /* do append rather than insert */ |
p_max = p_ptrn_lines + p_repl_lines + 1; |
p_max = p_ptrn_lines + p_repl_lines + 1; |
|
|
p_first = strtolinenum(buf, &s); |
p_first = strtolinenum(buf, &s); |
if (*s == ',') { |
if (*s == ',') { |
p_ptrn_lines = strtolinenum(s + 1, &s) - p_first + 1; |
p_ptrn_lines = strtolinenum(s + 1, &s) - p_first + 1; |
|
if (p_ptrn_lines < 0) |
|
malformed(); |
} else |
} else |
p_ptrn_lines = (*s != 'a'); |
p_ptrn_lines = (*s != 'a'); |
|
if (p_first >= LINENUM_MAX - p_ptrn_lines) |
|
malformed(); |
hunk_type = *s; |
hunk_type = *s; |
if (hunk_type == 'a') |
if (hunk_type == 'a') |
p_first++; /* do append rather than insert */ |
p_first++; /* do append rather than insert */ |
|
|
max = strtolinenum(s + 1, &s); |
max = strtolinenum(s + 1, &s); |
else |
else |
max = min; |
max = min; |
|
if (min < 0 || min > max || max - min == LINENUM_MAX) |
|
malformed(); |
if (hunk_type == 'd') |
if (hunk_type == 'd') |
min++; |
min++; |
p_end = p_ptrn_lines + 1 + max - min + 1; |
p_newfirst = min; |
|
p_repl_lines = max - min + 1; |
|
if (p_newfirst > LINENUM_MAX - p_repl_lines || |
|
p_ptrn_lines >= LINENUM_MAX - p_repl_lines - 1) |
|
malformed(); |
|
p_end = p_ptrn_lines + p_repl_lines + 1; |
if (p_end > MAXHUNKSIZE) |
if (p_end > MAXHUNKSIZE) |
fatal("hunk too large (%ld lines) at line %ld: %s", |
fatal("hunk too large (%ld lines) at line %ld: %s", |
p_end, p_input_line, buf); |
p_end, p_input_line, buf); |
while (p_end >= hunkmax) |
while (p_end >= hunkmax) |
grow_hunkmax(); |
grow_hunkmax(); |
p_newfirst = min; |
|
p_repl_lines = max - min + 1; |
|
snprintf(buf, sizeof buf, "*** %ld,%ld\n", p_first, |
snprintf(buf, sizeof buf, "*** %ld,%ld\n", p_first, |
p_first + p_ptrn_lines - 1); |
p_first + p_ptrn_lines - 1); |
p_line[0] = savestr(buf); |
p_line[0] = savestr(buf); |