From ba77257afab5392547675de65707fce625ef2324 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 16 Dec 2020 11:49:24 -0500 Subject: [PATCH] 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. --- VERSION | 2 +- commands/CmdLQ.c | 2 +- database/DBtech.c | 50 ++++++++++++++++++++++++++++++++++++++++++- ext2spice/ext2spice.c | 8 ++++--- scripts/configure | 16 -------------- scripts/configure.in | 8 ------- scripts/defs.mak.in | 6 +++--- utils/tech.c | 9 +++++--- 8 files changed, 65 insertions(+), 36 deletions(-) diff --git a/VERSION b/VERSION index 3b9dbc7d..208c2684 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.98 +8.3.99 diff --git a/commands/CmdLQ.c b/commands/CmdLQ.c index 1c68635b..15faffa8 100644 --- a/commands/CmdLQ.c +++ b/commands/CmdLQ.c @@ -1298,7 +1298,7 @@ CmdPort(w, cmd) char **msg; int argstart; int i, refidx, idx, pos, type, option, argc; - unsigned short dirmask; + unsigned int dirmask; bool found; bool nonEdit = FALSE; Label *lab, *sl; diff --git a/database/DBtech.c b/database/DBtech.c index 430ccf93..19ccded6 100644 --- a/database/DBtech.c +++ b/database/DBtech.c @@ -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-].., + * 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; } diff --git a/ext2spice/ext2spice.c b/ext2spice/ext2spice.c index a1ee2585..9d41656a 100644 --- a/ext2spice/ext2spice.c +++ b/ext2spice/ext2spice.c @@ -1722,7 +1722,8 @@ topVisit(def, doStub) basenode->efnode_name->efnn_port = portorder++; } snode->efnode_name->efnn_port = basenode->efnode_name->efnn_port; - HashSetValue(hep, (ClientData)snode->efnode_name->efnn_port); + HashSetValue(hep, + (ClientData)(pointertype)snode->efnode_name->efnn_port); } } } @@ -1774,7 +1775,8 @@ topVisit(def, doStub) if (HashLookOnly(&portNameTable, pname) == NULL) { hep = HashFind(&portNameTable, pname); - HashSetValue(hep, (ClientData)nodeName->efnn_port); + HashSetValue(hep, + (ClientData)(pointertype)nodeName->efnn_port); fprintf(esSpiceF, " %s", pname); tchars += strlen(pname) + 1; } @@ -1785,7 +1787,7 @@ topVisit(def, doStub) // port number is set correctly. hep = HashFind(&portNameTable, pname); - nodeName->efnn_port = (int)HashGetValue(hep); + nodeName->efnn_port = (int)(pointertype)HashGetValue(hep); } break; } diff --git a/scripts/configure b/scripts/configure index a2d9cb28..5b4fc516 100755 --- a/scripts/configure +++ b/scripts/configure @@ -626,8 +626,6 @@ INSTALL_TARGET ALL_TARGET OA_LIBS OA -MAGIC_REVISION -MAGIC_VERSION MSED MCPP LD_RUN_PATH @@ -2597,17 +2595,6 @@ test -n "$target_alias" && PACKAGE=magic -MAGIC_VERSION=`cat ../VERSION | cut -d. -f1-2` -MAGIC_REVISION=`cat ../VERSION | cut -d. -f3` -cat >>confdefs.h <<_ACEOF -#define MAGIC_VERSION "${MAGIC_VERSION}" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define MAGIC_REVISION "${MAGIC_REVISION}" -_ACEOF - - ALL_TARGET="standard" INSTALL_TARGET="install-magic" @@ -8227,9 +8214,6 @@ fi - - - diff --git a/scripts/configure.in b/scripts/configure.in index 8a00ba27..27a64c71 100644 --- a/scripts/configure.in +++ b/scripts/configure.in @@ -11,11 +11,6 @@ AC_CANONICAL_SYSTEM dnl pass the version string on the the makefiles PACKAGE=magic -MAGIC_VERSION=`cat ../VERSION | cut -d. -f1-2` -MAGIC_REVISION=`cat ../VERSION | cut -d. -f3` -AC_DEFINE_UNQUOTED(MAGIC_VERSION, "${MAGIC_VERSION}") -AC_DEFINE_UNQUOTED(MAGIC_REVISION, "${MAGIC_REVISION}") - dnl Override default target when compiling under TCL ALL_TARGET="standard" INSTALL_TARGET="install-magic" @@ -1800,9 +1795,6 @@ AC_SUBST(LD_RUN_PATH) AC_SUBST(MCPP) AC_SUBST(MSED) -AC_SUBST(MAGIC_VERSION) -AC_SUBST(MAGIC_REVISION) - AC_SUBST(OA) AC_SUBST(OA_LIBS) diff --git a/scripts/defs.mak.in b/scripts/defs.mak.in index 45d65f53..77dfddca 100755 --- a/scripts/defs.mak.in +++ b/scripts/defs.mak.in @@ -68,15 +68,15 @@ LIB_SPECS = @LIB_SPECS@ LIB_SPECS_NOSTUB = @LIB_SPECS_NOSTUB@ WISH_EXE = @WISH_EXE@ TCL_LIB_DIR = @TCL_LIB_DIR@ -MAGIC_VERSION = @MAGIC_VERSION@ -MAGIC_REVISION = @MAGIC_REVISION@ +MAGIC_VERSION = `cat ../VERSION | cut -d. -f1-2` +MAGIC_REVISION = `cat ../VERSION | cut -d. -f3` CC = @CC@ CPP = @CPP@ CXX = @CXX@ CPPFLAGS = -I. -I${MAGICDIR} @CPPFLAGS@ -DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ -DGCORE=\"@GCORE@\" +DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ -DMAGIC_VERSION=\"${MAGIC_VERSION}\" -DMAGIC_REVISION=\"${MAGIC_REVISION}\" -DGCORE=\"@GCORE@\" DFLAGS += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" -DNDEBUG DFLAGS_NOSTUB = @extra_defs@ @DEFS@ -DGCORE=\"@GCORE@\" DFLAGS_NOSTUB += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" -DNDEBUG diff --git a/utils/tech.c b/utils/tech.c index e64caacf..6b58cd51 100644 --- a/utils/tech.c +++ b/utils/tech.c @@ -272,9 +272,12 @@ changePlanesFunc(cellDef, arg) /* Old planes to be subtracted */ for (pNum = DBNumPlanes; pNum < oldnumplanes; pNum++) { - DBFreePaintPlane(cellDef->cd_planes[pNum]); - TiFreePlane(cellDef->cd_planes[pNum]); - cellDef->cd_planes[pNum] = (Plane *) NULL; + if (cellDef->cd_planes[pNum] != NULL) + { + DBFreePaintPlane(cellDef->cd_planes[pNum]); + TiFreePlane(cellDef->cd_planes[pNum]); + cellDef->cd_planes[pNum] = (Plane *) NULL; + } } } return 0;