diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2021-08-07 14:48:32 +0100 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2021-09-10 20:08:40 +0100 |
commit | 1d0d673f78c5c03a0f3c97ceeb7686e9388e0611 (patch) | |
tree | 388abd531263b971a0bfa2762402a33a3c0148ca /inline.h | |
parent | 914bb57489325d34ddbb7c0557c53df7baa84d86 (diff) | |
download | perl-1d0d673f78c5c03a0f3c97ceeb7686e9388e0611.tar.gz |
Add SvIsBOOL() macro to test for SVs being boolean-intent
These are identified as being static shared COW strings whose string
buffer points directly at PL_Yes / PL_No
Define sv_setbool() and sv_setbool_mg() macros
Use sv_setbool() where appropriate
Have sv_dump() annotate when an SV's PV buffer is one of the PL_(Yes|No) special booleans
Diffstat (limited to 'inline.h')
-rw-r--r-- | inline.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -3407,6 +3407,13 @@ Perl_mortal_getenv(const char * str) return ret; } +PERL_STATIC_INLINE bool +Perl_sv_isbool(pTHX_ const SV *sv) +{ + return SvIOK(sv) && SvPOK(sv) && SvIsCOW_static(sv) && + (SvPVX_const(sv) == PL_Yes || SvPVX_const(sv) == PL_No); +} + /* * ex: set ts=8 sts=4 sw=4 et: */ |