# FILE 7 OF SOFTWARE TOOLS FROM LBL # definitions for INCL tool # put on a file named 'inclsym' # Used only by the include tool define(NFILES,11) #max nbr of included files #(should be max nbr of open files allowed -4) #--------------------------------------------------------------------- # include symbol definitions # include symbols # reactivate this line after the ratfor preprocessor is up # include inclsym #--------------------------------------------------------------------- ## incl -- main program call initr4 call incl call endr4 end ## incl - replace include file by contents of line subroutine incl character line(MAXLINE), str(MAXLINE) integer equal, getlin, getwrd, open integer infile(NFILES), len, level, loc integer getarg, i character incld(8) data incld(1) /LETI/ data incld(2) /LETN/ data incld(3) /LETC/ data incld(4) /LETL/ data incld(5) /LETU/ data incld(6) /LETD/ data incld(7) /LETE/ data incld(8) /EOS/ for (i=1; ; i=i+1) { if (getarg(i, line, MAXLINE) == EOF) { if (i^= 1) break infile(1) = STDIN } else if (line(1) == MINUS & line(2) == EOS) infile(1) = STDIN else if (line(1) == QMARK & line(2) == EOS) call error ('usage: incl file!.') else { infile(1) = open(line,READ) if (infile(1) == ERR) call cant (line) } for (level=1; level > 0; level = level - 1) { while (getlin(line, infile(level)) ^= EOF) { loc = 1 len = getwrd(line, loc, str) if (equal(str,incld) == NO) call putlin (line, STDOUT) else { level = level + 1 if (level > NFILES) call error ('includes nested too deeply.') len = getwrd(line, loc,str) infile(level) = open(str,READ) if (infile(level) == ERR) call cant (str) } } if (infile(level) ^= 1) call close (infile(level)) } if (infile(1) ^= STDIN) call close (infile(1)) } return end