From ae6b627df725259c01a6a4cce8f5d38d9a2d4ad7 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Sat, 21 Mar 2020 15:34:41 -0400 Subject: [PATCH] One more change to add back the .mag extension when writing the file from the contents of def->cd_file. --- database/DBio.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/database/DBio.c b/database/DBio.c index 2a556a34..37c306e6 100644 --- a/database/DBio.c +++ b/database/DBio.c @@ -2721,29 +2721,25 @@ DBCellWrite(cellDef, fileName) /* * Figure out the name of the file we will eventually write. */ - if (fileName) + if (!fileName) { - realname = (char *) mallocMagic(strlen(fileName) + strlen(DBSuffix) + 1); - (void) sprintf(realname, "%s%s", fileName, DBSuffix); + if (cellDef->cd_file) + fileName = cellDef->cd_file; + else if (cellDef->cd_name) + fileName = cellDef->cd_name; + else + return FALSE; + } - /* Bug fix: 7/17/99, Michael D. Godfrey: Forces */ - /* cd_name and cd_file to ALWAYS be the same, otherwise ugly */ - /* surprises can occur after saving a file as a different */ - /* filename. */ + /* Bug fix: 7/17/99, Michael D. Godfrey: Forces */ + /* cd_name and cd_file to ALWAYS be the same, otherwise ugly */ + /* surprises can occur after saving a file as a different */ + /* filename. */ - cellDef->cd_file = StrDup(&cellDef->cd_file, fileName); - } - else if (cellDef->cd_file) - { - realname = StrDup((char **) NULL, cellDef->cd_file); - } - else if (cellDef->cd_name) - { - realname = (char *) mallocMagic((unsigned) (strlen(cellDef->cd_name) - + strlen(DBSuffix) + 1)); - (void) sprintf(realname, "%s%s", cellDef->cd_name, DBSuffix); - } - else return (FALSE); + cellDef->cd_file = StrDup(&cellDef->cd_file, fileName); + + realname = (char *) mallocMagic(strlen(fileName) + strlen(DBSuffix) + 1); + (void) sprintf(realname, "%s%s", fileName, DBSuffix); /* * Expand the filename, removing the leading ~, if any.