Apparently GDS format does not enforce the original string character

limit of the Calma definition, and probably has not done so for ages.
Nobody informed me of this.  The restriction has been lifted from
GDS input and output in Magic.  It can be reinstated if necessary by
setting a flag in the cifoutput section of the techfile, but it is
likely that this will not be necessary unless there are other tools
that enforce the limit and will not read a GDS file that exceeds it.
This commit is contained in:
Tim Edwards 2019-12-19 17:28:06 -05:00
parent f15ea2a135
commit 67866c7991
4 changed files with 27 additions and 8 deletions

View File

@ -282,7 +282,7 @@ calmaParseStructure(filename)
{
static int structs[] = { CALMA_STRCLASS, CALMA_STRTYPE, -1 };
int nbytes, rtype, nsrefs, osrefs, npaths;
char *strname = NULL, newname[CALMANAMELENGTH*2];
char *strname = NULL;
HashEntry *he;
int suffix;
int mfactor;
@ -327,15 +327,21 @@ calmaParseStructure(filename)
}
else
{
char *newname;
CalmaReadError("Cell \"%s\" was already defined in this file.\n",
strname);
newname = (char *)mallocMagic(strlen(strname) + 20);
for (suffix = 1; HashGetValue(he) != NULL; suffix++)
{
(void) sprintf(newname, "%s_%d", strname, suffix);
he = HashFind(&calmaDefInitHash, newname);
}
CalmaReadError("Giving this cell a new name: %s\n", newname);
strncpy(strname, newname, CALMANAMELENGTH*2);
freeMagic(strname);
strname = mallocMagic(strlen(newname) + 1);
strcpy(strname, newname);
freeMagic(newname);
}
}
cifReadCellDef = calmaFindCell(strname, &was_called);

View File

@ -372,7 +372,7 @@ calmaDumpStructure(def, outf, calmaDefHash, filename)
char *filename;
{
int nbytes, rtype;
char *strname = NULL, *newnameptr, newname[CALMANAMELENGTH*2];
char *strname = NULL, *newnameptr;
HashEntry *he, *he2;
CellDef *edef;
char *prefix = NULL;
@ -1316,7 +1316,7 @@ calmaOutStructName(type, def, f)
CellDef *def;
FILE *f;
{
char defname[CALMANAMELENGTH+1];
char *defname;
unsigned char c;
char *cp;
int calmanum;
@ -1341,10 +1341,11 @@ calmaOutStructName(type, def, f)
}
/* We really should ensure that the new name is unique. . . */
}
if (cp <= def->cd_name + CALMANAMELENGTH)
if ((!(CIFCurStyle->cs_flags & CWF_STRING_LIMIT)) ||
(cp <= def->cd_name + CALMANAMELENGTH))
{
/* Yes, it's legal: use it */
(void) strcpy(defname, def->cd_name);
defname = StrDup(NULL, def->cd_name);
}
else
{
@ -1352,12 +1353,14 @@ calmaOutStructName(type, def, f)
bad:
calmanum = (int) def->cd_client;
if (calmanum < 0) calmanum = -calmanum;
defname = (char *)mallocMagic(32);
(void) sprintf(defname, "XXXXX%d", calmanum);
TxError("Warning: string in output unprintable; changed to \'%s\'\n",
defname);
}
calmaOutStringRecord(type, defname, f);
freeMagic(defname);
}
/* Added by NP 8/21/2004 */
@ -2734,7 +2737,7 @@ calmaOutDate(t, f)
void
calmaOutStringRecord(type, str, f)
int type; /* Type of this record (data type is ASCII string) */
char *str; /* String to be output (<= CALMANAMELENGTH chars) */
char *str; /* String to be output */
FILE *f; /* Stream file */
{
int len;
@ -2759,9 +2762,16 @@ calmaOutStringRecord(type, str, f)
* last CALMANAMELENGTH characters (since cell names are more
* likely to be unique in the last characters than in the first
* characters).
*
* NOTE: GDS format has not used CALMANAMELENGTH restrictions
* for ages. Since this is a 2-byte record, then is it not
* worth checking the 65536 - 4 character limit. The CALMANAMELENGTH
* restriction must be enabled in the cifoutput flags.
*/
if (len & 01) len++;
if (len > CALMANAMELENGTH)
if ((CIFCurStyle->cs_flags & CWF_STRING_LIMIT) && (len > CALMANAMELENGTH))
{
TxError("Warning: Cellname %s truncated ", str);
TxError("to %s (GDS format limit)\n", str + len - CALMANAMELENGTH);

View File

@ -297,6 +297,7 @@ typedef struct cifstyle
#define CWF_GROW_EUCLIDEAN 0x08
#define CWF_SEE_VENDOR 0x10 /* Override vendor GDS flag in cells */
#define CWF_NO_ERRORS 0x20 /* Do not generate error msgs and fdbk */
#define CWF_STRING_LIMIT 0x40 /* Use older Calma format character limit */
/* procedures */

View File

@ -994,6 +994,8 @@ CIFTechLine(sectionName, argc, argv)
CIFCurStyle->cs_flags |= CWF_SEE_VENDOR;
else if (strcmp(argv[i], "no-errors") == 0)
CIFCurStyle->cs_flags |= CWF_NO_ERRORS;
else if (strcmp(argv[i], "string-limit") == 0)
CIFCurStyle->cs_flags |= CWF_STRING_LIMIT;
}
return TRUE;
}