[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203

Stephane Popinet popinet at users.sf.net
Fri May 15 02:55:47 UTC 2009


The following commit has been merged in the upstream branch:
commit c81cf96e5019751a793a447cec9be93f1671cb80
Author: Stephane Popinet <popinet at users.sf.net>
Date:   Thu Oct 16 10:33:26 2008 +1100

    Fixed access modes for Terrain module
    
    darcs-hash:20081015233326-d4795-344968655fbc54bb3cad585be101cb517c43fe7e.gz

diff --git a/modules/RStarTree/RSTInterUtil.c b/modules/RStarTree/RSTInterUtil.c
index dd05e96..f76ee7b 100644
--- a/modules/RStarTree/RSTInterUtil.c
+++ b/modules/RStarTree/RSTInterUtil.c
@@ -46,11 +46,10 @@ void CreateRSFiles(RSTREE R)
 
 /***********************************************************************/
 
-void OpenRSFiles(RSTREE R)
+void OpenRSFiles(RSTREE R, int O_MODE)
 
 {
   RSTName SufName;
-  int O_MODE= O_RDWR;
     
   (*R).dir.f= open((*R).dirname,O_MODE,STDMODE);
   if ((*R).dir.f == -1) {
diff --git a/modules/RStarTree/RSTInterUtil.h b/modules/RStarTree/RSTInterUtil.h
index 38db446..4c30a23 100644
--- a/modules/RStarTree/RSTInterUtil.h
+++ b/modules/RStarTree/RSTInterUtil.h
@@ -17,7 +17,7 @@
 /* declarations */
 
 void CreateRSFiles(RSTREE R);
-void OpenRSFiles(RSTREE R);
+void OpenRSFiles(RSTREE R, int O_MODE);
 void FastCloseRSFiles(RSTREE R);
 void CloseRSFiles(RSTREE R);
 void SetBase(RSTREE R, int pagelen, boolean unique);
diff --git a/modules/RStarTree/RStarTree.c b/modules/RStarTree/RStarTree.c
index ed6284a..cf71aff 100644
--- a/modules/RStarTree/RStarTree.c
+++ b/modules/RStarTree/RStarTree.c
@@ -122,7 +122,8 @@ boolean RemoveRST(char *name)
 /************************************************************************/
 
 boolean OpenRST(RSTREE *r,
-                char *name)
+                const char *name,
+		const char *mode)
 
 {
   RSTREE R;
@@ -135,7 +136,7 @@ boolean OpenRST(RSTREE *r,
   R= *r;
   strcpy((*R).dirname,name);
   (*R).RSTDone= TRUE;
-  OpenRSFiles(R);
+  OpenRSFiles(R, strcmp (mode, "rw") ? O_RDONLY : O_RDWR);
   if (! (*R).RSTDone) {
     free(R); *r= NULL;
     return FALSE;
@@ -515,7 +516,7 @@ boolean JoinCountNv(RSTREE R1, RSTREE R2,
       }
     } /* syncronize R1 */
     R2= NULL;
-    success= OpenRST(&R2,(*R1).dirname); /* NEW(R2) */
+    success= OpenRST(&R2,(*R1).dirname,"rw"); /* NEW(R2) */
     if (! success) {
       fprintf(stderr,"%s\n","FATAL INTERNAL ERROR");
       fprintf(stderr,"%s\n","JoinCountNv 1");
@@ -593,7 +594,7 @@ boolean JoinNv(RSTREE R1, RSTREE R2,
       }
     } /* syncronize R1 */
     R2= NULL;
-    success= OpenRST(&R2,(*R1).dirname); /* NEW(R2) */
+    success= OpenRST(&R2,(*R1).dirname,"rw"); /* NEW(R2) */
     if (! success) {
       fprintf(stderr,"%s\n","FATAL INTERNAL ERROR");
       fprintf(stderr,"%s\n","JoinCountNv 1");
diff --git a/modules/RStarTree/RStarTree.h b/modules/RStarTree/RStarTree.h
index 3c4a6ec..6b3f0a1 100644
--- a/modules/RStarTree/RStarTree.h
+++ b/modules/RStarTree/RStarTree.h
@@ -265,8 +265,9 @@ boolean  RemoveRST(char *name);
          /* RemoveRST removes all files corresponding to an R*-tree. */
 
 
-boolean  OpenRST(RSTREE  *rst,
-                 char    *name);
+boolean  OpenRST(RSTREE        *rst,
+                 const char    *name,
+		 const char    *mode);
 
          /* OpenRST opens the R*-tree named name. */
 
diff --git a/modules/rsurface.c b/modules/rsurface.c
index 1cb234b..c00dfc7 100644
--- a/modules/rsurface.c
+++ b/modules/rsurface.c
@@ -26,7 +26,7 @@ RSurface * r_surface_open (const char * fname, const char * mode, int size)
     }
   }
   rt->t = NULL;
-  if (!OpenRST (&rt->t, fname)) {
+  if (!OpenRST (&rt->t, fname, !strcmp (mode, "w") ? "rw" : "r")) {
     free (rt);
     return NULL;
   }
diff --git a/modules/rsurfacequery.c b/modules/rsurfacequery.c
index ea25dd5..5ff7be8 100644
--- a/modules/rsurfacequery.c
+++ b/modules/rsurfacequery.c
@@ -16,6 +16,11 @@ int main (int argc, char** argv)
   }
 
   RSurface * rs = r_surface_open (argv[1], "r", 0);
+  if (rs == NULL) {
+    fprintf (stderr, "rsurfacequery: could not open `%s'\n", argv[1]);
+    return -1;
+  }    
+
   double min[2], max[2];
   int count = 0;
   while (scanf ("%lf %lf %lf %lf", &min[0], &min[1], &max[0], &max[1]) == 4) {

-- 
Gerris Flow Solver



More information about the debian-science-commits mailing list