gnupic: Re: [gnupic] Adding a DATE macro to gpsim
Subject:
Re: [gnupic] Adding a DATE macro to gpsim
From:
Peter Onion ####@####.####
Date:
20 Apr 2005 09:58:32 +0100
Message-Id: <1113987481.27678.8.camel@ratbert.alien.bt.co.uk>
It is interesting to see several approaches to this seemingly trivial
problem.
As you no doubt detected I'm against any solution that require command
line options to be specified. Now I have a working patch I don't have
to worry about it (other than to apply the patch the next time I update
gputils). The "DATE" symbol is now available to any PIC code I write
without having to remember how to do it.
As for shell script wrappers.... :-(
Note I'm NOT an American, so the date format is dd/mm/yy ;-)
Peter
--- gpasm.c 2005-01-03 22:21:19.000000000 +0000
+++ /opt/gputils-0.13.1/gpasm/gpasm.c 2005-04-20 09:54:53.723925647
+0100
@@ -30,6 +30,8 @@
#include "cod.h"
#include "processor.h"
#include "coff.h"
+#include <time.h>
+#include <sys/time.h>
struct gpasm_state state;
@@ -208,7 +210,22 @@
/* initalize the defines table for command line arguments */
state.stDefines = push_symbol_table(NULL, state.case_insensitive);
-
+
+ /* Define a symbol with the current date as a string */
+ {
+ struct symbol *sym;
+ struct tm *tm;
+ static char date[100];
+ time_t t;
+
+ time(&t);
+ tm = localtime(&t);
+ strftime(date,100,"\"%d/%b/%y\"",tm);
+
+ sym = add_symbol(state.stDefines, "DATE");
+ annotate_symbol(sym, date);
+
+ }
while ((c = getopt_long(argc, argv, GET_OPTIONS, longopts, 0)) !=EOF)
{
switch (c) {
case '?':