equal
deleted
inserted
replaced
62 |
62 |
63 /* move hunks in source that are less cut to dest, compensating |
63 /* move hunks in source that are less cut to dest, compensating |
64 for changes in offset. the last hunk may be split if necessary. |
64 for changes in offset. the last hunk may be split if necessary. |
65 */ |
65 */ |
66 static int gather(struct mpatch_flist *dest, struct mpatch_flist *src, int cut, |
66 static int gather(struct mpatch_flist *dest, struct mpatch_flist *src, int cut, |
67 int offset) |
67 int offset) |
68 { |
68 { |
69 struct mpatch_frag *d = dest->tail, *s = src->head; |
69 struct mpatch_frag *d = dest->tail, *s = src->head; |
70 int postend, c, l; |
70 int postend, c, l; |
71 |
71 |
72 while (s != src->tail) { |
72 while (s != src->tail) { |
143 } |
143 } |
144 |
144 |
145 /* combine hunk lists a and b, while adjusting b for offset changes in a/ |
145 /* combine hunk lists a and b, while adjusting b for offset changes in a/ |
146 this deletes a and b and returns the resultant list. */ |
146 this deletes a and b and returns the resultant list. */ |
147 static struct mpatch_flist *combine(struct mpatch_flist *a, |
147 static struct mpatch_flist *combine(struct mpatch_flist *a, |
148 struct mpatch_flist *b) |
148 struct mpatch_flist *b) |
149 { |
149 { |
150 struct mpatch_flist *c = NULL; |
150 struct mpatch_flist *c = NULL; |
151 struct mpatch_frag *bh, *ct; |
151 struct mpatch_frag *bh, *ct; |
152 int offset = 0, post; |
152 int offset = 0, post; |
153 |
153 |
237 outlen += len - last; |
237 outlen += len - last; |
238 return outlen; |
238 return outlen; |
239 } |
239 } |
240 |
240 |
241 int mpatch_apply(char *buf, const char *orig, ssize_t len, |
241 int mpatch_apply(char *buf, const char *orig, ssize_t len, |
242 struct mpatch_flist *l) |
242 struct mpatch_flist *l) |
243 { |
243 { |
244 struct mpatch_frag *f = l->head; |
244 struct mpatch_frag *f = l->head; |
245 int last = 0; |
245 int last = 0; |
246 char *p = buf; |
246 char *p = buf; |
247 |
247 |
259 memcpy(p, orig + last, len - last); |
259 memcpy(p, orig + last, len - last); |
260 return 0; |
260 return 0; |
261 } |
261 } |
262 |
262 |
263 /* recursively generate a patch of all bins between start and end */ |
263 /* recursively generate a patch of all bins between start and end */ |
264 struct mpatch_flist *mpatch_fold(void *bins, |
264 struct mpatch_flist * |
265 struct mpatch_flist* (*get_next_item)(void*, ssize_t), |
265 mpatch_fold(void *bins, struct mpatch_flist *(*get_next_item)(void *, ssize_t), |
266 ssize_t start, ssize_t end) |
266 ssize_t start, ssize_t end) |
267 { |
267 { |
268 ssize_t len; |
268 ssize_t len; |
269 |
269 |
270 if (start + 1 == end) { |
270 if (start + 1 == end) { |
271 /* trivial case, output a decoded list */ |
271 /* trivial case, output a decoded list */ |