mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-08-28 17:15:13 +02:00
Several changes and updates: (1) Added a new keyword "required" to the
tech file format "version" section. This can be used to specify the version of magic that must be used to be compatible with the tech file. This effectively supercedes the technology version number. (2) Changed the behavior of "make" to set the version and revision numbers on doing "make" instead of "configure". This allows the version to update correctly after doing a "git pull" followed by "make" without doing "configure" in between. (3) Fixed a couple of issues that were flagged as compile-time warnings.
This commit is contained in:
+49
-1
@@ -204,9 +204,57 @@ DBTechSetVersion(sectionName, argc, argv)
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if (strcmp(argv[0], "requires") == 0)
|
||||
{
|
||||
/* Version requirement check. If the techfile has "requires" followed
|
||||
* by a magic version number in the form [magic-]<major>.<minor>.<revision>,
|
||||
* then the version of magic is checked against this, and the tech
|
||||
* loading will fail if there is a version incompatibility.
|
||||
*/
|
||||
|
||||
int major, minor, rev;
|
||||
int rmajor, rminor, rrev;
|
||||
bool goodversion = FALSE;
|
||||
char *vstring;
|
||||
|
||||
vstring = argv[1];
|
||||
while ((*vstring != '\0') && !isdigit(*vstring)) vstring++;
|
||||
|
||||
major = minor = rev = 0;
|
||||
rmajor = rminor = rrev = 0;
|
||||
|
||||
if (sscanf(vstring, "%d.%d.%d", &rmajor, &rminor, &rrev) == 0)
|
||||
{
|
||||
TechError("Badly formed magic version string, should be major.minor.rev\n");
|
||||
return FALSE;
|
||||
}
|
||||
sscanf(MagicVersion, "%d.%d", &major, &minor);
|
||||
sscanf(MagicRevision, "%d", &rev);
|
||||
if (major > rmajor)
|
||||
goodversion = TRUE;
|
||||
else if (major == rmajor)
|
||||
{
|
||||
if (minor > rminor)
|
||||
goodversion = TRUE;
|
||||
else if (minor == rminor)
|
||||
{
|
||||
if (rev >= rrev)
|
||||
goodversion = TRUE;
|
||||
}
|
||||
}
|
||||
if (goodversion == FALSE)
|
||||
{
|
||||
TechError("Error: Magic version %d.%d.%d is required by this "
|
||||
"techfile, but this version of magic is %d.%d.%d.\n",
|
||||
rmajor, rminor, rrev, major, minor, rev);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
usage:
|
||||
TechError("Badly formed version line\nUsage: {version text}|{description text}\n");
|
||||
TechError("Badly formed version line\n"
|
||||
"Usage: {version text}|{description text}|{requires text}\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user