jasonlarkin / p3dfft

Automatically exported from code.google.com/p/p3dfft
GNU General Public License v3.0
0 stars 0 forks source link

Put in check to see if stdin exists #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
- p3dfft.2.3.2/sample/C/*.c about line 61
There is no check wether file stdin exists. This leads to hard to find
segmentations faults, if the user didn't copy stdin from the sample folder 
into the C folder.

A warning for the user would be nice. So I replaced
> fp = fopen("stdin","r");
> ndim = 2;
> fscanf(fp,"%d,%d,%d,%d,%d\n",&nx,&ny,&nz,&ndim,&n);
> fclose(fp);
by
> ndim = 2;
> if((fp=fopen("stdin", "r"))==NULL){
>   printf("Cannot open file. Setting to default nx=ny=nz=128, ndim=2, n=1.
\n");
>   nx=ny=nz=128; n=1;
> }
> else{
>   fscanf(fp,"%d,%d,%d,%d,%d\n",&nx,&ny,&nz,&ndim,&n);
>   fclose(fp);
> }

Original issue reported on code.google.com by d4p...@ucsd.edu on 3 Mar 2010 at 1:23

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r34.

Original comment by dan.djc...@gmail.com on 4 Mar 2010 at 7:06