Subject: Re: Test defaults to True?

From: Tavis Ormandy <[email-masked]>
Date: Sun, 09 May 2004 13:03:19 +0100

--On Sunday, May 09, 2004 12:17:48 +0100 Tavis Ormandy
<[email-masked]> wrote:

> 
> 
> --On Saturday, May 08, 2004 22:53:27 +0000 Mikhael Goikhman
> <[email-masked]> wrote:
> 
>> IMHO, the Test condition should default to true just like with all other
>> conditional commands.
> 
> I see, how about changing the test for "True" to check for "False"?

Maybe I should expand on that, for example, right now:

Test (True) This will happen
Test (False) This will happen
Test (Blahblahblah) This will happen

but True is still tested for as an on-condition, if this was changed to
check for False and set match accordingly:

Test (True) This will happen
Test (False) This wont happen
Test (Blahblahblah) This will happen

so Test still defaults to a match, what do you think?

$ cvs diff conditional.c
Index: conditional.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/conditional.c,v
retrieving revision 1.92
diff -u -w -r1.92 conditional.c
--- conditional.c       2 Apr 2004 12:09:33 -0000       1.92
+++ conditional.c       9 May 2004 11:59:33 -0000
@@ -1608,9 +1608,9 @@
                        on = 0;
                        cond++;
                }
-               if (StrEquals(cond, "True"))
+               if (StrEquals(cond, "False"))
                {
-                       match = True;
+                       match = False;
                }
                else if (StrEquals(cond, "Version"))
                {

-- 
-------------------------------------
[email-masked] | finger me for my gpg key.
-------------------------------------------------------

---

From: Mikhael Goikhman <[email-masked]>
Date: Sun, 9 May 2004 12:19:29 +0000

> Test (Blahblahblah) This will happen

The last command should produce a syntax error, bad if it does not.
The Test command does not check that an arbitrary string is true, it
checks that the named condition is satisfied.

> so Test still defaults to a match, what do you think?

I think you misuse the intended condition syntax. As I said, you just
want a new IsEmpty or maybe IsTrue condition, i.e.:

  Test (IsTrue "$0") happens conditionally

Regards,
Mikhael.
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked]

---

From: Tavis Ormandy <[email-masked]>
Date: Sun, 09 May 2004 14:03:36 +0100

>   Test (IsTrue "$0") happens conditionally

Hmm, okay, I can live with that :)

how about this:

$ cvs diff conditional.c
Index: conditional.c
===================================================================
RCS file: /home/cvs/fvwm/fvwm/fvwm/conditional.c,v
retrieving revision 1.92
diff -u -w -r1.92 conditional.c
--- conditional.c       2 Apr 2004 12:09:33 -0000       1.92
+++ conditional.c       9 May 2004 12:59:26 -0000
@@ -1608,9 +1608,39 @@
                        on = 0;
                        cond++;
                }
-               if (StrEquals(cond, "True"))
+               if (StrEquals(cond, "IsTrue"))
                {
-                       match = True;
+                       char *pattern;
+                       int option;
+
+                       tmp = GetNextSimpleOption(tmp, &pattern);
+
+                       if (pattern)
+                       {
+                               option = ParseToggleArgument(pattern, NULL,
-1, 0);
+                       
+                               switch (option)
+                               {
+                                       case -1:
+                                               error = True;
+                                               break;
+                                       case 0:
+                                               match = False;
+                                               break;
+                                       case 1:
+                                               /* No action required */
+                                               break;
+                                       default:
+                                               break;
+                               }
+
+                               free(pattern);
+                       }
+                       else
+                       {
+                               error = True;
+                       }
+
                }
                else if (StrEquals(cond, "Version"))
                {

---

From: Mikhael Goikhman <[email-masked]>
Date: Sun, 9 May 2004 13:07:34 +0000

Ok, now Test behaves correctly in the False and Blahblahblah cases:

  Test          always-happens         # rc is Match
  Test ()       always-happens         # rc is Match
  Test (True)   always-happens         # rc is Match
  Test (False)  never-happens          # rc is NoMatch
  Test (!True)  never-happens          # rc is NoMatch
  Test (!False) always-happens         # rc is Match
  Test (Blahblahblah)  never-happens   # rc is Error
  Test (!Blahblahblah) never-happens   # rc is Error

It is not difficult to add IsTrue condition if you still need one.

Regards,
Mikhael.

---

From: Tavis Ormandy <[email-masked]>
Date: Sun, 09 May 2004 14:12:08 +0100

> Ok, now Test behaves correctly in the False and Blahblahblah cases:

This is perfect, Thanks!