Re: [gettext] changequote considered harmful

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

 



Hello,

On Wed, Jul 27, 2005 at 04:55:58PM +0200, Bruno Haible wrote:
> > +typedef int array [[2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]];

OK, I think I see why you don't like this.  (Paul Eggert prefers it, so I
tried it... ;-).

Actually, my preference is to quote the whole blocks of text which
I don't want to get screwed by the macro code.

IOW, I replace the pair
	changequote(,)   changequote([,])
with
	[                ]

My previous patch was a mix of these two methods.  I updated it to use
this one consistently; the new patch is attached to this mail.

Let me explain:

You spoke about mixing different syntaxes.  Well that's an important feature
of macro languages:  literal text is intermixed with macro calls.

On one side, this simplicity is one of the most appealing properties of
macro languages.

OTOH, this means you inevitably get into situation where some text/code is
screwed ^H^H^H^H^H^H^H^Hexpanded even though it was meant as literal text/code.

To fix this problem, you have to mark the literal text with \begin{verbatim}
\end{verbatim} or some such.
The changequote() call is of the same type as TeX's verbatim environment:
it changes the lexical analyzer temporarily.  I think this is the more
obscure solution.  As I said, it is more risky, and I mentioned some examples
in my previous mail.

I think it's cleaner to use a pair of quotes instead.  This cleanly and exactly
expresses the intention: "this is shell (or C) code; do not touch!"

Have I convinced you?

Have a nice day,
	Stepan


PS:
Actually, all literal code should be quoted, something like

AC_CHECK_FUNC([sinh], [[sinh_found=yes]], [[sinh_found=no]])
[if test $sinh_found = no; then]
  AC_MSG_WARNING([[sinh not found]])
[fi]

But hey, that's not possible in real life.
2005-07-28  Stepan Kasal  <kasal@xxxxxx>

	* gettext-runtime/m4/gettext.m4 (AM_GNU_GETTEXT, AM_INTL_SUBDIR):
	Don't use changequote, add pairs of quotes instead.
	* gettext-runtime/m4/po.m4 (AM_POSTPROCESS_PO_MAKEFILE): Likewise.

Index: gettext-runtime/m4/gettext.m4
===================================================================
RCS file: /cvs/gettext/gettext/gettext-runtime/m4/gettext.m4,v
retrieving revision 1.37
diff -u -r1.37 gettext.m4
--- gettext-runtime/m4/gettext.m4	27 Jul 2005 11:27:55 -0000	1.37
+++ gettext-runtime/m4/gettext.m4	28 Jul 2005 12:09:07 -0000
@@ -130,13 +130,11 @@
         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
          [AC_TRY_LINK([#include <libintl.h>
 ]ifelse([$2], [need-formatstring-macros],
-[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+[[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
 #endif
-changequote(,)dnl
 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-changequote([,])dnl
-], [])[extern int _nl_msg_cat_cntr;
+]], [])[extern int _nl_msg_cat_cntr;
 extern int *_nl_domain_bindings;],
             [bindtextdomain ("", "");
 return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
@@ -162,13 +160,11 @@
             dnl Now see whether libintl exists and does not depend on libiconv.
             AC_TRY_LINK([#include <libintl.h>
 ]ifelse([$2], [need-formatstring-macros],
-[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+[[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
 #endif
-changequote(,)dnl
 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-changequote([,])dnl
-], [])[extern int _nl_msg_cat_cntr;
+]], [])[extern int _nl_msg_cat_cntr;
 extern
 #ifdef __cplusplus
 "C"
@@ -183,13 +179,11 @@
               LIBS="$LIBS $LIBICONV"
               AC_TRY_LINK([#include <libintl.h>
 ]ifelse([$2], [need-formatstring-macros],
-[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+[[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
 #endif
-changequote(,)dnl
 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-changequote([,])dnl
-], [])[extern int _nl_msg_cat_cntr;
+]], [])[extern int _nl_msg_cat_cntr;
 extern
 #ifdef __cplusplus
 "C"
@@ -515,15 +509,15 @@
   else
     dnl Found it, now check the version.
     AC_MSG_CHECKING([version of bison])
-changequote(<<,>>)dnl
+    [
     ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
     case $ac_prog_version in
       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
       1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
-changequote([,])dnl
          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
     esac
+    ]
     AC_MSG_RESULT([$ac_prog_version])
   fi
   if test $ac_verc_fail = yes; then
Index: gettext-runtime/m4/po.m4
===================================================================
RCS file: /cvs/gettext/gettext/gettext-runtime/m4/po.m4,v
retrieving revision 1.13
diff -u -r1.13 po.m4
--- gettext-runtime/m4/po.m4	4 May 2005 10:56:47 -0000	1.13
+++ gettext-runtime/m4/po.m4	28 Jul 2005 12:09:07 -0000
@@ -210,13 +210,13 @@
 dnl Postprocesses a Makefile in a directory containing PO files.
 AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
 [
+[
   # When this code is run, in config.status, two variables have already been
   # set:
   # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
   # - LINGUAS is the value of the environment variable LINGUAS at configure
   #   time.
 
-changequote(,)dnl
   # Adjust a relative srcdir.
   ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
   ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
@@ -283,7 +283,7 @@
 x
 :d
 '
-changequote([,])dnl
+]
 
   # Set POTFILES to the value of the Makefile variable POTFILES.
   sed_x_POTFILES="`$gt_echo \"$sed_x_variable\" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`"
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux