bug-gnulib
[Top][All Lists]
Advanced

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

Re: m4 brackets question


From: Bruno Haible
Subject: Re: m4 brackets question
Date: Thu, 15 Sep 2011 01:01:35 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Eric Blake wrote:
> > Which of the following code lines should be changed, for maintainability?
> >
> >    absolute-header.m4:87:      s#^/[^/]#//&#
> 
> Underquoted.  I'd recommend using | instead of # in the sed snippet

Yes, this will be clearer. Thanks for the advice.

> >    csharpcomp.m4:15:  AC_MSG_CHECKING([for C[#] compiler])
> 
> Correctly double-quoted (with minimal range), also possible to use 
> maximal double-quoting as:
> 
> AC_MSG_CHECKING([[for C# compiler]])

This way of writing it would make it look as if AC_MSG_CHECKING's argument
generally should be double-quoted. I'll prefer to leave it as is: this
emphasizes that there is a particular problem with the #.

> >    csharp.m4:13:    [  --enable-csharp[[=IMPL]]  choose preferred C[#] 
> > implementation (pnet or mono)],
> 
> The second argument to AC_ARG_ENABLE should generally be using 
> AS_HELP_STRING to get better line-wrapping capabilities.

Yes, but due to different quoting behaviours of AS_HELP_STRING in older
versions of autoconf I'm not so eager to use that.

> >    include_next.m4:226:               
> > gl_absolute_header_sed='\#'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[#{
> >    include_next.m4:227:                   
> > s#.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*#\1#
> >    include_next.m4:228:                   s#^/[^/]#//&#
> 
> What started this conversation, and rather difficult to decipher.  Hence 
> my recommendation to use s||| instead of s###

I'm doing that.

> >    po.m4:122:          cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e 
> > "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*,     $top_srcdir/&  \\\\," | sed 
> > -e "\$s/\(.*\) \\\\/\1/">  "$ac_dir/POTFILES"
> 
> Similar to the include_next question about why we are using # as the sed 
> delimiter.

But here the entire piece of shell script is already double-quoted, so adding
extra brackets (after a # or on a new line) would not be good.


2011-09-14  Bruno Haible  <address@hidden>

        Avoid using #, the m4 comment starter character, near brackets.
        * m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): Use |, not #, as
        delimiter character in sed expressions.
        * m4/include_next.m4 (gl_NEXT_HEADERS_INTERNAL): Likewise.
        Suggested by Eric Blake.

--- m4/absolute-header.m4.orig  Thu Sep 15 00:46:24 2011
+++ m4/absolute-header.m4       Thu Sep 15 00:46:14 2011
@@ -1,4 +1,4 @@
-# absolute-header.m4 serial 14
+# absolute-header.m4 serial 15
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -81,13 +81,13 @@
       gl_dirsep_regex='/'
       ;;
   esac
-changequote([,])
-  gl_absolute_header_sed='\#'"${gl_dirsep_regex}"'$1#{
-      s#.*"\(.*'"${gl_dirsep_regex}"'$1\)".*#\1#
-      s#^/[^/]#//&#
+  gl_absolute_header_sed='\|'"${gl_dirsep_regex}"'$1|{
+      s|.*"\(.*'"${gl_dirsep_regex}"'$1\)".*|\1|
+      s|^/[^/]|//&|
       p
       q
     }'
+changequote([,])
   dnl eval is necessary to expand gl_absname_cpp.
   dnl Ultrix and Pyramid sh refuse to redirect output of eval,
   dnl so use subshell.
--- m4/include_next.m4.orig     Thu Sep 15 00:46:24 2011
+++ m4/include_next.m4  Thu Sep 15 00:46:14 2011
@@ -1,4 +1,4 @@
-# include_next.m4 serial 21
+# include_next.m4 serial 22
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -223,9 +223,11 @@
                    ;;
                esac
 changequote([,])
-               
gl_absolute_header_sed='\#'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[#{
-                   
s#.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*#\1#
-                   s#^/[^/]#//&#
+               
gl_absolute_header_sed='\|'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[|{
+                   
s|.*"\(.*'"${gl_dirsep_regex}"']m4_defn([gl_HEADER_NAME])[\)".*|\1|
+changequote(,)dnl
+                   s|^/[^/]|//&|
+changequote([,])dnl
                    p
                    q
                  }'

-- 
In memoriam Jerzy Popiełuszko <http://en.wikipedia.org/wiki/Jerzy_Popiełuszko>



reply via email to

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