automake-patches
[Top][All Lists]
Advanced

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

Avoid syntax error if IF-TRUE part of AM_COND_IF is empty.


From: Ralf Wildenhues
Subject: Avoid syntax error if IF-TRUE part of AM_COND_IF is empty.
Date: Tue, 27 Jul 2010 21:33:14 +0200
User-agent: Mutt/1.5.20 (2010-04-22)

Adding this patch to maint to fix the glitch at least for the IF-TRUE
case.  It's unfortunately not fixable as nicely in the IF-FALSE case
since we don't want to override $? there.

Cheers,
Ralf

    Avoid syntax error if IF-TRUE part of AM_COND_IF expands empty.
    
    * m4/cond-if.m4 (AM_COND_IF): Ensure IF-TRUE part is never empty
    to avoid shell syntax error if the m4 expansion is empty.
    * tests/cond40.test: Enhance test.

diff --git a/m4/cond-if.m4 b/m4/cond-if.m4
index 9f2611e..2500422 100644
--- a/m4/cond-if.m4
+++ b/m4/cond-if.m4
@@ -1,12 +1,12 @@
 # AM_COND_IF                                            -*- Autoconf -*-
 
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2010 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 2
 
 # _AM_COND_IF
 # _AM_COND_ELSE
@@ -27,8 +27,8 @@ AC_DEFUN([AM_COND_IF],
 [m4_ifndef([_AM_COND_VALUE_$1],
           [m4_fatal([$0: no such condition "$1"])])dnl
 _AM_COND_IF([$1])dnl
-if _AM_COND_VALUE_$1; then
-  m4_default([$2], [:])
+if _AM_COND_VALUE_$1; then :
+  m4_n([$2])[]dnl
 m4_ifval([$3],
 [_AM_COND_ELSE([$1])dnl
 else
diff --git a/tests/cond40.test b/tests/cond40.test
index be94fe3..d30f0ab 100755
--- a/tests/cond40.test
+++ b/tests/cond40.test
@@ -1,5 +1,5 @@
-#!/bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+#! /bin/sh
+# Copyright (C) 2008, 2010 Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -28,6 +28,10 @@ AC_DEFUN([FOO],
         [AC_CONFIG_FILES([$1])])
 
 AM_CONDITIONAL([COND], [test "$cond" = yes])
+# Next lines should not cause a shell syntax error.
+AM_COND_IF([COND])
+AM_COND_IF([COND],
+          [AC_SUBST([BAR])])
 AM_COND_IF([COND],
           [AC_CONFIG_FILES([file1])])
 



reply via email to

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