75008378%VAX2.NIHED.IE@cunyvm.cuny.edu (09/02/88)
Hi guys, First, about printer.c. I said I had a working model, and I do, but its based on V1.2 (rather than 1.3x), and I thought it might muddy the waters unduly to post it in this state: for now, I have mailed a copy to Dr. Tanenbaum, so he can decide whether, or in what form, to post it. If and when *I* reach the heights of V1.3, I'll look at it again myself. In the meantime if anyone *really* wants to see it, mail me and I'll pass on a copy. This may only make sense if you're still on V1.2.... Secondly, once you have a working printer, you may want to use roff. In that case, you may be interested in some little known facts (at least, little known to me!): 1: ungetc only works on buffered files. 2: fopen tries to buffer files by mallocing a buffer. If the malloc fails, but there is no other problem, the file will be opened, but unbuffered. 3: If you use any macros in roff it needs to open a file to hold the macro definitions. It actually opens this file twice simultaneously - once for writing, once for reading. Incidently, this is quite a neat way of handling macros, though it limits the generality somewhat. Anyway, this means it needs two buffers, whose default size is 1K. But, in V1.2, the default stack space for all commands is only 2K, and when you take away the actual stack, there certainly isn't space to malloc two 1K buffers. So: for reading (at least) the macro file is unbuffered; so ungetc fails; so roff doesn't happen to notice this, and roff fails, only without actually telling you so! It just terminates early, with some confusing stuff at the end of the output file. So? Make sure you increase the stack space for roff, with chmem. I use 4K which seems to work fine. Maybe this is all old hat, but I actually found and fixed this about six months ago, forgot about it, deleted the executable file (for reasons I won't go into!), then found the problem again last week, and spent another day figuring out *again* what was going wrong (now I have a separate makefile for roff to make sure I won't forget YET again!). So if this saves somebody having to go through that, I guess it's worth posting. Happy days, Barry McMullin, NIHED, Dublin, IRELAND. (MCMULLINB@VAX2.NIHED.IE)