This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
SvTRUE(): add code comment
authorDavid Mitchell <davem@iabyn.com>
Fri, 4 Aug 2017 08:48:06 +0000 (09:48 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 4 Aug 2017 08:48:06 +0000 (09:48 +0100)
explain that the '!= 0' is acting as a bool cast (since SvTRUE() is
supposed to return a bool value rather than an int value).

sv.h

diff --git a/sv.h b/sv.h
index 198d1d1..a31bd73 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -1775,7 +1775,7 @@ Like C<sv_utf8_upgrade>, but doesn't do magic on C<sv>.
     : SvPOK(sv)                                                \
        ? SvPVXtrue(sv)                                 \
     : SvIOK(sv)                                                \
-        ? (SvIVX(sv) != 0)                              \
+        ? (SvIVX(sv) != 0 /* cast to bool */)           \
     : (SvROK(sv) && !(   SvOBJECT(SvRV(sv))             \
                       && HvAMAGIC(SvSTASH(SvRV(sv)))))  \
         ? TRUE                                          \