In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/11f9ab1a291e36ad40cb66d0bd0aedce897c06c3?hp=679f225298d1387d98096620b81b27724e70766c>
- Log ----------------------------------------------------------------- commit 11f9ab1a291e36ad40cb66d0bd0aedce897c06c3 Author: Tony Cook <[email protected]> Date: Wed Nov 12 13:53:48 2014 +1100 [perl #123063] allow assert() to be used as an expression In non-DEBUGGING builds it would be replaced with nothing, producing a syntax error ----------------------------------------------------------------------- Summary of changes: ext/XS-APItest/APItest.xs | 7 +++++++ perl.h | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index a3810b5..9f8e0a3 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -1256,6 +1256,13 @@ INCLUDE: const-xs.inc INCLUDE: numeric.xs +void +assertx(int x) + CODE: + /* this only needs to compile and checks that assert() can be + used this way syntactically */ + (assert(x),1); + MODULE = XS::APItest::utf8 PACKAGE = XS::APItest::utf8 int diff --git a/perl.h b/perl.h index 55918d0..193458c 100644 --- a/perl.h +++ b/perl.h @@ -4035,6 +4035,7 @@ Gid_t getegid (void); # define DEBUG_Pv_TEST DEBUG_Pv_TEST_ # define PERL_DEB(a) a +# define PERL_DEB2(a,b) a # define PERL_DEBUG(a) if (PL_debug) a # define DEBUG_p(a) if (DEBUG_p_TEST) a # define DEBUG_s(a) if (DEBUG_s_TEST) a @@ -4117,6 +4118,7 @@ Gid_t getegid (void); # define DEBUG_Pv_TEST (0) # define PERL_DEB(a) +# define PERL_DEB2(a,b) b # define PERL_DEBUG(a) # define DEBUG_p(a) # define DEBUG_s(a) @@ -4159,11 +4161,11 @@ Gid_t getegid (void); /* Keep the old croak based assert for those who want it, and as a fallback if the platform is so heretically non-ANSI that it can't assert. */ -#define Perl_assert(what) PERL_DEB( \ +#define Perl_assert(what) PERL_DEB2( \ ((what) ? ((void) 0) : \ (Perl_croak_nocontext("Assertion %s failed: file \"" __FILE__ \ "\", line %d", STRINGIFY(what), __LINE__), \ - (void) 0))) + (void) 0)), ((void)0)) /* assert() gets defined if DEBUGGING (and I_ASSERT). * If no DEBUGGING, the <assert.h> has not been included. */ -- Perl5 Master Repository
