diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp index d838ea04ed4ddbbf3452ff5cd9f65e14721e40a9..b7c486a52b112db7eb09d0680bd49874bd7fb3f6 100644 --- a/src/sbbs3/writemsg.cpp +++ b/src/sbbs3/writemsg.cpp @@ -141,12 +141,14 @@ bool sbbs_t::quotemsg(smb_t* smb, smbmsg_t* msg, bool tails) } /****************************************************************************/ +/* Insure ends in LF or CRLF */ /****************************************************************************/ int sbbs_t::process_edited_text(char* buf, FILE* stream, int mode, unsigned* lines, unsigned maxlines) { unsigned i,l; int len=0; ushort useron_xedit = useron.xedit; + char lastch = 0; if(useron_xedit && !chk_ar(cfg.xedit[useron_xedit-1]->ar, &useron, &client)) useron_xedit = 0; @@ -157,6 +159,7 @@ int sbbs_t::process_edited_text(char* buf, FILE* stream, int mode, unsigned* lin switch(cfg.xedit[useron_xedit-1]->soft_cr) { case XEDIT_SOFT_CR_EXPAND: len += fwrite(crlf,1,2,stream); + lastch = '\n'; continue; case XEDIT_SOFT_CR_STRIP: continue; @@ -169,6 +172,7 @@ int sbbs_t::process_edited_text(char* buf, FILE* stream, int mode, unsigned* lin if(buf[l]==LF && (!l || buf[l-1]!=CR) && useron_xedit && cfg.xedit[useron_xedit-1]->misc&EXPANDLF) { len+=fwrite(crlf,1,2,stream); + lastch = '\n'; i++; continue; } @@ -205,6 +209,7 @@ int sbbs_t::process_edited_text(char* buf, FILE* stream, int mode, unsigned* lin if(buf[l]==LF) i++; fputc(buf[l],stream); + lastch = buf[l]; len++; } @@ -212,6 +217,10 @@ int sbbs_t::process_edited_text(char* buf, FILE* stream, int mode, unsigned* lin bprintf(text[NoMoreLines], i); buf[l] = 0; } + if(lastch != '\n') { + len+=fwrite(crlf,1,2,stream); + ++i; + } if(lines!=NULL) *lines=i;