Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site nbs-amrf.UUCP Path: utzoo!watmath!clyde!cbosgd!cbdkc1!desoto!packard!hoxna!houxm!mhuxj!mhuxr!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!umcp-cs!nbs-amrf!hopp From: hopp@nbs-amrf.UUCP (Ted Hopp) Newsgroups: net.bugs.4bsd Subject: Bug and fix in -me macros Message-ID: <441@nbs-amrf.UUCP> Date: Tue, 26-Feb-85 14:38:49 EST Article-I.D.: nbs-amrf.441 Posted: Tue Feb 26 14:38:49 1985 Date-Received: Fri, 1-Mar-85 06:21:11 EST Organization: National Bureau of Standards Lines: 61 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