home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / gnu / rcs5ap1s.lzh / RCS5AP1S / RCSREV.C < prev    next >
C/C++ Source or Header  |  1991-01-30  |  22KB  |  727 lines

  1. /*
  2.  *                     RCS revision number handling
  3.  */
  4.  
  5. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  6.    Copyright 1990 by Paul Eggert
  7.    Distributed under license by the Free Software Foundation, Inc.
  8.  
  9. This file is part of RCS.
  10.  
  11. RCS is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 1, or (at your option)
  14. any later version.
  15.  
  16. RCS is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with RCS; see the file COPYING.  If not, write to
  23. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. Report problems and direct all questions to:
  26.  
  27.     rcs-bugs@cs.purdue.edu
  28.  
  29. */
  30.  
  31.  
  32.  
  33.  
  34. /* $Log: rcsrev.c,v $
  35.  * Revision 5.2  1991/01/30  14:21:32  apratt
  36.  * CI with RCS version 5
  37.  *
  38.  * Revision 5.1  91/01/29  17:46:00  apratt
  39.  * Added HEAD_REV code: now you can freeze a configuration with rcs
  40.  * 
  41.  * Revision 5.0  90/08/22  08:13:43  eggert
  42.  * checked in with -k by apratt at 91.01.10.13.15.28.
  43.  * 
  44.  * Revision 5.0  1990/08/22  08:13:43  eggert
  45.  * Remove compile-time limits; use malloc instead.
  46.  * Ansify and Posixate.  Tune.
  47.  * Remove possibility of an internal error.  Remove lint.
  48.  *
  49.  * Revision 4.5  89/05/01  15:13:22  narten
  50.  * changed copyright header to reflect current distribution rules
  51.  * 
  52.  * Revision 4.4  87/12/18  11:45:22  narten
  53.  * more lint cleanups. Also, the NOTREACHED comment is no longer necessary, 
  54.  * since there's now a return value there with a value. (Guy Harris)
  55.  * 
  56.  * Revision 4.3  87/10/18  10:38:42  narten
  57.  * Updating version numbers. Changes relative to version 1.1 actually 
  58.  * relative to 4.1
  59.  * 
  60.  * Revision 1.3  87/09/24  14:00:37  narten
  61.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  62.  * warnings)
  63.  * 
  64.  * Revision 1.2  87/03/27  14:22:37  jenkins
  65.  * Port to suns
  66.  * 
  67.  * Revision 4.1  83/03/25  21:10:45  wft
  68.  * Only changed $Header to $Id.
  69.  * 
  70.  * Revision 3.4  82/12/04  13:24:08  wft
  71.  * Replaced getdelta() with gettree().
  72.  *
  73.  * Revision 3.3  82/11/28  21:33:15  wft
  74.  * fixed compartial() and compnum() for nil-parameters; fixed nils
  75.  * in error messages. Testprogram output shortenend.
  76.  *
  77.  * Revision 3.2  82/10/18  21:19:47  wft
  78.  * renamed compnum->cmpnum, compnumfld->cmpnumfld,
  79.  * numericrevno->numricrevno.
  80.  *
  81.  * Revision 3.1  82/10/11  19:46:09  wft
  82.  * changed expandsym() to check for source==nil; returns zero length string
  83.  * in that case.
  84.  */
  85.  
  86.  
  87.  
  88. /*
  89. #define REVTEST
  90. */
  91. /* version REVTEST is for testing the routines that generate a sequence
  92.  * of delta numbers needed to regenerate a given delta.
  93.  */
  94.  
  95. #include "rcsbase.h"
  96.  
  97. libId(revId, "$Id: rcsrev.c,v 5.2 1991/01/30 14:21:32 apratt Exp $")
  98.  
  99. static struct hshentry *genbranch P((const struct hshentry*,const char*,unsigned,const char*,const char*,const char*,struct hshentries**));
  100.  
  101.  
  102.  
  103.     unsigned
  104. countnumflds(s)
  105.     const char *s;
  106. /* Given a pointer s to a dotted number (date or revision number),
  107.  * countnumflds returns the number of digitfields in s.
  108.  */
  109. {
  110.     register const char *sp;
  111.     register unsigned count;
  112.         if ((sp=s)==nil) return(0);
  113.         if (*sp == '\0') return(0);
  114.         count = 1;
  115.     do {
  116.                 if (*sp++ == '.') count++;
  117.     } while (*sp);
  118.         if (*(--sp) == '.') count--; /*trailing periods don't count*/
  119.         return(count);
  120. }
  121.  
  122.     void
  123. getbranchno(revno,branchno)
  124.     const char *revno;
  125.     struct buf *branchno;
  126. /* Given a non-nil revision number revno, getbranchno copies the number of the branch
  127.  * on which revno is into branchno. If revno itself is a branch number,
  128.  * it is copied unchanged.
  129.  */
  130. {
  131.     register unsigned numflds;
  132.     register char *tp;
  133.  
  134.     bufscpy(branchno, revno);
  135.         numflds=countnumflds(revno);
  136.     if (!(numflds & 1)) {
  137.         tp = branchno->string;
  138.         while (--numflds)
  139.             while (*tp++ != '.')
  140.                 ;
  141.                 *(tp-1)='\0';
  142.         }
  143. }
  144.  
  145.  
  146.  
  147. int cmpnum(num1, num2)
  148.     const char *num1, *num2;
  149. /* compares the two dotted numbers num1 and num2 lexicographically
  150.  * by field. Individual fields are compared numerically.
  151.  * returns <0, 0, >0 if num1<num2, num1==num2, and num1>num2, resp.
  152.  * omitted fields are assumed to be higher than the existing ones.
  153. */
  154. {
  155.     register const char *s1, *s2;
  156.         register int n1, n2;
  157.  
  158.         s1=num1==nil?"":num1;
  159.         s2=num2==nil?"":num2;
  160.  
  161.         do {
  162.                 n1 = 0;
  163.         while (isdigit(*s1))
  164.             n1 = n1*10 + (*s1++ - '0');
  165.                 /* skip '.' */
  166.                 if (*s1=='.') s1++;
  167.  
  168.                 n2 = 0;
  169.         while (isdigit(*s2))
  170.             n2 = n2*10 + (*s2++ - '0');
  171.                 /* skip '.' */
  172.                 if (*s2=='.') s2++;
  173.  
  174.         } while ((n1==n2) && (*s1!='\0') && (*s2!='\0'));
  175.  
  176.         if (((*s1=='\0') && (*s2=='\0')) || (n1!=n2))
  177.                 return (n1 - n2);
  178.         /*now n1==n2 and one of s1 or s2 is shorter*/
  179.         /*give precedence to shorter one*/
  180.         if (*s1=='\0') return 1;
  181.         else           return -1;
  182.  
  183. }
  184.  
  185.  
  186.  
  187. int cmpnumfld(num1, num2, fld)
  188.     const char *num1, *num2;
  189.     unsigned fld;
  190. /* compares the two dotted numbers at field fld and returns
  191.  * num1[fld]-num2[fld]. Assumes that num1 and num2 have at least fld fields.
  192.  * fld must be positive.
  193. */
  194. {
  195.     register const char *s1, *s2;
  196.     register unsigned n1, n2;
  197.  
  198.     s1 = num1;
  199.     s2 = num2;
  200.         /* skip fld-1 fields */
  201.     for (n1 = fld;  (--n1);  ) {
  202.         while (*s1++ != '.')
  203.             ;
  204.         while (*s2++ != '.')
  205.             ;
  206.     }
  207.         /* Now s1 and s2 point to the beginning of the respective fields */
  208.         /* compute numerical value and compare */
  209.         n1 = 0;
  210.     while (isdigit(*s1))
  211.         n1 = n1*10 + (*s1++ - '0');
  212.         n2 = 0;
  213.     while (isdigit(*s2))
  214.         n2 = n2*10 + (*s2++ - '0');
  215.     return n1<n2 ? -1 : n1==n2 ? 0 : 1;
  216. }
  217.  
  218.  
  219.     int
  220. compartial(num1, num2, length)
  221.     const char *num1, *num2;
  222.     unsigned length;
  223.  
  224. /*   compare the first "length" fields of two dot numbers;
  225.      the omitted field is considered to be larger than any number  */
  226. /*   restriction:  at least one number has length or more fields   */
  227.  
  228. {
  229.     register const char *s1, *s2;
  230.         register        int     n1, n2;
  231.  
  232.  
  233.         s1 = num1;      s2 = num2;
  234.         if ( s1==nil || *s1 == '\0' ) return 1;
  235.         if ( s2==nil || *s2 == '\0' ) return -1;
  236.  
  237.     for (;;) {
  238.             n1 = 0;
  239.         while (isdigit(*s1))
  240.         n1 = n1*10 + (*s1++ - '0');
  241.             if ( *s1 == '.' ) s1++;    /*  skip .   */
  242.  
  243.             n2 = 0;
  244.         while (isdigit(*s2))
  245.         n2 = n2*10 + (*s2++ - '0');
  246.             if (*s2 == '.') s2++;
  247.  
  248.         if ( n1 != n2 ) return n1-n2;
  249.         if ( --length == 0 ) return 0;
  250.         if ( *s1 == '\0' ) return 1;
  251.         if ( *s2 == '\0' ) return -1;
  252.     }
  253. }
  254.  
  255.  
  256. char * partialno(rev1,rev2,length)
  257.     struct buf *rev1;
  258.     const char *rev2;
  259.     register unsigned length;
  260. /* Function: Copies length fields of revision number rev2 into rev1.
  261.  * Return rev1's string.
  262.  */
  263. {
  264.     register char *r1;
  265.  
  266.     bufscpy(rev1, rev2);
  267.     r1 = rev1->string;
  268.         while (length) {
  269.         while (*r1!='.' && *r1)
  270.             ++r1;
  271.         ++r1;
  272.                 length--;
  273.         }
  274.         /* eliminate last '.'*/
  275.         *(r1-1)='\0';
  276.     return rev1->string;
  277. }
  278.  
  279.  
  280.  
  281.  
  282.     static void
  283. store1(store, next)
  284.     struct hshentries ***store;
  285.     struct hshentry *next;
  286. /*
  287.  * Allocate a new list node that addresses NEXT.
  288.  * Append it to the list that **STORE is the end pointer of.
  289.  */
  290. {
  291.     register struct hshentries *p;
  292.  
  293.     p = ftalloc(struct hshentries);
  294.     p->first = next;
  295.     **store = p;
  296.     *store = &p->rest;
  297. }
  298.  
  299. struct hshentry * genrevs(revno,date,author,state,store)
  300.     const char *revno, *date, *author, *state;
  301.     struct hshentries **store;
  302. /* Function: finds the deltas needed for reconstructing the
  303.  * revision given by revno, date, author, and state, and stores pointers
  304.  * to these deltas into a list whose starting address is given by store.
  305.  * The last delta (target delta) is returned.
  306.  * If the proper delta could not be found, nil is returned.
  307.  */
  308. {
  309.     unsigned length;
  310.         register struct hshentry * next;
  311.         int result;
  312.     const char *branchnum;
  313.     struct buf t;
  314.  
  315.     bufautobegin(&t);
  316.  
  317.     if (!(next = Head)) {
  318.         error("RCS file empty");
  319.         goto norev;
  320.         }
  321.  
  322.         length = countnumflds(revno);
  323.  
  324.         if (length >= 1) {
  325.                 /* at least one field; find branch exactly */
  326.         while ((result=cmpnumfld(revno,next->num,1)) < 0) {
  327.             store1(&store, next);
  328.                         next = next->next;
  329.             if (!next) {
  330.                 error("branch number %s too low", partialno(&t,revno,1));
  331.                 goto norev;
  332.             }
  333.                 }
  334.  
  335.         if (result>0) {
  336.             error("branch number %s absent", partialno(&t,revno,1));
  337.             goto norev;
  338.         }
  339.         }
  340.         if (length<=1){
  341.                 /* pick latest one on given branch */
  342.                 branchnum = next->num; /* works even for empty revno*/
  343.                 while ((next!=nil) &&
  344.                        (cmpnumfld(branchnum,next->num,1)==0) &&
  345.                        !(
  346.                         (date==nil?1:(cmpnum(date,next->date)>=0)) &&
  347.                         (author==nil?1:(strcmp(author,next->author)==0)) &&
  348.                         (state ==nil?1:(strcmp(state, next->state) ==0))
  349.                         )
  350.                        )
  351.         {
  352.             store1(&store, next);
  353.                         next=next->next;
  354.                 }
  355.                 if ((next==nil) ||
  356.                     (cmpnumfld(branchnum,next->num,1)!=0))/*overshot*/ {
  357.             error("can't find revision on branch %s with a date before %s, author %s, and state %s",
  358.                 length ? revno : partialno(&t,branchnum,1),
  359.                 date ? date : "<now>",
  360.                                 author==nil?"<any>":author, state==nil?"<any>":state);
  361.             goto norev;
  362.                 } else {
  363.             store1(&store, next);
  364.                 }
  365.                 *store = nil;
  366.                 return next;
  367.         }
  368.  
  369.         /* length >=2 */
  370.         /* find revision; may go low if length==2*/
  371.     while ((result=cmpnumfld(revno,next->num,2)) < 0  &&
  372.                (cmpnumfld(revno,next->num,1)==0) ) {
  373.         store1(&store, next);
  374.                 next = next->next;
  375.         if (!next)
  376.             break;
  377.         }
  378.  
  379.         if ((next==nil) || (cmpnumfld(revno,next->num,1)!=0)) {
  380.         error("revision number %s too low", partialno(&t,revno,2));
  381.         goto norev;
  382.         }
  383.         if ((length>2) && (result!=0)) {
  384.         error("revision %s absent", partialno(&t,revno,2));
  385.         goto norev;
  386.         }
  387.  
  388.         /* print last one */
  389.     store1(&store, next);
  390.  
  391.         if (length>2)
  392.                 return genbranch(next,revno,length,date,author,state,store);
  393.         else { /* length == 2*/
  394.                 if ((date!=nil) && (cmpnum(date,next->date)<0)){
  395.                         error("Revision %s has date %s.",next->num, next->date);
  396.                         return nil;
  397.                 }
  398.                 if ((author!=nil)&&(strcmp(author,next->author)!=0)) {
  399.                         error("Revision %s has author %s.",next->num,next->author);
  400.                         return nil;
  401.                 }
  402.                 if ((state!=nil)&&(strcmp(state,next->state)!=0)) {
  403.                         error("Revision %s has state %s.",next->num,
  404.                                next->state==nil?"<empty>":next->state);
  405.                         return nil;
  406.                 }
  407.                 *store=nil;
  408.                 return next;
  409.         }
  410.     norev:
  411.     bufautoend(&t);
  412.     return nil;
  413. }
  414.  
  415.  
  416.  
  417.  
  418.     static struct hshentry *
  419. genbranch(bpoint, revno, length, date, author, state, store)
  420.     const struct hshentry *bpoint;
  421.     const char *revno;
  422.     unsigned length;
  423.     const char *date, *author, *state;
  424.     struct hshentries **store;
  425. /* Function: given a branchpoint, a revision number, date, author, and state,
  426.  * genbranch finds the deltas necessary to reconstruct the given revision
  427.  * from the branch point on.
  428.  * Pointers to the found deltas are stored in a list beginning with store.
  429.  * revno must be on a side branch.
  430.  * return nil on error
  431.  */
  432. {
  433.     unsigned field;
  434.         register struct hshentry * next, * trail;
  435.     register const struct branchhead *bhead;
  436.         int result;
  437.     struct buf t;
  438.  
  439.     field = 3;
  440.         bhead = bpoint->branches;
  441.  
  442.     do {
  443.         if (!bhead) {
  444.             bufautobegin(&t);
  445.             error("no side branches present for %s", partialno(&t,revno,field-1));
  446.             bufautoend(&t);
  447.             return nil;
  448.         }
  449.  
  450.                 /*find branch head*/
  451.                 /*branches are arranged in increasing order*/
  452.         while (0 < (result=cmpnumfld(revno,bhead->hsh->num,field))) {
  453.                         bhead = bhead->nextbranch;
  454.             if (!bhead) {
  455.                 bufautobegin(&t);
  456.                 error("branch number %s too high",partialno(&t,revno,field));
  457.                 bufautoend(&t);
  458.                 return nil;
  459.             }
  460.                 }
  461.  
  462.         if (result<0) {
  463.             bufautobegin(&t);
  464.             error("branch number %s absent", partialno(&t,revno,field));
  465.             bufautoend(&t);
  466.             return nil;
  467.         }
  468.  
  469.                 next = bhead->hsh;
  470.                 if (length==field) {
  471.                         /* pick latest one on that branch */
  472.                         trail=nil;
  473.                         do { if ((date==nil?1:(cmpnum(date,next->date)>=0)) &&
  474.                                  (author==nil?1:(strcmp(author,next->author)==0)) &&
  475.                                  (state ==nil?1:(strcmp(state, next->state) ==0))
  476.                              ) trail = next;
  477.                              next=next->next;
  478.                         } while (next!=nil);
  479.  
  480.                         if (trail==nil) {
  481.                  error("can't find revision on branch %s with a date before %s, author %s, and state %s",
  482.                                         revno, date==nil?"<now>":date,
  483.                                         author==nil?"<any>":author, state==nil?"<any>":state);
  484.                              return nil;
  485.                         } else { /* print up to last one suitable */
  486.                              next = bhead->hsh;
  487.                              while (next!=trail) {
  488.                   store1(&store, next);
  489.                                   next=next->next;
  490.                              }
  491.                  store1(&store, next);
  492.                         }
  493.             *store = nil;
  494.                         return next;
  495.                 }
  496.  
  497.                 /* length > field */
  498.                 /* find revision */
  499.                 /* check low */
  500.                 if (cmpnumfld(revno,next->num,field+1)<0) {
  501.             bufautobegin(&t);
  502.             error("revision number %s too low", partialno(&t,revno,field+1));
  503.             bufautoend(&t);
  504.                         return(nil);
  505.                 }
  506.         do {
  507.             store1(&store, next);
  508.                         trail = next;
  509.                         next = next->next;
  510.                 } while ((next!=nil) &&
  511.                        (cmpnumfld(revno,next->num,field+1) >=0));
  512.  
  513.                 if ((length>field+1) &&  /*need exact hit */
  514.                     (cmpnumfld(revno,trail->num,field+1) !=0)){
  515.             bufautobegin(&t);
  516.             error("revision %s absent", partialno(&t,revno,field+1));
  517.             bufautoend(&t);
  518.                         return(nil);
  519.                 }
  520.                 if (length == field+1) {
  521.                         if ((date!=nil) && (cmpnum(date,trail->date)<0)){
  522.                                 error("Revision %s has date %s.",trail->num, trail->date);
  523.                                 return nil;
  524.                         }
  525.                         if ((author!=nil)&&(strcmp(author,trail->author)!=0)) {
  526.                                 error("Revision %s has author %s.",trail->num,trail->author);
  527.                                 return nil;
  528.                         }
  529.                         if ((state!=nil)&&(strcmp(state,trail->state)!=0)) {
  530.                                 error("Revision %s has state %s.",trail->num,
  531.                                        trail->state==nil?"<empty>":trail->state);
  532.                                 return nil;
  533.                         }
  534.                 }
  535.                 bhead = trail->branches;
  536.  
  537.     } while ((field+=2) <= length);
  538.         * store = nil;
  539.         return trail;
  540. }
  541.  
  542.  
  543.     static const char *
  544. lookupsym(id)
  545.     const char *id;
  546. /* Function: looks up id in the list of symbolic names starting
  547.  * with pointer SYMBOLS, and returns a pointer to the corresponding
  548.  * revision number. Returns nil if not present.
  549.  */
  550. {
  551.     register const struct assoc *next;
  552. #if HEAD_REV
  553.     if (!strcmp(id,"head")) {
  554.         if (Head) return Head->num;
  555.         else return nil;
  556.     }
  557. #endif
  558.         next = Symbols;
  559.         while (next!=nil) {
  560.                 if (strcmp(id, next->symbol)==0)
  561.             return next->num;
  562.                 else    next=next->nextassoc;
  563.         }
  564.         return nil;
  565. }
  566.  
  567. int expandsym(source, target)
  568.     const char *source;
  569.     struct buf *target;
  570. /* Function: Source points to a revision number. Expandsym copies
  571.  * the number to target, but replaces all symbolic fields in the
  572.  * source number with their numeric values.
  573.  * A trailing '.' is omitted; leading zeroes are compressed.
  574.  * returns false on error;
  575.  */
  576. {
  577.     register const char *sp;
  578.     register char *tp;
  579.     const char *tlim;
  580.         register enum tokens d;
  581.  
  582.     bufalloc(target, 1);
  583.     tp = target->string;
  584.     sp = source;
  585.         if (sp == nil) { /*accept nil pointer as a legal value*/
  586.                 *tp='\0';
  587.                 return true;
  588.         }
  589.     tlim = tp + target->size;
  590.  
  591.         while (*sp != '\0') {
  592.         switch (ctab[(unsigned char)*sp]) {
  593.             case DIGIT:
  594.                         if (*sp=='0') {
  595.                                 /* skip leading zeroes */
  596.                                 sp++;
  597.                                 while(*sp == '0') sp++;
  598.                 if (!*sp || *sp=='.') --sp; /* single zero */
  599.                         }
  600.             while (isdigit(*sp)) {
  601.                 if (tlim <= tp)
  602.                     tp = bufenlarge(target, &tlim);
  603.                 *tp++ = *sp++;
  604.             }
  605.             if (tlim <= tp)
  606.                 tp = bufenlarge(target, &tlim);
  607.                         if ((*sp == '\0') || ((*sp=='.')&&(*(sp+1)=='\0'))) {
  608.                                 *tp='\0'; return true;
  609.                         }
  610.             if (*sp != '.')
  611.                 goto improper;
  612.             *tp++ = *sp++;
  613.             break;
  614.  
  615.             case LETTER:
  616.             case Letter:
  617.             {
  618.             register char *bp = tp;
  619.             register size_t s = tp - target->string;
  620.             do {
  621.                 if (tlim <= bp)
  622.                     bp = bufenlarge(target, &tlim);
  623.                 *bp++ = *sp++;
  624.             } while ((d=ctab[(unsigned char)*sp])==LETTER ||
  625.                   d==Letter || d==DIGIT ||
  626.                               (d==IDCHAR));
  627.             if (tlim <= bp)
  628.                 bp = bufenlarge(target, &tlim);
  629.                         *bp= '\0';
  630.             tp = target->string + s;
  631.             }
  632.             {
  633.             register const char *bp = lookupsym(tp);
  634.                         if (bp==nil) {
  635.                 error("Symbolic number %s is undefined.", tp);
  636.                                 return false;
  637.                         } else { /* copy number */
  638.                 do {
  639.                     if (tlim <= tp)
  640.                         tp = bufenlarge(target, &tlim);
  641.                 } while ((*tp++ = *bp++));
  642.                         }
  643.             }
  644.                         if ((*sp == '\0') || ((*sp=='.')&&(*(sp+1)=='\0')))
  645.                                 return true;
  646.             if (*sp++ != '.')
  647.                 goto improper;
  648.             tp[-1] = '.';
  649.             break;
  650.  
  651.             default:
  652.             improper:
  653.             error("improper revision number: %s", source);
  654.                         return false;
  655.                 }
  656.         }
  657.     if (tlim<=tp)
  658.         tp = bufenlarge(target,&tlim);
  659.         *tp = '\0';
  660.         return true;
  661. }
  662.  
  663.  
  664.  
  665. #ifdef REVTEST
  666.  
  667. const char cmdid[] = "revtest";
  668.  
  669.     int
  670. main(argc,argv)
  671. int argc; char * argv[];
  672. {
  673.     static struct buf numricrevno;
  674.     char symrevno[100];       /* used for input of revision numbers */
  675.         char author[20];
  676.         char state[20];
  677.         char date[20];
  678.     struct hshentries *gendeltas;
  679.         struct hshentry * target;
  680.         int i;
  681.  
  682.         if (argc<2) {
  683.         aputs("No input file\n",stderr);
  684.         exitmain(EXIT_FAILURE);
  685.         }
  686.         if ((finptr=fopen(argv[1], "r")) == NULL) {
  687.         faterror("can't open input file %s", argv[1]);
  688.         }
  689.         Lexinit();
  690.         getadmin();
  691.  
  692.         gettree();
  693.  
  694.         getdesc(false);
  695.  
  696.         do {
  697.                 /* all output goes to stderr, to have diagnostics and       */
  698.                 /* errors in sequence.                                      */
  699.         aputs("\nEnter revision number or <return> or '.': ",stderr);
  700.                 if(gets(symrevno)==NULL) break;
  701.                 if (*symrevno == '.') break;
  702.         aprintf(stderr,"%s;\n",symrevno);
  703.         expandsym(symrevno,&numricrevno);
  704.         aprintf(stderr,"expanded number: %s; ",numricrevno.string);
  705.         aprintf(stderr,"Date: ");
  706.         gets(date); aprintf(stderr,"%s; ",date);
  707.         aprintf(stderr,"Author: ");
  708.         gets(author); aprintf(stderr,"%s; ",author);
  709.         aprintf(stderr,"State: ");
  710.         gets(state); aprintf(stderr, "%s;\n", state);
  711.         target = genrevs(numricrevno.string, *date?date:(char *)nil, *author?author:(char *)nil,
  712.                  *state?state:(char*)nil, &gendeltas);
  713.                 if (target!=nil) {
  714.             while (gendeltas) {
  715.                 aprintf(stderr,"%s\n",gendeltas->first->num);
  716.                 gendeltas = gendeltas->next;
  717.                         }
  718.                 }
  719.         } while (true);
  720.     aprintf(stderr,"done\n");
  721.     exitmain(EXIT_SUCCESS);
  722. }
  723.  
  724. exiting void exiterr() { _exit(EXIT_FAILURE); }
  725.  
  726. #endif
  727.