[GRASS-SVN] r68748 - grass/trunk/raster/r.info

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 22 19:45:53 PDT 2016


Author: wenzeslaus
Date: 2016-06-22 19:45:53 -0700 (Wed, 22 Jun 2016)
New Revision: 68748

Modified:
   grass/trunk/raster/r.info/main.c
Log:
r.info: make category title the primary, use hist as fallback (see #3035)

This also makes the line shorter, so it more often fits
into the character limit and it does not contain the
stange parentheses (with spaces around them)
which were hard to interpret.

Follows r68746 and r68747.


Modified: grass/trunk/raster/r.info/main.c
===================================================================
--- grass/trunk/raster/r.info/main.c	2016-06-23 02:17:49 UTC (rev 68747)
+++ grass/trunk/raster/r.info/main.c	2016-06-23 02:45:53 UTC (rev 68748)
@@ -40,6 +40,7 @@
 int main(int argc, char **argv)
 {
     const char *name, *mapset;
+    const char *title;
     char tmp1[100], tmp2[100], tmp3[100];
     char timebuff[256];
     char *units, *vdatum;
@@ -132,15 +133,26 @@
 	!eflag->answer && !hflag->answer) {
 	divider('+');
 
+    /* empty title by default */
+    title = "";
+    /* use title from category file as the primary (and only) title */
+    if (cats_ok)
+        title = cats.title;
+    /* only use hist file title if there is none in the category file */
+    if ((!title || title[0] == '\0') && hist_ok) {
+        title = Rast_get_history(&hist, HIST_TITLE);
+        /* if the title is the same as name of the map, don't use it */
+        if (strcmp(title, name) == 0)
+            title = "";
+    }
+
 	compose_line(out, "Map:      %-29.29s  Date: %s", name,
 		     hist_ok ? Rast_get_history(&hist, HIST_MAPID) : "??");
 	compose_line(out, "Mapset:   %-29.29s  Login of Creator: %s",
 		     mapset, hist_ok ? Rast_get_history(&hist, HIST_CREATOR) : "??");
 	compose_line(out, "Location: %s", G_location());
 	compose_line(out, "DataBase: %s", G_gisdbase());
-	compose_line(out, "Title:    %s ( %s )",
-		     cats_ok ? cats.title : "??",
-		     hist_ok ? Rast_get_history(&hist, HIST_TITLE) : "??");
+	compose_line(out, "Title:    %s", title);
 
 	/* This shows the TimeStamp */
 	if (time_ok && (first_time_ok || second_time_ok)) {



More information about the grass-commit mailing list