3 If we are just plain old nroff (and not doing UNICODE) we should
4 only Lookup characters, not Install when we don't know them.
5 If we are troff, we Install them anyway
9 Nroff had problems with parsing quoted white space as options or
10 character code in some terminals tables. Changed by having scanf
11 include white space when necessary as suggested by Rich.
15 Made sanity check for terminal type depending on the trace level;
16 trace level set with -tn flag at start up
20 More pointer shuffling fixes.
24 More disabling of multibyte stuff. Fixed bug in n5.c: casetm didn'
25 know about the new format in the fontables.
29 Removed extra include <setlocale> from n1.c
31 Fixed dubious pointer shuffling in n7.c, t10.c & n8.c. Thanks Rich!
35 Disabled the multybyte stuff; only plan 9 will get it.
39 Fixed nasty bug discovered by td, which caused core dumps on
40 \D'l-0.002775i 0i' and apparently all numbers closer to 0
41 than -.002775. Fixed in storeline() and storeword() (n7.c).
45 nroff & troff -N were looking for the TYPESETTER variable, causing
47 troff: cannot open /sys/lib/troff/term/tab.202; line 1, file stdin
49 fixed my moving getenv("TYPESETTER") to t10.c in t_ptinit(void).
53 The sequence \s+2\H'+10' came sometimes out in the wrong order
54 (x H before s), so there wasn't a difference bewteen \s+2\H'+10'
55 and \H'+10'\s+2. Now the fonts bits of the CHARHT are used to
56 register the current pontsize, so we can issue a s10 in t10.c
57 if needed. A bit sneaky.
59 Try to prevent double slashes in path names. Especially under
60 plan9 things started to look ugly.
62 Exception word list now grows dynamic.
66 Allow multiple calls to .pi, requested by Rob.
69 is now equivalent with
73 .ab now takes also optional error code:
75 If n and string, n is exit code, string is message
76 If n, n is exit code, ``User Abort, exit code n" is message
77 If !n and string, standard exit code, string is message
78 If !n and ! string, standard exit code, "User Abort" is message
82 Reordered code to keep the UNASNI scripts happy.
84 Nroff dumped core reading terminal tables: apparenty under plan 9,
85 scanf includes the '\n'; added test for '\0' in parse in n10.c.
87 Relative tab settings (.ta +1C +2C) didn't work; anding the
88 previous value with TABMASK fixes this (caseta).
92 Included code, originally done by bwk for plan 9, to handle
93 multi-byte characters.
97 ``pair internal'' two char names by shifting 16 bits. Will allow
98 the use of 16 bit characters sets (Unicode in plan9 etc.) for
103 Word & line buffers are now dynamic: No more word or line overflow
104 unless when we run out of memory.
108 lost diversion warning pops up regularly with man macro's. Due
109 to a possible macro coding problem. Triggered by something like
117 throw away this diversion (aa) while being defined.
122 Fixed by disallowing .rm to throw away current diversion. The
123 rn request will complain with:
125 cannot remove diversion aa during definition; etc.
129 Some long standing fixes which never went back in the source.
130 Thanks to Janet & Rich.
134 Changed getach() (n1.c), so it does't consider truncated
135 special characters as (8-bit) ascii. STX ETX ENQ ACK and BELL
136 are still allowed for the ultimate backwards compatibility.
138 Some code changes, so real ANSI compilers like the SGI version
139 (acc from Sun is a poor excuse for an ANSI compiler) don't
140 barf. Some compromises (static Tchar wbuf in n9.c) allowed so
141 the unansified stuff for non-ansi compilers (cc on Sun's) will
146 Be nice to Gerard. Now also word spaces in .tl and after
151 Tabs setting can now be humongous. We also allow 99 tabs to
152 accomodate tbl. As a side effect, NTM buffers are now 1K
156 .R register, now contains maximum number of addessable
157 registers minus the number actually used.
159 Small esthetic changes in error messages; removed a statement
160 which wasn't reached anyway.
164 Some more speed hacks: be smarter doing the linear table
165 lookups in alloc() and finds().
167 The real name of the det diversion size macro is now gd.
171 A much faster way to find the end of a string/macro, by
172 remembering that when defined.
176 Slightly more eficient way of skipping to the end of a
181 Prevent character sign extension for 8-bit charnames diversions
186 Growing the dynamical macro/strings name space and registers
187 space (See the experiment of 21 July) now with bigger
188 increments. Casts added to satisfy non-ANSI compilers.
192 Should check return value in alloc (n3.c), to prevent core dump
193 when memory gets tight.
197 New request: .sg <div> sets the dn and dl registers to the size
198 of the diversion named in the argument. Doesn't do anything
199 when the named diversion doesn't exist. The name sg is
200 temporary until we find a better one.
204 Experiment: Macro space & registers name allocated
205 dynamically. Note that current reallocation occurs in
206 increments of 1, to force the code to be executed a lot; a kind
207 of stress testing. Also, eight bit characters allowed in
212 Turn on the escape mode if the end macro is called.
216 Tracing mode now default off
218 Don't print s stackdump either when a file specfied on the
219 command line argument cannot be opened
223 Don't print useless line & current file informations when a
224 file specfied on the command line argument cannot be opened.
226 Sun ansi compiler doesn't default adhere to standards. Undid
231 Coding error made the tab type R not function properly
235 Fixed a typo in the version stuff, noticed by Rich
239 Added the dwb home configuration stuff, thanks RIch. Also,
240 NCHARS is big enough. Added a fflush to casetm, so .fm <file>
243 June 25, 1993 (Rich):
247 reinstated for the sake of compatibility. Some old
248 shells scripts and man(1) from SunOs want this, sigh
250 Compiler and system dependencies
252 Some systems pull in sys/types.h via #include <time.h> and then
253 the compiler complains about two ushort typedefs. Therefore,
254 ushort is now Ushort (and uchar Uchar).
256 The SVID specifies a strdup, POSIX doesn't, anyway, troff
257 provides its own version, slightly different then the standard
258 one. A To prevent name clashes with that definion, renamed to
261 June 24, 1993 (Rich):
263 -V option added for DWB3.4 (rich)
267 Trivial fix (.cf) request for troff -a
273 with troff -a gives some spurious output:
280 fixed by checking for ascii mode it ptesc(), ptps() and
286 Added a .tm request to roff. Works just like .tm, but now
287 it will do it to file. The name is coined by Carmela. Great
288 for creating indeces & toc's (we hope).
294 Somebody complained that his favorite macro didn't work:
295 it had a BELL (^G) in the name. This was a non-documented
296 feature of earlier versions of troff (although the
297 documentation actually doesn't say that you can. (They can
298 only be used for delimiters or with the tr request), so it
299 isn't that important).
301 But the sake of eternal backward compatibilaty I allowed
302 some control characters like, STX, ACK, etc. also be part
303 of a macro/string name.
305 While at it, I made it also possible to have eight bit
306 characters be part of the name. It might be that this screws
307 up the way users think about these things. For UNICODE
308 versions, they probably want to do that as well, and that
309 won't work as easy, (because these characters are 16-bits
310 wide), so it is dubious whether we actually want this.
315 .tm terminal sigma macro
319 also works, as long the internal cookie for ts isn't more then
326 Some requests accept tabs as a separator, some don't and
327 this can be a nuisance. Now a tab is also recognized as
328 an argument separator for requests, this makes
334 To be more precise, any motion character is allowed, so
338 will work as well, if one really wants that.
340 It will be a problem for users who really relied on this as in
344 and expect the tab to become part of the string a, but I haven't
345 seen any use of that (obscure trick).
351 Troff sometimes went in a loop, and exited with: ``job
352 looping; check abuse of macros'' (also known as the Eileen's
353 loop). It can be forced with the next trivial programme:
361 Basically what happens is that a page transition now will
362 happen in a diversion, which doesn't make sense. Wat really
363 happens is that eject() (in n7.c) doesn't eject the frame
364 because we are in a diversion. This cause the loop in n1.c
365 (because now always stack->pname <= ejl). Adding check on
366 whether we are not in a diversion takes care of the problem.
372 When there is a begin of page trap set, and the first thing
373 in the file is a .ne request, the trap gets fired, but,
374 the x font R etc. cookies doen't come out, because the
375 troff thinks that the first page pseudo transition already
376 took place. Fixed by forcing the start of the first page
377 in the casene request with the same code as in casetl (which
378 caused a similar problem quite some time ago).
380 Change to .cf request ``Here document''
382 If the argument of .cf starts with a <<, the rest of it is taken
383 as an EOF token. It will reat the rest of the input until it hits
384 the EOF token and copies it to the output. This is similar as
385 the shell's ``here document'' mechanisme and put in place to
386 improve the kludgy way picasso, picpack etc. now include
389 Using troff -TLatin1 (DWB version) and \N'...' caused core dump
391 In t11, in chadd, it should test on NCHARS - ALPHABET to see
392 whether we run out of table space (and we probably should beaf
393 up NCHARS for the DWB version).
397 Diversion rename bug fix
399 It is possible to get troff in an infinite loop by renaming a
400 diversion in progress, and calling it later with the
401 new name (as in .di xx, .rn xx yy, .yy). The effect depends on
402 whether troff already put stuff in the diversion or not.
404 Fix by having .rn also rename the current diversion (if
405 there is any and when appropriate). If the diversion calls
406 itself by the new name and given the fix made on 11 nov
407 1992, this will now result in an error. (BTW, the fix from
408 11 nov is improved: diversions nest, so we have to account
412 Some people have complete novels as comments, so we need
413 to skip comments while checking the legality of font files.
418 Some people rely on the order that -r arguments are given,
419 so that troff -rC1 -rC3 ends up setting register C to 3.
420 Because cpushback() pushes things in a LIFO order back, we
421 have to do the same to get -r args in a FIFO order.
425 Giving a -rL8 option cuased the string .nr L 8 to be printed
426 on the output, using the wonderful 3b2. Some garbage was
427 left in buf[100] in main(). Fixed by setting buf[0] explicitly
428 to 0 (because some C-compilers complain about ``no automatic
429 aggregate initialization'').
435 If a diversion was being read and the input is faulty so
436 the diversion was reading in itself, it caused troff to
437 loop undefinitely. This was easily fixed by a test in
438 control(a,b) in n1.c.
440 Something similar things might happen with macros causing
441 the ``eileenct problem'', but I didn't look for that. We
442 have to wait until it happens.
448 Illegal argments are treated as missing arguments. This
449 changed the semantics of .ll, .ls, .in, .lg, .ul, .cu .lt
450 (which acted as if the argument was 0) and .ps which was
451 simply ignored with an illegal argument.
453 Tidied up number parsing in atoi1(). This prevents arguments
454 like .x or 1.2.3.4 being interpret as a legal number (nonumb = 0)
456 Numeric arguments error reporting:
458 Controlled by .pt, illegal numbers are now reported (default
459 trace mode is 1). This is also true for the escapes:
460 \h'..', \v'..' \H'..', \S'..', \N'..', \D'..', \l'.., \L'..
463 \D'c' is the only drawing request which doesn't take a pair
464 of numbers as arguments, so a special case is put here in
465 setdraw() (This code actually could use an overhaul to get
466 better parsing. As long as the \D'..' cookies are machine
467 generated it is low on the priority list).
469 Don't generate an error if the illegal argument to a request
470 is a \}. It is too painful to do right (although it can be
471 done, but it would clutter getch() and getcho() even more).
473 Input line numbers (.c register) bug fixes:
475 In not taken branches of .if or .ie, the input line #
476 (numtab[CD].val) should be raised when necessary (in eatblk()).
478 For concealed newlines, we still should count the line for input.
480 Setfield (n9.c) sometimes pushes the rest of the line back to
481 the input (including \n), without adjusting numtab[CD].val
483 Because .c (and so numtab[CD].val) is the number of lines read
484 and the error might actually happen in the current line
485 (before seeing the '\n), we need to apply correction in
486 errprint when nlflg set. (This correction needs to be undone
487 when inside a macro because the nlflg is set by reading the
490 Line number setting (.lf) request bug fixes:
492 I interpret that the .c register will contain the number of
493 read lines, not including the current one.
495 Also, don't change the input line number when the first
496 argument of .lf is not a number.
498 As a net effect, the next input
504 will generate the same output whether eqn has been used or not.
508 A ``.if page .tm foo'' caused the next line being ignored;
509 This bcause when the 2nd delimiter of a string couldn't be
510 found in cmpstr, the next line was always eaten. Solution:
511 in caseif1, if the condition is false, we should check
512 nlflg before eating a block. (Note: We might have eaten
513 \{\ as well. We could disallow the \{\ in a string to be
514 compared to prevent that but that might break other things).
518 The .pt now pops the previous values when no argument is
519 specified. Turned out to be handy when chasing for problems.
520 Just ``bracked'' the code with .pt 7 and .pt and you get
521 a trace of only that block. The meaning of the arguments
523 01 trace numeric arguments (default on)
527 Abort request (.ab) beautification:
529 Don't print the extra carriage return when .ab is called
534 (Comments & spelling errors from this day on by jaap)
536 replaced 32767 by INT_MAX in several places to allow for very
537 long pages (on 32-but machines).
539 The ``.fp 1 R \"COMMENT'' complains about ``./troff: Can't
540 open font file /usr/lib/font/devpost/h'' on some systems. It
541 sees the tab as part of the optional font file. Apparently it
542 is system dependent whether isgraph() includes the tab
543 character. Fixed by using getach() in getname() in n1.c
547 removed call to popi from rdtty(); it was eating up the
548 rest of the macro if it was used from within one. (thanks, jaap)
552 added extra test in nextfile() to pop current input file
553 only if not in .nx command. thanks to jaap.
555 added test in getword() to avoid hyphenating after \z character,
556 which prevents any hyphenation inside \X'...'. thanks to jaap.
558 added, then removed, code in getword() to prevent hyphenating
559 anything shorter than 6 characters. looks like it changed a
560 lot more than i thought.
563 added .pt request to trace macros and requests (from jaap).
564 .pt N Print trace of macros (N=1), requests (N=2) or both (N=3)
567 added tests to t.twrest and t.twinit to avoid 0 deref in
568 n2 and n10, for nroff -t xxxxx. thanks to Rich Drechsler.
571 added extern decls to e.g., void Tchar (*hmot)(void) in tdef.h
572 and added definition to ni.c, so pointers are defined explicitly.
573 makes it work on turbo c++ and probably others.
575 changed a couple of isdigit's and isgraph(getch()) to avoid
576 multiple evaluation (even though it shouldn't happen).
578 Made /usr/bin/nroff a shell script.
581 n1.c: need p++ after strrchr to skip / in program name.
582 thanks to Rich Drechsler.
585 casefi(), n5.c: .u register should be 0 or 1, not incremented
589 fiddled n7.c and added _nmwid to the environment, to add a
590 5th argument to .nm: the maximum number of digits in any
591 line number. default is 3, which was previously hardwired in.
593 added jaap's code for yet another register which actually delivers
594 a string, called .S (so it can easily go in the switch in setn()
595 in n4.c); it delivers the current tabstop and alignment modes in
596 a format suitable for a subsequent .ta \n(.S command:
602 added test in getword to avoid hyphenating things with motions
603 (and avoid a core dump sometimes too).
606 \n(sb initialized wrong in setwd().
608 TYPESETTER=foo troff -Tpost used foo instead of post.
611 rearranged tests in popf so that .so is closed properly before
612 moving on to the next macro package.
615 input mechanism rearranged to use getc() instead of stack of
616 explicit input buffers. 5-10% slowdown.
619 fixed .tm \(mi to print something sensible. thanks to jaap.
622 fiddle setfp so doesn't put out font stuff if -a turned on.
625 copy 3rd argument in .fp commands to x font ... lines when it contains
626 a /, for testing fonts locally.
629 parameterize the font directories, etc., so can be set in makefiles.
630 added -N argument to run as nroff.
633 add a maplow(towlower...) in n8.c to handle brain-damaged libraries.
636 merged nroff into troff, based on Ken's plan 9 version.
637 merged nii.c into ni.c, removed tw.h, etc. more work needed
638 to make this stuff cleaner.
641 added test in setn in n4 to fix bug that permitted things like
642 \n (ab to work "properly". thanks to jaap for finding and fixing.
644 added paranoid testing in t11 to make sure font files look ok.
647 moved evaluation of \(xx from copy mode to non-copy mode, so that
648 weird character names wouldn't get reevaluated in argument parsing.
652 increased size of hyphenation exception buffer to 512 from 128
655 added an extra redundant call of ptfont in setfp, since it appears
656 that some versions of adobe transcript assume that an "x font" command
657 means to change the actual font as well. the fix preserves the current font.
658 thanks to david brailsford and friends for spotting the problem.
660 fixed up tests in alpha() in n8 to defend isalpha() against too-big inputs.
661 punct() argument had wrong type too. thanks to rich drexler and peter nelson.
664 fixed bug that prevented .rd from working with new corebuf organization.
666 fixed bug that caused .ig inside diversions to give bad storage
667 allocation. thanks to arthur david olson, whose fix was on netnews
671 huge table sizes for kanji.
674 working on dealing with large alphabets, notably kanji.
675 added "defaultwidth" to font descriptions, for characters
676 not given an explicit width.
679 added tex hyphenation, using standard tex data files, but not the
680 elaborate compressed trie, which is a lot of trouble to save maybe
681 40k bytes. this appears to run at exactly the same speed as before.
683 so far this stuff reads into a fixed size array; that should change.
684 it should also be possible to deal with multiple languages.
686 the command .ha sets the algorithm. .ha 1 => tex, with troff rules
687 if tex doesn't hyphenate; .ha 0 gives troff rules, and .ha resets
688 to the default, which is tex. the hyphenation algorithm is part of
689 the environment, a nod to a future in which i handle more than one
692 replaced the fixed size corebuf array for string/macro storage by
693 a dynamic structure that can grow.
695 this appears to slow things down by maybe 3%. the code is about
699 converted to ansi c, based on some work by ken thompson, but not
700 as thoroughly as he did. there is a shell script unansi and an awk
701 program cvt that will help you step back in time if you do not have
704 moved the special-name characters up to 256 instead of 128, although
705 done in terms of ALPHABET, so one can pass 8 bit characters through.
706 removed lots of 0177's and similar numbers. input is now not filtered,
707 and if a character with the 8th bit on comes in, it will go out again.
709 fixed t11.c to read character names in hex or octal as well as
710 single-character ascii.
712 unknown characters are now carried through with width = spacewidth.
713 needs a way to set widths.
715 removed all signal handling from troff. you signal, you die.
717 added -d option to print version number.
720 .fp 3 V VERYLONGNAME used to truncate the name to 10 chars; fixed.
722 increased the limit on FBUFSZ for tables with very long fields.
724 changed atoi1() to use double to avoid intermediate overflow.
726 moved filenames like /usr/lib/font into tdef.h for easy change.
727 removed some dreggish definitions.
729 cleaned up non-portable error printing stuff; fixed up some messages.
732 Removed the .! command, an undocumented synonym for .sy.
735 Another wart to the \X code, to try to preserve blanks in all situations.
738 A number of small changes preparatory to getting rid of nroff.
739 The argument -Tnroff or -Tnroff-12 changes some internal values
740 so that the predicate .if n is true and certain arithmetic operations
741 are done as if nroff. This design is not yet final.
744 Fixed hyphenation for nov-ice, ad-vice, de-vice, ser-vice, *-vice.
747 It is now permitted to do an explicit change to font S.
748 It is not clear what will break (though nothing seems to have).
751 Modified flush code to always put out \nH instead of sometimes h.
752 This makes it easier to parse the output for positioning.
755 Fixed internal representation of \D'~...' so that it
756 is immune to .tr ~ and variations. No external change.
759 Changed .tm so it outputs \e, \%, \-, \&, \(blank).
760 This might break indexing code.
761 Only in the new version, as are all subsequent fixes.
764 A major internal change: font information is read in ascii
765 instead of the weird binary format of makedev (which is now dead).
766 character names need not all appear in DESC; new names that
767 appear when a font is used become part of the set of known names.
769 There are some flaky bits here (it's conceivable that some \N
770 number will collide with a real name), and it's probably 10-15%
773 As a by-product, nroff no longer compiles. I'll probably get
774 back to this, but an alternative is to bag it once and for all.
777 Another bug in \l, this time when width is 0. Not installed,
778 since it's in the new font version.
781 Fixed bug in n9 that caused core dump with unterminated
782 \l command, like \l'1.5i
784 ptflush no longer called when -a is on.
787 fixed bug in n2 that failed to suppress printing of \!
788 output when a -o was in effect.
791 .fl and \X now cause output of size, font, hpos and vpos.
792 this is necesary for postprocessors that intend to insert
793 independent material, such as postscript.
796 wait for .pi pipe to empty before exiting
799 default is now -Tpost
802 added abortive code to handle built-up characters by
803 passing something through as \D'b...'. never used.
806 replaced the sbrk nonsense in n3.c by calls to malloc.
808 \N now tests against proper font size.
810 installed Jaap Akkerhuis's code (mutatis mutandis) for
811 permitting up to 99 fonts, swapping them into font pos 0
812 as needed. fixes the long-standing problem of having
813 multiple font changes on a single output line.
816 \X now preserves spaces even when contents are diverted.
818 \N code safer -- NTRTAB and NWIDCACHE enlarged.
821 Fixed obscure bug causing incorrect indentation of .mc output.