[GRASS-SVN] r67276 - grass/trunk/imagery/i.cluster

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 20 04:51:44 PST 2015


Author: martinl
Date: 2015-12-20 04:51:44 -0800 (Sun, 20 Dec 2015)
New Revision: 67276

Modified:
   grass/trunk/imagery/i.cluster/main.c
   grass/trunk/imagery/i.cluster/print1.c
   grass/trunk/imagery/i.cluster/print2.c
   grass/trunk/imagery/i.cluster/print3.c
   grass/trunk/imagery/i.cluster/print4.c
   grass/trunk/imagery/i.cluster/print5.c
   grass/trunk/imagery/i.cluster/print6.c
Log:
i.cluster: use cross-platforn newline character for reports

Modified: grass/trunk/imagery/i.cluster/main.c
===================================================================
--- grass/trunk/imagery/i.cluster/main.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/main.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -232,42 +232,42 @@
 
 
     fprintf(report,
-	    _("#################### CLUSTER (%s) ####################\n\n"),
-	    G_date());
-    fprintf(report, _("Location: %s\n"), G_location());
-    fprintf(report, _("Mapset:   %s\n"), G_mapset());
-    fprintf(report, _("Group:    %s\n"), group);
-    fprintf(report, _("Subgroup: %s\n"), subgroup);
+	    _("#################### CLUSTER (%s) ####################%s%s"),
+	    G_date(), HOST_NEWLINE, HOST_NEWLINE);
+    fprintf(report, _("Location: %s%s"), G_location(), HOST_NEWLINE);
+    fprintf(report, _("Mapset:   %s%s"), G_mapset(), HOST_NEWLINE);
+    fprintf(report, _("Group:    %s%s"), group, HOST_NEWLINE);
+    fprintf(report, _("Subgroup: %s%s"), subgroup, HOST_NEWLINE);
     for (n = 0; n < ref.nfiles; n++) {
-	fprintf(report, _(" %s\n"),
-		G_fully_qualified_name(ref.file[n].name, ref.file[n].mapset));
+	fprintf(report, _(" %s%s"),
+		G_fully_qualified_name(ref.file[n].name, ref.file[n].mapset), HOST_NEWLINE);
     }
-    fprintf(report, _("Result signature file: %s\n"), outsigfile);
-    fprintf(report, "\n");
-    fprintf(report, _("Region\n"));
-    fprintf(report, _("  North: %12.2f  East: %12.2f\n"), window.north,
-	    window.east);
-    fprintf(report, _("  South: %12.2f  West: %12.2f\n"), window.south,
-	    window.west);
-    fprintf(report, _("  Res:   %12.2f  Res:  %12.2f\n"), window.ns_res,
-	    window.ew_res);
-    fprintf(report, _("  Rows:  %12d  Cols: %12d  Cells: %d\n"), nrows, ncols,
-	    nrows * ncols);
-    fprintf(report, _("Mask: %s\n"), Rast_mask_info());
-    fprintf(report, "\n");
-    fprintf(report, _("Cluster parameters\n"));
+    fprintf(report, _("Result signature file: %s%s"), outsigfile, HOST_NEWLINE);
+    fprintf(report, "%s", HOST_NEWLINE);
+    fprintf(report, _("Region%s"), HOST_NEWLINE);
+    fprintf(report, _("  North: %12.2f  East: %12.2f%s"), window.north,
+	    window.east, HOST_NEWLINE);
+    fprintf(report, _("  South: %12.2f  West: %12.2f%s"), window.south,
+	    window.west, HOST_NEWLINE);
+    fprintf(report, _("  Res:   %12.2f  Res:  %12.2f%s"), window.ns_res,
+	    window.ew_res, HOST_NEWLINE);
+    fprintf(report, _("  Rows:  %12d  Cols: %12d  Cells: %d%s"), nrows, ncols,
+	    nrows * ncols, HOST_NEWLINE);
+    fprintf(report, _("Mask: %s%s"), Rast_mask_info(), HOST_NEWLINE);
+    fprintf(report, "%s", HOST_NEWLINE);
+    fprintf(report, _("Cluster parameters%s"), HOST_NEWLINE);
     fprintf(report, _(" Number of initial classes:    %d"), maxclass);
     if (insigfile)
 	fprintf(report, _(" [from signature file %s]"), insigfile);
-    fprintf(report, "\n");
-    fprintf(report, _(" Minimum class size:           %d\n"), mcs);
-    fprintf(report, _(" Minimum class separation:     %f\n"), sep);
-    fprintf(report, _(" Percent convergence:          %f\n"), conv);
-    fprintf(report, _(" Maximum number of iterations: %d\n"), iters);
-    fprintf(report, "\n");
-    fprintf(report, _(" Row sampling interval:        %d\n"), sample_rows);
-    fprintf(report, _(" Col sampling interval:        %d\n"), sample_cols);
-    fprintf(report, "\n");
+    fprintf(report, "%s", HOST_NEWLINE);
+    fprintf(report, _(" Minimum class size:           %d%s"), mcs, HOST_NEWLINE);
+    fprintf(report, _(" Minimum class separation:     %f%s"), sep, HOST_NEWLINE);
+    fprintf(report, _(" Percent convergence:          %f%s"), conv, HOST_NEWLINE);
+    fprintf(report, _(" Maximum number of iterations: %d%s"), iters, HOST_NEWLINE);
+    fprintf(report, "%s", HOST_NEWLINE);
+    fprintf(report, _(" Row sampling interval:        %d%s"), sample_rows, HOST_NEWLINE);
+    fprintf(report, _(" Col sampling interval:        %d%s"), sample_cols, HOST_NEWLINE);
+    fprintf(report, "%s", HOST_NEWLINE);
     fflush(report);
 
     x = (DCELL *) G_malloc(ref.nfiles * sizeof(DCELL));
@@ -291,8 +291,8 @@
     }
     G_percent(nrows, nrows, 2);
 
-    fprintf(report, _("Sample size: %d points\n"), C.npoints);
-    fprintf(report, "\n");
+    fprintf(report, _("Sample size: %d points%s"), C.npoints, HOST_NEWLINE);
+    fprintf(report, "%s", HOST_NEWLINE);
     if (count < 2)
 	G_fatal_error(_("Not enough sample points. Please run again and "
 			"choose a larger sample size."));
@@ -311,9 +311,9 @@
     I_cluster_exec(&C, maxclass, iters, conv, sep, mcs, checkpoint,
 		   &interrupted);
 
-    fprintf(report, _("\n########## final results #############\n"));
-    fprintf(report, _("%d classes (convergence=%.1f%%)\n"),
-	    I_cluster_nclasses(&C, mcs), (double)C.percent_stable);
+    fprintf(report, _("%s########## final results #############%s"), HOST_NEWLINE, HOST_NEWLINE);
+    fprintf(report, _("%d classes (convergence=%.1f%%)%s"),
+	    I_cluster_nclasses(&C, mcs), (double)C.percent_stable, HOST_NEWLINE);
     print_separability(report, &C);
     print_class_means(report, &C);
 
@@ -328,10 +328,11 @@
     }
 
     fprintf(report,
-	    _("\n\n#################### CLASSES ####################\n"));
-    fprintf(report, _("\n%d classes, %.2f%% points stable\n"),
-	    I_cluster_nclasses(&C, 1), (double)C.percent_stable);
-    fprintf(report, _("\n######## CLUSTER END (%s) ########\n"), G_date());
+	    _("\n\n#################### CLASSES ####################%s"), HOST_NEWLINE);
+    fprintf(report, _("%s%d classes, %.2f%% points stable%s"),
+	    HOST_NEWLINE, I_cluster_nclasses(&C, 1), (double)C.percent_stable, HOST_NEWLINE);
+    fprintf(report, _("%s######## CLUSTER END (%s) ########%s"),
+	    HOST_NEWLINE, G_date(), HOST_NEWLINE);
     fclose(report);
 
     G_done_msg(_("File <%s> created."),

Modified: grass/trunk/imagery/i.cluster/print1.c
===================================================================
--- grass/trunk/imagery/i.cluster/print1.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/print1.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -8,9 +8,9 @@
 {
     int band;
 
-    fprintf(fd, "\n");
-    fprintf(fd, _("means and standard deviations for %d band%s\n\n"),
-	    C->nbands, C->nbands == 1 ? "" : "s");
+    fprintf(fd, "%s", HOST_NEWLINE);
+    fprintf(fd, _("means and standard deviations for %d band%s%s%s"),
+	    C->nbands, C->nbands == 1 ? "" : "s", HOST_NEWLINE, HOST_NEWLINE);
     fprintf(fd, _(" means  "));
     for (band = 0; band < C->nbands; band++)
 	fprintf(fd, " %g", C->band_sum[band] / C->npoints);
@@ -19,7 +19,7 @@
     for (band = 0; band < C->nbands; band++)
 	fprintf(fd, " %g",
 		I_stddev(C->band_sum[band], C->band_sum2[band], C->npoints));
-    fprintf(fd, "\n\n");
+    fprintf(fd, "%s%s", HOST_NEWLINE, HOST_NEWLINE);
 
     return 0;
 }

Modified: grass/trunk/imagery/i.cluster/print2.c
===================================================================
--- grass/trunk/imagery/i.cluster/print2.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/print2.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -15,11 +15,12 @@
     int c;
     int n;
 
-    fprintf(fd, _("\nclass means/stddev for each band\n\n"));
+    fprintf(fd, _("%sclass means/stddev for each band%s%s"),
+	    HOST_NEWLINE, HOST_NEWLINE, HOST_NEWLINE);
 
     for (c = 0; c < C->nclasses; c++) {
-	fprintf(fd, "\n");
-	fprintf(fd, _("class %d (%d)\n"), c + 1, n = C->count[c]);
+	fprintf(fd, "%s", HOST_NEWLINE);
+	fprintf(fd, _("class %d (%d)%s"), c + 1, n = C->count[c], HOST_NEWLINE);
 	fprintf(fd, _("  means "));
 	if (n > 0)
 	    for (band = 0; band < C->nbands; band++)
@@ -30,9 +31,9 @@
 	    for (band = 0; band < C->nbands; band++)
 		fprintf(fd, " %g",
 			I_stddev(C->sum[band][c], C->sum2[band][c], n));
-	fprintf(fd, "\n");
+	fprintf(fd, "%s", HOST_NEWLINE);
     }
-    fprintf(fd, "\n");
+    fprintf(fd, "%s", HOST_NEWLINE);
 
     return 0;
 }

