comparison mercurial/bdiff.c @ 1542:8e80eefb3de6

made C src formatting more consistent
author twaldmann@thinkmo.de
date Mon, 14 Nov 2005 04:58:28 +0200
parents 66fd3bc1cfcf
children 5afd459db177
comparison
equal deleted inserted replaced
1541:bf4e7ef08741 1542:8e80eefb3de6
145 j = (j + 1) & buckets) 145 j = (j + 1) & buckets)
146 if (!cmp(a + i, b + h[j].pos)) 146 if (!cmp(a + i, b + h[j].pos))
147 break; 147 break;
148 148
149 a[i].e = j; /* use equivalence class for quick compare */ 149 a[i].e = j; /* use equivalence class for quick compare */
150 if(h[j].len <= t) 150 if (h[j].len <= t)
151 a[i].n = h[j].pos; /* point to head of match list */ 151 a[i].n = h[j].pos; /* point to head of match list */
152 else 152 else
153 a[i].n = -1; /* too popular */ 153 a[i].n = -1; /* too popular */
154 } 154 }
155 155
268 l = diff(a, an, b, bn); 268 l = diff(a, an, b, bn);
269 rl = PyList_New(l.head - l.base); 269 rl = PyList_New(l.head - l.base);
270 if (!l.head || !rl) 270 if (!l.head || !rl)
271 goto nomem; 271 goto nomem;
272 272
273 for(h = l.base; h != l.head; h++) { 273 for (h = l.base; h != l.head; h++) {
274 m = Py_BuildValue("iiii", h->a1, h->a2, h->b1, h->b2); 274 m = Py_BuildValue("iiii", h->a1, h->a2, h->b1, h->b2);
275 PyList_SetItem(rl, pos, m); 275 PyList_SetItem(rl, pos, m);
276 pos++; 276 pos++;
277 } 277 }
278 278
303 l = diff(al, an, bl, bn); 303 l = diff(al, an, bl, bn);
304 if (!l.head) 304 if (!l.head)
305 goto nomem; 305 goto nomem;
306 306
307 /* calculate length of output */ 307 /* calculate length of output */
308 for(h = l.base; h != l.head; h++) { 308 for (h = l.base; h != l.head; h++) {
309 if (h->a1 != la || h->b1 != lb) 309 if (h->a1 != la || h->b1 != lb)
310 len += 12 + bl[h->b1].l - bl[lb].l; 310 len += 12 + bl[h->b1].l - bl[lb].l;
311 la = h->a2; 311 la = h->a2;
312 lb = h->b2; 312 lb = h->b2;
313 } 313 }
318 318
319 /* build binary patch */ 319 /* build binary patch */
320 rb = PyString_AsString(result); 320 rb = PyString_AsString(result);
321 la = lb = 0; 321 la = lb = 0;
322 322
323 for(h = l.base; h != l.head; h++) { 323 for (h = l.base; h != l.head; h++) {
324 if (h->a1 != la || h->b1 != lb) { 324 if (h->a1 != la || h->b1 != lb) {
325 len = bl[h->b1].l - bl[lb].l; 325 len = bl[h->b1].l - bl[lb].l;
326 *(uint32_t *)(encode) = htonl(al[la].l - al->l); 326 *(uint32_t *)(encode) = htonl(al[la].l - al->l);
327 *(uint32_t *)(encode + 4) = htonl(al[h->a1].l - al->l); 327 *(uint32_t *)(encode + 4) = htonl(al[h->a1].l - al->l);
328 *(uint32_t *)(encode + 8) = htonl(len); 328 *(uint32_t *)(encode + 8) = htonl(len);
351 351
352 PyMODINIT_FUNC initbdiff(void) 352 PyMODINIT_FUNC initbdiff(void)
353 { 353 {
354 Py_InitModule3("bdiff", methods, mdiff_doc); 354 Py_InitModule3("bdiff", methods, mdiff_doc);
355 } 355 }
356