[GRASS-SVN] r60670 - in grass/trunk/vector: v.surf.rst v.vol.rst

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 2 08:59:27 PDT 2014


Author: hcho
Date: 2014-06-02 08:59:27 -0700 (Mon, 02 Jun 2014)
New Revision: 60670

Modified:
   grass/trunk/vector/v.surf.rst/main.c
   grass/trunk/vector/v.vol.rst/dataoct.c
   grass/trunk/vector/v.vol.rst/main.c
   grass/trunk/vector/v.vol.rst/user.h
   grass/trunk/vector/v.vol.rst/user1.c
   grass/trunk/vector/v.vol.rst/user2.c
   grass/trunk/vector/v.vol.rst/user3.c
   grass/trunk/vector/v.vol.rst/user4.c
Log:
v.surf.rst/v.vol.rst: reduce messages to translate

Modified: grass/trunk/vector/v.surf.rst/main.c
===================================================================
--- grass/trunk/vector/v.surf.rst/main.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.surf.rst/main.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -480,49 +480,49 @@
 
     az = G_alloc_vector(n_cols + 1);
     if (!az) {
-	G_fatal_error(_("Not enough memory for az"));
+	G_fatal_error(_("Not enough memory for %s"), "az");
     }
     if (cond1) {
 	adx = G_alloc_vector(n_cols + 1);
 	if (!adx) {
-	    G_fatal_error(_("Not enough memory for adx"));
+	    G_fatal_error(_("Not enough memory for %s"), "adx");
 	}
 	ady = G_alloc_vector(n_cols + 1);
 	if (!ady) {
-	    G_fatal_error(_("Not enough memory for ady"));
+	    G_fatal_error(_("Not enough memory for %s"), "ady");
 	}
 	if (cond2) {
 	    adxx = G_alloc_vector(n_cols + 1);
 	    if (!adxx) {
-		G_fatal_error(_("Not enough memory for adxx"));
+		G_fatal_error(_("Not enough memory for %s"), "adxx");
 	    }
 	    adyy = G_alloc_vector(n_cols + 1);
 	    if (!adyy) {
-		G_fatal_error(_("Not enough memory for adyy"));
+		G_fatal_error(_("Not enough memory for %s"), "adyy");
 	    }
 	    adxy = G_alloc_vector(n_cols + 1);
 	    if (!adxy) {
-		G_fatal_error(_("Not enough memory for adxy"));
+		G_fatal_error(_("Not enough memory for %s"), "adxy");
 	    }
 	}
     }
     if ((data =
 	 quad_data_new(x_orig, y_orig, xm, ym, n_rows, n_cols, 0,
 		       KMAX)) == NULL)
-	G_fatal_error(_("Cannot create quaddata"));
+	G_fatal_error(_("Unable to create %s"), "quaddata");
     if ((functions =
 	 MT_functions_new(quad_compare, quad_divide_data, quad_add_data,
 			  quad_intersect, quad_division_check,
 			  quad_get_points)) == NULL)
 
-	G_fatal_error(_("Cannot create quadfunc"));
+	G_fatal_error(_("Unable to create %s"), "quadfunc");
 
     if ((tree = MT_tree_new(data, NULL, NULL, 0)) == NULL)
-	G_fatal_error(_("Cannot create tree"));
+	G_fatal_error(_("Unable to create %s"), "tree");
     root = tree;
 
     if ((info = MT_tree_info_new(root, functions, dmin, KMAX)) == NULL)
-	G_fatal_error(_("Cannot create tree info"));
+	G_fatal_error(_("Unable to create %s"), "tree info");
 
     open_check = Vect_open_old2(&Map, input, "", parm.field->answer);
     if (open_check < 1)
@@ -593,7 +593,7 @@
 	if (db_execute_immediate(driver2, &sql2) != DB_OK) {
 	    db_close_database(driver2);
 	    db_shutdown_driver(driver2);
-	    G_fatal_error(_("Unable to create table: '%s'"),
+	    G_fatal_error(_("Unable to create table '%s'"),
 			  db_get_string(&sql2));
 	}
 	count = 1;

Modified: grass/trunk/vector/v.vol.rst/dataoct.c
===================================================================
--- grass/trunk/vector/v.vol.rst/dataoct.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/dataoct.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -192,8 +192,8 @@
     double dx, dy, dz, x_or, y_or, z_or;
 
     if ((data->n_cols <= 1) || (data->n_rows <= 1)) {
-	clean_fatal_error
-	    (_("Points are too concentrated -- please increase DMIN"));
+	clean();
+	G_fatal_error(_("Points are too concentrated -- please increase DMIN"));
     }
 
     if (data->n_cols % 2 == 0) {
@@ -241,7 +241,8 @@
     for (i = 0; i < data->n_points; i++) {
 	comp = oct_compare(data->points + i, data);
 	if ((comp < 1) || (comp > NUMLEAFS)) {
-	    clean_fatal_error(_("Point out of range"));
+	    clean();
+	    G_fatal_error(_("Point out of range"));
 	}
 	oct_add_data(data->points + i, datas[comp]);
     }

Modified: grass/trunk/vector/v.vol.rst/main.c
===================================================================
--- grass/trunk/vector/v.vol.rst/main.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/main.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -69,8 +69,6 @@
 int cv;
 int sig1;
 
-char msg[80];
-
 struct Map_info Map;
 dbString sql;
 dbDriver *driver;
@@ -507,46 +505,46 @@
     /***************        KMAX2 = GRADPARAM1*npmax;***************/
     az = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!az)
-	G_fatal_error(_("Not enough memory for az"));
+	G_fatal_error(_("Not enough memory for %s"), "az");
     adx = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adx)
-	G_fatal_error(_("Not enough memory for adx"));
+	G_fatal_error(_("Not enough memory for %s"), "adx");
     ady = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!ady)
-	G_fatal_error(_("Not enough memory for ady"));
+	G_fatal_error(_("Not enough memory for %s"), "ady");
     adxx = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adxx)
-	G_fatal_error(_("Not enough memory for adxx"));
+	G_fatal_error(_("Not enough memory for %s"), "adxx");
     adyy = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adyy)
-	G_fatal_error(_("Not enough memory for adyy"));
+	G_fatal_error(_("Not enough memory for %s"), "adyy");
     adxy = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adxy)
-	G_fatal_error(_("Not enough memory for adxy"));
+	G_fatal_error(_("Not enough memory for %s"), "adxy");
     adz = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adz)
-	G_fatal_error(_("Not enough memory for adz"));
+	G_fatal_error(_("Not enough memory for %s"), "adz");
     adxz = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adxz)
-	G_fatal_error(_("Not enough memory for adxz"));
+	G_fatal_error(_("Not enough memory for %s"), "adxz");
     adyz = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adyz)
-	G_fatal_error(_("Not enough memory for adyz"));
+	G_fatal_error(_("Not enough memory for %s"), "adyz");
     adzz = (double *)G_malloc(sizeof(double) * (n_cols + 1));
     if (!adzz)
-	G_fatal_error(_("Not enough memory for adzz"));
+	G_fatal_error(_("Not enough memory for %s"), "adzz");
 
 
     if ((data =
 	 data_new(x_orig, y_orig, z_orig, n_rows, n_cols, n_levs, 0)) == NULL)
-	G_fatal_error(_("Unable to create octdata"));
+	G_fatal_error(_("Unable to create %s"), "octdata");
     if ((functions =
 	 OT_functions_new(oct_compare, oct_divide_data, oct_add_data,
 			  oct_intersect, oct_division_check,
 			  oct_get_points)) == NULL)
-	G_fatal_error(_("Unable to create octfunc"));
+	G_fatal_error(_("Unable to create %s"), "octfunc");
     if ((tree = OT_tree_new(data, NULL, NULL, functions, 0)) == NULL)
-	G_fatal_error(_("Unable to create octtree"));
+	G_fatal_error(_("Unable to create %s"), "octtree");
 
     root = tree;
 
@@ -555,7 +553,7 @@
      */
     if (TESTOUT) {
 	if ((fd4 = fopen("testout", "w+")) == NULL)
-	    G_fatal_error(_("Unable to open testout"));
+	    G_fatal_error(_("Unable to open %s"), "testout");
     }
 
     Vect_set_open_level(1);
@@ -606,7 +604,7 @@
 	if (db_execute_immediate(driver, &sql) != DB_OK) {
 	    db_close_database(driver);
 	    db_shutdown_driver(driver);
-	    G_fatal_error(_("Unable To create table: %s"), db_get_string(&sql));
+	    G_fatal_error(_("Unable to create table '%s'"), db_get_string(&sql));
 	}
 	count = 1;
     }
@@ -620,21 +618,25 @@
 	    fdcell = Rast_open_old(cellinp, mapset);
 	    fdcout = Rast_open_fp_new(cellout);
 	    zero_array_cell = (FCELL *) G_malloc(sizeof(FCELL) * n_cols);
-	    if (!zero_array_cell)
-		clean_fatal_error(_("Not enough memory for zero_array_cell"));
+	    if (!zero_array_cell) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array_cell");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array_cell[i] = 0;
 	    Tmp_file_cell = G_tempfile();
 	    if (NULL == (Tmp_fd_cell = fopen(Tmp_file_cell, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_cell);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_cell);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_rows; i++) {
 		if (!
 		    (fwrite
-		     (zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_cell)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		     (zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_cell))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	} else
 	  G_warning(_("Unable to create cellout raster map without cellinp"));
@@ -647,127 +649,155 @@
 	if (outz != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array1 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array1)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array1) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array1");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array1[i] = 0.;
 	    Tmp_file_z = G_tempfile();
 	    if (NULL == (Tmp_fd_z = fopen(Tmp_file_z, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_z);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_z);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array1, sizeof(float), n_cols, Tmp_fd_z)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array1, sizeof(float), n_cols, Tmp_fd_z))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	if (gradient != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array2 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array2)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array2) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array2");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array2[i] = 0.;
 	    Tmp_file_dx = G_tempfile();
 	    if (NULL == (Tmp_fd_dx = fopen(Tmp_file_dx, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_dx);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_dx);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array2, sizeof(float), n_cols, Tmp_fd_dx)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array2, sizeof(float), n_cols, Tmp_fd_dx))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	if (aspect1 != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array3 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array3)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array3) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array3");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array3[i] = 0.;
 	    Tmp_file_dy = G_tempfile();
 	    if (NULL == (Tmp_fd_dy = fopen(Tmp_file_dy, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_dy);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_dy);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array3, sizeof(float), n_cols, Tmp_fd_dy)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array3, sizeof(float), n_cols, Tmp_fd_dy))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	if (aspect2 != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array4 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array4)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array4) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array4");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array4[i] = 0.;
 	    Tmp_file_dz = G_tempfile();
 	    if (NULL == (Tmp_fd_dz = fopen(Tmp_file_dz, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_dz);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_dz);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array4, sizeof(float), n_cols, Tmp_fd_dz)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array4, sizeof(float), n_cols, Tmp_fd_dz))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	if (ncurv != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array5 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array5)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array5) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array5");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array5[i] = 0.;
 	    Tmp_file_xx = G_tempfile();
 	    if (NULL == (Tmp_fd_xx = fopen(Tmp_file_xx, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_xx);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_xx);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array5, sizeof(float), n_cols, Tmp_fd_xx)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array5, sizeof(float), n_cols, Tmp_fd_xx))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	if (gcurv != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array6 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array6)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array6) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array6");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array6[i] = 0.;
 	    Tmp_file_yy = G_tempfile();
 	    if (NULL == (Tmp_fd_yy = fopen(Tmp_file_yy, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_yy);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_yy);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array6, sizeof(float), n_cols, Tmp_fd_yy)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array6, sizeof(float), n_cols, Tmp_fd_yy))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	if (mcurv != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array7 = (float *)G_malloc(sizeof(float) * n_cols);
-	    if (!zero_array7)
-		clean_fatal_error(_("Not enough memory"));
+	    if (!zero_array7) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "zero_array7");
+	    }
 	    for (i = 0; i < n_cols; i++)
 		zero_array7[i] = 0.;
 	    Tmp_file_xy = G_tempfile();
 	    if (NULL == (Tmp_fd_xy = fopen(Tmp_file_xy, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_xy);
-		clean_fatal_error(msg);
+		clean();
+		G_fatal_error(_("Unable to open temp file '%s'"), Tmp_file_xy);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
-		if (!(fwrite(zero_array7, sizeof(float), n_cols, Tmp_fd_xy)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		if (!(fwrite(zero_array7, sizeof(float), n_cols, Tmp_fd_xy))) {
+		    clean();
+		    G_fatal_error(_("Not enough disk space - cannot write temp files"));
+		}
 	    }
 	}
 	cursegm = 0;
@@ -787,7 +817,7 @@
 	    if (mcurv != NULL)
 		G_free(zero_array7);
 
-	    G_message("Finished interpolating");
+	    G_message(_("Finished interpolating"));
 	    if (fd4 != NULL)
 		fprintf(fd4, "max. error found = %f \n", ertot);
 	    G_free(root);
@@ -876,11 +906,15 @@
 		    NPOINT);
 
 	}
-	else
-	    clean_fatal_error(_("Interpolation failed"));
+	else {
+	    clean();
+	    G_fatal_error(_("Interpolation failed"));
+	}
     }
-    else
-	clean_fatal_error(_("Input failed"));
+    else {
+	clean();
+	G_fatal_error(_("Input failed"));
+    }
     if (fd4 != NULL)
 	fclose(fd4);
 

Modified: grass/trunk/vector/v.vol.rst/user.h
===================================================================
--- grass/trunk/vector/v.vol.rst/user.h	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/user.h	2014-06-02 15:59:27 UTC (rev 60670)
@@ -18,7 +18,7 @@
 int COGRR1();
 int POINT();
 int LINEQS();
-void clean_fatal_error(const char*);
+void clean();
 int point_save();
 
 #endif

Modified: grass/trunk/vector/v.vol.rst/user1.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user1.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/user1.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -211,7 +211,8 @@
 	}
 	else {
 	    if (!(point = point_new(x, y, z, w, sm))) {
-		clean_fatal_error(_("Cannot allocate memory for point"));
+		clean();
+		G_fatal_error(_("Cannot allocate memory for point"));
 	    }
 
 	    a = OT_insert_oct(point, root);
@@ -274,8 +275,10 @@
     totsegm = translate_oct(root, ((struct octdata *)(root->data))->x_orig,
 			    ((struct octdata *)(root->data))->y_orig,
 			    ((struct octdata *)(root->data))->z_orig, nz);
-    if (!totsegm)
-	clean_fatal_error(_("Zero segments!"));
+    if (!totsegm) {
+	clean();
+	G_fatal_error(_("Zero segments!"));
+    }
 
     ((struct octdata *)(root->data))->x_orig = 0;
     ((struct octdata *)(root->data))->y_orig = 0;
@@ -361,8 +364,8 @@
     if (maskmap != NULL) {
 	mapsetm = G_find_raster2(maskmap, "");
 	if (!mapsetm) {
-	    sprintf(buf, _("Mask raster map [%s] not found"), maskmap);
-	    clean_fatal_error(buf);
+	    clean();
+	    G_fatal_error(_("Mask raster map [%s] not found"), maskmap);
 	}
 	bitmask = BM_create(nsizc, nsizr);
 	cellmask = Rast_allocate_c_buf();
@@ -377,7 +380,7 @@
 		    BM_set(bitmask, j, irev, 1);
 	    }
 	}
