--- imach/src/imach.c 2021/02/11 19:50:15 1.303 +++ imach/src/imach.c 2021/03/08 18:11:32 1.307 @@ -1,6 +1,21 @@ -/* $Id: imach.c,v 1.303 2021/02/11 19:50:15 brouard Exp $ +/* $Id: imach.c,v 1.307 2021/03/08 18:11:32 brouard Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.307 2021/03/08 18:11:32 brouard + Summary: 0.99r22 fixed bug on result: + + Revision 1.306 2021/02/20 15:44:02 brouard + Summary: Version 0.99r21 + + * imach.c (Module): Fix bug on quitting after result lines! + (Module): Version 0.99r21 + + Revision 1.305 2021/02/20 15:28:30 brouard + * imach.c (Module): Fix bug on quitting after result lines! + + Revision 1.304 2021/02/12 11:34:20 brouard + * imach.c (Module): The use of a Windows BOM (huge) file is now an error + Revision 1.303 2021/02/11 19:50:15 brouard * (Module): imach.c Someone entered 'results:' instead of 'result:'. Now it is an error which is printed. @@ -1129,12 +1144,12 @@ typedef struct { #define ODIRSEPARATOR '\\' #endif -/* $Id: imach.c,v 1.303 2021/02/11 19:50:15 brouard Exp $ */ +/* $Id: imach.c,v 1.307 2021/03/08 18:11:32 brouard Exp $ */ /* $State: Exp $ */ #include "version.h" char version[]=__IMACH_VERSION__; -char copyright[]="May 2019,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2020"; -char fullversion[]="$Revision: 1.303 $ $Date: 2021/02/11 19:50:15 $"; +char copyright[]="Feb 2021,INED-EUROREVES-Institut de longevite-Japan Society for the Promotion of Science (Grant-in-Aid for Scientific Research 25293121), Intel Software 2015-2020, INED 2000-2021"; +char fullversion[]="$Revision: 1.307 $ $Date: 2021/03/08 18:11:32 $"; char strstart[80]; char optionfilext[10], optionfilefiname[FILENAMELENGTH]; int erreur=0, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ @@ -9255,16 +9270,16 @@ int readdata(char datafile[], int firsto else if( line[0] == (char)0xFF && line[1] == (char)0xFE) { noffset=noffset+2; - printf("# Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile);fflush(stdout); - fprintf(ficlog,"# Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile); + printf("# Error Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile);fflush(stdout); + fprintf(ficlog,"# Error Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile); fflush(ficlog); return 1; } else if( line[0] == 0 && line[1] == 0) { if( line[2] == (char)0xFE && line[3] == (char)0xFF){ noffset=noffset+4; - printf("# Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile);fflush(stdout); - fprintf(ficlog,"# Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile); + printf("# Error Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile);fflush(stdout); + fprintf(ficlog,"# Error Data file '%s' is a huge UTF16BE BOM file, please convert to UTF8 or ascii file (for example with dos2unix) and rerun.\n",datafile); fflush(ficlog); return 1; } } else{ @@ -9579,7 +9594,6 @@ int decoderesult ( char resultline[], in char stra[80], strb[80], strc[80], strd[80],stre[80]; removefirstspace(&resultline); - printf("decoderesult:%s\n",resultline); if (strstr(resultline,"v") !=0){ printf("Error. 'v' must be in upper case 'V' result: %s ",resultline); @@ -9594,7 +9608,6 @@ int decoderesult ( char resultline[], in TKresult[nres]=0; /* Combination for the nresult and the model */ return (0); } - if( j != cptcovs ){ /* Be careful if a variable is in a product but not single */ printf("ERROR: the number of variable in the resultline, %d, differs from the number of variable used in the model line, %d.\n",j, cptcovs); fprintf(ficlog,"ERROR: the number of variable in the resultline, %d, differs from the number of variable used in the model line, %d.\n",j, cptcovs); @@ -12405,11 +12418,11 @@ Please run with mle=-1 to get a correct } /* Results */ + endishere=0; nresult=0; do{ if(!fgets(line, MAXLINE, ficpar)){ endishere=1; - parameterline=14; }else if (line[0] == '#') { /* If line starts with a # it is a comment */ numlinepar++; @@ -12422,8 +12435,9 @@ Please run with mle=-1 to get a correct parameterline=11; else if(sscanf(line,"prevbackcast=%[^\n]\n",modeltemp)) parameterline=12; - else if(sscanf(line,"result:%[^\n]\n",modeltemp)) + else if(sscanf(line,"result:%[^\n]\n",modeltemp)){ parameterline=13; + } else{ parameterline=14; } @@ -12475,42 +12489,33 @@ Please run with mle=-1 to get a correct } break; case 13: - if((num_filled=sscanf(line,"result:%[^\n]\n",resultline)) !=EOF){ - if (num_filled == 0){ - resultline[0]='\0'; - printf("Warning %d: no result line! It should be at minimum 'result: V2=0 V1=1 or result:.\n%s\n", num_filled, line); - fprintf(ficlog,"Warning %d: no result line! It should be at minimum 'result: V2=0 V1=1 or result:.\n%s\n", num_filled, line); - break; - } else if (num_filled != 1){ - printf("ERROR %d: result line! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",num_filled, line); - fprintf(ficlog,"ERROR %d: result line! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",num_filled, line); - } - nresult++; /* Sum of resultlines */ - printf("Result %d: result=%s\n",nresult, resultline); - if(nresult > MAXRESULTLINES){ - printf("ERROR: Current version of IMaCh limits the number of resultlines to %d, you used %d\n",MAXRESULTLINES,nresult); - fprintf(ficlog,"ERROR: Current version of IMaCh limits the number of resultlines to %d, you used %d\n",MAXRESULTLINES,nresult); - goto end; - } - decoderesult(resultline, nresult); /* Fills TKresult[nresult] combination and Tresult[nresult][k4+1] combination values */ - fprintf(ficparo,"result: %s\n",resultline); - fprintf(ficres,"result: %s\n",resultline); - fprintf(ficlog,"result: %s\n",resultline); - break; - case 14: - printf("Error: Unknown command '%s'\n",line); - fprintf(ficlog,"Error: Unknown command '%s'\n",line); - if(ncovmodel >=2 && nresult==0 ){ - printf("ERROR: no result lines! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",line); - fprintf(ficlog,"ERROR: no result lines! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",line); - } + num_filled=sscanf(line,"result:%[^\n]\n",resultline); + nresult++; /* Sum of resultlines */ + printf("Result %d: result:%s\n",nresult, resultline); + if(nresult > MAXRESULTLINES){ + printf("ERROR: Current version of IMaCh limits the number of resultlines to %d, you used %d\nYou can use the 'r' parameter file '%s' which uses option mle=0 to get other results. ",MAXRESULTLINES,nresult,rfileres); + fprintf(ficlog,"ERROR: Current version of IMaCh limits the number of resultlines to %d, you used %d\nYou can use the 'r' parameter file '%s' which uses option mle=0 to get other results. ",MAXRESULTLINES,nresult,rfileres); goto end; - break; - default: - nresult=1; - decoderesult(".",nresult ); /* No covariate */ } + decoderesult(resultline, nresult); /* Fills TKresult[nresult] combination and Tresult[nresult][k4+1] combination values */ + fprintf(ficparo,"result: %s\n",resultline); + fprintf(ficres,"result: %s\n",resultline); + fprintf(ficlog,"result: %s\n",resultline); + break; + case 14: + printf("Error: Unknown command '%s'\n",line); + fprintf(ficlog,"Error: Unknown command '%s'\n",line); + if(ncovmodel >=2 && nresult==0 ){ + printf("ERROR: no result lines! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",line); + fprintf(ficlog,"ERROR: no result lines! It should be at minimum 'result: V2=0 V1=1 or result:.' %s\n",line); + } + /* goto end; */ + break; + default: + nresult=1; + decoderesult(".",nresult ); /* No covariate */ } /* End switch parameterline */ + parameterline=0; }while(endishere==0); /* End do */ /* freqsummary(fileres, agemin, agemax, s, agev, nlstate, imx,Tvaraff,nbcode, ncodemax,mint,anint); */