[GRASS-SVN] r67366 - in grass/branches/releasebranch_7_0: lib/vector/Vlib vector/v.out.ascii

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 24 07:11:18 PST 2015


Author: martinl
Date: 2015-12-24 07:11:18 -0800 (Thu, 24 Dec 2015)
New Revision: 67366

Modified:
   grass/branches/releasebranch_7_0/lib/vector/Vlib/ascii.c
   grass/branches/releasebranch_7_0/vector/v.out.ascii/main.c
Log:
v.out.ascii + vlib: use cross-platform newline character (see #2745)
            (merge r67278 from trunk)


Modified: grass/branches/releasebranch_7_0/lib/vector/Vlib/ascii.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/Vlib/ascii.c	2015-12-24 15:09:34 UTC (rev 67365)
+++ grass/branches/releasebranch_7_0/lib/vector/Vlib/ascii.c	2015-12-24 15:11:18 UTC (rev 67366)
@@ -5,7 +5,7 @@
  
   Higher level functions for reading/writing/manipulating vectors.
   
-  (C) 2001-2009, 2011-2013 by the GRASS Development Team
+  (C) 2001-2015 by 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.
@@ -544,7 +544,7 @@
 		    fprintf(ascii, "%s", columns[i]); /* can not happen */
 	    }
 	}
-	fprintf(ascii, "\n");
+	fprintf(ascii, "%s", HOST_NEWLINE);
     }
 
     Points = Vect_new_line_struct();
@@ -637,7 +637,7 @@
 			G_trim_decimal(xstring);
 			G_rasprintf(&ystring, &ysize, "%.*f", dp, Points->y[0]);
 			G_trim_decimal(ystring);
-			fprintf(att, "A %s %s %d\n", xstring, ystring, cat);
+			fprintf(att, "A %s %s %d%s", xstring, ystring, cat, HOST_NEWLINE);
 		    }
 		}
 		continue;
@@ -764,15 +764,15 @@
 		}
 	    }
 
-	    fprintf(ascii, "\n");
+	    fprintf(ascii, "%s", HOST_NEWLINE);
 	}
 	else if (format == GV_ASCII_FORMAT_STD) {
 	    /* FORMAT_STANDARD */
 	    if (ver == 5 && Cats->n_cats > 0)
-		fprintf(ascii, "%c  %d %d\n", ctype, Points->n_points,
-			Cats->n_cats);
+		fprintf(ascii, "%c  %d %d%s", ctype, Points->n_points,
+			Cats->n_cats, HOST_NEWLINE);
 	    else
-		fprintf(ascii, "%c  %d\n", ctype, Points->n_points);
+              fprintf(ascii, "%c  %d%s", ctype, Points->n_points, HOST_NEWLINE);
 
 	    xptr = Points->x;
 	    yptr = Points->y;
@@ -789,22 +789,22 @@
 		    if (Map->head.with_z) {
 			G_rasprintf(&zstring, &zsize, "%.*f", dp, *zptr++);
 			G_trim_decimal(zstring);
-			fprintf(ascii, " %-12s %-12s %-12s\n", xstring,
-				ystring, zstring);
+			fprintf(ascii, " %-12s %-12s %-12s%s", xstring,
+				ystring, zstring, HOST_NEWLINE);
 		    }
 		    else {
-			fprintf(ascii, " %-12s %-12s\n", xstring, ystring);
+                      fprintf(ascii, " %-12s %-12s%s", xstring, ystring, HOST_NEWLINE);
 		    }
 		}		/*Version 4 */
 		else {
-		    fprintf(ascii, " %-12s %-12s\n", ystring, xstring);
+                    fprintf(ascii, " %-12s %-12s%s", ystring, xstring, HOST_NEWLINE);
 		}
 	    }
 
 	    if (ver == 5) {
 		for (i = 0; i < Cats->n_cats; i++) {
-		    fprintf(ascii, " %-5d %-10d\n", Cats->field[i],
-			    Cats->cat[i]);
+		    fprintf(ascii, " %-5d %-10d%s", Cats->field[i],
+			    Cats->cat[i], HOST_NEWLINE);
 		}
 	    }
 	    else {
@@ -814,7 +814,7 @@
 			G_trim_decimal(xstring);
 			G_rasprintf(&ystring, &ysize, "%.*f", dp, Points->y[0]);
 			G_trim_decimal(ystring);
-			fprintf(att, "P %s %s %d\n", xstring, ystring, cat);
+			fprintf(att, "P %s %s %d%s", xstring, ystring, cat, HOST_NEWLINE);
 		    }
 		    else {
 			x = (Points->x[1] + Points->x[0]) / 2;
@@ -824,7 +824,7 @@
 			G_trim_decimal(xstring);
 			G_rasprintf(&ystring, &ysize, "%.*f", dp, y);
 			G_trim_decimal(ystring);
-			fprintf(att, "L %s %s %d\n", xstring, ystring, cat);
+			fprintf(att, "L %s %s %d%s", xstring, ystring, cat, HOST_NEWLINE);
 		    }
 		}
 	    }
