[GRASS-SVN] r54817 - grass/trunk/general/g.version

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 30 06:47:13 PST 2013


Author: martinl
Date: 2013-01-30 06:47:13 -0800 (Wed, 30 Jan 2013)
New Revision: 54817

Added:
   grass/trunk/general/g.version/date.c
   grass/trunk/general/g.version/local_proto.h
Modified:
   grass/trunk/general/g.version/main.c
Log:
g.version: print also build date in shell script style


Added: grass/trunk/general/g.version/date.c
===================================================================
--- grass/trunk/general/g.version/date.c	                        (rev 0)
+++ grass/trunk/general/g.version/date.c	2013-01-30 14:47:13 UTC (rev 54817)
@@ -0,0 +1,35 @@
+#include <stdlib.h>
+#include <grass/gis.h>
+
+/* formatting macros for compilation date */
+#define YEAR ((((__DATE__ [7]-'0')*10+(__DATE__[8]-'0'))*10+\
+	       (__DATE__ [9]-'0'))*10+(__DATE__ [10]-'0'))
+
+/* month: 0 - 11 */
+#define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 0 : 5) \
+              : __DATE__ [2] == 'b' ? 1 \
+              : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 2 : 3) \
+              : __DATE__ [2] == 'y' ? 4 \
+              : __DATE__ [2] == 'l' ? 6 \
+              : __DATE__ [2] == 'g' ? 7 \
+              : __DATE__ [2] == 'p' ? 8 \
+              : __DATE__ [2] == 't' ? 9 \
+              : __DATE__ [2] == 'v' ? 10 : 11)
+
+#define DAY ((__DATE__ [4]==' ' ? 0 : __DATE__[4]-'0')*10+(__DATE__[5]-'0'))
+
+/* get compilation date as a string */
+const char *get_date()
+{
+    char *date = NULL;
+    char month[3];
+    
+    if (MONTH < 9)
+	sprintf(month, "0%d", MONTH + 1);
+    else
+	sprintf(month, "%d", MONTH + 1);
+    
+    G_asprintf(&date, "%d-%s-%d", YEAR, month, DAY);
+    
+    return date;
+}


Property changes on: grass/trunk/general/g.version/date.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/trunk/general/g.version/local_proto.h
===================================================================
--- grass/trunk/general/g.version/local_proto.h	                        (rev 0)
+++ grass/trunk/general/g.version/local_proto.h	2013-01-30 14:47:13 UTC (rev 54817)
@@ -0,0 +1,7 @@
+#ifndef __LOCAL_PROTO__
+#define __LOCAL_PROTO__
+
+/* date.c */
+const char *get_date();
+
+#endif


Property changes on: grass/trunk/general/g.version/local_proto.h
___________________________________________________________________
Added: svn:mime-type
   + text/x-chdr
Added: svn:eol-style
   + native

Modified: grass/trunk/general/g.version/main.c
===================================================================
--- grass/trunk/general/g.version/main.c	2013-01-30 14:10:36 UTC (rev 54816)
+++ grass/trunk/general/g.version/main.c	2013-01-30 14:47:13 UTC (rev 54817)
@@ -8,7 +8,7 @@
 *               Extended info by Martin Landa <landa.martin gmail.com>
 * PURPOSE: 	Output GRASS version number, date and copyright message.
 *             
-* COPYRIGHT:  	(C) 2000-2012 by the GRASS Development Team
+* COPYRIGHT:  	(C) 2000-2013 by the GRASS Development Team
 *
 *   	    	This program is free software under the GPL (>=v2)
 *   	    	Read the file COPYING that comes with GRASS for details.
@@ -21,6 +21,8 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
+#include "local_proto.h"
+
 #include <proj_api.h>
 
 #ifdef HAVE_GDAL
@@ -56,8 +58,9 @@
 
     module = G_define_module();
     G_add_keyword(_("general"));
-    G_add_keyword(_("version"));
-    module->description = _("Displays GRASS version and copyright information.");
+    G_add_keyword(_("supporting"));
+    module->label = _("Displays GRASS version info.");
+    module->description = _("Optionally also print build or copyright information.");
 
     copyright = G_define_flag();
     copyright->key = 'c';
@@ -66,13 +69,13 @@
 
     build = G_define_flag();
     build->key = 'b';
-    build->description = _("Print also the GRASS build information");
+    build->description = _("Print also the build information");
     build->guisection = _("Additional info");
 
     gish_rev = G_define_flag();
     gish_rev->key = 'r';
     gish_rev->description =
-	_("Print also the GIS library revision number and time");
+	_("Print also the GIS library revision number and date");
     gish_rev->guisection = _("Additional info");
 
     extended = G_define_flag();
@@ -91,8 +94,9 @@
 
     if (shell->answer) {
 	fprintf(stdout, "version=%s\n", GRASS_VERSION_NUMBER);
+	fprintf(stdout, "date=%s\n", GRASS_VERSION_DATE);
 	fprintf(stdout, "revision=%s\n", GRASS_VERSION_SVN);
-	fprintf(stdout, "date=%s\n", GRASS_VERSION_DATE);
+	fprintf(stdout, "build_date=%s\n", get_date());
     }
     else {
 	fprintf(stdout, "GRASS %s (%s)\n",



More information about the grass-commit mailing list