-	G_message("Bitmap mask created");
+	G_message(_("Bitmap mask created"));
     }
 
     return 1;
@@ -394,7 +397,6 @@
     FCELL *cell;
     float *data;
     int i, iarc, cnt;
-    char buff[1024];
     int bmask = 1;
     int x, y;
     float value;
@@ -417,7 +419,8 @@
     current_region.top = nsizl * tb_res_in + z_orig_in;
 
     if (!(data = (float *)G_malloc(sizeof(float) * nsizr * nsizc * nsizl))) {
-	clean_fatal_error(_("Out of memory"));
+	clean();
+	G_fatal_error(_("Out of memory"));
     }
 
   /*** Write elevation results ***/
@@ -425,8 +428,8 @@
 
 	cf1 = Rast3d_open_new_opt_tile_size(outz, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf1 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), outz);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), outz);
 	}
 
 	/* seek to the beginning */
@@ -435,8 +438,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_z);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -451,10 +456,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf1, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -465,8 +470,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf1) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), outz);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), outz);
 	} else
             G_message(_("3D raster map <%s> created"), outz);
     }
@@ -476,8 +481,8 @@
 
 	cf2 = Rast3d_open_new_opt_tile_size(gradient, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf2 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), gradient);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), gradient);
 	}
 
 	/* seek to the beginning */
@@ -486,8 +491,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_dx);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -502,10 +509,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf2, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -516,8 +523,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf2) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), gradient);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), gradient);
 	} else
             G_message(_("3D raster map <%s> created"), gradient);
     }
@@ -527,8 +534,8 @@
 
 	cf3 = Rast3d_open_new_opt_tile_size(aspect1, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf3 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), aspect1);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), aspect1);
 	}
 
 	/* seek to the beginning */
@@ -537,8 +544,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_dy);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -553,10 +562,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf3, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -567,8 +576,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf3) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), aspect1);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), aspect1);
 	} else
             G_message(_("3D raster map <%s> created"), aspect1);
     }
@@ -578,8 +587,8 @@
 
 	cf4 = Rast3d_open_new_opt_tile_size(aspect2, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf4 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), aspect2);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), aspect2);
 	}
 
 	/* seek to the beginning */
@@ -588,8 +597,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_dz);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -604,10 +615,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf4, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -618,8 +629,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf4) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), aspect2);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), aspect2);
 	} else
             G_message(_("3D raster map <%s> created"), aspect2);
     }
@@ -629,8 +640,8 @@
 
 	cf5 = Rast3d_open_new_opt_tile_size(ncurv, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf5 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), ncurv);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), ncurv);
 	}
 
 	/* seek to the beginning */
@@ -639,8 +650,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_xx);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -655,10 +668,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf5, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -669,8 +682,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf5) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), ncurv);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), ncurv);
 	} else
             G_message(_("3D raster map <%s> created"), ncurv);
     }
@@ -680,8 +693,8 @@
 
 	cf6 = Rast3d_open_new_opt_tile_size(gcurv, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf6 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), gcurv);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), gcurv);
 	}
 
 	/* seek to the beginning */
@@ -690,8 +703,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_yy);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -706,10 +721,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf6, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -720,8 +735,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf6) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), gcurv);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), gcurv);
 	} else
             G_message(_("3D raster map <%s> created"), gcurv);
     }
@@ -731,8 +746,8 @@
 
 	cf7 = Rast3d_open_new_opt_tile_size(mcurv, RASTER3D_USE_CACHE_DEFAULT, &current_region, FCELL_TYPE, 32); 
 	if (cf7 == NULL) {
-	    sprintf(buff, _("Unable to open %s for writing"), mcurv);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Unable to open %s for writing"), mcurv);
 	}
 
 	/* seek to the beginning */
@@ -741,8 +756,10 @@
 	/* Read data in from temp file */
 	read_val =
 	    fread(data, sizeof(float), nsizr * nsizc * nsizl, Tmp_fd_xy);