Modified: grass/trunk/imagery/i.cluster/print3.c
===================================================================
--- grass/trunk/imagery/i.cluster/print3.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/print3.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -13,15 +13,16 @@
     int band;
     int c;
 
-    fprintf(fd, _("\ninitial means for each band\n\n"));
+    fprintf(fd, _("%sinitial means for each band%s%s"),
+	    HOST_NEWLINE, HOST_NEWLINE, HOST_NEWLINE);
 
     for (c = 0; c < C->nclasses; c++) {
 	fprintf(fd, _("class %-3d "), c + 1);
 	for (band = 0; band < C->nbands; band++)
 	    fprintf(fd, " %g", C->mean[band][c]);
-	fprintf(fd, "\n");
+	fprintf(fd, "%s", HOST_NEWLINE);
     }
-    fprintf(fd, "\n");
+    fprintf(fd, "%s", HOST_NEWLINE);
 
     return 0;
 }

Modified: grass/trunk/imagery/i.cluster/print4.c
===================================================================
--- grass/trunk/imagery/i.cluster/print4.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/print4.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -13,7 +13,7 @@
     int band, cat;
     char buf[40];
 
-    fprintf(fd, _("class centroids (sum/count=mean)\n"));
+    fprintf(fd, _("class centroids (sum/count=mean)%s"), HOST_NEWLINE);
     for (band = 0; band < C->nbands; band++) {
 	fprintf(fd, _("band %d"), band + 1);
 	for (cat = 0; cat < C->nclasses; cat++) {
@@ -24,7 +24,7 @@
 		sprintf(buf, FMT2, C->sum[band][cat], C->count[cat]);
 	    fprintf(fd, "%s %-18s", cat % 4 ? "" : "\n", buf);
 	}
-	fprintf(fd, "\n");
+	fprintf(fd, "%s", HOST_NEWLINE);
     }
 
     return 0;

Modified: grass/trunk/imagery/i.cluster/print5.c
===================================================================
--- grass/trunk/imagery/i.cluster/print5.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/print5.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -12,15 +12,16 @@
     double q;
 
     I_cluster_sum2(C);
-    fprintf(fd, _("\nclass separability matrix\n\n"));
+    fprintf(fd, _("%sclass separability matrix%s%s"),
+	    HOST_NEWLINE, HOST_NEWLINE, HOST_NEWLINE);
     for (first = 0; first < C->nclasses; first = last) {
 	last = first + 10;
 	if (last > C->nclasses)
 	    last = C->nclasses;
-	fprintf(fd, "\n    ");
+	fprintf(fd, "%s    ", HOST_NEWLINE);
 	for (c2 = first; c2 < last; c2++)
 	    fprintf(fd, "   %3d", c2 + 1);
-	fprintf(fd, "\n\n");
+	fprintf(fd, "%s%s", HOST_NEWLINE, HOST_NEWLINE);
 	for (c1 = first; c1 < C->nclasses; c1++) {
 	    fprintf(fd, "%3d ", c1 + 1);
 	    for (c2 = first; c2 <= c1 && c2 < last; c2++) {
@@ -32,9 +33,9 @@
 		else
 		    fprintf(fd, "  --- ");
 	    }
-	    fprintf(fd, "\n");
+	    fprintf(fd, "%s", HOST_NEWLINE);
 	}
-	fprintf(fd, "\n");
+	fprintf(fd, "%s", HOST_NEWLINE);
     }
 
     return 0;

Modified: grass/trunk/imagery/i.cluster/print6.c
===================================================================
--- grass/trunk/imagery/i.cluster/print6.c	2015-12-20 12:50:48 UTC (rev 67275)
+++ grass/trunk/imagery/i.cluster/print6.c	2015-12-20 12:51:44 UTC (rev 67276)
@@ -10,9 +10,9 @@
 
     fprintf(fd, _("class distribution"));
     for (cat = 0; cat < C->nclasses; cat++) {
-	fprintf(fd, "%s %10ld", cat % 5 ? "" : "\n", (long)C->count[cat]);
+	fprintf(fd, "%s %10ld", cat % 5 ? "" : HOST_NEWLINE, (long)C->count[cat]);
     }
-    fprintf(fd, "\n");
+    fprintf(fd, "%s", HOST_NEWLINE);
 
     return 0;
 }



More information about the grass-commit mailing list