...
 
Commits (1)
  • Rob Swindell's avatar
    Don't print a CRLF in printfile() (called by menu) if no file exists · bba2a9d5
    Rob Swindell authored
    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.
    bba2a9d5
......@@ -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);
......