-	if (read_val < 0)
-	    clean_fatal_error(_("Unable to read data from temp file"));
+	if (read_val < 0) {
+	    clean();
+	    G_fatal_error(_("Unable to read data from temp file"));
+	}
 
 	cnt = 0;
 	for (iarc = 0; iarc < nsizl; iarc++) {
@@ -757,10 +774,10 @@
 		    if (!bmask)
 			Rast3d_set_null_value(&value, 1, FCELL_TYPE);
 		    if (Rast3d_put_float(cf7, x, y, iarc, value) == 0) {
-			sprintf(buff,
+			clean();
+			G_fatal_error(
 				_("Error writing cell (%d,%d,%d) with value %f"),
 				x, y, iarc, value);
-			clean_fatal_error(buff);
 		    }
 
 		    cnt++;
@@ -771,8 +788,8 @@
 
 	/* Close the file */
 	if (Rast3d_close(cf7) == 0) {
-	    sprintf(buff, _("Error closing output file %s"), mcurv);
-	    clean_fatal_error(buff);
+	    clean();
+	    G_fatal_error(_("Error closing output file %s"), mcurv);
 	} else
             G_message(_("3D raster map <%s> created"), mcurv);
     }

Modified: grass/trunk/vector/v.vol.rst/user2.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user2.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/user2.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -117,12 +117,14 @@
 	    if (!
 		(points =
 		 (struct quadruple *)G_malloc(sizeof(struct quadruple) *
-					      (KMAX2 + 1))))
-		clean_fatal_error(_("Not enough memory for points"));
+					      (KMAX2 + 1)))) {
+		clean();
+		G_fatal_error(_("Not enough memory for %s"), "points");
+	    }
 	}
 
 	/*           if(!(point=(struct point_3d*)G_malloc(sizeof(struct point_3d)*(KMAX2+1))))
-	   clean_fatal_error("Not enough memory for points"); */
+	   {clean(); G_fatal_error("Not enough memory for points");} */
 
 
 	distx = (((struct octdata *)(tree->data))->n_cols * ew_res) * 0.1;
@@ -207,23 +209,28 @@
 		    (A =
 		     (double *)G_malloc(sizeof(double) *
 					((KMAX2 + 1) * (KMAX2 + 2) + 1)))) {
-		    clean_fatal_error(_("Cannot allocate A"));
+		    clean();
+		    G_fatal_error(_("Cannot allocate A"));
 		}
 		if (!(b = (double *)G_malloc(sizeof(double) * (KMAX2 + 2)))) {
-		    clean_fatal_error(_("Cannot allocate b"));
+		    clean();
+		    G_fatal_error(_("Cannot allocate b"));
 		}
 		if (!(w = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) {
-		    clean_fatal_error(_("Cannot allocate w"));
+		    clean();
+		    G_fatal_error(_("Cannot allocate w"));
 		}
 	    }
 	}
 
 	/*      if(!(points=(struct quadruple*)G_malloc(sizeof(struct quadruple)*(npt))))
-	   clean_fatal_error("Not enough memory for points"); */
+	   {clean(); G_fatal_error("Not enough memory for points");} */
 	if (!
 	    (point =
-	     (struct point_3d *)G_malloc(sizeof(struct point_3d) * (npt))))
-	    clean_fatal_error(_("Not enough memory for points"));
+	     (struct point_3d *)G_malloc(sizeof(struct point_3d) * (npt)))) {
+	    clean();
+	    G_fatal_error(_("Not enough memory for %s"), "point");
+	}
 
 	/* cv stuff */
 

