Skip to content
Snippets Groups Projects
Commit bba2a9d5 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

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.
parent b11d34b0
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #939 passed
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment