[GRASS-SVN] r55272 - grass/trunk/general/g.version
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 1 07:42:17 PST 2013
Author: martinl
Date: 2013-03-01 07:42:16 -0800 (Fri, 01 Mar 2013)
New Revision: 55272
Removed:
grass/trunk/general/g.version/date.c
Modified:
grass/trunk/general/g.version/local_proto.h
grass/trunk/general/g.version/main.c
Log:
g.version: simplify build date formatting
Deleted: grass/trunk/general/g.version/date.c
===================================================================
--- grass/trunk/general/g.version/date.c 2013-03-01 14:16:53 UTC (rev 55271)
+++ grass/trunk/general/g.version/date.c 2013-03-01 15:42:16 UTC (rev 55272)
@@ -1,40 +0,0 @@
-#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], day[3];
-
- if (MONTH < 9)
- sprintf(month, "0%d", MONTH + 1);
- else
- sprintf(month, "%d", MONTH + 1);
-
- if (DAY < 10)
- sprintf(day, "0%d", DAY);
- else
- sprintf(day, "%d", DAY);
-
- G_asprintf(&date, "%d-%s-%s", YEAR, month, day);
-
- return date;
-}
Modified: grass/trunk/general/g.version/local_proto.h
===================================================================
--- grass/trunk/general/g.version/local_proto.h 2013-03-01 14:16:53 UTC (rev 55271)
+++ grass/trunk/general/g.version/local_proto.h 2013-03-01 15:42:16 UTC (rev 55272)
@@ -1,7 +1,21 @@
#ifndef __LOCAL_PROTO__
#define __LOCAL_PROTO__
-/* date.c */
-const char *get_date();
+/* 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'))
+
#endif
Modified: grass/trunk/general/g.version/main.c
===================================================================
--- grass/trunk/general/g.version/main.c 2013-03-01 14:16:53 UTC (rev 55271)
+++ grass/trunk/general/g.version/main.c 2013-03-01 15:42:16 UTC (rev 55272)
@@ -96,7 +96,7 @@
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, "build_date=%s\n", get_date());
+ fprintf(stdout, "build_date=%d-%02d-%02d\n", YEAR, MONTH, DAY);
}
else {
fprintf(stdout, "GRASS %s (%s)\n",
More information about the grass-commit
mailing list