%%s 5/5/108 %%d D 1.2 15-Jun-83 12:23:05 sventek 2 1 %%c Removed trailing periods from quoted strings, as they are no longer needed. %%s 0/0/0 %%d D 1.1 25-Mar-82 12:15:17 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 %%D 2 #-h- split.r 1792 asc 25-mar-82 08:54:39 v1.1 (sw-tools v1.1) #-h- main 832 asc 25-mar-82 08:54:17 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- split.r 1798 asc 15-jun-83 12:22:51 sventek (joseph sventek) #-h- main 831 asc 15-jun-83 12:22:20 sventek (joseph sventek) %%E 2 ## split - split a file into pieces DRIVER(split) integer getarg, create, open, ctoi, nlcopy character buf(MAXLINE), outf(FILENAMESIZE) integer nl, i, j, in, usein, out data outf(1), outf(2) / 'x', EOS/ %%D 2 call query("usage: split [-n] [file [name]].") %%E 2 %%I 2 call query("usage: split [-n] [file [name]]") %%E 2 nl = 1000 usein = NO in = STDIN #pick up file name(s) for (i=1; getarg(i,buf,MAXLINE)!=EOF; i=i+1) { if (buf(1) == '-') { if (buf(2) == EOS) usein = YES else { j = 2 nl = max(ctoi(buf,j), 1) } } else if (usein == NO) { in = open(buf,READ) if (in == ERR) call cant(buf) usein = YES } else call scopy(buf, 1, outf, 1) } #main loop to break up file repeat { call extnam(outf, buf) out = create(buf, WRITE) if (out == ERR) call cant(buf) if (nlcopy(in, out, nl) == EOF) break call close(out) } DRETURN end %%D 2 #-h- extnam 447 asc 25-mar-82 08:54:18 v1.1 (sw-tools v1.1) %%E 2 %%I 2 #-h- extnam 446 asc 15-jun-83 12:22:21 sventek (joseph sventek) %%E 2 ## extnam - add unique extension to filename -file- subroutine extnam (file, name) character file(ARB), name(ARB), append(3) integer length data append(1), append(2), append(3) /'a', 'a', EOS/ call scopy(file, 1, name, 1) if (append(2) > 'z') { append(2) = 'a' append(1) = append(1) + 1 if (append(1) > 'z') %%D 2 call error ("out of file names.") %%E 2 %%I 2 call error ("out of file names") %%E 2 } call scopy(append, 1, name, length(name)+1) append(2) = append(2) + 1 return end #-h- nlcopy 294 asc 25-mar-82 08:54:20 v1.1 (sw-tools v1.1) ## nlcopy - copy n lines from file in to file out integer function nlcopy (in, out, n) character buf(MAXLINE) integer getlin integer in, out, n, i for (i=1; i<=n; i=i+1) { if (getlin(buf,in) == EOF) { nlcopy = EOF return } call putlin(buf, out) } nlcopy = OK return end #-h- split.fmt 566 asc 25-mar-82 08:54:41 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Split (1) 11-Jan-79 split a file into pieces .sy split [-n] [file [name] ] .ds Split reads `file' and writes it in n-line pieces (default 1000), as many as necessary, onto a set of output files. The name of the output file is `name' with `aa' appended, and so on lexicographically. If no output name is given, `x' is default. If no input file is given, or if - is given in its stead, then the standard input file is used. .fl .sa The Unix command 'split' .di A message is printed if the input file could not be opened. .au Debbie Scherrer .bu %%E 1