Modified: grass/trunk/vector/v.vol.rst/user3.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user3.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/user3.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -268,16 +268,22 @@
     stepiz = tb_res / dnorm;
 
     if (!w2) {
-	if (!(w2 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1))))
-	    clean_fatal_error(_("Cannot allocate w2"));
+	if (!(w2 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) {
+	    clean();
+	    G_fatal_error(_("Not enough memory for %s"), "w2");
+	}
     }
     if (!wz2) {
-	if (!(wz2 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1))))
-	    clean_fatal_error(_("Cannot allocate wz2"));
+	if (!(wz2 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) {
+	    clean();
+	    G_fatal_error(_("Not enough memory for %s"), "wz2");
+	}
     }
     if (!wz1) {
-	if (!(wz1 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1))))
-	    clean_fatal_error(_("Cannot allocate wz1"));
+	if (!(wz1 = (double *)G_malloc(sizeof(double) * (KMAX2 + 1)))) {
+	    clean();
+	    G_fatal_error(_("Not enough memory for %s"), "wz1");
+	}
     }
 
     if (cell == NULL)
@@ -536,8 +542,10 @@
 			(aspect2 != NULL)
 			|| (ncurv != NULL) || (gcurv != NULL) ||
 			(mcurv != NULL))
-			if (!(secpar_loop(ngstc, nszc, l)))
-			    clean_fatal_error(_("Secpar_loop failed"));
+			if (!(secpar_loop(ngstc, nszc, l))) {
+			    clean();
+			    G_fatal_error(_("Secpar_loop failed"));
+			}
 		    if ((cellinp != NULL) && (cellout != NULL) &&
 			(i == ngstl)) {
 			zero_array_cell[l - 1] = (FCELL) (wwcell);
@@ -573,72 +581,88 @@
 		    if (!
 			(fwrite
 			 (zero_array_cell + ind1, sizeof(FCELL),
-			  nszc - ngstc + 1, Tmp_fd_cell)))
-			clean_fatal_error
+			  nszc - ngstc + 1, Tmp_fd_cell))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (outz != NULL) {
 		    G_fseek(Tmp_fd_z, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array1 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_z)))
-			clean_fatal_error
+			  Tmp_fd_z))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (gradient != NULL) {
 		    G_fseek(Tmp_fd_dx, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array2 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_dx)))
-			clean_fatal_error
+			  Tmp_fd_dx))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (aspect1 != NULL) {
 		    G_fseek(Tmp_fd_dy, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array3 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_dy)))
-			clean_fatal_error
+			  Tmp_fd_dy))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (aspect2 != NULL) {
 		    G_fseek(Tmp_fd_dz, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array4 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_dz)))
-			clean_fatal_error
+			  Tmp_fd_dz))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (ncurv != NULL) {
 		    G_fseek(Tmp_fd_xx, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array5 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_xx)))
-			clean_fatal_error
+			  Tmp_fd_xx))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (gcurv != NULL) {
 		    G_fseek(Tmp_fd_yy, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array6 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_yy)))
-			clean_fatal_error
+			  Tmp_fd_yy))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 		if (mcurv != NULL) {
 		    G_fseek(Tmp_fd_xy, (off_t)(offset2 * sizeof(float)), 0);
 		    if (!
 			(fwrite
 			 (zero_array7 + ind1, sizeof(float), nszc - ngstc + 1,
-			  Tmp_fd_xy)))
-			clean_fatal_error
+			  Tmp_fd_xy))) {
+			clean();
+			G_fatal_error
 			    (_("Not enough disk space--cannot write files"));
+		    }
 		}
 
 	    }

Modified: grass/trunk/vector/v.vol.rst/user4.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user4.c	2014-06-02 14:14:16 UTC (rev 60669)
+++ grass/trunk/vector/v.vol.rst/user4.c	2014-06-02 15:59:27 UTC (rev 60670)
@@ -44,7 +44,7 @@
 
  */
 
-void clean_fatal_error(char *str)
+void clean()
 {
     if (Tmp_fd_z) {
 	fclose(Tmp_fd_z);
@@ -74,7 +74,6 @@
 	fclose(Tmp_fd_xy);
 	unlink(Tmp_file_xy);
     }
-    G_fatal_error(str);
 }
 
 



More information about the grass-commit mailing list