git-svn: trunk@4205
Török Edvin authored on 2008/09/24 17:45:56... | ... |
@@ -333,6 +333,7 @@ int open_testfile(const char *name) |
333 | 333 |
|
334 | 334 |
void diff_file_mem(int fd, const char *ref, size_t len) |
335 | 335 |
{ |
336 |
+ char c1,c2; |
|
336 | 337 |
size_t p, reflen = len; |
337 | 338 |
char *buf = cli_malloc(len); |
338 | 339 |
|
... | ... |
@@ -341,12 +342,15 @@ void diff_file_mem(int fd, const char *ref, size_t len) |
341 | 341 |
fail_unless(p == len, "file is smaller: %lu, expected: %lu", p, len); |
342 | 342 |
p = 0; |
343 | 343 |
while(len > 0) { |
344 |
- char c1 = ref[p]; |
|
345 |
- char c2 = buf[p]; |
|
346 |
- fail_unless(c1 == c2, "file contents mismatch at byte: %lu, was: %c, expected: %c", p, c2, c1); |
|
344 |
+ c1 = ref[p]; |
|
345 |
+ c2 = buf[p]; |
|
346 |
+ if(c1 != c2) |
|
347 |
+ break; |
|
347 | 348 |
p++; |
348 | 349 |
len--; |
349 | 350 |
} |
351 |
+ if (len > 0) |
|
352 |
+ fail_unless(c1 == c2, "file contents mismatch at byte: %lu, was: %c, expected: %c", p, c2, c1); |
|
350 | 353 |
free(buf); |
351 | 354 |
p = lseek(fd, 0, SEEK_END); |
352 | 355 |
fail_unless(p == reflen, "trailing garbage, file size: %ld, expected: %ld", p, reflen); |