autoconf
[Top][All Lists]
Advanced

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

Re: m4_text_box => AS_TEXT_BOX?


From: Eric Blake
Subject: Re: m4_text_box => AS_TEXT_BOX?
Date: Tue, 28 Oct 2008 16:27:42 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Paolo Bonzini <bonzini <at> gnu.org> writes:

> 
> Eric Blake wrote:
> > Paolo Bonzini <bonzini <at> gnu.org> writes:
> > 
> >> m4_text_box is the sole user of quadrigraphs in m4sugar.m4.
> > 
> > Nope.  m4_text_wrap also uses it.
> 
> m4_text_wrap knows about quadrigraphs (via m4_qlen), but does not emit
> them.  If the input has no quadrigraphs, *and does not use m4_text_box*,
> the output is correct.

Ah.  I think I see what you are saying.

Right now, things look like:

m4sugar + quadrigraph/autom4te support
m4sh
other layers

But you want to divide it out:

m4sugar (no quadrigraph support)
autom4te (quadrigraphs, warnings)
m4sh (shell functionality)
other layers

so that bison can use m4sugar but use its own escaping mechanism of digraphs 
and its own warning mechanism of shell here-docs rather than autom4te.

Which means, yes, m4_text_box should either use literal ## (and not 
quadrigraphs), or that macro moved out of m4sugar.

Also, support for quadrigraphs can be easily removed from m4_text_wrap, by 
redefining m4_qlen as a synonym for m4_len (for now, both m4_qlen and the 
unused m4_qdelta are undocumented).  For the autom4te layer, we use the current 
m4_qlen definition that handles quadrigraphs.  But bison could redefine m4_qlen 
to recognize its digraphs - in other words, it is up to each m4sugar client how 
escape sequences are supported, and m4_text_wrap can be made to handle those 
escape sequences, without being tied to the notion of quadrigraphs and without 
having to use autom4te as the post-processor.

Is this patch sufficient for bison's needs?

diff --git a/ChangeLog b/ChangeLog
index 4e8fdd1..a2b5061 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
+2008-10-28  Eric Blake  <address@hidden>
+
+       Allow m4sugar to be used without autom4te, such as in bison.
+       * lib/m4sugar/m4sugar.m4 (m4_text_wrap, m4_qlen): Document that
+       alternate escape sequences can be used.
+       (m4_text_box): Likewise.  Don't output quadrigraphs.
+       (m4_qdelta): Delete unused macro.
+
 2008-10-28  Paolo Bonzini  <address@hidden>
-    
+
        use a shell function for AC_TYPE_INTx_T
        * lib/autoconf/types.m4 (_AC_TYPE_INT_BODY, _AC_TYPE_UNSIGNED_INT_BODY):
        New.
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 22c38e8..6bd1b01 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2228,7 +2228,9 @@ m4_define([m4_append_uniq_w],
 # FIRST-PREFIX will be left alone on the first line.
 #
 # No expansion occurs on the contents STRING, PREFIX, or FIRST-PREFIX,
-# although quadrigraphs are correctly recognized.
+# although quadrigraphs are correctly recognized.  More precisely,
+# you may redefine m4_qlen to recognize whatever escape sequences that
+# you will post-process.
 #
 # Typical outputs are:
 #
@@ -2307,20 +2309,29 @@ dnl finally, clean up the local variables
 #  ## MESSAGE ##
 #  ## ------- ##
 # using FRAME-CHARACTER in the border.
+#
+# Quadrigraphs are correctly recognized.  More precisely, you may
+# redefine m4_qlen to recognize whatever escape sequences that you
+# will post-process.
 m4_define([m4_text_box],
 [m4_pushdef([m4_Border],
            m4_translit(m4_format([%*s], m4_qlen(m4_expand([$1])), []),
                        [ ], m4_default_quoted([$2], [-])))dnl
address@hidden:@@%:@ m4_Border @%:@@%:@
address@hidden:@@%:@ $1 @%:@@%:@
address@hidden:@@%:@ m4_Border @%:@@%:@_m4_popdef([m4_Border])dnl
-])
+[##] m4_Border [##]
+[##] $1 [##]
+[##] m4_Border [##]_m4_popdef([m4_Border])])
 
 
 # m4_qlen(STRING)
 # ---------------
 # Expands to the length of STRING after autom4te converts all quadrigraphs.
 #
+# If you use some other means of post-processing m4 output rather than
+# autom4te, then you may redefine this macro to recognize whatever
+# escape sequences your post-processor will handle.  For that matter,
+# m4_define([m4_qlen], m4_defn([m4_len])) is sufficient if you don't
+# do any post-processing.
+#
 # Avoid bpatsubsts for the common case of no quadrigraphs.  Cache
 # results, as configure scripts tend to ask about lengths of common
 # strings like `/*' and `*/' rather frequently.  Minimize the number
@@ -2336,15 +2347,6 @@ m4_if(m4_index([$1], address@hidden), [-1], 
[m4_len([$1])],
                           [\3]))]))_m4_defn([m4_qlen-$1])])
 
 
-# m4_qdelta(STRING)
-# -----------------
-# Expands to the net change in the length of STRING from autom4te converting 
the
-# quadrigraphs in STRING.  This number is always negative or zero.
-m4_define([m4_qdelta],
-[m4_eval(m4_qlen([$1]) - m4_len([$1]))])
-
-
-
 ## ----------------------- ##
 ## 13. Number processing.  ##
 ## ----------------------- ##






reply via email to

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