home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OS9000
/
APPS
/
rcs.lzh
/
rcs1
/
rcsgen.a
< prev
next >
Wrap
Text File
|
1996-04-20
|
31KB
|
1,244 lines
psect rcsgen_c,0,0,0,0,0
nam rcsgen_c
* /*
* #ifndef lint
* static char rcsid[]= "$Id: rcsgen.c_v 1.2 96/04/07 00:23:11 hiro Exp $ Purdue CS";
vsect
rcsid dc.b "$Id: rcsgen.c_v 1.2 96/04/07 00:23:11 hiro Exp $ Purdue CS",$0
ends
* #endif
*
* /* Copyright (C) 1982, 1988, 1989 Walter Tichy
*
*
*
* /* $Log: rcsgen.c_v $
*
*
*
*
* #include "rcsbase.h"
* /*
* #define RCSBASE "$Id: rcsbase.h_v 1.2 96/04/07 00:17:24 hiro Exp $"
*
* /* Copyright (C) 1982, 1988, 1989 Walter Tichy
*
*
*
* /*****************************************************************************
*
*
* /* $Log: rcsbase.h_v $
*
* #if defined(_OS9000) && !defined(OSK)
* #define OSK 1
* #endif
*
* #include <stdio.h>
* /* type lengths regardless of compiler in use:
*
* typedef short WORD; /* always 16 bits */
*
* #ifdef OSK
* # define BUFSIZ 512
* # define _NFILE 32
* #else
* # ifdef OS9
* # define BUFSIZ 256
* # define _NFILE 16
* # endif
* #endif
*
* typedef struct _iobuf {
* char *_ptr, /* buffer pointer */
* *_base, /* buffer base address */
* *_end; /* buffer end address */
* WORD _flag; /* file status */
* WORD _fd; /* file path number */
* char _save; /* for 'ungetc' when unbuffered */
* WORD _bufsiz; /* size of data buffer */
* int (*_ifunc)();/* function to use for input */
* int (*_ofunc)();/* function to use for output */
* } FILE;
*
* extern FILE _iob[_NFILE];
*
* /* the following are fake pointer variable defintions */
* #define stdin (&_iob[0])
* #define stdout (&_iob[1])
* #define stderr (&_iob[2])
*
* #define _READ 1
* #define _WRITE 2
* #define _UNBUF 4
* #define _BIGBUF 8
* #define _EOF 0x10
* #define _ERR 0x20
* #define _SCF 0x40
* #define _RBF 0x80
* #define _DEVMASK 0xc0
* #define _WRITTEN 0x0100 /* buffer written in update mode */
* #define _MYBUF 0x0200 /* system allocated buffer */
* #define _INIT 0x8000 /* _iob initialized */
*
* #define EOF (-1)
* #define EOL 13
* #define NULL 0
*
* #ifdef OSK
* #define PMODE READ|WRITE /* r/w for owner */
* #else
* #define PMODE 0xb /* r/w for owner, r for others */
* #endif
*
* #define fgetc getc
* #define putchar(c) putc(c,stdout)
* #define getchar() getc(stdin)
* #define ferror(p) ((p)->_flag&_ERR)
* #define feof(p) ((p)->_flag&_EOF)
* #define clearerr(p) ((p)->_flag&=~_ERR)
* #define cleareof(p) ((p)->_flag&=~_EOF)
* #define fileno(p) ((p)->_fd)
*
* extern FILE *fopen(), *fdopen(), *freopen();
* extern char *fgets(), *gets();
* extern long ftell();
* #ifdef USG
* #include <string.h>
* #else
* #include <strings.h>
* /*
*
* extern char *strcat(),*strncat(),*strcpy();
* extern char *strncpy(),*index(),*rindex();
* extern int strcmp(),strncmp(),strlen();
* #endif
* #ifndef OSK
* #undef putc /* will be redefined */
* #endif
*
* #ifndef cleareof
* #define cleareof(s) _cleareof(s)
* #endif
* #ifndef clearerr
* #define clearerr(s) _clearerr(s)
* #endif
* #ifndef fileno
* #define fileno(s) _fileno(s)
* #endif
* #ifndef EOS_SHARE
* #define EOS_SHARE E_SHARE
* #endif
*
* #if defined(_UCC) || defined(_OS9000)
* #define environ _environ
* #endif
*
* #ifdef USG
* # define rindex strrchr
* # define DATEFORM "%.2d.%.2d.%.2d.%.2d.%.2d.%.2d"
* #else
* # define DATEFORM "%02d.%02d.%02d.%02d.%02d.%02d"
* #endif
* /* Make sure one of %02d or %.2d prints a number with a field width 2, with
*
* #define PRINTDATE(file,date) fprintf(file,"%.2s/%.2s/%.2s",date,date+3,date+6)
* #define PRINTTIME(file,date) fprintf(file,"%.2s:%.2s:%.2s",date+9,date+12,date+15)
* /* print RCS format date and time in nice format from a string */
*
* /*
* #define BYTESIZ 8 /* number of bits in a byte */
*
* /*#define STRICT_LOCKING 0 /* 0 sets the default locking to non-strict; */
* /* used in experimental environments. */
* /* 1 sets the default locking to strict; */
* /* used in production environments. */
* /* STRICT_LOCKING is set in the Makefile! */
* #ifndef hshsize
* #define hshsize 239 /* hashtable size; MUST be prime and -1 mod 4 */
* /* other choices: 547 or 719 */
* #endif
*
* #define strtsize (hshsize * 50) /* string table size */
* #ifdef SMALLOG
* # define logsize 1024 /* max. size of log message for pdp11 */
* #else
* # define logsize 4096 /* max. size of log message for others */
* #endif
* #define revlength 30 /* max. length of revision numbers */
* #define datelength 20 /* length of a date in RCS format */
* #define joinlength 20 /* number of joined revisions permitted */
* #ifdef MSDOS /* Added by $Author: hiro $ */
* #define RCSDIR "RCS\\" /* subdirectory for RCS files */
* #else
* #define RCSDIR "RCS/" /* subdirectory for RCS files */
* #endif /* MSDOS */
* #ifdef MSDOS /* Added by $Author: hiro $ */
* #define RCSSUF '\0' /* suffix for RCS files */
* #define RCSSEP '\0' /* separator for RCSSUF */
* #else
* #ifdef OSK
* #define RCSSUF 'v' /* suffix for RCS files */
* #define RCSSEP '_' /* separator for RCSSUF */
* #else
* #define RCSSUF 'v' /* suffix for RCS files */
* #define RCSSEP ',' /* separator for RCSSUF */
* #endif /* OSK */
* #endif /* MSDOS */
* #define KDELIM '$' /* delimiter for keywords */
* #define VDELIM ':' /* separates keywords from values */
* #define DEFAULTSTATE "Exp" /* default state of revisions */
* #ifdef V4_2BSD
* # define NCPFN 256 /* number of characters per filename */
* # define NCPPN 1024 /* number of characters per pathname */
* #else
* #ifdef MSDOS /* Added by $Author: hiro $ */
* # define NCPFN 13 /* number of characters per filename */
* # define NCPPN 66 /* number of characters per pathname */
* #else
* #ifdef OSK
* # define NCPFN 28 /* number of characters per filename */
* # define NCPPN 6*NCPFN /* number of characters per pathname */
* #else
* # define NCPFN 14 /* number of characters per filename */
* # define NCPPN 6*NCPFN /* number of characters per pathname */
* #endif /* OSK */
* #endif /* MSDOS */
* #endif
* #define keylength 20 /* buffer length for expansion keywords */
* #define keyvallength NCPPN+revlength+datelength+60
* /* buffer length for keyword expansion */
*
*
*
* #define true 1
* #define false 0
* #define nil 0
* #define elsif else if
* #define elif else if
*
*
* /* temporary file names */
*
* #ifdef MSDOS /* Added by $Author: hiro $ */
* #define NEWRCSFILE "nwXXXXXX"
* #define DIFFILE "ciXXXXXX"
* #define TMPFILE1 "t1XXXXXX"
* #define TMPFILE2 "t2XXXXXX"
* #define TMPFILE3 "t3XXXXXX"
* #define JOINFIL2 "j2XXXXXX"
* #define JOINFIL3 "j3XXXXXX"
* #else
* #ifdef OSK
* #define NEWRCSFILE "_RCSnewXXXXXX"
* #define DIFFILE "_RCSciXXXXXX"
* #define TMPFILE1 "_RCSt1XXXXXX"
* #define TMPFILE2 "_RCSt2XXXXXX"
* #define TMPFILE3 "_RCSt3XXXXXX"
* #define JOINFIL2 "_RCSj2XXXXXX"
* #define JOINFIL3 "_RCSj3XXXXXX"
* #else
* #define NEWRCSFILE ",RCSnewXXXXXX"
* #define DIFFILE ",RCSciXXXXXX"
* #define TMPFILE1 ",RCSt1XXXXXX"
* #define TMPFILE2 ",RCSt2XXXXXX"
* #define TMPFILE3 ",RCSt3XXXXXX"
* #define JOINFIL2 ",RCSj2XXXXXX"
* #define JOINFIL3 ",RCSj3XXXXXX"
* #endif /* OSK */
* #endif /* MSDOS */
*
* #ifndef OSK
* #define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):fflsbuf((unsigned)(x),p))
* /* This version of putc prints a char, but aborts on write error */
* #endif
*
* #define GETC(in,out,echo) (c=getc(in), echo?putc(c,out):c)
* /* GETC modifies a local variable c; a kludge, but smaller and faster. */
* /* GETC writes a del-character (octal 177) on end of file */
*
* #ifdef MSDOS
* #define WORKMODE(RCSmode) (RCSmode & ~S_IWRITE)|((lockflag||!StrictLocks)? ( S_IWRITE | S_IREAD ) : 0000 )
* #else
* #ifdef OSK
* #ifdef _OS9000
* #define WORKMODE(RCSmode) ( RCSmode&~(S_IWRITE|S_IGWRITE|S_IOWRITE)) | ( (lockflag||!StrictLocks) ? S_IWRITE|S_IREAD : 0 )
* #else
* #define WORKMODE(RCSmode) ( RCSmode&~0x12) | ( (lockflag||!StrictLocks) ? 0x02 : 0 )
* #endif
* #else
* #define WORKMODE(RCSmode) (RCSmode&~0222)|((lockflag||!StrictLocks)?0600:0000)
* #endif
* #endif /* MSDOS */
* /* computes mode of working file: same as RCSmode, but write permission */
* /* determined by lockflag and StrictLocks. */
*
*
* /* character classes and token codes */
* enum tokens {
* /* char classes*/ DIGIT, IDCHAR, NEWLN, LETTER, PERIOD, SBEGIN, SPACE, UNKN,
* /* tokens */ COLON, DATE, EOFILE, ID, KEYW, NUM, SEMI, STRING,
* };
*
* #define AT SBEGIN /* class SBEGIN (string begin) is returned by lex. anal. */
* #define SDELIM '@' /* the actual character is needed for string handling*/
* /* these must be changed consistently, for instance to:
*
* /* other characters */
*
* #define ACCENT IDCHAR
* #define AMPER IDCHAR
* #define BACKSL IDCHAR
* #define BAR IDCHAR
* #define COMMA UNKN
* #define DIVIDE IDCHAR
* #define DOLLAR UNKN /* overlap with KDELIM */
* #define DQUOTE IDCHAR
* #define EQUAL IDCHAR
* #define EXCLA IDCHAR
* #define GREAT IDCHAR
* #define HASH IDCHAR
* #define INSERT UNKN
* #define LBRACE IDCHAR
* #define LBRACK IDCHAR
* #define LESS IDCHAR
* #define LPARN IDCHAR
* #define MINUS IDCHAR
* #define PERCNT IDCHAR
* #define PLUS IDCHAR
* #define QUEST IDCHAR
* #define RBRACE IDCHAR
* #define RBRACK IDCHAR
* #define RPARN IDCHAR
* #define SQUOTE IDCHAR
* #define TILDE IDCHAR
* #define TIMES IDCHAR
* #define UNDER IDCHAR
* #define UPARR IDCHAR
*
*
*
*
* /***************************************
*
*
* /* Hash table entry */
* struct hshentry {
* char * num; /* pointer to revision number (ASCIZ) */
* char * date; /* pointer to date of checking */
* char * author; /* login of person checking in */
* char * lockedby; /* who locks the revision */
* char * log; /* log message requested at checkin */
* char * state; /* state of revision (Exp by default) */
* struct branchhead * branches; /* list of first revisions on branches*/
* struct hshentry * next; /* next revision on same branch */
* int insertlns;/* lines inserted (computed by rlog) */
* int deletelns;/* lines deleted (computed by rlog) */
* char selector; /* marks entry for selection/deletion */
* };
*
* /* list element for branch lists */
* struct branchhead {
* struct hshentry * hsh;
* struct branchhead * nextbranch;
* };
*
* /* accesslist element */
* struct access {
* char * login;
* struct access * nextaccess;
* };
*
* /* list element for locks */
* struct lock {
* char * login;
* struct hshentry * delta;
* struct lock * nextlock;
* };
*
* /* list element for symbolic names */
* struct assoc {
* char * symbol;
* struct hshentry * delta;
* struct assoc * nextassoc;
* };
*
*
* /* common variables (getadmin and getdelta())*/
* extern char * Comment;
* extern struct access * AccessList;
* extern struct assoc * Symbols;
* extern struct lock * Locks;
* extern struct hshentry * Head;
* extern struct hshentry * Dbranch;
* extern int StrictLocks;
* extern int TotalDeltas;
* #ifndef lint
* static char copyright[]="Copyright (C) 1982 by Walter F. Tichy";
vsect
copyright dc.b "Copyright (C) 1982 by Walter F. Tichy",$0
ends
* #endif
*
* /* common variables (lexical analyzer)*/
* extern enum tokens map[];
* #define ctab (&map[1])
* extern enum tokens nexttok;
* extern int hshenter;
* extern char * NextString;
* extern char * cmdid;
*
* #if defined(USG) || defined(V4_2BSD)
* #define VOID (void)
* #else
* #ifndef OSK
* typedef int void;
* #endif
* #define VOID
* #endif
*
* /* common routines */
* extern char *talloc();
* extern int serror();
* extern int faterror();
* extern int fatserror();
* extern void ignoreints();
* extern void catchints();
* extern void restoreints();
*
* #ifdef USG
* extern int sprintf();
* #endif
*
* /*
* #define AUTHOR "Author"
* #define DATE "Date"
* #define HEADER "Header"
* #define IDH "Id"
* #define LOCKER "Locker"
* #define LOG "Log"
* #define RCSFILE "RCSfile"
* #define REVISION "Revision"
* #define SOURCE "Source"
* #define STATE "State"
*
* enum markers { Nomatch, Author, Date, Header, Id,
* Locker, Log, RCSfile, Revision, Source, State };
*
* #define DELNUMFORM "\n\n%s\n%s\n"
* /* used by putdtext and scanlogtext */
* #define DELETE 'D'
* /* set by rcs -o and used by puttree() in rcssyn */
*
*
*
*
*
* extern struct hshentry * getnum();
* extern FILE * fopen();
* extern savestring();
* extern editstring();
*
* extern int nextc; /* next character from lexical analyzer */
* extern char Ktext[]; /* keywords from syntax analyzer */
* extern char Klog[]; /* Keyword "log" */
* extern char Kdesc[]; /* Keyword for description */
* extern FILE * frewrite; /* new RCS file */
* extern FILE * fcopy; /* result file during editing */
* extern char * resultfile; /* file name for fcopy */
* extern int rewriteflag; /* indicates whether to rewrite the input file */
* #if defined(MSDOS) || defined(OSK)
* extern char tmpdir[NCPPN];
* #endif /* MSDOS */
*
* char curlogmsg[logsize]; /* buffer for current log message */
vsect
curlogmsg: ds.b 4096
*
* enum stringwork {copy, edit, expand, edit_expand };
* /* parameter to scandeltatext() */
*
*
*
*
* char * buildrevision(deltas, target, dir, expandflag)
* struct hshentry ** deltas, * target;
ends
* char * dir; int expandflag;
* /* Function: Generates the revision given by target
* {
ttl buildrev
buildrevision: link a5,#0
movem.l #_1!3,-(sp)
move.l #_3,d0 :6
bsr _stkcheck
* int i;
*
* if (deltas[0]==target) {
subq.l #4,sp :2
movea.l 4(sp),a0
move.l 8(sp),d0
cmp.l (a0),d0 :2
bne _6
_5
* /* only latest revision to generate */
* if (dir==nil) {/* print directly to stdout */
tst.l 4+_2(sp)
bne _8
_7
* fcopy=stdout;
* scandeltatext(target,expand);
* return(char *) true;
lea _iob+28(a6),a0
move.l a0,fcopy(a6)
moveq.l #2,d1 :2
move.l 8(sp),d0
bsr scandeltatext
moveq.l #1,d0 :2
addq.l #4,sp :2
bra _4
* } else {
bra _9
_8
* initeditfiles(dir);
* scandeltatext(target,expandflag?expand:copy);
* ffclose(fcopy);
* return(resultfile);
move.l 4+_2(sp),d0
bsr initeditfiles
tst.l 8+_2(sp)
beq _10
_11
moveq.l #2,d0 :2
bra _12
_10
moveq.l #0,d0 :2
_12
move.l d0,d1 :2
move.l 8(sp),d0
bsr scandeltatext
move.l fcopy(a6),d0
bsr ffclose
move.l resultfile(a6),d0
addq.l #4,sp :2
bra _4
* }
* } else {
_9
bra _13
_6
* /* several revisions to generate */
* #if defined(MSDOS) || defined(OSK)
* initeditfiles(dir?dir: tmpdir);
* #else
* initeditfiles(dir?dir:"/tmp/");
* #endif /* MSDOS */
* /* write initial revision into fcopy, no keyword expansion */
* scandeltatext(deltas[0],copy);
* i = 1;
* while (deltas[i+1] != nil) {
tst.l 4+_2(sp)
beq _14
_15
movea.l 4+_2(sp),a0
bra _16
_14
lea tmpdir(a6),a0
_16
move.l a0,d0 :2
bsr initeditfiles
moveq.l #0,d1 :2
movea.l 4(sp),a0
move.l (a0),d0 :2
bsr scandeltatext
moveq.l #1,d0 :2
move.l d0,(sp) :2
bra _18
_19
* /* do all deltas except last one */
* scandeltatext(deltas[i++],edit);
* }
moveq.l #1,d1 :2
move.l (sp),d0 :2
addq.l #1,(sp) :2
lsl.l #2,d0 :2
movea.l 4(sp),a0
move.l 0(a0,d0.l),d0
bsr scandeltatext
* if (!expandflag) {
_18
move.l (sp),d0 :2
addq.l #1,d0 :2
lsl.l #2,d0 :2
movea.l 4(sp),a0
tst.l 0(a0,d0.l)
bne _19
_17
tst.l 8+_2(sp)
bne _21
_20
* /* no keyword expansion; only invoked from ci */
* scandeltatext(deltas[i],edit);
* finishedit((struct hshentry *)nil);
* ffclose(fcopy);
* } else {
moveq.l #1,d1 :2
move.l (sp),d0 :2
lsl.l #2,d0 :2
movea.l 4(sp),a0
move.l 0(a0,d0.l),d0
bsr scandeltatext
moveq.l #0,d0 :2
bsr finishedit
move.l fcopy(a6),d0
bsr ffclose
bra _22
_21
* /* perform keyword expansion*/
* /* first, get to beginning of file*/
* finishedit((struct hshentry *)nil); swapeditfiles(dir==nil);
* scandeltatext(deltas[i],edit_expand);
* finishedit(deltas[i]);
* if (dir!=nil) ffclose(fcopy);
moveq.l #0,d0 :2
bsr finishedit
tst.l 4+_2(sp)
bne _25
_26
moveq.l #1,d0 :2
bra _27
_25
moveq.l #0,d0 :2
_27
bsr swapeditfiles
moveq.l #3,d1 :2
move.l (sp),d0 :2
lsl.l #2,d0 :2
movea.l 4(sp),a0
move.l 0(a0,d0.l),d0
bsr scandeltatext
move.l (sp),d0 :2
lsl.l #2,d0 :2
movea.l 4(sp),a0
move.l 0(a0,d0.l),d0
bsr finishedit
tst.l 4+_2(sp)
beq _24
_23
* }
move.l fcopy(a6),d0
bsr ffclose
_24
* return(resultfile); /*doesn't matter for dir==nil*/
_22
move.l resultfile(a6),d0
addq.l #4,sp :2
bra _4
* }
* }
_13
addq.l #4,sp :2
_4
movem.l -4(a5),#_1
unlk a5
rts :2
_3 equ 0xffffffb8 :0
_1 equ 0x00000100 :0
_2 equ 0x00000014 :0
*
*
*
* scandeltatext(delta,func)
* struct hshentry * delta; enum stringwork func;
* /* Function: Scans delta text nodes up to and including the one given
* { struct hshentry * nextdelta;
ttl scandelt
scandeltatext: link a5,#0
movem.l #_28!3,-(sp)
move.l #_30,d0 :6
bsr _stkcheck
*
* do {
subq.l #4,sp :2
_34
* nextlex();
* if (!(nextdelta=getnum())) {
bsr nextlex
bsr getnum
move.l d0,(sp) :2
bne _36
_35
* fatserror("Can't find delta for revision %s", delta->num);
* }
movea.l 4(sp),a0
move.l (a0),d1 :2
lea _37(pc),a0
move.l a0,d0 :2
bsr fatserror
* if (!getkey(Klog) || nexttok!=STRING)
_36
* serror("Missing log entry");
lea Klog(a6),a0
move.l a0,d0 :2
bsr getkey
tst.l d0 :2
beq _38
_40
moveq.l #15,d0 :2
cmp.l nexttok(a6),d0
beq _39
_38
* elsif (delta==nextdelta) {
lea _41(pc),a0
move.l a0,d0 :2
bsr serror
bra _42
_39
move.l 4(sp),d0
cmp.l (sp),d0 :2
bne _44
_43
* VOID savestring(curlogmsg,logsize);
* delta->log=curlogmsg;
* } else {readstring();
move.l #4096,d1 :6
lea curlogmsg(a6),a0
move.l a0,d0 :2
bsr savestring
lea curlogmsg(a6),a0
movea.l 4(sp),a1
move.l a0,16(a1)
bra _45
_44
* delta->log= "";
* }
bsr readstring
lea _46(pc),a0
movea.l 4(sp),a1
move.l a0,16(a1)
* nextlex();
_45
_42
* if (!getkey(Ktext) || nexttok!=STRING)
* fatserror("Missing delta text");
bsr nextlex
lea Ktext(a6),a0
move.l a0,d0 :2
bsr getkey
tst.l d0 :2
beq _47
_49
moveq.l #15,d0 :2
cmp.l nexttok(a6),d0
beq _48
_47
*
* if(delta==nextdelta)
lea _50(pc),a0
move.l a0,d0 :2
bsr fatserror
_48
* /* got the one we're looking for */
* switch (func) {
move.l 4(sp),d0
cmp.l (sp),d0 :2
bne _52
_51
bra _54
* case copy: copystring();
_55
* break;
bsr copystring
bra _53
* case expand: xpandstring(delta);
_56
* break;
move.l 4(sp),d0
bsr xpandstring
bra _53
* case edit: editstring((struct hshentry *)nil);
_57
* break;
moveq.l #0,d0 :2
bsr editstring
bra _53
* case edit_expand: editstring(delta);
_58
* break;
move.l 4(sp),d0
bsr editstring
bra _53
* }
* else readstring(); /* skip over it */
_54
move.l 8(sp),d0
cmpi.l #3,d0 :6
bhi _53
add.w d0,d0 :2
move.w _59(pcr,d0.w),d0
jmp _59(pcr,d0.w)
_59
dc.w _55-_59 :2
dc.w _57-_59 :2
dc.w _56-_59 :2
dc.w _58-_59 :2
_53
bra _60
_52
*
* } while (delta!=nextdelta);
bsr readstring
_60
_32
move.l 4(sp),d0
cmp.l (sp),d0 :2
bne _34
_33
* }
addq.l #4,sp :2
_31
movem.l -8(a5),#_28
unlk a5
rts :2
_30 equ 0xffffffb8 :0
_28 equ 0x00000300 :0
_29 equ 0x00000018 :0
*
*
* int stdinread; /* stdinread>0 if redirected stdin has been read once */
vsect
stdinread: ds.l 1
*
* int ttystdin()
* {
ends
ttl ttystdin
ttystdin: link a5,#0
movem.l #_61!1,-(sp)
move.l #_63,d0 :6
bsr _stkcheck
* static int initialized, istty;
vsect
_65 ds.l 1
_66 ds.l 1
* if (!initialized) {
ends
tst.l _65(a6)
bne _68
_67
* istty = isatty(fileno(stdin));
* initialized = 1;
* }
movea.w _iob+14(a6),a0
move.l a0,d0 :2
bsr isatty
move.l d0,_66(a6)
moveq.l #1,d0 :2
move.l d0,_65(a6)
* return istty;
_68
move.l _66(a6),d0
bra _64
* }
nop :2
_64
movem.l -4(a5),#_61
unlk a5
rts :2
_63 equ 0xffffffbc :0
_61 equ 0x00000100 :0
_62 equ 0x00000010 :0
*
* void putdesc(initflag,textflag,textfile,quietflag)
* int initflag,textflag; char * textfile; int quietflag;
* /* Function: puts the descriptive text into file frewrite.
* { register FILE * txt; register int c, old1, old2;
ttl putdesc
putdesc: link a5,#0
movem.l #_69!3,-(sp)
move.l #_71,d0 :6
bsr _stkcheck
* register FILE * frew;
* #ifdef lint
* if (quietflag == 0) initflag = quietflag; /* silencelint */
* #endif
*
* frew = frewrite;
* if (!initflag && !textflag) {
movea.l frewrite(a6),a3
tst.l (sp) :2
bne _74
_75
tst.l 4(sp)
bne _74
_73
* /* copy old description */
* VOID fprintf(frew,"\n\n%s%c",Kdesc,nextc);
* rewriteflag=true; getdesc(false);
* } else {
move.l nextc(a6),-(sp)
pea Kdesc(a6)
lea _76(pc),a0
move.l a0,d1 :2
move.l a3,d0 :2
bsr fprintf
addq.l #8,sp :2
moveq.l #1,d0 :2
move.l d0,rewriteflag(a6)
moveq.l #0,d0 :2
bsr getdesc
bra _77
_74
* /* get new description */
* if (!initflag) {
tst.l (sp) :2
bne _79
_78
* /*skip old description*/
* rewriteflag=false; getdesc(false);
* }
clr.l rewriteflag(a6)
moveq.l #0,d0 :2
bsr getdesc
* VOID fprintf(frew,"\n\n%s\n%c",Kdesc,SDELIM);
_79
* if (textfile) {
pea 64.w
pea Kdesc(a6)
lea _82(pc),a0
move.l a0,d1 :2
move.l a3,d0 :2
bsr fprintf
addq.l #8,sp :2
tst.l -1048576+_70(sp)
beq _81
_80
* old1='\n';
* /* copy textfile */
* if ((txt=fopen(textfile,"r"))!=NULL) {
moveq.l #13,d5 :2
lea _85(pc),a0
move.l a0,d1 :2
move.l -1048576+_70(sp),d0
bsr fopen
movea.l d0,a2 :2
tst.l d0 :2
beq _84
_83
* while ((c=getc(txt))!=EOF) {
bra _87
_88
* if (c==SDELIM) VOID putc(c,frew); /*double up*/
moveq.l #64,d0 :2
cmp.l d4,d0 :2
bne _90
_89
* VOID putc(c,frew);
move.l a3,d1 :2
move.l d4,d0 :2
bsr putc
_90
* old1=c;
* }
move.l a3,d1 :2
move.l d4,d0 :2
bsr putc
move.l d4,d5 :2
* if (old1!='\n') VOID putc('\n',frew);
_87
move.l a2,d0 :2
bsr getc
move.l d0,d4 :2
moveq.l #-1,d1 :2
cmp.l d0,d1 :2
bne _88
_86
moveq.l #13,d0 :2
cmp.l d5,d0 :2
beq _92
_91
* VOID fclose(txt);
move.l a3,d1 :2
moveq.l #13,d0 :2
bsr putc
_92
* VOID putc(SDELIM,frew);
* VOID fputs("\n\n", frew);
* return;
move.l a2,d0 :2
bsr fclose
move.l a3,d1 :2
moveq.l #64,d0 :2
bsr putc
move.l a3,d1 :2
lea _93(pc),a0
move.l a0,d0 :2
bsr fputs
bra _72
* } else {
bra _94
_84
* error("Can't open file %s with description",textfile);
* if (!ttystdin()) return;
move.l -1048576+_70(sp),d1
lea _97(pc),a0
move.l a0,d0 :2
bsr error
bsr ttystdin
tst.l d0 :2
bne _96
_95
bra _72
* /* otherwise, get description from terminal */
* }
_96
* }
_94
* /* read text from stdin */
* if (ttystdin()) {
_81
bsr ttystdin
tst.l d0 :2
beq _99
_98
* #ifdef MSDOS
* VOID fputs("enter description, terminated with ^Z or '.':\n",stderr);
* #else
* #ifdef OSK
* VOID fputs("entern description , terminated with ESC or '.':\n",stderr);
* #else
* VOID fputs("enter description, terminated with ^D or '.':\n",stderr);
* #endif /* OSK */
* #endif /* MSDOS */
* VOID fputs("NOTE: This is NOT the log message!\n>> ",stderr);
* fflush(stderr);
* if (feof(stdin))
* clearerr(stdin);
lea _iob+56(a6),a0
move.l a0,d1 :2
lea _102(pc),a0
move.l a0,d0 :2
bsr fputs
lea _iob+56(a6),a0
move.l a0,d1 :2
lea _103(pc),a0
move.l a0,d0 :2
bsr fputs
lea _iob+56(a6),a0
move.l a0,d0 :2
bsr fflush
btst.b #4,_iob+13(a6) :6
beq _101
_100
* } else { /* redirected stdin */
andi.w #-33,_iob+12(a6) :6
_101
bra _104
_99
* if (stdinread>0)
* faterror("Can't reread redirected stdin for description; use -t<file>");
tst.l stdinread(a6)
ble _106
_105
* stdinread++;
lea _107(pc),a0
move.l a0,d0 :2
bsr faterror
_106
* }
addq.l #1,stdinread(a6)
* c = '\0'; old2= '\n';
_104
* if ((old1=getchar())==EOF) {
moveq.l #0,d4 :2
moveq.l #13,d6 :2
lea _iob(a6),a0
move.l a0,d0 :2
bsr getc
move.l d0,d5 :2
moveq.l #-1,d1 :2
cmp.l d0,d1 :2
bne _109
_108
* if (ttystdin()) {
bsr ttystdin
tst.l d0 :2
beq _111
_110
* VOID putc('\n',stderr);
* #ifdef OSK
* cleareof(stdin);
* #endif
* clearerr(stdin);
* }
lea _iob+56(a6),a0
move.l a0,d1 :2
moveq.l #13,d0 :2
bsr putc
andi.w #-17,_iob+12(a6) :6
andi.w #-33,_iob+12(a6) :6
* } else {
_111
bra _112
_109
* if (old1=='\n' && ttystdin())
* VOID fputs(">> ",stderr);
moveq.l #13,d0 :2
cmp.l d5,d0 :2
bne _114
_115
bsr ttystdin
tst.l d0 :2
beq _114
_113
* fflush(stderr);
lea _iob+56(a6),a0
move.l a0,d1 :2
lea _116(pc),a0
move.l a0,d0 :2
bsr fputs
_114
* for (;;) {
lea _iob+56(a6),a0
move.l a0,d0 :2
bsr fflush
_117
* c=getchar();
* if (c==EOF) {
lea _iob(a6),a0
move.l a0,d0 :2
bsr getc
move.l d0,d4 :2
moveq.l #-1,d0 :2
cmp.l d4,d0 :2
bne _120
_119
* if (ttystdin()) {
bsr ttystdin
tst.l d0 :2
beq _122
_121
* VOID putc('\n',stderr);
* #ifdef OSK
* cleareof(stdin);
* #endif
* clearerr(stdin);
* }
lea _iob+56(a6),a0
move.l a0,d1 :2
moveq.l #13,d0 :2
bsr putc
andi.w #-17,_iob+12(a6) :6
andi.w #-33,_iob+12(a6) :6
* VOID putc(old1,frew);
_122
* if (old1!='\n') VOID putc('\n',frew);
move.l a3,d1 :2
move.l d5,d0 :2
bsr putc
moveq.l #13,d0 :2
cmp.l d5,d0 :2
beq _124
_123
* break;
move.l a3,d1 :2
moveq.l #13,d0 :2
bsr putc
_124
bra _118
* }
* if (c=='\n' && old1=='.' && old2=='\n') {
_120
moveq.l #13,d0 :2
cmp.l d4,d0 :2
bne _126
_128
moveq.l #46,d0 :2
cmp.l d5,d0 :2
bne _126
_127
moveq.l #13,d0 :2
cmp.l d6,d0 :2
bne _126
_125
* break;
bra _118
* }
* if (c=='\n' && ttystdin()) VOID fputs(">> ",stderr);
_126
moveq.l #13,d0 :2
cmp.l d4,d0 :2
bne _130
_131
bsr ttystdin
tst.l d0 :2
beq _130
_129
* fflush(stderr);
lea _iob+56(a6),a0
move.l a0,d1 :2
lea _132(pc),a0
move.l a0,d0 :2
bsr fputs
_130
* if(old1==SDELIM) VOID putc(old1,frew); /* double up*/
lea _iob+56(a6),a0
move.l a0,d0 :2
bsr fflush
moveq.l #64,d0 :2
cmp.l d5,d0 :2
bne _134
_133
* VOID putc(old1,frew);
move.l a3,d1 :2
move.l d5,d0 :2
bsr putc
_134
* old2=old1;
* old1=c;
* } /* end for */
move.l a3,d1 :2
move.l d5,d0 :2
bsr putc
move.l d5,d6 :2
move.l d4,d5 :2
* }
bra _117
_118
* VOID putc(SDELIM,frew); VOID fputs("\n\n",frew);
_112
* }
move.l a3,d1 :2
moveq.l #64,d0 :2
bsr putc
move.l a3,d1 :2
lea _135(pc),a0
move.l a0,d0 :2
bsr fputs
* }
_77
_72
movem.l -24(a5),#_69
unlk a5
rts :2
_71 equ 0xffffffb4 :0
_69 equ 0x00000d70 :0
_70 equ 0x00000028 :0
_37 dc.b "Can't find delta for revision %s",$0
_41 dc.b "Missing log entry",$0
_46 dc.b $0
_50 dc.b "Missing delta text",$0
_76 dc.b $d,$d,"%s%c",$0
_82 dc.b $d,$d,"%s",$d,"%c",$0
_85 dc.b "r",$0
_93 dc.b $d,$d,$0
_97 dc.b "Can't open file %s with description",$0
_102 dc.b "entern description , terminated with ESC or '.':",$d,$0
_103 dc.b "NOTE: This is NOT the log message!",$d,">> ",$0
_107 dc.b "Can't reread redirected stdin for description; use -t<file>",$0
_116 dc.b ">> ",$0
_132 dc.b ">> ",$0
_135 dc.b $d,$d,$0
ends