From fb61be034f3ab95c48e3de5855599c8acf17fa13 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 12 Aug 2019 17:29:05 +0200 Subject: [PATCH] Fixed a comparation report text problem with files of 4 GiB or larger. Thanks Eliska Svobodova. --- test/compare_file.c | 7 ++++++- xorriso/cmp_update.c | 8 ++++++-- xorriso/xorriso_timestamp.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/test/compare_file.c b/test/compare_file.c index 87a55912..d27f740e 100644 --- a/test/compare_file.c +++ b/test/compare_file.c @@ -103,6 +103,7 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag) int ret, differs= 0, r1, r2, fd1= -1, fd2= -1, i, done; char buf1[4096], buf2[4096], a[4096], ttx1[40], ttx2[40]; off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1; + double dcount; ret= lstat(adr1, &s1); if(ret==-1) { @@ -241,9 +242,13 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag) if(diffcount>0 || r1count!=r2count) { if(first_diff<0) first_diff= (r1count>r2count ? r2count : r1count); + if(r1count > r2count) + dcount= diffcount + (r1count - r2count); + else + dcount= diffcount + (r2count - r1count); printf("%s : %s : differs by at least %.f bytes. First at %.f\n", a, (s1.st_mtime==s2.st_mtime ? "CONTENT":"content"), - (double) (diffcount + abs(r1count-r2count)), (double) first_diff); + dcount, (double) first_diff); differs= 1; } } diff --git a/xorriso/cmp_update.c b/xorriso/cmp_update.c index a9f61ad1..3fbdbd58 100644 --- a/xorriso/cmp_update.c +++ b/xorriso/cmp_update.c @@ -62,6 +62,7 @@ int Xorriso_compare_2_contents(struct XorrisO *xorriso, char *common_adr, char disk_md5[16], iso_md5[16]; void *ctx= NULL; int buf_size= 32 * 1024; + double dcount; Xorriso_alloc_meM(buf1, char, buf_size); Xorriso_alloc_meM(buf2, char, buf_size); @@ -238,10 +239,13 @@ cannot_address:; offset_text[0]= 0; if(offset>0) sprintf(offset_text, "%.f+", (double) offset); + if(r1count > r2count) + dcount= diffcount + (r1count - r2count); + else + dcount= diffcount + (r2count - r1count); sprintf(respt, "%s %s : differs by at least %.f bytes. First at %s%.f\n", common_adr, (flag&1 ? "CONTENT": "content"), - (double) (diffcount + abs(r1count-r2count)), - offset_text, (double) first_diff); + dcount, offset_text, (double) first_diff); if(!(flag&(1<<31))) Xorriso_result(xorriso,0); (*result)|= (1<<15); diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 5b707029..f4b8f6e3 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2019.07.24.141555" +#define Xorriso_timestamP "2019.08.12.152719"