Integrate mainline
Nick Ing-Simmons [Sun, 28 Apr 2002 07:19:01 +0000 (07:19 +0000)]
p4raw-id: //depot/perlio@16243

1  2 
ext/Encode/Encode.xs

@@@ -157,33 -159,35 +159,35 @@@ encode_method(pTHX_ encode_t * enc, enc
                        sdone += slen + clen;
                        ddone += dlen + SvCUR(xmlcref);
                        sv_catsv(dst, xmlcref);
 -                  } else { 
 +                  } else {
                        /* fallback char */
                        sdone += slen + clen;
 -                      ddone += dlen + enc->replen; 
 -                      sv_catpvn(dst, (char*)enc->rep, enc->replen); 
 +                      ddone += dlen + enc->replen;
 +                      sv_catpvn(dst, (char*)enc->rep, enc->replen);
                    }                   
 -              } 
 +              }
            }
            /* decoding */
 -          else {           
 +          else {
                if (check & ENCODE_DIE_ON_ERR){
                    Perl_croak(
-                       aTHX_ "%s \"\\x%02X\" does not map to Unicode (%d)",
 -                      aTHX_ "%s \"\\x%02" UVXf 
++                      aTHX_ "%s \"\\x%02" UVXf
+                       "\" does not map to Unicode (%d)",
                        enc->name[0], (U8) s[slen], code);
                }else{
                    if (check & ENCODE_RETURN_ON_ERR){
                        if (check & ENCODE_WARN_ON_ERR){
                            Perl_warner(
                                aTHX_ packWARN(WARN_UTF8),
-                               "%s \"\\x%02X\" does not map to Unicode (%d)",
 -                              "%s \"\\x%02" UVXf 
++                              "%s \"\\x%02" UVXf
+                               "\" does not map to Unicode (%d)",
                                enc->name[0], (U8) s[slen], code);
                        }
                        goto ENCODE_SET_SRC;
 -                  }else if (check & 
 +                  }else if (check &
                              (ENCODE_PERLQQ|ENCODE_HTMLCREF|ENCODE_XMLCREF)){
 -                      SV* perlqq = 
 +                      SV* perlqq =
-                           sv_2mortal(newSVpvf("\\x%02X", s[slen]));
+                           sv_2mortal(newSVpvf("\\x%02" UVXf, s[slen]));
                        sdone += slen + 1;
                        ddone += dlen + SvCUR(perlqq);
                        sv_catsv(dst, perlqq);
        SvCUR_set(src, sdone);
      }
      /* warn("check = 0x%X, code = 0x%d\n", check, code); */
-     if (code && !(check & ENCODE_RETURN_ON_ERR)) {
-       return &PL_sv_undef;
-     }
 -    
 +
      SvCUR_set(dst, dlen+ddone);
      SvPOK_only(dst);
 -    
 +
  #if ENCODE_XS_PROFILE
      if (SvCUR(dst) > SvCUR(src)){
        Perl_warn(aTHX_