[comp.bugs.sys5] m4 bug or feature?

evan@plx.UUCP (Evan Bigall) (11/27/89)

m4 feature or bug?  (I am leaning towards bug, because the information output
is (IMHO) incorrect, but it is consistent across systems).

Where:
  My generic plexus sys5 box, sunos /usr/5bin/m4, hpux m4

What:
  When using divert in an included file, all of the line numbers generated by
  the -s option after the divert refer to the last line of the parent file
  rather than their true positions.

Why:
  This is a simplified example, in real life, `prelude' is a c variable
definition built while scanning the file that I need inserted at the top.

Example:
---begin test.m4---
include(`bug.m4')
line 1
line 2
line 3
line 4
---end test.m4---

---begin bug.m4---
divert(2)
m4wrap(`divert(1) prelude')
---end test.m4---

---begin output---
#line 1 "-"
#line 1 "test.m4"
#line 1 "test.m4:bug.m4"
 prelude
#line 6 "test.m4"    <<<<from this point on all numbers are hosed>>>>

#line 6

#line 6
line 1
#line 6
line 2
#line 6
line 3
#line 6
line 4
#line 6
---end output---

Question number 1: is this the correct behavior, if so why?

It would seem to me the problem is that the line directives are being assigned
at the final output, instead of on input.  Question number 2: can this be
changed easily (hmmmmm). 

Question number 3: Can anybody duplicate the functionality I am looking for 
yet preserve the original line numbering (my best shot at this was writing
`prelude' out to a file and using the c preprocessor to include it back in).

Any input appreciated,
Evan
-- 
Evan Bigall, Plexus Software, Santa Clara CA (408)980-8190  ...!sun!plx!evan
"I barely have the authority to speak for myself, certainly not anybody else"