ral@pyuxqq.UUCP (R A Levenberg) (06/06/85)
This filter can be used to expand tables specified in files that are dragged in by .so nroff commands. It's needed in front of pipelines like tbl ... | nroff ... if the input contains lines like .so filename when filename contains a table definition such as .TS ... .TE because nroff, and not tbl, expands the .so line to the contents of the named file. The program is actually very trivial, but the concept is useful. The following was built with shar. # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. -----cut here-----cut here-----cut here-----cut here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # catso.1 # catso.c # This archive created: Wed Jun 5 22:39:44 1985 echo shar: extracting catso.1 '(1469 characters)' sed 's/^XX//' << \SHAR_EOF > catso.1 XX.ad b XX.de In \" Space and indent XX.sp XX.in +4 XX.. XX.de Un \" Space and undent XX.sp XX.in -4 XX.. XX.TH CATSO 1 "LOCAL" XX.SH NAME XXcatso - Cats files, interpreting nroff-style file inclusion XX.SH SYNOPSIS XX\fBcatso\fR [ file or \fB-\fR ] ... XX.SH DESCRIPTION XX\fICatso\fR concatenates the files together, recursively inserting XXfiles referenced by the nroff commands '.so' and '.nx' in their XXproper positions. XXWhen interpreting a '.so' command, the named file is itself \fIcatso\fRd XXat that point, then processing resumes in the file that contained the '.so' XXcommand. XXFiles referenced by '.nx' are treated the same, except that processing XXstops after the file referenced by the '.nx' command. XX.P XX\fICatso\fR is useful for providing input to an \fInroff\fR(1) XXpreprocessor, such as \fInrpp\fR(1), since normally the files referenced by XXthe .so and .nx commands will not be seen by the preprocessor. XX.P XXThe file name '-' means standard input. XXStandard input will also be used if no arguments are given, unless XXthe input is connected to the terminal. XXIn the latter case, \fIcatso\fR will print its usage instructions. XX.SH FILES XX.SH AUTHOR XXJ. Leth, IH 55414 6B-326, x6133. XX(Based on an earlier version by D. A. Spicer). XX.SH SEE ALSO XXnroff(1), mm(1) XX.SH DIAGNOSTICS XX"Can't open [ .nx | .so ] file '<filename>'." -- the argument file, .so XXfile, or .nx file can't be read or does not exist. XX.SH BUGS XXWill not interpret commands imbedded in macros or conditionals, or commands XXfollowing a ';'. SHAR_EOF if test 1469 -ne "`wc -c catso.1`" then echo shar: error transmitting catso.1 '(should have been 1469 characters)' fi echo shar: extracting catso.c '(1898 characters)' sed 's/^XX//' << \SHAR_EOF > catso.c XX#include <stdio.h> XX XX/* Catso will cat the standard input to the standard output, inserting XX * all files referenced by the nroff commands '.so' or '.nx'. XX * J. Leth, IH 55414 6B-326, x6133. XX * (original program from: D. A. Spicer) XX */ XX XX#define SPACE " \t\n" XX#define MAXLINE 500 XX XXchar buff[MAXLINE]; XXchar line[MAXLINE]; XX XX/* Functions: */ XXextern char *strtok(); XX/* * * * * * */ XX XX XXmain(argc, argv) XX int argc; XX char *argv[]; XX{ XX FILE *inp; XX int i; XX XX if (isatty(0) && argc == 1) { XX /* If input is from the terminal, and there are no args, XX * print usage instructions and exit. XX */ XX XX fprintf(stderr, "Usage:\tcatso [ file or '-' ] ...\n\ XX Cats the files (standard input, default) together, inserting\n\ XX files referenced by the nroff commands '.so' and '.nx' in their\n\ XX proper positions. File name '-' means standard input\n"); XX exit(1); XX }; XX XX if (argc == 1) { XX fetch(stdin); XX } else { XX for (i=1; i < argc; ++i) { XX if (strcmp(argv[i], "-") == 0) { XX fetch(stdin); XX } else { XX inp = fopen(argv[i], "r"); XX if (inp == NULL) { XX fprintf(stderr, XX "catso: can't open file '%s'.\n", XX argv[i]); XX } else { XX fetch(inp); XX } XX } XX } XX } XX} XX XX XXfetch(fdes) XX FILE *fdes; XX{ XX FILE *newdes; XX char *cmd; XX char *fname; XX XX while(fgets(buff,sizeof(buff),fdes) != NULL ) { XX strncpy(line, buff, sizeof(line)); XX cmd = strtok(buff, SPACE); XX fname = strtok((char *) 0, SPACE); XX XX if (strcmp(cmd, ".so") == 0) { XX if((newdes = fopen(fname,"r")) != NULL) { XX fetch(newdes); XX fclose(newdes); XX } else { XX fprintf(stderr, "catso: can't open .so file '%s'.\n", XX fname); XX } XX } else if (strcmp(cmd, ".nx") == 0) { XX if((newdes = fopen(fname,"r")) != NULL) { XX fclose(fdes); XX fetch(newdes); XX fclose(newdes); XX } else { XX fprintf(stderr, "catso: can't open .nx file '%s'.\n", XX fname); XX exit(1); XX } XX exit(0); XX } else { XX fputs(line, stdout); XX } XX } XX} SHAR_EOF if test 1898 -ne "`wc -c catso.c`" then echo shar: error transmitting catso.c '(should have been 1898 characters)' fi # End of shell archive exit 0
mikem@uwstat.UUCP (06/07/85)
> This filter can be used to expand tables specified in files that > are dragged in by .so nroff commands. It's needed in front of What about soelim? or is this one of the Berkeleyism's that hasn't made it back to AT&T land? -- Mike Meyer -- Phone +1 (608) 262-1157 (Leave messages at 262-2598) ARPA: mikem@Statistics <==> mikem@Wisc-Stat.ARPA UUCP: ...!{allegra,ihnp4,seismo,ucbvax,pyr_chi,heurikon}!uwvax!uwstat!mikem
ekrell@ucla-cs.UUCP (06/08/85)
There's a program called "soelim" that does exactly that. -- Eduardo Krell UCLA Computer Science Department ekrell@ucla-locus.arpa ..!{sdcrdcf,ihnp4,trwspp,ucbvax}!ucla-cs!ekrell
rwl@uvacs.UUCP (Ray Lubinsky) (06/10/85)
> This filter can be used to expand tables specified in files that > are dragged in by .so nroff commands. It's needed in front of > pipelines like > tbl ... | nroff ... : : Correct if I'm wrong, but isn't this just a weaker version of soelim(1)? I'm on 4.2 BSD, so, I don't know, maybe this filter doesn't exist on other versions of Unix. If it does, there's no point in reinventing the wheel. Soelim(1) can also handle nesting of ".so" calls. -- Ray Lubinsky University of Virginia, Dept. of Computer Science uucp: decvax!mcnc!ncsu!uvacs!rwl
ral@pyuxqq.UUCP (06/13/85)
>Correct if I'm wrong, but isn't [catso] just a weaker version of >soelim(1)? I'm on 4.2 BSD, so, I don't know, maybe this filter >doesn't exist on other versions of Unix. If it does, there's no >point in reinventing the wheel. Soelim(1) can also handle >nesting of ".so" calls. Sorry, but on our System V, we have no soelim! ======================================================================== Ron Levenberg Bell Communications Research 3 Corporate Place Room 2C-315 Piscataway, NJ 08854 (201) 981-6178 ..!allegra!pyuxqq!ral
guy@sun.uucp (Guy Harris) (06/16/85)
> >Correct if I'm wrong, but isn't [catso] just a weaker version of > >soelim(1)? I'm on 4.2 BSD, so, I don't know, maybe this filter > >doesn't exist on other versions of Unix. If it does, there's no > >point in reinventing the wheel. Soelim(1) can also handle > >nesting of ".so" calls. > > Sorry, but on our System V, we have no soelim! Since Bellcore has 4.2 one at least one of one of their machines, just copy the source over to your S5 machine and compile it. It's a simple program (written by the VP of R&D at Sun Microsystems) which should run on any V7 or post-V7 version of UNIX. (According to the comments at the front: This program eliminates .so's from a n/troff input stream. It can be used to prepare safe input for submission to the phototypesetter since the software supporting the operator doesn't let him do chdir. This is a kludge and the operator should be given the ability to do chdir. This program is more generally useful, it turns out, because the program tbl doesn't understand ".so" directives. ) I don't know what the U of C's policy on redistributing their software is, but I don't think "soelim" has any AT&T code in it so there's probably no problem with AT&T. Guy Harris