diff --git a/golded3/gedoit.cpp b/golded3/gedoit.cpp index 847d3da..933a5c6 100644 --- a/golded3/gedoit.cpp +++ b/golded3/gedoit.cpp @@ -67,8 +67,17 @@ void SaveLines(int mode, const char* savefile, GMsg* msg, int margin, bool clip) } } #else - if(mode == MODE_WRITE) - AA->LoadMsg(msg, msg->msgno, margin); // reload message + if(mode == MODE_WRITE) { + if(AA->LoadMsg(msg, msg->msgno, margin) == false) { + msg->txt = throw_strdup(""); + msg->attr.tou0(); + msg->TextToLines(margin); + } + } + else if((mode == MODE_SAVE) or (mode == MODE_SAVENOCTRL)) { + msg->attr.tou0(); + msg->TextToLines(margin); + } TemplateToText(((mode == MODE_WRITE) and prnheader) ? ((prnheader & WRITE_ONLY_HEADER) ? MODE_HEADER : MODE_WRITEHEADER) : MODE_WRITE, msg, msg, AA->WTpl(), CurrArea); msg->attr.tou1(); msg->TextToLines(margin); diff --git a/golded3/geread2.cpp b/golded3/geread2.cpp index fdea4a3..b0be5e0 100644 --- a/golded3/geread2.cpp +++ b/golded3/geread2.cpp @@ -525,7 +525,6 @@ int ExternUtil(GMsg* msg, int utilno) { Path editorfile, tmpfile; strcpy(editorfile, AddPath(CFG->goldpath, EDIT->File())); - mktemp(strcpy(tmpfile, AddPath(CFG->goldpath, "GDXXXXXX"))); std::vector::iterator extutil = CFG->externutil.begin(); @@ -538,18 +537,21 @@ int ExternUtil(GMsg* msg, int utilno) { int mode = (extutil->options & EXTUTIL_KEEPCTRL) ? MODE_SAVE : MODE_SAVENOCTRL; SaveLines(mode, editorfile, msg, 79); - if(striinc("@tmpfile", cmdline)) - SaveLines(mode, tmpfile, msg, 79); - - strcpy(buf, CFG->goldpath); - strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); - strischg(cmdline, "@path", buf); strcpy(buf, editorfile); strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); strischg(cmdline, "@file", buf); - strcpy(buf, tmpfile); + if(striinc("@tmpfile", cmdline)) { + mktemp(strcpy(tmpfile, AddPath(CFG->goldpath, "GDXXXXXX"))); + SaveLines(mode, tmpfile, msg, 79); + strcpy(buf, tmpfile); + strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); + strischg(cmdline, "@tmpfile", buf); + } + else + tmpfile[0] = NUL; + strcpy(buf, CFG->goldpath); strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); - strischg(cmdline, "@tmpfile", buf); + strischg(cmdline, "@path", buf); TokenXlat(MODE_NEW, cmdline, msg, msg, CurrArea); int pauseval = 0; @@ -585,7 +587,8 @@ int ExternUtil(GMsg* msg, int utilno) { LoadText(msg, editorfile); if(extutil->options & EXTUTIL_WIPE) WipeFile(editorfile, 0); - WipeFile(tmpfile, 0); + if(tmpfile[0] != NUL) + WipeFile(tmpfile, 0); EDIT->HardLines(hardlines); msg->attr.tou1(); // Ignore any kludge address found