[GRASS-SVN] r63570 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 16 04:10:57 PST 2014


Author: martinl
Date: 2014-12-16 04:10:57 -0800 (Tue, 16 Dec 2014)
New Revision: 63570

Modified:
   grass/trunk/lib/vector/Vlib/hist.c
Log:
vlib: Vect_hist_command() check return value of Vect_hist_write()


Modified: grass/trunk/lib/vector/Vlib/hist.c
===================================================================
--- grass/trunk/lib/vector/Vlib/hist.c	2014-12-16 08:39:59 UTC (rev 63569)
+++ grass/trunk/lib/vector/Vlib/hist.c	2014-12-16 12:10:57 UTC (rev 63570)
@@ -28,22 +28,27 @@
  */
 int Vect_hist_command(struct Map_info *Map)
 {
-    char *cmd, buf[2000];
+    char *cmd, buf[GPATH_MAX];
 
     G_debug(3, "Vect_hist_command()");
 
     cmd = G_recreate_command();
 
-    Vect_hist_write(Map, "COMMAND: ");
-    Vect_hist_write(Map, cmd);
-    Vect_hist_write(Map, "\n");
+    if (0 > Vect_hist_write(Map, "COMMAND: "))
+        return -1;
+    if (0 > Vect_hist_write(Map, cmd))
+        return -1;
+    if (0 > Vect_hist_write(Map, "\n"))
+        return -1;
 
     sprintf(buf, "GISDBASE: %s\n", G_gisdbase());	/* Needed ? */
-    Vect_hist_write(Map, buf);
+    if (0 > Vect_hist_write(Map, buf))
+        return -1;
 
     sprintf(buf, "LOCATION: %s MAPSET: %s USER: %s DATE: %s\n",
 	    G_location(), G_mapset(), G_whoami(), G_date());	/* Needed ? */
-    Vect_hist_write(Map, buf);
+    if (0 > Vect_hist_write(Map, buf))
+        return -1;
 
     return 0;
 }
@@ -55,6 +60,7 @@
    \param str string to write
 
    \return the number of characters printed
+   \return -1 on error
  */
 int Vect_hist_write(struct Map_info *Map, const char *str)
 {



More information about the grass-commit mailing list