regcomp.c: Add parameter to regclass()
authorKarl Williamson <public@khwilliamson.com>
Thu, 10 Jan 2013 22:15:21 +0000 (15:15 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 11 Jan 2013 18:50:37 +0000 (11:50 -0700)
This parameter silences warnings for non-portable characters.  It
currently is always FALSE, meaning that warnings are given.

embed.fnc
embed.h
proto.h
regcomp.c

index 4d1d81f..c781b75 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1961,7 +1961,8 @@ Es        |STRLEN |reguni         |NN const struct RExC_state_t *pRExC_state \
                                |UV uv|NN char *s
 Es     |regnode*|regclass      |NN struct RExC_state_t *pRExC_state \
                                |NN I32 *flagp|U32 depth|const bool stop_at_1 \
-                               |bool allow_multi_fold
+                               |bool allow_multi_fold                        \
+                               |const bool silence_non_portable
 Es     |regnode*|reg_node      |NN struct RExC_state_t *pRExC_state|U8 op
 Es     |UV     |reg_recode     |const char value|NN SV **encp
 Es     |regnode*|regpiece      |NN struct RExC_state_t *pRExC_state \
diff --git a/embed.h b/embed.h
index 3f4034e..5bae00e 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define reganode(a,b,c)                S_reganode(aTHX_ a,b,c)
 #define regatom(a,b,c)         S_regatom(aTHX_ a,b,c)
 #define regbranch(a,b,c,d)     S_regbranch(aTHX_ a,b,c,d)
-#define regclass(a,b,c,d,e)    S_regclass(aTHX_ a,b,c,d,e)
+#define regclass(a,b,c,d,e,f)  S_regclass(aTHX_ a,b,c,d,e,f)
 #define reginsert(a,b,c,d)     S_reginsert(aTHX_ a,b,c,d)
 #define regpiece(a,b,c)                S_regpiece(aTHX_ a,b,c)
 #define regpposixcc(a,b,c)     S_regpposixcc(aTHX_ a,b,c)
diff --git a/proto.h b/proto.h
index 9bb1228..37ceea3 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6639,7 +6639,7 @@ STATIC regnode*   S_regbranch(pTHX_ struct RExC_state_t *pRExC_state, I32 *flagp,
 #define PERL_ARGS_ASSERT_REGBRANCH     \
        assert(pRExC_state); assert(flagp)
 
-STATIC regnode*        S_regclass(pTHX_ struct RExC_state_t *pRExC_state, I32 *flagp, U32 depth, const bool stop_at_1, bool allow_multi_fold)
+STATIC regnode*        S_regclass(pTHX_ struct RExC_state_t *pRExC_state, I32 *flagp, U32 depth, const bool stop_at_1, bool allow_multi_fold, const bool silence_non_portable)
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2);
 #define PERL_ARGS_ASSERT_REGCLASS      \
index 5c52f77..0f25df7 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -10107,7 +10107,8 @@ tryagain:
        char * const oregcomp_parse = ++RExC_parse;
         ret = regclass(pRExC_state, flagp,depth+1,
                        FALSE, /* means parse the whole char class */
-                       TRUE); /* allow multi-char folds */
+                       TRUE, /* allow multi-char folds */
+                       FALSE); /* don't silence non-portable warnings. */
        if (*RExC_parse != ']') {
            RExC_parse = oregcomp_parse;
            vFAIL("Unmatched [");
@@ -10303,7 +10304,10 @@ tryagain:
 
                 ret = regclass(pRExC_state, flagp,depth+1,
                                TRUE, /* means just parse this element */
-                               FALSE); /* don't allow multi-char folds */
+                               FALSE, /* don't allow multi-char folds */
+                               FALSE); /* don't silence non-portable warnings.
+                                         It would be a bug if these returned
+                                         non-portables */
 
                RExC_parse--;
 
@@ -11232,7 +11236,8 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value, SV *free_me)
 
 STATIC regnode *
 S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
-                 const bool stop_at_1, bool allow_multi_folds)
+                 const bool stop_at_1, bool allow_multi_folds,
+                 const bool silence_non_portable)
 {
     /* parse a bracketed class specification.  Most of these will produce an ANYOF node;
      * but something like [a] will produce an EXACT node; [aA], an EXACTFish
@@ -11585,8 +11590,7 @@ parseit:
                                               &error_msg,
                                               SIZE_ONLY,
                                                FALSE, /* Not strict */
-                                               TRUE, /* Output warnings for
-                                                         non-portables */
+                                               silence_non_portable,
                                                UTF);
                    if (! valid) {
                        vFAIL(error_msg);
@@ -11605,8 +11609,7 @@ parseit:
                                               &error_msg,
                                               TRUE, /* Output warnings */
                                                FALSE, /* Not strict */
-                                               TRUE, /* Output warnings for
-                                                         non-portables */
+                                               silence_non_portable,
                                                UTF);
                    if (! valid) {
                        vFAIL(error_msg);