[GRASS-SVN] r64785 - grass/branches/releasebranch_7_0/raster/r.report

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 3 00:16:04 PST 2015


Author: martinl
Date: 2015-03-03 00:16:04 -0800 (Tue, 03 Mar 2015)
New Revision: 64785

Modified:
   grass/branches/releasebranch_7_0/raster/r.report/header.c
Log:
r.report: fix broken layout (units moved to right)
          (merge r64784 from trunk)


Modified: grass/branches/releasebranch_7_0/raster/r.report/header.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.report/header.c	2015-03-03 08:12:59 UTC (rev 64784)
+++ grass/branches/releasebranch_7_0/raster/r.report/header.c	2015-03-03 08:16:04 UTC (rev 64785)
@@ -166,15 +166,19 @@
 int lcr(const char *left, const char *center, const char *right, char *buf, int n)
 {
     int ll, lc, lr;
+    int sc, sr;
 
     ll = strlen(left);
     lc = strlen(center);
     lr = strlen(right);
 
+    sc = (n - lc) / 2 - ll;
+    sr = n - lr - lc - (n - lc) / 2;
+    
     sprintf(buf, "%s%*s%s%*s%s",
 	    left,
-	    (n - lc) / 2 - ll, "", center,
-	    n - lr - lc - (n - lc) / 2, "", right);
+	    sc > 0 ? sc : 0, "", center,
+	    sc > 0 ? sr : sr + sc , "", right);
 
     return 0;
 }



More information about the grass-commit mailing list