# HG changeset patch # User Paul Boddie # Date 1549301452 -3600 # Node ID 6169eae54bd4b49f3fe16971cb8cdd602a199bfd # Parent 5c50586c2ece786beba78711dfc88b9a14ff916e# Parent a13fc2cc28f0205df39a42819e553097da86acb9 Merged changes from the default branch. diff -r 5c50586c2ece -r 6169eae54bd4 templates/progops.c --- a/templates/progops.c Sat Feb 02 17:54:42 2019 +0100 +++ b/templates/progops.c Mon Feb 04 18:30:52 2019 +0100 @@ -314,9 +314,17 @@ int __BOOL(__attr attr) { - /* Invoke the bool function with the object and test against True. */ + __ref value; + + /* Integers can be used directly as truth values. */ - __ref value = __VALUE(attr); + if (__INTEGER(attr)) + return __TOINT(attr); + + /* Test against True and False explicitly. If necessary, invoke the bool + function with the object and test against True. */ + + value = attr.value; return value == (__ref) &__predefined___builtins___boolean_True ? 1 : value == (__ref) &__predefined___builtins___boolean_False ? 0 :