source: issm/oecreview/Archive/14312-15392/ISSM-14550-14551.diff@ 15393

Last change on this file since 15393 was 15393, checked in by Mathieu Morlighem, 12 years ago

NEW: adding Archive/14312-15392 for oecreview

File size: 3.2 KB
RevLine 
[15393]1Index: ../trunk-jpl/src/c/shared/Exp/exp.h
2===================================================================
3--- ../trunk-jpl/src/c/shared/Exp/exp.h (revision 14550)
4+++ ../trunk-jpl/src/c/shared/Exp/exp.h (revision 14551)
5@@ -90,14 +90,22 @@
6 /*Do a first pass through the domainname file, to figure out how many profiles we need to read: */
7 nprof=1;
8 for(;;){
9- fscanf(fid,"%255s %255s\n",chardummy,chardummy);
10- fscanf(fid,"%255s %255s\n",chardummy,chardummy);
11- fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy);
12- fscanf(fid,"%20u %255s\n",&n,chardummy);
13- fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
14- for (i=0;i<n;i++) fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy);
15+ //## Name:filename
16+ if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
17+ //## Icon:0
18+ if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
19+ //# Points Count Value
20+ if(fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy)!=4) _error_("Could not read " << domainname);
21+ if(fscanf(fid,"%20u %255s\n",&n,chardummy)!=2) _error_("Could not read number of points in "<<domainname);
22+ //# X pos Y pos
23+ if(fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy)!=5) _error_("Could not read " << domainname);
24+ for (i=0;i<n;i++){
25+ if(fscanf(fid,"%20lf %20lf\n",&ddummy,&ddummy)!=2){
26+ _error_("Could not read coordinate of vertex "<< i <<" of "<<domainname);
27+ }
28+ }
29 /*check whether we are at the end of the file, otherwise, keep reading next profile:*/
30- if (feof(fid)) break;
31+ if(feof(fid)) break;
32 nprof++;
33 }
34
35@@ -118,15 +126,19 @@
36 for(counter=0;counter<nprof;counter++){
37
38 /*Skip header: */
39- fscanf(fid,"%255s %255s\n",chardummy,chardummy);
40- fscanf(fid,"%255s %255s\n",chardummy,chardummy);
41- fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy);
42+ //## Name:filename
43+ if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
44+ //## Icon:0
45+ if(fscanf(fid,"%255s %255s\n",chardummy,chardummy)!=2) _error_("Could not read " << domainname);
46+ //# Points Count Value
47+ if(fscanf(fid,"%255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy)!=4) _error_("Could not read " << domainname);
48
49 /*Get number of profile vertices: */
50- fscanf(fid,"%20u %255s\n",&n,chardummy);
51+ if(fscanf(fid,"%20u %255s\n",&n,chardummy)!=2) _error_("Could not read number of points in "<<domainname);
52
53 /*Skip next line: */
54- fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy);
55+ //# X pos Y pos
56+ if(fscanf(fid,"%255s %255s %255s %255s %255s\n",chardummy,chardummy,chardummy,chardummy,chardummy)!=5) _error_("Could not read " << domainname);
57
58 /*Allocate vertices: */
59 x=xNew<doubletype>(n);
60@@ -134,7 +146,9 @@
61
62 /*Read vertices: */
63 for (i=0;i<n;i++){
64- fscanf(fid,"%20lf %20lf\n",&x[i],&y[i]);
65+ if(fscanf(fid,"%20lf %20lf\n",&x[i],&y[i])!=2){
66+ _error_("Could not read coordinate of vertex "<<i<<" of "<<domainname);
67+ }
68 }
69
70 /*Now check that we are dealing with open contours: */
Note: See TracBrowser for help on using the repository browser.