comparison mercurial/bdiff.c @ 13731:5d0cdf4ec338

bdiff.c: use unsigned arithmetic for hash computation Signed integer overflow is undefined in C.
author Markus F.X.J. Oberhumer <markus@oberhumer.com>
date Wed, 23 Mar 2011 02:33:23 +0100
parents df978f28a259
children afe9269dccec
comparison
equal deleted inserted replaced
13730:df978f28a259 13731:5d0cdf4ec338
63 struct hunk *next; 63 struct hunk *next;
64 }; 64 };
65 65
66 static int splitlines(const char *a, int len, struct line **lr) 66 static int splitlines(const char *a, int len, struct line **lr)
67 { 67 {
68 int h, i; 68 unsigned h;
69 int i;
69 const char *p, *b = a; 70 const char *p, *b = a;
70 const char * const plast = a + len - 1; 71 const char * const plast = a + len - 1;
71 struct line *l; 72 struct line *l;
72 73
73 /* count the lines */ 74 /* count the lines */
96 b = p + 1; 97 b = p + 1;
97 } 98 }
98 } 99 }
99 100
100 /* set up a sentinel */ 101 /* set up a sentinel */
101 l->h = l->len = 0; 102 l->h = 0;
103 l->len = 0;
102 l->l = a + len; 104 l->l = a + len;
103 return i - 1; 105 return i - 1;
104 } 106 }
105 107
106 static inline int cmp(struct line *a, struct line *b) 108 static inline int cmp(struct line *a, struct line *b)