autoconf-patches
[Top][All Lists]
Advanced

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

Re: 06AS_HELP_STRING-robust-to-commas.diff


From: Akim Demaille
Subject: Re: 06AS_HELP_STRING-robust-to-commas.diff
Date: Tue, 01 Apr 2003 18:14:26 +0200
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 (gnu/linux)

| This is on top of my 02 patch, but it fixes a problem that was present in
| AC_HELP_STRING - the macro would break when the LHS contained a comma.  This
| patch makes the LHS argument robust to commas, like the RHS argument.  The
| PREFIX argument is still not robust.
| 
| There were problems with the quoting of FIRST-PREFIX in m4_wrap_text that
| had top be repaired as well in order to fix AS_HELP_STRING.
| 
| Incidentally, what might cause spaces following a comma to disappear iin m4
| while leaving the rest of the string?  Spaces before the comma remained.
| 
| -Derek
| 
| Index: ChangeLog
| 2003-03-28  Derek Price  <address@hidden>
| 
|       * lib/autoconf/general.m4 (AU::AC_HELP_STRING): Quote arguments
|       properly.
|       * lib/m4sugar/m4sh.m4 (AS_HELP_STRING): Quote LHS argument to make it
|       robust to commas.
|       * lib/m4sugar/m4sugar.m4 (m4_text_wrap): Quote FIRST-PREFIX argument to
|       make it robust to commas.

m4_text_wrap is an horror to write, as are all the text crunching
macros, since they cannot be evaluated lazily: strict evaluation is
needed, what breaks most safe use of m4.

| Index: lib/autoconf/general.m4
| ===================================================================
| RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
| retrieving revision 1.813
| diff -u -r1.813 general.m4
| --- lib/autoconf/general.m4   27 Mar 2003 13:18:34 -0000      1.813
| +++ lib/autoconf/general.m4   28 Mar 2003 21:19:03 -0000
| @@ -217,7 +217,7 @@
|  # AU::AC_HELP_STRING(LHS, RHS, [COLUMN])
|  # ----------------------------------
|  AU_DEFUN([AC_HELP_STRING],
| -[AS_HELP_STRING(address@hidden)dnl
| +[AS_HELP_STRING([$1],[$2],[$3])dnl
|  ])
|  
|  

This is noop, so please, remove it.

| Index: lib/m4sugar/m4sh.m4
| ===================================================================
| RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
| retrieving revision 1.94
| diff -u -r1.94 m4sh.m4
| --- lib/m4sugar/m4sh.m4       27 Mar 2003 13:18:34 -0000      1.94
| +++ lib/m4sugar/m4sh.m4       28 Mar 2003 21:19:03 -0000
| @@ -897,7 +897,8 @@
|  [m4_pushdef([AS_Prefix], m4_default([$3], [                          ]))dnl
|  m4_pushdef([AS_Prefix_Format],
|             [  %-]m4_eval(m4_len(AS_Prefix) - 3)[s ])dnl [  %-23s ]
| -m4_text_wrap([$2], AS_Prefix, m4_format(AS_Prefix_Format, [$1]))dnl
| +m4_text_wrap([$2], AS_Prefix,
| +             [m4_format(AS_Prefix_Format, [$1])])dnl
|  m4_popdef([AS_Prefix_Format])dnl
|  m4_popdef([AS_Prefix])dnl
|  ])

I think this is wrong.  I'm surprised that it works actually.  Have
you tried passing a macro?  Rather, try to m4_dquote the whole
m4_format. 

| Index: lib/m4sugar/m4sugar.m4
| ===================================================================
| RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
| retrieving revision 2.68
| diff -u -r2.68 m4sugar.m4
| --- lib/m4sugar/m4sugar.m4    29 Sep 2002 08:14:32 -0000      2.68
| +++ lib/m4sugar/m4sugar.m4    28 Mar 2003 21:19:04 -0000
| @@ -1624,9 +1624,9 @@
|  # first word, and then ` ' (single space) for all the others.
|  m4_define([m4_text_wrap],
|  [m4_pushdef([m4_Prefix], m4_default([$2], []))dnl
| -m4_pushdef([m4_Prefix1], m4_default([$3], [m4_Prefix]))dnl
| +m4_pushdef([m4_Prefix1], [m4_default([$3], [m4_Prefix])])dnl
|  m4_pushdef([m4_Width], m4_default([$4], 79))dnl
| -m4_pushdef([m4_Cursor], m4_len(m4_Prefix1))dnl
| +m4_pushdef([m4_Cursor], m4_len(m4_quote(m4_Prefix1)))dnl
|  m4_pushdef([m4_Separator], [])dnl
|  m4_Prefix1[]dnl
|  m4_if(m4_eval(m4_Cursor > m4_len(m4_Prefix)),
| @@ -1638,8 +1638,8 @@
|  dnl of the words.
|  m4_if(m4_eval(m4_Cursor > m4_Width),
|        1, [m4_define([m4_Cursor],
| -                    m4_eval(m4_len(m4_Prefix) + m4_len(m4_defn([m4_Word])) + 
1))]
| -m4_Prefix,
| +                    m4_eval(m4_len(m4_Prefix) + m4_len(m4_defn([m4_Word]))))
| +m4_Prefix][],
|         [m4_Separator])[]dnl
|  m4_defn([m4_Word])[]dnl
|  m4_define([m4_Separator], [ ])])dnl

The same applies here.  Be extremely cautious with these guys.  And
to be honest, I do believe they are robust to comas, as there are
often comas in AC_DEFINE's 3rd arg.  Could you exhibit a test case?




reply via email to

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