correct CRLF problem between unix baseline and win platform test file generated by j2k_dump
This commit is contained in:
parent
f4601aff8b
commit
1776120dba
1
CHANGES
1
CHANGES
|
@ -8,6 +8,7 @@ What's New for OpenJPEG
|
|||
July 26, 2011
|
||||
! [mickael] delete double semi-colon at end of line which generate crash on win platform
|
||||
! [mickael] use ansi c function fgets instead of GNU function getline to avoid build error with win platform
|
||||
! [mickael] correct CRLF problem between unix baseline and win platform test file generated by j2k_dump
|
||||
|
||||
July 25, 2011
|
||||
* [mickael] fixed issue 74 for trunk
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*
|
||||
* Created on: 25 juil. 2011
|
||||
* Author: mickael
|
||||
* BASELINE MUST BE GENERATED BY UNIX PLATFORM REGARDING TO THE CRLF PROBLEM
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -93,7 +94,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
test_cmp_parameters inParam;
|
||||
FILE *fbase=NULL, *ftest=NULL;
|
||||
char chbase, chtest;
|
||||
int chbase, chtest;
|
||||
int same = 1;
|
||||
unsigned long l=1, pos;
|
||||
|
||||
|
@ -153,25 +154,39 @@ int main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// CRLF problem (Baseline must be always generated by unix platform)
|
||||
if (chbase == '\n' && chtest == '\r')
|
||||
if (fgetc(ftest) == '\n')
|
||||
chtest = '\n';
|
||||
|
||||
if(chbase != chtest)
|
||||
{
|
||||
size_t nbytes = 2048;
|
||||
int CRLF_shift=1;
|
||||
char *strbase, *strtest, *strbase_d, *strtest_d;
|
||||
|
||||
printf("Files differ at line %lu:\n", l);
|
||||
fseek(fbase,pos,SEEK_SET);
|
||||
|
||||
// Take into account CRLF characters when we write \n into
|
||||
// dump file when we used WIN platform
|
||||
#ifdef _WIN32
|
||||
CRLF_shift = 2;
|
||||
fseek(ftest,pos + l - 1,SEEK_SET);
|
||||
#else
|
||||
fseek(ftest,pos,SEEK_SET);
|
||||
#endif
|
||||
|
||||
strbase = (char *) malloc(nbytes + 1);
|
||||
strtest = (char *) malloc(nbytes + 1);
|
||||
fgets(strbase, nbytes, fbase);
|
||||
fgets(strtest, nbytes, ftest);
|
||||
strbase_d = (char *) malloc(strlen(strbase));
|
||||
strtest_d = (char *) malloc(strlen(strtest));
|
||||
strbase_d = (char *) malloc(strlen(strbase)+1);
|
||||
strtest_d = (char *) malloc(strlen(strtest)+1);
|
||||
strncpy(strbase_d, strbase, strlen(strbase)-1);
|
||||
strncpy(strtest_d, strtest, strlen(strtest)-1);
|
||||
strbase_d[strlen(strbase)] = '\0';
|
||||
strtest_d[strlen(strtest)] = '\0';
|
||||
strncpy(strtest_d, strtest, strlen(strtest)-CRLF_shift);
|
||||
strbase_d[strlen(strbase)-1] = '\0';
|
||||
strtest_d[strlen(strtest)-CRLF_shift] = '\0';
|
||||
printf("<%s> vs. <%s>\n", strbase_d, strtest_d);
|
||||
|
||||
free(strbase);free(strtest);
|
||||
|
|
Loading…
Reference in New Issue