summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2012-11-17 12:58:12 +0100
committerYves Orton <demerphq@gmail.com>2012-11-17 12:58:12 +0100
commitee98d22d3f83f14ecaaaefd176f9630c0f262afd (patch)
tree74968e13ed853b793cd2aa2ad5596ffb552ea412
parentba593adc2b8b59175ac3c28b7b41aef7a74908e2 (diff)
downloadperl-ee98d22d3f83f14ecaaaefd176f9630c0f262afd.tar.gz
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.
-rw-r--r--regcharclass.h6
-rwxr-xr-xregen/regcharclass.pl9
2 files changed, 9 insertions, 6 deletions
diff --git a/regcharclass.h b/regcharclass.h
index 17dee91816..c977a56c3b 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 b7dddd2efc..944f61b976 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;
}