When trying to describe this patch the words 'crazy' and 'wacko' come to mind, but believe it or not, this actually works _and_ it seems to be the only way to make --version use the svn revision correctly.
The current --version output only changes when superiotool.h is updated,
which is not very useful, of course. This patch fixes it, in that all
changes to *.c or *.h files bump the version number.
Note: You will not be able to easily test this before the commit. You'll
get a segfault, as the $Rev$ instances will not be replaced until
_after_ the commit. If you want you can manually change '$Rev$' to
'$Rev: 2555 $' or so in all files (for testing)...
Uwe.
--
http://www.hermann-uwe.de | http://www.holsham-traders.de
http://www.crazy-hacks.org | http://www.unmaintained-free-software.org
As the svn keyword $Rev$ is not replaced with the global repository ID
but rather with the ID of the last commit which changed the
respective file (where $Rev$ is located), the current --version output
is incorrect.
This patch fixes the output by keeping a $Rev$ instance in every file
(which can be different for every file) and then calculating the
biggest revision (which is our superiotool version) at runtime when
superiotool is invoked with --version.
This only takes *.c and *.h files into account, changes to the README
and other non-code files will no be reflected in the version number.
But this is actually a good thing in this case, we don't want to bump
the version number upon README changes anyway.
Signed-off-by: Uwe Hermann <[EMAIL PROTECTED]>
Index: fintek.c
===================================================================
--- fintek.c (Revision 2826)
+++ fintek.c (Arbeitskopie)
@@ -21,6 +21,8 @@
#include "superiotool.h"
+const char svnrev_fintek_c[] = "$Rev$";
+
#define DEVICE_ID_BYTE1_REG 0x20
#define DEVICE_ID_BYTE2_REG 0x21
Eigenschaftsänderungen: fintek.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: winbond.c
===================================================================
--- winbond.c (Revision 2826)
+++ winbond.c (Arbeitskopie)
@@ -20,6 +20,8 @@
#include "superiotool.h"
+const char svnrev_winbond_c[] = "$Rev$";
+
#define DEVICE_ID_REG_OLD 0x09
#define DEVICE_ID_REG 0x20
Eigenschaftsänderungen: winbond.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: ite.c
===================================================================
--- ite.c (Revision 2826)
+++ ite.c (Arbeitskopie)
@@ -21,6 +21,8 @@
#include "superiotool.h"
+const char svnrev_ite_c[] = "$Rev$";
+
#define CHIP_ID_BYTE1_REG 0x20
#define CHIP_ID_BYTE2_REG 0x21
Eigenschaftsänderungen: ite.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: nsc.c
===================================================================
--- nsc.c (Revision 2826)
+++ nsc.c (Arbeitskopie)
@@ -21,6 +21,8 @@
#include "superiotool.h"
+const char svnrev_nsc_c[] = "$Rev$";
+
#define CHIP_ID_REG 0x20 /* Super I/O ID (SID) / family */
#define CHIP_REV_REG 0x27 /* Super I/O revision ID (SRID) */
Eigenschaftsänderungen: nsc.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: superiotool.c
===================================================================
--- superiotool.c (Revision 2826)
+++ superiotool.c (Arbeitskopie)
@@ -22,6 +22,26 @@
#include "superiotool.h"
+static const char svnrev_superiotool_c[] = "$Rev$";
+
+extern const char svnrev_ali_c[];
+extern const char svnrev_fintek_c[];
+extern const char svnrev_ite_c[];
+extern const char svnrev_nsc_c[];
+extern const char svnrev_smsc_c[];
+extern const char svnrev_winbond_c[];
+
+static const char *svnrev_table[] = {
+ svnrev_ali_c,
+ svnrev_fintek_c,
+ svnrev_ite_c,
+ svnrev_nsc_c,
+ svnrev_smsc_c,
+ svnrev_superiotool_c,
+ SVNREV_SUPERIOTOOL_H, /* Must be a macro! */
+ svnrev_winbond_c,
+};
+
/* Command line options. */
int dump = 0, dump_readable = 0, verbose = 0;
@@ -168,11 +188,19 @@
static void print_version(void)
{
char tmp[80];
+ long int i, svnrev, greatest = 0;
- strncpy((char *)&tmp,
- (const char *)&SUPERIOTOOL_VERSION[6],
- strlen(SUPERIOTOOL_VERSION) - 8);
- printf("superiotool r%s\n", (char *)&tmp);
+ for (i = 0; i < ARRAY_SIZE(svnrev_table); i++) {
+ strncpy((char *)&tmp, (const char *)&svnrev_table[i][6],
+ strlen(svnrev_table[i]) - 8);
+
+ svnrev = strtol((const char *)&tmp, NULL, 10);
+
+ if (svnrev > greatest)
+ greatest = svnrev;
+ }
+
+ printf("superiotool r%ld\n", greatest);
}
int main(int argc, char *argv[])
Eigenschaftsänderungen: superiotool.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: smsc.c
===================================================================
--- smsc.c (Revision 2826)
+++ smsc.c (Arbeitskopie)
@@ -20,6 +20,8 @@
#include "superiotool.h"
+const char svnrev_smsc_c[] = "$Rev$";
+
#define DEVICE_ID_REG_OLD 0x0d
#define DEVICE_REV_REG_OLD 0x0e
Eigenschaftsänderungen: smsc.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: ali.c
===================================================================
--- ali.c (Revision 2826)
+++ ali.c (Arbeitskopie)
@@ -20,6 +20,8 @@
#include "superiotool.h"
+const char svnrev_ali_c[] = "$Rev$";
+
#define DEVICE_ID_BYTE1_REG 0x20
#define DEVICE_ID_BYTE2_REG 0x21
Eigenschaftsänderungen: ali.c
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Rev URL
Index: superiotool.h
===================================================================
--- superiotool.h (Revision 2826)
+++ superiotool.h (Arbeitskopie)
@@ -29,7 +29,7 @@
#include <getopt.h>
#include <sys/io.h>
-#define SUPERIOTOOL_VERSION "$Rev$"
+#define SVNREV_SUPERIOTOOL_H "$Rev$"
#define USAGE "Usage: superiotool [-d] [-D] [-V] [-v] [-h]\n\n\
-d | --dump Dump Super I/O registers\n\
signature.asc
Description: Digital signature
-- linuxbios mailing list [email protected] http://www.linuxbios.org/mailman/listinfo/linuxbios
