Skip to content

Commit

Permalink
Extended the code from the previous commit to handle automatically
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RTimothyEdwards committed May 5, 2022
1 parent 85d8ad6 commit da49a50
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
7 changes: 5 additions & 2 deletions calma/CalmaRdcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions calma/CalmaRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions calma/CalmaWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions commands/CmdCD.c
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand All @@ -957,7 +957,7 @@ CmdCalma(w, cmd)
dotptr = strrchr(namep, '.');

/* Check for additional ".gz" extension */
if (!strcmp(dotptr, ".gz"))
if (dotptr && !strcmp(dotptr, ".gz"))
{
gzipd = TRUE;
*dotptr = '\0';
Expand Down

0 comments on commit da49a50

Please sign in to comment.