From bba2a9d5f6426be4cec140f84e74aedf4c7580df Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Sat, 5 Dec 2020 19:26:48 -0800 Subject: [PATCH] Don't print a CRLF in printfile() (called by menu) if no file exists printfile() assumes you want the file displayed starting in column 0, so will send a CRLF to insure that it does (unless the P_NOCRLF mode flag is specified). But this CRLF printing was happening before the file was opened and when the P_NOERROR mode flag is specified, this should be a silent failure with no print output. So move the CRLF printing to *after* the file is opened. This expose an issue in the latest xtrn_sec.js where it makes several calls to bbs.menu() with the P_NOERROR mode flag set, expecting nothing to happen if/when the optional display files (e.g. xtrn*_tail.*) don't exist. Reported by JC via IRC. --- src/sbbs3/prntfile.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sbbs3/prntfile.cpp b/src/sbbs3/prntfile.cpp index 9419fcd00f..d20aaa0d35 100644 --- a/src/sbbs3/prntfile.cpp +++ b/src/sbbs3/prntfile.cpp @@ -84,10 +84,6 @@ bool sbbs_t::printfile(const char* fname, long mode, long org_cols, JSObject* ob sys_status&=~SS_ABORT; } - if(!(mode&P_NOCRLF) && row > 0 && !rip) { - newline(); - } - if((stream=fnopen(&file,fpath,O_RDONLY|O_DENYNONE))==NULL) { if(!(mode&P_NOERROR)) { lprintf(LOG_NOTICE,"!Error %d (%s) opening: %s" @@ -109,6 +105,10 @@ bool sbbs_t::printfile(const char* fname, long mode, long org_cols, JSObject* ob return true; } + if(!(mode&P_NOCRLF) && row > 0 && !rip) { + newline(); + } + if((mode&P_OPENCLOSE) && length <= PRINTFILE_MAX_FILE_LEN) { if((buf=(char*)malloc(length+1L))==NULL) { fclose(stream); @@ -196,9 +196,6 @@ bool sbbs_t::printtail(const char* fname, int lines, long mode, long org_cols, J } sys_status&=~SS_ABORT; } - if(!(mode&P_NOCRLF) && row > 0) { - newline(); - } if((fp=fnopen(&file,fpath,O_RDONLY|O_DENYNONE))==NULL) { if(!(mode&P_NOERROR)) { lprintf(LOG_NOTICE,"!Error %d (%s) opening: %s" @@ -209,6 +206,9 @@ bool sbbs_t::printtail(const char* fname, int lines, long mode, long org_cols, J } return false; } + if(!(mode&P_NOCRLF) && row > 0) { + newline(); + } length=(long)filelength(file); if(length<0) { fclose(fp); -- GitLab