This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove duplicate $VERSION handling code, made redundant in 3.28_01
[perl5.git] / universal.c
index 08f9ab8..35d1bcc 100644 (file)
@@ -290,7 +290,7 @@ XS(XS_UNIVERSAL_DOES)
     PERL_UNUSED_ARG(cv);
 
     if (items != 2)
-       Perl_croak(aTHX_ "Usage: invocand->DOES(kind)");
+       Perl_croak(aTHX_ "Usage: invocant->DOES(kind)");
     else {
        SV * const sv = ST(0);
        const char *name;
@@ -695,9 +695,10 @@ XS(XS_utf8_decode)
        croak_xs_usage(cv, "sv");
     else {
        SV * const sv = ST(0);
-       const bool RETVAL = sv_utf8_decode(sv);
+       bool RETVAL;
+       if (SvIsCOW(sv)) sv_force_normal(sv);
+       RETVAL = sv_utf8_decode(sv);
        ST(0) = boolSV(RETVAL);
-       sv_2mortal(ST(0));
     }
     XSRETURN(1);
 }
@@ -731,7 +732,6 @@ XS(XS_utf8_downgrade)
         const bool RETVAL = sv_utf8_downgrade(sv, failok);
 
        ST(0) = boolSV(RETVAL);
-       sv_2mortal(ST(0));
     }
     XSRETURN(1);
 }
@@ -1155,8 +1155,7 @@ XS(XS_re_regexp_pattern)
 
         if ( GIMME_V == G_ARRAY ) {
            STRLEN left = 0;
-           char reflags[sizeof(INT_PAT_MODS) + 1]; /* The +1 is for the charset
-                                                       modifier */
+           char reflags[sizeof(INT_PAT_MODS) + MAX_CHARSET_NAME_LENGTH];
             const char *fptr;
             char ch;
             U16 match_flags;
@@ -1164,17 +1163,18 @@ XS(XS_re_regexp_pattern)
             /*
                we are in list context so stringify
                the modifiers that apply. We ignore "negative
-               modifiers" in this scenario.
+               modifiers" in this scenario, and the default character set
             */
 
-            if (RX_EXTFLAGS(re) & RXf_PMf_LOCALE) {
-               reflags[left++] = LOCALE_PAT_MOD;
-           }
-           else if (RX_EXTFLAGS(re) & RXf_PMf_UNICODE) {
-               reflags[left++] = UNICODE_PAT_MOD;
+           if (get_regex_charset(RX_EXTFLAGS(re)) != REGEX_DEPENDS_CHARSET) {
+               STRLEN len;
+               const char* const name = get_regex_charset_name(RX_EXTFLAGS(re),
+                                                               &len);
+               Copy(name, reflags + left, len, char);
+               left += len;
            }
             fptr = INT_PAT_MODS;
-            match_flags = (U16)((RX_EXTFLAGS(re) & PMf_COMPILETIME)
+            match_flags = (U16)((RX_EXTFLAGS(re) & RXf_PMf_COMPILETIME)
                                     >> RXf_PMf_STD_PMMOD_SHIFT);
 
             while((ch = *fptr++)) {