From 09a87ec77c4c6f72d33c6b5b9b662d34664bb459 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Sat, 3 Aug 2019 09:41:19 +0000 Subject: [PATCH] When listing messages: - Use the P_TRUNCATE pmode flag to prevent long msg subj from wrapping the terminal - Use msghdr_text() to do the magic UTF-8/CP437 dance for messages with UTF-8 header fields (e.g. to/from/subject) This is why I assigned MSG_HFIELDS_UTF8 the same bit-flag value as P_UTF8. :-) --- src/sbbs3/readmail.cpp | 21 ++++++++++++++------- src/sbbs3/readmsgs.cpp | 9 ++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/sbbs3/readmail.cpp b/src/sbbs3/readmail.cpp index 529ee40250..e9e8597840 100644 --- a/src/sbbs3/readmail.cpp +++ b/src/sbbs3/readmail.cpp @@ -142,7 +142,8 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode) if(loadmsg(&msg,mail[smb.curmsg].number) < 1) continue; smb_unlockmsghdr(&smb,&msg); - bprintf(text[MailWaitingLstFmt],smb.curmsg+1 + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailWaitingLstFmt), smb.curmsg+1 ,which==MAIL_SENT ? msg.to : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] : msg.from @@ -489,12 +490,14 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode) continue; smb_unlockmsghdr(&smb,&msg); if(which==MAIL_ALL) - bprintf(text[MailOnSystemLstFmt] + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailOnSystemLstFmt) ,u+1,msg.from,msg.to ,mail_listing_flag(&msg) ,msg.subj); else - bprintf(text[MailWaitingLstFmt],u+1 + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailWaitingLstFmt),u+1 ,which==MAIL_SENT ? msg.to : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] : msg.from @@ -660,12 +663,14 @@ void sbbs_t::readmail(uint usernumber, int which, long lm_mode) continue; smb_unlockmsghdr(&smb,&msg); if(which==MAIL_ALL) - bprintf(text[MailOnSystemLstFmt] + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailOnSystemLstFmt) ,u+1,msg.from,msg.to ,mail_listing_flag(&msg) ,msg.subj); else - bprintf(text[MailWaitingLstFmt],u+1 + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailWaitingLstFmt),u+1 ,which==MAIL_SENT ? msg.to : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] : msg.from @@ -828,12 +833,14 @@ long sbbs_t::searchmail(mail_t *mail, long start, long msgs, int which, const ch bprintf(text[MailWaitingLstHdr], order); } if(which==MAIL_ALL) - bprintf(text[MailOnSystemLstFmt] + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailOnSystemLstFmt) ,l+1,msg.from,msg.to ,mail_listing_flag(&msg) ,msg.subj); else - bprintf(text[MailWaitingLstFmt],l+1 + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, MailWaitingLstFmt),l+1 ,which==MAIL_SENT ? msg.to : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] : msg.from diff --git a/src/sbbs3/readmsgs.cpp b/src/sbbs3/readmsgs.cpp index ee6044cc54..3e0fe3b265 100644 --- a/src/sbbs3/readmsgs.cpp +++ b/src/sbbs3/readmsgs.cpp @@ -74,7 +74,8 @@ long sbbs_t::listmsgs(uint subnum, long mode, post_t *post, long i, long posts, smb_unlockmsghdr(&smb,&msg); if(listed==0) bputs(text[MailOnSystemLstHdr]); - bprintf(text[SubMsgLstFmt], reading ? (i+1) : post[i].num + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, SubMsgLstFmt), reading ? (i+1) : post[i].num ,msg.hdr.attr&MSG_ANONYMOUS && !sub_op(subnum) ? text[Anonymous] : msg.from ,msg.to @@ -1764,7 +1765,8 @@ long sbbs_t::searchposts(uint subnum, post_t *post, long start, long posts || (msg.tags != NULL && strcasestr(msg.tags, search) != NULL)) { if(!found) bputs(text[MailOnSystemLstHdr]); - bprintf(text[SubMsgLstFmt],l+1 + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, SubMsgLstFmt),l+1 ,(msg.hdr.attr&MSG_ANONYMOUS) && !sub_op(subnum) ? text[Anonymous] : msg.from ,msg.to @@ -1819,7 +1821,8 @@ long sbbs_t::showposts_toyou(uint subnum, post_t *post, ulong start, long posts, if(!found) bputs(text[MailOnSystemLstHdr]); found++; - bprintf(text[SubMsgLstFmt],l+1 + bprintf(P_TRUNCATE|(msg.hdr.auxattr&MSG_HFIELDS_UTF8) + ,msghdr_text(&msg, SubMsgLstFmt),l+1 ,(msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] : msg.from ,msg.to -- GitLab