Bläddra i källkod

cairodriver: fix segfault for ppm (GRASS_PNG_READ=TRUE)
minor fix in headers and messages


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46944 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 år sedan
förälder
incheckning
84a2c2a880

+ 2 - 2
lib/cairodriver/Driver.c

@@ -1,9 +1,9 @@
 /*!
-  \file cairodriver/Driver.c
+  \file lib/cairodriver/Driver.c
 
   \brief GRASS cairo display driver - driver initialization
 
-  (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
+  (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
   
   This program is free software under the GNU General Public License
   (>=v2). Read the file COPYING that comes with GRASS for details.

+ 5 - 5
lib/cairodriver/Graph.c

@@ -1,9 +1,9 @@
 /*!
-  \file cairodriver/Graph.c
+  \file lib/cairodriver/Graph.c
 
   \brief GRASS cairo display driver - driver settings
 
-  (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
+  (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
   
   This program is free software under the GNU General Public License
   (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -174,9 +174,9 @@ static void init_file(void)
     if (do_read && access(ca.file_name, 0) != 0)
 	do_read = 0;
 
-    G_verbose_message(_("cairo: collecting to file: %s"),
+    G_verbose_message(_("cairo: collecting to file '%s'"),
 		      ca.file_name);
-    G_verbose_message(_("GRASS_WIDTH=%d, GRASS_HEIGHT=%d"),
+    G_verbose_message(_("cairo: image size %dx%d"),
 		      ca.width, ca.height);
     
     if (do_read && do_map)
@@ -382,7 +382,7 @@ static void map_file(void)
 	cairo_surface_destroy(surface);
 	G_free(ca.grid);
     }
-    ca.grid = (char *)ptr + HEADER_SIZE;
+    ca.grid = (unsigned char *) ptr + HEADER_SIZE;
 
     close(fd);
 

+ 2 - 0
lib/cairodriver/cairodriver.html

@@ -102,6 +102,7 @@ export GRASS_PNGFILE=spearfish.png
 export GRASS_WIDTH=800
 export GRASS_HEIGHT=800
 export GRASS_RENDER_IMMEDIATE=CAIRO
+export GRASS_PNG_READ=TRUE
 
 d.rast map=elevation.10m
 d.vect map=streams width=1 color=blue fcolor=aqua type=area,line
@@ -114,6 +115,7 @@ export GRASS_PNGFILE=spearfish.pdf
 export GRASS_WIDTH=800
 export GRASS_HEIGHT=800
 export GRASS_RENDER_IMMEDIATE=CAIRO
+export GRASS_PNG_READ=TRUE
 
 d.rast map=elevation.10m
 d.vect map=streams width=1 color=blue fcolor=aqua type=area,line

+ 2 - 2
lib/cairodriver/read.c

@@ -1,9 +1,9 @@
 /*!
-  \file cairodriver/read.c
+  \file lib/cairodriver/read.c
 
   \brief GRASS cairo display driver - read image (lower level functions)
 
-  (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
+  (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
   
   This program is free software under the GNU General Public License
   (>=v2). Read the file COPYING that comes with GRASS for details.

+ 6 - 6
lib/cairodriver/read_ppm.c

@@ -1,9 +1,9 @@
 /*!
-  \file cairodriver/read_ppm.c
+  \file lib/cairodriver/read_ppm.c
 
   \brief GRASS cairo display driver - read PPM image (lower level functions)
 
-  (C) 2007-2008 by Lars Ahlzen and the GRASS Development Team
+  (C) 2007-2008, 2011 by Lars Ahlzen and the GRASS Development Team
   
   This program is free software under the GNU General Public License
   (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -41,16 +41,16 @@ void cairo_read_ppm(void)
 
     mask_name[strlen(mask_name) - 2] = 'g';
 
-    input = fopen(mask_name, "rb");
-    if (!input)
+    mask = fopen(mask_name, "rb");
+    if (!mask)
 	G_fatal_error(_("Cairo: unable to open input mask file <%s>"),
 		      mask_name);
 
-    if (fscanf(input, "P5 %d %d %d", &i_width, &i_height, &maxval) != 3)
+    if (fscanf(mask, "P5 %d %d %d", &i_width, &i_height, &maxval) != 3)
 	G_fatal_error(_("Cairo: invalid input mask file <%s>"),
 		      mask_name);
 
-    fgetc(input);
+    fgetc(mask);
 
     if (i_width != ca.width || i_height != ca.height)
 	G_fatal_error(_("Cairo: input mask file has incorrect dimensions: "