From ee98d22d3f83f14ecaaaefd176f9630c0f262afd Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Sat, 17 Nov 2012 12:58:12 +0100 Subject: [PATCH] Eliminate test from generated cp macros Sayeth Karl: In the _cp macros, the final test can be simplified: /*** GENERATED CODE ***/ #define is_VERTWS_cp(cp) \ ( ( 0x0A <= cp && cp <= 0x0D ) || ( 0x0D < cp && \ ( 0x85 == cp || ( 0x85 < cp && \ ( 0x2028 == cp || ( 0x2028 < cp && \ 0x2029 == cp ) ) ) ) ) ) That 0x2028 < cp can be omitted and it will still mean the same thing. And So Be It. --- regcharclass.h | 6 ++---- regen/regcharclass.pl | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/regcharclass.h b/regcharclass.h index 17dee91..c977a56 100644 --- a/regcharclass.h +++ b/regcharclass.h @@ -210,8 +210,7 @@ ( 0x180E == cp || ( 0x180E < cp && \ ( ( 0x2000 <= cp && cp <= 0x200A ) || ( 0x200A < cp && \ ( 0x202F == cp || ( 0x202F < cp && \ -( 0x205F == cp || ( 0x205F < cp && \ -0x3000 == cp ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) +( 0x205F == cp || 0x3000 == cp ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) /* VERTWS: Vertical Whitespace: \v \V @@ -283,8 +282,7 @@ #define is_VERTWS_cp(cp) \ ( ( 0x0A <= cp && cp <= 0x0D ) || ( 0x0D < cp && \ ( 0x85 == cp || ( 0x85 < cp && \ -( 0x2028 == cp || ( 0x2028 < cp && \ -0x2029 == cp ) ) ) ) ) ) +( 0x2028 == cp || 0x2029 == cp ) ) ) ) ) /* REPLACEMENT: Unicode REPLACEMENT CHARACTER diff --git a/regen/regcharclass.pl b/regen/regcharclass.pl index b7dddd2..944f61b 100755 --- a/regen/regcharclass.pl +++ b/regen/regcharclass.pl @@ -1076,8 +1076,13 @@ sub _combine { $gtv= sprintf "$self->{val_fmt}", $item; } if ( @cond ) { - return "( $cstr || ( $gtv < $test &&\n" - . $self->_combine( $test, @cond ) . " ) )"; + my $combine= $self->_combine( $test, @cond ); + if (@cond >1) { + return "( $cstr || ( $gtv < $test &&\n" + . $combine . " ) )"; + } else { + return "( $cstr || $combine )"; + } } else { return $cstr; } -- 2.7.4