%%s 0/0/0 %%d D 1.1 25-Mar-82 12:07:29 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- incl.r 1658 asc 25-mar-82 08:01:48 v1.1 (sw-tools v1.1) #-h- defns 210 asc 25-mar-82 08:01:38 v1.1 (sw-tools v1.1) # definitions for INCL tool # put on a file named 'inclsym' # Used only by the include tool define(NFILES,arith(MAXOFILES,-,3)) #max nbr of included files #(should be max nbr of open files allowed -3) #-h- main 1302 asc 25-mar-82 08:01:38 v1.1 (sw-tools v1.1) ## incl - replace include file by contents of line DRIVER(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) /'i'/ data incld(2) /'n'/ data incld(3) /'c'/ data incld(4) /'l'/ data incld(5) /'u'/ data incld(6) /'d'/ data incld(7) /'e'/ data incld(8) /EOS/ call query("usage: incl [file] ...") for (i=1; ; i=i+1) { if (getarg(i, line, MAXLINE) == EOF) { if (i!= 1) break infile(1) = STDIN } else if (line(1) == '-' & line(2) == EOS) infile(1) = STDIN 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) call fold(str) #fold to lower case 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)) } DRETURN end #-h- incl.fmt 1253 asc 25-mar-82 08:01:49 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Incl (1) 10-Jul-78 expand included files .sy incl [file] ... .ds Include copies the input files to the standard output. Whenever an input line begins with .ce include filename the entire contents of filename will be copied to the standard output. If no input files are specified, the standard input is copied. An included file may include further includes. Multiple input files are allowed. Include is used to bring in much-used routines, common declarations or definitions, thus insuring use of the same version by all programs. .fl none .sa Kernighan and Plauger's "Software Tools", pages 74-77. .br The software tools "ratfor" tutorial .di includes nested too deeply .br .in +6 The depth of included files allowed is dependent upon the maximum number of open files allowed in the following manner: .ce MAXOFILES - 3 .br .sp .in -6 filename: can't open .br .in +6 File could not be located or maximum number of opened files was exceeded. .sp 1 .in -6 .au Original code by Kernighan and Plauger in "Software Tools", with modifications by Ardith Kenney. .bu .br The depth of included files allowed is dependent upon the maximum number of open files allowed by the implementor of the primitives. %%E 1