home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gnu / rcs-5.6.0.1-src.lha / rcs-5.6.0.1 / src / rlog.c < prev   
C/C++ Source or Header  |  1991-11-22  |  32KB  |  1,205 lines

  1. /*
  2.  *                       RLOG    operation
  3.  */
  4. /*****************************************************************************
  5.  *                       print contents of RCS files
  6.  *****************************************************************************
  7.  */
  8.  
  9. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  10.    Copyright 1990, 1991 by Paul Eggert
  11.    Distributed under license by the Free Software Foundation, Inc.
  12.  
  13. This file is part of RCS.
  14.  
  15. RCS is free software; you can redistribute it and/or modify
  16. it under the terms of the GNU General Public License as published by
  17. the Free Software Foundation; either version 2, or (at your option)
  18. any later version.
  19.  
  20. RCS is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. GNU General Public License for more details.
  24.  
  25. You should have received a copy of the GNU General Public License
  26. along with RCS; see the file COPYING.  If not, write to
  27. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  28.  
  29. Report problems and direct all questions to:
  30.  
  31.     rcs-bugs@cs.purdue.edu
  32.  
  33. */
  34.  
  35.  
  36.  
  37.  
  38. /* $Log: rlog.c,v $
  39.  * Revision 5.9  1991/09/17  19:07:40  eggert
  40.  * Getscript() didn't uncache partial lines.
  41.  *
  42.  * Revision 5.8  1991/08/19  03:13:55  eggert
  43.  * Revision separator is `:', not `-'.
  44.  * Check for missing and duplicate logs.  Tune.
  45.  * Permit log messages that do not end in newline (including empty logs).
  46.  *
  47.  * Revision 5.7  1991/04/21  11:58:31  eggert
  48.  * Add -x, RCSINIT, MS-DOS support.
  49.  *
  50.  * Revision 5.6  1991/02/26  17:07:17  eggert
  51.  * Survive RCS files with missing logs.
  52.  * strsave -> str_save (DG/UX name clash)
  53.  *
  54.  * Revision 5.5  1990/11/01  05:03:55  eggert
  55.  * Permit arbitrary data in logs and comment leaders.
  56.  *
  57.  * Revision 5.4  1990/10/04  06:30:22  eggert
  58.  * Accumulate exit status across files.
  59.  *
  60.  * Revision 5.3  1990/09/11  02:41:16  eggert
  61.  * Plug memory leak.
  62.  *
  63.  * Revision 5.2  1990/09/04  08:02:33  eggert
  64.  * Count RCS lines better.
  65.  *
  66.  * Revision 5.0  1990/08/22  08:13:48  eggert
  67.  * Remove compile-time limits; use malloc instead.  Add setuid support.
  68.  * Switch to GMT.
  69.  * Report dates in long form, to warn about dates past 1999/12/31.
  70.  * Change "added/del" message to make room for the longer dates.
  71.  * Don't generate trailing white space.  Add -V.  Ansify and Posixate.
  72.  *
  73.  * Revision 4.7  89/05/01  15:13:48  narten
  74.  * changed copyright header to reflect current distribution rules
  75.  * 
  76.  * Revision 4.6  88/08/09  19:13:28  eggert
  77.  * Check for memory exhaustion; don't access freed storage.
  78.  * Shrink stdio code size; remove lint.
  79.  * 
  80.  * Revision 4.5  87/12/18  11:46:38  narten
  81.  * more lint cleanups (Guy Harris)
  82.  * 
  83.  * Revision 4.4  87/10/18  10:41:12  narten
  84.  * Updating version numbers
  85.  * Changes relative to 1.1 actually relative to 4.2
  86.  * 
  87.  * Revision 1.3  87/09/24  14:01:10  narten
  88.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  89.  * warnings)
  90.  * 
  91.  * Revision 1.2  87/03/27  14:22:45  jenkins
  92.  * Port to suns
  93.  * 
  94.  * Revision 4.2  83/12/05  09:18:09  wft
  95.  * changed rewriteflag to external.
  96.  * 
  97.  * Revision 4.1  83/05/11  16:16:55  wft
  98.  * Added -b, updated getnumericrev() accordingly.
  99.  * Replaced getpwuid() with getcaller().
  100.  * 
  101.  * Revision 3.7  83/05/11  14:24:13  wft
  102.  * Added options -L and -R;
  103.  * Fixed selection bug with -l on multiple files.
  104.  * Fixed error on dates of the form -d'>date' (rewrote getdatepair()).
  105.  * 
  106.  * Revision 3.6  82/12/24  15:57:53  wft
  107.  * shortened output format.
  108.  *
  109.  * Revision 3.5  82/12/08  21:45:26  wft
  110.  * removed call to checkaccesslist(); used DATEFORM to format all dates;
  111.  * removed unused variables.
  112.  *
  113.  * Revision 3.4  82/12/04  13:26:25  wft
  114.  * Replaced getdelta() with gettree(); removed updating of field lockedby.
  115.  *
  116.  * Revision 3.3  82/12/03  14:08:20  wft
  117.  * Replaced getlogin with getpwuid(), %02d with %.2d, fancydate with PRINTDATE.
  118.  * Fixed printing of nil, removed printing of Suffix,
  119.  * added shortcut if no revisions are printed, disambiguated struct members.
  120.  *
  121.  * Revision 3.2  82/10/18  21:09:06  wft
  122.  * call to curdir replaced with getfullRCSname(),
  123.  * fixed call to getlogin(), cosmetic changes on output,
  124.  * changed conflicting long identifiers.
  125.  *
  126.  * Revision 3.1  82/10/13  16:07:56  wft
  127.  * fixed type of variables receiving from getc() (char -> int).
  128.  */
  129.  
  130.  
  131.  
  132. #include "rcsbase.h"
  133.  
  134. struct  lockers {                     /* lockers in locker option; stored   */
  135.      char const        * login;      /* lockerlist                */
  136.      struct     lockers * lockerlink;
  137.      }  ;
  138.  
  139. struct  stateattri {                  /* states in state option; stored in  */
  140.      char const        * status;     /* statelist                */
  141.      struct  stateattri * nextstate;
  142.      }  ;
  143.  
  144. struct  authors {                     /* login names in author option;      */
  145.      char const        * login;      /* stored in authorlist            */
  146.      struct     authors * nextauthor;
  147.      }  ;
  148.  
  149. struct Revpairs{                      /* revision or branch range in -r     */
  150.      unsigned          numfld;     /* option; stored in revlist        */
  151.      char const        * strtrev;
  152.      char const        * endrev;
  153.      struct  Revpairs   * rnext;
  154.      } ;
  155.  
  156. struct Datepairs{                     /* date range in -d option; stored in */
  157.      char               strtdate[datesize];   /* duelst and datelist      */
  158.      char               enddate[datesize];
  159.      struct  Datepairs  * dnext;
  160.      };
  161.  
  162. static char extractdelta P((struct hshentry const*));
  163. static int checkrevpair P((char const*,char const*));
  164. static struct hshentry const *readdeltalog P((void));
  165. static unsigned extdate P((struct hshentry*));
  166. static void cleanup P((void));
  167. static void exttree P((struct hshentry*));
  168. static void getauthor P((char*));
  169. static void getdatepair P((char*));
  170. static void getlocker P((char*));
  171. static void getnumericrev P((void));
  172. static void getrevpairs P((char*));
  173. static void getscript P((struct hshentry*));
  174. static void getstate P((char*));
  175. static void putabranch P((struct hshentry const*));
  176. static void putadelta P((struct hshentry const*,struct hshentry const*,int));
  177. static void putforest P((struct branchhead const*));
  178. static void putree P((struct hshentry const*));
  179. static void putrunk P((void));
  180. static void recentdate P((struct hshentry const*,struct Datepairs*));
  181. static void trunclocks P((void));
  182.  
  183. static char const *insDelFormat;
  184. static int branchflag;    /*set on -b */
  185. static int exitstatus;
  186. static int lockflag;
  187. static struct Datepairs *datelist, *duelst;
  188. static struct Revpairs *revlist, *Revlst;
  189. static struct authors *authorlist;
  190. static struct lockers *lockerlist;
  191. static struct stateattri *statelist;
  192.  
  193.  
  194. mainProg(rlogId, "rlog", "$Id: rlog.c,v 5.9 1991/09/17 19:07:40 eggert Exp $")
  195. {
  196.     static char const cmdusage[] =
  197.         "\nrlog usage: rlog -{bhLRt} -ddates -l[lockers] -rrevs -sstates -w[logins] -Vn file ...";
  198.  
  199.     register FILE *out;
  200.     char *a, **newargv;
  201.     struct Datepairs *currdate;
  202.     char const *accessListString, *accessFormat, *commentFormat;
  203.     char const *headFormat, *symbolFormat;
  204.     struct access const *curaccess;
  205.     struct assoc const *curassoc;
  206.     struct hshentry const *delta;
  207.     struct lock const *currlock;
  208.     int descflag, selectflag;
  209.     int onlylockflag;  /* print only files with locks */
  210.     int onlyRCSflag;  /* print only RCS file name */
  211.     unsigned revno;
  212.  
  213.         descflag = selectflag = true;
  214.     onlylockflag = onlyRCSflag = false;
  215.     out = stdout;
  216.     suffixes = X_DEFAULT;
  217.  
  218.     argc = getRCSINIT(argc, argv, &newargv);
  219.     argv = newargv;
  220.     while (a = *++argv,  0<--argc && *a++=='-') {
  221.         switch (*a++) {
  222.  
  223.         case 'L':
  224.             onlylockflag = true;
  225.             break;
  226.  
  227.         case 'R':
  228.             onlyRCSflag =true;
  229.             break;
  230.  
  231.                 case 'l':
  232.                         lockflag = true;
  233.             getlocker(a);
  234.                         break;
  235.  
  236.                 case 'b':
  237.                         branchflag = true;
  238.                         break;
  239.  
  240.                 case 'r':
  241.             getrevpairs(a);
  242.                         break;
  243.  
  244.                 case 'd':
  245.             getdatepair(a);
  246.                         break;
  247.  
  248.                 case 's':
  249.             getstate(a);
  250.                         break;
  251.  
  252.                 case 'w':
  253.             getauthor(a);
  254.                         break;
  255.  
  256.                 case 'h':
  257.             descflag = false;
  258.