@@ -879,7 +879,7 @@
 		/* write inner ring */
 		Vect_sfa_line_astext(Points, GV_BOUNDARY, 0, dp, ascii); /* boundary is always 2D */
 	    }
-	    fprintf(ascii, ")\n");
+	    fprintf(ascii, ")%s", HOST_NEWLINE);
 	    
 	    count++;
 	}
@@ -916,15 +916,24 @@
 */
 void Vect_write_ascii_head(FILE *dascii, struct Map_info *Map)
 {
-    fprintf(dascii, "ORGANIZATION: %s\n", Vect_get_organization(Map));
-    fprintf(dascii, "DIGIT DATE:   %s\n", Vect_get_date(Map));
-    fprintf(dascii, "DIGIT NAME:   %s\n", Vect_get_person(Map));
-    fprintf(dascii, "MAP NAME:     %s\n", Vect_get_map_name(Map));
-    fprintf(dascii, "MAP DATE:     %s\n", Vect_get_map_date(Map));
-    fprintf(dascii, "MAP SCALE:    %d\n", Vect_get_scale(Map));
-    fprintf(dascii, "OTHER INFO:   %s\n", Vect_get_comment(Map));
-    fprintf(dascii, "ZONE:         %d\n", Vect_get_zone(Map));
-    fprintf(dascii, "MAP THRESH:   %f\n", Vect_get_thresh(Map));
+    fprintf(dascii, "ORGANIZATION: %s%s",
+            Vect_get_organization(Map), HOST_NEWLINE);
+    fprintf(dascii, "DIGIT DATE:   %s%s",
+            Vect_get_date(Map), HOST_NEWLINE);
+    fprintf(dascii, "DIGIT NAME:   %s%s",
+            Vect_get_person(Map), HOST_NEWLINE);
+    fprintf(dascii, "MAP NAME:     %s%s",
+            Vect_get_map_name(Map), HOST_NEWLINE);
+    fprintf(dascii, "MAP DATE:     %s%s",
+            Vect_get_map_date(Map), HOST_NEWLINE);
+    fprintf(dascii, "MAP SCALE:    %d%s",
+            Vect_get_scale(Map), HOST_NEWLINE);
+    fprintf(dascii, "OTHER INFO:   %s%s",
+            Vect_get_comment(Map), HOST_NEWLINE);
+    fprintf(dascii, "ZONE:         %d%s",
+            Vect_get_zone(Map), HOST_NEWLINE);
+    fprintf(dascii, "MAP THRESH:   %f%s",
+            Vect_get_thresh(Map), HOST_NEWLINE);
 }
 
 /* check category */

Modified: grass/branches/releasebranch_7_0/vector/v.out.ascii/main.c
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.out.ascii/main.c	2015-12-24 15:09:34 UTC (rev 67365)
+++ grass/branches/releasebranch_7_0/vector/v.out.ascii/main.c	2015-12-24 15:11:18 UTC (rev 67366)
@@ -131,7 +131,7 @@
 
     if (format == GV_ASCII_FORMAT_STD) {
 	Vect_write_ascii_head(ascii, &Map);
-	fprintf(ascii, "VERTI:\n");
+	fprintf(ascii, "VERTI:%s", HOST_NEWLINE);
     }
 
     /* Open dig_att */



More information about the grass-commit mailing list