Extended the code from the previous commit to handle automatically

pointing GDS_FILE to a compressed filename when using "gds readonly
true" on a compressed file.  The start and end pointers still point
to data bounds in the uncompressed file.
This commit is contained in:
Tim Edwards 2022-05-05 18:04:41 -04:00
parent 85d8ad6622
commit da49a50d8e
4 changed files with 14 additions and 8 deletions

View File

@ -294,8 +294,11 @@ calmaExact()
*/
bool
calmaParseStructure(filename)
calmaParseStructure(filename, origname)
char *filename; /* Name of the GDS file read */
char *origname; /* Original name of the GDS file
* (used with compressed files)
*/
{
static int structs[] = { CALMA_STRCLASS, CALMA_STRTYPE, -1 };
int nbytes, rtype, nsrefs, osrefs, npaths;
@ -446,7 +449,7 @@ calmaParseStructure(filename)
/* Substitute variable for PDK path or ~ for home directory */
/* the same way that cell references are handled in .mag files. */
DBPathSubstitute(filename, cstring, cifReadCellDef);
DBPathSubstitute(origname, cstring, cifReadCellDef);
fncopy = StrDup(NULL, cstring);
sprintf(fpcopy, "%"DLONG_PREFIX"d", (dlong) filepos);
DBPropPut(cifReadCellDef, "GDS_START", (ClientData)fpcopy);

View File

@ -152,9 +152,12 @@ int calmaElementIgnore[] = { CALMA_ELFLAGS, CALMA_PLEX, -1 };
*/
void
CalmaReadFile(file, filename)
CalmaReadFile(file, filename, origname)
FILE *file; /* File from which to read Calma */
char *filename; /* The real name of the file read */
char *origname; /* Original name of file read (used for
* compressed files)
*/
{
int k, version;
char *libname = NULL;
@ -234,7 +237,7 @@ CalmaReadFile(file, filename)
if (!calmaParseUnits()) goto done;
/* Main body of GDS-II input */
while (calmaParseStructure(filename))
while (calmaParseStructure(filename, origname))
if (SigInterruptPending)
goto done;
(void) calmaSkipExact(CALMA_ENDLIB);

View File

@ -953,7 +953,7 @@ calmaProcessDef(def, outf, do_library)
namelen = strlen(filename);
if ((namelen > 4) && !strcmp(filename + namelen - 3, ".gz"))
{
char *sysCmd, sptr;
char *sysCmd, *sptr;
sptr = strrchr(filename, '/');
if (sptr == NULL)
@ -965,7 +965,7 @@ calmaProcessDef(def, outf, do_library)
*(modName + strlen(modName) - 3) = '\0';
sysCmd = mallocMagic(18 + namelen + strlen(modName));
sprinf(sysCmd, "gunzip -c -k %s > %s", filename, modName);
sprintf(sysCmd, "gunzip -c -k %s > %s", filename, modName);
if (system(sysCmd) != 0)
{
/* File didn't uncompress. Go back to original name,

View File

@ -931,7 +931,7 @@ CmdCalma(w, cmd)
cmd->tx_argv[2], cmd->tx_argv[2], cmd->tx_argv[2]);
return;
}
CalmaReadFile(f, namep);
CalmaReadFile(f, namep, cmd->tx_argv[2]);
(void) fclose(f);
if (modName != cmd->tx_argv[2])
{
@ -957,7 +957,7 @@ outputCalma:
dotptr = strrchr(namep, '.');
/* Check for additional ".gz" extension */
if (!strcmp(dotptr, ".gz"))
if (dotptr && !strcmp(dotptr, ".gz"))
{
gzipd = TRUE;
*dotptr = '\0';