d PROGRAM XTOC !! {<}Infile {>Outfile} {-Call -Index -List} c. An Index and Listing program ,c. c. Reads a source program, and identifies its 'module's via: c. 'PROGRAM', 'SUBROUTINE', 'FUNCTION'. Xc. c. The 'module' Name, Type, and Lead Comment can be listed. (options) c. 1) The calling parameters are to be shown also, and/or c. 2) The Source is to be listed, with Line NOs, and with c. page ejects between each 'module'. Lc. c. Parameters c. -C Show the calling parameters. xc. -F Show the file name c. -N Suppress the Line numbers {Only listing} @c. -L Show only the listing c. -I Show only the Index of programs c. -* Loop until ^Z lc-------------------------------------------------------end.of.info c. 05/16/81 .. Use JJUCMD 4c. 06/19/81 .. add page numbers c.  common /JJU_SWI/ JJUS(256) ` character*40 Infile,outfile c. ( character*132 upcmd, cmd character*60 discr character*9 name T character*4 ntyp character*10 chday, chtime  character*10 mode(0:1) data mode/'LISTed','INDEXed'/ byte ff H data ff/12/ c. 41 format(132a) t49 format(q,132a) 51 format(i6,': ',132a ) <c.  call jjctc(1)  call date( chday ) h call time( chtime ) c. 0c/// get the command Line c. 1000 continue \ close(unit=6)  open(6,type='new',carriagecontrol='list') $ upcmd = char(0)  cmd = '$XTOC {<}Infile {>Outfile} {-CFNLI*}' c. P ntot = 0  call jjctc(0)  do while( jjucmd( upcmd, cmd ) .gt.0 ) | enddo c. D if( jjctc(0).gt.0 ) goto 9000  if( JJUS(ichar('=')).lt.0 ) goto 9000  ifinx = 1 p iflis = 1  if( jjuswi('I').lt.0 ) iflis = 0 8 if( jjuswi('L').lt.0 .or. jjuswi('N').lt.0 ) ifinx = 0  ntot = 0  ifst = 0 d nmodule = 0 c. ,c/// Now process the INDEX and LISTING c. 2000 continue X if( JJUOPI( infile ) .le. 0 ) then !! No more inputs c. c... End of one pass c.  if( ntot.eq.0 ) goto 1000 L type 41,' '  type 2100,ntot,'Records ',mode(ifinx), nmodule,' Modules'  ntot = 0 x2100 format( i7,': ',2a, i7, ' ',a )  if( ifinx.gt.0 ) then !!Index @ if( iflis.eq.0 .and. JJUSWI('*').ge.0 ) goto 9000  if( iflis.eq.0 ) goto 1000  ifinx = 0 l upcmd = char(1) cmd = '*' 4! do while( jjucmd( upcmd,cmd ).gt.0 ) ! enddo ! nmodule = 0 `" goto 2000 " endif (# if( JJUSWI('*').ge.0 ) goto 9000 # goto 1000 # endif T$c. $c... Start of new file %c. % if( ifst.eq.0 ) then % ifst = 1 H& call JJUOPO( infile, outfile ) & write(6,41) chday, chtime(1:5),' ',infile(1:jjlen(infile)) ' write(6,41) ' ' t' endif ' npag = 1 <( irec = 0 (c... ntot = 0 )c. h)c/// read the next file record )c. 0*5000 continue * if( jjctc(0).gt.0 ) goto 1000 * read(1, 49, end=2000 ) nchar, cmd \+ if( cmd.eq.char(12) ) then !!New Page + npag = npag+1 $, irec = 0 , goto 5000 , endif P- ntot = ntot+1 - irec = irec+1 . inx = 1 |. if( mlatom( ifst, inx, cmd, ' ' ) .ne. 0 ) goto 5000 . upcmd = cmd(ifst:inx-1) D/ CALL jjupp( upcmd ) /c. 0c/// Process the File line p0c. 0 if( upcmd.eq.'PROGRAM' .or. upcmd.eq.'SUBROUTINE' 81 1 .or. upcmd.eq.'FUNCTION' ) then 1c. 2c//// Process a Program ... d2c. 2 nmodule = nmodule+1 ,3 ntyp = upcmd 3 if( ntyp.ne.'PROG' ) then 3 call jjlow( ntyp ) 3 else 3 call jjlow( ntyp(2:) ) 3 endif 3 CALL mlatom( ifst, inx, cmd, '(' ) X4 name = cmd(ifst:inx-1) 4 CALL jjupp( name ) 5 if( ifinx.gt.0 ) then !! Index 5 nrec = irec 5 nflag = 1 L6 if( JJUSWI('F').lt.0 ) then !! File 6 write(6,5400) nrec, npag, ntyp, name 7 1 ,infile(1:jjlen(infile)) x7 else if( jjus(ichar('C')) .lt. 0 ) then !!2 Line/Mod 7 do while( inx.lt.nchar ) @8 if( cmd(inx:inx).gt.' ' ) goto 5200 8 inx = inx+1 9 enddo l95200 continue 9 if( nchar.lt.inx ) nchar = inx 4: write(6,5400) nrec, npag, ntyp, name, cmd(inx:nchar) :5400 format( i6,'/',i3.3,' ',a,' ',a,' -- ', a ) : endif `; else !!Listing ; if( ntot.gt.1 .and. JJUSWI('N').lt.0 ) then (< write(6,41) ff < else < write(6,41) ' ' T= write(6,41)ff =c/// write(6,5500) ntyp, name, irec, npag =c/// 1 , infile(1:jjlen(infile)) > write(6,5400) irec, npag, ntyp, name > 1 , infile(1:jjlen(infile)) >5500 format( a,' ',a,i6,'/',i3.3,' ',a ) > write(6,41)'------:' > inxlin = 1 H? endif ? goto 6000 @ endif t@ else if( ifinx.le.0 ) then !!Listing @c. ', a ) H else I if( jjuswi('F').ge.0 ) then pI write(6,5400) nrec, npag, ntyp, name, cmd(ifst:nchar) I endif 8J endif J nflag = 0 K endif dK endif K goto 5000 ,Lc. ---- Lc. Lc.. output source also XMc. M9000 continue Nc. N end