Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATCH: /d not overriding /u #10752

Closed
p5pRT opened this issue Oct 21, 2010 · 6 comments
Closed

PATCH: /d not overriding /u #10752

p5pRT opened this issue Oct 21, 2010 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 21, 2010

Migrated from rt.perl.org#78508 (status was 'resolved')

Searchable as RT78508$

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

From @khwilliamson

It turns out that the code to set the charset in a regex is flawed.
Once set, a flag could not be cleared.

Patch attached

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

From @khwilliamson

0002-regcomp.c-Fix-typo-in-comment.patch
From fe4ca68626f9e104df23f2e3fbc488a0c2a80169 Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Sun, 17 Oct 2010 10:38:37 -0600
Subject: [PATCH] regcomp.c: Fix typo in comment

---
 regcomp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index e0f65fa..b5493f4 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -8819,7 +8819,7 @@ S_reg_skipcomment(pTHX_ RExC_state_t *pRExC_state)
 
 /* nextchar()
 
-   Advance that parse position, and optionall absorbs
+   Advance that parse position, and optionally absorbs
    "whitespace" from the inputstream.
 
    Without /x "whitespace" means (?#...) style comments only,
-- 
1.5.6.3

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

From @khwilliamson

0003-regcomp.c-d-not-overriding-u.patch
From b255f6b9db66c7c4ecb69a290aa31ceff732ca03 Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Wed, 20 Oct 2010 13:21:04 -0600
Subject: [PATCH] regcomp.c: /d not overriding /u

The setting of the charset regex modifiers was wrong.  /d didn't
override /u nor /l, and similarly /u and /l didn't properly override
each other.
---
 regcomp.c  |   10 +++++-----
 t/re/pat.t |   11 ++++++++++-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index b5493f4..831d579 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6238,16 +6238,16 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                         if (has_charset_modifier || flagsp == &negflags) {
                             goto fail_modifiers;
                         }
-                        *flagsp &= ~RXf_PMf_UNICODE;
-                        *flagsp |= RXf_PMf_LOCALE;
+                        posflags |= RXf_PMf_LOCALE;
+                        negflags |= RXf_PMf_UNICODE;
                         has_charset_modifier = 1;
                         break;
                     case UNICODE_PAT_MOD:
                         if (has_charset_modifier || flagsp == &negflags) {
                             goto fail_modifiers;
                         }
-                        *flagsp &= ~RXf_PMf_LOCALE;
-                        *flagsp |= RXf_PMf_UNICODE;
+                        posflags |= RXf_PMf_UNICODE;
+                        negflags |= RXf_PMf_LOCALE;
                         has_charset_modifier = 1;
                         break;
                     case DUAL_PAT_MOD:
@@ -6257,7 +6257,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                         {
                             goto fail_modifiers;
                         }
-                        *flagsp &= ~(RXf_PMf_LOCALE|RXf_PMf_UNICODE);
+                        negflags |= (RXf_PMf_LOCALE|RXf_PMf_UNICODE);
                         has_charset_modifier = 1;
                         break;
                     case ONCE_PAT_MOD: /* 'o' */
diff --git a/t/re/pat.t b/t/re/pat.t
index bb60999..1bbb73a 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -23,7 +23,7 @@ BEGIN {
 }
 
 
-plan tests => 406;  # Update this when adding/deleting tests.
+plan tests => 408;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1088,6 +1088,15 @@ sub run_tests {
         ok $c =~ /$utf8_pattern/i, "\\xc0 =~ /$pattern/i; Both target and pattern utf8";
     }
 
+    SKIP: {   # Make sure can override the formatting
+        if ($IS_EBCDIC) {
+            skip "Needs to be customized to run on EBCDIC", 2;
+        }
+        use feature 'unicode_strings';
+        ok "\xc0" =~ /\w/, 'Under unicode_strings: "\xc0" =~ /\w/';
+        ok "\xc0" !~ /(?d:\w)/, 'Under unicode_strings: "\xc0" !~ /(?d:\w)/';
+    }
+
     {
         # Test that a regex followed by an operator and/or a statement modifier work
         # These tests use string-eval so that it reports a clean error when it fails
-- 
1.5.6.3

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

From @cpansprout

On Thu Oct 21 11​:44​:28 2010, public@​khwilliamson.com wrote​:

It turns out that the code to set the charset in a regex is flawed.
Once set, a flag could not be cleared.

Patch attached

Thank you. Applied as f6e17a8 and
8cc8659.

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2010

@cpansprout - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant