[comp.sources.bugs] Official patch #3 for mp v2.0; please apply it.

richb@sunchat.oz (Rich Burridge) (04/10/89)

It fixes several problems, and adds an enhancement.

1/ Bug report and fix from Jimmy Aitken <jimmy%pyrps5.pyramid.com>
   On a Pyramid, in the ucb universe, 'strings.h' is required, not
   'string.h'. I've changed this to remove the #include for
   <string.h> and insert a declaration for 'char *strcpy()', which
   was the only definition needed from this file, and simplifies the
   solution.

2/ mp has been run through lint, and a few slight modifications made.

3/ Bug report and fix from Jimmy Aitken <jimmy%pyrps5.pyramid.com>
   An 'exit(0);' is required or else the shell gets' a garbage exit
   status.

4/ Bug report and fix from Jimmy Aitken <jimmy%pyrps5.pyramid.com>
   Pyramid compiler didn't like the negation of a character array as
   a logical value.

5/ Bug report and fix from Jimmy Aitken <jimmy%pyrps5.pyramid.com>
   The line warapping technique didn't work correctly for long lines
   containg TAB characters.

6/ Bug report and fix from Hugues Leroy <hleroy%presto.irisa.fr>
   Small modification to the routine that extracts the gecos field,
   to look for a comma as well as a space as a word separator.

7/ Modification suggested by stephenf@softway.oz.au>
   Modification suggested by Hugues Leroy <hleroy%presto.irisa.fr>
   A previous version of mp had a slightly different format for net
   news articles. The top banner contained the text "Article from ..."
   This has been reinstated as an option (-a). See the mp manual page
   for more details.

Thanks to the above people for the bug reports, fixes and suggestions.

Feed this file to Larry Walls' patch program, then recompile.

    Rich.

------CUT HERE------CUT HERE------
*** original/README	Mon Apr  3 14:52:30 1989
--- README	Mon Apr 10 13:22:22 1989
***************
*** 35,43 ****
  Buchanan added support for printing in filofax and Time Manager format.
  
  Thanks go also to Bill Shannon, Roger De Salis, L. Jill Debord, Frederick
! Avolio, Mark Prior, Stephen Frede, Craig Bishop and David Fiedler for bug
! reports and/or bug fixes. I'm grateful to all these people, plus everybody
! who has suggested enhancements, and fixed bugs in the previous versions.
  
  I welcome further bug reports and suggestions for improvements.
  
--- 35,44 ----
  Buchanan added support for printing in filofax and Time Manager format.
  
  Thanks go also to Bill Shannon, Roger De Salis, L. Jill Debord, Frederick
! Avolio, Mark Prior, Stephen Frede, Craig Bishop, Jimmy Aitken, Hugues Leroy
! and David Fiedler for bug reports and/or bug fixes. I'm grateful to all
! these people, plus everybody who has suggested enhancements, and fixed bugs
! in the previous versions.
  
  I welcome further bug reports and suggestions for improvements.
  
*** original/mp.1	Mon Apr  3 14:52:30 1989
--- mp.1	Mon Apr 10 13:22:22 1989
***************
*** 1,4 ****
! .\" @(#)mp.1 1.3 89/04/03
  .TH MP 1L "28 December 1988"
  .SH NAME
  mp \- Postscript pretty printer
--- 1,4 ----
! .\" @(#)mp.1 1.4 89/04/10
  .TH MP 1L "28 December 1988"
  .SH NAME
  mp \- Postscript pretty printer
***************
*** 5,10 ****
--- 5,13 ----
  .SH SYNOPSIS
  .B mp
  [
+ .B \-a
+ ]
+ [
  .B \-d
  ]
  [
***************
*** 98,103 ****
--- 101,114 ----
  .fi
  .in -1.0i
  .SH OPTIONS
+ .TP
+ .B \-a
+ The file on standard input is a news article, and should be printed with
+ "Article from
+ .I newsgroup
+ " in the top banner, where
+ .I newsgroup
+ is the first news group found on the Newsgroups: line.
  .TP
  .B \-d
  The file on standard input is a digest so print accordingly.
*** original/mp.c	Mon Apr  3 14:52:30 1989
--- mp.c	Mon Apr 10 13:22:20 1989
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)mp.c 1.5 89/04/03" ;
  #endif
  
  /*  Takes a mail file, a news article or an ordinary file
--- 1,5 ----
  #ifndef lint
! static char sccsid[] = "@(#)mp.c 1.6 89/04/10" ;
  #endif
  
  /*  Takes a mail file, a news article or an ordinary file
***************
*** 35,45 ****
  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/file.h>
- #include <string.h>
  #include <time.h>
  #include <pwd.h>
  
! #define  PATCHLEVEL   2
  
  #define  FPRINTF      (void) fprintf    /* To make lint happy. */
  #define  PRINTF       (void) printf
--- 35,44 ----
  #include <stdio.h>
  #include <sys/types.h>
  #include <sys/file.h>
  #include <time.h>
  #include <pwd.h>
  
! #define  PATCHLEVEL   3
  
  #define  FPRINTF      (void) fprintf    /* To make lint happy. */
  #define  PRINTF       (void) printf
***************
*** 64,71 ****
  time_t time() ;
  struct passwd *mypass ;
  struct tm *localtime() ;
! char *asctime(), *getlogin(), *gets() ;
! char gecos[MAXLINE] ;        /* Probably the real name to use */
  char mf[MAXLINE] ;           /* "[Mail,News,Listing] for ". */
  char nextline[MAXLINE] ;     /* Next line of the mail message. */
  char progname[MAXLINE] ;     /* Name of this program. */
--- 63,69 ----
  time_t time() ;
  struct passwd *mypass ;
  struct tm *localtime() ;
! char *asctime(), *getlogin(), *gets(), *strcpy(), *strncpy() ;
  char mf[MAXLINE] ;           /* "[Mail,News,Listing] for ". */
  char nextline[MAXLINE] ;     /* Next line of the mail message. */
  char progname[MAXLINE] ;     /* Name of this program. */
***************
*** 76,81 ****
--- 74,80 ----
  
  enum print_type ptype ;     /* Type of printing to do. */
  
+ int article = 0 ;           /* Set for news in "Article from " format. */
  int digest = 0 ;            /* Set if we are printing a mail digest. */
  int fflag = 0 ;             /* Set if mail message is from the user. */
  int filofax = 0 ;           /* Set if we are printing a filofax file. */
***************
*** 106,112 ****
  char **argv ;
  {
    char tmpstr[MAXLINE] ;   /* Temporary variable. */
!   int t1, t2 ;             /* Temporary variables. */
    long clock ;             /* Used by the localtime function call. */
    struct tm *tm ;          /* Used by the localtime and asctime calls. */
  
--- 105,111 ----
  char **argv ;
  {
    char tmpstr[MAXLINE] ;   /* Temporary variable. */
!   int t2 ;                 /* Temporary variable. */
    long clock ;             /* Used by the localtime function call. */
    struct tm *tm ;          /* Used by the localtime and asctime calls. */
  
***************
*** 122,128 ****
    while (fgets(nextline, MAXLINE, pf) != NULL)
      {
        PRINTF("%s", nextline) ;    /* Check for new line or page length. */
!       t1 = sscanf(nextline, "%s %d", tmpstr, &t2) ;
        if (strcmp(tmpstr, "%%PageLength") == 0)
          plen = t2 ;               /* Change the page length. */
        else if (strcmp(tmpstr, "%%LineLength") == 0)
--- 121,127 ----
    while (fgets(nextline, MAXLINE, pf) != NULL)
      {
        PRINTF("%s", nextline) ;    /* Check for new line or page length. */
!       SSCANF(nextline, "%s %d", tmpstr, &t2) ;
        if (strcmp(tmpstr, "%%PageLength") == 0)
          plen = t2 ;               /* Change the page length. */
        else if (strcmp(tmpstr, "%%LineLength") == 0)
***************
*** 161,166 ****
--- 160,166 ----
    else endpage() ;
    PRINTF("%%%%Trailer\n") ;
    PRINTF("%%%%Pages: %1d\n",tpn) ;
+   exit(0) ;
  }
  
  
***************
*** 229,235 ****
            default     : PRINTF("%c",s[i]) ;
                          n++ ;
          }
!       if (!(i % llen) && i)
          {
            eol = 1 ;
            if (filofax || timeman) eol = tabled(s) ;
--- 229,235 ----
            default     : PRINTF("%c",s[i]) ;
                          n++ ;
          }
!       if (!(n % llen) && n)
          {
            eol = 1 ;
            if (filofax || timeman) eol = tabled(s) ;
***************
*** 253,258 ****
--- 253,262 ----
        if (argv[0][0] == '-')
          switch (argv[0][1])
            {
+             case 'a' : ptype = PRINTNEWS ;            /* Print news article. */
+                        article = 1 ;        /* "Article from" in top banner. */
+                        STRCPY(mf, "Article from ") ;
+                        break ;
              case 'd' : digest = 1 ;                   /* Print mail digest. */
                         break ;
              case 'e' : if (!strcmp(&argv[0][2], "lm"))
***************
*** 343,349 ****
            spaces = 0 ;
            while (i < 18)
              {
!               if (username[i] == ' ')
                  {
                    spaces++ ;
                    if (spaces == 2)
--- 347,353 ----
            spaces = 0 ;
            while (i < 18)
              {
!               if (username[i] == ' ' || username[i] == ',')
                  {
                    spaces++ ;
                    if (spaces == 2)
***************
*** 365,370 ****
--- 369,375 ----
  char *s ;
  {
    char first[MAXLINE] ;
+   int i, n ;
  
    useline() ;
    SSCANF(s,"%s",first) ;
***************
*** 371,379 ****
    PRINTF("BoldFont (%s) show PrimaryFont (",first) ;
    expand(&s[strlen(first)]) ;
    endline() ;
    if (!strcmp("Date:", first))
      defwrite("TimeNow", &s[strlen(first)]) ;
!   if (!strcmp("Subject:",first) && !subject)
      {
        PRINTF("/Subject (") ;
        expand(&s[strlen(first)]) ;
--- 376,396 ----
    PRINTF("BoldFont (%s) show PrimaryFont (",first) ;
    expand(&s[strlen(first)]) ;
    endline() ;
+ 
+   if (!strcmp("Newsgroups:", first) && article)
+     {
+       n = strlen(first)+1 ;
+       for (i = n; i < strlen(s); i++)
+         if (s[i] == ',' || s[i] == '\0') break ;
+       STRNCPY(username, &s[n], i-n) ;
+       username[i-n] = '\0' ;
+       defwrite("User", username) ;
+     }
+ 
    if (!strcmp("Date:", first))
      defwrite("TimeNow", &s[strlen(first)]) ;
! 
!   if (!strcmp("Subject:",first) && !strlen(subject))
      {
        PRINTF("/Subject (") ;
        expand(&s[strlen(first)]) ;
***************
*** 510,517 ****
  
  usage()     /* Print usage message and exit. */
  {
!   FPRINTF(stderr,"Usage: %s [-d] [-elm] [-f] [-from] [-m] [-mh] ", progname) ;
!   FPRINTF(stderr, "[-n] [-o] [-p prologue] [-t] [-v] [-?]\n") ;
    exit(1) ;
  }
  
--- 527,534 ----
  
  usage()     /* Print usage message and exit. */
  {
!   FPRINTF(stderr,"Usage: %s [-a] [-d] [-elm] [-f] [-from] [-m] ", progname) ;
!   FPRINTF(stderr, "[-mh] [-n] [-o] [-p prologue] [-t] [-v] [-?]\n") ;
    exit(1) ;
  }