Replace two ugly casts in reg_recode() calls.
authorJarkko Hietaniemi <jhi@iki.fi>
Tue, 27 Oct 2015 01:38:09 +0000 (21:38 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 27 Oct 2015 11:02:05 +0000 (07:02 -0400)
With one ugly cast inside the reg_recode() call.

embed.fnc
proto.h
regcomp.c

index 096a92e..c7dfead 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2143,7 +2143,7 @@ Es        |regnode*|handle_regex_sets|NN RExC_state_t *pRExC_state \
                                |NN char * const oregcomp_parse
 Es     |void|parse_lparen_question_flags|NN RExC_state_t *pRExC_state
 Es     |regnode*|reg_node      |NN RExC_state_t *pRExC_state|U8 op
-Es     |UV     |reg_recode     |const char value|NN SV **encp
+Es     |UV     |reg_recode     |const U8 value|NN SV **encp
 Es     |regnode*|regpiece      |NN RExC_state_t *pRExC_state \
                                |NN I32 *flagp|U32 depth
 Es     |bool   |grok_bslash_N  |NN RExC_state_t *pRExC_state               \
diff --git a/proto.h b/proto.h
index 7d7fe88..210d013 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -4753,7 +4753,7 @@ STATIC regnode*   S_reg2Lanode(pTHX_ RExC_state_t *pRExC_state, const U8 op, const
 STATIC regnode*        S_reg_node(pTHX_ RExC_state_t *pRExC_state, U8 op);
 #define PERL_ARGS_ASSERT_REG_NODE      \
        assert(pRExC_state)
-STATIC UV      S_reg_recode(pTHX_ const char value, SV **encp);
+STATIC UV      S_reg_recode(pTHX_ const U8 value, SV **encp);
 #define PERL_ARGS_ASSERT_REG_RECODE    \
        assert(encp)
 STATIC SV *    S_reg_scan_name(pTHX_ RExC_state_t *pRExC_state, U32 flags);
index e4cb083..b170c4d 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11423,10 +11423,10 @@ S_grok_bslash_N(pTHX_ RExC_state_t *pRExC_state,
  * it returns U+FFFD (Replacement character) and sets *encp to NULL.
  */
 STATIC UV
-S_reg_recode(pTHX_ const char value, SV **encp)
+S_reg_recode(pTHX_ const U8 value, SV **encp)
 {
     STRLEN numlen = 1;
-    SV * const sv = newSVpvn_flags(&value, numlen, SVs_TEMP);
+    SV * const sv = newSVpvn_flags((const char *) &value, numlen, SVs_TEMP);
     const char * const s = *encp ? sv_recode_to_utf8(sv, *encp) : SvPVX(sv);
     const STRLEN newlen = SvCUR(sv);
     UV uv = UNICODE_REPLACEMENT;
@@ -12617,7 +12617,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                      recode_encoding:
                        if (! RExC_override_recoding) {
                            SV* enc = _get_encoding();
-                           ender = reg_recode((const char)(U8)ender, &enc);
+                           ender = reg_recode((U8)ender, &enc);
                            if (!enc && PASS2)
                                ckWARNreg(p, "Invalid escape in the specified encoding");
                            REQUIRE_UTF8(flagp);
@@ -14905,7 +14905,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth,
              recode_encoding:
                if (! RExC_override_recoding) {
                    SV* enc = _get_encoding();
-                   value = reg_recode((const char)(U8)value, &enc);
+                   value = reg_recode((U8)value, &enc);
                    if (!enc) {
                         if (strict) {
                             vFAIL("Invalid escape in the specified encoding");