automake-patches
[Top][All Lists]
Advanced

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

FYI: make_conditional_string


From: Alexandre Duret-Lutz
Subject: FYI: make_conditional_string
Date: Thu, 21 Nov 2002 15:26:40 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/20.7 (i386-debian-linux-gnu)

>>> "Raja" == Raja R Harinath <address@hidden> writes:

 Raja> Alexandre Duret-Lutz <address@hidden> writes:
 >> Index: automake.in
 >> ## ------------------------------ ##
 >> ## Handling the condition stack.  ##
 >> ## ------------------------------ ##
 >> @@ -5957,7 +5942,7 @@
 >> 
 >> $cond = "${cond}_TRUE"
 >> unless $cond =~ /^TRUE|FALSE$/;
 >> -  $cond = condition_negate ($cond)
 >> +  $cond = Automake::Conditional::condition_negate ($cond)
 >> if $negate;

 Raja> This pattern should probably be converted to a function

 Raja> make_conditional_string ($cond, $negate);

I'm checking in the following patch for that.

2002-11-21  Alexandre Duret-Lutz  <address@hidden>

        * automake.in (make_condition_string): New function.
        (cond_stack_if, cond_stack_else, cond_stack_endif): Use it.
        Suggested by Raja R Harinath.
 
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1394
diff -u -r1.1394 automake.in
--- automake.in 21 Nov 2002 11:54:11 -0000      1.1394
+++ automake.in 21 Nov 2002 14:19:52 -0000
@@ -5929,6 +5929,20 @@
 ## ------------------------------ ##
 
 
+# $STRING
+# make_conditional_string ($NEGATE, $COND)
+# ----------------------------------------
+sub make_conditional_string ($$)
+{
+  my ($negate, $cond) = @_;
+  $cond = "${cond}_TRUE"
+    unless $cond =~ /^TRUE|FALSE$/;
+  $cond = Automake::Conditional::condition_negate ($cond)
+    if $negate;
+  return $cond;
+}
+
+
 # $COND
 # cond_stack_if ($NEGATE, $COND, $WHERE)
 # --------------------------------------
@@ -5939,12 +5953,7 @@
   err $where, "$cond does not appear in AM_CONDITIONAL"
     if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
 
-  $cond = "${cond}_TRUE"
-    unless $cond =~ /^TRUE|FALSE$/;
-  $cond = Automake::Conditional::condition_negate ($cond)
-    if $negate;
-
-  push (@cond_stack, $cond);
+  push (@cond_stack, make_conditional_string ($negate, $cond));
 
   return new Automake::Conditional (@cond_stack);
 }
@@ -5964,15 +5973,12 @@
     }
 
   $cond_stack[$#cond_stack] =
-  Automake::Conditional::condition_negate ($cond_stack[$#cond_stack]);
+    Automake::Conditional::condition_negate ($cond_stack[$#cond_stack]);
 
   # If $COND is given, check against it.
   if (defined $cond)
     {
-      $cond = "${cond}_TRUE"
-       unless $cond =~ /^TRUE|FALSE$/;
-      $cond = Automake::Conditional::condition_negate ($cond)
-       if $negate;
+      $cond = make_conditional_string ($negate, $cond);
 
       err ($where, "else reminder ($negate$cond) incompatible with "
           . "current conditional: $cond_stack[$#cond_stack]")
@@ -5997,14 +6003,10 @@
       return;
     }
 
-
   # If $COND is given, check against it.
   if (defined $cond)
     {
-      $cond = "${cond}_TRUE"
-       unless $cond =~ /^TRUE|FALSE$/;
-      $cond = Automake::Conditional::condition_negate ($cond)
-       if $negate;
+      $cond = make_conditional_string ($negate, $cond);
 
       err ($where, "endif reminder ($negate$cond) incompatible with "
           . "current conditional: $cond_stack[$#cond_stack]")

-- 
Alexandre Duret-Lutz





reply via email to

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