diff options
author | Nicholas Clark <nick@ccl4.org> | 2003-01-17 19:40:45 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-01-22 12:34:06 +0000 |
commit | 906ed6d684efe07b1689c9b36fd4e093243a24dc (patch) | |
tree | 548236b0e51d1b148f04840407f493ba401a9801 /sv.h | |
parent | dbc2e2f5b50305115fcf8ccedc2a968a39d143d8 (diff) | |
download | perl-906ed6d684efe07b1689c9b36fd4e093243a24dc.tar.gz |
assert PV isn't RV
Message-ID: <20030117194044.GB297@Bagpuss.unfortu.net>
p4raw-id: //depot/perl@18552
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -514,11 +514,19 @@ Set the length of the string which is in the SV. See C<SvCUR>. #define SvNIOK_off(sv) (SvFLAGS(sv) &= ~(SVf_IOK|SVf_NOK| \ SVp_IOK|SVp_NOK|SVf_IVisUV)) +#ifdef __GNUC__ +#define assert_not_ROK(sv) ({assert(!SvROK(sv) || !SvRV(sv))}) +#else +#define assert_not_ROK(sv) 0 +#endif + #define SvOK(sv) (SvFLAGS(sv) & SVf_OK) -#define SvOK_off(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ +#define SvOK_off(sv) (assert_not_ROK(sv), \ + SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ SVf_IVisUV|SVf_UTF8), \ SvOOK_off(sv)) -#define SvOK_off_exc_UV(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ +#define SvOK_off_exc_UV(sv) (assert_not_ROK(sv), \ + SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ SVf_UTF8), \ SvOOK_off(sv)) @@ -529,7 +537,8 @@ Set the length of the string which is in the SV. See C<SvCUR>. #define SvNOKp(sv) (SvFLAGS(sv) & SVp_NOK) #define SvNOKp_on(sv) (SvFLAGS(sv) |= SVp_NOK) #define SvPOKp(sv) (SvFLAGS(sv) & SVp_POK) -#define SvPOKp_on(sv) (SvFLAGS(sv) |= SVp_POK) +#define SvPOKp_on(sv) (assert_not_ROK(sv), \ + SvFLAGS(sv) |= SVp_POK) #define SvIOK(sv) (SvFLAGS(sv) & SVf_IOK) #define SvIOK_on(sv) (SvRELEASE_IVX(sv), \ @@ -579,12 +588,15 @@ and leaves the UTF8 status as it was. #define SvUTF8_off(sv) (SvFLAGS(sv) &= ~(SVf_UTF8)) #define SvPOK(sv) (SvFLAGS(sv) & SVf_POK) -#define SvPOK_on(sv) (SvFLAGS(sv) |= (SVf_POK|SVp_POK)) +#define SvPOK_on(sv) (assert_not_ROK(sv), \ + SvFLAGS(sv) |= (SVf_POK|SVp_POK)) #define SvPOK_off(sv) (SvFLAGS(sv) &= ~(SVf_POK|SVp_POK)) -#define SvPOK_only(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ +#define SvPOK_only(sv) (assert_not_ROK(sv), \ + SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ SVf_IVisUV|SVf_UTF8), \ SvFLAGS(sv) |= (SVf_POK|SVp_POK)) -#define SvPOK_only_UTF8(sv) (SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ +#define SvPOK_only_UTF8(sv) (assert_not_ROK(sv), \ + SvFLAGS(sv) &= ~(SVf_OK|SVf_AMAGIC| \ SVf_IVisUV), \ SvFLAGS(sv) |= (SVf_POK|SVp_POK)) |