[comp.sources.misc] v10i051: PC-MAIL release 2, patch 1

wswietse@lso.win.tue.nl (Wietse Venema) (02/14/90)

Posting-number: Volume 10, Issue 51
Submitted-by: wswietse@lso.win.tue.nl (Wietse Venema)
Archive-name: pcmail2/patch01

There is a bug in some implementations of the MicroSoft C sscanf()
library function that may cause the pc-mail programs to believe
that there is more unread mail than there actually is. The following
patch should take care of the problem. 

The sscanf() problem definitely does not exist with the UNIX versions
that I compiled the software on (SunOS 4.0.3, Microport SysV/AT 2.3).

Feed the following to the patch command. If you do not have patch, the
changes are quite obvious and can easily be applied by hand.

*** newseqno.c-	Mon Jan 22 13:04:30 1990
--- newseqno.c	Mon Jan 29 15:50:48 1990
***************
*** 30,38 ****
  /* CREATION DATE
  /*      Sat Mar 28 18:10:53 GMT+1:00 1987
  /* LAST MODIFICATION
! /*	90/01/22 13:02:19
  /* VERSION/RELEASE
! /*	2.1
  /*--*/
  
  #include "defs.h"
--- 30,38 ----
  /* CREATION DATE
  /*      Sat Mar 28 18:10:53 GMT+1:00 1987
  /* LAST MODIFICATION
! /*	90/01/29 15:50:46
  /* VERSION/RELEASE
! /*	2.2
  /*--*/
  
  #include "defs.h"
***************
*** 72,81 ****
  public unsigned seqno(s)
  char   *s;
  {
!     int     seq;
!     char    junk;
  
!     if (strlen(s) == NAMELEN && sscanf(s + 1, "%u%c", &seq, &junk) == 1)
  	return (seq);
      else
  	return (0);
--- 72,84 ----
  public unsigned seqno(s)
  char   *s;
  {
!     unsigned seq;
!     char    junk = 0;
  
!     /* MicroSoft C sscanf() does not terminate if assignment to seq fails */
! 
!     if (strlen(s) == NAMELEN && sscanf(s + 1, "%u%c", &seq, &junk) == 1
!     && junk == 0)
  	return (seq);
      else
  	return (0);