Skip to content

Commit

Permalink
When importing messages into a local msgbase that contained an origin…
Browse files Browse the repository at this point in the history
… line

but no tear line, I noticed that the initial space before "* Origin" was absent
from the tail. It turns out the missing space character was being appended to
the end of the body text. While investigating why that was, I was dismayed at
the cruftiness of code but totally suprised that there was 80-column word-wrap
logic in here (!). Removed that word-wrap logic <blush> and fixed the origin
thing. More clean-up coming up next.
  • Loading branch information
rswindell committed Apr 30, 2020
1 parent b19b117 commit aa7049d
Showing 1 changed file with 15 additions and 35 deletions.
50 changes: 15 additions & 35 deletions sbbs3/sbbsecho.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Synchronet FidoNet EchoMail Scanning/Tossing and NetMail Tossing Utility */

/* $Id: sbbsecho.c,v 3.168 2020/04/28 04:07:02 rswindell Exp $ */
/* $Id: sbbsecho.c,v 3.169 2020/04/30 04:34:37 rswindell Exp $ */
// vi: tabstop=4

/****************************************************************************
Expand Down Expand Up @@ -3253,9 +3253,8 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
{
uchar ch,stail[MAX_TAILLEN+1],*sbody;
char msg_id[256],str[128],*p;
bool done,esc,cr;
bool done,cr;
int i;
uint col;
ushort xlat=XLAT_NONE,net;
ulong l,m,length,bodylen,taillen;
ulong save;
Expand Down Expand Up @@ -3328,7 +3327,7 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
return IMPORT_FAILURE;
}

for(col=0,l=0,esc=0,done=0,bodylen=0,taillen=0,cr=1;l<length;l++) {
for(l=0,done=0,bodylen=0,taillen=0,cr=1;l<length;l++) {

if(!l && !strncmp((char *)fbuf,"AREA:",5)) {
save=l;
Expand All @@ -3350,8 +3349,7 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
ch=fbuf[l];
if(ch==CTRL_A && !cr)
ch = '@';

if(ch==CTRL_A) { /* kludge line */
else if(ch==CTRL_A) { /* kludge line */

if(!strncmp((char *)fbuf+l+1,"TOPT ",5))
destaddr.point=atoi((char *)fbuf+l+6);
Expand Down Expand Up @@ -3494,13 +3492,20 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
while(l<length && fbuf[l]!='\r') l++;
continue;
}

if(ch == '\n')
continue;
if(cr && (!strncmp((char *)fbuf+l,"--- ",4)
|| !strncmp((char *)fbuf+l,"---\r",4)))
done=1; /* tear line and down go into tail */
if(done && cr && !strncmp((char *)fbuf+l,"SEEN-BY:",8)) {
else if(cr && !strncmp((char *)fbuf+l," * Origin: ",11)) {
p=(char*)fbuf+l+11;
while(*p && *p!='\r') p++; /* Find CR */
while(p && *p!='(') p--; /* rewind to '(' */
if(p)
origaddr=atofaddr(p+1); /* get orig address */
done=1;
}
else if(done && cr && !strncmp((char *)fbuf+l,"SEEN-BY:",8)) {
l+=8;
while(l<length && fbuf[l]<=' ' && fbuf[l]>=0) l++;
m=l;
Expand All @@ -3517,42 +3522,17 @@ int fmsgtosmsg(char* fbuf, fmsghdr_t* hdr, uint user, uint subnum)
}
else
sbody[bodylen++]=ch;
col++;
if(ch=='\r') {
cr=1;
col=0;
if(done) {
if(taillen<MAX_TAILLEN)
stail[taillen++]='\n';
}
else
sbody[bodylen++]='\n';
}
else {
else
cr=0;
if(col==1 && !strncmp((char *)fbuf+l," * Origin: ",11)) {
p=(char*)fbuf+l+11;
while(*p && *p!='\r') p++; /* Find CR */
while(p && *p!='(') p--; /* rewind to '(' */
if(p)
origaddr=atofaddr(p+1); /* get orig address */
done=1;
}
if(done)
continue;

if(ch==ESC) esc=1; /* ANSI codes */
if(ch==' ' && col>40 && !esc) { /* word wrap */
for(m=l+1;m<length;m++) /* find next space */
if(fbuf[m]<=' ' && fbuf[m]>=0)
break;
if(m<length && m-l>80-col) { /* if it's beyond the eol */
sbody[bodylen++]='\r';
sbody[bodylen++]='\n';
col=0;
}
}
}
}

if(bodylen>=2 && sbody[bodylen-2]=='\r' && sbody[bodylen-1]=='\n')
Expand Down Expand Up @@ -6118,7 +6098,7 @@ int main(int argc, char **argv)
memset(&smb[i],0,sizeof(smb_t));
memset(&cfg,0,sizeof(cfg));

sscanf("$Revision: 3.168 $", "%*s %s", revision);
sscanf("$Revision: 3.169 $", "%*s %s", revision);

DESCRIBE_COMPILER(compiler);

Expand Down

0 comments on commit aa7049d

Please sign in to comment.