diff --git a/calma/CalmaRdcl.c b/calma/CalmaRdcl.c index a64e0aeb..9753227a 100644 --- a/calma/CalmaRdcl.c +++ b/calma/CalmaRdcl.c @@ -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); diff --git a/calma/CalmaRead.c b/calma/CalmaRead.c index c9b300d2..2e65eb75 100644 --- a/calma/CalmaRead.c +++ b/calma/CalmaRead.c @@ -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); diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index d06325ee..c1e49a01 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -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, diff --git a/commands/CmdCD.c b/commands/CmdCD.c index 44189c47..9a9bb8eb 100644 --- a/commands/CmdCD.c +++ b/commands/CmdCD.c @@ -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';