From 7ec87864a6494149d0772c718b1f782e831f4646 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 23 Mar 2020 10:19:34 -0400 Subject: [PATCH 1/2] Corrected the "save" ("writeall") command, which after the fixes of the last couple of days, was left in a state where it keeps appending ".mag" to the filename if "save" or "writeall" is executed more than once in the same edit session. Also, added ext2sim.sh and ext2spice.sh to the CLEANS list in tcltk, and added both to .gitignore so they are not tracked. Removed them from git to stop the current tracking. --- .gitignore | 2 ++ VERSION | 2 +- database/DBio.c | 26 +++++++++++++++++++++----- tcltk/Makefile | 2 +- tcltk/ext2sim.sh | 23 ----------------------- tcltk/ext2spice.sh | 23 ----------------------- 6 files changed, 25 insertions(+), 53 deletions(-) delete mode 100644 tcltk/ext2sim.sh delete mode 100644 tcltk/ext2spice.sh 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 < Date: Mon, 23 Mar 2020 11:52:31 -0400 Subject: [PATCH 2/2] Found that the "crash save" command in tools.tcl also disrupts redirected command-line entry from the layout window; fixed. --- tcltk/tools.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcltk/tools.tcl b/tcltk/tools.tcl index b127292e..c72ee067 100644 --- a/tcltk/tools.tcl +++ b/tcltk/tools.tcl @@ -55,7 +55,7 @@ proc magic::resumeall {} { proc magic::makecrashbackup {} { global Opts - crash save + *bypass crash save if {$Opts(backupinterval) > 0} { after $Opts(backupinterval) magic::makecrashbackup }