Commit 5333777e authored by Vesa Oikonen's avatar Vesa Oikonen
Browse files

updated argument handling

parent 07a8ee2c
......@@ -101,30 +101,23 @@ int main(int argc, char **argv)
status.verbose=verbose-5;
/* Arguments */
for(; ai<argc; ai++) {
if(!tacfile1[0]) {
strcpy(tacfile1, argv[ai]); continue;
} else if(!tacfile2[0]) {
strcpy(tacfile2, argv[ai]); continue;
} else if(crossLimit==0) {
crossLimit=atoi(argv[ai]); if(crossLimit>0) continue;
}
fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
return(1);
}
if(ai<argc) strlcpy(tacfile1, argv[ai++], FILENAME_MAX);
if(ai<argc) strlcpy(tacfile2, argv[ai++], FILENAME_MAX);
if(ai<argc) crossLimit=atoi(argv[ai++]);
if(ai<argc) {fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]); return(1);}
/* Is something missing? */
if(!tacfile2[0] || crossLimit<1) {
tpcPrintUsage(argv[0], info, stdout); return(1);}
if(!tacfile2[0] || crossLimit<1) {tpcPrintUsage(argv[0], info, stdout); return(1);}
if(crossLimit<1) {fprintf(stderr, "Error: missing or invalid cross number.\n"); return(1);}
/* In verbose mode print arguments and options */
if(verbose>1) {
for(ai=0; ai<argc; ai++)
printf("%s ", argv[ai]);
for(ai=0; ai<argc; ai++) printf("%s ", argv[ai]);
printf("\n");
printf("tacfile1 := %s\n", tacfile1);
printf("tacfile2 := %s\n", tacfile2);
printf("crossLimit := %d\n", crossLimit);
fflush(stdout);
}
......@@ -172,8 +165,7 @@ int main(int argc, char **argv)
}
ret=tacYUnitConvert(&tac1, tac2.cunit, &status);
if(ret!=TPCERROR_OK) {
fprintf(stderr,
"Warning: could not convert concentrations from '%s' to '%s'.\n",
fprintf(stderr, "Warning: could not convert concentrations from '%s' to '%s'.\n",
unitName(tac1.cunit), unitName(tac2.cunit));
}
......@@ -196,8 +188,7 @@ int main(int argc, char **argv)
*/
int i, consecNr=0, crossNr=0, above=0;
i=0; if(tac2.c[0].y[i]>tac2.c[1].y[i]) above=1;
if(verbose>2)
printf(" %d: %d %g %g\n", 1+i, above, tac2.c[0].y[i], tac2.c[1].y[i]);
if(verbose>2) printf(" %d: %d %g %g\n", 1+i, above, tac2.c[0].y[i], tac2.c[1].y[i]);
for(i=1; i<tac2.sampleNr; i++) {
if(tac2.c[0].y[i]>tac2.c[1].y[i]) { // above
if(above) {consecNr++;} else {consecNr=0; crossNr++;}
......@@ -206,8 +197,7 @@ int main(int argc, char **argv)
if(!above) {consecNr++;} else {consecNr=0; crossNr++;}
above=0;
}
if(verbose>2)
printf(" %d: %d %g %g\n", 1+i, above, tac2.c[0].y[i], tac2.c[1].y[i]);
if(verbose>2) printf(" %d: %d %g %g\n", 1+i, above, tac2.c[0].y[i], tac2.c[1].y[i]);
if(crossNr>0 && consecNr>=crossLimit) break;
}
if(crossNr==0 || consecNr<crossLimit) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment