=================================================================== RCS file: /home/cvs/OpenXM/src/phc/phc6.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -r1.1 -r1.2 --- OpenXM/src/phc/phc6.c 1999/10/08 02:12:14 1.1 +++ OpenXM/src/phc/phc6.c 2000/10/31 12:21:28 1.2 @@ -58,7 +58,7 @@ char *phc_which(char *s); /* search a path for the f struct phc_object phc_complexTo(long double r, long double i); -int phc_scan_for_string(FILE *fp, char str[], int lenstr); +int phc_scan_for_string(FILE *fp, char str[]); struct phc_object phc_scan_solutions(FILE *fp, int npaths, int dim ); struct phc_object phc_scan_output_of_phc(char *fname); struct phc_object phc_call_phc(char *sys); @@ -77,7 +77,7 @@ main(int argc, char *argv[]) { int message = 0; for (i=1; i= BUF_SIZE-1) { + fprintf(stderr,"Too long string in phc_scan_for_string\n"); + exit(-1); + } index = -1; found = 0; - while ((fscanf(fp,"%c",&ch)!=EOF) && found == 0) - { - if (index == -1 && ch == str[0]) + while (((ch = fgetc(fp))!=EOF) && found == 0) { - index = 0; - buf[index] = ch; - } - else - { - if (index == lenstr) - { - compare = 0; - for (i=0; i -1 && index < lenstr) + { + index = index+1; + buf[index] = ch; + } } - index = -1; - } - else - if (index > -1 && index < lenstr) - { - index = index+1; - buf[index] = ch; - } + if (found == 1) break; } - if (found == 1) break; - } return found; } struct phc_object phc_scan_solutions(FILE *fp, int npaths, int dim ) @@ -187,24 +195,31 @@ struct phc_object phc_scan_solutions(FILE *fp, int npa struct phc_object rob,sob; char ch; int fnd,i,j,nsols; - float res; + double res; long double realpart; long double imagpart; long double realparts[npaths][dim]; long double imagparts[npaths][dim]; nsols = 0; - while (fscanf(fp,"%c",&ch)!=EOF) + while ((ch = fgetc(fp)) != EOF) { - fnd = phc_scan_for_string(fp,"start residual :",15); + fnd = phc_scan_for_string(fp,"start residual :"); if (fnd==1) { fscanf(fp,"%E",&res); - /* printf(" residual = "); printf("%E\n",res); */ - if (res < 1.0E-12) nsols = nsols+1; - fnd = phc_scan_for_string(fp,"the solution for t :",19); + /* printf(" residual = "); printf("%E\n",res); */ + if (res < 1.0E-12) { + nsols = nsols+1; + if (nsols > npaths) { + fprintf(stderr,"Something is wrong in phc_scan_solutions\n"); + fprintf(stderr,"npaths=%d, nsols=%d \n",npaths,nsols); + exit(-1); + } + } + fnd = phc_scan_for_string(fp,"the solution for t :"); for (i=0;i