mainGNU M4 - Support: sr #110929, Using changequote() breaks...

 
 

sr #110929: Using changequote() breaks --synclines

Submitter:  Karl O. Pinc <kop>
Submitted:  Wed 06 Sep 2023 05:14:08 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 06 Sep 2023 05:14:08 AM UTC, original submission:  

Using the changequote() macro breaks --synclines output.
(And has for years and years, FWIW.)
See the attached files foo.m4 and bar.m4 and output of:
m4 -s foo.m4

Full explaination follows:

-----------------------------------------------------
foo.m4 is:
line 1 of foo
include(bar.m4)
line 3 of foo
include(bar.m4)
line 5 of foo
line 6 of foo
baz()`'dnl
 This text is line 8 of foo
baz()
line 10 of foo
-----------------------------------------------------

bar.m4 is:
-----------------------------------------------------
dnl This is an included file
changequote([{[,]}])dnl m4 foolery so includes include only once.
dnl                     Once the macro is in the text, change the quotes back
ifdef([{[_bar.m4]}], [{[changequote(`,')]}], [{[dnl
changequote(`,')dnl
dnl
dnl Standard test for having already included the file.
define(`_bar.m4')dnl
dnl (Start putting things into the file here)
line 10 of bar
dnl
dnl Don't output anything while defining macros.
line 13 of bar
divert(-1)

# The utility of the changequote foolery is for when included files
# include other files.
# line 18 of bar

define(`baz',
       `The 'b``''`az macro made this')

# Done defining macros.
divert`'dnl
line 25 of bar
]}])dnl End of ifdef over the whole file.
-----------------------------------------------------

The output of `m4 -s foo.m4` is:
-----------------------------------------------------
#line 1 "foo.m4"
line 1 of foo
#line 4 "bar.m4"
line 10 of bar
#line 4
line 13 of bar
#line 4 "bar.m4"
line 25 of bar
#line 2 "foo.m4"

line 3 of foo
#line 4 "foo.m4"

line 5 of foo
line 6 of foo
The baz macro made this This text is line 8 of foo
#line 9
The baz macro made this
line 10 of foo
-----------------------------------------------------

The output should be (something like):
-----------------------------------------------------
#line 1 "foo.m4"
line 1 of foo
#line 10 "bar.m4"
line 10 of bar
#line 13
line 13 of bar
#line 25 "bar.m4"
line 25 of bar
#line 2 "foo.m4"

#line 3
line 3 of foo
#line 4 "foo.m4"

#line 5
line 5 of foo
#line 6
line 6 of foo
The baz macro made this This text is line 8 of foo
#line 21 "bar.m4"
The baz macro made this
#line 10 "foo.m4"
line 10 of foo
-----------------------------------------------------

Apologies, the example may be over-complicated.
It should at least involve direct output by included
files as well as use of a macro defined in an included file.
(I opted not to show included files including other files, but
that should work too.)

Karl O. Pinc <kop>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55118:  foo.m4 added by kop (148B - application/x-m4 - Use thse to reproduce with: m4 -s foo.m4)
file #55119:  bar.m4 added by kop (724B - application/x-m4 - Use thse to reproduce with: m4 -s foo.m4)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by kop (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-09-06 kop Attached File- Added foo.m4, #55118
        Attached File- Added bar.m4, #55119

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code