Skip to content

Commit 5eade07

Browse files
peffgitster
authored andcommitted
xdiff-interface: drop parse_hunk_header()
This function was used only for parsing the hunk headers generated by xdiff. Now that we can use hunk callbacks to get that information directly, it has outlived its usefulness. Note to anyone who wants to resurrect it: the "len" parameter was totally unused, meaning that the function could read past the end of the "line" array. In practice this never happened, because we only used it to parse xdiff's generated header lines. But it would be dangerous to use it for other cases without fixing this defect. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d2eb809 commit 5eade07

File tree

2 files changed

+0
-48
lines changed

2 files changed

+0
-48
lines changed

xdiff-interface.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,6 @@ struct xdiff_emit_state {
1515
struct strbuf remainder;
1616
};
1717

18-
static int parse_num(char **cp_p, int *num_p)
19-
{
20-
char *cp = *cp_p;
21-
int num = 0;
22-
23-
while ('0' <= *cp && *cp <= '9')
24-
num = num * 10 + *cp++ - '0';
25-
if (!(cp - *cp_p))
26-
return -1;
27-
*cp_p = cp;
28-
*num_p = num;
29-
return 0;
30-
}
31-
32-
int parse_hunk_header(char *line, int len,
33-
int *ob, int *on,
34-
int *nb, int *nn)
35-
{
36-
char *cp;
37-
cp = line + 4;
38-
if (parse_num(&cp, ob)) {
39-
bad_line:
40-
return error("malformed diff output: %s", line);
41-
}
42-
if (*cp == ',') {
43-
cp++;
44-
if (parse_num(&cp, on))
45-
goto bad_line;
46-
}
47-
else
48-
*on = 1;
49-
if (*cp++ != ' ' || *cp++ != '+')
50-
goto bad_line;
51-
if (parse_num(&cp, nb))
52-
goto bad_line;
53-
if (*cp == ',') {
54-
cp++;
55-
if (parse_num(&cp, nn))
56-
goto bad_line;
57-
}
58-
else
59-
*nn = 1;
60-
return -!!memcmp(cp, " @@", 3);
61-
}
62-
6318
static int xdiff_out_hunk(void *priv_,
6419
long old_begin, long old_nr,
6520
long new_begin, long new_nr,

xdiff-interface.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
2323
xdiff_emit_line_fn line_fn,
2424
void *consume_callback_data,
2525
xpparam_t const *xpp, xdemitconf_t const *xecfg);
26-
int parse_hunk_header(char *line, int len,
27-
int *ob, int *on,
28-
int *nb, int *nn);
2926
int read_mmfile(mmfile_t *ptr, const char *filename);
3027
void read_mmblob(mmfile_t *ptr, const struct object_id *oid);
3128
int buffer_is_binary(const char *ptr, unsigned long size);

0 commit comments

Comments
 (0)