summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-09-22 11:41:34 -0400
committerKevin Newton <kddnewton@gmail.com>2023-09-27 12:10:23 -0400
commitbe861053c5e19783d75c1d2cd66d6007b9ba5072 (patch)
treee573001ddb51ef5e479c35e2a56716ec1b0da9ba
parent2bc243b3dcd10d6de3efd80c3e91413d83b476fe (diff)
[ruby/yarp] Use less magical numbers for regular expression flags
https://github.com/ruby/yarp/commit/c6a0abdd24
-rw-r--r--lib/yarp.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/yarp.rb b/lib/yarp.rb
index 1a663bf702..41b71811b6 100644
--- a/lib/yarp.rb
+++ b/lib/yarp.rb
@@ -592,7 +592,7 @@ module YARP
# Returns a numeric value that represents the flags that were used to create
# the regular expression.
def options
- o = flags & 0b111
+ o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
o
@@ -610,7 +610,7 @@ module YARP
# Returns a numeric value that represents the flags that were used to create
# the regular expression.
def options
- o = flags & 0b111
+ o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
o