m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: m4-discuss Digest, Vol 72, Issue 1


From: daniel daniel
Subject: Re: m4-discuss Digest, Vol 72, Issue 1
Date: Mon, 18 Jul 2011 10:39:49 -0700

Hi John, I had a little think about this, and the solution is quite easy:
1. cd to home directory, create a new sub-directory called m4proj, and cd into that directory: # cd ~/; mkdir m4proj; cd m4proj
2. create your inputFile.m4 with the text: A word can expand to many things.: # echo "A word can expand to many things.">inputFile.m4
3. open a text editor of your choice to create your def.m4 m4 file, and save it with the following code:
define(word,term)`'define(many,a great `many')dnl
include(inputFile.m4)
4. run your code: m4 def.m4

Note how the inputFile.m4 is referred to via inclusion, so that if the contents of that change, then the output changes!

Having a little think,
Daniel.

On Mon, Jul 18, 2011 at 4:10 AM, John Allsup <address@hidden> wrote:
I've had a little think about this.  The simplest problem I can set you m4 people is the task of writing
a simple macro driven input that does the following:

Given a source file in1.m4 which contains the following:
   A word can expand to many things.
and the file def.m4 which contains
   define(word,term)define(many,a great `many')
the challenge is to generate the output
   The phrase 'A word can expand to many things' may be expanded to the following.
       A term can expand to a great many things.
using the simplest m4 input possible and by referring to the contents of the file via inclusion so that
if the contents of the input file change, the output changes accordingly.

Have a think.

John



On 18/07/11 03:57, John Calcote wrote:
Hi John,

I see exactly what you want, but I'm not sure what you're asking for is
reasonable. Why would you want to run a file though a macro processor and
not have it process any macros? Given your original input files, "a" and
"b", consider this sequence of commands:

cat a | m4>  out.txt
cat b>>  out.txt

This would see to accomplish exactly what you want, wouldn't it?

Regards,
John Calcote

-----Original Message-----
From: m4-discuss-bounces+john.calcote=gmail.com@gnu.org
[mailto:m4-discuss-bounces+john.calcote=gmail.com@gnu.org] On Behalf Of
address@hidden
Sent: Sunday, July 17, 2011 10:00 AM
To: address@hidden
Subject: m4-discuss Digest, Vol 72, Issue 1

Send m4-discuss mailing list submissions to
       address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
       https://lists.gnu.org/mailman/listinfo/m4-discuss
or, via email, send a message with subject or body 'help' to
       address@hidden

You can reach the person managing the list at
       address@hidden

When replying, please edit your Subject line so it is more specific than
"Re: Contents of m4-discuss digest..."


Today's Topics:

   1. Simple method of including a file that bypasses macro
      expansion (John Allsup (M4))


----------------------------------------------------------------------

Message: 1
Date: Sun, 17 Jul 2011 08:15:04 +0100 (BST)
From: "John Allsup (M4)"<address@hidden>
To: address@hidden
Subject: Simple method of including a file that bypasses macro
       expansion
Message-ID:
       
<315299693.53381.1310886904889.JavaMail.open-address@hidden>
       
Content-Type: text/plain; charset="utf-8"

Hi,
?
I am relatively new to m4, but can't seem to find an equivalent to include
that bypasses macro expansion.
?
Suppose file 'a' contains
? hello world
and file 'b' contains
? goodbye world
and in my m4 I have defined
? define(world,and).
I a macro which I will call 'oinclude' such that ? include(a) oinclude(b)
expands to ? hello and goodbye world.

Is there a simple method?
?
Thanks,
?
John?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
</archive/html/m4-discuss/attachments/20110717/1a5f3c41/attachment.html>

End of m4-discuss Digest, Vol 72, Issue 1
*****************************************






reply via email to

[Prev in Thread] Current Thread [Next in Thread]