hopp@nbs-amrf.UUCP (Ted Hopp) (02/26/85)
Description: This happened with version 2.9 of -me (version 2.1 of sh.me). I defined the macro '$0', which is automatically called from 'sh' when starting a new section, to log the section name in a Table of Contents index. Occasionally '$0' would get a null string as the section name. This occured when '$p', which prints the section header for 'sh', triggered a trap that causes an index entry to be generated. (I am floating figures and entering the figure captions in a List of Figures index when the figure is output.) Because of the delayed processing of the index entry macros when they are in a diversion such as a floating keep, they execute during the trap processing. The string '|x' is used by 'sh' to temporarily store the section header, but it is also used by ')x' to store the page number for the index entry. This destroys the value of '|x' for 'sh', so '$0' gets a null string. Repeat by: Playing around with the location of a trap that causes the index entry macros to be called just when a section header is to be printed. Define '$0' to do something with the section name; it will get a null string. Fix: I fixed 'sh' in \*(||/src/sh.me to redefine |x just before calling '$0'. This seems kind of a kludge, but it works. Old: .if !"\\$2"_" \ \{\ . ds |x \&\\$2 . $p "\\*(|x" "\\*($n" \\n($0 . $0 "\\*(|x" "\\*($n" \\n($0 . rm |x .\} New: .if !"\\$2"_" \ \{\ . ds |x \&\\$2 . $p "\\*(|x" "\\*($n" \\n($0 new --> . ds |x \&\\$2 \" in case |x got clobbered . $0 "\\*(|x" "\\*($n" \\n($0 . rm |x .\} Is there a more elegant solution? I thought of calling '$0' from '$p', but '$p' is called from 'sx' with no call to '$0'. The real fix is to avoid conficting uses of '|x', but I'm too lazy to figure out how to do that. -- Ted Hopp {seismo,umcp-cs}!nbs-amrf!hopp