diff --git a/.gitignore b/.gitignore index a632599a..fb7af471 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ tcltk/magic.sh tcltk/magic.tcl tcltk/magicdnull tcltk/magicexec +tcltk/ext2spice.sh +tcltk/ext2sim.sh diff --git a/VERSION b/VERSION index 315e3031..c4817a71 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.2.200 +8.2.201 diff --git a/database/DBio.c b/database/DBio.c index 37c306e6..50d6a662 100644 --- a/database/DBio.c +++ b/database/DBio.c @@ -2709,7 +2709,7 @@ DBCellWrite(cellDef, fileName) #define NAME_SIZE 1000 char *template = ".XXXXXXX"; char *realname, *tmpname, *expandname; - char *cp1, *cp2; + char *cp1, *cp2, *dotptr; char expandbuf[NAME_SIZE]; FILE *realf, *tmpf; int tmpres; @@ -2738,8 +2738,16 @@ DBCellWrite(cellDef, fileName) cellDef->cd_file = StrDup(&cellDef->cd_file, fileName); - realname = (char *) mallocMagic(strlen(fileName) + strlen(DBSuffix) + 1); - (void) sprintf(realname, "%s%s", fileName, DBSuffix); + /* The cd_file should not have the .mag suffix, but make sure */ + /* it doesn't before adding one. */ + + if (strcmp(fileName + strlen(fileName) - 4, DBSuffix)) + { + realname = (char *) mallocMagic(strlen(fileName) + strlen(DBSuffix) + 1); + (void) sprintf(realname, "%s%s", fileName, DBSuffix); + } + else + realname = StrDup((char **)NULL, fileName); /* * Expand the filename, removing the leading ~, if any. @@ -2927,13 +2935,21 @@ DBCellWrite(cellDef, fileName) } } + /* Copy expandname back to cellDef->cd_file, if the name was changed. */ + /* The file extension does not get copied into cd_file. */ + + dotptr = strrchr(expandname, '.'); + if (dotptr) *dotptr = '\0'; + if (strcmp(expandname, cellDef->cd_file)) + StrDup(&cellDef->cd_file, expandname); + if (dotptr) *dotptr = '.'; + /* Everything worked so far. */ - (void) StrDup(&cellDef->cd_file, expandname); result = TRUE; { struct stat thestat; - realf = fopen(expandname,"r"); + realf = fopen(expandname, "r"); if (realf == NULL) { cellDef->cd_flags |= CDMODIFIED; diff --git a/tcltk/Makefile b/tcltk/Makefile index efa12d00..0c200603 100644 --- a/tcltk/Makefile +++ b/tcltk/Makefile @@ -9,7 +9,7 @@ SRCS = tclmagic.c include ${MAGICDIR}/defs.mak DFLAGS += -DMAGIC_DATE="\"`date`\"" -CLEANS += magic.sh magic.tcl magicexec magicdnull +CLEANS += magic.sh magic.tcl magicexec magicdnull ext2spice.sh ext2sim.sh TCL_FILES = \ tkcon.tcl \ diff --git a/tcltk/ext2sim.sh b/tcltk/ext2sim.sh deleted file mode 100644 index 8bd40c31..00000000 --- a/tcltk/ext2sim.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# -# Standalone script for ext2sim, for Tcl-based magic 8.0 -# -# Parse arguments. "--" separates arguments to magic -# from arguments to ext2sim. -# -mgargs="" -esargs="" -for i in $@; do - case $i in - --) mgargs="$esargs" - esargs="" ;; - *) esargs="$esargs $i" ;; - esac -done -# -eval /usr/local/lib/magic/tcl/magicdnull -dnull -noconsole -nowrapper $mgargs < 0} { after $Opts(backupinterval) magic::makecrashbackup }